@carbon/react 1.70.0 → 1.71.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 (160) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +972 -947
  2. package/es/components/AILabel/index.js +15 -15
  3. package/es/components/Checkbox/Checkbox.d.ts +5 -0
  4. package/es/components/Checkbox/Checkbox.js +16 -7
  5. package/es/components/CheckboxGroup/CheckboxGroup.d.ts +5 -0
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +16 -7
  7. package/es/components/CodeSnippet/CodeSnippet.d.ts +5 -2
  8. package/es/components/CodeSnippet/CodeSnippet.js +40 -1
  9. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  10. package/es/components/ComboBox/ComboBox.js +19 -22
  11. package/es/components/ComboButton/index.js +40 -1
  12. package/es/components/ComposedModal/ComposedModal.d.ts +5 -0
  13. package/es/components/ComposedModal/ComposedModal.js +16 -10
  14. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +2 -2
  15. package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
  16. package/es/components/Copy/Copy.d.ts +5 -2
  17. package/es/components/Copy/Copy.js +40 -1
  18. package/es/components/CopyButton/CopyButton.d.ts +5 -2
  19. package/es/components/CopyButton/CopyButton.js +40 -1
  20. package/es/components/DataTable/TableSelectRow.js +14 -6
  21. package/es/components/DataTable/TableToolbarSearch.js +1 -1
  22. package/es/components/DataTable/stories/examples/TableToolbarFilter.d.ts +1 -1
  23. package/es/components/DatePicker/plugins/fixEventsPlugin.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/FluidNumberInput/FluidNumberInput.d.ts +4 -0
  30. package/es/components/FluidSelect/FluidSelect.d.ts +4 -0
  31. package/es/components/FluidSelect/FluidSelect.js +5 -1
  32. package/es/components/FluidTextArea/FluidTextArea.d.ts +4 -0
  33. package/es/components/FluidTextArea/FluidTextArea.js +5 -1
  34. package/es/components/FluidTextInput/FluidPasswordInput.d.ts +4 -0
  35. package/es/components/FluidTextInput/FluidPasswordInput.js +5 -1
  36. package/es/components/FluidTextInput/FluidTextInput.d.ts +4 -0
  37. package/es/components/FluidTextInput/FluidTextInput.js +5 -1
  38. package/es/components/FluidTimePicker/FluidTimePicker.d.ts +4 -0
  39. package/es/components/FluidTimePicker/FluidTimePicker.js +23 -7
  40. package/es/components/IconButton/index.d.ts +4 -1
  41. package/es/components/IconButton/index.js +40 -1
  42. package/es/components/InlineCheckbox/InlineCheckbox.d.ts +50 -0
  43. package/es/components/InlineCheckbox/InlineCheckbox.js +3 -6
  44. package/es/components/InlineCheckbox/index.d.ts +9 -0
  45. package/es/components/LayoutDirection/LayoutDirection.d.ts +44 -0
  46. package/es/components/LayoutDirection/LayoutDirectionContext.d.ts +10 -0
  47. package/es/components/LayoutDirection/useLayoutDirection.d.ts +12 -0
  48. package/es/components/Menu/MenuItem.js +0 -3
  49. package/es/components/Modal/Modal.d.ts +5 -0
  50. package/es/components/Modal/Modal.js +16 -10
  51. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  52. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -2
  53. package/es/components/MultiSelect/MultiSelect.js +1 -1
  54. package/es/components/Notification/Notification.d.ts +9 -2
  55. package/es/components/Notification/Notification.js +16 -2
  56. package/es/components/NumberInput/NumberInput.d.ts +5 -0
  57. package/es/components/NumberInput/NumberInput.js +17 -9
  58. package/es/components/OverflowMenu/next/index.js +40 -1
  59. package/es/components/Pagination/Pagination.js +1 -1
  60. package/es/components/PaginationNav/PaginationNav.d.ts +1 -1
  61. package/es/components/PaginationNav/PaginationNav.js +22 -5
  62. package/es/components/RadioButton/RadioButton.d.ts +5 -0
  63. package/es/components/RadioButton/RadioButton.js +16 -7
  64. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +5 -0
  65. package/es/components/RadioButtonGroup/RadioButtonGroup.js +16 -7
  66. package/es/components/RadioTile/RadioTile.d.ts +5 -0
  67. package/es/components/RadioTile/RadioTile.js +17 -8
  68. package/es/components/Tabs/Tabs.js +46 -29
  69. package/es/components/Tag/DismissibleTag.d.ts +11 -2
  70. package/es/components/Tag/DismissibleTag.js +13 -5
  71. package/es/components/Tag/Tag.d.ts +5 -0
  72. package/es/components/Tag/Tag.js +14 -7
  73. package/es/components/TextArea/TextArea.d.ts +5 -0
  74. package/es/components/TextArea/TextArea.js +15 -7
  75. package/es/components/TextInput/TextInput.d.ts +5 -0
  76. package/es/components/TextInput/TextInput.js +15 -7
  77. package/es/components/Tile/Tile.d.ts +21 -1
  78. package/es/components/Tile/Tile.js +68 -48
  79. package/es/components/UIShell/SideNavMenuItem.d.ts +5 -1
  80. package/es/components/UIShell/SideNavMenuItem.js +7 -2
  81. package/lib/components/AILabel/index.js +15 -15
  82. package/lib/components/Checkbox/Checkbox.d.ts +5 -0
  83. package/lib/components/Checkbox/Checkbox.js +16 -7
  84. package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +5 -0
  85. package/lib/components/CheckboxGroup/CheckboxGroup.js +16 -7
  86. package/lib/components/CodeSnippet/CodeSnippet.d.ts +5 -2
  87. package/lib/components/CodeSnippet/CodeSnippet.js +40 -1
  88. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  89. package/lib/components/ComboBox/ComboBox.js +19 -22
  90. package/lib/components/ComboButton/index.js +40 -1
  91. package/lib/components/ComposedModal/ComposedModal.d.ts +5 -0
  92. package/lib/components/ComposedModal/ComposedModal.js +16 -10
  93. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +2 -2
  94. package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
  95. package/lib/components/Copy/Copy.d.ts +5 -2
  96. package/lib/components/Copy/Copy.js +40 -1
  97. package/lib/components/CopyButton/CopyButton.d.ts +5 -2
  98. package/lib/components/CopyButton/CopyButton.js +40 -1
  99. package/lib/components/DataTable/TableSelectRow.js +14 -6
  100. package/lib/components/DataTable/TableToolbarSearch.js +1 -1
  101. package/lib/components/DataTable/stories/examples/TableToolbarFilter.d.ts +1 -1
  102. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +2 -2
  103. package/lib/components/DatePickerInput/DatePickerInput.d.ts +6 -1
  104. package/lib/components/DatePickerInput/DatePickerInput.js +16 -10
  105. package/lib/components/Dropdown/Dropdown.d.ts +5 -0
  106. package/lib/components/Dropdown/Dropdown.js +131 -91
  107. package/lib/components/FeatureFlags/index.js +1 -2
  108. package/lib/components/FluidNumberInput/FluidNumberInput.d.ts +4 -0
  109. package/lib/components/FluidSelect/FluidSelect.d.ts +4 -0
  110. package/lib/components/FluidSelect/FluidSelect.js +5 -1
  111. package/lib/components/FluidTextArea/FluidTextArea.d.ts +4 -0
  112. package/lib/components/FluidTextArea/FluidTextArea.js +5 -1
  113. package/lib/components/FluidTextInput/FluidPasswordInput.d.ts +4 -0
  114. package/lib/components/FluidTextInput/FluidPasswordInput.js +5 -1
  115. package/lib/components/FluidTextInput/FluidTextInput.d.ts +4 -0
  116. package/lib/components/FluidTextInput/FluidTextInput.js +5 -1
  117. package/lib/components/FluidTimePicker/FluidTimePicker.d.ts +4 -0
  118. package/lib/components/FluidTimePicker/FluidTimePicker.js +23 -7
  119. package/lib/components/IconButton/index.d.ts +4 -1
  120. package/lib/components/IconButton/index.js +40 -1
  121. package/lib/components/InlineCheckbox/InlineCheckbox.d.ts +50 -0
  122. package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -6
  123. package/lib/components/InlineCheckbox/index.d.ts +9 -0
  124. package/lib/components/LayoutDirection/LayoutDirection.d.ts +44 -0
  125. package/lib/components/LayoutDirection/LayoutDirectionContext.d.ts +10 -0
  126. package/lib/components/LayoutDirection/useLayoutDirection.d.ts +12 -0
  127. package/lib/components/Menu/MenuItem.js +0 -3
  128. package/lib/components/Modal/Modal.d.ts +5 -0
  129. package/lib/components/Modal/Modal.js +16 -10
  130. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  131. package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -2
  132. package/lib/components/MultiSelect/MultiSelect.js +1 -1
  133. package/lib/components/Notification/Notification.d.ts +9 -2
  134. package/lib/components/Notification/Notification.js +16 -2
  135. package/lib/components/NumberInput/NumberInput.d.ts +5 -0
  136. package/lib/components/NumberInput/NumberInput.js +17 -9
  137. package/lib/components/OverflowMenu/next/index.js +40 -1
  138. package/lib/components/Pagination/Pagination.js +1 -1
  139. package/lib/components/PaginationNav/PaginationNav.d.ts +1 -1
  140. package/lib/components/PaginationNav/PaginationNav.js +22 -5
  141. package/lib/components/RadioButton/RadioButton.d.ts +5 -0
  142. package/lib/components/RadioButton/RadioButton.js +16 -7
  143. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +5 -0
  144. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +16 -7
  145. package/lib/components/RadioTile/RadioTile.d.ts +5 -0
  146. package/lib/components/RadioTile/RadioTile.js +17 -8
  147. package/lib/components/Tabs/Tabs.js +46 -29
  148. package/lib/components/Tag/DismissibleTag.d.ts +11 -2
  149. package/lib/components/Tag/DismissibleTag.js +13 -5
  150. package/lib/components/Tag/Tag.d.ts +5 -0
  151. package/lib/components/Tag/Tag.js +14 -7
  152. package/lib/components/TextArea/TextArea.d.ts +5 -0
  153. package/lib/components/TextArea/TextArea.js +15 -7
  154. package/lib/components/TextInput/TextInput.d.ts +5 -0
  155. package/lib/components/TextInput/TextInput.js +15 -7
  156. package/lib/components/Tile/Tile.d.ts +21 -1
  157. package/lib/components/Tile/Tile.js +67 -47
  158. package/lib/components/UIShell/SideNavMenuItem.d.ts +5 -1
  159. package/lib/components/UIShell/SideNavMenuItem.js +7 -2
  160. package/package.json +5 -5
