@patternfly/react-data-view 6.3.0 → 6.4.0-prerelease.3
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/dist/cjs/DataViewTable/DataViewTable.d.ts +4 -0
- package/dist/cjs/DataViewTable/DataViewTable.js +21 -1
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +2 -0
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +2 -2
- package/dist/cjs/DataViewTableHead/DataViewTableHead.d.ts +2 -0
- package/dist/cjs/DataViewTableHead/DataViewTableHead.js +5 -4
- package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +2 -0
- package/dist/cjs/DataViewTableTree/DataViewTableTree.js +28 -1
- package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +4 -0
- package/dist/cjs/DataViewTh/DataViewTh.d.ts +32 -0
- package/dist/cjs/DataViewTh/DataViewTh.js +222 -0
- package/dist/cjs/Hooks/selection.d.ts +1 -0
- package/dist/cjs/Hooks/selection.js +5 -1
- package/dist/cjs/Hooks/selection.test.js +48 -0
- package/dist/cjs/InternalContext/InternalContext.d.ts +2 -0
- package/dist/esm/DataViewTable/DataViewTable.d.ts +4 -0
- package/dist/esm/DataViewTable/DataViewTable.js +21 -1
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +2 -0
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +2 -2
- package/dist/esm/DataViewTableHead/DataViewTableHead.d.ts +2 -0
- package/dist/esm/DataViewTableHead/DataViewTableHead.js +5 -4
- package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +2 -0
- package/dist/esm/DataViewTableTree/DataViewTableTree.js +29 -2
- package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +4 -0
- package/dist/esm/DataViewTh/DataViewTh.d.ts +32 -0
- package/dist/esm/DataViewTh/DataViewTh.js +215 -0
- package/dist/esm/Hooks/selection.d.ts +1 -0
- package/dist/esm/Hooks/selection.js +5 -1
- package/dist/esm/Hooks/selection.test.js +48 -0
- package/dist/esm/InternalContext/InternalContext.d.ts +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableResizableColumnsExample.tsx +155 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableTreeExample.tsx +1 -0
- package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +52 -14
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/SelectionExample.tsx +14 -3
- package/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md +1 -0
- package/release.config.js +1 -1
- package/src/DataViewCheckboxFilter/__snapshots__/DataViewCheckboxFilter.test.tsx.snap +0 -2
- package/src/DataViewFilters/__snapshots__/DataViewFilters.test.tsx.snap +0 -2
- package/src/DataViewTable/DataViewTable.tsx +48 -27
- package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +10 -18
- package/src/DataViewTableBasic/DataViewTableBasic.tsx +4 -1
- package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +20 -20
- package/src/DataViewTableHead/DataViewTableHead.tsx +24 -23
- package/src/DataViewTableHead/__snapshots__/DataViewTableHead.test.tsx.snap +15 -15
- package/src/DataViewTableTree/DataViewTableTree.test.tsx +9 -0
- package/src/DataViewTableTree/DataViewTableTree.tsx +35 -1
- package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +977 -28
- package/src/DataViewTextFilter/__snapshots__/DataViewTextFilter.test.tsx.snap +0 -3
- package/src/DataViewTh/DataViewTh.tsx +342 -0
- package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +0 -10
- package/src/Hooks/selection.test.tsx +65 -1
- package/src/Hooks/selection.ts +6 -1
- package/src/InternalContext/InternalContext.tsx +2 -0
package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableTreeExample.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { DataViewTable, DataViewTh, DataViewTrTree } from '@patternfly/react-dat
|
|
|
4
4
|
import { useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
|
|
5
5
|
import { FolderIcon, FolderOpenIcon, LeafIcon } from '@patternfly/react-icons';
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
interface Repository {
|
|
8
9
|
name: string;
|
|
9
10
|
branches: string | null;
|
|
@@ -12,10 +12,19 @@ source: react
|
|
|
12
12
|
# If you use typescript, the name of the interface to display props for
|
|
13
13
|
# These are found through the sourceProps function provided in patternfly-docs.source.js
|
|
14
14
|
sortValue: 3
|
|
15
|
-
propComponents:
|
|
15
|
+
propComponents:
|
|
16
|
+
[
|
|
17
|
+
'DataViewTableBasic',
|
|
18
|
+
'DataViewTableTree',
|
|
19
|
+
'DataViewTrTree',
|
|
20
|
+
'DataViewTrObject',
|
|
21
|
+
'DataViewTh',
|
|
22
|
+
'DataViewThResizableProps'
|
|
23
|
+
]
|
|
16
24
|
sourceLink: https://github.com/patternfly/react-data-view/blob/main/packages/module/patternfly-docs/content/extensions/data-view/examples/Table/Table.md
|
|
17
25
|
---
|
|
18
|
-
|
|
26
|
+
|
|
27
|
+
import { FunctionComponent, useMemo, useState } from 'react';
|
|
19
28
|
import { BrowserRouter, useSearchParams } from 'react-router-dom';
|
|
20
29
|
import { Button, EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter } from '@patternfly/react-core';
|
|
21
30
|
import { CubesIcon, FolderIcon, FolderOpenIcon, LeafIcon, ExclamationCircleIcon } from '@patternfly/react-icons';
|
|
@@ -28,7 +37,9 @@ import { DataView, DataViewState } from '@patternfly/react-data-view/dist/dynami
|
|
|
28
37
|
The **data view table** component renders your data into columns and rows within a [PatternFly table](/components/table) component. You can easily customize and configure the table with these additional [data view components and props](/extensions/data-view/table#props).
|
|
29
38
|
|
|
30
39
|
## Configuring rows and columns
|
|
40
|
+
|
|
31
41
|
To define rows and columns for your table, use these props:
|
|
42
|
+
|
|
32
43
|
- `columns`: Defines the column heads of the table. Each item in the array can be a `ReactNode` for simple heads, or an object with the following properties:
|
|
33
44
|
- `cell`: Content to display in the column head.
|
|
34
45
|
- `props` (optional): (`ThProps`) to pass to the `<Th>` component, such as `width`, `sort`, and other table head cell properties.
|
|
@@ -39,21 +50,41 @@ To define rows and columns for your table, use these props:
|
|
|
39
50
|
|
|
40
51
|
It is also possible to disable row selection using the `isSelectDisabled` function, which can be passed to the wrapping `DataView` component through the `selection` prop.
|
|
41
52
|
|
|
53
|
+
If you want to have all expandable nodes open on initial load pass the `expandAll` prop to the DataViewTable component
|
|
54
|
+
|
|
42
55
|
### Table example
|
|
56
|
+
|
|
43
57
|
```js file="./DataViewTableExample.tsx"
|
|
44
58
|
|
|
45
59
|
```
|
|
46
60
|
|
|
61
|
+
### Resizable columns
|
|
62
|
+
|
|
63
|
+
To allow a column to resize, add `isResizable` to the `DataViewTable` element, and pass `resizableProps` to each applicable header cell. The `resizableProps` object consists of the following fields:
|
|
64
|
+
|
|
65
|
+
- `isResizable` - indicates that the column is resizable
|
|
66
|
+
- `resizeButtonAriaLabel` - an accessible name for the resizable column's resize button. This must be passed in if the column is resizable.
|
|
67
|
+
- `onResize` - a callback that will return the source event and the new width of the column
|
|
68
|
+
- `width` - a default width value for a column
|
|
69
|
+
- `minWidth` - the minimum width a column may shrink to
|
|
70
|
+
- `increment` - how many pixels the column will move left or right for keyboard navigation
|
|
71
|
+
- `shiftIncrement` - how many pixels the column will move left or right while shift is held for keyboard navigation
|
|
72
|
+
- `screenReaderText` - text that will be announced when a column is resized
|
|
73
|
+
|
|
74
|
+
```js file="./DataViewTableResizableColumnsExample.tsx"
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
47
78
|
## Tree table
|
|
48
79
|
|
|
49
|
-
A tree table includes expandable rows and custom icons for leaf and parent nodes.
|
|
80
|
+
A tree table includes expandable rows and custom icons for leaf and parent nodes.
|
|
50
81
|
To enable a tree table, pass the `isTreeTable` flag to the `<DataViewTable>` component.
|
|
51
82
|
|
|
52
|
-
|
|
53
83
|
Tree table rows have to be defined with following keys:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
84
|
+
|
|
85
|
+
- `row`: Defines the content for each cell in the row.
|
|
86
|
+
- `id`: Unique identifier for the row that's used for matching selected items.
|
|
87
|
+
- `children` (optional): Defines the children rows.
|
|
57
88
|
|
|
58
89
|
To update a row's icon to reflect its expansion state, pass `collapsedIcon`, `expandedIcon`, and `leafIcon` to `<DataViewTable>`.
|
|
59
90
|
|
|
@@ -66,17 +97,21 @@ To disable row selection, pass the `isSelectDisabled` function to `selection` pr
|
|
|
66
97
|
```
|
|
67
98
|
|
|
68
99
|
## Sorting
|
|
100
|
+
|
|
69
101
|
The following example demonstrates how to enable sorting functionality within a data view. This implementation supports dynamic sorting by column and persists the sort state in the page's URL via [React Router](https://reactrouter.com/).
|
|
70
102
|
|
|
71
103
|
### Sorting example
|
|
104
|
+
|
|
72
105
|
```js file="./SortingExample.tsx"
|
|
73
106
|
|
|
74
107
|
```
|
|
108
|
+
|
|
75
109
|
### Sorting state
|
|
76
110
|
|
|
77
111
|
The `useDataViewSort` hook manages the sorting state of a data view and provides an easy way to handle sorting logic, such as synchronization with URL parameters and the definition of default sorting behavior.
|
|
78
112
|
|
|
79
113
|
**Initial values:**
|
|
114
|
+
|
|
80
115
|
- `initialSort` object to set default `sortBy` and `direction` values:
|
|
81
116
|
- `sortBy`: Key of the initial column to sort.
|
|
82
117
|
- `direction`: Default sorting direction (`asc` or `desc`).
|
|
@@ -86,44 +121,47 @@ The `useDataViewSort` hook manages the sorting state of a data view and provides
|
|
|
86
121
|
- Customizable parameter names for the URL:
|
|
87
122
|
- `sortByParam`: Name of the URL parameter for the column key.
|
|
88
123
|
- `directionParam`: Name of the URL parameter for the sorting direction.
|
|
89
|
-
The `useDataViewSort` hook integrates seamlessly with [React Router](https://reactrouter.com/) to manage the sort state via URL parameters. Alternatively, you can use `URLSearchParams` and `window.history.pushState` APIs, or other routing libraries. If URL synchronization is not configured, the sort state is managed internally within the component.
|
|
124
|
+
The `useDataViewSort` hook integrates seamlessly with [React Router](https://reactrouter.com/) to manage the sort state via URL parameters. Alternatively, you can use `URLSearchParams` and `window.history.pushState` APIs, or other routing libraries. If URL synchronization is not configured, the sort state is managed internally within the component.
|
|
90
125
|
|
|
91
126
|
**Return values:**
|
|
127
|
+
|
|
92
128
|
- `sortBy`: Key of the column currently being sorted.
|
|
93
129
|
- `direction`: Current sorting direction (`asc` or `desc`).
|
|
94
130
|
- `onSort`: Function to handle sorting changes programmatically or via user interaction.
|
|
95
131
|
|
|
96
132
|
## States
|
|
97
133
|
|
|
98
|
-
The data view table allows you to react to the `activeState` of the data view (such as `empty`, `error`, `loading`). You can use the `headStates` and `bodyStates` props to define the table head and body for a given state.
|
|
134
|
+
The data view table allows you to react to the `activeState` of the data view (such as `empty`, `error`, `loading`). You can use the `headStates` and `bodyStates` props to define the table head and body for a given state.
|
|
99
135
|
|
|
100
136
|
### Empty
|
|
101
|
-
When there is no data to render in the data view, you can instead display an empty state.
|
|
102
137
|
|
|
103
|
-
|
|
138
|
+
When there is no data to render in the data view, you can instead display an empty state.
|
|
139
|
+
|
|
140
|
+
You can create your empty state by passing a [PatternFly empty state](/components/empty-state) to the `empty` key of `headStates` or `bodyStates`.
|
|
104
141
|
|
|
105
142
|
```js file="./DataViewTableEmptyExample.tsx"
|
|
106
143
|
|
|
107
144
|
```
|
|
108
145
|
|
|
109
146
|
### Error
|
|
147
|
+
|
|
110
148
|
When there is a data connection or retrieval error, you can display an error state.
|
|
111
149
|
|
|
112
150
|
The error state will be displayed when the data view `activeState` value is `error`.
|
|
113
151
|
|
|
114
|
-
You can create your error state by passing either the [component groups extension's error state](/component-groups/error-state) or a [PatternFly empty state](/components/empty-state) to the `error` key of `headStates` or `bodyStates`.
|
|
152
|
+
You can create your error state by passing either the [component groups extension's error state](/component-groups/error-state) or a [PatternFly empty state](/components/empty-state) to the `error` key of `headStates` or `bodyStates`.
|
|
115
153
|
|
|
116
154
|
```js file="./DataViewTableErrorExample.tsx"
|
|
117
155
|
|
|
118
156
|
```
|
|
119
157
|
|
|
120
158
|
### Loading
|
|
159
|
+
|
|
121
160
|
To indicate that data is loading, you can display a loading state.
|
|
122
161
|
|
|
123
162
|
The loading state will be displayed when the data view `activeState` value is `loading`.
|
|
124
163
|
|
|
125
|
-
You can create your loading state by passing either the [component groups extension's skeleton table](/component-groups/skeleton-table) or a customized [PatternFly empty state](/components/empty-state) to the `loading` key of `headStates` or `bodyStates`.
|
|
126
|
-
|
|
164
|
+
You can create your loading state by passing either the [component groups extension's skeleton table](/component-groups/skeleton-table) or a customized [PatternFly empty state](/components/empty-state) to the `loading` key of `headStates` or `bodyStates`.
|
|
127
165
|
|
|
128
166
|
```js file="./DataViewTableLoadingExample.tsx"
|
|
129
167
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useDataViewSelection } from '@patternfly/react-data-view/dist/dynamic/Hooks';
|
|
3
3
|
import { BulkSelect, BulkSelectValue } from '@patternfly/react-component-groups/dist/dynamic/BulkSelect';
|
|
4
|
+
import { Button } from '@patternfly/react-core';
|
|
4
5
|
import { DataView } from '@patternfly/react-data-view/dist/dynamic/DataView';
|
|
5
6
|
import { DataViewToolbar } from '@patternfly/react-data-view/dist/dynamic/DataViewToolbar';
|
|
6
7
|
import { DataViewTable } from '@patternfly/react-data-view/dist/dynamic/DataViewTable';
|
|
@@ -30,13 +31,18 @@ const ouiaId = 'LayoutExample';
|
|
|
30
31
|
|
|
31
32
|
export const BasicExample: React.FunctionComponent = () => {
|
|
32
33
|
const selection = useDataViewSelection({ matchOption: (a, b) => a[0] === b[0] });
|
|
33
|
-
const { selected, onSelect } = selection;
|
|
34
|
+
const { selected, onSelect, setSelected } = selection;
|
|
34
35
|
|
|
35
36
|
const handleBulkSelect = (value: BulkSelectValue) => {
|
|
36
37
|
value === BulkSelectValue.none && onSelect(false);
|
|
37
38
|
value === BulkSelectValue.all && onSelect(true, rows);
|
|
38
39
|
};
|
|
39
40
|
|
|
41
|
+
// Example: Select first two rows programmatically using setSelected
|
|
42
|
+
const handleSelectFirstTwo = () => {
|
|
43
|
+
setSelected(rows.slice(0, 2));
|
|
44
|
+
};
|
|
45
|
+
|
|
40
46
|
return (
|
|
41
47
|
<DataView selection={selection}>
|
|
42
48
|
<DataViewToolbar
|
|
@@ -49,9 +55,14 @@ export const BasicExample: React.FunctionComponent = () => {
|
|
|
49
55
|
selectedCount={selected.length}
|
|
50
56
|
onSelect={handleBulkSelect}
|
|
51
57
|
/>
|
|
52
|
-
}
|
|
58
|
+
}
|
|
59
|
+
actions={
|
|
60
|
+
<Button variant="secondary" onClick={handleSelectFirstTwo}>
|
|
61
|
+
Select First Two
|
|
62
|
+
</Button>
|
|
63
|
+
}
|
|
53
64
|
/>
|
|
54
65
|
<DataViewTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} rows={rows} />
|
|
55
66
|
</DataView>
|
|
56
67
|
);
|
|
57
|
-
}
|
|
68
|
+
}
|
|
@@ -105,6 +105,7 @@ The `useDataViewSelection` hook manages the selection state of the data view.
|
|
|
105
105
|
- `selected` array of currently selected records.
|
|
106
106
|
- `isSelected` function returning the selection state for the record.
|
|
107
107
|
- `onSelect` callback to modify the selection state. This accepts the `isSelecting` flag (indicates if records are being selected or deselected) and `items` (affected records).
|
|
108
|
+
- `setSelected` function to directly set the selected items array. This is useful for programmatically setting a specific selection state without needing to use the `onSelect` callback.
|
|
108
109
|
|
|
109
110
|
### Selection example
|
|
110
111
|
|
package/release.config.js
CHANGED
|
@@ -135,7 +135,6 @@ exports[`DataViewCheckboxFilter component should render correctly 1`] = `
|
|
|
135
135
|
class="pf-v6-c-label__actions"
|
|
136
136
|
>
|
|
137
137
|
<button
|
|
138
|
-
aria-disabled="false"
|
|
139
138
|
aria-label="Close Workspace one"
|
|
140
139
|
class="pf-v6-c-button pf-m-plain pf-m-no-padding"
|
|
141
140
|
data-ouia-component-id="OUIA-Generated-Button-plain-1"
|
|
@@ -176,7 +175,6 @@ exports[`DataViewCheckboxFilter component should render correctly 1`] = `
|
|
|
176
175
|
class="pf-v6-c-toolbar__item"
|
|
177
176
|
>
|
|
178
177
|
<button
|
|
179
|
-
aria-disabled="false"
|
|
180
178
|
class="pf-v6-c-button pf-m-link pf-m-inline"
|
|
181
179
|
data-ouia-component-id="DataViewToolbar-clear-all-filters"
|
|
182
180
|
data-ouia-component-type="PF6/Button"
|
|
@@ -26,7 +26,6 @@ exports[`DataViewFilters component should render correctly 1`] = `
|
|
|
26
26
|
class="pf-v6-c-toolbar__toggle"
|
|
27
27
|
>
|
|
28
28
|
<button
|
|
29
|
-
aria-disabled="false"
|
|
30
29
|
aria-haspopup="false"
|
|
31
30
|
aria-label="Show Filters"
|
|
32
31
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -173,7 +172,6 @@ exports[`DataViewFilters component should render correctly 1`] = `
|
|
|
173
172
|
class="pf-v6-c-toolbar__item"
|
|
174
173
|
>
|
|
175
174
|
<button
|
|
176
|
-
aria-disabled="false"
|
|
177
175
|
class="pf-v6-c-button pf-m-link pf-m-inline"
|
|
178
176
|
data-ouia-component-id="DataViewToolbar-clear-all-filters"
|
|
179
177
|
data-ouia-component-type="PF6/Button"
|
|
@@ -1,46 +1,55 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
TdProps,
|
|
4
|
-
ThProps,
|
|
5
|
-
TrProps
|
|
6
|
-
} from '@patternfly/react-table';
|
|
2
|
+
import { TdProps, ThProps, TrProps, InnerScrollContainer } from '@patternfly/react-table';
|
|
7
3
|
import { DataViewTableTree, DataViewTableTreeProps } from '../DataViewTableTree';
|
|
8
4
|
import { DataViewTableBasic, DataViewTableBasicProps } from '../DataViewTableBasic';
|
|
5
|
+
import { DataViewThResizableProps } from '../DataViewTh/DataViewTh';
|
|
9
6
|
|
|
10
7
|
// Table head typings
|
|
11
|
-
export type DataViewTh =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
export type DataViewTh =
|
|
9
|
+
| ReactNode
|
|
10
|
+
| {
|
|
11
|
+
/** Table head cell node */
|
|
12
|
+
cell: ReactNode;
|
|
13
|
+
/** Additional props for a resizable column */
|
|
14
|
+
resizableProps?: DataViewThResizableProps;
|
|
15
|
+
/** Props passed to Th */
|
|
16
|
+
props?: ThProps;
|
|
17
|
+
};
|
|
18
|
+
export const isDataViewThObject = (value: DataViewTh): value is { cell: ReactNode; props?: ThProps } =>
|
|
19
|
+
value != null && typeof value === 'object' && 'cell' in value;
|
|
18
20
|
|
|
19
21
|
// Basic table typings
|
|
20
22
|
export interface DataViewTrObject {
|
|
21
23
|
/** Array of rows */
|
|
22
|
-
row: DataViewTd[]
|
|
24
|
+
row: DataViewTd[];
|
|
23
25
|
/** Unique identifier of a row */
|
|
24
|
-
id?: string
|
|
26
|
+
id?: string;
|
|
25
27
|
/** Props passed to Tr */
|
|
26
|
-
props?: TrProps
|
|
28
|
+
props?: TrProps;
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
export type DataViewTd =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
export type DataViewTd =
|
|
32
|
+
| ReactNode
|
|
33
|
+
| {
|
|
34
|
+
/** Table body cell node */
|
|
35
|
+
cell: ReactNode;
|
|
36
|
+
/** Props passed to Td */
|
|
37
|
+
props?: TdProps;
|
|
38
|
+
};
|
|
35
39
|
|
|
36
40
|
export type DataViewTr = DataViewTd[] | DataViewTrObject;
|
|
37
41
|
|
|
38
|
-
export const isDataViewTdObject = (value: DataViewTd): value is { cell: ReactNode; props?: TdProps } =>
|
|
39
|
-
|
|
42
|
+
export const isDataViewTdObject = (value: DataViewTd): value is { cell: ReactNode; props?: TdProps } =>
|
|
43
|
+
value != null && typeof value === 'object' && 'cell' in value;
|
|
44
|
+
export const isDataViewTrObject = (value: DataViewTr): value is { row: DataViewTd[]; id?: string } =>
|
|
45
|
+
value != null && typeof value === 'object' && 'row' in value;
|
|
40
46
|
|
|
41
47
|
// Tree table typings
|
|
42
48
|
/** extends DataViewTrObject */
|
|
43
|
-
export interface DataViewTrTree extends DataViewTrObject {
|
|
49
|
+
export interface DataViewTrTree extends DataViewTrObject {
|
|
50
|
+
id: string;
|
|
51
|
+
children?: DataViewTrTree[];
|
|
52
|
+
}
|
|
44
53
|
|
|
45
54
|
export type DataViewTableProps =
|
|
46
55
|
| ({
|
|
@@ -48,10 +57,22 @@ export type DataViewTableProps =
|
|
|
48
57
|
} & DataViewTableTreeProps)
|
|
49
58
|
| ({
|
|
50
59
|
isTreeTable?: false;
|
|
60
|
+
isResizable?: boolean;
|
|
51
61
|
} & DataViewTableBasicProps);
|
|
52
62
|
|
|
53
|
-
export const DataViewTable: FC<DataViewTableProps> = (props) =>
|
|
54
|
-
props.isTreeTable
|
|
55
|
-
|
|
63
|
+
export const DataViewTable: FC<DataViewTableProps> = (props) => {
|
|
64
|
+
if (props.isTreeTable) {
|
|
65
|
+
return <DataViewTableTree {...props} />;
|
|
66
|
+
} else {
|
|
67
|
+
const { isResizable, ...rest } = props;
|
|
68
|
+
return isResizable ? (
|
|
69
|
+
<InnerScrollContainer>
|
|
70
|
+
<DataViewTableBasic hasResizableColumns {...rest} />
|
|
71
|
+
</InnerScrollContainer>
|
|
72
|
+
) : (
|
|
73
|
+
<DataViewTableBasic {...rest} />
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
56
77
|
|
|
57
78
|
export default DataViewTable;
|
|
@@ -21,7 +21,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
21
21
|
data-ouia-safe="true"
|
|
22
22
|
>
|
|
23
23
|
<th
|
|
24
|
-
class="pf-v6-c-table__th"
|
|
24
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
25
25
|
data-ouia-component-id="TableExample-th-0"
|
|
26
26
|
scope="col"
|
|
27
27
|
tabindex="-1"
|
|
@@ -29,7 +29,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
29
29
|
Repositories
|
|
30
30
|
</th>
|
|
31
31
|
<th
|
|
32
|
-
class="pf-v6-c-table__th"
|
|
32
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
33
33
|
data-ouia-component-id="TableExample-th-1"
|
|
34
34
|
scope="col"
|
|
35
35
|
tabindex="-1"
|
|
@@ -37,7 +37,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
37
37
|
Branches
|
|
38
38
|
</th>
|
|
39
39
|
<th
|
|
40
|
-
class="pf-v6-c-table__th"
|
|
40
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
41
41
|
data-ouia-component-id="TableExample-th-2"
|
|
42
42
|
scope="col"
|
|
43
43
|
tabindex="-1"
|
|
@@ -45,7 +45,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
45
45
|
Pull requests
|
|
46
46
|
</th>
|
|
47
47
|
<th
|
|
48
|
-
class="pf-v6-c-table__th"
|
|
48
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
49
49
|
data-ouia-component-id="TableExample-th-3"
|
|
50
50
|
scope="col"
|
|
51
51
|
tabindex="-1"
|
|
@@ -53,7 +53,7 @@ exports[`DataViewTable component should render a basic table correctly 1`] = `
|
|
|
53
53
|
Workspaces
|
|
54
54
|
</th>
|
|
55
55
|
<th
|
|
56
|
-
class="pf-v6-c-table__th"
|
|
56
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
57
57
|
data-ouia-component-id="TableExample-th-4"
|
|
58
58
|
scope="col"
|
|
59
59
|
tabindex="-1"
|
|
@@ -344,7 +344,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
344
344
|
data-ouia-safe="true"
|
|
345
345
|
>
|
|
346
346
|
<th
|
|
347
|
-
class="pf-v6-c-table__th"
|
|
347
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
348
348
|
data-ouia-component-id="TableExample-th-0"
|
|
349
349
|
scope="col"
|
|
350
350
|
tabindex="-1"
|
|
@@ -352,7 +352,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
352
352
|
Repositories
|
|
353
353
|
</th>
|
|
354
354
|
<th
|
|
355
|
-
class="pf-v6-c-table__th"
|
|
355
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
356
356
|
data-ouia-component-id="TableExample-th-1"
|
|
357
357
|
scope="col"
|
|
358
358
|
tabindex="-1"
|
|
@@ -360,7 +360,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
360
360
|
Branches
|
|
361
361
|
</th>
|
|
362
362
|
<th
|
|
363
|
-
class="pf-v6-c-table__th"
|
|
363
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
364
364
|
data-ouia-component-id="TableExample-th-2"
|
|
365
365
|
scope="col"
|
|
366
366
|
tabindex="-1"
|
|
@@ -368,7 +368,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
368
368
|
Pull requests
|
|
369
369
|
</th>
|
|
370
370
|
<th
|
|
371
|
-
class="pf-v6-c-table__th"
|
|
371
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
372
372
|
data-ouia-component-id="TableExample-th-3"
|
|
373
373
|
scope="col"
|
|
374
374
|
tabindex="-1"
|
|
@@ -376,7 +376,7 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
376
376
|
Workspaces
|
|
377
377
|
</th>
|
|
378
378
|
<th
|
|
379
|
-
class="pf-v6-c-table__th"
|
|
379
|
+
class="pf-v6-c-table__th pf-m-truncate"
|
|
380
380
|
data-ouia-component-id="TableExample-th-4"
|
|
381
381
|
scope="col"
|
|
382
382
|
tabindex="-1"
|
|
@@ -411,7 +411,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
411
411
|
class="pf-v6-c-table__toggle"
|
|
412
412
|
>
|
|
413
413
|
<button
|
|
414
|
-
aria-disabled="false"
|
|
415
414
|
aria-expanded="false"
|
|
416
415
|
aria-label="Expand row 0"
|
|
417
416
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -457,7 +456,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
457
456
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
458
457
|
>
|
|
459
458
|
<button
|
|
460
|
-
aria-disabled="false"
|
|
461
459
|
aria-expanded="false"
|
|
462
460
|
aria-label="Show row details"
|
|
463
461
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -553,7 +551,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
553
551
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
554
552
|
>
|
|
555
553
|
<button
|
|
556
|
-
aria-disabled="false"
|
|
557
554
|
aria-expanded="false"
|
|
558
555
|
aria-label="Show row details"
|
|
559
556
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -649,7 +646,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
649
646
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
650
647
|
>
|
|
651
648
|
<button
|
|
652
|
-
aria-disabled="false"
|
|
653
649
|
aria-expanded="false"
|
|
654
650
|
aria-label="Show row details"
|
|
655
651
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -735,7 +731,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
735
731
|
class="pf-v6-c-table__toggle"
|
|
736
732
|
>
|
|
737
733
|
<button
|
|
738
|
-
aria-disabled="false"
|
|
739
734
|
aria-expanded="false"
|
|
740
735
|
aria-label="Expand row 3"
|
|
741
736
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -781,7 +776,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
781
776
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
782
777
|
>
|
|
783
778
|
<button
|
|
784
|
-
aria-disabled="false"
|
|
785
779
|
aria-expanded="false"
|
|
786
780
|
aria-label="Show row details"
|
|
787
781
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -877,7 +871,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
877
871
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
878
872
|
>
|
|
879
873
|
<button
|
|
880
|
-
aria-disabled="false"
|
|
881
874
|
aria-expanded="false"
|
|
882
875
|
aria-label="Show row details"
|
|
883
876
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -972,7 +965,6 @@ exports[`DataViewTable component should render a tree table correctly 1`] = `
|
|
|
972
965
|
class="pf-v6-c-table__tree-view-details-toggle"
|
|
973
966
|
>
|
|
974
967
|
<button
|
|
975
|
-
aria-disabled="false"
|
|
976
968
|
aria-expanded="false"
|
|
977
969
|
aria-label="Show row details"
|
|
978
970
|
class="pf-v6-c-button pf-m-plain"
|
|
@@ -23,6 +23,8 @@ export interface DataViewTableBasicProps extends Omit<TableProps, 'onSelect' | '
|
|
|
23
23
|
bodyStates?: Partial<Record<DataViewState | string, React.ReactNode>>
|
|
24
24
|
/** Custom OUIA ID */
|
|
25
25
|
ouiaId?: string;
|
|
26
|
+
/** @hide Indicates if the table is resizable */
|
|
27
|
+
hasResizableColumns?: boolean;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
export const DataViewTableBasic: FC<DataViewTableBasicProps> = ({
|
|
@@ -31,6 +33,7 @@ export const DataViewTableBasic: FC<DataViewTableBasicProps> = ({
|
|
|
31
33
|
ouiaId = 'DataViewTableBasic',
|
|
32
34
|
headStates,
|
|
33
35
|
bodyStates,
|
|
36
|
+
hasResizableColumns,
|
|
34
37
|
...props
|
|
35
38
|
}: DataViewTableBasicProps) => {
|
|
36
39
|
const { selection, activeState, isSelectable } = useInternalContext();
|
|
@@ -74,7 +77,7 @@ export const DataViewTableBasic: FC<DataViewTableBasicProps> = ({
|
|
|
74
77
|
|
|
75
78
|
return (
|
|
76
79
|
<Table aria-label="Data table" ouiaId={ouiaId} {...props}>
|
|
77
|
-
{ activeHeadState || <DataViewTableHead columns={columns} ouiaId={ouiaId} /> }
|
|
80
|
+
{ activeHeadState || <DataViewTableHead columns={columns} ouiaId={ouiaId} hasResizableColumns={hasResizableColumns} /> }
|
|
78
81
|
{ activeBodyState || <Tbody>{renderedRows}</Tbody> }
|
|
79
82
|
</Table>
|
|
80
83
|
);
|