@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
|
@@ -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
|
}
|
|
@@ -191,7 +196,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
191
196
|
[`${prefix}--list-box--up`]: direction === 'top',
|
|
192
197
|
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
|
|
193
198
|
[`${prefix}--list-box__wrapper--fluid--focus`]: isFluid && isFocused,
|
|
194
|
-
[`${prefix}--list-box__wrapper--slug`]: slug
|
|
199
|
+
[`${prefix}--list-box__wrapper--slug`]: slug,
|
|
200
|
+
[`${prefix}--autoalign`]: autoAlign
|
|
195
201
|
});
|
|
196
202
|
const helperId = !helperText ? undefined : `filterablemultiselect-helper-text-${filterableMultiSelectInstanceId}`;
|
|
197
203
|
const labelId = `${id}-label`;
|
|
@@ -532,10 +538,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
532
538
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
533
539
|
className: `${prefix}--list-box__field`,
|
|
534
540
|
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, {
|
|
541
|
+
}, controlledSelectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
539
542
|
clearSelection: () => {
|
|
540
543
|
clearSelection();
|
|
541
544
|
if (textInput.current) {
|
|
@@ -553,10 +556,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
553
556
|
className: `${prefix}--list-box__invalid-icon`
|
|
554
557
|
}), showWarning && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
555
558
|
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, {
|
|
559
|
+
}), inputValue && /*#__PURE__*/React__default.createElement(ListBoxSelection, {
|
|
560
560
|
clearSelection: clearInputValue,
|
|
561
561
|
disabled: disabled,
|
|
562
562
|
translateWithId: translateWithId,
|
|
@@ -569,7 +569,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
569
569
|
event.stopPropagation();
|
|
570
570
|
}
|
|
571
571
|
}), /*#__PURE__*/React__default.createElement(ListBoxTrigger, _extends({}, buttonProps, {
|
|
572
|
-
// @ts-expect-error
|
|
573
572
|
isOpen: isOpen,
|
|
574
573
|
translateWithId: translateWithId
|
|
575
574
|
}))), normalizedSlug, /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|
|
@@ -11,7 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import { useSelect } from 'downshift';
|
|
12
12
|
import isEqual from 'react-fast-compare';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useContext, useState, useLayoutEffect
|
|
14
|
+
import React__default, { useMemo, useContext, useState, useLayoutEffect } from 'react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
16
16
|
import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
17
17
|
import { defaultSortItems, defaultCompareItems } from './tools/sorting.js';
|
|
@@ -22,8 +22,11 @@ import deprecate from '../../prop-types/deprecate.js';
|
|
|
22
22
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
23
23
|
import '../FluidForm/FluidForm.js';
|
|
24
24
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
25
|
+
import Checkbox from '../Checkbox/Checkbox.js';
|
|
26
|
+
import '../Checkbox/Checkbox.Skeleton.js';
|
|
25
27
|
import { noopFn } from '../../internal/noopFn.js';
|
|
26
28
|
import { useFloating, flip, size, autoUpdate } from '@floating-ui/react';
|
|
29
|
+
import { hide } from '../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js';
|
|
27
30
|
import { match } from '../../internal/keyboard/match.js';
|
|
28
31
|
import { ListBoxSize } from '../ListBox/ListBoxPropTypes.js';
|
|
29
32
|
import { Delete, Escape, Space, ArrowDown, Enter } from '../../internal/keyboard/keys.js';
|
|
@@ -94,6 +97,23 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
94
97
|
locale = 'en',
|
|
95
98
|
slug
|
|
96
99
|
} = _ref;
|
|
100
|
+
const filteredItems = useMemo(() => {
|
|
101
|
+
return items.filter(item => {
|
|
102
|
+
if (typeof item === 'object' && item !== null) {
|
|
103
|
+
for (const key in item) {
|
|
104
|
+
if (Object.hasOwn(item, key) && item[key] === undefined) {
|
|
105
|
+
return false; // Return false if any property has an undefined value
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return true; // Return true if item is not an object with undefined values
|
|
110
|
+
});
|
|
111
|
+
}, [items]);
|
|
112
|
+
let selectAll = filteredItems.some(item => item.isSelectAll);
|
|
113
|
+
if ((selected ?? []).length > 0 && selectAll) {
|
|
114
|
+
console.warn('Warning: `selectAll` should not be used when `selectedItems` is provided. Please pass either `selectAll` or `selectedItems`, not both.');
|
|
115
|
+
selectAll = false;
|
|
116
|
+
}
|
|
97
117
|
const prefix = usePrefix();
|
|
98
118
|
const {
|
|
99
119
|
isFluid
|
|
@@ -105,16 +125,6 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
105
125
|
const [prevOpenProp, setPrevOpenProp] = useState(open);
|
|
106
126
|
const [topItems, setTopItems] = useState([]);
|
|
107
127
|
const [itemsCleared, setItemsCleared] = useState(false);
|
|
108
|
-
const {
|
|
109
|
-
selectedItems: controlledSelectedItems,
|
|
110
|
-
onItemChange,
|
|
111
|
-
clearSelection
|
|
112
|
-
} = useSelection({
|
|
113
|
-
disabled,
|
|
114
|
-
initialSelectedItems,
|
|
115
|
-
onChange,
|
|
116
|
-
selectedItems: selected
|
|
117
|
-
});
|
|
118
128
|
const {
|
|
119
129
|
refs,
|
|
120
130
|
floatingStyles,
|
|
@@ -139,32 +149,40 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
139
149
|
width: `${rects.reference.width}px`
|
|
140
150
|
});
|
|
141
151
|
}
|
|
142
|
-
})],
|
|
152
|
+
}), hide()],
|
|
143
153
|
whileElementsMounted: autoUpdate
|
|
144
154
|
} : {});
|
|
145
155
|
useLayoutEffect(() => {
|
|
146
156
|
if (autoAlign) {
|
|
147
|
-
|
|
157
|
+
const updatedFloatingStyles = {
|
|
158
|
+
...floatingStyles,
|
|
159
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
160
|
+
};
|
|
161
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
148
162
|
if (refs.floating.current) {
|
|
149
|
-
refs.floating.current.style[style] =
|
|
163
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
150
164
|
}
|
|
151
165
|
});
|
|
152
166
|
}
|
|
153
167
|
}, [autoAlign, floatingStyles, refs.floating, middlewareData, open]);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
const {
|
|
169
|
+
selectedItems: controlledSelectedItems,
|
|
170
|
+
onItemChange,
|
|
171
|
+
clearSelection
|
|
172
|
+
} = useSelection({
|
|
173
|
+
disabled,
|
|
174
|
+
initialSelectedItems,
|
|
175
|
+
onChange,
|
|
176
|
+
selectedItems: selected,
|
|
177
|
+
selectAll,
|
|
178
|
+
filteredItems
|
|
179
|
+
});
|
|
180
|
+
const sortOptions = {
|
|
181
|
+
selectedItems: controlledSelectedItems,
|
|
182
|
+
itemToString,
|
|
183
|
+
compareItems,
|
|
184
|
+
locale
|
|
185
|
+
};
|
|
168
186
|
const selectProps = {
|
|
169
187
|
stateReducer,
|
|
170
188
|
isOpen,
|
|
@@ -260,18 +278,14 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
260
278
|
[`${prefix}--multi-select--inline`]: inline,
|
|
261
279
|
[`${prefix}--multi-select--selected`]: selectedItems && selectedItems.length > 0,
|
|
262
280
|
[`${prefix}--list-box--up`]: direction === 'top',
|
|
263
|
-
[`${prefix}--multi-select--readonly`]: readOnly
|
|
281
|
+
[`${prefix}--multi-select--readonly`]: readOnly,
|
|
282
|
+
[`${prefix}--autoalign`]: autoAlign,
|
|
283
|
+
[`${prefix}--multi-select--selectall`]: selectAll
|
|
264
284
|
});
|
|
265
285
|
|
|
266
286
|
// needs to be capitalized for react to render it correctly
|
|
267
287
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
268
288
|
const ItemToElement = itemToElement;
|
|
269
|
-
const sortOptions = {
|
|
270
|
-
selectedItems: controlledSelectedItems,
|
|
271
|
-
itemToString,
|
|
272
|
-
compareItems,
|
|
273
|
-
locale
|
|
274
|
-
};
|
|
275
289
|
if (selectionFeedback === 'fixed') {
|
|
276
290
|
sortOptions.selectedItems = [];
|
|
277
291
|
} else if (selectionFeedback === 'top-after-reopen') {
|
|
@@ -334,7 +348,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
334
348
|
} else {
|
|
335
349
|
return {
|
|
336
350
|
...changes,
|
|
337
|
-
highlightedIndex:
|
|
351
|
+
highlightedIndex: filteredItems.indexOf(highlightedIndex)
|
|
338
352
|
};
|
|
339
353
|
}
|
|
340
354
|
case ToggleButtonKeyDownArrowDown:
|
|
@@ -392,11 +406,12 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
392
406
|
});
|
|
393
407
|
}
|
|
394
408
|
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item?.text);
|
|
409
|
+
const selectedItemsLength = selectAll ? selectedItems.filter(item => !item.isSelectAll).length : selectedItems.length;
|
|
395
410
|
|
|
396
411
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
397
412
|
const menuProps = useMemo(() => getMenuProps({
|
|
398
413
|
ref: autoAlign ? refs.setFloating : null
|
|
399
|
-
}), [autoAlign]);
|
|
414
|
+
}), [autoAlign, getMenuProps, refs.setFloating]);
|
|
400
415
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
401
416
|
className: wrapperClasses
|
|
402
417
|
}, /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -427,7 +442,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
427
442
|
}, selectedItems.length > 0 && /*#__PURE__*/React__default.createElement(ListBox.Selection, {
|
|
428
443
|
readOnly: readOnly,
|
|
429
444
|
clearSelection: !disabled && !readOnly ? clearSelection : noopFn,
|
|
430
|
-
selectionCount:
|
|
445
|
+
selectionCount: selectedItemsLength
|
|
431
446
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
432
447
|
,
|
|
433
448
|
translateWithId: translateWithId,
|
|
@@ -446,10 +461,9 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
446
461
|
}, label), /*#__PURE__*/React__default.createElement(ListBox.MenuIcon, {
|
|
447
462
|
isOpen: isOpen,
|
|
448
463
|
translateWithId: translateWithId
|
|
449
|
-
})), normalizedSlug), /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen &&
|
|
450
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
451
|
-
sortItems(filteredItems, sortOptions).map((item, index) => {
|
|
464
|
+
})), normalizedSlug), /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen && sortItems(filteredItems, sortOptions).map((item, index) => {
|
|
452
465
|
const isChecked = selectedItems.filter(selected => isEqual(selected, item)).length > 0;
|
|
466
|
+
const isIndeterminate = selectedItems.length !== 0 && item['isSelectAll'] && !isChecked;
|
|
453
467
|
const itemProps = getItemProps({
|
|
454
468
|
item,
|
|
455
469
|
// we don't want Downshift to set aria-selected for us
|
|
@@ -459,21 +473,23 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
459
473
|
const itemText = itemToString(item);
|
|
460
474
|
return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
|
|
461
475
|
key: itemProps.id,
|
|
462
|
-
isActive: isChecked,
|
|
476
|
+
isActive: isChecked && !item['isSelectAll'],
|
|
463
477
|
"aria-label": itemText,
|
|
464
478
|
isHighlighted: highlightedIndex === index,
|
|
465
479
|
title: itemText,
|
|
466
480
|
disabled: itemProps['aria-disabled']
|
|
467
481
|
}, itemProps), /*#__PURE__*/React__default.createElement("div", {
|
|
468
482
|
className: `${prefix}--checkbox-wrapper`
|
|
469
|
-
}, /*#__PURE__*/React__default.createElement(
|
|
483
|
+
}, /*#__PURE__*/React__default.createElement(Checkbox, {
|
|
484
|
+
id: `${itemProps.id}__checkbox`,
|
|
485
|
+
labelText: itemToElement ? /*#__PURE__*/React__default.createElement(ItemToElement, _extends({
|
|
486
|
+
key: itemProps.id
|
|
487
|
+
}, item)) : itemText,
|
|
488
|
+
checked: isChecked,
|
|
470
489
|
title: useTitleInItem ? itemText : undefined,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}, itemToElement ? /*#__PURE__*/React__default.createElement(ItemToElement, _extends({
|
|
475
|
-
key: itemProps.id
|
|
476
|
-
}, item)) : itemText)));
|
|
490
|
+
indeterminate: isIndeterminate,
|
|
491
|
+
disabled: disabled
|
|
492
|
+
})));
|
|
477
493
|
})), itemsCleared && /*#__PURE__*/React__default.createElement("span", {
|
|
478
494
|
"aria-live": "assertive",
|
|
479
495
|
"aria-label": clearAnnouncement
|
|
@@ -35,16 +35,13 @@ const defaultSortItems = (items, _ref2) => {
|
|
|
35
35
|
locale = 'en'
|
|
36
36
|
} = _ref2;
|
|
37
37
|
return items.sort((itemA, itemB) => {
|
|
38
|
+
// Always place "select all" option at the beginning
|
|
39
|
+
if (itemA.isSelectAll) return -1;
|
|
40
|
+
if (itemB.isSelectAll) return 1;
|
|
38
41
|
const hasItemA = selectedItems.includes(itemA);
|
|
39
42
|
const hasItemB = selectedItems.includes(itemB);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (hasItemA && !hasItemB) {
|
|
43
|
-
return -1;
|
|
44
|
-
}
|
|
45
|
-
if (hasItemB && !hasItemA) {
|
|
46
|
-
return 1;
|
|
47
|
-
}
|
|
43
|
+
if (hasItemA && !hasItemB) return -1;
|
|
44
|
+
if (hasItemB && !hasItemA) return 1;
|
|
48
45
|
return compareItems(itemToString(itemA), itemToString(itemB), {
|
|
49
46
|
locale
|
|
50
47
|
});
|
|
@@ -251,7 +251,7 @@ class OverflowMenu extends React__default.Component {
|
|
|
251
251
|
} = this.props;
|
|
252
252
|
if (menuBody) {
|
|
253
253
|
this._menuBody = menuBody;
|
|
254
|
-
const hasFocusin =
|
|
254
|
+
const hasFocusin = 'onfocusin' in window;
|
|
255
255
|
const focusinEventName = hasFocusin ? 'focusin' : 'focus';
|
|
256
256
|
this._hFocusIn = on(menuBody.ownerDocument, focusinEventName, event => {
|
|
257
257
|
const target = ClickListener.getEventTarget(event);
|
|
@@ -83,7 +83,9 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
|
|
|
83
83
|
hookOnClick();
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
const containerClasses = cx(className, `${prefix}--overflow-menu__container
|
|
86
|
+
const containerClasses = cx(className, `${prefix}--overflow-menu__container`, {
|
|
87
|
+
[`${prefix}--autoalign`]: autoAlign
|
|
88
|
+
});
|
|
87
89
|
const menuClasses = cx(`${prefix}--overflow-menu__${menuAlignment}`);
|
|
88
90
|
const triggerClasses = cx(`${prefix}--overflow-menu`, {
|
|
89
91
|
[`${prefix}--overflow-menu--open`]: open
|
|
@@ -16,6 +16,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
16
16
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
17
17
|
import { mapPopoverAlignProp } from '../../tools/createPropAdapter.js';
|
|
18
18
|
import { useFloating, offset, flip, arrow, autoUpdate } from '@floating-ui/react';
|
|
19
|
+
import { hide } from '../../node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js';
|
|
19
20
|
|
|
20
21
|
const PopoverContext = /*#__PURE__*/React__default.createContext({
|
|
21
22
|
setFloating: {
|
|
@@ -128,7 +129,7 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
|
|
|
128
129
|
fallbackAxisSideDirection: 'start'
|
|
129
130
|
}), arrow({
|
|
130
131
|
element: caretRef
|
|
131
|
-
})],
|
|
132
|
+
}), hide()],
|
|
132
133
|
whileElementsMounted: autoUpdate
|
|
133
134
|
} : {} // When autoAlign is turned off, floating-ui will not be used
|
|
134
135
|
);
|
|
@@ -148,9 +149,13 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
|
|
|
148
149
|
}
|
|
149
150
|
useEffect(() => {
|
|
150
151
|
if (autoAlign) {
|
|
151
|
-
|
|
152
|
+
const updatedFloatingStyles = {
|
|
153
|
+
...floatingStyles,
|
|
154
|
+
visibility: middlewareData.hide?.referenceHidden ? 'hidden' : 'visible'
|
|
155
|
+
};
|
|
156
|
+
Object.keys(updatedFloatingStyles).forEach(style => {
|
|
152
157
|
if (refs.floating.current) {
|
|
153
|
-
refs.floating.current.style[style] =
|
|
158
|
+
refs.floating.current.style[style] = updatedFloatingStyles[style];
|
|
154
159
|
}
|
|
155
160
|
});
|
|
156
161
|
if (caret && middlewareData && middlewareData.arrow && caretRef?.current) {
|
|
@@ -184,13 +189,25 @@ const Popover = /*#__PURE__*/React__default.forwardRef(function PopoverRenderFun
|
|
|
184
189
|
[`${prefix}--popover--drop-shadow`]: dropShadow,
|
|
185
190
|
[`${prefix}--popover--high-contrast`]: highContrast,
|
|
186
191
|
[`${prefix}--popover--open`]: open,
|
|
187
|
-
[`${prefix}--popover--auto-align`]: autoAlign,
|
|
192
|
+
[`${prefix}--popover--auto-align ${prefix}--autoalign`]: autoAlign,
|
|
188
193
|
[`${prefix}--popover--${currentAlignment}`]: true,
|
|
189
194
|
[`${prefix}--popover--tab-tip`]: isTabTip
|
|
190
195
|
}, customClassName);
|
|
191
196
|
const mappedChildren = React__default.Children.map(children, child => {
|
|
192
197
|
const item = child;
|
|
193
|
-
|
|
198
|
+
const displayName = item?.type?.displayName;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Only trigger elements (button) or trigger components (ToggletipButton) should be
|
|
202
|
+
* cloned because these will be decorated with a trigger-specific className and ref.
|
|
203
|
+
*
|
|
204
|
+
* There are also some specific components that should not be cloned when autoAlign
|
|
205
|
+
* is on, even if they are a trigger element.
|
|
206
|
+
*/
|
|
207
|
+
const isTriggerElement = item?.type === 'button';
|
|
208
|
+
const isTriggerComponent = autoAlign && displayName && ['ToggletipButton'].includes(displayName);
|
|
209
|
+
const isAllowedTriggerComponent = autoAlign && displayName && !['ToggletipContent', 'PopoverContent'].includes(displayName);
|
|
210
|
+
if ( /*#__PURE__*/React__default.isValidElement(item) && (isTriggerElement || isTriggerComponent || isAllowedTriggerComponent)) {
|
|
194
211
|
const className = item?.props?.className;
|
|
195
212
|
const ref = (item?.props).ref;
|
|
196
213
|
const tabTipClasses = cx(`${prefix}--popover--tab-tip__button`, className);
|
|
@@ -43,6 +43,10 @@ export interface DismissibleTagBaseProps {
|
|
|
43
43
|
* Provide text to be rendered inside of a the tag.
|
|
44
44
|
*/
|
|
45
45
|
text?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Provide a custom `title` to be inserted in the tag.
|
|
48
|
+
*/
|
|
49
|
+
tagTitle?: string;
|
|
46
50
|
/**
|
|
47
51
|
* Text to show on clear filters
|
|
48
52
|
*/
|
|
@@ -54,7 +58,7 @@ export interface DismissibleTagBaseProps {
|
|
|
54
58
|
}
|
|
55
59
|
export type DismissibleTagProps<T extends React.ElementType> = PolymorphicProps<T, DismissibleTagBaseProps>;
|
|
56
60
|
declare const DismissibleTag: {
|
|
57
|
-
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, title, onClose, slug, size, text, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
61
|
+
<T extends React.ElementType<any, keyof React.JSX.IntrinsicElements>>({ className, disabled, id, renderIcon, title, onClose, slug, size, text, tagTitle, type, ...other }: DismissibleTagProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
58
62
|
propTypes: {
|
|
59
63
|
/**
|
|
60
64
|
* Provide a custom className that is applied to the containing <span>
|
|
@@ -90,6 +94,10 @@ declare const DismissibleTag: {
|
|
|
90
94
|
* Provide text to be rendered inside of a the tag.
|
|
91
95
|
*/
|
|
92
96
|
text: PropTypes.Requireable<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Provide a custom `title` to be inserted in the tag.
|
|
99
|
+
*/
|
|
100
|
+
tagTitle: PropTypes.Requireable<string>;
|
|
93
101
|
/**
|
|
94
102
|
* Text to show on clear filters
|
|
95
103
|
*/
|
|
@@ -31,6 +31,7 @@ const DismissibleTag = _ref => {
|
|
|
31
31
|
slug,
|
|
32
32
|
size,
|
|
33
33
|
text,
|
|
34
|
+
tagTitle,
|
|
34
35
|
type,
|
|
35
36
|
...other
|
|
36
37
|
} = _ref;
|
|
@@ -76,7 +77,7 @@ const DismissibleTag = _ref => {
|
|
|
76
77
|
}, otherProps), /*#__PURE__*/React__default.createElement("div", {
|
|
77
78
|
className: `${prefix}--interactive--tag-children`
|
|
78
79
|
}, /*#__PURE__*/React__default.createElement(Text, {
|
|
79
|
-
title: text,
|
|
80
|
+
title: tagTitle ? tagTitle : text,
|
|
80
81
|
className: `${prefix}--tag__label`
|
|
81
82
|
}, text), /*#__PURE__*/React__default.createElement(Tooltip, {
|
|
82
83
|
label: isEllipsisApplied ? dismissLabel : title,
|
|
@@ -89,8 +90,7 @@ const DismissibleTag = _ref => {
|
|
|
89
90
|
className: `${prefix}--tag__close-icon`,
|
|
90
91
|
onClick: handleClose,
|
|
91
92
|
disabled: disabled,
|
|
92
|
-
"aria-label": title
|
|
93
|
-
title: title
|
|
93
|
+
"aria-label": title
|
|
94
94
|
}, _Close || (_Close = /*#__PURE__*/React__default.createElement(Close, null)))), normalizedSlug));
|
|
95
95
|
};
|
|
96
96
|
DismissibleTag.propTypes = {
|
|
@@ -128,6 +128,10 @@ DismissibleTag.propTypes = {
|
|
|
128
128
|
* Provide text to be rendered inside of a the tag.
|
|
129
129
|
*/
|
|
130
130
|
text: PropTypes.string,
|
|
131
|
+
/**
|
|
132
|
+
* Provide a custom `title` to be inserted in the tag.
|
|
133
|
+
*/
|
|
134
|
+
tagTitle: PropTypes.string,
|
|
131
135
|
/**
|
|
132
136
|
* Text to show on clear filters
|
|
133
137
|
*/
|
package/es/components/Tag/Tag.js
CHANGED
|
@@ -131,10 +131,10 @@ const Tag = /*#__PURE__*/React__default.forwardRef(function Tag(_ref, forwardRef
|
|
|
131
131
|
definition: children !== null && children !== undefined ? children : typeText,
|
|
132
132
|
className: `${prefix}--definition--tooltip--tag`
|
|
133
133
|
}, /*#__PURE__*/React__default.createElement(Text, {
|
|
134
|
-
title: children !== null && children !== undefined ? children : typeText,
|
|
134
|
+
title: children !== null && children !== undefined && typeof children === 'string' ? children : typeText,
|
|
135
135
|
className: labelClasses
|
|
136
136
|
}, children !== null && children !== undefined ? children : typeText)) : /*#__PURE__*/React__default.createElement(Text, {
|
|
137
|
-
title: children !== null && children !== undefined ? children : typeText,
|
|
137
|
+
title: children !== null && children !== undefined && typeof children === 'string' ? children : typeText,
|
|
138
138
|
className: labelClasses
|
|
139
139
|
}, children !== null && children !== undefined ? children : typeText), normalizedSlug);
|
|
140
140
|
});
|
|
@@ -74,7 +74,8 @@ function Toggletip(_ref2) {
|
|
|
74
74
|
const prefix = usePrefix();
|
|
75
75
|
const id = useId();
|
|
76
76
|
const className = cx(`${prefix}--toggletip`, customClassName, {
|
|
77
|
-
[`${prefix}--toggletip--open`]: open
|
|
77
|
+
[`${prefix}--toggletip--open`]: open,
|
|
78
|
+
[`${prefix}--autoalign`]: autoAlign
|
|
78
79
|
});
|
|
79
80
|
const actions = {
|
|
80
81
|
toggle: () => {
|
|
@@ -17,7 +17,7 @@ import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
|
17
17
|
import { matches, match } from '../../internal/keyboard/match.js';
|
|
18
18
|
import { ArrowLeft, ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
19
19
|
|
|
20
|
-
const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref,
|
|
20
|
+
const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, forwardedRef) => {
|
|
21
21
|
let {
|
|
22
22
|
active,
|
|
23
23
|
children,
|
|
@@ -54,6 +54,14 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
54
54
|
const currentNode = useRef(null);
|
|
55
55
|
const currentNodeLabel = useRef(null);
|
|
56
56
|
const prefix = usePrefix();
|
|
57
|
+
const setRefs = element => {
|
|
58
|
+
currentNode.current = element;
|
|
59
|
+
if (typeof forwardedRef === 'function') {
|
|
60
|
+
forwardedRef(element);
|
|
61
|
+
} else if (forwardedRef) {
|
|
62
|
+
forwardedRef.current = element;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
57
65
|
const nodesWithProps = React__default.Children.map(children, node => {
|
|
58
66
|
if ( /*#__PURE__*/React__default.isValidElement(node)) {
|
|
59
67
|
return /*#__PURE__*/React__default.cloneElement(node, {
|
|
@@ -121,13 +129,14 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
121
129
|
}
|
|
122
130
|
if (match(event, ArrowLeft)) {
|
|
123
131
|
const findParentTreeNode = node => {
|
|
132
|
+
if (!node) return null;
|
|
124
133
|
if (node.classList.contains(`${prefix}--tree-parent-node`)) {
|
|
125
134
|
return node;
|
|
126
135
|
}
|
|
127
136
|
if (node.classList.contains(`${prefix}--tree`)) {
|
|
128
137
|
return null;
|
|
129
138
|
}
|
|
130
|
-
return findParentTreeNode(node.
|
|
139
|
+
return findParentTreeNode(node.parentElement);
|
|
131
140
|
};
|
|
132
141
|
if (children && expanded) {
|
|
133
142
|
if (!enableTreeviewControllable) {
|
|
@@ -144,7 +153,10 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
144
153
|
* When focus is on a leaf node or a closed parent node, move focus to
|
|
145
154
|
* its parent node (unless its depth is level 1)
|
|
146
155
|
*/
|
|
147
|
-
findParentTreeNode(currentNode.current?.
|
|
156
|
+
const parentNode = findParentTreeNode(currentNode.current?.parentElement || null);
|
|
157
|
+
if (parentNode instanceof HTMLElement) {
|
|
158
|
+
parentNode.focus();
|
|
159
|
+
}
|
|
148
160
|
}
|
|
149
161
|
}
|
|
150
162
|
if (children && match(event, ArrowRight)) {
|
|
@@ -229,44 +241,40 @@ const TreeNode = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
229
241
|
onClick: handleClick,
|
|
230
242
|
onFocus: handleFocusEvent,
|
|
231
243
|
onKeyDown: handleKeyDown,
|
|
232
|
-
role: 'treeitem'
|
|
233
|
-
// @ts-ignore
|
|
234
|
-
ref: currentNode
|
|
244
|
+
role: 'treeitem'
|
|
235
245
|
};
|
|
236
246
|
if (!children) {
|
|
237
|
-
return /*#__PURE__*/React__default.createElement("li",
|
|
247
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({}, treeNodeProps, {
|
|
248
|
+
ref: setRefs
|
|
249
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
238
250
|
className: `${prefix}--tree-node__label`,
|
|
239
251
|
ref: currentNodeLabel
|
|
240
252
|
}, Icon && /*#__PURE__*/React__default.createElement(Icon, {
|
|
241
253
|
className: `${prefix}--tree-node__icon`
|
|
242
254
|
}), label));
|
|
243
255
|
}
|
|
244
|
-
return (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
role: "group",
|
|
267
|
-
className: `${prefix}--tree-node__children`
|
|
268
|
-
}, nodesWithProps))
|
|
269
|
-
);
|
|
256
|
+
return /*#__PURE__*/React__default.createElement("li", _extends({}, treeNodeProps, {
|
|
257
|
+
"aria-expanded": !!expanded,
|
|
258
|
+
ref: setRefs
|
|
259
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
260
|
+
className: `${prefix}--tree-node__label`,
|
|
261
|
+
ref: currentNodeLabel
|
|
262
|
+
}, /*#__PURE__*/React__default.createElement("span", {
|
|
263
|
+
className: `${prefix}--tree-parent-node__toggle`
|
|
264
|
+
// @ts-ignore
|
|
265
|
+
,
|
|
266
|
+
disabled: disabled,
|
|
267
|
+
onClick: handleToggleClick
|
|
268
|
+
}, /*#__PURE__*/React__default.createElement(CaretDown, {
|
|
269
|
+
className: toggleClasses
|
|
270
|
+
})), /*#__PURE__*/React__default.createElement("span", {
|
|
271
|
+
className: `${prefix}--tree-node__label__details`
|
|
272
|
+
}, Icon && /*#__PURE__*/React__default.createElement(Icon, {
|
|
273
|
+
className: `${prefix}--tree-node__icon`
|
|
274
|
+
}), label)), expanded && /*#__PURE__*/React__default.createElement("ul", {
|
|
275
|
+
role: "group",
|
|
276
|
+
className: `${prefix}--tree-node__children`
|
|
277
|
+
}, nodesWithProps));
|
|
270
278
|
});
|
|
271
279
|
TreeNode.propTypes = {
|
|
272
280
|
/**
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import TreeNode from './TreeNode';
|
|
8
|
+
import TreeNode, { TreeNodeProps } from './TreeNode';
|
|
9
9
|
export type TreeViewProps = {
|
|
10
10
|
/**
|
|
11
11
|
* Mark the active node in the tree, represented by its ID
|
|
@@ -40,7 +40,9 @@ export type TreeViewProps = {
|
|
|
40
40
|
/**
|
|
41
41
|
* Callback function that is called when any node is selected
|
|
42
42
|
*/
|
|
43
|
-
onSelect?: (
|
|
43
|
+
onSelect?: (event: React.SyntheticEvent<HTMLUListElement>, payload?: Partial<TreeNodeProps> & {
|
|
44
|
+
activeNodeId?: string | number;
|
|
45
|
+
}) => void;
|
|
44
46
|
/**
|
|
45
47
|
* Array representing all selected node IDs in the tree
|
|
46
48
|
*/
|
|
@@ -49,7 +51,7 @@ export type TreeViewProps = {
|
|
|
49
51
|
* Specify the size of the tree from a list of available sizes.
|
|
50
52
|
*/
|
|
51
53
|
size?: 'xs' | 'sm';
|
|
52
|
-
} & React.HTMLAttributes<HTMLUListElement>;
|
|
54
|
+
} & Omit<React.HTMLAttributes<HTMLUListElement>, 'onSelect'>;
|
|
53
55
|
type TreeViewComponent = {
|
|
54
56
|
(props: TreeViewProps): JSX.Element;
|
|
55
57
|
propTypes?: any;
|