@patternfly/react-data-view 6.4.0-prerelease.2 → 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.
Files changed (32) hide show
  1. package/dist/cjs/DataViewTable/DataViewTable.d.ts +4 -0
  2. package/dist/cjs/DataViewTable/DataViewTable.js +21 -1
  3. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +2 -0
  4. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +2 -2
  5. package/dist/cjs/DataViewTableHead/DataViewTableHead.d.ts +2 -0
  6. package/dist/cjs/DataViewTableHead/DataViewTableHead.js +5 -4
  7. package/dist/cjs/DataViewTh/DataViewTh.d.ts +32 -0
  8. package/dist/cjs/DataViewTh/DataViewTh.js +222 -0
  9. package/dist/esm/DataViewTable/DataViewTable.d.ts +4 -0
  10. package/dist/esm/DataViewTable/DataViewTable.js +21 -1
  11. package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +2 -0
  12. package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +2 -2
  13. package/dist/esm/DataViewTableHead/DataViewTableHead.d.ts +2 -0
  14. package/dist/esm/DataViewTableHead/DataViewTableHead.js +5 -4
  15. package/dist/esm/DataViewTh/DataViewTh.d.ts +32 -0
  16. package/dist/esm/DataViewTh/DataViewTh.js +215 -0
  17. package/dist/tsconfig.tsbuildinfo +1 -1
  18. package/package.json +6 -6
  19. package/patternfly-docs/content/extensions/data-view/examples/Table/DataViewTableResizableColumnsExample.tsx +155 -0
  20. package/patternfly-docs/content/extensions/data-view/examples/Table/Table.md +50 -14
  21. package/src/DataViewCheckboxFilter/__snapshots__/DataViewCheckboxFilter.test.tsx.snap +0 -2
  22. package/src/DataViewFilters/__snapshots__/DataViewFilters.test.tsx.snap +0 -2
  23. package/src/DataViewTable/DataViewTable.tsx +48 -27
  24. package/src/DataViewTable/__snapshots__/DataViewTable.test.tsx.snap +10 -18
  25. package/src/DataViewTableBasic/DataViewTableBasic.tsx +4 -1
  26. package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +20 -20
  27. package/src/DataViewTableHead/DataViewTableHead.tsx +24 -23
  28. package/src/DataViewTableHead/__snapshots__/DataViewTableHead.test.tsx.snap +15 -15
  29. package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +25 -41
  30. package/src/DataViewTextFilter/__snapshots__/DataViewTextFilter.test.tsx.snap +0 -3
  31. package/src/DataViewTh/DataViewTh.tsx +342 -0
  32. package/src/DataViewToolbar/__snapshots__/DataViewToolbar.test.tsx.snap +0 -10
@@ -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 = ReactNode | {
12
- /** Table head cell node */
13
- cell: ReactNode;
14
- /** Props passed to Th */
15
- props?: ThProps
16
- };
17
- export const isDataViewThObject = (value: DataViewTh): value is { cell: ReactNode; props?: ThProps } => value != null && typeof value === 'object' && 'cell' in value;
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 = ReactNode | {
30
- /** Table body cell node */
31
- cell: ReactNode;
32
- /** Props passed to Td */
33
- props?: TdProps
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 } => value != null && typeof value === 'object' && 'cell' in value;
39
- export const isDataViewTrObject = (value: DataViewTr): value is { row: DataViewTd[], id?: string } => value != null && typeof value === 'object' && 'row' in value;
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 { id: string, children?: DataViewTrTree[] }
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 ? <DataViewTableTree {...props} /> : <DataViewTableBasic {...props} />
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
  );
@@ -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"
@@ -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"
@@ -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"
@@ -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
  };
@@ -20,7 +20,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
20
20
  data-ouia-safe="true"
21
21
  >
22
22
  <th
23
- class="pf-v6-c-table__th"
23
+ class="pf-v6-c-table__th pf-m-truncate"
24
24
  data-ouia-component-id="HeaderExample-th-0"
25
25
  scope="col"
26
26
  tabindex="-1"
@@ -28,7 +28,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
28
28
  Repositories
29
29
  </th>
30
30
  <th
31
- class="pf-v6-c-table__th"
31
+ class="pf-v6-c-table__th pf-m-truncate"
32
32
  data-ouia-component-id="HeaderExample-th-1"
33
33
  scope="col"
34
34
  tabindex="-1"
@@ -36,7 +36,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
36
36
  Branches
37
37
  </th>
38
38
  <th
39
- class="pf-v6-c-table__th"
39
+ class="pf-v6-c-table__th pf-m-truncate"
40
40
  data-ouia-component-id="HeaderExample-th-2"
