@carbon/ibm-products 1.13.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css +47 -0
  2. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css.map +1 -0
  3. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css +20 -0
  4. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css.map +1 -0
  5. package/css/components/Datagrid/styles/datagrid.css +268 -0
  6. package/css/components/Datagrid/styles/datagrid.css.map +1 -0
  7. package/css/components/Datagrid/styles/index.css +513 -0
  8. package/css/components/Datagrid/styles/index.css.map +1 -0
  9. package/css/components/Datagrid/styles/useActionsColumn.css +23 -0
  10. package/css/components/Datagrid/styles/useActionsColumn.css.map +1 -0
  11. package/css/components/Datagrid/styles/useColumnRightAlign.css +28 -0
  12. package/css/components/Datagrid/styles/useColumnRightAlign.css.map +1 -0
  13. package/css/components/Datagrid/styles/useNestedRows.css +15 -0
  14. package/css/components/Datagrid/styles/useNestedRows.css.map +1 -0
  15. package/css/components/Datagrid/styles/useNestedTable.css +25 -0
  16. package/css/components/Datagrid/styles/useNestedTable.css.map +1 -0
  17. package/css/components/Datagrid/styles/useSelectAllToggle.css +28 -0
  18. package/css/components/Datagrid/styles/useSelectAllToggle.css.map +1 -0
  19. package/css/components/Datagrid/styles/useSortableColumns.css +50 -0
  20. package/css/components/Datagrid/styles/useSortableColumns.css.map +1 -0
  21. package/css/components/Datagrid/styles/useStickyColumn.css +35 -0
  22. package/css/components/Datagrid/styles/useStickyColumn.css.map +1 -0
  23. package/css/index-full-carbon.css +611 -10
  24. package/css/index-full-carbon.css.map +1 -1
  25. package/css/index-full-carbon.min.css +3 -3
  26. package/css/index-full-carbon.min.css.map +1 -1
  27. package/css/index-without-carbon-released-only.css +7 -4
  28. package/css/index-without-carbon-released-only.css.map +1 -1
  29. package/css/index-without-carbon-released-only.min.css +2 -2
  30. package/css/index-without-carbon-released-only.min.css.map +1 -1
  31. package/css/index-without-carbon.css +611 -10
  32. package/css/index-without-carbon.css.map +1 -1
  33. package/css/index-without-carbon.min.css +3 -3
  34. package/css/index-without-carbon.min.css.map +1 -1
  35. package/css/index.css +611 -10
  36. package/css/index.css.map +1 -1
  37. package/css/index.min.css +3 -3
  38. package/css/index.min.css.map +1 -1
  39. package/es/components/AddSelect/AddSelect.js +106 -43
  40. package/es/components/AddSelect/AddSelectFilter.js +172 -0
  41. package/es/components/AddSelect/add-select-utils.js +30 -0
  42. package/es/components/DataSpreadsheet/DataSpreadsheet.js +255 -175
  43. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +78 -17
  44. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +65 -20
  45. package/es/components/DataSpreadsheet/hooks/index.js +11 -0
  46. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +139 -0
  47. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  48. package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +68 -0
  49. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  50. package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +20 -8
  51. package/es/components/DataSpreadsheet/utils/generateData.js +17 -9
  52. package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
  53. package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +30 -0
  54. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +121 -0
  55. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +108 -0
  56. package/es/components/DataSpreadsheet/utils/handleEditSubmit.js +87 -0
  57. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +42 -8
  58. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +225 -13
  59. package/es/components/DataSpreadsheet/utils/selectAllCells.js +53 -0
  60. package/es/components/Datagrid/Datagrid/Datagrid.js +70 -0
  61. package/es/components/Datagrid/Datagrid/DatagridBody.js +36 -0
  62. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -0
  63. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -0
  64. package/es/components/Datagrid/Datagrid/DatagridHead.js +31 -0
  65. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +57 -0
  66. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +37 -0
  67. package/es/components/Datagrid/Datagrid/DatagridRow.js +60 -0
  68. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +50 -0
  69. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +122 -0
  70. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +36 -0
  71. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -0
  72. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +87 -0
  73. package/es/components/Datagrid/Datagrid/DraggableElement.js +188 -0
  74. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +78 -0
  75. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +51 -0
  76. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +140 -0
  77. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +157 -0
  78. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +62 -0
  79. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +13 -0
  80. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +9 -0
  81. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +62 -0
  82. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +139 -0
  83. package/es/components/Datagrid/Datagrid/addons/RowSize/index.js +8 -0
  84. package/es/components/Datagrid/Datagrid/index.js +8 -0
  85. package/es/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +6 -0
  86. package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +6 -0
  87. package/es/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +6 -0
  88. package/es/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +6 -0
  89. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -0
  90. package/es/components/Datagrid/Datagrid.stories/common.js +199 -0
  91. package/es/components/Datagrid/Datagrid.stories/index.js +5 -0
  92. package/es/components/Datagrid/common-column-ids.js +8 -0
  93. package/es/components/Datagrid/index.js +22 -0
  94. package/es/components/Datagrid/useActionsColumn.js +86 -0
  95. package/es/components/Datagrid/useColumnRightAlign.js +52 -0
  96. package/es/components/Datagrid/useCustomizeColumns.js +45 -0
  97. package/es/components/Datagrid/useDatagrid.js +44 -0
  98. package/es/components/Datagrid/useDefaultStringRenderer.js +48 -0
  99. package/es/components/Datagrid/useDisableSelectRows.js +84 -0
  100. package/es/components/Datagrid/useExpandedRow.js +52 -0
  101. package/es/components/Datagrid/useFlexResize.js +51 -0
  102. package/es/components/Datagrid/useFloatingScroll.js +88 -0
  103. package/es/components/Datagrid/useInfiniteScroll.js +54 -0
  104. package/es/components/Datagrid/useNestedRows.js +53 -0
  105. package/es/components/Datagrid/useOnRowClick.js +37 -0
  106. package/es/components/Datagrid/useParentDimensions.js +65 -0
  107. package/es/components/Datagrid/useResizeTable.js +40 -0
  108. package/es/components/Datagrid/useRowExpander.js +34 -0
  109. package/es/components/Datagrid/useRowIsMouseOver.js +61 -0
  110. package/es/components/Datagrid/useRowRenderer.js +30 -0
  111. package/es/components/Datagrid/useRowSize.js +56 -0
  112. package/es/components/Datagrid/useSelectAllToggle.js +74 -0
  113. package/es/components/Datagrid/useSelectRows.js +107 -0
  114. package/es/components/Datagrid/useSkeletonRows.js +32 -0
  115. package/es/components/Datagrid/useSortableColumns.js +110 -0
  116. package/es/components/Datagrid/useStickyColumn.js +183 -0
  117. package/es/components/MultiAddSelect/MultiAddSelect.js +150 -3
  118. package/es/components/PageHeader/PageHeader.js +3 -1
  119. package/es/components/SingleAddSelect/SingleAddSelect.js +90 -4
  120. package/es/components/TagSet/TagSet.js +13 -6
  121. package/es/components/Tearsheet/TearsheetShell.js +34 -10
  122. package/es/components/index.js +2 -1
  123. package/es/global/js/package-settings.js +4 -2
  124. package/lib/components/AddSelect/AddSelect.js +105 -41
  125. package/lib/components/AddSelect/AddSelectFilter.js +190 -0
  126. package/lib/components/AddSelect/add-select-utils.js +35 -2
  127. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +261 -177
  128. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +79 -23
  129. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +67 -21
  130. package/lib/components/DataSpreadsheet/hooks/index.js +45 -0
  131. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +151 -0
  132. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  133. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +79 -0
  134. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +1 -3
  135. package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +21 -8
  136. package/lib/components/DataSpreadsheet/utils/generateData.js +17 -9
  137. package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
  138. package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +40 -0
  139. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +127 -0
  140. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +118 -0
  141. package/lib/components/DataSpreadsheet/utils/handleEditSubmit.js +94 -0
  142. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +44 -8
  143. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +235 -20
  144. package/lib/components/DataSpreadsheet/utils/selectAllCells.js +60 -0
  145. package/lib/components/Datagrid/Datagrid/Datagrid.js +86 -0
  146. package/lib/components/Datagrid/Datagrid/DatagridBody.js +50 -0
  147. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +31 -0
  148. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +38 -0
  149. package/lib/components/Datagrid/Datagrid/DatagridHead.js +43 -0
  150. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +73 -0
  151. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +44 -0
  152. package/lib/components/Datagrid/Datagrid/DatagridRow.js +68 -0
  153. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +55 -0
  154. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +139 -0
  155. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +44 -0
  156. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +35 -0
  157. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +101 -0
  158. package/lib/components/Datagrid/Datagrid/DraggableElement.js +210 -0
  159. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +92 -0
  160. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +65 -0
  161. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +166 -0
  162. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +173 -0
  163. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +73 -0
  164. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +25 -0
  165. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +23 -0
  166. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +80 -0
  167. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +160 -0
  168. package/lib/components/Datagrid/Datagrid/addons/RowSize/index.js +15 -0
  169. package/lib/components/Datagrid/Datagrid/index.js +15 -0
  170. package/lib/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +13 -0
  171. package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +13 -0
  172. package/lib/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +13 -0
  173. package/lib/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +13 -0
  174. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +112 -0
  175. package/lib/components/Datagrid/Datagrid.stories/common.js +215 -0
  176. package/lib/components/Datagrid/Datagrid.stories/index.js +47 -0
  177. package/lib/components/Datagrid/common-column-ids.js +16 -0
  178. package/lib/components/Datagrid/index.js +127 -0
  179. package/lib/components/Datagrid/useActionsColumn.js +94 -0
  180. package/lib/components/Datagrid/useColumnRightAlign.js +59 -0
  181. package/lib/components/Datagrid/useCustomizeColumns.js +55 -0
  182. package/lib/components/Datagrid/useDatagrid.js +58 -0
  183. package/lib/components/Datagrid/useDefaultStringRenderer.js +54 -0
  184. package/lib/components/Datagrid/useDisableSelectRows.js +92 -0
  185. package/lib/components/Datagrid/useExpandedRow.js +58 -0
  186. package/lib/components/Datagrid/useFlexResize.js +61 -0
  187. package/lib/components/Datagrid/useFloatingScroll.js +101 -0
  188. package/lib/components/Datagrid/useInfiniteScroll.js +67 -0
  189. package/lib/components/Datagrid/useNestedRows.js +65 -0
  190. package/lib/components/Datagrid/useOnRowClick.js +45 -0
  191. package/lib/components/Datagrid/useParentDimensions.js +75 -0
  192. package/lib/components/Datagrid/useResizeTable.js +48 -0
  193. package/lib/components/Datagrid/useRowExpander.js +45 -0
  194. package/lib/components/Datagrid/useRowIsMouseOver.js +66 -0
  195. package/lib/components/Datagrid/useRowRenderer.js +40 -0
  196. package/lib/components/Datagrid/useRowSize.js +67 -0
  197. package/lib/components/Datagrid/useSelectAllToggle.js +88 -0
  198. package/lib/components/Datagrid/useSelectRows.js +119 -0
  199. package/lib/components/Datagrid/useSkeletonRows.js +42 -0
  200. package/lib/components/Datagrid/useSortableColumns.js +117 -0
  201. package/lib/components/Datagrid/useStickyColumn.js +190 -0
  202. package/lib/components/MultiAddSelect/MultiAddSelect.js +150 -2
  203. package/lib/components/PageHeader/PageHeader.js +3 -1
  204. package/lib/components/SingleAddSelect/SingleAddSelect.js +91 -3
  205. package/lib/components/TagSet/TagSet.js +13 -6
  206. package/lib/components/Tearsheet/TearsheetShell.js +36 -10
  207. package/lib/components/index.js +9 -1
  208. package/lib/global/js/package-settings.js +4 -2
  209. package/package.json +16 -12
  210. package/scss/components/AboutModal/_about-modal.scss +4 -0
  211. package/scss/components/AddSelect/_add-select.scss +46 -2
  212. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +41 -4
  213. package/scss/components/Datagrid/_datagrid.scss +66 -0
  214. package/scss/components/Datagrid/_index.scss +8 -0
  215. package/scss/components/Datagrid/_storybook-styles.scss +26 -0
  216. package/scss/components/Datagrid/styles/_variables.scss +9 -0
  217. package/scss/components/Datagrid/styles/addons/CustomizeColumnsModal.scss +48 -0
  218. package/scss/components/Datagrid/styles/addons/RowSizeDropdown.scss +23 -0
  219. package/scss/components/Datagrid/styles/datagrid.scss +326 -0
  220. package/scss/components/Datagrid/styles/index.scss +17 -0
  221. package/scss/components/Datagrid/styles/useActionsColumn.scss +24 -0
  222. package/scss/components/Datagrid/styles/useColumnRightAlign.scss +29 -0
  223. package/scss/components/Datagrid/styles/useNestedRows.scss +17 -0
  224. package/scss/components/Datagrid/styles/useNestedTable.scss +28 -0
  225. package/scss/components/Datagrid/styles/useSelectAllToggle.scss +28 -0
  226. package/scss/components/Datagrid/styles/useSortableColumns.scss +55 -0
  227. package/scss/components/Datagrid/styles/useStickyColumn.scss +38 -0
  228. package/scss/components/ExportModal/_export-modal.scss +0 -4
  229. package/scss/components/Tearsheet/_tearsheet.scss +4 -0
  230. package/scss/components/_index.scss +1 -0
