@carbon/react 1.36.0 → 1.37.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/es/components/ComboBox/ComboBox.js +2 -4
- package/es/components/DataTable/DataTable.d.ts +26 -0
- package/es/components/DataTable/DataTable.js +25 -0
- package/es/components/DataTable/TableExpandHeader.d.ts +27 -5
- package/es/components/DataTable/TableExpandHeader.js +17 -3
- package/es/components/DataTable/TableExpandRow.d.ts +24 -3
- package/es/components/DataTable/TableExpandRow.js +18 -3
- package/es/components/DataTable/TableRow.js +1 -1
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +40 -40
- package/es/components/ListBox/ListBoxMenu.d.ts +2 -2
- package/es/components/ListBox/ListBoxMenu.js +1 -1
- package/es/components/ListBox/ListBoxMenuItem.d.ts +6 -2
- package/es/components/ListBox/ListBoxMenuItem.js +6 -3
- package/es/components/MultiSelect/FilterableMultiSelect.js +24 -4
- package/es/components/MultiSelect/MultiSelect.js +77 -56
- package/es/components/NumberInput/NumberInput.d.ts +1 -1
- package/es/components/NumberInput/NumberInput.js +18 -44
- package/es/components/Slider/Slider.d.ts +6 -0
- package/es/components/Slider/Slider.js +17 -2
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/Tile/Tile.js +5 -5
- package/lib/components/ComboBox/ComboBox.js +2 -4
- package/lib/components/DataTable/DataTable.d.ts +26 -0
- package/lib/components/DataTable/DataTable.js +25 -0
- package/lib/components/DataTable/TableExpandHeader.d.ts +27 -5
- package/lib/components/DataTable/TableExpandHeader.js +17 -3
- package/lib/components/DataTable/TableExpandRow.d.ts +24 -3
- package/lib/components/DataTable/TableExpandRow.js +18 -3
- package/lib/components/DataTable/TableRow.js +1 -1
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +39 -39
- package/lib/components/ListBox/ListBoxMenu.d.ts +2 -2
- package/lib/components/ListBox/ListBoxMenu.js +1 -1
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +6 -2
- package/lib/components/ListBox/ListBoxMenuItem.js +6 -3
- package/lib/components/MultiSelect/FilterableMultiSelect.js +24 -4
- package/lib/components/MultiSelect/MultiSelect.js +75 -55
- package/lib/components/NumberInput/NumberInput.d.ts +1 -1
- package/lib/components/NumberInput/NumberInput.js +18 -44
- package/lib/components/Slider/Slider.d.ts +6 -0
- package/lib/components/Slider/Slider.js +17 -2
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/Tile/Tile.js +5 -5
- package/package.json +3 -3
|
@@ -8,11 +8,21 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { ReactAttr } from '../../types/common';
|
|
10
10
|
type TableExpandHeaderPropsBase = {
|
|
11
|
+
/**
|
|
12
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
|
|
13
|
+
*/
|
|
14
|
+
['aria-controls']: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated This prop has been deprecated and will be
|
|
17
|
+
* removed in the next major release of Carbon. Use the
|
|
18
|
+
* `aria-label` prop instead.
|
|
19
|
+
*/
|
|
20
|
+
ariaLabel?: string;
|
|
11
21
|
/**
|
|
12
22
|
* Specify the string read by a voice reader when the expand trigger is
|
|
13
23
|
* focused
|
|
14
24
|
*/
|
|
15
|
-
|
|
25
|
+
['aria-label']: string;
|
|
16
26
|
/**
|
|
17
27
|
* @deprecated The enableExpando prop is being replaced by `enableToggle`
|
|
18
28
|
*/
|
|
@@ -35,25 +45,37 @@ type TableExpandHeaderPropsBase = {
|
|
|
35
45
|
*/
|
|
36
46
|
onExpand?(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
37
47
|
} & ReactAttr<HTMLTableCellElement>;
|
|
38
|
-
type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'enableToggle' | 'onExpand'> & {
|
|
48
|
+
type TableExpandHeaderPropsWithToggle = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableToggle' | 'onExpand'> & {
|
|
39
49
|
enableToggle: true;
|
|
40
50
|
ariaLabel: string;
|
|
51
|
+
['aria-label']: string;
|
|
41
52
|
onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
42
53
|
};
|
|
43
|
-
type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'enableExpando' | 'onExpand'> & {
|
|
54
|
+
type TableExpandHeaderPropsWithExpando = Omit<TableExpandHeaderPropsBase, 'ariaLabel' | 'aria-label' | 'enableExpando' | 'onExpand'> & {
|
|
44
55
|
enableExpando: true;
|
|
45
56
|
ariaLabel: string;
|
|
57
|
+
['aria-label']: string;
|
|
46
58
|
onExpand(event: React.MouseEvent<HTMLButtonElement>): void;
|
|
47
59
|
};
|
|
48
60
|
export type TableExpandHeaderProps = TableExpandHeaderPropsWithToggle | TableExpandHeaderPropsWithExpando | TableExpandHeaderPropsBase;
|
|
49
61
|
declare const TableExpandHeader: {
|
|
50
|
-
({ ariaLabel, className: headerClassName, enableExpando, enableToggle, id, isExpanded, onExpand, expandIconDescription, children, ...rest }: TableExpandHeaderProps): JSX.Element;
|
|
62
|
+
({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: headerClassName, enableExpando, enableToggle, id, isExpanded, onExpand, expandIconDescription, children, ...rest }: TableExpandHeaderProps): JSX.Element;
|
|
51
63
|
propTypes: {
|
|
52
64
|
/**
|
|
65
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
|
|
66
|
+
*/
|
|
67
|
+
"aria-controls": PropTypes.Requireable<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
70
|
+
* focused
|
|
71
|
+
*/
|
|
72
|
+
"aria-label": PropTypes.Requireable<string>;
|
|
73
|
+
/**
|
|
74
|
+
* Deprecated, please use `aria-label` instead.
|
|
53
75
|
* Specify the string read by a voice reader when the expand trigger is
|
|
54
76
|
* focused
|
|
55
77
|
*/
|
|
56
|
-
ariaLabel: PropTypes.Requireable<
|
|
78
|
+
ariaLabel: PropTypes.Requireable<string>;
|
|
57
79
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
58
80
|
className: PropTypes.Requireable<string>;
|
|
59
81
|
/**
|
|
@@ -26,7 +26,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
26
26
|
|
|
27
27
|
const TableExpandHeader = _ref => {
|
|
28
28
|
let {
|
|
29
|
-
|
|
29
|
+
['aria-controls']: ariaControls,
|
|
30
|
+
['aria-label']: ariaLabel,
|
|
31
|
+
ariaLabel: deprecatedAriaLabel,
|
|
30
32
|
className: headerClassName,
|
|
31
33
|
enableExpando,
|
|
32
34
|
enableToggle,
|
|
@@ -50,7 +52,9 @@ const TableExpandHeader = _ref => {
|
|
|
50
52
|
className: `${prefix}--table-expand__button`,
|
|
51
53
|
onClick: onExpand,
|
|
52
54
|
title: expandIconDescription,
|
|
53
|
-
"aria-label": ariaLabel
|
|
55
|
+
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
56
|
+
"aria-expanded": isExpanded,
|
|
57
|
+
"aria-controls": ariaControls
|
|
54
58
|
}, /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronRight, {
|
|
55
59
|
className: `${prefix}--table-expand__svg`,
|
|
56
60
|
"aria-label": expandIconDescription
|
|
@@ -58,10 +62,20 @@ const TableExpandHeader = _ref => {
|
|
|
58
62
|
};
|
|
59
63
|
TableExpandHeader.propTypes = {
|
|
60
64
|
/**
|
|
65
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandHeader
|
|
66
|
+
*/
|
|
67
|
+
['aria-controls']: PropTypes__default["default"].string,
|
|
68
|
+
/**
|
|
69
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
70
|
+
* focused
|
|
71
|
+
*/
|
|
72
|
+
['aria-label']: PropTypes__default["default"].string,
|
|
73
|
+
/**
|
|
74
|
+
* Deprecated, please use `aria-label` instead.
|
|
61
75
|
* Specify the string read by a voice reader when the expand trigger is
|
|
62
76
|
* focused
|
|
63
77
|
*/
|
|
64
|
-
ariaLabel: PropTypes__default["default"].
|
|
78
|
+
ariaLabel: PropTypes__default["default"].string,
|
|
65
79
|
children: PropTypes__default["default"].node,
|
|
66
80
|
className: PropTypes__default["default"].string,
|
|
67
81
|
/**
|
|
@@ -8,11 +8,21 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { MouseEventHandler, PropsWithChildren } from 'react';
|
|
9
9
|
import { TableRowProps } from './TableRow';
|
|
10
10
|
interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
|
|
11
|
+
/**
|
|
12
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
13
|
+
*/
|
|
14
|
+
['aria-controls']: string;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated This prop has been deprecated and will be
|
|
17
|
+
* removed in the next major release of Carbon. Use the
|
|
18
|
+
* `aria-label` prop instead.
|
|
19
|
+
*/
|
|
20
|
+
ariaLabel?: string;
|
|
11
21
|
/**
|
|
12
22
|
* Specify the string read by a voice reader when the expand trigger is
|
|
13
23
|
* focused
|
|
14
24
|
*/
|
|
15
|
-
|
|
25
|
+
['aria-label']: string;
|
|
16
26
|
/**
|
|
17
27
|
* The id of the matching th node in the table head. Addresses a11y concerns outlined here: https://www.ibm.com/able/guidelines/ci162/info_and_relationships.html and https://www.w3.org/TR/WCAG20-TECHS/H43
|
|
18
28
|
*/
|
|
@@ -32,13 +42,24 @@ interface TableExpandRowProps extends PropsWithChildren<TableRowProps> {
|
|
|
32
42
|
onExpand: MouseEventHandler<HTMLButtonElement>;
|
|
33
43
|
}
|
|
34
44
|
declare const TableExpandRow: {
|
|
35
|
-
({ ariaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
|
|
45
|
+
({ ["aria-controls"]: ariaControls, ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, className: rowClassName, children, isExpanded, onExpand, expandIconDescription, isSelected, expandHeader, ...rest }: TableExpandRowProps): JSX.Element;
|
|
36
46
|
propTypes: {
|
|
37
47
|
/**
|
|
48
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
49
|
+
* TODO: make this required in v12
|
|
50
|
+
*/
|
|
51
|
+
"aria-controls": PropTypes.Requireable<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
54
|
+
* focused
|
|
55
|
+
*/
|
|
56
|
+
"aria-label": PropTypes.Requireable<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Deprecated, please use `aria-label` instead.
|
|
38
59
|
* Specify the string read by a voice reader when the expand trigger is
|
|
39
60
|
* focused
|
|
40
61
|
*/
|
|
41
|
-
ariaLabel: PropTypes.
|
|
62
|
+
ariaLabel: PropTypes.Requireable<string>;
|
|
42
63
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
43
64
|
className: PropTypes.Requireable<string>;
|
|
44
65
|
/**
|
|
@@ -25,7 +25,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
25
25
|
|
|
26
26
|
const TableExpandRow = _ref => {
|
|
27
27
|
let {
|
|
28
|
-
|
|
28
|
+
['aria-controls']: ariaControls,
|
|
29
|
+
['aria-label']: ariaLabel,
|
|
30
|
+
ariaLabel: deprecatedAriaLabel,
|
|
29
31
|
className: rowClassName,
|
|
30
32
|
children,
|
|
31
33
|
isExpanded,
|
|
@@ -54,7 +56,9 @@ const TableExpandRow = _ref => {
|
|
|
54
56
|
className: `${prefix}--table-expand__button`,
|
|
55
57
|
onClick: onExpand,
|
|
56
58
|
title: expandIconDescription,
|
|
57
|
-
"aria-label": ariaLabel
|
|
59
|
+
"aria-label": deprecatedAriaLabel || ariaLabel,
|
|
60
|
+
"aria-expanded": isExpanded,
|
|
61
|
+
"aria-controls": ariaControls
|
|
58
62
|
}, /*#__PURE__*/React__default["default"].createElement(iconsReact.ChevronRight, {
|
|
59
63
|
className: `${prefix}--table-expand__svg`,
|
|
60
64
|
"aria-label": expandIconDescription
|
|
@@ -62,10 +66,21 @@ const TableExpandRow = _ref => {
|
|
|
62
66
|
};
|
|
63
67
|
TableExpandRow.propTypes = {
|
|
64
68
|
/**
|
|
69
|
+
* Space separated list of one or more ID values referencing the TableExpandedRow(s) being controlled by the TableExpandRow
|
|
70
|
+
* TODO: make this required in v12
|
|
71
|
+
*/
|
|
72
|
+
['aria-controls']: PropTypes__default["default"].string,
|
|
73
|
+
/**
|
|
74
|
+
* Specify the string read by a voice reader when the expand trigger is
|
|
75
|
+
* focused
|
|
76
|
+
*/
|
|
77
|
+
['aria-label']: PropTypes__default["default"].string,
|
|
78
|
+
/**
|
|
79
|
+
* Deprecated, please use `aria-label` instead.
|
|
65
80
|
* Specify the string read by a voice reader when the expand trigger is
|
|
66
81
|
* focused
|
|
67
82
|
*/
|
|
68
|
-
ariaLabel: PropTypes__default["default"].string
|
|
83
|
+
ariaLabel: PropTypes__default["default"].string,
|
|
69
84
|
children: PropTypes__default["default"].node,
|
|
70
85
|
className: PropTypes__default["default"].string,
|
|
71
86
|
/**
|
|
@@ -30,7 +30,7 @@ const TableRow = props => {
|
|
|
30
30
|
[`${prefix}--data-table--selected`]: props.isSelected
|
|
31
31
|
});
|
|
32
32
|
const cleanProps = {
|
|
33
|
-
...omit__default["default"](props, ['ariaLabel', 'onExpand', 'isExpanded', 'isSelected']),
|
|
33
|
+
...omit__default["default"](props, ['ariaLabel', 'aria-label', 'aria-controls', 'onExpand', 'isExpanded', 'isSelected']),
|
|
34
34
|
className: className || undefined
|
|
35
35
|
};
|
|
36
36
|
return /*#__PURE__*/React__default["default"].createElement("tr", cleanProps);
|
|
@@ -71,7 +71,7 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
71
71
|
* given item to a string label. By default, it extracts the `label` field
|
|
72
72
|
* from a given item to serve as the item label in the list.
|
|
73
73
|
*/
|
|
74
|
-
itemToString?(item: ItemType): string;
|
|
74
|
+
itemToString?(item: ItemType | null): string;
|
|
75
75
|
/**
|
|
76
76
|
* We try to stay as generic as possible here to allow individuals to pass
|
|
77
77
|
* in a collection of whatever kind of data structure they prefer
|
|
@@ -32,11 +32,11 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
32
32
|
|
|
33
33
|
const getInstanceId = setupGetInstanceId["default"]();
|
|
34
34
|
const {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
ToggleButtonKeyDownArrowDown,
|
|
36
|
+
ToggleButtonKeyDownArrowUp,
|
|
37
|
+
ToggleButtonKeyDownHome,
|
|
38
|
+
ToggleButtonKeyDownEnd,
|
|
39
|
+
ItemMouseMove
|
|
40
40
|
} = Downshift.useSelect.stateChangeTypes;
|
|
41
41
|
const defaultItemToString = item => {
|
|
42
42
|
if (typeof item === 'string') {
|
|
@@ -82,7 +82,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
82
82
|
...other
|
|
83
83
|
} = _ref;
|
|
84
84
|
const prefix = usePrefix.usePrefix();
|
|
85
|
-
const [highlightedIndex, setHighlightedIndex] = React.useState();
|
|
86
85
|
const {
|
|
87
86
|
isFluid
|
|
88
87
|
} = React.useContext(FormContext.FormContext);
|
|
@@ -90,31 +89,43 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
90
89
|
...downshiftProps,
|
|
91
90
|
items,
|
|
92
91
|
itemToString,
|
|
93
|
-
highlightedIndex,
|
|
94
92
|
initialSelectedItem,
|
|
95
93
|
onSelectedItemChange,
|
|
96
|
-
|
|
94
|
+
stateReducer,
|
|
95
|
+
isItemDisabled(item, _index) {
|
|
96
|
+
const isObject = item !== null && typeof item === 'object';
|
|
97
|
+
return isObject && 'disabled' in item && item.disabled === true;
|
|
98
|
+
}
|
|
97
99
|
};
|
|
98
100
|
const {
|
|
99
101
|
current: dropdownInstanceId
|
|
100
102
|
} = React.useRef(getInstanceId());
|
|
101
|
-
function
|
|
103
|
+
function stateReducer(state, actionAndChanges) {
|
|
102
104
|
const {
|
|
105
|
+
changes,
|
|
106
|
+
props,
|
|
103
107
|
type
|
|
108
|
+
} = actionAndChanges;
|
|
109
|
+
const {
|
|
110
|
+
highlightedIndex
|
|
104
111
|
} = changes;
|
|
105
112
|
switch (type) {
|
|
106
|
-
case
|
|
107
|
-
case
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
case ToggleButtonKeyDownArrowDown:
|
|
114
|
+
case ToggleButtonKeyDownArrowUp:
|
|
115
|
+
case ToggleButtonKeyDownHome:
|
|
116
|
+
case ToggleButtonKeyDownEnd:
|
|
117
|
+
if (highlightedIndex > -1) {
|
|
118
|
+
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
119
|
+
props.scrollIntoView(itemArray[highlightedIndex]);
|
|
120
|
+
}
|
|
121
|
+
return changes;
|
|
122
|
+
case ItemMouseMove:
|
|
123
|
+
return {
|
|
124
|
+
...changes,
|
|
125
|
+
highlightedIndex: state.highlightedIndex
|
|
126
|
+
};
|
|
117
127
|
}
|
|
128
|
+
return changes;
|
|
118
129
|
}
|
|
119
130
|
|
|
120
131
|
// only set selectedItem if the prop is defined. Setting if it is undefined
|
|
@@ -128,7 +139,8 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
128
139
|
getLabelProps,
|
|
129
140
|
getMenuProps,
|
|
130
141
|
getItemProps,
|
|
131
|
-
selectedItem
|
|
142
|
+
selectedItem,
|
|
143
|
+
highlightedIndex
|
|
132
144
|
} = Downshift.useSelect(selectProps);
|
|
133
145
|
const inline = type === 'inline';
|
|
134
146
|
const showWarning = !invalid && warn;
|
|
@@ -172,14 +184,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
172
184
|
let {
|
|
173
185
|
selectedItem
|
|
174
186
|
} = _ref2;
|
|
175
|
-
setIsFocused(false);
|
|
176
187
|
if (onChange) {
|
|
177
188
|
onChange({
|
|
178
189
|
selectedItem: selectedItem ?? null
|
|
179
190
|
});
|
|
180
191
|
}
|
|
181
192
|
}
|
|
182
|
-
const menuItemOptionRefs = React.useRef(items.map(_ => /*#__PURE__*/React__default["default"].createRef()));
|
|
183
193
|
const handleFocus = evt => {
|
|
184
194
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
185
195
|
};
|
|
@@ -210,10 +220,6 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
210
220
|
setIsTyping(true);
|
|
211
221
|
}
|
|
212
222
|
if (isTyping && evt.code === 'Space' || !['ArrowDown', 'ArrowUp', ' ', 'Enter'].includes(evt.key)) {
|
|
213
|
-
if (evt.code === 'Space') {
|
|
214
|
-
evt.preventDefault();
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
223
|
if (currTimer) {
|
|
218
224
|
clearTimeout(currTimer);
|
|
219
225
|
}
|
|
@@ -221,7 +227,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
221
227
|
setIsTyping(false);
|
|
222
228
|
}, 3000));
|
|
223
229
|
}
|
|
224
|
-
toggleButtonProps.onKeyDown
|
|
230
|
+
if (toggleButtonProps.onKeyDown) {
|
|
231
|
+
toggleButtonProps.onKeyDown(evt);
|
|
232
|
+
}
|
|
225
233
|
}
|
|
226
234
|
};
|
|
227
235
|
const menuProps = getMenuProps();
|
|
@@ -250,16 +258,12 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
250
258
|
type: "button"
|
|
251
259
|
// aria-expanded is already being passed through {...toggleButtonProps}
|
|
252
260
|
,
|
|
253
|
-
role: "combobox" // eslint-disable-line jsx-a11y/role-has-required-aria-props
|
|
254
|
-
,
|
|
255
|
-
"aria-owns": getMenuProps().id,
|
|
256
|
-
"aria-controls": getMenuProps().id,
|
|
257
261
|
className: `${prefix}--list-box__field`,
|
|
258
262
|
disabled: disabled,
|
|
259
263
|
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
260
264
|
,
|
|
261
265
|
"aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
|
|
262
|
-
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : label
|
|
266
|
+
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString(label)
|
|
263
267
|
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
264
268
|
ref: mergedRef
|
|
265
269
|
}), /*#__PURE__*/React__default["default"].createElement("span", {
|
|
@@ -269,11 +273,9 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
269
273
|
translateWithId: translateWithId
|
|
270
274
|
})), /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen && items.map((item, index$1) => {
|
|
271
275
|
const isObject = item !== null && typeof item === 'object';
|
|
272
|
-
const disabled = isObject && 'disabled' in item && item.disabled === true;
|
|
273
276
|
const itemProps = getItemProps({
|
|
274
277
|
item,
|
|
275
|
-
index: index$1
|
|
276
|
-
disabled
|
|
278
|
+
index: index$1
|
|
277
279
|
});
|
|
278
280
|
const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
|
|
279
281
|
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -281,9 +283,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref) =
|
|
|
281
283
|
isActive: selectedItem === item,
|
|
282
284
|
isHighlighted: highlightedIndex === index$1,
|
|
283
285
|
title: title,
|
|
284
|
-
|
|
285
|
-
menuItemOptionRef: menuItemOptionRefs.current[index$1]
|
|
286
|
-
}
|
|
286
|
+
disabled: itemProps['aria-disabled']
|
|
287
287
|
}, itemProps), typeof item === 'object' && ItemToElement !== undefined && ItemToElement !== null ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
|
|
288
288
|
key: itemProps.id
|
|
289
289
|
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React__default["default"].createElement(iconsReact.Checkmark, {
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { ForwardRefReturn, ReactAttr } from '../../types/common';
|
|
8
8
|
type ExcludedAttributes = 'id';
|
|
9
|
-
export interface ListBoxMenuProps extends Omit<ReactAttr<
|
|
9
|
+
export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, ExcludedAttributes> {
|
|
10
10
|
/**
|
|
11
11
|
* Specify a custom `id`
|
|
12
12
|
*/
|
|
13
13
|
id: string;
|
|
14
14
|
}
|
|
15
|
-
export type ListBoxMenuComponent = ForwardRefReturn<
|
|
15
|
+
export type ListBoxMenuComponent = ForwardRefReturn<HTMLUListElement, ListBoxMenuProps>;
|
|
16
16
|
/**
|
|
17
17
|
* `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
|
|
18
18
|
* class into a single component. It is also being used to validate given
|
|
@@ -32,7 +32,7 @@ const ListBoxMenu = /*#__PURE__*/React__default["default"].forwardRef(function L
|
|
|
32
32
|
...rest
|
|
33
33
|
} = _ref;
|
|
34
34
|
const prefix = usePrefix.usePrefix();
|
|
35
|
-
return /*#__PURE__*/React__default["default"].createElement("
|
|
35
|
+
return /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
|
|
36
36
|
ref: ref,
|
|
37
37
|
id: id,
|
|
38
38
|
className: `${prefix}--list-box__menu`,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import React, { ForwardedRef } from 'react';
|
|
8
8
|
import { ForwardRefReturn, ReactAttr } from '../../types/common';
|
|
9
|
-
export interface ListBoxMenuItemProps extends ReactAttr<
|
|
9
|
+
export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
10
10
|
/**
|
|
11
11
|
* Specify whether the current menu item is "active".
|
|
12
12
|
*/
|
|
@@ -15,8 +15,12 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLDivElement> {
|
|
|
15
15
|
* Specify whether the current menu item is "highlighted".
|
|
16
16
|
*/
|
|
17
17
|
isHighlighted?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Specify whether the item should be disabled
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
18
22
|
}
|
|
19
|
-
export type ListBoxMenuItemForwardedRef = (ForwardedRef<
|
|
23
|
+
export type ListBoxMenuItemForwardedRef = (ForwardedRef<HTMLLIElement> & {
|
|
20
24
|
menuItemOptionRef?: React.Ref<HTMLDivElement>;
|
|
21
25
|
}) | null;
|
|
22
26
|
export type ListBoxMenuItemComponent = ForwardRefReturn<ListBoxMenuItemForwardedRef, ListBoxMenuItemProps>;
|
|
@@ -52,10 +52,9 @@ const ListBoxMenuItem = /*#__PURE__*/React__default["default"].forwardRef(functi
|
|
|
52
52
|
[`${prefix}--list-box__menu-item--active`]: isActive,
|
|
53
53
|
[`${prefix}--list-box__menu-item--highlighted`]: isHighlighted
|
|
54
54
|
});
|
|
55
|
-
return /*#__PURE__*/React__default["default"].createElement("
|
|
55
|
+
return /*#__PURE__*/React__default["default"].createElement("li", _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
56
56
|
className: className,
|
|
57
|
-
title: isTruncated ? title : undefined
|
|
58
|
-
tabIndex: -1
|
|
57
|
+
title: isTruncated ? title : undefined
|
|
59
58
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
60
59
|
className: `${prefix}--list-box__menu-item__option`,
|
|
61
60
|
ref: forwardedRef?.menuItemOptionRef || ref
|
|
@@ -68,6 +67,10 @@ ListBoxMenuItem.propTypes = {
|
|
|
68
67
|
* Menu Item
|
|
69
68
|
*/
|
|
70
69
|
children: PropTypes__default["default"].node,
|
|
70
|
+
/**
|
|
71
|
+
* Specify if the item should be disabled
|
|
72
|
+
*/
|
|
73
|
+
disabled: PropTypes__default["default"].bool,
|
|
71
74
|
/**
|
|
72
75
|
* Specify whether the current menu item is "active".
|
|
73
76
|
*/
|
|
@@ -45,6 +45,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
45
45
|
const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(function FilterableMultiSelect(_ref, ref) {
|
|
46
46
|
let {
|
|
47
47
|
className: containerClassName,
|
|
48
|
+
clearSelectionDescription,
|
|
49
|
+
clearSelectionText,
|
|
48
50
|
compareItems,
|
|
49
51
|
direction,
|
|
50
52
|
disabled,
|
|
@@ -332,11 +334,18 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
332
334
|
setIsFocused(evt.type === 'focus' ? true : false);
|
|
333
335
|
}
|
|
334
336
|
};
|
|
337
|
+
const clearSelectionContent = selectedItems.length > 0 ? /*#__PURE__*/React__default["default"].createElement("span", {
|
|
338
|
+
className: `${prefix}--visually-hidden`
|
|
339
|
+
}, clearSelectionDescription, " ", selectedItems.length, ",", clearSelectionText) : /*#__PURE__*/React__default["default"].createElement("span", {
|
|
340
|
+
className: `${prefix}--visually-hidden`
|
|
341
|
+
}, clearSelectionDescription, ": 0");
|
|
335
342
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
336
343
|
className: wrapperClasses
|
|
337
344
|
}, titleText ? /*#__PURE__*/React__default["default"].createElement("label", _rollupPluginBabelHelpers["extends"]({
|
|
338
345
|
className: titleClasses
|
|
339
|
-
}, labelProps), titleText
|
|
346
|
+
}, labelProps), titleText, /*#__PURE__*/React__default["default"].createElement("span", {
|
|
347
|
+
className: `${prefix}--visually-hidden`
|
|
348
|
+
}, clearSelectionContent)) : null, /*#__PURE__*/React__default["default"].createElement(index["default"], {
|
|
340
349
|
onFocus: isFluid ? handleFocus : null,
|
|
341
350
|
onBlur: isFluid ? handleFocus : null,
|
|
342
351
|
className: className,
|
|
@@ -397,12 +406,13 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
397
406
|
compareItems,
|
|
398
407
|
locale
|
|
399
408
|
}).map((item, index$1) => {
|
|
409
|
+
const isChecked = selectedItem.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
400
410
|
const itemProps = getItemProps({
|
|
401
411
|
item,
|
|
402
|
-
disabled: item.disabled
|
|
412
|
+
disabled: item.disabled,
|
|
413
|
+
['aria-selected']: isChecked
|
|
403
414
|
});
|
|
404
415
|
const itemText = itemToString(item);
|
|
405
|
-
const isChecked = selectedItem.filter(selected => isEqual__default["default"](selected, item)).length > 0;
|
|
406
416
|
return /*#__PURE__*/React__default["default"].createElement(index["default"].MenuItem, _rollupPluginBabelHelpers["extends"]({
|
|
407
417
|
key: itemProps.id,
|
|
408
418
|
"aria-label": itemText,
|
|
@@ -435,6 +445,14 @@ FilterableMultiSelect.propTypes = {
|
|
|
435
445
|
* Specify a label to be read by screen readers on the container note.
|
|
436
446
|
*/
|
|
437
447
|
ariaLabel: deprecate["default"](PropTypes__default["default"].string, 'ariaLabel / aria-label props are no longer required for FilterableMultiSelect'),
|
|
448
|
+
/**
|
|
449
|
+
* Specify the text that should be read for screen readers that describes total items selected
|
|
450
|
+
*/
|
|
451
|
+
clearSelectionDescription: PropTypes__default["default"].string,
|
|
452
|
+
/**
|
|
453
|
+
* Specify the text that should be read for screen readers to clear selection.
|
|
454
|
+
*/
|
|
455
|
+
clearSelectionText: PropTypes__default["default"].string,
|
|
438
456
|
/**
|
|
439
457
|
* Specify the direction of the multiselect dropdown. Can be either top or bottom.
|
|
440
458
|
*/
|
|
@@ -556,7 +574,9 @@ FilterableMultiSelect.defaultProps = {
|
|
|
556
574
|
locale: 'en',
|
|
557
575
|
sortItems: sorting.defaultSortItems,
|
|
558
576
|
open: false,
|
|
559
|
-
selectionFeedback: 'top-after-reopen'
|
|
577
|
+
selectionFeedback: 'top-after-reopen',
|
|
578
|
+
clearSelectionText: 'To clear selection, press Delete or Backspace,',
|
|
579
|
+
clearSelectionDescription: 'Total items selected: '
|
|
560
580
|
};
|
|
561
581
|
var FilterableMultiSelect$1 = FilterableMultiSelect;
|
|
562
582
|
|