@patternfly/react-table 4.102.0 → 4.103.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/esm/components/Table/RowWrapper.d.ts +1 -0
- package/dist/esm/components/Table/RowWrapper.d.ts.map +1 -1
- package/dist/esm/components/Table/RowWrapper.js.map +1 -1
- package/dist/js/components/Table/RowWrapper.d.ts +1 -0
- package/dist/js/components/Table/RowWrapper.d.ts.map +1 -1
- package/dist/js/components/Table/RowWrapper.js.map +1 -1
- package/dist/umd/react-table.css +129 -83
- package/dist/umd/react-table.js +28 -3
- package/dist/umd/react-table.min.css +1067 -1021
- package/dist/umd/react-table.min.js +4 -4
- package/package.json +6 -6
- package/src/components/Table/RowWrapper.tsx +1 -0
- package/src/{demos → docs/demos}/Table.md +1 -1
- package/src/{demos → docs/demos}/table-demos/Compact.jsx +0 -0
- package/src/{demos → docs/demos}/table-demos/CompoundExpansion.jsx +0 -0
- package/src/docs/demos/table-demos/ExpandCollapseAll.jsx +219 -0
- package/src/{demos → docs/demos}/table-demos/StickyFirstColumn.jsx +0 -0
- package/src/{demos → docs}/examples/ComposableTableStickyToolbar.tsx +0 -0
- package/src/docs/examples/Data.jsx +768 -0
- package/src/demos/table-demos/ExpandCollapseAll.jsx +0 -152
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.103.1",
|
|
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",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"clean": "rimraf dist"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@patternfly/react-core": "^4.
|
|
35
|
-
"@patternfly/react-icons": "^4.
|
|
36
|
-
"@patternfly/react-styles": "^4.
|
|
37
|
-
"@patternfly/react-tokens": "^4.
|
|
34
|
+
"@patternfly/react-core": "^4.234.1",
|
|
35
|
+
"@patternfly/react-icons": "^4.85.1",
|
|
36
|
+
"@patternfly/react-styles": "^4.84.1",
|
|
37
|
+
"@patternfly/react-tokens": "^4.86.1",
|
|
38
38
|
"lodash": "^4.17.19",
|
|
39
39
|
"tslib": "^2.0.0"
|
|
40
40
|
},
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"react": "^16.8.0 || ^17.0.0",
|
|
47
47
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "5ed44df6faaf77aae464836238b7f90a0c2fa8cb"
|
|
50
50
|
}
|
|
@@ -3026,7 +3026,7 @@ class PageLayoutDefaultNav extends React.Component {
|
|
|
3026
3026
|
|
|
3027
3027
|
A toolbar may be added above a sticky table either inside or outside the `OuterScrollContainer`.
|
|
3028
3028
|
|
|
3029
|
-
```ts isFullscreen file="examples/ComposableTableStickyToolbar.tsx"
|
|
3029
|
+
```ts isFullscreen file="../examples/ComposableTableStickyToolbar.tsx"
|
|
3030
3030
|
```
|
|
3031
3031
|
|
|
3032
3032
|
## Empty states
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Card, Label, PageSection, Table, TableHeader, TableBody, expandable } from '@patternfly/react-table';
|
|
3
|
+
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
4
|
+
import { TextVariants } from '@patternfly/react-core';
|
|
5
|
+
|
|
6
|
+
const columns = [
|
|
7
|
+
{
|
|
8
|
+
title: 'Servers',
|
|
9
|
+
cellFormatters: [expandable]
|
|
10
|
+
},
|
|
11
|
+
'Threads',
|
|
12
|
+
'Applications',
|
|
13
|
+
'Workspaces',
|
|
14
|
+
'Status'
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const serverData = [
|
|
18
|
+
{
|
|
19
|
+
name: 'US-Node 1',
|
|
20
|
+
threads: 18,
|
|
21
|
+
applications: 42,
|
|
22
|
+
workspaces: 7,
|
|
23
|
+
status: { title: <Label color="orange">Stopped</Label> },
|
|
24
|
+
details: (
|
|
25
|
+
<TextContent>
|
|
26
|
+
<Text component={TextVariants.p}>
|
|
27
|
+
Location<Text component={TextVariants.small}>Boston</Text>
|
|
28
|
+
</Text>
|
|
29
|
+
<Text component={TextVariants.p}>
|
|
30
|
+
Last Modified<Text component={TextVariants.small}>2 hours ago</Text>
|
|
31
|
+
</Text>
|
|
32
|
+
<Text component={TextVariants.p}>
|
|
33
|
+
URL<Text component={TextVariants.small}>http://www.redhat.com/en/office-locations/US-node1</Text>
|
|
34
|
+
</Text>
|
|
35
|
+
</TextContent>
|
|
36
|
+
)
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'US-Node 2',
|
|
40
|
+
threads: 9,
|
|
41
|
+
applications: 24,
|
|
42
|
+
workspaces: 17,
|
|
43
|
+
status: { title: <Label color="red">Down</Label> },
|
|
44
|
+
details: (
|
|
45
|
+
<TextContent>
|
|
46
|
+
<Text component={TextVariants.p}>
|
|
47
|
+
Location<Text component={TextVariants.small}>Atlanta</Text>
|
|
48
|
+
</Text>
|
|
49
|
+
<Text component={TextVariants.p}>
|
|
50
|
+
Last Modified<Text component={TextVariants.small}>5 hours ago</Text>
|
|
51
|
+
</Text>
|
|
52
|
+
<Text component={TextVariants.p}>
|
|
53
|
+
URL<Text component={TextVariants.small}>http://www.redhat.com/en/office-locations/US-node2</Text>
|
|
54
|
+
</Text>
|
|
55
|
+
</TextContent>
|
|
56
|
+
)
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'US-Node 3',
|
|
60
|
+
threads: 8,
|
|
61
|
+
applications: 47,
|
|
62
|
+
workspaces: 3,
|
|
63
|
+
status: { title: <Label color="green">Running</Label> },
|
|
64
|
+
details: (
|
|
65
|
+
<TextContent>
|
|
66
|
+
<Text component={TextVariants.p}>
|
|
67
|
+
Location<Text component={TextVariants.small}>San Francisco</Text>
|
|
68
|
+
</Text>
|
|
69
|
+
<Text component={TextVariants.p}>
|
|
70
|
+
Last Modified<Text component={TextVariants.small}>20 minutes ago</Text>
|
|
71
|
+
</Text>
|
|
72
|
+
<Text component={TextVariants.p}>
|
|
73
|
+
URL<Text component={TextVariants.small}>http://www.redhat.com/en/office-locations/US-node3</Text>
|
|
74
|
+
</Text>
|
|
75
|
+
</TextContent>
|
|
76
|
+
)
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'US-Node 4',
|
|
80
|
+
threads: 6,
|
|
81
|
+
applications: 4,
|
|
82
|
+
workspaces: 15,
|
|
83
|
+
status: { title: <Label color="blue">Needs Maintenance</Label> },
|
|
84
|
+
details: (
|
|
85
|
+
<TextContent>
|
|
86
|
+
<Text component={TextVariants.p}>
|
|
87
|
+
Location<Text component={TextVariants.small}>Raleigh</Text>
|
|
88
|
+
</Text>
|
|
89
|
+
<Text component={TextVariants.p}>
|
|
90
|
+
Last Modified<Text component={TextVariants.small}>10 minutes ago</Text>
|
|
91
|
+
</Text>
|
|
92
|
+
<Text component={TextVariants.p}>
|
|
93
|
+
URL<Text component={TextVariants.small}>http://www.redhat.com/en/office-locations/US-node4</Text>
|
|
94
|
+
</Text>
|
|
95
|
+
</TextContent>
|
|
96
|
+
)
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'US-Node 5',
|
|
100
|
+
threads: 9,
|
|
101
|
+
applications: 24,
|
|
102
|
+
workspaces: 17,
|
|
103
|
+
status: { title: <Label color="orange">Stopped</Label> },
|
|
104
|
+
details: (
|
|
105
|
+
<TextContent>
|
|
106
|
+
<Text component={TextVariants.p}>
|
|
107
|
+
Location<Text component={TextVariants.small}>Atlanta</Text>
|
|
108
|
+
</Text>
|
|
109
|
+
<Text component={TextVariants.p}>
|
|
110
|
+
Last Modified<Text component={TextVariants.small}>15 minutes ago</Text>
|
|
111
|
+
</Text>
|
|
112
|
+
<Text component={TextVariants.p}>
|
|
113
|
+
URL<Text component={TextVariants.small}>http://www.redhat.com/en/office-locations/US-node5</Text>
|
|
114
|
+
</Text>
|
|
115
|
+
</TextContent>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
const initialExpandedServerNames = ['US-Node 2']; // Default to expanded
|
|
121
|
+
|
|
122
|
+
class ExpandCollapseAllTableDemo extends React.Component {
|
|
123
|
+
constructor(props) {
|
|
124
|
+
super(props);
|
|
125
|
+
this.state = {
|
|
126
|
+
isChecked: false,
|
|
127
|
+
selectedRows: 0,
|
|
128
|
+
expandedRows: 0,
|
|
129
|
+
expandCollapseToggle: 'expand',
|
|
130
|
+
collapseAllAriaLabel: 'Expand all',
|
|
131
|
+
expandedServerNames: initialExpandedServerNames
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
setServerExpanded = (server, isExpanding) => {
|
|
136
|
+
this.setState(() => {
|
|
137
|
+
const otherExpandedServerNames = this.state.expandedServerNames.filter(r => r !== server.name);
|
|
138
|
+
return {
|
|
139
|
+
expandedServerNames: isExpanding ? [...otherExpandedServerNames, server.name] : otherExpandedServerNames
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
render() {
|
|
145
|
+
const { collapseAllAriaLabel } = this.state;
|
|
146
|
+
|
|
147
|
+
const isServerExpanded = server => this.state.expandedServerNames.includes(server.name);
|
|
148
|
+
// We want to be able to reference the original data object based on row index. But because an expanded
|
|
149
|
+
// row takes up two row indexes, servers[rowIndex] will not be accurate like it would in a normal table.
|
|
150
|
+
// One solution to this is to create an array of data objects indexed by the displayed row index.
|
|
151
|
+
const serversByRowIndex = [];
|
|
152
|
+
|
|
153
|
+
const rows = [];
|
|
154
|
+
serverData.forEach(server => {
|
|
155
|
+
rows.push({
|
|
156
|
+
...{ isOpen: isServerExpanded(server) },
|
|
157
|
+
cells: [server.name, server.threads, server.applications, server.workspaces, server.status]
|
|
158
|
+
});
|
|
159
|
+
serversByRowIndex.push(server);
|
|
160
|
+
if (server.details) {
|
|
161
|
+
const cells = [];
|
|
162
|
+
|
|
163
|
+
cells.push({
|
|
164
|
+
title: server.details
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
rows.push({
|
|
168
|
+
parent: rows.length - 1,
|
|
169
|
+
cells
|
|
170
|
+
});
|
|
171
|
+
serversByRowIndex.push(null);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const onCollapse = (_e, rowIndex, isOpen) => {
|
|
176
|
+
const collapseAll = rowIndex === undefined;
|
|
177
|
+
|
|
178
|
+
if (collapseAll) {
|
|
179
|
+
this.setState(() => {
|
|
180
|
+
return {
|
|
181
|
+
expandedServerNames: isOpen ? [...serverData.map((server) => server.name)] : []
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
}
|
|
186
|
+
else if (serversByRowIndex[rowIndex]) {
|
|
187
|
+
this.setServerExpanded(serversByRowIndex[rowIndex], isOpen);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<React.Fragment>
|
|
193
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
194
|
+
<PageSection
|
|
195
|
+
padding={{
|
|
196
|
+
default: 'noPadding',
|
|
197
|
+
xl: 'padding'
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
<Card component="div">
|
|
201
|
+
<Table
|
|
202
|
+
aria-label="Collapsible table"
|
|
203
|
+
onCollapse={onCollapse}
|
|
204
|
+
rows={rows}
|
|
205
|
+
cells={columns}
|
|
206
|
+
canCollapseAll={true}
|
|
207
|
+
collapseAllAriaLabel={collapseAllAriaLabel}
|
|
208
|
+
expandId="expand-collapse-all-demo"
|
|
209
|
+
>
|
|
210
|
+
<TableHeader />
|
|
211
|
+
<TableBody />
|
|
212
|
+
</Table>
|
|
213
|
+
</Card>
|
|
214
|
+
</PageSection>
|
|
215
|
+
</DashboardWrapper>
|
|
216
|
+
</React.Fragment>
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
File without changes
|
|
File without changes
|