@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.
Files changed (43) hide show
  1. package/css/index-full-carbon.css +6 -0
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +2 -2
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +6 -0
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +2 -2
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +6 -0
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +2 -2
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/ActionSet/ActionSet.js +1 -0
  14. package/es/components/AddSelect/AddSelectFilter.js +9 -3
  15. package/es/components/AddSelect/AddSelectSidebar.js +3 -2
  16. package/es/components/DataSpreadsheet/DataSpreadsheet.js +3 -1
  17. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
  18. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +25 -9
  19. package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +1 -3
  20. package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +63 -34
  21. package/es/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +17 -3
  22. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +113 -19
  23. package/es/components/Datagrid/Datagrid/DraggableElement.js +0 -7
  24. package/es/global/js/hooks/useWindowResize.js +2 -1
  25. package/es/global/js/hooks/useWindowScroll.js +2 -1
  26. package/es/global/js/utils/scrollableAncestor.js +2 -1
  27. package/lib/components/ActionSet/ActionSet.js +1 -0
  28. package/lib/components/AddSelect/AddSelectFilter.js +10 -3
  29. package/lib/components/AddSelect/AddSelectSidebar.js +3 -2
  30. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +3 -1
  31. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +4 -3
  32. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +25 -9
  33. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +1 -4
  34. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +64 -34
  35. package/lib/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +17 -3
  36. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +112 -19
  37. package/lib/components/Datagrid/Datagrid/DraggableElement.js +0 -7
  38. package/lib/global/js/hooks/useWindowResize.js +3 -1
  39. package/lib/global/js/hooks/useWindowScroll.js +5 -1
  40. package/lib/global/js/utils/scrollableAncestor.js +6 -1
  41. package/package.json +4 -4
  42. package/scss/components/AddSelect/_add-select.scss +6 -0
  43. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +1 -0
@@ -29,6 +29,7 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
29
29
  var activeCellCoordinates = _ref.activeCellCoordinates,
30
30
  cellSize = _ref.cellSize,
31
31
  columns = _ref.columns,
32
+ currentMatcher = _ref.currentMatcher,
32
33
  defaultColumn = _ref.defaultColumn,
33
34
  headerGroups = _ref.headerGroups,
34
35
  scrollBarSize = _ref.scrollBarSize,
@@ -71,6 +72,7 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
71
72
  var handleColumnHeaderClick = function handleColumnHeaderClick(index) {
72
73
  return function (event) {
73
74
  var isHoldingCommandKey = event.metaKey || event.ctrlKey;
75
+ var isHoldingShiftKey = event.shiftKey;
74
76
  handleHeaderCellSelection({
75
77
  type: 'column',
76
78
  activeCellCoordinates: activeCellCoordinates,
@@ -82,7 +84,9 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
82
84
  spreadsheetRef: ref,
83
85
  index: index,
84
86
  setSelectionAreaData: setSelectionAreaData,
85
- isHoldingCommandKey: isHoldingCommandKey
87
+ isHoldingCommandKey: isHoldingCommandKey,
88
+ isHoldingShiftKey: isHoldingShiftKey,
89
+ currentMatcher: currentMatcher
86
90
  });
87
91
  };
88
92
  };
