@carbon/react 1.84.0-rc.0 → 1.85.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 (177) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +943 -943
  2. package/es/components/AILabel/index.js +6 -1
  3. package/es/components/Checkbox/Checkbox.d.ts +2 -2
  4. package/es/components/Checkbox/Checkbox.js +8 -8
  5. package/es/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +9 -8
  7. package/es/components/CodeSnippet/CodeSnippet.js +2 -4
  8. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  9. package/es/components/ComboBox/ComboBox.js +8 -7
  10. package/es/components/ComposedModal/ComposedModal.d.ts +1 -1
  11. package/es/components/ComposedModal/ComposedModal.js +34 -12
  12. package/es/components/ContainedList/ContainedList.d.ts +1 -1
  13. package/es/components/ContainedList/ContainedList.js +4 -2
  14. package/es/components/ContentSwitcher/ContentSwitcher.js +6 -5
  15. package/es/components/DataTable/DataTable.js +3 -0
  16. package/es/components/DataTable/TableDecoratorRow.d.ts +2 -2
  17. package/es/components/DataTable/TableDecoratorRow.js +8 -8
  18. package/es/components/DataTable/TableExpandRow.d.ts +1 -1
  19. package/es/components/DataTable/TableExpandRow.js +15 -6
  20. package/es/components/DataTable/TableHeader.js +10 -10
  21. package/es/components/DataTable/TableRow.js +12 -4
  22. package/es/components/DataTable/tools/normalize.js +2 -1
  23. package/es/components/DatePickerInput/DatePickerInput.js +8 -7
  24. package/es/components/Dialog/index.d.ts +5 -1
  25. package/es/components/Dialog/index.js +20 -0
  26. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  27. package/es/components/Dropdown/Dropdown.js +8 -10
  28. package/es/components/FileUploader/FileUploaderButton.js +2 -2
  29. package/es/components/FileUploader/FileUploaderDropContainer.js +2 -2
  30. package/es/components/FileUploader/FileUploaderItem.js +2 -2
  31. package/es/components/Layer/index.d.ts +1 -3
  32. package/es/components/Layer/index.js +9 -8
  33. package/es/components/Menu/Menu.js +0 -6
  34. package/es/components/Modal/Modal.d.ts +2 -2
  35. package/es/components/Modal/Modal.js +39 -11
  36. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  37. package/es/components/MultiSelect/FilterableMultiSelect.js +29 -7
  38. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  39. package/es/components/MultiSelect/MultiSelect.js +8 -7
  40. package/es/components/NumberInput/NumberInput.d.ts +1 -1
  41. package/es/components/NumberInput/NumberInput.js +9 -8
  42. package/es/components/OverflowMenu/OverflowMenu.js +4 -5
  43. package/es/components/PageHeader/PageHeader.d.ts +10 -9
  44. package/es/components/PageHeader/PageHeader.js +94 -34
  45. package/es/components/PageHeader/index.d.ts +2 -2
  46. package/es/components/PageHeader/index.js +1 -1
  47. package/es/components/Popover/index.js +2 -1
  48. package/es/components/RadioButton/RadioButton.d.ts +2 -2
  49. package/es/components/RadioButton/RadioButton.js +8 -8
  50. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  51. package/es/components/RadioButtonGroup/RadioButtonGroup.js +9 -8
  52. package/es/components/RadioTile/RadioTile.d.ts +1 -1
  53. package/es/components/RadioTile/RadioTile.js +8 -7
  54. package/es/components/Search/Search.js +0 -1
  55. package/es/components/Select/Select.d.ts +2 -2
  56. package/es/components/Select/Select.js +8 -7
  57. package/es/components/Slider/Slider.js +6 -0
  58. package/es/components/Tag/DismissibleTag.d.ts +1 -1
  59. package/es/components/Tag/DismissibleTag.js +9 -8
  60. package/es/components/Tag/Tag.d.ts +1 -1
  61. package/es/components/Tag/Tag.js +9 -8
  62. package/es/components/TextArea/TextArea.js +12 -11
  63. package/es/components/TextInput/TextInput.d.ts +1 -1
  64. package/es/components/TextInput/TextInput.js +20 -9
  65. package/es/components/Tile/Tile.d.ts +2 -2
  66. package/es/components/Tile/Tile.js +30 -36
  67. package/es/components/TileGroup/TileGroup.d.ts +4 -4
  68. package/es/components/TileGroup/TileGroup.js +45 -53
  69. package/es/components/TileGroup/index.d.ts +3 -3
  70. package/es/components/Toggletip/index.js +2 -2
  71. package/es/components/Tooltip/DefinitionTooltip.js +1 -0
  72. package/es/components/TreeView/TreeNode.js +3 -3
  73. package/es/components/TreeView/TreeView.js +3 -3
  74. package/es/components/UIShell/Content.d.ts +5 -3
  75. package/es/components/UIShell/HeaderMenuItem.js +2 -1
  76. package/es/components/UIShell/HeaderPanel.d.ts +2 -2
  77. package/es/components/UIShell/HeaderPanel.js +9 -5
  78. package/es/index.js +1 -1
  79. package/es/internal/Selection.js +8 -3
  80. package/es/internal/environment.js +1 -12
  81. package/es/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
  82. package/es/internal/useOverflowItems.d.ts +29 -0
  83. package/es/internal/useOverflowItems.js +122 -0
  84. package/es/internal/useResizeObserver.d.ts +1 -1
  85. package/es/internal/utils.d.ts +14 -0
  86. package/es/internal/utils.js +18 -0
  87. package/es/tools/uniqueId.d.ts +1 -6
  88. package/lib/components/AILabel/index.js +6 -1
  89. package/lib/components/Checkbox/Checkbox.d.ts +2 -2
  90. package/lib/components/Checkbox/Checkbox.js +7 -7
  91. package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +2 -2
  92. package/lib/components/CheckboxGroup/CheckboxGroup.js +8 -7
  93. package/lib/components/CodeSnippet/CodeSnippet.js +2 -4
  94. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  95. package/lib/components/ComboBox/ComboBox.js +11 -10
  96. package/lib/components/ComposedModal/ComposedModal.d.ts +1 -1
  97. package/lib/components/ComposedModal/ComposedModal.js +35 -13
  98. package/lib/components/ContainedList/ContainedList.d.ts +1 -1
  99. package/lib/components/ContainedList/ContainedList.js +4 -2
  100. package/lib/components/ContentSwitcher/ContentSwitcher.js +5 -4
  101. package/lib/components/DataTable/DataTable.js +3 -0
  102. package/lib/components/DataTable/TableDecoratorRow.d.ts +2 -2
  103. package/lib/components/DataTable/TableDecoratorRow.js +8 -8
  104. package/lib/components/DataTable/TableExpandRow.d.ts +1 -1
  105. package/lib/components/DataTable/TableExpandRow.js +14 -5
  106. package/lib/components/DataTable/TableHeader.js +9 -9
  107. package/lib/components/DataTable/TableRow.js +11 -3
  108. package/lib/components/DataTable/tools/normalize.js +2 -1
  109. package/lib/components/DatePickerInput/DatePickerInput.js +7 -6
  110. package/lib/components/Dialog/index.d.ts +5 -1
  111. package/lib/components/Dialog/index.js +20 -0
  112. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  113. package/lib/components/Dropdown/Dropdown.js +12 -14
  114. package/lib/components/FileUploader/FileUploaderButton.js +2 -2
  115. package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
  116. package/lib/components/FileUploader/FileUploaderItem.js +2 -2
  117. package/lib/components/Layer/index.d.ts +1 -3
  118. package/lib/components/Layer/index.js +9 -8
  119. package/lib/components/Menu/Menu.js +0 -6
  120. package/lib/components/Modal/Modal.d.ts +2 -2
  121. package/lib/components/Modal/Modal.js +47 -19
  122. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  123. package/lib/components/MultiSelect/FilterableMultiSelect.js +33 -11
  124. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  125. package/lib/components/MultiSelect/MultiSelect.js +13 -12
  126. package/lib/components/NumberInput/NumberInput.d.ts +1 -1
  127. package/lib/components/NumberInput/NumberInput.js +8 -7
  128. package/lib/components/OverflowMenu/OverflowMenu.js +4 -5
  129. package/lib/components/PageHeader/PageHeader.d.ts +10 -9
  130. package/lib/components/PageHeader/PageHeader.js +92 -34
  131. package/lib/components/PageHeader/index.d.ts +2 -2
  132. package/lib/components/PageHeader/index.js +0 -2
  133. package/lib/components/Popover/index.js +2 -1
  134. package/lib/components/RadioButton/RadioButton.d.ts +2 -2
  135. package/lib/components/RadioButton/RadioButton.js +7 -7
  136. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +2 -2
  137. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +10 -9
  138. package/lib/components/RadioTile/RadioTile.d.ts +1 -1
  139. package/lib/components/RadioTile/RadioTile.js +7 -6
  140. package/lib/components/Search/Search.js +0 -1
  141. package/lib/components/Select/Select.d.ts +2 -2
  142. package/lib/components/Select/Select.js +7 -6
  143. package/lib/components/Slider/Slider.js +6 -0
  144. package/lib/components/Tag/DismissibleTag.d.ts +1 -1
  145. package/lib/components/Tag/DismissibleTag.js +8 -7
  146. package/lib/components/Tag/Tag.d.ts +1 -1
  147. package/lib/components/Tag/Tag.js +8 -7
  148. package/lib/components/TextArea/TextArea.js +11 -10
  149. package/lib/components/TextInput/TextInput.d.ts +1 -1
  150. package/lib/components/TextInput/TextInput.js +19 -8
  151. package/lib/components/Tile/Tile.d.ts +2 -2
  152. package/lib/components/Tile/Tile.js +29 -35
  153. package/lib/components/TileGroup/TileGroup.d.ts +4 -4
  154. package/lib/components/TileGroup/TileGroup.js +44 -52
  155. package/lib/components/TileGroup/index.d.ts +3 -3
  156. package/lib/components/Toggletip/index.js +2 -2
  157. package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
  158. package/lib/components/TreeView/TreeNode.js +3 -3
  159. package/lib/components/TreeView/TreeView.js +3 -3
  160. package/lib/components/UIShell/Content.d.ts +5 -3
  161. package/lib/components/UIShell/HeaderMenuItem.js +2 -1
  162. package/lib/components/UIShell/HeaderPanel.d.ts +2 -2
  163. package/lib/components/UIShell/HeaderPanel.js +8 -4
  164. package/lib/index.js +1 -1
  165. package/lib/internal/Selection.js +8 -3
  166. package/lib/internal/environment.js +1 -12
  167. package/lib/internal/{__mocks__/mockHTMLElement.d.ts → index.d.ts} +2 -4
  168. package/lib/internal/useOverflowItems.d.ts +29 -0
  169. package/lib/internal/useOverflowItems.js +126 -0
  170. package/lib/internal/useResizeObserver.d.ts +1 -1
  171. package/lib/internal/utils.d.ts +14 -0
  172. package/lib/internal/utils.js +22 -0
  173. package/lib/tools/uniqueId.d.ts +1 -6
  174. package/package.json +14 -23
  175. package/telemetry.yml +3 -0
  176. package/es/tools/uniqueId.js +0 -14
  177. package/lib/tools/uniqueId.js +0 -18
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
- import React, { useRef, useState, useLayoutEffect, useEffect } from 'react';
9
+ import React, { useRef, useState, useLayoutEffect, useEffect, useMemo, useCallback } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -20,7 +20,14 @@ import { DefinitionTooltip } from '../Tooltip/DefinitionTooltip.js';
20
20
  import '../Tooltip/Tooltip.js';
