From 77ebd0d1aa05f5d18155ffb2d64a20c0abdceb41 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sat, 17 Oct 2020 13:51:32 -0700 Subject: [PATCH] fix(parse-component): parse ArrayExpression --- COMPONENT_INDEX.md | 26 +++++++++++++------------- docs/src/PUBLIC_API.json | 13 +++++++++++++ scripts/rollup/parse-component.js | 5 ++++- types/index.d.ts | 13 +++++++++++++ 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 8a35bc48..294135ec 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -773,7 +773,7 @@ interface ComboBoxItem { | Prop name | Type | Default value | Description | | :--------------- | :---------------------------------------------------------- | :------------ | :------------------------------------------------------------------------ | -| items | ComboBoxItem[] | -- | Set the combobox items. | +| items | ComboBoxItem[] | `[]` | Set the combobox items. | | itemToString | (item: ComboBoxItem) => string | -- | Override the display of a combobox item. | | selectedIndex | number | -- | Set the selected item by value index. | | value | string | `""` | Specify the selected combobox value. | @@ -982,8 +982,8 @@ import { DataTable } from "carbon-components-svelte"; | Prop name | Type | Default value | Description | | :------------- | :-------------------------------------------------- | :------------ | :--------------------------------------------------------------------------------------------------- | -| headers | {key: string; value: string;}[] | -- | Specify the data table headers. | -| rows | Object[] | -- | Specify the rows the data table should render. keys defined in `headers` are used for the row ids. | +| headers | {key: string; value: string;}[] | `[]` | Specify the data table headers. | +| rows | Object[] | `[]` | Specify the rows the data table should render. keys defined in `headers` are used for the row ids. | | size | "compact" | "short" | "tall" | -- | Set the size of the data table. | | title | string | `""` | Specify the title of the data table. | | description | string | `""` | Specify the description of the data table. | @@ -991,7 +991,7 @@ import { DataTable } from "carbon-components-svelte"; | sortable | boolean | `false` | Set to `true` for the sortable variant. | | expandable | boolean | `false` | Set to `true` for the expandable variant. Automatically set to `true` if `batchExpansion` is `true`. | | batchExpansion | boolean | `false` | Set to `true` to enable batch expansion. | -| expandedRowIds | string[] | -- | Specify the row ids to be expanded. | +| expandedRowIds | string[] | `[]` | Specify the row ids to be expanded. | | stickyHeader | boolean | `false` | Set to `true` to enable a sticky header. | ### Slots @@ -1030,7 +1030,7 @@ import { DataTableSkeleton } from "carbon-components-svelte"; | size | "compact" | "short" | "tall" | -- | Set the size of the data table. | | zebra | boolean | `false` | Set to `true` to apply zebra styles to the datatable rows. | | showHeader | boolean | `true` | Set to `false` to hide the header. | -| headers | string[] | -- | Set the column headers. If `headers` has one more items, `count` is ignored. | +| headers | string[] | `[]` | Set the column headers. If `headers` has one more items, `count` is ignored. | | showToolbar | boolean | `true` | Set to `false` to hide the toolbar. | ### Slots @@ -1189,7 +1189,7 @@ interface DropdownItem { | Prop name | Type | Default value | Description | | :-------------- | :------------------------------------------ | :------------ | :--------------------------------------------- | -| items | DropdownItem[] | -- | Set the dropdown items. | +| items | DropdownItem[] | `[]` | Set the dropdown items. | | itemToString | (item: DropdownItem) => string | -- | Override the display of a dropdown item. | | selectedIndex | number | -- | Specify the selected item index. | | type | "default" | "inline" | `"default"` | Specify the type of dropdown. | @@ -1307,8 +1307,8 @@ import { FileUploader } from "carbon-components-svelte"; | Prop name | Type | Default value | Description | | :---------------------- | :----------------------------------------------------------------------------------------- | :--------------------------- | :--------------------------------------------------------------------- | | status | "uploading" | "edit" | "complete" | `"uploading"` | Specify the file uploader status. | -| accept | string[] | -- | Specify the accepted file types. | -| files | string[] | -- | Obtain the uploaded file names. | +| accept | string[] | `[]` | Specify the accepted file types. | +| files | string[] | `[]` | Obtain the uploaded file names. | | multiple | boolean | `false` | Set to `true` to allow multiple files. | | clearFiles (`constant`) | () => any | -- | Override the default behavior of clearing the array of uploaded files. | | labelDescription | string | `""` | Specify the label description. | @@ -1350,7 +1350,7 @@ import { FileUploaderButton } from "carbon-components-svelte"; | Prop name | Type | Default value | Description | | :------------------ | :----------------------------------------------------------------------------------------- | :------------ | :-------------------------------------------- | -| accept | string[] | -- | Specify the accepted file types. | +| accept | string[] | `[]` | Specify the accepted file types. | | multiple | boolean | `false` | Set to `true` to allow multiple files. | | disabled | boolean | `false` | Set to `true` to disable the input. | | disableLabelChanges | boolean | `false` | Set to `true` to disable label changes. | @@ -1396,7 +1396,7 @@ type Files = string[]; | Prop name | Type | Default value | Description | | :------------ | :---------------------------------------- | :------------ | :-------------------------------------------------------------------------------------------------------- | -| accept | string[] | -- | Specify the accepted file types. | +| accept | string[] | `[]` | Specify the accepted file types. | | multiple | boolean | `false` | Set to `true` to allow multiple files. | | validateFiles | (files: Files) => Files | -- | Override the default behavior of validating uploaded files. The default behavior does not validate files. | | labelText | string | `"Add file"` | Specify the label text. | @@ -2693,9 +2693,9 @@ interface MultiSelectItem { | Prop name | Type | Default value | Description | | :---------------- | :----------------------------------------------------------------------- | :------------------- | :--------------------------------------------------------------------------------- | -| items | MultiSelectItem[] | -- | Set the multiselect items. | +| items | MultiSelectItem[] | `[]` | Set the multiselect items. | | itemToString | (item: MultiSelectItem) => string | -- | Override the display of a multiselect item. | -| selectedIds | MultiSelectItemId[] | -- | Set the selected ids. | +| selectedIds | MultiSelectItemId[] | `[]` | Set the selected ids. | | value | string | `""` | Specify the multiselect value. | | size | "sm" | "lg" | "xl" | -- | Set the size of the combobox. | | type | "default" | "inline" | `"default"` | Specify the type of multiselect. | @@ -3078,7 +3078,7 @@ import { Pagination } from "carbon-components-svelte"; | pageInputDisabled | boolean | `false` | Set to `true` to disable the page input. | | pageSizeInputDisabled | boolean | `false` | Set to `true` to disable the page size input. | | pageSize | number | `10` | Specify the number of items to display in a page. | -| pageSizes | number[] | -- | Specify the available page sizes. | +| pageSizes | number[] | `[10]` | Specify the available page sizes. | | pagesUnknown | boolean | `false` | Set to `true` if the number of pages is unknown. | | pageText | (page: number) => string | -- | Override the page text. | | pageRangeText | (current: number, total: number) => string | -- | Override the page range text. | diff --git a/docs/src/PUBLIC_API.json b/docs/src/PUBLIC_API.json index 00c38a2f..0299262b 100644 --- a/docs/src/PUBLIC_API.json +++ b/docs/src/PUBLIC_API.json @@ -1800,6 +1800,7 @@ "items", { "kind": "let", + "value": "[]", "type": "ComboBoxItem[]", "description": "Set the combobox items" } @@ -2510,6 +2511,7 @@ "headers", { "kind": "let", + "value": "[]", "type": "{key: string; value: string;}[]", "description": "Specify the data table headers" } @@ -2518,6 +2520,7 @@ "rows", { "kind": "let", + "value": "[]", "type": "Object[]", "description": "Specify the rows the data table should render\nkeys defined in `headers` are used for the row ids" } @@ -2588,6 +2591,7 @@ "expandedRowIds", { "kind": "let", + "value": "[]", "type": "string[]", "description": "Specify the row ids to be expanded" } @@ -2749,6 +2753,7 @@ "headers", { "kind": "let", + "value": "[]", "type": "string[]", "description": "Set the column headers\nIf `headers` has one more items, `count` is ignored" } @@ -3203,6 +3208,7 @@ "items", { "kind": "let", + "value": "[]", "type": "DropdownItem[]", "description": "Set the dropdown items" } @@ -3638,6 +3644,7 @@ "accept", { "kind": "let", + "value": "[]", "type": "string[]", "description": "Specify the accepted file types" } @@ -3646,6 +3653,7 @@ "files", { "kind": "let", + "value": "[]", "type": "string[]", "description": "Obtain the uploaded file names" } @@ -3813,6 +3821,7 @@ "accept", { "kind": "let", + "value": "[]", "type": "string[]", "description": "Specify the accepted file types" } @@ -3952,6 +3961,7 @@ "accept", { "kind": "let", + "value": "[]", "type": "string[]", "description": "Specify the accepted file types" } @@ -7251,6 +7261,7 @@ "items", { "kind": "let", + "value": "[]", "type": "MultiSelectItem[]", "description": "Set the multiselect items" } @@ -7267,6 +7278,7 @@ "selectedIds", { "kind": "let", + "value": "[]", "type": "MultiSelectItemId[]", "description": "Set the selected ids" } @@ -8793,6 +8805,7 @@ "pageSizes", { "kind": "let", + "value": "[10]", "type": "number[]", "description": "Specify the available page sizes" } diff --git a/scripts/rollup/parse-component.js b/scripts/rollup/parse-component.js index 1379b5e0..837c9c71 100644 --- a/scripts/rollup/parse-component.js +++ b/scripts/rollup/parse-component.js @@ -44,7 +44,10 @@ export function parseComponent(source, hooks) { let description = null; if (init != null) { - if (init.type === "ObjectExpression") { + if ( + init.type === "ObjectExpression" || + init.type === "ArrayExpression" + ) { value = source.slice(init.start, init.end).replace(/\n/g, " "); type = value; } else { diff --git a/types/index.d.ts b/types/index.d.ts index 8aa34063..70862ad7 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -564,6 +564,7 @@ export class ComboBox extends CarbonSvelteComponent { $$prop_def: { /** * Set the combobox items + * @default [] */ items?: ComboBoxItem[]; @@ -784,12 +785,14 @@ export class DataTable extends CarbonSvelteComponent { $$prop_def: { /** * Specify the data table headers + * @default [] */ headers?: { key: string; value: string }[]; /** * Specify the rows the data table should render * keys defined in `headers` are used for the row ids + * @default [] */ rows?: Object[]; @@ -837,6 +840,7 @@ export class DataTable extends CarbonSvelteComponent { /** * Specify the row ids to be expanded + * @default [] */ expandedRowIds?: string[]; @@ -884,6 +888,7 @@ export class DataTableSkeleton extends CarbonSvelteComponent { /** * Set the column headers * If `headers` has one more items, `count` is ignored + * @default [] */ headers?: string[]; @@ -1066,6 +1071,7 @@ export class Dropdown extends CarbonSvelteComponent { $$prop_def: { /** * Set the dropdown items + * @default [] */ items?: DropdownItem[]; @@ -1245,11 +1251,13 @@ export class FileUploader extends CarbonSvelteComponent { /** * Specify the accepted file types + * @default [] */ accept?: string[]; /** * Obtain the uploaded file names + * @default [] */ files?: string[]; @@ -1307,6 +1315,7 @@ export class FileUploaderButton extends CarbonSvelteComponent { $$prop_def: { /** * Specify the accepted file types + * @default [] */ accept?: string[]; @@ -1377,6 +1386,7 @@ export class FileUploaderDropContainer extends CarbonSvelteComponent { $$prop_def: { /** * Specify the accepted file types + * @default [] */ accept?: string[]; @@ -2454,6 +2464,7 @@ export class MultiSelect extends CarbonSvelteComponent { $$prop_def: { /** * Set the multiselect items + * @default [] */ items?: MultiSelectItem[]; @@ -2464,6 +2475,7 @@ export class MultiSelect extends CarbonSvelteComponent { /** * Set the selected ids + * @default [] */ selectedIds?: MultiSelectItemId[]; @@ -3014,6 +3026,7 @@ export class Pagination extends CarbonSvelteComponent { /** * Specify the available page sizes + * @default [10] */ pageSizes?: number[];