@patternfly/react-table 4.105.9 → 4.105.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-table",
3
- "version": "4.105.9",
3
+ "version": "4.105.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.236.9",
35
- "@patternfly/react-icons": "^4.87.9",
36
- "@patternfly/react-styles": "^4.86.9",
37
- "@patternfly/react-tokens": "^4.88.9",
34
+ "@patternfly/react-core": "^4.236.12",
35
+ "@patternfly/react-icons": "^4.87.12",
36
+ "@patternfly/react-styles": "^4.86.12",
37
+ "@patternfly/react-tokens": "^4.88.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": "af946599c755b320f313aa394a460c31ddf000c9"
49
+ "gitHead": "ef7593c96a44bb5c01f44c79d05ac667ada3b575"
50
50
  }
@@ -302,17 +302,17 @@ class BulkSelectTableDemo extends React.Component {
302
302
 
303
303
  ### Expand/collapse all
304
304
 
305
- ```js isFullscreen file="table-demos/ExpandCollapseAll.jsx"
305
+ ```js isFullscreen file="./table-demos/ExpandCollapseAll.jsx"
306
306
  ```
307
307
 
308
308
  ### Compact
309
309
 
310
- ```js isFullscreen file="table-demos/Compact.jsx"
310
+ ```js isFullscreen file="./table-demos/Compact.jsx"
311
311
  ```
312
312
 
313
313
  ### Compound expansion
314
314
 
315
- ```js isFullscreen file="table-demos/CompoundExpansion.jsx"
315
+ ```js isFullscreen file="./table-demos/CompoundExpansion.jsx"
316
316
  ```
317
317
 
318
318
  ### Column management
@@ -2852,7 +2852,7 @@ class StickyHeaderTableDemo extends React.Component {
2852
2852
 
2853
2853
  ### Sticky first column
2854
2854
 
2855
- ```js isFullscreen file="table-demos/StickyFirstColumn.jsx"
2855
+ ```js isFullscreen file="./table-demos/StickyFirstColumn.jsx"
2856
2856
  ```
2857
2857
 
2858
2858
  ### Sticky columns and header with toolbar
@@ -12,41 +12,35 @@ import {
12
12
  SelectOption,
13
13
  PageSection
14
14
  } from '@patternfly/react-core';
15
- import { TableComposable, Thead, Tr, Th, Tbody, Td, ActionsColumn } from '@patternfly/react-table';
15
+ import { TableComposable, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
16
16
 
17
17
  import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
18
- import CheckIcon from '@patternfly/react-icons/dist/esm/icons/check-icon';
19
18
  import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper';
19
+ import { rows, columns } from '../../examples/Data.jsx';
20
20
 
21
- export const ComposableTable = () => {
21
+ export const CompactTable = () => {
22
22
  const [isSelectOpen, setIsSelectOpen] = React.useState(false);
23
+ const [page, setPage] = React.useState(1);
24
+ const [perPage, setPerPage] = React.useState(10);
25
+ const [paginatedRows, setPaginatedRows] = React.useState(rows.slice(0, 10));
26
+ const handleSetPage = (_evt, newPage, perPage, startIdx, endIdx) => {
27
+ setPaginatedRows(rows.slice(startIdx, endIdx));
28
+ setPage(newPage);
29
+ };
30
+ handlePerPageSelect = (_evt, newPerPage, newPage, startIdx, endIdx) => {
31
+ setPaginatedRows(rows.slice(startIdx, endIdx));
32
+ setPage(newPage);
33
+ setPerPage(newPerPage);
34
+ };
23
35
 
24
- const columns = ['Contributor', 'Position', 'Location', 'Last seen', 'Numbers', 'Icons'];
25
- const rows = [
26
- ['Sam Jones', 'CSS guru', 'Not too sure', 'May 9, 2018', '0556'],
27
- ['Amy Miller', 'Visual design', 'Raleigh', 'May 9, 2018', '9492'],
28
- ['Steve Wilson', 'Visual design lead', 'Westford', 'May 9, 2018', '9929'],
29
- ['Emma Jackson', 'Interaction design', 'Westford', 'May 9, 2018', '2217']
30
- ];
31
-
32
- const defaultActions = () => [
33
- {
34
- title: 'Settings',
35
- // eslint-disable-next-line no-console
36
- onClick: () => console.log(`clicked on Settings`)
37
- },
38
- {
39
- title: 'Help',
40
- // eslint-disable-next-line no-console
41
- onClick: () => console.log(`clicked on Help`)
42
- }
43
- ];
44
36
  const renderPagination = (variant, isCompact) => (
45
37
  <Pagination
46
38
  isCompact={isCompact}
47
- itemCount={36}
48
- page={1}
49
- perPage={10}
39
+ itemCount={rows.length}
40
+ page={page}
41
+ perPage={perPage}
42
+ onSetPage={handleSetPage}
43
+ onPerPageSelect={handlePerPageSelect}
50
44
  variant={variant}
51
45
  titles={{
52
46
  paginationTitle: `${variant} pagination`
@@ -89,37 +83,54 @@ export const ComposableTable = () => {
89
83
  </Toolbar>
90
84
  );
91
85
 
86
+ const renderLabel = labelText => {
87
+ switch (labelText) {
88
+ case 'Running':
89
+ return <Label color="green">{labelText}</Label>;
90
+ case 'Stopped':
91
+ return <Label color="orange">{labelText}</Label>;
92
+ case 'Needs Maintenance':
93
+ return <Label color="blue">{labelText}</Label>;
94
+ case 'Down':
95
+ return <Label color="red">{labelText}</Label>;
96
+ }
97
+ };
92
98
  return (
93
99
  <React.Fragment>
94
100
  <DashboardWrapper hasPageTemplateTitle>
95
101
  <PageSection isFilled>
96
102
  <Card>
97
103
  {tableToolbar}
98
- <TableComposable variant="compact" aria-label="Sortable Table">
104
+ <TableComposable variant="compact" aria-label="Compact Table">
99
105
  <Thead>
100
106
  <Tr>
101
- {columns.map((column, columnIndex) => (
102
- <Th key={columnIndex}>{column}</Th>
103
- ))}
107
+ <Th key={0}>{columns[0]}</Th>
108
+ <Th key={1}>{columns[1]}</Th>
109
+ <Th key={2}>{columns[2]}</Th>
110
+ <Th key={3}>{columns[3]}</Th>
111
+ <Th key={4}>{columns[4]}</Th>
112
+ <Th key={5}>{columns[5]}</Th>
113
+ <Th key={6}>{columns[6]}</Th>
114
+ <Th key={7} width={10}>
115
+ {columns[7]}
116
+ </Th>
104
117
  </Tr>
105
118
  </Thead>
106
119
  <Tbody>
107
- {rows.map((row, rowIndex) => (
120
+ {paginatedRows.map((row, rowIndex) => (
108
121
  <Tr key={rowIndex}>
109
122
  <>
110
- <Td dataLabel={columns[0]}>{row[0]}</Td>
111
- <Td dataLabel={columns[1]}>{row[1]}</Td>
112
- <Td dataLabel={columns[2]}>{row[2]}</Td>
113
- <Td dataLabel={columns[3]}>{row[3]}</Td>
114
- <Td dataLabel={columns[4]}>{row[4]}</Td>
115
- <Td dataLabel={columns[5]}>
116
- <CheckIcon key="icon" />
117
- </Td>
118
- <Td dataLabel={'Action'}>
119
- <a href="#">Action link</a>
120
- </Td>
121
- <Td isActionCell>
122
- <ActionsColumn items={defaultActions()} />
123
+ <Td dataLabel={columns[0]}>{row.name}</Td>
124
+ <Td dataLabel={columns[1]}>{row.threads}</Td>
125
+ <Td dataLabel={columns[2]}>{row.applications}</Td>
126
+ <Td dataLabel={columns[3]}>{row.workspaces}</Td>
127
+ <Td dataLabel={columns[4]}>{renderLabel(row.status)}</Td>
128
+ <Td dataLabel={columns[5]}>{row.location}</Td>
129
+ <Td dataLabel={columns[6]}>{row.lastModified}</Td>
130
+ <Td dataLabel={columns[7]} modifier="truncate">
131
+ <TableText>
132
+ <a href="#">{row.url}</a>
133
+ </TableText>
123
134
  </Td>
124
135
  </>
125
136
  </Tr>
@@ -1,6 +1,3 @@
1
- /* eslint-disable no-console */
2
- import * as React from 'react';
3
-
4
1
  const getRandomInteger = (min, max) => (
5
2
  Math.floor(Math.random() * (max - min + 1)) + min
6
3
  );
@@ -737,7 +734,8 @@ export const rows = [
737
734
  lastModified: '20 minutes ago',
738
735
  url: 'http://www.redhat.com/en/office-locations/Bangalore-node13'
739
736
  },
740
- { name: 'Bangalore-Node 14',
737
+ {
738
+ name: 'Bangalore-Node 14',
741
739
  threads: getRandomInteger(1, 20),
742
740
  applications: getRandomInteger(1, 50),
743
741
  workspaces: getRandomInteger(1, 30),
@@ -746,7 +744,8 @@ export const rows = [
746
744
  lastModified: '4 hours ago',
747
745
  url: 'http://www.redhat.com/en/office-locations/Bangalore-node14'
748
746
  },
749
- { name: 'Bangalore-Node 15',
747
+ {
748
+ name: 'Bangalore-Node 15',
750
749
  threads: getRandomInteger(1, 20),
751
750
  applications: getRandomInteger(1, 50),
752
751
  workspaces: getRandomInteger(1, 30),