@carbon/react 1.78.2 → 1.79.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 +882 -882
- package/es/components/Accordion/AccordionItem.js +2 -2
- package/es/components/Button/Button.d.ts +2 -3
- package/es/components/Button/Button.js +29 -19
- package/es/components/Button/ButtonBase.js +3 -1
- package/es/components/ChatButton/ChatButton.d.ts +2 -3
- package/es/components/ChatButton/ChatButton.js +1 -2
- package/es/components/ComboBox/ComboBox.js +34 -24
- package/es/components/ComposedModal/ComposedModal.js +65 -51
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +3 -3
- package/es/components/DataTable/TableBatchAction.d.ts +3 -3
- package/es/components/DataTable/TableBatchAction.js +1 -1
- package/es/components/DataTable/TableContainer.d.ts +1 -1
- package/es/components/DataTable/TableContainer.js +5 -4
- package/es/components/DataTable/TableExpandHeader.d.ts +6 -5
- package/es/components/DataTable/TableToolbarMenu.d.ts +2 -2
- package/es/components/DataTable/TableToolbarMenu.js +1 -1
- package/es/components/DatePicker/DatePicker.js +2 -2
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
- package/es/components/Dialog/index.d.ts +42 -4
- package/es/components/Dialog/index.js +177 -0
- package/es/components/ExpandableSearch/ExpandableSearch.js +2 -2
- package/es/components/FeatureFlags/index.d.ts +3 -1
- package/es/components/FeatureFlags/index.js +3 -0
- package/es/components/FileUploader/FileUploader.d.ts +1 -1
- package/es/components/FileUploader/FileUploader.js +2 -2
- package/es/components/FileUploader/FileUploaderButton.js +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +6 -4
- package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +2 -2
- package/es/components/Grid/CSSGrid.js +18 -14
- package/es/components/Grid/Column.d.ts +2 -2
- package/es/components/Grid/Column.js +7 -8
- package/es/components/Grid/FlexGrid.js +7 -6
- package/es/components/Grid/GridTypes.d.ts +5 -3
- package/es/components/IconButton/index.d.ts +2 -2
- package/es/components/IconButton/index.js +4 -4
- package/es/components/Layer/index.d.ts +4 -6
- package/es/components/Layer/index.js +5 -6
- package/es/components/Link/Link.d.ts +2 -3
- package/es/components/Link/Link.js +1 -2
- package/es/components/ListBox/ListBoxMenuItem.d.ts +3 -3
- package/es/components/ListBox/ListBoxMenuItem.js +37 -15
- package/es/components/Menu/Menu.js +2 -2
- package/es/components/Menu/MenuItem.d.ts +2 -2
- package/es/components/Menu/MenuItem.js +3 -3
- package/es/components/Modal/Modal.js +121 -49
- package/es/components/ModalWrapper/ModalWrapper.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +3 -3
- package/es/components/MultiSelect/MultiSelect.js +2 -2
- package/es/components/MultiSelect/index.d.ts +1 -1
- package/es/components/MultiSelect/index.js +1 -8
- package/es/components/Notification/Notification.d.ts +5 -13
- package/es/components/Notification/Notification.js +3 -4
- package/es/components/OverflowMenu/OverflowMenu.d.ts +22 -201
- package/es/components/OverflowMenu/OverflowMenu.js +269 -338
- package/es/components/OverflowMenu/index.d.ts +5 -5
- package/es/components/OverflowMenu/index.js +2 -2
- package/es/components/OverflowMenu/next/index.d.ts +4 -4
- package/es/components/OverflowMenu/next/index.js +1 -1
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/es/components/ProgressIndicator/ProgressIndicator.js +2 -2
- package/es/components/RadioTile/RadioTile.js +2 -2
- package/es/components/Search/Search.d.ts +2 -3
- package/es/components/Search/Search.js +4 -6
- package/es/components/Slider/Slider.d.ts +39 -44
- package/es/components/Slider/Slider.js +57 -59
- package/es/components/Tabs/Tabs.d.ts +3 -6
- package/es/components/Tabs/Tabs.js +16 -18
- package/es/components/Tag/DismissibleTag.d.ts +3 -5
- package/es/components/Tag/DismissibleTag.js +1 -2
- package/es/components/Tag/OperationalTag.d.ts +2 -3
- package/es/components/Tag/OperationalTag.js +1 -2
- package/es/components/Tag/SelectableTag.d.ts +3 -5
- package/es/components/Tag/SelectableTag.js +1 -2
- package/es/components/Tag/Tag.d.ts +2 -3
- package/es/components/Tag/Tag.js +1 -2
- package/es/components/Tile/Tile.d.ts +3 -5
- package/es/components/Tile/Tile.js +16 -10
- package/es/components/Toggletip/index.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.js +2 -2
- package/es/components/Tooltip/Tooltip.d.ts +1 -1
- package/es/components/Tooltip/Tooltip.js +2 -2
- package/es/components/TreeView/TreeNode.d.ts +3 -5
- package/es/components/TreeView/TreeNode.js +3 -4
- package/es/components/TreeView/TreeView.js +2 -2
- package/es/components/UIShell/HeaderContainer.js +2 -2
- package/es/components/UIShell/HeaderMenu.js +2 -2
- package/es/components/UIShell/HeaderPanel.js +2 -2
- package/es/components/UIShell/SideNav.d.ts +1 -1
- package/es/components/UIShell/SideNav.js +2 -2
- package/es/components/UIShell/SideNavHeader.d.ts +2 -3
- package/es/components/UIShell/SideNavHeader.js +1 -2
- package/es/components/UIShell/SideNavLink.d.ts +2 -2
- package/es/components/UIShell/SideNavLink.js +1 -1
- package/es/components/UIShell/SideNavMenu.d.ts +2 -2
- package/es/components/UIShell/SideNavMenu.js +3 -3
- package/es/components/UIShell/SwitcherItem.js +2 -2
- package/es/index.js +1 -1
- package/es/internal/FloatingMenu.d.ts +2 -2
- package/es/internal/FloatingMenu.js +8 -5
- package/es/internal/OptimizedResize.d.ts +18 -0
- package/es/internal/OptimizedResize.js +21 -24
- package/es/internal/createClassWrapper.d.ts +3 -3
- package/es/internal/createClassWrapper.js +4 -4
- package/es/internal/keyboard/index.d.ts +9 -0
- package/es/internal/keyboard/keys.d.ts +23 -0
- package/es/internal/keyboard/keys.js +2 -2
- package/es/internal/keyboard/match.d.ts +26 -0
- package/es/internal/keyboard/match.js +17 -41
- package/es/internal/keyboard/navigation.d.ts +37 -0
- package/es/internal/keyboard/navigation.js +15 -27
- package/es/internal/useIsomorphicEffect.d.ts +10 -0
- package/es/internal/useIsomorphicEffect.js +2 -3
- package/es/internal/useMatchMedia.d.ts +8 -0
- package/es/internal/useMatchMedia.js +10 -20
- package/es/internal/useMergedRefs.js +3 -0
- package/es/internal/useNormalizedInputProps.d.ts +52 -0
- package/es/internal/useNormalizedInputProps.js +9 -36
- package/lib/components/Accordion/AccordionItem.js +2 -2
- package/lib/components/Button/Button.d.ts +2 -3
- package/lib/components/Button/Button.js +29 -19
- package/lib/components/Button/ButtonBase.js +3 -1
- package/lib/components/ChatButton/ChatButton.d.ts +2 -3
- package/lib/components/ChatButton/ChatButton.js +1 -2
- package/lib/components/ComboBox/ComboBox.js +34 -24
- package/lib/components/ComposedModal/ComposedModal.js +64 -50
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +3 -3
- package/lib/components/DataTable/TableBatchAction.d.ts +3 -3
- package/lib/components/DataTable/TableBatchAction.js +1 -1
- package/lib/components/DataTable/TableContainer.d.ts +1 -1
- package/lib/components/DataTable/TableContainer.js +5 -4
- package/lib/components/DataTable/TableExpandHeader.d.ts +6 -5
- package/lib/components/DataTable/TableToolbarMenu.d.ts +2 -2
- package/lib/components/DataTable/TableToolbarMenu.js +1 -1
- package/lib/components/DatePicker/DatePicker.js +2 -2
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
- package/lib/components/Dialog/index.d.ts +42 -4
- package/lib/components/Dialog/index.js +190 -0
- package/lib/components/ExpandableSearch/ExpandableSearch.js +2 -2
- package/lib/components/FeatureFlags/index.d.ts +3 -1
- package/lib/components/FeatureFlags/index.js +3 -0
- package/lib/components/FileUploader/FileUploader.d.ts +1 -1
- package/lib/components/FileUploader/FileUploader.js +2 -2
- package/lib/components/FileUploader/FileUploaderButton.js +2 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +6 -4
- package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +2 -2
- package/lib/components/Grid/CSSGrid.js +18 -14
- package/lib/components/Grid/Column.d.ts +2 -2
- package/lib/components/Grid/Column.js +7 -8
- package/lib/components/Grid/FlexGrid.js +7 -6
- package/lib/components/Grid/GridTypes.d.ts +5 -3
- package/lib/components/IconButton/index.d.ts +2 -2
- package/lib/components/IconButton/index.js +4 -4
- package/lib/components/Layer/index.d.ts +4 -6
- package/lib/components/Layer/index.js +5 -6
- package/lib/components/Link/Link.d.ts +2 -3
- package/lib/components/Link/Link.js +1 -2
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +3 -3
- package/lib/components/ListBox/ListBoxMenuItem.js +36 -14
- package/lib/components/Menu/Menu.js +2 -2
- package/lib/components/Menu/MenuItem.d.ts +2 -2
- package/lib/components/Menu/MenuItem.js +3 -3
- package/lib/components/Modal/Modal.js +123 -51
- package/lib/components/ModalWrapper/ModalWrapper.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -3
- package/lib/components/MultiSelect/MultiSelect.js +2 -2
- package/lib/components/MultiSelect/index.d.ts +1 -1
- package/lib/components/MultiSelect/index.js +1 -8
- package/lib/components/Notification/Notification.d.ts +5 -13
- package/lib/components/Notification/Notification.js +3 -4
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +22 -201
- package/lib/components/OverflowMenu/OverflowMenu.js +268 -336
- package/lib/components/OverflowMenu/index.d.ts +5 -5
- package/lib/components/OverflowMenu/index.js +2 -2
- package/lib/components/OverflowMenu/next/index.d.ts +4 -4
- package/lib/components/OverflowMenu/next/index.js +1 -1
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/lib/components/ProgressIndicator/ProgressIndicator.js +2 -2
- package/lib/components/RadioTile/RadioTile.js +2 -2
- package/lib/components/Search/Search.d.ts +2 -3
- package/lib/components/Search/Search.js +4 -6
- package/lib/components/Slider/Slider.d.ts +39 -44
- package/lib/components/Slider/Slider.js +57 -59
- package/lib/components/Tabs/Tabs.d.ts +3 -6
- package/lib/components/Tabs/Tabs.js +16 -18
- package/lib/components/Tag/DismissibleTag.d.ts +3 -5
- package/lib/components/Tag/DismissibleTag.js +1 -2
- package/lib/components/Tag/OperationalTag.d.ts +2 -3
- package/lib/components/Tag/OperationalTag.js +1 -2
- package/lib/components/Tag/SelectableTag.d.ts +3 -5
- package/lib/components/Tag/SelectableTag.js +1 -2
- package/lib/components/Tag/Tag.d.ts +2 -3
- package/lib/components/Tag/Tag.js +1 -2
- package/lib/components/Tile/Tile.d.ts +3 -5
- package/lib/components/Tile/Tile.js +16 -10
- package/lib/components/Toggletip/index.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
- package/lib/components/Tooltip/Tooltip.d.ts +1 -1
- package/lib/components/Tooltip/Tooltip.js +2 -2
- package/lib/components/TreeView/TreeNode.d.ts +3 -5
- package/lib/components/TreeView/TreeNode.js +3 -4
- package/lib/components/TreeView/TreeView.js +2 -2
- package/lib/components/UIShell/HeaderContainer.js +2 -2
- package/lib/components/UIShell/HeaderMenu.js +2 -2
- package/lib/components/UIShell/HeaderPanel.js +2 -2
- package/lib/components/UIShell/SideNav.d.ts +1 -1
- package/lib/components/UIShell/SideNav.js +2 -2
- package/lib/components/UIShell/SideNavHeader.d.ts +2 -3
- package/lib/components/UIShell/SideNavHeader.js +1 -2
- package/lib/components/UIShell/SideNavLink.d.ts +2 -2
- package/lib/components/UIShell/SideNavLink.js +1 -1
- package/lib/components/UIShell/SideNavMenu.d.ts +2 -2
- package/lib/components/UIShell/SideNavMenu.js +3 -3
- package/lib/components/UIShell/SwitcherItem.js +2 -2
- package/lib/index.js +2 -2
- package/lib/internal/FloatingMenu.d.ts +2 -2
- package/lib/internal/FloatingMenu.js +9 -6
- package/lib/internal/OptimizedResize.d.ts +18 -0
- package/lib/internal/OptimizedResize.js +21 -24
- package/lib/internal/createClassWrapper.d.ts +3 -3
- package/lib/internal/createClassWrapper.js +4 -4
- package/lib/internal/keyboard/index.d.ts +9 -0
- package/lib/internal/keyboard/keys.d.ts +23 -0
- package/lib/internal/keyboard/keys.js +2 -2
- package/lib/internal/keyboard/match.d.ts +26 -0
- package/lib/internal/keyboard/match.js +17 -41
- package/lib/internal/keyboard/navigation.d.ts +37 -0
- package/lib/internal/keyboard/navigation.js +15 -27
- package/lib/internal/useIsomorphicEffect.d.ts +10 -0
- package/lib/internal/useIsomorphicEffect.js +2 -3
- package/lib/internal/useMatchMedia.d.ts +8 -0
- package/lib/internal/useMatchMedia.js +10 -20
- package/lib/internal/useMergedRefs.js +3 -0
- package/lib/internal/useNormalizedInputProps.d.ts +52 -0
- package/lib/internal/useNormalizedInputProps.js +9 -36
- package/package.json +6 -6
- package/scss/components/dialog/_dialog.scss +9 -0
- package/scss/components/dialog/_index.scss +9 -0
- package/telemetry.yml +1 -0
- package/es/components/Modal/next/index.d.ts +0 -171
- package/es/internal/focus/index.js +0 -15
- package/es/internal/useEffectOnce.js +0 -30
- package/lib/components/Modal/next/index.d.ts +0 -171
- package/lib/internal/focus/index.js +0 -19
- package/lib/internal/useEffectOnce.js +0 -34
|
@@ -24,9 +24,9 @@ function useLayer() {
|
|
|
24
24
|
level
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const Layer = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
28
28
|
let {
|
|
29
|
-
as
|
|
29
|
+
as,
|
|
30
30
|
className: customClassName,
|
|
31
31
|
children,
|
|
32
32
|
level: overrideLevel,
|
|
@@ -38,7 +38,7 @@ const LayerRenderFunction = /*#__PURE__*/React__default.forwardRef(function Laye
|
|
|
38
38
|
const className = cx(`${prefix}--layer-${levels[level]}`, customClassName);
|
|
39
39
|
// The level should be between MIN_LEVEL and MAX_LEVEL
|
|
40
40
|
const value = Math.max(MIN_LEVEL, Math.min(level + 1, MAX_LEVEL));
|
|
41
|
-
const BaseComponent = as;
|
|
41
|
+
const BaseComponent = as || 'div';
|
|
42
42
|
return /*#__PURE__*/React__default.createElement(LayerContext.Provider, {
|
|
43
43
|
value: value
|
|
44
44
|
}, /*#__PURE__*/React__default.createElement(BaseComponent, _extends({
|
|
@@ -47,8 +47,8 @@ const LayerRenderFunction = /*#__PURE__*/React__default.forwardRef(function Laye
|
|
|
47
47
|
className: className
|
|
48
48
|
}), children));
|
|
49
49
|
});
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
Layer.displayName = 'Layer';
|
|
51
|
+
Layer.propTypes = {
|
|
52
52
|
/**
|
|
53
53
|
* Specify a custom component or element to be rendered as the top-level
|
|
54
54
|
* element in the component
|
|
@@ -68,6 +68,5 @@ LayerRenderFunction.propTypes = {
|
|
|
68
68
|
*/
|
|
69
69
|
level: PropTypes.oneOf([0, 1, 2])
|
|
70
70
|
};
|
|
71
|
-
const Layer = LayerRenderFunction;
|
|
72
71
|
|
|
73
72
|
export { Layer, useLayer };
|
|
@@ -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.
|
|
@@ -31,8 +31,7 @@ export interface LinkBaseProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
31
31
|
*/
|
|
32
32
|
inline?: boolean;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* Can be a React component class
|
|
34
|
+
* A component used to render an icon.
|
|
36
35
|
*/
|
|
37
36
|
renderIcon?: ComponentType;
|
|
38
37
|
/**
|
|
@@ -82,8 +82,7 @@ Link.propTypes = {
|
|
|
82
82
|
*/
|
|
83
83
|
inline: PropTypes.bool,
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
* Can be a React component class
|
|
85
|
+
* A component used to render an icon.
|
|
87
86
|
*/
|
|
88
87
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
89
88
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
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.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import { ForwardedRef, ReactNode, type Ref } from 'react';
|
|
8
8
|
import { ForwardRefReturn, ReactAttr } from '../../types/common';
|
|
9
9
|
export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
10
10
|
/**
|
|
@@ -30,7 +30,7 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
|
30
30
|
title?: string;
|
|
31
31
|
}
|
|
32
32
|
export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLLIElement> & {
|
|
33
|
-
menuItemOptionRef?:
|
|
33
|
+
menuItemOptionRef?: Ref<HTMLDivElement>;
|
|
34
34
|
}) | null;
|
|
35
35
|
export type ListBoxMenuItemComponent = ForwardRefReturn<ListBoxMenuItemForwardedRef, ListBoxMenuItemProps>;
|
|
36
36
|
declare const _default: ListBoxMenuItemComponent;
|
|
@@ -7,28 +7,47 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
|
-
import React__default, { useRef, useState, useEffect } from 'react';
|
|
10
|
+
import React__default, { forwardRef, useRef, useState, useEffect } from 'react';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Determines if the content of an element is truncated.
|
|
17
|
+
*
|
|
18
|
+
* Merges a forwarded ref with a local ref to check the element's dimensions.
|
|
19
|
+
*
|
|
20
|
+
* @template T
|
|
21
|
+
* @param forwardedRef - A ref passed from the parent component.
|
|
22
|
+
* @param deps - Dependencies to re-run the truncation check.
|
|
23
|
+
* @returns An object containing the truncation state and the merged ref.
|
|
24
|
+
*/
|
|
25
|
+
const useIsTruncated = function (forwardedRef) {
|
|
26
|
+
let deps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
27
|
+
const localRef = useRef(null);
|
|
28
|
+
const mergedRef = useMergedRefs([...(forwardedRef ? [forwardedRef] : []), localRef]);
|
|
15
29
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
16
30
|
useEffect(() => {
|
|
17
|
-
const element =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
31
|
+
const element = localRef.current;
|
|
32
|
+
if (element) {
|
|
33
|
+
const {
|
|
34
|
+
offsetWidth,
|
|
35
|
+
scrollWidth
|
|
36
|
+
} = element;
|
|
37
|
+
setIsTruncated(offsetWidth < scrollWidth);
|
|
38
|
+
}
|
|
39
|
+
}, [localRef, ...deps]);
|
|
40
|
+
return {
|
|
41
|
+
isTruncated,
|
|
42
|
+
ref: mergedRef
|
|
43
|
+
};
|
|
44
|
+
};
|
|
26
45
|
/**
|
|
27
46
|
* `ListBoxMenuItem` is a helper component for managing the container class
|
|
28
47
|
* name, alongside any classes for any corresponding states, for a generic list
|
|
29
48
|
* box menu item.
|
|
30
49
|
*/
|
|
31
|
-
const ListBoxMenuItem = /*#__PURE__*/
|
|
50
|
+
const ListBoxMenuItem = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
|
|
32
51
|
let {
|
|
33
52
|
children,
|
|
34
53
|
isActive = false,
|
|
@@ -37,8 +56,11 @@ const ListBoxMenuItem = /*#__PURE__*/React__default.forwardRef(function ListBoxM
|
|
|
37
56
|
...rest
|
|
38
57
|
} = _ref;
|
|
39
58
|
const prefix = usePrefix();
|
|
40
|
-
const
|
|
41
|
-
const
|
|
59
|
+
const menuItemOptionRefProp = forwardedRef && typeof forwardedRef !== 'function' ? forwardedRef.menuItemOptionRef : undefined;
|
|
60
|
+
const {
|
|
61
|
+
isTruncated,
|
|
62
|
+
ref: menuItemOptionRef
|
|
63
|
+
} = useIsTruncated(menuItemOptionRefProp, [children]);
|
|
42
64
|
const className = cx(`${prefix}--list-box__menu-item`, {
|
|
43
65
|
[`${prefix}--list-box__menu-item--active`]: isActive,
|
|
44
66
|
[`${prefix}--list-box__menu-item--highlighted`]: isHighlighted
|
|
@@ -48,7 +70,7 @@ const ListBoxMenuItem = /*#__PURE__*/React__default.forwardRef(function ListBoxM
|
|
|
48
70
|
title: isTruncated ? title : undefined
|
|
49
71
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
50
72
|
className: `${prefix}--list-box__menu-item__option`,
|
|
51
|
-
ref:
|
|
73
|
+
ref: menuItemOptionRef
|
|
52
74
|
}, children));
|
|
53
75
|
});
|
|
54
76
|
ListBoxMenuItem.displayName = 'ListBoxMenuItem';
|
|
@@ -10,14 +10,14 @@ import cx from 'classnames';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React__default, { forwardRef, useRef, useContext, useReducer, useMemo, useState, useEffect } from 'react';
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
|
+
import { Escape, ArrowLeft, ArrowUp, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
14
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
13
15
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
14
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
17
|
import deprecate from '../../prop-types/deprecate.js';
|
|
16
18
|
import { MenuContext, menuReducer } from './MenuContext.js';
|
|
17
19
|
import { canUseDOM } from '../../internal/environment.js';
|
|
18
20
|
import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
|
|
19
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
20
|
-
import { Escape, ArrowLeft, ArrowUp, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
21
21
|
|
|
22
22
|
const spacing = 8; // distance to keep to window edges, in px
|
|
23
23
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp.
|
|
2
|
+
* Copyright IBM Corp. 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.
|
|
@@ -31,7 +31,7 @@ export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
|
31
31
|
*/
|
|
32
32
|
onClick?: (event: KeyboardEvent<HTMLLIElement> | MouseEvent<HTMLLIElement>) => void;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* A component used to render an icon.
|
|
35
35
|
*/
|
|
36
36
|
renderIcon?: FC;
|
|
37
37
|
/**
|
|
@@ -11,6 +11,8 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import React__default, { forwardRef, useState, useContext, useRef, useEffect } from 'react';
|
|
12
12
|
import { useFloating, autoUpdate, offset, useInteractions, useHover, safePolygon, FloatingFocusManager } from '@floating-ui/react';
|
|
13
13
|
import { Checkmark, CaretLeft, CaretRight } from '@carbon/icons-react';
|
|
14
|
+
import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
15
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
14
16
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
15
17
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
16
18
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -18,9 +20,7 @@ import { Menu } from './Menu.js';
|
|
|
18
20
|
import { MenuContext } from './MenuContext.js';
|
|
19
21
|
import '../Text/index.js';
|
|
20
22
|
import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
|
|
21
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
22
23
|
import { Text } from '../Text/Text.js';
|
|
23
|
-
import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
24
24
|
|
|
25
25
|
var _Checkmark, _CaretLeft, _CaretRight;
|
|
26
26
|
const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
@@ -212,7 +212,7 @@ MenuItem.propTypes = {
|
|
|
212
212
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
213
213
|
onClick: PropTypes.func,
|
|
214
214
|
/**
|
|
215
|
-
*
|
|
215
|
+
* A component used to render an icon.
|
|
216
216
|
*/
|
|
217
217
|
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
218
218
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
@@ -17,20 +17,21 @@ import ButtonSet from '../ButtonSet/ButtonSet.js';
|
|
|
17
17
|
import InlineLoading from '../InlineLoading/InlineLoading.js';
|
|
18
18
|
import { Layer } from '../Layer/index.js';
|
|
19
19
|
import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy.js';
|
|
20
|
-
import wrapFocus, {
|
|
20
|
+
import wrapFocus, { elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
|
|
21
21
|
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
22
22
|
import { useId } from '../../internal/useId.js';
|
|
23
23
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
24
|
+
import { Escape, Enter } from '../../internal/keyboard/keys.js';
|
|
25
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
24
26
|
import { IconButton } from '../IconButton/index.js';
|
|
25
27
|
import { noopFn } from '../../internal/noopFn.js';
|
|
26
28
|
import '../Text/index.js';
|
|
27
29
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
28
30
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
29
31
|
import deprecate from '../../prop-types/deprecate.js';
|
|
32
|
+
import { unstable__Dialog } from '../Dialog/index.js';
|
|
30
33
|
import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.mjs.js';
|
|
31
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
32
34
|
import { Text } from '../Text/Text.js';
|
|
33
|
-
import { Escape, Enter, Tab } from '../../internal/keyboard/keys.js';
|
|
34
35
|
|
|
35
36
|
const ModalSizes = ['xs', 'sm', 'md', 'lg'];
|
|
36
37
|
const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
@@ -86,7 +87,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
86
87
|
[`${prefix}--btn--loading`]: loadingStatus !== 'inactive'
|
|
87
88
|
});
|
|
88
89
|
const loadingActive = loadingStatus !== 'inactive';
|
|
89
|
-
const
|
|
90
|
+
const enableDialogElement = useFeatureFlag('enable-experimental-focus-wrap-without-sentinels') || useFeatureFlag('enable-dialog-element');
|
|
90
91
|
function isCloseButton(element) {
|
|
91
92
|
return !onSecondarySubmit && element === secondaryButton.current || element.classList.contains(modalCloseButtonClass);
|
|
92
93
|
}
|
|
@@ -99,13 +100,6 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
99
100
|
if (match(evt, Enter) && shouldSubmitOnEnter && !isCloseButton(evt.target)) {
|
|
100
101
|
onRequestSubmit(evt);
|
|
101
102
|
}
|
|
102
|
-
if (focusTrapWithoutSentinels && match(evt, Tab) && innerModal.current) {
|
|
103
|
-
wrapFocusWithoutSentinels({
|
|
104
|
-
containerNode: innerModal.current,
|
|
105
|
-
currentActiveNode: evt.target,
|
|
106
|
-
event: evt
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
105
|
function handleOnClick(evt) {
|
|
@@ -181,40 +175,46 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
181
175
|
}
|
|
182
176
|
useEffect(() => {
|
|
183
177
|
return () => {
|
|
184
|
-
|
|
178
|
+
if (!enableDialogElement) {
|
|
179
|
+
toggleClass(document.body, `${prefix}--body--with-modal-open`, false);
|
|
180
|
+
}
|
|
185
181
|
};
|
|
186
|
-
}, [prefix]);
|
|
182
|
+
}, [prefix, enableDialogElement]);
|
|
187
183
|
useEffect(() => {
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
if (!enableDialogElement) {
|
|
185
|
+
toggleClass(document.body, `${prefix}--body--with-modal-open`, open ?? false);
|
|
186
|
+
}
|
|
187
|
+
}, [open, prefix, enableDialogElement]);
|
|
190
188
|
useEffect(() => {
|
|
191
|
-
if (!open && launcherButtonRef) {
|
|
189
|
+
if (!enableDialogElement && !open && launcherButtonRef) {
|
|
192
190
|
setTimeout(() => {
|
|
193
191
|
if ('current' in launcherButtonRef) {
|
|
194
192
|
launcherButtonRef.current?.focus();
|
|
195
193
|
}
|
|
196
194
|
});
|
|
197
195
|
}
|
|
198
|
-
}, [open, launcherButtonRef]);
|
|
196
|
+
}, [open, launcherButtonRef, enableDialogElement]);
|
|
199
197
|
useEffect(() => {
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
target
|
|
198
|
+
if (!enableDialogElement) {
|
|
199
|
+
const initialFocus = focusContainerElement => {
|
|
200
|
+
const containerElement = focusContainerElement || innerModal.current;
|
|
201
|
+
const primaryFocusElement = containerElement ? containerElement.querySelector(danger ? `.${prefix}--btn--secondary` : selectorPrimaryFocus) : null;
|
|
202
|
+
if (primaryFocusElement) {
|
|
203
|
+
return primaryFocusElement;
|
|
204
|
+
}
|
|
205
|
+
return button && button.current;
|
|
206
|
+
};
|
|
207
|
+
const focusButton = focusContainerElement => {
|
|
208
|
+
const target = initialFocus(focusContainerElement);
|
|
209
|
+
if (target !== null) {
|
|
210
|
+
target.focus();
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
if (open) {
|
|
214
|
+
focusButton(innerModal.current);
|
|
212
215
|
}
|
|
213
|
-
};
|
|
214
|
-
if (open) {
|
|
215
|
-
focusButton(innerModal.current);
|
|
216
216
|
}
|
|
217
|
-
}, [open, selectorPrimaryFocus, danger, prefix]);
|
|
217
|
+
}, [open, selectorPrimaryFocus, danger, prefix, enableDialogElement]);
|
|
218
218
|
useIsomorphicEffect(() => {
|
|
219
219
|
if (contentRef.current) {
|
|
220
220
|
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
@@ -254,7 +254,84 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
254
254
|
tabIndex: "-1",
|
|
255
255
|
className: `${modalCloseButtonClass}__icon`
|
|
256
256
|
})));
|
|
257
|
-
|
|
257
|
+
|
|
258
|
+
// alertdialog is the only permitted aria role for a native dialog element
|
|
259
|
+
// https://www.w3.org/TR/html-aria/#docconformance:~:text=Role%3A-,alertdialog,-.%20(dialog%20is
|
|
260
|
+
const isAlertDialog = alert && !passiveModal;
|
|
261
|
+
const modalBody = enableDialogElement ? /*#__PURE__*/React__default.createElement(unstable__Dialog, {
|
|
262
|
+
open: open,
|
|
263
|
+
modal: true,
|
|
264
|
+
ref: innerModal,
|
|
265
|
+
role: isAlertDialog ? 'alertdialog' : '',
|
|
266
|
+
"aria-describedby": isAlertDialog ? modalBodyId : '',
|
|
267
|
+
className: containerClasses,
|
|
268
|
+
"aria-label": ariaLabel
|
|
269
|
+
}, /*#__PURE__*/React__default.createElement("div", {
|
|
270
|
+
className: `${prefix}--modal-header`
|
|
271
|
+
}, modalLabel && /*#__PURE__*/React__default.createElement(Text, {
|
|
272
|
+
as: "h2",
|
|
273
|
+
id: modalLabelId,
|
|
274
|
+
className: `${prefix}--modal-header__label`
|
|
275
|
+
}, modalLabel), /*#__PURE__*/React__default.createElement(Text, {
|
|
276
|
+
as: "h2",
|
|
277
|
+
id: modalHeadingId,
|
|
278
|
+
className: `${prefix}--modal-header__heading`
|
|
279
|
+
}, modalHeading), decorator ? /*#__PURE__*/React__default.createElement("div", {
|
|
280
|
+
className: `${prefix}--modal--inner__decorator`
|
|
281
|
+
}, normalizedDecorator) : '', /*#__PURE__*/React__default.createElement("div", {
|
|
282
|
+
className: `${prefix}--modal-close-button`
|
|
283
|
+
}, /*#__PURE__*/React__default.createElement(IconButton, {
|
|
284
|
+
className: modalCloseButtonClass,
|
|
285
|
+
label: closeButtonLabel,
|
|
286
|
+
onClick: onRequestClose,
|
|
287
|
+
"aria-label": closeButtonLabel,
|
|
288
|
+
align: "left",
|
|
289
|
+
ref: button
|
|
290
|
+
}, /*#__PURE__*/React__default.createElement(Close, {
|
|
291
|
+
size: 20,
|
|
292
|
+
"aria-hidden": "true",
|
|
293
|
+
tabIndex: "-1",
|
|
294
|
+
className: `${modalCloseButtonClass}__icon`
|
|
295
|
+
})))), /*#__PURE__*/React__default.createElement(Layer, _extends({
|
|
296
|
+
ref: contentRef,
|
|
297
|
+
id: modalBodyId,
|
|
298
|
+
className: contentClasses
|
|
299
|
+
}, hasScrollingContentProps), children), !passiveModal && /*#__PURE__*/React__default.createElement(ButtonSet, {
|
|
300
|
+
className: footerClasses,
|
|
301
|
+
"aria-busy": loadingActive
|
|
302
|
+
}, Array.isArray(secondaryButtons) && secondaryButtons.length <= 2 ? secondaryButtons.map((_ref3, i) => {
|
|
303
|
+
let {
|
|
304
|
+
buttonText,
|
|
305
|
+
onClick: onButtonClick
|
|
306
|
+
} = _ref3;
|
|
307
|
+
return /*#__PURE__*/React__default.createElement(Button, {
|
|
308
|
+
key: `${buttonText}-${i}`,
|
|
309
|
+
kind: "secondary",
|
|
310
|
+
onClick: onButtonClick
|
|
311
|
+
}, buttonText);
|
|
312
|
+
}) : secondaryButtonText && /*#__PURE__*/React__default.createElement(Button, {
|
|
313
|
+
disabled: loadingActive,
|
|
314
|
+
kind: "secondary",
|
|
315
|
+
onClick: onSecondaryButtonClick,
|
|
316
|
+
ref: secondaryButton
|
|
317
|
+
}, secondaryButtonText), /*#__PURE__*/React__default.createElement(Button, {
|
|
318
|
+
className: primaryButtonClass,
|
|
319
|
+
kind: danger ? 'danger' : 'primary',
|
|
320
|
+
disabled: loadingActive || primaryButtonDisabled,
|
|
321
|
+
onClick: onRequestSubmit,
|
|
322
|
+
ref: button
|
|
323
|
+
}, loadingStatus === 'inactive' ? primaryButtonText : /*#__PURE__*/React__default.createElement(InlineLoading, {
|
|
324
|
+
status: loadingStatus,
|
|
325
|
+
description: loadingDescription,
|
|
326
|
+
iconDescription: loadingIconDescription,
|
|
327
|
+
className: `${prefix}--inline-loading--btn`,
|
|
328
|
+
onSuccess: onLoadingSuccess
|
|
329
|
+
})))) : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, !enableDialogElement && /*#__PURE__*/React__default.createElement("span", {
|
|
330
|
+
ref: startTrap,
|
|
331
|
+
tabIndex: 0,
|
|
332
|
+
role: "link",
|
|
333
|
+
className: `${prefix}--visually-hidden`
|
|
334
|
+
}, "Focus sentinel"), /*#__PURE__*/React__default.createElement("div", _extends({
|
|
258
335
|
ref: innerModal,
|
|
259
336
|
role: "dialog"
|
|
260
337
|
}, alertDialogProps, {
|
|
@@ -281,11 +358,11 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
281
358
|
}, hasScrollingContentProps), children), !passiveModal && /*#__PURE__*/React__default.createElement(ButtonSet, {
|
|
282
359
|
className: footerClasses,
|
|
283
360
|
"aria-busy": loadingActive
|
|
284
|
-
}, Array.isArray(secondaryButtons) && secondaryButtons.length <= 2 ? secondaryButtons.map((
|
|
361
|
+
}, Array.isArray(secondaryButtons) && secondaryButtons.length <= 2 ? secondaryButtons.map((_ref4, i) => {
|
|
285
362
|
let {
|
|
286
363
|
buttonText,
|
|
287
364
|
onClick: onButtonClick
|
|
288
|
-
} =
|
|
365
|
+
} = _ref4;
|
|
289
366
|
return /*#__PURE__*/React__default.createElement(Button, {
|
|
290
367
|
key: `${buttonText}-${i}`,
|
|
291
368
|
kind: "secondary",
|
|
@@ -308,26 +385,21 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
308
385
|
iconDescription: loadingIconDescription,
|
|
309
386
|
className: `${prefix}--inline-loading--btn`,
|
|
310
387
|
onSuccess: onLoadingSuccess
|
|
311
|
-
}))))
|
|
388
|
+
})))), !enableDialogElement && /*#__PURE__*/React__default.createElement("span", {
|
|
389
|
+
ref: endTrap,
|
|
390
|
+
tabIndex: 0,
|
|
391
|
+
role: "link",
|
|
392
|
+
className: `${prefix}--visually-hidden`
|
|
393
|
+
}, "Focus sentinel"));
|
|
312
394
|
return /*#__PURE__*/React__default.createElement(Layer, _extends({}, rest, {
|
|
313
395
|
level: 0,
|
|
314
396
|
onKeyDown: handleKeyDown,
|
|
315
397
|
onClick: composeEventHandlers([rest?.onClick, handleOnClick]),
|
|
316
|
-
onBlur: !
|
|
398
|
+
onBlur: !enableDialogElement ? handleBlur : () => {},
|
|
317
399
|
className: modalClasses,
|
|
318
400
|
role: "presentation",
|
|
319
401
|
ref: ref
|
|
320
|
-
}),
|
|
321
|
-
ref: startTrap,
|
|
322
|
-
tabIndex: 0,
|
|
323
|
-
role: "link",
|
|
324
|
-
className: `${prefix}--visually-hidden`
|
|
325
|
-
}, "Focus sentinel"), modalBody, !focusTrapWithoutSentinels && /*#__PURE__*/React__default.createElement("span", {
|
|
326
|
-
ref: endTrap,
|
|
327
|
-
tabIndex: 0,
|
|
328
|
-
role: "link",
|
|
329
|
-
className: `${prefix}--visually-hidden`
|
|
330
|
-
}, "Focus sentinel"));
|
|
402
|
+
}), modalBody);
|
|
331
403
|
});
|
|
332
404
|
Modal.propTypes = {
|
|
333
405
|
/**
|
|
@@ -13,8 +13,8 @@ import Button, { ButtonKinds } from '../Button/Button.js';
|
|
|
13
13
|
import '../Button/Button.Skeleton.js';
|
|
14
14
|
import { warning } from '../../internal/warning.js';
|
|
15
15
|
import { noopFn } from '../../internal/noopFn.js';
|
|
16
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
17
16
|
import { Escape } from '../../internal/keyboard/keys.js';
|
|
17
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
18
18
|
|
|
19
19
|
let didWarnAboutDeprecation = false;
|
|
20
20
|
class ModalWrapper extends React__default.Component {
|
|
@@ -17,6 +17,8 @@ import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
|
17
17
|
import ListBox from '../ListBox/index.js';
|
|
18
18
|
import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
|
|
19
19
|
import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
20
|
+
import { Escape, Space, Enter, Delete, Tab, Home, End } from '../../internal/keyboard/keys.js';
|
|
21
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
20
22
|
import { defaultItemToString } from './tools/itemToString.js';
|
|
21
23
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
22
24
|
import deprecate from '../../prop-types/deprecate.js';
|
|
@@ -27,9 +29,7 @@ import '../FluidForm/FluidForm.js';
|
|
|
27
29
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
28
30
|
import { useSelection } from '../../internal/Selection.js';
|
|
29
31
|
import { useFloating, flip, size, hide, autoUpdate } from '@floating-ui/react';
|
|
30
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
31
32
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
32
|
-
import { Escape, Space, Enter, Delete, Tab, Home, End } from '../../internal/keyboard/keys.js';
|
|
33
33
|
|
|
34
34
|
const {
|
|
35
35
|
InputBlur,
|
|
@@ -414,7 +414,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
414
414
|
});
|
|
415
415
|
function clearInputValue(event) {
|
|
416
416
|
const value = textInput.current?.value;
|
|
417
|
-
if (value?.length === 1 || event && match(event, Escape)) {
|
|
417
|
+
if (value?.length === 1 || event && 'key' in event && match(event, Escape)) {
|
|
418
418
|
setInputValue('');
|
|
419
419
|
} else {
|
|
420
420
|
setInputValue(value ?? '');
|
|
@@ -19,6 +19,8 @@ import { useSelection } from '../../internal/Selection.js';
|
|
|
19
19
|
import { useId } from '../../internal/useId.js';
|
|
20
20
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
21
21
|
import deprecate from '../../prop-types/deprecate.js';
|
|
22
|
+
import { Delete, Escape, Space, ArrowDown, Enter } from '../../internal/keyboard/keys.js';
|
|
23
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
22
24
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
23
25
|
import '../FluidForm/FluidForm.js';
|
|
24
26
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
@@ -27,9 +29,7 @@ import '../Checkbox/Checkbox.Skeleton.js';
|
|
|
27
29
|
import { noopFn } from '../../internal/noopFn.js';
|
|
28
30
|
import { useFloating, flip, size, hide, autoUpdate } from '@floating-ui/react';
|
|
29
31
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
30
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
31
32
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
32
|
-
import { Delete, Escape, Space, ArrowDown, Enter } from '../../internal/keyboard/keys.js';
|
|
33
33
|
|
|
34
34
|
const {
|
|
35
35
|
ItemClick,
|
|
@@ -5,16 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { deprecateFieldOnObject } from '../../internal/deprecateFieldOnObject.js';
|
|
9
8
|
import MultiSelect from './MultiSelect.js';
|
|
10
9
|
export { default as MultiSelect, default } from './MultiSelect.js';
|
|
11
10
|
import FilterableMultiSelect from './FilterableMultiSelect.js';
|
|
12
11
|
export { default as FilterableMultiSelect } from './FilterableMultiSelect.js';
|
|
13
12
|
|
|
14
|
-
FilterableMultiSelect.displayName = '
|
|
15
|
-
// @ts-expect-error: The attribute indeed does not exist on the object,
|
|
16
|
-
// but since it is already deprecated, we do not have to fix it.
|
|
17
|
-
MultiSelect.Filterable = FilterableMultiSelect;
|
|
18
|
-
if (process.env.NODE_ENV !== "production") {
|
|
19
|
-
deprecateFieldOnObject(MultiSelect, 'Filterable', FilterableMultiSelect);
|
|
20
|
-
}
|
|
13
|
+
FilterableMultiSelect.displayName = 'FilterableMultiSelect';
|
|
@@ -1,11 +1,11 @@
|
|
|
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.
|
|
6
6
|
*/
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { type ReactNode, type MouseEvent, type
|
|
8
|
+
import React, { type ReactNode, type MouseEvent, type ButtonHTMLAttributes, type HTMLAttributes } from 'react';
|
|
9
9
|
import { type ButtonProps } from '../Button';
|
|
10
10
|
export interface NotificationActionButtonProps extends ButtonProps<'button'> {
|
|
11
11
|
/**
|
|
@@ -71,16 +71,9 @@ export interface NotificationButtonProps extends ButtonHTMLAttributes<HTMLButton
|
|
|
71
71
|
*/
|
|
72
72
|
notificationType?: 'toast' | 'inline' | 'actionable';
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* Can be a React component class
|
|
74
|
+
* A component used to render an icon.
|
|
76
75
|
*/
|
|
77
|
-
renderIcon?:
|
|
78
|
-
className?: string;
|
|
79
|
-
name?: string;
|
|
80
|
-
}> | FunctionComponent<{
|
|
81
|
-
className?: string;
|
|
82
|
-
name?: string;
|
|
83
|
-
}>;
|
|
76
|
+
renderIcon?: React.ElementType;
|
|
84
77
|
}
|
|
85
78
|
export declare function NotificationButton({ 'aria-label': ariaLabel, ariaLabel: deprecatedAriaLabel, className, type, renderIcon: IconTag, name, notificationType, ...rest }: NotificationButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
86
79
|
export declare namespace NotificationButton {
|
|
@@ -108,8 +101,7 @@ export declare namespace NotificationButton {
|
|
|
108
101
|
*/
|
|
109
102
|
notificationType: PropTypes.Requireable<string>;
|
|
110
103
|
/**
|
|
111
|
-
*
|
|
112
|
-
* Can be a React component class
|
|
104
|
+
* A component used to render an icon.
|
|
113
105
|
*/
|
|
114
106
|
renderIcon: PropTypes.Requireable<object>;
|
|
115
107
|
/**
|
|
@@ -16,6 +16,8 @@ import Button from '../Button/Button.js';
|
|
|
16
16
|
import '../Button/Button.Skeleton.js';
|
|
17
17
|
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
18
18
|
import { useNoInteractiveChildren, useInteractiveChildrenNeedDescription } from '../../internal/useNoInteractiveChildren.js';
|
|
19
|
+
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
20
|
+
import { match, matches } from '../../internal/keyboard/match.js';
|
|
19
21
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
20
22
|
import { useId } from '../../internal/useId.js';
|
|
21
23
|
import { noopFn } from '../../internal/noopFn.js';
|
|
@@ -23,9 +25,7 @@ import wrapFocus, { wrapFocusWithoutSentinels } from '../../internal/wrapFocus.j
|
|
|
23
25
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
24
26
|
import { warning } from '../../internal/warning.js';
|
|
25
27
|
import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
|
|
26
|
-
import { match, matches } from '../../internal/keyboard/match.js';
|
|
27
28
|
import { Text } from '../Text/Text.js';
|
|
28
|
-
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* Conditionally call a callback when the escape key is pressed
|
|
@@ -145,8 +145,7 @@ NotificationButton.propTypes = {
|
|
|
145
145
|
*/
|
|
146
146
|
notificationType: PropTypes.oneOf(['toast', 'inline', 'actionable']),
|
|
147
147
|
/**
|
|
148
|
-
*
|
|
149
|
-
* Can be a React component class
|
|
148
|
+
* A component used to render an icon.
|
|
150
149
|
*/
|
|
151
150
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
152
151
|
/**
|