@carbon/react 1.102.0-rc.0 → 1.103.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 (172) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +976 -976
  2. package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
  3. package/es/components/Button/Button.Skeleton.js +2 -1
  4. package/es/components/Button/Button.d.ts +4 -4
  5. package/es/components/Button/Button.js +4 -4
  6. package/es/components/Button/index.js +1 -1
  7. package/es/components/ButtonSet/ButtonSet.js +1 -1
  8. package/es/components/Checkbox/index.js +1 -1
  9. package/es/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  10. package/es/components/CheckboxGroup/CheckboxGroup.js +2 -2
  11. package/es/components/ComboBox/ComboBox.js +3 -4
  12. package/es/components/ComposedModal/ComposedModal.js +0 -3
  13. package/es/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
  14. package/es/components/ComposedModal/ComposedModalPresence.js +14 -1
  15. package/es/components/ComposedModal/index.d.ts +1 -1
  16. package/es/components/ContainedList/index.js +1 -1
  17. package/es/components/ContentSwitcher/ContentSwitcher.js +3 -2
  18. package/es/components/DataTable/TableExpandRow.js +2 -2
  19. package/es/components/DataTable/TableHeader.js +1 -1
  20. package/es/components/DataTable/TableRow.js +1 -1
  21. package/es/components/DataTable/TableToolbarMenu.js +1 -1
  22. package/es/components/DataTable/tools/normalize.js +2 -1
  23. package/es/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
  24. package/es/components/DatePicker/DatePicker.Skeleton.js +2 -2
  25. package/es/components/DatePicker/DatePicker.js +3 -2
  26. package/es/components/DatePicker/index.js +1 -1
  27. package/es/components/DatePickerInput/DatePickerInput.js +1 -1
  28. package/es/components/Dialog/Dialog.js +1 -1
  29. package/es/components/Dropdown/Dropdown.js +1 -3
  30. package/es/components/Dropdown/index.js +1 -1
  31. package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
  32. package/es/components/FeatureFlags/index.d.ts +8 -18
  33. package/es/components/FeatureFlags/index.js +23 -103
  34. package/es/components/FileUploader/FileUploader.Skeleton.js +1 -1
  35. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  36. package/es/components/FileUploader/FileUploaderButton.js +3 -7
  37. package/es/components/Icon/Icon.Skeleton.js +1 -1
  38. package/es/components/IconIndicator/index.js +1 -1
  39. package/es/components/Menu/MenuItem.js +1 -1
  40. package/es/components/Modal/ModalPresence.d.ts +9 -1
  41. package/es/components/Modal/ModalPresence.js +14 -1
  42. package/es/components/Modal/index.d.ts +2 -2
  43. package/es/components/MultiSelect/MultiSelect.js +9 -10
  44. package/es/components/Notification/Notification.js +1 -1
  45. package/es/components/NumberInput/NumberInput.js +15 -13
  46. package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -1
  47. package/es/components/OverflowMenu/OverflowMenu.js +3 -5
  48. package/es/components/OverflowMenuV2/index.js +1 -1
  49. package/es/components/PageHeader/PageHeader.js +2 -23
  50. package/es/components/Pagination/Pagination.Skeleton.js +1 -1
  51. package/es/components/Pagination/Pagination.d.ts +4 -0
  52. package/es/components/Pagination/Pagination.js +6 -1
  53. package/es/components/Pagination/experimental/Pagination.js +12 -1
  54. package/es/components/Popover/index.js +1 -1
  55. package/es/components/ProgressIndicator/ProgressIndicator.js +3 -3
  56. package/es/components/RadioButton/RadioButton.Skeleton.js +1 -1
  57. package/es/components/Search/index.js +1 -1
  58. package/es/components/Select/index.js +1 -1
  59. package/es/components/ShapeIndicator/index.js +1 -1
  60. package/es/components/Slider/Slider.d.ts +1 -1
  61. package/es/components/Slider/Slider.js +230 -255
  62. package/es/components/Slider/SliderHandles.js +65 -53
  63. package/es/components/Switch/IconSwitch.js +1 -1
  64. package/es/components/Tabs/Tabs.js +2 -6
  65. package/es/components/Tag/Tag.Skeleton.js +1 -1
  66. package/es/components/TextArea/TextArea.js +1 -1
  67. package/es/components/TextArea/index.js +1 -1
  68. package/es/components/TextInput/index.js +1 -1
  69. package/es/components/Tile/Tile.js +1 -1
  70. package/es/components/TileGroup/TileGroup.d.ts +1 -1
  71. package/es/components/TileGroup/TileGroup.js +2 -1
  72. package/es/components/Toggle/Toggle.Skeleton.js +1 -1
  73. package/es/components/Toggletip/index.js +1 -1
  74. package/es/components/UIShell/HeaderMenu.js +1 -1
  75. package/es/components/UIShell/HeaderPanel.js +3 -2
  76. package/es/components/UIShell/SideNav.d.ts +1 -4
  77. package/es/components/UIShell/SideNav.js +10 -25
  78. package/es/components/UIShell/SideNavContext.d.ts +17 -0
  79. package/es/components/UIShell/SideNavContext.js +24 -0
  80. package/es/components/UIShell/SideNavItems.d.ts +1 -1
  81. package/es/components/UIShell/SideNavItems.js +12 -16
  82. package/es/components/UIShell/SideNavLink.js +8 -4
  83. package/es/components/UIShell/SideNavMenu.js +7 -5
  84. package/es/components/UIShell/Switcher.js +5 -4
  85. package/es/index.js +30 -30
  86. package/es/internal/useNoInteractiveChildren.js +25 -30
  87. package/es/internal/useOverflowItems.d.ts +1 -5
  88. package/es/internal/useOverflowItems.js +6 -27
  89. package/es/internal/usePresence.d.ts +1 -1
  90. package/es/internal/usePresence.js +14 -17
  91. package/lib/components/Button/Button.Skeleton.js +2 -1
  92. package/lib/components/Button/Button.d.ts +4 -4
  93. package/lib/components/Button/Button.js +4 -4
  94. package/lib/components/Button/index.js +1 -1
  95. package/lib/components/ButtonSet/ButtonSet.js +1 -1
  96. package/lib/components/Checkbox/index.js +1 -1
  97. package/lib/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  98. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  99. package/lib/components/ComboBox/ComboBox.js +3 -4
  100. package/lib/components/ComposedModal/ComposedModal.js +0 -3
  101. package/lib/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
  102. package/lib/components/ComposedModal/ComposedModalPresence.js +14 -0
  103. package/lib/components/ComposedModal/index.d.ts +1 -1
  104. package/lib/components/ContainedList/index.js +0 -3
  105. package/lib/components/ContentSwitcher/ContentSwitcher.js +2 -1
  106. package/lib/components/DataTable/TableExpandRow.js +1 -1
  107. package/lib/components/DataTable/TableToolbarMenu.js +1 -1
  108. package/lib/components/DataTable/tools/normalize.js +2 -1
  109. package/lib/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
  110. package/lib/components/DatePicker/DatePicker.Skeleton.js +2 -2
  111. package/lib/components/DatePicker/DatePicker.js +3 -2
  112. package/lib/components/DatePicker/index.js +1 -1
  113. package/lib/components/Dropdown/Dropdown.js +1 -3
  114. package/lib/components/Dropdown/index.js +1 -1
  115. package/lib/components/FeatureFlags/index.d.ts +8 -18
  116. package/lib/components/FeatureFlags/index.js +21 -102
  117. package/lib/components/FileUploader/FileUploader.Skeleton.js +1 -1
  118. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  119. package/lib/components/FileUploader/FileUploaderButton.js +2 -6
  120. package/lib/components/Icon/Icon.Skeleton.js +0 -3
  121. package/lib/components/IconIndicator/index.js +0 -3
  122. package/lib/components/Modal/ModalPresence.d.ts +9 -1
  123. package/lib/components/Modal/ModalPresence.js +14 -0
  124. package/lib/components/Modal/index.d.ts +2 -2
  125. package/lib/components/MultiSelect/MultiSelect.js +8 -9
  126. package/lib/components/NumberInput/NumberInput.js +14 -12
  127. package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -1
  128. package/lib/components/OverflowMenu/OverflowMenu.js +2 -7
  129. package/lib/components/OverflowMenuV2/index.js +1 -1
  130. package/lib/components/PageHeader/PageHeader.js +2 -23
  131. package/lib/components/Pagination/Pagination.Skeleton.js +0 -3
  132. package/lib/components/Pagination/Pagination.d.ts +4 -0
  133. package/lib/components/Pagination/Pagination.js +6 -1
  134. package/lib/components/Pagination/experimental/Pagination.js +12 -1
  135. package/lib/components/ProgressIndicator/ProgressIndicator.js +3 -3
  136. package/lib/components/RadioButton/RadioButton.Skeleton.js +0 -3
  137. package/lib/components/Search/index.js +1 -1
  138. package/lib/components/Select/index.js +1 -1
  139. package/lib/components/ShapeIndicator/index.js +0 -3
  140. package/lib/components/Slider/Slider.d.ts +1 -1
  141. package/lib/components/Slider/Slider.js +229 -254
  142. package/lib/components/Slider/SliderHandles.js +64 -52
  143. package/lib/components/Tabs/Tabs.js +1 -5
  144. package/lib/components/Tag/Tag.Skeleton.js +0 -3
  145. package/lib/components/TextArea/index.js +1 -1
  146. package/lib/components/TextInput/index.js +1 -1
  147. package/lib/components/TileGroup/TileGroup.d.ts +1 -1
  148. package/lib/components/TileGroup/TileGroup.js +2 -1
  149. package/lib/components/Toggle/Toggle.Skeleton.js +0 -3
  150. package/lib/components/Toggletip/index.js +0 -3
  151. package/lib/components/UIShell/HeaderPanel.js +2 -1
  152. package/lib/components/UIShell/SideNav.d.ts +1 -4
  153. package/lib/components/UIShell/SideNav.js +8 -24
  154. package/lib/components/UIShell/SideNavContext.d.ts +17 -0
  155. package/lib/components/UIShell/SideNavContext.js +27 -0
  156. package/lib/components/UIShell/SideNavItems.d.ts +1 -1
  157. package/lib/components/UIShell/SideNavItems.js +11 -15
  158. package/lib/components/UIShell/SideNavLink.js +7 -3
  159. package/lib/components/UIShell/SideNavMenu.js +8 -6
  160. package/lib/components/UIShell/Switcher.js +4 -3
  161. package/lib/index.js +102 -100
  162. package/lib/internal/useNoInteractiveChildren.js +25 -30
  163. package/lib/internal/useOverflowItems.d.ts +1 -5
  164. package/lib/internal/useOverflowItems.js +6 -27
  165. package/lib/internal/usePresence.d.ts +1 -1
  166. package/lib/internal/usePresence.js +13 -16
  167. package/package.json +8 -8
  168. package/telemetry.yml +2 -1
  169. package/es/components/UIShell/_utils.d.ts +0 -7
  170. package/es/components/UIShell/_utils.js +0 -10
  171. package/lib/components/UIShell/_utils.d.ts +0 -7
  172. package/lib/components/UIShell/_utils.js +0 -12
