@patternfly/react-table 5.0.0-alpha.64 → 5.0.0-alpha.65

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/esm/components/Table/EditableSelectInputCell.d.ts +1 -1
  3. package/dist/esm/components/Table/EditableSelectInputCell.d.ts.map +1 -1
  4. package/dist/esm/components/Table/EditableSelectInputCell.js +1 -1
  5. package/dist/esm/components/Table/EditableSelectInputCell.js.map +1 -1
  6. package/dist/esm/components/Table/base/types.d.ts +1 -1
  7. package/dist/esm/components/Table/base/types.d.ts.map +1 -1
  8. package/dist/esm/components/Table/base/types.js.map +1 -1
  9. package/dist/js/components/Table/EditableSelectInputCell.d.ts +1 -1
  10. package/dist/js/components/Table/EditableSelectInputCell.d.ts.map +1 -1
  11. package/dist/js/components/Table/EditableSelectInputCell.js +1 -1
  12. package/dist/js/components/Table/EditableSelectInputCell.js.map +1 -1
  13. package/dist/js/components/Table/base/types.d.ts +1 -1
  14. package/dist/js/components/Table/base/types.d.ts.map +1 -1
  15. package/dist/js/components/Table/base/types.js +1 -1
  16. package/dist/js/components/Table/base/types.js.map +1 -1
  17. package/dist/umd/react-table.min.js +2 -2
  18. package/package.json +3 -3
  19. package/src/components/Table/EditableSelectInputCell.tsx +4 -1
  20. package/src/components/Table/base/types.tsx +4 -1
  21. package/src/components/Table/examples/TableSortableCustom.tsx +57 -40
  22. package/src/deprecated/components/Table/examples/LegacyTableSortableCustom.tsx +66 -46
  23. package/src/deprecated/components/Table/examples/Table.md +19 -7
  24. package/src/docs/demos/Table.md +123 -63
  25. package/src/docs/demos/table-demos/ColumnManagement.jsx +6 -28
  26. package/src/docs/demos/table-demos/Compact.jsx +20 -16
  27. package/src/docs/demos/table-demos/CompoundExpansion.jsx +17 -13
  28. package/src/docs/demos/table-demos/SortableResponsive.jsx +86 -80
  29. package/src/docs/demos/table-demos/StaticBottomPagination.jsx +18 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-table",
3
- "version": "5.0.0-alpha.64",
3
+ "version": "5.0.0-alpha.65",
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",
@@ -39,7 +39,7 @@
39
39
  "subpaths": "node scripts/createSubpaths.js"
40
40
  },
41
41
  "dependencies": {
42
- "@patternfly/react-core": "^5.0.0-alpha.62",
42
+ "@patternfly/react-core": "^5.0.0-alpha.63",
43
43
  "@patternfly/react-icons": "^5.0.0-alpha.10",
44
44
  "@patternfly/react-styles": "^5.0.0-alpha.6",
45
45
  "@patternfly/react-tokens": "^5.0.0-alpha.6",
@@ -54,5 +54,5 @@
54
54
  "react": "^17 || ^18",
55
55
  "react-dom": "^17 || ^18"
56
56
  },
57
- "gitHead": "d92de5c78c49b2c1e5df50821a7fdb0870cea154"
57
+ "gitHead": "729d7446d8c6769feecaa9406667d89cfbf53a9c"
58
58
  }
@@ -1,6 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { css } from '@patternfly/react-styles';
3
- import { Select, SelectOptionObject } from '@patternfly/react-core/dist/esm/components/Select';
3
+ import {
4
+ Select,
5
+ SelectOptionObject
6
+ } from '@patternfly/react-core/dist/esm/deprecated/components/Select';
4
7
  import inlineStyles from '@patternfly/react-styles/css/components/InlineEdit/inline-edit';
5
8
  import formStyles from '@patternfly/react-styles/css/components/Form/form';
6
9
  import { EditableSelectInputProps } from './base/types';
@@ -9,7 +9,10 @@ import * as React from 'react';
9
9
  import { TooltipProps } from '@patternfly/react-core/dist/esm/components/Tooltip';
10
10
  import { PopoverProps } from '@patternfly/react-core/dist/esm/components/Popover';
