@mui/material 6.4.5 → 6.4.7
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 +58 -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 +61 -16
- package/Rating/Rating.d.ts +59 -1
- package/Rating/Rating.js +131 -45
- 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 +61 -16
- package/modern/Rating/Rating.js +131 -45
- 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 +61 -16
- package/node/Rating/Rating.js +132 -46
- 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 +5 -5
- package/styles/ThemeProvider.d.ts +6 -0
- package/styles/ThemeProviderWithVars.d.ts +1 -0
- package/styles/createThemeNoVars.js +7 -2
- package/styles/index.d.ts +1 -0
- package/version/index.js +2 -2
package/Popover/Popover.js
CHANGED
|
@@ -15,12 +15,12 @@ import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
|
15
15
|
import debounce from "../utils/debounce.js";
|
|
16
16
|
import ownerDocument from "../utils/ownerDocument.js";
|
|
17
17
|
import ownerWindow from "../utils/ownerWindow.js";
|
|
18
|
-
import useForkRef from "../utils/useForkRef.js";
|
|
19
18
|
import Grow from "../Grow/index.js";
|
|
20
19
|
import Modal from "../Modal/index.js";
|
|
21
20
|
import PaperBase from "../Paper/index.js";
|
|
22
21
|
import { getPopoverUtilityClass } from "./popoverClasses.js";
|
|
23
22
|
import useSlot from "../utils/useSlot.js";
|
|
23
|
+
import { mergeSlotProps } from "../utils/index.js";
|
|
24
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
25
|
export function getOffsetTop(rect, vertical) {
|
|
26
26
|
let offset = 0;
|
|
@@ -103,22 +103,21 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
|
|
|
103
103
|
marginThreshold = 16,
|
|
104
104
|
open,
|
|
105
105
|
PaperProps: PaperPropsProp = {},
|
|
106
|
+
// TODO: remove in v7
|
|
106
107
|
slots = {},
|
|
107
108
|
slotProps = {},
|
|
108
109
|
transformOrigin = {
|
|
109
110
|
vertical: 'top',
|
|
110
111
|
horizontal: 'left'
|
|
111
112
|
},
|
|
112
|
-
TransitionComponent
|
|
113
|
+
TransitionComponent,
|
|
114
|
+
// TODO: remove in v7
|
|
113
115
|
transitionDuration: transitionDurationProp = 'auto',
|
|
114
|
-
TransitionProps
|
|
115
|
-
|
|
116
|
-
...TransitionProps
|
|
117
|
-
} = {},
|
|
116
|
+
TransitionProps = {},
|
|
117
|
+
// TODO: remove in v7
|
|
118
118
|
disableScrollLock = false,
|
|
119
119
|
...other
|
|
120
120
|
} = props;
|
|
121
|
-
const externalPaperSlotProps = slotProps?.paper ?? PaperPropsProp;
|
|
122
121
|
const paperRef = React.useRef();
|
|
123
122
|
const ownerState = {
|
|
124
123
|
...props,
|
|
@@ -126,7 +125,6 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
|
|
|
126
125
|
anchorReference,
|
|
127
126
|
elevation,
|
|
128
127
|
marginThreshold,
|
|
129
|
-
externalPaperSlotProps,
|
|
130
128
|
transformOrigin,
|
|
131
129
|
TransitionComponent,
|
|
132
130
|
transitionDuration: transitionDurationProp,
|
|
@@ -255,10 +253,7 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
|
|
|
255
253
|
}
|
|
256
254
|
return () => window.removeEventListener('scroll', setPositioningStyles);
|
|
257
255
|
}, [anchorEl, disableScrollLock, setPositioningStyles]);
|
|
258
|
-
const handleEntering = (
|
|
259
|
-
if (onEntering) {
|
|
260
|
-
onEntering(element, isAppearing);
|
|
261
|
-
}
|
|
256
|
+
const handleEntering = () => {
|
|
262
257
|
setPositioningStyles();
|
|
263
258
|
};
|
|
264
259
|
const handleExited = () => {
|
|
@@ -289,45 +284,65 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
|
|
|
289
284
|
};
|
|
290
285
|
}, [anchorEl, open, setPositioningStyles]);
|
|
291
286
|
let transitionDuration = transitionDurationProp;
|
|
292
|
-
if (transitionDurationProp === 'auto' && !TransitionComponent.muiSupportAuto) {
|
|
293
|
-
transitionDuration = undefined;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// If the container prop is provided, use that
|
|
297
|
-
// If the anchorEl prop is provided, use its parent body element as the container
|
|
298
|
-
// If neither are provided let the Modal take care of choosing the container
|
|
299
|
-
const container = containerProp || (anchorEl ? ownerDocument(resolveAnchorEl(anchorEl)).body : undefined);
|
|
300
287
|
const externalForwardedProps = {
|
|
301
|
-
slots
|
|
288
|
+
slots: {
|
|
289
|
+
transition: TransitionComponent,
|
|
290
|
+
...slots
|
|
291
|
+
},
|
|
302
292
|
slotProps: {
|
|
303
|
-
|
|
304
|
-
paper:
|
|
293
|
+
transition: TransitionProps,
|
|
294
|
+
paper: PaperPropsProp,
|
|
295
|
+
...slotProps
|
|
305
296
|
}
|
|
306
297
|
};
|
|
307
|
-
const [
|
|
308
|
-
elementType:
|
|
298
|
+
const [TransitionSlot, transitionSlotProps] = useSlot('transition', {
|
|
299
|
+
elementType: Grow,
|
|
309
300
|
externalForwardedProps,
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
301
|
+
ownerState,
|
|
302
|
+
getSlotProps: handlers => ({
|
|
303
|
+
...handlers,
|
|
304
|
+
onEntering: (element, isAppearing) => {
|
|
305
|
+
handlers.onEntering?.(element, isAppearing);
|
|
306
|
+
handleEntering();
|
|
307
|
+
},
|
|
308
|
+
onExited: element => {
|
|
309
|
+
handlers.onExited?.(element);
|
|
310
|
+
handleExited();
|
|
316
311
|
}
|
|
317
|
-
},
|
|
318
|
-
|
|
312
|
+
}),
|
|
313
|
+
additionalProps: {
|
|
314
|
+
appear: true,
|
|
315
|
+
in: open
|
|
316
|
+
}
|
|
319
317
|
});
|
|
318
|
+
if (transitionDurationProp === 'auto' && !TransitionSlot.muiSupportAuto) {
|
|
319
|
+
transitionDuration = undefined;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// If the container prop is provided, use that
|
|
323
|
+
// If the anchorEl prop is provided, use its parent body element as the container
|
|
324
|
+
// If neither are provided let the Modal take care of choosing the container
|
|
325
|
+
const container = containerProp || (anchorEl ? ownerDocument(resolveAnchorEl(anchorEl)).body : undefined);
|
|
320
326
|
const [RootSlot, {
|
|
327
|
+
slots: rootSlotsProp,
|
|
321
328
|
slotProps: rootSlotPropsProp,
|
|
322
329
|
...rootProps
|
|
323
330
|
}] = useSlot('root', {
|
|
331
|
+
ref,
|
|
324
332
|
elementType: PopoverRoot,
|
|
325
|
-
externalForwardedProps
|
|
333
|
+
externalForwardedProps: {
|
|
334
|
+
...externalForwardedProps,
|
|
335
|
+
...other
|
|
336
|
+
},
|
|
337
|
+
shouldForwardComponentProp: true,
|
|
326
338
|
additionalProps: {
|
|
339
|
+
slots: {
|
|
340
|
+
backdrop: slots.backdrop
|
|
341
|
+
},
|
|
327
342
|
slotProps: {
|
|
328
|
-
backdrop: {
|
|
343
|
+
backdrop: mergeSlotProps(typeof slotProps.backdrop === 'function' ? slotProps.backdrop(ownerState) : slotProps.backdrop, {
|
|
329
344
|
invisible: true
|
|
330
|
-
}
|
|
345
|
+
})
|
|
331
346
|
},
|
|
332
347
|
container,
|
|
333
348
|
open
|
|
@@ -335,25 +350,32 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
|
|
|
335
350
|
ownerState,
|
|
336
351
|
className: clsx(classes.root, className)
|
|
337
352
|
});
|
|
338
|
-
const
|
|
353
|
+
const [PaperSlot, paperProps] = useSlot('paper', {
|
|
354
|
+
ref: paperRef,
|
|
355
|
+
className: classes.paper,
|
|
356
|
+
elementType: PopoverPaper,
|
|
357
|
+
externalForwardedProps,
|
|
358
|
+
shouldForwardComponentProp: true,
|
|
359
|
+
additionalProps: {
|
|
360
|
+
elevation,
|
|
361
|
+
style: isPositioned ? undefined : {
|
|
362
|
+
opacity: 0
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
ownerState
|
|
366
|
+
});
|
|
339
367
|
return /*#__PURE__*/_jsx(RootSlot, {
|
|
340
368
|
...rootProps,
|
|
341
369
|
...(!isHostComponent(RootSlot) && {
|
|
370
|
+
slots: rootSlotsProp,
|
|
342
371
|
slotProps: rootSlotPropsProp,
|
|
343
372
|
disableScrollLock
|
|
344
373
|
}),
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
children: /*#__PURE__*/_jsx(TransitionComponent, {
|
|
348
|
-
appear: true,
|
|
349
|
-
in: open,
|
|
350
|
-
onEntering: handleEntering,
|
|
351
|
-
onExited: handleExited,
|
|
374
|
+
children: /*#__PURE__*/_jsx(TransitionSlot, {
|
|
375
|
+
...transitionSlotProps,
|
|
352
376
|
timeout: transitionDuration,
|
|
353
|
-
...TransitionProps,
|
|
354
377
|
children: /*#__PURE__*/_jsx(PaperSlot, {
|
|
355
378
|
...paperProps,
|
|
356
|
-
ref: handlePaperRef,
|
|
357
379
|
children: children
|
|
358
380
|
})
|
|
359
381
|
})
|
|
@@ -421,8 +443,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
|
|
|
421
443
|
anchorReference: PropTypes.oneOf(['anchorEl', 'anchorPosition', 'none']),
|
|
422
444
|
/**
|
|
423
445
|
* A backdrop component. This prop enables custom backdrop rendering.
|
|
424
|
-
* @deprecated Use `
|
|
425
|
-
* Use the `slotProps.root.slots.backdrop` prop to make your application ready for the next version of Material UI.
|
|
446
|
+
* @deprecated Use `slots.backdrop` 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.
|
|
426
447
|
* @default styled(Backdrop, {
|
|
427
448
|
* name: 'MuiModal',
|
|
428
449
|
* slot: 'Backdrop',
|
|
@@ -436,7 +457,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
|
|
|
436
457
|
BackdropComponent: PropTypes.elementType,
|
|
437
458
|
/**
|
|
438
459
|
* Props applied to the [`Backdrop`](/material-ui/api/backdrop/) element.
|
|
439
|
-
* @deprecated Use `slotProps.
|
|
460
|
+
* @deprecated Use `slotProps.backdrop` 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.
|
|
440
461
|
*/
|
|
441
462
|
BackdropProps: PropTypes.object,
|
|
442
463
|
/**
|
|
@@ -500,16 +521,20 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
|
|
|
500
521
|
* @default {}
|
|
501
522
|
*/
|
|
502
523
|
slotProps: PropTypes.shape({
|
|
524
|
+
backdrop: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
503
525
|
paper: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
504
|
-
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
526
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
527
|
+
transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
505
528
|
}),
|
|
506
529
|
/**
|
|
507
530
|
* The components used for each slot inside.
|
|
508
531
|
* @default {}
|
|
509
532
|
*/
|
|
510
533
|
slots: PropTypes.shape({
|
|
534
|
+
backdrop: PropTypes.elementType,
|
|
511
535
|
paper: PropTypes.elementType,
|
|
512
|
-
root: PropTypes.elementType
|
|
536
|
+
root: PropTypes.elementType,
|
|
537
|
+
transition: PropTypes.elementType
|
|
513
538
|
}),
|
|
514
539
|
/**
|
|
515
540
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
@@ -534,6 +559,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
|
|
|
534
559
|
/**
|
|
535
560
|
* The component used for the transition.
|
|
536
561
|
* [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
|
|
562
|
+
* @deprecated use the `slots.transition` 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.
|
|
537
563
|
* @default Grow
|
|
538
564
|
*/
|
|
539
565
|
TransitionComponent: PropTypes.elementType,
|
|
@@ -549,6 +575,7 @@ process.env.NODE_ENV !== "production" ? Popover.propTypes /* remove-proptypes */
|
|
|
549
575
|
/**
|
|
550
576
|
* Props applied to the transition element.
|
|
551
577
|
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
|
|
578
|
+
* @deprecated use the `slotProps.transition` 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.
|
|
552
579
|
* @default {}
|
|
553
580
|
*/
|
|
554
581
|
TransitionProps: PropTypes.object
|
package/Radio/Radio.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { SxProps } from '@mui/system';
|
|
3
3
|
import { OverridableStringUnion } from '@mui/types';
|
|
4
4
|
import { InternalStandardProps as StandardProps, Theme } from '..';
|
|
5
|
+
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
|
|
5
6
|
import { SwitchBaseProps } from '../internal/SwitchBase';
|
|
6
7
|
import { RadioClasses } from './radioClasses';
|
|
7
8
|
|
|
@@ -9,8 +10,49 @@ export interface RadioPropsSizeOverrides {}
|
|
|
9
10
|
|
|
10
11
|
export interface RadioPropsColorOverrides {}
|
|
11
12
|
|
|
13
|
+
export interface RadioRootSlotPropsOverrides {}
|
|
14
|
+
|
|
15
|
+
export interface RadioInputSlotPropsOverrides {}
|
|
16
|
+
|
|
17
|
+
export interface RadioSlots {
|
|
18
|
+
/**
|
|
19
|
+
* The component that renders the root slot.
|
|
20
|
+
* @default SwitchBase
|
|
21
|
+
*/
|
|
22
|
+
root: React.ElementType;
|
|
23
|
+
/**
|
|
24
|
+
* The component that renders the input slot.
|
|
25
|
+
* @default SwitchBase's input
|
|
26
|
+
*/
|
|
27
|
+
input: React.ElementType;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type RadioSlotsAndSlotProps = CreateSlotsAndSlotProps<
|
|
31
|
+
RadioSlots,
|
|
32
|
+
{
|
|
33
|
+
/**
|
|
34
|
+
* Props forwarded to the root slot.
|
|
35
|
+
* By default, the avaible props are based on the span element.
|
|
36
|
+
*/
|
|
37
|
+
root: SlotProps<
|
|
38
|
+
React.ElementType<SwitchBaseProps>,
|
|
39
|
+
RadioRootSlotPropsOverrides,
|
|
40
|
+
RadioOwnerState
|
|
41
|
+
>;
|
|
42
|
+
/**
|
|
43
|
+
* Props forwarded to the input slot.
|
|
44
|
+
* By default, the avaible props are based on the input element.
|
|
45
|
+
*/
|
|
46
|
+
input: SlotProps<'input', RadioInputSlotPropsOverrides, RadioOwnerState>;
|
|
47
|
+
}
|
|
48
|
+
>;
|
|
49
|
+
|
|
12
50
|
export interface RadioProps
|
|
13
|
-
extends StandardProps<
|
|
51
|
+
extends StandardProps<
|
|
52
|
+
SwitchBaseProps,
|
|
53
|
+
'checkedIcon' | 'color' | 'icon' | 'type' | 'slots' | 'slotProps'
|
|
54
|
+
>,
|
|
55
|
+
RadioSlotsAndSlotProps {
|
|
14
56
|
/**
|
|
15
57
|
* The icon to display when the component is checked.
|
|
16
58
|
* @default <RadioButtonIcon checked />
|
|
@@ -51,6 +93,8 @@ export interface RadioProps
|
|
|
51
93
|
sx?: SxProps<Theme>;
|
|
52
94
|
}
|
|
53
95
|
|
|
96
|
+
export interface RadioOwnerState extends Omit<RadioProps, 'slots' | 'slotProps'> {}
|
|
97
|
+
|
|
54
98
|
/**
|
|
55
99
|
*
|
|
56
100
|
* Demos:
|
package/Radio/Radio.js
CHANGED
|
@@ -17,6 +17,7 @@ import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
|
|
|
17
17
|
import { styled } from "../zero-styled/index.js";
|
|
18
18
|
import memoTheme from "../utils/memoTheme.js";
|
|
19
19
|
import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.js";
|
|
20
|
+
import useSlot from "../utils/useSlot.js";
|
|
20
21
|
import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
|
21
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
23
|
const useUtilityClasses = ownerState => {
|
|
@@ -125,6 +126,9 @@ const Radio = /*#__PURE__*/React.forwardRef(function Radio(inProps, ref) {
|
|
|
125
126
|
className,
|
|
126
127
|
disabled: disabledProp,
|
|
127
128
|
disableRipple = false,
|
|
129
|
+
slots = {},
|
|
130
|
+
slotProps = {},
|
|
131
|
+
inputProps,
|
|
128
132
|
...other
|
|
129
133
|
} = props;
|
|
130
134
|
const muiFormControl = useFormControl();
|
|
@@ -155,23 +159,46 @@ const Radio = /*#__PURE__*/React.forwardRef(function Radio(inProps, ref) {
|
|
|
155
159
|
name = radioGroup.name;
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}),
|
|
163
|
-
checkedIcon: /*#__PURE__*/React.cloneElement(checkedIcon, {
|
|
164
|
-
fontSize: defaultCheckedIcon.props.fontSize ?? size
|
|
165
|
-
}),
|
|
166
|
-
disabled: disabled,
|
|
167
|
-
ownerState: ownerState,
|
|
168
|
-
classes: classes,
|
|
169
|
-
name: name,
|
|
170
|
-
checked: checked,
|
|
171
|
-
onChange: onChange,
|
|
172
|
-
ref: ref,
|
|
162
|
+
const externalInputProps = slotProps.input ?? inputProps;
|
|
163
|
+
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
164
|
+
ref,
|
|
165
|
+
elementType: RadioRoot,
|
|
173
166
|
className: clsx(classes.root, className),
|
|
174
|
-
|
|
167
|
+
shouldForwardComponentProp: true,
|
|
168
|
+
externalForwardedProps: {
|
|
169
|
+
slots,
|
|
170
|
+
slotProps,
|
|
171
|
+
...other
|
|
172
|
+
},
|
|
173
|
+
getSlotProps: handlers => ({
|
|
174
|
+
...handlers,
|
|
175
|
+
onChange: (event, ...args) => {
|
|
176
|
+
handlers.onChange?.(event, ...args);
|
|
177
|
+
onChange(event, ...args);
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
ownerState,
|
|
181
|
+
additionalProps: {
|
|
182
|
+
type: 'radio',
|
|
183
|
+
icon: /*#__PURE__*/React.cloneElement(icon, {
|
|
184
|
+
fontSize: icon.props.fontSize ?? size
|
|
185
|
+
}),
|
|
186
|
+
checkedIcon: /*#__PURE__*/React.cloneElement(checkedIcon, {
|
|
187
|
+
fontSize: checkedIcon.props.fontSize ?? size
|
|
188
|
+
}),
|
|
189
|
+
disabled,
|
|
190
|
+
name,
|
|
191
|
+
checked,
|
|
192
|
+
slots,
|
|
193
|
+
slotProps: {
|
|
194
|
+
// Do not forward `slotProps.root` again because it's already handled by the `RootSlot` in this file.
|
|
195
|
+
input: typeof externalInputProps === 'function' ? externalInputProps(ownerState) : externalInputProps
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return /*#__PURE__*/_jsx(RootSlot, {
|
|
200
|
+
...rootSlotProps,
|
|
201
|
+
classes: classes
|
|
175
202
|
});
|
|
176
203
|
});
|
|
177
204
|
process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ = {
|
|
@@ -223,10 +250,12 @@ process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ =
|
|
|
223
250
|
id: PropTypes.string,
|
|
224
251
|
/**
|
|
225
252
|
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
253
|
+
* @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.
|
|
226
254
|
*/
|
|
227
255
|
inputProps: PropTypes.object,
|
|
228
256
|
/**
|
|
229
257
|
* Pass a ref to the `input` element.
|
|
258
|
+
* @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.
|
|
230
259
|
*/
|
|
231
260
|
inputRef: refType,
|
|
232
261
|
/**
|
|
@@ -252,6 +281,22 @@ process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ =
|
|
|
252
281
|
* @default 'medium'
|
|
253
282
|
*/
|
|
254
283
|
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
284
|
+
/**
|
|
285
|
+
* The props used for each slot inside.
|
|
286
|
+
* @default {}
|
|
287
|
+
*/
|
|
288
|
+
slotProps: PropTypes.shape({
|
|
289
|
+
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
290
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
291
|
+
}),
|
|
292
|
+
/**
|
|
293
|
+
* The components used for each slot inside.
|
|
294
|
+
* @default {}
|
|
295
|
+
*/
|
|
296
|
+
slots: PropTypes.shape({
|
|
297
|
+
input: PropTypes.elementType,
|
|
298
|
+
root: PropTypes.elementType
|
|
299
|
+
}),
|
|
255
300
|
/**
|
|
256
301
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
257
302
|
*/
|
package/Rating/Rating.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { OverridableStringUnion } from '@mui/types';
|
|
|
4
4
|
import { Theme } from '..';
|
|
5
5
|
import { RatingClasses } from './ratingClasses';
|
|
6
6
|
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
|
|
7
|
+
import { CreateSlotsAndSlotProps, SlotProps } from '../utils/types';
|
|
7
8
|
|
|
8
9
|
export interface IconContainerProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
9
10
|
value: number;
|
|
@@ -11,7 +12,61 @@ export interface IconContainerProps extends React.HTMLAttributes<HTMLSpanElement
|
|
|
11
12
|
|
|
12
13
|
export interface RatingPropsSizeOverrides {}
|
|
13
14
|
|
|
14
|
-
export interface
|
|
15
|
+
export interface RatingRootSlotPropsOverrides {}
|
|
16
|
+
export interface RatingLabelSlotPropsOverrides {}
|
|
17
|
+
export interface RatingIconSlotPropsOverrides {}
|
|
18
|
+
export interface RatingDecimalSlotPropsOverrides {}
|
|
19
|
+
|
|
20
|
+
export interface RatingSlots {
|
|
21
|
+
/**
|
|
22
|
+
* The component used for the root slot.
|
|
23
|
+
* @default 'span'
|
|
24
|
+
*/
|
|
25
|
+
root: React.ElementType;
|
|
26
|
+
/**
|
|
27
|
+
* The component used for the label slot.
|
|
28
|
+
* @default 'label'
|
|
29
|
+
*/
|
|
30
|
+
label: React.ElementType;
|
|
31
|
+
/**
|
|
32
|
+
* The component used for the icon slot.
|
|
33
|
+
* @default 'span'
|
|
34
|
+
*/
|
|
35
|
+
icon: React.ElementType;
|
|
36
|
+
/**
|
|
37
|
+
* The component used fo r the decimal slot.
|
|
38
|
+
* @default 'span'
|
|
39
|
+
*/
|
|
40
|
+
decimal: React.ElementType;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type RatingSlotsAndSlotProps = CreateSlotsAndSlotProps<
|
|
44
|
+
RatingSlots,
|
|
45
|
+
{
|
|
46
|
+
/**
|
|
47
|
+
* Props forwarded to the root slot.
|
|
48
|
+
* By default, the avaible props are based on the span element.
|
|
49
|
+
*/
|
|
50
|
+
root: SlotProps<'span', RatingRootSlotPropsOverrides, RatingOwnerState>;
|
|
51
|
+
/**
|
|
52
|
+
* Props forwarded to the label slot.
|
|
53
|
+
* By default, the avaible props are based on the label element.
|
|
54
|
+
*/
|
|
55
|
+
label: SlotProps<'label', RatingLabelSlotPropsOverrides, RatingOwnerState>;
|
|
56
|
+
/**
|
|
57
|
+
* Props forwarded to the icon slot.
|
|
58
|
+
* By default, the avaible props are based on the span element.
|
|
59
|
+
*/
|
|
60
|
+
icon: SlotProps<'span', RatingIconSlotPropsOverrides, RatingOwnerState>;
|
|
61
|
+
/**
|
|
62
|
+
* Props forwarded to the decimal slot.
|
|
63
|
+
* By default, the avaible props are based on the span element.
|
|
64
|
+
*/
|
|
65
|
+
decimal: SlotProps<'span', RatingDecimalSlotPropsOverrides, RatingOwnerState>;
|
|
66
|
+
}
|
|
67
|
+
>;
|
|
68
|
+
|
|
69
|
+
export interface RatingOwnProps extends RatingSlotsAndSlotProps {
|
|
15
70
|
/**
|
|
16
71
|
* Override or extend the styles applied to the component.
|
|
17
72
|
*/
|
|
@@ -60,6 +115,7 @@ export interface RatingOwnProps {
|
|
|
60
115
|
icon?: React.ReactNode;
|
|
61
116
|
/**
|
|
62
117
|
* The component containing the icon.
|
|
118
|
+
* @deprecated Use `slotProps.icon.component` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
63
119
|
* @default function IconContainer(props) {
|
|
64
120
|
* const { value, ...other } = props;
|
|
65
121
|
* return <span {...other} />;
|
|
@@ -114,6 +170,8 @@ export interface RatingOwnProps {
|
|
|
114
170
|
value?: number | null;
|
|
115
171
|
}
|
|
116
172
|
|
|
173
|
+
export interface RatingOwnerState extends Omit<RatingProps, 'slots' | 'slotProps'> {}
|
|
174
|
+
|
|
117
175
|
export type RatingTypeMap<
|
|
118
176
|
AdditionalProps = {},
|
|
119
177
|
RootComponent extends React.ElementType = 'span',
|