@@ -16,6 +16,8 @@ var cx = require('classnames');
16
16
  var iconsReact = require('@carbon/icons-react');
17
17
  var index = require('../IconButton/index.js');
18
18
  var usePrefix = require('../../internal/usePrefix.js');
19
+ var layout = require('@carbon/layout');
20
+ var useMatchMedia = require('../../internal/useMatchMedia.js');
19
21
 
20
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
21
23
 
@@ -189,8 +191,22 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
189
191
  translateWithId: t = translateWithId,
190
192
  ...rest
191
193
  } = _ref4;
194
+ const smMediaQuery = `(max-width: ${layout.breakpoints.sm.width})`;
195
+ const isSm = useMatchMedia.useMatchMedia(smMediaQuery);
196
+ let numberOfPages;
197
+ switch (size) {
198
+ case 'md':
199
+ numberOfPages = itemsShown === 4 ? itemsShown : 5;
200
+ break;
201
+ case 'sm':
202
+ numberOfPages = Math.max(4, Math.min(itemsShown, 7));
203
+ break;
204
+ default:
205
+ numberOfPages = 4;
206
+ break;
207
+ }
192
208
  const [currentPage, setCurrentPage] = React.useState(page);
193
- const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = React.useState(itemsShown >= 4 ? itemsShown : 4);
209
+ const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = React.useState(itemsShown >= 4 && !isSm ? itemsShown : numberOfPages);
194
210
  const [cuts, setCuts] = React.useState(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage));
