@patternfly/react-table 4.110.18 → 4.110.20

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 (36) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/esm/components/Table/RowWrapper.d.ts +2 -0
  3. package/dist/esm/components/Table/RowWrapper.d.ts.map +1 -1
  4. package/dist/esm/components/Table/RowWrapper.js.map +1 -1
  5. package/dist/esm/components/Table/Table.d.ts +4 -0
  6. package/dist/esm/components/Table/Table.d.ts.map +1 -1
  7. package/dist/esm/components/Table/Table.js.map +1 -1
  8. package/dist/esm/components/TableComposable/TableComposable.d.ts +4 -0
  9. package/dist/esm/components/TableComposable/TableComposable.d.ts.map +1 -1
  10. package/dist/esm/components/TableComposable/TableComposable.js.map +1 -1
  11. package/dist/esm/components/TableComposable/Tr.d.ts +4 -0
  12. package/dist/esm/components/TableComposable/Tr.d.ts.map +1 -1
  13. package/dist/esm/components/TableComposable/Tr.js.map +1 -1
  14. package/dist/js/components/Table/RowWrapper.d.ts +2 -0
  15. package/dist/js/components/Table/RowWrapper.d.ts.map +1 -1
  16. package/dist/js/components/Table/RowWrapper.js.map +1 -1
  17. package/dist/js/components/Table/Table.d.ts +4 -0
  18. package/dist/js/components/Table/Table.d.ts.map +1 -1
  19. package/dist/js/components/Table/Table.js.map +1 -1
  20. package/dist/js/components/TableComposable/TableComposable.d.ts +4 -0
  21. package/dist/js/components/TableComposable/TableComposable.d.ts.map +1 -1
  22. package/dist/js/components/TableComposable/TableComposable.js.map +1 -1
  23. package/dist/js/components/TableComposable/Tr.d.ts +4 -0
  24. package/dist/js/components/TableComposable/Tr.d.ts.map +1 -1
  25. package/dist/js/components/TableComposable/Tr.js.map +1 -1
  26. package/dist/umd/react-table.css +526 -526
  27. package/package.json +3 -3
  28. package/src/components/Table/RowWrapper.tsx +2 -0
  29. package/src/components/Table/Table.tsx +4 -0
  30. package/src/components/Table/__tests__/Table.test.tsx +12 -0
  31. package/src/components/Table/__tests__/__snapshots__/Table.test.tsx.snap +235 -235
  32. package/src/components/Table/examples/Table.md +1 -0
  33. package/src/components/TableComposable/TableComposable.tsx +4 -0
  34. package/src/components/TableComposable/Tr.tsx +4 -0
  35. package/src/docs/demos/Table.md +1 -642
  36. package/src/docs/demos/table-demos/ColumnManagement.jsx +486 -0
@@ -142,6 +142,7 @@ interface RowWrapperProps {
142
142
  rowKey: string;
143
143
  };
144
144
  children?: React.ReactNode;
145
+ ouiaId?: number | string;
145
146
  }
