@carbon/ibm-products 1.12.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) 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 +264 -0
  6. package/css/components/Datagrid/styles/datagrid.css.map +1 -0
  7. package/css/components/Datagrid/styles/index.css +509 -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 +653 -21
  24. package/css/index-full-carbon.css.map +1 -1
  25. package/css/index-full-carbon.min.css +6 -6
  26. package/css/index-full-carbon.min.css.map +1 -1
  27. package/css/index-without-carbon-released-only.css +21 -10
  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 +653 -21
  32. package/css/index-without-carbon.css.map +1 -1
  33. package/css/index-without-carbon.min.css +5 -5
  34. package/css/index-without-carbon.min.css.map +1 -1
  35. package/css/index.css +653 -21
  36. package/css/index.css.map +1 -1
  37. package/css/index.min.css +6 -6
  38. package/css/index.min.css.map +1 -1
  39. package/es/components/ActionBar/ActionBar.js +3 -1
  40. package/es/components/ActionBar/ActionBarOverflowItems.js +5 -3
  41. package/es/components/AddSelect/AddSelect.js +98 -40
  42. package/es/components/AddSelect/AddSelectFilter.js +129 -0
  43. package/es/components/AddSelect/AddSelectList.js +27 -1
  44. package/es/components/AddSelect/AddSelectSidebar.js +15 -5
  45. package/es/components/AddSelect/add-select-utils.js +30 -0
  46. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
  47. package/es/components/DataSpreadsheet/DataSpreadsheet.js +269 -142
  48. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +122 -39
  49. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +46 -17
  50. package/es/components/DataSpreadsheet/hooks/index.js +11 -0
  51. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +139 -0
  52. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  53. package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +68 -0
  54. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -6
  55. package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +20 -8
  56. package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
  57. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +121 -0
  58. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +108 -0
  59. package/es/components/DataSpreadsheet/utils/handleEditSubmit.js +87 -0
  60. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +42 -8
  61. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +225 -13
  62. package/es/components/DataSpreadsheet/utils/selectAllCells.js +53 -0
  63. package/es/components/Datagrid/Datagrid/Datagrid.js +70 -0
  64. package/es/components/Datagrid/Datagrid/DatagridBody.js +36 -0
  65. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -0
  66. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -0
  67. package/es/components/Datagrid/Datagrid/DatagridHead.js +31 -0
  68. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +57 -0
  69. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +37 -0
  70. package/es/components/Datagrid/Datagrid/DatagridRow.js +50 -0
  71. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +50 -0
  72. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +122 -0
  73. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +36 -0
  74. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -0
  75. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +87 -0
  76. package/es/components/Datagrid/Datagrid/DraggableElement.js +188 -0
  77. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +78 -0
  78. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +51 -0
  79. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +140 -0
  80. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +157 -0
  81. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +62 -0
  82. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +13 -0
  83. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +9 -0
  84. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +62 -0
  85. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +139 -0
  86. package/es/components/Datagrid/Datagrid/addons/RowSize/index.js +8 -0
  87. package/es/components/Datagrid/Datagrid/index.js +8 -0
  88. package/es/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +6 -0
  89. package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +6 -0
  90. package/es/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +6 -0
  91. package/es/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +6 -0
  92. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -0
  93. package/es/components/Datagrid/Datagrid.stories/common.js +199 -0
  94. package/es/components/Datagrid/Datagrid.stories/index.js +5 -0
  95. package/es/components/Datagrid/common-column-ids.js +8 -0
  96. package/es/components/Datagrid/index.js +22 -0
  97. package/es/components/Datagrid/useActionsColumn.js +86 -0
  98. package/es/components/Datagrid/useColumnRightAlign.js +52 -0
  99. package/es/components/Datagrid/useCustomizeColumns.js +45 -0
  100. package/es/components/Datagrid/useDatagrid.js +44 -0
  101. package/es/components/Datagrid/useDefaultStringRenderer.js +48 -0
  102. package/es/components/Datagrid/useDisableSelectRows.js +84 -0
  103. package/es/components/Datagrid/useExpandedRow.js +52 -0
  104. package/es/components/Datagrid/useFlexResize.js +51 -0
  105. package/es/components/Datagrid/useFloatingScroll.js +88 -0
  106. package/es/components/Datagrid/useInfiniteScroll.js +54 -0
  107. package/es/components/Datagrid/useNestedRows.js +53 -0
  108. package/es/components/Datagrid/useOnRowClick.js +37 -0
  109. package/es/components/Datagrid/useParentDimensions.js +65 -0
  110. package/es/components/Datagrid/useResizeTable.js +40 -0
  111. package/es/components/Datagrid/useRowExpander.js +34 -0
  112. package/es/components/Datagrid/useRowIsMouseOver.js +61 -0
  113. package/es/components/Datagrid/useRowRenderer.js +30 -0
  114. package/es/components/Datagrid/useRowSize.js +56 -0
  115. package/es/components/Datagrid/useSelectAllToggle.js +74 -0
  116. package/es/components/Datagrid/useSelectRows.js +107 -0
  117. package/es/components/Datagrid/useSkeletonRows.js +32 -0
  118. package/es/components/Datagrid/useSortableColumns.js +110 -0
  119. package/es/components/Datagrid/useStickyColumn.js +183 -0
  120. package/es/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
  121. package/es/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
  122. package/es/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
  123. package/es/components/MultiAddSelect/MultiAddSelect.js +150 -3
  124. package/es/components/PageHeader/PageHeader.js +3 -1
  125. package/es/components/SingleAddSelect/SingleAddSelect.js +90 -4
  126. package/es/components/TagSet/TagSet.js +22 -6
  127. package/es/components/Tearsheet/TearsheetShell.js +34 -10
  128. package/es/components/UserProfileImage/UserProfileImage.js +37 -9
  129. package/es/components/index.js +2 -1
  130. package/es/global/js/package-settings.js +4 -2
  131. package/lib/components/ActionBar/ActionBar.js +3 -1
  132. package/lib/components/ActionBar/ActionBarOverflowItems.js +5 -3
  133. package/lib/components/AddSelect/AddSelect.js +97 -38
  134. package/lib/components/AddSelect/AddSelectFilter.js +147 -0
  135. package/lib/components/AddSelect/AddSelectList.js +28 -1
  136. package/lib/components/AddSelect/AddSelectSidebar.js +15 -11
  137. package/lib/components/AddSelect/add-select-utils.js +35 -2
  138. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
  139. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +279 -145
  140. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +121 -45
  141. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +47 -17
  142. package/lib/components/DataSpreadsheet/hooks/index.js +45 -0
  143. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +151 -0
  144. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  145. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +79 -0
  146. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -5
  147. package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +21 -8
  148. package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
  149. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +127 -0
  150. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +118 -0
  151. package/lib/components/DataSpreadsheet/utils/handleEditSubmit.js +94 -0
  152. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +44 -8
  153. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +235 -20
  154. package/lib/components/DataSpreadsheet/utils/selectAllCells.js +60 -0
  155. package/lib/components/Datagrid/Datagrid/Datagrid.js +86 -0
  156. package/lib/components/Datagrid/Datagrid/DatagridBody.js +50 -0
  157. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +31 -0
  158. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +38 -0
  159. package/lib/components/Datagrid/Datagrid/DatagridHead.js +43 -0
  160. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +73 -0
  161. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +44 -0
  162. package/lib/components/Datagrid/Datagrid/DatagridRow.js +56 -0
  163. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +55 -0
  164. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +139 -0
  165. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +44 -0
  166. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +35 -0
  167. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +101 -0
  168. package/lib/components/Datagrid/Datagrid/DraggableElement.js +210 -0
  169. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +92 -0
  170. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +65 -0
  171. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +166 -0
  172. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +173 -0
  173. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +73 -0
  174. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +25 -0
  175. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +23 -0
  176. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +80 -0
  177. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +160 -0
  178. package/lib/components/Datagrid/Datagrid/addons/RowSize/index.js +15 -0
  179. package/lib/components/Datagrid/Datagrid/index.js +15 -0
  180. package/lib/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +13 -0
  181. package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +13 -0
  182. package/lib/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +13 -0
  183. package/lib/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +13 -0
  184. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +112 -0
  185. package/lib/components/Datagrid/Datagrid.stories/common.js +215 -0
  186. package/lib/components/Datagrid/Datagrid.stories/index.js +47 -0
  187. package/lib/components/Datagrid/common-column-ids.js +16 -0
  188. package/lib/components/Datagrid/index.js +127 -0
  189. package/lib/components/Datagrid/useActionsColumn.js +94 -0
  190. package/lib/components/Datagrid/useColumnRightAlign.js +59 -0
  191. package/lib/components/Datagrid/useCustomizeColumns.js +55 -0
  192. package/lib/components/Datagrid/useDatagrid.js +58 -0
  193. package/lib/components/Datagrid/useDefaultStringRenderer.js +54 -0
  194. package/lib/components/Datagrid/useDisableSelectRows.js +92 -0
  195. package/lib/components/Datagrid/useExpandedRow.js +58 -0
  196. package/lib/components/Datagrid/useFlexResize.js +61 -0
  197. package/lib/components/Datagrid/useFloatingScroll.js +101 -0
  198. package/lib/components/Datagrid/useInfiniteScroll.js +67 -0
  199. package/lib/components/Datagrid/useNestedRows.js +65 -0
  200. package/lib/components/Datagrid/useOnRowClick.js +45 -0
  201. package/lib/components/Datagrid/useParentDimensions.js +75 -0
  202. package/lib/components/Datagrid/useResizeTable.js +48 -0
  203. package/lib/components/Datagrid/useRowExpander.js +45 -0
  204. package/lib/components/Datagrid/useRowIsMouseOver.js +66 -0
  205. package/lib/components/Datagrid/useRowRenderer.js +40 -0
  206. package/lib/components/Datagrid/useRowSize.js +67 -0
  207. package/lib/components/Datagrid/useSelectAllToggle.js +88 -0
  208. package/lib/components/Datagrid/useSelectRows.js +119 -0
  209. package/lib/components/Datagrid/useSkeletonRows.js +42 -0
  210. package/lib/components/Datagrid/useSortableColumns.js +117 -0
  211. package/lib/components/Datagrid/useStickyColumn.js +190 -0
  212. package/lib/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
  213. package/lib/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
  214. package/lib/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
  215. package/lib/components/MultiAddSelect/MultiAddSelect.js +150 -2
  216. package/lib/components/PageHeader/PageHeader.js +3 -1
  217. package/lib/components/SingleAddSelect/SingleAddSelect.js +91 -3
  218. package/lib/components/TagSet/TagSet.js +22 -6
  219. package/lib/components/Tearsheet/TearsheetShell.js +36 -10
  220. package/lib/components/UserProfileImage/UserProfileImage.js +37 -9
  221. package/lib/components/index.js +9 -1
  222. package/lib/global/js/package-settings.js +4 -2
  223. package/package.json +20 -16
  224. package/scss/components/AboutModal/_about-modal.scss +4 -0
  225. package/scss/components/AddSelect/_add-select.scss +51 -2
  226. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +72 -9
  227. package/scss/components/Datagrid/_datagrid.scss +66 -0
  228. package/scss/components/Datagrid/_index.scss +8 -0
  229. package/scss/components/Datagrid/_storybook-styles.scss +26 -0
  230. package/scss/components/Datagrid/styles/_variables.scss +9 -0
  231. package/scss/components/Datagrid/styles/addons/CustomizeColumnsModal.scss +48 -0
  232. package/scss/components/Datagrid/styles/addons/RowSizeDropdown.scss +23 -0
  233. package/scss/components/Datagrid/styles/datagrid.scss +318 -0
  234. package/scss/components/Datagrid/styles/index.scss +17 -0
  235. package/scss/components/Datagrid/styles/useActionsColumn.scss +24 -0
  236. package/scss/components/Datagrid/styles/useColumnRightAlign.scss +29 -0
  237. package/scss/components/Datagrid/styles/useNestedRows.scss +17 -0
  238. package/scss/components/Datagrid/styles/useNestedTable.scss +28 -0
  239. package/scss/components/Datagrid/styles/useSelectAllToggle.scss +28 -0
  240. package/scss/components/Datagrid/styles/useSortableColumns.scss +55 -0
  241. package/scss/components/Datagrid/styles/useStickyColumn.scss +38 -0
  242. package/scss/components/ExportModal/_export-modal.scss +0 -4
  243. package/scss/components/HTTPErrors/_http-errors.scss +16 -16
  244. package/scss/components/PageHeader/_page-header.scss +4 -0
  245. package/scss/components/Tearsheet/_tearsheet.scss +4 -0
  246. package/scss/components/_index.scss +1 -0