21
21
  import AspectRatio from '../AspectRatio/AspectRatio.js';
22
22
  import { createOverflowHandler } from '@carbon/utilities';
23
- import { Tabs as Tabs$1 } from '../Tabs/Tabs.js';
23
+ import Tag from '../Tag/Tag.js';
24
+ import '../Tag/DismissibleTag.js';
25
+ import OperationalTag from '../Tag/OperationalTag.js';
26
+ import '../Tag/SelectableTag.js';
27
+ import '../Tag/Tag.Skeleton.js';
28
+ import useOverflowItems from '../../internal/useOverflowItems.js';
29
+ import { Popover, PopoverContent } from '../Popover/index.js';
30
+ import { useId } from '../../internal/useId.js';
24
31
  import '../Grid/FlexGrid.js';
25
32
  import { Grid as GridAsGridComponent } from '../Grid/Grid.js';
26
33
  import '../Grid/Row.js';
@@ -355,46 +362,101 @@ PageHeaderHeroImage.propTypes = {
355
362
  const PageHeaderTabBar = /*#__PURE__*/React.forwardRef(function PageHeaderTabBar({
356
363
  className,
357
364
  children,
365
+ tags = [],
358
366
  ...other
359
367
  }, ref) {
360
368
  const prefix = usePrefix();
361
369
  const classNames = cx({
362
370
  [`${prefix}--page-header__tab-bar`]: true
363
371
  }, className);
372
+ // Early return if no tags are provided
373
+ if (!tags.length) {
374
+ return /*#__PURE__*/React.createElement("div", _extends({
375
+ className: classNames,
376
+ ref: ref
377
+ }, other), /*#__PURE__*/React.createElement(GridAsGridComponent, null, /*#__PURE__*/React.createElement(Column, {
378
+ lg: 16,
379
+ md: 8,
380
+ sm: 4
381
+ }, children)));
382
+ }
383
+ const [openPopover, setOpenPopover] = useState(false);
384
+ const tagSize = tags[0]?.size || 'md';
385
+ const instanceId = useId('PageHeaderTabBar');
386
+ const tagsWithIds = useMemo(() => {
387
+ return tags.map((tag, index) => ({
388
+ ...tag,
389
+ id: tag.id || `tag-${index}-${instanceId}`
390
+ }));
391
+ }, [tags]);
392
+ const tagsContainerRef = useRef(null);
393
+ const offsetRef = useRef(null);
394
+ // To close popover when window resizes
395
+ useEffect(() => {
396
+ const handleResize = () => {
397
+ // Close the popover when window resizes to prevent unwanted opens
398
+ setOpenPopover(false);
399
+ };
400
+ window.addEventListener('resize', handleResize);
401
+ return () => {
402
+ window.removeEventListener('resize', handleResize);
403
+ };
404
+ }, []);
405
+
406
+ // overflow items hook
407
+ const {
408
+ visibleItems = [],
409
+ hiddenItems = [],
410
+ itemRefHandler = () => {}
411
+ } = useOverflowItems(tagsWithIds, tagsContainerRef, offsetRef) || {
412
+ visibleItems: [],
413
+ hiddenItems: [],
414
+ itemRefHandler: () => {}
415
+ };
416
+ const handleOverflowClick = useCallback(event => {
417
+ event.stopPropagation();
418
+ setOpenPopover(prev => !prev);
419
+ }, []);
420
+
421
+ // Function to render tags
422
+ const renderTags = () => /*#__PURE__*/React.createElement("div", {
423
+ className: `${prefix}--page-header__tags`,
424
+ ref: tagsContainerRef
425
+ }, visibleItems.map(tag => /*#__PURE__*/React.createElement(Tag, {
426
+ key: tag.id,
427
+ ref: node => itemRefHandler(tag.id, node),
428
+ type: tag.type,
429
+ size: tag.size,
430
+ className: `${prefix}--page-header__tag-item`
431
+ }, tag.text)), hiddenItems.length > 0 && /*#__PURE__*/React.createElement(Popover, {
432
+ open: openPopover,
433
+ onRequestClose: () => setOpenPopover(false)
434
+ }, /*#__PURE__*/React.createElement(OperationalTag, {
435
+ onClick: handleOverflowClick,
436
+ "aria-expanded": openPopover,
437
+ text: `+${hiddenItems.length}`,
438
+ size: tagSize
439
+ }), /*#__PURE__*/React.createElement(PopoverContent, {
440
+ className: "tag-popover-content"
441
+ }, /*#__PURE__*/React.createElement("div", {
442
+ className: `${prefix}--page-header__tags-popover-list`
443
+ }, hiddenItems.map(tag => /*#__PURE__*/React.createElement(Tag, {
444
+ key: tag.id,
445
+ type: tag.type,
446
+ size: tag.size
447
+ }, tag.text))))));
364
448
  return /*#__PURE__*/React.createElement("div", _extends({
365
449
  className: classNames,
366
450
  ref: ref
367
- }, other), children);
368
- });
369
- PageHeaderTabBar.displayName = 'PageHeaderTabBar';
370
- const PageHeaderTabs = /*#__PURE__*/React.forwardRef(function PageHeaderTabs({
371
- className,
372
- children,
373
- ...other
374
- }, ref) {
375
- const prefix = usePrefix();
376
- const childrenArray = React.Children.toArray(children);
377
- let tabListElement = null;
378
- const otherChildren = [];
379
-
380
- // extract the TabList component so we can wrap a needed div around for
381
- // layout purposes
382
- childrenArray.forEach(child => {
383
- if (child?.type?.displayName === 'TabList' || child?.type?.name === 'TabList') {
384
- tabListElement = child;
385
- } else {
386
- otherChildren.push(child);
387
- }
388
- });
389
- return /*#__PURE__*/React.createElement(Tabs$1, other, tabListElement && /*#__PURE__*/React.createElement("div", {
390
- className: `${prefix}--page-header__tablist-wrapper`
391
- }, /*#__PURE__*/React.createElement(GridAsGridComponent, null, /*#__PURE__*/React.createElement(Column, {
451
+ }, other), /*#__PURE__*/React.createElement(GridAsGridComponent, null, /*#__PURE__*/React.createElement(Column, {
392
452
  lg: 16,
393
453
  md: 8,
394
454
  sm: 4
395
- }, tabListElement))), otherChildren);
455
+ }, /*#__PURE__*/React.createElement("div", {
456
+ className: `${prefix}--page-header__tab-bar--tablist`
457
+ }, children, tags.length > 0 && renderTags()))));
396
458
  });
