@carbon/ibm-products 2.32.0 → 2.34.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. package/css/index-full-carbon.css +351 -3
  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 +351 -3
  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 +351 -3
  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/ActionBar/ActionBar.js +8 -1
  14. package/es/components/CreateSidePanel/CreateSidePanel.d.ts +81 -2
  15. package/es/components/CreateSidePanel/CreateSidePanel.js +5 -2
  16. package/es/components/CreateTearsheet/CreateTearsheetDivider.d.ts +12 -1
  17. package/es/components/CreateTearsheet/CreateTearsheetDivider.js +1 -1
  18. package/es/components/DataSpreadsheet/DataSpreadsheet.js +39 -145
  19. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +60 -112
  20. package/es/components/DataSpreadsheet/hooks/useMoveActiveCell.d.ts +3 -1
  21. package/es/components/DataSpreadsheet/hooks/useMoveActiveCell.js +10 -3
  22. package/es/components/DataSpreadsheet/utils/commonEventHandlers.d.ts +4 -0
  23. package/es/components/DataSpreadsheet/utils/commonEventHandlers.js +304 -0
  24. package/es/components/Datagrid/Datagrid/DatagridContent.js +2 -1
  25. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +4 -1
  26. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  27. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  28. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +6 -2
  29. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.d.ts +1 -1
  30. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +4 -0
  31. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.d.ts +2 -1
  32. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +4 -3
  33. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +5 -5
  34. package/es/components/Datagrid/useRowSize.js +4 -2
  35. package/es/components/DescriptionList/DescriptionList.d.ts +0 -37
  36. package/es/components/DescriptionList/DescriptionList.js +7 -12
  37. package/es/components/DescriptionList/DescriptionListBody.d.ts +2 -0
  38. package/es/components/DescriptionList/DescriptionListBody.js +39 -0
  39. package/es/components/DescriptionList/DescriptionListCell.d.ts +2 -0
  40. package/es/components/DescriptionList/DescriptionListCell.js +39 -0
  41. package/es/components/DescriptionList/DescriptionListRow.d.ts +2 -0
  42. package/es/components/DescriptionList/DescriptionListRow.js +41 -0
  43. package/es/components/DescriptionList/index.d.ts +4 -1
  44. package/es/components/EditSidePanel/EditSidePanel.d.ts +92 -2
  45. package/es/components/EditSidePanel/EditSidePanel.js +8 -10
  46. package/es/components/FilterPanel/FilterPanel.d.ts +5 -0
  47. package/es/components/FilterPanel/FilterPanel.js +55 -0
  48. package/es/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.d.ts +5 -0
  49. package/es/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.js +83 -0
  50. package/es/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.d.ts +5 -0
  51. package/es/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.js +94 -0
  52. package/es/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.d.ts +5 -0
  53. package/es/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.js +80 -0
  54. package/es/components/FilterPanel/FilterPanelCheckbox/index.d.ts +1 -0
  55. package/es/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.d.ts +10 -0
  56. package/es/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.js +157 -0
  57. package/es/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.d.ts +5 -0
  58. package/es/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.js +72 -0
  59. package/es/components/FilterPanel/FilterPanelLabel/FilterPanelLabel.d.ts +5 -0
  60. package/es/components/FilterPanel/FilterPanelLabel/FilterPanelLabel.js +63 -0
  61. package/es/components/FilterPanel/FilterPanelLabel/index.d.ts +1 -0
  62. package/es/components/FilterPanel/index.d.ts +7 -0
  63. package/es/components/OptionsTile/OptionsTile.d.ts +77 -3
  64. package/es/components/OptionsTile/OptionsTile.js +9 -20
  65. package/es/components/RemoveModal/RemoveModal.d.ts +81 -7
  66. package/es/components/RemoveModal/RemoveModal.js +1 -0
  67. package/es/components/ScrollGradient/ScrollGradient.d.ts +5 -0
  68. package/es/components/ScrollGradient/ScrollGradient.js +156 -0
  69. package/es/components/ScrollGradient/constants.d.ts +15 -0
  70. package/es/components/ScrollGradient/constants.js +121 -0
  71. package/es/components/ScrollGradient/index.d.ts +1 -0
  72. package/es/components/SidePanel/SidePanel.d.ts +144 -2
  73. package/es/components/SidePanel/SidePanel.js +88 -112
  74. package/es/components/StatusIcon/StatusIcon.d.ts +34 -2
  75. package/es/components/StatusIcon/StatusIcon.js +97 -95
  76. package/es/components/Tearsheet/TearsheetShell.js +9 -1
  77. package/es/components/Toolbar/ToolbarGroup.d.ts +17 -2
  78. package/es/components/Toolbar/ToolbarGroup.js +0 -1
  79. package/es/components/TruncatedList/TruncatedList.js +5 -3
  80. package/es/components/UserAvatar/UserAvatar.js +3 -2
  81. package/es/components/index.d.ts +4 -1
  82. package/es/global/js/hooks/useFocus.js +9 -2
  83. package/es/global/js/package-settings.d.ts +12 -0
  84. package/es/global/js/package-settings.js +12 -0
  85. package/es/index.js +12 -0
  86. package/es/settings.d.ts +12 -0
  87. package/lib/components/ActionBar/ActionBar.js +11 -6
  88. package/lib/components/CreateSidePanel/CreateSidePanel.d.ts +81 -2
  89. package/lib/components/CreateSidePanel/CreateSidePanel.js +5 -2
  90. package/lib/components/CreateTearsheet/CreateTearsheetDivider.d.ts +12 -1
  91. package/lib/components/CreateTearsheet/CreateTearsheetDivider.js +1 -1
  92. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +39 -145
  93. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +60 -112
  94. package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.d.ts +3 -1
  95. package/lib/components/DataSpreadsheet/hooks/useMoveActiveCell.js +9 -2
  96. package/lib/components/DataSpreadsheet/utils/commonEventHandlers.d.ts +4 -0
  97. package/lib/components/DataSpreadsheet/utils/commonEventHandlers.js +311 -0
  98. package/lib/components/Datagrid/Datagrid/DatagridContent.js +2 -1
  99. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +4 -1
  100. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  101. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  102. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +5 -1
  103. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.d.ts +1 -1
  104. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +4 -0
  105. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.d.ts +2 -1
  106. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +4 -3
  107. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +5 -5
  108. package/lib/components/Datagrid/useRowSize.js +4 -2
  109. package/lib/components/DescriptionList/DescriptionList.d.ts +0 -37
  110. package/lib/components/DescriptionList/DescriptionList.js +6 -11
  111. package/lib/components/DescriptionList/DescriptionListBody.d.ts +2 -0
  112. package/lib/components/DescriptionList/DescriptionListBody.js +46 -0
  113. package/lib/components/DescriptionList/DescriptionListCell.d.ts +2 -0
  114. package/lib/components/DescriptionList/DescriptionListCell.js +46 -0
  115. package/lib/components/DescriptionList/DescriptionListRow.d.ts +2 -0
  116. package/lib/components/DescriptionList/DescriptionListRow.js +48 -0
  117. package/lib/components/DescriptionList/index.d.ts +4 -1
  118. package/lib/components/EditSidePanel/EditSidePanel.d.ts +92 -2
  119. package/lib/components/EditSidePanel/EditSidePanel.js +8 -10
  120. package/lib/components/FilterPanel/FilterPanel.d.ts +5 -0
  121. package/lib/components/FilterPanel/FilterPanel.js +62 -0
  122. package/lib/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.d.ts +5 -0
  123. package/lib/components/FilterPanel/FilterPanelAccordion/FilterPanelAccordion.js +90 -0
  124. package/lib/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.d.ts +5 -0
  125. package/lib/components/FilterPanel/FilterPanelAccordionItem/FilterPanelAccordionItem.js +101 -0
  126. package/lib/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.d.ts +5 -0
  127. package/lib/components/FilterPanel/FilterPanelCheckbox/FilterPanelCheckbox.js +87 -0
  128. package/lib/components/FilterPanel/FilterPanelCheckbox/index.d.ts +1 -0
  129. package/lib/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.d.ts +10 -0
  130. package/lib/components/FilterPanel/FilterPanelCheckboxWithOverflow/FilterPanelCheckboxWithOverflow.js +164 -0
  131. package/lib/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.d.ts +5 -0
  132. package/lib/components/FilterPanel/FilterPanelGroup/FilterPanelGroup.js +79 -0
  133. package/lib/components/FilterPanel/FilterPanelLabel/FilterPanelLabel.d.ts +5 -0
  134. package/lib/components/FilterPanel/FilterPanelLabel/FilterPanelLabel.js +70 -0
  135. package/lib/components/FilterPanel/FilterPanelLabel/index.d.ts +1 -0
  136. package/lib/components/FilterPanel/index.d.ts +7 -0
  137. package/lib/components/OptionsTile/OptionsTile.d.ts +77 -3
  138. package/lib/components/OptionsTile/OptionsTile.js +9 -20
  139. package/lib/components/RemoveModal/RemoveModal.d.ts +81 -7
  140. package/lib/components/RemoveModal/RemoveModal.js +1 -0
  141. package/lib/components/ScrollGradient/ScrollGradient.d.ts +5 -0
  142. package/lib/components/ScrollGradient/ScrollGradient.js +163 -0
  143. package/lib/components/ScrollGradient/constants.d.ts +15 -0
  144. package/lib/components/ScrollGradient/constants.js +128 -0
  145. package/lib/components/ScrollGradient/index.d.ts +1 -0
  146. package/lib/components/SidePanel/SidePanel.d.ts +144 -2
  147. package/lib/components/SidePanel/SidePanel.js +88 -112
  148. package/lib/components/StatusIcon/StatusIcon.d.ts +34 -2
  149. package/lib/components/StatusIcon/StatusIcon.js +97 -95
  150. package/lib/components/Tearsheet/TearsheetShell.js +9 -1
  151. package/lib/components/Toolbar/ToolbarGroup.d.ts +17 -2
  152. package/lib/components/Toolbar/ToolbarGroup.js +0 -1
  153. package/lib/components/TruncatedList/TruncatedList.js +5 -3
  154. package/lib/components/UserAvatar/UserAvatar.js +3 -2
  155. package/lib/components/index.d.ts +4 -1
  156. package/lib/global/js/hooks/useFocus.js +9 -2
  157. package/lib/global/js/package-settings.d.ts +12 -0
  158. package/lib/global/js/package-settings.js +12 -0
  159. package/lib/index.js +60 -0
  160. package/lib/settings.d.ts +12 -0
  161. package/package.json +3 -3
  162. package/scss/components/FilterPanel/_carbon-imports.scss +9 -0
  163. package/scss/components/FilterPanel/_filter-panel-accordion-item.scss +56 -0
  164. package/scss/components/FilterPanel/_filter-panel-accordion.scss +6 -0
  165. package/scss/components/FilterPanel/_filter-panel-checkbox-with-overflow.scss +62 -0
  166. package/scss/components/FilterPanel/_filter-panel-checkbox.scss +54 -0
  167. package/scss/components/FilterPanel/_filter-panel-group.scss +39 -0
  168. package/scss/components/FilterPanel/_filter-panel-label.scss +39 -0
  169. package/scss/components/FilterPanel/_filter-panel.scss +31 -0
  170. package/scss/components/FilterPanel/_index-with-carbon.scss +15 -0
  171. package/scss/components/FilterPanel/_index.scss +14 -0
  172. package/scss/components/ScrollGradient/_carbon-imports.scss +9 -0
  173. package/scss/components/ScrollGradient/_index-with-carbon.scss +9 -0
  174. package/scss/components/ScrollGradient/_index.scss +8 -0
  175. package/scss/components/ScrollGradient/_scroll-gradient.scss +102 -0
  176. package/scss/components/UserAvatar/_user-avatar.scss +37 -4
  177. package/scss/components/_index-with-carbon.scss +2 -0
  178. package/scss/components/_index.scss +2 -0
