@carbon/react 1.70.0-rc.0 → 1.71.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +756 -756
  2. package/es/components/AILabel/index.js +15 -15
  3. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  4. package/es/components/CodeSnippet/CodeSnippet.d.ts +5 -2
  5. package/es/components/CodeSnippet/CodeSnippet.js +40 -1
  6. package/es/components/ComboBox/ComboBox.js +28 -23
  7. package/es/components/ComboButton/index.js +40 -1
  8. package/es/components/ComposedModal/ComposedModal.js +6 -2
  9. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +2 -2
  10. package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
  11. package/es/components/Copy/Copy.d.ts +5 -2
  12. package/es/components/Copy/Copy.js +40 -1
  13. package/es/components/CopyButton/CopyButton.d.ts +5 -2
  14. package/es/components/CopyButton/CopyButton.js +40 -1
  15. package/es/components/DataTable/Table.d.ts +9 -1
  16. package/es/components/DataTable/Table.js +7 -2
  17. package/es/components/DataTable/TableSelectRow.js +14 -6
  18. package/es/components/DataTable/TableToolbarSearch.js +1 -1
  19. package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +1 -1
  20. package/es/components/DatePicker/DatePicker.js +0 -8
  21. package/es/components/DatePicker/plugins/appendToPlugin.js +2 -2
  22. package/es/components/DatePicker/plugins/fixEventsPlugin.js +4 -4
  23. package/es/components/DatePicker/plugins/rangePlugin.js +2 -2
  24. package/es/components/DatePickerInput/DatePickerInput.d.ts +6 -1
  25. package/es/components/DatePickerInput/DatePickerInput.js +16 -10
  26. package/es/components/Dropdown/Dropdown.d.ts +5 -0
  27. package/es/components/Dropdown/Dropdown.js +132 -92
  28. package/es/components/FeatureFlags/index.js +1 -2
  29. package/es/components/IconButton/index.d.ts +4 -1
  30. package/es/components/IconButton/index.js +40 -1
  31. package/es/components/InlineCheckbox/InlineCheckbox.d.ts +50 -0
  32. package/es/components/InlineCheckbox/InlineCheckbox.js +3 -6
  33. package/es/components/InlineCheckbox/index.d.ts +9 -0
  34. package/es/components/LayoutDirection/LayoutDirection.d.ts +44 -0
  35. package/es/components/LayoutDirection/LayoutDirectionContext.d.ts +10 -0
  36. package/es/components/LayoutDirection/useLayoutDirection.d.ts +12 -0
  37. package/es/components/Menu/MenuItem.js +0 -3
  38. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  39. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -2
  40. package/es/components/MultiSelect/MultiSelect.js +1 -1
  41. package/es/components/Notification/Notification.d.ts +9 -2
  42. package/es/components/Notification/Notification.js +16 -2
  43. package/es/components/NumberInput/NumberInput.d.ts +5 -0
  44. package/es/components/NumberInput/NumberInput.js +17 -9
  45. package/es/components/OverflowMenu/OverflowMenu.js +1 -1
  46. package/es/components/OverflowMenu/next/index.js +40 -1
  47. package/es/components/Pagination/Pagination.js +2 -2
  48. package/es/components/Pagination/experimental/PageSelector.js +1 -1
  49. package/es/components/PaginationNav/PaginationNav.d.ts +1 -1
  50. package/es/components/PaginationNav/PaginationNav.js +10 -5
  51. package/es/components/Popover/index.js +2 -2
  52. package/es/components/SkeletonText/SkeletonText.js +1 -1
  53. package/es/components/Tabs/Tabs.js +46 -29
  54. package/es/components/TextArea/TextArea.d.ts +5 -0
  55. package/es/components/TextArea/TextArea.js +15 -7
  56. package/es/components/TextInput/TextInput.d.ts +5 -0
  57. package/es/components/TextInput/TextInput.js +15 -7
  58. package/es/components/TreeView/TreeNode.js +1 -1
  59. package/es/components/TreeView/TreeView.js +1 -1
  60. package/es/components/UIShell/HeaderMenu.js +1 -1
  61. package/es/components/UIShell/SideNav.js +1 -1
  62. package/es/components/UIShell/SideNavItems.js +1 -1
  63. package/es/components/UIShell/SideNavMenu.js +1 -1
  64. package/es/components/UIShell/SideNavMenuItem.d.ts +5 -1
  65. package/es/components/UIShell/SideNavMenuItem.js +7 -2
  66. package/es/components/UIShell/Switcher.js +1 -1
  67. package/lib/components/AILabel/index.js +15 -15
  68. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  69. package/lib/components/CodeSnippet/CodeSnippet.d.ts +5 -2
  70. package/lib/components/CodeSnippet/CodeSnippet.js +40 -1
  71. package/lib/components/ComboBox/ComboBox.js +29 -23
  72. package/lib/components/ComboButton/index.js +40 -1
  73. package/lib/components/ComposedModal/ComposedModal.js +6 -2
  74. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +2 -2
  75. package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
  76. package/lib/components/Copy/Copy.d.ts +5 -2
  77. package/lib/components/Copy/Copy.js +40 -1
  78. package/lib/components/CopyButton/CopyButton.d.ts +5 -2
  79. package/lib/components/CopyButton/CopyButton.js +40 -1
  80. package/lib/components/DataTable/Table.d.ts +9 -1
  81. package/lib/components/DataTable/Table.js +7 -2
  82. package/lib/components/DataTable/TableSelectRow.js +14 -6
  83. package/lib/components/DataTable/TableToolbarSearch.js +1 -1
  84. package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +1 -1
  85. package/lib/components/DatePicker/DatePicker.js +0 -8
  86. package/lib/components/DatePicker/plugins/appendToPlugin.js +2 -2
  87. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +4 -4
  88. package/lib/components/DatePicker/plugins/rangePlugin.js +2 -2
  89. package/lib/components/DatePickerInput/DatePickerInput.d.ts +6 -1
  90. package/lib/components/DatePickerInput/DatePickerInput.js +16 -10
  91. package/lib/components/Dropdown/Dropdown.d.ts +5 -0
  92. package/lib/components/Dropdown/Dropdown.js +131 -91
  93. package/lib/components/FeatureFlags/index.js +1 -2
  94. package/lib/components/IconButton/index.d.ts +4 -1
  95. package/lib/components/IconButton/index.js +40 -1
  96. package/lib/components/InlineCheckbox/InlineCheckbox.d.ts +50 -0
  97. package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -6
  98. package/lib/components/InlineCheckbox/index.d.ts +9 -0
  99. package/lib/components/LayoutDirection/LayoutDirection.d.ts +44 -0
  100. package/lib/components/LayoutDirection/LayoutDirectionContext.d.ts +10 -0
  101. package/lib/components/LayoutDirection/useLayoutDirection.d.ts +12 -0
  102. package/lib/components/Menu/MenuItem.js +0 -3
  103. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  104. package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -2
  105. package/lib/components/MultiSelect/MultiSelect.js +1 -1
  106. package/lib/components/Notification/Notification.d.ts +9 -2
  107. package/lib/components/Notification/Notification.js +16 -2
  108. package/lib/components/NumberInput/NumberInput.d.ts +5 -0
  109. package/lib/components/NumberInput/NumberInput.js +17 -9
  110. package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
  111. package/lib/components/OverflowMenu/next/index.js +40 -1
  112. package/lib/components/Pagination/Pagination.js +2 -2
  113. package/lib/components/Pagination/experimental/PageSelector.js +1 -1
  114. package/lib/components/PaginationNav/PaginationNav.d.ts +1 -1
  115. package/lib/components/PaginationNav/PaginationNav.js +10 -5
  116. package/lib/components/Popover/index.js +2 -2
  117. package/lib/components/SkeletonText/SkeletonText.js +1 -1
  118. package/lib/components/Tabs/Tabs.js +46 -29
  119. package/lib/components/TextArea/TextArea.d.ts +5 -0
  120. package/lib/components/TextArea/TextArea.js +15 -7
  121. package/lib/components/TextInput/TextInput.d.ts +5 -0
  122. package/lib/components/TextInput/TextInput.js +15 -7
  123. package/lib/components/TreeView/TreeNode.js +1 -1
  124. package/lib/components/TreeView/TreeView.js +1 -1
  125. package/lib/components/UIShell/HeaderMenu.js +1 -1
  126. package/lib/components/UIShell/SideNav.js +1 -1
  127. package/lib/components/UIShell/SideNavItems.js +1 -1
  128. package/lib/components/UIShell/SideNavMenu.js +1 -1
  129. package/lib/components/UIShell/SideNavMenuItem.d.ts +5 -1
  130. package/lib/components/UIShell/SideNavMenuItem.js +7 -2
  131. package/lib/components/UIShell/Switcher.js +1 -1
  132. package/package.json +5 -5
