@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
@@ -41,16 +41,16 @@ var _checkActiveHeaderCell = require("./utils/checkActiveHeaderCell");
41
41
 
42
42
  var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
43
43
 
44
+ var _getSpreadsheetWidth = require("./utils/getSpreadsheetWidth");
45
+
44
46
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
47
 
46
48
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
49
 
48
- /**
49
- * Copyright IBM Corp. 2022, 2022
50
- *
51
- * This source code is licensed under the Apache-2.0 license found in the
52
- * LICENSE file in the root directory of this source tree.
53
- */
50
+ 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; }
51
+
52
+ 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) { (0, _defineProperty2.default)(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; }
53
+
54
54
  var blockClass = "".concat(_settings.pkg.prefix, "--data-spreadsheet");
55
55
  var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
56
56
  var columns = _ref.columns,
@@ -75,7 +75,10 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
75
75
  setClickAndHoldActive = _ref.setClickAndHoldActive,
76
76
  currentMatcher = _ref.currentMatcher,
77
77
  setCurrentMatcher = _ref.setCurrentMatcher,
78
- onSelectionAreaChange = _ref.onSelectionAreaChange;
78
+ onSelectionAreaChange = _ref.onSelectionAreaChange,
79
+ setActiveCellInsideSelectionArea = _ref.setActiveCellInsideSelectionArea,
80
+ totalVisibleColumns = _ref.totalVisibleColumns;
81
+ var contentScrollRef = (0, _react.useRef)();
79
82
  var previousState = (0, _hooks.usePreviousValue)({
80
83
  selectionAreaData: selectionAreaData,
81
84
  clickAndHoldActive: clickAndHoldActive
@@ -133,18 +136,20 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
133
136
 
134
137
  if (!area.areaCreated && area.point1 && area.point2 && area.matcher) {
135
138
  (0, _createCellSelectionArea.createCellSelectionArea)({
139
+ ref: ref,
136
140
  area: area,
137
141
  blockClass: blockClass,
138
142
  defaultColumn: defaultColumn,
139
143
  selectionAreas: selectionAreas,
140
- setSelectionAreas: setSelectionAreas
144
+ setSelectionAreas: setSelectionAreas,
145
+ setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea
141
146
  });
142
147
  }
143
148
 
144
149
  return;
145
150
  });
146
151
  }
147
- }, [selectionAreas, setSelectionAreas, defaultColumn, onSelectionAreaChange, setSelectionAreaData]);
152
+ }, [selectionAreas, setSelectionAreas, defaultColumn, onSelectionAreaChange, setSelectionAreaData, ref, activeCellCoordinates, setActiveCellInsideSelectionArea]);
148
153
 
