@carbon/react 1.60.1 → 1.60.3
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 +1069 -946
- package/es/components/ComboBox/ComboBox.js +18 -12
- package/es/components/MultiSelect/FilterableMultiSelect.js +5 -3
- package/lib/components/ComboBox/ComboBox.js +17 -11
- package/lib/components/MultiSelect/FilterableMultiSelect.js +5 -3
- package/package.json +2 -2
|
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
|
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import { useCombobox } from 'downshift';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
|
-
import React__default, { forwardRef, useEffect, useContext, useRef, useState } from 'react';
|
|
12
|
+
import React__default, { forwardRef, useEffect, useContext, useRef, useState, useMemo } from 'react';
|
|
13
13
|
import '../Text/index.js';
|
|
14
14
|
import { WarningFilled, WarningAltFilled, Checkmark } from '@carbon/icons-react';
|
|
15
15
|
import ListBox from '../ListBox/index.js';
|
|
@@ -198,13 +198,19 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
198
198
|
} = changes;
|
|
199
199
|
switch (type) {
|
|
200
200
|
case InputBlur:
|
|
201
|
-
if (state.inputValue && highlightedIndex == '-1' &&
|
|
201
|
+
if (state.inputValue && highlightedIndex == '-1' && changes.selectedItem) {
|
|
202
|
+
return {
|
|
203
|
+
...changes,
|
|
204
|
+
inputValue: itemToString(changes.selectedItem)
|
|
205
|
+
};
|
|
206
|
+
} else if (state.inputValue && highlightedIndex == '-1' && !allowCustomValue && !changes.selectedItem) {
|
|
202
207
|
return {
|
|
203
208
|
...changes,
|
|
204
209
|
inputValue: ''
|
|
205
210
|
};
|
|
211
|
+
} else {
|
|
212
|
+
return changes;
|
|
206
213
|
}
|
|
207
|
-
return changes;
|
|
208
214
|
case InputKeyDownEnter:
|
|
209
215
|
if (allowCustomValue) {
|
|
210
216
|
setInputValue(inputValue);
|
|
@@ -315,7 +321,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
315
321
|
setHighlightedIndex
|
|
316
322
|
} = useCombobox({
|
|
317
323
|
...downshiftProps,
|
|
318
|
-
items,
|
|
324
|
+
items: filterItems(items, itemToString, inputValue),
|
|
319
325
|
inputValue: inputValue,
|
|
320
326
|
itemToString: item => {
|
|
321
327
|
return itemToString(item);
|
|
@@ -376,6 +382,10 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
376
382
|
// when both the message is supplied *and* when the component is in
|
|
377
383
|
// the matching state (invalid, warn, etc).
|
|
378
384
|
const ariaDescribedBy = invalid && invalidText && invalidTextId || warn && warnText && warnTextId || helperText && !isFluid && helperTextId || undefined;
|
|
385
|
+
const menuProps = useMemo(() => getMenuProps({
|
|
386
|
+
'aria-label': deprecatedAriaLabel || ariaLabel,
|
|
387
|
+
ref: autoAlign ? refs.setFloating : null
|
|
388
|
+
}), [autoAlign, deprecatedAriaLabel, ariaLabel]);
|
|
379
389
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
380
390
|
className: wrapperClasses
|
|
381
391
|
}, titleText && /*#__PURE__*/React__default.createElement(Text, _extends({
|
|
@@ -393,7 +403,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
393
403
|
light: light,
|
|
394
404
|
size: size,
|
|
395
405
|
warn: warn,
|
|
396
|
-
ref: refs.setReference,
|
|
406
|
+
ref: autoAlign ? refs.setReference : null,
|
|
397
407
|
warnText: warnText,
|
|
398
408
|
warnTextId: warnTextId
|
|
399
409
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -406,7 +416,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
406
416
|
"aria-haspopup": "listbox",
|
|
407
417
|
title: textInput?.current?.value
|
|
408
418
|
}, getInputProps({
|
|
409
|
-
'aria-controls': isOpen ? undefined :
|
|
419
|
+
'aria-controls': isOpen ? undefined : menuProps.id,
|
|
410
420
|
placeholder,
|
|
411
421
|
ref: {
|
|
412
422
|
...mergeRefs(textInput, ref)
|
|
@@ -418,7 +428,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
418
428
|
if (match(event, Enter) && (!inputValue || allowCustomValue)) {
|
|
419
429
|
toggleMenu();
|
|
420
430
|
if (highlightedIndex !== -1) {
|
|
421
|
-
selectItem(items[highlightedIndex]);
|
|
431
|
+
selectItem(filterItems(items, itemToString, inputValue)[highlightedIndex]);
|
|
422
432
|
}
|
|
423
433
|
event.preventDownshiftDefault = true;
|
|
424
434
|
event?.persist?.();
|
|
@@ -468,11 +478,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
468
478
|
// @ts-expect-error
|
|
469
479
|
isOpen: isOpen,
|
|
470
480
|
translateWithId: translateWithId
|
|
471
|
-
}))), normalizedSlug, /*#__PURE__*/React__default.createElement(ListBox.Menu,
|
|
472
|
-
'aria-label': deprecatedAriaLabel || ariaLabel
|
|
473
|
-
}), {
|
|
474
|
-
ref: mergeRefs(getMenuProps().ref, refs.setFloating)
|
|
475
|
-
}), isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
481
|
+
}))), normalizedSlug, /*#__PURE__*/React__default.createElement(ListBox.Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index) => {
|
|
476
482
|
const isObject = item !== null && typeof item === 'object';
|
|
477
483
|
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
478
484
|
const itemProps = getItemProps({
|
|
@@ -231,8 +231,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
231
231
|
return changes;
|
|
232
232
|
case InputBlur:
|
|
233
233
|
case InputKeyDownEscape:
|
|
234
|
-
setInputFocused(false);
|
|
235
|
-
setInputValue('');
|
|
236
234
|
setIsOpen(false);
|
|
237
235
|
return changes;
|
|
238
236
|
case FunctionToggleMenu:
|
|
@@ -416,7 +414,11 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
416
414
|
$input.setSelectionRange($value.length, $value.length);
|
|
417
415
|
}
|
|
418
416
|
},
|
|
419
|
-
onFocus: () => setInputFocused(true)
|
|
417
|
+
onFocus: () => setInputFocused(true),
|
|
418
|
+
onBlur: () => {
|
|
419
|
+
!isOpen && setInputFocused(false);
|
|
420
|
+
setInputValue('');
|
|
421
|
+
}
|
|
420
422
|
}));
|
|
421
423
|
const menuProps = getMenuProps({}, {
|
|
422
424
|
suppressRefError: true
|
|
@@ -208,13 +208,19 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
208
208
|
} = changes;
|
|
209
209
|
switch (type) {
|
|
210
210
|
case InputBlur:
|
|
211
|
-
if (state.inputValue && highlightedIndex == '-1' &&
|
|
211
|
+
if (state.inputValue && highlightedIndex == '-1' && changes.selectedItem) {
|
|
212
|
+
return {
|
|
213
|
+
...changes,
|
|
214
|
+
inputValue: itemToString(changes.selectedItem)
|
|
215
|
+
};
|
|
216
|
+
} else if (state.inputValue && highlightedIndex == '-1' && !allowCustomValue && !changes.selectedItem) {
|
|
212
217
|
return {
|
|
213
218
|
...changes,
|
|
214
219
|
inputValue: ''
|
|
215
220
|
};
|
|
221
|
+
} else {
|
|
222
|
+
return changes;
|
|
216
223
|
}
|
|
217
|
-
return changes;
|
|
218
224
|
case InputKeyDownEnter:
|
|
219
225
|
if (allowCustomValue) {
|
|
220
226
|
setInputValue(inputValue);
|
|
@@ -325,7 +331,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
325
331
|
setHighlightedIndex
|
|
326
332
|
} = Downshift.useCombobox({
|
|
327
333
|
...downshiftProps,
|
|
328
|
-
items,
|
|
334
|
+
items: filterItems(items, itemToString, inputValue),
|
|
329
335
|
inputValue: inputValue,
|
|
330
336
|
itemToString: item => {
|
|
331
337
|
return itemToString(item);
|
|
@@ -386,6 +392,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
386
392
|
// when both the message is supplied *and* when the component is in
|
|
387
393
|
// the matching state (invalid, warn, etc).
|
|
388
394
|
const ariaDescribedBy = invalid && invalidText && invalidTextId || warn && warnText && warnTextId || helperText && !isFluid && helperTextId || undefined;
|
|
395
|
+
const menuProps = React.useMemo(() => getMenuProps({
|
|
396
|
+
'aria-label': deprecatedAriaLabel || ariaLabel,
|
|
397
|
+
ref: autoAlign ? refs.setFloating : null
|
|
398
|
+
}), [autoAlign, deprecatedAriaLabel, ariaLabel]);
|
|
389
399
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
390
400
|
className: wrapperClasses
|
|
391
401
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -403,7 +413,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
403
413
|
light: light,
|
|
404
414
|
size: size,
|
|
405
415
|
warn: warn,
|
|
406
|
-
ref: refs.setReference,
|
|
416
|
+
ref: autoAlign ? refs.setReference : null,
|
|
407
417
|
warnText: warnText,
|
|
408
418
|
warnTextId: warnTextId
|
|
409
419
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -416,7 +426,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
416
426
|
"aria-haspopup": "listbox",
|
|
417
427
|
title: textInput?.current?.value
|
|
418
428
|
}, getInputProps({
|
|
419
|
-
'aria-controls': isOpen ? undefined :
|
|
429
|
+
'aria-controls': isOpen ? undefined : menuProps.id,
|
|
420
430
|
placeholder,
|
|
421
431
|
ref: {
|
|
422
432
|
...mergeRefs["default"](textInput, ref)
|
|
@@ -428,7 +438,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
428
438
|
if (match.match(event, keys.Enter) && (!inputValue || allowCustomValue)) {
|
|
429
439
|
toggleMenu();
|
|
430
440
|
if (highlightedIndex !== -1) {
|
|
431
|
-
selectItem(items[highlightedIndex]);
|
|
441
|
+
selectItem(filterItems(items, itemToString, inputValue)[highlightedIndex]);
|
|
432
442
|
}
|
|
433
443
|
event.preventDownshiftDefault = true;
|
|
434
444
|
event?.persist?.();
|
|
@@ -478,11 +488,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
478
488
|
// @ts-expect-error
|
|
479
489
|
isOpen: isOpen,
|
|
480
490
|
translateWithId: translateWithId
|
|
481
|
-
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu,
|
|
482
|
-
'aria-label': deprecatedAriaLabel || ariaLabel
|
|
483
|
-
}), {
|
|
484
|
-
ref: mergeRefs["default"](getMenuProps().ref, refs.setFloating)
|
|
485
|
-
}), isOpen ? filterItems(items, itemToString, inputValue).map((item, index$1) => {
|
|
491
|
+
}))), normalizedSlug, /*#__PURE__*/React__default["default"].createElement(index["default"].Menu, menuProps, isOpen ? filterItems(items, itemToString, inputValue).map((item, index$1) => {
|
|
486
492
|
const isObject = item !== null && typeof item === 'object';
|
|
487
493
|
const title = isObject && 'text' in item && itemToElement ? item.text?.toString() : itemToString(item);
|
|
488
494
|
const itemProps = getItemProps({
|
|
@@ -243,8 +243,6 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
243
243
|
return changes;
|
|
244
244
|
case InputBlur:
|
|
245
245
|
case InputKeyDownEscape:
|
|
246
|
-
setInputFocused(false);
|
|
247
|
-
setInputValue('');
|
|
248
246
|
setIsOpen(false);
|
|
249
247
|
return changes;
|
|
250
248
|
case FunctionToggleMenu:
|
|
@@ -428,7 +426,11 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
428
426
|
$input.setSelectionRange($value.length, $value.length);
|
|
429
427
|
}
|
|
430
428
|
},
|
|
431
|
-
onFocus: () => setInputFocused(true)
|
|
429
|
+
onFocus: () => setInputFocused(true),
|
|
430
|
+
onBlur: () => {
|
|
431
|
+
!isOpen && setInputFocused(false);
|
|
432
|
+
setInputValue('');
|
|
433
|
+
}
|
|
432
434
|
}));
|
|
433
435
|
const menuProps = getMenuProps({}, {
|
|
434
436
|
suppressRefError: true
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/react",
|
|
3
3
|
"description": "React components for the Carbon Design System",
|
|
4
|
-
"version": "1.60.
|
|
4
|
+
"version": "1.60.3",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"**/*.scss",
|
|
143
143
|
"**/*.css"
|
|
144
144
|
],
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "7e7aa249813b0a3376f13f403702d8c3e2551952"
|
|
146
146
|
}
|