@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
|
@@ -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/modern/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,8 @@ const Radio = /*#__PURE__*/React.forwardRef(function Radio(inProps, ref) {
|
|
|
125
126
|
className,
|
|
126
127
|
disabled: disabledProp,
|
|
127
128
|
disableRipple = false,
|
|
129
|
+
slots = {},
|
|
130
|
+
slotProps = {},
|
|
128
131
|
...other
|
|
129
132
|
} = props;
|
|
130
133
|
const muiFormControl = useFormControl();
|
|
@@ -155,23 +158,45 @@ const Radio = /*#__PURE__*/React.forwardRef(function Radio(inProps, ref) {
|
|
|
155
158
|
name = radioGroup.name;
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
fontSize: defaultIcon.props.fontSize ?? size
|
|
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,
|
|
161
|
+
const [RootSlot, rootSlotProps] = useSlot('root', {
|
|
162
|
+
ref,
|
|
163
|
+
elementType: RadioRoot,
|
|
173
164
|
className: clsx(classes.root, className),
|
|
174
|
-
|
|
165
|
+
shouldForwardComponentProp: true,
|
|
166
|
+
externalForwardedProps: {
|
|
167
|
+
slots,
|
|
168
|
+
slotProps,
|
|
169
|
+
...other
|
|
170
|
+
},
|
|
171
|
+
getSlotProps: handlers => ({
|
|
172
|
+
...handlers,
|
|
173
|
+
onChange: (event, ...args) => {
|
|
174
|
+
handlers.onChange?.(event, ...args);
|
|
175
|
+
onChange(event, ...args);
|
|
176
|
+
}
|
|
177
|
+
}),
|
|
178
|
+
ownerState,
|
|
179
|
+
additionalProps: {
|
|
180
|
+
type: 'radio',
|
|
181
|
+
icon: /*#__PURE__*/React.cloneElement(icon, {
|
|
182
|
+
fontSize: icon.props.fontSize ?? size
|
|
183
|
+
}),
|
|
184
|
+
checkedIcon: /*#__PURE__*/React.cloneElement(checkedIcon, {
|
|
185
|
+
fontSize: checkedIcon.props.fontSize ?? size
|
|
186
|
+
}),
|
|
187
|
+
disabled,
|
|
188
|
+
name,
|
|
189
|
+
checked,
|
|
190
|
+
slots,
|
|
191
|
+
slotProps: {
|
|
192
|
+
// Do not forward `slotProps.root` again because it's already handled by the `RootSlot` in this file.
|
|
193
|
+
input: typeof slotProps.input === 'function' ? slotProps.input(ownerState) : slotProps.input
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
return /*#__PURE__*/_jsx(RootSlot, {
|
|
198
|
+
...rootSlotProps,
|
|
199
|
+
classes: classes
|
|
175
200
|
});
|
|
176
201
|
});
|
|
177
202
|
process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ = {
|
|
@@ -223,10 +248,12 @@ process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ =
|
|
|
223
248
|
id: PropTypes.string,
|
|
224
249
|
/**
|
|
225
250
|
* [Attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes) applied to the `input` element.
|
|
251
|
+
* @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
252
|
*/
|
|
227
253
|
inputProps: PropTypes.object,
|
|
228
254
|
/**
|
|
229
255
|
* Pass a ref to the `input` element.
|
|
256
|
+
* @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
257
|
*/
|
|
231
258
|
inputRef: refType,
|
|
232
259
|
/**
|
|
@@ -252,6 +279,22 @@ process.env.NODE_ENV !== "production" ? Radio.propTypes /* remove-proptypes */ =
|
|
|
252
279
|
* @default 'medium'
|
|
253
280
|
*/
|
|
254
281
|
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.oneOf(['medium', 'small']), PropTypes.string]),
|
|
282
|
+
/**
|
|
283
|
+
* The props used for each slot inside.
|
|
284
|
+
* @default {}
|
|
285
|
+
*/
|
|
286
|
+
slotProps: PropTypes.shape({
|
|
287
|
+
input: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
288
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
289
|
+
}),
|
|
290
|
+
/**
|
|
291
|
+
* The components used for each slot inside.
|
|
292
|
+
* @default {}
|
|
293
|
+
*/
|
|
294
|
+
slots: PropTypes.shape({
|
|
295
|
+
input: PropTypes.elementType,
|
|
296
|
+
root: PropTypes.elementType
|
|
297
|
+
}),
|
|
255
298
|
/**
|
|
256
299
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
257
300
|
*/
|
|
@@ -500,16 +500,16 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
|
|
|
500
500
|
horizontal: 'center'
|
|
501
501
|
},
|
|
502
502
|
...MenuProps,
|
|
503
|
-
MenuListProps: {
|
|
504
|
-
'aria-labelledby': labelId,
|
|
505
|
-
role: 'listbox',
|
|
506
|
-
'aria-multiselectable': multiple ? 'true' : undefined,
|
|
507
|
-
disableListWrap: true,
|
|
508
|
-
id: listboxId,
|
|
509
|
-
...MenuProps.MenuListProps
|
|
510
|
-
},
|
|
511
503
|
slotProps: {
|
|
512
504
|
...MenuProps.slotProps,
|
|
505
|
+
list: {
|
|
506
|
+
'aria-labelledby': labelId,
|
|
507
|
+
role: 'listbox',
|
|
508
|
+
'aria-multiselectable': multiple ? 'true' : undefined,
|
|
509
|
+
disableListWrap: true,
|
|
510
|
+
id: listboxId,
|
|
511
|
+
...MenuProps.MenuListProps
|
|
512
|
+
},
|
|
513
513
|
paper: {
|
|
514
514
|
...paperProps,
|
|
515
515
|
style: {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
|
-
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
6
|
import useSnackbar from "./useSnackbar.js";
|
|
8
7
|
import ClickAwayListener from "../ClickAwayListener/index.js";
|
|
9
8
|
import { styled, useTheme } from "../zero-styled/index.js";
|
|
@@ -13,6 +12,7 @@ import capitalize from "../utils/capitalize.js";
|
|
|
13
12
|
import Grow from "../Grow/index.js";
|
|
14
13
|
import SnackbarContent from "../SnackbarContent/index.js";
|
|
15
14
|
import { getSnackbarUtilityClass } from "./snackbarClasses.js";
|
|
15
|
+
import useSlot from "../utils/useSlot.js";
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
const useUtilityClasses = ownerState => {
|
|
18
18
|
const {
|
|
@@ -120,8 +120,8 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
|
|
|
120
120
|
autoHideDuration = null,
|
|
121
121
|
children,
|
|
122
122
|
className,
|
|
123
|
-
ClickAwayListenerProps,
|
|
124
|
-
ContentProps,
|
|
123
|
+
ClickAwayListenerProps: ClickAwayListenerPropsProp,
|
|
124
|
+
ContentProps: ContentPropsProp,
|
|
125
125
|
disableWindowBlurListener = false,
|
|
126
126
|
message,
|
|
127
127
|
onBlur,
|
|
@@ -131,12 +131,14 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
|
|
|
131
131
|
onMouseLeave,
|
|
132
132
|
open,
|
|
133
133
|
resumeHideDuration,
|
|
134
|
-
|
|
134
|
+
slots = {},
|
|
135
|
+
slotProps = {},
|
|
136
|
+
TransitionComponent: TransitionComponentProp,
|
|
135
137
|
transitionDuration = defaultTransitionDuration,
|
|
136
138
|
TransitionProps: {
|
|
137
139
|
onEnter,
|
|
138
140
|
onExited,
|
|
139
|
-
...
|
|
141
|
+
...TransitionPropsProp
|
|
140
142
|
} = {},
|
|
141
143
|
...other
|
|
142
144
|
} = props;
|
|
@@ -148,7 +150,7 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
|
|
|
148
150
|
},
|
|
149
151
|
autoHideDuration,
|
|
150
152
|
disableWindowBlurListener,
|
|
151
|
-
TransitionComponent,
|
|
153
|
+
TransitionComponent: TransitionComponentProp,
|
|
152
154
|
transitionDuration
|
|
153
155
|
};
|
|
154
156
|
const classes = useUtilityClasses(ownerState);
|
|
@@ -159,16 +161,6 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
|
|
|
159
161
|
...ownerState
|
|
160
162
|
});
|
|
161
163
|
const [exited, setExited] = React.useState(true);
|
|
162
|
-
const rootProps = useSlotProps({
|
|
163
|
-
elementType: SnackbarRoot,
|
|
164
|
-
getSlotProps: getRootProps,
|
|
165
|
-
externalForwardedProps: other,
|
|
166
|
-
ownerState,
|
|
167
|
-
additionalProps: {
|
|
168
|
-
ref
|
|
169
|
-
},
|
|
170
|
-
className: [classes.root, className]
|
|
171
|
-
});
|
|
172
164
|
const handleExited = node => {
|
|
173
165
|
setExited(true);
|
|
174
166
|
if (onExited) {
|
|
@@ -181,28 +173,84 @@ const Snackbar = /*#__PURE__*/React.forwardRef(function Snackbar(inProps, ref) {
|
|
|
181
173
|
onEnter(node, isAppearing);
|
|
182
174
|
}
|
|
183
175
|
};
|
|
176
|
+
const externalForwardedProps = {
|
|
177
|
+
slots: {
|
|
178
|
+
transition: TransitionComponentProp,
|
|
179
|
+
...slots
|
|
180
|
+
},
|
|
181
|
+
slotProps: {
|
|
182
|
+
content: ContentPropsProp,
|
|
183
|
+
clickAwayListener: ClickAwayListenerPropsProp,
|
|
184
|
+
transition: TransitionPropsProp,
|
|
185
|
+
...slotProps
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const [Root, rootProps] = useSlot('root', {
|
|
189
|
+
ref,
|
|
190
|
+
className: [classes.root, className],
|
|
191
|
+
elementType: SnackbarRoot,
|
|
192
|
+
getSlotProps: getRootProps,
|
|
193
|
+
externalForwardedProps: {
|
|
194
|
+
...externalForwardedProps,
|
|
195
|
+
...other
|
|
196
|
+
},
|
|
197
|
+
ownerState
|
|
198
|
+
});
|
|
199
|
+
const [ClickAwaySlot, clickAwayListenerProps] = useSlot('clickAwayListener', {
|
|
200
|
+
elementType: ClickAwayListener,
|
|
201
|
+
externalForwardedProps,
|
|
202
|
+
getSlotProps: handlers => ({
|
|
203
|
+
onClickAway: (...params) => {
|
|
204
|
+
handlers.onClickAway?.(...params);
|
|
205
|
+
onClickAway(...params);
|
|
206
|
+
}
|
|
207
|
+
}),
|
|
208
|
+
ownerState
|
|
209
|
+
});
|
|
210
|
+
const [ContentSlot, contentSlotProps] = useSlot('content', {
|
|
211
|
+
elementType: SnackbarContent,
|
|
212
|
+
shouldForwardComponentProp: true,
|
|
213
|
+
externalForwardedProps,
|
|
214
|
+
additionalProps: {
|
|
215
|
+
message,
|
|
216
|
+
action
|
|
217
|
+
},
|
|
218
|
+
ownerState
|
|
219
|
+
});
|
|
220
|
+
const [TransitionSlot, transitionProps] = useSlot('transition', {
|
|
221
|
+
elementType: Grow,
|
|
222
|
+
externalForwardedProps,
|
|
223
|
+
getSlotProps: handlers => ({
|
|
224
|
+
onEnter: (...params) => {
|
|
225
|
+
handlers.onEnter?.(...params);
|
|
226
|
+
handleEnter(...params);
|
|
227
|
+
},
|
|
228
|
+
onExited: (...params) => {
|
|
229
|
+
handlers.onExited?.(...params);
|
|
230
|
+
handleExited(...params);
|
|
231
|
+
}
|
|
232
|
+
}),
|
|
233
|
+
additionalProps: {
|
|
234
|
+
appear: true,
|
|
235
|
+
in: open,
|
|
236
|
+
timeout: transitionDuration,
|
|
237
|
+
direction: vertical === 'top' ? 'down' : 'up'
|
|
238
|
+
},
|
|
239
|
+
ownerState
|
|
240
|
+
});
|
|
184
241
|
|
|
185
242
|
// So we only render active snackbars.
|
|
186
243
|
if (!open && exited) {
|
|
187
244
|
return null;
|
|
188
245
|
}
|
|
189
|
-
return /*#__PURE__*/_jsx(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
children: /*#__PURE__*/_jsx(SnackbarRoot, {
|
|
246
|
+
return /*#__PURE__*/_jsx(ClickAwaySlot, {
|
|
247
|
+
...clickAwayListenerProps,
|
|
248
|
+
children: /*#__PURE__*/_jsx(Root, {
|
|
193
249
|
...rootProps,
|
|
194
|
-
children: /*#__PURE__*/_jsx(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
direction: vertical === 'top' ? 'down' : 'up',
|
|
199
|
-
onEnter: handleEnter,
|
|
200
|
-
onExited: handleExited,
|
|
201
|
-
...TransitionProps,
|
|
202
|
-
children: children || /*#__PURE__*/_jsx(SnackbarContent, {
|
|
203
|
-
message: message,
|
|
204
|
-
action: action,
|
|
205
|
-
...ContentProps
|
|
250
|
+
children: /*#__PURE__*/_jsx(TransitionSlot, {
|
|
251
|
+
...transitionProps,
|
|
252
|
+
children: children || /*#__PURE__*/_jsx(ContentSlot, {
|
|
253
|
+
...contentSlotProps
|
|
206
254
|
})
|
|
207
255
|
})
|
|
208
256
|
})
|
|
@@ -249,10 +297,12 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
|
|
|
249
297
|
className: PropTypes.string,
|
|
250
298
|
/**
|
|
251
299
|
* Props applied to the `ClickAwayListener` element.
|
|
300
|
+
* @deprecated Use `slotProps.clickAwayListener` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
252
301
|
*/
|
|
253
302
|
ClickAwayListenerProps: PropTypes.object,
|
|
254
303
|
/**
|
|
255
304
|
* Props applied to the [`SnackbarContent`](https://mui.com/material-ui/api/snackbar-content/) element.
|
|
305
|
+
* @deprecated Use `slotProps.content` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
256
306
|
*/
|
|
257
307
|
ContentProps: PropTypes.object,
|
|
258
308
|
/**
|
|
@@ -309,6 +359,32 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
|
|
|
309
359
|
* we default to `autoHideDuration / 2` ms.
|
|
310
360
|
*/
|
|
311
361
|
resumeHideDuration: PropTypes.number,
|
|
362
|
+
/**
|
|
363
|
+
* The props used for each slot inside.
|
|
364
|
+
* @default {}
|
|
365
|
+
*/
|
|
366
|
+
slotProps: PropTypes.shape({
|
|
367
|
+
clickAwayListener: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
368
|
+
children: PropTypes.element.isRequired,
|
|
369
|
+
disableReactTree: PropTypes.bool,
|
|
370
|
+
mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
|
|
371
|
+
onClickAway: PropTypes.func,
|
|
372
|
+
touchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false])
|
|
373
|
+
})]),
|
|
374
|
+
content: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
375
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
376
|
+
transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
377
|
+
}),
|
|
378
|
+
/**
|
|
379
|
+
* The components used for each slot inside.
|
|
380
|
+
* @default {}
|
|
381
|
+
*/
|
|
382
|
+
slots: PropTypes.shape({
|
|
383
|
+
clickAwayListener: PropTypes.elementType,
|
|
384
|
+
content: PropTypes.elementType,
|
|
385
|
+
root: PropTypes.elementType,
|
|
386
|
+
transition: PropTypes.elementType
|
|
387
|
+
}),
|
|
312
388
|
/**
|
|
313
389
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
314
390
|
*/
|
|
@@ -316,6 +392,7 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
|
|
|
316
392
|
/**
|
|
317
393
|
* The component used for the transition.
|
|
318
394
|
* [Follow this guide](https://mui.com/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
|
|
395
|
+
* @deprecated Use `slots.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
319
396
|
* @default Grow
|
|
320
397
|
*/
|
|
321
398
|
TransitionComponent: PropTypes.elementType,
|
|
@@ -335,6 +412,7 @@ process.env.NODE_ENV !== "production" ? Snackbar.propTypes /* remove-proptypes *
|
|
|
335
412
|
/**
|
|
336
413
|
* Props applied to the transition element.
|
|
337
414
|
* By default, the element is based on this [`Transition`](https://reactcommunity.org/react-transition-group/transition/) component.
|
|
415
|
+
* @deprecated Use `slotProps.transition` instead. This prop will be removed in v7. See [Migrating from deprecated APIs](/material-ui/migration/migrating-from-deprecated-apis/) for more details.
|
|
338
416
|
* @default {}
|
|
339
417
|
*/
|
|
340
418
|
TransitionProps: PropTypes.object
|