@@ -1,9 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
5
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
6
- var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
6
+ var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "totalVisibleColumns"];
7
7
 
8
8
  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; }
9
9
 
@@ -17,8 +17,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
17
17
  */
18
18
  // Import portions of React that are needed.
19
19
  import React, { useMemo, useRef, useState, useCallback, useEffect } from 'react';
20
- import { useBlockLayout, useTable } from 'react-table';
21
- import { px } from '@carbon/layout'; // Other standard imports.
20
+ import { useBlockLayout, useTable } from 'react-table'; // Other standard imports.
22
21
 
23
22
  import PropTypes from 'prop-types';
24
23
  import cx from 'classnames';
@@ -30,14 +29,17 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools';
30
29
  import { getScrollbarWidth } from '../../global/js/utils/getScrollbarWidth';
31
30
  import { useActiveElement, usePreviousValue } from '../../global/js/hooks';
32
31
  import uuidv4 from '../../global/js/utils/uuidv4';
33
- import { useResetSpreadsheetFocus } from './hooks/useResetSpreadsheetFocus';
34
- import { useSpreadsheetOutsideClick } from './hooks/useSpreadsheetOutsideClick';
35
- import { useMoveActiveCell } from './hooks/useMoveActiveCell';
32
+ import { deepCloneObject } from '../../global/js/utils/deepCloneObject';
33
+ import { useResetSpreadsheetFocus, useSpreadsheetOutsideClick, useMoveActiveCell, useMultipleKeyTracking, useSpreadsheetEdit } from './hooks';
36
34
  import { createActiveCellFn } from './utils/createActiveCellFn';
