@patternfly/react-data-view 7.0.0-prerelease.1 → 7.0.0-prerelease.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DataView/DataView.d.ts +12 -0
- package/dist/cjs/DataView/DataView.js +14 -3
- package/dist/cjs/DataView/DataView.test.js +3 -4
- package/dist/cjs/DataViewEventsContext/DataViewEventsContext.d.ts +16 -0
- package/dist/cjs/DataViewEventsContext/DataViewEventsContext.js +62 -0
- package/dist/cjs/DataViewEventsContext/DataViewEventsContext.test.d.ts +1 -0
- package/dist/cjs/DataViewEventsContext/DataViewEventsContext.test.js +72 -0
- package/dist/cjs/DataViewEventsContext/index.d.ts +2 -0
- package/dist/cjs/DataViewEventsContext/index.js +23 -0
- package/dist/cjs/DataViewTable/DataViewTable.d.ts +41 -0
- package/dist/cjs/DataViewTable/DataViewTable.js +18 -0
- package/dist/cjs/DataViewTable/DataViewTable.test.d.ts +1 -0
- package/dist/cjs/DataViewTable/DataViewTable.test.js +57 -0
- package/dist/cjs/DataViewTable/index.d.ts +2 -0
- package/dist/cjs/DataViewTable/index.js +23 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +18 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +71 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.d.ts +1 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +43 -0
- package/dist/cjs/DataViewTableBasic/index.d.ts +2 -0
- package/dist/cjs/DataViewTableBasic/index.js +23 -0
- package/dist/cjs/DataViewTableHead/DataViewTableHead.d.ts +13 -0
- package/dist/cjs/DataViewTableHead/DataViewTableHead.js +57 -0
- package/dist/cjs/DataViewTableHead/DataViewTableHead.test.d.ts +1 -0
- package/dist/cjs/DataViewTableHead/DataViewTableHead.test.js +36 -0
- package/dist/cjs/DataViewTableHead/index.d.ts +2 -0
- package/dist/cjs/DataViewTableHead/index.js +23 -0
- package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +24 -0
- package/dist/cjs/DataViewTableTree/DataViewTableTree.js +132 -0
- package/dist/cjs/DataViewTableTree/DataViewTableTree.test.d.ts +1 -0
- package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +90 -0
- package/dist/cjs/DataViewTableTree/index.d.ts +2 -0
- package/dist/cjs/DataViewTableTree/index.js +23 -0
- package/dist/cjs/DataViewToolbar/DataViewToolbar.d.ts +2 -0
- package/dist/cjs/DataViewToolbar/DataViewToolbar.js +2 -1
- package/dist/cjs/Hooks/pagination.d.ts +9 -5
- package/dist/cjs/Hooks/pagination.js +8 -8
- package/dist/cjs/Hooks/pagination.test.js +0 -52
- package/dist/cjs/Hooks/selection.d.ts +3 -3
- package/dist/cjs/Hooks/selection.js +4 -6
- package/dist/cjs/Hooks/selection.test.js +4 -4
- package/dist/cjs/InternalContext/InternalContext.d.ts +25 -0
- package/dist/cjs/InternalContext/InternalContext.js +40 -0
- package/dist/cjs/InternalContext/InternalContext.test.d.ts +1 -0
- package/dist/cjs/InternalContext/InternalContext.test.js +56 -0
- package/dist/cjs/InternalContext/index.d.ts +2 -0
- package/dist/cjs/InternalContext/index.js +23 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.js +20 -2
- package/dist/dynamic/DataViewEventsContext/package.json +1 -0
- package/dist/dynamic/DataViewTable/package.json +1 -0
- package/dist/dynamic/DataViewTableBasic/package.json +1 -0
- package/dist/dynamic/DataViewTableHead/package.json +1 -0
- package/dist/dynamic/DataViewTableTree/package.json +1 -0
- package/dist/dynamic/InternalContext/package.json +1 -0
- package/dist/esm/DataView/DataView.d.ts +12 -0
- package/dist/esm/DataView/DataView.js +13 -2
- package/dist/esm/DataView/DataView.test.js +3 -4
- package/dist/esm/DataViewEventsContext/DataViewEventsContext.d.ts +16 -0
- package/dist/esm/DataViewEventsContext/DataViewEventsContext.js +34 -0
- package/dist/esm/DataViewEventsContext/DataViewEventsContext.test.d.ts +1 -0
- package/dist/esm/DataViewEventsContext/DataViewEventsContext.test.js +67 -0
- package/dist/esm/DataViewEventsContext/index.d.ts +2 -0
- package/dist/esm/DataViewEventsContext/index.js +2 -0
- package/dist/esm/DataViewTable/DataViewTable.d.ts +41 -0
- package/dist/esm/DataViewTable/DataViewTable.js +8 -0
- package/dist/esm/DataViewTable/DataViewTable.test.d.ts +1 -0
- package/dist/esm/DataViewTable/DataViewTable.test.js +52 -0
- package/dist/esm/DataViewTable/index.d.ts +2 -0
- package/dist/esm/DataViewTable/index.js +2 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +18 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +44 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.d.ts +1 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +38 -0
- package/dist/esm/DataViewTableBasic/index.d.ts +2 -0
- package/dist/esm/DataViewTableBasic/index.js +2 -0
- package/dist/esm/DataViewTableHead/DataViewTableHead.d.ts +13 -0
- package/dist/esm/DataViewTableHead/DataViewTableHead.js +30 -0
- package/dist/esm/DataViewTableHead/DataViewTableHead.test.d.ts +1 -0
- package/dist/esm/DataViewTableHead/DataViewTableHead.test.js +31 -0
- package/dist/esm/DataViewTableHead/index.d.ts +2 -0
- package/dist/esm/DataViewTableHead/index.js +2 -0
- package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +24 -0
- package/dist/esm/DataViewTableTree/DataViewTableTree.js +105 -0
- package/dist/esm/DataViewTableTree/DataViewTableTree.test.d.ts +1 -0
- package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +85 -0
- package/dist/esm/DataViewTableTree/index.d.ts +2 -0
- package/dist/esm/DataViewTableTree/index.js +2 -0
- package/dist/esm/DataViewToolbar/DataViewToolbar.d.ts +2 -0
- package/dist/esm/DataViewToolbar/DataViewToolbar.js +2 -1
- package/dist/esm/Hooks/pagination.d.ts +9 -5
- package/dist/esm/Hooks/pagination.js +9 -9
- package/dist/esm/Hooks/pagination.test.js +0 -52
- package/dist/esm/Hooks/selection.d.ts +3 -3
- package/dist/esm/Hooks/selection.js +4 -6
- package/dist/esm/Hooks/selection.test.js +4 -4
- package/dist/esm/InternalContext/InternalContext.d.ts +25 -0
- package/dist/esm/InternalContext/InternalContext.js +12 -0
- package/dist/esm/InternalContext/InternalContext.test.d.ts +1 -0
- package/dist/esm/InternalContext/InternalContext.test.js +51 -0
- package/dist/esm/InternalContext/index.d.ts +2 -0
- package/dist/esm/InternalContext/index.js +2 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +12 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +11 -10
- package/patternfly-docs/content/extensions/data-view/examples/Components/Components.md +80 -5
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableEmptyExample.tsx +57 -0
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableErrorExample.tsx +45 -0
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableExample.tsx +67 -0
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableLoadingExample.tsx +27 -0
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableTreeExample.tsx +71 -0
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewToolbarActionsExample.tsx +27 -0
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewToolbarExample.tsx +4 -4
- package/patternfly-docs/content/extensions/data-view/examples/EventsContext/EventsContext.md +32 -0
- package/patternfly-docs/content/extensions/data-view/examples/EventsContext/EventsExample.tsx +108 -0
- package/patternfly-docs/content/extensions/data-view/examples/Functionality/Functionality.md +12 -11
- package/patternfly-docs/content/extensions/data-view/examples/Functionality/PaginationExample.tsx +20 -37
- package/patternfly-docs/content/extensions/data-view/examples/Functionality/SelectionExample.tsx +15 -46
- package/patternfly-docs/content/extensions/data-view/examples/Layout/AbstractLayoutExample.tsx +3 -4
- package/patternfly-docs/content/extensions/data-view/examples/Layout/Layout.md +2 -1
- package/patternfly-docs/content/extensions/data-view/examples/Layout/PredefinedLayoutExample.tsx +20 -51
- package/patternfly-docs/pages/index.js +1 -1
- package/release.config.js +1 -5
- package/src/DataView/DataView.test.tsx +3 -4
- package/src/DataView/DataView.tsx +25 -3
- package/src/DataView/__snapshots__/DataView.test.tsx.snap +16 -16
- package/src/DataViewEventsContext/DataViewEventsContext.test.tsx +105 -0
- package/src/DataViewEventsContext/DataViewEventsContext.tsx +70 -0
- package/src/DataViewEventsContext/index.ts +2 -0
- package/src/DataViewTable/DataViewTable.test.tsx +80 -0
- package/src/DataViewTable/DataViewTable.tsx +37 -0
- package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +1042 -0
- package/src/DataViewTable/index.ts +2 -0
- package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +65 -0
- package/src/DataViewTableBasic/DataViewTableBasic.tsx +82 -0
- package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +555 -0
- package/src/DataViewTableBasic/index.ts +2 -0
- package/src/DataViewTableHead/DataViewTableHead.test.tsx +50 -0
- package/src/DataViewTableHead/DataViewTableHead.tsx +53 -0
- package/src/DataViewTableHead/__snapshots__/DataViewTableHead.test.tsx.snap +227 -0
- package/src/DataViewTableHead/index.ts +2 -0
- package/src/DataViewTableTree/DataViewTableTree.test.tsx +113 -0
- package/src/DataViewTableTree/DataViewTableTree.tsx +164 -0
- package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +1200 -0
- package/src/DataViewTableTree/index.ts +2 -0
- package/src/DataViewToolbar/DataViewToolbar.tsx +9 -2
- package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +208 -166
- package/src/Hooks/pagination.test.tsx +0 -80
- package/src/Hooks/pagination.ts +22 -16
- package/src/Hooks/selection.test.tsx +5 -5
- package/src/Hooks/selection.ts +6 -7
- package/src/InternalContext/InternalContext.test.tsx +89 -0
- package/src/InternalContext/InternalContext.tsx +51 -0
- package/src/InternalContext/index.ts +2 -0
- package/src/index.ts +18 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { useInternalContext } from './InternalContext';
|
|
5
|
+
import { DataView } from '../DataView';
|
|
6
|
+
describe('InternalContext', () => {
|
|
7
|
+
const mockSelection = {
|
|
8
|
+
onSelect: jest.fn(),
|
|
9
|
+
isSelected: jest.fn(),
|
|
10
|
+
isSelectDisabled: jest.fn(),
|
|
11
|
+
};
|
|
12
|
+
test('should provide context value and allow consuming it', () => {
|
|
13
|
+
const TestComponent = () => {
|
|
14
|
+
const { selection } = useInternalContext();
|
|
15
|
+
return (React.createElement("div", null,
|
|
16
|
+
React.createElement("button", { onClick: () => selection === null || selection === void 0 ? void 0 : selection.onSelect(true, ['item1']) }, "Select item"),
|
|
17
|
+
React.createElement("span", null, (selection === null || selection === void 0 ? void 0 : selection.isSelected('item1')) ? 'Selected' : 'Not selected')));
|
|
18
|
+
};
|
|
19
|
+
const { getByText } = render(React.createElement(DataView, { selection: mockSelection },
|
|
20
|
+
React.createElement(TestComponent, null)));
|
|
21
|
+
fireEvent.click(getByText('Select item'));
|
|
22
|
+
expect(mockSelection.onSelect).toHaveBeenCalledWith(true, ['item1']);
|
|
23
|
+
});
|
|
24
|
+
test('should handle selection state correctly', () => {
|
|
25
|
+
const mockSelectionState = Object.assign(Object.assign({}, mockSelection), { isSelected: jest.fn((item) => item === 'item1') });
|
|
26
|
+
const TestComponent = () => {
|
|
27
|
+
const { selection } = useInternalContext();
|
|
28
|
+
return (React.createElement("div", null,
|
|
29
|
+
React.createElement("span", null, (selection === null || selection === void 0 ? void 0 : selection.isSelected('item1')) ? 'Item 1 is selected' : 'Item 1 is not selected'),
|
|
30
|
+
React.createElement("span", null, (selection === null || selection === void 0 ? void 0 : selection.isSelected('item2')) ? 'Item 2 is selected' : 'Item 2 is not selected')));
|
|
31
|
+
};
|
|
32
|
+
const { getByText } = render(React.createElement(DataView, { selection: mockSelectionState },
|
|
33
|
+
React.createElement(TestComponent, null)));
|
|
34
|
+
expect(getByText('Item 1 is selected')).toBeInTheDocument();
|
|
35
|
+
expect(getByText('Item 2 is not selected')).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
test('should handle selection disabled correctly', () => {
|
|
38
|
+
const mockSelectionWithDisabled = Object.assign(Object.assign({}, mockSelection), { isSelectDisabled: jest.fn((item) => item === 'item3') });
|
|
39
|
+
const TestComponent = () => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const { selection } = useInternalContext();
|
|
42
|
+
return (React.createElement("div", null,
|
|
43
|
+
React.createElement("span", null, ((_a = selection === null || selection === void 0 ? void 0 : selection.isSelectDisabled) === null || _a === void 0 ? void 0 : _a.call(selection, 'item3')) ? 'Item 3 is disabled' : 'Item 3 is enabled'),
|
|
44
|
+
React.createElement("span", null, ((_b = selection === null || selection === void 0 ? void 0 : selection.isSelectDisabled) === null || _b === void 0 ? void 0 : _b.call(selection, 'item1')) ? 'Item 1 is disabled' : 'Item 1 is enabled')));
|
|
45
|
+
};
|
|
46
|
+
const { getByText } = render(React.createElement(DataView, { selection: mockSelectionWithDisabled },
|
|
47
|
+
React.createElement(TestComponent, null)));
|
|
48
|
+
expect(getByText('Item 3 is disabled')).toBeInTheDocument();
|
|
49
|
+
expect(getByText('Item 1 is enabled')).toBeInTheDocument();
|
|
50
|
+
});
|
|
51
|
+
});
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
export { default as InternalContext } from './InternalContext';
|
|
2
|
+
export * from './InternalContext';
|
|
1
3
|
export * from './Hooks';
|
|
2
4
|
export { default as DataViewToolbar } from './DataViewToolbar';
|
|
3
5
|
export * from './DataViewToolbar';
|
|
6
|
+
export { default as DataViewTableTree } from './DataViewTableTree';
|
|
7
|
+
export * from './DataViewTableTree';
|
|
8
|
+
export { default as DataViewTableHead } from './DataViewTableHead';
|
|
9
|
+
export * from './DataViewTableHead';
|
|
10
|
+
export { default as DataViewTableBasic } from './DataViewTableBasic';
|
|
11
|
+
export * from './DataViewTableBasic';
|
|
12
|
+
export { default as DataViewTable } from './DataViewTable';
|
|
13
|
+
export * from './DataViewTable';
|
|
14
|
+
export { default as DataViewEventsContext } from './DataViewEventsContext';
|
|
15
|
+
export * from './DataViewEventsContext';
|
|
4
16
|
export { default as DataView } from './DataView';
|
|
5
17
|
export * from './DataView';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
// this file is autogenerated by generate-index.js, modifying it manually will have no effect
|
|
2
|
+
export { default as InternalContext } from './InternalContext';
|
|
3
|
+
export * from './InternalContext';
|
|
2
4
|
export * from './Hooks';
|
|
3
5
|
export { default as DataViewToolbar } from './DataViewToolbar';
|
|
4
6
|
export * from './DataViewToolbar';
|
|
7
|
+
export { default as DataViewTableTree } from './DataViewTableTree';
|
|
8
|
+
export * from './DataViewTableTree';
|
|
9
|
+
export { default as DataViewTableHead } from './DataViewTableHead';
|
|
10
|
+
export * from './DataViewTableHead';
|
|
11
|
+
export { default as DataViewTableBasic } from './DataViewTableBasic';
|
|
12
|
+
export * from './DataViewTableBasic';
|
|
13
|
+
export { default as DataViewTable } from './DataViewTable';
|
|
14
|
+
export * from './DataViewTable';
|
|
15
|
+
export { default as DataViewEventsContext } from './DataViewEventsContext';
|
|
16
|
+
export * from './DataViewEventsContext';
|
|
5
17
|
export { default as DataView } from './DataView';
|
|
6
18
|
export * from './DataView';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/index.ts","../src/DataView/DataView.test.tsx","../src/DataView/DataView.tsx","../src/DataView/index.ts","../src/DataViewEventsContext/DataViewEventsContext.test.tsx","../src/DataViewEventsContext/DataViewEventsContext.tsx","../src/DataViewEventsContext/index.ts","../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/DataViewToolbar/DataViewToolbar.test.tsx","../src/DataViewToolbar/DataViewToolbar.tsx","../src/DataViewToolbar/index.ts","../src/Hooks/index.ts","../src/Hooks/pagination.test.tsx","../src/Hooks/pagination.ts","../src/Hooks/selection.test.tsx","../src/Hooks/selection.ts","../src/InternalContext/InternalContext.test.tsx","../src/InternalContext/InternalContext.tsx","../src/InternalContext/index.ts"],"version":"5.6.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-data-view",
|
|
3
|
-
"version": "7.0.0-prerelease.
|
|
3
|
+
"version": "7.0.0-prerelease.3",
|
|
4
4
|
"description": "Data view used for Red Hat projects.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -27,24 +27,25 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/patternfly/react-data-view#readme",
|
|
29
29
|
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
30
|
+
"access": "public",
|
|
31
|
+
"tag": "prerelease"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@patternfly/react-
|
|
34
|
-
"@patternfly/react-
|
|
35
|
-
"@patternfly/react-
|
|
36
|
-
"@patternfly/react-
|
|
37
|
-
"
|
|
38
|
-
"
|
|
34
|
+
"@patternfly/react-component-groups": "6.0.0-prerelease.7",
|
|
35
|
+
"@patternfly/react-core": "6.0.0-prerelease.23",
|
|
36
|
+
"@patternfly/react-icons": "6.0.0-prerelease.7",
|
|
37
|
+
"@patternfly/react-table": "6.0.0-prerelease.24",
|
|
38
|
+
"clsx": "^2.1.1",
|
|
39
|
+
"react-jss": "^10.10.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"react": "^17 || ^18",
|
|
42
43
|
"react-dom": "^17 || ^18"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
46
|
+
"@patternfly/documentation-framework": "6.0.0-alpha.117",
|
|
47
|
+
"@patternfly/patternfly": "6.0.0-prerelease.15",
|
|
45
48
|
"@patternfly/patternfly-a11y": "^4.3.1",
|
|
46
|
-
"@patternfly/documentation-framework": "5.16.9",
|
|
47
|
-
"@patternfly/patternfly": "^5.3.1",
|
|
48
49
|
"@types/react": "^18.3.1",
|
|
49
50
|
"@types/react-dom": "^18.3.0",
|
|
50
51
|
"@types/react-router-dom": "^5.3.3",
|
|
@@ -11,21 +11,96 @@ source: react
|
|
|
11
11
|
# If you use typescript, the name of the interface to display props for
|
|
12
12
|
# These are found through the sourceProps function provided in patternfly-docs.source.js
|
|
13
13
|
sortValue: 4
|
|
14
|
-
propComponents: ['DataViewToolbar']
|
|
14
|
+
propComponents: ['DataViewToolbar', 'DataViewTableBasic', 'DataViewTableTree']
|
|
15
15
|
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/Components/Components.md
|
|
16
16
|
---
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
17
|
+
import { Button, EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter } from '@patternfly/react-core';
|
|
18
|
+
import { CubesIcon, FolderIcon, FolderOpenIcon, LeafIcon, ExclamationCircleIcon } from '@patternfly/react-icons';
|
|
19
|
+
import { BulkSelect, ErrorState, ResponsiveAction, ResponsiveActions, SkeletonTableHead, SkeletonTableBody } from '@patternfly/react-component-groups';
|
|
20
|
+
import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
|
|
21
|
+
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
22
|
+
import { useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
|
|
23
|
+
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
19
24
|
|
|
20
25
|
## Data view toolbar
|
|
21
26
|
|
|
22
27
|
The **data view toolbar** component renders a default opinionated data view toolbar above or below the data section.
|
|
23
28
|
|
|
24
|
-
Data view toolbar can contain a `pagination`, `bulkSelect` or
|
|
29
|
+
Data view toolbar can contain a `pagination`, `bulkSelect`, `actions` or other children content passed. The preffered way of passing children toolbar items is using the [toolbar item](/components/toolbar#toolbar-items) component.
|
|
25
30
|
|
|
26
|
-
### Basic example
|
|
31
|
+
### Basic toolbar example
|
|
27
32
|
|
|
28
33
|
```js file="./DataViewToolbarExample.tsx"
|
|
29
34
|
|
|
30
35
|
```
|
|
31
36
|
|
|
37
|
+
# Toolbar actions
|
|
38
|
+
Data view toolbar can display actions using the `actions` property accepting a React node. You can make use of a predefined [responsive actions](/extensions/component-groups/responsive-actions) component from the [component groups](/extensions/component-groups/about-component-groups) extension.
|
|
39
|
+
|
|
40
|
+
### Actions configuration
|
|
41
|
+
|
|
42
|
+
### Actions example
|
|
43
|
+
|
|
44
|
+
```js file="./DataViewToolbarActionsExample.tsx"
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Data view table
|
|
49
|
+
|
|
50
|
+
The **data view table** component renders your columns and rows definition into a [table](/components/table) component.
|
|
51
|
+
|
|
52
|
+
### Rows and columns customization
|
|
53
|
+
|
|
54
|
+
This example shows possible formats of `rows` and `columns` passed to the `DataViewTable` which allow you various customizations of the table head and body.
|
|
55
|
+
|
|
56
|
+
```js file="./DataViewTableExample.tsx"
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The `DataViewTable` component accepts the following props:
|
|
61
|
+
|
|
62
|
+
- `columns` defining the column heads of the table. Each item in the array can be a `ReactNode` (for simple heads) or an object with the following properties:
|
|
63
|
+
- `cell` (`ReactNode`) content to display in the column head.
|
|
64
|
+
- optional `props` (`ThProps`) to pass to the `<Th>` component, such as `width`, `sort`, and other table head cell properties.
|
|
65
|
+
|
|
66
|
+
- `rows` defining the rows to be displayed in the table. Each item in the array can be either an array of `DataViewTd` (for simple rows) or an object with the following properties:
|
|
67
|
+
- `row` (`DataViewTd[]`) defining the content for each cell in the row.
|
|
68
|
+
- optional `id` (`string`) for the row (can be used to match items in selection).
|
|
69
|
+
- optional `props` (`TrProps`) to pass to the `<Tr>` component, such as `isHoverable`, `isRowSelected`, and other table row properties.
|
|
70
|
+
|
|
71
|
+
- optional `ouiaId`
|
|
72
|
+
|
|
73
|
+
- optional `props` (`TableProps`) that are passed down to the `<Table>` component, except for `onSelect`, which is managed internally.
|
|
74
|
+
|
|
75
|
+
### Tree table example
|
|
76
|
+
This example shows the tree table variant with expandable rows, custom icons for leaf and parent nodes. Tree table is turned on by passing `isTreeTable` flag to the `DataViewTable` component. You can pass `collapsedIcon`, `expandedIcon` or `leafIcon` to be displayen rows with given status. The tree table rows have to be defined in a format of object with following keys:
|
|
77
|
+
- `row` (`DataViewTd[]`) defining the content for each cell in the row.
|
|
78
|
+
- `id` (`string`) for the row (used to match items in selection end expand the rows).
|
|
79
|
+
- optional `children` (`DataViewTrTree[]`) defining the children rows.
|
|
80
|
+
|
|
81
|
+
It is also possible to disable row selection using the `isSelectDisabled` function passed to the wrapping data view component.
|
|
82
|
+
|
|
83
|
+
```js file="./DataViewTableTreeExample.tsx"
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Empty state example
|
|
88
|
+
The data view table supports displaying a custom empty state. You can pass it using the the `headStates` and `bodyStates` properties and their `empty` key. It will be automatically displayed in case there are no rows to be rendered.
|
|
89
|
+
|
|
90
|
+
```js file="./DataViewTableEmptyExample.tsx"
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Error state example
|
|
95
|
+
The data view table also supports displaying an error state. You can pass it using the the `headStates` and `bodyStates` properties and their `error` key. It will be displayed in case the data view recieves its `state` property set to `error`.
|
|
96
|
+
|
|
97
|
+
```js file="./DataViewTableErrorExample.tsx"
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Loading state example
|
|
102
|
+
The data view table also supports displaying a custom loading state. You can pass it using the `headStates` and `bodyStates` properties and their `loading` key. Your state will be displayed in case the data view recieves its `state` property set to `loading`.
|
|
103
|
+
|
|
104
|
+
```js file="./DataViewTableLoadingExample.tsx"
|
|
105
|
+
|
|
106
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
|
+
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
|
+
import { CubesIcon } from '@patternfly/react-icons';
|
|
5
|
+
import { Button, EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter, } from '@patternfly/react-core';
|
|
6
|
+
import { Tbody, Td, Tr } from '@patternfly/react-table';
|
|
7
|
+
|
|
8
|
+
interface Repository {
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
branches: string | null;
|
|
12
|
+
prs: string | null;
|
|
13
|
+
workspaces: string;
|
|
14
|
+
lastCommit: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const repositories: Repository[] = [];
|
|
18
|
+
|
|
19
|
+
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
|
|
20
|
+
const rows: DataViewTr[] = repositories.map((repository) => Object.values(repository));
|
|
21
|
+
|
|
22
|
+
const columns: DataViewTh[] = [ 'Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit' ];
|
|
23
|
+
|
|
24
|
+
const ouiaId = 'TableExample';
|
|
25
|
+
|
|
26
|
+
const empty = (
|
|
27
|
+
<Tbody>
|
|
28
|
+
<Tr key="loading" ouiaId={`${ouiaId}-tr-loading`}>
|
|
29
|
+
<Td colSpan={columns.length}>
|
|
30
|
+
<EmptyState headingLevel="h4" icon={CubesIcon} titleText="No data found">
|
|
31
|
+
<EmptyStateBody>There are no matching data to be displayed.</EmptyStateBody>
|
|
32
|
+
<EmptyStateFooter>
|
|
33
|
+
<EmptyStateActions>
|
|
34
|
+
<Button variant="primary">Primary action</Button>
|
|
35
|
+
</EmptyStateActions>
|
|
36
|
+
<EmptyStateActions>
|
|
37
|
+
<Button variant="link">Multiple</Button>
|
|
38
|
+
<Button variant="link">Action Buttons</Button>
|
|
39
|
+
</EmptyStateActions>
|
|
40
|
+
</EmptyStateFooter>
|
|
41
|
+
</EmptyState>
|
|
42
|
+
</Td>
|
|
43
|
+
</Tr>
|
|
44
|
+
</Tbody>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export const BasicExample: React.FunctionComponent = () => (
|
|
48
|
+
<DataView activeState={DataViewState.empty}>
|
|
49
|
+
<DataViewTable
|
|
50
|
+
aria-label='Repositories table'
|
|
51
|
+
ouiaId={ouiaId}
|
|
52
|
+
columns={columns}
|
|
53
|
+
rows={rows}
|
|
54
|
+
bodyStates={{ empty }}
|
|
55
|
+
/>
|
|
56
|
+
</DataView>
|
|
57
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
|
+
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
|
+
import { ErrorState } from '@patternfly/react-component-groups';
|
|
5
|
+
import { Tbody, Td, Tr } 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 repositories: Repository[] = [];
|
|
17
|
+
|
|
18
|
+
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
|
|
19
|
+
const rows: DataViewTr[] = repositories.map((repository) => Object.values(repository));
|
|
20
|
+
|
|
21
|
+
const columns: DataViewTh[] = [ 'Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit' ];
|
|
22
|
+
|
|
23
|
+
const ouiaId = 'TableErrorExample';
|
|
24
|
+
|
|
25
|
+
const error = (
|
|
26
|
+
<Tbody>
|
|
27
|
+
<Tr key="loading" ouiaId={`${ouiaId}-tr-loading`}>
|
|
28
|
+
<Td colSpan={columns.length}>
|
|
29
|
+
<ErrorState titleText='Unable to load data' bodyText='There was an error retrieving data. Check your connection and reload the page.' />
|
|
30
|
+
</Td>
|
|
31
|
+
</Tr>
|
|
32
|
+
</Tbody>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const BasicExample: React.FunctionComponent = () => (
|
|
36
|
+
<DataView activeState={DataViewState.error}>
|
|
37
|
+
<DataViewTable
|
|
38
|
+
aria-label='Repositories table'
|
|
39
|
+
ouiaId={ouiaId}
|
|
40
|
+
columns={columns}
|
|
41
|
+
rows={rows}
|
|
42
|
+
bodyStates={{ error }}
|
|
43
|
+
/>
|
|
44
|
+
</DataView>
|
|
45
|
+
);
|
package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableExample.tsx
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React 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
|
+
}
|
|
15
|
+
|
|
16
|
+
const repositories: Repository[] = [
|
|
17
|
+
{ id: 1, name: 'Repository one', branches: 'Branch one', prs: 'Pull request one', workspaces: 'Workspace one', lastCommit: 'Timestamp one' },
|
|
18
|
+
{ id: 2, name: 'Repository two', branches: 'Branch two', prs: 'Pull request two', workspaces: 'Workspace two', lastCommit: 'Timestamp two' },
|
|
19
|
+
{ id: 3, name: 'Repository three', branches: 'Branch three', prs: 'Pull request three', workspaces: 'Workspace three', lastCommit: 'Timestamp three' },
|
|
20
|
+
{ id: 4, name: 'Repository four', branches: 'Branch four', prs: 'Pull request four', workspaces: 'Workspace four', lastCommit: 'Timestamp four' },
|
|
21
|
+
{ id: 5, name: 'Repository five', branches: 'Branch five', prs: 'Pull request five', workspaces: 'Workspace five', lastCommit: 'Timestamp five' },
|
|
22
|
+
{ id: 6, name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six' }
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const rowActions = [
|
|
26
|
+
{
|
|
27
|
+
title: 'Some action',
|
|
28
|
+
onClick: () => console.log('clicked on Some action') // eslint-disable-line no-console
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: <div>Another action</div>,
|
|
32
|
+
onClick: () => console.log('clicked on Another action') // eslint-disable-line no-console
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
isSeparator: true
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'Third action',
|
|
39
|
+
onClick: () => console.log('clicked on Third action') // eslint-disable-line no-console
|
|
40
|
+
}
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
|
|
44
|
+
const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspaces, lastCommit }) => [
|
|
45
|
+
{ id, cell: workspaces, props: { favorites: { isFavorited: true } } },
|
|
46
|
+
{ cell: <Button href='#' variant='link' isInline>{name}</Button> },
|
|
47
|
+
branches,
|
|
48
|
+
prs,
|
|
49
|
+
workspaces,
|
|
50
|
+
lastCommit,
|
|
51
|
+
{ cell: <ActionsColumn items={rowActions}/>, props: { isActionCell: true } },
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
const columns: DataViewTh[] = [
|
|
55
|
+
null,
|
|
56
|
+
'Repositories',
|
|
57
|
+
{ cell: <>Branches<ExclamationCircleIcon className='pf-v5-u-ml-sm' color="var(--pf-t--temp--dev--tbd)"/* CODEMODS: original v5 color was --pf-v5-global--danger-color--100 *//></> },
|
|
58
|
+
'Pull requests',
|
|
59
|
+
{ cell: 'Workspaces', props: { info: { tooltip: 'More information' } } },
|
|
60
|
+
{ cell: 'Last commit', props: { sort: { sortBy: {}, columnIndex: 4 } } },
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
const ouiaId = 'TableExample';
|
|
64
|
+
|
|
65
|
+
export const BasicExample: React.FunctionComponent = () => (
|
|
66
|
+
<DataViewTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} rows={rows} />
|
|
67
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
|
+
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
|
+
import { SkeletonTableBody, SkeletonTableHead } from '@patternfly/react-component-groups';
|
|
5
|
+
|
|
6
|
+
// you can also pass props to Tr by returning { row: DataViewTd[], props: TrProps } }
|
|
7
|
+
const rows: DataViewTr[] = [];
|
|
8
|
+
|
|
9
|
+
const columns: DataViewTh[] = [ 'Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit' ];
|
|
10
|
+
|
|
11
|
+
const ouiaId = 'TableExample';
|
|
12
|
+
|
|
13
|
+
const headLoading = <SkeletonTableHead columns={columns} />
|
|
14
|
+
const bodyLoading = <SkeletonTableBody rowsCount={5} columnsCount={columns.length} />;
|
|
15
|
+
|
|
16
|
+
export const BasicExample: React.FunctionComponent = () => (
|
|
17
|
+
<DataView activeState={DataViewState.loading}>
|
|
18
|
+
<DataViewTable
|
|
19
|
+
aria-label='Repositories table'
|
|
20
|
+
ouiaId={ouiaId}
|
|
21
|
+
columns={columns}
|
|
22
|
+
rows={rows}
|
|
23
|
+
headStates={{ loading: headLoading }}
|
|
24
|
+
bodyStates={{ loading: bodyLoading }}
|
|
25
|
+
/>
|
|
26
|
+
</DataView>
|
|
27
|
+
);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
|
+
import { DataViewTable, DataViewTh, DataViewTrTree } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
|
+
import { useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
|
|
5
|
+
import { FolderIcon, FolderOpenIcon, LeafIcon } from '@patternfly/react-icons';
|
|
6
|
+
|
|
7
|
+
interface Repository {
|
|
8
|
+
name: string;
|
|
9
|
+
branches: string | null;
|
|
10
|
+
prs: string | null;
|
|
11
|
+
workspaces: string;
|
|
12
|
+
lastCommit: string;
|
|
13
|
+
children?: Repository[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const repositories: Repository[] = [
|
|
17
|
+
{
|
|
18
|
+
name: 'Repository one',
|
|
19
|
+
branches: 'Branch one',
|
|
20
|
+
prs: 'Pull request one',
|
|
21
|
+
workspaces: 'Workspace one',
|
|
22
|
+
lastCommit: 'Timestamp one',
|
|
23
|
+
children: [
|
|
24
|
+
{ name: 'Repository two', branches: 'Branch two', prs: 'Pull request two', workspaces: 'Workspace two', lastCommit: 'Timestamp two' },
|
|
25
|
+
{ name: 'Repository three', branches: 'Branch three', prs: 'Pull request three', workspaces: 'Workspace three', lastCommit: 'Timestamp three' },
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Repository four',
|
|
30
|
+
branches: 'Branch four',
|
|
31
|
+
prs: 'Pull request four',
|
|
32
|
+
workspaces: 'Workspace four',
|
|
33
|
+
lastCommit: 'Timestamp four',
|
|
34
|
+
children: [ { name: 'Repository five', branches: 'Branch five', prs: 'Pull request five', workspaces: 'Workspace five', lastCommit: 'Timestamp five' } ]
|
|
35
|
+
},
|
|
36
|
+
{ name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six' }
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
const buildRows = (repositories: Repository[]): DataViewTrTree[] => repositories.map((repo) => ({
|
|
40
|
+
row: [ repo.name, repo.branches, repo.prs, repo.workspaces, repo.lastCommit ],
|
|
41
|
+
id: repo.name, // unique ID for each row
|
|
42
|
+
...(repo.children
|
|
43
|
+
? {
|
|
44
|
+
children: buildRows(repo.children) // build rows for children
|
|
45
|
+
}
|
|
46
|
+
: {})
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
const rows: DataViewTrTree[] = buildRows(repositories);
|
|
50
|
+
|
|
51
|
+
const columns: DataViewTh[] = [ 'Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit' ];
|
|
52
|
+
|
|
53
|
+
const ouiaId = 'TreeTableExample';
|
|
54
|
+
|
|
55
|
+
export const BasicExample: React.FunctionComponent = () => {
|
|
56
|
+
const selection = useDataViewSelection({ matchOption: (a, b) => a.id === b.id });
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<DataView selection={selection}>
|
|
60
|
+
<DataViewTable
|
|
61
|
+
isTreeTable
|
|
62
|
+
ouiaId={ouiaId}
|
|
63
|
+
columns={columns}
|
|
64
|
+
rows={rows}
|
|
65
|
+
leafIcon={<LeafIcon/>}
|
|
66
|
+
expandedIcon={<FolderOpenIcon aria-hidden />}
|
|
67
|
+
collapsedIcon={<FolderIcon aria-hidden />}
|
|
68
|
+
/>
|
|
69
|
+
</DataView>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pagination } from '@patternfly/react-core';
|
|
3
|
+
import { BulkSelect, ResponsiveAction, ResponsiveActions } from '@patternfly/react-component-groups';
|
|
4
|
+
import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
|
|
5
|
+
|
|
6
|
+
export const BasicExample: React.FunctionComponent = () => (
|
|
7
|
+
<DataViewToolbar
|
|
8
|
+
bulkSelect={
|
|
9
|
+
<BulkSelect
|
|
10
|
+
selectedCount={0}
|
|
11
|
+
pageCount={5}
|
|
12
|
+
onSelect={() => null}
|
|
13
|
+
/>
|
|
14
|
+
}
|
|
15
|
+
actions={
|
|
16
|
+
<ResponsiveActions breakpoint="lg" ouiaId="example-actions">
|
|
17
|
+
<ResponsiveAction isPersistent variant="primary">Persistent</ResponsiveAction>
|
|
18
|
+
<ResponsiveAction isPinned variant="secondary">Pinned</ResponsiveAction>
|
|
19
|
+
<ResponsiveAction>Action three</ResponsiveAction>
|
|
20
|
+
<ResponsiveAction>Action four</ResponsiveAction>
|
|
21
|
+
</ResponsiveActions>
|
|
22
|
+
}
|
|
23
|
+
pagination={
|
|
24
|
+
<Pagination page={1} perPage={10} />
|
|
25
|
+
}
|
|
26
|
+
/>
|
|
27
|
+
)
|
package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewToolbarExample.tsx
CHANGED
|
@@ -6,15 +6,15 @@ import DataViewToolbar from '@patternfly/react-data-view/dist/dynamic/DataViewTo
|
|
|
6
6
|
|
|
7
7
|
export const BasicExample: React.FunctionComponent = () => (
|
|
8
8
|
<DataViewToolbar
|
|
9
|
-
pagination={
|
|
10
|
-
<Pagination page={1} perPage={10} />
|
|
11
|
-
}
|
|
12
9
|
bulkSelect={
|
|
13
10
|
<BulkSelect
|
|
14
11
|
selectedCount={0}
|
|
15
12
|
pageCount={5}
|
|
16
13
|
onSelect={() => null}
|
|
17
14
|
/>
|
|
18
|
-
}
|
|
15
|
+
}
|
|
16
|
+
pagination={
|
|
17
|
+
<Pagination page={1} perPage={10} />
|
|
18
|
+
}
|
|
19
19
|
/>
|
|
20
20
|
)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Sidenav top-level section
|
|
3
|
+
# should be the same for all markdown files
|
|
4
|
+
section: extensions
|
|
5
|
+
subsection: Data view
|
|
6
|
+
# Sidenav secondary level section
|
|
7
|
+
# should be the same for all markdown files
|
|
8
|
+
id: Events context
|
|
9
|
+
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
|
|
10
|
+
source: react
|
|
11
|
+
# If you use typescript, the name of the interface to display props for
|
|
12
|
+
# These are found through the sourceProps function provided in patternfly-docs.source.js
|
|
13
|
+
sortValue: 3
|
|
14
|
+
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/EventsContext/EventsContext.md
|
|
15
|
+
---
|
|
16
|
+
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
17
|
+
import { Table, Tbody, Th, Thead, Tr, Td } from '@patternfly/react-table';
|
|
18
|
+
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
19
|
+
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
20
|
+
import { useDataViewEventsContext, DataViewEventsContext, DataViewEventsProvider, EventTypes } from '@patternfly/react-data-view/dist/dynamic/DataViewEventsContext';
|
|
21
|
+
import { Drawer, DrawerContent, DrawerContentBody } from '@patternfly/react-core';
|
|
22
|
+
|
|
23
|
+
The **data view events context** provides a way of listening to the data view events from the outside of the component.
|
|
24
|
+
|
|
25
|
+
### Row click subscription example
|
|
26
|
+
The following example demonstrates how to use the `DataViewEventsContext` to manage shared state and handle events. The `DataViewEventsProvider` is used to wrap components that need access to the shared context. This example illustrates how to set up a layout that listens for data view row click events and displays detailed information about the selected row in a [drawer component](/components/drawer).
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
```js file="./EventsExample.tsx"
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|