@patternfly/react-data-view 6.3.0 → 6.4.0-prerelease.10
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 +1 -0
- 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 +1 -0
- 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 +6 -1
- package/src/InternalContext/InternalContext.tsx +2 -0
- package/src/index.ts +9 -0
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Pagination } from '@patternfly/react-core';
|
|
3
|
+
import { BrowserRouter, useSearchParams } from 'react-router-dom';
|
|
4
|
+
import { TreeViewDataItem } from '@patternfly/react-core';
|
|
5
|
+
import { useDataViewFilters, useDataViewPagination } from '@patternfly/react-data-view/dist/dynamic/Hooks';
|
|
6
|
+
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
7
|
+
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
8
|
+
import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
|
|
9
|
+
import { DataViewFilters } from '@patternfly/react-data-view/dist/dynamic/DataViewFilters';
|
|
10
|
+
import { DataViewTreeFilter } from '@patternfly/react-data-view/dist/dynamic/DataViewTreeFilter';
|
|
11
|
+
|
|
12
|
+
const perPageOptions = [
|
|
13
|
+
{ title: '5', value: 5 },
|
|
14
|
+
{ title: '10', value: 10 }
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
interface Repository {
|
|
18
|
+
name: string;
|
|
19
|
+
workspace: string;
|
|
20
|
+
tags: string[];
|
|
21
|
+
os: string;
|
|
22
|
+
lastSeen: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface RepositoryFilters {
|
|
26
|
+
name: string;
|
|
27
|
+
workspace: string[];
|
|
28
|
+
os: string[];
|
|
29
|
+
tags: string[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const repositories: Repository[] = [
|
|
33
|
+
{ name: 'Server-001', workspace: 'Development Workspace', tags: ['web', 'frontend'], os: 'Ubuntu 22.04', lastSeen: '2 hours ago' },
|
|
34
|
+
{ name: 'Server-002', workspace: 'Development Workspace', tags: ['api', 'backend'], os: 'RHEL 9', lastSeen: '5 hours ago' },
|
|
35
|
+
{ name: 'Server-003', workspace: 'Development Workspace', tags: ['database'], os: 'Windows Server 2022', lastSeen: '1 day ago' },
|
|
36
|
+
{ name: 'Server-004', workspace: 'Production Workspace', tags: ['web', 'frontend'], os: 'Ubuntu 22.04', lastSeen: '30 minutes ago' },
|
|
37
|
+
{ name: 'Server-005', workspace: 'Production Workspace', tags: ['api', 'backend'], os: 'Debian 12', lastSeen: '1 hour ago' },
|
|
38
|
+
{ name: 'Server-006', workspace: 'Production Workspace', tags: ['monitoring'], os: 'macOS Ventura', lastSeen: '3 hours ago' },
|
|
39
|
+
{ name: 'Server-007', workspace: 'Production Workspace', tags: ['cache'], os: 'macOS Sonoma', lastSeen: '2 days ago' },
|
|
40
|
+
{ name: 'Server-008', workspace: 'Testing Workspace', tags: ['test', 'frontend'], os: 'CentOS 8', lastSeen: '6 hours ago' },
|
|
41
|
+
{ name: 'Server-009', workspace: 'Testing Workspace', tags: ['test', 'backend'], os: 'Fedora 38', lastSeen: '4 hours ago' }
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const osOptions: TreeViewDataItem[] = [
|
|
46
|
+
{
|
|
47
|
+
name: 'Linux',
|
|
48
|
+
id: 'os-linux',
|
|
49
|
+
checkProps: { 'aria-label': 'linux-check', checked: false },
|
|
50
|
+
children: [
|
|
51
|
+
{
|
|
52
|
+
name: 'Ubuntu 22.04',
|
|
53
|
+
id: 'os-ubuntu',
|
|
54
|
+
checkProps: { checked: false }
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'RHEL 9',
|
|
58
|
+
id: 'os-rhel',
|
|
59
|
+
checkProps: { checked: false }
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'Debian 12',
|
|
63
|
+
id: 'os-debian',
|
|
64
|
+
checkProps: { checked: false }
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'CentOS 8',
|
|
68
|
+
id: 'os-centos',
|
|
69
|
+
checkProps: { checked: false }
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Fedora 38',
|
|
73
|
+
id: 'os-fedora',
|
|
74
|
+
checkProps: { checked: false }
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
defaultExpanded: true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'Windows',
|
|
81
|
+
id: 'os-windows',
|
|
82
|
+
checkProps: { 'aria-label': 'windows-check', checked: false },
|
|
83
|
+
children: [
|
|
84
|
+
{
|
|
85
|
+
name: 'Windows Server 2022',
|
|
86
|
+
id: 'os-windows-2022',
|
|
87
|
+
checkProps: { checked: false }
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'macOS',
|
|
93
|
+
id: 'os-macos',
|
|
94
|
+
checkProps: { 'aria-label': 'macos-check', checked: false },
|
|
95
|
+
children: [
|
|
96
|
+
{
|
|
97
|
+
name: 'macOS Ventura',
|
|
98
|
+
id: 'os-macos-ventura',
|
|
99
|
+
checkProps: { checked: false }
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'macOS Sonoma',
|
|
103
|
+
id: 'os-macos-sonoma',
|
|
104
|
+
checkProps: { checked: false }
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
const tagOptions: TreeViewDataItem[] = [
|
|
111
|
+
{
|
|
112
|
+
name: 'Environment',
|
|
113
|
+
id: 'tags-env',
|
|
114
|
+
checkProps: { 'aria-label': 'env-check', checked: false },
|
|
115
|
+
children: [
|
|
116
|
+
{
|
|
117
|
+
name: 'web',
|
|
118
|
+
id: 'tag-web',
|
|
119
|
+
checkProps: { checked: false }
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'api',
|
|
123
|
+
id: 'tag-api',
|
|
124
|
+
checkProps: { checked: false }
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'database',
|
|
128
|
+
id: 'tag-database',
|
|
129
|
+
checkProps: { checked: false }
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
defaultExpanded: true
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
name: 'Layer',
|
|
136
|
+
id: 'tags-layer',
|
|
137
|
+
checkProps: { 'aria-label': 'layer-check', checked: false },
|
|
138
|
+
children: [
|
|
139
|
+
{
|
|
140
|
+
name: 'frontend',
|
|
141
|
+
id: 'tag-frontend',
|
|
142
|
+
checkProps: { checked: false }
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'backend',
|
|
146
|
+
id: 'tag-backend',
|
|
147
|
+
checkProps: { checked: false }
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'Other',
|
|
153
|
+
id: 'tags-other',
|
|
154
|
+
checkProps: { 'aria-label': 'other-check', checked: false },
|
|
155
|
+
children: [
|
|
156
|
+
{
|
|
157
|
+
name: 'monitoring',
|
|
158
|
+
id: 'tag-monitoring',
|
|
159
|
+
checkProps: { checked: false }
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'cache',
|
|
163
|
+
id: 'tag-cache',
|
|
164
|
+
checkProps: { checked: false }
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'test',
|
|
168
|
+
id: 'tag-test',
|
|
169
|
+
checkProps: { checked: false }
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
const columns = ['Name', 'Workspace', 'Tags', 'OS', 'Last seen'];
|
|
176
|
+
|
|
177
|
+
const ouiaId = 'TreeFilterExample';
|
|
178
|
+
|
|
179
|
+
const MyTable: React.FunctionComponent = () => {
|
|
180
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
181
|
+
const { filters, onSetFilters, clearAllFilters } = useDataViewFilters<RepositoryFilters>({
|
|
182
|
+
initialFilters: { name: '', workspace: [], os: [], tags: [] },
|
|
183
|
+
searchParams,
|
|
184
|
+
setSearchParams,
|
|
185
|
+
});
|
|
186
|
+
const pagination = useDataViewPagination({ perPage: 5 });
|
|
187
|
+
const { page, perPage } = pagination;
|
|
188
|
+
|
|
189
|
+
const filteredData = useMemo(
|
|
190
|
+
() =>
|
|
191
|
+
repositories.filter(
|
|
192
|
+
(item) =>
|
|
193
|
+
(!filters.name || item.name?.toLocaleLowerCase().includes(filters.name?.toLocaleLowerCase())) &&
|
|
194
|
+
(!filters.workspace || filters.workspace.length === 0 || filters.workspace.includes(item.workspace)) &&
|
|
195
|
+
(!filters.os || filters.os.length === 0 || filters.os.includes(item.os)) &&
|
|
196
|
+
(!filters.tags || filters.tags.length === 0 || filters.tags.some(tag => item.tags.includes(tag)))
|
|
197
|
+
),
|
|
198
|
+
[filters]
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const pageRows = useMemo(
|
|
202
|
+
() =>
|
|
203
|
+
filteredData
|
|
204
|
+
.slice((page - 1) * perPage, (page - 1) * perPage + perPage)
|
|
205
|
+
.map((item) => [item.name, item.workspace, item.tags.join(', '), item.os, item.lastSeen]),
|
|
206
|
+
[page, perPage, filteredData]
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<DataView>
|
|
211
|
+
<DataViewToolbar
|
|
212
|
+
ouiaId="TreeFilterExampleHeader"
|
|
213
|
+
clearAllFilters={clearAllFilters}
|
|
214
|
+
pagination={<Pagination perPageOptions={perPageOptions} itemCount={filteredData.length} {...pagination} />}
|
|
215
|
+
filters={
|
|
216
|
+
<DataViewFilters onChange={(_e, values) => onSetFilters(values)} values={filters}>
|
|
217
|
+
<DataViewTreeFilter
|
|
218
|
+
filterId="os"
|
|
219
|
+
title="Operating System"
|
|
220
|
+
items={osOptions}
|
|
221
|
+
defaultExpanded={false}
|
|
222
|
+
/>
|
|
223
|
+
<DataViewTreeFilter
|
|
224
|
+
filterId="tags"
|
|
225
|
+
title="Tags"
|
|
226
|
+
items={tagOptions}
|
|
227
|
+
defaultExpanded={false}
|
|
228
|
+
defaultSelected={['tag-web', 'tag-api']}
|
|
229
|
+
/>
|
|
230
|
+
</DataViewFilters>
|
|
231
|
+
}
|
|
232
|
+
/>
|
|
233
|
+
<DataViewTable aria-label="Repositories table" ouiaId={ouiaId} columns={columns} rows={pageRows} />
|
|
234
|
+
<DataViewToolbar
|
|
235
|
+
ouiaId="TreeFilterExampleFooter"
|
|
236
|
+
pagination={
|
|
237
|
+
<Pagination isCompact perPageOptions={perPageOptions} itemCount={filteredData.length} {...pagination} />
|
|
238
|
+
}
|
|
239
|
+
/>
|
|
240
|
+
</DataView>
|
|
241
|
+
);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export const TreeFilterExample: React.FunctionComponent = () => (
|
|
245
|
+
<BrowserRouter>
|
|
246
|
+
<MyTable />
|
|
247
|
+
</BrowserRouter>
|
|
248
|
+
);
|
package/release.config.js
CHANGED
|
@@ -135,7 +135,6 @@ exports[`DataViewCheckboxFilter component should render correctly 1`] = `
|
|
|
135
135
|
class="pf-v6-c-label__actions"
|
|
136
136
|
>
|
|
137
137
|
<button
|
|
138
|
-
aria-disabled="false"
|
|
139
138
|
aria-label="Close Workspace one"
|
|
140
139
|
class="pf-v6-c-button pf-m-plain pf-m-no-padding"
|
|
141
140
|
data-ouia-component-id="OUIA-Generated-Button-plain-1"
|
|
@@ -176,7 +175,6 @@ exports[`DataViewCheckboxFilter component should render correctly 1`] = `
|
|
|
176
175
|
class="pf-v6-c-toolbar__item"
|
|
177
176
|
>
|
|
178
177
|
<button
|
|
179
|
-
aria-disabled="false"
|
|
180
178
|
class="pf-v6-c-button pf-m-link pf-m-inline"
|
|
181
179
|
data-ouia-component-id="DataViewToolbar-clear-all-filters"
|
|
182
180
|
data-ouia-component-type="PF6/Button"
|
|
@@ -26,7 +26,6 @@ exports[`DataViewFilters component should render correctly 1`] = `
|
|
|
26
26
|
class="pf-v6-c-toolbar__toggle"
|
|
27
27
|
>
|
|
28
28
|
<button
|
|
29
|
-
aria-disabled="false"
|
|
30
29
|
aria-haspopup="false"
|
|
31
30
|
aria-label="Show Filters"
|
|
32
31
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -173,7 +172,6 @@ exports[`DataViewFilters component should render correctly 1`] = `
|
|
|
173
172
|
class="pf-v6-c-toolbar__item"
|
|
174
173
|
>
|
|
175
174
|
<button
|
|
176
|
-
aria-disabled="false"
|
|
177
175
|
class="pf-v6-c-button pf-m-link pf-m-inline"
|
|
178
176
|
data-ouia-component-id="DataViewToolbar-clear-all-filters"
|
|
179
177
|
data-ouia-component-type="PF6/Button"
|
|
@@ -1,46 +1,57 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
TdProps,
|
|
4
|
-
ThProps,
|
|
5
|
-
TrProps
|
|
6
|
-
} from '@patternfly/react-table';
|
|
2
|
+
import { TdProps, ThProps, TrProps, InnerScrollContainer } from '@patternfly/react-table';
|
|
7
3
|
import { DataViewTableTree, DataViewTableTreeProps } from '../DataViewTableTree';
|
|
8
|
-
import { DataViewTableBasic, DataViewTableBasicProps } from '../DataViewTableBasic';
|
|
4
|
+
import { DataViewTableBasic, DataViewTableBasicProps, ExpandableContent } from '../DataViewTableBasic';
|
|
5
|
+
import { DataViewThResizableProps } from '../DataViewTh/DataViewTh';
|
|
6
|
+
|
|
7
|
+
export type { ExpandableContent };
|
|
9
8
|
|
|
10
9
|
// Table head typings
|
|
11
|
-
export type DataViewTh =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
export type DataViewTh =
|
|
11
|
+
| ReactNode
|
|
12
|
+
| {
|
|
13
|
+
/** Table head cell node */
|
|
14
|
+
cell: ReactNode;
|
|
15
|
+
/** Additional props for a resizable column */
|
|
16
|
+
resizableProps?: DataViewThResizableProps;
|
|
17
|
+
/** Props passed to Th */
|
|
18
|
+
props?: ThProps;
|
|
19
|
+
};
|
|
20
|
+
export const isDataViewThObject = (value: DataViewTh): value is { cell: ReactNode; props?: ThProps } =>
|
|
21
|
+
value != null && typeof value === 'object' && 'cell' in value;
|
|
18
22
|
|
|
19
23
|
// Basic table typings
|
|
20
24
|
export interface DataViewTrObject {
|
|
21
25
|
/** Array of rows */
|
|
22
|
-
row: DataViewTd[]
|
|
26
|
+
row: DataViewTd[];
|
|
23
27
|
/** Unique identifier of a row */
|
|
24
|
-
id?: string
|
|
28
|
+
id?: string;
|
|
25
29
|
/** Props passed to Tr */
|
|
26
|
-
props?: TrProps
|
|
30
|
+
props?: TrProps;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
export type DataViewTd =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
export type DataViewTd =
|
|
34
|
+
| ReactNode
|
|
35
|
+
| {
|
|
36
|
+
/** Table body cell node */
|
|
37
|
+
cell: ReactNode;
|
|
38
|
+
/** Props passed to Td */
|
|
39
|
+
props?: TdProps;
|
|
40
|
+
};
|
|
35
41
|
|
|
36
42
|
export type DataViewTr = DataViewTd[] | DataViewTrObject;
|
|
37
43
|
|
|
38
|
-
export const isDataViewTdObject = (value: DataViewTd): value is { cell: ReactNode; props?: TdProps } =>
|
|
39
|
-
|
|
44
|
+
export const isDataViewTdObject = (value: DataViewTd): value is { cell: ReactNode; props?: TdProps } =>
|
|
45
|
+
value != null && typeof value === 'object' && 'cell' in value;
|
|
46
|
+
export const isDataViewTrObject = (value: DataViewTr): value is { row: DataViewTd[]; id?: string } =>
|
|
47
|
+
value != null && typeof value === 'object' && 'row' in value;
|
|
40
48
|
|
|
41
49
|
// Tree table typings
|
|
42
50
|
/** extends DataViewTrObject */
|
|
43
|
-
export interface DataViewTrTree extends DataViewTrObject {
|
|
51
|
+
export interface DataViewTrTree extends DataViewTrObject {
|
|
52
|
+
id: string;
|
|
53
|
+
children?: DataViewTrTree[];
|
|
54
|
+
}
|
|
44
55
|
|
|
45
56
|
export type DataViewTableProps =
|
|
46
57
|
| ({
|
|
@@ -48,10 +59,22 @@ export type DataViewTableProps =
|
|
|
48
59
|
} & DataViewTableTreeProps)
|
|
49
60
|
| ({
|
|
50
61
|
isTreeTable?: false;
|
|
62
|
+
isResizable?: boolean;
|
|
51
63
|
} & DataViewTableBasicProps);
|
|
52
64
|
|
|
53
|
-
export const DataViewTable: FC<DataViewTableProps> = (props) =>
|
|
54
|
-
props.isTreeTable
|
|
55
|
-
|
|
65
|
+
export const DataViewTable: FC<DataViewTableProps> = (props) => {
|
|
66
|
+
if (props.isTreeTable) {
|
|
67
|
+
return <DataViewTableTree {...props} />;
|
|
68
|
+
} else {
|
|
69
|
+
const { isResizable, ...rest } = props;
|
|
70
|
+
return isResizable ? (
|
|
71
|
+
<InnerScrollContainer>
|
|
72
|
+
<DataViewTableBasic hasResizableColumns {...rest} />
|
|
73
|
+
</InnerScrollContainer>
|
|
74
|
+
) : (
|
|
75
|
+
<DataViewTableBasic {...rest} />
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
56
79
|
|
|
57
80
|
export default DataViewTable;
|
|
@@ -4,7 +4,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
4
4
|
<div>
|
|
5
5
|
<table
|
|
6
6
|
aria-label="Repositories table"
|
|
7
|
-
class="pf-v6-c-table pf-m-grid-md"
|
|
7
|
+
class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
|
|
8
8
|
data-ouia-component-id="TableExample"
|
|
9
9
|
data-ouia-component-type="PF6/Table"
|
|
10
10
|
data-ouia-safe="true"
|
|
@@ -21,7 +21,7 @@ exports[`DataViewTable component should render a basic table 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 a basic table 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 a basic table 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 a basic table 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 a basic table 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"
|
|
@@ -67,7 +67,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
67
67
|
role="rowgroup"
|
|
68
68
|
>
|
|
69
69
|
<tr
|
|
70
|
-
class="pf-v6-c-table__tr"
|
|
70
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
71
71
|
data-ouia-component-id="TableExample-tr-0"
|
|
72
72
|
data-ouia-component-type="PF6/TableRow"
|
|
73
73
|
data-ouia-safe="true"
|
|
@@ -109,7 +109,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
109
109
|
</td>
|
|
110
110
|
</tr>
|
|
111
111
|
<tr
|
|
112
|
-
class="pf-v6-c-table__tr"
|
|
112
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
113
113
|
data-ouia-component-id="TableExample-tr-1"
|
|
114
114
|
data-ouia-component-type="PF6/TableRow"
|
|
115
115
|
data-ouia-safe="true"
|
|
@@ -151,7 +151,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
151
151
|
</td>
|
|
152
152
|
</tr>
|
|
153
153
|
<tr
|
|
154
|
-
class="pf-v6-c-table__tr"
|
|
154
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
155
155
|
data-ouia-component-id="TableExample-tr-2"
|
|
156
156
|
data-ouia-component-type="PF6/TableRow"
|
|
157
157
|
data-ouia-safe="true"
|
|
@@ -193,7 +193,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
193
193
|
</td>
|
|
194
194
|
</tr>
|
|
195
195
|
<tr
|
|
196
|
-
class="pf-v6-c-table__tr"
|
|
196
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
197
197
|
data-ouia-component-id="TableExample-tr-3"
|
|
198
198
|
data-ouia-component-type="PF6/TableRow"
|
|
199
199
|
data-ouia-safe="true"
|
|
@@ -235,7 +235,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
235
235
|
</td>
|
|
236
236
|
</tr>
|
|
237
237
|
<tr
|
|
238
|
-
class="pf-v6-c-table__tr"
|
|
238
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
239
239
|
data-ouia-component-id="TableExample-tr-4"
|
|
240
240
|
data-ouia-component-type="PF6/TableRow"
|
|
241
241
|
data-ouia-safe="true"
|
|
@@ -277,7 +277,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
277
277
|
</td>
|
|
278
278
|
</tr>
|
|
279
279
|
<tr
|
|
280
|
-
class="pf-v6-c-table__tr"
|
|
280
|
+
class="pf-v6-c-table__tr pf-v6-c-table__control-row"
|
|
281
281
|
data-ouia-component-id="TableExample-tr-5"
|
|
282
282
|
data-ouia-component-type="PF6/TableRow"
|
|
283
283
|
data-ouia-safe="true"
|
|
@@ -344,7 +344,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
344
344
|
data-ouia-safe="true"
|
|
345
345
|
>
|
|
346
346
|
<th
|
|
347
|
-
class="pf-v6-c-table__th"
|
|
347
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
348
348
|
data-ouia-component-id="TableExample-th-0"
|
|
349
349
|
scope="col"
|
|
350
350
|
tabindex="-1"
|
|
@@ -352,7 +352,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
352
352
|
Repositories
|
|
353
353
|
</th>
|
|
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-1"
|
|
357
357
|
scope="col"
|
|
358
358
|
tabindex="-1"
|
|
@@ -360,7 +360,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
360
360
|
Branches
|
|
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-2"
|
|
365
365
|
scope="col"
|
|
366
366
|
tabindex="-1"
|
|
@@ -368,7 +368,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
368
368
|
Pull requests
|
|
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-3"
|
|
373
373
|
scope="col"
|
|
374
374
|
tabindex="-1"
|
|
@@ -376,7 +376,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
376
376
|
Workspaces
|
|
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-4"
|
|
381
381
|
scope="col"
|
|
382
382
|
tabindex="-1"
|
|
@@ -411,7 +411,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
411
411
|
class="pf-v6-c-table__toggle"
|
|
412
412
|
>
|
|
413
413
|
<button
|
|
414
|
-
aria-disabled="false"
|
|
415
414
|
aria-expanded="false"
|
|
416
415
|
aria-label="Expand row 0"
|
|
417
416
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -457,7 +456,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
457
456
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
458
457
|
>
|
|
459
458
|
<button
|
|
460
|
-
aria-disabled="false"
|
|
461
459
|
aria-expanded="false"
|
|
462
460
|
aria-label="Show row details"
|
|
463
461
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -553,7 +551,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
553
551
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
554
552
|
>
|
|
555
553
|
<button
|
|
556
|
-
aria-disabled="false"
|
|
557
554
|
aria-expanded="false"
|
|
558
555
|
aria-label="Show row details"
|
|
559
556
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -649,7 +646,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
649
646
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
650
647
|
>
|
|
651
648
|
<button
|
|
652
|
-
aria-disabled="false"
|
|
653
649
|
aria-expanded="false"
|
|
654
650
|
aria-label="Show row details"
|
|
655
651
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -735,7 +731,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
735
731
|
class="pf-v6-c-table__toggle"
|
|
736
732
|
>
|
|
737
733
|
<button
|
|
738
|
-
aria-disabled="false"
|
|
739
734
|
aria-expanded="false"
|
|
740
735
|
aria-label="Expand row 3"
|
|
741
736
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -781,7 +776,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
781
776
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
782
777
|
>
|
|
783
778
|
<button
|
|
784
|
-
aria-disabled="false"
|
|
785
779
|
aria-expanded="false"
|
|
786
780
|
aria-label="Show row details"
|
|
787
781
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -877,7 +871,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
877
871
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
878
872
|
>
|
|
879
873
|
<button
|
|
880
|
-
aria-disabled="false"
|
|
881
874
|
aria-expanded="false"
|
|
882
875
|
aria-label="Show row details"
|
|
883
876
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -972,7 +965,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
972
965
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
973
966
|
>
|
|
974
967
|
<button
|
|
975
|
-
aria-disabled="false"
|
|
976
968
|
aria-expanded="false"
|
|
977
969
|
aria-label="Show row details"
|
|
978
970
|
class="pf-v6-c-button pf-m-plain"
|