@carbon/ibm-products 2.60.0 → 2.61.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 (143) hide show
  1. package/css/index-full-carbon.css +113 -497
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +64 -492
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +93 -492
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +93 -510
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/ActionBar/ActionBar.d.ts +3 -3
  18. package/es/components/ActionBar/ActionBar.js +47 -150
  19. package/es/components/ActionBar/ActionBarOverflowItems.js +1 -1
  20. package/es/components/Checklist/ChecklistChart.js +1 -1
  21. package/es/components/Coachmark/Coachmark.js +1 -1
  22. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +1 -1
  23. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +3 -3
  24. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +4 -1
  25. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +7 -2
  26. package/es/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +7 -2
  27. package/es/components/ConditionBuilder/utils/handleKeyboardEvents.js +15 -15
  28. package/es/components/ConditionBuilder/utils/util.d.ts +1 -0
  29. package/es/components/ConditionBuilder/utils/util.js +7 -1
  30. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +1 -3
  31. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +2 -2
  32. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  33. package/es/components/Datagrid/useDatagrid.js +2 -2
  34. package/es/components/Datagrid/useInfiniteScroll.js +2 -5
  35. package/es/components/Datagrid/useRowIsMouseOver.d.ts +1 -1
  36. package/es/components/Datagrid/useRowIsMouseOver.js +2 -1
  37. package/es/components/Datagrid/useStickyColumn.d.ts +1 -1
  38. package/es/components/Datagrid/useStickyColumn.js +1 -1
  39. package/es/components/FilterSummary/FilterSummary.js +1 -1
  40. package/es/components/InterstitialScreen/InterstitialScreen.js +1 -1
  41. package/es/components/Nav/NavItem.js +1 -1
  42. package/es/components/NotificationsPanel/NotificationsPanel.d.ts +5 -0
  43. package/es/components/NotificationsPanel/NotificationsPanel.js +11 -17
  44. package/es/components/OptionsTile/OptionsTile.d.ts +2 -3
  45. package/es/components/OptionsTile/OptionsTile.js +49 -97
  46. package/es/components/PageHeader/PageHeader.js +16 -14
  47. package/es/components/PageHeader/PageHeaderTitle.js +2 -2
  48. package/es/components/ScrollGradient/ScrollGradient.js +74 -25
  49. package/es/components/ScrollGradient/constants.d.ts +0 -5
  50. package/es/components/ScrollGradient/constants.js +2 -47
  51. package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +1 -1
  52. package/es/components/TagOverflow/TagOverflow.d.ts +5 -1
  53. package/es/components/Tearsheet/Tearsheet.d.ts +5 -1
  54. package/es/components/Tearsheet/TearsheetNarrow.d.ts +5 -1
  55. package/es/components/WebTerminal/WebTerminal.js +0 -13
  56. package/es/global/js/hooks/useControllableState.d.ts +12 -24
  57. package/es/global/js/hooks/useControllableState.js +18 -60
  58. package/es/global/js/hooks/useOverflowItems.d.ts +7 -2
  59. package/es/global/js/hooks/useOverflowItems.js +50 -17
  60. package/es/global/js/hooks/useOverflowString.d.ts +9 -0
  61. package/es/global/js/hooks/useOverflowString.js +52 -0
  62. package/es/global/js/hooks/usePresence.d.ts +1 -1
  63. package/es/global/js/hooks/usePresence.js +2 -2
  64. package/es/global/js/utils/checkForOverflow.js +1 -11
  65. package/es/global/js/utils/clamp.d.ts +7 -0
  66. package/es/global/js/utils/clamp.js +25 -0
  67. package/es/global/js/utils/debounce.d.ts +7 -0
  68. package/es/global/js/utils/debounce.js +30 -0
  69. package/es/global/js/utils/deepCompareObject.d.ts +7 -0
  70. package/es/global/js/utils/deepCompareObject.js +47 -0
  71. package/es/global/js/utils/throttle.d.ts +7 -0
  72. package/es/global/js/utils/throttle.js +19 -0
  73. package/es/global/js/utils/uuidv4.d.ts +2 -2
  74. package/es/global/js/utils/uuidv4.js +3 -2
  75. package/es/node_modules/@carbon/icons-react/es/generated/bucket-10.js +2787 -0
  76. package/es/node_modules/@carbon/icons-react/es/generated/bucket-3.js +1013 -943
  77. package/lib/components/ActionBar/ActionBar.d.ts +3 -3
  78. package/lib/components/ActionBar/ActionBar.js +45 -148
  79. package/lib/components/ActionBar/ActionBarOverflowItems.js +1 -1
  80. package/lib/components/Checklist/ChecklistChart.js +2 -2
  81. package/lib/components/Coachmark/Coachmark.js +2 -2
  82. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +4 -4
  83. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItem.js +2 -2
  84. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemDate/ConditionBuilderItemDate.js +3 -0
  85. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOption.js +6 -1
  86. package/lib/components/ConditionBuilder/ConditionBuilderItem/ConditionBuilderItemOption/ItemOptionForValueField.js +6 -1
  87. package/lib/components/ConditionBuilder/utils/handleKeyboardEvents.js +15 -15
  88. package/lib/components/ConditionBuilder/utils/util.d.ts +1 -0
  89. package/lib/components/ConditionBuilder/utils/util.js +7 -0
  90. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/common.js +1 -3
  91. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js +2 -2
  92. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  93. package/lib/components/Datagrid/useDatagrid.js +2 -2
  94. package/lib/components/Datagrid/useInfiniteScroll.js +2 -5
  95. package/lib/components/Datagrid/useRowIsMouseOver.d.ts +1 -1
  96. package/lib/components/Datagrid/useRowIsMouseOver.js +3 -2
  97. package/lib/components/Datagrid/useStickyColumn.d.ts +1 -1
  98. package/lib/components/Datagrid/useStickyColumn.js +2 -2
  99. package/lib/components/FilterSummary/FilterSummary.js +2 -2
  100. package/lib/components/InterstitialScreen/InterstitialScreen.js +3 -3
  101. package/lib/components/Nav/NavItem.js +2 -2
  102. package/lib/components/NotificationsPanel/NotificationsPanel.d.ts +5 -0
  103. package/lib/components/NotificationsPanel/NotificationsPanel.js +11 -17
  104. package/lib/components/OptionsTile/OptionsTile.d.ts +2 -3
  105. package/lib/components/OptionsTile/OptionsTile.js +49 -97
  106. package/lib/components/PageHeader/PageHeader.js +16 -14
  107. package/lib/components/PageHeader/PageHeaderTitle.js +2 -2
  108. package/lib/components/ScrollGradient/ScrollGradient.js +72 -23
  109. package/lib/components/ScrollGradient/constants.d.ts +0 -5
  110. package/lib/components/ScrollGradient/constants.js +1 -48
  111. package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +2 -2
  112. package/lib/components/TagOverflow/TagOverflow.d.ts +5 -1
  113. package/lib/components/Tearsheet/Tearsheet.d.ts +5 -1
  114. package/lib/components/Tearsheet/TearsheetNarrow.d.ts +5 -1
  115. package/lib/components/WebTerminal/WebTerminal.js +0 -13
  116. package/lib/global/js/hooks/useControllableState.d.ts +12 -24
  117. package/lib/global/js/hooks/useControllableState.js +17 -59
  118. package/lib/global/js/hooks/useOverflowItems.d.ts +7 -2
  119. package/lib/global/js/hooks/useOverflowItems.js +49 -16
  120. package/lib/global/js/hooks/useOverflowString.d.ts +9 -0
  121. package/lib/global/js/hooks/useOverflowString.js +55 -0
  122. package/lib/global/js/hooks/usePresence.d.ts +1 -1
  123. package/lib/global/js/hooks/usePresence.js +2 -2
  124. package/lib/global/js/utils/checkForOverflow.js +0 -11
  125. package/lib/global/js/utils/clamp.d.ts +7 -0
  126. package/lib/global/js/utils/clamp.js +27 -0
  127. package/lib/global/js/utils/debounce.d.ts +7 -0
  128. package/lib/global/js/utils/debounce.js +32 -0
  129. package/lib/global/js/utils/deepCompareObject.d.ts +7 -0
  130. package/lib/global/js/utils/deepCompareObject.js +49 -0
  131. package/lib/global/js/utils/throttle.d.ts +7 -0
  132. package/lib/global/js/utils/throttle.js +21 -0
  133. package/lib/global/js/utils/uuidv4.d.ts +2 -2
  134. package/lib/global/js/utils/uuidv4.js +3 -2
  135. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-10.js +2913 -0
  136. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-3.js +1018 -948
  137. package/package.json +6 -7
  138. package/scss/components/NotificationsPanel/_notifications-panel.scss +33 -20
  139. package/scss/components/ScrollGradient/_scroll-gradient.scss +30 -0
  140. package/scss/components/UserAvatar/_user-avatar.scss +2 -6
  141. package/scss/components/WebTerminal/_web-terminal.scss +13 -1
  142. package/es/node_modules/@carbon/icons-react/es/generated/bucket-9.js +0 -2959
  143. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-9.js +0 -3085
