@carbon/react 1.90.0-rc.0 → 1.90.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 +743 -784
- package/es/components/AILabel/index.js +8 -6
- package/es/components/Breadcrumb/BreadcrumbItem.js +2 -0
- package/es/components/Button/Button.js +3 -0
- package/es/components/ChatButton/ChatButton.js +1 -0
- package/es/components/CheckboxGroup/CheckboxGroup.js +21 -2
- package/es/components/ComboBox/ComboBox.js +17 -1
- package/es/components/ComboButton/index.js +1 -0
- package/es/components/ComposedModal/ComposedModal.js +4 -1
- package/es/components/DataTable/DataTable.js +14 -0
- package/es/components/DataTable/Table.js +3 -3
- package/es/components/DataTable/TableExpandHeader.js +5 -1
- package/es/components/DataTable/TableExpandRow.js +1 -0
- package/es/components/DataTable/TableHeader.js +2 -0
- package/es/components/DataTable/TableRow.js +5 -0
- package/es/components/DataTable/TableSlugRow.js +1 -0
- package/es/components/DataTable/TableToolbarMenu.js +3 -0
- package/es/components/DataTable/state/sorting.d.ts +3 -1
- package/es/components/DataTable/state/sorting.js +2 -0
- package/es/components/DataTable/tools/sorting.js +1 -0
- package/es/components/DatePicker/DatePicker.js +14 -3
- package/es/components/DatePickerInput/DatePickerInput.js +6 -0
- package/es/components/Dialog/Dialog.js +10 -2
- package/es/components/Dropdown/Dropdown.js +16 -4
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +1 -0
- package/es/components/FileUploader/FileUploader.js +9 -2
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +3 -0
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +2 -0
- package/es/components/FluidNumberInput/FluidNumberInput.js +3 -2
- package/es/components/FluidSearch/FluidSearch.js +3 -2
- package/es/components/FluidSelect/FluidSelect.js +3 -2
- package/es/components/FluidTextInput/FluidTextInput.js +3 -2
- package/es/components/FluidTimePicker/FluidTimePicker.js +11 -4
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +3 -2
- package/es/components/Grid/CSSGrid.js +5 -0
- package/es/components/Grid/Column.js +3 -0
- package/es/components/Grid/ColumnHang.js +1 -0
- package/es/components/Grid/FlexGrid.js +1 -0
- package/es/components/Grid/Row.js +1 -0
- package/es/components/Heading/index.js +3 -1
- package/es/components/IconButton/index.js +4 -2
- package/es/components/IconIndicator/index.js +4 -2
- package/es/components/InlineCheckbox/InlineCheckbox.js +3 -2
- package/es/components/Layout/index.js +6 -4
- package/es/components/LayoutDirection/LayoutDirection.js +2 -0
- package/es/components/Link/Link.js +3 -0
- package/es/components/ListBox/ListBoxMenuItem.js +4 -1
- package/es/components/ListBox/next/ListBoxTrigger.js +3 -2
- package/es/components/Menu/Menu.js +6 -9
- package/es/components/Menu/MenuContext.js +1 -0
- package/es/components/Menu/MenuItem.js +5 -13
- package/es/components/MenuButton/index.js +7 -2
- package/es/components/Modal/Modal.js +3 -0
- package/es/components/ModalWrapper/ModalWrapper.js +2 -0
- package/es/components/MultiSelect/FilterableMultiSelect.js +24 -5
- package/es/components/MultiSelect/MultiSelect.js +21 -5
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.js +7 -1
- package/es/components/OverflowMenu/OverflowMenu.js +2 -0
- package/es/components/OverflowMenu/next/index.js +3 -2
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -0
- package/es/components/PageHeader/PageHeader.d.ts +3 -3
- package/es/components/PageHeader/PageHeader.js +22 -8
- package/es/components/Pagination/Pagination.js +6 -2
- package/es/components/PaginationNav/PaginationNav.js +2 -5
- package/es/components/Popover/index.js +14 -4
- package/es/components/ProgressBar/ProgressBar.js +4 -2
- package/es/components/RadioTile/RadioTile.js +2 -2
- package/es/components/Search/Search.js +2 -2
- package/es/components/Select/Select.js +2 -3
- package/es/components/ShapeIndicator/index.js +4 -2
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +4 -4
- package/es/components/SkeletonPlaceholder/SkeletonPlaceholder.js +1 -2
- package/es/components/SkeletonText/SkeletonText.js +0 -2
- package/es/components/Slider/Slider.js +11 -16
- package/es/components/Stack/HStack.js +1 -0
- package/es/components/Stack/Stack.js +6 -9
- package/es/components/Stack/VStack.js +1 -0
- package/es/components/StructuredList/StructuredList.js +3 -0
- package/es/components/Switch/Switch.js +1 -1
- package/es/components/Tabs/Tabs.js +28 -17
- package/es/components/Tag/DismissibleTag.js +2 -0
- package/es/components/Tag/OperationalTag.js +2 -0
- package/es/components/Tag/SelectableTag.js +2 -0
- package/es/components/Tag/Tag.js +4 -0
- package/es/components/Tag/isEllipsisActive.js +1 -0
- package/es/components/Text/Text.js +1 -0
- package/es/components/TextInput/ControlledPasswordInput.js +2 -4
- package/es/components/TextInput/PasswordInput.js +7 -2
- package/es/components/TextInput/TextInput.js +4 -2
- package/es/components/Theme/index.js +8 -3
- package/es/components/Tile/Tile.js +14 -17
- package/es/components/TimePicker/TimePicker.js +1 -0
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/Toggletip/index.js +4 -0
- package/es/components/Tooltip/DefinitionTooltip.js +1 -0
- package/es/components/Tooltip/Tooltip.js +30 -23
- package/es/components/TreeView/TreeNode.js +13 -5
- package/es/components/TreeView/TreeView.js +7 -0
- package/es/components/UIShell/HeaderContainer.js +3 -1
- package/es/components/UIShell/HeaderGlobalAction.js +2 -2
- package/es/components/UIShell/HeaderMenu.js +3 -3
- package/es/components/UIShell/HeaderPanel.js +2 -2
- package/es/components/UIShell/Link.js +2 -0
- package/es/components/UIShell/SideNavItems.js +1 -0
- package/es/components/UIShell/SideNavMenu.js +2 -2
- package/es/components/UIShell/SideNavMenuItem.js +1 -1
- package/es/components/UIShell/SideNavSwitcher.js +1 -1
- package/es/components/UIShell/Switcher.js +2 -1
- package/es/components/UIShell/SwitcherItem.js +4 -2
- package/es/internal/FloatingMenu.js +7 -1
- package/es/internal/Selection.js +12 -3
- package/es/internal/useMergedRefs.js +1 -0
- package/es/internal/useNoInteractiveChildren.js +4 -0
- package/es/internal/useOutsideClick.js +1 -0
- package/es/internal/useOverflowItems.js +6 -0
- package/es/internal/useResizeObserver.js +4 -0
- package/es/internal/useSavedCallback.js +1 -0
- package/es/internal/warning.js +1 -0
- package/es/prop-types/isRequiredOneOf.js +4 -1
- package/es/tools/events.js +3 -1
- package/es/tools/wrapComponent.js +1 -0
- package/lib/components/AILabel/index.js +8 -6
- package/lib/components/Breadcrumb/BreadcrumbItem.js +2 -0
- package/lib/components/Button/Button.js +3 -0
- package/lib/components/ChatButton/ChatButton.js +1 -0
- package/lib/components/CheckboxGroup/CheckboxGroup.js +20 -1
- package/lib/components/ComboBox/ComboBox.js +17 -1
- package/lib/components/ComboButton/index.js +1 -0
- package/lib/components/ComposedModal/ComposedModal.js +4 -1
- package/lib/components/DataTable/DataTable.js +14 -0
- package/lib/components/DataTable/Table.js +3 -3
- package/lib/components/DataTable/TableExpandHeader.js +5 -1
- package/lib/components/DataTable/TableExpandRow.js +1 -0
- package/lib/components/DataTable/TableHeader.js +2 -0
- package/lib/components/DataTable/TableRow.js +5 -0
- package/lib/components/DataTable/TableSlugRow.js +1 -0
- package/lib/components/DataTable/TableToolbarMenu.js +3 -0
- package/lib/components/DataTable/state/sorting.d.ts +3 -1
- package/lib/components/DataTable/state/sorting.js +2 -0
- package/lib/components/DataTable/tools/sorting.js +1 -0
- package/lib/components/DatePicker/DatePicker.js +14 -3
- package/lib/components/DatePickerInput/DatePickerInput.js +6 -0
- package/lib/components/Dialog/Dialog.js +10 -2
- package/lib/components/Dropdown/Dropdown.js +16 -4
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +1 -0
- package/lib/components/FileUploader/FileUploader.js +9 -2
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +3 -0
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +2 -0
- package/lib/components/FluidNumberInput/FluidNumberInput.js +3 -2
- package/lib/components/FluidSearch/FluidSearch.js +3 -2
- package/lib/components/FluidSelect/FluidSelect.js +3 -2
- package/lib/components/FluidTextInput/FluidTextInput.js +3 -2
- package/lib/components/FluidTimePicker/FluidTimePicker.js +11 -4
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +3 -2
- package/lib/components/Grid/CSSGrid.js +5 -0
- package/lib/components/Grid/Column.js +3 -0
- package/lib/components/Grid/ColumnHang.js +1 -0
- package/lib/components/Grid/FlexGrid.js +1 -0
- package/lib/components/Grid/Row.js +1 -0
- package/lib/components/Heading/index.js +3 -1
- package/lib/components/IconButton/index.js +4 -2
- package/lib/components/IconIndicator/index.js +4 -2
- package/lib/components/InlineCheckbox/InlineCheckbox.js +3 -2
- package/lib/components/Layout/index.js +6 -4
- package/lib/components/LayoutDirection/LayoutDirection.js +2 -0
- package/lib/components/Link/Link.js +3 -0
- package/lib/components/ListBox/ListBoxMenuItem.js +4 -1
- package/lib/components/ListBox/next/ListBoxTrigger.js +3 -2
- package/lib/components/Menu/Menu.js +6 -9
- package/lib/components/Menu/MenuContext.js +1 -0
- package/lib/components/Menu/MenuItem.js +5 -13
- package/lib/components/MenuButton/index.js +7 -2
- package/lib/components/Modal/Modal.js +3 -0
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.js +24 -5
- package/lib/components/MultiSelect/MultiSelect.js +21 -5
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/NumberInput/NumberInput.js +7 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -0
- package/lib/components/OverflowMenu/next/index.js +3 -2
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -0
- package/lib/components/PageHeader/PageHeader.d.ts +3 -3
- package/lib/components/PageHeader/PageHeader.js +22 -8
- package/lib/components/Pagination/Pagination.js +6 -2
- package/lib/components/PaginationNav/PaginationNav.js +2 -5
- package/lib/components/Popover/index.js +14 -4
- package/lib/components/ProgressBar/ProgressBar.js +4 -2
- package/lib/components/RadioTile/RadioTile.js +2 -2
- package/lib/components/Search/Search.js +2 -2
- package/lib/components/Select/Select.js +2 -3
- package/lib/components/ShapeIndicator/index.js +4 -2
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.d.ts +4 -4
- package/lib/components/SkeletonPlaceholder/SkeletonPlaceholder.js +1 -2
- package/lib/components/SkeletonText/SkeletonText.js +0 -2
- package/lib/components/Slider/Slider.js +11 -16
- package/lib/components/Stack/HStack.js +1 -0
- package/lib/components/Stack/Stack.js +6 -9
- package/lib/components/Stack/VStack.js +1 -0
- package/lib/components/StructuredList/StructuredList.js +3 -0
- package/lib/components/Switch/Switch.js +1 -1
- package/lib/components/Tabs/Tabs.js +28 -17
- package/lib/components/Tag/DismissibleTag.js +2 -0
- package/lib/components/Tag/OperationalTag.js +2 -0
- package/lib/components/Tag/SelectableTag.js +2 -0
- package/lib/components/Tag/Tag.js +4 -0
- package/lib/components/Tag/isEllipsisActive.js +1 -0
- package/lib/components/Text/Text.js +1 -0
- package/lib/components/TextInput/ControlledPasswordInput.js +2 -4
- package/lib/components/TextInput/PasswordInput.js +7 -2
- package/lib/components/TextInput/TextInput.js +4 -2
- package/lib/components/Theme/index.js +8 -3
- package/lib/components/Tile/Tile.js +14 -17
- package/lib/components/TimePicker/TimePicker.js +1 -0
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/Toggletip/index.js +4 -0
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -0
- package/lib/components/Tooltip/Tooltip.js +30 -23
- package/lib/components/TreeView/TreeNode.js +13 -5
- package/lib/components/TreeView/TreeView.js +7 -0
- package/lib/components/UIShell/HeaderContainer.js +3 -1
- package/lib/components/UIShell/HeaderGlobalAction.js +2 -2
- package/lib/components/UIShell/HeaderMenu.js +3 -3
- package/lib/components/UIShell/HeaderPanel.js +2 -2
- package/lib/components/UIShell/Link.js +2 -0
- package/lib/components/UIShell/SideNavItems.js +1 -0
- package/lib/components/UIShell/SideNavMenu.js +2 -2
- package/lib/components/UIShell/SideNavMenuItem.js +1 -1
- package/lib/components/UIShell/SideNavSwitcher.js +1 -1
- package/lib/components/UIShell/Switcher.js +2 -1
- package/lib/components/UIShell/SwitcherItem.js +4 -2
- package/lib/internal/FloatingMenu.js +7 -1
- package/lib/internal/Selection.js +12 -3
- package/lib/internal/useMergedRefs.js +1 -0
- package/lib/internal/useNoInteractiveChildren.js +4 -0
- package/lib/internal/useOutsideClick.js +1 -0
- package/lib/internal/useOverflowItems.js +6 -0
- package/lib/internal/useResizeObserver.js +4 -0
- package/lib/internal/useSavedCallback.js +1 -0
- package/lib/internal/warning.js +1 -0
- package/lib/prop-types/isRequiredOneOf.js +4 -1
- package/lib/tools/events.js +3 -1
- package/lib/tools/wrapComponent.js +1 -0
- package/package.json +9 -9
|
@@ -149,6 +149,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
149
149
|
}
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
152
153
|
}, [floatingStyles, autoAlign, refs.floating]);
|
|
153
154
|
const prefix = usePrefix();
|
|
154
155
|
const {
|
|
@@ -163,6 +164,8 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
163
164
|
});
|
|
164
165
|
}
|
|
165
166
|
}, [onChange]);
|
|
167
|
+
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
166
169
|
const isItemDisabled = useCallback((item, _index) => {
|
|
167
170
|
const isObject = item !== null && typeof item === 'object';
|
|
168
171
|
return isObject && 'disabled' in item && item.disabled === true;
|
|
@@ -171,7 +174,9 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
171
174
|
const {
|
|
172
175
|
highlightedIndex
|
|
173
176
|
} = changes;
|
|
174
|
-
if (highlightedIndex !== undefined && highlightedIndex > -1 &&
|
|
177
|
+
if (highlightedIndex !== undefined && highlightedIndex > -1 &&
|
|
178
|
+
// eslint-disable-next-line valid-typeof , no-constant-binary-expression -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
179
|
+
typeof window !== undefined) {
|
|
175
180
|
const itemArray = document.querySelectorAll(`li.${prefix}--list-box__menu-item[role="option"]`);
|
|
176
181
|
const highlightedItem = itemArray[highlightedIndex];
|
|
177
182
|
if (highlightedItem) {
|
|
@@ -192,7 +197,9 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
192
197
|
isItemDisabled,
|
|
193
198
|
onHighlightedIndexChange,
|
|
194
199
|
...downshiftProps
|
|
195
|
-
}),
|
|
200
|
+
}),
|
|
201
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
202
|
+
[items, itemToString, initialSelectedItem, onSelectedItemChange, stateReducer, isItemDisabled, onHighlightedIndexChange, downshiftProps]);
|
|
196
203
|
const dropdownInstanceId = useId();
|
|
197
204
|
|
|
198
205
|
// only set selectedItem if the prop is defined. Setting if it is undefined
|
|
@@ -281,7 +288,9 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
281
288
|
if (toggleButtonProps.onKeyDown && (evt.key !== 'ArrowUp' || isOpen && evt.key === 'ArrowUp')) {
|
|
282
289
|
toggleButtonProps.onKeyDown(evt);
|
|
283
290
|
}
|
|
284
|
-
},
|
|
291
|
+
},
|
|
292
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
293
|
+
[isTyping, currTimer, toggleButtonProps]);
|
|
285
294
|
const readOnlyEventHandlers = useMemo(() => {
|
|
286
295
|
if (readOnly) {
|
|
287
296
|
return {
|
|
@@ -304,6 +313,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
304
313
|
onKeyDown: onKeyDownHandler
|
|
305
314
|
};
|
|
306
315
|
}
|
|
316
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
307
317
|
}, [readOnly, onKeyDownHandler]);
|
|
308
318
|
const menuProps = useMemo(() => getMenuProps({
|
|
309
319
|
ref: enableFloatingStyles || autoAlign ? refs.setFloating : null
|
|
@@ -354,7 +364,9 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
354
364
|
ref: mergedRef
|
|
355
365
|
}), /*#__PURE__*/React.createElement("span", {
|
|
356
366
|
className: `${prefix}--list-box__label`
|
|
357
|
-
}, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) :
|
|
367
|
+
}, selectedItem ? renderSelectedItem ? renderSelectedItem(selectedItem) : itemToString(selectedItem) :
|
|
368
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
369
|
+
label), /*#__PURE__*/React.createElement(ListBox.MenuIcon, {
|
|
358
370
|
isOpen: isOpen,
|
|
359
371
|
translateWithId: translateWithId
|
|
360
372
|
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -9,6 +9,7 @@ import { createContext } from 'react';
|
|
|
9
9
|
|
|
10
10
|
const ErrorBoundaryContext = /*#__PURE__*/createContext({
|
|
11
11
|
log(error, info) {
|
|
12
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
12
13
|
console.log(info.componentStack);
|
|
13
14
|
}
|
|
14
15
|
});
|
|
@@ -20,6 +20,7 @@ import { useId } from '../../internal/useId.js';
|
|
|
20
20
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
21
21
|
import { Text } from '../Text/Text.js';
|
|
22
22
|
|
|
23
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
23
24
|
const FileUploader = /*#__PURE__*/React.forwardRef(({
|
|
24
25
|
accept,
|
|
25
26
|
buttonKind,
|
|
@@ -43,6 +44,8 @@ const FileUploader = /*#__PURE__*/React.forwardRef(({
|
|
|
43
44
|
const enhancedFileUploaderEnabled = useFeatureFlag('enable-enhanced-file-uploader');
|
|
44
45
|
const [fileItems, setFileItems] = useState([]);
|
|
45
46
|
const [legacyFileNames, setLegacyFileNames] = useState([]);
|
|
47
|
+
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
46
49
|
const [fileObjects, setFileObjects] = useState(new Map());
|
|
47
50
|
const nodes = [];
|
|
48
51
|
const createFileItem = file => ({
|
|
@@ -95,7 +98,9 @@ const FileUploader = /*#__PURE__*/React.forwardRef(({
|
|
|
95
98
|
onChange(evt);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
|
-
},
|
|
101
|
+
},
|
|
102
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
103
|
+
[enhancedFileUploaderEnabled, fileItems, legacyFileNames, multiple, onChange]);
|
|
99
104
|
const handleClick = useCallback((evt, {
|
|
100
105
|
index,
|
|
101
106
|
filenameStatus
|
|
@@ -150,7 +155,9 @@ const FileUploader = /*#__PURE__*/React.forwardRef(({
|
|
|
150
155
|
}
|
|
151
156
|
uploaderButton.current?.focus?.();
|
|
152
157
|
}
|
|
153
|
-
},
|
|
158
|
+
},
|
|
159
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
160
|
+
[enhancedFileUploaderEnabled, fileItems, legacyFileNames, onDelete, onChange, onClick]);
|
|
154
161
|
useImperativeHandle(ref, () => ({
|
|
155
162
|
clearFiles() {
|
|
156
163
|
if (enhancedFileUploaderEnabled) {
|
|
@@ -30,13 +30,13 @@ function FileUploaderButton({
|
|
|
30
30
|
onChange = noopFn,
|
|
31
31
|
name,
|
|
32
32
|
size = 'md',
|
|
33
|
-
// eslint-disable-next-line react/prop-types
|
|
34
33
|
innerRef,
|
|
35
34
|
...other
|
|
36
35
|
}) {
|
|
37
36
|
const prefix = usePrefix();
|
|
38
37
|
const [labelText, setLabelText] = useState(ownerLabelText);
|
|
39
38
|
const [prevOwnerLabelText, setPrevOwnerLabelText] = useState(ownerLabelText);
|
|
39
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
40
40
|
const {
|
|
41
41
|
current: inputId
|
|
42
42
|
} = useRef(id || useId());
|
|
@@ -28,12 +28,12 @@ function FileUploaderDropContainer({
|
|
|
28
28
|
onAddFiles = noopFn,
|
|
29
29
|
onClick,
|
|
30
30
|
pattern = '.[0-9a-z]+$',
|
|
31
|
-
// eslint-disable-next-line react/prop-types
|
|
32
31
|
innerRef,
|
|
33
32
|
...rest
|
|
34
33
|
}) {
|
|
35
34
|
const prefix = usePrefix();
|
|
36
35
|
const inputRef = useRef(null);
|
|
36
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
37
37
|
const {
|
|
38
38
|
current: uid
|
|
39
39
|
} = useRef(id || useId());
|
|
@@ -36,6 +36,7 @@ function FileUploaderItem({
|
|
|
36
36
|
const textRef = useRef(null);
|
|
37
37
|
const [isEllipsisApplied, setIsEllipsisApplied] = useState(false);
|
|
38
38
|
const prefix = usePrefix();
|
|
39
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
39
40
|
const {
|
|
40
41
|
current: id
|
|
41
42
|
} = useRef(uuid || useId());
|
|
@@ -48,6 +49,8 @@ function FileUploaderItem({
|
|
|
48
49
|
const filterSpaceName = name => {
|
|
49
50
|
return name?.replace(/\s+/g, '');
|
|
50
51
|
};
|
|
52
|
+
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
51
54
|
const isEllipsisActive = element => {
|
|
52
55
|
setIsEllipsisApplied(element.offsetWidth < element.scrollWidth);
|
|
53
56
|
return element.offsetWidth < element.scrollWidth;
|
|
@@ -30,12 +30,14 @@ const FluidMultiSelect = /*#__PURE__*/React.forwardRef(function FluidMultiSelect
|
|
|
30
30
|
}
|
|
31
31
|
}, isFilterable ?
|
|
32
32
|
/*#__PURE__*/
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
33
34
|
// @ts-ignore
|
|
34
35
|
React.createElement(FilterableMultiSelect, _extends({
|
|
35
36
|
ref: ref,
|
|
36
37
|
className: classNames
|
|
37
38
|
}, other)) :
|
|
38
39
|
/*#__PURE__*/
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
39
41
|
// @ts-ignore
|
|
40
42
|
React.createElement(MultiSelect, _extends({
|
|
41
43
|
ref: ref,
|
|
@@ -15,10 +15,11 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
15
15
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
16
16
|
import { NumberFormatOptionsPropType } from '../NumberInput/NumberFormatPropTypes.js';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
19
|
+
const FluidNumberInput = /*#__PURE__*/React.forwardRef(({
|
|
19
20
|
className,
|
|
20
21
|
...other
|
|
21
|
-
}, ref) {
|
|
22
|
+
}, ref) => {
|
|
22
23
|
const prefix = usePrefix();
|
|
23
24
|
const classNames = cx(`${prefix}--number-input--fluid`, className);
|
|
24
25
|
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
@@ -14,10 +14,11 @@ import '../Search/Search.Skeleton.js';
|
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
18
|
+
const FluidSearch = /*#__PURE__*/React.forwardRef(({
|
|
18
19
|
className,
|
|
19
20
|
...other
|
|
20
|
-
}, ref) {
|
|
21
|
+
}, ref) => {
|
|
21
22
|
const prefix = usePrefix();
|
|
22
23
|
const classNames = cx(`${prefix}--search--fluid`, className);
|
|
23
24
|
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
@@ -14,11 +14,12 @@ import '../Select/Select.Skeleton.js';
|
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
18
|
+
const FluidSelect = /*#__PURE__*/React.forwardRef(({
|
|
18
19
|
className,
|
|
19
20
|
children,
|
|
20
21
|
...other
|
|
21
|
-
}, ref) {
|
|
22
|
+
}, ref) => {
|
|
22
23
|
const prefix = usePrefix();
|
|
23
24
|
const classNames = cx(`${prefix}--select--fluid`, className);
|
|
24
25
|
return /*#__PURE__*/React.createElement(FormContext.Provider, {
|
|
@@ -16,11 +16,12 @@ import PasswordInput from '../TextInput/PasswordInput.js';
|
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
20
|
+
const FluidTextInput = /*#__PURE__*/React.forwardRef(({
|
|
20
21
|
className,
|
|
21
22
|
isPassword,
|
|
22
23
|
...other
|
|
23
|
-
}, ref) {
|
|
24
|
+
}, ref) => {
|
|
24
25
|
const prefix = usePrefix();
|
|
25
26
|
const classNames = cx(className, {
|
|
26
27
|
[`${prefix}--text-input--fluid`]: !isPassword
|
|
@@ -15,7 +15,8 @@ import '../FluidTextInput/FluidTextInput.Skeleton.js';
|
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
19
|
+
const FluidTimePicker = /*#__PURE__*/React.forwardRef(({
|
|
19
20
|
className,
|
|
20
21
|
children,
|
|
21
22
|
disabled,
|
|
@@ -25,7 +26,7 @@ const FluidTimePicker = /*#__PURE__*/React.forwardRef(function FluidTimePicker({
|
|
|
25
26
|
warnText,
|
|
26
27
|
readOnly,
|
|
27
28
|
...other
|
|
28
|
-
}, ref) {
|
|
29
|
+
}, ref) => {
|
|
29
30
|
const prefix = usePrefix();
|
|
30
31
|
const classNames = cx(className, {
|
|
31
32
|
[`${prefix}--time-picker--fluid`]: true,
|
|
@@ -45,12 +46,18 @@ const FluidTimePicker = /*#__PURE__*/React.forwardRef(function FluidTimePicker({
|
|
|
45
46
|
const error = invalid || warn;
|
|
46
47
|
const childrenWithProps = () => {
|
|
47
48
|
if (disabled) {
|
|
48
|
-
return React.Children.toArray(children).map(child =>
|
|
49
|
+
return React.Children.toArray(children).map(child =>
|
|
50
|
+
/*#__PURE__*/
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
52
|
+
React.cloneElement(child, {
|
|
49
53
|
disabled: true
|
|
50
54
|
}));
|
|
51
55
|
}
|
|
52
56
|
if (readOnly) {
|
|
53
|
-
return React.Children.toArray(children).map(child =>
|
|
57
|
+
return React.Children.toArray(children).map(child =>
|
|
58
|
+
/*#__PURE__*/
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
60
|
+
React.cloneElement(child, {
|
|
54
61
|
readOnly: true
|
|
55
62
|
}));
|
|
56
63
|
}
|
|
@@ -11,11 +11,12 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import FluidSelect from '../FluidSelect/FluidSelect.js';
|
|
12
12
|
import '../FluidSelect/FluidSelect.Skeleton.js';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
15
|
+
const FluidTimePickerSelect = /*#__PURE__*/React.forwardRef(({
|
|
15
16
|
children,
|
|
16
17
|
className,
|
|
17
18
|
...other
|
|
18
|
-
}, ref) {
|
|
19
|
+
}, ref) => {
|
|
19
20
|
return /*#__PURE__*/React.createElement(FluidSelect, _extends({
|
|
20
21
|
className: className,
|
|
21
22
|
ref: ref
|
|
@@ -12,6 +12,7 @@ import React from 'react';
|
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
import { useGridSettings, GridSettings } from './GridContext.js';
|
|
14
14
|
|
|
15
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
15
16
|
const CSSGrid = /*#__PURE__*/React.forwardRef(({
|
|
16
17
|
align,
|
|
17
18
|
as,
|
|
@@ -94,6 +95,10 @@ CSSGrid.propTypes = {
|
|
|
94
95
|
*/
|
|
95
96
|
narrow: PropTypes.bool
|
|
96
97
|
};
|
|
98
|
+
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
100
|
+
|
|
101
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
97
102
|
const Subgrid = /*#__PURE__*/React.forwardRef(({
|
|
98
103
|
as,
|
|
99
104
|
className: customClassName,
|
|
@@ -13,6 +13,7 @@ import React from 'react';
|
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
14
|
import { useGridSettings } from './GridContext.js';
|
|
15
15
|
|
|
16
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
16
17
|
const Column = /*#__PURE__*/React.forwardRef(({
|
|
17
18
|
as,
|
|
18
19
|
children,
|
|
@@ -114,6 +115,8 @@ Column.propTypes = {
|
|
|
114
115
|
*/
|
|
115
116
|
xlg: spanPropType
|
|
116
117
|
};
|
|
118
|
+
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any , react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
117
120
|
const CSSGridColumn = /*#__PURE__*/React.forwardRef(({
|
|
118
121
|
as: BaseComponent = 'div',
|
|
119
122
|
children,
|
|
@@ -24,6 +24,7 @@ function ColumnHang({
|
|
|
24
24
|
const prefix = usePrefix();
|
|
25
25
|
const className = cx(customClassName, `${prefix}--grid-column-hang`);
|
|
26
26
|
// cast as any to let TypeScript allow passing in attributes to base component
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
27
28
|
const BaseComponentAsAny = BaseComponent;
|
|
28
29
|
return /*#__PURE__*/React.createElement(BaseComponentAsAny, _extends({}, rest, {
|
|
29
30
|
className: className
|
|
@@ -12,6 +12,7 @@ import React from 'react';
|
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
import { GridSettings } from './GridContext.js';
|
|
14
14
|
|
|
15
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
15
16
|
const FlexGrid = /*#__PURE__*/React.forwardRef(({
|
|
16
17
|
as,
|
|
17
18
|
condensed = false,
|
|
@@ -26,6 +26,7 @@ function Row({
|
|
|
26
26
|
[`${prefix}--row--narrow`]: narrow
|
|
27
27
|
});
|
|
28
28
|
// TypeScript type validation reports conflicts on different instances of keyof JSX.IntrinsicElements
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
29
30
|
const BaseComponentAsAny = BaseComponent;
|
|
30
31
|
return /*#__PURE__*/React.createElement(BaseComponentAsAny, _extends({
|
|
31
32
|
className: className
|
|
@@ -17,6 +17,7 @@ const Section = /*#__PURE__*/React.forwardRef(function Section({
|
|
|
17
17
|
}, ref) {
|
|
18
18
|
const parentLevel = React.useContext(HeadingContext);
|
|
19
19
|
const level = levelOverride ?? parentLevel + 1;
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
20
21
|
const BaseComponentAsAny = BaseComponent;
|
|
21
22
|
return /*#__PURE__*/React.createElement(HeadingContext.Provider, {
|
|
22
23
|
value: Math.min(level, 6)
|
|
@@ -43,7 +44,8 @@ Section.propTypes = {
|
|
|
43
44
|
*/
|
|
44
45
|
level: PropTypes.number
|
|
45
46
|
};
|
|
46
|
-
|
|
47
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
48
|
+
const Heading = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
47
49
|
const HeadingIntrinsic = `h${React.useContext(HeadingContext)}`;
|
|
48
50
|
return /*#__PURE__*/React.createElement(HeadingIntrinsic, _extends({
|
|
49
51
|
ref: ref
|
|
@@ -19,7 +19,8 @@ import { BadgeIndicator } from '../BadgeIndicator/index.js';
|
|
|
19
19
|
import { mapPopoverAlign } from '../../tools/mapPopoverAlign.js';
|
|
20
20
|
|
|
21
21
|
const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
|
|
22
|
-
|
|
22
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
23
|
+
const IconButton = /*#__PURE__*/React.forwardRef(({
|
|
23
24
|
align,
|
|
24
25
|
autoAlign = false,
|
|
25
26
|
badgeCount,
|
|
@@ -38,12 +39,13 @@ const IconButton = /*#__PURE__*/React.forwardRef(function IconButton({
|
|
|
38
39
|
size,
|
|
39
40
|
isSelected,
|
|
40
41
|
...rest
|
|
41
|
-
}, ref) {
|
|
42
|
+
}, ref) => {
|
|
42
43
|
const prefix = usePrefix();
|
|
43
44
|
const tooltipClasses = cx(wrapperClasses, `${prefix}--icon-tooltip`, {
|
|
44
45
|
[`${prefix}--icon-tooltip--disabled`]: disabled
|
|
45
46
|
});
|
|
46
47
|
if (badgeCount && (kind !== 'ghost' || size !== 'lg')) {
|
|
48
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
47
49
|
console.warn("The prop BadgeCount must be used with hasIconOnly=true, kind='ghost' and size='lg'");
|
|
48
50
|
}
|
|
49
51
|
const badgeId = useId('badge-indicator');
|
|
@@ -26,13 +26,15 @@ const iconTypes = {
|
|
|
26
26
|
unknown: UnknownFilled,
|
|
27
27
|
informative: WarningSquareFilled
|
|
28
28
|
};
|
|
29
|
-
|
|
29
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
30
|
+
const IconIndicator = /*#__PURE__*/React.forwardRef(({
|
|
30
31
|
className: customClassName,
|
|
31
32
|
kind,
|
|
32
33
|
label,
|
|
33
34
|
size = 16,
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
34
36
|
...rest
|
|
35
|
-
}, ref) {
|
|
37
|
+
}, ref) => {
|
|
36
38
|
const prefix = usePrefix();
|
|
37
39
|
const classNames = cx(`${prefix}--icon-indicator`, customClassName, {
|
|
38
40
|
[`${prefix}--icon-indicator--20`]: size == 20
|
|
@@ -11,7 +11,8 @@ import { deprecate } from '../../prop-types/deprecate.js';
|
|
|
11
11
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
12
12
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
15
|
+
const InlineCheckbox = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
15
16
|
const {
|
|
16
17
|
['aria-label']: ariaLabel,
|
|
17
18
|
ariaLabel: deprecatedAriaLabel,
|
|
@@ -60,7 +61,7 @@ const InlineCheckbox = /*#__PURE__*/React.forwardRef(function InlineCheckbox(pro
|
|
|
60
61
|
className: `${prefix}--checkbox--inline`
|
|
61
62
|
}, /*#__PURE__*/React.createElement("input", inputProps),
|
|
62
63
|
/*#__PURE__*/
|
|
63
|
-
/* eslint-disable jsx-a11y/
|
|
64
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions */
|
|
64
65
|
React.createElement("label", {
|
|
65
66
|
htmlFor: id,
|
|
66
67
|
className: `${prefix}--checkbox-label`,
|
|
@@ -22,14 +22,15 @@ const densities = ['condensed', 'normal'];
|
|
|
22
22
|
* Size of components within this layout
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
26
|
+
const Layout = /*#__PURE__*/React.forwardRef(({
|
|
26
27
|
as: BaseComponent = 'div',
|
|
27
28
|
children,
|
|
28
29
|
className,
|
|
29
30
|
density,
|
|
30
31
|
size,
|
|
31
32
|
...rest
|
|
32
|
-
}, forwardRef) {
|
|
33
|
+
}, forwardRef) => {
|
|
33
34
|
const prefix = usePrefix();
|
|
34
35
|
const classes = cx(className, `${prefix}--layout`, {
|
|
35
36
|
[`${prefix}--layout--size-${size}`]: size && sizes.includes(size),
|
|
@@ -64,14 +65,15 @@ Layout.propTypes = {
|
|
|
64
65
|
*/
|
|
65
66
|
size: PropTypes.oneOf(sizes)
|
|
66
67
|
};
|
|
67
|
-
|
|
68
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
69
|
+
const LayoutConstraint = /*#__PURE__*/React.forwardRef(({
|
|
68
70
|
as: BaseComponent = 'div',
|
|
69
71
|
children,
|
|
70
72
|
className,
|
|
71
73
|
density,
|
|
72
74
|
size,
|
|
73
75
|
...rest
|
|
74
|
-
}, forwardRef) {
|
|
76
|
+
}, forwardRef) => {
|
|
75
77
|
const prefix = usePrefix();
|
|
76
78
|
const classes = cx(className, Object.entries({
|
|
77
79
|
size,
|
|
@@ -10,6 +10,8 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { LayoutDirectionContext } from './LayoutDirectionContext.js';
|
|
12
12
|
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
14
|
+
|
|
13
15
|
function LayoutDirection({
|
|
14
16
|
as: BaseComponent = 'div',
|
|
15
17
|
children,
|
|
@@ -12,6 +12,7 @@ import React from 'react';
|
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
|
|
14
14
|
// First create the component with basic types
|
|
15
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
15
16
|
const LinkBase = /*#__PURE__*/React.forwardRef(({
|
|
16
17
|
as: BaseComponent,
|
|
17
18
|
children,
|
|
@@ -47,6 +48,8 @@ const LinkBase = /*#__PURE__*/React.forwardRef(({
|
|
|
47
48
|
linkProps.role = 'link';
|
|
48
49
|
linkProps['aria-disabled'] = true;
|
|
49
50
|
}
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
50
53
|
const BaseComponentAsAny = BaseComponent ?? 'a';
|
|
51
54
|
const handleOnClick = event => {
|
|
52
55
|
if (disabled) {
|
|
@@ -22,7 +22,9 @@ import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
|
22
22
|
* @param deps - Dependencies to re-run the truncation check.
|
|
23
23
|
* @returns An object containing the truncation state and the merged ref.
|
|
24
24
|
*/
|
|
25
|
-
const useIsTruncated = (forwardedRef,
|
|
25
|
+
const useIsTruncated = (forwardedRef,
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
27
|
+
deps = []) => {
|
|
26
28
|
const localRef = useRef(null);
|
|
27
29
|
const mergedRef = useMergedRefs([...(forwardedRef ? [forwardedRef] : []), localRef]);
|
|
28
30
|
const [isTruncated, setIsTruncated] = useState(false);
|
|
@@ -35,6 +37,7 @@ const useIsTruncated = (forwardedRef, deps = []) => {
|
|
|
35
37
|
} = element;
|
|
36
38
|
setIsTruncated(offsetWidth < scrollWidth);
|
|
37
39
|
}
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
38
41
|
}, [localRef, ...deps]);
|
|
39
42
|
return {
|
|
40
43
|
isTruncated,
|
|
@@ -27,11 +27,12 @@ const defaultTranslateWithId = id => defaultTranslations[id];
|
|
|
27
27
|
* state of the menu for a given `ListBox`
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
31
|
+
const ListBoxTrigger = /*#__PURE__*/React.forwardRef(({
|
|
31
32
|
isOpen,
|
|
32
33
|
translateWithId: t = defaultTranslateWithId,
|
|
33
34
|
...rest
|
|
34
|
-
}, ref) {
|
|
35
|
+
}, ref) => {
|
|
35
36
|
const prefix = usePrefix();
|
|
36
37
|
const className = cx({
|
|
37
38
|
[`${prefix}--list-box__menu-icon`]: true,
|
|
@@ -28,7 +28,6 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
28
28
|
containerRef,
|
|
29
29
|
label,
|
|
30
30
|
menuAlignment,
|
|
31
|
-
mode,
|
|
32
31
|
onClose,
|
|
33
32
|
onOpen,
|
|
34
33
|
open,
|
|
@@ -118,6 +117,8 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
118
117
|
}
|
|
119
118
|
}
|
|
120
119
|
function focusItem(e) {
|
|
120
|
+
const validItems = focusableItems?.filter(item => item?.ref?.current);
|
|
121
|
+
if (!validItems?.length) return;
|
|
121
122
|
const currentItem = focusableItems.findIndex(item => item.ref?.current?.contains(document.activeElement));
|
|
122
123
|
let indexToFocus = currentItem;
|
|
123
124
|
|
|
@@ -134,14 +135,14 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
|
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
137
|
if (indexToFocus < 0) {
|
|
137
|
-
indexToFocus =
|
|
138
|
+
indexToFocus = validItems.length - 1;
|
|
138
139
|
}
|
|
139
|
-
if (indexToFocus >=
|
|
140
|
+
if (indexToFocus >= validItems.length) {
|
|
140
141
|
indexToFocus = 0;
|
|
141
142
|
}
|
|
142
143
|
if (indexToFocus !== currentItem) {
|
|
143
|
-
const nodeToFocus =
|
|
144
|
-
nodeToFocus
|
|
144
|
+
const nodeToFocus = validItems[indexToFocus];
|
|
145
|
+
nodeToFocus?.ref?.current?.focus();
|
|
145
146
|
e?.preventDefault();
|
|
146
147
|
}
|
|
147
148
|
}
|
|
@@ -304,7 +305,6 @@ Menu.propTypes = {
|
|
|
304
305
|
/**
|
|
305
306
|
* A label describing the Menu.
|
|
306
307
|
*/
|
|
307
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
308
308
|
label: PropTypes.string,
|
|
309
309
|
/**
|
|
310
310
|
* Specify how the menu should align with the button element
|
|
@@ -340,17 +340,14 @@ Menu.propTypes = {
|
|
|
340
340
|
/**
|
|
341
341
|
* Specify a DOM node where the Menu should be rendered in. Defaults to document.body.
|
|
342
342
|
*/
|
|
343
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
344
343
|
target: PropTypes.object,
|
|
345
344
|
/**
|
|
346
345
|
* 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])
|
|
347
346
|
*/
|
|
348
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
349
347
|
x: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)]),
|
|
350
348
|
/**
|
|
351
349
|
* Specify the y position of the Menu. Either pass a single number or an array with two numbers describing your activator's boundaries ([y1, y2])
|
|
352
350
|
*/
|
|
353
|
-
// @ts-ignore-next-line -- avoid spurious (?) TS2322 error
|
|
354
351
|
y: PropTypes.oneOfType([PropTypes.number, PropTypes.arrayOf(PropTypes.number)])
|
|
355
352
|
};
|
|
356
353
|
|
|
@@ -44,6 +44,7 @@ function menuReducer(state, action) {
|
|
|
44
44
|
const MenuContext = /*#__PURE__*/createContext({
|
|
45
45
|
state: menuDefaultState,
|
|
46
46
|
// 'dispatch' is populated by the root menu
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20071
|
|
47
48
|
dispatch: _ => {}
|
|
48
49
|
});
|
|
49
50
|
|