@carbon/ibm-products 1.16.0 → 1.18.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. package/README.md +30 -27
  2. package/css/components/Datagrid/styles/datagrid.css +24 -4
  3. package/css/components/Datagrid/styles/datagrid.css.map +1 -1
  4. package/css/components/Datagrid/styles/index.css +24 -4
  5. package/css/components/Datagrid/styles/index.css.map +1 -1
  6. package/css/index-full-carbon.css +241 -93
  7. package/css/index-full-carbon.css.map +1 -1
  8. package/css/index-full-carbon.min.css +7 -4
  9. package/css/index-full-carbon.min.css.map +1 -1
  10. package/css/index-without-carbon-released-only.css +9 -3
  11. package/css/index-without-carbon-released-only.css.map +1 -1
  12. package/css/index-without-carbon-released-only.min.css +4 -1
  13. package/css/index-without-carbon-released-only.min.css.map +1 -1
  14. package/css/index-without-carbon.css +124 -27
  15. package/css/index-without-carbon.css.map +1 -1
  16. package/css/index-without-carbon.min.css +6 -3
  17. package/css/index-without-carbon.min.css.map +1 -1
  18. package/css/index.css +150 -58
  19. package/css/index.css.map +1 -1
  20. package/css/index.min.css +7 -4
  21. package/css/index.min.css.map +1 -1
  22. package/es/components/AddSelect/AddSelect.js +57 -8
  23. package/es/components/AddSelect/AddSelectColumn.js +31 -73
  24. package/es/components/AddSelect/AddSelectFilter.js +2 -2
  25. package/es/components/AddSelect/AddSelectList.js +32 -6
  26. package/es/components/AddSelect/AddSelectMetaPanel.js +54 -0
  27. package/es/components/AddSelect/AddSelectSidebar.js +19 -1
  28. package/es/components/AddSelect/AddSelectSort.js +61 -0
  29. package/es/components/AddSelect/add-select-utils.js +21 -0
  30. package/es/components/AddSelect/hooks/useItemSort.js +20 -0
  31. package/es/components/DataSpreadsheet/DataSpreadsheet.js +28 -13
  32. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +60 -42
  33. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +73 -6
  34. package/es/components/DataSpreadsheet/hooks/index.js +3 -1
  35. package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +65 -19
  36. package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +60 -0
  37. package/es/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +153 -0
  38. package/es/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +16 -0
  39. package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +11 -6
  40. package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +8 -2
  41. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +7 -3
  42. package/es/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +34 -0
  43. package/es/components/Datagrid/Datagrid/Datagrid.js +25 -13
  44. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +22 -3
  45. package/es/components/Datagrid/Datagrid/DatagridHead.js +8 -16
  46. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -10
  47. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +3 -3
  48. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  49. package/es/components/Datagrid/Datagrid/index.js +6 -7
  50. package/es/components/Datagrid/index.js +1 -1
  51. package/es/components/ExportModal/ExportModal.js +10 -5
  52. package/es/components/SidePanel/SidePanel.js +5 -1
  53. package/es/components/WebTerminal/WebTerminal.js +36 -11
  54. package/es/components/WebTerminal/WebTerminalContentWrapper.js +49 -0
  55. package/es/components/WebTerminal/index.js +2 -1
  56. package/es/components/index.js +1 -1
  57. package/es/global/js/package-settings.js +1 -0
  58. package/lib/components/AddSelect/AddSelect.js +58 -8
  59. package/lib/components/AddSelect/AddSelectColumn.js +32 -71
  60. package/lib/components/AddSelect/AddSelectFilter.js +2 -2
  61. package/lib/components/AddSelect/AddSelectList.js +30 -4
  62. package/lib/components/AddSelect/AddSelectMetaPanel.js +77 -0
  63. package/lib/components/AddSelect/AddSelectSidebar.js +20 -1
  64. package/lib/components/AddSelect/AddSelectSort.js +79 -0
  65. package/lib/components/AddSelect/add-select-utils.js +29 -2
  66. package/lib/components/AddSelect/hooks/useItemSort.js +33 -0
  67. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +27 -12
  68. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +62 -41
  69. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +76 -6
  70. package/lib/components/DataSpreadsheet/hooks/index.js +17 -1
  71. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +68 -18
  72. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseMove.js +74 -0
  73. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetMouseUp.js +161 -0
  74. package/lib/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +26 -0
  75. package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +11 -6
  76. package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +8 -2
  77. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +7 -3
  78. package/lib/components/DataSpreadsheet/utils/moveColumnIndicatorLine.js +45 -0
  79. package/lib/components/Datagrid/Datagrid/Datagrid.js +26 -9
  80. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +24 -3
  81. package/lib/components/Datagrid/Datagrid/DatagridHead.js +8 -16
  82. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -10
  83. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +3 -3
  84. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  85. package/lib/components/Datagrid/Datagrid/index.js +3 -5
  86. package/lib/components/Datagrid/index.js +2 -2
  87. package/lib/components/ExportModal/ExportModal.js +9 -4
  88. package/lib/components/SidePanel/SidePanel.js +5 -1
  89. package/lib/components/WebTerminal/WebTerminal.js +36 -10
  90. package/lib/components/WebTerminal/WebTerminalContentWrapper.js +58 -0
  91. package/lib/components/WebTerminal/index.js +9 -1
  92. package/lib/components/index.js +6 -0
  93. package/lib/global/js/package-settings.js +1 -0
  94. package/package.json +17 -16
  95. package/scss/components/AddSelect/_add-select.scss +45 -5
  96. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +31 -13
  97. package/scss/components/Datagrid/_storybook-styles.scss +5 -0
  98. package/scss/components/Datagrid/styles/datagrid.scss +43 -5
  99. package/scss/components/SidePanel/_side-panel.scss +22 -3
  100. package/scss/components/WebTerminal/_storybook-styles.scss +5 -0
  101. package/scss/components/WebTerminal/_web-terminal.scss +14 -4
