1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import clsx from 'clsx';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import { emphasize } from '@mui/system/colorManipulator';
|
8 | import { styled } from "../zero-styled/index.js";
|
9 | import memoTheme from "../utils/memoTheme.js";
|
10 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
11 | import Paper from "../Paper/index.js";
|
12 | import { getSnackbarContentUtilityClass } from "./snackbarContentClasses.js";
|
13 | import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
14 | const useUtilityClasses = ownerState => {
|
15 | const {
|
16 | classes
|
17 | } = ownerState;
|
18 | const slots = {
|
19 | root: ['root'],
|
20 | action: ['action'],
|
21 | message: ['message']
|
22 | };
|
23 | return composeClasses(slots, getSnackbarContentUtilityClass, classes);
|
24 | };
|
25 | const SnackbarContentRoot = styled(Paper, {
|
26 | name: 'MuiSnackbarContent',
|
27 | slot: 'Root',
|
28 | overridesResolver: (props, styles) => styles.root
|
29 | })(memoTheme(({
|
30 | theme
|
31 | }) => {
|
32 | const emphasis = theme.palette.mode === 'light' ? 0.8 : 0.98;
|
33 | const backgroundColor = emphasize(theme.palette.background.default, emphasis);
|
34 | return {
|
35 | ...theme.typography.body2,
|
36 | color: theme.vars ? theme.vars.palette.SnackbarContent.color : theme.palette.getContrastText(backgroundColor),
|
37 | backgroundColor: theme.vars ? theme.vars.palette.SnackbarContent.bg : backgroundColor,
|
38 | display: 'flex',
|
39 | alignItems: 'center',
|
40 | flexWrap: 'wrap',
|
41 | padding: '6px 16px',
|
42 | borderRadius: (theme.vars || theme).shape.borderRadius,
|
43 | flexGrow: 1,
|
44 | [theme.breakpoints.up('sm')]: {
|
45 | flexGrow: 'initial',
|
46 | minWidth: 288
|
47 | }
|
48 | };
|
49 | }));
|
50 | const SnackbarContentMessage = styled('div', {
|
51 | name: 'MuiSnackbarContent',
|
52 | slot: 'Message',
|
53 | overridesResolver: (props, styles) => styles.message
|
54 | })({
|
55 | padding: '8px 0'
|
56 | });
|
57 | const SnackbarContentAction = styled('div', {
|
58 | name: 'MuiSnackbarContent',
|
59 | slot: 'Action',
|
60 | overridesResolver: (props, styles) => styles.action
|
61 | })({
|
62 | display: 'flex',
|
63 | alignItems: 'center',
|
64 | marginLeft: 'auto',
|
65 | paddingLeft: 16,
|
66 | marginRight: -8
|
67 | });
|
68 | const SnackbarContent = React.forwardRef(function SnackbarContent(inProps, ref) {
|
69 | const props = useDefaultProps({
|
70 | props: inProps,
|
71 | name: 'MuiSnackbarContent'
|
72 | });
|
73 | const {
|
74 | action,
|
75 | className,
|
76 | message,
|
77 | role = 'alert',
|
78 | ...other
|
79 | } = props;
|
80 | const ownerState = props;
|
81 | const classes = useUtilityClasses(ownerState);
|
82 | return _jsxs(SnackbarContentRoot, {
|
83 | role: role,
|
84 | square: true,
|
85 | elevation: 6,
|
86 | className: clsx(classes.root, className),
|
87 | ownerState: ownerState,
|
88 | ref: ref,
|
89 | ...other,
|
90 | children: [_jsx(SnackbarContentMessage, {
|
91 | className: classes.message,
|
92 | ownerState: ownerState,
|
93 | children: message
|
94 | }), action ? _jsx(SnackbarContentAction, {
|
95 | className: classes.action,
|
96 | ownerState: ownerState,
|
97 | children: action
|
98 | }) : null]
|
99 | });
|
100 | });
|
101 | process.env.NODE_ENV !== "production" ? SnackbarContent.propTypes = {
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | |
107 |
|
108 |
|
109 | action: PropTypes.node,
|
110 | |
111 |
|
112 |
|
113 | classes: PropTypes.object,
|
114 | |
115 |
|
116 |
|
117 | className: PropTypes.string,
|
118 | |
119 |
|
120 |
|
121 | message: PropTypes.node,
|
122 | |
123 |
|
124 |
|
125 |
|
126 | role: PropTypes .string,
|
127 | |
128 |
|
129 |
|
130 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
131 | } : void 0;
|
132 | export default SnackbarContent; |
\ | No newline at end of file |