@carbon/ibm-products 1.31.0 → 1.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/css/index-full-carbon.css +57 -5
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +57 -5
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +1 -1
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +57 -5
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +1 -1
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
  14. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  15. package/es/components/Datagrid/Datagrid/DatagridContent.js +26 -5
  16. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  17. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +12 -3
  18. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
  19. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
  20. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +9 -1
  21. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +153 -87
  22. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +66 -0
  23. package/es/components/Datagrid/useActionsColumn.js +28 -12
  24. package/es/components/Datagrid/useExpandedRow.js +0 -1
  25. package/es/components/Datagrid/useNestedRowExpander.js +42 -0
  26. package/es/components/Datagrid/useNestedRows.js +2 -2
  27. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  28. package/es/components/Datagrid/utils/DatagridActions.js +121 -0
  29. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  30. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  31. package/es/components/Datagrid/utils/getArgTypes.js +85 -0
  32. package/es/global/js/utils/story-helper.js +5 -1
  33. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
  34. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  35. package/lib/components/Datagrid/Datagrid/DatagridContent.js +27 -5
  36. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  37. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +14 -3
  38. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
  39. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
  40. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +10 -7
  41. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +155 -87
  42. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +78 -0
  43. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  44. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  45. package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
  46. package/lib/components/Datagrid/useNestedRows.js +3 -3
  47. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  48. package/lib/components/Datagrid/utils/DatagridActions.js +139 -0
  49. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  50. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  51. package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
  52. package/lib/global/js/utils/story-helper.js +5 -1
  53. package/package.json +2 -2
  54. package/scss/components/Datagrid/styles/_datagrid.scss +0 -4
  55. package/scss/components/Datagrid/styles/_useActionsColumn.scss +12 -0
  56. package/scss/components/Datagrid/styles/_useExpandedRow.scss +30 -0
  57. package/scss/components/Datagrid/styles/_useNestedRows.scss +15 -1
  58. package/scss/components/Datagrid/styles/_useStickyColumn.scss +6 -0
