@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
@@ -1,14 +1,9 @@
1
- export namespace ScrollDirection {
2
- let X: string;
3
- let Y: string;
4
- }
5
1
  export namespace ScrollStates {
6
2
  let NONE: string;
7
3
  let INITIAL: string;
8
4
  let STARTED: string;
9
5
  let END: string;
10
6
  }
11
- export function getScrollState(element: any, scrollDirection: any): string;
12
7
  export function useIsOverflow(ref: any): {
13
8
  xScrollable: undefined;
14
9
  yScrollable: undefined;
@@ -10,57 +10,12 @@
10
10
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
11
11
  var React = require('react');
12
12
 
13
- var ScrollDirection = {
14
- X: 'X',
15
- Y: 'Y'
16
- };
17
13
  var ScrollStates = {
18
14
  // No scrolling required because content fits within container.
19
- NONE: 'NONE',
20
- // Scroll position is a the start of the scrollable content.
21
- INITIAL: 'INITIAL',
22
- // Scroll position is neither at start or end of scrollable content.
23
- STARTED: 'STARTED',
24
- // Scroll position is a the end of the scrollable content.
25
- END: 'END'
26
- };
15
+ NONE: 'NONE'};
27
16
 
28
17
  // FUNCTIONS
29
18
 
30
- var getScrollState = function getScrollState(element, scrollDirection) {
31
- // console.log('getScrollState - element: ', element);
32
- // console.log('getScrollState - scrollDirection: ', scrollDirection);
33
- // console.log('-------------------------------------------------');
34
- switch (scrollDirection) {
35
- case ScrollDirection.X:
36
- {
37
- if (element.scrollWidth === element.clientWidth) {
38
- return ScrollStates.NONE;
39
- }
40
- if (element.scrollLeft === 0) {
41
- return ScrollStates.INITIAL;
42
- }
43
- if (element.scrollLeft + element.clientWidth === element.scrollWidth) {
44
- return ScrollStates.END;
45
- }
46
- return ScrollStates.STARTED;
47
- }
48
- case ScrollDirection.Y:
49
- default:
50
- {
51
- if (element.scrollHeight === element.clientHeight) {
52
- return ScrollStates.NONE;
53
- }
54
- if (element.scrollTop === 0) {
55
- return ScrollStates.INITIAL;
56
- }
57
- if (element.scrollTop + element.clientHeight === element.scrollHeight) {
58
- return ScrollStates.END;
59
- }
60
- return ScrollStates.STARTED;
61
- }
62
- }
63
- };
64
19
  var useIsOverflow = function useIsOverflow(ref) {
65
20
  var _useState = React.useState(),
66
21
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
@@ -120,7 +75,5 @@ var useIsOverflow = function useIsOverflow(ref) {
120
75
  };
121
76
  };
122
77
 
123
- exports.ScrollDirection = ScrollDirection;
124
78
  exports.ScrollStates = ScrollStates;
125
- exports.getScrollState = getScrollState;
126
79
  exports.useIsOverflow = useIsOverflow;
@@ -10,9 +10,9 @@
10
10
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
11
11
  var React = require('react');
12
12
  var lottie = require('lottie-web');
13
- var clamp = require('lodash/clamp');
14
13
  var index = require('../../_virtual/index.js');
15
14
  var cx = require('classnames');
15
+ var clamp = require('../../global/js/utils/clamp.js');
16
16
  var devtools = require('../../global/js/utils/devtools.js');
17
17
  var settings = require('../../settings.js');
18
18
 
