@carbon/ibm-products 1.18.0 → 1.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. package/css/components/Datagrid/styles/datagrid.css +24 -4
  2. package/css/components/Datagrid/styles/datagrid.css.map +1 -1
  3. package/css/components/Datagrid/styles/index.css +24 -4
  4. package/css/components/Datagrid/styles/index.css.map +1 -1
  5. package/css/index-full-carbon.css +78 -13
  6. package/css/index-full-carbon.css.map +1 -1
  7. package/css/index-full-carbon.min.css +2 -2
  8. package/css/index-full-carbon.min.css.map +1 -1
  9. package/css/index-without-carbon.css +78 -13
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +2 -2
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +78 -13
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +2 -2
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/ActionSet/ActionSet.js +1 -0
  18. package/es/components/AddSelect/AddSelect.js +28 -3
  19. package/es/components/AddSelect/AddSelectFilter.js +9 -3
  20. package/es/components/AddSelect/AddSelectList.js +32 -6
  21. package/es/components/AddSelect/AddSelectMetaPanel.js +54 -0
  22. package/es/components/AddSelect/AddSelectSidebar.js +22 -3
  23. package/es/components/DataSpreadsheet/DataSpreadsheet.js +7 -4
  24. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +43 -10
  25. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +36 -13
  26. package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +8 -6
  27. package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +65 -34
  28. package/es/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +17 -3
  29. package/es/components/DataSpreadsheet/utils/getCellSize.js +10 -10
  30. package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +8 -2
  31. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +113 -19
  32. package/es/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +4 -3
  33. package/es/components/Datagrid/Datagrid/Datagrid.js +1 -1
  34. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +22 -3
  35. package/es/components/Datagrid/Datagrid/DraggableElement.js +0 -7
  36. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +3 -3
  37. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  38. package/es/components/ExportModal/ExportModal.js +1 -1
  39. package/es/global/js/hooks/useWindowResize.js +2 -1
  40. package/es/global/js/hooks/useWindowScroll.js +2 -1
  41. package/es/global/js/utils/scrollableAncestor.js +2 -1
  42. package/lib/components/ActionSet/ActionSet.js +1 -0
  43. package/lib/components/AddSelect/AddSelect.js +28 -3
  44. package/lib/components/AddSelect/AddSelectFilter.js +10 -3
  45. package/lib/components/AddSelect/AddSelectList.js +30 -4
  46. package/lib/components/AddSelect/AddSelectMetaPanel.js +77 -0
  47. package/lib/components/AddSelect/AddSelectSidebar.js +23 -3
  48. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +7 -4
  49. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +43 -10
  50. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +36 -13
  51. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +8 -7
  52. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +66 -34
  53. package/lib/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +17 -3
  54. package/lib/components/DataSpreadsheet/utils/getCellSize.js +4 -4
  55. package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +8 -2
  56. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +112 -19
  57. package/lib/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +4 -3
  58. package/lib/components/Datagrid/Datagrid/Datagrid.js +1 -1
  59. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +24 -3
  60. package/lib/components/Datagrid/Datagrid/DraggableElement.js +0 -7
  61. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +3 -3
  62. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  63. package/lib/components/ExportModal/ExportModal.js +1 -1
  64. package/lib/global/js/hooks/useWindowResize.js +3 -1
  65. package/lib/global/js/hooks/useWindowScroll.js +5 -1
  66. package/lib/global/js/utils/scrollableAncestor.js +6 -1
  67. package/package.json +7 -7
  68. package/scss/components/AddSelect/_add-select.scss +46 -6
  69. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +8 -1
  70. package/scss/components/Datagrid/_storybook-styles.scss +5 -0
  71. package/scss/components/Datagrid/styles/datagrid.scss +43 -5
