Blame view

天文台pc/tianwentai-ui/node_modules/@mui/system/esm/GlobalStyles/GlobalStyles.js 2.35 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  'use client';
  
  import PropTypes from 'prop-types';
  import { GlobalStyles as MuiGlobalStyles, internal_serializeStyles as serializeStyles } from '@mui/styled-engine';
  import useTheme from "../useTheme/index.js";
  import { jsx as _jsx } from "react/jsx-runtime";
  function wrapGlobalLayer(styles) {
    const serialized = serializeStyles(styles);
    if (styles !== serialized && serialized.styles) {
      if (!serialized.styles.match(/^@layer\s+[^{]*$/)) {
        // If the styles are not already wrapped in a layer, wrap them in a global layer.
        serialized.styles = `@layer global{${serialized.styles}}`;
      }
      return serialized;
    }
    return styles;
  }
  function GlobalStyles({
    styles,
    themeId,
    defaultTheme = {}
  }) {
    const upperTheme = useTheme(defaultTheme);
    const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
    let globalStyles = typeof styles === 'function' ? styles(resolvedTheme) : styles;
    if (resolvedTheme.modularCssLayers) {
      if (Array.isArray(globalStyles)) {
        globalStyles = globalStyles.map(styleArg => {
          if (typeof styleArg === 'function') {
            return wrapGlobalLayer(styleArg(resolvedTheme));
          }
          return wrapGlobalLayer(styleArg);
        });
      } else {
        globalStyles = wrapGlobalLayer(globalStyles);
      }
    }
    return /*#__PURE__*/_jsx(MuiGlobalStyles, {
      styles: globalStyles
    });
  }
  process.env.NODE_ENV !== "production" ? GlobalStyles.propTypes /* remove-proptypes */ = {
    // ┌────────────────────────────── Warning ──────────────────────────────┐
    // │ These PropTypes are generated from the TypeScript type definitions. │
    // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
    // └─────────────────────────────────────────────────────────────────────┘
    /**
     * @ignore
     */
    defaultTheme: PropTypes.object,
    /**
     * @ignore
     */
    styles: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.array, PropTypes.func, PropTypes.number, PropTypes.object, PropTypes.string, PropTypes.bool]),
    /**
     * @ignore
     */
    themeId: PropTypes.string
  } : void 0;
  export default GlobalStyles;