@carbon/react 1.63.2 → 1.64.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 +1562 -1193
- package/es/components/{Slug → AILabel}/index.js +47 -35
- package/es/components/{AiSkeleton/AiSkeletonIcon.d.ts → AISkeleton/AISkeletonIcon.d.ts} +4 -4
- package/es/components/{AiSkeleton/AiSkeletonIcon.js → AISkeleton/AISkeletonIcon.js} +5 -5
- package/es/components/{AiSkeleton/AiSkeletonPlaceholder.d.ts → AISkeleton/AISkeletonPlaceholder.d.ts} +4 -4
- package/es/components/{AiSkeleton/AiSkeletonPlaceholder.js → AISkeleton/AISkeletonPlaceholder.js} +5 -5
- package/es/components/{AiSkeleton/AiSkeletonText.d.ts → AISkeleton/AISkeletonText.d.ts} +4 -4
- package/es/components/{AiSkeleton/AiSkeletonText.js → AISkeleton/AISkeletonText.js} +3 -3
- package/es/components/AISkeleton/index.d.ts +10 -0
- package/es/components/Accordion/AccordionItem.js +1 -0
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/es/components/ComboBox/ComboBox.js +4 -4
- package/es/components/ComposedModal/ComposedModal.js +1 -1
- package/es/components/DataTable/DataTable.js +1 -1
- package/es/components/DatePicker/DatePicker.js +16 -1
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dropdown/Dropdown.js +12 -6
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +4 -2
- package/es/components/Menu/MenuItem.js +45 -63
- package/es/components/Modal/Modal.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +44 -23
- package/es/components/MultiSelect/MultiSelect.js +6 -4
- package/es/components/NumberInput/NumberInput.js +12 -4
- package/es/components/OverflowMenu/OverflowMenu.js +2 -1
- package/es/components/OverflowMenu/next/index.js +2 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es/components/RadioTile/RadioTile.js +1 -1
- package/es/components/Select/Select.js +1 -1
- package/es/components/Tabs/Tabs.js +3 -3
- package/es/components/Tag/DismissibleTag.js +1 -1
- package/es/components/Tag/OperationalTag.js +1 -1
- package/es/components/Tag/SelectableTag.js +3 -1
- package/es/components/Tag/Tag.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextInput/PasswordInput.js +5 -0
- package/es/components/TextInput/TextInput.js +1 -1
- package/es/components/Tile/Tile.js +2 -2
- package/es/components/TreeView/TreeNode.d.ts +150 -0
- package/es/components/TreeView/TreeNode.js +22 -15
- package/es/components/TreeView/TreeView.d.ts +59 -0
- package/es/components/TreeView/TreeView.js +37 -23
- package/es/components/TreeView/index.d.ts +11 -0
- package/es/components/UIShell/SwitcherItem.d.ts +4 -0
- package/es/components/UIShell/SwitcherItem.js +7 -1
- package/es/index.d.ts +4 -2
- package/es/index.js +6 -6
- package/es/node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js +143 -0
- package/es/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs.js +39 -0
- package/lib/components/{Slug → AILabel}/index.js +49 -37
- package/lib/components/{AiSkeleton/AiSkeletonIcon.d.ts → AISkeleton/AISkeletonIcon.d.ts} +4 -4
- package/lib/components/{AiSkeleton/AiSkeletonIcon.js → AISkeleton/AISkeletonIcon.js} +5 -5
- package/lib/components/{AiSkeleton/AiSkeletonPlaceholder.d.ts → AISkeleton/AISkeletonPlaceholder.d.ts} +4 -4
- package/lib/components/{AiSkeleton/AiSkeletonPlaceholder.js → AISkeleton/AISkeletonPlaceholder.js} +5 -5
- package/lib/components/{AiSkeleton/AiSkeletonText.d.ts → AISkeleton/AISkeletonText.d.ts} +4 -4
- package/lib/components/{AiSkeleton/AiSkeletonText.js → AISkeleton/AISkeletonText.js} +3 -3
- package/lib/components/AISkeleton/index.d.ts +10 -0
- package/lib/components/Accordion/AccordionItem.js +1 -0
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +4 -4
- package/lib/components/ComposedModal/ComposedModal.js +1 -1
- package/lib/components/DataTable/DataTable.js +2 -2
- package/lib/components/DatePicker/DatePicker.js +15 -0
- package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +12 -6
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +4 -2
- package/lib/components/Menu/MenuItem.js +44 -62
- package/lib/components/Modal/Modal.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +43 -22
- package/lib/components/MultiSelect/MultiSelect.js +6 -4
- package/lib/components/NumberInput/NumberInput.js +12 -4
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -1
- package/lib/components/OverflowMenu/next/index.js +2 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +1 -1
- package/lib/components/Select/Select.js +1 -1
- package/lib/components/Tabs/Tabs.js +2 -2
- package/lib/components/Tag/DismissibleTag.js +1 -1
- package/lib/components/Tag/OperationalTag.js +1 -1
- package/lib/components/Tag/SelectableTag.js +3 -1
- package/lib/components/Tag/Tag.js +1 -1
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/TextInput/PasswordInput.js +5 -0
- package/lib/components/TextInput/TextInput.js +1 -1
- package/lib/components/Tile/Tile.js +2 -2
- package/lib/components/TreeView/TreeNode.d.ts +150 -0
- package/lib/components/TreeView/TreeNode.js +24 -17
- package/lib/components/TreeView/TreeView.d.ts +59 -0
- package/lib/components/TreeView/TreeView.js +39 -25
- package/lib/components/TreeView/index.d.ts +11 -0
- package/lib/components/UIShell/SwitcherItem.d.ts +4 -0
- package/lib/components/UIShell/SwitcherItem.js +7 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.js +20 -14
- package/lib/node_modules/@floating-ui/core/dist/floating-ui.core.mjs.js +148 -0
- package/lib/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs.js +47 -0
- package/package.json +5 -5
- package/scss/components/ai-label/_ai-label.scss +9 -0
- package/scss/components/ai-label/_index.scss +9 -0
- package/es/components/AiSkeleton/index.d.ts +0 -10
- package/es/components/DataTable/tools/instanceId.js +0 -20
- package/lib/components/AiSkeleton/index.d.ts +0 -10
- package/lib/components/DataTable/tools/instanceId.js +0 -24
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React__default, { forwardRef, useContext, useRef,
|
|
11
|
+
import React__default, { forwardRef, useState, useContext, useRef, useEffect } from 'react';
|
|
12
|
+
import { useFloating, autoUpdate, offset, useInteractions, useHover, safePolygon, FloatingFocusManager } from '@floating-ui/react';
|
|
12
13
|
import { CaretLeft, CaretRight, Checkmark } from '@carbon/icons-react';
|
|
13
14
|
import { useControllableState } from '../../internal/useControllableState.js';
|
|
14
15
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
@@ -23,9 +24,6 @@ import { match } from '../../internal/keyboard/match.js';
|
|
|
23
24
|
import { ArrowRight, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
24
25
|
|
|
25
26
|
var _CaretLeft, _CaretRight;
|
|
26
|
-
const hoverIntentDelay = 150; // in ms
|
|
27
|
-
const leaveIntentDelay = 300; // in ms
|
|
28
|
-
|
|
29
27
|
const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
30
28
|
let {
|
|
31
29
|
children,
|
|
@@ -38,19 +36,37 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
38
36
|
shortcut,
|
|
39
37
|
...rest
|
|
40
38
|
} = _ref;
|
|
39
|
+
const [submenuOpen, setSubmenuOpen] = useState(false);
|
|
40
|
+
const [rtl, setRtl] = useState(false);
|
|
41
|
+
const {
|
|
42
|
+
refs,
|
|
43
|
+
floatingStyles,
|
|
44
|
+
context: floatingContext
|
|
45
|
+
} = useFloating({
|
|
46
|
+
open: submenuOpen,
|
|
47
|
+
onOpenChange: setSubmenuOpen,
|
|
48
|
+
placement: rtl ? 'left-start' : 'right-start',
|
|
49
|
+
whileElementsMounted: autoUpdate,
|
|
50
|
+
middleware: [offset({
|
|
51
|
+
mainAxis: -6,
|
|
52
|
+
crossAxis: -6
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
const {
|
|
56
|
+
getReferenceProps,
|
|
57
|
+
getFloatingProps
|
|
58
|
+
} = useInteractions([useHover(floatingContext, {
|
|
59
|
+
delay: 100,
|
|
60
|
+
enabled: true,
|
|
61
|
+
handleClose: safePolygon({
|
|
62
|
+
requireIntent: false
|
|
63
|
+
})
|
|
64
|
+
})]);
|
|
41
65
|
const prefix = usePrefix();
|
|
42
66
|
const context = useContext(MenuContext);
|
|
43
67
|
const menuItem = useRef(null);
|
|
44
|
-
const ref = useMergedRefs([forwardRef, menuItem]);
|
|
45
|
-
const [boundaries, setBoundaries] = useState({
|
|
46
|
-
x: -1,
|
|
47
|
-
y: -1
|
|
48
|
-
});
|
|
49
|
-
const [rtl, setRtl] = useState(false);
|
|
68
|
+
const ref = useMergedRefs([forwardRef, menuItem, refs.setReference]);
|
|
50
69
|
const hasChildren = Boolean(children);
|
|
51
|
-
const [submenuOpen, setSubmenuOpen] = useState(false);
|
|
52
|
-
const hoverIntentTimeout = useRef(null);
|
|
53
|
-
const leaveIntentTimeout = useRef(null);
|
|
54
70
|
const isDisabled = disabled && !hasChildren;
|
|
55
71
|
const isDanger = kind === 'danger' && !hasChildren;
|
|
56
72
|
function registerItem() {
|
|
@@ -66,31 +82,10 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
66
82
|
if (!menuItem.current) {
|
|
67
83
|
return;
|
|
68
84
|
}
|
|
69
|
-
const {
|
|
70
|
-
x,
|
|
71
|
-
y,
|
|
72
|
-
width,
|
|
73
|
-
height
|
|
74
|
-
} = menuItem.current.getBoundingClientRect();
|
|
75
|
-
if (rtl) {
|
|
76
|
-
setBoundaries({
|
|
77
|
-
x: [-x, x - width],
|
|
78
|
-
y: [y, y + height]
|
|
79
|
-
});
|
|
80
|
-
} else {
|
|
81
|
-
setBoundaries({
|
|
82
|
-
x: [x, x + width],
|
|
83
|
-
y: [y, y + height]
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
85
|
setSubmenuOpen(true);
|
|
87
86
|
}
|
|
88
87
|
function closeSubmenu() {
|
|
89
88
|
setSubmenuOpen(false);
|
|
90
|
-
setBoundaries({
|
|
91
|
-
x: -1,
|
|
92
|
-
y: -1
|
|
93
|
-
});
|
|
94
89
|
}
|
|
95
90
|
function handleClick(e) {
|
|
96
91
|
if (!isDisabled) {
|
|
@@ -104,27 +99,6 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
104
99
|
}
|
|
105
100
|
}
|
|
106
101
|
}
|
|
107
|
-
function handleMouseEnter() {
|
|
108
|
-
if (leaveIntentTimeout.current) {
|
|
109
|
-
// When mouse reenters before closing keep sub menu open
|
|
110
|
-
clearTimeout(leaveIntentTimeout.current);
|
|
111
|
-
leaveIntentTimeout.current = null;
|
|
112
|
-
}
|
|
113
|
-
hoverIntentTimeout.current = setTimeout(() => {
|
|
114
|
-
openSubmenu();
|
|
115
|
-
}, hoverIntentDelay);
|
|
116
|
-
}
|
|
117
|
-
function handleMouseLeave() {
|
|
118
|
-
if (hoverIntentTimeout.current) {
|
|
119
|
-
clearTimeout(hoverIntentTimeout.current);
|
|
120
|
-
// Avoid closing the sub menu as soon as mouse leaves
|
|
121
|
-
// prevents accidental closure due to scroll bar
|
|
122
|
-
leaveIntentTimeout.current = setTimeout(() => {
|
|
123
|
-
closeSubmenu();
|
|
124
|
-
menuItem.current?.focus();
|
|
125
|
-
}, leaveIntentDelay);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
102
|
function handleKeyDown(e) {
|
|
129
103
|
if (hasChildren && match(e, ArrowRight)) {
|
|
130
104
|
openSubmenu();
|
|
@@ -169,7 +143,18 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
169
143
|
});
|
|
170
144
|
}
|
|
171
145
|
}, [iconsAllowed, IconElement, context.state.hasIcons, context]);
|
|
172
|
-
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
Object.keys(floatingStyles).forEach(style => {
|
|
148
|
+
if (refs.floating.current && style !== 'position') {
|
|
149
|
+
refs.floating.current.style[style] = floatingStyles[style];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}, [floatingStyles, refs.floating]);
|
|
153
|
+
return /*#__PURE__*/React__default.createElement(FloatingFocusManager, {
|
|
154
|
+
context: floatingContext,
|
|
155
|
+
order: ['reference', 'floating'],
|
|
156
|
+
modal: false
|
|
157
|
+
}, /*#__PURE__*/React__default.createElement("li", _extends({
|
|
173
158
|
role: "menuitem"
|
|
174
159
|
}, rest, {
|
|
175
160
|
ref: ref,
|
|
@@ -179,10 +164,8 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
179
164
|
"aria-haspopup": hasChildren ?? undefined,
|
|
180
165
|
"aria-expanded": hasChildren ? submenuOpen : undefined,
|
|
181
166
|
onClick: handleClick,
|
|
182
|
-
onMouseEnter: hasChildren ? handleMouseEnter : undefined,
|
|
183
|
-
onMouseLeave: hasChildren ? handleMouseLeave : undefined,
|
|
184
167
|
onKeyDown: handleKeyDown
|
|
185
|
-
}), /*#__PURE__*/React__default.createElement("div", {
|
|
168
|
+
}, getReferenceProps()), /*#__PURE__*/React__default.createElement("div", {
|
|
186
169
|
className: `${prefix}--menu-item__icon`
|
|
187
170
|
}, iconsAllowed && IconElement && /*#__PURE__*/React__default.createElement(IconElement, null)), /*#__PURE__*/React__default.createElement(Text, {
|
|
188
171
|
as: "div",
|
|
@@ -192,16 +175,15 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
192
175
|
className: `${prefix}--menu-item__shortcut`
|
|
193
176
|
}, shortcut), hasChildren && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
|
|
194
177
|
className: `${prefix}--menu-item__shortcut`
|
|
195
|
-
}, rtl ? _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default.createElement(CaretLeft, null)) : _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null))), /*#__PURE__*/React__default.createElement(Menu, {
|
|
178
|
+
}, rtl ? _CaretLeft || (_CaretLeft = /*#__PURE__*/React__default.createElement(CaretLeft, null)) : _CaretRight || (_CaretRight = /*#__PURE__*/React__default.createElement(CaretRight, null))), /*#__PURE__*/React__default.createElement(Menu, _extends({
|
|
196
179
|
label: label,
|
|
197
180
|
open: submenuOpen,
|
|
198
181
|
onClose: () => {
|
|
199
182
|
closeSubmenu();
|
|
200
183
|
menuItem.current?.focus();
|
|
201
184
|
},
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}, children)));
|
|
185
|
+
ref: refs.setFloating
|
|
186
|
+
}, getFloatingProps()), children))));
|
|
205
187
|
});
|
|
206
188
|
MenuItem.propTypes = {
|
|
207
189
|
/**
|
|
@@ -229,7 +229,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
229
229
|
|
|
230
230
|
// Slug is always size `sm`
|
|
231
231
|
let normalizedSlug;
|
|
232
|
-
if (slug && slug['type']?.displayName === '
|
|
232
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
233
233
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
234
234
|
size: 'sm'
|
|
235
235
|
});
|
|
@@ -11,7 +11,7 @@ import cx from 'classnames';
|
|
|
11
11
|
import Downshift, { useCombobox, useMultipleSelection } from 'downshift';
|
|
12
12
|
import isEqual from 'react-fast-compare';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useContext, useState, useLayoutEffect, useRef,
|
|
14
|
+
import React__default, { useContext, useState, useLayoutEffect, useRef, useMemo, useEffect } from 'react';
|
|
15
15
|
import { defaultFilterItems } from '../ComboBox/tools/filter.js';
|
|
16
16
|
import { sortingPropTypes } from './MultiSelectPropTypes.js';
|
|
17
17
|
import ListBox from '../ListBox/index.js';
|
|
@@ -164,20 +164,23 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
164
164
|
setPrevOpen(open);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
//
|
|
168
|
-
const sortedItems =
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
167
|
+
// memoize sorted items to reduce unnecessary expensive sort on rerender
|
|
168
|
+
const sortedItems = useMemo(() => {
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
170
|
+
return sortItems(filterItems(items, {
|
|
171
|
+
itemToString,
|
|
172
|
+
inputValue
|
|
173
|
+
}), {
|
|
174
|
+
selectedItems: {
|
|
175
|
+
top: controlledSelectedItems,
|
|
176
|
+
fixed: [],
|
|
177
|
+
'top-after-reopen': topItems
|
|
178
|
+
}[selectionFeedback],
|
|
179
|
+
itemToString,
|
|
180
|
+
compareItems,
|
|
181
|
+
locale
|
|
182
|
+
});
|
|
183
|
+
}, [items, inputValue, controlledSelectedItems, topItems, selectionFeedback, itemToString, compareItems, locale]);
|
|
181
184
|
const inline = type === 'inline';
|
|
182
185
|
const showWarning = !invalid && warn;
|
|
183
186
|
const wrapperClasses = cx(`${prefix}--multi-select__wrapper`, `${prefix}--multi-select--filterable__wrapper`, `${prefix}--list-box__wrapper`, containerClassName, {
|
|
@@ -217,9 +220,15 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
217
220
|
setTopItems(controlledSelectedItems);
|
|
218
221
|
}
|
|
219
222
|
}, [controlledSelectedItems, isOpen, setTopItems]);
|
|
223
|
+
const validateHighlightFocus = () => {
|
|
224
|
+
if (controlledSelectedItems.length > 0) {
|
|
225
|
+
setHighlightedIndex(0);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
220
228
|
function handleMenuChange(forceIsOpen) {
|
|
221
229
|
const nextIsOpen = forceIsOpen ?? !isOpen;
|
|
222
230
|
setIsOpen(nextIsOpen);
|
|
231
|
+
validateHighlightFocus();
|
|
223
232
|
if (onMenuChange) {
|
|
224
233
|
onMenuChange(nextIsOpen);
|
|
225
234
|
}
|
|
@@ -237,9 +246,8 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
237
246
|
} = useCombobox({
|
|
238
247
|
isOpen,
|
|
239
248
|
items: sortedItems,
|
|
249
|
+
// defaultHighlightedIndex: 0, // after selection, highlight the first item.
|
|
240
250
|
itemToString,
|
|
241
|
-
defaultHighlightedIndex: 0,
|
|
242
|
-
// after selection, highlight the first item.
|
|
243
251
|
id,
|
|
244
252
|
labelId,
|
|
245
253
|
menuId,
|
|
@@ -284,24 +292,37 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
284
292
|
return changes;
|
|
285
293
|
case FunctionToggleMenu:
|
|
286
294
|
case ToggleButtonClick:
|
|
295
|
+
validateHighlightFocus();
|
|
287
296
|
if (changes.isOpen && !changes.selectedItem) {
|
|
288
297
|
return {
|
|
289
|
-
...changes
|
|
290
|
-
highlightedIndex: 0
|
|
298
|
+
...changes
|
|
291
299
|
};
|
|
292
300
|
}
|
|
293
|
-
return
|
|
301
|
+
return {
|
|
302
|
+
...changes,
|
|
303
|
+
highlightedIndex: null
|
|
304
|
+
};
|
|
294
305
|
case InputChange:
|
|
295
306
|
if (onInputValueChange) {
|
|
296
307
|
onInputValueChange(changes.inputValue);
|
|
297
308
|
}
|
|
298
309
|
setInputValue(changes.inputValue ?? '');
|
|
299
310
|
setIsOpen(true);
|
|
300
|
-
return
|
|
311
|
+
return {
|
|
312
|
+
...changes,
|
|
313
|
+
highlightedIndex: 0
|
|
314
|
+
};
|
|
301
315
|
case InputClick:
|
|
316
|
+
validateHighlightFocus();
|
|
317
|
+
if (changes.isOpen && !changes.selectedItem) {
|
|
318
|
+
return {
|
|
319
|
+
...changes
|
|
320
|
+
};
|
|
321
|
+
}
|
|
302
322
|
return {
|
|
303
323
|
...changes,
|
|
304
|
-
isOpen: false
|
|
324
|
+
isOpen: false,
|
|
325
|
+
highlightedIndex: null
|
|
305
326
|
};
|
|
306
327
|
case MenuMouseLeave:
|
|
307
328
|
return {
|
|
@@ -385,7 +406,7 @@ const FilterableMultiSelect = /*#__PURE__*/React__default.forwardRef(function Fi
|
|
|
385
406
|
|
|
386
407
|
// Slug is always size `mini`
|
|
387
408
|
let normalizedSlug;
|
|
388
|
-
if (slug && slug['type']?.displayName === '
|
|
409
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
389
410
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
390
411
|
size: 'mini'
|
|
391
412
|
});
|
|
@@ -311,7 +311,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
311
311
|
setIsOpenWrapper(changes.isOpen || false);
|
|
312
312
|
return {
|
|
313
313
|
...changes,
|
|
314
|
-
highlightedIndex: 0
|
|
314
|
+
highlightedIndex: controlledSelectedItems.length > 0 ? 0 : undefined
|
|
315
315
|
};
|
|
316
316
|
case ItemClick:
|
|
317
317
|
setHighlightedIndex(changes.selectedItem);
|
|
@@ -386,7 +386,7 @@ const MultiSelect = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
386
386
|
|
|
387
387
|
// Slug is always size `mini`
|
|
388
388
|
let normalizedSlug;
|
|
389
|
-
if (slug && slug['type']?.displayName === '
|
|
389
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
390
390
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
391
391
|
size: 'mini'
|
|
392
392
|
});
|
|
@@ -506,7 +506,8 @@ MultiSelect.propTypes = {
|
|
|
506
506
|
clearSelectionText: PropTypes.string,
|
|
507
507
|
/**
|
|
508
508
|
* Provide a compare function that is used to determine the ordering of
|
|
509
|
-
* options. See 'sortItems' for more control.
|
|
509
|
+
* options. See 'sortItems' for more control. Consider
|
|
510
|
+
* declaring function with `useCallback` to prevent unnecessary re-renders.
|
|
510
511
|
*/
|
|
511
512
|
compareItems: PropTypes.func,
|
|
512
513
|
/**
|
|
@@ -560,7 +561,8 @@ MultiSelect.propTypes = {
|
|
|
560
561
|
/**
|
|
561
562
|
* Helper function passed to downshift that allows the library to render a
|
|
562
563
|
* given item to a string label. By default, it extracts the `label` field
|
|
563
|
-
* from a given item to serve as the item label in the list.
|
|
564
|
+
* from a given item to serve as the item label in the list. Consider
|
|
565
|
+
* declaring function with `useCallback` to prevent unnecessary re-renders.
|
|
564
566
|
*/
|
|
565
567
|
itemToString: PropTypes.func,
|
|
566
568
|
/**
|
|
@@ -163,9 +163,17 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
163
163
|
const Icon = normalizedProps.icon;
|
|
164
164
|
function handleStepperClick(event, direction) {
|
|
165
165
|
if (inputRef.current) {
|
|
166
|
-
|
|
166
|
+
const currentValue = Number(inputRef.current.value);
|
|
167
|
+
let newValue = direction === 'up' ? currentValue + step : currentValue - step;
|
|
168
|
+
if (min !== undefined) {
|
|
169
|
+
newValue = Math.max(newValue, min);
|
|
170
|
+
}
|
|
171
|
+
if (max !== undefined) {
|
|
172
|
+
newValue = Math.min(newValue, max);
|
|
173
|
+
}
|
|
174
|
+
const currentInputValue = inputRef.current ? inputRef.current.value : '';
|
|
167
175
|
const state = {
|
|
168
|
-
value: allowEmpty &&
|
|
176
|
+
value: allowEmpty && currentInputValue === '' && step === 0 ? '' : newValue,
|
|
169
177
|
direction: direction
|
|
170
178
|
};
|
|
171
179
|
setValue(state.value);
|
|
@@ -180,7 +188,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
180
188
|
|
|
181
189
|
// Slug is always size `mini`
|
|
182
190
|
let normalizedSlug;
|
|
183
|
-
if (slug && slug['type']?.displayName === '
|
|
191
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
184
192
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
185
193
|
size: 'mini'
|
|
186
194
|
});
|
|
@@ -188,7 +196,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
|
|
|
188
196
|
|
|
189
197
|
// Need to update the internal value when the revert button is clicked
|
|
190
198
|
let isRevertActive;
|
|
191
|
-
if (slug && slug['type']?.displayName === '
|
|
199
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
192
200
|
isRevertActive = normalizedSlug.props.revertActive;
|
|
193
201
|
}
|
|
194
202
|
useEffect(() => {
|
|
@@ -405,7 +405,8 @@ class OverflowMenu extends React__default.Component {
|
|
|
405
405
|
id: id,
|
|
406
406
|
ref: mergeRefs(this._triggerRef, ref),
|
|
407
407
|
size: size,
|
|
408
|
-
label: iconDescription
|
|
408
|
+
label: iconDescription,
|
|
409
|
+
kind: "ghost"
|
|
409
410
|
}), /*#__PURE__*/React__default.createElement(IconElement, iconProps)), open && this.state.hasMountedTrigger && wrappedMenuBody));
|
|
410
411
|
}
|
|
411
412
|
}
|
|
@@ -96,7 +96,8 @@ const OverflowMenu = /*#__PURE__*/React__default.forwardRef(function OverflowMen
|
|
|
96
96
|
onMouseDown: handleMousedown,
|
|
97
97
|
ref: floatingRef,
|
|
98
98
|
label: label,
|
|
99
|
-
align: tooltipAlignment
|
|
99
|
+
align: tooltipAlignment,
|
|
100
|
+
kind: "ghost"
|
|
100
101
|
}, /*#__PURE__*/React__default.createElement(IconElement, {
|
|
101
102
|
className: `${prefix}--overflow-menu__icon`
|
|
102
103
|
})), /*#__PURE__*/React__default.createElement(Menu, {
|
|
@@ -101,7 +101,7 @@ const RadioButtonGroup = /*#__PURE__*/React__default.forwardRef((props, ref) =>
|
|
|
101
101
|
|
|
102
102
|
// Slug is always size `mini`
|
|
103
103
|
let normalizedSlug;
|
|
104
|
-
if (slug && slug['type']?.displayName === '
|
|
104
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
105
105
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
106
106
|
size: 'mini',
|
|
107
107
|
kind: 'default'
|
|
@@ -71,7 +71,7 @@ const RadioTile = /*#__PURE__*/React__default.forwardRef(function RadioTile(_ref
|
|
|
71
71
|
|
|
72
72
|
// Slug is always size `xs`
|
|
73
73
|
let normalizedSlug;
|
|
74
|
-
if (slug && slug['type']?.displayName === '
|
|
74
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
75
75
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
76
76
|
size: 'xs'
|
|
77
77
|
});
|
|
@@ -125,7 +125,7 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
|
|
|
125
125
|
|
|
126
126
|
// Slug is always size `mini`
|
|
127
127
|
let normalizedSlug;
|
|
128
|
-
if (slug && slug['type']?.displayName === '
|
|
128
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
129
129
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
130
130
|
size: 'mini'
|
|
131
131
|
});
|
|
@@ -11,7 +11,7 @@ import { breakpoints } from '@carbon/layout';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import debounce from 'lodash.debounce';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
|
-
import React__default, { useState, useRef, useCallback, useEffect, forwardRef
|
|
14
|
+
import React__default, { useState, useRef, useCallback, useEffect, forwardRef } from 'react';
|
|
15
15
|
import '../Grid/FlexGrid.js';
|
|
16
16
|
import { Grid as GridAsGridComponent } from '../Grid/Grid.js';
|
|
17
17
|
import '../Grid/Row.js';
|
|
@@ -787,7 +787,7 @@ const Tab = /*#__PURE__*/forwardRef(function Tab(_ref8, forwardRef) {
|
|
|
787
787
|
};
|
|
788
788
|
useEvent(dismissIconRef, 'mouseover', onDismissIconMouseEnter);
|
|
789
789
|
useEvent(dismissIconRef, 'mouseleave', onDismissIconMouseLeave);
|
|
790
|
-
|
|
790
|
+
useIsomorphicEffect(() => {
|
|
791
791
|
function handler() {
|
|
792
792
|
const elementTabId = document.getElementById(`${id}`) || tabRef.current;
|
|
793
793
|
if (elementTabId?.closest(`.${prefix}--tabs--vertical`)) {
|
|
@@ -1128,7 +1128,7 @@ function TabPanels(_ref11) {
|
|
|
1128
1128
|
const prefix = usePrefix();
|
|
1129
1129
|
const refs = useRef([]);
|
|
1130
1130
|
const hiddenStates = useRef([]);
|
|
1131
|
-
|
|
1131
|
+
useIsomorphicEffect(() => {
|
|
1132
1132
|
const tabContainer = refs.current[0]?.previousElementSibling;
|
|
1133
1133
|
const isVertical = tabContainer?.classList.contains(`${prefix}--tabs--vertical`);
|
|
1134
1134
|
const parentHasHeight = tabContainer?.parentElement?.style.height;
|
|
@@ -50,7 +50,7 @@ const DismissibleTag = _ref => {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
let normalizedSlug;
|
|
53
|
-
if (slug && slug['type']?.displayName === '
|
|
53
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
54
54
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
55
55
|
size: 'sm',
|
|
56
56
|
kind: 'inline'
|
|
@@ -52,7 +52,7 @@ const OperationalTag = _ref => {
|
|
|
52
52
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
53
53
|
}, [prefix, tagRef]);
|
|
54
54
|
let normalizedSlug;
|
|
55
|
-
if (slug && slug['type']?.displayName === '
|
|
55
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
56
56
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
57
57
|
size: 'sm',
|
|
58
58
|
kind: 'inline'
|
|
@@ -43,7 +43,7 @@ const SelectableTag = _ref => {
|
|
|
43
43
|
setIsEllipsisApplied(isEllipsisActive(newElement));
|
|
44
44
|
}, [prefix, tagRef]);
|
|
45
45
|
let normalizedSlug;
|
|
46
|
-
if (slug && slug['type']?.displayName === '
|
|
46
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
47
47
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
48
48
|
size: 'sm',
|
|
49
49
|
kind: 'inline'
|
|
@@ -65,6 +65,7 @@ const SelectableTag = _ref => {
|
|
|
65
65
|
leaveDelayMs: 0,
|
|
66
66
|
onMouseEnter: () => false
|
|
67
67
|
}, /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
68
|
+
"aria-pressed": selectedTag,
|
|
68
69
|
ref: tagRef,
|
|
69
70
|
slug: slug,
|
|
70
71
|
size: size,
|
|
@@ -79,6 +80,7 @@ const SelectableTag = _ref => {
|
|
|
79
80
|
}, text), normalizedSlug));
|
|
80
81
|
}
|
|
81
82
|
return /*#__PURE__*/React__default.createElement(Tag, _extends({
|
|
83
|
+
"aria-pressed": selectedTag,
|
|
82
84
|
ref: tagRef,
|
|
83
85
|
slug: slug,
|
|
84
86
|
size: size,
|
package/es/components/Tag/Tag.js
CHANGED
|
@@ -89,7 +89,7 @@ const Tag = /*#__PURE__*/React__default.forwardRef(function Tag(_ref, forwardRef
|
|
|
89
89
|
|
|
90
90
|
// Slug is always size `md` and `inline`
|
|
91
91
|
let normalizedSlug;
|
|
92
|
-
if (slug && slug['type']?.displayName === '
|
|
92
|
+
if (slug && slug['type']?.displayName === 'AILabel' && !isInteractiveTag) {
|
|
93
93
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
94
94
|
size: 'sm',
|
|
95
95
|
kind: 'inline'
|
|
@@ -255,7 +255,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
|
|
|
255
255
|
|
|
256
256
|
// Slug is always size `mini`
|
|
257
257
|
let normalizedSlug;
|
|
258
|
-
if (slug && slug['type']?.displayName === '
|
|
258
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
259
259
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
260
260
|
size: 'mini'
|
|
261
261
|
});
|
|
@@ -148,6 +148,11 @@ const PasswordInput = /*#__PURE__*/React__default.forwardRef(function PasswordIn
|
|
|
148
148
|
if (tooltipPosition === 'right' || tooltipPosition === 'left') {
|
|
149
149
|
align = tooltipPosition;
|
|
150
150
|
}
|
|
151
|
+
if (!hidePasswordLabel || hidePasswordLabel.trim() === '') {
|
|
152
|
+
console.warn('Warning: The "hidePasswordLabel" should not be blank.');
|
|
153
|
+
} else if (!showPasswordLabel || showPasswordLabel.trim() === '') {
|
|
154
|
+
console.warn('Warning: The "showPasswordLabel" should not be blank.');
|
|
155
|
+
}
|
|
151
156
|
const input = /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("input", _extends({}, textInputProps({
|
|
152
157
|
sharedTextInputProps,
|
|
153
158
|
invalid: normalizedProps.invalid,
|
|
@@ -181,7 +181,7 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
|
|
|
181
181
|
|
|
182
182
|
// Slug is always size `mini`
|
|
183
183
|
let normalizedSlug;
|
|
184
|
-
if (slug && slug['type']?.displayName === '
|
|
184
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
185
185
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
186
186
|
size: 'mini'
|
|
187
187
|
});
|
|
@@ -269,7 +269,7 @@ const SelectableTile = /*#__PURE__*/React__default.forwardRef(function Selectabl
|
|
|
269
269
|
// Slug is always size `xs`
|
|
270
270
|
const slugRef = useRef(null);
|
|
271
271
|
let normalizedSlug;
|
|
272
|
-
if (slug && slug['type']?.displayName === '
|
|
272
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
273
273
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
274
274
|
size: 'xs',
|
|
275
275
|
ref: slugRef
|
|
@@ -495,7 +495,7 @@ const ExpandableTile = /*#__PURE__*/React__default.forwardRef(function Expandabl
|
|
|
495
495
|
|
|
496
496
|
// Slug is always size `xs`
|
|
497
497
|
let normalizedSlug;
|
|
498
|
-
if (slug && slug['type']?.displayName === '
|
|
498
|
+
if (slug && slug['type']?.displayName === 'AILabel') {
|
|
499
499
|
normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
|
|
500
500
|
size: 'xs'
|
|
501
501
|
});
|