@carbon/ibm-products 2.0.0-rc.2 → 2.0.0-rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (229) hide show
  1. package/css/index-full-carbon.css +891 -178
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +4 -2
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +779 -19
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +4 -2
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +659 -77
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +4 -2
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +683 -91
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +4 -2
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/APIKeyModal/APIKeyModal.js +1 -1
  18. package/es/components/AddSelect/AddSelect.js +0 -3
  19. package/es/components/AddSelect/AddSelectBody.js +20 -3
  20. package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -3
  21. package/es/components/AddSelect/AddSelectColumn.js +5 -5
  22. package/es/components/AddSelect/AddSelectFilter.js +5 -4
  23. package/es/components/AddSelect/AddSelectList.js +61 -27
  24. package/es/components/AddSelect/AddSelectMetaPanel.js +1 -1
  25. package/es/components/AddSelect/AddSelectSort.js +1 -1
  26. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +4 -6
  27. package/es/components/Card/Card.js +16 -6
  28. package/es/components/Card/CardFooter.js +3 -1
  29. package/es/components/Card/CardHeader.js +20 -1
  30. package/es/components/ComboButton/ComboButton.js +1 -1
  31. package/es/components/DataSpreadsheet/DataSpreadsheet.js +63 -11
  32. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  33. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  34. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
  35. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +31 -0
  36. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  37. package/es/components/Datagrid/Datagrid/Datagrid.js +10 -38
  38. package/es/components/Datagrid/Datagrid/DatagridContent.js +149 -0
  39. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  40. package/es/components/Datagrid/Datagrid/DatagridRow.js +10 -2
  41. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
  42. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +13 -4
  43. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +5 -4
  44. package/es/components/Datagrid/Datagrid/DraggableElement.js +6 -2
  45. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -45
  46. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +1 -1
  47. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +35 -10
  48. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +61 -24
  49. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  50. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +60 -0
  51. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  52. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +534 -0
  53. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  54. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  55. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  56. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  57. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +39 -0
  58. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  59. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +263 -0
  60. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +87 -0
  61. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -14
  62. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -36
  63. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
  64. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/LeftPanelStory.js +0 -0
  65. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
  66. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
  67. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
  68. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
  69. package/es/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -0
  70. package/es/components/Datagrid/index.js +3 -1
  71. package/es/components/Datagrid/useActionsColumn.js +28 -12
  72. package/es/components/Datagrid/useColumnOrder.js +8 -0
  73. package/es/components/Datagrid/useCustomizeColumns.js +5 -0
  74. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  75. package/es/components/Datagrid/useExpandedRow.js +0 -1
  76. package/es/components/Datagrid/useInlineEdit.js +71 -0
  77. package/es/components/Datagrid/useNestedRowExpander.js +42 -0
  78. package/es/components/Datagrid/useNestedRows.js +2 -2
  79. package/es/components/Datagrid/useRowExpander.js +1 -1
  80. package/es/components/Datagrid/useRowSize.js +17 -6
  81. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  82. package/es/components/Datagrid/useSelectRows.js +12 -2
  83. package/es/components/Datagrid/useSortableColumns.js +1 -1
  84. package/es/components/Datagrid/useStickyColumn.js +11 -0
  85. package/es/components/Datagrid/utils/DatagridActions.js +152 -0
  86. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  87. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  88. package/es/components/Datagrid/utils/getArgTypes.js +85 -0
  89. package/es/components/Datagrid/utils/getInlineEditColumns.js +153 -0
  90. package/es/components/Datagrid/utils/makeData.js +46 -1
  91. package/es/components/ExportModal/ExportModal.js +1 -1
  92. package/es/components/ImportModal/ImportModal.js +3 -3
  93. package/es/components/InlineEdit/InlineEdit.js +11 -9
  94. package/es/components/ModifiedTabs/ModifiedTabLabelNew.js +1 -1
  95. package/es/components/ModifiedTabs/ModifiedTabLabelWithClose.js +1 -1
  96. package/es/components/NotificationsPanel/NotificationsPanel.js +1 -1
  97. package/es/components/OptionsTile/OptionsTile.js +1 -1
  98. package/es/components/PageHeader/PageHeader.js +1 -1
  99. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  100. package/es/components/Saving/Saving.js +1 -1
  101. package/es/components/SidePanel/SidePanel.js +1 -1
  102. package/es/components/StatusIcon/StatusIcon.js +1 -1
  103. package/es/components/UserProfileImage/UserProfileImage.js +1 -1
  104. package/es/components/WebTerminal/WebTerminal.js +1 -1
  105. package/es/components/WebTerminal/preview-components/Navigation.js +1 -1
  106. package/es/components/index.js +1 -1
  107. package/es/global/js/hooks/useClickOutside.js +1 -1
  108. package/es/global/js/package-settings.js +3 -3
  109. package/es/global/js/utils/rangeWithCallback.js +13 -0
  110. package/es/global/js/utils/story-helper.js +5 -1
  111. package/es/global/js/utils/uuidv4.spec.js +4 -0
  112. package/lib/components/APIKeyModal/APIKeyModal.js +4 -4
  113. package/lib/components/AddSelect/AddSelect.js +0 -4
  114. package/lib/components/AddSelect/AddSelectBody.js +20 -3
  115. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
  116. package/lib/components/AddSelect/AddSelectColumn.js +5 -5
  117. package/lib/components/AddSelect/AddSelectFilter.js +5 -4
  118. package/lib/components/AddSelect/AddSelectList.js +62 -28
  119. package/lib/components/AddSelect/AddSelectMetaPanel.js +2 -2
  120. package/lib/components/AddSelect/AddSelectSort.js +4 -4
  121. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +6 -6
  122. package/lib/components/Card/Card.js +16 -6
  123. package/lib/components/Card/CardFooter.js +3 -1
  124. package/lib/components/Card/CardHeader.js +21 -1
  125. package/lib/components/ComboButton/ComboButton.js +3 -3
  126. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +63 -10
  127. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  128. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  129. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +6 -5
  130. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
  131. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  132. package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
  133. package/lib/components/Datagrid/Datagrid/DatagridContent.js +183 -0
  134. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  135. package/lib/components/Datagrid/Datagrid/DatagridRow.js +19 -2
  136. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
  137. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +16 -5
  138. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +6 -5
  139. package/lib/components/Datagrid/Datagrid/DraggableElement.js +7 -3
  140. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -47
  141. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +2 -2
  142. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +47 -25
  143. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +59 -23
  144. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  145. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +76 -0
  146. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  147. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +558 -0
  148. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  149. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  150. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  151. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  152. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +45 -0
  153. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  154. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +272 -0
  155. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +100 -0
  156. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -13
  157. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +13 -35
  158. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/CustomizeColumnStory.js +0 -0
  159. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/LeftPanelStory.js +0 -0
  160. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/RowSizeDropdownStory.js +0 -0
  161. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/SelectAllWithToggleStory.js +0 -0
  162. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/StickyActionsColumnStory.js +0 -0
  163. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/common.js +0 -0
  164. package/lib/components/Datagrid/{Datagrid.stories-helpers → Datagrid.stories}/index.js +0 -0
  165. package/lib/components/Datagrid/index.js +17 -1
  166. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  167. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  168. package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
  169. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  170. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  171. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  172. package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
  173. package/lib/components/Datagrid/useNestedRows.js +3 -3
  174. package/lib/components/Datagrid/useRowExpander.js +3 -3
  175. package/lib/components/Datagrid/useRowSize.js +18 -13
  176. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  177. package/lib/components/Datagrid/useSelectRows.js +12 -2
  178. package/lib/components/Datagrid/useSortableColumns.js +5 -5
  179. package/lib/components/Datagrid/useStickyColumn.js +11 -0
  180. package/lib/components/Datagrid/utils/DatagridActions.js +170 -0
  181. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  182. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  183. package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
  184. package/lib/components/Datagrid/utils/getInlineEditColumns.js +168 -0
  185. package/lib/components/Datagrid/utils/makeData.js +47 -1
  186. package/lib/components/ExportModal/ExportModal.js +3 -3
  187. package/lib/components/ImportModal/ImportModal.js +4 -4
  188. package/lib/components/InlineEdit/InlineEdit.js +16 -14
  189. package/lib/components/ModifiedTabs/ModifiedTabLabelNew.js +2 -2
  190. package/lib/components/ModifiedTabs/ModifiedTabLabelWithClose.js +3 -3
  191. package/lib/components/NotificationsPanel/NotificationsPanel.js +8 -8
  192. package/lib/components/OptionsTile/OptionsTile.js +6 -6
  193. package/lib/components/PageHeader/PageHeader.js +2 -2
  194. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  195. package/lib/components/Saving/Saving.js +5 -5
  196. package/lib/components/SidePanel/SidePanel.js +3 -3
  197. package/lib/components/StatusIcon/StatusIcon.js +45 -45
  198. package/lib/components/UserProfileImage/UserProfileImage.js +7 -7
  199. package/lib/components/WebTerminal/WebTerminal.js +3 -3
  200. package/lib/components/WebTerminal/preview-components/Navigation.js +4 -4
  201. package/lib/components/index.js +12 -0
  202. package/lib/global/js/hooks/useClickOutside.js +1 -1
  203. package/lib/global/js/package-settings.js +3 -3
  204. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  205. package/lib/global/js/utils/story-helper.js +5 -1
  206. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  207. package/package.json +15 -15
  208. package/scss/components/AddSelect/_add-select.scss +127 -28
  209. package/scss/components/Card/_card.scss +1 -0
  210. package/scss/components/Cascade/_cascade.scss +1 -1
  211. package/scss/components/CreateTearsheet/_create-tearsheet.scss +2 -0
  212. package/scss/components/Datagrid/_datagrid.scss +7 -0
  213. package/scss/components/Datagrid/_storybook-styles.scss +8 -5
  214. package/scss/components/Datagrid/styles/_datagrid.scss +31 -15
  215. package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
  216. package/scss/components/Datagrid/styles/_index.scss +1 -0
  217. package/scss/components/Datagrid/styles/_useActionsColumn.scss +14 -0
  218. package/scss/components/Datagrid/styles/_useExpandedRow.scss +37 -9
  219. package/scss/components/Datagrid/styles/_useInlineEdit.scss +404 -0
  220. package/scss/components/Datagrid/styles/_useNestedRows.scss +16 -1
  221. package/scss/components/Datagrid/styles/_useStickyColumn.scss +31 -2
  222. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +45 -6
  223. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -1
  224. package/scss/components/InlineEdit/_inline-edit.scss +4 -2
  225. package/scss/components/NotificationsPanel/_notifications-panel.scss +3 -6
  226. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  227. package/scss/components/SidePanel/_side-panel.scss +3 -6
  228. package/scss/components/Tearsheet/_tearsheet.scss +2 -2
  229. package/scss/components/_index-released-only.scss +1 -0
