@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
@@ -25,13 +25,19 @@ var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWi
25
25
  var blockClass = "".concat(pkg.prefix, "--action-bar");
26
26
  var componentName = 'ActionBar';
27
27
 
28
+ // Default values for props
29
+ var defaults = {
30
+ actions: Object.freeze([])
31
+ };
32
+
28
33
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
29
34
 
30
35
  /**
31
36
  * The ActionBar is used internally by the PageHeader to wrap ActionBarItems.
32
37
  */
33
38
  var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
34
- var actions = _ref.actions,
39
+ var _ref$actions = _ref.actions,
40
+ actions = _ref$actions === void 0 ? defaults.actions : _ref$actions,
35
41
  className = _ref.className,
36
42
  maxVisible = _ref.maxVisible,
37
43
  menuOptionsClass = _ref.menuOptionsClass,
@@ -188,6 +194,7 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
188
194
  className: cx(["".concat(blockClass, "__displayed-items"), _defineProperty({}, "".concat(blockClass, "__displayed-items--right"), rightAlign)])
189
195
  }, displayedItems));
190
196
  });
197
+ ActionBar = pkg.checkComponentEnabled(ActionBar, componentName);
191
198
  ActionBar.displayName = componentName;
192
199
  ActionBar.propTypes = {
193
200
  /**
@@ -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 {};
@@ -47,7 +47,7 @@ var CreateSidePanel = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
47
47
  label: primaryButtonText,
48
48
  onClick: function onClick(event) {
49
49
  event.preventDefault();
50
- onRequestSubmit();
50
+ onRequestSubmit === null || onRequestSubmit === void 0 || onRequestSubmit();
51
51
  },
52
52
  kind: 'primary',
53
53
  disabled: disableSubmit,
@@ -90,6 +90,7 @@ CreateSidePanel.propTypes = {
90
90
  /**
91
91
  * Sets the body content of the create side panel
92
92
  */
93
+ /**@ts-ignore*/
93
94
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
94
95
  /**
95
96
  * Provide an optional class to be applied to the containing node.
@@ -129,6 +130,7 @@ CreateSidePanel.propTypes = {
129
130
  /**
130
131
  * Specifies whether the CreateSidePanel is open or not.
131
132
  */
133
+ /**@ts-ignore*/
132
134
  open: PropTypes.bool,
133
135
  /**
134
136
  * Specifies the primary button's text in the modal.
@@ -146,6 +148,7 @@ CreateSidePanel.propTypes = {
146
148
  /**
147
149
  * Specifies which DOM element in the form should be focused.
148
150
  */
151
+ /**@ts-ignore*/
149
152
  selectorPrimaryFocus: PropTypes.node.isRequired,
150
153
  /**
151
154
  * **Experimental:** Provide a `Slug` component to be rendered inside the `SidePanel` component
@@ -158,7 +161,7 @@ CreateSidePanel.propTypes = {
158
161
  /**
159
162
  * The title of the CreateSidePanel is usually the product or service name.
160
163
  */
161
- title: PropTypes.node.isRequired
164
+ title: PropTypes.string.isRequired
162
165
  };
163
166
 
164
167
  export { CreateSidePanel };
