@carbon/ibm-products 1.11.2 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. package/README.md +0 -3
  2. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css +47 -0
  3. package/css/components/Datagrid/styles/addons/CustomizeColumnsModal.css.map +1 -0
  4. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css +20 -0
  5. package/css/components/Datagrid/styles/addons/RowSizeDropdown.css.map +1 -0
  6. package/css/components/Datagrid/styles/datagrid.css +264 -0
  7. package/css/components/Datagrid/styles/datagrid.css.map +1 -0
  8. package/css/components/Datagrid/styles/index.css +509 -0
  9. package/css/components/Datagrid/styles/index.css.map +1 -0
  10. package/css/components/Datagrid/styles/useActionsColumn.css +23 -0
  11. package/css/components/Datagrid/styles/useActionsColumn.css.map +1 -0
  12. package/css/components/Datagrid/styles/useColumnRightAlign.css +28 -0
  13. package/css/components/Datagrid/styles/useColumnRightAlign.css.map +1 -0
  14. package/css/components/Datagrid/styles/useNestedRows.css +15 -0
  15. package/css/components/Datagrid/styles/useNestedRows.css.map +1 -0
  16. package/css/components/Datagrid/styles/useNestedTable.css +25 -0
  17. package/css/components/Datagrid/styles/useNestedTable.css.map +1 -0
  18. package/css/components/Datagrid/styles/useSelectAllToggle.css +28 -0
  19. package/css/components/Datagrid/styles/useSelectAllToggle.css.map +1 -0
  20. package/css/components/Datagrid/styles/useSortableColumns.css +50 -0
  21. package/css/components/Datagrid/styles/useSortableColumns.css.map +1 -0
  22. package/css/components/Datagrid/styles/useStickyColumn.css +35 -0
  23. package/css/components/Datagrid/styles/useStickyColumn.css.map +1 -0
  24. package/css/index-full-carbon.css +2019 -376
  25. package/css/index-full-carbon.css.map +1 -1
  26. package/css/index-full-carbon.min.css +6 -6
  27. package/css/index-full-carbon.min.css.map +1 -1
  28. package/css/index-without-carbon-released-only.css +18 -6
  29. package/css/index-without-carbon-released-only.css.map +1 -1
  30. package/css/index-without-carbon-released-only.min.css +2 -2
  31. package/css/index-without-carbon-released-only.min.css.map +1 -1
  32. package/css/index-without-carbon.css +679 -19
  33. package/css/index-without-carbon.css.map +1 -1
  34. package/css/index-without-carbon.min.css +5 -5
  35. package/css/index-without-carbon.min.css.map +1 -1
  36. package/css/index.css +679 -19
  37. package/css/index.css.map +1 -1
  38. package/css/index.min.css +6 -6
  39. package/css/index.min.css.map +1 -1
  40. package/es/components/ActionBar/ActionBar.js +3 -1
  41. package/es/components/ActionBar/ActionBarOverflowItems.js +5 -3
  42. package/es/components/AddSelect/AddSelect.js +133 -30
  43. package/es/components/AddSelect/AddSelectColumn.js +0 -1
  44. package/es/components/AddSelect/AddSelectFilter.js +129 -0
  45. package/es/components/AddSelect/AddSelectList.js +59 -13
  46. package/es/components/AddSelect/AddSelectSidebar.js +15 -5
  47. package/es/components/AddSelect/add-select-utils.js +30 -0
  48. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
  49. package/es/components/DataSpreadsheet/DataSpreadsheet.js +262 -164
  50. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +191 -51
  51. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +65 -13
  52. package/es/components/DataSpreadsheet/hooks/index.js +10 -0
  53. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +111 -0
  54. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  55. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -6
  56. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +3 -1
  57. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +80 -6
  58. package/es/components/Datagrid/Datagrid/Datagrid.js +70 -0
  59. package/es/components/Datagrid/Datagrid/DatagridBody.js +36 -0
  60. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +19 -0
  61. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -0
  62. package/es/components/Datagrid/Datagrid/DatagridHead.js +31 -0
  63. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +57 -0
  64. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +37 -0
  65. package/es/components/Datagrid/Datagrid/DatagridRow.js +50 -0
  66. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +50 -0
  67. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +122 -0
  68. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +36 -0
  69. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -0
  70. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +87 -0
  71. package/es/components/Datagrid/Datagrid/DraggableElement.js +188 -0
  72. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +78 -0
  73. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +51 -0
  74. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +140 -0
  75. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +157 -0
  76. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +62 -0
  77. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +13 -0
  78. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +9 -0
  79. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +62 -0
  80. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +139 -0
  81. package/es/components/Datagrid/Datagrid/addons/RowSize/index.js +8 -0
  82. package/es/components/Datagrid/Datagrid/index.js +8 -0
  83. package/es/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +6 -0
  84. package/es/components/Datagrid/Datagrid.stories/LeftPanelStory.js +6 -0
  85. package/es/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +6 -0
  86. package/es/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +6 -0
  87. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -0
  88. package/es/components/Datagrid/Datagrid.stories/common.js +199 -0
  89. package/es/components/Datagrid/Datagrid.stories/index.js +5 -0
  90. package/es/components/Datagrid/common-column-ids.js +8 -0
  91. package/es/components/Datagrid/index.js +22 -0
  92. package/es/components/Datagrid/useActionsColumn.js +86 -0
  93. package/es/components/Datagrid/useColumnRightAlign.js +52 -0
  94. package/es/components/Datagrid/useCustomizeColumns.js +45 -0
  95. package/es/components/Datagrid/useDatagrid.js +44 -0
  96. package/es/components/Datagrid/useDefaultStringRenderer.js +48 -0
  97. package/es/components/Datagrid/useDisableSelectRows.js +84 -0
  98. package/es/components/Datagrid/useExpandedRow.js +52 -0
  99. package/es/components/Datagrid/useFlexResize.js +51 -0
  100. package/es/components/Datagrid/useFloatingScroll.js +88 -0
  101. package/es/components/Datagrid/useInfiniteScroll.js +54 -0
  102. package/es/components/Datagrid/useNestedRows.js +53 -0
  103. package/es/components/Datagrid/useOnRowClick.js +37 -0
  104. package/es/components/Datagrid/useParentDimensions.js +65 -0
  105. package/es/components/Datagrid/useResizeTable.js +40 -0
  106. package/es/components/Datagrid/useRowExpander.js +34 -0
  107. package/es/components/Datagrid/useRowIsMouseOver.js +61 -0
  108. package/es/components/Datagrid/useRowRenderer.js +30 -0
  109. package/es/components/Datagrid/useRowSize.js +56 -0
  110. package/es/components/Datagrid/useSelectAllToggle.js +74 -0
  111. package/es/components/Datagrid/useSelectRows.js +107 -0
  112. package/es/components/Datagrid/useSkeletonRows.js +32 -0
  113. package/es/components/Datagrid/useSortableColumns.js +110 -0
  114. package/es/components/Datagrid/useStickyColumn.js +183 -0
  115. package/es/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
  116. package/es/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
  117. package/es/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
  118. package/es/components/ImportModal/ImportModal.js +2 -2
  119. package/es/components/TagSet/TagSet.js +12 -3
  120. package/es/components/UserProfileImage/UserProfileImage.js +38 -10
  121. package/es/components/index.js +2 -1
  122. package/es/global/js/package-settings.js +2 -1
  123. package/lib/components/ActionBar/ActionBar.js +3 -1
  124. package/lib/components/ActionBar/ActionBarOverflowItems.js +5 -3
  125. package/lib/components/AddSelect/AddSelect.js +132 -28
  126. package/lib/components/AddSelect/AddSelectColumn.js +0 -1
  127. package/lib/components/AddSelect/AddSelectFilter.js +147 -0
  128. package/lib/components/AddSelect/AddSelectList.js +61 -12
  129. package/lib/components/AddSelect/AddSelectSidebar.js +15 -11
  130. package/lib/components/AddSelect/add-select-utils.js +35 -2
  131. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
  132. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +267 -168
  133. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +191 -57
  134. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +67 -18
  135. package/lib/components/DataSpreadsheet/hooks/index.js +37 -0
  136. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +123 -0
  137. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +2 -4
  138. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -5
  139. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +3 -1
  140. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +83 -7
  141. package/lib/components/Datagrid/Datagrid/Datagrid.js +86 -0
  142. package/lib/components/Datagrid/Datagrid/DatagridBody.js +50 -0
  143. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +31 -0
  144. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +38 -0
  145. package/lib/components/Datagrid/Datagrid/DatagridHead.js +43 -0
  146. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +73 -0
  147. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +44 -0
  148. package/lib/components/Datagrid/Datagrid/DatagridRow.js +56 -0
  149. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +55 -0
  150. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +139 -0
  151. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +44 -0
  152. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +35 -0
  153. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +101 -0
  154. package/lib/components/Datagrid/Datagrid/DraggableElement.js +210 -0
  155. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +92 -0
  156. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +65 -0
  157. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +166 -0
  158. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +173 -0
  159. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +73 -0
  160. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +25 -0
  161. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +23 -0
  162. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +80 -0
  163. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +160 -0
  164. package/lib/components/Datagrid/Datagrid/addons/RowSize/index.js +15 -0
  165. package/lib/components/Datagrid/Datagrid/index.js +15 -0
  166. package/lib/components/Datagrid/Datagrid.stories/CustomizeColumnStory.js +13 -0
  167. package/lib/components/Datagrid/Datagrid.stories/LeftPanelStory.js +13 -0
  168. package/lib/components/Datagrid/Datagrid.stories/RowSizeDropdownStory.js +13 -0
  169. package/lib/components/Datagrid/Datagrid.stories/SelectAllWithToggleStory.js +13 -0
  170. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +112 -0
  171. package/lib/components/Datagrid/Datagrid.stories/common.js +215 -0
  172. package/lib/components/Datagrid/Datagrid.stories/index.js +47 -0
  173. package/lib/components/Datagrid/common-column-ids.js +16 -0
  174. package/lib/components/Datagrid/index.js +127 -0
  175. package/lib/components/Datagrid/useActionsColumn.js +94 -0
  176. package/lib/components/Datagrid/useColumnRightAlign.js +59 -0
  177. package/lib/components/Datagrid/useCustomizeColumns.js +55 -0
  178. package/lib/components/Datagrid/useDatagrid.js +58 -0
  179. package/lib/components/Datagrid/useDefaultStringRenderer.js +54 -0
  180. package/lib/components/Datagrid/useDisableSelectRows.js +92 -0
  181. package/lib/components/Datagrid/useExpandedRow.js +58 -0
  182. package/lib/components/Datagrid/useFlexResize.js +61 -0
  183. package/lib/components/Datagrid/useFloatingScroll.js +101 -0
  184. package/lib/components/Datagrid/useInfiniteScroll.js +67 -0
  185. package/lib/components/Datagrid/useNestedRows.js +65 -0
  186. package/lib/components/Datagrid/useOnRowClick.js +45 -0
  187. package/lib/components/Datagrid/useParentDimensions.js +75 -0
  188. package/lib/components/Datagrid/useResizeTable.js +48 -0
  189. package/lib/components/Datagrid/useRowExpander.js +45 -0
  190. package/lib/components/Datagrid/useRowIsMouseOver.js +66 -0
  191. package/lib/components/Datagrid/useRowRenderer.js +40 -0
  192. package/lib/components/Datagrid/useRowSize.js +67 -0
  193. package/lib/components/Datagrid/useSelectAllToggle.js +88 -0
  194. package/lib/components/Datagrid/useSelectRows.js +119 -0
  195. package/lib/components/Datagrid/useSkeletonRows.js +42 -0
  196. package/lib/components/Datagrid/useSortableColumns.js +117 -0
  197. package/lib/components/Datagrid/useStickyColumn.js +190 -0
  198. package/lib/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
  199. package/lib/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
  200. package/lib/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
  201. package/lib/components/ImportModal/ImportModal.js +1 -1
  202. package/lib/components/TagSet/TagSet.js +12 -3
  203. package/lib/components/UserProfileImage/UserProfileImage.js +38 -10
  204. package/lib/components/index.js +9 -1
  205. package/lib/global/js/package-settings.js +2 -1
  206. package/package.json +19 -15
  207. package/scss/components/AboutModal/_about-modal.scss +2 -2
  208. package/scss/components/ActionSet/_action-set.scss +3 -1
  209. package/scss/components/AddSelect/_add-select.scss +87 -3
  210. package/scss/components/CreateModal/_create-modal.scss +7 -5
  211. package/scss/components/CreateModal/_storybook-styles.scss +8 -7
  212. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +70 -10
  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 +318 -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 +3 -3
  229. package/scss/components/HTTPErrors/_http-errors.scss +16 -16
  230. package/scss/components/InlineEdit/_inline-edit.scss +0 -1
  231. package/scss/components/ModifiedTabs/_modified-tabs.scss +0 -10
  232. package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -3
  233. package/scss/components/OptionsTile/_options-tile.scss +0 -1
  234. package/scss/components/PageHeader/_page-header.scss +4 -0
  235. package/scss/components/RemoveModal/_remove-modal.scss +3 -3
  236. package/scss/components/TagSet/_tag-set.scss +2 -1
  237. package/scss/components/Tearsheet/_tearsheet.scss +5 -2
  238. 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 _typeof3 = require("@babel/runtime/helpers/typeof");
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
6
 
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
@@ -11,10 +11,6 @@ exports.DataSpreadsheet = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
15
-
16
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
17
-
18
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
15
 