@@ -103,23 +107,30 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
103
107
  return function (event) {
104
108
  var _selectionAreaToClone;
105
109
 
110
+ if (event.shiftKey) {
111
+ // Remove columns, need to call handleHeaderCellSelection
112
+ return;
113
+ }
114
+
106
115
  setSelectedHeaderReorderActive(true);
116
+ var selectionAreaToClone = selectionAreas.filter(function (item) {
117
+ return (item === null || item === void 0 ? void 0 : item.matcher) === currentMatcher;
118
+ });
119
+ var selectionAreaElement = ref.current.querySelector("[data-matcher-id=\"".concat((_selectionAreaToClone = selectionAreaToClone[0]) === null || _selectionAreaToClone === void 0 ? void 0 : _selectionAreaToClone.matcher, "\"]"));
107
120
  var clickXPosition = event.clientX;
108
121
  var headerButtonCoords = event.target.getBoundingClientRect();
122
+ var headerIndex = event.target.getAttribute('data-column-index');
109
123
  var offsetXValue = clickXPosition - headerButtonCoords.left;
124
+ var lowestColumnIndexFromSelectionArea = Math.min(selectionAreaToClone[0].point1.column, selectionAreaToClone[0].point2.column);
125
+ var selectionAreaCoords = selectionAreaElement.getBoundingClientRect();
126
+ var updatedOffsetDifference = lowestColumnIndexFromSelectionArea < parseInt(headerIndex) ? offsetXValue + (headerButtonCoords.left - selectionAreaCoords.left) : offsetXValue;
110
127
  var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
111
- var selectionAreaToClone = selectionAreas.filter(function (item) {
112
- var _item$header;
113
-
114
- return (item === null || item === void 0 ? void 0 : (_item$header = item.header) === null || _item$header === void 0 ? void 0 : _item$header.index) === index;
115
- });
116
- var selectionAreaElement = ref.current.querySelector("[data-matcher-id=\"".concat((_selectionAreaToClone = selectionAreaToClone[0]) === null || _selectionAreaToClone === void 0 ? void 0 : _selectionAreaToClone.matcher, "\"]"));
117
128
  var selectionAreaClonedElement = selectionAreaElement.cloneNode();
118
129
  var reorderIndicatorLine = selectionAreaElement.cloneNode();
119
130
  reorderIndicatorLine.className = "".concat(blockClass, "__reorder-indicator-line");
120
131
  reorderIndicatorLine.style.width = px(2);
121
132
  selectionAreaClonedElement.classList.add("".concat(blockClass, "__selection-area--element-cloned"));
122
- selectionAreaClonedElement.setAttribute('data-clone-offset-x', offsetXValue);
133
+ selectionAreaClonedElement.setAttribute('data-clone-offset-x', updatedOffsetDifference);
123
134
  selectionAreaClonedElement.setAttribute('data-column-index-original', index);
124
135
  bodyContainer.appendChild(selectionAreaClonedElement);
125
136
  bodyContainer.appendChild(reorderIndicatorLine);
@@ -169,7 +180,7 @@ export var DataSpreadsheetHeader = /*#__PURE__*/forwardRef(function (_ref, ref)
169
180
  }, "\xA0")), headerGroup.headers.map(function (column, index) {
170
181
  var _cx2;
171
182
 
172
- var selectedHeader = checkSelectedHeaderCell(index, selectionAreas, 'column');
183
+ var selectedHeader = checkSelectedHeaderCell(index, selectionAreas, 'column', rows);
173
184
  return /*#__PURE__*/React.createElement("div", _extends({
174
185
  key: "column_".concat(index),
175
186
  role: "columnheader",
@@ -213,6 +224,11 @@ DataSpreadsheetHeader.propTypes = {
213
224
  */
214
225
  columns: PropTypes.array,
215
226
 
227
+ /**
228
+ * uuid that corresponds to the current selection area
229
+ */
230
+ currentMatcher: PropTypes.string,
231
+
216
232
  /**
217
233
  * Default spreadsheet sizing values
218
234
  */
@@ -7,7 +7,6 @@
7
7
  import { useEffect } from 'react';
8
8
  import { px } from '@carbon/layout';
9
9
  import { pkg } from '../../../settings';
10
- import { getScrollbarWidth } from '../../../global/js/utils/getScrollbarWidth';
11
10
  import { moveColumnIndicatorLine } from '../utils/moveColumnIndicatorLine'; // Used specifically for reordering columns, will move the position of the
12
11
  // cloned selection area to follow the position of the cursor
13
12
 
@@ -34,7 +33,6 @@ export var useSpreadsheetMouseMove = function useSpreadsheetMouseMove(_ref) {
34
33
  spreadsheetCoords: spreadsheetCoords,
35
34
  leftScrollAmount: scrollAmount
36
35
  });
37
- var scrollbarWidth = getScrollbarWidth();
38
36
  var spreadsheetWrapperElement = ref.current;
39
37
  spreadsheetWrapperElement.getBoundingClientRect();
40
38
  var xPositionRelativeToSpreadsheet = event.clientX - spreadsheetCoords.left;
@@ -44,7 +42,7 @@ export var useSpreadsheetMouseMove = function useSpreadsheetMouseMove(_ref) {
44
42
  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
45
43
  // add the amount horizontally scrolled
46
44
 
47
- clonedSelectionElement.style.left = px(totalSpreadsheetScrollingWidth - clonedSelectionWidth - scrollbarWidth >= clonePlacement ? clonePlacement + scrollAmount : totalSpreadsheetScrollingWidth - clonedSelectionWidth - scrollbarWidth);
45
+ clonedSelectionElement.style.left = px(totalSpreadsheetScrollingWidth - clonedSelectionWidth >= clonePlacement ? clonePlacement + scrollAmount : totalSpreadsheetScrollingWidth - clonedSelectionWidth);
48
46
  };
49
47
 
50
48
  if (headerCellHoldActive) {
@@ -30,7 +30,8 @@ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
30
30
  setActiveCellCoordinates = _ref.setActiveCellCoordinates,
31
31
  activeCellCoordinates = _ref.activeCellCoordinates,
32
32
  rows = _ref.rows,
33
- defaultColumn = _ref.defaultColumn;
33
+ defaultColumn = _ref.defaultColumn,
34
+ selectionAreas = _ref.selectionAreas;
34
35
  useEffect(function () {
35
36
  var handleMouseUp = function handleMouseUp(event) {
36
37
  // Remove the cloned selection area on mouse up
@@ -45,8 +46,12 @@ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
45
46
 
46
47
  if (selectionAreaCloneElement) {
47
48
  var closestCell = event.target.closest(".".concat(blockClass, "--interactive-cell-element"));
48
- var newColumnIndex = closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index');
49
- var originalColumnIndex = selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 ? void 0 : selectionAreaCloneElement.getAttribute('data-column-index-original');
49
+ var newColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index'));
50
+ var originalColumnIndex = parseInt === null || parseInt === void 0 ? void 0 : parseInt(selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 ? void 0 : selectionAreaCloneElement.getAttribute('data-column-index-original'));
51
+ var selectionAreaToClone = selectionAreas.filter(function (item) {
52
+ return (item === null || item === void 0 ? void 0 : item.matcher) === currentMatcher;
53
+ });
54
+ var selectionAreaIndexArray = selectionAreaToClone[0].header.selectedIndexList;
50
55
  var columnToMoveToElement = ref.current.querySelector("[data-row-index=\"header\"][data-column-index=\"".concat(newColumnIndex, "\"]")); // Mouse up element was not part of the spreadsheet component
51
56
 
52
57
  if (!columnToMoveToElement) {
@@ -55,24 +60,11 @@ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
55
60
 
56
61
  var selectionAreaToMove = ref.current.querySelector("[data-matcher-id=\"".concat(currentMatcher, "\"]"));
57
62
  var spreadsheetPosition = ref.current.getBoundingClientRect();
58
- var newIndexPosition = columnToMoveToElement.getBoundingClientRect();
59
63
  var listContainer = ref.current.querySelector(".".concat(blockClass, "__list--container"));
60
64
  var leftScrollAmount = listContainer.scrollLeft;
61
- var relativeNewPosition = newIndexPosition.left - spreadsheetPosition.left + leftScrollAmount;
62
- var cloneColumnWidth = selectionAreaCloneElement.offsetWidth;
63
- var columnsWidthUpToNewIndex = 0;
64
65
  var newIndexLessThanStarting = newColumnIndex < originalColumnIndex;
65
- visibleColumns.forEach(function (item, index) {
66
- if (newIndexLessThanStarting && index === visibleColumns.length - 1) {
67
- return;
68
- }
69
-
70
- if (index <= newColumnIndex) {
71
- columnsWidthUpToNewIndex += (item === null || item === void 0 ? void 0 : item.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width);
72
- }
73
- });
74
- var updatedSelectionAreaPlacement = newIndexLessThanStarting ? relativeNewPosition : columnsWidthUpToNewIndex - cloneColumnWidth + (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth);
75
- selectionAreaToMove.style.left = px(updatedSelectionAreaPlacement);
66
+ var newIndexGreater = newColumnIndex > originalColumnIndex;
67
+ var differenceBetweenOldNewIndex = newIndexGreater ? newColumnIndex - originalColumnIndex : originalColumnIndex - newColumnIndex;
76
68
  setSelectionAreas(function (prev) {
77
69
  var selectionAreaClone = deepCloneObject(prev);
78
70
 
@@ -88,28 +80,65 @@ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
88
80
  return prev;
89
81
  }
90
82
 
91
- selectionAreaClone[indexOfItemToUpdate].header.index = Number(newColumnIndex);
92
- selectionAreaClone[indexOfItemToUpdate].point1.column = Number(newColumnIndex);
93
- selectionAreaClone[indexOfItemToUpdate].point2.column = Number(newColumnIndex);
83
+ if (!selectionAreaIndexArray.includes(newColumnIndex)) {
84
+ // We need to not add just the newColumnIndex, but an array of indexes
85
+ // if there are multiple columns
86
+ var newIndexArray = newIndexGreater ? selectionAreaIndexArray.map(function (num) {
87
+ return num + differenceBetweenOldNewIndex;
88
+ }) : selectionAreaIndexArray.map(function (num) {
89
+ return num - differenceBetweenOldNewIndex;
90
+ });
91
+ selectionAreaClone[indexOfItemToUpdate].header.selectedIndexList = newIndexArray;
92
+ selectionAreaClone[indexOfItemToUpdate].point1.column = Math.min.apply(Math, _toConsumableArray(newIndexArray));
93
+ selectionAreaClone[indexOfItemToUpdate].point2.column = Math.max.apply(Math, _toConsumableArray(newIndexArray));
94
+ }
95
+
94
96
  return selectionAreaClone;
95
- });
96
- var columnIdArray = visibleColumns.map(function (column) {
97
- return column.id;
98
- });
97
+ }); // Only reorder columns if the new index is _not_ part of the
98
+ // selectionAreaIndexArray, meaning the new placement is outside
99
+ // of the current selection area. Similarly, the active cell position
100
+ // should only be changed under the same condition.
101
+
102
+ if (!selectionAreaIndexArray.includes(newColumnIndex)) {
103
+ var deleteCount = selectionAreaIndexArray.length;
104
+ var startIndex = Math.min.apply(Math, _toConsumableArray(selectionAreaIndexArray));
105
+ var columnIdArray = visibleColumns.map(function (column) {
106
+ return column.id;
107
+ });
99
108
 
100
- var columnIdArrayClone = _toConsumableArray(columnIdArray); // Remove one element at the original index
109
+ var columnIdArrayClone = _toConsumableArray(columnIdArray);
101
110
 
111
+ var getNewColumnOrder = function getNewColumnOrder() {
112
+ var newColumnList = [];
113
+ selectionAreaIndexArray.map(function (index) {
114
+ return newColumnList.push(columnIdArray[index]);
115
+ });
116
+ return newColumnList;
117
+ }; // Remove one element at the original index
102
118
 
103
- columnIdArrayClone.splice(originalColumnIndex, 1); // Add one element at the new index
104
119
 
105
- columnIdArrayClone.splice(newColumnIndex, 0, columnIdArray[originalColumnIndex]);
106
- setColumnOrder(columnIdArrayClone); // Function provided by useTable (react-table) hook to reorder columns
120
+ columnIdArrayClone.splice(startIndex, deleteCount);
121
+ var originalPointIndex = selectionAreaIndexArray.findIndex(function (item) {
122
+ return item === originalColumnIndex;
123
+ });
124
+ var updatedNewIndexWithNewOrder = newColumnIndex - originalPointIndex; // Add one element at the new index
107
125
 
108
- var newCellCoords = _objectSpread(_objectSpread({}, activeCellCoordinates), {}, {
109
- column: Number(newColumnIndex)
110
- });
126
+ columnIdArrayClone.splice.apply(columnIdArrayClone, [updatedNewIndexWithNewOrder, 0].concat(_toConsumableArray(getNewColumnOrder())));
127
+ setColumnOrder(columnIdArrayClone); // Function provided by useTable (react-table) hook to reorder columns
128
+
129
+ var newCellCoords = _objectSpread(_objectSpread({}, activeCellCoordinates), {}, {
130
+ column: newIndexGreater ? activeCellCoordinates.column + differenceBetweenOldNewIndex : activeCellCoordinates.column - differenceBetweenOldNewIndex
131
+ });
132
+
133
+ setActiveCellCoordinates(newCellCoords);
134
+ var firstSelectedHeader = Array.from(ref.current.querySelectorAll(".".concat(blockClass, "__th--selected-header")))[0];
135
+ var firstSelectedHeaderCoords = firstSelectedHeader.getBoundingClientRect();
136
+ var newRelativePosition = firstSelectedHeaderCoords.left - spreadsheetPosition.left + leftScrollAmount; // console.log(firstSelectedHeaderCoords.left - spreadsheetPosition.left + leftScrollAmount);
137
+
138
+ var updatedSelectionAreaPlacement = newIndexLessThanStarting ? newRelativePosition : newColumnIndex === originalColumnIndex ? selectionAreaToMove.style.left : newRelativePosition;
139
+ selectionAreaToMove.style.left = px(updatedSelectionAreaPlacement);
140
+ } // Remove the cloned column and indicator elements
111
141
 
112
- setActiveCellCoordinates(newCellCoords); // Remove the cloned column and indicator elements
113
142
 
114
143
  var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
115
144
  indicatorLineElement === null || indicatorLineElement === void 0 ? void 0 : indicatorLineElement.remove();
@@ -151,5 +180,5 @@ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
151
180
  return function () {
152
181
  document.removeEventListener('mouseup', handleMouseUp);
153
182
  };
154
- }, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn]);
183
+ }, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn, selectionAreas]);
155
184
  };
@@ -5,12 +5,26 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
8
- export var checkSelectedHeaderCell = function checkSelectedHeaderCell(headerIndex, selectionAreas, headerType) {
8
+ export var checkSelectedHeaderCell = function checkSelectedHeaderCell(headerIndex, selectionAreas, headerType, items) {
9
9
  var areasCloned = deepCloneObject(selectionAreas);
10
10
  var isSelectedHeader = areasCloned.some(function (area) {
11
- var _area$header, _area$header2;
11
+ var _area$point, _area$point2, _area$point3, _area$point4, _area$point5, _area$point6, _area$point7, _area$point8;
12
12
 
13
- return (area === null || area === void 0 ? void 0 : (_area$header = area.header) === null || _area$header === void 0 ? void 0 : _area$header.type) === headerType && headerIndex === (area === null || area === void 0 ? void 0 : (_area$header2 = area.header) === null || _area$header2 === void 0 ? void 0 : _area$header2.index);
13
+ var oppositeType = headerType === 'column' ? 'row' : 'column';
14
+ 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]);
15
+ 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]);
16
+ 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]);
17
+ 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]);
18
+ var isTrueSelectedState = (items === null || items === void 0 ? void 0 : items.length) - 1 === maxOppositeSelection && minOppositeSelection === 0; // console.log({minSelection, maxSelection});
19
+ // Iterate over all columns included in the selection area
20
+
21
+ for (var i = minSelection; i <= maxSelection; i++) {
22
+ if (headerIndex === i && isTrueSelectedState) {
23
+ return true;
24
+ }
25
+ }
26
+
27
+ return false;
14
28
  });
