New source found from dndbeyond.com
This commit is contained in:
+26
-2
@@ -2,16 +2,40 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { GlobalStyles as MuiGlobalStyles } from '@mui/styled-engine';
|
||||
import { GlobalStyles as MuiGlobalStyles, internal_serializeStyles as serializeStyles } from '@mui/styled-engine';
|
||||
import useTheme from '../useTheme';
|
||||
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 globalStyles = typeof styles === 'function' ? styles(themeId ? upperTheme[themeId] || upperTheme : upperTheme) : styles;
|
||||
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
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user