20
16
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
@@ -25,6 +21,8 @@ var _react = _interopRequireWildcard(require("react"));
25
21
 
26
22
  var _reactTable = require("react-table");
27
23
 
24
+ var _layout = require("@carbon/layout");
25
+
28
26
  var _propTypes = _interopRequireDefault(require("prop-types"));
29
27
 
30
28
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -43,15 +41,9 @@ var _getScrollbarWidth = require("../../global/js/utils/getScrollbarWidth");
43
41
 
44
42
  var _hooks = require("../../global/js/hooks");
45
43
 
46
- var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
47
-
48
44
  var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
49
45
 
50
- var _useResetSpreadsheetFocus = require("./hooks/useResetSpreadsheetFocus");
51
-
52
- var _useSpreadsheetOutsideClick = require("./hooks/useSpreadsheetOutsideClick");
53
-
54
- var _useMoveActiveCell = require("./hooks/useMoveActiveCell");
46
+ var _hooks2 = require("./hooks");
55
47
 
56
48
  var _createActiveCellFn = require("./utils/createActiveCellFn");
57
49
 
@@ -61,11 +53,13 @@ var _handleMultipleKeys = require("./utils/handleMultipleKeys");
61
53
 
62
54
  var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
63
55
 
64
- var _excluded = ["cellSize", "className", "columns", "data", "onDataUpdate", "id", "onActiveCellChange"];
56
+ var _removeCellSelections = require("./utils/removeCellSelections");
57
+
58
+ var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange"];
65
59
 
