@mui/material 9.0.0-alpha.2 → 9.0.0-alpha.3
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/Autocomplete/Autocomplete.d.mts +16 -0
- package/Autocomplete/Autocomplete.d.ts +16 -0
- package/Autocomplete/Autocomplete.js +48 -25
- package/Autocomplete/Autocomplete.mjs +48 -25
- package/Box/Box.d.mts +1 -0
- package/Box/Box.d.ts +1 -0
- package/Button/Button.d.mts +1 -0
- package/Button/Button.d.ts +1 -0
- package/CHANGELOG.md +37 -0
- package/CardHeader/CardHeader.js +5 -1
- package/CardHeader/CardHeader.mjs +5 -1
- package/Divider/Divider.d.mts +1 -0
- package/Divider/Divider.d.ts +1 -0
- package/List/List.d.mts +1 -0
- package/List/List.d.ts +1 -0
- package/ListItemButton/ListItemButton.d.mts +1 -0
- package/ListItemButton/ListItemButton.d.ts +1 -0
- package/ListItemIcon/ListItemIcon.d.mts +1 -0
- package/ListItemIcon/ListItemIcon.d.ts +1 -0
- package/ListItemText/ListItemText.d.mts +1 -0
- package/ListItemText/ListItemText.d.ts +1 -0
- package/ListItemText/ListItemText.js +5 -1
- package/ListItemText/ListItemText.mjs +5 -1
- package/ListSubheader/ListSubheader.d.mts +1 -0
- package/ListSubheader/ListSubheader.d.ts +1 -0
- package/MenuList/MenuList.js +76 -106
- package/MenuList/MenuList.mjs +76 -106
- package/Paper/Paper.d.mts +1 -0
- package/Paper/Paper.d.ts +1 -0
- package/Step/Step.js +7 -5
- package/Step/Step.mjs +7 -5
- package/StepButton/StepButton.js +16 -6
- package/StepButton/StepButton.mjs +16 -6
- package/StepConnector/StepConnector.js +2 -2
- package/StepConnector/StepConnector.mjs +2 -2
- package/StepContent/StepContent.js +2 -2
- package/StepContent/StepContent.mjs +2 -2
- package/StepLabel/StepLabel.js +2 -2
- package/StepLabel/StepLabel.mjs +2 -2
- package/Stepper/Stepper.js +44 -7
- package/Stepper/Stepper.mjs +44 -7
- package/Stepper/StepperContext.d.mts +7 -0
- package/Stepper/StepperContext.d.ts +7 -0
- package/Stepper/StepperContext.js +2 -1
- package/Stepper/StepperContext.mjs +1 -0
- package/Stepper/index.d.mts +0 -1
- package/Stepper/index.d.ts +0 -1
- package/Tab/Tab.js +0 -1
- package/Tab/Tab.mjs +0 -1
- package/Tabs/Tabs.js +46 -97
- package/Tabs/Tabs.mjs +46 -97
- package/Typography/Typography.d.mts +1 -0
- package/Typography/Typography.d.ts +1 -0
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +236 -222
- package/themeCssVarsAugmentation/index.js +5 -0
- package/themeCssVarsAugmentation/index.mjs +5 -0
- package/useAutocomplete/useAutocomplete.js +24 -0
- package/useAutocomplete/useAutocomplete.mjs +24 -0
- package/utils/index.d.mts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +14 -0
- package/utils/index.mjs +2 -0
- package/utils/useRovingTabIndex.d.mts +2 -0
- package/utils/useRovingTabIndex.d.ts +2 -0
- package/utils/useRovingTabIndex.js +9 -0
- package/utils/useRovingTabIndex.mjs +2 -0
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
|
@@ -15,7 +15,7 @@ var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
|
|
|
15
15
|
var _zeroStyled = require("../zero-styled");
|
|
16
16
|
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
|
|
17
17
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
18
|
-
var _StepperContext =
|
|
18
|
+
var _StepperContext = require("../Stepper/StepperContext");
|
|
19
19
|
var _StepContext = _interopRequireDefault(require("../Step/StepContext"));
|
|
20
20
|
var _stepConnectorClasses = require("./stepConnectorClasses");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -112,7 +112,7 @@ const StepConnector = /*#__PURE__*/React.forwardRef(function StepConnector(inPro
|
|
|
112
112
|
const {
|
|
113
113
|
alternativeLabel,
|
|
114
114
|
orientation = 'horizontal'
|
|
115
|
-
} =
|
|
115
|
+
} = (0, _StepperContext.useStepperContext)();
|
|
116
116
|
const {
|
|
117
117
|
active,
|
|
118
118
|
disabled,
|
|
@@ -8,7 +8,7 @@ import capitalize from "../utils/capitalize.mjs";
|
|
|
8
8
|
import { styled } from "../zero-styled/index.mjs";
|
|
9
9
|
import memoTheme from "../utils/memoTheme.mjs";
|
|
10
10
|
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
11
|
-
import
|
|
11
|
+
import { useStepperContext } from "../Stepper/StepperContext.mjs";
|
|
12
12
|
import StepContext from "../Step/StepContext.mjs";
|
|
13
13
|
import { getStepConnectorUtilityClass } from "./stepConnectorClasses.mjs";
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -105,7 +105,7 @@ const StepConnector = /*#__PURE__*/React.forwardRef(function StepConnector(inPro
|
|
|
105
105
|
const {
|
|
106
106
|
alternativeLabel,
|
|
107
107
|
orientation = 'horizontal'
|
|
108
|
-
} =
|
|
108
|
+
} = useStepperContext();
|
|
109
109
|
const {
|
|
110
110
|
active,
|
|
111
111
|
disabled,
|
|
@@ -15,7 +15,7 @@ var _zeroStyled = require("../zero-styled");
|
|
|
15
15
|
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
|
|
16
16
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
17
17
|
var _Collapse = _interopRequireDefault(require("../Collapse"));
|
|
18
|
-
var _StepperContext =
|
|
18
|
+
var _StepperContext = require("../Stepper/StepperContext");
|
|
19
19
|
var _StepContext = _interopRequireDefault(require("../Step/StepContext"));
|
|
20
20
|
var _stepContentClasses = require("./stepContentClasses");
|
|
21
21
|
var _useSlot = _interopRequireDefault(require("../utils/useSlot"));
|
|
@@ -79,7 +79,7 @@ const StepContent = /*#__PURE__*/React.forwardRef(function StepContent(inProps,
|
|
|
79
79
|
} = props;
|
|
80
80
|
const {
|
|
81
81
|
orientation
|
|
82
|
-
} =
|
|
82
|
+
} = (0, _StepperContext.useStepperContext)();
|
|
83
83
|
const {
|
|
84
84
|
active,
|
|
85
85
|
last,
|
|
@@ -8,7 +8,7 @@ import { styled } from "../zero-styled/index.mjs";
|
|
|
8
8
|
import memoTheme from "../utils/memoTheme.mjs";
|
|
9
9
|
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
10
10
|
import Collapse from "../Collapse/index.mjs";
|
|
11
|
-
import
|
|
11
|
+
import { useStepperContext } from "../Stepper/StepperContext.mjs";
|
|
12
12
|
import StepContext from "../Step/StepContext.mjs";
|
|
13
13
|
import { getStepContentUtilityClass } from "./stepContentClasses.mjs";
|
|
14
14
|
import useSlot from "../utils/useSlot.mjs";
|
|
@@ -72,7 +72,7 @@ const StepContent = /*#__PURE__*/React.forwardRef(function StepContent(inProps,
|
|
|
72
72
|
} = props;
|
|
73
73
|
const {
|
|
74
74
|
orientation
|
|
75
|
-
} =
|
|
75
|
+
} = useStepperContext();
|
|
76
76
|
const {
|
|
77
77
|
active,
|
|
78
78
|
last,
|
package/StepLabel/StepLabel.js
CHANGED
|
@@ -13,7 +13,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
13
13
|
var React = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _StepContext = _interopRequireDefault(require("../Step/StepContext"));
|
|
15
15
|
var _StepIcon = _interopRequireDefault(require("../StepIcon"));
|
|
16
|
-
var _StepperContext =
|
|
16
|
+
var _StepperContext = require("../Stepper/StepperContext");
|
|
17
17
|
var _zeroStyled = require("../zero-styled");
|
|
18
18
|
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
|
|
19
19
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
@@ -132,7 +132,7 @@ const StepLabel = /*#__PURE__*/React.forwardRef(function StepLabel(inProps, ref)
|
|
|
132
132
|
const {
|
|
133
133
|
alternativeLabel,
|
|
134
134
|
orientation
|
|
135
|
-
} =
|
|
135
|
+
} = (0, _StepperContext.useStepperContext)();
|
|
136
136
|
const {
|
|
137
137
|
active,
|
|
138
138
|
disabled,
|
package/StepLabel/StepLabel.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import StepContext from "../Step/StepContext.mjs";
|
|
8
8
|
import StepIcon from "../StepIcon/index.mjs";
|
|
9
|
-
import
|
|
9
|
+
import { useStepperContext } from "../Stepper/StepperContext.mjs";
|
|
10
10
|
import { styled } from "../zero-styled/index.mjs";
|
|
11
11
|
import memoTheme from "../utils/memoTheme.mjs";
|
|
12
12
|
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
@@ -125,7 +125,7 @@ const StepLabel = /*#__PURE__*/React.forwardRef(function StepLabel(inProps, ref)
|
|
|
125
125
|
const {
|
|
126
126
|
alternativeLabel,
|
|
127
127
|
orientation
|
|
128
|
-
} =
|
|
128
|
+
} = useStepperContext();
|
|
129
129
|
const {
|
|
130
130
|
active,
|
|
131
131
|
disabled,
|
package/Stepper/Stepper.js
CHANGED
|
@@ -12,11 +12,14 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
12
12
|
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
13
|
var _integerPropType = _interopRequireDefault(require("@mui/utils/integerPropType"));
|
|
14
14
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
15
|
+
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
16
|
+
var _useRovingTabIndex = _interopRequireDefault(require("../utils/useRovingTabIndex"));
|
|
15
17
|
var _zeroStyled = require("../zero-styled");
|
|
16
18
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
17
19
|
var _stepperClasses = require("./stepperClasses");
|
|
18
20
|
var _StepConnector = _interopRequireDefault(require("../StepConnector"));
|
|
19
|
-
var _StepperContext =
|
|
21
|
+
var _StepperContext = require("./StepperContext");
|
|
22
|
+
var _StepButton = _interopRequireDefault(require("../StepButton"));
|
|
20
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
24
|
const useUtilityClasses = ownerState => {
|
|
22
25
|
const {
|
|
@@ -30,7 +33,7 @@ const useUtilityClasses = ownerState => {
|
|
|
30
33
|
};
|
|
31
34
|
return (0, _composeClasses.default)(slots, _stepperClasses.getStepperUtilityClass, classes);
|
|
32
35
|
};
|
|
33
|
-
const StepperRoot = (0, _zeroStyled.styled)('
|
|
36
|
+
const StepperRoot = (0, _zeroStyled.styled)('ol', {
|
|
34
37
|
name: 'MuiStepper',
|
|
35
38
|
slot: 'Root',
|
|
36
39
|
overridesResolver: (props, styles) => {
|
|
@@ -41,6 +44,9 @@ const StepperRoot = (0, _zeroStyled.styled)('div', {
|
|
|
41
44
|
}
|
|
42
45
|
})({
|
|
43
46
|
display: 'flex',
|
|
47
|
+
listStyle: 'none',
|
|
48
|
+
margin: 0,
|
|
49
|
+
padding: 0,
|
|
44
50
|
variants: [{
|
|
45
51
|
props: {
|
|
46
52
|
orientation: 'horizontal'
|
|
@@ -67,6 +73,7 @@ const StepperRoot = (0, _zeroStyled.styled)('div', {
|
|
|
67
73
|
});
|
|
68
74
|
const defaultConnector = /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepConnector.default, {});
|
|
69
75
|
const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
76
|
+
const isRtl = (0, _RtlProvider.useRtl)();
|
|
70
77
|
const props = (0, _DefaultPropsProvider.useDefaultProps)({
|
|
71
78
|
props: inProps,
|
|
72
79
|
name: 'MuiStepper'
|
|
@@ -76,7 +83,7 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
76
83
|
alternativeLabel = false,
|
|
77
84
|
children,
|
|
78
85
|
className,
|
|
79
|
-
component = '
|
|
86
|
+
component = 'ol',
|
|
80
87
|
connector = defaultConnector,
|
|
81
88
|
nonLinear = false,
|
|
82
89
|
orientation = 'horizontal',
|
|
@@ -91,27 +98,57 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
91
98
|
};
|
|
92
99
|
const classes = useUtilityClasses(ownerState);
|
|
93
100
|
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
101
|
+
const totalSteps = childrenArray.length;
|
|
102
|
+
const isTabList = childrenArray.some(child => {
|
|
103
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (child.type === _StepButton.default) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
const grandChildren = child.props.children;
|
|
110
|
+
if (grandChildren) {
|
|
111
|
+
return React.Children.toArray(grandChildren).some(grandChild => /*#__PURE__*/React.isValidElement(grandChild) && grandChild.type === _StepButton.default);
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
});
|
|
94
115
|
const steps = childrenArray.map((step, index) => {
|
|
95
116
|
return /*#__PURE__*/React.cloneElement(step, {
|
|
96
117
|
index,
|
|
97
|
-
last: index + 1 ===
|
|
118
|
+
last: index + 1 === totalSteps,
|
|
98
119
|
...step.props
|
|
99
120
|
});
|
|
100
121
|
});
|
|
122
|
+
const {
|
|
123
|
+
getContainerProps,
|
|
124
|
+
getItemProps
|
|
125
|
+
} = (0, _useRovingTabIndex.default)({
|
|
126
|
+
orientation,
|
|
127
|
+
isRtl
|
|
128
|
+
});
|
|
129
|
+
const rovingTabIndexContainerProps = getContainerProps(ref);
|
|
101
130
|
const contextValue = React.useMemo(() => ({
|
|
102
131
|
activeStep,
|
|
103
132
|
alternativeLabel,
|
|
104
133
|
connector,
|
|
105
134
|
nonLinear,
|
|
106
|
-
orientation
|
|
107
|
-
|
|
108
|
-
|
|
135
|
+
orientation,
|
|
136
|
+
totalSteps,
|
|
137
|
+
getRovingTabIndexProps: getItemProps,
|
|
138
|
+
isTabList
|
|
139
|
+
}), [activeStep, alternativeLabel, connector, nonLinear, orientation, totalSteps, getItemProps, isTabList]);
|
|
140
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepperContext.StepperContextProvider, {
|
|
109
141
|
value: contextValue,
|
|
110
142
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepperRoot, {
|
|
111
143
|
as: component,
|
|
112
144
|
ownerState: ownerState,
|
|
113
145
|
className: (0, _clsx.default)(classes.root, className),
|
|
114
146
|
ref: ref,
|
|
147
|
+
...(isTabList && {
|
|
148
|
+
role: 'tablist',
|
|
149
|
+
'aria-orientation': orientation,
|
|
150
|
+
...rovingTabIndexContainerProps
|
|
151
|
+
}),
|
|
115
152
|
...other,
|
|
116
153
|
children: steps
|
|
117
154
|
})
|
package/Stepper/Stepper.mjs
CHANGED
|
@@ -5,11 +5,14 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import integerPropType from '@mui/utils/integerPropType';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
9
|
+
import useRovingTabIndex from "../utils/useRovingTabIndex.mjs";
|
|
8
10
|
import { styled } from "../zero-styled/index.mjs";
|
|
9
11
|
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
10
12
|
import { getStepperUtilityClass } from "./stepperClasses.mjs";
|
|
11
13
|
import StepConnector from "../StepConnector/index.mjs";
|
|
12
|
-
import
|
|
14
|
+
import { StepperContextProvider } from "./StepperContext.mjs";
|
|
15
|
+
import StepButton from "../StepButton/index.mjs";
|
|
13
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
17
|
const useUtilityClasses = ownerState => {
|
|
15
18
|
const {
|
|
@@ -23,7 +26,7 @@ const useUtilityClasses = ownerState => {
|
|
|
23
26
|
};
|
|
24
27
|
return composeClasses(slots, getStepperUtilityClass, classes);
|
|
25
28
|
};
|
|
26
|
-
const StepperRoot = styled('
|
|
29
|
+
const StepperRoot = styled('ol', {
|
|
27
30
|
name: 'MuiStepper',
|
|
28
31
|
slot: 'Root',
|
|
29
32
|
overridesResolver: (props, styles) => {
|
|
@@ -34,6 +37,9 @@ const StepperRoot = styled('div', {
|
|
|
34
37
|
}
|
|
35
38
|
})({
|
|
36
39
|
display: 'flex',
|
|
40
|
+
listStyle: 'none',
|
|
41
|
+
margin: 0,
|
|
42
|
+
padding: 0,
|
|
37
43
|
variants: [{
|
|
38
44
|
props: {
|
|
39
45
|
orientation: 'horizontal'
|
|
@@ -60,6 +66,7 @@ const StepperRoot = styled('div', {
|
|
|
60
66
|
});
|
|
61
67
|
const defaultConnector = /*#__PURE__*/_jsx(StepConnector, {});
|
|
62
68
|
const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
69
|
+
const isRtl = useRtl();
|
|
63
70
|
const props = useDefaultProps({
|
|
64
71
|
props: inProps,
|
|
65
72
|
name: 'MuiStepper'
|
|
@@ -69,7 +76,7 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
69
76
|
alternativeLabel = false,
|
|
70
77
|
children,
|
|
71
78
|
className,
|
|
72
|
-
component = '
|
|
79
|
+
component = 'ol',
|
|
73
80
|
connector = defaultConnector,
|
|
74
81
|
nonLinear = false,
|
|
75
82
|
orientation = 'horizontal',
|
|
@@ -84,27 +91,57 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
84
91
|
};
|
|
85
92
|
const classes = useUtilityClasses(ownerState);
|
|
86
93
|
const childrenArray = React.Children.toArray(children).filter(Boolean);
|
|
94
|
+
const totalSteps = childrenArray.length;
|
|
95
|
+
const isTabList = childrenArray.some(child => {
|
|
96
|
+
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (child.type === StepButton) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
const grandChildren = child.props.children;
|
|
103
|
+
if (grandChildren) {
|
|
104
|
+
return React.Children.toArray(grandChildren).some(grandChild => /*#__PURE__*/React.isValidElement(grandChild) && grandChild.type === StepButton);
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
});
|
|
87
108
|
const steps = childrenArray.map((step, index) => {
|
|
88
109
|
return /*#__PURE__*/React.cloneElement(step, {
|
|
89
110
|
index,
|
|
90
|
-
last: index + 1 ===
|
|
111
|
+
last: index + 1 === totalSteps,
|
|
91
112
|
...step.props
|
|
92
113
|
});
|
|
93
114
|
});
|
|
115
|
+
const {
|
|
116
|
+
getContainerProps,
|
|
117
|
+
getItemProps
|
|
118
|
+
} = useRovingTabIndex({
|
|
119
|
+
orientation,
|
|
120
|
+
isRtl
|
|
121
|
+
});
|
|
122
|
+
const rovingTabIndexContainerProps = getContainerProps(ref);
|
|
94
123
|
const contextValue = React.useMemo(() => ({
|
|
95
124
|
activeStep,
|
|
96
125
|
alternativeLabel,
|
|
97
126
|
connector,
|
|
98
127
|
nonLinear,
|
|
99
|
-
orientation
|
|
100
|
-
|
|
101
|
-
|
|
128
|
+
orientation,
|
|
129
|
+
totalSteps,
|
|
130
|
+
getRovingTabIndexProps: getItemProps,
|
|
131
|
+
isTabList
|
|
132
|
+
}), [activeStep, alternativeLabel, connector, nonLinear, orientation, totalSteps, getItemProps, isTabList]);
|
|
133
|
+
return /*#__PURE__*/_jsx(StepperContextProvider, {
|
|
102
134
|
value: contextValue,
|
|
103
135
|
children: /*#__PURE__*/_jsx(StepperRoot, {
|
|
104
136
|
as: component,
|
|
105
137
|
ownerState: ownerState,
|
|
106
138
|
className: clsx(classes.root, className),
|
|
107
139
|
ref: ref,
|
|
140
|
+
...(isTabList && {
|
|
141
|
+
role: 'tablist',
|
|
142
|
+
'aria-orientation': orientation,
|
|
143
|
+
...rovingTabIndexContainerProps
|
|
144
|
+
}),
|
|
108
145
|
...other,
|
|
109
146
|
children: steps
|
|
110
147
|
})
|
|
@@ -5,6 +5,12 @@ export interface StepperContextType {
|
|
|
5
5
|
connector: React.ReactNode;
|
|
6
6
|
nonLinear: boolean;
|
|
7
7
|
orientation: 'horizontal' | 'vertical';
|
|
8
|
+
totalSteps: number;
|
|
9
|
+
getRovingTabIndexProps: (index: number, ref?: React.Ref<HTMLElement>) => {
|
|
10
|
+
ref: (element: HTMLElement | null) => void;
|
|
11
|
+
tabIndex: number;
|
|
12
|
+
};
|
|
13
|
+
isTabList: boolean;
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
10
16
|
* Provides information about the current step in Stepper.
|
|
@@ -15,4 +21,5 @@ declare const StepperContext: React.Context<{} | StepperContextType>;
|
|
|
15
21
|
* has been defined in the component tree.
|
|
16
22
|
*/
|
|
17
23
|
export declare function useStepperContext(): StepperContextType | {};
|
|
24
|
+
export declare const StepperContextProvider: React.Provider<{} | StepperContextType>;
|
|
18
25
|
export default StepperContext;
|
|
@@ -5,6 +5,12 @@ export interface StepperContextType {
|
|
|
5
5
|
connector: React.ReactNode;
|
|
6
6
|
nonLinear: boolean;
|
|
7
7
|
orientation: 'horizontal' | 'vertical';
|
|
8
|
+
totalSteps: number;
|
|
9
|
+
getRovingTabIndexProps: (index: number, ref?: React.Ref<HTMLElement>) => {
|
|
10
|
+
ref: (element: HTMLElement | null) => void;
|
|
11
|
+
tabIndex: number;
|
|
12
|
+
};
|
|
13
|
+
isTabList: boolean;
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
10
16
|
* Provides information about the current step in Stepper.
|
|
@@ -15,4 +21,5 @@ declare const StepperContext: React.Context<{} | StepperContextType>;
|
|
|
15
21
|
* has been defined in the component tree.
|
|
16
22
|
*/
|
|
17
23
|
export declare function useStepperContext(): StepperContextType | {};
|
|
24
|
+
export declare const StepperContextProvider: React.Provider<{} | StepperContextType>;
|
|
18
25
|
export default StepperContext;
|
|
@@ -5,7 +5,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.default = exports.StepperContextProvider = void 0;
|
|
9
9
|
exports.useStepperContext = useStepperContext;
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
/**
|
|
@@ -23,4 +23,5 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
23
23
|
function useStepperContext() {
|
|
24
24
|
return React.useContext(StepperContext);
|
|
25
25
|
}
|
|
26
|
+
const StepperContextProvider = exports.StepperContextProvider = StepperContext.Provider;
|
|
26
27
|
var _default = exports.default = StepperContext;
|
package/Stepper/index.d.mts
CHANGED
|
@@ -2,5 +2,4 @@ export { default } from "./Stepper.mjs";
|
|
|
2
2
|
export * from "./Stepper.mjs";
|
|
3
3
|
export { default as stepperClasses } from "./stepperClasses.mjs";
|
|
4
4
|
export * from "./stepperClasses.mjs";
|
|
5
|
-
export { default as StepperContext } from "./StepperContext.mjs";
|
|
6
5
|
export * from "./StepperContext.mjs";
|
package/Stepper/index.d.ts
CHANGED
|
@@ -2,5 +2,4 @@ export { default } from "./Stepper.js";
|
|
|
2
2
|
export * from "./Stepper.js";
|
|
3
3
|
export { default as stepperClasses } from "./stepperClasses.js";
|
|
4
4
|
export * from "./stepperClasses.js";
|
|
5
|
-
export { default as StepperContext } from "./StepperContext.js";
|
|
6
5
|
export * from "./StepperContext.js";
|
package/Tab/Tab.js
CHANGED
|
@@ -257,7 +257,6 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(inProps, ref) {
|
|
|
257
257
|
onClick: handleClick,
|
|
258
258
|
onFocus: handleFocus,
|
|
259
259
|
ownerState: ownerState,
|
|
260
|
-
tabIndex: selected ? 0 : -1,
|
|
261
260
|
...other,
|
|
262
261
|
children: [iconPosition === 'top' || iconPosition === 'start' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
263
262
|
children: [icon, label]
|
package/Tab/Tab.mjs
CHANGED
|
@@ -250,7 +250,6 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(inProps, ref) {
|
|
|
250
250
|
onClick: handleClick,
|
|
251
251
|
onFocus: handleFocus,
|
|
252
252
|
ownerState: ownerState,
|
|
253
|
-
tabIndex: selected ? 0 : -1,
|
|
254
253
|
...other,
|
|
255
254
|
children: [iconPosition === 'top' || iconPosition === 'start' ? /*#__PURE__*/_jsxs(React.Fragment, {
|
|
256
255
|
children: [icon, label]
|
package/Tabs/Tabs.js
CHANGED
|
@@ -24,53 +24,11 @@ var _ScrollbarSize = _interopRequireDefault(require("./ScrollbarSize"));
|
|
|
24
24
|
var _TabScrollButton = _interopRequireDefault(require("../TabScrollButton"));
|
|
25
25
|
var _useEventCallback = _interopRequireDefault(require("../utils/useEventCallback"));
|
|
26
26
|
var _tabsClasses = _interopRequireWildcard(require("./tabsClasses"));
|
|
27
|
-
var _ownerDocument = _interopRequireDefault(require("../utils/ownerDocument"));
|
|
28
27
|
var _ownerWindow = _interopRequireDefault(require("../utils/ownerWindow"));
|
|
29
|
-
var _getActiveElement = _interopRequireDefault(require("../utils/getActiveElement"));
|
|
30
28
|
var _isLayoutSupported = _interopRequireDefault(require("../utils/isLayoutSupported"));
|
|
31
29
|
var _useSlot = _interopRequireDefault(require("../utils/useSlot"));
|
|
30
|
+
var _utils = require("../utils");
|
|
32
31
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
33
|
-
const nextItem = (list, item) => {
|
|
34
|
-
if (list === item) {
|
|
35
|
-
return list.firstChild;
|
|
36
|
-
}
|
|
37
|
-
if (item && item.nextElementSibling) {
|
|
38
|
-
return item.nextElementSibling;
|
|
39
|
-
}
|
|
40
|
-
return list.firstChild;
|
|
41
|
-
};
|
|
42
|
-
const previousItem = (list, item) => {
|
|
43
|
-
if (list === item) {
|
|
44
|
-
return list.lastChild;
|
|
45
|
-
}
|
|
46
|
-
if (item && item.previousElementSibling) {
|
|
47
|
-
return item.previousElementSibling;
|
|
48
|
-
}
|
|
49
|
-
return list.lastChild;
|
|
50
|
-
};
|
|
51
|
-
const moveFocus = (list, currentFocus, traversalFunction) => {
|
|
52
|
-
let wrappedOnce = false;
|
|
53
|
-
let nextFocus = traversalFunction(list, currentFocus);
|
|
54
|
-
while (nextFocus) {
|
|
55
|
-
// Prevent infinite loop.
|
|
56
|
-
if (nextFocus === list.firstChild) {
|
|
57
|
-
if (wrappedOnce) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
wrappedOnce = true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Same logic as useAutocomplete.js
|
|
64
|
-
const nextFocusDisabled = nextFocus.disabled || nextFocus.getAttribute('aria-disabled') === 'true';
|
|
65
|
-
if (!nextFocus.hasAttribute('tabindex') || nextFocusDisabled) {
|
|
66
|
-
// Move to the next element.
|
|
67
|
-
nextFocus = traversalFunction(list, nextFocus);
|
|
68
|
-
} else {
|
|
69
|
-
nextFocus.focus();
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
32
|
const useUtilityClasses = ownerState => {
|
|
75
33
|
const {
|
|
76
34
|
vertical,
|
|
@@ -673,20 +631,37 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
673
631
|
const indicator = /*#__PURE__*/(0, _jsxRuntime.jsx)(IndicatorSlot, {
|
|
674
632
|
...indicatorSlotProps
|
|
675
633
|
});
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
679
|
-
return null;
|
|
680
|
-
}
|
|
634
|
+
const validChildren = React.Children.toArray(childrenProp).filter(React.isValidElement).map((child, index) => {
|
|
635
|
+
const childValue = child.props.value === undefined ? index : child.props.value;
|
|
681
636
|
if (process.env.NODE_ENV !== 'production') {
|
|
682
637
|
if ((0, _reactIs.isFragment)(child)) {
|
|
683
638
|
console.error(["MUI: The Tabs component doesn't accept a Fragment as a child.", 'Consider providing an array instead.'].join('\n'));
|
|
684
639
|
}
|
|
685
640
|
}
|
|
686
|
-
|
|
687
|
-
|
|
641
|
+
valueToIndex.set(childValue, index);
|
|
642
|
+
return {
|
|
643
|
+
child,
|
|
644
|
+
index,
|
|
645
|
+
childValue
|
|
646
|
+
};
|
|
647
|
+
});
|
|
648
|
+
const focusableIndex = valueToIndex.get(value);
|
|
649
|
+
const {
|
|
650
|
+
getContainerProps,
|
|
651
|
+
getItemProps
|
|
652
|
+
} = (0, _utils.useRovingTabIndex)({
|
|
653
|
+
focusableIndex,
|
|
654
|
+
orientation,
|
|
655
|
+
isRtl
|
|
656
|
+
});
|
|
657
|
+
const rovingTabIndexContainerProps = getContainerProps();
|
|
658
|
+
const children = validChildren.map(({
|
|
659
|
+
child,
|
|
660
|
+
index,
|
|
661
|
+
childValue
|
|
662
|
+
}) => {
|
|
688
663
|
const selected = childValue === value;
|
|
689
|
-
|
|
664
|
+
const rovingTabIndexItemProps = getItemProps(index, child.ref);
|
|
690
665
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
691
666
|
fullWidth: variant === 'fullWidth',
|
|
692
667
|
indicator: selected && !mounted && indicator,
|
|
@@ -695,53 +670,10 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
695
670
|
onChange,
|
|
696
671
|
textColor,
|
|
697
672
|
value: childValue,
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
} : {})
|
|
673
|
+
ref: rovingTabIndexItemProps.ref,
|
|
674
|
+
tabIndex: child.props.tabIndex ?? rovingTabIndexItemProps.tabIndex
|
|
701
675
|
});
|
|
702
676
|
});
|
|
703
|
-
const handleKeyDown = event => {
|
|
704
|
-
// Check if a modifier key (Alt, Shift, Ctrl, Meta) is pressed
|
|
705
|
-
if (event.altKey || event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
706
|
-
return;
|
|
707
|
-
}
|
|
708
|
-
const list = tabListRef.current;
|
|
709
|
-
const currentFocus = (0, _getActiveElement.default)((0, _ownerDocument.default)(list));
|
|
710
|
-
// Keyboard navigation assumes that [role="tab"] are siblings
|
|
711
|
-
// though we might warn in the future about nested, interactive elements
|
|
712
|
-
// as a a11y violation
|
|
713
|
-
const role = currentFocus?.getAttribute('role');
|
|
714
|
-
if (role !== 'tab') {
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
let previousItemKey = orientation === 'horizontal' ? 'ArrowLeft' : 'ArrowUp';
|
|
718
|
-
let nextItemKey = orientation === 'horizontal' ? 'ArrowRight' : 'ArrowDown';
|
|
719
|
-
if (orientation === 'horizontal' && isRtl) {
|
|
720
|
-
// swap previousItemKey with nextItemKey
|
|
721
|
-
previousItemKey = 'ArrowRight';
|
|
722
|
-
nextItemKey = 'ArrowLeft';
|
|
723
|
-
}
|
|
724
|
-
switch (event.key) {
|
|
725
|
-
case previousItemKey:
|
|
726
|
-
event.preventDefault();
|
|
727
|
-
moveFocus(list, currentFocus, previousItem);
|
|
728
|
-
break;
|
|
729
|
-
case nextItemKey:
|
|
730
|
-
event.preventDefault();
|
|
731
|
-
moveFocus(list, currentFocus, nextItem);
|
|
732
|
-
break;
|
|
733
|
-
case 'Home':
|
|
734
|
-
event.preventDefault();
|
|
735
|
-
moveFocus(list, null, nextItem);
|
|
736
|
-
break;
|
|
737
|
-
case 'End':
|
|
738
|
-
event.preventDefault();
|
|
739
|
-
moveFocus(list, null, previousItem);
|
|
740
|
-
break;
|
|
741
|
-
default:
|
|
742
|
-
break;
|
|
743
|
-
}
|
|
744
|
-
};
|
|
745
677
|
const conditionalElements = getConditionalElements();
|
|
746
678
|
const [RootSlot, rootSlotProps] = (0, _useSlot.default)('root', {
|
|
747
679
|
ref,
|
|
@@ -767,8 +699,21 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
767
699
|
}
|
|
768
700
|
}
|
|
769
701
|
});
|
|
702
|
+
const mergedRef = (0, _utils.useForkRef)(rovingTabIndexContainerProps.ref, tabListRef);
|
|
703
|
+
const handleKeyDown = event => {
|
|
704
|
+
const list = tabListRef.current;
|
|
705
|
+
const currentFocus = (0, _utils.getActiveElement)((0, _utils.ownerDocument)(list));
|
|
706
|
+
// Keyboard navigation assumes that [role="tab"] are siblings
|
|
707
|
+
// though we might warn in the future about nested, interactive elements
|
|
708
|
+
// as a a11y violation
|
|
709
|
+
const role = currentFocus?.getAttribute('role');
|
|
710
|
+
if (role !== 'tab') {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
rovingTabIndexContainerProps.onKeyDown(event);
|
|
714
|
+
};
|
|
770
715
|
const [ListSlot, listSlotProps] = (0, _useSlot.default)('list', {
|
|
771
|
-
ref:
|
|
716
|
+
ref: mergedRef,
|
|
772
717
|
className: (0, _clsx.default)(classes.list, classes.flexContainer),
|
|
773
718
|
elementType: List,
|
|
774
719
|
externalForwardedProps,
|
|
@@ -778,6 +723,10 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
778
723
|
onKeyDown: event => {
|
|
779
724
|
handleKeyDown(event);
|
|
780
725
|
handlers.onKeyDown?.(event);
|
|
726
|
+
},
|
|
727
|
+
onFocus: event => {
|
|
728
|
+
rovingTabIndexContainerProps.onFocus(event);
|
|
729
|
+
handlers.onFocus?.(event);
|
|
781
730
|
}
|
|
782
731
|
})
|
|
783
732
|
});
|