@carbon/react 1.102.0 → 1.103.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 +973 -973
- package/es/components/Breadcrumb/BreadcrumbItem.js +1 -1
- package/es/components/Button/Button.Skeleton.js +2 -1
- package/es/components/Button/Button.d.ts +4 -4
- package/es/components/Button/Button.js +4 -4
- package/es/components/Button/index.js +1 -1
- package/es/components/ButtonSet/ButtonSet.js +1 -1
- package/es/components/Checkbox/index.js +1 -1
- package/es/components/ComboBox/ComboBox.js +2 -2
- package/es/components/ComposedModal/ComposedModal.js +0 -3
- package/es/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
- package/es/components/ComposedModal/ComposedModalPresence.js +14 -1
- package/es/components/ComposedModal/index.d.ts +1 -1
- package/es/components/ContainedList/index.js +1 -1
- package/es/components/DataTable/TableHeader.js +1 -1
- package/es/components/DataTable/TableRow.js +1 -1
- package/es/components/DataTable/TableToolbarMenu.js +1 -1
- package/es/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
- package/es/components/DatePicker/DatePicker.Skeleton.js +2 -2
- package/es/components/DatePicker/index.js +1 -1
- package/es/components/DatePickerInput/DatePickerInput.js +1 -1
- package/es/components/Dialog/Dialog.js +1 -1
- package/es/components/Dropdown/index.js +1 -1
- package/es/components/ExpandableSearch/ExpandableSearch.js +1 -1
- package/es/components/FeatureFlags/index.d.ts +8 -18
- package/es/components/FeatureFlags/index.js +23 -103
- package/es/components/FileUploader/FileUploader.Skeleton.js +1 -1
- package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/es/components/FileUploader/FileUploaderButton.js +3 -7
- package/es/components/Icon/Icon.Skeleton.js +1 -1
- package/es/components/IconIndicator/index.js +1 -1
- package/es/components/Menu/MenuItem.js +1 -1
- package/es/components/Modal/ModalPresence.d.ts +9 -1
- package/es/components/Modal/ModalPresence.js +14 -1
- package/es/components/Modal/index.d.ts +2 -2
- package/es/components/MultiSelect/MultiSelect.js +9 -10
- package/es/components/Notification/Notification.js +1 -1
- package/es/components/NumberInput/NumberInput.js +15 -13
- package/es/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +3 -5
- package/es/components/OverflowMenuV2/index.js +1 -1
- package/es/components/PageHeader/PageHeader.js +2 -23
- package/es/components/Pagination/Pagination.Skeleton.js +1 -1
- package/es/components/Pagination/Pagination.d.ts +4 -0
- package/es/components/Pagination/Pagination.js +6 -1
- package/es/components/Pagination/experimental/Pagination.js +12 -1
- package/es/components/Popover/index.js +1 -1
- package/es/components/RadioButton/RadioButton.Skeleton.js +1 -1
- package/es/components/Search/index.js +1 -1
- package/es/components/Select/index.js +1 -1
- package/es/components/ShapeIndicator/index.js +1 -1
- package/es/components/Slider/Slider.js +230 -249
- package/es/components/Slider/SliderHandles.js +65 -53
- package/es/components/Switch/IconSwitch.js +1 -1
- package/es/components/Tabs/Tabs.js +2 -6
- package/es/components/Tag/Tag.Skeleton.js +1 -1
- package/es/components/TextArea/TextArea.js +1 -1
- package/es/components/TextArea/index.js +1 -1
- package/es/components/TextInput/index.js +1 -1
- package/es/components/Tile/Tile.js +1 -1
- package/es/components/Toggle/Toggle.Skeleton.js +1 -1
- package/es/components/Toggletip/index.js +1 -1
- package/es/components/UIShell/HeaderMenu.js +1 -1
- package/es/components/UIShell/SideNav.d.ts +1 -4
- package/es/components/UIShell/SideNav.js +10 -25
- package/es/components/UIShell/SideNavContext.d.ts +17 -0
- package/es/components/UIShell/SideNavContext.js +24 -0
- package/es/components/UIShell/SideNavItems.d.ts +1 -1
- package/es/components/UIShell/SideNavItems.js +12 -16
- package/es/components/UIShell/SideNavLink.js +8 -4
- package/es/components/UIShell/SideNavMenu.js +7 -5
- package/es/index.js +30 -30
- package/es/internal/useNoInteractiveChildren.js +25 -30
- package/es/internal/usePresence.d.ts +1 -1
- package/es/internal/usePresence.js +14 -17
- package/lib/components/Button/Button.Skeleton.js +2 -1
- package/lib/components/Button/Button.d.ts +4 -4
- package/lib/components/Button/Button.js +4 -4
- package/lib/components/Button/index.js +1 -1
- package/lib/components/ButtonSet/ButtonSet.js +1 -1
- package/lib/components/Checkbox/index.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +2 -2
- package/lib/components/ComposedModal/ComposedModal.js +0 -3
- package/lib/components/ComposedModal/ComposedModalPresence.d.ts +9 -1
- package/lib/components/ComposedModal/ComposedModalPresence.js +14 -0
- package/lib/components/ComposedModal/index.d.ts +1 -1
- package/lib/components/ContainedList/index.js +0 -3
- package/lib/components/DataTable/TableToolbarMenu.js +1 -1
- package/lib/components/DatePicker/DatePicker.Skeleton.d.ts +8 -5
- package/lib/components/DatePicker/DatePicker.Skeleton.js +2 -2
- package/lib/components/DatePicker/index.js +1 -1
- package/lib/components/Dropdown/index.js +1 -1
- package/lib/components/FeatureFlags/index.d.ts +8 -18
- package/lib/components/FeatureFlags/index.js +21 -102
- package/lib/components/FileUploader/FileUploader.Skeleton.js +1 -1
- package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
- package/lib/components/FileUploader/FileUploaderButton.js +2 -6
- package/lib/components/Icon/Icon.Skeleton.js +0 -3
- package/lib/components/IconIndicator/index.js +0 -3
- package/lib/components/Modal/ModalPresence.d.ts +9 -1
- package/lib/components/Modal/ModalPresence.js +14 -0
- package/lib/components/Modal/index.d.ts +2 -2
- package/lib/components/MultiSelect/MultiSelect.js +8 -9
- package/lib/components/NumberInput/NumberInput.js +14 -12
- package/lib/components/OverflowMenu/OverflowMenu.d.ts +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +2 -7
- package/lib/components/OverflowMenuV2/index.js +1 -1
- package/lib/components/PageHeader/PageHeader.js +2 -23
- package/lib/components/Pagination/Pagination.Skeleton.js +0 -3
- package/lib/components/Pagination/Pagination.d.ts +4 -0
- package/lib/components/Pagination/Pagination.js +6 -1
- package/lib/components/Pagination/experimental/Pagination.js +12 -1
- package/lib/components/RadioButton/RadioButton.Skeleton.js +0 -3
- package/lib/components/Search/index.js +1 -1
- package/lib/components/Select/index.js +1 -1
- package/lib/components/ShapeIndicator/index.js +0 -3
- package/lib/components/Slider/Slider.js +229 -248
- package/lib/components/Slider/SliderHandles.js +64 -52
- package/lib/components/Tabs/Tabs.js +1 -5
- package/lib/components/Tag/Tag.Skeleton.js +0 -3
- package/lib/components/TextArea/index.js +1 -1
- package/lib/components/TextInput/index.js +1 -1
- package/lib/components/Toggle/Toggle.Skeleton.js +0 -3
- package/lib/components/Toggletip/index.js +0 -3
- package/lib/components/UIShell/SideNav.d.ts +1 -4
- package/lib/components/UIShell/SideNav.js +8 -24
- package/lib/components/UIShell/SideNavContext.d.ts +17 -0
- package/lib/components/UIShell/SideNavContext.js +27 -0
- package/lib/components/UIShell/SideNavItems.d.ts +1 -1
- package/lib/components/UIShell/SideNavItems.js +11 -15
- package/lib/components/UIShell/SideNavLink.js +7 -3
- package/lib/components/UIShell/SideNavMenu.js +8 -6
- package/lib/index.js +102 -100
- package/lib/internal/useNoInteractiveChildren.js +25 -30
- package/lib/internal/usePresence.d.ts +1 -1
- package/lib/internal/usePresence.js +13 -16
- package/package.json +5 -5
- package/telemetry.yml +2 -1
- package/es/components/UIShell/_utils.d.ts +0 -7
- package/es/components/UIShell/_utils.js +0 -10
- package/lib/components/UIShell/_utils.d.ts +0 -7
- package/lib/components/UIShell/_utils.js +0 -12
|
@@ -6,61 +6,73 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import {
|
|
9
|
+
import { usePrefix } from '../../internal/usePrefix.js';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
|
|
12
12
|
var _path, _path2, _path3, _path4, _path5, _path6, _path7, _path8, _path9, _path0, _path1, _path10, _path11, _path12;
|
|
13
|
-
const LowerHandle = props =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
})),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})
|
|
13
|
+
const LowerHandle = props => {
|
|
14
|
+
const prefix = usePrefix();
|
|
15
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
16
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
17
|
+
viewBox: "0 0 16 24",
|
|
18
|
+
className: `${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--lower`
|
|
19
|
+
}, props), _path || (_path = /*#__PURE__*/React.createElement("path", {
|
|
20
|
+
d: "M15.08 6.46H16v11.08h-.92zM4.46 17.54c-.25 0-.46-.21-.46-.46V6.92a.465.465 0 0 1 .69-.4l8.77 5.08a.46.46 0 0 1 0 .8l-8.77 5.08c-.07.04-.15.06-.23.06Z"
|
|
21
|
+
})), _path2 || (_path2 = /*#__PURE__*/React.createElement("path", {
|
|
22
|
+
fill: "none",
|
|
23
|
+
d: "M-4 0h24v24H-4z"
|
|
24
|
+
})));
|
|
25
|
+
};
|
|
26
|
+
const LowerHandleFocus = props => {
|
|
27
|
+
const prefix = usePrefix();
|
|
28
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
29
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
30
|
+
viewBox: "0 0 16 24",
|
|
31
|
+
className: `${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--lower ${prefix}--slider__thumb-icon--focus`
|
|
32
|
+
}, props), _path3 || (_path3 = /*#__PURE__*/React.createElement("path", {
|
|
33
|
+
d: "M15.08 6.46H16v11.08h-.92zM4.46 17.54c-.25 0-.46-.21-.46-.46V6.92a.465.465 0 0 1 .69-.4l8.77 5.08a.46.46 0 0 1 0 .8l-8.77 5.08c-.07.04-.15.06-.23.06Z"
|
|
34
|
+
})), _path4 || (_path4 = /*#__PURE__*/React.createElement("path", {
|
|
35
|
+
fill: "none",
|
|
36
|
+
d: "M-4 0h24v24H-4z"
|
|
37
|
+
})), _path5 || (_path5 = /*#__PURE__*/React.createElement("path", {
|
|
38
|
+
d: "M15.08 0H16v6.46h-.92z"
|
|
39
|
+
})), _path6 || (_path6 = /*#__PURE__*/React.createElement("path", {
|
|
40
|
+
d: "M0 0h.92v24H0zM15.08 0H16v24h-.92z"
|
|
41
|
+
})), _path7 || (_path7 = /*#__PURE__*/React.createElement("path", {
|
|
42
|
+
d: "M0 .92V0h16v.92zM0 24v-.92h16V24z"
|
|
43
|
+
})));
|
|
44
|
+
};
|
|
45
|
+
const UpperHandle = props => {
|
|
46
|
+
const prefix = usePrefix();
|
|
47
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
48
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
49
|
+
viewBox: "0 0 16 24",
|
|
50
|
+
className: `${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--upper`
|
|
51
|
+
}, props), _path8 || (_path8 = /*#__PURE__*/React.createElement("path", {
|
|
52
|
+
d: "M0 6.46h.92v11.08H0zM11.54 6.46c.25 0 .46.21.46.46v10.15a.465.465 0 0 1-.69.4L2.54 12.4a.46.46 0 0 1 0-.8l8.77-5.08c.07-.04.15-.06.23-.06Z"
|
|
53
|
+
})), _path9 || (_path9 = /*#__PURE__*/React.createElement("path", {
|
|
54
|
+
fill: "none",
|
|
55
|
+
d: "M-4 0h24v24H-4z"
|
|
56
|
+
})));
|
|
57
|
+
};
|
|
58
|
+
const UpperHandleFocus = props => {
|
|
59
|
+
const prefix = usePrefix();
|
|
60
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
61
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
62
|
+
viewBox: "0 0 16 24",
|
|
63
|
+
className: `${prefix}--slider__thumb-icon ${prefix}--slider__thumb-icon--upper ${prefix}--slider__thumb-icon--focus`
|
|
64
|
+
}, props), _path0 || (_path0 = /*#__PURE__*/React.createElement("path", {
|
|
65
|
+
d: "M0 6.46h.92v11.08H0zM11.54 6.46c.25 0 .46.21.46.46v10.15a.465.465 0 0 1-.69.4L2.54 12.4a.46.46 0 0 1 0-.8l8.77-5.08c.07-.04.15-.06.23-.06Z"
|
|
66
|
+
})), _path1 || (_path1 = /*#__PURE__*/React.createElement("path", {
|
|
67
|
+
fill: "none",
|
|
68
|
+
d: "M-4 0h24v24H-4z"
|
|
69
|
+
})), _path10 || (_path10 = /*#__PURE__*/React.createElement("path", {
|
|
70
|
+
d: "M.92 24H0v-6.46h.92z"
|
|
71
|
+
})), _path11 || (_path11 = /*#__PURE__*/React.createElement("path", {
|
|
72
|
+
d: "M16 24h-.92V0H16zM.92 24H0V0h.92z"
|
|
73
|
+
})), _path12 || (_path12 = /*#__PURE__*/React.createElement("path", {
|
|
74
|
+
d: "M16 23.08V24H0v-.92zM16 0v.92H0V0z"
|
|
75
|
+
})));
|
|
76
|
+
};
|
|
65
77
|
|
|
66
78
|
export { LowerHandle, LowerHandleFocus, UpperHandle, UpperHandleFocus };
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, {
|
|
10
|
+
import React, { useState, forwardRef } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { IconButton } from '../IconButton/index.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
@@ -10,7 +10,7 @@ import { Close, ChevronLeft, ChevronRight } from '@carbon/icons-react';
|
|
|
10
10
|
import { breakpoints } from '@carbon/layout';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
|
-
import React, { forwardRef,
|
|
13
|
+
import React, { forwardRef, useRef, useState, useMemo, isValidElement, createContext, Children, useCallback, useEffect, cloneElement } from 'react';
|
|
14
14
|
import '../Grid/FlexGrid.js';
|
|
15
15
|
import { Grid as GridAsGridComponent } from '../Grid/Grid.js';
|
|
16
16
|
import '../Grid/Row.js';
|
|
@@ -1038,11 +1038,7 @@ const IconTab = /*#__PURE__*/React.forwardRef(({
|
|
|
1038
1038
|
const value = useMemo(() => ({
|
|
1039
1039
|
badgeIndicator
|
|
1040
1040
|
}), [badgeIndicator]);
|
|
1041
|
-
const hasSize20 = /*#__PURE__*/isValidElement(children) &&
|
|
1042
|
-
// TODO: The interface allows `size` to be a string. Should this case be
|
|
1043
|
-
// handled here, or should the prop type be restricted to `number`
|
|
1044
|
-
// instead?
|
|
1045
|
-
children.props.size === 20;
|
|
1041
|
+
const hasSize20 = /*#__PURE__*/isValidElement(children) && (children.props.size === 20 || children.props.size === '20');
|
|
1046
1042
|
const classNames = cx(`${prefix}--tabs__nav-item--icon-only`, customClassName, {
|
|
1047
1043
|
[`${prefix}--tabs__nav-item--icon-only__20`]: hasSize20
|
|
1048
1044
|
});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React, {
|
|
10
|
+
import React, { useContext, useRef, useState, useEffect, forwardRef, cloneElement } from 'react';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
13
13
|
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React, {
|
|
9
|
+
import React, { useState, useEffect, useCallback, useRef, forwardRef, Children, cloneElement } from 'react';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
11
|
import cx from 'classnames';
|
|
12
12
|
import { AiLabel, CheckboxCheckedFilled, Checkbox, ChevronDown, ArrowRight, Error } from '@carbon/icons-react';
|
|
@@ -283,4 +283,4 @@ ToggletipActions.propTypes = {
|
|
|
283
283
|
className: PropTypes.string
|
|
284
284
|
};
|
|
285
285
|
|
|
286
|
-
export { Toggletip, ToggletipActions, ToggletipButton, ToggletipContent, ToggletipLabel
|
|
286
|
+
export { Toggletip, ToggletipActions, ToggletipButton, ToggletipContent, ToggletipLabel };
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import { ChevronDown } from '@carbon/icons-react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
|
-
import React, {
|
|
11
|
+
import React, { useContext, useState, useRef, Children, forwardRef, isValidElement, cloneElement } from 'react';
|
|
12
12
|
import PropTypes from 'prop-types';
|
|
13
13
|
import { Escape, Enter, Space } from '../../internal/keyboard/keys.js';
|
|
14
14
|
import { matches } from '../../internal/keyboard/match.js';
|
|
@@ -20,9 +20,6 @@ export interface SideNavProps {
|
|
|
20
20
|
onSideNavBlur?: () => void;
|
|
21
21
|
enterDelayMs?: number;
|
|
22
22
|
}
|
|
23
|
-
interface SideNavContextData {
|
|
24
|
-
isRail?: boolean | undefined;
|
|
25
|
-
}
|
|
26
|
-
export declare const SideNavContext: React.Context<SideNavContextData>;
|
|
27
23
|
declare const SideNav: React.ForwardRefExoticComponent<Omit<SideNavProps & React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
28
24
|
export default SideNav;
|
|
25
|
+
export { SideNavContext } from './SideNavContext';
|
|
@@ -6,24 +6,24 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React, {
|
|
9
|
+
import React, { useRef, useEffect, forwardRef } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
13
|
-
import { CARBON_SIDENAV_ITEMS } from './_utils.js';
|
|
14
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
14
|
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
16
15
|
import { match } from '../../internal/keyboard/match.js';
|
|
17
16
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
18
17
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
19
18
|
import { useDelayedState } from '../../internal/useDelayedState.js';
|
|
19
|
+
import { SideNavContextProvider } from './SideNavContext.js';
|
|
20
|
+
export { SideNavContext } from './SideNavContext.js';
|
|
20
21
|
import { breakpoints } from '@carbon/layout';
|
|
21
22
|
import { useMatchMedia } from '../../internal/useMatchMedia.js';
|
|
22
23
|
|
|
23
24
|
// TODO: comment back in when footer is added for rails
|
|
24
25
|
// import SideNavFooter from './SideNavFooter';
|
|
25
26
|
|
|
26
|
-
const SideNavContext = /*#__PURE__*/createContext({});
|
|
27
27
|
const frFn = forwardRef;
|
|
28
28
|
const SideNav = frFn((props, ref) => {
|
|
29
29
|
const {
|
|
@@ -90,23 +90,9 @@ const SideNav = frFn((props, ref) => {
|
|
|
90
90
|
[`${prefix}--side-nav__overlay`]: true,
|
|
91
91
|
[`${prefix}--side-nav__overlay-active`]: expanded || expandedViaHoverState
|
|
92
92
|
});
|
|
93
|
-
let childrenToRender = children;
|
|
94
93
|
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
// if we are controlled, check for if we have hovered over or the expanded state, else just use the expanded state (uncontrolled)
|
|
98
|
-
const currentExpansionState = controlled ? expandedViaHoverState || expanded : expanded;
|
|
99
|
-
if (/*#__PURE__*/isValidElement(child)) {
|
|
100
|
-
const childJsxElement = child;
|
|
101
|
-
// avoid spreading `isSideNavExpanded` to non-Carbon UI Shell children
|
|
102
|
-
return /*#__PURE__*/React.cloneElement(childJsxElement, {
|
|
103
|
-
...(CARBON_SIDENAV_ITEMS.includes(childJsxElement.type?.displayName ?? childJsxElement.type?.name) ? {
|
|
104
|
-
isSideNavExpanded: currentExpansionState
|
|
105
|
-
} : {})
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
return child;
|
|
109
|
-
});
|
|
94
|
+
// In controlled mode, rail hover can temporarily expand SideNav.
|
|
95
|
+
const currentExpansionState = controlled ? expandedViaHoverState || expanded : expanded;
|
|
110
96
|
const eventHandlers = {};
|
|
111
97
|
if (addFocusListeners) {
|
|
112
98
|
eventHandlers.onFocus = event => {
|
|
@@ -167,10 +153,9 @@ const SideNav = frFn((props, ref) => {
|
|
|
167
153
|
node.removeAttribute('inert');
|
|
168
154
|
}
|
|
169
155
|
}, [inertEnabled]);
|
|
170
|
-
return /*#__PURE__*/React.createElement(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
156
|
+
return /*#__PURE__*/React.createElement(SideNavContextProvider, {
|
|
157
|
+
isRail: isRail,
|
|
158
|
+
isSideNavExpanded: currentExpansionState
|
|
174
159
|
}, isFixedNav ? null :
|
|
175
160
|
/*#__PURE__*/
|
|
176
161
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
@@ -181,7 +166,7 @@ const SideNav = frFn((props, ref) => {
|
|
|
181
166
|
tabIndex: -1,
|
|
182
167
|
ref: navRef,
|
|
183
168
|
className: `${prefix}--side-nav__navigation ${className}`
|
|
184
|
-
}, accessibilityLabel, eventHandlers, other),
|
|
169
|
+
}, accessibilityLabel, eventHandlers, other), children));
|
|
185
170
|
});
|
|
186
171
|
SideNav.displayName = 'SideNav';
|
|
187
172
|
SideNav.propTypes = {
|
|
@@ -264,4 +249,4 @@ SideNav.propTypes = {
|
|
|
264
249
|
// translateById: PropTypes.func,
|
|
265
250
|
};
|
|
266
251
|
|
|
267
|
-
export {
|
|
252
|
+
export { SideNav as default };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2026
|
|
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 React, { type ReactNode } from 'react';
|
|
8
|
+
interface SideNavContextData {
|
|
9
|
+
isRail?: boolean | undefined;
|
|
10
|
+
isSideNavExpanded?: boolean | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare const SideNavContext: React.Context<SideNavContextData>;
|
|
13
|
+
interface SideNavContextProviderProps extends SideNavContextData {
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
export declare const SideNavContextProvider: ({ children, isRail, isSideNavExpanded, }: SideNavContextProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import React, { createContext } from 'react';
|
|
9
|
+
|
|
10
|
+
const SideNavContext = /*#__PURE__*/createContext({});
|
|
11
|
+
const SideNavContextProvider = ({
|
|
12
|
+
children,
|
|
13
|
+
isRail,
|
|
14
|
+
isSideNavExpanded
|
|
15
|
+
}) => {
|
|
16
|
+
return /*#__PURE__*/React.createElement(SideNavContext.Provider, {
|
|
17
|
+
value: {
|
|
18
|
+
isRail,
|
|
19
|
+
isSideNavExpanded
|
|
20
|
+
}
|
|
21
|
+
}, children);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { SideNavContext, SideNavContextProvider };
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
import cx from 'classnames';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import {
|
|
10
|
+
import React, { useContext } from 'react';
|
|
11
|
+
import { SideNavContext, SideNavContextProvider } from './SideNavContext.js';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
|
|
14
14
|
const SideNavItems = ({
|
|
@@ -17,22 +17,18 @@ const SideNavItems = ({
|
|
|
17
17
|
isSideNavExpanded
|
|
18
18
|
}) => {
|
|
19
19
|
const prefix = usePrefix();
|
|
20
|
+
const {
|
|
21
|
+
isRail,
|
|
22
|
+
isSideNavExpanded: contextIsSideNavExpanded
|
|
23
|
+
} = useContext(SideNavContext);
|
|
24
|
+
const currentIsSideNavExpanded = isSideNavExpanded ?? contextIsSideNavExpanded;
|
|
20
25
|
const className = cx([`${prefix}--side-nav__items`], customClassName);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const childDisplayName = child.type?.displayName;
|
|
26
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
27
|
-
...(CARBON_SIDENAV_ITEMS.includes(childDisplayName) ? {
|
|
28
|
-
isSideNavExpanded
|
|
29
|
-
} : {})
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return /*#__PURE__*/React.createElement("ul", {
|
|
26
|
+
return /*#__PURE__*/React.createElement(SideNavContextProvider, {
|
|
27
|
+
isRail: isRail,
|
|
28
|
+
isSideNavExpanded: currentIsSideNavExpanded
|
|
29
|
+
}, /*#__PURE__*/React.createElement("ul", {
|
|
34
30
|
className: className
|
|
35
|
-
},
|
|
31
|
+
}, children));
|
|
36
32
|
};
|
|
37
33
|
SideNavItems.displayName = 'SideNavItems';
|
|
38
34
|
SideNavItems.propTypes = {
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
-
import React, {
|
|
11
|
+
import React, { useContext, forwardRef } from 'react';
|
|
12
12
|
import Link, { LinkPropTypes } from './Link.js';
|
|
13
13
|
import SideNavIcon from './SideNavIcon.js';
|
|
14
14
|
import SideNavItem from './SideNavItem.js';
|
|
15
15
|
import SideNavLinkText from './SideNavLinkText.js';
|
|
16
|
+
import { SideNavContext } from './SideNavContext.js';
|
|
16
17
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
17
|
-
import { SideNavContext } from './SideNav.js';
|
|
18
18
|
|
|
19
19
|
// First define a non-generic base component to work with forwardRef
|
|
20
20
|
|
|
@@ -30,7 +30,11 @@ const SideNavLink = frFn((props, ref) => {
|
|
|
30
30
|
tabIndex,
|
|
31
31
|
...rest
|
|
32
32
|
} = props;
|
|
33
|
-
const
|
|
33
|
+
const {
|
|
34
|
+
isRail,
|
|
35
|
+
isSideNavExpanded: contextIsSideNavExpanded
|
|
36
|
+
} = useContext(SideNavContext);
|
|
37
|
+
const currentIsSideNavExpanded = isSideNavExpanded ?? contextIsSideNavExpanded;
|
|
34
38
|
const prefix = usePrefix();
|
|
35
39
|
const className = cx({
|
|
36
40
|
[`${prefix}--side-nav__link`]: true,
|
|
@@ -42,7 +46,7 @@ const SideNavLink = frFn((props, ref) => {
|
|
|
42
46
|
}, /*#__PURE__*/React.createElement(Link, _extends({}, rest, {
|
|
43
47
|
className: className,
|
|
44
48
|
ref: ref,
|
|
45
|
-
tabIndex: tabIndex === undefined ? !
|
|
49
|
+
tabIndex: tabIndex === undefined ? !currentIsSideNavExpanded && !isRail ? -1 : 0 : tabIndex
|
|
46
50
|
}), IconElement && /*#__PURE__*/React.createElement(SideNavIcon, {
|
|
47
51
|
small: true
|
|
48
52
|
}, /*#__PURE__*/React.createElement(IconElement, null)), /*#__PURE__*/React.createElement(SideNavLinkText, null, children)));
|
|
@@ -13,7 +13,7 @@ import SideNavIcon from './SideNavIcon.js';
|
|
|
13
13
|
import { Escape } from '../../internal/keyboard/keys.js';
|
|
14
14
|
import { match } from '../../internal/keyboard/match.js';
|
|
15
15
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
|
-
import { SideNavContext } from './
|
|
16
|
+
import { SideNavContext } from './SideNavContext.js';
|
|
17
17
|
|
|
18
18
|
var _ChevronDown;
|
|
19
19
|
const SideNavMenu = /*#__PURE__*/forwardRef(({
|
|
@@ -28,8 +28,10 @@ const SideNavMenu = /*#__PURE__*/forwardRef(({
|
|
|
28
28
|
title
|
|
29
29
|
}, ref) => {
|
|
30
30
|
const {
|
|
31
|
-
isRail
|
|
31
|
+
isRail,
|
|
32
|
+
isSideNavExpanded: contextIsSideNavExpanded
|
|
32
33
|
} = useContext(SideNavContext);
|
|
34
|
+
const currentIsSideNavExpanded = isSideNavExpanded ?? contextIsSideNavExpanded;
|
|
33
35
|
const prefix = usePrefix();
|
|
34
36
|
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
|
35
37
|
const [prevExpanded, setPrevExpanded] = useState(defaultExpanded);
|
|
@@ -40,10 +42,10 @@ const SideNavMenu = /*#__PURE__*/forwardRef(({
|
|
|
40
42
|
[`${prefix}--side-nav__item--large`]: large,
|
|
41
43
|
[customClassName]: !!customClassName
|
|
42
44
|
});
|
|
43
|
-
if (!
|
|
45
|
+
if (!currentIsSideNavExpanded && isExpanded && isRail) {
|
|
44
46
|
setIsExpanded(false);
|
|
45
47
|
setPrevExpanded(true);
|
|
46
|
-
} else if (
|
|
48
|
+
} else if (currentIsSideNavExpanded && prevExpanded && isRail) {
|
|
47
49
|
setIsExpanded(true);
|
|
48
50
|
setPrevExpanded(false);
|
|
49
51
|
}
|
|
@@ -65,7 +67,7 @@ const SideNavMenu = /*#__PURE__*/forwardRef(({
|
|
|
65
67
|
},
|
|
66
68
|
ref: ref,
|
|
67
69
|
type: "button",
|
|
68
|
-
tabIndex: tabIndex === undefined ? !
|
|
70
|
+
tabIndex: tabIndex === undefined ? !currentIsSideNavExpanded && !isRail ? -1 : 0 : tabIndex
|
|
69
71
|
}, IconElement && /*#__PURE__*/React.createElement(SideNavIcon, null, /*#__PURE__*/React.createElement(IconElement, null)), /*#__PURE__*/React.createElement("span", {
|
|
70
72
|
className: `${prefix}--side-nav__submenu-title`
|
|
71
73
|
}, title), /*#__PURE__*/React.createElement(SideNavIcon, {
|