@patternfly/react-data-view 6.3.0-prerelease.3 → 6.4.0-prerelease.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/dist/cjs/DataViewTable/DataViewTable.d.ts +6 -1
  2. package/dist/cjs/DataViewTable/DataViewTable.js +21 -1
  3. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +13 -0
  4. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +46 -6
  5. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +47 -9
  6. package/dist/cjs/DataViewTableHead/DataViewTableHead.d.ts +2 -0
  7. package/dist/cjs/DataViewTableHead/DataViewTableHead.js +5 -4
  8. package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +2 -0
  9. package/dist/cjs/DataViewTableTree/DataViewTableTree.js +28 -1
  10. package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +4 -0
  11. package/dist/cjs/DataViewTh/DataViewTh.d.ts +32 -0
  12. package/dist/cjs/DataViewTh/DataViewTh.js +222 -0
  13. package/dist/cjs/DataViewTh/index.d.ts +2 -0
  14. package/dist/cjs/DataViewTh/index.js +23 -0
  15. package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.d.ts +26 -0
  16. package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.js +229 -0
  17. package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.test.d.ts +1 -0
  18. package/dist/cjs/DataViewTreeFilter/DataViewTreeFilter.test.js +171 -0
  19. package/dist/cjs/DataViewTreeFilter/index.d.ts +2 -0
  20. package/dist/cjs/DataViewTreeFilter/index.js +23 -0
  21. package/dist/cjs/Hooks/selection.d.ts +1 -0
  22. package/dist/cjs/Hooks/selection.js +5 -1
  23. package/dist/cjs/Hooks/selection.test.js +48 -0
  24. package/dist/cjs/InternalContext/InternalContext.d.ts +2 -0
  25. package/dist/cjs/index.d.ts +6 -0
  26. package/dist/cjs/index.js +10 -1
  27. package/dist/dynamic/DataViewTh/package.json +1 -0
  28. package/dist/dynamic/DataViewTreeFilter/package.json +1 -0
  29. package/dist/dynamic-modules.json +62 -0
  30. package/dist/esm/DataViewTable/DataViewTable.d.ts +6 -1
  31. package/dist/esm/DataViewTable/DataViewTable.js +21 -1
  32. package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +13 -0
  33. package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +48 -8
  34. package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +45 -10
  35. package/dist/esm/DataViewTableHead/DataViewTableHead.d.ts +2 -0
  36. package/dist/esm/DataViewTableHead/DataViewTableHead.js +5 -4
  37. package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +2 -0
  38. package/dist/esm/DataViewTableTree/DataViewTableTree.js +29 -2
  39. package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +4 -0
  40. package/dist/esm/DataViewTh/DataViewTh.d.ts +32 -0
  41. package/dist/esm/DataViewTh/DataViewTh.js +215 -0
  42. package/dist/esm/DataViewTh/index.d.ts +2 -0
  43. package/dist/esm/DataViewTh/index.js +2 -0
  44. package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.d.ts +26 -0
  45. package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.js +225 -0
  46. package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.test.d.ts +1 -0
  47. package/dist/esm/DataViewTreeFilter/DataViewTreeFilter.test.js +166 -0
  48. package/dist/esm/DataViewTreeFilter/index.d.ts +2 -0
  49. package/dist/esm/DataViewTreeFilter/index.js +2 -0
  50. package/dist/esm/Hooks/selection.d.ts +1 -0
  51. package/dist/esm/Hooks/selection.js +5 -1
  52. package/dist/esm/Hooks/selection.test.js +48 -0
  53. package/dist/esm/InternalContext/InternalContext.d.ts +2 -0
  54. package/dist/esm/index.d.ts +6 -0
  55. package/dist/esm/index.js +6 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/generate-fed-package-json.js +18 -0
  58. package/generate-index.js +2 -2
  59. package/package.json +12 -12
  60. package/patternfly-docs/content/extensions/data-view/examples/DataView/DataView.md +10 -4
  61. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableExpandableExample.tsx +108 -0
  62. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableInteractiveExample.tsx +148 -0
  63. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableResizableColumnsExample.tsx +155 -0
  64. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableStickyExample.tsx +90 -0
  65. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableTreeExample.tsx +1 -0
  66. package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +113 -14
  67. package/patternfly-docs/content/extensions/data-view/examples/Toolbar/SelectionExample.tsx +14 -3
  68. package/patternfly-docs/content/extensions/data-view/examples/Toolbar/Toolbar.md +10 -2
  69. package/patternfly-docs/content/extensions/data-view/examples/Toolbar/TreeFilterExample.tsx +248 -0
  70. package/patternfly-docs/patternfly-docs.config.js +4 -1
  71. package/release.config.js +1 -1
  72. package/src/DataViewCheckboxFilter/__snapshots__/DataViewCheckboxFilter.test.tsx.snap +0 -2
  73. package/src/DataViewFilters/__snapshots__/DataViewFilters.test.tsx.snap +0 -2
  74. package/src/DataViewTable/DataViewTable.tsx +51 -28
  75. package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +17 -25
  76. package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +54 -12
  77. package/src/DataViewTableBasic/DataViewTableBasic.tsx +104 -10
  78. package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +30 -30
  79. package/src/DataViewTableHead/DataViewTableHead.tsx +24 -23
  80. package/src/DataViewTableHead/__snapshots__/DataViewTableHead.test.tsx.snap +15 -15
  81. package/src/DataViewTableTree/DataViewTableTree.test.tsx +9 -0
  82. package/src/DataViewTableTree/DataViewTableTree.tsx +35 -1
  83. package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +977 -28
  84. package/src/DataViewTextFilter/__snapshots__/DataViewTextFilter.test.tsx.snap +0 -3
  85. package/src/DataViewTh/DataViewTh.tsx +342 -0
  86. package/src/DataViewTh/index.ts +2 -0
  87. package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +0 -10
  88. package/src/DataViewTreeFilter/DataViewTreeFilter.test.tsx +222 -0
  89. package/src/DataViewTreeFilter/DataViewTreeFilter.tsx +361 -0
  90. package/src/DataViewTreeFilter/__snapshots__/DataViewTreeFilter.test.tsx.snap +199 -0
  91. package/src/DataViewTreeFilter/index.ts +2 -0
  92. package/src/Hooks/selection.test.tsx +65 -1
  93. package/src/Hooks/selection.ts +6 -1
  94. package/src/InternalContext/InternalContext.tsx +2 -0
  95. package/src/index.ts +9 -0