66
60
  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); }
67
61
 
68
- 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; }
62
+ 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; }
69
63
 
70
64
  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; }
71
65
 
@@ -80,7 +74,10 @@ var defaults = {
80
74
  cellSize: 'standard',
81
75
  columns: Object.freeze([]),
82
76
  data: Object.freeze([]),
83
- onDataUpdate: Object.freeze(function () {})
77
+ defaultEmptyRowCount: 16,
78
+ onDataUpdate: Object.freeze(function () {}),
79
+ onActiveCellChange: Object.freeze(function () {}),
80
+ onSelectionAreaChange: Object.freeze(function () {})
84
81
  };
85
82
  /**
86
83
  * DataSpreadsheet: used to organize and display large amounts of structured data, separated by columns and rows in a grid-like format.
@@ -94,11 +91,17 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
94
91
  columns = _ref$columns === void 0 ? defaults.columns : _ref$columns,
95
92
  _ref$data = _ref.data,
96
93
  data = _ref$data === void 0 ? defaults.data : _ref$data,
94
+ _ref$defaultEmptyRowC = _ref.defaultEmptyRowCount,
95
+ defaultEmptyRowCount = _ref$defaultEmptyRowC === void 0 ? defaults.defaultEmptyRowCount : _ref$defaultEmptyRowC,
97
96
  _ref$onDataUpdate = _ref.onDataUpdate,
98
97
  onDataUpdate = _ref$onDataUpdate === void 0 ? defaults.onDataUpdate : _ref$onDataUpdate,
99
98
  id = _ref.id,
100
- onActiveCellChange = _ref.onActiveCellChange,
99
+ _ref$onActiveCellChan = _ref.onActiveCellChange,
100
+ onActiveCellChange = _ref$onActiveCellChan === void 0 ? defaults.onActiveCellChange : _ref$onActiveCellChan,
101
+ _ref$onSelectionAreaC = _ref.onSelectionAreaChange,
102
+ onSelectionAreaChange = _ref$onSelectionAreaC === void 0 ? defaults.onSelectionAreaChange : _ref$onSelectionAreaC,
101
103
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
104
+ var multiKeyTrackingRef = (0, _react.useRef)();
102
105
  var localRef = (0, _react.useRef)();
103
106
  var spreadsheetRef = ref || localRef;
104
107
  var focusedElement = (0, _hooks.useActiveElement)();
@@ -118,34 +121,45 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
118
121
  selectionAreas = _useState6[0],
119
122
  setSelectionAreas = _useState6[1];
120
123
 
121
- var _useState7 = (0, _react.useState)(false),
124
+ var _useState7 = (0, _react.useState)([]),
122
125
  _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
123
- clickAndHoldActive = _useState8[0],
124
- setClickAndHoldActive = _useState8[1];
126
+ selectionAreaData = _useState8[0],
127
+ setSelectionAreaData = _useState8[1];
125
128
 
126
- var _useState9 = (0, _react.useState)(''),
129
+ var _useState9 = (0, _react.useState)(false),
127
130
  _useState10 = (0, _slicedToArray2.default)(_useState9, 2),
128
- currentMatcher = _useState10[0],
129
- setCurrentMatcher = _useState10[1];
131
+ clickAndHoldActive = _useState10[0],
132
+ setClickAndHoldActive = _useState10[1];
130
133
 
131
- var _useState11 = (0, _react.useState)(false),
134
+ var _useState11 = (0, _react.useState)(''),
132
135
  _useState12 = (0, _slicedToArray2.default)(_useState11, 2),
133
- isEditing = _useState12[0],
134
- setIsEditing = _useState12[1];
136
+ currentMatcher = _useState12[0],
137
+ setCurrentMatcher = _useState12[1];
135
138
 
136
- var _useState13 = (0, _react.useState)(''),
139
+ var _useState13 = (0, _react.useState)(false),
137
140
  _useState14 = (0, _slicedToArray2.default)(_useState13, 2),
138
- cellEditorValue = _useState14[0],
139
- setCellEditorValue = _useState14[1];
141
+ isEditing = _useState14[0],
142
+ setIsEditing = _useState14[1];
143
+
144
+ var _useState15 = (0, _react.useState)(''),
145
+ _useState16 = (0, _slicedToArray2.default)(_useState15, 2),
146
+ cellEditorValue = _useState16[0],
147
+ setCellEditorValue = _useState16[1];
140
148
 
141
149
  var previousState = (0, _hooks.usePreviousValue)({
142
- activeCellCoordinates: activeCellCoordinates
150
+ activeCellCoordinates: activeCellCoordinates,
151
+ isEditing: isEditing
143
152
  });
144
153
  var cellSizeValue = (0, _getCellSize.getCellSize)(cellSize);
145
154
  var cellEditorRef = (0, _react.useRef)();
146
- var currentMatcherRef = (0, _react.useRef)();
147
- var activeKeys = (0, _react.useRef)([]);
155
+
156
+ var _useState17 = (0, _react.useState)(),
157
+ _useState18 = (0, _slicedToArray2.default)(_useState17, 2),
158
+ activeCellContent = _useState18[0],
159
+ setActiveCellContent = _useState18[1];
160
+
148
161
  var activeCellRef = (0, _react.useRef)();
162
+ var cellEditorRulerRef = (0, _react.useRef)();
149
163
  var defaultColumn = (0, _react.useMemo)(function () {
150
164
  return {
151
165
  width: 150,
@@ -153,6 +167,14 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
153
167
  rowHeight: cellSizeValue
154
168
  };
155
169
  }, [cellSizeValue]);
170
+
171
+ var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
172
+ ref: multiKeyTrackingRef,
173
+ containerHasFocus: containerHasFocus,
174
+ isEditing: isEditing
175
+ }),
176
+ keysPressedList = _useMultipleKeyTracki.keysPressedList;
177
+
156
178
  var scrollBarSize = (0, _react.useMemo)(function () {
157
179
  return (0, _getScrollbarWidth.getScrollbarWidth)();
158
180
  }, []);
@@ -193,22 +215,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
193
215
  setCellEditorValue('');
194
216
  setIsEditing(false);
195
217
  cellEditorRef.current.style.display = 'none';
196
- }, []); // Removes the cell selection elements
197
-
198
- var removeCellSelections = (0, _react.useCallback)(function (matcher) {
199
- if (matcher && typeof matcher === 'string') {
200
- var selectionToRemove = spreadsheetRef.current.querySelector("[data-matcher-id=\"".concat(matcher, "\"]"));
201
-
202
- if (selectionToRemove) {
203
- selectionToRemove.remove();
204
- }
205
- } else {
206
- var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
207
- (0, _toConsumableArray2.default)(cellSelections).forEach(function (element) {
208
- return element.remove();
209
- });
210
- }
211
- }, [spreadsheetRef]); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
218
+ }, []); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
212
219
  // happen if you click on another cell while isEditing is true
213
220
 
214
221
  (0, _react.useEffect)(function () {
@@ -218,11 +225,20 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
218
225
  var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
219
226
  removeCellEditor();
220
227
  updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
228
+ cellEditorRulerRef.current.textContent = '';
229
+ }
230
+
231
+ 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)) {
232
+ if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
233
+ 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;
234
+ setActiveCellContent(activeCellFullData.render('Cell'));
235
+ }
236
+
237
+ if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
238
+ setActiveCellContent(null);
239
+ }
221
240
  }
222
- }, [activeCellCoordinates, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, updateData, rows, isEditing, removeCellEditor]);
223
- var handleActiveCellMouseEnter = (0, _react.useCallback)(function () {
224
- handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
225
- }, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
241
+ }, [activeCellCoordinates, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, updateData, rows, isEditing, removeCellEditor, activeCellContent]);
226
242
  var createActiveCell = (0, _react.useCallback)(function (_ref2) {
227
243
  var placementElement = _ref2.placementElement,
228
244
  coords = _ref2.coords,
@@ -247,23 +263,21 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
247
263
  });
248
264
  }
249
265
  }, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
250
- (0, _useResetSpreadsheetFocus.useResetSpreadsheetFocus)({
251
- activeKeys: activeKeys,
266
+ (0, _hooks2.useResetSpreadsheetFocus)({
252
267
  focusedElement: focusedElement,
253
268
  removeActiveCell: removeActiveCell,
254
269
  setContainerHasFocus: setContainerHasFocus
255
270
  });
256
- (0, _useSpreadsheetOutsideClick.useSpreadsheetOutsideClick)({
271
+ (0, _hooks2.useSpreadsheetOutsideClick)({
257
272
  spreadsheetRef: spreadsheetRef,
258
273
  setActiveCellCoordinates: setActiveCellCoordinates,
259
274
  setSelectionAreas: setSelectionAreas,
260
275
  removeActiveCell: removeActiveCell,
261
- removeCellSelections: removeCellSelections,
276
+ removeCellSelections: _removeCellSelections.removeCellSelections,
262
277
  setContainerHasFocus: setContainerHasFocus,
263
- activeKeys: activeKeys,
264
278
  removeCellEditor: removeCellEditor
265
279
  });
266
- (0, _useMoveActiveCell.useMoveActiveCell)({
280
+ (0, _hooks2.useMoveActiveCell)({
267
281
  spreadsheetRef: spreadsheetRef,
268
282
  activeCellCoordinates: activeCellCoordinates,
269
283
  containerHasFocus: containerHasFocus,
@@ -300,10 +314,28 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
300
314
  setCurrentMatcher(tempMatcher);
301
315
  }
302
316
  }, []);
317
+ var handleHomeEndKey = (0, _react.useCallback)(function (_ref4) {
318
+ var type = _ref4.type;
319
+
320
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
321
+
322
+ updateActiveCellCoordinates({
323
+ coords: coordinatesClone,
324
+ updatedValue: {
325
+ column: type === 'home' ? 0 : columns.length - 1
326
+ }
327
+ });
328
+ (0, _removeCellSelections.removeCellSelections)({
329
+ spreadsheetRef: spreadsheetRef
330
+ });
331
+ }, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
303
332
  var handleKeyPress = (0, _react.useCallback)(function (event) {
304
- var _activeKeys$current, _activeKeys$current2;
333
+ var key = event.key;
334
+
335
+ if (isEditing) {
336
+ return;
337
+ } // Command keys need to be returned as there is default browser behavior with these keys
305
338
 
306
- var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
307
339
 
308
340
  if (key === 'Meta' || key === 'Control') {
309
341
  return;
@@ -320,27 +352,20 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
320
352
 
321
353
 
322
354
  if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
323
- if (isEditing) {
324
- return;
325
- }
326
-
327
- if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
355
+ if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList)) {
328
356
  setSelectionAreas([]);
329
- removeCellSelections({
357
+ setSelectionAreaData([]);
358
+ (0, _removeCellSelections.removeCellSelections)({
330
359
  spreadsheetRef: spreadsheetRef
331
360
  });
332
361
  }
333
- } // Update list of activeKeys
334
-
335
-
336
- if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
337
- var activeClone = (0, _toConsumableArray2.default)(activeKeys.current);
338
- activeKeys.current = [].concat((0, _toConsumableArray2.default)(activeClone), [key]);
339
362
  }
340
363
 
341
- if (((_activeKeys$current2 = activeKeys.current) === null || _activeKeys$current2 === void 0 ? void 0 : _activeKeys$current2.length) > 1) {
364
+ if (!isEditing && (keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
342
365
  (0, _handleMultipleKeys.handleMultipleKeys)({
343
- activeKeys: activeKeys,
366
+ activeCellCoordinates: activeCellCoordinates,
367
+ event: event,
368
+ keysPressedList: keysPressedList,
344
369
  selectionAreas: selectionAreas,
345
370
  currentMatcher: currentMatcher,
346
371
  rows: rows,
@@ -351,9 +376,26 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
351
376
  // if one of the activeCellCoordinates is in a header position
352
377
 
353
378
 
354
- if (!activeKeys.current.includes('Shift') || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
379
+ if (keysPressedList.length < 2 && !(0, _handleMultipleKeys.includesShift)(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
355
380
  switch (key) {
381
+ // HOME
382
+ case 'Home':
383
+ {
384
+ handleHomeEndKey({
385
+ type: 'home'
386
+ });
387
+ break;
388
+ }
389
+
390
+ case 'End':
391
+ {
392
+ handleHomeEndKey({
393
+ type: 'end'
394
+ });
395
+ break;
396
+ }
356
397
  // Tab
398
+
357
399
  case 'Tab':
358
400
  {
359
401
  setSelectionAreas([]);
@@ -502,13 +544,35 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
502
544
  }
503
545
  }
504
546
  }
505
- }, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, removeCellSelections, selectionAreas]);
547
+ }, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList]);
506
548
 
507
549
  var startEditMode = function startEditMode() {
508
550
  setIsEditing(true);
509
551
  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;
510
552
  var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
511
553
  setCellEditorValue(activeCellValue);
554
+ cellEditorRulerRef.current.textContent = activeCellValue;
555
+ }; // Sets the initial placement of the cell editor cursor at the end of the text area
556
+ // this is not done for us by default in Safari
557
+
558
+
559
+ (0, _react.useEffect)(function () {
560
+ if (isEditing && !(previousState !== null && previousState !== void 0 && previousState.isEditing)) {
561
+ cellEditorRef.current.setSelectionRange(cellEditorRulerRef.current.textContent.length, cellEditorRulerRef.current.textContent.length);
562
+ cellEditorRef.current.focus();
563
+ }
564
+ }, [isEditing, previousState === null || previousState === void 0 ? void 0 : previousState.isEditing]);
565
+
566
+ var handleActiveCellClick = function handleActiveCellClick() {
567
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
568
+ 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;
569
+ handleRowColumnHeaderClick({
570
+ isKeyboard: false,
571
+ index: indexValue
572
+ });
573
+ }
574
+
575
+ return;
512
576
  }; // Go into edit mode if 'Enter' key is pressed on activeCellRef
513
577
 
514
578
 
@@ -521,41 +585,51 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
521
585
  }
522
586
 
523
587
  if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
524
- var handleHeaderCellProps = {
525
- activeCellCoordinates: activeCellCoordinates,
526
- rows: rows,
527
- columns: columns,
528
- setActiveCellCoordinates: setActiveCellCoordinates,
529
- setCurrentMatcher: setCurrentMatcher,
530
- setSelectionAreas: setSelectionAreas,
531
- spreadsheetRef: spreadsheetRef,
588
+ handleRowColumnHeaderClick({
532
589
  isKeyboard: true
533
- }; // Select an entire column
534
-
535
- if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
536
- (0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
537
- type: 'column'
538
- }, handleHeaderCellProps));
539
- } // Select an entire row
540
-
541
-
542
- if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
543
- (0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
544
- type: 'row'
545
- }, handleHeaderCellProps));
546
- }
590
+ });
547
591
  }
548
592
  }
593
+ };
594
+
595
+ var handleRowColumnHeaderClick = function handleRowColumnHeaderClick(_ref5) {
596
+ var isKeyboard = _ref5.isKeyboard,
597
+ _ref5$index = _ref5.index,
598
+ index = _ref5$index === void 0 ? null : _ref5$index;
599
+ var handleHeaderCellProps = {
600
+ activeCellCoordinates: activeCellCoordinates,
601
+ rows: rows,
602
+ columns: columns,
603
+ setActiveCellCoordinates: setActiveCellCoordinates,
604
+ setCurrentMatcher: setCurrentMatcher,
605
+ setSelectionAreas: setSelectionAreas,
606
+ spreadsheetRef: spreadsheetRef,
607
+ isKeyboard: isKeyboard,
608
+ setSelectionAreaData: setSelectionAreaData,
609
+ index: index
610
+ }; // Select an entire column
611
+
612
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
613
+ (0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
614
+ type: 'column'
615
+ }, handleHeaderCellProps));
616
+ } // Select an entire row
617
+
618
+
619
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
620
+ (0, _handleHeaderCellSelection.handleHeaderCellSelection)(_objectSpread({
621
+ type: 'row'
622
+ }, handleHeaderCellProps));
623
+ }
549
624
  }; // Go into edit mode if double click is detected on activeCellRef
550
625
 
551
626
 
552
627
  var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
553
628
  startEditMode();
554
- }; // Update the data
555
-
629
+ };
556
630
 
557
- var handleEditSubmit = function handleEditSubmit(event) {
558
- var key = event.key;
631
+ var updateSelectionAreaOnCellEditSubmit = function updateSelectionAreaOnCellEditSubmit(_ref6) {
632
+ var type = _ref6.type;
559
633
 
560
634
  var submitEditChanges = function submitEditChanges() {
561
635
  var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
@@ -564,8 +638,33 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
564
638
  updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
565
639
  };
566
640
 
641
+ (0, _removeCellSelections.removeCellSelections)({
642
+ spreadsheetRef: spreadsheetRef
643
+ });
644
+ submitEditChanges();
645
+ var tempMatcher = (0, _uuidv.default)();
646
+ var newSelectionArea = {
647
+ row: type === 'Enter' ? activeCellCoordinates.row === rows.length - 1 ? activeCellCoordinates.row : activeCellCoordinates.row + 1 : activeCellCoordinates.row,
648
+ column: type === 'Tab' ? activeCellCoordinates.column === columns.length - 1 ? activeCellCoordinates.column : activeCellCoordinates.column + 1 : activeCellCoordinates.column
649
+ };
650
+ setSelectionAreas([{
651
+ point1: newSelectionArea,
652
+ point2: newSelectionArea,
653
+ matcher: tempMatcher,
654
+ areaCreated: false
655
+ }]);
656
+ setCurrentMatcher(tempMatcher);
657
+ cellEditorRulerRef.current.textContent = '';
658
+ }; // Update the data
659
+
660
+
661
+ var handleEditSubmit = function handleEditSubmit(event) {
662
+ var key = event.key;
663
+
567
664
  if (key === 'Enter') {
568
- submitEditChanges();
665
+ updateSelectionAreaOnCellEditSubmit({
666
+ type: 'Enter'
667
+ });
569
668
  setActiveCellCoordinates(function (prev) {
570
669
  return _objectSpread(_objectSpread({}, prev), {}, {
571
670
  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
@@ -576,7 +675,9 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
576
675
 
577
676
  if (key === 'Tab') {
578
677
  event.preventDefault();
579
- submitEditChanges();
678
+ updateSelectionAreaOnCellEditSubmit({
679
+ type: 'Tab'
680
+ });
580
681
  setActiveCellCoordinates(function (prev) {
581
682
  return _objectSpread(_objectSpread({}, prev), {}, {
582
683
  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
@@ -586,44 +687,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
586
687
  }
587
688
 
588
689
  return;
589
- }; // Only update if there are cell selection areas
590
- // Find point object that matches currentMatcher and remove the second point
591
- // because hovering over the active cell while clicking and holding should
592
- // remove the previously existing selection area
593
-
594
-
595
- var handleActiveCellMouseEnterCallback = (0, _react.useCallback)(function (areas, clickHold) {
596
- var freshMatcherValue = currentMatcherRef.current;
597
-
598
- if (!freshMatcherValue) {
599
- return;
600
- }
601
-
602
- if (areas && areas.length && clickHold && freshMatcherValue) {
603
- setSelectionAreas(function (prev) {
604
- var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
605
- var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
606
- return item.matcher === freshMatcherValue;
607
- });
608
-
609
- if (indexOfItemToUpdate === -1) {
610
- return prev;
611
- }
612
-
613
- if ((0, _typeof2.default)(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
614
- selectionAreaClone[indexOfItemToUpdate].point2 = null;
615
- selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
616
- removeCellSelections({
617
- matcher: freshMatcherValue,
618
- spreadsheetRef: spreadsheetRef
619
- });
620
- return selectionAreaClone;
621
- }
690
+ };
622
691
 
623
- return prev;
624
- });
625
- }
626
- }, [spreadsheetRef, removeCellSelections]);
627
692
  (0, _react.useEffect)(function () {
628
693
  if (isEditing) {
629
694
  var _rows$activeCellCoord, _cellProps$column, _cellEditorRef$curren;
@@ -636,57 +701,70 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
636
701
  cellEditorRef.current.style.display = 'block';
637
702
  cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
638
703
  cellEditorRef.current.style.height = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height;
639
- cellEditorRef.current.style.paddingTop = "".concat((parseInt(activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height) - 16) / 2, "px"); // calculate paddingTop based on cellHeight which could be variable depending on the cellSize prop
704
+ 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
640
705
 
641
706
  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';
642
707
  (_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 ? void 0 : _cellEditorRef$curren.focus();
708
+ var rulerWidth = cellEditorRulerRef.current.offsetWidth;
709
+ var cellWidth = activeCellRef.current.offsetWidth;
710
+
711
+ if (rulerWidth >= cellWidth) {
712
+ var widthMultiplier = Math.floor(rulerWidth / cellWidth) + 1;
713
+ var startingColumnPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column;
714
+ var startingRowPosition = activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row;
715
+ var totalColumns = columns.length;
716
+ var totalRows = rows.length;
717
+ var totalMultiplierPossible = totalColumns - startingColumnPosition;
718
+ var totalCellEditorMaxHeight = (totalRows - startingRowPosition) * defaultColumn.rowHeight;
719
+ cellEditorRef.current.style.maxHeight = (0, _layout.px)(totalCellEditorMaxHeight);
720
+ cellEditorRef.current.style.width = (0, _layout.px)(cellWidth * (widthMultiplier <= totalMultiplierPossible ? widthMultiplier : totalMultiplierPossible));
721
+ cellEditorRef.current.style.height = (0, _layout.px)(cellEditorRef.current.scrollHeight); // adds dynamic height to cell editor
722
+ // Cell editor has reached max height, we need to add the scrolling back.
723
+ // We also need to subtract 1 to account for the fact that the cell editor
724
+ // is placed one pixel below the cell being edited to account for the border
725
+
726
+ if (cellEditorRef.current.clientHeight === totalCellEditorMaxHeight - 1) {
727
+ cellEditorRef.current.style.overflow = 'auto';
728
+ } else {
729
+ cellEditorRef.current.style.overflow = 'hidden';
730
+ }
731
+ }
643
732
  }
644
733
 
645
734
  if (!isEditing) {
735
+ cellEditorRef.current.style.overflow = 'hidden';
646
736
  cellEditorRef.current.style.display = 'none';
647
737
  cellEditorRef.current.blur();
648
738
  activeCellRef.current.focus();
649
739
  }
650
- }, [isEditing, activeCellCoordinates, rows]);
651
-
652
- var handleKeyUp = function handleKeyUp(event) {
653
- var _activeKeys$current3;
654
-
655
- var key = event.key; // Remove key from active keys array on key up
656
-
657
- if ((_activeKeys$current3 = activeKeys.current) !== null && _activeKeys$current3 !== void 0 && _activeKeys$current3.includes(key)) {
658
- var activeKeysClone = (0, _toConsumableArray2.default)(activeKeys.current);
659
- var filteredKeysClone = activeKeysClone.filter(function (item) {
660
- return item !== key;
661
- });
662
- activeKeys.current = filteredKeysClone;
663
- }
664
- };
665
-
740
+ }, [isEditing, activeCellCoordinates, rows, cellEditorValue, columns.length, defaultColumn]);
666
741
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, rest, getTableProps(), (0, _devtools.getDevtoolsProps)(componentName), {
667
- className: (0, _classnames.default)(blockClass, className, (0, _defineProperty2.default)({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
742
+ className: (0, _classnames.default)(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
668
743
  ref: spreadsheetRef,
669
744
  role: "grid",
670
745
  tabIndex: 0,
671
746
  "aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
672
747
  "aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
673
748
  onKeyDown: handleKeyPress,
674
- onKeyUp: handleKeyUp,
675
749
  onFocus: function onFocus() {
676
750
  return setContainerHasFocus(true);
677
751
  }
678
- }), /*#__PURE__*/_react.default.createElement(_DataSpreadsheetHeader.DataSpreadsheetHeader, {
752
+ }), /*#__PURE__*/_react.default.createElement("div", {
753
+ ref: multiKeyTrackingRef
754
+ }, /*#__PURE__*/_react.default.createElement(_DataSpreadsheetHeader.DataSpreadsheetHeader, {
679
755
  ref: spreadsheetRef,
680
756
  activeCellCoordinates: activeCellCoordinates,
681
- cellSizeValue: cellSizeValue,
757
+ cellSize: cellSize,
682
758
  columns: columns,
683
759
  defaultColumn: defaultColumn,
684
760
  headerGroups: headerGroups,
685
761
  rows: rows,
762
+ scrollBarSize: scrollBarSize,
686
763
  selectionAreas: selectionAreas,
687
764
  setActiveCellCoordinates: setActiveCellCoordinates,
688
765
  setSelectionAreas: setSelectionAreas,
689
- setCurrentMatcher: setCurrentMatcher
766
+ setCurrentMatcher: setCurrentMatcher,
767
+ setSelectionAreaData: setSelectionAreaData
690
768
  }), /*#__PURE__*/_react.default.createElement(_DataSpreadsheetBody.DataSpreadsheetBody, {
691
769
  activeCellCoordinates: activeCellCoordinates,
692
770
  ref: spreadsheetRef,
@@ -698,34 +776,45 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
698
776
  selectionAreas: selectionAreas,
699
777
  setSelectionAreas: setSelectionAreas,
700
778
  cellSize: cellSize,
779
+ headerGroups: headerGroups,
701
780
  defaultColumn: defaultColumn,
702
781
  getTableBodyProps: getTableBodyProps,
782
+ onDataUpdate: onDataUpdate,
703
783
  onActiveCellChange: onActiveCellChange,
784
+ onSelectionAreaChange: onSelectionAreaChange,
704
785
  prepareRow: prepareRow,
705
786
  rows: rows,
787
+ selectionAreaData: selectionAreaData,
788
+ setSelectionAreaData: setSelectionAreaData,
706
789
  setActiveCellCoordinates: setActiveCellCoordinates,
707
790
  scrollBarSize: scrollBarSize,
708
791
  totalColumnsWidth: totalColumnsWidth,
709
792
  id: id,
710
- columns: columns
793
+ columns: columns,
794
+ defaultEmptyRowCount: defaultEmptyRowCount
711
795
  }), /*#__PURE__*/_react.default.createElement("button", {
796
+ onClick: handleActiveCellClick,
712
797
  onKeyDown: handleActiveCellKeyDown,
713
- onMouseEnter: handleActiveCellMouseEnter,
714
798
  onDoubleClick: handleActiveCellDoubleClick,
715
799
  ref: activeCellRef,
716
800
  className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight")),
717
801
  type: "button"
718
- }), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextArea, {
802
+ }, activeCellContent), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextArea, {
719
803
  value: cellEditorValue,
720
804
  onKeyDown: handleEditSubmit,
721
805
  onChange: function onChange(event) {
722
- return setCellEditorValue(event.target.value);
806
+ setCellEditorValue(event.target.value);
807
+ cellEditorRulerRef.current.textContent = event.target.value;
723
808
  },
724
809
  ref: cellEditorRef,
725
810
  labelText: "",
726
811
  "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,
727
812
  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))