15
29
  return isSelectedHeader;
16
30
  };
@@ -10,19 +10,37 @@ import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
10
10
  import uuidv4 from '../../../global/js/utils/uuidv4';
11
11
  import { removeCellSelections } from './removeCellSelections';
12
12
  import { checkActiveHeaderCell } from './checkActiveHeaderCell';
13
- export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref) {
14
- var type = _ref.type,
15
- activeCellCoordinates = _ref.activeCellCoordinates,
16
- rows = _ref.rows,
17
- columns = _ref.columns,
18
- setActiveCellCoordinates = _ref.setActiveCellCoordinates,
19
- setCurrentMatcher = _ref.setCurrentMatcher,
20
- setSelectionAreas = _ref.setSelectionAreas,
21
- spreadsheetRef = _ref.spreadsheetRef,
22
- index = _ref.index,
23
- isKeyboard = _ref.isKeyboard,
24
- setSelectionAreaData = _ref.setSelectionAreaData,
25
- isHoldingCommandKey = _ref.isHoldingCommandKey;
13
+
14
+ var getSelectedItemIndexList = function getSelectedItemIndexList(_ref) {
15
+ var indexList = _ref.indexList,
16
+ newIndex = _ref.newIndex,
17
+ activeCellIndex = _ref.activeCellIndex;
18
+ var lowestIndex = newIndex > activeCellIndex ? activeCellIndex : Math.min.apply(Math, _toConsumableArray(indexList).concat([newIndex]));
19
+ var highestIndex = newIndex < activeCellIndex ? activeCellIndex : Math.max.apply(Math, _toConsumableArray(indexList).concat([newIndex]));
20
+ var newIndexList = [];
21
+
22
+ for (var i = lowestIndex; i <= highestIndex; i++) {
23
+ newIndexList.push(i);
24
+ }
25
+
26
+ return [].concat(newIndexList);
27
+ };
28
+
29
+ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref2) {
30
+ var type = _ref2.type,
31
+ activeCellCoordinates = _ref2.activeCellCoordinates,
32
+ rows = _ref2.rows,
33
+ columns = _ref2.columns,
34
+ currentMatcher = _ref2.currentMatcher,
35
+ setActiveCellCoordinates = _ref2.setActiveCellCoordinates,
36
+ setCurrentMatcher = _ref2.setCurrentMatcher,
37
+ setSelectionAreas = _ref2.setSelectionAreas,
38
+ spreadsheetRef = _ref2.spreadsheetRef,
39
+ index = _ref2.index,
40
+ isKeyboard = _ref2.isKeyboard,
41
+ setSelectionAreaData = _ref2.setSelectionAreaData,
42
+ isHoldingCommandKey = _ref2.isHoldingCommandKey,
43
+ isHoldingShiftKey = _ref2.isHoldingShiftKey;
26
44
 
27
45
  if (!isHoldingCommandKey) {
28
46
  setSelectionAreaData([]);
@@ -43,11 +61,15 @@ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref)
43
61
  column: type === 'column' ? columnValue : columns.length - 1
44
62
  };
