@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
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof = require("@babel/runtime/helpers/typeof");
5
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
6
6
 
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
@@ -11,7 +11,7 @@ exports.DataSpreadsheet = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
14
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
15
 
16
16
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
17
 
@@ -43,11 +43,9 @@ var _hooks = require("../../global/js/hooks");
43
43
 
44
44
  var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
45
45
 
46
- var _useResetSpreadsheetFocus = require("./hooks/useResetSpreadsheetFocus");
46
+ var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
47
47
 
48
- var _useSpreadsheetOutsideClick = require("./hooks/useSpreadsheetOutsideClick");
49
-
50
- var _useMoveActiveCell = require("./hooks/useMoveActiveCell");
48
+ var _hooks2 = require("./hooks");
51
49
 
52
50
  var _createActiveCellFn = require("./utils/createActiveCellFn");
53
51
 
@@ -57,11 +55,21 @@ var _handleMultipleKeys = require("./utils/handleMultipleKeys");
57
55
 
58
56
  var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
59
57
 
60
- var _excluded = ["cellSize", "className", "columns", "data", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
58
+ var _removeCellSelections = require("./utils/removeCellSelections");
59
+
60
+ var _selectAllCells = require("./utils/selectAllCells");
61
+
62
+ var _handleEditSubmit = require("./utils/handleEditSubmit");
63
+
64
+ var _handleActiveCellInSelectionEnter = require("./utils/handleActiveCellInSelectionEnter");
65
+
66
+ var _handleActiveCellInSelectionTab = require("./utils/handleActiveCellInSelectionTab");
67
+
68
+ var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
61
69
 
62
70
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
63
71
 
64
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
72
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
65
73
 
66
74
  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; }
67
75
 
@@ -76,6 +84,7 @@ var defaults = {
76
84
  cellSize: 'standard',
77
85
  columns: Object.freeze([]),
78
86
  data: Object.freeze([]),
87
+ defaultEmptyRowCount: 16,
79
88
  onDataUpdate: Object.freeze(function () {}),
80
89
  onActiveCellChange: Object.freeze(function () {}),
81
90
  onSelectionAreaChange: Object.freeze(function () {})
@@ -92,6 +101,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
92
101
  columns = _ref$columns === void 0 ? defaults.columns : _ref$columns,
93
102
  _ref$data = _ref.data,
94
103
  data = _ref$data === void 0 ? defaults.data : _ref$data,
104
+ _ref$defaultEmptyRowC = _ref.defaultEmptyRowCount,
105
+ defaultEmptyRowCount = _ref$defaultEmptyRowC === void 0 ? defaults.defaultEmptyRowCount : _ref$defaultEmptyRowC,
95
106
  _ref$onDataUpdate = _ref.onDataUpdate,
96
107
  onDataUpdate = _ref$onDataUpdate === void 0 ? defaults.onDataUpdate : _ref$onDataUpdate,
97
108
  id = _ref.id,
@@ -100,6 +111,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
100
111
  _ref$onSelectionAreaC = _ref.onSelectionAreaChange,
101
112
  onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
102
113
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
114
+ var multiKeyTrackingRef = (0, _react.useRef)();
103
115
  var localRef = (0, _react.useRef)();
104
116
  var spreadsheetRef = ref || localRef;
105
117
  var focusedElement = (0, _hooks.useActiveElement)();
@@ -144,19 +156,25 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
144
156
  cellEditorValue = _useState16[0],
145
157
  setCellEditorValue = _useState16[1];
146
158
 
159
+ var _useState17 = (0, _react.useState)(false),
160
+ _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
161
+ activeCellInsideSelectionArea = _useState18[0],
162
+ setActiveCellInsideSelectionArea = _useState18[1];
163
+
147
164
  var previousState = (0, _hooks.usePreviousValue)({
148
- activeCellCoordinates: activeCellCoordinates
165
+ activeCellCoordinates: activeCellCoordinates,
166
+ isEditing: isEditing
149
167
  });
150
168
  var cellSizeValue = (0, _getCellSize.getCellSize)(cellSize);
151
169
  var cellEditorRef = (0, _react.useRef)();
152
170
 
153
- var _useState17 = (0, _react.useState)(),
154
- _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
155
- activeCellContent = _useState18[0],
156
- setActiveCellContent = _useState18[1];
171
+ var _useState19 = (0, _react.useState)(),
172
+ _useState20 = (0, _slicedToArray2.default)(_useState19, 2),
173
+ activeCellContent = _useState20[0],
174
+ setActiveCellContent = _useState20[1];
157
175
 
158
- var activeKeys = (0, _react.useRef)([]);
159
176
  var activeCellRef = (0, _react.useRef)();
177
+ var cellEditorRulerRef = (0, _react.useRef)();
160
178
  var defaultColumn = (0, _react.useMemo)(function () {
161
179
  return {
162
180
  width: 150,
@@ -164,6 +182,15 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
164
182
  rowHeight: cellSizeValue
165
183
  };
166
184
  }, [cellSizeValue]);
185
+
186
+ var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
187
+ ref: multiKeyTrackingRef,
188
+ containerHasFocus: containerHasFocus,
189
+ isEditing: isEditing
190
+ }),
191
+ keysPressedList = _useMultipleKeyTracki.keysPressedList,
192
+ usingMac = _useMultipleKeyTracki.usingMac;
193
+
167
194
  var scrollBarSize = (0, _react.useMemo)(function () {
168
195
  return (0, _getScrollbarWidth.getScrollbarWidth)();
169
196
  }, []);
