@carbon/react 1.100.0-rc.0 → 1.101.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +933 -933
- package/es/components/AILabel/index.d.ts +1 -1
- package/es/components/AILabel/index.js +1 -12
- package/es/components/Checkbox/Checkbox.js +5 -3
- package/es/components/CheckboxGroup/CheckboxGroup.js +4 -3
- package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.d.ts +3 -4
- package/es/components/ComboBox/ComboBox.js +20 -18
- package/es/components/ComboButton/index.d.ts +1 -1
- package/es/components/ComboButton/index.js +3 -2
- package/es/components/ComposedModal/ComposedModal.js +17 -22
- package/es/components/ComposedModal/ModalHeader.d.ts +2 -2
- package/es/components/ComposedModal/ModalHeader.js +1 -1
- package/es/components/Copy/Copy.d.ts +1 -1
- package/es/components/CopyButton/CopyButton.d.ts +1 -1
- package/es/components/DataTable/DataTable.d.ts +2 -0
- package/es/components/DataTable/DataTable.js +6 -5
- package/es/components/DataTable/Table.d.ts +1 -1
- package/es/components/DataTable/Table.js +10 -4
- package/es/components/DataTable/state/sorting.d.ts +4 -2
- package/es/components/Dropdown/Dropdown.d.ts +3 -4
- package/es/components/Dropdown/Dropdown.js +16 -13
- package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +3 -2
- package/es/components/FluidComboBox/FluidComboBox.d.ts +2 -7
- package/es/components/FluidComboBox/FluidComboBox.js +1 -2
- package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -6
- package/es/components/FluidDropdown/FluidDropdown.js +1 -2
- package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +1 -6
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +1 -2
- package/es/components/InlineLoading/InlineLoading.js +5 -11
- package/es/components/Menu/Menu.js +8 -4
- package/es/components/Menu/MenuItem.d.ts +5 -1
- package/es/components/Menu/MenuItem.js +11 -1
- package/es/components/MenuButton/index.d.ts +1 -1
- package/es/components/MenuButton/index.js +3 -2
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +7 -5
- package/es/components/MultiSelect/MultiSelect.d.ts +3 -4
- package/es/components/MultiSelect/MultiSelect.js +10 -13
- package/es/components/Notification/Notification.js +5 -3
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +5 -4
- package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -0
- package/es/components/OverflowMenu/OverflowMenu.js +8 -4
- package/es/components/PageHeader/PageHeader.d.ts +1 -1
- package/es/components/PageHeader/PageHeader.js +5 -5
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +4 -3
- package/es/components/Select/Select.js +2 -1
- package/es/components/StructuredList/StructuredList.d.ts +1 -1
- package/es/components/StructuredList/StructuredList.js +2 -4
- package/es/components/Tabs/Tabs.d.ts +2 -2
- package/es/components/Tabs/Tabs.js +20 -26
- package/es/components/Tag/DismissibleTag.js +3 -2
- package/es/components/Tag/OperationalTag.js +3 -2
- package/es/components/Tag/SelectableTag.js +3 -2
- package/es/components/Tag/Tag.js +3 -2
- package/es/components/TextArea/TextArea.d.ts +1 -1
- package/es/components/TextArea/TextArea.js +7 -8
- package/es/components/TextInput/ControlledPasswordInput.js +7 -6
- package/es/components/TextInput/PasswordInput.js +5 -6
- package/es/components/TextInput/TextInput.js +4 -4
- package/es/components/Tile/Tile.d.ts +1 -1
- package/es/components/Tile/Tile.js +37 -69
- package/es/components/TimePicker/TimePicker.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.d.ts +1 -1
- package/es/components/Tooltip/DefinitionTooltip.js +3 -2
- package/es/components/UIShell/SideNav.d.ts +0 -1
- package/es/components/UIShell/SideNav.js +12 -3
- package/es/internal/useId.js +3 -4
- package/es/internal/usePresence.js +3 -2
- package/es/internal/useResizeObserver.d.ts +1 -1
- package/es/internal/useResizeObserver.js +5 -7
- package/es/tools/events.d.ts +1 -1
- package/lib/components/AILabel/index.d.ts +1 -1
- package/lib/components/AILabel/index.js +1 -12
- package/lib/components/Checkbox/Checkbox.js +5 -3
- package/lib/components/CheckboxGroup/CheckboxGroup.js +4 -3
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.d.ts +3 -4
- package/lib/components/ComboBox/ComboBox.js +20 -18
- package/lib/components/ComboButton/index.d.ts +1 -1
- package/lib/components/ComboButton/index.js +2 -1
- package/lib/components/ComposedModal/ComposedModal.js +16 -21
- package/lib/components/ComposedModal/ModalHeader.d.ts +2 -2
- package/lib/components/ComposedModal/ModalHeader.js +1 -1
- package/lib/components/Copy/Copy.d.ts +1 -1
- package/lib/components/CopyButton/CopyButton.d.ts +1 -1
- package/lib/components/DataTable/DataTable.d.ts +2 -0
- package/lib/components/DataTable/DataTable.js +6 -5
- package/lib/components/DataTable/Table.d.ts +1 -1
- package/lib/components/DataTable/Table.js +10 -4
- package/lib/components/DataTable/state/sorting.d.ts +4 -2
- package/lib/components/Dropdown/Dropdown.d.ts +3 -4
- package/lib/components/Dropdown/Dropdown.js +16 -13
- package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +2 -1
- package/lib/components/FluidComboBox/FluidComboBox.d.ts +2 -7
- package/lib/components/FluidComboBox/FluidComboBox.js +1 -2
- package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -6
- package/lib/components/FluidDropdown/FluidDropdown.js +1 -2
- package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +1 -6
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +1 -2
- package/lib/components/InlineLoading/InlineLoading.js +5 -11
- package/lib/components/Menu/Menu.js +7 -3
- package/lib/components/Menu/MenuItem.d.ts +5 -1
- package/lib/components/Menu/MenuItem.js +11 -1
- package/lib/components/MenuButton/index.d.ts +1 -1
- package/lib/components/MenuButton/index.js +2 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +6 -4
- package/lib/components/MultiSelect/MultiSelect.d.ts +3 -4
- package/lib/components/MultiSelect/MultiSelect.js +9 -12
- package/lib/components/Notification/Notification.js +5 -3
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +5 -4
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -0
- package/lib/components/OverflowMenu/OverflowMenu.js +7 -3
- package/lib/components/PageHeader/PageHeader.d.ts +1 -1
- package/lib/components/PageHeader/PageHeader.js +4 -4
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +4 -3
- package/lib/components/Select/Select.js +2 -1
- package/lib/components/StructuredList/StructuredList.d.ts +1 -1
- package/lib/components/StructuredList/StructuredList.js +2 -4
- package/lib/components/Tabs/Tabs.d.ts +2 -2
- package/lib/components/Tabs/Tabs.js +15 -21
- package/lib/components/Tag/DismissibleTag.js +2 -1
- package/lib/components/Tag/OperationalTag.js +2 -1
- package/lib/components/Tag/SelectableTag.js +2 -1
- package/lib/components/Tag/Tag.js +2 -1
- package/lib/components/TextArea/TextArea.d.ts +1 -1
- package/lib/components/TextArea/TextArea.js +7 -8
- package/lib/components/TextInput/ControlledPasswordInput.js +7 -6
- package/lib/components/TextInput/PasswordInput.js +5 -6
- package/lib/components/TextInput/TextInput.js +4 -4
- package/lib/components/Tile/Tile.d.ts +1 -1
- package/lib/components/Tile/Tile.js +35 -67
- package/lib/components/TimePicker/TimePicker.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +1 -1
- package/lib/components/Tooltip/DefinitionTooltip.js +3 -2
- package/lib/components/UIShell/SideNav.d.ts +0 -1
- package/lib/components/UIShell/SideNav.js +11 -2
- package/lib/internal/useId.js +2 -3
- package/lib/internal/usePresence.js +2 -1
- package/lib/internal/useResizeObserver.d.ts +1 -1
- package/lib/internal/useResizeObserver.js +4 -6
- package/lib/tools/events.d.ts +1 -1
- package/package.json +8 -8
|
@@ -256,9 +256,6 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
256
256
|
[`${prefix}--list-box__wrapper--slug`]: slug,
|
|
257
257
|
[`${prefix}--list-box__wrapper--decorator`]: decorator
|
|
258
258
|
});
|
|
259
|
-
|
|
260
|
-
// needs to be Capitalized for react to render it correctly
|
|
261
|
-
const ItemToElement = itemToElement;
|
|
262
259
|
const toggleButtonProps = getToggleButtonProps({
|
|
263
260
|
'aria-label': ariaLabel || deprecatedAriaLabel
|
|
264
261
|
});
|
|
@@ -274,10 +271,20 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
274
271
|
const [currTimer, setCurrTimer] = React.useState();
|
|
275
272
|
const [isTyping, setIsTyping] = React.useState(false);
|
|
276
273
|
const onKeyDownHandler = React.useCallback(evt => {
|
|
277
|
-
|
|
274
|
+
const navigationKeys = ['ArrowDown', 'ArrowUp', ' ', 'Enter'];
|
|
275
|
+
|
|
276
|
+
// If the key is not a navigation key, the user is typing
|
|
277
|
+
if (!navigationKeys.includes(evt.key)) {
|
|
278
278
|
setIsTyping(true);
|
|
279
|
-
|
|
280
|
-
|
|
279
|
+
// Reset the timer for typing timeout
|
|
280
|
+
if (currTimer) {
|
|
281
|
+
clearTimeout(currTimer);
|
|
282
|
+
}
|
|
283
|
+
setCurrTimer(setTimeout(() => {
|
|
284
|
+
setIsTyping(false);
|
|
285
|
+
}, 3000));
|
|
286
|
+
} else if (isTyping && evt.key === ' ') {
|
|
287
|
+
// If user is typing and presses space, reset the timer
|
|
281
288
|
if (currTimer) {
|
|
282
289
|
clearTimeout(currTimer);
|
|
283
290
|
}
|
|
@@ -381,21 +388,18 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
381
388
|
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
382
389
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
383
390
|
}, normalizedDecorator) : '', /*#__PURE__*/React.createElement(index$2.default.Menu, menuProps, isOpen && items.map((item, index) => {
|
|
384
|
-
const isObject = item !== null && typeof item === 'object';
|
|
385
391
|
const itemProps = getItemProps({
|
|
386
392
|
item,
|
|
387
393
|
index
|
|
388
394
|
});
|
|
389
|
-
const title =
|
|
395
|
+
const title = itemToString(item);
|
|
390
396
|
return /*#__PURE__*/React.createElement(index$2.default.MenuItem, _rollupPluginBabelHelpers.extends({
|
|
391
397
|
key: itemProps.id,
|
|
392
398
|
isActive: selectedItem === item,
|
|
393
399
|
isHighlighted: highlightedIndex === index,
|
|
394
400
|
title: title,
|
|
395
401
|
disabled: itemProps['aria-disabled']
|
|
396
|
-
}, itemProps),
|
|
397
|
-
key: itemProps.id
|
|
398
|
-
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React.createElement(iconsReact.Checkmark, {
|
|
402
|
+
}, itemProps), itemToElement ? itemToElement(item) : itemToString(item), selectedItem === item && /*#__PURE__*/React.createElement(iconsReact.Checkmark, {
|
|
399
403
|
className: `${prefix}--list-box__menu-item__selected-icon`
|
|
400
404
|
}));
|
|
401
405
|
}))), !inline && !isFluid && !normalizedProps.validation && helper, !inline && !isFluid && normalizedProps.validation);
|
|
@@ -475,8 +479,7 @@ Dropdown.propTypes = {
|
|
|
475
479
|
*/
|
|
476
480
|
invalidText: PropTypes.node,
|
|
477
481
|
/**
|
|
478
|
-
*
|
|
479
|
-
* Defaults to null and is overridden by a getter
|
|
482
|
+
* Renders an item as a custom React node instead of a string.
|
|
480
483
|
*/
|
|
481
484
|
itemToElement: PropTypes.func,
|
|
482
485
|
/**
|
|
@@ -19,6 +19,7 @@ var match = require('../../internal/keyboard/match.js');
|
|
|
19
19
|
var useId = require('../../internal/useId.js');
|
|
20
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
21
21
|
var noopFn = require('../../internal/noopFn.js');
|
|
22
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
22
23
|
var Text = require('../Text/Text.js');
|
|
23
24
|
require('../Text/TextDirection.js');
|
|
24
25
|
require('../Tooltip/DefinitionTooltip.js');
|
|
@@ -62,7 +63,7 @@ function FileUploaderItem({
|
|
|
62
63
|
setIsEllipsisApplied(isActive);
|
|
63
64
|
return isActive;
|
|
64
65
|
};
|
|
65
|
-
|
|
66
|
+
useIsomorphicEffect.default(() => {
|
|
66
67
|
isEllipsisActive(textRef.current);
|
|
67
68
|
}, [prefix, name]);
|
|
68
69
|
return /*#__PURE__*/React.createElement("span", _rollupPluginBabelHelpers.extends({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2022,
|
|
2
|
+
* Copyright IBM Corp. 2022, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, {
|
|
7
|
+
import React, { type ComponentProps } from 'react';
|
|
8
8
|
import ComboBox from '../ComboBox';
|
|
9
9
|
import { ComboBoxProps } from '../ComboBox/ComboBox';
|
|
10
10
|
type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
|
|
@@ -46,11 +46,6 @@ export interface FluidComboBoxProps<ItemType> extends ComboBoxProps<ItemType>, P
|
|
|
46
46
|
* Specify if the `FluidComboBox` should render its menu items in condensed mode
|
|
47
47
|
*/
|
|
48
48
|
isCondensed?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Function to render items as custom components instead of strings.
|
|
51
|
-
* Defaults to null and is overridden by a getter
|
|
52
|
-
*/
|
|
53
|
-
itemToElement?: ComponentType<ItemType> | null;
|
|
54
49
|
/**
|
|
55
50
|
* Helper function passed to downshift that allows the library to render a
|
|
56
51
|
* given item to a string label. By default, it extracts the `label` field
|
|
@@ -70,8 +70,7 @@ FluidComboBox.propTypes = {
|
|
|
70
70
|
*/
|
|
71
71
|
isCondensed: PropTypes.bool,
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
74
|
-
* Defaults to null and is overridden by a getter
|
|
73
|
+
* Renders an item as a custom React node instead of a string.
|
|
75
74
|
*/
|
|
76
75
|
itemToElement: PropTypes.func,
|
|
77
76
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2022,
|
|
2
|
+
* Copyright IBM Corp. 2022, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -43,11 +43,6 @@ export interface FluidDropdownProps<ItemType> extends DropdownProps<ItemType>, P
|
|
|
43
43
|
* Specify if the `FluidDropdown` should render its menu items in condensed mode
|
|
44
44
|
*/
|
|
45
45
|
isCondensed?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Function to render items as custom components instead of strings.
|
|
48
|
-
* Defaults to null and is overridden by a getter
|
|
49
|
-
*/
|
|
50
|
-
itemToElement?: React.JSXElementConstructor<ItemType> | null;
|
|
51
46
|
/**
|
|
52
47
|
* Helper function passed to downshift that allows the library to render a
|
|
53
48
|
* given item to a string label. By default, it extracts the `label` field
|
|
@@ -71,8 +71,7 @@ FluidDropdown.propTypes = {
|
|
|
71
71
|
*/
|
|
72
72
|
isCondensed: PropTypes.bool,
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
75
|
-
* Defaults to null and is overridden by a getter
|
|
74
|
+
* Renders an item as a custom React node instead of a string.
|
|
76
75
|
*/
|
|
77
76
|
itemToElement: PropTypes.func,
|
|
78
77
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2022,
|
|
2
|
+
* Copyright IBM Corp. 2022, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -66,11 +66,6 @@ export interface FluidMultiSelectProps<ItemType> extends MultiSelectProps<ItemTy
|
|
|
66
66
|
* @deprecated This prop is deprecated in favor of new component called FluidFilterableMultiSelect and will be removed in the next major release
|
|
67
67
|
*/
|
|
68
68
|
isFilterable?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Function to render items as custom components instead of strings.
|
|
71
|
-
* Defaults to null and is overridden by a getter
|
|
72
|
-
*/
|
|
73
|
-
itemToElement?: React.JSXElementConstructor<ItemType>;
|
|
74
69
|
/**
|
|
75
70
|
* Helper function passed to downshift that allows the library to render a
|
|
76
71
|
* given item to a string label. By default, it extracts the `label` field
|
|
@@ -110,8 +110,7 @@ FluidMultiSelect.propTypes = {
|
|
|
110
110
|
*/
|
|
111
111
|
isFilterable: PropTypes.bool,
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
114
|
-
* Defaults to null and is overridden by a getter
|
|
113
|
+
* Renders an item as a custom React node instead of a string.
|
|
115
114
|
*/
|
|
116
115
|
itemToElement: PropTypes.func,
|
|
117
116
|
/**
|
|
@@ -56,7 +56,10 @@ const InlineLoading = ({
|
|
|
56
56
|
className: `${prefix}--inline-loading__checkmark-container`
|
|
57
57
|
}, /*#__PURE__*/React.createElement("title", null, iconLabel));
|
|
58
58
|
}
|
|
59
|
-
if (status === 'active') {
|
|
59
|
+
if (status === 'inactive' || status === 'active') {
|
|
60
|
+
if (status === 'inactive') {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
60
63
|
if (!iconDescription) {
|
|
61
64
|
iconLabel = 'loading';
|
|
62
65
|
}
|
|
@@ -67,15 +70,6 @@ const InlineLoading = ({
|
|
|
67
70
|
active: status === 'active'
|
|
68
71
|
});
|
|
69
72
|
}
|
|
70
|
-
if (status === 'inactive') {
|
|
71
|
-
if (!iconDescription) {
|
|
72
|
-
iconLabel = 'not loading';
|
|
73
|
-
}
|
|
74
|
-
return /*#__PURE__*/React.createElement("title", {
|
|
75
|
-
className: `${prefix}--inline-loading__inactive-status`
|
|
76
|
-
}, iconLabel);
|
|
77
|
-
}
|
|
78
|
-
return undefined;
|
|
79
73
|
};
|
|
80
74
|
const loadingText = description && /*#__PURE__*/React.createElement("div", {
|
|
81
75
|
className: `${prefix}--inline-loading__text`
|
|
@@ -87,7 +81,7 @@ const InlineLoading = ({
|
|
|
87
81
|
return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({
|
|
88
82
|
className: loadingClasses
|
|
89
83
|
}, rest, {
|
|
90
|
-
"aria-live": rest['aria-live'] ?? 'assertive'
|
|
84
|
+
"aria-live": rest['aria-live'] ?? (status === 'inactive' ? 'off' : 'assertive')
|
|
91
85
|
}), loadingAnimation, loadingText);
|
|
92
86
|
};
|
|
93
87
|
InlineLoading.propTypes = {
|
|
@@ -50,6 +50,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
50
50
|
const [childState, childDispatch] = React.useReducer(MenuContext.menuReducer, {
|
|
51
51
|
...context.state,
|
|
52
52
|
isRoot: false,
|
|
53
|
+
hasIcons: false,
|
|
54
|
+
hasSelectableItems: false,
|
|
53
55
|
size,
|
|
54
56
|
requestCloseRoot: isRoot ? handleClose : context.state.requestCloseRoot
|
|
55
57
|
});
|
|
@@ -112,9 +114,9 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
112
114
|
function handleKeyDown(e) {
|
|
113
115
|
e.stopPropagation();
|
|
114
116
|
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
// If the user presses escape or tab, or this is a submenu and the user presses ArrowLeft, close it.
|
|
118
|
+
if ((match.match(e, keys.Escape) || match.match(e, keys.Tab) || !isRoot && match.match(e, keys.ArrowLeft)) && onClose) {
|
|
119
|
+
e.preventDefault();
|
|
118
120
|
handleClose();
|
|
119
121
|
} else {
|
|
120
122
|
focusItem(e);
|
|
@@ -248,6 +250,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
248
250
|
}
|
|
249
251
|
return [fitValue(ranges.x, 'x') ?? -1, fitValue(ranges.y, 'y') ?? -1];
|
|
250
252
|
}
|
|
253
|
+
|
|
254
|
+
// When a menu is opened, focus the first item.
|
|
251
255
|
React.useEffect(() => {
|
|
252
256
|
if (open) {
|
|
253
257
|
const raf = requestAnimationFrame(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2023,
|
|
2
|
+
* Copyright IBM Corp. 2023, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -14,6 +14,10 @@ export interface MenuItemProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
|
14
14
|
* Additional CSS class names.
|
|
15
15
|
*/
|
|
16
16
|
className?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Specify the message read by screen readers for the danger menu item variant
|
|
19
|
+
*/
|
|
20
|
+
dangerDescription?: string;
|
|
17
21
|
/**
|
|
18
22
|
* Specify whether the MenuItem is disabled or not.
|
|
19
23
|
*/
|
|
@@ -18,6 +18,7 @@ var match = require('../../internal/keyboard/match.js');
|
|
|
18
18
|
var useControllableState = require('../../internal/useControllableState.js');
|
|
19
19
|
var useMergedRefs = require('../../internal/useMergedRefs.js');
|
|
20
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
21
|
+
var useId = require('../../internal/useId.js');
|
|
21
22
|
var Menu = require('./Menu.js');
|
|
22
23
|
var MenuContext = require('./MenuContext.js');
|
|
23
24
|
require('../LayoutDirection/LayoutDirection.js');
|
|
@@ -30,6 +31,7 @@ var _Checkmark, _CaretLeft, _CaretRight;
|
|
|
30
31
|
const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem({
|
|
31
32
|
children,
|
|
32
33
|
className,
|
|
34
|
+
dangerDescription = 'danger',
|
|
33
35
|
disabled,
|
|
34
36
|
kind = 'default',
|
|
35
37
|
label,
|
|
@@ -166,6 +168,7 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem({
|
|
|
166
168
|
}
|
|
167
169
|
});
|
|
168
170
|
}, [floatingStyles, refs.floating]);
|
|
171
|
+
const assistiveId = useId.useId('danger-description');
|
|
169
172
|
return /*#__PURE__*/React.createElement(react.FloatingFocusManager, {
|
|
170
173
|
context: floatingContext,
|
|
171
174
|
order: ['reference', 'floating'],
|
|
@@ -190,7 +193,10 @@ const MenuItem = /*#__PURE__*/React.forwardRef(function MenuItem({
|
|
|
190
193
|
}, IconElement && /*#__PURE__*/React.createElement(IconElement, null)), /*#__PURE__*/React.createElement(Text.Text, {
|
|
191
194
|
as: "div",
|
|
192
195
|
className: `${prefix}--menu-item__label`
|
|
193
|
-
}, label),
|
|
196
|
+
}, label), isDanger && /*#__PURE__*/React.createElement("span", {
|
|
197
|
+
id: assistiveId,
|
|
198
|
+
className: `${prefix}--visually-hidden`
|
|
199
|
+
}, dangerDescription), shortcut && !hasChildren && /*#__PURE__*/React.createElement("div", {
|
|
194
200
|
className: `${prefix}--menu-item__shortcut`
|
|
195
201
|
}, shortcut), hasChildren && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
196
202
|
className: `${prefix}--menu-item__shortcut`
|
|
@@ -213,6 +219,10 @@ MenuItem.propTypes = {
|
|
|
213
219
|
* Additional CSS class names.
|
|
214
220
|
*/
|
|
215
221
|
className: PropTypes.string,
|
|
222
|
+
/**
|
|
223
|
+
* Specify the message read by screen readers for the danger menu item variant
|
|
224
|
+
*/
|
|
225
|
+
dangerDescription: PropTypes.string,
|
|
216
226
|
/**
|
|
217
227
|
* Specify whether the MenuItem is disabled or not.
|
|
218
228
|
*/
|
|
@@ -19,6 +19,7 @@ require('../Menu/MenuItem.js');
|
|
|
19
19
|
var useAttachedMenu = require('../../internal/useAttachedMenu.js');
|
|
20
20
|
var useId = require('../../internal/useId.js');
|
|
21
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
22
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
22
23
|
var react = require('@floating-ui/react');
|
|
23
24
|
var index = require('../FeatureFlags/index.js');
|
|
24
25
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
@@ -97,7 +98,7 @@ const MenuButton = /*#__PURE__*/React.forwardRef(({
|
|
|
97
98
|
handleMousedown,
|
|
98
99
|
handleClose
|
|
99
100
|
} = useAttachedMenu.useAttachedMenu(triggerRef);
|
|
100
|
-
|
|
101
|
+
useIsomorphicEffect.default(() => {
|
|
101
102
|
Object.keys(floatingStyles).forEach(style => {
|
|
102
103
|
if (refs.floating.current) {
|
|
103
104
|
let value = floatingStyles[style];
|
|
@@ -36,6 +36,7 @@ var index = require('../AILabel/index.js');
|
|
|
36
36
|
var defaultItemToString = require('../../internal/defaultItemToString.js');
|
|
37
37
|
var utils = require('../../internal/utils.js');
|
|
38
38
|
var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
|
|
39
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
39
40
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
40
41
|
|
|
41
42
|
const {
|
|
@@ -191,7 +192,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
191
192
|
}), react.hide()],
|
|
192
193
|
whileElementsMounted: react.autoUpdate
|
|
193
194
|
} : {});
|
|
194
|
-
|
|
195
|
+
useIsomorphicEffect.default(() => {
|
|
195
196
|
if (autoAlign) {
|
|
196
197
|
const updatedFloatingStyles = {
|
|
197
198
|
...floatingStyles,
|
|
@@ -261,7 +262,8 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
261
262
|
[`${prefix}--list-box__wrapper--decorator`]: decorator,
|
|
262
263
|
[`${prefix}--autoalign`]: autoAlign
|
|
263
264
|
});
|
|
264
|
-
const
|
|
265
|
+
const hasHelper = typeof helperText !== 'undefined' && helperText !== null;
|
|
266
|
+
const helperId = !hasHelper ? undefined : `filterablemultiselect-helper-text-${filterableMultiSelectInstanceId}`;
|
|
265
267
|
const labelId = `${id}-label`;
|
|
266
268
|
const titleClasses = cx({
|
|
267
269
|
[`${prefix}--label`]: true,
|
|
@@ -277,10 +279,10 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
277
279
|
[`${prefix}--text-input--empty`]: !inputValue,
|
|
278
280
|
[`${prefix}--text-input--light`]: light
|
|
279
281
|
});
|
|
280
|
-
const helper =
|
|
282
|
+
const helper = hasHelper && /*#__PURE__*/React.createElement("div", {
|
|
281
283
|
id: helperId,
|
|
282
284
|
className: helperClasses
|
|
283
|
-
}, helperText)
|
|
285
|
+
}, helperText);
|
|
284
286
|
const menuId = `${id}__menu`;
|
|
285
287
|
const inputId = `${id}-input`;
|
|
286
288
|
React.useEffect(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2026
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -82,10 +82,9 @@ export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<Item
|
|
|
82
82
|
*/
|
|
83
83
|
invalidText?: ReactNode;
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
86
|
-
* Defaults to null and is overridden by a getter
|
|
85
|
+
* Renders an item as a custom React node instead of a string.
|
|
87
86
|
*/
|
|
88
|
-
itemToElement?:
|
|
87
|
+
itemToElement?: ((item: ItemType) => NonNullable<ReactNode>) | null;
|
|
89
88
|
/**
|
|
90
89
|
* Helper function passed to downshift that allows the library to render a
|
|
91
90
|
* given item to a string label. By default, it extracts the `label` field
|
|
@@ -35,6 +35,7 @@ var index$1 = require('../AILabel/index.js');
|
|
|
35
35
|
var defaultItemToString = require('../../internal/defaultItemToString.js');
|
|
36
36
|
var utils = require('../../internal/utils.js');
|
|
37
37
|
var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
|
|
38
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
38
39
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
39
40
|
|
|
40
41
|
const {
|
|
@@ -145,7 +146,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
145
146
|
}), autoAlign && react.hide()],
|
|
146
147
|
whileElementsMounted: react.autoUpdate
|
|
147
148
|
} : {});
|
|
148
|
-
|
|
149
|
+
useIsomorphicEffect.default(() => {
|
|
149
150
|
if (enableFloatingStyles) {
|
|
150
151
|
const updatedFloatingStyles = {
|
|
151
152
|
...floatingStyles,
|
|
@@ -296,10 +297,6 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
296
297
|
[`${prefix}--autoalign`]: enableFloatingStyles,
|
|
297
298
|
[`${prefix}--multi-select--selectall`]: selectAll
|
|
298
299
|
});
|
|
299
|
-
|
|
300
|
-
// needs to be capitalized for react to render it correctly
|
|
301
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
302
|
-
const ItemToElement = itemToElement;
|
|
303
300
|
if (selectionFeedback === 'fixed') {
|
|
304
301
|
sortOptions.selectedItems = [];
|
|
305
302
|
} else if (selectionFeedback === 'top-after-reopen') {
|
|
@@ -392,8 +389,11 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
392
389
|
[`${prefix}--list-box__field--wrapper--input-focused`]: inputFocused
|
|
393
390
|
});
|
|
394
391
|
const handleFocus = evt => {
|
|
395
|
-
|
|
396
|
-
|
|
392
|
+
if (evt.target.classList.contains(`${prefix}--tag__close-icon`)) {
|
|
393
|
+
setIsFocused(false);
|
|
394
|
+
} else {
|
|
395
|
+
setIsFocused(evt.type === 'focus' ? true : false);
|
|
396
|
+
}
|
|
397
397
|
};
|
|
398
398
|
const readOnlyEventHandlers = readOnly ? {
|
|
399
399
|
onClick: evt => {
|
|
@@ -528,9 +528,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
528
528
|
className: `${prefix}--checkbox-wrapper`
|
|
529
529
|
}, /*#__PURE__*/React.createElement(Checkbox.default, {
|
|
530
530
|
id: `${itemProps.id}__checkbox`,
|
|
531
|
-
labelText: itemToElement ?
|
|
532
|
-
key: itemProps.id
|
|
533
|
-
}, item)) : itemText,
|
|
531
|
+
labelText: itemToElement ? itemToElement(item) : itemText,
|
|
534
532
|
checked: isChecked,
|
|
535
533
|
title: useTitleInItem ? itemText : undefined,
|
|
536
534
|
indeterminate: isIndeterminate,
|
|
@@ -621,8 +619,7 @@ MultiSelect.propTypes = {
|
|
|
621
619
|
*/
|
|
622
620
|
invalidText: PropTypes.node,
|
|
623
621
|
/**
|
|
624
|
-
*
|
|
625
|
-
* Defaults to null and is overridden by a getter
|
|
622
|
+
* Renders an item as a custom React node instead of a string.
|
|
626
623
|
*/
|
|
627
624
|
itemToElement: PropTypes.func,
|
|
628
625
|
/**
|
|
@@ -574,6 +574,9 @@ function ActionableNotification({
|
|
|
574
574
|
role: "link",
|
|
575
575
|
className: `${prefix}--visually-hidden`
|
|
576
576
|
}, "Focus sentinel"), /*#__PURE__*/React.createElement("div", {
|
|
577
|
+
ref: innerModal,
|
|
578
|
+
className: `${prefix}--actionable-notification__focus-wrapper`
|
|
579
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
577
580
|
className: `${prefix}--actionable-notification__details`
|
|
578
581
|
}, /*#__PURE__*/React.createElement(NotificationIcon, {
|
|
579
582
|
notificationType: inline ? 'inline' : 'toast',
|
|
@@ -595,8 +598,7 @@ function ActionableNotification({
|
|
|
595
598
|
as: "div",
|
|
596
599
|
className: `${prefix}--actionable-notification__caption`
|
|
597
600
|
}, caption), children))), /*#__PURE__*/React.createElement("div", {
|
|
598
|
-
className: `${prefix}--actionable-notification__button-wrapper
|
|
599
|
-
ref: innerModal
|
|
601
|
+
className: `${prefix}--actionable-notification__button-wrapper`
|
|
600
602
|
}, actionButtonLabel && /*#__PURE__*/React.createElement(NotificationActionButton, {
|
|
601
603
|
onClick: onActionButtonClick,
|
|
602
604
|
inline: inline
|
|
@@ -604,7 +606,7 @@ function ActionableNotification({
|
|
|
604
606
|
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
605
607
|
notificationType: "actionable",
|
|
606
608
|
onClick: handleCloseButtonClick
|
|
607
|
-
})), !focusTrapWithoutSentinels && /*#__PURE__*/React.createElement("span", {
|
|
609
|
+
}))), !focusTrapWithoutSentinels && /*#__PURE__*/React.createElement("span", {
|
|
608
610
|
ref: endTrap,
|
|
609
611
|
tabIndex: 0,
|
|
610
612
|
role: "link",
|
|
@@ -566,10 +566,11 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
566
566
|
onKeyUp: onKeyUp,
|
|
567
567
|
onKeyDown: e => {
|
|
568
568
|
if (type === 'text') {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
569
|
+
if (match.match(e, keys.ArrowUp)) {
|
|
570
|
+
handleStep(e, 'up');
|
|
571
|
+
} else if (match.match(e, keys.ArrowDown)) {
|
|
572
|
+
handleStep(e, 'down');
|
|
573
|
+
}
|
|
573
574
|
}
|
|
574
575
|
if (rest?.onKeyDown) {
|
|
575
576
|
rest?.onKeyDown(e);
|
|
@@ -44,6 +44,7 @@ export interface OverflowMenuProps extends Omit<IconButtonProps, 'type' | 'aria-
|
|
|
44
44
|
*/
|
|
45
45
|
flipped?: boolean;
|
|
46
46
|
/**
|
|
47
|
+
* @deprecated Tab key is handled with event handler so no need for focus trap.
|
|
47
48
|
* Enable or disable focus trap behavior
|
|
48
49
|
*/
|
|
49
50
|
focusTrap?: boolean;
|
|
@@ -101,7 +101,7 @@ const OverflowMenu = /*#__PURE__*/React.forwardRef(({
|
|
|
101
101
|
className,
|
|
102
102
|
direction = FloatingMenu.DIRECTION_BOTTOM,
|
|
103
103
|
flipped = false,
|
|
104
|
-
focusTrap =
|
|
104
|
+
focusTrap = false,
|
|
105
105
|
iconClass,
|
|
106
106
|
iconDescription = 'Options',
|
|
107
107
|
id,
|
|
@@ -204,12 +204,15 @@ const OverflowMenu = /*#__PURE__*/React.forwardRef(({
|
|
|
204
204
|
evt.preventDefault();
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
// Close the overflow menu on escape
|
|
208
|
-
if (match.matches(evt, [keys.Escape])) {
|
|
207
|
+
// Close the overflow menu on escape or tab.
|
|
208
|
+
if (match.matches(evt, [keys.Escape, keys.Tab])) {
|
|
209
209
|
closeMenuOnEscape();
|
|
210
210
|
|
|
211
211
|
// Stop the esc keypress from bubbling out and closing something it shouldn't
|
|
212
212
|
evt.stopPropagation();
|
|
213
|
+
|
|
214
|
+
// Stop the tab key from making the browser focus somewhere else.
|
|
215
|
+
evt.preventDefault();
|
|
213
216
|
}
|
|
214
217
|
};
|
|
215
218
|
|
|
@@ -394,6 +397,7 @@ OverflowMenu.propTypes = {
|
|
|
394
397
|
*/
|
|
395
398
|
flipped: PropTypes.bool,
|
|
396
399
|
/**
|
|
400
|
+
* @deprecated Tab key is handled with event handler so no need for focus trap.
|
|
397
401
|
* Enable or disable focus trap behavior
|
|
398
402
|
*/
|
|
399
403
|
focusTrap: PropTypes.bool,
|
|
@@ -37,6 +37,7 @@ require('../Grid/Row.js');
|
|
|
37
37
|
var Column = require('../Grid/Column.js');
|
|
38
38
|
require('../Grid/ColumnHang.js');
|
|
39
39
|
require('../Grid/GridContext.js');
|
|
40
|
+
var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* ----------
|
|
@@ -132,9 +133,8 @@ const PageHeaderContent = /*#__PURE__*/React.forwardRef(({
|
|
|
132
133
|
setIsEllipsisApplied(element.offsetHeight < element.scrollHeight);
|
|
133
134
|
return element.offsetHeight < element.scrollHeight;
|
|
134
135
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
titleRef.current && isEllipsisActive(titleRef.current);
|
|
136
|
+
useIsomorphicEffect.default(() => {
|
|
137
|
+
if (titleRef.current) isEllipsisActive(titleRef.current);
|
|
138
138
|
}, [title]);
|
|
139
139
|
return /*#__PURE__*/React.createElement("div", _rollupPluginBabelHelpers.extends({
|
|
140
140
|
className: classNames,
|
|
@@ -222,7 +222,7 @@ const PageHeaderContentPageActions = ({
|
|
|
222
222
|
|
|
223
223
|
// need to set the grid columns width based on the menu button's width
|
|
224
224
|
// to avoid overlapping when resizing
|
|
225
|
-
|
|
225
|
+
useIsomorphicEffect.default(() => {
|
|
226
226
|
if (menuButtonVisibility && offsetRef.current) {
|
|
227
227
|
const width = offsetRef.current.offsetWidth;
|
|
228
228
|
document.documentElement.style.setProperty('--pageheader-title-grid-width', `${width}px`);
|
|
@@ -101,11 +101,12 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
101
101
|
const helperClasses = cx(`${prefix}--form__helper-text`, {
|
|
102
102
|
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
103
103
|
});
|
|
104
|
-
const
|
|
105
|
-
const
|
|
104
|
+
const hasHelper = typeof helperText !== 'undefined' && helperText !== null;
|
|
105
|
+
const helperId = !hasHelper ? undefined : `radio-button-group-helper-text-${radioButtonGroupInstanceId}`;
|
|
106
|
+
const helper = hasHelper && /*#__PURE__*/React.createElement("div", {
|
|
106
107
|
id: helperId,
|
|
107
108
|
className: helperClasses
|
|
108
|
-
}, helperText)
|
|
109
|
+
}, helperText);
|
|
109
110
|
const divRef = React.useRef(null);
|
|
110
111
|
|
|
111
112
|
// AILabel is always size `mini`
|