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