@carbon/ibm-products 1.27.0 → 1.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/css/index-full-carbon.css +570 -80
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +942 -23
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -3
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +569 -79
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +570 -80
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -3
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelect.js +0 -3
  18. package/es/components/AddSelect/AddSelectBody.js +20 -3
  19. package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -3
  20. package/es/components/AddSelect/AddSelectColumn.js +4 -3
  21. package/es/components/AddSelect/AddSelectFilter.js +4 -3
  22. package/es/components/AddSelect/AddSelectList.js +40 -14
  23. package/es/components/Card/Card.js +16 -6
  24. package/es/components/Card/CardFooter.js +3 -1
  25. package/es/components/Card/CardHeader.js +20 -1
  26. package/es/components/DataSpreadsheet/DataSpreadsheet.js +63 -11
  27. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  28. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  29. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +31 -0
  30. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  31. package/es/components/Datagrid/Datagrid/Datagrid.js +10 -38
  32. package/es/components/Datagrid/Datagrid/DatagridContent.js +127 -0
  33. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  34. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
  35. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +12 -3
  36. package/es/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  37. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -40
  38. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +35 -10
  39. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +61 -24
  40. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  41. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +60 -0
  42. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  43. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +467 -0
  44. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  45. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  46. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  47. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  48. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +39 -0
  49. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  50. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +263 -0
  51. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +66 -0
  52. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  53. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  54. package/es/components/Datagrid/index.js +3 -1
  55. package/es/components/Datagrid/useActionsColumn.js +28 -12
  56. package/es/components/Datagrid/useColumnOrder.js +8 -0
  57. package/es/components/Datagrid/useCustomizeColumns.js +5 -0
  58. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  59. package/es/components/Datagrid/useExpandedRow.js +0 -1
  60. package/es/components/Datagrid/useInlineEdit.js +71 -0
  61. package/es/components/Datagrid/useNestedRowExpander.js +42 -0
  62. package/es/components/Datagrid/useNestedRows.js +2 -2
  63. package/es/components/Datagrid/useRowSize.js +17 -6
  64. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  65. package/es/components/Datagrid/useSelectRows.js +12 -2
  66. package/es/components/Datagrid/useStickyColumn.js +11 -0
  67. package/es/components/Datagrid/utils/DatagridActions.js +121 -0
  68. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  69. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  70. package/es/components/Datagrid/utils/getArgTypes.js +85 -0
  71. package/es/components/Datagrid/utils/getInlineEditColumns.js +121 -0
  72. package/es/components/Datagrid/utils/makeData.js +17 -1
  73. package/es/components/ImportModal/ImportModal.js +2 -2
  74. package/es/components/InlineEdit/InlineEdit.js +4 -2
  75. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  76. package/es/components/index.js +1 -1
  77. package/es/global/js/hooks/useClickOutside.js +1 -1
  78. package/es/global/js/package-settings.js +3 -3
  79. package/es/global/js/utils/rangeWithCallback.js +13 -0
  80. package/es/global/js/utils/story-helper.js +5 -1
  81. package/es/global/js/utils/uuidv4.spec.js +4 -0
  82. package/lib/components/AddSelect/AddSelect.js +0 -4
  83. package/lib/components/AddSelect/AddSelectBody.js +20 -3
  84. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
  85. package/lib/components/AddSelect/AddSelectColumn.js +3 -2
  86. package/lib/components/AddSelect/AddSelectFilter.js +3 -2
  87. package/lib/components/AddSelect/AddSelectList.js +39 -13
  88. package/lib/components/Card/Card.js +16 -6
  89. package/lib/components/Card/CardFooter.js +3 -1
  90. package/lib/components/Card/CardHeader.js +21 -1
  91. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +63 -10
  92. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  93. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  94. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
  95. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  96. package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
  97. package/lib/components/Datagrid/Datagrid/DatagridContent.js +160 -0
  98. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  99. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
  100. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +14 -3
  101. package/lib/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  102. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -41
  103. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +47 -25
  104. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +59 -23
  105. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  106. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +76 -0
  107. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  108. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +491 -0
  109. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  110. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  111. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  112. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  113. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +45 -0
  114. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  115. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +272 -0
  116. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +78 -0
  117. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  118. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  119. package/lib/components/Datagrid/index.js +17 -1
  120. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  121. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  122. package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
  123. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  124. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  125. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  126. package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
  127. package/lib/components/Datagrid/useNestedRows.js +3 -3
  128. package/lib/components/Datagrid/useRowSize.js +18 -13
  129. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  130. package/lib/components/Datagrid/useSelectRows.js +12 -2
  131. package/lib/components/Datagrid/useStickyColumn.js +11 -0
  132. package/lib/components/Datagrid/utils/DatagridActions.js +139 -0
  133. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  134. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  135. package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
  136. package/lib/components/Datagrid/utils/getInlineEditColumns.js +133 -0
  137. package/lib/components/Datagrid/utils/makeData.js +17 -1
  138. package/lib/components/ImportModal/ImportModal.js +2 -2
  139. package/lib/components/InlineEdit/InlineEdit.js +4 -2
  140. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  141. package/lib/components/index.js +12 -0
  142. package/lib/global/js/hooks/useClickOutside.js +1 -1
  143. package/lib/global/js/package-settings.js +3 -3
  144. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  145. package/lib/global/js/utils/story-helper.js +5 -1
  146. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  147. package/package.json +13 -13
  148. package/scss/components/AddSelect/_add-select.scss +126 -28
  149. package/scss/components/Card/_card.scss +1 -0
  150. package/scss/components/Cascade/_cascade.scss +1 -1
  151. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  152. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +18 -1
  153. package/scss/components/Datagrid/_storybook-styles.scss +1 -1
  154. package/scss/components/Datagrid/styles/_datagrid.scss +27 -4
  155. package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
  156. package/scss/components/Datagrid/styles/_index.scss +1 -0
  157. package/scss/components/Datagrid/styles/_useActionsColumn.scss +12 -0
  158. package/scss/components/Datagrid/styles/_useExpandedRow.scss +30 -0
  159. package/scss/components/Datagrid/styles/_useInlineEdit.scss +211 -0
  160. package/scss/components/Datagrid/styles/_useNestedRows.scss +15 -1
  161. package/scss/components/Datagrid/styles/_useStickyColumn.scss +30 -2
  162. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +44 -6
  163. package/scss/components/NotificationsPanel/_notifications-panel.scss +5 -6
  164. package/scss/components/ProductiveCard/_productive-card.scss +39 -0
  165. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  166. package/scss/components/SidePanel/_side-panel.scss +4 -6
  167. package/scss/components/_index-released-only.scss +1 -0
