@patternfly/react-data-view 6.3.0 → 6.4.0-prerelease.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/DataViewTable/DataViewTable.d.ts +4 -0
  2. package/dist/cjs/DataViewTable/DataViewTable.js +21 -1
  3. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +2 -0
  4. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +2 -2
  5. package/dist/cjs/DataViewTableHead/DataViewTableHead.d.ts +2 -0
  6. package/dist/cjs/DataViewTableHead/DataViewTableHead.js +5 -4
  7. package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +2 -0
  8. package/dist/cjs/DataViewTableTree/DataViewTableTree.js +28 -1
  9. package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +4 -0
  10. package/dist/cjs/DataViewTh/DataViewTh.d.ts +32 -0
  11. package/dist/cjs/DataViewTh/DataViewTh.js +222 -0
  12. package/dist/cjs/Hooks/selection.d.ts +1 -0
  13. package/dist/cjs/Hooks/selection.js +5 -1
  14. package/dist/cjs/Hooks/selection.test.js +48 -0
  15. package/dist/cjs/InternalContext/InternalContext.d.ts +2 -0
  16. package/dist/esm/DataViewTable/DataViewTable.d.ts +4 -0
  17. package/dist/esm/DataViewTable/DataViewTable.js +21 -1
  18. package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +2 -0
  19. package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +2 -2
  20. package/dist/esm/DataViewTableHead/DataViewTableHead.d.ts +2 -0
  21. package/dist/esm/DataViewTableHead/DataViewTableHead.js +5 -4
  22. package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +2 -0
  23. package/dist/esm/DataViewTableTree/DataViewTableTree.js +29 -2
  24. package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +4 -0
  25. package/dist/esm/DataViewTh/DataViewTh.d.ts +32 -0
  26. package/dist/esm/DataViewTh/DataViewTh.js +215 -0
  27. package/dist/esm/Hooks/selection.d.ts +1 -0
  28. package/dist/esm/Hooks/selection.js +5 -1
  29. package/dist/esm/Hooks/selection.test.js +48 -0
  30. package/dist/esm/InternalContext/InternalContext.d.ts +2 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +7 -7
  33. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableResizableColumnsExample.tsx +155 -0
  34. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableTreeExample.tsx +1 -0
  35. package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +52 -14
  36. package/patternfly-docs/content/extensions/data-view/examples/Toolbar/SelectionExample.tsx +14 -3
  37. package/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md +1 -0
  38. package/release.config.js +1 -1
  39. package/src/DataViewCheckboxFilter/__snapshots__/DataViewCheckboxFilter.test.tsx.snap +0 -2
  40. package/src/DataViewFilters/__snapshots__/DataViewFilters.test.tsx.snap +0 -2
  41. package/src/DataViewTable/DataViewTable.tsx +48 -27
  42. package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +10 -18
  43. package/src/DataViewTableBasic/DataViewTableBasic.tsx +4 -1
  44. package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +20 -20
  45. package/src/DataViewTableHead/DataViewTableHead.tsx +24 -23
  46. package/src/DataViewTableHead/__snapshots__/DataViewTableHead.test.tsx.snap +15 -15
  47. package/src/DataViewTableTree/DataViewTableTree.test.tsx +9 -0
  48. package/src/DataViewTableTree/DataViewTableTree.tsx +35 -1
  49. package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +977 -28
  50. package/src/DataViewTextFilter/__snapshots__/DataViewTextFilter.test.tsx.snap +0 -3
  51. package/src/DataViewTh/DataViewTh.tsx +342 -0
  52. package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +0 -10
  53. package/src/Hooks/selection.test.tsx +65 -1
  54. package/src/Hooks/selection.ts +6 -1
  55. package/src/InternalContext/InternalContext.tsx +2 -0