397
- PageHeaderTabs.displayName = 'PageHeaderTabs';
459
+ PageHeaderTabBar.displayName = 'PageHeaderTabBar';
398
460
 
399
461
  /**
400
462
  * -------
@@ -408,14 +470,12 @@ BreadcrumbBar.displayName = 'PageHeaderBreadcrumbBar';
408
470
  const Content = PageHeaderContent;
409
471
  Content.displayName = 'PageHeaderContent';
410
472
  const ContentPageActions = PageHeaderContentPageActions;
411
- Content.displayName = 'PageHeaderContentPageActions';
473
+ ContentPageActions.displayName = 'PageHeaderContentPageActions';
412
474
  const ContentText = PageHeaderContentText;
413
- Content.displayName = 'PageHeaderContentText';
475
+ ContentText.displayName = 'PageHeaderContentText';
414
476
  const HeroImage = PageHeaderHeroImage;
415
477
  HeroImage.displayName = 'PageHeaderHeroImage';
416
478
  const TabBar = PageHeaderTabBar;
417
479
  TabBar.displayName = 'PageHeaderTabBar';
418
- const Tabs = PageHeaderTabs;
419
- Tabs.displayName = 'PageHeader.Tabs';
420
480
 
421
- export { BreadcrumbBar, Content, ContentPageActions, ContentText, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderContentPageActions, PageHeaderContentText, PageHeaderHeroImage, PageHeaderTabBar, PageHeaderTabs, Root, TabBar, Tabs };
481
+ export { BreadcrumbBar, Content, ContentPageActions, ContentText, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderContentPageActions, PageHeaderContentText, PageHeaderHeroImage, PageHeaderTabBar, Root, TabBar };
@@ -4,5 +4,5 @@
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
- export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderContentPageActions, PageHeaderContentText, PageHeaderTabBar, PageHeaderHeroImage, PageHeaderTabs, Root, BreadcrumbBar, Content, ContentPageActions, ContentText, TabBar, HeroImage, Tabs, } from './PageHeader';
8
- export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderContentPageActionsProps, PageHeaderContentTextProps, PageHeaderTabBarProps, PageHeaderHeroImageProps, PageHeaderTabsProps, } from './PageHeader';
7
+ export { PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderContentPageActions, PageHeaderContentText, PageHeaderTabBar, PageHeaderHeroImage, Root, BreadcrumbBar, Content, ContentPageActions, ContentText, TabBar, HeroImage, } from './PageHeader';
8
+ export type { PageHeaderProps, PageHeaderBreadcrumbBarProps, PageHeaderContentProps, PageHeaderContentPageActionsProps, PageHeaderContentTextProps, PageHeaderTabBarProps, PageHeaderHeroImageProps, } from './PageHeader';
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- export { BreadcrumbBar, Content, ContentPageActions, ContentText, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderContentPageActions, PageHeaderContentText, PageHeaderHeroImage, PageHeaderTabBar, PageHeaderTabs, Root, TabBar, Tabs } from './PageHeader.js';
8
+ export { BreadcrumbBar, Content, ContentPageActions, ContentText, HeroImage, PageHeader, PageHeaderBreadcrumbBar, PageHeaderContent, PageHeaderContentPageActions, PageHeaderContentText, PageHeaderHeroImage, PageHeaderTabBar, Root, TabBar } from './PageHeader.js';
@@ -17,6 +17,7 @@ import { useWindowEvent } from '../../internal/useEvent.js';
17
17
  import { mapPopoverAlign } from '../../tools/mapPopoverAlign.js';
18
18
  import { useFloating, offset, flip, arrow, hide, autoUpdate } from '@floating-ui/react';
19
19
  import { useFeatureFlag } from '../FeatureFlags/index.js';
20
+ import { ToggletipButton } from '../Toggletip/index.js';
20
21
 
21
22
  const PopoverContext = /*#__PURE__*/React.createContext({
22
23
  setFloating: {
@@ -226,7 +227,7 @@ forwardRef) {
226
227
  // For a toggletip there is a specific trigger component, ToggletipButton.
227
228
  // In either of these cases we want to set this as the reference node for floating-ui autoAlign
228
229
  // positioning.
229
- if (enableFloatingStyles && item?.type?.displayName !== 'PopoverContent' || enableFloatingStyles && item?.type?.displayName === 'ToggletipButton') {
230
+ if (enableFloatingStyles && item?.type !== PopoverContent || enableFloatingStyles && item?.type === ToggletipButton) {
230
231
  // Set the reference element for floating-ui
231
232
  refs.setReference(node);
232
233
  }
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ReactNode } from 'react';
7
+ import React, { type ReactNode } from 'react';
8
8
  type ExcludedAttributes = 'onChange';
9
9
  export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
10
10
  /**
@@ -7,13 +7,15 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React, { useRef } from 'react';
10
+ import React, { useRef, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import '../Text/index.js';
13
13
  import deprecate from '../../prop-types/deprecate.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import { useId } from '../../internal/useId.js';
16
16
  import mergeRefs from '../../tools/mergeRefs.js';
17
+ import { AILabel } from '../AILabel/index.js';
18
+ import { isComponentElement } from '../../internal/utils.js';
17
19
  import { Text } from '../Text/Text.js';
18
20
 
19
21
  const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
@@ -47,13 +49,11 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
47
49
  [`${prefix}--radio-button-wrapper--decorator`]: decorator
48
50
  });
49
51
  const inputRef = useRef(null);
50
- let normalizedDecorator = /*#__PURE__*/React.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
51
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
52
- const size = normalizedDecorator.props?.['kind'] === 'inline' ? 'md' : 'mini';
53
- normalizedDecorator = /*#__PURE__*/React.cloneElement(normalizedDecorator, {
54
- size
55
- });
56
- }
52
+ const candidate = slug ?? decorator;
53
+ const candidateIsAILabel = isComponentElement(candidate, AILabel);
54
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
55
+ size: candidate.props?.['kind'] === 'inline' ? 'md' : 'mini'
56
+ }) : null;
57
57
  return /*#__PURE__*/React.createElement("div", {
58
58
  className: wrapperClasses
59
59
  }, /*#__PURE__*/React.createElement("input", _extends({}, rest, {
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ReactNode } from 'react';
7
+ import React, { type ReactNode } from 'react';
8
8
  import type { RadioButtonProps } from '../RadioButton';
9
9
  export declare const RadioButtonGroupContext: React.Context<null>;
10
10
  type ExcludedAttributes = 'onChange';
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React, { useState, useRef } from 'react';
10
+ import React, { useState, useRef, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { Legend } from '../Text/index.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -15,6 +15,8 @@ import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
15
15
  import deprecate from '../../prop-types/deprecate.js';
16
16
  import mergeRefs from '../../tools/mergeRefs.js';
17
17
  import { useId } from '../../internal/useId.js';
18
+ import { AILabel } from '../AILabel/index.js';
19
+ import { isComponentElement } from '../../internal/utils.js';
18
20
 
19
21
  const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
20
22
  const {
@@ -103,13 +105,12 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
103
105
  const divRef = useRef(null);
104
106
 
105
107
  // AILabel is always size `mini`
106
- let normalizedDecorator = /*#__PURE__*/React.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
107
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
108
- normalizedDecorator = /*#__PURE__*/React.cloneElement(normalizedDecorator, {
109
- size: 'mini',
110
- kind: 'default'
111
- });
112
- }
108
+ const candidate = slug ?? decorator;
109
+ const candidateIsAILabel = isComponentElement(candidate, AILabel);
110
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
111
+ size: 'mini',
112
+ kind: 'default'
113
+ }) : null;
113
114
  return /*#__PURE__*/React.createElement("div", {
114
115
  className: wrapperClasses,
115
116
  ref: mergeRefs(divRef, ref)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
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.
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import { RadioButtonChecked, RadioButton, CheckmarkFilled } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React from 'react';
12
+ import React, { cloneElement } from 'react';
13
13
  import { Enter, Space } from '../../internal/keyboard/keys.js';
14
14
  import { matches } from '../../internal/keyboard/match.js';
15
15
  import { useFallbackId } from '../../internal/useId.js';
@@ -18,6 +18,8 @@ import deprecate from '../../prop-types/deprecate.js';
18
18
  import { noopFn } from '../../internal/noopFn.js';
19
19
  import '../Text/index.js';
20
20
  import { useFeatureFlag } from '../FeatureFlags/index.js';
21
+ import { AILabel } from '../AILabel/index.js';
22
+ import { isComponentElement } from '../../internal/utils.js';
21
23
  import { Text } from '../Text/Text.js';
22
24
 
23
25
  var _RadioButtonChecked, _RadioButton, _CheckmarkFilled;
@@ -72,12 +74,11 @@ const RadioTile = /*#__PURE__*/React.forwardRef(function RadioTile({
72
74
  }
73
75
 
74
76
  // AILabel is always size `xs`
75
- let normalizedDecorator = /*#__PURE__*/React.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
76
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
77
- normalizedDecorator = /*#__PURE__*/React.cloneElement(normalizedDecorator, {
78
- size: 'xs'
79
- });
80
- }
77
+ const candidate = slug ?? decorator;
78
+ const candidateIsAILabel = isComponentElement(candidate, AILabel);
79
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
80
+ size: 'xs'
81
+ }) : null;
81
82
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", {
82
83
  checked: checked,
83
84
  className: `${prefix}--tile-input`,
@@ -134,7 +134,6 @@ const Search = /*#__PURE__*/React.forwardRef(function Search({
134
134
  "aria-label": placeholder,
135
135
  className: searchClasses
136
136
  }, /*#__PURE__*/React.createElement("div", {
137
- "aria-label": onExpand ? 'button' : undefined,
138
137
  "aria-labelledby": onExpand ? searchId : undefined,
139
138
  role: onExpand ? 'button' : undefined,
140
139
  className: `${prefix}--search-magnifier`,
@@ -1,10 +1,10 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ChangeEventHandler, ComponentPropsWithRef, ReactNode } from 'react';
7
+ import React, { type ChangeEventHandler, type ComponentPropsWithRef, type ReactNode } from 'react';
8
8
  type ExcludedAttributes = 'size';
9
9
  export interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttributes> {
10
10
  /**
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React, { useContext, useState } from 'react';
10
+ import React, { useContext, useState, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { ChevronDown, WarningFilled, WarningAltFilled } from '@carbon/icons-react';
13
13
  import deprecate from '../../prop-types/deprecate.js';
@@ -17,6 +17,8 @@ import { FormContext } from '../FluidForm/FormContext.js';
17
17
  import { useId } from '../../internal/useId.js';
18
18
  import { composeEventHandlers } from '../../tools/events.js';
19
19
  import '../Text/index.js';
20
+ import { AILabel } from '../AILabel/index.js';
21
+ import { isComponentElement } from '../../internal/utils.js';
20
22
  import { Text } from '../Text/Text.js';
21
23
 
22
24
  const Select = /*#__PURE__*/React.forwardRef(function Select({
@@ -134,12 +136,11 @@ const Select = /*#__PURE__*/React.forwardRef(function Select({
134
136
  };
135
137
 
136
138
  // AILabel always size `mini`
137
- let normalizedDecorator = /*#__PURE__*/React.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
138
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
139
- normalizedDecorator = /*#__PURE__*/React.cloneElement(normalizedDecorator, {
140
- size: 'mini'
141
- });
142
- }
139
+ const candidate = slug ?? decorator;
140
+ const candidateIsAILabel = isComponentElement(candidate, AILabel);
141
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
142
+ size: 'mini'
143
+ }) : null;
143
144
  const input = (() => {
144
145
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", _extends({}, other, ariaProps, {
145
146
  id: id,
@@ -758,6 +758,9 @@ class Slider extends PureComponent {
758
758
  valueUpper,
759
759
  leftUpper
760
760
  });
761
+ if (this.filledTrackRef.current) {
762
+ this.filledTrackRef.current.style.transform = this.state.isRtl ? `translate(${100 - this.state.leftUpper}%, -50%) scaleX(${(this.state.leftUpper - this.state.left) / 100})` : `translate(${this.state.left}%, -50%) scaleX(${(this.state.leftUpper - this.state.left) / 100})`;
763
+ }
761
764
  } else {
762
765
  const {
763
766
  value,
@@ -771,6 +774,9 @@ class Slider extends PureComponent {
771
774
  value,
772
775
  left
773
776
  });
777
+ if (this.filledTrackRef.current) {
778
+ this.filledTrackRef.current.style.transform = this.state.isRtl ? `translate(100%, -50%) scaleX(-${this.state.left / 100})` : `translate(0%, -50%) scaleX(${this.state.left / 100})`;
779
+ }
774
780
  }
775
781
  }
776
782
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ReactNode } from 'react';
7
+ import React, { type ReactNode } from 'react';
8
8
  import { PolymorphicProps } from '../../types/common';
9
9
  import { SIZES, TYPES } from './Tag';
10
10
  export interface DismissibleTagBaseProps {
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React, { forwardRef, useRef, useState, useLayoutEffect } from 'react';
10
+ import React, { forwardRef, useRef, useState, useLayoutEffect, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { useId } from '../../internal/useId.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -19,6 +19,8 @@ import { Tooltip } from '../Tooltip/Tooltip.js';
19
19
  import '../Text/index.js';
20
20
  import { isEllipsisActive } from './isEllipsisActive.js';
21
21
  import mergeRefs from '../../tools/mergeRefs.js';
22
+ import { AILabel } from '../AILabel/index.js';
23
+ import { isComponentElement } from '../../internal/utils.js';
22
24
  import { Text } from '../Text/Text.js';
23
25
 
24
26
  var _Close;
@@ -54,13 +56,12 @@ const DismissibleTag = /*#__PURE__*/forwardRef(({
54
56
  onClose(event);
55
57
  }
56
58
  };
57
- let normalizedDecorator = /*#__PURE__*/React.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
58
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
59
- normalizedDecorator = /*#__PURE__*/React.cloneElement(normalizedDecorator, {
60
- size: 'sm',
61
- kind: 'inline'
62
- });
63
- }
59
+ const candidate = slug ?? decorator;
60
+ const candidateIsAILabel = isComponentElement(candidate, AILabel);
61
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
62
+ size: 'sm',
63
+ kind: 'inline'
64
+ }) : null;
64
65
  const tooltipClasses = cx(`${prefix}--icon-tooltip`, `${prefix}--tag-label-tooltip`);
65
66
 
66
67
  // Removing onClick from the spread operator
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ReactNode } from 'react';
7
+ import React, { type ReactNode } from 'react';
8
8
  import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
9
9
  import { SelectableTagBaseProps } from './SelectableTag';
10
10
  import { OperationalTagBaseProps } from './OperationalTag';
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React, { useRef, useState, useLayoutEffect } from 'react';
10
+ import React, { useRef, useState, useLayoutEffect, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { Close } from '@carbon/icons-react';
13
13
  import { useId } from '../../internal/useId.js';
@@ -18,6 +18,8 @@ import { DefinitionTooltip } from '../Tooltip/DefinitionTooltip.js';
18
18
  import '../Tooltip/Tooltip.js';
19
19
  import { isEllipsisActive } from './isEllipsisActive.js';
20
20
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
21
+ import { AILabel } from '../AILabel/index.js';
22
+ import { isComponentElement } from '../../internal/utils.js';
21
23
  import { Text } from '../Text/Text.js';
22
24
 
23
25
  var _Close;
@@ -94,13 +96,12 @@ const TagBase = /*#__PURE__*/React.forwardRef(({
94
96
  };
95
97
 
96
98
  // AILabel is always size `sm` and `inline`
97
- let normalizedDecorator = /*#__PURE__*/React.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
98
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel' && !isInteractiveTag) {
99
- normalizedDecorator = /*#__PURE__*/React.cloneElement(normalizedDecorator, {
100
- size: 'sm',
101
- kind: 'inline'
102
- });
103
- }
99
+ const candidate = slug ?? decorator;
100
+ const candidateIsAILabel = isComponentElement(candidate, AILabel);
101
+ const normalizedDecorator = candidateIsAILabel && !isInteractiveTag ? /*#__PURE__*/cloneElement(candidate, {
102
+ size: 'sm',
103
+ kind: 'inline'
104
+ }) : null;
104
105
  if (filter) {
105
106
  const ComponentTag = BaseComponent ?? 'div';
106
107
  return /*#__PURE__*/React.createElement(ComponentTag, _extends({
@@ -7,7 +7,7 @@
7
7
 
8
8
  import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import PropTypes from 'prop-types';
10
- import React, { useContext, useRef, useState, useEffect, forwardRef } from 'react';
10
+ import React, { useContext, useRef, useState, useEffect, forwardRef, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import deprecate from '../../prop-types/deprecate.js';
13
13
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
@@ -20,6 +20,8 @@ import { useMergedRefs } from '../../internal/useMergedRefs.js';
20
20
  import { useId } from '../../internal/useId.js';
21
21
  import { noopFn } from '../../internal/noopFn.js';
22
22
  import '../Text/index.js';
23
+ import { AILabel } from '../AILabel/index.js';
24
+ import { isComponentElement } from '../../internal/utils.js';
23
25
  import { Text } from '../Text/Text.js';
24
26
 
25
27
  const frFn = forwardRef;
@@ -65,7 +67,7 @@ const TextArea = frFn((props, forwardRef) => {
65
67
  if (counterMode === 'character') {
66
68
  return strValue.length;
67
69
  } else {
68
- return strValue.match(/\w+/g)?.length || 0;
70
+ return strValue.match(/\p{L}+/gu)?.length || 0;
69
71
  }
70
72
  }
71
73
  const [textCount, setTextCount] = useState(getInitialTextCount());
@@ -97,8 +99,8 @@ const TextArea = frFn((props, forwardRef) => {
97
99
  onPaste: evt => {
98
100
  if (!disabled) {
99
101
  if (counterMode === 'word' && enableCounter && typeof maxCount !== 'undefined' && textareaRef.current !== null) {
100
- const existingWords = textareaRef.current.value.match(/\w+/g) || [];
101
- const pastedWords = evt.clipboardData.getData('Text').match(/\w+/g) || [];
102
+ const existingWords = textareaRef.current.value.match(/\p{L}+/gu) || [];
103
+ const pastedWords = evt.clipboardData.getData('Text').match(/\p{L}+/gu) || [];
102
104
  const totalWords = existingWords.length + pastedWords.length;
103
105
  if (totalWords > maxCount) {
104
106
  evt.preventDefault();
@@ -127,7 +129,7 @@ const TextArea = frFn((props, forwardRef) => {
127
129
  return;
128
130
  }
129
131
  if (enableCounter && typeof maxCount !== 'undefined' && textareaRef.current !== null) {
130
- const matchedWords = evt.target?.value?.match(/\w+/g);
132
+ const matchedWords = evt.target?.value?.match(/\p{L}+/gu);
131
133
  if (matchedWords && matchedWords.length <= maxCount) {
132
134
  textareaRef.current.removeAttribute('maxLength');
133
135
  setTimeout(() => {
@@ -258,12 +260,11 @@ const TextArea = frFn((props, forwardRef) => {
258
260
  }));
259
261
 
260
262
  // AILabel is always size `mini`
261
- let normalizedDecorator = /*#__PURE__*/React.isValidElement(slug ?? decorator) ? slug ?? decorator : null;
262
- if (normalizedDecorator && normalizedDecorator['type']?.displayName === 'AILabel') {
263
- normalizedDecorator = /*#__PURE__*/React.cloneElement(normalizedDecorator, {
264
- size: 'mini'
265
- });
266
- }
263
+ const candidate = slug ?? decorator;
264
+ const candidateIsAILabel = isComponentElement(candidate, AILabel);
265
+ const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
266
+ size: 'mini'
267
+ }) : null;
267
268
  return /*#__PURE__*/React.createElement("div", {
268
269
  className: formItemClasses
269
270
  }, /*#__PURE__*/React.createElement("div", {
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import React, { ReactNode } from 'react';
7
+ import React, { type ReactNode } from 'react';
8
8
  type ExcludedAttributes = 'defaultValue' | 'id' | 'size' | 'value';
9
9
  export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
10
10
  /**