1 | "use strict";
|
2 | 'use client';
|
3 |
|
4 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
6 | Object.defineProperty(exports, "__esModule", {
|
7 | value: true
|
8 | });
|
9 | exports.styles = exports.html = exports.default = exports.body = void 0;
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
12 | var _zeroStyled = require("../zero-styled");
|
13 | var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
14 | var _jsxRuntime = require("react/jsx-runtime");
|
15 |
|
16 | const isDynamicSupport = typeof (0, _zeroStyled.globalCss)({}) === 'function';
|
17 | const html = (theme, enableColorScheme) => ({
|
18 | WebkitFontSmoothing: 'antialiased',
|
19 |
|
20 | MozOsxFontSmoothing: 'grayscale',
|
21 |
|
22 |
|
23 |
|
24 | boxSizing: 'border-box',
|
25 |
|
26 | WebkitTextSizeAdjust: '100%',
|
27 |
|
28 | ...(enableColorScheme && !theme.vars && {
|
29 | colorScheme: theme.palette.mode
|
30 | })
|
31 | });
|
32 | exports.html = html;
|
33 | const body = theme => ({
|
34 | color: (theme.vars || theme).palette.text.primary,
|
35 | ...theme.typography.body1,
|
36 | backgroundColor: (theme.vars || theme).palette.background.default,
|
37 | '@media print': {
|
38 |
|
39 | backgroundColor: (theme.vars || theme).palette.common.white
|
40 | }
|
41 | });
|
42 | exports.body = body;
|
43 | const styles = (theme, enableColorScheme = false) => {
|
44 | const colorSchemeStyles = {};
|
45 | if (enableColorScheme && theme.colorSchemes && typeof theme.getColorSchemeSelector === 'function') {
|
46 | Object.entries(theme.colorSchemes).forEach(([key, scheme]) => {
|
47 | const selector = theme.getColorSchemeSelector(key);
|
48 | if (selector.startsWith('@')) {
|
49 |
|
50 | colorSchemeStyles[selector] = {
|
51 | ':root': {
|
52 | colorScheme: scheme.palette?.mode
|
53 | }
|
54 | };
|
55 | } else {
|
56 |
|
57 | colorSchemeStyles[selector.replace(/\s*&/, '')] = {
|
58 | colorScheme: scheme.palette?.mode
|
59 | };
|
60 | }
|
61 | });
|
62 | }
|
63 | let defaultStyles = {
|
64 | html: html(theme, enableColorScheme),
|
65 | '*, *::before, *::after': {
|
66 | boxSizing: 'inherit'
|
67 | },
|
68 | 'strong, b': {
|
69 | fontWeight: theme.typography.fontWeightBold
|
70 | },
|
71 | body: {
|
72 | margin: 0,
|
73 |
|
74 | ...body(theme),
|
75 |
|
76 |
|
77 | '&::backdrop': {
|
78 | backgroundColor: (theme.vars || theme).palette.background.default
|
79 | }
|
80 | },
|
81 | ...colorSchemeStyles
|
82 | };
|
83 | const themeOverrides = theme.components?.MuiCssBaseline?.styleOverrides;
|
84 | if (themeOverrides) {
|
85 | defaultStyles = [defaultStyles, themeOverrides];
|
86 | }
|
87 | return defaultStyles;
|
88 | };
|
89 |
|
90 |
|
91 | exports.styles = styles;
|
92 | const SELECTOR = 'mui-ecs';
|
93 | const staticStyles = theme => {
|
94 | const result = styles(theme, false);
|
95 | const baseStyles = Array.isArray(result) ? result[0] : result;
|
96 | if (!theme.vars && baseStyles) {
|
97 | baseStyles.html[`:root:has(${SELECTOR})`] = {
|
98 | colorScheme: theme.palette.mode
|
99 | };
|
100 | }
|
101 | if (theme.colorSchemes) {
|
102 | Object.entries(theme.colorSchemes).forEach(([key, scheme]) => {
|
103 | const selector = theme.getColorSchemeSelector(key);
|
104 | if (selector.startsWith('@')) {
|
105 |
|
106 | baseStyles[selector] = {
|
107 | [`:root:not(:has(.${SELECTOR}))`]: {
|
108 | colorScheme: scheme.palette?.mode
|
109 | }
|
110 | };
|
111 | } else {
|
112 |
|
113 | baseStyles[selector.replace(/\s*&/, '')] = {
|
114 | [`&:not(:has(.${SELECTOR}))`]: {
|
115 | colorScheme: scheme.palette?.mode
|
116 | }
|
117 | };
|
118 | }
|
119 | });
|
120 | }
|
121 | return result;
|
122 | };
|
123 | const GlobalStyles = (0, _zeroStyled.globalCss)(isDynamicSupport ? ({
|
124 | theme,
|
125 | enableColorScheme
|
126 | }) => styles(theme, enableColorScheme) : ({
|
127 | theme
|
128 | }) => staticStyles(theme));
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | function CssBaseline(inProps) {
|
134 | const props = (0, _DefaultPropsProvider.useDefaultProps)({
|
135 | props: inProps,
|
136 | name: 'MuiCssBaseline'
|
137 | });
|
138 | const {
|
139 | children,
|
140 | enableColorScheme = false
|
141 | } = props;
|
142 | return (0, _jsxRuntime.jsxs)(React.Fragment, {
|
143 | children: [isDynamicSupport && (0, _jsxRuntime.jsx)(GlobalStyles, {
|
144 | enableColorScheme: enableColorScheme
|
145 | }), !isDynamicSupport && !enableColorScheme && (0, _jsxRuntime.jsx)("span", {
|
146 | className: SELECTOR,
|
147 | style: {
|
148 | display: 'none'
|
149 | }
|
150 | }), children]
|
151 | });
|
152 | }
|
153 | process.env.NODE_ENV !== "production" ? CssBaseline.propTypes = {
|
154 |
|
155 |
|
156 |
|
157 |
|
158 | |
159 |
|
160 |
|
161 | children: _propTypes.default.node,
|
162 | |
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 | enableColorScheme: _propTypes.default.bool
|
169 | } : void 0;
|
170 | var _default = exports.default = CssBaseline; |
\ | No newline at end of file |