@@ -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 {};
@@ -27,7 +27,7 @@ var CreateTearsheetDivider = /*#__PURE__*/forwardRef(function (_ref, ref) {
27
27
  CreateTearsheetDivider = pkg.checkComponentEnabled(CreateTearsheetDivider, componentName);
28
28
  CreateTearsheetDivider.propTypes = {
29
29
  /**
30
- * Sets an optional className to be added to the tearsheet step
30
+ * Sets an optional className to be added to the tearsheet divider
31
31
  */
32
32
  className: PropTypes.string
33
33
  };
@@ -19,14 +19,11 @@ import uuidv4 from '../../global/js/utils/uuidv4.js';
19
19
  import { deepCloneObject } from '../../global/js/utils/deepCloneObject.js';
20
20
  import { createActiveCellFn } from './utils/createActiveCellFn.js';
21
21
  import { getCellSize } from './utils/getCellSize.js';
22
- import { includesShift, handleMultipleKeys, includesResourceKey } from './utils/handleMultipleKeys.js';
23
22
  import { handleHeaderCellSelection } from './utils/handleHeaderCellSelection.js';
24
23
  import { removeCellSelections } from './utils/removeCellSelections.js';
25
24
  import { selectAllCells } from './utils/selectAllCells.js';
26
25
  import { handleEditSubmit } from './utils/handleEditSubmit.js';
27
- import { handleActiveCellInSelectionEnter } from './utils/handleActiveCellInSelectionEnter.js';
28
- import { handleActiveCellInSelectionTab } from './utils/handleActiveCellInSelectionTab.js';
29
- import { handleCellDeletion } from './utils/handleCellDeletion.js';
26
+ import { handleKeyPress } from './utils/commonEventHandlers.js';
30
27
  import { useActiveElement } from '../../global/js/hooks/useActiveElement.js';
31
28
  import { usePreviousValue } from '../../global/js/hooks/usePreviousValue.js';
32
29
  import { useMultipleKeyTracking } from './hooks/useMultipleKeyTracking.js';
@@ -36,7 +33,6 @@ import { useMoveActiveCell } from './hooks/useMoveActiveCell.js';
36
33
  import { useSpreadsheetEdit } from './hooks/useSpreadsheetEdit.js';
37
34
 
38
35
  var _excluded = ["cellSize", "className", "columns", "data", "defaultEmptyRowCount", "onDataUpdate", "id", "onActiveCellChange", "onSelectionAreaChange", "selectAllAriaLabel", "spreadsheetAriaLabel", "theme", "totalVisibleColumns"];
39
- // cspell:words rowcount colcount
40
36
 
41
37
  // The block part of our conventional BEM class names (blockClass__E--M).
42
38
  var blockClass = "".concat(pkg.prefix, "--data-spreadsheet");
@@ -119,20 +115,24 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
119
115
  _useState18 = _slicedToArray(_useState17, 2),
120
116
  headerCellHoldActive = _useState18[0],
121
117
  setHeaderCellHoldActive = _useState18[1];
122
- var _useState19 = useState(false),
118
+ var _useState19 = useState(null),
123
119
  _useState20 = _slicedToArray(_useState19, 2),
124
- activeCellInsideSelectionArea = _useState20[0],
125
- setActiveCellInsideSelectionArea = _useState20[1];
120
+ isActiveHeaderCellChanged = _useState20[0],
121
+ setIsActiveHeaderCellChanged = _useState20[1];
122
+ var _useState21 = useState(false),
123
+ _useState22 = _slicedToArray(_useState21, 2),
124
+ activeCellInsideSelectionArea = _useState22[0],
125
+ setActiveCellInsideSelectionArea = _useState22[1];
126
126
  var previousState = usePreviousValue({
127
127
  activeCellCoordinates: activeCellCoordinates,
128
128
  isEditing: isEditing
129
129
  });
130
130
  var cellSizeValue = getCellSize(cellSize);
131
131
  var cellEditorRef = useRef();
132
- var _useState21 = useState(),
133
- _useState22 = _slicedToArray(_useState21, 2),
134
- activeCellContent = _useState22[0],
135
- setActiveCellContent = _useState22[1];
132
+ var _useState23 = useState(),
133
+ _useState24 = _slicedToArray(_useState23, 2),
134
+ activeCellContent = _useState24[0],
135
+ setActiveCellContent = _useState24[1];
136
136
  var activeCellRef = useRef();
137
137
  var cellEditorRulerRef = useRef();
138
138
  var defaultColumn = useMemo(function () {
@@ -206,6 +206,9 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
206
206
  }
207
207
  if (activeCellCoordinates && (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.row) === 'header' || (activeCellCoordinates === null || activeCellCoordinates === void 0 ? void 0 : activeCellCoordinates.column) === 'header') {
208
208
  setActiveCellContent(null);
209
+ setIsActiveHeaderCellChanged(function (prev) {
210
+ return !prev;
211
+ });
209
212
  }
210
213
  }
211
214
  }, [activeCellCoordinates, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, updateData, rows, isEditing, removeCellEditor, activeCellContent]);
@@ -216,23 +219,19 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
216
219
  addToHeader = _ref2$addToHeader === void 0 ? false : _ref2$addToHeader;
217
220
  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;
218
221
  var activeCellValue = activeCellFullData ? Object.values(activeCellFullData.row.values)[coords === null || coords === void 0 ? void 0 : coords.column] : null;
