styled-components 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/styled-components-macro.cjs.js +1 -1
- package/dist/styled-components-macro.esm.js +1 -1
- package/dist/styled-components.browser.cjs.js +1 -1
- package/dist/styled-components.browser.cjs.js.map +1 -1
- package/dist/styled-components.browser.esm.js +1 -1
- package/dist/styled-components.browser.esm.js.map +1 -1
- package/dist/styled-components.cjs.js +1 -1
- package/dist/styled-components.cjs.js.map +1 -1
- package/dist/styled-components.esm.js +1 -1
- package/dist/styled-components.esm.js.map +1 -1
- package/dist/styled-components.js +1 -1
- package/dist/styled-components.js.map +1 -1
- package/dist/styled-components.min.js +1 -1
- package/dist/styled-components.min.js.map +1 -1
- package/native/dist/styled-components.native.cjs.js +212 -209
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +212 -209
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/package.json +4 -4
- package/primitives/dist/styled-components-primitives.cjs.js +212 -209
- package/primitives/dist/styled-components-primitives.cjs.js.map +1 -1
- package/primitives/dist/styled-components-primitives.esm.js +212 -209
- package/primitives/dist/styled-components-primitives.esm.js.map +1 -1
|
@@ -154,17 +154,14 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
154
154
|
var SC_ATTR = typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || 'data-styled';
|
|
155
155
|
var SC_ATTR_ACTIVE = 'active';
|
|
156
156
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
157
|
-
var SC_VERSION = "5.
|
|
157
|
+
var SC_VERSION = "5.3.0";
|
|
158
158
|
var SPLITTER = '/*!sc*/\n';
|
|
159
159
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
160
|
-
var DISABLE_SPEEDY = typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
160
|
+
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean' ? SC_DISABLE_SPEEDY : typeof process !== 'undefined' && typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' && process.env.REACT_APP_SC_DISABLE_SPEEDY !== '' ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false' ? false : process.env.REACT_APP_SC_DISABLE_SPEEDY : typeof process !== 'undefined' && typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' && process.env.SC_DISABLE_SPEEDY !== '' ? process.env.SC_DISABLE_SPEEDY === 'false' ? false : process.env.SC_DISABLE_SPEEDY : process.env.NODE_ENV !== 'production'); // Shared empty execution context when generating static styles
|
|
161
161
|
|
|
162
162
|
//
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
var getNonce = function getNonce() {
|
|
166
|
-
return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
|
|
167
|
-
};
|
|
163
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
164
|
+
var EMPTY_OBJECT = Object.freeze({});
|
|
168
165
|
|
|
169
166
|
var errorMap = {
|
|
170
167
|
"1": "Cannot create styled-component for component: %s.\n\n",
|
|
@@ -223,192 +220,6 @@ function throwStyledComponentsError(code) {
|
|
|
223
220
|
}
|
|
224
221
|
}
|
|
225
222
|
|
|
226
|
-
//
|
|
227
|
-
var ELEMENT_TYPE = 1;
|
|
228
|
-
/* Node.ELEMENT_TYPE */
|
|
229
|
-
|
|
230
|
-
/** Find last style element if any inside target */
|
|
231
|
-
|
|
232
|
-
var findLastStyleTag = function findLastStyleTag(target) {
|
|
233
|
-
var childNodes = target.childNodes;
|
|
234
|
-
|
|
235
|
-
for (var i = childNodes.length; i >= 0; i--) {
|
|
236
|
-
var child = childNodes[i];
|
|
237
|
-
|
|
238
|
-
if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
|
|
239
|
-
return child;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return undefined;
|
|
244
|
-
};
|
|
245
|
-
/** Create a style element inside `target` or <head> after the last */
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
var makeStyleTag = function makeStyleTag(target) {
|
|
249
|
-
var head = document.head;
|
|
250
|
-
var parent = target || head;
|
|
251
|
-
var style = document.createElement('style');
|
|
252
|
-
var prevStyle = findLastStyleTag(parent);
|
|
253
|
-
var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
|
|
254
|
-
style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
|
|
255
|
-
style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
|
|
256
|
-
var nonce = getNonce();
|
|
257
|
-
if (nonce) style.setAttribute('nonce', nonce);
|
|
258
|
-
parent.insertBefore(style, nextSibling);
|
|
259
|
-
return style;
|
|
260
|
-
};
|
|
261
|
-
/** Get the CSSStyleSheet instance for a given style element */
|
|
262
|
-
|
|
263
|
-
var getSheet = function getSheet(tag) {
|
|
264
|
-
if (tag.sheet) {
|
|
265
|
-
return tag.sheet;
|
|
266
|
-
} // Avoid Firefox quirk where the style element might not have a sheet property
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
var _document = document,
|
|
270
|
-
styleSheets = _document.styleSheets;
|
|
271
|
-
|
|
272
|
-
for (var i = 0, l = styleSheets.length; i < l; i++) {
|
|
273
|
-
var sheet = styleSheets[i];
|
|
274
|
-
|
|
275
|
-
if (sheet.ownerNode === tag) {
|
|
276
|
-
return sheet;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
throwStyledComponentsError(17);
|
|
281
|
-
return undefined;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
//
|
|
285
|
-
/** Create a CSSStyleSheet-like tag depending on the environment */
|
|
286
|
-
|
|
287
|
-
var makeTag = function makeTag(_ref) {
|
|
288
|
-
var isServer = _ref.isServer,
|
|
289
|
-
useCSSOMInjection = _ref.useCSSOMInjection,
|
|
290
|
-
target = _ref.target;
|
|
291
|
-
|
|
292
|
-
if (isServer) {
|
|
293
|
-
return new VirtualTag(target);
|
|
294
|
-
} else if (useCSSOMInjection) {
|
|
295
|
-
return new CSSOMTag(target);
|
|
296
|
-
} else {
|
|
297
|
-
return new TextTag(target);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
var CSSOMTag = /*#__PURE__*/function () {
|
|
301
|
-
function CSSOMTag(target) {
|
|
302
|
-
var element = this.element = makeStyleTag(target); // Avoid Edge bug where empty style elements don't create sheets
|
|
303
|
-
|
|
304
|
-
element.appendChild(document.createTextNode(''));
|
|
305
|
-
this.sheet = getSheet(element);
|
|
306
|
-
this.length = 0;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
var _proto = CSSOMTag.prototype;
|
|
310
|
-
|
|
311
|
-
_proto.insertRule = function insertRule(index, rule) {
|
|
312
|
-
try {
|
|
313
|
-
this.sheet.insertRule(rule, index);
|
|
314
|
-
this.length++;
|
|
315
|
-
return true;
|
|
316
|
-
} catch (_error) {
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
_proto.deleteRule = function deleteRule(index) {
|
|
322
|
-
this.sheet.deleteRule(index);
|
|
323
|
-
this.length--;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
_proto.getRule = function getRule(index) {
|
|
327
|
-
var rule = this.sheet.cssRules[index]; // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
|
|
328
|
-
|
|
329
|
-
if (rule !== undefined && typeof rule.cssText === 'string') {
|
|
330
|
-
return rule.cssText;
|
|
331
|
-
} else {
|
|
332
|
-
return '';
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
return CSSOMTag;
|
|
337
|
-
}();
|
|
338
|
-
/** A Tag that emulates the CSSStyleSheet API but uses text nodes */
|
|
339
|
-
|
|
340
|
-
var TextTag = /*#__PURE__*/function () {
|
|
341
|
-
function TextTag(target) {
|
|
342
|
-
var element = this.element = makeStyleTag(target);
|
|
343
|
-
this.nodes = element.childNodes;
|
|
344
|
-
this.length = 0;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
var _proto2 = TextTag.prototype;
|
|
348
|
-
|
|
349
|
-
_proto2.insertRule = function insertRule(index, rule) {
|
|
350
|
-
if (index <= this.length && index >= 0) {
|
|
351
|
-
var node = document.createTextNode(rule);
|
|
352
|
-
var refNode = this.nodes[index];
|
|
353
|
-
this.element.insertBefore(node, refNode || null);
|
|
354
|
-
this.length++;
|
|
355
|
-
return true;
|
|
356
|
-
} else {
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
_proto2.deleteRule = function deleteRule(index) {
|
|
362
|
-
this.element.removeChild(this.nodes[index]);
|
|
363
|
-
this.length--;
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
_proto2.getRule = function getRule(index) {
|
|
367
|
-
if (index < this.length) {
|
|
368
|
-
return this.nodes[index].textContent;
|
|
369
|
-
} else {
|
|
370
|
-
return '';
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
return TextTag;
|
|
375
|
-
}();
|
|
376
|
-
/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
|
|
377
|
-
|
|
378
|
-
var VirtualTag = /*#__PURE__*/function () {
|
|
379
|
-
function VirtualTag(_target) {
|
|
380
|
-
this.rules = [];
|
|
381
|
-
this.length = 0;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
var _proto3 = VirtualTag.prototype;
|
|
385
|
-
|
|
386
|
-
_proto3.insertRule = function insertRule(index, rule) {
|
|
387
|
-
if (index <= this.length) {
|
|
388
|
-
this.rules.splice(index, 0, rule);
|
|
389
|
-
this.length++;
|
|
390
|
-
return true;
|
|
391
|
-
} else {
|
|
392
|
-
return false;
|
|
393
|
-
}
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
_proto3.deleteRule = function deleteRule(index) {
|
|
397
|
-
this.rules.splice(index, 1);
|
|
398
|
-
this.length--;
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
_proto3.getRule = function getRule(index) {
|
|
402
|
-
if (index < this.length) {
|
|
403
|
-
return this.rules[index];
|
|
404
|
-
} else {
|
|
405
|
-
return '';
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
|
|
409
|
-
return VirtualTag;
|
|
410
|
-
}();
|
|
411
|
-
|
|
412
223
|
//
|
|
413
224
|
/** Create a GroupedTag with an underlying Tag implementation */
|
|
414
225
|
|
|
@@ -513,6 +324,10 @@ var getGroupForId = function getGroupForId(id) {
|
|
|
513
324
|
return groupIDRegister.get(id);
|
|
514
325
|
}
|
|
515
326
|
|
|
327
|
+
while (reverseRegister.has(nextFreeGroup)) {
|
|
328
|
+
nextFreeGroup++;
|
|
329
|
+
}
|
|
330
|
+
|
|
516
331
|
var group = nextFreeGroup++;
|
|
517
332
|
|
|
518
333
|
if (process.env.NODE_ENV !== 'production' && ((group | 0) < 0 || group > MAX_SMI)) {
|
|
@@ -527,10 +342,6 @@ var getIdForGroup = function getIdForGroup(group) {
|
|
|
527
342
|
return reverseRegister.get(group);
|
|
528
343
|
};
|
|
529
344
|
var setGroupForId = function setGroupForId(id, group) {
|
|
530
|
-
if (group >= nextFreeGroup) {
|
|
531
|
-
nextFreeGroup = group + 1;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
345
|
groupIDRegister.set(id, group);
|
|
535
346
|
reverseRegister.set(group, id);
|
|
536
347
|
};
|
|
@@ -625,6 +436,199 @@ var rehydrateSheet = function rehydrateSheet(sheet) {
|
|
|
625
436
|
}
|
|
626
437
|
};
|
|
627
438
|
|
|
439
|
+
//
|
|
440
|
+
|
|
441
|
+
/* eslint-disable camelcase, no-undef */
|
|
442
|
+
var getNonce = function getNonce() {
|
|
443
|
+
return typeof window !== 'undefined' ? typeof window.__webpack_nonce__ !== 'undefined' ? window.__webpack_nonce__ : null : null;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
//
|
|
447
|
+
var ELEMENT_TYPE = 1;
|
|
448
|
+
/* Node.ELEMENT_TYPE */
|
|
449
|
+
|
|
450
|
+
/** Find last style element if any inside target */
|
|
451
|
+
|
|
452
|
+
var findLastStyleTag = function findLastStyleTag(target) {
|
|
453
|
+
var childNodes = target.childNodes;
|
|
454
|
+
|
|
455
|
+
for (var i = childNodes.length; i >= 0; i--) {
|
|
456
|
+
var child = childNodes[i];
|
|
457
|
+
|
|
458
|
+
if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
|
|
459
|
+
return child;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
return undefined;
|
|
464
|
+
};
|
|
465
|
+
/** Create a style element inside `target` or <head> after the last */
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
var makeStyleTag = function makeStyleTag(target) {
|
|
469
|
+
var head = document.head;
|
|
470
|
+
var parent = target || head;
|
|
471
|
+
var style = document.createElement('style');
|
|
472
|
+
var prevStyle = findLastStyleTag(parent);
|
|
473
|
+
var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
|
|
474
|
+
style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
|
|
475
|
+
style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
|
|
476
|
+
var nonce = getNonce();
|
|
477
|
+
if (nonce) style.setAttribute('nonce', nonce);
|
|
478
|
+
parent.insertBefore(style, nextSibling);
|
|
479
|
+
return style;
|
|
480
|
+
};
|
|
481
|
+
/** Get the CSSStyleSheet instance for a given style element */
|
|
482
|
+
|
|
483
|
+
var getSheet = function getSheet(tag) {
|
|
484
|
+
if (tag.sheet) {
|
|
485
|
+
return tag.sheet;
|
|
486
|
+
} // Avoid Firefox quirk where the style element might not have a sheet property
|
|
487
|
+
|
|
488
|
+
|
|
489
|
+
var _document = document,
|
|
490
|
+
styleSheets = _document.styleSheets;
|
|
491
|
+
|
|
492
|
+
for (var i = 0, l = styleSheets.length; i < l; i++) {
|
|
493
|
+
var sheet = styleSheets[i];
|
|
494
|
+
|
|
495
|
+
if (sheet.ownerNode === tag) {
|
|
496
|
+
return sheet;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
throwStyledComponentsError(17);
|
|
501
|
+
return undefined;
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
//
|
|
505
|
+
/** Create a CSSStyleSheet-like tag depending on the environment */
|
|
506
|
+
|
|
507
|
+
var makeTag = function makeTag(_ref) {
|
|
508
|
+
var isServer = _ref.isServer,
|
|
509
|
+
useCSSOMInjection = _ref.useCSSOMInjection,
|
|
510
|
+
target = _ref.target;
|
|
511
|
+
|
|
512
|
+
if (isServer) {
|
|
513
|
+
return new VirtualTag(target);
|
|
514
|
+
} else if (useCSSOMInjection) {
|
|
515
|
+
return new CSSOMTag(target);
|
|
516
|
+
} else {
|
|
517
|
+
return new TextTag(target);
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
var CSSOMTag = /*#__PURE__*/function () {
|
|
521
|
+
function CSSOMTag(target) {
|
|
522
|
+
var element = this.element = makeStyleTag(target); // Avoid Edge bug where empty style elements don't create sheets
|
|
523
|
+
|
|
524
|
+
element.appendChild(document.createTextNode(''));
|
|
525
|
+
this.sheet = getSheet(element);
|
|
526
|
+
this.length = 0;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
var _proto = CSSOMTag.prototype;
|
|
530
|
+
|
|
531
|
+
_proto.insertRule = function insertRule(index, rule) {
|
|
532
|
+
try {
|
|
533
|
+
this.sheet.insertRule(rule, index);
|
|
534
|
+
this.length++;
|
|
535
|
+
return true;
|
|
536
|
+
} catch (_error) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
|
|
541
|
+
_proto.deleteRule = function deleteRule(index) {
|
|
542
|
+
this.sheet.deleteRule(index);
|
|
543
|
+
this.length--;
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
_proto.getRule = function getRule(index) {
|
|
547
|
+
var rule = this.sheet.cssRules[index]; // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
|
|
548
|
+
|
|
549
|
+
if (rule !== undefined && typeof rule.cssText === 'string') {
|
|
550
|
+
return rule.cssText;
|
|
551
|
+
} else {
|
|
552
|
+
return '';
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
return CSSOMTag;
|
|
557
|
+
}();
|
|
558
|
+
/** A Tag that emulates the CSSStyleSheet API but uses text nodes */
|
|
559
|
+
|
|
560
|
+
var TextTag = /*#__PURE__*/function () {
|
|
561
|
+
function TextTag(target) {
|
|
562
|
+
var element = this.element = makeStyleTag(target);
|
|
563
|
+
this.nodes = element.childNodes;
|
|
564
|
+
this.length = 0;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
var _proto2 = TextTag.prototype;
|
|
568
|
+
|
|
569
|
+
_proto2.insertRule = function insertRule(index, rule) {
|
|
570
|
+
if (index <= this.length && index >= 0) {
|
|
571
|
+
var node = document.createTextNode(rule);
|
|
572
|
+
var refNode = this.nodes[index];
|
|
573
|
+
this.element.insertBefore(node, refNode || null);
|
|
574
|
+
this.length++;
|
|
575
|
+
return true;
|
|
576
|
+
} else {
|
|
577
|
+
return false;
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
_proto2.deleteRule = function deleteRule(index) {
|
|
582
|
+
this.element.removeChild(this.nodes[index]);
|
|
583
|
+
this.length--;
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
_proto2.getRule = function getRule(index) {
|
|
587
|
+
if (index < this.length) {
|
|
588
|
+
return this.nodes[index].textContent;
|
|
589
|
+
} else {
|
|
590
|
+
return '';
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
|
|
594
|
+
return TextTag;
|
|
595
|
+
}();
|
|
596
|
+
/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
|
|
597
|
+
|
|
598
|
+
var VirtualTag = /*#__PURE__*/function () {
|
|
599
|
+
function VirtualTag(_target) {
|
|
600
|
+
this.rules = [];
|
|
601
|
+
this.length = 0;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
var _proto3 = VirtualTag.prototype;
|
|
605
|
+
|
|
606
|
+
_proto3.insertRule = function insertRule(index, rule) {
|
|
607
|
+
if (index <= this.length) {
|
|
608
|
+
this.rules.splice(index, 0, rule);
|
|
609
|
+
this.length++;
|
|
610
|
+
return true;
|
|
611
|
+
} else {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
_proto3.deleteRule = function deleteRule(index) {
|
|
617
|
+
this.rules.splice(index, 1);
|
|
618
|
+
this.length--;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
_proto3.getRule = function getRule(index) {
|
|
622
|
+
if (index < this.length) {
|
|
623
|
+
return this.rules[index];
|
|
624
|
+
} else {
|
|
625
|
+
return '';
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
return VirtualTag;
|
|
630
|
+
}();
|
|
631
|
+
|
|
628
632
|
var SHOULD_REHYDRATE = IS_BROWSER;
|
|
629
633
|
var defaultOptions = {
|
|
630
634
|
isServer: !IS_BROWSER,
|
|
@@ -640,7 +644,7 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
640
644
|
|
|
641
645
|
function StyleSheet(options, globalStyles, names) {
|
|
642
646
|
if (options === void 0) {
|
|
643
|
-
options =
|
|
647
|
+
options = EMPTY_OBJECT;
|
|
644
648
|
}
|
|
645
649
|
|
|
646
650
|
if (globalStyles === void 0) {
|
|
@@ -736,10 +740,6 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
736
740
|
return StyleSheet;
|
|
737
741
|
}();
|
|
738
742
|
|
|
739
|
-
//
|
|
740
|
-
var EMPTY_ARRAY = Object.freeze([]);
|
|
741
|
-
var EMPTY_OBJECT = Object.freeze({});
|
|
742
|
-
|
|
743
743
|
/**
|
|
744
744
|
* MIT License
|
|
745
745
|
*
|
|
@@ -842,7 +842,7 @@ function createStylisInstance(_temp) {
|
|
|
842
842
|
|
|
843
843
|
var selfReferenceReplacer = function selfReferenceReplacer(match, offset, string) {
|
|
844
844
|
if ( // do not replace the first occurrence if it is complex (has a modifier)
|
|
845
|
-
(offset === 0 ?
|
|
845
|
+
(offset === 0 ? COMPLEX_SELECTOR_PREFIX.indexOf(string[_selector.length]) === -1 : true) && // no consecutive self refs (.b.b); that is a precedence boost and treated differently
|
|
846
846
|
!string.match(_consecutiveSelfRefRegExp)) {
|
|
847
847
|
return "." + _componentId;
|
|
848
848
|
}
|
|
@@ -955,7 +955,7 @@ var Keyframes = /*#__PURE__*/function () {
|
|
|
955
955
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
956
956
|
*/
|
|
957
957
|
var uppercaseCheck = /([A-Z])/;
|
|
958
|
-
var uppercasePattern =
|
|
958
|
+
var uppercasePattern = /([A-Z])/g;
|
|
959
959
|
var msPattern = /^ms-/;
|
|
960
960
|
|
|
961
961
|
var prefixAndLowerCase = function prefixAndLowerCase(_char) {
|
|
@@ -5877,7 +5877,6 @@ function isTag(target) {
|
|
|
5877
5877
|
|
|
5878
5878
|
//
|
|
5879
5879
|
function generateDisplayName(target) {
|
|
5880
|
-
// $FlowFixMe
|
|
5881
5880
|
return isTag(target) ? "styled." + target : "Styled(" + getComponentName(target) + ")";
|
|
5882
5881
|
}
|
|
5883
5882
|
|
|
@@ -5959,9 +5958,10 @@ var StyledNativeComponent = /*#__PURE__*/function (_Component) {
|
|
|
5959
5958
|
forwardedComponent = _this2$props.forwardedComponent,
|
|
5960
5959
|
forwardedAs = _this2$props.forwardedAs,
|
|
5961
5960
|
forwardedRef = _this2$props.forwardedRef,
|
|
5961
|
+
testID = _this2$props.testID,
|
|
5962
5962
|
_this2$props$style = _this2$props.style,
|
|
5963
5963
|
style = _this2$props$style === void 0 ? [] : _this2$props$style,
|
|
5964
|
-
props = _objectWithoutPropertiesLoose(_this2$props, ["$as", "as", "forwardedComponent", "forwardedAs", "forwardedRef", "style"]);
|
|
5964
|
+
props = _objectWithoutPropertiesLoose(_this2$props, ["$as", "as", "forwardedComponent", "forwardedAs", "forwardedRef", "testID", "style"]);
|
|
5965
5965
|
|
|
5966
5966
|
var defaultProps = forwardedComponent.defaultProps,
|
|
5967
5967
|
target = forwardedComponent.target,
|
|
@@ -5985,7 +5985,10 @@ var StyledNativeComponent = /*#__PURE__*/function (_Component) {
|
|
|
5985
5985
|
}
|
|
5986
5986
|
}
|
|
5987
5987
|
|
|
5988
|
-
propsForElement.style =
|
|
5988
|
+
propsForElement.style = typeof style === 'function' ? function (state) {
|
|
5989
|
+
return [generatedStyles].concat(style(state));
|
|
5990
|
+
} : [generatedStyles].concat(style);
|
|
5991
|
+
propsForElement.testID = testID;
|
|
5989
5992
|
if (forwardedRef) propsForElement.ref = forwardedRef;
|
|
5990
5993
|
if (forwardedAs) propsForElement.as = forwardedAs;
|
|
5991
5994
|
return React.createElement(elementToBeRendered, propsForElement);
|
|
@@ -6067,9 +6070,9 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
6067
6070
|
if (isTargetStyledComp && target.shouldForwardProp) {
|
|
6068
6071
|
if (shouldForwardProp) {
|
|
6069
6072
|
// compose nested shouldForwardProp calls
|
|
6070
|
-
shouldForwardProp = function shouldForwardProp(prop, filterFn) {
|
|
6073
|
+
shouldForwardProp = function shouldForwardProp(prop, filterFn, elementToBeCreated) {
|
|
6071
6074
|
return (// $FlowFixMe
|
|
6072
|
-
target.shouldForwardProp(prop, filterFn) && options.shouldForwardProp(prop, filterFn)
|
|
6075
|
+
target.shouldForwardProp(prop, filterFn, elementToBeCreated) && options.shouldForwardProp(prop, filterFn, elementToBeCreated)
|
|
6073
6076
|
);
|
|
6074
6077
|
};
|
|
6075
6078
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled-components.native.cjs.js","sources":["../../src/constants.js","../../src/sheet/Tag.js","../../src/sheet/GroupedTag.js","../../src/sheet/GroupIDAllocator.js","../../src/sheet/Sheet.js","../../src/models/Keyframes.js","../../src/models/InlineStyle.js"],"sourcesContent":["// @flow\n\ndeclare var SC_DISABLE_SPEEDY: ?boolean;\ndeclare var __VERSION__: string;\n\nexport const SC_ATTR =\n (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||\n 'data-styled';\n\nexport const SC_ATTR_ACTIVE = 'active';\nexport const SC_ATTR_VERSION = 'data-styled-version';\nexport const SC_VERSION = __VERSION__;\nexport const SPLITTER = '/*!sc*/\\n';\n\nexport const IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;\n\nexport const DISABLE_SPEEDY =\n (typeof SC_DISABLE_SPEEDY === 'boolean' && SC_DISABLE_SPEEDY) ||\n (typeof process !== 'undefined' &&\n (process.env.REACT_APP_SC_DISABLE_SPEEDY || process.env.SC_DISABLE_SPEEDY)) ||\n process.env.NODE_ENV !== 'production';\n\n// Shared empty execution context when generating static styles\nexport const STATIC_EXECUTION_CONTEXT = {};\n","// @flow\n/* eslint-disable no-use-before-define */\n\nimport { makeStyleTag, getSheet } from './dom';\nimport type { SheetOptions, Tag } from './types';\n\n/** Create a CSSStyleSheet-like tag depending on the environment */\nexport const makeTag = ({ isServer, useCSSOMInjection, target }: SheetOptions): Tag => {\n if (isServer) {\n return new VirtualTag(target);\n } else if (useCSSOMInjection) {\n return new CSSOMTag(target);\n } else {\n return new TextTag(target);\n }\n};\n\nexport class CSSOMTag implements Tag {\n element: HTMLStyleElement;\n\n sheet: CSSStyleSheet;\n\n length: number;\n\n constructor(target?: HTMLElement) {\n const element = (this.element = makeStyleTag(target));\n\n // Avoid Edge bug where empty style elements don't create sheets\n element.appendChild(document.createTextNode(''));\n\n this.sheet = getSheet(element);\n this.length = 0;\n }\n\n insertRule(index: number, rule: string): boolean {\n try {\n this.sheet.insertRule(rule, index);\n this.length++;\n return true;\n } catch (_error) {\n return false;\n }\n }\n\n deleteRule(index: number): void {\n this.sheet.deleteRule(index);\n this.length--;\n }\n\n getRule(index: number): string {\n const rule = this.sheet.cssRules[index];\n // Avoid IE11 quirk where cssText is inaccessible on some invalid rules\n if (rule !== undefined && typeof rule.cssText === 'string') {\n return rule.cssText;\n } else {\n return '';\n }\n }\n}\n\n/** A Tag that emulates the CSSStyleSheet API but uses text nodes */\nexport class TextTag implements Tag {\n element: HTMLStyleElement;\n\n nodes: NodeList<Node>;\n\n length: number;\n\n constructor(target?: HTMLElement) {\n const element = (this.element = makeStyleTag(target));\n this.nodes = element.childNodes;\n this.length = 0;\n }\n\n insertRule(index: number, rule: string): boolean {\n if (index <= this.length && index >= 0) {\n const node = document.createTextNode(rule);\n const refNode = this.nodes[index];\n this.element.insertBefore(node, refNode || null);\n this.length++;\n return true;\n } else {\n return false;\n }\n }\n\n deleteRule(index: number): void {\n this.element.removeChild(this.nodes[index]);\n this.length--;\n }\n\n getRule(index: number): string {\n if (index < this.length) {\n return this.nodes[index].textContent;\n } else {\n return '';\n }\n }\n}\n\n/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */\nexport class VirtualTag implements Tag {\n rules: string[];\n\n length: number;\n\n constructor(_target?: HTMLElement) {\n this.rules = [];\n this.length = 0;\n }\n\n insertRule(index: number, rule: string): boolean {\n if (index <= this.length) {\n this.rules.splice(index, 0, rule);\n this.length++;\n return true;\n } else {\n return false;\n }\n }\n\n deleteRule(index: number): void {\n this.rules.splice(index, 1);\n this.length--;\n }\n\n getRule(index: number): string {\n if (index < this.length) {\n return this.rules[index];\n } else {\n return '';\n }\n }\n}\n","// @flow\n/* eslint-disable no-use-before-define */\n\nimport type { GroupedTag, Tag } from './types';\nimport { SPLITTER } from '../constants';\nimport throwStyledError from '../utils/error';\n\n/** Create a GroupedTag with an underlying Tag implementation */\nexport const makeGroupedTag = (tag: Tag): GroupedTag => {\n return new DefaultGroupedTag(tag);\n};\n\nconst BASE_SIZE = 1 << 9;\n\nclass DefaultGroupedTag implements GroupedTag {\n groupSizes: Uint32Array;\n\n length: number;\n\n tag: Tag;\n\n constructor(tag: Tag) {\n this.groupSizes = new Uint32Array(BASE_SIZE);\n this.length = BASE_SIZE;\n this.tag = tag;\n }\n\n indexOfGroup(group: number): number {\n let index = 0;\n for (let i = 0; i < group; i++) {\n index += this.groupSizes[i];\n }\n\n return index;\n }\n\n insertRules(group: number, rules: string[]): void {\n if (group >= this.groupSizes.length) {\n const oldBuffer = this.groupSizes;\n const oldSize = oldBuffer.length;\n\n let newSize = oldSize;\n while (group >= newSize) {\n newSize <<= 1;\n if (newSize < 0) {\n throwStyledError(16, `${group}`);\n }\n }\n\n this.groupSizes = new Uint32Array(newSize);\n this.groupSizes.set(oldBuffer);\n this.length = newSize;\n\n for (let i = oldSize; i < newSize; i++) {\n this.groupSizes[i] = 0;\n }\n }\n\n let ruleIndex = this.indexOfGroup(group + 1);\n for (let i = 0, l = rules.length; i < l; i++) {\n if (this.tag.insertRule(ruleIndex, rules[i])) {\n this.groupSizes[group]++;\n ruleIndex++;\n }\n }\n }\n\n clearGroup(group: number): void {\n if (group < this.length) {\n const length = this.groupSizes[group];\n const startIndex = this.indexOfGroup(group);\n const endIndex = startIndex + length;\n\n this.groupSizes[group] = 0;\n\n for (let i = startIndex; i < endIndex; i++) {\n this.tag.deleteRule(startIndex);\n }\n }\n }\n\n getGroup(group: number): string {\n let css = '';\n if (group >= this.length || this.groupSizes[group] === 0) {\n return css;\n }\n\n const length = this.groupSizes[group];\n const startIndex = this.indexOfGroup(group);\n const endIndex = startIndex + length;\n\n for (let i = startIndex; i < endIndex; i++) {\n css += `${this.tag.getRule(i)}${SPLITTER}`;\n }\n\n return css;\n }\n}\n","// @flow\n\nimport throwStyledError from '../utils/error';\n\nconst MAX_SMI = 1 << 31 - 1;\n\nlet groupIDRegister: Map<string, number> = new Map();\nlet reverseRegister: Map<number, string> = new Map();\nlet nextFreeGroup = 1;\n\nexport const resetGroupIds = () => {\n groupIDRegister = new Map();\n reverseRegister = new Map();\n nextFreeGroup = 1;\n};\n\nexport const getGroupForId = (id: string): number => {\n if (groupIDRegister.has(id)) {\n return (groupIDRegister.get(id): any);\n }\n\n const group = nextFreeGroup++;\n if (\n process.env.NODE_ENV !== 'production' &&\n ((group | 0) < 0 || group > MAX_SMI)\n ) {\n throwStyledError(16, `${group}`);\n }\n\n groupIDRegister.set(id, group);\n reverseRegister.set(group, id);\n return group;\n};\n\nexport const getIdForGroup = (group: number): void | string => {\n return reverseRegister.get(group);\n};\n\nexport const setGroupForId = (id: string, group: number) => {\n if (group >= nextFreeGroup) {\n nextFreeGroup = group + 1;\n }\n\n groupIDRegister.set(id, group);\n reverseRegister.set(group, id);\n};\n","// @flow\nimport { DISABLE_SPEEDY, IS_BROWSER } from '../constants';\nimport type { GroupedTag, Sheet, SheetOptions } from './types';\nimport { makeTag } from './Tag';\nimport { makeGroupedTag } from './GroupedTag';\nimport { getGroupForId } from './GroupIDAllocator';\nimport { outputSheet, rehydrateSheet } from './Rehydration';\n\nlet SHOULD_REHYDRATE = IS_BROWSER;\n\ntype SheetConstructorArgs = {\n isServer?: boolean,\n useCSSOMInjection?: boolean,\n target?: HTMLElement,\n};\n\ntype GlobalStylesAllocationMap = { [key: string]: number };\ntype NamesAllocationMap = Map<string, Set<string>>;\n\nconst defaultOptions = {\n isServer: !IS_BROWSER,\n useCSSOMInjection: !DISABLE_SPEEDY,\n};\n\n/** Contains the main stylesheet logic for stringification and caching */\nexport default class StyleSheet implements Sheet {\n gs: GlobalStylesAllocationMap;\n\n names: NamesAllocationMap;\n\n options: SheetOptions;\n\n tag: void | GroupedTag;\n\n /** Register a group ID to give it an index */\n static registerId(id: string): number {\n return getGroupForId(id);\n }\n\n constructor(\n options: SheetConstructorArgs = defaultOptions,\n globalStyles?: GlobalStylesAllocationMap = {},\n names?: NamesAllocationMap\n ) {\n this.options = {\n ...defaultOptions,\n ...options,\n };\n\n this.gs = globalStyles;\n this.names = new Map(names);\n\n // We rehydrate only once and use the sheet that is created first\n if (!this.options.isServer && IS_BROWSER && SHOULD_REHYDRATE) {\n SHOULD_REHYDRATE = false;\n rehydrateSheet(this);\n }\n }\n\n reconstructWithOptions(options: SheetConstructorArgs, withNames?: boolean = true) {\n return new StyleSheet(\n { ...this.options, ...options },\n this.gs,\n (withNames && this.names) || undefined\n );\n }\n\n allocateGSInstance(id: string) {\n return (this.gs[id] = (this.gs[id] || 0) + 1);\n }\n\n /** Lazily initialises a GroupedTag for when it's actually needed */\n getTag(): GroupedTag {\n return this.tag || (this.tag = makeGroupedTag(makeTag(this.options)));\n }\n\n /** Check whether a name is known for caching */\n hasNameForId(id: string, name: string): boolean {\n return this.names.has(id) && (this.names.get(id): any).has(name);\n }\n\n /** Mark a group's name as known for caching */\n registerName(id: string, name: string) {\n getGroupForId(id);\n\n if (!this.names.has(id)) {\n const groupNames = new Set();\n groupNames.add(name);\n this.names.set(id, groupNames);\n } else {\n (this.names.get(id): any).add(name);\n }\n }\n\n /** Insert new rules which also marks the name as known */\n insertRules(id: string, name: string, rules: string[]) {\n this.registerName(id, name);\n this.getTag().insertRules(getGroupForId(id), rules);\n }\n\n /** Clears all cached names for a given group ID */\n clearNames(id: string) {\n if (this.names.has(id)) {\n (this.names.get(id): any).clear();\n }\n }\n\n /** Clears all rules for a given group ID */\n clearRules(id: string) {\n this.getTag().clearGroup(getGroupForId(id));\n this.clearNames(id);\n }\n\n /** Clears the entire tag which deletes all rules but not its names */\n clearTag() {\n // NOTE: This does not clear the names, since it's only used during SSR\n // so that we can continuously output only new rules\n this.tag = undefined;\n }\n\n /** Outputs the current sheet as a CSS string with markers for SSR */\n toString(): string {\n return outputSheet(this);\n }\n}\n","// @flow\nimport StyleSheet from '../sheet';\nimport { type Stringifier } from '../types';\nimport throwStyledError from '../utils/error';\nimport { masterStylis } from './StyleSheetManager';\n\nexport default class Keyframes {\n id: string;\n\n name: string;\n\n rules: string;\n\n constructor(name: string, rules: string) {\n this.name = name;\n this.id = `sc-keyframes-${name}`;\n this.rules = rules;\n }\n\n inject = (styleSheet: StyleSheet, stylisInstance: Stringifier = masterStylis) => {\n const resolvedName = this.name + stylisInstance.hash;\n\n if (!styleSheet.hasNameForId(this.id, resolvedName)) {\n styleSheet.insertRules(\n this.id,\n resolvedName,\n stylisInstance(this.rules, resolvedName, '@keyframes')\n );\n }\n };\n\n toString = () => {\n return throwStyledError(12, String(this.name));\n };\n\n getName(stylisInstance: Stringifier = masterStylis) {\n return this.name + stylisInstance.hash;\n }\n}\n","// @flow\n/* eslint-disable import/no-unresolved */\nimport transformDeclPairs from 'css-to-react-native';\n\nimport generateComponentId from '../utils/generateComponentId';\nimport type { RuleSet, StyleSheet } from '../types';\nimport flatten from '../utils/flatten';\n// $FlowFixMe\nimport parse from '../vendor/postcss-safe-parser/parse';\n\nlet generated = {};\n\nexport const resetStyleCache = () => {\n generated = {};\n};\n\n/*\n InlineStyle takes arbitrary CSS and generates a flat object\n */\nexport default (styleSheet: StyleSheet) => {\n class InlineStyle {\n rules: RuleSet;\n\n constructor(rules: RuleSet) {\n this.rules = rules;\n }\n\n generateStyleObject(executionContext: Object) {\n const flatCSS = flatten(this.rules, executionContext).join('');\n\n const hash = generateComponentId(flatCSS);\n if (!generated[hash]) {\n const root = parse(flatCSS);\n const declPairs = [];\n root.each(node => {\n if (node.type === 'decl') {\n declPairs.push([node.prop, node.value]);\n } else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {\n /* eslint-disable no-console */\n console.warn(`Node of type ${node.type} not supported as an inline style`);\n }\n });\n // RN currently does not support differing values for the corner radii of Image\n // components (but does for View). It is almost impossible to tell whether we'll have\n // support, so we'll just disable multiple values here.\n // https://github.com/styled-components/css-to-react-native/issues/11\n const styleObject = transformDeclPairs(declPairs, [\n 'borderRadius',\n 'borderWidth',\n 'borderColor',\n 'borderStyle',\n ]);\n const styles = styleSheet.create({\n generated: styleObject,\n });\n generated[hash] = styles.generated;\n }\n return generated[hash];\n }\n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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"styled-components.native.cjs.js","sources":["../../src/utils/isFunction.js","../../src/utils/isStyledComponent.js","../../src/constants.js","../../src/sheet/GroupedTag.js","../../src/sheet/GroupIDAllocator.js","../../src/sheet/Tag.js","../../src/sheet/Sheet.js","../../src/models/Keyframes.js","../../src/models/InlineStyle.js","../../src/utils/generateDisplayName.js"],"sourcesContent":["// @flow\nexport default function isFunction(test: any): boolean %checks {\n return typeof test === 'function';\n}\n","// @flow\nexport default function isStyledComponent(target: any): boolean %checks {\n return target && typeof target.styledComponentId === 'string';\n}\n","// @flow\n\ndeclare var SC_DISABLE_SPEEDY: ?boolean;\ndeclare var __VERSION__: string;\n\nexport const SC_ATTR: string =\n (typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR)) ||\n 'data-styled';\n\nexport const SC_ATTR_ACTIVE = 'active';\nexport const SC_ATTR_VERSION = 'data-styled-version';\nexport const SC_VERSION = __VERSION__;\nexport const SPLITTER = '/*!sc*/\\n';\n\nexport const IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;\n\nexport const DISABLE_SPEEDY =\n Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'\n ? SC_DISABLE_SPEEDY\n : (typeof process !== 'undefined' && typeof process.env.REACT_APP_SC_DISABLE_SPEEDY !== 'undefined' && process.env.REACT_APP_SC_DISABLE_SPEEDY !== ''\n ? process.env.REACT_APP_SC_DISABLE_SPEEDY === 'false' ? false : process.env.REACT_APP_SC_DISABLE_SPEEDY\n : (typeof process !== 'undefined' && typeof process.env.SC_DISABLE_SPEEDY !== 'undefined' && process.env.SC_DISABLE_SPEEDY !== ''\n ? process.env.SC_DISABLE_SPEEDY === 'false' ? false : process.env.SC_DISABLE_SPEEDY\n : process.env.NODE_ENV !== 'production'\n )\n ));\n\n// Shared empty execution context when generating static styles\nexport const STATIC_EXECUTION_CONTEXT = {};\n","// @flow\n/* eslint-disable no-use-before-define */\n\nimport type { GroupedTag, Tag } from './types';\nimport { SPLITTER } from '../constants';\nimport throwStyledError from '../utils/error';\n\n/** Create a GroupedTag with an underlying Tag implementation */\nexport const makeGroupedTag = (tag: Tag): GroupedTag => {\n return new DefaultGroupedTag(tag);\n};\n\nconst BASE_SIZE = 1 << 9;\n\nclass DefaultGroupedTag implements GroupedTag {\n groupSizes: Uint32Array;\n\n length: number;\n\n tag: Tag;\n\n constructor(tag: Tag) {\n this.groupSizes = new Uint32Array(BASE_SIZE);\n this.length = BASE_SIZE;\n this.tag = tag;\n }\n\n indexOfGroup(group: number): number {\n let index = 0;\n for (let i = 0; i < group; i++) {\n index += this.groupSizes[i];\n }\n\n return index;\n }\n\n insertRules(group: number, rules: string[]): void {\n if (group >= this.groupSizes.length) {\n const oldBuffer = this.groupSizes;\n const oldSize = oldBuffer.length;\n\n let newSize = oldSize;\n while (group >= newSize) {\n newSize <<= 1;\n if (newSize < 0) {\n throwStyledError(16, `${group}`);\n }\n }\n\n this.groupSizes = new Uint32Array(newSize);\n this.groupSizes.set(oldBuffer);\n this.length = newSize;\n\n for (let i = oldSize; i < newSize; i++) {\n this.groupSizes[i] = 0;\n }\n }\n\n let ruleIndex = this.indexOfGroup(group + 1);\n for (let i = 0, l = rules.length; i < l; i++) {\n if (this.tag.insertRule(ruleIndex, rules[i])) {\n this.groupSizes[group]++;\n ruleIndex++;\n }\n }\n }\n\n clearGroup(group: number): void {\n if (group < this.length) {\n const length = this.groupSizes[group];\n const startIndex = this.indexOfGroup(group);\n const endIndex = startIndex + length;\n\n this.groupSizes[group] = 0;\n\n for (let i = startIndex; i < endIndex; i++) {\n this.tag.deleteRule(startIndex);\n }\n }\n }\n\n getGroup(group: number): string {\n let css = '';\n if (group >= this.length || this.groupSizes[group] === 0) {\n return css;\n }\n\n const length = this.groupSizes[group];\n const startIndex = this.indexOfGroup(group);\n const endIndex = startIndex + length;\n\n for (let i = startIndex; i < endIndex; i++) {\n css += `${this.tag.getRule(i)}${SPLITTER}`;\n }\n\n return css;\n }\n}\n","// @flow\n\nimport throwStyledError from '../utils/error';\n\nconst MAX_SMI = 1 << 31 - 1;\n\nlet groupIDRegister: Map<string, number> = new Map();\nlet reverseRegister: Map<number, string> = new Map();\nlet nextFreeGroup = 1;\n\nexport const resetGroupIds = () => {\n groupIDRegister = new Map();\n reverseRegister = new Map();\n nextFreeGroup = 1;\n};\n\nexport const getGroupForId = (id: string): number => {\n if (groupIDRegister.has(id)) {\n return (groupIDRegister.get(id): any);\n }\n\n while (reverseRegister.has(nextFreeGroup)) {\n nextFreeGroup++;\n }\n\n const group = nextFreeGroup++;\n\n if (\n process.env.NODE_ENV !== 'production' &&\n ((group | 0) < 0 || group > MAX_SMI)\n ) {\n throwStyledError(16, `${group}`);\n }\n\n groupIDRegister.set(id, group);\n reverseRegister.set(group, id);\n return group;\n};\n\nexport const getIdForGroup = (group: number): void | string => {\n return reverseRegister.get(group);\n};\n\nexport const setGroupForId = (id: string, group: number) => {\n groupIDRegister.set(id, group);\n reverseRegister.set(group, id);\n};\n","// @flow\n/* eslint-disable no-use-before-define */\n\nimport { makeStyleTag, getSheet } from './dom';\nimport type { SheetOptions, Tag } from './types';\n\n/** Create a CSSStyleSheet-like tag depending on the environment */\nexport const makeTag = ({ isServer, useCSSOMInjection, target }: SheetOptions): Tag => {\n if (isServer) {\n return new VirtualTag(target);\n } else if (useCSSOMInjection) {\n return new CSSOMTag(target);\n } else {\n return new TextTag(target);\n }\n};\n\nexport class CSSOMTag implements Tag {\n element: HTMLStyleElement;\n\n sheet: CSSStyleSheet;\n\n length: number;\n\n constructor(target?: HTMLElement) {\n const element = (this.element = makeStyleTag(target));\n\n // Avoid Edge bug where empty style elements don't create sheets\n element.appendChild(document.createTextNode(''));\n\n this.sheet = getSheet(element);\n this.length = 0;\n }\n\n insertRule(index: number, rule: string): boolean {\n try {\n this.sheet.insertRule(rule, index);\n this.length++;\n return true;\n } catch (_error) {\n return false;\n }\n }\n\n deleteRule(index: number): void {\n this.sheet.deleteRule(index);\n this.length--;\n }\n\n getRule(index: number): string {\n const rule = this.sheet.cssRules[index];\n // Avoid IE11 quirk where cssText is inaccessible on some invalid rules\n if (rule !== undefined && typeof rule.cssText === 'string') {\n return rule.cssText;\n } else {\n return '';\n }\n }\n}\n\n/** A Tag that emulates the CSSStyleSheet API but uses text nodes */\nexport class TextTag implements Tag {\n element: HTMLStyleElement;\n\n nodes: NodeList<Node>;\n\n length: number;\n\n constructor(target?: HTMLElement) {\n const element = (this.element = makeStyleTag(target));\n this.nodes = element.childNodes;\n this.length = 0;\n }\n\n insertRule(index: number, rule: string): boolean {\n if (index <= this.length && index >= 0) {\n const node = document.createTextNode(rule);\n const refNode = this.nodes[index];\n this.element.insertBefore(node, refNode || null);\n this.length++;\n return true;\n } else {\n return false;\n }\n }\n\n deleteRule(index: number): void {\n this.element.removeChild(this.nodes[index]);\n this.length--;\n }\n\n getRule(index: number): string {\n if (index < this.length) {\n return this.nodes[index].textContent;\n } else {\n return '';\n }\n }\n}\n\n/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */\nexport class VirtualTag implements Tag {\n rules: string[];\n\n length: number;\n\n constructor(_target?: HTMLElement) {\n this.rules = [];\n this.length = 0;\n }\n\n insertRule(index: number, rule: string): boolean {\n if (index <= this.length) {\n this.rules.splice(index, 0, rule);\n this.length++;\n return true;\n } else {\n return false;\n }\n }\n\n deleteRule(index: number): void {\n this.rules.splice(index, 1);\n this.length--;\n }\n\n getRule(index: number): string {\n if (index < this.length) {\n return this.rules[index];\n } else {\n return '';\n }\n }\n}\n","// @flow\nimport { DISABLE_SPEEDY, IS_BROWSER } from '../constants';\nimport { EMPTY_OBJECT } from '../utils/empties';\nimport { makeGroupedTag } from './GroupedTag';\nimport { getGroupForId } from './GroupIDAllocator';\nimport { outputSheet, rehydrateSheet } from './Rehydration';\nimport { makeTag } from './Tag';\nimport type { GroupedTag, Sheet, SheetOptions } from './types';\n\nlet SHOULD_REHYDRATE = IS_BROWSER;\n\ntype SheetConstructorArgs = {\n isServer?: boolean,\n useCSSOMInjection?: boolean,\n target?: HTMLElement,\n};\n\ntype GlobalStylesAllocationMap = { [key: string]: number };\ntype NamesAllocationMap = Map<string, Set<string>>;\n\nconst defaultOptions: SheetOptions = {\n isServer: !IS_BROWSER,\n useCSSOMInjection: !DISABLE_SPEEDY,\n};\n\n/** Contains the main stylesheet logic for stringification and caching */\nexport default class StyleSheet implements Sheet {\n gs: GlobalStylesAllocationMap;\n\n names: NamesAllocationMap;\n\n options: SheetOptions;\n\n tag: void | GroupedTag;\n\n /** Register a group ID to give it an index */\n static registerId(id: string): number {\n return getGroupForId(id);\n }\n\n constructor(\n options: SheetConstructorArgs = EMPTY_OBJECT,\n globalStyles?: GlobalStylesAllocationMap = {},\n names?: NamesAllocationMap\n ) {\n this.options = {\n ...defaultOptions,\n ...options,\n };\n\n this.gs = globalStyles;\n this.names = new Map(names);\n\n // We rehydrate only once and use the sheet that is created first\n if (!this.options.isServer && IS_BROWSER && SHOULD_REHYDRATE) {\n SHOULD_REHYDRATE = false;\n rehydrateSheet(this);\n }\n }\n\n reconstructWithOptions(options: SheetConstructorArgs, withNames?: boolean = true) {\n return new StyleSheet(\n { ...this.options, ...options },\n this.gs,\n (withNames && this.names) || undefined\n );\n }\n\n allocateGSInstance(id: string) {\n return (this.gs[id] = (this.gs[id] || 0) + 1);\n }\n\n /** Lazily initialises a GroupedTag for when it's actually needed */\n getTag(): GroupedTag {\n return this.tag || (this.tag = makeGroupedTag(makeTag(this.options)));\n }\n\n /** Check whether a name is known for caching */\n hasNameForId(id: string, name: string): boolean {\n return this.names.has(id) && (this.names.get(id): any).has(name);\n }\n\n /** Mark a group's name as known for caching */\n registerName(id: string, name: string) {\n getGroupForId(id);\n\n if (!this.names.has(id)) {\n const groupNames = new Set();\n groupNames.add(name);\n this.names.set(id, groupNames);\n } else {\n (this.names.get(id): any).add(name);\n }\n }\n\n /** Insert new rules which also marks the name as known */\n insertRules(id: string, name: string, rules: string[]) {\n this.registerName(id, name);\n this.getTag().insertRules(getGroupForId(id), rules);\n }\n\n /** Clears all cached names for a given group ID */\n clearNames(id: string) {\n if (this.names.has(id)) {\n (this.names.get(id): any).clear();\n }\n }\n\n /** Clears all rules for a given group ID */\n clearRules(id: string) {\n this.getTag().clearGroup(getGroupForId(id));\n this.clearNames(id);\n }\n\n /** Clears the entire tag which deletes all rules but not its names */\n clearTag() {\n // NOTE: This does not clear the names, since it's only used during SSR\n // so that we can continuously output only new rules\n this.tag = undefined;\n }\n\n /** Outputs the current sheet as a CSS string with markers for SSR */\n toString(): string {\n return outputSheet(this);\n }\n}\n","// @flow\nimport StyleSheet from '../sheet';\nimport { type Stringifier } from '../types';\nimport throwStyledError from '../utils/error';\nimport { masterStylis } from './StyleSheetManager';\n\nexport default class Keyframes {\n id: string;\n\n name: string;\n\n rules: string;\n\n constructor(name: string, rules: string) {\n this.name = name;\n this.id = `sc-keyframes-${name}`;\n this.rules = rules;\n }\n\n inject = (styleSheet: StyleSheet, stylisInstance: Stringifier = masterStylis) => {\n const resolvedName = this.name + stylisInstance.hash;\n\n if (!styleSheet.hasNameForId(this.id, resolvedName)) {\n styleSheet.insertRules(\n this.id,\n resolvedName,\n stylisInstance(this.rules, resolvedName, '@keyframes')\n );\n }\n };\n\n toString = () => {\n return throwStyledError(12, String(this.name));\n };\n\n getName(stylisInstance: Stringifier = masterStylis) {\n return this.name + stylisInstance.hash;\n }\n}\n","// @flow\n/* eslint-disable import/no-unresolved */\nimport transformDeclPairs from 'css-to-react-native';\n\nimport generateComponentId from '../utils/generateComponentId';\nimport type { RuleSet, StyleSheet } from '../types';\nimport flatten from '../utils/flatten';\n// $FlowFixMe\nimport parse from '../vendor/postcss-safe-parser/parse';\n\nlet generated = {};\n\nexport const resetStyleCache = () => {\n generated = {};\n};\n\n/*\n InlineStyle takes arbitrary CSS and generates a flat object\n */\nexport default (styleSheet: StyleSheet) => {\n class InlineStyle {\n rules: RuleSet;\n\n constructor(rules: RuleSet) {\n this.rules = rules;\n }\n\n generateStyleObject(executionContext: Object) {\n const flatCSS = flatten(this.rules, executionContext).join('');\n\n const hash = generateComponentId(flatCSS);\n if (!generated[hash]) {\n const root = parse(flatCSS);\n const declPairs = [];\n root.each(node => {\n if (node.type === 'decl') {\n declPairs.push([node.prop, node.value]);\n } else if (process.env.NODE_ENV !== 'production' && node.type !== 'comment') {\n /* eslint-disable no-console */\n console.warn(`Node of type ${node.type} not supported as an inline style`);\n }\n });\n // RN currently does not support differing values for the corner radii of Image\n // components (but does for View). It is almost impossible to tell whether we'll have\n // support, so we'll just disable multiple values here.\n // https://github.com/styled-components/css-to-react-native/issues/11\n const styleObject = transformDeclPairs(declPairs, [\n 'borderRadius',\n 'borderWidth',\n 'borderColor',\n 'borderStyle',\n ]);\n const styles = styleSheet.create({\n generated: styleObject,\n });\n generated[hash] = styles.generated;\n }\n return generated[hash];\n }\n }\n\n return InlineStyle;\n};\n","// @flow\nimport type { IStyledComponent } from '../types';\nimport getComponentName from './getComponentName';\nimport isTag from './isTag';\n\nexport default function generateDisplayName(\n target: $PropertyType<IStyledComponent, 'target'>\n): string {\n return isTag(target) ? `styled.${target}` : `Styled(${getComponentName(target)})`;\n}\n"],"names":["nodes","insertRule","names","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BACuD;;;;;;;;;;;;;;;mCCAS;;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