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 { styled } from "../zero-styled/index.js";
|
8 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
9 | import useSlot from "../utils/useSlot.js";
|
10 | import Fade from "../Fade/index.js";
|
11 | import { getBackdropUtilityClass } from "./backdropClasses.js";
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 | const removeOwnerState = props => {
|
14 | const {
|
15 | ownerState,
|
16 | ...rest
|
17 | } = props;
|
18 | return rest;
|
19 | };
|
20 | const useUtilityClasses = ownerState => {
|
21 | const {
|
22 | classes,
|
23 | invisible
|
24 | } = ownerState;
|
25 | const slots = {
|
26 | root: ['root', invisible && 'invisible']
|
27 | };
|
28 | return composeClasses(slots, getBackdropUtilityClass, classes);
|
29 | };
|
30 | const BackdropRoot = styled('div', {
|
31 | name: 'MuiBackdrop',
|
32 | slot: 'Root',
|
33 | overridesResolver: (props, styles) => {
|
34 | const {
|
35 | ownerState
|
36 | } = props;
|
37 | return [styles.root, ownerState.invisible && styles.invisible];
|
38 | }
|
39 | })({
|
40 | position: 'fixed',
|
41 | display: 'flex',
|
42 | alignItems: 'center',
|
43 | justifyContent: 'center',
|
44 | right: 0,
|
45 | bottom: 0,
|
46 | top: 0,
|
47 | left: 0,
|
48 | backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
49 | WebkitTapHighlightColor: 'transparent',
|
50 | variants: [{
|
51 | props: {
|
52 | invisible: true
|
53 | },
|
54 | style: {
|
55 | backgroundColor: 'transparent'
|
56 | }
|
57 | }]
|
58 | });
|
59 | const Backdrop = React.forwardRef(function Backdrop(inProps, ref) {
|
60 | const props = useDefaultProps({
|
61 | props: inProps,
|
62 | name: 'MuiBackdrop'
|
63 | });
|
64 | const {
|
65 | children,
|
66 | className,
|
67 | component = 'div',
|
68 | invisible = false,
|
69 | open,
|
70 | components = {},
|
71 | componentsProps = {},
|
72 | slotProps = {},
|
73 | slots = {},
|
74 | TransitionComponent: TransitionComponentProp,
|
75 | transitionDuration,
|
76 | ...other
|
77 | } = props;
|
78 | const ownerState = {
|
79 | ...props,
|
80 | component,
|
81 | invisible
|
82 | };
|
83 | const classes = useUtilityClasses(ownerState);
|
84 | const backwardCompatibleSlots = {
|
85 | transition: TransitionComponentProp,
|
86 | root: components.Root,
|
87 | ...slots
|
88 | };
|
89 | const backwardCompatibleSlotProps = {
|
90 | ...componentsProps,
|
91 | ...slotProps
|
92 | };
|
93 | const externalForwardedProps = {
|
94 | slots: backwardCompatibleSlots,
|
95 | slotProps: backwardCompatibleSlotProps
|
96 | };
|
97 | const [RootSlot, rootProps] = useSlot('root', {
|
98 | elementType: BackdropRoot,
|
99 | externalForwardedProps,
|
100 | className: clsx(classes.root, className),
|
101 | ownerState
|
102 | });
|
103 | const [TransitionSlot, transitionProps] = useSlot('transition', {
|
104 | elementType: Fade,
|
105 | externalForwardedProps,
|
106 | ownerState
|
107 | });
|
108 | const transitionPropsRemoved = removeOwnerState(transitionProps);
|
109 | return _jsx(TransitionSlot, {
|
110 | in: open,
|
111 | timeout: transitionDuration,
|
112 | ...other,
|
113 | ...transitionPropsRemoved,
|
114 | children: _jsx(RootSlot, {
|
115 | "aria-hidden": true,
|
116 | ...rootProps,
|
117 | classes: classes,
|
118 | ref: ref,
|
119 | children: children
|
120 | })
|
121 | });
|
122 | });
|
123 | process.env.NODE_ENV !== "production" ? Backdrop.propTypes = {
|
124 |
|
125 |
|
126 |
|
127 |
|
128 | |
129 |
|
130 |
|
131 | children: PropTypes.node,
|
132 | |
133 |
|
134 |
|
135 | classes: PropTypes.object,
|
136 | |
137 |
|
138 |
|
139 | className: PropTypes.string,
|
140 | |
141 |
|
142 |
|
143 |
|
144 | component: PropTypes.elementType,
|
145 | |
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 | components: PropTypes.shape({
|
153 | Root: PropTypes.elementType
|
154 | }),
|
155 | |
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 | componentsProps: PropTypes.shape({
|
164 | root: PropTypes.object
|
165 | }),
|
166 | |
167 |
|
168 |
|
169 |
|
170 |
|
171 | invisible: PropTypes.bool,
|
172 | |
173 |
|
174 |
|
175 | open: PropTypes.bool.isRequired,
|
176 | |
177 |
|
178 |
|
179 |
|
180 | slotProps: PropTypes.shape({
|
181 | root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
182 | transition: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
183 | }),
|
184 | |
185 |
|
186 |
|
187 |
|
188 | slots: PropTypes.shape({
|
189 | root: PropTypes.elementType,
|
190 | transition: PropTypes.elementType
|
191 | }),
|
192 | |
193 |
|
194 |
|
195 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
196 | |
197 |
|
198 |
|
199 |
|
200 |
|
201 | TransitionComponent: PropTypes.elementType,
|
202 | |
203 |
|
204 |
|
205 |
|
206 | transitionDuration: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
207 | appear: PropTypes.number,
|
208 | enter: PropTypes.number,
|
209 | exit: PropTypes.number
|
210 | })])
|
211 | } : void 0;
|
212 | export default Backdrop; |
\ | No newline at end of file |