728
- }));
813
+ }), /*#__PURE__*/_react.default.createElement("pre", {
814
+ "aria-hidden": true,
815
+ ref: cellEditorRulerRef,
816
+ className: "".concat(blockClass, "__cell-editor-ruler")
817
+ })));
729
818
  }); // Return a placeholder if not released and not enabled by feature flag
730
819
 
731
820
 
@@ -763,6 +852,11 @@ DataSpreadsheet.propTypes = {
763
852
  */
764
853
  data: _propTypes.default.arrayOf(_propTypes.default.shape),
765
854
 
855
+ /**
856
+ * Sets the number of empty rows to be created when there is no data provided
857
+ */
858
+ defaultEmptyRowCount: _propTypes.default.number,
859
+
766
860
  /**
767
861
  * The spreadsheet id
768
862
  */
@@ -776,7 +870,12 @@ DataSpreadsheet.propTypes = {
776
870
  /**
777
871
  * The setter fn for the data prop
778
872
  */
779
- onDataUpdate: _propTypes.default.func
873
+ onDataUpdate: _propTypes.default.func,
874
+
875
+ /**
876
+ * The event handler that is called when the selection area values change
877
+ */
878
+ onSelectionAreaChange: _propTypes.default.func
780
879
  /* TODO: add types and DocGen for all props. */
781
880
 
782
881
  };