@@ -7,8 +7,6 @@
7
7
 
8
8
  'use strict';
9
9
 
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
10
  var deprecateFieldOnObject = require('../../internal/deprecateFieldOnObject.js');
13
11
  var ContainedList = require('./ContainedList.js');
14
12
  var ContainedListItem = require('./ContainedListItem/ContainedListItem.js');
@@ -22,5 +20,4 @@ if (process.env.NODE_ENV !== 'production') {
22
20
  }
23
21
 
24
22
  exports.ContainedList = ContainedList.default;
25
- exports.default = ContainedList.default;
26
23
  exports.ContainedListItem = ContainedListItem.default;
@@ -18,6 +18,7 @@ var keys = require('../../internal/keyboard/keys.js');
18
18
  var match = require('../../internal/keyboard/match.js');
19
19
  var navigation = require('../../internal/keyboard/navigation.js');
20
20
  var usePrefix = require('../../internal/usePrefix.js');
21
+ var utils = require('../../internal/utils.js');
21
22
  require('../Switch/Switch.js');
22
23
  var IconSwitch = require('../Switch/IconSwitch.js');
23
24
 
@@ -83,7 +84,7 @@ const ContentSwitcher = ({
83
84
  }
84
85
  };
85
86
  const isIconOnly = React.Children.map(children, child => {
86
- return /*#__PURE__*/React.isValidElement(child) ? child.type === IconSwitch.default : null;
87
+ return utils.isComponentElement(child, IconSwitch.default);
87
88
  })?.every(val => val === true);
