@carbon/ibm-products 1.13.0 → 1.16.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 (230) hide show
  1. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css +47 -0
  2. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css.map +1 -0
  3. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css +20 -0
  4. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css.map +1 -0
  5. package/css/components/Datagrid/styles/datagrid.css +268 -0
  6. package/css/components/Datagrid/styles/datagrid.css.map +1 -0
  7. package/css/components/Datagrid/styles/index.css +513 -0
  8. package/css/components/Datagrid/styles/index.css.map +1 -0
  9. package/css/components/Datagrid/styles/useActionsColumn.css +23 -0
  10. package/css/components/Datagrid/styles/useActionsColumn.css.map +1 -0
  11. package/css/components/Datagrid/styles/useColumnRightAlign.css +28 -0
  12. package/css/components/Datagrid/styles/useColumnRightAlign.css.map +1 -0
  13. package/css/components/Datagrid/styles/useNestedRows.css +15 -0
  14. package/css/components/Datagrid/styles/useNestedRows.css.map +1 -0
  15. package/css/components/Datagrid/styles/useNestedTable.css +25 -0
  16. package/css/components/Datagrid/styles/useNestedTable.css.map +1 -0
  17. package/css/components/Datagrid/styles/useSelectAllToggle.css +28 -0
  18. package/css/components/Datagrid/styles/useSelectAllToggle.css.map +1 -0
  19. package/css/components/Datagrid/styles/useSortableColumns.css +50 -0
  20. package/css/components/Datagrid/styles/useSortableColumns.css.map +1 -0
  21. package/css/components/Datagrid/styles/useStickyColumn.css +35 -0
  22. package/css/components/Datagrid/styles/useStickyColumn.css.map +1 -0
  23. package/css/index-full-carbon.css +611 -10
  24. package/css/index-full-carbon.css.map +1 -1
  25. package/css/index-full-carbon.min.css +3 -3
  26. package/css/index-full-carbon.min.css.map +1 -1
  27. package/css/index-without-carbon-released-only.css +7 -4
  28. package/css/index-without-carbon-released-only.css.map +1 -1
  29. package/css/index-without-carbon-released-only.min.css +2 -2
  30. package/css/index-without-carbon-released-only.min.css.map +1 -1
  31. package/css/index-without-carbon.css +611 -10
  32. package/css/index-without-carbon.css.map +1 -1
  33. package/css/index-without-carbon.min.css +3 -3
  34. package/css/index-without-carbon.min.css.map +1 -1
  35. package/css/index.css +611 -10
  36. package/css/index.css.map +1 -1
  37. package/css/index.min.css +3 -3
  38. package/css/index.min.css.map +1 -1
  39. package/es/components/AddSelect/AddSelect.js +106 -43
  40. package/es/components/AddSelect/AddSelectFilter.js +172 -0
  41. package/es/components/AddSelect/add-select-utils.js +30 -0
  42. package/es/components/DataSpreadsheet/DataSpreadsheet.js +255 -175
  43. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +78 -17
  44. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +65 -20
  45. package/es/components/DataSpreadsheet/hooks/index.js +11 -0
  46. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +139 -0
  47. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  48. package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +68 -0
  49. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  50. package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +20 -8
  51. package/es/components/DataSpreadsheet/utils/generateData.js +17 -9
  52. package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
  53. package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +30 -0
  54. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +121 -0
  55. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +108 -0
  56. package/es/components/DataSpreadsheet/utils/handleEditSubmit.js +87 -0
  57. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +42 -8
  58. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +225 -13
  59. package/es/components/DataSpreadsheet/utils/selectAllCells.js +53 -0
  60. package/es/components/Datagrid/Datagrid/Datagrid.js +70 -0
  61. package/es/components/Datagrid/Datagrid/DatagridBody.js +36 -0
  62. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -0
  63. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -0
  64. package/es/components/Datagrid/Datagrid/DatagridHead.js +31 -0
  65. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +57 -0
  66. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +37 -0
  67. package/es/components/Datagrid/Datagrid/DatagridRow.js +60 -0
  68. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +50 -0
  69. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +122 -0
  70. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +36 -0
  71. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -0
  72. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +87 -0
  73. package/es/components/Datagrid/Datagrid/DraggableElement.js +188 -0
  74. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +78 -0
  75. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +51 -0
  76. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +140 -0
  77. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +157 -0
  78. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +62 -0
  79. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +13 -0
  80. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +9 -0
  81. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +62 -0
  82. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +139 -0
  83. package/es/components/Datagrid/Datagrid/addons/RowSize/index.js +8 -0
  84. package/es/components/Datagrid/Datagrid/index.js +8 -0
  85. package/es/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +6 -0
  86. package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +6 -0
  87. package/es/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +6 -0
  88. package/es/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +6 -0
  89. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -0
  90. package/es/components/Datagrid/Datagrid.stories/common.js +199 -0
  91. package/es/components/Datagrid/Datagrid.stories/index.js +5 -0
  92. package/es/components/Datagrid/common-column-ids.js +8 -0
  93. package/es/components/Datagrid/index.js +22 -0
  94. package/es/components/Datagrid/useActionsColumn.js +86 -0
  95. package/es/components/Datagrid/useColumnRightAlign.js +52 -0
  96. package/es/components/Datagrid/useCustomizeColumns.js +45 -0
  97. package/es/components/Datagrid/useDatagrid.js +44 -0
  98. package/es/components/Datagrid/useDefaultStringRenderer.js +48 -0
  99. package/es/components/Datagrid/useDisableSelectRows.js +84 -0
  100. package/es/components/Datagrid/useExpandedRow.js +52 -0
  101. package/es/components/Datagrid/useFlexResize.js +51 -0
  102. package/es/components/Datagrid/useFloatingScroll.js +88 -0
  103. package/es/components/Datagrid/useInfiniteScroll.js +54 -0
  104. package/es/components/Datagrid/useNestedRows.js +53 -0
  105. package/es/components/Datagrid/useOnRowClick.js +37 -0
  106. package/es/components/Datagrid/useParentDimensions.js +65 -0
  107. package/es/components/Datagrid/useResizeTable.js +40 -0
  108. package/es/components/Datagrid/useRowExpander.js +34 -0
  109. package/es/components/Datagrid/useRowIsMouseOver.js +61 -0
  110. package/es/components/Datagrid/useRowRenderer.js +30 -0
  111. package/es/components/Datagrid/useRowSize.js +56 -0
  112. package/es/components/Datagrid/useSelectAllToggle.js +74 -0
  113. package/es/components/Datagrid/useSelectRows.js +107 -0
  114. package/es/components/Datagrid/useSkeletonRows.js +32 -0
  115. package/es/components/Datagrid/useSortableColumns.js +110 -0
  116. package/es/components/Datagrid/useStickyColumn.js +183 -0
  117. package/es/components/MultiAddSelect/MultiAddSelect.js +150 -3
  118. package/es/components/PageHeader/PageHeader.js +3 -1
  119. package/es/components/SingleAddSelect/SingleAddSelect.js +90 -4
  120. package/es/components/TagSet/TagSet.js +13 -6
  121. package/es/components/Tearsheet/TearsheetShell.js +34 -10
  122. package/es/components/index.js +2 -1
  123. package/es/global/js/package-settings.js +4 -2
  124. package/lib/components/AddSelect/AddSelect.js +105 -41
  125. package/lib/components/AddSelect/AddSelectFilter.js +190 -0
  126. package/lib/components/AddSelect/add-select-utils.js +35 -2
  127. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +261 -177
  128. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +79 -23
  129. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +67 -21
  130. package/lib/components/DataSpreadsheet/hooks/index.js +45 -0
  131. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +151 -0
  132. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  133. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +79 -0
  134. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  135. package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +21 -8
  136. package/lib/components/DataSpreadsheet/utils/generateData.js +17 -9
  137. package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
  138. package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +40 -0
  139. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +127 -0
  140. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +118 -0
  141. package/lib/components/DataSpreadsheet/utils/handleEditSubmit.js +94 -0
  142. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +44 -8
  143. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +235 -20
  144. package/lib/components/DataSpreadsheet/utils/selectAllCells.js +60 -0
  145. package/lib/components/Datagrid/Datagrid/Datagrid.js +86 -0
  146. package/lib/components/Datagrid/Datagrid/DatagridBody.js +50 -0
  147. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +31 -0
  148. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +38 -0
  149. package/lib/components/Datagrid/Datagrid/DatagridHead.js +43 -0
  150. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +73 -0
  151. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +44 -0
  152. package/lib/components/Datagrid/Datagrid/DatagridRow.js +68 -0
  153. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +55 -0
  154. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +139 -0
  155. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +44 -0
  156. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +35 -0
  157. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +101 -0
  158. package/lib/components/Datagrid/Datagrid/DraggableElement.js +210 -0
  159. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +92 -0
  160. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +65 -0
  161. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +166 -0
  162. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +173 -0
  163. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +73 -0
  164. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +25 -0
  165. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +23 -0
  166. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +80 -0
  167. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +160 -0
  168. package/lib/components/Datagrid/Datagrid/addons/RowSize/index.js +15 -0
  169. package/lib/components/Datagrid/Datagrid/index.js +15 -0
  170. package/lib/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +13 -0
  171. package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +13 -0
  172. package/lib/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +13 -0
  173. package/lib/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +13 -0
  174. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +112 -0
  175. package/lib/components/Datagrid/Datagrid.stories/common.js +215 -0
  176. package/lib/components/Datagrid/Datagrid.stories/index.js +47 -0
  177. package/lib/components/Datagrid/common-column-ids.js +16 -0
  178. package/lib/components/Datagrid/index.js +127 -0
  179. package/lib/components/Datagrid/useActionsColumn.js +94 -0
  180. package/lib/components/Datagrid/useColumnRightAlign.js +59 -0
  181. package/lib/components/Datagrid/useCustomizeColumns.js +55 -0
  182. package/lib/components/Datagrid/useDatagrid.js +58 -0
  183. package/lib/components/Datagrid/useDefaultStringRenderer.js +54 -0
  184. package/lib/components/Datagrid/useDisableSelectRows.js +92 -0
  185. package/lib/components/Datagrid/useExpandedRow.js +58 -0
  186. package/lib/components/Datagrid/useFlexResize.js +61 -0
  187. package/lib/components/Datagrid/useFloatingScroll.js +101 -0
  188. package/lib/components/Datagrid/useInfiniteScroll.js +67 -0
  189. package/lib/components/Datagrid/useNestedRows.js +65 -0
  190. package/lib/components/Datagrid/useOnRowClick.js +45 -0
  191. package/lib/components/Datagrid/useParentDimensions.js +75 -0
  192. package/lib/components/Datagrid/useResizeTable.js +48 -0
  193. package/lib/components/Datagrid/useRowExpander.js +45 -0
  194. package/lib/components/Datagrid/useRowIsMouseOver.js +66 -0
  195. package/lib/components/Datagrid/useRowRenderer.js +40 -0
  196. package/lib/components/Datagrid/useRowSize.js +67 -0
  197. package/lib/components/Datagrid/useSelectAllToggle.js +88 -0
  198. package/lib/components/Datagrid/useSelectRows.js +119 -0
  199. package/lib/components/Datagrid/useSkeletonRows.js +42 -0
  200. package/lib/components/Datagrid/useSortableColumns.js +117 -0
  201. package/lib/components/Datagrid/useStickyColumn.js +190 -0
  202. package/lib/components/MultiAddSelect/MultiAddSelect.js +150 -2
  203. package/lib/components/PageHeader/PageHeader.js +3 -1
  204. package/lib/components/SingleAddSelect/SingleAddSelect.js +91 -3
  205. package/lib/components/TagSet/TagSet.js +13 -6
  206. package/lib/components/Tearsheet/TearsheetShell.js +36 -10
  207. package/lib/components/index.js +9 -1
  208. package/lib/global/js/package-settings.js +4 -2
  209. package/package.json +16 -12
  210. package/scss/components/AboutModal/_about-modal.scss +4 -0
  211. package/scss/components/AddSelect/_add-select.scss +46 -2
  212. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +41 -4
  213. package/scss/components/Datagrid/_datagrid.scss +66 -0
  214. package/scss/components/Datagrid/_index.scss +8 -0
  215. package/scss/components/Datagrid/_storybook-styles.scss +26 -0
  216. package/scss/components/Datagrid/styles/_variables.scss +9 -0
  217. package/scss/components/Datagrid/styles/addons/CustomizeColumnsModal.scss +48 -0
  218. package/scss/components/Datagrid/styles/addons/RowSizeDropdown.scss +23 -0
  219. package/scss/components/Datagrid/styles/datagrid.scss +326 -0
  220. package/scss/components/Datagrid/styles/index.scss +17 -0
  221. package/scss/components/Datagrid/styles/useActionsColumn.scss +24 -0
  222. package/scss/components/Datagrid/styles/useColumnRightAlign.scss +29 -0
  223. package/scss/components/Datagrid/styles/useNestedRows.scss +17 -0
  224. package/scss/components/Datagrid/styles/useNestedTable.scss +28 -0
  225. package/scss/components/Datagrid/styles/useSelectAllToggle.scss +28 -0
  226. package/scss/components/Datagrid/styles/useSortableColumns.scss +55 -0
  227. package/scss/components/Datagrid/styles/useStickyColumn.scss +38 -0
  228. package/scss/components/ExportModal/_export-modal.scss +0 -4
  229. package/scss/components/Tearsheet/_tearsheet.scss +4 -0
  230. package/scss/components/_index.scss +1 -0
