@carbon/ibm-products 1.6.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/index-full-carbon.css +224 -143
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +1 -2
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +178 -142
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +178 -142
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.js +10 -13
- package/es/components/ActionBar/ActionBar.js +0 -3
- package/es/components/ActionBar/ActionBarItem.js +2 -6
- package/es/components/ActionSet/ActionSet.js +11 -13
- package/es/components/AddSelect/AddSelect.js +121 -25
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +5 -5
- package/es/components/AddSelect/AddSelectColumn.js +21 -0
- package/es/components/AddSelect/AddSelectList.js +68 -9
- package/es/components/AddSelect/AddSelectSidebar.js +43 -5
- package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +0 -3
- package/es/components/ButtonMenu/ButtonMenu.js +6 -4
- package/es/components/ButtonMenu/ButtonMenuItem.js +1 -2
- package/es/components/Card/Card.js +31 -21
- package/es/components/Card/CardFooter.js +14 -10
- package/es/components/Card/CardHeader.js +8 -6
- package/es/components/Cascade/Cascade.js +5 -4
- package/es/components/ComboButton/ComboButton.js +0 -4
- package/es/components/ComboButton/ComboButtonItem/index.js +0 -5
- package/es/components/CreateFullPage/CreateFullPageStep.js +15 -8
- package/es/components/CreateModal/CreateModal.js +1 -4
- package/es/components/CreateTearsheet/CreateTearsheet.js +10 -11
- package/es/components/CreateTearsheet/CreateTearsheetStep.js +18 -14
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +454 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +322 -0
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +64 -0
- package/es/components/DataSpreadsheet/createActiveCellFn.js +45 -0
- package/es/components/DataSpreadsheet/createCellSelectionArea.js +45 -0
- package/es/components/DataSpreadsheet/generateData.js +47 -0
- package/es/components/DataSpreadsheet/getCellSize.js +30 -0
- package/es/components/{CancelableTextEdit → DataSpreadsheet}/index.js +2 -2
- package/es/components/EditSidePanel/EditSidePanel.js +9 -10
- package/es/components/EmptyStates/EmptyState.js +7 -6
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +4 -8
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +4 -8
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +4 -8
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +4 -8
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +4 -8
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +4 -8
- package/es/components/ExampleComponent/ExampleComponent.js +12 -13
- package/es/components/ExportModal/ExportModal.js +13 -9
- package/es/components/ExpressiveCard/ExpressiveCard.js +0 -8
- package/es/components/ImportModal/ImportModal.js +7 -5
- package/es/components/InlineEdit/InlineEdit.js +51 -46
- package/es/components/LoadingBar/LoadingBar.js +13 -17
- package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +0 -4
- package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +0 -5
- package/es/components/ModifiedTabs/ModifiedTabs.js +24 -18
- package/es/components/NotificationsPanel/NotificationsPanel.js +109 -86
- package/es/components/OptionsTile/OptionsTile.js +6 -9
- package/es/components/PageHeader/PageHeader.js +10 -7
- package/es/components/ProductiveCard/ProductiveCard.js +23 -12
- package/es/components/RemoveModal/RemoveModal.js +0 -3
- package/es/components/SidePanel/SidePanel.js +22 -17
- package/es/components/TagSet/TagSet.js +13 -9
- package/es/components/TagSet/TagSetModal.js +16 -12
- package/es/components/TagSet/TagSetOverflow.js +21 -13
- package/es/components/Tearsheet/Tearsheet.js +27 -18
- package/es/components/Tearsheet/TearsheetNarrow.js +18 -15
- package/es/components/Tearsheet/TearsheetShell.js +3 -4
- package/es/components/Toolbar/ToolbarButton.js +0 -3
- package/es/components/WebTerminal/WebTerminal.js +17 -18
- package/es/components/index.js +2 -2
- package/es/global/js/hooks/index.js +1 -0
- package/es/global/js/hooks/useActiveElement.js +27 -0
- package/es/global/js/package-settings.js +2 -1
- package/es/global/js/utils/DisplayBox.js +31 -0
- package/es/global/js/utils/Wrap.js +7 -5
- package/es/global/js/utils/deepCloneObject.js +26 -0
- package/es/global/js/utils/getScrollbarWidth.js +14 -0
- package/lib/components/APIKeyModal/APIKeyModal.js +10 -13
- package/lib/components/ActionBar/ActionBar.js +0 -3
- package/lib/components/ActionBar/ActionBarItem.js +2 -6
- package/lib/components/ActionSet/ActionSet.js +11 -13
- package/lib/components/AddSelect/AddSelect.js +119 -24
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +3 -4
- package/lib/components/AddSelect/AddSelectColumn.js +37 -0
- package/lib/components/AddSelect/AddSelectList.js +66 -9
- package/lib/components/AddSelect/AddSelectSidebar.js +43 -4
- package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +0 -3
- package/lib/components/ButtonMenu/ButtonMenu.js +6 -4
- package/lib/components/ButtonMenu/ButtonMenuItem.js +1 -2
- package/lib/components/Card/Card.js +31 -21
- package/lib/components/Card/CardFooter.js +14 -10
- package/lib/components/Card/CardHeader.js +8 -6
- package/lib/components/Cascade/Cascade.js +5 -4
- package/lib/components/ComboButton/ComboButton.js +0 -4
- package/lib/components/ComboButton/ComboButtonItem/index.js +0 -5
- package/lib/components/CreateFullPage/CreateFullPageStep.js +17 -14
- package/lib/components/CreateModal/CreateModal.js +1 -4
- package/lib/components/CreateTearsheet/CreateTearsheet.js +10 -11
- package/lib/components/CreateTearsheet/CreateTearsheetStep.js +20 -20
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +478 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +349 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +80 -0
- package/lib/components/DataSpreadsheet/createActiveCellFn.js +56 -0
- package/lib/components/DataSpreadsheet/createCellSelectionArea.js +56 -0
- package/lib/components/DataSpreadsheet/generateData.js +58 -0
- package/lib/components/DataSpreadsheet/getCellSize.js +39 -0
- package/lib/components/DataSpreadsheet/index.js +13 -0
- package/lib/components/EditSidePanel/EditSidePanel.js +9 -10
- package/lib/components/EmptyStates/EmptyState.js +9 -8
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +3 -7
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +3 -7
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +3 -7
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +3 -7
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +3 -7
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +3 -7
- package/lib/components/ExampleComponent/ExampleComponent.js +12 -13
- package/lib/components/ExportModal/ExportModal.js +13 -9
- package/lib/components/ExpressiveCard/ExpressiveCard.js +0 -8
- package/lib/components/ImportModal/ImportModal.js +7 -5
- package/lib/components/InlineEdit/InlineEdit.js +51 -46
- package/lib/components/LoadingBar/LoadingBar.js +13 -17
- package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +0 -4
- package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +0 -5
- package/lib/components/ModifiedTabs/ModifiedTabs.js +24 -18
- package/lib/components/NotificationsPanel/NotificationsPanel.js +109 -86
- package/lib/components/OptionsTile/OptionsTile.js +6 -9
- package/lib/components/PageHeader/PageHeader.js +9 -6
- package/lib/components/ProductiveCard/ProductiveCard.js +24 -18
- package/lib/components/RemoveModal/RemoveModal.js +0 -3
- package/lib/components/SidePanel/SidePanel.js +22 -17
- package/lib/components/TagSet/TagSet.js +13 -9
- package/lib/components/TagSet/TagSetModal.js +17 -13
- package/lib/components/TagSet/TagSetOverflow.js +24 -19
- package/lib/components/Tearsheet/Tearsheet.js +26 -17
- package/lib/components/Tearsheet/TearsheetNarrow.js +18 -15
- package/lib/components/Tearsheet/TearsheetShell.js +2 -3
- package/lib/components/Toolbar/ToolbarButton.js +0 -3
- package/lib/components/WebTerminal/WebTerminal.js +17 -18
- package/lib/components/index.js +8 -8
- package/lib/global/js/hooks/index.js +8 -0
- package/lib/global/js/hooks/useActiveElement.js +39 -0
- package/lib/global/js/package-settings.js +2 -1
- package/lib/global/js/utils/DisplayBox.js +46 -0
- package/lib/global/js/utils/Wrap.js +7 -5
- package/lib/global/js/utils/deepCloneObject.js +37 -0
- package/lib/global/js/utils/getScrollbarWidth.js +23 -0
- package/package.json +18 -16
- package/scss/components/{CancelableTextEdit → ActionBar}/_storybook-styles.scss +2 -2
- package/scss/components/ActionSet/_storybook-styles.scss +1 -3
- package/scss/components/AddSelect/_add-select.scss +77 -1
- package/scss/components/BreadcrumbWithOverflow/_storybook-styles.scss +8 -0
- package/scss/components/ButtonSetWithOverflow/_storybook-styles.scss +8 -0
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +120 -0
- package/scss/components/{CancelableTextEdit → DataSpreadsheet}/_index.scss +2 -2
- package/scss/components/DataSpreadsheet/_storybook-styles.scss +6 -0
- package/scss/components/InlineEdit/_inline-edit.scss +22 -8
- package/scss/components/InlineEdit/_storybook-styles.scss +1 -0
- package/scss/components/TagSet/_storybook-styles.scss +8 -0
- package/scss/components/Tearsheet/_tearsheet.scss +1 -2
- package/scss/components/_index.scss +1 -1
- package/scss/global/styles/_display-box.scss +62 -0
- package/es/components/CancelableTextEdit/CancelableTextEdit.js +0 -245
- package/lib/components/CancelableTextEdit/CancelableTextEdit.js +0 -265
- package/lib/components/CancelableTextEdit/index.js +0 -13
- package/scss/components/CancelableTextEdit/_cancelable-text-edit.scss +0 -212
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.DataSpreadsheetBody = void 0;
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
+
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
+
|
|
20
|
+
var _reactWindow = require("react-window");
|
|
21
|
+
|
|
22
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
23
|
+
|
|
24
|
+
var _settings = require("../../settings");
|
|
25
|
+
|
|
26
|
+
var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
|
|
27
|
+
|
|
28
|
+
var _uuidv = _interopRequireDefault(require("../../global/js/utils/uuidv4"));
|
|
29
|
+
|
|
30
|
+
var _createCellSelectionArea = require("./createCellSelectionArea");
|
|
31
|
+
|
|
32
|
+
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); }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Copyright IBM Corp. 2022, 2022
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
40
|
+
* LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/
|
|
42
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--data-spreadsheet");
|
|
43
|
+
|
|
44
|
+
var DataSpreadsheetBody = function DataSpreadsheetBody(_ref) {
|
|
45
|
+
var defaultColumn = _ref.defaultColumn,
|
|
46
|
+
getTableBodyProps = _ref.getTableBodyProps,
|
|
47
|
+
id = _ref.id,
|
|
48
|
+
prepareRow = _ref.prepareRow,
|
|
49
|
+
rows = _ref.rows,
|
|
50
|
+
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
|
51
|
+
selectionAreas = _ref.selectionAreas,
|
|
52
|
+
setContainerHasFocus = _ref.setContainerHasFocus,
|
|
53
|
+
setSelectionAreas = _ref.setSelectionAreas,
|
|
54
|
+
scrollBarSize = _ref.scrollBarSize,
|
|
55
|
+
totalColumnsWidth = _ref.totalColumnsWidth,
|
|
56
|
+
clickAndHoldActive = _ref.clickAndHoldActive,
|
|
57
|
+
setClickAndHoldActive = _ref.setClickAndHoldActive,
|
|
58
|
+
currentMatcher = _ref.currentMatcher,
|
|
59
|
+
setCurrentMatcher = _ref.setCurrentMatcher;
|
|
60
|
+
// Create cell selection areas based on selectionAreas array
|
|
61
|
+
(0, _react.useEffect)(function () {
|
|
62
|
+
if (selectionAreas && selectionAreas.length) {
|
|
63
|
+
selectionAreas.map(function (area) {
|
|
64
|
+
if (!area.areaCreated && area.point1 && area.point2 && area.matcher) {
|
|
65
|
+
// Do not create a cell selection area if point1 and point2 have the same values
|
|
66
|
+
// Cell selections must have two distinctly different points for an area to be created
|
|
67
|
+
if (area.point1.row === area.point2.row && area.point1.column === area.point2.column) {
|
|
68
|
+
var selectionAreasClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
|
69
|
+
var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
|
|
70
|
+
return item.matcher === area.matcher;
|
|
71
|
+
});
|
|
72
|
+
selectionAreasClone[indexOfCurrentArea].areaCreated = false;
|
|
73
|
+
selectionAreasClone[indexOfCurrentArea].point2 = null;
|
|
74
|
+
return setSelectionAreas(selectionAreasClone);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
(0, _createCellSelectionArea.createCellSelectionArea)({
|
|
78
|
+
area: area,
|
|
79
|
+
blockClass: blockClass,
|
|
80
|
+
selectionAreas: selectionAreas,
|
|
81
|
+
setSelectionAreas: setSelectionAreas
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}, [selectionAreas, setSelectionAreas]); // Mouse up
|
|
89
|
+
|
|
90
|
+
(0, _react.useEffect)(function () {
|
|
91
|
+
var handleMouseUp = function handleMouseUp(event) {
|
|
92
|
+
setClickAndHoldActive(false);
|
|
93
|
+
var cellButton = event.target.closest(".".concat(blockClass, "__body--td"));
|
|
94
|
+
|
|
95
|
+
if (cellButton) {
|
|
96
|
+
var endCellCoordinates = {
|
|
97
|
+
row: Number(cellButton.getAttribute('data-row-index')),
|
|
98
|
+
column: Number(cellButton.getAttribute('data-column-index'))
|
|
99
|
+
};
|
|
100
|
+
setCurrentMatcher(null);
|
|
101
|
+
setSelectionAreas(function (prev) {
|
|
102
|
+
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
|
|
103
|
+
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
|
104
|
+
return item.matcher === currentMatcher;
|
|
105
|
+
}); // No items in the array have an object that matches the value of currentMatcher
|
|
106
|
+
|
|
107
|
+
if (indexOfItemToUpdate === -1) {
|
|
108
|
+
return prev;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
selectionAreaClone[indexOfItemToUpdate].point2 = endCellCoordinates;
|
|
112
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
|
113
|
+
return selectionAreaClone;
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
|
117
|
+
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
|
118
|
+
return item.matcher === currentMatcher;
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (indexOfItemToUpdate === -1) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
var newArray = selectionAreaClone.filter(function (item) {
|
|
126
|
+
return item.matcher !== currentMatcher;
|
|
127
|
+
});
|
|
128
|
+
setCurrentMatcher(null);
|
|
129
|
+
setSelectionAreas(newArray);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
document.addEventListener('mouseup', handleMouseUp);
|
|
134
|
+
return function () {
|
|
135
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
|
136
|
+
};
|
|
137
|
+
}, [selectionAreas, currentMatcher, setSelectionAreas, setClickAndHoldActive, setCurrentMatcher]); // Make sure that if the cellSize prop changes, the active
|
|
138
|
+
// cell also gets updated with the new size
|
|
139
|
+
|
|
140
|
+
(0, _react.useEffect)(function () {
|
|
141
|
+
var listContainer = spreadsheetBodyRef === null || spreadsheetBodyRef === void 0 ? void 0 : spreadsheetBodyRef.current;
|
|
142
|
+
var activeCellButton = listContainer.querySelector(".".concat(blockClass, "__active-cell--highlight"));
|
|
143
|
+
|
|
144
|
+
if (activeCellButton) {
|
|
145
|
+
activeCellButton.style.height = "".concat(defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight, "px");
|
|
146
|
+
}
|
|
147
|
+
}, [defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight]); // onClick fn for each cell in the data spreadsheet body,
|
|
148
|
+
// adds the active cell highlight
|
|
149
|
+
|
|
150
|
+
var handleBodyCellClick = (0, _react.useCallback)(function (event, cell, columnIndex) {
|
|
151
|
+
var isHoldingCommandKey = event.metaKey || event.ctrlKey;
|
|
152
|
+
setContainerHasFocus(true);
|
|
153
|
+
var activeCoordinates = {
|
|
154
|
+
row: cell.row.index,
|
|
155
|
+
column: columnIndex
|
|
156
|
+
};
|
|
157
|
+
var tempMatcher = (0, _uuidv.default)();
|
|
158
|
+
setActiveCellCoordinates(activeCoordinates); // prevent multiple selections unless cmd key is held
|
|
159
|
+
// meaning that selectionAreas should only have one item by default
|
|
160
|
+
|
|
161
|
+
if (isHoldingCommandKey) {
|
|
162
|
+
setSelectionAreas(function (prev) {
|
|
163
|
+
return [].concat((0, _toConsumableArray2.default)(prev), [{
|
|
164
|
+
point1: activeCoordinates,
|
|
165
|
+
matcher: tempMatcher
|
|
166
|
+
}]);
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
// remove all previous cell selections
|
|
170
|
+
var cellSelections = spreadsheetBodyRef.current.querySelectorAll(".".concat(blockClass, "__selection-area--element"));
|
|
171
|
+
Array.from(cellSelections).forEach(function (element) {
|
|
172
|
+
return element.remove();
|
|
173
|
+
});
|
|
174
|
+
setSelectionAreas([{
|
|
175
|
+
point1: activeCoordinates,
|
|
176
|
+
matcher: tempMatcher
|
|
177
|
+
}]);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
setCurrentMatcher(tempMatcher);
|
|
181
|
+
setClickAndHoldActive(true);
|
|
182
|
+
}, [setActiveCellCoordinates, setSelectionAreas, setContainerHasFocus, setClickAndHoldActive, setCurrentMatcher]);
|
|
183
|
+
var handleBodyCellHover = (0, _react.useCallback)(function (event, cell, columnIndex) {
|
|
184
|
+
if (clickAndHoldActive) {
|
|
185
|
+
var cellCoordinates = {
|
|
186
|
+
row: cell.row.index,
|
|
187
|
+
column: columnIndex
|
|
188
|
+
};
|
|
189
|
+
setSelectionAreas(function (prev) {
|
|
190
|
+
var _selectionAreaClone$i, _selectionAreaClone$i2;
|
|
191
|
+
|
|
192
|
+
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
|
|
193
|
+
var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
|
|
194
|
+
return item.matcher === currentMatcher;
|
|
195
|
+
}); // No items in the array match up with the currentMatcher value
|
|
196
|
+
|
|
197
|
+
if (indexOfItemToUpdate === -1) {
|
|
198
|
+
return prev;
|
|
199
|
+
} // Do not update state if you're still hovering on the same cell
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
if (((_selectionAreaClone$i = selectionAreaClone[indexOfItemToUpdate].point2) === null || _selectionAreaClone$i === void 0 ? void 0 : _selectionAreaClone$i.row) === cellCoordinates.row && ((_selectionAreaClone$i2 = selectionAreaClone[indexOfItemToUpdate].point2) === null || _selectionAreaClone$i2 === void 0 ? void 0 : _selectionAreaClone$i2.column) === cellCoordinates.column) {
|
|
203
|
+
return prev;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
selectionAreaClone[indexOfItemToUpdate].point2 = cellCoordinates;
|
|
207
|
+
selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
|
|
208
|
+
return selectionAreaClone;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}, [clickAndHoldActive, currentMatcher, setSelectionAreas]); // Renders each cell in the spreadsheet body
|
|
212
|
+
|
|
213
|
+
var RenderRow = (0, _react.useCallback)(function (_ref2) {
|
|
214
|
+
var index = _ref2.index,
|
|
215
|
+
style = _ref2.style;
|
|
216
|
+
var row = rows[index];
|
|
217
|
+
prepareRow(row);
|
|
218
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({}, row.getRowProps({
|
|
219
|
+
style: style
|
|
220
|
+
}), {
|
|
221
|
+
className: (0, _classnames.default)("".concat(blockClass, "__tr")),
|
|
222
|
+
"data-row-index": index
|
|
223
|
+
}), /*#__PURE__*/_react.default.createElement("button", {
|
|
224
|
+
tabIndex: -1,
|
|
225
|
+
"data-row-index": index,
|
|
226
|
+
"data-column-index": "header",
|
|
227
|
+
type: "button",
|
|
228
|
+
className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element")),
|
|
229
|
+
style: {
|
|
230
|
+
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
|
|
231
|
+
}
|
|
232
|
+
}, index + 1), row.cells.map(function (cell, index) {
|
|
233
|
+
return /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
|
|
234
|
+
tabIndex: -1,
|
|
235
|
+
"data-row-index": cell.row.index,
|
|
236
|
+
"data-column-index": index
|
|
237
|
+
}, cell.getCellProps(), {
|
|
238
|
+
className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "__body--td"), "".concat(blockClass, "--interactive-cell-element")),
|
|
239
|
+
key: "cell_".concat(index),
|
|
240
|
+
onMouseDown: function onMouseDown(event) {
|
|
241
|
+
return handleBodyCellClick(event, cell, index);
|
|
242
|
+
},
|
|
243
|
+
onMouseOver: function onMouseOver(event) {
|
|
244
|
+
return handleBodyCellHover(event, cell, index);
|
|
245
|
+
},
|
|
246
|
+
onFocus: function onFocus() {},
|
|
247
|
+
type: "button"
|
|
248
|
+
}), cell.render('Cell'));
|
|
249
|
+
}));
|
|
250
|
+
}, [prepareRow, rows, defaultColumn.rowHeaderWidth, handleBodyCellClick, handleBodyCellHover]);
|
|
251
|
+
var spreadsheetBodyRef = (0, _react.useRef)();
|
|
252
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
253
|
+
ref: spreadsheetBodyRef,
|
|
254
|
+
className: (0, _classnames.default)("".concat(blockClass, "__body--container"))
|
|
255
|
+
}, getTableBodyProps()), /*#__PURE__*/_react.default.createElement(_reactWindow.FixedSizeList, {
|
|
256
|
+
className: (0, _classnames.default)("".concat(blockClass, "__list--container"), "".concat(blockClass, "__list--container--").concat(id)),
|
|
257
|
+
height: 400,
|
|
258
|
+
itemCount: rows.length,
|
|
259
|
+
itemSize: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight,
|
|
260
|
+
width: totalColumnsWidth + scrollBarSize
|
|
261
|
+
}, RenderRow));
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
exports.DataSpreadsheetBody = DataSpreadsheetBody;
|
|
265
|
+
DataSpreadsheetBody.propTypes = {
|
|
266
|
+
/**
|
|
267
|
+
* Is the user clicking and holding in the data spreadsheet body
|
|
268
|
+
*/
|
|
269
|
+
clickAndHoldActive: _propTypes.default.bool,
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* This represents the id of the current cell selection area
|
|
273
|
+
*/
|
|
274
|
+
currentMatcher: _propTypes.default.string,
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Default spreadsheet sizing values
|
|
278
|
+
*/
|
|
279
|
+
defaultColumn: _propTypes.default.shape({
|
|
280
|
+
rowHeight: _propTypes.default.number,
|
|
281
|
+
rowHeaderWidth: _propTypes.default.number,
|
|
282
|
+
width: _propTypes.default.number
|
|
283
|
+
}),
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Function to set table body prop values
|
|
287
|
+
*/
|
|
288
|
+
getTableBodyProps: _propTypes.default.func,
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The spreadsheet id
|
|
292
|
+
*/
|
|
293
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The event handler that is called when the active cell changes
|
|
297
|
+
*/
|
|
298
|
+
onActiveCellChange: _propTypes.default.func,
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Prepare row function from react-table
|
|
302
|
+
*/
|
|
303
|
+
prepareRow: _propTypes.default.func,
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* All of the spreadsheet row data
|
|
307
|
+
*/
|
|
308
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* The scrollbar width
|
|
312
|
+
*/
|
|
313
|
+
scrollBarSize: _propTypes.default.number,
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Array of selection areas
|
|
317
|
+
*/
|
|
318
|
+
selectionAreas: _propTypes.default.array,
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Setter fn for activeCellCoordinates state value
|
|
322
|
+
*/
|
|
323
|
+
setActiveCellCoordinates: _propTypes.default.func,
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Setter fn for clickAndHold state value
|
|
327
|
+
*/
|
|
328
|
+
setClickAndHoldActive: _propTypes.default.func,
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Setter fn for containerHasFocus state value
|
|
332
|
+
*/
|
|
333
|
+
setContainerHasFocus: _propTypes.default.func,
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Setter fn for currentMatcher state value
|
|
337
|
+
*/
|
|
338
|
+
setCurrentMatcher: _propTypes.default.func,
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Setter fn for selectionAreas state value
|
|
342
|
+
*/
|
|
343
|
+
setSelectionAreas: _propTypes.default.func,
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* The total columns width
|
|
347
|
+
*/
|
|
348
|
+
totalColumnsWidth: _propTypes.default.number
|
|
349
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.DataSpreadsheetHeader = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
|
+
|
|
18
|
+
var _settings = require("../../settings");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Copyright IBM Corp. 2022, 2022
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/
|
|
26
|
+
var blockClass = "".concat(_settings.pkg.prefix, "--data-spreadsheet");
|
|
27
|
+
|
|
28
|
+
var DataSpreadsheetHeader = function DataSpreadsheetHeader(_ref) {
|
|
29
|
+
var defaultColumn = _ref.defaultColumn,
|
|
30
|
+
headerGroups = _ref.headerGroups;
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
32
|
+
className: (0, _classnames.default)("".concat(blockClass, "__header--container"))
|
|
33
|
+
}, headerGroups.map(function (headerGroup, index) {
|
|
34
|
+
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
35
|
+
key: "header_".concat(index)
|
|
36
|
+
}, headerGroup.getHeaderGroupProps(), {
|
|
37
|
+
className: "".concat(blockClass, "__tr")
|
|
38
|
+
}), /*#__PURE__*/_react.default.createElement("button", {
|
|
39
|
+
"data-row-index": "header",
|
|
40
|
+
"data-column-index": "header",
|
|
41
|
+
type: "button",
|
|
42
|
+
tabIndex: -1,
|
|
43
|
+
className: (0, _classnames.default)("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element")),
|
|
44
|
+
style: {
|
|
45
|
+
width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth,
|
|
46
|
+
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
|
47
|
+
}
|
|
48
|
+
}, "\xA0"), headerGroup.headers.map(function (column, index) {
|
|
49
|
+
return /*#__PURE__*/_react.default.createElement("button", (0, _extends2.default)({
|
|
50
|
+
key: "column_".concat(index),
|
|
51
|
+
"data-row-index": "header",
|
|
52
|
+
"data-column-index": index,
|
|
53
|
+
tabIndex: -1,
|
|
54
|
+
style: {
|
|
55
|
+
height: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeight
|
|
56
|
+
}
|
|
57
|
+
}, column.getHeaderProps(), {
|
|
58
|
+
className: (0, _classnames.default)("".concat(blockClass, "__th"), "".concat(blockClass, "--interactive-cell-element")),
|
|
59
|
+
type: "button"
|
|
60
|
+
}), column.render('Header'));
|
|
61
|
+
}));
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
exports.DataSpreadsheetHeader = DataSpreadsheetHeader;
|
|
66
|
+
DataSpreadsheetHeader.propTypes = {
|
|
67
|
+
/**
|
|
68
|
+
* Default spreadsheet sizing values
|
|
69
|
+
*/
|
|
70
|
+
defaultColumn: _propTypes.default.shape({
|
|
71
|
+
rowHeight: _propTypes.default.number,
|
|
72
|
+
rowHeaderWidth: _propTypes.default.number,
|
|
73
|
+
width: _propTypes.default.number
|
|
74
|
+
}),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Headers provided from useTable hook
|
|
78
|
+
*/
|
|
79
|
+
headerGroups: _propTypes.default.arrayOf(_propTypes.default.object)
|
|
80
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createActiveCellFn = void 0;
|
|
7
|
+
|
|
8
|
+
var _layout = require("@carbon/layout");
|
|
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 createActiveCellFn = function createActiveCellFn(_ref) {
|
|
19
|
+
var placementElement = _ref.placementElement,
|
|
20
|
+
coords = _ref.coords,
|
|
21
|
+
_ref$addToHeader = _ref.addToHeader,
|
|
22
|
+
addToHeader = _ref$addToHeader === void 0 ? false : _ref$addToHeader,
|
|
23
|
+
contextRef = _ref.contextRef,
|
|
24
|
+
_ref$blockClass = _ref.blockClass,
|
|
25
|
+
blockClass = _ref$blockClass === void 0 ? "".concat(_settings.pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
|
|
26
|
+
onActiveCellChange = _ref.onActiveCellChange,
|
|
27
|
+
activeCellValue = _ref.activeCellValue;
|
|
28
|
+
|
|
29
|
+
if (!coords) {
|
|
30
|
+
return;
|
|
31
|
+
} // If the active cell is in the column header row (very first), we need to append this element
|
|
32
|
+
// to `.${blockClass}__header--container`, otherwise it should be appended to `.${blockClass}__listContainer` firstElementChild
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
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;
|
|
36
|
+
var relativePosition = {
|
|
37
|
+
top: placementElement.getBoundingClientRect().top - activeElementContainer.getBoundingClientRect().top,
|
|
38
|
+
left: placementElement.getBoundingClientRect().left - activeElementContainer.getBoundingClientRect().left
|
|
39
|
+
};
|
|
40
|
+
var activeCellButton = (contextRef === null || contextRef === void 0 ? void 0 : contextRef.current.querySelector(".".concat(blockClass, "__active-cell--highlight"))) || document.createElement('button');
|
|
41
|
+
activeCellButton.classList.add("".concat(blockClass, "__active-cell--highlight"), "".concat(blockClass, "--interactive-cell-element"));
|
|
42
|
+
activeCellButton.style.width = (0, _layout.px)(placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetWidth);
|
|
43
|
+
activeCellButton.style.height = (0, _layout.px)(placementElement === null || placementElement === void 0 ? void 0 : placementElement.offsetHeight);
|
|
44
|
+
activeCellButton.style.left = (0, _layout.px)(relativePosition.left);
|
|
45
|
+
activeCellButton.style.top = (0, _layout.px)(relativePosition.top);
|
|
46
|
+
activeCellButton.setAttribute('data-active-row-index', typeof (coords === null || coords === void 0 ? void 0 : coords.row) === 'number' ? coords.row : 'header');
|
|
47
|
+
activeCellButton.setAttribute('data-active-column-index', typeof (coords === null || coords === void 0 ? void 0 : coords.column) === 'number' ? coords.column : 'header');
|
|
48
|
+
activeElementContainer.appendChild(activeCellButton);
|
|
49
|
+
activeCellButton.focus();
|
|
50
|
+
|
|
51
|
+
if (typeof (coords === null || coords === void 0 ? void 0 : coords.column) === 'number' && typeof (coords === null || coords === void 0 ? void 0 : coords.row) === 'number') {
|
|
52
|
+
onActiveCellChange === null || onActiveCellChange === void 0 ? void 0 : onActiveCellChange(activeCellValue);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.createActiveCellFn = createActiveCellFn;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createCellSelectionArea = void 0;
|
|
7
|
+
|
|
8
|
+
var _layout = require("@carbon/layout");
|
|
9
|
+
|
|
10
|
+
var _deepCloneObject = require("../../global/js/utils/deepCloneObject");
|
|
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 createCellSelectionArea = function createCellSelectionArea(_ref) {
|
|
19
|
+
var area = _ref.area,
|
|
20
|
+
blockClass = _ref.blockClass,
|
|
21
|
+
selectionAreas = _ref.selectionAreas,
|
|
22
|
+
setSelectionAreas = _ref.setSelectionAreas;
|
|
23
|
+
var greatestRow = Math.max(area.point1.row, area.point2.row);
|
|
24
|
+
var greatestColumn = Math.max(area.point1.column, area.point2.column);
|
|
25
|
+
var lowestRowIndex = Math.min(area.point1.row, area.point2.row);
|
|
26
|
+
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 selectionAreaCellWidth = point1Element.offsetWidth;
|
|
29
|
+
var selectionAreaCellHeight = point1Element.offsetHeight;
|
|
30
|
+
var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumn - lowestColumnIndex + 1);
|
|
31
|
+
var selectionAreaTotalHeight = selectionAreaCellHeight * (greatestRow - lowestRowIndex + 1);
|
|
32
|
+
var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
|
|
33
|
+
var placementElement = bodyContainer.querySelector("[data-row-index=\"".concat(lowestRowIndex, "\"][data-column-index=\"").concat(lowestColumnIndex, "\"]"));
|
|
34
|
+
var relativePosition = {
|
|
35
|
+
top: placementElement.getBoundingClientRect().top - bodyContainer.getBoundingClientRect().top,
|
|
36
|
+
left: placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left
|
|
37
|
+
};
|
|
38
|
+
var selectionAreaElement = document.querySelector("[data-matcher-id=\"".concat(area.matcher, "\"]")) || document.createElement('div');
|
|
39
|
+
selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
|
|
40
|
+
selectionAreaElement.setAttribute('data-matcher-id', area.matcher);
|
|
41
|
+
selectionAreaElement.style.width = (0, _layout.px)(selectionAreaTotalWidth);
|
|
42
|
+
selectionAreaElement.style.height = (0, _layout.px)(selectionAreaTotalHeight);
|
|
43
|
+
selectionAreaElement.style.left = (0, _layout.px)(relativePosition.left);
|
|
44
|
+
selectionAreaElement.style.top = (0, _layout.px)(relativePosition.top);
|
|
45
|
+
bodyContainer.appendChild(selectionAreaElement);
|
|
46
|
+
var selectionAreasClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
|
47
|
+
var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
|
|
48
|
+
return item.matcher === area.matcher;
|
|
49
|
+
}); // We need to add another property to the selectionAreas object array to
|
|
50
|
+
// let us know if an area has been created for each item already, ie createdArea: true
|
|
51
|
+
|
|
52
|
+
selectionAreasClone[indexOfCurrentArea].areaCreated = true;
|
|
53
|
+
setSelectionAreas(selectionAreasClone);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.createCellSelectionArea = createCellSelectionArea;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.generateData = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
|
|
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
|
+
|
|
16
|
+
// cspell:disable
|
|
17
|
+
var pets = ['dog', 'cat', 'bird', 'lizard', 'frog', 'hamster', 'fish', 'rabbit', 'snake'];
|
|
18
|
+
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
|
|
19
|
+
|
|
20
|
+
var range = function range(len) {
|
|
21
|
+
var arr = [];
|
|
22
|
+
|
|
23
|
+
for (var i = 0; i < len; i++) {
|
|
24
|
+
arr.push(i);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return arr;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var newPet = function newPet() {
|
|
31
|
+
return {
|
|
32
|
+
petType: pets[Math.floor(Math.random() * pets.length)],
|
|
33
|
+
firstName: petNames[Math.floor(Math.random() * petNames.length)],
|
|
34
|
+
age: Math.floor(Math.random() * 30),
|
|
35
|
+
visits: Math.floor(Math.random() * 40),
|
|
36
|
+
health: Math.floor(Math.random() * 100)
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
var generateData = function generateData() {
|
|
41
|
+
for (var _len = arguments.length, lens = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
42
|
+
lens[_key] = arguments[_key];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var makeDataLevel = function makeDataLevel() {
|
|
46
|
+
var depth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
47
|
+
var len = lens[depth];
|
|
48
|
+
return range(len).map(function () {
|
|
49
|
+
return _objectSpread(_objectSpread({}, newPet()), {}, {
|
|
50
|
+
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return makeDataLevel();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.generateData = generateData;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCellSize = void 0;
|
|
7
|
+
|
|
8
|
+
var _layout = require("@carbon/layout");
|
|
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
|
+
var getSizeInPixels = function getSizeInPixels(carbonSize) {
|
|
17
|
+
return Number(carbonSize.replace('rem', '') * _layout.baseFontSize);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var getCellSize = function getCellSize(cellSize) {
|
|
21
|
+
switch (cellSize) {
|
|
22
|
+
case 'compact':
|
|
23
|
+
return getSizeInPixels(_layout.sizeXSmall);
|
|
24
|
+
|
|
25
|
+
case 'standard':
|
|
26
|
+
return getSizeInPixels(_layout.sizeSmall);
|
|
27
|
+
|
|
28
|
+
case 'medium':
|
|
29
|
+
return getSizeInPixels(_layout.sizeMedium);
|
|
30
|
+
|
|
31
|
+
case 'large':
|
|
32
|
+
return getSizeInPixels(_layout.sizeLarge);
|
|
33
|
+
|
|
34
|
+
default:
|
|
35
|
+
return getSizeInPixels(_layout.sizeSmall);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.getCellSize = getCellSize;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DataSpreadsheet", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _DataSpreadsheet.DataSpreadsheet;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _DataSpreadsheet = require("./DataSpreadsheet");
|