diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index f07aecc176..75a34e1372 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -1,6 +1,6 @@ # Component Index -> 169 components exported from carbon-components-svelte@1.0.0-next.1. +> 171 components exported from carbon-components-svelte@1.0.0-next.1. ## Components @@ -23,6 +23,8 @@ - [`Column`](#column) - [`ComboBox`](#combobox) - [`ComposedModal`](#composedmodal) +- [`ContainedList`](#containedlist) +- [`ContainedListItem`](#containedlistitem) - [`Content`](#content) - [`ContentSwitcher`](#contentswitcher) - [`ContextMenu`](#contextmenu) @@ -723,6 +725,53 @@ export interface ComboBoxItem { | close | dispatched | null | | open | dispatched | null | +## `ContainedList` + +### Props + +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :-------- | :------- | :--------------- | :------- | ----------------------------------------------------- | ------------------------------------------------ | ------------------------------------------------------- | +| kind | No | let | No | "on-page" | "disclosed" | "on-page" | -- | +| labelText | No | let | No | string | "" | Specify the label text | +| size | No | let | No | "sm" | "md" | "lg" | "xl" | "md" | Specify the size of the list | +| inset | No | let | No | boolean | false | Set to `true` for lines between list items to be inset. | +| id | No | let | No | string | "ccs-" + Math.random().toString(36) | Set an id for the list | + +### Slots + +| Slot name | Default | Props | Fallback | +| :-------- | :------ | :---- | :----------------------- | +| -- | Yes | -- | -- | +| action | No | -- | -- | +| labelText | No | -- | {labelText} | + +### Events + +None. + +## `ContainedListItem` + +### Props + +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :---------- | :------- | :--------------- | :------- | --------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------------ | +| interactive | No | let | No | boolean | false | Set to `true` to render a `button` element instead of a `div` | +| disabled | No | let | No | boolean | false | Set to `true` to disable the list item. | +| icon | No | let | No | typeof import("svelte").SvelteComponent | undefined | Specify the icon to render
Icon is rendered to the left of the label text | + +### Slots + +| Slot name | Default | Props | Fallback | +| :-------- | :------ | :---- | :------- | +| -- | Yes | -- | -- | +| action | No | -- | -- | + +### Events + +| Event name | Type | Detail | +| :--------- | :-------- | :----- | +| click | forwarded | -- | + ## `Content` ### Props diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index 84b7485f8a..00e3ef224b 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -1,5 +1,5 @@ { - "total": 169, + "total": 171, "components": [ { "moduleName": "Accordion", @@ -1847,6 +1847,134 @@ "typedefs": [], "rest_props": { "type": "Element", "name": "div" } }, + { + "moduleName": "ContainedList", + "filePath": "src/ContainedList/ContainedList.svelte", + "props": [ + { + "name": "kind", + "kind": "let", + "type": "\"on-page\" | \"disclosed\"", + "value": "\"on-page\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "labelText", + "kind": "let", + "description": "Specify the label text", + "type": "string", + "value": "\"\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "size", + "kind": "let", + "description": "Specify the size of the list", + "type": "\"sm\" | \"md\" | \"lg\" | \"xl\"", + "value": "\"md\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "inset", + "kind": "let", + "description": "Set to `true` for lines between list items to be inset.", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "id", + "kind": "let", + "description": "Set an id for the list", + "type": "string", + "value": "\"ccs-\" + Math.random().toString(36)", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + } + ], + "moduleExports": [], + "slots": [ + { "name": "__default__", "default": true, "slot_props": "{}" }, + { "name": "action", "default": false, "slot_props": "{}" }, + { + "name": "labelText", + "default": false, + "fallback": "{labelText}", + "slot_props": "{}" + } + ], + "events": [], + "typedefs": [] + }, + { + "moduleName": "ContainedListItem", + "filePath": "src/ContainedList/ContainedListItem.svelte", + "props": [ + { + "name": "interactive", + "kind": "let", + "description": "Set to `true` to render a `button` element instead of a `div`", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "disabled", + "kind": "let", + "description": "Set to `true` to disable the list item.", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "icon", + "kind": "let", + "description": "Specify the icon to render\nIcon is rendered to the left of the label text", + "type": "typeof import(\"svelte\").SvelteComponent", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + } + ], + "moduleExports": [], + "slots": [ + { "name": "__default__", "default": true, "slot_props": "{}" }, + { "name": "action", "default": false, "slot_props": "{}" } + ], + "events": [ + { "type": "forwarded", "name": "click", "element": "svelte:element" } + ], + "typedefs": [] + }, { "moduleName": "Content", "filePath": "src/UIShell/Content.svelte", diff --git a/docs/src/pages/components/ContainedList.svx b/docs/src/pages/components/ContainedList.svx new file mode 100644 index 0000000000..0db62cd71c --- /dev/null +++ b/docs/src/pages/components/ContainedList.svx @@ -0,0 +1,122 @@ + + +## Default + +The `ContainedList` component is used to display a list of items in a container. + +It uses a `md` size by default. + + + Item 1 + Item 2 + Item 3 + + +## Small size + + + Item 1 + Item 2 + Item 3 + + +## Large size + + + Item 1 + Item 2 + Item 3 + + +## Extra-large size + + + Item 1 + Item 2 + Item 3 + + +## Inset items + + + Item 1 + Item 2 + Item 3 + + +## Disclosed + +Set `kind="disclosed"` for the list title to be sticky positioned. + +When scrolling, the list title will stick to the top of the container. + +
+ + {#each Array.from({ length: 6 }) as i} + Item + {/each} + + + {#each Array.from({ length: 6 }) as i} + Item + {/each} + +
+ +## With icons + + + Item 1 + Item 2 + Item 3 + + +## With expandable search + +Use the `action` slot to add an expandable search. + + + + Item 1 + Item 2 + Item 3 + + +## Interactive items + +Set `interactive` to make the items render as a `button`. + + + console.log('click')}> + Item 1 + + Item 2 + Item 3 + + +## Interactive items with actions + +Similarly to `ContainedList`, you can add an action to `ContainedListItem` using the `action` slot. + + + console.log('click')}> + Item 1 +