@@ -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,22 +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
- var relativeNewPosition = newIndexPosition.left - spreadsheetPosition.left;
60
- var cloneColumnWidth = selectionAreaCloneElement.offsetWidth;
61
- var columnsWidthUpToNewIndex = 0;
63
+ var listContainer = ref.current.querySelector(".".concat(blockClass, "__list--container"));
64
+ var leftScrollAmount = listContainer.scrollLeft;
62
65
  var newIndexLessThanStarting = newColumnIndex < originalColumnIndex;
63
- visibleColumns.forEach(function (item, index) {
64
- if (newIndexLessThanStarting && index === visibleColumns.length - 1) {
65
- return;
66
- }
67
-
68
- if (index <= newColumnIndex) {
69
- columnsWidthUpToNewIndex += (item === null || item === void 0 ? void 0 : item.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width);
70
- }
71
- });
72
- var updatedSelectionAreaPlacement = newIndexLessThanStarting ? relativeNewPosition : columnsWidthUpToNewIndex - cloneColumnWidth + (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.rowHeaderWidth);
73
- selectionAreaToMove.style.left = px(updatedSelectionAreaPlacement);
66
+ var newIndexGreater = newColumnIndex > originalColumnIndex;
67
+ var differenceBetweenOldNewIndex = newIndexGreater ? newColumnIndex - originalColumnIndex : originalColumnIndex - newColumnIndex;
74
68
  setSelectionAreas(function (prev) {
75
69
  var selectionAreaClone = deepCloneObject(prev);
76
70
 
@@ -86,28 +80,65 @@ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
86
80
  return prev;
87
81
  }
88
82
 
89
- selectionAreaClone[indexOfItemToUpdate].header.index = Number(newColumnIndex);
90
- selectionAreaClone[indexOfItemToUpdate].point1.column = Number(newColumnIndex);
91
- 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
+
92
96
  return selectionAreaClone;
93
- });
94
- var columnIdArray = visibleColumns.map(function (column) {
95
- return column.id;
96
- });
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
+ });
97
108
 
98
- var columnIdArrayClone = _toConsumableArray(columnIdArray); // Remove one element at the original index
109
+ var columnIdArrayClone = _toConsumableArray(columnIdArray);
99
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
100
118
 
101
- columnIdArrayClone.splice(originalColumnIndex, 1); // Add one element at the new index
102
119
 
103
- columnIdArrayClone.splice(newColumnIndex, 0, columnIdArray[originalColumnIndex]);
104
- 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
105
125
 
106
- var newCellCoords = _objectSpread(_objectSpread({}, activeCellCoordinates), {}, {
107
- column: Number(newColumnIndex)
108
- });
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
109
141
 
110
- setActiveCellCoordinates(newCellCoords); // Remove the cloned column and indicator elements
111
142
 
112
143
  var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
113
144
  indicatorLineElement === null || indicatorLineElement === void 0 ? void 0 : indicatorLineElement.remove();
@@ -149,5 +180,5 @@ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
149
180
  return function () {
150
181
  document.removeEventListener('mouseup', handleMouseUp);
151
182
  };
152
- }, [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]);
153
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
  };
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import { baseFontSize, sizeXSmall as compact, sizeSmall as standard, sizeMedium as medium, sizeLarge as large } from '@carbon/layout';
7
+ import { baseFontSize, sizeXSmall as xs, sizeSmall as sm, sizeMedium as md, sizeLarge as lg } from '@carbon/layout';
8
8
 
