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