@carbon/ibm-products 1.11.1 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -3
- package/css/index-full-carbon.css +1445 -369
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +6 -6
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +15 -6
- 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 +109 -16
- 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 +109 -16
- package/css/index.css.map +1 -1
- package/css/index.min.css +6 -6
- package/css/index.min.css.map +1 -1
- package/es/components/ActionBar/ActionBar.js +3 -1
- package/es/components/ActionBar/ActionBarOverflowItems.js +5 -3
- package/es/components/AddSelect/AddSelect.js +63 -12
- package/es/components/AddSelect/AddSelectColumn.js +0 -1
- package/es/components/AddSelect/AddSelectList.js +59 -13
- package/es/components/AddSelect/AddSelectSidebar.js +15 -5
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
- package/es/components/CreateFullPage/CreateFullPageStep.js +4 -4
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +4 -4
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +193 -119
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +178 -51
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +50 -2
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -4
- package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +3 -1
- package/es/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
- package/es/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
- package/es/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
- package/es/components/ImportModal/ImportModal.js +2 -2
- package/es/components/TagSet/TagSet.js +12 -3
- package/es/components/UserProfileImage/UserProfileImage.js +38 -10
- package/lib/components/ActionBar/ActionBar.js +3 -1
- package/lib/components/ActionBar/ActionBarOverflowItems.js +5 -3
- package/lib/components/AddSelect/AddSelect.js +63 -12
- package/lib/components/AddSelect/AddSelectColumn.js +0 -1
- package/lib/components/AddSelect/AddSelectList.js +61 -12
- package/lib/components/AddSelect/AddSelectSidebar.js +15 -11
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -0
- package/lib/components/CreateFullPage/CreateFullPageStep.js +4 -4
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +4 -4
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +196 -120
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +178 -51
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +52 -7
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetOutsideClick.js +6 -3
- package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +3 -1
- package/lib/components/HTTPErrors/assets/HTTPErrorSvg403.js +2 -3
- package/lib/components/HTTPErrors/assets/HTTPErrorSvg404.js +2 -3
- package/lib/components/HTTPErrors/assets/HTTPErrorSvgOther.js +2 -3
- package/lib/components/ImportModal/ImportModal.js +1 -1
- package/lib/components/TagSet/TagSet.js +12 -3
- package/lib/components/UserProfileImage/UserProfileImage.js +38 -10
- package/package.json +15 -15
- package/scss/components/AboutModal/_about-modal.scss +2 -2
- package/scss/components/ActionSet/_action-set.scss +3 -1
- package/scss/components/AddSelect/_add-select.scss +50 -3
- package/scss/components/CreateModal/_create-modal.scss +7 -5
- package/scss/components/CreateModal/_storybook-styles.scss +8 -7
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +57 -7
- package/scss/components/ExportModal/_export-modal.scss +3 -3
- package/scss/components/HTTPErrors/_http-errors.scss +16 -16
- package/scss/components/InlineEdit/_inline-edit.scss +0 -1
- package/scss/components/ModifiedTabs/_modified-tabs.scss +0 -10
- package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -3
- package/scss/components/OptionsTile/_options-tile.scss +0 -1
- package/scss/components/PageHeader/_page-header.scss +4 -0
- package/scss/components/RemoveModal/_remove-modal.scss +3 -3
- package/scss/components/TagSet/_tag-set.scss +2 -1
- package/scss/components/Tearsheet/_tearsheet.scss +1 -2
@@ -12,9 +12,11 @@ import React, { useRef, useCallback, useEffect, forwardRef } from 'react';
|
|
12
12
|
import PropTypes from 'prop-types';
|
13
13
|
import { FixedSizeList } from 'react-window';
|
14
14
|
import cx from 'classnames';
|
15
|
+
import { px } from '@carbon/layout';
|
15
16
|
import { pkg } from '../../settings';
|
16
17
|
import { deepCloneObject } from '../../global/js/utils/deepCloneObject';
|
17
18
|
import uuidv4 from '../../global/js/utils/uuidv4';
|
19
|
+
import { usePreviousValue } from '../../global/js/hooks';
|
18
20
|
import { removeCellSelections } from './utils/removeCellSelections';
|
19
21
|
import { createCellSelectionArea } from './utils/createCellSelectionArea';
|
20
22
|
import { checkActiveHeaderCell } from './utils/checkActiveHeaderCell';
|
@@ -24,10 +26,15 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
24
26
|
var columns = _ref.columns,
|
25
27
|
activeCellCoordinates = _ref.activeCellCoordinates,
|
26
28
|
defaultColumn = _ref.defaultColumn,
|
29
|
+
defaultEmptyRowCount = _ref.defaultEmptyRowCount,
|
27
30
|
getTableBodyProps = _ref.getTableBodyProps,
|
31
|
+
headerGroups = _ref.headerGroups,
|
28
32
|
id = _ref.id,
|
33
|
+
onDataUpdate = _ref.onDataUpdate,
|
29
34
|
prepareRow = _ref.prepareRow,
|
30
35
|
rows = _ref.rows,
|
36
|
+
selectionAreaData = _ref.selectionAreaData,
|
37
|
+
setSelectionAreaData = _ref.setSelectionAreaData,
|
31
38
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
32
39
|
selectionAreas = _ref.selectionAreas,
|
33
40
|
setContainerHasFocus = _ref.setContainerHasFocus,
|
@@ -37,24 +44,64 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
37
44
|
clickAndHoldActive = _ref.clickAndHoldActive,
|
38
45
|
setClickAndHoldActive = _ref.setClickAndHoldActive,
|
39
46
|
currentMatcher = _ref.currentMatcher,
|
40
|
-
setCurrentMatcher = _ref.setCurrentMatcher
|
41
|
-
|
47
|
+
setCurrentMatcher = _ref.setCurrentMatcher,
|
48
|
+
onSelectionAreaChange = _ref.onSelectionAreaChange;
|
49
|
+
var previousState = usePreviousValue({
|
50
|
+
selectionAreaData: selectionAreaData,
|
51
|
+
clickAndHoldActive: clickAndHoldActive
|
52
|
+
}); // Set custom css property containing the spreadsheet total width
|
53
|
+
|
54
|
+
useEffect(function () {
|
55
|
+
ref === null || ref === void 0 ? void 0 : ref.current.style.setProperty("--".concat(blockClass, "--total-width"), px(totalColumnsWidth + scrollBarSize));
|
56
|
+
}, [ref, scrollBarSize, totalColumnsWidth]); // Call the `onSelectionAreaChange` handler to send selection area data
|
57
|
+
// back to the consumer
|
58
|
+
|
59
|
+
useEffect(function () {
|
60
|
+
if (selectionAreaData.length) {
|
61
|
+
var _previousState$select;
|
62
|
+
|
63
|
+
if (!clickAndHoldActive && previousState !== null && previousState !== void 0 && previousState.clickAndHoldActive || (previousState === null || previousState === void 0 ? void 0 : (_previousState$select = previousState.selectionAreaData) === null || _previousState$select === void 0 ? void 0 : _previousState$select.length) !== (selectionAreaData === null || selectionAreaData === void 0 ? void 0 : selectionAreaData.length)) {
|
64
|
+
onSelectionAreaChange(selectionAreaData);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}, [previousState === null || previousState === void 0 ? void 0 : previousState.selectionAreaData, selectionAreaData, onSelectionAreaChange, clickAndHoldActive, previousState === null || previousState === void 0 ? void 0 : previousState.clickAndHoldActive]); // Create cell selection areas based on selectionAreas array
|
68
|
+
|
42
69
|
useEffect(function () {
|
43
70
|
if (selectionAreas && selectionAreas.length) {
|
44
71
|
selectionAreas.map(function (area) {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
72
|
+
// Setup selection area data that will be sent back to consumer via onSelectionAreaChange prop
|
73
|
+
if (area.areaCreated) {
|
74
|
+
var rowStart = Math.min(area.point1.row, area.point2.row);
|
75
|
+
var rowEnd = Math.max(area.point1.row, area.point2.row);
|
76
|
+
var columnStart = Math.min(area.point1.column, area.point2.column);
|
77
|
+
var columnEnd = Math.max(area.point1.column, area.point2.column);
|
78
|
+
var selectionData = {
|
79
|
+
rows: {
|
80
|
+
start: rowStart,
|
81
|
+
end: rowEnd
|
82
|
+
},
|
83
|
+
columns: {
|
84
|
+
start: columnStart,
|
85
|
+
end: columnEnd
|
86
|
+
},
|
87
|
+
cells: populateSelectionAreaCellData({
|
88
|
+
rowStart: rowStart,
|
89
|
+
rowEnd: rowEnd,
|
90
|
+
columnStart: columnStart,
|
91
|
+
columnEnd: columnEnd
|
92
|
+
}),
|
93
|
+
selectionId: area.matcher
|
94
|
+
};
|
95
|
+
setSelectionAreaData(function (prev) {
|
96
|
+
var prevValues = deepCloneObject(prev);
|
97
|
+
var newAreaData = prevValues.filter(function (item) {
|
98
|
+
return item.selectionId !== area.matcher;
|
52
99
|
});
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
100
|
+
return [].concat(_toConsumableArray(newAreaData), [selectionData]);
|
101
|
+
});
|
102
|
+
}
|
57
103
|
|
104
|
+
if (!area.areaCreated && area.point1 && area.point2 && area.matcher) {
|
58
105
|
createCellSelectionArea({
|
59
106
|
area: area,
|
60
107
|
blockClass: blockClass,
|
@@ -67,7 +114,24 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
67
114
|
return;
|
68
115
|
});
|
69
116
|
}
|
70
|
-
}, [selectionAreas, setSelectionAreas, defaultColumn]);
|
117
|
+
}, [selectionAreas, setSelectionAreas, defaultColumn, onSelectionAreaChange, setSelectionAreaData]);
|
118
|
+
|
119
|
+
var populateSelectionAreaCellData = function populateSelectionAreaCellData(_ref2) {
|
120
|
+
var rowStart = _ref2.rowStart,
|
121
|
+
rowEnd = _ref2.rowEnd,
|
122
|
+
columnStart = _ref2.columnStart,
|
123
|
+
columnEnd = _ref2.columnEnd;
|
124
|
+
var cellContainer = [];
|
125
|
+
|
126
|
+
for (var rowIndex = rowStart; rowIndex <= rowEnd; rowIndex++) {
|
127
|
+
for (var columnIndex = columnStart; columnIndex <= columnEnd; columnIndex++) {
|
128
|
+
cellContainer.push([rowIndex, columnIndex]);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
return cellContainer;
|
133
|
+
}; // Mouse up
|
134
|
+
|
71
135
|
|
72
136
|
useEffect(function () {
|
73
137
|
var handleMouseUp = function handleMouseUp(event) {
|
@@ -168,9 +232,10 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
168
232
|
matcher: tempMatcher
|
169
233
|
}]);
|
170
234
|
setCurrentMatcher(tempMatcher);
|
235
|
+
setSelectionAreaData([]);
|
171
236
|
}
|
172
237
|
};
|
173
|
-
}, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref]);
|
238
|
+
}, [currentMatcher, activeCellCoordinates, selectionAreas, setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher, ref, setSelectionAreaData]);
|
174
239
|
var handleBodyCellHover = useCallback(function (cell, columnIndex) {
|
175
240
|
return function () {
|
176
241
|
if (clickAndHoldActive) {
|
@@ -213,45 +278,77 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
213
278
|
setCurrentMatcher: setCurrentMatcher,
|
214
279
|
setSelectionAreas: setSelectionAreas,
|
215
280
|
spreadsheetRef: ref,
|
216
|
-
index: index
|
281
|
+
index: index,
|
282
|
+
setSelectionAreaData: setSelectionAreaData
|
217
283
|
});
|
218
284
|
};
|
219
|
-
}, [columns, ref, setSelectionAreas, setCurrentMatcher, setActiveCellCoordinates, activeCellCoordinates, rows]); //
|
285
|
+
}, [columns, ref, setSelectionAreas, setCurrentMatcher, setActiveCellCoordinates, activeCellCoordinates, rows, setSelectionAreaData]); // Builds the empty rows and calls `onDataUpdate` to set the new empty rows
|
286
|
+
// using defaultEmptyRowCount to determine how many empty rows are created.
|
287
|
+
|
288
|
+
useEffect(function () {
|
289
|
+
if (!(rows !== null && rows !== void 0 && rows.length)) {
|
290
|
+
var buildEmptyRows = function buildEmptyRows() {
|
291
|
+
var emptyRowData = [];
|
292
|
+
|
293
|
+
_toConsumableArray(Array(defaultEmptyRowCount)).map(function () {
|
294
|
+
var _headerGroups$;
|
220
295
|
|
221
|
-
|
222
|
-
|
223
|
-
|
296
|
+
var emptyCell = {};
|
297
|
+
(_headerGroups$ = headerGroups[0]) === null || _headerGroups$ === void 0 ? void 0 : _headerGroups$.headers.map(function (header) {
|
298
|
+
emptyCell[header.id] = null;
|
299
|
+
});
|
300
|
+
emptyRowData.push(emptyCell);
|
301
|
+
});
|
302
|
+
|
303
|
+
onDataUpdate(emptyRowData);
|
304
|
+
};
|
305
|
+
|
306
|
+
buildEmptyRows();
|
307
|
+
}
|
308
|
+
}, [rows, headerGroups, defaultEmptyRowCount, onDataUpdate]);
|
309
|
+
|
310
|
+
var RenderEmptyRows = function RenderEmptyRows() {
|
311
|
+
return /*#__PURE__*/React.createElement("div", null);
|
312
|
+
}; // Renders each row/cell in the spreadsheet body
|
313
|
+
|
314
|
+
|
315
|
+
var RenderRow = useCallback(function (_ref3) {
|
316
|
+
var index = _ref3.index,
|
317
|
+
style = _ref3.style;
|
224
318
|
var row = rows[index];
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
"
|
234
|
-
"data-column-index": "header",
|
235
|
-
type: "button",
|
236
|
-
onClick: handleRowHeaderClick(index),
|
237
|
-
className: cx("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element"), _defineProperty({}, "".concat(blockClass, "__td-th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === index || checkActiveHeaderCell(index, selectionAreas, 'row'))),
|
238
|
-
style: {
|
239
|
-
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
|
240
|
-
}
|
241
|
-
}, index + 1), row.cells.map(function (cell, index) {
|
242
|
-
return /*#__PURE__*/React.createElement("button", _extends({
|
319
|
+
|
320
|
+
if (rows && rows.length) {
|
321
|
+
prepareRow(row);
|
322
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, row.getRowProps({
|
323
|
+
style: style
|
324
|
+
}), {
|
325
|
+
className: cx("".concat(blockClass, "__tr")),
|
326
|
+
"data-row-index": index
|
327
|
+
}), /*#__PURE__*/React.createElement("button", {
|
243
328
|
tabIndex: -1,
|
244
|
-
"data-row-index":
|
245
|
-
"data-column-index":
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
329
|
+
"data-row-index": index,
|
330
|
+
"data-column-index": "header",
|
331
|
+
type: "button",
|
332
|
+
onClick: handleRowHeaderClick(index),
|
333
|
+
className: cx("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element"), _defineProperty({}, "".concat(blockClass, "__td-th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === index || checkActiveHeaderCell(index, selectionAreas, 'row'))),
|
334
|
+
style: {
|
335
|
+
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
|
336
|
+
}
|
337
|
+
}, index + 1), row.cells.map(function (cell, index) {
|
338
|
+
return /*#__PURE__*/React.createElement("button", _extends({
|
339
|
+
tabIndex: -1,
|
340
|
+
"data-row-index": cell.row.index,
|
341
|
+
"data-column-index": index
|
342
|
+
}, cell.getCellProps(), {
|
343
|
+
className: cx("".concat(blockClass, "__td"), "".concat(blockClass, "__body--td"), "".concat(blockClass, "--interactive-cell-element")),
|
344
|
+
key: "cell_".concat(index),
|
345
|
+
onMouseDown: handleBodyCellClick(cell, index),
|
346
|
+
onMouseOver: handleBodyCellHover(cell, index),
|
347
|
+
onFocus: function onFocus() {},
|
348
|
+
type: "button"
|
349
|
+
}), cell.render('Cell'));
|
350
|
+
}));
|
351
|
+
}
|
255
352
|
}, [prepareRow, rows, defaultColumn.rowHeaderWidth, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas, handleRowHeaderClick, handleBodyCellClick, handleBodyCellHover]);
|
256
353
|
var spreadsheetBodyRef = useRef();
|
257
354
|
return /*#__PURE__*/React.createElement("div", _extends({
|
@@ -260,10 +357,10 @@ export var DataSpreadsheetBody = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
260
357
|
}, getTableBodyProps()), /*#__PURE__*/React.createElement(FixedSizeList, {
|
261
358
|
className: cx("".concat(blockClass, "__list--container"), "".concat(blockClass, "__list--container--").concat(id)),
|
262
359
|
height: 400,
|
263
|
-
itemCount: rows.length,
|
360
|
+
itemCount: rows.length || defaultEmptyRowCount,
|
264
361
|
itemSize: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
265
362
|
width: totalColumnsWidth + scrollBarSize
|
266
|
-
}, RenderRow));
|
363
|
+
}, rows !== null && rows !== void 0 && rows.length ? RenderRow : RenderEmptyRows));
|
267
364
|
});
|
268
365
|
DataSpreadsheetBody.propTypes = {
|
269
366
|
/**
|
@@ -298,11 +395,21 @@ DataSpreadsheetBody.propTypes = {
|
|
298
395
|
width: PropTypes.number
|
299
396
|
}),
|
300
397
|
|
398
|
+
/**
|
399
|
+
* Sets the number of empty rows to be created when there is no data provided
|
400
|
+
*/
|
401
|
+
defaultEmptyRowCount: PropTypes.number,
|
402
|
+
|
301
403
|
/**
|
302
404
|
* Function to set table body prop values
|
303
405
|
*/
|
304
406
|
getTableBodyProps: PropTypes.func,
|
305
407
|
|
408
|
+
/**
|
409
|
+
* Headers provided from useTable hook
|
410
|
+
*/
|
411
|
+
headerGroups: PropTypes.arrayOf(PropTypes.object),
|
412
|
+
|
306
413
|
/**
|
307
414
|
* The spreadsheet id
|
308
415
|
*/
|
@@ -313,6 +420,16 @@ DataSpreadsheetBody.propTypes = {
|
|
313
420
|
*/
|
314
421
|
onActiveCellChange: PropTypes.func,
|
315
422
|
|
423
|
+
/**
|
424
|
+
* The event handler that is called to set the rows for the empty spreadsheet
|
425
|
+
*/
|
426
|
+
onDataUpdate: PropTypes.func,
|
427
|
+
|
428
|
+
/**
|
429
|
+
* The event handler that is called when the selection areas change
|
430
|
+
*/
|
431
|
+
onSelectionAreaChange: PropTypes.func,
|
432
|
+
|
316
433
|
/**
|
317
434
|
* Prepare row function from react-table
|
318
435
|
*/
|
@@ -328,6 +445,11 @@ DataSpreadsheetBody.propTypes = {
|
|
328
445
|
*/
|
329
446
|
scrollBarSize: PropTypes.number,
|
330
447
|
|
448
|
+
/**
|
449
|
+
* Array of selection area data
|
450
|
+
*/
|
451
|
+
selectionAreaData: PropTypes.array,
|
452
|
+
|
331
453
|
/**
|
332
454
|
* Array of selection areas
|
333
455
|
*/
|
@@ -353,6 +475,11 @@ DataSpreadsheetBody.propTypes = {
|
|
353
475
|
*/
|
354
476
|
setCurrentMatcher: PropTypes.func,
|
355
477
|
|
478
|
+
/**
|
479
|
+
* Setter fn for selectionAreaData state value
|
480
|
+
*/
|
481
|
+
setSelectionAreaData: PropTypes.func,
|
482
|
+
|
356
483
|
/**
|
357
484
|
* Setter fn for selectionAreas state value
|
358
485
|
*/
|
@@ -1,5 +1,10 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
|
+
|
5
|
+
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; }
|
6
|
+
|
7
|
+
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) { _defineProperty(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; }
|
3
8
|
|
4
9
|
/**
|
5
10
|
* Copyright IBM Corp. 2022, 2022
|
@@ -7,24 +12,48 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
12
|
* This source code is licensed under the Apache-2.0 license found in the
|
8
13
|
* LICENSE file in the root directory of this source tree.
|
9
14
|
*/
|
10
|
-
import React, { forwardRef } from 'react';
|
15
|
+
import React, { forwardRef, useEffect, useState } from 'react';
|
11
16
|
import PropTypes from 'prop-types';
|
12
17
|
import cx from 'classnames';
|
18
|
+
import { px } from '@carbon/layout';
|
13
19
|
import { pkg } from '../../settings';
|
14
20
|
import { checkActiveHeaderCell } from './utils/checkActiveHeaderCell';
|
15
21
|
import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection';
|
22
|
+
import { usePreviousValue } from '../../global/js/hooks';
|
16
23
|
var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
|
17
24
|
export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
18
25
|
var activeCellCoordinates = _ref.activeCellCoordinates,
|
26
|
+
cellSize = _ref.cellSize,
|
19
27
|
columns = _ref.columns,
|
20
28
|
defaultColumn = _ref.defaultColumn,
|
21
29
|
headerGroups = _ref.headerGroups,
|
30
|
+
scrollBarSize = _ref.scrollBarSize,
|
22
31
|
selectionAreas = _ref.selectionAreas,
|
23
32
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
24
33
|
setCurrentMatcher = _ref.setCurrentMatcher,
|
25
34
|
setSelectionAreas = _ref.setSelectionAreas,
|
35
|
+
setSelectionAreaData = _ref.setSelectionAreaData,
|
26
36
|
rows = _ref.rows;
|
27
37
|
|
38
|
+
var _useState = useState(0),
|
39
|
+
_useState2 = _slicedToArray(_useState, 2),
|
40
|
+
scrollBarSizeValue = _useState2[0],
|
41
|
+
setScrollBarSizeValue = _useState2[1];
|
42
|
+
|
43
|
+
var previousState = usePreviousValue({
|
44
|
+
cellSize: cellSize
|
45
|
+
});
|
46
|
+
useEffect(function () {
|
47
|
+
if ((previousState === null || previousState === void 0 ? void 0 : previousState.cellSize) !== cellSize) {
|
48
|
+
var _ref$current;
|
49
|
+
|
50
|
+
var scrollContainer = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector(".".concat(blockClass, "__list--container"));
|
51
|
+
var hasScrollBar = (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.scrollHeight) > (scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.clientHeight);
|
52
|
+
var scrollBarValue = hasScrollBar ? 0 : scrollBarSize;
|
53
|
+
setScrollBarSizeValue(scrollBarValue);
|
54
|
+
}
|
55
|
+
}, [cellSize, ref, scrollBarSize, previousState === null || previousState === void 0 ? void 0 : previousState.cellSize]);
|
56
|
+
|
28
57
|
var handleColumnHeaderClick = function handleColumnHeaderClick(index) {
|
29
58
|
return function () {
|
30
59
|
handleHeaderCellSelection({
|
@@ -36,7 +65,8 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
|
|
36
65
|
setCurrentMatcher: setCurrentMatcher,
|
37
66
|
setSelectionAreas: setSelectionAreas,
|
38
67
|
spreadsheetRef: ref,
|
39
|
-
index: index
|
68
|
+
index: index,
|
69
|
+
setSelectionAreaData: setSelectionAreaData
|
40
70
|
});
|
41
71
|
};
|
42
72
|
};
|
@@ -47,6 +77,9 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
|
|
47
77
|
return /*#__PURE__*/React.createElement("div", _extends({
|
48
78
|
key: "header_".concat(index)
|
49
79
|
}, headerGroup.getHeaderGroupProps(), {
|
80
|
+
style: _objectSpread(_objectSpread({}, headerGroup.getHeaderGroupProps().style), {}, {
|
81
|
+
width: px(parseInt(headerGroup.getHeaderGroupProps().style.width) + scrollBarSizeValue)
|
82
|
+
}),
|
50
83
|
className: "".concat(blockClass, "__tr")
|
51
84
|
}), /*#__PURE__*/React.createElement("button", {
|
52
85
|
"data-row-index": "header",
|
@@ -84,6 +117,11 @@ DataSpreadsheetHeader.propTypes = {
|
|
84
117
|
column: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
85
118
|
}),
|
86
119
|
|
120
|
+
/**
|
121
|
+
* Specifies the cell height
|
122
|
+
*/
|
123
|
+
cellSize: PropTypes.oneOf(['compact', 'standard', 'medium', 'large']),
|
124
|
+
|
87
125
|
/**
|
88
126
|
* All of the spreadsheet columns
|
89
127
|
*/
|
@@ -108,6 +146,11 @@ DataSpreadsheetHeader.propTypes = {
|
|
108
146
|
*/
|
109
147
|
rows: PropTypes.arrayOf(PropTypes.object),
|
110
148
|
|
149
|
+
/**
|
150
|
+
* The scrollbar width
|
151
|
+
*/
|
152
|
+
scrollBarSize: PropTypes.number,
|
153
|
+
|
111
154
|
/**
|
112
155
|
* All of the cell selection area items
|
113
156
|
*/
|
@@ -123,6 +166,11 @@ DataSpreadsheetHeader.propTypes = {
|
|
123
166
|
*/
|
124
167
|
setCurrentMatcher: PropTypes.func,
|
125
168
|
|
169
|
+
/**
|
170
|
+
* Setter fn for selectionAreaData state value
|
171
|
+
*/
|
172
|
+
setSelectionAreaData: PropTypes.func,
|
173
|
+
|
126
174
|
/**
|
127
175
|
* Setter fn for selectionAreas value
|
128
176
|
*/
|
@@ -5,7 +5,8 @@
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
import { useEffect } from 'react';
|
8
|
-
import { pkg } from '../../../settings';
|
8
|
+
import { pkg } from '../../../settings';
|
9
|
+
import { removeCellSelections } from '../utils/removeCellSelections'; // Click outside useEffect for spreadsheet
|
9
10
|
|
10
11
|
export var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref) {
|
11
12
|
var spreadsheetRef = _ref.spreadsheetRef,
|
@@ -14,7 +15,6 @@ export var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref
|
|
14
15
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
15
16
|
setSelectionAreas = _ref.setSelectionAreas,
|
16
17
|
removeActiveCell = _ref.removeActiveCell,
|
17
|
-
removeCellSelections = _ref.removeCellSelections,
|
18
18
|
setContainerHasFocus = _ref.setContainerHasFocus,
|
19
19
|
activeKeys = _ref.activeKeys,
|
20
20
|
removeCellEditor = _ref.removeCellEditor;
|
@@ -27,7 +27,9 @@ export var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref
|
|
27
27
|
setActiveCellCoordinates(null);
|
28
28
|
setSelectionAreas([]);
|
29
29
|
removeActiveCell();
|
30
|
-
removeCellSelections(
|
30
|
+
removeCellSelections({
|
31
|
+
spreadsheetRef: spreadsheetRef
|
32
|
+
});
|
31
33
|
setContainerHasFocus(false);
|
32
34
|
removeCellEditor();
|
33
35
|
activeKeys.current = [];
|
@@ -37,5 +39,5 @@ export var useSpreadsheetOutsideClick = function useSpreadsheetOutsideClick(_ref
|
|
37
39
|
return function () {
|
38
40
|
document.removeEventListener('click', handleOutsideClick);
|
39
41
|
};
|
40
|
-
}, [spreadsheetRef, removeActiveCell,
|
42
|
+
}, [spreadsheetRef, removeActiveCell, activeKeys, blockClass, setActiveCellCoordinates, setContainerHasFocus, setSelectionAreas, removeCellEditor]);
|
41
43
|
};
|
@@ -16,7 +16,9 @@ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref)
|
|
16
16
|
setSelectionAreas = _ref.setSelectionAreas,
|
17
17
|
spreadsheetRef = _ref.spreadsheetRef,
|
18
18
|
index = _ref.index,
|
19
|
-
isKeyboard = _ref.isKeyboard
|
19
|
+
isKeyboard = _ref.isKeyboard,
|
20
|
+
setSelectionAreaData = _ref.setSelectionAreaData;
|
21
|
+
setSelectionAreaData([]);
|
20
22
|
var rowValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row : index;
|
21
23
|
var columnValue = isKeyboard ? activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column : index;
|
22
24
|
var point1 = {
|
@@ -13,10 +13,9 @@ export var HTTPErrorSvg403 = function HTTPErrorSvg403(_ref) {
|
|
13
13
|
return /*#__PURE__*/React.createElement("svg", {
|
14
14
|
xmlns: "http://www.w3.org/2000/svg",
|
15
15
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
16
|
-
width: 1584,
|
17
|
-
height: 916,
|
18
16
|
viewBox: "0 0 1584 916",
|
19
|
-
className: className
|
17
|
+
className: className,
|
18
|
+
preserveAspectRatio: "xMinYMax meet"
|
20
19
|
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
21
20
|
id: "prefix__clip-path"
|
22
21
|
}, /*#__PURE__*/React.createElement("path", {
|
@@ -13,10 +13,9 @@ export var HTTPErrorSvg404 = function HTTPErrorSvg404(_ref) {
|
|
13
13
|
return /*#__PURE__*/React.createElement("svg", {
|
14
14
|
xmlns: "http://www.w3.org/2000/svg",
|
15
15
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
16
|
-
width: 1584,
|
17
|
-
height: 916,
|
18
16
|
viewBox: "0 0 1584 916",
|
19
|
-
className: className
|
17
|
+
className: className,
|
18
|
+
preserveAspectRatio: "xMinYMax meet"
|
20
19
|
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
21
20
|
id: "prefix__clip-path"
|
22
21
|
}, /*#__PURE__*/React.createElement("path", {
|
@@ -13,10 +13,9 @@ export var HTTPErrorSvgOther = function HTTPErrorSvgOther(_ref) {
|
|
13
13
|
return /*#__PURE__*/React.createElement("svg", {
|
14
14
|
xmlns: "http://www.w3.org/2000/svg",
|
15
15
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
16
|
-
width: 1584,
|
17
|
-
height: 916,
|
18
16
|
viewBox: "0 0 1584 916",
|
19
|
-
className: className
|
17
|
+
className: className,
|
18
|
+
preserveAspectRatio: "xMinYMax meet"
|
20
19
|
}, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("clipPath", {
|
21
20
|
id: "prefix__clip-path"
|
22
21
|
}, /*#__PURE__*/React.createElement("path", {
|
@@ -23,7 +23,7 @@ import cx from 'classnames';
|
|
23
23
|
import PropTypes from 'prop-types';
|
24
24
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
25
25
|
import uuidv4 from '../../global/js/utils/uuidv4';
|
26
|
-
import { pkg } from '../../settings';
|
26
|
+
import { pkg, carbon } from '../../settings';
|
27
27
|
var componentName = 'ImportModal'; // Default values for props
|
28
28
|
|
29
29
|
var defaults = {
|
@@ -254,7 +254,7 @@ export var ImportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
254
254
|
size: "sm",
|
255
255
|
disabled: importButtonDisabled
|
256
256
|
}, inputButtonText)), /*#__PURE__*/React.createElement("div", {
|
257
|
-
className: "
|
257
|
+
className: "".concat(carbon.prefix, "--file-container ").concat(blockClass, "__file-container")
|
258
258
|
}, hasFiles && /*#__PURE__*/React.createElement("p", {
|
259
259
|
className: "".concat(blockClass, "__helper-text")
|
260
260
|
}, fileStatusString), files.map(function (file) {
|
@@ -33,15 +33,14 @@ var allTagsModalSearchThreshold = 10; // Default values for props
|
|
33
33
|
|
34
34
|
var defaults = {
|
35
35
|
align: 'start',
|
36
|
-
allTagsModalTarget: document.body,
|
36
|
+
// allTagsModalTarget: document.body,
|
37
37
|
overflowAlign: 'center',
|
38
38
|
overflowDirection: 'bottom'
|
39
39
|
};
|
40
40
|
export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
41
41
|
var _ref$align = _ref.align,
|
42
42
|
align = _ref$align === void 0 ? defaults.align : _ref$align,
|
43
|
-
|
44
|
-
allTagsModalTarget = _ref$allTagsModalTarg === void 0 ? defaults.allTagsModalTarget : _ref$allTagsModalTarg,
|
43
|
+
allTagsModalTargetIn = _ref.allTagsModalTarget,
|
45
44
|
className = _ref.className,
|
46
45
|
maxVisible = _ref.maxVisible,
|
47
46
|
_ref$overflowAlign = _ref.overflowAlign,
|
@@ -88,10 +87,20 @@ export var TagSet = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
88
87
|
|
89
88
|
var overflowTag = useRef(null);
|
90
89
|
|
90
|
+
var _useState11 = useState(null),
|
91
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
92
|
+
allTagsModalTarget = _useState12[0],
|
93
|
+
setAllTagsModalTarget = _useState12[1];
|
94
|
+
|
91
95
|
var handleShowAllClick = function handleShowAllClick() {
|
92
96
|
setShowAllModalOpen(true);
|
93
97
|
};
|
94
98
|
|
99
|
+
useEffect(function () {
|
100
|
+
var _document;
|
101
|
+
|
102
|
+
setAllTagsModalTarget(allTagsModalTargetIn !== null && allTagsModalTargetIn !== void 0 ? allTagsModalTargetIn : (_document = document) === null || _document === void 0 ? void 0 : _document.body);
|
103
|
+
}, [allTagsModalTargetIn]);
|
95
104
|
useEffect(function () {
|
96
105
|
var newSizingTags = []; // create sizing tags
|
97
106
|
|