@carbon/react 1.104.1 → 1.105.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 (83) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +988 -988
  2. package/es/components/AISkeleton/AISkeletonPlaceholder.d.ts +1 -1
  3. package/es/components/Checkbox/Checkbox.js +1 -1
  4. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  5. package/es/components/ComboBox/ComboBox.js +2 -2
  6. package/es/components/ComposedModal/ComposedModal.js +1 -1
  7. package/es/components/DataTable/TableDecoratorRow.js +1 -1
  8. package/es/components/DataTable/TableExpandRow.js +1 -1
  9. package/es/components/DataTable/TableHeader.js +1 -1
  10. package/es/components/DataTable/TableRow.js +1 -1
  11. package/es/components/DataTable/tools/normalize.js +1 -1
  12. package/es/components/DatePicker/DatePicker.d.ts +0 -8
  13. package/es/components/DatePicker/DatePicker.js +5 -28
  14. package/es/components/DatePicker/plugins/fixEventsPlugin.d.ts +18 -2
  15. package/es/components/DatePicker/plugins/fixEventsPlugin.js +9 -16
  16. package/es/components/DatePickerInput/DatePickerInput.js +1 -2
  17. package/es/components/Dropdown/Dropdown.js +2 -2
  18. package/es/components/FluidDatePicker/FluidDatePicker.js +1 -3
  19. package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +2 -2
  20. package/es/components/Menu/MenuItem.js +1 -1
  21. package/es/components/Modal/Modal.js +1 -1
  22. package/es/components/MultiSelect/FilterableMultiSelect.js +2 -2
  23. package/es/components/MultiSelect/MultiSelect.js +2 -2
  24. package/es/components/NumberInput/NumberInput.js +2 -2
  25. package/es/components/Pagination/Pagination.js +60 -29
  26. package/es/components/Popover/index.js +7 -4
  27. package/es/components/RadioButton/RadioButton.js +1 -1
  28. package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  29. package/es/components/RadioTile/RadioTile.js +1 -1
  30. package/es/components/Select/Select.js +1 -1
  31. package/es/components/Slider/Slider.js +60 -45
  32. package/es/components/Tabs/Tabs.js +1 -1
  33. package/es/components/Tag/DismissibleTag.js +1 -1
  34. package/es/components/Tag/Tag.js +1 -1
  35. package/es/components/TextArea/TextArea.js +1 -1
  36. package/es/components/TextInput/TextInput.js +1 -1
  37. package/es/components/Tile/Tile.js +1 -1
  38. package/es/components/UIShell/HeaderPanel.js +1 -1
  39. package/es/components/UIShell/Switcher.js +1 -1
  40. package/es/internal/useNoInteractiveChildren.d.ts +2 -10
  41. package/es/internal/useNoInteractiveChildren.js +16 -27
  42. package/lib/components/AISkeleton/AISkeletonPlaceholder.d.ts +1 -1
  43. package/lib/components/AISkeleton/AISkeletonPlaceholder.js +1 -1
  44. package/lib/components/Checkbox/Checkbox.js +1 -1
  45. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  46. package/lib/components/ComboBox/ComboBox.js +2 -2
  47. package/lib/components/ComposedModal/ComposedModal.js +1 -1
  48. package/lib/components/DataTable/TableDecoratorRow.js +1 -1
  49. package/lib/components/DataTable/TableExpandRow.js +1 -1
  50. package/lib/components/DataTable/TableHeader.js +1 -1
  51. package/lib/components/DataTable/TableRow.js +1 -1
  52. package/lib/components/DataTable/tools/normalize.js +1 -1
  53. package/lib/components/DatePicker/DatePicker.d.ts +0 -8
  54. package/lib/components/DatePicker/DatePicker.js +1 -24
  55. package/lib/components/DatePicker/plugins/fixEventsPlugin.d.ts +18 -2
  56. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +9 -16
  57. package/lib/components/DatePickerInput/DatePickerInput.js +1 -2
  58. package/lib/components/Dropdown/Dropdown.js +2 -2
  59. package/lib/components/FluidDatePicker/FluidDatePicker.js +1 -3
  60. package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +2 -2
  61. package/lib/components/Menu/MenuItem.js +1 -1
  62. package/lib/components/Modal/Modal.js +1 -1
  63. package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -2
  64. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  65. package/lib/components/NumberInput/NumberInput.js +2 -2
  66. package/lib/components/Pagination/Pagination.js +59 -28
  67. package/lib/components/Popover/index.js +7 -4
  68. package/lib/components/RadioButton/RadioButton.js +1 -1
  69. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  70. package/lib/components/RadioTile/RadioTile.js +1 -1
  71. package/lib/components/Select/Select.js +1 -1
  72. package/lib/components/Slider/Slider.js +60 -45
  73. package/lib/components/Tabs/Tabs.js +1 -1
  74. package/lib/components/Tag/DismissibleTag.js +1 -1
  75. package/lib/components/Tag/Tag.js +1 -1
  76. package/lib/components/TextArea/TextArea.js +1 -1
  77. package/lib/components/TextInput/TextInput.js +1 -1
  78. package/lib/components/Tile/Tile.js +1 -1
  79. package/lib/components/UIShell/HeaderPanel.js +1 -1
  80. package/lib/components/UIShell/Switcher.js +1 -1
  81. package/lib/internal/useNoInteractiveChildren.d.ts +2 -10
  82. package/lib/internal/useNoInteractiveChildren.js +16 -27
  83. package/package.json +7 -7
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2024
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.
@@ -10,8 +10,8 @@ import { Text } from "../Text/Text.js";
10
10
  import { useId } from "../../internal/useId.js";
