@patternfly/react-table 5.0.0-alpha.48 → 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 +4 -0
- package/package.json +2 -2
- package/src/components/TableComposable/examples/{ComposableTable.md → Table.md} +62 -95
- package/src/components/TableComposable/examples/{ComposableTableActions.tsx → TableActions.tsx} +2 -2
- package/src/components/TableComposable/examples/{ComposableTableActionsOverflow.tsx → TableActionsOverflow.tsx} +1 -1
- 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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [5.0.0-alpha.49](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-table@5.0.0-alpha.48...@patternfly/react-table@5.0.0-alpha.49) (2023-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @patternfly/react-table
|
|
9
|
+
|
|
6
10
|
# 5.0.0-alpha.48 (2023-03-24)
|
|
7
11
|
|
|
8
12
|
### Features
|
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",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"react": "^17 || ^18",
|
|
55
55
|
"react-dom": "^17 || ^18"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "f7c6ecbdd9eccfb269895726c988329773acddfb"
|
|
58
58
|
}
|
|
@@ -36,7 +36,7 @@ propComponents:
|
|
|
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
|
|
|
@@ -58,9 +58,9 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico
|
|
|
58
58
|
import { css } from '@patternfly/react-styles';
|
|
59
59
|
import styles from '@patternfly/react-styles/css/components/Table/table';
|
|
60
60
|
|
|
61
|
-
##
|
|
61
|
+
## Table examples
|
|
62
62
|
|
|
63
|
-
|
|
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.
|
|
64
64
|
|
|
65
65
|
Some general notes:
|
|
66
66
|
|
|
@@ -68,13 +68,12 @@ Some general notes:
|
|
|
68
68
|
- If you want a table caption, simply place a `<Caption>My caption</Caption>` as the first child within a `TableComposable`.
|
|
69
69
|
- You can set the `TableComposable` variant to `compact`
|
|
70
70
|
|
|
71
|
-
###
|
|
72
|
-
|
|
73
|
-
```ts file="ComposableTableBasic.tsx"
|
|
71
|
+
### Basic
|
|
74
72
|
|
|
73
|
+
```ts file="TableBasic.tsx"
|
|
75
74
|
```
|
|
76
75
|
|
|
77
|
-
###
|
|
76
|
+
### Custom row wrapper, header tooltips & popovers
|
|
78
77
|
|
|
79
78
|
- If you add the `noWrap` prop to `Thead`, it won't wrap it if there is no space
|
|
80
79
|
- You can add the `textCenter` prop to `Th` or `Td` to center the contents
|
|
@@ -82,11 +81,10 @@ Some general notes:
|
|
|
82
81
|
|
|
83
82
|
To add a header tooltip or popover to `Th`, pass a `ThInfoType` object via the `info` prop.
|
|
84
83
|
|
|
85
|
-
```ts file="
|
|
86
|
-
|
|
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,19 +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="
|
|
108
|
-
|
|
105
|
+
```ts file="TableSortable.tsx"
|
|
109
106
|
```
|
|
110
107
|
|
|
111
|
-
###
|
|
108
|
+
### Sortable - custom control
|
|
112
109
|
|
|
113
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.
|
|
114
111
|
|
|
115
|
-
```ts file="
|
|
116
|
-
|
|
112
|
+
```ts file="TableSortableCustom.tsx"
|
|
117
113
|
```
|
|
118
114
|
|
|
119
|
-
###
|
|
115
|
+
### Selectable with checkbox
|
|
120
116
|
|
|
121
117
|
To make a row selectable, the table needs a selection column.
|
|
122
118
|
The selection column is just another column, but with selection specific props added.
|
|
@@ -143,27 +139,24 @@ type OnSelect = (
|
|
|
143
139
|
**Note:** This example has a `shift + select` feature where holding shift while
|
|
144
140
|
checking checkboxes will check intermediate rows' checkboxes.
|
|
145
141
|
|
|
146
|
-
```ts file="
|
|
147
|
-
|
|
142
|
+
```ts file="TableSelectable.tsx"
|
|
148
143
|
```
|
|
149
144
|
|
|
150
|
-
###
|
|
145
|
+
### Selectable radio input
|
|
151
146
|
|
|
152
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.
|
|
153
148
|
|
|
154
|
-
```ts file="
|
|
155
|
-
|
|
149
|
+
```ts file="TableSelectableRadio.tsx"
|
|
156
150
|
```
|
|
157
151
|
|
|
158
|
-
###
|
|
152
|
+
### Row click handler, hoverable & selected rows
|
|
159
153
|
|
|
160
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.
|
|
161
155
|
|
|
162
|
-
```ts file="
|
|
163
|
-
|
|
156
|
+
```ts file="TableHoverable.tsx"
|
|
164
157
|
```
|
|
165
158
|
|
|
166
|
-
###
|
|
159
|
+
### Actions
|
|
167
160
|
|
|
168
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.
|
|
169
162
|
|
|
@@ -171,19 +164,17 @@ To make a cell an action cell, render an `ActionsColumn` component inside a row'
|
|
|
171
164
|
|
|
172
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.
|
|
173
166
|
|
|
174
|
-
```ts file="
|
|
175
|
-
|
|
167
|
+
```ts file="TableActions.tsx"
|
|
176
168
|
```
|
|
177
169
|
|
|
178
|
-
###
|
|
170
|
+
### Actions Overflow
|
|
179
171
|
|
|
180
172
|
Useing an `OverflowMenu` in the actions column, allowing the actions to condense into a dropdown if necessary for space.
|
|
181
173
|
|
|
182
|
-
```ts file="
|
|
183
|
-
|
|
174
|
+
```ts file="TableActionsOverflow.tsx"
|
|
184
175
|
```
|
|
185
176
|
|
|
186
|
-
###
|
|
177
|
+
### Expandable
|
|
187
178
|
|
|
188
179
|
To make a parent/child row pair expandable:
|
|
189
180
|
|
|
@@ -205,11 +196,10 @@ type OnCollapse = (
|
|
|
205
196
|
|
|
206
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.
|
|
207
198
|
|
|
208
|
-
```ts file="
|
|
209
|
-
|
|
199
|
+
```ts file="TableExpandable.tsx"
|
|
210
200
|
```
|
|
211
201
|
|
|
212
|
-
###
|
|
202
|
+
### Compound expandable
|
|
213
203
|
|
|
214
204
|
To make a parent/child row pair compound expandable:
|
|
215
205
|
|
|
@@ -230,35 +220,30 @@ export type OnExpand = (
|
|
|
230
220
|
) => void;
|
|
231
221
|
```
|
|
232
222
|
|
|
233
|
-
```ts file="
|
|
234
|
-
|
|
223
|
+
```ts file="TableCompoundExpandable.tsx"
|
|
235
224
|
```
|
|
236
225
|
|
|
237
|
-
###
|
|
238
|
-
|
|
239
|
-
```ts file="ComposableTableCellWidth.tsx"
|
|
226
|
+
### Cell width, breakpoint modifiers
|
|
240
227
|
|
|
228
|
+
```ts file="TableCellWidth.tsx"
|
|
241
229
|
```
|
|
242
230
|
|
|
243
|
-
###
|
|
244
|
-
|
|
245
|
-
```ts file="ComposableTableControllingText.tsx"
|
|
231
|
+
### Controlling text
|
|
246
232
|
|
|
233
|
+
```ts file="TableControllingText.tsx"
|
|
247
234
|
```
|
|
248
235
|
|
|
249
|
-
###
|
|
250
|
-
|
|
251
|
-
```ts file="ComposableTableTextModifiers.tsx"
|
|
236
|
+
### Modifiers with table text
|
|
252
237
|
|
|
238
|
+
```ts file="TableTextModifiers.tsx"
|
|
253
239
|
```
|
|
254
240
|
|
|
255
|
-
###
|
|
256
|
-
|
|
257
|
-
```ts file="ComposableTableEmptyState.tsx"
|
|
241
|
+
### Empty state
|
|
258
242
|
|
|
243
|
+
```ts file="TableEmptyState.tsx"
|
|
259
244
|
```
|
|
260
245
|
|
|
261
|
-
###
|
|
246
|
+
### Favoritable (implemented with sortable)
|
|
262
247
|
|
|
263
248
|
To make a row favoritable, the table needs a favoritable column.
|
|
264
249
|
Pass a `TdFavoritesType` object via the `favorites` prop on each rows's first `Td` in the favoritable column.
|
|
@@ -277,11 +262,10 @@ type OnFavorite = (
|
|
|
277
262
|
|
|
278
263
|
To make a favoritable column sortable, pass a `ThSortType` object to the favoritable column's `Th` with `isFavorites` set to true.
|
|
279
264
|
|
|
280
|
-
```ts file="
|
|
281
|
-
|
|
265
|
+
```ts file="TableFavoritable.tsx"
|
|
282
266
|
```
|
|
283
267
|
|
|
284
|
-
###
|
|
268
|
+
### Tree table
|
|
285
269
|
|
|
286
270
|
To enable a tree table:
|
|
287
271
|
|
|
@@ -311,11 +295,10 @@ Note: If this table is going to be tested using axe-core, the tests will flag th
|
|
|
311
295
|
aria-posinset, and aria-setsize as violations. This is an intentional choice at this time so that
|
|
312
296
|
the voice over technologies will recognize the flat table structure as a tree.
|
|
313
297
|
|
|
314
|
-
```ts file="
|
|
315
|
-
|
|
298
|
+
```ts file="TableTree.tsx"
|
|
316
299
|
```
|
|
317
300
|
|
|
318
|
-
###
|
|
301
|
+
### Draggable row table
|
|
319
302
|
|
|
320
303
|
To make a row draggable:
|
|
321
304
|
|
|
@@ -325,11 +308,10 @@ To make a row draggable:
|
|
|
325
308
|
4. While the user is dragging a row, the `pf-m-drag-over` class needs to be applied to `TableComposable`.
|
|
326
309
|
5. The draggable `Td` in each row needs a `TdDraggableType` object passed to its `draggable` prop.
|
|
327
310
|
|
|
328
|
-
```ts isBeta file="
|
|
329
|
-
|
|
311
|
+
```ts isBeta file="TableDraggable.tsx"
|
|
330
312
|
```
|
|
331
313
|
|
|
332
|
-
|
|
314
|
+
### Sticky table modifiers
|
|
333
315
|
|
|
334
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.
|
|
335
317
|
|
|
@@ -341,31 +323,28 @@ There are a few ways this can be handled:
|
|
|
341
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.
|
|
342
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.
|
|
343
325
|
|
|
344
|
-
###
|
|
326
|
+
### Sticky column
|
|
345
327
|
|
|
346
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.
|
|
347
329
|
|
|
348
|
-
```ts file="
|
|
349
|
-
|
|
330
|
+
```ts file="TableStickyColumn.tsx"
|
|
350
331
|
```
|
|
351
332
|
|
|
352
|
-
###
|
|
333
|
+
### Multiple sticky columns
|
|
353
334
|
|
|
354
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.
|
|
355
336
|
|
|
356
|
-
```ts file="
|
|
357
|
-
|
|
337
|
+
```ts file="TableMultipleStickyColumns.tsx"
|
|
358
338
|
```
|
|
359
339
|
|
|
360
|
-
###
|
|
340
|
+
### Sticky columns and header
|
|
361
341
|
|
|
362
342
|
To maintain proper sticky behavior across sticky columns and header, `TableComposable` must be wrapped with `OuterScrollContainer` and `InnerScrollContainer`.
|
|
363
343
|
|
|
364
|
-
```ts file="
|
|
365
|
-
|
|
344
|
+
```ts file="TableStickyColumnsAndHeader.tsx"
|
|
366
345
|
```
|
|
367
346
|
|
|
368
|
-
|
|
347
|
+
### Nested column headers
|
|
369
348
|
|
|
370
349
|
To make a nested column header:
|
|
371
350
|
|
|
@@ -378,60 +357,48 @@ The first `Tr` represents the top level of columns, and each must pass either `r
|
|
|
378
357
|
|
|
379
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`.
|
|
380
359
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
```ts file="ComposableTableNestedHeaders.tsx"
|
|
384
|
-
|
|
360
|
+
```ts file="TableNestedHeaders.tsx"
|
|
385
361
|
```
|
|
386
362
|
|
|
387
|
-
###
|
|
388
|
-
|
|
389
|
-
```ts file="ComposableTableNestedExpandable.tsx"
|
|
363
|
+
### Nested column headers and expandable rows
|
|
390
364
|
|
|
365
|
+
```ts file="TableNestedExpandable.tsx"
|
|
391
366
|
```
|
|
392
367
|
|
|
393
|
-
###
|
|
394
|
-
|
|
395
|
-
```ts file="ComposableTableNestedTableExpandable.tsx"
|
|
368
|
+
### Expandable with nested table
|
|
396
369
|
|
|
370
|
+
```ts file="TableNestedTableExpandable.tsx"
|
|
397
371
|
```
|
|
398
372
|
|
|
399
|
-
###
|
|
400
|
-
|
|
401
|
-
```ts file="ComposableTableNestedStickyHeader.tsx"
|
|
373
|
+
### Nested sticky header
|
|
402
374
|
|
|
375
|
+
```ts file="TableNestedStickyHeader.tsx"
|
|
403
376
|
```
|
|
404
377
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
### Composable: Striped
|
|
378
|
+
### Striped
|
|
408
379
|
|
|
409
380
|
To apply striping to a basic table, add the `isStriped` property to `TableComposable`.
|
|
410
381
|
|
|
411
|
-
```ts file="
|
|
412
|
-
|
|
382
|
+
```ts file="TableStriped.tsx"
|
|
413
383
|
```
|
|
414
384
|
|
|
415
|
-
###
|
|
385
|
+
### Striped expandable
|
|
416
386
|
|
|
417
387
|
To apply striping to an expandable table, add the `isStriped` and `isExpandable` properties to `TableComposable`.
|
|
418
388
|
|
|
419
|
-
```ts file="
|
|
420
|
-
|
|
389
|
+
```ts file="TableStripedExpandable.tsx"
|
|
421
390
|
```
|
|
422
391
|
|
|
423
|
-
###
|
|
392
|
+
### Striped multiple tobdy
|
|
424
393
|
|
|
425
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.
|
|
426
395
|
|
|
427
|
-
```ts file="
|
|
428
|
-
|
|
396
|
+
```ts file="TableStripedMultipleTbody.tsx"
|
|
429
397
|
```
|
|
430
398
|
|
|
431
|
-
###
|
|
399
|
+
### Striped tr
|
|
432
400
|
|
|
433
401
|
To manually control striping, add the `isStriped` property to each desired `Tr`. This replaces adding the `isStriped` property to `TableComposable`.
|
|
434
402
|
|
|
435
|
-
```ts file="
|
|
436
|
-
|
|
403
|
+
```ts file="TableStripedTr.tsx"
|
|
437
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;
|
|
@@ -24,7 +24,7 @@ interface Repository {
|
|
|
24
24
|
isMenuOpen: boolean;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const TableActions: React.FunctionComponent = () => {
|
|
28
28
|
// In real usage, this data would come from some external source like an API via props.
|
|
29
29
|
const repositories: Repository[] = [
|
|
30
30
|
{ name: 'one', branches: 'two', prs: 'a', workspaces: 'four', lastCommit: 'five', isMenuOpen: false },
|
|
@@ -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' },
|
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableMisc: 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' },
|
|
@@ -14,7 +14,7 @@ interface Fact {
|
|
|
14
14
|
detail7: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const
|
|
17
|
+
export const TableMultipleStickyColumns: React.FunctionComponent = () => {
|
|
18
18
|
// In real usage, this data would come from some external source like an API via props.
|
|
19
19
|
const facts: Fact[] = Array.from({ length: 9 }, (_, index) => ({
|
|
20
20
|
name: `Fact ${index + 1}`,
|
|
@@ -22,7 +22,7 @@ interface Team {
|
|
|
22
22
|
description: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const
|
|
25
|
+
export const TableNestedExpandable: React.FunctionComponent = () => {
|
|
26
26
|
// In real usage, this data would come from some external source like an API via props.
|
|
27
27
|
const teams: Team[] = [
|
|
28
28
|
{
|
|
@@ -18,7 +18,7 @@ interface PodConnection {
|
|
|
18
18
|
packets: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
22
22
|
// In real usage, this data would come from some external source like an API via props.
|
|
23
23
|
const connections: PodConnection[] = [
|
|
24
24
|
{
|
|
@@ -18,7 +18,7 @@ interface PodConnection {
|
|
|
18
18
|
packets: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const TableNestedHeaders: React.FunctionComponent = () => {
|
|
22
22
|
// In real usage, this data would come from some external source like an API via props.
|
|
23
23
|
const connections: PodConnection[] = [
|
|
24
24
|
{
|
|
@@ -71,7 +71,7 @@ const NestedReposTable: React.FunctionComponent = () => {
|
|
|
71
71
|
);
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
-
export const
|
|
74
|
+
export const TableExpandable: React.FunctionComponent = () => {
|
|
75
75
|
// In real usage, this data would come from some external source like an API via props.
|
|
76
76
|
const repositories: Repository[] = [
|
|
77
77
|
{ name: 'Node 1', branches: '10', prs: '2', nestedComponent: <NestedReposTable />, link: <a>Link 1</a> },
|
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableSelectable: 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' },
|
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableSelectableRadio: 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' },
|
package/src/components/TableComposable/examples/{ComposableTableSortable.tsx → TableSortable.tsx}
RENAMED
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableSortable: 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' },
|
|
@@ -13,7 +13,7 @@ interface Repository {
|
|
|
13
13
|
lastCommit: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const TableSortableCustom: 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: 'one', branches: 'two', prs: 'a', workspaces: 'four', lastCommit: 'five' },
|
|
@@ -13,7 +13,7 @@ interface Fact {
|
|
|
13
13
|
detail7: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const
|
|
16
|
+
export const TableStickyColumn: React.FunctionComponent = () => {
|
|
17
17
|
// In real usage, this data would come from some external source like an API via props.
|
|
18
18
|
const facts: Fact[] = Array.from({ length: 9 }, (_, index) => ({
|
|
19
19
|
name: `Fact ${index + 1}`,
|
|
@@ -24,7 +24,7 @@ interface Fact {
|
|
|
24
24
|
detail7: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const TableStickyColumnsAndHeader: React.FunctionComponent = () => {
|
|
28
28
|
// In real usage, this data would come from some external source like an API via props.
|
|
29
29
|
const facts: Fact[] = Array.from({ length: 9 }, (_, index) => ({
|
|
30
30
|
name: `Fact ${index + 1}`,
|
package/src/components/TableComposable/examples/{ComposableTableStriped.tsx → TableStriped.tsx}
RENAMED
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableStriped: 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: 'Repository 1', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' },
|
|
@@ -16,7 +16,7 @@ interface Repository {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const TableStripedExpandable: React.FunctionComponent = () => {
|
|
20
20
|
// In real usage, this data would come from some external source like an API via props.
|
|
21
21
|
const repositories: Repository[] = [
|
|
22
22
|
{ name: 'one', branches: 'two', prs: 'a', workspaces: 'four', lastCommit: 'five' },
|
|
@@ -10,7 +10,7 @@ interface Repository {
|
|
|
10
10
|
lastCommit: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const TableStripedMultipleTbody: React.FunctionComponent = () => {
|
|
14
14
|
// In real usage, this data would come from some external source like an API via props.
|
|
15
15
|
const repositories1: Repository[] = [
|
|
16
16
|
{
|
package/src/components/TableComposable/examples/{ComposableTableStripedTr.tsx → TableStripedTr.tsx}
RENAMED
|
@@ -9,7 +9,7 @@ interface Repository {
|
|
|
9
9
|
lastCommit: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableStripedTr: 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: 'Repository 1', branches: 10, prs: 25, workspaces: 5, lastCommit: '2 days ago' },
|
|
@@ -9,7 +9,7 @@ const columnNames = {
|
|
|
9
9
|
wrap: 'Wrapping table header text. This th text will wrap instead of truncate.'
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
export const
|
|
12
|
+
export const TableTextModifiers: React.FunctionComponent = () => (
|
|
13
13
|
<TableComposable aria-label="Table text">
|
|
14
14
|
<Thead>
|
|
15
15
|
<Tr>
|
|
@@ -12,7 +12,7 @@ interface RepositoriesTreeNode {
|
|
|
12
12
|
children?: RepositoriesTreeNode[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const TableTree: React.FunctionComponent = () => {
|
|
16
16
|
// In real usage, this data would come from some external source like an API via props.
|
|
17
17
|
const data: RepositoriesTreeNode[] = [
|
|
18
18
|
{
|