@@ -0,0 +1,153 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
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; }
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; }
7
+
8
+ /**
9
+ * Copyright IBM Corp. 2022, 2022
10
+ *
11
+ * This source code is licensed under the Apache-2.0 license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ import { useEffect } from 'react';
15
+ import { px } from '@carbon/layout';
16
+ import { pkg } from '../../../settings';
17
+ import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
18
+ export var useSpreadsheetMouseUp = function useSpreadsheetMouseUp(_ref) {
19
+ var currentMatcher = _ref.currentMatcher,
20
+ setSelectionAreas = _ref.setSelectionAreas,
21
+ setClickAndHoldActive = _ref.setClickAndHoldActive,
22
+ setValidStartingPoint = _ref.setValidStartingPoint,
23
+ validStartingPoint = _ref.validStartingPoint,
24
+ _ref$blockClass = _ref.blockClass,
25
+ blockClass = _ref$blockClass === void 0 ? "".concat(pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
26
+ ref = _ref.ref,
27
+ setHeaderCellHoldActive = _ref.setHeaderCellHoldActive,
28
+ setColumnOrder = _ref.setColumnOrder,
29
+ visibleColumns = _ref.visibleColumns,
30
+ setActiveCellCoordinates = _ref.setActiveCellCoordinates,
31
+ activeCellCoordinates = _ref.activeCellCoordinates,
32
+ rows = _ref.rows,
33
+ defaultColumn = _ref.defaultColumn;
34
+ useEffect(function () {
35
+ var handleMouseUp = function handleMouseUp(event) {
36
+ // Remove the cloned selection area on mouse up
37
+ if (!validStartingPoint) {
38
+ setHeaderCellHoldActive(false);
39
+ var selectionAreaCloneElement = ref.current.querySelector(".".concat(blockClass, "__selection-area--element-cloned"));
40
+
41
+ if (!selectionAreaCloneElement) {
42
+ return;
43
+ } // Mouse up while a cloned selection area exists/a column is being reordered
44
+
45
+
46
+ if (selectionAreaCloneElement) {
47
+ 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');
50
+ 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
+
52
+ if (!columnToMoveToElement) {
53
+ return;
54
+ }
55
+
56
+ var selectionAreaToMove = ref.current.querySelector("[data-matcher-id=\"".concat(currentMatcher, "\"]"));
57
+ 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;
62
+ 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);
74
+ setSelectionAreas(function (prev) {
75
+ var selectionAreaClone = deepCloneObject(prev);
76
+
77
+ if (originalColumnIndex === newColumnIndex) {
78
+ return prev;
79
+ }
80
+
81
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
82
+ return item.matcher === currentMatcher;
83
+ });
84
+
85
+ if (indexOfItemToUpdate === -1) {
86
+ return prev;
87
+ }
88
+
89
+ selectionAreaClone[indexOfItemToUpdate].header.index = Number(newColumnIndex);
90
+ selectionAreaClone[indexOfItemToUpdate].point1.column = Number(newColumnIndex);
91
+ selectionAreaClone[indexOfItemToUpdate].point2.column = Number(newColumnIndex);
92
+ return selectionAreaClone;
93
+ });
94
+ var columnIdArray = visibleColumns.map(function (column) {
95
+ return column.id;
96
+ });
97
+
98
+ var columnIdArrayClone = _toConsumableArray(columnIdArray); // Remove one element at the original index
99
+
100
+
101
+ columnIdArrayClone.splice(originalColumnIndex, 1); // Add one element at the new index
102
+
103
+ columnIdArrayClone.splice(newColumnIndex, 0, columnIdArray[originalColumnIndex]);
104
+ setColumnOrder(columnIdArrayClone); // Function provided by useTable (react-table) hook to reorder columns
105
+
106
+ var newCellCoords = _objectSpread(_objectSpread({}, activeCellCoordinates), {}, {
107
+ column: Number(newColumnIndex)
108
+ });
109
+
110
+ setActiveCellCoordinates(newCellCoords); // Remove the cloned column and indicator elements
111
+
112
+ var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
113
+ indicatorLineElement === null || indicatorLineElement === void 0 ? void 0 : indicatorLineElement.remove();
114
+ selectionAreaCloneElement === null || selectionAreaCloneElement === void 0 ? void 0 : selectionAreaCloneElement.remove();
115
+ }
116
+ } // Mouse up was on a spreadsheet body cell which is a valid
117
+ // start/end point for creating a selection area
118
+
119
+
120
+ if (validStartingPoint) {
121
+ setClickAndHoldActive(false);
122
+ setValidStartingPoint(false);
123
+ var cellButton = event.target.closest(".".concat(blockClass, "__body--td"));
124
+
125
+ if (cellButton) {
126
+ var endCellCoordinates = {
127
+ row: Number(cellButton.getAttribute('data-row-index')),
128
+ column: Number(cellButton.getAttribute('data-column-index'))
129
+ };
130
+ setSelectionAreas(function (prev) {
131
+ var selectionAreaClone = deepCloneObject(prev);
132
+ var indexOfItemToUpdate = selectionAreaClone.findIndex(function (item) {
133
+ return item.matcher === currentMatcher;
134
+ }); // No items in the array have an object that matches the value of currentMatcher
135
+
136
+ if (indexOfItemToUpdate === -1) {
137
+ return prev;
138
+ }
139
+
140
+ selectionAreaClone[indexOfItemToUpdate].point2 = endCellCoordinates;
141
+ selectionAreaClone[indexOfItemToUpdate].areaCreated = false;
142
+ return selectionAreaClone;
143
+ });
144
+ }
145
+ }
146
+ };
147
+
148
+ document.addEventListener('mouseup', handleMouseUp);
149
+ return function () {
150
+ document.removeEventListener('mouseup', handleMouseUp);
151
+ };
152
+ }, [blockClass, currentMatcher, setSelectionAreas, setClickAndHoldActive, setValidStartingPoint, validStartingPoint, ref, setHeaderCellHoldActive, setColumnOrder, visibleColumns, setActiveCellCoordinates, activeCellCoordinates, rows, defaultColumn]);
153
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
8
+ export var checkSelectedHeaderCell = function checkSelectedHeaderCell(headerIndex, selectionAreas, headerType) {
9
+ var areasCloned = deepCloneObject(selectionAreas);
10
+ var isSelectedHeader = areasCloned.some(function (area) {
11
+ var _area$header, _area$header2;
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);
14
+ });
15
+ return isSelectedHeader;
16
+ };
@@ -14,7 +14,8 @@ export var createCellSelectionArea = function createCellSelectionArea(_ref) {
14
14
  defaultColumn = _ref.defaultColumn,
15
15
  selectionAreas = _ref.selectionAreas,
16
16
  setSelectionAreas = _ref.setSelectionAreas,
17
- setActiveCellInsideSelectionArea = _ref.setActiveCellInsideSelectionArea;
17
+ setActiveCellInsideSelectionArea = _ref.setActiveCellInsideSelectionArea,
18
+ visibleColumns = _ref.visibleColumns;
18
19
 
19
20
  var _getSelectionAreaPoin = getSelectionAreaPoints(area),
20
21
  lowestColumnIndex = _getSelectionAreaPoin.lowestColumnIndex,
@@ -28,24 +29,28 @@ export var createCellSelectionArea = function createCellSelectionArea(_ref) {
28
29
  activeCellElement.setAttribute('data-selection-id', area.matcher);
29
30
  }
30
31
 
31
- var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]")) || document.querySelector(".".concat(blockClass, "__body--td")); // if we can't find the point1 element (this can happen in the case where a virtualized row is not present anymore in the DOM), we get the default height/width of the first body cell we find
32
+ var selectionAreaVariableWidth = 0;
33
+ visibleColumns.forEach(function (item, index) {
34
+ if (index >= lowestColumnIndex && index <= greatestColumnIndex) {
35
+ selectionAreaVariableWidth += (item === null || item === void 0 ? void 0 : item.width) || (defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.width);
36
+ }
37
+ });
38
+ var point1Element = document.querySelector("[data-row-index=\"".concat(area.point1.row, "\"][data-column-index=\"").concat(area.point1.column, "\"]")) || document.querySelector(".".concat(blockClass, "__body--td")); // if we can't find the point1 element (this can happen in the case where a virtualized row is not present anymore in the DOM), we get the default height of the first body cell we find
32
39
 
33
- var selectionAreaCellWidth = point1Element.offsetWidth;
34
40
  var selectionAreaCellHeight = point1Element.offsetHeight;
35
- var selectionAreaTotalWidth = selectionAreaCellWidth * (greatestColumnIndex - lowestColumnIndex + 1);
36
41
  var selectionAreaTotalHeight = selectionAreaCellHeight * (greatestRowIndex - lowestRowIndex + 1);
37
42
  var bodyContainer = document.querySelector(".".concat(blockClass, "__list--container")).firstElementChild;
38
43
  var placementElement = bodyContainer.querySelector("[data-row-index=\"".concat(lowestRowIndex, "\"][data-column-index=\"").concat(lowestColumnIndex, "\"]"));
39
44
  var relativePosition = {
40
45
  top: placementElement ? placementElement.getBoundingClientRect().top - bodyContainer.getBoundingClientRect().top : lowestRowIndex === 0 ? 0 : selectionAreaCellHeight * lowestRowIndex,
41
46
  // calculate top value here if virtualized row is not in DOM
42
- left: placementElement ? placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left : lowestColumnIndex === 0 ? 0 + (defaultColumn.rowHeaderWidth - 4) : selectionAreaCellWidth * lowestColumnIndex + (defaultColumn.rowHeaderWidth - 4) // calculate left value here if virtualized row is not in DOM, accounting for row header cell width (including borders)
47
+ left: placementElement ? placementElement.getBoundingClientRect().left - bodyContainer.getBoundingClientRect().left : lowestColumnIndex === 0 ? 0 + (defaultColumn.rowHeaderWidth - 4) : defaultColumn.width * lowestColumnIndex + (defaultColumn.rowHeaderWidth - 4) // calculate left value here if virtualized row is not in DOM, accounting for row header cell width (including borders)
43
48
 
44
49
  };
45
50
  var selectionAreaElement = document.querySelector("[data-matcher-id=\"".concat(area.matcher, "\"]")) || document.createElement('div');
46
51
  selectionAreaElement.classList.add("".concat(blockClass, "__selection-area--element"));
47
52
  selectionAreaElement.setAttribute('data-matcher-id', area.matcher);
48
- selectionAreaElement.style.width = px(selectionAreaTotalWidth);
53
+ selectionAreaElement.style.width = px(selectionAreaVariableWidth);
49
54
  selectionAreaElement.style.height = px(selectionAreaTotalHeight);
50
55
  selectionAreaElement.style.left = px(relativePosition.left);
51
56
  selectionAreaElement.style.top = px(relativePosition.top);
@@ -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
  };
@@ -55,7 +55,7 @@ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref)
55
55
  matcher: tempMatcher,
56
56
  header: {
57
57
  type: type,
58
- index: index
58
+ index: type === 'column' ? columnValue : rowValue
59
59
  }
60
60
  };
61
61
  setSelectionAreas(function (prev) {
@@ -63,10 +63,14 @@ export var handleHeaderCellSelection = function handleHeaderCellSelection(_ref)
63
63
 
64
64
  if (isHoldingCommandKey) {
65
65
  var selectionsFromHeaderCell = selectionsClone.filter(function (item) {
66
- return item.header.type;
66
+ var _item$header;
67
+
68
+ return (_item$header = item.header) === null || _item$header === void 0 ? void 0 : _item$header.type;
67
69
  });
68
70
  var previouslyCreatedHeaderSelection = selectionsFromHeaderCell.filter(function (item) {
69
- return item.header.type === type;
71
+ var _item$header2;
72
+
73
+ return ((_item$header2 = item.header) === null || _item$header2 === void 0 ? void 0 : _item$header2.type) === type;
70
74
  });
71
75
  var isHeaderPartOfPreviousSelection = checkActiveHeaderCell(index, previouslyCreatedHeaderSelection, type); // Prevents row/column header selections from being created multiple times
72
76
 
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { px } from '@carbon/layout';
8
+ import { pkg } from '../../../settings';
9
+ export var moveColumnIndicatorLine = function moveColumnIndicatorLine(_ref) {
10
+ var _ref$blockClass = _ref.blockClass,
11
+ blockClass = _ref$blockClass === void 0 ? "".concat(pkg.prefix, "--data-spreadsheet") : _ref$blockClass,
12
+ clonedSelectionElement = _ref.clonedSelectionElement,
13
+ ref = _ref.ref,
14
+ spreadsheetCoords = _ref.spreadsheetCoords;
15
+ var closestCell = event.target.closest(".".concat(blockClass, "--interactive-cell-element"));
16
+ var newColumnIndex = closestCell === null || closestCell === void 0 ? void 0 : closestCell.getAttribute('data-column-index');
17
+ var originalColumnIndex = clonedSelectionElement === null || clonedSelectionElement === void 0 ? void 0 : clonedSelectionElement.getAttribute('data-column-index-original');
18
+ var closestCellCoords = closestCell.getBoundingClientRect();
19
+ var indicatorLineElement = ref.current.querySelector(".".concat(blockClass, "__reorder-indicator-line"));
20
+ var matcherId = clonedSelectionElement === null || clonedSelectionElement === void 0 ? void 0 : clonedSelectionElement.getAttribute('data-matcher-id');
21
+ var selectionAreaOrigin = ref.current.querySelector("[data-matcher-id=\"".concat(matcherId, "\"]"));
22
+
23
+ if (Number(newColumnIndex) > Number(originalColumnIndex)) {
24
+ indicatorLineElement.style.left = px(closestCellCoords.left - spreadsheetCoords.left + closestCell.offsetWidth - 2);
25
+ }
26
+
27
+ if (Number(newColumnIndex) < Number(originalColumnIndex)) {
28
+ indicatorLineElement.style.left = px(closestCellCoords.left - spreadsheetCoords.left);
29
+ }
30
+
31
+ if (Number(newColumnIndex) === Number(originalColumnIndex)) {
32
+ indicatorLineElement.style.left = selectionAreaOrigin.style.left;
33
+ }
34
+ };
@@ -1,16 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["getTableProps", "withVirtualScroll", "DatagridPagination", "isFetching", "tableId", "CustomizeColumnsModal", "leftPanel", "fullHeightDatagrid", "verticalAlign", "variableRowHeight", "className"];
4
+ var _excluded = ["datagridState"];
5
5
 
6
- /*
7
- * Licensed Materials - Property of IBM
8
- * 5724-Q36
9
- * (c) Copyright IBM Corp. 2020 - 2021
10
- * US Government Users Restricted Rights - Use, duplication or disclosure
11
- * restricted by GSA ADP Schedule Contract with IBM Corp.
6
+ /**
7
+ * Copyright IBM Corp. 2020, 2022
8
+ *
9
+ * This source code is licensed under the Apache-2.0 license found in the
10
+ * LICENSE file in the root directory of this source tree.
12
11
  */
