@patternfly/react-data-view 6.1.0 → 6.3.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 +2 -2
- package/dist/cjs/DataView/DataView.js +4 -7
- package/dist/cjs/DataView/DataView.test.js +3 -6
- package/dist/cjs/DataViewCheckboxFilter/DataViewCheckboxFilter.d.ts +2 -2
- package/dist/cjs/DataViewCheckboxFilter/DataViewCheckboxFilter.js +10 -15
- package/dist/cjs/DataViewCheckboxFilter/DataViewCheckboxFilter.test.js +3 -3
- package/dist/cjs/DataViewEventsContext/DataViewEventsContext.d.ts +3 -3
- package/dist/cjs/DataViewEventsContext/DataViewEventsContext.js +3 -25
- package/dist/cjs/DataViewEventsContext/DataViewEventsContext.test.js +11 -16
- package/dist/cjs/DataViewFilters/DataViewFilters.d.ts +2 -2
- package/dist/cjs/DataViewFilters/DataViewFilters.js +12 -40
- package/dist/cjs/DataViewFilters/DataViewFilters.test.js +11 -5
- package/dist/cjs/DataViewTable/DataViewTable.d.ts +2 -2
- package/dist/cjs/DataViewTable/DataViewTable.js +2 -5
- package/dist/cjs/DataViewTable/DataViewTable.test.js +4 -7
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +2 -2
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +15 -41
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +6 -12
- package/dist/cjs/DataViewTableHead/DataViewTableHead.d.ts +2 -2
- package/dist/cjs/DataViewTableHead/DataViewTableHead.js +5 -28
- package/dist/cjs/DataViewTableHead/DataViewTableHead.test.js +5 -13
- package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +2 -2
- package/dist/cjs/DataViewTableTree/DataViewTableTree.js +10 -34
- package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +6 -13
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.d.ts +2 -2
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.js +2 -6
- package/dist/cjs/DataViewTextFilter/DataViewTextFilter.test.js +3 -3
- package/dist/cjs/DataViewToolbar/DataViewToolbar.d.ts +4 -2
- package/dist/cjs/DataViewToolbar/DataViewToolbar.js +5 -34
- package/dist/cjs/DataViewToolbar/DataViewToolbar.test.js +3 -3
- package/dist/cjs/Hooks/filters.js +1 -1
- package/dist/cjs/Hooks/filters.test.js +25 -0
- package/dist/cjs/InternalContext/InternalContext.d.ts +3 -3
- package/dist/cjs/InternalContext/InternalContext.js +3 -25
- package/dist/cjs/InternalContext/InternalContext.test.js +9 -21
- package/dist/esm/DataView/DataView.d.ts +2 -2
- package/dist/esm/DataView/DataView.js +4 -4
- package/dist/esm/DataView/DataView.test.js +2 -5
- package/dist/esm/DataViewCheckboxFilter/DataViewCheckboxFilter.d.ts +2 -2
- package/dist/esm/DataViewCheckboxFilter/DataViewCheckboxFilter.js +10 -12
- package/dist/esm/DataViewCheckboxFilter/DataViewCheckboxFilter.test.js +2 -2
- package/dist/esm/DataViewEventsContext/DataViewEventsContext.d.ts +3 -3
- package/dist/esm/DataViewEventsContext/DataViewEventsContext.js +3 -2
- package/dist/esm/DataViewEventsContext/DataViewEventsContext.test.js +11 -13
- package/dist/esm/DataViewFilters/DataViewFilters.d.ts +2 -2
- package/dist/esm/DataViewFilters/DataViewFilters.js +12 -17
- package/dist/esm/DataViewFilters/DataViewFilters.test.js +11 -5
- package/dist/esm/DataViewTable/DataViewTable.d.ts +2 -2
- package/dist/esm/DataViewTable/DataViewTable.js +2 -2
- package/dist/esm/DataViewTable/DataViewTable.test.js +3 -3
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +2 -2
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +15 -18
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +5 -8
- package/dist/esm/DataViewTableHead/DataViewTableHead.d.ts +2 -2
- package/dist/esm/DataViewTableHead/DataViewTableHead.js +5 -5
- package/dist/esm/DataViewTableHead/DataViewTableHead.test.js +4 -9
- package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +2 -2
- package/dist/esm/DataViewTableTree/DataViewTableTree.js +10 -11
- package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +5 -9
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.d.ts +2 -2
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.js +2 -3
- package/dist/esm/DataViewTextFilter/DataViewTextFilter.test.js +2 -2
- package/dist/esm/DataViewToolbar/DataViewToolbar.d.ts +4 -2
- package/dist/esm/DataViewToolbar/DataViewToolbar.js +5 -11
- package/dist/esm/DataViewToolbar/DataViewToolbar.test.js +2 -2
- package/dist/esm/Hooks/filters.js +1 -1
- package/dist/esm/Hooks/filters.test.js +25 -0
- package/dist/esm/InternalContext/InternalContext.d.ts +3 -3
- package/dist/esm/InternalContext/InternalContext.js +3 -2
- package/dist/esm/InternalContext/InternalContext.test.js +7 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/patternfly-docs/content/extensions/data-view/examples/DataView/AbstractLayoutExample.tsx +3 -3
- package/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md +1 -1
- package/patternfly-docs/content/extensions/data-view/examples/DataView/EventsExample.tsx +4 -4
- package/patternfly-docs/content/extensions/data-view/examples/DataView/PredefinedLayoutFullExample.tsx +5 -5
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableEmptyExample.tsx +6 -6
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableErrorExample.tsx +2 -2
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableExample.tsx +2 -2
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableLoadingExample.tsx +4 -4
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableTreeExample.tsx +2 -2
- package/patternfly-docs/content/extensions/data-view/examples/Table/SortingExample.tsx +3 -3
- package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +1 -1
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/AllSelectedExample.tsx +116 -0
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md +13 -1
- package/patternfly-docs/pages/index.js +1 -0
- package/release.config.js +10 -2
- package/src/DataView/DataView.test.tsx +10 -8
- package/src/DataView/DataView.tsx +4 -4
- package/src/DataViewCheckboxFilter/DataViewCheckboxFilter.test.tsx +0 -1
- package/src/DataViewCheckboxFilter/DataViewCheckboxFilter.tsx +10 -10
- package/src/DataViewEventsContext/DataViewEventsContext.test.tsx +4 -4
- package/src/DataViewEventsContext/DataViewEventsContext.tsx +1 -1
- package/src/DataViewFilters/DataViewFilters.test.tsx +29 -10
- package/src/DataViewFilters/DataViewFilters.tsx +12 -12
- package/src/DataViewTable/DataViewTable.test.tsx +0 -1
- package/src/DataViewTable/DataViewTable.tsx +2 -2
- package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +0 -1
- package/src/DataViewTableBasic/DataViewTableBasic.tsx +2 -2
- package/src/DataViewTableHead/DataViewTableHead.test.tsx +0 -1
- package/src/DataViewTableHead/DataViewTableHead.tsx +2 -2
- package/src/DataViewTableTree/DataViewTableTree.test.tsx +0 -1
- package/src/DataViewTableTree/DataViewTableTree.tsx +5 -5
- package/src/DataViewTextFilter/DataViewTextFilter.test.tsx +0 -1
- package/src/DataViewTextFilter/DataViewTextFilter.tsx +2 -2
- package/src/DataViewToolbar/DataViewToolbar.test.tsx +0 -1
- package/src/DataViewToolbar/DataViewToolbar.tsx +9 -2
- package/src/Hooks/filters.test.tsx +27 -0
- package/src/Hooks/filters.ts +1 -1
- package/src/InternalContext/InternalContext.test.tsx +0 -1
- package/src/InternalContext/InternalContext.tsx +2 -2
- package/tsconfig.json +1 -1
|
@@ -9,7 +9,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useState, useMemo } from 'react';
|
|
13
14
|
import { Table, Tbody, Td, TreeRowWrapper, } from '@patternfly/react-table';
|
|
14
15
|
import { useInternalContext } from '../InternalContext';
|
|
15
16
|
import { DataViewTableHead } from '../DataViewTableHead';
|
|
@@ -44,8 +45,8 @@ export const DataViewTableTree = (_a) => {
|
|
|
44
45
|
var { columns, rows, headStates, bodyStates, leafIcon = null, expandedIcon = null, collapsedIcon = null, ouiaId = 'DataViewTableTree' } = _a, props = __rest(_a, ["columns", "rows", "headStates", "bodyStates", "leafIcon", "expandedIcon", "collapsedIcon", "ouiaId"]);
|
|
45
46
|
const { selection, activeState } = useInternalContext();
|
|
46
47
|
const { onSelect, isSelected, isSelectDisabled } = selection !== null && selection !== void 0 ? selection : {};
|
|
47
|
-
const [expandedNodeIds, setExpandedNodeIds] =
|
|
48
|
-
const [expandedDetailsNodeNames, setExpandedDetailsNodeIds] =
|
|
48
|
+
const [expandedNodeIds, setExpandedNodeIds] = useState([]);
|
|
49
|
+
const [expandedDetailsNodeNames, setExpandedDetailsNodeIds] = useState([]);
|
|
49
50
|
const activeHeadState = useMemo(() => activeState ? headStates === null || headStates === void 0 ? void 0 : headStates[activeState] : undefined, [activeState, headStates]);
|
|
50
51
|
const activeBodyState = useMemo(() => activeState ? bodyStates === null || bodyStates === void 0 ? void 0 : bodyStates[activeState] : undefined, [activeState, bodyStates]);
|
|
51
52
|
const nodes = useMemo(() => {
|
|
@@ -88,11 +89,11 @@ export const DataViewTableTree = (_a) => {
|
|
|
88
89
|
? renderRows(node.children, level + 1, 1, rowIndex + 1, !isExpanded || isHidden)
|
|
89
90
|
: [];
|
|
90
91
|
return [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
92
|
+
_jsx(TreeRowWrapper, { row: { props: treeRow.props }, ouiaId: `${ouiaId}-tr-${rowIndex}`, children: node.row.map((cell, colIndex) => {
|
|
93
|
+
var _a;
|
|
94
|
+
const cellIsObject = isDataViewTdObject(cell);
|
|
95
|
+
return (_jsx(Td, Object.assign({ treeRow: colIndex === 0 ? treeRow : undefined }, (cellIsObject && ((_a = cell === null || cell === void 0 ? void 0 : cell.props) !== null && _a !== void 0 ? _a : {})), { "data-ouia-component-id": `${ouiaId}-td-${rowIndex}-${colIndex}`, children: cellIsObject ? cell.cell : cell }), colIndex));
|
|
96
|
+
}) }, node.id),
|
|
96
97
|
...childRows,
|
|
97
98
|
...renderRows(remainingNodes, level, posinset + 1, rowIndex + 1 + childRows.length, isHidden),
|
|
98
99
|
];
|
|
@@ -110,8 +111,6 @@ export const DataViewTableTree = (_a) => {
|
|
|
110
111
|
isSelectDisabled,
|
|
111
112
|
ouiaId
|
|
112
113
|
]);
|
|
113
|
-
return (
|
|
114
|
-
activeHeadState || React.createElement(DataViewTableHead, { isTreeTable: true, columns: columns, ouiaId: ouiaId }),
|
|
115
|
-
activeBodyState || React.createElement(Tbody, null, nodes)));
|
|
114
|
+
return (_jsxs(Table, Object.assign({ isTreeTable: true, "aria-label": "Data table", ouiaId: ouiaId }, props, { children: [activeHeadState || _jsx(DataViewTableHead, { isTreeTable: true, columns: columns, ouiaId: ouiaId }), activeBodyState || _jsx(Tbody, { children: nodes })] })));
|
|
116
115
|
};
|
|
117
116
|
export default DataViewTableTree;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { FolderIcon, FolderOpenIcon, LeafIcon } from '@patternfly/react-icons';
|
|
4
4
|
import { DataView } from '../DataView';
|
|
@@ -63,23 +63,19 @@ describe('DataViewTableTree component', () => {
|
|
|
63
63
|
isSelectDisabled: jest.fn(),
|
|
64
64
|
};
|
|
65
65
|
test('should render the tree table correctly', () => {
|
|
66
|
-
const { container } = render(
|
|
67
|
-
React.createElement(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, rows: rows, leafIcon: React.createElement(LeafIcon, null), expandedIcon: React.createElement(FolderOpenIcon, { "aria-hidden": true }), collapsedIcon: React.createElement(FolderIcon, { "aria-hidden": true }) })));
|
|
66
|
+
const { container } = render(_jsx(DataView, { selection: mockSelection, children: _jsx(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, rows: rows, leafIcon: _jsx(LeafIcon, {}), expandedIcon: _jsx(FolderOpenIcon, { "aria-hidden": true }), collapsedIcon: _jsx(FolderIcon, { "aria-hidden": true }) }) }));
|
|
68
67
|
expect(container).toMatchSnapshot();
|
|
69
68
|
});
|
|
70
69
|
test('should render tree table with an empty state', () => {
|
|
71
|
-
const { container } = render(
|
|
72
|
-
React.createElement(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, bodyStates: { empty: "No data found" }, rows: [] })));
|
|
70
|
+
const { container } = render(_jsx(DataView, { activeState: "empty", children: _jsx(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, bodyStates: { empty: "No data found" }, rows: [] }) }));
|
|
73
71
|
expect(container).toMatchSnapshot();
|
|
74
72
|
});
|
|
75
73
|
test('should render tree table with an error state', () => {
|
|
76
|
-
const { container } = render(
|
|
77
|
-
React.createElement(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, bodyStates: { error: "Some error" }, rows: [] })));
|
|
74
|
+
const { container } = render(_jsx(DataView, { activeState: "error", children: _jsx(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, bodyStates: { error: "Some error" }, rows: [] }) }));
|
|
78
75
|
expect(container).toMatchSnapshot();
|
|
79
76
|
});
|
|
80
77
|
test('should render tree table with a loading state', () => {
|
|
81
|
-
const { container } = render(
|
|
82
|
-
React.createElement(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, bodyStates: { loading: "Data is loading" }, rows: [] })));
|
|
78
|
+
const { container } = render(_jsx(DataView, { activeState: "loading", children: _jsx(DataViewTable, { isTreeTable: true, "aria-label": 'Repositories table', ouiaId: ouiaId, columns: columns, bodyStates: { loading: "Data is loading" }, rows: [] }) }));
|
|
83
79
|
expect(container).toMatchSnapshot();
|
|
84
80
|
});
|
|
85
81
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { SearchInputProps, ToolbarFilterProps } from '@patternfly/react-core';
|
|
3
3
|
/** extends SearchInputProps */
|
|
4
4
|
export interface DataViewTextFilterProps extends SearchInputProps {
|
|
@@ -17,5 +17,5 @@ export interface DataViewTextFilterProps extends SearchInputProps {
|
|
|
17
17
|
/** Custom OUIA ID */
|
|
18
18
|
ouiaId?: string;
|
|
19
19
|
}
|
|
20
|
-
export declare const DataViewTextFilter:
|
|
20
|
+
export declare const DataViewTextFilter: FC<DataViewTextFilterProps>;
|
|
21
21
|
export default DataViewTextFilter;
|
|
@@ -9,11 +9,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { SearchInput, ToolbarFilter } from '@patternfly/react-core';
|
|
14
14
|
export const DataViewTextFilter = (_a) => {
|
|
15
15
|
var { filterId, title, value = '', onChange, onClear = () => onChange === null || onChange === void 0 ? void 0 : onChange(undefined, ''), showToolbarItem, trimValue = true, ouiaId = 'DataViewTextFilter' } = _a, props = __rest(_a, ["filterId", "title", "value", "onChange", "onClear", "showToolbarItem", "trimValue", "ouiaId"]);
|
|
16
|
-
return (
|
|
17
|
-
React.createElement(SearchInput, Object.assign({ searchInputId: filterId, value: value, onChange: (e, inputValue) => onChange === null || onChange === void 0 ? void 0 : onChange(e, trimValue ? inputValue.trim() : inputValue), onClear: onClear, placeholder: `Filter by ${title}`, "aria-label": `${title !== null && title !== void 0 ? title : filterId} filter`, "data-ouia-component-id": `${ouiaId}-input` }, props))));
|
|
16
|
+
return (_jsx(ToolbarFilter, { "data-ouia-component-id": ouiaId, labels: value.length > 0 ? [{ key: title, node: value }] : [], deleteLabel: () => onChange === null || onChange === void 0 ? void 0 : onChange(undefined, ''), categoryName: title, showToolbarItem: showToolbarItem, children: _jsx(SearchInput, Object.assign({ searchInputId: filterId, value: value, onChange: (e, inputValue) => onChange === null || onChange === void 0 ? void 0 : onChange(e, trimValue ? inputValue.trim() : inputValue), onClear: onClear, placeholder: `Filter by ${title}`, "aria-label": `${title !== null && title !== void 0 ? title : filterId} filter`, "data-ouia-component-id": `${ouiaId}-input` }, props)) }, ouiaId));
|
|
18
17
|
};
|
|
19
18
|
export default DataViewTextFilter;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import DataViewTextFilter from './DataViewTextFilter';
|
|
4
4
|
import DataViewToolbar from '../DataViewToolbar';
|
|
@@ -11,7 +11,7 @@ describe('DataViewTextFilter component', () => {
|
|
|
11
11
|
onChange: mockOnChange,
|
|
12
12
|
};
|
|
13
13
|
it('should render correctly', () => {
|
|
14
|
-
const { container } = render(
|
|
14
|
+
const { container } = render(_jsx(DataViewToolbar, { filters: _jsx(DataViewTextFilter, Object.assign({}, defaultProps)) }));
|
|
15
15
|
expect(container).toMatchSnapshot();
|
|
16
16
|
});
|
|
17
17
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { ToolbarProps } from '@patternfly/react-core';
|
|
3
3
|
/** extends ToolbarProps */
|
|
4
4
|
export interface DataViewToolbarProps extends Omit<PropsWithChildren<ToolbarProps>, 'ref'> {
|
|
@@ -12,10 +12,12 @@ export interface DataViewToolbarProps extends Omit<PropsWithChildren<ToolbarProp
|
|
|
12
12
|
pagination?: React.ReactNode;
|
|
13
13
|
/** React node to display actions */
|
|
14
14
|
actions?: React.ReactNode;
|
|
15
|
+
/** React node to display toggle group */
|
|
16
|
+
toggleGroup?: React.ReactNode;
|
|
15
17
|
/** React node to display filters */
|
|
16
18
|
filters?: React.ReactNode;
|
|
17
19
|
/** React node to display custom filter labels */
|
|
18
20
|
customLabelGroupContent?: React.ReactNode;
|
|
19
21
|
}
|
|
20
|
-
export declare const DataViewToolbar:
|
|
22
|
+
export declare const DataViewToolbar: FC<DataViewToolbarProps>;
|
|
21
23
|
export default DataViewToolbar;
|
|
@@ -9,18 +9,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useRef } from 'react';
|
|
13
14
|
import { Button, Toolbar, ToolbarContent, ToolbarItem, ToolbarItemVariant } from '@patternfly/react-core';
|
|
14
15
|
export const DataViewToolbar = (_a) => {
|
|
15
|
-
var { className, ouiaId = 'DataViewToolbar', bulkSelect, actions, pagination, filters, customLabelGroupContent, clearAllFilters, children } = _a, props = __rest(_a, ["className", "ouiaId", "bulkSelect", "actions", "pagination", "filters", "customLabelGroupContent", "clearAllFilters", "children"]);
|
|
16
|
-
const defaultClearFilters = useRef(
|
|
17
|
-
|
|
18
|
-
return (React.createElement(Toolbar, Object.assign({ ouiaId: ouiaId, className: className, customLabelGroupContent: customLabelGroupContent !== null && customLabelGroupContent !== void 0 ? customLabelGroupContent : defaultClearFilters.current }, props),
|
|
19
|
-
React.createElement(ToolbarContent, null,
|
|
20
|
-
bulkSelect && (React.createElement(ToolbarItem, { "data-ouia-component-id": `${ouiaId}-bulk-select` }, bulkSelect)),
|
|
21
|
-
filters && (React.createElement(ToolbarItem, null, filters)),
|
|
22
|
-
actions && (React.createElement(ToolbarItem, null, actions)),
|
|
23
|
-
pagination && (React.createElement(ToolbarItem, { variant: ToolbarItemVariant.pagination, "data-ouia-component-id": `${ouiaId}-pagination` }, pagination)),
|
|
24
|
-
children)));
|
|
16
|
+
var { className, ouiaId = 'DataViewToolbar', bulkSelect, actions, toggleGroup, pagination, filters, customLabelGroupContent, clearAllFilters, children } = _a, props = __rest(_a, ["className", "ouiaId", "bulkSelect", "actions", "toggleGroup", "pagination", "filters", "customLabelGroupContent", "clearAllFilters", "children"]);
|
|
17
|
+
const defaultClearFilters = useRef(_jsx(ToolbarItem, { children: _jsx(Button, { ouiaId: `${ouiaId}-clear-all-filters`, variant: "link", onClick: clearAllFilters, isInline: true, children: "Clear filters" }) }));
|
|
18
|
+
return (_jsx(Toolbar, Object.assign({ ouiaId: ouiaId, className: className, customLabelGroupContent: customLabelGroupContent !== null && customLabelGroupContent !== void 0 ? customLabelGroupContent : defaultClearFilters.current }, props, { children: _jsxs(ToolbarContent, { children: [bulkSelect && (_jsx(ToolbarItem, { "data-ouia-component-id": `${ouiaId}-bulk-select`, children: bulkSelect })), filters && (_jsx(ToolbarItem, { children: filters })), actions && (_jsx(ToolbarItem, { children: actions })), toggleGroup && (_jsx(ToolbarItem, { children: toggleGroup })), pagination && (_jsx(ToolbarItem, { variant: ToolbarItemVariant.pagination, "data-ouia-component-id": `${ouiaId}-pagination`, children: pagination })), children] }) })));
|
|
25
19
|
};
|
|
26
20
|
export default DataViewToolbar;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import DataViewToolbar from './DataViewToolbar';
|
|
4
4
|
import { Pagination } from '@patternfly/react-core';
|
|
5
5
|
describe('DataViewToolbar component', () => {
|
|
6
6
|
test('should render correctly', () => {
|
|
7
|
-
expect(render(
|
|
7
|
+
expect(render(_jsx(DataViewToolbar, { pagination: _jsx(Pagination, { page: 1, perPage: 10 }) }))).toMatchSnapshot();
|
|
8
8
|
});
|
|
9
9
|
});
|
|
@@ -4,8 +4,8 @@ export const useDataViewFilters = ({ initialFilters = {}, searchParams, setSearc
|
|
|
4
4
|
const isUrlSyncEnabled = useMemo(() => searchParams && !!setSearchParams, [searchParams, setSearchParams]);
|
|
5
5
|
const getInitialFilters = useCallback(() => isUrlSyncEnabled
|
|
6
6
|
? Object.keys(initialFilters).reduce((loadedFilters, key) => {
|
|
7
|
-
const urlValue = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get(key);
|
|
8
7
|
const isArrayFilter = Array.isArray(initialFilters[key]);
|
|
8
|
+
const urlValue = isArrayFilter ? searchParams === null || searchParams === void 0 ? void 0 : searchParams.getAll(key) : searchParams === null || searchParams === void 0 ? void 0 : searchParams.get(key);
|
|
9
9
|
// eslint-disable-next-line no-nested-ternary
|
|
10
10
|
loadedFilters[key] = urlValue
|
|
11
11
|
? (isArrayFilter && !Array.isArray(urlValue) ? [urlValue] : urlValue)
|
|
@@ -40,6 +40,31 @@ describe('useDataViewFilters', () => {
|
|
|
40
40
|
act(() => result.current.onSetFilters({ search: 'new search' }));
|
|
41
41
|
expect(setSearchParams).toHaveBeenCalled();
|
|
42
42
|
});
|
|
43
|
+
it('should sync with URL search params with non array value', () => {
|
|
44
|
+
const searchParams = new URLSearchParams();
|
|
45
|
+
searchParams.set('test', 'foo');
|
|
46
|
+
const setSearchParams = jest.fn();
|
|
47
|
+
const props = {
|
|
48
|
+
initialFilters: { test: '' },
|
|
49
|
+
searchParams,
|
|
50
|
+
setSearchParams,
|
|
51
|
+
};
|
|
52
|
+
const { result } = renderHook(() => useDataViewFilters(props));
|
|
53
|
+
expect(result.current.filters).toEqual({ test: 'foo' });
|
|
54
|
+
});
|
|
55
|
+
it('should sync with URL search params with array value', () => {
|
|
56
|
+
const searchParams = new URLSearchParams();
|
|
57
|
+
searchParams.append('test', 'foo');
|
|
58
|
+
searchParams.append('test', 'bar');
|
|
59
|
+
const setSearchParams = jest.fn();
|
|
60
|
+
const props = {
|
|
61
|
+
initialFilters: { test: [] },
|
|
62
|
+
searchParams,
|
|
63
|
+
setSearchParams,
|
|
64
|
+
};
|
|
65
|
+
const { result } = renderHook(() => useDataViewFilters(props));
|
|
66
|
+
expect(result.current.filters).toEqual({ test: ['foo', 'bar'] });
|
|
67
|
+
});
|
|
43
68
|
it('should reset filters to default values when clearAllFilters is called', () => {
|
|
44
69
|
const { result } = renderHook(() => useDataViewFilters({ initialFilters }));
|
|
45
70
|
act(() => result.current.clearAllFilters());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
2
|
import { DataViewState } from '../DataView';
|
|
3
3
|
export interface DataViewSelection {
|
|
4
4
|
/** Called when the selection of items changes */
|
|
@@ -19,8 +19,8 @@ export interface InternalContextValue extends InternalContextProps {
|
|
|
19
19
|
/** Flag indicating if data view is selectable (auto-calculated) */
|
|
20
20
|
isSelectable: boolean;
|
|
21
21
|
}
|
|
22
|
-
export declare const InternalContext:
|
|
22
|
+
export declare const InternalContext: import("react").Context<InternalContextValue>;
|
|
23
23
|
export type InternalProviderProps = PropsWithChildren<InternalContextProps>;
|
|
24
|
-
export declare const InternalContextProvider:
|
|
24
|
+
export declare const InternalContextProvider: FC<InternalProviderProps>;
|
|
25
25
|
export declare const useInternalContext: () => InternalContextValue;
|
|
26
26
|
export default InternalContext;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
2
3
|
export const InternalContext = createContext({
|
|
3
4
|
selection: undefined,
|
|
4
5
|
activeState: undefined,
|
|
@@ -6,7 +7,7 @@ export const InternalContext = createContext({
|
|
|
6
7
|
});
|
|
7
8
|
export const InternalContextProvider = ({ children, selection, activeState }) => {
|
|
8
9
|
const isSelectable = useMemo(() => Boolean((selection === null || selection === void 0 ? void 0 : selection.onSelect) && (selection === null || selection === void 0 ? void 0 : selection.isSelected)), [selection === null || selection === void 0 ? void 0 : selection.onSelect, selection === null || selection === void 0 ? void 0 : selection.isSelected]);
|
|
9
|
-
return (
|
|
10
|
+
return (_jsx(InternalContext.Provider, { value: { selection, activeState, isSelectable }, children: children }));
|
|
10
11
|
};
|
|
11
12
|
export const useInternalContext = () => useContext(InternalContext);
|
|
12
13
|
export default InternalContext;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { render, fireEvent } from '@testing-library/react';
|
|
3
3
|
import '@testing-library/jest-dom';
|
|
4
4
|
import { useInternalContext } from './InternalContext';
|
|
@@ -12,12 +12,9 @@ describe('InternalContext', () => {
|
|
|
12
12
|
test('should provide context value and allow consuming it', () => {
|
|
13
13
|
const TestComponent = () => {
|
|
14
14
|
const { selection } = useInternalContext();
|
|
15
|
-
return (
|
|
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')));
|
|
15
|
+
return (_jsxs("div", { children: [_jsx("button", { onClick: () => selection === null || selection === void 0 ? void 0 : selection.onSelect(true, ['item1']), children: "Select item" }), _jsx("span", { children: (selection === null || selection === void 0 ? void 0 : selection.isSelected('item1')) ? 'Selected' : 'Not selected' })] }));
|
|
18
16
|
};
|
|
19
|
-
const { getByText } = render(
|
|
20
|
-
React.createElement(TestComponent, null)));
|
|
17
|
+
const { getByText } = render(_jsx(DataView, { selection: mockSelection, children: _jsx(TestComponent, {}) }));
|
|
21
18
|
fireEvent.click(getByText('Select item'));
|
|
22
19
|
expect(mockSelection.onSelect).toHaveBeenCalledWith(true, ['item1']);
|
|
23
20
|
});
|
|
@@ -25,12 +22,9 @@ describe('InternalContext', () => {
|
|
|
25
22
|
const mockSelectionState = Object.assign(Object.assign({}, mockSelection), { isSelected: jest.fn((item) => item === 'item1') });
|
|
26
23
|
const TestComponent = () => {
|
|
27
24
|
const { selection } = useInternalContext();
|
|
28
|
-
return (
|
|
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')));
|
|
25
|
+
return (_jsxs("div", { children: [_jsx("span", { children: (selection === null || selection === void 0 ? void 0 : selection.isSelected('item1')) ? 'Item 1 is selected' : 'Item 1 is not selected' }), _jsx("span", { children: (selection === null || selection === void 0 ? void 0 : selection.isSelected('item2')) ? 'Item 2 is selected' : 'Item 2 is not selected' })] }));
|
|
31
26
|
};
|
|
32
|
-
const { getByText } = render(
|
|
33
|
-
React.createElement(TestComponent, null)));
|
|
27
|
+
const { getByText } = render(_jsx(DataView, { selection: mockSelectionState, children: _jsx(TestComponent, {}) }));
|
|
34
28
|
expect(getByText('Item 1 is selected')).toBeInTheDocument();
|
|
35
29
|
expect(getByText('Item 2 is not selected')).toBeInTheDocument();
|
|
36
30
|
});
|
|
@@ -39,12 +33,9 @@ describe('InternalContext', () => {
|
|
|
39
33
|
const TestComponent = () => {
|
|
40
34
|
var _a, _b;
|
|
41
35
|
const { selection } = useInternalContext();
|
|
42
|
-
return (
|
|
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')));
|
|
36
|
+
return (_jsxs("div", { children: [_jsx("span", { children: ((_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' }), _jsx("span", { children: ((_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
37
|
};
|
|
46
|
-
const { getByText } = render(
|
|
47
|
-
React.createElement(TestComponent, null)));
|
|
38
|
+
const { getByText } = render(_jsx(DataView, { selection: mockSelectionWithDisabled, children: _jsx(TestComponent, {}) }));
|
|
48
39
|
expect(getByText('Item 3 is disabled')).toBeInTheDocument();
|
|
49
40
|
expect(getByText('Item 1 is enabled')).toBeInTheDocument();
|
|
50
41
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/
|
|
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/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.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-data-view",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.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",
|
|
@@ -39,22 +39,22 @@
|
|
|
39
39
|
"react-jss": "^10.10.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"react": "^17 || ^18",
|
|
43
|
-
"react-dom": "^17 || ^18"
|
|
42
|
+
"react": "^17 || ^18 || ^19",
|
|
43
|
+
"react-dom": "^17 || ^18 || ^19"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/documentation-framework": "^6.5.
|
|
46
|
+
"@patternfly/documentation-framework": "^6.5.20",
|
|
47
47
|
"@patternfly/patternfly": "^6.0.0",
|
|
48
48
|
"@patternfly/react-code-editor": "^6.0.0",
|
|
49
|
-
"@patternfly/patternfly-a11y": "^5.
|
|
50
|
-
"@types/react": "^18.3.
|
|
51
|
-
"@types/react-dom": "^18.3.
|
|
49
|
+
"@patternfly/patternfly-a11y": "^5.1.0",
|
|
50
|
+
"@types/react": "^18.3.23",
|
|
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.
|
|
56
|
-
"react-router-dom": "^6.
|
|
55
|
+
"react-router": "^6.30.1",
|
|
56
|
+
"react-router-dom": "^6.30.1",
|
|
57
57
|
"rimraf": "^6.0.1",
|
|
58
|
-
"typescript": "^5.
|
|
58
|
+
"typescript": "^5.8.3"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/patternfly-docs/content/extensions/data-view/examples/DataView/AbstractLayoutExample.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import DataView from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
3
|
|
|
4
4
|
const layoutItemStyling = {
|
|
@@ -8,10 +8,10 @@ const layoutItemStyling = {
|
|
|
8
8
|
border: 'var(--pf-t--global--border--width--box--default) dashed var(--pf-t--global--border--color--default)'
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export const BasicExample:
|
|
11
|
+
export const BasicExample: FunctionComponent = () => (
|
|
12
12
|
<DataView>
|
|
13
13
|
<div style={layoutItemStyling}>Header</div>
|
|
14
14
|
<div style={layoutItemStyling}>Data representation</div>
|
|
15
15
|
<div style={layoutItemStyling}>Footer</div>
|
|
16
16
|
</DataView>
|
|
17
|
-
)
|
|
17
|
+
);
|
|
@@ -7,7 +7,7 @@ propComponents: ['DataView']
|
|
|
7
7
|
sortValue: 1
|
|
8
8
|
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md
|
|
9
9
|
---
|
|
10
|
-
import { useState, useEffect, useRef, useMemo } from 'react';
|
|
10
|
+
import { FunctionComponent, useState, useEffect, useRef, useMemo } from 'react';
|
|
11
11
|
import { Drawer, DrawerContent, DrawerContentBody } from '@patternfly/react-core';
|
|
12
12
|
import { CubesIcon } from '@patternfly/react-icons';
|
|
13
13
|
import { useDataViewPagination, useDataViewSelection, useDataViewFilters, useDataViewSort } from '@patternfly/react-data-view/dist/dynamic/Hooks';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent, useEffect, useState, useRef, useMemo } from 'react';
|
|
2
2
|
import { Drawer, DrawerActions, DrawerCloseButton, DrawerContent, DrawerContentBody, DrawerHead, DrawerPanelContent, Title, Content } from '@patternfly/react-core';
|
|
3
3
|
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
4
4
|
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
@@ -32,7 +32,7 @@ interface RepositoryDetailProps {
|
|
|
32
32
|
setSelectedRepo: React.Dispatch<React.SetStateAction<Repository | undefined>>;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const RepositoryDetail:
|
|
35
|
+
const RepositoryDetail: FunctionComponent<RepositoryDetailProps> = ({ selectedRepo, setSelectedRepo }) => {
|
|
36
36
|
const context = useDataViewEventsContext();
|
|
37
37
|
|
|
38
38
|
useEffect(() => {
|
|
@@ -84,7 +84,7 @@ const rowActions = [
|
|
|
84
84
|
}
|
|
85
85
|
];
|
|
86
86
|
|
|
87
|
-
const RepositoriesTable:
|
|
87
|
+
const RepositoriesTable: FunctionComponent<RepositoriesTableProps> = ({ selectedRepo = undefined }) => {
|
|
88
88
|
const selection = useDataViewSelection({ matchOption: (a, b) => a.row[0] === b.row[0] });
|
|
89
89
|
const { trigger } = useDataViewEventsContext();
|
|
90
90
|
const rows = useMemo(() => {
|
|
@@ -110,7 +110,7 @@ const RepositoriesTable: React.FunctionComponent<RepositoriesTableProps> = ({ se
|
|
|
110
110
|
);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
export const BasicExample:
|
|
113
|
+
export const BasicExample: FunctionComponent = () => {
|
|
114
114
|
const [ selectedRepo, setSelectedRepo ] = useState<Repository>();
|
|
115
115
|
const drawerRef = useRef<HTMLDivElement>(null);
|
|
116
116
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
|
-
import
|
|
2
|
+
import { FunctionComponent, useEffect, useState, useRef, useMemo } from 'react';
|
|
3
3
|
import { Drawer, DrawerActions, DrawerCloseButton, DrawerContent, DrawerContentBody, DrawerHead, DrawerPanelContent, Title, Content, EmptyState, EmptyStateBody, EmptyStateFooter, EmptyStateActions, Button, } from '@patternfly/react-core';
|
|
4
4
|
import { ActionsColumn, Tbody, Td, ThProps, Tr } from '@patternfly/react-table';
|
|
5
5
|
import { BulkSelect, BulkSelectValue } from '@patternfly/react-component-groups/dist/dynamic/BulkSelect';
|
|
@@ -94,7 +94,7 @@ interface RepositoryDetailProps {
|
|
|
94
94
|
setSelectedRepo: React.Dispatch<React.SetStateAction<Repository | undefined>>;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
const RepositoryDetail:
|
|
97
|
+
const RepositoryDetail: FunctionComponent<RepositoryDetailProps> = ({ selectedRepo, setSelectedRepo }) => {
|
|
98
98
|
const context = useDataViewEventsContext();
|
|
99
99
|
|
|
100
100
|
useEffect(() => {
|
|
@@ -146,13 +146,13 @@ const rowActions = [
|
|
|
146
146
|
}
|
|
147
147
|
];
|
|
148
148
|
|
|
149
|
-
const RepositoriesTable:
|
|
149
|
+
const RepositoriesTable: FunctionComponent<RepositoriesTableProps> = ({ selectedRepo = undefined }) => {
|
|
150
150
|
const { filters, onSetFilters, clearAllFilters } = useDataViewFilters<RepositoryFilters>({ initialFilters: { name: '', branch: '', workspace: [] } });
|
|
151
151
|
|
|
152
152
|
const pagination = useDataViewPagination({ perPage: 5 });
|
|
153
153
|
const { page, perPage } = pagination;
|
|
154
154
|
|
|
155
|
-
const selection = useDataViewSelection({ matchOption: (a, b) => a[0] === b[0] });
|
|
155
|
+
const selection = useDataViewSelection({ matchOption: (a, b) => a.row[0] === b.row[0] });
|
|
156
156
|
const { selected, onSelect, isSelected } = selection;
|
|
157
157
|
|
|
158
158
|
const { trigger } = useDataViewEventsContext();
|
|
@@ -255,7 +255,7 @@ const RepositoriesTable: React.FunctionComponent<RepositoriesTableProps> = ({ se
|
|
|
255
255
|
);
|
|
256
256
|
};
|
|
257
257
|
|
|
258
|
-
export const BasicExample:
|
|
258
|
+
export const BasicExample: FunctionComponent = () => {
|
|
259
259
|
const [ selectedRepo, setSelectedRepo ] = useState<Repository>();
|
|
260
260
|
const drawerRef = useRef<HTMLDivElement>(null);
|
|
261
261
|
|
package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableEmptyExample.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
3
|
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
4
|
import { CubesIcon } from '@patternfly/react-icons';
|
|
5
|
-
import { Button, EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter
|
|
5
|
+
import { Button, EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter } from '@patternfly/react-core';
|
|
6
6
|
import { Tbody, Td, Tr } from '@patternfly/react-table';
|
|
7
7
|
|
|
8
8
|
interface Repository {
|
|
@@ -27,7 +27,7 @@ const empty = (
|
|
|
27
27
|
<Tbody>
|
|
28
28
|
<Tr key="loading" ouiaId={`${ouiaId}-tr-loading`}>
|
|
29
29
|
<Td colSpan={columns.length}>
|
|
30
|
-
<EmptyState
|
|
30
|
+
<EmptyState headingLevel="h4" icon={CubesIcon} titleText="No data found">
|
|
31
31
|
<EmptyStateBody>There are no matching data to be displayed.</EmptyStateBody>
|
|
32
32
|
<EmptyStateFooter>
|
|
33
33
|
<EmptyStateActions>
|
|
@@ -44,10 +44,10 @@ const empty = (
|
|
|
44
44
|
</Tbody>
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
export const BasicExample:
|
|
47
|
+
export const BasicExample: FunctionComponent = () => (
|
|
48
48
|
<DataView activeState={DataViewState.empty}>
|
|
49
|
-
<DataViewTable
|
|
50
|
-
aria-label=
|
|
49
|
+
<DataViewTable
|
|
50
|
+
aria-label="Repositories table"
|
|
51
51
|
ouiaId={ouiaId}
|
|
52
52
|
columns={columns}
|
|
53
53
|
rows={rows}
|
package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableErrorExample.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
3
|
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
4
|
import { ErrorState } from '@patternfly/react-component-groups';
|
|
@@ -32,7 +32,7 @@ const error = (
|
|
|
32
32
|
</Tbody>
|
|
33
33
|
);
|
|
34
34
|
|
|
35
|
-
export const BasicExample:
|
|
35
|
+
export const BasicExample: FunctionComponent = () => (
|
|
36
36
|
<DataView activeState={DataViewState.error}>
|
|
37
37
|
<DataViewTable
|
|
38
38
|
aria-label='Repositories table'
|
package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableExample.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
3
3
|
import { ExclamationCircleIcon } from '@patternfly/react-icons';
|
|
4
4
|
import { Button } from '@patternfly/react-core';
|
|
@@ -62,6 +62,6 @@ const columns: DataViewTh[] = [
|
|
|
62
62
|
|
|
63
63
|
const ouiaId = 'TableExample';
|
|
64
64
|
|
|
65
|
-
export const BasicExample:
|
|
65
|
+
export const BasicExample: FunctionComponent = () => (
|
|
66
66
|
<DataViewTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} rows={rows} />
|
|
67
67
|
);
|
package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableLoadingExample.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
3
|
import { DataViewTable, DataViewTr, DataViewTh } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
4
|
import { SkeletonTableBody, SkeletonTableHead } from '@patternfly/react-component-groups';
|
|
@@ -10,13 +10,13 @@ const columns: DataViewTh[] = [ 'Repositories', 'Branches', 'Pull requests', 'Wo
|
|
|
10
10
|
|
|
11
11
|
const ouiaId = 'TableExample';
|
|
12
12
|
|
|
13
|
-
const headLoading = <SkeletonTableHead columns={columns}
|
|
13
|
+
const headLoading = <SkeletonTableHead columns={columns} />;
|
|
14
14
|
const bodyLoading = <SkeletonTableBody rowsCount={5} columnsCount={columns.length} />;
|
|
15
15
|
|
|
16
|
-
export const BasicExample:
|
|
16
|
+
export const BasicExample: FunctionComponent = () => (
|
|
17
17
|
<DataView activeState={DataViewState.loading}>
|
|
18
18
|
<DataViewTable
|
|
19
|
-
aria-label=
|
|
19
|
+
aria-label="Repositories table"
|
|
20
20
|
ouiaId={ouiaId}
|
|
21
21
|
columns={columns}
|
|
22
22
|
rows={rows}
|
package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableTreeExample.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FunctionComponent } from 'react';
|
|
2
2
|
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
3
3
|
import { DataViewTable, DataViewTh, DataViewTrTree } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
4
4
|
import { useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
|
|
@@ -52,7 +52,7 @@ const columns: DataViewTh[] = [ 'Repositories', 'Branches', 'Pull requests', 'Wo
|
|
|
52
52
|
|
|
53
53
|
const ouiaId = 'TreeTableExample';
|
|
54
54
|
|
|
55
|
-
export const BasicExample:
|
|
55
|
+
export const BasicExample: FunctionComponent = () => {
|
|
56
56
|
const selection = useDataViewSelection({ matchOption: (a, b) => a.id === b.id });
|
|
57
57
|
|
|
58
58
|
return (
|