UNPKG

4 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import composeClasses from '@mui/utils/composeClasses';
7import { styled } from "../zero-styled/index.js";
8import memoTheme from "../utils/memoTheme.js";
9import { useDefaultProps } from "../DefaultPropsProvider/index.js";
10import { html, body } from "../CssBaseline/CssBaseline.js";
11import { getScopedCssBaselineUtilityClass } from "./scopedCssBaselineClasses.js";
12import { jsx as _jsx } from "react/jsx-runtime";
13const useUtilityClasses = ownerState => {
14 const {
15 classes
16 } = ownerState;
17 const slots = {
18 root: ['root']
19 };
20 return composeClasses(slots, getScopedCssBaselineUtilityClass, classes);
21};
22const 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}));
63const ScopedCssBaseline = /*#__PURE__*/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 /*#__PURE__*/_jsx(ScopedCssBaselineRoot, {
80 as: component,
81 className: clsx(classes.root, className),
82 ref: ref,
83 ownerState: ownerState,
84 ...other
85 });
86});
87process.env.NODE_ENV !== "production" ? ScopedCssBaseline.propTypes /* remove-proptypes */ = {
88 // ┌────────────────────────────── Warning ──────────────────────────────┐
89 // │ These PropTypes are generated from the TypeScript type definitions. │
90 // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
91 // └─────────────────────────────────────────────────────────────────────┘
92 /**
93 * The content of the component.
94 */
95 children: PropTypes.node,
96 /**
97 * Override or extend the styles applied to the component.
98 */
99 classes: PropTypes.object,
100 /**
101 * @ignore
102 */
103 className: PropTypes.string,
104 /**
105 * The component used for the root node.
106 * Either a string to use a HTML element or a component.
107 */
108 component: PropTypes.elementType,
109 /**
110 * Enable `color-scheme` CSS property to use `theme.palette.mode`.
111 * For more details, check out https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme
112 * For browser support, check out https://caniuse.com/?search=color-scheme
113 */
114 enableColorScheme: PropTypes.bool,
115 /**
116 * The system prop that allows defining system overrides as well as additional CSS styles.
117 */
118 sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
119} : void 0;
120export default ScopedCssBaseline;
\No newline at end of file