@patternfly/react-table 5.0.0-alpha.99 → 5.0.0-prerelease.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +210 -7991
- package/README.md +48 -87
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/Table/package.json +1 -0
- package/dist/dynamic/components/Table/utils/decorators/package.json +1 -0
- package/dist/dynamic/components/Table/utils/package.json +1 -0
- package/dist/dynamic/deprecated/components/Table/base/package.json +1 -0
- package/dist/dynamic/deprecated/components/Table/package.json +1 -0
- package/dist/dynamic/deprecated/components/package.json +1 -0
- package/dist/esm/components/Table/ActionsColumn.d.ts +4 -2
- package/dist/esm/components/Table/ActionsColumn.d.ts.map +1 -1
- package/dist/esm/components/Table/ActionsColumn.js +6 -6
- package/dist/esm/components/Table/ActionsColumn.js.map +1 -1
- package/dist/esm/components/Table/Caption.d.ts.map +1 -1
- package/dist/esm/components/Table/Caption.js +3 -1
- package/dist/esm/components/Table/Caption.js.map +1 -1
- package/dist/esm/components/Table/Table.js +1 -1
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/Tbody.d.ts.map +1 -1
- package/dist/esm/components/Table/Tbody.js +1 -1
- package/dist/esm/components/Table/Tbody.js.map +1 -1
- package/dist/esm/components/Table/Td.d.ts +1 -1
- package/dist/esm/components/Table/Td.d.ts.map +1 -1
- package/dist/esm/components/Table/Td.js +1 -1
- package/dist/esm/components/Table/Td.js.map +1 -1
- package/dist/esm/components/Table/Th.d.ts.map +1 -1
- package/dist/esm/components/Table/Th.js +1 -1
- package/dist/esm/components/Table/Th.js.map +1 -1
- package/dist/esm/components/Table/Thead.d.ts.map +1 -1
- package/dist/esm/components/Table/Thead.js +1 -1
- package/dist/esm/components/Table/Thead.js.map +1 -1
- package/dist/esm/components/Table/Tr.js +1 -2
- package/dist/esm/components/Table/Tr.js.map +1 -1
- package/dist/js/components/Table/ActionsColumn.d.ts +4 -2
- package/dist/js/components/Table/ActionsColumn.d.ts.map +1 -1
- package/dist/js/components/Table/ActionsColumn.js +6 -6
- package/dist/js/components/Table/ActionsColumn.js.map +1 -1
- package/dist/js/components/Table/Caption.d.ts.map +1 -1
- package/dist/js/components/Table/Caption.js +3 -1
- package/dist/js/components/Table/Caption.js.map +1 -1
- package/dist/js/components/Table/Table.js +1 -1
- package/dist/js/components/Table/Table.js.map +1 -1
- package/dist/js/components/Table/Tbody.d.ts.map +1 -1
- package/dist/js/components/Table/Tbody.js +1 -1
- package/dist/js/components/Table/Tbody.js.map +1 -1
- package/dist/js/components/Table/Td.d.ts +1 -1
- package/dist/js/components/Table/Td.d.ts.map +1 -1
- package/dist/js/components/Table/Td.js +1 -1
- package/dist/js/components/Table/Td.js.map +1 -1
- package/dist/js/components/Table/Th.d.ts.map +1 -1
- package/dist/js/components/Table/Th.js +1 -1
- package/dist/js/components/Table/Th.js.map +1 -1
- package/dist/js/components/Table/Thead.d.ts.map +1 -1
- package/dist/js/components/Table/Thead.js +1 -1
- package/dist/js/components/Table/Thead.js.map +1 -1
- package/dist/js/components/Table/Tr.js +1 -2
- package/dist/js/components/Table/Tr.js.map +1 -1
- package/dist/umd/react-table.min.js +5 -5
- package/package.json +8 -8
- package/single-packages.config.json +0 -14
- package/src/components/Table/ActionsColumn.tsx +12 -6
- package/src/components/Table/Caption.tsx +3 -1
- package/src/components/Table/Table.tsx +1 -1
- package/src/components/Table/Tbody.tsx +1 -0
- package/src/components/Table/Td.tsx +2 -1
- package/src/components/Table/Th.tsx +1 -0
- package/src/components/Table/Thead.tsx +1 -0
- package/src/components/Table/Tr.tsx +1 -1
- package/src/components/Table/__tests__/__snapshots__/RowWrapper.test.tsx.snap +4 -4
- package/src/components/Table/examples/TableSortableCustom.tsx +10 -21
- package/src/components/Table/utils/transformers.test.tsx +1 -1
- package/src/deprecated/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +1896 -1780
- package/src/deprecated/components/Table/examples/LegacyTableSortableCustom.tsx +12 -29
- package/src/deprecated/components/Table/examples/Table.md +1 -0
- package/src/docs/demos/Table.md +32 -344
- package/src/docs/demos/table-demos/BulkSelect.jsx +167 -0
- package/src/docs/demos/table-demos/ColumnManagement.jsx +10 -4
- package/src/docs/demos/table-demos/Compact.jsx +19 -14
- package/src/docs/demos/table-demos/CompoundExpansion.jsx +4 -4
- package/src/docs/demos/table-demos/ExpandCollapseAll.jsx +88 -106
- package/src/docs/demos/table-demos/SortableResponsive.jsx +11 -21
- package/src/docs/demos/table-demos/StaticBottomPagination.jsx +18 -13
- package/src/docs/demos/table-demos/StickyHeader.jsx +63 -0
- package/src/docs/{examples/Data.jsx → demos/table-demos/sampleData.js} +6 -8
- package/subpaths.config.json +4 -0
- package/components/index.d.ts +0 -2
- package/components/index.d.ts.map +0 -1
- package/components/index.js +0 -2
- package/components/index.js.map +0 -1
- package/deprecated/index.d.ts +0 -2
- package/deprecated/index.d.ts.map +0 -1
- package/deprecated/index.js +0 -2
- package/deprecated/index.js.map +0 -1
- package/dist/js/components/Table/package.json +0 -1
- package/dist/js/components/Table/utils/decorators/package.json +0 -1
- package/dist/js/components/Table/utils/package.json +0 -1
- package/dist/js/components/package.json +0 -1
- package/dist/js/deprecated/components/Table/base/package.json +0 -1
- package/dist/js/deprecated/components/Table/package.json +0 -1
- package/dist/js/deprecated/components/package.json +0 -1
- package/dist/js/deprecated/package.json +0 -1
- package/dist/js/package.json +0 -1
- package/scripts/createSubpaths.js +0 -32
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Dropdown,
|
|
5
|
+
DropdownList,
|
|
6
|
+
DropdownItem,
|
|
7
|
+
MenuToggle,
|
|
8
|
+
MenuToggleCheckbox,
|
|
9
|
+
PageSection,
|
|
10
|
+
Pagination,
|
|
11
|
+
Toolbar,
|
|
12
|
+
ToolbarContent,
|
|
13
|
+
ToolbarGroup,
|
|
14
|
+
ToolbarItem
|
|
15
|
+
} from '@patternfly/react-core';
|
|
16
|
+
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
17
|
+
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
18
|
+
|
|
19
|
+
import { rows, columns } from './sampleData';
|
|
20
|
+
|
|
21
|
+
export const BulkSelectTableDemo = () => {
|
|
22
|
+
const [isBulkSelectDropdownOpen, setIsBulkSelectDropdownOpen] = React.useState(false);
|
|
23
|
+
const [bulkSelection, setBulkSelection] = React.useState('');
|
|
24
|
+
const [page, setPage] = React.useState(1);
|
|
25
|
+
const [perPage, setPerPage] = React.useState(10);
|
|
26
|
+
const [paginatedRows, setPaginatedRows] = React.useState(rows.slice(0, 10));
|
|
27
|
+
const [selectedRows, setSelectedRows] = React.useState([]);
|
|
28
|
+
const handleSetPage = (_evt, newPage, _perPage, startIdx, endIdx) => {
|
|
29
|
+
setPaginatedRows(rows.slice(startIdx, endIdx));
|
|
30
|
+
setPage(newPage);
|
|
31
|
+
};
|
|
32
|
+
const handlePerPageSelect = (_evt, newPerPage, newPage, startIdx, endIdx) => {
|
|
33
|
+
setPaginatedRows(rows.slice(startIdx, endIdx));
|
|
34
|
+
setPage(newPage);
|
|
35
|
+
setPerPage(newPerPage);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const setRowSelected = (row, isSelecting = true) =>
|
|
39
|
+
setSelectedRows((prevSelected) => {
|
|
40
|
+
const otherSelectedRows = prevSelected.filter((r) => r !== row.name);
|
|
41
|
+
return isSelecting ? [...otherSelectedRows, row.name] : otherSelectedRows;
|
|
42
|
+
});
|
|
43
|
+
const selectAllRows = (isSelecting = true) => setSelectedRows(isSelecting ? rows.map((r) => r.name) : []);
|
|
44
|
+
const selectPageRows = (isSelecting = true) => setSelectedRows(isSelecting ? paginatedRows.map((r) => r.name) : []);
|
|
45
|
+
const isRowSelected = (row) => selectedRows.includes(row.name);
|
|
46
|
+
|
|
47
|
+
const buildPagination = (variant, isCompact) => (
|
|
48
|
+
<Pagination
|
|
49
|
+
isCompact={isCompact}
|
|
50
|
+
itemCount={rows.length}
|
|
51
|
+
page={page}
|
|
52
|
+
perPage={perPage}
|
|
53
|
+
onSetPage={handleSetPage}
|
|
54
|
+
onPerPageSelect={handlePerPageSelect}
|
|
55
|
+
variant={variant}
|
|
56
|
+
titles={{
|
|
57
|
+
paginationAriaLabel: `${variant} pagination`
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const buildBulkSelectDropdown = () => {
|
|
63
|
+
const numSelected = selectedRows.length;
|
|
64
|
+
const allSelected = numSelected === rows.length;
|
|
65
|
+
const anySelected = numSelected > 0;
|
|
66
|
+
const someChecked = anySelected ? null : false;
|
|
67
|
+
const isChecked = allSelected ? true : someChecked;
|
|
68
|
+
|
|
69
|
+
const items = (
|
|
70
|
+
<>
|
|
71
|
+
<DropdownItem value="none">Select none (0 items)</DropdownItem>
|
|
72
|
+
<DropdownItem value="page">Select page ({perPage} items)</DropdownItem>
|
|
73
|
+
<DropdownItem value="all">Select all ({rows.length} items)</DropdownItem>
|
|
74
|
+
</>
|
|
75
|
+
);
|
|
76
|
+
return (
|
|
77
|
+
<Dropdown
|
|
78
|
+
role="menu"
|
|
79
|
+
onSelect={(_ev, value) => {
|
|
80
|
+
if (value === 'all') {
|
|
81
|
+
selectAllRows(bulkSelection !== 'all');
|
|
82
|
+
} else if (value === 'page') {
|
|
83
|
+
selectPageRows(bulkSelection !== 'page');
|
|
84
|
+
} else {
|
|
85
|
+
setSelectedRows([]);
|
|
86
|
+
}
|
|
87
|
+
setBulkSelection(value);
|
|
88
|
+
}}
|
|
89
|
+
isOpen={isBulkSelectDropdownOpen}
|
|
90
|
+
onOpenChange={(isOpen) => setIsBulkSelectDropdownOpen(isOpen)}
|
|
91
|
+
toggle={(toggleRef) => (
|
|
92
|
+
<MenuToggle
|
|
93
|
+
ref={toggleRef}
|
|
94
|
+
isExpanded={isBulkSelectDropdownOpen}
|
|
95
|
+
onClick={() => setIsBulkSelectDropdownOpen(!isBulkSelectDropdownOpen)}
|
|
96
|
+
aria-label="Select cards"
|
|
97
|
+
splitButtonOptions={{
|
|
98
|
+
items: [
|
|
99
|
+
<MenuToggleCheckbox
|
|
100
|
+
id="split-dropdown-checkbox"
|
|
101
|
+
key="split-dropdown-checkbox"
|
|
102
|
+
aria-label={anySelected ? 'Deselect all cards' : 'Select all cards'}
|
|
103
|
+
isChecked={isChecked}
|
|
104
|
+
onClick={() => {
|
|
105
|
+
anySelected ? setSelectedRows([]) : selectAllRows(bulkSelection !== 'all');
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
{numSelected !== 0 && `${numSelected} selected`}
|
|
109
|
+
</MenuToggleCheckbox>
|
|
110
|
+
]
|
|
111
|
+
}}
|
|
112
|
+
></MenuToggle>
|
|
113
|
+
)}
|
|
114
|
+
>
|
|
115
|
+
<DropdownList>{items}</DropdownList>
|
|
116
|
+
</Dropdown>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const toolbar = (
|
|
121
|
+
<Toolbar>
|
|
122
|
+
<ToolbarContent>
|
|
123
|
+
<ToolbarGroup>
|
|
124
|
+
<ToolbarItem variant="bulk-select">{buildBulkSelectDropdown()}</ToolbarItem>
|
|
125
|
+
</ToolbarGroup>
|
|
126
|
+
<ToolbarItem variant="pagination">{buildPagination('top')}</ToolbarItem>
|
|
127
|
+
</ToolbarContent>
|
|
128
|
+
</Toolbar>
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
133
|
+
<PageSection isWidthLimited>
|
|
134
|
+
{toolbar}
|
|
135
|
+
<Table aria-label="Selectable table">
|
|
136
|
+
<Thead>
|
|
137
|
+
<Tr>
|
|
138
|
+
<Th />
|
|
139
|
+
<Th key={0}>{columns[0]}</Th>
|
|
140
|
+
<Th key={1}>{columns[1]}</Th>
|
|
141
|
+
<Th key={2}>{columns[2]}</Th>
|
|
142
|
+
<Th key={3}>{columns[3]}</Th>
|
|
143
|
+
</Tr>
|
|
144
|
+
</Thead>
|
|
145
|
+
<Tbody>
|
|
146
|
+
{paginatedRows.map((row, rowIndex) => (
|
|
147
|
+
<Tr key={row.name}>
|
|
148
|
+
<Td
|
|
149
|
+
select={{
|
|
150
|
+
rowIndex,
|
|
151
|
+
onSelect: (_event, isSelecting) => setRowSelected(row, isSelecting),
|
|
152
|
+
isSelected: isRowSelected(row)
|
|
153
|
+
}}
|
|
154
|
+
/>
|
|
155
|
+
<Td dataLabel={columns[0]}>{row.name}</Td>
|
|
156
|
+
<Td dataLabel={columns[1]}>{row.threads}</Td>
|
|
157
|
+
<Td dataLabel={columns[2]}>{row.applications}</Td>
|
|
158
|
+
<Td dataLabel={columns[3]}>{row.workspaces}</Td>
|
|
159
|
+
</Tr>
|
|
160
|
+
))}
|
|
161
|
+
</Tbody>
|
|
162
|
+
</Table>
|
|
163
|
+
{buildPagination('bottom')}
|
|
164
|
+
</PageSection>
|
|
165
|
+
</DashboardWrapper>
|
|
166
|
+
);
|
|
167
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
Button,
|
|
4
5
|
DataList,
|
|
@@ -26,10 +27,11 @@ import {
|
|
|
26
27
|
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
27
28
|
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
28
29
|
import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
|
|
29
|
-
import { rows, columns } from '../../examples/Data.jsx';
|
|
30
30
|
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper.js';
|
|
31
31
|
import { capitalize } from '@patternfly/react-table/src/components/Table/utils/utils';
|
|
32
32
|
|
|
33
|
+
import { rows, columns } from './sampleData';
|
|
34
|
+
|
|
33
35
|
export const ColumnManagementAction = () => {
|
|
34
36
|
const defaultColumns = columns;
|
|
35
37
|
const defaultRows = rows;
|
|
@@ -389,10 +391,14 @@ export const ColumnManagementAction = () => {
|
|
|
389
391
|
<ToolbarItem variant="overflow-menu">
|
|
390
392
|
<OverflowMenu breakpoint="md">
|
|
391
393
|
<OverflowMenuItem>
|
|
392
|
-
<MenuToggle
|
|
394
|
+
<MenuToggle>
|
|
395
|
+
<FilterIcon /> Name
|
|
396
|
+
</MenuToggle>
|
|
393
397
|
</OverflowMenuItem>
|
|
394
398
|
<OverflowMenuItem>
|
|
395
|
-
<MenuToggle variant="plain" aria-label="Sort columns"
|
|
399
|
+
<MenuToggle variant="plain" aria-label="Sort columns">
|
|
400
|
+
<SortAmountDownIcon aria-hidden="true" />
|
|
401
|
+
</MenuToggle>
|
|
396
402
|
</OverflowMenuItem>
|
|
397
403
|
<OverflowMenuGroup groupType="button" isPersistent>
|
|
398
404
|
<OverflowMenuItem>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
Button,
|
|
4
5
|
Card,
|
|
@@ -7,17 +8,17 @@ import {
|
|
|
7
8
|
Pagination,
|
|
8
9
|
PageSection,
|
|
9
10
|
Select,
|
|
10
|
-
|
|
11
|
+
SelectOption,
|
|
11
12
|
Toolbar,
|
|
12
13
|
ToolbarContent,
|
|
13
14
|
ToolbarGroup,
|
|
14
15
|
ToolbarItem
|
|
15
16
|
} from '@patternfly/react-core';
|
|
16
17
|
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
17
|
-
|
|
18
18
|
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
19
19
|
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
import { rows, columns } from './sampleData';
|
|
21
22
|
|
|
22
23
|
export const CompactTable = () => {
|
|
23
24
|
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
|
@@ -57,23 +58,27 @@ export const CompactTable = () => {
|
|
|
57
58
|
id="select-example"
|
|
58
59
|
aria-label="Select Input"
|
|
59
60
|
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
|
60
|
-
<MenuToggle
|
|
61
|
-
ref={toggleRef}
|
|
62
|
-
onClick={() => setIsSelectOpen(!isSelectOpen)}
|
|
63
|
-
isExpanded={isSelectOpen}
|
|
64
|
-
>
|
|
61
|
+
<MenuToggle ref={toggleRef} onClick={() => setIsSelectOpen(!isSelectOpen)} isExpanded={isSelectOpen}>
|
|
65
62
|
<FilterIcon /> Status
|
|
66
63
|
</MenuToggle>
|
|
67
64
|
)}
|
|
68
65
|
isOpen={isSelectOpen}
|
|
69
|
-
onOpenChange={isOpen => setIsSelectOpen(isOpen)}
|
|
66
|
+
onOpenChange={(isOpen) => setIsSelectOpen(isOpen)}
|
|
70
67
|
onSelect={() => setIsSelectOpen(!isSelectOpen)}
|
|
71
68
|
>
|
|
72
69
|
{[
|
|
73
|
-
<SelectOption key={0}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<SelectOption key={
|
|
70
|
+
<SelectOption key={0} value="Debug">
|
|
71
|
+
Debug
|
|
72
|
+
</SelectOption>,
|
|
73
|
+
<SelectOption key={1} value="Info">
|
|
74
|
+
Info
|
|
75
|
+
</SelectOption>,
|
|
76
|
+
<SelectOption key={2} value="Warn">
|
|
77
|
+
Warn
|
|
78
|
+
</SelectOption>,
|
|
79
|
+
<SelectOption key={3} value="Error">
|
|
80
|
+
Error
|
|
81
|
+
</SelectOption>
|
|
77
82
|
]}
|
|
78
83
|
</Select>
|
|
79
84
|
</ToolbarItem>
|
|
@@ -87,7 +92,7 @@ export const CompactTable = () => {
|
|
|
87
92
|
</Toolbar>
|
|
88
93
|
);
|
|
89
94
|
|
|
90
|
-
const renderLabel = labelText => {
|
|
95
|
+
const renderLabel = (labelText) => {
|
|
91
96
|
switch (labelText) {
|
|
92
97
|
case 'Running':
|
|
93
98
|
return <Label color="green">{labelText}</Label>;
|
|
@@ -98,16 +98,16 @@ export const CompoundExpandable = () => {
|
|
|
98
98
|
onSelect={() => setIsSelectOpen(!isSelectOpen)}
|
|
99
99
|
>
|
|
100
100
|
{[
|
|
101
|
-
<SelectOption key={0}
|
|
101
|
+
<SelectOption key={0} value="Debug">
|
|
102
102
|
Debug
|
|
103
103
|
</SelectOption>,
|
|
104
|
-
<SelectOption key={1}
|
|
104
|
+
<SelectOption key={1} value="Info">
|
|
105
105
|
Info
|
|
106
106
|
</SelectOption>,
|
|
107
|
-
<SelectOption key={2}
|
|
107
|
+
<SelectOption key={2} value="Warn">
|
|
108
108
|
Warn
|
|
109
109
|
</SelectOption>,
|
|
110
|
-
<SelectOption key={3}
|
|
110
|
+
<SelectOption key={3} value="Error">
|
|
111
111
|
Error
|
|
112
112
|
</SelectOption>
|
|
113
113
|
]}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Card, Label, PageSection } from '@patternfly/react-core';
|
|
3
|
-
import {
|
|
4
|
-
import { Table, TableHeader, TableBody } from '@patternfly/react-table/deprecated';
|
|
2
|
+
import { Card, Label, PageSection, TextVariants, Text, TextContent } from '@patternfly/react-core';
|
|
3
|
+
import { Table, Thead, Tbody, Tr, Th, Td, ExpandableRowContent } from '@patternfly/react-table';
|
|
5
4
|
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
6
|
-
import { TextVariants } from '@patternfly/react-core';
|
|
7
5
|
|
|
8
|
-
const expandableColumns = [
|
|
9
|
-
{
|
|
10
|
-
title: 'Servers',
|
|
11
|
-
cellFormatters: [expandable]
|
|
12
|
-
},
|
|
13
|
-
'Threads',
|
|
14
|
-
'Applications',
|
|
15
|
-
'Workspaces',
|
|
16
|
-
'Status'
|
|
17
|
-
];
|
|
6
|
+
const expandableColumns = ['Servers', 'Threads', 'Applications', 'Workspaces', 'Status'];
|
|
18
7
|
|
|
19
8
|
const serverData = [
|
|
20
9
|
{
|
|
@@ -22,7 +11,7 @@ const serverData = [
|
|
|
22
11
|
threads: 18,
|
|
23
12
|
applications: 42,
|
|
24
13
|
workspaces: 7,
|
|
25
|
-
status: { title: <Label color="
|
|
14
|
+
status: { title: <Label color="green">Running</Label> },
|
|
26
15
|
details: (
|
|
27
16
|
<TextContent>
|
|
28
17
|
<Text component={TextVariants.p}>
|
|
@@ -121,101 +110,94 @@ const serverData = [
|
|
|
121
110
|
|
|
122
111
|
const initialExpandedServerNames = ['US-Node 2']; // Default to expanded
|
|
123
112
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
isChecked: false,
|
|
129
|
-
selectedRows: 0,
|
|
130
|
-
expandedRows: 0,
|
|
131
|
-
expandCollapseToggle: 'expand',
|
|
132
|
-
collapseAllAriaLabel: 'Expand all',
|
|
133
|
-
expandedServerNames: initialExpandedServerNames
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
setServerExpanded = (server, isExpanding) => {
|
|
138
|
-
this.setState(() => {
|
|
139
|
-
const otherExpandedServerNames = this.state.expandedServerNames.filter(r => r !== server.name);
|
|
140
|
-
return {
|
|
141
|
-
expandedServerNames: isExpanding ? [...otherExpandedServerNames, server.name] : otherExpandedServerNames
|
|
142
|
-
};
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
render() {
|
|
147
|
-
const { collapseAllAriaLabel } = this.state;
|
|
113
|
+
const ExpandCollapseAllTableDemo = () => {
|
|
114
|
+
const [areAllExpanded, setAreAllExpanded] = React.useState(false);
|
|
115
|
+
const [collapseAllAriaLabel, setCollapseAllAriaLabel] = React.useState('Expand all');
|
|
116
|
+
const [expandedServerNames, setExpandedServerNames] = React.useState(initialExpandedServerNames);
|
|
148
117
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
118
|
+
React.useEffect(() => {
|
|
119
|
+
const allExpanded = expandedServerNames.length === serverData.length;
|
|
120
|
+
setAreAllExpanded(allExpanded);
|
|
121
|
+
setCollapseAllAriaLabel(allExpanded ? 'Collapse all' : 'Expand all');
|
|
122
|
+
}, [expandedServerNames]);
|
|
154
123
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
cells: [server.name, server.threads, server.applications, server.workspaces, server.status]
|
|
160
|
-
});
|
|
161
|
-
serversByRowIndex.push(server);
|
|
162
|
-
if (server.details) {
|
|
163
|
-
const cells = [];
|
|
164
|
-
|
|
165
|
-
cells.push({
|
|
166
|
-
title: server.details
|
|
167
|
-
});
|
|
124
|
+
const setServerExpanded = (server, isExpanding) => {
|
|
125
|
+
const otherExpandedServerNames = expandedServerNames.filter((r) => r !== server.name);
|
|
126
|
+
setExpandedServerNames(isExpanding ? [...otherExpandedServerNames, server.name] : otherExpandedServerNames);
|
|
127
|
+
};
|
|
168
128
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
173
|
-
serversByRowIndex.push(null);
|
|
174
|
-
}
|
|
175
|
-
});
|
|
129
|
+
const isServerExpanded = (server) => {
|
|
130
|
+
return expandedServerNames.includes(server.name);
|
|
131
|
+
};
|
|
176
132
|
|
|
177
|
-
|
|
178
|
-
|
|
133
|
+
// We want to be able to reference the original data object based on row index. But because an expanded
|
|
134
|
+
// row takes up two row indexes, servers[rowIndex] will not be accurate like it would in a normal table.
|
|
135
|
+
// One solution to this is to create an array of data objects indexed by the displayed row index.
|
|
179
136
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
expandedServerNames: isOpen ? [...serverData.map((server) => server.name)] : []
|
|
184
|
-
};
|
|
185
|
-
});
|
|
137
|
+
const onCollapseAll = (_event, _rowIndex, isOpen) => {
|
|
138
|
+
setExpandedServerNames(isOpen ? [...serverData.map((server) => server.name)] : []);
|
|
139
|
+
};
|
|
186
140
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
141
|
+
return (
|
|
142
|
+
<React.Fragment>
|
|
143
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
144
|
+
<PageSection
|
|
145
|
+
padding={{
|
|
146
|
+
default: 'noPadding',
|
|
147
|
+
xl: 'padding'
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<Card component="div">
|
|
151
|
+
<Table aria-label="Collapsible table">
|
|
152
|
+
<Thead>
|
|
153
|
+
<Tr>
|
|
154
|
+
<Th
|
|
155
|
+
expand={{
|
|
156
|
+
areAllExpanded: !areAllExpanded,
|
|
157
|
+
collapseAllAriaLabel: collapseAllAriaLabel,
|
|
158
|
+
onToggle: onCollapseAll
|
|
159
|
+
}}
|
|
160
|
+
></Th>
|
|
161
|
+
{expandableColumns.map((column) => (
|
|
162
|
+
<Th key={column}>{column}</Th>
|
|
163
|
+
))}
|
|
164
|
+
</Tr>
|
|
165
|
+
</Thead>
|
|
192
166
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
167
|
+
{serverData.map((server, serverIndex) => (
|
|
168
|
+
<Tbody key={server.name} isExpanded={isServerExpanded(server)}>
|
|
169
|
+
<Tr>
|
|
170
|
+
<Td
|
|
171
|
+
expand={
|
|
172
|
+
server.details
|
|
173
|
+
? {
|
|
174
|
+
rowIndex: serverIndex,
|
|
175
|
+
isExpanded: isServerExpanded(server),
|
|
176
|
+
onToggle: () => setServerExpanded(server, !isServerExpanded(server))
|
|
177
|
+
}
|
|
178
|
+
: undefined
|
|
179
|
+
}
|
|
180
|
+
>
|
|
181
|
+
<ExpandableRowContent>{server.details}</ExpandableRowContent>
|
|
182
|
+
</Td>
|
|
183
|
+
<Td>{server?.name}</Td>
|
|
184
|
+
<Td>{server?.threads}</Td>
|
|
185
|
+
<Td>{server?.applications}</Td>
|
|
186
|
+
<Td>{server?.workspaces}</Td>
|
|
187
|
+
<Td>{server?.status?.title}</Td>
|
|
188
|
+
</Tr>
|
|
189
|
+
<Tr isExpanded={isServerExpanded(server)}>
|
|
190
|
+
<Td></Td>
|
|
191
|
+
<Td colSpan={expandableColumns.length}>
|
|
192
|
+
<ExpandableRowContent>{server?.details}</ExpandableRowContent>
|
|
193
|
+
</Td>
|
|
194
|
+
</Tr>
|
|
195
|
+
</Tbody>
|
|
196
|
+
))}
|
|
197
|
+
</Table>
|
|
198
|
+
</Card>
|
|
199
|
+
</PageSection>
|
|
200
|
+
</DashboardWrapper>
|
|
201
|
+
</React.Fragment>
|
|
202
|
+
);
|
|
203
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
Button,
|
|
4
5
|
Card,
|
|
@@ -21,7 +22,6 @@ import {
|
|
|
21
22
|
ToolbarItem
|
|
22
23
|
} from '@patternfly/react-core';
|
|
23
24
|
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
24
|
-
import { rows, columns } from '../../examples/Data.jsx';
|
|
25
25
|
import CloneIcon from '@patternfly/react-icons/dist/esm/icons/clone-icon';
|
|
26
26
|
import EditIcon from '@patternfly/react-icons/dist/esm/icons/edit-icon';
|
|
27
27
|
import SyncIcon from '@patternfly/react-icons/dist/esm/icons/sync-icon';
|
|
@@ -32,6 +32,8 @@ import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
|
32
32
|
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
33
33
|
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
34
34
|
|
|
35
|
+
import { rows, columns } from './sampleData';
|
|
36
|
+
|
|
35
37
|
export const ComposableTableSortable = () => {
|
|
36
38
|
const [isKebabDropdownOpen, setIsKebabDropdownOpen] = React.useState(false);
|
|
37
39
|
|
|
@@ -128,12 +130,12 @@ export const ComposableTableSortable = () => {
|
|
|
128
130
|
<Select
|
|
129
131
|
isOpen={isSortDropdownOpen}
|
|
130
132
|
selected={[activeSortDirection, activeSortIndex]}
|
|
131
|
-
onOpenChange={isOpen => setIsSortDropdownOpen(isOpen)}
|
|
132
|
-
onSelect={(event,
|
|
133
|
-
if (
|
|
134
|
-
onSort(event, activeSortIndex,
|
|
133
|
+
onOpenChange={(isOpen) => setIsSortDropdownOpen(isOpen)}
|
|
134
|
+
onSelect={(event, value) => {
|
|
135
|
+
if (value === 'asc' || value === 'desc') {
|
|
136
|
+
onSort(event, activeSortIndex, value);
|
|
135
137
|
} else {
|
|
136
|
-
onSort(event,
|
|
138
|
+
onSort(event, value, activeSortDirection !== 'none' ? activeSortDirection : 'asc');
|
|
137
139
|
}
|
|
138
140
|
}}
|
|
139
141
|
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
|
@@ -150,11 +152,7 @@ export const ComposableTableSortable = () => {
|
|
|
150
152
|
<SelectGroup label="Sort column">
|
|
151
153
|
<SelectList>
|
|
152
154
|
{columns.map((column, columnIndex) => (
|
|
153
|
-
<SelectOption
|
|
154
|
-
key={column}
|
|
155
|
-
itemId={columnIndex}
|
|
156
|
-
isSelected={activeSortIndex === columnIndex}
|
|
157
|
-
>
|
|
155
|
+
<SelectOption key={column} value={columnIndex} isSelected={activeSortIndex === columnIndex}>
|
|
158
156
|
{column}
|
|
159
157
|
</SelectOption>
|
|
160
158
|
))}
|
|
@@ -162,18 +160,10 @@ export const ComposableTableSortable = () => {
|
|
|
162
160
|
</SelectGroup>
|
|
163
161
|
<SelectGroup label="Sort direction">
|
|
164
162
|
<SelectList>
|
|
165
|
-
<SelectOption
|
|
166
|
-
isSelected={activeSortDirection === 'asc'}
|
|
167
|
-
itemId="asc"
|
|
168
|
-
key="ascending"
|
|
169
|
-
>
|
|
163
|
+
<SelectOption isSelected={activeSortDirection === 'asc'} value="asc" key="ascending">
|
|
170
164
|
Ascending
|
|
171
165
|
</SelectOption>
|
|
172
|
-
<SelectOption
|
|
173
|
-
isSelected={activeSortDirection === 'desc'}
|
|
174
|
-
itemId="desc"
|
|
175
|
-
key="descending"
|
|
176
|
-
>
|
|
166
|
+
<SelectOption isSelected={activeSortDirection === 'desc'} value="desc" key="descending">
|
|
177
167
|
Descending
|
|
178
168
|
</SelectOption>
|
|
179
169
|
</SelectList>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import {
|
|
3
4
|
Button,
|
|
4
5
|
Card,
|
|
@@ -15,11 +16,11 @@ import {
|
|
|
15
16
|
SelectOption
|
|
16
17
|
} from '@patternfly/react-core';
|
|
17
18
|
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
18
|
-
import { rows, columns } from '../../examples/Data.jsx';
|
|
19
|
-
|
|
20
19
|
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
21
20
|
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
22
21
|
|
|
22
|
+
import { rows, columns } from './sampleData';
|
|
23
|
+
|
|
23
24
|
export const StaticBottomPagination = () => {
|
|
24
25
|
const [isSelectOpen, setIsSelectOpen] = React.useState(false);
|
|
25
26
|
const [page, setPage] = React.useState(1);
|
|
@@ -51,7 +52,7 @@ export const StaticBottomPagination = () => {
|
|
|
51
52
|
/>
|
|
52
53
|
);
|
|
53
54
|
|
|
54
|
-
const renderLabel = labelText => {
|
|
55
|
+
const renderLabel = (labelText) => {
|
|
55
56
|
switch (labelText) {
|
|
56
57
|
case 'Running':
|
|
57
58
|
return (
|
|
@@ -88,23 +89,27 @@ export const StaticBottomPagination = () => {
|
|
|
88
89
|
id="select-example"
|
|
89
90
|
aria-label="Select Input"
|
|
90
91
|
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
|
91
|
-
<MenuToggle
|
|
92
|
-
ref={toggleRef}
|
|
93
|
-
onClick={() => setIsSelectOpen(!isSelectOpen)}
|
|
94
|
-
isExpanded={isSelectOpen}
|
|
95
|
-
>
|
|
92
|
+
<MenuToggle ref={toggleRef} onClick={() => setIsSelectOpen(!isSelectOpen)} isExpanded={isSelectOpen}>
|
|
96
93
|
<FilterIcon /> Status
|
|
97
94
|
</MenuToggle>
|
|
98
95
|
)}
|
|
99
96
|
isOpen={isSelectOpen}
|
|
100
|
-
onOpenChange={isOpen => setIsSelectOpen(isOpen)}
|
|
97
|
+
onOpenChange={(isOpen) => setIsSelectOpen(isOpen)}
|
|
101
98
|
onSelect={() => setIsSelectOpen(!isSelectOpen)}
|
|
102
99
|
>
|
|
103
100
|
{[
|
|
104
|
-
<SelectOption key={0}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
<SelectOption key={
|
|
101
|
+
<SelectOption key={0} value="Debug">
|
|
102
|
+
Debug
|
|
103
|
+
</SelectOption>,
|
|
104
|
+
<SelectOption key={1} value="Info">
|
|
105
|
+
Info
|
|
106
|
+
</SelectOption>,
|
|
107
|
+
<SelectOption key={2} value="Warn">
|
|
108
|
+
Warn
|
|
109
|
+
</SelectOption>,
|
|
110
|
+
<SelectOption key={3} value="Error">
|
|
111
|
+
Error
|
|
112
|
+
</SelectOption>
|
|
108
113
|
]}
|
|
109
114
|
</Select>
|
|
110
115
|
</ToolbarItem>
|