@@ -204,22 +231,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
204
231
  setCellEditorValue('');
205
232
  setIsEditing(false);
206
233
  cellEditorRef.current.style.display = 'none';
207
- }, []); // Removes the cell selection elements
208
-
209
- var removeCellSelections = (0, _react.useCallback)(function (matcher) {
210
- if (matcher && typeof matcher === 'string') {
211
- var selectionToRemove = spreadsheetRef.current.querySelector("[data-matcher-id=\"".concat(matcher, "\"]"));
212
-
213
- if (selectionToRemove) {
214
- selectionToRemove.remove();
215
- }
216
- } else {
217
- var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
218
- (0, _toConsumableArray2.default)(cellSelections).forEach(function (element) {
219
- return element.remove();
220
- });
221
- }
222
- }, [spreadsheetRef]); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
234
+ }, []); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
223
235
  // happen if you click on another cell while isEditing is true
224
236
 
225
237
  (0, _react.useEffect)(function () {
@@ -229,6 +241,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
229
241
  var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
230
242
  removeCellEditor();
231
243
  updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
244
+ cellEditorRulerRef.current.textContent = '';
232
245
  }
233
246
 
234
247
  if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column)) {
@@ -266,23 +279,21 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
266
279
  });
267
280
  }
268
281
  }, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
