@carbon/react 1.42.1 → 1.44.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 (97) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +2843 -1416
  2. package/es/components/Breadcrumb/BreadcrumbItem.js +1 -2
  3. package/es/components/ComboBox/ComboBox.d.ts +5 -0
  4. package/es/components/ComboBox/ComboBox.js +28 -2
  5. package/es/components/ComboButton/index.js +2 -1
  6. package/es/components/ComposedModal/ComposedModal.d.ts +3 -3
  7. package/es/components/ComposedModal/ComposedModal.js +3 -3
  8. package/es/components/ComposedModal/ModalFooter.d.ts +18 -0
  9. package/es/components/ComposedModal/ModalFooter.js +48 -16
  10. package/es/components/ContextMenu/useContextMenu.js +2 -1
  11. package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
  12. package/es/components/DatePickerInput/DatePickerInput.d.ts +4 -0
  13. package/es/components/DatePickerInput/DatePickerInput.js +16 -2
  14. package/es/components/Dropdown/Dropdown.d.ts +5 -0
  15. package/es/components/Dropdown/Dropdown.js +20 -3
  16. package/es/components/InlineLoading/index.js +9 -0
  17. package/es/components/Link/Link.d.ts +5 -0
  18. package/es/components/Link/Link.js +9 -2
  19. package/es/components/Menu/Menu.js +14 -0
  20. package/es/components/Menu/MenuContext.js +1 -0
  21. package/es/components/Menu/MenuItem.js +19 -4
  22. package/es/components/MenuButton/index.js +3 -1
  23. package/es/components/Modal/Modal.d.ts +17 -0
  24. package/es/components/Modal/Modal.js +38 -3
  25. package/es/components/MultiSelect/FilterableMultiSelect.js +17 -3
  26. package/es/components/MultiSelect/MultiSelect.d.ts +5 -0
  27. package/es/components/MultiSelect/MultiSelect.js +17 -3
  28. package/es/components/NumberInput/NumberInput.d.ts +5 -0
  29. package/es/components/NumberInput/NumberInput.js +29 -4
  30. package/es/components/Select/Select.d.ts +6 -1
  31. package/es/components/Select/Select.js +16 -2
  32. package/es/components/Slug/index.js +187 -0
  33. package/es/components/TextArea/TextArea.d.ts +4 -0
  34. package/es/components/TextArea/TextArea.js +47 -31
  35. package/es/components/TextInput/TextInput.d.ts +5 -0
  36. package/es/components/TextInput/TextInput.js +16 -2
  37. package/es/components/UIShell/SideNav.js +1 -1
  38. package/es/components/UIShell/SideNavHeader.d.ts +29 -0
  39. package/es/components/UIShell/SideNavHeader.js +3 -3
  40. package/es/components/UIShell/Switcher.d.ts +38 -0
  41. package/es/components/UIShell/Switcher.js +14 -13
  42. package/es/components/UIShell/SwitcherDivider.d.ts +9 -0
  43. package/es/components/UIShell/SwitcherDivider.js +4 -5
  44. package/es/components/UIShell/SwitcherItem.d.ts +49 -0
  45. package/es/components/UIShell/SwitcherItem.js +13 -17
  46. package/es/index.d.ts +1 -0
  47. package/es/index.js +1 -0
  48. package/es/prop-types/tools/getDisplayName.js +34 -0
  49. package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -2
  50. package/lib/components/ComboBox/ComboBox.d.ts +5 -0
  51. package/lib/components/ComboBox/ComboBox.js +28 -2
  52. package/lib/components/ComboButton/index.js +2 -1
  53. package/lib/components/ComposedModal/ComposedModal.d.ts +3 -3
  54. package/lib/components/ComposedModal/ComposedModal.js +3 -3
  55. package/lib/components/ComposedModal/ModalFooter.d.ts +18 -0
  56. package/lib/components/ComposedModal/ModalFooter.js +48 -16
  57. package/lib/components/ContextMenu/useContextMenu.js +2 -1
  58. package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -1
  59. package/lib/components/DatePickerInput/DatePickerInput.d.ts +4 -0
  60. package/lib/components/DatePickerInput/DatePickerInput.js +16 -2
  61. package/lib/components/Dropdown/Dropdown.d.ts +5 -0
  62. package/lib/components/Dropdown/Dropdown.js +20 -3
  63. package/lib/components/InlineLoading/index.js +17 -0
  64. package/lib/components/Link/Link.d.ts +5 -0
  65. package/lib/components/Link/Link.js +9 -2
  66. package/lib/components/Menu/Menu.js +14 -0
  67. package/lib/components/Menu/MenuContext.js +1 -0
  68. package/lib/components/Menu/MenuItem.js +19 -4
  69. package/lib/components/MenuButton/index.js +3 -1
  70. package/lib/components/Modal/Modal.d.ts +17 -0
  71. package/lib/components/Modal/Modal.js +38 -3
  72. package/lib/components/MultiSelect/FilterableMultiSelect.js +17 -3
  73. package/lib/components/MultiSelect/MultiSelect.d.ts +5 -0
  74. package/lib/components/MultiSelect/MultiSelect.js +17 -3
  75. package/lib/components/NumberInput/NumberInput.d.ts +5 -0
  76. package/lib/components/NumberInput/NumberInput.js +28 -3
  77. package/lib/components/Select/Select.d.ts +6 -1
  78. package/lib/components/Select/Select.js +16 -2
  79. package/lib/components/Slug/index.js +199 -0
  80. package/lib/components/TextArea/TextArea.d.ts +4 -0
  81. package/lib/components/TextArea/TextArea.js +47 -31
  82. package/lib/components/TextInput/TextInput.d.ts +5 -0
  83. package/lib/components/TextInput/TextInput.js +16 -2
  84. package/lib/components/UIShell/SideNav.js +1 -1
  85. package/lib/components/UIShell/SideNavHeader.d.ts +29 -0
  86. package/lib/components/UIShell/SideNavHeader.js +3 -3
  87. package/lib/components/UIShell/Switcher.d.ts +38 -0
  88. package/lib/components/UIShell/Switcher.js +13 -12
  89. package/lib/components/UIShell/SwitcherDivider.d.ts +9 -0
  90. package/lib/components/UIShell/SwitcherDivider.js +4 -5
  91. package/lib/components/UIShell/SwitcherItem.d.ts +49 -0
  92. package/lib/components/UIShell/SwitcherItem.js +12 -16
  93. package/lib/index.d.ts +1 -0
  94. package/lib/index.js +45 -41
  95. package/lib/prop-types/tools/getDisplayName.js +38 -0
  96. package/package.json +6 -6
  97. package/scss/utilities/_ai-gradient.scss +9 -0