@@ -0,0 +1,263 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ /**
8
+ * Copyright IBM Corp. 2022, 2022
9
+ *
10
+ * This source code is licensed under the Apache-2.0 license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ import { carbon, pkg } from '../../../../../settings';
14
+ import { handleMultipleKeys } from './handleMultipleKeys';
15
+ import { getCellIdAsObject } from './InlineEditContext/getCellIdAsObject';
16
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
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;
24
+ var key = event.key;
25
+ var gridActive = state.gridActive,
26
+ activeCellId = state.activeCellId,
27
+ editId = state.editId;
28
+ var focusedCell = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit [data-cell-id=\"").concat(activeCellId, "\"]")); // If we reach this it means that tab was pressed while in
29
+ // edit mode which should not remove the focus from the grid
30
+
31
+ if (activeCellId === editId && key === 'Tab') {
32
+ // Attempting to exit date picker
33
+ if (focusedCell.getAttribute('data-inline-type') === 'date') {
34
+ dispatch({
35
+ type: 'EXIT_EDIT_MODE',
36
+ payload: activeCellId
37
+ });
38
+ }
39
+
40
+ event.preventDefault();
41
+ var inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
42
+ inlineEditArea.focus();
43
+ return;
44
+ }
45
+
46
+ if (activeCellId === editId && key === 'Escape') {
47
+ if (focusedCell.getAttribute('data-inline-type') === 'date') {
48
+ dispatch({
49
+ type: 'EXIT_EDIT_MODE',
50
+ payload: activeCellId
51
+ });
52
+ event.preventDefault();
53
+
54
+ var _inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
55
+
56
+ _inlineEditArea.focus();
57
+
58
+ return;
59
+ }
60
+ } // Checks if the dropdown menu is open
61
+
62
+
63
+ var dropdownIsActive = function dropdownIsActive() {
64
+ var focusedElementRole = document.activeElement.getAttribute('role');
65
+
66
+ if (focusedElementRole === 'listbox' && document.activeElement.classList.contains("".concat(carbon.prefix, "--list-box__menu"))) {
67
+ // Prevents arrow keys from scrolling any other content when dropdown menu is open
68
+ event.preventDefault();
69
+ return true;
70
+ }
71
+
72
+ return false;
73
+ }; // Checks if the date picker is open
74
+
75
+
76
+ var datePickerIsActive = function datePickerIsActive() {
77
+ var focusedCalendarElement = document.querySelector(".".concat(carbon.prefix, "--date-picker__input.flatpickr-input.active"));
78
+
79
+ if (focusedCalendarElement || document.activeElement.classList.contains("flatpickr-day")) {
80
+ event.preventDefault();
81
+ return true;
82
+ }
83
+
84
+ return false;
85
+ }; // Stop grid key listener when in edit mode
86
+
87
+
88
+ var isEditing = document.activeElement.id === activeCellId && document.activeElement.id === editId || dropdownIsActive() || datePickerIsActive();
89
+
90
+ if (isEditing || !gridActive) {
91
+ return;
92
+ } // Command keys need to be returned as there is default browser behavior with these keys
93
+
94
+
95
+ if (key === 'Meta' || key === 'Control') {
96
+ return;
97
+ } // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
98
+
99
+
100
+ if (['End', 'Home', 'ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1 && !isEditing && keysPressedList.length < 2) {
101
+ event.preventDefault();
102
+ }
103
+
104
+ var isDisabledCell = !!focusedCell.getAttribute('data-disabled');
105
+ var sharedUpdateParams = {
106
+ oldId: activeCellId,
107
+ instance: instance
108
+ };
109
+
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
+ {
136
+ dispatch({
137
+ type: 'UPDATE_ACTIVE_CELL_ID',
138
+ payload: _objectSpread({
139
+ direction: 'right'
140
+ }, sharedUpdateParams)
141
+ });
142
+ break;
143
+ }
144
+
145
+ case 'ArrowLeft':
146
+ {
147
+ dispatch({
148
+ type: 'UPDATE_ACTIVE_CELL_ID',
149
+ payload: _objectSpread({
150
+ direction: 'left'
151
+ }, sharedUpdateParams)
152
+ });
153
+ break;
154
+ }
155
+
156
+ case 'ArrowUp':
157
+ {
158
+ dispatch({
159
+ type: 'UPDATE_ACTIVE_CELL_ID',
160
+ payload: _objectSpread({
161
+ direction: 'up'
162
+ }, sharedUpdateParams)
163
+ });
164
+ break;
165
+ }
166
+
167
+ case 'ArrowDown':
168
+ {
169
+ dispatch({
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
194
+ });
195
+ break;
196
+ }
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
+ }
262
+ }
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
+ };
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["buttonLabel"];
5
+ var _excluded = ["legendText"];
6
6
  // @flow
7
7
 
8
8
  /*
@@ -22,8 +22,8 @@ import { pkg } from '../../../../../settings';
22
22
  var blockClass = "".concat(pkg.prefix, "--datagrid");
23
23
 
24
24
  var RowSizeDropdown = function RowSizeDropdown(_ref) {
25
- var _ref$buttonLabel = _ref.buttonLabel,
26
- buttonLabel = _ref$buttonLabel === void 0 ? 'Row height' : _ref$buttonLabel,
25
+ var _ref$legendText = _ref.legendText,
26
+ legendText = _ref$legendText === void 0 ? 'Row height' : _ref$legendText,
27
27
  props = _objectWithoutProperties(_ref, _excluded);
28
28
 
29
29
  var buttonRef = React.useRef({});
@@ -42,9 +42,10 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
42
42
  onClick: function onClick() {
43
43
  return setIsOpen(!isOpen);
44
44
  },
45
- iconDescription: buttonLabel,
45
+ iconDescription: legendText,
46
46
  className: cx(_defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
47
47
  }), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({}, props, {
48
+ legendText: legendText,
48
49
  buttonRef: buttonRef,
49
50
  hideRadioGroup: function hideRadioGroup() {
50
51
  setIsOpen(false);
@@ -53,8 +54,8 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
53
54
  };
54
55
 
55
56
  RowSizeDropdown.propTypes = {
56
- buttonLabel: PropTypes.string,
57
57
  datagridName: PropTypes.string,
58
+ legendText: PropTypes.string,
58
59
  light: PropTypes.bool,
59
60
  onChange: PropTypes.func.isRequired,
60
61
  selectedOption: PropTypes.string
@@ -22,8 +22,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
22
22
  buttonRef = _ref.buttonRef,
23
23
  onChange = _ref.onChange,
24
24
  hideRadioGroup = _ref.hideRadioGroup,
25
- _ref$legendText = _ref.legendText,
26
- legendText = _ref$legendText === void 0 ? 'Row height' : _ref$legendText,
25
+ legendText = _ref.legendText,
27
26
  _ref$rowSizeLabels = _ref.rowSizeLabels,
28
27
  rowSizeLabels = _ref$rowSizeLabels === void 0 ? {
29
28
  xl: 'Extra large',
@@ -20,4 +20,6 @@ export { default as useStickyColumn } from './useStickyColumn';
20
20
  export { default as useActionsColumn } from './useActionsColumn';
21
21
  export { default as useCustomizeColumns } from './useCustomizeColumns';
22
22
  export { default as useSelectAllWithToggle } from './useSelectAllToggle';
23
- export { default as useColumnCenterAlign } from './useColumnCenterAlign';
23
+ export { default as useColumnCenterAlign } from './useColumnCenterAlign';
24
+ export { default as useColumnOrder } from './useColumnOrder';
25
+ export { default as useInlineEdit } from './useInlineEdit';
@@ -1,7 +1,8 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
4
+ var _excluded = ["id", "itemText", "onClick", "icon"],
5
+ _excluded2 = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
5
6
 
6
7
  /*
7
8
  * Licensed Materials - Property of IBM
@@ -19,7 +20,8 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useActionsColumn = function useActionsColumn(hooks) {
20
21
  var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
21
22
  var rowActions = instance.rowActions,
22
- isFetching = instance.isFetching;
23
+ isFetching = instance.isFetching,
24
+ selectedFlatRows = instance.selectedFlatRows;
23
25
 
24
26
  if (rowActions && Array.isArray(rowActions)) {
25
27
  var addActionsMenu = function addActionsMenu(props, cellData) {
@@ -28,7 +30,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
28
30
  column = cell.column;
29
31
 
30
32
  if (column.isAction) {
31
- var _cx;
33
+ var _cx3;
32
34
 
33
35
  return [props, {
34
36
  children: /*#__PURE__*/React.createElement("div", {
@@ -40,26 +42,37 @@ var useActionsColumn = function useActionsColumn(hooks) {
40
42
  style: {
41
43
  display: 'flex'
42
44
  }
43
- }, rowActions.map(function (action) {
45
+ }, rowActions.map(function (action, index) {
44
46
  var id = action.id,
45
47
  itemText = action.itemText,
46
48
  _onClick = action.onClick,
47
- icon = action.icon;
49
+ icon = action.icon,
50
+ rest = _objectWithoutProperties(action, _excluded);
51
+
52
+ var selectedRowId = selectedFlatRows === null || selectedFlatRows === void 0 ? void 0 : selectedFlatRows.filter(function (item) {
53
+ return item.id === row.id ? item.id : null;
54
+ });
48
55
  return /*#__PURE__*/React.createElement("div", {
49
- className: "".concat(blockClass, "__actions-column-button"),
50
- key: ""
51
- }, /*#__PURE__*/React.createElement(OverflowMenu, {
56
+ className: cx("".concat(blockClass, "__actions-column-button"), _defineProperty({}, "".concat(blockClass, "__disabled-row-action-button"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
57
+ key: "".concat(itemText, "__").concat(index)
58
+ }, /*#__PURE__*/React.createElement(OverflowMenu, _extends({}, rest, {
52
59
  renderIcon: icon,
53
60
  hasIconOnly: true,
54
61
  light: true,
55
62
  iconDescription: itemText,
56
63
  kind: "ghost",
64
+ className: cx(_defineProperty({}, "".concat(blockClass, "__disabled-row-action"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
57
65
  onClick: function onClick(e) {
66
+ if (selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length) {
67
+ // Row actions should be disabled if row is selected and batchActions toolbar is active
68
+ return;
69
+ }
70
+
58
71
  e.stopPropagation();
59
72
 
60
73
  _onClick(id, row, e);
61
74
  }
62
- }));
75
+ })));
63
76
  })), !isFetching && rowActions.length > 2 && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(OverflowMenu, {
64
77
  size: "sm",
65
78
  light: true,
@@ -73,7 +86,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
73
86
  shouldHideMenuItem = action.shouldHideMenuItem,
74
87
  shouldDisableMenuItem = action.shouldDisableMenuItem,
75
88
  disabled = action.disabled,
76
- rest = _objectWithoutProperties(action, _excluded);
89
+ rest = _objectWithoutProperties(action, _excluded2);
77
90
 
78
91
  var hidden = typeof shouldHideMenuItem === 'function' && shouldHideMenuItem(row); // shouldDisableMenuItem will override disabled because it's more specific
79
92
  // if shouldDisableMenuItem doesn't exists, fall back to disabled
@@ -94,7 +107,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
94
107
  key: id
95
108
  }));
96
109
  })))),
