@carbon/react 1.65.0 → 1.66.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 +927 -927
- package/es/components/AILabel/index.d.ts +37 -0
- package/es/components/AILabel/index.js +38 -14
- package/es/components/Accordion/Accordion.d.ts +5 -1
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/es/components/Button/Button.d.ts +2 -1
- package/es/components/Button/Button.js +14 -3
- package/es/components/ChatButton/ChatButton.Skeleton.d.ts +31 -0
- package/es/components/ChatButton/ChatButton.Skeleton.js +1 -2
- package/es/components/ChatButton/ChatButton.d.ts +46 -0
- package/es/components/ChatButton/ChatButton.js +3 -3
- package/es/components/ChatButton/index.d.ts +12 -0
- package/es/components/Checkbox/index.js +10 -0
- package/es/components/CodeSnippet/CodeSnippet.d.ts +9 -1
- package/es/components/CodeSnippet/CodeSnippet.js +7 -0
- package/es/components/ComboBox/ComboBox.js +38 -19
- package/es/components/ComboButton/index.js +8 -3
- package/es/components/ComposedModal/index.d.ts +2 -0
- package/es/components/Copy/Copy.d.ts +9 -1
- package/es/components/Copy/Copy.js +6 -0
- package/es/components/CopyButton/CopyButton.d.ts +9 -1
- package/es/components/CopyButton/CopyButton.js +6 -0
- package/es/components/DataTable/TableSlugRow.d.ts +1 -0
- package/es/components/DataTable/TableSlugRow.js +1 -0
- package/es/components/Dropdown/Dropdown.js +1 -1
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +20 -0
- package/es/components/FluidTextArea/FluidTextArea.Skeleton.js +3 -20
- package/es/components/FluidTextArea/FluidTextArea.d.ts +96 -0
- package/es/components/FluidTextArea/FluidTextArea.js +2 -2
- package/es/components/FluidTextArea/index.d.ts +12 -0
- package/es/components/Grid/Column.js +3 -3
- package/es/components/IconButton/index.d.ts +4 -0
- package/es/components/IconButton/index.js +6 -0
- package/es/components/ListBox/ListBoxMenuItem.d.ts +10 -1
- package/es/components/ListBox/next/ListBoxSelection.d.ts +106 -0
- package/es/components/ListBox/next/ListBoxSelection.js +12 -16
- package/es/components/ListBox/next/ListBoxTrigger.d.ts +31 -0
- package/es/components/ListBox/next/ListBoxTrigger.js +2 -4
- package/es/components/ListBox/next/index.d.ts +8 -0
- package/es/components/Menu/Menu.js +2 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +14 -15
- package/es/components/MultiSelect/MultiSelect.js +65 -49
- package/es/components/MultiSelect/tools/sorting.js +5 -8
- package/es/components/OverflowMenu/OverflowMenu.js +1 -1
- package/es/components/OverflowMenu/next/index.js +3 -1
- package/es/components/Popover/index.js +22 -5
- package/es/components/Tag/DismissibleTag.d.ts +9 -1
- package/es/components/Tag/DismissibleTag.js +7 -3
- package/es/components/Tag/Tag.js +2 -2
- package/es/components/Toggletip/index.js +2 -1
- package/es/components/TreeView/TreeNode.js +41 -33
- package/es/components/TreeView/TreeView.d.ts +5 -3
- package/es/index.js +4 -4
- package/es/internal/Selection.js +30 -18
- package/es/internal/useMergedRefs.d.ts +1 -1
- package/lib/components/AILabel/index.d.ts +37 -0
- package/lib/components/AILabel/index.js +38 -14
- package/lib/components/Accordion/Accordion.d.ts +5 -1
- package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/lib/components/Button/Button.d.ts +2 -1
- package/lib/components/Button/Button.js +13 -2
- package/lib/components/ChatButton/ChatButton.Skeleton.d.ts +31 -0
- package/lib/components/ChatButton/ChatButton.Skeleton.js +1 -2
- package/lib/components/ChatButton/ChatButton.d.ts +46 -0
- package/lib/components/ChatButton/ChatButton.js +4 -4
- package/lib/components/ChatButton/index.d.ts +12 -0
- package/lib/components/Checkbox/index.js +19 -0
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +9 -1
- package/lib/components/CodeSnippet/CodeSnippet.js +7 -0
- package/lib/components/ComboBox/ComboBox.js +38 -19
- package/lib/components/ComboButton/index.js +8 -3
- package/lib/components/ComposedModal/index.d.ts +2 -0
- package/lib/components/Copy/Copy.d.ts +9 -1
- package/lib/components/Copy/Copy.js +6 -0
- package/lib/components/CopyButton/CopyButton.d.ts +9 -1
- package/lib/components/CopyButton/CopyButton.js +6 -0
- package/lib/components/DataTable/TableSlugRow.d.ts +1 -0
- package/lib/components/DataTable/TableSlugRow.js +1 -0
- package/lib/components/Dropdown/Dropdown.js +1 -1
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.d.ts +20 -0
- package/lib/components/FluidTextArea/FluidTextArea.Skeleton.js +3 -22
- package/lib/components/FluidTextArea/FluidTextArea.d.ts +96 -0
- package/lib/components/FluidTextArea/FluidTextArea.js +2 -2
- package/lib/components/FluidTextArea/index.d.ts +12 -0
- package/lib/components/Grid/Column.js +3 -3
- package/lib/components/IconButton/index.d.ts +4 -0
- package/lib/components/IconButton/index.js +6 -0
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +10 -1
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +106 -0
- package/lib/components/ListBox/next/ListBoxSelection.js +11 -16
- package/lib/components/ListBox/next/ListBoxTrigger.d.ts +31 -0
- package/lib/components/ListBox/next/ListBoxTrigger.js +2 -4
- package/lib/components/ListBox/next/index.d.ts +8 -0
- package/lib/components/Menu/Menu.js +2 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +14 -15
- package/lib/components/MultiSelect/MultiSelect.js +64 -48
- package/lib/components/MultiSelect/tools/sorting.js +5 -8
- package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
- package/lib/components/OverflowMenu/next/index.js +3 -1
- package/lib/components/Popover/index.js +22 -5
- package/lib/components/Tag/DismissibleTag.d.ts +9 -1
- package/lib/components/Tag/DismissibleTag.js +7 -3
- package/lib/components/Tag/Tag.js +2 -2
- package/lib/components/Toggletip/index.js +2 -1
- package/lib/components/TreeView/TreeNode.js +41 -33
- package/lib/components/TreeView/TreeView.d.ts +5 -3
- package/lib/index.js +8 -8
- package/lib/internal/Selection.js +30 -18
- package/lib/internal/useMergedRefs.d.ts +1 -1
- package/package.json +25 -22
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2024
|
|
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
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
/**
|
|
10
|
+
* `ListBoxSelection` is used to provide controls for clearing a selection, in
|
|
11
|
+
* addition to conditionally rendering a badge if the control has more than one
|
|
12
|
+
* selection.
|
|
13
|
+
*/
|
|
14
|
+
export declare const translationIds: {
|
|
15
|
+
readonly 'clear.all': "clear.all";
|
|
16
|
+
readonly 'clear.selection': "clear.selection";
|
|
17
|
+
};
|
|
18
|
+
export type TranslationKey = keyof typeof translationIds;
|
|
19
|
+
export interface ListBoxSelectionProps {
|
|
20
|
+
/**
|
|
21
|
+
* Specify a function to be invoked when a user interacts with the clear
|
|
22
|
+
* selection element.
|
|
23
|
+
*/
|
|
24
|
+
clearSelection: (event: React.MouseEvent<HTMLButtonElement> | React.KeyboardEvent<HTMLButtonElement>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Specify an optional `selectionCount` value that will be used to determine
|
|
27
|
+
* whether the selection should display a badge or a single clear icon.
|
|
28
|
+
*/
|
|
29
|
+
selectionCount?: number;
|
|
30
|
+
/**
|
|
31
|
+
* i18n hook used to provide the appropriate description for the given menu
|
|
32
|
+
* icon. This function takes in an id defined in `translationIds` and should
|
|
33
|
+
* return a string message for that given message id.
|
|
34
|
+
*/
|
|
35
|
+
translateWithId?: (id: TranslationKey) => string;
|
|
36
|
+
/**
|
|
37
|
+
* Specify whether or not the clear selection element should be disabled
|
|
38
|
+
*/
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
42
|
+
* element is cleared
|
|
43
|
+
*/
|
|
44
|
+
onClearSelection?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Specify an optional `onClick` handler that is called when the underlying
|
|
47
|
+
* clear selection element is clicked
|
|
48
|
+
*/
|
|
49
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
50
|
+
/**
|
|
51
|
+
* Specify an optional `onKeyDown` handler that is called when the underlying
|
|
52
|
+
* clear selection element fires a keydown event
|
|
53
|
+
*/
|
|
54
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLButtonElement>;
|
|
55
|
+
/**
|
|
56
|
+
* Specify an optional `onMouseUp` handler that is called when the underlying
|
|
57
|
+
* clear selection element fires a mouseup event
|
|
58
|
+
*/
|
|
59
|
+
onMouseUp?: React.MouseEventHandler<HTMLButtonElement>;
|
|
60
|
+
}
|
|
61
|
+
declare function ListBoxSelection({ clearSelection, selectionCount, translateWithId: t, disabled, onClearSelection, ...rest }: ListBoxSelectionProps): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
declare namespace ListBoxSelection {
|
|
63
|
+
var propTypes: {
|
|
64
|
+
/**
|
|
65
|
+
* Specify a function to be invoked when a user interacts with the clear
|
|
66
|
+
* selection element.
|
|
67
|
+
*/
|
|
68
|
+
clearSelection: PropTypes.Validator<(...args: any[]) => any>;
|
|
69
|
+
/**
|
|
70
|
+
* Specify whether or not the clear selection element should be disabled
|
|
71
|
+
*/
|
|
72
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
73
|
+
/**
|
|
74
|
+
* Specify an optional `onClearSelection` handler that is called when the underlying
|
|
75
|
+
* element is cleared
|
|
76
|
+
*/
|
|
77
|
+
onClearSelection: PropTypes.Requireable<(...args: any[]) => any>;
|
|
78
|
+
/**
|
|
79
|
+
* Specify an optional `onClick` handler that is called when the underlying
|
|
80
|
+
* clear selection element is clicked
|
|
81
|
+
*/
|
|
82
|
+
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
83
|
+
/**
|
|
84
|
+
* Specify an optional `onClick` handler that is called when the underlying
|
|
85
|
+
* clear selection element is clicked
|
|
86
|
+
*/
|
|
87
|
+
onMouseUp: PropTypes.Requireable<(...args: any[]) => any>;
|
|
88
|
+
/**
|
|
89
|
+
* Specify an optional `onKeyDown` handler that is called when the underlying
|
|
90
|
+
* clear selection element fires a keydown event
|
|
91
|
+
*/
|
|
92
|
+
onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
93
|
+
/**
|
|
94
|
+
* Specify an optional `selectionCount` value that will be used to determine
|
|
95
|
+
* whether the selection should display a badge or a single clear icon.
|
|
96
|
+
*/
|
|
97
|
+
selectionCount: PropTypes.Requireable<number>;
|
|
98
|
+
/**
|
|
99
|
+
* i18n hook used to provide the appropriate description for the given menu
|
|
100
|
+
* icon. This function takes in an id defined in `translationIds` and should
|
|
101
|
+
* return a string message for that given message id.
|
|
102
|
+
*/
|
|
103
|
+
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export default ListBoxSelection;
|
|
@@ -23,22 +23,13 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
23
23
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
24
24
|
|
|
25
25
|
var _Close, _Close2;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* `ListBoxSelection` is used to provide controls for clearing a selection, in
|
|
29
|
-
* addition to conditionally rendering a badge if the control has more than one
|
|
30
|
-
* selection.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const translationIds = {
|
|
34
|
-
'clear.all': 'clear.all',
|
|
35
|
-
'clear.selection': 'clear.selection'
|
|
36
|
-
};
|
|
37
26
|
const defaultTranslations = {
|
|
38
|
-
|
|
39
|
-
|
|
27
|
+
'clear.all': 'Clear all selected items',
|
|
28
|
+
'clear.selection': 'Clear selected item'
|
|
40
29
|
};
|
|
41
|
-
|
|
30
|
+
function defaultTranslateWithId(id) {
|
|
31
|
+
return defaultTranslations[id];
|
|
32
|
+
}
|
|
42
33
|
function ListBoxSelection(_ref) {
|
|
43
34
|
let {
|
|
44
35
|
clearSelection,
|
|
@@ -72,7 +63,7 @@ function ListBoxSelection(_ref) {
|
|
|
72
63
|
className: tagClasses
|
|
73
64
|
}, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
74
65
|
className: `${prefix}--tag__label`,
|
|
75
|
-
title: selectionCount
|
|
66
|
+
title: selectionCount?.toString()
|
|
76
67
|
}, selectionCount), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
77
68
|
"aria-label": description,
|
|
78
69
|
className: `${prefix}--tag__close-icon`,
|
|
@@ -113,6 +104,11 @@ ListBoxSelection.propTypes = {
|
|
|
113
104
|
* clear selection element is clicked
|
|
114
105
|
*/
|
|
115
106
|
onClick: PropTypes__default["default"].func,
|
|
107
|
+
/**
|
|
108
|
+
* Specify an optional `onClick` handler that is called when the underlying
|
|
109
|
+
* clear selection element is clicked
|
|
110
|
+
*/
|
|
111
|
+
onMouseUp: PropTypes__default["default"].func,
|
|
116
112
|
/**
|
|
117
113
|
* Specify an optional `onKeyDown` handler that is called when the underlying
|
|
118
114
|
* clear selection element fires a keydown event
|
|
@@ -132,4 +128,3 @@ ListBoxSelection.propTypes = {
|
|
|
132
128
|
};
|
|
133
129
|
|
|
134
130
|
exports["default"] = ListBoxSelection;
|
|
135
|
-
exports.translationIds = translationIds;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2024
|
|
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
|
+
export declare const translationIds: {
|
|
9
|
+
readonly 'close.menu': "close.menu";
|
|
10
|
+
readonly 'open.menu': "open.menu";
|
|
11
|
+
};
|
|
12
|
+
export type TranslationKey = keyof typeof translationIds;
|
|
13
|
+
export interface ListBoxTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
14
|
+
/**
|
|
15
|
+
* Specify whether the menu is currently open, which will influence the
|
|
16
|
+
* direction of the menu icon
|
|
17
|
+
*/
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* i18n hook used to provide the appropriate description for the given menu
|
|
21
|
+
* icon. This function takes in an id defined in `translationIds` and should
|
|
22
|
+
* return a string message for that given message id.
|
|
23
|
+
*/
|
|
24
|
+
translateWithId?: (id: TranslationKey) => string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* `ListBoxTrigger` is used to orient the icon up or down depending on the
|
|
28
|
+
* state of the menu for a given `ListBox`
|
|
29
|
+
*/
|
|
30
|
+
declare const ListBoxTrigger: React.ForwardRefExoticComponent<ListBoxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
31
|
+
export default ListBoxTrigger;
|
|
@@ -32,7 +32,6 @@ const defaultTranslations = {
|
|
|
32
32
|
[translationIds['open.menu']]: 'Open'
|
|
33
33
|
};
|
|
34
34
|
const defaultTranslateWithId = id => defaultTranslations[id];
|
|
35
|
-
|
|
36
35
|
/**
|
|
37
36
|
* `ListBoxTrigger` is used to orient the icon up or down depending on the
|
|
38
37
|
* state of the menu for a given `ListBox`
|
|
@@ -55,7 +54,7 @@ const ListBoxTrigger = /*#__PURE__*/React__default["default"].forwardRef(functio
|
|
|
55
54
|
title: description,
|
|
56
55
|
className: className,
|
|
57
56
|
type: "button",
|
|
58
|
-
tabIndex:
|
|
57
|
+
tabIndex: -1,
|
|
59
58
|
ref: ref
|
|
60
59
|
}), _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronDown, null)));
|
|
61
60
|
});
|
|
@@ -72,7 +71,6 @@ ListBoxTrigger.propTypes = {
|
|
|
72
71
|
*/
|
|
73
72
|
translateWithId: PropTypes__default["default"].func
|
|
74
73
|
};
|
|
75
|
-
var ListBoxTrigger$1 = ListBoxTrigger;
|
|
76
74
|
|
|
77
|
-
exports["default"] = ListBoxTrigger
|
|
75
|
+
exports["default"] = ListBoxTrigger;
|
|
78
76
|
exports.translationIds = translationIds;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2024
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
export { default as ListBoxSelection, type ListBoxSelectionProps, } from './ListBoxSelection';
|
|
8
|
+
export { default as ListBoxTrigger, type ListBoxTriggerProps, } from './ListBoxTrigger';
|
|
@@ -292,7 +292,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
292
292
|
[`${prefix}--menu--box-shadow-top`]: menuAlignment && menuAlignment.slice(0, 3) === 'top',
|
|
293
293
|
[`${prefix}--menu--open`]: open,
|
|
294
294
|
[`${prefix}--menu--shown`]: open && !legacyAutoalign || position[0] >= 0 && position[1] >= 0,
|
|
295
|
-
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons
|
|
295
|
+
[`${prefix}--menu--with-icons`]: childContext.state.hasIcons,
|
|
296
|
+
[`${prefix}--autoalign`]: !legacyAutoalign
|
|
296
297
|
});
|
|
297
298
|
const rendered = /*#__PURE__*/React__default["default"].createElement(MenuContext.MenuContext.Provider, {
|
|
298
299
|
value: childContext
|
|
@@ -19,6 +19,8 @@ var React = require('react');
|
|
|
19
19
|
var filter = require('../ComboBox/tools/filter.js');
|
|
20
20
|
var MultiSelectPropTypes = require('./MultiSelectPropTypes.js');
|
|
21
21
|
var index = require('../ListBox/index.js');
|
|
22
|
+
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
23
|
+
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
22
24
|
var itemToString = require('./tools/itemToString.js');
|
|
23
25
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
24
26
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
@@ -29,9 +31,8 @@ require('../FluidForm/FluidForm.js');
|
|
|
29
31
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
30
32
|
var Selection = require('../../internal/Selection.js');
|
|
31
33
|
var react = require('@floating-ui/react');
|
|
34
|
+
var floatingUi_core = require('../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js');
|
|
32
35
|
var match = require('../../internal/keyboard/match.js');
|
|
33
|
-
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
34
|
-
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
35
36
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
36
37
|
var keys = require('../../internal/keyboard/keys.js');
|
|
37
38
|
|
|
@@ -156,14 +157,18 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
156
157
|
width: `${rects.reference.width}px`
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
|
-
})],
|
|
160
|
+
}), floatingUi_core.hide()],
|
|
160
161
|
whileElementsMounted: react.autoUpdate
|
|
161
162
|
} : {});
|
|
162
163
|
React.useLayoutEffect(() => {
|
|
163
164
|
if (autoAlign) {
|
|
164
|
-
|
|
165
|
+
const updatedFloatingStyles = {
|
|
166
|
+
...floatingStyles,
|
|
167
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
168
|
+
};
|
|
169
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
165
170
|
if (refs.floating.current) {
|
|
166
|
-
refs.floating.current.style[style] =
|
|
171
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
167
172
|
}
|
|
168
173
|
});
|
|
169
174
|
}
|
|
@@ -203,7 +208,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
203
208
|
[`${prefix}--list-box--up`]: direction === 'top',
|
|
204
209
|
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
|
|
205
210
|
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused,
|
|
206
|
-
[`${prefix}--list-box__wrapper--slug`]: slug
|
|
211
|
+
[`${prefix}--list-box__wrapper--slug`]: slug,
|
|
212
|
+
[`${prefix}--autoalign`]: autoAlign
|
|
207
213
|
});
|
|
208
214
|
const helperId = !helperText ? undefined : `filterablemultiselect-helper-text-${filterableMultiSelectInstanceId}`;
|
|
209
215
|
const labelId = `${id}-label`;
|
|
@@ -544,10 +550,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
544
550
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
545
551
|
className: `${prefix}--list-box__field`,
|
|
546
552
|
ref: autoAlign ? refs.setReference : null
|
|
547
|
-
}, controlledSelectedItems.length > 0 &&
|
|
548
|
-
/*#__PURE__*/
|
|
549
|
-
// @ts-expect-error: It is expecting a non-required prop called: "onClearSelection"
|
|
550
|
-
React__default["default"].createElement(ListBoxSelection["default"], {
|
|
553
|
+
}, controlledSelectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
|
|
551
554
|
clearSelection: () => {
|
|
552
555
|
clearSelection();
|
|
553
556
|
if (textInput.current) {
|
|
@@ -565,10 +568,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
565
568
|
className: `${prefix}--list-box__invalid-icon`
|
|
566
569
|
}), showWarning && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
567
570
|
className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
|
|
568
|
-
}), inputValue &&
|
|
569
|
-
/*#__PURE__*/
|
|
570
|
-
// @ts-expect-error: It is expecting two non-required prop called: "onClearSelection" & "selectionCount"
|
|
571
|
-
React__default["default"].createElement(ListBoxSelection["default"], {
|
|
571
|
+
}), inputValue && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
|
|
572
572
|
clearSelection: clearInputValue,
|
|
573
573
|
disabled: disabled,
|
|
574
574
|
translateWithId: translateWithId,
|
|
@@ -581,7 +581,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
581
581
|
event.stopPropagation();
|
|
582
582
|
}
|
|
583
583
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
584
|
-
// @ts-expect-error
|
|
585
584
|
isOpen: isOpen,
|
|
586
585
|
translateWithId: translateWithId
|
|
587
586
|
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? sortedItems.map((item, index$1) => {
|
|
@@ -26,8 +26,11 @@ var deprecate = require('../../prop-types/deprecate.js');
|
|
|
26
26
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
27
27
|
require('../FluidForm/FluidForm.js');
|
|
28
28
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
29
|
+
var Checkbox = require('../Checkbox/Checkbox.js');
|
|
30
|
+
require('../Checkbox/Checkbox.Skeleton.js');
|
|
29
31
|
var noopFn = require('../../internal/noopFn.js');
|
|
30
32
|
var react = require('@floating-ui/react');
|
|
33
|
+
var floatingUi_core = require('../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js');
|
|
31
34
|
var match = require('../../internal/keyboard/match.js');
|
|
32
35
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
33
36
|
var keys = require('../../internal/keyboard/keys.js');
|
|
@@ -105,6 +108,23 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
105
108
|
locale = 'en',
|
|
106
109
|
slug
|
|
107
110
|
} = _ref;
|
|
111
|
+
const filteredItems = React.useMemo(() => {
|
|
112
|
+
return items.filter(item => {
|
|
113
|
+
if (typeof item === 'object' && item !== null) {
|
|
114
|
+
for (const key in item) {
|
|
115
|
+
if (Object.hasOwn(item, key) && item[key] === undefined) {
|
|
116
|
+
return false; // Return false if any property has an undefined value
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return true; // Return true if item is not an object with undefined values
|
|
121
|
+
});
|
|
122
|
+
}, [items]);
|
|
123
|
+
let selectAll = filteredItems.some(item => item.isSelectAll);
|
|
124
|
+
if ((selected ?? []).length > 0 && selectAll) {
|
|
125
|
+
console.warn('Warning: `selectAll` should not be used when `selectedItems` is provided. Please pass either `selectAll` or `selectedItems`, not both.');
|
|
126
|
+
selectAll = false;
|
|
127
|
+
}
|
|
108
128
|
const prefix = usePrefix.usePrefix();
|
|
109
129
|
const {
|
|
110
130
|
isFluid
|
|
@@ -116,16 +136,6 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
116
136
|
const [prevOpenProp, setPrevOpenProp] = React.useState(open);
|
|
117
137
|
const [topItems, setTopItems] = React.useState([]);
|
|
118
138
|
const [itemsCleared, setItemsCleared] = React.useState(false);
|
|
119
|
-
const {
|
|
120
|
-
selectedItems: controlledSelectedItems,
|
|
121
|
-
onItemChange,
|
|
122
|
-
clearSelection
|
|
123
|
-
} = Selection.useSelection({
|
|
124
|
-
disabled,
|
|
125
|
-
initialSelectedItems,
|
|
126
|
-
onChange,
|
|
127
|
-
selectedItems: selected
|
|
128
|
-
});
|
|
129
139
|
const {
|
|
130
140
|
refs,
|
|
131
141
|
floatingStyles,
|
|
@@ -150,32 +160,40 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
150
160
|
width: `${rects.reference.width}px`
|
|
151
161
|
});
|
|
152
162
|
}
|
|
153
|
-
})],
|
|
163
|
+
}), floatingUi_core.hide()],
|
|
154
164
|
whileElementsMounted: react.autoUpdate
|
|
155
165
|
} : {});
|
|
156
166
|
React.useLayoutEffect(() => {
|
|
157
167
|
if (autoAlign) {
|
|
158
|
-
|
|
168
|
+
const updatedFloatingStyles = {
|
|
169
|
+
...floatingStyles,
|
|
170
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
171
|
+
};
|
|
172
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
159
173
|
if (refs.floating.current) {
|
|
160
|
-
refs.floating.current.style[style] =
|
|
174
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
161
175
|
}
|
|
162
176
|
});
|
|
163
177
|
}
|
|
164
178
|
}, [autoAlign, floatingStyles, refs.floating, middlewareData, open]);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
const {
|
|
180
|
+
selectedItems: controlledSelectedItems,
|
|
181
|
+
onItemChange,
|
|
182
|
+
clearSelection
|
|
183
|
+
} = Selection.useSelection({
|
|
184
|
+
disabled,
|
|
185
|
+
initialSelectedItems,
|
|
186
|
+
onChange,
|
|
187
|
+
selectedItems: selected,
|
|
188
|
+
selectAll,
|
|
189
|
+
filteredItems
|
|
190
|
+
});
|
|
191
|
+
const sortOptions = {
|
|
192
|
+
selectedItems: controlledSelectedItems,
|
|
193
|
+
itemToString,
|
|
194
|
+
compareItems,
|
|
195
|
+
locale
|
|
196
|
+
};
|
|
179
197
|
const selectProps = {
|
|
180
198
|
stateReducer,
|
|
181
199
|
isOpen,
|
|
@@ -271,18 +289,14 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
271
289
|
[`${prefix}--multi-select--inline`]: inline,
|
|
272
290
|
[`${prefix}--multi-select--selected`]: selectedItems && selectedItems.length > 0,
|
|
273
291
|
[`${prefix}--list-box--up`]: direction === 'top',
|
|
274
|
-
[`${prefix}--multi-select--readonly`]: readOnly
|
|
292
|
+
[`${prefix}--multi-select--readonly`]: readOnly,
|
|
293
|
+
[`${prefix}--autoalign`]: autoAlign,
|
|
294
|
+
[`${prefix}--multi-select--selectall`]: selectAll
|
|
275
295
|
});
|
|
276
296
|
|
|
277
297
|
// needs to be capitalized for react to render it correctly
|
|
278
298
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
279
299
|
const ItemToElement = itemToElement;
|
|
280
|
-
const sortOptions = {
|
|
281
|
-
selectedItems: controlledSelectedItems,
|
|
282
|
-
itemToString,
|
|
283
|
-
compareItems,
|
|
284
|
-
locale
|
|
285
|
-
};
|
|
286
300
|
if (selectionFeedback === 'fixed') {
|
|
287
301
|
sortOptions.selectedItems = [];
|
|
288
302
|
} else if (selectionFeedback === 'top-after-reopen') {
|
|
@@ -345,7 +359,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
345
359
|
} else {
|
|
346
360
|
return {
|
|
347
361
|
...changes,
|
|
348
|
-
highlightedIndex:
|
|
362
|
+
highlightedIndex: filteredItems.indexOf(highlightedIndex)
|
|
349
363
|
};
|
|
350
364
|
}
|
|
351
365
|
case ToggleButtonKeyDownArrowDown:
|
|
@@ -403,11 +417,12 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
403
417
|
});
|
|
404
418
|
}
|
|
405
419
|
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item?.text);
|
|
420
|
+
const selectedItemsLength = selectAll ? selectedItems.filter(item => !item.isSelectAll).length : selectedItems.length;
|
|
406
421
|
|
|
407
422
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
408
423
|
const menuProps = React.useMemo(() => getMenuProps({
|
|
409
424
|
ref: autoAlign ? refs.setFloating : null
|
|
410
|
-
}), [autoAlign]);
|
|
425
|
+
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
411
426
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
412
427
|
className: wrapperClasses
|
|
413
428
|
}, /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -438,7 +453,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
438
453
|
}, selectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement(index["default"].Selection, {
|
|
439
454
|
readOnly: readOnly,
|
|
440
455
|
clearSelection: !disabled && !readOnly ? clearSelection : noopFn.noopFn,
|
|
441
|
-
selectionCount:
|
|
456
|
+
selectionCount: selectedItemsLength
|
|
442
457
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
443
458
|
,
|
|
444
459
|
translateWithId: translateWithId,
|
|
@@ -457,10 +472,9 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
457
472
|
}, label), /*#__PURE__*/React__default["default"].createElement(index["default"].MenuIcon, {
|
|
458
473
|
isOpen: isOpen,
|
|
459
474
|
translateWithId: translateWithId
|
|
460
|
-
})), normalizedSlug), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen &&
|
|
461
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
462
|
-
sortItems(filteredItems, sortOptions).map((item, index$1) => {
|
|
475
|
+
})), normalizedSlug), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && sortItems(filteredItems, sortOptions).map((item, index$1) => {
|
|
463
476
|
const isChecked = selectedItems.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
477
|
+
const isIndeterminate = selectedItems.length !== 0 && item['isSelectAll'] && !isChecked;
|
|
464
478
|
const itemProps = getItemProps({
|
|
465
479
|
item,
|
|
466
480
|
// we don't want Downshift to set aria-selected for us
|
|
@@ -470,21 +484,23 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
|
|
|
470
484
|
const itemText = itemToString(item);
|
|
471
485
|
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
472
486
|
key: itemProps.id,
|
|
473
|
-
isActive: isChecked,
|
|
487
|
+
isActive: isChecked && !item['isSelectAll'],
|
|
474
488
|
"aria-label": itemText,
|
|
475
489
|
isHighlighted: highlightedIndex === index$1,
|
|
476
490
|
title: itemText,
|
|
477
491
|
disabled: itemProps['aria-disabled']
|
|
478
492
|
}, itemProps), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
479
493
|
className: `${prefix}--checkbox-wrapper`
|
|
480
|
-
}, /*#__PURE__*/React__default["default"].createElement("
|
|
494
|
+
}, /*#__PURE__*/React__default["default"].createElement(Checkbox["default"], {
|
|
495
|
+
id: `${itemProps.id}__checkbox`,
|
|
496
|
+
labelText: itemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
497
|
+
key: itemProps.id
|
|
498
|
+
}, item)) : itemText,
|
|
499
|
+
checked: isChecked,
|
|
481
500
|
title: useTitleInItem ? itemText : undefined,
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}, itemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
486
|
-
key: itemProps.id
|
|
487
|
-
}, item)) : itemText)));
|
|
501
|
+
indeterminate: isIndeterminate,
|
|
502
|
+
disabled: disabled
|
|
503
|
+
})));
|
|
488
504
|
})), itemsCleared && /*#__PURE__*/React__default["default"].createElement("span", {
|
|
489
505
|
"aria-live": "assertive",
|
|
490
506
|
"aria-label": clearAnnouncement
|
|
@@ -39,16 +39,13 @@ const defaultSortItems = (items, _ref2) => {
|
|
|
39
39
|
locale = 'en'
|
|
40
40
|
} = _ref2;
|
|
41
41
|
return items.sort((itemA, itemB) => {
|
|
42
|
+
// Always place "select all" option at the beginning
|
|
43
|
+
if (itemA.isSelectAll) return -1;
|
|
44
|
+
if (itemB.isSelectAll) return 1;
|
|
42
45
|
const hasItemA = selectedItems.includes(itemA);
|
|
43
46
|
const hasItemB = selectedItems.includes(itemB);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (hasItemA && !hasItemB) {
|
|
47
|
-
return -1;
|
|
48
|
-
}
|
|
49
|
-
if (hasItemB && !hasItemA) {
|
|
50
|
-
return 1;
|
|
51
|
-
}
|
|
47
|
+
if (hasItemA && !hasItemB) return -1;
|
|
48
|
+
if (hasItemB && !hasItemA) return 1;
|
|
52
49
|
return compareItems(itemToString(itemA), itemToString(itemB), {
|
|
53
50
|
locale
|
|
54
51
|
});
|
|
@@ -262,7 +262,7 @@ class OverflowMenu extends React__default["default"].Component {
|
|
|
262
262
|
} = this.props;
|
|
263
263
|
if (menuBody) {
|
|
264
264
|
this._menuBody = menuBody;
|
|
265
|
-
const hasFocusin =
|
|
265
|
+
const hasFocusin = 'onfocusin' in window;
|
|
266
266
|
const focusinEventName = hasFocusin ? 'focusin' : 'focus';
|
|
267
267
|
this._hFocusIn = on(menuBody.ownerDocument, focusinEventName, event => {
|
|
268
268
|
const target = ClickListener["default"].getEventTarget(event);
|
|
@@ -93,7 +93,9 @@ const OverflowMenu = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
93
93
|
hookOnClick();
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const containerClasses = cx__default["default"](className, `${prefix}--overflow-menu__container
|
|
96
|
+
const containerClasses = cx__default["default"](className, `${prefix}--overflow-menu__container`, {
|
|
97
|
+
[`${prefix}--autoalign`]: autoAlign
|
|
98
|
+
});
|
|
97
99
|
const menuClasses = cx__default["default"](`${prefix}--overflow-menu__${menuAlignment}`);
|
|
98
100
|
const triggerClasses = cx__default["default"](`${prefix}--overflow-menu`, {
|
|
99
101
|
[`${prefix}--overflow-menu--open`]: open
|
|
@@ -20,6 +20,7 @@ var usePrefix = require('../../internal/usePrefix.js');
|
|
|
20
20
|
var useEvent = require('../../internal/useEvent.js');
|
|
21
21
|
var createPropAdapter = require('../../tools/createPropAdapter.js');
|
|
22
22
|
var react = require('@floating-ui/react');
|
|
23
|
+
var floatingUi_core = require('../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
26
|
|
|
@@ -138,7 +139,7 @@ const Popover = /*#__PURE__*/React__default["default"].forwardRef(function Popov
|
|
|
138
139
|
fallbackAxisSideDirection: 'start'
|
|
139
140
|
}), react.arrow({
|
|
140
141
|
element: caretRef
|
|
141
|
-
})],
|
|
142
|
+
}), floatingUi_core.hide()],
|
|
142
143
|
whileElementsMounted: react.autoUpdate
|
|
143
144
|
} : {} // When autoAlign is turned off, floating-ui will not be used
|
|
144
145
|
);
|
|
@@ -158,9 +159,13 @@ const Popover = /*#__PURE__*/React__default["default"].forwardRef(function Popov
|
|
|
158
159
|
}
|
|
159
160
|
React.useEffect(() => {
|
|
160
161
|
if (autoAlign) {
|
|
161
|
-
|
|
162
|
+
const updatedFloatingStyles = {
|
|
163
|
+
...floatingStyles,
|
|
164
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
165
|
+
};
|
|
166
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
162
167
|
if (refs.floating.current) {
|
|
163
|
-
refs.floating.current.style[style] =
|
|
168
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
164
169
|
}
|
|
165
170
|
});
|
|
166
171
|
if (caret && middlewareData && middlewareData.arrow && caretRef?.current) {
|
|
@@ -194,13 +199,25 @@ const Popover = /*#__PURE__*/React__default["default"].forwardRef(function Popov
|
|
|
194
199
|
[`${prefix}--popover--drop-shadow`]: dropShadow,
|
|
195
200
|
[`${prefix}--popover--high-contrast`]: highContrast,
|
|
196
201
|
[`${prefix}--popover--open`]: open,
|
|
197
|
-
[`${prefix}--popover--auto-align`]: autoAlign,
|
|
202
|
+
[`${prefix}--popover--auto-align ${prefix}--autoalign`]: autoAlign,
|
|
198
203
|
[`${prefix}--popover--${currentAlignment}`]: true,
|
|
199
204
|
[`${prefix}--popover--tab-tip`]: isTabTip
|
|
200
205
|
}, customClassName);
|
|
201
206
|
const mappedChildren = React__default["default"].Children.map(children, child => {
|
|
202
207
|
const item = child;
|
|
203
|
-
|
|
208
|
+
const displayName = item?.type?.displayName;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Only trigger elements (button) or trigger components (ToggletipButton) should be
|
|
212
|
+
* cloned because these will be decorated with a trigger-specific className and ref.
|
|
213
|
+
*
|
|
214
|
+
* There are also some specific components that should not be cloned when autoAlign
|
|
215
|
+
* is on, even if they are a trigger element.
|
|
216
|
+
*/
|
|
217
|
+
const isTriggerElement = item?.type === 'button';
|
|
218
|
+
const isTriggerComponent = autoAlign && displayName && ['ToggletipButton'].includes(displayName);
|
|
219
|
+
const isAllowedTriggerComponent = autoAlign && displayName && !['ToggletipContent', 'PopoverContent'].includes(displayName);
|
|
220
|
+
if ( /*#__PURE__*/React__default["default"].isValidElement(item) && (isTriggerElement || isTriggerComponent || isAllowedTriggerComponent)) {
|
|
204
221
|
const className = item?.props?.className;
|
|
205
222
|
const ref = (item?.props).ref;
|
|
206
223
|
const tabTipClasses = cx__default["default"](`${prefix}--popover--tab-tip__button`, className);
|