@@ -99,7 +99,7 @@ var SteppedAnimatedMedia = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
99
99
  animRef.current = lottie.loadAnimation({
100
100
  container: localRefValue,
101
101
  renderer: 'svg',
102
- animationData: jsonData[clamp(playStep, 0, jsonData.length - 1)],
102
+ animationData: jsonData[clamp.clamp(playStep, 0, jsonData.length - 1)],
103
103
  loop: false,
104
104
  autoplay: false,
105
105
  rendererSettings: {
@@ -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).
@@ -14,11 +14,9 @@ var React = require('react');
14
14
  var index = require('../../_virtual/index.js');
15
15
  var cx = require('classnames');
16
16
  var devtools = require('../../global/js/utils/devtools.js');
17
- var carbonMotion = require('@carbon/motion');
18
17
  var settings = require('../../settings.js');
19
18
  var index$1 = require('./hooks/index.js');
20
19
  var usePrefersReducedMotion = require('../../global/js/hooks/usePrefersReducedMotion.js');
21
- var useIsomorphicEffect = require('../../global/js/hooks/useIsomorphicEffect.js');
22
20
 
23
21
  var _excluded = ["actions", "children", "className", "closeIconDescription", "documentationLinks", "documentationLinksIconDescription", "isInitiallyOpen", "webTerminalAriaLabel"];
24
22
 
@@ -63,17 +61,6 @@ exports.WebTerminal = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
63
61
  shouldRender = _useState2[0],
64
62
  setRender = _useState2[1];
65
63
  var shouldReduceMotion = usePrefersReducedMotion.usePrefersReducedMotion();
66
- var webTerminalAnimationName = "".concat(open ? 'web-terminal-entrance' : 'web-terminal-exit forwards', " ").concat(carbonMotion.moderate02);
67
- useIsomorphicEffect.useIsomorphicEffect(function () {
68
- var timeout = setTimeout(function () {
69
- if (webTerminalRef.current && !shouldReduceMotion) {
70
- webTerminalRef.current.style.animation = webTerminalAnimationName;
71
- }
72
- }, 0);
73
- return function () {
74
- return clearTimeout(timeout);
75
- };
76
- }, [shouldReduceMotion, webTerminalAnimationName, webTerminalRef]);
77
64
  var showDocumentationLinks = React.useMemo(function () {
78
65
  return documentationLinks.length > 0;
79
66
  }, [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 {};
@@ -9,70 +9,28 @@
9
9
 
10
10
  var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
11
11
  var React = require('react');
12
- var pconsole = require('../utils/pconsole.js');
13
12
 
14
13
  /**
15
- * This custom hook simplifies the behavior of a component if it has state that
16
- * can be both controlled and uncontrolled. It functions identical to a
17
- * useState() hook and provides [state, setState] for you to use. You can use
18
- * the `onChange` argument to allow updates to the `state` to be communicated to
19
- * owners of controlled components.
20
- *
21
- * Note: this hook will warn if a component is switching from controlled to
22
- * uncontrolled, or vice-versa.
23
- *
24
- * @param {object} config
25
- * @param {string} config.name - the name of the custom component
26
- * @param {any} config.defaultValue - the default value used for the state. This will be
27
- * the fallback value used if `value` is not defined.
28
- * @param {Function} config.onChange - an optional function that is called when
29
- * the value of the state changes. This is useful for communicating to parents of
30
- * controlled components that the value is requesting to be changed.
31
- * @param {any} config.value - a controlled value. Omitting this means that the state is
32
- * uncontrolled
33
- * @returns {[any, Function]}
14
+ * handles controlling state for any component that utilizes controlled and uncontrolled state
15
+ * @param {T} value - any generic value being held in state
16
+ * @param {Callback} onChange - a callback function to handle state change when the user puts the component in a controlled state
17
+ * @returns {[value: T, Callback]}
34
18
  */
35
- function useControllableState(_ref) {
36
- var defaultValue = _ref.defaultValue,
37
- _ref$name = _ref.name,
38
- name = _ref$name === undefined ? 'custom' : _ref$name,
39
- onChange = _ref.onChange,
40
- value = _ref.value;
41
- var _useState = React.useState(value !== null && value !== undefined ? value : defaultValue),
42
- _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
43
- state = _useState2[0],
44
- internalSetState = _useState2[1];
45
- var controlled = React.useRef(null);
46
- if (controlled.current === null) {
47
- controlled.current = value !== undefined;
19
+ function useControllableState(value, onChange) {
20
+ if (typeof value === 'function') {
21
+ throw new TypeError('Functions are not supported');
48
22
  }
49
- function setState(stateOrUpdater) {
50
- var value = typeof stateOrUpdater === 'function' ? stateOrUpdater(state) : stateOrUpdater;
51
- if (controlled.current === false) {
52
- internalSetState(value);
53
- }
54
- if (onChange) {
55
- onChange(value);
56
- }
57
- }
58
- React.useEffect(function () {
59
- var controlledValue = value !== undefined;
60
- // Uncontrolled -> Controlled
61
- // If the component prop is uncontrolled, the prop value should be undefined
62
- if (controlled.current === false && controlledValue) {
63
- pconsole.default.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");
64
- }
65
-
66
- // Controlled -> Uncontrolled
67
- // If the component prop is controlled, the prop value should be defined
68
- if (controlled.current === true && !controlledValue) {
69
- pconsole.default.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");
70
- }
71
- }, [name, value]);
72
- if (controlled.current === true) {
73
- return [value, setState];
23
+ var _useState = React.useState(value),
24
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
25
+ uncontrolledValue = _useState2[0],
26
+ setUncontrolledValue = _useState2[1];
27
+ var onControlledChange = React.useCallback(function (controlledValue) {
28
+ onChange === null || onChange === undefined || onChange(controlledValue);
29
+ }, [onChange]);
30
+ if (typeof onChange === 'function') {
31
+ return [value, onControlledChange];
74
32
  }
75
- return [state, setState];
33
+ return [uncontrolledValue, setUncontrolledValue];
76
34
  }
77
35
 
78
36
  exports.useControllableState = 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 {};
@@ -11,25 +11,37 @@ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHel
11
11
  var React = require('react');
12
12
  var useResizeObserver = require('./useResizeObserver.js');
13
13
 
14
- var useOverflowItems = function useOverflowItems() {
14
+ function useOverflowItems() {
15
+ var _items$slice;
15
16
  var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
16
17
  var containerRef = arguments.length > 1 ? arguments[1] : undefined;
17
18
  var offsetRef = arguments.length > 2 ? arguments[2] : undefined;
18
19
  var maxItems = arguments.length > 3 ? arguments[3] : undefined;
19
20
  var onChange = arguments.length > 4 ? arguments[4] : undefined;
20
- var itemsRef = React.useRef(null);
21
21
  var _useState = React.useState(0),
22
22
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
23
- maxWidth = _useState2[0],
24
- setMaxWidth = _useState2[1];
23
+ remainingWidth = _useState2[0],
24
+ setRemainingWidth = _useState2[1];
25
+ var offsetWidthRef = React.useRef(0);
26
+ var itemsRef = React.useRef(null);
25
27
  var visibleItemCount = React.useRef(0);
28
+ var minWidthRef = React.useRef(0);
29
+ var requiredWidthRef = React.useRef(0);
26
30
  var handleResize = function handleResize() {
27
31
  if (containerRef !== null && containerRef !== undefined && containerRef.current) {
28
32
  var _offsetRef$current;
29
- var offset = (offsetRef === null || offsetRef === undefined || (_offsetRef$current = offsetRef.current) === null || _offsetRef$current === undefined ? undefined : _offsetRef$current.offsetWidth) || 0;
30
- var newMax = containerRef.current.offsetWidth - offset;
31
- setMaxWidth(newMax);
33
+ offsetWidthRef.current = (offsetRef === null || offsetRef === undefined || (_offsetRef$current = offsetRef.current) === null || _offsetRef$current === undefined ? undefined : _offsetRef$current.offsetWidth) || 0;
34
+ var usableWidth = containerRef.current.offsetWidth - offsetWidthRef.current;
35
+ setRemainingWidth(usableWidth);
36
+ }
37
+ };
38
+ var offsetRefHandler = function offsetRefHandler(node) {
39
+ if (node && containerRef !== null && containerRef !== undefined && containerRef.current) {
40
+ offsetWidthRef.current = node.offsetWidth;
41
+ var usableWidth = containerRef.current.offsetWidth - offsetWidthRef.current;
42
+ setRemainingWidth(usableWidth);
32
43
  }
44
+ return node;
33
45
  };
34
46
  useResizeObserver.useResizeObserver(containerRef, handleResize);
35
47
  var getMap = function getMap() {
@@ -38,6 +50,9 @@ var useOverflowItems = function useOverflowItems() {
38
50
  }
39
51
  return itemsRef.current;
40
52
  };
53
+ var requiredWidth = items === null || items === undefined || (_items$slice = items.slice(0, maxItems)) === null || _items$slice === undefined ? undefined : _items$slice.reduce(function (acc, item) {
54
+ return acc + (getMap().get(item.id) || 0);
55
+ }, 0);
41
56
  var itemRefHandler = function itemRefHandler(id, node) {
42
57
  var map = getMap();
43
58
  if (node) {
@@ -57,12 +72,21 @@ var useOverflowItems = function useOverflowItems() {
57
72
  var map = getMap();
58
73
  var maxReached = false;
59
74
  var accumulatedWidth = 0;
60
- var visibleItems = items.slice(0, maxItems).reduce(function (prev, cur) {
75
+ var includeOffset = false;
76
+ if (maxItems) {
77
+ includeOffset = requiredWidth + (offsetWidthRef === null || offsetWidthRef === undefined ? undefined : offsetWidthRef.current) > requiredWidth;
78
+ } else {
79
+ includeOffset = requiredWidth > remainingWidth + (offsetWidthRef === null || offsetWidthRef === undefined ? undefined : offsetWidthRef.current);
80
+ }
81
+ return items.slice(0, maxItems).reduce(function (prev, cur) {
61
82
  if (maxReached) {
62
83
  return prev;
63
84
  }
64
85
  var itemWidth = map.get(cur.id) || 0;
65
- var willFit = accumulatedWidth + itemWidth <= maxWidth;
86
+ var willFit = accumulatedWidth + itemWidth <= remainingWidth;
87
+ if (!includeOffset) {
88
+ willFit = accumulatedWidth + itemWidth <= remainingWidth + (offsetWidthRef === null || offsetWidthRef === undefined ? undefined : offsetWidthRef.current);
89
+ }
66
90
  if (willFit) {
67
91
  accumulatedWidth += itemWidth;
68
92
  prev.push(cur);
@@ -71,20 +95,29 @@ var useOverflowItems = function useOverflowItems() {
71
95
  }
72
96
  return prev;
73
97
  }, []);
74
- return visibleItems;
75
98
  };
76
99
  var visibleItems = getVisibleItems();
77
- var hiddenItems = items.slice(visibleItems.length);
100
+ var hiddenItems = items.slice(visibleItems === null || visibleItems === undefined ? undefined : visibleItems.length);
78
101
  // only call the change handler when the number of visible items has changed
79
- if (visibleItems.length !== visibleItemCount.current) {
80
- visibleItemCount.current = visibleItems.length;
81
- onChange === null || onChange === undefined || onChange(hiddenItems);
102
+ if ((visibleItems === null || visibleItems === undefined ? undefined : visibleItems.length) !== visibleItemCount.current || remainingWidth !== minWidthRef.current || requiredWidth !== requiredWidthRef.current) {
103
+ var _getMap, _getMap2;
104
+ visibleItemCount.current = visibleItems === null || visibleItems === undefined ? undefined : visibleItems.length;
105
+ minWidthRef.current = remainingWidth;
106
+ requiredWidthRef.current = requiredWidth;
107
+ var firstItemKey = ((_getMap = getMap()) === null || _getMap === undefined || (_getMap = _getMap.keys()) === null || _getMap === undefined || (_getMap = _getMap.next()) === null || _getMap === undefined ? undefined : _getMap.value) || '';
108
+ var firstItemWidth = ((_getMap2 = getMap()) === null || _getMap2 === undefined ? undefined : _getMap2.get(firstItemKey)) || 0;
109
+ onChange === null || onChange === undefined || onChange({
110
+ hiddenItems: hiddenItems,
111
+ minWidth: remainingWidth,
112
+ maxWidth: requiredWidth + firstItemWidth
113
+ });
82
114
  }
83
115
  return {
84
116
  visibleItems: visibleItems,
85
117
  itemRefHandler: itemRefHandler,
86
- hiddenItems: hiddenItems
118
+ hiddenItems: hiddenItems,
119
+ offsetRefHandler: offsetRefHandler
87
120
  };
88
- };
121
+ }
89
122
 
90
123
  exports.useOverflowItems = 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,55 @@
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
+ 'use strict';
9
+
10
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
11
+ var React = require('react');
12
+
13
+ function useOverflowStringWidth(elementRef) {
14
+ var _elementRef$current;
15
+ var innerText = elementRef === null || elementRef === undefined || (_elementRef$current = elementRef.current) === null || _elementRef$current === undefined ? undefined : _elementRef$current.innerText;
16
+ var _useState = React.useState(),
17
+ _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
18
+ isOverflowing = _useState2[0],
19
+ setIsOverflowing = _useState2[1];
20
+ var checkWidthOverflow = React.useCallback(function () {
21
+ var _elementRef$current2, _elementRef$current3;
22
+ var offsetWidth = elementRef === null || elementRef === undefined || (_elementRef$current2 = elementRef.current) === null || _elementRef$current2 === undefined ? undefined : _elementRef$current2.offsetWidth;
23
+ var scrollWidth = elementRef === null || elementRef === undefined || (_elementRef$current3 = elementRef.current) === null || _elementRef$current3 === undefined ? undefined : _elementRef$current3.scrollWidth;
24
+ if (offsetWidth && scrollWidth) {
25
+ setIsOverflowing(offsetWidth < scrollWidth);
26
+ }
27
+ }, [elementRef]);
28
+ React.useEffect(function () {
29
+ checkWidthOverflow();
30
+ }, [checkWidthOverflow, elementRef, innerText]);
31
+ return isOverflowing;
32
+ }
33
+ var useOverflowStringHeight = function useOverflowStringHeight(elementRef) {
34
+ var _elementRef$current4;
35
+ var innerText = elementRef === null || elementRef === undefined || (_elementRef$current4 = elementRef.current) === null || _elementRef$current4 === undefined ? undefined : _elementRef$current4.innerText;
36
+ var _useState3 = React.useState(),
37
+ _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
38
+ isOverflowing = _useState4[0],
39
+ setIsOverflowing = _useState4[1];
40
+ var checkHeightOverflow = React.useCallback(function () {
41
+ var _elementRef$current5, _elementRef$current6;
42
+ var offsetHeight = elementRef === null || elementRef === undefined || (_elementRef$current5 = elementRef.current) === null || _elementRef$current5 === undefined ? undefined : _elementRef$current5.offsetHeight;
43
+ var scrollHeight = elementRef === null || elementRef === undefined || (_elementRef$current6 = elementRef.current) === null || _elementRef$current6 === undefined ? undefined : _elementRef$current6.scrollHeight;
44
+ if (offsetHeight && scrollHeight) {
45
+ setIsOverflowing(offsetHeight < scrollHeight);
46
+ }
47
+ }, [elementRef]);
48
+ React.useEffect(function () {
49
+ checkHeightOverflow();
50
+ }, [checkHeightOverflow, elementRef, innerText]);
51
+ return isOverflowing;
52
+ };
53
+
54
+ exports.useOverflowStringHeight = useOverflowStringHeight;
55
+ exports.useOverflowStringWidth = 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
  };
@@ -13,7 +13,7 @@ var React = require('react');
13
13
  // Used as a replacement for AnimatePresence from framer-motion,
14
14
  // this hook will return a boolean value to let the component
15
15
  // calling this hook to know whether it should render or not
16
- var usePresence = function usePresence(open, ref, animationName) {
16
+ function usePresence(open, ref, animationName) {
17
17
  var _useState = React.useState(open),
18
18
  _useState2 = _rollupPluginBabelHelpers.slicedToArray(_useState, 2),
19
19
  shouldRender = _useState2[0],
@@ -40,6 +40,6 @@ var usePresence = function usePresence(open, ref, animationName) {
40
40
  return {
41
41
  shouldRender: shouldRender
42
42
  };
43
- };
43
+ }
44
44
 
45
45
  exports.usePresence = usePresence;
@@ -13,16 +13,6 @@
13
13
  // LICENSE file in the root directory of this source tree.
14
14
  //
15
15
 
16
- /**
17
- * used to calculate if a element is overflowing the width or height of an area
18
- */
19
-
20
- var checkWidthOverflow = function checkWidthOverflow(el) {
21
- if (el) {
22
- return (el === null || el === undefined ? undefined : el.offsetWidth) < (el === null || el === undefined ? undefined : el.scrollWidth);
23
- }
24
- return false;
25
- };
26
16
  var checkHeightOverflow = function checkHeightOverflow(el) {
27
17
  if (el) {
28
18
  return (el === null || el === undefined ? undefined : el.offsetHeight) < (el === null || el === undefined ? undefined : el.scrollHeight);
@@ -31,4 +21,3 @@ var checkHeightOverflow = function checkHeightOverflow(el) {
31
21
  };
32
22
 
33
23
  exports.checkHeightOverflow = checkHeightOverflow;
34
- exports.checkWidthOverflow = checkWidthOverflow;
@@ -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,27 @@
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
+ 'use strict';
9
+
10
+ // clamp utility, replacing lodash.clamp
11
+ // If it's lower than the lower bound, we pick the lower bound.
12
+ // If it's higher than the upper bound, we pick the upper bound.
13
+ // Otherwise, we pick the number passed in.
14
+ var clamp = function clamp(value, min, max) {
15
+ if (isNaN(value) || isNaN(min) || isNaN(max)) {
16
+ return;
17
+ }
18
+ if (max !== undefined) {
19
+ value = value <= max ? value : max;
20
+ }
21
+ {
22
+ value = value >= min ? value : min;
23
+ }
24
+ return value;
25
+ };
26
+
27
+ exports.clamp = 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,32 @@
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
+ 'use strict';
9
+
10
+ var debounce = function debounce(func, delay) {
11
+ var leading = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
12
+ var timeout;
13
+ return function () {
14
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
15
+ args[_key] = arguments[_key];
16
+ }
17
+ if (timeout) {
18
+ clearTimeout(timeout);
19
+ }
20
+ if (leading && !timeout) {
21
+ func.apply(undefined, args);
22
+ }
23
+ timeout = setTimeout(function () {
24
+ timeout = null;
25
+ if (!leading) {
26
+ func.apply(undefined, args);
27
+ }
28
+ }, delay);
29
+ };
30
+ };
31
+
32
+ exports.debounce = debounce;