@carbon/ibm-products 1.14.0 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. package/css/components/Datagrid/styles/datagrid.css +4 -0
  2. package/css/components/Datagrid/styles/datagrid.css.map +1 -1
  3. package/css/components/Datagrid/styles/index.css +5 -1
  4. package/css/components/Datagrid/styles/index.css.map +1 -1
  5. package/css/components/Datagrid/styles/useNestedRows.css +1 -1
  6. package/css/index-full-carbon.css +75 -16
  7. package/css/index-full-carbon.css.map +1 -1
  8. package/css/index-full-carbon.min.css +6 -3
  9. package/css/index-full-carbon.min.css.map +1 -1
  10. package/css/index-without-carbon-released-only.css +13 -7
  11. package/css/index-without-carbon-released-only.css.map +1 -1
  12. package/css/index-without-carbon-released-only.min.css +5 -2
  13. package/css/index-without-carbon-released-only.min.css.map +1 -1
  14. package/css/index-without-carbon.css +75 -16
  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 +75 -16
  19. package/css/index.css.map +1 -1
  20. package/css/index.min.css +6 -3
  21. package/css/index.min.css.map +1 -1
  22. package/es/components/AddSelect/AddSelect.js +34 -23
  23. package/es/components/AddSelect/AddSelectFilter.js +52 -9
  24. package/es/components/DataSpreadsheet/DataSpreadsheet.js +186 -129
  25. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +67 -15
  26. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +55 -11
  27. package/es/components/DataSpreadsheet/hooks/index.js +2 -1
  28. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +36 -8
  29. package/es/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +113 -0
  30. package/es/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +16 -0
  31. package/es/components/DataSpreadsheet/utils/createCellSelectionArea.js +29 -12
  32. package/es/components/DataSpreadsheet/utils/generateData.js +17 -9
  33. package/es/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +18 -0
  34. package/es/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +30 -0
  35. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +121 -0
  36. package/es/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +108 -0
  37. package/es/components/DataSpreadsheet/utils/handleEditSubmit.js +87 -0
  38. package/es/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +46 -8
  39. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +153 -15
  40. package/es/components/DataSpreadsheet/utils/selectAllCells.js +53 -0
  41. package/es/components/Datagrid/Datagrid/Datagrid.js +24 -12
  42. package/es/components/Datagrid/Datagrid/DatagridHead.js +8 -16
  43. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -10
  44. package/es/components/Datagrid/Datagrid/DatagridRow.js +12 -2
  45. package/es/components/Datagrid/Datagrid/index.js +6 -7
  46. package/es/components/Datagrid/index.js +1 -1
  47. package/es/components/Datagrid/useNestedRows.js +3 -3
  48. package/es/components/Datagrid/useRowExpander.js +1 -1
  49. package/es/components/ExportModal/ExportModal.js +10 -5
  50. package/es/components/MultiAddSelect/MultiAddSelect.js +150 -3
  51. package/es/components/PageHeader/PageHeader.js +3 -1
  52. package/es/components/SidePanel/SidePanel.js +5 -1
  53. package/es/components/SingleAddSelect/SingleAddSelect.js +90 -4
  54. package/es/components/TagSet/TagSet.js +13 -6
  55. package/es/components/Tearsheet/TearsheetShell.js +34 -10
  56. package/es/components/WebTerminal/WebTerminal.js +36 -11
  57. package/es/components/WebTerminal/WebTerminalContentWrapper.js +49 -0
  58. package/es/components/WebTerminal/index.js +2 -1
  59. package/es/components/index.js +1 -1
  60. package/es/global/js/package-settings.js +3 -1
  61. package/lib/components/AddSelect/AddSelect.js +34 -23
  62. package/lib/components/AddSelect/AddSelectFilter.js +51 -8
  63. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +190 -128
  64. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +69 -15
  65. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +58 -12
  66. package/lib/components/DataSpreadsheet/hooks/index.js +9 -1
  67. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +36 -8
  68. package/lib/components/DataSpreadsheet/hooks/useSpreadsheetEdit.js +129 -0
  69. package/lib/components/DataSpreadsheet/utils/checkSelectedHeaderCell.js +26 -0
  70. package/lib/components/DataSpreadsheet/utils/createCellSelectionArea.js +31 -13
  71. package/lib/components/DataSpreadsheet/utils/generateData.js +17 -9
  72. package/lib/components/DataSpreadsheet/utils/getSelectionAreaPoints.js +27 -0
  73. package/lib/components/DataSpreadsheet/utils/getSpreadsheetWidth.js +40 -0
  74. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionEnter.js +127 -0
  75. package/lib/components/DataSpreadsheet/utils/handleActiveCellInSelectionTab.js +118 -0
  76. package/lib/components/DataSpreadsheet/utils/handleEditSubmit.js +94 -0
  77. package/lib/components/DataSpreadsheet/utils/handleHeaderCellSelection.js +48 -8
  78. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +161 -22
  79. package/lib/components/DataSpreadsheet/utils/selectAllCells.js +60 -0
  80. package/lib/components/Datagrid/Datagrid/Datagrid.js +25 -8
  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/DatagridRow.js +14 -2
  84. package/lib/components/Datagrid/Datagrid/index.js +3 -5
  85. package/lib/components/Datagrid/index.js +2 -2
  86. package/lib/components/Datagrid/useNestedRows.js +3 -3
  87. package/lib/components/Datagrid/useRowExpander.js +1 -1
  88. package/lib/components/ExportModal/ExportModal.js +9 -4
  89. package/lib/components/MultiAddSelect/MultiAddSelect.js +150 -2
  90. package/lib/components/PageHeader/PageHeader.js +3 -1
  91. package/lib/components/SidePanel/SidePanel.js +5 -1
  92. package/lib/components/SingleAddSelect/SingleAddSelect.js +91 -3
  93. package/lib/components/TagSet/TagSet.js +13 -6
  94. package/lib/components/Tearsheet/TearsheetShell.js +36 -10
  95. package/lib/components/WebTerminal/WebTerminal.js +36 -10
  96. package/lib/components/WebTerminal/WebTerminalContentWrapper.js +58 -0
  97. package/lib/components/WebTerminal/index.js +9 -1
  98. package/lib/components/index.js +6 -0
  99. package/lib/global/js/package-settings.js +3 -1
  100. package/package.json +13 -13
  101. package/scss/components/AboutModal/_about-modal.scss +4 -0
  102. package/scss/components/AddSelect/_add-select.scss +9 -2
  103. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +39 -2
  104. package/scss/components/Datagrid/styles/datagrid.scss +8 -0
  105. package/scss/components/Datagrid/styles/useNestedRows.scss +1 -1
  106. package/scss/components/ExportModal/_export-modal.scss +0 -4
  107. package/scss/components/SidePanel/_side-panel.scss +22 -3
  108. package/scss/components/WebTerminal/_storybook-styles.scss +5 -0
  109. package/scss/components/WebTerminal/_web-terminal.scss +14 -4