149
154
  var populateSelectionAreaCellData = function populateSelectionAreaCellData(_ref2) {
150
155
  var rowStart = _ref2.rowStart,
@@ -222,6 +227,9 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
222
227
  // meaning that selectionAreas should only have one item by default
223
228
 
224
229
  if (isHoldingCommandKey) {
230
+ var activeCellElement = ref.current.querySelector(".".concat(blockClass, "__active-cell--highlight"));
231
+ activeCellElement.setAttribute('data-selection-id', tempMatcher);
232
+ setActiveCellInsideSelectionArea(true);
225
233
  setActiveCellCoordinates(activeCoordinates);
226
234
  setCurrentMatcher(tempMatcher);
227
235
  setSelectionAreas(function (prev) {
@@ -252,6 +260,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
252
260
  setSelectionAreas(selectionAreaClone);
253
261
  }
254
262
  } else {
263
+ setActiveCellInsideSelectionArea(false);
255
264
  setActiveCellCoordinates(activeCoordinates); // remove all previous cell selections
256
265
 
257
266
  (0, _removeCellSelections.removeCellSelections)({
@@ -265,7 +274,22 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
265
274
  setSelectionAreaData([]);
266
275
  }
267
276
  };
268
- }, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref, setSelectionAreaData]);
277
+ }, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref, setSelectionAreaData, setActiveCellInsideSelectionArea]);
278
+
279
+ var handleBodyScroll = function handleBodyScroll() {
280
+ var headerRowElement = ref.current.querySelector("\n .".concat(blockClass, "__header--container .").concat(blockClass, "__tr"));
281
+ headerRowElement.scrollLeft = contentScrollRef.current.scrollLeft;
282
+ };
283
+
284
+ (0, _react.useEffect)(function () {
285
+ contentScrollRef.current.addEventListener('scroll', function (event) {
286
+ return handleBodyScroll(event);
287
+ });
288
+ var contentScrollElementRef = contentScrollRef.current;
289
+ return function () {
290
+ contentScrollElementRef.removeEventListener('scroll', handleBodyScroll);
291
+ };
292
+ });
269
293
  var handleBodyCellHover = (0, _react.useCallback)(function (cell, columnIndex) {
270
294
  return function () {
271
295
  if (clickAndHoldActive) {
@@ -298,7 +322,8 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
298
322
  };
299
323
  }, [clickAndHoldActive, currentMatcher, setSelectionAreas]);
300
324
  var handleRowHeaderClick = (0, _react.useCallback)(function (index) {
301
- return function () {
325
+ return function (event) {
326
+ var isHoldingCommandKey = event.metaKey || event.ctrlKey;
302
327
  (0, _handleHeaderCellSelection.handleHeaderCellSelection)({
303
328
  type: 'row',
304
329
  activeCellCoordinates: activeCellCoordinates,
@@ -309,7 +334,8 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
309
334
  setSelectionAreas: setSelectionAreas,
310
335
  spreadsheetRef: ref,
311
336
  index: index,
312
- setSelectionAreaData: setSelectionAreaData
337
+ setSelectionAreaData: setSelectionAreaData,
338
+ isHoldingCommandKey: isHoldingCommandKey
313
339
  });
314
340
  };
315
341
  }, [columns, ref, setSelectionAreas, setCurrentMatcher, setActiveCellCoordinates, activeCellCoordinates, rows, setSelectionAreaData]); // Builds the empty rows and calls `onDataUpdate` to set the new empty rows
@@ -351,8 +377,13 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
351
377
  style: style
352
378
  }), {
353
379
  className: (0, _classnames.default)("".concat(blockClass, "__tr")),
354
- "data-row-index": index
355
- }), /*#__PURE__*/_react.default.createElement("button", {
380
+ "data-row-index": index,
381
+ "aria-rowindex": index + 1
382
+ }), /*#__PURE__*/_react.default.createElement("div", {
383
+ role: "rowheader",
384
+ className: "".concat(blockClass, "__td-th--cell-container")
385
+ }, /*#__PURE__*/_react.default.createElement("button", {
386
+ id: "".concat(blockClass, "__cell--").concat(index, "--header"),
356
387
  tabIndex: -1,
357
388
  "data-row-index": index,
358
389
  "data-column-index": "header",
@@ -362,22 +393,30 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
362
393
  style: {
363
394
  width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
364
395
  }
365
- }, index + 1), row.cells.map(function (cell, index) {
366
- return /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
396
+ }, index + 1)), row.cells.map(function (cell, index) {
397
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
398
+ key: "cell_".concat(index),
399
+ "aria-colindex": index + 1
400
+ }, cell.getCellProps(), {
401
+ role: "gridcell",
402
+ style: _objectSpread(_objectSpread({}, cell.getCellProps().style), {}, {
403
+ display: 'grid',
404
+ minWidth: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width
405
+ })
406
+ }), /*#__PURE__*/_react.default.createElement("button", {
407
+ id: "".concat(blockClass, "__cell--").concat(cell.row.index, "--").concat(index),
367
408
  tabIndex: -1,
368
409
  "data-row-index": cell.row.index,
369
- "data-column-index": index
370
- }, cell.getCellProps(), {
410
+ "data-column-index": index,
371
411
  className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "__body--td"), "".concat(blockClass, "--interactive-cell-element")),
372
- key: "cell_".concat(index),
373
412
  onMouseDown: handleBodyCellClick(cell, index),
374
413
  onMouseOver: handleBodyCellHover(cell, index),
375
414
  onFocus: function onFocus() {},
376
415
  type: "button"
377
- }), cell.render('Cell'));
416
+ }, cell.render('Cell')));
378
417
  }));
379
418
  }
380
- }, [prepareRow, rows, defaultColumn.rowHeaderWidth, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas, handleRowHeaderClick, handleBodyCellClick, handleBodyCellHover]);
419
+ }, [prepareRow, rows, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas, handleRowHeaderClick, handleBodyCellClick, handleBodyCellHover, defaultColumn]);
381
420
  var spreadsheetBodyRef = (0, _react.useRef)();
