@patternfly/react-data-view 6.4.0 → 6.5.0-prerelease.1
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 +2 -1
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +11 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +46 -6
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +47 -9
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.d.ts +2 -0
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.js +29 -1
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.test.d.ts +1 -1
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.test.js +83 -0
- package/dist/cjs/DataViewTh/DataViewTh.d.ts +4 -4
- package/dist/cjs/DataViewTh/DataViewTh.js +8 -1
- package/dist/cjs/DataViewTh/index.d.ts +2 -0
- package/dist/cjs/DataViewTh/index.js +23 -0
- package/dist/cjs/DataViewToolbar/DataViewToolbar.js +13 -1
- 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 -8
- 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 +2 -1
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +11 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +48 -8
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +45 -10
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.d.ts +2 -0
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.js +29 -1
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.test.d.ts +1 -1
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.test.js +84 -1
- package/dist/esm/DataViewTh/DataViewTh.d.ts +4 -4
- package/dist/esm/DataViewTh/DataViewTh.js +8 -1
- package/dist/esm/DataViewTh/index.d.ts +2 -0
- package/dist/esm/DataViewTh/index.js +2 -0
- package/dist/esm/DataViewToolbar/DataViewToolbar.js +13 -1
- 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 -8
- 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 +6 -6
- package/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md +10 -4
- package/patternfly-docs/content/extensions/data-view/examples/DataView/PredefinedLayoutFullExample.tsx +2 -1
- 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/DataViewTableStickyExample.tsx +90 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +63 -2
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/FiltersExample.tsx +2 -1
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/PaginationExample.tsx +1 -1
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md +9 -2
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/TreeFilterExample.tsx +248 -0
- package/patternfly-docs/patternfly-docs.config.js +4 -1
- package/src/DataViewTable/DataViewTable.tsx +3 -1
- package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +7 -7
- package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +54 -12
- package/src/DataViewTableBasic/DataViewTableBasic.tsx +101 -10
- package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +10 -10
- package/src/DataViewTextFilter/DataViewTextFilter.test.tsx +129 -0
- package/src/DataViewTextFilter/DataViewTextFilter.tsx +58 -22
- package/src/DataViewTh/DataViewTh.tsx +15 -7
- package/src/DataViewTh/index.ts +2 -0
- package/src/DataViewToolbar/DataViewToolbar.tsx +17 -2
- package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +288 -280
- 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.ts +8 -8
- package/src/index.ts +9 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { FunctionComponent, useState } from 'react';
|
|
2
|
+
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
3
|
+
import { ExpandableContent } from '@patternfly/react-data-view/dist/dynamic/DataViewTableBasic';
|
|
4
|
+
import { ExclamationCircleIcon } from '@patternfly/react-icons';
|
|
5
|
+
import { Button, Toolbar, ToolbarContent, ToolbarItem, Switch } from '@patternfly/react-core';
|
|
6
|
+
|
|
7
|
+
interface Repository {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
branches: string | null;
|
|
11
|
+
prs: string | null;
|
|
12
|
+
workspaces: string;
|
|
13
|
+
lastCommit: string;
|
|
14
|
+
contributors: string;
|
|
15
|
+
stars: string;
|
|
16
|
+
forks: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const expandableContents: ExpandableContent[] = [
|
|
20
|
+
// Row 1 - Repository one
|
|
21
|
+
{ rowId: 1, columnId: 2, content: <div><strong>Branch Details:</strong> 5 active branches, main, develop, feature/new-ui, hotfix/bug-123, release/v2.0</div> },
|
|
22
|
+
{ rowId: 1, columnId: 3, content: <div><strong>PR Details:</strong> 3 open PRs, 45 merged this month, avg review time: 2 days</div> },
|
|
23
|
+
{ rowId: 1, columnId: 5, content: <div><strong>Commit Info:</strong> Author: John Doe, Message: "Fix critical authentication bug", SHA: a1b2c3d</div> },
|
|
24
|
+
|
|
25
|
+
// Row 2 - Repository two
|
|
26
|
+
{ rowId: 2, columnId: 2, content: <div><strong>Branch Details:</strong> 8 active branches, main, staging, feature/api-v2, feature/dashboard</div> },
|
|
27
|
+
{ rowId: 2, columnId: 3, content: <div><strong>PR Details:</strong> 5 open PRs, 120 merged this month, avg review time: 1.5 days</div> },
|
|
28
|
+
{ rowId: 2, columnId: 4, content: <div><strong>Workspace Info:</strong> Development env, 3 active deployments, last updated 30 mins ago</div> },
|
|
29
|
+
{ rowId: 2, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Jane Smith, Message: "Add new API endpoints", SHA: x9y8z7w</div> },
|
|
30
|
+
|
|
31
|
+
// Row 3 - Repository three
|
|
32
|
+
{ rowId: 3, columnId: 2, content: <div><strong>Branch Details:</strong> 12 active branches including main, develop, multiple feature branches</div> },
|
|
33
|
+
{ rowId: 3, columnId: 3, content: <div><strong>PR Details:</strong> 8 open PRs, 200 merged this month, avg review time: 3 days</div> },
|
|
34
|
+
{ rowId: 3, columnId: 4, content: <div><strong>Workspace Info:</strong> Staging env, 10 active deployments, last updated 1 day ago</div> },
|
|
35
|
+
{ rowId: 3, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Bob Johnson, Message: "Refactor core modules", SHA: p0o9i8u</div> },
|
|
36
|
+
|
|
37
|
+
// Row 4 - Repository four
|
|
38
|
+
{ rowId: 4, columnId: 2, content: <div><strong>Branch Details:</strong> 6 active branches, focusing on microservices architecture</div> },
|
|
39
|
+
{ rowId: 4, columnId: 3, content: <div><strong>PR Details:</strong> 2 open PRs, 90 merged this month, avg review time: 2.5 days</div> },
|
|
40
|
+
{ rowId: 4, columnId: 4, content: <div><strong>Workspace Info:</strong> QA env, 7 active deployments, automated testing enabled</div> },
|
|
41
|
+
{ rowId: 4, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Alice Williams, Message: "Update dependencies", SHA: m5n4b3v</div> },
|
|
42
|
+
|
|
43
|
+
// Row 5 - Repository five
|
|
44
|
+
{ rowId: 5, columnId: 2, content: <div><strong>Branch Details:</strong> 4 active branches, clean branch strategy</div> },
|
|
45
|
+
{ rowId: 5, columnId: 3, content: <div><strong>PR Details:</strong> 6 open PRs, 75 merged this month, avg review time: 1 day</div> },
|
|
46
|
+
{ rowId: 5, columnId: 4, content: <div><strong>Workspace Info:</strong> Pre-production env, CI/CD pipeline configured</div> },
|
|
47
|
+
{ rowId: 5, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Charlie Brown, Message: "Implement dark mode", SHA: q2w3e4r</div> },
|
|
48
|
+
|
|
49
|
+
// Row 6 - Repository six
|
|
50
|
+
{ rowId: 6, columnId: 2, content: <div><strong>Branch Details:</strong> 15 active branches, complex branching model</div> },
|
|
51
|
+
{ rowId: 6, columnId: 3, content: <div><strong>PR Details:</strong> 10 open PRs, 250 merged this month, avg review time: 4 days</div> },
|
|
52
|
+
{ rowId: 6, columnId: 4, content: <div><strong>Workspace Info:</strong> Multi-region deployment, high availability setup</div> },
|
|
53
|
+
{ rowId: 6, columnId: 5, content: <div><strong>Commit Info:</strong> Author: David Lee, Message: "Security patches applied", SHA: t6y7u8i</div> },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const repositories: Repository[] = [
|
|
57
|
+
{ id: 1, name: 'Repository one', branches: 'Branch one', prs: 'Pull request one', workspaces: 'Workspace one', lastCommit: 'Timestamp one', contributors: '25 contributors', stars: '1.2k stars', forks: '340 forks' },
|
|
58
|
+
{ id: 2, name: 'Repository two', branches: 'Branch two', prs: 'Pull request two', workspaces: 'Workspace two', lastCommit: 'Timestamp two', contributors: '45 contributors', stars: '3.5k stars', forks: '890 forks' },
|
|
59
|
+
{ id: 3, name: 'Repository three', branches: 'Branch three', prs: 'Pull request three', workspaces: 'Workspace three', lastCommit: 'Timestamp three', contributors: '200 contributors', stars: '15k stars', forks: '2.1k forks' },
|
|
60
|
+
{ id: 4, name: 'Repository four', branches: 'Branch four', prs: 'Pull request four', workspaces: 'Workspace four', lastCommit: 'Timestamp four', contributors: '80 contributors', stars: '5.7k stars', forks: '1.2k forks' },
|
|
61
|
+
{ id: 5, name: 'Repository five', branches: 'Branch five', prs: 'Pull request five', workspaces: 'Workspace five', lastCommit: 'Timestamp five', contributors: '60 contributors', stars: '4.3k stars', forks: '780 forks' },
|
|
62
|
+
{ id: 6, name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six', contributors: '300 contributors', stars: '22k stars', forks: '4.5k forks' },
|
|
63
|
+
{ id: 7, name: 'Repository seven', branches: 'Branch seven', prs: 'Pull request seven', workspaces: 'Workspace seven', lastCommit: 'Timestamp seven', contributors: '12 contributors', stars: '567 stars', forks: '120 forks' },
|
|
64
|
+
{ id: 8, name: 'Repository eight', branches: 'Branch eight', prs: 'Pull request eight', workspaces: 'Workspace eight', lastCommit: 'Timestamp eight', contributors: '98 contributors', stars: '7.8k stars', forks: '1.5k forks' },
|
|
65
|
+
{ id: 9, name: 'Repository nine', branches: 'Branch nine', prs: 'Pull request nine', workspaces: 'Workspace nine', lastCommit: 'Timestamp nine', contributors: '33 contributors', stars: '2.1k stars', forks: '456 forks' },
|
|
66
|
+
{ id: 10, name: 'Repository ten', branches: 'Branch ten', prs: 'Pull request ten', workspaces: 'Workspace ten', lastCommit: 'Timestamp ten', contributors: '150 contributors', stars: '11k stars', forks: '2.8k forks' },
|
|
67
|
+
{ id: 11, name: 'Repository eleven', branches: 'Branch eleven', prs: 'Pull request eleven', workspaces: 'Workspace eleven', lastCommit: 'Timestamp eleven', contributors: '67 contributors', stars: '5.2k stars', forks: '980 forks' },
|
|
68
|
+
{ id: 12, name: 'Repository twelve', branches: 'Branch twelve', prs: 'Pull request twelve', workspaces: 'Workspace twelve', lastCommit: 'Timestamp twelve', contributors: '41 contributors', stars: '3.1k stars', forks: '670 forks' },
|
|
69
|
+
{ id: 13, name: 'Repository thirteen', branches: 'Branch thirteen', prs: 'Pull request thirteen', workspaces: 'Workspace thirteen', lastCommit: 'Timestamp thirteen', contributors: '89 contributors', stars: '6.4k stars', forks: '1.3k forks' },
|
|
70
|
+
{ id: 14, name: 'Repository fourteen', branches: 'Branch fourteen', prs: 'Pull request fourteen', workspaces: 'Workspace fourteen', lastCommit: 'Timestamp fourteen', contributors: '120 contributors', stars: '9.2k stars', forks: '1.9k forks' },
|
|
71
|
+
{ id: 15, name: 'Repository fifteen', branches: 'Branch fifteen', prs: 'Pull request fifteen', workspaces: 'Workspace fifteen', lastCommit: 'Timestamp fifteen', contributors: '78 contributors', stars: '5.9k stars', forks: '1.1k forks' }
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const ouiaId = 'TableInteractiveExample';
|
|
75
|
+
|
|
76
|
+
export const InteractiveExample: FunctionComponent = () => {
|
|
77
|
+
const [isExpandable, setIsExpandable] = useState(true);
|
|
78
|
+
const [isSticky, setIsSticky] = useState(true);
|
|
79
|
+
|
|
80
|
+
// Generate rows based on current settings
|
|
81
|
+
const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspaces, lastCommit, contributors, stars, forks }) => [
|
|
82
|
+
{
|
|
83
|
+
id,
|
|
84
|
+
cell: workspaces,
|
|
85
|
+
props: {
|
|
86
|
+
favorites: { isFavorited: true }
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{ cell: <Button href='#' variant='link' isInline>{name}</Button>, props: { isStickyColumn: isSticky, hasRightBorder: true, hasLeftBorder: true, modifier: "nowrap" } },
|
|
90
|
+
{ cell: branches, props: { modifier: "nowrap" } },
|
|
91
|
+
{ cell: prs, props: { modifier: "nowrap" } },
|
|
92
|
+
{ cell: workspaces, props: { modifier: "nowrap" } },
|
|
93
|
+
{ cell: lastCommit, props: { modifier: "nowrap" } },
|
|
94
|
+
{ cell: contributors, props: { modifier: "nowrap" } },
|
|
95
|
+
{ cell: stars, props: { modifier: "nowrap" } },
|
|
96
|
+
{ cell: forks, props: { modifier: "nowrap" } }
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
const columns: DataViewTh[] = [
|
|
100
|
+
null,
|
|
101
|
+
{ cell: 'Repositories', props: { isStickyColumn: isSticky, modifier: 'fitContent', hasRightBorder: true, hasLeftBorder: true } },
|
|
102
|
+
{ cell: <>Branches<ExclamationCircleIcon className='pf-v6-u-ml-sm' color="var(--pf-t--global--color--status--danger--default)"/></>, props: { width: 20 } },
|
|
103
|
+
{ cell: 'Pull requests', props: { width: 20 } },
|
|
104
|
+
{ cell: 'Workspaces', props: { info: { tooltip: 'More information' }, width: 20 } },
|
|
105
|
+
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 }, width: 20 } },
|
|
106
|
+
{ cell: 'Contributors', props: { width: 20 } },
|
|
107
|
+
{ cell: 'Stars', props: { width: 20 } },
|
|
108
|
+
{ cell: 'Forks', props: { width: 20 } },
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<>
|
|
113
|
+
<Toolbar>
|
|
114
|
+
<ToolbarContent>
|
|
115
|
+
<ToolbarItem>
|
|
116
|
+
<Switch
|
|
117
|
+
id="expandable-switch"
|
|
118
|
+
label="Expandable"
|
|
119
|
+
isChecked={isExpandable}
|
|
120
|
+
onChange={(_event, checked) => setIsExpandable(checked)}
|
|
121
|
+
aria-label="Toggle expandable rows"
|
|
122
|
+
/>
|
|
123
|
+
</ToolbarItem>
|
|
124
|
+
<ToolbarItem>
|
|
125
|
+
<Switch
|
|
126
|
+
id="sticky-switch"
|
|
127
|
+
label="Sticky header & column"
|
|
128
|
+
isChecked={isSticky}
|
|
129
|
+
onChange={(_event, checked) => setIsSticky(checked)}
|
|
130
|
+
aria-label="Toggle sticky header and columns"
|
|
131
|
+
/>
|
|
132
|
+
</ToolbarItem>
|
|
133
|
+
</ToolbarContent>
|
|
134
|
+
</Toolbar>
|
|
135
|
+
<div style={{ height: '400px', overflow: 'auto' }}>
|
|
136
|
+
<DataViewTable
|
|
137
|
+
aria-label='Interactive repositories table'
|
|
138
|
+
ouiaId={ouiaId}
|
|
139
|
+
columns={columns}
|
|
140
|
+
rows={rows}
|
|
141
|
+
expandedRows={isExpandable ? expandableContents : undefined}
|
|
142
|
+
isExpandable={isExpandable}
|
|
143
|
+
isSticky={isSticky}
|
|
144
|
+
/>
|
|
145
|
+
</div>
|
|
146
|
+
</>
|
|
147
|
+
);
|
|
148
|
+
};
|
package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableStickyExample.tsx
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
3
|
+
import { ExclamationCircleIcon } from '@patternfly/react-icons';
|
|
4
|
+
import { Button } from '@patternfly/react-core';
|
|
5
|
+
import { ActionsColumn } from '@patternfly/react-table';
|
|
6
|
+
|
|
7
|
+
interface Repository {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
branches: string | null;
|
|
11
|
+
prs: string | null;
|
|
12
|
+
workspaces: string;
|
|
13
|
+
lastCommit: string;
|
|
14
|
+
contributors: string;
|
|
15
|
+
stars: string;
|
|
16
|
+
forks: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const repositories: Repository[] = [
|
|
20
|
+
{ id: 1, name: 'Repository one', branches: 'Branch one', prs: 'Pull request one', workspaces: 'Workspace one', lastCommit: 'Timestamp one', contributors: '25 contributors', stars: '1.2k stars', forks: '340 forks' },
|
|
21
|
+
{ id: 2, name: 'Repository two', branches: 'Branch two', prs: 'Pull request two', workspaces: 'Workspace two', lastCommit: 'Timestamp two', contributors: '45 contributors', stars: '3.5k stars', forks: '890 forks' },
|
|
22
|
+
{ id: 3, name: 'Repository three', branches: 'Branch three', prs: 'Pull request three', workspaces: 'Workspace three', lastCommit: 'Timestamp three', contributors: '200 contributors', stars: '15k stars', forks: '2.1k forks' },
|
|
23
|
+
{ id: 4, name: 'Repository four', branches: 'Branch four', prs: 'Pull request four', workspaces: 'Workspace four', lastCommit: 'Timestamp four', contributors: '80 contributors', stars: '5.7k stars', forks: '1.2k forks' },
|
|
24
|
+
{ id: 5, name: 'Repository five', branches: 'Branch five', prs: 'Pull request five', workspaces: 'Workspace five', lastCommit: 'Timestamp five', contributors: '60 contributors', stars: '4.3k stars', forks: '780 forks' },
|
|
25
|
+
{ id: 6, name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six', contributors: '300 contributors', stars: '22k stars', forks: '4.5k forks' },
|
|
26
|
+
{ id: 7, name: 'Repository seven', branches: 'Branch seven', prs: 'Pull request seven', workspaces: 'Workspace seven', lastCommit: 'Timestamp seven', contributors: '12 contributors', stars: '567 stars', forks: '120 forks' },
|
|
27
|
+
{ id: 8, name: 'Repository eight', branches: 'Branch eight', prs: 'Pull request eight', workspaces: 'Workspace eight', lastCommit: 'Timestamp eight', contributors: '98 contributors', stars: '7.8k stars', forks: '1.5k forks' },
|
|
28
|
+
{ id: 9, name: 'Repository nine', branches: 'Branch nine', prs: 'Pull request nine', workspaces: 'Workspace nine', lastCommit: 'Timestamp nine', contributors: '33 contributors', stars: '2.1k stars', forks: '456 forks' },
|
|
29
|
+
{ id: 10, name: 'Repository ten', branches: 'Branch ten', prs: 'Pull request ten', workspaces: 'Workspace ten', lastCommit: 'Timestamp ten', contributors: '150 contributors', stars: '11k stars', forks: '2.8k forks' },
|
|
30
|
+
{ id: 11, name: 'Repository eleven', branches: 'Branch eleven', prs: 'Pull request eleven', workspaces: 'Workspace eleven', lastCommit: 'Timestamp eleven', contributors: '67 contributors', stars: '5.2k stars', forks: '980 forks' },
|
|
31
|
+
{ id: 12, name: 'Repository twelve', branches: 'Branch twelve', prs: 'Pull request twelve', workspaces: 'Workspace twelve', lastCommit: 'Timestamp twelve', contributors: '41 contributors', stars: '3.1k stars', forks: '670 forks' }
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const rowActions = [
|
|
35
|
+
{
|
|
36
|
+
title: 'Some action',
|
|
37
|
+
onClick: () => console.log('clicked on Some action') // eslint-disable-line no-console
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: <div>Another action</div>,
|
|
41
|
+
onClick: () => console.log('clicked on Another action') // eslint-disable-line no-console
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
isSeparator: true
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: 'Third action',
|
|
48
|
+
onClick: () => console.log('clicked on Third action') // eslint-disable-line no-console
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspaces, lastCommit, contributors, stars, forks }) => [
|
|
53
|
+
{ id, cell: workspaces, props: { favorites: { isFavorited: true } } },
|
|
54
|
+
{ cell: <Button href='#' variant='link' isInline>{name}</Button>, props: { isStickyColumn: true, hasRightBorder: true, hasLeftBorder: true, modifier: "nowrap" } },
|
|
55
|
+
{ cell: branches, props: { modifier: "nowrap" } },
|
|
56
|
+
{ cell: prs, props: { modifier: "nowrap" } },
|
|
57
|
+
{ cell: workspaces, props: { modifier: "nowrap" } },
|
|
58
|
+
{ cell: lastCommit, props: { modifier: "nowrap" } },
|
|
59
|
+
{ cell: contributors, props: { modifier: "nowrap" } },
|
|
60
|
+
{ cell: stars, props: { modifier: "nowrap" } },
|
|
61
|
+
{ cell: forks, props: { modifier: "nowrap" } },
|
|
62
|
+
{ cell: <ActionsColumn items={rowActions}/>, props: { isActionCell: true } },
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
const columns: DataViewTh[] = [
|
|
66
|
+
null,
|
|
67
|
+
{ cell: 'Repositories', props: { isStickyColumn: true, modifier: 'fitContent', hasRightBorder: true, hasLeftBorder: true } },
|
|
68
|
+
{ cell: <>Branches<ExclamationCircleIcon className='pf-v6-u-ml-sm' color="var(--pf-t--global--color--status--danger--default)"/></>, props: { width: 20 } },
|
|
69
|
+
{ cell: 'Pull requests', props: { width: 20 } },
|
|
70
|
+
{ cell: 'Workspaces', props: { info: { tooltip: 'More information' }, width: 20 } },
|
|
71
|
+
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 }, width: 20 } },
|
|
72
|
+
{ cell: 'Contributors', props: { width: 20 } },
|
|
73
|
+
{ cell: 'Stars', props: { width: 20 } },
|
|
74
|
+
{ cell: 'Forks', props: { width: 20 } },
|
|
75
|
+
null, // Actions column header
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
const ouiaId = 'TableStickyExample';
|
|
79
|
+
|
|
80
|
+
export const StickyExample: FunctionComponent = () => (
|
|
81
|
+
<div style={{ height: '400px', width: '800px', overflow: 'auto' }}>
|
|
82
|
+
<DataViewTable
|
|
83
|
+
aria-label='Sticky repositories table'
|
|
84
|
+
ouiaId={ouiaId}
|
|
85
|
+
columns={columns}
|
|
86
|
+
rows={rows}
|
|
87
|
+
isSticky
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
@@ -58,6 +58,67 @@ If you want to have all expandable nodes open on initial load pass the `expandAl
|
|
|
58
58
|
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
## Expandable rows
|
|
62
|
+
|
|
63
|
+
To add expandable content to table cells, pass an array of `ExpandableContent` objects to the `expandedRows` prop of the `<DataViewTable>` component. Each expandable content object defines which cell can be expanded and what content to display when expanded.
|
|
64
|
+
|
|
65
|
+
The `ExpandableContent` interface is defined as:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
interface ExpandableContent {
|
|
69
|
+
/** The ID of the row containing the expandable cell (must match the id property in the row data) */
|
|
70
|
+
rowId: number;
|
|
71
|
+
/** The column index (0-based) that should be expandable */
|
|
72
|
+
columnId: number;
|
|
73
|
+
/** The content to display when the cell is expanded */
|
|
74
|
+
content: ReactNode;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
When a cell has expandable content:
|
|
79
|
+
- A compound expand toggle button appears in the cell
|
|
80
|
+
- Clicking the toggle expands the row to show the additional content below
|
|
81
|
+
- Only one expanded cell is shown per row at a time
|
|
82
|
+
- Clicking another expandable cell in the same row switches the expanded content
|
|
83
|
+
|
|
84
|
+
### Expandable rows example
|
|
85
|
+
|
|
86
|
+
```js file="./DataViewTableExpandableExample.tsx"
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Sticky header and columns
|
|
91
|
+
|
|
92
|
+
To enable sticky headers and columns, set the `isSticky` prop to `true` on the `<DataViewTable>` component. This keeps the table header and designated columns visible when scrolling.
|
|
93
|
+
|
|
94
|
+
To make specific columns sticky, add the `isStickyColumn` property to the column's `props` in the column definition:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
const columns: DataViewTh[] = [
|
|
98
|
+
{ cell: 'Column Name', props: { isStickyColumn: true } }
|
|
99
|
+
];
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
When sticky headers and columns are enabled:
|
|
103
|
+
- The table header remains visible when scrolling vertically
|
|
104
|
+
- Columns marked with `isStickyColumn: true` remain visible when scrolling horizontally
|
|
105
|
+
- The table is wrapped in `OuterScrollContainer` and `InnerScrollContainer` components to enable sticky behavior
|
|
106
|
+
- Sticky columns can have additional styling like borders using `hasRightBorder` or `hasLeftBorder` props
|
|
107
|
+
|
|
108
|
+
### Sticky header and columns example
|
|
109
|
+
|
|
110
|
+
```js file="./DataViewTableStickyExample.tsx"
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Interactive example
|
|
115
|
+
- Interactive example show how the different composable options work together.
|
|
116
|
+
- By toggling the toggles you can switch between them and observe the behaviour
|
|
117
|
+
|
|
118
|
+
```js file="./DataViewTableInteractiveExample.tsx"
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
|
|
61
122
|
### Resizable columns
|
|
62
123
|
|
|
63
124
|
To allow a column to resize, add `isResizable` to the `DataViewTable` element, and pass `resizableProps` to each applicable header cell. The `resizableProps` object consists of the following fields:
|
|
@@ -149,7 +210,7 @@ When there is a data connection or retrieval error, you can display an error sta
|
|
|
149
210
|
|
|
150
211
|
The error state will be displayed when the data view `activeState` value is `error`.
|
|
151
212
|
|
|
152
|
-
You can create your error state by passing either the [component groups extension's error state](/component-groups/error-state) or a [PatternFly empty state](/components/empty-state) to the `error` key of `headStates` or `bodyStates`.
|
|
213
|
+
You can create your error state by passing either the [component groups extension's error state](/extensions/component-groups/error-state) or a [PatternFly empty state](/components/empty-state) to the `error` key of `headStates` or `bodyStates`.
|
|
153
214
|
|
|
154
215
|
```js file="./DataViewTableErrorExample.tsx"
|
|
155
216
|
|
|
@@ -161,7 +222,7 @@ To indicate that data is loading, you can display a loading state.
|
|
|
161
222
|
|
|
162
223
|
The loading state will be displayed when the data view `activeState` value is `loading`.
|
|
163
224
|
|
|
164
|
-
You can create your loading state by passing either the [component groups extension's skeleton table](/component-groups/skeleton-table) or a customized [PatternFly empty state](/components/empty-state) to the `loading` key of `headStates` or `bodyStates`.
|
|
225
|
+
You can create your loading state by passing either the [component groups extension's skeleton table](/extensions/component-groups/skeleton-table) or a customized [PatternFly empty state](/components/empty-state) to the `loading` key of `headStates` or `bodyStates`.
|
|
165
226
|
|
|
166
227
|
```js file="./DataViewTableLoadingExample.tsx"
|
|
167
228
|
|
|
@@ -44,7 +44,7 @@ const MyTable: React.FunctionComponent = () => {
|
|
|
44
44
|
<DataView>
|
|
45
45
|
<DataViewToolbar ouiaId='DataViewHeader' pagination={<Pagination perPageOptions={perPageOptions} itemCount={repositories.length} {...pagination} />} />
|
|
46
46
|
<DataViewTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} rows={pageRows} />
|
|
47
|
-
<DataViewToolbar ouiaId='DataViewFooter' pagination={<Pagination isCompact perPageOptions={perPageOptions} itemCount={repositories.length} {...pagination} />} />
|
|
47
|
+
<DataViewToolbar ouiaId='DataViewFooter' pagination={<Pagination isCompact variant="bottom" perPageOptions={perPageOptions} itemCount={repositories.length} {...pagination} />} />
|
|
48
48
|
</DataView>
|
|
49
49
|
);
|
|
50
50
|
};
|
|
@@ -12,7 +12,7 @@ source: react
|
|
|
12
12
|
# If you use typescript, the name of the interface to display props for
|
|
13
13
|
# These are found through the sourceProps function provided in patternfly-docs.source.js
|
|
14
14
|
sortValue: 2
|
|
15
|
-
propComponents: ['DataViewToolbar', 'DataViewFilters', 'DataViewTextFilter', 'DataViewCheckboxFilter']
|
|
15
|
+
propComponents: ['DataViewToolbar', 'DataViewFilters', 'DataViewTextFilter', 'DataViewCheckboxFilter', 'DataViewTreeFilter']
|
|
16
16
|
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md
|
|
17
17
|
---
|
|
18
18
|
import { useMemo, useState, useEffect } from 'react';
|
|
@@ -26,6 +26,7 @@ import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataView
|
|
|
26
26
|
import { DataViewFilters } from '@patternfly/react-data-view/dist/dynamic/DataViewFilters';
|
|
27
27
|
import { DataViewTextFilter } from '@patternfly/react-data-view/dist/dynamic/DataViewTextFilter';
|
|
28
28
|
import { DataViewCheckboxFilter } from '@patternfly/react-data-view/dist/dynamic/DataViewCheckboxFilter';
|
|
29
|
+
import { DataViewTreeFilter } from '@patternfly/react-data-view/dist/dynamic/DataViewTreeFilter';
|
|
29
30
|
|
|
30
31
|
The **data view toolbar** component renders a default opinionated data view toolbar above or below the data section.
|
|
31
32
|
|
|
@@ -44,7 +45,7 @@ You can further customize toolbar interactions by referring to the additional do
|
|
|
44
45
|
```
|
|
45
46
|
|
|
46
47
|
## Toolbar actions
|
|
47
|
-
To support additional user needs, you can pass relevant actions to the toolbar via `actions`. Add standard PatternFly actions (like buttons) or choose predefined [responsive actions](/component-groups/responsive-actions) which ensure the responsive behavior of multiple actions in 1 toolbar.
|
|
48
|
+
To support additional user needs, you can pass relevant actions to the toolbar via `actions`. Add standard PatternFly actions (like buttons) or choose predefined [responsive actions](/extensions/component-groups/responsive-actions) which ensure the responsive behavior of multiple actions in 1 toolbar.
|
|
48
49
|
|
|
49
50
|
### Actions example
|
|
50
51
|
|
|
@@ -143,6 +144,12 @@ This example demonstrates the setup and usage of filters within the data view. I
|
|
|
143
144
|
|
|
144
145
|
```
|
|
145
146
|
|
|
147
|
+
### Tree filter example
|
|
148
|
+
This example demonstrates the usage of a tree filter with hierarchical data. The tree filter allows users to select items from a nested structure, making it ideal for categorized or grouped filtering options.
|
|
149
|
+
|
|
150
|
+
```js file="./TreeFilterExample.tsx"
|
|
151
|
+
|
|
152
|
+
```
|
|
146
153
|
|
|
147
154
|
## All/selected data switch
|
|
148
155
|
All/selected data switch allows users to toggle between displaying the entire table (All) and only the rows they have selected (Selected). If the user deselects the last selected row, the filter automatically switches back to All, displaying all table rows again. Until at least one row is selected, a tooltip with guidance is displayed, and the Selected button does not perform any action. The Selected button is intentionally not disabled for accessibility reasons but instead has `aria-disabled` set.
|
|
@@ -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 variant="bottom" 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
|
+
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { TdProps, ThProps, TrProps, InnerScrollContainer } from '@patternfly/react-table';
|
|
3
3
|
import { DataViewTableTree, DataViewTableTreeProps } from '../DataViewTableTree';
|
|
4
|
-
import { DataViewTableBasic, DataViewTableBasicProps } from '../DataViewTableBasic';
|
|
4
|
+
import { DataViewTableBasic, DataViewTableBasicProps, ExpandableContent } from '../DataViewTableBasic';
|
|
5
5
|
import { DataViewThResizableProps } from '../DataViewTh/DataViewTh';
|
|
6
6
|
|
|
7
|
+
export type { ExpandableContent };
|
|
8
|
+
|
|
7
9
|
// Table head typings
|
|
8
10
|
export type DataViewTh =
|
|
9
11
|
| ReactNode
|