@carbon/react 1.45.0-rc.0 → 1.46.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 (52) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +975 -893
  2. package/README.md +9 -0
  3. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  4. package/es/components/ComboBox/ComboBox.js +1 -1
  5. package/es/components/ComposedModal/ComposedModal.d.ts +5 -0
  6. package/es/components/ComposedModal/ComposedModal.js +20 -3
  7. package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
  8. package/es/components/DatePickerInput/DatePickerInput.js +1 -1
  9. package/es/components/Dropdown/Dropdown.js +1 -1
  10. package/es/components/Grid/Column.js +2 -2
  11. package/es/components/Modal/Modal.d.ts +5 -0
  12. package/es/components/Modal/Modal.js +17 -3
  13. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
  14. package/es/components/MultiSelect/MultiSelect.js +4 -1
  15. package/es/components/NumberInput/NumberInput.js +2 -2
  16. package/es/components/PaginationNav/PaginationNav.js +35 -2
  17. package/es/components/ProgressIndicator/ProgressIndicator.js +4 -0
  18. package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  19. package/es/components/Select/Select.js +1 -1
  20. package/es/components/Slug/index.js +1 -0
  21. package/es/components/Tag/Tag.d.ts +18 -10
  22. package/es/components/Tag/Tag.js +23 -7
  23. package/es/components/TextArea/TextArea.js +1 -1
  24. package/es/components/TextInput/TextInput.js +1 -1
  25. package/es/components/Tile/Tile.js +2 -2
  26. package/es/components/UIShell/Switcher.js +1 -1
  27. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  28. package/lib/components/ComboBox/ComboBox.js +1 -1
  29. package/lib/components/ComposedModal/ComposedModal.d.ts +5 -0
  30. package/lib/components/ComposedModal/ComposedModal.js +20 -3
  31. package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
  32. package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
  33. package/lib/components/Dropdown/Dropdown.js +1 -1
  34. package/lib/components/Grid/Column.js +2 -2
  35. package/lib/components/Modal/Modal.d.ts +5 -0
  36. package/lib/components/Modal/Modal.js +17 -3
  37. package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -1
  38. package/lib/components/MultiSelect/MultiSelect.js +4 -1
  39. package/lib/components/NumberInput/NumberInput.js +2 -2
  40. package/lib/components/PaginationNav/PaginationNav.js +35 -2
  41. package/lib/components/ProgressIndicator/ProgressIndicator.js +4 -0
  42. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  43. package/lib/components/Select/Select.js +1 -1
  44. package/lib/components/Slug/index.js +1 -0
  45. package/lib/components/Tag/Tag.d.ts +18 -10
  46. package/lib/components/Tag/Tag.js +23 -7
  47. package/lib/components/TextArea/TextArea.js +1 -1
  48. package/lib/components/TextInput/TextInput.js +1 -1
  49. package/lib/components/Tile/Tile.js +2 -2
  50. package/lib/components/UIShell/Switcher.js +1 -1
  51. package/package.json +7 -7
  52. package/telemetry.yml +816 -0
package/README.md CHANGED
@@ -113,3 +113,12 @@ check out our [Contributing Guide](/.github/CONTRIBUTING.md)! 👀
113
113
  ## 📝 License
114
114
 
115
115
  Licensed under the [Apache 2.0 License](/LICENSE).