219
- var prevCoords = previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates;
220
- // Only create an active cell if the activeCellCoordinates have changed
221
- 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)) {
222
- createActiveCellFn({
223
- placementElement: placementElement,
224
- coords: coords,
225
- addToHeader: addToHeader,
226
- contextRef: spreadsheetRef,
227
- blockClass: blockClass,
228
- onActiveCellChange: onActiveCellChange,
229
- activeCellValue: activeCellValue,
230
- activeCellRef: activeCellRef,
231
- cellEditorRef: cellEditorRef,
232
- defaultColumn: defaultColumn
233
- });
234
- }
235
- }, [spreadsheetRef, rows, onActiveCellChange, previousState === null || previousState === void 0 ? void 0 : previousState.activeCellCoordinates, defaultColumn]);
222
+ createActiveCellFn({
223
+ placementElement: placementElement,
224
+ coords: coords,
225
+ addToHeader: addToHeader,
226
+ contextRef: spreadsheetRef,
227
+ blockClass: blockClass,
228
+ onActiveCellChange: onActiveCellChange,
229
+ activeCellValue: activeCellValue,
230
+ activeCellRef: activeCellRef,
231
+ cellEditorRef: cellEditorRef,
232
+ defaultColumn: defaultColumn
233
+ });
234
+ }, [spreadsheetRef, rows, onActiveCellChange, defaultColumn]);
236
235
  useResetSpreadsheetFocus({
237
236
  focusedElement: focusedElement,
238
237
  removeActiveCell: removeActiveCell,
@@ -251,7 +250,9 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
251
250
  spreadsheetRef: spreadsheetRef,
252
251
  activeCellCoordinates: activeCellCoordinates,
253
252
  containerHasFocus: containerHasFocus,
254
- createActiveCell: createActiveCell
253
+ createActiveCell: createActiveCell,
254
+ activeCellContent: activeCellContent,
255
+ isActiveHeaderCellChanged: isActiveHeaderCellChanged
255
256
  });
256
257
  var handleInitialArrowPress = useCallback(function () {
257
258
  // If activeCellCoordinates is null then we need to set an initial value
@@ -299,10 +300,10 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
299
300
  spreadsheetRef: spreadsheetRef
300
301
  });
301
302
  }, [activeCellCoordinates, updateActiveCellCoordinates, spreadsheetRef, columns.length]);
