@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.
- package/css/index-full-carbon.css +364 -5838
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +5 -5
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +68 -3430
- 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 +185 -4098
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +5 -5
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +302 -4099
- package/css/index.css.map +1 -1
- package/css/index.min.css +5 -5
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelect.js +98 -92
- package/es/components/AddSelect/AddSelectColumn.js +219 -8
- package/es/components/AddSelect/AddSelectList.js +5 -5
- package/es/components/AddSelect/AddSelectSidebar.js +3 -15
- package/es/components/AddSelect/add-select-utils.js +64 -0
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -1
- package/es/components/ButtonMenu/ButtonMenu.js +12 -4
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +480 -182
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +124 -81
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +74 -8
- package/es/components/DataSpreadsheet/hooks/useMoveActiveCell.js +27 -0
- package/es/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +28 -0
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +41 -0
- package/es/components/DataSpreadsheet/utils/checkActiveHeaderCell.js +34 -0
- package/es/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js} +21 -8
- package/es/components/DataSpreadsheet/{createCellSelectionArea.js → utils/createCellSelectionArea.js} +8 -4
- package/es/components/DataSpreadsheet/{generateData.js → utils/generateData.js} +6 -0
- package/es/components/DataSpreadsheet/{getCellSize.js → utils/getCellSize.js} +0 -0
- package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +46 -0
- package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +82 -0
- package/es/components/DataSpreadsheet/utils/removeCellSelections.js +30 -0
- package/es/components/InlineEdit/InlineEdit.js +58 -27
- package/es/components/OptionsTile/OptionsTile.js +31 -21
- package/es/components/OptionsTile/index.js +1 -1
- package/es/components/PageHeader/PageHeader.js +26 -15
- package/es/components/PageHeader/PageHeaderTitle.js +2 -1
- package/es/components/PageHeader/PageHeaderUtils.js +24 -29
- package/es/components/TagSet/TagSet.js +12 -3
- package/es/components/UserProfileImage/UserProfileImage.js +2 -1
- package/es/components/index.js +0 -1
- package/es/global/js/package-settings.js +1 -2
- package/lib/components/AddSelect/AddSelect.js +101 -92
- package/lib/components/AddSelect/AddSelectColumn.js +232 -13
- package/lib/components/AddSelect/AddSelectList.js +5 -5
- package/lib/components/AddSelect/AddSelectSidebar.js +9 -15
- package/lib/components/AddSelect/add-select-utils.js +78 -0
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -1
- package/lib/components/ButtonMenu/ButtonMenu.js +12 -4
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +490 -186
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +127 -82
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +82 -9
- package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.js +37 -0
- package/lib/components/DataSpreadsheet/hooks/useResetSpreadsheetFocus.js +39 -0
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +52 -0
- package/lib/components/DataSpreadsheet/utils/checkActiveHeaderCell.js +45 -0
- package/lib/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js} +21 -8
- package/lib/components/DataSpreadsheet/{createCellSelectionArea.js → utils/createCellSelectionArea.js} +8 -4
- package/lib/components/DataSpreadsheet/{generateData.js → utils/generateData.js} +6 -0
- package/lib/components/DataSpreadsheet/{getCellSize.js → utils/getCellSize.js} +0 -0
- package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +59 -0
- package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +92 -0
- package/lib/components/DataSpreadsheet/utils/removeCellSelections.js +41 -0
- package/lib/components/InlineEdit/InlineEdit.js +60 -28
- package/lib/components/OptionsTile/OptionsTile.js +30 -20
- package/lib/components/PageHeader/PageHeader.js +25 -15
- package/lib/components/PageHeader/PageHeaderTitle.js +2 -1
- package/lib/components/PageHeader/PageHeaderUtils.js +24 -29
- package/lib/components/TagSet/TagSet.js +13 -3
- package/lib/components/UserProfileImage/UserProfileImage.js +2 -1
- package/lib/components/index.js +0 -8
- package/lib/global/js/package-settings.js +1 -2
- package/package.json +17 -17
- package/scss/components/AddSelect/_add-select.scss +47 -14
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +7 -3
- package/scss/components/CreateInfluencer/_create-influencer.scss +2 -0
- package/scss/components/CreateModal/_create-modal.scss +1 -0
- package/scss/components/CreateSidePanel/_create-side-panel.scss +1 -1
- package/scss/components/CreateSidePanel/_storybook-styles.scss +1 -1
- 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 +25 -7
- package/scss/components/EditSidePanel/_edit-side-panel.scss +9 -0
- package/scss/components/EditSidePanel/_storybook-styles.scss +1 -1
- package/scss/components/InlineEdit/_inline-edit.scss +46 -39
- package/scss/components/InlineEdit/_storybook-styles.scss +1 -0
- package/scss/components/ModifiedTabs/_modified-tabs.scss +5 -0
- package/scss/components/NotificationsPanel/_notifications-panel.scss +10 -3
- package/scss/components/OptionsTile/_index.scss +1 -1
- package/scss/components/OptionsTile/_options-tile.scss +17 -17
- package/scss/components/OptionsTile/_storybook-styles.scss +4 -4
- package/scss/components/PageHeader/_page-header.scss +5 -2
- package/scss/components/SidePanel/_side-panel.scss +19 -12
- package/scss/components/StatusIcon/_status-icon.scss +1 -0
- package/scss/components/Tearsheet/_tearsheet.scss +4 -0
- package/scss/components/UserProfileImage/_user-profile-image.scss +9 -0
- package/scss/components/WebTerminal/_web-terminal.scss +2 -0
- package/scss/components/_index.scss +0 -1
- package/es/components/LoadingBar/LoadingBar.js +0 -156
- package/es/components/LoadingBar/index.js +0 -7
- package/lib/components/LoadingBar/LoadingBar.js +0 -170
- package/lib/components/LoadingBar/index.js +0 -13
- package/scss/components/LoadingBar/_index.scss +0 -8
- package/scss/components/LoadingBar/_loading-bar.scss +0 -211
- 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,
|
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 {
|
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 {
|
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(
|
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; //
|
139
|
+
prepareRow = _useTable.prepareRow; // Update the spreadsheet data after editing a cell
|
107
140
|
|
108
141
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
-
|
116
|
-
|
117
|
-
}
|
118
|
-
}, [
|
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.
|
158
|
+
activeCellHighlight.style.display = 'none';
|
125
159
|
}
|
126
|
-
}, [spreadsheetRef]);
|
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
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
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
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
|
274
|
+
var _activeKeys$current, _activeKeys$current2;
|
191
275
|
|
192
|
-
|
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 ([
|
283
|
+
if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing) {
|
198
284
|
event.preventDefault();
|
199
|
-
}
|
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
|
-
|
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
|
-
|
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
|
-
|
309
|
+
activeKeys.current = [].concat(_toConsumableArray(activeClone), [key]);
|
310
|
+
}
|
226
311
|
|
227
|
-
|
228
|
-
|
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:
|
363
|
+
column: coordinatesClone.column - 1
|
237
364
|
}
|
238
365
|
});
|
239
|
-
return;
|
240
366
|
}
|
241
367
|
|
242
|
-
|
243
|
-
coords: coordinatesClone,
|
244
|
-
updatedValue: {
|
245
|
-
column: coordinatesClone.column - 1
|
246
|
-
}
|
247
|
-
});
|
368
|
+
break;
|
248
369
|
}
|
370
|
+
// Up
|
249
371
|
|
250
|
-
|
251
|
-
|
252
|
-
|
372
|
+
case 'ArrowUp':
|
373
|
+
{
|
374
|
+
handleInitialArrowPress();
|
253
375
|
|
254
|
-
|
255
|
-
{
|
256
|
-
handleInitialArrowPress();
|
376
|
+
var _coordinatesClone = _objectSpread({}, activeCellCoordinates);
|
257
377
|
|
258
|
-
|
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:
|
398
|
+
row: _coordinatesClone.row - 1
|
271
399
|
}
|
272
400
|
});
|
273
|
-
|
274
|
-
} // if we are at any other index than 0, subtract 1 from current row index
|
275
|
-
|
401
|
+
}
|
276
402
|
|
277
|
-
|
278
|
-
coords: _coordinatesClone,
|
279
|
-
updatedValue: {
|
280
|
-
row: _coordinatesClone.row - 1
|
281
|
-
}
|
282
|
-
});
|
403
|
+
break;
|
283
404
|
}
|
405
|
+
// Right
|
284
406
|
|
285
|
-
|
286
|
-
|
287
|
-
|
407
|
+
case 'ArrowRight':
|
408
|
+
{
|
409
|
+
handleInitialArrowPress();
|
288
410
|
|
289
|
-
|
290
|
-
{
|
291
|
-
handleInitialArrowPress();
|
411
|
+
var _coordinatesClone2 = _objectSpread({}, activeCellCoordinates);
|
292
412
|
|
293
|
-
|
413
|
+
if (_coordinatesClone2.column === 'header') {
|
414
|
+
updateActiveCellCoordinates({
|
415
|
+
coords: _coordinatesClone2,
|
416
|
+
updatedValue: {
|
417
|
+
column: 0
|
418
|
+
}
|
419
|
+
});
|
420
|
+
}
|
294
421
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
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
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
429
|
+
updateActiveCellCoordinates({
|
430
|
+
coords: _coordinatesClone2,
|
431
|
+
updatedValue: {
|
432
|
+
column: _coordinatesClone2.column + 1
|
433
|
+
}
|
434
|
+
});
|
309
435
|
}
|
310
436
|
|
311
|
-
|
312
|
-
coords: _coordinatesClone2,
|
313
|
-
updatedValue: {
|
314
|
-
column: _coordinatesClone2.column + 1
|
315
|
-
}
|
316
|
-
});
|
437
|
+
break;
|
317
438
|
}
|
439
|
+
// Down
|
318
440
|
|
319
|
-
|
320
|
-
|
321
|
-
|
441
|
+
case 'ArrowDown':
|
442
|
+
{
|
443
|
+
handleInitialArrowPress();
|
322
444
|
|
323
|
-
|
324
|
-
{
|
325
|
-
handleInitialArrowPress();
|
445
|
+
var _coordinatesClone3 = _objectSpread({}, activeCellCoordinates);
|
326
446
|
|
327
|
-
|
447
|
+
if (_coordinatesClone3.row === 'header') {
|
448
|
+
updateActiveCellCoordinates({
|
449
|
+
coords: _coordinatesClone3,
|
450
|
+
updatedValue: {
|
451
|
+
row: 0
|
452
|
+
}
|
453
|
+
});
|
454
|
+
}
|
328
455
|
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
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
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
464
|
+
updateActiveCellCoordinates({
|
465
|
+
coords: _coordinatesClone3,
|
466
|
+
updatedValue: {
|
467
|
+
row: _coordinatesClone3.row + 1
|
468
|
+
}
|
469
|
+
});
|
344
470
|
}
|
345
471
|
|
346
|
-
|
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
|
-
|
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
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
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
|
-
}
|
372
|
-
|
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
|
};
|