@carbon/ibm-products 1.9.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. package/css/index-full-carbon.css +364 -5838
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +5 -5
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +68 -3430
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -3
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +185 -4098
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +5 -5
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +302 -4099
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +5 -5
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelect.js +98 -92
  18. package/es/components/AddSelect/AddSelectColumn.js +219 -8
  19. package/es/components/AddSelect/AddSelectList.js +5 -5
  20. package/es/components/AddSelect/AddSelectSidebar.js +3 -15
  21. package/es/components/AddSelect/add-select-utils.js +64 -0
  22. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -1
  23. package/es/components/ButtonMenu/ButtonMenu.js +12 -4
  24. package/es/components/DataSpreadsheet/DataSpreadsheet.js +480 -182
  25. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +124 -81
  26. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +74 -8
  27. package/es/components/DataSpreadsheet/hooks/useMoveActiveCell.js +27 -0
  28. package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +28 -0
  29. package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +41 -0
  30. package/es/components/DataSpreadsheet/utils/checkActiveHeaderCell.js +34 -0
  31. package/es/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js} +21 -8
  32. package/es/components/DataSpreadsheet/{createCellSelectionArea.js → utils/createCellSelectionArea.js} +8 -4
  33. package/es/components/DataSpreadsheet/{generateData.js → utils/generateData.js} +6 -0
  34. package/es/components/DataSpreadsheet/{getCellSize.js → utils/getCellSize.js} +0 -0
  35. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +46 -0
  36. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +82 -0
  37. package/es/components/DataSpreadsheet/utils/removeCellSelections.js +30 -0
  38. package/es/components/InlineEdit/InlineEdit.js +58 -27
  39. package/es/components/OptionsTile/OptionsTile.js +31 -21
  40. package/es/components/OptionsTile/index.js +1 -1
  41. package/es/components/PageHeader/PageHeader.js +26 -15
  42. package/es/components/PageHeader/PageHeaderTitle.js +2 -1
  43. package/es/components/PageHeader/PageHeaderUtils.js +24 -29
  44. package/es/components/TagSet/TagSet.js +12 -3
  45. package/es/components/UserProfileImage/UserProfileImage.js +2 -1
  46. package/es/components/index.js +0 -1
  47. package/es/global/js/package-settings.js +1 -2
  48. package/lib/components/AddSelect/AddSelect.js +101 -92
  49. package/lib/components/AddSelect/AddSelectColumn.js +232 -13
  50. package/lib/components/AddSelect/AddSelectList.js +5 -5
  51. package/lib/components/AddSelect/AddSelectSidebar.js +9 -15
  52. package/lib/components/AddSelect/add-select-utils.js +78 -0
  53. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -1
  54. package/lib/components/ButtonMenu/ButtonMenu.js +12 -4
  55. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +490 -186
  56. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +127 -82
  57. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +82 -9
  58. package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.js +37 -0
  59. package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +39 -0
  60. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +52 -0
  61. package/lib/components/DataSpreadsheet/utils/checkActiveHeaderCell.js +45 -0
  62. package/lib/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js} +21 -8
  63. package/lib/components/DataSpreadsheet/{createCellSelectionArea.js → utils/createCellSelectionArea.js} +8 -4
  64. package/lib/components/DataSpreadsheet/{generateData.js → utils/generateData.js} +6 -0
  65. package/lib/components/DataSpreadsheet/{getCellSize.js → utils/getCellSize.js} +0 -0
  66. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +59 -0
  67. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +92 -0
  68. package/lib/components/DataSpreadsheet/utils/removeCellSelections.js +41 -0
  69. package/lib/components/InlineEdit/InlineEdit.js +60 -28
  70. package/lib/components/OptionsTile/OptionsTile.js +30 -20
  71. package/lib/components/PageHeader/PageHeader.js +25 -15
  72. package/lib/components/PageHeader/PageHeaderTitle.js +2 -1
  73. package/lib/components/PageHeader/PageHeaderUtils.js +24 -29
  74. package/lib/components/TagSet/TagSet.js +13 -3
  75. package/lib/components/UserProfileImage/UserProfileImage.js +2 -1
  76. package/lib/components/index.js +0 -8
  77. package/lib/global/js/package-settings.js +1 -2
  78. package/package.json +17 -17
  79. package/scss/components/AddSelect/_add-select.scss +47 -14
  80. package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +7 -3
  81. package/scss/components/CreateInfluencer/_create-influencer.scss +2 -0
  82. package/scss/components/CreateModal/_create-modal.scss +1 -0
  83. package/scss/components/CreateSidePanel/_create-side-panel.scss +1 -1
  84. package/scss/components/CreateSidePanel/_storybook-styles.scss +1 -1
  85. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  86. package/scss/components/CreateTearsheetNarrow/_create-tearsheet-narrow.scss +1 -0
  87. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +25 -7
  88. package/scss/components/EditSidePanel/_edit-side-panel.scss +9 -0
  89. package/scss/components/EditSidePanel/_storybook-styles.scss +1 -1
  90. package/scss/components/InlineEdit/_inline-edit.scss +46 -39
  91. package/scss/components/InlineEdit/_storybook-styles.scss +1 -0
  92. package/scss/components/ModifiedTabs/_modified-tabs.scss +5 -0
  93. package/scss/components/NotificationsPanel/_notifications-panel.scss +10 -3
  94. package/scss/components/OptionsTile/_index.scss +1 -1
  95. package/scss/components/OptionsTile/_options-tile.scss +17 -17
  96. package/scss/components/OptionsTile/_storybook-styles.scss +4 -4
  97. package/scss/components/PageHeader/_page-header.scss +5 -2
  98. package/scss/components/SidePanel/_side-panel.scss +19 -12
  99. package/scss/components/StatusIcon/_status-icon.scss +1 -0
  100. package/scss/components/Tearsheet/_tearsheet.scss +4 -0
  101. package/scss/components/UserProfileImage/_user-profile-image.scss +9 -0
  102. package/scss/components/WebTerminal/_web-terminal.scss +2 -0
  103. package/scss/components/_index.scss +0 -1
  104. package/es/components/LoadingBar/LoadingBar.js +0 -156
  105. package/es/components/LoadingBar/index.js +0 -7
  106. package/lib/components/LoadingBar/LoadingBar.js +0 -170
  107. package/lib/components/LoadingBar/index.js +0 -13
  108. package/scss/components/LoadingBar/_index.scss +0 -8
  109. package/scss/components/LoadingBar/_loading-bar.scss +0 -211
  110. package/scss/components/LoadingBar/_storybook-styles.scss +0 -14