@@ -1,18 +1,36 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
- exports.includesShift = exports.handleMultipleKeys = void 0;
8
+ exports.includesShift = exports.includesResourceKey = exports.handleMultipleKeys = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
11
 
8
12
  var _deepCloneObject = require("../../../global/js/utils/deepCloneObject");
9
13
 
10
- /**
11
- * Copyright IBM Corp. 2022, 2022
12
- *
13
- * This source code is licensed under the Apache-2.0 license found in the
14
- * LICENSE file in the root directory of this source tree.
15
- */
14
+ var _uuidv = _interopRequireDefault(require("../../../global/js/utils/uuidv4"));
15
+
16
+ var _selectAllCells = require("./selectAllCells");
17
+
18
+ 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; }
19
+
20
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
+
22
+ var includesResourceKey = function includesResourceKey(arr, usingMac) {
23
+ if (usingMac) {
24
+ return includesMeta(arr);
25
+ }
26
+
27
+ if (!usingMac) {
28
+ return includesControl(arr);
29
+ }
30
+ };
31
+
32
+ exports.includesResourceKey = includesResourceKey;
33
+
16
34
  var includesShift = function includesShift(arr) {
17
35
  if (arr.includes('ShiftLeft') || arr.includes('ShiftRight')) {
18
36
  return true;
@@ -40,7 +58,7 @@ var includesControl = function includesControl(arr) {
40
58
  };
41
59
 
42
60
  var handleMultipleKeys = function handleMultipleKeys(_ref) {
43
- var _selectionAreasClone$;
61
+ var _selectionAreasClone$, _selectionAreasClone$2, _selectionAreasClone$3;
44
62
 
45
63
  var activeCellCoordinates = _ref.activeCellCoordinates,
46
64
  event = _ref.event,
@@ -49,15 +67,21 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
49
67
  currentMatcher = _ref.currentMatcher,
50
68
  rows = _ref.rows,
51
69
  setSelectionAreas = _ref.setSelectionAreas,
52
- columns = _ref.columns;
70
+ columns = _ref.columns,
71
+ updateActiveCellCoordinates = _ref.updateActiveCellCoordinates,
72
+ spreadsheetRef = _ref.spreadsheetRef,
73
+ removeCellSelections = _ref.removeCellSelections,
74
+ blockClass = _ref.blockClass,
75
+ setCurrentMatcher = _ref.setCurrentMatcher,
76
+ usingMac = _ref.usingMac;
53
77
  var selectionAreasClone = (0, _deepCloneObject.deepCloneObject)(selectionAreas);
54
78
  var indexOfCurrentArea = selectionAreasClone.findIndex(function (item) {
55
79
  return item.matcher === currentMatcher;
56
80
  });
57
- var pointToUpdate = (_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) !== null && _selectionAreasClone$ !== void 0 && _selectionAreasClone$.point2 ? selectionAreasClone[indexOfCurrentArea].point2 : selectionAreasClone[indexOfCurrentArea].point1; // Down + Shift
81
+ var pointToUpdate = (_selectionAreasClone$ = selectionAreasClone[indexOfCurrentArea]) !== null && _selectionAreasClone$ !== void 0 && _selectionAreasClone$.point2 ? (_selectionAreasClone$2 = selectionAreasClone[indexOfCurrentArea]) === null || _selectionAreasClone$2 === void 0 ? void 0 : _selectionAreasClone$2.point2 : (_selectionAreasClone$3 = selectionAreasClone[indexOfCurrentArea]) === null || _selectionAreasClone$3 === void 0 ? void 0 : _selectionAreasClone$3.point1; // Down + Shift
58
82
 
59
83
  if (includesShift(keysPressedList) && keysPressedList.includes('ArrowDown') && keysPressedList.length === 2) {
60
- if (rows.length - 1 === pointToUpdate.row) {
84
+ if (rows.length - 1 === (pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.row) || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
61
85
  return;
62
86
  }
63
87
 
@@ -72,7 +96,7 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
72
96
 
73
97
 
74
98
  if (includesShift(keysPressedList) && keysPressedList.includes('ArrowRight') && keysPressedList.length === 2) {
75
- if (columns.length - 1 === pointToUpdate.column) {
99
+ if (columns.length - 1 === (pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.column) || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
76
100
  return;
77
101
  }
78
102
 
@@ -87,7 +111,7 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
87
111
 
88
112
 
89
113
  if (includesShift(keysPressedList) && keysPressedList.includes('ArrowUp') && keysPressedList.length === 2) {
90
- if (pointToUpdate.row === 0) {
114
+ if ((pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.row) === 0 || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
91
115
  return;
92
116
  }
93
117
 
@@ -102,7 +126,7 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
102
126
 
103
127
 
104
128
  if (includesShift(keysPressedList) && keysPressedList.includes('ArrowLeft') && keysPressedList.length === 2) {
105
- if (pointToUpdate.column === 0) {
129
+ if ((pointToUpdate === null || pointToUpdate === void 0 ? void 0 : pointToUpdate.column) === 0 || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
106
130
  return;
107
131
  }
108
132
 
@@ -116,7 +140,7 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
116
140
  } // CMD + a (select all)
117
141
 
118
142
 
119
- if (includesMeta(keysPressedList) && keysPressedList.includes('KeyA')) {
143
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('KeyA')) {
120
144
  event.preventDefault();
121
145
  var selectionPoint1 = {
122
146
  row: 0,
@@ -125,7 +149,20 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
125
149
  var selectionPoint2 = {
126
150
  row: rows.length - 1,
127
151
  column: columns.length - 1
128
- };
152
+ }; // If indexOfCurrentArea is -1, it means the active cell is in a cell header position
153
+
154
+ if (indexOfCurrentArea === -1) {
155
+ (0, _selectAllCells.selectAllCells)({
156
+ ref: spreadsheetRef,
157
+ setCurrentMatcher: setCurrentMatcher,
158
+ setSelectionAreas: setSelectionAreas,
159
+ rows: rows,
160
+ columns: columns,
161
+ activeCellCoordinates: activeCellCoordinates,
162
+ updateActiveCellCoordinates: updateActiveCellCoordinates
163
+ });
164
+ }
165
+
129
166
  selectionAreasClone[indexOfCurrentArea].point1 = selectionPoint1;
130
167
  selectionAreasClone[indexOfCurrentArea].point2 = selectionPoint2;
131
168
  selectionAreasClone[indexOfCurrentArea].areaCreated = false;
@@ -136,12 +173,35 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
136
173
  if (includesControl(keysPressedList) && keysPressedList.includes('Space')) {
137
174
  var _selectionPoint = {
138
175
  row: 0,
139
- column: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
176
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
140
177
  };
141
178
  var _selectionPoint2 = {
142
179
  row: rows.length - 1,
143
- column: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
144
- };
180
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column
181
+ }; // If indexOfCurrentArea is -1, it means the active cell is in a cell header position
182
+
183
+ if (indexOfCurrentArea === -1) {
184
+ var tempMatcher = (0, _uuidv.default)();
185
+ var newSelectionArea = {
186
+ point1: _selectionPoint,
187
+ point2: _selectionPoint2,
188
+ areaCreated: false,
189
+ matcher: tempMatcher
190
+ };
191
+
192
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
193
+
194
+ updateActiveCellCoordinates({
195
+ coords: coordinatesClone,
196
+ updatedValue: {
197
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column,
198
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row
199
+ }
200
+ });
201
+ setCurrentMatcher(tempMatcher);
202
+ return setSelectionAreas([newSelectionArea]);
203
+ }
204
+
145
205
  selectionAreasClone[indexOfCurrentArea].point1 = _selectionPoint;
146
206
  selectionAreasClone[indexOfCurrentArea].point2 = _selectionPoint2;
147
207
  selectionAreasClone[indexOfCurrentArea].areaCreated = false;
@@ -151,17 +211,96 @@ var handleMultipleKeys = function handleMultipleKeys(_ref) {
151
211
 
152
212
  if (includesShift(keysPressedList) && keysPressedList.includes('Space')) {
153
213
  var _selectionPoint3 = {
154
- row: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
214
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
155
215
  column: 0
156
216
  };
157
217
  var _selectionPoint4 = {
158
- row: activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
218
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row,
159
219
  column: columns.length - 1
160
- };
220
+ }; // If indexOfCurrentArea is -1, it means the active cell is in a cell header position
221
+
222
+ if (indexOfCurrentArea === -1) {
223
+ var _tempMatcher = (0, _uuidv.default)();
224
+
225
+ var _newSelectionArea = {
226
+ point1: _selectionPoint3,
227
+ point2: _selectionPoint4,
228
+ areaCreated: false,
229
+ matcher: _tempMatcher
230
+ };
231
+
232
+ var _coordinatesClone = _objectSpread({}, activeCellCoordinates);
233
+
234
+ updateActiveCellCoordinates({
235
+ coords: _coordinatesClone,
236
+ updatedValue: {
237
+ column: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column,
238
+ row: (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' ? 0 : activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row
239
+ }
240
+ });
241
+ setCurrentMatcher(_tempMatcher);
242
+ return setSelectionAreas([_newSelectionArea]);
243
+ }
244
+
161
245
  selectionAreasClone[indexOfCurrentArea].point1 = _selectionPoint3;
162
246
  selectionAreasClone[indexOfCurrentArea].point2 = _selectionPoint4;
163
247
  selectionAreasClone[indexOfCurrentArea].areaCreated = false;
164
248
  setSelectionAreas(selectionAreasClone);
249
+ } // CMD + HOME (Selects first cell in first row)
250
+
251
+
252
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('Home')) {
253
+ var scrollElement = spreadsheetRef.current.querySelector(".".concat(blockClass, "__list--container"));
254
+ scrollElement.scrollTop = 0;
255
+
256
+ var _coordinatesClone2 = _objectSpread({}, activeCellCoordinates);
257
+
258
+ removeCellSelections({
259
+ spreadsheetRef: spreadsheetRef
260
+ });
261
+ updateActiveCellCoordinates({
262
+ coords: _coordinatesClone2,
263
+ updatedValue: {
264
+ column: 0,
265
+ row: 0
266
+ }
267
+ });
268
+ } // CMD + END (Selects last cell in last row)
269
+
270
+
271
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('End')) {
272
+ var _scrollElement = spreadsheetRef.current.querySelector(".".concat(blockClass, "__list--container"));
273
+
274
+ _scrollElement.scrollTop = _scrollElement.scrollHeight;
275
+
276
+ var _coordinatesClone3 = _objectSpread({}, activeCellCoordinates);
277
+
278
+ removeCellSelections({
279
+ spreadsheetRef: spreadsheetRef
280
+ });
281
+ var lastCellExists = !!rows[(rows === null || rows === void 0 ? void 0 : rows.length) - 1].cells[(columns === null || columns === void 0 ? void 0 : columns.length) - 1];
282
+
283
+ var updateToLastCell = function updateToLastCell() {
284
+ updateActiveCellCoordinates({
285
+ coords: _coordinatesClone3,
286
+ updatedValue: {
287
+ column: columns.length - 1,
288
+ row: rows.length - 1
289
+ }
290
+ });
291
+ }; // With the spreadsheet supporting virtualized data, it's possible that the last cell
292
+ // has never been rendered yet, if that's the case we scroll to the bottom of the spreadsheet
293
+ // and add a timeout to wait for the last row to render to the DOM before updating the active cell coordinates.
294
+ // If we're able to verify that the last row has been rendered, no timeout is used.
295
+
296
+
297
+ if (lastCellExists) {
298
+ updateToLastCell();
299
+ } else {
300
+ setTimeout(function () {
301
+ updateToLastCell();
302
+ }, 1);
303
+ }
165
304
  }
166
305
  };
167
306
 
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.selectAllCells = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _removeCellSelections = require("./removeCellSelections");
13
+
14
+ var _uuidv = _interopRequireDefault(require("../../../global/js/utils/uuidv4"));
15
+
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
+
20
+ var selectAllCells = function selectAllCells(_ref) {
21
+ var activeCellCoordinates = _ref.activeCellCoordinates,
22
+ columns = _ref.columns,
23
+ setCurrentMatcher = _ref.setCurrentMatcher,
24
+ setSelectionAreas = _ref.setSelectionAreas,
25
+ ref = _ref.ref,
26
+ rows = _ref.rows,
27
+ updateActiveCellCoordinates = _ref.updateActiveCellCoordinates;
28
+ (0, _removeCellSelections.removeCellSelections)({
29
+ spreadsheetRef: ref
30
+ });
31
+ var selectionPoint1 = {
32
+ row: 0,
33
+ column: 0
34
+ };
35
+ var selectionPoint2 = {
36
+ row: rows.length - 1,
37
+ column: columns.length - 1
38
+ };
39
+ var tempMatcher = (0, _uuidv.default)();
40
+ var newSelectionArea = {
41
+ point1: selectionPoint1,
42
+ point2: selectionPoint2,
43
+ areaCreated: false,
44
+ matcher: tempMatcher
45
+ };
46
+
47
+ var coordinatesClone = _objectSpread({}, activeCellCoordinates);
48
+
49
+ updateActiveCellCoordinates({
50
+ coords: coordinatesClone,
51
+ updatedValue: {
52
+ column: 0,
53
+ row: 0
54
+ }
55
+ });
56
+ setCurrentMatcher(tempMatcher);
57
+ return setSelectionAreas([newSelectionArea]);
58
+ };
59
+
60
+ exports.selectAllCells = selectAllCells;
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = void 0;
8
+ exports.Datagrid = void 0;
9
9
 
10
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
11
 
@@ -15,6 +15,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
15
15
 
16
16
  var _react = _interopRequireDefault(require("react"));
17
17
 
18
+ var _propTypes = _interopRequireDefault(require("prop-types"));
19
+
18
20
  var _carbonComponentsReact = require("carbon-components-react");
19
21
 
20
22
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -29,15 +31,26 @@ var _devtools = require("../../../global/js/utils/devtools");
29
31
 
30
32
  var _settings = require("../../../settings");
31
33
 
32
- var _excluded = ["getTableProps", "withVirtualScroll", "DatagridPagination", "isFetching", "tableId", "CustomizeColumnsModal", "leftPanel", "fullHeightDatagrid", "verticalAlign", "variableRowHeight", "className"];
34
+ var _pconsole = _interopRequireDefault(require("../../../global/js/utils/pconsole"));
35
+
36
+ var _excluded = ["datagridState"];
33
37
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
34
38
  var componentName = 'Datagrid';
35
39
  var TableContainer = _carbonComponentsReact.DataTable.TableContainer,
36
40
  Table = _carbonComponentsReact.DataTable.Table;
37
41
 
38
- var Datagrid = /*#__PURE__*/_react.default.forwardRef(function (datagridState, ref) {
42
+ var Datagrid = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
39
43
  var _getTableProps;
40
44
 
45
+ var datagridState = _ref.datagridState,
46
+ rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
47
+
48
+ if (!datagridState) {
49
+ _pconsole.default.warn('Datagrid was not passed datagridState which is required to render this component.');
50
+
51
+ return null;
52
+ }
53
+
41
54
  var _datagridState$getTab = datagridState.getTableProps,
42
55
  getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
43
56
  withVirtualScroll = datagridState.withVirtualScroll,
@@ -50,8 +63,7 @@ var Datagrid = /*#__PURE__*/_react.default.forwardRef(function (datagridState, r
50
63
  _datagridState$vertic = datagridState.verticalAlign,
51
64
  verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
52
65
  variableRowHeight = datagridState.variableRowHeight,
53
- className = datagridState.className,
54
- rest = (0, _objectWithoutProperties2.default)(datagridState, _excluded);
66
+ className = datagridState.className;
55
67
  var rows = DatagridPagination && datagridState.page || datagridState.rows;
56
68
 
57
69
  var dataGrid = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(TableContainer, {
@@ -78,9 +90,14 @@ var Datagrid = /*#__PURE__*/_react.default.forwardRef(function (datagridState, r
78
90
  }); // Return a placeholder if not released and not enabled by feature flag
79
91
 
80
92
 
81
- Datagrid = _settings.pkg.checkComponentEnabled(Datagrid, componentName); // The display name of the component, used by React. Note that displayName
93
+ exports.Datagrid = Datagrid;
94
+ exports.Datagrid = Datagrid = _settings.pkg.checkComponentEnabled(Datagrid, componentName); // The display name of the component, used by React. Note that displayName
82
95
  // is used in preference to relying on function.name.
83
96
 
84
97
  Datagrid.displayName = componentName;
85
- var _default = Datagrid;
86
- exports.default = _default;
98
+ Datagrid.propTypes = {
99
+ /**
100
+ * The data grid state, much of it being supplied by the useDatagrid hook
101
+ */
102
+ datagridState: _propTypes.default.object.isRequired
103
+ };
@@ -7,18 +7,15 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
10
  var _react = _interopRequireDefault(require("react"));
13
11
 
14
12
  var _carbonComponentsReact = require("carbon-components-react");
15
13
 
16
- /*
17
- * Licensed Materials - Property of IBM
18
- * 5724-Q36
19
- * (c) Copyright IBM Corp. 2020, 2021
20
- * US Government Users Restricted Rights - Use, duplication or disclosure
21
- * restricted by GSA ADP Schedule Contract with IBM Corp.
14
+ /**
15
+ * Copyright IBM Corp. 2020, 2022
16
+ *
17
+ * This source code is licensed under the Apache-2.0 license found in the
18
+ * LICENSE file in the root directory of this source tree.
22
19
  */
23
20
  var TableHead = _carbonComponentsReact.DataTable.TableHead;
24
21
 
@@ -27,14 +24,9 @@ var DatagridHead = function DatagridHead(datagridState) {
27
24
  headerGroups = _datagridState$header === void 0 ? [] : _datagridState$header,
28
25
  headRef = datagridState.headRef,
29
26
  HeaderRow = datagridState.HeaderRow;
30
- return /*#__PURE__*/_react.default.createElement(TableHead, null, headerGroups.map(function (headerGroup, index) {
31
- return (
32
- /*#__PURE__*/
33
- // doesn't support header grouping.
34
- _react.default.createElement("div", (0, _extends2.default)({}, headerGroup.getHeaderGroupProps(), {
35
- ref: headRef,
36
- key: "header_".concat(index)
37
- }), HeaderRow(datagridState))
27
+ return /*#__PURE__*/_react.default.createElement(TableHead, null, headerGroups.map(function (headerGroup) {
28
+ return (// doesn't support header grouping.
29
+ HeaderRow(datagridState, headRef, headerGroup)
38
30
  );
39
31
  }));
40
32
  };
@@ -21,20 +21,20 @@ var _commonColumnIds = require("../common-column-ids");
21
21
 
22
22
  var _settings = require("../../../settings");
23
23
 
24
- /*
25
- * Licensed Materials - Property of IBM
26
- * 5724-Q36
27
- * (c) Copyright IBM Corp. 2020, 2021
28
- * US Government Users Restricted Rights - Use, duplication or disclosure
29
- * restricted by GSA ADP Schedule Contract with IBM Corp.
24
+ /**
25
+ * Copyright IBM Corp. 2020, 2022
26
+ *
27
+ * This source code is licensed under the Apache-2.0 license found in the
28
+ * LICENSE file in the root directory of this source tree.
30
29
  */
31
30
  // @flow
32
31
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
33
32
 
34
- var HeaderRow = function HeaderRow(datagridState) {
35
- return /*#__PURE__*/_react.default.createElement(TableRow, {
36
- className: "".concat(blockClass, "__head")
37
- }, datagridState.headers.filter(function (_ref) {
33
+ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
34
+ return /*#__PURE__*/_react.default.createElement(TableRow, (0, _extends2.default)({}, headerGroup.getHeaderGroupProps(), {
35
+ className: (0, _classnames.default)("".concat(blockClass, "__head"), headerGroup.getHeaderGroupProps().className),
36
+ ref: headRef
37
+ }), datagridState.headers.filter(function (_ref) {
38
38
  var isVisible = _ref.isVisible;
39
39
  return isVisible;
40
40
  }).map(function (header) {
@@ -11,12 +11,16 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
 
12
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
13
 
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
14
16
  var _react = _interopRequireDefault(require("react"));
15
17
 
16
18
  var _carbonComponentsReact = require("carbon-components-react");
17
19
 
18
20
  var _commonColumnIds = require("../common-column-ids");
19
21
 
22
+ var _classnames = _interopRequireDefault(require("classnames"));
23
+
20
24
  var _settings = require("../../../settings");
21
25
 
22
26
  var _excluded = ["children"];
@@ -27,9 +31,17 @@ var TableRow = _carbonComponentsReact.DataTable.TableRow,
27
31
  var DatagridRow = function DatagridRow(datagridState) {
28
32
  var row = datagridState.row;
29
33
  return /*#__PURE__*/_react.default.createElement(TableRow, (0, _extends2.default)({
30
- className: "".concat(blockClass, "__carbon-row")
34
+ className: (0, _classnames.default)("".concat(blockClass, "__carbon-row"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded))
31
35
  }, row.getRowProps(), {
32
- key: row.id
36
+ key: row.id,
37
+ onMouseEnter: function onMouseEnter(event) {
38
+ var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
39
+ hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.add("".concat(blockClass, "__carbon-row-expanded-hover-active"));
40
+ },
41
+ onMouseLeave: function onMouseLeave(event) {
42
+ var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
43
+ hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
44
+ }
33
45
  }), row.cells.map(function (cell) {
34
46
  var cellProps = cell.getCellProps();
35
47
  var children = cellProps.children,
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
- Object.defineProperty(exports, "default", {
6
+ Object.defineProperty(exports, "Datagrid", {
9
7
  enumerable: true,
10
8
  get: function get() {
11
- return _Datagrid.default;
9
+ return _Datagrid.Datagrid;
12
10
  }
13
11
  });
14
12
 
15
- var _Datagrid = _interopRequireDefault(require("./Datagrid"));
13
+ var _Datagrid = require("./Datagrid");
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  Object.defineProperty(exports, "Datagrid", {
9
9
  enumerable: true,
10
10
  get: function get() {
11
- return _Datagrid.default;
11
+ return _Datagrid.Datagrid;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "useActionsColumn", {
@@ -96,7 +96,7 @@ Object.defineProperty(exports, "useStickyColumn", {
96
96
  }
97
97
  });
98
98
 
99
- var _Datagrid = _interopRequireDefault(require("./Datagrid"));
99
+ var _Datagrid = require("./Datagrid");
100
100
 
101
101
  var _useDatagrid = _interopRequireDefault(require("./useDatagrid"));
102
102
 
@@ -22,7 +22,7 @@ var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
22
22
 
23
23
  var useNestedRows = function useNestedRows(hooks) {
24
24
  (0, _useRowExpander.default)(hooks);
25
- var marginLeft = 32;
25
+ var marginLeft = 24;
26
26
 
27
27
  var getRowProps = function getRowProps(props, _ref) {
28
28
  var row = _ref.row;
@@ -36,7 +36,7 @@ var useNestedRows = function useNestedRows(hooks) {
36
36
  return [props, {
37
37
  style: {
38
38
  marginLeft: "".concat(row.depth > 0 ? marginLeft : 0, "px"),
39
- paddingLeft: "".concat(row.depth > 1 ? marginLeft * (row.depth - 1) : 0, "px"),
39
+ paddingLeft: "".concat(row.depth > 1 ? marginLeft * (row.depth - 1) + marginLeft : row.depth === 1 ? marginLeft : 0, "px"),
40
40
  maxWidth: "calc(100% - ".concat(marginLeft * row.depth, "px)")
41
41
  }
42
42
  }];
@@ -51,7 +51,7 @@ var useNestedRows = function useNestedRows(hooks) {
51
51
  }) === 0;
52
52
  return [props, {
53
53
  style: {
54
- marginRight: isFirstCell ? "-".concat(marginLeft * cell.row.depth, "px") : ''
54
+ marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "-".concat(marginLeft * (cell.row.depth + 1), "px") : '')
55
55
  }
56
56
  }];
57
57
  };
@@ -30,7 +30,7 @@ var useRowExpander = function useRowExpander(hooks) {
30
30
  var row = _ref.row;
31
31
  return row.canExpand && /*#__PURE__*/_react.default.createElement("span", row.getToggleRowExpandedProps(), row.isExpanded ? /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronUp16, null) : /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronDown16, null));
32
32
  },
33
- width: 32,
33
+ width: 48,
34
34
  disableResizing: true,
35
35
  disableSortBy: true,
36
36
  Header: ''
@@ -51,8 +51,6 @@ var defaults = {
51
51
  validExtensions: Object.freeze([])
52
52
  };
53
53
  var ExportModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
54
- var _preformattedExtensio;
55
-
56
54
  var body = _ref.body,
57
55
  className = _ref.className,
58
56
  error = _ref.error,
@@ -81,7 +79,7 @@ var ExportModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
81
79
  validExtensions = _ref$validExtensions === void 0 ? defaults.validExtensions : _ref$validExtensions,
82
80
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
83
81
 
84
- var _useState = (0, _react.useState)(filename),
82
+ var _useState = (0, _react.useState)(''),
85
83
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
86
84
  name = _useState2[0],
87
85
  setName = _useState2[1];
@@ -92,11 +90,18 @@ var ExportModal = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
92
90
  setDirtyInput = _useState4[1]; // by default (if it exists) use the first extension in the extension array
93
91
 
94
92
 
95
- var _useState5 = (0, _react.useState)(preformattedExtensions === null || preformattedExtensions === void 0 ? void 0 : (_preformattedExtensio = preformattedExtensions[0]) === null || _preformattedExtensio === void 0 ? void 0 : _preformattedExtensio.extension),
93
+ var _useState5 = (0, _react.useState)(''),
96
94
  _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
97
95
  extension = _useState6[0],
98
96
  setExtension = _useState6[1];
99
97
 
98
+ (0, _react.useEffect)(function () {
99
+ var _preformattedExtensio;
100
+
101
+ setName(filename);
102
+ setExtension(preformattedExtensions === null || preformattedExtensions === void 0 ? void 0 : (_preformattedExtensio = preformattedExtensions[0]) === null || _preformattedExtensio === void 0 ? void 0 : _preformattedExtensio.extension);
103
+ }, [filename, preformattedExtensions]);
104
+
100
105
  var onNameChangeHandler = function onNameChangeHandler(evt) {
101
106
  setName(evt.target.value);
102
107
  };