13
12
  import React from 'react';
13
+ import PropTypes from 'prop-types';
14
14
  import { DataTable } from 'carbon-components-react';
15
15
  import cx from 'classnames';
16
16
  import DatagridHead from './DatagridHead';
@@ -18,13 +18,22 @@ import DatagridBody from './DatagridBody';
18
18
  import DatagridToolbar from './DatagridToolbar';
19
19
  import { getDevtoolsProps } from '../../../global/js/utils/devtools';
20
20
  import { pkg } from '../../../settings';
21
+ import pconsole from '../../../global/js/utils/pconsole';
21
22
  var blockClass = "".concat(pkg.prefix, "--datagrid");
22
23
  var componentName = 'Datagrid';
23
24
  var TableContainer = DataTable.TableContainer,
24
25
  Table = DataTable.Table;
25
- var Datagrid = /*#__PURE__*/React.forwardRef(function (datagridState, ref) {
26
+ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
26
27
  var _getTableProps;
27
28
 
29
+ var datagridState = _ref.datagridState,
30
+ rest = _objectWithoutProperties(_ref, _excluded);
31
+
32
+ if (!datagridState) {
33
+ pconsole.warn('Datagrid was not passed datagridState which is required to render this component.');
34
+ return null;
35
+ }
36
+
28
37
  var _datagridState$getTab = datagridState.getTableProps,
29
38
  getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
30
39
  withVirtualScroll = datagridState.withVirtualScroll,
@@ -37,9 +46,7 @@ var Datagrid = /*#__PURE__*/React.forwardRef(function (datagridState, ref) {
37
46
  _datagridState$vertic = datagridState.verticalAlign,
38
47
  verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
39
48
  variableRowHeight = datagridState.variableRowHeight,
40
- className = datagridState.className,
41
- rest = _objectWithoutProperties(datagridState, _excluded);
42
-
49
+ className = datagridState.className;
43
50
  var rows = DatagridPagination && datagridState.page || datagridState.rows;
44
51
  var dataGrid = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
45
52
  className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '')
@@ -53,7 +60,7 @@ var Datagrid = /*#__PURE__*/React.forwardRef(function (datagridState, ref) {
53
60
  return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
54
61
  id: tableId,
55
62
  ref: ref,
56
- 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") : '')
57
64
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(DatagridToolbar, datagridState), leftPanel && /*#__PURE__*/React.createElement("div", {
58
65
  className: "".concat(blockClass, "__grid-container ").concat(blockClass, "__displayFlex")
59
66
  }, leftPanel && leftPanel.isOpen && /*#__PURE__*/React.createElement("div", {
@@ -67,4 +74,9 @@ Datagrid = pkg.checkComponentEnabled(Datagrid, componentName); // The display na
67
74
  // is used in preference to relying on function.name.
68
75
 
69
76
  Datagrid.displayName = componentName;
70
- export default Datagrid;
77
+ Datagrid.propTypes = {
78
+ /**
79
+ * The data grid state, much of it being supplied by the useDatagrid hook
80
+ */
81
+ datagridState: PropTypes.object.isRequired
82
+ };
@@ -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;
@@ -1,11 +1,8 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
-
3
- /*
4
- * Licensed Materials - Property of IBM
5
- * 5724-Q36
6
- * (c) Copyright IBM Corp. 2020, 2021
7
- * US Government Users Restricted Rights - Use, duplication or disclosure
8
- * restricted by GSA ADP Schedule Contract with IBM Corp.
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
9
6
  */
10
7
  import React from 'react';
11
8
  import { DataTable } from 'carbon-components-react';
@@ -16,14 +13,9 @@ var DatagridHead = function DatagridHead(datagridState) {
16
13
  headerGroups = _datagridState$header === void 0 ? [] : _datagridState$header,
17
14
  headRef = datagridState.headRef,
18
15
  HeaderRow = datagridState.HeaderRow;
19
- return /*#__PURE__*/React.createElement(TableHead, null, headerGroups.map(function (headerGroup, index) {
20
- return (
21
- /*#__PURE__*/
22
- // doesn't support header grouping.
23
- React.createElement("div", _extends({}, headerGroup.getHeaderGroupProps(), {
24
- ref: headRef,
25
- key: "header_".concat(index)
26
- }), HeaderRow(datagridState))
16
+ return /*#__PURE__*/React.createElement(TableHead, null, headerGroups.map(function (headerGroup) {
17
+ return (// doesn't support header grouping.
18
+ HeaderRow(datagridState, headRef, headerGroup)
27
19
  );
28
20
  }));
29
21
  };
@@ -1,12 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
- /*
5
- * Licensed Materials - Property of IBM
6
- * 5724-Q36
7
- * (c) Copyright IBM Corp. 2020, 2021
8
- * US Government Users Restricted Rights - Use, duplication or disclosure
9
- * restricted by GSA ADP Schedule Contract with IBM Corp.
4
+ /**
5
+ * Copyright IBM Corp. 2020, 2022
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
10
9
  */
11
10
  // @flow
12
11
  import React from 'react';
@@ -16,10 +15,11 @@ import { selectionColumnId } from '../common-column-ids';
16
15
  import { pkg } from '../../../settings';
17
16
  var blockClass = "".concat(pkg.prefix, "--datagrid");
18
17
 
19
- var HeaderRow = function HeaderRow(datagridState) {
20
- return /*#__PURE__*/React.createElement(TableRow, {
21
- className: "".concat(blockClass, "__head")
22
- }, datagridState.headers.filter(function (_ref) {
18
+ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
19
+ return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps(), {
20
+ className: cx("".concat(blockClass, "__head"), headerGroup.getHeaderGroupProps().className),
21
+ ref: headRef
22
+ }), datagridState.headers.filter(function (_ref) {
23
23
  var isVisible = _ref.isVisible;
24
24
  return isVisible;
25
25
  }).map(function (header) {
@@ -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,
@@ -1,8 +1,7 @@
1
- /*
2
- * Licensed Materials - Property of IBM
3
- * 5724-Q36
4
- * (c) Copyright IBM Corp. 2020
5
- * US Government Users Restricted Rights - Use, duplication or disclosure
6
- * restricted by GSA ADP Schedule Contract with IBM Corp.
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
7
6
  */
8
- export { default } from './Datagrid';
7
+ export { Datagrid } from './Datagrid';
@@ -5,7 +5,7 @@
5
5
  * US Government Users Restricted Rights - Use, duplication or disclosure
6
6
  * restricted by GSA ADP Schedule Contract with IBM Corp.
7
7
  */
8
- export { default as Datagrid } from './Datagrid';
8
+ export { Datagrid } from './Datagrid';
9
9
  export { default as useDatagrid } from './useDatagrid';
10
10
  export { default as useInfiniteScroll } from './useInfiniteScroll';
11
11
  export { default as useNestedRows } from './useNestedRows';
@@ -14,7 +14,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
14
14
  // This source code is licensed under the Apache-2.0 license found in the
15
15
  // LICENSE file in the root directory of this source tree.
16
16
  //
17
- import React, { useState, useRef, forwardRef } from 'react';
17
+ import React, { useState, useRef, forwardRef, useEffect } from 'react';
18
18
  import { Button, ComposedModal, ModalHeader, ModalFooter, ModalBody, TextInput, RadioButton, RadioButtonGroup, FormGroup, Loading, PasswordInput } from 'carbon-components-react';
19
19
  import cx from 'classnames';
20
20
  import { ErrorFilled16, CheckmarkFilled16 } from '@carbon/icons-react';
@@ -30,8 +30,6 @@ var defaults = {
30
30
  validExtensions: Object.freeze([])
31
31
  };
32
32
  export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
33
- var _preformattedExtensio;
34
-
35
33
  var body = _ref.body,
36
34
  className = _ref.className,
37
35
  error = _ref.error,
@@ -60,7 +58,7 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
60
58
  validExtensions = _ref$validExtensions === void 0 ? defaults.validExtensions : _ref$validExtensions,
61
59
  rest = _objectWithoutProperties(_ref, _excluded);
62
60
 
63
- var _useState = useState(filename),
61
+ var _useState = useState(''),
64
62
  _useState2 = _slicedToArray(_useState, 2),
65
63
  name = _useState2[0],
66
64
  setName = _useState2[1];
@@ -71,11 +69,18 @@ export var ExportModal = /*#__PURE__*/forwardRef(function (_ref, ref) {
71
69
  setDirtyInput = _useState4[1]; // by default (if it exists) use the first extension in the extension array
72
70
 
73
71
 
74
- var _useState5 = useState(preformattedExtensions === null || preformattedExtensions === void 0 ? void 0 : (_preformattedExtensio = preformattedExtensions[0]) === null || _preformattedExtensio === void 0 ? void 0 : _preformattedExtensio.extension),
72
+ var _useState5 = useState(''),
75
73
  _useState6 = _slicedToArray(_useState5, 2),
76
74
  extension = _useState6[0],
77
75
  setExtension = _useState6[1];
78
76
 
77
+ useEffect(function () {
78
+ var _preformattedExtensio;
79
+
80
+ setName(filename);
81
+ setExtension(preformattedExtensions === null || preformattedExtensions === void 0 ? void 0 : (_preformattedExtensio = preformattedExtensions[0]) === null || _preformattedExtensio === void 0 ? void 0 : _preformattedExtensio.extension);
82
+ }, [filename, preformattedExtensions]);
83
+
79
84
  var onNameChangeHandler = function onNameChangeHandler(evt) {
80
85
  setName(evt.target.value);
81
86
  };
@@ -272,13 +272,17 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
272
272
 
273
273
  var actionToolbarElement = document.querySelector(".".concat(blockClass, "__action-toolbar"));
274
274
 
275
+ var _labelText = document.querySelector(".".concat(blockClass, "__label-text"));
276
+
275
277
  var _sidePanelSubtitleElementHeight = (_sidePanelSubtitleElement === null || _sidePanelSubtitleElement === void 0 ? void 0 : _sidePanelSubtitleElement.offsetHeight) || 0;
276
278
 
277
279
  var sidePanelActionBarElementHeight = (actionToolbarElement === null || actionToolbarElement === void 0 ? void 0 : actionToolbarElement.offsetHeight) || 0;
278
280
  var titleHeight = (_sidePanelTitleElement === null || _sidePanelTitleElement === void 0 ? void 0 : _sidePanelTitleElement.offsetHeight) + 24;
281
+ var labelHeight = (_labelText === null || _labelText === void 0 ? void 0 : _labelText.offsetHeight) || 0;
279
282
  _sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--title-text-height"), "".concat(titleHeight, "px"));
280
283
  _sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--subtitle-container-height"), "".concat(_sidePanelSubtitleElementHeight, "px"));
281
284
  _sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--action-bar-container-height"), "".concat(sidePanelActionBarElementHeight, "px"));
285
+ _sidePanelOuter === null || _sidePanelOuter === void 0 ? void 0 : _sidePanelOuter.style.setProperty("--".concat(blockClass, "--label-text-height"), "".concat(labelHeight, "px"));
282
286
  }
283
287
  }, [open, animateTitle, animationComplete, shouldRender, panelHeight, title, size, reducedMotion.matches]); // click outside functionality if `includeOverlay` prop is set
284
288
 
@@ -492,7 +496,7 @@ export var SidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
492
496
  className: "".concat(blockClass, "__visually-hidden")
493
497
  }, "Focus sentinel"), !animateTitle && renderHeader(), /*#__PURE__*/React.createElement("div", {
494
498
  ref: sidePanelInnerRef,
495
- className: cx("".concat(blockClass, "__inner-content"), (_cx4 = {}, _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content"), !animateTitle), _defineProperty(_cx4, "".concat(blockClass, "__inner-content-with-actions"), actions && actions.length), _cx4))
499
+ className: cx("".concat(blockClass, "__inner-content"), (_cx4 = {}, _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content"), !animateTitle), _defineProperty(_cx4, "".concat(blockClass, "__static-inner-content-no-actions"), !animateTitle && !(actions !== null && actions !== void 0 && actions.length)), _defineProperty(_cx4, "".concat(blockClass, "__inner-content-with-actions"), actions && actions.length), _cx4))
496
500
  }, animateTitle && renderHeader(), /*#__PURE__*/React.createElement("div", {
497
501
  className: "".concat(blockClass, "__body-content")
498
502
  }, children), /*#__PURE__*/React.createElement(ActionSet, {