41
41
  scope="col"
42
42
  tabindex="-1"
@@ -44,7 +44,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
44
44
  Pull requests
45
45
  </th>
46
46
  <th
47
- class="pf-v6-c-table__th"
47
+ class="pf-v6-c-table__th pf-m-truncate"
48
48
  data-ouia-component-id="HeaderExample-th-3"
49
49
  scope="col"
50
50
  tabindex="-1"
@@ -52,7 +52,7 @@ exports[`DataViewTableHead component should render correctly 1`] = `
52
52
  Workspaces
53
53
  </th>
54
54
  <th
55
- class="pf-v6-c-table__th"
55
+ class="pf-v6-c-table__th pf-m-truncate"
56
56
  data-ouia-component-id="HeaderExample-th-4"
57
57
  scope="col"
58
58
  tabindex="-1"
@@ -104,7 +104,7 @@ exports[`DataViewTableHead component should render selection column when selecti
104
104
  </span>
105
105
  </th>
106
106
  <th
107
- class="pf-v6-c-table__th"
107
+ class="pf-v6-c-table__th pf-m-truncate"
108
108
  data-ouia-component-id="HeaderExample-th-0"
109
109
  scope="col"
110
110
  tabindex="-1"
@@ -112,7 +112,7 @@ exports[`DataViewTableHead component should render selection column when selecti
112
112
  Repositories
113
113
  </th>
114
114
  <th
115
- class="pf-v6-c-table__th"
115
+ class="pf-v6-c-table__th pf-m-truncate"
116
116
  data-ouia-component-id="HeaderExample-th-1"
117
117
  scope="col"
118
118
  tabindex="-1"
@@ -120,7 +120,7 @@ exports[`DataViewTableHead component should render selection column when selecti
120
120
  Branches
121
121
  </th>
122
122
  <th
123
- class="pf-v6-c-table__th"
123
+ class="pf-v6-c-table__th pf-m-truncate"
124
124
  data-ouia-component-id="HeaderExample-th-2"
125
125
  scope="col"
126
126
  tabindex="-1"
@@ -128,7 +128,7 @@ exports[`DataViewTableHead component should render selection column when selecti
128
128
  Pull requests
129
129
  </th>
130
130
  <th
131
- class="pf-v6-c-table__th"
131
+ class="pf-v6-c-table__th pf-m-truncate"
132
132
  data-ouia-component-id="HeaderExample-th-3"
133
133
  scope="col"
134
134
  tabindex="-1"
@@ -136,7 +136,7 @@ exports[`DataViewTableHead component should render selection column when selecti
136
136
  Workspaces
137
137
  </th>
138
138
  <th
139
- class="pf-v6-c-table__th"
139
+ class="pf-v6-c-table__th pf-m-truncate"
140
140
  data-ouia-component-id="HeaderExample-th-4"
141
141
  scope="col"
142
142
  tabindex="-1"
@@ -179,7 +179,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
179
179
  data-ouia-safe="true"
180
180
  >
181
181
  <th
182
- class="pf-v6-c-table__th"
182
+ class="pf-v6-c-table__th pf-m-truncate"
183
183
  data-ouia-component-id="HeaderExample-th-0"
184
184
  scope="col"
185
185
  tabindex="-1"
@@ -187,7 +187,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
187
187
  Repositories
188
188
  </th>
189
189
  <th
190
- class="pf-v6-c-table__th"
190
+ class="pf-v6-c-table__th pf-m-truncate"
191
191
  data-ouia-component-id="HeaderExample-th-1"
192
192
  scope="col"
193
193
  tabindex="-1"
@@ -195,7 +195,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
195
195
  Branches
196
196
  </th>
197
197
  <th
198
- class="pf-v6-c-table__th"
198
+ class="pf-v6-c-table__th pf-m-truncate"
199
199
  data-ouia-component-id="HeaderExample-th-2"
200
200
  scope="col"
201
201
  tabindex="-1"
@@ -203,7 +203,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
203
203
  Pull requests
204
204
  </th>
205
205
  <th
206
- class="pf-v6-c-table__th"
206
+ class="pf-v6-c-table__th pf-m-truncate"
207
207
  data-ouia-component-id="HeaderExample-th-3"
208
208
  scope="col"
209
209
  tabindex="-1"
@@ -211,7 +211,7 @@ exports[`DataViewTableHead component should render the tree table correctly when
211
211
  Workspaces
212
212
  </th>
213
213
  <th
214
- class="pf-v6-c-table__th"
214
+ class="pf-v6-c-table__th pf-m-truncate"
215
215
  data-ouia-component-id="HeaderExample-th-4"
216
216
  scope="col"
217
217
  tabindex="-1"