@@ -8,57 +8,12 @@
8
8
  import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import { useState, useCallback, useEffect, useLayoutEffect } from 'react';
10
10
 
11
- var ScrollDirection = {
12
- X: 'X',
13
- Y: 'Y'
14
- };
15
11
  var ScrollStates = {
16
12
  // No scrolling required because content fits within container.
17
- NONE: 'NONE',
18
- // Scroll position is a the start of the scrollable content.
19
- INITIAL: 'INITIAL',
20
- // Scroll position is neither at start or end of scrollable content.
21
- STARTED: 'STARTED',
22
- // Scroll position is a the end of the scrollable content.
23
- END: 'END'
24
- };
13
+ NONE: 'NONE'};
25
14
 
26
15
  // FUNCTIONS
27
16
 
28
- var getScrollState = function getScrollState(element, scrollDirection) {
29
- // console.log('getScrollState - element: ', element);
30
- // console.log('getScrollState - scrollDirection: ', scrollDirection);
31
- // console.log('-------------------------------------------------');
32
- switch (scrollDirection) {
33
- case ScrollDirection.X:
34
- {
35
- if (element.scrollWidth === element.clientWidth) {
36
- return ScrollStates.NONE;
37
- }
38
- if (element.scrollLeft === 0) {
39
- return ScrollStates.INITIAL;
40
- }
41
- if (element.scrollLeft + element.clientWidth === element.scrollWidth) {
42
- return ScrollStates.END;
43
- }
44
- return ScrollStates.STARTED;
45
- }
46
- case ScrollDirection.Y:
47
- default:
48
- {
49
- if (element.scrollHeight === element.clientHeight) {
50
- return ScrollStates.NONE;
51
- }
52
- if (element.scrollTop === 0) {
53
- return ScrollStates.INITIAL;
54
- }
55
- if (element.scrollTop + element.clientHeight === element.scrollHeight) {
56
- return ScrollStates.END;
57
- }
58
- return ScrollStates.STARTED;
59
- }
60
- }
61
- };
62
17
  var useIsOverflow = function useIsOverflow(ref) {
63
18
  var _useState = useState(),
64
19
  _useState2 = _slicedToArray(_useState, 2),
@@ -118,4 +73,4 @@ var useIsOverflow = function useIsOverflow(ref) {
118
73
  };
119
74
  };
