@carbon/react 1.102.0 → 1.103.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 (153) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1011 -1011
  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/ComboBox/ComboBox.js +2 -2
  10. package/es/components/ComposedModal/ComposedModal.js +0 -3
  11. package/es/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
  12. package/es/components/ComposedModal/ComposedModalPresence.js +14 -1
  13. package/es/components/ComposedModal/index.d.ts +1 -1
  14. package/es/components/ContainedList/index.js +1 -1
  15. package/es/components/DataTable/TableHeader.js +1 -1
  16. package/es/components/DataTable/TableRow.js +1 -1
  17. package/es/components/DataTable/TableToolbarMenu.js +1 -1
  18. package/es/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
  19. package/es/components/DatePicker/DatePicker.Skeleton.js +2 -2
  20. package/es/components/DatePicker/DatePicker.d.ts +4 -2
  21. package/es/components/DatePicker/DatePicker.js +9 -6
  22. package/es/components/DatePicker/index.js +1 -1
  23. package/es/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
  24. package/es/components/DatePicker/plugins/rangePlugin.js +2 -1
  25. package/es/components/{UIShell/_utils.d.ts → DatePicker/utils.d.ts} +2 -2
  26. package/es/components/{UIShell/_utils.js → DatePicker/utils.js} +2 -2
  27. package/es/components/DatePickerInput/DatePickerInput.js +1 -1
  28. package/es/components/Dialog/Dialog.js +1 -1
  29. package/es/components/Dropdown/index.js +1 -1
  30. package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
  31. package/es/components/FeatureFlags/index.d.ts +8 -18
  32. package/es/components/FeatureFlags/index.js +23 -103
  33. package/es/components/FileUploader/FileUploader.Skeleton.js +1 -1
  34. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  35. package/es/components/FileUploader/FileUploaderButton.js +3 -7
  36. package/es/components/Icon/Icon.Skeleton.js +1 -1
  37. package/es/components/IconIndicator/index.js +1 -1
  38. package/es/components/Menu/MenuItem.js +1 -1
  39. package/es/components/Modal/ModalPresence.d.ts +9 -1
  40. package/es/components/Modal/ModalPresence.js +14 -1
  41. package/es/components/Modal/index.d.ts +2 -2
  42. package/es/components/MultiSelect/MultiSelect.js +9 -10
  43. package/es/components/Notification/Notification.js +1 -1
  44. package/es/components/NumberInput/NumberInput.js +15 -13
  45. package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -1
  46. package/es/components/OverflowMenu/OverflowMenu.js +3 -5
  47. package/es/components/OverflowMenuV2/index.js +1 -1
  48. package/es/components/PageHeader/PageHeader.js +2 -23
  49. package/es/components/Pagination/Pagination.Skeleton.js +1 -1
  50. package/es/components/Pagination/Pagination.d.ts +4 -0
  51. package/es/components/Pagination/Pagination.js +6 -1
  52. package/es/components/Pagination/experimental/Pagination.js +12 -1
  53. package/es/components/Popover/index.js +1 -1
  54. package/es/components/RadioButton/RadioButton.Skeleton.js +1 -1
  55. package/es/components/Search/index.js +1 -1
  56. package/es/components/Select/index.js +1 -1
  57. package/es/components/ShapeIndicator/index.js +1 -1
  58. package/es/components/Slider/Slider.js +230 -249
  59. package/es/components/Slider/SliderHandles.js +65 -53
  60. package/es/components/Switch/IconSwitch.js +1 -1
  61. package/es/components/Tabs/Tabs.js +10 -12
  62. package/es/components/Tag/Tag.Skeleton.js +1 -1
  63. package/es/components/TextArea/TextArea.js +1 -1
  64. package/es/components/TextArea/index.js +1 -1
  65. package/es/components/TextInput/index.js +1 -1
  66. package/es/components/Tile/Tile.d.ts +2 -2
  67. package/es/components/Tile/Tile.js +7 -2
  68. package/es/components/Toggle/Toggle.Skeleton.js +1 -1
  69. package/es/components/Toggletip/index.js +1 -1
  70. package/es/components/UIShell/HeaderMenu.js +1 -1
  71. package/es/components/UIShell/SideNav.d.ts +1 -4
  72. package/es/components/UIShell/SideNav.js +10 -25
  73. package/es/components/UIShell/SideNavContext.d.ts +17 -0
  74. package/es/components/UIShell/SideNavContext.js +24 -0
  75. package/es/components/UIShell/SideNavItems.d.ts +1 -1
  76. package/es/components/UIShell/SideNavItems.js +12 -16
  77. package/es/components/UIShell/SideNavLink.js +8 -4
  78. package/es/components/UIShell/SideNavMenu.js +7 -5
  79. package/es/index.js +30 -30
  80. package/es/internal/useNoInteractiveChildren.js +25 -30
  81. package/es/internal/usePresence.d.ts +1 -1
  82. package/es/internal/usePresence.js +14 -17
  83. package/lib/components/Button/Button.Skeleton.js +2 -1
  84. package/lib/components/Button/Button.d.ts +4 -4
  85. package/lib/components/Button/Button.js +4 -4
  86. package/lib/components/Button/index.js +1 -1
  87. package/lib/components/ButtonSet/ButtonSet.js +1 -1
  88. package/lib/components/Checkbox/index.js +1 -1
  89. package/lib/components/ComboBox/ComboBox.js +2 -2
  90. package/lib/components/ComposedModal/ComposedModal.js +0 -3
  91. package/lib/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
  92. package/lib/components/ComposedModal/ComposedModalPresence.js +14 -0
  93. package/lib/components/ComposedModal/index.d.ts +1 -1
  94. package/lib/components/ContainedList/index.js +0 -3
  95. package/lib/components/DataTable/TableToolbarMenu.js +1 -1
  96. package/lib/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
  97. package/lib/components/DatePicker/DatePicker.Skeleton.js +2 -2
  98. package/lib/components/DatePicker/DatePicker.d.ts +4 -2
  99. package/lib/components/DatePicker/DatePicker.js +9 -6
  100. package/lib/components/DatePicker/index.js +1 -1
  101. package/lib/components/DatePicker/plugins/rangePlugin.d.ts +1 -1
  102. package/lib/components/DatePicker/plugins/rangePlugin.js +2 -1
  103. package/lib/components/{UIShell/_utils.d.ts → DatePicker/utils.d.ts} +2 -2
  104. package/lib/components/{UIShell/_utils.js → DatePicker/utils.js} +2 -2
  105. package/lib/components/Dropdown/index.js +1 -1
  106. package/lib/components/FeatureFlags/index.d.ts +8 -18
  107. package/lib/components/FeatureFlags/index.js +21 -102
  108. package/lib/components/FileUploader/FileUploader.Skeleton.js +1 -1
  109. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  110. package/lib/components/FileUploader/FileUploaderButton.js +2 -6
  111. package/lib/components/Icon/Icon.Skeleton.js +0 -3
  112. package/lib/components/IconIndicator/index.js +0 -3
  113. package/lib/components/Modal/ModalPresence.d.ts +9 -1
  114. package/lib/components/Modal/ModalPresence.js +14 -0
  115. package/lib/components/Modal/index.d.ts +2 -2
  116. package/lib/components/MultiSelect/MultiSelect.js +8 -9
  117. package/lib/components/NumberInput/NumberInput.js +14 -12
  118. package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -1
  119. package/lib/components/OverflowMenu/OverflowMenu.js +2 -7
  120. package/lib/components/OverflowMenuV2/index.js +1 -1
  121. package/lib/components/PageHeader/PageHeader.js +2 -23
  122. package/lib/components/Pagination/Pagination.Skeleton.js +0 -3
  123. package/lib/components/Pagination/Pagination.d.ts +4 -0
  124. package/lib/components/Pagination/Pagination.js +6 -1
  125. package/lib/components/Pagination/experimental/Pagination.js +12 -1
  126. package/lib/components/RadioButton/RadioButton.Skeleton.js +0 -3
  127. package/lib/components/Search/index.js +1 -1
  128. package/lib/components/Select/index.js +1 -1
  129. package/lib/components/ShapeIndicator/index.js +0 -3
  130. package/lib/components/Slider/Slider.js +229 -248
  131. package/lib/components/Slider/SliderHandles.js +64 -52
  132. package/lib/components/Tabs/Tabs.js +9 -11
  133. package/lib/components/Tag/Tag.Skeleton.js +0 -3
  134. package/lib/components/TextArea/index.js +1 -1
  135. package/lib/components/TextInput/index.js +1 -1
  136. package/lib/components/Tile/Tile.d.ts +2 -2
  137. package/lib/components/Tile/Tile.js +6 -1
  138. package/lib/components/Toggle/Toggle.Skeleton.js +0 -3
  139. package/lib/components/Toggletip/index.js +0 -3
  140. package/lib/components/UIShell/SideNav.d.ts +1 -4
  141. package/lib/components/UIShell/SideNav.js +8 -24
  142. package/lib/components/UIShell/SideNavContext.d.ts +17 -0
  143. package/lib/components/UIShell/SideNavContext.js +27 -0
  144. package/lib/components/UIShell/SideNavItems.d.ts +1 -1
  145. package/lib/components/UIShell/SideNavItems.js +11 -15
  146. package/lib/components/UIShell/SideNavLink.js +7 -3
  147. package/lib/components/UIShell/SideNavMenu.js +8 -6
  148. package/lib/index.js +102 -100
  149. package/lib/internal/useNoInteractiveChildren.js +25 -30
  150. package/lib/internal/usePresence.d.ts +1 -1
  151. package/lib/internal/usePresence.js +13 -16
  152. package/package.json +5 -5
  153. package/telemetry.yml +2 -1