195
211
  const prevPage = usePrevious(currentPage);
196
212
  const prefix = usePrefix.usePrefix();
@@ -235,9 +251,10 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
235
251
 
236
252
  // re-calculate cuts if props.totalItems or props.itemsShown change
237
253
  React.useEffect(() => {
238
- setItemsDisplayedOnPage(itemsShown >= 4 ? itemsShown : 4);
239
- setCuts(calculateCuts(currentPage, totalItems, itemsShown));
240
- }, [totalItems, itemsShown]); // eslint-disable-line react-hooks/exhaustive-deps
254
+ const itemsToBeShown = itemsShown >= 4 && !isSm ? itemsShown : numberOfPages;
255
+ setItemsDisplayedOnPage(Math.max(itemsToBeShown, 4));
256
+ setCuts(calculateCuts(currentPage, totalItems, Math.max(itemsToBeShown, 4)));
257
+ }, [totalItems, itemsShown, isSm, size]); // eslint-disable-line react-hooks/exhaustive-deps
241
258
 
242
259
  // update cuts if necessary whenever currentPage changes
243
260
  React.useEffect(() => {
@@ -396,7 +413,7 @@ PaginationNav.propTypes = {
396
413
  // eslint-disable-line react/prop-types
397
414
 
398
415
  /**
399
- * The number of items to be shown.
416
+ * The number of items to be shown (minimum of 4 unless props.items < 4).
400
417
  */
401
418
  itemsShown: PropTypes__default["default"].number,
402
419
  /**
@@ -15,6 +15,10 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
15
15
  * Provide an optional className to be applied to the containing node
16
16
  */
17
17
  className?: string;
18
+ /**
19
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `RadioButton` component
20
+ */
21
+ decorator?: ReactNode;
18
22
  /**
19
23
  * Specify whether the `<RadioButton>` should be checked by default
20
24
  */
@@ -55,6 +59,7 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
55
59
  */
56
60
  onClick?: (evt: React.MouseEvent<HTMLInputElement>) => void;
57
61
  /**
62
+ * @deprecated please use decorator instead.
58
63
  * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
59
64
  */
60
65
  slug?: ReactNode;
@@ -14,6 +14,7 @@ var PropTypes = require('prop-types');
14
14
  var React = require('react');
15
15
  var cx = require('classnames');
16
16
  require('../Text/index.js');
17
+ var deprecate = require('../../prop-types/deprecate.js');
17
18
  var usePrefix = require('../../internal/usePrefix.js');
18
19
  var useId = require('../../internal/useId.js');
19
20
  var mergeRefs = require('../../tools/mergeRefs.js');
@@ -28,6 +29,7 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
28
29
  const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
29
30
  const {
30
31
  className,
32
+ decorator,
31
33
  disabled,
32
34
  hideLabel,
33
35
  id,
@@ -51,13 +53,14 @@ const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, re
51
53
  });
52
54
  const wrapperClasses = cx__default["default"](className, `${prefix}--radio-button-wrapper`, {
53
55
  [`${prefix}--radio-button-wrapper--label-${labelPosition}`]: labelPosition !== 'right',
54
- [`${prefix}--radio-button-wrapper--slug`]: slug
56
+ [`${prefix}--radio-button-wrapper--slug`]: slug,
57
+ [`${prefix}--radio-button-wrapper--decorator`]: decorator
55
58
  });
56
59
  const inputRef = React.useRef(null);
57
- let normalizedSlug;
58
- if (slug && /*#__PURE__*/React__default["default"].isValidElement(slug)) {
59
- const size = slug.props?.['kind'] === 'inline' ? 'md' : 'mini';
60
- normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
60
+ let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
61
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
62
+ const size = normalizedDecorator.props?.['kind'] === 'inline' ? 'md' : 'mini';
63
+ normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
61
64
  size
62
65
  });
63
66
  }