@@ -34,13 +34,19 @@ var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWi
34
34
  var blockClass = "".concat(settings.pkg.prefix, "--action-bar");
35
35
  var componentName = 'ActionBar';
36
36
 
37
+ // Default values for props
38
+ var defaults = {
39
+ actions: Object.freeze([])
40
+ };
41
+
37
42
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
38
43
 
39
44
  /**
40
45
  * The ActionBar is used internally by the PageHeader to wrap ActionBarItems.
41
46
  */
42
- var ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
43
- var actions = _ref.actions,
47
+ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
48
+ var _ref$actions = _ref.actions,
49
+ actions = _ref$actions === void 0 ? defaults.actions : _ref$actions,
44
50
  className = _ref.className,
45
51
  maxVisible = _ref.maxVisible,
46
52
  menuOptionsClass = _ref.menuOptionsClass,
@@ -197,8 +203,9 @@ var ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (_ref
197
203
  className: cx__default["default"](["".concat(blockClass, "__displayed-items"), _rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__displayed-items--right"), rightAlign)])
198
204
  }, displayedItems));
199
205
  });
200
- ActionBar.displayName = componentName;
201
- ActionBar.propTypes = {
206
+ exports.ActionBar = settings.pkg.checkComponentEnabled(exports.ActionBar, componentName);
207
+ exports.ActionBar.displayName = componentName;
208
+ exports.ActionBar.propTypes = {
202
209
  /**
203
210
  * Specifies the action bar items. Each item is specified as an object
204
211
  * with required fields: key for array rendering, renderIcon, iconDescription and
@@ -252,5 +259,3 @@ ActionBar.propTypes = {
252
259
  */
253
260
  rightAlign: index["default"].bool
254
261
  };
255
-
256
- exports.ActionBar = ActionBar;
@@ -1,5 +1,84 @@
1
+ /**
2
+ * Copyright IBM Corp. 2021, 2024
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 React, { ReactNode } from 'react';
8
+ interface CreateSidePanelProps {
9
+ /**
10
+ * Provide an optional class to be applied to the containing node.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * The description of the CreateSidePanel serves to provide more information about the form within the panel.
15
+ */
16
+ description?: ReactNode;
17
+ /**
18
+ * Specifies a boolean for disabling or enabling the primary button. This is important for form validation
19
+ * Returning `true` prevents the primary button from being clicked until required fields are completed.
20
+ */
21
+ disableSubmit?: boolean;
22
+ /**
23
+ * Specifies an optional field that provides a additional context for a form
24
+ */
25
+ formDescription?: ReactNode;
26
+ /**
27
+ * Specifies a required field that provides a title for a form
28
+ */
29
+ formTitle: ReactNode;
30
+ /**
31
+ * Unique identifier
32
+ */
33
+ id?: string;
34
+ /**
35
+ * Specifies an optional handler which is called when the CreateSidePanel
36
+ * is closed.
37
+ */
38
+ onRequestClose?(): void;
39
+ /**
40
+ * Specifies an optional handler which is called when the CreateSidePanel
41
+ * primary button is pressed.
42
+ */
43
+ onRequestSubmit?(): void;
44
+ /**
45
+ * Specifies whether the CreateSidePanel is open or not.
46
+ */
47
+ open: boolean;
48
+ /**
49
+ * Specifies the primary button's text in the modal.
50
+ */
51
+ primaryButtonText: string;
52
+ /**
53
+ * Specifies the secondary button's text in the modal.
54
+ */
55
+ secondaryButtonText: string;
56
+ /**
57
+ * This is the selector to the element that contains all of the page content that will shrink when the panel is a slide in.
58
+ * This prop is required since create flows use the `slideIn` variant of the side panel.
59
+ */
60
+ selectorPageContent: string;
61
+ /**
62
+ * Specifies which DOM element in the form should be focused.
63
+ */
64
+ selectorPrimaryFocus: string;
65
+ /**
66
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `SidePanel` component
67
+ */
68
+ slug?: ReactNode;
69
+ /**
70
+ * The subtitle of the CreateSidePanel is optional and serves to provide more information about the modal.
71
+ */
72
+ subtitle?: ReactNode;
73
+ /**
74
+ * The title of the CreateSidePanel is usually the product or service name.
75
+ */
76
+ title: string;
77
+ }
1
78
  /**
2
79
  * Use with medium complexity creations if the user needs page context. On-page content can be seen and interacted with.
3
80
  */