@@ -55,8 +55,6 @@ var InlineEditCell = function InlineEditCell(_ref) {
55
55
  placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
56
56
  tabIndex = _ref.tabIndex,
57
57
  value = _ref.value,
58
- _ref$label = _ref.label,
59
- label = _ref$label === void 0 ? 'Inline edit type text label' : _ref$label,
60
58
  nonEditCell = _ref.nonEditCell,
61
59
  totalInlineEditColumns = _ref.totalInlineEditColumns,
62
60
  type = _ref.type;
@@ -86,6 +84,11 @@ var InlineEditCell = function InlineEditCell(_ref) {
86
84
  initialValue = _useState6[0],
87
85
  setInitialValue = _useState6[1];
88
86
 
87
+ var _useState7 = (0, _react.useState)(),
88
+ _useState8 = (0, _slicedToArray2.default)(_useState7, 2),
89
+ cellLabel = _useState8[0],
90
+ setCellLabel = _useState8[1];
91
+
89
92
  var activeCellId = state.activeCellId,
90
93
  editId = state.editId;
91
94
  var previousState = (0, _hooks.usePreviousValue)({
@@ -102,7 +105,12 @@ var InlineEditCell = function InlineEditCell(_ref) {
102
105
  var datePickerRef = (0, _react.useRef)();
103
106
  var outerButtonElement = (0, _react.useRef)();
104
107
  (0, _react.useEffect)(function () {
105
- setInitialValue(value); // eslint-disable-next-line react-hooks/exhaustive-deps
108
+ setInitialValue(value);
109
+ var columnId = cell.column.id;
110
+ var columnLabel = instance.columns.find(function (item) {
111
+ return item.id === columnId;
112
+ });
113
+ setCellLabel(typeof columnLabel.Header === 'string' ? columnLabel.Header : 'Inline edit cell label'); // eslint-disable-next-line react-hooks/exhaustive-deps
106
114
  }, []); // If you are in edit mode and click outside of the cell,
107
115
  // this changes the cell back to the InlineEditButton
108
116
 
@@ -270,7 +278,8 @@ var InlineEditCell = function InlineEditCell(_ref) {
270
278
 
271
279
  return /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Dropdown, (0, _extends2.default)({
272
280
  id: cellId,
273
- label: "Dropdown menu options"
281
+ label: cellLabel || 'Dropdown menu options',
282
+ ariaLabel: cellLabel || 'Dropdown menu options'
274
283
  }, inputProps, {
275
284
  hideLabel: true,
276
285
  style: {
@@ -372,7 +381,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
372
381
  position: 'static'
373
382
  },
374
383
  placeholder: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.placeholder) || 'mm/dd/yyyy',
375
- labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || 'Set date',
384
+ labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || cellLabel || 'Set date',
376
385
  id: datePickerInputProps.id || "".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index),
377
386
  hideLabel: true
378
387
  })));
@@ -429,7 +438,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
429
438
  totalColumns: totalColumns,
430
439
  type: type
431
440
  }), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, type === 'text' && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextInput, (0, _extends2.default)({
432
- labelText: label,
441
+ labelText: cellLabel,
433
442
  placeholder: placeholder
434
443
  }, inputProps, {
435
444
  id: cellId,
@@ -445,7 +454,7 @@ var InlineEditCell = function InlineEditCell(_ref) {
445
454
  ref: textInputRef
446
455
  })), type === 'number' && /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.NumberInput, (0, _extends2.default)({
447
456
  placeholder: placeholder,
448
- label: label
457
+ label: cellLabel
449
458
  }, inputProps, {
450
459
  id: cellId,
451
460
  hideLabel: true,
@@ -473,7 +482,6 @@ InlineEditCell.propTypes = {
473
482
  rowSize: _propTypes.default.string,
474
483
  tableId: _propTypes.default.string
475
484
  }),
476
- label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.number]),
477
485
  nonEditCell: _propTypes.default.bool,
478
486
  placeholder: _propTypes.default.string,
479
487
  tabIndex: _propTypes.default.number,
@@ -9,18 +9,15 @@ exports.returnUpdatedActiveCell = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
+ var _settings = require("../../../../../../settings");
13
+
12
14
  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; }
13
15
 
14
16
  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; }
15
17
 
16
- /**
17
- * Copyright IBM Corp. 2022, 2022
18
- *
19
- * This source code is licensed under the Apache-2.0 license found in the
20
- * LICENSE file in the root directory of this source tree.
21
- */
22
- // This function returns the state back to the reducer after
18
+ var blockClass = "".concat(_settings.pkg.prefix, "--datagrid"); // This function returns the state back to the reducer after
23
19
  // determining the new active cell value
20
+
24
21
  var returnUpdatedActiveCell = function returnUpdatedActiveCell(_ref) {
25
22
  var activeCellCoords = _ref.activeCellCoords,
26
23
  direction = _ref.direction,
@@ -34,6 +31,12 @@ var returnUpdatedActiveCell = function returnUpdatedActiveCell(_ref) {
34
31
  });
35
32
 
36
33
  var newActiveCellId = "column-".concat(newActiveCoords.column, "-row-").concat(newActiveCoords.row);
34
+ var newCellIdButton = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit [data-cell-id=\"").concat(newActiveCellId, "\"] .").concat(blockClass, "__inline-edit-button")); // Allows scrollable area to keep focused/active cell id visible
35
+
36
+ if (newCellIdButton) {
37
+ newCellIdButton === null || newCellIdButton === void 0 ? void 0 : newCellIdButton.focus();
38
+ }
39
+
37
40
  return _objectSpread(_objectSpread({}, state), {}, {
38
41
  activeCellId: newActiveCellId
39
42
  });
@@ -11,13 +11,23 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
 