45
63
  var tempMatcher = uuidv4();
46
- setActiveCellCoordinates({
47
- row: type === 'column' ? 0 : rowValue,
48
- column: type === 'column' ? columnValue : 0
49
- });
50
- setCurrentMatcher(tempMatcher);
64
+
65
+ if (!isHoldingShiftKey) {
66
+ setActiveCellCoordinates({
67
+ row: type === 'column' ? 0 : rowValue,
68
+ column: type === 'column' ? columnValue : 0
69
+ });
70
+ setCurrentMatcher(tempMatcher);
71
+ }
72
+
51
73
  var newSelectionArea = {
52
74
  point1: point1,
53
75
  point2: point2,
@@ -55,7 +77,7 @@ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref)
55
77
  matcher: tempMatcher,
56
78
  header: {
57
79
  type: type,
58
- index: type === 'column' ? columnValue : rowValue
80
+ selectedIndexList: [type === 'column' ? columnValue : rowValue]
59
81
  }
60
82
  };
61
83
  setSelectionAreas(function (prev) {
@@ -81,6 +103,78 @@ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref)
81
103
  return [].concat(_toConsumableArray(prev), [newSelectionArea]);
82
104
  }
83
105
 
106
+ if (isHoldingShiftKey) {
107
+ var _selectionAreasClone$, _selectionAreasClone$2;
108
+
109
+ var _selectionsFromHeaderCell = selectionsClone.filter(function (item) {
110
+ var _item$header3;
111
+
112
+ return (_item$header3 = item.header) === null || _item$header3 === void 0 ? void 0 : _item$header3.type;
113
+ }); // Shift/click behavior should not occur unless there are activeCellCoordinates set
114
+
115
+
116
+ var currentSelectionArea = _selectionsFromHeaderCell.filter(function (item) {
117
+ return item.matcher === currentMatcher;
118
+ })[0];
119
+
120
+ 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]);
121
+ var newIndexValue = type === 'column' ? columnValue : rowValue;
122
+ var newPoint = {
123
+ row: originalAreaIndex < newIndexValue ? rows.length - 1 : 0,
124
+ column: columnValue
125
+ };
126
+ var selectionAreasClone = deepCloneObject(prev);
127
+ var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
128
+ return item.matcher === currentMatcher;
129
+ });
130
+ var newIndexList = getSelectedItemIndexList({
131
+ 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],
132
+ newIndex: newIndexValue,
133
+ activeCellIndex: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates[type]
134
+ });
135
+
136
+ var setPoint1 = function setPoint1(value) {
137
+ return value < newIndexValue ? {
138
+ row: type === 'column' ? 0 : Math.min.apply(Math, _toConsumableArray(newIndexList)),
139
+ column: type === 'column' ? Math.min.apply(Math, _toConsumableArray(newIndexList)) : 0
140
+ } : newPoint;
141
+ };
142
+
143
+ var setPoint2 = function setPoint2(value) {
144
+ return value < newIndexValue ? newPoint : {
145
+ row: type === 'column' ? rows.length - 1 : Math.max.apply(Math, _toConsumableArray(newIndexList)),
146
+ column: type === 'column' ? Math.max.apply(Math, _toConsumableArray(newIndexList)) : columns.length - 1
147
+ };
148
+ }; // If there is no active cell set and shift is clicked on a header cell
149
+
150
+
151
+ if (!activeCellCoordinates || typeof activeCellCoordinates === 'undefined') {
152
+ // Need to set positioning of active cell because it doesn't exist yet
153
+ setCurrentMatcher(tempMatcher);
154
+ var firstSelectionArea = {
155
+ point1: setPoint1(type === 'column' ? columnValue : rowValue),
156
+ point2: setPoint2(type === 'column' ? columnValue : rowValue),
157
+ areaCreated: false,
158
+ matcher: tempMatcher,
159
+ header: {
160
+ type: type,
161
+ selectedIndexList: [type === 'column' ? columnValue : rowValue]
162
+ }
163
+ };
164
+ setActiveCellCoordinates({
165
+ row: type === 'column' ? 0 : rowValue,
166
+ column: type === 'column' ? columnValue : 0
167
+ });
168
+ return [firstSelectionArea];
169
+ }
170
+
171
+ selectionAreasClone[indexOfCurrentArea].point1 = setPoint1(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates[type]);
172
+ selectionAreasClone[indexOfCurrentArea].point2 = setPoint2(activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates[type]);
173
+ selectionAreasClone[indexOfCurrentArea].areaCreated = false;
174
+ selectionAreasClone[indexOfCurrentArea].header.selectedIndexList = newIndexList;
175
+ return selectionAreasClone;
176
+ }
177
+
84
178
  return [newSelectionArea];
