diff --git a/api-generator/api-generator.js b/api-generator/api-generator.js index 71be9c0d..9339004d 100644 --- a/api-generator/api-generator.js +++ b/api-generator/api-generator.js @@ -48,13 +48,22 @@ async function main() { let doc = {}; let typesMap = {}; - const parseText = (text) => { - return text.replace(/{/g, '{').replace(/}/g, '}'); + const parseText = (content) => { + if (content.kind === 'text') { + return content.text.replace(/{/g, '{').replace(/}/g, '}'); + } else if (content.kind === 'code') { + return content.text.replace(/^```ts\n/g, '').replace(/\n```$/g, ''); + } }; const getDeprecatedText = (signature) => { const deprecatedTag = signature?.comment?.getTag('@deprecated'); - return deprecatedTag ? parseText(deprecatedTag.content[0].text) : undefined; + return deprecatedTag ? parseText(deprecatedTag.content[0]) : undefined; + }; + + const getDefaultValue = (signature) => { + const defaultValueTag = signature?.comment?.getTag('@default') ?? signature?.comment?.getTag('@defaultValue'); + return defaultValueTag ? parseText(defaultValueTag.content[0]) : undefined; }; const modules = project.groups.find((g) => g.title === 'Modules'); @@ -127,13 +136,13 @@ async function main() { ? prop.type.toString() : null, default: - prop.type && + (prop.type && prop.type.name === 'boolean' && !prop.defaultValue ? 'false' : prop.defaultValue ? prop.defaultValue.replace(/^'|'$/g, '') - : undefined, + : undefined) ?? getDefaultValue(prop.setSignature) ?? getDefaultValue(prop.getSignature), description: ((prop.getSignature?.comment?.summary || prop.setSignature?.comment?.summary) || prop.comment?.summary)?.map((s) => s.text || '').join(' '), deprecated: getDeprecatedText(prop.getSignature) || getDeprecatedText(prop.setSignature) diff --git a/projects/composition/src/app/api-data/cps-checkbox.json b/projects/composition/src/app/api-data/cps-checkbox.json index 6b516977..3b70c0de 100644 --- a/projects/composition/src/app/api-data/cps-checkbox.json +++ b/projects/composition/src/app/api-data/cps-checkbox.json @@ -82,6 +82,7 @@ "optional": false, "readonly": false, "type": "boolean", + "default": "false", "description": "Value of the checkbox." } ] diff --git a/projects/composition/src/app/api-data/cps-datepicker.json b/projects/composition/src/app/api-data/cps-datepicker.json index 96a1764e..193b5e50 100644 --- a/projects/composition/src/app/api-data/cps-datepicker.json +++ b/projects/composition/src/app/api-data/cps-datepicker.json @@ -152,6 +152,7 @@ "optional": false, "readonly": false, "type": "null | Date", + "default": "null", "description": "Value of the datepicker." } ] diff --git a/projects/composition/src/app/api-data/cps-input.json b/projects/composition/src/app/api-data/cps-input.json index 84e3eab6..5efab3bd 100644 --- a/projects/composition/src/app/api-data/cps-input.json +++ b/projects/composition/src/app/api-data/cps-input.json @@ -194,6 +194,7 @@ "optional": false, "readonly": false, "type": "string", + "default": "''", "description": "Value of the input." } ] diff --git a/projects/composition/src/app/api-data/cps-switch.json b/projects/composition/src/app/api-data/cps-switch.json index 56527819..49f80ab7 100644 --- a/projects/composition/src/app/api-data/cps-switch.json +++ b/projects/composition/src/app/api-data/cps-switch.json @@ -66,6 +66,7 @@ "optional": false, "readonly": false, "type": "boolean", + "default": "false", "description": "Value of the switch component." } ] diff --git a/projects/composition/src/app/api-data/cps-tab-group.json b/projects/composition/src/app/api-data/cps-tab-group.json index c161654d..74dab187 100644 --- a/projects/composition/src/app/api-data/cps-tab-group.json +++ b/projects/composition/src/app/api-data/cps-tab-group.json @@ -10,6 +10,7 @@ "optional": false, "readonly": false, "type": "number", + "default": "0", "description": "Index of the selected tab." }, { diff --git a/projects/composition/src/app/api-data/cps-table.json b/projects/composition/src/app/api-data/cps-table.json index 8b577aff..68e86749 100644 --- a/projects/composition/src/app/api-data/cps-table.json +++ b/projects/composition/src/app/api-data/cps-table.json @@ -498,6 +498,7 @@ "optional": false, "readonly": false, "type": "any[]", + "default": "[]", "description": "An array of objects to display." } ] diff --git a/projects/composition/src/app/api-data/cps-tag.json b/projects/composition/src/app/api-data/cps-tag.json index 6f599f7e..4c16ad2c 100644 --- a/projects/composition/src/app/api-data/cps-tag.json +++ b/projects/composition/src/app/api-data/cps-tag.json @@ -42,6 +42,7 @@ "optional": false, "readonly": false, "type": "boolean", + "default": "false", "description": "Tag value." } ] diff --git a/projects/composition/src/app/api-data/cps-textarea.json b/projects/composition/src/app/api-data/cps-textarea.json index 2327f0ff..3c176d3b 100644 --- a/projects/composition/src/app/api-data/cps-textarea.json +++ b/projects/composition/src/app/api-data/cps-textarea.json @@ -154,6 +154,7 @@ "optional": false, "readonly": false, "type": "string", + "default": "''", "description": "Value of the textarea." } ] diff --git a/projects/composition/src/app/api-data/cps-tree-table.json b/projects/composition/src/app/api-data/cps-tree-table.json index 7bde6384..592f07f2 100644 --- a/projects/composition/src/app/api-data/cps-tree-table.json +++ b/projects/composition/src/app/api-data/cps-tree-table.json @@ -482,6 +482,7 @@ "optional": false, "readonly": false, "type": "any[]", + "default": "[]", "description": "An array of objects to display." } ] diff --git a/projects/cps-ui-kit/src/lib/components/cps-checkbox/cps-checkbox.component.ts b/projects/cps-ui-kit/src/lib/components/cps-checkbox/cps-checkbox.component.ts index d7a83edb..0f9802dc 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-checkbox/cps-checkbox.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-checkbox/cps-checkbox.component.ts @@ -83,6 +83,7 @@ export class CpsCheckboxComponent implements OnInit, ControlValueAccessor { /** * Value of the checkbox. + * @default false * @group Props */ @Input() set value(value: boolean) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts b/projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts index 754677b4..c68a56b8 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-datepicker/cps-datepicker.component.ts @@ -159,6 +159,7 @@ export class CpsDatepickerComponent /** * Value of the datepicker. + * @default null * @group Props */ @Input() set value(value: Date | null) { @@ -190,7 +191,7 @@ export class CpsDatepickerComponent cvtWidth = ''; private _statusChangesSubscription?: Subscription; - private _value!: Date | null; + private _value: Date | null = null; constructor(@Self() @Optional() private _control: NgControl) { if (this._control) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-input/cps-input.component.ts b/projects/cps-ui-kit/src/lib/components/cps-input/cps-input.component.ts index aba5ab33..6b634b9a 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-input/cps-input.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-input/cps-input.component.ts @@ -190,6 +190,7 @@ export class CpsInputComponent /** * Value of the input. + * @default '' * @group Props */ @Input() set value(value: string) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.ts b/projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.ts index 210cc0d0..3124d2f0 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-switch/cps-switch.component.ts @@ -68,6 +68,7 @@ export class CpsSwitchComponent implements ControlValueAccessor { /** * Value of the switch component. + * @default false * @group Props */ @Input() set value(value: boolean) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-tab-group/cps-tab-group.component.ts b/projects/cps-ui-kit/src/lib/components/cps-tab-group/cps-tab-group.component.ts index 17cfb352..57e1c408 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-tab-group/cps-tab-group.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-tab-group/cps-tab-group.component.ts @@ -109,6 +109,7 @@ export class CpsTabGroupComponent { /** * Index of the selected tab. + * @default 0 * @group Props */ @Input() set selectedIndex(value: number) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-table/cps-table.component.ts b/projects/cps-ui-kit/src/lib/components/cps-table/cps-table.component.ts index f9ebcfd8..7808864b 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-table/cps-table.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-table/cps-table.component.ts @@ -465,6 +465,7 @@ export class CpsTableComponent implements OnInit, AfterViewChecked, OnChanges { /** * An array of objects to display. + * @default [] * @group Props */ @Input() set data(value: any[]) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-tag/cps-tag.component.ts b/projects/cps-ui-kit/src/lib/components/cps-tag/cps-tag.component.ts index 0ef9088c..c96f7009 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-tag/cps-tag.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-tag/cps-tag.component.ts @@ -49,6 +49,7 @@ export class CpsTagComponent implements ControlValueAccessor, OnChanges { /** * Tag value. + * @default false * @group Props */ @Input() set value(value: boolean) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-textarea/cps-textarea.component.ts b/projects/cps-ui-kit/src/lib/components/cps-textarea/cps-textarea.component.ts index e080bcf4..918c6a3c 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-textarea/cps-textarea.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-textarea/cps-textarea.component.ts @@ -141,6 +141,7 @@ export class CpsTextareaComponent /** * Value of the textarea. + * @default '' * @group Props */ @Input() set value(value: string) { diff --git a/projects/cps-ui-kit/src/lib/components/cps-tree-table/cps-tree-table.component.ts b/projects/cps-ui-kit/src/lib/components/cps-tree-table/cps-tree-table.component.ts index 339e92be..d8e1981e 100644 --- a/projects/cps-ui-kit/src/lib/components/cps-tree-table/cps-tree-table.component.ts +++ b/projects/cps-ui-kit/src/lib/components/cps-tree-table/cps-tree-table.component.ts @@ -471,6 +471,7 @@ export class CpsTreeTableComponent /** * An array of objects to display. + * @default [] * @group Props */ @Input() set data(value: any[]) {