146
147
  ```
147
148
 
@@ -63,6 +63,10 @@ export interface TableComposableProps extends React.HTMLProps<HTMLTableElement>,
63
63
  hasSelectableRowCaption?: boolean;
64
64
  /** Visible text to add alongside the hidden a11y caption for tables with selectable rows. This prop must be used to add custom caption content to the table when the hasSelectableRowCaption prop is set to true. */
65
65
  selectableRowCaptionText?: string;
66
+ /** Value to overwrite the randomly generated data-ouia-component-id.*/
67
+ ouiaId?: number | string;
68
+ /** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
69
+ ouiaSafe?: boolean;
66
70
  }
67
71
 
68
72
  interface TableComposableContextProps {
@@ -34,6 +34,10 @@ export interface TrProps extends React.HTMLProps<HTMLTableRowElement>, OUIAProps
34
34
  isSelectable?: boolean;
35
35
  /** Flag indicating the spacing offset of the first cell should be reset */
36
36
  resetOffset?: boolean;
37
+ /** Value to overwrite the randomly generated data-ouia-component-id.*/
38
+ ouiaId?: number | string;
39
+ /** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
40
+ ouiaSafe?: boolean;
37
41
  }
38
42
 
39
43
  const TrBase: React.FunctionComponent<TrProps> = ({
@@ -317,648 +317,7 @@ class BulkSelectTableDemo extends React.Component {
317
317
 
318
318
  ### Column management
319
319
 
320
- ```js
321
- import React from 'react';
322
- import {
323
- Button,
324
- DataList,
325
- DataListCheck,
326
- DataListItem,
327
- DataListItemRow,
328
- DataListCell,
329
- DataListItemCells,
330
- Toolbar,
331
- ToolbarContent,
332
- ToolbarItem,
333
- Modal,
334
- OverflowMenu,
335
- OverflowMenuGroup,
336
- OverflowMenuItem,
337
- OptionsMenu,
338
- OptionsMenuToggle,
339
- Pagination,
340
- PaginationVariant,
341
- Text,
342
- TextContent,
343
- Select,
344
- SelectVariant
345
- } from '@patternfly/react-core';
346
- import { Table, TableHeader, TableBody } from '@patternfly/react-table';
347
- import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
348
- import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
349
- import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
350
- import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
351
- import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
352
-
353
- class ColumnManagementAction extends React.Component {
354
- constructor(props) {
355
- super(props);
356
- this.actions = [
357
- {
358
- title: <a href="#">Link</a>
359
- },
360
- {
361
- title: 'Action'
362
- },
363
- {
364
- isSeparator: true
365
- },
366
- {
367
- title: <a href="#">Separated link</a>
368
- }
369
- ];
370
- this.defaultColumns = ['Repositories', 'Branches', 'Pull requests', 'Workspaces', 'Last commit', ''];
371
- this.defaultRows = [
372
- {
373
- cells: [
374
- {
375
- title: (
376
- <React.Fragment>
377
- <div>Node 1</div>
378
- <a href="#">siemur/test-space</a>
379
- </React.Fragment>
380
- ),
381
- props: { column: 'Repositories' }
382
- },
383
- {
384
- title: (
385
- <React.Fragment>
386
- <CodeBranchIcon key="icon" /> 10
387
- </React.Fragment>
388
- ),
389
- props: { column: 'Branches' }
390
- },
391
- {
392
- title: (
393
- <React.Fragment>
394
- <CodeIcon key="icon" /> 25
395
- </React.Fragment>
396
- ),
397
- props: { column: 'Pull requests' }
398
- },
399
- {
400
- title: (
401
- <React.Fragment>
402
- <CubeIcon key="icon" /> 5
403
- </React.Fragment>
404
- ),
405
- props: { column: 'Workspaces' }
406
- },
407
- {
408
- title: '2 days ago',
409
- props: { column: 'Last commit' }
410
- },
411
- {
412
- title: (
413
- <React.Fragment>
414
- <a href="#">Action link</a>
415
- </React.Fragment>
416
- ),
417
- props: { column: '' }
418
- }
419
- ]
420
- },
421
- {
422
- cells: [
423
- {
424
- title: (
425
- <React.Fragment>
426
- <div>Node 2</div>
427
- <a href="#">siemur/test-space</a>
428
- </React.Fragment>
429
- ),
430
- props: { column: 'Repositories' }
431
- },
432
- {
433
- title: (
434
- <React.Fragment>
435
- <CodeBranchIcon key="icon" /> 8
436
- </React.Fragment>
437
- ),
438
- props: { column: 'Branches' }
439
- },
440
- {
441
- title: (
442
- <React.Fragment>
443
- <CodeIcon key="icon" /> 30
444
- </React.Fragment>
445
- ),
446
- props: { column: 'Pull requests' }
447
- },
448
- {
449
- title: (
450
- <React.Fragment>
451
- <CubeIcon key="icon" /> 2
452
- </React.Fragment>
453
- ),
454
- props: { column: 'Workspaces' }
455
- },
456
- {
457
- title: '2 days ago',
458
- props: { column: 'Last commit' }
459
- },
460
- {
461
- title: (
462
- <React.Fragment>
463
- <a href="#">Action link</a>
464
- </React.Fragment>
465
- ),
466
- props: { column: '' }
467
- }
468
- ]
469
- },
470
- {
471
- cells: [
472
- {
473
- title: (
474
- <React.Fragment>
475
- <div>Node 3</div>
476
- <a href="#">siemur/test-space</a>
477
- </React.Fragment>
478
- ),
479
- props: { column: 'Repositories' }
480
- },
481
- {
482
- title: (
483
- <React.Fragment>
484
- <CodeBranchIcon key="icon" /> 12
485
- </React.Fragment>
486
- ),
487
- props: { column: 'Branches' }
488
- },
489
- {
490
- title: (
491
- <React.Fragment>
492
- <CodeIcon key="icon" /> 48
493
- </React.Fragment>
494
- ),
495
- props: { column: 'Pull requests' }
496
- },
497
- {
498
- title: (
499
- <React.Fragment>
500
- <CubeIcon key="icon" /> 13
501
- </React.Fragment>
502
- ),
503
- props: { column: 'Workspaces' }
504
- },
505
- {
506
- title: '30 days ago',
507
- props: { column: 'Last commit' }
508
- },
509
- {
510
- title: (
511
- <React.Fragment>
512
- <a href="#">Action link</a>
513
- </React.Fragment>
514
- ),
515
- props: { column: '' }
516
- }
517
- ]
518
- },
519
- {
520
- cells: [
521
- {
522
- title: (
523
- <React.Fragment>
524
- <div>Node 4</div>
525
- <a href="#">siemur/test-space</a>
526
- </React.Fragment>
527
- ),
528
- props: { column: 'Repositories' }
529
- },
530
- {
531
- title: (
532
- <React.Fragment>
533
- <CodeBranchIcon key="icon" /> 3
534
- </React.Fragment>
535
- ),
536
- props: { column: 'Branches' }
537
- },
538
- {
539
- title: (
540
- <React.Fragment>
541
- <CodeIcon key="icon" /> 8
542
- </React.Fragment>
543
- ),
544
- props: { column: 'Pull requests' }
545
- },
546
- {
547
- title: (
548
- <React.Fragment>
549
- <CubeIcon key="icon" /> 20
550
- </React.Fragment>
551
- ),
552
- props: { column: 'Workspaces' }
553
- },
554
- {
555
- title: '8 days ago',
556
- props: { column: 'Last commit' }
557
- },
558
- {
559
- title: (
560
- <React.Fragment>
561
- <a href="#">Action link</a>
562
- </React.Fragment>
563
- ),
564
- props: { column: '' }
565
- }
566
- ]
567
- },
568
- {
569
- cells: [
570
- {
571
- title: (
572
- <React.Fragment>
573
- <div>Node 5</div>
574
- <a href="#">siemur/test-space</a>
575
- </React.Fragment>
576
- ),
577
- props: { column: 'Repositories' }
578
- },
579
- {
580
- title: (
581
- <React.Fragment>
582
- <CodeBranchIcon key="icon" /> 34
583
- </React.Fragment>
584
- ),
585
- props: { column: 'Branches' }
586
- },
587
- {
588
- title: (
589
- <React.Fragment>
590
- <CodeIcon key="icon" /> 21
591
- </React.Fragment>
592
- ),
593
- props: { column: 'Pull requests' }
594
- },
595
- {
596
- title: (
597
- <React.Fragment>
598
- <CubeIcon key="icon" /> 26
599
- </React.Fragment>
600
- ),
601
- props: { column: 'Workspaces' }
602
- },
603
- {
604
- title: '2 days ago',
605
- props: { column: 'Last commit' }
606
- },
607
- {
608
- title: (
609
- <React.Fragment>
610
- <a href="#">Action link</a>
611
- </React.Fragment>
612
- ),
613
- props: { column: '' }
614
- }
615
- ]
616
- }
617
- ];
618
- this.state = {
619
- filters: [],
620
- filteredColumns: [],
621
- filteredRows: [],
622
- columns: this.defaultColumns,
623
- rows: this.defaultRows,
624
- canSelectAll: true,
625
- isModalOpen: false,
626
- check1: true,
627
- check2: true,
628
- check3: true,
629
- check4: true,
630
- check5: true
631
- };
632
- this.onSelect = this.onSelect.bind(this);
633
- this.toggleSelect = this.toggleSelect.bind(this);
634
- this.renderModal = this.renderModal.bind(this);
635
- this.matchCheckboxNameToColumn = name => {
636
- switch (name) {
637
- case 'check1':
638
- return 'Repositories';
639
- case 'check2':
640
- return 'Branches';
641
- case 'check3':
642
- return 'Pull requests';
643
- case 'check4':
644
- return 'Workspaces';
645
- case 'check5':
646
- return 'Last commit';
647
- }
648
- };
649
- this.filterData = (checked, name) => {
650
- const { rows, columns, filters } = this.state;
651
- if (checked) {
652
- const updatedFilters = filters.filter(item => item !== name);
653
- const filteredColumns = this.defaultColumns.filter(column => !updatedFilters.includes(column));
654
- const filteredRows = this.defaultRows.map(({ ...row }) => {
655
- row.cells = row.cells.filter(cell => !updatedFilters.includes(cell.props.column));
656
- return row;
657
- });
658
- this.setState({
659
- filters: updatedFilters,
660
- filteredColumns: filteredColumns,
661
- filteredRows: filteredRows
662
- });
663
- } else {
664
- let updatedFilters = filters;
665
- updatedFilters.push(name);
666
- const filteredColumns = columns.filter(column => !filters.includes(column));
667
- const filteredRows = rows.map(({ ...row }) => {
668
- row.cells = row.cells.filter(cell => !filters.includes(cell.props.column));
669
- return row;
670
- });
671
- this.setState({
672
- filters: updatedFilters,
673
- filteredColumns: filteredColumns,
674
- filteredRows: filteredRows
675
- });
676
- }
677
- };
678
- this.unfilterAllData = () => {
679
- this.setState({
680
- filters: [],
681
- filteredColumns: this.defaultColumns,
682
- filteredRows: this.defaultRows
683
- });
684
- };
685
- this.handleChange = (checked, event) => {
686
- const target = event.target;
687
- const value = target.type === 'checkbox' ? target.checked : target.value;
688
- this.filterData(checked, this.matchCheckboxNameToColumn(target.name));
689
- this.setState({
690
- [target.name]: value
691
- });
692
- };
693
- this.handleModalToggle = () => {
694
- this.setState(({ isModalOpen }) => ({
695
- isModalOpen: !isModalOpen
696
- }));
697
- };
698
- this.onSave = () => {
699
- this.setState(({ filteredColumns, filteredRows, isModalOpen }) => ({
700
- columns: filteredColumns,
701
- rows: filteredRows,
702
- isModalOpen: !isModalOpen
703
- }));
704
- };
705
- this.selectAllColumns = () => {
706
- this.unfilterAllData();
707
- this.setState({
708
- check1: true,
709
- check2: true,
710
- check3: true,
711
- check4: true,
712
- check5: true
713
- });
714
- };
715
- }
716
-
717
- onSelect(event, isSelected, rowId) {
718
- let rows;
719
- if (rowId === -1) {
720
- rows = this.state.rows.map(oneRow => {
721
- oneRow.selected = isSelected;
722
- return oneRow;
723
- });
724
- } else {
725
- rows = [...this.state.rows];
726
- rows[rowId] = { ...rows[rowId], selected: isSelected };
727
- }
728
- this.setState({
729
- rows
730
- });
731
- }
732
-
733
- toggleSelect(checked) {
734
- this.setState({
735
- canSelectAll: checked
736
- });
737
- }
738
-
739
- renderModal() {
740
- const { isModalOpen } = this.state;
741
- return (
742
- <Modal
743
- title="Manage columns"
744
- isOpen={isModalOpen}
745
- variant="small"
746
- description={
747
- <TextContent>
748
- <Text component={TextVariants.p}>Selected categories will be displayed in the table.</Text>
749
- <Button isInline onClick={this.selectAllColumns} variant="link">
750
- Select all
751
- </Button>
752
- </TextContent>
753
- }
754
- onClose={this.handleModalToggle}
755
- actions={[
756
- <Button key="save" variant="primary" onClick={this.onSave}>
757
- Save
758
- </Button>,
759
- <Button key="cancel" variant="secondary" onClick={this.handleModalToggle}>
760
- Cancel
761
- </Button>
762
- ]}
763
- >
764
- <DataList aria-label="Table column management" id="table-column-management" isCompact>
765
- <DataListItem aria-labelledby="table-column-management-item1">
766
- <DataListItemRow>
767
- <DataListCheck
768
- aria-labelledby="table-column-management-item1"
769
- checked={this.state.check1}
770
- name="check1"
771
- id="check1"
772
- onChange={this.handleChange}
773
- />
774
- <DataListItemCells
775
- dataListCells={[
776
- <DataListCell id="table-column-management-item1" key="table-column-management-item1">
777
- <label htmlFor="check1">Repositories</label>
778
- </DataListCell>
779
- ]}
780
- />
781
- </DataListItemRow>
782
- </DataListItem>
783
- <DataListItem aria-labelledby="table-column-management-item2">
784
- <DataListItemRow>
785
- <DataListCheck
786
- aria-labelledby="table-column-management-item2"
787
- checked={this.state.check2}
788
- name="check2"
789
- id="check2"
790
- onChange={this.handleChange}
791
- />
792
- <DataListItemCells
793
- dataListCells={[
794
- <DataListCell id="table-column-management-item2" key="table-column-management-item2">
795
- <label htmlFor="check2">Branches</label>
796
- </DataListCell>
797
- ]}
798
- />
799
- </DataListItemRow>
800
- </DataListItem>
801
- <DataListItem aria-labelledby="table-column-management-item3">
802
- <DataListItemRow>
803
- <DataListCheck
804
- aria-labelledby="table-column-management-item3"
805
- checked={this.state.check3}
806
- name="check3"
807
- id="check3"
808
- onChange={this.handleChange}
809
- />
810
- <DataListItemCells
811
- dataListCells={[
812
- <DataListCell id="table-column-management-item3" key="table-column-management-item3">
813
- <label htmlFor="check3">Pull requests</label>
814
- </DataListCell>
815
- ]}
816
- />
817
- </DataListItemRow>
818
- </DataListItem>
819
- <DataListItem aria-labelledby="table-column-management-item4">
820
- <DataListItemRow>
821
- <DataListCheck
822
- aria-labelledby="table-column-management-item4"
823
- checked={this.state.check4}
824
- name="check4"
825
- id="check4"
826
- onChange={this.handleChange}
827
- />
828
- <DataListItemCells
829
- dataListCells={[
830
- <DataListCell id="table-column-management-item4" key="table-column-management-item4">
831
- <label htmlFor="check4">Workspaces</label>
832
- </DataListCell>
833
- ]}
834
- />
835
- </DataListItemRow>
836
- </DataListItem>
837
- <DataListItem aria-labelledby="table-column-management-item5">
838
- <DataListItemRow>
839
- <DataListCheck
840
- aria-labelledby="table-column-management-item5"
841
- checked={this.state.check5}
842
- name="check5"
843
- id="check5"
844
- onChange={this.handleChange}
845
- />
846
- <DataListItemCells
847
- dataListCells={[
848
- <DataListCell id="table-column-management-item5" key="table-column-management-item5">
849
- <label htmlFor="check5">Last commit</label>
850
- </DataListCell>
851
- ]}
852
- />
853
- </DataListItemRow>
854
- </DataListItem>
855
- </DataList>
856
- </Modal>
857
- );
858
- }
859
-
860
- render() {
861
- const { canSelectAll, columns, rows } = this.state;
862
-
863
- const toolbarItems = (
864
- <React.Fragment>
865
- <span id="page-layout-table-column-management-action-toolbar-top-select-checkbox-label" hidden>
866
- Choose one
867
- </span>
868
- <ToolbarContent>
869
- <ToolbarItem variant="overflow-menu">
870
- <OverflowMenu breakpoint="md">
871
- <OverflowMenuItem isPersistent>
872
- <Select
873
- id="page-layout-table-column-management-action-toolbar-top-select-checkbox-toggle"
874
- variant={SelectVariant.single}
875
- aria-label="Select Input"
876
- aria-labelledby="page-layout-table-column-management-action-toolbar-top-select-checkbox-label page-layout-table-column-management-action-toolbar-top-select-checkbox-toggle"
877
- placeholderText={
878
- <>
879
- <FilterIcon /> Name
880
- </>
881
- }
882
- />
883
- </OverflowMenuItem>
884
- <OverflowMenuItem>
885
- <OptionsMenu
886
- id="page-layout-table-column-management-action-toolbar-top-options-menu-toggle"
887
- isPlain
888
- menuItems={[]}
889
- toggle={
890
- <OptionsMenuToggle
891
- toggleTemplate={<SortAmountDownIcon aria-hidden="true" />}
892
- aria-label="Sort by"
893
- hideCaret
894
- />
895
- }
896
- />
897
- </OverflowMenuItem>
898
- <OverflowMenuGroup groupType="button" isPersistent>
899
- <OverflowMenuItem>
900
- <Button variant="primary">Action</Button>
901
- </OverflowMenuItem>
902
- <OverflowMenuItem>
903
- <Button variant="link" onClick={this.handleModalToggle}>
904
- Manage columns
905
- </Button>
906
- </OverflowMenuItem>
907
- </OverflowMenuGroup>
908
- </OverflowMenu>
909
- </ToolbarItem>
910
- <ToolbarItem variant="pagination">
911
- <Pagination
912
- itemCount={37}
913
- widgetId="pagination-options-menu"
914
- page={1}
915
- variant={PaginationVariant.top}
916
- isCompact
917
- titles={{
918
- paginationTitle: `Column management top pagination`
919
- }}
920
- />
921
- </ToolbarItem>
922
- </ToolbarContent>
923
- </React.Fragment>
924
- );
925
-
926
- return (
927
- <React.Fragment>
928
- <Table
929
- gridBreakPoint="grid-xl"
930
- header={
931
- <React.Fragment>
932
- <Toolbar id="page-layout-table-column-management-action-toolbar-top">{toolbarItems}</Toolbar>
933
- </React.Fragment>
934
- }
935
- aria-label="This is a table with checkboxes"
936
- id="page-layout-table-column-management-action-table"
937
- onSelect={this.onSelect}
938
- cells={columns}
939
- rows={rows}
940
- actions={this.actions}
941
- canSelectAll={canSelectAll}
942
- >
943
- <TableHeader />
944
- <TableBody />
945
- </Table>
946
- <Pagination
947
- isCompact
948
- id="page-layout-table-column-management-action-toolbar-bottom"
949
- itemCount={37}
950
- widgetId="pagination-options-menu-bottom"
951
- page={1}
952
- variant={PaginationVariant.bottom}
953
- titles={{
954
- paginationTitle: `Column management bottom pagination`
955
- }}
956
- />
957
- {this.renderModal()}
958
- </React.Fragment>
959
- );
960
- }
961
- }
320
+ ```js isFullscreen file="./table-demos/ColumnManagement.jsx"
962
321
  ```
963
322
 
964
323
  ### Column management with draggable