88
89
  const classes = cx(`${prefix}--content-switcher`, className, {
89
90
  [`${prefix}--content-switcher--light`]: light,
@@ -54,7 +54,7 @@ const TableExpandRow = /*#__PURE__*/React.forwardRef(({
54
54
  }
55
55
  });
56
56
  const normalizedChildren = React.Children.toArray(children).map(child => {
57
- if (/*#__PURE__*/React.isValidElement(child) && child.type !== TableSlugRow.default && child.type !== TableDecoratorRow.default) {
57
+ if (!utils.isComponentElement(child, TableSlugRow.default) && !utils.isComponentElement(child, TableDecoratorRow.default)) {
58
58
  return child;
59
59
  }
60
60
  });
@@ -29,7 +29,7 @@ const TableToolbarMenu = ({
29
29
  const prefix = usePrefix.usePrefix();
30
30
  const toolbarActionClasses = cx(className, `${prefix}--toolbar-action ${prefix}--overflow-menu`);
31
31
  const menuOptionsClasses = cx(menuOptionsClass, `${prefix}--toolbar-action__menu`);
32
- return /*#__PURE__*/React.createElement(index.default, _rollupPluginBabelHelpers.extends({
32
+ return /*#__PURE__*/React.createElement(index.OverflowMenu, _rollupPluginBabelHelpers.extends({
33
33
  renderIcon: renderIcon,
34
34
  className: toolbarActionClasses,
35
35
  title: iconDescription,
@@ -10,6 +10,7 @@
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
12
  var index = require('../../AILabel/index.js');
13
+ var utils = require('../../../internal/utils.js');
13
14
  var cells = require('./cells.js');
14
15
 
15
16
  /**
@@ -64,7 +65,7 @@ const normalize = (rows, headers, prevState = {}) => {
64
65
  isEditing: false,
65
66
  isValid: true,
66
67
  errors: null,
67
- hasAILabelHeader: !!(slug || decorator?.type === index.AILabel),
68
+ hasAILabelHeader: !!(slug || utils.isComponentElement(decorator, index.AILabel)),
68
69
  info: {
69
70
  header: key
70
71
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2026
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.
@@ -7,11 +7,14 @@
7
7
  import PropTypes from 'prop-types';
8
8
  import { type HTMLAttributes } from 'react';
9
9
  export interface DatePickerSkeletonProps extends HTMLAttributes<HTMLDivElement> {
10
- range?: boolean;
11
10
  /**
12
- * Specify whether the label should be hidden, or not
11
+ * Specify whether to hide the label.
13
12
  */
14
13
  hideLabel?: boolean;
14
+ /**
15
+ * Specify whether to render the range skeleton variant.
16
+ */
17
+ range?: boolean;
15
18
  }
16
19
  declare const DatePickerSkeleton: {
17
20
  ({ range, id, hideLabel, className, ...rest }: DatePickerSkeletonProps): import("react/jsx-runtime").JSX.Element;
@@ -21,7 +24,7 @@ declare const DatePickerSkeleton: {
21
24
  */
22
25
  className: PropTypes.Requireable<string>;
23
26
  /**
24
- * Specify whether the label should be hidden, or not
27
+ * Specify whether to hide the label.
25
28
  */
26
29
  hideLabel: PropTypes.Requireable<boolean>;
27
30
  /**
@@ -29,7 +32,7 @@ declare const DatePickerSkeleton: {
29
32
  */
30
33
  id: PropTypes.Requireable<string>;
31
34
  /**
32
- * Specify whether the skeleton should be of range date picker.
35
+ * Specify whether to render the range skeleton variant.
33
36
  */
34
37
  range: PropTypes.Requireable<boolean>;
35
38
  };
@@ -50,7 +50,7 @@ DatePickerSkeleton.propTypes = {
50
50
  */
51
51
  className: PropTypes.string,
52
52
  /**
53
- * Specify whether the label should be hidden, or not
53
+ * Specify whether to hide the label.
54
54
  */
55
55
  hideLabel: PropTypes.bool,
56
56
  /**
@@ -58,7 +58,7 @@ DatePickerSkeleton.propTypes = {
58
58
  */
59
59
  id: PropTypes.string,
60
60
  /**
61
- * Specify whether the skeleton should be of range date picker.
61
+ * Specify whether to render the range skeleton variant.
62
62
  */
63
63
  range: PropTypes.bool
64
64
  };
@@ -22,6 +22,7 @@ var rangePlugin = require('./plugins/rangePlugin.js');
22
22
  var deprecate = require('../../prop-types/deprecate.js');
23
23
  var keys = require('../../internal/keyboard/keys.js');
24
24
  var match = require('../../internal/keyboard/match.js');
25
+ var utils = require('../../internal/utils.js');
25
26
  var usePrefix = require('../../internal/usePrefix.js');
26
27
  var useSavedCallback = require('../../internal/useSavedCallback.js');
27
28
  require('../FluidForm/FluidForm.js');
@@ -246,7 +247,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
246
247
  const childrenWithProps = React.Children.toArray(children).map(
247
248
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
248
249
  (child, index) => {
249
- if (index === 0 && child.type === /*#__PURE__*/React.createElement(DatePickerInput.default, child.props).type) {
250
+ if (index === 0 && utils.isComponentElement(child, DatePickerInput.default)) {
250
251
  return /*#__PURE__*/React.cloneElement(child, {
251
252
  datePickerType,
252
253
  ref: startInputField,
@@ -255,7 +256,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
255
256
  warn: effectiveWarn
256
257
  });
257
258
  }
258
- if (index === 1 && child.type === /*#__PURE__*/React.createElement(DatePickerInput.default, child.props).type) {
259
+ if (index === 1 && utils.isComponentElement(child, DatePickerInput.default)) {
259
260
  return /*#__PURE__*/React.cloneElement(child, {
260
261
  datePickerType,
261
262
  ref: endInputField,
@@ -16,4 +16,4 @@ var DatePicker_Skeleton = require('./DatePicker.Skeleton.js');
16
16
 
17
17
  exports.DatePicker = DatePicker.default;
18
18
  exports.default = DatePicker.default;
19
- exports.DatePickerSkeleton = DatePicker_Skeleton.default;
19
+ exports.DatePickerSkeleton = DatePicker_Skeleton.DatePickerSkeleton;
@@ -176,9 +176,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
176
176
  const {
177
177
  highlightedIndex
178
178
  } = changes;
179
- if (highlightedIndex !== undefined && highlightedIndex > -1 &&
180
- // eslint-disable-next-line valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20452
181
- typeof window !== undefined) {
179
+ if (highlightedIndex !== undefined && highlightedIndex > -1) {
182
180
  const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
183
181
  const highlightedItem = itemArray[highlightedIndex];
184
182
  if (highlightedItem) {
@@ -16,4 +16,4 @@ var Dropdown_Skeleton = require('./Dropdown.Skeleton.js');
16
16
 
17
17
  exports.Dropdown = Dropdown.default;
18
18
  exports.default = Dropdown.default;
19
- exports.DropdownSkeleton = Dropdown_Skeleton.default;
19
+ exports.DropdownSkeleton = Dropdown_Skeleton.DropdownSkeleton;
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Copyright IBM Corp. 2015, 2025
2
+ * Copyright IBM Corp. 2015, 2026
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
7
  import PropTypes from 'prop-types';
8
- import React, { ReactNode, type JSX } from 'react';
8
+ import { type ReactNode } from 'react';
9
9
  export interface FeatureFlagsProps {
10
10
  children?: ReactNode;
11
11
  flags?: Record<string, boolean>;
@@ -20,19 +20,14 @@ export interface FeatureFlagsProps {
20
20
  enableEnhancedFileUploader?: boolean;
21
21
  enablePresence?: boolean;
22
22
  }
23
- /**
24
- * Our FeatureFlagContext is used alongside the FeatureFlags component to enable
25
- * or disable feature flags in a given React tree
26
- */
27
- declare const FeatureFlagContext: React.Context<any>;
28
23
  /**
29
24
  * Supports an object of feature flag values with the `flags` prop, merging them
30
25
  * along with the current `FeatureFlagContext` to provide consumers to check if
31
26
  * a feature flag is enabled or disabled in a given React tree
32
27
  */
33
- declare function FeatureFlags({ children, flags, enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence, }: FeatureFlagsProps): JSX.Element;
34
- declare namespace FeatureFlags {
35
- var propTypes: {
28
+ export declare const FeatureFlags: {
29
+ ({ children, flags, enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence, }: FeatureFlagsProps): import("react/jsx-runtime").JSX.Element;
30
+ propTypes: {
36
31
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
37
32
  /**
38
33
  * Provide the feature flags to enabled or disabled in the current Rea,ct tree
@@ -49,18 +44,13 @@ declare namespace FeatureFlags {
49
44
  enableEnhancedFileUploader: PropTypes.Requireable<boolean>;
50
45
  enablePresence: PropTypes.Requireable<boolean>;
51
46
  };
52
- }
47
+ };
53
48
  /**
54
49
  * Access whether a given flag is enabled or disabled in a given
55
50
  * FeatureFlagContext
56
- *
57
- * @returns {boolean}
58
51
  */
59
- declare function useFeatureFlag(flag: any): any;
52
+ export declare const useFeatureFlag: (flag: string) => boolean;
60
53
  /**
61
54
  * Access all feature flag information for the given FeatureFlagContext
62
- *
63
- * @returns {FeatureFlagScope}
64
55
  */
65
- declare function useFeatureFlags(): any;
66
- export { FeatureFlags, FeatureFlagContext, useFeatureFlags, useFeatureFlag };
56
+ export declare const useFeatureFlags: () => import("@carbon/feature-flags/types/FeatureFlagScope").FeatureFlagScope;
@@ -12,7 +12,6 @@ var PropTypes = require('prop-types');
12
12
  var React = require('react');
13
13
  var deprecate = require('../../prop-types/deprecate.js');
14
14
 
15
- // TODO: Can this variable be deleted now? It isn't used anywhere.
16
15
  /**
17
16
  * Our FeatureFlagContext is used alongside the FeatureFlags component to enable
18
17
  * or disable feature flags in a given React tree
@@ -24,7 +23,7 @@ const FeatureFlagContext = /*#__PURE__*/React.createContext(featureFlags.Feature
24
23
  * along with the current `FeatureFlagContext` to provide consumers to check if
25
24
  * a feature flag is enabled or disabled in a given React tree
26
25
  */
27
- function FeatureFlags({
26
+ const FeatureFlags = ({
28
27
  children,
29
28
  flags = {},
30
29
  enableV12TileDefaultIcons = false,
@@ -37,46 +36,30 @@ function FeatureFlags({
37
36
  enableV12DynamicFloatingStyles = false,
38
37
  enableEnhancedFileUploader = false,
39
38
  enablePresence = false
40
- }) {
39
+ }) => {
41
40
  const parentScope = React.useContext(FeatureFlagContext);
42
- const [prevParentScope, setPrevParentScope] = React.useState(parentScope);
43
- const combinedFlags = {
44
- 'enable-v12-tile-default-icons': enableV12TileDefaultIcons,
45
- 'enable-v12-tile-radio-icons': enableV12TileRadioIcons,
46
- 'enable-v12-overflowmenu': enableV12Overflowmenu,
47
- 'enable-treeview-controllable': enableTreeviewControllable,
48
- 'enable-experimental-focus-wrap-without-sentinels': enableExperimentalFocusWrapWithoutSentinels,
49
- 'enable-focus-wrap-without-sentinels': enableFocusWrapWithoutSentinels,
50
- 'enable-dialog-element': enableDialogElement,
51
- 'enable-v12-dynamic-floating-styles': enableV12DynamicFloatingStyles,
52
- 'enable-enhanced-file-uploader': enableEnhancedFileUploader,
53
- 'enable-presence': enablePresence,
54
- ...flags
55
- };
56
- const [scope, updateScope] = React.useState(() => {
41
+ const scope = React.useMemo(() => {
42
+ const combinedFlags = {
43
+ 'enable-v12-tile-default-icons': enableV12TileDefaultIcons,
44
+ 'enable-v12-tile-radio-icons': enableV12TileRadioIcons,
45
+ 'enable-v12-overflowmenu': enableV12Overflowmenu,
46
+ 'enable-treeview-controllable': enableTreeviewControllable,
47
+ 'enable-experimental-focus-wrap-without-sentinels': enableExperimentalFocusWrapWithoutSentinels,
48
+ 'enable-focus-wrap-without-sentinels': enableFocusWrapWithoutSentinels,
49
+ 'enable-dialog-element': enableDialogElement,
50
+ 'enable-v12-dynamic-floating-styles': enableV12DynamicFloatingStyles,
51
+ 'enable-enhanced-file-uploader': enableEnhancedFileUploader,
52
+ 'enable-presence': enablePresence,
53
+ ...flags
54
+ };
57
55
  const scope = featureFlags.createScope(combinedFlags);
58
56
  scope.mergeWithScope(parentScope);
59
57
  return scope;
60
- });
61
- if (parentScope !== prevParentScope) {
62
- const scope = featureFlags.createScope(combinedFlags);
63
- scope.mergeWithScope(parentScope);
64
- updateScope(scope);
65
- setPrevParentScope(parentScope);
66
- }
67
-
68
- // We use a custom hook to detect if any of the keys or their values change
69
- // for flags that are passed in. If they have changed, then we re-create the
70
- // FeatureFlagScope using the new flags
71
- useChangedValue(combinedFlags, isEqual, changedFlags => {
72
- const scope = featureFlags.createScope(changedFlags);
73
- scope.mergeWithScope(parentScope);
74
- updateScope(scope);
75
- });
58
+ }, [enableV12TileDefaultIcons, enableV12TileRadioIcons, enableV12Overflowmenu, enableTreeviewControllable, enableExperimentalFocusWrapWithoutSentinels, enableFocusWrapWithoutSentinels, enableDialogElement, enableV12DynamicFloatingStyles, enableEnhancedFileUploader, enablePresence, flags, parentScope]);
76
59
  return /*#__PURE__*/React.createElement(FeatureFlagContext.Provider, {
77
60
  value: scope
78
61
  }, children);
79
- }
62
+ };
80
63
  FeatureFlags.propTypes = {
81
64
  children: PropTypes.node,
82
65
  /**
@@ -95,84 +78,20 @@ FeatureFlags.propTypes = {
95
78
  enablePresence: PropTypes.bool
96
79
  };
97
80
 
98
- /**
99
- * This hook will store previous versions of the given `value` and compare the
100
- * current value to the previous one using the `compare` function. If the
101
- * compare function returns true, then the given `callback` is invoked in an
102
- * effect.
103
- *
104
- * @param {any} value
105
- * @param {Function} compare
106
- * @param {Function} callback
107
- */
108
- function useChangedValue(value, compare, callback) {
109
- const initialRender = React.useRef(false);
110
- const savedCallback = React.useRef(callback);
111
- const [prevValue, setPrevValue] = React.useState(value);
112
- if (!compare(prevValue, value)) {
113
- setPrevValue(value);
114
- }
115
- React.useEffect(() => {
116
- savedCallback.current = callback;
117
- });
118
- React.useEffect(() => {
119
- // We only want the callback triggered after the first render
120
- if (initialRender.current) {
121
- savedCallback.current(prevValue);
122
- }
123
- }, [prevValue]);
124
- React.useEffect(() => {
125
- initialRender.current = true;
126
- }, []);
127
- }
128
-
129
81
  /**
130
82
  * Access whether a given flag is enabled or disabled in a given
131
83
  * FeatureFlagContext
132
- *
133
- * @returns {boolean}
134
84
  */
135
- function useFeatureFlag(flag) {
85
+ const useFeatureFlag = flag => {
136
86
  const scope = React.useContext(FeatureFlagContext);
137
87
  return scope.enabled(flag);
138
- }
88
+ };
139
89
 
140
90
  /**
141
91
  * Access all feature flag information for the given FeatureFlagContext
142
- *
143
- * @returns {FeatureFlagScope}
144
- */
145
- function useFeatureFlags() {
146
- return React.useContext(FeatureFlagContext);
147
- }
148
-
149
- /**
150
- * Compare two objects and determine if they are equal. This is a shallow
151
- * comparison since the objects we are comparing are objects with boolean flags
152
- * from the flags prop in the `FeatureFlags` component
153
- *
154
- * @param {object} a
155
- * @param {object} b
156
- * @returns {boolean}
157
92
  */
158
- function isEqual(a, b) {
159
- if (a === b) {
160
- return true;
161
- }
162
- for (const key of Object.keys(a)) {
163
- if (a[key] !== b[key]) {
164
- return false;
165
- }
166
- }
167
- for (const key of Object.keys(b)) {
168
- if (b[key] !== a[key]) {
169
- return false;
170
- }
171
- }
172
- return true;
173
- }
93
+ const useFeatureFlags = () => React.useContext(FeatureFlagContext);
174
94
 
175
- exports.FeatureFlagContext = FeatureFlagContext;
176
95
  exports.FeatureFlags = FeatureFlags;
177
96
  exports.useFeatureFlag = useFeatureFlag;
178
97
  exports.useFeatureFlags = useFeatureFlags;
@@ -31,7 +31,7 @@ function FileUploaderSkeleton({
31
31
  })), /*#__PURE__*/React.createElement(SkeletonText.default, {
32
32
  width: "225px",
33
33
  className: `${prefix}--label-description`
34
- }), _ButtonSkeleton || (_ButtonSkeleton = /*#__PURE__*/React.createElement(Button_Skeleton.default, null)));
34
+ }), _ButtonSkeleton || (_ButtonSkeleton = /*#__PURE__*/React.createElement(Button_Skeleton.ButtonSkeleton, null)));
35
35
  }
36
36
  FileUploaderSkeleton.propTypes = {
37
37
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2025
2
+ * Copyright IBM Corp. 2016, 2026
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.
@@ -39,7 +39,6 @@ function FileUploaderButton({
39
39
  }) {
40
40
  const prefix = usePrefix.usePrefix();
41
41
  const [labelText, setLabelText] = React.useState(ownerLabelText);
42
- const [prevOwnerLabelText, setPrevOwnerLabelText] = React.useState(ownerLabelText);
43
42
  const generatedId = useId.useId();
44
43
  const {
45
44
  current: inputId
@@ -53,12 +52,9 @@ function FileUploaderButton({
53
52
  [`${prefix}--btn--sm`]: size === 'small' || size === 'sm',
54
53
  [`${prefix}--layout--size-${size}`]: size
55
54
  });
56
-
57
- // Adjust label text state based on changes to the labelText prop
58
- if (ownerLabelText !== prevOwnerLabelText) {
55
+ React.useEffect(() => {
59
56
  setLabelText(ownerLabelText);
60
- setPrevOwnerLabelText(ownerLabelText);
61
- }
57
+ }, [ownerLabelText]);
62
58
  function onClick(event) {
63
59
  event.target.value = null;
64
60
  if (inputNode.current) {
@@ -7,8 +7,6 @@
7
7
 
8
8
  'use strict';
9
9
 
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
10
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
11
  var PropTypes = require('prop-types');
14
12
  var React = require('react');
@@ -32,4 +30,3 @@ IconSkeleton.propTypes = {
32
30
  };
33
31
 
34
32
  exports.IconSkeleton = IconSkeleton;
35
- exports.default = IconSkeleton;
@@ -7,8 +7,6 @@
7
7
 
8
8
  'use strict';
9
9
 
10
- Object.defineProperty(exports, '__esModule', { value: true });
11
-
12
10
  var PropTypes = require('prop-types');
13
11
  var React = require('react');
14
12
  var cx = require('classnames');
@@ -76,4 +74,3 @@ IconIndicator.propTypes = {
76
74
 
77
75
  exports.IconIndicator = IconIndicator;
78
76
  exports.IconIndicatorKinds = IconIndicatorKinds;
79
- exports.default = IconIndicator;
@@ -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, { type PropsWithChildren } from 'react';
7
+ import React, { type ComponentType, type PropsWithChildren } from 'react';
8
8
  import { type PresenceContext } from '../../internal/usePresenceContext';
9
9
  export interface ModalPresenceProps {
10
10
  /**
@@ -29,4 +29,12 @@ export declare const ModalPresenceContext: React.Context<ModalPresenceContextPro
29
29
  * Handles occurrences where only a single modal must consume a context.
30
30
  */
31
31
  export declare const useExclusiveModalPresenceContext: (id: string) => ModalPresenceContextProps | undefined;
32
+ type WithModalPresenceProps = Pick<ModalPresenceProps, 'open'>;
33
+ /**
34
+ * Higher-order function that wraps a component with ModalPresence
35
+ */
36
+ export declare const withModalPresence: <TProps extends object>(Component: ComponentType<TProps>) => {
37
+ ({ open, ...componentProps }: TProps & WithModalPresenceProps): import("react/jsx-runtime").JSX.Element;
38
+ displayName: string;
39
+ };
32
40
  export {};
@@ -35,7 +35,21 @@ const useExclusiveModalPresenceContext = id => {
35
35
  const ctx = React.useContext(ModalPresenceContext);
36
36
  return ctx?.isPresenceExclusive(id) ? ctx : undefined;
37
37
  };
38
+ /**
39
+ * Higher-order function that wraps a component with ModalPresence
40
+ */
41
+ const withModalPresence = Component => {
42
+ const WithModalPresence = ({
43
+ open,
44
+ ...componentProps
45
+ }) => /*#__PURE__*/React.createElement(ModalPresence, {
46
+ open: open
47
+ }, /*#__PURE__*/React.createElement(Component, componentProps));
48
+ WithModalPresence.displayName = `withModalPresence(${Component.displayName || Component.name || 'Component'})`;
49
+ return WithModalPresence;
50
+ };
38
51
 
39
52
  exports.ModalPresence = ModalPresence;
40
53
  exports.ModalPresenceContext = ModalPresenceContext;
41
54
  exports.useExclusiveModalPresenceContext = useExclusiveModalPresenceContext;
55
+ exports.withModalPresence = withModalPresence;
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import Modal, { type ModalProps } from './Modal';
8
- import { ModalPresence, type ModalPresenceProps } from './ModalPresence';
8
+ import { ModalPresence, withModalPresence, type ModalPresenceProps } from './ModalPresence';
9
9
  export default Modal;
10
- export { Modal, ModalPresence, type ModalProps, type ModalPresenceProps };
10
+ export { Modal, ModalPresence, withModalPresence, type ModalProps, type ModalPresenceProps, };
@@ -112,11 +112,11 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
112
112
  isFluid
113
113
  } = React.useContext(FormContext.FormContext);
114
114
  const multiSelectInstanceId = useId.useId();
115
+ const prevOpenPropRef = React.useRef(open);
115
116
  // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
116
117
  const [isFocused, setIsFocused] = React.useState(false);
117
118
  const [inputFocused, setInputFocused] = React.useState(false);
118
119
  const [isOpen, setIsOpen] = React.useState(open || false);
119
- const [prevOpenProp, setPrevOpenProp] = React.useState(open);
120
120
  const [topItems, setTopItems] = React.useState([]);
121
121
  const [itemsCleared, setItemsCleared] = React.useState(false);
122
122
  const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
@@ -250,14 +250,13 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
250
250
  onMenuChange(open);
251
251
  }
252
252
  };
253
-
254
- /**
255
- * programmatically control this `open` prop
256
- */
257
- if (prevOpenProp !== open) {
258
- setIsOpenWrapper(open);
259
- setPrevOpenProp(open);
260
- }
253
+ React.useEffect(() => {
254
+ if (prevOpenPropRef.current !== open) {
255
+ setIsOpen(open);
256
+ onMenuChange?.(open);
257
+ prevOpenPropRef.current = open;
258
+ }
259
+ }, [open, onMenuChange]);
261
260
  const normalizedProps = useNormalizedInputProps.useNormalizedInputProps({
262
261
  id,
263
262
  disabled,
@@ -343,7 +343,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
343
343
  * The number value that was previously "committed" to the input on blur
344
344
  * Only used when type="text"
345
345
  */
346
- const [previousNumberValue, setPreviousNumberValue] = React.useState(numberValue);
346
+ const previousNumberValue = React.useRef(numberValue);
347
347
  /**
348
348
  * The current text value of the input.
349
349
  * Only used when type=text
@@ -356,10 +356,12 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
356
356
  numberingSystem
357
357
  }), [locale, formatOptions, numberingSystem]);
358
358
  const format = React.useCallback(value => isNaN(value) || value === null ? '' : numberFormatter.format(value), [numberFormatter]);
359
- if (isControlled && !(isNaN(previousNumberValue) && isNaN(numberValue)) && previousNumberValue !== numberValue) {
360
- setInputValue(format(numberValue));
361
- setPreviousNumberValue(numberValue);
362
- }
359
+ React.useEffect(() => {
360
+ if (isControlled && !(isNaN(previousNumberValue.current) && isNaN(numberValue)) && previousNumberValue.current !== numberValue) {
361
+ setInputValue(format(numberValue));
362
+ previousNumberValue.current = numberValue;
363
+ }
364
+ }, [isControlled, numberValue, format]);
363
365
  const inputRef = React.useRef(null);
364
366
  const ref = useMergedRefs.useMergedRefs([forwardRef, inputRef]);
365
367
  const numberInputClasses = cx({
@@ -506,7 +508,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
506
508
  // numberValue in useControllableState.
507
509
  setNumberValue(parsedFormattedNewValue);
508
510
  setInputValue(formattedNewValue);
509
- setPreviousNumberValue(parsedFormattedNewValue);
511
+ previousNumberValue.current = parsedFormattedNewValue;
510
512
  }
511
513
  if (onChange) {
512
514
  onChange(event, state);
@@ -608,22 +610,22 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
608
610
  if (onChange && isValid) {
609
611
  const state = {
610
612
  value: parsedFormattedNewValue,
611
- direction: previousNumberValue < parsedFormattedNewValue ? 'up' : 'down'
613
+ direction: previousNumberValue.current < parsedFormattedNewValue ? 'up' : 'down'
612
614
  };
613
615
 
614
616
  // If the old and new values are NaN, don't call onChange
615
- // to avoid an unecessary re-render and potential infinite
617
+ // to avoid an unnecessary re-render and potential infinite
616
618
  // loop when isControlled.
617
- if (!(isNaN(previousNumberValue) && isNaN(parsedFormattedNewValue))) {
619
+ if (!(isNaN(previousNumberValue.current) && isNaN(parsedFormattedNewValue))) {
618
620
  onChange(e, state);
619
621
  }
620
622
  }
621
623
 
622
624
  // If the old and new values are NaN, don't set state to avoid
623
- // an unecessary re-render and potential infinite loop when
625
+ // an unnecessary re-render and potential infinite loop when
624
626
  // isControlled.
625
- if (!(isNaN(previousNumberValue) && isNaN(numberValue))) {
626
- setPreviousNumberValue(numberValue);
627
+ if (!(isNaN(previousNumberValue.current) && isNaN(numberValue))) {
628
+ previousNumberValue.current = numberValue;
627
629
  }
628
630
  if (!(isNaN(numberValue) && isNaN(parsedFormattedNewValue))) {
629
631
  setNumberValue(parsedFormattedNewValue);
@@ -70,7 +70,7 @@ export interface OverflowMenuProps extends Omit<IconButtonProps, 'type' | 'aria-
70
70
  */
71
71
  menuOffset?: MenuOffset;
72
72
  /**
73
- * The adjustment in position applied to the floating menu.
73
+ * The adjustment in position applied to the floating menu when flipped.
74
74
  */
75
75
  menuOffsetFlip?: MenuOffset;
76
76
  /**