@patternfly/react-table 5.0.0-alpha.117 → 5.0.0-alpha.119
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 +8 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/js/components/Table/package.json +1 -1
- package/dist/js/components/Table/utils/decorators/package.json +1 -1
- package/dist/js/components/Table/utils/package.json +1 -1
- package/dist/js/components/package.json +1 -1
- package/dist/js/deprecated/components/Table/base/package.json +1 -1
- package/dist/js/deprecated/components/Table/package.json +1 -1
- package/dist/js/deprecated/components/package.json +1 -1
- package/dist/js/deprecated/package.json +1 -1
- package/dist/js/package.json +1 -1
- package/dist/umd/react-table.min.js +3 -3
- package/package.json +3 -3
- package/src/docs/demos/table-demos/ExpandCollapseAll.jsx +88 -106
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.119",
|
|
4
4
|
"description": "This library provides a set of React table components for use with the PatternFly 4",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"subpaths": "node scripts/createSubpaths.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@patternfly/react-core": "^5.0.0-alpha.
|
|
43
|
+
"@patternfly/react-core": "^5.0.0-alpha.116",
|
|
44
44
|
"@patternfly/react-icons": "^5.0.0-alpha.19",
|
|
45
45
|
"@patternfly/react-styles": "^5.0.0-alpha.16",
|
|
46
46
|
"@patternfly/react-tokens": "^5.0.0-alpha.14",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react": "^17 || ^18",
|
|
56
56
|
"react-dom": "^17 || ^18"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "26ffe379333044d711d36be0066f889caca1ed89"
|
|
59
59
|
}
|
|
@@ -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
|
+
};
|