37
35
  import { getCellSize } from './utils/getCellSize';
38
- import { handleMultipleKeys } from './utils/handleMultipleKeys';
36
+ import { handleMultipleKeys, includesResourceKey, includesShift } from './utils/handleMultipleKeys';
39
37
  import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection';
40
- import { removeCellSelections } from './utils/removeCellSelections'; // cspell:words rowcount colcount
38
+ import { removeCellSelections } from './utils/removeCellSelections';
39
+ import { selectAllCells } from './utils/selectAllCells';
40
+ import { handleEditSubmit } from './utils/handleEditSubmit';
41
+ import { handleActiveCellInSelectionEnter } from './utils/handleActiveCellInSelectionEnter';
42
+ import { handleActiveCellInSelectionTab } from './utils/handleActiveCellInSelectionTab'; // cspell:words rowcount colcount
41
43
  // The block part of our conventional BEM class names (blockClass__E--M).
42
44
 
43
45
  var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
@@ -73,8 +75,10 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
73
75
  onActiveCellChange = _ref$onActiveCellChan === void 0 ? defaults.onActiveCellChange : _ref$onActiveCellChan,
74
76
  _ref$onSelectionAreaC = _ref.onSelectionAreaChange,
75
77
  onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
78
+ totalVisibleColumns = _ref.totalVisibleColumns,
76
79
  rest = _objectWithoutProperties(_ref, _excluded);
