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 memoTheme from "../utils/memoTheme.js";
|
9 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
10 | import { html, body } from "../CssBaseline/CssBaseline.js";
|
11 | import { getScopedCssBaselineUtilityClass } from "./scopedCssBaselineClasses.js";
|
12 | import { jsx as _jsx } from "react/jsx-runtime";
|
13 | const useUtilityClasses = ownerState => {
|
14 | const {
|
15 | classes
|
16 | } = ownerState;
|
17 | const slots = {
|
18 | root: ['root']
|
19 | };
|
20 | return composeClasses(slots, getScopedCssBaselineUtilityClass, classes);
|
21 | };
|
22 | const ScopedCssBaselineRoot = styled('div', {
|
23 | name: 'MuiScopedCssBaseline',
|
24 | slot: 'Root',
|
25 | overridesResolver: (props, styles) => styles.root
|
26 | })(memoTheme(({
|
27 | theme
|
28 | }) => {
|
29 | const colorSchemeStyles = {};
|
30 | if (theme.colorSchemes) {
|
31 | Object.entries(theme.colorSchemes).forEach(([key, scheme]) => {
|
32 | const selector = theme.getColorSchemeSelector(key);
|
33 | if (selector.startsWith('@')) {
|
34 | colorSchemeStyles[selector] = {
|
35 | colorScheme: scheme.palette?.mode
|
36 | };
|
37 | } else {
|
38 | colorSchemeStyles[`&${selector.replace(/\s*&/, '')}`] = {
|
39 | colorScheme: scheme.palette?.mode
|
40 | };
|
41 | }
|
42 | });
|
43 | }
|
44 | return {
|
45 | ...html(theme, false),
|
46 | ...body(theme),
|
47 | '& *, & *::before, & *::after': {
|
48 | boxSizing: 'inherit'
|
49 | },
|
50 | '& strong, & b': {
|
51 | fontWeight: theme.typography.fontWeightBold
|
52 | },
|
53 | variants: [{
|
54 | props: {
|
55 | enableColorScheme: true
|
56 | },
|
57 | style: theme.vars ? colorSchemeStyles : {
|
58 | colorScheme: theme.palette.mode
|
59 | }
|
60 | }]
|
61 | };
|
62 | }));
|
63 | const ScopedCssBaseline = React.forwardRef(function ScopedCssBaseline(inProps, ref) {
|
64 | const props = useDefaultProps({
|
65 | props: inProps,
|
66 | name: 'MuiScopedCssBaseline'
|
67 | });
|
68 | const {
|
69 | className,
|
70 | component = 'div',
|
71 | enableColorScheme,
|
72 | ...other
|
73 | } = props;
|
74 | const ownerState = {
|
75 | ...props,
|
76 | component
|
77 | };
|
78 | const classes = useUtilityClasses(ownerState);
|
79 | return _jsx(ScopedCssBaselineRoot, {
|
80 | as: component,
|
81 | className: clsx(classes.root, className),
|
82 | ref: ref,
|
83 | ownerState: ownerState,
|
84 | ...other
|
85 | });
|
86 | });
|
87 | process.env.NODE_ENV !== "production" ? ScopedCssBaseline.propTypes = {
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | |
93 |
|
94 |
|
95 | children: PropTypes.node,
|
96 | |
97 |
|
98 |
|
99 | classes: PropTypes.object,
|
100 | |
101 |
|
102 |
|
103 | className: PropTypes.string,
|
104 | |
105 |
|
106 |
|
107 |
|
108 | component: PropTypes.elementType,
|
109 | |
110 |
|
111 |
|
112 |
|
113 |
|
114 | enableColorScheme: PropTypes.bool,
|
115 | |
116 |
|
117 |
|
118 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
|
119 | } : void 0;
|
120 | export default ScopedCssBaseline; |
\ | No newline at end of file |