@@ -1,8 +1,10 @@
1
- import { render } from '@testing-library/react';
1
+ import { render, screen } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
2
3
  import { DataView } from '../DataView';
3
- import { DataViewTableBasic } from './DataViewTableBasic';
4
+ import { DataViewTableBasic, ExpandableContent } from './DataViewTableBasic';
4
5
 
5
6
  interface Repository {
7
+ id: number;
6
8
  name: string;
7
9
  branches: string | null;
8
10
  prs: string | null;
@@ -11,20 +13,28 @@ interface Repository {
11
13
  }
12
14
 
13
15
  const repositories: Repository[] = [
14
- { name: 'Repository one', branches: 'Branch one', prs: 'Pull request one', workspaces: 'Workspace one', lastCommit: 'Timestamp one' },
15
- { name: 'Repository two', branches: 'Branch two', prs: 'Pull request two', workspaces: 'Workspace two', lastCommit: 'Timestamp two' },
16
- { name: 'Repository three', branches: 'Branch three', prs: 'Pull request three', workspaces: 'Workspace three', lastCommit: 'Timestamp three' },
17
- { name: 'Repository four', branches: 'Branch four', prs: 'Pull request four', workspaces: 'Workspace four', lastCommit: 'Timestamp four' },
18
- { name: 'Repository five', branches: 'Branch five', prs: 'Pull request five', workspaces: 'Workspace five', lastCommit: 'Timestamp five' },
19
- { name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six' }
16
+ { id: 1, name: 'Repository one', branches: 'Branch one', prs: 'Pull request one', workspaces: 'Workspace one', lastCommit: 'Timestamp one' },
17
+ { id: 2, name: 'Repository two', branches: 'Branch two', prs: 'Pull request two', workspaces: 'Workspace two', lastCommit: 'Timestamp two' },
18
+ { id: 3, name: 'Repository three', branches: 'Branch three', prs: 'Pull request three', workspaces: 'Workspace three', lastCommit: 'Timestamp three' },
19
+ { id: 4, name: 'Repository four', branches: 'Branch four', prs: 'Pull request four', workspaces: 'Workspace four', lastCommit: 'Timestamp four' },
20
+ { id: 5, name: 'Repository five', branches: 'Branch five', prs: 'Pull request five', workspaces: 'Workspace five', lastCommit: 'Timestamp five' },
21
+ { id: 6, name: 'Repository six', branches: 'Branch six', prs: 'Pull request six', workspaces: 'Workspace six', lastCommit: 'Timestamp six' }
20
22
  ];
21
23
 
22
- const rows = repositories.map(repo => ({
23
- row: Object.values(repo),
24
- }));
24
+ const rows = repositories.map(({ id, name, branches, prs, workspaces, lastCommit }) => [
25
+ { id, cell: name },
26
+ branches,
27
+ prs,
28
+ workspaces,
29
+ lastCommit
30
+ ]);
25
31
 
26
32
  const columns = [ 'Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit' ];
27
33
 
34
+ const expandableContents: ExpandableContent[] = [
35
+ { rowId: 1, columnId: 1, content: <div>Branch details for Repository one</div> },
36
+ ];
37
+
28
38
  const ouiaId = 'TableExample';
29
39
 
30
40
  describe('DataViewTable component', () => {
@@ -57,8 +67,40 @@ describe('DataViewTable component', () => {
57
67
  const { container } = render(
58
68
  <DataView activeState="loading">
59
69
  <DataViewTableBasic aria-label='Repositories table' ouiaId={ouiaId} columns={columns} bodyStates={{ loading: "Data is loading" }} rows={[]} />
60
- </DataView>
70
+ </DataView>
61
71
  );
62
72
  expect(container).toMatchSnapshot();
63
73
  });
74
+
75
+ test('when isExpandable cell should be clickable and expandable', async () => {
76
+ const user = userEvent.setup();
77
+
78
+ render(
79
+ <DataViewTableBasic
80
+ aria-label='Repositories table'
81
+ ouiaId={ouiaId}
82
+ columns={columns}
83
+ rows={rows}
84
+ isExpandable={true}
85
+ expandedRows={expandableContents}
86
+ />
87
+ );
88
+
89
+ // Initially, expandable content is rendered but should be hidden (not visible)
90
+ const initialBranchContent = screen.getByText('Branch details for Repository one');
91
+ expect(initialBranchContent.closest('tr')?.classList.contains('pf-m-expanded')).toBeFalsy();
92
+
93
+ // Find the first expandable button by ID
94
+ const branchExpandButton = document.getElementById('expandable-0-0-1');
95
+ expect(branchExpandButton).toBeTruthy();
96
+ // Verify the button is in the cell with "Branch one" text
97
+ expect(branchExpandButton?.closest('td')?.textContent).toContain('Branch one');
98
+
99
+ // Click the expand button for Branches column
100
+ await user.click(branchExpandButton!);
101
+
102
+ // After clicking, the expandable content should be visible
103
+ const branchContent = screen.getByText('Branch details for Repository one');
104
+ expect(branchContent.closest('tr')?.classList.contains('pf-m-expanded')).toBeTruthy();
105
+ });
64
106
  });
@@ -1,5 +1,8 @@
1
- import { FC, useMemo } from 'react';
1
+ import { FC, useMemo, useState, useRef } from 'react';
2
2
  import {
3
+ ExpandableRowContent,
4
+ InnerScrollContainer,
5
+ OuterScrollContainer,
3
6
  Table,
4
7
  TableProps,
5
8
  Tbody,
@@ -11,26 +14,44 @@ import { DataViewTableHead } from '../DataViewTableHead';
11
14
  import { DataViewTh, DataViewTr, isDataViewTdObject, isDataViewTrObject } from '../DataViewTable';
12
15
  import { DataViewState } from '../DataView/DataView';
13
16
 
17
+ export interface ExpandableContent {
18
+ rowId: number;
19
+ columnId: number;
20
+ content: React.ReactNode;
21
+ }
22
+
14
23
  /** extends TableProps */
15
24
  export interface DataViewTableBasicProps extends Omit<TableProps, 'onSelect' | 'rows'> {
16
25
  /** Columns definition */
17
26
  columns: DataViewTh[];
18
27
  /** Current page rows */
19
28
  rows: DataViewTr[];
29
+ /** Expanded rows content */
30
+ expandedRows?: ExpandableContent[];
20
31
  /** Table head states to be displayed when active */
21
32
  headStates?: Partial<Record<DataViewState | string, React.ReactNode>>
22
33
  /** Table body states to be displayed when active */
23
34
  bodyStates?: Partial<Record<DataViewState | string, React.ReactNode>>
24
35
  /** Custom OUIA ID */
25
36
  ouiaId?: string;
37
+ /** @hide Indicates if the table is resizable */
38
+ hasResizableColumns?: boolean;
39
+ /** Toggles expandable */
40
+ isExpandable?: boolean;
41
+ /** Toggles sticky columns and header */
42
+ isSticky?: boolean;
26
43
  }
27
44
 
28
45
  export const DataViewTableBasic: FC<DataViewTableBasicProps> = ({
29
46
  columns,
30
47
  rows,
48
+ expandedRows,
31
49
  ouiaId = 'DataViewTableBasic',
32
50
  headStates,
33
51
  bodyStates,
52
+ hasResizableColumns,
53
+ isExpandable = false,
54
+ isSticky = false,
34
55
  ...props
35
56
  }: DataViewTableBasicProps) => {
36
57
  const { selection, activeState, isSelectable } = useInternalContext();
@@ -39,10 +60,30 @@ export const DataViewTableBasic: FC<DataViewTableBasicProps> = ({
39
60
  const activeHeadState = useMemo(() => activeState ? headStates?.[activeState] : undefined, [ activeState, headStates ]);
40
61
  const activeBodyState = useMemo(() => activeState ? bodyStates?.[activeState] : undefined, [ activeState, bodyStates ]);
41
62
 
63
+ const [expandedRowsState, setExpandedRowsState] = useState<Record<number, boolean>>({})
64
+ const [expandedColumnIndex, setExpandedColumnIndex] = useState<Record<number, number>>({})
65
+
66
+ const tableRef = useRef<HTMLTableElement>(null);
67
+
68
+ const needsSeparateTbody = isExpandable;
69
+
42
70
  const renderedRows = useMemo(() => rows.map((row, rowIndex) => {
43
71
  const rowIsObject = isDataViewTrObject(row);
44
- return (
45
- <Tr key={rowIndex} ouiaId={`${ouiaId}-tr-${rowIndex}`} {...(rowIsObject && row?.props)}>
72
+ const isRowExpanded = expandedRowsState[rowIndex] || false;
73
+ const expandedColIndex = expandedColumnIndex[rowIndex];
74
+
75
+ // Get the first cell to extract the row ID
76
+ const rowData = rowIsObject ? row.row : row;
77
+ const firstCell = rowData[0];
78
+ const rowId = isDataViewTdObject(firstCell) ? (firstCell as { id?: number }).id : undefined;
79
+
80
+ // Find all expandable contents for this row
81
+ const rowExpandableContents = isExpandable ? expandedRows?.filter(
82
+ (content) => content.rowId === rowId
83
+ ) : [];
84
+
85
+ const rowContent = (
86
+ <Tr key={needsSeparateTbody ? undefined : rowIndex} ouiaId={`${ouiaId}-tr-${rowIndex}`} {...(rowIsObject && row?.props)} isContentExpanded={isRowExpanded} isControlRow>
46
87
  {isSelectable && (
47
88
  <Td
48
89
  key={`select-${rowIndex}`}
@@ -58,10 +99,29 @@ export const DataViewTableBasic: FC<DataViewTableBasicProps> = ({
58
99
  )}
59
100
  {(rowIsObject ? row.row : row).map((cell, colIndex) => {
60
101
  const cellIsObject = isDataViewTdObject(cell);
102
+ const cellExpandableContent = isExpandable ? expandedRows?.find(
103
+ (content) => content.rowId === rowId && content.columnId === colIndex
104
+ ) : undefined;
61
105
  return (
62
106
  <Td
63
107
  key={colIndex}
64
108
  {...(cellIsObject && (cell?.props ?? {}))}
109
+ {...(cellExpandableContent != null && {
110
+ compoundExpand: {
111
+ isExpanded: isRowExpanded && expandedColIndex === colIndex,
112
+ expandId: `expandable-${rowIndex}`,
113
+ onToggle: () => {
114
+ setExpandedRowsState(prev => {
115
+ const isSameColumn = expandedColIndex === colIndex;
116
+ const wasExpanded = prev[rowIndex];
117
+ return { ...prev, [rowIndex]: isSameColumn ? !wasExpanded : true };
118
+ });
119
+ setExpandedColumnIndex(prev => ({ ...prev, [rowIndex]: colIndex }));
120
+ },
121
+ rowIndex,
122
+ columnIndex: colIndex
123
+ }
124
+ })}
65
125
  data-ouia-component-id={`${ouiaId}-td-${rowIndex}-${colIndex}`}
66
126
  >
67
127
  {cellIsObject ? cell.cell : cell}
@@ -70,14 +130,48 @@ export const DataViewTableBasic: FC<DataViewTableBasicProps> = ({
70
130
  })}
71
131
  </Tr>
72
132
  );
73
- }), [ rows, isSelectable, isSelected, isSelectDisabled, onSelect, ouiaId ]);
74
133
 
75
- return (
76
- <Table aria-label="Data table" ouiaId={ouiaId} {...props}>
77
- { activeHeadState || <DataViewTableHead columns={columns} ouiaId={ouiaId} /> }
78
- { activeBodyState || <Tbody>{renderedRows}</Tbody> }
79
- </Table>
80
- );
134
+ if (needsSeparateTbody) {
135
+ return (
136
+ <Tbody key={rowIndex} isExpanded={isRowExpanded}>
137
+ {rowContent}
138
+ {rowExpandableContents?.map((expandableContent) => (
139
+ <Tr key={`expand-${rowIndex}-${expandableContent.columnId}`} isExpanded={isRowExpanded && expandedColIndex === expandableContent.columnId}>
140
+ <Td colSpan={rowData.length + (isSelectable ? 1 : 0)} data-expanded-column-index={expandableContent.columnId}>
141
+ <ExpandableRowContent>
142
+ {expandableContent.content}
143
+ </ExpandableRowContent>
144
+ </Td>
145
+ </Tr>
146
+ ))}
147
+ </Tbody>
148
+ );
149
+ } else {
150
+ return rowContent;
151
+ }
152
+ }), [ rows, isSelectable, isSelected, isSelectDisabled, onSelect, ouiaId, expandedRowsState, expandedColumnIndex, expandedRows, isExpandable, needsSeparateTbody ]);
153
+
154
+ const bodyContent = activeBodyState || (needsSeparateTbody ? renderedRows : <Tbody>{renderedRows}</Tbody>);
155
+
156
+ if (isSticky) {
157
+ return (
158
+ <OuterScrollContainer>
159
+ <InnerScrollContainer>
160
+ <Table ref={tableRef} aria-label="Data table" ouiaId={ouiaId} isExpandable={isExpandable} hasAnimations {...props} isStickyHeader >
161
+ { activeHeadState || <DataViewTableHead columns={columns} ouiaId={ouiaId} hasResizableColumns={hasResizableColumns} /> }
162
+ { bodyContent }
163
+ </Table>
164
+ </InnerScrollContainer>
165
+ </OuterScrollContainer>
166
+ );
167
+ } else {
168
+ return (
169
+ <Table ref={tableRef} aria-label="Data table" ouiaId={ouiaId} isExpandable={isExpandable} hasAnimations {...props}>
170
+ { activeHeadState || <DataViewTableHead columns={columns} ouiaId={ouiaId} hasResizableColumns={hasResizableColumns} /> }
171
+ { bodyContent }
172
+ </Table>
173
+ );
174
+ }
81
175
  };
82
176
 
83
177
  export default DataViewTableBasic;
@@ -4,7 +4,7 @@ exports[`DataViewTable component should render correctly 1`] = `
4
4
  <div>
5
5
  <table
6
6
  aria-label="Repositories table"
7
- class="pf-v6-c-table pf-m-grid-md"
7
+ class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
8
8
  data-ouia-component-id="TableExample"
9
9
  data-ouia-component-type="PF6/Table"
10
10
  data-ouia-safe="true"
@@ -21,7 +21,7 @@ exports[`DataViewTable component should render 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 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 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 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 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"
@@ -67,7 +67,7 @@ exports[`DataViewTable component should render correctly 1`] = `
67
67
  role="rowgroup"
68
68
  >
69
69
  <tr
70
- class="pf-v6-c-table__tr"
70
+ class="pf-v6-c-table__tr pf-v6-c-table__control-row"
71
71
  data-ouia-component-id="TableExample-tr-0"
72
72
  data-ouia-component-type="PF6/TableRow"
73
73
  data-ouia-safe="true"
@@ -109,7 +109,7 @@ exports[`DataViewTable component should render correctly 1`] = `
109
109
  </td>
110
110
  </tr>
111
111
  <tr
112
- class="pf-v6-c-table__tr"
112
+ class="pf-v6-c-table__tr pf-v6-c-table__control-row"
113
113
  data-ouia-component-id="TableExample-tr-1"
114
114
  data-ouia-component-type="PF6/TableRow"
115
115
  data-ouia-safe="true"
@@ -151,7 +151,7 @@ exports[`DataViewTable component should render correctly 1`] = `
151
151
  </td>
152
152
  </tr>
153
153
  <tr
154
- class="pf-v6-c-table__tr"
154
+ class="pf-v6-c-table__tr pf-v6-c-table__control-row"
155
155
  data-ouia-component-id="TableExample-tr-2"
156
156
  data-ouia-component-type="PF6/TableRow"
157
157
  data-ouia-safe="true"
@@ -193,7 +193,7 @@ exports[`DataViewTable component should render correctly 1`] = `
193
193
  </td>
194
194
  </tr>
195
195
  <tr
196
- class="pf-v6-c-table__tr"
196
+ class="pf-v6-c-table__tr pf-v6-c-table__control-row"
197
197
  data-ouia-component-id="TableExample-tr-3"
198
198
  data-ouia-component-type="PF6/TableRow"
199
199
  data-ouia-safe="true"
@@ -235,7 +235,7 @@ exports[`DataViewTable component should render correctly 1`] = `
235
235
  </td>
236
236
  </tr>
237
237
  <tr
238
- class="pf-v6-c-table__tr"
238
+ class="pf-v6-c-table__tr pf-v6-c-table__control-row"
239
239
  data-ouia-component-id="TableExample-tr-4"
240
240
  data-ouia-component-type="PF6/TableRow"
241
241
  data-ouia-safe="true"
@@ -277,7 +277,7 @@ exports[`DataViewTable component should render correctly 1`] = `
277
277
  </td>
278
278
  </tr>
279
279
  <tr
280
- class="pf-v6-c-table__tr"
280
+ class="pf-v6-c-table__tr pf-v6-c-table__control-row"
281
281
  data-ouia-component-id="TableExample-tr-5"
282
282
  data-ouia-component-type="PF6/TableRow"
283
283
  data-ouia-safe="true"
@@ -335,7 +335,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
335
335
  >
336
336
  <table
337
337
  aria-label="Repositories table"
338
- class="pf-v6-c-table pf-m-grid-md"
338
+ class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
339
339
  data-ouia-component-id="TableExample"
340
340
  data-ouia-component-type="PF6/Table"
341
341
  data-ouia-safe="true"
@@ -352,7 +352,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
352
352
  data-ouia-safe="true"
353
353
  >
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-0"
357
357
  scope="col"
358
358
  tabindex="-1"
@@ -360,7 +360,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
360
360
  Repositories
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-1"
365
365
  scope="col"
366
366
  tabindex="-1"
@@ -368,7 +368,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
368
368
  Branches
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-2"
373
373
  scope="col"
374
374
  tabindex="-1"
@@ -376,7 +376,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
376
376
  Pull requests
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-3"
381
381
  scope="col"
382
382
  tabindex="-1"
@@ -384,7 +384,7 @@ exports[`DataViewTable component should render with a loading state 1`] = `
384
384
  Workspaces
385
385
  </th>
386
386
  <th
387
- class="pf-v6-c-table__th"
387
+ class="pf-v6-c-table__th pf-m-truncate"
388
388
  data-ouia-component-id="TableExample-th-4"
389
389
  scope="col"
390
390
  tabindex="-1"
@@ -412,7 +412,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
412
412
  >
413
413
  <table
414
414
  aria-label="Repositories table"
415
- class="pf-v6-c-table pf-m-grid-md"
415
+ class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
416
416
  data-ouia-component-id="TableExample"
417
417
  data-ouia-component-type="PF6/Table"
418
418
  data-ouia-safe="true"
@@ -429,7 +429,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
429
429
  data-ouia-safe="true"
430
430
  >
431
431
  <th
432
- class="pf-v6-c-table__th"
432
+ class="pf-v6-c-table__th pf-m-truncate"
433
433
  data-ouia-component-id="TableExample-th-0"
434
434
  scope="col"
435
435
  tabindex="-1"
@@ -437,7 +437,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
437
437
  Repositories
438
438
  </th>
439
439
  <th
440
- class="pf-v6-c-table__th"
440
+ class="pf-v6-c-table__th pf-m-truncate"
441
441
  data-ouia-component-id="TableExample-th-1"
442
442
  scope="col"
443
443
  tabindex="-1"
@@ -445,7 +445,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
445
445
  Branches
446
446
  </th>
447
447
  <th
448
- class="pf-v6-c-table__th"
448
+ class="pf-v6-c-table__th pf-m-truncate"
449
449
  data-ouia-component-id="TableExample-th-2"
450
450
  scope="col"
451
451
  tabindex="-1"
@@ -453,7 +453,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
453
453
  Pull requests
454
454
  </th>
455
455
  <th
456
- class="pf-v6-c-table__th"
456
+ class="pf-v6-c-table__th pf-m-truncate"
457
457
  data-ouia-component-id="TableExample-th-3"
458
458
  scope="col"
459
459
  tabindex="-1"
@@ -461,7 +461,7 @@ exports[`DataViewTable component should render with an empty state 1`] = `
461
461
  Workspaces
462
462
  </th>
463
463
  <th
464
- class="pf-v6-c-table__th"
464
+ class="pf-v6-c-table__th pf-m-truncate"
465
465
  data-ouia-component-id="TableExample-th-4"
466
466
  scope="col"
467
467
  tabindex="-1"
@@ -489,7 +489,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
489
489
  >
490
490
  <table
491
491
  aria-label="Repositories table"
492
- class="pf-v6-c-table pf-m-grid-md"
492
+ class="pf-v6-c-table pf-m-grid-md pf-m-animate-expand"
493
493
  data-ouia-component-id="TableExample"
494
494
  data-ouia-component-type="PF6/Table"
495
495
  data-ouia-safe="true"
@@ -506,7 +506,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
506
506
  data-ouia-safe="true"
507
507
  >
508
508
  <th
509
- class="pf-v6-c-table__th"
509
+ class="pf-v6-c-table__th pf-m-truncate"
510
510
  data-ouia-component-id="TableExample-th-0"
511
511
  scope="col"
512
512
  tabindex="-1"
@@ -514,7 +514,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
514
514
  Repositories
515
515
  </th>
516
516
  <th
517
- class="pf-v6-c-table__th"
517
+ class="pf-v6-c-table__th pf-m-truncate"
518
518
  data-ouia-component-id="TableExample-th-1"
519
519
  scope="col"
520
520
  tabindex="-1"
@@ -522,7 +522,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
522
522
  Branches
523
523
  </th>
524
524
  <th
525
- class="pf-v6-c-table__th"
525
+ class="pf-v6-c-table__th pf-m-truncate"
526
526
  data-ouia-component-id="TableExample-th-2"
527
527
  scope="col"
528
528
  tabindex="-1"
@@ -530,7 +530,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
530
530
  Pull requests
531
531
  </th>
532
532
  <th
533
- class="pf-v6-c-table__th"
533
+ class="pf-v6-c-table__th pf-m-truncate"
534
534
  data-ouia-component-id="TableExample-th-3"
535
535
  scope="col"
536
536
  tabindex="-1"
@@ -538,7 +538,7 @@ exports[`DataViewTable component should render with an error state 1`] = `
538
538
  Workspaces
539
539
  </th>
540
540
  <th
541
- class="pf-v6-c-table__th"
541
+ class="pf-v6-c-table__th pf-m-truncate"
542
542
  data-ouia-component-id="TableExample-th-4"
543
543
  scope="col"
544
544
  tabindex="-1"
@@ -1,12 +1,8 @@
1
1
  import { FC, useMemo } from 'react';
2
- import {
3
- Th,
4
- Thead,
5
- TheadProps,
6
- Tr
7
- } from '@patternfly/react-table';
2
+ import { Th, Thead, TheadProps, Tr } from '@patternfly/react-table';
8
3
  import { useInternalContext } from '../InternalContext';
9
4
  import { DataViewTh, isDataViewThObject } from '../DataViewTable';
5
+ import { DataViewTh as DataViewThElement } from '../DataViewTh/DataViewTh';
10
6
 
11
7
  /** extends TheadProps */
12
8
  export interface DataViewTableHeadProps extends TheadProps {
@@ -16,37 +12,42 @@ export interface DataViewTableHeadProps extends TheadProps {
16
12
  columns: DataViewTh[];
17
13
  /** Custom OUIA ID */
18
14
  ouiaId?: string;
15
+ /** @hide Indicates whether table is resizable */
16
+ hasResizableColumns?: boolean;
19
17
  }
20
18
 
21
19
  export const DataViewTableHead: FC<DataViewTableHeadProps> = ({
22
20
  isTreeTable = false,
23
21
  columns,
24
22
  ouiaId = 'DataViewTableHead',
23
+ hasResizableColumns,
25
24
  ...props
26
25
  }: DataViewTableHeadProps) => {
27
26
  const { selection } = useInternalContext();
28
27
  const { onSelect, isSelected } = selection ?? {};
29
28
 
30
- const cells = useMemo(() => [
31
- onSelect && isSelected && !isTreeTable ? (
32
- <Th key="row-select" screenReaderText='Data selection table head cell' />
33
- ) : null,
34
- ...columns.map((column, index) => (
35
- <Th
36
- key={index}
37
- {...(isDataViewThObject(column) && (column?.props ?? {}))}
38
- data-ouia-component-id={`${ouiaId}-th-${index}`}
39
- >
40
- {isDataViewThObject(column) ? column.cell : column}
41
- </Th>
42
- )
43
- ) ], [ columns, ouiaId, onSelect, isSelected, isTreeTable ]);
29
+ const cells = useMemo(
30
+ () => [
31
+ onSelect && isSelected && !isTreeTable ? (
32
+ <Th key="row-select" screenReaderText="Data selection table head cell" />
33
+ ) : null,
34
+ ...columns.map((column, index) => (
35
+ <DataViewThElement
36
+ key={index}
37
+ content={isDataViewThObject(column) ? column.cell : column}
38
+ resizableProps={isDataViewThObject(column) ? column.resizableProps : undefined}
39
+ data-ouia-component-id={`${ouiaId}-th-${index}`}
40
+ thProps={isDataViewThObject(column) ? (column?.props ?? {}) : {}}
41
+ hasResizableColumns={hasResizableColumns}
42
+ />
43
+ ))
44
+ ],
45
+ [ columns, ouiaId, onSelect, isSelected, isTreeTable, hasResizableColumns ]
46
+ );
44
47
 
45
48
  return (
46
49
  <Thead data-ouia-component-id={`${ouiaId}-thead`} {...props}>
47
- <Tr ouiaId={`${ouiaId}-tr-head`}>
48
- {cells}
49
- </Tr>
50
+ <Tr ouiaId={`${ouiaId}-tr-head`}>{cells}</Tr>
50
51
  </Thead>
51
52
  );
52
53
  };