@@ -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;
@@ -9,6 +9,8 @@ var _react = require("react");
9
9
 
10
10
  var _settings = require("../../../settings");
11
11
 
12
+ var _removeCellSelections = require("../utils/removeCellSelections");
13
+
12
14
  /**
13
15
  * Copyright IBM Corp. 2022, 2022
14
16
  *
@@ -23,9 +25,7 @@ var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref) {
23
25
  setActiveCellCoordinates = _ref.setActiveCellCoordinates,
24
26
  setSelectionAreas = _ref.setSelectionAreas,
25
27
  removeActiveCell = _ref.removeActiveCell,
26
- removeCellSelections = _ref.removeCellSelections,
27
28
  setContainerHasFocus = _ref.setContainerHasFocus,
28
- activeKeys = _ref.activeKeys,
29
29
  removeCellEditor = _ref.removeCellEditor;
30
30
  (0, _react.useEffect)(function () {
31
31
  var handleOutsideClick = function handleOutsideClick(event) {
@@ -36,17 +36,18 @@ var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref) {
36
36
  setActiveCellCoordinates(null);
37
37
  setSelectionAreas([]);
38
38
  removeActiveCell();
39
- removeCellSelections();
39
+ (0, _removeCellSelections.removeCellSelections)({
40
+ spreadsheetRef: spreadsheetRef
41
+ });
40
42
  setContainerHasFocus(false);
41
43
  removeCellEditor();
42
- activeKeys.current = [];
43
44
  };
44
45
 
45
46
  document.addEventListener('click', handleOutsideClick);
46
47
  return function () {
47
48
  document.removeEventListener('click', handleOutsideClick);
48
49
  };
49
- }, [spreadsheetRef, removeActiveCell, removeCellSelections, activeKeys, blockClass, setActiveCellCoordinates, setContainerHasFocus, setSelectionAreas, removeCellEditor]);
50
+ }, [spreadsheetRef, removeActiveCell, blockClass, setActiveCellCoordinates, setContainerHasFocus, setSelectionAreas, removeCellEditor]);
50
51
  };
51
52
 
52
53
  exports.useSpreadsheetOutsideClick = useSpreadsheetOutsideClick;
@@ -9,6 +9,8 @@ var _layout = require("@carbon/layout");
9
9
 
10
10
  var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
11
11
 
12
+ var _getSelectionAreaPoints = require("./getSelectionAreaPoints");
13
+
12
14
  /**
13
15
  * Copyright IBM Corp. 2022, 2022
14
16
  *
@@ -16,21 +18,32 @@ var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
16
18
  * LICENSE file in the root directory of this source tree.
17
19
  */