85
179
  });
86
180
  };
@@ -55,7 +55,6 @@ var DraggableElement = function DraggableElement(_ref) {
55
55
  var dragIndex = item.index;
56
56
  var hoverIndex = index; // Don't replace items with themselves
57
57
 
58
- // Don't replace items with themselves
59
58
  if (dragIndex === hoverIndex || disabled) {
60
59
  return;
61
60
  }
@@ -67,12 +66,6 @@ var DraggableElement = function DraggableElement(_ref) {
67
66
  // to avoid expensive index searches.
68
67
  // eslint-disable-next-line no-param-reassign
69
68
 
70
- // Time to actually perform the action
71
- // Note: we're mutating the monitor item here!
72
- // Generally it's better to avoid mutations,
73
- // but it's good here for the sake of performance
74
- // to avoid expensive index searches.
75
- // eslint-disable-next-line no-param-reassign
76
69
  item.index = hoverIndex;
77
70
  }
78
71
  }),
@@ -1,11 +1,12 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
2
3
 
3
4
  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; }
4
5
 
5
6
  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; }
6
7
 
7
8
  import { useRef, useLayoutEffect } from 'react';
8
- var windowExists = typeof window !== "undefined";
9
+ var windowExists = (typeof window === "undefined" ? "undefined" : _typeof(window)) !== "undefined";
9
10
 
