From bb7526472e57bba40d6f1815a2d8f4d3eecf6c24 Mon Sep 17 00:00:00 2001 From: mJarsater <62651103+mJarsater@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:06:41 +0200 Subject: [PATCH] feat(table): add inderminate state & updated selected prop (#372) * feat(table): added indeterminate support for multiselect table * docs(table): added allSelected and allIndeterminate controls to storybook * docs(table): updated control name * fix(table): deprecated allSelected and introduces selected and indeterminate props * docs(table): updated stoory to use correct prop names --- .../table-component-multiselect.stories.tsx | 22 ++++++++++++++++++- .../components/table/table-header/readme.md | 8 ++++--- .../table/table-header/table-header.tsx | 11 ++++++++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/packages/core/src/components/table/table-component-multiselect.stories.tsx b/packages/core/src/components/table/table-component-multiselect.stories.tsx index 27530689e..b3d2cb631 100644 --- a/packages/core/src/components/table/table-component-multiselect.stories.tsx +++ b/packages/core/src/components/table/table-component-multiselect.stories.tsx @@ -38,6 +38,20 @@ export default { defaultValue: { summary: 'Inherit from parent' }, }, }, + allSelected: { + name: 'All selected', + description: `Controls the checked state of the "all-selected"-checkbox.`, + control: { + type: 'boolean', + }, + }, + allIndeterminate: { + name: 'All indeterminate', + description: `Controls the indeterminate state of the "all-selected"-checkbox.`, + control: { + type: 'boolean', + }, + }, compactDesign: { name: 'Compact design', description: 'Enables compact design of the Table, rows with less height.', @@ -116,6 +130,8 @@ export default { }, args: { modeVariant: 'Inherit from parent', + allSelected: false, + allIndeterminate: false, compactDesign: false, responsiveDesign: false, verticalDivider: false, @@ -129,6 +145,8 @@ export default { const MultiselectTemplate = ({ modeVariant, + allSelected, + allIndeterminate, compactDesign, responsiveDesign, verticalDivider, @@ -150,7 +168,9 @@ const MultiselectTemplate = ({ modeVariant !== 'Inherit from parent' ? `mode-variant="${modeVariant.toLowerCase()}"` : '' } > - + diff --git a/packages/core/src/components/table/table-header/readme.md b/packages/core/src/components/table/table-header/readme.md index b88b40b76..1e1d4962b 100644 --- a/packages/core/src/components/table/table-header/readme.md +++ b/packages/core/src/components/table/table-header/readme.md @@ -7,9 +7,11 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| ------------- | -------------- | ------------------------------------------------------------------------------- | --------- | ------- | -| `allSelected` | `all-selected` | Prop for controling the checked/unchecked state of the "all selected"-checkbox. | `boolean` | `false` | +| Property | Attribute | Description | Type | Default | +| --------------- | --------------- | -------------------------------------------------------------------------------------------- | --------- | ----------- | +| `allSelected` | `all-selected` | **[DEPRECATED]** Deprecated, use selected instead..

| `boolean` | `false` | +| `indeterminate` | `indeterminate` | Prop for controling the indeterminate state of the "All selected"-checkbox. | `boolean` | `false` | +| `selected` | `selected` | Prop for controling the checked/unchecked state of the "All selected"-checkbox. | `boolean` | `undefined` | ## Events diff --git a/packages/core/src/components/table/table-header/table-header.tsx b/packages/core/src/components/table/table-header/table-header.tsx index 28f8a53e1..71efd911f 100644 --- a/packages/core/src/components/table/table-header/table-header.tsx +++ b/packages/core/src/components/table/table-header/table-header.tsx @@ -28,9 +28,15 @@ const relevantTableProps: InternalTdsTablePropChange['changed'] = [ shadow: true, }) export class TdsTableHeaderRow { - /** Prop for controling the checked/unchecked state of the "all selected"-checkbox. */ + /** @deprecated Deprecated, use selected instead.. */ @Prop({ reflect: true, mutable: true }) allSelected: boolean = false; + /** Prop for controling the checked/unchecked state of the "All selected"-checkbox. */ + @Prop({ reflect: true, mutable: true }) selected: boolean; + + /** Prop for controling the indeterminate state of the "All selected"-checkbox. */ + @Prop() indeterminate: boolean = false; + @State() multiselect: boolean = false; @State() expandableRows: boolean = false; @@ -146,7 +152,8 @@ export class TdsTableHeaderRow {
this.handleCheckboxChange(event)} >