18
20
  var createCellSelectionArea = function createCellSelectionArea(_ref) {
19
- var area = _ref.area,
21
+ var ref = _ref.ref,
22
+ area = _ref.area,
20
23
  blockClass = _ref.blockClass,
21
24
  defaultColumn = _ref.defaultColumn,
22
25
  selectionAreas = _ref.selectionAreas,
23
- setSelectionAreas = _ref.setSelectionAreas;
24
- var greatestRow = Math.max(area.point1.row, area.point2.row);
25
- var greatestColumn = Math.max(area.point1.column, area.point2.column);
26
- var lowestRowIndex = Math.min(area.point1.row, area.point2.row);
27
- var lowestColumnIndex = Math.min(area.point1.column, area.point2.column);
26
+ setSelectionAreas = _ref.setSelectionAreas,
27
+ setActiveCellInsideSelectionArea = _ref.setActiveCellInsideSelectionArea;
28
+
29
+ var _getSelectionAreaPoin = (0, _getSelectionAreaPoints.getSelectionAreaPoints)(area),
30
+ lowestColumnIndex = _getSelectionAreaPoin.lowestColumnIndex,
31
+ lowestRowIndex = _getSelectionAreaPoin.lowestRowIndex,
32
+ greatestColumnIndex = _getSelectionAreaPoin.greatestColumnIndex,
33
+ greatestRowIndex = _getSelectionAreaPoin.greatestRowIndex;
34
+
35
+ if (greatestRowIndex - lowestRowIndex > 0 || greatestColumnIndex - lowestColumnIndex > 0) {
36
+ setActiveCellInsideSelectionArea(true);
37
+ var activeCellElement = ref.current.querySelector(".".concat(blockClass, "__active-cell--highlight"));
38
+ activeCellElement.setAttribute('data-selection-id', area.matcher);
39
+ }
40
+
28
41
  var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]")) || document.querySelector(".".concat(blockClass, "__body--td")); // if we can't find the point1 element (this can happen in the case where a virtualized row is not present anymore in the DOM), we get the default height/width of the first body cell we find