77
80
 
81
+ var multiKeyTrackingRef = useRef();
78
82
  var localRef = useRef();
79
83
  var spreadsheetRef = ref || localRef;
80
84
  var focusedElement = useActiveElement();
@@ -119,18 +123,23 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
119
123
  cellEditorValue = _useState16[0],
120
124
  setCellEditorValue = _useState16[1];
121
125
 
126
+ var _useState17 = useState(false),
127
+ _useState18 = _slicedToArray(_useState17, 2),
128
+ activeCellInsideSelectionArea = _useState18[0],
129
+ setActiveCellInsideSelectionArea = _useState18[1];
130
+
122
131
  var previousState = usePreviousValue({
123
- activeCellCoordinates: activeCellCoordinates
132
+ activeCellCoordinates: activeCellCoordinates,
133
+ isEditing: isEditing
124
134
  });
125
135
  var cellSizeValue = getCellSize(cellSize);
126
136
  var cellEditorRef = useRef();
127
137
 
128
- var _useState17 = useState(),
129
- _useState18 = _slicedToArray(_useState17, 2),
130
- activeCellContent = _useState18[0],
131
- setActiveCellContent = _useState18[1];
138
+ var _useState19 = useState(),
139
+ _useState20 = _slicedToArray(_useState19, 2),
140
+ activeCellContent = _useState20[0],
141
+ setActiveCellContent = _useState20[1];
132
142
 
133
- var activeKeys = useRef([]);
134
143
  var activeCellRef = useRef();
135
144
  var cellEditorRulerRef = useRef();
136
145
  var defaultColumn = useMemo(function () {
@@ -140,6 +149,15 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
140
149
  rowHeight: cellSizeValue
141
150
  };
142
151
  }, [cellSizeValue]);
152
+
153
+ var _useMultipleKeyTracki = useMultipleKeyTracking({
154
+ ref: multiKeyTrackingRef,
155
+ containerHasFocus: containerHasFocus,
156
+ isEditing: isEditing
157
+ }),
158
+ keysPressedList = _useMultipleKeyTracki.keysPressedList,
159
+ usingMac = _useMultipleKeyTracki.usingMac;
160
+
143
161
  var scrollBarSize = useMemo(function () {
144
162
  return getScrollbarWidth();
145
163
  }, []);
@@ -229,7 +247,6 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
229
247
  }
230
248
  }, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
231
249
  useResetSpreadsheetFocus({
232
- activeKeys: activeKeys,
233
250
  focusedElement: focusedElement,
234
251
  removeActiveCell: removeActiveCell,
235
252
  setContainerHasFocus: setContainerHasFocus
@@ -241,7 +258,6 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
241
258
  removeActiveCell: removeActiveCell,
242
259
  removeCellSelections: removeCellSelections,
243
260
  setContainerHasFocus: setContainerHasFocus,
244
- activeKeys: activeKeys,
245
261
  removeCellEditor: removeCellEditor
246
262
  });