@@ -1,8 +1,10 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
3
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
5
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
6
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["cellSize", "className", "columns", "data", "id", "onActiveCellChange"];
7
+ var _excluded = ["cellSize", "className", "columns", "data", "onDataUpdate", "id", "onActiveCellChange"];
6
8
 
7
9
  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; }
8
10
 
@@ -15,19 +17,28 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
15
17
  * LICENSE file in the root directory of this source tree.
16
18
  */
17
19
  // Import portions of React that are needed.
18
- import React, { useMemo, useRef, useEffect, useState, useCallback } from 'react';
20
+ import React, { useMemo, useRef, useState, useCallback, useEffect } from 'react';
19
21
  import { useBlockLayout, useTable } from 'react-table'; // Other standard imports.
20
22
 
21
23
  import PropTypes from 'prop-types';
22
24
  import cx from 'classnames';
23
- import { getDevtoolsProps } from '../../global/js/utils/devtools';
25
+ import { TextArea } from 'carbon-components-react';
24
26
  import { pkg } from '../../settings';
25
- import { getScrollbarWidth } from '../../global/js/utils/getScrollbarWidth';
26
27
  import { DataSpreadsheetBody } from './DataSpreadsheetBody';
27
- import { getCellSize } from './getCellSize';
28
28
  import { DataSpreadsheetHeader } from './DataSpreadsheetHeader';
29
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
30
+ import { getScrollbarWidth } from '../../global/js/utils/getScrollbarWidth';
29
31
  import { useActiveElement } from '../../global/js/hooks';
30
- import { createActiveCellFn } from './createActiveCellFn'; // cspell:words rowcount colcount
32
+ import { deepCloneObject } from '../../global/js/utils/deepCloneObject';
33
+ import { usePreviousValue } from '../../global/js/hooks';
34
+ import uuidv4 from '../../global/js/utils/uuidv4';
35
+ import { useResetSpreadsheetFocus } from './hooks/useResetSpreadsheetFocus';
36
+ import { useSpreadsheetOutsideClick } from './hooks/useSpreadsheetOutsideClick';
37
+ import { useMoveActiveCell } from './hooks/useMoveActiveCell';
38
+ import { createActiveCellFn } from './utils/createActiveCellFn';
39
+ import { getCellSize } from './utils/getCellSize';
40
+ import { handleMultipleKeys } from './utils/handleMultipleKeys';
41
+ import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection'; // cspell:words rowcount colcount
31
42
  // The block part of our conventional BEM class names (blockClass__E--M).
32
43
 
33
44
  var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
@@ -36,7 +47,8 @@ var componentName = 'DataSpreadsheet'; // Default values for props
36
47
  var defaults = {
37
48
  cellSize: 'standard',
38
49
  columns: Object.freeze([]),
39
- data: Object.freeze([])
50
+ data: Object.freeze([]),
51
+ onDataUpdate: Object.freeze(function () {})
40
52
  };