116
+
117
+ ## <picture><source height="20" width="20" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-dark.svg"><source height="20" width="20" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"><img height="20" width="20" alt="IBM Telemetry" src="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"></picture> IBM Telemetry
118
+
119
+ This package uses IBM Telemetry to collect metrics data. By installing this
120
+ package as a dependency you are agreeing to telemetry collection. To opt out,
121
+ see
122
+ [Opting out of IBM Telemetry data collection](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection).
123
+ For more information on the data being collected, please see the
124
+ [IBM Telemetry documentation](https://github.com/ibm-telemetry/telemetry-js/tree/main#ibm-telemetry-collection-basics).
@@ -47,7 +47,7 @@ function CheckboxGroup(_ref) {
47
47
 
48
48
  // Slug is always size `mini`
49
49
  let normalizedSlug;
50
- if (slug) {
50
+ if (slug && slug['type']?.displayName === 'Slug') {
51
51
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
52
52
  size: 'mini',
53
53
  kind: 'default'
@@ -257,7 +257,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
257
257
 
258
258
  // Slug is always size `mini`
259
259
  let normalizedSlug;
260
- if (slug) {
260
+ if (slug && slug['type']?.displayName === 'Slug') {
261
261
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
262
262
  size: 'mini'
263
263
  });
@@ -1,4 +1,5 @@
1
1
  import React, { type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ReactNode, type RefObject } from 'react';
2
+ import { ReactNodeLike } from 'prop-types';
2
3
  export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
3
4
  /** Specify the content to be placed in the ModalBody. */
4
5
  children?: ReactNode;
@@ -69,6 +70,10 @@ export interface ComposedModalProps extends HTMLAttributes<HTMLDivElement> {
69
70
  /** Specify the CSS selectors that match the floating menus. */
70
71
  selectorsFloatingMenus?: Array<string | null | undefined>;
71
72
  size?: 'xs' | 'sm' | 'md' | 'lg';
73
+ /**
74
+ * **Experimental**: Provide a `Slug` component to be rendered inside the `ComposedModal` component
75
+ */
76
+ slug?: ReactNodeLike;
72
77
  }
73
78
  declare const ComposedModal: React.ForwardRefExoticComponent<ComposedModalProps & React.RefAttributes<HTMLDivElement>>;
74
79
  export default ComposedModal;
@@ -81,6 +81,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
81
81
  selectorsFloatingMenus,
82
82
  size,
83
83
  launcherButtonRef,
84
+ slug,
84
85
  ...rest
85
86
  } = _ref2;
86
87
  const prefix = usePrefix();
@@ -149,7 +150,11 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
149
150
  setIsOpen(false);
150
151
  }
151
152
  }
152
- const modalClass = cx(`${prefix}--modal`, isOpen && 'is-visible', danger && `${prefix}--modal--danger`, customClassName);
153
+ const modalClass = cx(`${prefix}--modal`, {
154
+ 'is-visible': isOpen,
155
+ [`${prefix}--modal--danger`]: danger,
156
+ [`${prefix}--modal--slug`]: slug
157
+ }, customClassName);
153
158
  const containerClass = cx(`${prefix}--modal-container`, size && `${prefix}--modal-container--${size}`, isFullWidth && `${prefix}--modal-container--full-width`, containerClassName);
154
159
 
155
160
  // Generate aria-label based on Modal Header label if one is not provided (L253)
@@ -202,6 +207,14 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
202
207
  focusButton(innerModal.current);
203
208
  }
204
209
  }, [open, selectorPrimaryFocus, isOpen]);
210
+
211
+ // Slug is always size `lg`
212
+ let normalizedSlug;
213
+ if (slug && slug['type']?.displayName === 'Slug') {
214
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
215
+ size: 'lg'
216
+ });
217
+ }
205
218
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
206
219
  role: "presentation",
207
220
  ref: ref,