120
75
 
121
- export { ScrollDirection, ScrollStates, getScrollState, useIsOverflow };
76
+ export { ScrollStates, useIsOverflow };
@@ -8,9 +8,9 @@
8
8
  import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default, { useState, useRef, useEffect } from 'react';
10
10
  import lottie from 'lottie-web';
11
- import clamp from 'lodash/clamp';
12
11
  import PropTypes from '../../_virtual/index.js';
13
12
  import cx from 'classnames';
13
+ import { clamp } from '../../global/js/utils/clamp.js';
14
14
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
15
15
  import { pkg } from '../../settings.js';
16
16
 
@@ -43,7 +43,11 @@ export interface TagOverflowProps {
43
43
  overflowAlign?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-bottom' | 'left-top' | 'right' | 'right-bottom' | 'right-top';
44
44
  overflowClassName?: string;
45
45
  overflowType?: 'default' | 'tag';
46
- onOverflowTagChange?: (arr: TagOverflowItem[]) => void;
46
+ onOverflowTagChange?: (value: {
47
+ hiddenItems?: TagOverflowItem[];
48
+ minWidth?: number;
49
+ maxWidth?: number;
50
+ }) => void;
47
51
  showAllTagsLabel?: string;
48
52
  tagComponent?: string;
49
53
  }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { type ButtonProps } from '@carbon/react';
8
- import React, { PropsWithChildren, ReactNode } from 'react';
8
+ import React, { PropsWithChildren, ReactNode, RefObject } from 'react';
9
9
  export interface TearsheetAction extends ButtonProps<'button'> {
10
10
  label?: string;
11
11
  }
@@ -79,6 +79,10 @@ export interface TearsheetProps extends PropsWithChildren {
79
79
  * to page of a multi-page task).
80
80
  */
81
81
  label?: ReactNode;
82
+ /**
83
+ * Provide a ref to return focus to once the tearsheet is closed.
84
+ */
85
+ launcherButtonRef?: RefObject<any>;
82
86
  /**
83
87
  * Navigation content, such as a set of tabs, to be displayed at the bottom
84
88
  * of the header area of the tearsheet.
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { ButtonProps } from '@carbon/react';
8
- import React, { PropsWithChildren, ReactNode } from 'react';
8
+ import React, { PropsWithChildren, ReactNode, RefObject } from 'react';
9
9
  export interface TearsheetNarrowProps extends PropsWithChildren {
10
10
  /**
11
11
  * The navigation actions to be shown as buttons in the action area at the
@@ -52,6 +52,10 @@ export interface TearsheetNarrowProps extends PropsWithChildren {
52
52
  * to page of a multi-page task).
53
53
  */
