@carbon/ibm-products 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/css/index-full-carbon.css +123 -5628
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +4 -4
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +45 -3424
  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 +91 -3894
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +4 -4
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +91 -3895
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +4 -4
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelect.js +11 -6
  18. package/es/components/AddSelect/AddSelectColumn.js +44 -7
  19. package/es/components/ButtonMenu/ButtonMenu.js +1 -1
  20. package/es/components/DataSpreadsheet/DataSpreadsheet.js +316 -133
  21. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +113 -69
  22. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +22 -5
  23. package/es/components/DataSpreadsheet/checkActiveHeaderCell.js +34 -0
  24. package/es/components/DataSpreadsheet/createActiveCellFn.js +3 -1
  25. package/es/components/InlineEdit/InlineEdit.js +11 -21
  26. package/es/components/OptionsTile/OptionsTile.js +11 -1
  27. package/es/components/PageHeader/PageHeader.js +48 -40
  28. package/es/components/PageHeader/PageHeaderUtils.js +3 -7
  29. package/es/components/TagSet/TagSet.js +12 -3
  30. package/es/components/UserProfileImage/UserProfileImage.js +2 -1
  31. package/lib/components/AddSelect/AddSelect.js +11 -6
  32. package/lib/components/AddSelect/AddSelectColumn.js +55 -13
  33. package/lib/components/ButtonMenu/ButtonMenu.js +1 -1
  34. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +317 -134
  35. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +112 -70
  36. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +24 -5
  37. package/lib/components/DataSpreadsheet/checkActiveHeaderCell.js +45 -0
  38. package/lib/components/DataSpreadsheet/createActiveCellFn.js +3 -1
  39. package/lib/components/InlineEdit/InlineEdit.js +10 -20
  40. package/lib/components/OptionsTile/OptionsTile.js +11 -1
  41. package/lib/components/PageHeader/PageHeader.js +47 -40
  42. package/lib/components/PageHeader/PageHeaderUtils.js +3 -7
  43. package/lib/components/TagSet/TagSet.js +13 -3
  44. package/lib/components/UserProfileImage/UserProfileImage.js +2 -1
  45. package/package.json +14 -14
  46. package/scss/components/AddSelect/_add-select.scss +27 -14
  47. package/scss/components/CreateInfluencer/_create-influencer.scss +2 -0
  48. package/scss/components/CreateModal/_create-modal.scss +1 -0
  49. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  50. package/scss/components/CreateTearsheetNarrow/_create-tearsheet-narrow.scss +1 -0
  51. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +12 -7
  52. package/scss/components/InlineEdit/_inline-edit.scss +20 -11
  53. package/scss/components/InlineEdit/_storybook-styles.scss +1 -0
  54. package/scss/components/LoadingBar/_loading-bar.scss +13 -0
  55. package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -0
  56. package/scss/components/PageHeader/_page-header.scss +2 -0
  57. package/scss/components/SidePanel/_side-panel.scss +11 -4
  58. package/scss/components/StatusIcon/_status-icon.scss +1 -0
  59. package/scss/components/UserProfileImage/_user-profile-image.scss +9 -0
  60. package/scss/components/WebTerminal/_web-terminal.scss +2 -0
@@ -1,5 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
2
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
5
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
6
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
7
  var _excluded = ["cellSize", "className", "columns", "data", "id", "onActiveCellChange"];
@@ -27,7 +29,10 @@ import { DataSpreadsheetBody } from './DataSpreadsheetBody';
27
29
  import { getCellSize } from './getCellSize';
28
30
  import { DataSpreadsheetHeader } from './DataSpreadsheetHeader';
29
31
  import { useActiveElement } from '../../global/js/hooks';
30
- import { createActiveCellFn } from './createActiveCellFn'; // cspell:words rowcount colcount
32
+ import { createActiveCellFn } from './createActiveCellFn';
33
+ import { deepCloneObject } from '../../global/js/utils/deepCloneObject';
34
+ import { usePreviousValue } from '../../global/js/hooks';
35
+ import uuidv4 from '../../global/js/utils/uuidv4'; // cspell:words rowcount colcount
31
36
  // The block part of our conventional BEM class names (blockClass__E--M).