@@ -13,6 +13,7 @@ import { CaretLeft, CaretRight, Checkmark } from '@carbon/icons-react';
13
13
  import { useControllableState } from '../../internal/useControllableState.js';
14
14
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
+ import { warning } from '../../internal/warning.js';
16
17
  import { Menu } from './Menu.js';
17
18
  import { MenuContext } from './MenuContext.js';
18
19
  import '../Text/index.js';
@@ -143,6 +144,14 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
143
144
  setRtl(false);
144
145
  }
145
146
  }, [direction]);
147
+ const iconsAllowed = context.state.mode === 'basic' || rest.role === 'menuitemcheckbox' || rest.role === 'menuitemradio';
148
+ useEffect(() => {
149
+ if (iconsAllowed && IconElement && !context.state.hasIcons) {
150
+ context.dispatch({
151
+ type: 'enableIcons'
152
+ });
153
+ }
154
+ }, [iconsAllowed, IconElement, context.state.hasIcons, context]);
146
155
  return /*#__PURE__*/React__default.createElement("li", _extends({
147
156
  role: "menuitem"
148
157
  }, rest, {
@@ -158,7 +167,7 @@ const MenuItem = /*#__PURE__*/React__default.forwardRef(function MenuItem(_ref,
158
167
  onKeyDown: handleKeyDown
159
168
  }), /*#__PURE__*/React__default.createElement("div", {
160
169
  className: `${prefix}--menu-item__icon`
161
- }, IconElement && /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement(Text, {
170
+ }, iconsAllowed && IconElement && /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement(Text, {
162
171
  as: "div",
163
172
  className: `${prefix}--menu-item__label`
164
173
  }, label), shortcut && !hasChildren && /*#__PURE__*/React__default.createElement("div", {
@@ -202,7 +211,7 @@ MenuItem.propTypes = {
202
211
  */
203
212
  onClick: PropTypes.func,
204
213
  /**
205
- * This prop is not intended for use. The only supported icons are Checkmarks to depict single- and multi-selects. This prop is used by MenuItemSelectable and MenuItemRadioGroup automatically.
214
+ * Only applicable if the parent menu is in `basic` mode. Sets the menu item's icon.
206
215
  */
207
216
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
208
217
  /**
@@ -221,6 +230,9 @@ const MenuItemSelectable = /*#__PURE__*/React__default.forwardRef(function MenuI
221
230
  } = _ref2;
222
231
  const prefix = usePrefix();
223
232
  const context = useContext(MenuContext);
233
+ if (context.state.mode === 'basic') {
234
+ process.env.NODE_ENV !== "production" ? warning(false, 'MenuItemSelectable is not supported when the menu is in "basic" mode.') : void 0;
235
+ }
224
236
  const [checked, setChecked] = useControllableState({
225
237
  value: selected,
226
238
  onChange,
@@ -246,7 +258,7 @@ const MenuItemSelectable = /*#__PURE__*/React__default.forwardRef(function MenuI
246
258
  className: classNames,
247
259
  role: "menuitemcheckbox",
248
260
  "aria-checked": checked,
249
- renderIcon: checked && Checkmark,
261
+ renderIcon: checked ? Checkmark : undefined,
250
262
  onClick: handleClick
251
263
  }));
252
264
  });
@@ -318,6 +330,9 @@ const MenuItemRadioGroup = /*#__PURE__*/React__default.forwardRef(function MenuI
318
330
  } = _ref4;
319
331
  const prefix = usePrefix();
320
332
  const context = useContext(MenuContext);
333
+ if (context.state.mode === 'basic') {
334
+ process.env.NODE_ENV !== "production" ? warning(false, 'MenuItemRadioGroup is not supported when the menu is in "basic" mode.') : void 0;
335
+ }
321
336
  const [selection, setSelection] = useControllableState({
322
337
  value: selectedItem,
323
338
  onChange,
@@ -349,7 +364,7 @@ const MenuItemRadioGroup = /*#__PURE__*/React__default.forwardRef(function MenuI
349
364
  label: itemToString(item),
350
365
  role: "menuitemradio",
351
366
  "aria-checked": item === selection,
352
- renderIcon: item === selection && Checkmark,
367
+ renderIcon: item === selection ? Checkmark : undefined,
353
368
  onClick: e => {
354
369
  handleClick(item, e);
355
370
  }
@@ -57,6 +57,7 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(_r
57
57
  function handleOpen() {
58
58
  menuRef.current.style.inlineSize = `${width}px`;
59
59
  }
60
+ const containerClasses = cx(`${prefix}--menu-button__container`, className);
60
61
  const triggerClasses = cx(`${prefix}--menu-button__trigger`, {
61
62
  [`${prefix}--menu-button__trigger--open`]: open
62
63
  });
@@ -64,7 +65,7 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(_r
64
65
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
65
66
  ref: ref,
66
67
  "aria-owns": open ? id : null,
67
- className: className
68
+ className: containerClasses
68
69
  }), /*#__PURE__*/React__default.createElement(Button, {
69
70
  className: triggerClasses,
70
71
  size: size,
@@ -80,6 +81,7 @@ const MenuButton = /*#__PURE__*/React__default.forwardRef(function MenuButton(_r
80
81
  ref: menuRef,
81
82
  id: id,
82
83
  label: label,
84
+ mode: "basic",
83
85
  size: size,
84
86
  open: open,
85
87
  onClose: handleClose,
@@ -54,6 +54,18 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
54
54
  * Provide a ref to return focus to once the modal is closed.
55
55
  */
56
56
  launcherButtonRef?: any;
57
+ /**
58
+ * Specify the description for the loading text
59
+ */
60
+ loadingDescription?: string;
61
+ /**
62
+ * Specify the description for the loading text
63
+ */
64
+ loadingIconDescription?: string;
65
+ /**
66
+ * Specify loading status
67
+ */
68
+ loadingStatus?: string;
57
69
  /**
58
70
  * Specify a label to be read by screen readers on the modal root node
59
71
  */
@@ -71,6 +83,11 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
71
83
  * @deprecated this property is unused
72
84
  */
73
85
  onKeyDown?: React.KeyboardEventHandler<HTMLElement>;
86
+ /**
87
+ * Specify an optional handler to be invoked when loading is
88
+ * successful
89
+ */
90
+ onLoadingSuccess?: React.ReactEventHandler<HTMLElement>;
74
91
  /**
75
92
  * Specify a handler for closing modal.
76
93
  * The handler should care of closing modal, e.g. changing `open` prop.
@@ -14,6 +14,7 @@ import toggleClass from '../../tools/toggleClass.js';
14
14
  import Button from '../Button/Button.js';
15
15
  import '../Button/Button.Skeleton.js';
16
16
  import ButtonSet from '../ButtonSet/ButtonSet.js';
17
+ import InlineLoading from '../InlineLoading/InlineLoading.js';
17
18
  import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy.js';
18
19
  import wrapFocus, { elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
19
20
  import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
@@ -54,6 +55,10 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
54
55
  preventCloseOnClickOutside = false,
55
56
  isFullWidth,
56
57
  launcherButtonRef,
58
+ loadingStatus = 'inactive',
59
+ loadingDescription,
60
+ loadingIconDescription,
61
+ onLoadingSuccess = noopFn,
57
62
  ...rest
58
63
  } = _ref;
59
64
  const prefix = usePrefix();
@@ -67,6 +72,10 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
67
72
  const modalHeadingId = `${prefix}--modal-header__heading--${modalInstanceId}`;
68
73
  const modalBodyId = `${prefix}--modal-body--${modalInstanceId}`;
69
74
  const modalCloseButtonClass = `${prefix}--modal-close`;
75
+ const primaryButtonClass = cx({
76
+ [`${prefix}--btn--loading`]: loadingStatus !== 'inactive'
77
+ });
78
+ const loadingActive = loadingStatus !== 'inactive';
70
79
  function isCloseButton(element) {
71
80
  return !onSecondarySubmit && element === secondaryButton.current || element.classList.contains(modalCloseButtonClass);
72
81
  }
@@ -219,7 +228,8 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
219
228
  }, hasScrollingContentProps), children), hasScrollingContent && /*#__PURE__*/React__default.createElement("div", {
220
229
  className: `${prefix}--modal-content--overflow-indicator`
221
230
  }), !passiveModal && /*#__PURE__*/React__default.createElement(ButtonSet, {
222
- className: footerClasses
231
+ className: footerClasses,
232
+ "aria-busy": loadingActive
223
233
  }, Array.isArray(secondaryButtons) && secondaryButtons.length <= 2 ? secondaryButtons.map((_ref3, i) => {
224
234
  let {
225
235
  buttonText,
@@ -231,15 +241,23 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
231
241
  onClick: onButtonClick
232
242
  }, buttonText);
233
243
  }) : secondaryButtonText && /*#__PURE__*/React__default.createElement(Button, {
244
+ disabled: loadingActive,
234
245
  kind: "secondary",
235
246
  onClick: onSecondaryButtonClick,
236
247
  ref: secondaryButton
237
248
  }, secondaryButtonText), /*#__PURE__*/React__default.createElement(Button, {
249
+ className: primaryButtonClass,
238
250
  kind: danger ? 'danger' : 'primary',
239
- disabled: primaryButtonDisabled,
251
+ disabled: loadingActive || primaryButtonDisabled,
240
252
  onClick: onRequestSubmit,
241
253
  ref: button
242
- }, primaryButtonText)));
254
+ }, loadingStatus === 'inactive' ? primaryButtonText : /*#__PURE__*/React__default.createElement(InlineLoading, {
255
+ status: loadingStatus,
256
+ description: loadingDescription,
257
+ iconDescription: loadingIconDescription,
258
+ className: `${prefix}--inline-loading--btn`,
259
+ onSuccess: onLoadingSuccess
260
+ }))));
243
261
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
244
262
  onKeyDown: handleKeyDown,
245
263
  onMouseDown: handleMousedown,
@@ -303,6 +321,18 @@ Modal.propTypes = {
303
321
  launcherButtonRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
304
322
  current: PropTypes.any
305
323
  })]),
324
+ /**
325
+ * Specify the description for the loading text
326
+ */
327
+ loadingDescription: PropTypes.string,
328
+ /**
329
+ * Specify the description for the loading text
330
+ */
331
+ loadingIconDescription: PropTypes.string,
332
+ /**
333
+ * loading status
334
+ */
335
+ loadingStatus: PropTypes.oneOf(['inactive', 'active', 'finished', 'error']),
306
336
  /**
307
337
  * Specify a label to be read by screen readers on the modal root node
308
338
  */
@@ -319,6 +349,11 @@ Modal.propTypes = {
319
349
  * Specify a handler for keypresses.
320
350
  */
321
351
  onKeyDown: PropTypes.func,
352
+ /**
353
+ * Provide an optional handler to be invoked when loading is
354
+ * successful
355
+ */
356
+ onLoadingSuccess: PropTypes.func,
322
357
  /**
323
358
  * Specify a handler for closing modal.
324
359
  * The handler should care of closing modal, e.g. changing `open` prop.
@@ -65,7 +65,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
65
65
  translateWithId,
66
66
  useTitleInItem,
67
67
  warn,
68
- warnText
68
+ warnText,
69
+ slug
69
70
  } = _ref;
70
71
  const {
71
72
  isFluid
@@ -94,7 +95,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
94
95
  [`${prefix}--list-box__wrapper--inline--invalid`]: inline && invalid,
95
96
  [`${prefix}--list-box--up`]: direction === 'top',
96
97
  [`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
97
- [`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused
98
+ [`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused,
99
+ [`${prefix}--list-box__wrapper--slug`]: slug
98
100
  });
99
101
  const helperId = !helperText ? undefined : `filterablemultiselect-helper-text-${filterableMultiSelectInstanceId}`;
100
102
  const labelId = `${id}-label`;
@@ -188,6 +190,14 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
188
190
  textInput.current.focus();
189
191
  }
190
192
  }
193
+
194
+ // Slug is always size `mini`
195
+ let normalizedSlug;
196
+ if (slug) {
197
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
198
+ size: 'mini'
199
+ });
200
+ }
191
201
  return /*#__PURE__*/React__default.createElement(Selection, {
192
202
  disabled: disabled,
193
203
  onChange: handleOnChange,
@@ -381,7 +391,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
381
391
  }), /*#__PURE__*/React__default.createElement(ListBoxTrigger, _extends({}, buttonProps, {
382
392
  isOpen: isOpen,
383
393
  translateWithId: translateWithId
384
- }))), isOpen ? /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, sortItems(filterItems(items, {
394
+ }))), normalizedSlug, isOpen ? /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, sortItems(filterItems(items, {
385
395
  itemToString,
386
396
  inputValue
387
397
  }), {
@@ -534,6 +544,10 @@ FilterableMultiSelect.propTypes = {
534
544
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
535
545
  */
536
546
  size: ListBoxSize,
547
+ /**
548
+ * Provide a `Slug` component to be rendered inside the `FilterableMultiSelect` component
549
+ */
550
+ slug: PropTypes.node,
537
551
  ...sortingPropTypes,
538
552
  /**
539
553
  * Callback function for translating ListBoxMenuIcon SVG title
@@ -5,6 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { UseSelectProps } from 'downshift';
8
+ import { ReactNodeLike } from 'prop-types';
8
9
  import React from 'react';
9
10
  import { ListBoxSize, ListBoxType } from '../ListBox';
10
11
  import { ListBoxProps } from '../ListBox/ListBox';
@@ -162,6 +163,10 @@ export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<Item
162
163
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
163
164
  */
164
165
  size?: ListBoxSize;
166
+ /**
167
+ * Provide a `Slug` component to be rendered inside the `MultiSelect` component
168
+ */
169
+ slug?: ReactNodeLike;
165
170
  /**
166
171
  * Provide text to be used in a `<label>` element that is tied to the
167
172
  * multiselect via ARIA attributes.
@@ -87,7 +87,8 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
87
87
  direction = 'bottom',
88
88
  selectedItems: selected,
89
89
  readOnly,
90
- locale = 'en'
90
+ locale = 'en',
91
+ slug
91
92
  } = _ref;
92
93
  const prefix = usePrefix();
93
94
  const {
@@ -181,7 +182,8 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
181
182
  [`${prefix}--multi-select__wrapper--inline--invalid`]: inline && invalid,
182
183
  [`${prefix}--list-box__wrapper--inline--invalid`]: inline && invalid,
183
184
  [`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
184
- [`${prefix}--list-box__wrapper--fluid--focus`]: !isOpen && isFluid && isFocused
185
+ [`${prefix}--list-box__wrapper--fluid--focus`]: !isOpen && isFluid && isFocused,
186
+ [`${prefix}--list-box__wrapper--slug`]: slug
185
187
  });
186
188
  const titleClasses = cx(`${prefix}--label`, {
187
189
  [`${prefix}--label--disabled`]: disabled,
@@ -293,6 +295,14 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
293
295
  }
294
296
  }
295
297
  } : {};
298
+
299
+ // Slug is always size `mini`
300
+ let normalizedSlug;
301
+ if (slug) {
302
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
303
+ size: 'mini'
304
+ });
305
+ }
296
306
  return /*#__PURE__*/React__default.createElement("div", {
297
307
  className: wrapperClasses
298
308
  }, /*#__PURE__*/React__default.createElement("label", _extends({
@@ -341,7 +351,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
341
351
  }, label), /*#__PURE__*/React__default.createElement(ListBox.MenuIcon, {
342
352
  isOpen: isOpen,
343
353
  translateWithId: translateWithId
344
- }))), /*#__PURE__*/React__default.createElement(ListBox.Menu, getMenuProps(), isOpen &&
354
+ })), normalizedSlug), /*#__PURE__*/React__default.createElement(ListBox.Menu, getMenuProps(), isOpen &&
345
355
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
346
356
  sortItems(items, sortOptions).map((item, index) => {
347
357
  const isChecked = selectedItems.filter(selected => isEqual(selected, item)).length > 0;
@@ -496,6 +506,10 @@ MultiSelect.propTypes = {
496
506
  * Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
497
507
  */
498
508
  size: ListBoxSize,
509
+ /**
510
+ * Provide a `Slug` component to be rendered inside the `MultiSelect` component
511
+ */
512
+ slug: PropTypes.node,
499
513
  /**
500
514
  * Provide a method that sorts all options in the control. Overriding this
501
515
  * prop means that you also have to handle the sort logic for selected versus
@@ -4,6 +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 { ReactNodeLike } from 'prop-types';
7
8
  import React, { ReactNode } from 'react';
8
9
  export declare const translationIds: {
9
10
  'increment.number': string;
@@ -107,6 +108,10 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
107
108
  * Specify the size of the Number Input.
108
109
  */
109
110
  size?: 'sm' | 'md' | 'lg';
111
+ /**
112
+ * Provide a `Slug` component to be rendered inside the `TextInput` component
113
+ */
114
+ slug?: ReactNodeLike;
110
115
  /**
111
116
  * Specify how much the values should increase/decrease upon clicking on up/down button
112
117
  */
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import { Subtract, Add } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React__default, { useContext, useState, useRef } from 'react';
12
+ import React__default, { useContext, useState, useRef, useEffect } from 'react';
13
13
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
14
14
  import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -34,7 +34,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
34
34
  className: customClassName,
35
35
  disabled = false,
36
36
  disableWheel: disableWheelProp = false,
37
- defaultValue,
37
+ defaultValue = 0,
38
38
  helperText = '',
39
39
  hideLabel = false,
40
40
  hideSteppers,
@@ -51,6 +51,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
51
51
  onKeyUp,
52
52
  readOnly,
53
53
  size = 'md',
54
+ slug,
54
55
  step = 1,
55
56
  translateWithId: t = id => defaultTranslations[id],
56
57
  warn = false,
@@ -102,7 +103,8 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
102
103
  });
103
104
  const [incrementNumLabel, decrementNumLabel] = [t('increment.number'), t('decrement.number')];
104
105
  const wrapperClasses = cx(`${prefix}--number__input-wrapper`, {
105
- [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn
106
+ [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
107
+ [`${prefix}--number__input-wrapper--slug`]: slug
106
108
  });
107
109
  const iconClasses = cx({
108
110
  [`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
@@ -167,6 +169,25 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
167
169
  }
168
170
  }
169
171
  }
172
+
173
+ // Slug is always size `mini`
174
+ let normalizedSlug;
175
+ if (slug) {
176
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
177
+ size: 'mini'
178
+ });
179
+ }
180
+
181
+ // Need to update the internal value when the revert button is clicked
182
+ let isRevertActive;
183
+ if (slug) {
184
+ isRevertActive = normalizedSlug.props.revertActive;
185
+ }
186
+ useEffect(() => {
187
+ if (!isRevertActive && slug && defaultValue) {
188
+ setValue(defaultValue);
189
+ }
190
+ }, [defaultValue, isRevertActive, slug]);
170
191
  return /*#__PURE__*/React__default.createElement("div", {
171
192
  className: outerElementClasses,
172
193
  onFocus: isFluid ? handleFocus : undefined,
@@ -214,7 +235,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
214
235
  step: step,
215
236
  type: "number",
216
237
  value: value
217
- })), Icon ? /*#__PURE__*/React__default.createElement(Icon, {
238
+ })), normalizedSlug, Icon ? /*#__PURE__*/React__default.createElement(Icon, {
218
239
  className: iconClasses
219
240
  }) : null, !hideSteppers && /*#__PURE__*/React__default.createElement("div", {
220
241
  className: `${prefix}--number__controls`
@@ -338,6 +359,10 @@ NumberInput.propTypes = {
338
359
  * Specify the size of the Number Input.
339
360
  */
340
361
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
362
+ /**
363
+ * Provide a `Slug` component to be rendered inside the `NumberInput` component
364
+ */
365
+ slug: PropTypes.node,
341
366
  /**
342
367
  * Specify how much the values should increase/decrease upon clicking on up/down button
343
368
  */
@@ -4,6 +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 { ReactNodeLike } from 'prop-types';
7
8
  import React, { ChangeEventHandler, ComponentPropsWithRef, ReactNode } from 'react';
8
9
  type ExcludedAttributes = 'size';
9
10
  interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttributes> {
@@ -76,6 +77,10 @@ interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttr
76
77
  * Specify the size of the Select Input.
77
78
  */
78
79
  size?: 'sm' | 'md' | 'lg';
80
+ /**
81
+ * Provide a `Slug` component to be rendered inside the `Dropdown` component
82
+ */
83
+ slug?: ReactNodeLike;
79
84
  /**
80
85
  * Specify whether the control is currently in warning state
81
86
  */
@@ -85,5 +90,5 @@ interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttr
85
90
  */
86
91
  warnText?: ReactNode;
87
92
  }
88
- declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "disabled" | "form" | "slot" | "style" | "title" | "className" | "size" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onAnimationEnd" | "onKeyDown" | "tabIndex" | "color" | "lang" | "name" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "inline" | "readOnly" | "required" | "light" | "invalid" | "labelText" | "helperText" | "invalidText" | "hideLabel" | "warn" | "warnText" | "noLabel"> & React.RefAttributes<HTMLSelectElement>>;
93
+ declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "disabled" | "form" | "slot" | "style" | "title" | "className" | "size" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onAnimationEnd" | "onKeyDown" | "tabIndex" | "color" | "lang" | "name" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "inline" | "readOnly" | "required" | "light" | "invalid" | "labelText" | "helperText" | "invalidText" | "hideLabel" | "warn" | "warnText" | "slug" | "noLabel"> & React.RefAttributes<HTMLSelectElement>>;
89
94
  export default Select;
@@ -41,6 +41,7 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
41
41
  warn = false,
42
42
  warnText,
43
43
  onChange,
44
+ slug,
44
45
  ...other
45
46
  } = _ref;
46
47
  const prefix = usePrefix();
@@ -61,7 +62,8 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
61
62
  [`${prefix}--select--readonly`]: readOnly,
62
63
  [`${prefix}--select--warning`]: warn,
63
64
  [`${prefix}--select--fluid--invalid`]: isFluid && invalid,
64
- [`${prefix}--select--fluid--focus`]: isFluid && isFocused
65
+ [`${prefix}--select--fluid--focus`]: isFluid && isFocused,
66
+ [`${prefix}--select--slug`]: slug
65
67
  });
66
68
  const labelClasses = cx(`${prefix}--label`, {
67
69
  [`${prefix}--visually-hidden`]: hideLabel,
@@ -123,6 +125,14 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
123
125
  }
124
126
  }
125
127
  };
128
+
129
+ // Slug is always size `mini`
130
+ let normalizedSlug;
131
+ if (slug) {
132
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
133
+ size: 'mini'
134
+ });
135
+ }
126
136
  const input = (() => {
127
137
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("select", _extends({}, other, ariaProps, {
128
138
  id: id,
@@ -160,7 +170,7 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
160
170
  "data-invalid": invalid || null,
161
171
  onFocus: handleFocus,
162
172
  onBlur: handleFocus
163
- }, input, isFluid && /*#__PURE__*/React__default.createElement("hr", {
173
+ }, input, normalizedSlug, isFluid && /*#__PURE__*/React__default.createElement("hr", {
164
174
  className: `${prefix}--select__divider`
165
175
  }), isFluid && error ? error : null), !inline && !isFluid && error ? error : helper));
166
176
  });
@@ -234,6 +244,10 @@ Select.propTypes = {
234
244
  * Specify the size of the Select Input.
235
245
  */
236
246
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
247
+ /**
248
+ * Provide a `Slug` component to be rendered inside the `Select` component
249
+ */
250
+ slug: PropTypes.node,
237
251
  /**
238
252
  * Specify whether the control is currently in warning state
239
253
  */