54
54
  label?: ReactNode;
55
+ /**
56
+ * Provide a ref to return focus to once the tearsheet is closed.
57
+ */
58
+ launcherButtonRef?: RefObject<any>;
55
59
  /**
56
60
  * An optional handler that is called when the user closes the tearsheet (by
57
61
  * clicking the close button, if enabled, or clicking outside, if enabled).
@@ -12,11 +12,9 @@ import React__default, { useRef, useState, useMemo, useEffect } from 'react';
12
12
  import PropTypes from '../../_virtual/index.js';
13
13
  import cx from 'classnames';
14
14
  import { getDevtoolsProps } from '../../global/js/utils/devtools.js';
15
- import { moderate02 } from '@carbon/motion';
16
15
  import { pkg } from '../../settings.js';
17
16
  import { useWebTerminal } from './hooks/index.js';
18
17
  import { usePrefersReducedMotion } from '../../global/js/hooks/usePrefersReducedMotion.js';
19
- import { useIsomorphicEffect } from '../../global/js/hooks/useIsomorphicEffect.js';
20
18
 
21
19
  var _excluded = ["actions", "children", "className", "closeIconDescription", "documentationLinks", "documentationLinksIconDescription", "isInitiallyOpen", "webTerminalAriaLabel"];
22
20
 
@@ -61,17 +59,6 @@ var WebTerminal = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
61
59
  shouldRender = _useState2[0],
62
60
  setRender = _useState2[1];
63
61
  var shouldReduceMotion = usePrefersReducedMotion();
64
- var webTerminalAnimationName = "".concat(open ? 'web-terminal-entrance' : 'web-terminal-exit forwards', " ").concat(moderate02);
65
- useIsomorphicEffect(function () {
66
- var timeout = setTimeout(function () {
67
- if (webTerminalRef.current && !shouldReduceMotion) {
68
- webTerminalRef.current.style.animation = webTerminalAnimationName;
69
- }
70
- }, 0);
71
- return function () {
72
- return clearTimeout(timeout);
73
- };
74
- }, [shouldReduceMotion, webTerminalAnimationName, webTerminalRef]);
75
62
  var showDocumentationLinks = useMemo(function () {
76
63
  return documentationLinks.length > 0;
77
64
  }, [documentationLinks]);
@@ -1,27 +1,15 @@
1
1
  /**
2
- * This custom hook simplifies the behavior of a component if it has state that
3
- * can be both controlled and uncontrolled. It functions identical to a
4
- * useState() hook and provides [state, setState] for you to use. You can use
5
- * the `onChange` argument to allow updates to the `state` to be communicated to
6
- * owners of controlled components.
2
+ * Copyright IBM Corp. 2025, 2025
7
3
  *
8
- * Note: this hook will warn if a component is switching from controlled to
9
- * uncontrolled, or vice-versa.
10
- *
11
- * @param {object} config
12
- * @param {string} config.name - the name of the custom component
13
- * @param {any} config.defaultValue - the default value used for the state. This will be
14
- * the fallback value used if `value` is not defined.
15
- * @param {Function} config.onChange - an optional function that is called when
16
- * the value of the state changes. This is useful for communicating to parents of
17
- * controlled components that the value is requesting to be changed.
18
- * @param {any} config.value - a controlled value. Omitting this means that the state is
19
- * uncontrolled
20
- * @returns {[any, Function]}
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
+ type Callback<T> = (value: T) => void;
8
+ /**
9
+ * handles controlling state for any component that utilizes controlled and uncontrolled state
10
+ * @param {T} value - any generic value being held in state
11
+ * @param {Callback} onChange - a callback function to handle state change when the user puts the component in a controlled state
12
+ * @returns {[value: T, Callback]}
21
13
  */
22
- export function useControllableState({ defaultValue, name, onChange, value, }: {
23
- name: string;
24
- defaultValue: any;
25
- onChange: Function;
26
- value: any;
27
- }): [any, Function];
14
+ export declare function useControllableState<T>(value: T, onChange?: Callback<T>): [T, Callback<T>];
15
+ export {};
@@ -6,71 +6,29 @@
6
6
  */
7
7
 
8
8
  import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import { useState, useRef, useEffect } from 'react';
10
- import pconsole from '../utils/pconsole.js';
9
+ import { useState, useCallback } from 'react';
11
10
 