@@ -25,6 +25,7 @@ import { Text } from '../Text/Text.js';
25
25
  const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
26
26
  const {
27
27
  className,
28
+ decorator,
28
29
  disabled = false,
29
30
  id,
30
31
  labelText,
@@ -154,7 +155,8 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
154
155
  [`${prefix}--text-area__wrapper--cols`]: other.cols,
155
156
  [`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
156
157
  [`${prefix}--text-area__wrapper--warn`]: warn,
157
- [`${prefix}--text-area__wrapper--slug`]: slug
158
+ [`${prefix}--text-area__wrapper--slug`]: slug,
159
+ [`${prefix}--text-area__wrapper--decorator`]: decorator
158
160
  });
159
161
  const labelClasses = cx(`${prefix}--label`, {
160
162
  [`${prefix}--visually-hidden`]: hideLabel && !isFluid,
@@ -253,10 +255,10 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
253
255
  ref: ref
254
256
  }));
255
257
 
256
- // Slug is always size `mini`
257
- let normalizedSlug;
258
- if (slug && slug['type']?.displayName === 'AILabel') {
259
- normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
258
+ // AILabel is always size `mini`
259
+ let normalizedDecorator = /*#__PURE__*/React__default.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
260
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
261
+ normalizedDecorator = /*#__PURE__*/React__default.cloneElement(normalizedDecorator, {
260
262
  size: 'mini'
261
263
  });
262
264
  }
@@ -271,7 +273,9 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
271
273
  className: `${prefix}--text-area__invalid-icon`
272
274
  }), warn && !invalid && !isFluid && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
273
275
  className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
274
- }), input, normalizedSlug, /*#__PURE__*/React__default.createElement("span", {
276
+ }), input, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default.createElement("div", {
277
+ className: `${prefix}--text-area__inner-wrapper--decorator`
278
+ }, normalizedDecorator) : '', /*#__PURE__*/React__default.createElement("span", {
275
279
  className: `${prefix}--text-area__counter-alert`,
276
280
  role: "alert",
277
281
  "aria-live": "assertive",
@@ -296,6 +300,10 @@ TextArea.propTypes = {
296
300
  * Specify the method used for calculating the counter number
297
301
  */
298
302
  counterMode: PropTypes.oneOf(['character', 'word']),
303
+ /**
304
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TextArea` component
305
+ */
306
+ decorator: PropTypes.node,
299
307
  /**
300
308
  * Optionally provide the default value of the `<textarea>`
301
309
  */
@@ -372,7 +380,7 @@ TextArea.propTypes = {
372
380
  /**
373
381
  * **Experimental**: Provide a `Slug` component to be rendered inside the `TextArea` component
374
382
  */
375
- slug: PropTypes.node,
383
+ slug: deprecate(PropTypes.node, 'The `slug` prop for `TextArea` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.'),
376
384
  /**
377
385
  * Provide the current value of the `<textarea>`
378
386
  */
@@ -11,6 +11,10 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
11
11
  * Specify an optional className to be applied to the `<input>` node
12
12
  */
13
13
  className?: string;
14
+ /**
15
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TextInput` component
16
+ */
17
+ decorator?: ReactNode;
14
18
  /**
15
19
  * Optionally provide the default value of the `<input>`
16
20
  */
@@ -86,6 +90,7 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
86
90
  */
87
91
  size?: 'sm' | 'md' | 'lg' | 'xl';
88
92
  /**
93
+ * @deprecated please use `decorator` instead.
89
94
  * **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
90
95
  */
91
96
  slug?: ReactNode;
@@ -23,6 +23,7 @@ import { Text } from '../Text/Text.js';
23
23
  const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref, ref) {
24
24
  let {
25
25
  className,
26
+ decorator,
26
27
  disabled = false,
27
28
  helperText,
28
29
  hideLabel,
@@ -115,7 +116,8 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
115
116
  });
116
117
  const fieldWrapperClasses = cx(`${prefix}--text-input__field-wrapper`, {
117
118
  [`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn,
118
- [`${prefix}--text-input__field-wrapper--slug`]: slug
119
+ [`${prefix}--text-input__field-wrapper--slug`]: slug,
120
+ [`${prefix}--text-input__field-wrapper--decorator`]: decorator
119
121
  });
120
122
  const iconClasses = cx({
121
123
  [`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
@@ -179,10 +181,10 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
179
181
  }, [ariaAnnouncement, prevAnnouncement]);
180
182
  const Icon = normalizedProps.icon;
181
183
 
182
- // Slug is always size `mini`
183
- let normalizedSlug;
184
- if (slug && slug['type']?.displayName === 'AILabel') {
185
- normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
184
+ // AILabel is always size `mini`
185
+ let normalizedDecorator = /*#__PURE__*/React__default.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
186
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
187
+ normalizedDecorator = /*#__PURE__*/React__default.cloneElement(normalizedDecorator, {
186
188
  size: 'mini'
187
189
  });
188
190
  }
@@ -197,7 +199,9 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
197
199
  "data-invalid": normalizedProps.invalid || null
198
200
  }, Icon && /*#__PURE__*/React__default.createElement(Icon, {
199
201
  className: iconClasses
200
- }), input, normalizedSlug, /*#__PURE__*/React__default.createElement("span", {
202
+ }), input, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default.createElement("div", {
203
+ className: `${prefix}--text-input__field-inner-wrapper--decorator`
204
+ }, normalizedDecorator) : '', /*#__PURE__*/React__default.createElement("span", {
201
205
  className: `${prefix}--text-input__counter-alert`,
202
206
  role: "alert",
203
207
  "aria-live": "assertive",
@@ -215,6 +219,10 @@ TextInput.propTypes = {
215
219
  * Specify an optional className to be applied to the `<input>` node
216
220
  */
217
221
  className: PropTypes.string,
222
+ /**
223
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TextInput` component
224
+ */
225
+ decorator: PropTypes.node,
218
226
  /**
219
227
  * Optionally provide the default value of the `<input>`
220
228
  */
@@ -290,7 +298,7 @@ TextInput.propTypes = {
290
298
  /**
291
299
  * **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component
292
300
  */
293
- slug: PropTypes.node,
301
+ slug: deprecate(PropTypes.node, 'The `slug` prop for `TextInput` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.'),
294
302
  /**
295
303
  * Specify the type of the `<input>`
296
304
  */
@@ -63,7 +63,7 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, forwardedRef) =>
63
63
  }
64
64
  };
65
65
  const nodesWithProps = React__default.Children.map(children, node => {
66
- if ( /*#__PURE__*/React__default.isValidElement(node)) {
66
+ if (/*#__PURE__*/React__default.isValidElement(node)) {
67
67
  return /*#__PURE__*/React__default.cloneElement(node, {
68
68
  active,
69
69
  depth: depth + 1,
@@ -121,7 +121,7 @@ const TreeView = _ref => {
121
121
  sharedNodeProps.tabIndex = 0;
122
122
  focusTarget = true;
123
123
  }
124
- if ( /*#__PURE__*/React__default.isValidElement(node)) {
124
+ if (/*#__PURE__*/React__default.isValidElement(node)) {
125
125
  return /*#__PURE__*/React__default.cloneElement(node, sharedNodeProps);
126
126
  }
127
127
  });
@@ -124,7 +124,7 @@ class HeaderMenu extends React__default.Component {
124
124
  * sequence when they might not want to go through all the items.
125
125
  */
126
126
  _defineProperty(this, "_renderMenuItem", (item, index) => {
127
- if ( /*#__PURE__*/React__default.isValidElement(item)) {
127
+ if (/*#__PURE__*/React__default.isValidElement(item)) {
128
128
  return /*#__PURE__*/React__default.cloneElement(item, {
129
129
  ref: this.handleItemRef(index)
130
130
  });
@@ -96,7 +96,7 @@ function SideNavRenderFunction(_ref, ref) {
96
96
  childrenToRender = React__default.Children.map(children, child => {
97
97
  // if we are controlled, check for if we have hovered over or the expanded state, else just use the expanded state (uncontrolled)
98
98
  const currentExpansionState = controlled ? expandedViaHoverState || expanded : expanded;
99
- if ( /*#__PURE__*/isValidElement(child)) {
99
+ if (/*#__PURE__*/isValidElement(child)) {
100
100
  const childJsxElement = child;
101
101
  // avoid spreading `isSideNavExpanded` to non-Carbon UI Shell children
102
102
  return /*#__PURE__*/React__default.cloneElement(childJsxElement, {
@@ -20,7 +20,7 @@ const SideNavItems = _ref => {
20
20
  const prefix = usePrefix();
21
21
  const className = cx([`${prefix}--side-nav__items`], customClassName);
22
22
  const childrenWithExpandedState = React__default.Children.map(children, child => {
23
- if ( /*#__PURE__*/React__default.isValidElement(child)) {
23
+ if (/*#__PURE__*/React__default.isValidElement(child)) {
24
24
  // avoid spreading `isSideNavExpanded` to non-Carbon UI Shell children
25
25
  const childDisplayName = child.type?.displayName;
26
26
  return /*#__PURE__*/React__default.cloneElement(child, {
@@ -148,7 +148,7 @@ function hasActiveDescendant(children) {
148
148
 
149
149
  // We use React.isValidElement(child) to check if the child is a valid React element before accessing its props
150
150
 
151
- if ( /*#__PURE__*/React__default.isValidElement(children)) {
151
+ if (/*#__PURE__*/React__default.isValidElement(children)) {
152
152
  const props = children.props;
153
153
  if (props.isActive === true || props['aria-current']) {
154
154
  return true;
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ComponentProps } from 'react';
7
+ import React, { ElementType, ComponentProps } from 'react';
8
8
  import Link from './Link';
9
9
  interface SideNavMenuItemProps extends ComponentProps<typeof Link> {
10
10
  /**
@@ -25,6 +25,10 @@ interface SideNavMenuItemProps extends ComponentProps<typeof Link> {
25
25
  * Optionally provide an href for the underlying li`
26
26
  */
27
27
  href?: string;
28
+ /**
29
+ * Optional component to render instead of default Link
30
+ */
31
+ as?: ElementType;
28
32
  }
29
33
  declare const SideNavMenuItem: React.ForwardRefExoticComponent<Omit<SideNavMenuItemProps, "ref"> & React.RefAttributes<HTMLElement>>;
30
34
  export default SideNavMenuItem;
@@ -18,6 +18,7 @@ const SideNavMenuItem = /*#__PURE__*/React__default.forwardRef(function SideNavM
18
18
  const {
19
19
  children,
20
20
  className: customClassName,
21
+ as: Component = Link,
21
22
  isActive,
22
23
  ...rest
23
24
  } = props;
@@ -28,7 +29,7 @@ const SideNavMenuItem = /*#__PURE__*/React__default.forwardRef(function SideNavM
28
29
  });
29
30
  return /*#__PURE__*/React__default.createElement("li", {
30
31
  className: className
31
- }, /*#__PURE__*/React__default.createElement(Link, _extends({}, rest, {
32
+ }, /*#__PURE__*/React__default.createElement(Component, _extends({}, rest, {
32
33
  className: linkClassName,
33
34
  ref: ref
34
35
  }), /*#__PURE__*/React__default.createElement(SideNavLinkText, null, children)));
@@ -52,7 +53,11 @@ SideNavMenuItem.propTypes = {
52
53
  * has an href that is the same as the current page. Can also pass in
53
54
  * `aria-current="page"`, as well.
54
55
  */
55
- isActive: PropTypes.bool
56
+ isActive: PropTypes.bool,
57
+ /**
58
+ * Optional component to render instead of default Link
59
+ */
60
+ as: PropTypes.elementType
56
61
  };
57
62
 
58
63
  export { SideNavMenuItem as default };
@@ -62,7 +62,7 @@ const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
62
62
  };
63
63
  const childrenWithProps = React__default.Children.toArray(children).map((child, index) => {
64
64
  // only setup click handlers if onChange event is passed
65
- if ( /*#__PURE__*/React__default.isValidElement(child) && child.type && getDisplayName(child.type) === 'Switcher') {
65
+ if (/*#__PURE__*/React__default.isValidElement(child) && child.type && getDisplayName(child.type) === 'Switcher') {
66
66
  return /*#__PURE__*/React__default.cloneElement(child, {
67
67
  handleSwitcherItemFocus,
68
68
  index,
@@ -41,8 +41,8 @@ const AILabelContent = /*#__PURE__*/React__default["default"].forwardRef(functio
41
41
  item.type?.displayName === 'AILabelActions';
42
42
  });
43
43
  const aiLabelContentClasses = cx__default["default"](className, {
44
- [`${prefix}--slug-content`]: true,
45
- [`${prefix}--slug-content--with-actions`]: hasAILabelActions
44
+ [`${prefix}--ai-label-content`]: true,
45
+ [`${prefix}--ai-label-content--with-actions`]: hasAILabelActions
46
46
  });
47
47
  return /*#__PURE__*/React__default["default"].createElement(index.ToggletipContent, {
48
48
  className: aiLabelContentClasses
@@ -51,11 +51,11 @@ const AILabelContent = /*#__PURE__*/React__default["default"].forwardRef(functio
51
51
  AILabelContent.displayName = 'AILabelContent';
52
52
  AILabelContent.propTypes = {
53
53
  /**
54
- * Specify the content you want rendered inside the slug ToggleTip
54
+ * Specify the content you want rendered inside the AILabel ToggleTip
55
55
  */
56
56
  children: PropTypes__default["default"].node,
57
57
  /**
58
- * Specify an optional className to be added to the AI slug callout
58
+ * Specify an optional className to be added to the AILabel callout
59
59
  */
60
60
  className: PropTypes__default["default"].string
61
61
  };
@@ -67,7 +67,7 @@ const AILabelActions = /*#__PURE__*/React__default["default"].forwardRef(functio
67
67
  } = _ref2;
68
68
  const prefix = usePrefix.usePrefix();
69
69
  const aiLabelActionsClasses = cx__default["default"](className, {
70
- [`${prefix}--slug-actions`]: true
70
+ [`${prefix}--ai-label-actions`]: true
71
71
  });
72
72
  return /*#__PURE__*/React__default["default"].createElement(index.ToggletipActions, {
73
73
  className: aiLabelActionsClasses
@@ -76,11 +76,11 @@ const AILabelActions = /*#__PURE__*/React__default["default"].forwardRef(functio
76
76
  AILabelActions.displayName = 'AILabelActions';
77
77
  AILabelActions.propTypes = {
78
78
  /**
79
- * Specify the content you want rendered inside the slug callout toolbar
79
+ * Specify the content you want rendered inside the AILabel callout toolbar
80
80
  */
81
81
  children: PropTypes__default["default"].node,
82
82
  /**
83
- * Specify an optional className to be added to the AI slug toolbar
83
+ * Specify an optional className to be added to the AILabel toolbar
84
84
  */
85
85
  className: PropTypes__default["default"].string
86
86
  };
@@ -114,14 +114,14 @@ const AILabel = /*#__PURE__*/React__default["default"].forwardRef(function AILab
114
114
  const prefix = usePrefix.usePrefix();
115
115
  const id = useId.useId('AILabel');
116
116
  const aiLabelClasses = cx__default["default"](className, {
117
- [`${prefix}--slug`]: true,
118
- [`${prefix}--slug--revert`]: revertActive
117
+ [`${prefix}--ai-label`]: true,
118
+ [`${prefix}--ai-label--revert`]: revertActive
119
119
  });
120
120
  const aiLabelButtonClasses = cx__default["default"]({
121
- [`${prefix}--slug__button`]: true,
122
- [`${prefix}--slug__button--${size}`]: size,
123
- [`${prefix}--slug__button--${kind}`]: kind,
124
- [`${prefix}--slug__button--inline-with-content`]: kind === 'inline' && (aiTextLabel || textLabel)
121
+ [`${prefix}--ai-label__button`]: true,
122
+ [`${prefix}--ai-label__button--${size}`]: size,
123
+ [`${prefix}--ai-label__button--${kind}`]: kind,
124
+ [`${prefix}--ai-label__button--inline-with-content`]: kind === 'inline' && (aiTextLabel || textLabel)
125
125
  });
126
126
  const handleOnRevertClick = evt => {
127
127
  if (onRevertClick) {
@@ -145,9 +145,9 @@ const AILabel = /*#__PURE__*/React__default["default"].forwardRef(function AILab
145
145
  className: aiLabelButtonClasses,
146
146
  label: ariaLabelText
147
147
  }, /*#__PURE__*/React__default["default"].createElement("span", {
148
- className: `${prefix}--slug__text`
148
+ className: `${prefix}--ai-label__text`
149
149
  }, aiText), kind === 'inline' && (aiTextLabel || textLabel) && /*#__PURE__*/React__default["default"].createElement("span", {
150
- className: `${prefix}--slug__additional-text`
150
+ className: `${prefix}--ai-label__additional-text`
151
151
  }, aiTextLabel || textLabel)), children));
152
152
  });
153
153
  AILabel.displayName = 'AILabel';
@@ -58,7 +58,7 @@ const CheckboxGroup = _ref => {
58
58
 
59
59
  // Slug is always size `mini`
60
60
  let normalizedSlug;
61
- if ( /*#__PURE__*/React__default["default"].isValidElement(slug) && slug['type']?.displayName === 'AILabel') {
61
+ if (/*#__PURE__*/React__default["default"].isValidElement(slug) && slug['type']?.displayName === 'AILabel') {
62
62
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
63
63
  size: 'mini',
64
64
  kind: 'default'
@@ -6,11 +6,14 @@
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  import { PropsWithChildren } from 'react';
9
+ export type DeprecatedCodeSnippetAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'left-bottom' | 'left-top' | 'right-bottom' | 'right-top';
10
+ export type NewCodeSnippetAlignmnet = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
11
+ export type CodeSnippetAlignment = DeprecatedCodeSnippetAlignment | NewCodeSnippetAlignmnet;
9
12
  export interface CodeSnippetProps {
10
13
  /**
11
14
  * Specify how the trigger should align with the tooltip
12
15
  */
13
- align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
16
+ align?: CodeSnippetAlignment;
14
17
  /**
15
18
  * **Experimental**: Will attempt to automatically align the tooltip
16
19
  */
@@ -106,7 +109,7 @@ declare namespace CodeSnippet {
106
109
  /**
107
110
  * Specify how the trigger should align with the tooltip
108
111
  */
109
- align: PropTypes.Requireable<string>;
112
+ align: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
110
113
  /**
111
114
  * Specify a label to be read by screen readers on the containing textbox
112
115
  * node
@@ -23,6 +23,7 @@ var uniqueId = require('../../tools/uniqueId.js');
23
23
  var copy = require('copy-to-clipboard');
24
24
  var deprecate = require('../../prop-types/deprecate.js');
25
25
  var usePrefix = require('../../internal/usePrefix.js');
26
+ var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
26
27
 
27
28
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
28
29
 
@@ -37,6 +38,19 @@ const defaultMaxCollapsedNumberOfRows = 15;
37
38
  const defaultMaxExpandedNumberOfRows = 0;
38
39
  const defaultMinCollapsedNumberOfRows = 3;
39
40
  const defaultMinExpandedNumberOfRows = 16;
41
+ const propMappingFunction = deprecatedValue => {
42
+ const mapping = {
43
+ 'top-left': 'top-start',
44
+ 'top-right': 'top-end',
45
+ 'bottom-left': 'bottom-start',
46
+ 'bottom-right': 'bottom-end',
47
+ 'left-bottom': 'left-end',
48
+ 'left-top': 'left-start',
49
+ 'right-bottom': 'right-end',
50
+ 'right-top': 'right-start'
51
+ };
52
+ return mapping[deprecatedValue];
53
+ };
40
54
  function CodeSnippet(_ref) {
41
55
  let {
42
56
  align = 'bottom',
@@ -244,7 +258,32 @@ CodeSnippet.propTypes = {
244
258
  /**
245
259
  * Specify how the trigger should align with the tooltip
246
260
  */
247
- align: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
261
+ align: deprecateValuesWithin["default"](PropTypes__default["default"].oneOf(['top', 'top-left',
262
+ // deprecated use top-start instead
263
+ 'top-right',
264
+ // deprecated use top-end instead
265
+
266
+ 'bottom', 'bottom-left',
267
+ // deprecated use bottom-start instead
268
+ 'bottom-right',
269
+ // deprecated use bottom-end instead
270
+
271
+ 'left', 'left-bottom',
272
+ // deprecated use left-end instead
273
+ 'left-top',
274
+ // deprecated use left-start instead
275
+
276
+ 'right', 'right-bottom',
277
+ // deprecated use right-end instead
278
+ 'right-top',
279
+ // deprecated use right-start instead
280
+
281
+ // new values to match floating-ui
282
+ 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
283
+ //allowed prop values
284
+ ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
285
+ //optional mapper function
286
+ propMappingFunction),
248
287
  /**
249
288
  * Specify a label to be read by screen readers on the containing textbox
250
289
  * node
@@ -16,6 +16,7 @@ var PropTypes = require('prop-types');
16
16
  var React = require('react');
17
17
  require('../Text/index.js');
18
18
  var iconsReact = require('@carbon/icons-react');
19
+ var isEqual = require('react-fast-compare');
19
20
  var index$1 = require('../ListBox/index.js');
20
21
  var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
21
22
  var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
@@ -38,6 +39,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
38
39
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
39
40
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
40
41
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
42
+ var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
41
43
 
42
44
  const {
43
45
  InputBlur,
@@ -235,11 +237,14 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
235
237
  selectedItem: selectedItemProp,
236
238
  prevSelectedItem: prevSelectedItemProp.current
237
239
  });
238
- setInputValue(currentInputValue);
239
- onChange({
240
- selectedItem: selectedItemProp,
241
- inputValue: currentInputValue
242
- });
240
+ // selectedItem has been updated externally, need to update state and call onChange
241
+ if (inputValue !== currentInputValue) {
242
+ setInputValue(currentInputValue);
243
+ onChange({
244
+ selectedItem: selectedItemProp,
245
+ inputValue: currentInputValue
246
+ });
247
+ }
243
248
  prevSelectedItemProp.current = selectedItemProp;
244
249
  }
245
250
  }, [selectedItemProp]);
@@ -440,27 +445,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
440
445
  } = _ref4;
441
446
  const normalizedInput = inputValue || '';
442
447
  setInputValue(normalizedInput);
443
- if (selectedItemProp && !inputValue) {
444
- // ensure onChange is called when selectedItem is cleared
445
- onChange({
446
- selectedItem,
447
- inputValue: normalizedInput
448
- });
449
- }
450
448
  setHighlightedIndex(indexToHighlight(normalizedInput));
451
449
  },
452
- onSelectedItemChange(_ref5) {
453
- let {
454
- selectedItem
455
- } = _ref5;
456
- onChange({
457
- selectedItem
458
- });
459
- },
460
- onHighlightedIndexChange: _ref6 => {
450
+ onHighlightedIndexChange: _ref5 => {
461
451
  let {
462
452
  highlightedIndex
463
- } = _ref6;
453
+ } = _ref5;
464
454
  if (highlightedIndex > -1 && typeof window !== undefined) {
465
455
  const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
466
456
  const highlightedItem = itemArray[highlightedIndex];
@@ -472,11 +462,27 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
472
462
  }
473
463
  }
474
464
  },
465
+ onStateChange: _ref6 => {
466
+ let {
467
+ type,
468
+ selectedItem: newSelectedItem
469
+ } = _ref6;
470
+ if (type === '__item_click__' && !isEqual__default["default"](selectedItemProp, newSelectedItem)) {
471
+ onChange({
472
+ selectedItem: newSelectedItem
473
+ });
474
+ }
475
+ if (type === '__function_select_item__' || type === '__input_keydown_enter__') {
476
+ onChange({
477
+ selectedItem: newSelectedItem
478
+ });
479
+ }
480
+ },
475
481
  initialSelectedItem: initialSelectedItem,
476
482
  inputId: id,
477
483
  stateReducer,
478
484
  isItemDisabled(item, _index) {
479
- return item.disabled;
485
+ return item?.disabled;
480
486
  },
481
487
  ...downshiftProps
482
488
  });
@@ -26,6 +26,7 @@ var react = require('@floating-ui/react');
26
26
  var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
27
27
  var index = require('../FeatureFlags/index.js');
28
28
  var mergeRefs = require('../../tools/mergeRefs.js');
29
+ var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
29
30
 
30
31
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
31
32
 
@@ -42,6 +43,19 @@ const defaultTranslations = {
42
43
  * Message ids that will be passed to translateWithId().
43
44
  */
44
45
 
46
+ const propMappingFunction = deprecatedValue => {
47
+ const mapping = {
48
+ 'top-left': 'top-start',
49
+ 'top-right': 'top-end',
50
+ 'bottom-left': 'bottom-start',
51
+ 'bottom-right': 'bottom-end',
52
+ 'left-bottom': 'left-end',
53
+ 'left-top': 'left-start',
54
+ 'right-bottom': 'right-end',
55
+ 'right-top': 'right-start'
56
+ };
57
+ return mapping[deprecatedValue];
58
+ };
45
59
  function defaultTranslateWithId(messageId) {
46
60
  return defaultTranslations[messageId];
47
61
  }
@@ -201,7 +215,32 @@ ComboButton.propTypes = {
201
215
  /**
202
216
  * Specify how the trigger tooltip should be aligned.
203
217
  */
204
- tooltipAlignment: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-start', 'top-right', 'top-end', 'bottom', 'bottom-left', 'bottom-start', 'bottom-right', 'bottom-end', 'left', 'right']),
218
+ tooltipAlignment: deprecateValuesWithin["default"](PropTypes__default["default"].oneOf(['top', 'top-left',
219
+ // deprecated use top-start instead
220
+ 'top-right',
221
+ // deprecated use top-end instead
222
+
223
+ 'bottom', 'bottom-left',
224
+ // deprecated use bottom-start instead
225
+ 'bottom-right',
226
+ // deprecated use bottom-end instead
227
+
228
+ 'left', 'left-bottom',
229
+ // deprecated use left-end instead
230
+ 'left-top',
231
+ // deprecated use left-start instead
232
+
233
+ 'right', 'right-bottom',
234
+ // deprecated use right-end instead
235
+ 'right-top',
236
+ // deprecated use right-start instead
237
+
238
+ // new values to match floating-ui
239
+ 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
240
+ //allowed prop values
241
+ ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
242
+ //optional mapper function
243
+ propMappingFunction),
205
244
  /**
206
245
  * Optional method that takes in a message id and returns an
207
246
  * internationalized string.
@@ -221,7 +221,8 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
221
221
  const el = child;
222
222
  return /*#__PURE__*/React__default["default"].cloneElement(el, {
223
223
  closeModal,
224
- inputref: button
224
+ inputref: button,
225
+ danger
225
226
  });
226
227
  }
227
228
  default:
@@ -238,7 +239,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
238
239
  React.useEffect(() => {
239
240
  const initialFocus = focusContainerElement => {
240
241
  const containerElement = focusContainerElement || innerModal.current;
241
- const primaryFocusElement = containerElement ? containerElement.querySelector(selectorPrimaryFocus) : null;
242
+ const primaryFocusElement = containerElement ? containerElement.querySelector(danger ? `.${prefix}--btn--secondary` : selectorPrimaryFocus) : null;
242
243
  if (primaryFocusElement) {
243
244
  return primaryFocusElement;
244
245
  }
@@ -246,8 +247,11 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
246
247
  };
247
248
  const focusButton = focusContainerElement => {
248
249
  const target = initialFocus(focusContainerElement);
250
+ const closeButton = focusContainerElement.querySelector(`.${prefix}--modal-close`);
249
251
  if (target) {
250
252
  target.focus();
253
+ } else if (!target && closeButton) {
254
+ closeButton?.focus();
251
255
  }
252
256
  };
253
257
  if (open && isOpen) {
@@ -38,7 +38,7 @@ export interface ContentSwitcherProps extends Omit<HTMLAttributes<HTMLElement>,
38
38
  */
39
39
  selectedIndex: number;
40
40
  /**
41
- * Choose whether or not to automatically change selection on focus
41
+ * Choose whether or not to automatically change selection on focus when left/right arrow pressed. Defaults to 'automatic'
42
42
  */
43
43
  selectionMode?: 'automatic' | 'manual';
44
44
  /**
@@ -82,7 +82,7 @@ export default class ContentSwitcher extends React.Component<ContentSwitcherProp
82
82
  */
83
83
  selectedIndex: PropTypes.Requireable<number>;
84
84
  /**
85
- * Choose whether or not to automatically change selection on focus
85
+ * Choose whether or not to automatically change selection on focus when left/right arrow pressed. Defaults to 'automatic'
86
86
  */
87
87
  selectionMode: PropTypes.Requireable<string>;
88
88
  /**