@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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, { useContext, useRef,
|
|
10
|
+
import React, { useContext, useRef, useEffect, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Close } from '@carbon/icons-react';
|
|
13
13
|
import { toggleClass } from '../../tools/toggleClass.js';
|
|
@@ -18,7 +18,7 @@ import InlineLoading from '../InlineLoading/InlineLoading.js';
|
|
|
18
18
|
import { Layer } from '../Layer/index.js';
|
|
19
19
|
import { requiredIfGivenPropIsTruthy } from '../../prop-types/requiredIfGivenPropIsTruthy.js';
|
|
20
20
|
import { wrapFocus, wrapFocusWithoutSentinels, elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
|
|
21
|
-
import
|
|
21
|
+
import { useResizeObserver } from '../../internal/useResizeObserver.js';
|
|
22
22
|
import { useId } from '../../internal/useId.js';
|
|
23
23
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
24
24
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -37,7 +37,6 @@ import { AILabel } from '../AILabel/index.js';
|
|
|
37
37
|
import { isComponentElement } from '../../internal/utils.js';
|
|
38
38
|
import { warning } from '../../internal/warning.js';
|
|
39
39
|
import { ModalPresenceContext, useExclusiveModalPresenceContext, ModalPresence } from './ModalPresence.js';
|
|
40
|
-
import { debounce } from '../../node_modules/es-toolkit/dist/compat/function/debounce.js';
|
|
41
40
|
|
|
42
41
|
const ModalSizes = ['xs', 'sm', 'md', 'lg'];
|
|
43
42
|
const invalidOutsideClickMessage = '`<Modal>` prop `preventCloseOnClickOutside` should not be `false` when ' + '`passiveModal` is `false`. Transactional, non-passive Modals should ' + 'not be dissmissable by clicking outside. ' + 'See: https://carbondesignsystem.com/components/modal/usage/#transactional-modal';
|
|
@@ -112,7 +111,6 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
|
|
|
112
111
|
const startTrap = useRef(null);
|
|
113
112
|
const endTrap = useRef(null);
|
|
114
113
|
const wrapFocusTimeout = useRef(null);
|
|
115
|
-
const [isScrollable, setIsScrollable] = useState(false);
|
|
116
114
|
const modalInstanceId = `modal-${useId()}`;
|
|
117
115
|
const modalLabelId = `${prefix}--modal-header__label--${modalInstanceId}`;
|
|
118
116
|
const modalHeadingId = `${prefix}--modal-header__heading--${modalInstanceId}`;
|
|
@@ -212,6 +210,11 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
|
|
|
212
210
|
});
|
|
213
211
|
}
|
|
214
212
|
const onSecondaryButtonClick = onSecondarySubmit ? onSecondarySubmit : onRequestClose;
|
|
213
|
+
const {
|
|
214
|
+
height
|
|
215
|
+
} = useResizeObserver({
|
|
216
|
+
ref: contentRef
|
|
217
|
+
});
|
|
215
218
|
const modalClasses = cx(`${prefix}--modal`, {
|
|
216
219
|
[`${prefix}--modal-tall`]: !passiveModal,
|
|
217
220
|
'is-visible': enablePresence || open,
|
|
@@ -224,8 +227,15 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
|
|
|
224
227
|
[`${prefix}--modal-container--${size}`]: size,
|
|
225
228
|
[`${prefix}--modal-container--full-width`]: isFullWidth
|
|
226
229
|
});
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* isScrollable is implicitly dependent on height, when height gets updated
|
|
233
|
+
* via `useResizeObserver`, clientHeight and scrollHeight get updated too
|
|
234
|
+
*/
|
|
235
|
+
const isScrollable = !!contentRef.current && contentRef?.current?.scrollHeight > contentRef?.current?.clientHeight;
|
|
227
236
|
const contentClasses = cx(`${prefix}--modal-content`, {
|
|
228
|
-
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable
|
|
237
|
+
[`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
|
|
238
|
+
[`${prefix}--modal-scroll-content--no-fade`]: height <= 300
|
|
229
239
|
});
|
|
230
240
|
const footerClasses = cx(`${prefix}--modal-footer`, {
|
|
231
241
|
[`${prefix}--modal-footer--three-button`]: Array.isArray(secondaryButtons) && secondaryButtons.length === 2
|
|
@@ -264,7 +274,7 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
|
|
|
264
274
|
return () => {
|
|
265
275
|
document.removeEventListener('keydown', handleEscapeKey, true);
|
|
266
276
|
};
|
|
267
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
277
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
268
278
|
}, [open]);
|
|
269
279
|
useEffect(() => {
|
|
270
280
|
return () => {
|
|
@@ -319,29 +329,13 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
|
|
|
319
329
|
}
|
|
320
330
|
}
|
|
321
331
|
}, [open, selectorPrimaryFocus, danger, prefix, enableDialogElement]);
|
|
322
|
-
useIsomorphicEffect(() => {
|
|
323
|
-
if (contentRef.current) {
|
|
324
|
-
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
325
|
-
}
|
|
326
|
-
function handler() {
|
|
327
|
-
if (contentRef.current) {
|
|
328
|
-
setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
const debouncedHandler = debounce(handler, 200);
|
|
332
|
-
window.addEventListener('resize', debouncedHandler);
|
|
333
|
-
return () => {
|
|
334
|
-
debouncedHandler.cancel();
|
|
335
|
-
window.removeEventListener('resize', debouncedHandler);
|
|
336
|
-
};
|
|
337
|
-
}, []);
|
|
338
332
|
|
|
339
333
|
// AILabel always size `sm`
|
|
340
334
|
const candidate = slug ?? decorator;
|
|
341
335
|
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
342
336
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
343
337
|
size: 'sm'
|
|
344
|
-
}) :
|
|
338
|
+
}) : candidate;
|
|
345
339
|
const modalButton = /*#__PURE__*/React.createElement("div", {
|
|
346
340
|
className: `${prefix}--modal-close-button`
|
|
347
341
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
@@ -17,7 +17,7 @@ import { Escape } from '../../internal/keyboard/keys.js';
|
|
|
17
17
|
import { match } from '../../internal/keyboard/match.js';
|
|
18
18
|
|
|
19
19
|
let didWarnAboutDeprecation = false;
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
21
21
|
process.env.NODE_ENV !== 'production';
|
|
22
22
|
class ModalWrapper extends React.Component {
|
|
23
23
|
constructor(...args) {
|
|
@@ -54,7 +54,7 @@ class ModalWrapper extends React.Component {
|
|
|
54
54
|
handleSubmit?.(evt);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
58
58
|
if(isDev) {
|
|
59
59
|
process.env.NODE_ENV !== "production" ? warning(didWarnAboutDeprecation, '`<ModalWrapper>` has been deprecated in favor of `<ComposedModal/>` and will be removed in the next major version, `@carbon/react@v2.x`') : void 0;
|
|
60
60
|
didWarnAboutDeprecation = true;
|
|
@@ -7,17 +7,9 @@
|
|
|
7
7
|
import { type UseComboboxProps, type UseMultipleSelectionProps } from 'downshift';
|
|
8
8
|
import React, { type FunctionComponent, type ReactElement, type ReactNode } from 'react';
|
|
9
9
|
import { type MultiSelectSortingProps } from './MultiSelectPropTypes';
|
|
10
|
-
import { type ListBoxSize, type ListBoxType } from '../ListBox';
|
|
11
|
-
import { TranslateWithId } from '../../types/common';
|
|
12
|
-
|
|
13
|
-
* Message ids that will be passed to translateWithId().
|
|
14
|
-
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
15
|
-
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
16
|
-
* because those components aren't Typescript. (If you try, TranslationKey
|
|
17
|
-
* ends up just being defined as "string".)
|
|
18
|
-
*/
|
|
19
|
-
type TranslationKey = 'close.menu' | 'open.menu' | 'clear.all' | 'clear.selection';
|
|
20
|
-
export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, React.RefAttributes<HTMLDivElement>, TranslateWithId<TranslationKey> {
|
|
10
|
+
import { type ListBoxMenuIconTranslationKey, type ListBoxSelectionTranslationKey, type ListBoxSize, type ListBoxType } from '../ListBox';
|
|
11
|
+
import type { TranslateWithId } from '../../types/common';
|
|
12
|
+
export interface FilterableMultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, React.RefAttributes<HTMLDivElement>, TranslateWithId<ListBoxSelectionTranslationKey | ListBoxMenuIconTranslationKey> {
|
|
21
13
|
/**
|
|
22
14
|
* Specify a label to be read by screen readers on the container node
|
|
23
15
|
* @deprecated
|
|
@@ -209,4 +201,3 @@ export declare const FilterableMultiSelect: {
|
|
|
209
201
|
defaultProps?: any;
|
|
210
202
|
displayName?: any;
|
|
211
203
|
};
|
|
212
|
-
export {};
|
|
@@ -56,15 +56,6 @@ const {
|
|
|
56
56
|
DropdownKeyDownBackspace,
|
|
57
57
|
FunctionRemoveSelectedItem
|
|
58
58
|
} = useMultipleSelection.stateChangeTypes;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Message ids that will be passed to translateWithId().
|
|
62
|
-
* Combination of message ids from ListBox/next/ListBoxSelection.js and
|
|
63
|
-
* ListBox/next/ListBoxTrigger.js, but we can't access those values directly
|
|
64
|
-
* because those components aren't Typescript. (If you try, TranslationKey
|
|
65
|
-
* ends up just being defined as "string".)
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
59
|
const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSelect({
|
|
69
60
|
autoAlign = false,
|
|
70
61
|
className: containerClassName,
|
|
@@ -111,7 +102,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
111
102
|
isFluid
|
|
112
103
|
} = useContext(FormContext);
|
|
113
104
|
const isFirstRender = useRef(true);
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
115
106
|
const [isFocused, setIsFocused] = useState(false);
|
|
116
107
|
const [isOpen, setIsOpen] = useState(!!open);
|
|
117
108
|
const [prevOpen, setPrevOpen] = useState(!!open);
|
|
@@ -123,9 +114,9 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
123
114
|
inputValue
|
|
124
115
|
}), [items, inputValue, itemToString, filterItems]);
|
|
125
116
|
const nonSelectAllItems = useMemo(
|
|
126
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
127
118
|
() => filteredItems.filter(item => !item.isSelectAll), [filteredItems]);
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
129
120
|
const selectAll = filteredItems.some(item => item.isSelectAll);
|
|
130
121
|
const {
|
|
131
122
|
selectedItems: controlledSelectedItems,
|
|
@@ -142,7 +133,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
142
133
|
});
|
|
143
134
|
const selectAllStatus = useMemo(() => {
|
|
144
135
|
const selectable = nonSelectAllItems.filter(
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
146
137
|
item => !item.disabled);
|
|
147
138
|
const nonSelectedCount = selectable.filter(item => !controlledSelectedItems.some(sel => isEqual(sel, item))).length;
|
|
148
139
|
const totalCount = selectable.length;
|
|
@@ -152,7 +143,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
152
143
|
};
|
|
153
144
|
}, [controlledSelectedItems, nonSelectAllItems]);
|
|
154
145
|
const handleSelectAllClick = useCallback(() => {
|
|
155
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
156
147
|
const selectable = nonSelectAllItems.filter(i => !i.disabled);
|
|
157
148
|
const {
|
|
158
149
|
checked,
|
|
@@ -169,7 +160,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
169
160
|
const toSelect = selectable.filter(e => !controlledSelectedItems.some(sel => isEqual(sel, e)));
|
|
170
161
|
toggleAll([...controlledSelectedItems, ...toSelect]);
|
|
171
162
|
}
|
|
172
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
163
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
173
164
|
}, [nonSelectAllItems, selectAllStatus, controlledSelectedItems, toggleAll]);
|
|
174
165
|
const {
|
|
175
166
|
refs,
|
|
@@ -220,14 +211,14 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
220
211
|
|
|
221
212
|
// memoize sorted items to reduce unnecessary expensive sort on rerender
|
|
222
213
|
const sortedItems = useMemo(() => {
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
224
215
|
const selectAllItem = items.find(item => item.isSelectAll);
|
|
225
216
|
const selectableRealItems = nonSelectAllItems.filter(
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
227
218
|
item => !item.disabled);
|
|
228
219
|
|
|
229
220
|
// Sort only non-select-all items, select-all item must stay at the top
|
|
230
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
231
222
|
const sortedReal = sortItems(nonSelectAllItems, {
|
|
232
223
|
selectedItems: {
|
|
233
224
|
top: controlledSelectedItems,
|
|
@@ -244,7 +235,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
244
235
|
return [selectAllItem, ...sortedReal];
|
|
245
236
|
}
|
|
246
237
|
return sortedReal;
|
|
247
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
238
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
248
239
|
}, [items, inputValue, controlledSelectedItems, topItems, selectionFeedback, itemToString, compareItems, locale, sortItems, nonSelectAllItems]);
|
|
249
240
|
const inline = type === 'inline';
|
|
250
241
|
const showWarning = !invalid && warn;
|
|
@@ -328,7 +319,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
328
319
|
return () => {
|
|
329
320
|
document.removeEventListener('mousedown', handleClickOutside);
|
|
330
321
|
};
|
|
331
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
322
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
332
323
|
}, [isOpen, inputFocused]);
|
|
333
324
|
const {
|
|
334
325
|
getToggleButtonProps,
|
|
@@ -351,9 +342,9 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
351
342
|
inputId,
|
|
352
343
|
inputValue,
|
|
353
344
|
stateReducer,
|
|
354
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
345
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
355
346
|
isItemDisabled(item, _index) {
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
347
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
357
348
|
return item?.disabled;
|
|
358
349
|
}
|
|
359
350
|
});
|
|
@@ -521,11 +512,11 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
521
512
|
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
522
513
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
523
514
|
size: 'mini'
|
|
524
|
-
}) :
|
|
515
|
+
}) : candidate;
|
|
525
516
|
|
|
526
517
|
// exclude the select-all item from the count
|
|
527
518
|
const selectedItemsLength = controlledSelectedItems.filter(
|
|
528
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
519
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
529
520
|
item => !item.isSelectAll).length;
|
|
530
521
|
const className = cx(`${prefix}--multi-select`, `${prefix}--combo-box`, `${prefix}--multi-select--filterable`, {
|
|
531
522
|
[`${prefix}--multi-select--invalid`]: invalid,
|
|
@@ -707,7 +698,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
707
698
|
}, normalizedDecorator) : '', /*#__PURE__*/React.createElement(ListBox.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|
|
708
699
|
let isChecked;
|
|
709
700
|
let isIndeterminate = false;
|
|
710
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
701
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
711
702
|
if (item.isSelectAll) {
|
|
712
703
|
isChecked = selectAllStatus.checked;
|
|
713
704
|
isIndeterminate = selectAllStatus.indeterminate;
|
|
@@ -805,7 +796,7 @@ FilterableMultiSelect.propTypes = {
|
|
|
805
796
|
* change, and in some cases they can not be shimmed by Carbon to shield you
|
|
806
797
|
* from potentially breaking changes.
|
|
807
798
|
*/
|
|
808
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/
|
|
799
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
809
800
|
// @ts-ignore
|
|
810
801
|
downshiftProps: PropTypes.shape(Downshift.propTypes),
|
|
811
802
|
/**
|
|
@@ -897,7 +888,7 @@ FilterableMultiSelect.propTypes = {
|
|
|
897
888
|
*/
|
|
898
889
|
titleText: PropTypes.node,
|
|
899
890
|
/**
|
|
900
|
-
*
|
|
891
|
+
* Translates component strings using your i18n tool.
|
|
901
892
|
*/
|
|
902
893
|
translateWithId: PropTypes.func,
|
|
903
894
|
type: ListBoxTypePropType,
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { UseSelectProps } from 'downshift';
|
|
8
8
|
import React, { type ReactNode } from 'react';
|
|
9
|
-
import { type ListBoxSize, type ListBoxType } from '../ListBox';
|
|
9
|
+
import { type ListBoxMenuIconTranslationKey, type ListBoxSelectionTranslationKey, type ListBoxSize, type ListBoxType } from '../ListBox';
|
|
10
10
|
import { MultiSelectSortingProps } from './MultiSelectPropTypes';
|
|
11
11
|
import { ListBoxProps } from '../ListBox/ListBox';
|
|
12
12
|
import type { TranslateWithId } from '../../types/common';
|
|
13
13
|
interface OnChangeData<ItemType> {
|
|
14
14
|
selectedItems: ItemType[] | null;
|
|
15
15
|
}
|
|
16
|
-
export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, TranslateWithId<
|
|
16
|
+
export interface MultiSelectProps<ItemType> extends MultiSelectSortingProps<ItemType>, TranslateWithId<ListBoxMenuIconTranslationKey | ListBoxSelectionTranslationKey> {
|
|
17
17
|
/**
|
|
18
18
|
* **Experimental**: Will attempt to automatically align the floating
|
|
19
19
|
* element to avoid collisions with the viewport and being clipped by
|
|
@@ -101,14 +101,14 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
101
101
|
});
|
|
102
102
|
}, [items]);
|
|
103
103
|
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
105
105
|
const selectAll = filteredItems.some(item => item.isSelectAll);
|
|
106
106
|
const prefix = usePrefix();
|
|
107
107
|
const {
|
|
108
108
|
isFluid
|
|
109
109
|
} = useContext(FormContext);
|
|
110
110
|
const multiSelectInstanceId = useId();
|
|
111
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
112
112
|
const [isFocused, setIsFocused] = useState(false);
|
|
113
113
|
const [inputFocused, setInputFocused] = useState(false);
|
|
114
114
|
const [isOpen, setIsOpen] = useState(open || false);
|
|
@@ -183,9 +183,9 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
183
183
|
},
|
|
184
184
|
selectedItem: controlledSelectedItems,
|
|
185
185
|
items: filteredItems,
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
186
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
187
187
|
isItemDisabled(item, _index) {
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
189
189
|
return item?.disabled;
|
|
190
190
|
},
|
|
191
191
|
...downshiftProps
|
|
@@ -381,7 +381,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
381
381
|
[`${prefix}--list-box__field--wrapper--input-focused`]: inputFocused
|
|
382
382
|
});
|
|
383
383
|
const handleFocus = evt => {
|
|
384
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/
|
|
384
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
385
385
|
evt.target.classList.contains(`${prefix}--tag__close-icon`) ? setIsFocused(false) : setIsFocused(evt.type === 'focus' ? true : false);
|
|
386
386
|
};
|
|
387
387
|
const readOnlyEventHandlers = readOnly ? {
|
|
@@ -407,10 +407,10 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
407
407
|
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
408
408
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
409
409
|
size: 'mini'
|
|
410
|
-
}) :
|
|
410
|
+
}) : candidate;
|
|
411
411
|
const itemsSelectedText = selectedItems.length > 0 && selectedItems.map(item => item?.text);
|
|
412
412
|
const selectedItemsLength = selectAll ?
|
|
413
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
413
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
414
414
|
selectedItems.filter(item => !item.isSelectAll).length : selectedItems.length;
|
|
415
415
|
|
|
416
416
|
// Memoize the value of getMenuProps to avoid an infinite loop
|
|
@@ -431,7 +431,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
431
431
|
totalSelectableCount
|
|
432
432
|
};
|
|
433
433
|
},
|
|
434
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/
|
|
434
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
435
435
|
[selectedItems, filteredItems]);
|
|
436
436
|
return /*#__PURE__*/React.createElement("div", {
|
|
437
437
|
className: wrapperClasses
|
|
@@ -485,7 +485,7 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
485
485
|
})), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
486
486
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
487
487
|
}, normalizedDecorator) : ''), /*#__PURE__*/React.createElement(ListBox.Menu, menuProps, isOpen &&
|
|
488
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/
|
|
488
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
489
489
|
sortItems(filteredItems, sortOptions).map((item, index) => {
|
|
490
490
|
const {
|
|
491
491
|
hasIndividualSelections,
|
|
@@ -493,10 +493,10 @@ const MultiSelect = /*#__PURE__*/React.forwardRef(({
|
|
|
493
493
|
totalSelectableCount
|
|
494
494
|
} = getSelectionStats(selectedItems, filteredItems);
|
|
495
495
|
|
|
496
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
496
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
497
497
|
const isChecked = item.isSelectAll ? nonSelectAllSelectedCount === totalSelectableCount && totalSelectableCount > 0 : selectedItems.some(selected => isEqual(selected, item));
|
|
498
498
|
const isIndeterminate =
|
|
499
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
499
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
500
500
|
item.isSelectAll && hasIndividualSelections && nonSelectAllSelectedCount < totalSelectableCount;
|
|
501
501
|
const itemProps = getItemProps({
|
|
502
502
|
item,
|
|
@@ -700,7 +700,7 @@ MultiSelect.propTypes = {
|
|
|
700
700
|
*/
|
|
701
701
|
titleText: PropTypes.node,
|
|
702
702
|
/**
|
|
703
|
-
*
|
|
703
|
+
* Translates component strings using your i18n tool.
|
|
704
704
|
*/
|
|
705
705
|
translateWithId: PropTypes.func,
|
|
706
706
|
/**
|
|
@@ -807,7 +807,7 @@ Callout.propTypes = {
|
|
|
807
807
|
/**
|
|
808
808
|
* @deprecated Use `CalloutProps` instead.
|
|
809
809
|
*/
|
|
810
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- https://github.com/carbon-design-system/carbon/issues/
|
|
810
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
811
811
|
|
|
812
812
|
let didWarnAboutDeprecation = false;
|
|
813
813
|
const StaticNotification = props => {
|
|
@@ -5,15 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { type ReactNode } from 'react';
|
|
8
|
-
import { TranslateWithId } from '../../types/common';
|
|
8
|
+
import type { TranslateWithId } from '../../types/common';
|
|
9
9
|
import { type NumberFormatOptions } from '@carbon/utilities';
|
|
10
|
-
|
|
10
|
+
declare const translationIds: {
|
|
11
11
|
readonly 'increment.number': "increment.number";
|
|
12
12
|
readonly 'decrement.number': "decrement.number";
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Message ids that will be passed to translateWithId().
|
|
16
|
-
*/
|
|
17
14
|
type TranslationKey = keyof typeof translationIds;
|
|
18
15
|
type ExcludedAttributes = 'defaultValue' | 'id' | 'min' | 'max' | 'onChange' | 'onClick' | 'size' | 'step' | 'value';
|
|
19
16
|
export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes>, TranslateWithId<TranslationKey> {
|
|
@@ -32,17 +32,15 @@ const translationIds = {
|
|
|
32
32
|
'increment.number': 'increment.number',
|
|
33
33
|
'decrement.number': 'decrement.number'
|
|
34
34
|
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Message ids that will be passed to translateWithId().
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
35
|
const defaultTranslations = {
|
|
41
36
|
[translationIds['increment.number']]: 'Increment number',
|
|
42
37
|
[translationIds['decrement.number']]: 'Decrement number'
|
|
43
38
|
};
|
|
39
|
+
const defaultTranslateWithId = messageId => {
|
|
40
|
+
return defaultTranslations[messageId];
|
|
41
|
+
};
|
|
44
42
|
|
|
45
|
-
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/
|
|
43
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
46
44
|
const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
47
45
|
const {
|
|
48
46
|
allowEmpty = false,
|
|
@@ -73,7 +71,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
73
71
|
size = 'md',
|
|
74
72
|
slug,
|
|
75
73
|
step = 1,
|
|
76
|
-
translateWithId: t =
|
|
74
|
+
translateWithId: t = defaultTranslateWithId,
|
|
77
75
|
type = 'number',
|
|
78
76
|
defaultValue = type === 'number' ? 0 : NaN,
|
|
79
77
|
validate,
|
|
@@ -104,7 +102,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
104
102
|
}
|
|
105
103
|
return 0;
|
|
106
104
|
});
|
|
107
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
108
106
|
const [prevControlledValue, setPrevControlledValue] = useState(controlledValue);
|
|
109
107
|
const numberParser = useMemo(() => new NumberParser(locale, formatOptions), [locale, formatOptions]);
|
|
110
108
|
/**
|
|
@@ -237,7 +235,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
237
235
|
[`${prefix}--number-input--fluid--disabled`]: isFluid && disabled
|
|
238
236
|
});
|
|
239
237
|
|
|
240
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
241
239
|
const Icon = normalizedProps.icon;
|
|
242
240
|
const getDecimalPlaces = num => {
|
|
243
241
|
const parts = num.toString().split('.');
|
|
@@ -306,13 +304,10 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
306
304
|
const candidateIsAILabel = isComponentElement(candidate, AILabel);
|
|
307
305
|
const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
|
|
308
306
|
size: 'mini'
|
|
309
|
-
}) :
|
|
307
|
+
}) : candidate;
|
|
310
308
|
|
|
311
309
|
// Need to update the internal value when the revert button is clicked
|
|
312
|
-
|
|
313
|
-
if (normalizedDecorator?.type === AILabel) {
|
|
314
|
-
isRevertActive = normalizedDecorator.props.revertActive;
|
|
315
|
-
}
|
|
310
|
+
const isRevertActive = isComponentElement(normalizedDecorator, AILabel) ? normalizedDecorator.props.revertActive : undefined;
|
|
316
311
|
useEffect(() => {
|
|
317
312
|
if (!isRevertActive && slug && defaultValue) {
|
|
318
313
|
setValue(defaultValue);
|
|
@@ -347,9 +342,9 @@ const NumberInput = /*#__PURE__*/React.forwardRef((props, forwardRef) => {
|
|
|
347
342
|
onKeyUp: onKeyUp,
|
|
348
343
|
onKeyDown: e => {
|
|
349
344
|
if (type === 'text') {
|
|
350
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/
|
|
345
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
351
346
|
match(e, ArrowUp) && handleStep(e, 'up');
|
|
352
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/
|
|
347
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
353
348
|
match(e, ArrowDown) && handleStep(e, 'down');
|
|
354
349
|
}
|
|
355
350
|
if (rest?.onKeyDown) {
|
|
@@ -597,7 +592,7 @@ NumberInput.propTypes = {
|
|
|
597
592
|
*/
|
|
598
593
|
step: PropTypes.number,
|
|
599
594
|
/**
|
|
600
|
-
*
|
|
595
|
+
* Translates component strings using your i18n tool.
|
|
601
596
|
*/
|
|
602
597
|
translateWithId: PropTypes.func,
|
|
603
598
|
/**
|
|
@@ -731,4 +726,4 @@ function disableWheel(e) {
|
|
|
731
726
|
e.preventDefault();
|
|
732
727
|
}
|
|
733
728
|
|
|
734
|
-
export { NumberInput
|
|
729
|
+
export { NumberInput };
|
|
@@ -102,9 +102,9 @@ export interface OverflowMenuProps extends Omit<IconButtonProps, 'type' | 'aria-
|
|
|
102
102
|
*/
|
|
103
103
|
selectorPrimaryFocus?: string;
|
|
104
104
|
/**
|
|
105
|
-
* Specify the size of the OverflowMenu. Currently supports either `sm`, `md` (default) or `lg` as an option.
|
|
105
|
+
* Specify the size of the OverflowMenu. Currently supports either `xs`, `sm`, `md` (default) or `lg` as an option.
|
|
106
106
|
*/
|
|
107
|
-
size?: 'sm' | 'md' | 'lg';
|
|
107
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
108
108
|
/**
|
|
109
109
|
* The ref to the overflow menu's trigger button element.
|
|
110
110
|
* @deprecated Use the standard React `ref` prop instead.
|
|
@@ -66,7 +66,7 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
66
66
|
if (process.env.NODE_ENV !== 'production') {
|
|
67
67
|
!(triggerButtonPositionProp && triggerButtonPositionFactor) ? process.env.NODE_ENV !== "production" ? invariant(false, '[OverflowMenu] wrong floating menu direction: `%s`', direction) : invariant(false) : void 0;
|
|
68
68
|
}
|
|
69
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
70
70
|
const {
|
|
71
71
|
offsetWidth: menuWidth,
|
|
72
72
|
offsetHeight: menuHeight
|
|
@@ -89,7 +89,7 @@ const getMenuOffset = (menuBody, direction, trigger, flip) => {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/
|
|
92
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
93
93
|
const OverflowMenu = /*#__PURE__*/forwardRef(({
|
|
94
94
|
align,
|
|
95
95
|
['aria-label']: ariaLabel = null,
|
|
@@ -463,9 +463,9 @@ OverflowMenu.propTypes = {
|
|
|
463
463
|
*/
|
|
464
464
|
selectorPrimaryFocus: PropTypes.string,
|
|
465
465
|
/**
|
|
466
|
-
* Specify the size of the OverflowMenu. Currently supports either `sm`, `md` (default) or `lg` as an option.
|
|
466
|
+
* Specify the size of the OverflowMenu. Currently supports either `xs`, `sm`, `md` (default) or `lg` as an option.
|
|
467
467
|
*/
|
|
468
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg'])
|
|
468
|
+
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg'])
|
|
469
469
|
};
|
|
470
470
|
|
|
471
471
|
export { OverflowMenu, OverflowMenu as default, getMenuOffset };
|
|
@@ -23,7 +23,7 @@ import { deprecateValuesWithin } from '../../../prop-types/deprecateValuesWithin
|
|
|
23
23
|
import { mapPopoverAlign } from '../../../tools/mapPopoverAlign.js';
|
|
24
24
|
|
|
25
25
|
const defaultSize = 'md';
|
|
26
|
-
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/
|
|
26
|
+
// eslint-disable-next-line react/display-name -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
27
27
|
const OverflowMenu = /*#__PURE__*/React.forwardRef(({
|
|
28
28
|
autoAlign = false,
|
|
29
29
|
children,
|
|
@@ -162,7 +162,7 @@ OverflowMenu.propTypes = {
|
|
|
162
162
|
/**
|
|
163
163
|
* Specify the size of the menu, from a list of available sizes.
|
|
164
164
|
*/
|
|
165
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
165
|
+
size: PropTypes.oneOf(['xs', 'sm', 'md', 'lg']),
|
|
166
166
|
/**
|
|
167
167
|
* Specify how the trigger tooltip should be aligned.
|
|
168
168
|
*/
|
|
@@ -89,14 +89,14 @@ const OverflowMenuItem = frFn((props, ref) => {
|
|
|
89
89
|
// ref as any: the type of `ref` is `ForwardedRef<HTMLButtonElement>` in `Button` component
|
|
90
90
|
// but `OverflowMenuItem` can be rendered as `a` tag as well, which is `HTMLAnchorElement`
|
|
91
91
|
// so we have to use `any` here
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
93
93
|
,
|
|
94
94
|
ref: ref,
|
|
95
95
|
tabIndex: -1
|
|
96
96
|
// itemText as any: itemText may be a ReactNode, but `title` only accepts string
|
|
97
97
|
// to avoid compatibility issue, we use `any` here. Consider to enforce `itemText` to be `string?`
|
|
98
98
|
// in the next major release
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
100
100
|
,
|
|
101
101
|
title: requireTitle ? title || itemText : undefined
|
|
102
102
|
}, rest), OverflowMenuItemContent));
|