@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,166 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
12
|
+
import '@testing-library/jest-dom';
|
|
13
|
+
import userEvent from '@testing-library/user-event';
|
|
14
|
+
import DataViewTreeFilter from './DataViewTreeFilter';
|
|
15
|
+
import DataViewToolbar from '../DataViewToolbar';
|
|
16
|
+
describe('DataViewTreeFilter component', () => {
|
|
17
|
+
const treeItems = [
|
|
18
|
+
{
|
|
19
|
+
name: 'Linux',
|
|
20
|
+
id: 'os-linux',
|
|
21
|
+
checkProps: { 'aria-label': 'linux-check', checked: false },
|
|
22
|
+
children: [
|
|
23
|
+
{
|
|
24
|
+
name: 'Ubuntu 22.04',
|
|
25
|
+
id: 'os-ubuntu',
|
|
26
|
+
checkProps: { checked: false }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'RHEL 9',
|
|
30
|
+
id: 'os-rhel',
|
|
31
|
+
checkProps: { checked: false }
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'Debian 12',
|
|
35
|
+
id: 'os-debian',
|
|
36
|
+
checkProps: { checked: false }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'CentOS 8',
|
|
40
|
+
id: 'os-centos',
|
|
41
|
+
checkProps: { checked: false }
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Fedora 38',
|
|
45
|
+
id: 'os-fedora',
|
|
46
|
+
checkProps: { checked: false }
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
defaultExpanded: true
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Windows',
|
|
53
|
+
id: 'os-windows',
|
|
54
|
+
checkProps: { 'aria-label': 'windows-check', checked: false },
|
|
55
|
+
children: [
|
|
56
|
+
{
|
|
57
|
+
name: 'Windows Server 2022',
|
|
58
|
+
id: 'os-windows-2022',
|
|
59
|
+
checkProps: { checked: false }
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'macOS',
|
|
65
|
+
id: 'os-macos',
|
|
66
|
+
checkProps: { 'aria-label': 'macos-check', checked: false },
|
|
67
|
+
children: [
|
|
68
|
+
{
|
|
69
|
+
name: 'macOS Ventura',
|
|
70
|
+
id: 'os-macos-ventura',
|
|
71
|
+
checkProps: { checked: false }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'macOS Sonoma',
|
|
75
|
+
id: 'os-macos-sonoma',
|
|
76
|
+
checkProps: { checked: false }
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
const defaultProps = {
|
|
82
|
+
filterId: 'test-tree-filter',
|
|
83
|
+
title: 'Test Tree Filter',
|
|
84
|
+
value: ['Linux'],
|
|
85
|
+
items: treeItems
|
|
86
|
+
};
|
|
87
|
+
beforeEach(() => {
|
|
88
|
+
jest.clearAllMocks();
|
|
89
|
+
});
|
|
90
|
+
it('should render correctly', () => {
|
|
91
|
+
const { container } = render(_jsx(DataViewToolbar, { filters: _jsx(DataViewTreeFilter, Object.assign({}, defaultProps)) }));
|
|
92
|
+
expect(container).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
describe('defaultExpanded', () => {
|
|
95
|
+
it('should have expanded items by default', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
render(_jsx(DataViewToolbar, { filters: _jsx(DataViewTreeFilter, { filterId: "os", title: "Operating System", items: treeItems, defaultExpanded: true }) }));
|
|
97
|
+
const openMenu = screen.getByRole('button', { name: /operating system/i });
|
|
98
|
+
yield userEvent.click(openMenu);
|
|
99
|
+
yield waitFor(() => {
|
|
100
|
+
const node = screen.getByText('Ubuntu 22.04');
|
|
101
|
+
expect(node).toHaveClass('pf-v6-c-tree-view__node-text');
|
|
102
|
+
expect(node).toBeInTheDocument();
|
|
103
|
+
});
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
describe('onChange callback', () => {
|
|
107
|
+
it('onChange should be called on toggle of node', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
const mockOnChange = jest.fn();
|
|
109
|
+
render(_jsx(DataViewToolbar, { filters: _jsx(DataViewTreeFilter, { filterId: "os", title: "Operating System", items: treeItems, defaultExpanded: true, onChange: mockOnChange }) }));
|
|
110
|
+
const openMenu = screen.getByRole('button', { name: /operating system/i });
|
|
111
|
+
yield userEvent.click(openMenu);
|
|
112
|
+
yield waitFor(() => {
|
|
113
|
+
const node = screen.getByText('Ubuntu 22.04');
|
|
114
|
+
expect(node).toBeInTheDocument();
|
|
115
|
+
});
|
|
116
|
+
const node = screen.getByText('Ubuntu 22.04');
|
|
117
|
+
yield userEvent.click(node);
|
|
118
|
+
yield waitFor(() => {
|
|
119
|
+
expect(mockOnChange).toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
}));
|
|
122
|
+
});
|
|
123
|
+
describe('onSelect callback', () => {
|
|
124
|
+
it('onSelect should return list of selected items when item is selected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
const mockOnSelect = jest.fn();
|
|
126
|
+
render(_jsx(DataViewToolbar, { filters: _jsx(DataViewTreeFilter, { filterId: "os", title: "Operating System", items: treeItems, defaultExpanded: true, onSelect: mockOnSelect }) }));
|
|
127
|
+
const openMenu = screen.getByRole('button', { name: /operating system/i });
|
|
128
|
+
yield userEvent.click(openMenu);
|
|
129
|
+
yield waitFor(() => {
|
|
130
|
+
const node = screen.getByText('Ubuntu 22.04');
|
|
131
|
+
expect(node).toBeInTheDocument();
|
|
132
|
+
});
|
|
133
|
+
const node = screen.getByText('Ubuntu 22.04');
|
|
134
|
+
yield userEvent.click(node);
|
|
135
|
+
yield waitFor(() => {
|
|
136
|
+
expect(mockOnSelect).toHaveBeenCalled();
|
|
137
|
+
expect(mockOnSelect).toHaveBeenCalledWith(expect.arrayContaining([
|
|
138
|
+
expect.objectContaining({
|
|
139
|
+
name: 'Ubuntu 22.04',
|
|
140
|
+
id: 'os-ubuntu'
|
|
141
|
+
})
|
|
142
|
+
]));
|
|
143
|
+
});
|
|
144
|
+
}));
|
|
145
|
+
});
|
|
146
|
+
describe('rendering all items', () => {
|
|
147
|
+
it('all tree items should be rendered', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
|
+
render(_jsx(DataViewToolbar, { filters: _jsx(DataViewTreeFilter, { filterId: "os", title: "Operating System", items: treeItems, defaultExpanded: true }) }));
|
|
149
|
+
const openMenu = screen.getByRole('button', { name: /operating system/i });
|
|
150
|
+
yield userEvent.click(openMenu);
|
|
151
|
+
yield waitFor(() => {
|
|
152
|
+
expect(screen.getByText('Linux')).toBeInTheDocument();
|
|
153
|
+
expect(screen.getByText('Windows')).toBeInTheDocument();
|
|
154
|
+
expect(screen.getByText('macOS')).toBeInTheDocument();
|
|
155
|
+
expect(screen.getByText('Ubuntu 22.04')).toBeInTheDocument();
|
|
156
|
+
expect(screen.getByText('RHEL 9')).toBeInTheDocument();
|
|
157
|
+
expect(screen.getByText('Debian 12')).toBeInTheDocument();
|
|
158
|
+
expect(screen.getByText('CentOS 8')).toBeInTheDocument();
|
|
159
|
+
expect(screen.getByText('Fedora 38')).toBeInTheDocument();
|
|
160
|
+
expect(screen.getByText('Windows Server 2022')).toBeInTheDocument();
|
|
161
|
+
expect(screen.getByText('macOS Ventura')).toBeInTheDocument();
|
|
162
|
+
expect(screen.getByText('macOS Sonoma')).toBeInTheDocument();
|
|
163
|
+
});
|
|
164
|
+
}));
|
|
165
|
+
});
|
|
166
|
+
});
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export interface UseDataViewSelectionProps {
|
|
1
|
+
export interface UseDataViewSelectionProps<T = any> {
|
|
2
2
|
/** Function to compare items when checking if item is selected */
|
|
3
|
-
matchOption: (item:
|
|
3
|
+
matchOption: (item: T, another: T) => boolean;
|
|
4
4
|
/** Array of initially selected entries */
|
|
5
|
-
initialSelected?: (
|
|
5
|
+
initialSelected?: (T)[];
|
|
6
6
|
}
|
|
7
|
-
export declare const useDataViewSelection: (props?: UseDataViewSelectionProps) => {
|
|
8
|
-
selected:
|
|
9
|
-
onSelect: (isSelecting: boolean, items?:
|
|
10
|
-
isSelected: (item:
|
|
11
|
-
setSelected: (items:
|
|
7
|
+
export declare const useDataViewSelection: <T = any>(props?: UseDataViewSelectionProps<T>) => {
|
|
8
|
+
selected: T[];
|
|
9
|
+
onSelect: (isSelecting: boolean, items?: T[] | T) => void;
|
|
10
|
+
isSelected: (item: T) => boolean;
|
|
11
|
+
setSelected: (items: T[]) => void;
|
|
12
12
|
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export { default as InternalContext } from './InternalContext';
|
|
2
2
|
export * from './InternalContext';
|
|
3
3
|
export * from './Hooks';
|
|
4
|
+
export { default as DataViewTreeFilter } from './DataViewTreeFilter';
|
|
5
|
+
export * from './DataViewTreeFilter';
|
|
4
6
|
export { default as DataViewToolbar } from './DataViewToolbar';
|
|
5
7
|
export * from './DataViewToolbar';
|
|
8
|
+
export { default as DataViewTh } from './DataViewTh';
|
|
9
|
+
export * from './DataViewTh';
|
|
6
10
|
export { default as DataViewTextFilter } from './DataViewTextFilter';
|
|
7
11
|
export * from './DataViewTextFilter';
|
|
8
12
|
export { default as DataViewTableTree } from './DataViewTableTree';
|
|
@@ -13,6 +17,8 @@ export { default as DataViewTableBasic } from './DataViewTableBasic';
|
|
|
13
17
|
export * from './DataViewTableBasic';
|
|
14
18
|
export { default as DataViewTable } from './DataViewTable';
|
|
15
19
|
export * from './DataViewTable';
|
|
20
|
+
export { default as DataViewFilters } from './DataViewFilters';
|
|
21
|
+
export * from './DataViewFilters';
|
|
16
22
|
export { default as DataViewEventsContext } from './DataViewEventsContext';
|
|
17
23
|
export * from './DataViewEventsContext';
|
|
18
24
|
export { default as DataViewCheckboxFilter } from './DataViewCheckboxFilter';
|
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
export { default as InternalContext } from './InternalContext';
|
|
3
3
|
export * from './InternalContext';
|
|
4
4
|
export * from './Hooks';
|
|
5
|
+
export { default as DataViewTreeFilter } from './DataViewTreeFilter';
|
|
6
|
+
export * from './DataViewTreeFilter';
|
|
5
7
|
export { default as DataViewToolbar } from './DataViewToolbar';
|
|
6
8
|
export * from './DataViewToolbar';
|
|
9
|
+
export { default as DataViewTh } from './DataViewTh';
|
|
10
|
+
export * from './DataViewTh';
|
|
7
11
|
export { default as DataViewTextFilter } from './DataViewTextFilter';
|
|
8
12
|
export * from './DataViewTextFilter';
|
|
9
13
|
export { default as DataViewTableTree } from './DataViewTableTree';
|
|
@@ -14,6 +18,8 @@ export { default as DataViewTableBasic } from './DataViewTableBasic';
|
|
|
14
18
|
export * from './DataViewTableBasic';
|
|
15
19
|
export { default as DataViewTable } from './DataViewTable';
|
|
16
20
|
export * from './DataViewTable';
|
|
21
|
+
export { default as DataViewFilters } from './DataViewFilters';
|
|
22
|
+
export * from './DataViewFilters';
|
|
17
23
|
export { default as DataViewEventsContext } from './DataViewEventsContext';
|
|
18
24
|
export * from './DataViewEventsContext';
|
|
19
25
|
export { default as DataViewCheckboxFilter } from './DataViewCheckboxFilter';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/DataView/DataView.test.tsx","../src/DataView/DataView.tsx","../src/DataView/index.ts","../src/DataViewCheckboxFilter/DataViewCheckboxFilter.test.tsx","../src/DataViewCheckboxFilter/DataViewCheckboxFilter.tsx","../src/DataViewCheckboxFilter/index.ts","../src/DataViewEventsContext/DataViewEventsContext.test.tsx","../src/DataViewEventsContext/DataViewEventsContext.tsx","../src/DataViewEventsContext/index.ts","../src/DataViewFilters/DataViewFilters.test.tsx","../src/DataViewFilters/DataViewFilters.tsx","../src/DataViewFilters/index.tsx","../src/DataViewTable/DataViewTable.test.tsx","../src/DataViewTable/DataViewTable.tsx","../src/DataViewTable/index.ts","../src/DataViewTableBasic/DataViewTableBasic.test.tsx","../src/DataViewTableBasic/DataViewTableBasic.tsx","../src/DataViewTableBasic/index.ts","../src/DataViewTableHead/DataViewTableHead.test.tsx","../src/DataViewTableHead/DataViewTableHead.tsx","../src/DataViewTableHead/index.ts","../src/DataViewTableTree/DataViewTableTree.test.tsx","../src/DataViewTableTree/DataViewTableTree.tsx","../src/DataViewTableTree/index.ts","../src/DataViewTextFilter/DataViewTextFilter.test.tsx","../src/DataViewTextFilter/DataViewTextFilter.tsx","../src/DataViewTextFilter/index.ts","../src/DataViewTh/DataViewTh.tsx","../src/DataViewToolbar/DataViewToolbar.test.tsx","../src/DataViewToolbar/DataViewToolbar.tsx","../src/DataViewToolbar/index.ts","../src/Hooks/filters.test.tsx","../src/Hooks/filters.ts","../src/Hooks/index.ts","../src/Hooks/pagination.test.tsx","../src/Hooks/pagination.ts","../src/Hooks/selection.test.tsx","../src/Hooks/selection.ts","../src/Hooks/sort.test.tsx","../src/Hooks/sort.ts","../src/InternalContext/InternalContext.test.tsx","../src/InternalContext/InternalContext.tsx","../src/InternalContext/index.ts"],"version":"5.9.3"}
|
|
1
|
+
{"root":["../src/index.ts","../src/DataView/DataView.test.tsx","../src/DataView/DataView.tsx","../src/DataView/index.ts","../src/DataViewCheckboxFilter/DataViewCheckboxFilter.test.tsx","../src/DataViewCheckboxFilter/DataViewCheckboxFilter.tsx","../src/DataViewCheckboxFilter/index.ts","../src/DataViewEventsContext/DataViewEventsContext.test.tsx","../src/DataViewEventsContext/DataViewEventsContext.tsx","../src/DataViewEventsContext/index.ts","../src/DataViewFilters/DataViewFilters.test.tsx","../src/DataViewFilters/DataViewFilters.tsx","../src/DataViewFilters/index.tsx","../src/DataViewTable/DataViewTable.test.tsx","../src/DataViewTable/DataViewTable.tsx","../src/DataViewTable/index.ts","../src/DataViewTableBasic/DataViewTableBasic.test.tsx","../src/DataViewTableBasic/DataViewTableBasic.tsx","../src/DataViewTableBasic/index.ts","../src/DataViewTableHead/DataViewTableHead.test.tsx","../src/DataViewTableHead/DataViewTableHead.tsx","../src/DataViewTableHead/index.ts","../src/DataViewTableTree/DataViewTableTree.test.tsx","../src/DataViewTableTree/DataViewTableTree.tsx","../src/DataViewTableTree/index.ts","../src/DataViewTextFilter/DataViewTextFilter.test.tsx","../src/DataViewTextFilter/DataViewTextFilter.tsx","../src/DataViewTextFilter/index.ts","../src/DataViewTh/DataViewTh.tsx","../src/DataViewTh/index.ts","../src/DataViewToolbar/DataViewToolbar.test.tsx","../src/DataViewToolbar/DataViewToolbar.tsx","../src/DataViewToolbar/index.ts","../src/DataViewTreeFilter/DataViewTreeFilter.test.tsx","../src/DataViewTreeFilter/DataViewTreeFilter.tsx","../src/DataViewTreeFilter/index.ts","../src/Hooks/filters.test.tsx","../src/Hooks/filters.ts","../src/Hooks/index.ts","../src/Hooks/pagination.test.tsx","../src/Hooks/pagination.ts","../src/Hooks/selection.test.tsx","../src/Hooks/selection.ts","../src/Hooks/sort.test.tsx","../src/Hooks/sort.ts","../src/InternalContext/InternalContext.test.tsx","../src/InternalContext/InternalContext.tsx","../src/InternalContext/index.ts"],"version":"5.9.3"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const fse = require('fs-extra');
|
|
2
2
|
const { globSync } = require('glob');
|
|
3
3
|
const path = require('path');
|
|
4
|
+
const { default: getDynamicModuleMap } = require('../../scripts/parse-dynamic-modules.mjs');
|
|
4
5
|
|
|
5
6
|
const root = process.cwd();
|
|
6
7
|
|
|
@@ -60,12 +61,29 @@ async function generatePackages(files) {
|
|
|
60
61
|
return Promise.all(cmds);
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
async function generateDynamicModuleMap() {
|
|
65
|
+
const moduleMap = getDynamicModuleMap(root);
|
|
66
|
+
// eslint-disable-next-line no-console
|
|
67
|
+
console.log('Generating dynamic module map for', Object.keys(moduleMap).length, 'modules');
|
|
68
|
+
|
|
69
|
+
if (Object.keys(moduleMap).length === 0) {
|
|
70
|
+
return Promise.resolve();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const moduleMapSorted = Object.keys(moduleMap)
|
|
74
|
+
.sort()
|
|
75
|
+
.reduce((acc, key) => ({ ...acc, [key]: moduleMap[key] }), {});
|
|
76
|
+
|
|
77
|
+
return fse.writeJSON(path.resolve(root, 'dist/dynamic-modules.json'), moduleMapSorted, { spaces: 2 });
|
|
78
|
+
}
|
|
79
|
+
|
|
63
80
|
async function run(files) {
|
|
64
81
|
try {
|
|
65
82
|
await generatePackages(files);
|
|
66
83
|
if (indexTypings.length === 1) {
|
|
67
84
|
copyTypings(indexTypings, root);
|
|
68
85
|
}
|
|
86
|
+
await generateDynamicModuleMap();
|
|
69
87
|
} catch (error) {
|
|
70
88
|
// eslint-disable-next-line no-console
|
|
71
89
|
console.error(error);
|
package/generate-index.js
CHANGED
|
@@ -6,7 +6,7 @@ const root = process.cwd();
|
|
|
6
6
|
|
|
7
7
|
const ENV_AGNOSTIC_ROOT = `${root}/src`
|
|
8
8
|
|
|
9
|
-
const sourceFiles = globSync(path.resolve(__dirname, './src/*/index.ts'))
|
|
9
|
+
const sourceFiles = globSync(path.resolve(__dirname, './src/*/index.{ts,tsx}'))
|
|
10
10
|
|
|
11
11
|
async function generateIndex(files) {
|
|
12
12
|
// ensure the dynamic root exists
|
|
@@ -19,7 +19,7 @@ async function generateIndex(files) {
|
|
|
19
19
|
stream.write('// this file is autogenerated by generate-index.js, modifying it manually will have no effect\n');
|
|
20
20
|
|
|
21
21
|
files.forEach(file => {
|
|
22
|
-
const name = file.replace(
|
|
22
|
+
const name = file.replace(/\/index\.(ts|tsx)$/, '').split('/').pop();
|
|
23
23
|
// do not generate default exports for Hooks/
|
|
24
24
|
name !== 'Hooks' && stream.write(`\nexport { default as ${name} } from './${name}';\n`);
|
|
25
25
|
stream.write(`export * from './${name}';\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-data-view",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0-prerelease.1",
|
|
4
4
|
"description": "Data view used for Red Hat projects.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"@patternfly/patternfly": "^6.4.0",
|
|
48
48
|
"@patternfly/react-code-editor": "^6.4.0",
|
|
49
49
|
"@patternfly/patternfly-a11y": "^5.1.0",
|
|
50
|
-
"@types/react": "^18.3.
|
|
50
|
+
"@types/react": "^18.3.27",
|
|
51
51
|
"@types/react-dom": "^18.3.7",
|
|
52
52
|
"@types/react-router-dom": "^5.3.3",
|
|
53
53
|
"react": "^18.3.1",
|
|
54
54
|
"react-dom": "^18.3.1",
|
|
55
|
-
"react-router": "^6.30.
|
|
56
|
-
"react-router-dom": "^6.30.
|
|
57
|
-
"rimraf": "^6.
|
|
58
|
-
"typescript": "^5.9.
|
|
55
|
+
"react-router": "^6.30.2",
|
|
56
|
+
"react-router-dom": "^6.30.2",
|
|
57
|
+
"rimraf": "^6.1.2",
|
|
58
|
+
"typescript": "^5.9.3"
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -22,15 +22,17 @@ import { DataViewCheckboxFilter } from '@patternfly/react-data-view/dist/dynamic
|
|
|
22
22
|
|
|
23
23
|
**Note:** Data view lives in its own package [`@patternfly/react-data-view`](https://www.npmjs.com/package/@patternfly/react-data-view)
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The **data view** extension enables you to display datasets in organized layouts, with data representations and interactive toolbars for actions like selection and pagination.
|
|
26
26
|
|
|
27
|
-
---
|
|
27
|
+
---
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
## How to structure and implement the data view
|
|
30
|
+
|
|
31
|
+
The **data view** extension provides a modular architecture that lets you efficiently create consistent data views, either by using predefined sub-components and hooks or by defining your own custom implementations.
|
|
30
32
|
|
|
31
33
|
### Layout
|
|
32
34
|
|
|
33
|
-
A data view should contain a header, the data representation, and a footer. These parts are organized in a [stack layout](/layouts/stack).
|
|
35
|
+
A data view should contain a header, the data representation, and a footer. These parts are organized in a [stack layout](/foundations-and-styles/layouts/stack).
|
|
34
36
|
|
|
35
37
|
The data view toolbars and sub-components that display the data (like a card view or table) are always passed as `children` to the `<DataView>` component.
|
|
36
38
|
|
|
@@ -61,3 +63,7 @@ This example uses the `<DataViewEventsProvider>` to display details about a sele
|
|
|
61
63
|
```js file="./EventsExample.tsx"
|
|
62
64
|
|
|
63
65
|
```
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
If you notice a bug, or if you have a suggestion for improving the data view extension or its documentation, please file an issue in the [react-data-view](https://github.com/patternfly/react-data-view/issues) repository. Before doing so, please make sure there is not already a pre-existing issue.
|
|
@@ -244,7 +244,8 @@ const RepositoriesTable: FunctionComponent<RepositoriesTableProps> = ({ selected
|
|
|
244
244
|
ouiaId='LayoutExampleFooter'
|
|
245
245
|
pagination={
|
|
246
246
|
<Pagination
|
|
247
|
-
isCompact
|
|
247
|
+
isCompact
|
|
248
|
+
variant="bottom"
|
|
248
249
|
perPageOptions={perPageOptions}
|
|
249
250
|
itemCount={repositories.length}
|
|
250
251
|
{...pagination}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
|
+
import { DataViewTable, DataViewTr, DataViewTh, ExpandableContent } 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
|
+
}
|
|
15
|
+
|
|
16
|
+
const expandableContents: ExpandableContent[] = [
|
|
17
|
+
// Row 1 - Repository one
|
|
18
|
+
{ rowId: 1, columnId: 3, content: <div><strong>PR Details:</strong> 3 open PRs, 45 merged this month, avg review time: 2 days</div> },
|
|
19
|
+
{ rowId: 1, columnId: 5, content: <div><strong>Commit Info:</strong> Author: John Doe, Message: "Fix critical authentication bug", SHA: a1b2c3d</div> },
|
|
20
|
+
|
|
21
|
+
// Row 2 - Repository two
|
|
22
|
+
{ rowId: 2, columnId: 2, content: <div><strong>Branch Details:</strong> 8 active branches, main, staging, feature/api-v2, feature/dashboard</div> },
|
|
23
|
+
{ rowId: 2, columnId: 3, content: <div><strong>PR Details:</strong> 5 open PRs, 120 merged this month, avg review time: 1.5 days</div> },
|
|
24
|
+
{ rowId: 2, columnId: 4, content: <div><strong>Workspace Info:</strong> Development env, 3 active deployments, last updated 30 mins ago</div> },
|
|
25
|
+
{ rowId: 2, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Jane Smith, Message: "Add new API endpoints", SHA: x9y8z7w</div> },
|
|
26
|
+
|
|
27
|
+
// Row 3 - Repository three
|
|
28
|
+
{ rowId: 3, columnId: 2, content: <div><strong>Branch Details:</strong> 12 active branches including main, develop, multiple feature branches</div> },
|
|
29
|
+
{ rowId: 3, columnId: 3, content: <div><strong>PR Details:</strong> 8 open PRs, 200 merged this month, avg review time: 3 days</div> },
|
|
30
|
+
{ rowId: 3, columnId: 4, content: <div><strong>Workspace Info:</strong> Staging env, 10 active deployments, last updated 1 day ago</div> },
|
|
31
|
+
{ rowId: 3, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Bob Johnson, Message: "Refactor core modules", SHA: p0o9i8u</div> },
|
|
32
|
+
|
|
33
|
+
// Row 4 - Repository four
|
|
34
|
+
{ rowId: 4, columnId: 2, content: <div><strong>Branch Details:</strong> 6 active branches, focusing on microservices architecture</div> },
|
|
35
|
+
{ rowId: 4, columnId: 3, content: <div><strong>PR Details:</strong> 2 open PRs, 90 merged this month, avg review time: 2.5 days</div> },
|
|
36
|
+
{ rowId: 4, columnId: 4, content: <div><strong>Workspace Info:</strong> QA env, 7 active deployments, automated testing enabled</div> },
|
|
37
|
+
{ rowId: 4, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Alice Williams, Message: "Update dependencies", SHA: m5n4b3v</div> },
|
|
38
|
+
|
|
39
|
+
// Row 5 - Repository five
|
|
40
|
+
{ rowId: 5, columnId: 2, content: <div><strong>Branch Details:</strong> 4 active branches, clean branch strategy</div> },
|
|
41
|
+
{ rowId: 5, columnId: 3, content: <div><strong>PR Details:</strong> 6 open PRs, 75 merged this month, avg review time: 1 day</div> },
|
|
42
|
+
{ rowId: 5, columnId: 4, content: <div><strong>Workspace Info:</strong> Pre-production env, CI/CD pipeline configured</div> },
|
|
43
|
+
{ rowId: 5, columnId: 5, content: <div><strong>Commit Info:</strong> Author: Charlie Brown, Message: "Implement dark mode", SHA: q2w3e4r</div> },
|
|
44
|
+
|
|
45
|
+
// Row 6 - Repository six
|
|
46
|
+
{ rowId: 6, columnId: 2, content: <div><strong>Branch Details:</strong> 15 active branches, complex branching model</div> },
|
|
47
|
+
{ rowId: 6, columnId: 3, content: <div><strong>PR Details:</strong> 10 open PRs, 250 merged this month, avg review time: 4 days</div> },
|
|
48
|
+
{ rowId: 6, columnId: 4, content: <div><strong>Workspace Info:</strong> Multi-region deployment, high availability setup</div> },
|
|
49
|
+
{ rowId: 6, columnId: 5, content: <div><strong>Commit Info:</strong> Author: David Lee, Message: "Security patches applied", SHA: t6y7u8i</div> },
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const repositories: Repository[] = [
|
|
53
|
+
{ id: 1, name: 'Repository one', branches: 'Branch one', prs: 'Pull request one', workspaces: 'Workspace one', lastCommit: 'Timestamp one' },
|
|
54
|
+
{ id: 2, name: 'Repository two', branches: 'Branch two', prs: 'Pull request two', workspaces: 'Workspace two', lastCommit: 'Timestamp two' },
|
|
55
|
+
{ id: 3, name: 'Repository three', branches: 'Branch three', prs: 'Pull request three', workspaces: 'Workspace three', lastCommit: 'Timestamp three' },
|
|
56
|
+
{ id: 4, name: 'Repository four', branches: 'Branch four', prs: 'Pull request four', workspaces: 'Workspace four', lastCommit: 'Timestamp four' },
|
|
57
|
+
{ id: 5, name: 'Repository five', branches: 'Branch five', prs: 'Pull request five', workspaces: 'Workspace five', lastCommit: 'Timestamp five' },
|
|
58
|
+
{ id: 6, name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six' }
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const rowActions = [
|
|
62
|
+
{
|
|
63
|
+
title: 'Some action',
|
|
64
|
+
onClick: () => console.log('clicked on Some action') // eslint-disable-line no-console
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
title: <div>Another action</div>,
|
|
68
|
+
onClick: () => console.log('clicked on Another action') // eslint-disable-line no-console
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
isSeparator: true
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: 'Third action',
|
|
75
|
+
onClick: () => console.log('clicked on Third action') // eslint-disable-line no-console
|
|
76
|
+
}
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspaces, lastCommit }) => [
|
|
80
|
+
{
|
|
81
|
+
id,
|
|
82
|
+
cell: workspaces,
|
|
83
|
+
props: {
|
|
84
|
+
favorites: { isFavorited: true }
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
{ cell: <Button href='#' variant='link' isInline>{name}</Button> },
|
|
88
|
+
branches,
|
|
89
|
+
prs,
|
|
90
|
+
workspaces,
|
|
91
|
+
lastCommit,
|
|
92
|
+
{ cell: <ActionsColumn items={rowActions}/>, props: { isActionCell: true } },
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
const columns: DataViewTh[] = [
|
|
96
|
+
null,
|
|
97
|
+
'Repositories',
|
|
98
|
+
{ cell: <>Branches<ExclamationCircleIcon className='pf-v6-u-ml-sm' color="var(--pf-t--global--color--status--danger--default)"/></> },
|
|
99
|
+
'Pull requests',
|
|
100
|
+
{ cell: 'Workspaces', props: { info: { tooltip: 'More information' }, isStickyColumn: true } },
|
|
101
|
+
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 } } },
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
const ouiaId = 'TableExample';
|
|
105
|
+
|
|
106
|
+
export const ExpandableExample: FunctionComponent = () => (
|
|
107
|
+
<DataViewTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} rows={rows} expandedRows={expandableContents} isExpandable={true}/>
|
|
108
|
+
);
|