12
12
  var _settings = require("../../../../../settings");
13
13
 
14
+ var _handleMultipleKeys = require("./handleMultipleKeys");
15
+
16
+ var _getCellIdAsObject = require("./InlineEditContext/getCellIdAsObject");
17
+
14
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; }
15
19
 
16
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; }
17
21
 
18
22
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
19
23
 
20
- var handleGridKeyPress = function handleGridKeyPress(event, dispatch, state, instance) {
24
+ var handleGridKeyPress = function handleGridKeyPress(_ref) {
25
+ var event = _ref.event,
26
+ dispatch = _ref.dispatch,
27
+ state = _ref.state,
28
+ instance = _ref.instance,
29
+ keysPressedList = _ref.keysPressedList,
30
+ usingMac = _ref.usingMac;
21
31
  var key = event.key;
22
32
  var gridActive = state.gridActive,
23
33
  activeCellId = state.activeCellId,
@@ -94,7 +104,7 @@ var handleGridKeyPress = function handleGridKeyPress(event, dispatch, state, ins
94
104
  } // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
95
105
 
96
106
 
97
- if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing) {
107
+ if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing && keysPressedList.length < 2) {
98
108
  event.preventDefault();
99
109
  }
100
110
 
@@ -104,100 +114,158 @@ var handleGridKeyPress = function handleGridKeyPress(event, dispatch, state, ins
104
114
  instance: instance
105
115
  };
106
116
 
107
- switch (key) {
108
- case 'Tab':
109
- {
110
- if (!editId) {
117
+ if (keysPressedList.length > 1) {
118
+ (0, _handleMultipleKeys.handleMultipleKeys)({
119
+ usingMac: usingMac,
120
+ keysPressedList: keysPressedList,
121
+ dispatch: dispatch,
122
+ activeCellId: activeCellId,
123
+ instance: instance
124
+ });
125
+ }
126
+
127
+ if (keysPressedList.length < 2) {
128
+ switch (key) {
129
+ case 'Tab':
130
+ {
131
+ if (!editId) {
132
+ dispatch({
133
+ type: 'REMOVE_GRID_ACTIVE_FOCUS',
134
+ payload: activeCellId
135
+ });
136
+ }
137
+
138
+ break;
139
+ }
140
+
141
+ case 'ArrowRight':
142
+ {
111
143
  dispatch({
112
- type: 'REMOVE_GRID_ACTIVE_FOCUS',
113
- payload: activeCellId
144
+ type: 'UPDATE_ACTIVE_CELL_ID',
145
+ payload: _objectSpread({
146
+ direction: 'right'
147
+ }, sharedUpdateParams)
114
148
  });
149
+ break;
115
150
  }
116
151
 
117
- break;
118
- }
119
-
120
- case 'ArrowRight':
121
- {
122
- dispatch({
123
- type: 'UPDATE_ACTIVE_CELL_ID',
124
- payload: _objectSpread({
125
- direction: 'right'
126
- }, sharedUpdateParams)
127
- });
128
- break;
129
- }
130
-
131
- case 'ArrowLeft':
132
- {
133
- dispatch({
134
- type: 'UPDATE_ACTIVE_CELL_ID',
135
- payload: _objectSpread({
136
- direction: 'left'
137
- }, sharedUpdateParams)
138
- });
139
- break;
140
- }
141
-
142
- case 'ArrowUp':
143
- {
144
- dispatch({
145
- type: 'UPDATE_ACTIVE_CELL_ID',
146
- payload: _objectSpread({
147
- direction: 'up'
148
- }, sharedUpdateParams)
149
- });
150
- break;
151
- }
152
-
153
- case 'ArrowDown':
154
- {
155
- dispatch({
156
- type: 'UPDATE_ACTIVE_CELL_ID',
157
- payload: _objectSpread({
158
- direction: 'down'
159
- }, sharedUpdateParams)
160
- });
161
- break;
162
- }
163
-
164
- case ' ':
165
- case 'F2':
166
- case 'Enter':
167
- {
168
- // Disabled cells are not allowed to go into edit mode
169
- if (isDisabledCell) {
170
- return;
171
- } // Only go into edit mode if there is no editId, meaning that we're not already in edit mode
172
-
173
-
174
- if (!editId) {
175
- var focusedType = focusedCell.getAttribute('data-inline-type'); // Open dropdown immediately after entering edit mode for selection type
176
-
177
- if (focusedType === 'selection') {
178
- setTimeout(function () {
179
- var dropdownTrigger = focusedCell.querySelector('button');
180
- dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.click();
181
- }, 1);
182
- }
152
+ case 'ArrowLeft':
153
+ {
154
+ dispatch({
155
+ type: 'UPDATE_ACTIVE_CELL_ID',
156
+ payload: _objectSpread({
157
+ direction: 'left'
158
+ }, sharedUpdateParams)
159
+ });
160
+ break;
161
+ }
183
162
 
184
- if (focusedType === 'date') {
185
- setTimeout(function () {
186
- var dateInputTrigger = focusedCell.querySelector('input');
187
- dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.click();
188
- dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.focus();
189
- }, 1);
190
- }
163
+ case 'ArrowUp':
164
+ {
165
+ dispatch({
166
+ type: 'UPDATE_ACTIVE_CELL_ID',
167
+ payload: _objectSpread({
168
+ direction: 'up'
169
+ }, sharedUpdateParams)
170
+ });
171
+ break;
172
+ }
191
173
 
174
+ case 'ArrowDown':
175
+ {
192
176
  dispatch({
193
- type: 'ENTER_EDIT_MODE',
194
- payload: {
195
- activeCellId: activeCellId,
196
- editId: activeCellId
197
- }
177
+ type: 'UPDATE_ACTIVE_CELL_ID',
178
+ payload: _objectSpread({
179
+ direction: 'down'
180
+ }, sharedUpdateParams)
181
+ });
182
+ break;
183
+ }
184
+ // Move active cell to first column in current row
185
+
186
+ case 'Home':
187
+ {
188
+ var activeCellObject = (0, _getCellIdAsObject.getCellIdAsObject)(activeCellId);
189
+
190
+ var newActiveCellCoords = _objectSpread(_objectSpread({}, activeCellObject), {}, {
191
+ column: 0
192
+ });
193
+
194
+ var newActiveCellId = "column-".concat(newActiveCellCoords.column, "-row-").concat(newActiveCellCoords.row);
195
+ var scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(_settings.pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest left position
196
+
197
+ scrollElement.scrollLeft = 0;
198
+ dispatch({
199
+ type: 'UPDATE_ACTIVE_CELL_ID',
200
+ payload: newActiveCellId
201
+ });
202
+ break;
203
+ }
204
+ // Move active cell to last column in current row
205
+
206
+ case 'End':
207
+ {
208
+ var _activeCellObject = (0, _getCellIdAsObject.getCellIdAsObject)(activeCellId);
209
+
210
+ var totalVisibleColumns = instance.visibleColumns.filter(function (item) {
211
+ return item.id !== 'spacer';
212
+ });
213
+
214
+ var _newActiveCellCoords = _objectSpread(_objectSpread({}, _activeCellObject), {}, {
215
+ column: totalVisibleColumns.length - 1
216
+ });
217
+
218
+ var _newActiveCellId = "column-".concat(_newActiveCellCoords.column, "-row-").concat(_newActiveCellCoords.row);
219
+
220
+ var _scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(_settings.pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest right position
221
+
222
+
223
+ _scrollElement.scrollLeft = _scrollElement.scrollWidth;
224
+ dispatch({
225
+ type: 'UPDATE_ACTIVE_CELL_ID',
226
+ payload: _newActiveCellId
198
227
  });
228
+ break;
229
+ }
230
+
231
+ case ' ':
232
+ case 'F2':
233
+ case 'Enter':
234
+ {
235
+ // Disabled cells are not allowed to go into edit mode
236
+ if (isDisabledCell) {
237
+ return;
238
+ } // Only go into edit mode if there is no editId, meaning that we're not already in edit mode
239
+
240
+
241
+ if (!editId) {
242
+ var focusedType = focusedCell.getAttribute('data-inline-type'); // Open dropdown immediately after entering edit mode for selection type
243
+
244
+ if (focusedType === 'selection') {
245
+ setTimeout(function () {
246
+ var dropdownTrigger = focusedCell.querySelector('button');
247
+ dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.click();
248
+ }, 1);
249
+ }
250
+
251
+ if (focusedType === 'date') {
252
+ setTimeout(function () {
253
+ var dateInputTrigger = focusedCell.querySelector('input');
254
+ dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.click();
255
+ dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.focus();
256
+ }, 1);
257
+ }
258
+
259
+ dispatch({
260
+ type: 'ENTER_EDIT_MODE',
261
+ payload: {
262
+ activeCellId: activeCellId,
263
+ editId: activeCellId
264
+ }
265
+ });
266
+ }
199
267
  }
200
- }
268
+ }
201
269
  }
202
270
  };
203
271
 
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.handleMultipleKeys = void 0;
7
+
8
+ var _handleMultipleKeys = require("../../../../DataSpreadsheet/utils/handleMultipleKeys");
9
+
10
+ var _settings = require("../../../../../settings");
11
+
12
+ /**
13
+ * Copyright IBM Corp. 2022, 2022
14
+ *
15
+ * This source code is licensed under the Apache-2.0 license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */
18
+ var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
19
+
20
+ var handleMultipleKeys = function handleMultipleKeys(_ref) {
21
+ var usingMac = _ref.usingMac,
22
+ keysPressedList = _ref.keysPressedList,
23
+ dispatch = _ref.dispatch,
24
+ activeCellId = _ref.activeCellId,
25
+ instance = _ref.instance;
26
+
27
+ // Resource key and Home
28
+ // Move active cell to first cell in first row and column
29
+ if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac) && keysPressedList.includes('Home')) {
30
+ var scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(_settings.pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest top left position
31
+
32
+ scrollElement.scrollTop = 0;
33
+ scrollElement.scrollLeft = 0;
34
+ dispatch({
35
+ type: 'UPDATE_ACTIVE_CELL_ID',
36
+ payload: 'column-0-row-0'
37
+ });
38
+ } // Resource key and End
39
+ // Move active cell to last cell in in the last row and column
40
+
41
+
42
+ if ((0, _handleMultipleKeys.includesResourceKey)(keysPressedList, usingMac) && keysPressedList.includes('End')) {
43
+ var _instance$rows;
44
+
45
+ var totalVisibleColumns = instance.visibleColumns.filter(function (item) {
46
+ return item.id !== 'spacer';
47
+ }).length;
48
+ var totalRows = (_instance$rows = instance.rows) === null || _instance$rows === void 0 ? void 0 : _instance$rows.length;
49
+ var lastCellDataId = "column-".concat(totalVisibleColumns - 1, "-row-").concat(totalRows - 1);
50
+ var lastCellElement = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit [data-cell-id=\"").concat(activeCellId, "\"]"));
51
+
52
+ var _scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(_settings.pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest bottom right position
53
+
54
+
55
+ _scrollElement.scrollTop = _scrollElement.scrollHeight;
56
+ _scrollElement.scrollLeft = _scrollElement.scrollWidth;
57
+
58
+ if (lastCellElement) {
59
+ dispatch({
60
+ type: 'UPDATE_ACTIVE_CELL_ID',
61
+ payload: lastCellDataId
62
+ });
63
+ } else {
64
+ // If a Datagrid component is using virtualized data, it's possible that the last cell
65
+ // has not yet been rendered. In this case, we simply need to wait until the scrollable
66
+ // container has scrolled to the bottom/right most position, then we can dispatch the
67
+ // update active cell id action
68
+ setTimeout(function () {
69
+ dispatch({
70
+ type: 'UPDATE_ACTIVE_CELL_ID',
71
+ payload: lastCellDataId
72
+ });
73
+ }, 250);
74
+ }
75
+ }
76
+ };
77
+
78
+ exports.handleMultipleKeys = handleMultipleKeys;
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
11
 
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
15
15
 
16
16
  var _react = _interopRequireDefault(require("react"));
@@ -21,13 +21,15 @@ var _carbonComponentsReact = require("carbon-components-react");
21
21
 
22
22
  var _settings = require("../../settings");
23
23
 
24
- var _excluded = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
24
+ var _excluded = ["id", "itemText", "onClick", "icon"],
25
+ _excluded2 = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
25
26
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
26
27
 
27
28
  var useActionsColumn = function useActionsColumn(hooks) {
28
29
  var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
29
30
  var rowActions = instance.rowActions,
30
- isFetching = instance.isFetching;
31
+ isFetching = instance.isFetching,
32
+ selectedFlatRows = instance.selectedFlatRows;
31
33
 
32
34
  if (rowActions && Array.isArray(rowActions)) {
33
35
  var addActionsMenu = function addActionsMenu(props, cellData) {
@@ -36,7 +38,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
36
38
  column = cell.column;
37
39
 
38
40
  if (column.isAction) {
39
- var _cx;
41
+ var _cx3;
40
42
 
41
43
  return [props, {
42
44
  children: /*#__PURE__*/_react.default.createElement("div", {
@@ -48,26 +50,36 @@ var useActionsColumn = function useActionsColumn(hooks) {
48
50
  style: {
49
51
  display: 'flex'
50
52
  }
51
- }, rowActions.map(function (action) {
53
+ }, rowActions.map(function (action, index) {
52
54
  var id = action.id,
53
55
  itemText = action.itemText,
54
56
  _onClick = action.onClick,
55
- icon = action.icon;
57
+ icon = action.icon,
58
+ rest = (0, _objectWithoutProperties2.default)(action, _excluded);
59
+ var selectedRowId = selectedFlatRows === null || selectedFlatRows === void 0 ? void 0 : selectedFlatRows.filter(function (item) {
60
+ return item.id === row.id ? item.id : null;
61
+ });
56
62
  return /*#__PURE__*/_react.default.createElement("div", {
57
- className: "".concat(blockClass, "__actions-column-button"),
58
- key: ""
59
- }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.OverflowMenu, {
63
+ className: (0, _classnames.default)("".concat(blockClass, "__actions-column-button"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__disabled-row-action-button"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
64
+ key: "".concat(itemText, "__").concat(index)
65
+ }, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.OverflowMenu, (0, _extends2.default)({}, rest, {
60
66
  renderIcon: icon,
61
67
  hasIconOnly: true,
62
68
  light: true,
63
69
  iconDescription: itemText,
64
70
  kind: "ghost",
71
+ className: (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "__disabled-row-action"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
65
72
  onClick: function onClick(e) {
73
+ if (selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length) {
74
+ // Row actions should be disabled if row is selected and batchActions toolbar is active
75
+ return;
76
+ }
77
+
66
78
  e.stopPropagation();
67
79
 
68
80
  _onClick(id, row, e);
69
81
  }
70
- }));
82
+ })));
71
83
  })), !isFetching && rowActions.length > 2 && /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.OverflowMenu, {
72
84
  size: "sm",
73
85
  light: true,
@@ -81,7 +93,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
81
93
  shouldHideMenuItem = action.shouldHideMenuItem,
82
94
  shouldDisableMenuItem = action.shouldDisableMenuItem,
83
95
  disabled = action.disabled,
84
- rest = (0, _objectWithoutProperties2.default)(action, _excluded);
96
+ rest = (0, _objectWithoutProperties2.default)(action, _excluded2);
85
97
  var hidden = typeof shouldHideMenuItem === 'function' && shouldHideMenuItem(row); // shouldDisableMenuItem will override disabled because it's more specific
86
98
  // if shouldDisableMenuItem doesn't exists, fall back to disabled
87
99
 
@@ -101,7 +113,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
101
113
  key: id
102
114
  }));
103
115
  })))),
104
- className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__actions-column-cell"), true), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__cell"), true), _cx))
116
+ className: (0, _classnames.default)((_cx3 = {}, (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__actions-column-cell"), true), (0, _defineProperty2.default)(_cx3, "".concat(blockClass, "__cell"), true), _cx3)),
117
+ style: {
118
+ width: 96
119
+ }
105
120
  }];
106
121
  }
