@carbon/ibm-products 1.18.2 → 1.19.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 +6 -0
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon.css +6 -0
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +6 -0
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/ActionSet/ActionSet.js +1 -0
- package/es/components/AddSelect/AddSelectFilter.js +9 -3
- package/es/components/AddSelect/AddSelectSidebar.js +3 -2
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +3 -1
- package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +25 -9
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +1 -3
- package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +63 -34
- package/es/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +17 -3
- package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +113 -19
- package/es/components/Datagrid/Datagrid/DraggableElement.js +0 -7
- package/es/global/js/hooks/useWindowResize.js +2 -1
- package/es/global/js/hooks/useWindowScroll.js +2 -1
- package/es/global/js/utils/scrollableAncestor.js +2 -1
- package/lib/components/ActionSet/ActionSet.js +1 -0
- package/lib/components/AddSelect/AddSelectFilter.js +10 -3
- package/lib/components/AddSelect/AddSelectSidebar.js +3 -2
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +3 -1
- package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
- package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +25 -9
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +1 -4
- package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +64 -34
- package/lib/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +17 -3
- package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +112 -19
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +0 -7
- package/lib/global/js/hooks/useWindowResize.js +3 -1
- package/lib/global/js/hooks/useWindowScroll.js +5 -1
- package/lib/global/js/utils/scrollableAncestor.js +6 -1
- package/package.json +4 -4
- package/scss/components/AddSelect/_add-select.scss +6 -0
- package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +1 -0
@@ -52,6 +52,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
52
52
|
var activeCellCoordinates = _ref.activeCellCoordinates,
|
53
53
|
cellSize = _ref.cellSize,
|
54
54
|
columns = _ref.columns,
|
55
|
+
currentMatcher = _ref.currentMatcher,
|
55
56
|
defaultColumn = _ref.defaultColumn,
|
56
57
|
headerGroups = _ref.headerGroups,
|
57
58
|
scrollBarSize = _ref.scrollBarSize,
|
@@ -94,6 +95,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
94
95
|
var handleColumnHeaderClick = function handleColumnHeaderClick(index) {
|
95
96
|
return function (event) {
|
96
97
|
var isHoldingCommandKey = event.metaKey || event.ctrlKey;
|
98
|
+
var isHoldingShiftKey = event.shiftKey;
|
97
99
|
(0, _handleHeaderCellSelection.handleHeaderCellSelection)({
|
98
100
|
type: 'column',
|
99
101
|
activeCellCoordinates: activeCellCoordinates,
|
@@ -105,7 +107,9 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
105
107
|
spreadsheetRef: ref,
|
106
108
|
index: index,
|
107
109
|
setSelectionAreaData: setSelectionAreaData,
|
108
|
-
isHoldingCommandKey: isHoldingCommandKey
|
110
|
+
isHoldingCommandKey: isHoldingCommandKey,
|
111
|
+
isHoldingShiftKey: isHoldingShiftKey,
|
112
|
+
currentMatcher: currentMatcher
|
109
113
|
});
|
110
114
|
};
|
111
115
|
};
|
@@ -126,23 +130,30 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
126
130
|
return function (event) {
|
127
131
|
var _selectionAreaToClone;
|
128
132
|
|
133
|
+
if (event.shiftKey) {
|
134
|
+
// Remove columns, need to call handleHeaderCellSelection
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
|
129
138
|
setSelectedHeaderReorderActive(true);
|
139
|
+
var selectionAreaToClone = selectionAreas.filter(function (item) {
|
140
|
+
return (item === null || item === void 0 ? void 0 : item.matcher) === currentMatcher;
|
141
|
+
});
|
142
|
+
var selectionAreaElement = ref.current.querySelector("[data-matcher-id=\"".concat((_selectionAreaToClone = selectionAreaToClone[0]) === null || _selectionAreaToClone === void 0 ? void 0 : _selectionAreaToClone.matcher, "\"]"));
|
130
143
|
var clickXPosition = event.clientX;
|
131
144
|
var headerButtonCoords = event.target.getBoundingClientRect();
|
145
|
+
var headerIndex = event.target.getAttribute('data-column-index');
|
132
146
|
var offsetXValue = clickXPosition - headerButtonCoords.left;
|
147
|
+
var lowestColumnIndexFromSelectionArea = Math.min(selectionAreaToClone[0].point1.column, selectionAreaToClone[0].point2.column);
|
148
|
+
var selectionAreaCoords = selectionAreaElement.getBoundingClientRect();
|
149
|
+
var updatedOffsetDifference = lowestColumnIndexFromSelectionArea < parseInt(headerIndex) ? offsetXValue + (headerButtonCoords.left - selectionAreaCoords.left) : offsetXValue;
|
133
150
|
var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
|
134
|
-
var selectionAreaToClone = selectionAreas.filter(function (item) {
|
135
|
-
var _item$header;
|
136
|
-
|
137
|
-
return (item === null || item === void 0 ? void 0 : (_item$header = item.header) === null || _item$header === void 0 ? void 0 : _item$header.index) === index;
|
138
|
-
});
|
139
|
-
var selectionAreaElement = ref.current.querySelector("[data-matcher-id=\"".concat((_selectionAreaToClone = selectionAreaToClone[0]) === null || _selectionAreaToClone === void 0 ? void 0 : _selectionAreaToClone.matcher, "\"]"));
|
140
151
|
var selectionAreaClonedElement = selectionAreaElement.cloneNode();
|
141
152
|
var reorderIndicatorLine = selectionAreaElement.cloneNode();
|
142
153
|
reorderIndicatorLine.className = "".concat(blockClass, "__reorder-indicator-line");
|
143
154
|
reorderIndicatorLine.style.width = (0, _layout.px)(2);
|
144
155
|
selectionAreaClonedElement.classList.add("".concat(blockClass, "__selection-area--element-cloned"));
|
145
|
-
selectionAreaClonedElement.setAttribute('data-clone-offset-x',
|
156
|
+
selectionAreaClonedElement.setAttribute('data-clone-offset-x', updatedOffsetDifference);
|
146
157
|
selectionAreaClonedElement.setAttribute('data-column-index-original', index);
|
147
158
|
bodyContainer.appendChild(selectionAreaClonedElement);
|
148
159
|
bodyContainer.appendChild(reorderIndicatorLine);
|
@@ -192,7 +203,7 @@ var DataSpreadsheetHeader = /*#__PURE__*/(0, _react.forwardRef)(function (_ref,
|
|
192
203
|
}, "\xA0")), headerGroup.headers.map(function (column, index) {
|
193
204
|
var _cx2;
|
194
205
|
|
195
|
-
var selectedHeader = (0, _checkSelectedHeaderCell.checkSelectedHeaderCell)(index, selectionAreas, 'column');
|
206
|
+
var selectedHeader = (0, _checkSelectedHeaderCell.checkSelectedHeaderCell)(index, selectionAreas, 'column', rows);
|
196
207
|
return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
197
208
|
key: "column_".concat(index),
|
198
209
|
role: "columnheader",
|
@@ -237,6 +248,11 @@ DataSpreadsheetHeader.propTypes = {
|
|
237
248
|
*/
|
238
249
|
columns: _propTypes.default.array,
|
239
250
|
|
251
|
+
/**
|
252
|
+
* uuid that corresponds to the current selection area
|
253
|
+
*/
|
254
|
+
currentMatcher: _propTypes.default.string,
|
255
|
+
|
240
256
|
/**
|
241
257
|
* Default spreadsheet sizing values
|
242
258
|
*/
|
@@ -11,8 +11,6 @@ var _layout = require("@carbon/layout");
|
|
11
11
|
|
12
12
|
var _settings = require("../../../settings");
|
13
13
|
|
14
|
-
var _getScrollbarWidth = require("../../../global/js/utils/getScrollbarWidth");
|
15
|
-
|
16
14
|
var _moveColumnIndicatorLine = require("../utils/moveColumnIndicatorLine");
|
17
15
|
|
18
16
|
/**
|
@@ -46,7 +44,6 @@ var useSpreadsheetMouseMove = function useSpreadsheetMouseMove(_ref) {
|
|
46
44
|
spreadsheetCoords: spreadsheetCoords,
|
47
45
|
leftScrollAmount: scrollAmount
|
48
46
|
});
|
49
|
-
var scrollbarWidth = (0, _getScrollbarWidth.getScrollbarWidth)();
|
50
47
|
var spreadsheetWrapperElement = ref.current;
|
51
48
|
spreadsheetWrapperElement.getBoundingClientRect();
|
52
49
|
var xPositionRelativeToSpreadsheet = event.clientX - spreadsheetCoords.left;
|
@@ -56,7 +53,7 @@ var useSpreadsheetMouseMove = function useSpreadsheetMouseMove(_ref) {
|
|
56
53
|
var clonePlacement = Math.max(xPositionRelativeToSpreadsheet - offsetXValue, defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth); // Moves the position of the cloned selection area to follow mouse, and
|
57
54
|
// add the amount horizontally scrolled
|
58
55
|
|
59
|
-
clonedSelectionElement.style.left = (0, _layout.px)(totalSpreadsheetScrollingWidth - clonedSelectionWidth
|
56
|
+
clonedSelectionElement.style.left = (0, _layout.px)(totalSpreadsheetScrollingWidth - clonedSelectionWidth >= clonePlacement ? clonePlacement + scrollAmount : totalSpreadsheetScrollingWidth - clonedSelectionWidth);
|
60
57
|
};
|
61
58
|
|
62
59
|
if (headerCellHoldActive) {
|
@@ -38,7 +38,8 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
38
38
|
setActiveCellCoordinates = _ref.setActiveCellCoordinates,
|
39
39
|
activeCellCoordinates = _ref.activeCellCoordinates,
|
40
40
|
rows = _ref.rows,
|
41
|
-
defaultColumn = _ref.defaultColumn
|
41
|
+
defaultColumn = _ref.defaultColumn,
|
42
|
+
selectionAreas = _ref.selectionAreas;
|
42
43
|
(0, _react.useEffect)(function () {
|
43
44
|
var handleMouseUp = function handleMouseUp(event) {
|
44
45
|
// Remove the cloned selection area on mouse up
|
@@ -53,8 +54,12 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
53
54
|
|
54
55
|
if (selectionAreaCloneElement) {
|
55
56
|
var closestCell = event.target.closest(".".concat(blockClass, "--interactive-cell-element"));
|
56
|
-
var newColumnIndex = closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index');
|
57
|
-
var originalColumnIndex = selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 ? void 0 : selectionAreaCloneElement.getAttribute('data-column-index-original');
|
57
|
+
var newColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index'));
|
58
|
+
var originalColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 ? void 0 : selectionAreaCloneElement.getAttribute('data-column-index-original'));
|
59
|
+
var selectionAreaToClone = selectionAreas.filter(function (item) {
|
60
|
+
return (item === null || item === void 0 ? void 0 : item.matcher) === currentMatcher;
|
61
|
+
});
|
62
|
+
var selectionAreaIndexArray = selectionAreaToClone[0].header.selectedIndexList;
|
58
63
|
var columnToMoveToElement = ref.current.querySelector("[data-row-index=\"header\"][data-column-index=\"".concat(newColumnIndex, "\"]")); // Mouse up element was not part of the spreadsheet component
|
59
64
|
|
60
65
|
if (!columnToMoveToElement) {
|
@@ -63,24 +68,11 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
63
68
|
|
64
69
|
var selectionAreaToMove = ref.current.querySelector("[data-matcher-id=\"".concat(currentMatcher, "\"]"));
|
65
70
|
var spreadsheetPosition = ref.current.getBoundingClientRect();
|
66
|
-
var newIndexPosition = columnToMoveToElement.getBoundingClientRect();
|
67
71
|
var listContainer = ref.current.querySelector(".".concat(blockClass, "__list--container"));
|
68
72
|
var leftScrollAmount = listContainer.scrollLeft;
|
69
|
-
var relativeNewPosition = newIndexPosition.left - spreadsheetPosition.left + leftScrollAmount;
|
70
|
-
var cloneColumnWidth = selectionAreaCloneElement.offsetWidth;
|
71
|
-
var columnsWidthUpToNewIndex = 0;
|
72
73
|
var newIndexLessThanStarting = newColumnIndex < originalColumnIndex;
|
73
|
-
|
74
|
-
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
|
78
|
-
if (index <= newColumnIndex) {
|
79
|
-
columnsWidthUpToNewIndex += (item === null || item === void 0 ? void 0 : item.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width);
|
80
|
-
}
|
81
|
-
});
|
82
|
-
var updatedSelectionAreaPlacement = newIndexLessThanStarting ? relativeNewPosition : columnsWidthUpToNewIndex - cloneColumnWidth + (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth);
|
83
|
-
selectionAreaToMove.style.left = (0, _layout.px)(updatedSelectionAreaPlacement);
|
74
|
+
var newIndexGreater = newColumnIndex > originalColumnIndex;
|
75
|
+
var differenceBetweenOldNewIndex = newIndexGreater ? newColumnIndex - originalColumnIndex : originalColumnIndex - newColumnIndex;
|
84
76
|
setSelectionAreas(function (prev) {
|
85
77
|
var selectionAreaClone = (0, _deepCloneObject.deepCloneObject)(prev);
|
86
78
|
|
@@ -96,26 +88,64 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
96
88
|
return prev;
|
97
89
|
}
|
98
90
|
|
99
|
-
|
100
|
-
|
101
|
-
|
91
|
+
if (!selectionAreaIndexArray.includes(newColumnIndex)) {
|
92
|
+
// We need to not add just the newColumnIndex, but an array of indexes
|
93
|
+
// if there are multiple columns
|
94
|
+
var newIndexArray = newIndexGreater ? selectionAreaIndexArray.map(function (num) {
|
95
|
+
return num + differenceBetweenOldNewIndex;
|
96
|
+
}) : selectionAreaIndexArray.map(function (num) {
|
97
|
+
return num - differenceBetweenOldNewIndex;
|
98
|
+
});
|
99
|
+
selectionAreaClone[indexOfItemToUpdate].header.selectedIndexList = newIndexArray;
|
100
|
+
selectionAreaClone[indexOfItemToUpdate].point1.column = Math.min.apply(Math, (0, _toConsumableArray2.default)(newIndexArray));
|
101
|
+
selectionAreaClone[indexOfItemToUpdate].point2.column = Math.max.apply(Math, (0, _toConsumableArray2.default)(newIndexArray));
|
102
|
+
}
|
103
|
+
|
102
104
|
return selectionAreaClone;
|
103
|
-
});
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
105
|
+
}); // Only reorder columns if the new index is _not_ part of the
|
106
|
+
// selectionAreaIndexArray, meaning the new placement is outside
|
107
|
+
// of the current selection area. Similarly, the active cell position
|
108
|
+
// should only be changed under the same condition.
|
109
|
+
|
110
|
+
if (!selectionAreaIndexArray.includes(newColumnIndex)) {
|
111
|
+
var deleteCount = selectionAreaIndexArray.length;
|
112
|
+
var startIndex = Math.min.apply(Math, (0, _toConsumableArray2.default)(selectionAreaIndexArray));
|
113
|
+
var columnIdArray = visibleColumns.map(function (column) {
|
114
|
+
return column.id;
|
115
|
+
});
|
116
|
+
var columnIdArrayClone = (0, _toConsumableArray2.default)(columnIdArray);
|
108
117
|
|
109
|
-
|
118
|
+
var getNewColumnOrder = function getNewColumnOrder() {
|
119
|
+
var newColumnList = [];
|
120
|
+
selectionAreaIndexArray.map(function (index) {
|
121
|
+
return newColumnList.push(columnIdArray[index]);
|
122
|
+
});
|
123
|
+
return newColumnList;
|
124
|
+
}; // Remove one element at the original index
|
110
125
|
|
111
|
-
columnIdArrayClone.splice(newColumnIndex, 0, columnIdArray[originalColumnIndex]);
|
112
|
-
setColumnOrder(columnIdArrayClone); // Function provided by useTable (react-table) hook to reorder columns
|
113
126
|
|
114
|
-
|
115
|
-
|
116
|
-
|
127
|
+
columnIdArrayClone.splice(startIndex, deleteCount);
|
128
|
+
var originalPointIndex = selectionAreaIndexArray.findIndex(function (item) {
|
129
|
+
return item === originalColumnIndex;
|
130
|
+
});
|
131
|
+
var updatedNewIndexWithNewOrder = newColumnIndex - originalPointIndex; // Add one element at the new index
|
132
|
+
|
133
|
+
columnIdArrayClone.splice.apply(columnIdArrayClone, [updatedNewIndexWithNewOrder, 0].concat((0, _toConsumableArray2.default)(getNewColumnOrder())));
|
134
|
+
setColumnOrder(columnIdArrayClone); // Function provided by useTable (react-table) hook to reorder columns
|
135
|
+
|
136
|
+
var newCellCoords = _objectSpread(_objectSpread({}, activeCellCoordinates), {}, {
|
137
|
+
column: newIndexGreater ? activeCellCoordinates.column + differenceBetweenOldNewIndex : activeCellCoordinates.column - differenceBetweenOldNewIndex
|
138
|
+
});
|
139
|
+
|
140
|
+
setActiveCellCoordinates(newCellCoords);
|
141
|
+
var firstSelectedHeader = Array.from(ref.current.querySelectorAll(".".concat(blockClass, "__th--selected-header")))[0];
|
142
|
+
var firstSelectedHeaderCoords = firstSelectedHeader.getBoundingClientRect();
|
143
|
+
var newRelativePosition = firstSelectedHeaderCoords.left - spreadsheetPosition.left + leftScrollAmount; // console.log(firstSelectedHeaderCoords.left - spreadsheetPosition.left + leftScrollAmount);
|
144
|
+
|
145
|
+
var updatedSelectionAreaPlacement = newIndexLessThanStarting ? newRelativePosition : newColumnIndex === originalColumnIndex ? selectionAreaToMove.style.left : newRelativePosition;
|
146
|
+
selectionAreaToMove.style.left = (0, _layout.px)(updatedSelectionAreaPlacement);
|
147
|
+
} // Remove the cloned column and indicator elements
|
117
148
|
|
118
|
-
setActiveCellCoordinates(newCellCoords); // Remove the cloned column and indicator elements
|
119
149
|
|
120
150
|
var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
|
121
151
|
indicatorLineElement === null || indicatorLineElement === void 0 ? void 0 : indicatorLineElement.remove();
|
@@ -157,7 +187,7 @@ var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
|
|
157
187
|
return function () {
|
158
188
|
document.removeEventListener('mouseup', handleMouseUp);
|
159
189
|
};
|
160
|
-
}, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn]);
|
190
|
+
}, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas]);
|
161
191
|
};
|
162
192
|
|
163
193
|
exports.useSpreadsheetMouseUp = useSpreadsheetMouseUp;
|
@@ -13,12 +13,26 @@ var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
|
|
13
13
|
* This source code is licensed under the Apache-2.0 license found in the
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
15
15
|
*/
|
16
|
-
var checkSelectedHeaderCell = function checkSelectedHeaderCell(headerIndex, selectionAreas, headerType) {
|
16
|
+
var checkSelectedHeaderCell = function checkSelectedHeaderCell(headerIndex, selectionAreas, headerType, items) {
|
17
17
|
var areasCloned = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
|
18
18
|
var isSelectedHeader = areasCloned.some(function (area) {
|
19
|
-
var _area$
|
19
|
+
var _area$point, _area$point2, _area$point3, _area$point4, _area$point5, _area$point6, _area$point7, _area$point8;
|
20
20
|
|
21
|
-
|
21
|
+
var oppositeType = headerType === 'column' ? 'row' : 'column';
|
22
|
+
var minOppositeSelection = Math.min(area === null || area === void 0 ? void 0 : (_area$point = area.point1) === null || _area$point === void 0 ? void 0 : _area$point[oppositeType], area === null || area === void 0 ? void 0 : (_area$point2 = area.point2) === null || _area$point2 === void 0 ? void 0 : _area$point2[oppositeType]);
|
23
|
+
var maxOppositeSelection = Math.max(area === null || area === void 0 ? void 0 : (_area$point3 = area.point1) === null || _area$point3 === void 0 ? void 0 : _area$point3[oppositeType], area === null || area === void 0 ? void 0 : (_area$point4 = area.point2) === null || _area$point4 === void 0 ? void 0 : _area$point4[oppositeType]);
|
24
|
+
var minSelection = Math.min(area === null || area === void 0 ? void 0 : (_area$point5 = area.point1) === null || _area$point5 === void 0 ? void 0 : _area$point5[headerType], area === null || area === void 0 ? void 0 : (_area$point6 = area.point2) === null || _area$point6 === void 0 ? void 0 : _area$point6[headerType]);
|
25
|
+
var maxSelection = Math.max(area === null || area === void 0 ? void 0 : (_area$point7 = area.point1) === null || _area$point7 === void 0 ? void 0 : _area$point7[headerType], area === null || area === void 0 ? void 0 : (_area$point8 = area.point2) === null || _area$point8 === void 0 ? void 0 : _area$point8[headerType]);
|
26
|
+
var isTrueSelectedState = (items === null || items === void 0 ? void 0 : items.length) - 1 === maxOppositeSelection && minOppositeSelection === 0; // console.log({minSelection, maxSelection});
|
27
|
+
// Iterate over all columns included in the selection area
|
28
|
+
|
29
|
+
for (var i = minSelection; i <= maxSelection; i++) {
|
30
|
+
if (headerIndex === i && isTrueSelectedState) {
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
return false;
|
22
36
|
});
|
23
37
|
return isSelectedHeader;
|
24
38
|
};
|
@@ -23,19 +23,36 @@ var _checkActiveHeaderCell = require("./checkActiveHeaderCell");
|
|
23
23
|
* This source code is licensed under the Apache-2.0 license found in the
|
24
24
|
* LICENSE file in the root directory of this source tree.
|
25
25
|
*/
|
26
|
-
var
|
27
|
-
var
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
var getSelectedItemIndexList = function getSelectedItemIndexList(_ref) {
|
27
|
+
var indexList = _ref.indexList,
|
28
|
+
newIndex = _ref.newIndex,
|
29
|
+
activeCellIndex = _ref.activeCellIndex;
|
30
|
+
var lowestIndex = newIndex > activeCellIndex ? activeCellIndex : Math.min.apply(Math, (0, _toConsumableArray2.default)(indexList).concat([newIndex]));
|
31
|
+
var highestIndex = newIndex < activeCellIndex ? activeCellIndex : Math.max.apply(Math, (0, _toConsumableArray2.default)(indexList).concat([newIndex]));
|
32
|
+
var newIndexList = [];
|
33
|
+
|
34
|
+
for (var i = lowestIndex; i <= highestIndex; i++) {
|
35
|
+
newIndexList.push(i);
|
36
|
+
}
|
37
|
+
|
38
|
+
return [].concat(newIndexList);
|
39
|
+
};
|
40
|
+
|
41
|
+
var handleHeaderCellSelection = function handleHeaderCellSelection(_ref2) {
|
42
|
+
var type = _ref2.type,
|
43
|
+
activeCellCoordinates = _ref2.activeCellCoordinates,
|
44
|
+
rows = _ref2.rows,
|
45
|
+
columns = _ref2.columns,
|
46
|
+
currentMatcher = _ref2.currentMatcher,
|
47
|
+
setActiveCellCoordinates = _ref2.setActiveCellCoordinates,
|
48
|
+
setCurrentMatcher = _ref2.setCurrentMatcher,
|
49
|
+
setSelectionAreas = _ref2.setSelectionAreas,
|
50
|
+
spreadsheetRef = _ref2.spreadsheetRef,
|
51
|
+
index = _ref2.index,
|
52
|
+
isKeyboard = _ref2.isKeyboard,
|
53
|
+
setSelectionAreaData = _ref2.setSelectionAreaData,
|
54
|
+
isHoldingCommandKey = _ref2.isHoldingCommandKey,
|
55
|
+
isHoldingShiftKey = _ref2.isHoldingShiftKey;
|
39
56
|
|
40
57
|
if (!isHoldingCommandKey) {
|
41
58
|
setSelectionAreaData([]);
|
@@ -56,11 +73,15 @@ var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
|
|
56
73
|
column: type === 'column' ? columnValue : columns.length - 1
|
57
74
|
};
|
58
75
|
var tempMatcher = (0, _uuidv.default)();
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
76
|
+
|
77
|
+
if (!isHoldingShiftKey) {
|
78
|
+
setActiveCellCoordinates({
|
79
|
+
row: type === 'column' ? 0 : rowValue,
|
80
|
+
column: type === 'column' ? columnValue : 0
|
81
|
+
});
|
82
|
+
setCurrentMatcher(tempMatcher);
|
83
|
+
}
|
84
|
+
|
64
85
|
var newSelectionArea = {
|
65
86
|
point1: point1,
|
66
87
|
point2: point2,
|
@@ -68,7 +89,7 @@ var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
|
|
68
89
|
matcher: tempMatcher,
|
69
90
|
header: {
|
70
91
|
type: type,
|
71
|
-
|
92
|
+
selectedIndexList: [type === 'column' ? columnValue : rowValue]
|
72
93
|
}
|
73
94
|
};
|
74
95
|
setSelectionAreas(function (prev) {
|
@@ -94,6 +115,78 @@ var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
|
|
94
115
|
return [].concat((0, _toConsumableArray2.default)(prev), [newSelectionArea]);
|
95
116
|
}
|
96
117
|
|
118
|
+
if (isHoldingShiftKey) {
|
119
|
+
var _selectionAreasClone$, _selectionAreasClone$2;
|
120
|
+
|
121
|
+
var _selectionsFromHeaderCell = selectionsClone.filter(function (item) {
|
122
|
+
var _item$header3;
|
123
|
+
|
124
|
+
return (_item$header3 = item.header) === null || _item$header3 === void 0 ? void 0 : _item$header3.type;
|
125
|
+
}); // Shift/click behavior should not occur unless there are activeCellCoordinates set
|
126
|
+
|
127
|
+
|
128
|
+
var currentSelectionArea = _selectionsFromHeaderCell.filter(function (item) {
|
129
|
+
return item.matcher === currentMatcher;
|
130
|
+
})[0];
|
131
|
+
|
132
|
+
var originalAreaIndex = Math.max(currentSelectionArea === null || currentSelectionArea === void 0 ? void 0 : currentSelectionArea.point1[type], currentSelectionArea === null || currentSelectionArea === void 0 ? void 0 : currentSelectionArea.point2[type], activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates[type]);
|
133
|
+
var newIndexValue = type === 'column' ? columnValue : rowValue;
|
134
|
+
var newPoint = {
|
135
|
+
row: originalAreaIndex < newIndexValue ? rows.length - 1 : 0,
|
136
|
+
column: columnValue
|
137
|
+
};
|
138
|
+
var selectionAreasClone = (0, _deepCloneObject.deepCloneObject)(prev);
|
139
|
+
var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
|
140
|
+
return item.matcher === currentMatcher;
|
141
|
+
});
|
142
|
+
var newIndexList = getSelectedItemIndexList({
|
143
|
+
indexList: ((_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) === null || _selectionAreasClone$ === void 0 ? void 0 : (_selectionAreasClone$2 = _selectionAreasClone$.header) === null || _selectionAreasClone$2 === void 0 ? void 0 : _selectionAreasClone$2.selectedIndexList) || [type === 'column' ? columnValue : rowValue],
|
144
|
+
newIndex: newIndexValue,
|
145
|
+
activeCellIndex: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates[type]
|
146
|
+
});
|
147
|
+
|
148
|
+
var setPoint1 = function setPoint1(value) {
|
149
|
+
return value < newIndexValue ? {
|
150
|
+
row: type === 'column' ? 0 : Math.min.apply(Math, (0, _toConsumableArray2.default)(newIndexList)),
|
151
|
+
column: type === 'column' ? Math.min.apply(Math, (0, _toConsumableArray2.default)(newIndexList)) : 0
|
152
|
+
} : newPoint;
|
153
|
+
};
|
154
|
+
|
155
|
+
var setPoint2 = function setPoint2(value) {
|
156
|
+
return value < newIndexValue ? newPoint : {
|
157
|
+
row: type === 'column' ? rows.length - 1 : Math.max.apply(Math, (0, _toConsumableArray2.default)(newIndexList)),
|
158
|
+
column: type === 'column' ? Math.max.apply(Math, (0, _toConsumableArray2.default)(newIndexList)) : columns.length - 1
|
159
|
+
};
|
160
|
+
}; // If there is no active cell set and shift is clicked on a header cell
|
161
|
+
|
162
|
+
|
163
|
+
if (!activeCellCoordinates || typeof activeCellCoordinates === 'undefined') {
|
164
|
+
// Need to set positioning of active cell because it doesn't exist yet
|
165
|
+
setCurrentMatcher(tempMatcher);
|
166
|
+
var firstSelectionArea = {
|
167
|
+
point1: setPoint1(type === 'column' ? columnValue : rowValue),
|
168
|
+
point2: setPoint2(type === 'column' ? columnValue : rowValue),
|
169
|
+
areaCreated: false,
|
170
|
+
matcher: tempMatcher,
|
171
|
+
header: {
|
172
|
+
type: type,
|
173
|
+
selectedIndexList: [type === 'column' ? columnValue : rowValue]
|
174
|
+
}
|
175
|
+
};
|
176
|
+
setActiveCellCoordinates({
|
177
|
+
row: type === 'column' ? 0 : rowValue,
|
178
|
+
column: type === 'column' ? columnValue : 0
|
179
|
+
});
|
180
|
+
return [firstSelectionArea];
|
181
|
+
}
|
182
|
+
|
183
|
+
selectionAreasClone[indexOfCurrentArea].point1 = setPoint1(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates[type]);
|
184
|
+
selectionAreasClone[indexOfCurrentArea].point2 = setPoint2(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates[type]);
|
185
|
+
selectionAreasClone[indexOfCurrentArea].areaCreated = false;
|
186
|
+
selectionAreasClone[indexOfCurrentArea].header.selectedIndexList = newIndexList;
|
187
|
+
return selectionAreasClone;
|
188
|
+
}
|
189
|
+
|
97
190
|
return [newSelectionArea];
|
98
191
|
});
|
99
192
|
};
|
@@ -76,7 +76,6 @@ var DraggableElement = function DraggableElement(_ref) {
|
|
76
76
|
var dragIndex = item.index;
|
77
77
|
var hoverIndex = index; // Don't replace items with themselves
|
78
78
|
|
79
|
-
// Don't replace items with themselves
|
80
79
|
if (dragIndex === hoverIndex || disabled) {
|
81
80
|
return;
|
82
81
|
}
|
@@ -88,12 +87,6 @@ var DraggableElement = function DraggableElement(_ref) {
|
|
88
87
|
// to avoid expensive index searches.
|
89
88
|
// eslint-disable-next-line no-param-reassign
|
90
89
|
|
91
|
-
// Time to actually perform the action
|
92
|
-
// Note: we're mutating the monitor item here!
|
93
|
-
// Generally it's better to avoid mutations,
|
94
|
-
// but it's good here for the sake of performance
|
95
|
-
// to avoid expensive index searches.
|
96
|
-
// eslint-disable-next-line no-param-reassign
|
97
90
|
item.index = hoverIndex;
|
98
91
|
}
|
99
92
|
}),
|
@@ -9,13 +9,15 @@ exports.useWindowResize = void 0;
|
|
9
9
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
11
11
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
13
|
+
|
12
14
|
var _react = require("react");
|
13
15
|
|
14
16
|
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; }
|
15
17
|
|
16
18
|
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; }
|
17
19
|
|
18
|
-
var windowExists = typeof window !== "undefined";
|
20
|
+
var windowExists = (typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) !== "undefined";
|
19
21
|
|
20
22
|
var getWindowSize = function getWindowSize() {
|
21
23
|
if (!windowExists) {
|
@@ -1,16 +1,20 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
4
6
|
value: true
|
5
7
|
});
|
6
8
|
exports.useNearestScroll = useNearestScroll;
|
7
9
|
exports.useWindowScroll = useWindowScroll;
|
8
10
|
|
11
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
12
|
+
|
9
13
|
var _react = require("react");
|
10
14
|
|
11
15
|
var _scrollableAncestor = require("../utils/scrollableAncestor");
|
12
16
|
|
13
|
-
var windowExists = typeof window !== "undefined";
|
17
|
+
var windowExists = (typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) !== "undefined";
|
14
18
|
|
15
19
|
var useTargetScroll = function useTargetScroll(target, effect, deps, throttleInterval) {
|
16
20
|
var scrollPosition = (0, _react.useRef)({});
|
@@ -1,10 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
4
6
|
value: true
|
5
7
|
});
|
6
8
|
exports.scrollableAncestor = void 0;
|
7
|
-
|
9
|
+
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
11
|
+
|
12
|
+
var windowExists = (typeof window === "undefined" ? "undefined" : (0, _typeof2.default)(window)) !== "undefined"; // determine whether the target is scrollable
|
8
13
|
|
9
14
|
var scrollable = function scrollable(target) {
|
10
15
|
var style = window.getComputedStyle(target);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.19.0",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -34,7 +34,7 @@
|
|
34
34
|
},
|
35
35
|
"scripts": {
|
36
36
|
"build": "run-s clean build-first build-all",
|
37
|
-
"build-all": "run-p build:*",
|
37
|
+
"build-all": "run-p 'build:*'",
|
38
38
|
"build-first": "copyfiles 'src/**/*.scss' scss -u 1",
|
39
39
|
"build:css-dev": "sass --style=expanded --load-path node_modules --load-path ../../node_modules scss:css",
|
40
40
|
"build:css-min": "sass --style=compressed --load-path node_modules --load-path ../../node_modules scss/index.scss:css/index.min.css scss/index-full-carbon.scss:css/index-full-carbon.min.css scss/index-without-carbon.scss:css/index-without-carbon.min.css scss/index-without-carbon-released-only.scss:css/index-without-carbon-released-only.min.css",
|
@@ -60,7 +60,7 @@
|
|
60
60
|
"fs-extra": "^10.1.0",
|
61
61
|
"glob": "^8.0.3",
|
62
62
|
"jest": "^28.1.0",
|
63
|
-
"jest-config-ibm-cloud-cognitive": "^0.
|
63
|
+
"jest-config-ibm-cloud-cognitive": "^0.24.0",
|
64
64
|
"jest-environment-jsdom": "^28.1.0",
|
65
65
|
"namor": "^1.1.2",
|
66
66
|
"npm-check-updates": "^12.5.11",
|
@@ -93,5 +93,5 @@
|
|
93
93
|
"react": "^16.8.6 || ^17.0.1",
|
94
94
|
"react-dom": "^16.8.6 || ^17.0.1"
|
95
95
|
},
|
96
|
-
"gitHead": "
|
96
|
+
"gitHead": "0b3c895c53963a176ff7e274639c5cce460c0ef1"
|
97
97
|
}
|
@@ -221,6 +221,7 @@
|
|
221
221
|
width: 100%;
|
222
222
|
max-width: 40rem;
|
223
223
|
background: $ui-01;
|
224
|
+
box-shadow: 0 6px 6px 0 rgba(0, 0, 0, 0.2);
|
224
225
|
transform: translate(0, 100%);
|
225
226
|
|
226
227
|
&-search {
|
@@ -256,6 +257,11 @@
|
|
256
257
|
button.#{$block-class}__global-filter-toggle {
|
257
258
|
border-bottom-color: $ui-04;
|
258
259
|
background: $field-01;
|
260
|
+
|
261
|
+
&--open {
|
262
|
+
border-bottom: $ui-01;
|
263
|
+
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.2);
|
264
|
+
}
|
259
265
|
}
|
260
266
|
|
261
267
|
// meta panel
|