9
9
  var getSizeInPixels = function getSizeInPixels(carbonSize) {
10
10
  return Number(carbonSize.replace('rem', '') * baseFontSize);
@@ -12,19 +12,19 @@ var getSizeInPixels = function getSizeInPixels(carbonSize) {
12
12
 
13
13
  export var getCellSize = function getCellSize(cellSize) {
14
14
  switch (cellSize) {
15
- case 'compact':
16
- return getSizeInPixels(compact);
15
+ case 'xs':
16
+ return getSizeInPixels(xs);
17
17
 
18
- case 'standard':
19
- return getSizeInPixels(standard);
18
+ case 'sm':
19
+ return getSizeInPixels(sm);
20
20
 
21
- case 'medium':
22
- return getSizeInPixels(medium);
21
+ case 'md':
22
+ return getSizeInPixels(md);
23
23
 
24
- case 'large':
25
- return getSizeInPixels(large);
24
+ case 'lg':
25
+ return getSizeInPixels(lg);
26
26
 
27
27
  default:
28
- return getSizeInPixels(standard);
28
+ return getSizeInPixels(sm);
29
29
  }
30
30
  };
@@ -11,7 +11,8 @@ export var getSpreadsheetWidth = function getSpreadsheetWidth(_ref) {
11
11
  scrollBarSizeValue = _ref.scrollBarSizeValue,
12
12
  totalVisibleColumns = _ref.totalVisibleColumns,
13
13
  defaultColumn = _ref.defaultColumn,
14
- totalColumnsWidth = _ref.totalColumnsWidth;
14
+ totalColumnsWidth = _ref.totalColumnsWidth,
15
+ visibleColumns = _ref.visibleColumns;
15
16
  var additionalWidth = scrollBarSizeValue + defaultColumn.rowHeaderWidth;
16
17
 
17
18
  if (!totalVisibleColumns) {
@@ -25,6 +26,11 @@ export var getSpreadsheetWidth = function getSpreadsheetWidth(_ref) {
25
26
  }
26
27
 
27
28
  if (totalVisibleColumns) {
28
- return totalVisibleColumns * (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width) + additionalWidth;
29
+ var totalVisibleColumnWidth = visibleColumns.map(function (item, index) {
30
+ return index <= totalVisibleColumns - 1 && ((item === null || item === void 0 ? void 0 : item.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width));
31
+ }).reduce(function (prev, curr) {
32
+ return prev + curr;
33
+ }, 0);
34
+ return totalVisibleColumnWidth + additionalWidth;
29
35
  }
30
36
  };
@@ -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: index
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
  };
@@ -11,7 +11,8 @@ export var moveColumnIndicatorLine = function moveColumnIndicatorLine(_ref) {
11
11
  blockClass = _ref$blockClass === void 0 ? "".concat(pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
12
12
  clonedSelectionElement = _ref.clonedSelectionElement,
13
13
  ref = _ref.ref,
14
- spreadsheetCoords = _ref.spreadsheetCoords;
14
+ spreadsheetCoords = _ref.spreadsheetCoords,
15
+ leftScrollAmount = _ref.leftScrollAmount;
15
16
  var closestCell = event.target.closest(".".concat(blockClass, "--interactive-cell-element"));
16
17
  var newColumnIndex = closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index');
17
18
  var originalColumnIndex = clonedSelectionElement === null || clonedSelectionElement === void 0 ? void 0 : clonedSelectionElement.getAttribute('data-column-index-original');
@@ -21,11 +22,11 @@ export var moveColumnIndicatorLine = function moveColumnIndicatorLine(_ref) {
21
22
  var selectionAreaOrigin = ref.current.querySelector("[data-matcher-id=\"".concat(matcherId, "\"]"));
22
23
 
23
24
  if (Number(newColumnIndex) > Number(originalColumnIndex)) {
24
- indicatorLineElement.style.left = px(closestCellCoords.left - spreadsheetCoords.left + closestCell.offsetWidth - 2);
25
+ indicatorLineElement.style.left = px(closestCellCoords.left - spreadsheetCoords.left + closestCell.offsetWidth - 2 + leftScrollAmount);
25
26
  }
26
27
 
27
28
  if (Number(newColumnIndex) < Number(originalColumnIndex)) {
28
- indicatorLineElement.style.left = px(closestCellCoords.left - spreadsheetCoords.left);
29
+ indicatorLineElement.style.left = px(closestCellCoords.left - spreadsheetCoords.left + leftScrollAmount);
29
30
  }
30
31
 
31
32
  if (Number(newColumnIndex) === Number(originalColumnIndex)) {
@@ -60,7 +60,7 @@ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
60
60
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
61
61
  id: tableId,
62
62
  ref: ref,
63
- className: cx(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"))
63
+ className: cx(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"), !isFetching && rows.length === 0 ? "".concat(blockClass, "__empty-state") : '')
64
64
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(DatagridToolbar, datagridState), leftPanel && /*#__PURE__*/React.createElement("div", {
65
65
  className: "".concat(blockClass, "__grid-container ").concat(blockClass, "__displayFlex")
66
66
  }, leftPanel && leftPanel.isOpen && /*#__PURE__*/React.createElement("div", {
@@ -1,3 +1,5 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
1
3
  /*
2
4
  * Licensed Materials - Property of IBM
3
5
  * 5724-Q36
@@ -7,13 +9,30 @@
7
9
  */
8
10
  import React from 'react';
9
11
  import { pkg } from '../../../settings';
12
+ import { DataTable } from 'carbon-components-react';
13
+ import { NoDataEmptyState } from '../../EmptyStates/NoDataEmptyState';
10
14
  var blockClass = "".concat(pkg.prefix, "--datagrid");
15
+ var TableBody = DataTable.TableBody,
16
+ TableRow = DataTable.TableRow,
17
+ TableCell = DataTable.TableCell;
11
18
 
12
19
  var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
13
- var EmptyState = datagridState.EmptyState;
14
- return /*#__PURE__*/React.createElement("div", {
20
+ var getTableBodyProps = datagridState.getTableBodyProps,
21
+ headers = datagridState.headers,
22
+ emptyStateTitle = datagridState.emptyStateTitle,
23
+ emptyStateDescription = datagridState.emptyStateDescription,
24
+ emptyStateSize = datagridState.emptyStateSize,
25
+ illustrationTheme = datagridState.illustrationTheme;
26
+ return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
15
27
  className: "".concat(blockClass, "__empty-state-body")
16
- }, EmptyState);
28
+ }), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
29
+ colSpan: headers.length
30
+ }, /*#__PURE__*/React.createElement(NoDataEmptyState, {
31
+ illustrationTheme: illustrationTheme,
32
+ size: emptyStateSize,
33
+ title: emptyStateTitle,
34
+ subtitle: emptyStateDescription
35
+ }))));
17
36
  };
18
37
 
19
38
  export default DatagridEmptyBody;
@@ -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
  }),
@@ -54,9 +54,9 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
54
54
 
55
55
  RowSizeDropdown.propTypes = {
56
56
  buttonLabel: PropTypes.string,
57
- datagridName: PropTypes.string.isRequired,
58
- light: PropTypes.bool.isRequired,
57
+ datagridName: PropTypes.string,
58
+ light: PropTypes.bool,
59
59
  onChange: PropTypes.func.isRequired,
60
- selectedOption: PropTypes.string.isRequired
60
+ selectedOption: PropTypes.string
61
61
  };
62
62
  export default RowSizeDropdown;
@@ -128,7 +128,7 @@ RowSizeRadioGroup.defaultProps = {
128
128
  };
129
129
  RowSizeRadioGroup.propTypes = {
130
130
  buttonRef: PropTypes.any.isRequired,
131
- datagridName: PropTypes.string.isRequired,
131
+ datagridName: PropTypes.string,
132
132
  hideRadioGroup: PropTypes.func.isRequired,
133
133
  legendText: PropTypes.string,
134
134
  onChange: PropTypes.func.isRequired,
@@ -79,7 +79,7 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
79
79
 
80
80
  setName(filename);
81
81
  setExtension(preformattedExtensions === null || preformattedExtensions === void 0 ? void 0 : (_preformattedExtensio = preformattedExtensions[0]) === null || _preformattedExtensio === void 0 ? void 0 : _preformattedExtensio.extension);
82
- }, [filename, preformattedExtensions]);
82
+ }, [filename, preformattedExtensions, open]);
83
83
 
84
84
  var onNameChangeHandler = function onNameChangeHandler(evt) {
85
85
  setName(evt.target.value);
@@ -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