@carbon/react 1.106.0-rc.0 → 1.107.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 (155) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1006 -971
  2. package/es/components/Accordion/AccordionItem.d.ts +2 -2
  3. package/es/components/Button/Button.js +1 -1
  4. package/es/components/Checkbox/Checkbox.js +2 -1
  5. package/es/components/CheckboxGroup/CheckboxGroup.js +2 -1
  6. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  7. package/es/components/ComboBox/ComboBox.js +1 -1
  8. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  9. package/es/components/ContentSwitcher/ContentSwitcher.js +24 -15
  10. package/es/components/DataTable/DataTable.d.ts +3 -3
  11. package/es/components/DataTable/TableActionList.d.ts +1 -1
  12. package/es/components/DataTable/TableHead.d.ts +1 -1
  13. package/es/components/DataTable/TableSlugRow.d.ts +2 -2
  14. package/es/components/DataTable/TableSlugRow.js +8 -11
  15. package/es/components/DataTable/TableToolbarContent.d.ts +1 -1
  16. package/es/components/DataTable/TableToolbarSearch.d.ts +5 -1
  17. package/es/components/DatePicker/DatePicker.js +15 -13
  18. package/es/components/DatePicker/plugins/fixEventsPlugin.js +2 -3
  19. package/es/components/DatePickerInput/DatePickerInput.js +9 -2
  20. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  21. package/es/components/FluidTimePicker/FluidTimePicker.d.ts +1 -1
  22. package/es/components/FluidTimePicker/FluidTimePicker.js +6 -4
  23. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +4 -0
  24. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +2 -1
  25. package/es/components/FluidTimePickerSelect/index.js +18 -0
  26. package/es/components/Grid/CSSGrid.js +11 -6
  27. package/es/components/Grid/Column.d.ts +2 -2
  28. package/es/components/Grid/ColumnHang.d.ts +3 -3
  29. package/es/components/Grid/ColumnHang.js +1 -1
  30. package/es/components/Grid/FlexGrid.js +5 -3
  31. package/es/components/Grid/Grid.js +2 -1
  32. package/es/components/Grid/GridTypes.d.ts +5 -0
  33. package/es/components/Grid/Row.d.ts +3 -3
  34. package/es/components/Grid/Row.js +1 -1
  35. package/es/components/Menu/Menu.js +1 -1
  36. package/es/components/Menu/MenuItem.js +4 -0
  37. package/es/components/Modal/Modal.js +3 -0
  38. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  39. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
  40. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  41. package/es/components/OverflowMenu/OverflowMenu.js +11 -12
  42. package/es/components/Pagination/Pagination.d.ts +1 -1
  43. package/es/components/Pagination/Pagination.js +2 -0
  44. package/es/components/Popover/index.js +14 -1
  45. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
  46. package/es/components/RadioButtonGroup/RadioButtonGroup.js +8 -6
  47. package/es/components/Search/Search.Skeleton.d.ts +12 -3
  48. package/es/components/Search/Search.Skeleton.js +16 -8
  49. package/es/components/Search/Search.d.ts +1 -1
  50. package/es/components/Search/Search.js +4 -4
  51. package/es/components/Select/Select.d.ts +1 -1
  52. package/es/components/Select/Select.js +7 -6
  53. package/es/components/Slider/Slider.js +46 -62
  54. package/es/components/Tabs/Tabs.js +2 -2
  55. package/es/components/TextArea/TextArea.js +5 -2
  56. package/es/components/TextInput/ControlledPasswordInput.js +2 -1
  57. package/es/components/TextInput/PasswordInput.d.ts +2 -2
  58. package/es/components/TextInput/PasswordInput.js +33 -21
  59. package/es/components/TextInput/TextInput.Skeleton.d.ts +10 -2
  60. package/es/components/TextInput/TextInput.Skeleton.js +10 -4
  61. package/es/components/TextInput/TextInput.d.ts +1 -1
  62. package/es/components/TextInput/TextInput.js +39 -30
  63. package/es/components/TextInput/util.d.ts +1 -0
  64. package/es/components/TextInput/util.js +1 -1
  65. package/es/components/Theme/index.d.ts +2 -2
  66. package/es/components/Theme/index.js +3 -3
  67. package/es/components/TimePicker/TimePicker.js +5 -2
  68. package/es/components/TreeView/TreeNode.js +2 -2
  69. package/es/components/UIShell/HeaderGlobalBar.d.ts +1 -1
  70. package/es/components/UIShell/HeaderMenu.d.ts +1 -1
  71. package/es/components/UIShell/HeaderMenu.js +5 -3
  72. package/es/index.js +2 -2
  73. package/es/internal/FloatingMenu.d.ts +5 -1
  74. package/es/internal/hasHelperText.d.ts +8 -0
  75. package/es/internal/hasHelperText.js +11 -0
  76. package/es/tools/wrapComponent.d.ts +3 -3
  77. package/es/tools/wrapComponent.js +1 -1
  78. package/lib/components/Accordion/AccordionItem.d.ts +2 -2
  79. package/lib/components/Button/Button.js +1 -1
  80. package/lib/components/Checkbox/Checkbox.js +2 -1
  81. package/lib/components/CheckboxGroup/CheckboxGroup.js +2 -1
  82. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  83. package/lib/components/ComboBox/ComboBox.js +1 -1
  84. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  85. package/lib/components/ContentSwitcher/ContentSwitcher.js +22 -13
  86. package/lib/components/DataTable/DataTable.d.ts +3 -3
  87. package/lib/components/DataTable/TableActionList.d.ts +1 -1
  88. package/lib/components/DataTable/TableHead.d.ts +1 -1
  89. package/lib/components/DataTable/TableSlugRow.d.ts +2 -2
  90. package/lib/components/DataTable/TableSlugRow.js +7 -10
  91. package/lib/components/DataTable/TableToolbarContent.d.ts +1 -1
  92. package/lib/components/DataTable/TableToolbarSearch.d.ts +5 -1
  93. package/lib/components/DatePicker/DatePicker.js +15 -13
  94. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +1 -2
  95. package/lib/components/DatePickerInput/DatePickerInput.js +9 -2
  96. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  97. package/lib/components/FluidTimePicker/FluidTimePicker.d.ts +1 -1
  98. package/lib/components/FluidTimePicker/FluidTimePicker.js +5 -3
  99. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +4 -0
  100. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +2 -1
  101. package/lib/components/FluidTimePickerSelect/index.js +17 -0
  102. package/lib/components/Grid/CSSGrid.js +11 -6
  103. package/lib/components/Grid/Column.d.ts +2 -2
  104. package/lib/components/Grid/ColumnHang.d.ts +3 -3
  105. package/lib/components/Grid/ColumnHang.js +1 -1
  106. package/lib/components/Grid/FlexGrid.js +5 -3
  107. package/lib/components/Grid/Grid.js +2 -1
  108. package/lib/components/Grid/GridTypes.d.ts +5 -0
  109. package/lib/components/Grid/Row.d.ts +3 -3
  110. package/lib/components/Grid/Row.js +1 -1
  111. package/lib/components/Menu/Menu.js +1 -1
  112. package/lib/components/Menu/MenuItem.js +4 -0
  113. package/lib/components/Modal/Modal.js +3 -0
  114. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  115. package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -2
  116. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  117. package/lib/components/OverflowMenu/OverflowMenu.js +10 -11
  118. package/lib/components/Pagination/Pagination.d.ts +1 -1
  119. package/lib/components/Pagination/Pagination.js +2 -0
  120. package/lib/components/Popover/index.js +14 -1
  121. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
  122. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -5
  123. package/lib/components/Search/Search.Skeleton.d.ts +12 -3
  124. package/lib/components/Search/Search.Skeleton.js +15 -7
  125. package/lib/components/Search/Search.d.ts +1 -1
  126. package/lib/components/Search/Search.js +4 -4
  127. package/lib/components/Select/Select.d.ts +1 -1
  128. package/lib/components/Select/Select.js +7 -6
  129. package/lib/components/Slider/Slider.js +46 -62
  130. package/lib/components/Tabs/Tabs.js +2 -2
  131. package/lib/components/TextArea/TextArea.js +5 -2
  132. package/lib/components/TextInput/ControlledPasswordInput.js +2 -1
  133. package/lib/components/TextInput/PasswordInput.d.ts +2 -2
  134. package/lib/components/TextInput/PasswordInput.js +33 -21
  135. package/lib/components/TextInput/TextInput.Skeleton.d.ts +10 -2
  136. package/lib/components/TextInput/TextInput.Skeleton.js +10 -4
  137. package/lib/components/TextInput/TextInput.d.ts +1 -1
  138. package/lib/components/TextInput/TextInput.js +39 -30
  139. package/lib/components/TextInput/util.d.ts +1 -0
  140. package/lib/components/TextInput/util.js +1 -1
  141. package/lib/components/Theme/index.d.ts +2 -2
  142. package/lib/components/Theme/index.js +2 -2
  143. package/lib/components/TimePicker/TimePicker.js +5 -2
  144. package/lib/components/TreeView/TreeNode.js +1 -1
  145. package/lib/components/UIShell/HeaderGlobalBar.d.ts +1 -1
  146. package/lib/components/UIShell/HeaderMenu.d.ts +1 -1
  147. package/lib/components/UIShell/HeaderMenu.js +5 -3
  148. package/lib/index.js +2 -2
  149. package/lib/internal/FloatingMenu.d.ts +5 -1
  150. package/lib/internal/hasHelperText.d.ts +8 -0
  151. package/lib/internal/hasHelperText.js +11 -0
  152. package/lib/tools/wrapComponent.d.ts +3 -3
  153. package/lib/tools/wrapComponent.js +1 -1
  154. package/package.json +8 -8
  155. package/telemetry.yml +1 -0
