diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 5a957ef4..f0929f70 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -685,17 +685,18 @@ None. ### Events -| Event name | Type | Detail | -| :------------ | :--------- | :------------------------------ | -| transitionend | dispatched | { open: boolean; } | -| keydown | forwarded | -- | -| click | forwarded | -- | -| mouseover | forwarded | -- | -| mouseenter | forwarded | -- | -| mouseleave | forwarded | -- | -| submit | dispatched | -- | -| close | dispatched | -- | -| open | dispatched | -- | +| Event name | Type | Detail | +| :-------------------- | :--------- | :------------------------------ | +| transitionend | dispatched | { open: boolean; } | +| keydown | forwarded | -- | +| click | forwarded | -- | +| mouseover | forwarded | -- | +| mouseenter | forwarded | -- | +| mouseleave | forwarded | -- | +| submit | dispatched | -- | +| click:button--primary | dispatched | -- | +| close | dispatched | -- | +| open | dispatched | -- | ## `Content` @@ -958,6 +959,7 @@ export interface DataTableCell { | radio | let | No | boolean | false | Set to `true` for the radio selection variant | | batchSelection | let | No | boolean | false | Set to `true` to enable batch selection | | stickyHeader | let | No | boolean | false | Set to `true` to enable a sticky header | +| useStaticWidth | let | No | boolean | false | Set to `true` to use static width | ### Slots @@ -2269,6 +2271,7 @@ None. | mouseenter | forwarded | -- | | mouseleave | forwarded | -- | | submit | dispatched | -- | +| click:button--primary | dispatched | -- | | close | dispatched | -- | | open | dispatched | -- | diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index da7a5789..1ae514df 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -1530,6 +1530,7 @@ { "type": "forwarded", "name": "mouseenter", "element": "div" }, { "type": "forwarded", "name": "mouseleave", "element": "div" }, { "type": "dispatched", "name": "submit" }, + { "type": "dispatched", "name": "click:button--primary" }, { "type": "dispatched", "name": "close" }, { "type": "dispatched", "name": "open" } ], @@ -2095,6 +2096,16 @@ "isFunction": false, "constant": false, "reactive": false + }, + { + "name": "useStaticWidth", + "kind": "let", + "description": "Set to `true` to use static width", + "type": "boolean", + "value": "false", + "isFunction": false, + "constant": false, + "reactive": false } ], "slots": [ @@ -5500,6 +5511,7 @@ { "type": "forwarded", "name": "mouseenter", "element": "div" }, { "type": "forwarded", "name": "mouseleave", "element": "div" }, { "type": "dispatched", "name": "submit" }, + { "type": "dispatched", "name": "click:button--primary" }, { "type": "dispatched", "name": "close" }, { "type": "dispatched", "name": "open" } ], diff --git a/docs/src/pages/components/DataTable.svx b/docs/src/pages/components/DataTable.svx index 41ecd931..c991bde0 100644 --- a/docs/src/pages/components/DataTable.svx +++ b/docs/src/pages/components/DataTable.svx @@ -3,15 +3,23 @@ components: ["DataTable", "Toolbar", "ToolbarContent", "ToolbarSearch", "Toolbar --- +`DataTable` is keyed for both rendering and sorting purposes. + + +
Every headers object must have a unique "key" property.
+
+ + +
Every rows object must have a unique "id" property.
+
+ ### Default -The `DataTable` is keyed for both rendering and sorting. You must define a "key" value per object in the `headers` property and an "id" value in `rows`. - +### Static width + +Set `useStaticWidth` to `true` to render the table with a width of "auto" instead of "100%". + + + ### Slotted cells Use the `"cell"` slot to control the display value per table cell. Individual row and cell data are provided through the `let:row` and `let:cell` directives. diff --git a/src/ComposedModal/ComposedModal.svelte b/src/ComposedModal/ComposedModal.svelte index 094eba37..78d923de 100644 --- a/src/ComposedModal/ComposedModal.svelte +++ b/src/ComposedModal/ComposedModal.svelte @@ -53,6 +53,7 @@ }, submit: () => { dispatch("submit"); + dispatch("click:button--primary"); }, declareRef: (ref) => { buttonRef = ref; diff --git a/src/DataTable/DataTable.svelte b/src/DataTable/DataTable.svelte index 9938b46c..8e12d4c0 100644 --- a/src/DataTable/DataTable.svelte +++ b/src/DataTable/DataTable.svelte @@ -91,6 +91,9 @@ /** Set to `true` to enable a sticky header */ export let stickyHeader = false; + /** Set to `true` to use static width */ + export let useStaticWidth = false; + import { createEventDispatcher, setContext } from "svelte"; import { writable, derived } from "svelte/store"; import ChevronRight16 from "carbon-icons-svelte/lib/ChevronRight16/ChevronRight16.svelte"; @@ -203,24 +206,27 @@ -
- {#if title || $$slots.title} -

- {title} -

- {/if} - {#if description || $$slots.description} -

- {description} -

- {/if} -
+ {#if title || $$slots.title || description || $$slots.description} +
+ {#if title || $$slots.title} +

+ {title} +

+ {/if} + {#if description || $$slots.description} +

+ {description} +

+ {/if} +
+ {/if} diff --git a/src/Modal/Modal.svelte b/src/Modal/Modal.svelte index a55657b1..54a205c8 100644 --- a/src/Modal/Modal.svelte +++ b/src/Modal/Modal.svelte @@ -297,6 +297,7 @@ disabled="{primaryButtonDisabled}" on:click="{() => { dispatch('submit'); + dispatch('click:button--primary'); }}" > {primaryButtonText} diff --git a/tests/ComposedModal.test.svelte b/tests/ComposedModal.test.svelte index 380e3865..8ad4a7c3 100644 --- a/tests/ComposedModal.test.svelte +++ b/tests/ComposedModal.test.svelte @@ -10,7 +10,7 @@ let checked = false; - + @@ -19,6 +19,8 @@ primaryButtonText="Proceed" primaryButtonDisabled="{!checked}" secondaryButtons="{[{ text: 'Cancel' }, { text: 'Duplicate' }]}" - on:click:button--secondary="{({ detail }) => {}}" + on:click:button--secondary="{({ detail }) => { + console.log(detail); + }}" /> diff --git a/tests/DataTable.test.svelte b/tests/DataTable.test.svelte index 208d3a5d..e2e24959 100644 --- a/tests/DataTable.test.svelte +++ b/tests/DataTable.test.svelte @@ -98,6 +98,7 @@ description="Your organization's active load balancers." headers="{headers}" rows="{rows}" + useStaticWidth />

Create a new Cloudant database in the US South region.

diff --git a/types/ComposedModal/ComposedModal.d.ts b/types/ComposedModal/ComposedModal.d.ts index a5327b3b..0441eae5 100644 --- a/types/ComposedModal/ComposedModal.d.ts +++ b/types/ComposedModal/ComposedModal.d.ts @@ -55,6 +55,7 @@ export default class ComposedModal extends SvelteComponentTyped< mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; submit: CustomEvent; + ["click:button--primary"]: CustomEvent; close: CustomEvent; open: CustomEvent; }, diff --git a/types/DataTable/DataTable.d.ts b/types/DataTable/DataTable.d.ts index 3c9c84a7..62ed3c21 100644 --- a/types/DataTable/DataTable.d.ts +++ b/types/DataTable/DataTable.d.ts @@ -129,6 +129,12 @@ export interface DataTableProps * @default false */ stickyHeader?: boolean; + + /** + * Set to `true` to use static width + * @default false + */ + useStaticWidth?: boolean; } export default class DataTable extends SvelteComponentTyped< diff --git a/types/Modal/Modal.d.ts b/types/Modal/Modal.d.ts index 11c9130d..bc27704d 100644 --- a/types/Modal/Modal.d.ts +++ b/types/Modal/Modal.d.ts @@ -132,6 +132,7 @@ export default class Modal extends SvelteComponentTyped< mouseenter: WindowEventMap["mouseenter"]; mouseleave: WindowEventMap["mouseleave"]; submit: CustomEvent; + ["click:button--primary"]: CustomEvent; close: CustomEvent; open: CustomEvent; },