41
53
  /**
42
54
  * DataSpreadsheet: used to organize and display large amounts of structured data, separated by columns and rows in a grid-like format.
@@ -50,10 +62,14 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
50
62
  columns = _ref$columns === void 0 ? defaults.columns : _ref$columns,
51
63
  _ref$data = _ref.data,
52
64
  data = _ref$data === void 0 ? defaults.data : _ref$data,
65
+ _ref$onDataUpdate = _ref.onDataUpdate,
66
+ onDataUpdate = _ref$onDataUpdate === void 0 ? defaults.onDataUpdate : _ref$onDataUpdate,
53
67
  id = _ref.id,
54
68
  onActiveCellChange = _ref.onActiveCellChange,
55
69
  rest = _objectWithoutProperties(_ref, _excluded);
56
70
 
71
+ var localRef = useRef();
72
+ var spreadsheetRef = ref || localRef;
57
73
  var focusedElement = useActiveElement();
58
74
 
59
75
  var _useState = useState(false),
@@ -76,12 +92,29 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
76
92
  clickAndHoldActive = _useState8[0],
77
93
  setClickAndHoldActive = _useState8[1];
78
94
 
79
- var _useState9 = useState(null),
95
+ var _useState9 = useState(''),
80
96
  _useState10 = _slicedToArray(_useState9, 2),
81
97
  currentMatcher = _useState10[0],
82
98
  setCurrentMatcher = _useState10[1];
83
99
 
100
+ var _useState11 = useState(false),
101
+ _useState12 = _slicedToArray(_useState11, 2),
102
+ isEditing = _useState12[0],
103
+ setIsEditing = _useState12[1];
104
+
105
+ var _useState13 = useState(''),
106
+ _useState14 = _slicedToArray(_useState13, 2),
107
+ cellEditorValue = _useState14[0],
108
+ setCellEditorValue = _useState14[1];
109
+
110
+ var previousState = usePreviousValue({
111
+ activeCellCoordinates: activeCellCoordinates
112
+ });
84
113
  var cellSizeValue = getCellSize(cellSize);
114
+ var cellEditorRef = useRef();
115
+ var currentMatcherRef = useRef();
116
+ var activeKeys = useRef([]);
117
+ var activeCellRef = useRef();
85
118
  var defaultColumn = useMemo(function () {
86
119
  return {
87
120
  width: 150,
@@ -103,53 +136,63 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
103
136
  headerGroups = _useTable.headerGroups,
104
137
  rows = _useTable.rows,
105
138
  totalColumnsWidth = _useTable.totalColumnsWidth,
106
- prepareRow = _useTable.prepareRow; // Reset everything when spreadsheet loses focus
139
+ prepareRow = _useTable.prepareRow; // Update the spreadsheet data after editing a cell
107
140
 
108
141
 
109
- useEffect(function () {
110
- if (!focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
111
- setContainerHasFocus(false);
112
- removeActiveCell();
113
- }
142
+ var updateData = useCallback(function (rowIndex, columnId) {
143
+ onDataUpdate(function (prev) {
144
+ return prev.map(function (row, index) {
145
+ if (index === rowIndex) {
146
+ return _objectSpread(_objectSpread({}, prev[rowIndex]), {}, _defineProperty({}, columnId, cellEditorValue));
147
+ }
114
148
 
115
- if (focusedElement.classList.contains(blockClass) || focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
116
- setContainerHasFocus(true);
117
- }
118
- }, [focusedElement, removeActiveCell]); // Removes the active cell element
149
+ return row;
150
+ });
151
+ });
152
+ }, [cellEditorValue, onDataUpdate]); // Removes the active cell element
119
153
 
120
154
  var removeActiveCell = useCallback(function () {
121
155
  var activeCellHighlight = spreadsheetRef.current.querySelector(".".concat(blockClass, "__active-cell--highlight"));
122
156
 
123
157
  if (activeCellHighlight) {
124
- activeCellHighlight.remove();
158
+ activeCellHighlight.style.display = 'none';
125
159
  }
126
- }, [spreadsheetRef]); // Removes the cell selection elements
160
+ }, [spreadsheetRef]);
161
+ var removeCellEditor = useCallback(function () {
162
+ setCellEditorValue('');
163
+ setIsEditing(false);
164
+ cellEditorRef.current.style.display = 'none';
165
+ }, []); // Removes the cell selection elements
166
+
167
+ var removeCellSelections = useCallback(function (matcher) {
168
+ if (matcher && typeof matcher === 'string') {
169
+ var selectionToRemove = spreadsheetRef.current.querySelector("[data-matcher-id=\"".concat(matcher, "\"]"));
170
+
171
+ if (selectionToRemove) {
172
+ selectionToRemove.remove();
173
+ }
174
+ } else {
175
+ var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
127
176
 
128
- var removeCellSelections = useCallback(function () {
129
- var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
130
- Array.from(cellSelections).forEach(function (element) {
131
- return element.remove();
132
- });
133
- }, [spreadsheetRef]); // Click outside useEffect
177
+ _toConsumableArray(cellSelections).forEach(function (element) {
178
+ return element.remove();
179
+ });
180
+ }
181
+ }, [spreadsheetRef]); // Remove cell editor if the active cell coordinates change and save with new cell data, this will
182
+ // happen if you click on another cell while isEditing is true
134
183
 
135
184
  useEffect(function () {
136
- var handleOutsideClick = function handleOutsideClick(event) {
137
- if (!spreadsheetRef.current || spreadsheetRef.current.contains(event.target) || event.target.classList.contains("".concat(blockClass, "__active-cell--highlight"))) {
138
- return;
139
- }
140
-
141
- setSelectionAreas([]);
142
- removeActiveCell();
143
- removeCellSelections();
144
- setContainerHasFocus(false);
145
- setActiveCellCoordinates(null);
146
- };
185
+ var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
147
186
 
148
- document.addEventListener('click', handleOutsideClick);
149
- return function () {
150
- document.removeEventListener('click', handleOutsideClick);
151
- };
152
- }, [spreadsheetRef, removeActiveCell, removeCellSelections]);
187
+ 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)) && isEditing) {
188
+ var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
189
+ removeCellEditor();
190
+ updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
191
+ }
192
+ }, [activeCellCoordinates, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, updateData, rows, isEditing, removeCellEditor]);
193
+ var handleActiveCellMouseEnter = useCallback(function () {
194
+ handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
195
+ }, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
153
196
  var createActiveCell = useCallback(function (_ref2) {
154
197
  var placementElement = _ref2.placementElement,
155
198
  coords = _ref2.coords,
@@ -157,16 +200,45 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
157
200
  addToHeader = _ref2$addToHeader === void 0 ? false : _ref2$addToHeader;
158
201
  var activeCellFullData = typeof (coords === null || coords === void 0 ? void 0 : coords.column) === 'number' && typeof (coords === null || coords === void 0 ? void 0 : coords.row) === 'number' ? rows[coords === null || coords === void 0 ? void 0 : coords.row].cells[coords === null || coords === void 0 ? void 0 : coords.column] : null;
159
202
  var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[coords === null || coords === void 0 ? void 0 : coords.column] : null;
160
- createActiveCellFn({
161
- placementElement: placementElement,
162
- coords: coords,
163
- addToHeader: addToHeader,
164
- contextRef: spreadsheetRef,
165
- blockClass: blockClass,
166
- onActiveCellChange: onActiveCellChange,
167
- activeCellValue: activeCellValue
168
- });
169
- }, [spreadsheetRef, rows, onActiveCellChange]);
203
+ var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates; // Only create an active cell if the activeCellCoordinates have changed
204
+
205
+ if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (coords === null || coords === void 0 ? void 0 : coords.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (coords === null || coords === void 0 ? void 0 : coords.column)) {
206
+ createActiveCellFn({
207
+ placementElement: placementElement,
208
+ coords: coords,
209
+ addToHeader: addToHeader,
210
+ contextRef: spreadsheetRef,
211
+ blockClass: blockClass,
212
+ onActiveCellChange: onActiveCellChange,
213
+ activeCellValue: activeCellValue,
214
+ activeCellRef: activeCellRef,
215
+ cellEditorRef: cellEditorRef,
216
+ defaultColumn: defaultColumn
217
+ });
218
+ }
219
+ }, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
220
+ useResetSpreadsheetFocus({
221
+ activeKeys: activeKeys,
222
+ focusedElement: focusedElement,
223
+ removeActiveCell: removeActiveCell,
224
+ setContainerHasFocus: setContainerHasFocus
225
+ });
226
+ useSpreadsheetOutsideClick({
227
+ spreadsheetRef: spreadsheetRef,
228
+ setActiveCellCoordinates: setActiveCellCoordinates,
229
+ setSelectionAreas: setSelectionAreas,
230
+ removeActiveCell: removeActiveCell,
231
+ removeCellSelections: removeCellSelections,
232
+ setContainerHasFocus: setContainerHasFocus,
233
+ activeKeys: activeKeys,
234
+ removeCellEditor: removeCellEditor
235
+ });
236
+ useMoveActiveCell({
237
+ spreadsheetRef: spreadsheetRef,
238
+ activeCellCoordinates: activeCellCoordinates,
239
+ containerHasFocus: containerHasFocus,
240
+ createActiveCell: createActiveCell
241
+ });
170
242
  var handleInitialArrowPress = useCallback(function () {
171
243
  // If activeCellCoordinates is null then we need to set an initial value
172
244
  // which will place the activeCell on the select all cell/button
@@ -179,198 +251,390 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
179
251
 
180
252
  return;
181
253
  }, [activeCellCoordinates]);
182
-
183
- var updateActiveCellCoordinates = function updateActiveCellCoordinates(_ref3) {
254
+ var updateActiveCellCoordinates = useCallback(function (_ref3) {
184
255
  var coords = _ref3.coords,
185
256
  updatedValue = _ref3.updatedValue;
186
- setActiveCellCoordinates(_objectSpread(_objectSpread({}, coords), updatedValue));
187
- };
188
257
 
258
+ var newActiveCell = _objectSpread(_objectSpread({}, coords), updatedValue);
259
+
260
+ setActiveCellCoordinates(newActiveCell); // Only run if the active cell is _not_ a header cell. This will add a point1 object
261
+ // to selectionAreas every time the active cell changes, allowing us to create cell
262
+ // selections using keyboard
263
+
264
+ if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header') {
265
+ var tempMatcher = uuidv4();
266
+ setSelectionAreas([{
267
+ point1: newActiveCell,
268
+ matcher: tempMatcher
269
+ }]);
270
+ setCurrentMatcher(tempMatcher);
271
+ }
272
+ }, []);
189
273
  var handleKeyPress = useCallback(function (event) {
190
- var keyCode = event.keyCode; // Command keys need to be returned as there is default browser behavior with these keys
274
+ var _activeKeys$current, _activeKeys$current2;
191
275
 
192
- if (keyCode === 91 || keyCode === 93) {
276
+ var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
277
+
278
+ if (key === 'Meta' || key === 'Control') {
193
279
  return;
194
280
  } // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
195
281
 
196
282
 
197
- if ([35, 36, 37, 38, 39, 40].indexOf(keyCode) > -1) {
283
+ if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing) {
198
284
  event.preventDefault();
199
- } // Clear out all cell selection areas if user uses any arrow key
285
+ }
200
286
 
287
+ if (['Tab'].indexOf(key) > -1 && isEditing) {
288
+ return;
289
+ } // Clear out all cell selection areas if user uses any arrow key, except if the shift key is being held
290
+
291
+
292
+ if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
293
+ if (isEditing) {
294
+ return;
295
+ }
201
296
 
202
- if ([37, 38, 39, 40].indexOf(keyCode) > -1) {
203
- if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length) {
297
+ if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
204
298
  setSelectionAreas([]);
205
- removeCellSelections();
299
+ removeCellSelections({
300
+ spreadsheetRef: spreadsheetRef
301
+ });
206
302
  }
207
- }
303
+ } // Update list of activeKeys
208
304
 
209
- switch (keyCode) {
210
- // Tab
211
- case 9:
212
- {
213
- setSelectionAreas([]);
214
- removeActiveCell();
215
- setContainerHasFocus(false);
216
- setActiveCellCoordinates(null);
217
- break;
218
- }
219
- // Left
220
305
 
221
- case 37:
222
- {
223
- handleInitialArrowPress();
306
+ if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
307
+ var activeClone = _toConsumableArray(activeKeys.current);
224
308
 
225
- var coordinatesClone = _objectSpread({}, activeCellCoordinates);
309
+ activeKeys.current = [].concat(_toConsumableArray(activeClone), [key]);
310
+ }
226
311
 
227
- if (coordinatesClone.column === 'header') {
228
- return;
312
+ if (((_activeKeys$current2 = activeKeys.current) === null || _activeKeys$current2 === void 0 ? void 0 : _activeKeys$current2.length) > 1) {
313
+ handleMultipleKeys({
314
+ activeKeys: activeKeys,
315
+ selectionAreas: selectionAreas,
316
+ currentMatcher: currentMatcher,
317
+ rows: rows,
318
+ setSelectionAreas: setSelectionAreas,
319
+ columns: columns
320
+ });
321
+ } // Allow arrow key navigation if there are less than two activeKeys OR
322
+ // if one of the activeCellCoordinates is in a header position
323
+
324
+
325
+ if (!activeKeys.current.includes('Shift') || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
326
+ switch (key) {
327
+ // Tab
328
+ case 'Tab':
329
+ {
330
+ setSelectionAreas([]);
331
+ removeActiveCell();
332
+ removeCellEditor();
333
+ setContainerHasFocus(false);
334
+ setActiveCellCoordinates(null);
335
+ break;
229
336
  }
337
+ // Left
338
+
339
+ case 'ArrowLeft':
340
+ {
341
+ handleInitialArrowPress();
342
+
343
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
344
+
345
+ if (coordinatesClone.column === 'header') {
346
+ return;
347
+ }
348
+
349
+ if (typeof coordinatesClone.column === 'number') {
350
+ if (coordinatesClone.column === 0) {
351
+ updateActiveCellCoordinates({
352
+ coords: coordinatesClone,
353
+ updatedValue: {
354
+ column: 'header'
355
+ }
356
+ });
357
+ return;
358
+ }
230
359
 
231
- if (typeof coordinatesClone.column === 'number') {
232
- if (coordinatesClone.column === 0) {
233
360
  updateActiveCellCoordinates({
234
361
  coords: coordinatesClone,
235
362
  updatedValue: {
236
- column: 'header'
363
+ column: coordinatesClone.column - 1
237
364
  }
238
365
  });
239
- return;
240
366
  }
241
367
 
242
- updateActiveCellCoordinates({
243
- coords: coordinatesClone,
244
- updatedValue: {
245
- column: coordinatesClone.column - 1
246
- }
247
- });
368
+ break;
248
369
  }
370
+ // Up
249
371
 
250
- break;
251
- }
252
- // Up
372
+ case 'ArrowUp':
373
+ {
374
+ handleInitialArrowPress();
253
375
 
254
- case 38:
255
- {
256
- handleInitialArrowPress();
376
+ var _coordinatesClone = _objectSpread({}, activeCellCoordinates);
257
377
 
258
- var _coordinatesClone = _objectSpread({}, activeCellCoordinates);
378
+ if (_coordinatesClone.row === 'header') {
379
+ return;
380
+ }
381
+
382
+ if (typeof _coordinatesClone.row === 'number') {
383
+ // set row back to header if we are at index 0
384
+ if (_coordinatesClone.row === 0) {
385
+ updateActiveCellCoordinates({
386
+ coords: _coordinatesClone,
387
+ updatedValue: {
388
+ row: 'header'
389
+ }
390
+ });
391
+ return;
392
+ } // if we are at any other index than 0, subtract 1 from current row index
259
393
 
260
- if (_coordinatesClone.row === 'header') {
261
- return;
262
- }
263
394
 
264
- if (typeof _coordinatesClone.row === 'number') {
265
- // set row back to header if we are at index 0
266
- if (_coordinatesClone.row === 0) {
267
395
  updateActiveCellCoordinates({
268
396
  coords: _coordinatesClone,
269
397
  updatedValue: {
270
- row: 'header'
398
+ row: _coordinatesClone.row - 1
271
399
  }
272
400
  });
273
- return;
274
- } // if we are at any other index than 0, subtract 1 from current row index
275
-
401
+ }
276
402
 
277
- updateActiveCellCoordinates({
278
- coords: _coordinatesClone,
279
- updatedValue: {
280
- row: _coordinatesClone.row - 1
281
- }
282
- });
403
+ break;
283
404
  }
405
+ // Right
284
406
 
285
- break;
286
- }
287
- // Right
407
+ case 'ArrowRight':
408
+ {
409
+ handleInitialArrowPress();
288
410
 
289
- case 39:
290
- {
291
- handleInitialArrowPress();
411
+ var _coordinatesClone2 = _objectSpread({}, activeCellCoordinates);
292
412
 
293
- var _coordinatesClone2 = _objectSpread({}, activeCellCoordinates);
413
+ if (_coordinatesClone2.column === 'header') {
414
+ updateActiveCellCoordinates({
415
+ coords: _coordinatesClone2,
416
+ updatedValue: {
417
+ column: 0
418
+ }
419
+ });
420
+ }
294
421
 
295
- if (_coordinatesClone2.column === 'header') {
296
- updateActiveCellCoordinates({
297
- coords: _coordinatesClone2,
298
- updatedValue: {
299
- column: 0
422
+ if (typeof _coordinatesClone2.column === 'number') {
423
+ // Prevent active cell coordinates from updating if the active
424
+ // cell is in the last column, ie we can't go any further to the right
425
+ if (columns.length - 1 === _coordinatesClone2.column) {
426
+ return;
300
427
  }
301
- });
302
- }
303
428
 
304
- if (typeof _coordinatesClone2.column === 'number') {
305
- // Prevent active cell coordinates from updating if the active
306
- // cell is in the last column, ie we can't go any further to the right
307
- if (columns.length - 1 === _coordinatesClone2.column) {
308
- return;
429
+ updateActiveCellCoordinates({
430
+ coords: _coordinatesClone2,
431
+ updatedValue: {
432
+ column: _coordinatesClone2.column + 1
433
+ }
434
+ });
309
435
  }
310
436
 
311
- updateActiveCellCoordinates({
312
- coords: _coordinatesClone2,
313
- updatedValue: {
314
- column: _coordinatesClone2.column + 1
315
- }
316
- });
437
+ break;
317
438
  }
439
+ // Down
318
440
 
319
- break;
320
- }
321
- // Down
441
+ case 'ArrowDown':
442
+ {
443
+ handleInitialArrowPress();
322
444
 
323
- case 40:
324
- {
325
- handleInitialArrowPress();
445
+ var _coordinatesClone3 = _objectSpread({}, activeCellCoordinates);
326
446
 
327
- var _coordinatesClone3 = _objectSpread({}, activeCellCoordinates);
447
+ if (_coordinatesClone3.row === 'header') {
448
+ updateActiveCellCoordinates({
449
+ coords: _coordinatesClone3,
450
+ updatedValue: {
451
+ row: 0
452
+ }
453
+ });
454
+ }
328
455
 
329
- if (_coordinatesClone3.row === 'header') {
330
- updateActiveCellCoordinates({
331
- coords: _coordinatesClone3,
332
- updatedValue: {
333
- row: 0
456
+ if (typeof _coordinatesClone3.row === 'number') {
457
+ // Prevent active cell coordinates from updating if the active
458
+ // cell is in the last row, ie we can't go any further down since
459
+ // we are in the last row
460
+ if (rows.length - 1 === _coordinatesClone3.row) {
461
+ return;
334
462
  }
335
- });
336
- }
337
463
 
338
- if (typeof _coordinatesClone3.row === 'number') {
339
- // Prevent active cell coordinates from updating if the active
340
- // cell is in the last row, ie we can't go any further down since
341
- // we are in the last row
342
- if (rows.length - 1 === _coordinatesClone3.row) {
343
- return;
464
+ updateActiveCellCoordinates({
465
+ coords: _coordinatesClone3,
466
+ updatedValue: {
467
+ row: _coordinatesClone3.row + 1
468
+ }
469
+ });
344
470
  }
345
471
 
346
- updateActiveCellCoordinates({
347
- coords: _coordinatesClone3,
348
- updatedValue: {
349
- row: _coordinatesClone3.row + 1
350
- }
351
- });
472
+ break;
352
473
  }
474
+ }
475
+ }
476
+ }, [updateActiveCellCoordinates, handleInitialArrowPress, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, isEditing, removeCellEditor, removeCellSelections, selectionAreas]);
477
+
478
+ var startEditMode = function startEditMode() {
479
+ setIsEditing(true);
480
+ 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;
481
+ var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column] : null;
482
+ setCellEditorValue(activeCellValue);
483
+ }; // Go into edit mode if 'Enter' key is pressed on activeCellRef
353
484
 
354
- break;
485
+
486
+ var handleActiveCellKeyDown = function handleActiveCellKeyDown(event) {
487
+ var key = event.key;
488
+
489
+ if (key === 'Enter') {
490
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) !== 'header') {
491
+ startEditMode();
492
+ }
493
+
494
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
495
+ var handleHeaderCellProps = {
496
+ activeCellCoordinates: activeCellCoordinates,
497
+ rows: rows,
498
+ columns: columns,
499
+ setActiveCellCoordinates: setActiveCellCoordinates,
500
+ setCurrentMatcher: setCurrentMatcher,
501
+ setSelectionAreas: setSelectionAreas,
502
+ spreadsheetRef: spreadsheetRef,
503
+ isKeyboard: true
504
+ }; // Select an entire column
505
+
506
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header') {
507
+ handleHeaderCellSelection(_objectSpread({
508
+ type: 'column'
509
+ }, handleHeaderCellProps));
510
+ } // Select an entire row
511
+
512
+
513
+ if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
514
+ handleHeaderCellSelection(_objectSpread({
515
+ type: 'row'
516
+ }, handleHeaderCellProps));
355
517
  }
518
+ }
519
+ }
520
+ }; // Go into edit mode if double click is detected on activeCellRef
521
+
522
+
523
+ var handleActiveCellDoubleClick = function handleActiveCellDoubleClick() {
524
+ startEditMode();
525
+ }; // Update the data
526
+
527
+
528
+ var handleEditSubmit = function handleEditSubmit(event) {
529
+ var key = event.key;
530
+
531
+ var submitEditChanges = function submitEditChanges() {
532
+ var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
533
+ var cellProps = rows[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row].cells[prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column];
534
+ removeCellEditor();
535
+ updateData(prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row, cellProps.column.id);
536
+ };
537
+
538
+ if (key === 'Enter') {
539
+ submitEditChanges();
540
+ setActiveCellCoordinates(function (prev) {
541
+ return _objectSpread(_objectSpread({}, prev), {}, {
542
+ 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
543
+
544
+ });
545
+ });
546
+ }
547
+
548
+ if (key === 'Tab') {
549
+ event.preventDefault();
550
+ submitEditChanges();
551
+ setActiveCellCoordinates(function (prev) {
552
+ return _objectSpread(_objectSpread({}, prev), {}, {
553
+ 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
554
+
555
+ });
556
+ });
557
+ }
558
+
559
+ return;
560
+ }; // Only update if there are cell selection areas
561
+ // Find point object that matches currentMatcher and remove the second point
562
+ // because hovering over the active cell while clicking and holding should
563
+ // remove the previously existing selection area
564
+
565
+
566
+ var handleActiveCellMouseEnterCallback = useCallback(function (areas, clickHold) {
567
+ var freshMatcherValue = currentMatcherRef.current;
568
+
569
+ if (!freshMatcherValue) {
570
+ return;
356
571
  }
357
- }, [handleInitialArrowPress, activeCellCoordinates, selectionAreas === null || selectionAreas === void 0 ? void 0 : selectionAreas.length, removeCellSelections, removeActiveCell, columns.length, rows.length]); // Adds active cell highlight to correct cell onKeyDown
358
572
 
573
+ if (areas && areas.length && clickHold && freshMatcherValue) {
574
+ setSelectionAreas(function (prev) {
575
+ var selectionAreaClone = deepCloneObject(prev);
576
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
577
+ return item.matcher === freshMatcherValue;
578
+ });
579
+
580
+ if (indexOfItemToUpdate === -1) {
581
+ return prev;
582
+ }
583
+
584
+ if (_typeof(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
585
+ selectionAreaClone[indexOfItemToUpdate].point2 = null;
586
+ selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
587
+ removeCellSelections({
588
+ matcher: freshMatcherValue,
589
+ spreadsheetRef: spreadsheetRef
590
+ });
591
+ return selectionAreaClone;
592
+ }
593
+
594
+ return prev;
595
+ });
596
+ }
597
+ }, [spreadsheetRef, removeCellSelections]);
359
598
  useEffect(function () {
360
- var activeCellPlacementElement = spreadsheetRef === null || spreadsheetRef === void 0 ? void 0 : spreadsheetRef.current.querySelector("[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, "\"]"));
361
- var shouldPlaceActiveCellInHeader = (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && true;
362
- var selectAllElement = spreadsheetRef === null || spreadsheetRef === void 0 ? void 0 : spreadsheetRef.current.querySelector("[data-row-index=\"header\"][data-column-index=\"header\"]");
363
-
364
- if (containerHasFocus) {
365
- createActiveCell({
366
- placementElement: activeCellCoordinates ? activeCellPlacementElement : selectAllElement,
367
- coords: activeCellCoordinates,
368
- addToHeader: shouldPlaceActiveCellInHeader
599
+ if (isEditing) {
600
+ var _rows$activeCellCoord, _cellProps$column, _cellEditorRef$curren;
601
+
602
+ 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];
603
+ var activeCellLeftPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.left;
604
+ var activeCellTopPosition = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.top;
605
+ cellEditorRef.current.style.left = activeCellLeftPosition;
606
+ cellEditorRef.current.style.top = activeCellTopPosition;
607
+ cellEditorRef.current.style.display = 'block';
608
+ cellEditorRef.current.style.width = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.width;
609
+ cellEditorRef.current.style.height = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current.style.height;
610
+ 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
611
+
612
+ 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';
613
+ (_cellEditorRef$curren = cellEditorRef.current) === null || _cellEditorRef$curren === void 0 ? void 0 : _cellEditorRef$curren.focus();
614
+ }
615
+
616
+ if (!isEditing) {
617
+ cellEditorRef.current.style.display = 'none';
618
+ cellEditorRef.current.blur();
619
+ activeCellRef.current.focus();
620
+ }
621
+ }, [isEditing, activeCellCoordinates, rows]);
622
+
623
+ var handleKeyUp = function handleKeyUp(event) {
624
+ var _activeKeys$current3;
625
+
626
+ var key = event.key; // Remove key from active keys array on key up
627
+
628
+ if ((_activeKeys$current3 = activeKeys.current) !== null && _activeKeys$current3 !== void 0 && _activeKeys$current3.includes(key)) {
629
+ var activeKeysClone = _toConsumableArray(activeKeys.current);
630
+
631
+ var filteredKeysClone = activeKeysClone.filter(function (item) {
632
+ return item !== key;
369
633
  });
634
+ activeKeys.current = filteredKeysClone;
370
635
  }
371
- }, [activeCellCoordinates, spreadsheetRef, createActiveCell, containerHasFocus]);
372
- var localRef = useRef();
373
- var spreadsheetRef = ref || localRef;
636
+ };
637
+
374
638
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, getTableProps(), getDevtoolsProps(componentName), {
375
639
  className: cx(blockClass, className, _defineProperty({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus)),
376
640
  ref: spreadsheetRef,
@@ -379,14 +643,25 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
379
643
  "aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
380
644
  "aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
381
645
  onKeyDown: handleKeyPress,
646
+ onKeyUp: handleKeyUp,
382
647
  onFocus: function onFocus() {
383
648
  return setContainerHasFocus(true);
384
649
  }
385
650
  }), /*#__PURE__*/React.createElement(DataSpreadsheetHeader, {
651
+ ref: spreadsheetRef,
652
+ activeCellCoordinates: activeCellCoordinates,
386
653
  cellSizeValue: cellSizeValue,
654
+ columns: columns,
387
655
  defaultColumn: defaultColumn,
388
- headerGroups: headerGroups
656
+ headerGroups: headerGroups,
657
+ rows: rows,
658
+ selectionAreas: selectionAreas,
659
+ setActiveCellCoordinates: setActiveCellCoordinates,
660
+ setSelectionAreas: setSelectionAreas,
661
+ setCurrentMatcher: setCurrentMatcher
389
662
  }), /*#__PURE__*/React.createElement(DataSpreadsheetBody, {
663
+ activeCellCoordinates: activeCellCoordinates,
664
+ ref: spreadsheetRef,
390
665
  clickAndHoldActive: clickAndHoldActive,
391
666
  setClickAndHoldActive: setClickAndHoldActive,
392
667
  currentMatcher: currentMatcher,
@@ -403,7 +678,25 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
403
678
  setActiveCellCoordinates: setActiveCellCoordinates,
404
679
  scrollBarSize: scrollBarSize,
405
680
  totalColumnsWidth: totalColumnsWidth,
406
- id: id
681
+ id: id,
682
+ columns: columns
683
+ }), /*#__PURE__*/React.createElement("button", {
684
+ onKeyDown: handleActiveCellKeyDown,
685
+ onMouseEnter: handleActiveCellMouseEnter,
686
+ onDoubleClick: handleActiveCellDoubleClick,
687
+ ref: activeCellRef,
688
+ className: cx("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight")),
689
+ type: "button"
690
+ }), /*#__PURE__*/React.createElement(TextArea, {
691
+ value: cellEditorValue,
692
+ onKeyDown: handleEditSubmit,
693
+ onChange: function onChange(event) {
694
+ return setCellEditorValue(event.target.value);
695
+ },
696
+ ref: cellEditorRef,
697
+ labelText: "",
698
+ "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,
699
+ className: cx("".concat(blockClass, "__cell-editor"), "".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__cell-editor--").concat(cellSize), _defineProperty({}, "".concat(blockClass, "__cell-editor--active"), isEditing))
407
700
  }));
408
701
  }); // Return a placeholder if not released and not enabled by feature flag
409
702
 
@@ -448,7 +741,12 @@ DataSpreadsheet.propTypes = {
448
741
  /**
449
742
  * The event handler that is called when the active cell changes
450
743
  */
451
- onActiveCellChange: PropTypes.func
744
+ onActiveCellChange: PropTypes.func,
745
+
746
+ /**
747
+ * The setter fn for the data prop
748
+ */
749
+ onDataUpdate: PropTypes.func
452
750
  /* TODO: add types and DocGen for all props. */
453
751
 
454
752
  };