@patternfly/react-data-view 5.3.0 → 5.4.1
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/DataView/DataView.d.ts +4 -2
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +4 -2
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +24 -23
- package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +10 -5
- package/dist/cjs/{DataViewTableHeader/DataViewTableHeader.d.ts → DataViewTableHead/DataViewTableHead.d.ts} +3 -3
- package/dist/cjs/{DataViewTableHeader/DataViewTableHeader.js → DataViewTableHead/DataViewTableHead.js} +6 -6
- package/dist/cjs/{DataViewTableHeader/DataViewTableHeader.test.js → DataViewTableHead/DataViewTableHead.test.js} +5 -5
- package/dist/cjs/DataViewTableHead/index.d.ts +2 -0
- package/dist/cjs/{DataViewTableHeader → DataViewTableHead}/index.js +3 -3
- package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +4 -2
- package/dist/cjs/DataViewTableTree/DataViewTableTree.js +6 -5
- package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +7 -2
- package/dist/cjs/InternalContext/InternalContext.d.ts +9 -3
- package/dist/cjs/InternalContext/InternalContext.js +6 -2
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +4 -4
- package/dist/dynamic/DataViewTableHead/package.json +1 -0
- package/dist/esm/DataView/DataView.d.ts +4 -2
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +4 -2
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +24 -23
- package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +8 -3
- package/dist/esm/{DataViewTableHeader/DataViewTableHeader.d.ts → DataViewTableHead/DataViewTableHead.d.ts} +3 -3
- package/dist/esm/{DataViewTableHeader/DataViewTableHeader.js → DataViewTableHead/DataViewTableHead.js} +4 -4
- package/dist/esm/{DataViewTableHeader/DataViewTableHeader.test.js → DataViewTableHead/DataViewTableHead.test.js} +5 -5
- package/dist/esm/DataViewTableHead/index.d.ts +2 -0
- package/dist/esm/DataViewTableHead/index.js +2 -0
- package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +4 -2
- package/dist/esm/DataViewTableTree/DataViewTableTree.js +7 -6
- package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +7 -2
- package/dist/esm/InternalContext/InternalContext.d.ts +9 -3
- package/dist/esm/InternalContext/InternalContext.js +7 -3
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +2 -2
- package/package.json +1 -1
- package/patternfly-docs/content/extensions/data-view/examples/Components/Components.md +17 -8
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableEmptyExample.tsx +21 -14
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableErrorExample.tsx +9 -2
- package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableLoadingExample.tsx +27 -0
- package/patternfly-docs/content/extensions/data-view/examples/EventsContext/EventsContext.md +1 -0
- package/patternfly-docs/content/extensions/data-view/examples/EventsContext/EventsExample.tsx +27 -5
- package/src/DataView/DataView.tsx +4 -3
- package/src/DataViewTable/DataViewTable.tsx +1 -1
- package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +12 -3
- package/src/DataViewTableBasic/DataViewTableBasic.tsx +46 -48
- package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +71 -30
- package/src/{DataViewTableHeader/DataViewTableHeader.test.tsx → DataViewTableHead/DataViewTableHead.test.tsx} +5 -7
- package/src/{DataViewTableHeader/DataViewTableHeader.tsx → DataViewTableHead/DataViewTableHead.tsx} +6 -6
- package/src/{DataViewTableHeader/__snapshots__/DataViewTableHeader.test.tsx.snap → DataViewTableHead/__snapshots__/DataViewTableHead.test.tsx.snap} +4 -4
- package/src/DataViewTableHead/index.ts +2 -0
- package/src/DataViewTableTree/DataViewTableTree.test.tsx +11 -2
- package/src/DataViewTableTree/DataViewTableTree.tsx +12 -16
- package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +71 -30
- package/src/InternalContext/InternalContext.tsx +24 -12
- package/src/index.ts +2 -2
- package/dist/cjs/DataViewTableHeader/index.d.ts +0 -2
- package/dist/dynamic/DataViewTableHeader/package.json +0 -1
- package/dist/esm/DataViewTableHeader/index.d.ts +0 -2
- package/dist/esm/DataViewTableHeader/index.js +0 -2
- package/src/DataViewTableHeader/index.ts +0 -2
- /package/dist/cjs/{DataViewTableHeader/DataViewTableHeader.test.d.ts → DataViewTableHead/DataViewTableHead.test.d.ts} +0 -0
- /package/dist/esm/{DataViewTableHeader/DataViewTableHeader.test.d.ts → DataViewTableHead/DataViewTableHead.test.d.ts} +0 -0
|
@@ -323,7 +323,7 @@ exports[`DataViewTable component should render correctly 1`] = `
|
|
|
323
323
|
</div>
|
|
324
324
|
`;
|
|
325
325
|
|
|
326
|
-
exports[`DataViewTable component should render with
|
|
326
|
+
exports[`DataViewTable component should render with a loading state 1`] = `
|
|
327
327
|
<div>
|
|
328
328
|
<div
|
|
329
329
|
class="pf-v5-l-stack"
|
|
@@ -393,25 +393,84 @@ exports[`DataViewTable component should render with an empty state 1`] = `
|
|
|
393
393
|
</th>
|
|
394
394
|
</tr>
|
|
395
395
|
</thead>
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
Data is loading
|
|
397
|
+
</table>
|
|
398
|
+
</div>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
`;
|
|
402
|
+
|
|
403
|
+
exports[`DataViewTable component should render with an empty state 1`] = `
|
|
404
|
+
<div>
|
|
405
|
+
<div
|
|
406
|
+
class="pf-v5-l-stack"
|
|
407
|
+
data-ouia-component-id="DataView-stack"
|
|
408
|
+
>
|
|
409
|
+
<div
|
|
410
|
+
class="pf-v5-l-stack__item"
|
|
411
|
+
data-ouia-component-id="DataView-stack-item-0"
|
|
412
|
+
>
|
|
413
|
+
<table
|
|
414
|
+
aria-label="Repositories table"
|
|
415
|
+
class="pf-v5-c-table pf-m-grid-md"
|
|
416
|
+
data-ouia-component-id="TableExample"
|
|
417
|
+
data-ouia-component-type="PF5/Table"
|
|
418
|
+
data-ouia-safe="true"
|
|
419
|
+
role="grid"
|
|
420
|
+
>
|
|
421
|
+
<thead
|
|
422
|
+
class="pf-v5-c-table__thead"
|
|
423
|
+
data-ouia-component-id="TableExample-thead"
|
|
399
424
|
>
|
|
400
425
|
<tr
|
|
401
426
|
class="pf-v5-c-table__tr"
|
|
402
|
-
data-ouia-component-id="TableExample-tr-
|
|
427
|
+
data-ouia-component-id="TableExample-tr-head"
|
|
403
428
|
data-ouia-component-type="PF5/TableRow"
|
|
404
429
|
data-ouia-safe="true"
|
|
405
430
|
>
|
|
406
|
-
<
|
|
407
|
-
class="pf-v5-c-
|
|
408
|
-
|
|
431
|
+
<th
|
|
432
|
+
class="pf-v5-c-table__th"
|
|
433
|
+
data-ouia-component-id="TableExample-th-0"
|
|
434
|
+
scope="col"
|
|
409
435
|
tabindex="-1"
|
|
410
436
|
>
|
|
411
|
-
|
|
412
|
-
</
|
|
437
|
+
Repositories
|
|
438
|
+
</th>
|
|
439
|
+
<th
|
|
440
|
+
class="pf-v5-c-table__th"
|
|
441
|
+
data-ouia-component-id="TableExample-th-1"
|
|
442
|
+
scope="col"
|
|
443
|
+
tabindex="-1"
|
|
444
|
+
>
|
|
445
|
+
Branches
|
|
446
|
+
</th>
|
|
447
|
+
<th
|
|
448
|
+
class="pf-v5-c-table__th"
|
|
449
|
+
data-ouia-component-id="TableExample-th-2"
|
|
450
|
+
scope="col"
|
|
451
|
+
tabindex="-1"
|
|
452
|
+
>
|
|
453
|
+
Pull requests
|
|
454
|
+
</th>
|
|
455
|
+
<th
|
|
456
|
+
class="pf-v5-c-table__th"
|
|
457
|
+
data-ouia-component-id="TableExample-th-3"
|
|
458
|
+
scope="col"
|
|
459
|
+
tabindex="-1"
|
|
460
|
+
>
|
|
461
|
+
Workspaces
|
|
462
|
+
</th>
|
|
463
|
+
<th
|
|
464
|
+
class="pf-v5-c-table__th"
|
|
465
|
+
data-ouia-component-id="TableExample-th-4"
|
|
466
|
+
scope="col"
|
|
467
|
+
tabindex="-1"
|
|
468
|
+
>
|
|
469
|
+
Last commit
|
|
470
|
+
</th>
|
|
413
471
|
</tr>
|
|
414
|
-
</
|
|
472
|
+
</thead>
|
|
473
|
+
No data found
|
|
415
474
|
</table>
|
|
416
475
|
</div>
|
|
417
476
|
</div>
|
|
@@ -488,25 +547,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
|
|
|
488
547
|
</th>
|
|
489
548
|
</tr>
|
|
490
549
|
</thead>
|
|
491
|
-
|
|
492
|
-
class="pf-v5-c-table__tbody"
|
|
493
|
-
role="rowgroup"
|
|
494
|
-
>
|
|
495
|
-
<tr
|
|
496
|
-
class="pf-v5-c-table__tr"
|
|
497
|
-
data-ouia-component-id="TableExample-tr-error"
|
|
498
|
-
data-ouia-component-type="PF5/TableRow"
|
|
499
|
-
data-ouia-safe="true"
|
|
500
|
-
>
|
|
501
|
-
<td
|
|
502
|
-
class="pf-v5-c-table__td"
|
|
503
|
-
colspan="5"
|
|
504
|
-
tabindex="-1"
|
|
505
|
-
>
|
|
506
|
-
Some error
|
|
507
|
-
</td>
|
|
508
|
-
</tr>
|
|
509
|
-
</tbody>
|
|
550
|
+
Some error
|
|
510
551
|
</table>
|
|
511
552
|
</div>
|
|
512
553
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render } from '@testing-library/react';
|
|
3
3
|
import { Table } from '@patternfly/react-table';
|
|
4
|
-
import {
|
|
4
|
+
import { DataViewTableHead } from './DataViewTableHead';
|
|
5
5
|
import { DataViewSelection } from '../InternalContext';
|
|
6
6
|
import { DataView } from '../DataView';
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ const columns = [ 'Repositories', 'Branches', 'Pull requests', 'Workspaces', 'La
|
|
|
9
9
|
|
|
10
10
|
const ouiaId = 'HeaderExample';
|
|
11
11
|
|
|
12
|
-
describe('
|
|
12
|
+
describe('DataViewTableHead component', () => {
|
|
13
13
|
const mockSelection: DataViewSelection = {
|
|
14
14
|
onSelect: jest.fn(),
|
|
15
15
|
isSelected: jest.fn(),
|
|
@@ -19,7 +19,7 @@ describe('DataViewTableHeader component', () => {
|
|
|
19
19
|
test('should render correctly', () => {
|
|
20
20
|
const { container } = render(
|
|
21
21
|
<Table>
|
|
22
|
-
<
|
|
22
|
+
<DataViewTableHead columns={columns} ouiaId={ouiaId} />
|
|
23
23
|
</Table>
|
|
24
24
|
);
|
|
25
25
|
expect(container).toMatchSnapshot();
|
|
@@ -29,7 +29,7 @@ describe('DataViewTableHeader component', () => {
|
|
|
29
29
|
const { container } = render(
|
|
30
30
|
<DataView selection={mockSelection}>
|
|
31
31
|
<Table>
|
|
32
|
-
<
|
|
32
|
+
<DataViewTableHead isTreeTable columns={columns} ouiaId={ouiaId} />
|
|
33
33
|
</Table>
|
|
34
34
|
</DataView>
|
|
35
35
|
);
|
|
@@ -40,7 +40,7 @@ describe('DataViewTableHeader component', () => {
|
|
|
40
40
|
const { container } = render(
|
|
41
41
|
<DataView selection={mockSelection}>
|
|
42
42
|
<Table>
|
|
43
|
-
<
|
|
43
|
+
<DataViewTableHead columns={columns} ouiaId={ouiaId} />
|
|
44
44
|
</Table>
|
|
45
45
|
</DataView>
|
|
46
46
|
);
|
|
@@ -48,5 +48,3 @@ describe('DataViewTableHeader component', () => {
|
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
package/src/{DataViewTableHeader/DataViewTableHeader.tsx → DataViewTableHead/DataViewTableHead.tsx}
RENAMED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { useInternalContext } from '../InternalContext';
|
|
9
9
|
import { DataViewTh, isDataViewThObject } from '../DataViewTable';
|
|
10
10
|
|
|
11
|
-
export interface
|
|
11
|
+
export interface DataViewTableHeadProps extends TheadProps {
|
|
12
12
|
/** Indicates whether table is a tree */
|
|
13
13
|
isTreeTable?: boolean;
|
|
14
14
|
/** Columns definition */
|
|
@@ -17,18 +17,18 @@ export interface DataViewTableHeaderProps extends TheadProps {
|
|
|
17
17
|
ouiaId?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export const
|
|
20
|
+
export const DataViewTableHead: React.FC<DataViewTableHeadProps> = ({
|
|
21
21
|
isTreeTable = false,
|
|
22
22
|
columns,
|
|
23
|
-
ouiaId = '
|
|
23
|
+
ouiaId = 'DataViewTableHead',
|
|
24
24
|
...props
|
|
25
|
-
}:
|
|
25
|
+
}: DataViewTableHeadProps) => {
|
|
26
26
|
const { selection } = useInternalContext();
|
|
27
27
|
const { onSelect, isSelected } = selection ?? {};
|
|
28
28
|
|
|
29
29
|
const cells = useMemo(() => [
|
|
30
30
|
onSelect && isSelected && !isTreeTable ? (
|
|
31
|
-
<Th key="row-select" screenReaderText='Data selection table
|
|
31
|
+
<Th key="row-select" screenReaderText='Data selection table head cell' />
|
|
32
32
|
) : null,
|
|
33
33
|
...columns.map((column, index) => (
|
|
34
34
|
<Th
|
|
@@ -50,4 +50,4 @@ export const DataViewTableHeader: React.FC<DataViewTableHeaderProps> = ({
|
|
|
50
50
|
);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
export default
|
|
53
|
+
export default DataViewTableHead;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`DataViewTableHead component should render correctly 1`] = `
|
|
4
4
|
<div>
|
|
5
5
|
<table
|
|
6
6
|
class="pf-v5-c-table pf-m-grid-md"
|
|
@@ -65,7 +65,7 @@ exports[`DataViewTableHeader component should render correctly 1`] = `
|
|
|
65
65
|
</div>
|
|
66
66
|
`;
|
|
67
67
|
|
|
68
|
-
exports[`
|
|
68
|
+
exports[`DataViewTableHead component should render selection column when selection is provided 1`] = `
|
|
69
69
|
<div>
|
|
70
70
|
<div
|
|
71
71
|
class="pf-v5-l-stack"
|
|
@@ -100,7 +100,7 @@ exports[`DataViewTableHeader component should render selection column when selec
|
|
|
100
100
|
<span
|
|
101
101
|
class="pf-v5-screen-reader"
|
|
102
102
|
>
|
|
103
|
-
Data selection table
|
|
103
|
+
Data selection table head cell
|
|
104
104
|
</span>
|
|
105
105
|
</th>
|
|
106
106
|
<th
|
|
@@ -151,7 +151,7 @@ exports[`DataViewTableHeader component should render selection column when selec
|
|
|
151
151
|
</div>
|
|
152
152
|
`;
|
|
153
153
|
|
|
154
|
-
exports[`
|
|
154
|
+
exports[`DataViewTableHead component should render the tree table correctly when isTreeTable is true 1`] = `
|
|
155
155
|
<div>
|
|
156
156
|
<div
|
|
157
157
|
class="pf-v5-l-stack"
|
|
@@ -86,7 +86,7 @@ describe('DataViewTableTree component', () => {
|
|
|
86
86
|
test('should render tree table with an empty state', () => {
|
|
87
87
|
const { container } = render(
|
|
88
88
|
<DataView activeState="empty">
|
|
89
|
-
<DataViewTable isTreeTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns}
|
|
89
|
+
<DataViewTable isTreeTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} bodyStates={{ empty: "No data found" }} rows={[]} />
|
|
90
90
|
|
|
91
91
|
</DataView>
|
|
92
92
|
);
|
|
@@ -96,9 +96,18 @@ describe('DataViewTableTree component', () => {
|
|
|
96
96
|
test('should render tree table with an error state', () => {
|
|
97
97
|
const { container } = render(
|
|
98
98
|
<DataView activeState="error">
|
|
99
|
-
<DataViewTable isTreeTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns}
|
|
99
|
+
<DataViewTable isTreeTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} bodyStates={{ error: "Some error" }} rows={[]} />
|
|
100
100
|
</DataView>
|
|
101
101
|
);
|
|
102
102
|
expect(container).toMatchSnapshot();
|
|
103
103
|
});
|
|
104
|
+
|
|
105
|
+
test('should render tree table with a loading state', () => {
|
|
106
|
+
const { container } = render(
|
|
107
|
+
<DataView activeState="loading">
|
|
108
|
+
<DataViewTable isTreeTable aria-label='Repositories table' ouiaId={ouiaId} columns={columns} bodyStates={{ loading: "Data is loading" }} rows={[]} />
|
|
109
|
+
</DataView>
|
|
110
|
+
);
|
|
111
|
+
expect(container).toMatchSnapshot();
|
|
112
|
+
});
|
|
104
113
|
});
|
|
@@ -5,11 +5,10 @@ import {
|
|
|
5
5
|
Tbody,
|
|
6
6
|
Td,
|
|
7
7
|
TdProps,
|
|
8
|
-
Tr,
|
|
9
8
|
TreeRowWrapper,
|
|
10
9
|
} from '@patternfly/react-table';
|
|
11
10
|
import { useInternalContext } from '../InternalContext';
|
|
12
|
-
import {
|
|
11
|
+
import { DataViewTableHead } from '../DataViewTableHead';
|
|
13
12
|
import { DataViewTh, DataViewTrTree, isDataViewTdObject } from '../DataViewTable';
|
|
14
13
|
import { DataViewState } from '../DataView/DataView';
|
|
15
14
|
|
|
@@ -36,8 +35,10 @@ export interface DataViewTableTreeProps extends Omit<TableProps, 'onSelect' | 'r
|
|
|
36
35
|
columns: DataViewTh[];
|
|
37
36
|
/** Current page rows */
|
|
38
37
|
rows: DataViewTrTree[];
|
|
39
|
-
/**
|
|
40
|
-
|
|
38
|
+
/** Table head states to be displayed when active */
|
|
39
|
+
headStates?: Partial<Record<DataViewState | string, React.ReactNode>>
|
|
40
|
+
/** Table body states to be displayed when active */
|
|
41
|
+
bodyStates?: Partial<Record<DataViewState | string, React.ReactNode>>
|
|
41
42
|
/** Optional icon for the leaf rows */
|
|
42
43
|
leafIcon?: React.ReactNode;
|
|
43
44
|
/** Optional icon for the expanded parent rows */
|
|
@@ -51,7 +52,8 @@ export interface DataViewTableTreeProps extends Omit<TableProps, 'onSelect' | 'r
|
|
|
51
52
|
export const DataViewTableTree: React.FC<DataViewTableTreeProps> = ({
|
|
52
53
|
columns,
|
|
53
54
|
rows,
|
|
54
|
-
|
|
55
|
+
headStates,
|
|
56
|
+
bodyStates,
|
|
55
57
|
leafIcon = null,
|
|
56
58
|
expandedIcon = null,
|
|
57
59
|
collapsedIcon = null,
|
|
@@ -63,6 +65,9 @@ export const DataViewTableTree: React.FC<DataViewTableTreeProps> = ({
|
|
|
63
65
|
const [ expandedNodeIds, setExpandedNodeIds ] = React.useState<string[]>([]);
|
|
64
66
|
const [ expandedDetailsNodeNames, setExpandedDetailsNodeIds ] = React.useState<string[]>([]);
|
|
65
67
|
|
|
68
|
+
const activeHeadState = useMemo(() => activeState ? headStates?.[activeState] : undefined, [ activeState, headStates ]);
|
|
69
|
+
const activeBodyState = useMemo(() => activeState ? bodyStates?.[activeState] : undefined, [ activeState, bodyStates ]);
|
|
70
|
+
|
|
66
71
|
const nodes = useMemo(() => {
|
|
67
72
|
|
|
68
73
|
const renderRows = (
|
|
@@ -150,17 +155,8 @@ export const DataViewTableTree: React.FC<DataViewTableTreeProps> = ({
|
|
|
150
155
|
|
|
151
156
|
return (
|
|
152
157
|
<Table isTreeTable aria-label="Data table" ouiaId={ouiaId} {...props}>
|
|
153
|
-
<
|
|
154
|
-
<Tbody>{
|
|
155
|
-
activeState && Object.keys(states).includes(activeState) ? (
|
|
156
|
-
<Tr key={activeState} ouiaId={`${ouiaId}-tr-${activeState}`}>
|
|
157
|
-
<Td colSpan={columns.length}>
|
|
158
|
-
{states[activeState]}
|
|
159
|
-
</Td>
|
|
160
|
-
</Tr>
|
|
161
|
-
) : nodes
|
|
162
|
-
}
|
|
163
|
-
</Tbody>
|
|
158
|
+
{activeHeadState || <DataViewTableHead isTreeTable columns={columns} ouiaId={ouiaId} />}
|
|
159
|
+
{activeBodyState || <Tbody>{nodes}</Tbody>}
|
|
164
160
|
</Table>
|
|
165
161
|
);
|
|
166
162
|
};
|
|
@@ -936,7 +936,7 @@ exports[`DataViewTableTree component should render the tree table correctly 1`]
|
|
|
936
936
|
</div>
|
|
937
937
|
`;
|
|
938
938
|
|
|
939
|
-
exports[`DataViewTableTree component should render tree table with
|
|
939
|
+
exports[`DataViewTableTree component should render tree table with a loading state 1`] = `
|
|
940
940
|
<div>
|
|
941
941
|
<div
|
|
942
942
|
class="pf-v5-l-stack"
|
|
@@ -1006,25 +1006,84 @@ exports[`DataViewTableTree component should render tree table with an empty stat
|
|
|
1006
1006
|
</th>
|
|
1007
1007
|
</tr>
|
|
1008
1008
|
</thead>
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1009
|
+
Data is loading
|
|
1010
|
+
</table>
|
|
1011
|
+
</div>
|
|
1012
|
+
</div>
|
|
1013
|
+
</div>
|
|
1014
|
+
`;
|
|
1015
|
+
|
|
1016
|
+
exports[`DataViewTableTree component should render tree table with an empty state 1`] = `
|
|
1017
|
+
<div>
|
|
1018
|
+
<div
|
|
1019
|
+
class="pf-v5-l-stack"
|
|
1020
|
+
data-ouia-component-id="DataView-stack"
|
|
1021
|
+
>
|
|
1022
|
+
<div
|
|
1023
|
+
class="pf-v5-l-stack__item"
|
|
1024
|
+
data-ouia-component-id="DataView-stack-item-0"
|
|
1025
|
+
>
|
|
1026
|
+
<table
|
|
1027
|
+
aria-label="Repositories table"
|
|
1028
|
+
class="pf-v5-c-table pf-m-tree-view-grid-md pf-m-tree-view"
|
|
1029
|
+
data-ouia-component-id="TreeTableExample"
|
|
1030
|
+
data-ouia-component-type="PF5/Table"
|
|
1031
|
+
data-ouia-safe="true"
|
|
1032
|
+
role="treegrid"
|
|
1033
|
+
>
|
|
1034
|
+
<thead
|
|
1035
|
+
class="pf-v5-c-table__thead"
|
|
1036
|
+
data-ouia-component-id="TreeTableExample-thead"
|
|
1012
1037
|
>
|
|
1013
1038
|
<tr
|
|
1014
1039
|
class="pf-v5-c-table__tr"
|
|
1015
|
-
data-ouia-component-id="TreeTableExample-tr-
|
|
1040
|
+
data-ouia-component-id="TreeTableExample-tr-head"
|
|
1016
1041
|
data-ouia-component-type="PF5/TableRow"
|
|
1017
1042
|
data-ouia-safe="true"
|
|
1018
1043
|
>
|
|
1019
|
-
<
|
|
1020
|
-
class="pf-v5-c-
|
|
1021
|
-
|
|
1044
|
+
<th
|
|
1045
|
+
class="pf-v5-c-table__th"
|
|
1046
|
+
data-ouia-component-id="TreeTableExample-th-0"
|
|
1047
|
+
scope="col"
|
|
1022
1048
|
tabindex="-1"
|
|
1023
1049
|
>
|
|
1024
|
-
|
|
1025
|
-
</
|
|
1050
|
+
Repositories
|
|
1051
|
+
</th>
|
|
1052
|
+
<th
|
|
1053
|
+
class="pf-v5-c-table__th"
|
|
1054
|
+
data-ouia-component-id="TreeTableExample-th-1"
|
|
1055
|
+
scope="col"
|
|
1056
|
+
tabindex="-1"
|
|
1057
|
+
>
|
|
1058
|
+
Branches
|
|
1059
|
+
</th>
|
|
1060
|
+
<th
|
|
1061
|
+
class="pf-v5-c-table__th"
|
|
1062
|
+
data-ouia-component-id="TreeTableExample-th-2"
|
|
1063
|
+
scope="col"
|
|
1064
|
+
tabindex="-1"
|
|
1065
|
+
>
|
|
1066
|
+
Pull requests
|
|
1067
|
+
</th>
|
|
1068
|
+
<th
|
|
1069
|
+
class="pf-v5-c-table__th"
|
|
1070
|
+
data-ouia-component-id="TreeTableExample-th-3"
|
|
1071
|
+
scope="col"
|
|
1072
|
+
tabindex="-1"
|
|
1073
|
+
>
|
|
1074
|
+
Workspaces
|
|
1075
|
+
</th>
|
|
1076
|
+
<th
|
|
1077
|
+
class="pf-v5-c-table__th"
|
|
1078
|
+
data-ouia-component-id="TreeTableExample-th-4"
|
|
1079
|
+
scope="col"
|
|
1080
|
+
tabindex="-1"
|
|
1081
|
+
>
|
|
1082
|
+
Last commit
|
|
1083
|
+
</th>
|
|
1026
1084
|
</tr>
|
|
1027
|
-
</
|
|
1085
|
+
</thead>
|
|
1086
|
+
No data found
|
|
1028
1087
|
</table>
|
|
1029
1088
|
</div>
|
|
1030
1089
|
</div>
|
|
@@ -1101,25 +1160,7 @@ exports[`DataViewTableTree component should render tree table with an error stat
|
|
|
1101
1160
|
</th>
|
|
1102
1161
|
</tr>
|
|
1103
1162
|
</thead>
|
|
1104
|
-
|
|
1105
|
-
class="pf-v5-c-table__tbody"
|
|
1106
|
-
role="rowgroup"
|
|
1107
|
-
>
|
|
1108
|
-
<tr
|
|
1109
|
-
class="pf-v5-c-table__tr"
|
|
1110
|
-
data-ouia-component-id="TreeTableExample-tr-error"
|
|
1111
|
-
data-ouia-component-type="PF5/TableRow"
|
|
1112
|
-
data-ouia-safe="true"
|
|
1113
|
-
>
|
|
1114
|
-
<td
|
|
1115
|
-
class="pf-v5-c-table__td"
|
|
1116
|
-
colspan="5"
|
|
1117
|
-
tabindex="-1"
|
|
1118
|
-
>
|
|
1119
|
-
Some error
|
|
1120
|
-
</td>
|
|
1121
|
-
</tr>
|
|
1122
|
-
</tbody>
|
|
1163
|
+
Some error
|
|
1123
1164
|
</table>
|
|
1124
1165
|
</div>
|
|
1125
1166
|
</div>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { createContext, PropsWithChildren, useContext } from 'react';
|
|
1
|
+
import React, { createContext, PropsWithChildren, useContext, useMemo } from 'react';
|
|
2
2
|
import { DataViewState } from '../DataView';
|
|
3
3
|
|
|
4
4
|
export interface DataViewSelection {
|
|
@@ -10,29 +10,41 @@ export interface DataViewSelection {
|
|
|
10
10
|
isSelectDisabled?: (item: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export interface
|
|
13
|
+
export interface InternalContextProps {
|
|
14
|
+
/** Data selection props */
|
|
14
15
|
selection?: DataViewSelection;
|
|
15
|
-
|
|
16
|
+
/** Currently active state */
|
|
17
|
+
activeState?: DataViewState | string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface InternalContextValue extends InternalContextProps {
|
|
21
|
+
/** Flag indicating if data view is selectable (auto-calculated) */
|
|
22
|
+
isSelectable: boolean;
|
|
16
23
|
}
|
|
17
24
|
|
|
18
25
|
export const InternalContext = createContext<InternalContextValue>({
|
|
19
26
|
selection: undefined,
|
|
20
|
-
activeState: undefined
|
|
27
|
+
activeState: undefined,
|
|
28
|
+
isSelectable: false,
|
|
21
29
|
});
|
|
22
30
|
|
|
23
|
-
export type InternalProviderProps = PropsWithChildren<
|
|
31
|
+
export type InternalProviderProps = PropsWithChildren<InternalContextProps>
|
|
24
32
|
|
|
25
33
|
export const InternalContextProvider: React.FC<InternalProviderProps> = ({
|
|
26
34
|
children,
|
|
27
35
|
selection,
|
|
28
36
|
activeState
|
|
29
|
-
}) =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
}) => {
|
|
38
|
+
const isSelectable = useMemo(() => Boolean(selection?.onSelect && selection?.isSelected), [ selection?.onSelect, selection?.isSelected ]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<InternalContext.Provider
|
|
42
|
+
value={{ selection, activeState, isSelectable }}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</InternalContext.Provider>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
36
48
|
|
|
37
49
|
export const useInternalContext = () => useContext(InternalContext);
|
|
38
50
|
|
package/src/index.ts
CHANGED
|
@@ -10,8 +10,8 @@ export * from './DataViewToolbar';
|
|
|
10
10
|
export { default as DataViewTableTree } from './DataViewTableTree';
|
|
11
11
|
export * from './DataViewTableTree';
|
|
12
12
|
|
|
13
|
-
export { default as
|
|
14
|
-
export * from './
|
|
13
|
+
export { default as DataViewTableHead } from './DataViewTableHead';
|
|
14
|
+
export * from './DataViewTableHead';
|
|
15
15
|
|
|
16
16
|
export { default as DataViewTableBasic } from './DataViewTableBasic';
|
|
17
17
|
export * from './DataViewTableBasic';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"main":"../../cjs/DataViewTableHeader/index.js","module":"../../esm/DataViewTableHeader/index.js","typings":"../../esm/DataViewTableHeader/index.d.ts"}
|
|
File without changes
|