@mui/material 6.4.4 → 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/Button/Button.js +3 -3
- package/CHANGELOG.md +63 -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/IconButton/IconButton.js +3 -3
- 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/Button/Button.js +3 -3
- package/modern/Checkbox/Checkbox.js +51 -21
- package/modern/Drawer/Drawer.js +108 -36
- package/modern/IconButton/IconButton.js +3 -3
- 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/useAutocomplete/useAutocomplete.js +0 -1
- package/modern/version/index.js +2 -2
- package/node/Button/Button.js +3 -3
- package/node/Checkbox/Checkbox.js +51 -21
- package/node/Drawer/Drawer.js +108 -36
- package/node/IconButton/IconButton.js +3 -3
- 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/useAutocomplete/useAutocomplete.js +0 -1
- package/node/version/index.js +2 -2
- package/package.json +5 -5
- package/styles/createThemeNoVars.js +7 -2
- package/useAutocomplete/useAutocomplete.js +0 -1
- package/version/index.js +2 -2
|
@@ -13,6 +13,8 @@ import Fab from "../Fab/index.js";
|
|
|
13
13
|
import Tooltip from "../Tooltip/index.js";
|
|
14
14
|
import capitalize from "../utils/capitalize.js";
|
|
15
15
|
import speedDialActionClasses, { getSpeedDialActionUtilityClass } from "./speedDialActionClasses.js";
|
|
16
|
+
import useSlot from "../utils/useSlot.js";
|
|
17
|
+
import { mergeSlotProps } from "../utils/index.js";
|
|
16
18
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
19
|
const useUtilityClasses = ownerState => {
|
|
18
20
|
const {
|
|
@@ -147,6 +149,8 @@ const SpeedDialAction = /*#__PURE__*/React.forwardRef(function SpeedDialAction(i
|
|
|
147
149
|
tooltipOpen: tooltipOpenProp = false,
|
|
148
150
|
tooltipPlacement = 'left',
|
|
149
151
|
tooltipTitle,
|
|
152
|
+
slots = {},
|
|
153
|
+
slotProps = {},
|
|
150
154
|
...other
|
|
151
155
|
} = props;
|
|
152
156
|
const ownerState = {
|
|
@@ -154,7 +158,20 @@ const SpeedDialAction = /*#__PURE__*/React.forwardRef(function SpeedDialAction(i
|
|
|
154
158
|
tooltipPlacement
|
|
155
159
|
};
|
|
156
160
|
const classes = useUtilityClasses(ownerState);
|
|
157
|
-
const
|
|
161
|
+
const externalForwardedProps = {
|
|
162
|
+
slots,
|
|
163
|
+
slotProps: {
|
|
164
|
+
fab: FabProps,
|
|
165
|
+
...slotProps,
|
|
166
|
+
tooltip: mergeSlotProps(typeof slotProps.tooltip === 'function' ? slotProps.tooltip(ownerState) : slotProps.tooltip, {
|
|
167
|
+
title: tooltipTitle,
|
|
168
|
+
open: tooltipOpenProp,
|
|
169
|
+
placement: tooltipPlacement,
|
|
170
|
+
classes: TooltipClasses
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
const [tooltipOpen, setTooltipOpen] = React.useState(externalForwardedProps.slotProps.tooltip?.open);
|
|
158
175
|
const handleTooltipClose = () => {
|
|
159
176
|
setTooltipOpen(false);
|
|
160
177
|
};
|
|
@@ -164,32 +181,71 @@ const SpeedDialAction = /*#__PURE__*/React.forwardRef(function SpeedDialAction(i
|
|
|
164
181
|
const transitionStyle = {
|
|
165
182
|
transitionDelay: `${delay}ms`
|
|
166
183
|
};
|
|
167
|
-
const
|
|
168
|
-
|
|
184
|
+
const [FabSlot, fabSlotProps] = useSlot('fab', {
|
|
185
|
+
elementType: SpeedDialActionFab,
|
|
186
|
+
externalForwardedProps,
|
|
187
|
+
ownerState,
|
|
188
|
+
shouldForwardComponentProp: true,
|
|
169
189
|
className: clsx(classes.fab, className),
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
190
|
+
additionalProps: {
|
|
191
|
+
style: transitionStyle,
|
|
192
|
+
tabIndex: -1,
|
|
193
|
+
role: 'menuitem',
|
|
194
|
+
size: 'small'
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
const [TooltipSlot, tooltipSlotProps] = useSlot('tooltip', {
|
|
198
|
+
elementType: Tooltip,
|
|
199
|
+
externalForwardedProps,
|
|
200
|
+
shouldForwardComponentProp: true,
|
|
201
|
+
ref,
|
|
202
|
+
additionalProps: {
|
|
203
|
+
id
|
|
177
204
|
},
|
|
205
|
+
ownerState,
|
|
206
|
+
getSlotProps: handlers => ({
|
|
207
|
+
...handlers,
|
|
208
|
+
onClose: event => {
|
|
209
|
+
handlers.onClose?.(event);
|
|
210
|
+
handleTooltipClose();
|
|
211
|
+
},
|
|
212
|
+
onOpen: event => {
|
|
213
|
+
handlers.onOpen?.(event);
|
|
214
|
+
handleTooltipOpen();
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
});
|
|
218
|
+
const [StaticTooltipSlot, staticTooltipSlotProps] = useSlot('staticTooltip', {
|
|
219
|
+
elementType: SpeedDialActionStaticTooltip,
|
|
220
|
+
externalForwardedProps,
|
|
221
|
+
ownerState,
|
|
222
|
+
ref,
|
|
223
|
+
className: classes.staticTooltip,
|
|
224
|
+
additionalProps: {
|
|
225
|
+
id
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
const [StaticTooltipLabelSlot, staticTooltipLabelSlotProps] = useSlot('staticTooltipLabel', {
|
|
229
|
+
elementType: SpeedDialActionStaticTooltipLabel,
|
|
230
|
+
externalForwardedProps,
|
|
231
|
+
ownerState,
|
|
232
|
+
className: classes.staticTooltipLabel,
|
|
233
|
+
additionalProps: {
|
|
234
|
+
style: transitionStyle,
|
|
235
|
+
id: `${id}-label`
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
const fab = /*#__PURE__*/_jsx(FabSlot, {
|
|
239
|
+
...fabSlotProps,
|
|
178
240
|
children: icon
|
|
179
241
|
});
|
|
180
|
-
if (
|
|
181
|
-
return /*#__PURE__*/_jsxs(
|
|
182
|
-
|
|
183
|
-
ref: ref,
|
|
184
|
-
className: classes.staticTooltip,
|
|
185
|
-
ownerState: ownerState,
|
|
242
|
+
if (tooltipSlotProps.open) {
|
|
243
|
+
return /*#__PURE__*/_jsxs(StaticTooltipSlot, {
|
|
244
|
+
...staticTooltipSlotProps,
|
|
186
245
|
...other,
|
|
187
|
-
children: [/*#__PURE__*/_jsx(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
className: classes.staticTooltipLabel,
|
|
191
|
-
ownerState: ownerState,
|
|
192
|
-
children: tooltipTitle
|
|
246
|
+
children: [/*#__PURE__*/_jsx(StaticTooltipLabelSlot, {
|
|
247
|
+
...staticTooltipLabelSlotProps,
|
|
248
|
+
children: tooltipSlotProps.title
|
|
193
249
|
}), /*#__PURE__*/React.cloneElement(fab, {
|
|
194
250
|
'aria-labelledby': `${id}-label`
|
|
195
251
|
})]
|
|
@@ -198,15 +254,12 @@ const SpeedDialAction = /*#__PURE__*/React.forwardRef(function SpeedDialAction(i
|
|
|
198
254
|
if (!open && tooltipOpen) {
|
|
199
255
|
setTooltipOpen(false);
|
|
200
256
|
}
|
|
201
|
-
return /*#__PURE__*/_jsx(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
title: tooltipTitle,
|
|
205
|
-
placement: tooltipPlacement,
|
|
206
|
-
onClose: handleTooltipClose,
|
|
207
|
-
onOpen: handleTooltipOpen,
|
|
257
|
+
return /*#__PURE__*/_jsx(TooltipSlot, {
|
|
258
|
+
...tooltipSlotProps,
|
|
259
|
+
title: tooltipSlotProps.title,
|
|
208
260
|
open: open && tooltipOpen,
|
|
209
|
-
|
|
261
|
+
placement: tooltipSlotProps.placement,
|
|
262
|
+
classes: tooltipSlotProps.classes,
|
|
210
263
|
...other,
|
|
211
264
|
children: fab
|
|
212
265
|
});
|
|
@@ -232,6 +285,7 @@ process.env.NODE_ENV !== "production" ? SpeedDialAction.propTypes /* remove-prop
|
|
|
232
285
|
/**
|
|
233
286
|
* Props applied to the [`Fab`](https://mui.com/material-ui/api/fab/) component.
|
|
234
287
|
* @default {}
|
|
288
|
+
* @deprecated Use `slotProps.fab` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
235
289
|
*/
|
|
236
290
|
FabProps: PropTypes.object,
|
|
237
291
|
/**
|
|
@@ -247,26 +301,50 @@ process.env.NODE_ENV !== "production" ? SpeedDialAction.propTypes /* remove-prop
|
|
|
247
301
|
* If `true`, the component is shown.
|
|
248
302
|
*/
|
|
249
303
|
open: PropTypes.bool,
|
|
304
|
+
/**
|
|
305
|
+
* The props used for each slot inside.
|
|
306
|
+
* @default {}
|
|
307
|
+
*/
|
|
308
|
+
slotProps: PropTypes.shape({
|
|
309
|
+
fab: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
310
|
+
staticTooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
311
|
+
staticTooltipLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
312
|
+
tooltip: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
313
|
+
}),
|
|
314
|
+
/**
|
|
315
|
+
* The components used for each slot inside.
|
|
316
|
+
* @default {}
|
|
317
|
+
*/
|
|
318
|
+
slots: PropTypes.shape({
|
|
319
|
+
fab: PropTypes.elementType,
|
|
320
|
+
staticTooltip: PropTypes.elementType,
|
|
321
|
+
staticTooltipLabel: PropTypes.elementType,
|
|
322
|
+
tooltip: PropTypes.elementType
|
|
323
|
+
}),
|
|
250
324
|
/**
|
|
251
325
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
252
326
|
*/
|
|
253
327
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
254
328
|
/**
|
|
255
329
|
* `classes` prop applied to the [`Tooltip`](https://mui.com/material-ui/api/tooltip/) element.
|
|
330
|
+
* @deprecated Use `slotProps.tooltip.classes` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
256
331
|
*/
|
|
257
332
|
TooltipClasses: PropTypes.object,
|
|
258
333
|
/**
|
|
259
334
|
* Make the tooltip always visible when the SpeedDial is open.
|
|
260
335
|
* @default false
|
|
336
|
+
* @deprecated Use `slotProps.tooltip.open` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
261
337
|
*/
|
|
262
338
|
tooltipOpen: PropTypes.bool,
|
|
263
339
|
/**
|
|
264
340
|
* Placement of the tooltip.
|
|
265
341
|
* @default 'left'
|
|
342
|
+
* @deprecated Use `slotProps.tooltip.placement` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
266
343
|
*/
|
|
267
344
|
tooltipPlacement: PropTypes.oneOf(['bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
268
345
|
/**
|
|
269
346
|
* Label to display in the tooltip.
|
|
347
|
+
* @deprecated Use `slotProps.tooltip.title` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
270
348
|
*/
|
|
271
349
|
tooltipTitle: PropTypes.node
|
|
272
350
|
} : void 0;
|
|
@@ -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/modern/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/modern/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,
|
|
@@ -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;
|
package/modern/index.js
CHANGED