diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 7bbbdc3fc8..d689be6ad0 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -1,6 +1,6 @@ # Component Index -> 155 components exported from carbon-components-svelte@0.25.1. +> 156 components exported from carbon-components-svelte@0.25.1. ## Components @@ -105,6 +105,7 @@ - [`SelectItemGroup`](#selectitemgroup) - [`SelectSkeleton`](#selectskeleton) - [`SelectableTile`](#selectabletile) +- [`SelectableTileGroup`](#selectabletilegroup) - [`SideNav`](#sidenav) - [`SideNavItems`](#sidenavitems) - [`SideNavLink`](#sidenavlink) @@ -2904,8 +2905,8 @@ None. | Prop name | Kind | Reactive | Type | Default value | Description | | :-------------- | :--------------- | :------- | :---------------------------------------- | ------------------------------------------------ | ------------------------------------------------------------- | | ref | let | Yes | null | HTMLInputElement | null | Obtain a reference to the input HTML element | +| light | let | Yes | boolean | false | Set to `true` to enable the light variant | | selected | let | Yes | boolean | false | Set to `true` to select the tile | -| light | let | No | boolean | false | Set to `true` to enable the light variant | | title | let | No | string | "title" | Specify the title of the selectable tile | | value | let | No | string | "value" | Specify the value of the selectable tile | | tabindex | let | No | string | "0" | Specify the tabindex | @@ -2923,11 +2924,35 @@ None. | Event name | Type | Detail | | :--------- | :-------- | :----- | +| change | forwarded | -- | +| keydown | forwarded | -- | | click | forwarded | -- | | mouseover | forwarded | -- | | mouseenter | forwarded | -- | | mouseleave | forwarded | -- | -| keydown | forwarded | -- | + +## `SelectableTileGroup` + +### Props + +| Prop name | Kind | Reactive | Type | Default value | Description | +| :------------- | :--------------- | :------- | :------------------- | ------------------ | -------------------------------------------------------------- | +| selectedValues | let | Yes | any[] | [] | Specify the selected tile's | +| disabled | let | No | boolean | false | Set to `true` to disable the tile group | +| legend | let | No | string | "" | Specify the legend text | +| light | let | No | boolean | false | Set to `true` to enable the light variant throughout the group | + +### Slots + +| Slot name | Default | Props | Fallback | +| :-------- | :------ | :---- | :------- | +| -- | Yes | -- | -- | + +### Events + +| Event name | Type | Detail | +| :--------- | :--------- | :----- | +| select | dispatched | -- | ## `SideNav` diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index 98e830608e..d47f431a83 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -1,5 +1,5 @@ { - "total": 155, + "total": 156, "components": [ { "moduleName": "SkeletonText", @@ -8534,7 +8534,7 @@ "value": "false", "isFunction": false, "constant": false, - "reactive": false + "reactive": true }, { "name": "title", @@ -8609,11 +8609,12 @@ ], "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], "events": [ + { "type": "forwarded", "name": "change", "element": "input" }, + { "type": "forwarded", "name": "keydown", "element": "input" }, { "type": "forwarded", "name": "click", "element": "label" }, { "type": "forwarded", "name": "mouseover", "element": "label" }, { "type": "forwarded", "name": "mouseenter", "element": "label" }, - { "type": "forwarded", "name": "mouseleave", "element": "label" }, - { "type": "forwarded", "name": "keydown", "element": "label" } + { "type": "forwarded", "name": "mouseleave", "element": "label" } ], "typedefs": [], "rest_props": { "type": "Element", "name": "label" } @@ -8744,6 +8745,56 @@ "typedefs": [], "rest_props": { "type": "Element", "name": "fieldset" } }, + { + "moduleName": "SelectableTileGroup", + "filePath": "/src/Tile/SelectableTileGroup.svelte", + "props": [ + { + "name": "selectedValues", + "kind": "let", + "description": "Specify the selected tile's", + "type": "any[]", + "value": "[]", + "isFunction": false, + "constant": false, + "reactive": true + }, + { + "name": "disabled", + "kind": "let", + "description": "Set to `true` to disable the tile group", + "type": "boolean", + "value": "false", + "isFunction": false, + "constant": false, + "reactive": false + }, + { + "name": "legend", + "kind": "let", + "description": "Specify the legend text", + "type": "string", + "value": "\"\"", + "isFunction": false, + "constant": false, + "reactive": false + }, + { + "name": "light", + "kind": "let", + "description": "Set to `true` to enable the light variant throughout the group", + "type": "boolean", + "value": "false", + "isFunction": false, + "constant": false, + "reactive": false + } + ], + "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], + "events": [{ "type": "dispatched", "name": "select" }], + "typedefs": [], + "rest_props": { "type": "Element", "name": "fieldset" } + }, { "moduleName": "TimePicker", "filePath": "/src/TimePicker/TimePicker.svelte", diff --git a/docs/src/pages/components/RadioTile.svx b/docs/src/pages/components/RadioTile.svx index 34109335c6..1a554fc5bf 100644 --- a/docs/src/pages/components/RadioTile.svx +++ b/docs/src/pages/components/RadioTile.svx @@ -7,6 +7,7 @@ components: ["TileGroup", "RadioTile"] import Preview from "../../components/Preview.svelte"; + ### Default @@ -24,13 +25,13 @@ components: ["TileGroup", "RadioTile"] ### Light variant - + Lite plan - + Standard plan - + Plus plan - \ No newline at end of file + diff --git a/docs/src/pages/components/SelectableTile.svx b/docs/src/pages/components/SelectableTile.svx index 01b41d1674..444751a51c 100644 --- a/docs/src/pages/components/SelectableTile.svx +++ b/docs/src/pages/components/SelectableTile.svx @@ -1,36 +1,36 @@ --- -components: ["SelectableTile"] +components: ["SelectableTile", "SelectableTileGroup"] --- -### Multi-selectable tiles +### Default -
- - Multi-select Tile + + + Option 1 - - Multi-select Tile + + Option 2 - - Multi-select Tile + + Option 3 (light variant) -
+ ### Light variant -
- - Multi-select Tile + + + Option 1 - - Multi-select Tile + + Option 2 - - Multi-select Tile + + Option 3 -
\ No newline at end of file + diff --git a/docs/src/pages/framed/SelectableTile/SelectableTileReactive.svelte b/docs/src/pages/framed/SelectableTile/SelectableTileReactive.svelte new file mode 100644 index 0000000000..9e04d92cc6 --- /dev/null +++ b/docs/src/pages/framed/SelectableTile/SelectableTileReactive.svelte @@ -0,0 +1,116 @@ + + + + Option 1 + Option 2 + + Option 3 (light variant) + + + +
+ {selectedValues.join(', ')} + + +
+ + + Option 1 + Option 2 + + Option 3 (light variant) + + + +
+ {selectedValues2.join(', ')} + + +
+ + + {#each selectedValues3_control as item} + + {item.value} + + {/each} + + +
+ {selectedValues3.join(', ')} + + +
+ +

#key fix

+ + + {#key selectedValues3_control} + {#each selectedValues3_control as item} + + {item.value} + + {/each} + {/key} + + +
+ {selectedValues3.join(', ')} + + +
diff --git a/src/DataTableSkeleton/DataTableSkeleton.svelte b/src/DataTableSkeleton/DataTableSkeleton.svelte index 2ee4ade3d9..eca0298c82 100644 --- a/src/DataTableSkeleton/DataTableSkeleton.svelte +++ b/src/DataTableSkeleton/DataTableSkeleton.svelte @@ -66,11 +66,11 @@ class:bx--data-table--short="{size === 'short'}" class:bx--data-table--tall="{size === 'tall'}" class:bx--data-table--zebra="{zebra}" - {...$$restProps} on:click on:mouseover on:mouseenter on:mouseleave + {...$$restProps} > diff --git a/src/Tile/SelectableTile.svelte b/src/Tile/SelectableTile.svelte index 4c1d2a1c62..c2f9c7660b 100644 --- a/src/Tile/SelectableTile.svelte +++ b/src/Tile/SelectableTile.svelte @@ -29,47 +29,53 @@ /** Obtain a reference to the input HTML element */ export let ref = null; - import { createEventDispatcher } from "svelte"; + import { getContext, onDestroy } from "svelte"; import CheckmarkFilled16 from "carbon-icons-svelte/lib/CheckmarkFilled16"; - const dispatch = createEventDispatcher(); + const { update, selectedValues, _light } = getContext("SelectableTileGroup"); - $: dispatch(selected ? "select" : "deselect", id); + $: update({ value, selected }); + + light = light || _light; + + $: selected = $selectedValues.indexOf(value) > -1; + + onDestroy(() => { + update({ value, selected: false }); + });