mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-14 18:01:06 +00:00
fix(parse-component): parse ArrayExpression
This commit is contained in:
parent
1a809c9c3a
commit
77ebd0d1aa
4 changed files with 43 additions and 14 deletions
|
@ -773,7 +773,7 @@ interface ComboBoxItem {
|
|||
|
||||
| Prop name | Type | Default value | Description |
|
||||
| :--------------- | :---------------------------------------------------------- | :------------ | :------------------------------------------------------------------------ |
|
||||
| items | <code>ComboBoxItem[]</code> | -- | Set the combobox items. |
|
||||
| items | <code>ComboBoxItem[]</code> | `[]` | Set the combobox items. |
|
||||
| itemToString | <code>(item: ComboBoxItem) => string</code> | -- | Override the display of a combobox item. |
|
||||
| selectedIndex | <code>number</code> | -- | Set the selected item by value index. |
|
||||
| value | <code>string</code> | `""` | Specify the selected combobox value. |
|
||||
|
@ -982,8 +982,8 @@ import { DataTable } from "carbon-components-svelte";
|
|||
|
||||
| Prop name | Type | Default value | Description |
|
||||
| :------------- | :-------------------------------------------------- | :------------ | :--------------------------------------------------------------------------------------------------- |
|
||||
| headers | <code>{key: string; value: string;}[]</code> | -- | Specify the data table headers. |
|
||||
| rows | <code>Object[]</code> | -- | Specify the rows the data table should render. keys defined in `headers` are used for the row ids. |
|
||||
| headers | <code>{key: string; value: string;}[]</code> | `[]` | Specify the data table headers. |
|
||||
| rows | <code>Object[]</code> | `[]` | Specify the rows the data table should render. keys defined in `headers` are used for the row ids. |
|
||||
| size | <code>"compact" | "short" | "tall"</code> | -- | Set the size of the data table. |
|
||||
| title | <code>string</code> | `""` | Specify the title of the data table. |
|
||||
| description | <code>string</code> | `""` | Specify the description of the data table. |
|
||||
|
@ -991,7 +991,7 @@ import { DataTable } from "carbon-components-svelte";
|
|||
| sortable | <code>boolean</code> | `false` | Set to `true` for the sortable variant. |
|
||||
| expandable | <code>boolean</code> | `false` | Set to `true` for the expandable variant. Automatically set to `true` if `batchExpansion` is `true`. |
|
||||
| batchExpansion | <code>boolean</code> | `false` | Set to `true` to enable batch expansion. |
|
||||
| expandedRowIds | <code>string[]</code> | -- | Specify the row ids to be expanded. |
|
||||
| expandedRowIds | <code>string[]</code> | `[]` | Specify the row ids to be expanded. |
|
||||
| stickyHeader | <code>boolean</code> | `false` | Set to `true` to enable a sticky header. |
|
||||
|
||||
### Slots
|
||||
|
@ -1030,7 +1030,7 @@ import { DataTableSkeleton } from "carbon-components-svelte";
|
|||
| size | <code>"compact" | "short" | "tall"</code> | -- | Set the size of the data table. |
|
||||
| zebra | <code>boolean</code> | `false` | Set to `true` to apply zebra styles to the datatable rows. |
|
||||
| showHeader | <code>boolean</code> | `true` | Set to `false` to hide the header. |
|
||||
| headers | <code>string[]</code> | -- | Set the column headers. If `headers` has one more items, `count` is ignored. |
|
||||
| headers | <code>string[]</code> | `[]` | Set the column headers. If `headers` has one more items, `count` is ignored. |
|
||||
| showToolbar | <code>boolean</code> | `true` | Set to `false` to hide the toolbar. |
|
||||
|
||||
### Slots
|
||||
|
@ -1189,7 +1189,7 @@ interface DropdownItem {
|
|||
|
||||
| Prop name | Type | Default value | Description |
|
||||
| :-------------- | :------------------------------------------ | :------------ | :--------------------------------------------- |
|
||||
| items | <code>DropdownItem[]</code> | -- | Set the dropdown items. |
|
||||
| items | <code>DropdownItem[]</code> | `[]` | Set the dropdown items. |
|
||||
| itemToString | <code>(item: DropdownItem) => string</code> | -- | Override the display of a dropdown item. |
|
||||
| selectedIndex | <code>number</code> | -- | Specify the selected item index. |
|
||||
| type | <code>"default" | "inline"</code> | `"default"` | Specify the type of dropdown. |
|
||||
|
@ -1307,8 +1307,8 @@ import { FileUploader } from "carbon-components-svelte";
|
|||
| Prop name | Type | Default value | Description |
|
||||
| :---------------------- | :----------------------------------------------------------------------------------------- | :--------------------------- | :--------------------------------------------------------------------- |
|
||||
| status | <code>"uploading" | "edit" | "complete"</code> | `"uploading"` | Specify the file uploader status. |
|
||||
| accept | <code>string[]</code> | -- | Specify the accepted file types. |
|
||||
| files | <code>string[]</code> | -- | Obtain the uploaded file names. |
|
||||
| accept | <code>string[]</code> | `[]` | Specify the accepted file types. |
|
||||
| files | <code>string[]</code> | `[]` | Obtain the uploaded file names. |
|
||||
| multiple | <code>boolean</code> | `false` | Set to `true` to allow multiple files. |
|
||||
| clearFiles (`constant`) | <code>() => any</code> | -- | Override the default behavior of clearing the array of uploaded files. |
|
||||
| labelDescription | <code>string</code> | `""` | Specify the label description. |
|
||||
|
@ -1350,7 +1350,7 @@ import { FileUploaderButton } from "carbon-components-svelte";
|
|||
|
||||
| Prop name | Type | Default value | Description |
|
||||
| :------------------ | :----------------------------------------------------------------------------------------- | :------------ | :-------------------------------------------- |
|
||||
| accept | <code>string[]</code> | -- | Specify the accepted file types. |
|
||||
| accept | <code>string[]</code> | `[]` | Specify the accepted file types. |
|
||||
| multiple | <code>boolean</code> | `false` | Set to `true` to allow multiple files. |
|
||||
| disabled | <code>boolean</code> | `false` | Set to `true` to disable the input. |
|
||||
| disableLabelChanges | <code>boolean</code> | `false` | Set to `true` to disable label changes. |
|
||||
|
@ -1396,7 +1396,7 @@ type Files = string[];
|
|||
|
||||
| Prop name | Type | Default value | Description |
|
||||
| :------------ | :---------------------------------------- | :------------ | :-------------------------------------------------------------------------------------------------------- |
|
||||
| accept | <code>string[]</code> | -- | Specify the accepted file types. |
|
||||
| accept | <code>string[]</code> | `[]` | Specify the accepted file types. |
|
||||
| multiple | <code>boolean</code> | `false` | Set to `true` to allow multiple files. |
|
||||
| validateFiles | <code>(files: Files) => Files</code> | -- | Override the default behavior of validating uploaded files. The default behavior does not validate files. |
|
||||
| labelText | <code>string</code> | `"Add file"` | Specify the label text. |
|
||||
|
@ -2693,9 +2693,9 @@ interface MultiSelectItem {
|
|||
|
||||
| Prop name | Type | Default value | Description |
|
||||
| :---------------- | :----------------------------------------------------------------------- | :------------------- | :--------------------------------------------------------------------------------- |
|
||||
| items | <code>MultiSelectItem[]</code> | -- | Set the multiselect items. |
|
||||
| items | <code>MultiSelectItem[]</code> | `[]` | Set the multiselect items. |
|
||||
| itemToString | <code>(item: MultiSelectItem) => string</code> | -- | Override the display of a multiselect item. |
|
||||
| selectedIds | <code>MultiSelectItemId[]</code> | -- | Set the selected ids. |
|
||||
| selectedIds | <code>MultiSelectItemId[]</code> | `[]` | Set the selected ids. |
|
||||
| value | <code>string</code> | `""` | Specify the multiselect value. |
|
||||
| size | <code>"sm" | "lg" | "xl"</code> | -- | Set the size of the combobox. |
|
||||
| type | <code>"default" | "inline"</code> | `"default"` | Specify the type of multiselect. |
|
||||
|
@ -3078,7 +3078,7 @@ import { Pagination } from "carbon-components-svelte";
|
|||
| pageInputDisabled | <code>boolean</code> | `false` | Set to `true` to disable the page input. |
|
||||
| pageSizeInputDisabled | <code>boolean</code> | `false` | Set to `true` to disable the page size input. |
|
||||
| pageSize | <code>number</code> | `10` | Specify the number of items to display in a page. |
|
||||
| pageSizes | <code>number[]</code> | -- | Specify the available page sizes. |
|
||||
| pageSizes | <code>number[]</code> | `[10]` | Specify the available page sizes. |
|
||||
| pagesUnknown | <code>boolean</code> | `false` | Set to `true` if the number of pages is unknown. |
|
||||
| pageText | <code>(page: number) => string</code> | -- | Override the page text. |
|
||||
| pageRangeText | <code>(current: number, total: number) => string</code> | -- | Override the page range text. |
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
13
types/index.d.ts
vendored
13
types/index.d.ts
vendored
|
@ -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[];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue