@carbon/react 1.85.0 → 1.86.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 +797 -797
- package/es/components/AILabel/index.js +1 -1
- package/es/components/Accordion/AccordionItem.d.ts +1 -1
- package/es/components/Accordion/AccordionItem.js +1 -1
- package/es/components/Checkbox/Checkbox.js +1 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/es/components/CodeSnippet/CodeSnippet.d.ts +2 -2
- package/es/components/CodeSnippet/CodeSnippet.js +1 -1
- package/es/components/ComboBox/ComboBox.js +1 -1
- package/es/components/ComposedModal/ComposedModal.js +1 -1
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
- package/es/components/DataTable/DataTable.d.ts +230 -170
- package/es/components/DataTable/DataTable.js +508 -519
- package/es/components/DataTable/TableContainer.d.ts +9 -1
- package/es/components/DataTable/TableContainer.js +7 -1
- package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/es/components/DataTable/TableExpandHeader.js +1 -1
- package/es/components/DataTable/TableSelectAll.d.ts +2 -2
- package/es/components/DataTable/TableSelectAll.js +1 -1
- package/es/components/DataTable/TableSelectRow.d.ts +2 -2
- package/es/components/DataTable/TableSelectRow.js +1 -1
- package/es/components/DataTable/TableToolbar.d.ts +1 -1
- package/es/components/DataTable/TableToolbar.js +1 -1
- package/es/components/DataTable/TableToolbarMenu.d.ts +2 -18
- package/es/components/DataTable/TableToolbarMenu.js +0 -1
- package/es/components/DataTable/index.d.ts +1 -1
- package/es/components/DataTable/state/getDerivedStateFromProps.js +5 -1
- package/es/components/DatePicker/DatePicker.js +1 -1
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dropdown/Dropdown.js +1 -1
- package/es/components/FeatureFlags/index.d.ts +2 -2
- package/es/components/FeatureFlags/index.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +1 -1
- package/es/components/FileUploader/FileUploaderDropContainer.d.ts +2 -2
- package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
- package/es/components/FluidTextArea/FluidTextArea.d.ts +1 -1
- package/es/components/FluidTextArea/FluidTextArea.js +1 -1
- package/es/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/es/components/ListBox/ListBox.js +1 -1
- package/es/components/Loading/Loading.d.ts +1 -1
- package/es/components/Loading/Loading.js +1 -1
- package/es/components/Menu/Menu.js +1 -1
- package/es/components/Modal/Modal.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/es/components/MultiSelect/MultiSelect.js +1 -1
- package/es/components/Notification/Notification.d.ts +4 -4
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.d.ts +7 -0
- package/es/components/NumberInput/NumberInput.js +80 -25
- package/es/components/OverflowMenu/OverflowMenu.d.ts +2 -6
- package/es/components/OverflowMenu/OverflowMenu.js +1 -1
- package/es/components/Pagination/Pagination.js +22 -5
- 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/Search/Search.js +1 -1
- package/es/components/Select/Select.js +1 -1
- package/es/components/Slider/Slider.js +1 -1
- package/es/components/StructuredList/StructuredList.d.ts +5 -5
- package/es/components/StructuredList/StructuredList.js +1 -1
- package/es/components/Tabs/Tabs.d.ts +1 -1
- package/es/components/Tabs/Tabs.js +1 -1
- package/es/components/Tag/DismissibleTag.js +1 -1
- package/es/components/Tag/Tag.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextInput/ControlledPasswordInput.js +1 -1
- package/es/components/TextInput/PasswordInput.js +1 -1
- package/es/components/TextInput/TextInput.js +1 -1
- package/es/components/Tile/Tile.js +1 -1
- package/es/components/TileGroup/TileGroup.d.ts +5 -5
- package/es/components/TimePicker/TimePicker.d.ts +8 -0
- package/es/components/TimePicker/TimePicker.js +6 -4
- package/es/components/Tooltip/DefinitionTooltip.d.ts +1 -1
- package/es/components/Tooltip/DefinitionTooltip.js +1 -1
- package/es/components/TreeView/TreeContext.d.ts +19 -0
- package/es/components/TreeView/TreeContext.js +13 -0
- package/es/components/TreeView/TreeNode.d.ts +4 -4
- package/es/components/TreeView/TreeNode.js +56 -108
- package/es/components/TreeView/TreeView.js +42 -79
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/HeaderMenuItem.d.ts +1 -1
- package/es/components/UIShell/HeaderMenuItem.js +1 -1
- package/es/components/UIShell/HeaderName.d.ts +1 -1
- package/es/components/UIShell/HeaderPanel.js +5 -7
- package/es/components/UIShell/Link.d.ts +2 -2
- package/es/components/UIShell/Link.js +1 -1
- package/es/components/UIShell/Switcher.d.ts +1 -1
- package/es/components/UIShell/Switcher.js +39 -12
- package/es/index.js +1 -1
- package/es/internal/useNoInteractiveChildren.d.ts +25 -0
- package/es/internal/useNoInteractiveChildren.js +39 -32
- package/es/prop-types/deprecate.d.ts +17 -0
- package/es/prop-types/deprecate.js +22 -12
- package/lib/components/AILabel/index.js +2 -2
- package/lib/components/Accordion/AccordionItem.d.ts +1 -1
- package/lib/components/Accordion/AccordionItem.js +1 -1
- package/lib/components/Checkbox/Checkbox.js +1 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
- package/lib/components/CodeSnippet/CodeSnippet.d.ts +2 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +2 -2
- package/lib/components/ComboBox/ComboBox.js +3 -3
- package/lib/components/ComposedModal/ComposedModal.js +1 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
- package/lib/components/DataTable/DataTable.d.ts +230 -170
- package/lib/components/DataTable/DataTable.js +507 -518
- package/lib/components/DataTable/TableContainer.d.ts +9 -1
- package/lib/components/DataTable/TableContainer.js +7 -1
- package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
- package/lib/components/DataTable/TableExpandHeader.js +1 -1
- package/lib/components/DataTable/TableSelectAll.d.ts +2 -2
- package/lib/components/DataTable/TableSelectAll.js +1 -1
- package/lib/components/DataTable/TableSelectRow.d.ts +2 -2
- package/lib/components/DataTable/TableSelectRow.js +1 -1
- package/lib/components/DataTable/TableToolbar.d.ts +1 -1
- package/lib/components/DataTable/TableToolbar.js +1 -1
- package/lib/components/DataTable/TableToolbarMenu.d.ts +2 -18
- package/lib/components/DataTable/TableToolbarMenu.js +0 -1
- package/lib/components/DataTable/index.d.ts +1 -1
- package/lib/components/DataTable/state/getDerivedStateFromProps.js +5 -1
- package/lib/components/DatePicker/DatePicker.js +1 -1
- package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
- package/lib/components/Dropdown/Dropdown.js +3 -3
- package/lib/components/FeatureFlags/index.d.ts +2 -2
- package/lib/components/FeatureFlags/index.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +1 -1
- package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +2 -2
- package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
- package/lib/components/FluidTextArea/FluidTextArea.d.ts +1 -1
- package/lib/components/FluidTextArea/FluidTextArea.js +1 -1
- package/lib/components/InlineCheckbox/InlineCheckbox.js +1 -1
- package/lib/components/ListBox/ListBox.js +1 -1
- package/lib/components/Loading/Loading.d.ts +1 -1
- package/lib/components/Loading/Loading.js +1 -1
- package/lib/components/Menu/Menu.js +1 -1
- package/lib/components/Modal/Modal.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +4 -4
- package/lib/components/MultiSelect/MultiSelect.js +2 -2
- package/lib/components/Notification/Notification.d.ts +4 -4
- package/lib/components/Notification/Notification.js +4 -4
- package/lib/components/NumberInput/NumberInput.d.ts +7 -0
- package/lib/components/NumberInput/NumberInput.js +81 -26
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +2 -6
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
- package/lib/components/Pagination/Pagination.js +21 -4
- package/lib/components/RadioButton/RadioButton.js +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
- package/lib/components/RadioTile/RadioTile.js +2 -2
- package/lib/components/Search/Search.js +1 -1
- package/lib/components/Select/Select.js +2 -2
- package/lib/components/Slider/Slider.js +1 -1
- package/lib/components/StructuredList/StructuredList.d.ts +5 -5
- package/lib/components/StructuredList/StructuredList.js +4 -4
- package/lib/components/Tabs/Tabs.d.ts +1 -1
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/components/Tag/DismissibleTag.js +1 -1
- package/lib/components/Tag/Tag.js +4 -4
- package/lib/components/TextArea/TextArea.js +2 -2
- package/lib/components/TextInput/ControlledPasswordInput.js +1 -1
- package/lib/components/TextInput/PasswordInput.js +1 -1
- package/lib/components/TextInput/TextInput.js +2 -2
- package/lib/components/Tile/Tile.js +9 -9
- package/lib/components/TileGroup/TileGroup.d.ts +5 -5
- package/lib/components/TimePicker/TimePicker.d.ts +8 -0
- package/lib/components/TimePicker/TimePicker.js +6 -4
- package/lib/components/Tooltip/DefinitionTooltip.d.ts +1 -1
- package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
- package/lib/components/TreeView/TreeContext.d.ts +19 -0
- package/lib/components/TreeView/TreeContext.js +18 -0
- package/lib/components/TreeView/TreeNode.d.ts +4 -4
- package/lib/components/TreeView/TreeNode.js +55 -107
- package/lib/components/TreeView/TreeView.js +41 -78
- package/lib/components/UIShell/HeaderMenu.js +1 -1
- package/lib/components/UIShell/HeaderMenuItem.d.ts +1 -1
- package/lib/components/UIShell/HeaderMenuItem.js +1 -1
- package/lib/components/UIShell/HeaderName.d.ts +1 -1
- package/lib/components/UIShell/HeaderPanel.js +5 -7
- package/lib/components/UIShell/Link.d.ts +2 -2
- package/lib/components/UIShell/Link.js +1 -1
- package/lib/components/UIShell/Switcher.d.ts +1 -1
- package/lib/components/UIShell/Switcher.js +38 -11
- package/lib/index.js +1 -1
- package/lib/internal/useNoInteractiveChildren.d.ts +25 -0
- package/lib/internal/useNoInteractiveChildren.js +39 -32
- package/lib/prop-types/deprecate.d.ts +17 -0
- package/lib/prop-types/deprecate.js +22 -12
- package/package.json +3 -3
- package/telemetry.yml +15 -14
|
@@ -6,13 +6,40 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React, { forwardRef, useRef } from 'react';
|
|
9
|
+
import React, { forwardRef, useRef, Children, isValidElement, cloneElement } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
12
12
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
15
|
+
import './Content.js';
|
|
16
|
+
import './Header.js';
|
|
17
|
+
import './HeaderContainer.js';
|
|
18
|
+
import './HeaderGlobalAction.js';
|
|
19
|
+
import './HeaderGlobalBar.js';
|
|
20
|
+
import './HeaderMenu.js';
|
|
21
|
+
import './HeaderMenuButton.js';
|
|
22
|
+
import './HeaderMenuItem.js';
|
|
23
|
+
import './HeaderName.js';
|
|
24
|
+
import './HeaderNavigation.js';
|
|
25
|
+
import './HeaderPanel.js';
|
|
26
|
+
import './HeaderSideNavItems.js';
|
|
15
27
|
import SwitcherItem from './SwitcherItem.js';
|
|
28
|
+
import SwitcherDivider from './SwitcherDivider.js';
|
|
29
|
+
import './SkipToContent.js';
|
|
30
|
+
import './SideNav.js';
|
|
31
|
+
import './SideNavDetails.js';
|
|
32
|
+
import './SideNavDivider.js';
|
|
33
|
+
import './SideNavFooter.js';
|
|
34
|
+
import './SideNavHeader.js';
|
|
35
|
+
import './SideNavIcon.js';
|
|
36
|
+
import './SideNavItem.js';
|
|
37
|
+
import './SideNavItems.js';
|
|
38
|
+
import './SideNavLink.js';
|
|
39
|
+
import './SideNavLinkText.js';
|
|
40
|
+
import './SideNavMenu.js';
|
|
41
|
+
import './SideNavMenuItem.js';
|
|
42
|
+
import './SideNavSwitcher.js';
|
|
16
43
|
|
|
17
44
|
const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
|
|
18
45
|
const switcherRef = useRef(null);
|
|
@@ -36,8 +63,8 @@ const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
|
|
|
36
63
|
currentIndex,
|
|
37
64
|
direction
|
|
38
65
|
}) => {
|
|
39
|
-
const enabledIndices =
|
|
40
|
-
if (/*#__PURE__*/
|
|
66
|
+
const enabledIndices = Children.toArray(children).reduce((acc, child, i) => {
|
|
67
|
+
if (/*#__PURE__*/isValidElement(child) && child.type === SwitcherItem && Object.keys(child.props).length) {
|
|
41
68
|
acc.push(i);
|
|
42
69
|
}
|
|
43
70
|
return acc;
|
|
@@ -63,21 +90,21 @@ const Switcher = /*#__PURE__*/forwardRef(function Switcher(props, forwardRef) {
|
|
|
63
90
|
switcherItem.focus();
|
|
64
91
|
}
|
|
65
92
|
};
|
|
66
|
-
const childrenWithProps =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
93
|
+
const childrenWithProps = Children.toArray(children).map((child, index) => {
|
|
94
|
+
if (/*#__PURE__*/isValidElement(child) && child.type === SwitcherItem) {
|
|
95
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
70
96
|
handleSwitcherItemFocus,
|
|
71
97
|
index,
|
|
72
98
|
key: index,
|
|
73
99
|
expanded
|
|
74
100
|
});
|
|
75
101
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
102
|
+
if (/*#__PURE__*/isValidElement(child) && child.type === SwitcherDivider) {
|
|
103
|
+
return /*#__PURE__*/cloneElement(child, {
|
|
104
|
+
key: index
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return child;
|
|
81
108
|
});
|
|
82
109
|
return /*#__PURE__*/React.createElement("ul", _extends({
|
|
83
110
|
ref: ref,
|
package/es/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export { default as useContextMenu } from './components/ContextMenu/useContextMe
|
|
|
33
33
|
export { default as Copy } from './components/Copy/Copy.js';
|
|
34
34
|
export { default as CopyButton } from './components/CopyButton/CopyButton.js';
|
|
35
35
|
export { default as DangerButton } from './components/DangerButton/DangerButton.js';
|
|
36
|
-
export {
|
|
36
|
+
export { DataTable } from './components/DataTable/DataTable.js';
|
|
37
37
|
export { Table } from './components/DataTable/Table.js';
|
|
38
38
|
export { default as TableActionList } from './components/DataTable/TableActionList.js';
|
|
39
39
|
export { default as TableBatchAction } from './components/DataTable/TableBatchAction.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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
|
+
import { type RefObject } from 'react';
|
|
8
|
+
export declare const useNoInteractiveChildren: (ref: RefObject<HTMLElement | null>, message?: string) => void;
|
|
9
|
+
export declare const useInteractiveChildrenNeedDescription: (ref: RefObject<HTMLElement | null>, message?: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Determines if a given DOM node has interactive content, or is itself
|
|
12
|
+
* interactive. It returns the interactive node if one is found.
|
|
13
|
+
*
|
|
14
|
+
* @param node - The node to check.
|
|
15
|
+
* @returns The interactive node, or `null` if none is found.
|
|
16
|
+
*/
|
|
17
|
+
export declare const getInteractiveContent: (node: HTMLElement) => HTMLElement | null;
|
|
18
|
+
/**
|
|
19
|
+
* Determines if a given DOM node has a `role`, or has itself a `role`.
|
|
20
|
+
* It returns the node with a `role` if one is found.
|
|
21
|
+
*
|
|
22
|
+
* @param node - The node to check.
|
|
23
|
+
* @returns The node with a `role`, or `null` if none is found.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getRoleContent: (node: HTMLElement) => HTMLElement | null;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import { useEffect } from 'react';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const useNoInteractiveChildren = (ref, message = 'component should have no interactive child nodes') => {
|
|
11
|
+
// TODO: Why can't the condition go inside the hook?
|
|
11
12
|
if (process.env.NODE_ENV !== 'production') {
|
|
12
13
|
// TODO: https://github.com/carbon-design-system/carbon/issues/19005
|
|
13
14
|
/*
|
|
@@ -17,14 +18,14 @@ function useNoInteractiveChildren(ref, message = 'component should have no inter
|
|
|
17
18
|
const node = ref.current ? getInteractiveContent(ref.current) : false;
|
|
18
19
|
if (node) {
|
|
19
20
|
const errorMessage = `Error: ${message}.\n\nInstead found: ${node.outerHTML}`;
|
|
20
|
-
// eslint-disable-next-line no-console
|
|
21
21
|
console.error(errorMessage);
|
|
22
22
|
throw new Error(errorMessage);
|
|
23
23
|
}
|
|
24
24
|
}, []);
|
|
25
25
|
}
|
|
26
|
-
}
|
|
27
|
-
|
|
26
|
+
};
|
|
27
|
+
const useInteractiveChildrenNeedDescription = (ref, message = `interactive child node(s) should have an \`aria-describedby\` property`) => {
|
|
28
|
+
// TODO: Why can't the condition go inside the hook?
|
|
28
29
|
if (process.env.NODE_ENV !== 'production') {
|
|
29
30
|
// TODO: https://github.com/carbon-design-system/carbon/issues/19005
|
|
30
31
|
/*
|
|
@@ -37,16 +38,16 @@ function useInteractiveChildrenNeedDescription(ref, message = `interactive child
|
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
}
|
|
41
|
+
};
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Determines if a given DOM node has interactive content, or is itself
|
|
44
|
-
* interactive. It returns the interactive node if one is found
|
|
45
|
+
* interactive. It returns the interactive node if one is found.
|
|
45
46
|
*
|
|
46
|
-
* @param
|
|
47
|
-
* @returns
|
|
47
|
+
* @param node - The node to check.
|
|
48
|
+
* @returns The interactive node, or `null` if none is found.
|
|
48
49
|
*/
|
|
49
|
-
|
|
50
|
+
const getInteractiveContent = node => {
|
|
50
51
|
if (!node || !node.childNodes) {
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
@@ -54,59 +55,65 @@ function getInteractiveContent(node) {
|
|
|
54
55
|
return node;
|
|
55
56
|
}
|
|
56
57
|
for (const childNode of node.childNodes) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
if (childNode instanceof HTMLElement) {
|
|
59
|
+
const interactiveNode = getInteractiveContent(childNode);
|
|
60
|
+
if (interactiveNode) {
|
|
61
|
+
return interactiveNode;
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
return null;
|
|
63
|
-
}
|
|
66
|
+
};
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
|
-
* Determines if a given DOM node has a role
|
|
67
|
-
* It returns the node with a role if one is found
|
|
69
|
+
* Determines if a given DOM node has a `role`, or has itself a `role`.
|
|
70
|
+
* It returns the node with a `role` if one is found.
|
|
68
71
|
*
|
|
69
|
-
* @param
|
|
70
|
-
* @returns
|
|
72
|
+
* @param node - The node to check.
|
|
73
|
+
* @returns The node with a `role`, or `null` if none is found.
|
|
71
74
|
*/
|
|
72
|
-
|
|
75
|
+
const getRoleContent = node => {
|
|
73
76
|
if (!node || !node.childNodes) {
|
|
74
77
|
return null;
|
|
75
78
|
}
|
|
76
|
-
if (node
|
|
79
|
+
if (node.getAttribute('role') && node.getAttribute('role') !== '') {
|
|
77
80
|
return node;
|
|
78
81
|
}
|
|
79
82
|
for (const childNode of node.childNodes) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
if (childNode instanceof HTMLElement) {
|
|
84
|
+
const roleNode = getRoleContent(childNode);
|
|
85
|
+
if (roleNode) {
|
|
86
|
+
return roleNode;
|
|
87
|
+
}
|
|
83
88
|
}
|
|
84
89
|
}
|
|
85
90
|
return null;
|
|
86
|
-
}
|
|
91
|
+
};
|
|
87
92
|
|
|
88
93
|
/**
|
|
89
|
-
* Determines if the given element is focusable
|
|
94
|
+
* Determines if the given element is focusable.
|
|
90
95
|
*
|
|
91
|
-
* @param
|
|
92
|
-
* @returns
|
|
96
|
+
* @param element - The element to check.
|
|
97
|
+
* @returns Whether the element is focusable.
|
|
93
98
|
* @see https://github.com/w3c/aria-practices/blob/0553bb51588ffa517506e2a1b2ca1422ed438c5f/examples/js/utils.js#L68
|
|
94
99
|
*/
|
|
95
|
-
|
|
100
|
+
const isFocusable = element => {
|
|
96
101
|
if (element.tabIndex === undefined || element.tabIndex < 0) {
|
|
97
102
|
return false;
|
|
98
103
|
}
|
|
99
|
-
if (element
|
|
100
|
-
|
|
104
|
+
if (element instanceof HTMLButtonElement || element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) {
|
|
105
|
+
if (element.disabled) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
101
108
|
}
|
|
102
109
|
switch (element.nodeName) {
|
|
103
110
|
case 'A':
|
|
104
|
-
return !!element.href && element.rel !== 'ignore';
|
|
111
|
+
return element instanceof HTMLAnchorElement && !!element.href && element.rel !== 'ignore';
|
|
105
112
|
case 'INPUT':
|
|
106
|
-
return element.type !== 'hidden';
|
|
113
|
+
return element instanceof HTMLInputElement && element.type !== 'hidden';
|
|
107
114
|
default:
|
|
108
115
|
return true;
|
|
109
116
|
}
|
|
110
|
-
}
|
|
117
|
+
};
|
|
111
118
|
|
|
112
119
|
export { getInteractiveContent, getRoleContent, useInteractiveChildrenNeedDescription, useNoInteractiveChildren };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2025
|
|
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
|
+
type PropValidator = (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a prop-type validator with a deprecation warning.
|
|
10
|
+
*
|
|
11
|
+
* @param propType - The original prop validator function.
|
|
12
|
+
* @param message - Deprecation message.
|
|
13
|
+
* @returns A new validator function that emits a warning the first time a
|
|
14
|
+
* deprecated prop is used.
|
|
15
|
+
*/
|
|
16
|
+
export declare const deprecate: (propType: PropValidator, message?: string) => PropValidator;
|
|
17
|
+
export {};
|
|
@@ -7,22 +7,32 @@
|
|
|
7
7
|
|
|
8
8
|
import { warning } from '../internal/warning.js';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const warningCache = new Map();
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Wraps a prop-type validator with a deprecation warning.
|
|
14
|
+
*
|
|
15
|
+
* @param propType - The original prop validator function.
|
|
16
|
+
* @param message - Deprecation message.
|
|
17
|
+
* @returns A new validator function that emits a warning the first time a
|
|
18
|
+
* deprecated prop is used.
|
|
19
|
+
*/
|
|
20
|
+
const deprecate = (propType, message) => {
|
|
21
|
+
const checker = (props, propName, componentName, ...rest) => {
|
|
22
|
+
if (typeof props[propName] === 'undefined') {
|
|
14
23
|
return;
|
|
15
24
|
}
|
|
16
|
-
if (!
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
if (!warningCache.has(componentName)) {
|
|
26
|
+
warningCache.set(componentName, new Set());
|
|
27
|
+
}
|
|
28
|
+
const warnedProps = warningCache.get(componentName);
|
|
29
|
+
if (warnedProps && !warnedProps.has(propName)) {
|
|
30
|
+
warnedProps.add(propName);
|
|
21
31
|
process.env.NODE_ENV !== "production" ? warning(false, message || `The prop \`${propName}\` has been deprecated for the ` + `${componentName} component. It will be removed in the next major ` + `release`) : void 0;
|
|
22
32
|
}
|
|
23
33
|
return propType(props, propName, componentName, ...rest);
|
|
24
|
-
}
|
|
34
|
+
};
|
|
25
35
|
return checker;
|
|
26
|
-
}
|
|
36
|
+
};
|
|
27
37
|
|
|
28
|
-
export { deprecate
|
|
38
|
+
export { deprecate };
|
|
@@ -165,7 +165,7 @@ AILabel.propTypes = {
|
|
|
165
165
|
* @deprecated
|
|
166
166
|
* Specify additional text to be rendered next to the AI label in the inline variant
|
|
167
167
|
*/
|
|
168
|
-
aiTextLabel: deprecate
|
|
168
|
+
aiTextLabel: deprecate.deprecate(PropTypes__default["default"].string, '`aiTextLabel` on `AILabel` has been deprecated - Please use the `textLabel` prop instead'),
|
|
169
169
|
/**
|
|
170
170
|
* Specify how the popover should align with the button
|
|
171
171
|
*/
|
|
@@ -231,7 +231,7 @@ AILabel.propTypes = {
|
|
|
231
231
|
* @deprecated
|
|
232
232
|
* Specify the text that will be provided to the aria-label of the `AILabel` button
|
|
233
233
|
*/
|
|
234
|
-
slugLabel: deprecate
|
|
234
|
+
slugLabel: deprecate.deprecate(PropTypes__default["default"].string, '`slugLabel` on `AILabel` has been deprecated - Please use the `ariaLabel` prop instead'),
|
|
235
235
|
/**
|
|
236
236
|
* Specify additional text to be rendered next to the AI label in the inline variant
|
|
237
237
|
*/
|
|
@@ -90,7 +90,7 @@ declare namespace AccordionItem {
|
|
|
90
90
|
* The callback function to render the expand button.
|
|
91
91
|
* Can be a React component class.
|
|
92
92
|
*/
|
|
93
|
-
renderExpando: (props:
|
|
93
|
+
renderExpando: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
|
|
94
94
|
/**
|
|
95
95
|
* The callback function to render the expand button.
|
|
96
96
|
* Can be a React component class.
|
|
@@ -153,7 +153,7 @@ AccordionItem.propTypes = {
|
|
|
153
153
|
* The callback function to render the expand button.
|
|
154
154
|
* Can be a React component class.
|
|
155
155
|
*/
|
|
156
|
-
renderExpando: deprecate
|
|
156
|
+
renderExpando: deprecate.deprecate(PropTypes__default["default"].func, 'The `renderExpando` prop has been deprecated and will be removed in the next major release of Carbon. Use the `renderToggle` prop instead.'),
|
|
157
157
|
/**
|
|
158
158
|
* The callback function to render the expand button.
|
|
159
159
|
* Can be a React component class.
|
|
@@ -194,7 +194,7 @@ Checkbox.propTypes = {
|
|
|
194
194
|
/**
|
|
195
195
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `Checkbox` component
|
|
196
196
|
*/
|
|
197
|
-
slug: deprecate
|
|
197
|
+
slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
|
|
198
198
|
/**
|
|
199
199
|
* Specify a title for the <label> node for the Checkbox
|
|
200
200
|
*/
|
|
@@ -135,7 +135,7 @@ CheckboxGroup.propTypes = {
|
|
|
135
135
|
/**
|
|
136
136
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `CheckboxGroup` component
|
|
137
137
|
*/
|
|
138
|
-
slug: deprecate
|
|
138
|
+
slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
|
|
139
139
|
/**
|
|
140
140
|
* Specify whether the form group is currently in warning state
|
|
141
141
|
*/
|
|
@@ -120,7 +120,7 @@ declare namespace CodeSnippet {
|
|
|
120
120
|
* Specify a label to be read by screen readers on the containing textbox
|
|
121
121
|
* node
|
|
122
122
|
*/
|
|
123
|
-
ariaLabel: (props:
|
|
123
|
+
ariaLabel: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
|
|
124
124
|
/**
|
|
125
125
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
126
126
|
*/
|
|
@@ -162,7 +162,7 @@ declare namespace CodeSnippet {
|
|
|
162
162
|
* Specify whether you are using the light variant of the Code Snippet,
|
|
163
163
|
* typically used for inline snippet to display an alternate color
|
|
164
164
|
*/
|
|
165
|
-
light: (props:
|
|
165
|
+
light: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
|
|
166
166
|
/**
|
|
167
167
|
* Specify the maximum number of rows to be shown when in collapsed view
|
|
168
168
|
*/
|
|
@@ -276,7 +276,7 @@ CodeSnippet.propTypes = {
|
|
|
276
276
|
* Specify a label to be read by screen readers on the containing textbox
|
|
277
277
|
* node
|
|
278
278
|
*/
|
|
279
|
-
ariaLabel: deprecate
|
|
279
|
+
ariaLabel: deprecate.deprecate(PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
|
|
280
280
|
/**
|
|
281
281
|
* **Experimental**: Will attempt to automatically align the tooltip
|
|
282
282
|
*/
|
|
@@ -319,7 +319,7 @@ CodeSnippet.propTypes = {
|
|
|
319
319
|
* typically used for inline snippet to display an alternate color
|
|
320
320
|
*/
|
|
321
321
|
|
|
322
|
-
light: deprecate
|
|
322
|
+
light: deprecate.deprecate(PropTypes__default["default"].bool, 'The `light` prop for `CodeSnippet` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
|
|
323
323
|
/**
|
|
324
324
|
* Specify the maximum number of rows to be shown when in collapsed view
|
|
325
325
|
*/
|
|
@@ -781,7 +781,7 @@ ComboBox.propTypes = {
|
|
|
781
781
|
* Specify a label to be read by screen readers on the container note.
|
|
782
782
|
* 'aria-label' of the ListBox component.
|
|
783
783
|
*/
|
|
784
|
-
ariaLabel: deprecate
|
|
784
|
+
ariaLabel: deprecate.deprecate(PropTypes__default["default"].string, 'This prop syntax has been deprecated. Please use the new `aria-label`.'),
|
|
785
785
|
/**
|
|
786
786
|
* **Experimental**: Will attempt to automatically align the floating
|
|
787
787
|
* element to avoid collisions with the viewport and being clipped by
|
|
@@ -868,7 +868,7 @@ ComboBox.propTypes = {
|
|
|
868
868
|
/**
|
|
869
869
|
* should use "light theme" (white background)?
|
|
870
870
|
*/
|
|
871
|
-
light: deprecate
|
|
871
|
+
light: deprecate.deprecate(PropTypes__default["default"].bool, 'The `light` prop for `Combobox` has ' + 'been deprecated in favor of the new `Layer` component. It will be removed in the next major release.'),
|
|
872
872
|
/**
|
|
873
873
|
* `onChange` is a utility for this controlled component to communicate to a
|
|
874
874
|
* consuming component when a specific dropdown item is selected.
|
|
@@ -913,7 +913,7 @@ ComboBox.propTypes = {
|
|
|
913
913
|
* Specify the size of the ListBox. Currently supports either `sm`, `md` or `lg` as an option.
|
|
914
914
|
*/
|
|
915
915
|
size: ListBoxPropTypes.ListBoxSizePropType,
|
|
916
|
-
slug: deprecate
|
|
916
|
+
slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop has been deprecated and will be removed in the next major version. Use the decorator prop instead.'),
|
|
917
917
|
/**
|
|
918
918
|
* Provide text to be used in a `<label>` element that is tied to the
|
|
919
919
|
* combobox via ARIA attributes.
|
|
@@ -416,7 +416,7 @@ ComposedModal.propTypes = {
|
|
|
416
416
|
* Specify the size variant.
|
|
417
417
|
*/
|
|
418
418
|
size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg']),
|
|
419
|
-
slug: deprecate
|
|
419
|
+
slug: deprecate.deprecate(PropTypes__default["default"].node, 'The `slug` prop for `ComposedModal` has ' + 'been deprecated in favor of the new `decorator` prop. It will be removed in the next major release.')
|
|
420
420
|
};
|
|
421
421
|
|
|
422
422
|
exports.ModalBody = ModalBody;
|
|
@@ -65,7 +65,7 @@ export declare const ContentSwitcher: {
|
|
|
65
65
|
/**
|
|
66
66
|
* `true` to use the light variant.
|
|
67
67
|
*/
|
|
68
|
-
light: (props:
|
|
68
|
+
light: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
|
|
69
69
|
/**
|
|
70
70
|
* `true` to use the low contrast version.
|
|
71
71
|
*/
|
|
@@ -134,7 +134,7 @@ ContentSwitcher.propTypes = {
|
|
|
134
134
|
/**
|
|
135
135
|
* `true` to use the light variant.
|
|
136
136
|
*/
|
|
137
|
-
light: deprecate
|
|
137
|
+
light: deprecate.deprecate(PropTypes__default["default"].bool, 'The `light` prop for `ContentSwitcher` is no longer needed and has ' + 'been deprecated. It will be removed in the next major release.'),
|
|
138
138
|
/**
|
|
139
139
|
* `true` to use the low contrast version.
|
|
140
140
|
*/
|