32
37
 
33
38
  var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
@@ -76,12 +81,17 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
76
81
  clickAndHoldActive = _useState8[0],
77
82
  setClickAndHoldActive = _useState8[1];
78
83
 
79
- var _useState9 = useState(null),
84
+ var _useState9 = useState(''),
80
85
  _useState10 = _slicedToArray(_useState9, 2),
81
86
  currentMatcher = _useState10[0],
82
87
  setCurrentMatcher = _useState10[1];
83
88
 
89
+ var previousState = usePreviousValue({
90
+ activeCellCoordinates: activeCellCoordinates
91
+ });
84
92
  var cellSizeValue = getCellSize(cellSize);
93
+ var currentMatcherRef = useRef();
94
+ var activeKeys = useRef([]);
85
95
  var defaultColumn = useMemo(function () {
86
96
  return {
87
97
  width: 150,
@@ -110,6 +120,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
110
120
  if (!focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
111
121
  setContainerHasFocus(false);
112
122
  removeActiveCell();
123
+ activeKeys.current = [];
113
124
  }
114
125
 
115
126
  if (focusedElement.classList.contains(blockClass) || focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
@@ -125,11 +136,20 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
125
136
  }
126
137
  }, [spreadsheetRef]); // Removes the cell selection elements
127
138
 
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
- });
139
+ var removeCellSelections = useCallback(function (matcher) {
140
+ if (matcher && typeof matcher === 'string') {
141
+ var selectionToRemove = spreadsheetRef.current.querySelector("[data-matcher-id=\"".concat(matcher, "\"]"));
142
+
143
+ if (selectionToRemove) {
144
+ selectionToRemove.remove();
145
+ }
146
+ } else {
147
+ var cellSelections = spreadsheetRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
148
+
149
+ _toConsumableArray(cellSelections).forEach(function (element) {
150
+ return element.remove();
151
+ });
152
+ }
133
153
  }, [spreadsheetRef]); // Click outside useEffect
134
154
 
135
155
  useEffect(function () {
@@ -138,11 +158,12 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
138
158
  return;
139
159
  }
140
160
 
161
+ setActiveCellCoordinates(null);
141
162
  setSelectionAreas([]);
142
163
  removeActiveCell();
143
164
  removeCellSelections();
144
165
  setContainerHasFocus(false);
145
- setActiveCellCoordinates(null);
166
+ activeKeys.current = [];
146
167
  };
147
168
 
148
169
  document.addEventListener('click', handleOutsideClick);
@@ -157,16 +178,26 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
157
178
  addToHeader = _ref2$addToHeader === void 0 ? false : _ref2$addToHeader;
158
179
  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
180
  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]);
181
+
182
+ var handleActiveCellMouseEnter = function handleActiveCellMouseEnter() {
183
+ handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
184
+ };
185
+
186
+ var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates; // Only create an active cell if the activeCellCoordinates have changed
187
+
188
+ 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)) {
189
+ createActiveCellFn({
190
+ placementElement: placementElement,
191
+ coords: coords,
192
+ addToHeader: addToHeader,
193
+ contextRef: spreadsheetRef,
194
+ blockClass: blockClass,
195
+ onActiveCellChange: onActiveCellChange,
196
+ activeCellValue: activeCellValue,
197
+ handleActiveCellMouseEnter: handleActiveCellMouseEnter
198
+ });
199
+ }
200
+ }, [spreadsheetRef, rows, onActiveCellChange, clickAndHoldActive, handleActiveCellMouseEnterCallback, selectionAreas, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates]);
170
201
  var handleInitialArrowPress = useCallback(function () {
171
202
  // If activeCellCoordinates is null then we need to set an initial value
172
203
  // which will place the activeCell on the select all cell/button
@@ -179,182 +210,313 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
179
210
 
180
211
  return;
181
212
  }, [activeCellCoordinates]);
