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
|
@@ -148,17 +148,14 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
148
148
|
var SC_ATTR = typeof process !== 'undefined' && (process.env.REACT_APP_SC_ATTR || process.env.SC_ATTR) || 'data-styled';
|
|
149
149
|
var SC_ATTR_ACTIVE = 'active';
|
|
150
150
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
151
|
-
var SC_VERSION = "5.
|
|
151
|
+
var SC_VERSION = "5.3.0";
|
|
152
152
|
var SPLITTER = '/*!sc*/\n';
|
|
153
153
|
var IS_BROWSER = typeof window !== 'undefined' && 'HTMLElement' in window;
|
|
154
|
-
var DISABLE_SPEEDY = typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
154
|
+
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
|
|
155
155
|
|
|
156
156
|
//
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
var getNonce = function getNonce() {
|
|
160
|
-
return typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null;
|
|
161
|
-
};
|
|
157
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
158
|
+
var EMPTY_OBJECT = Object.freeze({});
|
|
162
159
|
|
|
163
160
|
var errorMap = {
|
|
164
161
|
"1": "Cannot create styled-component for component: %s.\n\n",
|
|
@@ -217,192 +214,6 @@ function throwStyledComponentsError(code) {
|
|
|
217
214
|
}
|
|
218
215
|
}
|
|
219
216
|
|
|
220
|
-
//
|
|
221
|
-
var ELEMENT_TYPE = 1;
|
|
222
|
-
/* Node.ELEMENT_TYPE */
|
|
223
|
-
|
|
224
|
-
/** Find last style element if any inside target */
|
|
225
|
-
|
|
226
|
-
var findLastStyleTag = function findLastStyleTag(target) {
|
|
227
|
-
var childNodes = target.childNodes;
|
|
228
|
-
|
|
229
|
-
for (var i = childNodes.length; i >= 0; i--) {
|
|
230
|
-
var child = childNodes[i];
|
|
231
|
-
|
|
232
|
-
if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
|
|
233
|
-
return child;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
return undefined;
|
|
238
|
-
};
|
|
239
|
-
/** Create a style element inside `target` or <head> after the last */
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
var makeStyleTag = function makeStyleTag(target) {
|
|
243
|
-
var head = document.head;
|
|
244
|
-
var parent = target || head;
|
|
245
|
-
var style = document.createElement('style');
|
|
246
|
-
var prevStyle = findLastStyleTag(parent);
|
|
247
|
-
var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
|
|
248
|
-
style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
|
|
249
|
-
style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
|
|
250
|
-
var nonce = getNonce();
|
|
251
|
-
if (nonce) style.setAttribute('nonce', nonce);
|
|
252
|
-
parent.insertBefore(style, nextSibling);
|
|
253
|
-
return style;
|
|
254
|
-
};
|
|
255
|
-
/** Get the CSSStyleSheet instance for a given style element */
|
|
256
|
-
|
|
257
|
-
var getSheet = function getSheet(tag) {
|
|
258
|
-
if (tag.sheet) {
|
|
259
|
-
return tag.sheet;
|
|
260
|
-
} // Avoid Firefox quirk where the style element might not have a sheet property
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
var _document = document,
|
|
264
|
-
styleSheets = _document.styleSheets;
|
|
265
|
-
|
|
266
|
-
for (var i = 0, l = styleSheets.length; i < l; i++) {
|
|
267
|
-
var sheet = styleSheets[i];
|
|
268
|
-
|
|
269
|
-
if (sheet.ownerNode === tag) {
|
|
270
|
-
return sheet;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
throwStyledComponentsError(17);
|
|
275
|
-
return undefined;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
//
|
|
279
|
-
/** Create a CSSStyleSheet-like tag depending on the environment */
|
|
280
|
-
|
|
281
|
-
var makeTag = function makeTag(_ref) {
|
|
282
|
-
var isServer = _ref.isServer,
|
|
283
|
-
useCSSOMInjection = _ref.useCSSOMInjection,
|
|
284
|
-
target = _ref.target;
|
|
285
|
-
|
|
286
|
-
if (isServer) {
|
|
287
|
-
return new VirtualTag(target);
|
|
288
|
-
} else if (useCSSOMInjection) {
|
|
289
|
-
return new CSSOMTag(target);
|
|
290
|
-
} else {
|
|
291
|
-
return new TextTag(target);
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
var CSSOMTag = /*#__PURE__*/function () {
|
|
295
|
-
function CSSOMTag(target) {
|
|
296
|
-
var element = this.element = makeStyleTag(target); // Avoid Edge bug where empty style elements don't create sheets
|
|
297
|
-
|
|
298
|
-
element.appendChild(document.createTextNode(''));
|
|
299
|
-
this.sheet = getSheet(element);
|
|
300
|
-
this.length = 0;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
var _proto = CSSOMTag.prototype;
|
|
304
|
-
|
|
305
|
-
_proto.insertRule = function insertRule(index, rule) {
|
|
306
|
-
try {
|
|
307
|
-
this.sheet.insertRule(rule, index);
|
|
308
|
-
this.length++;
|
|
309
|
-
return true;
|
|
310
|
-
} catch (_error) {
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
_proto.deleteRule = function deleteRule(index) {
|
|
316
|
-
this.sheet.deleteRule(index);
|
|
317
|
-
this.length--;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
_proto.getRule = function getRule(index) {
|
|
321
|
-
var rule = this.sheet.cssRules[index]; // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
|
|
322
|
-
|
|
323
|
-
if (rule !== undefined && typeof rule.cssText === 'string') {
|
|
324
|
-
return rule.cssText;
|
|
325
|
-
} else {
|
|
326
|
-
return '';
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
return CSSOMTag;
|
|
331
|
-
}();
|
|
332
|
-
/** A Tag that emulates the CSSStyleSheet API but uses text nodes */
|
|
333
|
-
|
|
334
|
-
var TextTag = /*#__PURE__*/function () {
|
|
335
|
-
function TextTag(target) {
|
|
336
|
-
var element = this.element = makeStyleTag(target);
|
|
337
|
-
this.nodes = element.childNodes;
|
|
338
|
-
this.length = 0;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
var _proto2 = TextTag.prototype;
|
|
342
|
-
|
|
343
|
-
_proto2.insertRule = function insertRule(index, rule) {
|
|
344
|
-
if (index <= this.length && index >= 0) {
|
|
345
|
-
var node = document.createTextNode(rule);
|
|
346
|
-
var refNode = this.nodes[index];
|
|
347
|
-
this.element.insertBefore(node, refNode || null);
|
|
348
|
-
this.length++;
|
|
349
|
-
return true;
|
|
350
|
-
} else {
|
|
351
|
-
return false;
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
_proto2.deleteRule = function deleteRule(index) {
|
|
356
|
-
this.element.removeChild(this.nodes[index]);
|
|
357
|
-
this.length--;
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
_proto2.getRule = function getRule(index) {
|
|
361
|
-
if (index < this.length) {
|
|
362
|
-
return this.nodes[index].textContent;
|
|
363
|
-
} else {
|
|
364
|
-
return '';
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
return TextTag;
|
|
369
|
-
}();
|
|
370
|
-
/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
|
|
371
|
-
|
|
372
|
-
var VirtualTag = /*#__PURE__*/function () {
|
|
373
|
-
function VirtualTag(_target) {
|
|
374
|
-
this.rules = [];
|
|
375
|
-
this.length = 0;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
var _proto3 = VirtualTag.prototype;
|
|
379
|
-
|
|
380
|
-
_proto3.insertRule = function insertRule(index, rule) {
|
|
381
|
-
if (index <= this.length) {
|
|
382
|
-
this.rules.splice(index, 0, rule);
|
|
383
|
-
this.length++;
|
|
384
|
-
return true;
|
|
385
|
-
} else {
|
|
386
|
-
return false;
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
_proto3.deleteRule = function deleteRule(index) {
|
|
391
|
-
this.rules.splice(index, 1);
|
|
392
|
-
this.length--;
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
_proto3.getRule = function getRule(index) {
|
|
396
|
-
if (index < this.length) {
|
|
397
|
-
return this.rules[index];
|
|
398
|
-
} else {
|
|
399
|
-
return '';
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
return VirtualTag;
|
|
404
|
-
}();
|
|
405
|
-
|
|
406
217
|
//
|
|
407
218
|
/** Create a GroupedTag with an underlying Tag implementation */
|
|
408
219
|
|
|
@@ -507,6 +318,10 @@ var getGroupForId = function getGroupForId(id) {
|
|
|
507
318
|
return groupIDRegister.get(id);
|
|
508
319
|
}
|
|
509
320
|
|
|
321
|
+
while (reverseRegister.has(nextFreeGroup)) {
|
|
322
|
+
nextFreeGroup++;
|
|
323
|
+
}
|
|
324
|
+
|
|
510
325
|
var group = nextFreeGroup++;
|
|
511
326
|
|
|
512
327
|
if (process.env.NODE_ENV !== 'production' && ((group | 0) < 0 || group > MAX_SMI)) {
|
|
@@ -521,10 +336,6 @@ var getIdForGroup = function getIdForGroup(group) {
|
|
|
521
336
|
return reverseRegister.get(group);
|
|
522
337
|
};
|
|
523
338
|
var setGroupForId = function setGroupForId(id, group) {
|
|
524
|
-
if (group >= nextFreeGroup) {
|
|
525
|
-
nextFreeGroup = group + 1;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
339
|
groupIDRegister.set(id, group);
|
|
529
340
|
reverseRegister.set(group, id);
|
|
530
341
|
};
|
|
@@ -619,6 +430,199 @@ var rehydrateSheet = function rehydrateSheet(sheet) {
|
|
|
619
430
|
}
|
|
620
431
|
};
|
|
621
432
|
|
|
433
|
+
//
|
|
434
|
+
|
|
435
|
+
/* eslint-disable camelcase, no-undef */
|
|
436
|
+
var getNonce = function getNonce() {
|
|
437
|
+
return typeof window !== 'undefined' ? typeof window.__webpack_nonce__ !== 'undefined' ? window.__webpack_nonce__ : null : null;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
//
|
|
441
|
+
var ELEMENT_TYPE = 1;
|
|
442
|
+
/* Node.ELEMENT_TYPE */
|
|
443
|
+
|
|
444
|
+
/** Find last style element if any inside target */
|
|
445
|
+
|
|
446
|
+
var findLastStyleTag = function findLastStyleTag(target) {
|
|
447
|
+
var childNodes = target.childNodes;
|
|
448
|
+
|
|
449
|
+
for (var i = childNodes.length; i >= 0; i--) {
|
|
450
|
+
var child = childNodes[i];
|
|
451
|
+
|
|
452
|
+
if (child && child.nodeType === ELEMENT_TYPE && child.hasAttribute(SC_ATTR)) {
|
|
453
|
+
return child;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
return undefined;
|
|
458
|
+
};
|
|
459
|
+
/** Create a style element inside `target` or <head> after the last */
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
var makeStyleTag = function makeStyleTag(target) {
|
|
463
|
+
var head = document.head;
|
|
464
|
+
var parent = target || head;
|
|
465
|
+
var style = document.createElement('style');
|
|
466
|
+
var prevStyle = findLastStyleTag(parent);
|
|
467
|
+
var nextSibling = prevStyle !== undefined ? prevStyle.nextSibling : null;
|
|
468
|
+
style.setAttribute(SC_ATTR, SC_ATTR_ACTIVE);
|
|
469
|
+
style.setAttribute(SC_ATTR_VERSION, SC_VERSION);
|
|
470
|
+
var nonce = getNonce();
|
|
471
|
+
if (nonce) style.setAttribute('nonce', nonce);
|
|
472
|
+
parent.insertBefore(style, nextSibling);
|
|
473
|
+
return style;
|
|
474
|
+
};
|
|
475
|
+
/** Get the CSSStyleSheet instance for a given style element */
|
|
476
|
+
|
|
477
|
+
var getSheet = function getSheet(tag) {
|
|
478
|
+
if (tag.sheet) {
|
|
479
|
+
return tag.sheet;
|
|
480
|
+
} // Avoid Firefox quirk where the style element might not have a sheet property
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
var _document = document,
|
|
484
|
+
styleSheets = _document.styleSheets;
|
|
485
|
+
|
|
486
|
+
for (var i = 0, l = styleSheets.length; i < l; i++) {
|
|
487
|
+
var sheet = styleSheets[i];
|
|
488
|
+
|
|
489
|
+
if (sheet.ownerNode === tag) {
|
|
490
|
+
return sheet;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
throwStyledComponentsError(17);
|
|
495
|
+
return undefined;
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
//
|
|
499
|
+
/** Create a CSSStyleSheet-like tag depending on the environment */
|
|
500
|
+
|
|
501
|
+
var makeTag = function makeTag(_ref) {
|
|
502
|
+
var isServer = _ref.isServer,
|
|
503
|
+
useCSSOMInjection = _ref.useCSSOMInjection,
|
|
504
|
+
target = _ref.target;
|
|
505
|
+
|
|
506
|
+
if (isServer) {
|
|
507
|
+
return new VirtualTag(target);
|
|
508
|
+
} else if (useCSSOMInjection) {
|
|
509
|
+
return new CSSOMTag(target);
|
|
510
|
+
} else {
|
|
511
|
+
return new TextTag(target);
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
var CSSOMTag = /*#__PURE__*/function () {
|
|
515
|
+
function CSSOMTag(target) {
|
|
516
|
+
var element = this.element = makeStyleTag(target); // Avoid Edge bug where empty style elements don't create sheets
|
|
517
|
+
|
|
518
|
+
element.appendChild(document.createTextNode(''));
|
|
519
|
+
this.sheet = getSheet(element);
|
|
520
|
+
this.length = 0;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
var _proto = CSSOMTag.prototype;
|
|
524
|
+
|
|
525
|
+
_proto.insertRule = function insertRule(index, rule) {
|
|
526
|
+
try {
|
|
527
|
+
this.sheet.insertRule(rule, index);
|
|
528
|
+
this.length++;
|
|
529
|
+
return true;
|
|
530
|
+
} catch (_error) {
|
|
531
|
+
return false;
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
|
|
535
|
+
_proto.deleteRule = function deleteRule(index) {
|
|
536
|
+
this.sheet.deleteRule(index);
|
|
537
|
+
this.length--;
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
_proto.getRule = function getRule(index) {
|
|
541
|
+
var rule = this.sheet.cssRules[index]; // Avoid IE11 quirk where cssText is inaccessible on some invalid rules
|
|
542
|
+
|
|
543
|
+
if (rule !== undefined && typeof rule.cssText === 'string') {
|
|
544
|
+
return rule.cssText;
|
|
545
|
+
} else {
|
|
546
|
+
return '';
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
return CSSOMTag;
|
|
551
|
+
}();
|
|
552
|
+
/** A Tag that emulates the CSSStyleSheet API but uses text nodes */
|
|
553
|
+
|
|
554
|
+
var TextTag = /*#__PURE__*/function () {
|
|
555
|
+
function TextTag(target) {
|
|
556
|
+
var element = this.element = makeStyleTag(target);
|
|
557
|
+
this.nodes = element.childNodes;
|
|
558
|
+
this.length = 0;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
var _proto2 = TextTag.prototype;
|
|
562
|
+
|
|
563
|
+
_proto2.insertRule = function insertRule(index, rule) {
|
|
564
|
+
if (index <= this.length && index >= 0) {
|
|
565
|
+
var node = document.createTextNode(rule);
|
|
566
|
+
var refNode = this.nodes[index];
|
|
567
|
+
this.element.insertBefore(node, refNode || null);
|
|
568
|
+
this.length++;
|
|
569
|
+
return true;
|
|
570
|
+
} else {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
_proto2.deleteRule = function deleteRule(index) {
|
|
576
|
+
this.element.removeChild(this.nodes[index]);
|
|
577
|
+
this.length--;
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
_proto2.getRule = function getRule(index) {
|
|
581
|
+
if (index < this.length) {
|
|
582
|
+
return this.nodes[index].textContent;
|
|
583
|
+
} else {
|
|
584
|
+
return '';
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
return TextTag;
|
|
589
|
+
}();
|
|
590
|
+
/** A completely virtual (server-side) Tag that doesn't manipulate the DOM */
|
|
591
|
+
|
|
592
|
+
var VirtualTag = /*#__PURE__*/function () {
|
|
593
|
+
function VirtualTag(_target) {
|
|
594
|
+
this.rules = [];
|
|
595
|
+
this.length = 0;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
var _proto3 = VirtualTag.prototype;
|
|
599
|
+
|
|
600
|
+
_proto3.insertRule = function insertRule(index, rule) {
|
|
601
|
+
if (index <= this.length) {
|
|
602
|
+
this.rules.splice(index, 0, rule);
|
|
603
|
+
this.length++;
|
|
604
|
+
return true;
|
|
605
|
+
} else {
|
|
606
|
+
return false;
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
_proto3.deleteRule = function deleteRule(index) {
|
|
611
|
+
this.rules.splice(index, 1);
|
|
612
|
+
this.length--;
|
|
613
|
+
};
|
|
614
|
+
|
|
615
|
+
_proto3.getRule = function getRule(index) {
|
|
616
|
+
if (index < this.length) {
|
|
617
|
+
return this.rules[index];
|
|
618
|
+
} else {
|
|
619
|
+
return '';
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
return VirtualTag;
|
|
624
|
+
}();
|
|
625
|
+
|
|
622
626
|
var SHOULD_REHYDRATE = IS_BROWSER;
|
|
623
627
|
var defaultOptions = {
|
|
624
628
|
isServer: !IS_BROWSER,
|
|
@@ -634,7 +638,7 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
634
638
|
|
|
635
639
|
function StyleSheet(options, globalStyles, names) {
|
|
636
640
|
if (options === void 0) {
|
|
637
|
-
options =
|
|
641
|
+
options = EMPTY_OBJECT;
|
|
638
642
|
}
|
|
639
643
|
|
|
640
644
|
if (globalStyles === void 0) {
|
|
@@ -730,10 +734,6 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
730
734
|
return StyleSheet;
|
|
731
735
|
}();
|
|
732
736
|
|
|
733
|
-
//
|
|
734
|
-
var EMPTY_ARRAY = Object.freeze([]);
|
|
735
|
-
var EMPTY_OBJECT = Object.freeze({});
|
|
736
|
-
|
|
737
737
|
/**
|
|
738
738
|
* MIT License
|
|
739
739
|
*
|
|
@@ -836,7 +836,7 @@ function createStylisInstance(_temp) {
|
|
|
836
836
|
|
|
837
837
|
var selfReferenceReplacer = function selfReferenceReplacer(match, offset, string) {
|
|
838
838
|
if ( // do not replace the first occurrence if it is complex (has a modifier)
|
|
839
|
-
(offset === 0 ?
|
|
839
|
+
(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
|
|
840
840
|
!string.match(_consecutiveSelfRefRegExp)) {
|
|
841
841
|
return "." + _componentId;
|
|
842
842
|
}
|
|
@@ -949,7 +949,7 @@ var Keyframes = /*#__PURE__*/function () {
|
|
|
949
949
|
* https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/hyphenateStyleName.js
|
|
950
950
|
*/
|
|
951
951
|
var uppercaseCheck = /([A-Z])/;
|
|
952
|
-
var uppercasePattern =
|
|
952
|
+
var uppercasePattern = /([A-Z])/g;
|
|
953
953
|
var msPattern = /^ms-/;
|
|
954
954
|
|
|
955
955
|
var prefixAndLowerCase = function prefixAndLowerCase(_char) {
|
|
@@ -5871,7 +5871,6 @@ function isTag(target) {
|
|
|
5871
5871
|
|
|
5872
5872
|
//
|
|
5873
5873
|
function generateDisplayName(target) {
|
|
5874
|
-
// $FlowFixMe
|
|
5875
5874
|
return isTag(target) ? "styled." + target : "Styled(" + getComponentName(target) + ")";
|
|
5876
5875
|
}
|
|
5877
5876
|
|
|
@@ -5953,9 +5952,10 @@ var StyledNativeComponent = /*#__PURE__*/function (_Component) {
|
|
|
5953
5952
|
forwardedComponent = _this2$props.forwardedComponent,
|
|
5954
5953
|
forwardedAs = _this2$props.forwardedAs,
|
|
5955
5954
|
forwardedRef = _this2$props.forwardedRef,
|
|
5955
|
+
testID = _this2$props.testID,
|
|
5956
5956
|
_this2$props$style = _this2$props.style,
|
|
5957
5957
|
style = _this2$props$style === void 0 ? [] : _this2$props$style,
|
|
5958
|
-
props = _objectWithoutPropertiesLoose(_this2$props, ["$as", "as", "forwardedComponent", "forwardedAs", "forwardedRef", "style"]);
|
|
5958
|
+
props = _objectWithoutPropertiesLoose(_this2$props, ["$as", "as", "forwardedComponent", "forwardedAs", "forwardedRef", "testID", "style"]);
|
|
5959
5959
|
|
|
5960
5960
|
var defaultProps = forwardedComponent.defaultProps,
|
|
5961
5961
|
target = forwardedComponent.target,
|
|
@@ -5979,7 +5979,10 @@ var StyledNativeComponent = /*#__PURE__*/function (_Component) {
|
|
|
5979
5979
|
}
|
|
5980
5980
|
}
|
|
5981
5981
|
|
|
5982
|
-
propsForElement.style =
|
|
5982
|
+
propsForElement.style = typeof style === 'function' ? function (state) {
|
|
5983
|
+
return [generatedStyles].concat(style(state));
|
|
5984
|
+
} : [generatedStyles].concat(style);
|
|
5985
|
+
propsForElement.testID = testID;
|
|
5983
5986
|
if (forwardedRef) propsForElement.ref = forwardedRef;
|
|
5984
5987
|
if (forwardedAs) propsForElement.as = forwardedAs;
|
|
5985
5988
|
return createElement(elementToBeRendered, propsForElement);
|
|
@@ -6061,9 +6064,9 @@ var _StyledNativeComponent = (function (InlineStyle) {
|
|
|
6061
6064
|
if (isTargetStyledComp && target.shouldForwardProp) {
|
|
6062
6065
|
if (shouldForwardProp) {
|
|
6063
6066
|
// compose nested shouldForwardProp calls
|
|
6064
|
-
shouldForwardProp = function shouldForwardProp(prop, filterFn) {
|
|
6067
|
+
shouldForwardProp = function shouldForwardProp(prop, filterFn, elementToBeCreated) {
|
|
6065
6068
|
return (// $FlowFixMe
|
|
6066
|
-
target.shouldForwardProp(prop, filterFn) && options.shouldForwardProp(prop, filterFn)
|
|
6069
|
+
target.shouldForwardProp(prop, filterFn, elementToBeCreated) && options.shouldForwardProp(prop, filterFn, elementToBeCreated)
|
|
6067
6070
|
);
|
|
6068
6071
|
};
|
|
6069
6072
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled-components-primitives.esm.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-primitives.esm.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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