@carbon/react 1.60.0-rc.0 → 1.60.2
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 +960 -960
- package/es/components/ComboBox/ComboBox.js +10 -4
- package/es/components/Menu/Menu.d.ts +1 -1
- package/es/components/Menu/Menu.js +5 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +3 -5
- package/es/components/NumberInput/NumberInput.js +1 -0
- package/es/components/Pagination/Pagination.js +2 -0
- package/es/components/PaginationNav/PaginationNav.js +2 -0
- package/es/internal/Selection.js +20 -17
- package/es/internal/useId.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +10 -4
- package/lib/components/Menu/Menu.d.ts +1 -1
- package/lib/components/Menu/Menu.js +5 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -5
- package/lib/components/NumberInput/NumberInput.js +1 -0
- package/lib/components/Pagination/Pagination.js +2 -0
- package/lib/components/PaginationNav/PaginationNav.js +2 -0
- package/lib/internal/Selection.js +19 -16
- package/package.json +6 -6
|
@@ -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);
|
|
@@ -418,7 +424,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
418
424
|
if (match(event, Enter) && (!inputValue || allowCustomValue)) {
|
|
419
425
|
toggleMenu();
|
|
420
426
|
if (highlightedIndex !== -1) {
|
|
421
|
-
selectItem(items[highlightedIndex]);
|
|
427
|
+
selectItem(filterItems(items, itemToString, inputValue)[highlightedIndex]);
|
|
422
428
|
}
|
|
423
429
|
event.preventDownshiftDefault = true;
|
|
424
430
|
event?.persist?.();
|
|
@@ -53,7 +53,7 @@ interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
|
53
53
|
/**
|
|
54
54
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
55
55
|
*/
|
|
56
|
-
target?:
|
|
56
|
+
target?: Element;
|
|
57
57
|
/**
|
|
58
58
|
* Specify the x position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([x1, x2])
|
|
59
59
|
*/
|
|
@@ -14,6 +14,7 @@ import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { warning } from '../../internal/warning.js';
|
|
16
16
|
import { MenuContext, menuReducer } from './MenuContext.js';
|
|
17
|
+
import { canUseDOM } from '../../internal/environment.js';
|
|
17
18
|
import { useLayoutDirection } from '../LayoutDirection/useLayoutDirection.js';
|
|
18
19
|
import { match } from '../../internal/keyboard/match.js';
|
|
19
20
|
import { Escape, ArrowLeft, ArrowUp, ArrowDown } from '../../internal/keyboard/keys.js';
|
|
@@ -33,9 +34,8 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
33
34
|
open,
|
|
34
35
|
size = 'sm',
|
|
35
36
|
legacyAutoalign = 'true',
|
|
36
|
-
// TODO: #16004
|
|
37
37
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
|
|
38
|
-
target = document.body,
|
|
38
|
+
target = canUseDOM && document.body,
|
|
39
39
|
x = 0,
|
|
40
40
|
y = 0,
|
|
41
41
|
...rest
|
|
@@ -294,6 +294,9 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
294
294
|
onKeyDown: handleKeyDown,
|
|
295
295
|
onBlur: handleBlur
|
|
296
296
|
}), children));
|
|
297
|
+
if (!target) {
|
|
298
|
+
return rendered;
|
|
299
|
+
}
|
|
297
300
|
return isRoot ? open && /*#__PURE__*/createPortal(rendered, target) || null : rendered;
|
|
298
301
|
});
|
|
299
302
|
Menu.propTypes = {
|
|
@@ -231,6 +231,8 @@ 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('');
|
|
234
236
|
setIsOpen(false);
|
|
235
237
|
return changes;
|
|
236
238
|
case FunctionToggleMenu:
|
|
@@ -414,11 +416,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
414
416
|
$input.setSelectionRange($value.length, $value.length);
|
|
415
417
|
}
|
|
416
418
|
},
|
|
417
|
-
onFocus: () => setInputFocused(true)
|
|
418
|
-
onBlur() {
|
|
419
|
-
setInputFocused(false);
|
|
420
|
-
setInputValue('');
|
|
421
|
-
}
|
|
419
|
+
onFocus: () => setInputFocused(true)
|
|
422
420
|
}));
|
|
423
421
|
const menuProps = getMenuProps({}, {
|
|
424
422
|
suppressRefError: true
|
|
@@ -209,6 +209,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
209
209
|
"data-invalid": normalizedProps.invalid ? true : undefined,
|
|
210
210
|
"aria-invalid": normalizedProps.invalid,
|
|
211
211
|
"aria-describedby": ariaDescribedBy,
|
|
212
|
+
"aria-readonly": readOnly,
|
|
212
213
|
disabled: normalizedProps.disabled,
|
|
213
214
|
ref: ref,
|
|
214
215
|
id: id,
|
|
@@ -241,6 +241,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
241
241
|
kind: "ghost",
|
|
242
242
|
className: backButtonClasses,
|
|
243
243
|
label: backwardText,
|
|
244
|
+
"aria-label": backwardText,
|
|
244
245
|
onClick: decrementPage,
|
|
245
246
|
ref: backBtnRef
|
|
246
247
|
}, _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default.createElement(CaretLeft, null))), /*#__PURE__*/React__default.createElement(IconButton, {
|
|
@@ -249,6 +250,7 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
|
|
|
249
250
|
kind: "ghost",
|
|
250
251
|
className: forwardButtonClasses,
|
|
251
252
|
label: forwardText,
|
|
253
|
+
"aria-label": forwardText,
|
|
252
254
|
onClick: incrementPage,
|
|
253
255
|
ref: forwardBtnRef
|
|
254
256
|
}, _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null))))));
|
|
@@ -253,6 +253,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
253
253
|
className: `${prefix}--pagination-nav__list`
|
|
254
254
|
}, /*#__PURE__*/React__default.createElement(DirectionButton, {
|
|
255
255
|
direction: "backward",
|
|
256
|
+
"aria-label": t('carbon.pagination-nav.previous'),
|
|
256
257
|
label: t('carbon.pagination-nav.previous'),
|
|
257
258
|
disabled: backwardButtonDisabled,
|
|
258
259
|
onClick: jumpToPrevious
|
|
@@ -297,6 +298,7 @@ const PaginationNav = /*#__PURE__*/React__default.forwardRef(function Pagination
|
|
|
297
298
|
}
|
|
298
299
|
}), /*#__PURE__*/React__default.createElement(DirectionButton, {
|
|
299
300
|
direction: "forward",
|
|
301
|
+
"aria-label": t('carbon.pagination-nav.next'),
|
|
300
302
|
label: t('carbon.pagination-nav.next'),
|
|
301
303
|
disabled: forwardButtonDisabled,
|
|
302
304
|
onClick: jumpToNext
|
package/es/internal/Selection.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { defineProperty as _defineProperty } from '../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useRef, useState,
|
|
9
|
+
import React__default, { useRef, useState, useCallback, useEffect } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import isEqual from 'lodash.isequal';
|
|
12
12
|
|
|
@@ -39,19 +39,7 @@ function useSelection(_ref2) {
|
|
|
39
39
|
const savedOnChange = useRef(onChange);
|
|
40
40
|
const [uncontrolledItems, setUncontrolledItems] = useState(initialSelectedItems);
|
|
41
41
|
const isControlled = !!controlledItems;
|
|
42
|
-
const
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
setSelectedItems(isControlled ? controlledItems : uncontrolledItems);
|
|
45
|
-
}, [isControlled, controlledItems, uncontrolledItems]);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
callOnChangeHandler({
|
|
48
|
-
isControlled,
|
|
49
|
-
isMounted: isMounted.current,
|
|
50
|
-
onChangeHandlerControlled: savedOnChange.current,
|
|
51
|
-
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
52
|
-
selectedItems: selectedItems
|
|
53
|
-
});
|
|
54
|
-
}, [isControlled, isMounted, selectedItems]);
|
|
42
|
+
const selectedItems = isControlled ? controlledItems : uncontrolledItems;
|
|
55
43
|
const onItemChange = useCallback(item => {
|
|
56
44
|
if (disabled) {
|
|
57
45
|
return;
|
|
@@ -62,12 +50,27 @@ function useSelection(_ref2) {
|
|
|
62
50
|
selectedIndex = index;
|
|
63
51
|
}
|
|
64
52
|
});
|
|
53
|
+
let newSelectedItems;
|
|
65
54
|
if (selectedIndex === undefined) {
|
|
66
|
-
|
|
55
|
+
newSelectedItems = selectedItems.concat(item);
|
|
56
|
+
callOnChangeHandler({
|
|
57
|
+
isControlled,
|
|
58
|
+
isMounted: isMounted.current,
|
|
59
|
+
onChangeHandlerControlled: savedOnChange.current,
|
|
60
|
+
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
61
|
+
selectedItems: newSelectedItems
|
|
62
|
+
});
|
|
67
63
|
return;
|
|
68
64
|
}
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
newSelectedItems = removeAtIndex(selectedItems, selectedIndex);
|
|
66
|
+
callOnChangeHandler({
|
|
67
|
+
isControlled,
|
|
68
|
+
isMounted: isMounted.current,
|
|
69
|
+
onChangeHandlerControlled: savedOnChange.current,
|
|
70
|
+
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
71
|
+
selectedItems: newSelectedItems
|
|
72
|
+
});
|
|
73
|
+
}, [disabled, isControlled, selectedItems]);
|
|
71
74
|
const clearSelection = useCallback(() => {
|
|
72
75
|
if (disabled) {
|
|
73
76
|
return;
|
package/es/internal/useId.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import React__default, {
|
|
8
|
+
import React__default, { useState, useEffect, useLayoutEffect } from 'react';
|
|
9
9
|
import setupGetInstanceId from '../tools/setupGetInstanceId.js';
|
|
10
10
|
import { canUseDOM } from './environment.js';
|
|
11
11
|
import { useIdPrefix } from './useIdPrefix.js';
|
|
@@ -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);
|
|
@@ -428,7 +434,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
428
434
|
if (match.match(event, keys.Enter) && (!inputValue || allowCustomValue)) {
|
|
429
435
|
toggleMenu();
|
|
430
436
|
if (highlightedIndex !== -1) {
|
|
431
|
-
selectItem(items[highlightedIndex]);
|
|
437
|
+
selectItem(filterItems(items, itemToString, inputValue)[highlightedIndex]);
|
|
432
438
|
}
|
|
433
439
|
event.preventDownshiftDefault = true;
|
|
434
440
|
event?.persist?.();
|
|
@@ -53,7 +53,7 @@ interface MenuProps extends React.HTMLAttributes<HTMLUListElement> {
|
|
|
53
53
|
/**
|
|
54
54
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
55
55
|
*/
|
|
56
|
-
target?:
|
|
56
|
+
target?: Element;
|
|
57
57
|
/**
|
|
58
58
|
* Specify the x position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([x1, x2])
|
|
59
59
|
*/
|
|
@@ -18,6 +18,7 @@ var useMergedRefs = require('../../internal/useMergedRefs.js');
|
|
|
18
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
19
|
var warning = require('../../internal/warning.js');
|
|
20
20
|
var MenuContext = require('./MenuContext.js');
|
|
21
|
+
var environment = require('../../internal/environment.js');
|
|
21
22
|
var useLayoutDirection = require('../LayoutDirection/useLayoutDirection.js');
|
|
22
23
|
var match = require('../../internal/keyboard/match.js');
|
|
23
24
|
var keys = require('../../internal/keyboard/keys.js');
|
|
@@ -43,9 +44,8 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
43
44
|
open,
|
|
44
45
|
size = 'sm',
|
|
45
46
|
legacyAutoalign = 'true',
|
|
46
|
-
// TODO: #16004
|
|
47
47
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
|
|
48
|
-
target = document.body,
|
|
48
|
+
target = environment.canUseDOM && document.body,
|
|
49
49
|
x = 0,
|
|
50
50
|
y = 0,
|
|
51
51
|
...rest
|
|
@@ -304,6 +304,9 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu(_ref, forwardRef) {
|
|
|
304
304
|
onKeyDown: handleKeyDown,
|
|
305
305
|
onBlur: handleBlur
|
|
306
306
|
}), children));
|
|
307
|
+
if (!target) {
|
|
308
|
+
return rendered;
|
|
309
|
+
}
|
|
307
310
|
return isRoot ? open && /*#__PURE__*/ReactDOM.createPortal(rendered, target) || null : rendered;
|
|
308
311
|
});
|
|
309
312
|
Menu.propTypes = {
|
|
@@ -243,6 +243,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
243
243
|
return changes;
|
|
244
244
|
case InputBlur:
|
|
245
245
|
case InputKeyDownEscape:
|
|
246
|
+
setInputFocused(false);
|
|
247
|
+
setInputValue('');
|
|
246
248
|
setIsOpen(false);
|
|
247
249
|
return changes;
|
|
248
250
|
case FunctionToggleMenu:
|
|
@@ -426,11 +428,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default["default"].forwardRef(
|
|
|
426
428
|
$input.setSelectionRange($value.length, $value.length);
|
|
427
429
|
}
|
|
428
430
|
},
|
|
429
|
-
onFocus: () => setInputFocused(true)
|
|
430
|
-
onBlur() {
|
|
431
|
-
setInputFocused(false);
|
|
432
|
-
setInputValue('');
|
|
433
|
-
}
|
|
431
|
+
onFocus: () => setInputFocused(true)
|
|
434
432
|
}));
|
|
435
433
|
const menuProps = getMenuProps({}, {
|
|
436
434
|
suppressRefError: true
|
|
@@ -219,6 +219,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
|
|
|
219
219
|
"data-invalid": normalizedProps.invalid ? true : undefined,
|
|
220
220
|
"aria-invalid": normalizedProps.invalid,
|
|
221
221
|
"aria-describedby": ariaDescribedBy,
|
|
222
|
+
"aria-readonly": readOnly,
|
|
222
223
|
disabled: normalizedProps.disabled,
|
|
223
224
|
ref: ref,
|
|
224
225
|
id: id,
|
|
@@ -251,6 +251,7 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
251
251
|
kind: "ghost",
|
|
252
252
|
className: backButtonClasses,
|
|
253
253
|
label: backwardText,
|
|
254
|
+
"aria-label": backwardText,
|
|
254
255
|
onClick: decrementPage,
|
|
255
256
|
ref: backBtnRef
|
|
256
257
|
}, _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default["default"].createElement(iconsReact.CaretLeft, null))), /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
|
|
@@ -259,6 +260,7 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
|
|
|
259
260
|
kind: "ghost",
|
|
260
261
|
className: forwardButtonClasses,
|
|
261
262
|
label: forwardText,
|
|
263
|
+
"aria-label": forwardText,
|
|
262
264
|
onClick: incrementPage,
|
|
263
265
|
ref: forwardBtnRef
|
|
264
266
|
}, _CaretRight || (_CaretRight = /*#__PURE__*/React__default["default"].createElement(iconsReact.CaretRight, null))))));
|
|
@@ -263,6 +263,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
263
263
|
className: `${prefix}--pagination-nav__list`
|
|
264
264
|
}, /*#__PURE__*/React__default["default"].createElement(DirectionButton, {
|
|
265
265
|
direction: "backward",
|
|
266
|
+
"aria-label": t('carbon.pagination-nav.previous'),
|
|
266
267
|
label: t('carbon.pagination-nav.previous'),
|
|
267
268
|
disabled: backwardButtonDisabled,
|
|
268
269
|
onClick: jumpToPrevious
|
|
@@ -307,6 +308,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
307
308
|
}
|
|
308
309
|
}), /*#__PURE__*/React__default["default"].createElement(DirectionButton, {
|
|
309
310
|
direction: "forward",
|
|
311
|
+
"aria-label": t('carbon.pagination-nav.next'),
|
|
310
312
|
label: t('carbon.pagination-nav.next'),
|
|
311
313
|
disabled: forwardButtonDisabled,
|
|
312
314
|
onClick: jumpToNext
|
|
@@ -49,19 +49,7 @@ function useSelection(_ref2) {
|
|
|
49
49
|
const savedOnChange = React.useRef(onChange);
|
|
50
50
|
const [uncontrolledItems, setUncontrolledItems] = React.useState(initialSelectedItems);
|
|
51
51
|
const isControlled = !!controlledItems;
|
|
52
|
-
const
|
|
53
|
-
React.useEffect(() => {
|
|
54
|
-
setSelectedItems(isControlled ? controlledItems : uncontrolledItems);
|
|
55
|
-
}, [isControlled, controlledItems, uncontrolledItems]);
|
|
56
|
-
React.useEffect(() => {
|
|
57
|
-
callOnChangeHandler({
|
|
58
|
-
isControlled,
|
|
59
|
-
isMounted: isMounted.current,
|
|
60
|
-
onChangeHandlerControlled: savedOnChange.current,
|
|
61
|
-
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
62
|
-
selectedItems: selectedItems
|
|
63
|
-
});
|
|
64
|
-
}, [isControlled, isMounted, selectedItems]);
|
|
52
|
+
const selectedItems = isControlled ? controlledItems : uncontrolledItems;
|
|
65
53
|
const onItemChange = React.useCallback(item => {
|
|
66
54
|
if (disabled) {
|
|
67
55
|
return;
|
|
@@ -72,12 +60,27 @@ function useSelection(_ref2) {
|
|
|
72
60
|
selectedIndex = index;
|
|
73
61
|
}
|
|
74
62
|
});
|
|
63
|
+
let newSelectedItems;
|
|
75
64
|
if (selectedIndex === undefined) {
|
|
76
|
-
|
|
65
|
+
newSelectedItems = selectedItems.concat(item);
|
|
66
|
+
callOnChangeHandler({
|
|
67
|
+
isControlled,
|
|
68
|
+
isMounted: isMounted.current,
|
|
69
|
+
onChangeHandlerControlled: savedOnChange.current,
|
|
70
|
+
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
71
|
+
selectedItems: newSelectedItems
|
|
72
|
+
});
|
|
77
73
|
return;
|
|
78
74
|
}
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
newSelectedItems = removeAtIndex(selectedItems, selectedIndex);
|
|
76
|
+
callOnChangeHandler({
|
|
77
|
+
isControlled,
|
|
78
|
+
isMounted: isMounted.current,
|
|
79
|
+
onChangeHandlerControlled: savedOnChange.current,
|
|
80
|
+
onChangeHandlerUncontrolled: setUncontrolledItems,
|
|
81
|
+
selectedItems: newSelectedItems
|
|
82
|
+
});
|
|
83
|
+
}, [disabled, isControlled, selectedItems]);
|
|
81
84
|
const clearSelection = React.useCallback(() => {
|
|
82
85
|
if (disabled) {
|
|
83
86
|
return;
|
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.2",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "es/index.js",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@babel/runtime": "^7.18.3",
|
|
51
51
|
"@carbon/feature-flags": "^0.20.0",
|
|
52
|
-
"@carbon/icons-react": "^11.44.
|
|
53
|
-
"@carbon/layout": "^11.23.
|
|
54
|
-
"@carbon/styles": "^1.60.
|
|
52
|
+
"@carbon/icons-react": "^11.44.1",
|
|
53
|
+
"@carbon/layout": "^11.23.1",
|
|
54
|
+
"@carbon/styles": "^1.60.1",
|
|
55
55
|
"@figma/code-connect": "^0.1.2",
|
|
56
56
|
"@floating-ui/react": "^0.26.0",
|
|
57
57
|
"@ibm/telemetry-js": "^1.5.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@babel/preset-react": "^7.22.3",
|
|
83
83
|
"@babel/preset-typescript": "^7.21.5",
|
|
84
84
|
"@carbon/test-utils": "^10.30.0",
|
|
85
|
-
"@carbon/themes": "^11.37.
|
|
85
|
+
"@carbon/themes": "^11.37.1",
|
|
86
86
|
"@rollup/plugin-babel": "^6.0.0",
|
|
87
87
|
"@rollup/plugin-commonjs": "^26.0.0",
|
|
88
88
|
"@rollup/plugin-node-resolve": "^15.0.0",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
"**/*.scss",
|
|
143
143
|
"**/*.css"
|
|
144
144
|
],
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "d9b7c3eaee9e757cb7460d1ff626a1e2211a18fa"
|
|
146
146
|
}
|