@@ -80,7 +83,9 @@ const RadioButton = /*#__PURE__*/React__default["default"].forwardRef((props, re
80
83
  className: `${prefix}--radio-button__appearance`
81
84
  }), labelText && /*#__PURE__*/React__default["default"].createElement(Text.Text, {
82
85
  className: innerLabelClasses
83
- }, labelText, normalizedSlug)));
86
+ }, labelText, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
87
+ className: `${prefix}--radio-button-wrapper-inner--decorator`
88
+ }, normalizedDecorator) : '')));
84
89
  });
85
90
  RadioButton.displayName = 'RadioButton';
86
91
  RadioButton.propTypes = {
@@ -92,6 +97,10 @@ RadioButton.propTypes = {
92
97
  * Provide an optional className to be applied to the containing node
93
98
  */
94
99
  className: PropTypes__default["default"].string,
100
+ /**
101
+ * **Experimental**: Provide a decorator component to be rendered inside the `RadioButton` component
102
+ */
103
+ decorator: PropTypes__default["default"].node,
95
104
  /**
96
105
  * Specify whether the `<RadioButton>` should be checked by default
97
106
  */
@@ -138,7 +147,7 @@ RadioButton.propTypes = {
138
147
  /**
139
148
  * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
140
149
  */
141
- slug: PropTypes__default["default"].node,
150
+ slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
142
151
  /**
143
152
  * Specify the value of the `<RadioButton>`
144
153
  */
@@ -17,6 +17,10 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
17
17
  * Provide an optional className to be applied to the container node
18
18
  */
19
19
  className?: string;
20
+ /**
21
+ * **Experimental**: Provide a decorator component to be rendered inside the `RadioButtonGroup` component
22
+ */
23
+ decorator?: ReactNode;
20
24
  /**
21
25
  * Specify the `<RadioButton>` to be selected by default
22
26
  */
@@ -64,6 +68,7 @@ export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HT
64
68
  */
65
69
  readOnly?: boolean;
66
70
  /**
71
+ * @deprecated please use decorator instead.
67
72
  * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
68
73
  */
69
74
  slug?: ReactNode;
@@ -16,6 +16,7 @@ var cx = require('classnames');
16
16
  var index = require('../Text/index.js');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
18
  var iconsReact = require('@carbon/icons-react');
19
+ var deprecate = require('../../prop-types/deprecate.js');
19
20
  var mergeRefs = require('../../tools/mergeRefs.js');
20
21
  var useId = require('../../internal/useId.js');
21
22
 
@@ -29,6 +30,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
29
30
  const {
30
31
  children,
31
32
  className,
33
+ decorator,
32
34
  defaultSelected,
33
35
  disabled,
34
36
  helperText,
@@ -97,7 +99,8 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
97
99
  [`${prefix}--radio-button-group--readonly`]: readOnly,
98
100
  [`${prefix}--radio-button-group--invalid`]: !readOnly && invalid,
99
101
  [`${prefix}--radio-button-group--warning`]: showWarning,
100
- [`${prefix}--radio-button-group--slug`]: slug
102
+ [`${prefix}--radio-button-group--slug`]: slug,
103
+ [`${prefix}--radio-button-group--decorator`]: decorator
101
104
  });
102
105
  const helperClasses = cx__default["default"](`${prefix}--form__helper-text`, {
103
106
  [`${prefix}--form__helper-text--disabled`]: disabled
@@ -109,10 +112,10 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
109
112
  }, helperText) : null;
110
113
  const divRef = React.useRef(null);
111
114
 
112
- // Slug is always size `mini`
113
- let normalizedSlug;
114
- if (slug && slug['type']?.displayName === 'AILabel') {
115
- normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
115
+ // AILabel is always size `mini`
116
+ let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
117
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
118
+ normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
116
119
  size: 'mini',
117
120
  kind: 'default'
118
121
  });
@@ -127,7 +130,9 @@ const RadioButtonGroup = /*#__PURE__*/React__default["default"].forwardRef((prop
127
130
  "aria-describedby": showHelper && helperText ? helperId : undefined
128
131
  }, rest), legendText && /*#__PURE__*/React__default["default"].createElement(index.Legend, {
129
132
  className: `${prefix}--label`
130
- }, legendText, normalizedSlug), getRadioButtons()), /*#__PURE__*/React__default["default"].createElement("div", {
133
+ }, legendText, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
134
+ className: `${prefix}--radio-button-group-inner--decorator`
135
+ }, normalizedDecorator) : ''), getRadioButtons()), /*#__PURE__*/React__default["default"].createElement("div", {
131
136
  className: `${prefix}--radio-button__validation-msg`
132
137
  }, !readOnly && invalid && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
133
138
  className: `${prefix}--radio-button__invalid-icon`
@@ -148,6 +153,10 @@ RadioButtonGroup.propTypes = {
148
153
  * Provide an optional className to be applied to the container node
149
154
  */
150
155
  className: PropTypes__default["default"].string,
156
+ /**
157
+ * **Experimental**: Provide a decorator component to be rendered inside the `RadioButtonGroup` component
158
+ */
159
+ decorator: PropTypes__default["default"].node,
151
160
  /**
152
161
  * Specify the `<RadioButton>` to be selected by default
153
162
  */
@@ -201,7 +210,7 @@ RadioButtonGroup.propTypes = {
201
210
  /**
202
211
  * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
203
212
  */
204
- slug: PropTypes__default["default"].node,
213
+ slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
205
214
  /**
206
215
  * Specify the value that is currently selected in the group
207
216
  */
@@ -18,6 +18,10 @@ export interface RadioTileProps {
18
18
  * Provide an optional `className` to be applied to the underlying `<label>`.
19
19
  */
20
20
  className?: string;
21
+ /**
22
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `RadioTile` component
23
+ */
24
+ decorator?: React.ReactNode;
21
25
  /**
22
26
  * Specify whether the `RadioTile` should be disabled.
23
27
  */
@@ -48,6 +52,7 @@ export interface RadioTileProps {
48
52
  */
49
53
  onChange?: (value: string | number, name: string | undefined, event: React.ChangeEvent<HTMLInputElement> | React.KeyboardEvent<HTMLInputElement>) => void;
50
54
  /**
55
+ * @deprecated please use `decorator` instead.
51
56
  * **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
52
57
  */
53
58
  slug?: React.ReactNode;
@@ -35,6 +35,7 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
35
35
  let {
36
36
  children,
37
37
  className: customClassName,
38
+ decorator,
38
39
  disabled,
39
40
  light,
40
41
  checked,
@@ -55,7 +56,9 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
55
56
  [`${prefix}--tile--light`]: light,
56
57
  [`${prefix}--tile--disabled`]: disabled,
57
58
  [`${prefix}--tile--slug`]: slug,
58
- [`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners
59
+ [`${prefix}--tile--slug-rounded`]: slug && hasRoundedCorners,
60
+ [`${prefix}--tile--decorator`]: decorator,
61
+ [`${prefix}--tile--decorator-rounded`]: decorator && hasRoundedCorners
59
62
  });
60
63
  const v12TileRadioIcons = index.useFeatureFlag('enable-v12-tile-radio-icons');
61
64
  function icon() {
@@ -79,10 +82,10 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
79
82
  }
80
83
  }
81
84
 
82
- // Slug is always size `xs`
83
- let normalizedSlug;
84
- if (slug && slug['type']?.displayName === 'AILabel') {
85
- normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
85
+ // AILabel is always size `xs`
86
+ let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
87
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
88
+ normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
86
89
  size: 'xs'
87
90
  });
88
91
  }
@@ -106,7 +109,9 @@ const RadioTile = /*#__PURE__*/React__default["default"].forwardRef(function Rad
106
109
  className: `${prefix}--tile__checkmark`
107
110
  }, icon()), /*#__PURE__*/React__default["default"].createElement(Text.Text, {
108
111
  className: `${prefix}--tile-content`
109
- }, children), normalizedSlug));
112
+ }, children), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
113
+ className: `${prefix}--tile--inner-decorator`
114
+ }, normalizedDecorator) : ''));
110
115
  });
111
116
  RadioTile.displayName = 'RadioTile';
112
117
  RadioTile.propTypes = {
@@ -122,6 +127,10 @@ RadioTile.propTypes = {
122
127
  * Provide an optional `className` to be applied to the underlying `<label>`.
123
128
  */
124
129
  className: PropTypes__default["default"].string,
130
+ /**
131
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `RadioTile` component
132
+ */
133
+ decorator: PropTypes__default["default"].node,
125
134
  /**
126
135
  * Specify whether the `RadioTile` should be disabled.
127
136
  */
@@ -154,9 +163,9 @@ RadioTile.propTypes = {
154
163
  */
155
164
  required: PropTypes__default["default"].bool,
156
165
  /**
157
- * **Experimental**: Provide a `Slug` component to be rendered inside the `SelectableTile` component
166
+ * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioTile` component
158
167
  */
159
- slug: PropTypes__default["default"].node,
168
+ slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop for `RadioTile` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.'),
160
169
  /**
161
170
  * Specify the tab index of the underlying `<input>`.
162
171
  */
@@ -357,6 +357,41 @@ function TabList(_ref4) {
357
357
  setActiveIndex(selectedIndex);
358
358
  }
359
359
  }
360
+
361
+ /**
362
+ * Scroll the tab into view if it is not already visible
363
+ * @param tab - The tab to scroll into view
364
+ * @returns {void}
365
+ */
366
+ function scrollTabIntoView(tab) {
367
+ if (!isScrollable || !ref.current) {
368
+ return;
369
+ }
370
+ if (tab) {
371
+ // The width of the "scroll buttons"
372
+ const {
373
+ width: tabWidth
374
+ } = tab.getBoundingClientRect();
375
+
376
+ // The start and end position of the selected tab
377
+ const start = tab.offsetLeft;
378
+ const end = tab.offsetLeft + tabWidth;
379
+
380
+ // The start and end of the visible area for the tabs
381
+ const visibleStart = ref.current.scrollLeft + buttonWidth;
382
+ const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
383
+
384
+ // The beginning of the tab is clipped and not visible
385
+ if (start < visibleStart) {
386
+ setScrollLeft(start - buttonWidth);
387
+ }
388
+
389
+ // The end of the tab is clipped and not visible
390
+ if (end > visibleEnd) {
391
+ setScrollLeft(end + buttonWidth - ref.current.clientWidth);
392
+ }
393
+ }
394
+ }
360
395
  useEffectOnce.useEffectOnce(() => {
361
396
  const tab = tabs.current[selectedIndex];
362
397
  if (scrollIntoView && tab) {
@@ -388,12 +423,12 @@ function TabList(_ref4) {
388
423
  });
389
424
  useIsomorphicEffect["default"](() => {
390
425
  if (ref.current) {
391
- //adding 1 in calculation for firefox support
426
+ // adding 1 in calculation for firefox support
392
427
  setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
393
428
  }
394
429
  function handler() {
395
430
  if (ref.current) {
396
- //adding 1 in calculation for firefox support
431
+ // adding 1 in calculation for firefox support
397
432
  setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
398
433
  }
399
434
  }
@@ -411,36 +446,18 @@ function TabList(_ref4) {
411
446
  ref.current.scrollLeft = scrollLeft;
412
447
  }
413
448
  }, [scrollLeft]);
449
+
450
+ // scroll manual tabs when active index changes (focus outline movement)
414
451
  useIsomorphicEffect["default"](() => {
415
- if (!isScrollable || !ref.current) {
416
- return;
417
- }
418
452
  const tab = activation === 'manual' ? tabs.current[activeIndex] : tabs.current[selectedIndex];
419
- if (tab) {
420
- // The width of the "scroll buttons"
421
-
422
- // The start and end position of the selected tab
423
- const {
424
- width: tabWidth
425
- } = tab.getBoundingClientRect();
426
- const start = tab.offsetLeft;
427
- const end = tab.offsetLeft + tabWidth;
428
-
429
- // The start and end of the visible area for the tabs
430
- const visibleStart = ref.current.scrollLeft + buttonWidth;
431
- const visibleEnd = ref.current.scrollLeft + ref.current.clientWidth - buttonWidth;
432
-
433
- // The beginning of the tab is clipped and not visible
434
- if (start < visibleStart) {
435
- setScrollLeft(start - buttonWidth);
436
- }
453
+ scrollTabIntoView(tab);
454
+ }, [activation, activeIndex]);
437
455
 
438
- // The end of the tab is clipped and not visible
439
- if (end > visibleEnd) {
440
- setScrollLeft(end + buttonWidth - ref.current.clientWidth);
441
- }
442
- }
443
- }, [activation, activeIndex, selectedIndex, isScrollable, children]);
456
+ // scroll tabs when selected index changes
457
+ useIsomorphicEffect["default"](() => {
458
+ const tab = tabs.current[selectedIndex];
459
+ scrollTabIntoView(tab);
460
+ }, [selectedIndex, isScrollable, children]);
444
461
  usePressable.usePressable(previousButton, {
445
462
  onPress(_ref6) {
446
463
  let {
@@ -13,6 +13,10 @@ export interface DismissibleTagBaseProps {
13
13
  * Provide a custom className that is applied to the containing <span>
14
14
  */
15
15
  className?: string;
16
+ /**
17
+ * **Experimental:** Provide a `decorator` component to be rendered inside the `DismissibleTag` component
18
+ */
19
+ decorator?: ReactNode;
16
20
  /**
17
21
  * Specify if the `DismissibleTag` is disabled
18
22
  */
@@ -36,6 +40,7 @@ export interface DismissibleTagBaseProps {
36
40
  */
37
41
  size?: keyof typeof SIZES;
38
42
  /**
43
+ * @deprecated please use `decorator` instead.
39
44
  * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
40
45
  */
41
46
  slug?: ReactNode;
@@ -58,12 +63,16 @@ export interface DismissibleTagBaseProps {
58
63
  }
59
64
  export type DismissibleTagProps<T extends React.ElementType> = PolymorphicProps<T, DismissibleTagBaseProps>;
60
65
  declare const DismissibleTag: {
61
- <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, title, onClose, slug, size, text, tagTitle, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
66
+ <T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, decorator, disabled, id, renderIcon, title, onClose, slug, size, text, tagTitle, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
62
67
  propTypes: {
63
68
  /**
64
69
  * Provide a custom className that is applied to the containing <span>
65
70
  */
66
71
  className: PropTypes.Requireable<string>;
72
+ /**
73
+ * **Experimental:** Provide a `decorator` component to be rendered inside the `DismissibleTag` component
74
+ */
75
+ decorator: PropTypes.Requireable<PropTypes.ReactNodeLike>;
67
76
  /**
68
77
  * Specify if the `DismissibleTag` is disabled
69
78
  */
@@ -89,7 +98,7 @@ declare const DismissibleTag: {
89
98
  /**
90
99
  * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
91
100
  */
92
- slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
101
+ slug: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
93
102
  /**
94
103
  * Provide text to be rendered inside of a the tag.
95
104
  */
@@ -15,6 +15,7 @@ var React = require('react');
15
15
  var cx = require('classnames');
16
16
  var useId = require('../../internal/useId.js');
17
17
  var usePrefix = require('../../internal/usePrefix.js');
18
+ var deprecate = require('../../prop-types/deprecate.js');
18
19
  var Tag = require('./Tag.js');
19
20
  var iconsReact = require('@carbon/icons-react');
20
21
  require('../Tooltip/DefinitionTooltip.js');
@@ -33,6 +34,7 @@ var _Close;
33
34
  const DismissibleTag = _ref => {
34
35
  let {
35
36
  className,
37
+ decorator,
36
38
  disabled,
37
39
  id,
38
40
  renderIcon,
@@ -60,9 +62,9 @@ const DismissibleTag = _ref => {
60
62
  onClose(event);
61
63
  }
62
64
  };
63
- let normalizedSlug;
64
- if (slug && slug['type']?.displayName === 'AILabel') {
65
- normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
65
+ let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
66
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
67
+ normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
66
68
  size: 'sm',
67
69
  kind: 'inline'
68
70
  });
@@ -89,7 +91,9 @@ const DismissibleTag = _ref => {
89
91
  }, /*#__PURE__*/React__default["default"].createElement(Text.Text, {
90
92
  title: tagTitle ? tagTitle : text,
91
93
  className: `${prefix}--tag__label`
92
- }, text), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
94
+ }, text), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
95
+ className: `${prefix}--tag__decorator`
96
+ }, normalizedDecorator) : '', /*#__PURE__*/React__default["default"].createElement(Tooltip.Tooltip, {
93
97
  label: isEllipsisApplied ? dismissLabel : title,
94
98
  align: "bottom",
95
99
  className: tooltipClasses,
@@ -108,6 +112,10 @@ DismissibleTag.propTypes = {
108
112
  * Provide a custom className that is applied to the containing <span>
109
113
  */
110
114
  className: PropTypes__default["default"].string,
115
+ /**
116
+ * **Experimental:** Provide a `decorator` component to be rendered inside the `DismissibleTag` component
117
+ */
118
+ decorator: PropTypes__default["default"].node,
111
119
  /**
112
120
  * Specify if the `DismissibleTag` is disabled
113
121
  */
@@ -133,7 +141,7 @@ DismissibleTag.propTypes = {
133
141
  /**
134
142
  * **Experimental:** Provide a `Slug` component to be rendered inside the `DismissibleTag` component
135
143
  */
136
- slug: PropTypes__default["default"].node,
144
+ slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
137
145
  /**
138
146
  * Provide text to be rendered inside of a the tag.
139
147
  */
@@ -34,6 +34,10 @@ export interface TagBaseProps {
34
34
  * Provide a custom className that is applied to the containing <span>
35
35
  */
36
36
  className?: string;
37
+ /**
38
+ * **Experimental:** Provide a `decorator` component to be rendered inside the `Tag` component
39
+ */
40
+ decorator?: ReactNode;
37
41
  /**
38
42
  * Specify if the `Tag` is disabled
39
43
  */
@@ -61,6 +65,7 @@ export interface TagBaseProps {
61
65
  */
62
66
  size?: keyof typeof SIZES;
63
67
  /**
68
+ * @deprecated please use `decorator` instead.
64
69
  * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
65
70
  */
66
71
  slug?: ReactNode;
@@ -54,6 +54,7 @@ const Tag = /*#__PURE__*/React__default["default"].forwardRef(function Tag(_ref,
54
54
  let {
55
55
  children,
56
56
  className,
57
+ decorator,
57
58
  id,
58
59
  type,
59
60
  filter,
@@ -97,10 +98,10 @@ const Tag = /*#__PURE__*/React__default["default"].forwardRef(function Tag(_ref,
97
98
  }
98
99
  };
99
100
 
100
- // Slug is always size `md` and `inline`
101
- let normalizedSlug;
102
- if (slug && slug['type']?.displayName === 'AILabel' && !isInteractiveTag) {
103
- normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
101
+ // AILabel is always size `sm` and `inline`
102
+ let normalizedDecorator = /*#__PURE__*/React__default["default"].isValidElement(slug ?? decorator) ? slug ?? decorator : null;
103
+ if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel' && !isInteractiveTag) {
104
+ normalizedDecorator = /*#__PURE__*/React__default["default"].cloneElement(normalizedDecorator, {
104
105
  size: 'sm',
105
106
  kind: 'inline'
106
107
  });
@@ -115,7 +116,7 @@ const Tag = /*#__PURE__*/React__default["default"].forwardRef(function Tag(_ref,
115
116
  }, /*#__PURE__*/React__default["default"].createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default["default"].createElement(Text.Text, {
116
117
  title: typeof children === 'string' ? children : undefined,
117
118
  className: `${prefix}--tag__label`
118
- }, children !== null && children !== undefined ? children : typeText), normalizedSlug, /*#__PURE__*/React__default["default"].createElement("button", {
119
+ }, children !== null && children !== undefined ? children : typeText), normalizedDecorator, /*#__PURE__*/React__default["default"].createElement("button", {
119
120
  type: "button",
120
121
  className: `${prefix}--tag__close-icon`,
121
122
  onClick: handleClose,
@@ -146,7 +147,9 @@ const Tag = /*#__PURE__*/React__default["default"].forwardRef(function Tag(_ref,
146
147
  }, children !== null && children !== undefined ? children : typeText)) : /*#__PURE__*/React__default["default"].createElement(Text.Text, {
147
148
  title: children !== null && children !== undefined && typeof children === 'string' ? children : typeText,
148
149
  className: labelClasses
149
- }, children !== null && children !== undefined ? children : typeText), normalizedSlug);
150
+ }, children !== null && children !== undefined ? children : typeText), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React__default["default"].createElement("div", {
151
+ className: `${prefix}--tag__decorator`
152
+ }, normalizedDecorator) : '');
150
153
  });
151
154
  Tag.propTypes = {
152
155
  /**
@@ -162,6 +165,10 @@ Tag.propTypes = {
162
165
  * Provide a custom className that is applied to the containing <span>
163
166
  */
164
167
  className: PropTypes__default["default"].string,
168
+ /**
169
+ * **Experimental:** Provide a `decorator` component to be rendered inside the `Tag` component
170
+ */
171
+ decorator: PropTypes__default["default"].node,
165
172
  /**
166
173
  * Specify if the `Tag` is disabled
167
174
  */
@@ -191,7 +198,7 @@ Tag.propTypes = {
191
198
  /**
192
199
  * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
193
200
  */
194
- slug: PropTypes__default["default"].node,
201
+ slug: deprecate["default"](PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
195
202
  /**
196
203
  * Text to show on clear filters
197
204
  */
@@ -15,6 +15,10 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
15
15
  * Specify the `cols` attribute for the underlying `<textarea>` node
16
16
  */
17
17
  cols?: number;
18
+ /**
19
+ * **Experimental**: Provide a `decorator` component to be rendered inside the `TextArea` component
20
+ */
21
+ decorator?: ReactNode;
18
22
  /**
19
23
  * Optionally provide the default value of the `<textarea>`
20
24
  */
@@ -90,6 +94,7 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
90
94
  */
91
95
  rows?: number;
92
96
  /**
97
+ * @deprecated please use `decorator` instead.
93
98
  * **Experimental**: Provide a `Slug` component to be rendered inside the `TextArea` component
94
99
  */
95
100
  slug?: ReactNode;