269
- (0, _useResetSpreadsheetFocus.useResetSpreadsheetFocus)({
270
- activeKeys: activeKeys,
282
+ (0, _hooks2.useResetSpreadsheetFocus)({
271
283
  focusedElement: focusedElement,
272
284
  removeActiveCell: removeActiveCell,
273
285
  setContainerHasFocus: setContainerHasFocus
274
286
  });
275
- (0, _useSpreadsheetOutsideClick.useSpreadsheetOutsideClick)({
287
+ (0, _hooks2.useSpreadsheetOutsideClick)({
276
288
  spreadsheetRef: spreadsheetRef,
277
289
  setActiveCellCoordinates: setActiveCellCoordinates,
278
290
  setSelectionAreas: setSelectionAreas,
279
291
  removeActiveCell: removeActiveCell,
280
- removeCellSelections: removeCellSelections,
292
+ removeCellSelections: _removeCellSelections.removeCellSelections,
281
293
  setContainerHasFocus: setContainerHasFocus,
282
- activeKeys: activeKeys,
283
294
  removeCellEditor: removeCellEditor
284
295
  });
285
- (0, _useMoveActiveCell.useMoveActiveCell)({
296
+ (0, _hooks2.useMoveActiveCell)({
286
297
  spreadsheetRef: spreadsheetRef,
287
298
  activeCellCoordinates: activeCellCoordinates,
288
299
  containerHasFocus: containerHasFocus,
@@ -291,6 +302,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
291
302
  var handleInitialArrowPress = (0, _react.useCallback)(function () {
292
303
  // If activeCellCoordinates is null then we need to set an initial value
293
304
  // which will place the activeCell on the select all cell/button
305
+ setActiveCellInsideSelectionArea(false);
306
+
294
307
  if (!activeCellCoordinates) {
295
308
  setActiveCellCoordinates({
296
309
  column: 'header',
@@ -301,16 +314,20 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
301
314
  return;
302
315
  }, [activeCellCoordinates]);
303
316
  var updateActiveCellCoordinates = (0, _react.useCallback)(function (_ref3) {
304
- var coords = _ref3.coords,
305
- updatedValue = _ref3.updatedValue;
317
+ var _ref3$coords = _ref3.coords,
318
+ coords = _ref3$coords === void 0 ? _objectSpread({}, activeCellCoordinates) : _ref3$coords,
319
+ updatedValue = _ref3.updatedValue,
320
+ _ref3$optOutOfSelecti = _ref3.optOutOfSelectionAreaUpdate,
321
+ optOutOfSelectionAreaUpdate = _ref3$optOutOfSelecti === void 0 ? false : _ref3$optOutOfSelecti;
306
322
 
307
323
  var newActiveCell = _objectSpread(_objectSpread({}, coords), updatedValue);
308
324
 
309
325
  setActiveCellCoordinates(newActiveCell); // Only run if the active cell is _not_ a header cell. This will add a point1 object
310
326
  // to selectionAreas every time the active cell changes, allowing us to create cell
311
- // selections using keyboard
327
+ // selections using keyboard. Opting out of the selection area updates here means
328
+ // that the active cell is being moved within a selection area
312
329
 
313
- if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header') {
330
+ if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header' && !optOutOfSelectionAreaUpdate) {
314
331
  var tempMatcher = (0, _uuidv.default)();
315
332
  setSelectionAreas([{
316
333
  point1: newActiveCell,
@@ -318,11 +335,29 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
318
335
  }]);
319
336
  setCurrentMatcher(tempMatcher);
320
337
  }
321
- }, []);
338
+ }, [activeCellCoordinates]);
339
+ var handleHomeEndKey = (0, _react.useCallback)(function (_ref4) {
340
+ var type = _ref4.type;
341
+
342
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
343
+
344
+ updateActiveCellCoordinates({
345
+ coords: coordinatesClone,
346
+ updatedValue: {
347
+ column: type === 'home' ? 0 : columns.length - 1
348
+ }
349
+ });
350
+ (0, _removeCellSelections.removeCellSelections)({
351
+ spreadsheetRef: spreadsheetRef
352
+ });
353
+ }, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
322
354
  var handleKeyPress = (0, _react.useCallback)(function (event) {
323
- var _activeKeys$current, _activeKeys$current2;
355
+ var key = event.key;
356
+
357
+ if (isEditing) {
358
+ return;
359
+ } // Command keys need to be returned as there is default browser behavior with these keys
324
360
 
325
- var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
326
361
 
327
362
  if (key === 'Meta' || key === 'Control') {
328
363
  return;
@@ -339,43 +374,90 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
339
374
 
340
375
 
341
376
  if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
342
- if (isEditing) {
343
- return;
344
- }
345
-
346
- if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
377
+ if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList)) {
347
378
  setSelectionAreas([]);
348
379
  setSelectionAreaData([]);
349
- removeCellSelections({
380
+ (0, _removeCellSelections.removeCellSelections)({
350
381
  spreadsheetRef: spreadsheetRef
351
382
  });
352
383
  }
353
- } // Update list of activeKeys
354
-
355
-
356
- if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
357
- var activeClone = (0, _toConsumableArray2.default)(activeKeys.current);
358
- activeKeys.current = [].concat((0, _toConsumableArray2.default)(activeClone), [key]);
359
384
  }
360
385
 
361
- if (((_activeKeys$current2 = activeKeys.current) === null || _activeKeys$current2 === void 0 ? void 0 : _activeKeys$current2.length) > 1) {
386
+ if (!isEditing && (keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
362
387
  (0, _handleMultipleKeys.handleMultipleKeys)({
363
- activeKeys: activeKeys,
388
+ activeCellCoordinates: activeCellCoordinates,
389
+ event: event,
390
+ keysPressedList: keysPressedList,
364
391
  selectionAreas: selectionAreas,
365
392
  currentMatcher: currentMatcher,
366
393
  rows: rows,
367
394
  setSelectionAreas: setSelectionAreas,
368
- columns: columns
395
+ columns: columns,
396
+ updateActiveCellCoordinates: updateActiveCellCoordinates,
397
+ spreadsheetRef: spreadsheetRef,
398
+ removeCellSelections: _removeCellSelections.removeCellSelections,
399
+ blockClass: blockClass,
400
+ setCurrentMatcher: setCurrentMatcher,
401
+ usingMac: usingMac
369
402
  });
370
403
  } // Allow arrow key navigation if there are less than two activeKeys OR
371
404
  // if one of the activeCellCoordinates is in a header position
372
405
 
373
406
 
374
- if (!activeKeys.current.includes('Shift') || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
407
+ if (keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
375
408
  switch (key) {
409
+ // Enter
410
+ case 'Enter':
411
+ {
412
+ (0, _handleActiveCellInSelectionEnter.handleActiveCellInSelectionEnter)({
413
+ activeCellInsideSelectionArea: activeCellInsideSelectionArea,
414
+ activeCellCoordinates: activeCellCoordinates,
415
+ activeCellRef: activeCellRef,
416
+ selectionAreas: selectionAreas,
417
+ updateActiveCellCoordinates: updateActiveCellCoordinates
418
+ });
419
+ break;
420
+ }
421
+ // HOME
422
+
423
+ case 'Home':
424
+ {
425
+ if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac)) {
426
+ return;
427
+ }
428
+
429
+ handleHomeEndKey({
430
+ type: 'home'
431
+ });
432
+ break;
433
+ }
434
+
435
+ case 'End':
436
+ {
437
+ if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac)) {
438
+ return;
439
+ }
440
+
441
+ handleHomeEndKey({
442
+ type: 'end'
443
+ });
444
+ break;
445
+ }
376
446
  // Tab
447
+
377
448
  case 'Tab':
378
449
  {
450
+ if (activeCellInsideSelectionArea) {
451
+ event.preventDefault();
452
+ return (0, _handleActiveCellInSelectionTab.handleActiveCellInSelectionTab)({
453
+ activeCellInsideSelectionArea: activeCellInsideSelectionArea,
454
+ activeCellCoordinates: activeCellCoordinates,
455
+ activeCellRef: activeCellRef,
456
+ selectionAreas: selectionAreas,
457
+ updateActiveCellCoordinates: updateActiveCellCoordinates
458
+ });
459
+ }
460
+
379
461
  setSelectionAreas([]);
380
462
  removeActiveCell();
381
463
  removeCellEditor();
@@ -522,24 +604,59 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
522
604
  }
523
605
  }
524
606
  }
525
- }, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, removeCellSelections, selectionAreas]);
607
+ }, [activeCellInsideSelectionArea, updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac]);
526
608
 
527
609
  var startEditMode = function startEditMode() {
528
610
  setIsEditing(true);
529
611
  var activeCellFullData = typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'number' && typeof (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'number' ? rows[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row].cells[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
530
612
  var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
531
613
  setCellEditorValue(activeCellValue);
532
- };
614
+ cellEditorRulerRef.current.textContent = activeCellValue;
615
+ }; // Sets the initial placement of the cell editor cursor at the end of the text area
616
+ // this is not done for us by default in Safari
617
+
618
+
619
+ (0, _react.useEffect)(function () {
620
+ if (isEditing && !(previousState !== null && previousState !== void 0 && previousState.isEditing)) {
621
+ cellEditorRef.current.setSelectionRange(cellEditorRulerRef.current.textContent.length, cellEditorRulerRef.current.textContent.length);
622
+ cellEditorRef.current.focus();
623
+ }
624
+ }, [isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing]);
533
625
 
534
626
  var handleActiveCellClick = function handleActiveCellClick() {
535
627
  if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
536
628
  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;
629
+
630
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
631
+ return;
632
+ }
633
+
537
634
  handleRowColumnHeaderClick({
538
635
  isKeyboard: false,
539
636
  index: indexValue
540
637
  });
541
638
  }
542
639
 
640
+ return;
641
+ }; // Mouse down on active cell
642
+
643
+
644
+ var handleActiveCellMouseDown = function handleActiveCellMouseDown() {
645
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
646
+ var tempMatcher = (0, _uuidv.default)();
647
+ setClickAndHoldActive(true);
648
+ (0, _removeCellSelections.removeCellSelections)({
649
+ spreadsheetRef: spreadsheetRef
650
+ });
651
+ setSelectionAreas([{
652
+ point1: activeCellCoordinates,
653
+ matcher: tempMatcher
654
+ }]);
655
+ setCurrentMatcher(tempMatcher);
656
+ setSelectionAreaData([]);
657
+ setActiveCellInsideSelectionArea(false);
658
+ }
659
+
543
660
  return;
544
661
  }; // Go into edit mode if 'Enter' key is pressed on activeCellRef
545
662
 
@@ -547,7 +664,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
547
664
  var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
548
665
  var key = event.key;
549
666
 
550
- if (key === 'Enter') {
667
+ if (key === 'Enter' && !activeCellInsideSelectionArea) {
551
668
  if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
552
669
  startEditMode();
553
670
  }
@@ -560,10 +677,10 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
560
677
  }
561
678
  };
562
679
 
563
- var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref4) {
564
- var isKeyboard = _ref4.isKeyboard,
565
- _ref4$index = _ref4.index,
566
- index = _ref4$index === void 0 ? null : _ref4$index;
680
+ var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref5) {
681
+ var isKeyboard = _ref5.isKeyboard,
682
+ _ref5$index = _ref5.index,
683
+ index = _ref5$index === void 0 ? null : _ref5$index;
567
684
  var handleHeaderCellProps = {
568
685
  activeCellCoordinates: activeCellCoordinates,
569
686
  rows: rows,
@@ -577,112 +694,100 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
577
694
  index: index
578
695
  }; // Select an entire column
579
696
 
580
- if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
697
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
581
698
  (0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
582
699
  type: 'column'
583
700
  }, handleHeaderCellProps));
