1 | import Stylis from 'stylis/stylis.min';
|
2 | import _insertRulePlugin from 'stylis-rule-sheet';
|
3 | import React, { cloneElement, createContext, Component, createElement } from 'react';
|
4 | import unitless from '@emotion/unitless';
|
5 | import { isElement, isValidElementType, ForwardRef } from 'react-is';
|
6 | import memoize from 'memoize-one';
|
7 | import stream from 'stream';
|
8 | import PropTypes from 'prop-types';
|
9 | import ReactDOM from 'react-dom';
|
10 | import validAttr from '@emotion/is-prop-valid';
|
11 |
|
12 |
|
13 |
|
14 | var interleave = (function (strings, interpolations) {
|
15 | var result = [strings[0]];
|
16 |
|
17 | for (var i = 0, len = interpolations.length; i < len; i += 1) {
|
18 | result.push(interpolations[i], strings[i + 1]);
|
19 | }
|
20 |
|
21 | return result;
|
22 | });
|
23 |
|
24 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
25 | return typeof obj;
|
26 | } : function (obj) {
|
27 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
28 | };
|
29 |
|
30 | var classCallCheck = function (instance, Constructor) {
|
31 | if (!(instance instanceof Constructor)) {
|
32 | throw new TypeError("Cannot call a class as a function");
|
33 | }
|
34 | };
|
35 |
|
36 | var createClass = function () {
|
37 | function defineProperties(target, props) {
|
38 | for (var i = 0; i < props.length; i++) {
|
39 | var descriptor = props[i];
|
40 | descriptor.enumerable = descriptor.enumerable || false;
|
41 | descriptor.configurable = true;
|
42 | if ("value" in descriptor) descriptor.writable = true;
|
43 | Object.defineProperty(target, descriptor.key, descriptor);
|
44 | }
|
45 | }
|
46 |
|
47 | return function (Constructor, protoProps, staticProps) {
|
48 | if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
49 | if (staticProps) defineProperties(Constructor, staticProps);
|
50 | return Constructor;
|
51 | };
|
52 | }();
|
53 |
|
54 | var _extends = Object.assign || function (target) {
|
55 | for (var i = 1; i < arguments.length; i++) {
|
56 | var source = arguments[i];
|
57 |
|
58 | for (var key in source) {
|
59 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
60 | target[key] = source[key];
|
61 | }
|
62 | }
|
63 | }
|
64 |
|
65 | return target;
|
66 | };
|
67 |
|
68 | var inherits = function (subClass, superClass) {
|
69 | if (typeof superClass !== "function" && superClass !== null) {
|
70 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
71 | }
|
72 |
|
73 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
74 | constructor: {
|
75 | value: subClass,
|
76 | enumerable: false,
|
77 | writable: true,
|
78 | configurable: true
|
79 | }
|
80 | });
|
81 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
82 | };
|
83 |
|
84 | var objectWithoutProperties = function (obj, keys) {
|
85 | var target = {};
|
86 |
|
87 | for (var i in obj) {
|
88 | if (keys.indexOf(i) >= 0) continue;
|
89 | if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
|
90 | target[i] = obj[i];
|
91 | }
|
92 |
|
93 | return target;
|
94 | };
|
95 |
|
96 | var possibleConstructorReturn = function (self, call) {
|
97 | if (!self) {
|
98 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
99 | }
|
100 |
|
101 | return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
102 | };
|
103 |
|
104 |
|
105 | var isPlainObject = (function (x) {
|
106 | return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x.constructor === Object;
|
107 | });
|
108 |
|
109 |
|
110 | var EMPTY_ARRAY = Object.freeze([]);
|
111 | var EMPTY_OBJECT = Object.freeze({});
|
112 |
|
113 |
|
114 | function isFunction(test) {
|
115 | return typeof test === 'function';
|
116 | }
|
117 |
|
118 |
|
119 |
|
120 | function getComponentName(target) {
|
121 | return target.displayName || target.name || 'Component';
|
122 | }
|
123 |
|
124 |
|
125 | function isStyledComponent(target) {
|
126 | return target && typeof target.styledComponentId === 'string';
|
127 | }
|
128 |
|
129 |
|
130 |
|
131 | var SC_ATTR = typeof process !== 'undefined' && process.env.SC_ATTR || 'data-styled';
|
132 |
|
133 | var SC_VERSION_ATTR = 'data-styled-version';
|
134 |
|
135 | var SC_STREAM_ATTR = 'data-styled-streamed';
|
136 |
|
137 | var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
138 |
|
139 | var DISABLE_SPEEDY = typeof SC_DISABLE_SPEEDY === 'boolean' && SC_DISABLE_SPEEDY || process.env.NODE_ENV !== 'production';
|
140 |
|
141 |
|
142 | var STATIC_EXECUTION_CONTEXT = {};
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | var ERRORS = process.env.NODE_ENV !== 'production' ? {
|
151 | "1": "Cannot create styled-component for component: %s.\n\n",
|
152 | "2": "Can't collect styles once you've consumed a `ServerStyleSheet`'s styles! `ServerStyleSheet` is a one off instance for each server-side render cycle.\n\n- Are you trying to reuse it across renders?\n- Are you accidentally calling collectStyles twice?\n\n",
|
153 | "3": "Streaming SSR is only supported in a Node.js environment; Please do not try to call this method in the browser.\n\n",
|
154 | "4": "The `StyleSheetManager` expects a valid target or sheet prop!\n\n- Does this error occur on the client and is your target falsy?\n- Does this error occur on the server and is the sheet falsy?\n\n",
|
155 | "5": "The clone method cannot be used on the client!\n\n- Are you running in a client-like environment on the server?\n- Are you trying to run SSR on the client?\n\n",
|
156 | "6": "Trying to insert a new style tag, but the given Node is unmounted!\n\n- Are you using a custom target that isn't mounted?\n- Does your document not have a valid head element?\n- Have you accidentally removed a style tag manually?\n\n",
|
157 | "7": "ThemeProvider: Please return an object from your \"theme\" prop function, e.g.\n\n```js\ntheme={() => ({})}\n```\n\n",
|
158 | "8": "ThemeProvider: Please make your \"theme\" prop an object.\n\n",
|
159 | "9": "Missing document `<head>`\n\n",
|
160 | "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",
|
161 | "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",
|
162 | "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 (see https://www.styled-components.com/docs/api#css), which ensures the styles are injected correctly.\n\n",
|
163 | "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"
|
164 | } : {};
|
165 |
|
166 |
|
167 |
|
168 |
|
169 | function format() {
|
170 | var a = arguments.length <= 0 ? undefined : arguments[0];
|
171 | var b = [];
|
172 |
|
173 | for (var c = 1, len = arguments.length; c < len; c += 1) {
|
174 | b.push(arguments.length <= c ? undefined : arguments[c]);
|
175 | }
|
176 |
|
177 | b.forEach(function (d) {
|
178 | a = a.replace(/%[a-z]/, d);
|
179 | });
|
180 |
|
181 | return a;
|
182 | }
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 | var StyledComponentsError = function (_Error) {
|
190 | inherits(StyledComponentsError, _Error);
|
191 |
|
192 | function StyledComponentsError(code) {
|
193 | classCallCheck(this, StyledComponentsError);
|
194 |
|
195 | for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
196 | interpolations[_key - 1] = arguments[_key];
|
197 | }
|
198 |
|
199 | if (process.env.NODE_ENV === 'production') {
|
200 | 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(', ') : '')));
|
201 | } else {
|
202 | var _this = possibleConstructorReturn(this, _Error.call(this, format.apply(undefined, [ERRORS[code]].concat(interpolations)).trim()));
|
203 | }
|
204 | return possibleConstructorReturn(_this);
|
205 | }
|
206 |
|
207 | return StyledComponentsError;
|
208 | }(Error);
|
209 |
|
210 |
|
211 | var SC_COMPONENT_ID = /^[^\S\n]*?\/\* sc-component-id:\s*(\S+)\s+\*\//gm;
|
212 |
|
213 | var extractComps = (function (maybeCSS) {
|
214 | var css = '' + (maybeCSS || '');
|
215 | var existingComponents = [];
|
216 | css.replace(SC_COMPONENT_ID, function (match, componentId, matchIndex) {
|
217 | existingComponents.push({ componentId: componentId, matchIndex: matchIndex });
|
218 | return match;
|
219 | });
|
220 | return existingComponents.map(function (_ref, i) {
|
221 | var componentId = _ref.componentId,
|
222 | matchIndex = _ref.matchIndex;
|
223 |
|
224 | var nextComp = existingComponents[i + 1];
|
225 | var cssFromDOM = nextComp ? css.slice(matchIndex, nextComp.matchIndex) : css.slice(matchIndex);
|
226 | return { componentId: componentId, cssFromDOM: cssFromDOM };
|
227 | });
|
228 | });
|
229 |
|
230 |
|
231 |
|
232 | var COMMENT_REGEX = /^\s*\/\/.*$/gm;
|
233 |
|
234 |
|
235 | var stylisSplitter = new Stylis({
|
236 | global: false,
|
237 | cascade: true,
|
238 | keyframe: false,
|
239 | prefix: false,
|
240 | compress: false,
|
241 | semicolon: true
|
242 | });
|
243 |
|
244 | var stylis = new Stylis({
|
245 | global: false,
|
246 | cascade: true,
|
247 | keyframe: false,
|
248 | prefix: true,
|
249 | compress: false,
|
250 | semicolon: false
|
251 | });
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 | var parsingRules = [];
|
258 |
|
259 |
|
260 | var returnRulesPlugin = function returnRulesPlugin(context) {
|
261 | if (context === -2) {
|
262 | var parsedRules = parsingRules;
|
263 | parsingRules = [];
|
264 | return parsedRules;
|
265 | }
|
266 | };
|
267 |
|
268 | var parseRulesPlugin = _insertRulePlugin(function (rule) {
|
269 | parsingRules.push(rule);
|
270 | });
|
271 |
|
272 | var _componentId = void 0;
|
273 | var _selector = void 0;
|
274 | var _selectorRegexp = void 0;
|
275 |
|
276 | var selfReferenceReplacer = function selfReferenceReplacer(match, offset, string) {
|
277 | if (
|
278 |
|
279 | offset > 0 &&
|
280 |
|
281 | string.slice(0, offset).indexOf(_selector) !== -1 &&
|
282 |
|
283 | string.slice(offset - _selector.length, offset) !== _selector) {
|
284 | return '.' + _componentId;
|
285 | }
|
286 |
|
287 | return match;
|
288 | };
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 | var selfReferenceReplacementPlugin = function selfReferenceReplacementPlugin(context, _, selectors) {
|
301 | if (context === 2 && selectors.length && selectors[0].lastIndexOf(_selector) > 0) {
|
302 |
|
303 | selectors[0] = selectors[0].replace(_selectorRegexp, selfReferenceReplacer);
|
304 | }
|
305 | };
|
306 |
|
307 | stylis.use([selfReferenceReplacementPlugin, parseRulesPlugin, returnRulesPlugin]);
|
308 | stylisSplitter.use([parseRulesPlugin, returnRulesPlugin]);
|
309 |
|
310 | var splitByRules = function splitByRules(css) {
|
311 | return stylisSplitter('', css);
|
312 | };
|
313 |
|
314 | function stringifyRules(rules, selector, prefix) {
|
315 | var componentId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '&';
|
316 |
|
317 | var flatCSS = rules.join('').replace(COMMENT_REGEX, '');
|
318 |
|
319 | var cssStr = selector && prefix ? prefix + ' ' + selector + ' { ' + flatCSS + ' }' : flatCSS;
|
320 |
|
321 |
|
322 |
|
323 |
|
324 | _componentId = componentId;
|
325 | _selector = selector;
|
326 | _selectorRegexp = new RegExp('\\' + _selector + '\\b', 'g');
|
327 |
|
328 | return stylis(prefix || !selector ? '' : selector, cssStr);
|
329 | }
|
330 |
|
331 |
|
332 |
|
333 |
|
334 | var getNonce = (function () {
|
335 | return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
|
336 | });
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 |
|
344 |
|
345 |
|
346 | var addNameForId = function addNameForId(names, id, name) {
|
347 | if (name) {
|
348 |
|
349 | var namesForId = names[id] || (names[id] = Object.create(null));
|
350 | namesForId[name] = true;
|
351 | }
|
352 | };
|
353 |
|
354 |
|
355 | var resetIdNames = function resetIdNames(names, id) {
|
356 |
|
357 | names[id] = Object.create(null);
|
358 | };
|
359 |
|
360 |
|
361 | var hasNameForId = function hasNameForId(names) {
|
362 | return function (id, name) {
|
363 | return names[id] !== undefined && names[id][name];
|
364 | };
|
365 | };
|
366 |
|
367 |
|
368 | var stringifyNames = function stringifyNames(names) {
|
369 | var str = '';
|
370 |
|
371 | for (var id in names) {
|
372 | str += Object.keys(names[id]).join(' ') + ' ';
|
373 | }
|
374 | return str.trim();
|
375 | };
|
376 |
|
377 |
|
378 | var cloneNames = function cloneNames(names) {
|
379 | var clone = Object.create(null);
|
380 |
|
381 | for (var id in names) {
|
382 | clone[id] = _extends({}, names[id]);
|
383 | }
|
384 | return clone;
|
385 | };
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 | var sheetForTag = function sheetForTag(tag) {
|
395 |
|
396 | if (tag.sheet) return tag.sheet;
|
397 |
|
398 |
|
399 | var size = document.styleSheets.length;
|
400 | for (var i = 0; i < size; i += 1) {
|
401 | var sheet = document.styleSheets[i];
|
402 |
|
403 | if (sheet.ownerNode === tag) return sheet;
|
404 | }
|
405 |
|
406 |
|
407 | throw new StyledComponentsError(10);
|
408 | };
|
409 |
|
410 |
|
411 | var safeInsertRule = function safeInsertRule(sheet, cssRule, index) {
|
412 |
|
413 | if (!cssRule) return false;
|
414 |
|
415 | var maxIndex = sheet.cssRules.length;
|
416 |
|
417 | try {
|
418 |
|
419 | sheet.insertRule(cssRule, index <= maxIndex ? index : maxIndex);
|
420 | } catch (err) {
|
421 |
|
422 | return false;
|
423 | }
|
424 |
|
425 | return true;
|
426 | };
|
427 |
|
428 |
|
429 | var deleteRules = function deleteRules(sheet, removalIndex, size) {
|
430 | var lowerBound = removalIndex - size;
|
431 | for (var i = removalIndex; i > lowerBound; i -= 1) {
|
432 | sheet.deleteRule(i);
|
433 | }
|
434 | };
|
435 |
|
436 |
|
437 |
|
438 |
|
439 | var makeTextMarker = function makeTextMarker(id) {
|
440 | return '\n/* sc-component-id: ' + id + ' */\n';
|
441 | };
|
442 |
|
443 |
|
444 | var addUpUntilIndex = function addUpUntilIndex(sizes, index) {
|
445 | var totalUpToIndex = 0;
|
446 | for (var i = 0; i <= index; i += 1) {
|
447 | totalUpToIndex += sizes[i];
|
448 | }
|
449 |
|
450 | return totalUpToIndex;
|
451 | };
|
452 |
|
453 |
|
454 | var makeStyleTag = function makeStyleTag(target, tagEl, insertBefore) {
|
455 | var el = document.createElement('style');
|
456 | el.setAttribute(SC_ATTR, '');
|
457 | el.setAttribute(SC_VERSION_ATTR, "4.1.0");
|
458 |
|
459 | var nonce = getNonce();
|
460 | if (nonce) {
|
461 | el.setAttribute('nonce', nonce);
|
462 | }
|
463 |
|
464 |
|
465 | el.appendChild(document.createTextNode(''));
|
466 |
|
467 | if (target && !tagEl) {
|
468 |
|
469 | target.appendChild(el);
|
470 | } else {
|
471 | if (!tagEl || !target || !tagEl.parentNode) {
|
472 | throw new StyledComponentsError(6);
|
473 | }
|
474 |
|
475 |
|
476 | tagEl.parentNode.insertBefore(el, insertBefore ? tagEl : tagEl.nextSibling);
|
477 | }
|
478 |
|
479 | return el;
|
480 | };
|
481 |
|
482 |
|
483 | var wrapAsHtmlTag = function wrapAsHtmlTag(css, names) {
|
484 | return function (additionalAttrs) {
|
485 | var nonce = getNonce();
|
486 | var attrs = [nonce && 'nonce="' + nonce + '"', SC_ATTR + '="' + stringifyNames(names) + '"', SC_VERSION_ATTR + '="' + "4.1.0" + '"', additionalAttrs];
|
487 |
|
488 | var htmlAttr = attrs.filter(Boolean).join(' ');
|
489 | return '<style ' + htmlAttr + '>' + css() + '</style>';
|
490 | };
|
491 | };
|
492 |
|
493 |
|
494 | var wrapAsElement = function wrapAsElement(css, names) {
|
495 | return function () {
|
496 | var _props;
|
497 |
|
498 | var props = (_props = {}, _props[SC_ATTR] = stringifyNames(names), _props[SC_VERSION_ATTR] = "4.1.0", _props);
|
499 |
|
500 | var nonce = getNonce();
|
501 | if (nonce) {
|
502 |
|
503 | props.nonce = nonce;
|
504 | }
|
505 |
|
506 |
|
507 | return React.createElement('style', _extends({}, props, { dangerouslySetInnerHTML: { __html: css() } }));
|
508 | };
|
509 | };
|
510 |
|
511 | var getIdsFromMarkersFactory = function getIdsFromMarkersFactory(markers) {
|
512 | return function () {
|
513 | return Object.keys(markers);
|
514 | };
|
515 | };
|
516 |
|
517 |
|
518 | var makeSpeedyTag = function makeSpeedyTag(el, getImportRuleTag) {
|
519 | var names = Object.create(null);
|
520 | var markers = Object.create(null);
|
521 | var sizes = [];
|
522 |
|
523 | var extractImport = getImportRuleTag !== undefined;
|
524 |
|
525 | var usedImportRuleTag = false;
|
526 |
|
527 | var insertMarker = function insertMarker(id) {
|
528 | var prev = markers[id];
|
529 | if (prev !== undefined) {
|
530 | return prev;
|
531 | }
|
532 |
|
533 | markers[id] = sizes.length;
|
534 | sizes.push(0);
|
535 | resetIdNames(names, id);
|
536 |
|
537 | return markers[id];
|
538 | };
|
539 |
|
540 | var insertRules = function insertRules(id, cssRules, name) {
|
541 | var marker = insertMarker(id);
|
542 | var sheet = sheetForTag(el);
|
543 | var insertIndex = addUpUntilIndex(sizes, marker);
|
544 |
|
545 | var injectedRules = 0;
|
546 | var importRules = [];
|
547 | var cssRulesSize = cssRules.length;
|
548 |
|
549 | for (var i = 0; i < cssRulesSize; i += 1) {
|
550 | var cssRule = cssRules[i];
|
551 | var mayHaveImport = extractImport;
|
552 | if (mayHaveImport && cssRule.indexOf('@import') !== -1) {
|
553 | importRules.push(cssRule);
|
554 | } else if (safeInsertRule(sheet, cssRule, insertIndex + injectedRules)) {
|
555 | mayHaveImport = false;
|
556 | injectedRules += 1;
|
557 | }
|
558 | }
|
559 |
|
560 | if (extractImport && importRules.length > 0) {
|
561 | usedImportRuleTag = true;
|
562 |
|
563 | getImportRuleTag().insertRules(id + '-import', importRules);
|
564 | }
|
565 |
|
566 | sizes[marker] += injectedRules;
|
567 | addNameForId(names, id, name);
|
568 | };
|
569 |
|
570 | var removeRules = function removeRules(id) {
|
571 | var marker = markers[id];
|
572 | if (marker === undefined) return;
|
573 |
|
574 | var size = sizes[marker];
|
575 | var sheet = sheetForTag(el);
|
576 | var removalIndex = addUpUntilIndex(sizes, marker) - 1;
|
577 | deleteRules(sheet, removalIndex, size);
|
578 | sizes[marker] = 0;
|
579 | resetIdNames(names, id);
|
580 |
|
581 | if (extractImport && usedImportRuleTag) {
|
582 |
|
583 | getImportRuleTag().removeRules(id + '-import');
|
584 | }
|
585 | };
|
586 |
|
587 | var css = function css() {
|
588 | var _sheetForTag = sheetForTag(el),
|
589 | cssRules = _sheetForTag.cssRules;
|
590 |
|
591 | var str = '';
|
592 |
|
593 |
|
594 | for (var id in markers) {
|
595 | str += makeTextMarker(id);
|
596 | var marker = markers[id];
|
597 | var end = addUpUntilIndex(sizes, marker);
|
598 | var size = sizes[marker];
|
599 | for (var i = end - size; i < end; i += 1) {
|
600 | var rule = cssRules[i];
|
601 | if (rule !== undefined) {
|
602 | str += rule.cssText;
|
603 | }
|
604 | }
|
605 | }
|
606 |
|
607 | return str;
|
608 | };
|
609 |
|
610 | return {
|
611 | clone: function clone() {
|
612 | throw new StyledComponentsError(5);
|
613 | },
|
614 |
|
615 | css: css,
|
616 | getIds: getIdsFromMarkersFactory(markers),
|
617 | hasNameForId: hasNameForId(names),
|
618 | insertMarker: insertMarker,
|
619 | insertRules: insertRules,
|
620 | removeRules: removeRules,
|
621 | sealed: false,
|
622 | styleTag: el,
|
623 | toElement: wrapAsElement(css, names),
|
624 | toHTML: wrapAsHtmlTag(css, names)
|
625 | };
|
626 | };
|
627 |
|
628 | var makeTextNode = function makeTextNode(id) {
|
629 | return document.createTextNode(makeTextMarker(id));
|
630 | };
|
631 |
|
632 | var makeBrowserTag = function makeBrowserTag(el, getImportRuleTag) {
|
633 | var names = Object.create(null);
|
634 | var markers = Object.create(null);
|
635 |
|
636 | var extractImport = getImportRuleTag !== undefined;
|
637 |
|
638 |
|
639 | var usedImportRuleTag = false;
|
640 |
|
641 | var insertMarker = function insertMarker(id) {
|
642 | var prev = markers[id];
|
643 | if (prev !== undefined) {
|
644 | return prev;
|
645 | }
|
646 |
|
647 | markers[id] = makeTextNode(id);
|
648 | el.appendChild(markers[id]);
|
649 | names[id] = Object.create(null);
|
650 |
|
651 | return markers[id];
|
652 | };
|
653 |
|
654 | var insertRules = function insertRules(id, cssRules, name) {
|
655 | var marker = insertMarker(id);
|
656 | var importRules = [];
|
657 | var cssRulesSize = cssRules.length;
|
658 |
|
659 | for (var i = 0; i < cssRulesSize; i += 1) {
|
660 | var rule = cssRules[i];
|
661 | var mayHaveImport = extractImport;
|
662 | if (mayHaveImport && rule.indexOf('@import') !== -1) {
|
663 | importRules.push(rule);
|
664 | } else {
|
665 | mayHaveImport = false;
|
666 | var separator = i === cssRulesSize - 1 ? '' : ' ';
|
667 | marker.appendData('' + rule + separator);
|
668 | }
|
669 | }
|
670 |
|
671 | addNameForId(names, id, name);
|
672 |
|
673 | if (extractImport && importRules.length > 0) {
|
674 | usedImportRuleTag = true;
|
675 |
|
676 | getImportRuleTag().insertRules(id + '-import', importRules);
|
677 | }
|
678 | };
|
679 |
|
680 | var removeRules = function removeRules(id) {
|
681 | var marker = markers[id];
|
682 | if (marker === undefined) return;
|
683 |
|
684 |
|
685 | var newMarker = makeTextNode(id);
|
686 | el.replaceChild(newMarker, marker);
|
687 | markers[id] = newMarker;
|
688 | resetIdNames(names, id);
|
689 |
|
690 | if (extractImport && usedImportRuleTag) {
|
691 |
|
692 | getImportRuleTag().removeRules(id + '-import');
|
693 | }
|
694 | };
|
695 |
|
696 | var css = function css() {
|
697 | var str = '';
|
698 |
|
699 |
|
700 | for (var id in markers) {
|
701 | str += markers[id].data;
|
702 | }
|
703 |
|
704 | return str;
|
705 | };
|
706 |
|
707 | return {
|
708 | clone: function clone() {
|
709 | throw new StyledComponentsError(5);
|
710 | },
|
711 |
|
712 | css: css,
|
713 | getIds: getIdsFromMarkersFactory(markers),
|
714 | hasNameForId: hasNameForId(names),
|
715 | insertMarker: insertMarker,
|
716 | insertRules: insertRules,
|
717 | removeRules: removeRules,
|
718 | sealed: false,
|
719 | styleTag: el,
|
720 | toElement: wrapAsElement(css, names),
|
721 | toHTML: wrapAsHtmlTag(css, names)
|
722 | };
|
723 | };
|
724 |
|
725 | var makeServerTag = function makeServerTag(namesArg, markersArg) {
|
726 | var names = namesArg === undefined ? Object.create(null) : namesArg;
|
727 | var markers = markersArg === undefined ? Object.create(null) : markersArg;
|
728 |
|
729 | var insertMarker = function insertMarker(id) {
|
730 | var prev = markers[id];
|
731 | if (prev !== undefined) {
|
732 | return prev;
|
733 | }
|
734 |
|
735 | return markers[id] = [''];
|
736 | };
|
737 |
|
738 | var insertRules = function insertRules(id, cssRules, name) {
|
739 | var marker = insertMarker(id);
|
740 | marker[0] += cssRules.join(' ');
|
741 | addNameForId(names, id, name);
|
742 | };
|
743 |
|
744 | var removeRules = function removeRules(id) {
|
745 | var marker = markers[id];
|
746 | if (marker === undefined) return;
|
747 | marker[0] = '';
|
748 | resetIdNames(names, id);
|
749 | };
|
750 |
|
751 | var css = function css() {
|
752 | var str = '';
|
753 |
|
754 | for (var id in markers) {
|
755 | var cssForId = markers[id][0];
|
756 | if (cssForId) {
|
757 | str += makeTextMarker(id) + cssForId;
|
758 | }
|
759 | }
|
760 | return str;
|
761 | };
|
762 |
|
763 | var clone = function clone() {
|
764 | var namesClone = cloneNames(names);
|
765 | var markersClone = Object.create(null);
|
766 |
|
767 |
|
768 | for (var id in markers) {
|
769 | markersClone[id] = [markers[id][0]];
|
770 | }
|
771 |
|
772 | return makeServerTag(namesClone, markersClone);
|
773 | };
|
774 |
|
775 | var tag = {
|
776 | clone: clone,
|
777 | css: css,
|
778 | getIds: getIdsFromMarkersFactory(markers),
|
779 | hasNameForId: hasNameForId(names),
|
780 | insertMarker: insertMarker,
|
781 | insertRules: insertRules,
|
782 | removeRules: removeRules,
|
783 | sealed: false,
|
784 | styleTag: null,
|
785 | toElement: wrapAsElement(css, names),
|
786 | toHTML: wrapAsHtmlTag(css, names)
|
787 | };
|
788 |
|
789 | return tag;
|
790 | };
|
791 |
|
792 | var makeTag = function makeTag(target, tagEl, forceServer, insertBefore, getImportRuleTag) {
|
793 | if (IS_BROWSER && !forceServer) {
|
794 | var el = makeStyleTag(target, tagEl, insertBefore);
|
795 |
|
796 | if (DISABLE_SPEEDY) {
|
797 | return makeBrowserTag(el, getImportRuleTag);
|
798 | } else {
|
799 | return makeSpeedyTag(el, getImportRuleTag);
|
800 | }
|
801 | }
|
802 |
|
803 | return makeServerTag();
|
804 | };
|
805 |
|
806 | var rehydrate = function rehydrate(tag, els, extracted) {
|
807 |
|
808 | for (var i = 0, len = extracted.length; i < len; i += 1) {
|
809 | var _extracted$i = extracted[i],
|
810 | componentId = _extracted$i.componentId,
|
811 | cssFromDOM = _extracted$i.cssFromDOM;
|
812 |
|
813 | var cssRules = splitByRules(cssFromDOM);
|
814 | tag.insertRules(componentId, cssRules);
|
815 | }
|
816 |
|
817 |
|
818 | for (var _i = 0, _len = els.length; _i < _len; _i += 1) {
|
819 | var el = els[_i];
|
820 | if (el.parentNode) {
|
821 | el.parentNode.removeChild(el);
|
822 | }
|
823 | }
|
824 | };
|
825 |
|
826 |
|
827 |
|
828 | var SPLIT_REGEX = /\s+/;
|
829 |
|
830 |
|
831 | var MAX_SIZE = void 0;
|
832 | if (IS_BROWSER) {
|
833 |
|
834 | MAX_SIZE = DISABLE_SPEEDY ? 40 : 1000;
|
835 | } else {
|
836 |
|
837 | MAX_SIZE = -1;
|
838 | }
|
839 |
|
840 | var sheetRunningId = 0;
|
841 | var master = void 0;
|
842 |
|
843 | var StyleSheet = function () {
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 |
|
861 | function StyleSheet() {
|
862 | var _this = this;
|
863 |
|
864 | var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : IS_BROWSER ? document.head : null;
|
865 | var forceServer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
866 | classCallCheck(this, StyleSheet);
|
867 |
|
868 | this.getImportRuleTag = function () {
|
869 | var importRuleTag = _this.importRuleTag;
|
870 |
|
871 | if (importRuleTag !== undefined) {
|
872 | return importRuleTag;
|
873 | }
|
874 |
|
875 | var firstTag = _this.tags[0];
|
876 | var insertBefore = true;
|
877 |
|
878 | return _this.importRuleTag = makeTag(_this.target, firstTag ? firstTag.styleTag : null, _this.forceServer, insertBefore);
|
879 | };
|
880 |
|
881 | sheetRunningId += 1;
|
882 | this.id = sheetRunningId;
|
883 | this.forceServer = forceServer;
|
884 | this.target = forceServer ? null : target;
|
885 | this.tagMap = {};
|
886 | this.deferred = {};
|
887 | this.rehydratedNames = {};
|
888 | this.ignoreRehydratedNames = {};
|
889 | this.tags = [];
|
890 | this.capacity = 1;
|
891 | this.clones = [];
|
892 | }
|
893 |
|
894 |
|
895 |
|
896 |
|
897 | StyleSheet.prototype.rehydrate = function rehydrate$$1() {
|
898 | if (!IS_BROWSER || this.forceServer) return this;
|
899 |
|
900 | var els = [];
|
901 | var extracted = [];
|
902 | var isStreamed = false;
|
903 |
|
904 |
|
905 | var nodes = document.querySelectorAll('style[' + SC_ATTR + '][' + SC_VERSION_ATTR + '="' + "4.1.0" + '"]');
|
906 |
|
907 | var nodesSize = nodes.length;
|
908 |
|
909 |
|
910 | if (!nodesSize) return this;
|
911 |
|
912 | for (var i = 0; i < nodesSize; i += 1) {
|
913 | var el = nodes[i];
|
914 |
|
915 |
|
916 | if (!isStreamed) isStreamed = !!el.getAttribute(SC_STREAM_ATTR);
|
917 |
|
918 |
|
919 | var elNames = (el.getAttribute(SC_ATTR) || '').trim().split(SPLIT_REGEX);
|
920 | var elNamesSize = elNames.length;
|
921 | for (var j = 0, name; j < elNamesSize; j += 1) {
|
922 | name = elNames[j];
|
923 |
|
924 | this.rehydratedNames[name] = true;
|
925 | }
|
926 |
|
927 |
|
928 | extracted.push.apply(extracted, extractComps(el.textContent));
|
929 |
|
930 |
|
931 | els.push(el);
|
932 | }
|
933 |
|
934 |
|
935 | var extractedSize = extracted.length;
|
936 | if (!extractedSize) return this;
|
937 |
|
938 |
|
939 | var tag = this.makeTag(null);
|
940 |
|
941 | rehydrate(tag, els, extracted);
|
942 |
|
943 |
|
944 | this.capacity = Math.max(1, MAX_SIZE - extractedSize);
|
945 | this.tags.push(tag);
|
946 |
|
947 |
|
948 | for (var _j = 0; _j < extractedSize; _j += 1) {
|
949 | this.tagMap[extracted[_j].componentId] = tag;
|
950 | }
|
951 |
|
952 | return this;
|
953 | };
|
954 |
|
955 | |
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 | StyleSheet.reset = function reset() {
|
962 | var forceServer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
963 |
|
964 | master = new StyleSheet(undefined, forceServer).rehydrate();
|
965 | };
|
966 |
|
967 | |
968 |
|
969 |
|
970 |
|
971 | StyleSheet.prototype.clone = function clone() {
|
972 | var sheet = new StyleSheet(this.target, this.forceServer);
|
973 |
|
974 |
|
975 | this.clones.push(sheet);
|
976 |
|
977 |
|
978 | sheet.tags = this.tags.map(function (tag) {
|
979 | var ids = tag.getIds();
|
980 | var newTag = tag.clone();
|
981 |
|
982 |
|
983 | for (var i = 0; i < ids.length; i += 1) {
|
984 | sheet.tagMap[ids[i]] = newTag;
|
985 | }
|
986 |
|
987 | return newTag;
|
988 | });
|
989 |
|
990 |
|
991 | sheet.rehydratedNames = _extends({}, this.rehydratedNames);
|
992 | sheet.deferred = _extends({}, this.deferred);
|
993 |
|
994 | return sheet;
|
995 | };
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 | StyleSheet.prototype.sealAllTags = function sealAllTags() {
|
1001 | this.capacity = 1;
|
1002 |
|
1003 | this.tags.forEach(function (tag) {
|
1004 |
|
1005 | tag.sealed = true;
|
1006 | });
|
1007 | };
|
1008 |
|
1009 | StyleSheet.prototype.makeTag = function makeTag$$1(tag) {
|
1010 | var lastEl = tag ? tag.styleTag : null;
|
1011 | var insertBefore = false;
|
1012 |
|
1013 | return makeTag(this.target, lastEl, this.forceServer, insertBefore, this.getImportRuleTag);
|
1014 | };
|
1015 |
|
1016 |
|
1017 | StyleSheet.prototype.getTagForId = function getTagForId(id) {
|
1018 |
|
1019 | var prev = this.tagMap[id];
|
1020 | if (prev !== undefined && !prev.sealed) {
|
1021 | return prev;
|
1022 | }
|
1023 |
|
1024 | var tag = this.tags[this.tags.length - 1];
|
1025 |
|
1026 |
|
1027 | this.capacity -= 1;
|
1028 |
|
1029 | if (this.capacity === 0) {
|
1030 | this.capacity = MAX_SIZE;
|
1031 | tag = this.makeTag(tag);
|
1032 | this.tags.push(tag);
|
1033 | }
|
1034 |
|
1035 | return this.tagMap[id] = tag;
|
1036 | };
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 | StyleSheet.prototype.hasId = function hasId(id) {
|
1042 | return this.tagMap[id] !== undefined;
|
1043 | };
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 | StyleSheet.prototype.hasNameForId = function hasNameForId(id, name) {
|
1049 |
|
1050 | if (this.ignoreRehydratedNames[id] === undefined && this.rehydratedNames[name]) {
|
1051 | return true;
|
1052 | }
|
1053 |
|
1054 | var tag = this.tagMap[id];
|
1055 | return tag !== undefined && tag.hasNameForId(id, name);
|
1056 | };
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 | StyleSheet.prototype.deferredInject = function deferredInject(id, cssRules) {
|
1062 |
|
1063 | if (this.tagMap[id] !== undefined) return;
|
1064 |
|
1065 | var clones = this.clones;
|
1066 |
|
1067 | for (var i = 0; i < clones.length; i += 1) {
|
1068 | clones[i].deferredInject(id, cssRules);
|
1069 | }
|
1070 |
|
1071 | this.getTagForId(id).insertMarker(id);
|
1072 | this.deferred[id] = cssRules;
|
1073 | };
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 | StyleSheet.prototype.inject = function inject(id, cssRules, name) {
|
1079 | var clones = this.clones;
|
1080 |
|
1081 |
|
1082 | for (var i = 0; i < clones.length; i += 1) {
|
1083 | clones[i].inject(id, cssRules, name);
|
1084 | }
|
1085 |
|
1086 | var tag = this.getTagForId(id);
|
1087 |
|
1088 |
|
1089 | if (this.deferred[id] !== undefined) {
|
1090 |
|
1091 |
|
1092 |
|
1093 | var rules = this.deferred[id].concat(cssRules);
|
1094 | tag.insertRules(id, rules, name);
|
1095 |
|
1096 | this.deferred[id] = undefined;
|
1097 | } else {
|
1098 | tag.insertRules(id, cssRules, name);
|
1099 | }
|
1100 | };
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 | StyleSheet.prototype.remove = function remove(id) {
|
1106 | var tag = this.tagMap[id];
|
1107 | if (tag === undefined) return;
|
1108 |
|
1109 | var clones = this.clones;
|
1110 |
|
1111 | for (var i = 0; i < clones.length; i += 1) {
|
1112 | clones[i].remove(id);
|
1113 | }
|
1114 |
|
1115 |
|
1116 | tag.removeRules(id);
|
1117 |
|
1118 |
|
1119 | this.ignoreRehydratedNames[id] = true;
|
1120 |
|
1121 |
|
1122 | this.deferred[id] = undefined;
|
1123 | };
|
1124 |
|
1125 | StyleSheet.prototype.toHTML = function toHTML() {
|
1126 | return this.tags.map(function (tag) {
|
1127 | return tag.toHTML();
|
1128 | }).join('');
|
1129 | };
|
1130 |
|
1131 | StyleSheet.prototype.toReactElements = function toReactElements() {
|
1132 | var id = this.id;
|
1133 |
|
1134 |
|
1135 | return this.tags.map(function (tag, i) {
|
1136 | var key = 'sc-' + id + '-' + i;
|
1137 | return cloneElement(tag.toElement(), { key: key });
|
1138 | });
|
1139 | };
|
1140 |
|
1141 | createClass(StyleSheet, null, [{
|
1142 | key: 'master',
|
1143 | get: function get$$1() {
|
1144 | return master || (master = new StyleSheet().rehydrate());
|
1145 | }
|
1146 |
|
1147 |
|
1148 |
|
1149 | }, {
|
1150 | key: 'instance',
|
1151 | get: function get$$1() {
|
1152 | return StyleSheet.master;
|
1153 | }
|
1154 | }]);
|
1155 | return StyleSheet;
|
1156 | }();
|
1157 |
|
1158 |
|
1159 |
|
1160 | var Keyframes = function () {
|
1161 | function Keyframes(name, rules) {
|
1162 | var _this = this;
|
1163 |
|
1164 | classCallCheck(this, Keyframes);
|
1165 |
|
1166 | this.inject = function (styleSheet) {
|
1167 | if (!styleSheet.hasNameForId(_this.id, _this.name)) {
|
1168 | styleSheet.inject(_this.id, _this.rules, _this.name);
|
1169 | }
|
1170 | };
|
1171 |
|
1172 | this.toString = function () {
|
1173 | throw new StyledComponentsError(12, String(_this.name));
|
1174 | };
|
1175 |
|
1176 | this.name = name;
|
1177 | this.rules = rules;
|
1178 |
|
1179 | this.id = 'sc-keyframes-' + name;
|
1180 | }
|
1181 |
|
1182 | Keyframes.prototype.getName = function getName() {
|
1183 | return this.name;
|
1184 | };
|
1185 |
|
1186 | return Keyframes;
|
1187 | }();
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 | var uppercasePattern = /([A-Z])/g;
|
1197 | var msPattern = /^ms-/;
|
1198 |
|
1199 |
|
1200 |
|
1201 |
|
1202 |
|
1203 |
|
1204 |
|
1205 |
|
1206 |
|
1207 |
|
1208 |
|
1209 |
|
1210 |
|
1211 |
|
1212 |
|
1213 |
|
1214 |
|
1215 | function hyphenateStyleName(string) {
|
1216 | return string.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-');
|
1217 | }
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 | function addUnitIfNeeded(name, value) {
|
1223 |
|
1224 |
|
1225 | if (value == null || typeof value === 'boolean' || value === '') {
|
1226 | return '';
|
1227 | }
|
1228 |
|
1229 | if (typeof value === 'number' && value !== 0 && !(name in unitless)) {
|
1230 | return value + 'px';
|
1231 | }
|
1232 |
|
1233 | return String(value).trim();
|
1234 | }
|
1235 |
|
1236 |
|
1237 |
|
1238 |
|
1239 |
|
1240 |
|
1241 | var isFalsish = function isFalsish(chunk) {
|
1242 | return chunk === undefined || chunk === null || chunk === false || chunk === '';
|
1243 | };
|
1244 |
|
1245 | var objToCss = function objToCss(obj, prevKey) {
|
1246 | var css = Object.keys(obj).filter(function (key) {
|
1247 | return !isFalsish(obj[key]);
|
1248 | }).map(function (key) {
|
1249 | if (isPlainObject(obj[key])) return objToCss(obj[key], key);
|
1250 | return hyphenateStyleName(key) + ': ' + addUnitIfNeeded(key, obj[key]) + ';';
|
1251 | }).join(' ');
|
1252 | return prevKey ? prevKey + ' {\n ' + css + '\n}' : css;
|
1253 | };
|
1254 |
|
1255 | function flatten(chunk, executionContext, styleSheet) {
|
1256 | if (Array.isArray(chunk)) {
|
1257 | var ruleSet = [];
|
1258 |
|
1259 | for (var i = 0, len = chunk.length, result; i < len; i += 1) {
|
1260 | result = flatten(chunk[i], executionContext, styleSheet);
|
1261 |
|
1262 | if (result === null) continue;else if (Array.isArray(result)) ruleSet.push.apply(ruleSet, result);else ruleSet.push(result);
|
1263 | }
|
1264 |
|
1265 | return ruleSet;
|
1266 | }
|
1267 |
|
1268 | if (isFalsish(chunk)) {
|
1269 | return null;
|
1270 | }
|
1271 |
|
1272 |
|
1273 | if (isStyledComponent(chunk)) {
|
1274 | return '.' + chunk.styledComponentId;
|
1275 | }
|
1276 |
|
1277 |
|
1278 | if (isFunction(chunk)) {
|
1279 | if (executionContext) {
|
1280 |
|
1281 | if (isElement(new chunk(executionContext))) {
|
1282 | throw new StyledComponentsError(13, getComponentName(chunk));
|
1283 | }
|
1284 |
|
1285 | return flatten(chunk(executionContext), executionContext, styleSheet);
|
1286 | } else return chunk;
|
1287 | }
|
1288 |
|
1289 | if (chunk instanceof Keyframes) {
|
1290 | if (styleSheet) {
|
1291 | chunk.inject(styleSheet);
|
1292 | return chunk.getName();
|
1293 | } else return chunk;
|
1294 | }
|
1295 |
|
1296 |
|
1297 | return isPlainObject(chunk) ? objToCss(chunk) : chunk.toString();
|
1298 | }
|
1299 |
|
1300 |
|
1301 |
|
1302 | function css(styles) {
|
1303 | for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
1304 | interpolations[_key - 1] = arguments[_key];
|
1305 | }
|
1306 |
|
1307 | if (isFunction(styles) || isPlainObject(styles)) {
|
1308 |
|
1309 | return flatten(interleave(EMPTY_ARRAY, [styles].concat(interpolations)));
|
1310 | }
|
1311 |
|
1312 |
|
1313 | return flatten(interleave(styles, interpolations));
|
1314 | }
|
1315 |
|
1316 |
|
1317 |
|
1318 | function constructWithOptions(componentConstructor, tag) {
|
1319 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EMPTY_OBJECT;
|
1320 |
|
1321 | if (!isValidElementType(tag)) {
|
1322 | throw new StyledComponentsError(1, String(tag));
|
1323 | }
|
1324 |
|
1325 |
|
1326 |
|
1327 | var templateFunction = function templateFunction() {
|
1328 | return componentConstructor(tag, options, css.apply(undefined, arguments));
|
1329 | };
|
1330 |
|
1331 |
|
1332 | templateFunction.withConfig = function (config) {
|
1333 | return constructWithOptions(componentConstructor, tag, _extends({}, options, config));
|
1334 | };
|
1335 |
|
1336 |
|
1337 | templateFunction.attrs = function (attrs) {
|
1338 | return constructWithOptions(componentConstructor, tag, _extends({}, options, {
|
1339 | attrs: Array.prototype.concat(options.attrs, attrs).filter(Boolean)
|
1340 | }));
|
1341 | };
|
1342 |
|
1343 | return templateFunction;
|
1344 | }
|
1345 |
|
1346 |
|
1347 |
|
1348 | function murmurhash(c) {
|
1349 | for (var e = c.length | 0, a = e | 0, d = 0, b; e >= 4;) {
|
1350 | b = c.charCodeAt(d) & 255 | (c.charCodeAt(++d) & 255) << 8 | (c.charCodeAt(++d) & 255) << 16 | (c.charCodeAt(++d) & 255) << 24, b = 1540483477 * (b & 65535) + ((1540483477 * (b >>> 16) & 65535) << 16), b ^= b >>> 24, b = 1540483477 * (b & 65535) + ((1540483477 * (b >>> 16) & 65535) << 16), a = 1540483477 * (a & 65535) + ((1540483477 * (a >>> 16) & 65535) << 16) ^ b, e -= 4, ++d;
|
1351 | }
|
1352 | switch (e) {
|
1353 | case 3:
|
1354 | a ^= (c.charCodeAt(d + 2) & 255) << 16;
|
1355 | case 2:
|
1356 | a ^= (c.charCodeAt(d + 1) & 255) << 8;
|
1357 | case 1:
|
1358 | a ^= c.charCodeAt(d) & 255, a = 1540483477 * (a & 65535) + ((1540483477 * (a >>> 16) & 65535) << 16);
|
1359 | }
|
1360 | a ^= a >>> 13;
|
1361 | a = 1540483477 * (a & 65535) + ((1540483477 * (a >>> 16) & 65535) << 16);
|
1362 | return (a ^ a >>> 15) >>> 0;
|
1363 | }
|
1364 |
|
1365 |
|
1366 |
|
1367 |
|
1368 |
|
1369 |
|
1370 | var charsLength = 52;
|
1371 |
|
1372 |
|
1373 | var getAlphabeticChar = function getAlphabeticChar(code) {
|
1374 | return String.fromCharCode(code + (code > 25 ? 39 : 97));
|
1375 | };
|
1376 |
|
1377 |
|
1378 | function generateAlphabeticName(code) {
|
1379 | var name = '';
|
1380 | var x = void 0;
|
1381 |
|
1382 |
|
1383 | for (x = code; x > charsLength; x = Math.floor(x / charsLength)) {
|
1384 | name = getAlphabeticChar(x % charsLength) + name;
|
1385 | }
|
1386 |
|
1387 | return getAlphabeticChar(x % charsLength) + name;
|
1388 | }
|
1389 |
|
1390 |
|
1391 |
|
1392 | function hasFunctionObjectKey(obj) {
|
1393 |
|
1394 | for (var key in obj) {
|
1395 | if (isFunction(obj[key])) {
|
1396 | return true;
|
1397 | }
|
1398 | }
|
1399 |
|
1400 | return false;
|
1401 | }
|
1402 |
|
1403 | function isStaticRules(rules, attrs) {
|
1404 | for (var i = 0; i < rules.length; i += 1) {
|
1405 | var rule = rules[i];
|
1406 |
|
1407 |
|
1408 | if (Array.isArray(rule) && !isStaticRules(rule, attrs)) {
|
1409 | return false;
|
1410 | } else if (isFunction(rule) && !isStyledComponent(rule)) {
|
1411 |
|
1412 |
|
1413 | return false;
|
1414 | }
|
1415 | }
|
1416 |
|
1417 | if (attrs.some(function (x) {
|
1418 | return isFunction(x) || hasFunctionObjectKey(x);
|
1419 | })) return false;
|
1420 |
|
1421 | return true;
|
1422 | }
|
1423 |
|
1424 |
|
1425 |
|
1426 | var isHMREnabled = process.env.NODE_ENV !== 'production' && typeof module !== 'undefined' && module.hot;
|
1427 |
|
1428 |
|
1429 | var hasher = function hasher(str) {
|
1430 | return generateAlphabeticName(murmurhash(str));
|
1431 | };
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 |
|
1437 |
|
1438 | var ComponentStyle = function () {
|
1439 | function ComponentStyle(rules, attrs, componentId) {
|
1440 | classCallCheck(this, ComponentStyle);
|
1441 |
|
1442 | this.rules = rules;
|
1443 | this.isStatic = !isHMREnabled && isStaticRules(rules, attrs);
|
1444 | this.componentId = componentId;
|
1445 |
|
1446 | if (!StyleSheet.master.hasId(componentId)) {
|
1447 | StyleSheet.master.deferredInject(componentId, []);
|
1448 | }
|
1449 | }
|
1450 |
|
1451 | |
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 | ComponentStyle.prototype.generateAndInjectStyles = function generateAndInjectStyles(executionContext, styleSheet) {
|
1459 | var isStatic = this.isStatic,
|
1460 | componentId = this.componentId,
|
1461 | lastClassName = this.lastClassName;
|
1462 |
|
1463 | if (IS_BROWSER && isStatic && typeof lastClassName === 'string' && styleSheet.hasNameForId(componentId, lastClassName)) {
|
1464 | return lastClassName;
|
1465 | }
|
1466 |
|
1467 | var flatCSS = flatten(this.rules, executionContext, styleSheet);
|
1468 | var name = hasher(this.componentId + flatCSS.join(''));
|
1469 | if (!styleSheet.hasNameForId(componentId, name)) {
|
1470 | styleSheet.inject(this.componentId, stringifyRules(flatCSS, '.' + name, undefined, componentId), name);
|
1471 | }
|
1472 |
|
1473 | this.lastClassName = name;
|
1474 | return name;
|
1475 | };
|
1476 |
|
1477 | ComponentStyle.generateName = function generateName(str) {
|
1478 | return hasher(str);
|
1479 | };
|
1480 |
|
1481 | return ComponentStyle;
|
1482 | }();
|
1483 |
|
1484 |
|
1485 |
|
1486 | var LIMIT = 200;
|
1487 |
|
1488 | var createWarnTooManyClasses = (function (displayName) {
|
1489 | var generatedClasses = {};
|
1490 | var warningSeen = false;
|
1491 |
|
1492 | return function (className) {
|
1493 | if (!warningSeen) {
|
1494 | generatedClasses[className] = true;
|
1495 | if (Object.keys(generatedClasses).length >= LIMIT) {
|
1496 |
|
1497 |
|
1498 | console.warn('Over ' + LIMIT + ' classes were generated for component ' + displayName + '. \n' + 'Consider using the attrs method, together with a style object for frequently changed styles.\n' + 'Example:\n' + ' const Component = styled.div.attrs({\n' + ' style: ({ background }) => ({\n' + ' background,\n' + ' }),\n' + ' })`width: 100%;`\n\n' + ' <Component />');
|
1499 | warningSeen = true;
|
1500 | generatedClasses = {};
|
1501 | }
|
1502 | }
|
1503 | };
|
1504 | });
|
1505 |
|
1506 |
|
1507 |
|
1508 | var determineTheme = (function (props, fallbackTheme) {
|
1509 | var defaultProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EMPTY_OBJECT;
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 | var isDefaultTheme = defaultProps ? props.theme === defaultProps.theme : false;
|
1516 | var theme = props.theme && !isDefaultTheme ? props.theme : fallbackTheme || defaultProps.theme;
|
1517 |
|
1518 |
|
1519 | return theme;
|
1520 | });
|
1521 |
|
1522 |
|
1523 | var escapeRegex = /[[\].#*$><+~=|^:(),"'`-]+/g;
|
1524 | var dashesAtEnds = /(^-|-$)/g;
|
1525 |
|
1526 |
|
1527 |
|
1528 |
|
1529 |
|
1530 | function escape(str) {
|
1531 | return str
|
1532 |
|
1533 | .replace(escapeRegex, '-')
|
1534 |
|
1535 |
|
1536 | .replace(dashesAtEnds, '');
|
1537 | }
|
1538 |
|
1539 |
|
1540 |
|
1541 | function isTag(target) /* : %checks */{
|
1542 | return typeof target === 'string';
|
1543 | }
|
1544 |
|
1545 |
|
1546 |
|
1547 | function generateDisplayName(target) {
|
1548 | return isTag(target) ? 'styled.' + target : 'Styled(' + getComponentName(target) + ')';
|
1549 | }
|
1550 |
|
1551 | var _TYPE_STATICS;
|
1552 |
|
1553 | var REACT_STATICS = {
|
1554 | childContextTypes: true,
|
1555 | contextTypes: true,
|
1556 | defaultProps: true,
|
1557 | displayName: true,
|
1558 | getDerivedStateFromProps: true,
|
1559 | propTypes: true,
|
1560 | type: true
|
1561 | };
|
1562 |
|
1563 | var KNOWN_STATICS = {
|
1564 | name: true,
|
1565 | length: true,
|
1566 | prototype: true,
|
1567 | caller: true,
|
1568 | callee: true,
|
1569 | arguments: true,
|
1570 | arity: true
|
1571 | };
|
1572 |
|
1573 | var TYPE_STATICS = (_TYPE_STATICS = {}, _TYPE_STATICS[ForwardRef] = {
|
1574 | $$typeof: true,
|
1575 | render: true
|
1576 | }, _TYPE_STATICS);
|
1577 |
|
1578 | var defineProperty$1 = Object.defineProperty,
|
1579 | getOwnPropertyNames = Object.getOwnPropertyNames,
|
1580 | _Object$getOwnPropert = Object.getOwnPropertySymbols,
|
1581 | getOwnPropertySymbols = _Object$getOwnPropert === undefined ? function () {
|
1582 | return [];
|
1583 | } : _Object$getOwnPropert,
|
1584 | getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
|
1585 | getPrototypeOf = Object.getPrototypeOf,
|
1586 | objectPrototype = Object.prototype;
|
1587 | var arrayPrototype = Array.prototype;
|
1588 |
|
1589 |
|
1590 | function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
1591 | if (typeof sourceComponent !== 'string') {
|
1592 |
|
1593 |
|
1594 | var inheritedComponent = getPrototypeOf(sourceComponent);
|
1595 |
|
1596 | if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
1597 | hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
1598 | }
|
1599 |
|
1600 | var keys = arrayPrototype.concat(getOwnPropertyNames(sourceComponent),
|
1601 |
|
1602 | getOwnPropertySymbols(sourceComponent));
|
1603 |
|
1604 | var targetStatics = TYPE_STATICS[targetComponent.$$typeof] || REACT_STATICS;
|
1605 |
|
1606 | var sourceStatics = TYPE_STATICS[sourceComponent.$$typeof] || REACT_STATICS;
|
1607 |
|
1608 | var i = keys.length;
|
1609 | var descriptor = void 0;
|
1610 | var key = void 0;
|
1611 |
|
1612 |
|
1613 | while (i--) {
|
1614 | key = keys[i];
|
1615 |
|
1616 | if (
|
1617 |
|
1618 | !KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) &&
|
1619 |
|
1620 | !(targetStatics && targetStatics[key])) {
|
1621 | descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
1622 |
|
1623 | if (descriptor) {
|
1624 | try {
|
1625 |
|
1626 | defineProperty$1(targetComponent, key, descriptor);
|
1627 | } catch (e) {
|
1628 |
|
1629 | }
|
1630 | }
|
1631 | }
|
1632 | }
|
1633 |
|
1634 | return targetComponent;
|
1635 | }
|
1636 |
|
1637 | return targetComponent;
|
1638 | }
|
1639 |
|
1640 |
|
1641 | function isDerivedReactComponent(fn) {
|
1642 | return !!(fn && fn.prototype && fn.prototype.isReactComponent);
|
1643 | }
|
1644 |
|
1645 |
|
1646 |
|
1647 | var once = (function (cb) {
|
1648 | var called = false;
|
1649 |
|
1650 | return function () {
|
1651 | if (!called) {
|
1652 | called = true;
|
1653 | cb.apply(undefined, arguments);
|
1654 | }
|
1655 | };
|
1656 | });
|
1657 |
|
1658 |
|
1659 |
|
1660 | var ThemeContext = createContext();
|
1661 |
|
1662 | var ThemeConsumer = ThemeContext.Consumer;
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 | var ThemeProvider = function (_Component) {
|
1669 | inherits(ThemeProvider, _Component);
|
1670 |
|
1671 | function ThemeProvider(props) {
|
1672 | classCallCheck(this, ThemeProvider);
|
1673 |
|
1674 | var _this = possibleConstructorReturn(this, _Component.call(this, props));
|
1675 |
|
1676 | _this.getContext = memoize(_this.getContext.bind(_this));
|
1677 | _this.renderInner = _this.renderInner.bind(_this);
|
1678 | return _this;
|
1679 | }
|
1680 |
|
1681 | ThemeProvider.prototype.render = function render() {
|
1682 | if (!this.props.children) return null;
|
1683 |
|
1684 | return React.createElement(
|
1685 | ThemeContext.Consumer,
|
1686 | null,
|
1687 | this.renderInner
|
1688 | );
|
1689 | };
|
1690 |
|
1691 | ThemeProvider.prototype.renderInner = function renderInner(outerTheme) {
|
1692 | var context = this.getContext(this.props.theme, outerTheme);
|
1693 |
|
1694 | return React.createElement(
|
1695 | ThemeContext.Provider,
|
1696 | { value: context },
|
1697 | React.Children.only(this.props.children)
|
1698 | );
|
1699 | };
|
1700 |
|
1701 | |
1702 |
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 | ThemeProvider.prototype.getTheme = function getTheme(theme, outerTheme) {
|
1708 | if (isFunction(theme)) {
|
1709 | var mergedTheme = theme(outerTheme);
|
1710 |
|
1711 | if (process.env.NODE_ENV !== 'production' && (mergedTheme === null || Array.isArray(mergedTheme) || (typeof mergedTheme === 'undefined' ? 'undefined' : _typeof(mergedTheme)) !== 'object')) {
|
1712 | throw new StyledComponentsError(7);
|
1713 | }
|
1714 |
|
1715 | return mergedTheme;
|
1716 | }
|
1717 |
|
1718 | if (theme === null || Array.isArray(theme) || (typeof theme === 'undefined' ? 'undefined' : _typeof(theme)) !== 'object') {
|
1719 | throw new StyledComponentsError(8);
|
1720 | }
|
1721 |
|
1722 | return _extends({}, outerTheme, theme);
|
1723 | };
|
1724 |
|
1725 | ThemeProvider.prototype.getContext = function getContext(theme, outerTheme) {
|
1726 | return this.getTheme(theme, outerTheme);
|
1727 | };
|
1728 |
|
1729 | return ThemeProvider;
|
1730 | }(Component);
|
1731 |
|
1732 |
|
1733 |
|
1734 | var ServerStyleSheet = function () {
|
1735 | function ServerStyleSheet() {
|
1736 | classCallCheck(this, ServerStyleSheet);
|
1737 |
|
1738 |
|
1739 | this.masterSheet = StyleSheet.master;
|
1740 | this.instance = this.masterSheet.clone();
|
1741 | this.sealed = false;
|
1742 | }
|
1743 |
|
1744 | |
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 | ServerStyleSheet.prototype.seal = function seal() {
|
1751 | if (!this.sealed) {
|
1752 |
|
1753 | var index = this.masterSheet.clones.indexOf(this.instance);
|
1754 | this.masterSheet.clones.splice(index, 1);
|
1755 | this.sealed = true;
|
1756 | }
|
1757 | };
|
1758 |
|
1759 | ServerStyleSheet.prototype.collectStyles = function collectStyles(children) {
|
1760 | if (this.sealed) {
|
1761 | throw new StyledComponentsError(2);
|
1762 | }
|
1763 |
|
1764 | return React.createElement(
|
1765 | StyleSheetManager,
|
1766 | { sheet: this.instance },
|
1767 | children
|
1768 | );
|
1769 | };
|
1770 |
|
1771 | ServerStyleSheet.prototype.getStyleTags = function getStyleTags() {
|
1772 | this.seal();
|
1773 | return this.instance.toHTML();
|
1774 | };
|
1775 |
|
1776 | ServerStyleSheet.prototype.getStyleElement = function getStyleElement() {
|
1777 | this.seal();
|
1778 | return this.instance.toReactElements();
|
1779 | };
|
1780 |
|
1781 | ServerStyleSheet.prototype.interleaveWithNodeStream = function interleaveWithNodeStream(readableStream) {
|
1782 | var _this = this;
|
1783 |
|
1784 | if (IS_BROWSER) {
|
1785 | throw new StyledComponentsError(3);
|
1786 | }
|
1787 |
|
1788 |
|
1789 | var instance = this.instance;
|
1790 |
|
1791 | var instanceTagIndex = 0;
|
1792 |
|
1793 | var streamAttr = SC_STREAM_ATTR + '="true"';
|
1794 |
|
1795 | var transformer = new stream.Transform({
|
1796 | transform: function appendStyleChunks(chunk, /* encoding */_, callback) {
|
1797 | var tags = instance.tags;
|
1798 |
|
1799 | var html = '';
|
1800 |
|
1801 |
|
1802 | for (; instanceTagIndex < tags.length; instanceTagIndex += 1) {
|
1803 | var tag = tags[instanceTagIndex];
|
1804 | html += tag.toHTML(streamAttr);
|
1805 | }
|
1806 |
|
1807 |
|
1808 | instance.sealAllTags();
|
1809 |
|
1810 |
|
1811 | this.push(html + chunk);
|
1812 | callback();
|
1813 | }
|
1814 | });
|
1815 |
|
1816 | readableStream.on('end', function () {
|
1817 | return _this.seal();
|
1818 | });
|
1819 | readableStream.on('error', function (err) {
|
1820 | _this.seal();
|
1821 |
|
1822 |
|
1823 | transformer.emit('error', err);
|
1824 | });
|
1825 |
|
1826 | return readableStream.pipe(transformer);
|
1827 | };
|
1828 |
|
1829 | return ServerStyleSheet;
|
1830 | }();
|
1831 |
|
1832 |
|
1833 |
|
1834 | var StyleSheetContext = createContext();
|
1835 |
|
1836 | var StyleSheetConsumer = StyleSheetContext.Consumer;
|
1837 |
|
1838 | var StyleSheetManager = function (_Component) {
|
1839 | inherits(StyleSheetManager, _Component);
|
1840 |
|
1841 | function StyleSheetManager(props) {
|
1842 | classCallCheck(this, StyleSheetManager);
|
1843 |
|
1844 | var _this = possibleConstructorReturn(this, _Component.call(this, props));
|
1845 |
|
1846 | _this.getContext = memoize(_this.getContext);
|
1847 | return _this;
|
1848 | }
|
1849 |
|
1850 | StyleSheetManager.prototype.getContext = function getContext(sheet, target) {
|
1851 | if (sheet) {
|
1852 | return sheet;
|
1853 | } else if (target) {
|
1854 | return new StyleSheet(target);
|
1855 | } else {
|
1856 | throw new StyledComponentsError(4);
|
1857 | }
|
1858 | };
|
1859 |
|
1860 | StyleSheetManager.prototype.render = function render() {
|
1861 | var _props = this.props,
|
1862 | children = _props.children,
|
1863 | sheet = _props.sheet,
|
1864 | target = _props.target;
|
1865 |
|
1866 |
|
1867 | return React.createElement(
|
1868 | StyleSheetContext.Provider,
|
1869 | { value: this.getContext(sheet, target) },
|
1870 | process.env.NODE_ENV !== 'production' ? React.Children.only(children) : children
|
1871 | );
|
1872 | };
|
1873 |
|
1874 | return StyleSheetManager;
|
1875 | }(Component);
|
1876 | process.env.NODE_ENV !== "production" ? StyleSheetManager.propTypes = {
|
1877 | sheet: PropTypes.oneOfType([PropTypes.instanceOf(StyleSheet), PropTypes.instanceOf(ServerStyleSheet)]),
|
1878 |
|
1879 | target: PropTypes.shape({
|
1880 | appendChild: PropTypes.func.isRequired
|
1881 | })
|
1882 | } : void 0;
|
1883 |
|
1884 |
|
1885 |
|
1886 | var didWarnAboutClassNameUsage = new Set();
|
1887 |
|
1888 | var classNameUsageCheckInjector = (function (target) {
|
1889 | var elementClassName = '';
|
1890 |
|
1891 | var targetCDM = target.componentDidMount;
|
1892 |
|
1893 |
|
1894 | target.componentDidMount = function componentDidMount() {
|
1895 | if (typeof targetCDM === 'function') {
|
1896 | targetCDM.call(this);
|
1897 | }
|
1898 |
|
1899 | var forwardTarget = this.props.forwardedClass.target;
|
1900 |
|
1901 | if (target.props && target.props.suppressClassNameWarning || target.attrs && target.attrs.suppressClassNameWarning || didWarnAboutClassNameUsage.has(forwardTarget)) {
|
1902 | return;
|
1903 | }
|
1904 |
|
1905 | didWarnAboutClassNameUsage.add(forwardTarget);
|
1906 |
|
1907 | var classNames = elementClassName.replace(/ +/g, ' ').trim().split(' ');
|
1908 |
|
1909 | var node = ReactDOM.findDOMNode(this);
|
1910 | var selector = classNames.map(function (s) {
|
1911 | return '.' + s;
|
1912 | }).join('');
|
1913 |
|
1914 | if (node && node.nodeType === 1 && !classNames.every(function (className) {
|
1915 | return node.classList && node.classList.contains(className);
|
1916 | }) && !node.querySelector(selector)) {
|
1917 | 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.');
|
1918 | }
|
1919 | };
|
1920 |
|
1921 | var prevRenderInner = target.renderInner;
|
1922 |
|
1923 |
|
1924 | target.renderInner = function renderInner() {
|
1925 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
1926 | args[_key] = arguments[_key];
|
1927 | }
|
1928 |
|
1929 | var element = prevRenderInner.apply(this, args);
|
1930 |
|
1931 | elementClassName = element.props.className;
|
1932 |
|
1933 | return element;
|
1934 | };
|
1935 | });
|
1936 |
|
1937 |
|
1938 |
|
1939 | var identifiers = {};
|
1940 |
|
1941 |
|
1942 | function generateId(_ComponentStyle, _displayName, parentComponentId) {
|
1943 | var displayName = typeof _displayName !== 'string' ? 'sc' : escape(_displayName);
|
1944 |
|
1945 | |
1946 |
|
1947 |
|
1948 |
|
1949 | var nr = (identifiers[displayName] || 0) + 1;
|
1950 | identifiers[displayName] = nr;
|
1951 |
|
1952 | var componentId = displayName + '-' + _ComponentStyle.generateName(displayName + nr);
|
1953 |
|
1954 | return parentComponentId ? parentComponentId + '-' + componentId : componentId;
|
1955 | }
|
1956 |
|
1957 | var warnInnerRef = once(function () {
|
1958 | return (
|
1959 |
|
1960 | console.warn('The "innerRef" API has been removed in styled-components v4 in favor of React 16 ref forwarding, use "ref" instead like a typical component.')
|
1961 | );
|
1962 | });
|
1963 |
|
1964 | var warnAttrsFnObjectKeyDeprecated = once(function (key, displayName) {
|
1965 | return (
|
1966 |
|
1967 | console.warn('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 + '".')
|
1968 | );
|
1969 | });
|
1970 |
|
1971 | var warnNonStyledComponentAttrsObjectKey = once(function (key, displayName) {
|
1972 | return (
|
1973 |
|
1974 | console.warn('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' + 'You should use the new function-form attrs constructor which avoids this issue: attrs(props => ({ yourStuff }))\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" + ('For example, { ' + key + ': () => InnerComponent } instead of { ' + key + ': InnerComponent }'))
|
1975 | );
|
1976 | });
|
1977 |
|
1978 | // $FlowFixMe
|
1979 |
|
1980 | var StyledComponent = function (_Component) {
|
1981 | inherits(StyledComponent, _Component);
|
1982 |
|
1983 | function StyledComponent() {
|
1984 | classCallCheck(this, StyledComponent);
|
1985 |
|
1986 | var _this = possibleConstructorReturn(this, _Component.call(this));
|
1987 |
|
1988 | _this.attrs = {};
|
1989 |
|
1990 | _this.renderOuter = _this.renderOuter.bind(_this);
|
1991 | _this.renderInner = _this.renderInner.bind(_this);
|
1992 |
|
1993 | if (process.env.NODE_ENV !== 'production' && IS_BROWSER) {
|
1994 | classNameUsageCheckInjector(_this);
|
1995 | }
|
1996 | return _this;
|
1997 | }
|
1998 |
|
1999 | StyledComponent.prototype.render = function render() {
|
2000 | return React.createElement(
|
2001 | StyleSheetConsumer,
|
2002 | null,
|
2003 | this.renderOuter
|
2004 | );
|
2005 | };
|
2006 |
|
2007 | StyledComponent.prototype.renderOuter = function renderOuter(styleSheet) {
|
2008 | this.styleSheet = styleSheet;
|
2009 | var componentStyle = this.props.forwardedClass.componentStyle;
|
2010 |
|
2011 | // No need to subscribe a static component to theme changes, it won't change anything
|
2012 |
|
2013 | if (componentStyle.isStatic) return this.renderInner();
|
2014 |
|
2015 | return React.createElement(
|
2016 | ThemeConsumer,
|
2017 | null,
|
2018 | this.renderInner
|
2019 | );
|
2020 | };
|
2021 |
|
2022 | StyledComponent.prototype.renderInner = function renderInner(theme) {
|
2023 | var _props$forwardedClass = this.props.forwardedClass,
|
2024 | componentStyle = _props$forwardedClass.componentStyle,
|
2025 | defaultProps = _props$forwardedClass.defaultProps,
|
2026 | styledComponentId = _props$forwardedClass.styledComponentId,
|
2027 | target = _props$forwardedClass.target;
|
2028 |
|
2029 |
|
2030 | var generatedClassName = void 0;
|
2031 | if (componentStyle.isStatic) {
|
2032 | generatedClassName = this.generateAndInjectStyles(EMPTY_OBJECT, this.props, this.styleSheet);
|
2033 | } else if (theme !== undefined) {
|
2034 | generatedClassName = this.generateAndInjectStyles(determineTheme(this.props, theme, defaultProps), this.props, this.styleSheet);
|
2035 | } else {
|
2036 | generatedClassName = this.generateAndInjectStyles(this.props.theme || EMPTY_OBJECT, this.props, this.styleSheet);
|
2037 | }
|
2038 | var elementToBeCreated = this.props.as || this.attrs.as || target;
|
2039 | var isTargetTag = isTag(elementToBeCreated);
|
2040 |
|
2041 | var propsForElement = {};
|
2042 | var computedProps = _extends({}, this.attrs, this.props);
|
2043 |
|
2044 | var key = void 0;
|
2045 | // eslint-disable-next-line guard-for-in
|
2046 | for (key in computedProps) {
|
2047 | if (process.env.NODE_ENV !== 'production' && key === 'innerRef') {
|
2048 | warnInnerRef();
|
2049 | }
|
2050 |
|
2051 | if (key === 'forwardedClass' || key === 'as') continue;else if (key === 'forwardedRef') propsForElement.ref = computedProps[key];else if (!isTargetTag || validAttr(key)) {
|
2052 | // Don't pass through non HTML tags through to HTML elements
|
2053 | propsForElement[key] = computedProps[key];
|
2054 | }
|
2055 | }
|
2056 |
|
2057 | if (this.props.style && this.attrs.style) {
|
2058 | propsForElement.style = _extends({}, this.attrs.style, this.props.style);
|
2059 | }
|
2060 |
|
2061 | propsForElement.className = [this.props.className, styledComponentId, this.attrs.className, generatedClassName].filter(Boolean).join(' ');
|
2062 |
|
2063 | return createElement(elementToBeCreated, propsForElement);
|
2064 | };
|
2065 |
|
2066 | StyledComponent.prototype.buildExecutionContext = function buildExecutionContext(theme, props, attrs) {
|
2067 | var _this2 = this;
|
2068 |
|
2069 | var context = _extends({}, props, { theme: theme });
|
2070 |
|
2071 | if (!attrs.length) return context;
|
2072 |
|
2073 | this.attrs = {};
|
2074 |
|
2075 | attrs.forEach(function (attrDef) {
|
2076 | var resolvedAttrDef = attrDef;
|
2077 | var attrDefWasFn = false;
|
2078 | var attr = void 0;
|
2079 | var key = void 0;
|
2080 |
|
2081 | if (isFunction(resolvedAttrDef)) {
|
2082 | // $FlowFixMe
|
2083 | resolvedAttrDef = resolvedAttrDef(props);
|
2084 | attrDefWasFn = true;
|
2085 | }
|
2086 |
|
2087 | /* eslint-disable guard-for-in */
|
2088 | // $FlowFixMe
|
2089 | for (key in resolvedAttrDef) {
|
2090 | attr = resolvedAttrDef[key];
|
2091 |
|
2092 | if (!attrDefWasFn) {
|
2093 | if (isFunction(attr) && !isDerivedReactComponent(attr) && !isStyledComponent(attr)) {
|
2094 | if (process.env.NODE_ENV !== 'production' && warnAttrsFnObjectKeyDeprecated) {
|
2095 | warnAttrsFnObjectKeyDeprecated(key, props.forwardedClass.displayName);
|
2096 | }
|
2097 |
|
2098 | attr = attr(context);
|
2099 |
|
2100 | if (process.env.NODE_ENV !== 'production' && React.isValidElement(attr) && warnNonStyledComponentAttrsObjectKey) {
|
2101 | warnNonStyledComponentAttrsObjectKey(key, props.forwardedClass.displayName);
|
2102 | }
|
2103 | }
|
2104 | }
|
2105 |
|
2106 | _this2.attrs[key] = attr;
|
2107 | context[key] = attr;
|
2108 | }
|
2109 | /* eslint-enable */
|
2110 | });
|
2111 |
|
2112 | return context;
|
2113 | };
|
2114 |
|
2115 | StyledComponent.prototype.generateAndInjectStyles = function generateAndInjectStyles(theme, props) {
|
2116 | var styleSheet = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : StyleSheet.master;
|
2117 | var _props$forwardedClass2 = props.forwardedClass,
|
2118 | attrs = _props$forwardedClass2.attrs,
|
2119 | componentStyle = _props$forwardedClass2.componentStyle,
|
2120 | warnTooManyClasses = _props$forwardedClass2.warnTooManyClasses;
|
2121 |
|
2122 | // statically styled-components don't need to build an execution context object,
|
2123 | // and shouldn't be increasing the number of class names
|
2124 |
|
2125 | if (componentStyle.isStatic && !attrs.length) {
|
2126 | return componentStyle.generateAndInjectStyles(EMPTY_OBJECT, styleSheet);
|
2127 | }
|
2128 |
|
2129 | var className = componentStyle.generateAndInjectStyles(this.buildExecutionContext(theme, props, attrs), styleSheet);
|
2130 |
|
2131 | if (process.env.NODE_ENV !== 'production' && warnTooManyClasses) warnTooManyClasses(className);
|
2132 |
|
2133 | return className;
|
2134 | };
|
2135 |
|
2136 | return StyledComponent;
|
2137 | }(Component);
|
2138 |
|
2139 | function createStyledComponent(target, options, rules) {
|
2140 | var isTargetStyledComp = isStyledComponent(target);
|
2141 | var isClass = !isTag(target);
|
2142 |
|
2143 | var _options$displayName = options.displayName,
|
2144 | displayName = _options$displayName === undefined ? generateDisplayName(target) : _options$displayName,
|
2145 | _options$componentId = options.componentId,
|
2146 | componentId = _options$componentId === undefined ? generateId(ComponentStyle, options.displayName, options.parentComponentId) : _options$componentId,
|
2147 | _options$ParentCompon = options.ParentComponent,
|
2148 | ParentComponent = _options$ParentCompon === undefined ? StyledComponent : _options$ParentCompon,
|
2149 | _options$attrs = options.attrs,
|
2150 | attrs = _options$attrs === undefined ? EMPTY_ARRAY : _options$attrs;
|
2151 |
|
2152 |
|
2153 | var styledComponentId = options.displayName && options.componentId ? escape(options.displayName) + '-' + options.componentId : options.componentId || componentId;
|
2154 |
|
2155 | // fold the underlying StyledComponent attrs up (implicit extend)
|
2156 | var finalAttrs =
|
2157 | // $FlowFixMe
|
2158 | isTargetStyledComp && target.attrs ? Array.prototype.concat(target.attrs, attrs).filter(Boolean) : attrs;
|
2159 |
|
2160 | var componentStyle = new ComponentStyle(isTargetStyledComp ? // fold the underlying StyledComponent rules up (implicit extend)
|
2161 | // $FlowFixMe
|
2162 | target.componentStyle.rules.concat(rules) : rules, finalAttrs, styledComponentId);
|
2163 |
|
2164 | /**
|
2165 | * forwardRef creates a new interim component, which we'll take advantage of
|
2166 | * instead of extending ParentComponent to create _another_ interim class
|
2167 | */
|
2168 | var WrappedStyledComponent = React.forwardRef(function (props, ref) {
|
2169 | return React.createElement(ParentComponent, _extends({}, props, { forwardedClass: WrappedStyledComponent, forwardedRef: ref }));
|
2170 | });
|
2171 |
|
2172 | // $FlowFixMe
|
2173 | WrappedStyledComponent.attrs = finalAttrs;
|
2174 | // $FlowFixMe
|
2175 | WrappedStyledComponent.componentStyle = componentStyle;
|
2176 | WrappedStyledComponent.displayName = displayName;
|
2177 | // $FlowFixMe
|
2178 | WrappedStyledComponent.styledComponentId = styledComponentId;
|
2179 |
|
2180 | // fold the underlying StyledComponent target up since we folded the styles
|
2181 | // $FlowFixMe
|
2182 | WrappedStyledComponent.target = isTargetStyledComp ? target.target : target;
|
2183 |
|
2184 | // $FlowFixMe
|
2185 | WrappedStyledComponent.withComponent = function withComponent(tag) {
|
2186 | var previousComponentId = options.componentId,
|
2187 | optionsToCopy = objectWithoutProperties(options, ['componentId']);
|
2188 |
|
2189 |
|
2190 | var newComponentId = previousComponentId && previousComponentId + '-' + (isTag(tag) ? tag : escape(getComponentName(tag)));
|
2191 |
|
2192 | var newOptions = _extends({}, optionsToCopy, {
|
2193 | attrs: finalAttrs,
|
2194 | componentId: newComponentId,
|
2195 | ParentComponent: ParentComponent
|
2196 | });
|
2197 |
|
2198 | return createStyledComponent(tag, newOptions, rules);
|
2199 | };
|
2200 |
|
2201 | if (process.env.NODE_ENV !== 'production') {
|
2202 | // $FlowFixMe
|
2203 | WrappedStyledComponent.warnTooManyClasses = createWarnTooManyClasses(displayName);
|
2204 | }
|
2205 |
|
2206 | // $FlowFixMe
|
2207 | WrappedStyledComponent.toString = function () {
|
2208 | return '.' + WrappedStyledComponent.styledComponentId;
|
2209 | };
|
2210 |
|
2211 | if (isClass) {
|
2212 | hoistNonReactStatics(WrappedStyledComponent, target, {
|
2213 | // all SC-specific things should not be hoisted
|
2214 | attrs: true,
|
2215 | componentStyle: true,
|
2216 | displayName: true,
|
2217 | styledComponentId: true,
|
2218 | target: true,
|
2219 | withComponent: true
|
2220 | });
|
2221 | }
|
2222 |
|
2223 | return WrappedStyledComponent;
|
2224 | }
|
2225 |
|
2226 | //
|
2227 | // Thanks to ReactDOMFactories for this handy list!
|
2228 |
|
2229 | 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',
|
2230 |
|
2231 | // SVG
|
2232 | 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
|
2233 |
|
2234 | //
|
2235 |
|
2236 | var styled = function styled(tag) {
|
2237 | return constructWithOptions(createStyledComponent, tag);
|
2238 | };
|
2239 |
|
2240 | // Shorthands for all valid HTML Elements
|
2241 | domElements.forEach(function (domElement) {
|
2242 | styled[domElement] = styled(domElement);
|
2243 | });
|
2244 |
|
2245 | //
|
2246 |
|
2247 | var GlobalStyle = function () {
|
2248 | function GlobalStyle(rules, componentId) {
|
2249 | classCallCheck(this, GlobalStyle);
|
2250 |
|
2251 | this.rules = rules;
|
2252 | this.componentId = componentId;
|
2253 | this.isStatic = isStaticRules(rules, EMPTY_ARRAY);
|
2254 |
|
2255 | if (!StyleSheet.master.hasId(componentId)) {
|
2256 | StyleSheet.master.deferredInject(componentId, []);
|
2257 | }
|
2258 | }
|
2259 |
|
2260 | GlobalStyle.prototype.createStyles = function createStyles(executionContext, styleSheet) {
|
2261 | var flatCSS = flatten(this.rules, executionContext, styleSheet);
|
2262 | var css = stringifyRules(flatCSS, '');
|
2263 |
|
2264 | styleSheet.inject(this.componentId, css);
|
2265 | };
|
2266 |
|
2267 | GlobalStyle.prototype.removeStyles = function removeStyles(styleSheet) {
|
2268 | var componentId = this.componentId;
|
2269 |
|
2270 | if (styleSheet.hasId(componentId)) {
|
2271 | styleSheet.remove(componentId);
|
2272 | }
|
2273 | };
|
2274 |
|
2275 | // TODO: overwrite in-place instead of remove+create?
|
2276 |
|
2277 |
|
2278 | GlobalStyle.prototype.renderStyles = function renderStyles(executionContext, styleSheet) {
|
2279 | this.removeStyles(styleSheet);
|
2280 | this.createStyles(executionContext, styleSheet);
|
2281 | };
|
2282 |
|
2283 | return GlobalStyle;
|
2284 | }();
|
2285 |
|
2286 | //
|
2287 |
|
2288 | // place our cache into shared context so it'll persist between HMRs
|
2289 | if (IS_BROWSER) {
|
2290 | window.scCGSHMRCache = {};
|
2291 | }
|
2292 |
|
2293 | function createGlobalStyle(strings) {
|
2294 | for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
2295 | interpolations[_key - 1] = arguments[_key];
|
2296 | }
|
2297 |
|
2298 | var rules = css.apply(undefined, [strings].concat(interpolations));
|
2299 | var id = 'sc-global-' + murmurhash(JSON.stringify(rules));
|
2300 | var style = new GlobalStyle(rules, id);
|
2301 |
|
2302 | var GlobalStyleComponent = function (_React$Component) {
|
2303 | inherits(GlobalStyleComponent, _React$Component);
|
2304 |
|
2305 | function GlobalStyleComponent() {
|
2306 | classCallCheck(this, GlobalStyleComponent);
|
2307 |
|
2308 | var _this = possibleConstructorReturn(this, _React$Component.call(this));
|
2309 |
|
2310 | var _this$constructor = _this.constructor,
|
2311 | globalStyle = _this$constructor.globalStyle,
|
2312 | styledComponentId = _this$constructor.styledComponentId;
|
2313 |
|
2314 |
|
2315 | if (IS_BROWSER) {
|
2316 | window.scCGSHMRCache[styledComponentId] = (window.scCGSHMRCache[styledComponentId] || 0) + 1;
|
2317 | }
|
2318 |
|
2319 | /**
|
2320 | * This fixes HMR compatiblility. Don't ask me why, but this combination of
|
2321 | * caching the closure variables via statics and then persisting the statics in
|
2322 | * state works across HMR where no other combination did. ¯\_(ツ)_/¯
|
2323 | */
|
2324 | _this.state = {
|
2325 | globalStyle: globalStyle,
|
2326 | styledComponentId: styledComponentId
|
2327 | };
|
2328 | return _this;
|
2329 | }
|
2330 |
|
2331 | GlobalStyleComponent.prototype.componentDidMount = function componentDidMount() {
|
2332 | if (process.env.NODE_ENV !== 'production' && IS_BROWSER && window.scCGSHMRCache[this.state.styledComponentId] > 1 && !this.props.suppressMultiMountWarning) {
|
2333 | console.warn('The global style component ' + this.state.styledComponentId + ' was composed and rendered multiple times in your React component tree. Only the last-rendered copy will have its styles remain in <head> (or your StyleSheetManager target.)');
|
2334 | }
|
2335 | };
|
2336 |
|
2337 | GlobalStyleComponent.prototype.componentWillUnmount = function componentWillUnmount() {
|
2338 | if (window.scCGSHMRCache[this.state.styledComponentId]) {
|
2339 | window.scCGSHMRCache[this.state.styledComponentId] -= 1;
|
2340 | }
|
2341 | /**
|
2342 | * Depending on the order "render" is called this can cause the styles to be lost
|
2343 | * until the next render pass of the remaining instance, which may
|
2344 | * not be immediate.
|
2345 | */
|
2346 | if (window.scCGSHMRCache[this.state.styledComponentId] === 0) {
|
2347 | this.state.globalStyle.removeStyles(this.styleSheet);
|
2348 | }
|
2349 | };
|
2350 |
|
2351 | GlobalStyleComponent.prototype.render = function render() {
|
2352 | var _this2 = this;
|
2353 |
|
2354 | if (process.env.NODE_ENV !== 'production' && React.Children.count(this.props.children)) {
|
2355 | console.warn('The global style component ' + this.state.styledComponentId + ' was given child JSX. createGlobalStyle does not render children.');
|
2356 | }
|
2357 |
|
2358 | return React.createElement(
|
2359 | StyleSheetConsumer,
|
2360 | null,
|
2361 | function (styleSheet) {
|
2362 | _this2.styleSheet = styleSheet || StyleSheet.master;
|
2363 |
|
2364 | var globalStyle = _this2.state.globalStyle;
|
2365 |
|
2366 |
|
2367 | if (globalStyle.isStatic) {
|
2368 | globalStyle.renderStyles(STATIC_EXECUTION_CONTEXT, _this2.styleSheet);
|
2369 |
|
2370 | return null;
|
2371 | } else {
|
2372 | return React.createElement(
|
2373 | ThemeConsumer,
|
2374 | null,
|
2375 | function (theme) {
|
2376 | var defaultProps = _this2.constructor.defaultProps;
|
2377 |
|
2378 |
|
2379 | var context = _extends({}, _this2.props);
|
2380 |
|
2381 | if (typeof theme !== 'undefined') {
|
2382 | context.theme = determineTheme(_this2.props, theme, defaultProps);
|
2383 | }
|
2384 |
|
2385 | globalStyle.renderStyles(context, _this2.styleSheet);
|
2386 |
|
2387 | return null;
|
2388 | }
|
2389 | );
|
2390 | }
|
2391 | }
|
2392 | );
|
2393 | };
|
2394 |
|
2395 | return GlobalStyleComponent;
|
2396 | }(React.Component);
|
2397 |
|
2398 | GlobalStyleComponent.defaultProps = {
|
2399 | suppressMultiMountWarning: false
|
2400 | };
|
2401 | GlobalStyleComponent.globalStyle = style;
|
2402 | GlobalStyleComponent.styledComponentId = id;
|
2403 | process.env.NODE_ENV !== "production" ? GlobalStyleComponent.propTypes = {
|
2404 | suppressMultiMountWarning: PropTypes.bool
|
2405 | } : void 0;
|
2406 |
|
2407 |
|
2408 | return GlobalStyleComponent;
|
2409 | }
|
2410 |
|
2411 | //
|
2412 |
|
2413 | var replaceWhitespace = function replaceWhitespace(str) {
|
2414 | return str.replace(/\s|\\n/g, '');
|
2415 | };
|
2416 |
|
2417 | function keyframes(strings) {
|
2418 | /* Warning if you've used keyframes on React Native */
|
2419 | if (process.env.NODE_ENV !== 'production' && typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
2420 | console.warn('`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.');
|
2421 | }
|
2422 |
|
2423 | for (var _len = arguments.length, interpolations = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
2424 | interpolations[_key - 1] = arguments[_key];
|
2425 | }
|
2426 |
|
2427 | var rules = css.apply(undefined, [strings].concat(interpolations));
|
2428 |
|
2429 | var name = generateAlphabeticName(murmurhash(replaceWhitespace(JSON.stringify(rules))));
|
2430 |
|
2431 | return new Keyframes(name, stringifyRules(rules, name, '@keyframes'));
|
2432 | }
|
2433 |
|
2434 | //
|
2435 |
|
2436 | var withTheme = (function (Component$$1) {
|
2437 | var WithTheme = React.forwardRef(function (props, ref) {
|
2438 | return React.createElement(
|
2439 | ThemeConsumer,
|
2440 | null,
|
2441 | function (theme) {
|
2442 | // $FlowFixMe
|
2443 | var defaultProps = Component$$1.defaultProps;
|
2444 |
|
2445 | var themeProp = determineTheme(props, theme, defaultProps);
|
2446 |
|
2447 | if (process.env.NODE_ENV !== 'production' && themeProp === undefined) {
|
2448 | // eslint-disable-next-line no-console
|
2449 | console.warn('[withTheme] You are not using a ThemeProvider nor passing a theme prop or a theme in defaultProps in component class "' + getComponentName(Component$$1) + '"');
|
2450 | }
|
2451 |
|
2452 | return React.createElement(Component$$1, _extends({}, props, { theme: themeProp, ref: ref }));
|
2453 | }
|
2454 | );
|
2455 | });
|
2456 |
|
2457 | hoistNonReactStatics(WithTheme, Component$$1);
|
2458 |
|
2459 | WithTheme.displayName = 'WithTheme(' + getComponentName(Component$$1) + ')';
|
2460 |
|
2461 | return WithTheme;
|
2462 | });
|
2463 |
|
2464 | //
|
2465 |
|
2466 | /* eslint-disable */
|
2467 | var __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS = {
|
2468 | StyleSheet: StyleSheet
|
2469 | };
|
2470 |
|
2471 | //
|
2472 |
|
2473 | /* Warning if you've imported this file on React Native */
|
2474 | if (process.env.NODE_ENV !== 'production' && typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
|
2475 | // eslint-disable-next-line no-console
|
2476 | console.warn("It looks like you've imported 'styled-components' on React Native.\n" + "Perhaps you're looking to import 'styled-components/native'?\n" + 'Read more about this at https://www.styled-components.com/docs/basics#react-native');
|
2477 | }
|
2478 |
|
2479 | /* Warning if there are several instances of styled-components */
|
2480 | if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test' && typeof window !== 'undefined' && typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Node.js') === -1 && navigator.userAgent.indexOf('jsdom') === -1) {
|
2481 | window['__styled-components-init__'] = window['__styled-components-init__'] || 0;
|
2482 |
|
2483 | if (window['__styled-components-init__'] === 1) {
|
2484 | // eslint-disable-next-line no-console
|
2485 | console.warn("It looks like there are several instances of 'styled-components' initialized in this application. " + 'This may cause dynamic styles not rendering properly, errors happening during rehydration process ' + 'and makes your application bigger without a good reason.\n\n' + 'See https://s-c.sh/2BAXzed for more info.');
|
2486 | }
|
2487 |
|
2488 | window['__styled-components-init__'] += 1;
|
2489 | }
|
2490 |
|
2491 | //
|
2492 |
|
2493 | export default styled;
|
2494 | export { css, keyframes, createGlobalStyle, isStyledComponent, ThemeConsumer, ThemeContext, ThemeProvider, withTheme, ServerStyleSheet, StyleSheetManager, __DO_NOT_USE_OR_YOU_WILL_BE_HAUNTED_BY_SPOOKY_GHOSTS };
|
2495 | //# sourceMappingURL=styled-components.esm.js.map
|
2496 |
|
\ | No newline at end of file |