@patternfly/react-table 4.96.7 → 4.97.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.96.7",
3
+ "version": "4.97.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.227.7",
35
- "@patternfly/react-icons": "^4.78.7",
36
- "@patternfly/react-styles": "^4.77.7",
37
- "@patternfly/react-tokens": "^4.79.7",
34
+ "@patternfly/react-core": "^4.228.0",
35
+ "@patternfly/react-icons": "^4.79.0",
36
+ "@patternfly/react-styles": "^4.78.0",
37
+ "@patternfly/react-tokens": "^4.80.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": "86dc74f93f58bd72ce6ac164e9bda25422494ca0"
49
+ "gitHead": "f02b0e0e72ea0aa326e1d512b1da0397b10e7f9a"
50
50
  }
@@ -32,14 +32,7 @@ export const LegacyTableHoverable: React.FunctionComponent = () => {
32
32
 
33
33
  // In this example, selected rows are tracked by the repo names from each row. This could be any unique identifier.
34
34
  // This is to prevent state from being based on row order index in case we later add sorting.
35
- const [selectedRepoNames, setSelectedRepoNames] = React.useState<string[]>([]);
36
- const setRepoSelected = (repo: Repository, isSelecting = true) =>
37
- setSelectedRepoNames(prevSelected => {
38
- const otherSelectedRepoNames = prevSelected.filter(r => r !== repo.name);
39
- return isSelecting ? [...otherSelectedRepoNames, repo.name] : otherSelectedRepoNames;
40
- });
41
- const isRepoSelected = (repo: Repository) => selectedRepoNames.includes(repo.name);
42
-
35
+ const [selectedRepoName, setSelectedRepoName] = React.useState('');
43
36
  const columns: TableProps['cells'] = [
44
37
  {
45
38
  title: 'Repositories',
@@ -105,7 +98,7 @@ export const LegacyTableHoverable: React.FunctionComponent = () => {
105
98
  return {
106
99
  cells,
107
100
  isHoverable: true,
108
- isRowSelected: isRepoSelected(repo)
101
+ isRowSelected: selectedRepoName === repo.name
109
102
  };
110
103
  });
111
104
 
@@ -116,7 +109,7 @@ export const LegacyTableHoverable: React.FunctionComponent = () => {
116
109
  onRowClick={(_event, row, rowProps) => {
117
110
  if (rowProps) {
118
111
  const repo = repositories[rowProps.rowIndex];
119
- setRepoSelected(repo, !isRepoSelected(repo));
112
+ setSelectedRepoName(repo.name);
120
113
  }
121
114
  }}
122
115
  />
@@ -74,7 +74,7 @@ const TrBase: React.FunctionComponent<TrProps> = ({
74
74
 
75
75
  React.useEffect(() => {
76
76
  if (isSelectable && !rowIsHidden) {
77
- setComputedAriaLabel(`${isRowSelected ? 'Selected' : 'Unselected'}, selectable row.`);
77
+ setComputedAriaLabel(`${isRowSelected ? 'Row selected' : ''}`);
78
78
  registerSelectableRow();
79
79
  } else {
80
80
  setComputedAriaLabel(undefined);
@@ -27,13 +27,7 @@ export const ComposableTableHoverable: React.FunctionComponent = () => {
27
27
 
28
28
  // In this example, selected rows are tracked by the repo names from each row. This could be any unique identifier.
29
29
  // This is to prevent state from being based on row order index in case we later add sorting.
30
- const [selectedRepoNames, setSelectedRepoNames] = React.useState<string[]>([]);
31
- const setRepoSelected = (repo: Repository, isSelecting = true) =>
32
- setSelectedRepoNames(prevSelected => {
33
- const otherSelectedRepoNames = prevSelected.filter(r => r !== repo.name);
34
- return isSelecting ? [...otherSelectedRepoNames, repo.name] : otherSelectedRepoNames;
35
- });
36
- const isRepoSelected = (repo: Repository) => selectedRepoNames.includes(repo.name);
30
+ const [selectedRepoName, setSelectedRepoName] = React.useState('');
37
31
 
38
32
  return (
39
33
  <TableComposable aria-label="Hoverable table" hasSelectableRowCaption>
@@ -50,10 +44,10 @@ export const ComposableTableHoverable: React.FunctionComponent = () => {
50
44
  {repositories.map(repo => (
51
45
  <Tr
52
46
  key={repo.name}
53
- onRowClick={() => setRepoSelected(repo, !isRepoSelected(repo))}
47
+ onRowClick={() => setSelectedRepoName(repo.name)}
54
48
  isSelectable
55
49
  isHoverable
56
- isRowSelected={isRepoSelected(repo)}
50
+ isRowSelected={selectedRepoName === repo.name}
57
51
  >
58
52
  <Td dataLabel={columnNames.name}>{repo.name}</Td>
59
53
  <Td dataLabel={columnNames.branches}>{repo.branches}</Td>