@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
|
@@ -0,0 +1,31 @@
|
|
|
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 PropTypes from 'prop-types';
|
|
8
|
+
export interface ChatButtonSkeletonProps {
|
|
9
|
+
/**
|
|
10
|
+
* Specify an optional className to add.
|
|
11
|
+
*/
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Specify the size of the `ChatButtonSkeleton`, from the following list of sizes:
|
|
15
|
+
*/
|
|
16
|
+
size?: 'sm' | 'md' | 'lg';
|
|
17
|
+
}
|
|
18
|
+
declare const ChatButtonSkeleton: {
|
|
19
|
+
({ className, size, ...rest }: ChatButtonSkeletonProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
propTypes: {
|
|
21
|
+
/**
|
|
22
|
+
* Specify an optional className to add.
|
|
23
|
+
*/
|
|
24
|
+
className: PropTypes.Requireable<string>;
|
|
25
|
+
/**
|
|
26
|
+
* Specify the size of the `ChatButtonSkeleton`, from the following list of sizes:
|
|
27
|
+
*/
|
|
28
|
+
size: PropTypes.Requireable<string>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export default ChatButtonSkeleton;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 React, { type ComponentType, type FunctionComponent } from 'react';
|
|
8
|
+
export type ChatButtonKind = 'primary' | 'secondary' | 'danger' | 'ghost' | 'tertiary';
|
|
9
|
+
export type ChatButtonSize = 'sm' | 'md' | 'lg';
|
|
10
|
+
export interface ChatButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
11
|
+
/**
|
|
12
|
+
* Provide the contents of your Select
|
|
13
|
+
*/
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Specify an optional className to be applied to the node containing the label and the select box
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Specify whether the `ChatButton` should be disabled
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Specify whether the `ChatButton` should be rendered as a quick action button
|
|
25
|
+
*/
|
|
26
|
+
isQuickAction?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Specify whether the quick action `ChatButton` should be rendered as selected. This disables the input
|
|
29
|
+
*/
|
|
30
|
+
isSelected?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Specify the kind of `ChatButton` you want to create
|
|
33
|
+
*/
|
|
34
|
+
kind?: ChatButtonKind;
|
|
35
|
+
/**
|
|
36
|
+
* Optional prop to specify an icon to be rendered.
|
|
37
|
+
* Can be a React component class
|
|
38
|
+
*/
|
|
39
|
+
renderIcon?: ComponentType | FunctionComponent;
|
|
40
|
+
/**
|
|
41
|
+
* Specify the size of the `ChatButton`, from the following list of sizes:
|
|
42
|
+
*/
|
|
43
|
+
size?: ChatButtonSize;
|
|
44
|
+
}
|
|
45
|
+
declare const ChatButton: React.ForwardRefExoticComponent<ChatButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
46
|
+
export default ChatButton;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import PropTypes from 'prop-types';
|
|
10
9
|
import React__default from 'react';
|
|
10
|
+
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import Button from '../Button/Button.js';
|
|
13
13
|
import '../Button/Button.Skeleton.js';
|
|
@@ -78,12 +78,12 @@ ChatButton.propTypes = {
|
|
|
78
78
|
* Optional prop to specify an icon to be rendered.
|
|
79
79
|
* Can be a React component class
|
|
80
80
|
*/
|
|
81
|
+
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
81
82
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
82
83
|
/**
|
|
83
84
|
* Specify the size of the `ChatButton`, from the following list of sizes:
|
|
84
85
|
*/
|
|
85
86
|
size: PropTypes.oneOf(['sm', 'md', 'lg'])
|
|
86
87
|
};
|
|
87
|
-
var ChatButton$1 = ChatButton;
|
|
88
88
|
|
|
89
|
-
export { ChatButton
|
|
89
|
+
export { ChatButton as default };
|
|
@@ -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,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import Checkbox from './Checkbox.js';
|
|
9
|
+
export { default as Checkbox, default } from './Checkbox.js';
|
|
10
|
+
export { default as CheckboxSkeleton } from './Checkbox.Skeleton.js';
|
|
@@ -13,6 +13,8 @@ import React__default, { forwardRef, useEffect, useContext, useRef, useState, us
|
|
|
13
13
|
import '../Text/index.js';
|
|
14
14
|
import { WarningFilled, WarningAltFilled, Checkmark } from '@carbon/icons-react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
16
|
+
import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
|
|
17
|
+
import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
16
18
|
import { useId } from '../../internal/useId.js';
|
|
17
19
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
18
20
|
import deprecate from '../../prop-types/deprecate.js';
|
|
@@ -20,10 +22,9 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
20
22
|
import '../FluidForm/FluidForm.js';
|
|
21
23
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
22
24
|
import { useFloating, flip, autoUpdate } from '@floating-ui/react';
|
|
25
|
+
import { hide } from '../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js';
|
|
23
26
|
import { Text } from '../Text/Text.js';
|
|
24
27
|
import { match } from '../../internal/keyboard/match.js';
|
|
25
|
-
import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
|
|
26
|
-
import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
27
28
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
28
29
|
import { Space, Enter, Escape, Home, End } from '../../internal/keyboard/keys.js';
|
|
29
30
|
|
|
@@ -128,19 +129,24 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
128
129
|
} = props;
|
|
129
130
|
const {
|
|
130
131
|
refs,
|
|
131
|
-
floatingStyles
|
|
132
|
+
floatingStyles,
|
|
133
|
+
middlewareData
|
|
132
134
|
} = useFloating(autoAlign ? {
|
|
133
135
|
placement: direction,
|
|
134
136
|
strategy: 'fixed',
|
|
135
|
-
middleware: [flip()],
|
|
137
|
+
middleware: [flip(), hide()],
|
|
136
138
|
whileElementsMounted: autoUpdate
|
|
137
139
|
} : {});
|
|
138
140
|
const parentWidth = refs?.reference?.current?.clientWidth;
|
|
139
141
|
useEffect(() => {
|
|
140
142
|
if (autoAlign) {
|
|
141
|
-
|
|
143
|
+
const updatedFloatingStyles = {
|
|
144
|
+
...floatingStyles,
|
|
145
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
146
|
+
};
|
|
147
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
142
148
|
if (refs.floating.current) {
|
|
143
|
-
refs.floating.current.style[style] =
|
|
149
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
144
150
|
}
|
|
145
151
|
});
|
|
146
152
|
if (parentWidth && refs.floating.current) {
|
|
@@ -533,7 +539,6 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
533
539
|
onClearSelection: handleSelectionClear,
|
|
534
540
|
selectionCount: 0
|
|
535
541
|
}), /*#__PURE__*/React__default.createElement(ListBoxTrigger, _extends({}, buttonProps, {
|
|
536
|
-
// @ts-expect-error
|
|
537
542
|
isOpen: isOpen,
|
|
538
543
|
translateWithId: translateWithId
|
|
539
544
|
}))), normalizedSlug, /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
@@ -20,6 +20,7 @@ import { useId } from '../../internal/useId.js';
|
|
|
20
20
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
21
21
|
import { flip, size, useFloating, autoUpdate } from '@floating-ui/react';
|
|
22
22
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
23
|
+
import { hide } from '../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js';
|
|
23
24
|
|
|
24
25
|
var _ChevronDown;
|
|
25
26
|
const defaultTranslations = {
|
|
@@ -51,7 +52,7 @@ const ComboButton = /*#__PURE__*/React__default.forwardRef(function ComboButton(
|
|
|
51
52
|
const containerRef = useRef(null);
|
|
52
53
|
const middlewares = [flip({
|
|
53
54
|
crossAxis: false
|
|
54
|
-
})];
|
|
55
|
+
}), hide()];
|
|
55
56
|
if (menuAlignment === 'bottom' || menuAlignment === 'top') {
|
|
56
57
|
middlewares.push(size({
|
|
57
58
|
apply(_ref2) {
|
|
@@ -89,9 +90,13 @@ const ComboButton = /*#__PURE__*/React__default.forwardRef(function ComboButton(
|
|
|
89
90
|
handleClose
|
|
90
91
|
} = useAttachedMenu(containerRef);
|
|
91
92
|
useLayoutEffect(() => {
|
|
92
|
-
|
|
93
|
+
const updatedFloatingStyles = {
|
|
94
|
+
...floatingStyles,
|
|
95
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
96
|
+
};
|
|
97
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
93
98
|
if (refs.floating.current) {
|
|
94
|
-
refs.floating.current.style[style] =
|
|
99
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
95
100
|
}
|
|
96
101
|
});
|
|
97
102
|
}, [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
|
|
@@ -245,11 +245,11 @@ function getClassNameForBreakpoints(breakpoints, prefix) {
|
|
|
245
245
|
start,
|
|
246
246
|
end
|
|
247
247
|
} = breakpoint;
|
|
248
|
-
if (typeof offset === 'number'
|
|
249
|
-
classNames.push(`${prefix}--${name}:col-start-${offset + 1}`);
|
|
248
|
+
if (typeof offset === 'number') {
|
|
249
|
+
classNames.push(`${prefix}--${name}:col-start-${offset > 0 ? offset + 1 : 'auto'}`);
|
|
250
250
|
}
|
|
251
251
|
if (typeof start === 'number') {
|
|
252
|
-
classNames.push(`${prefix}--${name}:col-start-${start}`);
|
|
252
|
+
classNames.push(`${prefix}--${name}:col-start-${start ? start : 'auto'}`);
|
|
253
253
|
}
|
|
254
254
|
if (typeof end === 'number') {
|
|
255
255
|
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;
|
|
@@ -13,22 +13,13 @@ import { Close } from '@carbon/icons-react';
|
|
|
13
13
|
import { usePrefix } from '../../../internal/usePrefix.js';
|
|
14
14
|
|
|
15
15
|
var _Close, _Close2;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* `ListBoxSelection` is used to provide controls for clearing a selection, in
|
|
19
|
-
* addition to conditionally rendering a badge if the control has more than one
|
|
20
|
-
* selection.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
const translationIds = {
|
|
24
|
-
'clear.all': 'clear.all',
|
|
25
|
-
'clear.selection': 'clear.selection'
|
|
26
|
-
};
|
|
27
16
|
const defaultTranslations = {
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
'clear.all': 'Clear all selected items',
|
|
18
|
+
'clear.selection': 'Clear selected item'
|
|
30
19
|
};
|
|
31
|
-
|
|
20
|
+
function defaultTranslateWithId(id) {
|
|
21
|
+
return defaultTranslations[id];
|
|
22
|
+
}
|
|
32
23
|
function ListBoxSelection(_ref) {
|
|
33
24
|
let {
|
|
34
25
|
clearSelection,
|
|
@@ -62,7 +53,7 @@ function ListBoxSelection(_ref) {
|
|
|
62
53
|
className: tagClasses
|
|
63
54
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
64
55
|
className: `${prefix}--tag__label`,
|
|
65
|
-
title: selectionCount
|
|
56
|
+
title: selectionCount?.toString()
|
|
66
57
|
}, selectionCount), /*#__PURE__*/React__default.createElement("button", {
|
|
67
58
|
"aria-label": description,
|
|
68
59
|
className: `${prefix}--tag__close-icon`,
|
|
@@ -103,6 +94,11 @@ ListBoxSelection.propTypes = {
|
|
|
103
94
|
* clear selection element is clicked
|
|
104
95
|
*/
|
|
105
96
|
onClick: PropTypes.func,
|
|
97
|
+
/**
|
|
98
|
+
* Specify an optional `onClick` handler that is called when the underlying
|
|
99
|
+
* clear selection element is clicked
|
|
100
|
+
*/
|
|
101
|
+
onMouseUp: PropTypes.func,
|
|
106
102
|
/**
|
|
107
103
|
* Specify an optional `onKeyDown` handler that is called when the underlying
|
|
108
104
|
* clear selection element fires a keydown event
|
|
@@ -121,4 +117,4 @@ ListBoxSelection.propTypes = {
|
|
|
121
117
|
translateWithId: PropTypes.func
|
|
122
118
|
};
|
|
123
119
|
|
|
124
|
-
export { ListBoxSelection as default
|
|
120
|
+
export { ListBoxSelection as default };
|
|
@@ -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;
|
|
@@ -22,7 +22,6 @@ const defaultTranslations = {
|
|
|
22
22
|
[translationIds['open.menu']]: 'Open'
|
|
23
23
|
};
|
|
24
24
|
const defaultTranslateWithId = id => defaultTranslations[id];
|
|
25
|
-
|
|
26
25
|
/**
|
|
27
26
|
* `ListBoxTrigger` is used to orient the icon up or down depending on the
|
|
28
27
|
* state of the menu for a given `ListBox`
|
|
@@ -45,7 +44,7 @@ const ListBoxTrigger = /*#__PURE__*/React__default.forwardRef(function ListBoxTr
|
|
|
45
44
|
title: description,
|
|
46
45
|
className: className,
|
|
47
46
|
type: "button",
|
|
48
|
-
tabIndex:
|
|
47
|
+
tabIndex: -1,
|
|
49
48
|
ref: ref
|
|
50
49
|
}), _ChevronDown || (_ChevronDown = /*#__PURE__*/React__default.createElement(ChevronDown, null)));
|
|
51
50
|
});
|
|
@@ -62,6 +61,5 @@ ListBoxTrigger.propTypes = {
|
|
|
62
61
|
*/
|
|
63
62
|
translateWithId: PropTypes.func
|
|
64
63
|
};
|
|
65
|
-
var ListBoxTrigger$1 = ListBoxTrigger;
|
|
66
64
|
|
|
67
|
-
export { ListBoxTrigger
|
|
65
|
+
export { ListBoxTrigger as default, 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';
|
|
@@ -15,6 +15,8 @@ import React__default, { useContext, useState, useLayoutEffect, useRef, useMemo,
|
|
|
15
15
|
import { defaultFilterItems } from '../ComboBox/tools/filter.js';
|
|
16
16
|
import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
17
17
|
import ListBox from '../ListBox/index.js';
|
|
18
|
+
import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
|
|
19
|
+
import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
18
20
|
import { defaultItemToString } from './tools/itemToString.js';
|
|
19
21
|
import mergeRefs from '../../tools/mergeRefs.js';
|
|
20
22
|
import deprecate from '../../prop-types/deprecate.js';
|
|
@@ -25,9 +27,8 @@ import '../FluidForm/FluidForm.js';
|
|
|
25
27
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
26
28
|
import { useSelection } from '../../internal/Selection.js';
|
|
27
29
|
import { useFloating, flip, size, autoUpdate } from '@floating-ui/react';
|
|
30
|
+
import { hide } from '../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js';
|
|
28
31
|
import { match } from '../../internal/keyboard/match.js';
|
|
29
|
-
import ListBoxSelection from '../ListBox/next/ListBoxSelection.js';
|
|
30
|
-
import ListBoxTrigger from '../ListBox/next/ListBoxTrigger.js';
|
|
31
32
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
32
33
|
import { Escape, Space, Enter, Delete, Tab, Home, End } from '../../internal/keyboard/keys.js';
|
|
33
34
|
|
|
@@ -144,14 +145,18 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
144
145
|
width: `${rects.reference.width}px`
|
|
145
146
|
});
|
|
146
147
|
}
|
|
147
|
-
})],
|
|
148
|
+
}), hide()],
|
|
148
149
|
whileElementsMounted: autoUpdate
|
|
149
150
|
} : {});
|
|
150
151
|
useLayoutEffect(() => {
|
|
151
152
|
if (autoAlign) {
|
|
152
|
-
|
|
153
|
+
const updatedFloatingStyles = {
|
|
154
|
+
...floatingStyles,
|
|
155
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
156
|
+
};
|
|
157
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
153
158
|
if (refs.floating.current) {
|
|
154
|
-
refs.floating.current.style[style] =
|
|
159
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
155
160
|
}
|
|
156
161
|
});
|
|
157
162
|
}
|
|
@@ -532,10 +537,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
532
537
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
533
538
|
className: `${prefix}--list-box__field`,
|
|
534
539
|
ref: autoAlign ? refs.setReference : null
|
|
535
|
-
}, controlledSelectedItems.length > 0 &&
|
|
536
|
-
/*#__PURE__*/
|
|
537
|
-
// @ts-expect-error: It is expecting a non-required prop called: "onClearSelection"
|
|
538
|
-
React__default.createElement(ListBoxSelection, {
|
|
540
|
+
}, controlledSelectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
539
541
|
clearSelection: () => {
|
|
540
542
|
clearSelection();
|
|
541
543
|
if (textInput.current) {
|
|
@@ -553,10 +555,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
553
555
|
className: `${prefix}--list-box__invalid-icon`
|
|
554
556
|
}), showWarning && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
555
557
|
className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
|
|
556
|
-
}), inputValue &&
|
|
557
|
-
/*#__PURE__*/
|
|
558
|
-
// @ts-expect-error: It is expecting two non-required prop called: "onClearSelection" & "selectionCount"
|
|
559
|
-
React__default.createElement(ListBoxSelection, {
|
|
558
|
+
}), inputValue && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
560
559
|
clearSelection: clearInputValue,
|
|
561
560
|
disabled: disabled,
|
|
562
561
|
translateWithId: translateWithId,
|
|
@@ -569,7 +568,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
569
568
|
event.stopPropagation();
|
|
570
569
|
}
|
|
571
570
|
}), /*#__PURE__*/React__default.createElement(ListBoxTrigger, _extends({}, buttonProps, {
|
|
572
|
-
// @ts-expect-error
|
|
573
571
|
isOpen: isOpen,
|
|
574
572
|
translateWithId: translateWithId
|
|
575
573
|
}))), normalizedSlug, /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|