@mui/material 6.4.5 → 6.4.6
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.ts +14 -12
- package/Alert/Alert.d.ts +3 -15
- package/Backdrop/Backdrop.d.ts +14 -12
- package/CHANGELOG.md +38 -0
- package/CardHeader/CardHeader.d.ts +4 -20
- package/Checkbox/Checkbox.d.ts +45 -9
- package/Checkbox/Checkbox.js +51 -21
- package/Dialog/Dialog.d.ts +4 -4
- package/Drawer/Drawer.d.ts +92 -1
- package/Drawer/Drawer.js +108 -36
- package/InputBase/inputBaseClasses.d.ts +15 -6
- package/Menu/Menu.d.ts +88 -1
- package/Menu/Menu.js +58 -19
- package/Modal/Modal.js +9 -10
- package/Popover/Popover.d.ts +60 -6
- package/Popover/Popover.js +78 -51
- package/Radio/Radio.d.ts +45 -1
- package/Radio/Radio.js +59 -16
- package/Select/SelectInput.js +8 -8
- package/Snackbar/Snackbar.d.ts +79 -2
- package/Snackbar/Snackbar.js +110 -32
- package/SpeedDial/SpeedDial.d.ts +8 -6
- package/SpeedDialAction/SpeedDialAction.d.ts +82 -1
- package/SpeedDialAction/SpeedDialAction.js +108 -30
- package/StepContent/StepContent.d.ts +2 -2
- package/SwipeableDrawer/SwipeableDrawer.d.ts +28 -2
- package/SwipeableDrawer/SwipeableDrawer.js +60 -13
- package/Switch/Switch.js +2 -0
- package/Tabs/Tabs.d.ts +129 -29
- package/Tabs/Tabs.js +120 -52
- package/Tabs/tabsClasses.d.ts +4 -0
- package/Tabs/tabsClasses.js +1 -1
- package/Tooltip/Tooltip.d.ts +20 -12
- package/index.js +1 -1
- package/internal/SwitchBase.d.ts +35 -1
- package/internal/SwitchBase.js +84 -30
- package/modern/Checkbox/Checkbox.js +51 -21
- package/modern/Drawer/Drawer.js +108 -36
- package/modern/Menu/Menu.js +58 -19
- package/modern/Modal/Modal.js +9 -10
- package/modern/Popover/Popover.js +78 -51
- package/modern/Radio/Radio.js +59 -16
- package/modern/Select/SelectInput.js +8 -8
- package/modern/Snackbar/Snackbar.js +110 -32
- package/modern/SpeedDialAction/SpeedDialAction.js +108 -30
- package/modern/SwipeableDrawer/SwipeableDrawer.js +60 -13
- package/modern/Switch/Switch.js +2 -0
- package/modern/Tabs/Tabs.js +120 -52
- package/modern/Tabs/tabsClasses.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internal/SwitchBase.js +84 -30
- package/modern/styles/createThemeNoVars.js +7 -2
- package/modern/version/index.js +2 -2
- package/node/Checkbox/Checkbox.js +51 -21
- package/node/Drawer/Drawer.js +108 -36
- package/node/Menu/Menu.js +58 -19
- package/node/Modal/Modal.js +9 -10
- package/node/Popover/Popover.js +78 -51
- package/node/Radio/Radio.js +59 -16
- package/node/Select/SelectInput.js +8 -8
- package/node/Snackbar/Snackbar.js +110 -32
- package/node/SpeedDialAction/SpeedDialAction.js +108 -30
- package/node/SwipeableDrawer/SwipeableDrawer.js +60 -13
- package/node/Switch/Switch.js +2 -0
- package/node/Tabs/Tabs.js +120 -52
- package/node/Tabs/tabsClasses.js +1 -1
- package/node/index.js +1 -1
- package/node/internal/SwitchBase.js +84 -30
- package/node/styles/createThemeNoVars.js +7 -2
- package/node/version/index.js +2 -2
- package/package.json +6 -6
- package/styles/createThemeNoVars.js +7 -2
- package/version/index.js +2 -2
|
@@ -14,6 +14,8 @@ import useEnhancedEffect from "../utils/useEnhancedEffect.js";
|
|
|
14
14
|
import { useTheme } from "../zero-styled/index.js";
|
|
15
15
|
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
16
16
|
import { getTransitionProps } from "../transitions/utils.js";
|
|
17
|
+
import { mergeSlotProps } from "../utils/index.js";
|
|
18
|
+
import useSlot from "../utils/useSlot.js";
|
|
17
19
|
import SwipeArea from "./SwipeArea.js";
|
|
18
20
|
|
|
19
21
|
// This value is closed to what browsers are using internally to
|
|
@@ -145,6 +147,8 @@ const SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(i
|
|
|
145
147
|
transitionDuration = transitionDurationDefault,
|
|
146
148
|
variant = 'temporary',
|
|
147
149
|
// Mobile first.
|
|
150
|
+
slots = {},
|
|
151
|
+
slotProps = {},
|
|
148
152
|
...other
|
|
149
153
|
} = props;
|
|
150
154
|
const [maybeSwiping, setMaybeSwiping] = React.useState(false);
|
|
@@ -450,6 +454,22 @@ const SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(i
|
|
|
450
454
|
setMaybeSwiping(false);
|
|
451
455
|
}
|
|
452
456
|
}, [open]);
|
|
457
|
+
const [SwipeAreaSlot, swipeAreaSlotProps] = useSlot('swipeArea', {
|
|
458
|
+
ref: swipeAreaRef,
|
|
459
|
+
elementType: SwipeArea,
|
|
460
|
+
ownerState: props,
|
|
461
|
+
externalForwardedProps: {
|
|
462
|
+
slots,
|
|
463
|
+
slotProps: {
|
|
464
|
+
swipeArea: SwipeAreaProps,
|
|
465
|
+
...slotProps
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
additionalProps: {
|
|
469
|
+
width: swipeAreaWidth,
|
|
470
|
+
anchor
|
|
471
|
+
}
|
|
472
|
+
});
|
|
453
473
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
454
474
|
children: [/*#__PURE__*/_jsx(Drawer, {
|
|
455
475
|
open: variant === 'temporary' && maybeSwiping ? true : open,
|
|
@@ -467,25 +487,27 @@ const SwipeableDrawer = /*#__PURE__*/React.forwardRef(function SwipeableDrawer(i
|
|
|
467
487
|
...ModalPropsProp
|
|
468
488
|
},
|
|
469
489
|
hideBackdrop: hideBackdrop,
|
|
470
|
-
PaperProps: {
|
|
471
|
-
...PaperProps,
|
|
472
|
-
style: {
|
|
473
|
-
pointerEvents: variant === 'temporary' && !open && !allowSwipeInChildren ? 'none' : '',
|
|
474
|
-
...PaperProps.style
|
|
475
|
-
},
|
|
476
|
-
ref: handleRef
|
|
477
|
-
},
|
|
478
490
|
anchor: anchor,
|
|
479
491
|
transitionDuration: calculatedDurationRef.current || transitionDuration,
|
|
480
492
|
onClose: onClose,
|
|
481
493
|
ref: ref,
|
|
494
|
+
slots: slots,
|
|
495
|
+
slotProps: {
|
|
496
|
+
...slotProps,
|
|
497
|
+
backdrop: mergeSlotProps(slotProps.backdrop ?? BackdropProps, {
|
|
498
|
+
ref: backdropRef
|
|
499
|
+
}),
|
|
500
|
+
paper: mergeSlotProps(slotProps.paper ?? PaperProps, {
|
|
501
|
+
style: {
|
|
502
|
+
pointerEvents: variant === 'temporary' && !open && !allowSwipeInChildren ? 'none' : ''
|
|
503
|
+
},
|
|
504
|
+
ref: handleRef
|
|
505
|
+
})
|
|
506
|
+
},
|
|
482
507
|
...other
|
|
483
508
|
}), !disableSwipeToOpen && variant === 'temporary' && /*#__PURE__*/_jsx(NoSsr, {
|
|
484
|
-
children: /*#__PURE__*/_jsx(
|
|
485
|
-
|
|
486
|
-
ref: swipeAreaRef,
|
|
487
|
-
width: swipeAreaWidth,
|
|
488
|
-
...SwipeAreaProps
|
|
509
|
+
children: /*#__PURE__*/_jsx(SwipeAreaSlot, {
|
|
510
|
+
...swipeAreaSlotProps
|
|
489
511
|
})
|
|
490
512
|
})]
|
|
491
513
|
});
|
|
@@ -583,8 +605,33 @@ process.env.NODE_ENV !== "production" ? SwipeableDrawer.propTypes /* remove-prop
|
|
|
583
605
|
component: elementTypeAcceptingRef,
|
|
584
606
|
style: PropTypes.object
|
|
585
607
|
}),
|
|
608
|
+
/**
|
|
609
|
+
* The props used for each slot inside.
|
|
610
|
+
* @default {}
|
|
611
|
+
*/
|
|
612
|
+
slotProps: PropTypes.shape({
|
|
613
|
+
backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
614
|
+
docked: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
615
|
+
paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
616
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
617
|
+
swipeArea: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
618
|
+
transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
619
|
+
}),
|
|
620
|
+
/**
|
|
621
|
+
* The components used for each slot inside.
|
|
622
|
+
* @default {}
|
|
623
|
+
*/
|
|
624
|
+
slots: PropTypes.shape({
|
|
625
|
+
backdrop: PropTypes.elementType,
|
|
626
|
+
docked: PropTypes.elementType,
|
|
627
|
+
paper: PropTypes.elementType,
|
|
628
|
+
root: PropTypes.elementType,
|
|
629
|
+
swipeArea: PropTypes.elementType,
|
|
630
|
+
transition: PropTypes.elementType
|
|
631
|
+
}),
|
|
586
632
|
/**
|
|
587
633
|
* The element is used to intercept the touch events on the edge.
|
|
634
|
+
* @deprecated use the `slotProps.swipeArea` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
588
635
|
*/
|
|
589
636
|
SwipeAreaProps: PropTypes.object,
|
|
590
637
|
/**
|
package/Switch/Switch.js
CHANGED
|
@@ -305,10 +305,12 @@ process.env.NODE_ENV !== "production" ? Switch.propTypes /* remove-proptypes */
|
|
|
305
305
|
id: PropTypes.string,
|
|
306
306
|
/**
|
|
307
307
|
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
308
|
+
* @deprecated Use `slotProps.input` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
308
309
|
*/
|
|
309
310
|
inputProps: PropTypes.object,
|
|
310
311
|
/**
|
|
311
312
|
* Pass a ref to the `input` element.
|
|
313
|
+
* @deprecated Use `slotProps.input.ref` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
312
314
|
*/
|
|
313
315
|
inputRef: refType,
|
|
314
316
|
/**
|
package/Tabs/Tabs.d.ts
CHANGED
|
@@ -1,19 +1,141 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps } from '@mui/system';
|
|
3
3
|
import { OverridableStringUnion } from '@mui/types';
|
|
4
|
-
import {
|
|
4
|
+
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
|
|
5
5
|
import { Theme } from '../styles';
|
|
6
|
-
import { TabScrollButtonProps } from '../TabScrollButton';
|
|
6
|
+
import TabScrollButton, { TabScrollButtonProps } from '../TabScrollButton';
|
|
7
7
|
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
|
|
8
8
|
import { TabsClasses } from './tabsClasses';
|
|
9
9
|
import SvgIcon from '../SvgIcon';
|
|
10
10
|
|
|
11
11
|
export interface TabsPropsIndicatorColorOverrides {}
|
|
12
12
|
|
|
13
|
+
export interface TabsRootSlotPropsOverrides {}
|
|
14
|
+
export interface TabsScrollerSlotPropsOverrides {}
|
|
15
|
+
export interface TabsListSlotPropsOverrides {}
|
|
16
|
+
export interface TabsScrollbarSlotPropsOverrides {}
|
|
17
|
+
export interface TabsIndicatorSlotPropsOverrides {}
|
|
18
|
+
export interface TabsScrollButtonsSlotPropsOverrides {}
|
|
13
19
|
export interface TabsStartScrollButtonIconSlotPropsOverrides {}
|
|
14
20
|
export interface TabsEndScrollButtonIconSlotPropsOverrides {}
|
|
15
21
|
|
|
16
|
-
export interface
|
|
22
|
+
export interface TabsSlots {
|
|
23
|
+
/**
|
|
24
|
+
* The component used for the popper.
|
|
25
|
+
* @default div
|
|
26
|
+
*/
|
|
27
|
+
root: React.ElementType;
|
|
28
|
+
/**
|
|
29
|
+
* The component used for the scroller.
|
|
30
|
+
* @default div
|
|
31
|
+
*/
|
|
32
|
+
scroller: React.ElementType;
|
|
33
|
+
/**
|
|
34
|
+
* The component used for the flex container.
|
|
35
|
+
* @default div
|
|
36
|
+
*/
|
|
37
|
+
list: React.ElementType;
|
|
38
|
+
/**
|
|
39
|
+
* The component used for the scroller.
|
|
40
|
+
* @default ScrollbarSize
|
|
41
|
+
*/
|
|
42
|
+
scrollbar: React.ElementType;
|
|
43
|
+
/**
|
|
44
|
+
* The component used for the tab indicator.
|
|
45
|
+
* @default span
|
|
46
|
+
*/
|
|
47
|
+
indicator: React.ElementType;
|
|
48
|
+
/**
|
|
49
|
+
* The component used for the scroll button.
|
|
50
|
+
* @default TabScrollButton
|
|
51
|
+
*/
|
|
52
|
+
scrollButtons: React.ElementType;
|
|
53
|
+
/**
|
|
54
|
+
* The component used for the start scroll button icon.
|
|
55
|
+
* @default KeyboardArrowLeft
|
|
56
|
+
*/
|
|
57
|
+
startScrollButtonIcon: React.ElementType;
|
|
58
|
+
/**
|
|
59
|
+
* The component used for the end scroll button icon.
|
|
60
|
+
* @default KeyboardArrowRight
|
|
61
|
+
*/
|
|
62
|
+
endScrollButtonIcon: React.ElementType;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type TabsSlotsAndSlotProps = CreateSlotsAndSlotProps<
|
|
66
|
+
TabsSlots,
|
|
67
|
+
{
|
|
68
|
+
/**
|
|
69
|
+
* Props forwarded to the root slot.
|
|
70
|
+
* By default, the avaible props are based on the div element.
|
|
71
|
+
*/
|
|
72
|
+
root: SlotProps<'div', TabsRootSlotPropsOverrides, TabsOwnerState>;
|
|
73
|
+
/**
|
|
74
|
+
* Props forwarded to the scroller slot.
|
|
75
|
+
* By default, the avaible props are based on the div element.
|
|
76
|
+
*/
|
|
77
|
+
scroller: SlotProps<'div', TabsScrollerSlotPropsOverrides, TabsOwnerState>;
|
|
78
|
+
/**
|
|
79
|
+
* Props forwarded to the list slot.
|
|
80
|
+
* By default, the avaible props are based on the div element.
|
|
81
|
+
*/
|
|
82
|
+
list: SlotProps<'div', TabsListSlotPropsOverrides, TabsOwnerState>;
|
|
83
|
+
/**
|
|
84
|
+
* Props forwarded to the scrollbar slot.
|
|
85
|
+
* By default, the avaible props are based on the div element.
|
|
86
|
+
*/
|
|
87
|
+
scrollbar: SlotProps<
|
|
88
|
+
'div',
|
|
89
|
+
{ onChange?: (scrollbarWidth: undefined | number) => void } & TabsScrollbarSlotPropsOverrides,
|
|
90
|
+
TabsOwnerState
|
|
91
|
+
>;
|
|
92
|
+
/**
|
|
93
|
+
* Props forwarded to the indicator slot.
|
|
94
|
+
* By default, the avaible props are based on the span element.
|
|
95
|
+
*/
|
|
96
|
+
indicator: SlotProps<'span', TabsIndicatorSlotPropsOverrides, TabsOwnerState>;
|
|
97
|
+
/**
|
|
98
|
+
* Props forwarded to the scrollButton slot.
|
|
99
|
+
* By default, the avaible props are based on the [TabScrollButton](https://mui.com/material-ui/api/tab-scroll-button/#props) component.
|
|
100
|
+
*/
|
|
101
|
+
scrollButtons: SlotProps<
|
|
102
|
+
typeof TabScrollButton,
|
|
103
|
+
TabsScrollButtonsSlotPropsOverrides,
|
|
104
|
+
TabsOwnerState
|
|
105
|
+
>;
|
|
106
|
+
/**
|
|
107
|
+
* Props forwarded to the startScrollButtonIcon slot.
|
|
108
|
+
* By default, the avaible props are based on the [SvgIcon](https://mui.com/material-ui/api/svg-icon/#props) component.
|
|
109
|
+
*/
|
|
110
|
+
startScrollButtonIcon: SlotProps<
|
|
111
|
+
typeof SvgIcon,
|
|
112
|
+
TabsStartScrollButtonIconSlotPropsOverrides,
|
|
113
|
+
TabsOwnerState
|
|
114
|
+
>;
|
|
115
|
+
/**
|
|
116
|
+
* Props forwarded to the endScrollButtonIcon slot.
|
|
117
|
+
* By default, the avaible props are based on the [SvgIcon](https://mui.com/material-ui/api/svg-icon/#props) component.
|
|
118
|
+
*/
|
|
119
|
+
endScrollButtonIcon: SlotProps<
|
|
120
|
+
typeof SvgIcon,
|
|
121
|
+
TabsEndScrollButtonIconSlotPropsOverrides,
|
|
122
|
+
TabsOwnerState
|
|
123
|
+
>;
|
|
124
|
+
}
|
|
125
|
+
> & {
|
|
126
|
+
slots?: {
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated Use `slots.startScrollButtonIcon` instead.
|
|
129
|
+
*/
|
|
130
|
+
StartScrollButtonIcon?: React.ElementType;
|
|
131
|
+
/**
|
|
132
|
+
* @deprecated Use `slots.endScrollButtonIcon` instead.
|
|
133
|
+
*/
|
|
134
|
+
EndScrollButtonIcon?: React.ElementType;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export interface TabsOwnerState extends Omit<TabsProps, 'slots' | 'slotProps'> {
|
|
17
139
|
vertical: boolean;
|
|
18
140
|
fixed: boolean;
|
|
19
141
|
hideScrollbar: boolean;
|
|
@@ -23,7 +145,7 @@ export interface TabsOwnerState extends TabsProps {
|
|
|
23
145
|
scrollButtonsHideMobile: boolean;
|
|
24
146
|
}
|
|
25
147
|
|
|
26
|
-
export interface TabsOwnProps {
|
|
148
|
+
export interface TabsOwnProps extends TabsSlotsAndSlotProps {
|
|
27
149
|
/**
|
|
28
150
|
* Callback fired when the component mounts.
|
|
29
151
|
* This is useful when you want to trigger an action programmatically.
|
|
@@ -61,31 +183,6 @@ export interface TabsOwnProps {
|
|
|
61
183
|
* Override or extend the styles applied to the component.
|
|
62
184
|
*/
|
|
63
185
|
classes?: Partial<TabsClasses>;
|
|
64
|
-
/**
|
|
65
|
-
* The components used for each slot inside.
|
|
66
|
-
* @default {}
|
|
67
|
-
*/
|
|
68
|
-
slots?: {
|
|
69
|
-
StartScrollButtonIcon?: React.ElementType;
|
|
70
|
-
EndScrollButtonIcon?: React.ElementType;
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* The extra props for the slot components.
|
|
74
|
-
* You can override the existing props or add new ones.
|
|
75
|
-
* @default {}
|
|
76
|
-
*/
|
|
77
|
-
slotProps?: {
|
|
78
|
-
startScrollButtonIcon?: SlotComponentProps<
|
|
79
|
-
typeof SvgIcon,
|
|
80
|
-
TabsStartScrollButtonIconSlotPropsOverrides,
|
|
81
|
-
TabsOwnerState
|
|
82
|
-
>;
|
|
83
|
-
endScrollButtonIcon?: SlotComponentProps<
|
|
84
|
-
typeof SvgIcon,
|
|
85
|
-
TabsEndScrollButtonIconSlotPropsOverrides,
|
|
86
|
-
TabsOwnerState
|
|
87
|
-
>;
|
|
88
|
-
};
|
|
89
186
|
/**
|
|
90
187
|
* Determines the color of the indicator.
|
|
91
188
|
* @default 'primary'
|
|
@@ -108,6 +205,7 @@ export interface TabsOwnProps {
|
|
|
108
205
|
orientation?: 'horizontal' | 'vertical';
|
|
109
206
|
/**
|
|
110
207
|
* The component used to render the scroll buttons.
|
|
208
|
+
* @deprecated use the `slots.scrollButtons` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
111
209
|
* @default TabScrollButton
|
|
112
210
|
*/
|
|
113
211
|
ScrollButtonComponent?: React.ElementType;
|
|
@@ -130,6 +228,7 @@ export interface TabsOwnProps {
|
|
|
130
228
|
selectionFollowsFocus?: boolean;
|
|
131
229
|
/**
|
|
132
230
|
* Props applied to the tab indicator element.
|
|
231
|
+
* @deprecated use the `slotProps.indicator` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
133
232
|
* @default {}
|
|
134
233
|
*/
|
|
135
234
|
TabIndicatorProps?: React.HTMLAttributes<HTMLDivElement> & {
|
|
@@ -137,6 +236,7 @@ export interface TabsOwnProps {
|
|
|
137
236
|
};
|
|
138
237
|
/**
|
|
139
238
|
* Props applied to the [`TabScrollButton`](https://mui.com/material-ui/api/tab-scroll-button/) element.
|
|
239
|
+
* @deprecated use the `slotProps.scrollButtons` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
140
240
|
* @default {}
|
|
141
241
|
*/
|
|
142
242
|
TabScrollButtonProps?: Partial<TabScrollButtonProps>;
|
package/Tabs/Tabs.js
CHANGED
|
@@ -19,6 +19,7 @@ import useEventCallback from "../utils/useEventCallback.js";
|
|
|
19
19
|
import tabsClasses, { getTabsUtilityClass } from "./tabsClasses.js";
|
|
20
20
|
import ownerDocument from "../utils/ownerDocument.js";
|
|
21
21
|
import ownerWindow from "../utils/ownerWindow.js";
|
|
22
|
+
import useSlot from "../utils/useSlot.js";
|
|
22
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
24
|
const nextItem = (list, item) => {
|
|
24
25
|
if (list === item) {
|
|
@@ -75,7 +76,7 @@ const useUtilityClasses = ownerState => {
|
|
|
75
76
|
const slots = {
|
|
76
77
|
root: ['root', vertical && 'vertical'],
|
|
77
78
|
scroller: ['scroller', fixed && 'fixed', hideScrollbar && 'hideScrollbar', scrollableX && 'scrollableX', scrollableY && 'scrollableY'],
|
|
78
|
-
|
|
79
|
+
list: ['list', 'flexContainer', vertical && 'flexContainerVertical', vertical && 'vertical', centered && 'centered'],
|
|
79
80
|
indicator: ['indicator'],
|
|
80
81
|
scrollButtons: ['scrollButtons', scrollButtonsHideMobile && 'scrollButtonsHideMobile'],
|
|
81
82
|
scrollableX: [scrollableX && 'scrollableX'],
|
|
@@ -176,14 +177,14 @@ const TabsScroller = styled('div', {
|
|
|
176
177
|
}
|
|
177
178
|
}]
|
|
178
179
|
});
|
|
179
|
-
const
|
|
180
|
+
const List = styled('div', {
|
|
180
181
|
name: 'MuiTabs',
|
|
181
|
-
slot: '
|
|
182
|
+
slot: 'List',
|
|
182
183
|
overridesResolver: (props, styles) => {
|
|
183
184
|
const {
|
|
184
185
|
ownerState
|
|
185
186
|
} = props;
|
|
186
|
-
return [styles.flexContainer, ownerState.vertical && styles.flexContainerVertical, ownerState.centered && styles.centered];
|
|
187
|
+
return [styles.list, styles.flexContainer, ownerState.vertical && styles.flexContainerVertical, ownerState.centered && styles.centered];
|
|
187
188
|
}
|
|
188
189
|
})({
|
|
189
190
|
display: 'flex',
|
|
@@ -271,13 +272,16 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
271
272
|
indicatorColor = 'primary',
|
|
272
273
|
onChange,
|
|
273
274
|
orientation = 'horizontal',
|
|
274
|
-
ScrollButtonComponent
|
|
275
|
+
ScrollButtonComponent,
|
|
276
|
+
// TODO: remove in v7 (deprecated in v6)
|
|
275
277
|
scrollButtons = 'auto',
|
|
276
278
|
selectionFollowsFocus,
|
|
277
279
|
slots = {},
|
|
278
280
|
slotProps = {},
|
|
279
281
|
TabIndicatorProps = {},
|
|
282
|
+
// TODO: remove in v7 (deprecated in v6)
|
|
280
283
|
TabScrollButtonProps = {},
|
|
284
|
+
// TODO: remove in v7 (deprecated in v6)
|
|
281
285
|
textColor = 'primary',
|
|
282
286
|
value,
|
|
283
287
|
variant = 'standard',
|
|
@@ -337,6 +341,14 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
337
341
|
const valueToIndex = new Map();
|
|
338
342
|
const tabsRef = React.useRef(null);
|
|
339
343
|
const tabListRef = React.useRef(null);
|
|
344
|
+
const externalForwardedProps = {
|
|
345
|
+
slots,
|
|
346
|
+
slotProps: {
|
|
347
|
+
indicator: TabIndicatorProps,
|
|
348
|
+
scrollButton: TabScrollButtonProps,
|
|
349
|
+
...slotProps
|
|
350
|
+
}
|
|
351
|
+
};
|
|
340
352
|
const getTabsMeta = () => {
|
|
341
353
|
const tabsNode = tabsRef.current;
|
|
342
354
|
let tabsMeta;
|
|
@@ -458,50 +470,62 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
458
470
|
const handleEndScrollClick = () => {
|
|
459
471
|
moveTabsScroll(getScrollSize());
|
|
460
472
|
};
|
|
473
|
+
const [ScrollbarSlot, {
|
|
474
|
+
onChange: scrollbarOnChange,
|
|
475
|
+
...scrollbarSlotProps
|
|
476
|
+
}] = useSlot('scrollbar', {
|
|
477
|
+
className: clsx(classes.scrollableX, classes.hideScrollbar),
|
|
478
|
+
elementType: TabsScrollbarSize,
|
|
479
|
+
shouldForwardComponentProp: true,
|
|
480
|
+
externalForwardedProps,
|
|
481
|
+
ownerState
|
|
482
|
+
});
|
|
461
483
|
|
|
462
484
|
// TODO Remove <ScrollbarSize /> as browser support for hiding the scrollbar
|
|
463
485
|
// with CSS improves.
|
|
464
486
|
const handleScrollbarSizeChange = React.useCallback(scrollbarWidth => {
|
|
487
|
+
scrollbarOnChange?.(scrollbarWidth);
|
|
465
488
|
setScrollerStyle({
|
|
466
489
|
overflow: null,
|
|
467
490
|
scrollbarWidth
|
|
468
491
|
});
|
|
469
|
-
}, []);
|
|
492
|
+
}, [scrollbarOnChange]);
|
|
493
|
+
const [ScrollButtonsSlot, scrollButtonSlotProps] = useSlot('scrollButtons', {
|
|
494
|
+
className: clsx(classes.scrollButtons, TabScrollButtonProps.className),
|
|
495
|
+
elementType: TabScrollButton,
|
|
496
|
+
externalForwardedProps,
|
|
497
|
+
ownerState,
|
|
498
|
+
additionalProps: {
|
|
499
|
+
orientation,
|
|
500
|
+
slots: {
|
|
501
|
+
StartScrollButtonIcon: slots.startScrollButtonIcon || slots.StartScrollButtonIcon,
|
|
502
|
+
EndScrollButtonIcon: slots.endScrollButtonIcon || slots.EndScrollButtonIcon
|
|
503
|
+
},
|
|
504
|
+
slotProps: {
|
|
505
|
+
startScrollButtonIcon: startScrollButtonIconProps,
|
|
506
|
+
endScrollButtonIcon: endScrollButtonIconProps
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
});
|
|
470
510
|
const getConditionalElements = () => {
|
|
471
511
|
const conditionalElements = {};
|
|
472
|
-
conditionalElements.scrollbarSizeListener = scrollable ? /*#__PURE__*/_jsx(
|
|
473
|
-
|
|
474
|
-
|
|
512
|
+
conditionalElements.scrollbarSizeListener = scrollable ? /*#__PURE__*/_jsx(ScrollbarSlot, {
|
|
513
|
+
...scrollbarSlotProps,
|
|
514
|
+
onChange: handleScrollbarSizeChange
|
|
475
515
|
}) : null;
|
|
476
516
|
const scrollButtonsActive = displayStartScroll || displayEndScroll;
|
|
477
517
|
const showScrollButtons = scrollable && (scrollButtons === 'auto' && scrollButtonsActive || scrollButtons === true);
|
|
478
|
-
conditionalElements.scrollButtonStart = showScrollButtons ? /*#__PURE__*/_jsx(
|
|
479
|
-
slots: {
|
|
480
|
-
StartScrollButtonIcon: slots.StartScrollButtonIcon
|
|
481
|
-
},
|
|
482
|
-
slotProps: {
|
|
483
|
-
startScrollButtonIcon: startScrollButtonIconProps
|
|
484
|
-
},
|
|
485
|
-
orientation: orientation,
|
|
518
|
+
conditionalElements.scrollButtonStart = showScrollButtons ? /*#__PURE__*/_jsx(ScrollButtonsSlot, {
|
|
486
519
|
direction: isRtl ? 'right' : 'left',
|
|
487
520
|
onClick: handleStartScrollClick,
|
|
488
521
|
disabled: !displayStartScroll,
|
|
489
|
-
...
|
|
490
|
-
className: clsx(classes.scrollButtons, TabScrollButtonProps.className)
|
|
522
|
+
...scrollButtonSlotProps
|
|
491
523
|
}) : null;
|
|
492
|
-
conditionalElements.scrollButtonEnd = showScrollButtons ? /*#__PURE__*/_jsx(
|
|
493
|
-
slots: {
|
|
494
|
-
EndScrollButtonIcon: slots.EndScrollButtonIcon
|
|
495
|
-
},
|
|
496
|
-
slotProps: {
|
|
497
|
-
endScrollButtonIcon: endScrollButtonIconProps
|
|
498
|
-
},
|
|
499
|
-
orientation: orientation,
|
|
524
|
+
conditionalElements.scrollButtonEnd = showScrollButtons ? /*#__PURE__*/_jsx(ScrollButtonsSlot, {
|
|
500
525
|
direction: isRtl ? 'left' : 'right',
|
|
501
526
|
onClick: handleEndScrollClick,
|
|
502
527
|
disabled: !displayEndScroll,
|
|
503
|
-
...
|
|
504
|
-
className: clsx(classes.scrollButtons, TabScrollButtonProps.className)
|
|
528
|
+
...scrollButtonSlotProps
|
|
505
529
|
}) : null;
|
|
506
530
|
return conditionalElements;
|
|
507
531
|
};
|
|
@@ -629,15 +653,18 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
629
653
|
updateIndicator: updateIndicatorState,
|
|
630
654
|
updateScrollButtons: updateScrollButtonState
|
|
631
655
|
}), [updateIndicatorState, updateScrollButtonState]);
|
|
632
|
-
const
|
|
633
|
-
...TabIndicatorProps,
|
|
656
|
+
const [IndicatorSlot, indicatorSlotProps] = useSlot('indicator', {
|
|
634
657
|
className: clsx(classes.indicator, TabIndicatorProps.className),
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
658
|
+
elementType: TabsIndicator,
|
|
659
|
+
externalForwardedProps,
|
|
660
|
+
ownerState,
|
|
661
|
+
additionalProps: {
|
|
662
|
+
style: indicatorStyle
|
|
639
663
|
}
|
|
640
664
|
});
|
|
665
|
+
const indicator = /*#__PURE__*/_jsx(IndicatorSlot, {
|
|
666
|
+
...indicatorSlotProps
|
|
667
|
+
});
|
|
641
668
|
let childIndex = 0;
|
|
642
669
|
const children = React.Children.map(childrenProp, child => {
|
|
643
670
|
if (! /*#__PURE__*/React.isValidElement(child)) {
|
|
@@ -704,29 +731,54 @@ const Tabs = /*#__PURE__*/React.forwardRef(function Tabs(inProps, ref) {
|
|
|
704
731
|
}
|
|
705
732
|
};
|
|
706
733
|
const conditionalElements = getConditionalElements();
|
|
707
|
-
|
|
734
|
+
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
735
|
+
ref,
|
|
708
736
|
className: clsx(classes.root, className),
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
737
|
+
elementType: TabsRoot,
|
|
738
|
+
externalForwardedProps: {
|
|
739
|
+
...externalForwardedProps,
|
|
740
|
+
...other,
|
|
741
|
+
component
|
|
742
|
+
},
|
|
743
|
+
ownerState
|
|
744
|
+
});
|
|
745
|
+
const [ScrollerSlot, scrollerSlotProps] = useSlot('scroller', {
|
|
746
|
+
ref: tabsRef,
|
|
747
|
+
className: classes.scroller,
|
|
748
|
+
elementType: TabsScroller,
|
|
749
|
+
externalForwardedProps,
|
|
750
|
+
ownerState,
|
|
751
|
+
additionalProps: {
|
|
716
752
|
style: {
|
|
717
753
|
overflow: scrollerStyle.overflow,
|
|
718
754
|
[vertical ? `margin${isRtl ? 'Left' : 'Right'}` : 'marginBottom']: visibleScrollbar ? undefined : -scrollerStyle.scrollbarWidth
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
const [ListSlot, listSlotProps] = useSlot('list', {
|
|
759
|
+
ref: tabListRef,
|
|
760
|
+
className: clsx(classes.list, classes.flexContainer),
|
|
761
|
+
elementType: List,
|
|
762
|
+
externalForwardedProps,
|
|
763
|
+
ownerState,
|
|
764
|
+
getSlotProps: handlers => ({
|
|
765
|
+
...handlers,
|
|
766
|
+
onKeyDown: event => {
|
|
767
|
+
handleKeyDown(event);
|
|
768
|
+
handlers.onKeyDown?.(event);
|
|
769
|
+
}
|
|
770
|
+
})
|
|
771
|
+
});
|
|
772
|
+
return /*#__PURE__*/_jsxs(RootSlot, {
|
|
773
|
+
...rootSlotProps,
|
|
774
|
+
children: [conditionalElements.scrollButtonStart, conditionalElements.scrollbarSizeListener, /*#__PURE__*/_jsxs(ScrollerSlot, {
|
|
775
|
+
...scrollerSlotProps,
|
|
776
|
+
children: [/*#__PURE__*/_jsx(ListSlot, {
|
|
722
777
|
"aria-label": ariaLabel,
|
|
723
778
|
"aria-labelledby": ariaLabelledBy,
|
|
724
779
|
"aria-orientation": orientation === 'vertical' ? 'vertical' : null,
|
|
725
|
-
className: classes.flexContainer,
|
|
726
|
-
ownerState: ownerState,
|
|
727
|
-
onKeyDown: handleKeyDown,
|
|
728
|
-
ref: tabListRef,
|
|
729
780
|
role: "tablist",
|
|
781
|
+
...listSlotProps,
|
|
730
782
|
children: children
|
|
731
783
|
}), mounted && indicator]
|
|
732
784
|
}), conditionalElements.scrollButtonEnd]
|
|
@@ -802,6 +854,7 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
802
854
|
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
803
855
|
/**
|
|
804
856
|
* The component used to render the scroll buttons.
|
|
857
|
+
* @deprecated use the `slots.scrollButtons` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
805
858
|
* @default TabScrollButton
|
|
806
859
|
*/
|
|
807
860
|
ScrollButtonComponent: PropTypes.elementType,
|
|
@@ -823,12 +876,17 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
823
876
|
*/
|
|
824
877
|
selectionFollowsFocus: PropTypes.bool,
|
|
825
878
|
/**
|
|
826
|
-
* The
|
|
827
|
-
* You can override the existing props or add new ones.
|
|
879
|
+
* The props used for each slot inside.
|
|
828
880
|
* @default {}
|
|
829
881
|
*/
|
|
830
882
|
slotProps: PropTypes.shape({
|
|
831
883
|
endScrollButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
884
|
+
indicator: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
885
|
+
list: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
886
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
887
|
+
scrollbar: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
888
|
+
scrollButtons: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
889
|
+
scroller: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
832
890
|
startScrollButtonIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
833
891
|
}),
|
|
834
892
|
/**
|
|
@@ -836,7 +894,15 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
836
894
|
* @default {}
|
|
837
895
|
*/
|
|
838
896
|
slots: PropTypes.shape({
|
|
897
|
+
endScrollButtonIcon: PropTypes.elementType,
|
|
839
898
|
EndScrollButtonIcon: PropTypes.elementType,
|
|
899
|
+
indicator: PropTypes.elementType,
|
|
900
|
+
list: PropTypes.elementType,
|
|
901
|
+
root: PropTypes.elementType,
|
|
902
|
+
scrollbar: PropTypes.elementType,
|
|
903
|
+
scrollButtons: PropTypes.elementType,
|
|
904
|
+
scroller: PropTypes.elementType,
|
|
905
|
+
startScrollButtonIcon: PropTypes.elementType,
|
|
840
906
|
StartScrollButtonIcon: PropTypes.elementType
|
|
841
907
|
}),
|
|
842
908
|
/**
|
|
@@ -845,11 +911,13 @@ process.env.NODE_ENV !== "production" ? Tabs.propTypes /* remove-proptypes */ =
|
|
|
845
911
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
846
912
|
/**
|
|
847
913
|
* Props applied to the tab indicator element.
|
|
914
|
+
* @deprecated use the `slotProps.indicator` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
848
915
|
* @default {}
|
|
849
916
|
*/
|
|
850
917
|
TabIndicatorProps: PropTypes.object,
|
|
851
918
|
/**
|
|
852
919
|
* Props applied to the [`TabScrollButton`](https://mui.com/material-ui/api/tab-scroll-button/) element.
|
|
920
|
+
* @deprecated use the `slotProps.scrollButtons` prop instead. This prop will be removed in v7. See [Migrating from deprecated APIs](https://mui.com/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
853
921
|
* @default {}
|
|
854
922
|
*/
|
|
855
923
|
TabScrollButtonProps: PropTypes.object,
|
package/Tabs/tabsClasses.d.ts
CHANGED
|
@@ -4,9 +4,13 @@ export interface TabsClasses {
|
|
|
4
4
|
/** Styles applied to the root element if `orientation="vertical"`. */
|
|
5
5
|
vertical: string;
|
|
6
6
|
/** Styles applied to the flex container element. */
|
|
7
|
+
/** @deprecated use `list` instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. */
|
|
7
8
|
flexContainer: string;
|
|
8
9
|
/** Styles applied to the flex container element if `orientation="vertical"`. */
|
|
10
|
+
/** @deprecated use a combination of `list` and `vertical` instead. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details. */
|
|
9
11
|
flexContainerVertical: string;
|
|
12
|
+
/** Styles applied to the list element. */
|
|
13
|
+
list: string;
|
|
10
14
|
/** Styles applied to the flex container element if `centered={true}` & `!variant="scrollable"`. */
|
|
11
15
|
centered: string;
|
|
12
16
|
/** Styles applied to the tablist element. */
|
package/Tabs/tabsClasses.js
CHANGED
|
@@ -3,5 +3,5 @@ import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
|
3
3
|
export function getTabsUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiTabs', slot);
|
|
5
5
|
}
|
|
6
|
-
const tabsClasses = generateUtilityClasses('MuiTabs', ['root', 'vertical', 'flexContainer', 'flexContainerVertical', 'centered', 'scroller', 'fixed', 'scrollableX', 'scrollableY', 'hideScrollbar', 'scrollButtons', 'scrollButtonsHideMobile', 'indicator']);
|
|
6
|
+
const tabsClasses = generateUtilityClasses('MuiTabs', ['root', 'vertical', 'list', 'flexContainer', 'flexContainerVertical', 'centered', 'scroller', 'fixed', 'scrollableX', 'scrollableY', 'hideScrollbar', 'scrollButtons', 'scrollButtonsHideMobile', 'indicator']);
|
|
7
7
|
export default tabsClasses;
|