@carbon/react 1.81.0-rc.0 → 1.82.0-rc.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 +784 -784
- package/es/components/AILabel/index.d.ts +1 -1
- package/es/components/AILabel/index.js +2 -9
- package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -3
- package/es/components/Breadcrumb/Breadcrumb.js +4 -4
- package/es/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
- package/es/components/Breadcrumb/BreadcrumbItem.js +5 -4
- package/es/components/Button/Button.js +2 -10
- package/es/components/ButtonSet/ButtonSet.d.ts +2 -3
- package/es/components/ButtonSet/ButtonSet.js +4 -4
- package/es/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/es/components/CodeSnippet/CodeSnippet.js +3 -19
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +54 -32
- package/es/components/ComboButton/index.d.ts +1 -1
- package/es/components/ComboButton/index.js +2 -18
- package/es/components/ComposedModal/ComposedModal.js +5 -3
- package/es/components/Copy/Copy.d.ts +1 -1
- package/es/components/Copy/Copy.js +2 -18
- package/es/components/CopyButton/CopyButton.d.ts +1 -1
- package/es/components/CopyButton/CopyButton.js +2 -18
- package/es/components/DataTable/DataTable.d.ts +7 -12
- package/es/components/DataTable/DataTable.js +0 -5
- package/es/components/DataTable/TableCell.js +28 -4
- package/es/components/DataTable/TableToolbarAction.d.ts +2 -4
- package/es/components/DataTable/TableToolbarAction.js +5 -4
- package/es/components/DataTable/tools/cells.d.ts +13 -0
- package/es/components/DataTable/tools/cells.js +3 -6
- package/es/components/DataTable/tools/filter.d.ts +26 -0
- package/es/components/DataTable/tools/filter.js +8 -17
- package/es/components/DataTable/tools/sorting.d.ts +42 -0
- package/es/components/DataTable/tools/sorting.js +24 -53
- package/es/components/DatePicker/DatePicker.d.ts +1 -1
- package/es/components/DatePicker/DatePicker.js +19 -19
- package/es/components/Dialog/index.d.ts +1 -1
- package/es/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
- package/es/components/Dropdown/Dropdown.Skeleton.js +2 -2
- package/es/components/Dropdown/Dropdown.d.ts +7 -6
- package/es/components/Dropdown/Dropdown.js +13 -9
- package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +1 -1
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
- package/es/components/FluidDatePickerInput/FluidDatePickerInput.js +5 -6
- package/es/components/FluidDropdown/FluidDropdown.d.ts +1 -1
- package/es/components/FluidSearch/FluidSearch.d.ts +3 -6
- package/es/components/IconButton/index.d.ts +1 -1
- package/es/components/IconButton/index.js +2 -18
- package/es/components/ListBox/ListBox.d.ts +4 -5
- package/es/components/ListBox/ListBox.js +8 -7
- package/es/components/ListBox/ListBoxMenu.d.ts +4 -4
- package/es/components/ListBox/ListBoxMenu.js +4 -2
- package/es/components/ListBox/ListBoxMenuItem.d.ts +9 -8
- package/es/components/ListBox/ListBoxPropTypes.d.ts +3 -3
- package/es/components/ListBox/ListBoxPropTypes.js +3 -3
- package/es/components/ListBox/index.d.ts +7 -5
- package/es/components/ListBox/index.js +1 -1
- package/es/components/Menu/Menu.js +9 -14
- package/es/components/Menu/MenuItem.js +15 -4
- package/es/components/Modal/Modal.js +9 -9
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
- package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
- package/es/components/MultiSelect/MultiSelect.d.ts +8 -2
- package/es/components/MultiSelect/MultiSelect.js +7 -4
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +2 -21
- package/es/components/OverflowMenu/index.d.ts +1 -1
- package/es/components/OverflowMenu/index.js +2 -3
- package/es/components/OverflowMenu/next/index.js +2 -18
- package/es/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +5 -4
- package/es/components/PageHeader/PageHeader.d.ts +160 -8
- package/es/components/PageHeader/PageHeader.js +155 -21
- package/es/components/PageHeader/index.d.ts +2 -2
- package/es/components/PageHeader/index.js +1 -1
- package/es/components/Popover/index.js +4 -21
- package/es/components/Search/Search.d.ts +2 -5
- package/es/components/Search/Search.js +24 -8
- package/es/components/Stack/HStack.d.ts +2 -3
- package/es/components/Stack/HStack.js +4 -7
- package/es/components/Stack/Stack.d.ts +3 -4
- package/es/components/Stack/Stack.js +3 -6
- package/es/components/Stack/VStack.d.ts +2 -3
- package/es/components/Stack/VStack.js +3 -2
- package/es/components/Stack/index.d.ts +4 -4
- package/es/components/TextArea/TextArea.js +3 -5
- package/es/components/TimePicker/TimePicker.d.ts +3 -4
- package/es/components/TimePicker/TimePicker.js +5 -4
- package/es/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
- package/es/components/TimePickerSelect/TimePickerSelect.js +5 -4
- package/es/components/TreeView/TreeNode.js +13 -1
- package/es/components/TreeView/TreeView.js +1 -1
- package/es/index.js +1 -1
- package/es/internal/FloatingMenu.js +9 -5
- package/es/internal/environment.js +7 -0
- package/es/internal/keyboard/navigation.d.ts +0 -10
- package/es/internal/keyboard/navigation.js +1 -13
- package/es/internal/useId.js +1 -1
- package/es/internal/useNoInteractiveChildren.js +7 -0
- package/es/internal/useOutsideClick.js +3 -0
- package/es/internal/wrapFocus.d.ts +49 -0
- package/es/internal/wrapFocus.js +64 -51
- package/es/tools/events.d.ts +17 -0
- package/es/tools/events.js +10 -13
- package/es/tools/mapPopoverAlign.d.ts +15 -0
- package/es/tools/mapPopoverAlign.js +28 -0
- package/es/tools/uniqueId.d.ts +7 -0
- package/es/tools/uniqueId.js +3 -3
- package/es/types/common.d.ts +0 -2
- package/lib/components/AILabel/index.d.ts +1 -1
- package/lib/components/AILabel/index.js +2 -9
- package/lib/components/Breadcrumb/Breadcrumb.d.ts +2 -3
- package/lib/components/Breadcrumb/Breadcrumb.js +3 -3
- package/lib/components/Breadcrumb/BreadcrumbItem.d.ts +3 -4
- package/lib/components/Breadcrumb/BreadcrumbItem.js +4 -3
- package/lib/components/Button/Button.js +1 -9
- package/lib/components/ButtonSet/ButtonSet.d.ts +2 -3
- package/lib/components/ButtonSet/ButtonSet.js +3 -3
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.js +3 -19
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +53 -31
- package/lib/components/ComboButton/index.d.ts +1 -1
- package/lib/components/ComboButton/index.js +2 -18
- package/lib/components/ComposedModal/ComposedModal.js +5 -3
- package/lib/components/Copy/Copy.d.ts +1 -1
- package/lib/components/Copy/Copy.js +2 -18
- package/lib/components/CopyButton/CopyButton.d.ts +1 -1
- package/lib/components/CopyButton/CopyButton.js +2 -18
- package/lib/components/DataTable/DataTable.d.ts +7 -12
- package/lib/components/DataTable/DataTable.js +0 -5
- package/lib/components/DataTable/TableCell.js +28 -3
- package/lib/components/DataTable/TableToolbarAction.d.ts +2 -4
- package/lib/components/DataTable/TableToolbarAction.js +4 -3
- package/lib/components/DataTable/tools/cells.d.ts +13 -0
- package/lib/components/DataTable/tools/cells.js +3 -6
- package/lib/components/DataTable/tools/filter.d.ts +26 -0
- package/lib/components/DataTable/tools/filter.js +8 -17
- package/lib/components/DataTable/tools/sorting.d.ts +42 -0
- package/lib/components/DataTable/tools/sorting.js +23 -53
- package/lib/components/DatePicker/DatePicker.d.ts +1 -1
- package/lib/components/DatePicker/DatePicker.js +19 -19
- package/lib/components/Dialog/index.d.ts +1 -1
- package/lib/components/Dropdown/Dropdown.Skeleton.d.ts +2 -2
- package/lib/components/Dropdown/Dropdown.Skeleton.js +1 -1
- package/lib/components/Dropdown/Dropdown.d.ts +7 -6
- package/lib/components/Dropdown/Dropdown.js +12 -8
- package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +1 -1
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.d.ts +1 -1
- package/lib/components/FluidDatePickerInput/FluidDatePickerInput.js +4 -5
- package/lib/components/FluidDropdown/FluidDropdown.d.ts +1 -1
- package/lib/components/FluidSearch/FluidSearch.d.ts +3 -6
- package/lib/components/IconButton/index.d.ts +1 -1
- package/lib/components/IconButton/index.js +2 -18
- package/lib/components/ListBox/ListBox.d.ts +4 -5
- package/lib/components/ListBox/ListBox.js +7 -6
- package/lib/components/ListBox/ListBoxMenu.d.ts +4 -4
- package/lib/components/ListBox/ListBoxMenu.js +3 -1
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +9 -8
- package/lib/components/ListBox/ListBoxPropTypes.d.ts +3 -3
- package/lib/components/ListBox/ListBoxPropTypes.js +4 -4
- package/lib/components/ListBox/index.d.ts +7 -5
- package/lib/components/ListBox/index.js +2 -2
- package/lib/components/Menu/Menu.js +9 -14
- package/lib/components/Menu/MenuItem.js +15 -4
- package/lib/components/Modal/Modal.js +9 -9
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +3 -2
- package/lib/components/MultiSelect/FilterableMultiSelect.js +2 -1
- package/lib/components/MultiSelect/MultiSelect.d.ts +8 -2
- package/lib/components/MultiSelect/MultiSelect.js +6 -3
- package/lib/components/Notification/Notification.js +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -21
- package/lib/components/OverflowMenu/index.d.ts +1 -1
- package/lib/components/OverflowMenu/index.js +2 -3
- package/lib/components/OverflowMenu/next/index.js +2 -18
- package/lib/components/OverflowMenuItem/OverflowMenuItem.d.ts +2 -4
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +4 -3
- package/lib/components/PageHeader/PageHeader.d.ts +160 -8
- package/lib/components/PageHeader/PageHeader.js +159 -19
- package/lib/components/PageHeader/index.d.ts +2 -2
- package/lib/components/PageHeader/index.js +6 -0
- package/lib/components/Popover/index.js +4 -21
- package/lib/components/Search/Search.d.ts +2 -5
- package/lib/components/Search/Search.js +24 -8
- package/lib/components/Stack/HStack.d.ts +2 -3
- package/lib/components/Stack/HStack.js +3 -6
- package/lib/components/Stack/Stack.d.ts +3 -4
- package/lib/components/Stack/Stack.js +2 -5
- package/lib/components/Stack/VStack.d.ts +2 -3
- package/lib/components/Stack/VStack.js +2 -1
- package/lib/components/Stack/index.d.ts +4 -4
- package/lib/components/TextArea/TextArea.js +2 -4
- package/lib/components/TimePicker/TimePicker.d.ts +3 -4
- package/lib/components/TimePicker/TimePicker.js +4 -3
- package/lib/components/TimePickerSelect/TimePickerSelect.d.ts +23 -4
- package/lib/components/TimePickerSelect/TimePickerSelect.js +4 -3
- package/lib/components/TreeView/TreeNode.js +13 -1
- package/lib/components/TreeView/TreeView.js +1 -1
- package/lib/index.js +2 -2
- package/lib/internal/FloatingMenu.js +9 -5
- package/lib/internal/environment.js +7 -0
- package/lib/internal/keyboard/navigation.d.ts +0 -10
- package/lib/internal/keyboard/navigation.js +0 -14
- package/lib/internal/useNoInteractiveChildren.js +7 -0
- package/lib/internal/useOutsideClick.js +3 -0
- package/lib/internal/wrapFocus.d.ts +49 -0
- package/lib/internal/wrapFocus.js +66 -53
- package/lib/tools/events.d.ts +17 -0
- package/lib/tools/events.js +10 -13
- package/lib/tools/mapPopoverAlign.d.ts +15 -0
- package/lib/tools/mapPopoverAlign.js +32 -0
- package/lib/tools/uniqueId.d.ts +7 -0
- package/lib/tools/uniqueId.js +3 -3
- package/lib/types/common.d.ts +0 -2
- package/package.json +9 -9
- package/telemetry.yml +3 -1
- package/es/tools/createPropAdapter.js +0 -40
- package/lib/tools/createPropAdapter.js +0 -44
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React, { ReactNode } from 'react';
|
|
7
|
+
import React, { ReactNode, Ref } from 'react';
|
|
8
8
|
import { UseSelectProps } from 'downshift';
|
|
9
|
-
import { type ListBoxMenuIconTranslationKey, ListBoxSize, ListBoxType } from '../ListBox';
|
|
9
|
+
import { type ListBoxMenuIconTranslationKey, type ListBoxSize, type ListBoxType } from '../ListBox';
|
|
10
10
|
import { TranslateWithId, ReactAttr } from '../../types/common';
|
|
11
11
|
type ExcludedAttributes = 'id' | 'onChange';
|
|
12
12
|
export interface OnChangeData<ItemType> {
|
|
13
13
|
selectedItem: ItemType | null;
|
|
14
14
|
}
|
|
15
|
-
export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey
|
|
15
|
+
export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes>, TranslateWithId<ListBoxMenuIconTranslationKey> {
|
|
16
16
|
/**
|
|
17
17
|
* Specify a label to be read by screen readers on the container node
|
|
18
18
|
* 'aria-label' of the ListBox component.
|
|
@@ -147,9 +147,10 @@ export interface DropdownProps<ItemType> extends Omit<ReactAttr<HTMLDivElement>,
|
|
|
147
147
|
warnText?: ReactNode;
|
|
148
148
|
}
|
|
149
149
|
export type DropdownTranslationKey = ListBoxMenuIconTranslationKey;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
interface DropdownComponent {
|
|
151
|
+
<ItemType>(props: DropdownProps<ItemType> & {
|
|
152
|
+
ref?: Ref<HTMLButtonElement>;
|
|
153
|
+
}): React.ReactElement<any> | null;
|
|
153
154
|
}
|
|
154
155
|
declare const _default: DropdownComponent;
|
|
155
156
|
export default _default;
|
|
@@ -20,7 +20,7 @@ import { FormContext } from '../FluidForm/FormContext.js';
|
|
|
20
20
|
import { useId } from '../../internal/useId.js';
|
|
21
21
|
import { useFloating, size, flip, hide, autoUpdate } from '@floating-ui/react';
|
|
22
22
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
23
|
-
import {
|
|
23
|
+
import { ListBoxSizePropType, ListBoxTypePropType } from '../ListBox/ListBoxPropTypes.js';
|
|
24
24
|
|
|
25
25
|
const {
|
|
26
26
|
ItemMouseMove,
|
|
@@ -246,9 +246,9 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
246
246
|
|
|
247
247
|
// needs to be Capitalized for react to render it correctly
|
|
248
248
|
const ItemToElement = itemToElement;
|
|
249
|
-
const toggleButtonProps =
|
|
249
|
+
const toggleButtonProps = getToggleButtonProps({
|
|
250
250
|
'aria-label': ariaLabel || deprecatedAriaLabel
|
|
251
|
-
})
|
|
251
|
+
});
|
|
252
252
|
const helper = helperText && !isFluid ? /*#__PURE__*/React__default.createElement("div", {
|
|
253
253
|
id: helperId,
|
|
254
254
|
className: helperClasses
|
|
@@ -320,7 +320,10 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
320
320
|
}
|
|
321
321
|
return /*#__PURE__*/React__default.isValidElement(element) ? element : null;
|
|
322
322
|
}, [slug, decorator]);
|
|
323
|
-
const
|
|
323
|
+
const allLabelProps = getLabelProps();
|
|
324
|
+
const labelProps = /*#__PURE__*/isValidElement(titleText) ? {
|
|
325
|
+
id: allLabelProps.id
|
|
326
|
+
} : allLabelProps;
|
|
324
327
|
return /*#__PURE__*/React__default.createElement("div", _extends({
|
|
325
328
|
className: wrapperClasses
|
|
326
329
|
}, other), titleText && /*#__PURE__*/React__default.createElement("label", _extends({
|
|
@@ -367,9 +370,6 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
367
370
|
item,
|
|
368
371
|
index
|
|
369
372
|
});
|
|
370
|
-
if (item !== null && typeof item === 'object' && Object.prototype.hasOwnProperty.call(item, 'id')) {
|
|
371
|
-
itemProps.id = item['id'];
|
|
372
|
-
}
|
|
373
373
|
const title = isObject && 'text' in item && itemToElement ? item.text : itemToString(item);
|
|
374
374
|
return /*#__PURE__*/React__default.createElement(ListBox.MenuItem, _extends({
|
|
375
375
|
key: itemProps.id,
|
|
@@ -384,6 +384,10 @@ const Dropdown = /*#__PURE__*/React__default.forwardRef((_ref, ref) => {
|
|
|
384
384
|
}));
|
|
385
385
|
}))), !inline && !invalid && !warn && helper);
|
|
386
386
|
});
|
|
387
|
+
|
|
388
|
+
// Workaround problems with forwardRef() and generics. In the long term, should stop using forwardRef().
|
|
389
|
+
// See https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref.
|
|
390
|
+
|
|
387
391
|
Dropdown.displayName = 'Dropdown';
|
|
388
392
|
Dropdown.propTypes = {
|
|
389
393
|
/**
|
|
@@ -497,7 +501,7 @@ Dropdown.propTypes = {
|
|
|
497
501
|
/**
|
|
498
502
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
499
503
|
*/
|
|
500
|
-
size:
|
|
504
|
+
size: ListBoxSizePropType,
|
|
501
505
|
/**
|
|
502
506
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `Dropdown` component
|
|
503
507
|
*/
|
|
@@ -514,7 +518,7 @@ Dropdown.propTypes = {
|
|
|
514
518
|
/**
|
|
515
519
|
* The dropdown type, `default` or `inline`
|
|
516
520
|
*/
|
|
517
|
-
type:
|
|
521
|
+
type: ListBoxTypePropType,
|
|
518
522
|
/**
|
|
519
523
|
* Specify whether the control is currently in warning state
|
|
520
524
|
*/
|
|
@@ -12,7 +12,7 @@ import React__default, { useState, useRef } from 'react';
|
|
|
12
12
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
13
13
|
import { matches } from '../../internal/keyboard/match.js';
|
|
14
14
|
import { ButtonKinds } from '../../prop-types/types.js';
|
|
15
|
-
import uniqueId from '../../tools/uniqueId.js';
|
|
15
|
+
import { uniqueId } from '../../tools/uniqueId.js';
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import deprecate from '../../prop-types/deprecate.js';
|
|
18
18
|
import { noopFn } from '../../internal/noopFn.js';
|
|
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
13
13
|
import { matches } from '../../internal/keyboard/match.js';
|
|
14
|
-
import uniqueId from '../../tools/uniqueId.js';
|
|
14
|
+
import { uniqueId } from '../../tools/uniqueId.js';
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
16
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
17
17
|
import deprecate from '../../prop-types/deprecate.js';
|
|
@@ -12,7 +12,7 @@ import React__default, { useRef, useState, useLayoutEffect } from 'react';
|
|
|
12
12
|
import Filename from './Filename.js';
|
|
13
13
|
import { Enter, Space } from '../../internal/keyboard/keys.js';
|
|
14
14
|
import { matches } from '../../internal/keyboard/match.js';
|
|
15
|
-
import uniqueId from '../../tools/uniqueId.js';
|
|
15
|
+
import { uniqueId } from '../../tools/uniqueId.js';
|
|
16
16
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
17
|
import { noopFn } from '../../internal/noopFn.js';
|
|
18
18
|
import '../Text/index.js';
|
|
@@ -6,21 +6,20 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { forwardRef } from 'react';
|
|
10
10
|
import DatePickerInput from '../DatePickerInput/DatePickerInput.js';
|
|
11
11
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
12
12
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
...other
|
|
16
|
-
} = _ref;
|
|
13
|
+
const frFn = forwardRef;
|
|
14
|
+
const FluidDatePickerInput = frFn((props, ref) => {
|
|
17
15
|
return /*#__PURE__*/React__default.createElement(FormContext.Provider, {
|
|
18
16
|
value: {
|
|
19
17
|
isFluid: true
|
|
20
18
|
}
|
|
21
19
|
}, /*#__PURE__*/React__default.createElement(DatePickerInput, _extends({
|
|
22
20
|
ref: ref
|
|
23
|
-
},
|
|
21
|
+
}, props)));
|
|
24
22
|
});
|
|
23
|
+
FluidDatePickerInput.propTypes = DatePickerInput.propTypes;
|
|
25
24
|
|
|
26
25
|
export { FluidDatePickerInput as default };
|
|
@@ -97,5 +97,5 @@ export interface FluidDropdownProps<ItemType> extends DropdownProps<ItemType> {
|
|
|
97
97
|
*/
|
|
98
98
|
warnText?: React.ReactNode;
|
|
99
99
|
}
|
|
100
|
-
declare const FluidDropdown: React.ForwardRefExoticComponent<
|
|
100
|
+
declare const FluidDropdown: React.ForwardRefExoticComponent<FluidDropdownProps<unknown> & React.RefAttributes<HTMLButtonElement>>;
|
|
101
101
|
export default FluidDropdown;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2022
|
|
2
|
+
* Copyright IBM Corp. 2022, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import React from 'react';
|
|
7
|
+
import React, { type ChangeEvent } from 'react';
|
|
8
8
|
export interface FluidSearchProps {
|
|
9
9
|
/**
|
|
10
10
|
* Specify an optional value for the `autocomplete` property on the underlying
|
|
@@ -38,10 +38,7 @@ export interface FluidSearchProps {
|
|
|
38
38
|
/**
|
|
39
39
|
* Optional callback called when the search value changes.
|
|
40
40
|
*/
|
|
41
|
-
onChange?(
|
|
42
|
-
target: HTMLInputElement;
|
|
43
|
-
type: 'change';
|
|
44
|
-
}): void;
|
|
41
|
+
onChange?(event: ChangeEvent<HTMLInputElement>): void;
|
|
45
42
|
/**
|
|
46
43
|
* Optional callback called when the search value is cleared.
|
|
47
44
|
*/
|
|
@@ -16,21 +16,9 @@ import { usePrefix } from '../../internal/usePrefix.js';
|
|
|
16
16
|
import ButtonBase from '../Button/ButtonBase.js';
|
|
17
17
|
import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
|
|
18
18
|
import { BadgeIndicator } from '../BadgeIndicator/index.js';
|
|
19
|
+
import { mapPopoverAlign } from '../../tools/mapPopoverAlign.js';
|
|
19
20
|
|
|
20
21
|
const IconButtonKinds = ['primary', 'secondary', 'ghost', 'tertiary'];
|
|
21
|
-
const propMappingFunction = deprecatedValue => {
|
|
22
|
-
const mapping = {
|
|
23
|
-
'top-left': 'top-start',
|
|
24
|
-
'top-right': 'top-end',
|
|
25
|
-
'bottom-left': 'bottom-start',
|
|
26
|
-
'bottom-right': 'bottom-end',
|
|
27
|
-
'left-bottom': 'left-end',
|
|
28
|
-
'left-top': 'left-start',
|
|
29
|
-
'right-bottom': 'right-end',
|
|
30
|
-
'right-top': 'right-start'
|
|
31
|
-
};
|
|
32
|
-
return mapping[deprecatedValue];
|
|
33
|
-
};
|
|
34
22
|
const IconButton = /*#__PURE__*/React__default.forwardRef(function IconButton(_ref, ref) {
|
|
35
23
|
let {
|
|
36
24
|
align,
|
|
@@ -110,11 +98,7 @@ IconButton.propTypes = {
|
|
|
110
98
|
// deprecated use right-start instead
|
|
111
99
|
|
|
112
100
|
// new values to match floating-ui
|
|
113
|
-
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
|
|
114
|
-
//allowed prop values
|
|
115
|
-
['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'],
|
|
116
|
-
//optional mapper function
|
|
117
|
-
propMappingFunction),
|
|
101
|
+
'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']), ['top', 'top-start', 'top-end', 'bottom', 'bottom-start', 'bottom-end', 'left', 'left-start', 'left-end', 'right', 'right-start', 'right-end'], mapPopoverAlign),
|
|
118
102
|
/**
|
|
119
103
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
120
104
|
*/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React from 'react';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { type ListBoxSize, type ListBoxType } from '.';
|
|
9
|
+
import { ReactAttr } from '../../types/common';
|
|
10
10
|
type ExcludedAttributes = 'onKeyDown' | 'onKeyPress' | 'ref';
|
|
11
11
|
export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAttributes> {
|
|
12
12
|
/**
|
|
@@ -59,10 +59,9 @@ export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAt
|
|
|
59
59
|
*/
|
|
60
60
|
warnTextId?: string;
|
|
61
61
|
}
|
|
62
|
-
export type ListBoxComponent = ForwardRefReturn<HTMLDivElement, ListBoxProps>;
|
|
63
62
|
/**
|
|
64
63
|
* `ListBox` is a generic container component that handles creating the
|
|
65
64
|
* container class name in response to certain props.
|
|
66
65
|
*/
|
|
67
|
-
declare const ListBox:
|
|
66
|
+
declare const ListBox: React.ForwardRefExoticComponent<ListBoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
68
67
|
export default ListBox;
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
|
-
import React__default, { useContext } from 'react';
|
|
10
|
+
import React__default, { forwardRef, useContext } from 'react';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import deprecate from '../../prop-types/deprecate.js';
|
|
13
|
-
import
|
|
13
|
+
import './index.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import '../FluidForm/FluidForm.js';
|
|
16
16
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
17
|
+
import { ListBoxSizePropType, ListBoxTypePropType } from './ListBoxPropTypes.js';
|
|
17
18
|
|
|
18
19
|
const handleOnKeyDown = event => {
|
|
19
20
|
if (event.keyCode === 27) {
|
|
@@ -28,8 +29,8 @@ const handleClick = event => {
|
|
|
28
29
|
* `ListBox` is a generic container component that handles creating the
|
|
29
30
|
* container class name in response to certain props.
|
|
30
31
|
*/
|
|
31
|
-
const ListBox = /*#__PURE__*/
|
|
32
|
-
|
|
32
|
+
const ListBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
33
|
+
const {
|
|
33
34
|
children,
|
|
34
35
|
className: containerClassName,
|
|
35
36
|
disabled = false,
|
|
@@ -44,7 +45,7 @@ const ListBox = /*#__PURE__*/React__default.forwardRef(function ListBox(_ref, re
|
|
|
44
45
|
light,
|
|
45
46
|
isOpen,
|
|
46
47
|
...rest
|
|
47
|
-
} =
|
|
48
|
+
} = props;
|
|
48
49
|
const prefix = usePrefix();
|
|
49
50
|
const {
|
|
50
51
|
isFluid
|
|
@@ -117,12 +118,12 @@ ListBox.propTypes = {
|
|
|
117
118
|
/**
|
|
118
119
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
119
120
|
*/
|
|
120
|
-
size:
|
|
121
|
+
size: ListBoxSizePropType,
|
|
121
122
|
/**
|
|
122
123
|
* Specify the "type" of the ListBox. Currently supports either `default` or
|
|
123
124
|
* `inline` as an option.
|
|
124
125
|
*/
|
|
125
|
-
type:
|
|
126
|
+
type: ListBoxTypePropType,
|
|
126
127
|
/**
|
|
127
128
|
* Specify whether the control is currently in warning state
|
|
128
129
|
*/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ReactAttr } from '../../types/common';
|
|
8
9
|
type ExcludedAttributes = 'id';
|
|
9
10
|
export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, ExcludedAttributes> {
|
|
10
11
|
children?: any;
|
|
@@ -13,11 +14,10 @@ export interface ListBoxMenuProps extends Omit<ReactAttr<HTMLUListElement>, Excl
|
|
|
13
14
|
*/
|
|
14
15
|
id: string;
|
|
15
16
|
}
|
|
16
|
-
export type ListBoxMenuComponent = ForwardRefReturn<HTMLUListElement, ListBoxMenuProps>;
|
|
17
17
|
/**
|
|
18
18
|
* `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
|
|
19
19
|
* class into a single component. It is also being used to validate given
|
|
20
20
|
* `children` components.
|
|
21
21
|
*/
|
|
22
|
-
declare const ListBoxMenu:
|
|
22
|
+
declare const ListBoxMenu: React.ForwardRefExoticComponent<ListBoxMenuProps & React.RefAttributes<HTMLUListElement>>;
|
|
23
23
|
export default ListBoxMenu;
|
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { forwardRef } from 'react';
|
|
10
10
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import ListBoxMenuItem from './ListBoxMenuItem.js';
|
|
13
13
|
|
|
14
|
+
const frFn = forwardRef;
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* `ListBoxMenu` is a simple container node that isolates the `list-box__menu`
|
|
16
18
|
* class into a single component. It is also being used to validate given
|
|
17
19
|
* `children` components.
|
|
18
20
|
*/
|
|
19
|
-
const ListBoxMenu =
|
|
21
|
+
const ListBoxMenu = frFn((_ref, ref) => {
|
|
20
22
|
let {
|
|
21
23
|
children,
|
|
22
24
|
id,
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import React, { ReactNode } from 'react';
|
|
8
|
+
import { ReactAttr } from '../../types/common';
|
|
9
9
|
export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
10
10
|
/**
|
|
11
11
|
* Specify any children nodes that should be rendered inside of the ListBox
|
|
@@ -29,9 +29,10 @@ export interface ListBoxMenuItemProps extends ReactAttr<HTMLLIElement> {
|
|
|
29
29
|
*/
|
|
30
30
|
title?: string;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
/**
|
|
33
|
+
* `ListBoxMenuItem` is a helper component for managing the container class
|
|
34
|
+
* name, alongside any classes for any corresponding states, for a generic list
|
|
35
|
+
* box menu item.
|
|
36
|
+
*/
|
|
37
|
+
declare const ListBoxMenuItem: React.ForwardRefExoticComponent<ListBoxMenuItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
38
|
+
export default ListBoxMenuItem;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -9,6 +9,6 @@ declare const listBoxTypes: readonly ["default", "inline"];
|
|
|
9
9
|
declare const listBoxSizes: readonly ["sm", "md", "lg"];
|
|
10
10
|
export type ListBoxType = (typeof listBoxTypes)[number];
|
|
11
11
|
export type ListBoxSize = (typeof listBoxSizes)[number];
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
12
|
+
export declare const ListBoxTypePropType: PropTypes.Requireable<"default" | "inline">;
|
|
13
|
+
export declare const ListBoxSizePropType: PropTypes.Requireable<"sm" | "md" | "lg">;
|
|
14
14
|
export {};
|
|
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
|
|
|
9
9
|
|
|
10
10
|
const listBoxTypes = ['default', 'inline'];
|
|
11
11
|
const listBoxSizes = ['sm', 'md', 'lg'];
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const ListBoxTypePropType = PropTypes.oneOf(listBoxTypes);
|
|
13
|
+
const ListBoxSizePropType = PropTypes.oneOf(listBoxSizes);
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export { ListBoxSizePropType, ListBoxTypePropType };
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
export * as PropTypes from './ListBoxPropTypes';
|
|
8
7
|
export * from './ListBoxPropTypes';
|
|
9
|
-
import
|
|
8
|
+
import ListBoxInternal from './ListBox';
|
|
10
9
|
import { ListBoxFieldComponent } from './ListBoxField';
|
|
11
|
-
import
|
|
10
|
+
import ListBoxMenu from './ListBoxMenu';
|
|
12
11
|
import { ListBoxMenuIconComponent } from './ListBoxMenuIcon';
|
|
13
|
-
import
|
|
12
|
+
import ListBoxMenuItem from './ListBoxMenuItem';
|
|
14
13
|
import { ListBoxSelectionComponent } from './ListBoxSelection';
|
|
14
|
+
type ListBoxMenuComponent = typeof ListBoxMenu;
|
|
15
|
+
type ListBoxMenuItemComponent = typeof ListBoxMenuItem;
|
|
16
|
+
type ListBoxPartialComponent = typeof ListBoxInternal;
|
|
15
17
|
export interface ListBoxComponent extends ListBoxPartialComponent {
|
|
16
18
|
readonly Field: ListBoxFieldComponent;
|
|
17
19
|
readonly Menu: ListBoxMenuComponent;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export { ListBoxSizePropType, ListBoxTypePropType } from './ListBoxPropTypes.js';
|
|
9
9
|
import ListBox$1 from './ListBox.js';
|
|
10
10
|
import ListBoxField from './ListBoxField.js';
|
|
11
11
|
import ListBoxMenu from './ListBoxMenu.js';
|
|
@@ -34,7 +34,12 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
34
34
|
open,
|
|
35
35
|
size = 'sm',
|
|
36
36
|
legacyAutoalign = 'true',
|
|
37
|
+
// TODO: `ssr-friendly` doesn't support ESLint v9.
|
|
38
|
+
// https://github.com/kopiro/eslint-plugin-ssr-friendly/issues/30
|
|
39
|
+
// https://github.com/carbon-design-system/carbon/issues/18991
|
|
40
|
+
/*
|
|
37
41
|
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
|
|
42
|
+
*/
|
|
38
43
|
target = canUseDOM && document.body,
|
|
39
44
|
x = 0,
|
|
40
45
|
y = 0,
|
|
@@ -101,18 +106,8 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
|
-
function handleClose(
|
|
105
|
-
|
|
106
|
-
window.addEventListener('keyup', returnFocus, {
|
|
107
|
-
once: true
|
|
108
|
-
});
|
|
109
|
-
} else if (e.type === 'click' && menu.current) {
|
|
110
|
-
menu.current.addEventListener('focusout', returnFocus, {
|
|
111
|
-
once: true
|
|
112
|
-
});
|
|
113
|
-
} else {
|
|
114
|
-
returnFocus();
|
|
115
|
-
}
|
|
109
|
+
function handleClose() {
|
|
110
|
+
returnFocus();
|
|
116
111
|
if (onClose) {
|
|
117
112
|
onClose();
|
|
118
113
|
}
|
|
@@ -123,7 +118,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
123
118
|
// if the user presses escape or this is a submenu
|
|
124
119
|
// and the user presses ArrowLeft, close it
|
|
125
120
|
if ((match(e, Escape) || !isRoot && match(e, ArrowLeft)) && onClose) {
|
|
126
|
-
handleClose(
|
|
121
|
+
handleClose();
|
|
127
122
|
} else {
|
|
128
123
|
focusItem(e);
|
|
129
124
|
}
|
|
@@ -158,7 +153,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
|
|
|
158
153
|
}
|
|
159
154
|
function handleBlur(e) {
|
|
160
155
|
if (open && onClose && isRoot && !menu.current?.contains(e.relatedTarget)) {
|
|
161
|
-
handleClose(
|
|
156
|
+
handleClose();
|
|
162
157
|
}
|
|
163
158
|
}
|
|
164
159
|
function fitValue(range, axis) {
|
|
@@ -98,18 +98,28 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
// Avoid stray keyup event from MenuButton affecting MenuItem, and vice versa.
|
|
103
|
+
// Keyboard click is handled differently for <button> vs. <li> and for Enter vs. Space. See
|
|
104
|
+
// https://www.stefanjudis.com/today-i-learned/keyboard-button-clicks-with-space-and-enter-behave-differently/.
|
|
105
|
+
const pendingKeyboardClick = useRef(false);
|
|
106
|
+
const keyboardClickEvent = e => match(e, Enter) || match(e, Space);
|
|
101
107
|
function handleKeyDown(e) {
|
|
102
108
|
if (hasChildren && match(e, ArrowRight)) {
|
|
103
109
|
openSubmenu();
|
|
104
110
|
e.stopPropagation();
|
|
105
111
|
}
|
|
106
|
-
|
|
107
|
-
handleClick(e);
|
|
108
|
-
}
|
|
112
|
+
pendingKeyboardClick.current = keyboardClickEvent(e);
|
|
109
113
|
if (rest.onKeyDown) {
|
|
110
114
|
rest.onKeyDown(e);
|
|
111
115
|
}
|
|
112
116
|
}
|
|
117
|
+
function handleKeyUp(e) {
|
|
118
|
+
if (pendingKeyboardClick.current && keyboardClickEvent(e)) {
|
|
119
|
+
handleClick(e);
|
|
120
|
+
}
|
|
121
|
+
pendingKeyboardClick.current = false;
|
|
122
|
+
}
|
|
113
123
|
const classNames = cx(className, `${prefix}--menu-item`, {
|
|
114
124
|
[`${prefix}--menu-item--disabled`]: isDisabled,
|
|
115
125
|
[`${prefix}--menu-item--danger`]: isDanger
|
|
@@ -162,7 +172,8 @@ const MenuItem = /*#__PURE__*/forwardRef(function MenuItem(_ref, forwardRef) {
|
|
|
162
172
|
"aria-haspopup": hasChildren ?? undefined,
|
|
163
173
|
"aria-expanded": hasChildren ? submenuOpen : undefined,
|
|
164
174
|
onClick: handleClick,
|
|
165
|
-
onKeyDown: handleKeyDown
|
|
175
|
+
onKeyDown: handleKeyDown,
|
|
176
|
+
onKeyUp: handleKeyUp
|
|
166
177
|
}, getReferenceProps()), /*#__PURE__*/React__default.createElement("div", {
|
|
167
178
|
className: `${prefix}--menu-item__selection-icon`
|
|
168
179
|
}, rest['aria-checked'] && (_Checkmark || (_Checkmark = /*#__PURE__*/React__default.createElement(Checkmark, null)))), /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -17,7 +17,7 @@ import ButtonSet from '../ButtonSet/ButtonSet.js';
|
|
|
17
17
|
import InlineLoading from '../InlineLoading/InlineLoading.js';
|
|
18
18
|
import { Layer } from '../Layer/index.js';
|
|
19
19
|
import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy.js';
|
|
20
|
-
import
|
|
20
|
+
import { wrapFocusWithoutSentinels, elementOrParentIsFloatingMenu, wrapFocus } from '../../internal/wrapFocus.js';
|
|
21
21
|
import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
|
|
22
22
|
import { useId } from '../../internal/useId.js';
|
|
23
23
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -99,28 +99,28 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
99
99
|
target
|
|
100
100
|
} = evt;
|
|
101
101
|
evt.stopPropagation();
|
|
102
|
-
if (open) {
|
|
102
|
+
if (open && target instanceof HTMLElement) {
|
|
103
103
|
if (match(evt, Escape)) {
|
|
104
104
|
onRequestClose(evt);
|
|
105
105
|
}
|
|
106
|
-
if (match(evt, Enter) && shouldSubmitOnEnter &&
|
|
106
|
+
if (match(evt, Enter) && shouldSubmitOnEnter && !isCloseButton(target) && document.activeElement !== button.current) {
|
|
107
107
|
onRequestSubmit(evt);
|
|
108
108
|
}
|
|
109
109
|
if (focusTrapWithoutSentinels && !enableDialogElement && match(evt, Tab) && innerModal.current) {
|
|
110
110
|
wrapFocusWithoutSentinels({
|
|
111
111
|
containerNode: innerModal.current,
|
|
112
|
-
currentActiveNode:
|
|
113
|
-
// TODO: Delete type assertion following util rewrite.
|
|
114
|
-
// https://github.com/carbon-design-system/carbon/pull/18913
|
|
112
|
+
currentActiveNode: target,
|
|
115
113
|
event: evt
|
|
116
114
|
});
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
118
|
function handleOnClick(evt) {
|
|
121
|
-
const
|
|
119
|
+
const {
|
|
120
|
+
target
|
|
121
|
+
} = evt;
|
|
122
122
|
evt.stopPropagation();
|
|
123
|
-
if (!preventCloseOnClickOutside && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
|
|
123
|
+
if (!preventCloseOnClickOutside && target instanceof Node && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
|
|
124
124
|
onRequestClose(evt);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -129,7 +129,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
|
|
|
129
129
|
target: oldActiveNode,
|
|
130
130
|
relatedTarget: currentActiveNode
|
|
131
131
|
} = _ref2;
|
|
132
|
-
if (open &&
|
|
132
|
+
if (open && oldActiveNode instanceof HTMLElement && currentActiveNode instanceof HTMLElement) {
|
|
133
133
|
const {
|
|
134
134
|
current: bodyNode
|
|
135
135
|
} = innerModal;
|