@@ -10,6 +10,7 @@ import { Text } from "../Text/Text.js";
10
10
  import { deprecate } from "../../prop-types/deprecate.js";
11
11
  import { isComponentElement } from "../../internal/utils.js";
12
12
  import { useMergedRefs } from "../../internal/useMergedRefs.js";
13
+ import { hasHelperText } from "../../internal/hasHelperText.js";
13
14
  import { useNormalizedInputProps } from "../../internal/useNormalizedInputProps.js";
14
15
  import { AILabel } from "../AILabel/index.js";
15
16
  import { FormContext } from "../FluidForm/FormContext.js";
@@ -75,7 +76,7 @@ const TextInput = forwardRef(({ className, decorator, disabled = false, helperTe
75
76
  title: placeholder,
76
77
  disabled: normalizedProps.disabled,
77
78
  readOnly,
78
- ["aria-describedby"]: helperText && normalizedProps.helperId,
79
+ ["aria-describedby"]: hasHelperText(helperText) && !normalizedProps.invalid ? normalizedProps.helperId : void 0,
79
80
  ...rest
80
81
  };
81
82
  if (enableCounter) sharedTextInputProps.maxLength = maxCount;
@@ -124,7 +125,7 @@ const TextInput = forwardRef(({ className, decorator, disabled = false, helperTe
124
125
  className: `${prefix}--text-input__label-wrapper`,
125
126
  children: [label, counter]
126
127
  });
127
- const helper = typeof helperText !== "undefined" && helperText !== null && /* @__PURE__ */ jsx(Text, {
128
+ const helper = hasHelperText(helperText) && /* @__PURE__ */ jsx(Text, {
128
129
  as: "div",
129
130
  id: normalizedProps.helperId,
130
131
  className: helperTextClasses,
@@ -163,34 +164,41 @@ const TextInput = forwardRef(({ className, decorator, disabled = false, helperTe
163
164
  const normalizedDecorator = isComponentElement(candidate, AILabel) ? cloneElement(candidate, { size: "mini" }) : candidate;
164
165
  return /* @__PURE__ */ jsxs("div", {
165
166
  className: inputWrapperClasses,
166
- children: [!inline ? labelWrapper : /* @__PURE__ */ jsxs("div", {
167
- className: `${prefix}--text-input__label-helper-wrapper`,
168
- children: [labelWrapper, !isFluid && (normalizedProps.validation || helper)]
169
- }), /* @__PURE__ */ jsxs("div", {
170
- className: fieldOuterWrapperClasses,
171
- children: [/* @__PURE__ */ jsxs("div", {
172
- className: fieldWrapperClasses,
173
- "data-invalid": normalizedProps.invalid || null,
174
- children: [
175
- Icon && /* @__PURE__ */ jsx(Icon, { className: iconClasses }),
176
- input,
177
- slug ? normalizedDecorator : decorator ? /* @__PURE__ */ jsx("div", {
178
- className: `${prefix}--text-input__field-inner-wrapper--decorator`,
179
- children: normalizedDecorator
180
- }) : "",
181
- /* @__PURE__ */ jsx("span", {
182
- className: `${prefix}--text-input__counter-alert`,
183
- role: "alert",
184
- "aria-live": "assertive",
185
- "aria-atomic": "true",
186
- ref: announcerRef,
187
- children: ariaAnnouncement
188
- }),
189
- isFluid && /* @__PURE__ */ jsx("hr", { className: `${prefix}--text-input__divider` }),
190
- isFluid && !inline && normalizedProps.validation
191
- ]
192
- }), !isFluid && !inline && (normalizedProps.validation || helper)]
193
- })]
167
+ children: [
168
+ !inline ? labelWrapper : /* @__PURE__ */ jsx("div", {
169
+ className: `${prefix}--text-input__label-helper-wrapper`,
170
+ children: labelWrapper
171
+ }),
172
+ /* @__PURE__ */ jsxs("div", {
173
+ className: fieldOuterWrapperClasses,
174
+ children: [/* @__PURE__ */ jsxs("div", {
175
+ className: fieldWrapperClasses,
176
+ "data-invalid": normalizedProps.invalid || null,
177
+ children: [
178
+ input,
179
+ Icon && /* @__PURE__ */ jsx(Icon, { className: iconClasses }),
180
+ slug ? normalizedDecorator : decorator ? /* @__PURE__ */ jsx("div", {
181
+ className: `${prefix}--text-input__field-inner-wrapper--decorator`,
182
+ children: normalizedDecorator
183
+ }) : "",
184
+ /* @__PURE__ */ jsx("span", {
185
+ className: `${prefix}--text-input__counter-alert`,
186
+ role: "alert",
187
+ "aria-live": "assertive",
188
+ "aria-atomic": "true",
189
+ ref: announcerRef,
190
+ children: ariaAnnouncement
191
+ }),
192
+ isFluid && /* @__PURE__ */ jsx("hr", { className: `${prefix}--text-input__divider` }),
193
+ isFluid && !inline && normalizedProps.validation
194
+ ]
195
+ }), !isFluid && !inline && (normalizedProps.validation || helper)]
196
+ }),
197
+ inline && !isFluid && /* @__PURE__ */ jsx("div", {
198
+ className: `${prefix}--text-input__label-helper-wrapper`,
199
+ children: normalizedProps.validation || helper
200
+ })
201
+ ]
194
202
  });
195
203
  });
196
204
  TextInput.displayName = "TextInput";
@@ -214,6 +222,7 @@ TextInput.propTypes = {
214
222
  placeholder: PropTypes.string,
215
223
  readOnly: PropTypes.bool,
216
224
  size: PropTypes.oneOf([
225
+ "xs",
217
226
  "sm",
218
227
  "md",
219
228
  "lg"
@@ -17,5 +17,6 @@ export declare const getTextInputProps: ({ sharedTextInputProps, invalid, invali
17
17
  'aria-describedby'?: string | undefined;
18
18
  'data-invalid'?: boolean | undefined;
19
19
  'aria-invalid'?: boolean | undefined;
20
+ 'aria-errormessage'?: string | undefined;
20
21
  };
21
22
  export {};
@@ -15,7 +15,7 @@
15
15
  const invalidProps = (invalidId) => ({
16
16
  "data-invalid": true,
17
17
  "aria-invalid": true,
18
- "aria-describedby": invalidId
18
+ "aria-errormessage": invalidId
19
19
  });
20
20
  const warnProps = (warnId) => ({ "aria-describedby": warnId });
21
21
  const helperProps = (helperId) => ({ "aria-describedby": helperId });
@@ -1,11 +1,11 @@
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.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
- import React, { ElementType } from 'react';
8
+ import React, { type ElementType } from 'react';
9
9
  import { PolymorphicProps } from '../../types/common';
10
10
  export interface GlobalThemeProps {
11
11
  theme?: 'white' | 'g10' | 'g90' | 'g100';
@@ -9,12 +9,12 @@ import { usePrefix } from "../../internal/usePrefix.js";
9
9
  import { LayerContext } from "../Layer/LayerContext.js";
10
10
  import { useMatchMedia } from "../../internal/useMatchMedia.js";
11
11
  import classNames from "classnames";
12
- import React, { useMemo } from "react";
12
+ import React, { cloneElement, isValidElement, useMemo } from "react";
13
13
  import PropTypes from "prop-types";
14
14
  import { jsx } from "react/jsx-runtime";
15
15
  //#region src/components/Theme/index.tsx
16
16
  /**
17
- * Copyright IBM Corp. 2016, 2023
17
+ * Copyright IBM Corp. 2016, 2026
18
18
  *
19
19
  * This source code is licensed under the Apache-2.0 license found in the
20
20
  * LICENSE file in the root directory of this source tree.
@@ -24,7 +24,7 @@ const GlobalTheme = React.forwardRef(({ children, theme }, ref) => {
24
24
  const value = useMemo(() => {
25
25
  return { theme };
26
26
  }, [theme]);
27
- const childrenWithProps = React.cloneElement(children, { ref });
27
+ const childrenWithProps = isValidElement(children) ? cloneElement(children, { ref }) : children;
28
28
  return /* @__PURE__ */ jsx(ThemeContext.Provider, {
29
29
  value,
30
30
  children: childrenWithProps
@@ -20,7 +20,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
20
20
  * LICENSE file in the root directory of this source tree.
21
21
  */
22
22
  const TimePicker = forwardRef((props, ref) => {
23
- const { children, className, inputClassName, pickerClassName, disabled = false, hideLabel, id, invalidText = "Error message goes here", invalid = false, warningText = "Warning message goes here", warning = false, labelText, light = false, maxLength = 5, onChange = () => {}, onClick = () => {}, onBlur = () => {}, pattern = "(1[012]|[1-9]):[0-5][0-9](\\s)?", placeholder = "hh:mm", readOnly, size = "md", type = "text", value, ...rest } = props;
23
+ const { ["aria-describedby"]: ariaDescribedBy, children, className, inputClassName, pickerClassName, disabled = false, hideLabel, id, invalidText = "Error message goes here", invalid = false, warningText = "Warning message goes here", warning = false, labelText, light = false, maxLength = 5, onChange = () => {}, onClick = () => {}, onBlur = () => {}, pattern = "(1[012]|[1-9]):[0-5][0-9](\\s)?", placeholder = "hh:mm", readOnly, size = "md", type = "text", value, ...rest } = props;
24
24
  const prefix = usePrefix();
25
25
  function handleOnClick(evt) {
26
26
  if (!disabled) onClick(evt);
@@ -89,6 +89,7 @@ const TimePicker = forwardRef((props, ref) => {
89
89
  });
90
90
  }
91
91
  const readOnlyProps = { readOnly };
92
+ const describedBy = [normalizedProps.invalid ? normalizedProps.invalidId : normalizedProps.warn ? normalizedProps.warnId : null, ariaDescribedBy].filter(Boolean).join(" ") || void 0;
92
93
  return /* @__PURE__ */ jsxs("div", {
93
94
  className: classNames(`${prefix}--form-item`, className),
94
95
  children: [
@@ -112,7 +113,9 @@ const TimePicker = forwardRef((props, ref) => {
112
113
  type,
113
114
  value,
114
115
  ...rest,
115
- ...readOnlyProps
116
+ ...readOnlyProps,
117
+ "aria-describedby": describedBy,
118
+ "aria-invalid": normalizedProps.invalid ? true : void 0
116
119
  }), (normalizedProps.invalid || normalizedProps.warn) && normalizedProps.icon && /* @__PURE__ */ jsx("div", {
117
120
  className: `${prefix}--time-picker__error__icon`,
118
121
  children: React.createElement(normalizedProps.icon, {
@@ -15,7 +15,7 @@ import { IconButton } from "../IconButton/index.js";
15
15
  import { useControllableState } from "../../internal/useControllableState.js";
16
16
  import { DepthContext, TreeContext } from "./TreeContext.js";
17
17
  import classNames from "classnames";
18
- import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
18
+ import React, { isValidElement, useCallback, useContext, useEffect, useRef, useState } from "react";
19
19
  import PropTypes from "prop-types";
20
20
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
21
21
  import { CaretDown } from "@carbon/icons-react";
@@ -32,7 +32,7 @@ const extractTextContent = (node) => {
32
32
  if (typeof node === "number") return String(node);
33
33
  if (typeof node === "boolean") return String(node);
34
34
  if (Array.isArray(node)) return node.map(extractTextContent).join("");
35
- if (React.isValidElement(node)) {
35
+ if (isValidElement(node)) {
36
36
  const children = node.props.children;
37
37
  return extractTextContent(children);
38
38
  }
@@ -7,5 +7,5 @@
7
7
  /**
8
8
  * Generic container for `HeaderGlobalAction` components
9
9
  */
10
- declare const HeaderGlobalBar: (props: import("react").HTMLAttributes<"div">) => React.ReactElement<any>;
10
+ declare const HeaderGlobalBar: (props: import("react").HTMLAttributes<"div">) => import("react").ReactElement;
11
11
  export default HeaderGlobalBar;
@@ -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.
@@ -9,11 +9,13 @@ import { PrefixContext } from "../../internal/usePrefix.js";
9
9
  import { Enter, Escape, Space } from "../../internal/keyboard/keys.js";
10
10
  import { matches } from "../../internal/keyboard/match.js";
11
11
  import { deprecate } from "../../prop-types/deprecate.js";
12
+ import { isComponentElement } from "../../internal/utils.js";
12
13
  import { useMergedRefs } from "../../internal/useMergedRefs.js";
13
14
  import { composeEventHandlers } from "../../tools/events.js";
14
15
  import { AriaLabelPropType } from "../../prop-types/AriaPropTypes.js";
16
+ import HeaderMenuItem from "./HeaderMenuItem.js";
15
17
  import classNames from "classnames";
16
- import { Children, cloneElement, forwardRef, isValidElement, useContext, useRef, useState } from "react";
18
+ import { Children, cloneElement, forwardRef, useContext, useRef, useState } from "react";
17
19
  import PropTypes from "prop-types";
18
20
  import { jsx, jsxs } from "react/jsx-runtime";
19
21
  import { ChevronDown } from "@carbon/icons-react";
@@ -73,7 +75,7 @@ const HeaderMenu = forwardRef((props, ref) => {
73
75
  }
74
76
  };
75
77
  const hasActiveDescendant = (childrenArg) => Children.toArray(childrenArg).some((child) => {
76
- if (!isValidElement(child)) return false;
78
+ if (!isComponentElement(child, HeaderMenuItem)) return false;
77
79
  const { isActive, isCurrentPage, children } = child.props;
78
80
  return isActive || isCurrentPage || Array.isArray(children) && hasActiveDescendant(children);
79
81
  });
@@ -84,7 +86,7 @@ const HeaderMenu = forwardRef((props, ref) => {
84
86
  * sequence when they might not want to go through all the items.
85
87
  */
86
88
  const renderMenuItem = (item, index) => {
87
- if (isValidElement(item)) return cloneElement(item, { ref: handleItemRef(index) });
89
+ if (isComponentElement(item, HeaderMenuItem)) return cloneElement(item, { ref: handleItemRef(index) });
88
90
  return item;
89
91
  };
90
92
  const accessibilityLabel = {
package/es/index.js CHANGED
@@ -181,9 +181,9 @@ import Header from "./components/UIShell/Header.js";
181
181
  import HeaderContainer from "./components/UIShell/HeaderContainer.js";
182
182
  import HeaderGlobalAction from "./components/UIShell/HeaderGlobalAction.js";
183
183
  import HeaderGlobalBar from "./components/UIShell/HeaderGlobalBar.js";
184
+ import HeaderMenuItem from "./components/UIShell/HeaderMenuItem.js";
184
185
  import HeaderMenu from "./components/UIShell/HeaderMenu.js";
185
186
  import HeaderMenuButton from "./components/UIShell/HeaderMenuButton.js";
186
- import HeaderMenuItem from "./components/UIShell/HeaderMenuItem.js";
187
187
  import HeaderName from "./components/UIShell/HeaderName.js";
188
188
  import HeaderNavigation from "./components/UIShell/HeaderNavigation.js";
189
189
  import SwitcherItem from "./components/UIShell/SwitcherItem.js";
@@ -226,9 +226,9 @@ import FluidPasswordInput from "./components/FluidTextInput/FluidPasswordInput.j
226
226
  import FluidTextInputSkeleton from "./components/FluidTextInput/FluidTextInput.Skeleton.js";
227
227
  import FluidNumberInput from "./components/FluidNumberInput/FluidNumberInput.js";
228
228
  import FluidNumberInputSkeleton from "./components/FluidNumberInput/FluidNumberInput.Skeleton.js";
229
+ import FluidTimePickerSelect from "./components/FluidTimePickerSelect/FluidTimePickerSelect.js";
229
230
  import FluidTimePicker from "./components/FluidTimePicker/FluidTimePicker.js";
230
231
  import FluidTimePickerSkeleton from "./components/FluidTimePicker/FluidTimePicker.Skeleton.js";
231
- import FluidTimePickerSelect from "./components/FluidTimePickerSelect/FluidTimePickerSelect.js";
232
232
  import { OverflowMenuV2 } from "./components/OverflowMenuV2/index.js";
233
233
  import Pagination$1 from "./components/Pagination/experimental/Pagination.js";
234
234
  import PageSelector from "./components/Pagination/experimental/PageSelector.js";
@@ -17,13 +17,17 @@ interface Container {
17
17
  rect: DOMRect;
18
18
  position: string;
19
19
  }
20
+ type FloatingMenuChildProps = {
21
+ ref?: (node: HTMLElement | null) => void;
22
+ style?: CSSProperties;
23
+ };
20
24
  export type MenuDirection = typeof DIRECTION_LEFT | typeof DIRECTION_TOP | typeof DIRECTION_RIGHT | typeof DIRECTION_BOTTOM;
21
25
  export type MenuOffset = Offset | ((menuBody: HTMLElement, menuDirection: MenuDirection, triggerEl?: HTMLElement | null, flipped?: boolean) => Offset);
22
26
  interface FloatingMenuProps {
23
27
  /**
24
28
  * Contents of the floating menu.
25
29
  */
26
- children: ReactElement;
30
+ children: ReactElement<FloatingMenuChildProps>;
27
31
  /**
28
32
  * Whether the menu alignment should be flipped.
29
33
  */
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { ReactNode } from 'react';
8
+ export declare const hasHelperText: (helperText: ReactNode) => boolean;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ //#region src/internal/hasHelperText.ts
9
+ const hasHelperText = (helperText) => typeof helperText !== "undefined" && helperText !== null && helperText !== "";
10
+ //#endregion
11
+ export { hasHelperText };
@@ -1,10 +1,10 @@
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.
6
6
  */
7
- import React, { type HTMLAttributes } from 'react';
7
+ import { type HTMLAttributes, type ReactElement } from 'react';
8
8
  type HTMLTagName = keyof HTMLElementTagNameMap;
9
9
  type WrapComponentArgs<T extends HTMLTagName> = {
10
10
  name: string;
@@ -15,5 +15,5 @@ type WrapComponentArgs<T extends HTMLTagName> = {
15
15
  * @param {{ name: string, type: string, className?: string | (prefix: string) => string }} props
16
16
  * @returns
17
17
  */
18
- declare const wrapComponent: <T extends HTMLTagName>({ name, className: getClassName, type, }: WrapComponentArgs<T>) => ((props: HTMLAttributes<T>) => React.ReactElement<any>);
18
+ declare const wrapComponent: <T extends HTMLTagName>({ name, className: getClassName, type, }: WrapComponentArgs<T>) => ((props: HTMLAttributes<T>) => ReactElement);
19
19
  export default wrapComponent;
@@ -11,7 +11,7 @@ import React from "react";
11
11
  import PropTypes from "prop-types";
12
12
  //#region src/tools/wrapComponent.ts
13
13
  /**
14
- * Copyright IBM Corp. 2016, 2025
14
+ * Copyright IBM Corp. 2016, 2026
15
15
  *
16
16
  * This source code is licensed under the Apache-2.0 license found in the
17
17
  * LICENSE file in the root directory of this source tree.
@@ -38,12 +38,12 @@ export interface AccordionItemProps {
38
38
  * removed in the next major release of Carbon. Use the
39
39
  * `renderToggle` prop instead.
40
40
  */
41
- renderExpando?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement<any>;
41
+ renderExpando?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement;
42
42
  /**
43
43
  * The callback function to render the expand button.
44
44
  * Can be a React component class.
45
45
  */
46
- renderToggle?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement<any>;
46
+ renderToggle?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement;
47
47
  /**
48
48
  * The accordion title.
49
49
  */
@@ -49,7 +49,7 @@ const ButtonTooltipPositions = [
49
49
  "bottom",
50
50
  "left"
51
51
  ];
52
- function isIconOnlyButton(hasIconOnly, _kind) {
52
+ function isIconOnlyButton(hasIconOnly) {
53
53
  if (hasIconOnly === true) return true;
54
54
  return false;
55
55
  }
@@ -12,6 +12,7 @@ const require_useId = require("../../internal/useId.js");
12
12
  const require_noopFn = require("../../internal/noopFn.js");
13
13
  const require_deprecate = require("../../prop-types/deprecate.js");
14
14
  const require_utils = require("../../internal/utils.js");
15
+ const require_hasHelperText = require("../../internal/hasHelperText.js");
15
16
  const require_useNormalizedInputProps = require("../../internal/useNormalizedInputProps.js");
16
17
  const require_index = require("../AILabel/index.js");
17
18
  let classnames = require("classnames");
@@ -43,7 +44,7 @@ const Checkbox = react.default.forwardRef(({ className, decorator, helperText, i
43
44
  const showWarning = normalizedProps.warn;
44
45
  const showHelper = !normalizedProps.invalid && !normalizedProps.warn;
45
46
  const checkboxGroupInstanceId = require_useId.useId();
46
- const hasHelper = typeof helperText !== "undefined" && helperText !== null;
47
+ const hasHelper = require_hasHelperText.hasHelperText(helperText);
47
48
  const helperId = !hasHelper ? void 0 : `checkbox-helper-text-${checkboxGroupInstanceId}`;
48
49
  const helper = hasHelper && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
49
50
  id: helperId,
@@ -10,6 +10,7 @@ const require_usePrefix = require("../../internal/usePrefix.js");
10
10
  const require_useId = require("../../internal/useId.js");
11
11
  const require_deprecate = require("../../prop-types/deprecate.js");
12
12
  const require_utils = require("../../internal/utils.js");
13
+ const require_hasHelperText = require("../../internal/hasHelperText.js");
13
14
  const require_useNormalizedInputProps = require("../../internal/useNormalizedInputProps.js");
14
15
  const require_index = require("../AILabel/index.js");
15
16
  const require_Checkbox = require("../Checkbox/Checkbox.js");
@@ -42,7 +43,7 @@ const CheckboxGroup = ({ children, className, decorator, helperText, invalid, in
42
43
  });
43
44
  const showWarning = normalizedProps.warn;
44
45
  const showHelper = !normalizedProps.invalid && !normalizedProps.warn;
45
- const hasHelper = typeof helperText !== "undefined" && helperText !== null;
46
+ const hasHelper = require_hasHelperText.hasHelperText(helperText);
46
47
  const helperId = !hasHelper ? void 0 : `checkbox-group-helper-text-${checkboxGroupInstanceId}`;
47
48
  const helper = hasHelper && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
48
49
  id: helperId,
@@ -197,7 +197,7 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
197
197
  }
198
198
  type ComboboxComponentProps<ItemType> = PropsWithChildren<ComboBoxProps<ItemType>> & RefAttributes<HTMLInputElement>;
199
199
  export interface ComboBoxComponent {
200
- <ItemType>(props: ComboboxComponentProps<ItemType>): ReactElement<any> | null;
200
+ <ItemType>(props: ComboboxComponentProps<ItemType>): ReactElement | null;
201
201
  }
202
202
  declare const _default: ComboBoxComponent;
203
203
  export default _default;
@@ -356,7 +356,7 @@ const ComboBox = (0, react.forwardRef)((props, ref) => {
356
356
  selectedItem: newSelectedItem
357
357
  });
358
358
  if (isManualClearingRef.current) return;
359
- if ((type === ItemClick || type === FunctionSelectItem || type === InputKeyDownEnter) && typeof newSelectedItem !== "undefined" && !(0, react_fast_compare.default)(selectedItemProp, newSelectedItem)) {
359
+ if ((type === ItemClick || type === FunctionSelectItem || type === InputKeyDownEnter || !allowCustomValue && type === InputBlur) && typeof newSelectedItem !== "undefined" && !(0, react_fast_compare.default)(currentSelectedItem, newSelectedItem)) {
360
360
  if (items.some((item) => (0, react_fast_compare.default)(item, newSelectedItem))) committedCustomValueRef.current = "";
361
361
  onChange({ selectedItem: newSelectedItem });
362
362
  }
@@ -11,7 +11,7 @@ export interface ContentSwitcherProps extends Omit<HTMLAttributes<HTMLElement>,
11
11
  /**
12
12
  * Pass in Switch components to be rendered in the ContentSwitcher
13
13
  */
14
- children?: ReactElement<any>[];
14
+ children?: ReactElement | ReactElement[];
15
15
  /**
16
16
  * Specify an optional className to be added to the container node
17
17
  */
@@ -12,8 +12,8 @@ const require_match = require("../../internal/keyboard/match.js");
12
12
  const require_navigation = require("../../internal/keyboard/navigation.js");
13
13
  const require_deprecate = require("../../prop-types/deprecate.js");
14
14
  const require_utils = require("../../internal/utils.js");
15
- const require_events = require("../../tools/events.js");
16
15
  const require_index = require("../Layout/index.js");
16
+ const require_Switch = require("../Switch/Switch.js");
17
17
  const require_IconSwitch = require("../Switch/IconSwitch.js");
18
18
  let classnames = require("classnames");
19
19
  classnames = require_runtime.__toESM(classnames);
@@ -48,25 +48,25 @@ const ContentSwitcher = ({ children, className, light, lowContrast, selectedInde
48
48
  const ref = switchRefs.current[index];
49
49
  if (ref) ref.focus();
50
50
  };
51
- const isKeyboardEvent = (event) => event && typeof event === "object" && "key" in event;
51
+ const hasKey = (event) => typeof event === "object" && event !== null && "key" in event;
52
52
  const handleChildChange = (event) => {
53
53
  if (typeof event.index === "undefined") return;
54
54
  const { index } = event;
55
- if (isKeyboardEvent(event) && require_match.matches(event, [require_keys.ArrowRight, require_keys.ArrowLeft])) {
55
+ if (hasKey(event) && (require_match.match(event.key, require_keys.ArrowRight) || require_match.match(event.key, require_keys.ArrowLeft))) {
56
56
  const nextIndex = require_navigation.getNextIndex(event.key, index, childrenArray.length);
57
57
  if (typeof nextIndex !== "number") return;
58
58
  focusSwitch(nextIndex);
59
59
  if (selectionMode !== "manual") {
60
60
  const child = childrenArray[nextIndex];
61
61
  setSelectedIndex(nextIndex);
62
- if ((0, react.isValidElement)(child)) onChange({
62
+ if (require_utils.isComponentElement(child, require_Switch.default) || require_utils.isComponentElement(child, require_IconSwitch.default)) onChange({
63
63
  ...event,
64
64
  index: nextIndex,
65
65
  name: child.props.name,
66
66
  text: child.props.text
67
67
  });
68
68
  }
69
- } else if (selectedIndex !== index && (isKeyboardEvent(event) ? require_match.matches(event, [require_keys.Enter, require_keys.Space]) : true)) {
69
+ } else if (selectedIndex !== index && (hasKey(event) ? require_match.match(event.key, require_keys.Enter) || require_match.match(event.key, require_keys.Space) : true)) {
70
70
  setSelectedIndex(index);
71
71
  focusSwitch(index);
72
72
  onChange(event);
@@ -92,14 +92,23 @@ const ContentSwitcher = ({ children, className, light, lowContrast, selectedInde
92
92
  className: classes,
93
93
  role: "tablist",
94
94
  onChange: void 0,
95
- children: children && react.Children.map(children, (child, index) => (0, react.cloneElement)(child, {
96
- index,
97
- onClick: require_events.composeEventHandlers([handleChildChange, child.props.onClick]),
98
- onKeyDown: require_events.composeEventHandlers([handleChildChange, child.props.onKeyDown]),
99
- selected: index === selectedIndex,
100
- ref: handleItemRef(index),
101
- size
102
- }))
95
+ children: react.Children.map(children, (child, index) => {
96
+ if (!require_utils.isComponentElement(child, require_Switch.default) && !require_utils.isComponentElement(child, require_IconSwitch.default)) return child;
97
+ return (0, react.cloneElement)(child, {
98
+ index,
99
+ onClick: (event) => {
100
+ handleChildChange(event);
101
+ child.props.onClick?.(event);
102
+ },
103
+ onKeyDown: (event) => {
104
+ handleChildChange(event);
105
+ child.props.onKeyDown?.(event);
106
+ },
107
+ selected: index === selectedIndex,
108
+ ref: handleItemRef(index),
109
+ ...require_utils.isComponentElement(child, require_IconSwitch.default) ? { size } : {}
110
+ });
111
+ })
103
112
  });
104
113
  };
105
114
  ContentSwitcher.displayName = "ContentSwitcher";
@@ -255,7 +255,7 @@ export declare const DataTable: {
255
255
  tabIndex: PropTypes.Requireable<number>;
256
256
  };
257
257
  };
258
- TableActionList: (props: import("react").HTMLAttributes<"div">) => React.ReactElement<any>;
258
+ TableActionList: (props: import("react").HTMLAttributes<"div">) => ReactElement;
259
259
  TableBatchAction: {
260
260
  ({ renderIcon, iconDescription, ...props }: import("./TableBatchAction").TableBatchActionProps): import("react/jsx-runtime").JSX.Element;
261
261
  propTypes: {
@@ -332,7 +332,7 @@ export declare const DataTable: {
332
332
  colSpan: PropTypes.Validator<number>;
333
333
  };
334
334
  };
335
- TableHead: (props: import("react").HTMLAttributes<"thead">) => React.ReactElement<any>;
335
+ TableHead: (props: import("react").HTMLAttributes<"thead">) => ReactElement;
336
336
  TableHeader: import("react").ForwardRefExoticComponent<import("./TableHeader").TableHeaderProps & import("react").RefAttributes<HTMLTableCellElement>>;
337
337
  TableRow: import("react").ForwardRefExoticComponent<import("./TableRow").TableRowProps & import("react").RefAttributes<HTMLTableRowElement>>;
338
338
  TableSelectAll: {
@@ -382,7 +382,7 @@ export declare const DataTable: {
382
382
  };
383
383
  };
384
384
  TableToolbarAction: import("react").ForwardRefExoticComponent<import("./TableToolbarAction").TableToolbarActionProps & import("react").RefAttributes<HTMLDivElement>>;
385
- TableToolbarContent: (props: import("react").HTMLAttributes<"div">) => React.ReactElement<any>;
385
+ TableToolbarContent: (props: import("react").HTMLAttributes<"div">) => ReactElement;
386
386
  TableToolbarSearch: {
387
387
  ({ className, searchContainerClass, onChange: onChangeProp, onClear, translateWithId: t, placeholder, labelText, expanded: expandedProp, defaultExpanded, defaultValue, disabled, onExpand, persistent, id, onBlur, onFocus, size, tabIndex, ...rest }: import("./TableToolbarSearch").TableToolbarSearchProps): import("react/jsx-runtime").JSX.Element;
388
388
  propTypes: {
@@ -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
- declare const TableActionList: (props: import("react").HTMLAttributes<"div">) => React.ReactElement<any>;
7
+ declare const TableActionList: (props: import("react").HTMLAttributes<"div">) => import("react").ReactElement;
8
8
  export default TableActionList;
@@ -6,5 +6,5 @@
6
6
  */
7
7
  import { ThHTMLAttributes } from 'react';
8
8
  export type TableHeadProps = ThHTMLAttributes<HTMLTableSectionElement>;
9
- declare const TableHead: (props: import("react").HTMLAttributes<"thead">) => React.ReactElement<any>;
9
+ declare const TableHead: (props: import("react").HTMLAttributes<"thead">) => import("react").ReactElement;
10
10
  export default TableHead;
@@ -1,11 +1,11 @@
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.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
- import { ReactNode } from 'react';
8
+ import { type ReactNode } from 'react';
9
9
  export interface TableSlugRowProps {
10
10
  /**
11
11
  * The CSS class names of the cell that wraps the underlying input control
@@ -17,7 +17,7 @@ prop_types = require_runtime.__toESM(prop_types);
17
17
  let react_jsx_runtime = require("react/jsx-runtime");
18
18
  //#region src/components/DataTable/TableSlugRow.tsx
19
19
  /**
20
- * Copyright IBM Corp. 2016, 2025
20
+ * Copyright IBM Corp. 2016, 2026
21
21
  *
22
22
  * This source code is licensed under the Apache-2.0 license found in the
23
23
  * LICENSE file in the root directory of this source tree.
@@ -27,16 +27,13 @@ const TableSlugRow = ({ className, slug }) => {
27
27
  require_deprecateComponent.deprecateComponent("TableSlugRow", "The `TableSlugRow` component has been deprecated and will be removed in the next major version. Use the TableDecoratorRow component instead.");
28
28
  }, []);
29
29
  const prefix = require_usePrefix.usePrefix();
30
- const TableSlugRowClasses = (0, classnames.default)({
31
- ...className && { [className]: true },
32
- [`${prefix}--table-column-slug`]: true,
33
- [`${prefix}--table-column-slug--active`]: slug
34
- });
35
- let normalizedSlug;
36
- if (slug) normalizedSlug = react.default.cloneElement(slug, { size: "mini" });
37
30
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
38
- className: TableSlugRowClasses,
39
- children: normalizedSlug
31
+ className: (0, classnames.default)({
32
+ ...className && { [className]: true },
33
+ [`${prefix}--table-column-slug`]: true,
34
+ [`${prefix}--table-column-slug--active`]: slug
35
+ }),
36
+ children: (0, react.isValidElement)(slug) ? (0, react.cloneElement)(slug, { size: "mini" }) : void 0
40
37
  });
41
38
  };
42
39
  TableSlugRow.displayName = "TableSlugRow";
@@ -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
- declare const TableToolbarContent: (props: import("react").HTMLAttributes<"div">) => React.ReactElement<any>;
7
+ declare const TableToolbarContent: (props: import("react").HTMLAttributes<"div">) => import("react").ReactElement;
8
8
  export default TableToolbarContent;