@patternfly/react-table 4.101.9 → 4.101.12
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 +24 -0
- package/dist/umd/react-table.css +377 -377
- package/dist/umd/react-table.js +11810 -437
- package/dist/umd/react-table.min.css +768 -768
- package/dist/umd/react-table.min.js +21 -6
- package/package.json +6 -6
- package/src/demos/Table.md +30 -3
- package/src/demos/examples/ComposableTableStickyToolbar.tsx +252 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "4.101.
|
|
3
|
+
"version": "4.101.12",
|
|
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.232.
|
|
35
|
-
"@patternfly/react-icons": "^4.83.
|
|
36
|
-
"@patternfly/react-styles": "^4.82.
|
|
37
|
-
"@patternfly/react-tokens": "^4.84.
|
|
34
|
+
"@patternfly/react-core": "^4.232.12",
|
|
35
|
+
"@patternfly/react-icons": "^4.83.12",
|
|
36
|
+
"@patternfly/react-styles": "^4.82.12",
|
|
37
|
+
"@patternfly/react-tokens": "^4.84.12",
|
|
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": "f78c7a0fe58401bb6a9e3b380067a98af76cf523"
|
|
50
50
|
}
|
package/src/demos/Table.md
CHANGED
|
@@ -3,7 +3,26 @@ id: Table
|
|
|
3
3
|
section: components
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Checkbox,
|
|
8
|
+
PageSection,
|
|
9
|
+
ToolbarExpandIconWrapper,
|
|
10
|
+
ToolbarContent,
|
|
11
|
+
Toolbar,
|
|
12
|
+
ToolbarItem,
|
|
13
|
+
SearchInput,
|
|
14
|
+
Masthead,
|
|
15
|
+
MastheadToggle,
|
|
16
|
+
MastheadMain,
|
|
17
|
+
MastheadContent,
|
|
18
|
+
SkipToContent,
|
|
19
|
+
Breadcrumb,
|
|
20
|
+
BreadcrumbItem,
|
|
21
|
+
Page,
|
|
22
|
+
PageSectionVariants,
|
|
23
|
+
TextContent,
|
|
24
|
+
Text,
|
|
25
|
+
Divider } from '@patternfly/react-core';
|
|
7
26
|
import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';
|
|
8
27
|
import CloneIcon from '@patternfly/react-icons/dist/esm/icons/clone-icon';
|
|
9
28
|
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
|
|
@@ -26,6 +45,7 @@ import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-i
|
|
|
26
45
|
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
27
46
|
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
28
47
|
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
48
|
+
import BlueprintIcon from '@patternfly/react-icons/dist/esm/icons/blueprint-icon';
|
|
29
49
|
|
|
30
50
|
## Demos
|
|
31
51
|
|
|
@@ -1889,7 +1909,7 @@ class FilterTableDemo extends React.Component {
|
|
|
1889
1909
|
const categoryMenuItems = [
|
|
1890
1910
|
<SelectOption key="cat1" value="Location" />,
|
|
1891
1911
|
<SelectOption key="cat2" value="Name" />,
|
|
1892
|
-
<SelectOption key="cat3" value="Status"
|
|
1912
|
+
<SelectOption key="cat3" value="Status" />
|
|
1893
1913
|
];
|
|
1894
1914
|
|
|
1895
1915
|
return (
|
|
@@ -2346,7 +2366,7 @@ ComposableTableSortable = () => {
|
|
|
2346
2366
|
}
|
|
2347
2367
|
isPlain
|
|
2348
2368
|
isGrouped
|
|
2349
|
-
menuAppendTo=
|
|
2369
|
+
menuAppendTo="parent"
|
|
2350
2370
|
isFlipEnabled
|
|
2351
2371
|
/>
|
|
2352
2372
|
</ToolbarItem>
|
|
@@ -3002,6 +3022,13 @@ class PageLayoutDefaultNav extends React.Component {
|
|
|
3002
3022
|
```js isFullscreen file="table-demos/StickyFirstColumn.jsx"
|
|
3003
3023
|
```
|
|
3004
3024
|
|
|
3025
|
+
### Sticky columns and header with toolbar
|
|
3026
|
+
|
|
3027
|
+
A toolbar may be added above a sticky table either inside or outside the `OuterScrollContainer`.
|
|
3028
|
+
|
|
3029
|
+
```ts isFullscreen file="examples/ComposableTableStickyToolbar.tsx"
|
|
3030
|
+
```
|
|
3031
|
+
|
|
3005
3032
|
## Empty states
|
|
3006
3033
|
|
|
3007
3034
|
These examples demonstrate the use of an [Empty State component](/components/empty-state) inside of a [Table](/components/table). Empty states are useful in a table when a filter returns no results, while data is loading, or when any type of error or exception condition occurs.
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
TableComposable,
|
|
4
|
+
Thead,
|
|
5
|
+
Tr,
|
|
6
|
+
Th,
|
|
7
|
+
Tbody,
|
|
8
|
+
Td,
|
|
9
|
+
InnerScrollContainer,
|
|
10
|
+
OuterScrollContainer,
|
|
11
|
+
ThProps
|
|
12
|
+
} from '@patternfly/react-table';
|
|
13
|
+
import {
|
|
14
|
+
Toolbar,
|
|
15
|
+
ToolbarContent,
|
|
16
|
+
ToolbarItem,
|
|
17
|
+
PageSection,
|
|
18
|
+
SearchInput,
|
|
19
|
+
Masthead,
|
|
20
|
+
MastheadToggle,
|
|
21
|
+
MastheadMain,
|
|
22
|
+
MastheadContent,
|
|
23
|
+
SkipToContent,
|
|
24
|
+
Breadcrumb,
|
|
25
|
+
BreadcrumbItem,
|
|
26
|
+
Page,
|
|
27
|
+
PageSectionVariants,
|
|
28
|
+
TextContent,
|
|
29
|
+
Text,
|
|
30
|
+
Divider
|
|
31
|
+
} from '@patternfly/react-core';
|
|
32
|
+
import BlueprintIcon from '@patternfly/react-icons/dist/esm/icons/blueprint-icon';
|
|
33
|
+
|
|
34
|
+
interface Fact {
|
|
35
|
+
name: string;
|
|
36
|
+
state: string;
|
|
37
|
+
detail1: string;
|
|
38
|
+
detail2: string;
|
|
39
|
+
detail3: string;
|
|
40
|
+
detail4: string;
|
|
41
|
+
detail5: string;
|
|
42
|
+
detail6: string;
|
|
43
|
+
detail7: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const ComposableTableStickyColumnsAndHeader: React.FunctionComponent = () => {
|
|
47
|
+
// In real usage, this data would come from some external source like an API via props.
|
|
48
|
+
const facts: Fact[] = Array.from({ length: 25 }, (_, index) => ({
|
|
49
|
+
name: `Fact ${index + 1}`,
|
|
50
|
+
state: `State ${index + 1}`,
|
|
51
|
+
detail1: `Test cell ${index + 1}-3`,
|
|
52
|
+
detail2: `Test cell ${index + 1}-4`,
|
|
53
|
+
detail3: `Test cell ${index + 1}-5`,
|
|
54
|
+
detail4: `Test cell ${index + 1}-6`,
|
|
55
|
+
detail5: `Test cell ${index + 1}-7`,
|
|
56
|
+
detail6: `Test cell ${index + 1}-8`,
|
|
57
|
+
detail7: `Test cell ${index + 1}-9`
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
const columnNames = {
|
|
61
|
+
name: 'Fact',
|
|
62
|
+
state: 'State',
|
|
63
|
+
header3: 'Header 3',
|
|
64
|
+
header4: 'Header 4',
|
|
65
|
+
header5: 'Header 5',
|
|
66
|
+
header6: 'Header 6',
|
|
67
|
+
header7: 'Header 7',
|
|
68
|
+
header8: 'Header 8',
|
|
69
|
+
header9: 'Header 9'
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Index of the currently sorted column
|
|
73
|
+
// Note: if you intend to make columns reorderable, you may instead want to use a non-numeric key
|
|
74
|
+
// as the identifier of the sorted column. See the "Compound expandable" example.
|
|
75
|
+
const [activeSortIndex, setActiveSortIndex] = React.useState<number | null>(null);
|
|
76
|
+
|
|
77
|
+
// Sort direction of the currently sorted column
|
|
78
|
+
const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc' | null>(null);
|
|
79
|
+
|
|
80
|
+
// Since OnSort specifies sorted columns by index, we need sortable values for our object by column index.
|
|
81
|
+
// This example is trivial since our data objects just contain strings, but if the data was more complex
|
|
82
|
+
// this would be a place to return simplified string or number versions of each column to sort by.
|
|
83
|
+
const getSortableRowValues = (fact: Fact): (string | number)[] => {
|
|
84
|
+
const { name, state, detail1, detail2, detail3, detail4, detail5, detail6, detail7 } = fact;
|
|
85
|
+
return [name, state, detail1, detail2, detail3, detail4, detail5, detail6, detail7];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Note that we perform the sort as part of the component's render logic and not in onSort.
|
|
89
|
+
// We shouldn't store the list of data in state because we don't want to have to sync that with props.
|
|
90
|
+
let sortedFacts = facts;
|
|
91
|
+
if (activeSortIndex !== null) {
|
|
92
|
+
sortedFacts = facts.sort((a, b) => {
|
|
93
|
+
const aValue = getSortableRowValues(a)[activeSortIndex];
|
|
94
|
+
const bValue = getSortableRowValues(b)[activeSortIndex];
|
|
95
|
+
if (aValue === bValue) {
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
if (activeSortDirection === 'asc') {
|
|
99
|
+
return aValue > bValue ? 1 : -1;
|
|
100
|
+
} else {
|
|
101
|
+
return bValue > aValue ? 1 : -1;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const getSortParams = (columnIndex: number): ThProps['sort'] => ({
|
|
107
|
+
sortBy: {
|
|
108
|
+
index: activeSortIndex,
|
|
109
|
+
direction: activeSortDirection
|
|
110
|
+
},
|
|
111
|
+
onSort: (_event, index, direction) => {
|
|
112
|
+
setActiveSortIndex(index);
|
|
113
|
+
setActiveSortDirection(direction);
|
|
114
|
+
},
|
|
115
|
+
columnIndex
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const Header = (
|
|
119
|
+
<Masthead>
|
|
120
|
+
<MastheadToggle>Masthead</MastheadToggle>
|
|
121
|
+
<MastheadMain></MastheadMain>
|
|
122
|
+
<MastheadContent>header-tools</MastheadContent>
|
|
123
|
+
</Masthead>
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
const pageId = 'main-content-page-layout-tertiary-nav';
|
|
127
|
+
const PageSkipToContent = <SkipToContent href={`#${pageId}`}>Skip to content</SkipToContent>;
|
|
128
|
+
|
|
129
|
+
const PageBreadcrumb = (
|
|
130
|
+
<Breadcrumb>
|
|
131
|
+
<BreadcrumbItem>Section home</BreadcrumbItem>
|
|
132
|
+
<BreadcrumbItem to="#">Section title</BreadcrumbItem>
|
|
133
|
+
<BreadcrumbItem to="#">Section title</BreadcrumbItem>
|
|
134
|
+
<BreadcrumbItem to="#" isActive>
|
|
135
|
+
Section landing
|
|
136
|
+
</BreadcrumbItem>
|
|
137
|
+
</Breadcrumb>
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const toolbar = (
|
|
141
|
+
<Toolbar>
|
|
142
|
+
<ToolbarContent>
|
|
143
|
+
<ToolbarItem variant="search-filter">
|
|
144
|
+
<SearchInput aria-label="search input example" onChange={() => {}} value="test toolbar" onClear={() => {}} />
|
|
145
|
+
</ToolbarItem>
|
|
146
|
+
</ToolbarContent>
|
|
147
|
+
</Toolbar>
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<Page
|
|
152
|
+
header={Header}
|
|
153
|
+
breadcrumb={PageBreadcrumb}
|
|
154
|
+
isManagedSidebar
|
|
155
|
+
skipToContent={PageSkipToContent}
|
|
156
|
+
mainContainerId={pageId}
|
|
157
|
+
isTertiaryNavGrouped
|
|
158
|
+
isBreadcrumbGrouped
|
|
159
|
+
additionalGroupedContent={
|
|
160
|
+
<PageSection variant={PageSectionVariants.light}>
|
|
161
|
+
<TextContent>
|
|
162
|
+
<Text component="h1">Main title</Text>
|
|
163
|
+
<Text component="p">
|
|
164
|
+
Body text should be Overpass Regular at 16px. It should have leading of 24px because <br />
|
|
165
|
+
of its relative line height of 1.5.
|
|
166
|
+
</Text>
|
|
167
|
+
</TextContent>
|
|
168
|
+
</PageSection>
|
|
169
|
+
}
|
|
170
|
+
groupProps={{
|
|
171
|
+
sticky: 'top'
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
<PageSection hasOverflowScroll>
|
|
175
|
+
<div style={{ height: '500px' }}>
|
|
176
|
+
<OuterScrollContainer>
|
|
177
|
+
{toolbar}
|
|
178
|
+
<Divider />
|
|
179
|
+
<InnerScrollContainer>
|
|
180
|
+
<TableComposable aria-label="Sticky columns and header table" gridBreakPoint="" isStickyHeader>
|
|
181
|
+
<Thead>
|
|
182
|
+
<Tr>
|
|
183
|
+
<Th isStickyColumn modifier="truncate" sort={getSortParams(0)}>
|
|
184
|
+
{columnNames.name}
|
|
185
|
+
</Th>
|
|
186
|
+
<Th
|
|
187
|
+
isStickyColumn
|
|
188
|
+
stickyMinWidth="120px"
|
|
189
|
+
stickyLeftOffset="120px"
|
|
190
|
+
hasRightBorder
|
|
191
|
+
modifier="truncate"
|
|
192
|
+
sort={getSortParams(1)}
|
|
193
|
+
>
|
|
194
|
+
{columnNames.state}
|
|
195
|
+
</Th>
|
|
196
|
+
<Th modifier="truncate">{columnNames.header3}</Th>
|
|
197
|
+
<Th modifier="truncate">{columnNames.header4}</Th>
|
|
198
|
+
<Th modifier="truncate">{columnNames.header5}</Th>
|
|
199
|
+
<Th modifier="truncate">{columnNames.header6}</Th>
|
|
200
|
+
<Th modifier="truncate">{columnNames.header7}</Th>
|
|
201
|
+
<Th modifier="truncate">{columnNames.header8}</Th>
|
|
202
|
+
<Th modifier="truncate">{columnNames.header9}</Th>
|
|
203
|
+
</Tr>
|
|
204
|
+
</Thead>
|
|
205
|
+
<Tbody>
|
|
206
|
+
{sortedFacts.map(fact => (
|
|
207
|
+
<Tr key={fact.name}>
|
|
208
|
+
<Th isStickyColumn modifier="truncate">
|
|
209
|
+
{fact.name}
|
|
210
|
+
</Th>
|
|
211
|
+
<Th
|
|
212
|
+
isStickyColumn
|
|
213
|
+
stickyMinWidth="120px"
|
|
214
|
+
stickyLeftOffset="120px"
|
|
215
|
+
modifier="truncate"
|
|
216
|
+
hasRightBorder
|
|
217
|
+
>
|
|
218
|
+
<BlueprintIcon />
|
|
219
|
+
{` ${fact.state}`}
|
|
220
|
+
</Th>
|
|
221
|
+
<Td modifier="nowrap" dataLabel={columnNames.header3}>
|
|
222
|
+
{fact.detail1}
|
|
223
|
+
</Td>
|
|
224
|
+
<Td modifier="nowrap" dataLabel={columnNames.header4}>
|
|
225
|
+
{fact.detail2}
|
|
226
|
+
</Td>
|
|
227
|
+
<Td modifier="nowrap" dataLabel={columnNames.header5}>
|
|
228
|
+
{fact.detail3}
|
|
229
|
+
</Td>
|
|
230
|
+
<Td modifier="nowrap" dataLabel={columnNames.header6}>
|
|
231
|
+
{fact.detail4}
|
|
232
|
+
</Td>
|
|
233
|
+
<Td modifier="nowrap" dataLabel={columnNames.header7}>
|
|
234
|
+
{fact.detail5}
|
|
235
|
+
</Td>
|
|
236
|
+
<Td modifier="nowrap" dataLabel={columnNames.header8}>
|
|
237
|
+
{fact.detail6}
|
|
238
|
+
</Td>
|
|
239
|
+
<Td modifier="nowrap" dataLabel={columnNames.header9}>
|
|
240
|
+
{fact.detail7}
|
|
241
|
+
</Td>
|
|
242
|
+
</Tr>
|
|
243
|
+
))}
|
|
244
|
+
</Tbody>
|
|
245
|
+
</TableComposable>
|
|
246
|
+
</InnerScrollContainer>
|
|
247
|
+
</OuterScrollContainer>
|
|
248
|
+
</div>
|
|
249
|
+
</PageSection>
|
|
250
|
+
</Page>
|
|
251
|
+
);
|
|
252
|
+
};
|