382
421
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
383
422
  ref: spreadsheetBodyRef,
@@ -387,7 +426,13 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
387
426
  height: 400,
388
427
  itemCount: rows.length || defaultEmptyRowCount,
389
428
  itemSize: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
390
- width: totalColumnsWidth + scrollBarSize
429
+ width: (0, _getSpreadsheetWidth.getSpreadsheetWidth)({
430
+ scrollBarSizeValue: scrollBarSize,
431
+ totalVisibleColumns: totalVisibleColumns,
432
+ defaultColumn: defaultColumn,
433
+ totalColumnsWidth: totalColumnsWidth
434
+ }),
435
+ outerRef: contentScrollRef
391
436
  }, rows !== null && rows !== void 0 && rows.length ? RenderRow : RenderEmptyRows));
392
437
  });
393
438
  exports.DataSpreadsheetBody = DataSpreadsheetBody;
@@ -489,6 +534,11 @@ DataSpreadsheetBody.propTypes = {
489
534
  */
490
535
  setActiveCellCoordinates: _propTypes.default.func,
491
536
 
537
+ /**
538
+ * Setter fn for active cell inside of selection area
539
+ */
540
+ setActiveCellInsideSelectionArea: _propTypes.default.func,
541
+
492
542
  /**
493
543
  * Setter fn for clickAndHold state value
494
544
  */
@@ -517,5 +567,11 @@ DataSpreadsheetBody.propTypes = {
517
567
  /**
518
568
  * The total columns width
519
569
  */
520
- totalColumnsWidth: _propTypes.default.number
570
+ totalColumnsWidth: _propTypes.default.number,
571
+
572
+ /**
573
+ * The total number of columns to be initially visible, additional columns will be rendered and
574
+ * visible via horizontal scrollbar
575
+ */
576
+ totalVisibleColumns: _propTypes.default.number
521
577
  };
@@ -21,15 +21,17 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
21
21
 
22
22
  var _classnames = _interopRequireDefault(require("classnames"));
23
23
 
24
- var _layout = require("@carbon/layout");
25
-
26
24
  var _settings = require("../../settings");
27
25
 
26
+ var _hooks = require("../../global/js/hooks");
27
+
28
28
  var _checkActiveHeaderCell = require("./utils/checkActiveHeaderCell");
29
29
 
30
30
  var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
31
31
 
32
- var _hooks = require("../../global/js/hooks");
32
+ var _selectAllCells = require("./utils/selectAllCells");
33
+
34
+ var _getSpreadsheetWidth = require("./utils/getSpreadsheetWidth");
33
35
 
34
36
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
37
 
@@ -52,7 +54,9 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
52
54
  setCurrentMatcher = _ref.setCurrentMatcher,
53
55
  setSelectionAreas = _ref.setSelectionAreas,
54
56
  setSelectionAreaData = _ref.setSelectionAreaData,
55
- rows = _ref.rows;
57
+ rows = _ref.rows,
58
+ totalVisibleColumns = _ref.totalVisibleColumns,
59
+ updateActiveCellCoordinates = _ref.updateActiveCellCoordinates;
56
60
 
57
61
  var _useState = (0, _react.useState)(0),
58
62
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -74,7 +78,8 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
74
78
  }, [cellSize, ref, scrollBarSize, previousState === null || previousState === void 0 ? void 0 : previousState.cellSize]);
75
79
 
