Skip to content

Commit 01aa5d0

Browse files
committed
feat(Datatable): add numberOfCheckboxes to register new Checkboxes
1 parent 46aa49c commit 01aa5d0

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

components/mdc/Datatable/Datatable.svelte

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { createEventDispatcher, onMount } from 'svelte'
88
*/
99
export let label = ''
1010
/**
11-
* @prop {any}
12-
* @description used to register new Datatable Checkboxes when length changes
11+
* @prop {number}
12+
* @description used to register new Datatable Checkboxes when value changes
1313
*/
14-
export let checkboxIsMountedArray = []
14+
export let numberOfCheckboxes = 0
1515
1616
const dispatch = createEventDispatcher()
1717
let dataTable = {}
@@ -40,7 +40,7 @@ onMount(() => {
4040
return () => dataTable.destroy()
4141
})
4242
43-
$: checkboxIsMountedArray.length && dataTable?.layout()
43+
$: numberOfCheckboxes && dataTable?.layout()
4444
</script>
4545
4646
<div class="mdc-data-table w-100 {$$props.class}" bind:this={element}>

stories/Datatable.stories.svelte

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const args = {
1313
}
1414
1515
let loaded = false
16+
let numberOfCheckboxes = 0
1617
1718
onMount(() =>
1819
setTimeout(() => {
@@ -70,6 +71,7 @@ onMount(() =>
7071

7172
<Story name="Checkbox" {args}>
7273
<Datatable
74+
{numberOfCheckboxes}
7375
class={args.class}
7476
on:sorted={args['on:sorted']}
7577
on:rowSelectionChanged={args['on:rowSelectionChanged']}
@@ -84,19 +86,19 @@ onMount(() =>
8486

8587
<Datatable.Data>
8688
<Datatable.Data.Row clickable={args.clickable} let:rowId>
87-
<Datatable.Checkbox {rowId} />
89+
<Datatable.Checkbox on:mounted={() => numberOfCheckboxes++} {rowId} />
8890
<Datatable.Data.Row.Item>item</Datatable.Data.Row.Item>
8991
<Datatable.Data.Row.Item>today</Datatable.Data.Row.Item>
9092
</Datatable.Data.Row>
9193

9294
<Datatable.Data.Row>
93-
<Datatable.Checkbox />
95+
<Datatable.Checkbox on:mounted={() => numberOfCheckboxes++} />
9496
<Datatable.Data.Row.Item>item2</Datatable.Data.Row.Item>
9597
<Datatable.Data.Row.Item>tomorrow</Datatable.Data.Row.Item>
9698
</Datatable.Data.Row>
9799

98100
<Datatable.Data.Row>
99-
<Datatable.Checkbox />
101+
<Datatable.Checkbox on:mounted={() => numberOfCheckboxes++} />
100102
<Datatable.Data.Row.Item colspan={isAboveMobile() ? 6 : 2}>
101103
{#if loaded}
102104
Done loading

0 commit comments

Comments
 (0)