584
701
  } // Select an entire row
585
702
 
586
703
 
587
- if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
704
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
588
705
  (0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
589
706
  type: 'row'
590
707
  }, handleHeaderCellProps));
591
708
  }
592
- }; // Go into edit mode if double click is detected on activeCellRef
593
-
594
-
595
- var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
596
- startEditMode();
597
- }; // Update the data
598
709
 
599
-
600
- var handleEditSubmit = function handleEditSubmit(event) {
601
- var key = event.key;
602
-
603
- var submitEditChanges = function submitEditChanges() {
604
- var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
605
- var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
606
- removeCellEditor();
607
- updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
608
- };
609
-
610
- if (key === 'Enter') {
611
- submitEditChanges();
612
- setActiveCellCoordinates(function (prev) {
613
- return _objectSpread(_objectSpread({}, prev), {}, {
614
- 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
615
-
616
- });
710
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
711
+ (0, _selectAllCells.selectAllCells)({
712
+ ref: spreadsheetRef,
713
+ setCurrentMatcher: setCurrentMatcher,
714
+ setSelectionAreas: setSelectionAreas,
715
+ rows: rows,
716
+ columns: columns,
717
+ activeCellCoordinates: activeCellCoordinates,
718
+ updateActiveCellCoordinates: updateActiveCellCoordinates
617
719
  });
618
720
  }
721
+ }; // Go into edit mode if double click is detected on activeCellRef
619
722
 
620
- if (key === 'Tab') {
621
- event.preventDefault();
622
- submitEditChanges();
623
- setActiveCellCoordinates(function (prev) {
624
- return _objectSpread(_objectSpread({}, prev), {}, {
625
- 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
626
723
 
627
- });
628
- });
629
- }
630
-
631
- return;
724
+ var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
725
+ startEditMode();
632
726
  };
633
727
 
634
- (0, _react.useEffect)(function () {
635
- if (isEditing) {
636
- var _rows$activeCellCoord, _cellProps$column, _cellEditorRef$curren;
637
-
638
- 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];
639
- var activeCellLeftPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.left;
640
- var activeCellTopPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.top;
641
- cellEditorRef.current.style.left = activeCellLeftPosition;
642
- cellEditorRef.current.style.top = activeCellTopPosition;
643
- cellEditorRef.current.style.display = 'block';
644
- cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
645
- cellEditorRef.current.style.height = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height;
646
- 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
647
-
648
- 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';
649
- (_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 ? void 0 : _cellEditorRef$curren.focus();
728
+ (0, _hooks2.useSpreadsheetEdit)({
729
+ isEditing: isEditing,
730
+ rows: rows,
731
+ activeCellCoordinates: activeCellCoordinates,
732
+ activeCellRef: activeCellRef,
733
+ cellEditorRef: cellEditorRef,
734
+ cellEditorRulerRef: cellEditorRulerRef,
735
+ columns: columns,
736
+ defaultColumn: defaultColumn,
737
+ cellEditorValue: cellEditorValue
738
+ });
739
+ var handleActiveCellMouseEnter = (0, _react.useCallback)(function () {
740
+ handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
741
+ }, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]); // Only update if there are cell selection areas
742
+ // Find point object that matches currentMatcher and remove the second point
743
+ // because hovering over the active cell while clicking and holding should
744
+ // remove the previously existing selection area
745
+
746
+ var handleActiveCellMouseEnterCallback = (0, _react.useCallback)(function (areas, clickHold) {
747
+ if (!currentMatcher) {
748
+ return;
650
749
  }
651
750
 
652
- if (!isEditing) {
653
- cellEditorRef.current.style.display = 'none';
654
- cellEditorRef.current.blur();
655
- activeCellRef.current.focus();
656
- }
657
- }, [isEditing, activeCellCoordinates, rows]);
751
+ if (areas && areas.length && clickHold && currentMatcher) {
752
+ setSelectionAreas(function (prev) {
753
+ var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
754
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
755
+ return item.matcher === currentMatcher;
756
+ });
658
757
 
659
- var handleKeyUp = function handleKeyUp(event) {
660
- var _activeKeys$current3;
758
+ if (indexOfItemToUpdate === -1) {
759
+ return prev;
760
+ }
661
761
 
662
- var key = event.key; // Remove key from active keys array on key up
762
+ if ((0, _typeof2.default)(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
763
+ selectionAreaClone[indexOfItemToUpdate].point2 = selectionAreaClone[indexOfItemToUpdate].point1;
764
+ selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
765
+ setActiveCellInsideSelectionArea(false);
766
+ (0, _removeCellSelections.removeCellSelections)({
767
+ matcher: currentMatcher,
768
+ spreadsheetRef: spreadsheetRef
769
+ });
770
+ return selectionAreaClone;
771
+ }
663
772
 
664
- if ((_activeKeys$current3 = activeKeys.current) !== null && _activeKeys$current3 !== void 0 && _activeKeys$current3.includes(key)) {
665
- var activeKeysClone = (0, _toConsumableArray2.default)(activeKeys.current);
666
- var filteredKeysClone = activeKeysClone.filter(function (item) {
667
- return item !== key;
773
+ return prev;
668
774
  });
669
- activeKeys.current = filteredKeysClone;
670
775
  }
671
- };
672
-
776
+ }, [spreadsheetRef, currentMatcher]);
673
777
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, getTableProps(), (0, _devtools.getDevtoolsProps)(componentName), {
674
- className: (0, _classnames.default)(blockClass, className, (0, _defineProperty2.default)({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
778
+ className: (0, _classnames.default)(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
675
779
  ref: spreadsheetRef,
676
780
  role: "grid",
677
781
  tabIndex: 0,
678
782
  "aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
679
783
  "aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
680
784
  onKeyDown: handleKeyPress,
681
- onKeyUp: handleKeyUp,
682
785
  onFocus: function onFocus() {
683
786
  return setContainerHasFocus(true);
684
787
  }
685
- }), /*#__PURE__*/_react.default.createElement(_DataSpreadsheetHeader.DataSpreadsheetHeader, {
788
+ }), /*#__PURE__*/_react.default.createElement("div", {
789
+ ref: multiKeyTrackingRef
790
+ }, /*#__PURE__*/_react.default.createElement(_DataSpreadsheetHeader.DataSpreadsheetHeader, {
686
791
  ref: spreadsheetRef,
687
792
  activeCellCoordinates: activeCellCoordinates,
688
793
  cellSize: cellSize,
@@ -695,7 +800,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
695
800
  setActiveCellCoordinates: setActiveCellCoordinates,
696
801
  setSelectionAreas: setSelectionAreas,
697
802
  setCurrentMatcher: setCurrentMatcher,
698
- setSelectionAreaData: setSelectionAreaData
803
+ setSelectionAreaData: setSelectionAreaData,
804
+ updateActiveCellCoordinates: updateActiveCellCoordinates
699
805
  }), /*#__PURE__*/_react.default.createElement(_DataSpreadsheetBody.DataSpreadsheetBody, {
700
806
  activeCellCoordinates: activeCellCoordinates,
701
807
  ref: spreadsheetRef,
@@ -707,8 +813,10 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
707
813
  selectionAreas: selectionAreas,
708
814
  setSelectionAreas: setSelectionAreas,
709
815
  cellSize: cellSize,
816
+ headerGroups: headerGroups,
710
817
  defaultColumn: defaultColumn,
711
818
  getTableBodyProps: getTableBodyProps,
819
+ onDataUpdate: onDataUpdate,
712
820
  onActiveCellChange: onActiveCellChange,
713
821
  onSelectionAreaChange: onSelectionAreaChange,
714
822
  prepareRow: prepareRow,
@@ -719,25 +827,46 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
719
827
  scrollBarSize: scrollBarSize,
720
828
  totalColumnsWidth: totalColumnsWidth,
721
829
  id: id,
722
- columns: columns
830
+ columns: columns,
831
+ defaultEmptyRowCount: defaultEmptyRowCount,
832
+ setActiveCellInsideSelectionArea: setActiveCellInsideSelectionArea
723
833
  }), /*#__PURE__*/_react.default.createElement("button", {
834
+ onMouseDown: handleActiveCellMouseDown,
724
835
  onClick: handleActiveCellClick,
725
836
  onKeyDown: handleActiveCellKeyDown,
726
837
  onDoubleClick: handleActiveCellDoubleClick,
838
+ onMouseEnter: handleActiveCellMouseEnter,
727
839
  ref: activeCellRef,
728
- className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight")),
840
+ className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
729
841
  type: "button"
730
842
  }, activeCellContent), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextArea, {
731
843
  value: cellEditorValue,
732
- onKeyDown: handleEditSubmit,
844
+ onKeyDown: (0, _handleEditSubmit.handleEditSubmit)({
845
+ activeCellCoordinates: activeCellCoordinates,
846
+ cellEditorRulerRef: cellEditorRulerRef,
847
+ columns: columns,
848
+ previousState: previousState,
849
+ removeCellEditor: removeCellEditor,
850
+ rows: rows,
851
+ setActiveCellCoordinates: setActiveCellCoordinates,
852
+ setCurrentMatcher: setCurrentMatcher,
853
+ setSelectionAreas: setSelectionAreas,
854
+ spreadsheetRef: spreadsheetRef,
855
+ updateData: updateData
856
+ }),
733
857
  onChange: function onChange(event) {
734
- return setCellEditorValue(event.target.value);
858
+ setCellEditorValue(event.target.value);
859
+ cellEditorRulerRef.current.textContent = event.target.value;
735
860
  },
736
861
  ref: cellEditorRef,
737
862
  labelText: "",
738
- "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,
863
+ "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,
739
864
  className: (0, _classnames.default)("".concat(blockClass, "__cell-editor"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__cell-editor--").concat(cellSize), (0, _defineProperty2.default)({}, "".concat(blockClass, "__cell-editor--active"), isEditing))
740
- }));
865
+ }), /*#__PURE__*/_react.default.createElement("pre", {
866
+ "aria-hidden": true,
867
+ ref: cellEditorRulerRef,
868
+ className: "".concat(blockClass, "__cell-editor-ruler")
869
+ })));
741
870
  }); // Return a placeholder if not released and not enabled by feature flag
742
871
 
743
872
 
@@ -775,6 +904,11 @@ DataSpreadsheet.propTypes = {
775
904
  */
776
905
  data: _propTypes.default.arrayOf(_propTypes.default.shape),
777
906
 
907
+ /**
908
+ * Sets the number of empty rows to be created when there is no data provided
909
+ */
910
+ defaultEmptyRowCount: _propTypes.default.number,
911
+
778
912
  /**
779
913
  * The spreadsheet id
780
914
  */