@patternfly/react-table 4.89.0 → 4.90.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-table",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.90.0",
|
|
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.221.0",
|
|
35
|
+
"@patternfly/react-icons": "^4.72.0",
|
|
36
|
+
"@patternfly/react-styles": "^4.71.0",
|
|
37
|
+
"@patternfly/react-tokens": "^4.73.0",
|
|
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": "1aecd4152e3be5cfa7b1fb20d9797243f050253d"
|
|
50
50
|
}
|
package/src/demos/Table.md
CHANGED
|
@@ -2978,6 +2978,11 @@ class PageLayoutDefaultNav extends React.Component {
|
|
|
2978
2978
|
}
|
|
2979
2979
|
```
|
|
2980
2980
|
|
|
2981
|
+
### Sticky first column
|
|
2982
|
+
|
|
2983
|
+
```js isFullscreen file="table-demos/StickyFirstColumn.jsx"
|
|
2984
|
+
```
|
|
2985
|
+
|
|
2981
2986
|
## Empty states
|
|
2982
2987
|
|
|
2983
2988
|
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,210 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TableComposable, Thead, Tr, Th, Tbody, Td, InnerScrollContainer } from '@patternfly/react-table';
|
|
3
|
+
import { Card, PageSection } from '@patternfly/react-core';
|
|
4
|
+
import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
|
|
5
|
+
|
|
6
|
+
export const StickyFirstColumn = () => {
|
|
7
|
+
const facts = Array.from(
|
|
8
|
+
{
|
|
9
|
+
length: 9
|
|
10
|
+
},
|
|
11
|
+
(_, index) => ({
|
|
12
|
+
name: `Fact ${index + 1}`,
|
|
13
|
+
state: `State ${index + 1}`,
|
|
14
|
+
detail1: `Test cell ${index + 1}-3`,
|
|
15
|
+
detail2: `Test cell ${index + 1}-4`,
|
|
16
|
+
detail3: `Test cell ${index + 1}-5`,
|
|
17
|
+
detail4: `Test cell ${index + 1}-6`,
|
|
18
|
+
detail5: `Test cell ${index + 1}-7`,
|
|
19
|
+
detail6: `Test cell ${index + 1}-8`,
|
|
20
|
+
detail7: `Test cell ${index + 1}-9`,
|
|
21
|
+
detail8: `Test cell ${index + 1}-10`,
|
|
22
|
+
detail9: `Test cell ${index + 1}-11`,
|
|
23
|
+
detail10: `Test cell ${index + 1}-12`,
|
|
24
|
+
detail11: `Test cell ${index + 1}-13`,
|
|
25
|
+
detail12: `Test cell ${index + 1}-14`,
|
|
26
|
+
detail13: `Test cell ${index + 1}-15`,
|
|
27
|
+
detail14: `Test cell ${index + 1}-16`
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
const columnNames = {
|
|
31
|
+
name: 'Fact',
|
|
32
|
+
state: 'State',
|
|
33
|
+
header3: 'Header 3',
|
|
34
|
+
header4: 'Header 4',
|
|
35
|
+
header5: 'Header 5',
|
|
36
|
+
header6: 'Header 6',
|
|
37
|
+
header7: 'Header 7',
|
|
38
|
+
header8: 'Header 8',
|
|
39
|
+
header9: 'Header 9',
|
|
40
|
+
header10: 'Header 10',
|
|
41
|
+
header11: 'Header 11',
|
|
42
|
+
header12: 'Header 12',
|
|
43
|
+
header13: 'Header 13',
|
|
44
|
+
header14: 'Header 14',
|
|
45
|
+
header15: 'Header 15',
|
|
46
|
+
header16: 'Header 16'
|
|
47
|
+
};
|
|
48
|
+
const [activeSortIndex, setActiveSortIndex] = React.useState(null);
|
|
49
|
+
const [activeSortDirection, setActiveSortDirection] = React.useState(null);
|
|
50
|
+
const getSortableRowValues = fact => {
|
|
51
|
+
const {
|
|
52
|
+
name,
|
|
53
|
+
state,
|
|
54
|
+
detail1,
|
|
55
|
+
detail2,
|
|
56
|
+
detail3,
|
|
57
|
+
detail4,
|
|
58
|
+
detail5,
|
|
59
|
+
detail6,
|
|
60
|
+
detail7,
|
|
61
|
+
detail8,
|
|
62
|
+
detail9,
|
|
63
|
+
detail10,
|
|
64
|
+
detail11,
|
|
65
|
+
detail12,
|
|
66
|
+
detail13,
|
|
67
|
+
detail14
|
|
68
|
+
} = fact;
|
|
69
|
+
return [
|
|
70
|
+
name,
|
|
71
|
+
state,
|
|
72
|
+
detail1,
|
|
73
|
+
detail2,
|
|
74
|
+
detail3,
|
|
75
|
+
detail4,
|
|
76
|
+
detail5,
|
|
77
|
+
detail6,
|
|
78
|
+
detail7,
|
|
79
|
+
detail8,
|
|
80
|
+
detail9,
|
|
81
|
+
detail10,
|
|
82
|
+
detail11,
|
|
83
|
+
detail12,
|
|
84
|
+
detail13,
|
|
85
|
+
detail14
|
|
86
|
+
];
|
|
87
|
+
};
|
|
88
|
+
let sortedFacts = facts;
|
|
89
|
+
if (activeSortIndex !== null) {
|
|
90
|
+
sortedFacts = facts.sort((a, b) => {
|
|
91
|
+
const aValue = getSortableRowValues(a)[activeSortIndex];
|
|
92
|
+
const bValue = getSortableRowValues(b)[activeSortIndex];
|
|
93
|
+
if (aValue === bValue) {
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
if (activeSortDirection === 'asc') {
|
|
97
|
+
return aValue > bValue ? 1 : -1;
|
|
98
|
+
} else {
|
|
99
|
+
return bValue > aValue ? 1 : -1;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const getSortParams = columnIndex => ({
|
|
104
|
+
sortBy: {
|
|
105
|
+
index: activeSortIndex,
|
|
106
|
+
direction: activeSortDirection
|
|
107
|
+
},
|
|
108
|
+
onSort: (_event, index, direction) => {
|
|
109
|
+
setActiveSortIndex(index);
|
|
110
|
+
setActiveSortDirection(direction);
|
|
111
|
+
},
|
|
112
|
+
columnIndex
|
|
113
|
+
});
|
|
114
|
+
return (
|
|
115
|
+
<DashboardWrapper hasPageTemplateTitle>
|
|
116
|
+
<PageSection isWidthLimited padding={{ default: 'noPadding', xl: 'padding' }}>
|
|
117
|
+
<Card component="div">
|
|
118
|
+
<InnerScrollContainer>
|
|
119
|
+
<TableComposable aria-label="Sticky column table" gridBreakPoint="">
|
|
120
|
+
<Thead>
|
|
121
|
+
<Tr>
|
|
122
|
+
<Th
|
|
123
|
+
isStickyColumn
|
|
124
|
+
stickyMinWidth="100px"
|
|
125
|
+
hasRightBorder
|
|
126
|
+
modifier="fitContent"
|
|
127
|
+
sort={getSortParams(0)}
|
|
128
|
+
>
|
|
129
|
+
{columnNames.name}
|
|
130
|
+
</Th>
|
|
131
|
+
<Th modifier="fitContent" sort={getSortParams(1)}>
|
|
132
|
+
{columnNames.state}
|
|
133
|
+
</Th>
|
|
134
|
+
<Th>{columnNames.header3}</Th>
|
|
135
|
+
<Th>{columnNames.header4}</Th>
|
|
136
|
+
<Th>{columnNames.header5}</Th>
|
|
137
|
+
<Th>{columnNames.header6}</Th>
|
|
138
|
+
<Th>{columnNames.header7}</Th>
|
|
139
|
+
<Th>{columnNames.header8}</Th>
|
|
140
|
+
<Th>{columnNames.header9}</Th>
|
|
141
|
+
<Th>{columnNames.header10}</Th>
|
|
142
|
+
<Th>{columnNames.header11}</Th>
|
|
143
|
+
<Th>{columnNames.header12}</Th>
|
|
144
|
+
<Th>{columnNames.header13}</Th>
|
|
145
|
+
<Th>{columnNames.header14}</Th>
|
|
146
|
+
<Th>{columnNames.header15}</Th>
|
|
147
|
+
<Th>{columnNames.header16}</Th>
|
|
148
|
+
</Tr>
|
|
149
|
+
</Thead>
|
|
150
|
+
<Tbody>
|
|
151
|
+
{sortedFacts.map(fact => (
|
|
152
|
+
<Tr key={fact.name}>
|
|
153
|
+
<Th isStickyColumn stickyMinWidth="100px" hasRightBorder modifier="truncate">
|
|
154
|
+
{fact.name}
|
|
155
|
+
</Th>
|
|
156
|
+
<Td modifier="nowrap" dataLabel={columnNames.state}>
|
|
157
|
+
{fact.state}
|
|
158
|
+
</Td>
|
|
159
|
+
<Td modifier="nowrap" dataLabel={columnNames.header3}>
|
|
160
|
+
{fact.detail1}
|
|
161
|
+
</Td>
|
|
162
|
+
<Td modifier="nowrap" dataLabel={columnNames.header4}>
|
|
163
|
+
{fact.detail2}
|
|
164
|
+
</Td>
|
|
165
|
+
<Td modifier="nowrap" dataLabel={columnNames.header5}>
|
|
166
|
+
{fact.detail3}
|
|
167
|
+
</Td>
|
|
168
|
+
<Td modifier="nowrap" dataLabel={columnNames.header6}>
|
|
169
|
+
{fact.detail4}
|
|
170
|
+
</Td>
|
|
171
|
+
<Td modifier="nowrap" dataLabel={columnNames.header7}>
|
|
172
|
+
{fact.detail5}
|
|
173
|
+
</Td>
|
|
174
|
+
<Td modifier="nowrap" dataLabel={columnNames.header8}>
|
|
175
|
+
{fact.detail6}
|
|
176
|
+
</Td>
|
|
177
|
+
<Td modifier="nowrap" dataLabel={columnNames.header9}>
|
|
178
|
+
{fact.detail7}
|
|
179
|
+
</Td>
|
|
180
|
+
<Td modifier="nowrap" dataLabel={columnNames.header10}>
|
|
181
|
+
{fact.detail8}
|
|
182
|
+
</Td>
|
|
183
|
+
<Td modifier="nowrap" dataLabel={columnNames.header11}>
|
|
184
|
+
{fact.detail9}
|
|
185
|
+
</Td>
|
|
186
|
+
<Td modifier="nowrap" dataLabel={columnNames.header12}>
|
|
187
|
+
{fact.detail10}
|
|
188
|
+
</Td>
|
|
189
|
+
<Td modifier="nowrap" dataLabel={columnNames.header13}>
|
|
190
|
+
{fact.detail11}
|
|
191
|
+
</Td>
|
|
192
|
+
<Td modifier="nowrap" dataLabel={columnNames.header14}>
|
|
193
|
+
{fact.detail12}
|
|
194
|
+
</Td>
|
|
195
|
+
<Td modifier="nowrap" dataLabel={columnNames.header15}>
|
|
196
|
+
{fact.detail13}
|
|
197
|
+
</Td>
|
|
198
|
+
<Td modifier="nowrap" dataLabel={columnNames.header16}>
|
|
199
|
+
{fact.detail14}
|
|
200
|
+
</Td>
|
|
201
|
+
</Tr>
|
|
202
|
+
))}
|
|
203
|
+
</Tbody>
|
|
204
|
+
</TableComposable>
|
|
205
|
+
</InnerScrollContainer>
|
|
206
|
+
</Card>
|
|
207
|
+
</PageSection>
|
|
208
|
+
</DashboardWrapper>
|
|
209
|
+
);
|
|
210
|
+
};
|