@patternfly/react-table 5.0.0-alpha.97 → 5.0.0-alpha.99
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 +12 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/esm/components/Table/RowWrapper.js +2 -2
- package/dist/esm/components/Table/Table.js +2 -2
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/TableTypes.d.ts +1 -1
- package/dist/esm/components/Table/Tr.d.ts +3 -3
- package/dist/esm/components/Table/Tr.d.ts.map +1 -1
- package/dist/esm/components/Table/Tr.js +3 -3
- package/dist/esm/components/Table/Tr.js.map +1 -1
- package/dist/esm/components/Table/base/provider.d.ts +2 -2
- package/dist/esm/components/Table/base/types.d.ts +2 -2
- package/dist/js/components/Table/RowWrapper.js +2 -2
- package/dist/js/components/Table/Table.js +2 -2
- package/dist/js/components/Table/Table.js.map +1 -1
- package/dist/js/components/Table/TableTypes.d.ts +1 -1
- package/dist/js/components/Table/Tr.d.ts +3 -3
- package/dist/js/components/Table/Tr.d.ts.map +1 -1
- package/dist/js/components/Table/Tr.js +3 -3
- package/dist/js/components/Table/Tr.js.map +1 -1
- package/dist/js/components/Table/base/provider.d.ts +2 -2
- package/dist/js/components/Table/base/types.d.ts +2 -2
- 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 +1 -1
- package/package.json +3 -3
- package/src/components/Table/RowWrapper.tsx +2 -2
- package/src/components/Table/Table.tsx +2 -2
- package/src/components/Table/TableTypes.tsx +1 -1
- package/src/components/Table/Tr.tsx +6 -6
- package/src/components/Table/examples/Table.md +2 -2
- package/src/components/Table/examples/{TableHoverable.tsx → TableClickable.tsx} +3 -3
- package/src/components/Table/examples/TableMisc.tsx +1 -1
- package/src/deprecated/components/Table/examples/{LegacyTableHoverable.tsx → LegacyTableClickable.tsx} +2 -2
- package/src/deprecated/components/Table/examples/Table.md +2 -2
- package/src/docs/demos/Table.md +115 -84
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.99",
|
|
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.97",
|
|
44
44
|
"@patternfly/react-icons": "^5.0.0-alpha.14",
|
|
45
45
|
"@patternfly/react-styles": "^5.0.0-alpha.10",
|
|
46
46
|
"@patternfly/react-tokens": "^5.0.0-alpha.9",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react": "^17 || ^18",
|
|
56
56
|
"react-dom": "^17 || ^18"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "2f2eb377c744647e34d557e1550ae7a01f87f5a6"
|
|
59
59
|
}
|
|
@@ -94,7 +94,7 @@ export class RowWrapper extends React.Component<RowWrapperProps> {
|
|
|
94
94
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
95
95
|
onScroll,
|
|
96
96
|
onResize,
|
|
97
|
-
row: { isExpanded, isEditable,
|
|
97
|
+
row: { isExpanded, isEditable, isClickable, isRowSelected },
|
|
98
98
|
rowProps,
|
|
99
99
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
100
100
|
trRef,
|
|
@@ -111,7 +111,7 @@ export class RowWrapper extends React.Component<RowWrapperProps> {
|
|
|
111
111
|
isEditable={isEditable}
|
|
112
112
|
className={className}
|
|
113
113
|
ouiaId={ouiaId}
|
|
114
|
-
|
|
114
|
+
isClickable={isClickable}
|
|
115
115
|
isRowSelected={isRowSelected}
|
|
116
116
|
/>
|
|
117
117
|
);
|
|
@@ -121,7 +121,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
121
121
|
setTableCaption(
|
|
122
122
|
<caption>
|
|
123
123
|
{selectableRowCaptionText}
|
|
124
|
-
<div className="pf-screen-reader">
|
|
124
|
+
<div className="pf-v5-screen-reader">
|
|
125
125
|
This table has selectable rows. It can be navigated by row using tab, and each row can be selected using
|
|
126
126
|
space or enter.
|
|
127
127
|
</div>
|
|
@@ -129,7 +129,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
|
|
|
129
129
|
);
|
|
130
130
|
} else {
|
|
131
131
|
setTableCaption(
|
|
132
|
-
<caption className="pf-screen-reader">
|
|
132
|
+
<caption className="pf-v5-screen-reader">
|
|
133
133
|
This table has selectable rows. It can be navigated by row using tab, and each row can be selected using space
|
|
134
134
|
or enter.
|
|
135
135
|
</caption>
|
|
@@ -238,7 +238,7 @@ export interface IRow extends RowType {
|
|
|
238
238
|
cells?: (React.ReactNode | IRowCell)[];
|
|
239
239
|
isOpen?: boolean;
|
|
240
240
|
isEditable?: boolean;
|
|
241
|
-
|
|
241
|
+
isClickable?: boolean;
|
|
242
242
|
isRowSelected?: boolean;
|
|
243
243
|
isValid?: boolean;
|
|
244
244
|
/** An array of validation functions to run against every cell for a given row */
|
|
@@ -20,8 +20,8 @@ export interface TrProps extends React.HTMLProps<HTMLTableRowElement>, OUIAProps
|
|
|
20
20
|
isExpanded?: boolean;
|
|
21
21
|
/** Only applicable to Tr within the Tbody: Whether the row is editable */
|
|
22
22
|
isEditable?: boolean;
|
|
23
|
-
/** Flag which adds hover styles for the table row */
|
|
24
|
-
|
|
23
|
+
/** Flag which adds hover styles for the clickable table row */
|
|
24
|
+
isClickable?: boolean;
|
|
25
25
|
/** Flag indicating the row is selected - adds selected styling */
|
|
26
26
|
isRowSelected?: boolean;
|
|
27
27
|
/** Flag indicating the row is striped */
|
|
@@ -46,7 +46,7 @@ const TrBase: React.FunctionComponent<TrProps> = ({
|
|
|
46
46
|
isExpanded,
|
|
47
47
|
isEditable,
|
|
48
48
|
isHidden = false,
|
|
49
|
-
|
|
49
|
+
isClickable = false,
|
|
50
50
|
isRowSelected = false,
|
|
51
51
|
isStriped = false,
|
|
52
52
|
isBorderRow = false,
|
|
@@ -89,21 +89,21 @@ const TrBase: React.FunctionComponent<TrProps> = ({
|
|
|
89
89
|
|
|
90
90
|
return (
|
|
91
91
|
<>
|
|
92
|
-
{isSelectable && <output className="pf-screen-reader">{ariaLabel}</output>}
|
|
92
|
+
{isSelectable && <output className="pf-v5-screen-reader">{ariaLabel}</output>}
|
|
93
93
|
<tr
|
|
94
94
|
className={css(
|
|
95
95
|
className,
|
|
96
96
|
isExpanded !== undefined && styles.tableExpandableRow,
|
|
97
97
|
isExpanded && styles.modifiers.expanded,
|
|
98
98
|
isEditable && inlineStyles.modifiers.inlineEditable,
|
|
99
|
-
|
|
99
|
+
isClickable && styles.modifiers.clickable,
|
|
100
100
|
isRowSelected && styles.modifiers.selected,
|
|
101
101
|
isStriped && styles.modifiers.striped,
|
|
102
102
|
isBorderRow && styles.modifiers.borderRow,
|
|
103
103
|
resetOffset && styles.modifiers.firstCellOffsetReset
|
|
104
104
|
)}
|
|
105
105
|
hidden={rowIsHidden}
|
|
106
|
-
{...(
|
|
106
|
+
{...(isClickable && { tabIndex: 0 })}
|
|
107
107
|
aria-label={ariaLabel}
|
|
108
108
|
ref={innerRef}
|
|
109
109
|
{...(onRowClick && { onClick: onRowClick, onKeyDown })}
|
|
@@ -147,11 +147,11 @@ Similarly to the selectable example above, the radio buttons use the first colum
|
|
|
147
147
|
```ts file="TableSelectableRadio.tsx"
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
### Row click handler,
|
|
150
|
+
### Row click handler, clickable rows
|
|
151
151
|
|
|
152
152
|
This selectable rows feature is intended for use when a table is used to present a list of objects in a Primary-detail view.
|
|
153
153
|
|
|
154
|
-
```ts file="
|
|
154
|
+
```ts file="TableClickable.tsx"
|
|
155
155
|
```
|
|
156
156
|
|
|
157
157
|
### Actions
|
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableClickable: React.FunctionComponent = () => {
|
|
13
13
|
// In real usage, this data would come from some external source like an API via props.
|
|
14
14
|
const repositories: Repository[] = [
|
|
15
15
|
{ name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' },
|
|
@@ -30,7 +30,7 @@ export const TableHoverable: React.FunctionComponent = () => {
|
|
|
30
30
|
const [selectedRepoName, setSelectedRepoName] = React.useState('');
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<Table aria-label="
|
|
33
|
+
<Table aria-label="Clickable table">
|
|
34
34
|
<Thead>
|
|
35
35
|
<Tr>
|
|
36
36
|
<Th>{columnNames.name}</Th>
|
|
@@ -46,7 +46,7 @@ export const TableHoverable: React.FunctionComponent = () => {
|
|
|
46
46
|
key={repo.name}
|
|
47
47
|
onRowClick={() => setSelectedRepoName(repo.name)}
|
|
48
48
|
isSelectable
|
|
49
|
-
|
|
49
|
+
isClickable
|
|
50
50
|
isRowSelected={selectedRepoName === repo.name}
|
|
51
51
|
>
|
|
52
52
|
<Td dataLabel={columnNames.name}>{repo.name}</Td>
|
|
@@ -65,7 +65,7 @@ export const TableMisc: React.FunctionComponent = () => {
|
|
|
65
65
|
{repositories.map((repo, rowIndex) => {
|
|
66
66
|
const isOddRow = (rowIndex + 1) % 2;
|
|
67
67
|
const customStyle = {
|
|
68
|
-
backgroundColor: 'var(--pf-v5-global--
|
|
68
|
+
backgroundColor: 'var(--pf-v5-global--BackgroundColor--150)'
|
|
69
69
|
};
|
|
70
70
|
// Some arbitrary logic to demonstrate that cell styles can be based on anything
|
|
71
71
|
const nameColSpan = repo.branches === null && repo.prs === null ? 3 : 1;
|
|
@@ -11,7 +11,7 @@ interface Repository {
|
|
|
11
11
|
lastCommit: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const
|
|
14
|
+
export const LegacyTableClickable: React.FunctionComponent = () => {
|
|
15
15
|
// In real usage, this data would come from some external source like an API via props.
|
|
16
16
|
const repositories: Repository[] = [
|
|
17
17
|
{
|
|
@@ -98,7 +98,7 @@ export const LegacyTableHoverable: React.FunctionComponent = () => {
|
|
|
98
98
|
}
|
|
99
99
|
return {
|
|
100
100
|
cells,
|
|
101
|
-
|
|
101
|
+
isClickable: true,
|
|
102
102
|
isRowSelected: selectedRepoName === repo.name
|
|
103
103
|
};
|
|
104
104
|
});
|
|
@@ -205,11 +205,11 @@ To disable selection for a row, set `disableSelection: true` on the row definiti
|
|
|
205
205
|
```ts file="LegacyTableSelectableRadio.tsx"
|
|
206
206
|
```
|
|
207
207
|
|
|
208
|
-
###
|
|
208
|
+
### Clickable rows, selectable rows, and header cell tooltips/popovers
|
|
209
209
|
|
|
210
210
|
This selectable rows feature is intended for use when a table is used to present a list of objects in a Primary-detail view.
|
|
211
211
|
|
|
212
|
-
```ts file="
|
|
212
|
+
```ts file="LegacyTableClickable.tsx"
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
### Actions and first cell in body rows as th
|
package/src/docs/demos/Table.md
CHANGED
|
@@ -1076,11 +1076,21 @@ class ColumnManagementAction extends React.Component {
|
|
|
1076
1076
|
|
|
1077
1077
|
### Filterable
|
|
1078
1078
|
|
|
1079
|
-
```js
|
|
1079
|
+
```js isFullscreen
|
|
1080
1080
|
import React from 'react';
|
|
1081
1081
|
import {
|
|
1082
|
+
Badge,
|
|
1082
1083
|
Button,
|
|
1083
1084
|
Bullseye,
|
|
1085
|
+
EmptyState,
|
|
1086
|
+
EmptyStateActions,
|
|
1087
|
+
EmptyStateBody,
|
|
1088
|
+
EmptyStateIcon,
|
|
1089
|
+
EmptyStateHeader,
|
|
1090
|
+
EmptyStateFooter,
|
|
1091
|
+
Label,
|
|
1092
|
+
MenuToggle,
|
|
1093
|
+
MenuToggleElement,
|
|
1084
1094
|
Toolbar,
|
|
1085
1095
|
ToolbarItem,
|
|
1086
1096
|
ToolbarContent,
|
|
@@ -1090,17 +1100,12 @@ import {
|
|
|
1090
1100
|
Title,
|
|
1091
1101
|
Select,
|
|
1092
1102
|
SelectOption,
|
|
1093
|
-
SearchInput
|
|
1094
|
-
EmptyState,
|
|
1095
|
-
EmptyStateActions,
|
|
1096
|
-
EmptyStateBody,
|
|
1097
|
-
EmptyStateIcon,
|
|
1098
|
-
EmptyStateHeader,
|
|
1099
|
-
EmptyStateFooter
|
|
1103
|
+
SearchInput
|
|
1100
1104
|
} from '@patternfly/react-core';
|
|
1101
1105
|
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
1102
1106
|
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
1103
|
-
import { Table
|
|
1107
|
+
import { Table, TableText, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
1108
|
+
import { rows, columns } from '../../examples/Data.jsx';
|
|
1104
1109
|
|
|
1105
1110
|
class FilterTableDemo extends React.Component {
|
|
1106
1111
|
constructor(props) {
|
|
@@ -1115,27 +1120,8 @@ class FilterTableDemo extends React.Component {
|
|
|
1115
1120
|
isFilterDropdownOpen: false,
|
|
1116
1121
|
isCategoryDropdownOpen: false,
|
|
1117
1122
|
nameInput: '',
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
{ title: 'Threads' },
|
|
1121
|
-
{ title: 'Applications' },
|
|
1122
|
-
{ title: 'Workspaces' },
|
|
1123
|
-
{ title: 'Status' },
|
|
1124
|
-
{ title: 'Location' }
|
|
1125
|
-
],
|
|
1126
|
-
rows: [
|
|
1127
|
-
{ cells: ['US-Node 1', '5', '25', '5', 'Stopped', 'Raleigh'] },
|
|
1128
|
-
{ cells: ['US-Node 2', '5', '30', '2', 'Down', 'Westford'] },
|
|
1129
|
-
{ cells: ['US-Node 3', '13', '35', '12', 'Degraded', 'Boston'] },
|
|
1130
|
-
{ cells: ['US-Node 4', '2', '5', '18', 'Needs Maintainence', 'Raleigh'] },
|
|
1131
|
-
{ cells: ['US-Node 5', '7', '30', '5', 'Running', 'Boston'] },
|
|
1132
|
-
{ cells: ['US-Node 6', '5', '20', '15', 'Stopped', 'Raleigh'] },
|
|
1133
|
-
{ cells: ['CZ-Node 1', '12', '48', '13', 'Down', 'Brno'] },
|
|
1134
|
-
{ cells: ['CZ-Node 2', '3', '8', '20', 'Running', 'Brno'] },
|
|
1135
|
-
{ cells: ['CZ-Remote-Node 1', '15', '20', '10', 'Down', 'Brno'] },
|
|
1136
|
-
{ cells: ['Bangalore-Node 1', '20', '30', '30', 'Running', 'Bangalore'] }
|
|
1137
|
-
],
|
|
1138
|
-
inputValue: ''
|
|
1123
|
+
inputValue: '',
|
|
1124
|
+
rows: rows.slice(0, 10)
|
|
1139
1125
|
};
|
|
1140
1126
|
|
|
1141
1127
|
this.onDelete = (type = '', id = '') => {
|
|
@@ -1186,22 +1172,6 @@ class FilterTableDemo extends React.Component {
|
|
|
1186
1172
|
this.setState({ inputValue: newValue });
|
|
1187
1173
|
};
|
|
1188
1174
|
|
|
1189
|
-
this.onRowSelect = (event, isSelected, rowId) => {
|
|
1190
|
-
let rows;
|
|
1191
|
-
if (rowId === -1) {
|
|
1192
|
-
rows = this.state.rows.map((oneRow) => {
|
|
1193
|
-
oneRow.selected = isSelected;
|
|
1194
|
-
return oneRow;
|
|
1195
|
-
});
|
|
1196
|
-
} else {
|
|
1197
|
-
rows = [...this.state.rows];
|
|
1198
|
-
rows[rowId].selected = isSelected;
|
|
1199
|
-
}
|
|
1200
|
-
this.setState({
|
|
1201
|
-
rows
|
|
1202
|
-
});
|
|
1203
|
-
};
|
|
1204
|
-
|
|
1205
1175
|
this.onStatusSelect = (event, selection) => {
|
|
1206
1176
|
const checked = event.target.checked;
|
|
1207
1177
|
this.setState((prevState) => {
|
|
@@ -1291,10 +1261,9 @@ class FilterTableDemo extends React.Component {
|
|
|
1291
1261
|
|
|
1292
1262
|
const locationMenuItems = [
|
|
1293
1263
|
<SelectOption key="raleigh" itemId="Raleigh">Raleigh</SelectOption>,
|
|
1294
|
-
<SelectOption key="
|
|
1264
|
+
<SelectOption key="san francisco" itemId="San Francisco">San Francisco</SelectOption>,
|
|
1295
1265
|
<SelectOption key="boston" itemId="Boston">Boston</SelectOption>,
|
|
1296
|
-
<SelectOption key="
|
|
1297
|
-
<SelectOption key="bangalore" itemId="Bangalore">Bangalore</SelectOption>
|
|
1266
|
+
<SelectOption key="atlanta" itemId="Atlanta">Atlanta</SelectOption>,
|
|
1298
1267
|
];
|
|
1299
1268
|
|
|
1300
1269
|
const statusMenuItems = [
|
|
@@ -1333,10 +1302,10 @@ class FilterTableDemo extends React.Component {
|
|
|
1333
1302
|
<SelectOption
|
|
1334
1303
|
hasCheckbox
|
|
1335
1304
|
key="statusMaint"
|
|
1336
|
-
itemId="Needs
|
|
1337
|
-
isSelected={filters.status.includes("Needs
|
|
1305
|
+
itemId="Needs maintenance"
|
|
1306
|
+
isSelected={filters.status.includes("Needs maintenance")}
|
|
1338
1307
|
>
|
|
1339
|
-
Needs
|
|
1308
|
+
Needs maintenance
|
|
1340
1309
|
</SelectOption>
|
|
1341
1310
|
];
|
|
1342
1311
|
|
|
@@ -1402,7 +1371,6 @@ class FilterTableDemo extends React.Component {
|
|
|
1402
1371
|
minWidth="100px"
|
|
1403
1372
|
onSelect={this.onStatusSelect}
|
|
1404
1373
|
selected={filters.status}
|
|
1405
|
-
minWidth="200px"
|
|
1406
1374
|
toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
|
|
1407
1375
|
<MenuToggle
|
|
1408
1376
|
ref={toggleRef}
|
|
@@ -1428,7 +1396,6 @@ class FilterTableDemo extends React.Component {
|
|
|
1428
1396
|
}
|
|
1429
1397
|
|
|
1430
1398
|
renderToolbar() {
|
|
1431
|
-
const { filters } = this.state;
|
|
1432
1399
|
return (
|
|
1433
1400
|
<Toolbar id="toolbar-with-chip-groups" clearAllFilters={this.onDelete} collapseListedFiltersBreakpoint="xl">
|
|
1434
1401
|
<ToolbarContent>
|
|
@@ -1450,16 +1417,16 @@ class FilterTableDemo extends React.Component {
|
|
|
1450
1417
|
}
|
|
1451
1418
|
|
|
1452
1419
|
render() {
|
|
1453
|
-
const { loading,
|
|
1420
|
+
const { loading, filters, rows } = this.state;
|
|
1454
1421
|
|
|
1455
1422
|
const filteredRows =
|
|
1456
1423
|
filters.name.length > 0 || filters.location.length > 0 || filters.status.length > 0
|
|
1457
1424
|
? rows.filter((row) => {
|
|
1458
1425
|
return (
|
|
1459
1426
|
(filters.name.length === 0 ||
|
|
1460
|
-
filters.name.some((name) => row.
|
|
1461
|
-
(filters.location.length === 0 || filters.location.includes(row.
|
|
1462
|
-
(filters.status.length === 0 || filters.status.includes(row.
|
|
1427
|
+
filters.name.some((name) => row.name.toLowerCase().includes(name.toLowerCase()))) &&
|
|
1428
|
+
(filters.location.length === 0 || filters.location.includes(row.location)) &&
|
|
1429
|
+
(filters.status.length === 0 || filters.status.includes(row.status))
|
|
1463
1430
|
);
|
|
1464
1431
|
})
|
|
1465
1432
|
: rows;
|
|
@@ -1519,14 +1486,59 @@ class FilterTableDemo extends React.Component {
|
|
|
1519
1486
|
}
|
|
1520
1487
|
];
|
|
1521
1488
|
}
|
|
1522
|
-
|
|
1489
|
+
|
|
1490
|
+
const renderLabel = labelText => {
|
|
1491
|
+
switch (labelText) {
|
|
1492
|
+
case 'Running':
|
|
1493
|
+
return <Label color="green">{labelText}</Label>;
|
|
1494
|
+
case 'Stopped':
|
|
1495
|
+
return <Label color="orange">{labelText}</Label>;
|
|
1496
|
+
case 'Needs maintenance':
|
|
1497
|
+
return <Label color="blue">{labelText}</Label>;
|
|
1498
|
+
case 'Down':
|
|
1499
|
+
return <Label color="red">{labelText}</Label>;
|
|
1500
|
+
}
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1523
1503
|
return (
|
|
1524
1504
|
<React.Fragment>
|
|
1525
1505
|
{this.renderToolbar()}
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1506
|
+
<Table aria-label="Filterable Table Demo">
|
|
1507
|
+
<Thead>
|
|
1508
|
+
<Tr>
|
|
1509
|
+
<Th key={0}>{columns[0]}</Th>
|
|
1510
|
+
<Th key={1}>{columns[1]}</Th>
|
|
1511
|
+
<Th key={2}>{columns[2]}</Th>
|
|
1512
|
+
<Th key={3}>{columns[3]}</Th>
|
|
1513
|
+
<Th key={4}>{columns[4]}</Th>
|
|
1514
|
+
<Th key={5}>{columns[5]}</Th>
|
|
1515
|
+
<Th key={6}>{columns[6]}</Th>
|
|
1516
|
+
<Th key={7} width={10}>
|
|
1517
|
+
{columns[7]}
|
|
1518
|
+
</Th>
|
|
1519
|
+
</Tr>
|
|
1520
|
+
</Thead>
|
|
1521
|
+
<Tbody>
|
|
1522
|
+
{filteredRows.slice(0, 10).map((row, rowIndex) => (
|
|
1523
|
+
<Tr key={rowIndex}>
|
|
1524
|
+
<>
|
|
1525
|
+
<Td dataLabel={columns[0]}>{row.name}</Td>
|
|
1526
|
+
<Td dataLabel={columns[1]}>{row.threads}</Td>
|
|
1527
|
+
<Td dataLabel={columns[2]}>{row.applications}</Td>
|
|
1528
|
+
<Td dataLabel={columns[3]}>{row.workspaces}</Td>
|
|
1529
|
+
<Td dataLabel={columns[4]}>{renderLabel(row.status)}</Td>
|
|
1530
|
+
<Td dataLabel={columns[5]}>{row.location}</Td>
|
|
1531
|
+
<Td dataLabel={columns[6]}>{row.lastModified}</Td>
|
|
1532
|
+
<Td dataLabel={columns[7]} modifier="truncate">
|
|
1533
|
+
<TableText>
|
|
1534
|
+
<a href="#">{row.url}</a>
|
|
1535
|
+
</TableText>
|
|
1536
|
+
</Td>
|
|
1537
|
+
</>
|
|
1538
|
+
</Tr>
|
|
1539
|
+
))}
|
|
1540
|
+
</Tbody>
|
|
1541
|
+
</Table>
|
|
1530
1542
|
</React.Fragment>
|
|
1531
1543
|
);
|
|
1532
1544
|
}
|
|
@@ -1550,28 +1562,32 @@ To demonstrate this, navigate to the last page of data below using the `>>` navi
|
|
|
1550
1562
|
- The default behavior would show the last page of results, which would only contain the last two rows (rows 11 - 12).
|
|
1551
1563
|
- The `isLastFullPageShown` prop navigates you back to the previous page which does contain a full page of 5 rows (rows 6 - 10).
|
|
1552
1564
|
|
|
1553
|
-
```js
|
|
1565
|
+
```js isFullscreen
|
|
1554
1566
|
import React from 'react';
|
|
1555
1567
|
import { Pagination } from '@patternfly/react-core';
|
|
1556
|
-
import { Table
|
|
1568
|
+
import { Table, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
1557
1569
|
|
|
1558
1570
|
class ComplexPaginationTableDemo extends React.Component {
|
|
1559
1571
|
constructor(props) {
|
|
1560
1572
|
super(props);
|
|
1561
|
-
this.columns =
|
|
1573
|
+
this.columns = {
|
|
1574
|
+
firstColumn: 'First column',
|
|
1575
|
+
secondColumn: 'Second column',
|
|
1576
|
+
thirdColumn: 'Third column'
|
|
1577
|
+
},
|
|
1562
1578
|
this.defaultRows = [
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1579
|
+
{ firstColumn: 'Row 1 column 1', secondColumn: 'Row 1 column 2', thirdColumn: 'Row 1 column 3' },
|
|
1580
|
+
{ firstColumn: 'Row 2 column 1', secondColumn: 'Row 2 column 2', thirdColumn: 'Row 2 column 3' },
|
|
1581
|
+
{ firstColumn: 'Row 3 column 1', secondColumn: 'Row 3 column 2', thirdColumn: 'Row 3 column 3' },
|
|
1582
|
+
{ firstColumn: 'Row 4 column 1', secondColumn: 'Row 4 column 2', thirdColumn: 'Row 4 column 3' },
|
|
1583
|
+
{ firstColumn: 'Row 5 column 1', secondColumn: 'Row 5 column 2', thirdColumn: 'Row 5 column 3' },
|
|
1584
|
+
{ firstColumn: 'Row 6 column 1', secondColumn: 'Row 6 column 2', thirdColumn: 'Row 6 column 3' },
|
|
1585
|
+
{ firstColumn: 'Row 7 column 1', secondColumn: 'Row 7 column 2', thirdColumn: 'Row 7 column 3' },
|
|
1586
|
+
{ firstColumn: 'Row 8 column 1', secondColumn: 'Row 8 column 2', thirdColumn: 'Row 8 column 3' },
|
|
1587
|
+
{ firstColumn: 'Row 9 column 1', secondColumn: 'Row 9 column 2', thirdColumn: 'Row 9 column 3' },
|
|
1588
|
+
{ firstColumn: 'Row 10 column 1', secondColumn: 'Row 10 column 2', thirdColumn: 'Row 10 column 3' },
|
|
1589
|
+
{ firstColumn: 'Row 11 column 1', secondColumn: 'Row 11 column 2', thirdColumn: 'Row 11 column 3' },
|
|
1590
|
+
{ firstColumn: 'Row 12 column 1', secondColumn: 'Row 12 column 2', thirdColumn: 'Row 12 column 3' }
|
|
1575
1591
|
];
|
|
1576
1592
|
this.defaultPerPage = 10;
|
|
1577
1593
|
this.state = {
|
|
@@ -1623,14 +1639,29 @@ class ComplexPaginationTableDemo extends React.Component {
|
|
|
1623
1639
|
}
|
|
1624
1640
|
|
|
1625
1641
|
render() {
|
|
1626
|
-
const rows = this.state.rows.map((row) => ({ cells: row.cells }));
|
|
1627
1642
|
return (
|
|
1628
1643
|
<React.Fragment>
|
|
1629
1644
|
{this.renderPagination()}
|
|
1630
|
-
<
|
|
1631
|
-
<
|
|
1632
|
-
|
|
1633
|
-
|
|
1645
|
+
<Table aria-label="Automated Pagination Table Demo">
|
|
1646
|
+
<Thead>
|
|
1647
|
+
<Tr>
|
|
1648
|
+
<Th>{this.columns.firstColumn}</Th>
|
|
1649
|
+
<Th>{this.columns.secondColumn}</Th>
|
|
1650
|
+
<Th>{this.columns.thirdColumn}</Th>
|
|
1651
|
+
</Tr>
|
|
1652
|
+
</Thead>
|
|
1653
|
+
<Tbody>
|
|
1654
|
+
{this.state.rows.map((row, rowIndex) => (
|
|
1655
|
+
<Tr key={rowIndex}>
|
|
1656
|
+
<>
|
|
1657
|
+
<Td dataLabel={this.columns.firstColumn}>{row.firstColumn}</Td>
|
|
1658
|
+
<Td dataLabel={this.columns.secondColumn}>{row.secondColumn}</Td>
|
|
1659
|
+
<Td dataLabel={this.columns.thirdColumn}>{row.thirdColumn}</Td>
|
|
1660
|
+
</>
|
|
1661
|
+
</Tr>
|
|
1662
|
+
))}
|
|
1663
|
+
</Tbody>
|
|
1664
|
+
</Table>
|
|
1634
1665
|
</React.Fragment>
|
|
1635
1666
|
);
|
|
1636
1667
|
}
|
|
@@ -1659,7 +1690,7 @@ class StickyHeaderTableDemo extends React.Component {
|
|
|
1659
1690
|
return <Label color="green">{labelText}</Label>;
|
|
1660
1691
|
case 'Stopped':
|
|
1661
1692
|
return <Label color="orange">{labelText}</Label>;
|
|
1662
|
-
case 'Needs
|
|
1693
|
+
case 'Needs maintenance':
|
|
1663
1694
|
return <Label color="blue">{labelText}</Label>;
|
|
1664
1695
|
case 'Down':
|
|
1665
1696
|
return <Label color="red">{labelText}</Label>;
|