@@ -21,7 +21,7 @@ exports[`DataViewTable component should render correctly 1`] = `
21
21
  data-ouia-safe="true"
22
22
  >
23
23
  <th
24
- class="pf-v6-c-table__th"
24
+ class="pf-v6-c-table__th pf-m-truncate"
25
25
  data-ouia-component-id="TableExample-th-0"
26
26
  scope="col"
27
27
  tabindex="-1"
@@ -29,7 +29,7 @@ exports[`DataViewTable component should render correctly 1`] = `
29
29
  Repositories
30
30
  </th>
31
31
  <th
32
- class="pf-v6-c-table__th"
32
+ class="pf-v6-c-table__th pf-m-truncate"
33
33
  data-ouia-component-id="TableExample-th-1"
34
34
  scope="col"
35
35
  tabindex="-1"
@@ -37,7 +37,7 @@ exports[`DataViewTable component should render correctly 1`] = `
37
37
  Branches
38
38
  </th>
39
39
  <th
40
- class="pf-v6-c-table__th"
40
+ class="pf-v6-c-table__th pf-m-truncate"
41
41
  data-ouia-component-id="TableExample-th-2"
42
42
  scope="col"
43
43
  tabindex="-1"
@@ -45,7 +45,7 @@ exports[`DataViewTable component should render correctly 1`] = `
45
45
  Pull requests
46
46
  </th>
47
47
  <th
48
- class="pf-v6-c-table__th"
48
+ class="pf-v6-c-table__th pf-m-truncate"
49
49
  data-ouia-component-id="TableExample-th-3"
50
50
  scope="col"
51
51
  tabindex="-1"
