@carbon/ibm-products 1.31.0 → 1.32.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/css/index-full-carbon.css +71 -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 +67 -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 +67 -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/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
  16. package/es/components/Datagrid/Datagrid/DatagridContent.js +43 -18
  17. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  18. package/es/components/Datagrid/Datagrid/DatagridRow.js +10 -2
  19. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +12 -3
  20. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
  21. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
  22. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +9 -1
  23. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +153 -87
  24. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +66 -0
  25. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
  26. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  27. package/es/components/Datagrid/useActionsColumn.js +28 -12
  28. package/es/components/Datagrid/useExpandedRow.js +0 -1
  29. package/es/components/Datagrid/useNestedRowExpander.js +42 -0
  30. package/es/components/Datagrid/useNestedRows.js +2 -2
  31. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  32. package/es/components/Datagrid/utils/DatagridActions.js +121 -0
  33. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  34. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  35. package/es/components/Datagrid/utils/getArgTypes.js +85 -0
  36. package/es/components/Datagrid/utils/makeData.js +25 -5
  37. package/es/components/InlineEdit/InlineEdit.js +7 -7
  38. package/es/components/OptionsTile/OptionsTile.js +4 -2
  39. package/es/global/js/utils/story-helper.js +5 -1
  40. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
  41. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  42. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
  43. package/lib/components/Datagrid/Datagrid/DatagridContent.js +44 -18
  44. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  45. package/lib/components/Datagrid/Datagrid/DatagridRow.js +19 -2
  46. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +14 -3
  47. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
  48. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
  49. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +10 -7
  50. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +155 -87
  51. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +78 -0
  52. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
  53. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  54. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  55. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  56. package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
  57. package/lib/components/Datagrid/useNestedRows.js +3 -3
  58. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  59. package/lib/components/Datagrid/utils/DatagridActions.js +139 -0
  60. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  61. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  62. package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
  63. package/lib/components/Datagrid/utils/makeData.js +26 -5
  64. package/lib/components/InlineEdit/InlineEdit.js +7 -7
  65. package/lib/components/OptionsTile/OptionsTile.js +4 -2
  66. package/lib/global/js/utils/story-helper.js +5 -1
  67. package/package.json +12 -12
  68. package/scss/components/Datagrid/styles/_datagrid.scss +0 -4
  69. package/scss/components/Datagrid/styles/_useActionsColumn.scss +12 -0
  70. package/scss/components/Datagrid/styles/_useExpandedRow.scss +30 -0
  71. package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -0
  72. package/scss/components/Datagrid/styles/_useNestedRows.scss +15 -1
  73. package/scss/components/Datagrid/styles/_useStickyColumn.scss +6 -0
  74. package/scss/components/OptionsTile/_options-tile.scss +4 -0
@@ -13,13 +13,21 @@ var DatagridExpandedRow = function DatagridExpandedRow(PreviousRowRenderer, Expa
13
13
  return function (datagridState) {
14
14
  var row = datagridState.row;
15
15
 
16
+ var _ref = row || {},
17
+ expandedContentHeight = _ref.expandedContentHeight;
18
+
16
19
  if (!row.isExpanded) {
17
20
  return PreviousRowRenderer(datagridState);
18
21
  }
19
22
 
20
23
  return /*#__PURE__*/React.createElement("div", {
21
24
  className: "".concat(blockClass, "__expanded-row")
22
- }, PreviousRowRenderer(datagridState), ExpandedRowContentComponent(datagridState));
25
+ }, PreviousRowRenderer(datagridState), /*#__PURE__*/React.createElement("div", {
26
+ className: "".concat(blockClass, "__expanded-row-content"),
27
+ style: {
28
+ height: expandedContentHeight ? expandedContentHeight : null
29
+ }
30
+ }, ExpandedRowContentComponent(datagridState)));
23
31
  };
24
32
  };
25
33
 
@@ -11,11 +11,13 @@ var _excluded = ["children"];
11
11
  * restricted by GSA ADP Schedule Contract with IBM Corp.
12
12
  */
13
13
  // @flow