11
11
  import { DropdownPosition, DropdownDirection } from '@patternfly/react-core/dist/esm/deprecated/components/Dropdown';
12
- import { SelectProps, SelectOptionObject } from '@patternfly/react-core/dist/esm/components/Select';
12
+ import {
13
+ SelectOptionObject,
14
+ SelectProps
15
+ } from '@patternfly/react-core/dist/esm/deprecated/components/Select';
13
16
  import { Table } from '../Table';
14
17
  import { Thead } from '../Thead';
15
18
  import { Tbody } from '../Tbody';
@@ -3,7 +3,15 @@ import { Table, Thead, Tr, Th, Tbody, Td, ThProps } from '@patternfly/react-tabl
3
3
  import {
4
4
  Toolbar,
5
5
  ToolbarContent,
6
+ ToolbarItem,
7
+ Select,
8
+ SelectGroup,
9
+ SelectList,
10
+ SelectOption,
11
+ MenuToggle,
12
+ MenuToggleElement
6
13
  } from '@patternfly/react-core';
14
+ import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
7
15
 
8
16
  interface Repository {
9
17
  name: string;
@@ -29,6 +37,8 @@ export const TableSortableCustom: React.FunctionComponent = () => {
29
37
  lastCommit: 'Last commit'
30
38
  };
31
39
 
40
+ const [isSortDropdownOpen, setIsSortDropdownOpen] = React.useState(false);
41
+
32
42
  // Index of the currently sorted column
33
43
  // Note: if you intend to make columns reorderable, you may instead want to use a non-numeric key
34
44
  // as the identifier of the sorted column. See the "Compound expandable" example.
@@ -78,7 +88,7 @@ export const TableSortableCustom: React.FunctionComponent = () => {
78
88
  },
79
89
  onSort: (_event, index, direction) => {
80
90
  setActiveSortIndex(index);
81
- setActiveSortDirection(direction);
91
+ setActiveSortDirection(direction as 'desc' | 'asc');
82
92
  },
83
93
  columnIndex
84
94
  });