247
263
  useMoveActiveCell({
@@ -253,6 +269,8 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
253
269
  var handleInitialArrowPress = useCallback(function () {
254
270
  // If activeCellCoordinates is null then we need to set an initial value
255
271
  // which will place the activeCell on the select all cell/button
272
+ setActiveCellInsideSelectionArea(false);
273
+
256
274
  if (!activeCellCoordinates) {
257
275
  setActiveCellCoordinates({
258
276
  column: 'header',
@@ -263,16 +281,20 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
263
281
  return;
264
282
  }, [activeCellCoordinates]);
265
283
  var updateActiveCellCoordinates = useCallback(function (_ref3) {
266
- var coords = _ref3.coords,
267
- updatedValue = _ref3.updatedValue;
284
+ var _ref3$coords = _ref3.coords,
285
+ coords = _ref3$coords === void 0 ? _objectSpread({}, activeCellCoordinates) : _ref3$coords,
286
+ updatedValue = _ref3.updatedValue,
287
+ _ref3$optOutOfSelecti = _ref3.optOutOfSelectionAreaUpdate,
288
+ optOutOfSelectionAreaUpdate = _ref3$optOutOfSelecti === void 0 ? false : _ref3$optOutOfSelecti;
268
289
 
269
290
  var newActiveCell = _objectSpread(_objectSpread({}, coords), updatedValue);
270
291
 
271
292
  setActiveCellCoordinates(newActiveCell); // Only run if the active cell is _not_ a header cell. This will add a point1 object
272
293
  // to selectionAreas every time the active cell changes, allowing us to create cell
273
- // selections using keyboard
294
+ // selections using keyboard. Opting out of the selection area updates here means
295
+ // that the active cell is being moved within a selection area
274
296
 
275
- if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header') {
297
+ if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header' && !optOutOfSelectionAreaUpdate) {
276
298
  var tempMatcher = uuidv4();
277
299
  setSelectionAreas([{
278
300
  point1: newActiveCell,
@@ -280,11 +302,29 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
280
302
  }]);
281
303
  setCurrentMatcher(tempMatcher);
282
304
  }
283
- }, []);
305
+ }, [activeCellCoordinates]);
306
+ var handleHomeEndKey = useCallback(function (_ref4) {
307
+ var type = _ref4.type;
308
+
309
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
310
+
311
+ updateActiveCellCoordinates({
312
+ coords: coordinatesClone,
313
+ updatedValue: {
314
+ column: type === 'home' ? 0 : columns.length - 1
315
+ }
316
+ });
317
+ removeCellSelections({
318
+ spreadsheetRef: spreadsheetRef
319
+ });
320
+ }, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
284
321
  var handleKeyPress = useCallback(function (event) {
285
- var _activeKeys$current, _activeKeys$current2;
322
+ var key = event.key;
323
+
324
+ if (isEditing) {
325
+ return;
326
+ } // Command keys need to be returned as there is default browser behavior with these keys
286
327
 
287
- var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
288
328
 
289
329
  if (key === 'Meta' || key === 'Control') {
290
330
  return;
@@ -301,44 +341,90 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
301
341
 
302
342
 
303
343
  if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
304
- if (isEditing) {
305
- return;
306
- }
307
-
308
- if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
344
+ if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !includesShift(keysPressedList)) {
309
345
  setSelectionAreas([]);
310
346
  setSelectionAreaData([]);
311
347
  removeCellSelections({
312
348
  spreadsheetRef: spreadsheetRef
313
349
  });
314
350
  }
315
- } // Update list of activeKeys
316
-
317
-
318
- if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
319
- var activeClone = _toConsumableArray(activeKeys.current);
320
-
321
- activeKeys.current = [].concat(_toConsumableArray(activeClone), [key]);
322
351
  }
323
352
 
324
- if (((_activeKeys$current2 = activeKeys.current) === null || _activeKeys$current2 === void 0 ? void 0 : _activeKeys$current2.length) > 1) {
353
+ if (!isEditing && (keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
325
354
  handleMultipleKeys({
326
- activeKeys: activeKeys,
355
+ activeCellCoordinates: activeCellCoordinates,
356
+ event: event,
357
+ keysPressedList: keysPressedList,
327
358
  selectionAreas: selectionAreas,
328
359
  currentMatcher: currentMatcher,
329
360
  rows: rows,
330
361
  setSelectionAreas: setSelectionAreas,
331
- columns: columns
362
+ columns: columns,
363
+ updateActiveCellCoordinates: updateActiveCellCoordinates,
364
+ spreadsheetRef: spreadsheetRef,
365
+ removeCellSelections: removeCellSelections,
366
+ blockClass: blockClass,
367
+ setCurrentMatcher: setCurrentMatcher,
368
+ usingMac: usingMac
332
369
  });
333
370
  } // Allow arrow key navigation if there are less than two activeKeys OR
334
371
  // if one of the activeCellCoordinates is in a header position
335
372
 
336
373
 
337
- if (!activeKeys.current.includes('Shift') || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
374
+ if (keysPressedList.length < 2 && !includesShift(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
338
375
  switch (key) {
376
+ // Enter
377
+ case 'Enter':
378
+ {
379
+ handleActiveCellInSelectionEnter({
380
+ activeCellInsideSelectionArea: activeCellInsideSelectionArea,
381
+ activeCellCoordinates: activeCellCoordinates,
382
+ activeCellRef: activeCellRef,
383
+ selectionAreas: selectionAreas,
384
+ updateActiveCellCoordinates: updateActiveCellCoordinates
385
+ });
386
+ break;
387
+ }
388
+ // HOME
389
+
390
+ case 'Home':
391
+ {
392
+ if (includesResourceKey(keysPressedList, usingMac)) {
393
+ return;
394
+ }
395
+
396
+ handleHomeEndKey({
397
+ type: 'home'
398
+ });
399
+ break;
400
+ }
401
+
402
+ case 'End':
403
+ {
404
+ if (includesResourceKey(keysPressedList, usingMac)) {
405
+ return;
406
+ }
407
+
408
+ handleHomeEndKey({
409
+ type: 'end'
410
+ });
411
+ break;
412
+ }
339
413
  // Tab
414
+
340
415
  case 'Tab':
341
416
  {
417
+ if (activeCellInsideSelectionArea) {
418
+ event.preventDefault();
419
+ return handleActiveCellInSelectionTab({
420
+ activeCellInsideSelectionArea: activeCellInsideSelectionArea,
421
+ activeCellCoordinates: activeCellCoordinates,
422
+ activeCellRef: activeCellRef,
423
+ selectionAreas: selectionAreas,
424
+ updateActiveCellCoordinates: updateActiveCellCoordinates
425
+ });
426
+ }
427
+
342
428
  setSelectionAreas([]);
343
429
  removeActiveCell();
344
430
  removeCellEditor();
@@ -485,7 +571,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
485
571
  }
486
572
  }
487
573
  }
488
- }, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas]);
574
+ }, [activeCellInsideSelectionArea, updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac]);
489
575
 
490
576
  var startEditMode = function startEditMode() {
491
577
  setIsEditing(true);
@@ -493,17 +579,51 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
493
579
  var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
494
580
  setCellEditorValue(activeCellValue);
495
581
  cellEditorRulerRef.current.textContent = activeCellValue;
496
- };
582
+ }; // Sets the initial placement of the cell editor cursor at the end of the text area
583
+ // this is not done for us by default in Safari
584
+
585
+
586
+ useEffect(function () {
587
+ if (isEditing && !(previousState !== null && previousState !== void 0 && previousState.isEditing)) {
588
+ cellEditorRef.current.setSelectionRange(cellEditorRulerRef.current.textContent.length, cellEditorRulerRef.current.textContent.length);
589
+ cellEditorRef.current.focus();
590
+ }
591
+ }, [isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing]);
497
592
 
498
593
  var handleActiveCellClick = function handleActiveCellClick() {
499
594
  if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
500
595
  var indexValue = (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row;
596
+
597
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
598
+ return;
599
+ }
600
+
501
601
  handleRowColumnHeaderClick({
502
602
  isKeyboard: false,
503
603
  index: indexValue
504
604
  });
505
605
  }
506
606
 
607
+ return;
608
+ }; // Mouse down on active cell
609
+
610
+
611
+ var handleActiveCellMouseDown = function handleActiveCellMouseDown() {
612
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
613
+ var tempMatcher = uuidv4();
614
+ setClickAndHoldActive(true);
615
+ removeCellSelections({
616
+ spreadsheetRef: spreadsheetRef
617
+ });
618
+ setSelectionAreas([{
619
+ point1: activeCellCoordinates,
620
+ matcher: tempMatcher
621
+ }]);
622
+ setCurrentMatcher(tempMatcher);
623
+ setSelectionAreaData([]);
624
+ setActiveCellInsideSelectionArea(false);
625
+ }
626
+
507
627
  return;