182
-
183
- var updateActiveCellCoordinates = function updateActiveCellCoordinates(_ref3) {
213
+ var updateActiveCellCoordinates = useCallback(function (_ref3) {
184
214
  var coords = _ref3.coords,
185
215
  updatedValue = _ref3.updatedValue;
186
- setActiveCellCoordinates(_objectSpread(_objectSpread({}, coords), updatedValue));
187
- };
188
216
 
217
+ var newActiveCell = _objectSpread(_objectSpread({}, coords), updatedValue);
218
+
219
+ setActiveCellCoordinates(newActiveCell); // Only run if the active cell is _not_ a header cell. This will add a point1 object
220
+ // to selectionAreas every time the active cell changes, allowing us to create cell
221
+ // selections using keyboard
222
+
223
+ if (newActiveCell.row !== 'header' && newActiveCell.column !== 'header') {
224
+ var tempMatcher = uuidv4();
225
+ setSelectionAreas([{
226
+ point1: newActiveCell,
227
+ matcher: tempMatcher
228
+ }]);
229
+ setCurrentMatcher(tempMatcher);
230
+ }
231
+ }, []);
232
+ var handleMultipleKeys = useCallback(function () {
233
+ var _selectionAreasClone$;
234
+
235
+ var activeKeyValues = activeKeys.current;
236
+ var selectionAreasClone = deepCloneObject(selectionAreas);
237
+ var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
238
+ return item.matcher === currentMatcher;
239
+ });
240
+ var pointToUpdate = (_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) !== null && _selectionAreasClone$ !== void 0 && _selectionAreasClone$.point2 ? selectionAreasClone[indexOfCurrentArea].point2 : selectionAreasClone[indexOfCurrentArea].point1; // Down + Shift
241
+
242
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowDown')) {
243
+ if (rows.length - 1 === pointToUpdate.row) {
244
+ return;
245
+ }
246
+
247
+ var newPoint = {
248
+ row: pointToUpdate.row + 1,
249
+ column: pointToUpdate.column
250
+ };
251
+ selectionAreasClone[indexOfCurrentArea].point2 = newPoint;
252
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
253
+ setSelectionAreas(selectionAreasClone);
254
+ } // Right + Shift
255
+
256
+
257
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowRight')) {
258
+ if (columns.length - 1 === pointToUpdate.column) {
259
+ return;
260
+ }
261
+
262
+ var _newPoint = {
263
+ row: pointToUpdate.row,
264
+ column: pointToUpdate.column + 1
265
+ };
266
+ selectionAreasClone[indexOfCurrentArea].point2 = _newPoint;
267
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
268
+ setSelectionAreas(selectionAreasClone);
269
+ } // Up + Shift
270
+
271
+
272
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowUp')) {
273
+ if (pointToUpdate.row === 0) {
274
+ return;
275
+ }
276
+
277
+ var _newPoint2 = {
278
+ row: pointToUpdate.row - 1,
279
+ column: pointToUpdate.column
280
+ };
281
+ selectionAreasClone[indexOfCurrentArea].point2 = _newPoint2;
282
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
283
+ setSelectionAreas(selectionAreasClone);
284
+ } // Left + Shift
285
+
286
+
287
+ if (activeKeyValues.includes('Shift') && activeKeyValues.includes('ArrowLeft')) {
288
+ if (pointToUpdate.column === 0) {
289
+ return;
290
+ }
291
+
292
+ var _newPoint3 = {
293
+ row: pointToUpdate.row,
294
+ column: pointToUpdate.column - 1
295
+ };
296
+ selectionAreasClone[indexOfCurrentArea].point2 = _newPoint3;
297
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
298
+ setSelectionAreas(selectionAreasClone);
299
+ }
300
+ }, [selectionAreas, currentMatcher, columns, rows]);
189
301
  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
302
+ var _activeKeys$current, _activeKeys$current2;
191
303
 
192
- if (keyCode === 91 || keyCode === 93) {
304
+ var key = event.key; // Command keys need to be returned as there is default browser behavior with these keys
305
+
306
+ if (key === 'Meta' || key === 'Control') {
193
307
  return;
194
308
  } // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
195
309
 
196
310
 
197
- if ([35, 36, 37, 38, 39, 40].indexOf(keyCode) > -1) {
311
+ if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
198
312
  event.preventDefault();
199
- } // Clear out all cell selection areas if user uses any arrow key
313
+ } // Clear out all cell selection areas if user uses any arrow key, except if the shift key is being held
200
314
 