@@ -87,56 +97,63 @@ export const TableSortableCustom: React.FunctionComponent = () => {
87
97
  <React.Fragment>
88
98
  <Toolbar id="toolbar">
89
99
  <ToolbarContent>
90
- {/* <ToolbarItem> TODO: replace with select after #8073
91
- <OptionsMenu
92
- id="options-menu-multiple-options-example"
93
- menuItems={[
94
- <OptionsMenuItemGroup key="first group" aria-label="Sort column">
95
- {Object.values(columnNames).map((columnName, columnIndex) => (
96
- <OptionsMenuItem
97
- key={columnName}
100
+ <ToolbarItem>
101
+ <Select
102
+ isOpen={isSortDropdownOpen}
103
+ selected={[activeSortDirection, activeSortIndex]}
104
+ onOpenChange={isOpen => setIsSortDropdownOpen(isOpen)}
105
+ onSelect={(event, itemId) => {
106
+ if (itemId === 'asc' || itemId === 'desc') {
107
+ setActiveSortDirection(itemId as 'desc' | 'asc');
108
+ } else {
109
+ setActiveSortIndex(itemId as number);
110
+ setActiveSortDirection(activeSortDirection !== null ? activeSortDirection : 'asc'); }
111
+ }}
112
+ toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
113
+ <MenuToggle
114
+ ref={toggleRef}
115
+ onClick={() => setIsSortDropdownOpen(!isSortDropdownOpen)}
116
+ isExpanded={isSortDropdownOpen}
117
+ variant="plain"
118
+ aria-label="Sort columns"
119
+ >
120
+ <SortAmountDownIcon />
121
+ </MenuToggle>
122
+ )}
123
+ >
124
+ <SelectGroup label="Sort column">
125
+ <SelectList>
126
+ {Object.values(columnNames).map((column, columnIndex) => (
127
+ <SelectOption
128
+ key={column}
129
+ itemId={columnIndex}
98
130
  isSelected={activeSortIndex === columnIndex}
99
- onSelect={() => {
100
- setActiveSortIndex(columnIndex);
101
- setActiveSortDirection(activeSortDirection !== null ? activeSortDirection : 'asc');
102
- }}
103
131
  >
104
- {columnName}
105
- </OptionsMenuItem>
132
+ {column}
133
+ </SelectOption>
106
134
  ))}
107
- </OptionsMenuItemGroup>,
108
- <OptionsMenuSeparator key="separator" />,
109
- <OptionsMenuItemGroup key="second group" aria-label="Sort direction">
110
- <OptionsMenuItem
111
- onSelect={() => setActiveSortDirection('asc')}
135
+ </SelectList>
136
+ </SelectGroup>
137
+ <SelectGroup label="Sort direction">
138
+ <SelectList>
139
+ <SelectOption
112
140
  isSelected={activeSortDirection === 'asc'}
113
- id="ascending"
141
+ itemId="asc"
114
142
  key="ascending"
115
143
  >
116
144
  Ascending
117
- </OptionsMenuItem>
118
- <OptionsMenuItem
119
- onSelect={() => setActiveSortDirection('desc')}
145
+ </SelectOption>
146
+ <SelectOption
120
147
  isSelected={activeSortDirection === 'desc'}
121
- id="descending"
148
+ itemId="desc"
122
149
  key="descending"
123
150
  >
124
151
  Descending
125
- </OptionsMenuItem>
126
- </OptionsMenuItemGroup>
127
- ]}
128
- isOpen={isSortDropdownOpen}
129
- toggle={
130
- <OptionsMenuToggle
131
- hideCaret
132
- onToggle={() => setIsSortDropdownOpen(!isSortDropdownOpen)}
133
- toggleTemplate={<SortAmountDownIcon />}
134
- />
135
- }
136
- isPlain
137
- isGrouped
138
- />
139
- </ToolbarItem> */}
152
+ </SelectOption>
153
+ </SelectList>
154
+ </SelectGroup>
155
+ </Select>
156
+ </ToolbarItem>
140
157
  </ToolbarContent>
141
158
  </Toolbar>
142
159
  <Table aria-label="Sortable table custom toolbar">
@@ -4,7 +4,18 @@ import { Table, TableHeader, TableBody, TableProps } from '@patternfly/react-tab
4
4
  import {
5
5
  Toolbar,
6
6
  ToolbarContent,
7
+ ToolbarItem,
8
+ MenuToggle,
9
+ MenuToggleElement
7
10
  } from '@patternfly/react-core';
11
+ import {
12
+ Select as NewSelect,
13
+ SelectGroup as NewSelectGroup,
14
+ SelectList as NewSelectList,
15
+ SelectOption as NewSelectOption
16
+ } from '@patternfly/react-core/dist/esm/components/Select';
17
+
18
+ import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
8
19
 
9
20
  interface Repository {
10
21
  name: string;
@@ -22,13 +33,15 @@ export const LegacyTableSortableCustom: React.FunctionComponent = () => {
22
33
  { name: 'p', branches: 'two', prs: 'b', workspaces: 'four', lastCommit: 'five' }
23
34
  ];
24
35
 
25
- // const columnNames = {
26
- // name: 'Repositories',
27
- // branches: 'Branches',
28
- // prs: 'Pull requests',
29
- // workspaces: 'Workspaces',
30
- // lastCommit: 'Last commit'
31
- // };
36
+ const columnNames = {
37
+ name: 'Repositories',
38
+ branches: 'Branches',
39
+ prs: 'Pull requests',
40
+ workspaces: 'Workspaces',
41
+ lastCommit: 'Last commit'
42
+ };
43
+
44
+ const [isSortDropdownOpen, setIsSortDropdownOpen] = React.useState(false);
32
45
 
33
46
  // Index of the currently sorted column
34
47
  // Note: if you intend to make columns reorderable, you may instead want to use a non-numeric key
@@ -110,56 +123,63 @@ export const LegacyTableSortableCustom: React.FunctionComponent = () => {
110
123
  <React.Fragment>
111
124
  <Toolbar id="toolbar">
112
125
  <ToolbarContent>
113
- {/* <ToolbarItem> TODO: replace with select after #8073
114
- <OptionsMenu
115
- id="options-menu-multiple-options-example"
116
- menuItems={[
117
- <OptionsMenuItemGroup key="first group" aria-label="Sort column">
118
- {Object.values(columnNames).map((columnName, columnIndex) => (
119
- <OptionsMenuItem
120
- key={columnName}
126
+ <ToolbarItem>
127
+ <NewSelect
128
+ isOpen={isSortDropdownOpen}
129
+ selected={[activeSortDirection, activeSortIndex]}
130
+ onOpenChange={isOpen => setIsSortDropdownOpen(isOpen)}
131
+ onSelect={(event, itemId) => {
132
+ if (itemId === 'asc' || itemId === 'desc') {
133
+ setActiveSortDirection(itemId as 'desc' | 'asc');
134
+ } else {
135
+ setActiveSortIndex(itemId as number);
136
+ setActiveSortDirection(activeSortDirection !== null ? activeSortDirection : 'asc'); }
137
+ }}
138
+ toggle={(toggleRef: React.Ref<MenuToggleElement>) => (
139
+ <MenuToggle
140
+ ref={toggleRef}
141
+ onClick={() => setIsSortDropdownOpen(!isSortDropdownOpen)}
142
+ isExpanded={isSortDropdownOpen}
143
+ variant="plain"
144
+ aria-label="Sort columns"
145
+ >
146
+ <SortAmountDownIcon />
147
+ </MenuToggle>
148
+ )}
149
+ >
150
+ <NewSelectGroup label="Sort column">
151
+ <NewSelectList>
152
+ {Object.values(columnNames).map((column, columnIndex) => (
153
+ <NewSelectOption
154
+ key={column}
155
+ itemId={columnIndex}
121
156
  isSelected={activeSortIndex === columnIndex}
122
- onSelect={() => {
123
- setActiveSortIndex(columnIndex);
124
- setActiveSortDirection(activeSortDirection !== null ? activeSortDirection : 'asc');
125
- }}
126
157
  >
127
- {columnName}
128
- </OptionsMenuItem>
158
+ {column}
159
+ </NewSelectOption>
129
160
  ))}
130
- </OptionsMenuItemGroup>,
131
- <OptionsMenuSeparator key="separator" />,
132
- <OptionsMenuItemGroup key="second group" aria-label="Sort direction">
133
- <OptionsMenuItem
134
- onSelect={() => setActiveSortDirection('asc')}
161
+ </NewSelectList>
162
+ </NewSelectGroup>
163
+ <NewSelectGroup label="Sort direction">
164
+ <NewSelectList>
165
+ <NewSelectOption
135
166
  isSelected={activeSortDirection === 'asc'}
136
- id="ascending"
167
+ itemId="asc"
137
168
  key="ascending"
138
169
  >
139
170
  Ascending
140
- </OptionsMenuItem>
141
- <OptionsMenuItem
142
- onSelect={() => setActiveSortDirection('desc')}
171
+ </NewSelectOption>
172
+ <NewSelectOption
143
173
  isSelected={activeSortDirection === 'desc'}
144
- id="descending"
174
+ itemId="desc"
145
175
  key="descending"
146
176
  >
147
177
  Descending
148
- </OptionsMenuItem>
149
- </OptionsMenuItemGroup>
150
- ]}
151
- isOpen={isSortDropdownOpen}
152
- toggle={
153
- <OptionsMenuToggle
154
- hideCaret
155
- onToggle={() => setIsSortDropdownOpen(!isSortDropdownOpen)}
156
- toggleTemplate={<SortAmountDownIcon />}
157
- />
158
- }
159
- isPlain
160
- isGrouped
161
- />
162
- </ToolbarItem> */}
178
+ </NewSelectOption>
179
+ </NewSelectList>
180
+ </NewSelectGroup>
181
+ </NewSelect>
182
+ </ToolbarItem>
163
183
  </ToolbarContent>
164
184
  </Toolbar>
165
185
  <Table
@@ -20,6 +20,14 @@ import LeafIcon from '@patternfly/react-icons/dist/esm/icons/leaf-icon';
20
20
  import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon';
21
21
  import FolderOpenIcon from '@patternfly/react-icons/dist/esm/icons/folder-open-icon';
22
22
  import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
23
+ import { SelectOption as SelectOptionDeprecated } from '@patternfly/react-core/deprecated';
24
+ import {
25
+ Select as NewSelect,
26
+ SelectGroup as NewSelectGroup,
27
+ SelectList as NewSelectList,
28
+ SelectOption as NewSelectOption,
29
+ } from '@patternfly/react-core/dist/esm/components/Select';
30
+
23
31
 
24
32
  import { css } from '@patternfly/react-styles';
25
33
  import styles from '@patternfly/react-styles/css/components/Table/table';
@@ -292,7 +300,7 @@ Example:
292
300
 
293
301
  ```js
294
302
  import React from 'react';
295
- import { SelectOption } from '@patternfly/react-core';
303
+ import { SelectOption as SelectOptionDeprecated } from '@patternfly/react-core/deprecated';
296
304
  import {
297
305
  Table,
298
306
  TableHeader,
@@ -389,14 +397,14 @@ class EditableRowsTable extends React.Component {
389
397
  onSelect={this.onSelect}
390
398
  isOpen={props.isSelectOpen}
391
399
  options={props.options.map((option, index) => (
392
- <SelectOption
400
+ <SelectOptionDeprecated
393
401
  key={index}
394
402
  value={option.value}
395
403
  id={'uniqueIdRow1Cell4Option' + index}
396
404
  isPlaceholder={option.isPlaceholder}
397
405
  />
398
406
  ))}
399
- onToggle={isOpen => {
407
+ onToggle={(event, isOpen) => {
400
408
  this.onToggle(isOpen, rowIndex, cellIndex);
401
409
  }}
402
410
  selections={props.selected}
@@ -486,7 +494,7 @@ class EditableRowsTable extends React.Component {
486
494
  isOpen={props.isSelectOpen}
487
495
  options={props.options.map((option, index) => {
488
496
  return (
489
- <SelectOption
497
+ <SelectOptionDeprecated
490
498
  key={index}
491
499
  value={option.value}
492
500
  id={'uniqueIdRow2Cell4Option' + index}
@@ -494,7 +502,7 @@ class EditableRowsTable extends React.Component {
494
502
  />
495
503
  );
496
504
  })}
497
- onToggle={isOpen => {
505
+ onToggle={(event, isOpen) => {
498
506
  this.onToggle(isOpen, rowIndex, cellIndex);
499
507
  }}
500
508
  selections={props.selected}
@@ -606,14 +614,14 @@ class EditableRowsTable extends React.Component {
606
614
  clearSelection={this.clearSelection}
607
615
  isOpen={props.isSelectOpen}
608
616
  options={props.options.map((option, index) => (
609
- <SelectOption
617
+ <SelectOptionDeprecated
610
618
  key={index}
611
619
  value={option.value}
612
620
  id={'uniqueIdRow3Cell4Option' + index}
613
621
  isPlaceholder={option.isPlaceholder}
614
622
  />
615
623
  ))}
616
- onToggle={isOpen => {
624
+ onToggle={(event, isOpen) => {
617
625
  this.onToggle(isOpen, rowIndex, cellIndex);
618
626
  }}
619
627
  selections={props.selected}
@@ -684,6 +692,7 @@ class EditableRowsTable extends React.Component {
684
692
  }
685
693
 
686
694
  let newSelected = Array.from(newCellProps.selected);
695
+ let newSelectOpen = false;
687
696
 
688
697
  switch (newCellProps.editableSelectProps.variant) {
689
698
  case 'typeaheadmulti':
@@ -693,6 +702,7 @@ class EditableRowsTable extends React.Component {
693
702
  } else {
694
703
  newSelected = newSelected.filter(el => el !== newValue);
695
704
  }
705
+ newSelectOpen = true;
696
706
  break;
697
707
  }
698
708
  default: {
@@ -702,6 +712,7 @@ class EditableRowsTable extends React.Component {
702
712
 
703
713
  newCellProps.editableValue = newSelected;
704
714
  newCellProps.selected = newSelected;
715
+ newCellProps.isSelectOpen = newSelectOpen;
705
716
  }
706
717
 
707
718
  this.setState({
@@ -720,6 +731,7 @@ class EditableRowsTable extends React.Component {
720
731
  };
721
732
 
722
733
  this.onToggle = (isOpen, rowIndex, cellIndex) => {
734
+ console.log("isOpen", isOpen);
723
735
  let newRows = Array.from(this.state.rows);
724
736
  newRows[rowIndex].cells[cellIndex].props.isSelectOpen = isOpen;
725
737
  this.setState({