508
628
  }; // Go into edit mode if 'Enter' key is pressed on activeCellRef
509
629
 
@@ -511,7 +631,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
511
631
  var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
512
632
  var key = event.key;
513
633
 
514
- if (key === 'Enter') {
634
+ if (key === 'Enter' && !activeCellInsideSelectionArea) {
515
635
  if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
516
636
  startEditMode();
517
637
  }
@@ -524,10 +644,10 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
524
644
  }
525
645
  };
526
646
 
527
- var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref4) {
528
- var isKeyboard = _ref4.isKeyboard,
529
- _ref4$index = _ref4.index,
530
- index = _ref4$index === void 0 ? null : _ref4$index;
647
+ var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref5) {
648
+ var isKeyboard = _ref5.isKeyboard,
649
+ _ref5$index = _ref5.index,
650
+ index = _ref5$index === void 0 ? null : _ref5$index;
531
651
  var handleHeaderCellProps = {
532
652
  activeCellCoordinates: activeCellCoordinates,
533
653
  rows: rows,
@@ -541,18 +661,30 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
541
661
  index: index
542
662
  }; // Select an entire column
543
663
 
544
- if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
664
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
545
665
  handleHeaderCellSelection(_objectSpread({
546
666
  type: 'column'
547
667
  }, handleHeaderCellProps));
548
668
  } // Select an entire row
549
669
 
550
670
 
551
- if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
671
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
552
672
  handleHeaderCellSelection(_objectSpread({
553
673
  type: 'row'
554
674
  }, handleHeaderCellProps));
555
675
  }
676
+
677
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
678
+ selectAllCells({
679
+ ref: spreadsheetRef,
680
+ setCurrentMatcher: setCurrentMatcher,
681
+ setSelectionAreas: setSelectionAreas,
682
+ rows: rows,
683
+ columns: columns,
684
+ activeCellCoordinates: activeCellCoordinates,
685
+ updateActiveCellCoordinates: updateActiveCellCoordinates
686
+ });
687
+ }
556
688
  }; // Go into edit mode if double click is detected on activeCellRef
557
689
 
558
690
 
@@ -560,132 +692,55 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
560
692
  startEditMode();
561
693
  };
562
694
 