201
315
 
202
- if ([37, 38, 39, 40].indexOf(keyCode) > -1) {
203
- if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length) {
316
+ if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
317
+ if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && key !== 'Shift' && !activeKeys.current.includes('Shift')) {
204
318
  setSelectionAreas([]);
205
319
  removeCellSelections();
206
320
  }
207
- }
321
+ } // Update list of activeKeys
208
322
 
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
323
 
221
- case 37:
222
- {
223
- handleInitialArrowPress();
324
+ if (!((_activeKeys$current = activeKeys.current) !== null && _activeKeys$current !== void 0 && _activeKeys$current.includes(key))) {
325
+ var activeClone = _toConsumableArray(activeKeys.current);
224
326
 
225
- var coordinatesClone = _objectSpread({}, activeCellCoordinates);
327
+ activeKeys.current = [].concat(_toConsumableArray(activeClone), [key]);
328
+ }
226
329
 
227
- if (coordinatesClone.column === 'header') {
228
- return;
330
+ if (((_activeKeys$current2 = activeKeys.current) === null || _activeKeys$current2 === void 0 ? void 0 : _activeKeys$current2.length) > 1) {
331
+ handleMultipleKeys();
332
+ } // Allow arrow key navigation if there are less than two activeKeys OR
333
+ // if one of the activeCellCoordinates is in a header position
334
+
335
+
336
+ if (!activeKeys.current.includes('Shift') || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
337
+ switch (key) {
338
+ // Tab
339
+ case 'Tab':
340
+ {
341
+ setSelectionAreas([]);
342
+ removeActiveCell();
343
+ setContainerHasFocus(false);
344
+ setActiveCellCoordinates(null);
345
+ break;
229
346
  }
347
+ // Left
348
+
349
+ case 'ArrowLeft':
350
+ {
351
+ handleInitialArrowPress();
352
+
353
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
354
+
355
+ if (coordinatesClone.column === 'header') {
356
+ return;
357
+ }
358
+
359
+ if (typeof coordinatesClone.column === 'number') {
360
+ if (coordinatesClone.column === 0) {
361
+ updateActiveCellCoordinates({
362
+ coords: coordinatesClone,
363
+ updatedValue: {
364
+ column: 'header'
365
+ }
366
+ });
367
+ return;
368
+ }
230
369
 
231
- if (typeof coordinatesClone.column === 'number') {
232
- if (coordinatesClone.column === 0) {
233
370
  updateActiveCellCoordinates({
234
371
  coords: coordinatesClone,
235
372
  updatedValue: {
236
- column: 'header'
373
+ column: coordinatesClone.column - 1
237
374
  }
238
375
  });
239
- return;
240
376
  }
241
377
 
242
- updateActiveCellCoordinates({
243
- coords: coordinatesClone,
244
- updatedValue: {
245
- column: coordinatesClone.column - 1
246
- }
247
- });
378
+ break;
248
379
  }
380
+ // Up
249
381
 
250
- break;
251
- }
252
- // Up
382
+ case 'ArrowUp':
383
+ {
384
+ handleInitialArrowPress();
253
385
 
254
- case 38:
255
- {
256
- handleInitialArrowPress();
386
+ var _coordinatesClone = _objectSpread({}, activeCellCoordinates);
257
387
 
258
- var _coordinatesClone = _objectSpread({}, activeCellCoordinates);
388
+ if (_coordinatesClone.row === 'header') {
389
+ return;
390
+ }
391
+
392
+ if (typeof _coordinatesClone.row === 'number') {
393
+ // set row back to header if we are at index 0
394
+ if (_coordinatesClone.row === 0) {
395
+ updateActiveCellCoordinates({
396
+ coords: _coordinatesClone,
397
+ updatedValue: {
398
+ row: 'header'
399
+ }
400
+ });
401
+ return;
402
+ } // if we are at any other index than 0, subtract 1 from current row index
259
403
 
260
- if (_coordinatesClone.row === 'header') {
261
- return;
262
- }
263
404
 
264
- if (typeof _coordinatesClone.row === 'number') {
265
- // set row back to header if we are at index 0
266
- if (_coordinatesClone.row === 0) {
267
405
  updateActiveCellCoordinates({
268
406
  coords: _coordinatesClone,
269
407
  updatedValue: {
270
- row: 'header'
408
+ row: _coordinatesClone.row - 1
271
409
  }
272
410
  });
273
- return;
274
- } // if we are at any other index than 0, subtract 1 from current row index
275
-
411
+ }
276
412
 
277
- updateActiveCellCoordinates({
278
- coords: _coordinatesClone,
279
- updatedValue: {
280
- row: _coordinatesClone.row - 1
281
- }
282
- });
413
+ break;
283
414
  }
415
+ // Right
284
416
 
285
- break;
286
- }
287
- // Right
417
+ case 'ArrowRight':
418
+ {
419
+ handleInitialArrowPress();
288
420
 
289
- case 39:
290
- {
291
- handleInitialArrowPress();
421
+ var _coordinatesClone2 = _objectSpread({}, activeCellCoordinates);
292
422
 
293
- var _coordinatesClone2 = _objectSpread({}, activeCellCoordinates);
423
+ if (_coordinatesClone2.column === 'header') {
424
+ updateActiveCellCoordinates({
425
+ coords: _coordinatesClone2,
426
+ updatedValue: {
427
+ column: 0
428
+ }
429
+ });
430
+ }
294
431
 
295
- if (_coordinatesClone2.column === 'header') {
296
- updateActiveCellCoordinates({
297
- coords: _coordinatesClone2,
298
- updatedValue: {
299
- column: 0
432
+ if (typeof _coordinatesClone2.column === 'number') {
433
+ // Prevent active cell coordinates from updating if the active
434
+ // cell is in the last column, ie we can't go any further to the right
435
+ if (columns.length - 1 === _coordinatesClone2.column) {
436
+ return;
300
437
  }
301
- });
302
- }
303
438
 
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;
439
+ updateActiveCellCoordinates({
440
+ coords: _coordinatesClone2,
441
+ updatedValue: {
442
+ column: _coordinatesClone2.column + 1
443
+ }
444
+ });
309
445
  }
310
446
 
311
- updateActiveCellCoordinates({
312
- coords: _coordinatesClone2,
313
- updatedValue: {
314
- column: _coordinatesClone2.column + 1
315
- }
316
- });
447
+ break;
317
448
  }
449
+ // Down
318
450
 
319
- break;
320
- }
321
- // Down
451
+ case 'ArrowDown':
452
+ {
453
+ handleInitialArrowPress();
322
454
 
323
- case 40:
324
- {
325
- handleInitialArrowPress();
455
+ var _coordinatesClone3 = _objectSpread({}, activeCellCoordinates);
326
456
 
327
- var _coordinatesClone3 = _objectSpread({}, activeCellCoordinates);
457
+ if (_coordinatesClone3.row === 'header') {
458
+ updateActiveCellCoordinates({
459
+ coords: _coordinatesClone3,
460
+ updatedValue: {
461
+ row: 0
462
+ }
463
+ });
464
+ }
328
465
 
329
- if (_coordinatesClone3.row === 'header') {
330
- updateActiveCellCoordinates({
331
- coords: _coordinatesClone3,
332
- updatedValue: {
333
- row: 0
466
+ if (typeof _coordinatesClone3.row === 'number') {
467
+ // Prevent active cell coordinates from updating if the active
468
+ // cell is in the last row, ie we can't go any further down since
469
+ // we are in the last row
470
+ if (rows.length - 1 === _coordinatesClone3.row) {
471
+ return;
334
472
  }
335
- });
336
- }
337
473
 
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;
474
+ updateActiveCellCoordinates({
475
+ coords: _coordinatesClone3,
476
+ updatedValue: {
477
+ row: _coordinatesClone3.row + 1
478
+ }
479
+ });
344
480
  }
345
481
 
346
- updateActiveCellCoordinates({
347
- coords: _coordinatesClone3,
348
- updatedValue: {
349
- row: _coordinatesClone3.row + 1
350
- }
351
- });
482
+ break;
352
483
  }
484
+ }
485
+ }
486
+ }, [updateActiveCellCoordinates, handleInitialArrowPress, handleMultipleKeys, activeCellCoordinates, selectionAreas === null || selectionAreas === void 0 ? void 0 : selectionAreas.length, removeCellSelections, removeActiveCell, columns.length, rows.length]); // Only update if there are cell selection areas
487
+ // Find point object that matches currentMatcher and remove the second point
488
+ // because hovering over the active cell while clicking and holding should
489
+ // remove the previously existing selection area
490
+
491
+ var handleActiveCellMouseEnterCallback = useCallback(function (areas, clickHold) {
492
+ var freshMatcherValue = currentMatcherRef.current;
493
+
494
+ if (!freshMatcherValue) {
495
+ return;
496
+ }
353
497
 
354
- break;
498
+ if (areas && areas.length && clickHold && freshMatcherValue) {
499
+ setSelectionAreas(function (prev) {
500
+ var selectionAreaClone = deepCloneObject(prev);
501
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
502
+ return item.matcher === freshMatcherValue;
503
+ });
504
+
505
+ if (indexOfItemToUpdate === -1) {
506
+ return prev;
507
+ }
508
+
509
+ if (_typeof(selectionAreaClone[indexOfItemToUpdate].point2) === 'object' && selectionAreaClone[indexOfItemToUpdate].areaCreated) {
510
+ selectionAreaClone[indexOfItemToUpdate].point2 = null;
511
+ selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
512
+ removeCellSelections(freshMatcherValue);
513
+ return selectionAreaClone;
355
514
  }
515
+
516
+ return prev;
517
+ });
356
518
  }
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
519
+ }, [removeCellSelections]); // Adds active cell highlight to correct cell onKeyDown
358
520
 
359
521
  useEffect(function () {
360
522
  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, "\"]"));
@@ -369,6 +531,22 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
369
531
  });
370
532
  }