10
11
  var getWindowSize = function getWindowSize() {
11
12
  if (!windowExists) {
@@ -1,6 +1,7 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
1
2
  import { useRef, useLayoutEffect } from 'react';
2
3
  import { scrollableAncestor } from '../utils/scrollableAncestor';
3
- var windowExists = typeof window !== "undefined";
4
+ var windowExists = (typeof window === "undefined" ? "undefined" : _typeof(window)) !== "undefined";
4
5
 
5
6
  var useTargetScroll = function useTargetScroll(target, effect, deps, throttleInterval) {
6
7
  var scrollPosition = useRef({});
@@ -1,4 +1,5 @@
1
- var windowExists = typeof window !== "undefined"; // determine whether the target is scrollable
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ var windowExists = (typeof window === "undefined" ? "undefined" : _typeof(window)) !== "undefined"; // determine whether the target is scrollable
2
3
 
3
4
  var scrollable = function scrollable(target) {
4
5
  var style = window.getComputedStyle(target);
@@ -148,6 +148,7 @@ ActionSet.validateActions = function (sizeFn) {
148
148
  var problems = [];
149
149
 
150
150
  if (actions > 0) {
151
+ // eslint-disable-next-line react/prop-types
151
152
  var size = sizeFn ? sizeFn(props) : props.size || defaults.size;
152
153
  var stacking = willStack(size, actions);
153
154
 
@@ -17,6 +17,8 @@ var _react = _interopRequireWildcard(require("react"));
17
17
 
18
18
  var _carbonComponentsReact = require("carbon-components-react");
19
19
 
20
+ var _classnames = _interopRequireDefault(require("classnames"));
21
+
20
22
  var _propTypes = _interopRequireDefault(require("prop-types"));
21
23
 
22
24
  var _iconsReact = require("@carbon/icons-react");
@@ -79,6 +81,7 @@ var AddSelectFilter = function AddSelectFilter(_ref) {
79
81
 
80
82
 
81
83
  var applyFilters = function applyFilters() {
84
+ setOpen(false);
82
85
  handleFilter(filters);
83
86
  };
84
87
 
@@ -104,6 +107,8 @@ var AddSelectFilter = function AddSelectFilter(_ref) {
104
107
  };
105
108
 
106
109
  var showFilter = multi && (filterOpts === null || filterOpts === void 0 ? void 0 : filterOpts.length) > 0;
110
+ var filterBtnClassnames = (0, _classnames.default)("".concat(blockClass, "-toggle"), (0, _defineProperty2.default)({}, "".concat(blockClass, "-toggle--open"), open));
111
+ var dirtyInput = Object.keys(filters).length > 0;
107
112
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
108
113
  className: "".concat(blockClass, "-search")
109
114
  }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextInput, {
@@ -120,7 +125,7 @@ var AddSelectFilter = function AddSelectFilter(_ref) {
120
125
  return setOpen(!open);
121
126
  },
122
127
  iconDescription: iconDescription,
123
- className: "".concat(blockClass, "-toggle"),
128
+ className: filterBtnClassnames,
124
129
  size: "md"
125
130
  }), open && /*#__PURE__*/_react.default.createElement("div", {
126
131
  className: blockClass
@@ -146,11 +151,13 @@ var AddSelectFilter = function AddSelectFilter(_ref) {
146
151
  }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
147
152
  kind: "secondary",
148
153
  onClick: resetFilters,
149
- className: "".concat(blockClass, "-button")
154
+ className: "".concat(blockClass, "-button"),
155
+ disabled: !dirtyInput
150
156
  }, secondaryButtonText), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
151
157
  kind: "primary",
152
158
  onClick: applyFilters,
153
- className: "".concat(blockClass, "-button")
159
+ className: "".concat(blockClass, "-button"),
160
+ disabled: !dirtyInput && !hasFiltersApplied
154
161
  }, primaryButtonText)))), hasFiltersApplied && /*#__PURE__*/_react.default.createElement("div", {
155
162
  className: "".concat(blockClass, "-applied")
156
163
  }, Object.keys(appliedFilters).map(function (filterType) {
@@ -23,7 +23,7 @@ var _settings = require("../../settings");
23
23
 
24
24
  var _AddSelectMetaPanel = require("./AddSelectMetaPanel");
25
25
 
26
- var _excluded = ["icon", "avatar"];
26
+ var _excluded = ["meta", "icon", "avatar"];
27
27
  var componentName = 'AddSelectSidebar';
28
28
 
29
29
  var AddSelectSidebar = function AddSelectSidebar(_ref) {
@@ -53,7 +53,8 @@ var AddSelectSidebar = function AddSelectSidebar(_ref) {
53
53
  }); // certain properties should not be displayed in the sidebar
54
54
  // eslint-disable-next-line no-unused-vars
55
55
 
56
- var icon = selectedItem.icon,
56
+ var meta = selectedItem.meta,
57
+ icon = selectedItem.icon,
57
58
  avatar = selectedItem.avatar,
58
59
  newItem = (0, _objectWithoutProperties2.default)(selectedItem, _excluded);
59
60
  acc.push(newItem);
@@ -701,7 +701,8 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
701
701
  spreadsheetRef: spreadsheetRef,
702
702
  isKeyboard: isKeyboard,
703
703
  setSelectionAreaData: setSelectionAreaData,
704
- index: index
704
+ index: index,
705
+ currentMatcher: currentMatcher
705
706
  }; // Select an entire column
706
707
 
707
708
  if ((activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) !== 'header') {
@@ -802,6 +803,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
802
803
  activeCellCoordinates: activeCellCoordinates,
803
804
  cellSize: cellSize,
804
805
  columns: columns,
806
+ currentMatcher: currentMatcher,
805
807
  defaultColumn: defaultColumn,
806
808
  headerGroups: headerGroups,
807
809
  rows: rows,
@@ -197,7 +197,8 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
197
197
  setActiveCellCoordinates: setActiveCellCoordinates,
198
198
  rows: rows,
199
199
  activeCellCoordinates: activeCellCoordinates,
200
- defaultColumn: defaultColumn
200
+ defaultColumn: defaultColumn,
201
+ selectionAreas: selectionAreas
201
202
  }); // Make sure that if the cellSize prop changes, the active
202
203
  // cell also gets updated with the new size and new top placement
203
204
  // value. All of the cell selections will be updated as well
@@ -421,7 +422,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
421
422
  "data-column-index": "header",
422
423
  type: "button",
423
424
  onClick: handleRowHeaderClick(index),
424
- className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__td-th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === index || (0, _checkActiveHeaderCell.checkActiveHeaderCell)(index, selectionAreas, 'row')), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__td-th--selected-header"), (0, _checkSelectedHeaderCell.checkSelectedHeaderCell)(index, selectionAreas, 'row')), _cx)),
425
+ className: (0, _classnames.default)("".concat(blockClass, "__td"), "".concat(blockClass, "__td-th"), "".concat(blockClass, "--interactive-cell-element"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__td-th--active-header"), (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === index || (0, _checkActiveHeaderCell.checkActiveHeaderCell)(index, selectionAreas, 'row')), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__td-th--selected-header"), (0, _checkSelectedHeaderCell.checkSelectedHeaderCell)(index, selectionAreas, 'row', columns)), _cx)),
425
426
  style: {
426
427
  width: defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth
427
428
  }
@@ -450,7 +451,7 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
450
451
  }, cell.render('Cell')));
451
452
  }));
452
453
  }
453
- }, [prepareRow, rows, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas, handleRowHeaderClick, handleBodyCellClick, handleBodyCellHover, defaultColumn]);
454
+ }, [prepareRow, rows, activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row, selectionAreas, handleRowHeaderClick, handleBodyCellClick, handleBodyCellHover, defaultColumn, columns]);
454
455
  var spreadsheetBodyRef = (0, _react.useRef)();
455
456
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
456
457
  ref: spreadsheetBodyRef,