@carbon/react 1.92.1 → 1.93.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 +874 -838
- package/es/components/AILabel/index.js +4 -4
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/es/components/Button/Button.js +2 -2
- package/es/components/ChatButton/ChatButton.js +1 -1
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/es/components/CodeSnippet/CodeSnippet.js +9 -50
- package/es/components/ComboBox/ComboBox.d.ts +3 -11
- package/es/components/ComboBox/ComboBox.js +15 -25
- package/es/components/ComboButton/index.d.ts +5 -8
- package/es/components/ComboButton/index.js +9 -12
- package/es/components/ComposedModal/ComposedModal.js +19 -25
- package/es/components/DataTable/DataTable.d.ts +27 -16
- package/es/components/DataTable/DataTable.js +40 -39
- package/es/components/DataTable/Table.js +2 -2
- package/es/components/DataTable/TableBatchActions.d.ts +49 -10
- package/es/components/DataTable/TableBatchActions.js +26 -21
- package/es/components/DataTable/TableExpandHeader.js +2 -2
- package/es/components/DataTable/TableExpandRow.d.ts +4 -0
- package/es/components/DataTable/TableExpandRow.js +1 -1
- package/es/components/DataTable/TableHeader.d.ts +8 -10
- package/es/components/DataTable/TableHeader.js +11 -13
- package/es/components/DataTable/TableRow.js +7 -5
- package/es/components/DataTable/TableSlugRow.js +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +1 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +8 -7
- package/es/components/DataTable/TableToolbarSearch.js +11 -11
- package/es/components/DataTable/index.d.ts +2 -2
- package/es/components/DataTable/state/sorting.d.ts +2 -2
- package/es/components/DataTable/state/sorting.js +1 -1
- package/es/components/DataTable/tools/sorting.js +1 -1
- package/es/components/DatePicker/DatePicker.js +9 -9
- package/es/components/DatePickerInput/DatePickerInput.js +5 -5
- package/es/components/Dialog/Dialog.js +6 -6
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.js +8 -8
- package/es/components/ErrorBoundary/ErrorBoundaryContext.js +1 -1
- package/es/components/FileUploader/FileUploader.js +4 -4
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +2 -2
- package/es/components/FluidComboBox/FluidComboBox.d.ts +4 -7
- package/es/components/FluidComboBox/FluidComboBox.js +1 -1
- package/es/components/FluidDropdown/FluidDropdown.d.ts +4 -8
- package/es/components/FluidDropdown/FluidDropdown.js +1 -1
- package/es/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -7
- package/es/components/FluidMultiSelect/FluidMultiSelect.d.ts +3 -7
- package/es/components/FluidMultiSelect/FluidMultiSelect.js +3 -3
- package/es/components/FluidNumberInput/FluidNumberInput.d.ts +4 -7
- package/es/components/FluidNumberInput/FluidNumberInput.js +2 -2
- package/es/components/FluidSearch/FluidSearch.js +1 -1
- package/es/components/FluidSelect/FluidSelect.js +1 -1
- package/es/components/FluidTextInput/FluidTextInput.js +1 -1
- package/es/components/FluidTimePicker/FluidTimePicker.js +3 -3
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +1 -1
- package/es/components/Grid/CSSGrid.js +3 -3
- package/es/components/Grid/Column.js +2 -2
- package/es/components/Grid/ColumnHang.js +1 -1
- package/es/components/Grid/FlexGrid.js +1 -1
- package/es/components/Grid/Row.js +1 -1
- package/es/components/Heading/index.js +2 -2
- package/es/components/IconButton/index.js +2 -2
- package/es/components/IconIndicator/index.js +2 -2
- package/es/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/es/components/Layout/index.js +2 -2
- package/es/components/LayoutDirection/LayoutDirection.js +1 -1
- package/es/components/Link/Link.js +2 -2
- package/es/components/ListBox/ListBoxField.d.ts +0 -1
- package/es/components/ListBox/ListBoxMenuIcon.d.ts +8 -4
- package/es/components/ListBox/ListBoxMenuIcon.js +10 -6
- package/es/components/ListBox/ListBoxMenuItem.js +2 -2
- package/es/components/ListBox/ListBoxSelection.d.ts +3 -6
- package/es/components/ListBox/ListBoxSelection.js +5 -10
- package/es/components/ListBox/index.d.ts +5 -3
- package/es/components/ListBox/next/ListBoxSelection.d.ts +6 -13
- package/es/components/ListBox/next/ListBoxSelection.js +16 -8
- package/es/components/ListBox/next/ListBoxTrigger.d.ts +5 -10
- package/es/components/ListBox/next/ListBoxTrigger.js +6 -6
- package/es/components/Menu/MenuContext.js +1 -1
- package/es/components/Menu/MenuItem.js +1 -1
- package/es/components/MenuButton/index.js +5 -5
- package/es/components/Modal/Modal.js +17 -23
- package/es/components/ModalWrapper/ModalWrapper.js +2 -2
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -12
- package/es/components/MultiSelect/FilterableMultiSelect.js +18 -27
- package/es/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.js +12 -12
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.d.ts +2 -5
- package/es/components/NumberInput/NumberInput.js +13 -18
- package/es/components/OverflowMenu/OverflowMenu.d.ts +2 -2
- package/es/components/OverflowMenu/OverflowMenu.js +4 -4
- package/es/components/OverflowMenu/next/index.d.ts +1 -1
- package/es/components/OverflowMenu/next/index.js +2 -2
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/es/components/PageHeader/PageHeader.js +12 -12
- package/es/components/Pagination/Pagination.js +3 -3
- package/es/components/PaginationNav/PaginationNav.d.ts +6 -9
- package/es/components/PaginationNav/PaginationNav.js +21 -22
- package/es/components/Popover/index.js +10 -9
- package/es/components/ProgressBar/ProgressBar.js +2 -2
- package/es/components/ProgressIndicator/ProgressIndicator.d.ts +11 -15
- package/es/components/ProgressIndicator/ProgressIndicator.js +15 -15
- package/es/components/RadioButton/RadioButton.js +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/es/components/RadioTile/RadioTile.js +1 -1
- package/es/components/Select/Select.js +7 -5
- package/es/components/ShapeIndicator/index.js +2 -2
- package/es/components/Slider/Slider.d.ts +7 -9
- package/es/components/Slider/Slider.js +16 -20
- package/es/components/Stack/HStack.js +1 -1
- package/es/components/Stack/Stack.js +1 -1
- package/es/components/Stack/VStack.js +1 -1
- package/es/components/StructuredList/StructuredList.js +3 -3
- package/es/components/Tabs/Tabs.js +12 -12
- package/es/components/Tag/DismissibleTag.js +3 -3
- package/es/components/Tag/OperationalTag.js +2 -2
- package/es/components/Tag/SelectableTag.js +2 -2
- package/es/components/Tag/Tag.js +4 -4
- package/es/components/Tag/isEllipsisActive.js +1 -1
- package/es/components/Text/Text.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextInput/PasswordInput.js +4 -4
- package/es/components/TextInput/TextInput.js +3 -3
- package/es/components/Theme/index.js +3 -3
- package/es/components/Tile/Tile.js +3 -3
- package/es/components/TimePicker/TimePicker.js +1 -1
- package/es/components/Toggletip/index.js +4 -4
- package/es/components/Tooltip/DefinitionTooltip.js +1 -1
- package/es/components/Tooltip/Tooltip.js +3 -3
- package/es/components/TreeView/TreeNode.js +6 -6
- package/es/components/TreeView/TreeView.js +5 -5
- package/es/components/UIShell/HeaderContainer.js +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/Link.js +2 -2
- package/es/components/UIShell/SideNavItems.js +1 -1
- package/es/components/UIShell/Switcher.js +1 -1
- package/es/components/UIShell/SwitcherItem.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/internal/FloatingMenu.js +4 -4
- package/es/internal/Selection.js +6 -6
- package/es/internal/useMergedRefs.js +1 -1
- package/es/internal/useNoInteractiveChildren.js +4 -4
- package/es/internal/useOutsideClick.js +1 -1
- package/es/internal/useOverflowItems.js +6 -6
- package/es/internal/useResizeObserver.js +3 -3
- package/es/internal/useSavedCallback.js +1 -1
- package/es/internal/warning.js +1 -1
- package/es/prop-types/isRequiredOneOf.js +2 -2
- package/es/tools/events.js +1 -1
- package/es/tools/wrapComponent.js +1 -1
- package/es/types/common.d.ts +6 -2
- package/lib/components/AILabel/index.js +4 -4
- package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/lib/components/Button/Button.js +2 -2
- package/lib/components/ChatButton/ChatButton.js +1 -1
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.js +8 -49
- package/lib/components/ComboBox/ComboBox.d.ts +3 -11
- package/lib/components/ComboBox/ComboBox.js +15 -25
- package/lib/components/ComboButton/index.d.ts +5 -8
- package/lib/components/ComboButton/index.js +9 -12
- package/lib/components/ComposedModal/ComposedModal.js +18 -24
- package/lib/components/DataTable/DataTable.d.ts +27 -16
- package/lib/components/DataTable/DataTable.js +40 -39
- package/lib/components/DataTable/Table.js +2 -2
- package/lib/components/DataTable/TableBatchActions.d.ts +49 -10
- package/lib/components/DataTable/TableBatchActions.js +26 -21
- package/lib/components/DataTable/TableExpandHeader.js +2 -2
- package/lib/components/DataTable/TableExpandRow.d.ts +4 -0
- package/lib/components/DataTable/TableExpandRow.js +1 -1
- package/lib/components/DataTable/TableHeader.d.ts +8 -10
- package/lib/components/DataTable/TableHeader.js +11 -13
- package/lib/components/DataTable/TableRow.js +7 -5
- package/lib/components/DataTable/TableSlugRow.js +1 -1
- package/lib/components/DataTable/TableToolbarMenu.js +1 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +8 -7
- package/lib/components/DataTable/TableToolbarSearch.js +11 -11
- package/lib/components/DataTable/index.d.ts +2 -2
- package/lib/components/DataTable/state/sorting.d.ts +2 -2
- package/lib/components/DataTable/state/sorting.js +1 -1
- package/lib/components/DataTable/tools/sorting.js +1 -1
- package/lib/components/DatePicker/DatePicker.js +9 -9
- package/lib/components/DatePickerInput/DatePickerInput.js +5 -5
- package/lib/components/Dialog/Dialog.js +6 -6
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.js +8 -8
- package/lib/components/ErrorBoundary/ErrorBoundaryContext.js +1 -1
- package/lib/components/FileUploader/FileUploader.js +4 -4
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +2 -2
- package/lib/components/FluidComboBox/FluidComboBox.d.ts +4 -7
- package/lib/components/FluidComboBox/FluidComboBox.js +1 -1
- package/lib/components/FluidDropdown/FluidDropdown.d.ts +4 -8
- package/lib/components/FluidDropdown/FluidDropdown.js +1 -1
- package/lib/components/FluidMultiSelect/FluidFilterableMultiSelect.d.ts +3 -7
- package/lib/components/FluidMultiSelect/FluidMultiSelect.d.ts +3 -7
- package/lib/components/FluidMultiSelect/FluidMultiSelect.js +3 -3
- package/lib/components/FluidNumberInput/FluidNumberInput.d.ts +4 -7
- package/lib/components/FluidNumberInput/FluidNumberInput.js +2 -2
- package/lib/components/FluidSearch/FluidSearch.js +1 -1
- package/lib/components/FluidSelect/FluidSelect.js +1 -1
- package/lib/components/FluidTextInput/FluidTextInput.js +1 -1
- package/lib/components/FluidTimePicker/FluidTimePicker.js +3 -3
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +1 -1
- package/lib/components/Grid/CSSGrid.js +3 -3
- package/lib/components/Grid/Column.js +2 -2
- package/lib/components/Grid/ColumnHang.js +1 -1
- package/lib/components/Grid/FlexGrid.js +1 -1
- package/lib/components/Grid/Row.js +1 -1
- package/lib/components/Heading/index.js +2 -2
- package/lib/components/IconButton/index.js +2 -2
- package/lib/components/IconIndicator/index.js +2 -2
- package/lib/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/lib/components/Layout/index.js +2 -2
- package/lib/components/LayoutDirection/LayoutDirection.js +1 -1
- package/lib/components/Link/Link.js +2 -2
- package/lib/components/ListBox/ListBoxField.d.ts +0 -1
- package/lib/components/ListBox/ListBoxMenuIcon.d.ts +8 -4
- package/lib/components/ListBox/ListBoxMenuIcon.js +10 -6
- package/lib/components/ListBox/ListBoxMenuItem.js +2 -2
- package/lib/components/ListBox/ListBoxSelection.d.ts +3 -6
- package/lib/components/ListBox/ListBoxSelection.js +4 -10
- package/lib/components/ListBox/index.d.ts +5 -3
- package/lib/components/ListBox/next/ListBoxSelection.d.ts +6 -13
- package/lib/components/ListBox/next/ListBoxSelection.js +16 -8
- package/lib/components/ListBox/next/ListBoxTrigger.d.ts +5 -10
- package/lib/components/ListBox/next/ListBoxTrigger.js +5 -6
- package/lib/components/Menu/MenuContext.js +1 -1
- package/lib/components/Menu/MenuItem.js +1 -1
- package/lib/components/MenuButton/index.js +5 -5
- package/lib/components/Modal/Modal.js +16 -22
- package/lib/components/ModalWrapper/ModalWrapper.js +2 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -12
- package/lib/components/MultiSelect/FilterableMultiSelect.js +18 -27
- package/lib/components/MultiSelect/MultiSelect.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +12 -12
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/NumberInput/NumberInput.d.ts +2 -5
- package/lib/components/NumberInput/NumberInput.js +12 -18
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +2 -2
- package/lib/components/OverflowMenu/OverflowMenu.js +4 -4
- package/lib/components/OverflowMenu/next/index.d.ts +1 -1
- package/lib/components/OverflowMenu/next/index.js +2 -2
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/lib/components/PageHeader/PageHeader.js +12 -12
- package/lib/components/Pagination/Pagination.js +3 -3
- package/lib/components/PaginationNav/PaginationNav.d.ts +6 -9
- package/lib/components/PaginationNav/PaginationNav.js +21 -22
- package/lib/components/Popover/index.js +10 -9
- package/lib/components/ProgressBar/ProgressBar.js +2 -2
- package/lib/components/ProgressIndicator/ProgressIndicator.d.ts +11 -15
- package/lib/components/ProgressIndicator/ProgressIndicator.js +15 -15
- package/lib/components/RadioButton/RadioButton.js +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +1 -1
- package/lib/components/Select/Select.js +7 -5
- package/lib/components/ShapeIndicator/index.js +2 -2
- package/lib/components/Slider/Slider.d.ts +7 -9
- package/lib/components/Slider/Slider.js +16 -20
- package/lib/components/Stack/HStack.js +1 -1
- package/lib/components/Stack/Stack.js +1 -1
- package/lib/components/Stack/VStack.js +1 -1
- package/lib/components/StructuredList/StructuredList.js +3 -3
- package/lib/components/Tabs/Tabs.js +12 -12
- package/lib/components/Tag/DismissibleTag.js +3 -3
- package/lib/components/Tag/OperationalTag.js +2 -2
- package/lib/components/Tag/SelectableTag.js +2 -2
- package/lib/components/Tag/Tag.js +4 -4
- package/lib/components/Tag/isEllipsisActive.js +1 -1
- package/lib/components/Text/Text.js +1 -1
- package/lib/components/TextArea/TextArea.js +1 -1
- package/lib/components/TextInput/PasswordInput.js +4 -4
- package/lib/components/TextInput/TextInput.js +3 -3
- package/lib/components/Theme/index.js +3 -3
- package/lib/components/Tile/Tile.js +3 -3
- package/lib/components/TimePicker/TimePicker.js +1 -1
- package/lib/components/Toggletip/index.js +4 -4
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
- package/lib/components/Tooltip/Tooltip.js +3 -3
- package/lib/components/TreeView/TreeNode.js +6 -6
- package/lib/components/TreeView/TreeView.js +5 -5
- package/lib/components/UIShell/HeaderContainer.js +1 -1
- package/lib/components/UIShell/HeaderMenu.js +1 -1
- package/lib/components/UIShell/Link.js +2 -2
- package/lib/components/UIShell/SideNavItems.js +1 -1
- package/lib/components/UIShell/Switcher.js +1 -1
- package/lib/components/UIShell/SwitcherItem.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/internal/FloatingMenu.js +4 -4
- package/lib/internal/Selection.js +6 -6
- package/lib/internal/useMergedRefs.js +1 -1
- package/lib/internal/useNoInteractiveChildren.js +4 -4
- package/lib/internal/useOutsideClick.js +1 -1
- package/lib/internal/useOverflowItems.js +6 -6
- package/lib/internal/useResizeObserver.js +3 -3
- package/lib/internal/useSavedCallback.js +1 -1
- package/lib/internal/warning.js +1 -1
- package/lib/prop-types/isRequiredOneOf.js +2 -2
- package/lib/tools/events.js +1 -1
- package/lib/tools/wrapComponent.js +1 -1
- package/lib/types/common.d.ts +6 -2
- package/package.json +9 -9
|
@@ -69,7 +69,7 @@ const SwitcherItem = /*#__PURE__*/forwardRef((props, forwardRef) => {
|
|
|
69
69
|
href: href,
|
|
70
70
|
target: target,
|
|
71
71
|
rel: rel
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
73
73
|
,
|
|
74
74
|
ref: forwardRef
|
|
75
75
|
}, rest, {
|
package/es/index.d.ts
CHANGED
|
@@ -245,7 +245,7 @@ export type { ListBoxFieldProps } from './components/ListBox/ListBoxField';
|
|
|
245
245
|
export type { ListBoxMenuProps } from './components/ListBox/ListBoxMenu';
|
|
246
246
|
export type { ListBoxMenuItemProps } from './components/ListBox/ListBoxMenuItem';
|
|
247
247
|
export type { ListBoxMenuIconProps } from './components/ListBox/ListBoxMenuIcon';
|
|
248
|
-
export type { ListBoxMenuIconTranslationKey } from './components/ListBox
|
|
248
|
+
export type { ListBoxMenuIconTranslationKey, ListBoxSelectionTranslationKey, } from './components/ListBox';
|
|
249
249
|
export type { ListBoxMenuIconComponent } from './components/ListBox/ListBoxMenuIcon';
|
|
250
250
|
export type { ListBoxSelectionProps } from './components/ListBox/ListBoxSelection';
|
|
251
251
|
export type { ListItemProps } from './components/ListItem/ListItem';
|
|
@@ -198,7 +198,7 @@ const FloatingMenu = ({
|
|
|
198
198
|
}
|
|
199
199
|
placeInProgressRef.current = false;
|
|
200
200
|
}
|
|
201
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
201
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
202
202
|
}, [floatingPosition, onPlace]);
|
|
203
203
|
|
|
204
204
|
// Attach a resize listener.
|
|
@@ -209,13 +209,13 @@ const FloatingMenu = ({
|
|
|
209
209
|
return () => {
|
|
210
210
|
resizeHandler.remove();
|
|
211
211
|
};
|
|
212
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
212
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
213
213
|
}, [triggerRef, menuOffset, menuDirection, flipped, target, updateOrientation]);
|
|
214
214
|
|
|
215
215
|
// Update menu position when key props change.
|
|
216
216
|
useEffect(() => {
|
|
217
217
|
updateMenuPosition();
|
|
218
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
218
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
219
219
|
}, [menuOffset, menuDirection, flipped, triggerRef, target, updateOrientation]);
|
|
220
220
|
|
|
221
221
|
/**
|
|
@@ -279,7 +279,7 @@ const FloatingMenu = ({
|
|
|
279
279
|
const portalTarget = target ? target() : document.body;
|
|
280
280
|
return /*#__PURE__*/ReactDOM.createPortal(
|
|
281
281
|
/*#__PURE__*/
|
|
282
|
-
// eslint-disable-next-line jsx-a11y/no-static-element-interactions -- https://github.com/carbon-design-system/carbon/issues/
|
|
282
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
283
283
|
React.createElement("div", {
|
|
284
284
|
onBlur: focusTrap && !focusTrapWithoutSentinels ? handleBlur : undefined,
|
|
285
285
|
onKeyDown: focusTrapWithoutSentinels ? handleKeyDown : undefined
|
package/es/internal/Selection.js
CHANGED
|
@@ -42,7 +42,7 @@ const useSelection = ({
|
|
|
42
42
|
const savedOnChange = useRef(onChange);
|
|
43
43
|
const [uncontrolledItems, setUncontrolledItems] = useState(initialSelectedItems);
|
|
44
44
|
const isControlled = !!controlledItems;
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
46
46
|
const selectedItems = isControlled ? controlledItems : uncontrolledItems;
|
|
47
47
|
const onItemChange = useCallback(item => {
|
|
48
48
|
if (disabled) return;
|
|
@@ -50,20 +50,20 @@ const useSelection = ({
|
|
|
50
50
|
// Assert special properties (e.g., `disabled`, `isSelectAll`, etc.) are
|
|
51
51
|
// `any` since those properties aren’t part of the generic type.
|
|
52
52
|
const allSelectableItems = filteredItems.filter(
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
53
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
54
54
|
item => !item?.disabled && !item?.isSelectAll);
|
|
55
55
|
const disabledItemCount = filteredItems.filter(
|
|
56
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
57
57
|
item => item?.disabled).length;
|
|
58
58
|
let newSelectedItems;
|
|
59
59
|
|
|
60
60
|
// deselect all on click to All/indeterminate option
|
|
61
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
62
62
|
if (item?.isSelectAll && selectedItems.length > 0) {
|
|
63
63
|
newSelectedItems = [];
|
|
64
64
|
}
|
|
65
65
|
// select all options
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
67
67
|
else if (item?.isSelectAll && selectedItems.length === 0) {
|
|
68
68
|
newSelectedItems = allSelectableItems;
|
|
69
69
|
} else {
|
|
@@ -77,7 +77,7 @@ const useSelection = ({
|
|
|
77
77
|
} else {
|
|
78
78
|
newSelectedItems = removeAtIndex(selectedItems, selectedIndex);
|
|
79
79
|
newSelectedItems = newSelectedItems.filter(
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
81
81
|
item => !item?.isSelectAll);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -16,7 +16,7 @@ import { useMemo, useCallback } from 'react';
|
|
|
16
16
|
* node, assigns that node to every ref in the array.
|
|
17
17
|
*/
|
|
18
18
|
const useMergedRefs = refs => {
|
|
19
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
19
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
20
20
|
const memoizedRefs = useMemo(() => refs, refs);
|
|
21
21
|
return useCallback(node => {
|
|
22
22
|
memoizedRefs.forEach(ref => {
|
|
@@ -14,16 +14,16 @@ const useNoInteractiveChildren = (ref, message = 'component should have no inter
|
|
|
14
14
|
/*
|
|
15
15
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
16
16
|
*/
|
|
17
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
17
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
const node = ref.current ? getInteractiveContent(ref.current) : false;
|
|
20
20
|
if (node) {
|
|
21
21
|
const errorMessage = `Error: ${message}.\n\nInstead found: ${node.outerHTML}`;
|
|
22
|
-
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/
|
|
22
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
23
23
|
console.error(errorMessage);
|
|
24
24
|
throw new Error(errorMessage);
|
|
25
25
|
}
|
|
26
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
27
27
|
}, []);
|
|
28
28
|
}
|
|
29
29
|
};
|
|
@@ -34,7 +34,7 @@ const useInteractiveChildrenNeedDescription = (ref, message = `interactive child
|
|
|
34
34
|
/*
|
|
35
35
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
36
36
|
*/
|
|
37
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
37
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
38
38
|
useEffect(() => {
|
|
39
39
|
const node = ref.current ? getInteractiveContent(ref.current) : false;
|
|
40
40
|
if (node && !node.hasAttribute('aria-describedby')) {
|
|
@@ -23,7 +23,7 @@ const useOutsideClick = (ref, callback) => {
|
|
|
23
23
|
/*
|
|
24
24
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
25
25
|
*/
|
|
26
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
26
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
27
27
|
useWindowEvent('click', event => {
|
|
28
28
|
const {
|
|
29
29
|
target
|
|
@@ -36,7 +36,7 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
|
|
|
36
36
|
setMaxWidth(newMax);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
39
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
40
40
|
useResizeObserver({
|
|
41
41
|
ref: containerRef,
|
|
42
42
|
onResize: handleResize
|
|
@@ -86,17 +86,17 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
|
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
// Memoize visible items calculation to avoid recalculating on every render
|
|
89
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
89
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
90
90
|
const visibleItems = useMemo(() => {
|
|
91
91
|
if (!Array.isArray(items)) {
|
|
92
92
|
return [];
|
|
93
93
|
}
|
|
94
94
|
return getVisibleItems();
|
|
95
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
95
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
96
96
|
}, [items, maxWidth, maxItems]);
|
|
97
97
|
|
|
98
98
|
// Memoize hidden items calculation
|
|
99
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
99
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
100
100
|
const hiddenItems = useMemo(() => {
|
|
101
101
|
if (!Array.isArray(items)) {
|
|
102
102
|
return [];
|
|
@@ -105,11 +105,11 @@ const useOverflowItems = (items, containerRef, offsetRef, maxItems, onChange) =>
|
|
|
105
105
|
}, [items, visibleItems]);
|
|
106
106
|
|
|
107
107
|
// Use previous value to compare and only call onChange when needed
|
|
108
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
108
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
109
109
|
const previousHiddenItems = usePreviousValue(hiddenItems);
|
|
110
110
|
|
|
111
111
|
// Only call onChange if hidden items actually changed
|
|
112
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/
|
|
112
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
113
113
|
useEffect(() => {
|
|
114
114
|
}, [hiddenItems, previousHiddenItems, onChange]);
|
|
115
115
|
return {
|
|
@@ -35,7 +35,7 @@ const useResizeObserver = ({
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
getInitialSize();
|
|
38
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
38
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
39
39
|
}, [width, height]);
|
|
40
40
|
useLayoutEffect(() => {
|
|
41
41
|
if (!ref?.current) {
|
|
@@ -49,7 +49,7 @@ const useResizeObserver = ({
|
|
|
49
49
|
setWidth(entry.contentRect.width);
|
|
50
50
|
setHeight(entry.contentRect.height);
|
|
51
51
|
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
53
53
|
cb.current && cb.current(entry.contentRect);
|
|
54
54
|
};
|
|
55
55
|
const observer = new ResizeObserver(entries => {
|
|
@@ -66,7 +66,7 @@ const useResizeObserver = ({
|
|
|
66
66
|
return () => {
|
|
67
67
|
observer.disconnect();
|
|
68
68
|
};
|
|
69
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
70
70
|
}, []);
|
|
71
71
|
return {
|
|
72
72
|
width,
|
|
@@ -15,7 +15,7 @@ import { useRef, useEffect, useCallback } from 'react';
|
|
|
15
15
|
*
|
|
16
16
|
* @param callback - The callback to track.
|
|
17
17
|
*/
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
19
19
|
const useSavedCallback = callback => {
|
|
20
20
|
const savedCallback = useRef(callback);
|
|
21
21
|
useEffect(() => {
|
package/es/internal/warning.js
CHANGED
|
@@ -22,7 +22,7 @@ const warning = process.env.NODE_ENV !== 'production' ? (condition, message) =>
|
|
|
22
22
|
throw new Error('`warning(condition, message)` requires a warning ' + 'format argument');
|
|
23
23
|
}
|
|
24
24
|
if (!condition) {
|
|
25
|
-
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/
|
|
25
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
26
26
|
console.warn('Warning: ' + message);
|
|
27
27
|
}
|
|
28
28
|
} : noopFn;
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
* are the names of the props, and the values are the prop-type validators.
|
|
14
14
|
* @returns A new object of wrapped prop-type validators.
|
|
15
15
|
*/
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
17
17
|
const isRequiredOneOf = propTypes => {
|
|
18
18
|
const names = Object.keys(propTypes);
|
|
19
19
|
const checker = propType =>
|
|
20
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
20
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
21
21
|
(props, propName, componentName, ...rest) => {
|
|
22
22
|
if (process.env.NODE_ENV !== 'production' && names.every(name => typeof props[name] === 'undefined')) {
|
|
23
23
|
return new Error(`${componentName} requires one of the following props: ${names.join(', ')}`);
|
package/es/tools/events.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @returns A composite event handler.
|
|
16
16
|
*/
|
|
17
17
|
const composeEventHandlers = handlers =>
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
19
19
|
(event, ...args) => {
|
|
20
20
|
for (const handler of handlers) {
|
|
21
21
|
if (event.defaultPrevented) {
|
|
@@ -42,7 +42,7 @@ const wrapComponent = ({
|
|
|
42
42
|
Component.propTypes = {
|
|
43
43
|
className: PropTypes.string
|
|
44
44
|
};
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
46
46
|
return Component;
|
|
47
47
|
};
|
|
48
48
|
|
package/es/types/common.d.ts
CHANGED
|
@@ -13,8 +13,12 @@ export type PolymorphicProps<Element extends React.ElementType, Props> = Props &
|
|
|
13
13
|
};
|
|
14
14
|
export interface TranslateWithId<MID = string, ARGS = Record<string, unknown>> {
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Translates component strings using your i18n tool.
|
|
17
|
+
*
|
|
18
|
+
* @param messageId - The translation ID for the string to translate.
|
|
19
|
+
* @param [args] - Arguments for string interpolation.
|
|
20
|
+
* @returns The translated string.
|
|
18
21
|
*/
|
|
19
22
|
translateWithId?(messageId: MID, args?: ARGS): string;
|
|
20
23
|
}
|
|
24
|
+
export type TFunc<K, A = Record<string, unknown>> = NonNullable<TranslateWithId<K, A>['translateWithId']>;
|
|
@@ -22,18 +22,18 @@ var _Undo;
|
|
|
22
22
|
const AILabelContent = /*#__PURE__*/React.forwardRef(function AILabelContent({
|
|
23
23
|
className,
|
|
24
24
|
children
|
|
25
|
-
}, ref // eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
25
|
+
}, ref // eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
26
26
|
) {
|
|
27
27
|
const prefix = usePrefix.usePrefix();
|
|
28
28
|
const hasAILabelActions = React.Children.toArray(children).some(child => {
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
30
30
|
const item = child;
|
|
31
31
|
// TODO: Is there supposed to be a `return` here? If so, this issue would
|
|
32
32
|
// have been caught by ESLint. It's concerning that this code is 7 months
|
|
33
33
|
// old and no one has noticed any issues with it. It also makes me question
|
|
34
34
|
// whether the code is necessary.
|
|
35
35
|
// https://github.com/carbon-design-system/carbon/issues/18991
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
37
37
|
item.type === AILabelActions;
|
|
38
38
|
});
|
|
39
39
|
const aiLabelContentClasses = cx(className, {
|
|
@@ -58,7 +58,7 @@ AILabelContent.propTypes = {
|
|
|
58
58
|
const AILabelActions = /*#__PURE__*/React.forwardRef(function AILabelActions({
|
|
59
59
|
className,
|
|
60
60
|
children
|
|
61
|
-
}, ref // eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
61
|
+
}, ref // eslint-disable-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
62
62
|
) {
|
|
63
63
|
const prefix = usePrefix.usePrefix();
|
|
64
64
|
const aiLabelActionsClasses = cx(className, {
|
|
@@ -38,7 +38,7 @@ const BreadcrumbItem = frFn((props, ref) => {
|
|
|
38
38
|
[customClassName]: !!customClassName
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
42
42
|
const child = children;
|
|
43
43
|
if (child.type && child.type.displayName !== undefined && child.type.displayName.includes('OverflowMenu')) {
|
|
44
44
|
const horizontalOverflowIcon = /*#__PURE__*/React.createElement(iconsReact.OverflowMenuHorizontal, {
|
|
@@ -26,7 +26,7 @@ function isIconOnlyButton(hasIconOnly, _kind) {
|
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/
|
|
29
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
30
30
|
const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
31
31
|
const {
|
|
32
32
|
as,
|
|
@@ -49,7 +49,7 @@ const Button = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
49
49
|
...rest
|
|
50
50
|
} = props;
|
|
51
51
|
if (ButtonImageElement && !children && !iconDescription) {
|
|
52
|
-
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/
|
|
52
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
53
53
|
console.error('Button: renderIcon property specified without also providing an iconDescription property. ' + 'This may impact accessibility for screen reader users.');
|
|
54
54
|
}
|
|
55
55
|
const iconOnlyImage = !ButtonImageElement ? null : /*#__PURE__*/React.createElement(ButtonImageElement, null);
|
|
@@ -42,7 +42,7 @@ const ChatButton = /*#__PURE__*/React.forwardRef(function ChatButton({
|
|
|
42
42
|
} else {
|
|
43
43
|
// Check if size is valid and warn if not
|
|
44
44
|
if (size && !allowedSizes.includes(size)) {
|
|
45
|
-
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/
|
|
45
|
+
// eslint-disable-next-line no-console -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
46
46
|
console.error(`Invalid size "${size}" provided to ChatButton. Size must be one of: ${allowedSizes.join(', ')}. Defaulting to "lg".`);
|
|
47
47
|
size = 'lg';
|
|
48
48
|
}
|
|
@@ -65,7 +65,7 @@ const Checkbox = /*#__PURE__*/React.forwardRef(({
|
|
|
65
65
|
const candidateIsAILabel = utils.isComponentElement(candidate, index.AILabel);
|
|
66
66
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
67
67
|
size: candidate.props.kind === 'inline' ? 'md' : 'mini'
|
|
68
|
-
}) :
|
|
68
|
+
}) : candidate;
|
|
69
69
|
return /*#__PURE__*/React.createElement("div", {
|
|
70
70
|
className: wrapperClasses
|
|
71
71
|
}, /*#__PURE__*/React.createElement("input", _rollupPluginBabelHelpers.extends({}, other, {
|
|
@@ -62,7 +62,7 @@ const CheckboxGroup = ({
|
|
|
62
62
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
|
|
63
63
|
size: 'mini',
|
|
64
64
|
kind: 'default'
|
|
65
|
-
}) :
|
|
65
|
+
}) : candidate;
|
|
66
66
|
const clonedChildren = React.Children.map(children, child => {
|
|
67
67
|
if (/*#__PURE__*/React.isValidElement(child) && child.type === Checkbox.default) {
|
|
68
68
|
const childProps = {
|
|
@@ -64,8 +64,6 @@ function CodeSnippet({
|
|
|
64
64
|
const codeContentRef = React.useRef(null);
|
|
65
65
|
const codeContainerRef = React.useRef(null);
|
|
66
66
|
const innerCodeRef = React.useRef(null);
|
|
67
|
-
const [hasLeftOverflow, setHasLeftOverflow] = React.useState(false);
|
|
68
|
-
const [hasRightOverflow, setHasRightOverflow] = React.useState(false);
|
|
69
67
|
const getCodeRef = React.useCallback(() => {
|
|
70
68
|
if (type === 'single') {
|
|
71
69
|
return codeContainerRef;
|
|
@@ -77,39 +75,13 @@ function CodeSnippet({
|
|
|
77
75
|
}
|
|
78
76
|
}, [type]);
|
|
79
77
|
const prefix = usePrefix.usePrefix();
|
|
80
|
-
const getCodeRefDimensions = React.useCallback(() => {
|
|
81
|
-
const {
|
|
82
|
-
clientWidth: codeClientWidth = 0,
|
|
83
|
-
scrollLeft: codeScrollLeft = 0,
|
|
84
|
-
scrollWidth: codeScrollWidth = 0
|
|
85
|
-
} = getCodeRef().current || {};
|
|
86
|
-
return {
|
|
87
|
-
horizontalOverflow: codeScrollWidth > codeClientWidth,
|
|
88
|
-
codeClientWidth,
|
|
89
|
-
codeScrollWidth,
|
|
90
|
-
codeScrollLeft
|
|
91
|
-
};
|
|
92
|
-
}, [getCodeRef]);
|
|
93
|
-
const handleScroll = React.useCallback(() => {
|
|
94
|
-
if (type === 'inline' || type === 'single' && !codeContainerRef?.current || type === 'multi' && !codeContentRef?.current) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const {
|
|
98
|
-
horizontalOverflow,
|
|
99
|
-
codeClientWidth,
|
|
100
|
-
codeScrollWidth,
|
|
101
|
-
codeScrollLeft
|
|
102
|
-
} = getCodeRefDimensions();
|
|
103
|
-
setHasLeftOverflow(horizontalOverflow && !!codeScrollLeft);
|
|
104
|
-
setHasRightOverflow(horizontalOverflow && codeScrollLeft + codeClientWidth !== codeScrollWidth);
|
|
105
|
-
}, [type, getCodeRefDimensions]);
|
|
106
78
|
useResizeObserver.useResizeObserver({
|
|
107
79
|
ref: getCodeRef(),
|
|
108
80
|
onResize: () => {
|
|
109
|
-
if (
|
|
81
|
+
if (innerCodeRef?.current && type === 'multi') {
|
|
110
82
|
const {
|
|
111
83
|
height
|
|
112
|
-
} =
|
|
84
|
+
} = innerCodeRef.current.getBoundingClientRect();
|
|
113
85
|
if (maxCollapsedNumberOfRows > 0 && (maxExpandedNumberOfRows <= 0 || maxExpandedNumberOfRows > maxCollapsedNumberOfRows) && height > maxCollapsedNumberOfRows * rowHeightInPixels) {
|
|
114
86
|
setShouldShowMoreLessBtn(true);
|
|
115
87
|
} else {
|
|
@@ -119,14 +91,8 @@ function CodeSnippet({
|
|
|
119
91
|
setExpandedCode(false);
|
|
120
92
|
}
|
|
121
93
|
}
|
|
122
|
-
if (codeContentRef?.current && type === 'multi' || codeContainerRef?.current && type === 'single') {
|
|
123
|
-
handleScroll();
|
|
124
|
-
}
|
|
125
94
|
}
|
|
126
95
|
});
|
|
127
|
-
React.useEffect(() => {
|
|
128
|
-
handleScroll();
|
|
129
|
-
}, [handleScroll]);
|
|
130
96
|
const handleCopyClick = evt => {
|
|
131
97
|
if (copyText || innerCodeRef?.current) {
|
|
132
98
|
copy(copyText ?? innerCodeRef?.current?.innerText ?? '');
|
|
@@ -141,8 +107,7 @@ function CodeSnippet({
|
|
|
141
107
|
[`${prefix}--snippet--expand`]: expandedCode,
|
|
142
108
|
[`${prefix}--snippet--light`]: light,
|
|
143
109
|
[`${prefix}--snippet--no-copy`]: hideCopyButton,
|
|
144
|
-
[`${prefix}--snippet--wraptext`]: wrapText
|
|
145
|
-
[`${prefix}--snippet--has-right-overflow`]: type == 'multi' && hasRightOverflow
|
|
110
|
+
[`${prefix}--snippet--wraptext`]: wrapText
|
|
146
111
|
});
|
|
147
112
|
const expandCodeBtnText = expandedCode ? showLessText : showMoreText;
|
|
148
113
|
if (type === 'inline') {
|
|
@@ -200,18 +165,12 @@ function CodeSnippet({
|
|
|
200
165
|
className: `${prefix}--snippet-container`,
|
|
201
166
|
"aria-label": deprecatedAriaLabel || ariaLabel || 'code-snippet',
|
|
202
167
|
"aria-readonly": type === 'single' || type === 'multi' ? true : undefined,
|
|
203
|
-
"aria-multiline": type === 'multi' ? true : undefined
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
onScroll: type === 'multi' && handleScroll || undefined
|
|
208
|
-
}, /*#__PURE__*/React.createElement("code", {
|
|
168
|
+
"aria-multiline": type === 'multi' ? true : undefined
|
|
169
|
+
}, containerStyle), /*#__PURE__*/React.createElement("pre", _rollupPluginBabelHelpers.extends({
|
|
170
|
+
ref: codeContentRef
|
|
171
|
+
}, containerStyle), /*#__PURE__*/React.createElement("code", {
|
|
209
172
|
ref: innerCodeRef
|
|
210
|
-
}, children))),
|
|
211
|
-
className: `${prefix}--snippet__overflow-indicator--left`
|
|
212
|
-
}), hasRightOverflow && type !== 'multi' && /*#__PURE__*/React.createElement("div", {
|
|
213
|
-
className: `${prefix}--snippet__overflow-indicator--right`
|
|
214
|
-
}), !hideCopyButton && /*#__PURE__*/React.createElement(CopyButton.default, {
|
|
173
|
+
}, children))), !hideCopyButton && /*#__PURE__*/React.createElement(CopyButton.default, {
|
|
215
174
|
align: align,
|
|
216
175
|
autoAlign: autoAlign,
|
|
217
176
|
size: type === 'multi' ? 'sm' : 'md',
|
|
@@ -6,23 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { UseComboboxProps, UseComboboxActions } from 'downshift';
|
|
8
8
|
import React, { type ComponentType, type InputHTMLAttributes, type MouseEvent, type PropsWithChildren, type PropsWithRef, type ReactElement, type ReactNode, type RefAttributes } from 'react';
|
|
9
|
-
import { type ListBoxSize } from '../ListBox';
|
|
10
|
-
import { TranslateWithId } from '../../types/common';
|
|
9
|
+
import { type ListBoxMenuIconTranslationKey, type ListBoxSelectionTranslationKey, type ListBoxSize } from '../ListBox';
|
|
10
|
+
import type { TranslateWithId } from '../../types/common';
|
|
11
11
|
type ExcludedAttributes = 'id' | 'onChange' | 'onClick' | 'type' | 'size';
|
|
12
12
|
export interface OnChangeData<ItemType> {
|
|
13
13
|
selectedItem: ItemType | null | undefined;
|
|
14
14
|
inputValue?: string | null;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Message ids that will be passed to translateWithId().
|
|
18
|
-
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
19
|
-
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
20
|
-
* because those components aren't Typescript. (If you try, TranslationKey
|
|
21
|
-
* ends up just being defined as "string".)
|
|
22
|
-
*/
|
|
23
|
-
export type TranslationKey = 'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection';
|
|
24
16
|
export type ItemToStringHandler<ItemType> = (item: ItemType | null) => string;
|
|
25
|
-
export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<
|
|
17
|
+
export interface ComboBoxProps<ItemType> extends Omit<InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey | ListBoxSelectionTranslationKey> {
|
|
26
18
|
/**
|
|
27
19
|
* Specify whether or not the ComboBox should allow a value that is
|
|
28
20
|
* not in the list to be entered in the input
|