@patternfly/react-data-view 6.3.0 → 6.4.0-prerelease.11
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.
- package/dist/cjs/DataViewTable/DataViewTable.d.ts +6 -1
- package/dist/cjs/DataViewTable/DataViewTable.js +21 -1
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +13 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +46 -6
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +47 -9
- package/dist/cjs/DataViewTableHead/DataViewTableHead.d.ts +2 -0
- package/dist/cjs/DataViewTableHead/DataViewTableHead.js +5 -4
- package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +2 -0
- package/dist/cjs/DataViewTableTree/DataViewTableTree.js +28 -1
- package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +4 -0
- package/dist/cjs/DataViewTh/DataViewTh.d.ts +32 -0
- package/dist/cjs/DataViewTh/DataViewTh.js +222 -0
- package/dist/cjs/DataViewTh/index.d.ts +2 -0
- package/dist/cjs/DataViewTh/index.js +23 -0
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.d.ts +26 -0
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.js +229 -0
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.test.d.ts +1 -0
- package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.test.js +171 -0
- package/dist/cjs/DataViewTreeFilter/index.d.ts +2 -0
- package/dist/cjs/DataViewTreeFilter/index.js +23 -0
- package/dist/cjs/Hooks/selection.d.ts +8 -7
- package/dist/cjs/Hooks/selection.js +5 -1
- package/dist/cjs/Hooks/selection.test.js +48 -0
- package/dist/cjs/InternalContext/InternalContext.d.ts +2 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +10 -1
- package/dist/dynamic/DataViewTh/package.json +1 -0
- package/dist/dynamic/DataViewTreeFilter/package.json +1 -0
- package/dist/dynamic-modules.json +62 -0
- package/dist/esm/DataViewTable/DataViewTable.d.ts +6 -1
- package/dist/esm/DataViewTable/DataViewTable.js +21 -1
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +13 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +48 -8
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +45 -10
- package/dist/esm/DataViewTableHead/DataViewTableHead.d.ts +2 -0
- package/dist/esm/DataViewTableHead/DataViewTableHead.js +5 -4
- package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +2 -0
- package/dist/esm/DataViewTableTree/DataViewTableTree.js +29 -2
- package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +4 -0
- package/dist/esm/DataViewTh/DataViewTh.d.ts +32 -0
- package/dist/esm/DataViewTh/DataViewTh.js +215 -0
- package/dist/esm/DataViewTh/index.d.ts +2 -0
- package/dist/esm/DataViewTh/index.js +2 -0
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.d.ts +26 -0
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.js +225 -0
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.test.d.ts +1 -0
- package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.test.js +166 -0
- package/dist/esm/DataViewTreeFilter/index.d.ts +2 -0
- package/dist/esm/DataViewTreeFilter/index.js +2 -0
- package/dist/esm/Hooks/selection.d.ts +8 -7
- package/dist/esm/Hooks/selection.js +5 -1
- package/dist/esm/Hooks/selection.test.js +48 -0
- package/dist/esm/InternalContext/InternalContext.d.ts +2 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generate-fed-package-json.js +18 -0
- package/generate-index.js +2 -2
- package/package.json +12 -12
- package/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md +10 -4
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableExpandableExample.tsx +108 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableInteractiveExample.tsx +148 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableResizableColumnsExample.tsx +155 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableStickyExample.tsx +90 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableTreeExample.tsx +1 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +113 -14
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/SelectionExample.tsx +14 -3
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md +10 -2
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/TreeFilterExample.tsx +248 -0
- package/patternfly-docs/patternfly-docs.config.js +4 -1
- package/release.config.js +1 -1
- package/src/DataViewCheckboxFilter/__snapshots__/DataViewCheckboxFilter.test.tsx.snap +0 -2
- package/src/DataViewFilters/__snapshots__/DataViewFilters.test.tsx.snap +0 -2
- package/src/DataViewTable/DataViewTable.tsx +51 -28
- package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +17 -25
- package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +54 -12
- package/src/DataViewTableBasic/DataViewTableBasic.tsx +104 -10
- package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +30 -30
- package/src/DataViewTableHead/DataViewTableHead.tsx +24 -23
- package/src/DataViewTableHead/__snapshots__/DataViewTableHead.test.tsx.snap +15 -15
- package/src/DataViewTableTree/DataViewTableTree.test.tsx +9 -0
- package/src/DataViewTableTree/DataViewTableTree.tsx +35 -1
- package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +977 -28
- package/src/DataViewTextFilter/__snapshots__/DataViewTextFilter.test.tsx.snap +0 -3
- package/src/DataViewTh/DataViewTh.tsx +342 -0
- package/src/DataViewTh/index.ts +2 -0
- package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +0 -10
- package/src/DataViewTreeFilter/DataViewTreeFilter.test.tsx +222 -0
- package/src/DataViewTreeFilter/DataViewTreeFilter.tsx +361 -0
- package/src/DataViewTreeFilter/__snapshots__/DataViewTreeFilter.test.tsx.snap +199 -0
- package/src/DataViewTreeFilter/index.ts +2 -0
- package/src/Hooks/selection.test.tsx +65 -1
- package/src/Hooks/selection.ts +13 -8
- package/src/InternalContext/InternalContext.tsx +2 -0
- package/src/index.ts +9 -0
|
@@ -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
|
|