@@ -30,6 +30,7 @@ var FormContext = require('../FluidForm/FormContext.js');
30
30
  var iconsReact = require('@carbon/icons-react');
31
31
  var utilities = require('@carbon/utilities');
32
32
  var DatePickerLocales = require('./DatePickerLocales.js');
33
+ var utils$1 = require('./utils.js');
33
34
 
34
35
  // Weekdays shorthand for English locale
35
36
  // Ensure localization exists before trying to access it
@@ -595,9 +596,9 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
595
596
  React.useEffect(() => {
596
597
  // when value prop is manually reset, this clears the flatpickr calendar instance and text input
597
598
  // run if both:
598
- // 1. value prop is set to a falsy value (`""`, `undefined`, `null`, etc) OR an array of all falsy values
599
+ // 1. value prop is set to an empty value (`""`, `undefined`, `null`, etc) OR an array of all empty values
599
600
  // 2. flatpickr instance contains values in its `selectedDates` property so it hasn't already been cleared
600
- if ((!value || Array.isArray(value) && value.every(date => !date)) && calendarRef.current?.selectedDates.length) {
601
+ if ((utils$1.isEmptyDateValue(value) || Array.isArray(value) && value.every(utils$1.isEmptyDateValue)) && calendarRef.current?.selectedDates.length) {
601
602
  calendarRef.current?.clear();
602
603
  if (startInputField.current) {
603
604
  startInputField.current.value = '';
@@ -611,7 +612,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
611
612
  if (calendarRef.current?.set) {
612
613
  if (value !== undefined) {
613
614
  // To make up for calendarRef.current.setDate not making provision for an empty string or array
614
- if (value === '' || value === null || Array.isArray(value) && (value.length === 0 || value.every(element => !element))) {
615
+ if (value === '' || value === null || Array.isArray(value) && (value.length === 0 || value.every(utils$1.isEmptyDateValue))) {
615
616
  // only clear if there are selected dates to avoid unnecessary operations
616
617
  if (calendarRef.current.selectedDates.length > 0) {
617
618
  calendarRef.current.clear();
@@ -622,7 +623,7 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
622
623
  }
623
624
  updateClassNames(calendarRef.current, prefix);
624
625
  //for simple date picker w/o calendar; initial mount may not have value
625
- } else if (!calendarRef.current && value) {
626
+ } else if (!calendarRef.current && typeof value !== 'undefined' && value !== null) {
626
627
  startInputField.current.value = value;
627
628
  }
628
629
  }, [value, prefix, startInputField]);
@@ -656,8 +657,10 @@ const DatePicker = /*#__PURE__*/React.forwardRef((props, ref) => {
656
657
  });
657
658
  DatePicker.propTypes = {
658
659
  /**
659
- * Flatpickr prop passthrough enables direct date input, and when set to false,
660
- * we must clear dates manually by resetting the value prop to a falsy value (such as `""`, `null`, or `undefined`) or an array of all falsy values, making it a controlled input.
660
+ * Flatpickr prop passthrough enables direct date input, and when set to
661
+ * false, we must clear dates manually by resetting the value prop to an empty
662
+ * value (such as `""`, `null`, or `undefined`) or an array of all empty
663
+ * values, making it a controlled input.
661
664
  */
662
665
  allowInput: PropTypes.bool,
663
666
  /**
@@ -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;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2019, 2025
2
+ * Copyright IBM Corp. 2019, 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.
@@ -8,6 +8,7 @@
8
8
  'use strict';
9
9
 
10
10
  var baseRangePlugin = require('flatpickr/dist/plugins/rangePlugin');
11
+ var utils = require('../utils.js');
11
12
 
12
13
  /**
13
14
  * @param config Plugin configuration.
@@ -40,7 +41,7 @@ const rangePlugin = (config = {}) => {
40
41
  const inputToElement = typeof inputTo === 'string' ? document.querySelector(inputTo) : inputTo;
41
42
  [inputFrom, inputToElement].forEach((input, i) => {
42
43
  if (input && input instanceof HTMLInputElement) {
43
- input.value = !dates[i] ? '' : formatDate(new Date(dates[i]), fp.config.dateFormat);
44
+ input.value = utils.isEmptyDateValue(dates[i]) ? '' : formatDate(new Date(dates[i]), fp.config.dateFormat);
44
45
  }
45
46
  });
46
47
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Copyright IBM Corp. 2021, 2023
2
+ * Copyright IBM Corp. 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
- export const CARBON_SIDENAV_ITEMS: string[];
7
+ export declare const isEmptyDateValue: (date: unknown) => date is "" | null | undefined;
@@ -7,6 +7,6 @@
7
7
 
8
8
  'use strict';
9
9
 
10
- const CARBON_SIDENAV_ITEMS = ['SideNavFooter', 'SideNavHeader', 'SideNavItems', 'SideNavMenu', 'SideNavLink'];
10
+ const isEmptyDateValue = date => date === '' || date === null || typeof date === 'undefined';
11
11
 
12
- exports.CARBON_SIDENAV_ITEMS = CARBON_SIDENAV_ITEMS;
12
+ exports.isEmptyDateValue = isEmptyDateValue;
@@ -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
  /**
@@ -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 React = require('react');
14
12
  var iconsReact = require('@carbon/icons-react');
@@ -70,10 +68,8 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
70
68
  if (process.env.NODE_ENV !== 'production') {
71
69
  !(triggerButtonPositionProp && triggerButtonPositionFactor) ? process.env.NODE_ENV !== "production" ? invariant(false, '[OverflowMenu] wrong floating menu direction: `%s`', direction) : invariant(false) : void 0;
72
70
  }
73
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
74
71
  const {
75
- offsetWidth: menuWidth,
76
- offsetHeight: menuHeight
72
+ offsetWidth: menuWidth
77
73
  } = menuBody;
78
74
  switch (triggerButtonPositionProp) {
79
75
  case 'top':
@@ -427,7 +423,7 @@ OverflowMenu.propTypes = {
427
423
  left: PropTypes.number.isRequired
428
424
  }), PropTypes.func]),
429
425
  /**
430
- * The adjustment in position applied to the floating menu.
426
+ * The adjustment in position applied to the floating menu when flipped.
431
427
  */
432
428
  menuOffsetFlip: PropTypes.oneOfType([PropTypes.shape({
433
429
  top: PropTypes.number.isRequired,
@@ -477,5 +473,4 @@ OverflowMenu.propTypes = {
477
473
  };
478
474
 
479
475
  exports.OverflowMenu = OverflowMenu;
480
- exports.default = OverflowMenu;
481
476
  exports.getMenuOffset = getMenuOffset;
@@ -20,7 +20,7 @@ function OverflowMenuV2(props) {
20
20
  }
21
21
  return /*#__PURE__*/React.createElement(index.FeatureFlags, {
22
22
  enableV12Overflowmenu: true
23
- }, /*#__PURE__*/React.createElement(index$1.default, props));
23
+ }, /*#__PURE__*/React.createElement(index$1.OverflowMenu, props));
24
24
  }
25
25
 
26
26
  exports.OverflowMenuV2 = OverflowMenuV2;