97
- className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx, "".concat(blockClass, "__cell"), true), _cx))
110
+ className: cx((_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__cell"), true), _cx3)),
111
+ style: {
112
+ width: 96
113
+ }
98
114
  }];
99
115
  }
100
116
 
@@ -0,0 +1,8 @@
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 { useColumnOrder } from 'react-table';
8
+ export default useColumnOrder;
@@ -26,6 +26,10 @@ var useCustomizeColumns = function useCustomizeColumns(hooks) {
26
26
 
27
27
  hooks.useInstance.push(function (instance) {
28
28
  var customizeColumnsProps = instance.customizeColumnsProps;
29
+
30
+ var _ref = customizeColumnsProps || {},
31
+ labels = _ref.labels;
32
+
29
33
  Object.assign(instance, {
30
34
  customizeColumnsProps: _objectSpread(_objectSpread({}, customizeColumnsProps), {}, {
31
35
  isModalOpen: isModalOpen,
@@ -33,6 +37,7 @@ var useCustomizeColumns = function useCustomizeColumns(hooks) {
33
37
  }),
34
38
  CustomizeColumnsButton: function CustomizeColumnsButton(props) {
35
39
  return /*#__PURE__*/React.createElement(ToggleButtonWrapper, _extends({
40
+ iconTooltipLabel: labels === null || labels === void 0 ? void 0 : labels.iconTooltipLabel,
36
41
  isModalOpen: isModalOpen,
37
42
  setIsModalOpen: setIsModalOpen
38
43
  }, props));
@@ -22,6 +22,8 @@ var useDisableSelectRows = function useDisableSelectRows(hooks) {
22
22
 
23
23
  var updateSelectAll = function updateSelectAll(hooks) {
24
24
  var getToggleAllRowsSelectedProps = function getToggleAllRowsSelectedProps(props, _ref2) {
25
+ var _instance$disableSele, _instance$disableSele2;
26
+
25
27
  var instance = _ref2.instance;
26
28
  var selectableRows = instance.rows.filter(function (row) {
27
29
  return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
@@ -41,7 +43,7 @@ var updateSelectAll = function updateSelectAll(hooks) {
41
43
  },
42
44
  checked: isAllRowsSelected,
43
45
  disabled: instance.disableSelectAll,
44
- title: 'Toggle All Rows Selected',
46
+ title: (instance === null || instance === void 0 ? void 0 : (_instance$disableSele = instance.disableSelectRowsProps) === null || _instance$disableSele === void 0 ? void 0 : (_instance$disableSele2 = _instance$disableSele.labels) === null || _instance$disableSele2 === void 0 ? void 0 : _instance$disableSele2.toggleAllRowsLabel) || 'Toggle All Rows Selected',
45
47
  indeterminate: Boolean(!isAllRowsSelected && Object.keys(instance.state.selectedRowIds).length)
46
48
  }];
47
49
  };
@@ -51,6 +53,8 @@ var updateSelectAll = function updateSelectAll(hooks) {
51
53
 
52
54
  var updatePageSelectAll = function updatePageSelectAll(hooks) {
53
55
  var getToggleAllPageRowsSelectedProps = function getToggleAllPageRowsSelectedProps(props, _ref4) {
56
+ var _instance$disableSele3, _instance$disableSele4;
57
+
54
58
  var instance = _ref4.instance;
55
59
  var selectableRows = instance.page.filter(function (row) {
56
60
  return !(instance.shouldDisableSelectRow && instance.shouldDisableSelectRow(row));
@@ -70,7 +74,7 @@ var updatePageSelectAll = function updatePageSelectAll(hooks) {
70
74
  },
71
75
  checked: isAllRowsSelected,
72
76
  disabled: instance.disableSelectAll,
73
- title: 'Toggle All Rows Selected',
77
+ title: (instance === null || instance === void 0 ? void 0 : (_instance$disableSele3 = instance.disableSelectRowsProps) === null || _instance$disableSele3 === void 0 ? void 0 : (_instance$disableSele4 = _instance$disableSele3.labels) === null || _instance$disableSele4 === void 0 ? void 0 : _instance$disableSele4.toggleAllRowsLabel) || 'Toggle All Rows Selected',
74
78
  indeterminate: Boolean(!isAllRowsSelected && instance.page.some(function (_ref6) {
75
79
  var id = _ref6.id;
76
80
  return instance.state.selectedRowIds[id];
@@ -37,7 +37,6 @@ var useExpandedRow = function useExpandedRow(hooks) {
37
37
  return _objectSpread(_objectSpread({}, row), {}, {
38
38
  canExpand: row.original && !row.original.notExpandable,
39
39
  expandedContentHeight: expandedRowsHeight[row.index] || expandedContentHeight,
40
- // RowRenderer: DatagridExpandedRow(row.RowRenderer, expansionRenderer),
41
40
  RowRenderer: DatagridExpandedRow(row.RowRenderer, ExpandedRowContentComponent)
42
41
  });
43
42
  });
@@ -0,0 +1,71 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
3
+ /*
4
+ * Licensed Materials - Property of IBM
5
+ * 5724-Q36
6
+ * (c) Copyright IBM Corp. 2022
7
+ * US Government Users Restricted Rights - Use, duplication or disclosure
8
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
9
+ */
10
+ import React from 'react';
11
+ import { pkg } from '../../settings';
12
+ import cx from 'classnames';
13
+ import { InlineEditCell } from './Datagrid/addons/InlineEdit/InlineEditCell';
14
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
15
+
16
+ var useInlineEdit = function useInlineEdit(hooks) {
17
+ var addInlineEdit = function addInlineEdit(props, _ref) {
18
+ var _cell$column, _cell$column$inlineEd, _instance$columns$fil;
19
+
20
+ var cell = _ref.cell,
21
+ instance = _ref.instance;
22
+ var columnInlineEditConfig = cell.column.inlineEdit;
23
+ var inlineEditType = (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : (_cell$column$inlineEd = _cell$column.inlineEdit) === null || _cell$column$inlineEd === void 0 ? void 0 : _cell$column$inlineEd.type;
24
+ var totalInlineEditColumns = (_instance$columns$fil = instance.columns.filter(function (item) {
25
+ return item.inlineEdit;
26
+ })) === null || _instance$columns$fil === void 0 ? void 0 : _instance$columns$fil.length;
27
+
28
+ var renderInlineEditComponent = function renderInlineEditComponent(type) {
29
+ return /*#__PURE__*/React.createElement(InlineEditCell, {
30
+ config: columnInlineEditConfig,
31
+ tabIndex: -1,
32
+ value: cell.value,
33
+ cell: cell,
34
+ instance: instance,
35
+ totalInlineEditColumns: totalInlineEditColumns,
36
+ type: type
37
+ });
38
+ };
39
+
40
+ if (cell.column.id === 'spacer') {
41
+ return [props, {
42
+ className: cx("".concat(blockClass, "__cell"), "".concat(blockClass, "__cell--spacer"))
43
+ }];
44
+ }
45
+
46
+ return [props, {
47
+ className: cx("".concat(blockClass, "__cell"), _defineProperty({}, "".concat(blockClass, "__cell-inline-edit"), true)),
48
+ role: 'gridcell',
49
+ children: /*#__PURE__*/React.createElement(React.Fragment, null, inlineEditType === 'text' && renderInlineEditComponent(inlineEditType), inlineEditType === 'number' && renderInlineEditComponent(inlineEditType), inlineEditType === 'selection' && renderInlineEditComponent(inlineEditType), inlineEditType === 'date' && renderInlineEditComponent(inlineEditType), !inlineEditType && /*#__PURE__*/React.createElement(InlineEditCell, {
50
+ config: columnInlineEditConfig,
51
+ tabIndex: -1,
52
+ value: cell.value,
53
+ cell: cell,
54
+ instance: instance,
55
+ disabled: true,
56
+ nonEditCell: true,
57
+ totalInlineEditColumns: totalInlineEditColumns,
58
+ type: "text"
59
+ }))
60
+ }];
61
+ };
62
+
63
+ hooks.getCellProps.push(addInlineEdit);
64
+ hooks.useInstance.push(function (instance) {
65
+ Object.assign(instance, {
66
+ withInlineEdit: true
67
+ });
68
+ });
69
+ };
70
+
71
+ export default useInlineEdit;
@@ -0,0 +1,42 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ /* eslint-disable react/prop-types */
5
+
6
+ /*
7
+ * Licensed Materials - Property of IBM
8
+ * 5724-Q36
9
+ * (c) Copyright IBM Corp. 2020
10
+ * US Government Users Restricted Rights - Use, duplication or disclosure
11
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
12
+ */
13
+ import React from 'react';
14
+ import { ChevronRight16 } from '@carbon/icons-react';
15
+ import cx from 'classnames';
16
+ import { pkg } from '../../settings';
17
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
18
+
19
+ var useNestedRowExpander = function useNestedRowExpander(hooks) {
20
+ var visibleColumns = function visibleColumns(columns) {
21
+ var expanderColumn = {
22
+ id: 'expander',
23
+ Cell: function Cell(_ref) {
24
+ var _cx;
25
+
26
+ var row = _ref.row;
27
+ return row.canExpand && /*#__PURE__*/React.createElement("span", row.getToggleRowExpandedProps(), /*#__PURE__*/React.createElement(ChevronRight16, {
28
+ className: cx("".concat(blockClass, "__expander-icon"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
29
+ }));
30
+ },
31
+ width: 48,
32
+ disableResizing: true,
33
+ disableSortBy: true,
34
+ Header: ''
35
+ };
36
+ return [expanderColumn].concat(_toConsumableArray(columns));
37
+ };
38
+
39
+ hooks.visibleColumns.push(visibleColumns);
40
+ };
41
+
42
+ export default useNestedRowExpander;