@@ -223,7 +236,7 @@ const ComposedModal = /*#__PURE__*/React__default.forwardRef(function ComposedMo
223
236
  }, "Focus sentinel"), /*#__PURE__*/React__default.createElement("div", {
224
237
  ref: innerModal,
225
238
  className: `${prefix}--modal-container-body`
226
- }, childrenWithProps), /*#__PURE__*/React__default.createElement("button", {
239
+ }, normalizedSlug, childrenWithProps), /*#__PURE__*/React__default.createElement("button", {
227
240
  type: "button",
228
241
  ref: endSentinel,
229
242
  className: `${prefix}--visually-hidden`
@@ -293,7 +306,11 @@ ComposedModal.propTypes = {
293
306
  /**
294
307
  * Specify the size variant.
295
308
  */
296
- size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg'])
309
+ size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),
310
+ /**
311
+ * **Experimental**: Provide a `Slug` component to be rendered inside the `ComposedModal` component
312
+ */
313
+ slug: PropTypes.node
297
314
  };
298
315
 
299
316
  export { ModalBody, ComposedModal as default };
@@ -130,7 +130,7 @@ class ContentSwitcher extends React__default.Component {
130
130
  className: classes,
131
131
  role: "tablist",
132
132
  onChange: undefined
133
- }), children && React__default.Children.map(children, (child, index) => /*#__PURE__*/React__default.cloneElement(child, {
133
+ }), children && React__default.Children.toArray(children).map((child, index) => /*#__PURE__*/React__default.cloneElement(child, {
134
134
  index,
135
135
  onClick: composeEventHandlers([this.handleChildChange, child.props.onClick]),
136
136
  onKeyDown: this.handleChildChange,
@@ -98,7 +98,7 @@ const DatePickerInput = /*#__PURE__*/React__default.forwardRef(function DatePick
98
98
 
99
99
  // Slug is always size `mini`
100
100
  let normalizedSlug;
101
- if (slug) {
101
+ if (slug && slug['type']?.displayName === 'Slug') {
102
102
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
103
103
  size: 'mini'
104
104
  });
@@ -228,7 +228,7 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
228
228
 
229
229
  // Slug is always size `mini`
230
230
  let normalizedSlug;
231
- if (slug) {
231
+ if (slug && slug['type']?.displayName === 'Slug') {
232
232
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
233
233
  size: 'mini'
234
234
  });
@@ -225,10 +225,10 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
225
225
  continue;
226
226
  }
227
227
 
228
- // If our breakpoint is a string, the user has specified a percent
228
+ // If our breakpoint is a string, the user might have specified a percent
229
229
  // they'd like this column to span.
230
230
  if (typeof breakpoint === 'string') {
231
- classNames.push(`${prefix}--${name}:col-span-${breakpoint.slice(0, -1)}`);
231
+ classNames.push(`${prefix}--${name}:col-span-${breakpoint.replace('%', '')}`);
232
232
  continue;
233
233
  }
234
234
 
@@ -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 from 'react';
8
9
  import { ReactAttr } from '../../types/common';
9
10
  import { InlineLoadingStatus } from '../InlineLoading/InlineLoading';
@@ -150,6 +151,10 @@ export interface ModalProps extends ReactAttr<HTMLDivElement> {
150
151
  * Specify the size variant.
151
152
  */
152
153
  size?: ModalSize;
154
+ /**
155
+ * **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
156
+ */
157
+ slug?: ReactNodeLike;
153
158
  }
154
159
  declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
155
160
  export default Modal;
@@ -59,6 +59,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
59
59
  loadingDescription,
60
60
  loadingIconDescription,
61
61
  onLoadingSuccess = noopFn,
62
+ slug,
62
63
  ...rest
63
64
  } = _ref;
64
65
  const prefix = usePrefix();
@@ -124,7 +125,8 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
124
125
  const modalClasses = cx(`${prefix}--modal`, {
125
126
  [`${prefix}--modal-tall`]: !passiveModal,
126
127
  'is-visible': open,
127
- [`${prefix}--modal--danger`]: danger
128
+ [`${prefix}--modal--danger`]: danger,
129
+ [`${prefix}--modal--slug`]: slug
128
130
  }, className);
129
131
  const containerClasses = cx(`${prefix}--modal-container`, {
130
132
  [`${prefix}--modal-container--${size}`]: size,
@@ -191,6 +193,14 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
191
193
  focusButton(innerModal.current);
192
194
  }
193
195
  }, [open, selectorPrimaryFocus, danger, prefix]);
196
+
197
+ // Slug is always size `lg`
198
+ let normalizedSlug;
199
+ if (slug && slug['type']?.displayName === 'Slug') {
200
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
201
+ size: 'lg'
202
+ });
203
+ }
194
204
  const modalButton = /*#__PURE__*/React__default.createElement("button", {
195
205
  className: modalCloseButtonClass,
196
206
  type: "button",
@@ -222,7 +232,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
222
232
  as: "h3",
223
233
  id: modalHeadingId,
224
234
  className: `${prefix}--modal-header__heading`
225
- }, modalHeading), !passiveModal && modalButton), /*#__PURE__*/React__default.createElement("div", _extends({
235
+ }, modalHeading), normalizedSlug, !passiveModal && modalButton), /*#__PURE__*/React__default.createElement("div", _extends({
226
236
  id: modalBodyId,
227
237
  className: contentClasses
228
238
  }, hasScrollingContentProps), children), hasScrollingContent && /*#__PURE__*/React__default.createElement("div", {
@@ -432,7 +442,11 @@ Modal.propTypes = {
432
442
  /**
433
443
  * Specify the size variant.
434
444
  */
435
- size: PropTypes.oneOf(ModalSizes)
445
+ size: PropTypes.oneOf(ModalSizes),
446
+ /**
447
+ * **Experimental**: Provide a `Slug` component to be rendered inside the `Modal` component
448
+ */
449
+ slug: PropTypes.node
436
450
  };
437
451
 
438
452
  export { ModalSizes, Modal as default };
@@ -193,7 +193,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
193
193
 
194
194
  // Slug is always size `mini`
195
195
  let normalizedSlug;
196
- if (slug) {
196
+ if (slug && slug['type']?.displayName === 'Slug') {
197
197
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
198
198
  size: 'mini'
199
199
  });
@@ -237,6 +237,9 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
237
237
  if (changes.selectedItem === undefined) {
238
238
  break;
239
239
  }
240
+ if (Array.isArray(changes.selectedItem)) {
241
+ break;
242
+ }
240
243
  onItemChange(changes.selectedItem);
241
244
  return {
242
245
  ...changes,
@@ -298,7 +301,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
298
301
 
299
302
  // Slug is always size `mini`
300
303
  let normalizedSlug;
301
- if (slug) {
304
+ if (slug && slug['type']?.displayName === 'Slug') {
302
305
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
303
306
  size: 'mini'
304
307
  });
@@ -172,7 +172,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
172
172
 
173
173
  // Slug is always size `mini`
174
174
  let normalizedSlug;
175
- if (slug) {
175
+ if (slug && slug['type']?.displayName === 'Slug') {
176
176
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
177
177
  size: 'mini'
178
178
  });
@@ -180,7 +180,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
180
180
 
181
181
  // Need to update the internal value when the revert button is clicked
182
182
  let isRevertActive;
183
- if (slug) {
183
+ if (slug && slug['type']?.displayName === 'Slug') {
184
184
  isRevertActive = normalizedSlug.props.revertActive;
185
185
  }
186
186
  useEffect(() => {
@@ -103,9 +103,28 @@ function PaginationOverflow(_ref3) {
103
103
  fromIndex,
104
104
  count,
105
105
  onSelect,
106
+ // eslint-disable-next-line react/prop-types
107
+ disableOverflow,
106
108
  translateWithId: t = translateWithId
107
109
  } = _ref3;
108
110
  const prefix = usePrefix();
111
+
112
+ //If overflow is disabled, return a select tag with no select options
113
+ if (disableOverflow === true && count > 1) {
114
+ return /*#__PURE__*/React__default.createElement("li", {
115
+ className: `${prefix}--pagination-nav__list-item`
116
+ }, /*#__PURE__*/React__default.createElement("div", {
117
+ className: `${prefix}--pagination-nav__select`
118
+ }, /*#__PURE__*/React__default.createElement("select", {
119
+ className: `${prefix}--pagination-nav__page ${prefix}--pagination-nav__page--select`,
120
+ "aria-label": `Select ${t('carbon.pagination-nav.item')} number`,
121
+ disabled: true
122
+ }), /*#__PURE__*/React__default.createElement("div", {
123
+ className: `${prefix}--pagination-nav__select-icon-wrapper`
124
+ }, /*#__PURE__*/React__default.createElement(OverflowMenuHorizontal, {
125
+ className: `${prefix}--pagination-nav__select-icon`
126
+ }))));
127
+ }
109
128
  if (count > 1) {
110
129
  return /*#__PURE__*/React__default.createElement("li", {
111
130
  className: `${prefix}--pagination-nav__list-item`
@@ -147,6 +166,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
147
166
  className,
148
167
  onChange = () => {},
149
168
  totalItems,
169
+ disableOverflow,
150
170
  itemsShown = 10,
151
171
  page = 0,
152
172
  loop = false,
@@ -158,6 +178,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
158
178
  const [cuts, setCuts] = useState(getCuts(currentPage, totalItems, itemsThatFit));
159
179
  const prevPage = usePrevious(currentPage);
160
180
  const prefix = usePrefix();
181
+ const [isOverflowDisabled, setIsOverFlowDisabled] = useState(disableOverflow);
161
182
  function jumpToItem(index) {
162
183
  if (index >= 0 && index < totalItems) {
163
184
  setCurrentPage(index);
@@ -216,6 +237,9 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
216
237
  }
217
238
  }, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
218
239
 
240
+ useEffect(() => {
241
+ setIsOverFlowDisabled(disableOverflow);
242
+ }, [disableOverflow]);
219
243
  const classNames = cx(`${prefix}--pagination-nav`, className);
220
244
  const backwardButtonDisabled = !loop && currentPage === 0;
221
245
  const forwardButtonDisabled = !loop && currentPage === totalItems - 1;
@@ -245,7 +269,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
245
269
  }), /*#__PURE__*/React__default.createElement(PaginationOverflow, {
246
270
  fromIndex: startOffset,
247
271
  count: cuts.front,
248
- onSelect: jumpToItem
272
+ onSelect: jumpToItem,
273
+ disableOverflow: isOverflowDisabled
249
274
  }),
250
275
  // render items between overflows
251
276
  [...Array(totalItems)].map((e, i) => i).slice(startOffset + cuts.front, (1 + cuts.back) * -1).map(item => /*#__PURE__*/React__default.createElement(PaginationItem, {
@@ -259,7 +284,8 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
259
284
  })), /*#__PURE__*/React__default.createElement(PaginationOverflow, {
260
285
  fromIndex: totalItems - cuts.back - 1,
261
286
  count: cuts.back,
262
- onSelect: jumpToItem
287
+ onSelect: jumpToItem,
288
+ disableOverflow: isOverflowDisabled
263
289
  }),
264
290
  // render last item unless there is only one in total
265
291
  totalItems > 1 && /*#__PURE__*/React__default.createElement(PaginationItem, {
@@ -342,6 +368,13 @@ PaginationNav.propTypes = {
342
368
  * Additional CSS class names.
343
369
  */
344
370
  className: PropTypes.string,
371
+ /**
372
+ * If true, the '...' pagination overflow will not render page links between the first and last rendered buttons.
373
+ * Set this to true if you are having performance problems with large data sets.
374
+ */
375
+ disableOverflow: PropTypes.bool,
376
+ // eslint-disable-line react/prop-types
377
+
345
378
  /**
346
379
  * The number of items to be shown.
347
380
  */
@@ -51,6 +51,10 @@ function ProgressIndicator(_ref) {
51
51
  return /*#__PURE__*/React__default.createElement("ul", _extends({
52
52
  className: className
53
53
  }, rest), React__default.Children.map(children, (child, index) => {
54
+ if (! /*#__PURE__*/React__default.isValidElement(child)) {
55
+ return null;
56
+ }
57
+
54
58
  // only setup click handlers if onChange event is passed
55
59
  const onClick = onChange ? () => onChange(index) : undefined;
56
60
  if (index === currentIndex) {
@@ -104,7 +104,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default.forwardRef((props, ref) =>
104
104
 
105
105
  // Slug is always size `mini`
106
106
  let normalizedSlug;
107
- if (slug) {
107
+ if (slug && slug['type']?.displayName === 'Slug') {
108
108
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
109
109
  size: 'mini',
110
110
  kind: 'default'
@@ -128,7 +128,7 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
128
128
 
129
129
  // Slug is always size `mini`
130
130
  let normalizedSlug;
131
- if (slug) {
131
+ if (slug && slug['type']?.displayName === 'Slug') {
132
132
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
133
133
  size: 'mini'
134
134
  });
@@ -125,6 +125,7 @@ const Slug = /*#__PURE__*/React__default.forwardRef(function Slug(_ref3, ref) {
125
125
  className: `${prefix}--slug__additional-text`
126
126
  }, aiTextLabel)), children));
127
127
  });
128
+ Slug.displayName = 'Slug';
128
129
  Slug.propTypes = {
129
130
  /**
130
131
  * Specify the correct translation of the AI text
@@ -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 PropTypes from 'prop-types';
7
+ import PropTypes, { ReactNodeLike } from 'prop-types';
8
8
  import React from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  declare const TYPES: {
@@ -23,7 +23,7 @@ declare const TYPES: {
23
23
  };
24
24
  export interface TagBaseProps {
25
25
  /**
26
- * Provide content to be rendered inside of a <Tag>
26
+ * Provide content to be rendered inside of a `Tag`
27
27
  */
28
28
  children?: React.ReactNode;
29
29
  /**
@@ -31,11 +31,11 @@ export interface TagBaseProps {
31
31
  */
32
32
  className?: string;
33
33
  /**
34
- * Specify if the <Tag> is disabled
34
+ * Specify if the `Tag` is disabled
35
35
  */
36
36
  disabled?: boolean;
37
37
  /**
38
- * Determine if <Tag> is a filter/chip
38
+ * Determine if `Tag` is a filter/chip
39
39
  */
40
40
  filter?: boolean;
41
41
  /**
@@ -56,18 +56,22 @@ export interface TagBaseProps {
56
56
  * 'md' (default) sizes.
57
57
  */
58
58
  size?: 'sm' | 'md';
59
+ /**
60
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
61
+ */
62
+ slug?: ReactNodeLike;
59
63
  /**
60
64
  * Text to show on clear filters
61
65
  */
62
66
  title?: string;
63
67
  /**
64
- * Specify the type of the <Tag>
68
+ * Specify the type of the `Tag`
65
69
  */
66
70
  type?: keyof typeof TYPES;
67
71
  }
68
72
  export type TagProps<T extends React.ElementType> = PolymorphicProps<T, TagBaseProps>;
69
73
  declare const Tag: {
70
- <T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, ...other }: TagProps<T>): JSX.Element;
74
+ <T extends React.ElementType<any>>({ children, className, id, type, filter, renderIcon: CustomIconElement, title, disabled, onClose, size, as: BaseComponent, slug, ...other }: TagProps<T>): JSX.Element;
71
75
  propTypes: {
72
76
  /**
73
77
  * Provide an alternative tag or component to use instead of the default
@@ -75,7 +79,7 @@ declare const Tag: {
75
79
  */
76
80
  as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
77
81
  /**
78
- * Provide content to be rendered inside of a <Tag>
82
+ * Provide content to be rendered inside of a `Tag`
79
83
  */
80
84
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
81
85
  /**
@@ -83,11 +87,11 @@ declare const Tag: {
83
87
  */
84
88
  className: PropTypes.Requireable<string>;
85
89
  /**
86
- * Specify if the <Tag> is disabled
90
+ * Specify if the `Tag` is disabled
87
91
  */
88
92
  disabled: PropTypes.Requireable<boolean>;
89
93
  /**
90
- * Determine if <Tag> is a filter/chip
94
+ * Determine if `Tag` is a filter/chip
91
95
  */
92
96
  filter: PropTypes.Requireable<boolean>;
93
97
  /**
@@ -108,12 +112,16 @@ declare const Tag: {
108
112
  * 'md' (default) sizes.
109
113
  */
110
114
  size: PropTypes.Requireable<string>;
115
+ /**
116
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
117
+ */
118
+ slug: PropTypes.Requireable<PropTypes.ReactNodeLike>;
111
119
  /**
112
120
  * Text to show on clear filters
113
121
  */
114
122
  title: PropTypes.Requireable<string>;
115
123
  /**
116
- * Specify the type of the <Tag>
124
+ * Specify the type of the `Tag`
117
125
  */
118
126
  type: PropTypes.Requireable<string>;
119
127
  };
@@ -44,6 +44,7 @@ const Tag = _ref => {
44
44
  onClose,
45
45
  size,
46
46
  as: BaseComponent,
47
+ slug,
47
48
  ...other
48
49
  } = _ref;
49
50
  const prefix = usePrefix();
@@ -64,15 +65,26 @@ const Tag = _ref => {
64
65
  onClose(event);
65
66
  }
66
67
  };
68
+
69
+ // Slug is always size `md` and `inline`
70
+ let normalizedSlug;
71
+ if (slug && slug['type']?.displayName === 'Slug') {
72
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
73
+ size: 'sm',
74
+ kind: 'inline'
75
+ });
76
+ }
67
77
  if (filter) {
68
78
  const ComponentTag = BaseComponent ?? 'div';
69
79
  return /*#__PURE__*/React__default.createElement(ComponentTag, _extends({
70
80
  className: tagClasses,
71
81
  id: tagId
72
- }, other), /*#__PURE__*/React__default.createElement(Text, {
82
+ }, other), CustomIconElement ? /*#__PURE__*/React__default.createElement("div", {
83
+ className: `${prefix}--tag__custom-icon`
84
+ }, /*#__PURE__*/React__default.createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default.createElement(Text, {
73
85
  className: `${prefix}--tag__label`,
74
86
  title: typeof children === 'string' ? children : undefined
75
- }, children !== null && children !== undefined ? children : typeText), /*#__PURE__*/React__default.createElement("button", {
87
+ }, children !== null && children !== undefined ? children : typeText), normalizedSlug, /*#__PURE__*/React__default.createElement("button", {
76
88
  type: "button",
77
89
  className: `${prefix}--tag__close-icon`,
78
90
  onClick: handleClose,
@@ -90,7 +102,7 @@ const Tag = _ref => {
90
102
  className: `${prefix}--tag__custom-icon`
91
103
  }, /*#__PURE__*/React__default.createElement(CustomIconElement, null)) : '', /*#__PURE__*/React__default.createElement(Text, {
92
104
  title: typeof children === 'string' ? children : undefined
93
- }, children !== null && children !== undefined ? children : typeText));
105
+ }, children !== null && children !== undefined ? children : typeText), normalizedSlug);
94
106
  };
95
107
  Tag.propTypes = {
96
108
  /**
@@ -99,7 +111,7 @@ Tag.propTypes = {
99
111
  */
100
112
  as: PropTypes.elementType,
101
113
  /**
102
- * Provide content to be rendered inside of a <Tag>
114
+ * Provide content to be rendered inside of a `Tag`
103
115
  */
104
116
  children: PropTypes.node,
105
117
  /**
@@ -107,11 +119,11 @@ Tag.propTypes = {
107
119
  */
108
120
  className: PropTypes.string,
109
121
  /**
110
- * Specify if the <Tag> is disabled
122
+ * Specify if the `Tag` is disabled
111
123
  */
112
124
  disabled: PropTypes.bool,
113
125
  /**
114
- * Determine if <Tag> is a filter/chip
126
+ * Determine if `Tag` is a filter/chip
115
127
  */
116
128
  filter: PropTypes.bool,
117
129
  /**
@@ -132,12 +144,16 @@ Tag.propTypes = {
132
144
  * 'md' (default) sizes.
133
145
  */
134
146
  size: PropTypes.oneOf(['sm', 'md']),
147
+ /**
148
+ * **Experimental:** Provide a `Slug` component to be rendered inside the `Tag` component
149
+ */
150
+ slug: PropTypes.node,
135
151
  /**
136
152
  * Text to show on clear filters
137
153
  */
138
154
  title: PropTypes.string,
139
155
  /**
140
- * Specify the type of the <Tag>
156
+ * Specify the type of the `Tag`
141
157
  */
142
158
  type: PropTypes.oneOf(Object.keys(TYPES))
143
159
  };
@@ -226,7 +226,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
226
226
 
227
227
  // Slug is always size `mini`
228
228
  let normalizedSlug;
229
- if (slug) {
229
+ if (slug && slug['type']?.displayName === 'Slug') {
230
230
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
231
231
  size: 'mini'
232
232
  });
@@ -157,7 +157,7 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
157
157
 
158
158
  // Slug is always size `mini`
159
159
  let normalizedSlug;
160
- if (slug) {
160
+ if (slug && slug['type']?.displayName === 'Slug') {
161
161
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
162
162
  size: 'mini'
163
163
  });
@@ -269,7 +269,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
269
269
  // Slug is always size `xs`
270
270
  const slugRef = useRef(null);
271
271
  let normalizedSlug;
272
- if (slug) {
272
+ if (slug && slug['type']?.displayName === 'Slug') {
273
273
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
274
274
  size: 'xs',
275
275
  ref: slugRef
@@ -494,7 +494,7 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
494
494
 
495
495
  // Slug is always size `xs`
496
496
  let normalizedSlug;
497
- if (slug) {
497
+ if (slug && slug['type']?.displayName === 'Slug') {
498
498
  normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
499
499
  size: 'xs'
500
500
  });
@@ -60,7 +60,7 @@ const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
60
60
  switcherItem.focus();
61
61
  }
62
62
  };
63
- const childrenWithProps = React__default.Children.map(children, (child, index) => {
63
+ const childrenWithProps = React__default.Children.toArray(children).map((child, index) => {
64
64
  // only setup click handlers if onChange event is passed
65
65
  if ( /*#__PURE__*/React__default.isValidElement(child) && child.type && getDisplayName(child.type) === 'Switcher') {
66
66
  return /*#__PURE__*/React__default.cloneElement(child, {
@@ -57,7 +57,7 @@ function CheckboxGroup(_ref) {
57
57
 
58
58
  // Slug is always size `mini`
59
59
  let normalizedSlug;
60
- if (slug) {
60
+ if (slug && slug['type']?.displayName === 'Slug') {
61
61
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
62
62
  size: 'mini',
63
63
  kind: 'default'
@@ -268,7 +268,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
268
268
 
269
269
  // Slug is always size `mini`
270
270
  let normalizedSlug;
271
- if (slug) {
271
+ if (slug && slug['type']?.displayName === 'Slug') {
272
272
  normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
273
273
  size: 'mini'
274
274
  });