styled-components 6.3.11 → 6.3.13-prerelease.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/base.d.ts +1 -1
- package/dist/index-standalone.d.ts +1 -0
- package/dist/models/Keyframes.d.ts +2 -0
- 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 +616 -603
- 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/dist/utils/flatten.d.ts +1 -1
- package/dist/utils/isKeyframes.d.ts +4 -0
- package/native/dist/base.d.ts +1 -1
- package/native/dist/bench/run.d.ts +5 -0
- package/native/dist/dist/base.d.ts +1 -1
- package/native/dist/dist/bench/run.d.ts +5 -0
- package/native/dist/dist/index-standalone.d.ts +1 -0
- package/native/dist/dist/models/Keyframes.d.ts +2 -0
- package/native/dist/dist/test/globals.d.ts +2 -0
- package/native/dist/dist/test/utils.d.ts +163 -0
- package/native/dist/dist/test/veryLargeUnionType.d.ts +1 -0
- package/native/dist/dist/utils/flatten.d.ts +1 -1
- package/native/dist/dist/utils/isKeyframes.d.ts +4 -0
- package/native/dist/dist/utils/rawElement.d.ts +11 -0
- package/native/dist/index-standalone.d.ts +1 -0
- package/native/dist/models/Keyframes.d.ts +2 -0
- package/native/dist/styled-components.native.cjs.js +1 -1
- package/native/dist/styled-components.native.cjs.js.map +1 -1
- package/native/dist/styled-components.native.esm.js +1 -1
- package/native/dist/styled-components.native.esm.js.map +1 -1
- package/native/dist/test/globals.d.ts +2 -0
- package/native/dist/test/utils.d.ts +163 -0
- package/native/dist/test/veryLargeUnionType.d.ts +1 -0
- package/native/dist/utils/domElements.d.ts +1 -1
- package/native/dist/utils/flatten.d.ts +1 -1
- package/native/dist/utils/isKeyframes.d.ts +4 -0
- package/native/dist/utils/rawElement.d.ts +11 -0
- package/package.json +17 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ?
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['react'], factory) :
|
|
4
|
-
(global = global || self, global.styled =
|
|
5
|
-
})(this, (function (React) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
4
|
+
(global = global || self, factory(global.styled = {}, global.React));
|
|
5
|
+
})(this, (function (exports, React) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var SC_ATTR = (typeof process !== 'undefined' &&
|
|
8
8
|
typeof process.env !== 'undefined' &&
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
'data-styled';
|
|
11
11
|
var SC_ATTR_ACTIVE = 'active';
|
|
12
12
|
var SC_ATTR_VERSION = 'data-styled-version';
|
|
13
|
-
var SC_VERSION = "6.3.
|
|
13
|
+
var SC_VERSION = "6.3.13-prerelease.0";
|
|
14
14
|
var SPLITTER = '/*!sc*/\n';
|
|
15
15
|
var IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
16
16
|
var DISABLE_SPEEDY = Boolean(typeof SC_DISABLE_SPEEDY === 'boolean'
|
|
@@ -652,453 +652,6 @@
|
|
|
652
652
|
return StyleSheet;
|
|
653
653
|
}());
|
|
654
654
|
|
|
655
|
-
var e="-ms-";var r="-moz-";var a="-webkit-";var c="comm";var n="rule";var s="decl";var i="@import";var v="@namespace";var b="@keyframes";var g="@layer";var $=Math.abs;var m=String.fromCharCode;var x=Object.assign;function y(e,r){return A(e,0)^45?(((r<<2^A(e,0))<<2^A(e,1))<<2^A(e,2))<<2^A(e,3):0}function j(e){return e.trim()}function z(e,r){return (e=r.exec(e))?e[0]:e}function C(e,r,a){return e.replace(r,a)}function O(e,r,a){return e.indexOf(r,a)}function A(e,r){return e.charCodeAt(r)|0}function M(e,r,a){return e.slice(r,a)}function S(e){return e.length}function q(e){return e.length}function B(e,r){return r.push(e),e}function D(e,r){return e.map(r).join("")}function E(e,r){return e.filter((function(e){return !z(e,r)}))}var F=1;var G=1;var H=0;var I=0;var J=0;var K="";function L(e,r,a,c,n,s,t,u){return {value:e,root:r,parent:a,type:c,props:n,children:s,line:F,column:G,length:t,return:"",siblings:u}}function N(e,r){return x(L("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},r)}function P(e){while(e.root)e=N(e.root,{children:[e]});B(e,e.siblings);}function Q(){return J}function R(){J=I>0?A(K,--I):0;if(G--,J===10)G=1,F--;return J}function T(){J=I<H?A(K,I++):0;if(G++,J===10)G=1,F++;return J}function U(){return A(K,I)}function V(){return I}function W(e,r){return M(K,e,r)}function X(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Y(e){return F=G=1,H=S(K=e),I=0,[]}function Z(e){return K="",e}function _(e){return j(W(I-1,ne(e===91?e+2:e===40?e+1:e)))}function re(e){while(J=U())if(J<33)T();else break;return X(e)>2||X(J)>3?"":" "}function ce(e,r){while(--r&&T())if(J<48||J>102||J>57&&J<65||J>70&&J<97)break;return W(e,V()+(r<6&&U()==32&&T()==32))}function ne(e){while(T())switch(J){case e:return I;case 34:case 39:if(e!==34&&e!==39)ne(J);break;case 40:if(e===41)ne(e);break;case 92:T();break}return I}function se(e,r){while(T())if(e+J===47+10)break;else if(e+J===42+42&&U()===47)break;return "/*"+W(r,I-1)+"*"+m(e===47?e:T())}function te(e){while(!X(U()))T();return W(e,I)}function ue(e){return Z(ie("",null,null,null,[""],e=Y(e),0,[0],e))}function ie(e,r,a,c,n,s,t,u,i){var f=0;var o=0;var l=t;var p=0;var v=0;var b=0;var h=1;var w=1;var d=1;var g=0;var k="";var x=n;var y=s;var j=c;var z=k;while(w)switch(b=g,g=T()){case 40:if(b!=108&&A(z,l-1)==58){if(O(z+=C(_(g),"&","&\f"),"&\f",$(f?u[f-1]:0))!=-1)d=-1;break}case 34:case 39:case 91:z+=_(g);break;case 9:case 10:case 13:case 32:z+=re(b);break;case 92:z+=ce(V()-1,7);continue;case 47:switch(U()){case 42:case 47:B(oe(se(T(),V()),r,a,i),i);if((X(b||1)==5||X(U()||1)==5)&&S(z)&&M(z,-1,void 0)!==" ")z+=" ";break;default:z+="/";}break;case 123*h:u[f++]=S(z)*d;case 125*h:case 59:case 0:switch(g){case 0:case 125:w=0;case 59+o:if(d==-1)z=C(z,/\f/g,"");if(v>0&&(S(z)-l||h===0&&b===47))B(v>32?le(z+";",c,a,l-1,i):le(C(z," ","")+";",c,a,l-2,i),i);break;case 59:z+=";";default:B(j=fe(z,r,a,f,o,n,u,k,x=[],y=[],l,s),s);if(g===123)if(o===0)ie(z,r,j,j,x,s,l,u,y);else {switch(p){case 99:if(A(z,3)===110)break;case 108:if(A(z,2)===97)break;default:o=0;case 100:case 109:case 115:}if(o)ie(e,j,j,c&&B(fe(e,j,j,0,0,n,u,k,n,x=[],l,y),y),n,y,l,u,c?x:y);else ie(z,j,j,j,[""],y,0,u,y);}}f=o=v=0,h=d=1,k=z="",l=t;break;case 58:l=1+S(z),v=b;default:if(h<1)if(g==123)--h;else if(g==125&&h++==0&&R()==125)continue;switch(z+=m(g),g*h){case 38:d=o>0?1:(z+="\f",-1);break;case 44:u[f++]=(S(z)-1)*d,d=1;break;case 64:if(U()===45)z+=_(T());p=U(),o=l=S(k=z+=te(V())),g++;break;case 45:if(b===45&&S(z)==2)h=0;}}return s}function fe(e,r,a,c,s,t,u,i,f,o,l,p){var v=s-1;var b=s===0?t:[""];var h=q(b);for(var w=0,d=0,g=0;w<c;++w)for(var k=0,m=M(e,v+1,v=$(d=u[w])),x=e;k<h;++k)if(x=j(d>0?b[k]+" "+m:C(m,/&\f/g,b[k])))f[g++]=x;return L(e,r,a,s===0?n:i,f,o,l,p)}function oe(e,r,a,n){return L(e,r,a,c,m(Q()),M(e,2,-2),0,n)}function le(e,r,a,c,n){return L(e,r,a,s,M(e,0,c),M(e,c+1,-1),c,n)}function pe(c,n,s){switch(y(c,n)){case 5103:return a+"print-"+c+c;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return a+c+c;case 4855:return a+c.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+c;case 4789:return r+c+c;case 5349:case 4246:case 4810:case 6968:case 2756:return a+c+r+c+e+c+c;case 5936:switch(A(c,n+11)){case 114:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"tb")+c;case 108:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"tb-rl")+c;case 45:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"lr")+c}case 6828:case 4268:case 2903:return a+c+e+c+c;case 6165:return a+c+e+"flex-"+c+c;case 5187:return a+c+C(c,/(\w+).+(:[^]+)/,a+"box-$1$2"+e+"flex-$1$2")+c;case 5443:return a+c+e+"flex-item-"+C(c,/flex-|-self/g,"")+(!z(c,/flex-|baseline/)?e+"grid-row-"+C(c,/flex-|-self/g,""):"")+c;case 4675:return a+c+e+"flex-line-pack"+C(c,/align-content|flex-|-self/g,"")+c;case 5548:return a+c+e+C(c,"shrink","negative")+c;case 5292:return a+c+e+C(c,"basis","preferred-size")+c;case 6060:return a+"box-"+C(c,"-grow","")+a+c+e+C(c,"grow","positive")+c;case 4554:return a+C(c,/([^-])(transform)/g,"$1"+a+"$2")+c;case 6187:return C(C(C(c,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),c,"")+c;case 5495:case 3959:return C(c,/(image-set\([^]*)/,a+"$1"+"$`$1");case 4968:return C(C(c,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+e+"flex-pack:$3"),/space-between/,"justify")+a+c+c;case 4200:if(!z(c,/flex-|baseline/))return e+"grid-column-align"+M(c,n)+c;break;case 2592:case 3360:return e+C(c,"template-","")+c;case 4384:case 3616:if(s&&s.some((function(e,r){return n=r,z(e.props,/grid-\w+-end/)}))){return ~O(c+(s=s[n].value),"span",0)?c:e+C(c,"-start","")+c+e+"grid-row-span:"+(~O(s,"span",0)?z(s,/\d+/):+z(s,/\d+/)-+z(c,/\d+/))+";"}return e+C(c,"-start","")+c;case 4896:case 4128:return s&&s.some((function(e){return z(e.props,/grid-\w+-start/)}))?c:e+C(C(c,"-end","-span"),"span ","")+c;case 4095:case 3583:case 4068:case 2532:return C(c,/(.+)-inline(.+)/,a+"$1$2")+c;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(S(c)-1-n>6)switch(A(c,n+1)){case 109:if(A(c,n+4)!==45)break;case 102:return C(c,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3"+"$1"+r+(A(c,n+3)==108?"$3":"$2-$3"))+c;case 115:return ~O(c,"stretch",0)?pe(C(c,"stretch","fill-available"),n,s)+c:c}break;case 5152:case 5920:return C(c,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,(function(r,a,n,s,t,u,i){return e+a+":"+n+i+(s?e+a+"-span:"+(t?u:+u-+n)+i:"")+c}));case 4949:if(A(c,n+6)===121)return C(c,":",":"+a)+c;break;case 6444:switch(A(c,A(c,14)===45?18:11)){case 120:return C(c,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+a+(A(c,14)===45?"inline-":"")+"box$3"+"$1"+a+"$2$3"+"$1"+e+"$2box$3")+c;case 100:return C(c,":",":"+e)+c}break;case 5719:case 2647:case 2135:case 3927:case 2391:return C(c,"scroll-","scroll-snap-")+c}return c}function ve(e,r){var a="";for(var c=0;c<e.length;c++)a+=r(e[c],c,e,r)||"";return a}function be(e,r,a,t){switch(e.type){case g:if(e.children.length)break;case i:case v:case s:return e.return=e.return||e.value;case c:return "";case b:return e.return=e.value+"{"+ve(e.children,t)+"}";case n:if(!S(e.value=e.props.join(",")))return ""}return S(a=ve(e.children,t))?e.return=e.value+"{"+a+"}":""}function he(e){var r=q(e);return function(a,c,n,s){var t="";for(var u=0;u<r;u++)t+=e[u](a,c,n,s)||"";return t}}function we(e){return function(r){if(!r.root)if(r=r.return)e(r);}}function de(c,t,u,i){if(c.length>-1)if(!c.return)switch(c.type){case s:c.return=pe(c.value,c.length,u);return;case b:return ve([N(c,{value:C(c.value,"@","@"+a)})],i);case n:if(c.length)return D(u=c.props,(function(n){switch(z(n,i=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":P(N(c,{props:[C(n,/:(read-\w+)/,":"+r+"$1")]}));P(N(c,{props:[n]}));x(c,{props:E(u,i)});break;case"::placeholder":P(N(c,{props:[C(n,/:(plac\w+)/,":"+a+"input-$1")]}));P(N(c,{props:[C(n,/:(plac\w+)/,":"+r+"$1")]}));P(N(c,{props:[C(n,/:(plac\w+)/,e+"input-$1")]}));P(N(c,{props:[n]}));x(c,{props:E(u,i)});break}return ""}))}}
|
|
656
|
-
|
|
657
|
-
var SEED$1 = 5381;
|
|
658
|
-
// When we have separate strings it's useful to run a progressive
|
|
659
|
-
// version of djb2 where we pretend that we're still looping over
|
|
660
|
-
// the same string
|
|
661
|
-
var phash = function (h, x) {
|
|
662
|
-
var i = x.length;
|
|
663
|
-
while (i) {
|
|
664
|
-
h = (h * 33) ^ x.charCodeAt(--i);
|
|
665
|
-
}
|
|
666
|
-
return h;
|
|
667
|
-
};
|
|
668
|
-
// This is a djb2 hashing function
|
|
669
|
-
var hash = function (x) {
|
|
670
|
-
return phash(SEED$1, x);
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
var AMP_REGEX = /&/g;
|
|
674
|
-
// Character codes for fast comparison
|
|
675
|
-
var DOUBLE_QUOTE = 34; // "
|
|
676
|
-
var SINGLE_QUOTE = 39; // '
|
|
677
|
-
var SLASH = 47; // /
|
|
678
|
-
var ASTERISK = 42; // *
|
|
679
|
-
var BACKSLASH = 92; // \
|
|
680
|
-
var OPEN_BRACE = 123; // {
|
|
681
|
-
var CLOSE_BRACE = 125; // }
|
|
682
|
-
var SEMICOLON = 59; // ;
|
|
683
|
-
var NEWLINE = 10; // \n
|
|
684
|
-
var OPEN_PAREN = 40; // (
|
|
685
|
-
var CLOSE_PAREN = 41; // )
|
|
686
|
-
/**
|
|
687
|
-
* Strips JS-style line comments (//) from CSS, handling comments anywhere
|
|
688
|
-
* in the line while preserving strings, url() contents, and valid CSS.
|
|
689
|
-
* Optimized with early bail and charCodeAt for performance.
|
|
690
|
-
*/
|
|
691
|
-
function stripLineComments(css) {
|
|
692
|
-
// Fast path: no // means no line comments
|
|
693
|
-
if (css.indexOf('//') === -1)
|
|
694
|
-
return css;
|
|
695
|
-
var len = css.length;
|
|
696
|
-
var parts = [];
|
|
697
|
-
var start = 0;
|
|
698
|
-
var i = 0;
|
|
699
|
-
var inString = 0; // 0 = none, DOUBLE_QUOTE or SINGLE_QUOTE when in string
|
|
700
|
-
var urlDepth = 0; // Track nesting depth inside url()
|
|
701
|
-
while (i < len) {
|
|
702
|
-
var code = css.charCodeAt(i);
|
|
703
|
-
// Track string state
|
|
704
|
-
if ((code === DOUBLE_QUOTE || code === SINGLE_QUOTE) &&
|
|
705
|
-
(i === 0 || css.charCodeAt(i - 1) !== BACKSLASH)) {
|
|
706
|
-
if (inString === 0) {
|
|
707
|
-
inString = code;
|
|
708
|
-
}
|
|
709
|
-
else if (inString === code) {
|
|
710
|
-
inString = 0;
|
|
711
|
-
}
|
|
712
|
-
i++;
|
|
713
|
-
continue;
|
|
714
|
-
}
|
|
715
|
-
// Skip string content
|
|
716
|
-
if (inString !== 0) {
|
|
717
|
-
i++;
|
|
718
|
-
continue;
|
|
719
|
-
}
|
|
720
|
-
// Handle CSS block comments: skip /* ... */ entirely
|
|
721
|
-
if (code === SLASH && i + 1 < len && css.charCodeAt(i + 1) === ASTERISK) {
|
|
722
|
-
i += 2;
|
|
723
|
-
while (i + 1 < len && !(css.charCodeAt(i) === ASTERISK && css.charCodeAt(i + 1) === SLASH)) {
|
|
724
|
-
i++;
|
|
725
|
-
}
|
|
726
|
-
i += 2; // skip past */
|
|
727
|
-
continue;
|
|
728
|
-
}
|
|
729
|
-
// Track url() context - check for 'url(' (case insensitive via | 32)
|
|
730
|
-
if (code === OPEN_PAREN &&
|
|
731
|
-
i >= 3 &&
|
|
732
|
-
(css.charCodeAt(i - 1) | 32) === 108 && // l
|
|
733
|
-
(css.charCodeAt(i - 2) | 32) === 114 && // r
|
|
734
|
-
(css.charCodeAt(i - 3) | 32) === 117 // u
|
|
735
|
-
) {
|
|
736
|
-
urlDepth = 1;
|
|
737
|
-
i++;
|
|
738
|
-
continue;
|
|
739
|
-
}
|
|
740
|
-
// Track nested parentheses inside url()
|
|
741
|
-
if (urlDepth > 0) {
|
|
742
|
-
if (code === CLOSE_PAREN)
|
|
743
|
-
urlDepth--;
|
|
744
|
-
else if (code === OPEN_PAREN)
|
|
745
|
-
urlDepth++;
|
|
746
|
-
i++;
|
|
747
|
-
continue;
|
|
748
|
-
}
|
|
749
|
-
// Strip orphaned */ (no matching /*) — invalid CSS that breaks parsing
|
|
750
|
-
if (code === ASTERISK && i + 1 < len && css.charCodeAt(i + 1) === SLASH) {
|
|
751
|
-
if (i > start)
|
|
752
|
-
parts.push(css.substring(start, i));
|
|
753
|
-
i += 2;
|
|
754
|
-
start = i;
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
// Check for line comment (only when not in url())
|
|
758
|
-
if (code === SLASH && i + 1 < len && css.charCodeAt(i + 1) === SLASH) {
|
|
759
|
-
if (i > start)
|
|
760
|
-
parts.push(css.substring(start, i));
|
|
761
|
-
// Skip to end of line
|
|
762
|
-
while (i < len && css.charCodeAt(i) !== NEWLINE) {
|
|
763
|
-
i++;
|
|
764
|
-
}
|
|
765
|
-
start = i;
|
|
766
|
-
continue;
|
|
767
|
-
}
|
|
768
|
-
i++;
|
|
769
|
-
}
|
|
770
|
-
// No comments found after indexOf check means // was in a string or url()
|
|
771
|
-
if (start === 0)
|
|
772
|
-
return css;
|
|
773
|
-
if (start < len)
|
|
774
|
-
parts.push(css.substring(start));
|
|
775
|
-
return parts.join('');
|
|
776
|
-
}
|
|
777
|
-
/**
|
|
778
|
-
* Checks if CSS has unbalanced closing braces that would cause stylis
|
|
779
|
-
* to prematurely close rule blocks.
|
|
780
|
-
* Optimized with early bail and charCodeAt for performance.
|
|
781
|
-
*/
|
|
782
|
-
function hasUnbalancedBraces(css) {
|
|
783
|
-
// Fast path: no closing brace means can't have unbalanced braces
|
|
784
|
-
if (css.indexOf('}') === -1)
|
|
785
|
-
return false;
|
|
786
|
-
var len = css.length;
|
|
787
|
-
var depth = 0;
|
|
788
|
-
var inString = 0; // 0 = none, char code when in string
|
|
789
|
-
var inComment = false;
|
|
790
|
-
for (var i = 0; i < len; i++) {
|
|
791
|
-
var code = css.charCodeAt(i);
|
|
792
|
-
// Handle CSS comments
|
|
793
|
-
if (inString === 0 && !inComment && code === SLASH && css.charCodeAt(i + 1) === ASTERISK) {
|
|
794
|
-
inComment = true;
|
|
795
|
-
i++;
|
|
796
|
-
continue;
|
|
797
|
-
}
|
|
798
|
-
if (inComment) {
|
|
799
|
-
if (code === ASTERISK && css.charCodeAt(i + 1) === SLASH) {
|
|
800
|
-
inComment = false;
|
|
801
|
-
i++;
|
|
802
|
-
}
|
|
803
|
-
continue;
|
|
804
|
-
}
|
|
805
|
-
// Track string state
|
|
806
|
-
if ((code === DOUBLE_QUOTE || code === SINGLE_QUOTE) &&
|
|
807
|
-
(i === 0 || css.charCodeAt(i - 1) !== BACKSLASH)) {
|
|
808
|
-
if (inString === 0) {
|
|
809
|
-
inString = code;
|
|
810
|
-
}
|
|
811
|
-
else if (inString === code) {
|
|
812
|
-
inString = 0;
|
|
813
|
-
}
|
|
814
|
-
continue;
|
|
815
|
-
}
|
|
816
|
-
if (inString !== 0)
|
|
817
|
-
continue;
|
|
818
|
-
// Track brace depth
|
|
819
|
-
if (code === OPEN_BRACE) {
|
|
820
|
-
depth++;
|
|
821
|
-
}
|
|
822
|
-
else if (code === CLOSE_BRACE) {
|
|
823
|
-
depth--;
|
|
824
|
-
if (depth < 0)
|
|
825
|
-
return true;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
return depth !== 0 || inString !== 0;
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* Sanitizes CSS by removing declarations with unbalanced braces.
|
|
832
|
-
* This contains invalid syntax to just the affected declaration.
|
|
833
|
-
* Optimized with charCodeAt for performance.
|
|
834
|
-
*/
|
|
835
|
-
function sanitizeCSS(css) {
|
|
836
|
-
// Fast path: valid CSS passes through unchanged
|
|
837
|
-
if (!hasUnbalancedBraces(css)) {
|
|
838
|
-
return css;
|
|
839
|
-
}
|
|
840
|
-
var len = css.length;
|
|
841
|
-
var result = '';
|
|
842
|
-
var declStart = 0;
|
|
843
|
-
var braceDepth = 0;
|
|
844
|
-
var inString = 0;
|
|
845
|
-
var inComment = false;
|
|
846
|
-
for (var i = 0; i < len; i++) {
|
|
847
|
-
var code = css.charCodeAt(i);
|
|
848
|
-
// Handle CSS comments
|
|
849
|
-
if (inString === 0 && !inComment && code === SLASH && css.charCodeAt(i + 1) === ASTERISK) {
|
|
850
|
-
inComment = true;
|
|
851
|
-
i++;
|
|
852
|
-
continue;
|
|
853
|
-
}
|
|
854
|
-
if (inComment) {
|
|
855
|
-
if (code === ASTERISK && css.charCodeAt(i + 1) === SLASH) {
|
|
856
|
-
inComment = false;
|
|
857
|
-
i++;
|
|
858
|
-
}
|
|
859
|
-
continue;
|
|
860
|
-
}
|
|
861
|
-
// Track string state
|
|
862
|
-
if ((code === DOUBLE_QUOTE || code === SINGLE_QUOTE) &&
|
|
863
|
-
(i === 0 || css.charCodeAt(i - 1) !== BACKSLASH)) {
|
|
864
|
-
if (inString === 0) {
|
|
865
|
-
inString = code;
|
|
866
|
-
}
|
|
867
|
-
else if (inString === code) {
|
|
868
|
-
inString = 0;
|
|
869
|
-
}
|
|
870
|
-
continue;
|
|
871
|
-
}
|
|
872
|
-
if (inString !== 0)
|
|
873
|
-
continue;
|
|
874
|
-
if (code === OPEN_BRACE) {
|
|
875
|
-
braceDepth++;
|
|
876
|
-
}
|
|
877
|
-
else if (code === CLOSE_BRACE) {
|
|
878
|
-
braceDepth--;
|
|
879
|
-
if (braceDepth < 0) {
|
|
880
|
-
// Extra closing brace - skip to next semicolon or newline
|
|
881
|
-
var skipEnd = i + 1;
|
|
882
|
-
while (skipEnd < len) {
|
|
883
|
-
var skipCode = css.charCodeAt(skipEnd);
|
|
884
|
-
if (skipCode === SEMICOLON || skipCode === NEWLINE)
|
|
885
|
-
break;
|
|
886
|
-
skipEnd++;
|
|
887
|
-
}
|
|
888
|
-
if (skipEnd < len && css.charCodeAt(skipEnd) === SEMICOLON)
|
|
889
|
-
skipEnd++;
|
|
890
|
-
braceDepth = 0;
|
|
891
|
-
i = skipEnd - 1;
|
|
892
|
-
declStart = skipEnd;
|
|
893
|
-
continue;
|
|
894
|
-
}
|
|
895
|
-
if (braceDepth === 0) {
|
|
896
|
-
result += css.substring(declStart, i + 1);
|
|
897
|
-
declStart = i + 1;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
else if (code === SEMICOLON && braceDepth === 0) {
|
|
901
|
-
result += css.substring(declStart, i + 1);
|
|
902
|
-
declStart = i + 1;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
// Add remaining valid content
|
|
906
|
-
if (declStart < len) {
|
|
907
|
-
var remaining = css.substring(declStart);
|
|
908
|
-
if (!hasUnbalancedBraces(remaining)) {
|
|
909
|
-
result += remaining;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
return result;
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* Takes an element and recurses through it's rules added the namespace to the start of each selector.
|
|
916
|
-
* Takes into account media queries by recursing through child rules if they are present.
|
|
917
|
-
*/
|
|
918
|
-
function recursivelySetNamepace(compiled, namespace) {
|
|
919
|
-
return compiled.map(function (rule) {
|
|
920
|
-
if (rule.type === 'rule') {
|
|
921
|
-
// add the namespace to the start
|
|
922
|
-
rule.value = "".concat(namespace, " ").concat(rule.value);
|
|
923
|
-
// add the namespace after each comma for subsequent selectors.
|
|
924
|
-
rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
|
|
925
|
-
rule.props = rule.props.map(function (prop) {
|
|
926
|
-
return "".concat(namespace, " ").concat(prop);
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
if (Array.isArray(rule.children) && rule.type !== '@keyframes') {
|
|
930
|
-
rule.children = recursivelySetNamepace(rule.children, namespace);
|
|
931
|
-
}
|
|
932
|
-
return rule;
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
function createStylisInstance(_a) {
|
|
936
|
-
var _b = _a === void 0 ? EMPTY_OBJECT : _a, _c = _b.options, options = _c === void 0 ? EMPTY_OBJECT : _c, _d = _b.plugins, plugins = _d === void 0 ? EMPTY_ARRAY : _d;
|
|
937
|
-
var _componentId;
|
|
938
|
-
var _selector;
|
|
939
|
-
var _selectorRegexp;
|
|
940
|
-
var selfReferenceReplacer = function (match, offset, string) {
|
|
941
|
-
if (
|
|
942
|
-
/**
|
|
943
|
-
* We only want to refer to the static class directly if the selector is part of a
|
|
944
|
-
* self-reference selector `& + & { color: red; }`
|
|
945
|
-
*/
|
|
946
|
-
string.startsWith(_selector) &&
|
|
947
|
-
string.endsWith(_selector) &&
|
|
948
|
-
string.replaceAll(_selector, '').length > 0) {
|
|
949
|
-
return ".".concat(_componentId);
|
|
950
|
-
}
|
|
951
|
-
return match;
|
|
952
|
-
};
|
|
953
|
-
/**
|
|
954
|
-
* When writing a style like
|
|
955
|
-
*
|
|
956
|
-
* & + & {
|
|
957
|
-
* color: red;
|
|
958
|
-
* }
|
|
959
|
-
*
|
|
960
|
-
* The second ampersand should be a reference to the static component class. stylis
|
|
961
|
-
* has no knowledge of static class so we have to intelligently replace the base selector.
|
|
962
|
-
*
|
|
963
|
-
* https://github.com/thysultan/stylis.js/tree/v4.0.2#abstract-syntax-structure
|
|
964
|
-
*/
|
|
965
|
-
var selfReferenceReplacementPlugin = function (element) {
|
|
966
|
-
if (element.type === n && element.value.includes('&')) {
|
|
967
|
-
// Lazy RegExp creation: only allocate when self-reference pattern is actually used
|
|
968
|
-
if (!_selectorRegexp) {
|
|
969
|
-
_selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
|
|
970
|
-
}
|
|
971
|
-
element.props[0] = element.props[0]
|
|
972
|
-
// catch any hanging references that stylis missed
|
|
973
|
-
.replace(AMP_REGEX, _selector)
|
|
974
|
-
.replace(_selectorRegexp, selfReferenceReplacer);
|
|
975
|
-
}
|
|
976
|
-
};
|
|
977
|
-
var middlewares = plugins.slice();
|
|
978
|
-
middlewares.push(selfReferenceReplacementPlugin);
|
|
979
|
-
/**
|
|
980
|
-
* Enables automatic vendor-prefixing for styles.
|
|
981
|
-
*/
|
|
982
|
-
if (options.prefix) {
|
|
983
|
-
middlewares.push(de);
|
|
984
|
-
}
|
|
985
|
-
middlewares.push(be);
|
|
986
|
-
// Pre-build the middleware chain once to avoid allocating closures,
|
|
987
|
-
// arrays, and middleware wrappers on every stringifyRules call.
|
|
988
|
-
// Safe because JS is single-threaded and _stack is consumed before next call.
|
|
989
|
-
var _stack = [];
|
|
990
|
-
var _middleware = he(middlewares.concat(we(function (value) { return _stack.push(value); })));
|
|
991
|
-
var stringifyRules = function (css, selector,
|
|
992
|
-
/**
|
|
993
|
-
* This "prefix" referes to a _selector_ prefix.
|
|
994
|
-
*/
|
|
995
|
-
prefix, componentId) {
|
|
996
|
-
if (selector === void 0) { selector = ''; }
|
|
997
|
-
if (prefix === void 0) { prefix = ''; }
|
|
998
|
-
if (componentId === void 0) { componentId = '&'; }
|
|
999
|
-
// stylis has no concept of state to be passed to plugins
|
|
1000
|
-
// but since JS is single-threaded, we can rely on that to ensure
|
|
1001
|
-
// these properties stay in sync with the current stylis run
|
|
1002
|
-
_componentId = componentId;
|
|
1003
|
-
_selector = selector;
|
|
1004
|
-
_selectorRegexp = undefined; // Reset for lazy creation per call
|
|
1005
|
-
var flatCSS = sanitizeCSS(stripLineComments(css));
|
|
1006
|
-
var compiled = ue(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
|
|
1007
|
-
if (options.namespace) {
|
|
1008
|
-
compiled = recursivelySetNamepace(compiled, options.namespace);
|
|
1009
|
-
}
|
|
1010
|
-
_stack = [];
|
|
1011
|
-
ve(compiled, _middleware);
|
|
1012
|
-
return _stack;
|
|
1013
|
-
};
|
|
1014
|
-
stringifyRules.hash = plugins.length
|
|
1015
|
-
? plugins
|
|
1016
|
-
.reduce(function (acc, plugin) {
|
|
1017
|
-
if (!plugin.name) {
|
|
1018
|
-
throwStyledComponentsError(15);
|
|
1019
|
-
}
|
|
1020
|
-
return phash(acc, plugin.name);
|
|
1021
|
-
}, SEED$1)
|
|
1022
|
-
.toString()
|
|
1023
|
-
: '';
|
|
1024
|
-
return stringifyRules;
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
var mainSheet = new StyleSheet();
|
|
1028
|
-
var mainStylis = createStylisInstance();
|
|
1029
|
-
var defaultContextValue = {
|
|
1030
|
-
shouldForwardProp: undefined,
|
|
1031
|
-
styleSheet: mainSheet,
|
|
1032
|
-
stylis: mainStylis,
|
|
1033
|
-
};
|
|
1034
|
-
// Create context only if createContext is available, otherwise create a fallback
|
|
1035
|
-
var StyleSheetContext = React.createContext(defaultContextValue)
|
|
1036
|
-
;
|
|
1037
|
-
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1038
|
-
var StylisContext = React.createContext(undefined)
|
|
1039
|
-
;
|
|
1040
|
-
function useStyleSheetContext() {
|
|
1041
|
-
// Skip useContext if we're in an RSC environment without context support
|
|
1042
|
-
return React.useContext(StyleSheetContext) ;
|
|
1043
|
-
}
|
|
1044
|
-
function StyleSheetManager(props) {
|
|
1045
|
-
// In RSC environments without context support, StyleSheetManager becomes a no-op
|
|
1046
|
-
if (!React.useMemo) {
|
|
1047
|
-
return props.children;
|
|
1048
|
-
}
|
|
1049
|
-
var styleSheet = useStyleSheetContext().styleSheet;
|
|
1050
|
-
var resolvedStyleSheet = React.useMemo(function () {
|
|
1051
|
-
var sheet = styleSheet;
|
|
1052
|
-
if (props.sheet) {
|
|
1053
|
-
sheet = props.sheet;
|
|
1054
|
-
}
|
|
1055
|
-
else if (props.target) {
|
|
1056
|
-
sheet = sheet.reconstructWithOptions({ target: props.target }, false);
|
|
1057
|
-
}
|
|
1058
|
-
if (props.disableCSSOMInjection) {
|
|
1059
|
-
sheet = sheet.reconstructWithOptions({ useCSSOMInjection: false });
|
|
1060
|
-
}
|
|
1061
|
-
return sheet;
|
|
1062
|
-
}, [props.disableCSSOMInjection, props.sheet, props.target, styleSheet]);
|
|
1063
|
-
var stylis = React.useMemo(function () {
|
|
1064
|
-
return createStylisInstance({
|
|
1065
|
-
options: { namespace: props.namespace, prefix: props.enableVendorPrefixes },
|
|
1066
|
-
plugins: props.stylisPlugins,
|
|
1067
|
-
});
|
|
1068
|
-
}, [props.enableVendorPrefixes, props.namespace, props.stylisPlugins]);
|
|
1069
|
-
var styleSheetContextValue = React.useMemo(function () { return ({
|
|
1070
|
-
shouldForwardProp: props.shouldForwardProp,
|
|
1071
|
-
styleSheet: resolvedStyleSheet,
|
|
1072
|
-
stylis: stylis,
|
|
1073
|
-
}); }, [props.shouldForwardProp, resolvedStyleSheet, stylis]);
|
|
1074
|
-
return (React.createElement(StyleSheetContext.Provider, { value: styleSheetContextValue },
|
|
1075
|
-
React.createElement(StylisContext.Provider, { value: stylis }, props.children)));
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
var Keyframes = /** @class */ (function () {
|
|
1079
|
-
function Keyframes(name, rules) {
|
|
1080
|
-
var _this = this;
|
|
1081
|
-
this.inject = function (styleSheet, stylisInstance) {
|
|
1082
|
-
if (stylisInstance === void 0) { stylisInstance = mainStylis; }
|
|
1083
|
-
var resolvedName = _this.name + stylisInstance.hash;
|
|
1084
|
-
if (!styleSheet.hasNameForId(_this.id, resolvedName)) {
|
|
1085
|
-
styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
this.name = name;
|
|
1089
|
-
this.id = "sc-keyframes-".concat(name);
|
|
1090
|
-
this.rules = rules;
|
|
1091
|
-
setToString(this, function () {
|
|
1092
|
-
throw throwStyledComponentsError(12, String(_this.name));
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
Keyframes.prototype.getName = function (stylisInstance) {
|
|
1096
|
-
if (stylisInstance === void 0) { stylisInstance = mainStylis; }
|
|
1097
|
-
return this.name + stylisInstance.hash;
|
|
1098
|
-
};
|
|
1099
|
-
return Keyframes;
|
|
1100
|
-
}());
|
|
1101
|
-
|
|
1102
655
|
var unitlessKeys = {
|
|
1103
656
|
animationIterationCount: 1,
|
|
1104
657
|
aspectRatio: 1,
|
|
@@ -1191,182 +744,610 @@
|
|
|
1191
744
|
if (i === 1 && c === '-' && string[0] === '-') {
|
|
1192
745
|
return string;
|
|
1193
746
|
}
|
|
1194
|
-
if (isUpper(c)) {
|
|
1195
|
-
output += '-' + c.toLowerCase();
|
|
747
|
+
if (isUpper(c)) {
|
|
748
|
+
output += '-' + c.toLowerCase();
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
output += c;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
return output.startsWith('ms-') ? '-' + output : output;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
function isFunction(test) {
|
|
758
|
+
return typeof test === 'function';
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
var KEYFRAMES_SYMBOL = Symbol.for('sc-keyframes');
|
|
762
|
+
function isKeyframes(value) {
|
|
763
|
+
return typeof value === 'object' && value !== null && KEYFRAMES_SYMBOL in value;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
function isPlainObject(x) {
|
|
767
|
+
return (x !== null &&
|
|
768
|
+
typeof x === 'object' &&
|
|
769
|
+
x.constructor.name === Object.name &&
|
|
770
|
+
/* check for reasonable markers that the object isn't an element for react & preact/compat */
|
|
771
|
+
!('props' in x && x.$$typeof));
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function isStatelessFunction(test) {
|
|
775
|
+
return isFunction(test) && !(test.prototype && test.prototype.isReactComponent);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
function isStyledComponent(target) {
|
|
779
|
+
return typeof target === 'object' && 'styledComponentId' in target;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* It's falsish not falsy because 0 is allowed.
|
|
784
|
+
*/
|
|
785
|
+
var isFalsish = function (chunk) {
|
|
786
|
+
return chunk === undefined || chunk === null || chunk === false || chunk === '';
|
|
787
|
+
};
|
|
788
|
+
var objToCssArray = function (obj) {
|
|
789
|
+
var rules = [];
|
|
790
|
+
for (var key in obj) {
|
|
791
|
+
var val = obj[key];
|
|
792
|
+
if (!obj.hasOwnProperty(key) || isFalsish(val))
|
|
793
|
+
continue;
|
|
794
|
+
// @ts-expect-error Property 'isCss' does not exist on type 'any[]'
|
|
795
|
+
if ((Array.isArray(val) && val.isCss) || isFunction(val)) {
|
|
796
|
+
rules.push("".concat(hyphenateStyleName(key), ":"), val, ';');
|
|
797
|
+
}
|
|
798
|
+
else if (isPlainObject(val)) {
|
|
799
|
+
rules.push.apply(rules, __spreadArray(__spreadArray(["".concat(key, " {")], objToCssArray(val), false), ['}'], false));
|
|
800
|
+
}
|
|
801
|
+
else {
|
|
802
|
+
rules.push("".concat(hyphenateStyleName(key), ": ").concat(addUnitIfNeeded(key, val), ";"));
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return rules;
|
|
806
|
+
};
|
|
807
|
+
function flatten(chunk, executionContext, styleSheet, stylisInstance, result) {
|
|
808
|
+
if (result === void 0) { result = []; }
|
|
809
|
+
if (typeof chunk === 'string') {
|
|
810
|
+
if (chunk)
|
|
811
|
+
result.push(chunk);
|
|
812
|
+
return result;
|
|
813
|
+
}
|
|
814
|
+
if (isFalsish(chunk)) {
|
|
815
|
+
return result;
|
|
816
|
+
}
|
|
817
|
+
/* Handle other components */
|
|
818
|
+
if (isStyledComponent(chunk)) {
|
|
819
|
+
result.push(".".concat(chunk.styledComponentId));
|
|
820
|
+
return result;
|
|
821
|
+
}
|
|
822
|
+
/* Either execute or defer the function */
|
|
823
|
+
if (isFunction(chunk)) {
|
|
824
|
+
if (isStatelessFunction(chunk) && executionContext) {
|
|
825
|
+
var fnResult = chunk(executionContext);
|
|
826
|
+
if (typeof fnResult === 'object' &&
|
|
827
|
+
!Array.isArray(fnResult) &&
|
|
828
|
+
!isKeyframes(fnResult) &&
|
|
829
|
+
!isPlainObject(fnResult) &&
|
|
830
|
+
fnResult !== null) {
|
|
831
|
+
console.error("".concat(getComponentName(chunk), " is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details."));
|
|
832
|
+
}
|
|
833
|
+
return flatten(fnResult, executionContext, styleSheet, stylisInstance, result);
|
|
834
|
+
}
|
|
835
|
+
else {
|
|
836
|
+
result.push(chunk);
|
|
837
|
+
return result;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if (isKeyframes(chunk)) {
|
|
841
|
+
if (styleSheet) {
|
|
842
|
+
chunk.inject(styleSheet, stylisInstance);
|
|
843
|
+
result.push(chunk.getName(stylisInstance));
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
result.push(chunk);
|
|
847
|
+
}
|
|
848
|
+
return result;
|
|
849
|
+
}
|
|
850
|
+
/* Handle objects */
|
|
851
|
+
if (isPlainObject(chunk)) {
|
|
852
|
+
var cssArr = objToCssArray(chunk);
|
|
853
|
+
for (var i = 0; i < cssArr.length; i++)
|
|
854
|
+
result.push(cssArr[i]);
|
|
855
|
+
return result;
|
|
856
|
+
}
|
|
857
|
+
if (!Array.isArray(chunk)) {
|
|
858
|
+
result.push(chunk.toString());
|
|
859
|
+
return result;
|
|
860
|
+
}
|
|
861
|
+
for (var i = 0; i < chunk.length; i++) {
|
|
862
|
+
flatten(chunk[i], executionContext, styleSheet, stylisInstance, result);
|
|
863
|
+
}
|
|
864
|
+
return result;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
function isStaticRules(rules) {
|
|
868
|
+
for (var i = 0; i < rules.length; i += 1) {
|
|
869
|
+
var rule = rules[i];
|
|
870
|
+
if (isFunction(rule) && !isStyledComponent(rule)) {
|
|
871
|
+
// functions are allowed to be static if they're just being
|
|
872
|
+
// used to get the classname of a nested styled component
|
|
873
|
+
return false;
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* Convenience function for joining strings to form className chains
|
|
881
|
+
*/
|
|
882
|
+
function joinStrings(a, b) {
|
|
883
|
+
return a && b ? "".concat(a, " ").concat(b) : a || b || '';
|
|
884
|
+
}
|
|
885
|
+
function joinStringArray(arr, sep) {
|
|
886
|
+
return arr.join(sep || '');
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
var GlobalStyle = /** @class */ (function () {
|
|
890
|
+
function GlobalStyle(rules, componentId) {
|
|
891
|
+
this.rules = rules;
|
|
892
|
+
this.componentId = componentId;
|
|
893
|
+
this.isStatic = isStaticRules(rules);
|
|
894
|
+
// pre-register the first instance to ensure global styles
|
|
895
|
+
// load before component ones
|
|
896
|
+
StyleSheet.registerId(this.componentId + 1);
|
|
897
|
+
}
|
|
898
|
+
GlobalStyle.prototype.createStyles = function (instance, executionContext, styleSheet, stylis) {
|
|
899
|
+
var flatCSS = joinStringArray(flatten(this.rules, executionContext, styleSheet, stylis));
|
|
900
|
+
var css = stylis(flatCSS, '');
|
|
901
|
+
var id = this.componentId + instance;
|
|
902
|
+
// NOTE: We use the id as a name as well, since these rules never change
|
|
903
|
+
styleSheet.insertRules(id, id, css);
|
|
904
|
+
};
|
|
905
|
+
GlobalStyle.prototype.removeStyles = function (instance, styleSheet) {
|
|
906
|
+
styleSheet.clearRules(this.componentId + instance);
|
|
907
|
+
};
|
|
908
|
+
GlobalStyle.prototype.renderStyles = function (instance, executionContext, styleSheet, stylis) {
|
|
909
|
+
if (instance > 2)
|
|
910
|
+
StyleSheet.registerId(this.componentId + instance);
|
|
911
|
+
var id = this.componentId + instance;
|
|
912
|
+
// For static styles that don't change based on props,
|
|
913
|
+
// only inject once and don't remove/re-add on every render.
|
|
914
|
+
// This prevents issues with React StrictMode where the effect cleanup
|
|
915
|
+
// from the simulated unmount runs after the re-render.
|
|
916
|
+
if (this.isStatic) {
|
|
917
|
+
if (!styleSheet.hasNameForId(id, id)) {
|
|
918
|
+
this.createStyles(instance, executionContext, styleSheet, stylis);
|
|
919
|
+
}
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
// NOTE: Remove old styles, then inject the new ones
|
|
923
|
+
this.removeStyles(instance, styleSheet);
|
|
924
|
+
this.createStyles(instance, executionContext, styleSheet, stylis);
|
|
925
|
+
};
|
|
926
|
+
return GlobalStyle;
|
|
927
|
+
}());
|
|
928
|
+
|
|
929
|
+
var e="-ms-";var r="-moz-";var a="-webkit-";var c="comm";var n="rule";var s="decl";var i="@import";var v="@namespace";var b="@keyframes";var g="@layer";var $=Math.abs;var m=String.fromCharCode;var x=Object.assign;function y(e,r){return A(e,0)^45?(((r<<2^A(e,0))<<2^A(e,1))<<2^A(e,2))<<2^A(e,3):0}function j(e){return e.trim()}function z(e,r){return (e=r.exec(e))?e[0]:e}function C(e,r,a){return e.replace(r,a)}function O(e,r,a){return e.indexOf(r,a)}function A(e,r){return e.charCodeAt(r)|0}function M(e,r,a){return e.slice(r,a)}function S(e){return e.length}function q(e){return e.length}function B(e,r){return r.push(e),e}function D(e,r){return e.map(r).join("")}function E(e,r){return e.filter((function(e){return !z(e,r)}))}var F=1;var G=1;var H=0;var I=0;var J=0;var K="";function L(e,r,a,c,n,s,t,u){return {value:e,root:r,parent:a,type:c,props:n,children:s,line:F,column:G,length:t,return:"",siblings:u}}function N(e,r){return x(L("",null,null,"",null,null,0,e.siblings),e,{length:-e.length},r)}function P(e){while(e.root)e=N(e.root,{children:[e]});B(e,e.siblings);}function Q(){return J}function R(){J=I>0?A(K,--I):0;if(G--,J===10)G=1,F--;return J}function T(){J=I<H?A(K,I++):0;if(G++,J===10)G=1,F++;return J}function U(){return A(K,I)}function V(){return I}function W(e,r){return M(K,e,r)}function X(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Y(e){return F=G=1,H=S(K=e),I=0,[]}function Z(e){return K="",e}function _(e){return j(W(I-1,ne(e===91?e+2:e===40?e+1:e)))}function re(e){while(J=U())if(J<33)T();else break;return X(e)>2||X(J)>3?"":" "}function ce(e,r){while(--r&&T())if(J<48||J>102||J>57&&J<65||J>70&&J<97)break;return W(e,V()+(r<6&&U()==32&&T()==32))}function ne(e){while(T())switch(J){case e:return I;case 34:case 39:if(e!==34&&e!==39)ne(J);break;case 40:if(e===41)ne(e);break;case 92:T();break}return I}function se(e,r){while(T())if(e+J===47+10)break;else if(e+J===42+42&&U()===47)break;return "/*"+W(r,I-1)+"*"+m(e===47?e:T())}function te(e){while(!X(U()))T();return W(e,I)}function ue(e){return Z(ie("",null,null,null,[""],e=Y(e),0,[0],e))}function ie(e,r,a,c,n,s,t,u,i){var f=0;var o=0;var l=t;var p=0;var v=0;var b=0;var h=1;var w=1;var d=1;var g=0;var k="";var x=n;var y=s;var j=c;var z=k;while(w)switch(b=g,g=T()){case 40:if(b!=108&&A(z,l-1)==58){if(O(z+=C(_(g),"&","&\f"),"&\f",$(f?u[f-1]:0))!=-1)d=-1;break}case 34:case 39:case 91:z+=_(g);break;case 9:case 10:case 13:case 32:z+=re(b);break;case 92:z+=ce(V()-1,7);continue;case 47:switch(U()){case 42:case 47:B(oe(se(T(),V()),r,a,i),i);if((X(b||1)==5||X(U()||1)==5)&&S(z)&&M(z,-1,void 0)!==" ")z+=" ";break;default:z+="/";}break;case 123*h:u[f++]=S(z)*d;case 125*h:case 59:case 0:switch(g){case 0:case 125:w=0;case 59+o:if(d==-1)z=C(z,/\f/g,"");if(v>0&&(S(z)-l||h===0&&b===47))B(v>32?le(z+";",c,a,l-1,i):le(C(z," ","")+";",c,a,l-2,i),i);break;case 59:z+=";";default:B(j=fe(z,r,a,f,o,n,u,k,x=[],y=[],l,s),s);if(g===123)if(o===0)ie(z,r,j,j,x,s,l,u,y);else {switch(p){case 99:if(A(z,3)===110)break;case 108:if(A(z,2)===97)break;default:o=0;case 100:case 109:case 115:}if(o)ie(e,j,j,c&&B(fe(e,j,j,0,0,n,u,k,n,x=[],l,y),y),n,y,l,u,c?x:y);else ie(z,j,j,j,[""],y,0,u,y);}}f=o=v=0,h=d=1,k=z="",l=t;break;case 58:l=1+S(z),v=b;default:if(h<1)if(g==123)--h;else if(g==125&&h++==0&&R()==125)continue;switch(z+=m(g),g*h){case 38:d=o>0?1:(z+="\f",-1);break;case 44:u[f++]=(S(z)-1)*d,d=1;break;case 64:if(U()===45)z+=_(T());p=U(),o=l=S(k=z+=te(V())),g++;break;case 45:if(b===45&&S(z)==2)h=0;}}return s}function fe(e,r,a,c,s,t,u,i,f,o,l,p){var v=s-1;var b=s===0?t:[""];var h=q(b);for(var w=0,d=0,g=0;w<c;++w)for(var k=0,m=M(e,v+1,v=$(d=u[w])),x=e;k<h;++k)if(x=j(d>0?b[k]+" "+m:C(m,/&\f/g,b[k])))f[g++]=x;return L(e,r,a,s===0?n:i,f,o,l,p)}function oe(e,r,a,n){return L(e,r,a,c,m(Q()),M(e,2,-2),0,n)}function le(e,r,a,c,n){return L(e,r,a,s,M(e,0,c),M(e,c+1,-1),c,n)}function pe(c,n,s){switch(y(c,n)){case 5103:return a+"print-"+c+c;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return a+c+c;case 4855:return a+c.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+c;case 4789:return r+c+c;case 5349:case 4246:case 4810:case 6968:case 2756:return a+c+r+c+e+c+c;case 5936:switch(A(c,n+11)){case 114:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"tb")+c;case 108:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"tb-rl")+c;case 45:return a+c+e+C(c,/[svh]\w+-[tblr]{2}/,"lr")+c}case 6828:case 4268:case 2903:return a+c+e+c+c;case 6165:return a+c+e+"flex-"+c+c;case 5187:return a+c+C(c,/(\w+).+(:[^]+)/,a+"box-$1$2"+e+"flex-$1$2")+c;case 5443:return a+c+e+"flex-item-"+C(c,/flex-|-self/g,"")+(!z(c,/flex-|baseline/)?e+"grid-row-"+C(c,/flex-|-self/g,""):"")+c;case 4675:return a+c+e+"flex-line-pack"+C(c,/align-content|flex-|-self/g,"")+c;case 5548:return a+c+e+C(c,"shrink","negative")+c;case 5292:return a+c+e+C(c,"basis","preferred-size")+c;case 6060:return a+"box-"+C(c,"-grow","")+a+c+e+C(c,"grow","positive")+c;case 4554:return a+C(c,/([^-])(transform)/g,"$1"+a+"$2")+c;case 6187:return C(C(C(c,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),c,"")+c;case 5495:case 3959:return C(c,/(image-set\([^]*)/,a+"$1"+"$`$1");case 4968:return C(C(c,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+e+"flex-pack:$3"),/space-between/,"justify")+a+c+c;case 4200:if(!z(c,/flex-|baseline/))return e+"grid-column-align"+M(c,n)+c;break;case 2592:case 3360:return e+C(c,"template-","")+c;case 4384:case 3616:if(s&&s.some((function(e,r){return n=r,z(e.props,/grid-\w+-end/)}))){return ~O(c+(s=s[n].value),"span",0)?c:e+C(c,"-start","")+c+e+"grid-row-span:"+(~O(s,"span",0)?z(s,/\d+/):+z(s,/\d+/)-+z(c,/\d+/))+";"}return e+C(c,"-start","")+c;case 4896:case 4128:return s&&s.some((function(e){return z(e.props,/grid-\w+-start/)}))?c:e+C(C(c,"-end","-span"),"span ","")+c;case 4095:case 3583:case 4068:case 2532:return C(c,/(.+)-inline(.+)/,a+"$1$2")+c;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(S(c)-1-n>6)switch(A(c,n+1)){case 109:if(A(c,n+4)!==45)break;case 102:return C(c,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3"+"$1"+r+(A(c,n+3)==108?"$3":"$2-$3"))+c;case 115:return ~O(c,"stretch",0)?pe(C(c,"stretch","fill-available"),n,s)+c:c}break;case 5152:case 5920:return C(c,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,(function(r,a,n,s,t,u,i){return e+a+":"+n+i+(s?e+a+"-span:"+(t?u:+u-+n)+i:"")+c}));case 4949:if(A(c,n+6)===121)return C(c,":",":"+a)+c;break;case 6444:switch(A(c,A(c,14)===45?18:11)){case 120:return C(c,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+a+(A(c,14)===45?"inline-":"")+"box$3"+"$1"+a+"$2$3"+"$1"+e+"$2box$3")+c;case 100:return C(c,":",":"+e)+c}break;case 5719:case 2647:case 2135:case 3927:case 2391:return C(c,"scroll-","scroll-snap-")+c}return c}function ve(e,r){var a="";for(var c=0;c<e.length;c++)a+=r(e[c],c,e,r)||"";return a}function be(e,r,a,t){switch(e.type){case g:if(e.children.length)break;case i:case v:case s:return e.return=e.return||e.value;case c:return "";case b:return e.return=e.value+"{"+ve(e.children,t)+"}";case n:if(!S(e.value=e.props.join(",")))return ""}return S(a=ve(e.children,t))?e.return=e.value+"{"+a+"}":""}function he(e){var r=q(e);return function(a,c,n,s){var t="";for(var u=0;u<r;u++)t+=e[u](a,c,n,s)||"";return t}}function we(e){return function(r){if(!r.root)if(r=r.return)e(r);}}function de(c,t,u,i){if(c.length>-1)if(!c.return)switch(c.type){case s:c.return=pe(c.value,c.length,u);return;case b:return ve([N(c,{value:C(c.value,"@","@"+a)})],i);case n:if(c.length)return D(u=c.props,(function(n){switch(z(n,i=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":P(N(c,{props:[C(n,/:(read-\w+)/,":"+r+"$1")]}));P(N(c,{props:[n]}));x(c,{props:E(u,i)});break;case"::placeholder":P(N(c,{props:[C(n,/:(plac\w+)/,":"+a+"input-$1")]}));P(N(c,{props:[C(n,/:(plac\w+)/,":"+r+"$1")]}));P(N(c,{props:[C(n,/:(plac\w+)/,e+"input-$1")]}));P(N(c,{props:[n]}));x(c,{props:E(u,i)});break}return ""}))}}
|
|
930
|
+
|
|
931
|
+
var SEED$1 = 5381;
|
|
932
|
+
// When we have separate strings it's useful to run a progressive
|
|
933
|
+
// version of djb2 where we pretend that we're still looping over
|
|
934
|
+
// the same string
|
|
935
|
+
var phash = function (h, x) {
|
|
936
|
+
var i = x.length;
|
|
937
|
+
while (i) {
|
|
938
|
+
h = (h * 33) ^ x.charCodeAt(--i);
|
|
939
|
+
}
|
|
940
|
+
return h;
|
|
941
|
+
};
|
|
942
|
+
// This is a djb2 hashing function
|
|
943
|
+
var hash = function (x) {
|
|
944
|
+
return phash(SEED$1, x);
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
var AMP_REGEX = /&/g;
|
|
948
|
+
// Character codes for fast comparison
|
|
949
|
+
var DOUBLE_QUOTE = 34; // "
|
|
950
|
+
var SINGLE_QUOTE = 39; // '
|
|
951
|
+
var SLASH = 47; // /
|
|
952
|
+
var ASTERISK = 42; // *
|
|
953
|
+
var BACKSLASH = 92; // \
|
|
954
|
+
var OPEN_BRACE = 123; // {
|
|
955
|
+
var CLOSE_BRACE = 125; // }
|
|
956
|
+
var SEMICOLON = 59; // ;
|
|
957
|
+
var NEWLINE = 10; // \n
|
|
958
|
+
var OPEN_PAREN = 40; // (
|
|
959
|
+
var CLOSE_PAREN = 41; // )
|
|
960
|
+
/**
|
|
961
|
+
* Strips JS-style line comments (//) from CSS, handling comments anywhere
|
|
962
|
+
* in the line while preserving strings, url() contents, and valid CSS.
|
|
963
|
+
* Optimized with early bail and charCodeAt for performance.
|
|
964
|
+
*/
|
|
965
|
+
function stripLineComments(css) {
|
|
966
|
+
// Fast path: no // means no line comments
|
|
967
|
+
if (css.indexOf('//') === -1)
|
|
968
|
+
return css;
|
|
969
|
+
var len = css.length;
|
|
970
|
+
var parts = [];
|
|
971
|
+
var start = 0;
|
|
972
|
+
var i = 0;
|
|
973
|
+
var inString = 0; // 0 = none, DOUBLE_QUOTE or SINGLE_QUOTE when in string
|
|
974
|
+
var urlDepth = 0; // Track nesting depth inside url()
|
|
975
|
+
while (i < len) {
|
|
976
|
+
var code = css.charCodeAt(i);
|
|
977
|
+
// Track string state
|
|
978
|
+
if ((code === DOUBLE_QUOTE || code === SINGLE_QUOTE) &&
|
|
979
|
+
(i === 0 || css.charCodeAt(i - 1) !== BACKSLASH)) {
|
|
980
|
+
if (inString === 0) {
|
|
981
|
+
inString = code;
|
|
982
|
+
}
|
|
983
|
+
else if (inString === code) {
|
|
984
|
+
inString = 0;
|
|
985
|
+
}
|
|
986
|
+
i++;
|
|
987
|
+
continue;
|
|
988
|
+
}
|
|
989
|
+
// Skip string content
|
|
990
|
+
if (inString !== 0) {
|
|
991
|
+
i++;
|
|
992
|
+
continue;
|
|
1196
993
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
994
|
+
// Handle CSS block comments: skip /* ... */ entirely
|
|
995
|
+
if (code === SLASH && i + 1 < len && css.charCodeAt(i + 1) === ASTERISK) {
|
|
996
|
+
i += 2;
|
|
997
|
+
while (i + 1 < len && !(css.charCodeAt(i) === ASTERISK && css.charCodeAt(i + 1) === SLASH)) {
|
|
998
|
+
i++;
|
|
999
|
+
}
|
|
1000
|
+
i += 2; // skip past */
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
// Track url() context - check for 'url(' (case insensitive via | 32)
|
|
1004
|
+
if (code === OPEN_PAREN &&
|
|
1005
|
+
i >= 3 &&
|
|
1006
|
+
(css.charCodeAt(i - 1) | 32) === 108 && // l
|
|
1007
|
+
(css.charCodeAt(i - 2) | 32) === 114 && // r
|
|
1008
|
+
(css.charCodeAt(i - 3) | 32) === 117 // u
|
|
1009
|
+
) {
|
|
1010
|
+
urlDepth = 1;
|
|
1011
|
+
i++;
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
// Track nested parentheses inside url()
|
|
1015
|
+
if (urlDepth > 0) {
|
|
1016
|
+
if (code === CLOSE_PAREN)
|
|
1017
|
+
urlDepth--;
|
|
1018
|
+
else if (code === OPEN_PAREN)
|
|
1019
|
+
urlDepth++;
|
|
1020
|
+
i++;
|
|
1021
|
+
continue;
|
|
1022
|
+
}
|
|
1023
|
+
// Strip orphaned */ (no matching /*) — invalid CSS that breaks parsing
|
|
1024
|
+
if (code === ASTERISK && i + 1 < len && css.charCodeAt(i + 1) === SLASH) {
|
|
1025
|
+
if (i > start)
|
|
1026
|
+
parts.push(css.substring(start, i));
|
|
1027
|
+
i += 2;
|
|
1028
|
+
start = i;
|
|
1029
|
+
continue;
|
|
1199
1030
|
}
|
|
1031
|
+
// Check for line comment (only when not in url())
|
|
1032
|
+
if (code === SLASH && i + 1 < len && css.charCodeAt(i + 1) === SLASH) {
|
|
1033
|
+
if (i > start)
|
|
1034
|
+
parts.push(css.substring(start, i));
|
|
1035
|
+
// Skip to end of line
|
|
1036
|
+
while (i < len && css.charCodeAt(i) !== NEWLINE) {
|
|
1037
|
+
i++;
|
|
1038
|
+
}
|
|
1039
|
+
start = i;
|
|
1040
|
+
continue;
|
|
1041
|
+
}
|
|
1042
|
+
i++;
|
|
1200
1043
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
function isPlainObject(x) {
|
|
1209
|
-
return (x !== null &&
|
|
1210
|
-
typeof x === 'object' &&
|
|
1211
|
-
x.constructor.name === Object.name &&
|
|
1212
|
-
/* check for reasonable markers that the object isn't an element for react & preact/compat */
|
|
1213
|
-
!('props' in x && x.$$typeof));
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
function isStatelessFunction(test) {
|
|
1217
|
-
return isFunction(test) && !(test.prototype && test.prototype.isReactComponent);
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
function isStyledComponent(target) {
|
|
1221
|
-
return typeof target === 'object' && 'styledComponentId' in target;
|
|
1044
|
+
// No comments found after indexOf check means // was in a string or url()
|
|
1045
|
+
if (start === 0)
|
|
1046
|
+
return css;
|
|
1047
|
+
if (start < len)
|
|
1048
|
+
parts.push(css.substring(start));
|
|
1049
|
+
return parts.join('');
|
|
1222
1050
|
}
|
|
1223
|
-
|
|
1224
1051
|
/**
|
|
1225
|
-
*
|
|
1052
|
+
* Checks if CSS has unbalanced closing braces that would cause stylis
|
|
1053
|
+
* to prematurely close rule blocks.
|
|
1054
|
+
* Optimized with early bail and charCodeAt for performance.
|
|
1226
1055
|
*/
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
var
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1056
|
+
function hasUnbalancedBraces(css) {
|
|
1057
|
+
// Fast path: no closing brace means can't have unbalanced braces
|
|
1058
|
+
if (css.indexOf('}') === -1)
|
|
1059
|
+
return false;
|
|
1060
|
+
var len = css.length;
|
|
1061
|
+
var depth = 0;
|
|
1062
|
+
var inString = 0; // 0 = none, char code when in string
|
|
1063
|
+
var inComment = false;
|
|
1064
|
+
for (var i = 0; i < len; i++) {
|
|
1065
|
+
var code = css.charCodeAt(i);
|
|
1066
|
+
// Handle CSS comments
|
|
1067
|
+
if (inString === 0 && !inComment && code === SLASH && css.charCodeAt(i + 1) === ASTERISK) {
|
|
1068
|
+
inComment = true;
|
|
1069
|
+
i++;
|
|
1235
1070
|
continue;
|
|
1236
|
-
// @ts-expect-error Property 'isCss' does not exist on type 'any[]'
|
|
1237
|
-
if ((Array.isArray(val) && val.isCss) || isFunction(val)) {
|
|
1238
|
-
rules.push("".concat(hyphenateStyleName(key), ":"), val, ';');
|
|
1239
1071
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1072
|
+
if (inComment) {
|
|
1073
|
+
if (code === ASTERISK && css.charCodeAt(i + 1) === SLASH) {
|
|
1074
|
+
inComment = false;
|
|
1075
|
+
i++;
|
|
1076
|
+
}
|
|
1077
|
+
continue;
|
|
1242
1078
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1079
|
+
// Track string state
|
|
1080
|
+
if ((code === DOUBLE_QUOTE || code === SINGLE_QUOTE) &&
|
|
1081
|
+
(i === 0 || css.charCodeAt(i - 1) !== BACKSLASH)) {
|
|
1082
|
+
if (inString === 0) {
|
|
1083
|
+
inString = code;
|
|
1084
|
+
}
|
|
1085
|
+
else if (inString === code) {
|
|
1086
|
+
inString = 0;
|
|
1087
|
+
}
|
|
1088
|
+
continue;
|
|
1089
|
+
}
|
|
1090
|
+
if (inString !== 0)
|
|
1091
|
+
continue;
|
|
1092
|
+
// Track brace depth
|
|
1093
|
+
if (code === OPEN_BRACE) {
|
|
1094
|
+
depth++;
|
|
1095
|
+
}
|
|
1096
|
+
else if (code === CLOSE_BRACE) {
|
|
1097
|
+
depth--;
|
|
1098
|
+
if (depth < 0)
|
|
1099
|
+
return true;
|
|
1245
1100
|
}
|
|
1246
1101
|
}
|
|
1247
|
-
return
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
if (
|
|
1257
|
-
return
|
|
1258
|
-
}
|
|
1259
|
-
/* Handle other components */
|
|
1260
|
-
if (isStyledComponent(chunk)) {
|
|
1261
|
-
result.push(".".concat(chunk.styledComponentId));
|
|
1262
|
-
return result;
|
|
1102
|
+
return depth !== 0 || inString !== 0;
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* Sanitizes CSS by removing declarations with unbalanced braces.
|
|
1106
|
+
* This contains invalid syntax to just the affected declaration.
|
|
1107
|
+
* Optimized with charCodeAt for performance.
|
|
1108
|
+
*/
|
|
1109
|
+
function sanitizeCSS(css) {
|
|
1110
|
+
// Fast path: valid CSS passes through unchanged
|
|
1111
|
+
if (!hasUnbalancedBraces(css)) {
|
|
1112
|
+
return css;
|
|
1263
1113
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1114
|
+
var len = css.length;
|
|
1115
|
+
var result = '';
|
|
1116
|
+
var declStart = 0;
|
|
1117
|
+
var braceDepth = 0;
|
|
1118
|
+
var inString = 0;
|
|
1119
|
+
var inComment = false;
|
|
1120
|
+
for (var i = 0; i < len; i++) {
|
|
1121
|
+
var code = css.charCodeAt(i);
|
|
1122
|
+
// Handle CSS comments
|
|
1123
|
+
if (inString === 0 && !inComment && code === SLASH && css.charCodeAt(i + 1) === ASTERISK) {
|
|
1124
|
+
inComment = true;
|
|
1125
|
+
i++;
|
|
1126
|
+
continue;
|
|
1276
1127
|
}
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1128
|
+
if (inComment) {
|
|
1129
|
+
if (code === ASTERISK && css.charCodeAt(i + 1) === SLASH) {
|
|
1130
|
+
inComment = false;
|
|
1131
|
+
i++;
|
|
1132
|
+
}
|
|
1133
|
+
continue;
|
|
1280
1134
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1135
|
+
// Track string state
|
|
1136
|
+
if ((code === DOUBLE_QUOTE || code === SINGLE_QUOTE) &&
|
|
1137
|
+
(i === 0 || css.charCodeAt(i - 1) !== BACKSLASH)) {
|
|
1138
|
+
if (inString === 0) {
|
|
1139
|
+
inString = code;
|
|
1140
|
+
}
|
|
1141
|
+
else if (inString === code) {
|
|
1142
|
+
inString = 0;
|
|
1143
|
+
}
|
|
1144
|
+
continue;
|
|
1286
1145
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1146
|
+
if (inString !== 0)
|
|
1147
|
+
continue;
|
|
1148
|
+
if (code === OPEN_BRACE) {
|
|
1149
|
+
braceDepth++;
|
|
1150
|
+
}
|
|
1151
|
+
else if (code === CLOSE_BRACE) {
|
|
1152
|
+
braceDepth--;
|
|
1153
|
+
if (braceDepth < 0) {
|
|
1154
|
+
// Extra closing brace - skip to next semicolon or newline
|
|
1155
|
+
var skipEnd = i + 1;
|
|
1156
|
+
while (skipEnd < len) {
|
|
1157
|
+
var skipCode = css.charCodeAt(skipEnd);
|
|
1158
|
+
if (skipCode === SEMICOLON || skipCode === NEWLINE)
|
|
1159
|
+
break;
|
|
1160
|
+
skipEnd++;
|
|
1161
|
+
}
|
|
1162
|
+
if (skipEnd < len && css.charCodeAt(skipEnd) === SEMICOLON)
|
|
1163
|
+
skipEnd++;
|
|
1164
|
+
braceDepth = 0;
|
|
1165
|
+
i = skipEnd - 1;
|
|
1166
|
+
declStart = skipEnd;
|
|
1167
|
+
continue;
|
|
1168
|
+
}
|
|
1169
|
+
if (braceDepth === 0) {
|
|
1170
|
+
result += css.substring(declStart, i + 1);
|
|
1171
|
+
declStart = i + 1;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
else if (code === SEMICOLON && braceDepth === 0) {
|
|
1175
|
+
result += css.substring(declStart, i + 1);
|
|
1176
|
+
declStart = i + 1;
|
|
1289
1177
|
}
|
|
1290
|
-
return result;
|
|
1291
|
-
}
|
|
1292
|
-
/* Handle objects */
|
|
1293
|
-
if (isPlainObject(chunk)) {
|
|
1294
|
-
var cssArr = objToCssArray(chunk);
|
|
1295
|
-
for (var i = 0; i < cssArr.length; i++)
|
|
1296
|
-
result.push(cssArr[i]);
|
|
1297
|
-
return result;
|
|
1298
|
-
}
|
|
1299
|
-
if (!Array.isArray(chunk)) {
|
|
1300
|
-
result.push(chunk.toString());
|
|
1301
|
-
return result;
|
|
1302
|
-
}
|
|
1303
|
-
for (var i = 0; i < chunk.length; i++) {
|
|
1304
|
-
flatten(chunk[i], executionContext, styleSheet, stylisInstance, result);
|
|
1305
1178
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
var rule = rules[i];
|
|
1312
|
-
if (isFunction(rule) && !isStyledComponent(rule)) {
|
|
1313
|
-
// functions are allowed to be static if they're just being
|
|
1314
|
-
// used to get the classname of a nested styled component
|
|
1315
|
-
return false;
|
|
1179
|
+
// Add remaining valid content
|
|
1180
|
+
if (declStart < len) {
|
|
1181
|
+
var remaining = css.substring(declStart);
|
|
1182
|
+
if (!hasUnbalancedBraces(remaining)) {
|
|
1183
|
+
result += remaining;
|
|
1316
1184
|
}
|
|
1317
1185
|
}
|
|
1318
|
-
return
|
|
1186
|
+
return result;
|
|
1319
1187
|
}
|
|
1320
|
-
|
|
1321
1188
|
/**
|
|
1322
|
-
*
|
|
1189
|
+
* Takes an element and recurses through it's rules added the namespace to the start of each selector.
|
|
1190
|
+
* Takes into account media queries by recursing through child rules if they are present.
|
|
1323
1191
|
*/
|
|
1324
|
-
function
|
|
1325
|
-
return
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1192
|
+
function recursivelySetNamepace(compiled, namespace) {
|
|
1193
|
+
return compiled.map(function (rule) {
|
|
1194
|
+
if (rule.type === 'rule') {
|
|
1195
|
+
// add the namespace to the start
|
|
1196
|
+
rule.value = "".concat(namespace, " ").concat(rule.value);
|
|
1197
|
+
// add the namespace after each comma for subsequent selectors.
|
|
1198
|
+
rule.value = rule.value.replaceAll(',', ",".concat(namespace, " "));
|
|
1199
|
+
rule.props = rule.props.map(function (prop) {
|
|
1200
|
+
return "".concat(namespace, " ").concat(prop);
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
if (Array.isArray(rule.children) && rule.type !== '@keyframes') {
|
|
1204
|
+
rule.children = recursivelySetNamepace(rule.children, namespace);
|
|
1205
|
+
}
|
|
1206
|
+
return rule;
|
|
1207
|
+
});
|
|
1329
1208
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
GlobalStyle.prototype.removeStyles = function (instance, styleSheet) {
|
|
1348
|
-
styleSheet.clearRules(this.componentId + instance);
|
|
1209
|
+
function createStylisInstance(_a) {
|
|
1210
|
+
var _b = _a === void 0 ? EMPTY_OBJECT : _a, _c = _b.options, options = _c === void 0 ? EMPTY_OBJECT : _c, _d = _b.plugins, plugins = _d === void 0 ? EMPTY_ARRAY : _d;
|
|
1211
|
+
var _componentId;
|
|
1212
|
+
var _selector;
|
|
1213
|
+
var _selectorRegexp;
|
|
1214
|
+
var selfReferenceReplacer = function (match, offset, string) {
|
|
1215
|
+
if (
|
|
1216
|
+
/**
|
|
1217
|
+
* We only want to refer to the static class directly if the selector is part of a
|
|
1218
|
+
* self-reference selector `& + & { color: red; }`
|
|
1219
|
+
*/
|
|
1220
|
+
string.startsWith(_selector) &&
|
|
1221
|
+
string.endsWith(_selector) &&
|
|
1222
|
+
string.replaceAll(_selector, '').length > 0) {
|
|
1223
|
+
return ".".concat(_componentId);
|
|
1224
|
+
}
|
|
1225
|
+
return match;
|
|
1349
1226
|
};
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1227
|
+
/**
|
|
1228
|
+
* When writing a style like
|
|
1229
|
+
*
|
|
1230
|
+
* & + & {
|
|
1231
|
+
* color: red;
|
|
1232
|
+
* }
|
|
1233
|
+
*
|
|
1234
|
+
* The second ampersand should be a reference to the static component class. stylis
|
|
1235
|
+
* has no knowledge of static class so we have to intelligently replace the base selector.
|
|
1236
|
+
*
|
|
1237
|
+
* https://github.com/thysultan/stylis.js/tree/v4.0.2#abstract-syntax-structure
|
|
1238
|
+
*/
|
|
1239
|
+
var selfReferenceReplacementPlugin = function (element) {
|
|
1240
|
+
if (element.type === n && element.value.includes('&')) {
|
|
1241
|
+
// Lazy RegExp creation: only allocate when self-reference pattern is actually used
|
|
1242
|
+
if (!_selectorRegexp) {
|
|
1243
|
+
_selectorRegexp = new RegExp("\\".concat(_selector, "\\b"), 'g');
|
|
1361
1244
|
}
|
|
1362
|
-
|
|
1245
|
+
element.props[0] = element.props[0]
|
|
1246
|
+
// catch any hanging references that stylis missed
|
|
1247
|
+
.replace(AMP_REGEX, _selector)
|
|
1248
|
+
.replace(_selectorRegexp, selfReferenceReplacer);
|
|
1363
1249
|
}
|
|
1364
|
-
// NOTE: Remove old styles, then inject the new ones
|
|
1365
|
-
this.removeStyles(instance, styleSheet);
|
|
1366
|
-
this.createStyles(instance, executionContext, styleSheet, stylis);
|
|
1367
1250
|
};
|
|
1368
|
-
|
|
1369
|
-
|
|
1251
|
+
var middlewares = plugins.slice();
|
|
1252
|
+
middlewares.push(selfReferenceReplacementPlugin);
|
|
1253
|
+
/**
|
|
1254
|
+
* Enables automatic vendor-prefixing for styles.
|
|
1255
|
+
*/
|
|
1256
|
+
if (options.prefix) {
|
|
1257
|
+
middlewares.push(de);
|
|
1258
|
+
}
|
|
1259
|
+
middlewares.push(be);
|
|
1260
|
+
// Pre-build the middleware chain once to avoid allocating closures,
|
|
1261
|
+
// arrays, and middleware wrappers on every stringifyRules call.
|
|
1262
|
+
// Safe because JS is single-threaded and _stack is consumed before next call.
|
|
1263
|
+
var _stack = [];
|
|
1264
|
+
var _middleware = he(middlewares.concat(we(function (value) { return _stack.push(value); })));
|
|
1265
|
+
var stringifyRules = function (css, selector,
|
|
1266
|
+
/**
|
|
1267
|
+
* This "prefix" referes to a _selector_ prefix.
|
|
1268
|
+
*/
|
|
1269
|
+
prefix, componentId) {
|
|
1270
|
+
if (selector === void 0) { selector = ''; }
|
|
1271
|
+
if (prefix === void 0) { prefix = ''; }
|
|
1272
|
+
if (componentId === void 0) { componentId = '&'; }
|
|
1273
|
+
// stylis has no concept of state to be passed to plugins
|
|
1274
|
+
// but since JS is single-threaded, we can rely on that to ensure
|
|
1275
|
+
// these properties stay in sync with the current stylis run
|
|
1276
|
+
_componentId = componentId;
|
|
1277
|
+
_selector = selector;
|
|
1278
|
+
_selectorRegexp = undefined; // Reset for lazy creation per call
|
|
1279
|
+
var flatCSS = sanitizeCSS(stripLineComments(css));
|
|
1280
|
+
var compiled = ue(prefix || selector ? "".concat(prefix, " ").concat(selector, " { ").concat(flatCSS, " }") : flatCSS);
|
|
1281
|
+
if (options.namespace) {
|
|
1282
|
+
compiled = recursivelySetNamepace(compiled, options.namespace);
|
|
1283
|
+
}
|
|
1284
|
+
_stack = [];
|
|
1285
|
+
ve(compiled, _middleware);
|
|
1286
|
+
return _stack;
|
|
1287
|
+
};
|
|
1288
|
+
stringifyRules.hash = plugins.length
|
|
1289
|
+
? plugins
|
|
1290
|
+
.reduce(function (acc, plugin) {
|
|
1291
|
+
if (!plugin.name) {
|
|
1292
|
+
throwStyledComponentsError(15);
|
|
1293
|
+
}
|
|
1294
|
+
return phash(acc, plugin.name);
|
|
1295
|
+
}, SEED$1)
|
|
1296
|
+
.toString()
|
|
1297
|
+
: '';
|
|
1298
|
+
return stringifyRules;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
var mainSheet = new StyleSheet();
|
|
1302
|
+
var mainStylis = createStylisInstance();
|
|
1303
|
+
var defaultContextValue = {
|
|
1304
|
+
shouldForwardProp: undefined,
|
|
1305
|
+
styleSheet: mainSheet,
|
|
1306
|
+
stylis: mainStylis,
|
|
1307
|
+
};
|
|
1308
|
+
// Create context only if createContext is available, otherwise create a fallback
|
|
1309
|
+
var StyleSheetContext = React.createContext(defaultContextValue)
|
|
1310
|
+
;
|
|
1311
|
+
var StyleSheetConsumer = StyleSheetContext.Consumer;
|
|
1312
|
+
var StylisContext = React.createContext(undefined)
|
|
1313
|
+
;
|
|
1314
|
+
function useStyleSheetContext() {
|
|
1315
|
+
// Skip useContext if we're in an RSC environment without context support
|
|
1316
|
+
return React.useContext(StyleSheetContext) ;
|
|
1317
|
+
}
|
|
1318
|
+
function StyleSheetManager(props) {
|
|
1319
|
+
// In RSC environments without context support, StyleSheetManager becomes a no-op
|
|
1320
|
+
if (!React.useMemo) {
|
|
1321
|
+
return props.children;
|
|
1322
|
+
}
|
|
1323
|
+
var styleSheet = useStyleSheetContext().styleSheet;
|
|
1324
|
+
var resolvedStyleSheet = React.useMemo(function () {
|
|
1325
|
+
var sheet = styleSheet;
|
|
1326
|
+
if (props.sheet) {
|
|
1327
|
+
sheet = props.sheet;
|
|
1328
|
+
}
|
|
1329
|
+
else if (props.target) {
|
|
1330
|
+
sheet = sheet.reconstructWithOptions({ target: props.target }, false);
|
|
1331
|
+
}
|
|
1332
|
+
if (props.disableCSSOMInjection) {
|
|
1333
|
+
sheet = sheet.reconstructWithOptions({ useCSSOMInjection: false });
|
|
1334
|
+
}
|
|
1335
|
+
return sheet;
|
|
1336
|
+
}, [props.disableCSSOMInjection, props.sheet, props.target, styleSheet]);
|
|
1337
|
+
var stylis = React.useMemo(function () {
|
|
1338
|
+
return createStylisInstance({
|
|
1339
|
+
options: { namespace: props.namespace, prefix: props.enableVendorPrefixes },
|
|
1340
|
+
plugins: props.stylisPlugins,
|
|
1341
|
+
});
|
|
1342
|
+
}, [props.enableVendorPrefixes, props.namespace, props.stylisPlugins]);
|
|
1343
|
+
var styleSheetContextValue = React.useMemo(function () { return ({
|
|
1344
|
+
shouldForwardProp: props.shouldForwardProp,
|
|
1345
|
+
styleSheet: resolvedStyleSheet,
|
|
1346
|
+
stylis: stylis,
|
|
1347
|
+
}); }, [props.shouldForwardProp, resolvedStyleSheet, stylis]);
|
|
1348
|
+
return (React.createElement(StyleSheetContext.Provider, { value: styleSheetContextValue },
|
|
1349
|
+
React.createElement(StylisContext.Provider, { value: stylis }, props.children)));
|
|
1350
|
+
}
|
|
1370
1351
|
|
|
1371
1352
|
// Create context only if createContext is available, otherwise create a fallback
|
|
1372
1353
|
var ThemeContext = React.createContext(undefined)
|
|
@@ -1598,6 +1579,33 @@
|
|
|
1598
1579
|
return React.memo(GlobalStyleComponent);
|
|
1599
1580
|
}
|
|
1600
1581
|
|
|
1582
|
+
var _a$1;
|
|
1583
|
+
var Keyframes = /** @class */ (function () {
|
|
1584
|
+
function Keyframes(name, rules) {
|
|
1585
|
+
var _this = this;
|
|
1586
|
+
this[_a$1] = true;
|
|
1587
|
+
this.inject = function (styleSheet, stylisInstance) {
|
|
1588
|
+
if (stylisInstance === void 0) { stylisInstance = mainStylis; }
|
|
1589
|
+
var resolvedName = _this.name + stylisInstance.hash;
|
|
1590
|
+
if (!styleSheet.hasNameForId(_this.id, resolvedName)) {
|
|
1591
|
+
styleSheet.insertRules(_this.id, resolvedName, stylisInstance(_this.rules, resolvedName, '@keyframes'));
|
|
1592
|
+
}
|
|
1593
|
+
};
|
|
1594
|
+
this.name = name;
|
|
1595
|
+
this.id = "sc-keyframes-".concat(name);
|
|
1596
|
+
this.rules = rules;
|
|
1597
|
+
setToString(this, function () {
|
|
1598
|
+
throw throwStyledComponentsError(12, String(_this.name));
|
|
1599
|
+
});
|
|
1600
|
+
}
|
|
1601
|
+
Keyframes.prototype.getName = function (stylisInstance) {
|
|
1602
|
+
if (stylisInstance === void 0) { stylisInstance = mainStylis; }
|
|
1603
|
+
return this.name + stylisInstance.hash;
|
|
1604
|
+
};
|
|
1605
|
+
return Keyframes;
|
|
1606
|
+
}());
|
|
1607
|
+
_a$1 = KEYFRAMES_SYMBOL;
|
|
1608
|
+
|
|
1601
1609
|
function keyframes(strings) {
|
|
1602
1610
|
var interpolations = [];
|
|
1603
1611
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -2210,7 +2218,9 @@
|
|
|
2210
2218
|
else if (key === 'style') {
|
|
2211
2219
|
context.style = __assign(__assign({}, context.style), resolvedAttrDef[key]);
|
|
2212
2220
|
}
|
|
2213
|
-
else {
|
|
2221
|
+
else if (!(key in props && props[key] === undefined)) {
|
|
2222
|
+
// Apply attr value unless the user explicitly passed undefined for this prop,
|
|
2223
|
+
// which signals intent to reset the value.
|
|
2214
2224
|
// @ts-expect-error attrs can dynamically add arbitrary properties
|
|
2215
2225
|
context[key] = resolvedAttrDef[key];
|
|
2216
2226
|
}
|
|
@@ -2422,7 +2432,10 @@
|
|
|
2422
2432
|
styled[key] = secondary[key];
|
|
2423
2433
|
}
|
|
2424
2434
|
|
|
2425
|
-
|
|
2435
|
+
exports.default = styled;
|
|
2436
|
+
exports.styled = styled;
|
|
2437
|
+
|
|
2438
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2426
2439
|
|
|
2427
2440
|
}));
|
|
2428
2441
|
//# sourceMappingURL=styled-components.js.map
|