@carbon/react 1.78.1 → 1.78.2
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 +764 -764
- package/es/components/Accordion/AccordionItem.js +2 -2
- package/es/components/Button/Button.d.ts +3 -2
- package/es/components/Button/Button.js +2 -1
- package/es/components/Button/ButtonBase.js +1 -1
- package/es/components/ChatButton/ChatButton.d.ts +3 -2
- package/es/components/ChatButton/ChatButton.js +2 -1
- package/es/components/ComboBox/ComboBox.js +24 -34
- package/es/components/ComposedModal/ComposedModal.js +51 -65
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +3 -3
- package/es/components/DataTable/TableBatchAction.d.ts +3 -3
- package/es/components/DataTable/TableBatchAction.js +1 -1
- package/es/components/DataTable/TableContainer.d.ts +1 -1
- package/es/components/DataTable/TableContainer.js +3 -3
- package/es/components/DataTable/TableExpandHeader.d.ts +5 -6
- package/es/components/DataTable/TableToolbarMenu.d.ts +2 -2
- package/es/components/DataTable/TableToolbarMenu.js +1 -1
- package/es/components/DatePicker/DatePicker.js +2 -2
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
- package/es/components/Dialog/index.d.ts +4 -42
- package/es/components/ExpandableSearch/ExpandableSearch.js +2 -2
- package/es/components/FeatureFlags/index.d.ts +1 -3
- package/es/components/FeatureFlags/index.js +0 -3
- package/es/components/FileUploader/FileUploader.d.ts +1 -1
- package/es/components/FileUploader/FileUploader.js +2 -2
- package/es/components/FileUploader/FileUploaderButton.js +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.js +4 -6
- package/es/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderItem.js +2 -2
- package/es/components/Grid/CSSGrid.js +14 -18
- package/es/components/Grid/FlexGrid.js +6 -7
- package/es/components/Grid/GridTypes.d.ts +3 -5
- package/es/components/IconButton/index.js +3 -3
- package/es/components/Layer/index.d.ts +6 -4
- package/es/components/Layer/index.js +6 -5
- package/es/components/Link/Link.d.ts +3 -2
- package/es/components/Link/Link.js +2 -1
- package/es/components/ListBox/ListBoxMenuItem.d.ts +3 -3
- package/es/components/ListBox/ListBoxMenuItem.js +15 -37
- package/es/components/Menu/Menu.js +2 -2
- package/es/components/Menu/MenuItem.d.ts +2 -2
- package/es/components/Menu/MenuItem.js +3 -3
- package/es/components/Modal/Modal.js +49 -121
- package/es/components/Modal/next/index.d.ts +171 -0
- package/es/components/ModalWrapper/ModalWrapper.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +3 -3
- package/es/components/MultiSelect/MultiSelect.js +2 -2
- package/es/components/Notification/Notification.d.ts +13 -5
- package/es/components/Notification/Notification.js +4 -3
- package/es/components/OverflowMenu/OverflowMenu.d.ts +8 -4
- package/es/components/OverflowMenu/OverflowMenu.js +3 -3
- package/es/components/OverflowMenu/next/index.d.ts +2 -2
- package/es/components/OverflowMenu/next/index.js +1 -1
- package/es/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/es/components/ProgressIndicator/ProgressIndicator.js +2 -2
- package/es/components/RadioTile/RadioTile.js +2 -2
- package/es/components/Search/Search.d.ts +3 -2
- package/es/components/Search/Search.js +6 -4
- package/es/components/Slider/Slider.d.ts +15 -16
- package/es/components/Slider/Slider.js +22 -22
- package/es/components/Tabs/Tabs.d.ts +6 -3
- package/es/components/Tabs/Tabs.js +9 -8
- package/es/components/Tag/DismissibleTag.d.ts +5 -3
- package/es/components/Tag/DismissibleTag.js +2 -1
- package/es/components/Tag/OperationalTag.d.ts +3 -2
- package/es/components/Tag/OperationalTag.js +2 -1
- package/es/components/Tag/SelectableTag.d.ts +5 -3
- package/es/components/Tag/SelectableTag.js +2 -1
- package/es/components/Tag/Tag.d.ts +3 -2
- package/es/components/Tag/Tag.js +2 -1
- package/es/components/Tile/Tile.d.ts +5 -3
- package/es/components/Tile/Tile.js +6 -8
- package/es/components/Toggletip/index.js +2 -2
- package/es/components/Tooltip/DefinitionTooltip.js +2 -2
- package/es/components/Tooltip/Tooltip.d.ts +1 -1
- package/es/components/Tooltip/Tooltip.js +2 -2
- package/es/components/TreeView/TreeNode.d.ts +5 -3
- package/es/components/TreeView/TreeNode.js +4 -3
- package/es/components/TreeView/TreeView.js +2 -2
- package/es/components/UIShell/HeaderContainer.js +2 -2
- package/es/components/UIShell/HeaderMenu.js +2 -2
- package/es/components/UIShell/HeaderPanel.js +2 -2
- package/es/components/UIShell/SideNav.d.ts +1 -1
- package/es/components/UIShell/SideNav.js +2 -2
- package/es/components/UIShell/SideNavHeader.d.ts +3 -2
- package/es/components/UIShell/SideNavHeader.js +2 -1
- package/es/components/UIShell/SideNavLink.d.ts +2 -2
- package/es/components/UIShell/SideNavLink.js +1 -1
- package/es/components/UIShell/SideNavMenu.d.ts +2 -2
- package/es/components/UIShell/SideNavMenu.js +3 -3
- package/es/components/UIShell/SwitcherItem.js +2 -2
- package/es/internal/FloatingMenu.js +4 -4
- package/es/internal/OptimizedResize.js +24 -21
- package/es/internal/focus/index.js +15 -0
- package/es/internal/keyboard/keys.js +2 -2
- package/es/internal/keyboard/match.js +41 -17
- package/es/internal/keyboard/navigation.js +27 -15
- package/es/internal/useMergedRefs.js +0 -3
- package/lib/components/Accordion/AccordionItem.js +2 -2
- package/lib/components/Button/Button.d.ts +3 -2
- package/lib/components/Button/Button.js +2 -1
- package/lib/components/Button/ButtonBase.js +1 -1
- package/lib/components/ChatButton/ChatButton.d.ts +3 -2
- package/lib/components/ChatButton/ChatButton.js +2 -1
- package/lib/components/ComboBox/ComboBox.js +24 -34
- package/lib/components/ComposedModal/ComposedModal.js +50 -64
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.d.ts +2 -2
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +1 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +3 -3
- package/lib/components/DataTable/TableBatchAction.d.ts +3 -3
- package/lib/components/DataTable/TableBatchAction.js +1 -1
- package/lib/components/DataTable/TableContainer.d.ts +1 -1
- package/lib/components/DataTable/TableContainer.js +3 -3
- package/lib/components/DataTable/TableExpandHeader.d.ts +5 -6
- package/lib/components/DataTable/TableToolbarMenu.d.ts +2 -2
- package/lib/components/DataTable/TableToolbarMenu.js +1 -1
- package/lib/components/DatePicker/DatePicker.js +2 -2
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +1 -1
- package/lib/components/Dialog/index.d.ts +4 -42
- package/lib/components/ExpandableSearch/ExpandableSearch.js +2 -2
- package/lib/components/FeatureFlags/index.d.ts +1 -3
- package/lib/components/FeatureFlags/index.js +0 -3
- package/lib/components/FileUploader/FileUploader.d.ts +1 -1
- package/lib/components/FileUploader/FileUploader.js +2 -2
- package/lib/components/FileUploader/FileUploaderButton.js +2 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.js +4 -6
- package/lib/components/FileUploader/FileUploaderItem.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderItem.js +2 -2
- package/lib/components/Grid/CSSGrid.js +14 -18
- package/lib/components/Grid/FlexGrid.js +6 -7
- package/lib/components/Grid/GridTypes.d.ts +3 -5
- package/lib/components/IconButton/index.js +3 -3
- package/lib/components/Layer/index.d.ts +6 -4
- package/lib/components/Layer/index.js +6 -5
- package/lib/components/Link/Link.d.ts +3 -2
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/ListBox/ListBoxMenuItem.d.ts +3 -3
- package/lib/components/ListBox/ListBoxMenuItem.js +14 -36
- package/lib/components/Menu/Menu.js +2 -2
- package/lib/components/Menu/MenuItem.d.ts +2 -2
- package/lib/components/Menu/MenuItem.js +3 -3
- package/lib/components/Modal/Modal.js +51 -123
- package/lib/components/Modal/next/index.d.ts +171 -0
- package/lib/components/ModalWrapper/ModalWrapper.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -3
- package/lib/components/MultiSelect/MultiSelect.js +2 -2
- package/lib/components/Notification/Notification.d.ts +13 -5
- package/lib/components/Notification/Notification.js +4 -3
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +8 -4
- package/lib/components/OverflowMenu/OverflowMenu.js +3 -3
- package/lib/components/OverflowMenu/next/index.d.ts +2 -2
- package/lib/components/OverflowMenu/next/index.js +1 -1
- package/lib/components/OverflowMenuItem/OverflowMenuItem.js +2 -2
- package/lib/components/ProgressIndicator/ProgressIndicator.js +2 -2
- package/lib/components/RadioTile/RadioTile.js +2 -2
- package/lib/components/Search/Search.d.ts +3 -2
- package/lib/components/Search/Search.js +6 -4
- package/lib/components/Slider/Slider.d.ts +15 -16
- package/lib/components/Slider/Slider.js +22 -22
- package/lib/components/Tabs/Tabs.d.ts +6 -3
- package/lib/components/Tabs/Tabs.js +9 -8
- package/lib/components/Tag/DismissibleTag.d.ts +5 -3
- package/lib/components/Tag/DismissibleTag.js +2 -1
- package/lib/components/Tag/OperationalTag.d.ts +3 -2
- package/lib/components/Tag/OperationalTag.js +2 -1
- package/lib/components/Tag/SelectableTag.d.ts +5 -3
- package/lib/components/Tag/SelectableTag.js +2 -1
- package/lib/components/Tag/Tag.d.ts +3 -2
- package/lib/components/Tag/Tag.js +2 -1
- package/lib/components/Tile/Tile.d.ts +5 -3
- package/lib/components/Tile/Tile.js +6 -8
- package/lib/components/Toggletip/index.js +2 -2
- package/lib/components/Tooltip/DefinitionTooltip.js +2 -2
- package/lib/components/Tooltip/Tooltip.d.ts +1 -1
- package/lib/components/Tooltip/Tooltip.js +2 -2
- package/lib/components/TreeView/TreeNode.d.ts +5 -3
- package/lib/components/TreeView/TreeNode.js +4 -3
- package/lib/components/TreeView/TreeView.js +2 -2
- package/lib/components/UIShell/HeaderContainer.js +2 -2
- package/lib/components/UIShell/HeaderMenu.js +2 -2
- package/lib/components/UIShell/HeaderPanel.js +2 -2
- package/lib/components/UIShell/SideNav.d.ts +1 -1
- package/lib/components/UIShell/SideNav.js +2 -2
- package/lib/components/UIShell/SideNavHeader.d.ts +3 -2
- package/lib/components/UIShell/SideNavHeader.js +2 -1
- package/lib/components/UIShell/SideNavLink.d.ts +2 -2
- package/lib/components/UIShell/SideNavLink.js +1 -1
- package/lib/components/UIShell/SideNavMenu.d.ts +2 -2
- package/lib/components/UIShell/SideNavMenu.js +3 -3
- package/lib/components/UIShell/SwitcherItem.js +2 -2
- package/lib/internal/FloatingMenu.js +5 -5
- package/lib/internal/OptimizedResize.js +24 -21
- package/lib/internal/focus/index.js +19 -0
- package/lib/internal/keyboard/keys.js +2 -2
- package/lib/internal/keyboard/match.js +41 -17
- package/lib/internal/keyboard/navigation.js +27 -15
- package/lib/internal/useMergedRefs.js +0 -3
- package/package.json +6 -6
- package/telemetry.yml +0 -1
- package/es/components/Dialog/index.js +0 -177
- package/es/internal/OptimizedResize.d.ts +0 -18
- package/es/internal/keyboard/index.d.ts +0 -9
- package/es/internal/keyboard/keys.d.ts +0 -23
- package/es/internal/keyboard/match.d.ts +0 -26
- package/es/internal/keyboard/navigation.d.ts +0 -37
- package/lib/components/Dialog/index.js +0 -190
- package/lib/internal/OptimizedResize.d.ts +0 -18
- package/lib/internal/keyboard/index.d.ts +0 -9
- package/lib/internal/keyboard/keys.d.ts +0 -23
- package/lib/internal/keyboard/match.d.ts +0 -26
- package/lib/internal/keyboard/navigation.d.ts +0 -37
- package/scss/components/dialog/_dialog.scss +0 -9
- package/scss/components/dialog/_index.scss +0 -9
|
@@ -10,12 +10,12 @@ import { ChevronDown } from '@carbon/icons-react';
|
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import React__default from 'react';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
|
-
import { Enter, Space, Escape } from '../../internal/keyboard/keys.js';
|
|
14
|
-
import { matches } from '../../internal/keyboard/match.js';
|
|
15
13
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
16
14
|
import { PrefixContext } from '../../internal/usePrefix.js';
|
|
17
15
|
import deprecate from '../../prop-types/deprecate.js';
|
|
18
16
|
import { composeEventHandlers } from '../../tools/events.js';
|
|
17
|
+
import { matches } from '../../internal/keyboard/match.js';
|
|
18
|
+
import { Enter, Space, Escape } from '../../internal/keyboard/keys.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* `HeaderMenu` is used to render submenu's in the `Header`. Most often children
|
|
@@ -10,10 +10,10 @@ import cx from 'classnames';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React__default, { useRef, useState } from 'react';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
-
import { Escape } from '../../internal/keyboard/keys.js';
|
|
14
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
15
13
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
16
14
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
15
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Escape } from '../../internal/keyboard/keys.js';
|
|
17
17
|
|
|
18
18
|
const noopFn = () => {};
|
|
19
19
|
const HeaderPanel = /*#__PURE__*/React__default.forwardRef(function HeaderPanel(_ref, ref) {
|
|
@@ -12,13 +12,13 @@ import PropTypes from 'prop-types';
|
|
|
12
12
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
13
13
|
import { CARBON_SIDENAV_ITEMS } from './_utils.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
-
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
16
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
17
15
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
18
16
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
19
17
|
import { useDelayedState } from '../../internal/useDelayedState.js';
|
|
20
18
|
import { breakpoints } from '@carbon/layout';
|
|
21
19
|
import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
20
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
21
|
+
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
22
22
|
|
|
23
23
|
// TO-DO: comment back in when footer is added for rails
|
|
24
24
|
// import SideNavFooter from './SideNavFooter';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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.
|
|
@@ -20,7 +20,8 @@ export interface SideNavHeaderProps {
|
|
|
20
20
|
*/
|
|
21
21
|
isSideNavExpanded?: boolean;
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Provide an icon to render in the header of the side navigation. Should be
|
|
24
|
+
* a React class.
|
|
24
25
|
*/
|
|
25
26
|
renderIcon: React.ComponentType;
|
|
26
27
|
}
|
|
@@ -39,7 +39,8 @@ SideNavHeader.propTypes = {
|
|
|
39
39
|
*/
|
|
40
40
|
isSideNavExpanded: PropTypes.bool,
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Provide an icon to render in the header of the side navigation. Should be
|
|
43
|
+
* a React class.
|
|
43
44
|
*/
|
|
44
45
|
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
45
46
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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.
|
|
@@ -37,7 +37,7 @@ export type SideNavLinkProps<E extends ElementType> = LinkProps<E> & {
|
|
|
37
37
|
*/
|
|
38
38
|
large?: boolean;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Provide an icon to render in the side navigation link. Should be a React class.
|
|
41
41
|
*/
|
|
42
42
|
renderIcon?: ComponentType;
|
|
43
43
|
/**
|
|
@@ -69,7 +69,7 @@ SideNavLink.propTypes = {
|
|
|
69
69
|
*/
|
|
70
70
|
large: PropTypes.bool,
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Provide an icon to render in the side navigation link. Should be a React class.
|
|
73
73
|
*/
|
|
74
74
|
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
75
75
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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.
|
|
@@ -27,7 +27,7 @@ export interface SideNavMenuProps {
|
|
|
27
27
|
*/
|
|
28
28
|
large?: boolean;
|
|
29
29
|
/**
|
|
30
|
-
* A
|
|
30
|
+
* A custom icon to render next to the SideNavMenu title. This can be a function returning JSX or JSX itself.
|
|
31
31
|
*/
|
|
32
32
|
renderIcon?: React.ComponentType;
|
|
33
33
|
/**
|
|
@@ -10,10 +10,10 @@ import cx from 'classnames';
|
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import React__default, { useContext, useState } from 'react';
|
|
12
12
|
import SideNavIcon from './SideNavIcon.js';
|
|
13
|
-
import { Escape } from '../../internal/keyboard/keys.js';
|
|
14
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
15
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
14
|
import { SideNavContext } from './SideNav.js';
|
|
15
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Escape } from '../../internal/keyboard/keys.js';
|
|
17
17
|
|
|
18
18
|
var _ChevronDown;
|
|
19
19
|
const SideNavMenu = /*#__PURE__*/React__default.forwardRef(function SideNavMenu(_ref, ref) {
|
|
@@ -110,7 +110,7 @@ SideNavMenu.propTypes = {
|
|
|
110
110
|
*/
|
|
111
111
|
large: PropTypes.bool,
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
113
|
+
* Pass in a custom icon to render next to the `SideNavMenu` title
|
|
114
114
|
*/
|
|
115
115
|
// @ts-expect-error - PropTypes are unable to cover this case.
|
|
116
116
|
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
@@ -11,9 +11,9 @@ import cx from 'classnames';
|
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import { Link } from './Link.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
-
import { ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
|
|
15
|
-
import { match } from '../../internal/keyboard/match.js';
|
|
16
14
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
15
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
|
|
17
17
|
|
|
18
18
|
const SwitcherItem = /*#__PURE__*/forwardRef(function SwitcherItem(props, forwardRef) {
|
|
19
19
|
const {
|
|
@@ -9,13 +9,13 @@ import React__default, { useContext, useState, useRef, useCallback, useEffect, c
|
|
|
9
9
|
import * as FeatureFlags from '@carbon/feature-flags';
|
|
10
10
|
import ReactDOM from 'react-dom';
|
|
11
11
|
import window from 'window-or-global';
|
|
12
|
-
import
|
|
13
|
-
import { match } from './keyboard/match.js';
|
|
12
|
+
import OptimizedResize from './OptimizedResize.js';
|
|
14
13
|
import { selectorTabbable, selectorFocusable } from './keyboard/navigation.js';
|
|
15
|
-
import { OptimizedResize } from './OptimizedResize.js';
|
|
16
14
|
import { PrefixContext } from './usePrefix.js';
|
|
17
15
|
import { warning } from './warning.js';
|
|
18
16
|
import wrapFocus, { wrapFocusWithoutSentinels } from './wrapFocus.js';
|
|
17
|
+
import { match } from './keyboard/match.js';
|
|
18
|
+
import { Tab } from './keyboard/keys.js';
|
|
19
19
|
|
|
20
20
|
const DIRECTION_LEFT = 'left';
|
|
21
21
|
const DIRECTION_TOP = 'top';
|
|
@@ -205,7 +205,7 @@ const FloatingMenu = _ref2 => {
|
|
|
205
205
|
updateMenuPosition();
|
|
206
206
|
});
|
|
207
207
|
return () => {
|
|
208
|
-
resizeHandler.
|
|
208
|
+
resizeHandler.release();
|
|
209
209
|
};
|
|
210
210
|
}, [triggerRef, menuOffset, menuDirection, flipped, target, updateOrientation]);
|
|
211
211
|
|
|
@@ -8,42 +8,44 @@
|
|
|
8
8
|
import window from 'window-or-global';
|
|
9
9
|
|
|
10
10
|
// mdn resize function
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A callback function to be executed on `resize`.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
const OptimizedResize = (() => {
|
|
11
|
+
const OptimizedResize = function optimizedResize() {
|
|
17
12
|
const callbacks = [];
|
|
18
13
|
let running = false;
|
|
19
|
-
|
|
14
|
+
|
|
15
|
+
// run the actual callbacks
|
|
16
|
+
function runCallbacks() {
|
|
20
17
|
callbacks.forEach(callback => {
|
|
21
18
|
callback();
|
|
22
19
|
});
|
|
23
20
|
running = false;
|
|
24
|
-
}
|
|
25
|
-
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// fired on resize event
|
|
24
|
+
function resize() {
|
|
26
25
|
if (!running) {
|
|
27
26
|
running = true;
|
|
28
27
|
window.requestAnimationFrame(runCallbacks);
|
|
29
28
|
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// adds callback to loop
|
|
32
|
+
function addCallback(callback) {
|
|
33
|
+
if (callback) {
|
|
34
|
+
const index = callbacks.indexOf(callback);
|
|
35
|
+
if (index < 0) {
|
|
36
|
+
callbacks.push(callback);
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
|
-
}
|
|
39
|
+
}
|
|
37
40
|
return {
|
|
38
|
-
|
|
41
|
+
// public method to add additional callback
|
|
39
42
|
add: callback => {
|
|
40
43
|
if (!callbacks.length) {
|
|
41
|
-
window.addEventListener('resize',
|
|
44
|
+
window.addEventListener('resize', resize);
|
|
42
45
|
}
|
|
43
46
|
addCallback(callback);
|
|
44
47
|
return {
|
|
45
|
-
|
|
46
|
-
remove: () => {
|
|
48
|
+
release() {
|
|
47
49
|
const index = callbacks.indexOf(callback);
|
|
48
50
|
if (index >= 0) {
|
|
49
51
|
callbacks.splice(index, 1);
|
|
@@ -52,6 +54,7 @@ const OptimizedResize = (() => {
|
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
};
|
|
55
|
-
}
|
|
57
|
+
}();
|
|
58
|
+
var OptimizedResize$1 = OptimizedResize;
|
|
56
59
|
|
|
57
|
-
export { OptimizedResize };
|
|
60
|
+
export { OptimizedResize$1 as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function focus(elementOrRef) {
|
|
9
|
+
const element = elementOrRef.current || elementOrRef;
|
|
10
|
+
if (element && element.focus && document.activeElement !== element) {
|
|
11
|
+
element.focus();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { focus };
|
|
@@ -5,38 +5,65 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @typedef Key
|
|
10
|
+
* @property key {Array<string>|string}
|
|
11
|
+
* @property which {number}
|
|
12
|
+
* @property keyCode {number}
|
|
13
|
+
*/
|
|
14
|
+
|
|
8
15
|
/**
|
|
9
16
|
* Check to see if at least one key code matches the key code of the
|
|
10
17
|
* given event.
|
|
11
18
|
*
|
|
12
|
-
* @
|
|
13
|
-
*
|
|
14
|
-
*
|
|
19
|
+
* @example
|
|
20
|
+
* import * as keys from '../keys';
|
|
21
|
+
* import { matches } from '../match';
|
|
22
|
+
*
|
|
23
|
+
* function handleOnKeyDown(event) {
|
|
24
|
+
* if (matches(event, [keys.Enter, keys.Space]) {
|
|
25
|
+
* // ...
|
|
26
|
+
* }
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* @param {Event|React.SyntheticEvent} event
|
|
30
|
+
* @param {Array<Key>} keysToMatch
|
|
31
|
+
* @returns {boolean}
|
|
15
32
|
*/
|
|
16
|
-
|
|
33
|
+
function matches(event, keysToMatch) {
|
|
17
34
|
for (let i = 0; i < keysToMatch.length; i++) {
|
|
18
35
|
if (match(event, keysToMatch[i])) {
|
|
19
36
|
return true;
|
|
20
37
|
}
|
|
21
38
|
}
|
|
22
39
|
return false;
|
|
23
|
-
}
|
|
40
|
+
}
|
|
24
41
|
|
|
25
42
|
/**
|
|
26
43
|
* Check to see if the given key matches the corresponding keyboard event. Also
|
|
27
|
-
* supports passing in the value directly if you can't
|
|
44
|
+
* supports passing in the value directly if you can't used the given event.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* import * as keys from '../keys';
|
|
48
|
+
* import { matches } from '../match';
|
|
49
|
+
*
|
|
50
|
+
* function handleOnKeyDown(event) {
|
|
51
|
+
* if (match(event, keys.Enter) {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
28
55
|
*
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @returns
|
|
56
|
+
* @param {React.SyntheticEvent|Event|number|string} eventOrCode
|
|
57
|
+
* @param {Key} key
|
|
58
|
+
* @returns {boolean}
|
|
32
59
|
*/
|
|
33
|
-
|
|
60
|
+
function match(eventOrCode) {
|
|
34
61
|
let {
|
|
35
62
|
key,
|
|
36
63
|
which,
|
|
37
64
|
keyCode,
|
|
38
65
|
code
|
|
39
|
-
} =
|
|
66
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
40
67
|
if (typeof eventOrCode === 'string') {
|
|
41
68
|
return eventOrCode === key;
|
|
42
69
|
}
|
|
@@ -44,12 +71,9 @@ const match = (eventOrCode, _ref) => {
|
|
|
44
71
|
return eventOrCode === which || eventOrCode === keyCode;
|
|
45
72
|
}
|
|
46
73
|
if (eventOrCode.key && Array.isArray(key)) {
|
|
47
|
-
return key.
|
|
74
|
+
return key.indexOf(eventOrCode.key) !== -1;
|
|
48
75
|
}
|
|
49
|
-
return eventOrCode.key === key ||
|
|
50
|
-
|
|
51
|
-
// Presumably, the `Key` type should also be pruned of these properties.
|
|
52
|
-
eventOrCode.which === which || eventOrCode.keyCode === keyCode || eventOrCode.code === code;
|
|
53
|
-
};
|
|
76
|
+
return eventOrCode.key === key || eventOrCode.which === which || eventOrCode.keyCode === keyCode || eventOrCode.code === code;
|
|
77
|
+
}
|
|
54
78
|
|
|
55
79
|
export { match, matches };
|
|
@@ -9,16 +9,21 @@ import { ArrowRight, ArrowLeft } from './keys.js';
|
|
|
9
9
|
import { match } from './match.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
|
|
12
|
+
* Various utilities to help with a11y work
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A "ring buffer" function that takes an array and depending on an ArrowRight
|
|
17
|
+
* or ArrowLeft key input loops from last index to first or first index to last.
|
|
14
18
|
*
|
|
15
|
-
* @param key - the left or right arrow
|
|
16
|
-
* @param index - the current index in
|
|
17
|
-
* @param arrayLength - the total length of the array
|
|
19
|
+
* @param {string} key - the left or right arrow keys
|
|
20
|
+
* @param {number} index - the current index in a given array
|
|
21
|
+
* @param {number} arrayLength - the total length of the array
|
|
18
22
|
*
|
|
19
23
|
* @example
|
|
20
|
-
*
|
|
24
|
+
* getNextIndex(keyCodes.RIGHT, 0, 4)
|
|
21
25
|
*/
|
|
26
|
+
|
|
22
27
|
const getNextIndex = (key, index, arrayLength) => {
|
|
23
28
|
if (match(key, ArrowRight)) {
|
|
24
29
|
return (index + 1) % arrayLength;
|
|
@@ -26,23 +31,30 @@ const getNextIndex = (key, index, arrayLength) => {
|
|
|
26
31
|
if (match(key, ArrowLeft)) {
|
|
27
32
|
return (index + arrayLength - 1) % arrayLength;
|
|
28
33
|
}
|
|
29
|
-
return;
|
|
30
34
|
};
|
|
31
35
|
|
|
32
36
|
/**
|
|
33
|
-
* A flag `node.compareDocumentPosition(target)` returns
|
|
34
|
-
* `target` is located earlier than `node` in the document or `target` contains `node`.
|
|
37
|
+
* A flag `node.compareDocumentPosition(target)` returns,
|
|
38
|
+
* that indicates `target` is located earlier than `node` in the document or `target` contains `node`.
|
|
35
39
|
*/
|
|
36
|
-
const DOCUMENT_POSITION_BROAD_PRECEDING =
|
|
40
|
+
const DOCUMENT_POSITION_BROAD_PRECEDING =
|
|
41
|
+
// Checks `typeof Node` for `react-docgen`
|
|
42
|
+
typeof Node !== 'undefined' &&
|
|
43
|
+
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
|
44
|
+
Node.DOCUMENT_POSITION_PRECEDING | Node.DOCUMENT_POSITION_CONTAINS;
|
|
37
45
|
|
|
38
46
|
/**
|
|
39
|
-
* A flag `node.compareDocumentPosition(target)` returns
|
|
40
|
-
* `target` is located later than `node` in the document or `node` contains `target`.
|
|
47
|
+
* A flag `node.compareDocumentPosition(target)` returns,
|
|
48
|
+
* that indicates `target` is located later than `node` in the document or `node` contains `target`.
|
|
41
49
|
*/
|
|
42
|
-
const DOCUMENT_POSITION_BROAD_FOLLOWING =
|
|
50
|
+
const DOCUMENT_POSITION_BROAD_FOLLOWING =
|
|
51
|
+
// Checks `typeof Node` for `react-docgen`
|
|
52
|
+
typeof Node !== 'undefined' &&
|
|
53
|
+
// eslint-disable-next-line ssr-friendly/no-dom-globals-in-module-scope
|
|
54
|
+
Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_POSITION_CONTAINED_BY;
|
|
43
55
|
|
|
44
56
|
/**
|
|
45
|
-
* CSS selector that selects major nodes that are
|
|
57
|
+
* CSS selector that selects major nodes that are sequential-focusable.
|
|
46
58
|
*/
|
|
47
59
|
const selectorTabbable = `
|
|
48
60
|
a[href], area[href], input:not([disabled]):not([tabindex='-1']),
|
|
@@ -52,7 +64,7 @@ const selectorTabbable = `
|
|
|
52
64
|
`;
|
|
53
65
|
|
|
54
66
|
/**
|
|
55
|
-
* CSS selector that selects major nodes that are click focusable
|
|
67
|
+
* CSS selector that selects major nodes that are click focusable
|
|
56
68
|
*/
|
|
57
69
|
const selectorFocusable = `
|
|
58
70
|
a[href], area[href], input:not([disabled]),
|
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
|
|
8
8
|
import { useCallback } from 'react';
|
|
9
9
|
|
|
10
|
-
// TODO: Investigate updating this hook based on the following code from
|
|
11
|
-
// https://github.com/carbon-design-system/carbon/pull/18611:
|
|
12
|
-
// https://github.com/adamalston/carbon/blob/dd403b6b10de3d8a6ccd8d2e21174c908c1e890a/packages/react/src/components/ListBox/ListBoxMenuItem.tsx#L23-L46
|
|
13
10
|
/**
|
|
14
11
|
* Combine multiple refs into a single ref. This use useful when you have two
|
|
15
12
|
* refs from both `React.forwardRef` and `useRef` that you would like to add to
|
|
@@ -15,13 +15,13 @@ var cx = require('classnames');
|
|
|
15
15
|
var PropTypes = require('prop-types');
|
|
16
16
|
var React = require('react');
|
|
17
17
|
require('../Text/index.js');
|
|
18
|
-
var keys = require('../../internal/keyboard/keys.js');
|
|
19
|
-
var match = require('../../internal/keyboard/match.js');
|
|
20
18
|
var useId = require('../../internal/useId.js');
|
|
21
19
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
22
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
23
21
|
var AccordionProvider = require('./AccordionProvider.js');
|
|
22
|
+
var match = require('../../internal/keyboard/match.js');
|
|
24
23
|
var Text = require('../Text/Text.js');
|
|
24
|
+
var keys = require('../../internal/keyboard/keys.js');
|
|
25
25
|
|
|
26
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
27
27
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
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.
|
|
@@ -50,7 +50,8 @@ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
50
50
|
*/
|
|
51
51
|
rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Optional prop to allow overriding the icon rendering.
|
|
54
|
+
* Can be a React component class
|
|
54
55
|
*/
|
|
55
56
|
renderIcon?: React.ElementType;
|
|
56
57
|
/**
|
|
@@ -203,7 +203,8 @@ Button.propTypes = {
|
|
|
203
203
|
*/
|
|
204
204
|
rel: PropTypes__default["default"].string,
|
|
205
205
|
/**
|
|
206
|
-
*
|
|
206
|
+
* Optional prop to allow overriding the icon rendering.
|
|
207
|
+
* Can be a React component class
|
|
207
208
|
*/
|
|
208
209
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
209
210
|
/**
|
|
@@ -58,7 +58,7 @@ const ButtonBase = /*#__PURE__*/React__default["default"].forwardRef(function Bu
|
|
|
58
58
|
[`${prefix}--btn--${kind}`]: kind,
|
|
59
59
|
[`${prefix}--btn--disabled`]: disabled,
|
|
60
60
|
[`${prefix}--btn--expressive`]: isExpressive,
|
|
61
|
-
[`${prefix}--btn--icon-only`]: hasIconOnly,
|
|
61
|
+
[`${prefix}--btn--icon-only`]: hasIconOnly && !className?.includes(`${prefix}--btn--icon-only`),
|
|
62
62
|
[`${prefix}--btn--selected`]: hasIconOnly && isSelected && kind === 'ghost'
|
|
63
63
|
});
|
|
64
64
|
const commonProps = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2024
|
|
2
|
+
* Copyright IBM Corp. 2024
|
|
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.
|
|
@@ -33,7 +33,8 @@ export interface ChatButtonProps extends React.ButtonHTMLAttributes<HTMLButtonEl
|
|
|
33
33
|
*/
|
|
34
34
|
kind?: ChatButtonKind;
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Optional prop to specify an icon to be rendered.
|
|
37
|
+
* Can be a React component class
|
|
37
38
|
*/
|
|
38
39
|
renderIcon?: ComponentType | FunctionComponent;
|
|
39
40
|
/**
|
|
@@ -85,7 +85,8 @@ ChatButton.propTypes = {
|
|
|
85
85
|
*/
|
|
86
86
|
kind: PropTypes__default["default"].oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
|
|
87
87
|
/**
|
|
88
|
-
*
|
|
88
|
+
* Optional prop to specify an icon to be rendered.
|
|
89
|
+
* Can be a React component class
|
|
89
90
|
*/
|
|
90
91
|
// @ts-expect-error: PropTypes are not expressive enough to cover this case
|
|
91
92
|
renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
|
|
@@ -20,8 +20,6 @@ var isEqual = require('react-fast-compare');
|
|
|
20
20
|
var index$1 = require('../ListBox/index.js');
|
|
21
21
|
var ListBoxSelection = require('../ListBox/next/ListBoxSelection.js');
|
|
22
22
|
var ListBoxTrigger = require('../ListBox/next/ListBoxTrigger.js');
|
|
23
|
-
var keys = require('../../internal/keyboard/keys.js');
|
|
24
|
-
var match = require('../../internal/keyboard/match.js');
|
|
25
23
|
var useId = require('../../internal/useId.js');
|
|
26
24
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
27
25
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
@@ -30,8 +28,10 @@ require('../FluidForm/FluidForm.js');
|
|
|
30
28
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
31
29
|
var react = require('@floating-ui/react');
|
|
32
30
|
var index = require('../FeatureFlags/index.js');
|
|
31
|
+
var match = require('../../internal/keyboard/match.js');
|
|
33
32
|
var ListBoxPropTypes = require('../ListBox/ListBoxPropTypes.js');
|
|
34
33
|
var Text = require('../Text/Text.js');
|
|
34
|
+
var keys = require('../../internal/keyboard/keys.js');
|
|
35
35
|
|
|
36
36
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
37
37
|
|
|
@@ -312,41 +312,31 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
312
312
|
return changes;
|
|
313
313
|
}
|
|
314
314
|
case InputKeyDownEnter:
|
|
315
|
-
if (!allowCustomValue) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
selectedItem: matchingItem,
|
|
329
|
-
inputValue: itemToString(matchingItem)
|
|
330
|
-
};
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// If no matching item is found and there is an existing
|
|
334
|
-
// selection, clear the selection.
|
|
335
|
-
if (state.selectedItem !== null) {
|
|
336
|
-
return {
|
|
337
|
-
...changes,
|
|
338
|
-
selectedItem: null,
|
|
315
|
+
if (highlightedIndex === -1 && !allowCustomValue && state.selectedItem) {
|
|
316
|
+
return {
|
|
317
|
+
...changes,
|
|
318
|
+
selectedItem: null,
|
|
319
|
+
inputValue: state.inputValue
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
if (allowCustomValue) {
|
|
323
|
+
setInputValue(inputValue);
|
|
324
|
+
setHighlightedIndex(changes.selectedItem);
|
|
325
|
+
if (onChange) {
|
|
326
|
+
onChange({
|
|
327
|
+
selectedItem: changes.selectedItem,
|
|
339
328
|
inputValue
|
|
340
|
-
};
|
|
329
|
+
});
|
|
341
330
|
}
|
|
331
|
+
return changes;
|
|
332
|
+
} else if (changes.selectedItem && !allowCustomValue) {
|
|
333
|
+
return changes;
|
|
334
|
+
} else {
|
|
335
|
+
return {
|
|
336
|
+
...changes,
|
|
337
|
+
isOpen: true
|
|
338
|
+
};
|
|
342
339
|
}
|
|
343
|
-
|
|
344
|
-
// For `allowCustomValue` or if no matching item is found, keep the
|
|
345
|
-
// menu open.
|
|
346
|
-
return {
|
|
347
|
-
...changes,
|
|
348
|
-
isOpen: true
|
|
349
|
-
};
|
|
350
340
|
case FunctionToggleMenu:
|
|
351
341
|
case ToggleButtonClick:
|
|
352
342
|
if (!changes.isOpen && state.inputValue && highlightedIndex === -1 && !allowCustomValue) {
|