@patternfly/react-table 5.0.0-alpha.97 → 5.0.0-alpha.98

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": "5.0.0-alpha.97",
3
+ "version": "5.0.0-alpha.98",
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.95",
43
+ "@patternfly/react-core": "^5.0.0-alpha.96",
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": "90ba49c9bb04467b5482738c8102546ad70c662f"
58
+ "gitHead": "88e143dc1df5a48525453a2038c495f9ee5b8f62"
59
59
  }
@@ -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--palette--blue-50)'
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;
@@ -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 as TableDeprecated, TableHeader, TableBody } from '@patternfly/react-table/deprecated';
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
- columns: [
1119
- { title: 'Servers' },
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="westford" itemId="Westford">Westford</SelectOption>,
1264
+ <SelectOption key="san francisco" itemId="San Francisco">San Francisco</SelectOption>,
1295
1265
  <SelectOption key="boston" itemId="Boston">Boston</SelectOption>,
1296
- <SelectOption key="brno" itemId="Brno">Brno</SelectOption>,
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 Maintainence"
1337
- isSelected={filters.status.includes("Needs Maintainence")}
1305
+ itemId="Needs maintenance"
1306
+ isSelected={filters.status.includes("Needs maintenance")}
1338
1307
  >
1339
- Needs Maintainence
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, rows, columns, filters } = this.state;
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.cells[0].toLowerCase().includes(name.toLowerCase()))) &&
1461
- (filters.location.length === 0 || filters.location.includes(row.cells[5])) &&
1462
- (filters.status.length === 0 || filters.status.includes(row.cells[4]))
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
- const onSelect = loading || filteredRows.length === 0 ? null : this.onRowSelect; // To remove the select box when there are no rows
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
- <TableDeprecated cells={columns} rows={tableRows} onSelect={onSelect} aria-label="Filterable Table Demo">
1527
- <TableHeader />
1528
- <TableBody />
1529
- </TableDeprecated>
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 as TableDeprecated, TableHeader, TableBody } from '@patternfly/react-table/deprecated';
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 = [{ title: 'First column' }, { title: 'Second column' }, { title: 'Third column' }];
1573
+ this.columns = {
1574
+ firstColumn: 'First column',
1575
+ secondColumn: 'Second column',
1576
+ thirdColumn: 'Third column'
1577
+ },
1562
1578
  this.defaultRows = [
1563
- { cells: [{ title: 'Row 1 column 1' }, { title: 'Row 1 column 2' }, { title: 'Row 1 column 3' }] },
1564
- { cells: [{ title: 'Row 2 column 1' }, { title: 'Row 2 column 2' }, { title: 'Row 2 column 3' }] },
1565
- { cells: [{ title: 'Row 3 column 1' }, { title: 'Row 3 column 2' }, { title: 'Row 3 column 3' }] },
1566
- { cells: [{ title: 'Row 4 column 1' }, { title: 'Row 4 column 2' }, { title: 'Row 4 column 3' }] },
1567
- { cells: [{ title: 'Row 5 column 1' }, { title: 'Row 5 column 2' }, { title: 'Row 5 column 3' }] },
1568
- { cells: [{ title: 'Row 6 column 1' }, { title: 'Row 6 column 2' }, { title: 'Row 6 column 3' }] },
1569
- { cells: [{ title: 'Row 7 column 1' }, { title: 'Row 7 column 2' }, { title: 'Row 7 column 3' }] },
1570
- { cells: [{ title: 'Row 8 column 1' }, { title: 'Row 8 column 2' }, { title: 'Row 8 column 3' }] },
1571
- { cells: [{ title: 'Row 9 column 1' }, { title: 'Row 9 column 2' }, { title: 'Row 9 column 3' }] },
1572
- { cells: [{ title: 'Row 10 column 1' }, { title: 'Row 10 column 2' }, { title: 'Row 10 column 3' }] },
1573
- { cells: [{ title: 'Row 11 column 1' }, { title: 'Row 11 column 2' }, { title: 'Row 11 column 3' }] },
1574
- { cells: [{ title: 'Row 12 column 1' }, { title: 'Row 12 column 2' }, { title: 'Row 12 column 3' }] }
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
- <TableDeprecated aria-label="Automated pagination table" cells={this.columns} rows={rows}>
1631
- <TableHeader />
1632
- <TableBody />
1633
- </TableDeprecated>
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 Maintenance':
1693
+ case 'Needs maintenance':
1663
1694
  return <Label color="blue">{labelText}</Label>;
1664
1695
  case 'Down':
1665
1696
  return <Label color="red">{labelText}</Label>;