@@ -53,7 +53,7 @@ exports[`DataViewTable component should render correctly 1`] = `
53
53
  Workspaces
54
54
  </th>
55
55
  <th
56
- class="pf-v6-c-table__th"
56
+ class="pf-v6-c-table__th pf-m-truncate"
57
57
  data-ouia-component-id="TableExample-th-4"
58
58
  scope="col"
59
59
  tabindex="-1"
@@ -352,7 +352,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
352
352
  data-ouia-safe="true"
353
353
  >
354
354
  <th
355
- class="pf-v6-c-table__th"
355
+ class="pf-v6-c-table__th pf-m-truncate"
356
356
  data-ouia-component-id="TableExample-th-0"
357
357
  scope="col"
358
358
  tabindex="-1"
@@ -360,7 +360,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
360
360
  Repositories
361
361
  </th>
362
362
  <th
363
- class="pf-v6-c-table__th"
363
+ class="pf-v6-c-table__th pf-m-truncate"
364
364
  data-ouia-component-id="TableExample-th-1"
365
365
  scope="col"
366
366
  tabindex="-1"
@@ -368,7 +368,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
368
368
  Branches
369
369
  </th>
370
370
  <th
371
- class="pf-v6-c-table__th"
371
+ class="pf-v6-c-table__th pf-m-truncate"
372
372
  data-ouia-component-id="TableExample-th-2"
373
373
  scope="col"
374
374
  tabindex="-1"
@@ -376,7 +376,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
376
376
  Pull requests
377
377
  </th>
378
378
  <th
379
- class="pf-v6-c-table__th"
379
+ class="pf-v6-c-table__th pf-m-truncate"
380
380
  data-ouia-component-id="TableExample-th-3"
381
381
  scope="col"
382
382
  tabindex="-1"
@@ -384,7 +384,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
384
384
  Workspaces
385
385
  </th>
386
386
  <th
387
- class="pf-v6-c-table__th"
387
+ class="pf-v6-c-table__th pf-m-truncate"
388
388
  data-ouia-component-id="TableExample-th-4"
389
389
  scope="col"
390
390
  tabindex="-1"
@@ -429,7 +429,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
429
429
  data-ouia-safe="true"
430
430
  >
431
431
  <th
432
- class="pf-v6-c-table__th"
432
+ class="pf-v6-c-table__th pf-m-truncate"
433
433
  data-ouia-component-id="TableExample-th-0"
434
434
  scope="col"
435
435
  tabindex="-1"
@@ -437,7 +437,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
437
437
  Repositories
438
438
  </th>
439
439
  <th
440
- class="pf-v6-c-table__th"
440
+ class="pf-v6-c-table__th pf-m-truncate"
441
441
  data-ouia-component-id="TableExample-th-1"
442
442
  scope="col"
443
443
  tabindex="-1"
@@ -445,7 +445,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
445
445
  Branches
446
446
  </th>
447
447
  <th
448
- class="pf-v6-c-table__th"
448
+ class="pf-v6-c-table__th pf-m-truncate"
449
449
  data-ouia-component-id="TableExample-th-2"
450
450
  scope="col"
451
451
  tabindex="-1"
@@ -453,7 +453,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
453
453
  Pull requests
454
454
  </th>
455
455
  <th
456
- class="pf-v6-c-table__th"
456
+ class="pf-v6-c-table__th pf-m-truncate"
457
457
  data-ouia-component-id="TableExample-th-3"
458
458
  scope="col"
459
459
  tabindex="-1"
@@ -461,7 +461,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
461
461
  Workspaces
462
462
  </th>
463
463
  <th
464
- class="pf-v6-c-table__th"
464
+ class="pf-v6-c-table__th pf-m-truncate"
465
465
  data-ouia-component-id="TableExample-th-4"
466
466
  scope="col"
467
467
  tabindex="-1"
@@ -506,7 +506,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
506
506
  data-ouia-safe="true"
507
507
  >
508
508
  <th
509
- class="pf-v6-c-table__th"
509
+ class="pf-v6-c-table__th pf-m-truncate"
510
510
  data-ouia-component-id="TableExample-th-0"
511
511
  scope="col"
512
512
  tabindex="-1"
@@ -514,7 +514,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
514
514
  Repositories
515
515
  </th>
516
516
  <th
517
- class="pf-v6-c-table__th"
517
+ class="pf-v6-c-table__th pf-m-truncate"
518
518
  data-ouia-component-id="TableExample-th-1"
519
519
  scope="col"
520
520
  tabindex="-1"
@@ -522,7 +522,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
522
522
  Branches
523
523
  </th>
524
524
  <th
525
- class="pf-v6-c-table__th"
525
+ class="pf-v6-c-table__th pf-m-truncate"
526
526
  data-ouia-component-id="TableExample-th-2"
527
527
  scope="col"
528
528
  tabindex="-1"
@@ -530,7 +530,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
530
530
  Pull requests
531
531
  </th>
532
532
  <th
533
- class="pf-v6-c-table__th"
533
+ class="pf-v6-c-table__th pf-m-truncate"
534
534
  data-ouia-component-id="TableExample-th-3"
535
535
  scope="col"
536
536
  tabindex="-1"
@@ -538,7 +538,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
538
538
  Workspaces
539
539
  </th>
540
540
  <th
541
- class="pf-v6-c-table__th"
541
+ class="pf-v6-c-table__th pf-m-truncate"
542
542
  data-ouia-component-id="TableExample-th-4"
543
543
  scope="col"
544
544
  tabindex="-1"
@@ -1,12 +1,8 @@
1
1
  import { FC, useMemo } from 'react';
2
- import {
3
- Th,
4
- Thead,
5
- TheadProps,
6
- Tr
7
- } from '@patternfly/react-table';
2
+ import { Th, Thead, TheadProps, Tr } from '@patternfly/react-table';
8
3
  import { useInternalContext } from '../InternalContext';
9
4
  import { DataViewTh, isDataViewThObject } from '../DataViewTable';
5
+ import { DataViewTh as DataViewThElement } from '../DataViewTh/DataViewTh';
10
6
 
11
7
  /** extends TheadProps */
12
8
  export interface DataViewTableHeadProps extends TheadProps {
@@ -16,37 +12,42 @@ export interface DataViewTableHeadProps extends TheadProps {
16
12
  columns: DataViewTh[];
17
13
  /** Custom OUIA ID */
18
14
  ouiaId?: string;
15
+ /** @hide Indicates whether table is resizable */
16
+ hasResizableColumns?: boolean;
19
17
  }
20
18
 
21
19
  export const DataViewTableHead: FC<DataViewTableHeadProps> = ({
22
20
  isTreeTable = false,
23
21
  columns,
24
22
  ouiaId = 'DataViewTableHead',
23
+ hasResizableColumns,
25
24
  ...props
26
25
  }: DataViewTableHeadProps) => {
27
26
  const { selection } = useInternalContext();
28
27
  const { onSelect, isSelected } = selection ?? {};
29
28
 
30
- const cells = useMemo(() => [
31
- onSelect && isSelected && !isTreeTable ? (
32
- <Th key="row-select" screenReaderText='Data selection table head cell' />
33
- ) : null,
34
- ...columns.map((column, index) => (
35
- <Th
36
- key={index}
37
- {...(isDataViewThObject(column) && (column?.props ?? {}))}
38
- data-ouia-component-id={`${ouiaId}-th-${index}`}
39
- >
40
- {isDataViewThObject(column) ? column.cell : column}
41
- </Th>
42
- )
43
- ) ], [ columns, ouiaId, onSelect, isSelected, isTreeTable ]);
29
+ const cells = useMemo(
30
+ () => [
31
+ onSelect && isSelected && !isTreeTable ? (
32
+ <Th key="row-select" screenReaderText="Data selection table head cell" />
33
+ ) : null,
34
+ ...columns.map((column, index) => (
35
+ <DataViewThElement
36
+ key={index}
37
+ content={isDataViewThObject(column) ? column.cell : column}
38
+ resizableProps={isDataViewThObject(column) ? column.resizableProps : undefined}
39
+ data-ouia-component-id={`${ouiaId}-th-${index}`}
40
+ thProps={isDataViewThObject(column) ? (column?.props ?? {}) : {}}
41
+ hasResizableColumns={hasResizableColumns}
42
+ />
43
+ ))
44
+ ],
45
+ [ columns, ouiaId, onSelect, isSelected, isTreeTable, hasResizableColumns ]
46
+ );
44
47
 
45
48
  return (
46
49
  <Thead data-ouia-component-id={`${ouiaId}-thead`} {...props}>
47
- <Tr ouiaId={`${ouiaId}-tr-head`}>
48
- {cells}
49
- </Tr>
50
+ <Tr ouiaId={`${ouiaId}-tr-head`}>{cells}</Tr>
50
51
  </Thead>
51
52
  );
52
53
  };
@@ -20,7 +20,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
20
20
  data-ouia-safe="true"
21
21
  >
22
22
  <th
23
- class="pf-v6-c-table__th"
23
+ class="pf-v6-c-table__th pf-m-truncate"
24
24
  data-ouia-component-id="HeaderExample-th-0"
25
25
  scope="col"
26
26
  tabindex="-1"
@@ -28,7 +28,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
28
28
  Repositories
29
29
  </th>
30
30
  <th
31
- class="pf-v6-c-table__th"
31
+ class="pf-v6-c-table__th pf-m-truncate"
32
32
  data-ouia-component-id="HeaderExample-th-1"
33
33
  scope="col"
34
34
  tabindex="-1"
@@ -36,7 +36,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
36
36
  Branches
37
37
  </th>
38
38
  <th
39
- class="pf-v6-c-table__th"
39
+ class="pf-v6-c-table__th pf-m-truncate"
40
40
  data-ouia-component-id="HeaderExample-th-2"
41
41
  scope="col"
42
42
  tabindex="-1"
@@ -44,7 +44,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
44
44
  Pull requests
45
45
  </th>
46
46
  <th
47
- class="pf-v6-c-table__th"
47
+ class="pf-v6-c-table__th pf-m-truncate"
48
48
  data-ouia-component-id="HeaderExample-th-3"
49
49
  scope="col"
50
50
  tabindex="-1"
@@ -52,7 +52,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
52
52
  Workspaces
53
53
  </th>
54
54
  <th
55
- class="pf-v6-c-table__th"
55
+ class="pf-v6-c-table__th pf-m-truncate"
56
56
  data-ouia-component-id="HeaderExample-th-4"
57
57
  scope="col"
58
58
  tabindex="-1"
@@ -104,7 +104,7 @@ exports[`DataViewTableHead component should render selection column when selecti
104
104
  </span>
