New source found from dndbeyond.com
This commit is contained in:
+6
-151
@@ -1,5 +1,5 @@
|
||||
import { StyleSheet } from '@emotion/sheet';
|
||||
import { dealloc, alloc, next, token, from, peek, delimit, slice, position, RULESET, combine, match, serialize, copy, replace, WEBKIT, MOZ, MS, KEYFRAMES, DECLARATION, hash, charat, strlen, indexof, stringify, COMMENT, rulesheet, middleware, compile } from 'stylis';
|
||||
import { dealloc, alloc, next, token, from, peek, delimit, slice, position, RULESET, combine, match, serialize, copy, replace, WEBKIT, MOZ, MS, KEYFRAMES, DECLARATION, hash, charat, strlen, indexof, stringify, rulesheet, middleware, compile } from 'stylis';
|
||||
import '@emotion/weak-memoize';
|
||||
import '@emotion/memoize';
|
||||
|
||||
@@ -81,8 +81,8 @@ var compat = function compat(element) {
|
||||
return;
|
||||
}
|
||||
|
||||
var value = element.value,
|
||||
parent = element.parent;
|
||||
var value = element.value;
|
||||
var parent = element.parent;
|
||||
var isImplicitRule = element.column === parent.column && element.line === parent.line;
|
||||
|
||||
while (parent.type !== 'rule') {
|
||||
@@ -127,114 +127,6 @@ var removeLabel = function removeLabel(element) {
|
||||
}
|
||||
}
|
||||
};
|
||||
var ignoreFlag = 'emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason';
|
||||
|
||||
var isIgnoringComment = function isIgnoringComment(element) {
|
||||
return element.type === 'comm' && element.children.indexOf(ignoreFlag) > -1;
|
||||
};
|
||||
|
||||
var createUnsafeSelectorsAlarm = function createUnsafeSelectorsAlarm(cache) {
|
||||
return function (element, index, children) {
|
||||
if (element.type !== 'rule' || cache.compat) return;
|
||||
var unsafePseudoClasses = element.value.match(/(:first|:nth|:nth-last)-child/g);
|
||||
|
||||
if (unsafePseudoClasses) {
|
||||
var isNested = !!element.parent; // in nested rules comments become children of the "auto-inserted" rule and that's always the `element.parent`
|
||||
//
|
||||
// considering this input:
|
||||
// .a {
|
||||
// .b /* comm */ {}
|
||||
// color: hotpink;
|
||||
// }
|
||||
// we get output corresponding to this:
|
||||
// .a {
|
||||
// & {
|
||||
// /* comm */
|
||||
// color: hotpink;
|
||||
// }
|
||||
// .b {}
|
||||
// }
|
||||
|
||||
var commentContainer = isNested ? element.parent.children : // global rule at the root level
|
||||
children;
|
||||
|
||||
for (var i = commentContainer.length - 1; i >= 0; i--) {
|
||||
var node = commentContainer[i];
|
||||
|
||||
if (node.line < element.line) {
|
||||
break;
|
||||
} // it is quite weird but comments are *usually* put at `column: element.column - 1`
|
||||
// so we seek *from the end* for the node that is earlier than the rule's `element` and check that
|
||||
// this will also match inputs like this:
|
||||
// .a {
|
||||
// /* comm */
|
||||
// .b {}
|
||||
// }
|
||||
//
|
||||
// but that is fine
|
||||
//
|
||||
// it would be the easiest to change the placement of the comment to be the first child of the rule:
|
||||
// .a {
|
||||
// .b { /* comm */ }
|
||||
// }
|
||||
// with such inputs we wouldn't have to search for the comment at all
|
||||
// TODO: consider changing this comment placement in the next major version
|
||||
|
||||
|
||||
if (node.column < element.column) {
|
||||
if (isIgnoringComment(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsafePseudoClasses.forEach(function (unsafePseudoClass) {
|
||||
console.error("The pseudo class \"" + unsafePseudoClass + "\" is potentially unsafe when doing server-side rendering. Try changing it to \"" + unsafePseudoClass.split('-child')[0] + "-of-type\".");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var isImportRule = function isImportRule(element) {
|
||||
return element.type.charCodeAt(1) === 105 && element.type.charCodeAt(0) === 64;
|
||||
};
|
||||
|
||||
var isPrependedWithRegularRules = function isPrependedWithRegularRules(index, children) {
|
||||
for (var i = index - 1; i >= 0; i--) {
|
||||
if (!isImportRule(children[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}; // use this to remove incorrect elements from further processing
|
||||
// so they don't get handed to the `sheet` (or anything else)
|
||||
// as that could potentially lead to additional logs which in turn could be overhelming to the user
|
||||
|
||||
|
||||
var nullifyElement = function nullifyElement(element) {
|
||||
element.type = '';
|
||||
element.value = '';
|
||||
element["return"] = '';
|
||||
element.children = '';
|
||||
element.props = '';
|
||||
};
|
||||
|
||||
var incorrectImportAlarm = function incorrectImportAlarm(element, index, children) {
|
||||
if (!isImportRule(element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.parent) {
|
||||
console.error("`@import` rules can't be nested inside other rules. Please move it to the top level and put it before regular rules. Keep in mind that they can only be used within global styles.");
|
||||
nullifyElement(element);
|
||||
} else if (isPrependedWithRegularRules(index, children)) {
|
||||
console.error("`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.");
|
||||
nullifyElement(element);
|
||||
}
|
||||
};
|
||||
|
||||
/* eslint-disable no-fallthrough */
|
||||
|
||||
@@ -453,10 +345,6 @@ var defaultStylisPlugins = [prefixer];
|
||||
var createCache = function createCache(options) {
|
||||
var key = options.key;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !key) {
|
||||
throw new Error("You have to configure `key` for your cache. Please make sure it's unique (and not equal to 'css') as it's used for linking styles to your cache.\n" + "If multiple caches share the same key they might \"fight\" for each other's style elements.");
|
||||
}
|
||||
|
||||
if (key === 'css') {
|
||||
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
|
||||
// document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
|
||||
@@ -475,6 +363,7 @@ var createCache = function createCache(options) {
|
||||
if (dataEmotionAttribute.indexOf(' ') === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
document.head.appendChild(node);
|
||||
node.setAttribute('data-s', '');
|
||||
});
|
||||
@@ -482,13 +371,6 @@ var createCache = function createCache(options) {
|
||||
|
||||
var stylisPlugins = options.stylisPlugins || defaultStylisPlugins;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// $FlowFixMe
|
||||
if (/[^a-z-]/.test(key)) {
|
||||
throw new Error("Emotion key must only contain lower case alphabetical characters and - but \"" + key + "\" was passed");
|
||||
}
|
||||
}
|
||||
|
||||
var inserted = {};
|
||||
var container;
|
||||
var nodesToHydrate = [];
|
||||
@@ -498,7 +380,7 @@ var createCache = function createCache(options) {
|
||||
Array.prototype.forEach.call( // this means we will ignore elements which don't have a space in them which
|
||||
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
|
||||
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) {
|
||||
var attrib = node.getAttribute("data-emotion").split(' '); // $FlowFixMe
|
||||
var attrib = node.getAttribute("data-emotion").split(' ');
|
||||
|
||||
for (var i = 1; i < attrib.length; i++) {
|
||||
inserted[attrib[i]] = true;
|
||||
@@ -512,28 +394,9 @@ var createCache = function createCache(options) {
|
||||
|
||||
var omnipresentPlugins = [compat, removeLabel];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
omnipresentPlugins.push(createUnsafeSelectorsAlarm({
|
||||
get compat() {
|
||||
return cache.compat;
|
||||
}
|
||||
|
||||
}), incorrectImportAlarm);
|
||||
}
|
||||
|
||||
{
|
||||
var currentSheet;
|
||||
var finalizingPlugins = [stringify, process.env.NODE_ENV !== 'production' ? function (element) {
|
||||
if (!element.root) {
|
||||
if (element["return"]) {
|
||||
currentSheet.insert(element["return"]);
|
||||
} else if (element.value && element.type !== COMMENT) {
|
||||
// insert empty rule in non-production environments
|
||||
// so @emotion/jest can grab `key` from the (JS)DOM for caches without any rules inserted yet
|
||||
currentSheet.insert(element.value + "{}");
|
||||
}
|
||||
}
|
||||
} : rulesheet(function (rule) {
|
||||
var finalizingPlugins = [stringify, rulesheet(function (rule) {
|
||||
currentSheet.insert(rule);
|
||||
})];
|
||||
var serializer = middleware(omnipresentPlugins.concat(stylisPlugins, finalizingPlugins));
|
||||
@@ -545,14 +408,6 @@ var createCache = function createCache(options) {
|
||||
_insert = function insert(selector, serialized, sheet, shouldCache) {
|
||||
currentSheet = sheet;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && serialized.map !== undefined) {
|
||||
currentSheet = {
|
||||
insert: function insert(rule) {
|
||||
sheet.insert(rule + serialized.map);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
||||
|
||||
if (shouldCache) {
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
import memoize from '@emotion/memoize';
|
||||
|
||||
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
|
||||
// eslint-disable-next-line no-undef
|
||||
var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
|
||||
|
||||
var isPropValid = /* #__PURE__ */memoize(function (prop) {
|
||||
return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
|
||||
|
||||
Generated
Vendored
-262
@@ -1,262 +0,0 @@
|
||||
import * as React from 'react';
|
||||
import { useContext, forwardRef } from 'react';
|
||||
import createCache from '@emotion/cache';
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import weakMemoize from '@emotion/weak-memoize';
|
||||
import hoistNonReactStatics from '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js';
|
||||
import { getRegisteredStyles, registerStyles, insertStyles } from '@emotion/utils';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var isBrowser = "object" !== 'undefined';
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
|
||||
var EmotionCacheContext = /* #__PURE__ */React.createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
|
||||
// because this module is primarily intended for the browser and node
|
||||
// but it's also required in react native and similar environments sometimes
|
||||
// and we could have a special build just for that
|
||||
// but this is much easier and the native packages
|
||||
// might use a different theme context in the future anyway
|
||||
typeof HTMLElement !== 'undefined' ? /* #__PURE__ */createCache({
|
||||
key: 'css'
|
||||
}) : null);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
EmotionCacheContext.displayName = 'EmotionCacheContext';
|
||||
}
|
||||
|
||||
var CacheProvider = EmotionCacheContext.Provider;
|
||||
var __unsafe_useEmotionCache = function useEmotionCache() {
|
||||
return useContext(EmotionCacheContext);
|
||||
};
|
||||
|
||||
var withEmotionCache = function withEmotionCache(func) {
|
||||
// $FlowFixMe
|
||||
return /*#__PURE__*/forwardRef(function (props, ref) {
|
||||
// the cache will never be null in the browser
|
||||
var cache = useContext(EmotionCacheContext);
|
||||
return func(props, cache, ref);
|
||||
});
|
||||
};
|
||||
|
||||
if (!isBrowser) {
|
||||
withEmotionCache = function withEmotionCache(func) {
|
||||
return function (props) {
|
||||
var cache = useContext(EmotionCacheContext);
|
||||
|
||||
if (cache === null) {
|
||||
// yes, we're potentially creating this on every render
|
||||
// it doesn't actually matter though since it's only on the server
|
||||
// so there will only every be a single render
|
||||
// that could change in the future because of suspense and etc. but for now,
|
||||
// this works and i don't want to optimise for a future thing that we aren't sure about
|
||||
cache = createCache({
|
||||
key: 'css'
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(EmotionCacheContext.Provider, {
|
||||
value: cache
|
||||
}, func(props, cache));
|
||||
} else {
|
||||
return func(props, cache);
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var ThemeContext = /* #__PURE__ */React.createContext({});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ThemeContext.displayName = 'EmotionThemeContext';
|
||||
}
|
||||
|
||||
var useTheme = function useTheme() {
|
||||
return React.useContext(ThemeContext);
|
||||
};
|
||||
|
||||
var getTheme = function getTheme(outerTheme, theme) {
|
||||
if (typeof theme === 'function') {
|
||||
var mergedTheme = theme(outerTheme);
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && (mergedTheme == null || typeof mergedTheme !== 'object' || Array.isArray(mergedTheme))) {
|
||||
throw new Error('[ThemeProvider] Please return an object from your theme function, i.e. theme={() => ({})}!');
|
||||
}
|
||||
|
||||
return mergedTheme;
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && (theme == null || typeof theme !== 'object' || Array.isArray(theme))) {
|
||||
throw new Error('[ThemeProvider] Please make your theme prop a plain object');
|
||||
}
|
||||
|
||||
return _extends({}, outerTheme, theme);
|
||||
};
|
||||
|
||||
var createCacheWithTheme = /* #__PURE__ */weakMemoize(function (outerTheme) {
|
||||
return weakMemoize(function (theme) {
|
||||
return getTheme(outerTheme, theme);
|
||||
});
|
||||
});
|
||||
var ThemeProvider = function ThemeProvider(props) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme);
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
||||
value: theme
|
||||
}, props.children);
|
||||
};
|
||||
function withTheme(Component) {
|
||||
var componentName = Component.displayName || Component.name || 'Component';
|
||||
|
||||
var render = function render(props, ref) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
return /*#__PURE__*/React.createElement(Component, _extends({
|
||||
theme: theme,
|
||||
ref: ref
|
||||
}, props));
|
||||
}; // $FlowFixMe
|
||||
|
||||
|
||||
var WithTheme = /*#__PURE__*/React.forwardRef(render);
|
||||
WithTheme.displayName = "WithTheme(" + componentName + ")";
|
||||
return hoistNonReactStatics(WithTheme, Component);
|
||||
}
|
||||
|
||||
var getLastPart = function getLastPart(functionName) {
|
||||
// The match may be something like 'Object.createEmotionProps' or
|
||||
// 'Loader.prototype.render'
|
||||
var parts = functionName.split('.');
|
||||
return parts[parts.length - 1];
|
||||
};
|
||||
|
||||
var getFunctionNameFromStackTraceLine = function getFunctionNameFromStackTraceLine(line) {
|
||||
// V8
|
||||
var match = /^\s+at\s+([A-Za-z0-9$.]+)\s/.exec(line);
|
||||
if (match) return getLastPart(match[1]); // Safari / Firefox
|
||||
|
||||
match = /^([A-Za-z0-9$.]+)@/.exec(line);
|
||||
if (match) return getLastPart(match[1]);
|
||||
return undefined;
|
||||
};
|
||||
|
||||
var internalReactFunctionNames = /* #__PURE__ */new Set(['renderWithHooks', 'processChild', 'finishClassComponent', 'renderToString']); // These identifiers come from error stacks, so they have to be valid JS
|
||||
// identifiers, thus we only need to replace what is a valid character for JS,
|
||||
// but not for CSS.
|
||||
|
||||
var sanitizeIdentifier = function sanitizeIdentifier(identifier) {
|
||||
return identifier.replace(/\$/g, '-');
|
||||
};
|
||||
|
||||
var getLabelFromStackTrace = function getLabelFromStackTrace(stackTrace) {
|
||||
if (!stackTrace) return undefined;
|
||||
var lines = stackTrace.split('\n');
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var functionName = getFunctionNameFromStackTraceLine(lines[i]); // The first line of V8 stack traces is just "Error"
|
||||
|
||||
if (!functionName) continue; // If we reach one of these, we have gone too far and should quit
|
||||
|
||||
if (internalReactFunctionNames.has(functionName)) break; // The component name is the first function in the stack that starts with an
|
||||
// uppercase letter
|
||||
|
||||
if (/^[A-Z]/.test(functionName)) return sanitizeIdentifier(functionName);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
||||
var labelPropName = '__EMOTION_LABEL_PLEASE_DO_NOT_USE__';
|
||||
var createEmotionProps = function createEmotionProps(type, props) {
|
||||
if (process.env.NODE_ENV !== 'production' && typeof props.css === 'string' && // check if there is a css declaration
|
||||
props.css.indexOf(':') !== -1) {
|
||||
throw new Error("Strings are not allowed as css prop values, please wrap it in a css template literal from '@emotion/react' like this: css`" + props.css + "`");
|
||||
}
|
||||
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type; // For performance, only call getLabelFromStackTrace in development and when
|
||||
// the label hasn't already been computed
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !!props.css && (typeof props.css !== 'object' || typeof props.css.name !== 'string' || props.css.name.indexOf('-') === -1)) {
|
||||
var label = getLabelFromStackTrace(new Error().stack);
|
||||
if (label) newProps[labelPropName] = label;
|
||||
}
|
||||
|
||||
return newProps;
|
||||
};
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
isStringTag = _ref.isStringTag;
|
||||
registerStyles(cache, serialized, isStringTag);
|
||||
useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
return insertStyles(cache, serialized, isStringTag);
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
||||
var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
|
||||
// not passing the registered cache to serializeStyles because it would
|
||||
// make certain babel optimisations not possible
|
||||
|
||||
if (typeof cssProp === 'string' && cache.registered[cssProp] !== undefined) {
|
||||
cssProp = cache.registered[cssProp];
|
||||
}
|
||||
|
||||
var WrappedComponent = props[typePropName];
|
||||
var registeredStyles = [cssProp];
|
||||
var className = '';
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
||||
} else if (props.className != null) {
|
||||
className = props.className + " ";
|
||||
}
|
||||
|
||||
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && serialized.name.indexOf('-') === -1) {
|
||||
var labelFromStack = props[labelPropName];
|
||||
|
||||
if (labelFromStack) {
|
||||
serialized = serializeStyles([serialized, 'label:' + labelFromStack + ';']);
|
||||
}
|
||||
}
|
||||
|
||||
className += cache.key + "-" + serialized.name;
|
||||
var newProps = {};
|
||||
|
||||
for (var key in props) {
|
||||
if (hasOwn.call(props, key) && key !== 'css' && key !== typePropName && (process.env.NODE_ENV === 'production' || key !== labelPropName)) {
|
||||
newProps[key] = props[key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.ref = ref;
|
||||
newProps.className = className;
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
isStringTag: typeof WrappedComponent === 'string'
|
||||
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Emotion.displayName = 'EmotionCssPropInternal';
|
||||
}
|
||||
|
||||
var Emotion$1 = Emotion;
|
||||
|
||||
export { CacheProvider as C, Emotion$1 as E, ThemeContext as T, __unsafe_useEmotionCache as _, ThemeProvider as a, withTheme as b, createEmotionProps as c, hasOwn as h, isBrowser as i, useTheme as u, withEmotionCache as w };
|
||||
Generated
Vendored
+156
@@ -0,0 +1,156 @@
|
||||
import * as React from 'react';
|
||||
import { useContext, forwardRef } from 'react';
|
||||
import createCache from '@emotion/cache';
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import weakMemoize from '@emotion/weak-memoize';
|
||||
import hoistNonReactStatics from '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js';
|
||||
import { getRegisteredStyles, registerStyles, insertStyles } from '@emotion/utils';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
|
||||
var isDevelopment = false;
|
||||
|
||||
var EmotionCacheContext = /* #__PURE__ */React.createContext( // we're doing this to avoid preconstruct's dead code elimination in this one case
|
||||
// because this module is primarily intended for the browser and node
|
||||
// but it's also required in react native and similar environments sometimes
|
||||
// and we could have a special build just for that
|
||||
// but this is much easier and the native packages
|
||||
// might use a different theme context in the future anyway
|
||||
typeof HTMLElement !== 'undefined' ? /* #__PURE__ */createCache({
|
||||
key: 'css'
|
||||
}) : null);
|
||||
|
||||
var CacheProvider = EmotionCacheContext.Provider;
|
||||
var __unsafe_useEmotionCache = function useEmotionCache() {
|
||||
return useContext(EmotionCacheContext);
|
||||
};
|
||||
|
||||
var withEmotionCache = function withEmotionCache(func) {
|
||||
return /*#__PURE__*/forwardRef(function (props, ref) {
|
||||
// the cache will never be null in the browser
|
||||
var cache = useContext(EmotionCacheContext);
|
||||
return func(props, cache, ref);
|
||||
});
|
||||
};
|
||||
|
||||
var ThemeContext = /* #__PURE__ */React.createContext({});
|
||||
|
||||
var useTheme = function useTheme() {
|
||||
return React.useContext(ThemeContext);
|
||||
};
|
||||
|
||||
var getTheme = function getTheme(outerTheme, theme) {
|
||||
if (typeof theme === 'function') {
|
||||
var mergedTheme = theme(outerTheme);
|
||||
|
||||
return mergedTheme;
|
||||
}
|
||||
|
||||
return _extends({}, outerTheme, theme);
|
||||
};
|
||||
|
||||
var createCacheWithTheme = /* #__PURE__ */weakMemoize(function (outerTheme) {
|
||||
return weakMemoize(function (theme) {
|
||||
return getTheme(outerTheme, theme);
|
||||
});
|
||||
});
|
||||
var ThemeProvider = function ThemeProvider(props) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
|
||||
if (props.theme !== theme) {
|
||||
theme = createCacheWithTheme(theme)(props.theme);
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
||||
value: theme
|
||||
}, props.children);
|
||||
};
|
||||
function withTheme(Component) {
|
||||
var componentName = Component.displayName || Component.name || 'Component';
|
||||
var WithTheme = /*#__PURE__*/React.forwardRef(function render(props, ref) {
|
||||
var theme = React.useContext(ThemeContext);
|
||||
return /*#__PURE__*/React.createElement(Component, _extends({
|
||||
theme: theme,
|
||||
ref: ref
|
||||
}, props));
|
||||
});
|
||||
WithTheme.displayName = "WithTheme(" + componentName + ")";
|
||||
return hoistNonReactStatics(WithTheme, Component);
|
||||
}
|
||||
|
||||
var hasOwn = {}.hasOwnProperty;
|
||||
|
||||
var typePropName = '__EMOTION_TYPE_PLEASE_DO_NOT_USE__';
|
||||
var createEmotionProps = function createEmotionProps(type, props) {
|
||||
|
||||
var newProps = {};
|
||||
|
||||
for (var _key in props) {
|
||||
if (hasOwn.call(props, _key)) {
|
||||
newProps[_key] = props[_key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps[typePropName] = type; // Runtime labeling is an opt-in feature because:
|
||||
|
||||
return newProps;
|
||||
};
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
isStringTag = _ref.isStringTag;
|
||||
registerStyles(cache, serialized, isStringTag);
|
||||
useInsertionEffectAlwaysWithSyncFallback(function () {
|
||||
return insertStyles(cache, serialized, isStringTag);
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
var Emotion = /* #__PURE__ */withEmotionCache(function (props, cache, ref) {
|
||||
var cssProp = props.css; // so that using `css` from `emotion` and passing the result to the css prop works
|
||||
// not passing the registered cache to serializeStyles because it would
|
||||
// make certain babel optimisations not possible
|
||||
|
||||
if (typeof cssProp === 'string' && cache.registered[cssProp] !== undefined) {
|
||||
cssProp = cache.registered[cssProp];
|
||||
}
|
||||
|
||||
var WrappedComponent = props[typePropName];
|
||||
var registeredStyles = [cssProp];
|
||||
var className = '';
|
||||
|
||||
if (typeof props.className === 'string') {
|
||||
className = getRegisteredStyles(cache.registered, registeredStyles, props.className);
|
||||
} else if (props.className != null) {
|
||||
className = props.className + " ";
|
||||
}
|
||||
|
||||
var serialized = serializeStyles(registeredStyles, undefined, React.useContext(ThemeContext));
|
||||
|
||||
className += cache.key + "-" + serialized.name;
|
||||
var newProps = {};
|
||||
|
||||
for (var _key2 in props) {
|
||||
if (hasOwn.call(props, _key2) && _key2 !== 'css' && _key2 !== typePropName && (!isDevelopment )) {
|
||||
newProps[_key2] = props[_key2];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.className = className;
|
||||
|
||||
if (ref) {
|
||||
newProps.ref = ref;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
isStringTag: typeof WrappedComponent === 'string'
|
||||
}), /*#__PURE__*/React.createElement(WrappedComponent, newProps));
|
||||
});
|
||||
|
||||
var Emotion$1 = Emotion;
|
||||
|
||||
export { CacheProvider as C, Emotion$1 as E, ThemeContext as T, __unsafe_useEmotionCache as _, ThemeProvider as a, withTheme as b, createEmotionProps as c, hasOwn as h, isDevelopment as i, useTheme as u, withEmotionCache as w };
|
||||
+16
-213
@@ -1,5 +1,5 @@
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps, w as withEmotionCache, T as ThemeContext, i as isBrowser$1 } from './emotion-element-43c6fea0.browser.esm.js';
|
||||
export { C as CacheProvider, T as ThemeContext, a as ThemeProvider, _ as __unsafe_useEmotionCache, u as useTheme, w as withEmotionCache, b as withTheme } from './emotion-element-43c6fea0.browser.esm.js';
|
||||
import { h as hasOwn, E as Emotion, c as createEmotionProps, w as withEmotionCache, T as ThemeContext, i as isDevelopment } from './emotion-element-f0de968e.browser.esm.js';
|
||||
export { C as CacheProvider, T as ThemeContext, a as ThemeProvider, _ as __unsafe_useEmotionCache, u as useTheme, w as withEmotionCache, b as withTheme } from './emotion-element-f0de968e.browser.esm.js';
|
||||
import * as React from 'react';
|
||||
import { insertStyles, registerStyles, getRegisteredStyles } from '@emotion/utils';
|
||||
import { useInsertionEffectWithLayoutFallback, useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
@@ -10,143 +10,11 @@ import '@emotion/weak-memoize';
|
||||
import '../_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js';
|
||||
import 'hoist-non-react-statics';
|
||||
|
||||
var pkg = {
|
||||
name: "@emotion/react",
|
||||
version: "11.11.4",
|
||||
main: "dist/emotion-react.cjs.js",
|
||||
module: "dist/emotion-react.esm.js",
|
||||
browser: {
|
||||
"./dist/emotion-react.esm.js": "./dist/emotion-react.browser.esm.js"
|
||||
},
|
||||
exports: {
|
||||
".": {
|
||||
module: {
|
||||
worker: "./dist/emotion-react.worker.esm.js",
|
||||
browser: "./dist/emotion-react.browser.esm.js",
|
||||
"default": "./dist/emotion-react.esm.js"
|
||||
},
|
||||
"import": "./dist/emotion-react.cjs.mjs",
|
||||
"default": "./dist/emotion-react.cjs.js"
|
||||
},
|
||||
"./jsx-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-runtime/dist/emotion-react-jsx-runtime.worker.esm.js",
|
||||
browser: "./jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.mjs",
|
||||
"default": "./jsx-runtime/dist/emotion-react-jsx-runtime.cjs.js"
|
||||
},
|
||||
"./_isolated-hnrs": {
|
||||
module: {
|
||||
worker: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.worker.esm.js",
|
||||
browser: "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.browser.esm.js",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.esm.js"
|
||||
},
|
||||
"import": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.mjs",
|
||||
"default": "./_isolated-hnrs/dist/emotion-react-_isolated-hnrs.cjs.js"
|
||||
},
|
||||
"./jsx-dev-runtime": {
|
||||
module: {
|
||||
worker: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.worker.esm.js",
|
||||
browser: "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.browser.esm.js",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.esm.js"
|
||||
},
|
||||
"import": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.mjs",
|
||||
"default": "./jsx-dev-runtime/dist/emotion-react-jsx-dev-runtime.cjs.js"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
},
|
||||
types: "types/index.d.ts",
|
||||
files: [
|
||||
"src",
|
||||
"dist",
|
||||
"jsx-runtime",
|
||||
"jsx-dev-runtime",
|
||||
"_isolated-hnrs",
|
||||
"types/*.d.ts",
|
||||
"macro.*"
|
||||
],
|
||||
sideEffects: false,
|
||||
author: "Emotion Contributors",
|
||||
license: "MIT",
|
||||
scripts: {
|
||||
"test:typescript": "dtslint types"
|
||||
},
|
||||
dependencies: {
|
||||
"@babel/runtime": "^7.18.3",
|
||||
"@emotion/babel-plugin": "^11.11.0",
|
||||
"@emotion/cache": "^11.11.0",
|
||||
"@emotion/serialize": "^1.1.3",
|
||||
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.1",
|
||||
"@emotion/utils": "^1.2.1",
|
||||
"@emotion/weak-memoize": "^0.3.1",
|
||||
"hoist-non-react-statics": "^3.3.1"
|
||||
},
|
||||
peerDependencies: {
|
||||
react: ">=16.8.0"
|
||||
},
|
||||
peerDependenciesMeta: {
|
||||
"@types/react": {
|
||||
optional: true
|
||||
}
|
||||
},
|
||||
devDependencies: {
|
||||
"@definitelytyped/dtslint": "0.0.112",
|
||||
"@emotion/css": "11.11.2",
|
||||
"@emotion/css-prettifier": "1.1.3",
|
||||
"@emotion/server": "11.11.0",
|
||||
"@emotion/styled": "11.11.0",
|
||||
"html-tag-names": "^1.1.2",
|
||||
react: "16.14.0",
|
||||
"svg-tag-names": "^1.1.1",
|
||||
typescript: "^4.5.5"
|
||||
},
|
||||
repository: "https://github.com/emotion-js/emotion/tree/main/packages/react",
|
||||
publishConfig: {
|
||||
access: "public"
|
||||
},
|
||||
"umd:main": "dist/emotion-react.umd.min.js",
|
||||
preconstruct: {
|
||||
entrypoints: [
|
||||
"./index.js",
|
||||
"./jsx-runtime.js",
|
||||
"./jsx-dev-runtime.js",
|
||||
"./_isolated-hnrs.js"
|
||||
],
|
||||
umdName: "emotionReact",
|
||||
exports: {
|
||||
envConditions: [
|
||||
"browser",
|
||||
"worker"
|
||||
],
|
||||
extra: {
|
||||
"./types/css-prop": "./types/css-prop.d.ts",
|
||||
"./macro": {
|
||||
types: {
|
||||
"import": "./macro.d.mts",
|
||||
"default": "./macro.d.ts"
|
||||
},
|
||||
"default": "./macro.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var jsx = function jsx(type, props) {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
var args = arguments;
|
||||
|
||||
if (props == null || !hasOwn.call(props, 'css')) {
|
||||
// $FlowFixMe
|
||||
return React.createElement.apply(undefined, args);
|
||||
}
|
||||
|
||||
@@ -157,56 +25,24 @@ var jsx = function jsx(type, props) {
|
||||
|
||||
for (var i = 2; i < argsLength; i++) {
|
||||
createElementArgArray[i] = args[i];
|
||||
} // $FlowFixMe
|
||||
|
||||
}
|
||||
|
||||
return React.createElement.apply(null, createElementArgArray);
|
||||
};
|
||||
|
||||
var warnedAboutCssPropForGlobal = false; // maintain place over rerenders.
|
||||
(function (_jsx) {
|
||||
var JSX;
|
||||
|
||||
(function (_JSX) {})(JSX || (JSX = _jsx.JSX || (_jsx.JSX = {})));
|
||||
})(jsx || (jsx = {}));
|
||||
|
||||
// initial render from browser, insertBefore context.sheet.tags[0] or if a style hasn't been inserted there yet, appendChild
|
||||
// initial client-side render from SSR, use place of hydrating tag
|
||||
|
||||
var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
if (process.env.NODE_ENV !== 'production' && !warnedAboutCssPropForGlobal && ( // check for className as well since the user is
|
||||
// probably using the custom createElement which
|
||||
// means it will be turned into a className prop
|
||||
// $FlowFixMe I don't really want to add it to the type since it shouldn't be used
|
||||
props.className || props.css)) {
|
||||
console.error("It looks like you're using the css prop on Global, did you mean to use the styles prop instead?");
|
||||
warnedAboutCssPropForGlobal = true;
|
||||
}
|
||||
|
||||
var styles = props.styles;
|
||||
var serialized = serializeStyles([styles], undefined, React.useContext(ThemeContext));
|
||||
|
||||
if (!isBrowser$1) {
|
||||
var _ref;
|
||||
|
||||
var serializedNames = serialized.name;
|
||||
var serializedStyles = serialized.styles;
|
||||
var next = serialized.next;
|
||||
|
||||
while (next !== undefined) {
|
||||
serializedNames += ' ' + next.name;
|
||||
serializedStyles += next.styles;
|
||||
next = next.next;
|
||||
}
|
||||
|
||||
var shouldCache = cache.compat === true;
|
||||
var rules = cache.insert("", {
|
||||
name: serializedNames,
|
||||
styles: serializedStyles
|
||||
}, cache.sheet, shouldCache);
|
||||
|
||||
if (shouldCache) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement("style", (_ref = {}, _ref["data-emotion"] = cache.key + "-global " + serializedNames, _ref.dangerouslySetInnerHTML = {
|
||||
__html: rules
|
||||
}, _ref.nonce = cache.sheet.nonce, _ref));
|
||||
} // yes, i know these hooks are used conditionally
|
||||
// but it is based on a constant that will never change at runtime
|
||||
// it's effectively like having two implementations and switching them out
|
||||
// so it's not actually breaking anything
|
||||
@@ -222,8 +58,7 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
container: cache.sheet.container,
|
||||
speedy: cache.sheet.isSpeedy
|
||||
});
|
||||
var rehydrating = false; // $FlowFixMe
|
||||
|
||||
var rehydrating = false;
|
||||
var node = document.querySelector("style[data-emotion=\"" + key + " " + serialized.name + "\"]");
|
||||
|
||||
if (cache.sheet.tags.length) {
|
||||
@@ -269,10 +104,6 @@ var Global = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
return null;
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
Global.displayName = 'EmotionGlobal';
|
||||
}
|
||||
|
||||
function css() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
@@ -281,10 +112,9 @@ function css() {
|
||||
return serializeStyles(args);
|
||||
}
|
||||
|
||||
var keyframes = function keyframes() {
|
||||
function keyframes() {
|
||||
var insertable = css.apply(void 0, arguments);
|
||||
var name = "animation-" + insertable.name; // $FlowFixMe
|
||||
|
||||
var name = "animation-" + insertable.name;
|
||||
return {
|
||||
name: name,
|
||||
styles: "@keyframes " + name + "{" + insertable.styles + "}",
|
||||
@@ -293,7 +123,7 @@ var keyframes = function keyframes() {
|
||||
return "_EMO_" + this.name + "_" + this.styles + "_EMO_";
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
var classnames = function classnames(args) {
|
||||
var len = args.length;
|
||||
@@ -314,9 +144,6 @@ var classnames = function classnames(args) {
|
||||
if (Array.isArray(arg)) {
|
||||
toAdd = classnames(arg);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && arg.styles !== undefined && arg.name !== undefined) {
|
||||
console.error('You have passed styles created with `css` from `@emotion/react` package to the `cx`.\n' + '`cx` is meant to compose class names (strings) so you should convert those styles to a class name by passing them to the `css` received from <ClassNames/> component.');
|
||||
}
|
||||
|
||||
toAdd = '';
|
||||
|
||||
@@ -375,7 +202,7 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
var serializedArr = [];
|
||||
|
||||
var css = function css() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
if (hasRendered && isDevelopment) {
|
||||
throw new Error('css can only be used during render');
|
||||
}
|
||||
|
||||
@@ -391,7 +218,7 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
};
|
||||
|
||||
var cx = function cx() {
|
||||
if (hasRendered && process.env.NODE_ENV !== 'production') {
|
||||
if (hasRendered && isDevelopment) {
|
||||
throw new Error('cx can only be used during render');
|
||||
}
|
||||
|
||||
@@ -415,28 +242,4 @@ var ClassNames = /* #__PURE__ */withEmotionCache(function (props, cache) {
|
||||
}), ele);
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ClassNames.displayName = 'EmotionClassNames';
|
||||
}
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var isBrowser = "object" !== 'undefined'; // #1727, #2905 for some reason Jest and Vitest evaluate modules twice if some consuming module gets mocked
|
||||
|
||||
var isTestEnv = typeof jest !== 'undefined' || typeof vi !== 'undefined';
|
||||
|
||||
if (isBrowser && !isTestEnv) {
|
||||
// globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
|
||||
var globalContext = // $FlowIgnore
|
||||
typeof globalThis !== 'undefined' ? globalThis // eslint-disable-line no-undef
|
||||
: isBrowser ? window : global;
|
||||
var globalKey = "__EMOTION_REACT_" + pkg.version.split('.')[0] + "__";
|
||||
|
||||
if (globalContext[globalKey]) {
|
||||
console.warn('You are loading @emotion/react when it is already loaded. Running ' + 'multiple instances may cause problems. This can happen if multiple ' + 'versions are used, or if multiple builds of the same version are ' + 'used.');
|
||||
}
|
||||
|
||||
globalContext[globalKey] = true;
|
||||
}
|
||||
}
|
||||
|
||||
export { ClassNames, Global, jsx as createElement, css, jsx, keyframes };
|
||||
|
||||
-316
@@ -1,316 +0,0 @@
|
||||
import hashString from '@emotion/hash';
|
||||
import unitless from '@emotion/unitless';
|
||||
import memoize from '@emotion/memoize';
|
||||
|
||||
var ILLEGAL_ESCAPE_SEQUENCE_ERROR = "You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences";
|
||||
var UNDEFINED_AS_OBJECT_KEY_ERROR = "You have passed in falsy value as style object's key (can happen when in example you pass unexported component as computed key).";
|
||||
var hyphenateRegex = /[A-Z]|^ms/g;
|
||||
var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
|
||||
|
||||
var isCustomProperty = function isCustomProperty(property) {
|
||||
return property.charCodeAt(1) === 45;
|
||||
};
|
||||
|
||||
var isProcessableValue = function isProcessableValue(value) {
|
||||
return value != null && typeof value !== 'boolean';
|
||||
};
|
||||
|
||||
var processStyleName = /* #__PURE__ */memoize(function (styleName) {
|
||||
return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, '-$&').toLowerCase();
|
||||
});
|
||||
|
||||
var processStyleValue = function processStyleValue(key, value) {
|
||||
switch (key) {
|
||||
case 'animation':
|
||||
case 'animationName':
|
||||
{
|
||||
if (typeof value === 'string') {
|
||||
return value.replace(animationRegex, function (match, p1, p2) {
|
||||
cursor = {
|
||||
name: p1,
|
||||
styles: p2,
|
||||
next: cursor
|
||||
};
|
||||
return p1;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (unitless[key] !== 1 && !isCustomProperty(key) && typeof value === 'number' && value !== 0) {
|
||||
return value + 'px';
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var contentValuePattern = /(var|attr|counters?|url|element|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
|
||||
var contentValues = ['normal', 'none', 'initial', 'inherit', 'unset'];
|
||||
var oldProcessStyleValue = processStyleValue;
|
||||
var msPattern = /^-ms-/;
|
||||
var hyphenPattern = /-(.)/g;
|
||||
var hyphenatedCache = {};
|
||||
|
||||
processStyleValue = function processStyleValue(key, value) {
|
||||
if (key === 'content') {
|
||||
if (typeof value !== 'string' || contentValues.indexOf(value) === -1 && !contentValuePattern.test(value) && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== '"' && value.charAt(0) !== "'")) {
|
||||
throw new Error("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\"" + value + "\"'`");
|
||||
}
|
||||
}
|
||||
|
||||
var processed = oldProcessStyleValue(key, value);
|
||||
|
||||
if (processed !== '' && !isCustomProperty(key) && key.indexOf('-') !== -1 && hyphenatedCache[key] === undefined) {
|
||||
hyphenatedCache[key] = true;
|
||||
console.error("Using kebab-case for css properties in objects is not supported. Did you mean " + key.replace(msPattern, 'ms-').replace(hyphenPattern, function (str, _char) {
|
||||
return _char.toUpperCase();
|
||||
}) + "?");
|
||||
}
|
||||
|
||||
return processed;
|
||||
};
|
||||
}
|
||||
|
||||
var noComponentSelectorMessage = 'Component selectors can only be used in conjunction with ' + '@emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware ' + 'compiler transform.';
|
||||
|
||||
function handleInterpolation(mergedProps, registered, interpolation) {
|
||||
if (interpolation == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (interpolation.__emotion_styles !== undefined) {
|
||||
if (process.env.NODE_ENV !== 'production' && interpolation.toString() === 'NO_COMPONENT_SELECTOR') {
|
||||
throw new Error(noComponentSelectorMessage);
|
||||
}
|
||||
|
||||
return interpolation;
|
||||
}
|
||||
|
||||
switch (typeof interpolation) {
|
||||
case 'boolean':
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
case 'object':
|
||||
{
|
||||
if (interpolation.anim === 1) {
|
||||
cursor = {
|
||||
name: interpolation.name,
|
||||
styles: interpolation.styles,
|
||||
next: cursor
|
||||
};
|
||||
return interpolation.name;
|
||||
}
|
||||
|
||||
if (interpolation.styles !== undefined) {
|
||||
var next = interpolation.next;
|
||||
|
||||
if (next !== undefined) {
|
||||
// not the most efficient thing ever but this is a pretty rare case
|
||||
// and there will be very few iterations of this generally
|
||||
while (next !== undefined) {
|
||||
cursor = {
|
||||
name: next.name,
|
||||
styles: next.styles,
|
||||
next: cursor
|
||||
};
|
||||
next = next.next;
|
||||
}
|
||||
}
|
||||
|
||||
var styles = interpolation.styles + ";";
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && interpolation.map !== undefined) {
|
||||
styles += interpolation.map;
|
||||
}
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
return createStringFromObject(mergedProps, registered, interpolation);
|
||||
}
|
||||
|
||||
case 'function':
|
||||
{
|
||||
if (mergedProps !== undefined) {
|
||||
var previousCursor = cursor;
|
||||
var result = interpolation(mergedProps);
|
||||
cursor = previousCursor;
|
||||
return handleInterpolation(mergedProps, registered, result);
|
||||
} else if (process.env.NODE_ENV !== 'production') {
|
||||
console.error('Functions that are interpolated in css calls will be stringified.\n' + 'If you want to have a css call based on props, create a function that returns a css call like this\n' + 'let dynamicStyle = (props) => css`color: ${props.color}`\n' + 'It can be called directly with props or interpolated in a styled call like this\n' + "let SomeComponent = styled('div')`${dynamicStyle}`");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 'string':
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var matched = [];
|
||||
var replaced = interpolation.replace(animationRegex, function (match, p1, p2) {
|
||||
var fakeVarName = "animation" + matched.length;
|
||||
matched.push("const " + fakeVarName + " = keyframes`" + p2.replace(/^@keyframes animation-\w+/, '') + "`");
|
||||
return "${" + fakeVarName + "}";
|
||||
});
|
||||
|
||||
if (matched.length) {
|
||||
console.error('`keyframes` output got interpolated into plain string, please wrap it with `css`.\n\n' + 'Instead of doing this:\n\n' + [].concat(matched, ["`" + replaced + "`"]).join('\n') + '\n\nYou should wrap it with `css` like this:\n\n' + ("css`" + replaced + "`"));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
} // finalize string values (regular strings and functions interpolated into css calls)
|
||||
|
||||
|
||||
if (registered == null) {
|
||||
return interpolation;
|
||||
}
|
||||
|
||||
var cached = registered[interpolation];
|
||||
return cached !== undefined ? cached : interpolation;
|
||||
}
|
||||
|
||||
function createStringFromObject(mergedProps, registered, obj) {
|
||||
var string = '';
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
|
||||
}
|
||||
} else {
|
||||
for (var _key in obj) {
|
||||
var value = obj[_key];
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
if (registered != null && registered[value] !== undefined) {
|
||||
string += _key + "{" + registered[value] + "}";
|
||||
} else if (isProcessableValue(value)) {
|
||||
string += processStyleName(_key) + ":" + processStyleValue(_key, value) + ";";
|
||||
}
|
||||
} else {
|
||||
if (_key === 'NO_COMPONENT_SELECTOR' && process.env.NODE_ENV !== 'production') {
|
||||
throw new Error(noComponentSelectorMessage);
|
||||
}
|
||||
|
||||
if (Array.isArray(value) && typeof value[0] === 'string' && (registered == null || registered[value[0]] === undefined)) {
|
||||
for (var _i = 0; _i < value.length; _i++) {
|
||||
if (isProcessableValue(value[_i])) {
|
||||
string += processStyleName(_key) + ":" + processStyleValue(_key, value[_i]) + ";";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var interpolated = handleInterpolation(mergedProps, registered, value);
|
||||
|
||||
switch (_key) {
|
||||
case 'animation':
|
||||
case 'animationName':
|
||||
{
|
||||
string += processStyleName(_key) + ":" + interpolated + ";";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if (process.env.NODE_ENV !== 'production' && _key === 'undefined') {
|
||||
console.error(UNDEFINED_AS_OBJECT_KEY_ERROR);
|
||||
}
|
||||
|
||||
string += _key + "{" + interpolated + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
var labelPattern = /label:\s*([^\s;\n{]+)\s*(;|$)/g;
|
||||
var sourceMapPattern;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
sourceMapPattern = /\/\*#\ssourceMappingURL=data:application\/json;\S+\s+\*\//g;
|
||||
} // this is the cursor for keyframes
|
||||
// keyframes are stored on the SerializedStyles object as a linked list
|
||||
|
||||
|
||||
var cursor;
|
||||
var serializeStyles = function serializeStyles(args, registered, mergedProps) {
|
||||
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
var stringMode = true;
|
||||
var styles = '';
|
||||
cursor = undefined;
|
||||
var strings = args[0];
|
||||
|
||||
if (strings == null || strings.raw === undefined) {
|
||||
stringMode = false;
|
||||
styles += handleInterpolation(mergedProps, registered, strings);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && strings[0] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);
|
||||
}
|
||||
|
||||
styles += strings[0];
|
||||
} // we start at 1 since we've already handled the first arg
|
||||
|
||||
|
||||
for (var i = 1; i < args.length; i++) {
|
||||
styles += handleInterpolation(mergedProps, registered, args[i]);
|
||||
|
||||
if (stringMode) {
|
||||
if (process.env.NODE_ENV !== 'production' && strings[i] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);
|
||||
}
|
||||
|
||||
styles += strings[i];
|
||||
}
|
||||
}
|
||||
|
||||
var sourceMap;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
styles = styles.replace(sourceMapPattern, function (match) {
|
||||
sourceMap = match;
|
||||
return '';
|
||||
});
|
||||
} // using a global regex with .exec is stateful so lastIndex has to be reset each time
|
||||
|
||||
|
||||
labelPattern.lastIndex = 0;
|
||||
var identifierName = '';
|
||||
var match; // https://esbench.com/bench/5b809c2cf2949800a0f61fb5
|
||||
|
||||
while ((match = labelPattern.exec(styles)) !== null) {
|
||||
identifierName += '-' + // $FlowFixMe we know it's not null
|
||||
match[1];
|
||||
}
|
||||
|
||||
var name = hashString(styles) + identifierName;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// $FlowFixMe SerializedStyles type doesn't have toString property (and we don't want to add it)
|
||||
return {
|
||||
name: name,
|
||||
styles: styles,
|
||||
map: sourceMap,
|
||||
next: cursor,
|
||||
toString: function toString() {
|
||||
return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop).";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
name: name,
|
||||
styles: styles,
|
||||
next: cursor
|
||||
};
|
||||
};
|
||||
|
||||
export { serializeStyles };
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
import hashString from '@emotion/hash';
|
||||
import unitless from '@emotion/unitless';
|
||||
import memoize from '@emotion/memoize';
|
||||
|
||||
var isDevelopment = false;
|
||||
|
||||
var hyphenateRegex = /[A-Z]|^ms/g;
|
||||
var animationRegex = /_EMO_([^_]+?)_([^]*?)_EMO_/g;
|
||||
|
||||
var isCustomProperty = function isCustomProperty(property) {
|
||||
return property.charCodeAt(1) === 45;
|
||||
};
|
||||
|
||||
var isProcessableValue = function isProcessableValue(value) {
|
||||
return value != null && typeof value !== 'boolean';
|
||||
};
|
||||
|
||||
var processStyleName = /* #__PURE__ */memoize(function (styleName) {
|
||||
return isCustomProperty(styleName) ? styleName : styleName.replace(hyphenateRegex, '-$&').toLowerCase();
|
||||
});
|
||||
|
||||
var processStyleValue = function processStyleValue(key, value) {
|
||||
switch (key) {
|
||||
case 'animation':
|
||||
case 'animationName':
|
||||
{
|
||||
if (typeof value === 'string') {
|
||||
return value.replace(animationRegex, function (match, p1, p2) {
|
||||
cursor = {
|
||||
name: p1,
|
||||
styles: p2,
|
||||
next: cursor
|
||||
};
|
||||
return p1;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (unitless[key] !== 1 && !isCustomProperty(key) && typeof value === 'number' && value !== 0) {
|
||||
return value + 'px';
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
var noComponentSelectorMessage = 'Component selectors can only be used in conjunction with ' + '@emotion/babel-plugin, the swc Emotion plugin, or another Emotion-aware ' + 'compiler transform.';
|
||||
|
||||
function handleInterpolation(mergedProps, registered, interpolation) {
|
||||
if (interpolation == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
var componentSelector = interpolation;
|
||||
|
||||
if (componentSelector.__emotion_styles !== undefined) {
|
||||
|
||||
return componentSelector;
|
||||
}
|
||||
|
||||
switch (typeof interpolation) {
|
||||
case 'boolean':
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
case 'object':
|
||||
{
|
||||
var keyframes = interpolation;
|
||||
|
||||
if (keyframes.anim === 1) {
|
||||
cursor = {
|
||||
name: keyframes.name,
|
||||
styles: keyframes.styles,
|
||||
next: cursor
|
||||
};
|
||||
return keyframes.name;
|
||||
}
|
||||
|
||||
var serializedStyles = interpolation;
|
||||
|
||||
if (serializedStyles.styles !== undefined) {
|
||||
var next = serializedStyles.next;
|
||||
|
||||
if (next !== undefined) {
|
||||
// not the most efficient thing ever but this is a pretty rare case
|
||||
// and there will be very few iterations of this generally
|
||||
while (next !== undefined) {
|
||||
cursor = {
|
||||
name: next.name,
|
||||
styles: next.styles,
|
||||
next: cursor
|
||||
};
|
||||
next = next.next;
|
||||
}
|
||||
}
|
||||
|
||||
var styles = serializedStyles.styles + ";";
|
||||
return styles;
|
||||
}
|
||||
|
||||
return createStringFromObject(mergedProps, registered, interpolation);
|
||||
}
|
||||
|
||||
case 'function':
|
||||
{
|
||||
if (mergedProps !== undefined) {
|
||||
var previousCursor = cursor;
|
||||
var result = interpolation(mergedProps);
|
||||
cursor = previousCursor;
|
||||
return handleInterpolation(mergedProps, registered, result);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
} // finalize string values (regular strings and functions interpolated into css calls)
|
||||
|
||||
|
||||
var asString = interpolation;
|
||||
|
||||
if (registered == null) {
|
||||
return asString;
|
||||
}
|
||||
|
||||
var cached = registered[asString];
|
||||
return cached !== undefined ? cached : asString;
|
||||
}
|
||||
|
||||
function createStringFromObject(mergedProps, registered, obj) {
|
||||
var string = '';
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
string += handleInterpolation(mergedProps, registered, obj[i]) + ";";
|
||||
}
|
||||
} else {
|
||||
for (var key in obj) {
|
||||
var value = obj[key];
|
||||
|
||||
if (typeof value !== 'object') {
|
||||
var asString = value;
|
||||
|
||||
if (registered != null && registered[asString] !== undefined) {
|
||||
string += key + "{" + registered[asString] + "}";
|
||||
} else if (isProcessableValue(asString)) {
|
||||
string += processStyleName(key) + ":" + processStyleValue(key, asString) + ";";
|
||||
}
|
||||
} else {
|
||||
if (key === 'NO_COMPONENT_SELECTOR' && isDevelopment) {
|
||||
throw new Error(noComponentSelectorMessage);
|
||||
}
|
||||
|
||||
if (Array.isArray(value) && typeof value[0] === 'string' && (registered == null || registered[value[0]] === undefined)) {
|
||||
for (var _i = 0; _i < value.length; _i++) {
|
||||
if (isProcessableValue(value[_i])) {
|
||||
string += processStyleName(key) + ":" + processStyleValue(key, value[_i]) + ";";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var interpolated = handleInterpolation(mergedProps, registered, value);
|
||||
|
||||
switch (key) {
|
||||
case 'animation':
|
||||
case 'animationName':
|
||||
{
|
||||
string += processStyleName(key) + ":" + interpolated + ";";
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
|
||||
string += key + "{" + interpolated + "}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
var labelPattern = /label:\s*([^\s;{]+)\s*(;|$)/g; // this is the cursor for keyframes
|
||||
// keyframes are stored on the SerializedStyles object as a linked list
|
||||
|
||||
var cursor;
|
||||
function serializeStyles(args, registered, mergedProps) {
|
||||
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null && args[0].styles !== undefined) {
|
||||
return args[0];
|
||||
}
|
||||
|
||||
var stringMode = true;
|
||||
var styles = '';
|
||||
cursor = undefined;
|
||||
var strings = args[0];
|
||||
|
||||
if (strings == null || strings.raw === undefined) {
|
||||
stringMode = false;
|
||||
styles += handleInterpolation(mergedProps, registered, strings);
|
||||
} else {
|
||||
var asTemplateStringsArr = strings;
|
||||
|
||||
styles += asTemplateStringsArr[0];
|
||||
} // we start at 1 since we've already handled the first arg
|
||||
|
||||
|
||||
for (var i = 1; i < args.length; i++) {
|
||||
styles += handleInterpolation(mergedProps, registered, args[i]);
|
||||
|
||||
if (stringMode) {
|
||||
var templateStringsArr = strings;
|
||||
|
||||
styles += templateStringsArr[i];
|
||||
}
|
||||
} // using a global regex with .exec is stateful so lastIndex has to be reset each time
|
||||
|
||||
|
||||
labelPattern.lastIndex = 0;
|
||||
var identifierName = '';
|
||||
var match; // https://esbench.com/bench/5b809c2cf2949800a0f61fb5
|
||||
|
||||
while ((match = labelPattern.exec(styles)) !== null) {
|
||||
identifierName += '-' + match[1];
|
||||
}
|
||||
|
||||
var name = hashString(styles) + identifierName;
|
||||
|
||||
return {
|
||||
name: name,
|
||||
styles: styles,
|
||||
next: cursor
|
||||
};
|
||||
}
|
||||
|
||||
export { serializeStyles };
|
||||
Generated
Vendored
+12
-26
@@ -1,3 +1,5 @@
|
||||
var isDevelopment = false;
|
||||
|
||||
/*
|
||||
|
||||
Based off glamor's StyleSheet, thanks Sunil ❤️
|
||||
@@ -20,10 +22,9 @@ styleSheet.flush()
|
||||
- empties the stylesheet of all its contents
|
||||
|
||||
*/
|
||||
// $FlowFixMe
|
||||
|
||||
function sheetForTag(tag) {
|
||||
if (tag.sheet) {
|
||||
// $FlowFixMe
|
||||
return tag.sheet;
|
||||
} // this weirdness brought to you by firefox
|
||||
|
||||
@@ -32,10 +33,13 @@ function sheetForTag(tag) {
|
||||
|
||||
for (var i = 0; i < document.styleSheets.length; i++) {
|
||||
if (document.styleSheets[i].ownerNode === tag) {
|
||||
// $FlowFixMe
|
||||
return document.styleSheets[i];
|
||||
}
|
||||
}
|
||||
} // this function should always return with a value
|
||||
// TS can't understand it though so we make it stop complaining here
|
||||
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function createStyleElement(options) {
|
||||
@@ -76,7 +80,7 @@ var StyleSheet = /*#__PURE__*/function () {
|
||||
_this.tags.push(tag);
|
||||
};
|
||||
|
||||
this.isSpeedy = options.speedy === undefined ? process.env.NODE_ENV === 'production' : options.speedy;
|
||||
this.isSpeedy = options.speedy === undefined ? !isDevelopment : options.speedy;
|
||||
this.tags = [];
|
||||
this.ctr = 0;
|
||||
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
|
||||
@@ -104,18 +108,6 @@ var StyleSheet = /*#__PURE__*/function () {
|
||||
|
||||
var tag = this.tags[this.tags.length - 1];
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var isImportRule = rule.charCodeAt(0) === 64 && rule.charCodeAt(1) === 105;
|
||||
|
||||
if (isImportRule && this._alreadyInsertedOrderInsensitiveRule) {
|
||||
// this would only cause problem in speedy mode
|
||||
// but we don't want enabling speedy to affect the observable behavior
|
||||
// so we report this error at all times
|
||||
console.error("You're attempting to insert the following rule:\n" + rule + '\n\n`@import` rules must be before all other types of rules in a stylesheet but other rules have already been inserted. Please ensure that `@import` rules are before all other rules.');
|
||||
}
|
||||
this._alreadyInsertedOrderInsensitiveRule = this._alreadyInsertedOrderInsensitiveRule || !isImportRule;
|
||||
}
|
||||
|
||||
if (this.isSpeedy) {
|
||||
var sheet = sheetForTag(tag);
|
||||
|
||||
@@ -124,9 +116,6 @@ var StyleSheet = /*#__PURE__*/function () {
|
||||
// the big drawback is that the css won't be editable in devtools
|
||||
sheet.insertRule(rule, sheet.cssRules.length);
|
||||
} catch (e) {
|
||||
if (process.env.NODE_ENV !== 'production' && !/:(-moz-placeholder|-moz-focus-inner|-moz-focusring|-ms-input-placeholder|-moz-read-write|-moz-read-only|-ms-clear|-ms-expand|-ms-reveal){/.test(rule)) {
|
||||
console.error("There was a problem inserting the following rule: \"" + rule + "\"", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tag.appendChild(document.createTextNode(rule));
|
||||
@@ -136,16 +125,13 @@ var StyleSheet = /*#__PURE__*/function () {
|
||||
};
|
||||
|
||||
_proto.flush = function flush() {
|
||||
// $FlowFixMe
|
||||
this.tags.forEach(function (tag) {
|
||||
return tag.parentNode && tag.parentNode.removeChild(tag);
|
||||
var _tag$parentNode;
|
||||
|
||||
return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag);
|
||||
});
|
||||
this.tags = [];
|
||||
this.ctr = 0;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
this._alreadyInsertedOrderInsensitiveRule = false;
|
||||
}
|
||||
};
|
||||
|
||||
return StyleSheet;
|
||||
Generated
Vendored
+22
-28
@@ -1,10 +1,12 @@
|
||||
import _extends from '@babel/runtime/helpers/esm/extends';
|
||||
import * as React from 'react';
|
||||
import isPropValid from '@emotion/is-prop-valid';
|
||||
import { withEmotionCache, ThemeContext } from '@emotion/react';
|
||||
import { getRegisteredStyles, registerStyles, insertStyles } from '@emotion/utils';
|
||||
import { serializeStyles } from '@emotion/serialize';
|
||||
import { useInsertionEffectAlwaysWithSyncFallback } from '@emotion/use-insertion-effect-with-fallbacks';
|
||||
import { getRegisteredStyles, registerStyles, insertStyles } from '@emotion/utils';
|
||||
import * as React from 'react';
|
||||
import isPropValid from '@emotion/is-prop-valid';
|
||||
|
||||
var isDevelopment = false;
|
||||
|
||||
var testOmitPropsOnStringTag = isPropValid;
|
||||
|
||||
@@ -35,8 +37,6 @@ var composeShouldForwardProps = function composeShouldForwardProps(tag, options,
|
||||
return shouldForwardProp;
|
||||
};
|
||||
|
||||
var ILLEGAL_ESCAPE_SEQUENCE_ERROR = "You have illegal escape sequence in your template literal, most likely inside content's property value.\nBecause you write your CSS inside a JavaScript string you actually have to do double escaping, so for example \"content: '\\00d7';\" should become \"content: '\\\\00d7';\".\nYou can read more about this here:\nhttps://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences";
|
||||
|
||||
var Insertion = function Insertion(_ref) {
|
||||
var cache = _ref.cache,
|
||||
serialized = _ref.serialized,
|
||||
@@ -50,11 +50,6 @@ var Insertion = function Insertion(_ref) {
|
||||
};
|
||||
|
||||
var createStyled = function createStyled(tag, options) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (tag === undefined) {
|
||||
throw new Error('You are trying to create a styled element with an undefined component.\nYou may have forgotten to import it.');
|
||||
}
|
||||
}
|
||||
|
||||
var isReal = tag.__emotion_real === tag;
|
||||
var baseTag = isReal && tag.__emotion_base || tag;
|
||||
@@ -70,6 +65,7 @@ var createStyled = function createStyled(tag, options) {
|
||||
var defaultShouldForwardProp = shouldForwardProp || getDefaultShouldForwardProp(baseTag);
|
||||
var shouldUseAs = !defaultShouldForwardProp('as');
|
||||
return function () {
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
var args = arguments;
|
||||
var styles = isReal && tag.__emotion_styles !== undefined ? tag.__emotion_styles.slice(0) : [];
|
||||
|
||||
@@ -78,25 +74,20 @@ var createStyled = function createStyled(tag, options) {
|
||||
}
|
||||
|
||||
if (args[0] == null || args[0].raw === undefined) {
|
||||
// eslint-disable-next-line prefer-spread
|
||||
styles.push.apply(styles, args);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production' && args[0][0] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);
|
||||
}
|
||||
var templateStringsArr = args[0];
|
||||
|
||||
styles.push(args[0][0]);
|
||||
styles.push(templateStringsArr[0]);
|
||||
var len = args.length;
|
||||
var i = 1;
|
||||
|
||||
for (; i < len; i++) {
|
||||
if (process.env.NODE_ENV !== 'production' && args[0][i] === undefined) {
|
||||
console.error(ILLEGAL_ESCAPE_SEQUENCE_ERROR);
|
||||
}
|
||||
|
||||
styles.push(args[i], args[0][i]);
|
||||
styles.push(args[i], templateStringsArr[i]);
|
||||
}
|
||||
} // $FlowFixMe: we need to cast StatelessFunctionalComponent to our PrivateStyledComponent class
|
||||
|
||||
}
|
||||
|
||||
var Styled = withEmotionCache(function (props, cache, ref) {
|
||||
var FinalTag = shouldUseAs && props.as || baseTag;
|
||||
@@ -133,14 +124,17 @@ var createStyled = function createStyled(tag, options) {
|
||||
for (var _key in props) {
|
||||
if (shouldUseAs && _key === 'as') continue;
|
||||
|
||||
if ( // $FlowFixMe
|
||||
finalShouldForwardProp(_key)) {
|
||||
if (finalShouldForwardProp(_key)) {
|
||||
newProps[_key] = props[_key];
|
||||
}
|
||||
}
|
||||
|
||||
newProps.className = className;
|
||||
newProps.ref = ref;
|
||||
|
||||
if (ref) {
|
||||
newProps.ref = ref;
|
||||
}
|
||||
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Insertion, {
|
||||
cache: cache,
|
||||
serialized: serialized,
|
||||
@@ -155,19 +149,19 @@ var createStyled = function createStyled(tag, options) {
|
||||
Styled.__emotion_forwardProp = shouldForwardProp;
|
||||
Object.defineProperty(Styled, 'toString', {
|
||||
value: function value() {
|
||||
if (targetClassName === undefined && process.env.NODE_ENV !== 'production') {
|
||||
if (targetClassName === undefined && isDevelopment) {
|
||||
return 'NO_COMPONENT_SELECTOR';
|
||||
} // $FlowFixMe: coerce undefined to string
|
||||
|
||||
}
|
||||
|
||||
return "." + targetClassName;
|
||||
}
|
||||
});
|
||||
|
||||
Styled.withComponent = function (nextTag, nextOptions) {
|
||||
return createStyled(nextTag, _extends({}, options, nextOptions, {
|
||||
var newStyled = createStyled(nextTag, _extends({}, options, nextOptions, {
|
||||
shouldForwardProp: composeShouldForwardProps(Styled, nextOptions, true)
|
||||
})).apply(void 0, styles);
|
||||
}));
|
||||
return newStyled.apply(void 0, styles);
|
||||
};
|
||||
|
||||
return Styled;
|
||||
|
||||
+7
-7
@@ -1,19 +1,19 @@
|
||||
import createStyled from '../base/dist/emotion-styled-base.browser.esm.js';
|
||||
import '@babel/runtime/helpers/extends';
|
||||
import 'react';
|
||||
import '@emotion/is-prop-valid';
|
||||
import '@emotion/react';
|
||||
import '@emotion/utils';
|
||||
import '@emotion/serialize';
|
||||
import '@emotion/use-insertion-effect-with-fallbacks';
|
||||
import '@emotion/utils';
|
||||
import 'react';
|
||||
import '@emotion/is-prop-valid';
|
||||
|
||||
var tags = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
|
||||
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
||||
|
||||
var newStyled = createStyled.bind();
|
||||
// bind it to avoid mutating the original function
|
||||
var styled = createStyled.bind(null);
|
||||
tags.forEach(function (tagName) {
|
||||
// $FlowFixMe: we can ignore this because its exposed type is defined by the CreateStyled type
|
||||
newStyled[tagName] = newStyled(tagName);
|
||||
styled[tagName] = styled(tagName);
|
||||
});
|
||||
|
||||
export { newStyled as default };
|
||||
export { styled as default };
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ var unitlessKeys = {
|
||||
opacity: 1,
|
||||
order: 1,
|
||||
orphans: 1,
|
||||
scale: 1,
|
||||
tabSize: 1,
|
||||
widows: 1,
|
||||
zIndex: 1,
|
||||
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
var isBrowser = "object" !== 'undefined';
|
||||
var isBrowser = true;
|
||||
|
||||
function getRegisteredStyles(registered, registeredStyles, classNames) {
|
||||
var rawClassName = '';
|
||||
classNames.split(' ').forEach(function (className) {
|
||||
if (registered[className] !== undefined) {
|
||||
registeredStyles.push(registered[className] + ";");
|
||||
} else {
|
||||
} else if (className) {
|
||||
rawClassName += className + " ";
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
var weakMemoize = function weakMemoize(func) {
|
||||
// $FlowFixMe flow doesn't include all non-primitive types as allowed for weakmaps
|
||||
var cache = new WeakMap();
|
||||
return function (arg) {
|
||||
if (cache.has(arg)) {
|
||||
// $FlowFixMe
|
||||
// Use non-null assertion because we just checked that the cache `has` it
|
||||
// This allows us to remove `undefined` from the return value
|
||||
return cache.get(arg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user