29
42
 
30
43
  var selectionAreaCellWidth = point1Element.offsetWidth;
31
44
  var selectionAreaCellHeight = point1Element.offsetHeight;
32
- var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumn - lowestColumnIndex + 1);
33
- var selectionAreaTotalHeight = selectionAreaCellHeight * (greatestRow - lowestRowIndex + 1);
45
+ var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumnIndex - lowestColumnIndex + 1);
46
+ var selectionAreaTotalHeight = selectionAreaCellHeight * (greatestRowIndex - lowestRowIndex + 1);
34
47
  var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
35
48
  var placementElement = bodyContainer.querySelector("[data-row-index=\"".concat(lowestRowIndex, "\"][data-column-index=\"").concat(lowestColumnIndex, "\"]"));
36
49
  var relativePosition = {
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSelectionAreaPoints = void 0;
7
+
8
+ /**
9
+ * Copyright IBM Corp. 2022, 2022
10
+ *
11
+ * This source code is licensed under the Apache-2.0 license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ var getSelectionAreaPoints = function getSelectionAreaPoints(area) {
15
+ var greatestRowIndex = Math.max(area.point1.row, area.point2.row);
16
+ var greatestColumnIndex = Math.max(area.point1.column, area.point2.column);
17
+ var lowestRowIndex = Math.min(area.point1.row, area.point2.row);
18
+ var lowestColumnIndex = Math.min(area.point1.column, area.point2.column);
19
+ return {
20
+ greatestRowIndex: greatestRowIndex,
21
+ greatestColumnIndex: greatestColumnIndex,
22
+ lowestColumnIndex: lowestColumnIndex,
23
+ lowestRowIndex: lowestRowIndex
24
+ };
25
+ };
26
+
27
+ exports.getSelectionAreaPoints = getSelectionAreaPoints;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.handleActiveCellInSelectionEnter = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _getSelectionAreaPoints = require("./getSelectionAreaPoints");
13
+
14
+ 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; }
15
+
16
+ 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; }
17
+
18
+ var handleActiveCellInSelectionEnter = function handleActiveCellInSelectionEnter(_ref) {
19
+ var activeCellInsideSelectionArea = _ref.activeCellInsideSelectionArea,
20
+ activeCellCoordinates = _ref.activeCellCoordinates,
21
+ activeCellRef = _ref.activeCellRef,
22
+ selectionAreas = _ref.selectionAreas,
23
+ updateActiveCellCoordinates = _ref.updateActiveCellCoordinates;
24
+
25
+ if (!activeCellInsideSelectionArea) {
26
+ return;
27
+ }
28
+
29
+ var activeCellSelectionId = activeCellRef.current.getAttribute('data-selection-id');
30
+ var activeCellIndexInSelectionAreas = selectionAreas.findIndex(function (item) {
31
+ return item.matcher === activeCellSelectionId;
32
+ });
33
+ var selectionAreaToNavigate = selectionAreas[activeCellIndexInSelectionAreas];
34
+
35
+ var _getSelectionAreaPoin = (0, _getSelectionAreaPoints.getSelectionAreaPoints)(selectionAreaToNavigate),
36
+ lowestColumnIndex = _getSelectionAreaPoin.lowestColumnIndex,
37
+ lowestRowIndex = _getSelectionAreaPoin.lowestRowIndex,
38
+ greatestColumnIndex = _getSelectionAreaPoin.greatestColumnIndex,
39
+ greatestRowIndex = _getSelectionAreaPoin.greatestRowIndex; // Move active cell down one row if possible
40
+
41
+
42
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
43
+
44
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) < greatestRowIndex) {
45
+ updateActiveCellCoordinates({
46
+ coords: coordinatesClone,
47
+ updatedValue: {
48
+ row: (coordinatesClone === null || coordinatesClone === void 0 ? void 0 : coordinatesClone.row) + 1
49
+ },
50
+ optOutOfSelectionAreaUpdate: true
51
+ });
52
+ } // Move active cell to next column of selection area if it exists
53
+ // If not, find the next selection area and update active cell to
54
+ // be the first cell in that selection
55
+
56
+
57
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === greatestRowIndex) {
58
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) < greatestColumnIndex) {
59
+ updateActiveCellCoordinates({
60
+ coords: coordinatesClone,
61
+ updatedValue: {
62
+ column: (coordinatesClone === null || coordinatesClone === void 0 ? void 0 : coordinatesClone.column) + 1,
63
+ row: lowestRowIndex
64
+ },
65
+ optOutOfSelectionAreaUpdate: true
66
+ });
67
+ } // Move to next selection area if there is one, or back to
68
+ // the beginning of the current selection
69
+
70
+
71
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === greatestColumnIndex) {
72
+ if (selectionAreas.length > 1) {
73
+ if (selectionAreas[activeCellIndexInSelectionAreas + 1]) {
74
+ // Update activeCellRef data-selection-id attribute to the matcher of the next selection area
75
+ activeCellRef.current.setAttribute('data-selection-id', selectionAreas[activeCellIndexInSelectionAreas + 1].matcher);
76
+ var nextSelectionArea = selectionAreas[activeCellIndexInSelectionAreas + 1];
77
+
78
+ var _getSelectionAreaPoin2 = (0, _getSelectionAreaPoints.getSelectionAreaPoints)(nextSelectionArea),
79
+ _lowestColumnIndex = _getSelectionAreaPoin2.lowestColumnIndex,
80
+ _lowestRowIndex = _getSelectionAreaPoin2.lowestRowIndex;
81
+
82
+ updateActiveCellCoordinates({
83
+ coords: coordinatesClone,
84
+ updatedValue: {
85
+ column: _lowestColumnIndex,
86
+ row: _lowestRowIndex
87
+ },
88
+ optOutOfSelectionAreaUpdate: true
89
+ });
90
+ return;
91
+ } else {
92
+ // There are multiple selection areas and the active cell is in the last one
93
+ // So we need to move the active cell to the first cell in the first selection area
94
+ activeCellRef.current.setAttribute('data-selection-id', selectionAreas[0].matcher);
95
+ var firstSelectionArea = selectionAreas[0];
96
+
97
+ var _getSelectionAreaPoin3 = (0, _getSelectionAreaPoints.getSelectionAreaPoints)(firstSelectionArea),
98
+ _lowestColumnIndex2 = _getSelectionAreaPoin3.lowestColumnIndex,
99
+ _lowestRowIndex2 = _getSelectionAreaPoin3.lowestRowIndex;
100
+
101
+ updateActiveCellCoordinates({
102
+ coords: coordinatesClone,
103
+ updatedValue: {
104
+ column: _lowestColumnIndex2,
105
+ row: _lowestRowIndex2
106
+ },
107
+ optOutOfSelectionAreaUpdate: true
108
+ });
109
+ }
110
+ } // Only one selection area, go back to first cell in the selection
111
+
112
+
113
+ if (selectionAreas.length === 1) {
114
+ return updateActiveCellCoordinates({
115
+ coords: coordinatesClone,
116
+ updatedValue: {
117
+ column: lowestColumnIndex,
118
+ row: lowestRowIndex
119
+ },
120
+ optOutOfSelectionAreaUpdate: true
121
+ });
122
+ }
123
+ }
124
+ }
125
+ };
126
+
127
+ exports.handleActiveCellInSelectionEnter = handleActiveCellInSelectionEnter;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleActiveCellInSelectionTab = void 0;
7
+
8
+ var _getSelectionAreaPoints = require("./getSelectionAreaPoints");
9
+
10
+ /**
11
+ * Copyright IBM Corp. 2022, 2022
12
+ *
13
+ * This source code is licensed under the Apache-2.0 license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ var handleActiveCellInSelectionTab = function handleActiveCellInSelectionTab(_ref) {
17
+ var activeCellInsideSelectionArea = _ref.activeCellInsideSelectionArea,
18
+ activeCellCoordinates = _ref.activeCellCoordinates,
19
+ activeCellRef = _ref.activeCellRef,
20
+ selectionAreas = _ref.selectionAreas,
21
+ updateActiveCellCoordinates = _ref.updateActiveCellCoordinates;
22
+
23
+ if (!activeCellInsideSelectionArea) {
24
+ return;
25
+ }
26
+
27
+ var activeCellSelectionId = activeCellRef.current.getAttribute('data-selection-id');
28
+ var activeCellIndexInSelectionAreas = selectionAreas.findIndex(function (item) {
29
+ return item.matcher === activeCellSelectionId;
30
+ });
31
+ var selectionAreaToNavigate = selectionAreas[activeCellIndexInSelectionAreas];
32
+
33
+ var _getSelectionAreaPoin = (0, _getSelectionAreaPoints.getSelectionAreaPoints)(selectionAreaToNavigate),
34
+ lowestColumnIndex = _getSelectionAreaPoin.lowestColumnIndex,
35
+ lowestRowIndex = _getSelectionAreaPoin.lowestRowIndex,
36
+ greatestColumnIndex = _getSelectionAreaPoin.greatestColumnIndex,
37
+ greatestRowIndex = _getSelectionAreaPoin.greatestRowIndex; // Move active cell to next column in selection area
38
+
39
+
40
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) < greatestColumnIndex) {
41
+ updateActiveCellCoordinates({
42
+ updatedValue: {
43
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) + 1
44
+ },
45
+ optOutOfSelectionAreaUpdate: true
46
+ });
47
+ } // Move active cell to next row of selection area if it exists
48
+ // If not, find the next selection area and update active cell to
49
+ // be the first cell in that selection
50
+
51
+
52
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === greatestColumnIndex) {
53
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) < greatestRowIndex) {
54
+ updateActiveCellCoordinates({
55
+ updatedValue: {
56
+ column: lowestColumnIndex,
57
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) + 1
58
+ },
59
+ optOutOfSelectionAreaUpdate: true
60
+ });
61
+ } // Move to next selection area if there is on, or back to
62
+ // the beginning of the current selection
63
+
64
+
65
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === greatestRowIndex) {
66
+ if (selectionAreas.length > 1) {
67
+ if (selectionAreas[activeCellIndexInSelectionAreas + 1]) {
68
+ // Update activeCellRef data-selection-id attribute to the matcher of the next selection area
69
+ activeCellRef.current.setAttribute('data-selection-id', selectionAreas[activeCellIndexInSelectionAreas + 1].matcher);
70
+ var nextSelectionArea = selectionAreas[activeCellIndexInSelectionAreas + 1];
71
+
72
+ var _getSelectionAreaPoin2 = (0, _getSelectionAreaPoints.getSelectionAreaPoints)(nextSelectionArea),
73
+ _lowestColumnIndex = _getSelectionAreaPoin2.lowestColumnIndex,
74
+ _lowestRowIndex = _getSelectionAreaPoin2.lowestRowIndex;
75
+
76
+ updateActiveCellCoordinates({
77
+ updatedValue: {
78
+ column: _lowestColumnIndex,
79
+ row: _lowestRowIndex
80
+ },
81
+ optOutOfSelectionAreaUpdate: true
82
+ });
83
+ return;
84
+ } else {
85
+ // There are multiple selection areas and the active cell is in the last one
86
+ // So we need to move the active cell to the first cell in the first selection area
87
+ activeCellRef.current.setAttribute('data-selection-id', selectionAreas[0].matcher);
88
+ var firstSelectionArea = selectionAreas[0];
89
+
90
+ var _getSelectionAreaPoin3 = (0, _getSelectionAreaPoints.getSelectionAreaPoints)(firstSelectionArea),
91
+ _lowestColumnIndex2 = _getSelectionAreaPoin3.lowestColumnIndex,
92
+ _lowestRowIndex2 = _getSelectionAreaPoin3.lowestRowIndex;
93
+
94
+ updateActiveCellCoordinates({
95
+ updatedValue: {
96
+ column: _lowestColumnIndex2,
97
+ row: _lowestRowIndex2
98
+ },
99
+ optOutOfSelectionAreaUpdate: true
100
+ });
101
+ }
102
+ } // Only one selection area, go back to first cell in the selection
103
+
104
+
105
+ if (selectionAreas.length === 1) {
106
+ return updateActiveCellCoordinates({
107
+ updatedValue: {
108
+ column: lowestColumnIndex,
109
+ row: lowestRowIndex
110
+ },
111
+ optOutOfSelectionAreaUpdate: true
112
+ });
113
+ }
114
+ }
115
+ }
116
+ };
117
+
118
+ exports.handleActiveCellInSelectionTab = handleActiveCellInSelectionTab;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.handleEditSubmit = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _removeCellSelections = require("./removeCellSelections");
13
+
14
+ var _uuidv = _interopRequireDefault(require("../../../global/js/utils/uuidv4"));
15
+
16
+ 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; }
17
+
18
+ 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; }
19
+
20
+ // Update the data
21
+ var handleEditSubmit = function handleEditSubmit(_ref) {
22
+ var activeCellCoordinates = _ref.activeCellCoordinates,
23
+ cellEditorRulerRef = _ref.cellEditorRulerRef,
24
+ columns = _ref.columns,
25
+ previousState = _ref.previousState,
26
+ removeCellEditor = _ref.removeCellEditor,
27
+ rows = _ref.rows,
28
+ setActiveCellCoordinates = _ref.setActiveCellCoordinates,
29
+ setCurrentMatcher = _ref.setCurrentMatcher,
30
+ setSelectionAreas = _ref.setSelectionAreas,
31
+ spreadsheetRef = _ref.spreadsheetRef,
32
+ updateData = _ref.updateData;
33
+ return function (event) {
34
+ var key = event.key;
35
+
36
+ var updateSelectionAreaOnCellEditSubmit = function updateSelectionAreaOnCellEditSubmit(_ref2) {
37
+ var type = _ref2.type;
38
+
39
+ var submitEditChanges = function submitEditChanges() {
40
+ var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
41
+ var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
42
+ removeCellEditor();
43
+ updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
44
+ };
45
+
46
+ (0, _removeCellSelections.removeCellSelections)({
47
+ spreadsheetRef: spreadsheetRef
48
+ });
49
+ submitEditChanges();
50
+ var tempMatcher = (0, _uuidv.default)();
51
+ var newSelectionArea = {
52
+ row: type === 'Enter' ? activeCellCoordinates.row === rows.length - 1 ? activeCellCoordinates.row : activeCellCoordinates.row + 1 : activeCellCoordinates.row,
53
+ column: type === 'Tab' ? activeCellCoordinates.column === columns.length - 1 ? activeCellCoordinates.column : activeCellCoordinates.column + 1 : activeCellCoordinates.column
54
+ };
55
+ setSelectionAreas([{
56
+ point1: newSelectionArea,
57
+ point2: newSelectionArea,
58
+ matcher: tempMatcher,
59
+ areaCreated: false
60
+ }]);
61
+ setCurrentMatcher(tempMatcher);
62
+ cellEditorRulerRef.current.textContent = '';
63
+ };
64
+
65
+ if (key === 'Enter') {
66
+ updateSelectionAreaOnCellEditSubmit({
67
+ type: 'Enter'
68
+ });
69
+ setActiveCellCoordinates(function (prev) {
70
+ return _objectSpread(_objectSpread({}, prev), {}, {
71
+ row: prev.row === rows.length - 1 ? prev.row : prev.row + 1 // do not move to next cell below if we're already in the last row
72
+
73
+ });
74
+ });
75
+ }
76
+
77
+ if (key === 'Tab') {
78
+ event.preventDefault();
79
+ updateSelectionAreaOnCellEditSubmit({
80
+ type: 'Tab'
81
+ });
82
+ setActiveCellCoordinates(function (prev) {
83
+ return _objectSpread(_objectSpread({}, prev), {}, {
84
+ column: prev.column === columns.length - 1 ? prev.column : prev.column + 1 // do not move to next cell below if we're already in the last column
85
+
86
+ });
87
+ });
88
+ }
89
+
90
+ return;
91
+ };
92
+ };
93
+
94
+ exports.handleEditSubmit = handleEditSubmit;
@@ -7,10 +7,16 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.handleHeaderCellSelection = void 0;
9
9
 
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
13
+
10
14
  var _uuidv = _interopRequireDefault(require("../../../global/js/utils/uuidv4"));
11
15
 
12
16
  var _removeCellSelections = require("./removeCellSelections");
13
17
 
18
+ var _checkActiveHeaderCell = require("./checkActiveHeaderCell");
19
+
14
20
  /**
15
21
  * Copyright IBM Corp. 2022, 2022
16
22
  *
@@ -28,8 +34,16 @@ var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
28
34
  spreadsheetRef = _ref.spreadsheetRef,
29
35
  index = _ref.index,
30
36
  isKeyboard = _ref.isKeyboard,
31
- setSelectionAreaData = _ref.setSelectionAreaData;
32
- setSelectionAreaData([]);
37
+ setSelectionAreaData = _ref.setSelectionAreaData,
38
+ isHoldingCommandKey = _ref.isHoldingCommandKey;
39
+
40
+ if (!isHoldingCommandKey) {
41
+ setSelectionAreaData([]);
42
+ (0, _removeCellSelections.removeCellSelections)({
43
+ spreadsheetRef: spreadsheetRef
44
+ });
45
+ }
46
+
33
47
  var rowValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row : index;
34
48
  var columnValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column : index;
35
49
  var point1 = {
@@ -47,15 +61,37 @@ var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
47
61
  column: type === 'column' ? columnValue : 0
48
62
  });
49
63
  setCurrentMatcher(tempMatcher);
50
- (0, _removeCellSelections.removeCellSelections)({
51
- spreadsheetRef: spreadsheetRef
52
- });
53
- setSelectionAreas([{
64
+ var newSelectionArea = {
54
65
  point1: point1,
55
66
  point2: point2,
56
67
  areaCreated: false,
57
- matcher: tempMatcher
58
- }]);
68
+ matcher: tempMatcher,
69
+ header: {
70
+ type: type,
71
+ index: index
72
+ }
73
+ };
74
+ setSelectionAreas(function (prev) {
75
+ var selectionsClone = (0, _deepCloneObject.deepCloneObject)(prev);
76
+
77
+ if (isHoldingCommandKey) {
78
+ var selectionsFromHeaderCell = selectionsClone.filter(function (item) {
79
+ return item.header.type;
80
+ });
81
+ var previouslyCreatedHeaderSelection = selectionsFromHeaderCell.filter(function (item) {
82
+ return item.header.type === type;
83
+ });
84
+ var isHeaderPartOfPreviousSelection = (0, _checkActiveHeaderCell.checkActiveHeaderCell)(index, previouslyCreatedHeaderSelection, type); // Prevents row/column header selections from being created multiple times
85
+
86
+ if (previouslyCreatedHeaderSelection.length && isHeaderPartOfPreviousSelection) {
87
+ return prev;
88
+ }
89
+
90
+ return [].concat((0, _toConsumableArray2.default)(prev), [newSelectionArea]);
91
+ }
92
+
93
+ return [newSelectionArea];
94
+ });
59
95
  };
60
96
 
61
97
  exports.handleHeaderCellSelection = handleHeaderCellSelection;