@@ -1,3 +1,9 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
1
7
  /**
2
8
  * Copyright IBM Corp. 2022, 2022
3
9
  *
@@ -5,24 +11,66 @@
5
11
  * LICENSE file in the root directory of this source tree.
6
12
  */
7
13
  import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
14
+ import uuidv4 from '../../../global/js/utils/uuidv4';
15
+ import { selectAllCells } from './selectAllCells';
16
+ export var includesResourceKey = function includesResourceKey(arr, usingMac) {
17
+ if (usingMac) {
18
+ return includesMeta(arr);
19
+ }
20
+
21
+ if (!usingMac) {
22
+ return includesControl(arr);
23
+ }
24
+ };
25
+ export var includesShift = function includesShift(arr) {
26
+ if (arr.includes('ShiftLeft') || arr.includes('ShiftRight')) {
27
+ return true;
28
+ }
29
+
30
+ return false;
31
+ };
32
+
33
+ var includesMeta = function includesMeta(arr) {
34
+ if (arr.includes('MetaLeft') || arr.includes('MetaRight')) {
35
+ return true;
36
+ }
37
+
38
+ return false;
39
+ };
40
+
41
+ var includesControl = function includesControl(arr) {
42
+ if (arr.includes('ControlLeft') || arr.includes('ControlRight')) {
43
+ return true;
44
+ }
45
+
46
+ return false;
47
+ };
48
+
8
49
  export var handleMultipleKeys = function handleMultipleKeys(_ref) {
9
- var _selectionAreasClone$;
50
+ var _selectionAreasClone$, _selectionAreasClone$2, _selectionAreasClone$3;
10
51
 
11
- var activeKeys = _ref.activeKeys,
52
+ var activeCellCoordinates = _ref.activeCellCoordinates,
53
+ event = _ref.event,
54
+ keysPressedList = _ref.keysPressedList,
12
55
  selectionAreas = _ref.selectionAreas,
13
56
  currentMatcher = _ref.currentMatcher,
14
57
  rows = _ref.rows,
15
58
  setSelectionAreas = _ref.setSelectionAreas,
16
- columns = _ref.columns;
17
- var activeKeyValues = activeKeys.current;
59
+ columns = _ref.columns,
60
+ updateActiveCellCoordinates = _ref.updateActiveCellCoordinates,
61
+ spreadsheetRef = _ref.spreadsheetRef,
62
+ removeCellSelections = _ref.removeCellSelections,
63
+ blockClass = _ref.blockClass,
64
+ setCurrentMatcher = _ref.setCurrentMatcher,
65
+ usingMac = _ref.usingMac;
18
66
  var selectionAreasClone = deepCloneObject(selectionAreas);
19
67
  var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
20
68
  return item.matcher === currentMatcher;
21
69
  });