4
- export let CreateSidePanel: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
81
+ export declare let CreateSidePanel: React.ForwardRefExoticComponent<CreateSidePanelProps & {
82
+ children?: React.ReactNode;
83
+ } & React.RefAttributes<HTMLDivElement>>;
84
+ export {};
@@ -56,7 +56,7 @@ exports.CreateSidePanel = /*#__PURE__*/React__default["default"].forwardRef(func
56
56
  label: primaryButtonText,
57
57
  onClick: function onClick(event) {
58
58
  event.preventDefault();
59
- onRequestSubmit();
59
+ onRequestSubmit === null || onRequestSubmit === void 0 || onRequestSubmit();
60
60
  },
61
61
  kind: 'primary',
62
62
  disabled: disableSubmit,
@@ -99,6 +99,7 @@ exports.CreateSidePanel.propTypes = {
99
99
  /**
100
100
  * Sets the body content of the create side panel
101
101
  */
102
+ /**@ts-ignore*/
102
103
  children: index["default"].oneOfType([index["default"].arrayOf(index["default"].node), index["default"].node]).isRequired,
103
104
  /**
104
105
  * Provide an optional class to be applied to the containing node.
@@ -138,6 +139,7 @@ exports.CreateSidePanel.propTypes = {
138
139
  /**
139
140
  * Specifies whether the CreateSidePanel is open or not.
140
141
  */
142
+ /**@ts-ignore*/
141
143
  open: index["default"].bool,
142
144
  /**
143
145
  * Specifies the primary button's text in the modal.
@@ -155,6 +157,7 @@ exports.CreateSidePanel.propTypes = {
155
157
  /**
156
158
  * Specifies which DOM element in the form should be focused.
157
159
  */
160
+ /**@ts-ignore*/
158
161
  selectorPrimaryFocus: index["default"].node.isRequired,
159
162
  /**
160
163
  * **Experimental:** Provide a `Slug` component to be rendered inside the `SidePanel` component
@@ -167,5 +170,5 @@ exports.CreateSidePanel.propTypes = {
167
170
  /**
168
171
  * The title of the CreateSidePanel is usually the product or service name.
169
172
  */
170
- title: index["default"].node.isRequired
173
+ title: index["default"].string.isRequired
171
174
  };
@@ -1,2 +1,13 @@
1
- export let CreateTearsheetDivider: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
1
+ /**
2
+ * Copyright IBM Corp. 2021, 2024
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
+ */
2
7
  import React from 'react';
8
+ interface CreateTearsheetDividerProps {
9
+ /** Specifies an optional className to be added to the tearsheet divider */
10
+ className?: string;
11
+ }
12
+ export declare let CreateTearsheetDivider: React.FC<CreateTearsheetDividerProps>;
13
+ export {};
@@ -36,7 +36,7 @@ exports.CreateTearsheetDivider = /*#__PURE__*/React.forwardRef(function (_ref, r
36
36
  exports.CreateTearsheetDivider = settings.pkg.checkComponentEnabled(exports.CreateTearsheetDivider, componentName);
37
37
  exports.CreateTearsheetDivider.propTypes = {
38
38
  /**
39
- * Sets an optional className to be added to the tearsheet step
39
+ * Sets an optional className to be added to the tearsheet divider
40
40
  */
41
41
  className: index["default"].string
42
42
  };
@@ -23,14 +23,11 @@ var uuidv4 = require('../../global/js/utils/uuidv4.js');
23
23
  var deepCloneObject = require('../../global/js/utils/deepCloneObject.js');
24
24
  var createActiveCellFn = require('./utils/createActiveCellFn.js');
25
25
  var getCellSize = require('./utils/getCellSize.js');
26
- var handleMultipleKeys = require('./utils/handleMultipleKeys.js');
27
26
  var handleHeaderCellSelection = require('./utils/handleHeaderCellSelection.js');
28
27
  var removeCellSelections = require('./utils/removeCellSelections.js');
29
28
  var selectAllCells = require('./utils/selectAllCells.js');
30
29
  var handleEditSubmit = require('./utils/handleEditSubmit.js');
31
- var handleActiveCellInSelectionEnter = require('./utils/handleActiveCellInSelectionEnter.js');
32
- var handleActiveCellInSelectionTab = require('./utils/handleActiveCellInSelectionTab.js');
33
- var handleCellDeletion = require('./utils/handleCellDeletion.js');
30
+ var commonEventHandlers = require('./utils/commonEventHandlers.js');
34
31
  var useActiveElement = require('../../global/js/hooks/useActiveElement.js');
35
32
  var usePreviousValue = require('../../global/js/hooks/usePreviousValue.js');
36
33
  var useMultipleKeyTracking = require('./hooks/useMultipleKeyTracking.js');
@@ -45,7 +42,6 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
45
42
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
46
43
 
47
44
  var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
48
- // cspell:words rowcount colcount
49
45
 
50
46
  // The block part of our conventional BEM class names (blockClass__E--M).
51
47
  var blockClass = "".concat(settings.pkg.prefix, "--data-spreadsheet");
@@ -128,20 +124,24 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
128
124
  _useState18 = _rollupPluginBabelHelpers.slicedToArray(_useState17, 2),
129
125
  headerCellHoldActive = _useState18[0],
130
126
  setHeaderCellHoldActive = _useState18[1];
131
- var _useState19 = React.useState(false),
127
+ var _useState19 = React.useState(null),
132
128
  _useState20 = _rollupPluginBabelHelpers.slicedToArray(_useState19, 2),
133
- activeCellInsideSelectionArea = _useState20[0],
134
- setActiveCellInsideSelectionArea = _useState20[1];
129
+ isActiveHeaderCellChanged = _useState20[0],
130
+ setIsActiveHeaderCellChanged = _useState20[1];
131
+ var _useState21 = React.useState(false),
132
+ _useState22 = _rollupPluginBabelHelpers.slicedToArray(_useState21, 2),
133
+ activeCellInsideSelectionArea = _useState22[0],
134
+ setActiveCellInsideSelectionArea = _useState22[1];
135
135
  var previousState = usePreviousValue.usePreviousValue({
136
136
  activeCellCoordinates: activeCellCoordinates,
137
137
  isEditing: isEditing
138
138
  });
139
139
  var cellSizeValue = getCellSize.getCellSize(cellSize);
140
140
  var cellEditorRef = React.useRef();
141
- var _useState21 = React.useState(),
142
- _useState22 = _rollupPluginBabelHelpers.slicedToArray(_useState21, 2),
143
- activeCellContent = _useState22[0],
144
- setActiveCellContent = _useState22[1];
141
+ var _useState23 = React.useState(),
142
+ _useState24 = _rollupPluginBabelHelpers.slicedToArray(_useState23, 2),
143
+ activeCellContent = _useState24[0],
144
+ setActiveCellContent = _useState24[1];
145
145
  var activeCellRef = React.useRef();
146
146
  var cellEditorRulerRef = React.useRef();
147
147
  var defaultColumn = React.useMemo(function () {
@@ -215,6 +215,9 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
215
215
  }
216
216
  if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
217
217
  setActiveCellContent(null);
218
+ setIsActiveHeaderCellChanged(function (prev) {
219
+ return !prev;
220
+ });
218
221
  }
219
222
  }
220
223
  }, [activeCellCoordinates, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, updateData, rows, isEditing, removeCellEditor, activeCellContent]);