11
11
  import { noopFn } from "../../internal/noopFn.js";
12
12
  import { deprecate } from "../../prop-types/deprecate.js";
13
- import { AILabel } from "../AILabel/index.js";
14
13
  import { isComponentElement } from "../../internal/utils.js";
14
+ import { AILabel } from "../AILabel/index.js";
15
15
  import classNames from "classnames";
16
16
  import React, { cloneElement } from "react";
17
17
  import PropTypes from "prop-types";
@@ -8,8 +8,8 @@
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
9
  import { useId } from "../../internal/useId.js";
10
10
  import { deprecate } from "../../prop-types/deprecate.js";
11
- import { AILabel } from "../AILabel/index.js";
12
11
  import { isComponentElement } from "../../internal/utils.js";
12
+ import { AILabel } from "../AILabel/index.js";
13
13
  import Checkbox$1 from "../Checkbox/Checkbox.js";
14
14
  import classNames from "classnames";
15
15
  import React, { Children, cloneElement } from "react";
@@ -11,10 +11,10 @@ import { End, Enter, Escape, Home, Space } from "../../internal/keyboard/keys.js
11
11
  import { match } from "../../internal/keyboard/match.js";
12
12
  import { useId } from "../../internal/useId.js";
13
13
  import { deprecate } from "../../prop-types/deprecate.js";
14
- import { useFeatureFlag } from "../FeatureFlags/index.js";
15
- import { AILabel } from "../AILabel/index.js";
16
14
  import { defaultItemToString } from "../../internal/defaultItemToString.js";
17
15
  import { isComponentElement } from "../../internal/utils.js";
16
+ import { useFeatureFlag } from "../FeatureFlags/index.js";
17
+ import { AILabel } from "../AILabel/index.js";
18
18
  import { ListBoxSizePropType } from "../ListBox/ListBoxPropTypes.js";
19
19
  import { FormContext } from "../FluidForm/FormContext.js";
20
20
  import ListBox from "../ListBox/index.js";
@@ -11,9 +11,9 @@ import { match } from "../../internal/keyboard/match.js";
11
11
  import { useId } from "../../internal/useId.js";
12
12
  import { warning } from "../../internal/warning.js";
13
13
  import { deprecate } from "../../prop-types/deprecate.js";
14
+ import { isComponentElement } from "../../internal/utils.js";
14
15
  import { useFeatureFlag } from "../FeatureFlags/index.js";
15
16
  import { AILabel } from "../AILabel/index.js";
16
- import { isComponentElement } from "../../internal/utils.js";
17
17
  import { useResizeObserver } from "../../internal/useResizeObserver.js";
18
18
  import { composeEventHandlers } from "../../tools/events.js";
19
19
  import { mergeRefs } from "../../tools/mergeRefs.js";
@@ -6,8 +6,8 @@
6
6
  */
7
7
 
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
- import { AILabel } from "../AILabel/index.js";
10
9
  import { isComponentElement } from "../../internal/utils.js";
10
+ import { AILabel } from "../AILabel/index.js";
11
11
  import classNames from "classnames";
12
12
  import React, { cloneElement } from "react";
13
13
  import PropTypes from "prop-types";
@@ -6,8 +6,8 @@
6
6
  */
7
7
 
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
- import { AILabel } from "../AILabel/index.js";
10
9
  import { isComponentElement } from "../../internal/utils.js";
10
+ import { AILabel } from "../AILabel/index.js";
11
11
  import TableCell from "./TableCell.js";
12
12
  import TableDecoratorRow from "./TableDecoratorRow.js";
13
13
  import TableSlugRow from "./TableSlugRow.js";
@@ -7,8 +7,8 @@
7
7
 
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
9
  import { useId } from "../../internal/useId.js";
10
- import { AILabel } from "../AILabel/index.js";
11
10
  import { isComponentElement } from "../../internal/utils.js";
11
+ import { AILabel } from "../AILabel/index.js";
12
12
  import { sortStates } from "./state/sortStates.js";
13
13
  import classNames from "classnames";
14
14
  import React, { cloneElement, forwardRef, useRef } from "react";
@@ -6,8 +6,8 @@
6
6
  */
7
7
 
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
- import { AILabel } from "../AILabel/index.js";
10
9
  import { isComponentElement } from "../../internal/utils.js";
10
+ import { AILabel } from "../AILabel/index.js";
11
11
  import TableDecoratorRow from "./TableDecoratorRow.js";
12
12
  import TableSlugRow from "./TableSlugRow.js";
13
13
  import classNames from "classnames";
@@ -5,8 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { AILabel } from "../../AILabel/index.js";
9
8
  import { isComponentElement } from "../../../internal/utils.js";
9
+ import { AILabel } from "../../AILabel/index.js";
10
10
  import { getCellId } from "./cells.js";
11
11
 
12
12
  //#region src/components/DataTable/tools/normalize.js