302
- var checkforReturnConditon = useCallback(function (key) {
303
+ var checkForReturnCondition = useCallback(function (key) {
303
304
  return isEditing || key === 'Meta' || key === 'Control';
304
305
  }, [isEditing]);
305
- var handleArrowkeyPress = useCallback(function (arrowKey) {
306
+ var handleArrowKeyPress = useCallback(function (arrowKey) {
306
307
  event.preventDefault();
307
308
  handleInitialArrowPress();
308
309
  var coordinatesClone = _objectSpread2({}, activeCellCoordinates);
@@ -399,118 +400,9 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
399
400
  });
400
401
  }
401
402
  }, [handleInitialArrowPress, updateActiveCellCoordinates, activeCellCoordinates, columns, rows]);
402
- var handleKeyPress = useCallback(function (event) {
403
- var key = event.key;
404
- // Command keys need to be returned as there is default browser behavior with these keys
405
- // Needs to be returned in editing mode
406
- if (checkforReturnConditon(key)) {
407
- return;
408
- }
409
-
410
- // Clear out all cell selection areas if user uses any arrow key, except if the shift key is being held
411
- if (['ArrowLeft', 'ArrowUp', 'ArrowRight', 'ArrowDown'].indexOf(key) > -1) {
412
- if (selectionAreas !== null && selectionAreas !== void 0 && selectionAreas.length && keysPressedList.length < 2 && !includesShift(keysPressedList)) {
413
- setSelectionAreas([]);
414
- setSelectionAreaData([]);
415
- removeCellSelections({
416
- spreadsheetRef: spreadsheetRef
417
- });
418
- }
419
- }
420
- if ((keysPressedList === null || keysPressedList === void 0 ? void 0 : keysPressedList.length) > 1) {
421
- handleMultipleKeys({
422
- activeCellCoordinates: activeCellCoordinates,
423
- event: event,
424
- keysPressedList: keysPressedList,
425
- selectionAreas: selectionAreas,
426
- currentMatcher: currentMatcher,
427
- rows: rows,
428
- setSelectionAreas: setSelectionAreas,
429
- columns: columns,
430
- updateActiveCellCoordinates: updateActiveCellCoordinates,
431
- spreadsheetRef: spreadsheetRef,
432
- removeCellSelections: removeCellSelections,
433
- blockClass: blockClass,
434
- setCurrentMatcher: setCurrentMatcher,
435
- usingMac: usingMac
436
- });
437
- }
438
-
439
- // Allow arrow key navigation if there are less than two activeKeys OR
440
- // if one of the activeCellCoordinates is in a header position
441
- // Prevent arrow keys, home key, and end key from scrolling the page when the data spreadsheet container has focus
442
-
443
- if (keysPressedList.length < 2 && !includesShift(keysPressedList) || activeCellCoordinates.row === 'header' || activeCellCoordinates.column === 'header') {
444
- switch (key) {
445
- case 'Backspace':
446
- case 'Delete':
447
- {
448
- var deleteParams = {
449
- selectionAreas: selectionAreas,
450
- currentMatcher: currentMatcher,
451
- rows: rows,
452
- setActiveCellContent: setActiveCellContent,
453
- updateData: updateData,
454
- activeCellCoordinates: activeCellCoordinates
455
- };
456
- handleCellDeletion(deleteParams);
457
- break;
458
- }
459
- // Enter
460
- case 'Enter':
461
- {
462
- handleActiveCellInSelectionEnter({
463
- activeCellInsideSelectionArea: activeCellInsideSelectionArea,
464
- activeCellCoordinates: activeCellCoordinates,
465
- activeCellRef: activeCellRef,
466
- selectionAreas: selectionAreas,
467
- updateActiveCellCoordinates: updateActiveCellCoordinates
468
- });
469
- break;
470
- }
471
- // HOME
472
- case 'Home':
473
- case 'End':
474
- {
475
- event.preventDefault();
476
- if (includesResourceKey(keysPressedList, usingMac)) {
477
- return;
478
- }
479
- handleHomeEndKey({
480
- type: key
481
- });
482
- break;
483
- }
484
- // Tab
485
- case 'Tab':
486
- {
487
- if (activeCellInsideSelectionArea) {
488
- event.preventDefault();
489
- return handleActiveCellInSelectionTab({
490
- activeCellInsideSelectionArea: activeCellInsideSelectionArea,
491
- activeCellCoordinates: activeCellCoordinates,
492
- activeCellRef: activeCellRef,
493
- selectionAreas: selectionAreas,
494
- updateActiveCellCoordinates: updateActiveCellCoordinates
495
- });
496
- }
497
- setSelectionAreas([]);
498
- removeActiveCell();
499
- removeCellEditor();
500
- setContainerHasFocus(false);
501
- setActiveCellCoordinates(null);
502
- break;
503
- }
504
- case 'ArrowLeft':
505
- case 'ArrowUp':
506
- case 'ArrowRight':
507
- case 'ArrowDown':
508
- {
509
- handleArrowkeyPress(key);
510
- }
511
- }
512
- }
513
- }, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkforReturnConditon, handleArrowkeyPress]);
403
+ var handleKeyPressEvent = useCallback(function (event) {
404
+ 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);
405
+ }, [activeCellInsideSelectionArea, updateActiveCellCoordinates, activeCellCoordinates, removeActiveCell, columns, rows, spreadsheetRef, currentMatcher, removeCellEditor, selectionAreas, handleHomeEndKey, keysPressedList, usingMac, updateData, checkForReturnCondition, handleArrowKeyPress]);
514
406
  var startEditMode = function startEditMode() {
515
407
  setIsEditing(true);
516
408
  setClickAndHoldActive(false);
@@ -673,6 +565,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
673
565
  var handleActiveCellMouseEnter = useCallback(function () {
674
566
  handleActiveCellMouseEnterCallback(selectionAreas, clickAndHoldActive);
675
567
  }, [clickAndHoldActive, selectionAreas, handleActiveCellMouseEnterCallback]);
568
+ // cspell:words rowcount colcount
676
569
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, getTableProps(), getDevtoolsProps(componentName), {
677
570
  className: cx(blockClass, className, "".concat(blockClass, "--interactive-cell-element"), _defineProperty(_defineProperty({}, "".concat(blockClass, "__container-has-focus"), containerHasFocus), "".concat(blockClass, "__").concat(theme), theme === 'dark')),
678
571
  ref: spreadsheetRef,
@@ -681,7 +574,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
681
574
  "aria-rowcount": (rows === null || rows === void 0 ? void 0 : rows.length) || 0,
682
575
  "aria-colcount": (columns === null || columns === void 0 ? void 0 : columns.length) || 0,
683
576
  "aria-label": spreadsheetAriaLabel,
684
- onKeyDown: handleKeyPress,
577
+ onKeyDown: handleKeyPressEvent,
685
578
  onFocus: function onFocus() {
686
579
  return setContainerHasFocus(true);
687
580
  }
@@ -709,6 +602,7 @@ var DataSpreadsheet = /*#__PURE__*/React__default.forwardRef(function (_ref, ref
709
602
  visibleColumns: visibleColumns,
710
603
  selectAllAriaLabel: selectAllAriaLabel
711
604
  }), /*#__PURE__*/React__default.createElement(DataSpreadsheetBody, {
605
+ activeCellRef: activeCellRef,
712
606
  activeCellCoordinates: activeCellCoordinates,
713
607
  ref: spreadsheetRef,
714
608
  clickAndHoldActive: clickAndHoldActive,