76
80
  var handleColumnHeaderClick = function handleColumnHeaderClick(index) {
77
- return function () {
81
+ return function (event) {
82
+ var isHoldingCommandKey = event.metaKey || event.ctrlKey;
78
83
  (0, _handleHeaderCellSelection.handleHeaderCellSelection)({
79
84
  type: 'column',
80
85
  activeCellCoordinates: activeCellCoordinates,
@@ -85,45 +90,75 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
85
90
  setSelectionAreas: setSelectionAreas,
86
91
  spreadsheetRef: ref,
87
92
  index: index,
88
- setSelectionAreaData: setSelectionAreaData
93
+ setSelectionAreaData: setSelectionAreaData,
94
+ isHoldingCommandKey: isHoldingCommandKey
89
95
  });
90
96
  };
91
97
  };
92
98
 
99
+ var handleSelectAllClick = function handleSelectAllClick() {
100
+ (0, _selectAllCells.selectAllCells)({
101
+ ref: ref,
102
+ setCurrentMatcher: setCurrentMatcher,
103
+ setSelectionAreas: setSelectionAreas,
104
+ rows: rows,
105
+ columns: columns,
106
+ activeCellCoordinates: activeCellCoordinates,
107
+ updateActiveCellCoordinates: updateActiveCellCoordinates
108
+ });
109
+ };
110
+
93
111
  return /*#__PURE__*/_react.default.createElement("div", {
94
- className: (0, _classnames.default)("".concat(blockClass, "__header--container"))
112
+ className: (0, _classnames.default)("".concat(blockClass, "__header--container")),
113
+ role: "rowgroup"
95
114
  }, headerGroups.map(function (headerGroup, index) {
96
115
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
97
116
  key: "header_".concat(index)
98
117
  }, headerGroup.getHeaderGroupProps(), {
99
118
  style: _objectSpread(_objectSpread({}, headerGroup.getHeaderGroupProps().style), {}, {
100
- width: (0, _layout.px)(parseInt(headerGroup.getHeaderGroupProps().style.width) + scrollBarSizeValue)
119
+ width: (0, _getSpreadsheetWidth.getSpreadsheetWidth)({
120
+ type: 'header',
121
+ headerGroup: headerGroup,
122
+ scrollBarSizeValue: scrollBarSizeValue,
123
+ totalVisibleColumns: totalVisibleColumns,
124
+ defaultColumn: defaultColumn
125
+ }),
126
+ overflow: 'hidden'
101
127
  }),
102
128
  className: "".concat(blockClass, "__tr")
103
- }), /*#__PURE__*/_react.default.createElement("button", {
104
- "data-row-index": "header",
105
- "data-column-index": "header",
106
- type: "button",
107
- tabIndex: -1,
108
- className: (0, _classnames.default)("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header')),
129
+ }), /*#__PURE__*/_react.default.createElement("div", {
130
+ role: "columnheader",
131
+ className: "".concat(blockClass, "__select-all-cell-container"),
109
132
  style: {
110
133
  width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth,
111
134
  height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
112
135
  }
113
- }, "\xA0"), headerGroup.headers.map(function (column, index) {
114
- return /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
136
+ }, /*#__PURE__*/_react.default.createElement("button", {
137
+ id: "".concat(blockClass, "__cell--header--header"),
138
+ "data-row-index": "header",
139
+ "data-column-index": "header",
140
+ type: "button",
141
+ tabIndex: -1,
142
+ onClick: handleSelectAllClick,
143
+ className: (0, _classnames.default)("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__th--select-all"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header'))
144
+ }, "\xA0")), headerGroup.headers.map(function (column, index) {
145
+ return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
115
146
  key: "column_".concat(index),
147
+ role: "columnheader",
148
+ className: "".concat(blockClass, "__columnheader")
149
+ }, column.getHeaderProps()), /*#__PURE__*/_react.default.createElement("button", {
150
+ id: "".concat(blockClass, "__cell--header--").concat(index),
116
151
  "data-row-index": "header",
117
152
  "data-column-index": index,
118
153
  tabIndex: -1,
119
154
  onClick: handleColumnHeaderClick(index),
120
155
  style: {
121
- height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
122
- }
123
- }, column.getHeaderProps(), {
156
+ height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
157
+ width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width
158
+ },
124
159
  className: (0, _classnames.default)("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === index || (0, _checkActiveHeaderCell.checkActiveHeaderCell)(index, selectionAreas, 'column'))),
125
160
  type: "button"
126
- }), column.render('Header'));
161
+ }, column.render('Header')));
127
162
  }));
128
163
  }));
129
164
  });