@@ -225,23 +228,19 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
225
228
  addToHeader = _ref2$addToHeader === void 0 ? false : _ref2$addToHeader;
226
229
  var activeCellFullData = typeof (coords === null || coords === void 0 ? void 0 : coords.column) === 'number' && typeof (coords === null || coords === void 0 ? void 0 : coords.row) === 'number' ? rows[coords === null || coords === void 0 ? void 0 : coords.row].cells[coords === null || coords === void 0 ? void 0 : coords.column] : null;
227
230
  var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[coords === null || coords === void 0 ? void 0 : coords.column] : null;
228
- var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
229
- // Only create an active cell if the activeCellCoordinates have changed
230
- if ((prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.row) !== (coords === null || coords === void 0 ? void 0 : coords.row) || (prevCoords === null || prevCoords === void 0 ? void 0 : prevCoords.column) !== (coords === null || coords === void 0 ? void 0 : coords.column)) {
231
- createActiveCellFn.createActiveCellFn({
232
- placementElement: placementElement,
233
- coords: coords,
234
- addToHeader: addToHeader,
235
- contextRef: spreadsheetRef,
236
- blockClass: blockClass,
237
- onActiveCellChange: onActiveCellChange,
238
- activeCellValue: activeCellValue,
239
- activeCellRef: activeCellRef,
240
- cellEditorRef: cellEditorRef,
241
- defaultColumn: defaultColumn
242
- });
243
- }
244
- }, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
231
+ createActiveCellFn.createActiveCellFn({
232
+ placementElement: placementElement,
233
+ coords: coords,
234
+ addToHeader: addToHeader,
235
+ contextRef: spreadsheetRef,
236
+ blockClass: blockClass,
237
+ onActiveCellChange: onActiveCellChange,
238
+ activeCellValue: activeCellValue,
239
+ activeCellRef: activeCellRef,
240
+ cellEditorRef: cellEditorRef,
241
+ defaultColumn: defaultColumn
242
+ });
243
+ }, [spreadsheetRef, rows, onActiveCellChange, defaultColumn]);
245
244
  useResetSpreadsheetFocus.useResetSpreadsheetFocus({
246
245
  focusedElement: focusedElement,
247
246
  removeActiveCell: removeActiveCell,
@@ -260,7 +259,9 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
260
259
  spreadsheetRef: spreadsheetRef,
261
260
  activeCellCoordinates: activeCellCoordinates,
262
261
  containerHasFocus: containerHasFocus,
263
- createActiveCell: createActiveCell
262
+ createActiveCell: createActiveCell,
263
+ activeCellContent: activeCellContent,
264
+ isActiveHeaderCellChanged: isActiveHeaderCellChanged
264
265
  });