107
122
 
@@ -42,7 +42,6 @@ var useExpandedRow = function useExpandedRow(hooks) {
42
42
  return _objectSpread(_objectSpread({}, row), {}, {
43
43
  canExpand: row.original && !row.original.notExpandable,
44
44
  expandedContentHeight: expandedRowsHeight[row.index] || expandedContentHeight,
45
- // RowRenderer: DatagridExpandedRow(row.RowRenderer, expansionRenderer),
46
45
  RowRenderer: (0, _DatagridExpandedRow.default)(row.RowRenderer, ExpandedRowContentComponent)
47
46
  });
48
47
  });
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _iconsReact = require("@carbon/icons-react");
17
+
18
+ var _classnames = _interopRequireDefault(require("classnames"));
19
+
20
+ var _settings = require("../../settings");
21
+
22
+ /* eslint-disable react/prop-types */
23
+
24
+ /*
25
+ * Licensed Materials - Property of IBM
26
+ * 5724-Q36
27
+ * (c) Copyright IBM Corp. 2020
28
+ * US Government Users Restricted Rights - Use, duplication or disclosure
29
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
30
+ */
31
+ var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
32
+
33
+ var useNestedRowExpander = function useNestedRowExpander(hooks) {
34
+ var visibleColumns = function visibleColumns(columns) {
35
+ var expanderColumn = {
36
+ id: 'expander',
37
+ Cell: function Cell(_ref) {
38
+ var _cx;
39
+
40
+ var row = _ref.row;
41
+ return row.canExpand && /*#__PURE__*/_react.default.createElement("span", row.getToggleRowExpandedProps(), /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronRight16, {
42
+ className: (0, _classnames.default)("".concat(blockClass, "__expander-icon"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
43
+ }));
44
+ },
45
+ width: 48,
46
+ disableResizing: true,
47
+ disableSortBy: true,
48
+ Header: ''
49
+ };
50
+ return [expanderColumn].concat((0, _toConsumableArray2.default)(columns));
51
+ };
52
+
53
+ hooks.visibleColumns.push(visibleColumns);
54
+ };
55
+
56
+ var _default = useNestedRowExpander;
57
+ exports.default = _default;
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _useRowExpander = _interopRequireDefault(require("./useRowExpander"));
11
-
12
10
  var _settings = require("../../settings");
13
11
 
12
+ var _useNestedRowExpander = _interopRequireDefault(require("./useNestedRowExpander"));
13
+
14
14
  /*
15
15
  * Licensed Materials - Property of IBM
16
16
  * 5724-Q36
@@ -21,7 +21,7 @@ var _settings = require("../../settings");
21
21
  var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
22
22
 
23
23
  var useNestedRows = function useNestedRows(hooks) {
24
- (0, _useRowExpander.default)(hooks);
24
+ (0, _useNestedRowExpander.default)(hooks);
25
25
  var marginLeft = 24;
26
26
 
27
27
  var getRowProps = function getRowProps(props, _ref) {