22
- var pointToUpdate = (_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) !== null && _selectionAreasClone$ !== void 0 && _selectionAreasClone$.point2 ? selectionAreasClone[indexOfCurrentArea].point2 : selectionAreasClone[indexOfCurrentArea].point1; // Down + Shift
70
+ var pointToUpdate = (_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) !== null && _selectionAreasClone$ !== void 0 && _selectionAreasClone$.point2 ? (_selectionAreasClone$2 = selectionAreasClone[indexOfCurrentArea]) === null || _selectionAreasClone$2 === void 0 ? void 0 : _selectionAreasClone$2.point2 : (_selectionAreasClone$3 = selectionAreasClone[indexOfCurrentArea]) === null || _selectionAreasClone$3 === void 0 ? void 0 : _selectionAreasClone$3.point1; // Down + Shift
23
71
 
24
- if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowDown')) {
25
- if (rows.length - 1 === pointToUpdate.row) {
72
+ if (includesShift(keysPressedList) && keysPressedList.includes('ArrowDown') && keysPressedList.length === 2) {
73
+ if (rows.length - 1 === (pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.row) || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
26
74
  return;
27
75
  }
28
76
 
@@ -36,8 +84,8 @@ export var handleMultipleKeys = function handleMultipleKeys(_ref) {
36
84
  } // Right + Shift
37
85
 
38
86
 
39
- if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowRight')) {
40
- if (columns.length - 1 === pointToUpdate.column) {
87
+ if (includesShift(keysPressedList) && keysPressedList.includes('ArrowRight') && keysPressedList.length === 2) {
88
+ if (columns.length - 1 === (pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.column) || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
41
89
  return;
42
90
  }
43
91
 
@@ -51,8 +99,8 @@ export var handleMultipleKeys = function handleMultipleKeys(_ref) {
51
99
  } // Up + Shift
52
100
 
53
101
 
54
- if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowUp')) {
55
- if (pointToUpdate.row === 0) {
102
+ if (includesShift(keysPressedList) && keysPressedList.includes('ArrowUp') && keysPressedList.length === 2) {
103
+ if ((pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.row) === 0 || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
56
104
  return;
57
105
  }
58
106
 
@@ -66,8 +114,8 @@ export var handleMultipleKeys = function handleMultipleKeys(_ref) {
66
114
  } // Left + Shift
67
115
 
68
116
 
69
- if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowLeft')) {
70
- if (pointToUpdate.column === 0) {
117
+ if (includesShift(keysPressedList) && keysPressedList.includes('ArrowLeft') && keysPressedList.length === 2) {
118
+ if ((pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.column) === 0 || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
71
119
  return;
72
120
  }
73
121
 
@@ -78,5 +126,169 @@ export var handleMultipleKeys = function handleMultipleKeys(_ref) {
78
126
  selectionAreasClone[indexOfCurrentArea].point2 = _newPoint3;
79
127
  selectionAreasClone[indexOfCurrentArea].areaCreated = false;
80
128
  setSelectionAreas(selectionAreasClone);
129
+ } // CMD + a (select all)
130
+
131
+
132
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('KeyA')) {
133
+ event.preventDefault();
134
+ var selectionPoint1 = {
135
+ row: 0,
136
+ column: 0
137
+ };
138
+ var selectionPoint2 = {
139
+ row: rows.length - 1,
140
+ column: columns.length - 1
141
+ }; // If indexOfCurrentArea is -1, it means the active cell is in a cell header position
142
+
143
+ if (indexOfCurrentArea === -1) {
144
+ selectAllCells({
145
+ ref: spreadsheetRef,
146
+ setCurrentMatcher: setCurrentMatcher,
147
+ setSelectionAreas: setSelectionAreas,
148
+ rows: rows,
149
+ columns: columns,
150
+ activeCellCoordinates: activeCellCoordinates,
151
+ updateActiveCellCoordinates: updateActiveCellCoordinates
152
+ });
153
+ }
154
+
155
+ selectionAreasClone[indexOfCurrentArea].point1 = selectionPoint1;
156
+ selectionAreasClone[indexOfCurrentArea].point2 = selectionPoint2;
157
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
158
+ setSelectionAreas(selectionAreasClone);
159
+ } // CONTROL + SPACE (Select current column)
160
+
161
+
162
+ if (includesControl(keysPressedList) && keysPressedList.includes('Space')) {
163
+ var _selectionPoint = {
164
+ row: 0,
165
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
166
+ };
167
+ var _selectionPoint2 = {
168
+ row: rows.length - 1,
169
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
170
+ }; // If indexOfCurrentArea is -1, it means the active cell is in a cell header position
171
+
172
+ if (indexOfCurrentArea === -1) {
173
+ var tempMatcher = uuidv4();
174
+ var newSelectionArea = {
175
+ point1: _selectionPoint,
176
+ point2: _selectionPoint2,
177
+ areaCreated: false,
178
+ matcher: tempMatcher
179
+ };
180
+
181
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
182
+
183
+ updateActiveCellCoordinates({
184
+ coords: coordinatesClone,
185
+ updatedValue: {
186
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column,
187
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row
188
+ }
189
+ });
190
+ setCurrentMatcher(tempMatcher);
191
+ return setSelectionAreas([newSelectionArea]);
192
+ }
193
+
194
+ selectionAreasClone[indexOfCurrentArea].point1 = _selectionPoint;
195
+ selectionAreasClone[indexOfCurrentArea].point2 = _selectionPoint2;
196
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
197
+ setSelectionAreas(selectionAreasClone);
198
+ } // Shift + SPACE (Select current row)
199
+
200
+
201
+ if (includesShift(keysPressedList) && keysPressedList.includes('Space')) {
202
+ var _selectionPoint3 = {
203
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
204
+ column: 0
205
+ };
206
+ var _selectionPoint4 = {
207
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
208
+ column: columns.length - 1
209
+ }; // If indexOfCurrentArea is -1, it means the active cell is in a cell header position
210
+
211
+ if (indexOfCurrentArea === -1) {
212
+ var _tempMatcher = uuidv4();
213
+
214
+ var _newSelectionArea = {
215
+ point1: _selectionPoint3,
216
+ point2: _selectionPoint4,
217
+ areaCreated: false,
218
+ matcher: _tempMatcher
219
+ };
220
+
221
+ var _coordinatesClone = _objectSpread({}, activeCellCoordinates);
222
+
223
+ updateActiveCellCoordinates({
224
+ coords: _coordinatesClone,
225
+ updatedValue: {
226
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column,
227
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row
228
+ }
229
+ });
230
+ setCurrentMatcher(_tempMatcher);
231
+ return setSelectionAreas([_newSelectionArea]);
232
+ }
233
+
234
+ selectionAreasClone[indexOfCurrentArea].point1 = _selectionPoint3;
235
+ selectionAreasClone[indexOfCurrentArea].point2 = _selectionPoint4;
236
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
237
+ setSelectionAreas(selectionAreasClone);
238
+ } // CMD + HOME (Selects first cell in first row)
239
+
240
+
241
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('Home')) {
242
+ var scrollElement = spreadsheetRef.current.querySelector(".".concat(blockClass, "__list--container"));
243
+ scrollElement.scrollTop = 0;
244
+
245
+ var _coordinatesClone2 = _objectSpread({}, activeCellCoordinates);
246
+
247
+ removeCellSelections({
248
+ spreadsheetRef: spreadsheetRef
249
+ });
250
+ updateActiveCellCoordinates({
251
+ coords: _coordinatesClone2,
252
+ updatedValue: {
253
+ column: 0,
254
+ row: 0
255
+ }
256
+ });
257
+ } // CMD + END (Selects last cell in last row)
258
+
259
+
260
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('End')) {
261
+ var _scrollElement = spreadsheetRef.current.querySelector(".".concat(blockClass, "__list--container"));
262
+
263
+ _scrollElement.scrollTop = _scrollElement.scrollHeight;
264
+
265
+ var _coordinatesClone3 = _objectSpread({}, activeCellCoordinates);
266
+
267
+ removeCellSelections({
268
+ spreadsheetRef: spreadsheetRef
269
+ });
270
+ var lastCellExists = !!rows[(rows === null || rows === void 0 ? void 0 : rows.length) - 1].cells[(columns === null || columns === void 0 ? void 0 : columns.length) - 1];
271
+
272
+ var updateToLastCell = function updateToLastCell() {
273
+ updateActiveCellCoordinates({
274
+ coords: _coordinatesClone3,
275
+ updatedValue: {
276
+ column: columns.length - 1,
277
+ row: rows.length - 1
278
+ }
279
+ });
280
+ }; // With the spreadsheet supporting virtualized data, it's possible that the last cell
281
+ // has never been rendered yet, if that's the case we scroll to the bottom of the spreadsheet
282
+ // and add a timeout to wait for the last row to render to the DOM before updating the active cell coordinates.
283
+ // If we're able to verify that the last row has been rendered, no timeout is used.
284
+
285
+
286
+ if (lastCellExists) {
287
+ updateToLastCell();
288
+ } else {
289
+ setTimeout(function () {
290
+ updateToLastCell();
291
+ }, 1);
292
+ }
81
293
  }
82
294
  };
@@ -0,0 +1,53 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ /**
8
+ * Copyright IBM Corp. 2022, 2022
9
+ *
10
+ * This source code is licensed under the Apache-2.0 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ import { removeCellSelections } from './removeCellSelections';
14
+ import uuidv4 from '../../../global/js/utils/uuidv4';
15
+ export var selectAllCells = function selectAllCells(_ref) {
16
+ var activeCellCoordinates = _ref.activeCellCoordinates,
17
+ columns = _ref.columns,
18
+ setCurrentMatcher = _ref.setCurrentMatcher,
19
+ setSelectionAreas = _ref.setSelectionAreas,
20
+ ref = _ref.ref,
21
+ rows = _ref.rows,
22
+ updateActiveCellCoordinates = _ref.updateActiveCellCoordinates;
23
+ removeCellSelections({
24
+ spreadsheetRef: ref
25
+ });
26
+ var selectionPoint1 = {
27
+ row: 0,
28
+ column: 0
29
+ };
30
+ var selectionPoint2 = {
31
+ row: rows.length - 1,
32
+ column: columns.length - 1
33
+ };
34
+ var tempMatcher = uuidv4();
35
+ var newSelectionArea = {
36
+ point1: selectionPoint1,
37
+ point2: selectionPoint2,
38
+ areaCreated: false,
39
+ matcher: tempMatcher
40
+ };
41
+
42
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
43
+
44
+ updateActiveCellCoordinates({
45
+ coords: coordinatesClone,
46
+ updatedValue: {
47
+ column: 0,
48
+ row: 0
49
+ }
50
+ });
51
+ setCurrentMatcher(tempMatcher);
52
+ return setSelectionAreas([newSelectionArea]);
53
+ };
@@ -0,0 +1,70 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["getTableProps", "withVirtualScroll", "DatagridPagination", "isFetching", "tableId", "CustomizeColumnsModal", "leftPanel", "fullHeightDatagrid", "verticalAlign", "variableRowHeight", "className"];
5
+
6
+ /*
7
+ * Licensed Materials - Property of IBM
8
+ * 5724-Q36
9
+ * (c) Copyright IBM Corp. 2020 - 2021
10
+ * US Government Users Restricted Rights - Use, duplication or disclosure
11
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
12
+ */
13
+ import React from 'react';
14
+ import { DataTable } from 'carbon-components-react';
15
+ import cx from 'classnames';
16
+ import DatagridHead from './DatagridHead';
17
+ import DatagridBody from './DatagridBody';
18
+ import DatagridToolbar from './DatagridToolbar';
19
+ import { getDevtoolsProps } from '../../../global/js/utils/devtools';
20
+ import { pkg } from '../../../settings';
21
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
22
+ var componentName = 'Datagrid';
23
+ var TableContainer = DataTable.TableContainer,
24
+ Table = DataTable.Table;
25
+ var Datagrid = /*#__PURE__*/React.forwardRef(function (datagridState, ref) {
26
+ var _getTableProps;
27
+
28
+ var _datagridState$getTab = datagridState.getTableProps,
29
+ getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
30
+ withVirtualScroll = datagridState.withVirtualScroll,
31
+ DatagridPagination = datagridState.DatagridPagination,
32
+ isFetching = datagridState.isFetching,
33
+ tableId = datagridState.tableId,
34
+ CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
35
+ leftPanel = datagridState.leftPanel,
36
+ fullHeightDatagrid = datagridState.fullHeightDatagrid,
37
+ _datagridState$vertic = datagridState.verticalAlign,
38
+ verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
39
+ variableRowHeight = datagridState.variableRowHeight,
40
+ className = datagridState.className,
41
+ rest = _objectWithoutProperties(datagridState, _excluded);
42
+
43
+ var rows = DatagridPagination && datagridState.page || datagridState.rows;
44
+ var dataGrid = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
45
+ className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '')
46
+ }, /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), {
47
+ className: cx(DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className)
48
+ }), /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
49
+ rows: rows
50
+ })))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
51
+ instance: datagridState
52
+ }));
53
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
54
+ id: tableId,
55
+ ref: ref,
56
+ className: cx(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"))
57
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(DatagridToolbar, datagridState), leftPanel && /*#__PURE__*/React.createElement("div", {
58
+ className: "".concat(blockClass, "__grid-container ").concat(blockClass, "__displayFlex")
59
+ }, leftPanel && leftPanel.isOpen && /*#__PURE__*/React.createElement("div", {
60
+ className: "".concat(blockClass, "__datagridLeftPanel")
61
+ }, leftPanel.panelContent), /*#__PURE__*/React.createElement("div", {
62
+ className: "".concat(blockClass, "__datagridWithPanel")
63
+ }, dataGrid)), leftPanel === undefined && dataGrid);
64
+ }); // Return a placeholder if not released and not enabled by feature flag
65
+
66
+ Datagrid = pkg.checkComponentEnabled(Datagrid, componentName); // The display name of the component, used by React. Note that displayName
67
+ // is used in preference to relying on function.name.
68
+
69
+ Datagrid.displayName = componentName;
70
+ export default Datagrid;
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2021
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import React from 'react';
9
+ import DatagridEmptyBody from './DatagridEmptyBody';
10
+ import DatagridVirtualBody from './DatagridVirtualBody';
11
+ import DatagridSimpleBody from './DatagridSimpleBody';
12
+ import DatagridRefBody from './DatagridRefBody';
13
+
14
+ var DatagridBody = function DatagridBody(datagridState) {
15
+ var isFetching = datagridState.isFetching,
16
+ _datagridState$rows = datagridState.rows,
17
+ rows = _datagridState$rows === void 0 ? [] : _datagridState$rows,
18
+ withVirtualScroll = datagridState.withVirtualScroll,
19
+ withStickyColumn = datagridState.withStickyColumn;
20
+
21
+ if (!isFetching && rows.length === 0) {
22
+ return /*#__PURE__*/React.createElement(DatagridEmptyBody, datagridState);
23
+ }
24
+
25
+ if (withVirtualScroll) {
26
+ return /*#__PURE__*/React.createElement(DatagridVirtualBody, datagridState);
27
+ }
28
+
29
+ if (withStickyColumn) {
30
+ return /*#__PURE__*/React.createElement(DatagridRefBody, datagridState);
31
+ }
32
+
33
+ return /*#__PURE__*/React.createElement(DatagridSimpleBody, datagridState);
34
+ };
35
+
36
+ export default DatagridBody;
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import React from 'react';
9
+ import { pkg } from '../../../settings';
10
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
11
+
12
+ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
13
+ var EmptyState = datagridState.EmptyState;
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ className: "".concat(blockClass, "__empty-state-body")
16
+ }, EmptyState);
17
+ };
18
+
19
+ export default DatagridEmptyBody;
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Licensed Materials - Property of IBM
3
+ * 5724-Q36
4
+ * (c) Copyright IBM Corp. 2020
5
+ * US Government Users Restricted Rights - Use, duplication or disclosure
6
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
7
+ */
8
+ import React from 'react';
9
+ import { pkg } from '../../../settings';
10
+ var blockClass = "".concat(pkg.prefix, "--datagrid"); // eslint-disable-next-line react/prop-types
11
+
12
+ var DatagridExpandedRow = function DatagridExpandedRow(PreviousRowRenderer, ExpandedRowContentComponent) {
13
+ return function (datagridState) {
14
+ var row = datagridState.row;
15
+
16
+ if (!row.isExpanded) {
17
+ return PreviousRowRenderer(datagridState);
18
+ }
19
+
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ className: "".concat(blockClass, "__expanded-row")
22
+ }, PreviousRowRenderer(datagridState), ExpandedRowContentComponent(datagridState));
23
+ };
24
+ };
25
+
26
+ export default DatagridExpandedRow;
@@ -0,0 +1,31 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /*
4
+ * Licensed Materials - Property of IBM
5
+ * 5724-Q36
6
+ * (c) Copyright IBM Corp. 2020, 2021
7
+ * US Government Users Restricted Rights - Use, duplication or disclosure
8
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
9
+ */
10
+ import React from 'react';
11
+ import { DataTable } from 'carbon-components-react';
12
+ var TableHead = DataTable.TableHead;
13
+
14
+ var DatagridHead = function DatagridHead(datagridState) {
15
+ var _datagridState$header = datagridState.headerGroups,
16
+ headerGroups = _datagridState$header === void 0 ? [] : _datagridState$header,
17
+ headRef = datagridState.headRef,
18
+ HeaderRow = datagridState.HeaderRow;
19
+ return /*#__PURE__*/React.createElement(TableHead, null, headerGroups.map(function (headerGroup, index) {
20
+ return (
21
+ /*#__PURE__*/
22
+ // doesn't support header grouping.
23
+ React.createElement("div", _extends({}, headerGroup.getHeaderGroupProps(), {
24
+ ref: headRef,
25
+ key: "header_".concat(index)
26
+ }), HeaderRow(datagridState))
27
+ );
28
+ }));
29
+ };
30
+
31
+ export default DatagridHead;
@@ -0,0 +1,57 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ /*
5
+ * Licensed Materials - Property of IBM
6
+ * 5724-Q36
7
+ * (c) Copyright IBM Corp. 2020, 2021
8
+ * US Government Users Restricted Rights - Use, duplication or disclosure
9
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
10
+ */
11
+ // @flow
12
+ import React from 'react';
13
+ import cx from 'classnames';
14
+ import { DataTable } from 'carbon-components-react';
15
+ import { selectionColumnId } from '../common-column-ids';
16
+ import { pkg } from '../../../settings';
17
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
18
+
19
+ var HeaderRow = function HeaderRow(datagridState) {
20
+ return /*#__PURE__*/React.createElement(TableRow, {
21
+ className: "".concat(blockClass, "__head")
22
+ }, datagridState.headers.filter(function (_ref) {
23
+ var isVisible = _ref.isVisible;
24
+ return isVisible;
25
+ }).map(function (header) {
26
+ var _cx;
27
+
28
+ if (header.id === selectionColumnId) {
29
+ // render directly without the wrapper TableHeader
30
+ return header.render('Header', {
31
+ key: header.id
32
+ });
33
+ }
34
+
35
+ return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps(), {
36
+ className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), header.canSort), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
37
+ key: header.id
38
+ }), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement("div", _extends({}, header.getResizerProps(), {
39
+ className: "".concat(blockClass, "__resizer")
40
+ })));
41
+ }));
42
+ };
43
+
44
+ var TableHeader = DataTable.TableHeader,
45
+ TableRow = DataTable.TableRow;
46
+
47
+ var useHeaderRow = function useHeaderRow(hooks) {
48
+ var useInstance = function useInstance(instance) {
49
+ Object.assign(instance, {
50
+ HeaderRow: HeaderRow
51
+ });
52
+ };
53
+
54
+ hooks.useInstance.push(useInstance);
55
+ };
56
+
57
+ export default useHeaderRow;
@@ -0,0 +1,37 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
8
+ /*
9
+ * Licensed Materials - Property of IBM
10
+ * 5724-Q36
11
+ * (c) Copyright IBM Corp. 2021
12
+ * US Government Users Restricted Rights - Use, duplication or disclosure
13
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
14
+ */
15
+ import React from 'react';
16
+ import cx from 'classnames';
17
+ import { pkg } from '../../../settings';
18
+ var blockClass = "".concat(pkg.prefix, "--datagrid"); // TableBody from carbon is a functional component
19
+ // hence no way to pass the ref to html element without changes in carbon side
20
+ // define html directly here.
21
+ // ref should be passed in thru getTableBodyProps
22
+
23
+ var DatagridRefBody = function DatagridRefBody(datagridState) {
24
+ var getTableBodyProps = datagridState.getTableBodyProps,
25
+ rows = datagridState.rows,
26
+ prepareRow = datagridState.prepareRow;
27
+ return /*#__PURE__*/React.createElement("tbody", _extends({}, getTableBodyProps(), {
28
+ className: cx("".concat(blockClass, "__simple-body"), getTableBodyProps().className)
29
+ }), rows.map(function (row) {
30
+ prepareRow(row);
31
+ return row.RowRenderer(_objectSpread(_objectSpread({}, datagridState), {}, {
32
+ row: row
33
+ }));
34
+ }));
35
+ };
36
+
37
+ export default DatagridRefBody;