@mui/material 9.0.0-beta.0 → 9.0.0-beta.1
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/Accordion/Accordion.d.mts +1 -1
- package/Accordion/Accordion.d.ts +1 -1
- package/AccordionSummary/AccordionSummary.js +1 -0
- package/AccordionSummary/AccordionSummary.mjs +1 -0
- package/Backdrop/Backdrop.d.mts +1 -1
- package/Backdrop/Backdrop.d.ts +1 -1
- package/BottomNavigationAction/BottomNavigationAction.js +1 -0
- package/BottomNavigationAction/BottomNavigationAction.mjs +1 -0
- package/Breadcrumbs/BreadcrumbCollapsed.js +5 -1
- package/Breadcrumbs/BreadcrumbCollapsed.mjs +5 -1
- package/Button/Button.js +1 -0
- package/Button/Button.mjs +1 -0
- package/ButtonBase/ButtonBase.d.mts +5 -0
- package/ButtonBase/ButtonBase.d.ts +5 -0
- package/ButtonBase/ButtonBase.js +84 -85
- package/ButtonBase/ButtonBase.mjs +84 -85
- package/ButtonBase/useButtonBase.d.mts +91 -0
- package/ButtonBase/useButtonBase.d.ts +91 -0
- package/ButtonBase/useButtonBase.js +174 -0
- package/ButtonBase/useButtonBase.mjs +167 -0
- package/CHANGELOG.md +48 -0
- package/CardActionArea/CardActionArea.js +1 -0
- package/CardActionArea/CardActionArea.mjs +1 -0
- package/Chip/Chip.d.mts +7 -0
- package/Chip/Chip.d.ts +7 -0
- package/Chip/Chip.js +18 -1
- package/Chip/Chip.mjs +18 -1
- package/Dialog/Dialog.d.mts +8 -1
- package/Dialog/Dialog.d.ts +8 -1
- package/Dialog/Dialog.js +9 -1
- package/Dialog/Dialog.mjs +9 -1
- package/Divider/Divider.js +0 -8
- package/Divider/Divider.mjs +0 -8
- package/Drawer/Drawer.d.mts +1 -1
- package/Drawer/Drawer.d.ts +1 -1
- package/Fab/Fab.js +1 -0
- package/Fab/Fab.mjs +1 -0
- package/FilledInput/FilledInput.js +1 -1
- package/FilledInput/FilledInput.mjs +1 -1
- package/Grid/Grid.d.mts +8 -3
- package/Grid/Grid.d.ts +8 -3
- package/Grid/Grid.js +8 -3
- package/Grid/Grid.mjs +8 -3
- package/Grid/gridClasses.js +1 -1
- package/Grid/gridClasses.mjs +1 -1
- package/IconButton/IconButton.js +1 -0
- package/IconButton/IconButton.mjs +1 -0
- package/Input/Input.js +1 -1
- package/Input/Input.mjs +1 -1
- package/InputAdornment/inputAdornmentClasses.d.mts +2 -2
- package/InputAdornment/inputAdornmentClasses.d.ts +2 -2
- package/ListItemButton/ListItemButton.js +1 -0
- package/ListItemButton/ListItemButton.mjs +1 -0
- package/ListItemIcon/ListItemIcon.js +1 -1
- package/ListItemIcon/ListItemIcon.mjs +1 -1
- package/ListSubheader/ListSubheader.js +0 -3
- package/ListSubheader/ListSubheader.mjs +0 -3
- package/Menu/Menu.d.mts +1 -1
- package/Menu/Menu.d.ts +1 -1
- package/Menu/Menu.js +15 -32
- package/Menu/Menu.mjs +15 -32
- package/MenuItem/MenuItem.js +36 -26
- package/MenuItem/MenuItem.mjs +34 -26
- package/MenuList/MenuList.js +136 -101
- package/MenuList/MenuList.mjs +135 -100
- package/MenuList/MenuListContext.d.mts +11 -0
- package/MenuList/MenuListContext.d.ts +11 -0
- package/MenuList/MenuListContext.js +25 -0
- package/MenuList/MenuListContext.mjs +19 -0
- package/PaginationItem/PaginationItem.d.mts +5 -0
- package/PaginationItem/PaginationItem.d.ts +5 -0
- package/PaginationItem/PaginationItem.js +6 -0
- package/PaginationItem/PaginationItem.mjs +6 -0
- package/PigmentGrid/PigmentGrid.d.mts +1 -1
- package/PigmentGrid/PigmentGrid.d.ts +1 -1
- package/PigmentGrid/PigmentGrid.js +1 -1
- package/PigmentGrid/PigmentGrid.mjs +1 -1
- package/Popover/Popover.d.mts +1 -1
- package/Popover/Popover.d.ts +1 -1
- package/Popover/Popover.js +19 -7
- package/Popover/Popover.mjs +18 -6
- package/Snackbar/Snackbar.d.mts +1 -1
- package/Snackbar/Snackbar.d.ts +1 -1
- package/SpeedDial/SpeedDial.d.mts +1 -1
- package/SpeedDial/SpeedDial.d.ts +1 -1
- package/StepButton/StepButton.js +44 -14
- package/StepButton/StepButton.mjs +44 -14
- package/StepContent/StepContent.d.mts +1 -1
- package/StepContent/StepContent.d.ts +1 -1
- package/Stepper/Stepper.js +54 -22
- package/Stepper/Stepper.mjs +54 -22
- package/Stepper/StepperContext.d.mts +0 -5
- package/Stepper/StepperContext.d.ts +0 -5
- package/Stepper/StepperContext.js +1 -2
- package/Stepper/StepperContext.mjs +0 -1
- package/Tab/Tab.js +17 -1
- package/Tab/Tab.mjs +17 -1
- package/TabScrollButton/TabScrollButton.d.mts +1 -1
- package/TabScrollButton/TabScrollButton.d.ts +1 -1
- package/TabScrollButton/TabScrollButton.js +6 -2
- package/TabScrollButton/TabScrollButton.mjs +6 -2
- package/TableSortLabel/TableSortLabel.js +4 -1
- package/TableSortLabel/TableSortLabel.mjs +4 -1
- package/Tabs/Tabs.js +30 -21
- package/Tabs/Tabs.mjs +29 -20
- package/ToggleButton/ToggleButton.js +1 -0
- package/ToggleButton/ToggleButton.mjs +1 -0
- package/Tooltip/Tooltip.d.mts +1 -1
- package/Tooltip/Tooltip.d.ts +1 -1
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internal/SwitchBase.d.mts +2 -2
- package/internal/SwitchBase.d.ts +2 -2
- package/internal/SwitchBase.js +5 -1
- package/internal/SwitchBase.mjs +5 -1
- package/locale/psAF.js +1 -1
- package/locale/psAF.mjs +1 -1
- package/package.json +5 -5
- package/styles/createThemeWithVars.js +9 -9
- package/styles/createThemeWithVars.mjs +9 -9
- package/useAutocomplete/useAutocomplete.js +8 -0
- package/useAutocomplete/useAutocomplete.mjs +8 -0
- package/utils/focusWithVisible.js +24 -0
- package/utils/focusWithVisible.mjs +19 -0
- package/utils/index.d.mts +0 -1
- package/utils/index.d.ts +0 -1
- package/utils/index.js +0 -7
- package/utils/index.mjs +0 -1
- package/utils/useFocusableWhenDisabled.d.mts +30 -0
- package/utils/useFocusableWhenDisabled.d.ts +30 -0
- package/utils/useFocusableWhenDisabled.js +47 -0
- package/utils/useFocusableWhenDisabled.mjs +41 -0
- package/utils/useRovingTabIndex.d.mts +1 -2
- package/utils/useRovingTabIndex.d.ts +1 -2
- package/utils/useRovingTabIndex.js +25 -4
- package/utils/useRovingTabIndex.mjs +1 -2
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
package/Stepper/Stepper.js
CHANGED
|
@@ -13,12 +13,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
15
|
var _RtlProvider = require("@mui/system/RtlProvider");
|
|
16
|
-
var _useRovingTabIndex = _interopRequireDefault(require("../utils/useRovingTabIndex"));
|
|
17
16
|
var _zeroStyled = require("../zero-styled");
|
|
18
17
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
18
|
+
var _useRovingTabIndex = require("../utils/useRovingTabIndex");
|
|
19
19
|
var _stepperClasses = require("./stepperClasses");
|
|
20
20
|
var _StepConnector = _interopRequireDefault(require("../StepConnector"));
|
|
21
|
-
var _StepperContext = require("./StepperContext");
|
|
21
|
+
var _StepperContext = _interopRequireDefault(require("./StepperContext"));
|
|
22
22
|
var _StepButton = _interopRequireDefault(require("../StepButton"));
|
|
23
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
24
|
const useUtilityClasses = ownerState => {
|
|
@@ -72,6 +72,37 @@ const StepperRoot = (0, _zeroStyled.styled)('ol', {
|
|
|
72
72
|
}]
|
|
73
73
|
});
|
|
74
74
|
const defaultConnector = /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepConnector.default, {});
|
|
75
|
+
function RovingStepper(props) {
|
|
76
|
+
// eslint-disable-next-line react/prop-types
|
|
77
|
+
const {
|
|
78
|
+
children,
|
|
79
|
+
className,
|
|
80
|
+
component,
|
|
81
|
+
forwardedRef,
|
|
82
|
+
isRtl,
|
|
83
|
+
orientation,
|
|
84
|
+
ownerState,
|
|
85
|
+
...other
|
|
86
|
+
} = props;
|
|
87
|
+
const rovingContainer = (0, _useRovingTabIndex.useRovingTabIndexRoot)({
|
|
88
|
+
orientation,
|
|
89
|
+
isRtl
|
|
90
|
+
});
|
|
91
|
+
const rovingContainerProps = rovingContainer.getContainerProps(forwardedRef);
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_useRovingTabIndex.RovingTabIndexContext.Provider, {
|
|
93
|
+
value: rovingContainer,
|
|
94
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepperRoot, {
|
|
95
|
+
as: component,
|
|
96
|
+
ownerState: ownerState,
|
|
97
|
+
className: className,
|
|
98
|
+
role: "tablist",
|
|
99
|
+
"aria-orientation": orientation,
|
|
100
|
+
...rovingContainerProps,
|
|
101
|
+
...other,
|
|
102
|
+
children: children
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
75
106
|
const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
76
107
|
const isRtl = (0, _RtlProvider.useRtl)();
|
|
77
108
|
const props = (0, _DefaultPropsProvider.useDefaultProps)({
|
|
@@ -119,14 +150,6 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
119
150
|
...step.props
|
|
120
151
|
});
|
|
121
152
|
});
|
|
122
|
-
const {
|
|
123
|
-
getContainerProps,
|
|
124
|
-
getItemProps
|
|
125
|
-
} = (0, _useRovingTabIndex.default)({
|
|
126
|
-
orientation,
|
|
127
|
-
isRtl
|
|
128
|
-
});
|
|
129
|
-
const rovingTabIndexContainerProps = getContainerProps(ref);
|
|
130
153
|
const contextValue = React.useMemo(() => ({
|
|
131
154
|
activeStep,
|
|
132
155
|
alternativeLabel,
|
|
@@ -134,21 +157,30 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
134
157
|
nonLinear,
|
|
135
158
|
orientation,
|
|
136
159
|
totalSteps,
|
|
137
|
-
getRovingTabIndexProps: getItemProps,
|
|
138
160
|
isTabList
|
|
139
|
-
}), [activeStep, alternativeLabel, connector, nonLinear, orientation, totalSteps,
|
|
140
|
-
|
|
161
|
+
}), [activeStep, alternativeLabel, connector, nonLinear, orientation, totalSteps, isTabList]);
|
|
162
|
+
if (!isTabList) {
|
|
163
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepperContext.default.Provider, {
|
|
164
|
+
value: contextValue,
|
|
165
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StepperRoot, {
|
|
166
|
+
as: component,
|
|
167
|
+
ownerState: ownerState,
|
|
168
|
+
className: (0, _clsx.default)(classes.root, className),
|
|
169
|
+
ref: ref,
|
|
170
|
+
...other,
|
|
171
|
+
children: steps
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_StepperContext.default.Provider, {
|
|
141
176
|
value: contextValue,
|
|
142
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
143
|
-
|
|
144
|
-
|
|
177
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RovingStepper, {
|
|
178
|
+
forwardedRef: ref,
|
|
179
|
+
isRtl: isRtl,
|
|
145
180
|
className: (0, _clsx.default)(classes.root, className),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
'aria-orientation': orientation,
|
|
150
|
-
...rovingTabIndexContainerProps
|
|
151
|
-
}),
|
|
181
|
+
component: component,
|
|
182
|
+
orientation: orientation,
|
|
183
|
+
ownerState: ownerState,
|
|
152
184
|
...other,
|
|
153
185
|
children: steps
|
|
154
186
|
})
|
package/Stepper/Stepper.mjs
CHANGED
|
@@ -6,12 +6,12 @@ import clsx from 'clsx';
|
|
|
6
6
|
import integerPropType from '@mui/utils/integerPropType';
|
|
7
7
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
9
|
-
import useRovingTabIndex from "../utils/useRovingTabIndex.mjs";
|
|
10
9
|
import { styled } from "../zero-styled/index.mjs";
|
|
11
10
|
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
11
|
+
import { RovingTabIndexContext, useRovingTabIndexRoot } from "../utils/useRovingTabIndex.mjs";
|
|
12
12
|
import { getStepperUtilityClass } from "./stepperClasses.mjs";
|
|
13
13
|
import StepConnector from "../StepConnector/index.mjs";
|
|
14
|
-
import
|
|
14
|
+
import StepperContext from "./StepperContext.mjs";
|
|
15
15
|
import StepButton from "../StepButton/index.mjs";
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
const useUtilityClasses = ownerState => {
|
|
@@ -65,6 +65,37 @@ const StepperRoot = styled('ol', {
|
|
|
65
65
|
}]
|
|
66
66
|
});
|
|
67
67
|
const defaultConnector = /*#__PURE__*/_jsx(StepConnector, {});
|
|
68
|
+
function RovingStepper(props) {
|
|
69
|
+
// eslint-disable-next-line react/prop-types
|
|
70
|
+
const {
|
|
71
|
+
children,
|
|
72
|
+
className,
|
|
73
|
+
component,
|
|
74
|
+
forwardedRef,
|
|
75
|
+
isRtl,
|
|
76
|
+
orientation,
|
|
77
|
+
ownerState,
|
|
78
|
+
...other
|
|
79
|
+
} = props;
|
|
80
|
+
const rovingContainer = useRovingTabIndexRoot({
|
|
81
|
+
orientation,
|
|
82
|
+
isRtl
|
|
83
|
+
});
|
|
84
|
+
const rovingContainerProps = rovingContainer.getContainerProps(forwardedRef);
|
|
85
|
+
return /*#__PURE__*/_jsx(RovingTabIndexContext.Provider, {
|
|
86
|
+
value: rovingContainer,
|
|
87
|
+
children: /*#__PURE__*/_jsx(StepperRoot, {
|
|
88
|
+
as: component,
|
|
89
|
+
ownerState: ownerState,
|
|
90
|
+
className: className,
|
|
91
|
+
role: "tablist",
|
|
92
|
+
"aria-orientation": orientation,
|
|
93
|
+
...rovingContainerProps,
|
|
94
|
+
...other,
|
|
95
|
+
children: children
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
}
|
|
68
99
|
const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
69
100
|
const isRtl = useRtl();
|
|
70
101
|
const props = useDefaultProps({
|
|
@@ -112,14 +143,6 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
112
143
|
...step.props
|
|
113
144
|
});
|
|
114
145
|
});
|
|
115
|
-
const {
|
|
116
|
-
getContainerProps,
|
|
117
|
-
getItemProps
|
|
118
|
-
} = useRovingTabIndex({
|
|
119
|
-
orientation,
|
|
120
|
-
isRtl
|
|
121
|
-
});
|
|
122
|
-
const rovingTabIndexContainerProps = getContainerProps(ref);
|
|
123
146
|
const contextValue = React.useMemo(() => ({
|
|
124
147
|
activeStep,
|
|
125
148
|
alternativeLabel,
|
|
@@ -127,21 +150,30 @@ const Stepper = /*#__PURE__*/React.forwardRef(function Stepper(inProps, ref) {
|
|
|
127
150
|
nonLinear,
|
|
128
151
|
orientation,
|
|
129
152
|
totalSteps,
|
|
130
|
-
getRovingTabIndexProps: getItemProps,
|
|
131
153
|
isTabList
|
|
132
|
-
}), [activeStep, alternativeLabel, connector, nonLinear, orientation, totalSteps,
|
|
133
|
-
|
|
154
|
+
}), [activeStep, alternativeLabel, connector, nonLinear, orientation, totalSteps, isTabList]);
|
|
155
|
+
if (!isTabList) {
|
|
156
|
+
return /*#__PURE__*/_jsx(StepperContext.Provider, {
|
|
157
|
+
value: contextValue,
|
|
158
|
+
children: /*#__PURE__*/_jsx(StepperRoot, {
|
|
159
|
+
as: component,
|
|
160
|
+
ownerState: ownerState,
|
|
161
|
+
className: clsx(classes.root, className),
|
|
162
|
+
ref: ref,
|
|
163
|
+
...other,
|
|
164
|
+
children: steps
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return /*#__PURE__*/_jsx(StepperContext.Provider, {
|
|
134
169
|
value: contextValue,
|
|
135
|
-
children: /*#__PURE__*/_jsx(
|
|
136
|
-
|
|
137
|
-
|
|
170
|
+
children: /*#__PURE__*/_jsx(RovingStepper, {
|
|
171
|
+
forwardedRef: ref,
|
|
172
|
+
isRtl: isRtl,
|
|
138
173
|
className: clsx(classes.root, className),
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
'aria-orientation': orientation,
|
|
143
|
-
...rovingTabIndexContainerProps
|
|
144
|
-
}),
|
|
174
|
+
component: component,
|
|
175
|
+
orientation: orientation,
|
|
176
|
+
ownerState: ownerState,
|
|
145
177
|
...other,
|
|
146
178
|
children: steps
|
|
147
179
|
})
|
|
@@ -6,10 +6,6 @@ export interface StepperContextType {
|
|
|
6
6
|
nonLinear: boolean;
|
|
7
7
|
orientation: 'horizontal' | 'vertical';
|
|
8
8
|
totalSteps: number;
|
|
9
|
-
getRovingTabIndexProps: (index: number, ref?: React.Ref<HTMLElement>) => {
|
|
10
|
-
ref: (element: HTMLElement | null) => void;
|
|
11
|
-
tabIndex: number;
|
|
12
|
-
};
|
|
13
9
|
isTabList: boolean;
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
@@ -21,5 +17,4 @@ declare const StepperContext: React.Context<{} | StepperContextType>;
|
|
|
21
17
|
* has been defined in the component tree.
|
|
22
18
|
*/
|
|
23
19
|
export declare function useStepperContext(): StepperContextType | {};
|
|
24
|
-
export declare const StepperContextProvider: React.Provider<{} | StepperContextType>;
|
|
25
20
|
export default StepperContext;
|
|
@@ -6,10 +6,6 @@ export interface StepperContextType {
|
|
|
6
6
|
nonLinear: boolean;
|
|
7
7
|
orientation: 'horizontal' | 'vertical';
|
|
8
8
|
totalSteps: number;
|
|
9
|
-
getRovingTabIndexProps: (index: number, ref?: React.Ref<HTMLElement>) => {
|
|
10
|
-
ref: (element: HTMLElement | null) => void;
|
|
11
|
-
tabIndex: number;
|
|
12
|
-
};
|
|
13
9
|
isTabList: boolean;
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
@@ -21,5 +17,4 @@ declare const StepperContext: React.Context<{} | StepperContextType>;
|
|
|
21
17
|
* has been defined in the component tree.
|
|
22
18
|
*/
|
|
23
19
|
export declare function useStepperContext(): StepperContextType | {};
|
|
24
|
-
export declare const StepperContextProvider: React.Provider<{} | StepperContextType>;
|
|
25
20
|
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 =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
exports.useStepperContext = useStepperContext;
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
/**
|
|
@@ -23,5 +23,4 @@ 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;
|
|
27
26
|
var _default = exports.default = StepperContext;
|
package/Tab/Tab.js
CHANGED
|
@@ -17,6 +17,7 @@ var _zeroStyled = require("../zero-styled");
|
|
|
17
17
|
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
|
|
18
18
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
19
19
|
var _unsupportedProp = _interopRequireDefault(require("../utils/unsupportedProp"));
|
|
20
|
+
var _useRovingTabIndex = require("../utils/useRovingTabIndex");
|
|
20
21
|
var _tabClasses = _interopRequireWildcard(require("./tabClasses"));
|
|
21
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
23
|
const useUtilityClasses = ownerState => {
|
|
@@ -213,6 +214,19 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(inProps, ref) {
|
|
|
213
214
|
wrapped = false,
|
|
214
215
|
...other
|
|
215
216
|
} = props;
|
|
217
|
+
const rovingContext = (0, _useRovingTabIndex.useRovingTabIndexContext)();
|
|
218
|
+
const rovingItemProps = (0, _useRovingTabIndex.useRovingTabIndexItem)({
|
|
219
|
+
id: value,
|
|
220
|
+
ref,
|
|
221
|
+
disabled,
|
|
222
|
+
selected
|
|
223
|
+
});
|
|
224
|
+
// On the server, and on the first client render before registration effects run,
|
|
225
|
+
// the roving item map is still empty. In that window, fall back to `tabIndex={0}`
|
|
226
|
+
// for the selected tab so the rendered markup is immediately keyboard-accessible
|
|
227
|
+
// and hydration stays consistent until item registration takes over.
|
|
228
|
+
const shouldUseSelectedTabStopFallback = rovingContext.getItemMap().size === 0 && selected;
|
|
229
|
+
const tabIndex = shouldUseSelectedTabStopFallback ? 0 : rovingItemProps.tabIndex;
|
|
216
230
|
const ownerState = {
|
|
217
231
|
...props,
|
|
218
232
|
disabled,
|
|
@@ -246,14 +260,16 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(inProps, ref) {
|
|
|
246
260
|
}
|
|
247
261
|
};
|
|
248
262
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(TabRoot, {
|
|
263
|
+
internalNativeButton: true,
|
|
249
264
|
focusRipple: !disableFocusRipple,
|
|
250
265
|
className: (0, _clsx.default)(classes.root, className),
|
|
251
|
-
ref: ref,
|
|
266
|
+
ref: rovingItemProps.ref,
|
|
252
267
|
role: "tab",
|
|
253
268
|
"aria-selected": selected,
|
|
254
269
|
disabled: disabled,
|
|
255
270
|
onClick: handleClick,
|
|
256
271
|
onFocus: handleFocus,
|
|
272
|
+
tabIndex: tabIndex,
|
|
257
273
|
ownerState: ownerState,
|
|
258
274
|
...other,
|
|
259
275
|
children: [iconPosition === 'top' || iconPosition === 'start' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
package/Tab/Tab.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { styled } from "../zero-styled/index.mjs";
|
|
|
10
10
|
import memoTheme from "../utils/memoTheme.mjs";
|
|
11
11
|
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
12
12
|
import unsupportedProp from "../utils/unsupportedProp.mjs";
|
|
13
|
+
import { useRovingTabIndexContext, useRovingTabIndexItem } from "../utils/useRovingTabIndex.mjs";
|
|
13
14
|
import tabClasses, { getTabUtilityClass } from "./tabClasses.mjs";
|
|
14
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
16
|
const useUtilityClasses = ownerState => {
|
|
@@ -206,6 +207,19 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(inProps, ref) {
|
|
|
206
207
|
wrapped = false,
|
|
207
208
|
...other
|
|
208
209
|
} = props;
|
|
210
|
+
const rovingContext = useRovingTabIndexContext();
|
|
211
|
+
const rovingItemProps = useRovingTabIndexItem({
|
|
212
|
+
id: value,
|
|
213
|
+
ref,
|
|
214
|
+
disabled,
|
|
215
|
+
selected
|
|
216
|
+
});
|
|
217
|
+
// On the server, and on the first client render before registration effects run,
|
|
218
|
+
// the roving item map is still empty. In that window, fall back to `tabIndex={0}`
|
|
219
|
+
// for the selected tab so the rendered markup is immediately keyboard-accessible
|
|
220
|
+
// and hydration stays consistent until item registration takes over.
|
|
221
|
+
const shouldUseSelectedTabStopFallback = rovingContext.getItemMap().size === 0 && selected;
|
|
222
|
+
const tabIndex = shouldUseSelectedTabStopFallback ? 0 : rovingItemProps.tabIndex;
|
|
209
223
|
const ownerState = {
|
|
210
224
|
...props,
|
|
211
225
|
disabled,
|
|
@@ -239,14 +253,16 @@ const Tab = /*#__PURE__*/React.forwardRef(function Tab(inProps, ref) {
|
|
|
239
253
|
}
|
|
240
254
|
};
|
|
241
255
|
return /*#__PURE__*/_jsxs(TabRoot, {
|
|
256
|
+
internalNativeButton: true,
|
|
242
257
|
focusRipple: !disableFocusRipple,
|
|
243
258
|
className: clsx(classes.root, className),
|
|
244
|
-
ref: ref,
|
|
259
|
+
ref: rovingItemProps.ref,
|
|
245
260
|
role: "tab",
|
|
246
261
|
"aria-selected": selected,
|
|
247
262
|
disabled: disabled,
|
|
248
263
|
onClick: handleClick,
|
|
249
264
|
onFocus: handleFocus,
|
|
265
|
+
tabIndex: tabIndex,
|
|
250
266
|
ownerState: ownerState,
|
|
251
267
|
...other,
|
|
252
268
|
children: [iconPosition === 'top' || iconPosition === 'start' ? /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -10,7 +10,7 @@ export interface TabScrollButtonEndIconSlotPropsOverrides {}
|
|
|
10
10
|
export interface TabScrollButtonOwnerState extends TabScrollButtonProps {
|
|
11
11
|
isRtl: boolean;
|
|
12
12
|
}
|
|
13
|
-
export interface TabScrollButtonProps extends ButtonBaseProps {
|
|
13
|
+
export interface TabScrollButtonProps extends Omit<ButtonBaseProps, 'nativeButton'> {
|
|
14
14
|
/**
|
|
15
15
|
* The content of the component.
|
|
16
16
|
*/
|
|
@@ -10,7 +10,7 @@ export interface TabScrollButtonEndIconSlotPropsOverrides {}
|
|
|
10
10
|
export interface TabScrollButtonOwnerState extends TabScrollButtonProps {
|
|
11
11
|
isRtl: boolean;
|
|
12
12
|
}
|
|
13
|
-
export interface TabScrollButtonProps extends ButtonBaseProps {
|
|
13
|
+
export interface TabScrollButtonProps extends Omit<ButtonBaseProps, 'nativeButton'> {
|
|
14
14
|
/**
|
|
15
15
|
* The content of the component.
|
|
16
16
|
*/
|
|
@@ -75,6 +75,10 @@ const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(i
|
|
|
75
75
|
disabled,
|
|
76
76
|
...other
|
|
77
77
|
} = props;
|
|
78
|
+
const {
|
|
79
|
+
nativeButton,
|
|
80
|
+
...buttonBaseProps
|
|
81
|
+
} = other;
|
|
78
82
|
const isRtl = (0, _RtlProvider.useRtl)();
|
|
79
83
|
const ownerState = {
|
|
80
84
|
isRtl,
|
|
@@ -106,9 +110,9 @@ const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(i
|
|
|
106
110
|
role: null,
|
|
107
111
|
ownerState: ownerState,
|
|
108
112
|
tabIndex: null,
|
|
109
|
-
...
|
|
113
|
+
...buttonBaseProps,
|
|
110
114
|
style: {
|
|
111
|
-
...
|
|
115
|
+
...buttonBaseProps.style,
|
|
112
116
|
...(orientation === 'vertical' && {
|
|
113
117
|
'--TabScrollButton-svgRotate': `rotate(${isRtl ? -90 : 90}deg)`
|
|
114
118
|
})
|
|
@@ -68,6 +68,10 @@ const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(i
|
|
|
68
68
|
disabled,
|
|
69
69
|
...other
|
|
70
70
|
} = props;
|
|
71
|
+
const {
|
|
72
|
+
nativeButton,
|
|
73
|
+
...buttonBaseProps
|
|
74
|
+
} = other;
|
|
71
75
|
const isRtl = useRtl();
|
|
72
76
|
const ownerState = {
|
|
73
77
|
isRtl,
|
|
@@ -99,9 +103,9 @@ const TabScrollButton = /*#__PURE__*/React.forwardRef(function TabScrollButton(i
|
|
|
99
103
|
role: null,
|
|
100
104
|
ownerState: ownerState,
|
|
101
105
|
tabIndex: null,
|
|
102
|
-
...
|
|
106
|
+
...buttonBaseProps,
|
|
103
107
|
style: {
|
|
104
|
-
...
|
|
108
|
+
...buttonBaseProps.style,
|
|
105
109
|
...(orientation === 'vertical' && {
|
|
106
110
|
'--TabScrollButton-svgRotate': `rotate(${isRtl ? -90 : 90}deg)`
|
|
107
111
|
})
|
|
@@ -134,7 +134,10 @@ const TableSortLabel = /*#__PURE__*/React.forwardRef(function TableSortLabel(inP
|
|
|
134
134
|
externalForwardedProps,
|
|
135
135
|
ownerState,
|
|
136
136
|
className: (0, _clsx.default)(classes.root, className),
|
|
137
|
-
ref
|
|
137
|
+
ref,
|
|
138
|
+
additionalProps: {
|
|
139
|
+
internalNativeButton: false
|
|
140
|
+
}
|
|
138
141
|
});
|
|
139
142
|
const [IconSlot, iconProps] = (0, _useSlot.default)('icon', {
|
|
140
143
|
elementType: TableSortLabelIcon,
|
|
@@ -127,7 +127,10 @@ const TableSortLabel = /*#__PURE__*/React.forwardRef(function TableSortLabel(inP
|
|
|
127
127
|
externalForwardedProps,
|
|
128
128
|
ownerState,
|
|
129
129
|
className: clsx(classes.root, className),
|
|
130
|
-
ref
|
|
130
|
+
ref,
|
|
131
|
+
additionalProps: {
|
|
132
|
+
internalNativeButton: false
|
|
133
|
+
}
|
|
131
134
|
});
|
|
132
135
|
const [IconSlot, iconProps] = useSlot('icon', {
|
|
133
136
|
elementType: TableSortLabelIcon,
|
package/Tabs/Tabs.js
CHANGED
|
@@ -27,7 +27,10 @@ var _tabsClasses = _interopRequireWildcard(require("./tabsClasses"));
|
|
|
27
27
|
var _ownerWindow = _interopRequireDefault(require("../utils/ownerWindow"));
|
|
28
28
|
var _isLayoutSupported = _interopRequireDefault(require("../utils/isLayoutSupported"));
|
|
29
29
|
var _useSlot = _interopRequireDefault(require("../utils/useSlot"));
|
|
30
|
-
var
|
|
30
|
+
var _getActiveElement = _interopRequireDefault(require("../utils/getActiveElement"));
|
|
31
|
+
var _ownerDocument = _interopRequireDefault(require("../utils/ownerDocument"));
|
|
32
|
+
var _useForkRef = _interopRequireDefault(require("../utils/useForkRef"));
|
|
33
|
+
var _useRovingTabIndex = require("../utils/useRovingTabIndex");
|
|
31
34
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
32
35
|
const useUtilityClasses = ownerState => {
|
|
33
36
|
const {
|
|
@@ -294,6 +297,10 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
294
297
|
const [displayStartScroll, setDisplayStartScroll] = React.useState(false);
|
|
295
298
|
const [displayEndScroll, setDisplayEndScroll] = React.useState(false);
|
|
296
299
|
const [updateScrollObserver, setUpdateScrollObserver] = React.useState(false);
|
|
300
|
+
const selectedValue = value === false ? null : value;
|
|
301
|
+
// Tracks whether DOM focus is currently inside the tab list. When it is, roving focus
|
|
302
|
+
// should follow in-list keyboard movement instead of snapping back to `selectedValue`.
|
|
303
|
+
const [isFocusWithinList, setIsFocusWithinList] = React.useState(false);
|
|
297
304
|
const [scrollerStyle, setScrollerStyle] = React.useState({
|
|
298
305
|
overflow: 'hidden',
|
|
299
306
|
scrollbarWidth: 0
|
|
@@ -621,6 +628,12 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
621
628
|
const indicator = /*#__PURE__*/(0, _jsxRuntime.jsx)(IndicatorSlot, {
|
|
622
629
|
...indicatorSlotProps
|
|
623
630
|
});
|
|
631
|
+
const rovingContainer = (0, _useRovingTabIndex.useRovingTabIndexRoot)({
|
|
632
|
+
activeItemId: isFocusWithinList ? undefined : selectedValue,
|
|
633
|
+
orientation,
|
|
634
|
+
isRtl
|
|
635
|
+
});
|
|
636
|
+
const rovingContainerProps = rovingContainer.getContainerProps();
|
|
624
637
|
const validChildren = React.Children.toArray(childrenProp).filter(React.isValidElement).map((child, index) => {
|
|
625
638
|
const childValue = child.props.value === undefined ? index : child.props.value;
|
|
626
639
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -635,23 +648,11 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
635
648
|
childValue
|
|
636
649
|
};
|
|
637
650
|
});
|
|
638
|
-
const focusableIndex = valueToIndex.get(value);
|
|
639
|
-
const {
|
|
640
|
-
getContainerProps,
|
|
641
|
-
getItemProps
|
|
642
|
-
} = (0, _utils.useRovingTabIndex)({
|
|
643
|
-
focusableIndex,
|
|
644
|
-
orientation,
|
|
645
|
-
isRtl
|
|
646
|
-
});
|
|
647
|
-
const rovingTabIndexContainerProps = getContainerProps();
|
|
648
651
|
const children = validChildren.map(({
|
|
649
652
|
child,
|
|
650
|
-
index,
|
|
651
653
|
childValue
|
|
652
654
|
}) => {
|
|
653
655
|
const selected = childValue === value;
|
|
654
|
-
const rovingTabIndexItemProps = getItemProps(index, child.ref);
|
|
655
656
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
656
657
|
fullWidth: variant === 'fullWidth',
|
|
657
658
|
indicator: selected && !mounted && indicator,
|
|
@@ -659,9 +660,7 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
659
660
|
selectionFollowsFocus,
|
|
660
661
|
onChange,
|
|
661
662
|
textColor,
|
|
662
|
-
value: childValue
|
|
663
|
-
ref: rovingTabIndexItemProps.ref,
|
|
664
|
-
tabIndex: child.props.tabIndex ?? rovingTabIndexItemProps.tabIndex
|
|
663
|
+
value: childValue
|
|
665
664
|
});
|
|
666
665
|
});
|
|
667
666
|
const conditionalElements = getConditionalElements();
|
|
@@ -689,10 +688,10 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
689
688
|
}
|
|
690
689
|
}
|
|
691
690
|
});
|
|
692
|
-
const mergedRef = (0,
|
|
691
|
+
const mergedRef = (0, _useForkRef.default)(rovingContainerProps.ref, tabListRef);
|
|
693
692
|
const handleKeyDown = event => {
|
|
694
693
|
const list = tabListRef.current;
|
|
695
|
-
const currentFocus = (0,
|
|
694
|
+
const currentFocus = (0, _getActiveElement.default)((0, _ownerDocument.default)(list));
|
|
696
695
|
// Keyboard navigation assumes that [role="tab"] are siblings
|
|
697
696
|
// though we might warn in the future about nested, interactive elements
|
|
698
697
|
// as a a11y violation
|
|
@@ -700,7 +699,7 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
700
699
|
if (role !== 'tab') {
|
|
701
700
|
return;
|
|
702
701
|
}
|
|
703
|
-
|
|
702
|
+
rovingContainerProps.onKeyDown(event);
|
|
704
703
|
};
|
|
705
704
|
const [ListSlot, listSlotProps] = (0, _useSlot.default)('list', {
|
|
706
705
|
ref: mergedRef,
|
|
@@ -710,12 +709,19 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
710
709
|
ownerState,
|
|
711
710
|
getSlotProps: handlers => ({
|
|
712
711
|
...handlers,
|
|
712
|
+
onBlur: event => {
|
|
713
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
714
|
+
setIsFocusWithinList(false);
|
|
715
|
+
}
|
|
716
|
+
handlers.onBlur?.(event);
|
|
717
|
+
},
|
|
713
718
|
onKeyDown: event => {
|
|
714
719
|
handleKeyDown(event);
|
|
715
720
|
handlers.onKeyDown?.(event);
|
|
716
721
|
},
|
|
717
722
|
onFocus: event => {
|
|
718
|
-
|
|
723
|
+
setIsFocusWithinList(true);
|
|
724
|
+
rovingContainerProps.onFocus(event);
|
|
719
725
|
handlers.onFocus?.(event);
|
|
720
726
|
}
|
|
721
727
|
})
|
|
@@ -730,7 +736,10 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
730
736
|
"aria-orientation": orientation === 'vertical' ? 'vertical' : null,
|
|
731
737
|
role: "tablist",
|
|
732
738
|
...listSlotProps,
|
|
733
|
-
children:
|
|
739
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_useRovingTabIndex.RovingTabIndexContext.Provider, {
|
|
740
|
+
value: rovingContainer,
|
|
741
|
+
children: children
|
|
742
|
+
})
|
|
734
743
|
}), mounted && indicator]
|
|
735
744
|
}), conditionalElements.scrollButtonEnd]
|
|
736
745
|
});
|