105
105
  </th>
106
106
  <th
107
- class="pf-v6-c-table__th"
107
+ class="pf-v6-c-table__th pf-m-truncate"
108
108
  data-ouia-component-id="HeaderExample-th-0"
109
109
  scope="col"
110
110
  tabindex="-1"
@@ -112,7 +112,7 @@ exports[`DataViewTableHead component should render selection column when selecti
112
112
  Repositories
113
113
  </th>
114
114
  <th
115
- class="pf-v6-c-table__th"
115
+ class="pf-v6-c-table__th pf-m-truncate"
116
116
  data-ouia-component-id="HeaderExample-th-1"
117
117
  scope="col"
118
118
  tabindex="-1"
@@ -120,7 +120,7 @@ exports[`DataViewTableHead component should render selection column when selecti
120
120
  Branches
121
121
  </th>
122
122
  <th
123
- class="pf-v6-c-table__th"
123
+ class="pf-v6-c-table__th pf-m-truncate"
124
124
  data-ouia-component-id="HeaderExample-th-2"
125
125
  scope="col"
126
126
  tabindex="-1"
@@ -128,7 +128,7 @@ exports[`DataViewTableHead component should render selection column when selecti
128
128
  Pull requests
129
129
  </th>
130
130
  <th
131
- class="pf-v6-c-table__th"
131
+ class="pf-v6-c-table__th pf-m-truncate"
132
132
  data-ouia-component-id="HeaderExample-th-3"
133
133
  scope="col"
134
134
  tabindex="-1"
@@ -136,7 +136,7 @@ exports[`DataViewTableHead component should render selection column when selecti
136
136
  Workspaces
137
137
  </th>
138
138
  <th
139
- class="pf-v6-c-table__th"
139
+ class="pf-v6-c-table__th pf-m-truncate"
140
140
  data-ouia-component-id="HeaderExample-th-4"
141
141
  scope="col"
142
142
  tabindex="-1"
@@ -179,7 +179,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
179
179
  data-ouia-safe="true"
180
180
  >
181
181
  <th
182
- class="pf-v6-c-table__th"
182
+ class="pf-v6-c-table__th pf-m-truncate"
183
183
  data-ouia-component-id="HeaderExample-th-0"
184
184
  scope="col"
185
185
  tabindex="-1"
@@ -187,7 +187,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
187
187
  Repositories
188
188
  </th>
189
189
  <th
190
- class="pf-v6-c-table__th"
190
+ class="pf-v6-c-table__th pf-m-truncate"
191
191
  data-ouia-component-id="HeaderExample-th-1"
192
192
  scope="col"
193
193
  tabindex="-1"
@@ -195,7 +195,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
195
195
  Branches
196
196
  </th>
197
197
  <th
198
- class="pf-v6-c-table__th"
198
+ class="pf-v6-c-table__th pf-m-truncate"
199
199
  data-ouia-component-id="HeaderExample-th-2"
200
200
  scope="col"
201
201
  tabindex="-1"
@@ -203,7 +203,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
203
203
  Pull requests
204
204
  </th>
205
205
  <th
206
- class="pf-v6-c-table__th"
206
+ class="pf-v6-c-table__th pf-m-truncate"
207
207
  data-ouia-component-id="HeaderExample-th-3"
208
208
  scope="col"
209
209
  tabindex="-1"
@@ -211,7 +211,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
211
211
  Workspaces
212
212
  </th>
213
213
  <th
214
- class="pf-v6-c-table__th"
214
+ class="pf-v6-c-table__th pf-m-truncate"
215
215
  data-ouia-component-id="HeaderExample-th-4"
216
216
  scope="col"
217
217
  tabindex="-1"
@@ -101,6 +101,15 @@ describe('DataViewTableTree component', () => {
101
101
  expect(container).toMatchSnapshot();
102
102
  });
103
103
 
104
+ test('should render tree table with all expandable nodes expanded', () => {
105
+ const { container } = render(
106
+ <DataView selection={mockSelection}>
107
+ <DataViewTable isTreeTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} expandAll rows={rows} leafIcon={<LeafIcon/>} expandedIcon={<FolderOpenIcon aria-hidden />} collapsedIcon={<FolderIcon aria-hidden />} />
108
+ </DataView>
109
+ );
110
+ expect(container).toMatchSnapshot();
111
+ });
112
+
104
113
  test('should render tree table with a loading state', () => {
105
114
  const { container } = render(
106
115
  <DataView activeState="loading">
@@ -1,4 +1,4 @@
1
- import { FC, useState, useMemo, ReactNode } from 'react';
1
+ import { FC, useState, useMemo, useEffect, ReactNode } from 'react';
2
2
  import {
3
3
  Table,
4
4
  TableProps,
@@ -67,6 +67,8 @@ export interface DataViewTableTreeProps extends Omit<TableProps, 'onSelect' | 'r
67
67
  expandedIcon?: React.ReactNode;
68
68
  /** Optional icon for the collapsed parent rows */
69
69
  collapsedIcon?: React.ReactNode;
70
+ /** Expand all expandable nodes on initial load */
71
+ expandAll?: boolean;
70
72
  /** Custom OUIA ID */
71
73
  ouiaId?: string;
72
74
  }
@@ -79,6 +81,7 @@ export const DataViewTableTree: FC<DataViewTableTreeProps> = ({
79
81
  leafIcon = null,
80
82
  expandedIcon = null,
81
83
  collapsedIcon = null,
84
+ expandAll = false,
82
85
  ouiaId = 'DataViewTableTree',
83
86
  ...props
84
87
  }: DataViewTableTreeProps) => {
@@ -87,6 +90,37 @@ export const DataViewTableTree: FC<DataViewTableTreeProps> = ({
87
90
  const [ expandedNodeIds, setExpandedNodeIds ] = useState<string[]>([]);
88
91
  const [ expandedDetailsNodeNames, setExpandedDetailsNodeIds ] = useState<string[]>([]);
89
92
 
93
+ // Helper function to collect all node IDs that have children (are expandable)
94
+ const getExpandableNodeIds = (nodes: DataViewTrTree[]): string[] => {
95
+ const expandableIds: string[] = [];
96
+
97
+ const traverse = (nodeList: DataViewTrTree[]) => {
98
+ nodeList.forEach(node => {
99
+ if (node.children && node.children.length > 0) {
100
+ expandableIds.push(node.id);
101
+ traverse(node.children);
102
+ }
103
+ });
104
+ };
105
+
106
+ traverse(nodes);
107
+ return expandableIds;
108
+ };
109
+
110
+ // Effect to handle expandAll behavior
111
+ // Memoize the expandable IDs to avoid recalculating when rows object reference changes but structure is the same
112
+ const expandableIds = useMemo(() => getExpandableNodeIds(rows), [ rows ]);
113
+
114
+ // Effect to handle expandAll behavior - only runs when IDs actually change
115
+ useEffect(() => {
116
+ if (expandAll) {
117
+ setExpandedNodeIds(expandableIds);
118
+ } else {
119
+ setExpandedNodeIds([]);
120
+ }
121
+ // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ }, [ expandAll, expandableIds.join(',') ]);
123
+
90
124
  const activeHeadState = useMemo(() => activeState ? headStates?.[activeState] : undefined, [ activeState, headStates ]);
91
125
  const activeBodyState = useMemo(() => activeState ? bodyStates?.[activeState] : undefined, [ activeState, bodyStates ]);
92
126