265
266
  var handleInitialArrowPress = React.useCallback(function () {
266
267
  // If activeCellCoordinates is null then we need to set an initial value
@@ -308,10 +309,10 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
308
309
  spreadsheetRef: spreadsheetRef
309
310
  });
310
311
  }, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
311
- var checkforReturnConditon = React.useCallback(function (key) {
312
+ var checkForReturnCondition = React.useCallback(function (key) {
312
313
  return isEditing || key === 'Meta' || key === 'Control';
313
314
  }, [isEditing]);
314
- var handleArrowkeyPress = React.useCallback(function (arrowKey) {
315
+ var handleArrowKeyPress = React.useCallback(function (arrowKey) {
315
316
  event.preventDefault();
316
317
  handleInitialArrowPress();
317
318
  var coordinatesClone = _rollupPluginBabelHelpers.objectSpread2({}, activeCellCoordinates);
@@ -408,118 +409,9 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
408
409
  });
409
410
  }
410
411
  }, [handleInitialArrowPress, updateActiveCellCoordinates, activeCellCoordinates, columns, rows]);
411
- var handleKeyPress = React.useCallback(function (event) {
412
- var key = event.key;
413
- // Command keys need to be returned as there is default browser behavior with these keys
414
- // Needs to be returned in editing mode
415
- if (checkforReturnConditon(key)) {
416
- return;
417
- }
418
-
419
- // Clear out all cell selection areas if user uses any arrow key, except if the shift key is being held
420
- if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
421
- if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !handleMultipleKeys.includesShift(keysPressedList)) {
422
- setSelectionAreas([]);
423
- setSelectionAreaData([]);
424
- removeCellSelections.removeCellSelections({
425
- spreadsheetRef: spreadsheetRef
426
- });
427
- }
428
- }
429
- if ((keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
430
- handleMultipleKeys.handleMultipleKeys({
431
- activeCellCoordinates: activeCellCoordinates,
432
- event: event,
433
- keysPressedList: keysPressedList,
434
- selectionAreas: selectionAreas,
435
- currentMatcher: currentMatcher,
436
- rows: rows,
437
- setSelectionAreas: setSelectionAreas,
438
- columns: columns,
439
- updateActiveCellCoordinates: updateActiveCellCoordinates,
440
- spreadsheetRef: spreadsheetRef,
441
- removeCellSelections: removeCellSelections.removeCellSelections,
442
- blockClass: blockClass,
443
- setCurrentMatcher: setCurrentMatcher,
444
- usingMac: usingMac
445
- });
446
- }
447
-
448
- // Allow arrow key navigation if there are less than two activeKeys OR
449
- // if one of the activeCellCoordinates is in a header position
450
- // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
451
-
452
- if (keysPressedList.length < 2 && !handleMultipleKeys.includesShift(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
453
- switch (key) {
454
- case 'Backspace':
455
- case 'Delete':
456
- {
457
- var deleteParams = {
458
- selectionAreas: selectionAreas,
459
- currentMatcher: currentMatcher,
460
- rows: rows,
461
- setActiveCellContent: setActiveCellContent,
462
- updateData: updateData,
463
- activeCellCoordinates: activeCellCoordinates
464
- };
465
- handleCellDeletion.handleCellDeletion(deleteParams);
466
- break;
467
- }
468
- // Enter
469
- case 'Enter':
470
- {
471
- handleActiveCellInSelectionEnter.handleActiveCellInSelectionEnter({
472
- activeCellInsideSelectionArea: activeCellInsideSelectionArea,
473
- activeCellCoordinates: activeCellCoordinates,
474
- activeCellRef: activeCellRef,
475
- selectionAreas: selectionAreas,
476
- updateActiveCellCoordinates: updateActiveCellCoordinates
477
- });
478
- break;
479
- }
480
- // HOME
481
- case 'Home':
482
- case 'End':
483
- {
484
- event.preventDefault();
485
- if (handleMultipleKeys.includesResourceKey(keysPressedList, usingMac)) {
486
- return;
487
- }
488
- handleHomeEndKey({
489
- type: key
490
- });
491
- break;
492
- }
493
- // Tab
494
- case 'Tab':
495
- {
496
- if (activeCellInsideSelectionArea) {
497
- event.preventDefault();
498
- return handleActiveCellInSelectionTab.handleActiveCellInSelectionTab({
499
- activeCellInsideSelectionArea: activeCellInsideSelectionArea,
500
- activeCellCoordinates: activeCellCoordinates,
501
- activeCellRef: activeCellRef,
502
- selectionAreas: selectionAreas,
503
- updateActiveCellCoordinates: updateActiveCellCoordinates
504
- });
505
- }
506
- setSelectionAreas([]);
507
- removeActiveCell();
508
- removeCellEditor();
509
- setContainerHasFocus(false);
510
- setActiveCellCoordinates(null);
511
- break;
512
- }
513
- case 'ArrowLeft':
514
- case 'ArrowUp':
515
- case 'ArrowRight':
516
- case 'ArrowDown':
517
- {
518
- handleArrowkeyPress(key);
519
- }
520
- }
521
- }
522
- }, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkforReturnConditon, handleArrowkeyPress]);
412
+ var handleKeyPressEvent = React.useCallback(function (event) {
413
+ commonEventHandlers.handleKeyPress(event, activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress, setSelectionAreas, setSelectionAreaData, setCurrentMatcher, activeCellRef, setActiveCellCoordinates, setContainerHasFocus, setActiveCellContent);
414
+ }, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress]);
523
415
  var startEditMode = function startEditMode() {
524
416
  setIsEditing(true);
525
417
  setClickAndHoldActive(false);
@@ -682,6 +574,7 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
682
574
  var handleActiveCellMouseEnter = React.useCallback(function () {
683
575
  handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
684
576
  }, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
577
+ // cspell:words rowcount colcount
685
578
  return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, getTableProps(), devtools.getDevtoolsProps(componentName), {
686
579
  className: cx__default["default"](blockClass, className, "".concat(blockClass, "--interactive-cell-element"), _rollupPluginBabelHelpers.defineProperty(_rollupPluginBabelHelpers.defineProperty({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus), "".concat(blockClass, "__").concat(theme), theme === 'dark')),
687
580
  ref: spreadsheetRef,
@@ -690,7 +583,7 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
690
583
  "aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
691
584
  "aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
692
585
  "aria-label": spreadsheetAriaLabel,
693
- onKeyDown: handleKeyPress,
586
+ onKeyDown: handleKeyPressEvent,
694
587
  onFocus: function onFocus() {
695
588
  return setContainerHasFocus(true);
696
589
  }
@@ -718,6 +611,7 @@ exports.DataSpreadsheet = /*#__PURE__*/React__default["default"].forwardRef(func
718
611
  visibleColumns: visibleColumns,
719
612
  selectAllAriaLabel: selectAllAriaLabel
720
613
  }), /*#__PURE__*/React__default["default"].createElement(DataSpreadsheetBody.DataSpreadsheetBody, {
614
+ activeCellRef: activeCellRef,
721
615
  activeCellCoordinates: activeCellCoordinates,
722
616
  ref: spreadsheetRef,
723
617
  clickAndHoldActive: clickAndHoldActive,