563
- var updateSelectionAreaOnCellEditSubmit = function updateSelectionAreaOnCellEditSubmit(_ref5) {
564
- var type = _ref5.type;
565
-
566
- var submitEditChanges = function submitEditChanges() {
567
- var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
568
- var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
569
- removeCellEditor();
570
- updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
571
- };
572
-
573
- removeCellSelections({
574
- spreadsheetRef: spreadsheetRef
575
- });
576
- submitEditChanges();
577
- var tempMatcher = uuidv4();
578
- var newSelectionArea = {
579
- row: type === 'Enter' ? activeCellCoordinates.row === rows.length - 1 ? activeCellCoordinates.row : activeCellCoordinates.row + 1 : activeCellCoordinates.row,
580
- column: type === 'Tab' ? activeCellCoordinates.column === columns.length - 1 ? activeCellCoordinates.column : activeCellCoordinates.column + 1 : activeCellCoordinates.column
581
- };
582
- setSelectionAreas([{
583
- point1: newSelectionArea,
584
- point2: newSelectionArea,
585
- matcher: tempMatcher,
586
- areaCreated: false
587
- }]);
588
- setCurrentMatcher(tempMatcher);
589
- cellEditorRulerRef.current.textContent = '';
590
- }; // Update the data
591
-
592
-
593
- var handleEditSubmit = function handleEditSubmit(event) {
594
- var key = event.key;
595
-
596
- if (key === 'Enter') {
597
- updateSelectionAreaOnCellEditSubmit({
598
- type: 'Enter'
599
- });
600
- setActiveCellCoordinates(function (prev) {
601
- return _objectSpread(_objectSpread({}, prev), {}, {
602
- 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
603
-
604
- });
605
- });
695
+ useSpreadsheetEdit({
696
+ isEditing: isEditing,
697
+ rows: rows,
698
+ activeCellCoordinates: activeCellCoordinates,
699
+ activeCellRef: activeCellRef,
700
+ cellEditorRef: cellEditorRef,
701
+ cellEditorRulerRef: cellEditorRulerRef,
702
+ columns: columns,
703
+ defaultColumn: defaultColumn,
704
+ cellEditorValue: cellEditorValue
705
+ });
706
+ var handleActiveCellMouseEnter = useCallback(function () {
707
+ handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
708
+ }, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]); // Only update if there are cell selection areas
709
+ // Find point object that matches currentMatcher and remove the second point
710
+ // because hovering over the active cell while clicking and holding should
711
+ // remove the previously existing selection area
712
+
713
+ var handleActiveCellMouseEnterCallback = useCallback(function (areas, clickHold) {
714
+ if (!currentMatcher) {
715
+ return;
606
716
  }
607
717
 
608
- if (key === 'Tab') {
609
- event.preventDefault();
610
- updateSelectionAreaOnCellEditSubmit({
611
- type: 'Tab'
612
- });
613
- setActiveCellCoordinates(function (prev) {
614
- return _objectSpread(_objectSpread({}, prev), {}, {
615
- 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
616
-
718
+ if (areas && areas.length && clickHold && currentMatcher) {
719
+ setSelectionAreas(function (prev) {
720
+ var selectionAreaClone = deepCloneObject(prev);
721
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
722
+ return item.matcher === currentMatcher;
617
723
  });
618
- });
619
- }
620
-
621
- return;
622
- };
623
724
 
624
- useEffect(function () {
625
- if (isEditing) {
626
- var _rows$activeCellCoord, _cellProps$column, _cellEditorRef$curren;
627
-
628
- 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];
629
- var activeCellLeftPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.left;
630
- var activeCellTopPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.top;
631
- cellEditorRef.current.style.left = activeCellLeftPosition;
632
- cellEditorRef.current.style.top = activeCellTopPosition;
633
- cellEditorRef.current.style.display = 'block';
634
- cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
635
- cellEditorRef.current.style.height = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height;
636
- 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
637
-
638
- 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';
639
- (_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 ? void 0 : _cellEditorRef$curren.focus();
640
- var rulerWidth = cellEditorRulerRef.current.offsetWidth;
641
- var cellWidth = activeCellRef.current.offsetWidth;
642
-
643
- if (rulerWidth >= cellWidth) {
644
- var widthMultiplier = Math.floor(rulerWidth / cellWidth) + 1;
645
- var startingColumnPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column;
646
- var startingRowPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row;
647
- var totalColumns = columns.length;
648
- var totalRows = rows.length;
649
- var totalMultiplierPossible = totalColumns - startingColumnPosition;
650
- var totalCellEditorMaxHeight = (totalRows - startingRowPosition) * defaultColumn.rowHeight;
651
- cellEditorRef.current.style.maxHeight = px(totalCellEditorMaxHeight);
652
- cellEditorRef.current.style.width = px(cellWidth * (widthMultiplier <= totalMultiplierPossible ? widthMultiplier : totalMultiplierPossible));
653
- cellEditorRef.current.style.height = px(cellEditorRef.current.scrollHeight); // adds dynamic height to cell editor
654
- // Cell editor has reached max height, we need to add the scrolling back.
655
- // We also need to subtract 1 to account for the fact that the cell editor
656
- // is placed one pixel below the cell being edited to account for the border
657
-
658
- if (cellEditorRef.current.clientHeight === totalCellEditorMaxHeight - 1) {
659
- cellEditorRef.current.style.overflow = 'auto';
660
- } else {
661
- cellEditorRef.current.style.overflow = 'hidden';
725
+ if (indexOfItemToUpdate === -1) {
726
+ return prev;
662
727
  }
663
- }
664
- }
665
-
666
- if (!isEditing) {
667
- cellEditorRef.current.style.overflow = 'hidden';
668
- cellEditorRef.current.style.display = 'none';
669
- cellEditorRef.current.blur();
670
- activeCellRef.current.focus();
671
- }
672
- }, [isEditing, activeCellCoordinates, rows, cellEditorValue, columns.length, defaultColumn]);
673
-
674
- var handleKeyUp = function handleKeyUp(event) {
675
- var _activeKeys$current3;
676
728
 
677
- var key = event.key; // Remove key from active keys array on key up
678
-
679
- if ((_activeKeys$current3 = activeKeys.current) !== null && _activeKeys$current3 !== void 0 && _activeKeys$current3.includes(key)) {
680
- var activeKeysClone = _toConsumableArray(activeKeys.current);
729
+ if (_typeof(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
730
+ selectionAreaClone[indexOfItemToUpdate].point2 = selectionAreaClone[indexOfItemToUpdate].point1;
731
+ selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
732
+ setActiveCellInsideSelectionArea(false);
733
+ removeCellSelections({
734
+ matcher: currentMatcher,
735
+ spreadsheetRef: spreadsheetRef
736
+ });
737
+ return selectionAreaClone;
738
+ }
681
739
 
682
- var filteredKeysClone = activeKeysClone.filter(function (item) {
683
- return item !== key;
740
+ return prev;
684
741
  });
685
- activeKeys.current = filteredKeysClone;
686
742
  }
687
- };
688
-
743
+ }, [spreadsheetRef, currentMatcher]);
689
744
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, getTableProps(), getDevtoolsProps(componentName), {
690
745
  className: cx(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), _defineProperty({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
691
746
  ref: spreadsheetRef,
@@ -694,11 +749,12 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
694
749
  "aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
695
750
  "aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
696
751
  onKeyDown: handleKeyPress,
697
- onKeyUp: handleKeyUp,
698
752
  onFocus: function onFocus() {
699
753
  return setContainerHasFocus(true);
700
754
  }
701
- }), /*#__PURE__*/React.createElement(DataSpreadsheetHeader, {
755
+ }), /*#__PURE__*/React.createElement("div", {
756
+ ref: multiKeyTrackingRef
757
+ }, /*#__PURE__*/React.createElement(DataSpreadsheetHeader, {
702
758
  ref: spreadsheetRef,
703
759
  activeCellCoordinates: activeCellCoordinates,
704
760
  cellSize: cellSize,
@@ -711,7 +767,9 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
711
767
  setActiveCellCoordinates: setActiveCellCoordinates,
712
768
  setSelectionAreas: setSelectionAreas,
713
769
  setCurrentMatcher: setCurrentMatcher,
714
- setSelectionAreaData: setSelectionAreaData
770
+ setSelectionAreaData: setSelectionAreaData,
771
+ totalVisibleColumns: totalVisibleColumns,
772
+ updateActiveCellCoordinates: updateActiveCellCoordinates
715
773
  }), /*#__PURE__*/React.createElement(DataSpreadsheetBody, {
716
774
  activeCellCoordinates: activeCellCoordinates,
717
775
  ref: spreadsheetRef,
@@ -738,30 +796,46 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
738
796
  totalColumnsWidth: totalColumnsWidth,
739
797
  id: id,
740
798
  columns: columns,
741
- defaultEmptyRowCount: defaultEmptyRowCount
799
+ defaultEmptyRowCount: defaultEmptyRowCount,
800
+ setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea,
801
+ totalVisibleColumns: totalVisibleColumns
742
802
  }), /*#__PURE__*/React.createElement("button", {
803
+ onMouseDown: handleActiveCellMouseDown,
743
804
  onClick: handleActiveCellClick,
744
805
  onKeyDown: handleActiveCellKeyDown,
745
806
  onDoubleClick: handleActiveCellDoubleClick,
807
+ onMouseEnter: handleActiveCellMouseEnter,
746
808
  ref: activeCellRef,
747
- className: cx("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight")),
809
+ className: cx("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), _defineProperty({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
748
810
  type: "button"
749
811
  }, activeCellContent), /*#__PURE__*/React.createElement(TextArea, {
750
812
  value: cellEditorValue,
751
- onKeyDown: handleEditSubmit,
813
+ onKeyDown: handleEditSubmit({
814
+ activeCellCoordinates: activeCellCoordinates,
815
+ cellEditorRulerRef: cellEditorRulerRef,
816
+ columns: columns,
817
+ previousState: previousState,
818
+ removeCellEditor: removeCellEditor,
819
+ rows: rows,
820
+ setActiveCellCoordinates: setActiveCellCoordinates,
821
+ setCurrentMatcher: setCurrentMatcher,
822
+ setSelectionAreas: setSelectionAreas,
823
+ spreadsheetRef: spreadsheetRef,
824
+ updateData: updateData
825
+ }),
752
826
  onChange: function onChange(event) {
753
827
  setCellEditorValue(event.target.value);
754
828
  cellEditorRulerRef.current.textContent = event.target.value;
755
829
  },
756
830
  ref: cellEditorRef,
757
831
  labelText: "",
758
- "aria-labelledby": activeCellCoordinates ? "[data-row-index=\"".concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, "\"][data-column-index=\"").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column, "\"]") : null,
832
+ "aria-labelledby": activeCellCoordinates ? "#".concat(blockClass, "__cell--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, "--").concat(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) : null,
759
833
  className: cx("".concat(blockClass, "__cell-editor"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__cell-editor--").concat(cellSize), _defineProperty({}, "".concat(blockClass, "__cell-editor--active"), isEditing))
760
834
  }), /*#__PURE__*/React.createElement("pre", {
761
835
  "aria-hidden": true,
762
836
  ref: cellEditorRulerRef,
763
837
  className: "".concat(blockClass, "__cell-editor-ruler")
764
- }));
838
+ })));
765
839
  }); // Return a placeholder if not released and not enabled by feature flag
766
840
 
767
841
  DataSpreadsheet = pkg.checkComponentEnabled(DataSpreadsheet, componentName); // The display name of the component, used by React. Note that displayName
@@ -820,7 +894,13 @@ DataSpreadsheet.propTypes = {
820
894
  /**
821
895
  * The event handler that is called when the selection area values change
822
896
  */
823
- onSelectionAreaChange: PropTypes.func
897
+ onSelectionAreaChange: PropTypes.func,
898
+
899
+ /**
900
+ * The total number of columns to be initially visible, additional columns will be rendered and
901
+ * visible via horizontal scrollbar
902
+ */
903
+ totalVisibleColumns: PropTypes.number
824
904
  /* TODO: add types and DocGen for all props. */
825
905
 
826
906
  };