@@ -194,5 +229,16 @@ DataSpreadsheetHeader.propTypes = {
194
229
  /**
195
230
  * Setter fn for selectionAreas value
196
231
  */
197
- setSelectionAreas: _propTypes.default.func
232
+ setSelectionAreas: _propTypes.default.func,
233
+
234
+ /**
235
+ * The total number of columns to be initially visible, additional columns will be rendered and
236
+ * visible via horizontal scrollbar
237
+ */
238
+ totalVisibleColumns: _propTypes.default.number,
239
+
240
+ /**
241
+ * Function used to update the active cell coordinates
242
+ */
243
+ updateActiveCellCoordinates: _propTypes.default.func
198
244
  };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "useMoveActiveCell", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _useMoveActiveCell.useMoveActiveCell;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "useMultipleKeyTracking", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _useMultipleKeyTracking.useMultipleKeyTracking;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "useResetSpreadsheetFocus", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _useResetSpreadsheetFocus.useResetSpreadsheetFocus;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "useSpreadsheetEdit", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _useSpreadsheetEdit.useSpreadsheetEdit;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "useSpreadsheetOutsideClick", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _useSpreadsheetOutsideClick.useSpreadsheetOutsideClick;
34
+ }
35
+ });
36
+
37
+ var _useMoveActiveCell = require("./useMoveActiveCell");
38
+
39
+ var _useMultipleKeyTracking = require("./useMultipleKeyTracking");
40
+
41
+ var _useResetSpreadsheetFocus = require("./useResetSpreadsheetFocus");
42
+
43
+ var _useSpreadsheetOutsideClick = require("./useSpreadsheetOutsideClick");
44
+
45
+ var _useSpreadsheetEdit = require("./useSpreadsheetEdit");
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useMultipleKeyTracking = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _react = require("react");
15
+
16
+ var _hooks = require("../../../global/js/hooks");
17
+
18
+ var _handleMultipleKeys = require("../utils/handleMultipleKeys");
19
+
20
+ /**
21
+ * Copyright IBM Corp. 2022, 2022
22
+ *
23
+ * This source code is licensed under the Apache-2.0 license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */
26
+ var hasFocus = function hasFocus() {
27
+ return typeof document !== 'undefined' && document.hasFocus();
28
+ };
29
+
30
+ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
31
+ var ref = _ref.ref,
32
+ containerHasFocus = _ref.containerHasFocus,
33
+ isEditing = _ref.isEditing;
34
+
35
+ var _useState = (0, _react.useState)(''),
36
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
37
+ usingMac = _useState2[0],
38
+ setUsingMac = _useState2[1];
39
+
40
+ var _useState3 = (0, _react.useState)(hasFocus),
41
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
42
+ windowFocused = _useState4[0],
43
+ setWindowFocused = _useState4[1];
44
+
45
+ var _useState5 = (0, _react.useState)([]),
46
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
47
+ keysPressedList = _useState6[0],
48
+ setKeysPressedList = _useState6[1];
49
+
50
+ var previousState = (0, _hooks.usePreviousValue)({
51
+ isEditing: isEditing,
52
+ windowFocused: windowFocused
53
+ }); // useEffect to check for window focus, if window loses focus
54
+ // we need to clear out the keysPressedList
55
+
56
+ (0, _react.useEffect)(function () {
57
+ var userAgentString = window.navigator.userAgent;
58
+
59
+ if (userAgentString.includes('Macintosh')) {
60
+ setUsingMac(true);
61
+ } else {
62
+ setUsingMac(false);
63
+ }
64
+
65
+ setWindowFocused(hasFocus());
66
+
67
+ var onWindowFocus = function onWindowFocus() {
68
+ return setWindowFocused(true);
69
+ };
70
+
71
+ var onWindowBlur = function onWindowBlur() {
72
+ return setWindowFocused(false);
73
+ };
74
+
75
+ window.addEventListener('focus', onWindowFocus);
76
+ window.addEventListener('blur', onWindowBlur);
77
+ return function () {
78
+ window.removeEventListener('focus', onWindowFocus);
79
+ window.removeEventListener('blur', onWindowBlur);
80
+ };
81
+ }, []);
82
+ (0, _react.useEffect)(function () {
83
+ if (containerHasFocus && !isEditing) {
84
+ ref.current.onkeydown = ref.current.onkeyup = function (event) {
85
+ // If keydown, we will add the new key to the keysPressedList array
86
+ if (event.type === 'keydown') {
87
+ // Prevent multiple keys of the same type being added to our keysPressedList array
88
+ if (keysPressedList.includes(event.code)) {
89
+ return;
90
+ } // Because keyup events are lost when using the Command key
91
+ // we need to remove the previously pressed keys so that we
92
+ // do not have keys in the pressed list that should not be
93
+
94
+
95
+ if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac) && keysPressedList.length > 1) {
96
+ var clonedKeys = (0, _toConsumableArray2.default)(keysPressedList);
97
+ var filteredClonedKeys = clonedKeys.filter(function (item) {
98
+ return item === 'MetaLeft' || item === 'MetaRight';
99
+ });
100
+ filteredClonedKeys.push(event.code);
101
+ return setKeysPressedList((0, _toConsumableArray2.default)(new Set(filteredClonedKeys)));
102
+ }
103
+
104
+ var tempKeys = (0, _toConsumableArray2.default)(keysPressedList);
105
+ tempKeys.push(event.code);
106
+ setKeysPressedList((0, _toConsumableArray2.default)(new Set(tempKeys)));
107
+ } // If keyup, we will remove the key from the keysPressedList array
108
+
109
+
110
+ if (event.type === 'keyup') {
111
+ var _tempKeys = (0, _toConsumableArray2.default)(keysPressedList);
112
+
113
+ var filteredClone = _tempKeys.filter(function (item) {
114
+ return item !== event.code;
115
+ }); // Keyup events are lost on all other keys if a Meta key is used
116
+ // so to work around this behavior, we empty out all other keys
117
+ // from the keysPressedList array if we detect a Meta keyup event
118
+
119
+
120
+ if (event.code === 'MetaLeft' || event.code === 'MetaRight') {
121
+ return setKeysPressedList([]);
122
+ }
123
+
124
+ setKeysPressedList((0, _toConsumableArray2.default)(new Set(filteredClone)));
125
+ }
126
+ };
127
+ }
128
+
129
+ if (previousState !== null && previousState !== void 0 && previousState.windowFocused && !windowFocused) {
130
+ setKeysPressedList([]);
131
+ } // Remove handlers if the spreadsheet container loses focus
132
+ // or is currently in edit mode
133
+
134
+
135
+ if (!containerHasFocus || isEditing) {
136
+ ref.current.onkeydown = undefined;
137
+ ref.current.onkeyup = undefined;
138
+
139
+ if (!(previousState !== null && previousState !== void 0 && previousState.isEditing) && isEditing) {
140
+ setKeysPressedList([]);
141
+ }
142
+ }
143
+ }, [keysPressedList, containerHasFocus, ref, isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing, windowFocused, previousState === null || previousState === void 0 ? void 0 : previousState.windowFocused, usingMac]);
144
+ return {
145
+ keysPressedList: keysPressedList,
146
+ windowFocused: windowFocused,
147
+ usingMac: usingMac
148
+ };
149
+ };
150
+
151
+ exports.useMultipleKeyTracking = useMultipleKeyTracking;
@@ -16,8 +16,7 @@ var _settings = require("../../../settings");
16
16
  * LICENSE file in the root directory of this source tree.
