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