@carbon/react 1.65.0 → 1.66.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 +964 -888
- 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/ComboBox/ComboBox.js +12 -7
- package/es/components/ComboButton/index.js +8 -3
- package/es/components/ComposedModal/index.d.ts +2 -0
- package/es/components/DataTable/TableSlugRow.d.ts +1 -0
- package/es/components/DataTable/TableSlugRow.js +1 -0
- package/es/components/Grid/Column.js +3 -3
- 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/MultiSelect/FilterableMultiSelect.js +12 -14
- package/es/components/MultiSelect/MultiSelect.js +64 -49
- package/es/components/MultiSelect/tools/sorting.js +5 -8
- package/es/components/OverflowMenu/OverflowMenu.js +1 -1
- package/es/components/Popover/index.js +21 -4
- package/es/components/TreeView/TreeNode.js +41 -33
- package/es/components/TreeView/TreeView.d.ts +5 -3
- package/es/index.js +2 -2
- package/es/internal/Selection.js +30 -18
- package/es/internal/useMergedRefs.d.ts +1 -1
- 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/ComboBox/ComboBox.js +12 -7
- package/lib/components/ComboButton/index.js +8 -3
- package/lib/components/ComposedModal/index.d.ts +2 -0
- package/lib/components/DataTable/TableSlugRow.d.ts +1 -0
- package/lib/components/DataTable/TableSlugRow.js +1 -0
- package/lib/components/Grid/Column.js +3 -3
- 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/MultiSelect/FilterableMultiSelect.js +12 -14
- package/lib/components/MultiSelect/MultiSelect.js +63 -48
- package/lib/components/MultiSelect/tools/sorting.js +5 -8
- package/lib/components/OverflowMenu/OverflowMenu.js +1 -1
- package/lib/components/Popover/index.js +21 -4
- package/lib/components/TreeView/TreeNode.js +41 -33
- package/lib/components/TreeView/TreeView.d.ts +5 -3
- package/lib/index.js +4 -4
- package/lib/internal/Selection.js +30 -18
- package/lib/internal/useMergedRefs.d.ts +1 -1
- package/package.json +23 -20
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
|
-
var PropTypes = require('prop-types');
|
|
14
13
|
var React = require('react');
|
|
14
|
+
var PropTypes = require('prop-types');
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var Button = require('../Button/Button.js');
|
|
17
17
|
require('../Button/Button.Skeleton.js');
|
|
@@ -19,8 +19,8 @@ var usePrefix = require('../../internal/usePrefix.js');
|
|
|
19
19
|
|
|
20
20
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
21
|
|
|
22
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
23
22
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
23
|
+
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
24
24
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
25
25
|
|
|
26
26
|
const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function ChatButton(_ref, ref) {
|
|
@@ -88,12 +88,12 @@ ChatButton.propTypes = {
|
|
|
88
88
|
* Optional prop to specify an icon to be rendered.
|
|
89
89
|
* Can be a React component class
|
|
90
90
|
*/
|
|
91
|
+
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
91
92
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
92
93
|
/**
|
|
93
94
|
* Specify the size of the `ChatButton`, from the following list of sizes:
|
|
94
95
|
*/
|
|
95
96
|
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg'])
|
|
96
97
|
};
|
|
97
|
-
var ChatButton$1 = ChatButton;
|
|
98
98
|
|
|
99
|
-
exports["default"] = ChatButton
|
|
99
|
+
exports["default"] = ChatButton;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 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 ChatButton from './ChatButton';
|
|
8
|
+
import { type ChatButtonProps } from './ChatButton';
|
|
9
|
+
import { type ChatButtonSkeletonProps } from './ChatButton.Skeleton';
|
|
10
|
+
export default ChatButton;
|
|
11
|
+
export { ChatButton, type ChatButtonProps, type ChatButtonSkeletonProps };
|
|
12
|
+
export { default as ChatButtonSkeleton } from './ChatButton.Skeleton';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var Checkbox = require('./Checkbox.js');
|
|
13
|
+
var Checkbox_Skeleton = require('./Checkbox.Skeleton.js');
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
exports.Checkbox = Checkbox["default"];
|
|
18
|
+
exports["default"] = Checkbox["default"];
|
|
19
|
+
exports.CheckboxSkeleton = Checkbox_Skeleton["default"];
|
|
@@ -17,6 +17,8 @@ var React = require('react');
|
|
|
17
17
|
require('../Text/index.js');
|
|
18
18
|
var iconsReact = require('@carbon/icons-react');
|
|
19
19
|
var index = require('../ListBox/index.js');
|
|
20
|
+
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
21
|
+
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
20
22
|
var useId = require('../../internal/useId.js');
|
|
21
23
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
22
24
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
@@ -24,10 +26,9 @@ var usePrefix = require('../../internal/usePrefix.js');
|
|
|
24
26
|
require('../FluidForm/FluidForm.js');
|
|
25
27
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
26
28
|
var react = require('@floating-ui/react');
|
|
29
|
+
var floatingUi_core = require('../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js');
|
|
27
30
|
var Text = require('../Text/Text.js');
|
|
28
31
|
var match = require('../../internal/keyboard/match.js');
|
|
29
|
-
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
30
|
-
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
31
32
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
32
33
|
var keys = require('../../internal/keyboard/keys.js');
|
|
33
34
|
|
|
@@ -138,19 +139,24 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
138
139
|
} = props;
|
|
139
140
|
const {
|
|
140
141
|
refs,
|
|
141
|
-
floatingStyles
|
|
142
|
+
floatingStyles,
|
|
143
|
+
middlewareData
|
|
142
144
|
} = react.useFloating(autoAlign ? {
|
|
143
145
|
placement: direction,
|
|
144
146
|
strategy: 'fixed',
|
|
145
|
-
middleware: [react.flip()],
|
|
147
|
+
middleware: [react.flip(), floatingUi_core.hide()],
|
|
146
148
|
whileElementsMounted: react.autoUpdate
|
|
147
149
|
} : {});
|
|
148
150
|
const parentWidth = refs?.reference?.current?.clientWidth;
|
|
149
151
|
React.useEffect(() => {
|
|
150
152
|
if (autoAlign) {
|
|
151
|
-
|
|
153
|
+
const updatedFloatingStyles = {
|
|
154
|
+
...floatingStyles,
|
|
155
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
156
|
+
};
|
|
157
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
152
158
|
if (refs.floating.current) {
|
|
153
|
-
refs.floating.current.style[style] =
|
|
159
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
154
160
|
}
|
|
155
161
|
});
|
|
156
162
|
if (parentWidth && refs.floating.current) {
|
|
@@ -543,7 +549,6 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
543
549
|
onClearSelection: handleSelectionClear,
|
|
544
550
|
selectionCount: 0
|
|
545
551
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
546
|
-
// @ts-expect-error
|
|
547
552
|
isOpen: isOpen,
|
|
548
553
|
translateWithId: translateWithId
|
|
549
554
|
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index$1) => {
|
|
@@ -24,6 +24,7 @@ var useId = require('../../internal/useId.js');
|
|
|
24
24
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
27
|
+
var floatingUi_core = require('../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js');
|
|
27
28
|
|
|
28
29
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
29
30
|
|
|
@@ -61,7 +62,7 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
61
62
|
const containerRef = React.useRef(null);
|
|
62
63
|
const middlewares = [react.flip({
|
|
63
64
|
crossAxis: false
|
|
64
|
-
})];
|
|
65
|
+
}), floatingUi_core.hide()];
|
|
65
66
|
if (menuAlignment === 'bottom' || menuAlignment === 'top') {
|
|
66
67
|
middlewares.push(react.size({
|
|
67
68
|
apply(_ref2) {
|
|
@@ -99,9 +100,13 @@ const ComboButton = /*#__PURE__*/React__default["default"].forwardRef(function C
|
|
|
99
100
|
handleClose
|
|
100
101
|
} = useAttachedMenu.useAttachedMenu(containerRef);
|
|
101
102
|
React.useLayoutEffect(() => {
|
|
102
|
-
|
|
103
|
+
const updatedFloatingStyles = {
|
|
104
|
+
...floatingStyles,
|
|
105
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
106
|
+
};
|
|
107
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
103
108
|
if (refs.floating.current) {
|
|
104
|
-
refs.floating.current.style[style] =
|
|
109
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
105
110
|
}
|
|
106
111
|
});
|
|
107
112
|
}, [floatingStyles, refs.floating, middlewareData, placement, open]);
|
|
@@ -4,6 +4,8 @@
|
|
|
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 ComposedModal from './ComposedModal';
|
|
7
8
|
export { default as ComposedModal, type ComposedModalProps, ModalBody, type ModalBodyProps, } from './ComposedModal';
|
|
8
9
|
export { ModalHeader, type ModalHeaderProps } from './ModalHeader';
|
|
9
10
|
export { ModalFooter, type ModalFooterProps } from './ModalFooter';
|
|
11
|
+
export default ComposedModal;
|
|
@@ -18,6 +18,7 @@ export interface TableSlugRowProps {
|
|
|
18
18
|
}
|
|
19
19
|
declare const TableSlugRow: {
|
|
20
20
|
({ className, slug }: TableSlugRowProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
displayName: string;
|
|
21
22
|
propTypes: {
|
|
22
23
|
/**
|
|
23
24
|
* The CSS class names of the cell that wraps the underlying input control
|
|
@@ -274,11 +274,11 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
|
|
|
274
274
|
start,
|
|
275
275
|
end
|
|
276
276
|
} = breakpoint;
|
|
277
|
-
if (typeof offset === 'number'
|
|
278
|
-
classNames.push(`${prefix}--${name}:col-start-${offset + 1}`);
|
|
277
|
+
if (typeof offset === 'number') {
|
|
278
|
+
classNames.push(`${prefix}--${name}:col-start-${offset > 0 ? offset + 1 : 'auto'}`);
|
|
279
279
|
}
|
|
280
280
|
if (typeof start === 'number') {
|
|
281
|
-
classNames.push(`${prefix}--${name}:col-start-${start}`);
|
|
281
|
+
classNames.push(`${prefix}--${name}:col-start-${start ? start : 'auto'}`);
|
|
282
282
|
}
|
|
283
283
|
if (typeof end === 'number') {
|
|
284
284
|
classNames.push(`${prefix}--${name}:col-end-${end}`);
|
|
@@ -4,9 +4,14 @@
|
|
|
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, { ForwardedRef } from 'react';
|
|
7
|
+
import React, { ForwardedRef, ReactNode } from 'react';
|
|
8
8
|
import { ForwardRefReturn, ReactAttr } from '../../types/common';
|
|
9
9
|
export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
10
|
+
/**
|
|
11
|
+
* Specify any children nodes that should be rendered inside of the ListBox
|
|
12
|
+
* Menu Item
|
|
13
|
+
*/
|
|
14
|
+
children?: ReactNode;
|
|
10
15
|
/**
|
|
11
16
|
* Specify whether the current menu item is "active".
|
|
12
17
|
*/
|
|
@@ -19,6 +24,10 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
|
19
24
|
* Specify whether the item should be disabled
|
|
20
25
|
*/
|
|
21
26
|
disabled?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Provide an optional tooltip for the ListBoxMenuItem
|
|
29
|
+
*/
|
|
30
|
+
title?: string;
|
|
22
31
|
}
|
|
23
32
|
export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLLIElement> & {
|
|
24
33
|
menuItemOptionRef?: React.Ref<HTMLDivElement>;
|
|
@@ -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';
|
|
@@ -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
|
}
|
|
@@ -544,10 +549,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
544
549
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
545
550
|
className: `${prefix}--list-box__field`,
|
|
546
551
|
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"], {
|
|
552
|
+
}, controlledSelectedItems.length > 0 && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
|
|
551
553
|
clearSelection: () => {
|
|
552
554
|
clearSelection();
|
|
553
555
|
if (textInput.current) {
|
|
@@ -565,10 +567,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
565
567
|
className: `${prefix}--list-box__invalid-icon`
|
|
566
568
|
}), showWarning && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
567
569
|
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"], {
|
|
570
|
+
}), inputValue && /*#__PURE__*/React__default["default"].createElement(ListBoxSelection["default"], {
|
|
572
571
|
clearSelection: clearInputValue,
|
|
573
572
|
disabled: disabled,
|
|
574
573
|
translateWithId: translateWithId,
|
|
@@ -581,7 +580,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
581
580
|
event.stopPropagation();
|
|
582
581
|
}
|
|
583
582
|
}), /*#__PURE__*/React__default["default"].createElement(ListBoxTrigger["default"], _rollupPluginBabelHelpers["extends"]({}, buttonProps, {
|
|
584
|
-
// @ts-expect-error
|
|
585
583
|
isOpen: isOpen,
|
|
586
584
|
translateWithId: translateWithId
|
|
587
585
|
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? sortedItems.map((item, index$1) => {
|