@@ -0,0 +1,534 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+
5
+ 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; }
6
+
7
+ 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; }
8
+
9
+ /**
10
+ * Copyright IBM Corp. 2022, 2022
11
+ *
12
+ * This source code is licensed under the Apache-2.0 license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ */
15
+ import React, { useState, useRef, useEffect, useContext, useCallback } from 'react';
16
+ import PropTypes from 'prop-types';
17
+ import { TextInput, NumberInput, Dropdown, DatePicker, DatePickerInput } from '@carbon/react';
18
+ import { Edit, CaretSort, ChevronDown, Calendar } from '@carbon/react/icons';
19
+ import { InlineEditButton } from '../InlineEditButton';
20
+ import { pkg } from '../../../../../../settings';
21
+ import cx from 'classnames';
22
+ import { InlineEditContext } from '../InlineEditContext';
23
+ import { usePreviousValue } from '../../../../../../global/js/hooks';
24
+ import { prepareProps } from '../../../../../../global/js/utils/props-helper';
25
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
26
+ export var InlineEditCell = function InlineEditCell(_ref) {
27
+ var _config$validator, _cx3;
28
+
29
+ var cell = _ref.cell,
30
+ config = _ref.config,
31
+ instance = _ref.instance,
32
+ _ref$placeholder = _ref.placeholder,
33
+ placeholder = _ref$placeholder === void 0 ? '' : _ref$placeholder,
34
+ tabIndex = _ref.tabIndex,
35
+ value = _ref.value,
36
+ nonEditCell = _ref.nonEditCell,
37
+ totalInlineEditColumns = _ref.totalInlineEditColumns,
38
+ type = _ref.type;
39
+ var columnId = cell.column.id;
40
+ var columnIndex = instance.columns.findIndex(function (col) {
41
+ return col.id === columnId;
42
+ });
43
+ var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
44
+ var totalColumns = instance.columns.length;
45
+
46
+ var _useContext = useContext(InlineEditContext),
47
+ state = _useContext.state,
48
+ dispatch = _useContext.dispatch;
49
+
50
+ var _useState = useState(false),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ inEditMode = _useState2[0],
53
+ setInEditMode = _useState2[1];
54
+
55
+ var _useState3 = useState(value),
56
+ _useState4 = _slicedToArray(_useState3, 2),
57
+ cellValue = _useState4[0],
58
+ setCellValue = _useState4[1];
59
+
60
+ var _useState5 = useState(),
61
+ _useState6 = _slicedToArray(_useState5, 2),
62
+ initialValue = _useState6[0],
63
+ setInitialValue = _useState6[1];
64
+
65
+ var _useState7 = useState(),
66
+ _useState8 = _slicedToArray(_useState7, 2),
67
+ cellLabel = _useState8[0],
68
+ setCellLabel = _useState8[1];
69
+
70
+ var activeCellId = state.activeCellId,
71
+ editId = state.editId;
72
+ var previousState = usePreviousValue({
73
+ editId: editId,
74
+ activeCellId: activeCellId
75
+ });
76
+
77
+ var _ref2 = config || {},
78
+ inputProps = _ref2.inputProps;
79
+
80
+ var textInputRef = useRef();
81
+ var numberInputRef = useRef();
82
+ var dropdownRef = useRef();
83
+ var datePickerRef = useRef();
84
+ var outerButtonElement = useRef();
85
+ useEffect(function () {
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
92
+ }, []); // Reverts cellValue back to initialValue when exiting edit mode via clicking outside
93
+ // of the cell (either on a regular cell or clicking into another inline edit cell) and the
94
+ // edit input is in an invalid state
95
+
96
+ useEffect(function () {
97
+ if ((previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && !editId || (previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && cellId !== editId) {
98
+ var _ref3 = config || {},
99
+ validator = _ref3.validator;
100
+
101
+ var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue);
102
+
103
+ if (isInvalid) {
104
+ setCellValue(initialValue);
105
+ saveCellData(initialValue);
106
+ return;
107
+ }
108
+ }
109
+ }, [previousState === null || previousState === void 0 ? void 0 : previousState.editId, editId, cellId, cellValue, config, initialValue, saveCellData]); // If you are in edit mode and click outside of the cell,
110
+ // this changes the cell back to the InlineEditButton
111
+
112
+ useEffect(function () {
113
+ if (activeCellId !== cellId || !editId) {
114
+ setInEditMode(false);
115
+ }
116
+
117
+ if (activeCellId === cellId && editId === cellId && !nonEditCell) {
118
+ setInEditMode(true);
119
+ saveCellData(cellValue);
120
+ }
121
+ }, [activeCellId, cellId, nonEditCell, editId, cellValue, saveCellData]);
122
+
123
+ var openDropdown = function openDropdown(type) {
124
+ // *****
125
+ // Only added this querySelector because v11 Datepicker isn't forwarding the ref which breaks how we were handling this in v10
126
+ // *****
127
+ var datePickerInputElement = document.querySelector("#".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index));
128
+ var dropdownTrigger = type === 'selection' ? dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current : datePickerInputElement;
129
+ dropdownTrigger.click();
130
+
131
+ if (type === 'date') {
132
+ dropdownTrigger === null || dropdownTrigger === void 0 ? void 0 : dropdownTrigger.focus();
133
+ }
134
+ }; // Re-initializes initialValue if clicking outside of a cell that was previously
135
+ // in edit mode, otherwise `initialValue` becomes stale
136
+
137
+
138
+ useEffect(function () {
139
+ if ((previousState === null || previousState === void 0 ? void 0 : previousState.editId) === cellId && (previousState === null || previousState === void 0 ? void 0 : previousState.activeCellId) === cellId && activeCellId !== cellId) {
140
+ setInitialValue(cellValue);
141
+ }
142
+ }, [previousState, cellId, cellValue, activeCellId]);
143
+
144
+ var handleInlineCellClick = function handleInlineCellClick() {
145
+ if (!inEditMode) {
146
+ dispatch({
147
+ type: 'ENTER_EDIT_MODE',
148
+ payload: {
149
+ activeCellId: cellId,
150
+ editId: cellId
151
+ }
152
+ });
153
+ setInEditMode(true);
154
+ setTimeout(function () {
155
+ if (type === 'selection' || type === 'date') {
156
+ openDropdown(type);
157
+ }
158
+ }, 1);
159
+ }
160
+ };
161
+
162
+ var rowSize = instance.rowSize,
163
+ onDataUpdate = instance.onDataUpdate; // Auto focus text input when entering edit mode
164
+
165
+ useEffect(function () {
166
+ if (inEditMode) {
167
+ if (type === 'text') {
168
+ textInputRef.current.focus();
169
+ }
170
+
171
+ if (type === 'number') {
172
+ numberInputRef.current.focus();
173
+ }
174
+ }
175
+ }, [inEditMode, type]); // Initialize cellValue from value prop
176
+
177
+ useEffect(function () {
178
+ setCellValue(value);
179
+ }, [value]); // Saves the new cell data, onDataUpdate is a required function to be
180
+ // passed to useDatagrid when using useInlineEdit
181
+
182
+ var saveCellData = useCallback(function (newValue) {
183
+ var columnId = cell.column.id;
184
+ var rowIndex = cell.row.index;
185
+ onDataUpdate(function (prev) {
186
+ return prev.map(function (row, index) {
187
+ if (index === rowIndex) {
188
+ return _objectSpread(_objectSpread({}, prev[rowIndex]), {}, _defineProperty({}, columnId, newValue));
189
+ }
190
+
191
+ return row;
192
+ });
193
+ });
194
+ }, [cell, onDataUpdate]);
195
+
196
+ var sendFocusBackToGrid = function sendFocusBackToGrid() {
197
+ // Allows the onKeyDown listener to go back to the entire grid area
198
+ var inlineEditArea = document.querySelector("#".concat(instance.tableId, " .").concat(blockClass, "__table-with-inline-edit"));
199
+ inlineEditArea.focus();
200
+ };
201
+
202
+ var getNewCellId = function getNewCellId(key) {
203
+ var totalRows = instance.rows.length;
204
+ var newCellId = key === 'Enter' ? "column-".concat(columnIndex, "-row-").concat(cell.row.index < totalRows - 1 ? cell.row.index + 1 : cell.row.index) : "column-".concat(columnIndex < instance.columns.length - 1 ? columnIndex + 1 : columnIndex, "-row-").concat(cell.row.index);
205
+ return newCellId;
206
+ };
207
+
208
+ var handleKeyDown = function handleKeyDown(event) {
209
+ var key = event.key;
210
+
211
+ switch (key) {
212
+ // Save cell contents to data
213
+ case 'Tab':
214
+ case 'Enter':
215
+ {
216
+ if (inEditMode) {
217
+ // Dropdown saves are handled in the Dropdown's/DatePicker's onChange prop
218
+ if (type === 'selection' || type === 'date') {
219
+ return;
220
+ }
221
+
222
+ var _ref4 = config || {},
223
+ validator = _ref4.validator;
224
+
225
+ var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue); // If an invalid state is detected, Tab/Enter should not do anything
226
+ // until the input has a valid state once again
227
+
228
+ if (isInvalid) {
229
+ return;
230
+ }
231
+
232
+ var newCellId = getNewCellId(key);
233
+ saveCellData(cellValue);
234
+ setInitialValue(cellValue);
235
+ dispatch({
236
+ type: 'EXIT_EDIT_MODE',
237
+ payload: newCellId
238
+ });
239
+ setInEditMode(false);
240
+ sendFocusBackToGrid();
241
+ }
242
+
243
+ break;
244
+ }
245
+
246
+ case 'Escape':
247
+ {
248
+ if (inEditMode) {
249
+ dispatch({
250
+ type: 'EXIT_EDIT_MODE',
251
+ payload: cellId
252
+ });
253
+ setCellValue(initialValue);
254
+ saveCellData(initialValue);
255
+ setInEditMode(false);
256
+ sendFocusBackToGrid();
257
+ }
258
+
259
+ break;
260
+ }
261
+
262
+ default:
263
+ return;
264
+ }
265
+ };
266
+
267
+ var addActiveState = function addActiveState() {
268
+ dispatch({
269
+ type: 'UPDATE_ACTIVE_CELL_ID',
270
+ payload: cellId
271
+ });
272
+ };
273
+
274
+ var renderDropdownItem = function renderDropdownItem(item) {
275
+ var includesIcon = !!(item !== null && item !== void 0 && item.icon);
276
+ return includesIcon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(item.icon), /*#__PURE__*/React.createElement("span", {
277
+ className: cx("".concat(blockClass, "__inline-edit--select-item"))
278
+ }, item === null || item === void 0 ? void 0 : item.text)) : item === null || item === void 0 ? void 0 : item.text;
279
+ };
280
+
281
+ var renderSelectCell = function renderSelectCell() {
282
+ var _ref5 = config || {},
283
+ inputProps = _ref5.inputProps;
284
+
285
+ return /*#__PURE__*/React.createElement(Dropdown, _extends({
286
+ id: cellId,
287
+ label: cellLabel || 'Dropdown menu options',
288
+ ariaLabel: cellLabel || 'Dropdown menu options'
289
+ }, inputProps, {
290
+ hideLabel: true,
291
+ style: {
292
+ width: cell.column.totalWidth
293
+ },
294
+ className: cx("".concat(blockClass, "__inline-edit--select"), _defineProperty({}, "".concat(blockClass, "__inline-edit--select-").concat(rowSize), rowSize)),
295
+ items: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.items) || [],
296
+ initialSelectedItem: cell.value,
297
+ itemToElement: function itemToElement(item) {
298
+ return renderDropdownItem(item);
299
+ },
300
+ renderSelectedItem: function renderSelectedItem(item) {
301
+ return renderDropdownItem(item);
302
+ },
303
+ onChange: function onChange(item) {
304
+ var _inputProps$onChange;
305
+
306
+ var newCellId = getNewCellId('Enter');
307
+ saveCellData(item.selectedItem);
308
+ setCellValue(item.selectedItem);
309
+ dispatch({
310
+ type: 'EXIT_EDIT_MODE',
311
+ payload: newCellId
312
+ });
313
+ setInEditMode(false);
314
+ sendFocusBackToGrid();
315
+ inputProps === null || inputProps === void 0 ? void 0 : (_inputProps$onChange = inputProps.onChange) === null || _inputProps$onChange === void 0 ? void 0 : _inputProps$onChange.call(inputProps, item.selectedItem);
316
+ },
317
+ downshiftProps: {
318
+ onStateChange: function onStateChange(downshiftState) {
319
+ var _ref6 = downshiftState || {},
320
+ isOpen = _ref6.isOpen; // !isOpen does not work in this case because a state change occurs on hover of the
321
+ // menu items and isOpen is changed to undefined which causes dispatch to be called unexpectedly
322
+
323
+
324
+ if (isOpen === false) {
325
+ dispatch({
326
+ type: 'EXIT_EDIT_MODE',
327
+ payload: cellId
328
+ });
329
+ setInEditMode(false);
330
+ sendFocusBackToGrid();
331
+ }
332
+ }
333
+ },
334
+ ref: dropdownRef
335
+ }));
336
+ };
337
+
338
+ var setRenderIcon = function setRenderIcon() {
339
+ if (type === 'text') {
340
+ return function (props) {
341
+ return /*#__PURE__*/React.createElement(Edit, _extends({
342
+ size: 16
343
+ }, props));
344
+ };
345
+ }
346
+
347
+ if (type === 'number') {
348
+ return function (props) {
349
+ return /*#__PURE__*/React.createElement(CaretSort, _extends({
350
+ size: 16
351
+ }, props));
352
+ };
353
+ }
354
+
355
+ if (type === 'selection') {
356
+ return function (props) {
357
+ return /*#__PURE__*/React.createElement(ChevronDown, _extends({
358
+ size: 16
359
+ }, props));
360
+ };
361
+ }
362
+
363
+ if (type === 'date') {
364
+ return function (props) {
365
+ return /*#__PURE__*/React.createElement(Calendar, _extends({
366
+ size: 16
367
+ }, props));
368
+ };
369
+ }
370
+ };
371
+
372
+ var renderDateCell = function renderDateCell() {
373
+ var _config$inputProps, _outerButtonElement$c;
374
+
375
+ var datePickerPreparedProps = prepareProps(config.inputProps, ['datePickerInputProps']);
376
+ var datePickerInputProps = config === null || config === void 0 ? void 0 : (_config$inputProps = config.inputProps) === null || _config$inputProps === void 0 ? void 0 : _config$inputProps.datePickerInputProps;
377
+ return /*#__PURE__*/React.createElement(DatePicker, _extends({}, datePickerPreparedProps, {
378
+ appendTo: outerButtonElement === null || outerButtonElement === void 0 ? void 0 : (_outerButtonElement$c = outerButtonElement.current) === null || _outerButtonElement$c === void 0 ? void 0 : _outerButtonElement$c.parentElement,
379
+ ref: datePickerRef,
380
+ style: {
381
+ width: cell.column.totalWidth
382
+ },
383
+ datePickerType: "single",
384
+ className: cx("".concat(blockClass, "__inline-edit--date"), _defineProperty({}, "".concat(blockClass, "__inline-edit--date-").concat(rowSize), rowSize)),
385
+ onChange: function onChange(newDate) {
386
+ var _datePickerPreparedPr;
387
+
388
+ var newDateObj = newDate[0];
389
+ datePickerPreparedProps === null || datePickerPreparedProps === void 0 ? void 0 : (_datePickerPreparedPr = datePickerPreparedProps.onChange) === null || _datePickerPreparedPr === void 0 ? void 0 : _datePickerPreparedPr.call(datePickerPreparedProps, newDateObj, cell);
390
+ var newCellId = getNewCellId('Enter');
391
+ saveCellData(newDateObj);
392
+ setCellValue(newDateObj); // To handle the interaction of the masked input when the DatePicker and updating
393
+
394
+ setTimeout(function () {
395
+ setInEditMode(false);
396
+ sendFocusBackToGrid();
397
+ dispatch({
398
+ type: 'EXIT_EDIT_MODE',
399
+ payload: newCellId
400
+ });
401
+ }, 1);
402
+ },
403
+ value: cell.value
404
+ }), /*#__PURE__*/React.createElement(DatePickerInput, _extends({}, datePickerInputProps, {
405
+ style: {
406
+ position: 'static'
407
+ },
408
+ placeholder: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.placeholder) || 'mm/dd/yyyy',
409
+ labelText: (datePickerInputProps === null || datePickerInputProps === void 0 ? void 0 : datePickerInputProps.labelText) || cellLabel || 'Set date',
410
+ id: "".concat(blockClass, "__inline-edit--date-picker--").concat(cell.row.index),
411
+ hideLabel: true
412
+ })));
413
+ }; // Ensures that months and days are all 2 digits, prefixes 0 if `num` is a single digit
414
+
415
+
416
+ var padTo2Digits = function padTo2Digits(num) {
417
+ return num.toString().padStart(2, '0');
418
+ };
419
+
420
+ var buildDate = function buildDate(value) {
421
+ if (value instanceof Date) {
422
+ var _config$dateFormat = config.dateFormat,
423
+ dateFormat = _config$dateFormat === void 0 ? 'm/d/Y' : _config$dateFormat;
424
+ var maskedFullYear = value.getFullYear();
425
+ var maskedMonth = padTo2Digits(value.getMonth() + 1);
426
+ var maskedDay = padTo2Digits(value.getDate());
427
+
428
+ if (dateFormat === 'm/d/Y' || dateFormat === 'm/d/y') {
429
+ return [maskedMonth, maskedDay, maskedFullYear].join('/');
430
+ }
431
+
432
+ if (dateFormat === 'd/m/Y' || dateFormat === 'd/m/y') {
433
+ return [maskedDay, maskedMonth, maskedFullYear].join('/');
434
+ }
435
+ }
436
+
437
+ return null;
438
+ };
439
+
440
+ var renderNumberInput = function renderNumberInput() {
441
+ var _ref7 = config || {},
442
+ validator = _ref7.validator;
443
+
444
+ return /*#__PURE__*/React.createElement(NumberInput, _extends({
445
+ placeholder: placeholder,
446
+ label: cellLabel
447
+ }, inputProps, {
448
+ id: cellId,
449
+ hideLabel: true,
450
+ defaultValue: cellValue,
451
+ invalid: validator === null || validator === void 0 ? void 0 : validator(cellValue),
452
+ invalidText: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.invalidText) || 'Provide missing invalidText',
453
+ onChange: function onChange(event, _ref8) {
454
+ var value = _ref8.value;
455
+ setCellValue(value);
456
+
457
+ if (inputProps.onChange) {
458
+ inputProps.onChange(value);
459
+ }
460
+ },
461
+ ref: numberInputRef
462
+ }));
463
+ };
464
+
465
+ var renderTextInput = function renderTextInput() {
466
+ var _ref9 = config || {},
467
+ validator = _ref9.validator;
468
+
469
+ var isInvalid = validator === null || validator === void 0 ? void 0 : validator(cellValue);
470
+ return /*#__PURE__*/React.createElement(TextInput, _extends({
471
+ labelText: cellLabel,
472
+ placeholder: placeholder
473
+ }, inputProps, {
474
+ id: cellId,
475
+ hideLabel: true,
476
+ defaultValue: cellValue,
477
+ invalid: isInvalid,
478
+ invalidText: (inputProps === null || inputProps === void 0 ? void 0 : inputProps.invalidText) || 'Provide missing invalidText',
479
+ onChange: function onChange(event) {
480
+ setCellValue(event.target.value);
481
+
482
+ if (inputProps.onChange) {
483
+ inputProps.onChange(event.target.value);
484
+ }
485
+ },
486
+ ref: textInputRef
487
+ }));
488
+ };
489
+
490
+ return (
491
+ /*#__PURE__*/
492
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
493
+ React.createElement("div", {
494
+ ref: outerButtonElement,
495
+ "data-cell-id": cellId,
496
+ "data-column-index": columnIndex,
497
+ "data-row-index": cell.row.index,
498
+ "data-disabled": nonEditCell,
499
+ "data-inline-type": type,
500
+ onClick: !nonEditCell ? handleInlineCellClick : addActiveState,
501
+ onKeyDown: !nonEditCell ? handleKeyDown : null,
502
+ className: cx("".concat(blockClass, "__inline-edit--outer-cell-button"), (_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--").concat(rowSize), rowSize), _defineProperty(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--lg"), !rowSize), _defineProperty(_cx3, "".concat(blockClass, "__inline-edit--outer-cell-button--invalid"), config === null || config === void 0 ? void 0 : (_config$validator = config.validator) === null || _config$validator === void 0 ? void 0 : _config$validator.call(config, cellValue)), _cx3))
503
+ }, !inEditMode && /*#__PURE__*/React.createElement(InlineEditButton, {
504
+ isActiveCell: cellId === activeCellId,
505
+ renderIcon: setRenderIcon(),
506
+ label: type === 'selection' ? value.text : type === 'date' ? buildDate(value) : value,
507
+ labelIcon: (value === null || value === void 0 ? void 0 : value.icon) || null,
508
+ placeholder: placeholder,
509
+ tabIndex: tabIndex,
510
+ nonEditCell: nonEditCell,
511
+ columnConfig: cell.column,
512
+ totalInlineEditColumns: totalInlineEditColumns,
513
+ totalColumns: totalColumns,
514
+ type: type
515
+ }), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/React.createElement(React.Fragment, null, type === 'text' && renderTextInput(), type === 'number' && renderNumberInput(), type === 'selection' && renderSelectCell(), type === 'date' && renderDateCell()))
516
+ );
517
+ };
518
+ InlineEditCell.propTypes = {
519
+ cell: PropTypes.object,
520
+ config: PropTypes.object,
521
+ instance: PropTypes.shape({
522
+ columns: PropTypes.arrayOf(PropTypes.object),
523
+ onDataUpdate: PropTypes.func,
524
+ rows: PropTypes.arrayOf(PropTypes.object),
525
+ rowSize: PropTypes.string,
526
+ tableId: PropTypes.string
527
+ }),
528
+ nonEditCell: PropTypes.bool,
529
+ placeholder: PropTypes.string,
530
+ tabIndex: PropTypes.number,
531
+ totalInlineEditColumns: PropTypes.number,
532
+ type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
533
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.object])
534
+ };
@@ -0,0 +1 @@
1
+ export { InlineEditCell } from './InlineEditCell';
@@ -0,0 +1,112 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
+
8
+ /**
9
+ * Copyright IBM Corp. 2022, 2022
10
+ *
11
+ * This source code is licensed under the Apache-2.0 license found in the
12
+ * LICENSE file in the root directory of this source tree.
13
+ */
14
+ import React, { createContext, useReducer } from 'react';
15
+ import PropTypes from 'prop-types';
16
+ import { returnUpdatedActiveCell } from './returnUpdatedActiveCell';
17
+ import { getCellIdAsObject } from './getCellIdAsObject';
18
+ export var InlineEditContext = /*#__PURE__*/createContext();
19
+
20
+ var inlineEditReducer = function inlineEditReducer(state, action) {
21
+ switch (action.type) {
22
+ case 'ADD_GRID_ACTIVE_FOCUS':
23
+ {
24
+ return _objectSpread(_objectSpread({}, state), {}, {
25
+ gridActive: true,
26
+ activeCellId: action.payload,
27
+ // set default active cell when grid receives focus
28
+ previousActiveCellId: null
29
+ });
30
+ }
31
+
32
+ case 'REMOVE_GRID_ACTIVE_FOCUS':
33
+ {
34
+ return _objectSpread(_objectSpread({}, state), {}, {
35
+ gridActive: false,
36
+ editId: null,
37
+ activeCellId: null,
38
+ previousActiveCellId: action.payload
39
+ });
40
+ }
41
+
42
+ case 'ENTER_EDIT_MODE':
43
+ {
44
+ return _objectSpread(_objectSpread({}, state), {}, {
45
+ activeCellId: action.payload.activeCellId,
46
+ editId: action.payload.editId
47
+ });
48
+ }
49
+
50
+ case 'EXIT_EDIT_MODE':
51
+ {
52
+ return _objectSpread(_objectSpread({}, state), {}, {
53
+ activeCellId: action.payload,
54
+ editId: null
55
+ });
56
+ }
57
+
58
+ case 'UPDATE_ACTIVE_CELL_ID':
59
+ {
60
+ var _action$payload = action.payload,
61
+ direction = _action$payload.direction,
62
+ oldId = _action$payload.oldId,
63
+ instance = _action$payload.instance;
64
+
65
+ if (!action.payload.direction) {
66
+ return _objectSpread(_objectSpread({}, state), {}, {
67
+ activeCellId: action.payload,
68
+ editId: null
69
+ });
70
+ }
71
+
72
+ if (direction && typeof direction === 'string') {
73
+ var activeCellCoords = getCellIdAsObject(oldId);
74
+ var totalVisibleColumns = instance.visibleColumns.filter(function (item) {
75
+ return item.id !== 'spacer';
76
+ });
77
+ return returnUpdatedActiveCell({
78
+ activeCellCoords: activeCellCoords,
79
+ direction: direction,
80
+ totalVisibleColumns: totalVisibleColumns,
81
+ state: state,
82
+ instance: instance
83
+ });
84
+ }
85
+
86
+ break;
87
+ }
88
+
89
+ default:
90
+ return state;
91
+ }
92
+ };
93
+
94
+ export var InlineEditProvider = function InlineEditProvider(_ref) {
95
+ var children = _ref.children;
96
+ var initialState = {};
97
+
98
+ var _useReducer = useReducer(inlineEditReducer, initialState),
99
+ _useReducer2 = _slicedToArray(_useReducer, 2),
100
+ state = _useReducer2[0],
101
+ dispatch = _useReducer2[1];
102
+
103
+ return /*#__PURE__*/React.createElement(InlineEditContext.Provider, {
104
+ value: {
105
+ state: state,
106
+ dispatch: dispatch
107
+ }
108
+ }, children);
109
+ };
110
+ InlineEditProvider.propTypes = {
111
+ children: PropTypes.element
112
+ };
@@ -0,0 +1,27 @@
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
+ // Turns activeCellId into an object to be able to
8
+ // update cell coordinates more easily
9
+ export var getCellIdAsObject = function getCellIdAsObject(oldId) {
10
+ var oldIdArr = oldId.split('-');
11
+ var updatedOldValuesArray = oldIdArr.map(function (item) {
12
+ if (isNaN(item)) {
13
+ return item;
14
+ }
15
+
16
+ return Number(item);
17
+ });
18
+ var indexArray = updatedOldValuesArray.filter(Number.isFinite);
19
+ var keyArray = updatedOldValuesArray.filter(function (item) {
20
+ return typeof item === 'string';
21
+ });
22
+ var activeCellCoords = {};
23
+ keyArray.forEach(function (element, index) {
24
+ activeCellCoords[element] = indexArray[index];
25
+ });
26
+ return activeCellCoords;
27
+ };
@@ -0,0 +1 @@
1
+ export { InlineEditProvider, InlineEditContext } from './InlineEditContext';