styled-components 4.3.1 → 4.4.1
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/README.md +28 -4
- package/dist/styled-components-macro.cjs.js +3 -2
- package/dist/styled-components-macro.cjs.js.map +1 -1
- package/dist/styled-components-macro.esm.js +3 -2
- package/dist/styled-components-macro.esm.js.map +1 -1
- package/dist/styled-components.browser.cjs.js +27 -24
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +27 -24
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +27 -24
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +27 -24
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +28 -25
- 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 +27 -19
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +48 -39
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/package.json +3 -2
- package/primitives/dist/styled-components-primitives.cjs.js +20 -15
- package/primitives/dist/styled-components-primitives.cjs.js.map +1 -1
- package/primitives/dist/styled-components-primitives.esm.js +20 -15
- package/primitives/dist/styled-components-primitives.esm.js.map +1 -1
|
@@ -14,8 +14,6 @@ var supportsColor = _interopDefault(require('supports-color'));
|
|
|
14
14
|
var transformDeclPairs = _interopDefault(require('css-to-react-native'));
|
|
15
15
|
var memoize = _interopDefault(require('memoize-one'));
|
|
16
16
|
var merge = _interopDefault(require('merge-anything'));
|
|
17
|
-
var reactNative = require('react-native');
|
|
18
|
-
var reactNative__default = _interopDefault(reactNative);
|
|
19
17
|
|
|
20
18
|
//
|
|
21
19
|
// Source: https://github.com/garycourt/murmurhash-js/blob/master/murmurhash2_gc.js
|
|
@@ -172,7 +170,7 @@ var ERRORS = process.env.NODE_ENV !== 'production' ? {
|
|
|
172
170
|
"9": "Missing document `<head>`\n\n",
|
|
173
171
|
"10": "Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",
|
|
174
172
|
"11": "_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",
|
|
175
|
-
"12": "It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper
|
|
173
|
+
"12": "It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",
|
|
176
174
|
"13": "%s 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.\n"
|
|
177
175
|
} : {};
|
|
178
176
|
|
|
@@ -390,9 +388,9 @@ var sheetForTag = function sheetForTag(tag) {
|
|
|
390
388
|
if (tag.sheet) return tag.sheet;
|
|
391
389
|
|
|
392
390
|
/* Firefox quirk requires us to step through all stylesheets to find one owned by the given tag */
|
|
393
|
-
var size =
|
|
391
|
+
var size = tag.ownerDocument.styleSheets.length;
|
|
394
392
|
for (var i = 0; i < size; i += 1) {
|
|
395
|
-
var sheet =
|
|
393
|
+
var sheet = tag.ownerDocument.styleSheets[i];
|
|
396
394
|
// $FlowFixMe
|
|
397
395
|
if (sheet.ownerNode === tag) return sheet;
|
|
398
396
|
}
|
|
@@ -446,9 +444,12 @@ var addUpUntilIndex = function addUpUntilIndex(sizes, index) {
|
|
|
446
444
|
|
|
447
445
|
/* create a new style tag after lastEl */
|
|
448
446
|
var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
449
|
-
var
|
|
447
|
+
var targetDocument = document;
|
|
448
|
+
if (target) targetDocument = target.ownerDocument;else if (tagEl) targetDocument = tagEl.ownerDocument;
|
|
449
|
+
|
|
450
|
+
var el = targetDocument.createElement('style');
|
|
450
451
|
el.setAttribute(SC_ATTR, '');
|
|
451
|
-
el.setAttribute(SC_VERSION_ATTR, "4.
|
|
452
|
+
el.setAttribute(SC_VERSION_ATTR, "4.4.1");
|
|
452
453
|
|
|
453
454
|
var nonce = getNonce();
|
|
454
455
|
if (nonce) {
|
|
@@ -456,7 +457,7 @@ var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
|
456
457
|
}
|
|
457
458
|
|
|
458
459
|
/* Work around insertRule quirk in EdgeHTML */
|
|
459
|
-
el.appendChild(
|
|
460
|
+
el.appendChild(targetDocument.createTextNode(''));
|
|
460
461
|
|
|
461
462
|
if (target && !tagEl) {
|
|
462
463
|
/* Append to target when no previous element was passed */
|
|
@@ -477,7 +478,7 @@ var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
|
477
478
|
var wrapAsHtmlTag = function wrapAsHtmlTag(css, names) {
|
|
478
479
|
return function (additionalAttrs) {
|
|
479
480
|
var nonce = getNonce();
|
|
480
|
-
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.
|
|
481
|
+
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.4.1" + '"', additionalAttrs];
|
|
481
482
|
|
|
482
483
|
var htmlAttr = attrs.filter(Boolean).join(' ');
|
|
483
484
|
return '<style ' + htmlAttr + '>' + css() + '</style>';
|
|
@@ -489,7 +490,7 @@ var wrapAsElement = function wrapAsElement(css, names) {
|
|
|
489
490
|
return function () {
|
|
490
491
|
var _props;
|
|
491
492
|
|
|
492
|
-
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.
|
|
493
|
+
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.4.1", _props);
|
|
493
494
|
|
|
494
495
|
var nonce = getNonce();
|
|
495
496
|
if (nonce) {
|
|
@@ -564,6 +565,8 @@ var makeSpeedyTag = function makeSpeedyTag(el, getImportRuleTag) {
|
|
|
564
565
|
var removeRules = function removeRules(id) {
|
|
565
566
|
var marker = markers[id];
|
|
566
567
|
if (marker === undefined) return;
|
|
568
|
+
// $FlowFixMe
|
|
569
|
+
if (el.isConnected === false) return;
|
|
567
570
|
|
|
568
571
|
var size = sizes[marker];
|
|
569
572
|
var sheet = sheetForTag(el);
|
|
@@ -619,8 +622,8 @@ var makeSpeedyTag = function makeSpeedyTag(el, getImportRuleTag) {
|
|
|
619
622
|
};
|
|
620
623
|
};
|
|
621
624
|
|
|
622
|
-
var makeTextNode = function makeTextNode(id) {
|
|
623
|
-
return
|
|
625
|
+
var makeTextNode = function makeTextNode(targetDocument, id) {
|
|
626
|
+
return targetDocument.createTextNode(makeTextMarker(id));
|
|
624
627
|
};
|
|
625
628
|
|
|
626
629
|
var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
|
|
@@ -638,7 +641,7 @@ var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
|
|
|
638
641
|
return prev;
|
|
639
642
|
}
|
|
640
643
|
|
|
641
|
-
markers[id] = makeTextNode(id);
|
|
644
|
+
markers[id] = makeTextNode(el.ownerDocument, id);
|
|
642
645
|
el.appendChild(markers[id]);
|
|
643
646
|
names[id] = Object.create(null);
|
|
644
647
|
|
|
@@ -676,7 +679,7 @@ var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
|
|
|
676
679
|
if (marker === undefined) return;
|
|
677
680
|
|
|
678
681
|
/* create new empty text node and replace the current one */
|
|
679
|
-
var newMarker = makeTextNode(id);
|
|
682
|
+
var newMarker = makeTextNode(el.ownerDocument, id);
|
|
680
683
|
el.replaceChild(newMarker, marker);
|
|
681
684
|
markers[id] = newMarker;
|
|
682
685
|
resetIdNames(names, id);
|
|
@@ -896,7 +899,7 @@ var StyleSheet = function () {
|
|
|
896
899
|
var isStreamed = false;
|
|
897
900
|
|
|
898
901
|
/* retrieve all of our SSR style elements from the DOM */
|
|
899
|
-
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.
|
|
902
|
+
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.4.1" + '"]');
|
|
900
903
|
|
|
901
904
|
var nodesSize = nodes.length;
|
|
902
905
|
|
|
@@ -6131,7 +6134,7 @@ var ThemeProvider = function (_Component) {
|
|
|
6131
6134
|
return React__default.createElement(
|
|
6132
6135
|
ThemeContext.Provider,
|
|
6133
6136
|
{ value: context },
|
|
6134
|
-
|
|
6137
|
+
this.props.children
|
|
6135
6138
|
);
|
|
6136
6139
|
};
|
|
6137
6140
|
|
|
@@ -6227,7 +6230,7 @@ var StyledNativeComponent = function (_Component) {
|
|
|
6227
6230
|
|
|
6228
6231
|
var generatedStyles = _this2.generateAndInjectStyles(determineTheme(_this2.props, theme, defaultProps) || EMPTY_OBJECT, _this2.props);
|
|
6229
6232
|
|
|
6230
|
-
var propsForElement = _extends({}, _this2.attrs,
|
|
6233
|
+
var propsForElement = _extends({}, props, _this2.attrs, {
|
|
6231
6234
|
style: [generatedStyles].concat(style)
|
|
6232
6235
|
});
|
|
6233
6236
|
|
|
@@ -6492,7 +6495,12 @@ var withTheme = (function (Component) {
|
|
|
6492
6495
|
|
|
6493
6496
|
//
|
|
6494
6497
|
|
|
6495
|
-
var
|
|
6498
|
+
var reactNative = require('react-native');
|
|
6499
|
+
|
|
6500
|
+
var StyleSheet$1 = reactNative.StyleSheet;
|
|
6501
|
+
|
|
6502
|
+
|
|
6503
|
+
var InlineStyle = _InlineStyle(StyleSheet$1);
|
|
6496
6504
|
var StyledNativeComponent$1 = _StyledNativeComponent(InlineStyle);
|
|
6497
6505
|
var styled = function styled(tag) {
|
|
6498
6506
|
return constructWithOptions(StyledNativeComponent$1, tag);
|
|
@@ -6509,7 +6517,7 @@ aliases.split(/\s+/m).forEach(function (alias) {
|
|
|
6509
6517
|
enumerable: true,
|
|
6510
6518
|
configurable: false,
|
|
6511
6519
|
get: function get() {
|
|
6512
|
-
return styled(
|
|
6520
|
+
return styled(reactNative[alias]);
|
|
6513
6521
|
}
|
|
6514
6522
|
});
|
|
6515
6523
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled-components.native.cjs.js","sources":["../../src/models/StyleTags.js","../../src/models/InlineStyle.js","../../src/models/ThemeProvider.js","../../src/models/StyledNativeComponent.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\n/* eslint-disable import/no-unresolved */\nimport transformDeclPairs from 'css-to-react-native';\n\n// $FlowFixMe\nimport hashStr from '../vendor/glamor/hash';\nimport type { RuleSet, StyleSheet } from '../types';\nimport flatten from '../utils/flatten';\n// $FlowFixMe\nimport parse from '../vendor/postcss-safe-parser/parse';\n\nlet generated = {};\n\nexport const resetStyleCache = () => {\n generated = {};\n};\n\n/*\n InlineStyle takes arbitrary CSS and generates a flat object\n */\nexport default (styleSheet: StyleSheet) => {\n class InlineStyle {\n rules: RuleSet;\n\n constructor(rules: RuleSet) {\n this.rules = rules;\n }\n\n generateStyleObject(executionContext: Object) {\n const flatCSS = flatten(this.rules, executionContext).join('');\n\n const hash = hashStr(flatCSS);\n if (!generated[hash]) {\n const root = parse(flatCSS);\n const declPairs = [];\n root.each(node => {\n if (node.type === 'decl') {\n declPairs.push([node.prop, node.value]);\n } else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {\n /* eslint-disable no-console */\n console.warn(`Node of type ${node.type} not supported as an inline style`);\n }\n });\n // RN currently does not support differing values for the corner radii of Image\n // components (but does for View). It is almost impossible to tell whether we'll have\n // support, so we'll just disable multiple values here.\n // https://github.com/styled-components/css-to-react-native/issues/11\n const styleObject = transformDeclPairs(declPairs, [\n 'borderRadius',\n 'borderWidth',\n 'borderColor',\n 'borderStyle',\n ]);\n const styles = styleSheet.create({\n generated: styleObject,\n });\n generated[hash] = styles.generated;\n }\n return generated[hash];\n }\n }\n\n return InlineStyle;\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 merge from 'merge-anything';\nimport React, { createElement, Component } from 'react';\nimport determineTheme from '../utils/determineTheme';\nimport { EMPTY_ARRAY, EMPTY_OBJECT } from '../utils/empties';\nimport generateDisplayName from '../utils/generateDisplayName';\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 { ThemeConsumer } from './ThemeProvider';\n\nimport type { Theme } from './ThemeProvider';\nimport type { Attrs, RuleSet, Target } from '../types';\n\nclass StyledNativeComponent extends Component<*, *> {\n root: ?Object;\n\n warnInnerRef: Function;\n\n warnAttrsFnObjectKeyDeprecated: Function;\n\n warnNonStyledComponentAttrsObjectKey: Function;\n\n attrs = {};\n\n constructor(props) {\n super(props);\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 ${new Error().stack}`\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\n render() {\n return (\n <ThemeConsumer>\n {(theme?: Theme) => {\n const {\n as: renderAs,\n forwardedAs,\n forwardedComponent,\n forwardedRef,\n innerRef,\n style = [],\n ...props\n } = this.props;\n\n const { defaultProps, displayName, target } = forwardedComponent;\n\n const generatedStyles = this.generateAndInjectStyles(\n determineTheme(this.props, theme, defaultProps) || EMPTY_OBJECT,\n this.props\n );\n\n const propsForElement = {\n ...this.attrs,\n ...props,\n style: [generatedStyles].concat(style),\n };\n\n if (forwardedAs) propsForElement.as = forwardedAs;\n if (forwardedRef) propsForElement.ref = forwardedRef;\n\n if (process.env.NODE_ENV !== 'production' && innerRef) {\n this.warnInnerRef(displayName);\n }\n\n return createElement(renderAs || target, propsForElement);\n }}\n </ThemeConsumer>\n );\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 resolvedAttrDef = resolvedAttrDef(context);\n attrDefWasFn = true;\n }\n\n /* eslint-disable guard-for-in */\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, this.props.forwardedComponent.displayName);\n }\n\n attr = attr(context);\n\n if (process.env.NODE_ENV !== 'production' && React.isValidElement(attr)) {\n this.warnNonStyledComponentAttrsObjectKey(\n key,\n this.props.forwardedComponent.displayName\n );\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 { inlineStyle } = props.forwardedComponent;\n\n const executionContext = this.buildExecutionContext(\n theme,\n props,\n props.forwardedComponent.attrs\n );\n\n return inlineStyle.generateStyleObject(executionContext);\n }\n\n setNativeProps(nativeProps: Object) {\n if (this.root !== undefined) {\n // $FlowFixMe\n this.root.setNativeProps(nativeProps);\n } else if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n 'setNativeProps was called on a Styled Component wrapping a stateless functional component.'\n );\n }\n }\n}\n\nexport default (InlineStyle: Function) => {\n const createStyledNativeComponent = (target: Target, options: Object, rules: RuleSet) => {\n const {\n attrs = EMPTY_ARRAY,\n displayName = generateDisplayName(target),\n ParentComponent = StyledNativeComponent,\n } = options;\n\n const isClass = !isTag(target);\n const isTargetStyledComp = isStyledComponent(target);\n\n // $FlowFixMe\n const WrappedStyledNativeComponent = React.forwardRef((props, ref) => (\n <ParentComponent\n {...props}\n forwardedComponent={WrappedStyledNativeComponent}\n forwardedRef={ref}\n />\n ));\n\n const finalAttrs =\n // $FlowFixMe\n isTargetStyledComp && target.attrs\n ? Array.prototype.concat(target.attrs, attrs).filter(Boolean)\n : attrs;\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\n // $FlowFixMe\n WrappedStyledNativeComponent.attrs = finalAttrs;\n\n WrappedStyledNativeComponent.displayName = displayName;\n\n // $FlowFixMe\n WrappedStyledNativeComponent.inlineStyle = new InlineStyle(\n // $FlowFixMe\n isTargetStyledComp ? target.inlineStyle.rules.concat(rules) : rules\n );\n\n // $FlowFixMe\n WrappedStyledNativeComponent.styledComponentId = 'StyledNativeComponent';\n\n // $FlowFixMe\n WrappedStyledNativeComponent.target = isTargetStyledComp\n ? // $FlowFixMe\n target.target\n : target;\n\n // $FlowFixMe\n WrappedStyledNativeComponent.withComponent = function withComponent(tag: Target) {\n const { displayName: _, componentId: __, ...optionsToCopy } = options;\n const newOptions = {\n ...optionsToCopy,\n attrs: finalAttrs,\n ParentComponent,\n };\n\n return createStyledNativeComponent(tag, newOptions, rules);\n };\n\n // $FlowFixMe\n Object.defineProperty(WrappedStyledNativeComponent, 'defaultProps', {\n get() {\n return this._foldedDefaultProps;\n },\n\n set(obj) {\n // $FlowFixMe\n this._foldedDefaultProps = isTargetStyledComp ? merge(target.defaultProps, obj) : obj;\n },\n });\n\n if (isClass) {\n hoist(WrappedStyledNativeComponent, target, {\n // all SC-specific things should not be hoisted\n attrs: true,\n displayName: true,\n inlineStyle: true,\n styledComponentId: true,\n target: true,\n withComponent: true,\n });\n }\n\n return WrappedStyledNativeComponent;\n };\n\n return createStyledNativeComponent;\n};\n"],"names":["__VERSION__","i","attrs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CC;;CAAA;;;;;;;;;;;;;;;;mCAgBgDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEA2DO;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BCtYP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACXF;;;;;;;;;;;8BAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCCCA;;;;;UAFAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6FAiIkCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"styled-components.native.cjs.js","sources":["../../src/models/StyleTags.js","../../src/models/InlineStyle.js","../../src/models/ThemeProvider.js","../../src/models/StyledNativeComponent.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 let targetDocument = document;\n if(target) targetDocument = target.ownerDocument;\n else if(tagEl) targetDocument = tagEl.ownerDocument;\n\n const el = targetDocument.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(targetDocument.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 // $FlowFixMe\n if (el.isConnected === false) 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 = (targetDocument, id) => targetDocument.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(el.ownerDocument, 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(el.ownerDocument, 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\n/* eslint-disable import/no-unresolved */\nimport transformDeclPairs from 'css-to-react-native';\n\n// $FlowFixMe\nimport hashStr from '../vendor/glamor/hash';\nimport type { RuleSet, StyleSheet } from '../types';\nimport flatten from '../utils/flatten';\n// $FlowFixMe\nimport parse from '../vendor/postcss-safe-parser/parse';\n\nlet generated = {};\n\nexport const resetStyleCache = () => {\n generated = {};\n};\n\n/*\n InlineStyle takes arbitrary CSS and generates a flat object\n */\nexport default (styleSheet: StyleSheet) => {\n class InlineStyle {\n rules: RuleSet;\n\n constructor(rules: RuleSet) {\n this.rules = rules;\n }\n\n generateStyleObject(executionContext: Object) {\n const flatCSS = flatten(this.rules, executionContext).join('');\n\n const hash = hashStr(flatCSS);\n if (!generated[hash]) {\n const root = parse(flatCSS);\n const declPairs = [];\n root.each(node => {\n if (node.type === 'decl') {\n declPairs.push([node.prop, node.value]);\n } else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {\n /* eslint-disable no-console */\n console.warn(`Node of type ${node.type} not supported as an inline style`);\n }\n });\n // RN currently does not support differing values for the corner radii of Image\n // components (but does for View). It is almost impossible to tell whether we'll have\n // support, so we'll just disable multiple values here.\n // https://github.com/styled-components/css-to-react-native/issues/11\n const styleObject = transformDeclPairs(declPairs, [\n 'borderRadius',\n 'borderWidth',\n 'borderColor',\n 'borderStyle',\n ]);\n const styles = styleSheet.create({\n generated: styleObject,\n });\n generated[hash] = styles.generated;\n }\n return generated[hash];\n }\n }\n\n return InlineStyle;\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 {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 merge from 'merge-anything';\nimport React, { createElement, Component } from 'react';\nimport determineTheme from '../utils/determineTheme';\nimport { EMPTY_ARRAY, EMPTY_OBJECT } from '../utils/empties';\nimport generateDisplayName from '../utils/generateDisplayName';\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 { ThemeConsumer } from './ThemeProvider';\n\nimport type { Theme } from './ThemeProvider';\nimport type { Attrs, RuleSet, Target } from '../types';\n\nclass StyledNativeComponent extends Component<*, *> {\n root: ?Object;\n\n warnInnerRef: Function;\n\n warnAttrsFnObjectKeyDeprecated: Function;\n\n warnNonStyledComponentAttrsObjectKey: Function;\n\n attrs = {};\n\n constructor(props) {\n super(props);\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 ${new Error().stack}`\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\n render() {\n return (\n <ThemeConsumer>\n {(theme?: Theme) => {\n const {\n as: renderAs,\n forwardedAs,\n forwardedComponent,\n forwardedRef,\n innerRef,\n style = [],\n ...props\n } = this.props;\n\n const { defaultProps, displayName, target } = forwardedComponent;\n\n const generatedStyles = this.generateAndInjectStyles(\n determineTheme(this.props, theme, defaultProps) || EMPTY_OBJECT,\n this.props\n );\n\n const propsForElement = {\n ...props,\n ...this.attrs,\n style: [generatedStyles].concat(style),\n };\n\n if (forwardedAs) propsForElement.as = forwardedAs;\n if (forwardedRef) propsForElement.ref = forwardedRef;\n\n if (process.env.NODE_ENV !== 'production' && innerRef) {\n this.warnInnerRef(displayName);\n }\n\n return createElement(renderAs || target, propsForElement);\n }}\n </ThemeConsumer>\n );\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 resolvedAttrDef = resolvedAttrDef(context);\n attrDefWasFn = true;\n }\n\n /* eslint-disable guard-for-in */\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, this.props.forwardedComponent.displayName);\n }\n\n attr = attr(context);\n\n if (process.env.NODE_ENV !== 'production' && React.isValidElement(attr)) {\n this.warnNonStyledComponentAttrsObjectKey(\n key,\n this.props.forwardedComponent.displayName\n );\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 { inlineStyle } = props.forwardedComponent;\n\n const executionContext = this.buildExecutionContext(\n theme,\n props,\n props.forwardedComponent.attrs\n );\n\n return inlineStyle.generateStyleObject(executionContext);\n }\n\n setNativeProps(nativeProps: Object) {\n if (this.root !== undefined) {\n // $FlowFixMe\n this.root.setNativeProps(nativeProps);\n } else if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n 'setNativeProps was called on a Styled Component wrapping a stateless functional component.'\n );\n }\n }\n}\n\nexport default (InlineStyle: Function) => {\n const createStyledNativeComponent = (target: Target, options: Object, rules: RuleSet) => {\n const {\n attrs = EMPTY_ARRAY,\n displayName = generateDisplayName(target),\n ParentComponent = StyledNativeComponent,\n } = options;\n\n const isClass = !isTag(target);\n const isTargetStyledComp = isStyledComponent(target);\n\n // $FlowFixMe\n const WrappedStyledNativeComponent = React.forwardRef((props, ref) => (\n <ParentComponent\n {...props}\n forwardedComponent={WrappedStyledNativeComponent}\n forwardedRef={ref}\n />\n ));\n\n const finalAttrs =\n // $FlowFixMe\n isTargetStyledComp && target.attrs\n ? Array.prototype.concat(target.attrs, attrs).filter(Boolean)\n : attrs;\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\n // $FlowFixMe\n WrappedStyledNativeComponent.attrs = finalAttrs;\n\n WrappedStyledNativeComponent.displayName = displayName;\n\n // $FlowFixMe\n WrappedStyledNativeComponent.inlineStyle = new InlineStyle(\n // $FlowFixMe\n isTargetStyledComp ? target.inlineStyle.rules.concat(rules) : rules\n );\n\n // $FlowFixMe\n WrappedStyledNativeComponent.styledComponentId = 'StyledNativeComponent';\n\n // $FlowFixMe\n WrappedStyledNativeComponent.target = isTargetStyledComp\n ? // $FlowFixMe\n target.target\n : target;\n\n // $FlowFixMe\n WrappedStyledNativeComponent.withComponent = function withComponent(tag: Target) {\n const { displayName: _, componentId: __, ...optionsToCopy } = options;\n const newOptions = {\n ...optionsToCopy,\n attrs: finalAttrs,\n ParentComponent,\n };\n\n return createStyledNativeComponent(tag, newOptions, rules);\n };\n\n // $FlowFixMe\n Object.defineProperty(WrappedStyledNativeComponent, 'defaultProps', {\n get() {\n return this._foldedDefaultProps;\n },\n\n set(obj) {\n // $FlowFixMe\n this._foldedDefaultProps = isTargetStyledComp ? merge(target.defaultProps, obj) : obj;\n },\n });\n\n if (isClass) {\n hoist(WrappedStyledNativeComponent, target, {\n // all SC-specific things should not be hoisted\n attrs: true,\n displayName: true,\n inlineStyle: true,\n styledComponentId: true,\n target: true,\n withComponent: true,\n });\n }\n\n return WrappedStyledNativeComponent;\n };\n\n return createStyledNativeComponent;\n};\n"],"names":["i","attrs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CC;;CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iEA+EuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDAsSn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;8BC5YP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACXF;;;;;;;;;;;8BAUA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCCCA;;;;;UAFAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6FAiIkCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -7,7 +7,6 @@ import supportsColor from 'supports-color';
|
|
|
7
7
|
import transformDeclPairs from 'css-to-react-native';
|
|
8
8
|
import memoize from 'memoize-one';
|
|
9
9
|
import merge from 'merge-anything';
|
|
10
|
-
import reactNative, { StyleSheet } from 'react-native';
|
|
11
10
|
|
|
12
11
|
//
|
|
13
12
|
// Source: https://github.com/garycourt/murmurhash-js/blob/master/murmurhash2_gc.js
|
|
@@ -164,7 +163,7 @@ var ERRORS = process.env.NODE_ENV !== 'production' ? {
|
|
|
164
163
|
"9": "Missing document `<head>`\n\n",
|
|
165
164
|
"10": "Cannot find a StyleSheet instance. Usually this happens if there are multiple copies of styled-components loaded at once. Check out this issue for how to troubleshoot and fix the common cases where this situation can happen: https://github.com/styled-components/styled-components/issues/1941#issuecomment-417862021\n\n",
|
|
166
165
|
"11": "_This error was replaced with a dev-time warning, it will be deleted for v4 final._ [createGlobalStyle] received children which will not be rendered. Please use the component without passing children elements.\n\n",
|
|
167
|
-
"12": "It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper
|
|
166
|
+
"12": "It seems you are interpolating a keyframe declaration (%s) into an untagged string. This was supported in styled-components v3, but is not longer supported in v4 as keyframes are now injected on-demand. Please wrap your string in the css\\`\\` helper which ensures the styles are injected correctly. See https://www.styled-components.com/docs/api#css\n\n",
|
|
168
167
|
"13": "%s 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.\n"
|
|
169
168
|
} : {};
|
|
170
169
|
|
|
@@ -382,9 +381,9 @@ var sheetForTag = function sheetForTag(tag) {
|
|
|
382
381
|
if (tag.sheet) return tag.sheet;
|
|
383
382
|
|
|
384
383
|
/* Firefox quirk requires us to step through all stylesheets to find one owned by the given tag */
|
|
385
|
-
var size =
|
|
384
|
+
var size = tag.ownerDocument.styleSheets.length;
|
|
386
385
|
for (var i = 0; i < size; i += 1) {
|
|
387
|
-
var sheet =
|
|
386
|
+
var sheet = tag.ownerDocument.styleSheets[i];
|
|
388
387
|
// $FlowFixMe
|
|
389
388
|
if (sheet.ownerNode === tag) return sheet;
|
|
390
389
|
}
|
|
@@ -438,9 +437,12 @@ var addUpUntilIndex = function addUpUntilIndex(sizes, index) {
|
|
|
438
437
|
|
|
439
438
|
/* create a new style tag after lastEl */
|
|
440
439
|
var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
441
|
-
var
|
|
440
|
+
var targetDocument = document;
|
|
441
|
+
if (target) targetDocument = target.ownerDocument;else if (tagEl) targetDocument = tagEl.ownerDocument;
|
|
442
|
+
|
|
443
|
+
var el = targetDocument.createElement('style');
|
|
442
444
|
el.setAttribute(SC_ATTR, '');
|
|
443
|
-
el.setAttribute(SC_VERSION_ATTR, "4.
|
|
445
|
+
el.setAttribute(SC_VERSION_ATTR, "4.4.1");
|
|
444
446
|
|
|
445
447
|
var nonce = getNonce();
|
|
446
448
|
if (nonce) {
|
|
@@ -448,7 +450,7 @@ var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
|
448
450
|
}
|
|
449
451
|
|
|
450
452
|
/* Work around insertRule quirk in EdgeHTML */
|
|
451
|
-
el.appendChild(
|
|
453
|
+
el.appendChild(targetDocument.createTextNode(''));
|
|
452
454
|
|
|
453
455
|
if (target && !tagEl) {
|
|
454
456
|
/* Append to target when no previous element was passed */
|
|
@@ -469,7 +471,7 @@ var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
|
|
469
471
|
var wrapAsHtmlTag = function wrapAsHtmlTag(css, names) {
|
|
470
472
|
return function (additionalAttrs) {
|
|
471
473
|
var nonce = getNonce();
|
|
472
|
-
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.
|
|
474
|
+
var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.4.1" + '"', additionalAttrs];
|
|
473
475
|
|
|
474
476
|
var htmlAttr = attrs.filter(Boolean).join(' ');
|
|
475
477
|
return '<style ' + htmlAttr + '>' + css() + '</style>';
|
|
@@ -481,7 +483,7 @@ var wrapAsElement = function wrapAsElement(css, names) {
|
|
|
481
483
|
return function () {
|
|
482
484
|
var _props;
|
|
483
485
|
|
|
484
|
-
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.
|
|
486
|
+
var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.4.1", _props);
|
|
485
487
|
|
|
486
488
|
var nonce = getNonce();
|
|
487
489
|
if (nonce) {
|
|
@@ -556,6 +558,8 @@ var makeSpeedyTag = function makeSpeedyTag(el, getImportRuleTag) {
|
|
|
556
558
|
var removeRules = function removeRules(id) {
|
|
557
559
|
var marker = markers[id];
|
|
558
560
|
if (marker === undefined) return;
|
|
561
|
+
// $FlowFixMe
|
|
562
|
+
if (el.isConnected === false) return;
|
|
559
563
|
|
|
560
564
|
var size = sizes[marker];
|
|
561
565
|
var sheet = sheetForTag(el);
|
|
@@ -611,8 +615,8 @@ var makeSpeedyTag = function makeSpeedyTag(el, getImportRuleTag) {
|
|
|
611
615
|
};
|
|
612
616
|
};
|
|
613
617
|
|
|
614
|
-
var makeTextNode = function makeTextNode(id) {
|
|
615
|
-
return
|
|
618
|
+
var makeTextNode = function makeTextNode(targetDocument, id) {
|
|
619
|
+
return targetDocument.createTextNode(makeTextMarker(id));
|
|
616
620
|
};
|
|
617
621
|
|
|
618
622
|
var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
|
|
@@ -630,7 +634,7 @@ var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
|
|
|
630
634
|
return prev;
|
|
631
635
|
}
|
|
632
636
|
|
|
633
|
-
markers[id] = makeTextNode(id);
|
|
637
|
+
markers[id] = makeTextNode(el.ownerDocument, id);
|
|
634
638
|
el.appendChild(markers[id]);
|
|
635
639
|
names[id] = Object.create(null);
|
|
636
640
|
|
|
@@ -668,7 +672,7 @@ var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
|
|
|
668
672
|
if (marker === undefined) return;
|
|
669
673
|
|
|
670
674
|
/* create new empty text node and replace the current one */
|
|
671
|
-
var newMarker = makeTextNode(id);
|
|
675
|
+
var newMarker = makeTextNode(el.ownerDocument, id);
|
|
672
676
|
el.replaceChild(newMarker, marker);
|
|
673
677
|
markers[id] = newMarker;
|
|
674
678
|
resetIdNames(names, id);
|
|
@@ -826,7 +830,7 @@ if (IS_BROWSER) {
|
|
|
826
830
|
var sheetRunningId = 0;
|
|
827
831
|
var master = void 0;
|
|
828
832
|
|
|
829
|
-
var StyleSheet
|
|
833
|
+
var StyleSheet = function () {
|
|
830
834
|
|
|
831
835
|
/* a map from ids to tags */
|
|
832
836
|
|
|
@@ -844,12 +848,12 @@ var StyleSheet$1 = function () {
|
|
|
844
848
|
|
|
845
849
|
/* children (aka clones) of this StyleSheet inheriting all and future injections */
|
|
846
850
|
|
|
847
|
-
function StyleSheet
|
|
851
|
+
function StyleSheet() {
|
|
848
852
|
var _this = this;
|
|
849
853
|
|
|
850
854
|
var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : IS_BROWSER ? document.head : null;
|
|
851
855
|
var forceServer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
852
|
-
classCallCheck(this, StyleSheet
|
|
856
|
+
classCallCheck(this, StyleSheet);
|
|
853
857
|
|
|
854
858
|
this.getImportRuleTag = function () {
|
|
855
859
|
var importRuleTag = _this.importRuleTag;
|
|
@@ -880,7 +884,7 @@ var StyleSheet$1 = function () {
|
|
|
880
884
|
/* rehydrate all SSR'd style tags */
|
|
881
885
|
|
|
882
886
|
|
|
883
|
-
StyleSheet
|
|
887
|
+
StyleSheet.prototype.rehydrate = function rehydrate$$1() {
|
|
884
888
|
if (!IS_BROWSER || this.forceServer) return this;
|
|
885
889
|
|
|
886
890
|
var els = [];
|
|
@@ -888,7 +892,7 @@ var StyleSheet$1 = function () {
|
|
|
888
892
|
var isStreamed = false;
|
|
889
893
|
|
|
890
894
|
/* retrieve all of our SSR style elements from the DOM */
|
|
891
|
-
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.
|
|
895
|
+
var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.4.1" + '"]');
|
|
892
896
|
|
|
893
897
|
var nodesSize = nodes.length;
|
|
894
898
|
|
|
@@ -944,18 +948,18 @@ var StyleSheet$1 = function () {
|
|
|
944
948
|
|
|
945
949
|
|
|
946
950
|
/* reset the internal "master" instance */
|
|
947
|
-
StyleSheet
|
|
951
|
+
StyleSheet.reset = function reset() {
|
|
948
952
|
var forceServer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
949
953
|
|
|
950
|
-
master = new StyleSheet
|
|
954
|
+
master = new StyleSheet(undefined, forceServer).rehydrate();
|
|
951
955
|
};
|
|
952
956
|
|
|
953
957
|
/* adds "children" to the StyleSheet that inherit all of the parents' rules
|
|
954
958
|
* while their own rules do not affect the parent */
|
|
955
959
|
|
|
956
960
|
|
|
957
|
-
StyleSheet
|
|
958
|
-
var sheet = new StyleSheet
|
|
961
|
+
StyleSheet.prototype.clone = function clone() {
|
|
962
|
+
var sheet = new StyleSheet(this.target, this.forceServer);
|
|
959
963
|
|
|
960
964
|
/* add to clone array */
|
|
961
965
|
this.clones.push(sheet);
|
|
@@ -983,7 +987,7 @@ var StyleSheet$1 = function () {
|
|
|
983
987
|
/* force StyleSheet to create a new tag on the next injection */
|
|
984
988
|
|
|
985
989
|
|
|
986
|
-
StyleSheet
|
|
990
|
+
StyleSheet.prototype.sealAllTags = function sealAllTags() {
|
|
987
991
|
this.capacity = 1;
|
|
988
992
|
|
|
989
993
|
this.tags.forEach(function (tag) {
|
|
@@ -992,7 +996,7 @@ var StyleSheet$1 = function () {
|
|
|
992
996
|
});
|
|
993
997
|
};
|
|
994
998
|
|
|
995
|
-
StyleSheet
|
|
999
|
+
StyleSheet.prototype.makeTag = function makeTag$$1(tag) {
|
|
996
1000
|
var lastEl = tag ? tag.styleTag : null;
|
|
997
1001
|
var insertBefore = false;
|
|
998
1002
|
|
|
@@ -1000,7 +1004,7 @@ var StyleSheet$1 = function () {
|
|
|
1000
1004
|
};
|
|
1001
1005
|
|
|
1002
1006
|
/* get a tag for a given componentId, assign the componentId to one, or shard */
|
|
1003
|
-
StyleSheet
|
|
1007
|
+
StyleSheet.prototype.getTagForId = function getTagForId(id) {
|
|
1004
1008
|
/* simply return a tag, when the componentId was already assigned one */
|
|
1005
1009
|
var prev = this.tagMap[id];
|
|
1006
1010
|
if (prev !== undefined && !prev.sealed) {
|
|
@@ -1024,14 +1028,14 @@ var StyleSheet$1 = function () {
|
|
|
1024
1028
|
/* mainly for createGlobalStyle to check for its id */
|
|
1025
1029
|
|
|
1026
1030
|
|
|
1027
|
-
StyleSheet
|
|
1031
|
+
StyleSheet.prototype.hasId = function hasId(id) {
|
|
1028
1032
|
return this.tagMap[id] !== undefined;
|
|
1029
1033
|
};
|
|
1030
1034
|
|
|
1031
1035
|
/* caching layer checking id+name to already have a corresponding tag and injected rules */
|
|
1032
1036
|
|
|
1033
1037
|
|
|
1034
|
-
StyleSheet
|
|
1038
|
+
StyleSheet.prototype.hasNameForId = function hasNameForId(id, name) {
|
|
1035
1039
|
/* exception for rehydrated names which are checked separately */
|
|
1036
1040
|
if (this.ignoreRehydratedNames[id] === undefined && this.rehydratedNames[name]) {
|
|
1037
1041
|
return true;
|
|
@@ -1044,7 +1048,7 @@ var StyleSheet$1 = function () {
|
|
|
1044
1048
|
/* registers a componentId and registers it on its tag */
|
|
1045
1049
|
|
|
1046
1050
|
|
|
1047
|
-
StyleSheet
|
|
1051
|
+
StyleSheet.prototype.deferredInject = function deferredInject(id, cssRules) {
|
|
1048
1052
|
/* don't inject when the id is already registered */
|
|
1049
1053
|
if (this.tagMap[id] !== undefined) return;
|
|
1050
1054
|
|
|
@@ -1061,7 +1065,7 @@ var StyleSheet$1 = function () {
|
|
|
1061
1065
|
/* injects rules for a given id with a name that will need to be cached */
|
|
1062
1066
|
|
|
1063
1067
|
|
|
1064
|
-
StyleSheet
|
|
1068
|
+
StyleSheet.prototype.inject = function inject(id, cssRules, name) {
|
|
1065
1069
|
var clones = this.clones;
|
|
1066
1070
|
|
|
1067
1071
|
|
|
@@ -1088,7 +1092,7 @@ var StyleSheet$1 = function () {
|
|
|
1088
1092
|
/* removes all rules for a given id, which doesn't remove its marker but resets it */
|
|
1089
1093
|
|
|
1090
1094
|
|
|
1091
|
-
StyleSheet
|
|
1095
|
+
StyleSheet.prototype.remove = function remove(id) {
|
|
1092
1096
|
var tag = this.tagMap[id];
|
|
1093
1097
|
if (tag === undefined) return;
|
|
1094
1098
|
|
|
@@ -1108,13 +1112,13 @@ var StyleSheet$1 = function () {
|
|
|
1108
1112
|
this.deferred[id] = undefined;
|
|
1109
1113
|
};
|
|
1110
1114
|
|
|
1111
|
-
StyleSheet
|
|
1115
|
+
StyleSheet.prototype.toHTML = function toHTML() {
|
|
1112
1116
|
return this.tags.map(function (tag) {
|
|
1113
1117
|
return tag.toHTML();
|
|
1114
1118
|
}).join('');
|
|
1115
1119
|
};
|
|
1116
1120
|
|
|
1117
|
-
StyleSheet
|
|
1121
|
+
StyleSheet.prototype.toReactElements = function toReactElements() {
|
|
1118
1122
|
var id = this.id;
|
|
1119
1123
|
|
|
1120
1124
|
|
|
@@ -1124,10 +1128,10 @@ var StyleSheet$1 = function () {
|
|
|
1124
1128
|
});
|
|
1125
1129
|
};
|
|
1126
1130
|
|
|
1127
|
-
createClass(StyleSheet
|
|
1131
|
+
createClass(StyleSheet, null, [{
|
|
1128
1132
|
key: 'master',
|
|
1129
1133
|
get: function get$$1() {
|
|
1130
|
-
return master || (master = new StyleSheet
|
|
1134
|
+
return master || (master = new StyleSheet().rehydrate());
|
|
1131
1135
|
}
|
|
1132
1136
|
|
|
1133
1137
|
/* NOTE: This is just for backwards-compatibility with jest-styled-components */
|
|
@@ -1135,10 +1139,10 @@ var StyleSheet$1 = function () {
|
|
|
1135
1139
|
}, {
|
|
1136
1140
|
key: 'instance',
|
|
1137
1141
|
get: function get$$1() {
|
|
1138
|
-
return StyleSheet
|
|
1142
|
+
return StyleSheet.master;
|
|
1139
1143
|
}
|
|
1140
1144
|
}]);
|
|
1141
|
-
return StyleSheet
|
|
1145
|
+
return StyleSheet;
|
|
1142
1146
|
}();
|
|
1143
1147
|
|
|
1144
1148
|
//
|
|
@@ -6123,7 +6127,7 @@ var ThemeProvider = function (_Component) {
|
|
|
6123
6127
|
return React.createElement(
|
|
6124
6128
|
ThemeContext.Provider,
|
|
6125
6129
|
{ value: context },
|
|
6126
|
-
|
|
6130
|
+
this.props.children
|
|
6127
6131
|
);
|
|
6128
6132
|
};
|
|
6129
6133
|
|
|
@@ -6219,7 +6223,7 @@ var StyledNativeComponent = function (_Component) {
|
|
|
6219
6223
|
|
|
6220
6224
|
var generatedStyles = _this2.generateAndInjectStyles(determineTheme(_this2.props, theme, defaultProps) || EMPTY_OBJECT, _this2.props);
|
|
6221
6225
|
|
|
6222
|
-
var propsForElement = _extends({}, _this2.attrs,
|
|
6226
|
+
var propsForElement = _extends({}, props, _this2.attrs, {
|
|
6223
6227
|
style: [generatedStyles].concat(style)
|
|
6224
6228
|
});
|
|
6225
6229
|
|
|
@@ -6484,7 +6488,12 @@ var withTheme = (function (Component$$1) {
|
|
|
6484
6488
|
|
|
6485
6489
|
//
|
|
6486
6490
|
|
|
6487
|
-
var
|
|
6491
|
+
var reactNative = require('react-native');
|
|
6492
|
+
|
|
6493
|
+
var StyleSheet$1 = reactNative.StyleSheet;
|
|
6494
|
+
|
|
6495
|
+
|
|
6496
|
+
var InlineStyle = _InlineStyle(StyleSheet$1);
|
|
6488
6497
|
var StyledNativeComponent$1 = _StyledNativeComponent(InlineStyle);
|
|
6489
6498
|
var styled = function styled(tag) {
|
|
6490
6499
|
return constructWithOptions(StyledNativeComponent$1, tag);
|