371
533
  }, [activeCellCoordinates, spreadsheetRef, createActiveCell, containerHasFocus]);
534
+
535
+ var handleKeyUp = function handleKeyUp(event) {
536
+ var _activeKeys$current3;
537
+
538
+ var key = event.key; // Remove key from active keys array on key up
539
+
540
+ if ((_activeKeys$current3 = activeKeys.current) !== null && _activeKeys$current3 !== void 0 && _activeKeys$current3.includes(key)) {
541
+ var activeKeysClone = _toConsumableArray(activeKeys.current);
542
+
543
+ var filteredKeysClone = activeKeysClone.filter(function (item) {
544
+ return item !== key;
545
+ });
546
+ activeKeys.current = filteredKeysClone;
547
+ }
548
+ };
549
+
372
550
  var localRef = useRef();
373
551
  var spreadsheetRef = ref || localRef;
374
552
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, getTableProps(), getDevtoolsProps(componentName), {
@@ -379,14 +557,19 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
379
557
  "aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
380
558
  "aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
381
559
  onKeyDown: handleKeyPress,
560
+ onKeyUp: handleKeyUp,
382
561
  onFocus: function onFocus() {
383
562
  return setContainerHasFocus(true);
384
563
  }
385
564
  }), /*#__PURE__*/React.createElement(DataSpreadsheetHeader, {
565
+ activeCellCoordinates: activeCellCoordinates,
386
566
  cellSizeValue: cellSizeValue,
387
567
  defaultColumn: defaultColumn,
388
- headerGroups: headerGroups
568
+ headerGroups: headerGroups,
569
+ selectionAreas: selectionAreas
389
570
  }), /*#__PURE__*/React.createElement(DataSpreadsheetBody, {
571
+ activeCellCoordinates: activeCellCoordinates,
572
+ ref: currentMatcherRef,
390
573
  clickAndHoldActive: clickAndHoldActive,
391
574
  setClickAndHoldActive: setClickAndHoldActive,
392
575
  currentMatcher: currentMatcher,