@carbon/react 1.76.0 → 1.77.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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +810 -775
- package/es/components/Button/Button.d.ts +9 -1
- package/es/components/Button/Button.js +8 -0
- package/es/components/CodeSnippet/CodeSnippet.d.ts +2 -2
- package/es/components/ComboBox/ComboBox.d.ts +2 -2
- package/es/components/ComboBox/ComboBox.js +34 -12
- package/es/components/ComboButton/index.js +1 -2
- package/es/components/ComposedModal/ComposedModal.js +1 -1
- package/es/components/ContentSwitcher/index.d.ts +0 -1
- package/es/components/ContextMenu/useContextMenu.d.ts +0 -1
- package/es/components/Copy/Copy.js +1 -1
- package/es/components/DataTable/DataTable.d.ts +12 -20
- package/es/components/DataTable/DataTable.js +1 -9
- package/es/components/DataTable/Table.js +1 -1
- package/es/components/DataTable/TableActionList.d.ts +1 -1
- package/es/components/DataTable/TableBody.js +1 -1
- package/es/components/DataTable/TableContext.d.ts +0 -1
- package/es/components/DataTable/TableHead.d.ts +1 -1
- package/es/components/DataTable/TableToolbarContent.d.ts +1 -1
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +2 -2
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dropdown/Dropdown.js +1 -2
- package/es/components/FluidForm/FormContext.d.ts +0 -1
- package/es/components/Grid/CSSGrid.js +1 -1
- package/es/components/Grid/Grid.js +1 -1
- package/es/components/Grid/GridTypes.d.ts +0 -1
- package/es/components/Heading/index.d.ts +1 -1
- package/es/components/IconButton/index.d.ts +17 -1
- package/es/components/IconButton/index.js +20 -1
- package/es/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/es/components/InlineLoading/InlineLoading.d.ts +1 -1
- package/es/components/InlineLoading/InlineLoading.js +21 -7
- package/es/components/Menu/Menu.js +2 -2
- package/es/components/Menu/MenuContext.d.ts +1 -1
- package/es/components/MenuButton/index.d.ts +1 -1
- package/es/components/MenuButton/index.js +1 -2
- package/es/components/Modal/Modal.js +1 -1
- package/es/components/Modal/next/index.d.ts +175 -0
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +12 -5
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/MultiSelect.js +1 -2
- package/es/components/Pagination/Pagination.js +2 -2
- package/es/components/Popover/index.js +2 -3
- package/es/components/PrimaryButton/PrimaryButton.d.ts +1 -1
- package/es/components/RadioTile/RadioTile.d.ts +1 -1
- package/es/components/SecondaryButton/SecondaryButton.d.ts +1 -1
- package/es/components/Slider/Slider.d.ts +1 -1
- package/es/components/Slider/Slider.js +1 -1
- package/es/components/Slider/index.d.ts +0 -1
- package/es/components/Tabs/Tabs.d.ts +3 -3
- package/es/components/Tabs/Tabs.js +4 -4
- package/es/components/Tag/DismissibleTag.d.ts +2 -2
- package/es/components/Tag/OperationalTag.d.ts +1 -1
- package/es/components/Tag/SelectableTag.d.ts +2 -2
- package/es/components/Text/index.d.ts +2 -2
- package/es/components/TextInput/PasswordInput.d.ts +1 -1
- package/es/components/Theme/index.d.ts +1 -1
- package/es/components/Tile/Tile.d.ts +1 -1
- package/es/components/Tile/Tile.js +1 -1
- package/es/components/Toggletip/index.d.ts +3 -3
- package/es/components/Toggletip/index.js +5 -4
- package/es/components/Tooltip/Tooltip.d.ts +17 -1
- package/es/components/Tooltip/Tooltip.js +12 -2
- package/es/components/TreeView/TreeNode.d.ts +27 -19
- package/es/components/TreeView/TreeNode.js +100 -31
- package/es/components/TreeView/TreeView.js +1 -1
- package/es/components/UIShell/Content.d.ts +9 -9
- package/es/components/UIShell/HeaderGlobalBar.d.ts +1 -1
- package/es/components/UIShell/HeaderMenu.d.ts +69 -25
- package/es/components/UIShell/HeaderMenuButton.d.ts +69 -27
- package/es/components/UIShell/HeaderMenuItem.d.ts +4 -3
- package/es/components/UIShell/HeaderMenuItem.js +1 -1
- package/es/components/UIShell/HeaderName.js +1 -1
- package/es/components/UIShell/HeaderNavigation.d.ts +69 -25
- package/es/components/UIShell/Link.d.ts +14 -11
- package/es/components/UIShell/Link.js +5 -6
- package/es/components/UIShell/SideNav.js +3 -3
- package/es/components/UIShell/SideNavLink.js +1 -1
- package/es/components/UIShell/SideNavMenuItem.d.ts +51 -3
- package/es/components/UIShell/SideNavMenuItem.js +6 -6
- package/es/components/UIShell/SwitcherItem.d.ts +2 -2
- package/es/components/UIShell/SwitcherItem.js +1 -1
- package/es/internal/PolymorphicProps.d.ts +0 -1
- package/es/internal/Selection.d.ts +38 -0
- package/es/internal/Selection.js +26 -113
- package/es/node_modules/es-toolkit/dist/compat/function/debounce.mjs.js +55 -0
- package/es/node_modules/es-toolkit/dist/compat/function/throttle.mjs.js +23 -0
- package/es/node_modules/es-toolkit/dist/function/debounce.mjs.js +70 -0
- package/es/tools/wrapComponent.d.ts +1 -1
- package/lib/components/Button/Button.d.ts +9 -1
- package/lib/components/Button/Button.js +8 -0
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +2 -2
- package/lib/components/ComboBox/ComboBox.d.ts +2 -2
- package/lib/components/ComboBox/ComboBox.js +34 -12
- package/lib/components/ComboButton/index.js +1 -2
- package/lib/components/ComposedModal/ComposedModal.js +2 -2
- package/lib/components/ContentSwitcher/index.d.ts +0 -1
- package/lib/components/ContextMenu/useContextMenu.d.ts +0 -1
- package/lib/components/Copy/Copy.js +2 -2
- package/lib/components/DataTable/DataTable.d.ts +12 -20
- package/lib/components/DataTable/DataTable.js +1 -9
- package/lib/components/DataTable/Table.js +3 -3
- package/lib/components/DataTable/TableActionList.d.ts +1 -1
- package/lib/components/DataTable/TableBody.js +1 -1
- package/lib/components/DataTable/TableContext.d.ts +0 -1
- package/lib/components/DataTable/TableHead.d.ts +1 -1
- package/lib/components/DataTable/TableToolbarContent.d.ts +1 -1
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +2 -2
- package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +1 -2
- package/lib/components/FluidForm/FormContext.d.ts +0 -1
- package/lib/components/Grid/CSSGrid.js +1 -1
- package/lib/components/Grid/Grid.js +1 -1
- package/lib/components/Grid/GridTypes.d.ts +0 -1
- package/lib/components/Heading/index.d.ts +1 -1
- package/lib/components/IconButton/index.d.ts +17 -1
- package/lib/components/IconButton/index.js +20 -1
- package/lib/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/lib/components/InlineLoading/InlineLoading.d.ts +1 -1
- package/lib/components/InlineLoading/InlineLoading.js +20 -6
- package/lib/components/Menu/Menu.js +2 -2
- package/lib/components/Menu/MenuContext.d.ts +1 -1
- package/lib/components/MenuButton/index.d.ts +1 -1
- package/lib/components/MenuButton/index.js +1 -2
- package/lib/components/Modal/Modal.js +2 -2
- package/lib/components/Modal/next/index.d.ts +175 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +11 -4
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/MultiSelect.js +1 -2
- package/lib/components/Pagination/Pagination.js +3 -2
- package/lib/components/Popover/index.js +2 -3
- package/lib/components/PrimaryButton/PrimaryButton.d.ts +1 -1
- package/lib/components/RadioTile/RadioTile.d.ts +1 -1
- package/lib/components/SecondaryButton/SecondaryButton.d.ts +1 -1
- package/lib/components/Slider/Slider.d.ts +1 -1
- package/lib/components/Slider/Slider.js +2 -2
- package/lib/components/Slider/index.d.ts +0 -1
- package/lib/components/Tabs/Tabs.d.ts +3 -3
- package/lib/components/Tabs/Tabs.js +6 -6
- package/lib/components/Tag/DismissibleTag.d.ts +2 -2
- package/lib/components/Tag/OperationalTag.d.ts +1 -1
- package/lib/components/Tag/SelectableTag.d.ts +2 -2
- package/lib/components/Text/index.d.ts +2 -2
- package/lib/components/TextInput/PasswordInput.d.ts +1 -1
- package/lib/components/Theme/index.d.ts +1 -1
- package/lib/components/Tile/Tile.d.ts +1 -1
- package/lib/components/Tile/Tile.js +1 -1
- package/lib/components/Toggletip/index.d.ts +3 -3
- package/lib/components/Toggletip/index.js +5 -4
- package/lib/components/Tooltip/Tooltip.d.ts +17 -1
- package/lib/components/Tooltip/Tooltip.js +12 -2
- package/lib/components/TreeView/TreeNode.d.ts +27 -19
- package/lib/components/TreeView/TreeNode.js +100 -31
- package/lib/components/TreeView/TreeView.js +1 -1
- package/lib/components/UIShell/Content.d.ts +9 -9
- package/lib/components/UIShell/HeaderGlobalBar.d.ts +1 -1
- package/lib/components/UIShell/HeaderMenu.d.ts +69 -25
- package/lib/components/UIShell/HeaderMenuButton.d.ts +69 -27
- package/lib/components/UIShell/HeaderMenuItem.d.ts +4 -3
- package/lib/components/UIShell/HeaderMenuItem.js +1 -1
- package/lib/components/UIShell/HeaderName.js +1 -1
- package/lib/components/UIShell/HeaderNavigation.d.ts +69 -25
- package/lib/components/UIShell/Link.d.ts +14 -11
- package/lib/components/UIShell/Link.js +4 -4
- package/lib/components/UIShell/SideNav.js +3 -3
- package/lib/components/UIShell/SideNavLink.js +1 -1
- package/lib/components/UIShell/SideNavMenuItem.d.ts +51 -3
- package/lib/components/UIShell/SideNavMenuItem.js +6 -6
- package/lib/components/UIShell/SwitcherItem.d.ts +2 -2
- package/lib/components/UIShell/SwitcherItem.js +1 -1
- package/lib/internal/PolymorphicProps.d.ts +0 -1
- package/lib/internal/Selection.d.ts +38 -0
- package/lib/internal/Selection.js +24 -114
- package/lib/node_modules/es-toolkit/dist/compat/function/debounce.mjs.js +59 -0
- package/lib/node_modules/es-toolkit/dist/compat/function/throttle.mjs.js +27 -0
- package/lib/node_modules/es-toolkit/dist/function/debounce.mjs.js +74 -0
- package/lib/tools/wrapComponent.d.ts +1 -1
- package/package.json +10 -9
- package/es/node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js +0 -896
- package/es/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js +0 -76
- package/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs.js +0 -139
- package/es/tools/array.js +0 -29
- package/lib/node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js +0 -909
- package/lib/node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js +0 -80
- package/lib/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs.js +0 -163
- package/lib/tools/array.js +0 -33
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { HTMLAttributeAnchorTarget } from 'react';
|
|
1
|
+
import React, { HTMLAttributeAnchorTarget, KeyboardEvent } from 'react';
|
|
2
2
|
export interface BaseSwitcherItemProps {
|
|
3
3
|
/**
|
|
4
4
|
* Specify the text content for the link
|
|
@@ -61,5 +61,5 @@ export interface SwitcherItemWithAriaLabelledBy extends BaseSwitcherItemProps {
|
|
|
61
61
|
'aria-labelledby': string;
|
|
62
62
|
}
|
|
63
63
|
export type SwitcherItemProps = SwitcherItemWithAriaLabel | SwitcherItemWithAriaLabelledBy;
|
|
64
|
-
declare const SwitcherItem: React.ForwardRefExoticComponent<SwitcherItemProps & React.RefAttributes<React.ElementType
|
|
64
|
+
declare const SwitcherItem: React.ForwardRefExoticComponent<SwitcherItemProps & React.RefAttributes<React.ElementType>>;
|
|
65
65
|
export default SwitcherItem;
|
|
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import React__default, { forwardRef } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import Link from './Link.js';
|
|
12
|
+
import { Link } from './Link.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
15
15
|
import { match } from '../../internal/keyboard/match.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 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 React from 'react';
|
|
8
|
+
interface UseSelectionProps<ItemType> {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
filteredItems?: ItemType[];
|
|
11
|
+
initialSelectedItems?: ItemType[];
|
|
12
|
+
onChange?: (data: {
|
|
13
|
+
selectedItems: ItemType[];
|
|
14
|
+
}) => void;
|
|
15
|
+
selectAll?: boolean;
|
|
16
|
+
selectedItems?: ItemType[];
|
|
17
|
+
}
|
|
18
|
+
export declare const useSelection: <ItemType>({ disabled, onChange, initialSelectedItems, selectedItems: controlledItems, selectAll, filteredItems, }: UseSelectionProps<ItemType>) => {
|
|
19
|
+
clearSelection: () => void;
|
|
20
|
+
onItemChange: (item: ItemType) => void;
|
|
21
|
+
selectedItems: ItemType[];
|
|
22
|
+
};
|
|
23
|
+
interface SelectionRenderProps<ItemType> {
|
|
24
|
+
clearSelection: () => void;
|
|
25
|
+
onItemChange: (item: ItemType) => void;
|
|
26
|
+
selectedItems: ItemType[];
|
|
27
|
+
}
|
|
28
|
+
interface SelectionProps<ItemType> {
|
|
29
|
+
children?: (renderProps: SelectionRenderProps<ItemType>) => React.ReactNode;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
initialSelectedItems: ItemType[];
|
|
32
|
+
onChange?: (state: {
|
|
33
|
+
selectedItems: ItemType[];
|
|
34
|
+
}) => void;
|
|
35
|
+
render?: (renderProps: SelectionRenderProps<ItemType>) => React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
export declare const Selection: <ItemType>({ children, disabled, initialSelectedItems, onChange, render, }: SelectionProps<ItemType>) => import("react/jsx-runtime").JSX.Element | null;
|
|
38
|
+
export {};
|
package/es/internal/Selection.js
CHANGED
|
@@ -5,12 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import React__default, { useRef, useState, useCallback, useEffect } from 'react';
|
|
10
|
-
import PropTypes from 'prop-types';
|
|
8
|
+
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
11
9
|
import isEqual from 'react-fast-compare';
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
const callOnChangeHandler = _ref => {
|
|
14
12
|
let {
|
|
15
13
|
isControlled,
|
|
16
14
|
isMounted,
|
|
@@ -27,8 +25,8 @@ function callOnChangeHandler(_ref) {
|
|
|
27
25
|
} else {
|
|
28
26
|
onChangeHandlerUncontrolled(selectedItems);
|
|
29
27
|
}
|
|
30
|
-
}
|
|
31
|
-
|
|
28
|
+
};
|
|
29
|
+
const useSelection = _ref2 => {
|
|
32
30
|
let {
|
|
33
31
|
disabled,
|
|
34
32
|
onChange,
|
|
@@ -43,28 +41,24 @@ function useSelection(_ref2) {
|
|
|
43
41
|
const isControlled = !!controlledItems;
|
|
44
42
|
const selectedItems = isControlled ? controlledItems : uncontrolledItems;
|
|
45
43
|
const onItemChange = useCallback(item => {
|
|
46
|
-
if (disabled)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
44
|
+
if (disabled) return;
|
|
45
|
+
|
|
46
|
+
// Assert special properties (e.g., `disabled`, `isSelectAll`, etc.) are
|
|
47
|
+
// `any` since those properties aren’t part of the generic type.
|
|
48
|
+
const allSelectableItems = filteredItems.filter(item => !item?.disabled);
|
|
49
|
+
const disabledItemCount = filteredItems.filter(item => item?.disabled).length;
|
|
51
50
|
let newSelectedItems;
|
|
52
51
|
|
|
53
|
-
//deselect all on click to All/indeterminate option
|
|
54
|
-
if (item
|
|
52
|
+
// deselect all on click to All/indeterminate option
|
|
53
|
+
if (item?.isSelectAll && selectedItems.length > 0) {
|
|
55
54
|
newSelectedItems = [];
|
|
56
55
|
}
|
|
57
|
-
//select all
|
|
58
|
-
else if (item
|
|
56
|
+
// select all options
|
|
57
|
+
else if (item?.isSelectAll && selectedItems.length === 0) {
|
|
59
58
|
newSelectedItems = allSelectableItems;
|
|
60
59
|
} else {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (isEqual(selectedItem, item)) {
|
|
64
|
-
selectedIndex = index;
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
if (selectedIndex === undefined) {
|
|
60
|
+
const selectedIndex = selectedItems.findLastIndex(selectedItem => isEqual(selectedItem, item));
|
|
61
|
+
if (selectedIndex === -1) {
|
|
68
62
|
newSelectedItems = selectedItems.concat(item);
|
|
69
63
|
// checking if all items are selected then We should select mark the 'select All' option as well
|
|
70
64
|
if (selectAll && filteredItems.length - 1 === newSelectedItems.length + disabledItemCount) {
|
|
@@ -72,7 +66,7 @@ function useSelection(_ref2) {
|
|
|
72
66
|
}
|
|
73
67
|
} else {
|
|
74
68
|
newSelectedItems = removeAtIndex(selectedItems, selectedIndex);
|
|
75
|
-
newSelectedItems = newSelectedItems.filter(item => !item
|
|
69
|
+
newSelectedItems = newSelectedItems.filter(item => !item?.isSelectAll);
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
72
|
callOnChangeHandler({
|
|
@@ -84,9 +78,7 @@ function useSelection(_ref2) {
|
|
|
84
78
|
});
|
|
85
79
|
}, [disabled, selectedItems, filteredItems, selectAll, isControlled]);
|
|
86
80
|
const clearSelection = useCallback(() => {
|
|
87
|
-
if (disabled)
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
81
|
+
if (disabled) return;
|
|
90
82
|
callOnChangeHandler({
|
|
91
83
|
isControlled,
|
|
92
84
|
isMounted: isMounted.current,
|
|
@@ -112,99 +104,20 @@ function useSelection(_ref2) {
|
|
|
112
104
|
};
|
|
113
105
|
}, []);
|
|
114
106
|
return {
|
|
115
|
-
|
|
107
|
+
clearSelection,
|
|
116
108
|
onItemChange,
|
|
117
|
-
|
|
109
|
+
selectedItems
|
|
118
110
|
};
|
|
119
|
-
}
|
|
120
|
-
class Selection extends React__default.Component {
|
|
121
|
-
constructor(props) {
|
|
122
|
-
super(props);
|
|
123
|
-
_defineProperty(this, "internalSetState", (stateToSet, callback) => this.setState(stateToSet, () => {
|
|
124
|
-
if (callback) {
|
|
125
|
-
callback();
|
|
126
|
-
}
|
|
127
|
-
if (this.props.onChange) {
|
|
128
|
-
this.props.onChange(this.state);
|
|
129
|
-
}
|
|
130
|
-
}));
|
|
131
|
-
_defineProperty(this, "handleClearSelection", () => {
|
|
132
|
-
if (this.props.disabled) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
this.internalSetState({
|
|
136
|
-
selectedItems: []
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
_defineProperty(this, "handleSelectItem", item => {
|
|
140
|
-
this.internalSetState(state => ({
|
|
141
|
-
selectedItems: state.selectedItems.concat(item)
|
|
142
|
-
}));
|
|
143
|
-
});
|
|
144
|
-
_defineProperty(this, "handleRemoveItem", index => {
|
|
145
|
-
this.internalSetState(state => ({
|
|
146
|
-
selectedItems: removeAtIndex(state.selectedItems, index)
|
|
147
|
-
}));
|
|
148
|
-
});
|
|
149
|
-
_defineProperty(this, "handleOnItemChange", item => {
|
|
150
|
-
if (this.props.disabled) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
const {
|
|
154
|
-
selectedItems
|
|
155
|
-
} = this.state;
|
|
156
|
-
let selectedIndex;
|
|
157
|
-
selectedItems.forEach((selectedItem, index) => {
|
|
158
|
-
if (isEqual(selectedItem, item)) {
|
|
159
|
-
selectedIndex = index;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
if (selectedIndex === undefined) {
|
|
163
|
-
this.handleSelectItem(item);
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
this.handleRemoveItem(selectedIndex);
|
|
167
|
-
});
|
|
168
|
-
this.state = {
|
|
169
|
-
selectedItems: props.initialSelectedItems
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
render() {
|
|
173
|
-
const {
|
|
174
|
-
children,
|
|
175
|
-
render
|
|
176
|
-
} = this.props;
|
|
177
|
-
const {
|
|
178
|
-
selectedItems
|
|
179
|
-
} = this.state;
|
|
180
|
-
const renderProps = {
|
|
181
|
-
selectedItems,
|
|
182
|
-
onItemChange: this.handleOnItemChange,
|
|
183
|
-
clearSelection: this.handleClearSelection
|
|
184
|
-
};
|
|
185
|
-
if (render !== undefined) {
|
|
186
|
-
return render(renderProps);
|
|
187
|
-
}
|
|
188
|
-
if (children !== undefined) {
|
|
189
|
-
return children(renderProps);
|
|
190
|
-
}
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
111
|
+
};
|
|
194
112
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
disabled: PropTypes.bool,
|
|
200
|
-
initialSelectedItems: PropTypes.array.isRequired,
|
|
201
|
-
onChange: PropTypes.func,
|
|
202
|
-
render: PropTypes.func
|
|
203
|
-
});
|
|
113
|
+
/**
|
|
114
|
+
* Generic utility for safely removing an element at a given index from an
|
|
115
|
+
* array.
|
|
116
|
+
*/
|
|
204
117
|
const removeAtIndex = (array, index) => {
|
|
205
118
|
const result = array.slice();
|
|
206
119
|
result.splice(index, 1);
|
|
207
120
|
return result;
|
|
208
121
|
};
|
|
209
122
|
|
|
210
|
-
export {
|
|
123
|
+
export { useSelection };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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 { debounce as debounce$1 } from '../../function/debounce.mjs.js';
|
|
9
|
+
|
|
10
|
+
function debounce(func, debounceMs = 0, options = {}) {
|
|
11
|
+
if (typeof options !== 'object') {
|
|
12
|
+
options = {};
|
|
13
|
+
}
|
|
14
|
+
const { signal, leading = false, trailing = true, maxWait } = options;
|
|
15
|
+
const edges = Array(2);
|
|
16
|
+
if (leading) {
|
|
17
|
+
edges[0] = 'leading';
|
|
18
|
+
}
|
|
19
|
+
if (trailing) {
|
|
20
|
+
edges[1] = 'trailing';
|
|
21
|
+
}
|
|
22
|
+
let result = undefined;
|
|
23
|
+
let pendingAt = null;
|
|
24
|
+
const _debounced = debounce$1(function (...args) {
|
|
25
|
+
result = func.apply(this, args);
|
|
26
|
+
pendingAt = null;
|
|
27
|
+
}, debounceMs, { signal, edges });
|
|
28
|
+
const debounced = function (...args) {
|
|
29
|
+
if (maxWait != null) {
|
|
30
|
+
if (pendingAt === null) {
|
|
31
|
+
pendingAt = Date.now();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (Date.now() - pendingAt >= maxWait) {
|
|
35
|
+
result = func.apply(this, args);
|
|
36
|
+
pendingAt = Date.now();
|
|
37
|
+
_debounced.cancel();
|
|
38
|
+
_debounced.schedule();
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
_debounced.apply(this, args);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
const flush = () => {
|
|
47
|
+
_debounced.flush();
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
debounced.cancel = _debounced.cancel;
|
|
51
|
+
debounced.flush = flush;
|
|
52
|
+
return debounced;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { debounce };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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 { debounce } from './debounce.mjs.js';
|
|
9
|
+
|
|
10
|
+
function throttle(func, throttleMs = 0, options = {}) {
|
|
11
|
+
if (typeof options !== 'object') {
|
|
12
|
+
options = {};
|
|
13
|
+
}
|
|
14
|
+
const { leading = true, trailing = true, signal } = options;
|
|
15
|
+
return debounce(func, throttleMs, {
|
|
16
|
+
leading,
|
|
17
|
+
trailing,
|
|
18
|
+
signal,
|
|
19
|
+
maxWait: throttleMs,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { throttle };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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
|
+
function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
9
|
+
let pendingThis = undefined;
|
|
10
|
+
let pendingArgs = null;
|
|
11
|
+
const leading = edges != null && edges.includes('leading');
|
|
12
|
+
const trailing = edges == null || edges.includes('trailing');
|
|
13
|
+
const invoke = () => {
|
|
14
|
+
if (pendingArgs !== null) {
|
|
15
|
+
func.apply(pendingThis, pendingArgs);
|
|
16
|
+
pendingThis = undefined;
|
|
17
|
+
pendingArgs = null;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const onTimerEnd = () => {
|
|
21
|
+
if (trailing) {
|
|
22
|
+
invoke();
|
|
23
|
+
}
|
|
24
|
+
cancel();
|
|
25
|
+
};
|
|
26
|
+
let timeoutId = null;
|
|
27
|
+
const schedule = () => {
|
|
28
|
+
if (timeoutId != null) {
|
|
29
|
+
clearTimeout(timeoutId);
|
|
30
|
+
}
|
|
31
|
+
timeoutId = setTimeout(() => {
|
|
32
|
+
timeoutId = null;
|
|
33
|
+
onTimerEnd();
|
|
34
|
+
}, debounceMs);
|
|
35
|
+
};
|
|
36
|
+
const cancelTimer = () => {
|
|
37
|
+
if (timeoutId !== null) {
|
|
38
|
+
clearTimeout(timeoutId);
|
|
39
|
+
timeoutId = null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const cancel = () => {
|
|
43
|
+
cancelTimer();
|
|
44
|
+
pendingThis = undefined;
|
|
45
|
+
pendingArgs = null;
|
|
46
|
+
};
|
|
47
|
+
const flush = () => {
|
|
48
|
+
cancelTimer();
|
|
49
|
+
invoke();
|
|
50
|
+
};
|
|
51
|
+
const debounced = function (...args) {
|
|
52
|
+
if (signal?.aborted) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
pendingThis = this;
|
|
56
|
+
pendingArgs = args;
|
|
57
|
+
const isFirstCall = timeoutId == null;
|
|
58
|
+
schedule();
|
|
59
|
+
if (leading && isFirstCall) {
|
|
60
|
+
invoke();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
debounced.schedule = schedule;
|
|
64
|
+
debounced.cancel = cancel;
|
|
65
|
+
debounced.flush = flush;
|
|
66
|
+
signal?.addEventListener('abort', cancel, { once: true });
|
|
67
|
+
return debounced;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { debounce };
|
|
@@ -16,5 +16,5 @@ type WrapComponentArgs<T extends HTMLTagName> = {
|
|
|
16
16
|
* @param {{ name: string, type: string, className?: string | (prefix: string) => string }} props
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
|
-
declare const wrapComponent: <T extends
|
|
19
|
+
declare const wrapComponent: <T extends HTMLTagName>({ name, className: getClassName, type, }: WrapComponentArgs<T>) => ((props: ReactAttr<T>) => React.ReactElement);
|
|
20
20
|
export default wrapComponent;
|
|
@@ -27,7 +27,7 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
27
27
|
/**
|
|
28
28
|
* Optionally specify an href for your Button to become an `<a>` element
|
|
29
29
|
*/
|
|
30
|
-
href?:
|
|
30
|
+
href?: React.AnchorHTMLAttributes<HTMLAnchorElement>['href'];
|
|
31
31
|
/**
|
|
32
32
|
* If specifying the `renderIcon` prop, provide a description for that icon that can
|
|
33
33
|
* be read by screen readers
|
|
@@ -45,6 +45,10 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
45
45
|
* Specify the kind of Button you want to create
|
|
46
46
|
*/
|
|
47
47
|
kind?: ButtonBaseProps['hasIconOnly'] extends true ? IconButtonKind : ButtonKind;
|
|
48
|
+
/**
|
|
49
|
+
* Optionally specify a `rel` when using an `<a>` element.
|
|
50
|
+
*/
|
|
51
|
+
rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
|
|
48
52
|
/**
|
|
49
53
|
* Optional prop to allow overriding the icon rendering.
|
|
50
54
|
* Can be a React component class
|
|
@@ -54,6 +58,10 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
54
58
|
* Specify the size of the button, from the following list of sizes:
|
|
55
59
|
*/
|
|
56
60
|
size?: ButtonSize;
|
|
61
|
+
/**
|
|
62
|
+
* Optionally specify a `target` when using an `<a>` element.
|
|
63
|
+
*/
|
|
64
|
+
target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
|
|
57
65
|
/**
|
|
58
66
|
* Specify the alignment of the tooltip to the icon-only button.
|
|
59
67
|
* Can be one of: start, center, or end.
|
|
@@ -194,6 +194,10 @@ Button.propTypes = {
|
|
|
194
194
|
* leaves the button element
|
|
195
195
|
*/
|
|
196
196
|
onMouseLeave: PropTypes__default["default"].func,
|
|
197
|
+
/**
|
|
198
|
+
* Optionally specify a `rel` when using an `<a>` element.
|
|
199
|
+
*/
|
|
200
|
+
rel: PropTypes__default["default"].string,
|
|
197
201
|
/**
|
|
198
202
|
* Optional prop to allow overriding the icon rendering.
|
|
199
203
|
* Can be a React component class
|
|
@@ -211,6 +215,10 @@ Button.propTypes = {
|
|
|
211
215
|
* Optional prop to specify the tabIndex of the Button
|
|
212
216
|
*/
|
|
213
217
|
tabIndex: PropTypes__default["default"].number,
|
|
218
|
+
/**
|
|
219
|
+
* Optionally specify a `target` when using an `<a>` element.
|
|
220
|
+
*/
|
|
221
|
+
target: PropTypes__default["default"].string,
|
|
214
222
|
/**
|
|
215
223
|
* Specify the alignment of the tooltip to the icon-only button.
|
|
216
224
|
* Can be one of: start, center, or end.
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { PropsWithChildren } from 'react';
|
|
9
9
|
export type DeprecatedCodeSnippetAlignment = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'left-bottom' | 'left-top' | 'right-bottom' | 'right-top';
|
|
10
|
-
export type
|
|
11
|
-
export type CodeSnippetAlignment = DeprecatedCodeSnippetAlignment |
|
|
10
|
+
export type NewCodeSnippetAlignment = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
|
|
11
|
+
export type CodeSnippetAlignment = DeprecatedCodeSnippetAlignment | NewCodeSnippetAlignment;
|
|
12
12
|
export interface CodeSnippetProps {
|
|
13
13
|
/**
|
|
14
14
|
* Specify how the trigger should align with the tooltip
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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.
|
|
@@ -184,7 +184,7 @@ export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLIn
|
|
|
184
184
|
*/
|
|
185
185
|
titleText?: ReactNode;
|
|
186
186
|
/**
|
|
187
|
-
* **Experimental**: will enable
|
|
187
|
+
* **Experimental**: will enable autocomplete and typeahead for the input field
|
|
188
188
|
*/
|
|
189
189
|
typeahead?: boolean;
|
|
190
190
|
/**
|
|
@@ -27,7 +27,6 @@ var usePrefix = require('../../internal/usePrefix.js');
|
|
|
27
27
|
require('../FluidForm/FluidForm.js');
|
|
28
28
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
29
29
|
var react = require('@floating-ui/react');
|
|
30
|
-
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
31
30
|
var index = require('../FeatureFlags/index.js');
|
|
32
31
|
var Text = require('../Text/Text.js');
|
|
33
32
|
var match = require('../../internal/keyboard/match.js');
|
|
@@ -79,21 +78,24 @@ const autocompleteCustomFilter = _ref => {
|
|
|
79
78
|
const getInputValue = _ref2 => {
|
|
80
79
|
let {
|
|
81
80
|
initialSelectedItem,
|
|
82
|
-
inputValue,
|
|
83
81
|
itemToString,
|
|
84
82
|
selectedItem,
|
|
85
83
|
prevSelectedItem
|
|
86
84
|
} = _ref2;
|
|
87
|
-
if
|
|
85
|
+
// If there's a current selection (even if it's an object or string), use it.
|
|
86
|
+
if (selectedItem !== null && typeof selectedItem !== 'undefined') {
|
|
88
87
|
return itemToString(selectedItem);
|
|
89
88
|
}
|
|
90
|
-
|
|
89
|
+
|
|
90
|
+
// On the very first render (when no previous value exists), use
|
|
91
|
+
// `initialSelectedItem`.
|
|
92
|
+
if (typeof prevSelectedItem === 'undefined' && initialSelectedItem !== null && typeof initialSelectedItem !== 'undefined') {
|
|
91
93
|
return itemToString(initialSelectedItem);
|
|
92
94
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return
|
|
95
|
+
|
|
96
|
+
// Otherwise (i.e., after the user has cleared the selection), return an empty
|
|
97
|
+
// string.
|
|
98
|
+
return '';
|
|
97
99
|
};
|
|
98
100
|
const findHighlightedIndex = (_ref3, inputValue) => {
|
|
99
101
|
let {
|
|
@@ -168,7 +170,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
168
170
|
} = react.useFloating(enableFloatingStyles ? {
|
|
169
171
|
placement: direction,
|
|
170
172
|
strategy: 'fixed',
|
|
171
|
-
middleware: autoAlign ? [react.flip(),
|
|
173
|
+
middleware: autoAlign ? [react.flip(), react.hide()] : undefined,
|
|
172
174
|
whileElementsMounted: react.autoUpdate
|
|
173
175
|
} : {});
|
|
174
176
|
const parentWidth = refs?.reference?.current?.clientWidth;
|
|
@@ -190,7 +192,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
190
192
|
}, [enableFloatingStyles, floatingStyles, refs.floating, parentWidth]);
|
|
191
193
|
const [inputValue, setInputValue] = React.useState(getInputValue({
|
|
192
194
|
initialSelectedItem,
|
|
193
|
-
inputValue: '',
|
|
194
195
|
itemToString,
|
|
195
196
|
selectedItem: selectedItemProp
|
|
196
197
|
}));
|
|
@@ -233,7 +234,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
233
234
|
if (prevSelectedItemProp.current !== selectedItemProp) {
|
|
234
235
|
const currentInputValue = getInputValue({
|
|
235
236
|
initialSelectedItem,
|
|
236
|
-
inputValue,
|
|
237
237
|
itemToString,
|
|
238
238
|
selectedItem: selectedItemProp,
|
|
239
239
|
prevSelectedItem: prevSelectedItemProp.current
|
|
@@ -312,6 +312,13 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
312
312
|
return changes;
|
|
313
313
|
}
|
|
314
314
|
case InputKeyDownEnter:
|
|
315
|
+
if (highlightedIndex === -1 && !allowCustomValue && state.selectedItem) {
|
|
316
|
+
return {
|
|
317
|
+
...changes,
|
|
318
|
+
selectedItem: null,
|
|
319
|
+
inputValue: state.inputValue
|
|
320
|
+
};
|
|
321
|
+
}
|
|
315
322
|
if (allowCustomValue) {
|
|
316
323
|
setInputValue(inputValue);
|
|
317
324
|
setHighlightedIndex(changes.selectedItem);
|
|
@@ -332,6 +339,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
332
339
|
}
|
|
333
340
|
case FunctionToggleMenu:
|
|
334
341
|
case ToggleButtonClick:
|
|
342
|
+
if (!changes.isOpen && state.inputValue && highlightedIndex === -1 && !allowCustomValue) {
|
|
343
|
+
return {
|
|
344
|
+
...changes,
|
|
345
|
+
inputValue: '' // Clear the input
|
|
346
|
+
};
|
|
347
|
+
}
|
|
335
348
|
if (changes.isOpen && !changes.selectedItem) {
|
|
336
349
|
return {
|
|
337
350
|
...changes
|
|
@@ -524,6 +537,9 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
524
537
|
});
|
|
525
538
|
const handleFocus = evt => {
|
|
526
539
|
setIsFocused(evt.type === 'focus');
|
|
540
|
+
if (!inputRef.current?.value && evt.type === 'blur') {
|
|
541
|
+
selectItem(null);
|
|
542
|
+
}
|
|
527
543
|
};
|
|
528
544
|
const readOnlyEventHandlers = readOnly ? {
|
|
529
545
|
onKeyDown: evt => {
|
|
@@ -646,6 +662,12 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
646
662
|
toggleMenu();
|
|
647
663
|
}
|
|
648
664
|
}
|
|
665
|
+
if (!inputValue && highlightedIndex == -1 && event.key == 'Enter') {
|
|
666
|
+
if (!isOpen) toggleMenu();
|
|
667
|
+
selectItem(null);
|
|
668
|
+
event.preventDownshiftDefault = true;
|
|
669
|
+
if (event.currentTarget.ariaExpanded === 'false') openMenu();
|
|
670
|
+
}
|
|
649
671
|
if (typeahead && event.key === 'Tab') {
|
|
650
672
|
// event.preventDefault();
|
|
651
673
|
const matchingItem = items.find(item => itemToString(item).toLowerCase().startsWith(inputValue.toLowerCase()));
|
|
@@ -872,7 +894,7 @@ ComboBox.propTypes = {
|
|
|
872
894
|
*/
|
|
873
895
|
translateWithId: PropTypes__default["default"].func,
|
|
874
896
|
/**
|
|
875
|
-
* **Experimental**: will enable
|
|
897
|
+
* **Experimental**: will enable autocomplete and typeahead for the input field
|
|
876
898
|
*/
|
|
877
899
|
typeahead: PropTypes__default["default"].bool,
|
|
878
900
|
/**
|
|
@@ -23,7 +23,6 @@ var useAttachedMenu = require('../../internal/useAttachedMenu.js');
|
|
|
23
23
|
var useId = require('../../internal/useId.js');
|
|
24
24
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
|
-
var floatingUi_dom = require('../../node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs.js');
|
|
27
26
|
var index = require('../FeatureFlags/index.js');
|
|
28
27
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
29
28
|
var deprecateValuesWithin = require('../../prop-types/deprecateValuesWithin.js');
|
|
@@ -82,7 +81,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
82
81
|
if (!enableOnlyFloatingStyles) {
|
|
83
82
|
middlewares = [react.flip({
|
|
84
83
|
crossAxis: false
|
|
85
|
-
}),
|
|
84
|
+
}), react.hide()];
|
|
86
85
|
}
|
|
87
86
|
if (menuAlignment === 'bottom' || menuAlignment === 'top') {
|
|
88
87
|
middlewares.push(react.size({
|
|
@@ -16,7 +16,6 @@ var PropTypes = require('prop-types');
|
|
|
16
16
|
var index = require('../Layer/index.js');
|
|
17
17
|
var ModalHeader = require('./ModalHeader.js');
|
|
18
18
|
var ModalFooter = require('./ModalFooter.js');
|
|
19
|
-
var compat = require('es-toolkit/compat');
|
|
20
19
|
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
21
20
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
22
21
|
var cx = require('classnames');
|
|
@@ -27,6 +26,7 @@ var usePrefix = require('../../internal/usePrefix.js');
|
|
|
27
26
|
var index$1 = require('../FeatureFlags/index.js');
|
|
28
27
|
var events = require('../../tools/events.js');
|
|
29
28
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
29
|
+
var debounce = require('../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js');
|
|
30
30
|
var match = require('../../internal/keyboard/match.js');
|
|
31
31
|
var keys = require('../../internal/keyboard/keys.js');
|
|
32
32
|
|
|
@@ -61,7 +61,7 @@ const ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function Mod
|
|
|
61
61
|
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
const debouncedHandler =
|
|
64
|
+
const debouncedHandler = debounce.debounce(handler, 200);
|
|
65
65
|
window.addEventListener('resize', debouncedHandler);
|
|
66
66
|
return () => {
|
|
67
67
|
debouncedHandler.cancel();
|