14
- import React from 'react';
14
+ import React, { useContext } from 'react';
15
15
  import { DataTable, SkeletonText } from 'carbon-components-react';
16
16
  import { selectionColumnId } from '../common-column-ids';
17
17
  import cx from 'classnames';
18
18
  import { pkg, carbon } from '../../../settings';
19
+ import { InlineEditContext } from './addons/InlineEdit/InlineEditContext/InlineEditContext';
20
+ import { getCellIdAsObject } from './addons/InlineEdit/InlineEditContext/getCellIdAsObject';
19
21
  var blockClass = "".concat(pkg.prefix, "--datagrid");
20
22
  var TableRow = DataTable.TableRow,
21
23
  TableCell = DataTable.TableCell; // eslint-disable-next-line react/prop-types
@@ -24,8 +26,14 @@ var DatagridRow = function DatagridRow(datagridState) {
24
26
  var _cx;
25
27
 
26
28
  var row = datagridState.row;
29
+
30
+ var _useContext = useContext(InlineEditContext),
31
+ state = _useContext.state;
32
+
33
+ var activeCellId = state.activeCellId;
34
+ var activeCellObject = activeCellId && getCellIdAsObject(activeCellId);
27
35
  return /*#__PURE__*/React.createElement(TableRow, _extends({
28
- className: cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx))
36
+ className: cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-hover-active"), activeCellObject && row.index === activeCellObject.row), _cx))
29
37
  }, row.getRowProps(), {
30
38
  key: row.id,
31
39
  onMouseEnter: function onMouseEnter(event) {
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  var _excluded = ["onChange"];
@@ -13,6 +14,7 @@ var _excluded = ["onChange"];
13
14
  // @flow
14
15
  import React, { useEffect, useState } from 'react';
15
16
  import PropTypes from 'prop-types';
17
+ import cx from 'classnames';
16
18
  import { OverflowMenu, OverflowMenuItem, Checkbox } from 'carbon-components-react';
17
19
  import { CaretDown16 } from '@carbon/icons-react';
18
20
  import { pkg } from '../../../settings'; // cspell:words columnheader
@@ -22,6 +24,8 @@ var SELECT_ALL_PAGE_ROWS = 'pageRows';
22
24
  var SELECT_ALL_ROWS = 'allRows';
23
25
 
24
26
  var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
27
+ var _columns$;
28
+
25
29
  var tableId = _ref.tableId,
26
30
  isFetching = _ref.isFetching,
27
31
  isAllRowsSelected = _ref.isAllRowsSelected,
@@ -31,7 +35,9 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
31
35
  _ref$allPageRowsLabel = _ref.allPageRowsLabel,
32
36
  allPageRowsLabel = _ref$allPageRowsLabel === void 0 ? 'Select all on page' : _ref$allPageRowsLabel,
33
37
  _ref$allRowsLabel = _ref.allRowsLabel,
34
- allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel;
38
+ allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel,
39
+ columns = _ref.columns,
40
+ withStickyColumn = _ref.withStickyColumn;
35
41
 
36
42
  var _useState = useState(SELECT_ALL_PAGE_ROWS),
37
43
  _useState2 = _slicedToArray(_useState, 2),
@@ -60,10 +66,11 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
60
66
  selectProps = _objectWithoutProperties(_getProps, _excluded);
61
67
 
62
68
  var disabled = isFetching || selectProps.disabled;
69
+ var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
63
70
  return /*#__PURE__*/React.createElement("th", {
64
71
  role: "columnheader",
65
72
  scope: "col",
66
- className: "".concat(blockClass, "__select-all-toggle-on")
73
+ className: cx("".concat(blockClass, "__select-all-toggle-on"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
67
74
  }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, selectProps, {
68
75
  name: "".concat(tableId, "-select-all-checkbox-name"),
69
76
  onClick: function onClick(e) {
@@ -111,11 +118,13 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
111
118
  SelectAllWithToggle.propTypes = {
112
119
  allPageRowsLabel: PropTypes.string,
113
120
  allRowsLabel: PropTypes.string,
121
+ columns: PropTypes.arrayOf(PropTypes.object),
114
122
  getToggleAllPageRowsSelectedProps: PropTypes.func.isRequired,
115
123
  getToggleAllRowsSelectedProps: PropTypes.func.isRequired,
116
124
  isAllRowsSelected: PropTypes.bool.isRequired,
117
125
  isFetching: PropTypes.bool,
118
126
  selectAllToggle: PropTypes.object,
119
- tableId: PropTypes.string.isRequired
127
+ tableId: PropTypes.string.isRequired,
128
+ withStickyColumn: PropTypes.bool
120
129
  };
121
130
  export default SelectAllWithToggle;
@@ -20,8 +20,6 @@ export var InlineEditButton = function InlineEditButton(_ref) {
20
20
  disabled = _ref.disabled,
21
21
  LabelIcon = _ref.labelIcon,
22
22
  placeholder = _ref.placeholder,
23
- _ref$tabIndex = _ref.tabIndex,
24
- tabIndex = _ref$tabIndex === void 0 ? -1 : _ref$tabIndex,
25
23
  nonEditCell = _ref.nonEditCell,
26
24
  isActiveCell = _ref.isActiveCell,
27
25
  columnConfig = _ref.columnConfig,
@@ -31,7 +29,7 @@ export var InlineEditButton = function InlineEditButton(_ref) {
31
29
  var inlineEditColsLessThanHalfOfTotal = totalInlineEditColumns < totalColumns / 2;
32
30
  return /*#__PURE__*/React.createElement("div", {
33
31
  className: cx("".concat(blockClass, "__inline-edit-button"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--edit-less-than-half-of-total-cols"), inlineEditColsLessThanHalfOfTotal), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
34
- tabIndex: tabIndex,
32
+ tabIndex: isActiveCell ? 0 : -1,
35
33
  "data-disabled": disabled || nonEditCell,
36
34
  "aria-disabled": disabled || nonEditCell,
37
35
  role: "button",
@@ -55,7 +53,6 @@ InlineEditButton.propTypes = {
55
53
  nonEditCell: PropTypes.bool,
56
54
  placeholder: PropTypes.string,
57
55
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
58
- tabIndex: PropTypes.number,
59
56
  totalColumns: PropTypes.number,
60
57
  totalInlineEditColumns: PropTypes.number,
61
58
  type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
@@ -33,8 +33,6 @@ export var InlineEditCell = function InlineEditCell(_ref) {
33
33
  placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
34
34
  tabIndex = _ref.tabIndex,
35
35
  value = _ref.value,
36
- _ref$label = _ref.label,
37
- label = _ref$label === void 0 ? 'Inline edit type text label' : _ref$label,
38
36
  nonEditCell = _ref.nonEditCell,
39
37
  totalInlineEditColumns = _ref.totalInlineEditColumns,
40
38
  type = _ref.type;
@@ -64,6 +62,11 @@ export var InlineEditCell = function InlineEditCell(_ref) {
64
62
  initialValue = _useState6[0],
65
63
  setInitialValue = _useState6[1];
66
64
 
65
+ var _useState7 = useState(),
66
+ _useState8 = _slicedToArray(_useState7, 2),
67
+ cellLabel = _useState8[0],
68
+ setCellLabel = _useState8[1];
69
+
67
70
  var activeCellId = state.activeCellId,
68
71
  editId = state.editId;
69
72
  var previousState = usePreviousValue({
@@ -80,7 +83,12 @@ export var InlineEditCell = function InlineEditCell(_ref) {
80
83
  var datePickerRef = useRef();
81
84
  var outerButtonElement = useRef();
82
85
  useEffect(function () {
83
- setInitialValue(value); // eslint-disable-next-line react-hooks/exhaustive-deps
86
+ setInitialValue(value);
87
+ var columnId = cell.column.id;
88
+ var columnLabel = instance.columns.find(function (item) {
89
+ return item.id === columnId;
90
+ });
91
+ setCellLabel(typeof columnLabel.Header === 'string' ? columnLabel.Header : 'Inline edit cell label'); // eslint-disable-next-line react-hooks/exhaustive-deps
84
92
  }, []); // If you are in edit mode and click outside of the cell,
85
93
  // this changes the cell back to the InlineEditButton
86
94
 
@@ -248,7 +256,8 @@ export var InlineEditCell = function InlineEditCell(_ref) {
248
256
 
249
257
  return /*#__PURE__*/React.createElement(Dropdown, _extends({
250
258
  id: cellId,
251
- label: "Dropdown menu options"
259
+ label: cellLabel || 'Dropdown menu options',
260
+ ariaLabel: cellLabel || 'Dropdown menu options'
252
261
  }, inputProps, {
253
262
  hideLabel: true,
254
263
  style: {
@@ -350,7 +359,7 @@ export var InlineEditCell = function InlineEditCell(_ref) {
350
359
  position: 'static'
351
360
  },
352
361
  placeholder: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.placeholder) || 'mm/dd/yyyy',
353
- labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || 'Set date',
362
+ labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || cellLabel || 'Set date',
354
363
  id: datePickerInputProps.id || "".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index),
355
364
  hideLabel: true
356
365
  })));
@@ -407,7 +416,7 @@ export var InlineEditCell = function InlineEditCell(_ref) {
407
416
  totalColumns: totalColumns,
408
417
  type: type
409
418
  }), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/React.createElement(React.Fragment, null, type === 'text' && /*#__PURE__*/React.createElement(TextInput, _extends({
410
- labelText: label,
419
+ labelText: cellLabel,
411
420
  placeholder: placeholder
412
421
  }, inputProps, {
413
422
  id: cellId,
@@ -423,7 +432,7 @@ export var InlineEditCell = function InlineEditCell(_ref) {
423
432
  ref: textInputRef
424
433
  })), type === 'number' && /*#__PURE__*/React.createElement(NumberInput, _extends({
425
434
  placeholder: placeholder,
426
- label: label
435
+ label: cellLabel
427
436
  }, inputProps, {
428
437
  id: cellId,
429
438
  hideLabel: true,
@@ -449,7 +458,6 @@ InlineEditCell.propTypes = {
449
458
  rowSize: PropTypes.string,
450
459
  tableId: PropTypes.string
451
460
  }),
452
- label: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
453
461
  nonEditCell: PropTypes.bool,
454
462
  placeholder: PropTypes.string,
455
463
  tabIndex: PropTypes.number,
@@ -10,8 +10,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
10
10
  * This source code is licensed under the Apache-2.0 license found in the
11
11
  * LICENSE file in the root directory of this source tree.
12
12
  */
13
- // This function returns the state back to the reducer after
13
+ import { pkg } from '../../../../../../settings';
14
+ var blockClass = "".concat(pkg.prefix, "--datagrid"); // This function returns the state back to the reducer after
14
15
  // determining the new active cell value
16
+
15
17
  export var returnUpdatedActiveCell = function returnUpdatedActiveCell(_ref) {
16
18
  var activeCellCoords = _ref.activeCellCoords,
17
19
  direction = _ref.direction,
@@ -25,6 +27,12 @@ export var returnUpdatedActiveCell = function returnUpdatedActiveCell(_ref) {
25
27
  });
26
28
 
27
29
  var newActiveCellId = "column-".concat(newActiveCoords.column, "-row-").concat(newActiveCoords.row);
30
+ 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
31
+
32
+ if (newCellIdButton) {
33
+ newCellIdButton === null || newCellIdButton === void 0 ? void 0 : newCellIdButton.focus();
34
+ }
35
+
28
36
  return _objectSpread(_objectSpread({}, state), {}, {
29
37
  activeCellId: newActiveCellId
30
38
  });
@@ -11,8 +11,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
11
11
  * LICENSE file in the root directory of this source tree.
12
12
  */
13
13
  import { carbon, pkg } from '../../../../../settings';
14
+ import { handleMultipleKeys } from './handleMultipleKeys';
15
+ import { getCellIdAsObject } from './InlineEditContext/getCellIdAsObject';
14
16
  var blockClass = "".concat(pkg.prefix, "--datagrid");
15
- export var handleGridKeyPress = function handleGridKeyPress(event, dispatch, state, instance) {
17
+ export var handleGridKeyPress = function handleGridKeyPress(_ref) {
18
+ var event = _ref.event,
19
+ dispatch = _ref.dispatch,
20
+ state = _ref.state,
21
+ instance = _ref.instance,
22
+ keysPressedList = _ref.keysPressedList,
23
+ usingMac = _ref.usingMac;
16
24
  var key = event.key;
17
25
  var gridActive = state.gridActive,
18
26
  activeCellId = state.activeCellId,
@@ -89,7 +97,7 @@ export var handleGridKeyPress = function handleGridKeyPress(event, dispatch, sta
89
97
  } // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
90
98
 
91
99
 
92
- if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing) {
100
+ if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing && keysPressedList.length < 2) {
93
101
  event.preventDefault();
94
102
  }
95
103
 
@@ -99,99 +107,157 @@ export var handleGridKeyPress = function handleGridKeyPress(event, dispatch, sta
99
107
  instance: instance
100
108
  };
101
109
 
102
- switch (key) {
103
- case 'Tab':
104
- {
105
- if (!editId) {
110
+ if (keysPressedList.length > 1) {
111
+ handleMultipleKeys({
112
+ usingMac: usingMac,
113
+ keysPressedList: keysPressedList,
114
+ dispatch: dispatch,
115
+ activeCellId: activeCellId,
116
+ instance: instance
117
+ });
118
+ }
119
+
120
+ if (keysPressedList.length < 2) {
121
+ switch (key) {
122
+ case 'Tab':
123
+ {
124
+ if (!editId) {
125
+ dispatch({
126
+ type: 'REMOVE_GRID_ACTIVE_FOCUS',
127
+ payload: activeCellId
128
+ });
129
+ }
130
+
131
+ break;
132
+ }
133
+
134
+ case 'ArrowRight':
135
+ {
106
136
  dispatch({
107
- type: 'REMOVE_GRID_ACTIVE_FOCUS',
108
- payload: activeCellId
137
+ type: 'UPDATE_ACTIVE_CELL_ID',
138
+ payload: _objectSpread({
139
+ direction: 'right'
140
+ }, sharedUpdateParams)
109
141
  });
142
+ break;
110
143
  }
111
144
 
112
- break;
113
- }
114
-
115
- case 'ArrowRight':
116
- {
117
- dispatch({
118
- type: 'UPDATE_ACTIVE_CELL_ID',
119
- payload: _objectSpread({
120
- direction: 'right'
121
- }, sharedUpdateParams)
122
- });
123
- break;
124
- }
125
-
126
- case 'ArrowLeft':
127
- {
128
- dispatch({
129
- type: 'UPDATE_ACTIVE_CELL_ID',
130
- payload: _objectSpread({
131
- direction: 'left'
132
- }, sharedUpdateParams)
133
- });
134
- break;
135
- }
136
-
137
- case 'ArrowUp':
138
- {
139
- dispatch({
140
- type: 'UPDATE_ACTIVE_CELL_ID',
141
- payload: _objectSpread({
142
- direction: 'up'
143
- }, sharedUpdateParams)
144
- });
145
- break;
146
- }
147
-
148
- case 'ArrowDown':
149
- {
150
- dispatch({
151
- type: 'UPDATE_ACTIVE_CELL_ID',
152
- payload: _objectSpread({
153
- direction: 'down'
154
- }, sharedUpdateParams)
155
- });
156
- break;
157
- }
158
-
159
- case ' ':
160
- case 'F2':
161
- case 'Enter':
162
- {
163
- // Disabled cells are not allowed to go into edit mode
164
- if (isDisabledCell) {
165
- return;
166
- } // Only go into edit mode if there is no editId, meaning that we're not already in edit mode
167
-
168
-
169
- if (!editId) {
170
- var focusedType = focusedCell.getAttribute('data-inline-type'); // Open dropdown immediately after entering edit mode for selection type
171
-
172
- if (focusedType === 'selection') {
173
- setTimeout(function () {
174
- var dropdownTrigger = focusedCell.querySelector('button');
175
- dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.click();
176
- }, 1);
177
- }
145
+ case 'ArrowLeft':
146
+ {
147
+ dispatch({
148
+ type: 'UPDATE_ACTIVE_CELL_ID',
149
+ payload: _objectSpread({
150
+ direction: 'left'
151
+ }, sharedUpdateParams)
152
+ });
153
+ break;
154
+ }
178
155
 
179
- if (focusedType === 'date') {
180
- setTimeout(function () {
181
- var dateInputTrigger = focusedCell.querySelector('input');
182
- dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.click();
183
- dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.focus();
184
- }, 1);
185
- }
156
+ case 'ArrowUp':
157
+ {
158
+ dispatch({
159
+ type: 'UPDATE_ACTIVE_CELL_ID',
160
+ payload: _objectSpread({
161
+ direction: 'up'
162
+ }, sharedUpdateParams)
163
+ });
164
+ break;
165
+ }
186
166
 
167
+ case 'ArrowDown':
168
+ {
187
169
  dispatch({
188
- type: 'ENTER_EDIT_MODE',
189
- payload: {
190
- activeCellId: activeCellId,
191
- editId: activeCellId
192
- }
170
+ type: 'UPDATE_ACTIVE_CELL_ID',
171
+ payload: _objectSpread({
172
+ direction: 'down'
173
+ }, sharedUpdateParams)
174
+ });
175
+ break;
176
+ }
177
+ // Move active cell to first column in current row
178
+
179
+ case 'Home':
180
+ {
181
+ var activeCellObject = getCellIdAsObject(activeCellId);
182
+
183
+ var newActiveCellCoords = _objectSpread(_objectSpread({}, activeCellObject), {}, {
184
+ column: 0
185
+ });
186
+
187
+ var newActiveCellId = "column-".concat(newActiveCellCoords.column, "-row-").concat(newActiveCellCoords.row);
188
+ var scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest left position
189
+
190
+ scrollElement.scrollLeft = 0;
191
+ dispatch({
192
+ type: 'UPDATE_ACTIVE_CELL_ID',
193
+ payload: newActiveCellId
193
194
  });
195
+ break;
194
196
  }
195
- }
197
+ // Move active cell to last column in current row
198
+
199
+ case 'End':
200
+ {
201
+ var _activeCellObject = getCellIdAsObject(activeCellId);
202
+
203
+ var totalVisibleColumns = instance.visibleColumns.filter(function (item) {
204
+ return item.id !== 'spacer';
205
+ });
206
+
207
+ var _newActiveCellCoords = _objectSpread(_objectSpread({}, _activeCellObject), {}, {
208
+ column: totalVisibleColumns.length - 1
209
+ });
210
+
211
+ var _newActiveCellId = "column-".concat(_newActiveCellCoords.column, "-row-").concat(_newActiveCellCoords.row);
212
+
213
+ var _scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest right position
214
+
215
+
216
+ _scrollElement.scrollLeft = _scrollElement.scrollWidth;
217
+ dispatch({
218
+ type: 'UPDATE_ACTIVE_CELL_ID',
219
+ payload: _newActiveCellId
220
+ });
221
+ break;
222
+ }
223
+
224
+ case ' ':
225
+ case 'F2':
226
+ case 'Enter':
227
+ {
228
+ // Disabled cells are not allowed to go into edit mode
229
+ if (isDisabledCell) {
230
+ return;
231
+ } // Only go into edit mode if there is no editId, meaning that we're not already in edit mode
232
+
233
+
234
+ if (!editId) {
235
+ var focusedType = focusedCell.getAttribute('data-inline-type'); // Open dropdown immediately after entering edit mode for selection type
236
+
237
+ if (focusedType === 'selection') {
238
+ setTimeout(function () {
239
+ var dropdownTrigger = focusedCell.querySelector('button');
240
+ dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.click();
241
+ }, 1);
242
+ }
243
+
244
+ if (focusedType === 'date') {
245
+ setTimeout(function () {
246
+ var dateInputTrigger = focusedCell.querySelector('input');
247
+ dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.click();
248
+ dateInputTrigger === null || dateInputTrigger === void 0 ? void 0 : dateInputTrigger.focus();
249
+ }, 1);
250
+ }
251
+
252
+ dispatch({
253
+ type: 'ENTER_EDIT_MODE',
254
+ payload: {
255
+ activeCellId: activeCellId,
256
+ editId: activeCellId
257
+ }
258
+ });
259
+ }
260
+ }
261
+ }
196
262
  }
197
263
  };
@@ -0,0 +1,66 @@
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 { includesResourceKey } from '../../../../DataSpreadsheet/utils/handleMultipleKeys';
8
+ import { pkg } from '../../../../../settings';
9
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
10
+ export var handleMultipleKeys = function handleMultipleKeys(_ref) {
11
+ var usingMac = _ref.usingMac,
12
+ keysPressedList = _ref.keysPressedList,
13
+ dispatch = _ref.dispatch,
14
+ activeCellId = _ref.activeCellId,
15
+ instance = _ref.instance;
16
+
17
+ // Resource key and Home
18
+ // Move active cell to first cell in first row and column
19
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('Home')) {
20
+ var scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest top left position
21
+
22
+ scrollElement.scrollTop = 0;
23
+ scrollElement.scrollLeft = 0;
24
+ dispatch({
25
+ type: 'UPDATE_ACTIVE_CELL_ID',
26
+ payload: 'column-0-row-0'
27
+ });
28
+ } // Resource key and End
29
+ // Move active cell to last cell in in the last row and column
30
+
31
+
32
+ if (includesResourceKey(keysPressedList, usingMac) && keysPressedList.includes('End')) {
33
+ var _instance$rows;
34
+
35
+ var totalVisibleColumns = instance.visibleColumns.filter(function (item) {
36
+ return item.id !== 'spacer';
37
+ }).length;
38
+ var totalRows = (_instance$rows = instance.rows) === null || _instance$rows === void 0 ? void 0 : _instance$rows.length;
39
+ var lastCellDataId = "column-".concat(totalVisibleColumns - 1, "-row-").concat(totalRows - 1);
40
+ var lastCellElement = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit [data-cell-id=\"").concat(activeCellId, "\"]"));
41
+
42
+ var _scrollElement = document.querySelector("#".concat(instance.tableId, " .").concat(pkg.prefix, "--datagrid__table-container")); // Scroll table container to the furthest bottom right position
43
+
44
+
45
+ _scrollElement.scrollTop = _scrollElement.scrollHeight;
46
+ _scrollElement.scrollLeft = _scrollElement.scrollWidth;
47
+
48
+ if (lastCellElement) {
49
+ dispatch({
50
+ type: 'UPDATE_ACTIVE_CELL_ID',
51
+ payload: lastCellDataId
52
+ });
53
+ } else {
54
+ // If a Datagrid component is using virtualized data, it's possible that the last cell
55
+ // has not yet been rendered. In this case, we simply need to wait until the scrollable
56
+ // container has scrolled to the bottom/right most position, then we can dispatch the
57
+ // update active cell id action
58
+ setTimeout(function () {
59
+ dispatch({
60
+ type: 'UPDATE_ACTIVE_CELL_ID',
61
+ payload: lastCellDataId
62
+ });
63
+ }, 250);
64
+ }
65
+ }
66
+ };
@@ -43,7 +43,7 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
43
43
  return setIsOpen(!isOpen);
44
44
  },
45
45
  iconDescription: legendText,
46
- className: cx(_defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
46
+ className: cx("".concat(blockClass, "__row-size-button"), _defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
47
47
  }), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({}, props, {
48
48
  legendText: legendText,
49
49
  buttonRef: buttonRef,
@@ -93,7 +93,7 @@ var getDropdownPosition = function getDropdownPosition(buttonEle) {
93
93
 
94
94
  if (parent instanceof HTMLElement) {
95
95
  var top = buttonEle.offsetTop + buttonEle.offsetHeight;
96
- var right = parent.offsetWidth - parent.offsetLeft - (buttonEle.offsetLeft + buttonEle.offsetWidth);
96
+ var right = parent.offsetWidth - parent.offsetLeft - buttonEle.offsetLeft;
97
97
  return {
98
98
  top: top,
99
99
  right: right