@@ -61,10 +61,6 @@ export interface DatePickerProps {
61
61
  * Specify whether or not the control is invalid (Fluid only)
62
62
  */
63
63
  invalid?: boolean;
64
- /**
65
- * Provide the text that is displayed when the control is in error state (Fluid Only)
66
- */
67
- invalidText?: ReactNode;
68
64
  /**
69
65
  * `true` to use the light version.
70
66
  */
@@ -116,10 +112,6 @@ export interface DatePickerProps {
116
112
  * Specify whether the control is currently in warning state (Fluid only)
117
113
  */
118
114
  warn?: boolean;
119
- /**
120
- * Provide the text that is displayed when the control is in warning state (Fluid only)
121
- */
122
- warnText?: ReactNode;
123
115
  /**
124
116
  * Accessible aria-label for the "next month" arrow icon.
125
117
  */
@@ -10,19 +10,17 @@ import { Enter, Escape, Tab } from "../../internal/keyboard/keys.js";
10
10
  import { match } from "../../internal/keyboard/match.js";
11
11
  import { deprecate } from "../../prop-types/deprecate.js";
12
12
  import { isComponentElement } from "../../internal/utils.js";
13
- import { FormContext } from "../FluidForm/FormContext.js";
14
13
  import DatePickerInput_default from "../DatePickerInput/index.js";
15
14
  import { appendToPlugin } from "./plugins/appendToPlugin.js";
16
- import fixEventsPlugin_default from "./plugins/fixEventsPlugin.js";
15
+ import fixEventsPlugin from "./plugins/fixEventsPlugin.js";
17
16
  import { isEmptyDateValue } from "./utils.js";
18
17
  import { rangePlugin } from "./plugins/rangePlugin.js";
19
18
  import { useSavedCallback } from "../../internal/useSavedCallback.js";
20
19
  import { SUPPORTED_LOCALES } from "./DatePickerLocales.js";
21
20
  import classNames from "classnames";
22
- import React, { forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from "react";
21
+ import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from "react";
23
22
  import PropTypes from "prop-types";
24
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
25
- import { WarningAltFilled, WarningFilled } from "@carbon/icons-react";
23
+ import { jsx, jsxs } from "react/jsx-runtime";
26
24
  import flatpickr from "flatpickr";
27
25
  import l10n from "flatpickr/dist/l10n/index";
28
26
  import { datePartsOrder } from "@carbon/utilities";
@@ -129,9 +127,8 @@ function updateClassNames(calendar, prefix) {
129
127
  }
130
128
  }
131
129
  const DatePicker = forwardRef((props, ref) => {
132
- const { allowInput, appendTo, children, className, closeOnSelect = true, dateFormat = "m/d/Y", datePickerType, disable, enable, inline, invalid, invalidText, warn, warnText, light = false, locale = "en", maxDate, minDate, onChange, onClose, onOpen, readOnly = false, short = false, value, parseDate: parseDateProp, nextMonthAriaLabel = "Next month", prevMonthAriaLabel = "Previous month", ...rest } = props;
130
+ const { allowInput, appendTo, children, className, closeOnSelect = true, dateFormat = "m/d/Y", datePickerType, disable, enable, inline, invalid, warn, light = false, locale = "en", maxDate, minDate, onChange, onClose, onOpen, readOnly = false, short = false, value, parseDate: parseDateProp, nextMonthAriaLabel = "Next month", prevMonthAriaLabel = "Previous month", ...rest } = props;
133
131
  const prefix = usePrefix();
134
- const { isFluid } = useContext(FormContext);
135
132
  const [hasInput, setHasInput] = useState(false);
136
133
  const startInputField = useCallback((node) => {
137
134
  if (node !== null) {
@@ -279,7 +276,7 @@ const DatePicker = forwardRef((props, ref) => {
279
276
  classFlatpickrCurrentMonth: "cur-month",
280
277
  locale
281
278
  }),
282
- fixEventsPlugin_default({
279
+ fixEventsPlugin({
283
280
  inputFrom: startInputField.current,
284
281
  inputTo: endInputField.current,
285
282
  lastStartValue,
@@ -435,24 +432,6 @@ const DatePicker = forwardRef((props, ref) => {
435
432
  startInputField
436
433
  ]);
437
434
  let fluidError;
438
- if (isFluid) {
439
- if (invalid) fluidError = /* @__PURE__ */ jsxs(Fragment, { children: [
440
- /* @__PURE__ */ jsx(WarningFilled, { className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--invalid` }),
441
- /* @__PURE__ */ jsx("hr", { className: `${prefix}--date-picker__divider` }),
442
- /* @__PURE__ */ jsx("div", {
443
- className: `${prefix}--form-requirement`,
444
- children: invalidText
445
- })
446
- ] });
447
- else if (warn) fluidError = /* @__PURE__ */ jsxs(Fragment, { children: [
448
- /* @__PURE__ */ jsx(WarningAltFilled, { className: `${prefix}--date-picker__icon ${prefix}--date-picker__icon--warn` }),
449
- /* @__PURE__ */ jsx("hr", { className: `${prefix}--date-picker__divider` }),
450
- /* @__PURE__ */ jsx("div", {
451
- className: `${prefix}--form-requirement`,
452
- children: warnText
453
- })
454
- ] });
455
- }
456
435
  return /* @__PURE__ */ jsxs("div", {
457
436
  className: wrapperClasses,
458
437
  ref,
@@ -480,7 +459,6 @@ DatePicker.propTypes = {
480
459
  enable: PropTypes.array,
481
460
  inline: PropTypes.bool,
482
461
  invalid: PropTypes.bool,
483
- invalidText: PropTypes.node,
484
462
  light: deprecate(PropTypes.bool, "The `light` prop for `DatePicker` has been deprecated in favor of the new `Layer` component. It will be removed in the next major release."),
485
463
  locale: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(SUPPORTED_LOCALES)]),
486
464
  maxDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
@@ -502,7 +480,6 @@ DatePicker.propTypes = {
502
480
  PropTypes.number
503
481
  ]),
504
482
  warn: PropTypes.bool,
505
- warnText: PropTypes.node,
506
483
  nextMonthAriaLabel: PropTypes.string,
507
484
  prevMonthAriaLabel: PropTypes.string
508
485
  };
@@ -1,2 +1,18 @@
1
- declare function _default(config: object): Plugin;
2
- export default _default;
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
+ import type { Plugin } from 'flatpickr/dist/types/options';
8
+ interface FixEventsPluginConfig {
9
+ inputFrom: HTMLInputElement;
10
+ inputTo?: HTMLInputElement | null;
11
+ lastStartValue: {
12
+ current: string;
13
+ };
14
+ container?: HTMLElement | null;
15
+ }
16
+ type FixEventsPlugin = (config: FixEventsPluginConfig) => Plugin;
17
+ declare const fixEventsPlugin: FixEventsPlugin;
18
+ export default fixEventsPlugin;
@@ -8,24 +8,16 @@
8
8
  import { ArrowDown, ArrowLeft, ArrowRight, Enter } from "../../../internal/keyboard/keys.js";
9
9
  import { match } from "../../../internal/keyboard/match.js";
10
10
 
11
- //#region src/components/DatePicker/plugins/fixEventsPlugin.js
12
- /**
13
- * Copyright IBM Corp. 2016, 2026
14
- *
15
- * This source code is licensed under the Apache-2.0 license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */
18
- /**
19
- * @param {object} config Plugin configuration.
20
- * @returns {Plugin} A Flatpickr plugin to fix Flatpickr's behavior of certain events.
21
- */
22
- var fixEventsPlugin_default = (config) => (fp) => {
11
+ //#region src/components/DatePicker/plugins/fixEventsPlugin.ts
12
+ const fixEventsPlugin = (config) => (fp) => {
23
13
  const { inputFrom, inputTo, lastStartValue, container } = config;
24
14
  let mouseDownInside = false;
25
15
  const getEventPath = (event) => typeof event.composedPath === "function" ? event.composedPath() : [];
26
16
  const isEventInside = (event) => {
27
17
  const path = getEventPath(event);
28
- return Boolean(container && (path.includes(container) || container.contains(event.target)) || fp.calendarContainer && (path.includes(fp.calendarContainer) || fp.calendarContainer.contains(event.target)) || inputFrom && (path.includes(inputFrom) || inputFrom.contains(event.target)) || inputTo && (path.includes(inputTo) || inputTo.contains(event.target)));
18
+ const { target } = event;
19
+ if (!(target instanceof Node)) return false;
20
+ return Boolean(container && (path.includes(container) || container.contains(target)) || fp.calendarContainer && (path.includes(fp.calendarContainer) || fp.calendarContainer.contains(target)) || inputFrom && (path.includes(inputFrom) || inputFrom.contains(target)) || inputTo && (path.includes(inputTo) || inputTo.contains(target)));
29
21
  };
30
22
  /**
31
23
  * Handles `click` outside to close calendar
@@ -55,7 +47,7 @@ var fixEventsPlugin_default = (config) => (fp) => {
55
47
  const { target } = event;
56
48
  if (inputFrom === target || inputTo === target) {
57
49
  if (match(event, Enter)) {
58
- fp.setDate([inputFrom.value, inputTo && inputTo.value], true, fp.config.dateFormat);
50
+ fp.setDate(inputTo ? [inputFrom.value, inputTo.value] : [inputFrom.value], true, fp.config.dateFormat);
59
51
  event.stopPropagation();
60
52
  } else if (match(event, ArrowLeft) || match(event, ArrowRight)) event.stopPropagation();
61
53
  else if (match(event, ArrowDown)) {
@@ -77,11 +69,12 @@ var fixEventsPlugin_default = (config) => (fp) => {
77
69
  */
78
70
  const handleBlur = (event) => {
79
71
  const { target } = event;
72
+ if (!inputTo) return;
80
73
  if (inputTo === target && fp.selectedDates[1]) {
81
74
  const withoutTime = (date) => date?.setHours(0, 0, 0, 0);
82
75
  const selectedToDate = withoutTime(new Date(fp.selectedDates[1]));
83
76
  const currentValueToDate = withoutTime(parseDateWithFormat(inputTo.value));
84
- if (selectedToDate && currentValueToDate && selectedToDate !== currentValueToDate) fp.setDate([inputFrom.value, inputTo && inputTo.value], true, fp.config.dateFormat);
77
+ if (selectedToDate && currentValueToDate && selectedToDate !== currentValueToDate) fp.setDate([inputFrom.value, inputTo.value], true, fp.config.dateFormat);
85
78
  }
86
79
  const isValidDate = (date) => date?.toString() !== "Invalid Date";
87
80
  if (inputTo === target && fp.selectedDates.length === 1 && inputTo.value) {
@@ -134,4 +127,4 @@ var fixEventsPlugin_default = (config) => (fp) => {
134
127
  };
135
128
 
136
129
  //#endregion
137
- export { fixEventsPlugin_default as default };
130
+ export { fixEventsPlugin as default };
@@ -10,8 +10,8 @@ import { Text } from "../Text/Text.js";
10
10
  import { useId } from "../../internal/useId.js";
11
11
  import { warning } from "../../internal/warning.js";
12
12
  import { deprecate } from "../../prop-types/deprecate.js";
13
- import { AILabel } from "../AILabel/index.js";
14
13
  import { isComponentElement } from "../../internal/utils.js";
14
+ import { AILabel } from "../AILabel/index.js";
15
15
  import { FormContext } from "../FluidForm/FormContext.js";
16
16
  import { useNormalizedInputProps } from "../../internal/useNormalizedInputProps.js";
17
17
  import classNames from "classnames";
@@ -110,7 +110,6 @@ const DatePickerInput = forwardRef((props, ref) => {
110
110
  className: `${prefix}--date-picker-input-inner-wrapper--decorator`,
111
111
  children: normalizedDecorator
112
112
  }) : "",
113
- isFluid && /* @__PURE__ */ jsx(DatePickerIcon, { datePickerType }),
114
113
  /* @__PURE__ */ jsx(DatePickerIcon, {
115
114
  datePickerType,
116
115
  invalid: normalizedProps.invalid,
@@ -7,10 +7,10 @@
7
7
 
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
9
  import { deprecate } from "../../prop-types/deprecate.js";
10
- import { useFeatureFlag } from "../FeatureFlags/index.js";
11
- import { AILabel } from "../AILabel/index.js";
12
10
  import { defaultItemToString } from "../../internal/defaultItemToString.js";
13
11
  import { isComponentElement } from "../../internal/utils.js";
12
+ import { useFeatureFlag } from "../FeatureFlags/index.js";
13
+ import { AILabel } from "../AILabel/index.js";
14
14
  import { ListBoxSizePropType, ListBoxTypePropType } from "../ListBox/ListBoxPropTypes.js";
15
15
  import { FormContext } from "../FluidForm/FormContext.js";
16
16
  import ListBox from "../ListBox/index.js";
@@ -20,7 +20,7 @@ import { jsx } from "react/jsx-runtime";
20
20
  * This source code is licensed under the Apache-2.0 license found in the
21
21
  * LICENSE file in the root directory of this source tree.
22
22
  */
23
- const FluidDatePicker = React.forwardRef(function FluidDatePicker({ className, children, invalid, invalidText, readOnly, warn, warnText, ...other }, ref) {
23
+ const FluidDatePicker = React.forwardRef(function FluidDatePicker({ className, children, invalid, readOnly, warn, ...other }, ref) {
24
24
  const prefix = usePrefix();
25
25
  const classNames$1 = classNames(className, {
26
26
  [`${prefix}--date-picker--fluid`]: true,
@@ -32,10 +32,8 @@ const FluidDatePicker = React.forwardRef(function FluidDatePicker({ className, c
32
32
  value: { isFluid: true },
33
33
  children: /* @__PURE__ */ jsx(DatePicker_default, {
34
34
  invalid,
35
- invalidText,
36
35
  readOnly,
37
36
  warn,
38
- warnText,
39
37
  className: classNames$1,
40
38
  ref,
41
39
  ...other,
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import React, { type ComponentProps } from 'react';
8
8
  import { MultiSelect, type MultiSelectProps } from '../MultiSelect';
9
- import { UseSelectProps } from 'downshift';
9
+ import { UseComboboxProps, UseSelectProps } from 'downshift';
10
10
  interface OnChangeData<ItemType> {
11
11
  selectedItems: ItemType[] | null;
12
12
  }
@@ -97,7 +97,7 @@ export interface FluidMultiSelectProps<ItemType> extends MultiSelectProps<ItemTy
97
97
  * **Filterable variant only** - `onInputValueChange` is a utility for this controlled component to communicate to
98
98
  * the currently typed input.
99
99
  */
100
- onInputValueChange?: (inputValue: string) => void;
100
+ onInputValueChange?: UseComboboxProps<ItemType>['onInputValueChange'];
101
101
  /**
102
102
  * `onMenuChange` is a utility for this controlled component to communicate to a
103
103
  * consuming component that the menu was open(`true`)/closed(`false`).
@@ -10,8 +10,8 @@ import { Text } from "../Text/Text.js";
10
10
  import { ArrowRight as ArrowRight$1, Enter, Space } from "../../internal/keyboard/keys.js";
11
11
  import { match } from "../../internal/keyboard/match.js";
12
12
  import { useId } from "../../internal/useId.js";
13
- import { useMergedRefs } from "../../internal/useMergedRefs.js";
14
13
  import { defaultItemToString } from "../../internal/defaultItemToString.js";
14
+ import { useMergedRefs } from "../../internal/useMergedRefs.js";
15
15
  import { MenuContext } from "./MenuContext.js";
16
16
  import { useLayoutDirection } from "../LayoutDirection/useLayoutDirection.js";
17
17
  import { Menu as Menu$1 } from "./Menu.js";
@@ -13,13 +13,13 @@ import { useId } from "../../internal/useId.js";
13
13
  import { noopFn } from "../../internal/noopFn.js";
14
14
  import { warning } from "../../internal/warning.js";
15
15
  import { deprecate } from "../../prop-types/deprecate.js";
16
+ import { isComponentElement } from "../../internal/utils.js";
16
17
  import { useMergedRefs } from "../../internal/useMergedRefs.js";
17
18
  import { useFeatureFlag } from "../FeatureFlags/index.js";
18
19
  import { IconButton } from "../IconButton/index.js";
19
20
  import Button_default from "../Button/index.js";
20
21
  import ButtonSet_default from "../ButtonSet/index.js";
21
22
  import { AILabel } from "../AILabel/index.js";
22
- import { isComponentElement } from "../../internal/utils.js";
23
23
  import { useResizeObserver } from "../../internal/useResizeObserver.js";
24
24
  import { composeEventHandlers } from "../../tools/events.js";
25
25
  import { Layer } from "../Layer/index.js";
@@ -11,9 +11,9 @@ import { match } from "../../internal/keyboard/match.js";
11
11
  import useIsomorphicEffect from "../../internal/useIsomorphicEffect.js";
12
12
  import { useId } from "../../internal/useId.js";
13
13
  import { deprecate } from "../../prop-types/deprecate.js";
14
- import { AILabel } from "../AILabel/index.js";
15
14
  import { defaultItemToString } from "../../internal/defaultItemToString.js";
16
15
  import { isComponentElement } from "../../internal/utils.js";
16
+ import { AILabel } from "../AILabel/index.js";
17
17
  import Checkbox_default from "../Checkbox/index.js";
18
18
  import { ListBoxSizePropType, ListBoxTypePropType } from "../ListBox/ListBoxPropTypes.js";
19
19
  import { FormContext } from "../FluidForm/FormContext.js";
@@ -290,7 +290,7 @@ const FilterableMultiSelect = forwardRef(function FilterableMultiSelect({ autoAl
290
290
  highlightedIndex: controlledSelectedItems.length > 0 ? 0 : -1
291
291
  };
292
292
  case InputChange:
293
- if (onInputValueChange) onInputValueChange(changes.inputValue);
293
+ if (onInputValueChange) onInputValueChange(changes);
294
294
  setInputValue(changes.inputValue ?? "");
295
295
  setIsOpen(true);
296
296
  return {
@@ -12,10 +12,10 @@ import useIsomorphicEffect from "../../internal/useIsomorphicEffect.js";
12
12
  import { useId } from "../../internal/useId.js";
13
13
  import { noopFn } from "../../internal/noopFn.js";
14
14
  import { deprecate } from "../../prop-types/deprecate.js";
15
- import { useFeatureFlag } from "../FeatureFlags/index.js";
16
- import { AILabel } from "../AILabel/index.js";
17
15
  import { defaultItemToString } from "../../internal/defaultItemToString.js";
18
16
  import { isComponentElement } from "../../internal/utils.js";
17
+ import { useFeatureFlag } from "../FeatureFlags/index.js";
18
+ import { AILabel } from "../AILabel/index.js";
19
19
  import Checkbox_default from "../Checkbox/index.js";
20
20
  import { ListBoxSizePropType, ListBoxTypePropType } from "../ListBox/ListBoxPropTypes.js";
21
21
  import { FormContext } from "../FluidForm/FormContext.js";
@@ -10,9 +10,9 @@ import { Text } from "../Text/Text.js";
10
10
  import { ArrowDown, ArrowUp as ArrowUp$1 } from "../../internal/keyboard/keys.js";
11
11
  import { match } from "../../internal/keyboard/match.js";
12
12
  import { deprecate } from "../../prop-types/deprecate.js";
13
+ import { isComponentElement } from "../../internal/utils.js";
13
14
  import { useMergedRefs } from "../../internal/useMergedRefs.js";
14
15
  import { AILabel } from "../AILabel/index.js";
15
- import { isComponentElement } from "../../internal/utils.js";
16
16
  import { FormContext } from "../FluidForm/FormContext.js";
17
17
  import { useNormalizedInputProps } from "../../internal/useNormalizedInputProps.js";
18
18
  import { useControllableState } from "../../internal/useControllableState.js";
@@ -373,7 +373,7 @@ const NumberInput = React.forwardRef((props, forwardRef) => {
373
373
  onChange: handleOnChange,
374
374
  onKeyUp,
375
375
  onKeyDown: (e) => {
376
- if (type === "text") {
376
+ if (type === "text" && !readOnly && !disabled) {
377
377
  if (match(e, ArrowUp$1)) handleStep(e, "up");
378
378
  else if (match(e, ArrowDown)) handleStep(e, "down");
379
379
  }
@@ -8,10 +8,11 @@
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
9
  import { useFallbackId } from "../../internal/useId.js";
10
10
  import { IconButton } from "../IconButton/index.js";
11
+ import { usePreviousValue } from "../../internal/usePreviousValue.js";
11
12
  import Select_default from "../Select/index.js";
12
13
  import SelectItem_default from "../SelectItem/index.js";
13
14
  import classNames from "classnames";
14
- import React, { useEffect, useRef, useState } from "react";
15
+ import React, { useEffect, useMemo, useRef, useState } from "react";
15
16
  import PropTypes from "prop-types";
16
17
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
17
18
  import { CaretLeft, CaretRight } from "@carbon/icons-react";
@@ -24,12 +25,14 @@ import isEqual from "react-fast-compare";
24
25
  * This source code is licensed under the Apache-2.0 license found in the
25
26
  * LICENSE file in the root directory of this source tree.
26
27
  */
27
- function mapPageSizesToObject(sizes) {
28
- return typeof sizes[0] === "object" && sizes[0] !== null ? sizes : sizes.map((size) => ({
29
- text: size,
28
+ const isPaginationPageSizeArray = (sizes) => typeof sizes[0] === "object" && sizes[0] !== null;
29
+ const mapPageSizesToObject = (sizes) => {
30
+ if (isPaginationPageSizeArray(sizes)) return sizes;
31
+ return sizes.map((size) => ({
32
+ text: String(size),
30
33
  value: size
31
34
  }));
32
- }
35
+ };
33
36
  function renderSelectItems(total) {
34
37
  let counter = 1;
35
38
  const itemArr = [];
@@ -42,30 +45,29 @@ function renderSelectItems(total) {
42
45
  }
43
46
  return itemArr;
44
47
  }
45
- function getPageSize(pageSizes, pageSize) {
46
- if (pageSize) {
48
+ const getPageSize = (pageSizes, pageSize) => {
49
+ if (typeof pageSize !== "undefined") {
47
50
  if (pageSizes.find((size) => {
48
51
  return pageSize === size.value;
49
52
  })) return pageSize;
50
53
  }
51
54
  return pageSizes[0].value;
52
- }
55
+ };
53
56
  const Pagination = React.forwardRef(({ backwardText = "Previous page", className: customClassName = "", disabled = false, forwardText = "Next page", id, isLastPage = false, itemText = (min, max) => `${min}–${max} items`, itemRangeText = (min, max, total) => `${min}–${max} of ${total} items`, itemsPerPageText = "Items per page:", onChange, pageNumberText: _pageNumberText, pageRangeText = (_current, total) => `of ${total} ${total === 1 ? "page" : "pages"}`, pageSelectLabelText = (total) => `Page of ${total} ${total === 1 ? "page" : "pages"}`, page: controlledPage = 1, pageInputDisabled, pageSize: controlledPageSize, pageSizeInputDisabled, pageSizes: controlledPageSizes, pageText = (page) => `page ${page}`, pagesUnknown = false, size = "md", totalItems, ...rest }, ref) => {
54
57
  const prefix = usePrefix();
55
58
  const inputId = useFallbackId(id?.toString());
56
59
  const backBtnRef = useRef(null);
57
60
  const forwardBtnRef = useRef(null);
58
- const [pageSizes, setPageSizes] = useState(() => {
59
- return mapPageSizesToObject(controlledPageSizes);
60
- });
61
- const [prevPageSizes, setPrevPageSizes] = useState(controlledPageSizes);
61
+ const pendingChangeRef = useRef(null);
62
+ const normalizedControlledPageSizes = useMemo(() => mapPageSizesToObject(controlledPageSizes), [controlledPageSizes]);
63
+ const prevControlledPageSize = usePreviousValue(controlledPageSize);
64
+ const prevControlledPageSizes = usePreviousValue(normalizedControlledPageSizes);
65
+ const [pageSizes, setPageSizes] = useState(normalizedControlledPageSizes);
62
66
  const [page, setPage] = useState(controlledPage);
63
- const [prevControlledPage, setPrevControlledPage] = useState(controlledPage);
64
67
  const [focusTarget, setFocusTarget] = useState(null);
65
68
  const [pageSize, setPageSize] = useState(() => {
66
- return getPageSize(pageSizes, controlledPageSize);
69
+ return getPageSize(normalizedControlledPageSizes, controlledPageSize);
67
70
  });
68
- const [prevControlledPageSize, setPrevControlledPageSize] = useState(controlledPageSize);
69
71
  const className = classNames({
70
72
  [`${prefix}--pagination`]: true,
71
73
  [`${prefix}--pagination--${size}`]: size,
@@ -99,22 +101,51 @@ const Pagination = React.forwardRef(({ backwardText = "Previous page", className
99
101
  setFocusTarget(null);
100
102
  }
101
103
  }, [focusTarget]);
102
- if (controlledPage !== prevControlledPage) {
104
+ useEffect(() => {
105
+ if (pendingChangeRef.current && onChange) {
106
+ onChange(pendingChangeRef.current);
107
+ pendingChangeRef.current = null;
108
+ }
109
+ }, [
110
+ onChange,
111
+ page,
112
+ pageSize
113
+ ]);
114
+ useEffect(() => {
103
115
  setPage(controlledPage);
104
- setPrevControlledPage(controlledPage);
105
- }
106
- if (controlledPageSize !== prevControlledPageSize) {
107
- setPageSize(getPageSize(pageSizes, controlledPageSize));
108
- setPrevControlledPageSize(controlledPageSize);
109
- }
110
- if (!isEqual(controlledPageSizes, prevPageSizes)) {
111
- const pageSizes = mapPageSizesToObject(controlledPageSizes);
112
- if (!pageSizes.find((size) => {
116
+ }, [controlledPage]);
117
+ useEffect(() => {
118
+ if (typeof prevControlledPageSizes === "undefined" || isEqual(prevControlledPageSizes, normalizedControlledPageSizes)) return;
119
+ setPageSizes((prev) => isEqual(normalizedControlledPageSizes, prev) ? prev : normalizedControlledPageSizes);
120
+ const nextPageSize = getPageSize(normalizedControlledPageSizes, controlledPageSize ?? pageSize);
121
+ const hasPageSize = normalizedControlledPageSizes.some((size) => {
113
122
  return size.value === pageSize;
114
- })) setPage(1);
115
- setPageSizes(pageSizes);
116
- setPrevPageSizes(controlledPageSizes);
117
- }
123
+ });
124
+ const nextPage = hasPageSize ? page : 1;
125
+ const hasControlledPageSize = typeof controlledPageSize !== "undefined";
126
+ const hasValidControlledPageSize = hasControlledPageSize ? normalizedControlledPageSizes.some((size) => size.value === controlledPageSize) : false;
127
+ if (!hasPageSize) setPage(nextPage);
128
+ if (nextPageSize !== pageSize) setPageSize(nextPageSize);
129
+ if (onChange && (!hasControlledPageSize || !hasValidControlledPageSize) && (nextPage !== page || nextPageSize !== pageSize)) pendingChangeRef.current = {
130
+ page: nextPage,
131
+ pageSize: nextPageSize
132
+ };
133
+ }, [
134
+ controlledPageSize,
135
+ normalizedControlledPageSizes,
136
+ onChange,
137
+ page,
138
+ pageSize,
139
+ prevControlledPageSizes
140
+ ]);
141
+ useEffect(() => {
142
+ if (controlledPageSize === prevControlledPageSize) return;
143
+ setPageSize(getPageSize(normalizedControlledPageSizes, controlledPageSize));
144
+ }, [
145
+ controlledPageSize,
146
+ normalizedControlledPageSizes,
147
+ prevControlledPageSize
148
+ ]);
118
149
  function handleSizeChange(event) {
119
150
  const changes = {
120
151
  pageSize: Number(event.target.value),
@@ -8,6 +8,7 @@
8
8
  import { usePrefix } from "../../internal/usePrefix.js";
9
9
  import useIsomorphicEffect from "../../internal/useIsomorphicEffect.js";
10
10
  import { deprecateValuesWithin } from "../../prop-types/deprecateValuesWithin.js";
11
+ import { isComponentElement } from "../../internal/utils.js";
11
12
  import { useMergedRefs } from "../../internal/useMergedRefs.js";
12
13
  import { useEvent, useWindowEvent } from "../../internal/useEvent.js";
13
14
  import { mapPopoverAlign } from "../../tools/mapPopoverAlign.js";
@@ -202,7 +203,9 @@ const Popover = React.forwardRef(function PopoverRenderFunction({ isTabTip, alig
202
203
  }, customClassName);
203
204
  const mappedChildren = React.Children.map(children, (child) => {
204
205
  const item = child;
205
- const displayName = item?.type?.displayName;
206
+ const isToggletipButton = item?.type?.displayName === "ToggletipButton";
207
+ const isToggletipContent = item?.type?.displayName === "ToggletipContent";
208
+ const isPopoverContent = isComponentElement(item, PopoverContent);
206
209
  /**
207
210
  * Only trigger elements (button) or trigger components (ToggletipButton) should be
208
211
  * cloned because these will be decorated with a trigger-specific className and ref.
@@ -211,8 +214,8 @@ const Popover = React.forwardRef(function PopoverRenderFunction({ isTabTip, alig
211
214
  * is on, even if they are a trigger element.
212
215
  */
213
216
  const isTriggerElement = item?.type === "button";
214
- const isTriggerComponent = enableFloatingStyles && displayName && ["ToggletipButton"].includes(displayName);
215
- const isAllowedTriggerComponent = enableFloatingStyles && !["ToggletipContent", "PopoverContent"].includes(displayName);
217
+ const isTriggerComponent = enableFloatingStyles && isToggletipButton;
218
+ const isAllowedTriggerComponent = enableFloatingStyles && !isToggletipContent && !isPopoverContent;
216
219
  if (React.isValidElement(item) && (isTriggerElement || isTriggerComponent || isAllowedTriggerComponent)) {
217
220
  const className = (item?.props)?.className;
218
221
  const ref = (item?.props).ref;
@@ -220,7 +223,7 @@ const Popover = React.forwardRef(function PopoverRenderFunction({ isTabTip, alig
220
223
  return React.cloneElement(item, {
221
224
  className: isTabTip && item?.type === "button" ? tabTipClasses : className || "",
222
225
  ref: (node) => {
223
- if (enableFloatingStyles && item?.type !== PopoverContent || enableFloatingStyles && item?.type["displayName"] === "ToggletipButton") refs.setReference(node);
226
+ if (enableFloatingStyles && !isPopoverContent) refs.setReference(node);
224
227
  if (typeof ref === "function") ref(node);
225
228
  else if (ref !== null && ref !== void 0) ref.current = node;
226
229
  }