@patternfly/react-table 5.0.0-alpha.47 → 5.0.0-alpha.49
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 +10 -0
- package/dist/esm/components/Table/ActionsColumn.js +1 -1
- package/dist/esm/components/Table/ActionsColumn.js.map +1 -1
- package/dist/esm/components/Table/Table.d.ts.map +1 -1
- package/dist/esm/components/Table/Table.js +4 -4
- package/dist/esm/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Table/TableTypes.d.ts +2 -2
- package/dist/esm/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/esm/components/Table/TableTypes.js.map +1 -1
- package/dist/esm/components/Table/base/types.d.ts +2 -1
- package/dist/esm/components/Table/base/types.d.ts.map +1 -1
- package/dist/esm/components/Table/base/types.js.map +1 -1
- package/dist/js/components/Table/ActionsColumn.js +4 -4
- package/dist/js/components/Table/ActionsColumn.js.map +1 -1
- package/dist/js/components/Table/Table.d.ts.map +1 -1
- package/dist/js/components/Table/Table.js +6 -6
- package/dist/js/components/Table/Table.js.map +1 -1
- package/dist/js/components/Table/TableTypes.d.ts +2 -2
- package/dist/js/components/Table/TableTypes.d.ts.map +1 -1
- package/dist/js/components/Table/TableTypes.js +1 -1
- package/dist/js/components/Table/TableTypes.js.map +1 -1
- package/dist/js/components/Table/base/types.d.ts +2 -1
- package/dist/js/components/Table/base/types.d.ts.map +1 -1
- package/dist/js/components/Table/base/types.js +1 -0
- package/dist/js/components/Table/base/types.js.map +1 -1
- package/dist/umd/react-table.min.js +1 -1
- package/package.json +3 -3
- package/src/components/Table/ActionsColumn.tsx +2 -2
- package/src/components/Table/Table.tsx +4 -7
- package/src/components/Table/TableTypes.tsx +2 -5
- package/src/components/Table/base/types.tsx +2 -8
- package/src/components/Table/utils/transformers.test.tsx +3 -3
- package/src/components/TableComposable/examples/{ComposableTable.md → Table.md} +63 -69
- package/src/components/TableComposable/examples/{ComposableTableActions.tsx → TableActions.tsx} +2 -2
- package/src/components/TableComposable/examples/{ComposableTableActionsOverflow.tsx → TableActionsOverflow.tsx} +6 -5
- package/src/components/TableComposable/examples/{ComposableTableBasic.tsx → TableBasic.tsx} +2 -2
- package/src/components/TableComposable/examples/{ComposableTableCellWidth.tsx → TableCellWidth.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableCompoundExpandable.tsx → TableCompoundExpandable.tsx} +2 -2
- package/src/components/TableComposable/examples/{ComposableTableControllingText.tsx → TableControllingText.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableDraggable.tsx → TableDraggable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableEmptyState.tsx → TableEmptyState.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableExpandable.tsx → TableExpandable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableFavoritable.tsx → TableFavoritable.tsx} +3 -3
- package/src/components/TableComposable/examples/{ComposableTableHoverable.tsx → TableHoverable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableMisc.tsx → TableMisc.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableMultipleStickyColumns.tsx → TableMultipleStickyColumns.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableNestedExpandable.tsx → TableNestedExpandable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableNestedHeaders.tsx → TableNestedHeaders.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableNestedStickyHeader.tsx → TableNestedStickyHeader.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableNestedTableExpandable.tsx → TableNestedTableExpandable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableSelectable.tsx → TableSelectable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableSelectableRadio.tsx → TableSelectableRadio.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableSortable.tsx → TableSortable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableSortableCustom.tsx → TableSortableCustom.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableStickyColumn.tsx → TableStickyColumn.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableStickyColumnsAndHeader.tsx → TableStickyColumnsAndHeader.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableStriped.tsx → TableStriped.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableStripedExpandable.tsx → TableStripedExpandable.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableStripedMultipleTbody.tsx → TableStripedMultipleTbody.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableStripedTr.tsx → TableStripedTr.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableTextModifiers.tsx → TableTextModifiers.tsx} +1 -1
- package/src/components/TableComposable/examples/{ComposableTableTree.tsx → TableTree.tsx} +1 -1
- package/src/docs/demos/Table.md +24 -17
- package/src/docs/demos/table-demos/SortableResponsive.jsx +21 -10
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.49",
|
|
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.
|
|
42
|
+
"@patternfly/react-core": "^5.0.0-alpha.48",
|
|
43
43
|
"@patternfly/react-icons": "^5.0.0-alpha.6",
|
|
44
44
|
"@patternfly/react-styles": "^5.0.0-alpha.5",
|
|
45
45
|
"@patternfly/react-tokens": "^5.0.0-alpha.5",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"react": "^17 || ^18",
|
|
55
55
|
"react-dom": "^17 || ^18"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "f7c6ecbdd9eccfb269895726c988329773acddfb"
|
|
58
58
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Dropdown, DropdownItem, DropdownList } from '@patternfly/react-core
|
|
2
|
+
import { Dropdown, DropdownItem, DropdownList } from '@patternfly/react-core';
|
|
3
3
|
import { Button } from '@patternfly/react-core/dist/esm/components/Button';
|
|
4
4
|
import { Divider } from '@patternfly/react-core/dist/esm/components/Divider';
|
|
5
5
|
import { MenuToggle } from '@patternfly/react-core/dist/esm/components/MenuToggle';
|
|
@@ -115,7 +115,7 @@ const ActionsColumnBase: React.FunctionComponent<ActionsColumnProps> = ({
|
|
|
115
115
|
}
|
|
116
116
|
const item = (
|
|
117
117
|
<DropdownItem
|
|
118
|
-
onClick={(event) => {
|
|
118
|
+
onClick={(event: any) => {
|
|
119
119
|
onActionClick(event, onClick);
|
|
120
120
|
onToggle();
|
|
121
121
|
}}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { OUIAProps, getDefaultOUIAId } from '@patternfly/react-core';
|
|
3
|
-
import {
|
|
4
|
-
DropdownDirection,
|
|
5
|
-
DropdownPosition
|
|
6
|
-
} from '@patternfly/react-core/dist/esm/components/Dropdown/dropdownConstants';
|
|
3
|
+
import { DropdownDirection, DropdownPosition } from '@patternfly/react-core/dist/esm/deprecated/components';
|
|
7
4
|
import inlineStyles from '@patternfly/react-styles/css/components/InlineEdit/inline-edit';
|
|
8
5
|
import { css } from '@patternfly/react-styles';
|
|
9
6
|
import { Provider } from './base';
|
|
@@ -177,7 +174,7 @@ export class Table extends React.Component<TableProps, {}> {
|
|
|
177
174
|
return false;
|
|
178
175
|
}
|
|
179
176
|
return rows.every(
|
|
180
|
-
row => this.isSelected(row) || row.disableSelection || (row.hasOwnProperty('parent') && !row.showSelect)
|
|
177
|
+
(row) => this.isSelected(row) || row.disableSelection || (row.hasOwnProperty('parent') && !row.showSelect)
|
|
181
178
|
);
|
|
182
179
|
};
|
|
183
180
|
|
|
@@ -185,7 +182,7 @@ export class Table extends React.Component<TableProps, {}> {
|
|
|
185
182
|
if (rows === undefined || rows.length === 0) {
|
|
186
183
|
return false;
|
|
187
184
|
}
|
|
188
|
-
return rows.every(row => row.isOpen === undefined || row.isOpen);
|
|
185
|
+
return rows.every((row) => row.isOpen === undefined || row.isOpen);
|
|
189
186
|
};
|
|
190
187
|
|
|
191
188
|
render() {
|
|
@@ -259,7 +256,7 @@ export class Table extends React.Component<TableProps, {}> {
|
|
|
259
256
|
onFavorite,
|
|
260
257
|
canSortFavorites,
|
|
261
258
|
// order of columns: Collapsible | Selectable | Favoritable
|
|
262
|
-
firstUserColumnIndex: [onCollapse, onSelect, onFavorite].filter(callback => callback).length
|
|
259
|
+
firstUserColumnIndex: [onCollapse, onSelect, onFavorite].filter((callback) => callback).length
|
|
263
260
|
});
|
|
264
261
|
|
|
265
262
|
const table = (
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { DropdownItemProps } from '@patternfly/react-core
|
|
1
|
+
import { DropdownItemProps } from '@patternfly/react-core';
|
|
2
2
|
import { formatterValueType, ColumnType, RowType, RowKeyType, HeaderType } from './base';
|
|
3
3
|
import { SortByDirection } from './SortColumn';
|
|
4
|
-
import {
|
|
5
|
-
DropdownDirection,
|
|
6
|
-
DropdownPosition
|
|
7
|
-
} from '@patternfly/react-core/dist/esm/components/Dropdown/dropdownConstants';
|
|
4
|
+
import { DropdownDirection, DropdownPosition } from '@patternfly/react-core/dist/esm/deprecated/components';
|
|
8
5
|
import * as React from 'react';
|
|
9
6
|
import { CustomActionsToggleProps } from './ActionsColumn';
|
|
10
7
|
import { ButtonProps } from '@patternfly/react-core';
|
|
@@ -6,14 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import * as React from 'react';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
PopoverProps,
|
|
12
|
-
DropdownPosition,
|
|
13
|
-
DropdownDirection,
|
|
14
|
-
SelectOptionObject,
|
|
15
|
-
SelectProps
|
|
16
|
-
} from '@patternfly/react-core';
|
|
9
|
+
import { TooltipProps, PopoverProps, SelectOptionObject, SelectProps } from '@patternfly/react-core';
|
|
10
|
+
import { DropdownPosition, DropdownDirection } from '@patternfly/react-core/dist/esm/deprecated/components';
|
|
17
11
|
import { TableComposable } from '../../TableComposable/TableComposable';
|
|
18
12
|
import { Thead } from '../../TableComposable/Thead';
|
|
19
13
|
import { Tbody } from '../../TableComposable/Tbody';
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
textCenter,
|
|
19
19
|
cellActions
|
|
20
20
|
} from './';
|
|
21
|
-
import { DropdownPosition, DropdownDirection } from '@patternfly/react-core';
|
|
21
|
+
import { DropdownPosition, DropdownDirection } from '@patternfly/react-core/deprecated';
|
|
22
22
|
import {
|
|
23
23
|
IAction,
|
|
24
24
|
IActions,
|
|
@@ -210,7 +210,7 @@ describe('Transformer functions', () => {
|
|
|
210
210
|
|
|
211
211
|
describe('cellWidth', () => {
|
|
212
212
|
const widths = [10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100];
|
|
213
|
-
widths.forEach(width =>
|
|
213
|
+
widths.forEach((width) =>
|
|
214
214
|
test(`${width}`, () => {
|
|
215
215
|
expect(cellWidth(width as widthType)()).toEqual({ className: `pf-m-width-${width}` });
|
|
216
216
|
})
|
|
@@ -336,7 +336,7 @@ describe('Transformer functions', () => {
|
|
|
336
336
|
});
|
|
337
337
|
|
|
338
338
|
describe('visibility classNames', () => {
|
|
339
|
-
Object.keys(Visibility).forEach(className => {
|
|
339
|
+
Object.keys(Visibility).forEach((className) => {
|
|
340
340
|
test(`${className} is defined`, () => {
|
|
341
341
|
expect(Visibility[className]).not.toBe(undefined);
|
|
342
342
|
});
|
|
@@ -31,12 +31,12 @@ propComponents:
|
|
|
31
31
|
'ThSortType',
|
|
32
32
|
'ISortBy',
|
|
33
33
|
'InnerScrollContainer',
|
|
34
|
-
'OuterScrollContainer'
|
|
34
|
+
'OuterScrollContainer'
|
|
35
35
|
]
|
|
36
36
|
ouia: true
|
|
37
37
|
---
|
|
38
38
|
|
|
39
|
-
# Table
|
|
39
|
+
# Table
|
|
40
40
|
|
|
41
41
|
Note: Table lives in its own package at [@patternfly/react-table](https://www.npmjs.com/package/@patternfly/react-table)!
|
|
42
42
|
|
|
@@ -57,12 +57,10 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico
|
|
|
57
57
|
|
|
58
58
|
import { css } from '@patternfly/react-styles';
|
|
59
59
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
60
|
-
import { Dropdown as DropdownNext, DropdownList } from '@patternfly/react-core/next';
|
|
61
60
|
|
|
61
|
+
## Table examples
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
The `TableComposable` component differs from the regular `Table` component, in that it allows you to compose the table by nesting the relevant `Thead`, `Tbody`, `Tr`, `Th` and `Td` components within it. For a less declarative and more implicit approach, use the `Table` component instead.
|
|
63
|
+
This `TableComposable` component differs from the deprecated `Table` component, in that it allows you to compose the table by nesting the relevant `Thead`, `Tbody`, `Tr`, `Th` and `Td` components within it. For a less declarative and more implicit approach, use the `Table` component instead.
|
|
66
64
|
|
|
67
65
|
Some general notes:
|
|
68
66
|
|
|
@@ -70,12 +68,12 @@ Some general notes:
|
|
|
70
68
|
- If you want a table caption, simply place a `<Caption>My caption</Caption>` as the first child within a `TableComposable`.
|
|
71
69
|
- You can set the `TableComposable` variant to `compact`
|
|
72
70
|
|
|
73
|
-
###
|
|
71
|
+
### Basic
|
|
74
72
|
|
|
75
|
-
```ts file="
|
|
73
|
+
```ts file="TableBasic.tsx"
|
|
76
74
|
```
|
|
77
75
|
|
|
78
|
-
###
|
|
76
|
+
### Custom row wrapper, header tooltips & popovers
|
|
79
77
|
|
|
80
78
|
- If you add the `noWrap` prop to `Thead`, it won't wrap it if there is no space
|
|
81
79
|
- You can add the `textCenter` prop to `Th` or `Td` to center the contents
|
|
@@ -83,10 +81,10 @@ Some general notes:
|
|
|
83
81
|
|
|
84
82
|
To add a header tooltip or popover to `Th`, pass a `ThInfoType` object via the `info` prop.
|
|
85
83
|
|
|
86
|
-
```ts file="
|
|
84
|
+
```ts file="TableMisc.tsx"
|
|
87
85
|
```
|
|
88
86
|
|
|
89
|
-
###
|
|
87
|
+
### Sortable & wrapping headers
|
|
90
88
|
|
|
91
89
|
To make a column sortable, pass a `ThSortType` object via the `sort` prop on a column's `Th`.
|
|
92
90
|
|
|
@@ -104,17 +102,17 @@ type OnSort = (
|
|
|
104
102
|
|
|
105
103
|
The built in display for sorting is not fully responsive, as the column headers will be displayed per row when the screen size is small. To see a full page demo of a responsive sortable table, utilizing a toolbar item to control sorting for small screens, view the `Sortable - responsive` demo in the `React demos` tab.
|
|
106
104
|
|
|
107
|
-
```ts file="
|
|
105
|
+
```ts file="TableSortable.tsx"
|
|
108
106
|
```
|
|
109
107
|
|
|
110
|
-
###
|
|
108
|
+
### Sortable - custom control
|
|
111
109
|
|
|
112
110
|
Sorting a table may also be controlled manually with a toolbar control. To see a full page demo of a responsive table, view the `Sortable - responsive` demo in the `React demos` tab.
|
|
113
111
|
|
|
114
|
-
```ts file="
|
|
112
|
+
```ts file="TableSortableCustom.tsx"
|
|
115
113
|
```
|
|
116
114
|
|
|
117
|
-
###
|
|
115
|
+
### Selectable with checkbox
|
|
118
116
|
|
|
119
117
|
To make a row selectable, the table needs a selection column.
|
|
120
118
|
The selection column is just another column, but with selection specific props added.
|
|
@@ -141,24 +139,24 @@ type OnSelect = (
|
|
|
141
139
|
**Note:** This example has a `shift + select` feature where holding shift while
|
|
142
140
|
checking checkboxes will check intermediate rows' checkboxes.
|
|
143
141
|
|
|
144
|
-
```ts file="
|
|
142
|
+
```ts file="TableSelectable.tsx"
|
|
145
143
|
```
|
|
146
144
|
|
|
147
|
-
###
|
|
145
|
+
### Selectable radio input
|
|
148
146
|
|
|
149
147
|
Similarly to the selectable example above, the radio buttons use the first column. The first header cell is empty, and each body row's first cell has radio button props.
|
|
150
148
|
|
|
151
|
-
```ts file="
|
|
149
|
+
```ts file="TableSelectableRadio.tsx"
|
|
152
150
|
```
|
|
153
151
|
|
|
154
|
-
###
|
|
152
|
+
### Row click handler, hoverable & selected rows
|
|
155
153
|
|
|
156
154
|
This selectable rows feature is intended for use when a table is used to present a list of objects in a Primary-detail view.
|
|
157
155
|
|
|
158
|
-
```ts file="
|
|
156
|
+
```ts file="TableHoverable.tsx"
|
|
159
157
|
```
|
|
160
158
|
|
|
161
|
-
###
|
|
159
|
+
### Actions
|
|
162
160
|
|
|
163
161
|
This example demonstrates adding actions as the last column. The header's last cell is an empty cell, and each body row's last cell is an action cell.
|
|
164
162
|
|
|
@@ -166,17 +164,17 @@ To make a cell an action cell, render an `ActionsColumn` component inside a row'
|
|
|
166
164
|
|
|
167
165
|
If actions menus are getting clipped by other items on the page, such as sticky columns or rows, the `ActionsColumn` can be passed a `menuAppendTo` prop to adjust where the actions menu is appended.
|
|
168
166
|
|
|
169
|
-
```ts file="
|
|
167
|
+
```ts file="TableActions.tsx"
|
|
170
168
|
```
|
|
171
169
|
|
|
172
|
-
###
|
|
170
|
+
### Actions Overflow
|
|
173
171
|
|
|
174
172
|
Useing an `OverflowMenu` in the actions column, allowing the actions to condense into a dropdown if necessary for space.
|
|
175
173
|
|
|
176
|
-
```ts file="
|
|
174
|
+
```ts file="TableActionsOverflow.tsx"
|
|
177
175
|
```
|
|
178
176
|
|
|
179
|
-
###
|
|
177
|
+
### Expandable
|
|
180
178
|
|
|
181
179
|
To make a parent/child row pair expandable:
|
|
182
180
|
|
|
@@ -198,10 +196,10 @@ type OnCollapse = (
|
|
|
198
196
|
|
|
199
197
|
Note: Table column widths will respond automatically when toggling expanded rows. To retain column widths between expanded and collapsed states, column header and/or data cell widths must be set.
|
|
200
198
|
|
|
201
|
-
```ts file="
|
|
199
|
+
```ts file="TableExpandable.tsx"
|
|
202
200
|
```
|
|
203
201
|
|
|
204
|
-
###
|
|
202
|
+
### Compound expandable
|
|
205
203
|
|
|
206
204
|
To make a parent/child row pair compound expandable:
|
|
207
205
|
|
|
@@ -222,30 +220,30 @@ export type OnExpand = (
|
|
|
222
220
|
) => void;
|
|
223
221
|
```
|
|
224
222
|
|
|
225
|
-
```ts file="
|
|
223
|
+
```ts file="TableCompoundExpandable.tsx"
|
|
226
224
|
```
|
|
227
225
|
|
|
228
|
-
###
|
|
226
|
+
### Cell width, breakpoint modifiers
|
|
229
227
|
|
|
230
|
-
```ts file="
|
|
228
|
+
```ts file="TableCellWidth.tsx"
|
|
231
229
|
```
|
|
232
230
|
|
|
233
|
-
###
|
|
231
|
+
### Controlling text
|
|
234
232
|
|
|
235
|
-
```ts file="
|
|
233
|
+
```ts file="TableControllingText.tsx"
|
|
236
234
|
```
|
|
237
235
|
|
|
238
|
-
###
|
|
236
|
+
### Modifiers with table text
|
|
239
237
|
|
|
240
|
-
```ts file="
|
|
238
|
+
```ts file="TableTextModifiers.tsx"
|
|
241
239
|
```
|
|
242
240
|
|
|
243
|
-
###
|
|
241
|
+
### Empty state
|
|
244
242
|
|
|
245
|
-
```ts file="
|
|
243
|
+
```ts file="TableEmptyState.tsx"
|
|
246
244
|
```
|
|
247
245
|
|
|
248
|
-
###
|
|
246
|
+
### Favoritable (implemented with sortable)
|
|
249
247
|
|
|
250
248
|
To make a row favoritable, the table needs a favoritable column.
|
|
251
249
|
Pass a `TdFavoritesType` object via the `favorites` prop on each rows's first `Td` in the favoritable column.
|
|
@@ -264,10 +262,10 @@ type OnFavorite = (
|
|
|
264
262
|
|
|
265
263
|
To make a favoritable column sortable, pass a `ThSortType` object to the favoritable column's `Th` with `isFavorites` set to true.
|
|
266
264
|
|
|
267
|
-
```ts file="
|
|
265
|
+
```ts file="TableFavoritable.tsx"
|
|
268
266
|
```
|
|
269
267
|
|
|
270
|
-
###
|
|
268
|
+
### Tree table
|
|
271
269
|
|
|
272
270
|
To enable a tree table:
|
|
273
271
|
|
|
@@ -297,10 +295,10 @@ Note: If this table is going to be tested using axe-core, the tests will flag th
|
|
|
297
295
|
aria-posinset, and aria-setsize as violations. This is an intentional choice at this time so that
|
|
298
296
|
the voice over technologies will recognize the flat table structure as a tree.
|
|
299
297
|
|
|
300
|
-
```ts file="
|
|
298
|
+
```ts file="TableTree.tsx"
|
|
301
299
|
```
|
|
302
300
|
|
|
303
|
-
###
|
|
301
|
+
### Draggable row table
|
|
304
302
|
|
|
305
303
|
To make a row draggable:
|
|
306
304
|
|
|
@@ -310,10 +308,10 @@ To make a row draggable:
|
|
|
310
308
|
4. While the user is dragging a row, the `pf-m-drag-over` class needs to be applied to `TableComposable`.
|
|
311
309
|
5. The draggable `Td` in each row needs a `TdDraggableType` object passed to its `draggable` prop.
|
|
312
310
|
|
|
313
|
-
```ts isBeta file="
|
|
311
|
+
```ts isBeta file="TableDraggable.tsx"
|
|
314
312
|
```
|
|
315
313
|
|
|
316
|
-
|
|
314
|
+
### Sticky table modifiers
|
|
317
315
|
|
|
318
316
|
To make certain columns and the header sticky, the table must be wrapped in a combination of `OuterScrollContainer` and `InnerScrollContainer`. For sticky columns, only `InnerScrollContainer` is required. For sticky headers, and sticky headers with sticky columns, both containers are required to ensure the sticky behavior behaves correctly.
|
|
319
317
|
|
|
@@ -325,28 +323,28 @@ There are a few ways this can be handled:
|
|
|
325
323
|
- Use the `menuAppendTo` prop in non-composable react components with menus to append the menu to an element outside of the table (e.g., the table's parent element) so that the menu has a higher stacking context than - and can appear on top of - sticky headers/columns as well as appear outside of any scrollable content in the table.
|
|
326
324
|
- In the case where the menu is outside of the table (e.g., above the table in a toolbar, or below the table and the menu expands up), assign the entire table a lower `z-index` than the `z-index` of the menu. This creates a lower stacking context for the entire table compared to the menu, while preserving the stacking context of the elements inside of the table.
|
|
327
325
|
|
|
328
|
-
###
|
|
326
|
+
### Sticky column
|
|
329
327
|
|
|
330
328
|
To make a column sticky, wrap `TableComposable` with `InnerScrollContainer` and add the following properties to the `Th` or `Td` that should be sticky: `isStickyColumn` and `hasRightBorder`. To prevent the default text wrapping behavior and allow horizontal scrolling, all `Th` or `Td` cells should also have the `modifier="nowrap"` property. To set the minimum width of the sticky column, use the `stickyMinWidth` property.
|
|
331
329
|
|
|
332
|
-
```ts file="
|
|
330
|
+
```ts file="TableStickyColumn.tsx"
|
|
333
331
|
```
|
|
334
332
|
|
|
335
|
-
###
|
|
333
|
+
### Multiple sticky columns
|
|
336
334
|
|
|
337
335
|
To make multiple columns sticky, wrap `TableComposable` with `InnerScrollContainer` and add `isStickyColumn` to all columns that should be sticky. The rightmost column should also have the `hasRightBorder` property, and each sticky column after the first must define a `stickyLeftOffset` property that equals the combined width of the previous sticky columns - set by `stickyMinWidth`. To prevent the default text wrapping behavior and allow horizontal scrolling, all `Th` or `Td` cells should also have the `modifier="nowrap"` property.
|
|
338
336
|
|
|
339
|
-
```ts file="
|
|
337
|
+
```ts file="TableMultipleStickyColumns.tsx"
|
|
340
338
|
```
|
|
341
339
|
|
|
342
|
-
###
|
|
340
|
+
### Sticky columns and header
|
|
343
341
|
|
|
344
342
|
To maintain proper sticky behavior across sticky columns and header, `TableComposable` must be wrapped with `OuterScrollContainer` and `InnerScrollContainer`.
|
|
345
343
|
|
|
346
|
-
```ts file="
|
|
344
|
+
```ts file="TableStickyColumnsAndHeader.tsx"
|
|
347
345
|
```
|
|
348
346
|
|
|
349
|
-
|
|
347
|
+
### Nested column headers
|
|
350
348
|
|
|
351
349
|
To make a nested column header:
|
|
352
350
|
|
|
@@ -359,52 +357,48 @@ The first `Tr` represents the top level of columns, and each must pass either `r
|
|
|
359
357
|
|
|
360
358
|
The second `Tr` represents the second level of sub columns. The `Th` in this row each should pass `isSubHeader`, and the last sub column of a column should also pass `hasRightBorder`.
|
|
361
359
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
```ts file="ComposableTableNestedHeaders.tsx"
|
|
360
|
+
```ts file="TableNestedHeaders.tsx"
|
|
365
361
|
```
|
|
366
362
|
|
|
367
|
-
###
|
|
363
|
+
### Nested column headers and expandable rows
|
|
368
364
|
|
|
369
|
-
```ts file="
|
|
365
|
+
```ts file="TableNestedExpandable.tsx"
|
|
370
366
|
```
|
|
371
367
|
|
|
372
|
-
###
|
|
368
|
+
### Expandable with nested table
|
|
373
369
|
|
|
374
|
-
```ts file="
|
|
370
|
+
```ts file="TableNestedTableExpandable.tsx"
|
|
375
371
|
```
|
|
376
372
|
|
|
377
|
-
###
|
|
373
|
+
### Nested sticky header
|
|
378
374
|
|
|
379
|
-
```ts file="
|
|
375
|
+
```ts file="TableNestedStickyHeader.tsx"
|
|
380
376
|
```
|
|
381
377
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
### Composable: Striped
|
|
378
|
+
### Striped
|
|
385
379
|
|
|
386
380
|
To apply striping to a basic table, add the `isStriped` property to `TableComposable`.
|
|
387
381
|
|
|
388
|
-
```ts file="
|
|
382
|
+
```ts file="TableStriped.tsx"
|
|
389
383
|
```
|
|
390
384
|
|
|
391
|
-
###
|
|
385
|
+
### Striped expandable
|
|
392
386
|
|
|
393
387
|
To apply striping to an expandable table, add the `isStriped` and `isExpandable` properties to `TableComposable`.
|
|
394
388
|
|
|
395
|
-
```ts file="
|
|
389
|
+
```ts file="TableStripedExpandable.tsx"
|
|
396
390
|
```
|
|
397
391
|
|
|
398
|
-
###
|
|
392
|
+
### Striped multiple tobdy
|
|
399
393
|
|
|
400
394
|
When there are multiple `Tbody` components within a table, a more granular application of striping may be controlled by adding either the `isEvenStriped` or `isOddStriped` properties to `Tbody`. These properties will stripe even or odd rows within that `Tbody` respectively.
|
|
401
395
|
|
|
402
|
-
```ts file="
|
|
396
|
+
```ts file="TableStripedMultipleTbody.tsx"
|
|
403
397
|
```
|
|
404
398
|
|
|
405
|
-
###
|
|
399
|
+
### Striped tr
|
|
406
400
|
|
|
407
401
|
To manually control striping, add the `isStriped` property to each desired `Tr`. This replaces adding the `isStriped` property to `TableComposable`.
|
|
408
402
|
|
|
409
|
-
```ts file="
|
|
403
|
+
```ts file="TableStripedTr.tsx"
|
|
410
404
|
```
|
package/src/components/TableComposable/examples/{ComposableTableActions.tsx → TableActions.tsx}
RENAMED
|
@@ -25,7 +25,7 @@ interface Repository {
|
|
|
25
25
|
|
|
26
26
|
type ExampleType = 'defaultToggle' | 'customToggle';
|
|
27
27
|
|
|
28
|
-
export const
|
|
28
|
+
export const TableActions: React.FunctionComponent = () => {
|
|
29
29
|
// In real usage, this data would come from some external source like an API via props.
|
|
30
30
|
const repositories: Repository[] = [
|
|
31
31
|
{ name: 'one', branches: 'two', prs: 'a', workspaces: 'four', lastCommit: 'five', singleAction: 'Start' },
|
|
@@ -44,7 +44,7 @@ export const ComposableTableActions: React.FunctionComponent = () => {
|
|
|
44
44
|
singleAction: 'Single action'
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
// This state is just for the ToggleGroup in this example and isn't necessary for
|
|
47
|
+
// This state is just for the ToggleGroup in this example and isn't necessary for Table usage.
|
|
48
48
|
const [exampleChoice, setExampleChoice] = React.useState<ExampleType>('defaultToggle');
|
|
49
49
|
const onExampleTypeChange: ToggleGroupItemProps['onChange'] = (_isSelected, event) => {
|
|
50
50
|
const id = event.currentTarget.id;
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
OverflowMenuGroup,
|
|
9
9
|
OverflowMenuItem,
|
|
10
10
|
OverflowMenuDropdownItem,
|
|
11
|
-
MenuToggle
|
|
11
|
+
MenuToggle,
|
|
12
|
+
Dropdown,
|
|
13
|
+
DropdownList
|
|
12
14
|
} from '@patternfly/react-core';
|
|
13
15
|
import { TableComposable, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
14
|
-
import { Dropdown as DropdownNext, DropdownList } from '@patternfly/react-core/next';
|
|
15
16
|
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
16
17
|
|
|
17
18
|
interface Repository {
|
|
@@ -23,7 +24,7 @@ interface Repository {
|
|
|
23
24
|
isMenuOpen: boolean;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export const
|
|
27
|
+
export const TableActions: React.FunctionComponent = () => {
|
|
27
28
|
// In real usage, this data would come from some external source like an API via props.
|
|
28
29
|
const repositories: Repository[] = [
|
|
29
30
|
{ name: 'one', branches: 'two', prs: 'a', workspaces: 'four', lastCommit: 'five', isMenuOpen: false },
|
|
@@ -92,7 +93,7 @@ export const ComposableTableActions: React.FunctionComponent = () => {
|
|
|
92
93
|
</OverflowMenuGroup>
|
|
93
94
|
</OverflowMenuContent>
|
|
94
95
|
<OverflowMenuControl>
|
|
95
|
-
<
|
|
96
|
+
<Dropdown
|
|
96
97
|
onSelect={() =>
|
|
97
98
|
setRepos(repos.map((r) => (r.name !== repo.name ? r : { ...r, isMenuOpen: !r.isMenuOpen })))
|
|
98
99
|
}
|
|
@@ -115,7 +116,7 @@ export const ComposableTableActions: React.FunctionComponent = () => {
|
|
|
115
116
|
}
|
|
116
117
|
>
|
|
117
118
|
<DropdownList>{dropdownItems}</DropdownList>
|
|
118
|
-
</
|
|
119
|
+
</Dropdown>
|
|
119
120
|
</OverflowMenuControl>
|
|
120
121
|
</OverflowMenu>
|
|
121
122
|
</Td>
|
|
@@ -12,7 +12,7 @@ interface Repository {
|
|
|
12
12
|
|
|
13
13
|
type ExampleType = 'default' | 'compact' | 'compactBorderless';
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const TableBasic: React.FunctionComponent = () => {
|
|
16
16
|
// In real usage, this data would come from some external source like an API via props.
|
|
17
17
|
const repositories: Repository[] = [
|
|
18
18
|
{ name: 'one', branches: 'two', prs: 'three', workspaces: 'four', lastCommit: 'five' },
|
|
@@ -28,7 +28,7 @@ export const ComposableTableBasic: React.FunctionComponent = () => {
|
|
|
28
28
|
lastCommit: 'Last commit'
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
// This state is just for the ToggleGroup in this example and isn't necessary for
|
|
31
|
+
// This state is just for the ToggleGroup in this example and isn't necessary for Table usage.
|
|
32
32
|
const [exampleChoice, setExampleChoice] = React.useState<ExampleType>('default');
|
|
33
33
|
const onExampleTypeChange: ToggleGroupItemProps['onChange'] = (_isSelected, event) => {
|
|
34
34
|
const id = event.currentTarget.id;
|
package/src/components/TableComposable/examples/{ComposableTableCellWidth.tsx → TableCellWidth.tsx}
RENAMED
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableCellWidth: 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' },
|
|
@@ -13,7 +13,7 @@ interface Repository {
|
|
|
13
13
|
lastCommit: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const TableCompoundExpandable: React.FunctionComponent = () => {
|
|
17
17
|
// In real usage, this data would come from some external source like an API via props.
|
|
18
18
|
const repositories: Repository[] = [
|
|
19
19
|
{ name: 'siemur/test-space', branches: 10, prs: 4, workspaces: 4, lastCommit: '20 minutes' },
|
|
@@ -52,7 +52,7 @@ export const ComposableTableCompoundExpandable: React.FunctionComponent = () =>
|
|
|
52
52
|
): TdProps['compoundExpand'] => ({
|
|
53
53
|
isExpanded: expandedCells[repo.name] === columnKey,
|
|
54
54
|
onToggle: () => setCellExpanded(repo, columnKey, expandedCells[repo.name] !== columnKey),
|
|
55
|
-
expandId: '
|
|
55
|
+
expandId: 'compound-expandable-example',
|
|
56
56
|
rowIndex,
|
|
57
57
|
columnIndex
|
|
58
58
|
});
|
|
@@ -12,7 +12,7 @@ const columnNames = {
|
|
|
12
12
|
nowrap: 'No wrap'
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const TableControllingText: React.FunctionComponent = () => (
|
|
16
16
|
<TableComposable aria-label="Controlling text">
|
|
17
17
|
<Thead>
|
|
18
18
|
<Tr>
|
package/src/components/TableComposable/examples/{ComposableTableDraggable.tsx → TableDraggable.tsx}
RENAMED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { TableComposable, Thead, Tbody, Tr, Th, Td, TbodyProps, TrProps } from '@patternfly/react-table';
|
|
3
3
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const TableDraggable: React.FunctionComponent = () => {
|
|
6
6
|
const [draggedItemId, setDraggedItemId] = React.useState<string | null>(null);
|
|
7
7
|
const [draggingToItemIndex, setDraggingToItemIndex] = React.useState<number | null>(null);
|
|
8
8
|
const [isDragging, setIsDragging] = React.useState(false);
|
|
@@ -16,7 +16,7 @@ import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
|
16
16
|
// This example has been simplified to focus on the empty state. In real usage,
|
|
17
17
|
// you may want to derive your rows from typed underlying data and minimal state. See other examples.
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const TableEmptyState: React.FunctionComponent = () => (
|
|
20
20
|
<TableComposable aria-label="Empty state table">
|
|
21
21
|
<Thead>
|
|
22
22
|
<Tr>
|
|
@@ -17,7 +17,7 @@ interface Repository {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
-
export const
|
|
20
|
+
export const TableExpandable: React.FunctionComponent = () => {
|
|
21
21
|
// In real usage, this data would come from some external source like an API via props.
|
|
22
22
|
const repositories: Repository[] = [
|
|
23
23
|
{ name: 'one', branches: 'two', prs: 'a', workspaces: 'four', lastCommit: 'five' },
|
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableFavoritable: 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: 'a', workspaces: 'four', lastCommit: 'five' },
|
|
@@ -33,7 +33,7 @@ export const ComposableTableFavoritable: React.FunctionComponent = () => {
|
|
|
33
33
|
// Sort direction of the currently sorted column
|
|
34
34
|
const [activeSortDirection, setActiveSortDirection] = React.useState<'asc' | 'desc' | null>(null);
|
|
35
35
|
|
|
36
|
-
// Favorite state is similar to selection state, see
|
|
36
|
+
// Favorite state is similar to selection state, see Selectable with checkbox.
|
|
37
37
|
const [favoriteRepoNames, setFavoriteRepoNames] = React.useState<string[]>([]);
|
|
38
38
|
const setRepoFavorited = (repo: Repository, isFavoriting = true) =>
|
|
39
39
|
setFavoriteRepoNames(prevFavorites => {
|
|
@@ -44,7 +44,7 @@ export const ComposableTableFavoritable: React.FunctionComponent = () => {
|
|
|
44
44
|
|
|
45
45
|
// Since OnSort specifies sorted columns by index, we need sortable values for our object by column index.
|
|
46
46
|
// In this example we only deal with booleans here because we only sort on the favorites column.
|
|
47
|
-
// For more complex sorting, see
|
|
47
|
+
// For more complex sorting, see Sortable.
|
|
48
48
|
// Note: We also memoize the sortable values with useCallback to prevent rows jumping around when you change
|
|
49
49
|
// the favorites while sorting on that column. Only updating the sort state will reorder the rows.
|
|
50
50
|
const getSortableRowValues = React.useCallback((repo: Repository): boolean[] => [isRepoFavorited(repo)], [
|
package/src/components/TableComposable/examples/{ComposableTableHoverable.tsx → TableHoverable.tsx}
RENAMED
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableHoverable: 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' },
|