@patternfly/react-data-view 5.1.4 → 5.2.0

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 (35) hide show
  1. package/dist/cjs/DataView/DataView.d.ts +8 -0
  2. package/dist/cjs/DataView/DataView.js +9 -4
  3. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.d.ts +3 -2
  4. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.js +6 -7
  5. package/dist/cjs/DataViewTableBasic/DataViewTableBasic.test.js +8 -1
  6. package/dist/cjs/DataViewTableTree/DataViewTableTree.d.ts +3 -2
  7. package/dist/cjs/DataViewTableTree/DataViewTableTree.js +16 -5
  8. package/dist/cjs/DataViewTableTree/DataViewTableTree.test.js +7 -1
  9. package/dist/cjs/InternalContext/InternalContext.d.ts +2 -0
  10. package/dist/cjs/InternalContext/InternalContext.js +3 -2
  11. package/dist/esm/DataView/DataView.d.ts +8 -0
  12. package/dist/esm/DataView/DataView.js +8 -3
  13. package/dist/esm/DataViewTableBasic/DataViewTableBasic.d.ts +3 -2
  14. package/dist/esm/DataViewTableBasic/DataViewTableBasic.js +6 -7
  15. package/dist/esm/DataViewTableBasic/DataViewTableBasic.test.js +8 -1
  16. package/dist/esm/DataViewTableTree/DataViewTableTree.d.ts +3 -2
  17. package/dist/esm/DataViewTableTree/DataViewTableTree.js +16 -5
  18. package/dist/esm/DataViewTableTree/DataViewTableTree.test.js +7 -1
  19. package/dist/esm/InternalContext/InternalContext.d.ts +2 -0
  20. package/dist/esm/InternalContext/InternalContext.js +3 -2
  21. package/package.json +1 -1
  22. package/patternfly-docs/content/extensions/data-view/examples/Components/Components.md +10 -3
  23. package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableEmptyExample.tsx +11 -8
  24. package/patternfly-docs/content/extensions/data-view/examples/Components/DataViewTableErrorExample.tsx +38 -0
  25. package/patternfly-docs/content/extensions/data-view/examples/Layout/Layout.md +1 -1
  26. package/src/DataView/DataView.tsx +14 -4
  27. package/src/DataView/__snapshots__/DataView.test.tsx.snap +2 -2
  28. package/src/DataViewTableBasic/DataViewTableBasic.test.tsx +13 -1
  29. package/src/DataViewTableBasic/DataViewTableBasic.tsx +42 -39
  30. package/src/DataViewTableBasic/__snapshots__/DataViewTableBasic.test.tsx.snap +178 -73
  31. package/src/DataViewTableHeader/__snapshots__/DataViewTableHeader.test.tsx.snap +2 -2
  32. package/src/DataViewTableTree/DataViewTableTree.test.tsx +13 -1
  33. package/src/DataViewTableTree/DataViewTableTree.tsx +24 -11
  34. package/src/DataViewTableTree/__snapshots__/DataViewTableTree.test.tsx.snap +176 -71
  35. package/src/InternalContext/InternalContext.tsx +7 -3
@@ -4,7 +4,7 @@ exports[`DataViewTableTree component should render the tree table correctly 1`]
4
4
  <div>
5
5
  <div
6
6
  class="pf-v5-l-stack"
7
- data-ouia-component-id="DataView-stack}"
7
+ data-ouia-component-id="DataView-stack"
8
8
  >
9
9
  <div
10
10
  class="pf-v5-l-stack__item"
@@ -938,85 +938,190 @@ exports[`DataViewTableTree component should render the tree table correctly 1`]
938
938
 