12
11
  /**
13
- * This custom hook simplifies the behavior of a component if it has state that
14
- * can be both controlled and uncontrolled. It functions identical to a
15
- * useState() hook and provides [state, setState] for you to use. You can use
16
- * the `onChange` argument to allow updates to the `state` to be communicated to
17
- * owners of controlled components.
18
- *
19
- * Note: this hook will warn if a component is switching from controlled to
20
- * uncontrolled, or vice-versa.
21
- *
22
- * @param {object} config
23
- * @param {string} config.name - the name of the custom component
24
- * @param {any} config.defaultValue - the default value used for the state. This will be
25
- * the fallback value used if `value` is not defined.
26
- * @param {Function} config.onChange - an optional function that is called when
27
- * the value of the state changes. This is useful for communicating to parents of
28
- * controlled components that the value is requesting to be changed.
29
- * @param {any} config.value - a controlled value. Omitting this means that the state is
30
- * uncontrolled
31
- * @returns {[any, Function]}
12
+ * handles controlling state for any component that utilizes controlled and uncontrolled state
13
+ * @param {T} value - any generic value being held in state
14
+ * @param {Callback} onChange - a callback function to handle state change when the user puts the component in a controlled state
15
+ * @returns {[value: T, Callback]}
32
16
  */
33
- function useControllableState(_ref) {
34
- var defaultValue = _ref.defaultValue,
35
- _ref$name = _ref.name,
36
- name = _ref$name === undefined ? 'custom' : _ref$name,
37
- onChange = _ref.onChange,
38
- value = _ref.value;
39
- var _useState = useState(value !== null && value !== undefined ? value : defaultValue),
40
- _useState2 = _slicedToArray(_useState, 2),
41
- state = _useState2[0],
42
- internalSetState = _useState2[1];
43
- var controlled = useRef(null);
44
- if (controlled.current === null) {
45
- controlled.current = value !== undefined;
17
+ function useControllableState(value, onChange) {
18
+ if (typeof value === 'function') {
19
+ throw new TypeError('Functions are not supported');
46
20
  }
47
- function setState(stateOrUpdater) {
48
- var value = typeof stateOrUpdater === 'function' ? stateOrUpdater(state) : stateOrUpdater;
49
- if (controlled.current === false) {
50
- internalSetState(value);
51
- }
52
- if (onChange) {
53
- onChange(value);
54
- }
55
- }
56
- useEffect(function () {
57
- var controlledValue = value !== undefined;
58
- // Uncontrolled -> Controlled
59
- // If the component prop is uncontrolled, the prop value should be undefined
60
- if (controlled.current === false && controlledValue) {
61
- pconsole.warn("A component is changing an uncontrolled %s component to be controlled.\n This is likely caused by the value changing to a defined value\n from undefined. Decide between using a controlled or uncontrolled\n value for the lifetime of the component.\n More info: https://reactjs.org/link/controlled-components");
62
- }
63
-
64
- // Controlled -> Uncontrolled
65
- // If the component prop is controlled, the prop value should be defined
66
- if (controlled.current === true && !controlledValue) {
67
- pconsole.warn("A component is changing a controlled %s component to be uncontrolled.\n 'This is likely caused by the value changing to an undefined value\n 'from a defined one. Decide between using a controlled or\n 'uncontrolled value for the lifetime of the component.\n 'More info: https://reactjs.org/link/controlled-components");
68
- }
69
- }, [name, value]);
70
- if (controlled.current === true) {
71
- return [value, setState];
21
+ var _useState = useState(value),
22
+ _useState2 = _slicedToArray(_useState, 2),
23
+ uncontrolledValue = _useState2[0],
24
+ setUncontrolledValue = _useState2[1];
25
+ var onControlledChange = useCallback(function (controlledValue) {
26
+ onChange === null || onChange === undefined || onChange(controlledValue);
27
+ }, [onChange]);
28
+ if (typeof onChange === 'function') {
29
+ return [value, onControlledChange];
72
30
  }
73
- return [state, setState];
31
+ return [uncontrolledValue, setUncontrolledValue];
74
32
  }
75
33
 
76
34
  export { useControllableState };
@@ -8,9 +8,14 @@ import { RefObject } from 'react';
8
8
  type Item = {
9
9
  id: string;
10
10
  };
11
- export declare const useOverflowItems: <T extends Item>(items: T[] | undefined, containerRef: RefObject<HTMLDivElement | null>, offsetRef?: RefObject<HTMLDivElement | null>, maxItems?: number, onChange?: (hiddenItems: T[]) => void) => {
11
+ export declare function useOverflowItems<T extends Item>(items: T[] | undefined, containerRef: RefObject<HTMLElement | null>, offsetRef?: RefObject<HTMLElement | null>, maxItems?: number, onChange?: (value: {
12
+ hiddenItems?: T[];
13
+ minWidth?: number;
14
+ maxWidth?: number;
15
+ }) => void): {
12
16
  visibleItems: T[];
13
- itemRefHandler: (id: string, node: HTMLDivElement | null) => () => void;
17
+ itemRefHandler: (id: string, node: HTMLElement | null) => () => void;
14
18
  hiddenItems: T[];
19
+ offsetRefHandler: (node: any) => any;
15
20
  };
16
21
  export {};
@@ -6,28 +6,40 @@
6
6
  */
7
7
 
8
8
  import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
- import { useRef, useState } from 'react';
9
+ import { useState, useRef } from 'react';
10
10
  import { useResizeObserver } from './useResizeObserver.js';
11
11
 
12
- var useOverflowItems = function useOverflowItems() {
12
+ function useOverflowItems() {
13
+ var _items$slice;
13
14
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
14
15
  var containerRef = arguments.length > 1 ? arguments[1] : undefined;
15
16
  var offsetRef = arguments.length > 2 ? arguments[2] : undefined;
16
17
  var maxItems = arguments.length > 3 ? arguments[3] : undefined;
17
18
  var onChange = arguments.length > 4 ? arguments[4] : undefined;
18
- var itemsRef = useRef(null);
19
19
  var _useState = useState(0),
20
20
  _useState2 = _slicedToArray(_useState, 2),
21
- maxWidth = _useState2[0],
22
- setMaxWidth = _useState2[1];
21
+ remainingWidth = _useState2[0],
22
+ setRemainingWidth = _useState2[1];
23
+ var offsetWidthRef = useRef(0);
24
+ var itemsRef = useRef(null);
23
25
  var visibleItemCount = useRef(0);
26
+ var minWidthRef = useRef(0);
27
+ var requiredWidthRef = useRef(0);
24
28
  var handleResize = function handleResize() {
25
29
  if (containerRef !== null && containerRef !== undefined && containerRef.current) {
26
30
  var _offsetRef$current;
27
- var offset = (offsetRef === null || offsetRef === undefined || (_offsetRef$current = offsetRef.current) === null || _offsetRef$current === undefined ? undefined : _offsetRef$current.offsetWidth) || 0;
28
- var newMax = containerRef.current.offsetWidth - offset;
29
- setMaxWidth(newMax);
31
+ offsetWidthRef.current = (offsetRef === null || offsetRef === undefined || (_offsetRef$current = offsetRef.current) === null || _offsetRef$current === undefined ? undefined : _offsetRef$current.offsetWidth) || 0;
32
+ var usableWidth = containerRef.current.offsetWidth - offsetWidthRef.current;
33
+ setRemainingWidth(usableWidth);
34
+ }
35
+ };
36
+ var offsetRefHandler = function offsetRefHandler(node) {
37
+ if (node && containerRef !== null && containerRef !== undefined && containerRef.current) {
38
+ offsetWidthRef.current = node.offsetWidth;
39
+ var usableWidth = containerRef.current.offsetWidth - offsetWidthRef.current;
40
+ setRemainingWidth(usableWidth);
30
41
  }
42
+ return node;
31
43
  };
32
44
  useResizeObserver(containerRef, handleResize);
33
45
  var getMap = function getMap() {
@@ -36,6 +48,9 @@ var useOverflowItems = function useOverflowItems() {
36
48
  }
37
49
  return itemsRef.current;
38
50
  };
51
+ var requiredWidth = items === null || items === undefined || (_items$slice = items.slice(0, maxItems)) === null || _items$slice === undefined ? undefined : _items$slice.reduce(function (acc, item) {
52
+ return acc + (getMap().get(item.id) || 0);
53
+ }, 0);
39
54
  var itemRefHandler = function itemRefHandler(id, node) {
40
55
  var map = getMap();
41
56
  if (node) {
@@ -55,12 +70,21 @@ var useOverflowItems = function useOverflowItems() {
55
70
  var map = getMap();
56
71
  var maxReached = false;
57
72
  var accumulatedWidth = 0;
58
- var visibleItems = items.slice(0, maxItems).reduce(function (prev, cur) {
73
+ var includeOffset = false;
74
+ if (maxItems) {
75
+ includeOffset = requiredWidth + (offsetWidthRef === null || offsetWidthRef === undefined ? undefined : offsetWidthRef.current) > requiredWidth;
76
+ } else {
77
+ includeOffset = requiredWidth > remainingWidth + (offsetWidthRef === null || offsetWidthRef === undefined ? undefined : offsetWidthRef.current);
78
+ }
79
+ return items.slice(0, maxItems).reduce(function (prev, cur) {
59
80
  if (maxReached) {
60
81
  return prev;
61
82
  }
62
83
  var itemWidth = map.get(cur.id) || 0;
63
- var willFit = accumulatedWidth + itemWidth <= maxWidth;
84
+ var willFit = accumulatedWidth + itemWidth <= remainingWidth;
85
+ if (!includeOffset) {
86
+ willFit = accumulatedWidth + itemWidth <= remainingWidth + (offsetWidthRef === null || offsetWidthRef === undefined ? undefined : offsetWidthRef.current);
87
+ }
64
88
  if (willFit) {
65
89
  accumulatedWidth += itemWidth;
66
90
  prev.push(cur);
@@ -69,20 +93,29 @@ var useOverflowItems = function useOverflowItems() {
69
93
  }
70
94
  return prev;
71
95
  }, []);
72
- return visibleItems;
73
96
  };
74
97
  var visibleItems = getVisibleItems();
75
- var hiddenItems = items.slice(visibleItems.length);
98
+ var hiddenItems = items.slice(visibleItems === null || visibleItems === undefined ? undefined : visibleItems.length);
76
99
  // only call the change handler when the number of visible items has changed
77
- if (visibleItems.length !== visibleItemCount.current) {
78
- visibleItemCount.current = visibleItems.length;
79
- onChange === null || onChange === undefined || onChange(hiddenItems);
100
+ if ((visibleItems === null || visibleItems === undefined ? undefined : visibleItems.length) !== visibleItemCount.current || remainingWidth !== minWidthRef.current || requiredWidth !== requiredWidthRef.current) {
101
+ var _getMap, _getMap2;
102
+ visibleItemCount.current = visibleItems === null || visibleItems === undefined ? undefined : visibleItems.length;
103
+ minWidthRef.current = remainingWidth;
104
+ requiredWidthRef.current = requiredWidth;
105
+ var firstItemKey = ((_getMap = getMap()) === null || _getMap === undefined || (_getMap = _getMap.keys()) === null || _getMap === undefined || (_getMap = _getMap.next()) === null || _getMap === undefined ? undefined : _getMap.value) || '';
106
+ var firstItemWidth = ((_getMap2 = getMap()) === null || _getMap2 === undefined ? undefined : _getMap2.get(firstItemKey)) || 0;
107
+ onChange === null || onChange === undefined || onChange({
108
+ hiddenItems: hiddenItems,
109
+ minWidth: remainingWidth,
110
+ maxWidth: requiredWidth + firstItemWidth
111
+ });
80
112
  }
81
113
  return {
82
114
  visibleItems: visibleItems,
83
115
  itemRefHandler: itemRefHandler,
84
- hiddenItems: hiddenItems
116
+ hiddenItems: hiddenItems,
117
+ offsetRefHandler: offsetRefHandler
85
118
  };
86
- };
119
+ }
87
120
 
88
121
  export { useOverflowItems };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025, 2025
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 { RefObject } from 'react';
8
+ export declare function useOverflowStringWidth(elementRef: RefObject<HTMLElement>): boolean | undefined;
9
+ export declare const useOverflowStringHeight: (elementRef: RefObject<HTMLElement>) => boolean | undefined;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2025
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
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import { useState, useCallback, useEffect } from 'react';
10
+
11
+ function useOverflowStringWidth(elementRef) {
12
+ var _elementRef$current;
13
+ var innerText = elementRef === null || elementRef === undefined || (_elementRef$current = elementRef.current) === null || _elementRef$current === undefined ? undefined : _elementRef$current.innerText;
14
+ var _useState = useState(),
15
+ _useState2 = _slicedToArray(_useState, 2),
16
+ isOverflowing = _useState2[0],
17
+ setIsOverflowing = _useState2[1];
18
+ var checkWidthOverflow = useCallback(function () {
19
+ var _elementRef$current2, _elementRef$current3;
20
+ var offsetWidth = elementRef === null || elementRef === undefined || (_elementRef$current2 = elementRef.current) === null || _elementRef$current2 === undefined ? undefined : _elementRef$current2.offsetWidth;
21
+ var scrollWidth = elementRef === null || elementRef === undefined || (_elementRef$current3 = elementRef.current) === null || _elementRef$current3 === undefined ? undefined : _elementRef$current3.scrollWidth;
22
+ if (offsetWidth && scrollWidth) {
23
+ setIsOverflowing(offsetWidth < scrollWidth);
24
+ }
25
+ }, [elementRef]);
26
+ useEffect(function () {
27
+ checkWidthOverflow();
28
+ }, [checkWidthOverflow, elementRef, innerText]);
29
+ return isOverflowing;
30
+ }
31
+ var useOverflowStringHeight = function useOverflowStringHeight(elementRef) {
32
+ var _elementRef$current4;
33
+ var innerText = elementRef === null || elementRef === undefined || (_elementRef$current4 = elementRef.current) === null || _elementRef$current4 === undefined ? undefined : _elementRef$current4.innerText;
34
+ var _useState3 = useState(),
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ isOverflowing = _useState4[0],
37
+ setIsOverflowing = _useState4[1];
38
+ var checkHeightOverflow = useCallback(function () {
39
+ var _elementRef$current5, _elementRef$current6;
40
+ var offsetHeight = elementRef === null || elementRef === undefined || (_elementRef$current5 = elementRef.current) === null || _elementRef$current5 === undefined ? undefined : _elementRef$current5.offsetHeight;
41
+ var scrollHeight = elementRef === null || elementRef === undefined || (_elementRef$current6 = elementRef.current) === null || _elementRef$current6 === undefined ? undefined : _elementRef$current6.scrollHeight;
42
+ if (offsetHeight && scrollHeight) {
43
+ setIsOverflowing(offsetHeight < scrollHeight);
44
+ }
45
+ }, [elementRef]);
46
+ useEffect(function () {
47
+ checkHeightOverflow();
48
+ }, [checkHeightOverflow, elementRef, innerText]);
49
+ return isOverflowing;
50
+ };
51
+
52
+ export { useOverflowStringHeight, useOverflowStringWidth };
@@ -5,6 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { RefObject } from 'react';
8
- export declare const usePresence: (open: boolean, ref: RefObject<HTMLElement>, animationName: string) => {
8
+ export declare function usePresence(open: boolean, ref: RefObject<HTMLElement>, animationName: string): {
9
9
  shouldRender: boolean;
10
10
  };
@@ -11,7 +11,7 @@ import { useState, useEffect } from 'react';
11
11
  // Used as a replacement for AnimatePresence from framer-motion,
12
12
  // this hook will return a boolean value to let the component
13
13
  // calling this hook to know whether it should render or not
14
- var usePresence = function usePresence(open, ref, animationName) {
14
+ function usePresence(open, ref, animationName) {
15
15
  var _useState = useState(open),
16
16
  _useState2 = _slicedToArray(_useState, 2),
17
17
  shouldRender = _useState2[0],
@@ -38,6 +38,6 @@ var usePresence = function usePresence(open, ref, animationName) {
38
38
  return {
39
39
  shouldRender: shouldRender
40
40
  };
41
- };
41
+ }
42
42
 
43
43
  export { usePresence };
@@ -11,16 +11,6 @@
11
11
  // LICENSE file in the root directory of this source tree.
12
12
  //
13
13
 
14
- /**
15
- * used to calculate if a element is overflowing the width or height of an area
16
- */
17
-
18
- var checkWidthOverflow = function checkWidthOverflow(el) {
19
- if (el) {
20
- return (el === null || el === undefined ? undefined : el.offsetWidth) < (el === null || el === undefined ? undefined : el.scrollWidth);
21
- }
22
- return false;
23
- };
24
14
  var checkHeightOverflow = function checkHeightOverflow(el) {
25
15
  if (el) {
26
16
  return (el === null || el === undefined ? undefined : el.offsetHeight) < (el === null || el === undefined ? undefined : el.scrollHeight);
@@ -28,4 +18,4 @@ var checkHeightOverflow = function checkHeightOverflow(el) {
28
18
  return false;
29
19
  };
30
20
 
31
- export { checkHeightOverflow, checkWidthOverflow };
21
+ export { checkHeightOverflow };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025, 2025
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
+ export declare const clamp: (value: number, min: number, max: number) => number | void;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2025
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
+ // clamp utility, replacing lodash.clamp
9
+ // If it's lower than the lower bound, we pick the lower bound.
10
+ // If it's higher than the upper bound, we pick the upper bound.
11
+ // Otherwise, we pick the number passed in.
12
+ var clamp = function clamp(value, min, max) {
13
+ if (isNaN(value) || isNaN(min) || isNaN(max)) {
14
+ return;
15
+ }
16
+ if (max !== undefined) {
17
+ value = value <= max ? value : max;
18
+ }
19
+ {
20
+ value = value >= min ? value : min;
21
+ }
22
+ return value;
23
+ };
24
+
25
+ export { clamp };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025, 2025
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
+ export declare const debounce: (func: any, delay: number, leading?: boolean) => () => void;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2025
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
+ var debounce = function debounce(func, delay) {
9
+ var leading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
10
+ var timeout;
11
+ return function () {
12
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
13
+ args[_key] = arguments[_key];
14
+ }
15
+ if (timeout) {
16
+ clearTimeout(timeout);
17
+ }
18
+ if (leading && !timeout) {
19
+ func.apply(undefined, args);
20
+ }
21
+ timeout = setTimeout(function () {
22
+ timeout = null;
23
+ if (!leading) {
24
+ func.apply(undefined, args);
25
+ }
26
+ }, delay);
27
+ };
28
+ };
29
+
30
+ export { debounce };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright IBM Corp. 2025, 2025
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
+ export declare const deepCompareObject: (a: any, b: any) => boolean;