17
17
  */
18
18
  var useResetSpreadsheetFocus = function useResetSpreadsheetFocus(_ref) {
19
- var activeKeys = _ref.activeKeys,
20
- _ref$blockClass = _ref.blockClass,
19
+ var _ref$blockClass = _ref.blockClass,
21
20
  blockClass = _ref$blockClass === void 0 ? "".concat(_settings.pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
22
21
  focusedElement = _ref.focusedElement,
23
22
  removeActiveCell = _ref.removeActiveCell,
@@ -27,13 +26,12 @@ var useResetSpreadsheetFocus = function useResetSpreadsheetFocus(_ref) {
27
26
  if (!focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
28
27
  setContainerHasFocus(false);
29
28
  removeActiveCell();
30
- activeKeys.current = [];
31
29
  }
32
30
 
33
31
  if (focusedElement.classList.contains(blockClass) || focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
34
32
  setContainerHasFocus(true);
35
33
  }
36
- }, [focusedElement, removeActiveCell, activeKeys, blockClass, setContainerHasFocus]);
34
+ }, [focusedElement, removeActiveCell, blockClass, setContainerHasFocus]);
37
35
  };
38
36
 
39
37
  exports.useResetSpreadsheetFocus = useResetSpreadsheetFocus;
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSpreadsheetEdit = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _layout = require("@carbon/layout");
11
+
12
+ // /**
13
+ // * Copyright IBM Corp. 2022, 2022
14
+ // *
15
+ // * This source code is licensed under the Apache-2.0 license found in the
16
+ // * LICENSE file in the root directory of this source tree.
17
+ // */
18
+ var useSpreadsheetEdit = function useSpreadsheetEdit(_ref) {
19
+ var isEditing = _ref.isEditing,
20
+ rows = _ref.rows,
21
+ activeCellCoordinates = _ref.activeCellCoordinates,
22
+ activeCellRef = _ref.activeCellRef,
23
+ cellEditorRef = _ref.cellEditorRef,
24
+ cellEditorRulerRef = _ref.cellEditorRulerRef,
25
+ columns = _ref.columns,
26
+ defaultColumn = _ref.defaultColumn,
27
+ cellEditorValue = _ref.cellEditorValue;
28
+ (0, _react.useEffect)(function () {
29
+ if (isEditing) {
30
+ var _rows$activeCellCoord, _cellProps$column, _cellEditorRef$curren;
31
+
32
+ var cellProps = (_rows$activeCellCoord = rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row]) === null || _rows$activeCellCoord === void 0 ? void 0 : _rows$activeCellCoord.cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column];
33
+ var activeCellLeftPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.left;
34
+ var activeCellTopPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.top;
35
+ cellEditorRef.current.style.left = activeCellLeftPosition;
36
+ cellEditorRef.current.style.top = activeCellTopPosition;
37
+ cellEditorRef.current.style.display = 'block';
38
+ cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
39
+ cellEditorRef.current.style.height = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height;
40
+ cellEditorRef.current.style.paddingTop = "".concat((parseInt(activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height) - 16) / 2 - 1, "px"); // calculate paddingTop based on cellHeight which could be variable depending on the cellSize prop
41
+
42
+ cellEditorRef.current.style.textAlign = (cellProps === null || cellProps === void 0 ? void 0 : (_cellProps$column = cellProps.column) === null || _cellProps$column === void 0 ? void 0 : _cellProps$column.placement) === 'right' ? 'right' : 'left';
43
+ (_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 ? void 0 : _cellEditorRef$curren.focus();
44
+ var rulerWidth = cellEditorRulerRef.current.offsetWidth;
45
+ var cellWidth = activeCellRef.current.offsetWidth;
46
+
47
+ if (rulerWidth >= cellWidth) {
48
+ var widthMultiplier = Math.floor(rulerWidth / cellWidth) + 1;
49
+ var startingColumnPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column;
50
+ var startingRowPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row;
51
+ var totalColumns = columns.length;
52
+ var totalRows = rows.length;
53
+ var totalMultiplierPossible = totalColumns - startingColumnPosition;
54
+ var totalCellEditorMaxHeight = (totalRows - startingRowPosition) * defaultColumn.rowHeight;
55
+ cellEditorRef.current.style.maxHeight = (0, _layout.px)(totalCellEditorMaxHeight);
56
+ cellEditorRef.current.style.width = (0, _layout.px)(cellWidth * (widthMultiplier <= totalMultiplierPossible ? widthMultiplier : totalMultiplierPossible));
57
+ cellEditorRef.current.style.height = (0, _layout.px)(cellEditorRef.current.scrollHeight); // adds dynamic height to cell editor
58
+ // Cell editor has reached max height, we need to add the scrolling back.
59
+ // We also need to subtract 1 to account for the fact that the cell editor
60
+ // is placed one pixel below the cell being edited to account for the border
61
+
62
+ if (cellEditorRef.current.clientHeight === totalCellEditorMaxHeight - 1) {
63
+ cellEditorRef.current.style.overflow = 'auto';
64
+ } else {
65
+ cellEditorRef.current.style.overflow = 'hidden';
66
+ }
67
+ }
68
+ }
69
+
70
+ if (!isEditing) {
71
+ cellEditorRef.current.style.overflow = 'hidden';
72
+ cellEditorRef.current.style.display = 'none';
73
+ cellEditorRef.current.blur();
74
+ activeCellRef.current.focus();
75
+ }
76
+ }, [isEditing, activeCellCoordinates, rows, cellEditorValue, columns.length, defaultColumn, cellEditorValue, activeCellRef, cellEditorRef, cellEditorRulerRef]);
77
+ };
78
+
79
+ exports.useSpreadsheetEdit = useSpreadsheetEdit;