@carbon/ibm-products 1.10.0 → 1.11.2
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 +249 -218
- 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 +21 -4
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +2 -2
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +102 -212
- 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 +219 -212
- 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 +88 -87
- package/es/components/AddSelect/AddSelectColumn.js +193 -19
- 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 +11 -3
- package/es/components/CreateFullPage/CreateFullPageStep.js +4 -4
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +4 -4
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +255 -140
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +37 -38
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +55 -6
- 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/{checkActiveHeaderCell.js → utils/checkActiveHeaderCell.js} +1 -1
- package/es/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js} +20 -9
- 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 +49 -8
- package/es/components/OptionsTile/OptionsTile.js +20 -20
- package/es/components/OptionsTile/index.js +1 -1
- package/es/components/PageHeader/PageHeader.js +35 -32
- package/es/components/PageHeader/PageHeaderTitle.js +2 -1
- package/es/components/PageHeader/PageHeaderUtils.js +21 -22
- package/es/components/index.js +0 -1
- package/es/global/js/package-settings.js +1 -2
- package/lib/components/AddSelect/AddSelect.js +91 -87
- package/lib/components/AddSelect/AddSelectColumn.js +193 -16
- 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 +11 -3
- package/lib/components/CreateFullPage/CreateFullPageStep.js +4 -4
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +4 -4
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +263 -142
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +39 -36
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +62 -8
- 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/{checkActiveHeaderCell.js → utils/checkActiveHeaderCell.js} +1 -1
- package/lib/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js} +20 -9
- 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 +52 -10
- package/lib/components/OptionsTile/OptionsTile.js +19 -19
- package/lib/components/PageHeader/PageHeader.js +35 -32
- package/lib/components/PageHeader/PageHeaderTitle.js +2 -1
- package/lib/components/PageHeader/PageHeaderUtils.js +21 -22
- package/lib/components/index.js +0 -8
- package/lib/global/js/package-settings.js +1 -2
- package/package.json +13 -13
- package/scss/components/AddSelect/_add-select.scss +20 -0
- package/scss/components/BreadcrumbWithOverflow/_breadcrumb-with-overflow.scss +7 -3
- package/scss/components/CreateSidePanel/_create-side-panel.scss +1 -1
- package/scss/components/CreateSidePanel/_storybook-styles.scss +1 -1
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +14 -1
- 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 +35 -37
- package/scss/components/ModifiedTabs/_modified-tabs.scss +5 -0
- package/scss/components/NotificationsPanel/_notifications-panel.scss +7 -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 +3 -2
- package/scss/components/SidePanel/_side-panel.scss +8 -8
- package/scss/components/Tearsheet/_tearsheet.scss +4 -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 -224
- package/scss/components/LoadingBar/_storybook-styles.scss +0 -14
|
@@ -29,9 +29,13 @@ var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
|
|
|
29
29
|
|
|
30
30
|
var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _removeCellSelections = require("./utils/removeCellSelections");
|
|
33
33
|
|
|
34
|
-
var
|
|
34
|
+
var _createCellSelectionArea = require("./utils/createCellSelectionArea");
|
|
35
|
+
|
|
36
|
+
var _checkActiveHeaderCell = require("./utils/checkActiveHeaderCell");
|
|
37
|
+
|
|
38
|
+
var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
|
|
35
39
|
|
|
36
40
|
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); }
|
|
37
41
|
|
|
@@ -45,7 +49,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
45
49
|
*/
|
|
46
50
|
var blockClass = "".concat(_settings.pkg.prefix, "--data-spreadsheet");
|
|
47
51
|
var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
48
|
-
var
|
|
52
|
+
var columns = _ref.columns,
|
|
53
|
+
activeCellCoordinates = _ref.activeCellCoordinates,
|
|
49
54
|
defaultColumn = _ref.defaultColumn,
|
|
50
55
|
getTableBodyProps = _ref.getTableBodyProps,
|
|
51
56
|
id = _ref.id,
|
|
@@ -61,8 +66,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
61
66
|
setClickAndHoldActive = _ref.setClickAndHoldActive,
|
|
62
67
|
currentMatcher = _ref.currentMatcher,
|
|
63
68
|
setCurrentMatcher = _ref.setCurrentMatcher;
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
// Create cell selection areas based on selectionAreas array
|
|
66
70
|
(0, _react.useEffect)(function () {
|
|
67
71
|
if (selectionAreas && selectionAreas.length) {
|
|
68
72
|
selectionAreas.map(function (area) {
|
|
@@ -82,6 +86,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
82
86
|
(0, _createCellSelectionArea.createCellSelectionArea)({
|
|
83
87
|
area: area,
|
|
84
88
|
blockClass: blockClass,
|
|
89
|
+
defaultColumn: defaultColumn,
|
|
85
90
|
selectionAreas: selectionAreas,
|
|
86
91
|
setSelectionAreas: setSelectionAreas
|
|
87
92
|
});
|
|
@@ -90,7 +95,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
90
95
|
return;
|
|
91
96
|
});
|
|
92
97
|
}
|
|
93
|
-
}, [selectionAreas, setSelectionAreas]); // Mouse up
|
|
98
|
+
}, [selectionAreas, setSelectionAreas, defaultColumn]); // Mouse up
|
|
94
99
|
|
|
95
100
|
(0, _react.useEffect)(function () {
|
|
96
101
|
var handleMouseUp = function handleMouseUp(event) {
|
|
@@ -116,26 +121,6 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
116
121
|
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
|
117
122
|
return selectionAreaClone;
|
|
118
123
|
});
|
|
119
|
-
} else {
|
|
120
|
-
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
|
121
|
-
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
|
122
|
-
return item.matcher === currentMatcher;
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
if (indexOfItemToUpdate === -1) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
var notYetCreatedSelections = selectionAreaClone.filter(function (item) {
|
|
130
|
-
return !item.areaCreated && item.matcher === currentMatcher;
|
|
131
|
-
});
|
|
132
|
-
var previouslyCreatedSelectionAreas = selectionAreaClone.filter(function (item) {
|
|
133
|
-
return item.point2 && item.areaCreated;
|
|
134
|
-
}); // We want to ensure that there is only ever one item in selectionAreas
|
|
135
|
-
// that has not been created yet. This item's point1 values will always
|
|
136
|
-
// be equal to the activeCellCoordinates
|
|
137
|
-
|
|
138
|
-
setSelectionAreas([].concat((0, _toConsumableArray2.default)(notYetCreatedSelections), (0, _toConsumableArray2.default)(previouslyCreatedSelectionAreas)));
|
|
139
124
|
}
|
|
140
125
|
};
|
|
141
126
|
|
|
@@ -166,7 +151,8 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
166
151
|
row: cell.row.index,
|
|
167
152
|
column: columnIndex
|
|
168
153
|
};
|
|
169
|
-
var tempMatcher = (0, _uuidv.default)();
|
|
154
|
+
var tempMatcher = (0, _uuidv.default)();
|
|
155
|
+
setClickAndHoldActive(true); // prevent multiple selections unless cmd key is held
|
|
170
156
|
// meaning that selectionAreas should only have one item by default
|
|
171
157
|
|
|
172
158
|
if (isHoldingCommandKey) {
|
|
@@ -202,9 +188,8 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
202
188
|
} else {
|
|
203
189
|
setActiveCellCoordinates(activeCoordinates); // remove all previous cell selections
|
|
204
190
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
return element.remove();
|
|
191
|
+
(0, _removeCellSelections.removeCellSelections)({
|
|
192
|
+
spreadsheetRef: ref
|
|
208
193
|
});
|
|
209
194
|
setSelectionAreas([{
|
|
210
195
|
point1: activeCoordinates,
|
|
@@ -212,11 +197,8 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
212
197
|
}]);
|
|
213
198
|
setCurrentMatcher(tempMatcher);
|
|
214
199
|
}
|
|
215
|
-
|
|
216
|
-
currentMatcherRef.current = tempMatcher;
|
|
217
|
-
setClickAndHoldActive(true);
|
|
218
200
|
};
|
|
219
|
-
}, [
|
|
201
|
+
}, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref]);
|
|
220
202
|
var handleBodyCellHover = (0, _react.useCallback)(function (cell, columnIndex) {
|
|
221
203
|
return function () {
|
|
222
204
|
if (clickAndHoldActive) {
|
|
@@ -247,7 +229,22 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
247
229
|
});
|
|
248
230
|
}
|
|
249
231
|
};
|
|
250
|
-
}, [clickAndHoldActive, currentMatcher, setSelectionAreas]);
|
|
232
|
+
}, [clickAndHoldActive, currentMatcher, setSelectionAreas]);
|
|
233
|
+
var handleRowHeaderClick = (0, _react.useCallback)(function (index) {
|
|
234
|
+
return function () {
|
|
235
|
+
(0, _handleHeaderCellSelection.handleHeaderCellSelection)({
|
|
236
|
+
type: 'row',
|
|
237
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
238
|
+
rows: rows,
|
|
239
|
+
columns: columns,
|
|
240
|
+
setActiveCellCoordinates: setActiveCellCoordinates,
|
|
241
|
+
setCurrentMatcher: setCurrentMatcher,
|
|
242
|
+
setSelectionAreas: setSelectionAreas,
|
|
243
|
+
spreadsheetRef: ref,
|
|
244
|
+
index: index
|
|
245
|
+
});
|
|
246
|
+
};
|
|
247
|
+
}, [columns, ref, setSelectionAreas, setCurrentMatcher, setActiveCellCoordinates, activeCellCoordinates, rows]); // Renders each row/cell in the spreadsheet body
|
|
251
248
|
|
|
252
249
|
var RenderRow = (0, _react.useCallback)(function (_ref2) {
|
|
253
250
|
var index = _ref2.index,
|
|
@@ -264,6 +261,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
264
261
|
"data-row-index": index,
|
|
265
262
|
"data-column-index": "header",
|
|
266
263
|
type: "button",
|
|
264
|
+
onClick: handleRowHeaderClick(index),
|
|
267
265
|
className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__td-th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === index || (0, _checkActiveHeaderCell.checkActiveHeaderCell)(index, selectionAreas, 'row'))),
|
|
268
266
|
style: {
|
|
269
267
|
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
|
|
@@ -282,7 +280,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
|
|
|
282
280
|
type: "button"
|
|
283
281
|
}), cell.render('Cell'));
|
|
284
282
|
}));
|
|
285
|
-
}, [prepareRow, rows, defaultColumn.rowHeaderWidth,
|
|
283
|
+
}, [prepareRow, rows, defaultColumn.rowHeaderWidth, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas, handleRowHeaderClick, handleBodyCellClick, handleBodyCellHover]);
|
|
286
284
|
var spreadsheetBodyRef = (0, _react.useRef)();
|
|
287
285
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
288
286
|
ref: spreadsheetBodyRef,
|
|
@@ -310,6 +308,11 @@ DataSpreadsheetBody.propTypes = {
|
|
|
310
308
|
*/
|
|
311
309
|
clickAndHoldActive: _propTypes.default.bool,
|
|
312
310
|
|
|
311
|
+
/**
|
|
312
|
+
* All of the spreadsheet columns
|
|
313
|
+
*/
|
|
314
|
+
columns: _propTypes.default.array,
|
|
315
|
+
|
|
313
316
|
/**
|
|
314
317
|
* This represents the id of the current cell selection area
|
|
315
318
|
*/
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -11,7 +13,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
13
|
|
|
12
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
15
|
|
|
14
|
-
var _react =
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
17
|
|
|
16
18
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
19
|
|
|
@@ -19,7 +21,13 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
19
21
|
|
|
20
22
|
var _settings = require("../../settings");
|
|
21
23
|
|
|
22
|
-
var _checkActiveHeaderCell = require("./checkActiveHeaderCell");
|
|
24
|
+
var _checkActiveHeaderCell = require("./utils/checkActiveHeaderCell");
|
|
25
|
+
|
|
26
|
+
var _handleHeaderCellSelection = require("./utils/handleHeaderCellSelection");
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
31
|
|
|
24
32
|
/**
|
|
25
33
|
* Copyright IBM Corp. 2022, 2022
|
|
@@ -28,12 +36,33 @@ var _checkActiveHeaderCell = require("./checkActiveHeaderCell");
|
|
|
28
36
|
* LICENSE file in the root directory of this source tree.
|
|
29
37
|
*/
|
|
30
38
|
var blockClass = "".concat(_settings.pkg.prefix, "--data-spreadsheet");
|
|
31
|
-
|
|
32
|
-
var DataSpreadsheetHeader = function DataSpreadsheetHeader(_ref) {
|
|
39
|
+
var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
33
40
|
var activeCellCoordinates = _ref.activeCellCoordinates,
|
|
41
|
+
columns = _ref.columns,
|
|
34
42
|
defaultColumn = _ref.defaultColumn,
|
|
35
43
|
headerGroups = _ref.headerGroups,
|
|
36
|
-
selectionAreas = _ref.selectionAreas
|
|
44
|
+
selectionAreas = _ref.selectionAreas,
|
|
45
|
+
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
|
46
|
+
setCurrentMatcher = _ref.setCurrentMatcher,
|
|
47
|
+
setSelectionAreas = _ref.setSelectionAreas,
|
|
48
|
+
rows = _ref.rows;
|
|
49
|
+
|
|
50
|
+
var handleColumnHeaderClick = function handleColumnHeaderClick(index) {
|
|
51
|
+
return function () {
|
|
52
|
+
(0, _handleHeaderCellSelection.handleHeaderCellSelection)({
|
|
53
|
+
type: 'column',
|
|
54
|
+
activeCellCoordinates: activeCellCoordinates,
|
|
55
|
+
rows: rows,
|
|
56
|
+
columns: columns,
|
|
57
|
+
setActiveCellCoordinates: setActiveCellCoordinates,
|
|
58
|
+
setCurrentMatcher: setCurrentMatcher,
|
|
59
|
+
setSelectionAreas: setSelectionAreas,
|
|
60
|
+
spreadsheetRef: ref,
|
|
61
|
+
index: index
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
37
66
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
38
67
|
className: (0, _classnames.default)("".concat(blockClass, "__header--container"))
|
|
39
68
|
}, headerGroups.map(function (headerGroup, index) {
|
|
@@ -57,6 +86,7 @@ var DataSpreadsheetHeader = function DataSpreadsheetHeader(_ref) {
|
|
|
57
86
|
"data-row-index": "header",
|
|
58
87
|
"data-column-index": index,
|
|
59
88
|
tabIndex: -1,
|
|
89
|
+
onClick: handleColumnHeaderClick(index),
|
|
60
90
|
style: {
|
|
61
91
|
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
|
62
92
|
}
|
|
@@ -66,8 +96,7 @@ var DataSpreadsheetHeader = function DataSpreadsheetHeader(_ref) {
|
|
|
66
96
|
}), column.render('Header'));
|
|
67
97
|
}));
|
|
68
98
|
}));
|
|
69
|
-
};
|
|
70
|
-
|
|
99
|
+
});
|
|
71
100
|
exports.DataSpreadsheetHeader = DataSpreadsheetHeader;
|
|
72
101
|
DataSpreadsheetHeader.propTypes = {
|
|
73
102
|
/**
|
|
@@ -78,6 +107,11 @@ DataSpreadsheetHeader.propTypes = {
|
|
|
78
107
|
column: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
|
|
79
108
|
}),
|
|
80
109
|
|
|
110
|
+
/**
|
|
111
|
+
* All of the spreadsheet columns
|
|
112
|
+
*/
|
|
113
|
+
columns: _propTypes.default.array,
|
|
114
|
+
|
|
81
115
|
/**
|
|
82
116
|
* Default spreadsheet sizing values
|
|
83
117
|
*/
|
|
@@ -92,8 +126,28 @@ DataSpreadsheetHeader.propTypes = {
|
|
|
92
126
|
*/
|
|
93
127
|
headerGroups: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
94
128
|
|
|
129
|
+
/**
|
|
130
|
+
* All of the spreadsheet row data
|
|
131
|
+
*/
|
|
132
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
133
|
+
|
|
95
134
|
/**
|
|
96
135
|
* All of the cell selection area items
|
|
97
136
|
*/
|
|
98
|
-
selectionAreas: _propTypes.default.arrayOf(_propTypes.default.object)
|
|
137
|
+
selectionAreas: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Setter fn for activeCellCoordinates value
|
|
141
|
+
*/
|
|
142
|
+
setActiveCellCoordinates: _propTypes.default.func,
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Setter fn for currentMatcher value
|
|
146
|
+
*/
|
|
147
|
+
setCurrentMatcher: _propTypes.default.func,
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Setter fn for selectionAreas value
|
|
151
|
+
*/
|
|
152
|
+
setSelectionAreas: _propTypes.default.func
|
|
99
153
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useMoveActiveCell = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Copyright IBM Corp. 2022, 2022
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
// Moves the placement of the active cell
|
|
17
|
+
var useMoveActiveCell = function useMoveActiveCell(_ref) {
|
|
18
|
+
var spreadsheetRef = _ref.spreadsheetRef,
|
|
19
|
+
activeCellCoordinates = _ref.activeCellCoordinates,
|
|
20
|
+
containerHasFocus = _ref.containerHasFocus,
|
|
21
|
+
createActiveCell = _ref.createActiveCell;
|
|
22
|
+
(0, _react.useEffect)(function () {
|
|
23
|
+
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, "\"]"));
|
|
24
|
+
var shouldPlaceActiveCellInHeader = (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && true;
|
|
25
|
+
var selectAllElement = spreadsheetRef === null || spreadsheetRef === void 0 ? void 0 : spreadsheetRef.current.querySelector("[data-row-index=\"header\"][data-column-index=\"header\"]");
|
|
26
|
+
|
|
27
|
+
if (containerHasFocus) {
|
|
28
|
+
createActiveCell({
|
|
29
|
+
placementElement: activeCellCoordinates ? activeCellPlacementElement : selectAllElement,
|
|
30
|
+
coords: activeCellCoordinates,
|
|
31
|
+
addToHeader: shouldPlaceActiveCellInHeader
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}, [activeCellCoordinates, spreadsheetRef, createActiveCell, containerHasFocus]);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.useMoveActiveCell = useMoveActiveCell;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useResetSpreadsheetFocus = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _settings = require("../../../settings");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copyright IBM Corp. 2022, 2022
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/
|
|
18
|
+
var useResetSpreadsheetFocus = function useResetSpreadsheetFocus(_ref) {
|
|
19
|
+
var activeKeys = _ref.activeKeys,
|
|
20
|
+
_ref$blockClass = _ref.blockClass,
|
|
21
|
+
blockClass = _ref$blockClass === void 0 ? "".concat(_settings.pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
|
|
22
|
+
focusedElement = _ref.focusedElement,
|
|
23
|
+
removeActiveCell = _ref.removeActiveCell,
|
|
24
|
+
setContainerHasFocus = _ref.setContainerHasFocus;
|
|
25
|
+
// Reset everything when spreadsheet loses focus
|
|
26
|
+
(0, _react.useEffect)(function () {
|
|
27
|
+
if (!focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
|
|
28
|
+
setContainerHasFocus(false);
|
|
29
|
+
removeActiveCell();
|
|
30
|
+
activeKeys.current = [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (focusedElement.classList.contains(blockClass) || focusedElement.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
|
|
34
|
+
setContainerHasFocus(true);
|
|
35
|
+
}
|
|
36
|
+
}, [focusedElement, removeActiveCell, activeKeys, blockClass, setContainerHasFocus]);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.useResetSpreadsheetFocus = useResetSpreadsheetFocus;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSpreadsheetOutsideClick = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _settings = require("../../../settings");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copyright IBM Corp. 2022, 2022
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/
|
|
18
|
+
// Click outside useEffect for spreadsheet
|
|
19
|
+
var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref) {
|
|
20
|
+
var spreadsheetRef = _ref.spreadsheetRef,
|
|
21
|
+
_ref$blockClass = _ref.blockClass,
|
|
22
|
+
blockClass = _ref$blockClass === void 0 ? "".concat(_settings.pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
|
|
23
|
+
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
|
24
|
+
setSelectionAreas = _ref.setSelectionAreas,
|
|
25
|
+
removeActiveCell = _ref.removeActiveCell,
|
|
26
|
+
removeCellSelections = _ref.removeCellSelections,
|
|
27
|
+
setContainerHasFocus = _ref.setContainerHasFocus,
|
|
28
|
+
activeKeys = _ref.activeKeys,
|
|
29
|
+
removeCellEditor = _ref.removeCellEditor;
|
|
30
|
+
(0, _react.useEffect)(function () {
|
|
31
|
+
var handleOutsideClick = function handleOutsideClick(event) {
|
|
32
|
+
if (!spreadsheetRef.current || spreadsheetRef.current.contains(event.target) || event.target.classList.contains("".concat(blockClass, "__active-cell--highlight")) || event.target.classList.contains("".concat(blockClass, "--interactive-cell-element"))) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setActiveCellCoordinates(null);
|
|
37
|
+
setSelectionAreas([]);
|
|
38
|
+
removeActiveCell();
|
|
39
|
+
removeCellSelections();
|
|
40
|
+
setContainerHasFocus(false);
|
|
41
|
+
removeCellEditor();
|
|
42
|
+
activeKeys.current = [];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
document.addEventListener('click', handleOutsideClick);
|
|
46
|
+
return function () {
|
|
47
|
+
document.removeEventListener('click', handleOutsideClick);
|
|
48
|
+
};
|
|
49
|
+
}, [spreadsheetRef, removeActiveCell, removeCellSelections, activeKeys, blockClass, setActiveCellCoordinates, setContainerHasFocus, setSelectionAreas, removeCellEditor]);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.useSpreadsheetOutsideClick = useSpreadsheetOutsideClick;
|
package/lib/components/DataSpreadsheet/{checkActiveHeaderCell.js → utils/checkActiveHeaderCell.js}
RENAMED
|
@@ -9,7 +9,7 @@ exports.checkActiveHeaderCell = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
11
|
|
|
12
|
-
var _deepCloneObject = require("
|
|
12
|
+
var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Copyright IBM Corp. 2022, 2022
|
package/lib/components/DataSpreadsheet/{createActiveCellFn.js → utils/createActiveCellFn.js}
RENAMED
|
@@ -7,7 +7,7 @@ exports.createActiveCellFn = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _layout = require("@carbon/layout");
|
|
9
9
|
|
|
10
|
-
var _settings = require("
|
|
10
|
+
var _settings = require("../../../settings");
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Copyright IBM Corp. 2022, 2022
|
|
@@ -25,7 +25,9 @@ var createActiveCellFn = function createActiveCellFn(_ref) {
|
|
|
25
25
|
blockClass = _ref$blockClass === void 0 ? "".concat(_settings.pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
|
|
26
26
|
onActiveCellChange = _ref.onActiveCellChange,
|
|
27
27
|
activeCellValue = _ref.activeCellValue,
|
|
28
|
-
|
|
28
|
+
activeCellRef = _ref.activeCellRef,
|
|
29
|
+
cellEditorRef = _ref.cellEditorRef,
|
|
30
|
+
defaultColumn = _ref.defaultColumn;
|
|
29
31
|
|
|
30
32
|
if (!coords) {
|
|
31
33
|
return;
|
|
@@ -33,23 +35,32 @@ var createActiveCellFn = function createActiveCellFn(_ref) {
|
|
|
33
35
|
// to `.${blockClass}__header--container`, otherwise it should be appended to `.${blockClass}__listContainer` firstElementChild
|
|
34
36
|
|
|
35
37
|
|
|
38
|
+
var point1Element = document.querySelector("[data-row-index=\"".concat(coords.row, "\"][data-column-index=\"").concat(coords.column, "\"]")) || document.querySelector(".".concat(blockClass, "__body--td")); // if we can't find the point1 element (this can happen in the case where a virtualized row is not present anymore in the DOM), we get the default height/width of the first body cell we find
|
|
39
|
+
|
|
40
|
+
var selectionAreaCellWidth = point1Element.offsetWidth;
|
|
41
|
+
var selectionAreaCellHeight = point1Element.offsetHeight;
|
|
36
42
|
var activeElementContainer = addToHeader ? contextRef === null || contextRef === void 0 ? void 0 : contextRef.current.querySelector(".".concat(blockClass, "__header--container")) : contextRef === null || contextRef === void 0 ? void 0 : contextRef.current.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
|
|
37
43
|
var relativePosition = {
|
|
38
|
-
top: placementElement.getBoundingClientRect().top - activeElementContainer.getBoundingClientRect().top,
|
|
39
|
-
|
|
44
|
+
top: placementElement ? placementElement.getBoundingClientRect().top - activeElementContainer.getBoundingClientRect().top : coords.row === 0 ? 0 : selectionAreaCellHeight * coords.row,
|
|
45
|
+
// calculate top value here if virtualized row is not in DOM
|
|
46
|
+
left: placementElement ? placementElement.getBoundingClientRect().left - activeElementContainer.getBoundingClientRect().left : coords.column === 0 ? 0 + (defaultColumn.rowHeaderWidth - 4) : selectionAreaCellWidth * coords.column + (defaultColumn.rowHeaderWidth - 4) // calculate left value here if virtualized row is not in DOM, accounting for row header cell width (including borders)
|
|
47
|
+
|
|
40
48
|
};
|
|
41
|
-
var activeCellButton =
|
|
42
|
-
activeCellButton.
|
|
43
|
-
activeCellButton.
|
|
44
|
-
activeCellButton.style.width = (0, _layout.px)(placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetWidth);
|
|
45
|
-
activeCellButton.style.height = (0, _layout.px)(placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetHeight);
|
|
49
|
+
var activeCellButton = activeCellRef === null || activeCellRef === void 0 ? void 0 : activeCellRef.current;
|
|
50
|
+
activeCellButton.style.width = (0, _layout.px)(placementElement ? placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetWidth : selectionAreaCellWidth);
|
|
51
|
+
activeCellButton.style.height = (0, _layout.px)(placementElement ? placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetHeight : selectionAreaCellHeight);
|
|
46
52
|
activeCellButton.style.left = (0, _layout.px)(relativePosition.left);
|
|
47
53
|
activeCellButton.style.top = (0, _layout.px)(relativePosition.top);
|
|
54
|
+
activeCellButton.style.display = 'block';
|
|
48
55
|
activeCellButton.setAttribute('data-active-row-index', typeof (coords === null || coords === void 0 ? void 0 : coords.row) === 'number' ? coords.row : 'header');
|
|
49
56
|
activeCellButton.setAttribute('data-active-column-index', typeof (coords === null || coords === void 0 ? void 0 : coords.column) === 'number' ? coords.column : 'header');
|
|
50
57
|
activeElementContainer.appendChild(activeCellButton);
|
|
51
58
|
activeCellButton.focus();
|
|
52
59
|
|
|
60
|
+
if (!addToHeader) {
|
|
61
|
+
activeElementContainer.appendChild(cellEditorRef.current);
|
|
62
|
+
}
|
|
63
|
+
|
|
53
64
|
if (typeof (coords === null || coords === void 0 ? void 0 : coords.column) === 'number' && typeof (coords === null || coords === void 0 ? void 0 : coords.row) === 'number') {
|
|
54
65
|
onActiveCellChange === null || onActiveCellChange === void 0 ? void 0 : onActiveCellChange(activeCellValue);
|
|
55
66
|
}
|
|
@@ -7,7 +7,7 @@ exports.createCellSelectionArea = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _layout = require("@carbon/layout");
|
|
9
9
|
|
|
10
|
-
var _deepCloneObject = require("
|
|
10
|
+
var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Copyright IBM Corp. 2022, 2022
|
|
@@ -18,13 +18,15 @@ var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
|
|
|
18
18
|
var createCellSelectionArea = function createCellSelectionArea(_ref) {
|
|
19
19
|
var area = _ref.area,
|
|
20
20
|
blockClass = _ref.blockClass,
|
|
21
|
+
defaultColumn = _ref.defaultColumn,
|
|
21
22
|
selectionAreas = _ref.selectionAreas,
|
|
22
23
|
setSelectionAreas = _ref.setSelectionAreas;
|
|
23
24
|
var greatestRow = Math.max(area.point1.row, area.point2.row);
|
|
24
25
|
var greatestColumn = Math.max(area.point1.column, area.point2.column);
|
|
25
26
|
var lowestRowIndex = Math.min(area.point1.row, area.point2.row);
|
|
26
27
|
var lowestColumnIndex = Math.min(area.point1.column, area.point2.column);
|
|
27
|
-
var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]"));
|
|
28
|
+
var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]")) || document.querySelector(".".concat(blockClass, "__body--td")); // if we can't find the point1 element (this can happen in the case where a virtualized row is not present anymore in the DOM), we get the default height/width of the first body cell we find
|
|
29
|
+
|
|
28
30
|
var selectionAreaCellWidth = point1Element.offsetWidth;
|
|
29
31
|
var selectionAreaCellHeight = point1Element.offsetHeight;
|
|
30
32
|
var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumn - lowestColumnIndex + 1);
|
|
@@ -32,8 +34,10 @@ var createCellSelectionArea = function createCellSelectionArea(_ref) {
|
|
|
32
34
|
var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
|
|
33
35
|
var placementElement = bodyContainer.querySelector("[data-row-index=\"".concat(lowestRowIndex, "\"][data-column-index=\"").concat(lowestColumnIndex, "\"]"));
|
|
34
36
|
var relativePosition = {
|
|
35
|
-
top: placementElement.getBoundingClientRect().top - bodyContainer.getBoundingClientRect().top,
|
|
36
|
-
|
|
37
|
+
top: placementElement ? placementElement.getBoundingClientRect().top - bodyContainer.getBoundingClientRect().top : lowestRowIndex === 0 ? 0 : selectionAreaCellHeight * lowestRowIndex,
|
|
38
|
+
// calculate top value here if virtualized row is not in DOM
|
|
39
|
+
left: placementElement ? placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left : lowestColumnIndex === 0 ? 0 + (defaultColumn.rowHeaderWidth - 4) : selectionAreaCellWidth * lowestColumnIndex + (defaultColumn.rowHeaderWidth - 4) // calculate left value here if virtualized row is not in DOM, accounting for row header cell width (including borders)
|
|
40
|
+
|
|
37
41
|
};
|
|
38
42
|
var selectionAreaElement = document.querySelector("[data-matcher-id=\"".concat(area.matcher, "\"]")) || document.createElement('div');
|
|
39
43
|
selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
|
|
@@ -13,6 +13,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
13
13
|
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Copyright IBM Corp. 2022, 2022
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/
|
|
16
22
|
// cspell:disable
|
|
17
23
|
var pets = ['dog', 'cat', 'bird', 'lizard', 'frog', 'hamster', 'fish', 'rabbit', 'snake'];
|
|
18
24
|
var petNames = ['Bruno', 'Willow', 'Kona', 'Heidi', 'Rusty', 'Bonnie', 'Cash', 'Gucci', 'Brody', 'Emma', 'Loki', 'Angel', 'Astro', 'Sherman', 'Layla', 'Peanut', 'Grace', 'Mickey', 'Sasha', 'Finn', 'Tucker', 'Bear', 'Mocha', 'Roscoe']; // cspell:enable
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.handleHeaderCellSelection = void 0;
|
|
9
|
+
|
|
10
|
+
var _uuidv = _interopRequireDefault(require("../../../global/js/utils/uuidv4"));
|
|
11
|
+
|
|
12
|
+
var _removeCellSelections = require("./removeCellSelections");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Copyright IBM Corp. 2022, 2022
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
18
|
+
* LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/
|
|
20
|
+
var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
|
|
21
|
+
var type = _ref.type,
|
|
22
|
+
activeCellCoordinates = _ref.activeCellCoordinates,
|
|
23
|
+
rows = _ref.rows,
|
|
24
|
+
columns = _ref.columns,
|
|
25
|
+
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
|
26
|
+
setCurrentMatcher = _ref.setCurrentMatcher,
|
|
27
|
+
setSelectionAreas = _ref.setSelectionAreas,
|
|
28
|
+
spreadsheetRef = _ref.spreadsheetRef,
|
|
29
|
+
index = _ref.index,
|
|
30
|
+
isKeyboard = _ref.isKeyboard;
|
|
31
|
+
var rowValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row : index;
|
|
32
|
+
var columnValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column : index;
|
|
33
|
+
var point1 = {
|
|
34
|
+
row: type === 'column' ? 0 : rowValue,
|
|
35
|
+
column: type === 'column' ? columnValue : 0
|
|
36
|
+
};
|
|
37
|
+
var point2 = {
|
|
38
|
+
row: type === 'column' ? rows.length - 1 : rowValue,
|
|
39
|
+
// going to always be the last row
|
|
40
|
+
column: type === 'column' ? columnValue : columns.length - 1
|
|
41
|
+
};
|
|
42
|
+
var tempMatcher = (0, _uuidv.default)();
|
|
43
|
+
setActiveCellCoordinates({
|
|
44
|
+
row: type === 'column' ? 0 : rowValue,
|
|
45
|
+
column: type === 'column' ? columnValue : 0
|
|
46
|
+
});
|
|
47
|
+
setCurrentMatcher(tempMatcher);
|
|
48
|
+
(0, _removeCellSelections.removeCellSelections)({
|
|
49
|
+
spreadsheetRef: spreadsheetRef
|
|
50
|
+
});
|
|
51
|
+
setSelectionAreas([{
|
|
52
|
+
point1: point1,
|
|
53
|
+
point2: point2,
|
|
54
|
+
areaCreated: false,
|
|
55
|
+
matcher: tempMatcher
|
|
56
|
+
}]);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
exports.handleHeaderCellSelection = handleHeaderCellSelection;
|