styled-components 4.1.4-alpha.3 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/styled-components-macro.cjs.js +41 -29
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components-macro.esm.js +41 -29
- package/dist/styled-components-macro.esm.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +41 -29
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +36 -26
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +41 -29
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +36 -26
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +40 -28
- package/dist/styled-components.js.map +1 -1
- package/dist/styled-components.min.js +1 -1
- package/dist/styled-components.min.js.map +1 -1
- package/native/dist/styled-components.native.cjs.js +16 -19
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +16 -19
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/package.json +2 -2
- package/primitives/dist/styled-components-primitives.cjs.js +16 -19
- package/primitives/dist/styled-components-primitives.cjs.js.map +1 -1
- package/primitives/dist/styled-components-primitives.esm.js +16 -19
- package/primitives/dist/styled-components-primitives.esm.js.map +1 -1
- package/test-utils/setupTestFramework.js +6 -1
|
@@ -131,6 +131,11 @@ function getComponentName(target) {
|
|
|
131
131
|
return (process.env.NODE_ENV !== 'production' ? typeof target === 'string' && target : false) || target.displayName || target.name || 'Component';
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
//
|
|
135
|
+
function isStatelessFunction(test) {
|
|
136
|
+
return typeof test === 'function' && !(test.prototype && test.prototype.isReactComponent);
|
|
137
|
+
}
|
|
138
|
+
|
|
134
139
|
//
|
|
135
140
|
function isStyledComponent(target) {
|
|
136
141
|
return target && typeof target.styledComponentId === 'string';
|
|
@@ -207,7 +212,7 @@ var StyledComponentsError = function (_Error) {
|
|
|
207
212
|
}
|
|
208
213
|
|
|
209
214
|
if (process.env.NODE_ENV === 'production') {
|
|
210
|
-
var _this = possibleConstructorReturn(this, _Error.call(this, 'An error occurred. See https://github.com/styled-components/styled-components/blob/master/src/utils/errors.md#' + code + ' for more information. ' + (interpolations ? 'Additional arguments: ' + interpolations.join(', ') : '')));
|
|
215
|
+
var _this = possibleConstructorReturn(this, _Error.call(this, 'An error occurred. See https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/utils/errors.md#' + code + ' for more information. ' + (interpolations ? 'Additional arguments: ' + interpolations.join(', ') : '')));
|
|
211
216
|
} else {
|
|
212
217
|
var _this = possibleConstructorReturn(this, _Error.call(this, format.apply(undefined, [ERRORS[code]].concat(interpolations)).trim()));
|
|
213
218
|
}
|
|
@@ -464,7 +469,7 @@ var addUpUntilIndex = function addUpUntilIndex(sizes, index) {
|
|
|
464
469
|
var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
465
470
|
var el = document.createElement('style');
|
|
466
471
|
el.setAttribute(SC_ATTR, '');
|
|
467
|
-
el.setAttribute(SC_VERSION_ATTR, "4.
|
|
472
|
+
el.setAttribute(SC_VERSION_ATTR, "4.2.0");
|
|
468
473
|
|
|
469
474
|
var nonce = getNonce();
|
|
470
475
|
if (nonce) {
|
|
@@ -493,7 +498,7 @@ var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
|
493
498
|
var wrapAsHtmlTag = function wrapAsHtmlTag(css, names) {
|
|
494
499
|
return function (additionalAttrs) {
|
|
495
500
|
var nonce = getNonce();
|
|
496
|
-
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.
|
|
501
|
+
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.2.0" + '"', additionalAttrs];
|
|
497
502
|
|
|
498
503
|
var htmlAttr = attrs.filter(Boolean).join(' ');
|
|
499
504
|
return '<style ' + htmlAttr + '>' + css() + '</style>';
|
|
@@ -505,7 +510,7 @@ var wrapAsElement = function wrapAsElement(css, names) {
|
|
|
505
510
|
return function () {
|
|
506
511
|
var _props;
|
|
507
512
|
|
|
508
|
-
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.
|
|
513
|
+
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.2.0", _props);
|
|
509
514
|
|
|
510
515
|
var nonce = getNonce();
|
|
511
516
|
if (nonce) {
|
|
@@ -912,7 +917,7 @@ var StyleSheet = function () {
|
|
|
912
917
|
var isStreamed = false;
|
|
913
918
|
|
|
914
919
|
/* retrieve all of our SSR style elements from the DOM */
|
|
915
|
-
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.
|
|
920
|
+
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.2.0" + '"]');
|
|
916
921
|
|
|
917
922
|
var nodesSize = nodes.length;
|
|
918
923
|
|
|
@@ -1286,23 +1291,15 @@ function flatten(chunk, executionContext, styleSheet) {
|
|
|
1286
1291
|
|
|
1287
1292
|
/* Either execute or defer the function */
|
|
1288
1293
|
if (isFunction(chunk)) {
|
|
1289
|
-
if (executionContext) {
|
|
1290
|
-
var
|
|
1291
|
-
|
|
1292
|
-
try {
|
|
1293
|
-
// eslint-disable-next-line new-cap
|
|
1294
|
-
if (reactIs.isElement(new chunk(executionContext))) {
|
|
1295
|
-
shouldThrow = true;
|
|
1296
|
-
}
|
|
1297
|
-
} catch (e) {
|
|
1298
|
-
/* */
|
|
1299
|
-
}
|
|
1294
|
+
if (isStatelessFunction(chunk) && executionContext) {
|
|
1295
|
+
var _result = chunk(executionContext);
|
|
1300
1296
|
|
|
1301
|
-
if (
|
|
1302
|
-
|
|
1297
|
+
if (process.env.NODE_ENV !== 'production' && reactIs.isElement(_result)) {
|
|
1298
|
+
// eslint-disable-next-line no-console
|
|
1299
|
+
console.warn(getComponentName(chunk) + ' is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.');
|
|
1303
1300
|
}
|
|
1304
1301
|
|
|
1305
|
-
return flatten(
|
|
1302
|
+
return flatten(_result, executionContext, styleSheet);
|
|
1306
1303
|
} else return chunk;
|
|
1307
1304
|
}
|
|
1308
1305
|
|
|
@@ -1752,6 +1749,8 @@ var ThemeProvider = function (_Component) {
|
|
|
1752
1749
|
|
|
1753
1750
|
//
|
|
1754
1751
|
|
|
1752
|
+
var CLOSING_TAG_R = /^\s*<\/[a-z]/i;
|
|
1753
|
+
|
|
1755
1754
|
var ServerStyleSheet = function () {
|
|
1756
1755
|
function ServerStyleSheet() {
|
|
1757
1756
|
classCallCheck(this, ServerStyleSheet);
|
|
@@ -1828,8 +1827,15 @@ var ServerStyleSheet = function () {
|
|
|
1828
1827
|
/* force our StyleSheets to emit entirely new tags */
|
|
1829
1828
|
instance.sealAllTags();
|
|
1830
1829
|
|
|
1831
|
-
|
|
1832
|
-
|
|
1830
|
+
var renderedHtml = chunk.toString();
|
|
1831
|
+
|
|
1832
|
+
/* prepend style html to chunk, unless the start of the chunk is a closing tag in which case append right after that */
|
|
1833
|
+
if (CLOSING_TAG_R.test(renderedHtml)) {
|
|
1834
|
+
var endOfClosingTag = renderedHtml.indexOf('>');
|
|
1835
|
+
|
|
1836
|
+
this.push(renderedHtml.slice(0, endOfClosingTag + 1) + html + renderedHtml.slice(endOfClosingTag + 1));
|
|
1837
|
+
} else this.push(html + renderedHtml);
|
|
1838
|
+
|
|
1833
1839
|
callback();
|
|
1834
1840
|
}
|
|
1835
1841
|
});
|
|
@@ -1837,6 +1843,7 @@ var ServerStyleSheet = function () {
|
|
|
1837
1843
|
readableStream.on('end', function () {
|
|
1838
1844
|
return _this.seal();
|
|
1839
1845
|
});
|
|
1846
|
+
|
|
1840
1847
|
readableStream.on('error', function (err) {
|
|
1841
1848
|
_this.seal();
|
|
1842
1849
|
|
|
@@ -1853,7 +1860,6 @@ var ServerStyleSheet = function () {
|
|
|
1853
1860
|
//
|
|
1854
1861
|
|
|
1855
1862
|
var StyleSheetContext = React.createContext();
|
|
1856
|
-
|
|
1857
1863
|
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1858
1864
|
|
|
1859
1865
|
var StyleSheetManager = function (_Component) {
|
|
@@ -1925,7 +1931,7 @@ var classNameUsageCheckInjector = (function (target) {
|
|
|
1925
1931
|
|
|
1926
1932
|
didWarnAboutClassNameUsage.add(forwardTarget);
|
|
1927
1933
|
|
|
1928
|
-
var classNames = elementClassName.replace(
|
|
1934
|
+
var classNames = elementClassName.replace(/\s+/g, ' ').trim().split(' ');
|
|
1929
1935
|
// eslint-disable-next-line react/no-find-dom-node
|
|
1930
1936
|
var node = ReactDOM.findDOMNode(this);
|
|
1931
1937
|
var selector = classNames.map(function (s) {
|
|
@@ -1935,6 +1941,7 @@ var classNameUsageCheckInjector = (function (target) {
|
|
|
1935
1941
|
if (node && node.nodeType === 1 && !classNames.every(function (className) {
|
|
1936
1942
|
return node.classList && node.classList.contains(className);
|
|
1937
1943
|
}) && !node.querySelector(selector)) {
|
|
1944
|
+
// eslint-disable-next-line no-console
|
|
1938
1945
|
console.warn('It looks like you\'ve wrapped styled() around your React component (' + getComponentName(forwardTarget) + '), but the className prop is not being passed down to a child. No styles will be rendered unless className is composed within your React component.');
|
|
1939
1946
|
}
|
|
1940
1947
|
};
|
|
@@ -2074,7 +2081,9 @@ var StyledComponent = function (_Component) {
|
|
|
2074
2081
|
this.warnInnerRef(displayName);
|
|
2075
2082
|
}
|
|
2076
2083
|
|
|
2077
|
-
if (key === 'forwardedComponent' || key === 'as'
|
|
2084
|
+
if (key === 'forwardedComponent' || key === 'as' || key === 'suppressClassNameWarning') {
|
|
2085
|
+
continue;
|
|
2086
|
+
} else if (key === 'forwardedRef') propsForElement.ref = computedProps[key];else if (!isTargetTag || validAttr(key)) {
|
|
2078
2087
|
// Don't pass through non HTML tags through to HTML elements
|
|
2079
2088
|
propsForElement[key] = computedProps[key];
|
|
2080
2089
|
}
|
|
@@ -2260,7 +2269,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
2260
2269
|
var domElements = ['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',
|
|
2261
2270
|
|
|
2262
2271
|
// SVG
|
|
2263
|
-
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
|
2272
|
+
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'marker', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
|
2264
2273
|
|
|
2265
2274
|
//
|
|
2266
2275
|
|
|
@@ -2438,6 +2447,7 @@ var replaceWhitespace = function replaceWhitespace(str) {
|
|
|
2438
2447
|
function keyframes(strings) {
|
|
2439
2448
|
/* Warning if you've used keyframes on React Native */
|
|
2440
2449
|
if (process.env.NODE_ENV !== 'production' && typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
2450
|
+
// eslint-disable-next-line no-console
|
|
2441
2451
|
console.warn('`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.');
|
|
2442
2452
|
}
|
|
2443
2453
|
|
|
@@ -2513,16 +2523,18 @@ if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test' &&
|
|
|
2513
2523
|
|
|
2514
2524
|
var styled$1 = /*#__PURE__*/Object.freeze({
|
|
2515
2525
|
default: styled,
|
|
2516
|
-
css: css,
|
|
2517
|
-
keyframes: keyframes,
|
|
2518
2526
|
createGlobalStyle: createGlobalStyle,
|
|
2527
|
+
css: css,
|
|
2519
2528
|
isStyledComponent: isStyledComponent,
|
|
2529
|
+
keyframes: keyframes,
|
|
2530
|
+
ServerStyleSheet: ServerStyleSheet,
|
|
2531
|
+
StyleSheetConsumer: StyleSheetConsumer,
|
|
2532
|
+
StyleSheetContext: StyleSheetContext,
|
|
2533
|
+
StyleSheetManager: StyleSheetManager,
|
|
2520
2534
|
ThemeConsumer: ThemeConsumer,
|
|
2521
2535
|
ThemeContext: ThemeContext,
|
|
2522
2536
|
ThemeProvider: ThemeProvider,
|
|
2523
2537
|
withTheme: withTheme,
|
|
2524
|
-
ServerStyleSheet: ServerStyleSheet,
|
|
2525
|
-
StyleSheetManager: StyleSheetManager,
|
|
2526
2538
|
__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS: __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS
|
|
2527
2539
|
});
|
|
2528
2540
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled-components-macro.cjs.js","sources":["../src/models/StyleTags.js","../src/models/ThemeProvider.js","../src/models/StyleSheetManager.js","../src/models/StyledComponent.js","../src/models/GlobalStyle.js"],"sourcesContent":["// @flow\n/* eslint-disable flowtype/object-type-delimiter */\n/* eslint-disable react/prop-types */\n\nimport React, { type Element } from 'react';\nimport { IS_BROWSER, DISABLE_SPEEDY, SC_ATTR, SC_VERSION_ATTR } from '../constants';\nimport StyledError from '../utils/error';\nimport { type ExtractedComp } from '../utils/extractCompsFromCSS';\nimport { splitByRules } from '../utils/stringifyRules';\nimport getNonce from '../utils/nonce';\n\nimport {\n type Names,\n addNameForId,\n resetIdNames,\n hasNameForId,\n stringifyNames,\n cloneNames,\n} from '../utils/styleNames';\n\nimport { sheetForTag, safeInsertRule, deleteRules } from '../utils/insertRuleHelpers';\n\ndeclare var __VERSION__: string;\n\nexport interface Tag<T> {\n // $FlowFixMe: Doesn't seem to accept any combination w/ HTMLStyleElement for some reason\n styleTag: HTMLStyleElement | null;\n /* lists all ids of the tag */\n getIds(): string[];\n /* checks whether `name` is already injected for `id` */\n hasNameForId(id: string, name: string): boolean;\n /* inserts a marker to ensure the id's correct position in the sheet */\n insertMarker(id: string): T;\n /* inserts rules according to the ids markers */\n insertRules(id: string, cssRules: string[], name: ?string): void;\n /* removes all rules belonging to the id, keeping the marker around */\n removeRules(id: string): void;\n css(): string;\n toHTML(additionalAttrs: ?string): string;\n toElement(): Element<*>;\n clone(): Tag<T>;\n /* used in server side rendering to indicate that the rules in the tag have been flushed to HTML */\n sealed: boolean;\n}\n\n/* this marker separates component styles and is important for rehydration */\nconst makeTextMarker = id => `\\n/* sc-component-id: ${id} */\\n`;\n\n/* add up all numbers in array up until and including the index */\nconst addUpUntilIndex = (sizes: number[], index: number): number => {\n let totalUpToIndex = 0;\n for (let i = 0; i <= index; i += 1) {\n totalUpToIndex += sizes[i];\n }\n\n return totalUpToIndex;\n};\n\n/* create a new style tag after lastEl */\nconst makeStyleTag = (target: ?HTMLElement, tagEl: ?Node, insertBefore: ?boolean) => {\n const el = document.createElement('style');\n el.setAttribute(SC_ATTR, '');\n el.setAttribute(SC_VERSION_ATTR, __VERSION__);\n\n const nonce = getNonce();\n if (nonce) {\n el.setAttribute('nonce', nonce);\n }\n\n /* Work around insertRule quirk in EdgeHTML */\n el.appendChild(document.createTextNode(''));\n\n if (target && !tagEl) {\n /* Append to target when no previous element was passed */\n target.appendChild(el);\n } else {\n if (!tagEl || !target || !tagEl.parentNode) {\n throw new StyledError(6);\n }\n\n /* Insert new style tag after the previous one */\n tagEl.parentNode.insertBefore(el, insertBefore ? tagEl : tagEl.nextSibling);\n }\n\n return el;\n};\n\n/* takes a css factory function and outputs an html styled tag factory */\nconst wrapAsHtmlTag = (css: () => string, names: Names) => (additionalAttrs: ?string): string => {\n const nonce = getNonce();\n const attrs = [\n nonce && `nonce=\"${nonce}\"`,\n `${SC_ATTR}=\"${stringifyNames(names)}\"`,\n `${SC_VERSION_ATTR}=\"${__VERSION__}\"`,\n additionalAttrs,\n ];\n\n const htmlAttr = attrs.filter(Boolean).join(' ');\n return `<style ${htmlAttr}>${css()}</style>`;\n};\n\n/* takes a css factory function and outputs an element factory */\nconst wrapAsElement = (css: () => string, names: Names) => () => {\n const props = {\n [SC_ATTR]: stringifyNames(names),\n [SC_VERSION_ATTR]: __VERSION__,\n };\n\n const nonce = getNonce();\n if (nonce) {\n // $FlowFixMe\n props.nonce = nonce;\n }\n\n // eslint-disable-next-line react/no-danger\n return <style {...props} dangerouslySetInnerHTML={{ __html: css() }} />;\n};\n\nconst getIdsFromMarkersFactory = (markers: Object) => (): string[] => Object.keys(markers);\n\n/* speedy tags utilise insertRule */\nconst makeSpeedyTag = (el: HTMLStyleElement, getImportRuleTag: ?() => Tag<any>): Tag<number> => {\n const names: Names = (Object.create(null): Object);\n const markers = Object.create(null);\n const sizes: number[] = [];\n\n const extractImport = getImportRuleTag !== undefined;\n /* indicates whether getImportRuleTag was called */\n let usedImportRuleTag = false;\n\n const insertMarker = id => {\n const prev = markers[id];\n if (prev !== undefined) {\n return prev;\n }\n\n markers[id] = sizes.length;\n sizes.push(0);\n resetIdNames(names, id);\n\n return markers[id];\n };\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id);\n const sheet = sheetForTag(el);\n const insertIndex = addUpUntilIndex(sizes, marker);\n\n let injectedRules = 0;\n const importRules = [];\n const cssRulesSize = cssRules.length;\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const cssRule = cssRules[i];\n let mayHaveImport = extractImport; /* @import rules are reordered to appear first */\n if (mayHaveImport && cssRule.indexOf('@import') !== -1) {\n importRules.push(cssRule);\n } else if (safeInsertRule(sheet, cssRule, insertIndex + injectedRules)) {\n mayHaveImport = false;\n injectedRules += 1;\n }\n }\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true;\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules);\n }\n\n sizes[marker] += injectedRules; /* add up no of injected rules */\n addNameForId(names, id, name);\n };\n\n const removeRules = id => {\n const marker = markers[id];\n if (marker === undefined) return;\n\n const size = sizes[marker];\n const sheet = sheetForTag(el);\n const removalIndex = addUpUntilIndex(sizes, marker) - 1;\n deleteRules(sheet, removalIndex, size);\n sizes[marker] = 0;\n resetIdNames(names, id);\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`);\n }\n };\n\n const css = () => {\n const { cssRules } = sheetForTag(el);\n let str = '';\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += makeTextMarker(id);\n const marker = markers[id];\n const end = addUpUntilIndex(sizes, marker);\n const size = sizes[marker];\n for (let i = end - size; i < end; i += 1) {\n const rule = cssRules[i];\n if (rule !== undefined) {\n str += rule.cssText;\n }\n }\n }\n\n return str;\n };\n\n return {\n clone() {\n throw new StyledError(5);\n },\n css,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n sealed: false,\n styleTag: el,\n toElement: wrapAsElement(css, names),\n toHTML: wrapAsHtmlTag(css, names),\n };\n};\n\nconst makeTextNode = id => document.createTextNode(makeTextMarker(id));\n\nconst makeBrowserTag = (el: HTMLStyleElement, getImportRuleTag: ?() => Tag<any>): Tag<Text> => {\n const names = (Object.create(null): Object);\n const markers = Object.create(null);\n\n const extractImport = getImportRuleTag !== undefined;\n\n /* indicates whether getImportRuleTag was called */\n let usedImportRuleTag = false;\n\n const insertMarker = id => {\n const prev = markers[id];\n if (prev !== undefined) {\n return prev;\n }\n\n markers[id] = makeTextNode(id);\n el.appendChild(markers[id]);\n names[id] = Object.create(null);\n\n return markers[id];\n };\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id);\n const importRules = [];\n const cssRulesSize = cssRules.length;\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const rule = cssRules[i];\n let mayHaveImport = extractImport;\n if (mayHaveImport && rule.indexOf('@import') !== -1) {\n importRules.push(rule);\n } else {\n mayHaveImport = false;\n const separator = i === cssRulesSize - 1 ? '' : ' ';\n marker.appendData(`${rule}${separator}`);\n }\n }\n\n addNameForId(names, id, name);\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true;\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules);\n }\n };\n\n const removeRules = id => {\n const marker = markers[id];\n if (marker === undefined) return;\n\n /* create new empty text node and replace the current one */\n const newMarker = makeTextNode(id);\n el.replaceChild(newMarker, marker);\n markers[id] = newMarker;\n resetIdNames(names, id);\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`);\n }\n };\n\n const css = () => {\n let str = '';\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += markers[id].data;\n }\n\n return str;\n };\n\n return {\n clone() {\n throw new StyledError(5);\n },\n css,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n sealed: false,\n styleTag: el,\n toElement: wrapAsElement(css, names),\n toHTML: wrapAsHtmlTag(css, names),\n };\n};\n\nconst makeServerTag = (namesArg, markersArg): Tag<[string]> => {\n const names = namesArg === undefined ? (Object.create(null): Object) : namesArg;\n const markers = markersArg === undefined ? Object.create(null) : markersArg;\n\n const insertMarker = id => {\n const prev = markers[id];\n if (prev !== undefined) {\n return prev;\n }\n\n return (markers[id] = ['']);\n };\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id);\n marker[0] += cssRules.join(' ');\n addNameForId(names, id, name);\n };\n\n const removeRules = id => {\n const marker = markers[id];\n if (marker === undefined) return;\n marker[0] = '';\n resetIdNames(names, id);\n };\n\n const css = () => {\n let str = '';\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n const cssForId = markers[id][0];\n if (cssForId) {\n str += makeTextMarker(id) + cssForId;\n }\n }\n return str;\n };\n\n const clone = () => {\n const namesClone = cloneNames(names);\n const markersClone = Object.create(null);\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n markersClone[id] = [markers[id][0]];\n }\n\n return makeServerTag(namesClone, markersClone);\n };\n\n const tag = {\n clone,\n css,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n sealed: false,\n styleTag: null,\n toElement: wrapAsElement(css, names),\n toHTML: wrapAsHtmlTag(css, names),\n };\n\n return tag;\n};\n\nexport const makeTag = (\n target: ?HTMLElement,\n tagEl: ?HTMLStyleElement,\n forceServer?: boolean,\n insertBefore?: boolean,\n getImportRuleTag?: () => Tag<any>\n): Tag<any> => {\n if (IS_BROWSER && !forceServer) {\n const el = makeStyleTag(target, tagEl, insertBefore);\n\n if (DISABLE_SPEEDY) {\n return makeBrowserTag(el, getImportRuleTag);\n } else {\n return makeSpeedyTag(el, getImportRuleTag);\n }\n }\n\n return makeServerTag();\n};\n\nexport const rehydrate = (\n tag: Tag<any>,\n els: HTMLStyleElement[],\n extracted: ExtractedComp[]\n): void => {\n /* add all extracted components to the new tag */\n for (let i = 0, len = extracted.length; i < len; i += 1) {\n const { componentId, cssFromDOM } = extracted[i];\n const cssRules = splitByRules(cssFromDOM);\n tag.insertRules(componentId, cssRules);\n }\n\n /* remove old HTMLStyleElements, since they have been rehydrated */\n for (let i = 0, len = els.length; i < len; i += 1) {\n const el = els[i];\n if (el.parentNode) {\n el.parentNode.removeChild(el);\n }\n }\n};\n","// @flow\nimport React, { createContext, Component, type Element } from 'react';\nimport memoize from 'memoize-one';\nimport StyledError from '../utils/error';\nimport isFunction from '../utils/isFunction';\n\nexport type Theme = { [key: string]: mixed };\n\ntype Props = {\n children?: Element<any>,\n theme: Theme | ((outerTheme: Theme) => void),\n};\n\nexport const ThemeContext = createContext();\n\nexport const ThemeConsumer = ThemeContext.Consumer;\n\n/**\n * Provide a theme to an entire react component tree via context\n */\nexport default class ThemeProvider extends Component<Props> {\n getContext: (theme: Theme | ((outerTheme: Theme) => void), outerTheme?: Theme) => Theme;\n\n renderInner: Function;\n\n constructor(props: Props) {\n super(props);\n this.getContext = memoize(this.getContext.bind(this));\n this.renderInner = this.renderInner.bind(this);\n }\n\n render() {\n if (!this.props.children) return null;\n\n return <ThemeContext.Consumer>{this.renderInner}</ThemeContext.Consumer>;\n }\n\n renderInner(outerTheme?: Theme) {\n const context = this.getContext(this.props.theme, outerTheme);\n\n return (\n <ThemeContext.Provider value={context}>\n {React.Children.only(this.props.children)}\n </ThemeContext.Provider>\n );\n }\n\n /**\n * Get the theme from the props, supporting both (outerTheme) => {}\n * as well as object notation\n */\n getTheme(theme: (outerTheme: ?Theme) => void, outerTheme: ?Theme) {\n if (isFunction(theme)) {\n const mergedTheme = theme(outerTheme);\n\n if (\n process.env.NODE_ENV !== 'production' &&\n (mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object')\n ) {\n throw new StyledError(7);\n }\n\n return mergedTheme;\n }\n\n if (theme === null || Array.isArray(theme) || typeof theme !== 'object') {\n throw new StyledError(8);\n }\n\n return { ...outerTheme, ...theme };\n }\n\n getContext(theme: (outerTheme: ?Theme) => void, outerTheme?: Theme) {\n return this.getTheme(theme, outerTheme);\n }\n}\n","// @flow\nimport React, { createContext, Component, type Element } from 'react';\nimport PropTypes from 'prop-types';\nimport memoize from 'memoize-one';\nimport StyleSheet from './StyleSheet';\nimport ServerStyleSheet from './ServerStyleSheet';\nimport StyledError from '../utils/error';\n\ntype Props = {\n children?: Element<any>,\n sheet?: StyleSheet,\n target?: HTMLElement,\n};\n\nconst StyleSheetContext = createContext();\n\nexport const StyleSheetConsumer = StyleSheetContext.Consumer;\n\nexport default class StyleSheetManager extends Component<Props> {\n static propTypes = {\n sheet: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]),\n\n target: PropTypes.shape({\n appendChild: PropTypes.func.isRequired,\n }),\n };\n\n getContext: (sheet: ?StyleSheet, target: ?HTMLElement) => StyleSheet;\n\n constructor(props: Props) {\n super(props);\n this.getContext = memoize(this.getContext);\n }\n\n getContext(sheet: ?StyleSheet, target: ?HTMLElement) {\n if (sheet) {\n return sheet;\n } else if (target) {\n return new StyleSheet(target);\n } else {\n throw new StyledError(4);\n }\n }\n\n render() {\n const { children, sheet, target } = this.props;\n\n return (\n <StyleSheetContext.Provider value={this.getContext(sheet, target)}>\n {process.env.NODE_ENV !== 'production' ? React.Children.only(children) : children}\n </StyleSheetContext.Provider>\n );\n }\n}\n","// @flow\nimport validAttr from '@emotion/is-prop-valid';\nimport React, { createElement, Component } from 'react';\nimport ComponentStyle from './ComponentStyle';\nimport createWarnTooManyClasses from '../utils/createWarnTooManyClasses';\nimport determineTheme from '../utils/determineTheme';\nimport escape from '../utils/escape';\nimport generateDisplayName from '../utils/generateDisplayName';\nimport getComponentName from '../utils/getComponentName';\nimport hoist from '../utils/hoist';\nimport isFunction from '../utils/isFunction';\nimport isTag from '../utils/isTag';\nimport isDerivedReactComponent from '../utils/isDerivedReactComponent';\nimport isStyledComponent from '../utils/isStyledComponent';\nimport once from '../utils/once';\nimport StyleSheet from './StyleSheet';\nimport { ThemeConsumer, type Theme } from './ThemeProvider';\nimport { StyleSheetConsumer } from './StyleSheetManager';\nimport { EMPTY_ARRAY, EMPTY_OBJECT } from '../utils/empties';\nimport classNameUsageCheckInjector from '../utils/classNameUsageCheckInjector';\n\nimport type { Attrs, RuleSet, Target } from '../types';\nimport { IS_BROWSER } from '../constants';\n\nconst identifiers = {};\n\n/* We depend on components having unique IDs */\nfunction generateId(_ComponentStyle: Function, _displayName: string, parentComponentId: string) {\n const displayName = typeof _displayName !== 'string' ? 'sc' : escape(_displayName);\n\n /**\n * This ensures uniqueness if two components happen to share\n * the same displayName.\n */\n const nr = (identifiers[displayName] || 0) + 1;\n identifiers[displayName] = nr;\n\n const componentId = `${displayName}-${_ComponentStyle.generateName(displayName + nr)}`;\n\n return parentComponentId ? `${parentComponentId}-${componentId}` : componentId;\n}\n\n// $FlowFixMe\nclass StyledComponent extends Component<*> {\n renderOuter: Function;\n\n renderInner: Function;\n\n styleSheet: ?StyleSheet;\n\n warnInnerRef: Function;\n\n warnAttrsFnObjectKeyDeprecated: Function;\n\n warnNonStyledComponentAttrsObjectKey: Function;\n\n attrs = {};\n\n constructor() {\n super();\n this.renderOuter = this.renderOuter.bind(this);\n this.renderInner = this.renderInner.bind(this);\n\n if (process.env.NODE_ENV !== 'production') {\n this.warnInnerRef = once(displayName =>\n // eslint-disable-next-line no-console\n console.warn(\n `The \"innerRef\" API has been removed in styled-components v4 in favor of React 16 ref forwarding, use \"ref\" instead like a typical component. \"innerRef\" was detected on component \"${displayName}\".`\n )\n );\n\n this.warnAttrsFnObjectKeyDeprecated = once(\n (key, displayName): void =>\n // eslint-disable-next-line no-console\n console.warn(\n `Functions as object-form attrs({}) keys are now deprecated and will be removed in a future version of styled-components. Switch to the new attrs(props => ({})) syntax instead for easier and more powerful composition. The attrs key in question is \"${key}\" on component \"${displayName}\".`\n )\n );\n\n this.warnNonStyledComponentAttrsObjectKey = once(\n (key, displayName): void =>\n // eslint-disable-next-line no-console\n console.warn(\n `It looks like you've used a non styled-component as the value for the \"${key}\" prop in an object-form attrs constructor of \"${displayName}\".\\n` +\n 'You should use the new function-form attrs constructor which avoids this issue: attrs(props => ({ yourStuff }))\\n' +\n \"To continue using the deprecated object syntax, you'll need to wrap your component prop in a function to make it available inside the styled component (you'll still get the deprecation warning though.)\\n\" +\n `For example, { ${key}: () => InnerComponent } instead of { ${key}: InnerComponent }`\n )\n );\n }\n\n if (process.env.NODE_ENV !== 'production' && IS_BROWSER) {\n classNameUsageCheckInjector(this);\n }\n }\n\n render() {\n return <StyleSheetConsumer>{this.renderOuter}</StyleSheetConsumer>;\n }\n\n renderOuter(styleSheet?: StyleSheet = StyleSheet.master) {\n this.styleSheet = styleSheet;\n\n // No need to subscribe a static component to theme changes, it won't change anything\n if (this.props.forwardedComponent.componentStyle.isStatic) return this.renderInner();\n\n return <ThemeConsumer>{this.renderInner}</ThemeConsumer>;\n }\n\n renderInner(theme?: Theme) {\n const {\n componentStyle,\n defaultProps,\n displayName,\n foldedComponentIds,\n styledComponentId,\n target,\n } = this.props.forwardedComponent;\n\n let generatedClassName;\n if (componentStyle.isStatic) {\n generatedClassName = this.generateAndInjectStyles(EMPTY_OBJECT, this.props);\n } else if (theme !== undefined) {\n generatedClassName = this.generateAndInjectStyles(\n determineTheme(this.props, theme, defaultProps),\n this.props\n );\n } else {\n generatedClassName = this.generateAndInjectStyles(\n this.props.theme || EMPTY_OBJECT,\n this.props\n );\n }\n\n const elementToBeCreated = this.props.as || this.attrs.as || target;\n const isTargetTag = isTag(elementToBeCreated);\n\n const propsForElement = {};\n const computedProps = { ...this.attrs, ...this.props };\n\n let key;\n // eslint-disable-next-line guard-for-in\n for (key in computedProps) {\n if (process.env.NODE_ENV !== 'production' && key === 'innerRef' && isTargetTag) {\n this.warnInnerRef(displayName);\n }\n\n if (key === 'forwardedComponent' || key === 'as') continue;\n else if (key === 'forwardedRef') propsForElement.ref = computedProps[key];\n else if (!isTargetTag || validAttr(key)) {\n // Don't pass through non HTML tags through to HTML elements\n propsForElement[key] = computedProps[key];\n }\n }\n\n if (this.props.style && this.attrs.style) {\n propsForElement.style = { ...this.attrs.style, ...this.props.style };\n }\n\n propsForElement.className = Array.prototype\n .concat(\n foldedComponentIds,\n this.props.className,\n styledComponentId,\n this.attrs.className,\n generatedClassName\n )\n .filter(Boolean)\n .join(' ');\n\n return createElement(elementToBeCreated, propsForElement);\n }\n\n buildExecutionContext(theme: ?Object, props: Object, attrs: Attrs) {\n const context = { ...props, theme };\n\n if (!attrs.length) return context;\n\n this.attrs = {};\n\n attrs.forEach(attrDef => {\n let resolvedAttrDef = attrDef;\n let attrDefWasFn = false;\n let attr;\n let key;\n\n if (isFunction(resolvedAttrDef)) {\n // $FlowFixMe\n resolvedAttrDef = resolvedAttrDef(context);\n attrDefWasFn = true;\n }\n\n /* eslint-disable guard-for-in */\n // $FlowFixMe\n for (key in resolvedAttrDef) {\n attr = resolvedAttrDef[key];\n\n if (!attrDefWasFn) {\n if (isFunction(attr) && !isDerivedReactComponent(attr) && !isStyledComponent(attr)) {\n if (process.env.NODE_ENV !== 'production') {\n this.warnAttrsFnObjectKeyDeprecated(key, props.forwardedComponent.displayName);\n }\n\n attr = attr(context);\n\n if (process.env.NODE_ENV !== 'production' && React.isValidElement(attr)) {\n this.warnNonStyledComponentAttrsObjectKey(key, props.forwardedComponent.displayName);\n }\n }\n }\n\n this.attrs[key] = attr;\n context[key] = attr;\n }\n /* eslint-enable */\n });\n\n return context;\n }\n\n generateAndInjectStyles(theme: any, props: any) {\n const { attrs, componentStyle, warnTooManyClasses } = props.forwardedComponent;\n\n // statically styled-components don't need to build an execution context object,\n // and shouldn't be increasing the number of class names\n if (componentStyle.isStatic && !attrs.length) {\n return componentStyle.generateAndInjectStyles(EMPTY_OBJECT, this.styleSheet);\n }\n\n const className = componentStyle.generateAndInjectStyles(\n this.buildExecutionContext(theme, props, attrs),\n this.styleSheet\n );\n\n if (process.env.NODE_ENV !== 'production' && warnTooManyClasses) warnTooManyClasses(className);\n\n return className;\n }\n}\n\nexport default function createStyledComponent(target: Target, options: Object, rules: RuleSet) {\n const isTargetStyledComp = isStyledComponent(target);\n const isClass = !isTag(target);\n\n const {\n displayName = generateDisplayName(target),\n componentId = generateId(ComponentStyle, options.displayName, options.parentComponentId),\n ParentComponent = StyledComponent,\n attrs = EMPTY_ARRAY,\n } = options;\n\n const styledComponentId =\n options.displayName && options.componentId\n ? `${escape(options.displayName)}-${options.componentId}`\n : options.componentId || componentId;\n\n // fold the underlying StyledComponent attrs up (implicit extend)\n const finalAttrs =\n // $FlowFixMe\n isTargetStyledComp && target.attrs\n ? Array.prototype.concat(target.attrs, attrs).filter(Boolean)\n : attrs;\n\n const componentStyle = new ComponentStyle(\n isTargetStyledComp\n ? // fold the underlying StyledComponent rules up (implicit extend)\n // $FlowFixMe\n target.componentStyle.rules.concat(rules)\n : rules,\n finalAttrs,\n styledComponentId\n );\n\n /**\n * forwardRef creates a new interim component, which we'll take advantage of\n * instead of extending ParentComponent to create _another_ interim class\n */\n const WrappedStyledComponent = React.forwardRef((props, ref) => (\n <ParentComponent {...props} forwardedComponent={WrappedStyledComponent} forwardedRef={ref} />\n ));\n\n // $FlowFixMe\n WrappedStyledComponent.attrs = finalAttrs;\n // $FlowFixMe\n WrappedStyledComponent.componentStyle = componentStyle;\n WrappedStyledComponent.displayName = displayName;\n\n // $FlowFixMe\n WrappedStyledComponent.foldedComponentIds = isTargetStyledComp\n ? // $FlowFixMe\n Array.prototype.concat(target.foldedComponentIds, target.styledComponentId)\n : EMPTY_ARRAY;\n\n // $FlowFixMe\n WrappedStyledComponent.styledComponentId = styledComponentId;\n\n // fold the underlying StyledComponent target up since we folded the styles\n // $FlowFixMe\n WrappedStyledComponent.target = isTargetStyledComp ? target.target : target;\n\n // $FlowFixMe\n WrappedStyledComponent.withComponent = function withComponent(tag: Target) {\n const { componentId: previousComponentId, ...optionsToCopy } = options;\n\n const newComponentId =\n previousComponentId &&\n `${previousComponentId}-${isTag(tag) ? tag : escape(getComponentName(tag))}`;\n\n const newOptions = {\n ...optionsToCopy,\n attrs: finalAttrs,\n componentId: newComponentId,\n ParentComponent,\n };\n\n return createStyledComponent(tag, newOptions, rules);\n };\n\n if (process.env.NODE_ENV !== 'production') {\n // $FlowFixMe\n WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName);\n }\n\n // $FlowFixMe\n WrappedStyledComponent.toString = () => `.${WrappedStyledComponent.styledComponentId}`;\n\n if (isClass) {\n hoist(WrappedStyledComponent, target, {\n // all SC-specific things should not be hoisted\n attrs: true,\n componentStyle: true,\n displayName: true,\n foldedComponentIds: true,\n styledComponentId: true,\n target: true,\n withComponent: true,\n });\n }\n\n return WrappedStyledComponent;\n}\n","// @flow\nimport { EMPTY_ARRAY } from '../utils/empties';\nimport flatten from '../utils/flatten';\nimport isStaticRules from '../utils/isStaticRules';\nimport stringifyRules from '../utils/stringifyRules';\nimport StyleSheet from './StyleSheet';\n\nimport type { RuleSet } from '../types';\n\nexport default class GlobalStyle {\n componentId: string;\n\n isStatic: boolean;\n\n rules: RuleSet;\n\n constructor(rules: RuleSet, componentId: string) {\n this.rules = rules;\n this.componentId = componentId;\n this.isStatic = isStaticRules(rules, EMPTY_ARRAY);\n\n if (!StyleSheet.master.hasId(componentId)) {\n StyleSheet.master.deferredInject(componentId, []);\n }\n }\n\n createStyles(executionContext: Object, styleSheet: StyleSheet) {\n const flatCSS = flatten(this.rules, executionContext, styleSheet);\n const css = stringifyRules(flatCSS, '');\n\n styleSheet.inject(this.componentId, css);\n }\n\n removeStyles(styleSheet: StyleSheet) {\n const { componentId } = this;\n if (styleSheet.hasId(componentId)) {\n styleSheet.remove(componentId);\n }\n }\n\n // TODO: overwrite in-place instead of remove+create?\n renderStyles(executionContext: Object, styleSheet: StyleSheet) {\n this.removeStyles(styleSheet);\n this.createStyles(executionContext, styleSheet);\n }\n}\n"],"names":["__VERSION__","i"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CC;;CAAA;;;;;;;;;;;;;;;;mCAgBgDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEA2DO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDAoSnD;;WAEMC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjZT;;;;;;;;;;;8BAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCCSA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCC+I2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BCjK3B,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"styled-components-macro.cjs.js","sources":["../src/models/StyleTags.js","../src/models/ThemeProvider.js","../src/models/StyleSheetManager.js","../src/models/StyledComponent.js","../src/models/GlobalStyle.js"],"sourcesContent":["// @flow\n/* eslint-disable flowtype/object-type-delimiter */\n/* eslint-disable react/prop-types */\n\nimport React, { type Element } from 'react';\nimport { IS_BROWSER, DISABLE_SPEEDY, SC_ATTR, SC_VERSION_ATTR } from '../constants';\nimport StyledError from '../utils/error';\nimport { type ExtractedComp } from '../utils/extractCompsFromCSS';\nimport { splitByRules } from '../utils/stringifyRules';\nimport getNonce from '../utils/nonce';\n\nimport {\n type Names,\n addNameForId,\n resetIdNames,\n hasNameForId,\n stringifyNames,\n cloneNames,\n} from '../utils/styleNames';\n\nimport { sheetForTag, safeInsertRule, deleteRules } from '../utils/insertRuleHelpers';\n\ndeclare var __VERSION__: string;\n\nexport interface Tag<T> {\n // $FlowFixMe: Doesn't seem to accept any combination w/ HTMLStyleElement for some reason\n styleTag: HTMLStyleElement | null;\n /* lists all ids of the tag */\n getIds(): string[];\n /* checks whether `name` is already injected for `id` */\n hasNameForId(id: string, name: string): boolean;\n /* inserts a marker to ensure the id's correct position in the sheet */\n insertMarker(id: string): T;\n /* inserts rules according to the ids markers */\n insertRules(id: string, cssRules: string[], name: ?string): void;\n /* removes all rules belonging to the id, keeping the marker around */\n removeRules(id: string): void;\n css(): string;\n toHTML(additionalAttrs: ?string): string;\n toElement(): Element<*>;\n clone(): Tag<T>;\n /* used in server side rendering to indicate that the rules in the tag have been flushed to HTML */\n sealed: boolean;\n}\n\n/* this marker separates component styles and is important for rehydration */\nconst makeTextMarker = id => `\\n/* sc-component-id: ${id} */\\n`;\n\n/* add up all numbers in array up until and including the index */\nconst addUpUntilIndex = (sizes: number[], index: number): number => {\n let totalUpToIndex = 0;\n for (let i = 0; i <= index; i += 1) {\n totalUpToIndex += sizes[i];\n }\n\n return totalUpToIndex;\n};\n\n/* create a new style tag after lastEl */\nconst makeStyleTag = (target: ?HTMLElement, tagEl: ?Node, insertBefore: ?boolean) => {\n const el = document.createElement('style');\n el.setAttribute(SC_ATTR, '');\n el.setAttribute(SC_VERSION_ATTR, __VERSION__);\n\n const nonce = getNonce();\n if (nonce) {\n el.setAttribute('nonce', nonce);\n }\n\n /* Work around insertRule quirk in EdgeHTML */\n el.appendChild(document.createTextNode(''));\n\n if (target && !tagEl) {\n /* Append to target when no previous element was passed */\n target.appendChild(el);\n } else {\n if (!tagEl || !target || !tagEl.parentNode) {\n throw new StyledError(6);\n }\n\n /* Insert new style tag after the previous one */\n tagEl.parentNode.insertBefore(el, insertBefore ? tagEl : tagEl.nextSibling);\n }\n\n return el;\n};\n\n/* takes a css factory function and outputs an html styled tag factory */\nconst wrapAsHtmlTag = (css: () => string, names: Names) => (additionalAttrs: ?string): string => {\n const nonce = getNonce();\n const attrs = [\n nonce && `nonce=\"${nonce}\"`,\n `${SC_ATTR}=\"${stringifyNames(names)}\"`,\n `${SC_VERSION_ATTR}=\"${__VERSION__}\"`,\n additionalAttrs,\n ];\n\n const htmlAttr = attrs.filter(Boolean).join(' ');\n return `<style ${htmlAttr}>${css()}</style>`;\n};\n\n/* takes a css factory function and outputs an element factory */\nconst wrapAsElement = (css: () => string, names: Names) => () => {\n const props = {\n [SC_ATTR]: stringifyNames(names),\n [SC_VERSION_ATTR]: __VERSION__,\n };\n\n const nonce = getNonce();\n if (nonce) {\n // $FlowFixMe\n props.nonce = nonce;\n }\n\n // eslint-disable-next-line react/no-danger\n return <style {...props} dangerouslySetInnerHTML={{ __html: css() }} />;\n};\n\nconst getIdsFromMarkersFactory = (markers: Object) => (): string[] => Object.keys(markers);\n\n/* speedy tags utilise insertRule */\nconst makeSpeedyTag = (el: HTMLStyleElement, getImportRuleTag: ?() => Tag<any>): Tag<number> => {\n const names: Names = (Object.create(null): Object);\n const markers = Object.create(null);\n const sizes: number[] = [];\n\n const extractImport = getImportRuleTag !== undefined;\n /* indicates whether getImportRuleTag was called */\n let usedImportRuleTag = false;\n\n const insertMarker = id => {\n const prev = markers[id];\n if (prev !== undefined) {\n return prev;\n }\n\n markers[id] = sizes.length;\n sizes.push(0);\n resetIdNames(names, id);\n\n return markers[id];\n };\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id);\n const sheet = sheetForTag(el);\n const insertIndex = addUpUntilIndex(sizes, marker);\n\n let injectedRules = 0;\n const importRules = [];\n const cssRulesSize = cssRules.length;\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const cssRule = cssRules[i];\n let mayHaveImport = extractImport; /* @import rules are reordered to appear first */\n if (mayHaveImport && cssRule.indexOf('@import') !== -1) {\n importRules.push(cssRule);\n } else if (safeInsertRule(sheet, cssRule, insertIndex + injectedRules)) {\n mayHaveImport = false;\n injectedRules += 1;\n }\n }\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true;\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules);\n }\n\n sizes[marker] += injectedRules; /* add up no of injected rules */\n addNameForId(names, id, name);\n };\n\n const removeRules = id => {\n const marker = markers[id];\n if (marker === undefined) return;\n\n const size = sizes[marker];\n const sheet = sheetForTag(el);\n const removalIndex = addUpUntilIndex(sizes, marker) - 1;\n deleteRules(sheet, removalIndex, size);\n sizes[marker] = 0;\n resetIdNames(names, id);\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`);\n }\n };\n\n const css = () => {\n const { cssRules } = sheetForTag(el);\n let str = '';\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += makeTextMarker(id);\n const marker = markers[id];\n const end = addUpUntilIndex(sizes, marker);\n const size = sizes[marker];\n for (let i = end - size; i < end; i += 1) {\n const rule = cssRules[i];\n if (rule !== undefined) {\n str += rule.cssText;\n }\n }\n }\n\n return str;\n };\n\n return {\n clone() {\n throw new StyledError(5);\n },\n css,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n sealed: false,\n styleTag: el,\n toElement: wrapAsElement(css, names),\n toHTML: wrapAsHtmlTag(css, names),\n };\n};\n\nconst makeTextNode = id => document.createTextNode(makeTextMarker(id));\n\nconst makeBrowserTag = (el: HTMLStyleElement, getImportRuleTag: ?() => Tag<any>): Tag<Text> => {\n const names = (Object.create(null): Object);\n const markers = Object.create(null);\n\n const extractImport = getImportRuleTag !== undefined;\n\n /* indicates whether getImportRuleTag was called */\n let usedImportRuleTag = false;\n\n const insertMarker = id => {\n const prev = markers[id];\n if (prev !== undefined) {\n return prev;\n }\n\n markers[id] = makeTextNode(id);\n el.appendChild(markers[id]);\n names[id] = Object.create(null);\n\n return markers[id];\n };\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id);\n const importRules = [];\n const cssRulesSize = cssRules.length;\n\n for (let i = 0; i < cssRulesSize; i += 1) {\n const rule = cssRules[i];\n let mayHaveImport = extractImport;\n if (mayHaveImport && rule.indexOf('@import') !== -1) {\n importRules.push(rule);\n } else {\n mayHaveImport = false;\n const separator = i === cssRulesSize - 1 ? '' : ' ';\n marker.appendData(`${rule}${separator}`);\n }\n }\n\n addNameForId(names, id, name);\n\n if (extractImport && importRules.length > 0) {\n usedImportRuleTag = true;\n // $FlowFixMe\n getImportRuleTag().insertRules(`${id}-import`, importRules);\n }\n };\n\n const removeRules = id => {\n const marker = markers[id];\n if (marker === undefined) return;\n\n /* create new empty text node and replace the current one */\n const newMarker = makeTextNode(id);\n el.replaceChild(newMarker, marker);\n markers[id] = newMarker;\n resetIdNames(names, id);\n\n if (extractImport && usedImportRuleTag) {\n // $FlowFixMe\n getImportRuleTag().removeRules(`${id}-import`);\n }\n };\n\n const css = () => {\n let str = '';\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n str += markers[id].data;\n }\n\n return str;\n };\n\n return {\n clone() {\n throw new StyledError(5);\n },\n css,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n sealed: false,\n styleTag: el,\n toElement: wrapAsElement(css, names),\n toHTML: wrapAsHtmlTag(css, names),\n };\n};\n\nconst makeServerTag = (namesArg, markersArg): Tag<[string]> => {\n const names = namesArg === undefined ? (Object.create(null): Object) : namesArg;\n const markers = markersArg === undefined ? Object.create(null) : markersArg;\n\n const insertMarker = id => {\n const prev = markers[id];\n if (prev !== undefined) {\n return prev;\n }\n\n return (markers[id] = ['']);\n };\n\n const insertRules = (id, cssRules, name) => {\n const marker = insertMarker(id);\n marker[0] += cssRules.join(' ');\n addNameForId(names, id, name);\n };\n\n const removeRules = id => {\n const marker = markers[id];\n if (marker === undefined) return;\n marker[0] = '';\n resetIdNames(names, id);\n };\n\n const css = () => {\n let str = '';\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n const cssForId = markers[id][0];\n if (cssForId) {\n str += makeTextMarker(id) + cssForId;\n }\n }\n return str;\n };\n\n const clone = () => {\n const namesClone = cloneNames(names);\n const markersClone = Object.create(null);\n\n // eslint-disable-next-line guard-for-in\n for (const id in markers) {\n markersClone[id] = [markers[id][0]];\n }\n\n return makeServerTag(namesClone, markersClone);\n };\n\n const tag = {\n clone,\n css,\n getIds: getIdsFromMarkersFactory(markers),\n hasNameForId: hasNameForId(names),\n insertMarker,\n insertRules,\n removeRules,\n sealed: false,\n styleTag: null,\n toElement: wrapAsElement(css, names),\n toHTML: wrapAsHtmlTag(css, names),\n };\n\n return tag;\n};\n\nexport const makeTag = (\n target: ?HTMLElement,\n tagEl: ?HTMLStyleElement,\n forceServer?: boolean,\n insertBefore?: boolean,\n getImportRuleTag?: () => Tag<any>\n): Tag<any> => {\n if (IS_BROWSER && !forceServer) {\n const el = makeStyleTag(target, tagEl, insertBefore);\n\n if (DISABLE_SPEEDY) {\n return makeBrowserTag(el, getImportRuleTag);\n } else {\n return makeSpeedyTag(el, getImportRuleTag);\n }\n }\n\n return makeServerTag();\n};\n\nexport const rehydrate = (\n tag: Tag<any>,\n els: HTMLStyleElement[],\n extracted: ExtractedComp[]\n): void => {\n /* add all extracted components to the new tag */\n for (let i = 0, len = extracted.length; i < len; i += 1) {\n const { componentId, cssFromDOM } = extracted[i];\n const cssRules = splitByRules(cssFromDOM);\n tag.insertRules(componentId, cssRules);\n }\n\n /* remove old HTMLStyleElements, since they have been rehydrated */\n for (let i = 0, len = els.length; i < len; i += 1) {\n const el = els[i];\n if (el.parentNode) {\n el.parentNode.removeChild(el);\n }\n }\n};\n","// @flow\nimport React, { createContext, Component, type Element } from 'react';\nimport memoize from 'memoize-one';\nimport StyledError from '../utils/error';\nimport isFunction from '../utils/isFunction';\n\nexport type Theme = { [key: string]: mixed };\n\ntype Props = {\n children?: Element<any>,\n theme: Theme | ((outerTheme: Theme) => void),\n};\n\nexport const ThemeContext = createContext();\n\nexport const ThemeConsumer = ThemeContext.Consumer;\n\n/**\n * Provide a theme to an entire react component tree via context\n */\nexport default class ThemeProvider extends Component<Props> {\n getContext: (theme: Theme | ((outerTheme: Theme) => void), outerTheme?: Theme) => Theme;\n\n renderInner: Function;\n\n constructor(props: Props) {\n super(props);\n this.getContext = memoize(this.getContext.bind(this));\n this.renderInner = this.renderInner.bind(this);\n }\n\n render() {\n if (!this.props.children) return null;\n\n return <ThemeContext.Consumer>{this.renderInner}</ThemeContext.Consumer>;\n }\n\n renderInner(outerTheme?: Theme) {\n const context = this.getContext(this.props.theme, outerTheme);\n\n return (\n <ThemeContext.Provider value={context}>\n {React.Children.only(this.props.children)}\n </ThemeContext.Provider>\n );\n }\n\n /**\n * Get the theme from the props, supporting both (outerTheme) => {}\n * as well as object notation\n */\n getTheme(theme: (outerTheme: ?Theme) => void, outerTheme: ?Theme) {\n if (isFunction(theme)) {\n const mergedTheme = theme(outerTheme);\n\n if (\n process.env.NODE_ENV !== 'production' &&\n (mergedTheme === null || Array.isArray(mergedTheme) || typeof mergedTheme !== 'object')\n ) {\n throw new StyledError(7);\n }\n\n return mergedTheme;\n }\n\n if (theme === null || Array.isArray(theme) || typeof theme !== 'object') {\n throw new StyledError(8);\n }\n\n return { ...outerTheme, ...theme };\n }\n\n getContext(theme: (outerTheme: ?Theme) => void, outerTheme?: Theme) {\n return this.getTheme(theme, outerTheme);\n }\n}\n","// @flow\nimport React, { createContext, Component, type Element } from 'react';\nimport PropTypes from 'prop-types';\nimport memoize from 'memoize-one';\nimport StyleSheet from './StyleSheet';\nimport ServerStyleSheet from './ServerStyleSheet';\nimport StyledError from '../utils/error';\n\ntype Props = {\n children?: Element<any>,\n sheet?: StyleSheet,\n target?: HTMLElement,\n};\n\nexport const StyleSheetContext = createContext();\nexport const StyleSheetConsumer = StyleSheetContext.Consumer;\n\nexport default class StyleSheetManager extends Component<Props> {\n static propTypes = {\n sheet: PropTypes.oneOfType([\n PropTypes.instanceOf(StyleSheet),\n PropTypes.instanceOf(ServerStyleSheet),\n ]),\n\n target: PropTypes.shape({\n appendChild: PropTypes.func.isRequired,\n }),\n };\n\n getContext: (sheet: ?StyleSheet, target: ?HTMLElement) => StyleSheet;\n\n constructor(props: Props) {\n super(props);\n this.getContext = memoize(this.getContext);\n }\n\n getContext(sheet: ?StyleSheet, target: ?HTMLElement) {\n if (sheet) {\n return sheet;\n } else if (target) {\n return new StyleSheet(target);\n } else {\n throw new StyledError(4);\n }\n }\n\n render() {\n const { children, sheet, target } = this.props;\n\n return (\n <StyleSheetContext.Provider value={this.getContext(sheet, target)}>\n {process.env.NODE_ENV !== 'production' ? React.Children.only(children) : children}\n </StyleSheetContext.Provider>\n );\n }\n}\n","// @flow\nimport validAttr from '@emotion/is-prop-valid';\nimport React, { createElement, Component } from 'react';\nimport ComponentStyle from './ComponentStyle';\nimport createWarnTooManyClasses from '../utils/createWarnTooManyClasses';\nimport determineTheme from '../utils/determineTheme';\nimport escape from '../utils/escape';\nimport generateDisplayName from '../utils/generateDisplayName';\nimport getComponentName from '../utils/getComponentName';\nimport hoist from '../utils/hoist';\nimport isFunction from '../utils/isFunction';\nimport isTag from '../utils/isTag';\nimport isDerivedReactComponent from '../utils/isDerivedReactComponent';\nimport isStyledComponent from '../utils/isStyledComponent';\nimport once from '../utils/once';\nimport StyleSheet from './StyleSheet';\nimport { ThemeConsumer, type Theme } from './ThemeProvider';\nimport { StyleSheetConsumer } from './StyleSheetManager';\nimport { EMPTY_ARRAY, EMPTY_OBJECT } from '../utils/empties';\nimport classNameUsageCheckInjector from '../utils/classNameUsageCheckInjector';\n\nimport type { Attrs, RuleSet, Target } from '../types';\nimport { IS_BROWSER } from '../constants';\n\nconst identifiers = {};\n\n/* We depend on components having unique IDs */\nfunction generateId(_ComponentStyle: Function, _displayName: string, parentComponentId: string) {\n const displayName = typeof _displayName !== 'string' ? 'sc' : escape(_displayName);\n\n /**\n * This ensures uniqueness if two components happen to share\n * the same displayName.\n */\n const nr = (identifiers[displayName] || 0) + 1;\n identifiers[displayName] = nr;\n\n const componentId = `${displayName}-${_ComponentStyle.generateName(displayName + nr)}`;\n\n return parentComponentId ? `${parentComponentId}-${componentId}` : componentId;\n}\n\n// $FlowFixMe\nclass StyledComponent extends Component<*> {\n renderOuter: Function;\n\n renderInner: Function;\n\n styleSheet: ?StyleSheet;\n\n warnInnerRef: Function;\n\n warnAttrsFnObjectKeyDeprecated: Function;\n\n warnNonStyledComponentAttrsObjectKey: Function;\n\n attrs = {};\n\n constructor() {\n super();\n this.renderOuter = this.renderOuter.bind(this);\n this.renderInner = this.renderInner.bind(this);\n\n if (process.env.NODE_ENV !== 'production') {\n this.warnInnerRef = once(displayName =>\n // eslint-disable-next-line no-console\n console.warn(\n `The \"innerRef\" API has been removed in styled-components v4 in favor of React 16 ref forwarding, use \"ref\" instead like a typical component. \"innerRef\" was detected on component \"${displayName}\".`\n )\n );\n\n this.warnAttrsFnObjectKeyDeprecated = once(\n (key, displayName): void =>\n // eslint-disable-next-line no-console\n console.warn(\n `Functions as object-form attrs({}) keys are now deprecated and will be removed in a future version of styled-components. Switch to the new attrs(props => ({})) syntax instead for easier and more powerful composition. The attrs key in question is \"${key}\" on component \"${displayName}\".`\n )\n );\n\n this.warnNonStyledComponentAttrsObjectKey = once(\n (key, displayName): void =>\n // eslint-disable-next-line no-console\n console.warn(\n `It looks like you've used a non styled-component as the value for the \"${key}\" prop in an object-form attrs constructor of \"${displayName}\".\\n` +\n 'You should use the new function-form attrs constructor which avoids this issue: attrs(props => ({ yourStuff }))\\n' +\n \"To continue using the deprecated object syntax, you'll need to wrap your component prop in a function to make it available inside the styled component (you'll still get the deprecation warning though.)\\n\" +\n `For example, { ${key}: () => InnerComponent } instead of { ${key}: InnerComponent }`\n )\n );\n }\n\n if (process.env.NODE_ENV !== 'production' && IS_BROWSER) {\n classNameUsageCheckInjector(this);\n }\n }\n\n render() {\n return <StyleSheetConsumer>{this.renderOuter}</StyleSheetConsumer>;\n }\n\n renderOuter(styleSheet?: StyleSheet = StyleSheet.master) {\n this.styleSheet = styleSheet;\n\n // No need to subscribe a static component to theme changes, it won't change anything\n if (this.props.forwardedComponent.componentStyle.isStatic) return this.renderInner();\n\n return <ThemeConsumer>{this.renderInner}</ThemeConsumer>;\n }\n\n renderInner(theme?: Theme) {\n const {\n componentStyle,\n defaultProps,\n displayName,\n foldedComponentIds,\n styledComponentId,\n target,\n } = this.props.forwardedComponent;\n\n let generatedClassName;\n if (componentStyle.isStatic) {\n generatedClassName = this.generateAndInjectStyles(EMPTY_OBJECT, this.props);\n } else if (theme !== undefined) {\n generatedClassName = this.generateAndInjectStyles(\n determineTheme(this.props, theme, defaultProps),\n this.props\n );\n } else {\n generatedClassName = this.generateAndInjectStyles(\n this.props.theme || EMPTY_OBJECT,\n this.props\n );\n }\n\n const elementToBeCreated = this.props.as || this.attrs.as || target;\n const isTargetTag = isTag(elementToBeCreated);\n\n const propsForElement = {};\n const computedProps = { ...this.attrs, ...this.props };\n\n let key;\n // eslint-disable-next-line guard-for-in\n for (key in computedProps) {\n if (process.env.NODE_ENV !== 'production' && key === 'innerRef' && isTargetTag) {\n this.warnInnerRef(displayName);\n }\n\n if (key === 'forwardedComponent' || key === 'as' || key === 'suppressClassNameWarning')\n {continue;}\n else if (key === 'forwardedRef') propsForElement.ref = computedProps[key];\n else if (!isTargetTag || validAttr(key)) {\n // Don't pass through non HTML tags through to HTML elements\n propsForElement[key] = computedProps[key];\n }\n }\n\n if (this.props.style && this.attrs.style) {\n propsForElement.style = { ...this.attrs.style, ...this.props.style };\n }\n\n propsForElement.className = Array.prototype\n .concat(\n foldedComponentIds,\n this.props.className,\n styledComponentId,\n this.attrs.className,\n generatedClassName\n )\n .filter(Boolean)\n .join(' ');\n\n return createElement(elementToBeCreated, propsForElement);\n }\n\n buildExecutionContext(theme: ?Object, props: Object, attrs: Attrs) {\n const context = { ...props, theme };\n\n if (!attrs.length) return context;\n\n this.attrs = {};\n\n attrs.forEach(attrDef => {\n let resolvedAttrDef = attrDef;\n let attrDefWasFn = false;\n let attr;\n let key;\n\n if (isFunction(resolvedAttrDef)) {\n // $FlowFixMe\n resolvedAttrDef = resolvedAttrDef(context);\n attrDefWasFn = true;\n }\n\n /* eslint-disable guard-for-in */\n // $FlowFixMe\n for (key in resolvedAttrDef) {\n attr = resolvedAttrDef[key];\n\n if (!attrDefWasFn) {\n if (isFunction(attr) && !isDerivedReactComponent(attr) && !isStyledComponent(attr)) {\n if (process.env.NODE_ENV !== 'production') {\n this.warnAttrsFnObjectKeyDeprecated(key, props.forwardedComponent.displayName);\n }\n\n attr = attr(context);\n\n if (process.env.NODE_ENV !== 'production' && React.isValidElement(attr)) {\n this.warnNonStyledComponentAttrsObjectKey(key, props.forwardedComponent.displayName);\n }\n }\n }\n\n this.attrs[key] = attr;\n context[key] = attr;\n }\n /* eslint-enable */\n });\n\n return context;\n }\n\n generateAndInjectStyles(theme: any, props: any) {\n const { attrs, componentStyle, warnTooManyClasses } = props.forwardedComponent;\n\n // statically styled-components don't need to build an execution context object,\n // and shouldn't be increasing the number of class names\n if (componentStyle.isStatic && !attrs.length) {\n return componentStyle.generateAndInjectStyles(EMPTY_OBJECT, this.styleSheet);\n }\n\n const className = componentStyle.generateAndInjectStyles(\n this.buildExecutionContext(theme, props, attrs),\n this.styleSheet\n );\n\n if (process.env.NODE_ENV !== 'production' && warnTooManyClasses) warnTooManyClasses(className);\n\n return className;\n }\n}\n\nexport default function createStyledComponent(target: Target, options: Object, rules: RuleSet) {\n const isTargetStyledComp = isStyledComponent(target);\n const isClass = !isTag(target);\n\n const {\n displayName = generateDisplayName(target),\n componentId = generateId(ComponentStyle, options.displayName, options.parentComponentId),\n ParentComponent = StyledComponent,\n attrs = EMPTY_ARRAY,\n } = options;\n\n const styledComponentId =\n options.displayName && options.componentId\n ? `${escape(options.displayName)}-${options.componentId}`\n : options.componentId || componentId;\n\n // fold the underlying StyledComponent attrs up (implicit extend)\n const finalAttrs =\n // $FlowFixMe\n isTargetStyledComp && target.attrs\n ? Array.prototype.concat(target.attrs, attrs).filter(Boolean)\n : attrs;\n\n const componentStyle = new ComponentStyle(\n isTargetStyledComp\n ? // fold the underlying StyledComponent rules up (implicit extend)\n // $FlowFixMe\n target.componentStyle.rules.concat(rules)\n : rules,\n finalAttrs,\n styledComponentId\n );\n\n /**\n * forwardRef creates a new interim component, which we'll take advantage of\n * instead of extending ParentComponent to create _another_ interim class\n */\n const WrappedStyledComponent = React.forwardRef((props, ref) => (\n <ParentComponent {...props} forwardedComponent={WrappedStyledComponent} forwardedRef={ref} />\n ));\n\n // $FlowFixMe\n WrappedStyledComponent.attrs = finalAttrs;\n // $FlowFixMe\n WrappedStyledComponent.componentStyle = componentStyle;\n WrappedStyledComponent.displayName = displayName;\n\n // $FlowFixMe\n WrappedStyledComponent.foldedComponentIds = isTargetStyledComp\n ? // $FlowFixMe\n Array.prototype.concat(target.foldedComponentIds, target.styledComponentId)\n : EMPTY_ARRAY;\n\n // $FlowFixMe\n WrappedStyledComponent.styledComponentId = styledComponentId;\n\n // fold the underlying StyledComponent target up since we folded the styles\n // $FlowFixMe\n WrappedStyledComponent.target = isTargetStyledComp ? target.target : target;\n\n // $FlowFixMe\n WrappedStyledComponent.withComponent = function withComponent(tag: Target) {\n const { componentId: previousComponentId, ...optionsToCopy } = options;\n\n const newComponentId =\n previousComponentId &&\n `${previousComponentId}-${isTag(tag) ? tag : escape(getComponentName(tag))}`;\n\n const newOptions = {\n ...optionsToCopy,\n attrs: finalAttrs,\n componentId: newComponentId,\n ParentComponent,\n };\n\n return createStyledComponent(tag, newOptions, rules);\n };\n\n if (process.env.NODE_ENV !== 'production') {\n // $FlowFixMe\n WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName);\n }\n\n // $FlowFixMe\n WrappedStyledComponent.toString = () => `.${WrappedStyledComponent.styledComponentId}`;\n\n if (isClass) {\n hoist(WrappedStyledComponent, target, {\n // all SC-specific things should not be hoisted\n attrs: true,\n componentStyle: true,\n displayName: true,\n foldedComponentIds: true,\n styledComponentId: true,\n target: true,\n withComponent: true,\n });\n }\n\n return WrappedStyledComponent;\n}\n","// @flow\nimport { EMPTY_ARRAY } from '../utils/empties';\nimport flatten from '../utils/flatten';\nimport isStaticRules from '../utils/isStaticRules';\nimport stringifyRules from '../utils/stringifyRules';\nimport StyleSheet from './StyleSheet';\n\nimport type { RuleSet } from '../types';\n\nexport default class GlobalStyle {\n componentId: string;\n\n isStatic: boolean;\n\n rules: RuleSet;\n\n constructor(rules: RuleSet, componentId: string) {\n this.rules = rules;\n this.componentId = componentId;\n this.isStatic = isStaticRules(rules, EMPTY_ARRAY);\n\n if (!StyleSheet.master.hasId(componentId)) {\n StyleSheet.master.deferredInject(componentId, []);\n }\n }\n\n createStyles(executionContext: Object, styleSheet: StyleSheet) {\n const flatCSS = flatten(this.rules, executionContext, styleSheet);\n const css = stringifyRules(flatCSS, '');\n\n styleSheet.inject(this.componentId, css);\n }\n\n removeStyles(styleSheet: StyleSheet) {\n const { componentId } = this;\n if (styleSheet.hasId(componentId)) {\n styleSheet.remove(componentId);\n }\n }\n\n // TODO: overwrite in-place instead of remove+create?\n renderStyles(executionContext: Object, styleSheet: StyleSheet) {\n this.removeStyles(styleSheet);\n this.createStyles(executionContext, styleSheet);\n }\n}\n"],"names":["__VERSION__","i"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CC;;CAAA;;;;;;;;;;;;;;;;mCAgBgDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEA2DO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDAoSnD;;WAEMC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACjZT;;;;;;;;;;;8BAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCCQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCCiJ2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BClK3B,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -124,6 +124,11 @@ function getComponentName(target) {
|
|
|
124
124
|
return (process.env.NODE_ENV !== 'production' ? typeof target === 'string' && target : false) || target.displayName || target.name || 'Component';
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
//
|
|
128
|
+
function isStatelessFunction(test) {
|
|
129
|
+
return typeof test === 'function' && !(test.prototype && test.prototype.isReactComponent);
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
//
|
|
128
133
|
function isStyledComponent(target) {
|
|
129
134
|
return target && typeof target.styledComponentId === 'string';
|
|
@@ -200,7 +205,7 @@ var StyledComponentsError = function (_Error) {
|
|
|
200
205
|
}
|
|
201
206
|
|
|
202
207
|
if (process.env.NODE_ENV === 'production') {
|
|
203
|
-
var _this = possibleConstructorReturn(this, _Error.call(this, 'An error occurred. See https://github.com/styled-components/styled-components/blob/master/src/utils/errors.md#' + code + ' for more information. ' + (interpolations ? 'Additional arguments: ' + interpolations.join(', ') : '')));
|
|
208
|
+
var _this = possibleConstructorReturn(this, _Error.call(this, 'An error occurred. See https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/utils/errors.md#' + code + ' for more information. ' + (interpolations ? 'Additional arguments: ' + interpolations.join(', ') : '')));
|
|
204
209
|
} else {
|
|
205
210
|
var _this = possibleConstructorReturn(this, _Error.call(this, format.apply(undefined, [ERRORS[code]].concat(interpolations)).trim()));
|
|
206
211
|
}
|
|
@@ -457,7 +462,7 @@ var addUpUntilIndex = function addUpUntilIndex(sizes, index) {
|
|
|
457
462
|
var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
458
463
|
var el = document.createElement('style');
|
|
459
464
|
el.setAttribute(SC_ATTR, '');
|
|
460
|
-
el.setAttribute(SC_VERSION_ATTR, "4.
|
|
465
|
+
el.setAttribute(SC_VERSION_ATTR, "4.2.0");
|
|
461
466
|
|
|
462
467
|
var nonce = getNonce();
|
|
463
468
|
if (nonce) {
|
|
@@ -486,7 +491,7 @@ var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
|
486
491
|
var wrapAsHtmlTag = function wrapAsHtmlTag(css, names) {
|
|
487
492
|
return function (additionalAttrs) {
|
|
488
493
|
var nonce = getNonce();
|
|
489
|
-
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.
|
|
494
|
+
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.2.0" + '"', additionalAttrs];
|
|
490
495
|
|
|
491
496
|
var htmlAttr = attrs.filter(Boolean).join(' ');
|
|
492
497
|
return '<style ' + htmlAttr + '>' + css() + '</style>';
|
|
@@ -498,7 +503,7 @@ var wrapAsElement = function wrapAsElement(css, names) {
|
|
|
498
503
|
return function () {
|
|
499
504
|
var _props;
|
|
500
505
|
|
|
501
|
-
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.
|
|
506
|
+
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.2.0", _props);
|
|
502
507
|
|
|
503
508
|
var nonce = getNonce();
|
|
504
509
|
if (nonce) {
|
|
@@ -905,7 +910,7 @@ var StyleSheet = function () {
|
|
|
905
910
|
var isStreamed = false;
|
|
906
911
|
|
|
907
912
|
/* retrieve all of our SSR style elements from the DOM */
|
|
908
|
-
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.
|
|
913
|
+
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.2.0" + '"]');
|
|
909
914
|
|
|
910
915
|
var nodesSize = nodes.length;
|
|
911
916
|
|
|
@@ -1279,23 +1284,15 @@ function flatten(chunk, executionContext, styleSheet) {
|
|
|
1279
1284
|
|
|
1280
1285
|
/* Either execute or defer the function */
|
|
1281
1286
|
if (isFunction(chunk)) {
|
|
1282
|
-
if (executionContext) {
|
|
1283
|
-
var
|
|
1284
|
-
|
|
1285
|
-
try {
|
|
1286
|
-
// eslint-disable-next-line new-cap
|
|
1287
|
-
if (isElement(new chunk(executionContext))) {
|
|
1288
|
-
shouldThrow = true;
|
|
1289
|
-
}
|
|
1290
|
-
} catch (e) {
|
|
1291
|
-
/* */
|
|
1292
|
-
}
|
|
1287
|
+
if (isStatelessFunction(chunk) && executionContext) {
|
|
1288
|
+
var _result = chunk(executionContext);
|
|
1293
1289
|
|
|
1294
|
-
if (
|
|
1295
|
-
|
|
1290
|
+
if (process.env.NODE_ENV !== 'production' && isElement(_result)) {
|
|
1291
|
+
// eslint-disable-next-line no-console
|
|
1292
|
+
console.warn(getComponentName(chunk) + ' is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.');
|
|
1296
1293
|
}
|
|
1297
1294
|
|
|
1298
|
-
return flatten(
|
|
1295
|
+
return flatten(_result, executionContext, styleSheet);
|
|
1299
1296
|
} else return chunk;
|
|
1300
1297
|
}
|
|
1301
1298
|
|
|
@@ -1745,6 +1742,8 @@ var ThemeProvider = function (_Component) {
|
|
|
1745
1742
|
|
|
1746
1743
|
//
|
|
1747
1744
|
|
|
1745
|
+
var CLOSING_TAG_R = /^\s*<\/[a-z]/i;
|
|
1746
|
+
|
|
1748
1747
|
var ServerStyleSheet = function () {
|
|
1749
1748
|
function ServerStyleSheet() {
|
|
1750
1749
|
classCallCheck(this, ServerStyleSheet);
|
|
@@ -1821,8 +1820,15 @@ var ServerStyleSheet = function () {
|
|
|
1821
1820
|
/* force our StyleSheets to emit entirely new tags */
|
|
1822
1821
|
instance.sealAllTags();
|
|
1823
1822
|
|
|
1824
|
-
|
|
1825
|
-
|
|
1823
|
+
var renderedHtml = chunk.toString();
|
|
1824
|
+
|
|
1825
|
+
/* prepend style html to chunk, unless the start of the chunk is a closing tag in which case append right after that */
|
|
1826
|
+
if (CLOSING_TAG_R.test(renderedHtml)) {
|
|
1827
|
+
var endOfClosingTag = renderedHtml.indexOf('>');
|
|
1828
|
+
|
|
1829
|
+
this.push(renderedHtml.slice(0, endOfClosingTag + 1) + html + renderedHtml.slice(endOfClosingTag + 1));
|
|
1830
|
+
} else this.push(html + renderedHtml);
|
|
1831
|
+
|
|
1826
1832
|
callback();
|
|
1827
1833
|
}
|
|
1828
1834
|
});
|
|
@@ -1830,6 +1836,7 @@ var ServerStyleSheet = function () {
|
|
|
1830
1836
|
readableStream.on('end', function () {
|
|
1831
1837
|
return _this.seal();
|
|
1832
1838
|
});
|
|
1839
|
+
|
|
1833
1840
|
readableStream.on('error', function (err) {
|
|
1834
1841
|
_this.seal();
|
|
1835
1842
|
|
|
@@ -1846,7 +1853,6 @@ var ServerStyleSheet = function () {
|
|
|
1846
1853
|
//
|
|
1847
1854
|
|
|
1848
1855
|
var StyleSheetContext = createContext();
|
|
1849
|
-
|
|
1850
1856
|
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1851
1857
|
|
|
1852
1858
|
var StyleSheetManager = function (_Component) {
|
|
@@ -1918,7 +1924,7 @@ var classNameUsageCheckInjector = (function (target) {
|
|
|
1918
1924
|
|
|
1919
1925
|
didWarnAboutClassNameUsage.add(forwardTarget);
|
|
1920
1926
|
|
|
1921
|
-
var classNames = elementClassName.replace(
|
|
1927
|
+
var classNames = elementClassName.replace(/\s+/g, ' ').trim().split(' ');
|
|
1922
1928
|
// eslint-disable-next-line react/no-find-dom-node
|
|
1923
1929
|
var node = ReactDOM.findDOMNode(this);
|
|
1924
1930
|
var selector = classNames.map(function (s) {
|
|
@@ -1928,6 +1934,7 @@ var classNameUsageCheckInjector = (function (target) {
|
|
|
1928
1934
|
if (node && node.nodeType === 1 && !classNames.every(function (className) {
|
|
1929
1935
|
return node.classList && node.classList.contains(className);
|
|
1930
1936
|
}) && !node.querySelector(selector)) {
|
|
1937
|
+
// eslint-disable-next-line no-console
|
|
1931
1938
|
console.warn('It looks like you\'ve wrapped styled() around your React component (' + getComponentName(forwardTarget) + '), but the className prop is not being passed down to a child. No styles will be rendered unless className is composed within your React component.');
|
|
1932
1939
|
}
|
|
1933
1940
|
};
|
|
@@ -2067,7 +2074,9 @@ var StyledComponent = function (_Component) {
|
|
|
2067
2074
|
this.warnInnerRef(displayName);
|
|
2068
2075
|
}
|
|
2069
2076
|
|
|
2070
|
-
if (key === 'forwardedComponent' || key === 'as'
|
|
2077
|
+
if (key === 'forwardedComponent' || key === 'as' || key === 'suppressClassNameWarning') {
|
|
2078
|
+
continue;
|
|
2079
|
+
} else if (key === 'forwardedRef') propsForElement.ref = computedProps[key];else if (!isTargetTag || validAttr(key)) {
|
|
2071
2080
|
// Don't pass through non HTML tags through to HTML elements
|
|
2072
2081
|
propsForElement[key] = computedProps[key];
|
|
2073
2082
|
}
|
|
@@ -2253,7 +2262,7 @@ function createStyledComponent(target, options, rules) {
|
|
|
2253
2262
|
var domElements = ['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',
|
|
2254
2263
|
|
|
2255
2264
|
// SVG
|
|
2256
|
-
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
|
2265
|
+
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'marker', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
|
2257
2266
|
|
|
2258
2267
|
//
|
|
2259
2268
|
|
|
@@ -2431,6 +2440,7 @@ var replaceWhitespace = function replaceWhitespace(str) {
|
|
|
2431
2440
|
function keyframes(strings) {
|
|
2432
2441
|
/* Warning if you've used keyframes on React Native */
|
|
2433
2442
|
if (process.env.NODE_ENV !== 'production' && typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
|
2443
|
+
// eslint-disable-next-line no-console
|
|
2434
2444
|
console.warn('`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.');
|
|
2435
2445
|
}
|
|
2436
2446
|
|
|
@@ -2506,16 +2516,18 @@ if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test' &&
|
|
|
2506
2516
|
|
|
2507
2517
|
var styled$1 = /*#__PURE__*/Object.freeze({
|
|
2508
2518
|
default: styled,
|
|
2509
|
-
css: css,
|
|
2510
|
-
keyframes: keyframes,
|
|
2511
2519
|
createGlobalStyle: createGlobalStyle,
|
|
2520
|
+
css: css,
|
|
2512
2521
|
isStyledComponent: isStyledComponent,
|
|
2522
|
+
keyframes: keyframes,
|
|
2523
|
+
ServerStyleSheet: ServerStyleSheet,
|
|
2524
|
+
StyleSheetConsumer: StyleSheetConsumer,
|
|
2525
|
+
StyleSheetContext: StyleSheetContext,
|
|
2526
|
+
StyleSheetManager: StyleSheetManager,
|
|
2513
2527
|
ThemeConsumer: ThemeConsumer,
|
|
2514
2528
|
ThemeContext: ThemeContext,
|
|
2515
2529
|
ThemeProvider: ThemeProvider,
|
|
2516
2530
|
withTheme: withTheme,
|
|
2517
|
-
ServerStyleSheet: ServerStyleSheet,
|
|
2518
|
-
StyleSheetManager: StyleSheetManager,
|
|
2519
2531
|
__DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS: __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS
|
|
2520
2532
|
});
|
|
2521
2533
|
|