New source found from dndbeyond.com
This commit is contained in:
Generated
Vendored
+37
-8
@@ -8,28 +8,57 @@ import createCache from '@emotion/cache';
|
||||
// prepend: true moves MUI styles to the top of the <head> so they're loaded first.
|
||||
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
let cache;
|
||||
if (typeof document === 'object') {
|
||||
cache = createCache({
|
||||
function getCache(injectFirst, enableCssLayer) {
|
||||
const emotionCache = createCache({
|
||||
key: 'css',
|
||||
prepend: true
|
||||
prepend: injectFirst
|
||||
});
|
||||
if (enableCssLayer) {
|
||||
const prevInsert = emotionCache.insert;
|
||||
emotionCache.insert = (...args) => {
|
||||
if (!args[1].styles.match(/^@layer\s+[^{]*$/)) {
|
||||
// avoid nested @layer
|
||||
args[1].styles = `@layer mui {${args[1].styles}}`;
|
||||
}
|
||||
return prevInsert(...args);
|
||||
};
|
||||
}
|
||||
return emotionCache;
|
||||
}
|
||||
const cacheMap = new Map();
|
||||
export default function StyledEngineProvider(props) {
|
||||
const {
|
||||
injectFirst,
|
||||
enableCssLayer,
|
||||
children
|
||||
} = props;
|
||||
return injectFirst && cache ? /*#__PURE__*/_jsx(CacheProvider, {
|
||||
value: cache,
|
||||
children: children
|
||||
}) : children;
|
||||
const cache = React.useMemo(() => {
|
||||
const cacheKey = `${injectFirst}-${enableCssLayer}`;
|
||||
if (typeof document === 'object' && cacheMap.has(cacheKey)) {
|
||||
return cacheMap.get(cacheKey);
|
||||
}
|
||||
const fresh = getCache(injectFirst, enableCssLayer);
|
||||
cacheMap.set(cacheKey, fresh);
|
||||
return fresh;
|
||||
}, [injectFirst, enableCssLayer]);
|
||||
if (injectFirst || enableCssLayer) {
|
||||
return /*#__PURE__*/_jsx(CacheProvider, {
|
||||
value: cache,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
return children;
|
||||
}
|
||||
process.env.NODE_ENV !== "production" ? StyledEngineProvider.propTypes = {
|
||||
/**
|
||||
* Your component tree.
|
||||
*/
|
||||
children: PropTypes.node,
|
||||
/**
|
||||
* If true, MUI styles are wrapped in CSS `@layer mui` rule.
|
||||
* It helps to override MUI styles when using CSS Modules, Tailwind CSS, plain CSS, or any other styling solution.
|
||||
*/
|
||||
enableCssLayer: PropTypes.bool,
|
||||
/**
|
||||
* By default, the styles are injected last in the <head> element of the page.
|
||||
* As a result, they gain more specificity than any other style sheet.
|
||||
|
||||
+10
-1
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @mui/styled-engine v5.15.14
|
||||
* @mui/styled-engine v5.18.0
|
||||
*
|
||||
* @license MIT
|
||||
* This source code is licensed under the MIT license found in the
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
import emStyled from '@emotion/styled';
|
||||
import { serializeStyles as emSerializeStyles } from '@emotion/serialize';
|
||||
export default function styled(tag, options) {
|
||||
const stylesFactory = emStyled(tag, options);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
@@ -33,6 +34,14 @@ export const internal_processStyles = (tag, processor) => {
|
||||
tag.__emotion_styles = processor(tag.__emotion_styles);
|
||||
}
|
||||
};
|
||||
|
||||
// Emotion only accepts an array, but we want to avoid allocations
|
||||
const wrapper = [];
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export function internal_serializeStyles(styles) {
|
||||
wrapper[0] = styles;
|
||||
return emSerializeStyles(wrapper);
|
||||
}
|
||||
export { ThemeContext, keyframes, css } from '@emotion/react';
|
||||
export { default as StyledEngineProvider } from './StyledEngineProvider';
|
||||
export { default as GlobalStyles } from './GlobalStyles';
|
||||
Reference in New Issue
Block a user