939
939
  exports[`DataViewTableTree component should render tree table with an empty state 1`] = `
940
940
  <div>
941
- <table
942
- aria-label="Repositories table"
943
- class="pf-v5-c-table pf-m-tree-view-grid-md pf-m-tree-view"
944
- data-ouia-component-id="TreeTableExample"
945
- data-ouia-component-type="PF5/Table"
946
- data-ouia-safe="true"
947
- role="treegrid"
941
+ <div
942
+ class="pf-v5-l-stack"
943
+ data-ouia-component-id="DataView-stack"
948
944
  >
949
- <thead
950
- class="pf-v5-c-table__thead"
951
- data-ouia-component-id="TreeTableExample-thead"
945
+ <div
946
+ class="pf-v5-l-stack__item"
947
+ data-ouia-component-id="DataView-stack-item-0"
952
948
  >
953
- <tr
954
- class="pf-v5-c-table__tr"
955
- data-ouia-component-id="TreeTableExample-tr-head"
956
- data-ouia-component-type="PF5/TableRow"
949
+ <table
950
+ aria-label="Repositories table"
951
+ class="pf-v5-c-table pf-m-tree-view-grid-md pf-m-tree-view"
952
+ data-ouia-component-id="TreeTableExample"
953
+ data-ouia-component-type="PF5/Table"
957
954
  data-ouia-safe="true"
955
+ role="treegrid"
958
956
  >
959
- <th
960
- class="pf-v5-c-table__th"
961
- data-ouia-component-id="TreeTableExample-th-0"
962
- scope="col"
963
- tabindex="-1"
964
- >
965
- Repositories
966
- </th>
967
- <th
968
- class="pf-v5-c-table__th"
969
- data-ouia-component-id="TreeTableExample-th-1"
970
- scope="col"
971
- tabindex="-1"
972
- >
973
- Branches
974
- </th>
975
- <th
976
- class="pf-v5-c-table__th"
977
- data-ouia-component-id="TreeTableExample-th-2"
978
- scope="col"
979
- tabindex="-1"
980
- >
981
- Pull requests
982
- </th>
983
- <th
984
- class="pf-v5-c-table__th"
985
- data-ouia-component-id="TreeTableExample-th-3"
986
- scope="col"
987
- tabindex="-1"
957
+ <thead
958
+ class="pf-v5-c-table__thead"
959
+ data-ouia-component-id="TreeTableExample-thead"
988
960
  >
989
- Workspaces
990
- </th>
991
- <th
992
- class="pf-v5-c-table__th"
993
- data-ouia-component-id="TreeTableExample-th-4"
994
- scope="col"
995
- tabindex="-1"
961
+ <tr
962
+ class="pf-v5-c-table__tr"
963
+ data-ouia-component-id="TreeTableExample-tr-head"
964
+ data-ouia-component-type="PF5/TableRow"
965
+ data-ouia-safe="true"
966
+ >
967
+ <th
968
+ class="pf-v5-c-table__th"
969
+ data-ouia-component-id="TreeTableExample-th-0"
970
+ scope="col"
971
+ tabindex="-1"
972
+ >
973
+ Repositories
974
+ </th>
975
+ <th
976
+ class="pf-v5-c-table__th"
977
+ data-ouia-component-id="TreeTableExample-th-1"
978
+ scope="col"
979
+ tabindex="-1"
980
+ >
981
+ Branches
982
+ </th>
983
+ <th
984
+ class="pf-v5-c-table__th"
985
+ data-ouia-component-id="TreeTableExample-th-2"
986
+ scope="col"
987
+ tabindex="-1"
988
+ >
989
+ Pull requests
990
+ </th>
991
+ <th
992
+ class="pf-v5-c-table__th"
993
+ data-ouia-component-id="TreeTableExample-th-3"
994
+ scope="col"
995
+ tabindex="-1"
996
+ >
997
+ Workspaces
998
+ </th>
999
+ <th
1000
+ class="pf-v5-c-table__th"
1001
+ data-ouia-component-id="TreeTableExample-th-4"
1002
+ scope="col"
1003
+ tabindex="-1"
1004
+ >
1005
+ Last commit
1006
+ </th>
1007
+ </tr>
1008
+ </thead>
1009
+ <tbody
1010
+ class="pf-v5-c-table__tbody"
1011
+ role="rowgroup"
996
1012
  >
997
- Last commit
998
- </th>
999
- </tr>
1000
- </thead>
1001
- <tbody
1002
- class="pf-v5-c-table__tbody"
1003
- role="rowgroup"
1013
+ <tr
1014
+ class="pf-v5-c-table__tr"
1015
+ data-ouia-component-id="TreeTableExample-tr-empty"
1016
+ data-ouia-component-type="PF5/TableRow"
1017
+ data-ouia-safe="true"
1018
+ >
1019
+ <td
1020
+ class="pf-v5-c-table__td"
1021
+ colspan="5"
1022
+ tabindex="-1"
1023
+ >
1024
+ No data found
1025
+ </td>
1026
+ </tr>
1027
+ </tbody>
1028
+ </table>
1029
+ </div>
1030
+ </div>
1031
+ </div>
1032
+ `;
1033
+
1034
+ exports[`DataViewTableTree component should render tree table with an error state 1`] = `
1035
+ <div>
1036
+ <div
1037
+ class="pf-v5-l-stack"
1038
+ data-ouia-component-id="DataView-stack"
1039
+ >
1040
+ <div
1041
+ class="pf-v5-l-stack__item"
1042
+ data-ouia-component-id="DataView-stack-item-0"
1004
1043
  >
1005
- <tr
1006
- class="pf-v5-c-table__tr"
1007
- data-ouia-component-id="TreeTableExample-tr-empty"
1008
- data-ouia-component-type="PF5/TableRow"
1044
+ <table
1045
+ aria-label="Repositories table"
1046
+ class="pf-v5-c-table pf-m-tree-view-grid-md pf-m-tree-view"
1047
+ data-ouia-component-id="TreeTableExample"
1048
+ data-ouia-component-type="PF5/Table"
1009
1049
  data-ouia-safe="true"
1050
+ role="treegrid"
1010
1051
  >
1011
- <td
1012
- class="pf-v5-c-table__td"
1013
- colspan="5"
1014
- tabindex="-1"
1052
+ <thead
1053
+ class="pf-v5-c-table__thead"
1054
+ data-ouia-component-id="TreeTableExample-thead"
1055
+ >
1056
+ <tr
1057
+ class="pf-v5-c-table__tr"
1058
+ data-ouia-component-id="TreeTableExample-tr-head"
1059
+ data-ouia-component-type="PF5/TableRow"
1060
+ data-ouia-safe="true"
1061
+ >
1062
+ <th
1063
+ class="pf-v5-c-table__th"
1064
+ data-ouia-component-id="TreeTableExample-th-0"
1065
+ scope="col"
1066
+ tabindex="-1"
1067
+ >
1068
+ Repositories
1069
+ </th>
1070
+ <th
1071
+ class="pf-v5-c-table__th"
1072
+ data-ouia-component-id="TreeTableExample-th-1"
1073
+ scope="col"
1074
+ tabindex="-1"
1075
+ >
1076
+ Branches
1077
+ </th>
1078
+ <th
1079
+ class="pf-v5-c-table__th"
1080
+ data-ouia-component-id="TreeTableExample-th-2"
1081
+ scope="col"
1082
+ tabindex="-1"
1083
+ >
1084
+ Pull requests
1085
+ </th>
1086
+ <th
1087
+ class="pf-v5-c-table__th"
1088
+ data-ouia-component-id="TreeTableExample-th-3"
1089
+ scope="col"
1090
+ tabindex="-1"
1091
+ >
1092
+ Workspaces
1093
+ </th>
1094
+ <th
1095
+ class="pf-v5-c-table__th"
1096
+ data-ouia-component-id="TreeTableExample-th-4"
1097
+ scope="col"
1098
+ tabindex="-1"
1099
+ >
1100
+ Last commit
1101
+ </th>
1102
+ </tr>
1103
+ </thead>
1104
+ <tbody
1105
+ class="pf-v5-c-table__tbody"
1106
+ role="rowgroup"
1015
1107
  >
1016
- No data found
1017
- </td>
1018
- </tr>
1019
- </tbody>
1020
- </table>
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>
1123
+ </table>
1124
+ </div>
1125
+ </div>
1021
1126
  </div>
1022
1127
  `;
@@ -1,4 +1,5 @@
1
1
  import React, { createContext, PropsWithChildren, useContext } from 'react';
2
+ import { DataViewState } from '../DataView';
2
3
 
3
4
  export interface DataViewSelection {
4
5
  /** Called when the selection of items changes */
@@ -11,20 +12,23 @@ export interface DataViewSelection {
11
12
 
12
13
  export interface InternalContextValue {
13
14
  selection?: DataViewSelection;
15
+ activeState?: DataViewState;
14
16
  }
15
17
 
16
18
  export const InternalContext = createContext<InternalContextValue>({
17
- selection: undefined
19
+ selection: undefined,
20
+ activeState: undefined
18
21
  });
19
22
 
20
23
  export type InternalProviderProps = PropsWithChildren<InternalContextValue>
21
24
 
22
25
  export const InternalContextProvider: React.FC<InternalProviderProps> = ({
23
26
  children,
24
- selection
27
+ selection,
28
+ activeState
25
29
  }) => (
26
30
  <InternalContext.Provider
27
- value={{ selection }}
31
+ value={{ selection, activeState }}
28
32
  >
29
33
  {children}
30
34
  </InternalContext.Provider>