Comparing version 10.8.2 to 10.9.0
@@ -490,2 +490,12 @@ function _extends() { | ||
/** | ||
* Replace rule, run plugins. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(name, style, options) { | ||
var newRule = this.rules.replace(name, style, options); | ||
if (newRule) this.options.jss.plugins.onProcessRule(newRule); | ||
return newRule; | ||
} | ||
/** | ||
* Generates a CSS string. | ||
@@ -901,10 +911,31 @@ */ | ||
/** | ||
* Get a rule. | ||
* Replace rule. | ||
* Create a new rule and remove old one instead of overwriting | ||
* because we want to invoke onCreateRule hook to make plugins work. | ||
*/ | ||
; | ||
_proto.get = function get(name) { | ||
return this.map[name]; | ||
_proto.replace = function replace(name, decl, ruleOptions) { | ||
var oldRule = this.get(name); | ||
var oldIndex = this.index.indexOf(oldRule); | ||
if (oldRule) { | ||
this.remove(oldRule); | ||
} | ||
var options = ruleOptions; | ||
if (oldIndex !== -1) options = _extends({}, ruleOptions, { | ||
index: oldIndex | ||
}); | ||
return this.add(name, decl, options); | ||
} | ||
/** | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.get = function get(nameOrSelector) { | ||
return this.map[nameOrSelector]; | ||
} | ||
/** | ||
* Delete a rule. | ||
@@ -989,3 +1020,3 @@ */ | ||
if (name) { | ||
this.updateOne(this.map[name], data, options); | ||
this.updateOne(this.get(name), data, options); | ||
} else { | ||
@@ -1163,2 +1194,36 @@ for (var index = 0; index < this.index.length; index++) { | ||
/** | ||
* Replace a rule in the current stylesheet. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(nameOrSelector, decl, options) { | ||
var oldRule = this.rules.get(nameOrSelector); | ||
if (!oldRule) return this.addRule(nameOrSelector, decl, options); | ||
var newRule = this.rules.replace(nameOrSelector, decl, options); | ||
if (newRule) { | ||
this.options.jss.plugins.onProcessRule(newRule); | ||
} | ||
if (this.attached) { | ||
if (!this.deployed) return newRule; // Don't replace / delete rule directly if there is no stringified version yet. | ||
// It will be inserted all together when .attach is called. | ||
if (this.renderer) { | ||
if (!newRule) { | ||
this.renderer.deleteRule(oldRule); | ||
} else if (oldRule.renderable) { | ||
this.renderer.replaceRule(oldRule.renderable, newRule); | ||
} | ||
} | ||
return newRule; | ||
} // We can't replace rules to a detached style node. | ||
// We will redeploy the sheet once user will attach it. | ||
this.deployed = false; | ||
return newRule; | ||
} | ||
/** | ||
* Insert rule into the StyleSheet | ||
@@ -1190,8 +1255,8 @@ */ | ||
/** | ||
* Get a rule by name. | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.getRule = function getRule(name) { | ||
return this.rules.get(name); | ||
_proto.getRule = function getRule(nameOrSelector) { | ||
return this.rules.get(nameOrSelector); | ||
} | ||
@@ -1992,3 +2057,3 @@ /** | ||
if (rule.options.parent instanceof StyleSheet) { | ||
this.cssRules[index] = cssRule; | ||
this.cssRules.splice(index, 0, cssRule); | ||
} | ||
@@ -2019,4 +2084,2 @@ } | ||
* Generate a new CSS rule and replace the existing one. | ||
* | ||
* Only used for some old browsers because they can't set a selector. | ||
*/ | ||
@@ -2051,3 +2114,3 @@ ; | ||
this.id = instanceCounter++; | ||
this.version = "10.8.2"; | ||
this.version = "10.9.0"; | ||
this.plugins = new PluginsRegistry(); | ||
@@ -2054,0 +2117,0 @@ this.options = { |
@@ -442,2 +442,12 @@ 'use strict'; | ||
/** | ||
* Replace rule, run plugins. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(name, style, options) { | ||
var newRule = this.rules.replace(name, style, options); | ||
if (newRule) this.options.jss.plugins.onProcessRule(newRule); | ||
return newRule; | ||
} | ||
/** | ||
* Generates a CSS string. | ||
@@ -853,10 +863,31 @@ */ | ||
/** | ||
* Get a rule. | ||
* Replace rule. | ||
* Create a new rule and remove old one instead of overwriting | ||
* because we want to invoke onCreateRule hook to make plugins work. | ||
*/ | ||
; | ||
_proto.get = function get(name) { | ||
return this.map[name]; | ||
_proto.replace = function replace(name, decl, ruleOptions) { | ||
var oldRule = this.get(name); | ||
var oldIndex = this.index.indexOf(oldRule); | ||
if (oldRule) { | ||
this.remove(oldRule); | ||
} | ||
var options = ruleOptions; | ||
if (oldIndex !== -1) options = _extends__default['default']({}, ruleOptions, { | ||
index: oldIndex | ||
}); | ||
return this.add(name, decl, options); | ||
} | ||
/** | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.get = function get(nameOrSelector) { | ||
return this.map[nameOrSelector]; | ||
} | ||
/** | ||
* Delete a rule. | ||
@@ -941,3 +972,3 @@ */ | ||
if (name) { | ||
this.updateOne(this.map[name], data, options); | ||
this.updateOne(this.get(name), data, options); | ||
} else { | ||
@@ -1115,2 +1146,36 @@ for (var index = 0; index < this.index.length; index++) { | ||
/** | ||
* Replace a rule in the current stylesheet. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(nameOrSelector, decl, options) { | ||
var oldRule = this.rules.get(nameOrSelector); | ||
if (!oldRule) return this.addRule(nameOrSelector, decl, options); | ||
var newRule = this.rules.replace(nameOrSelector, decl, options); | ||
if (newRule) { | ||
this.options.jss.plugins.onProcessRule(newRule); | ||
} | ||
if (this.attached) { | ||
if (!this.deployed) return newRule; // Don't replace / delete rule directly if there is no stringified version yet. | ||
// It will be inserted all together when .attach is called. | ||
if (this.renderer) { | ||
if (!newRule) { | ||
this.renderer.deleteRule(oldRule); | ||
} else if (oldRule.renderable) { | ||
this.renderer.replaceRule(oldRule.renderable, newRule); | ||
} | ||
} | ||
return newRule; | ||
} // We can't replace rules to a detached style node. | ||
// We will redeploy the sheet once user will attach it. | ||
this.deployed = false; | ||
return newRule; | ||
} | ||
/** | ||
* Insert rule into the StyleSheet | ||
@@ -1142,8 +1207,8 @@ */ | ||
/** | ||
* Get a rule by name. | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.getRule = function getRule(name) { | ||
return this.rules.get(name); | ||
_proto.getRule = function getRule(nameOrSelector) { | ||
return this.rules.get(nameOrSelector); | ||
} | ||
@@ -1929,3 +1994,3 @@ /** | ||
if (rule.options.parent instanceof StyleSheet) { | ||
this.cssRules[index] = cssRule; | ||
this.cssRules.splice(index, 0, cssRule); | ||
} | ||
@@ -1956,4 +2021,2 @@ } | ||
* Generate a new CSS rule and replace the existing one. | ||
* | ||
* Only used for some old browsers because they can't set a selector. | ||
*/ | ||
@@ -1988,3 +2051,3 @@ ; | ||
this.id = instanceCounter++; | ||
this.version = "10.8.2"; | ||
this.version = "10.9.0"; | ||
this.plugins = new PluginsRegistry(); | ||
@@ -1991,0 +2054,0 @@ this.options = { |
@@ -428,2 +428,12 @@ import _extends from '@babel/runtime/helpers/esm/extends'; | ||
/** | ||
* Replace rule, run plugins. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(name, style, options) { | ||
var newRule = this.rules.replace(name, style, options); | ||
if (newRule) this.options.jss.plugins.onProcessRule(newRule); | ||
return newRule; | ||
} | ||
/** | ||
* Generates a CSS string. | ||
@@ -839,10 +849,31 @@ */ | ||
/** | ||
* Get a rule. | ||
* Replace rule. | ||
* Create a new rule and remove old one instead of overwriting | ||
* because we want to invoke onCreateRule hook to make plugins work. | ||
*/ | ||
; | ||
_proto.get = function get(name) { | ||
return this.map[name]; | ||
_proto.replace = function replace(name, decl, ruleOptions) { | ||
var oldRule = this.get(name); | ||
var oldIndex = this.index.indexOf(oldRule); | ||
if (oldRule) { | ||
this.remove(oldRule); | ||
} | ||
var options = ruleOptions; | ||
if (oldIndex !== -1) options = _extends({}, ruleOptions, { | ||
index: oldIndex | ||
}); | ||
return this.add(name, decl, options); | ||
} | ||
/** | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.get = function get(nameOrSelector) { | ||
return this.map[nameOrSelector]; | ||
} | ||
/** | ||
* Delete a rule. | ||
@@ -927,3 +958,3 @@ */ | ||
if (name) { | ||
this.updateOne(this.map[name], data, options); | ||
this.updateOne(this.get(name), data, options); | ||
} else { | ||
@@ -1101,2 +1132,36 @@ for (var index = 0; index < this.index.length; index++) { | ||
/** | ||
* Replace a rule in the current stylesheet. | ||
*/ | ||
; | ||
_proto.replaceRule = function replaceRule(nameOrSelector, decl, options) { | ||
var oldRule = this.rules.get(nameOrSelector); | ||
if (!oldRule) return this.addRule(nameOrSelector, decl, options); | ||
var newRule = this.rules.replace(nameOrSelector, decl, options); | ||
if (newRule) { | ||
this.options.jss.plugins.onProcessRule(newRule); | ||
} | ||
if (this.attached) { | ||
if (!this.deployed) return newRule; // Don't replace / delete rule directly if there is no stringified version yet. | ||
// It will be inserted all together when .attach is called. | ||
if (this.renderer) { | ||
if (!newRule) { | ||
this.renderer.deleteRule(oldRule); | ||
} else if (oldRule.renderable) { | ||
this.renderer.replaceRule(oldRule.renderable, newRule); | ||
} | ||
} | ||
return newRule; | ||
} // We can't replace rules to a detached style node. | ||
// We will redeploy the sheet once user will attach it. | ||
this.deployed = false; | ||
return newRule; | ||
} | ||
/** | ||
* Insert rule into the StyleSheet | ||
@@ -1128,8 +1193,8 @@ */ | ||
/** | ||
* Get a rule by name. | ||
* Get a rule by name or selector. | ||
*/ | ||
; | ||
_proto.getRule = function getRule(name) { | ||
return this.rules.get(name); | ||
_proto.getRule = function getRule(nameOrSelector) { | ||
return this.rules.get(nameOrSelector); | ||
} | ||
@@ -1915,3 +1980,3 @@ /** | ||
if (rule.options.parent instanceof StyleSheet) { | ||
this.cssRules[index] = cssRule; | ||
this.cssRules.splice(index, 0, cssRule); | ||
} | ||
@@ -1942,4 +2007,2 @@ } | ||
* Generate a new CSS rule and replace the existing one. | ||
* | ||
* Only used for some old browsers because they can't set a selector. | ||
*/ | ||
@@ -1974,3 +2037,3 @@ ; | ||
this.id = instanceCounter++; | ||
this.version = "10.8.2"; | ||
this.version = "10.9.0"; | ||
this.plugins = new PluginsRegistry(); | ||
@@ -1977,0 +2040,0 @@ this.options = { |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jss={})}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r="object"===("undefined"==typeof window?"undefined":n(window))&&"object"===("undefined"==typeof document?"undefined":n(document))&&9===document.nodeType,i={}.constructor;function s(e){if(null==e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(s);if(e.constructor!==i)return e;var t={};for(var n in e)t[n]=s(e[n]);return t}function o(e,t,n){void 0===e&&(e="unnamed");var r=n.jss,i=s(t),o=r.plugins.onCreateRule(e,i,n);return o||(e[0],null)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),e}function h(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var c=function(e,t){for(var n="",r=0;r<e.length&&"!important"!==e[r];r++)n&&(n+=t),n+=e[r];return n},f=function(e,t){if(void 0===t&&(t=!1),!Array.isArray(e))return e;var n="";if(Array.isArray(e[0]))for(var r=0;r<e.length&&"!important"!==e[r];r++)n&&(n+=", "),n+=c(e[r]," ");else n=c(e,", ");return t||"!important"!==e[e.length-1]||(n+=" !important"),n};function d(e){return e&&!1===e.format?{linebreak:"",space:""}:{linebreak:"\n",space:" "}}function p(e,t){for(var n="",r=0;r<t;r++)n+=" ";return n+e}function y(e,t,n){void 0===n&&(n={});var r="";if(!t)return r;var i=n.indent,s=void 0===i?0:i,o=t.fallbacks;!1===n.format&&(s=-1/0);var a=d(n),u=a.linebreak,h=a.space;if(e&&s++,o)if(Array.isArray(o))for(var l=0;l<o.length;l++){var c=o[l];for(var y in c){var v=c[y];null!=v&&(r&&(r+=u),r+=p(y+":"+h+f(v)+";",s))}}else for(var g in o){var m=o[g];null!=m&&(r&&(r+=u),r+=p(g+":"+h+f(m)+";",s))}for(var R in t){var S=t[R];null!=S&&"fallbacks"!==R&&(r&&(r+=u),r+=p(R+":"+h+f(S)+";",s))}return(r||n.allowEmpty)&&e?(r&&(r=""+u+r+u),p(""+e+h+"{"+r,--s)+p("}",s)):r}var v=/([[\].#*$><+~=|^:(),"'`\s])/g,g="undefined"!=typeof CSS&&CSS.escape,m=function(e){return g?g(e):e.replace(v,"\\$1")},R=function(){function e(e,t,n){this.type="style",this.isProcessed=!1;var r=n.sheet,i=n.Renderer;this.key=e,this.options=n,this.style=t,r?this.renderer=r.renderer:i&&(this.renderer=new i)}return e.prototype.prop=function(e,t,n){if(void 0===t)return this.style[e];var r=!!n&&n.force;if(!r&&this.style[e]===t)return this;var i=t;n&&!1===n.process||(i=this.options.jss.plugins.onChangeValue(t,e,this));var s=null==i||!1===i,o=e in this.style;if(s&&!o&&!r)return this;var a=s&&o;if(a?delete this.style[e]:this.style[e]=i,this.renderable&&this.renderer)return a?this.renderer.removeProperty(this.renderable,e):this.renderer.setProperty(this.renderable,e,i),this;var u=this.options.sheet;return u&&u.attached,this},e}(),S=function(e){function n(t,n,r){var i;i=e.call(this,t,n,r)||this;var s=r.selector,o=r.scoped,a=r.sheet,u=r.generateId;return s?i.selectorText=s:!1!==o&&(i.id=u(l(l(i)),a),i.selectorText="."+m(i.id)),i}h(n,e);var r=n.prototype;return r.applyTo=function(e){var t=this.renderer;if(t){var n=this.toJSON();for(var r in n)t.setProperty(e,r,n[r])}return this},r.toJSON=function(){var e={};for(var t in this.style){var n=this.style[t];"object"!=typeof n?e[t]=n:Array.isArray(n)&&(e[t]=f(n))}return e},r.toString=function(e){var n=this.options.sheet,r=!!n&&n.options.link?t({},e,{allowEmpty:!0}):e;return y(this.selectorText,this.style,r)},u(n,[{key:"selector",set:function(e){if(e!==this.selectorText){this.selectorText=e;var t=this.renderer,n=this.renderable;if(n&&t)t.setSelector(n,e)||t.replaceRule(n,this)}},get:function(){return this.selectorText}}]),n}(R),b={onCreateRule:function(e,t,n){return"@"===e[0]||n.parent&&"keyframes"===n.parent.type?null:new S(e,t,n)}},x={indent:1,children:!0},k=/@([\w-]+)/,P=function(){function e(e,n,r){this.type="conditional",this.isProcessed=!1,this.key=e;var i=e.match(k);for(var s in this.at=i?i[1]:"unknown",this.query=r.name||"@"+this.at,this.options=r,this.rules=new W(t({},r,{parent:this})),n)this.rules.add(s,n[s]);this.rules.process()}var n=e.prototype;return n.getRule=function(e){return this.rules.get(e)},n.indexOf=function(e){return this.rules.indexOf(e)},n.addRule=function(e,t,n){var r=this.rules.add(e,t,n);return r?(this.options.jss.plugins.onProcessRule(r),r):null},n.toString=function(e){void 0===e&&(e=x);var t=d(e).linebreak;if(null==e.indent&&(e.indent=x.indent),null==e.children&&(e.children=x.children),!1===e.children)return this.query+" {}";var n=this.rules.toString(e);return n?this.query+" {"+t+n+t+"}":""},e}(),w=/@media|@supports\s+/,C={onCreateRule:function(e,t,n){return w.test(e)?new P(e,t,n):null}},O={indent:1,children:!0},j=/@keyframes\s+([\w-]+)/,A=function(){function e(e,n,r){this.type="keyframes",this.at="@keyframes",this.isProcessed=!1;var i=e.match(j);i&&i[1]?this.name=i[1]:this.name="noname",this.key=this.type+"-"+this.name,this.options=r;var s=r.scoped,o=r.sheet,a=r.generateId;for(var u in this.id=!1===s?this.name:m(a(this,o)),this.rules=new W(t({},r,{parent:this})),n)this.rules.add(u,n[u],t({},r,{parent:this}));this.rules.process()}return e.prototype.toString=function(e){void 0===e&&(e=O);var t=d(e).linebreak;if(null==e.indent&&(e.indent=O.indent),null==e.children&&(e.children=O.children),!1===e.children)return this.at+" "+this.id+" {}";var n=this.rules.toString(e);return n&&(n=""+t+n+t),this.at+" "+this.id+" {"+n+"}"},e}(),I=/@keyframes\s+/,T=/\$([\w-]+)/g,M=function(e,t){return"string"==typeof e?e.replace(T,(function(e,n){return n in t?t[n]:e})):e},q=function(e,t,n){var r=e[t],i=M(r,n);i!==r&&(e[t]=i)},N={onCreateRule:function(e,t,n){return"string"==typeof e&&I.test(e)?new A(e,t,n):null},onProcessStyle:function(e,t,n){return"style"===t.type&&n?("animation-name"in e&&q(e,"animation-name",n.keyframes),"animation"in e&&q(e,"animation",n.keyframes),e):e},onChangeValue:function(e,t,n){var r=n.options.sheet;if(!r)return e;switch(t){case"animation":case"animation-name":return M(e,r.keyframes);default:return e}}},V=function(e){function n(){return e.apply(this,arguments)||this}return h(n,e),n.prototype.toString=function(e){var n=this.options.sheet,r=!!n&&n.options.link?t({},e,{allowEmpty:!0}):e;return y(this.key,this.style,r)},n}(R),E={onCreateRule:function(e,t,n){return n.parent&&"keyframes"===n.parent.type?new V(e,t,n):null}},G=function(){function e(e,t,n){this.type="font-face",this.at="@font-face",this.isProcessed=!1,this.key=e,this.style=t,this.options=n}return e.prototype.toString=function(e){var t=d(e).linebreak;if(Array.isArray(this.style)){for(var n="",r=0;r<this.style.length;r++)n+=y(this.at,this.style[r]),this.style[r+1]&&(n+=t);return n}return y(this.at,this.style,e)},e}(),_=/@font-face/,U={onCreateRule:function(e,t,n){return _.test(e)?new G(e,t,n):null}},B=function(){function e(e,t,n){this.type="viewport",this.at="@viewport",this.isProcessed=!1,this.key=e,this.style=t,this.options=n}return e.prototype.toString=function(e){return y(this.key,this.style,e)},e}(),$={onCreateRule:function(e,t,n){return"@viewport"===e||"@-ms-viewport"===e?new B(e,t,n):null}},J=function(){function e(e,t,n){this.type="simple",this.isProcessed=!1,this.key=e,this.value=t,this.options=n}return e.prototype.toString=function(e){if(Array.isArray(this.value)){for(var t="",n=0;n<this.value.length;n++)t+=this.key+" "+this.value[n]+";",this.value[n+1]&&(t+="\n");return t}return this.key+" "+this.value+";"},e}(),z={"@charset":!0,"@import":!0,"@namespace":!0},D=[b,C,N,E,U,$,{onCreateRule:function(e,t,n){return e in z?new J(e,t,n):null}}],F={process:!0},L={force:!0,process:!0},W=function(){function e(e){this.map={},this.raw={},this.index=[],this.counter=0,this.options=e,this.classes=e.classes,this.keyframes=e.keyframes}var n=e.prototype;return n.add=function(e,n,r){var i=this.options,s=i.parent,a=i.sheet,u=i.jss,h=i.Renderer,l=i.generateId,c=i.scoped,f=t({classes:this.classes,parent:s,sheet:a,jss:u,Renderer:h,generateId:l,scoped:c,name:e,keyframes:this.keyframes,selector:void 0},r),d=e;e in this.raw&&(d=e+"-d"+this.counter++),this.raw[d]=n,d in this.classes&&(f.selector="."+m(this.classes[d]));var p=o(d,n,f);if(!p)return null;this.register(p);var y=void 0===f.index?this.index.length:f.index;return this.index.splice(y,0,p),p},n.get=function(e){return this.map[e]},n.remove=function(e){this.unregister(e),delete this.raw[e.key],this.index.splice(this.index.indexOf(e),1)},n.indexOf=function(e){return this.index.indexOf(e)},n.process=function(){var e=this.options.jss.plugins;this.index.slice(0).forEach(e.onProcessRule,e)},n.register=function(e){this.map[e.key]=e,e instanceof S?(this.map[e.selector]=e,e.id&&(this.classes[e.key]=e.id)):e instanceof A&&this.keyframes&&(this.keyframes[e.name]=e.id)},n.unregister=function(e){delete this.map[e.key],e instanceof S?(delete this.map[e.selector],delete this.classes[e.key]):e instanceof A&&delete this.keyframes[e.name]},n.update=function(){var e,t,n;if("string"==typeof(arguments.length<=0?void 0:arguments[0])?(e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1],n=arguments.length<=2?void 0:arguments[2]):(t=arguments.length<=0?void 0:arguments[0],n=arguments.length<=1?void 0:arguments[1],e=null),e)this.updateOne(this.map[e],t,n);else for(var r=0;r<this.index.length;r++)this.updateOne(this.index[r],t,n)},n.updateOne=function(t,n,r){void 0===r&&(r=F);var i=this.options,s=i.jss.plugins,o=i.sheet;if(t.rules instanceof e)t.rules.update(n,r);else{var a=t.style;if(s.onUpdate(n,t,o,r),r.process&&a&&a!==t.style){for(var u in s.onProcessStyle(t.style,t,o),t.style){var h=t.style[u];h!==a[u]&&t.prop(u,h,L)}for(var l in a){var c=t.style[l],f=a[l];null==c&&c!==f&&t.prop(l,null,L)}}}},n.toString=function(e){for(var t="",n=this.options.sheet,r=!!n&&n.options.link,i=d(e).linebreak,s=0;s<this.index.length;s++){var o=this.index[s].toString(e);(o||r)&&(t&&(t+=i),t+=o)}return t},e}(),H=function(){function e(e,n){for(var r in this.attached=!1,this.deployed=!1,this.classes={},this.keyframes={},this.options=t({},n,{sheet:this,parent:this,classes:this.classes,keyframes:this.keyframes}),n.Renderer&&(this.renderer=new n.Renderer(this)),this.rules=new W(this.options),e)this.rules.add(r,e[r]);this.rules.process()}var n=e.prototype;return n.attach=function(){return this.attached||(this.renderer&&this.renderer.attach(),this.attached=!0,this.deployed||this.deploy()),this},n.detach=function(){return this.attached?(this.renderer&&this.renderer.detach(),this.attached=!1,this):this},n.addRule=function(e,t,n){var r=this.queue;this.attached&&!r&&(this.queue=[]);var i=this.rules.add(e,t,n);return i?(this.options.jss.plugins.onProcessRule(i),this.attached?this.deployed?(r?r.push(i):(this.insertRule(i),this.queue&&(this.queue.forEach(this.insertRule,this),this.queue=void 0)),i):i:(this.deployed=!1,i)):null},n.insertRule=function(e){this.renderer&&this.renderer.insertRule(e)},n.addRules=function(e,t){var n=[];for(var r in e){var i=this.addRule(r,e[r],t);i&&n.push(i)}return n},n.getRule=function(e){return this.rules.get(e)},n.deleteRule=function(e){var t="object"==typeof e?e:this.rules.get(e);return!(!t||this.attached&&!t.renderable)&&(this.rules.remove(t),!(this.attached&&t.renderable&&this.renderer)||this.renderer.deleteRule(t.renderable))},n.indexOf=function(e){return this.rules.indexOf(e)},n.deploy=function(){return this.renderer&&this.renderer.deploy(),this.deployed=!0,this},n.update=function(){var e;return(e=this.rules).update.apply(e,arguments),this},n.updateOne=function(e,t,n){return this.rules.updateOne(e,t,n),this},n.toString=function(e){return this.rules.toString(e)},e}(),K=function(){function e(){this.plugins={internal:[],external:[]},this.registry={}}var t=e.prototype;return t.onCreateRule=function(e,t,n){for(var r=0;r<this.registry.onCreateRule.length;r++){var i=this.registry.onCreateRule[r](e,t,n);if(i)return i}return null},t.onProcessRule=function(e){if(!e.isProcessed){for(var t=e.options.sheet,n=0;n<this.registry.onProcessRule.length;n++)this.registry.onProcessRule[n](e,t);e.style&&this.onProcessStyle(e.style,e,t),e.isProcessed=!0}},t.onProcessStyle=function(e,t,n){for(var r=0;r<this.registry.onProcessStyle.length;r++)t.style=this.registry.onProcessStyle[r](t.style,t,n)},t.onProcessSheet=function(e){for(var t=0;t<this.registry.onProcessSheet.length;t++)this.registry.onProcessSheet[t](e)},t.onUpdate=function(e,t,n,r){for(var i=0;i<this.registry.onUpdate.length;i++)this.registry.onUpdate[i](e,t,n,r)},t.onChangeValue=function(e,t,n){for(var r=e,i=0;i<this.registry.onChangeValue.length;i++)r=this.registry.onChangeValue[i](r,t,n);return r},t.use=function(e,t){void 0===t&&(t={queue:"external"});var n=this.plugins[t.queue];-1===n.indexOf(e)&&(n.push(e),this.registry=[].concat(this.plugins.external,this.plugins.internal).reduce((function(e,t){for(var n in t)n in e&&e[n].push(t[n]);return e}),{onCreateRule:[],onProcessRule:[],onProcessStyle:[],onProcessSheet:[],onChangeValue:[],onUpdate:[]}))},e}();var Q=function(){function e(){this.registry=[]}var t=e.prototype;return t.add=function(e){var t=this.registry,n=e.options.index;if(-1===t.indexOf(e))if(0===t.length||n>=this.index)t.push(e);else for(var r=0;r<t.length;r++)if(t[r].options.index>n)return void t.splice(r,0,e)},t.reset=function(){this.registry=[]},t.remove=function(e){var t=this.registry.indexOf(e);this.registry.splice(t,1)},t.toString=function(e){for(var t=void 0===e?{}:e,n=t.attached,r=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(t,["attached"]),i=d(r).linebreak,s="",o=0;o<this.registry.length;o++){var a=this.registry[o];null!=n&&a.attached!==n||(s&&(s+=i),s+=a.toString(r))}return s},u(e,[{key:"index",get:function(){return 0===this.registry.length?0:this.registry[this.registry.length-1].options.index}}]),e}(),X=new Q,Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),Z="2f1acc6c3a606b082e5eef5e54414ffb";null==Y[Z]&&(Y[Z]=0);var ee=Y[Z]++,te=function(e){void 0===e&&(e={});var t=0;return function(n,r){t+=1;var i="",s="";return r&&(r.options.classNamePrefix&&(s=r.options.classNamePrefix),null!=r.options.jss.id&&(i=String(r.options.jss.id))),e.minify?""+(s||"c")+ee+i+t:s+n.key+"-"+ee+(i?"-"+i:"")+"-"+t}},ne=function(e){var t;return function(){return t||(t=e()),t}},re=function(e,t){try{return e.attributeStyleMap?e.attributeStyleMap.get(t):e.style.getPropertyValue(t)}catch(e){return""}},ie=function(e,t,n){try{var r=n;if(Array.isArray(n)&&(r=f(n,!0),"!important"===n[n.length-1]))return e.style.setProperty(t,r,"important"),!0;e.attributeStyleMap?e.attributeStyleMap.set(t,r):e.style.setProperty(t,r)}catch(e){return!1}return!0},se=function(e,t){try{e.attributeStyleMap?e.attributeStyleMap.delete(t):e.style.removeProperty(t)}catch(e){}},oe=function(e,t){return e.selectorText=t,e.selectorText===t},ae=ne((function(){return document.querySelector("head")}));function ue(e){var t=X.registry;if(t.length>0){var n=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.attached&&r.options.index>t.index&&r.options.insertionPoint===t.insertionPoint)return r}return null}(t,e);if(n&&n.renderer)return{parent:n.renderer.element.parentNode,node:n.renderer.element};if((n=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.attached&&r.options.insertionPoint===t.insertionPoint)return r}return null}(t,e))&&n.renderer)return{parent:n.renderer.element.parentNode,node:n.renderer.element.nextSibling}}var r=e.insertionPoint;if(r&&"string"==typeof r){var i=function(e){for(var t=ae(),n=0;n<t.childNodes.length;n++){var r=t.childNodes[n];if(8===r.nodeType&&r.nodeValue.trim()===e)return r}return null}(r);if(i)return{parent:i.parentNode,node:i.nextSibling}}return!1}var he=ne((function(){var e=document.querySelector('meta[property="csp-nonce"]');return e?e.getAttribute("content"):null})),le=function(e,t,n){try{"insertRule"in e?e.insertRule(t,n):"appendRule"in e&&e.appendRule(t)}catch(e){return!1}return e.cssRules[n]},ce=function(e,t){var n=e.cssRules.length;return void 0===t||t>n?n:t},fe=function(){function e(e){this.getPropertyValue=re,this.setProperty=ie,this.removeProperty=se,this.setSelector=oe,this.hasInsertedRules=!1,this.cssRules=[],e&&X.add(e),this.sheet=e;var t,n=this.sheet?this.sheet.options:{},r=n.media,i=n.meta,s=n.element;this.element=s||((t=document.createElement("style")).textContent="\n",t),this.element.setAttribute("data-jss",""),r&&this.element.setAttribute("media",r),i&&this.element.setAttribute("data-meta",i);var o=he();o&&this.element.setAttribute("nonce",o)}var t=e.prototype;return t.attach=function(){if(!this.element.parentNode&&this.sheet){!function(e,t){var n=t.insertionPoint,r=ue(t);if(!1!==r&&r.parent)r.parent.insertBefore(e,r.node);else if(n&&"number"==typeof n.nodeType){var i=n,s=i.parentNode;s&&s.insertBefore(e,i.nextSibling)}else ae().appendChild(e)}(this.element,this.sheet.options);var e=Boolean(this.sheet&&this.sheet.deployed);this.hasInsertedRules&&e&&(this.hasInsertedRules=!1,this.deploy())}},t.detach=function(){if(this.sheet){var e=this.element.parentNode;e&&e.removeChild(this.element),this.sheet.options.link&&(this.cssRules=[],this.element.textContent="\n")}},t.deploy=function(){var e=this.sheet;e&&(e.options.link?this.insertRules(e.rules):this.element.textContent="\n"+e.toString()+"\n")},t.insertRules=function(e,t){for(var n=0;n<e.index.length;n++)this.insertRule(e.index[n],n,t)},t.insertRule=function(e,t,n){if(void 0===n&&(n=this.element.sheet),e.rules){var r=e,i=n;if("conditional"===e.type||"keyframes"===e.type){var s=ce(n,t);if(!1===(i=le(n,r.toString({children:!1}),s)))return!1;this.refCssRule(e,s,i)}return this.insertRules(r.rules,i),i}var o=e.toString();if(!o)return!1;var a=ce(n,t),u=le(n,o,a);return!1!==u&&(this.hasInsertedRules=!0,this.refCssRule(e,a,u),u)},t.refCssRule=function(e,t,n){e.renderable=n,e.options.parent instanceof H&&(this.cssRules[t]=n)},t.deleteRule=function(e){var t=this.element.sheet,n=this.indexOf(e);return-1!==n&&(t.deleteRule(n),this.cssRules.splice(n,1),!0)},t.indexOf=function(e){return this.cssRules.indexOf(e)},t.replaceRule=function(e,t){var n=this.indexOf(e);return-1!==n&&(this.element.sheet.deleteRule(n),this.cssRules.splice(n,1),this.insertRule(t,n))},t.getRules=function(){return this.element.sheet.cssRules},e}(),de=0,pe=function(){function e(e){this.id=de++,this.version="10.8.2",this.plugins=new K,this.options={id:{minify:!1},createGenerateId:te,Renderer:r?fe:null,plugins:[]},this.generateId=te({minify:!1});for(var t=0;t<D.length;t++)this.plugins.use(D[t],{queue:"internal"});this.setup(e)}var n=e.prototype;return n.setup=function(e){return void 0===e&&(e={}),e.createGenerateId&&(this.options.createGenerateId=e.createGenerateId),e.id&&(this.options.id=t({},this.options.id,e.id)),(e.createGenerateId||e.id)&&(this.generateId=this.options.createGenerateId(this.options.id)),null!=e.insertionPoint&&(this.options.insertionPoint=e.insertionPoint),"Renderer"in e&&(this.options.Renderer=e.Renderer),e.plugins&&this.use.apply(this,e.plugins),this},n.createStyleSheet=function(e,n){void 0===n&&(n={});var r=n.index;"number"!=typeof r&&(r=0===X.index?0:X.index+1);var i=new H(e,t({},n,{jss:this,generateId:n.generateId||this.generateId,insertionPoint:this.options.insertionPoint,Renderer:this.options.Renderer,index:r}));return this.plugins.onProcessSheet(i),i},n.removeStyleSheet=function(e){return e.detach(),X.remove(e),this},n.createRule=function(e,n,r){if(void 0===n&&(n={}),void 0===r&&(r={}),"object"==typeof e)return this.createRule(void 0,e,n);var i=t({},r,{name:e,jss:this,Renderer:this.options.Renderer});i.generateId||(i.generateId=this.generateId),i.classes||(i.classes={}),i.keyframes||(i.keyframes={});var s=o(e,n,i);return s&&this.plugins.onProcessRule(s),s},n.use=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach((function(t){e.plugins.use(t)})),this},e}(),ye=function(e){return new pe(e)},ve=function(){function e(){this.length=0,this.sheets=new WeakMap}var t=e.prototype;return t.get=function(e){var t=this.sheets.get(e);return t&&t.sheet},t.add=function(e,t){this.sheets.has(e)||(this.length++,this.sheets.set(e,{sheet:t,refs:0}))},t.manage=function(e){var t=this.sheets.get(e);if(t)return 0===t.refs&&t.sheet.attach(),t.refs++,t.sheet},t.unmanage=function(e){var t=this.sheets.get(e);t&&t.refs>0&&(t.refs--,0===t.refs&&t.sheet.detach())},u(e,[{key:"size",get:function(){return this.length}}]),e}(),ge="object"==typeof CSS&&null!=CSS&&"number"in CSS; | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jss={})}(this,(function(e){"use strict";function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r="object"===("undefined"==typeof window?"undefined":n(window))&&"object"===("undefined"==typeof document?"undefined":n(document))&&9===document.nodeType,i={}.constructor;function s(e){if(null==e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(s);if(e.constructor!==i)return e;var t={};for(var n in e)t[n]=s(e[n]);return t}function o(e,t,n){void 0===e&&(e="unnamed");var r=n.jss,i=s(t),o=r.plugins.onCreateRule(e,i,n);return o||(e[0],null)}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}function h(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}var c=function(e,t){for(var n="",r=0;r<e.length&&"!important"!==e[r];r++)n&&(n+=t),n+=e[r];return n},f=function(e,t){if(void 0===t&&(t=!1),!Array.isArray(e))return e;var n="";if(Array.isArray(e[0]))for(var r=0;r<e.length&&"!important"!==e[r];r++)n&&(n+=", "),n+=c(e[r]," ");else n=c(e,", ");return t||"!important"!==e[e.length-1]||(n+=" !important"),n};function d(e){return e&&!1===e.format?{linebreak:"",space:""}:{linebreak:"\n",space:" "}}function p(e,t){for(var n="",r=0;r<t;r++)n+=" ";return n+e}function y(e,t,n){void 0===n&&(n={});var r="";if(!t)return r;var i=n.indent,s=void 0===i?0:i,o=t.fallbacks;!1===n.format&&(s=-1/0);var u=d(n),a=u.linebreak,h=u.space;if(e&&s++,o)if(Array.isArray(o))for(var l=0;l<o.length;l++){var c=o[l];for(var y in c){var v=c[y];null!=v&&(r&&(r+=a),r+=p(y+":"+h+f(v)+";",s))}}else for(var g in o){var m=o[g];null!=m&&(r&&(r+=a),r+=p(g+":"+h+f(m)+";",s))}for(var R in t){var b=t[R];null!=b&&"fallbacks"!==R&&(r&&(r+=a),r+=p(R+":"+h+f(b)+";",s))}return(r||n.allowEmpty)&&e?(r&&(r=""+a+r+a),p(""+e+h+"{"+r,--s)+p("}",s)):r}var v=/([[\].#*$><+~=|^:(),"'`\s])/g,g="undefined"!=typeof CSS&&CSS.escape,m=function(e){return g?g(e):e.replace(v,"\\$1")},R=function(){function e(e,t,n){this.type="style",this.isProcessed=!1;var r=n.sheet,i=n.Renderer;this.key=e,this.options=n,this.style=t,r?this.renderer=r.renderer:i&&(this.renderer=new i)}return e.prototype.prop=function(e,t,n){if(void 0===t)return this.style[e];var r=!!n&&n.force;if(!r&&this.style[e]===t)return this;var i=t;n&&!1===n.process||(i=this.options.jss.plugins.onChangeValue(t,e,this));var s=null==i||!1===i,o=e in this.style;if(s&&!o&&!r)return this;var u=s&&o;if(u?delete this.style[e]:this.style[e]=i,this.renderable&&this.renderer)return u?this.renderer.removeProperty(this.renderable,e):this.renderer.setProperty(this.renderable,e,i),this;var a=this.options.sheet;return a&&a.attached,this},e}(),b=function(e){function n(t,n,r){var i;i=e.call(this,t,n,r)||this;var s=r.selector,o=r.scoped,u=r.sheet,a=r.generateId;return s?i.selectorText=s:!1!==o&&(i.id=a(l(l(i)),u),i.selectorText="."+m(i.id)),i}h(n,e);var r=n.prototype;return r.applyTo=function(e){var t=this.renderer;if(t){var n=this.toJSON();for(var r in n)t.setProperty(e,r,n[r])}return this},r.toJSON=function(){var e={};for(var t in this.style){var n=this.style[t];"object"!=typeof n?e[t]=n:Array.isArray(n)&&(e[t]=f(n))}return e},r.toString=function(e){var n=this.options.sheet,r=!!n&&n.options.link?t({},e,{allowEmpty:!0}):e;return y(this.selectorText,this.style,r)},a(n,[{key:"selector",set:function(e){if(e!==this.selectorText){this.selectorText=e;var t=this.renderer,n=this.renderable;if(n&&t)t.setSelector(n,e)||t.replaceRule(n,this)}},get:function(){return this.selectorText}}]),n}(R),S={onCreateRule:function(e,t,n){return"@"===e[0]||n.parent&&"keyframes"===n.parent.type?null:new b(e,t,n)}},x={indent:1,children:!0},k=/@([\w-]+)/,P=function(){function e(e,n,r){this.type="conditional",this.isProcessed=!1,this.key=e;var i=e.match(k);for(var s in this.at=i?i[1]:"unknown",this.query=r.name||"@"+this.at,this.options=r,this.rules=new W(t({},r,{parent:this})),n)this.rules.add(s,n[s]);this.rules.process()}var n=e.prototype;return n.getRule=function(e){return this.rules.get(e)},n.indexOf=function(e){return this.rules.indexOf(e)},n.addRule=function(e,t,n){var r=this.rules.add(e,t,n);return r?(this.options.jss.plugins.onProcessRule(r),r):null},n.replaceRule=function(e,t,n){var r=this.rules.replace(e,t,n);return r&&this.options.jss.plugins.onProcessRule(r),r},n.toString=function(e){void 0===e&&(e=x);var t=d(e).linebreak;if(null==e.indent&&(e.indent=x.indent),null==e.children&&(e.children=x.children),!1===e.children)return this.query+" {}";var n=this.rules.toString(e);return n?this.query+" {"+t+n+t+"}":""},e}(),w=/@media|@supports\s+/,C={onCreateRule:function(e,t,n){return w.test(e)?new P(e,t,n):null}},j={indent:1,children:!0},O=/@keyframes\s+([\w-]+)/,A=function(){function e(e,n,r){this.type="keyframes",this.at="@keyframes",this.isProcessed=!1;var i=e.match(O);i&&i[1]?this.name=i[1]:this.name="noname",this.key=this.type+"-"+this.name,this.options=r;var s=r.scoped,o=r.sheet,u=r.generateId;for(var a in this.id=!1===s?this.name:m(u(this,o)),this.rules=new W(t({},r,{parent:this})),n)this.rules.add(a,n[a],t({},r,{parent:this}));this.rules.process()}return e.prototype.toString=function(e){void 0===e&&(e=j);var t=d(e).linebreak;if(null==e.indent&&(e.indent=j.indent),null==e.children&&(e.children=j.children),!1===e.children)return this.at+" "+this.id+" {}";var n=this.rules.toString(e);return n&&(n=""+t+n+t),this.at+" "+this.id+" {"+n+"}"},e}(),I=/@keyframes\s+/,T=/\$([\w-]+)/g,M=function(e,t){return"string"==typeof e?e.replace(T,(function(e,n){return n in t?t[n]:e})):e},q=function(e,t,n){var r=e[t],i=M(r,n);i!==r&&(e[t]=i)},N={onCreateRule:function(e,t,n){return"string"==typeof e&&I.test(e)?new A(e,t,n):null},onProcessStyle:function(e,t,n){return"style"===t.type&&n?("animation-name"in e&&q(e,"animation-name",n.keyframes),"animation"in e&&q(e,"animation",n.keyframes),e):e},onChangeValue:function(e,t,n){var r=n.options.sheet;if(!r)return e;switch(t){case"animation":case"animation-name":return M(e,r.keyframes);default:return e}}},V=function(e){function n(){return e.apply(this,arguments)||this}return h(n,e),n.prototype.toString=function(e){var n=this.options.sheet,r=!!n&&n.options.link?t({},e,{allowEmpty:!0}):e;return y(this.key,this.style,r)},n}(R),E={onCreateRule:function(e,t,n){return n.parent&&"keyframes"===n.parent.type?new V(e,t,n):null}},G=function(){function e(e,t,n){this.type="font-face",this.at="@font-face",this.isProcessed=!1,this.key=e,this.style=t,this.options=n}return e.prototype.toString=function(e){var t=d(e).linebreak;if(Array.isArray(this.style)){for(var n="",r=0;r<this.style.length;r++)n+=y(this.at,this.style[r]),this.style[r+1]&&(n+=t);return n}return y(this.at,this.style,e)},e}(),_=/@font-face/,U={onCreateRule:function(e,t,n){return _.test(e)?new G(e,t,n):null}},B=function(){function e(e,t,n){this.type="viewport",this.at="@viewport",this.isProcessed=!1,this.key=e,this.style=t,this.options=n}return e.prototype.toString=function(e){return y(this.key,this.style,e)},e}(),$={onCreateRule:function(e,t,n){return"@viewport"===e||"@-ms-viewport"===e?new B(e,t,n):null}},J=function(){function e(e,t,n){this.type="simple",this.isProcessed=!1,this.key=e,this.value=t,this.options=n}return e.prototype.toString=function(e){if(Array.isArray(this.value)){for(var t="",n=0;n<this.value.length;n++)t+=this.key+" "+this.value[n]+";",this.value[n+1]&&(t+="\n");return t}return this.key+" "+this.value+";"},e}(),z={"@charset":!0,"@import":!0,"@namespace":!0},D=[S,C,N,E,U,$,{onCreateRule:function(e,t,n){return e in z?new J(e,t,n):null}}],F={process:!0},L={force:!0,process:!0},W=function(){function e(e){this.map={},this.raw={},this.index=[],this.counter=0,this.options=e,this.classes=e.classes,this.keyframes=e.keyframes}var n=e.prototype;return n.add=function(e,n,r){var i=this.options,s=i.parent,u=i.sheet,a=i.jss,h=i.Renderer,l=i.generateId,c=i.scoped,f=t({classes:this.classes,parent:s,sheet:u,jss:a,Renderer:h,generateId:l,scoped:c,name:e,keyframes:this.keyframes,selector:void 0},r),d=e;e in this.raw&&(d=e+"-d"+this.counter++),this.raw[d]=n,d in this.classes&&(f.selector="."+m(this.classes[d]));var p=o(d,n,f);if(!p)return null;this.register(p);var y=void 0===f.index?this.index.length:f.index;return this.index.splice(y,0,p),p},n.replace=function(e,n,r){var i=this.get(e),s=this.index.indexOf(i);i&&this.remove(i);var o=r;return-1!==s&&(o=t({},r,{index:s})),this.add(e,n,o)},n.get=function(e){return this.map[e]},n.remove=function(e){this.unregister(e),delete this.raw[e.key],this.index.splice(this.index.indexOf(e),1)},n.indexOf=function(e){return this.index.indexOf(e)},n.process=function(){var e=this.options.jss.plugins;this.index.slice(0).forEach(e.onProcessRule,e)},n.register=function(e){this.map[e.key]=e,e instanceof b?(this.map[e.selector]=e,e.id&&(this.classes[e.key]=e.id)):e instanceof A&&this.keyframes&&(this.keyframes[e.name]=e.id)},n.unregister=function(e){delete this.map[e.key],e instanceof b?(delete this.map[e.selector],delete this.classes[e.key]):e instanceof A&&delete this.keyframes[e.name]},n.update=function(){var e,t,n;if("string"==typeof(arguments.length<=0?void 0:arguments[0])?(e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1],n=arguments.length<=2?void 0:arguments[2]):(t=arguments.length<=0?void 0:arguments[0],n=arguments.length<=1?void 0:arguments[1],e=null),e)this.updateOne(this.get(e),t,n);else for(var r=0;r<this.index.length;r++)this.updateOne(this.index[r],t,n)},n.updateOne=function(t,n,r){void 0===r&&(r=F);var i=this.options,s=i.jss.plugins,o=i.sheet;if(t.rules instanceof e)t.rules.update(n,r);else{var u=t.style;if(s.onUpdate(n,t,o,r),r.process&&u&&u!==t.style){for(var a in s.onProcessStyle(t.style,t,o),t.style){var h=t.style[a];h!==u[a]&&t.prop(a,h,L)}for(var l in u){var c=t.style[l],f=u[l];null==c&&c!==f&&t.prop(l,null,L)}}}},n.toString=function(e){for(var t="",n=this.options.sheet,r=!!n&&n.options.link,i=d(e).linebreak,s=0;s<this.index.length;s++){var o=this.index[s].toString(e);(o||r)&&(t&&(t+=i),t+=o)}return t},e}(),H=function(){function e(e,n){for(var r in this.attached=!1,this.deployed=!1,this.classes={},this.keyframes={},this.options=t({},n,{sheet:this,parent:this,classes:this.classes,keyframes:this.keyframes}),n.Renderer&&(this.renderer=new n.Renderer(this)),this.rules=new W(this.options),e)this.rules.add(r,e[r]);this.rules.process()}var n=e.prototype;return n.attach=function(){return this.attached||(this.renderer&&this.renderer.attach(),this.attached=!0,this.deployed||this.deploy()),this},n.detach=function(){return this.attached?(this.renderer&&this.renderer.detach(),this.attached=!1,this):this},n.addRule=function(e,t,n){var r=this.queue;this.attached&&!r&&(this.queue=[]);var i=this.rules.add(e,t,n);return i?(this.options.jss.plugins.onProcessRule(i),this.attached?this.deployed?(r?r.push(i):(this.insertRule(i),this.queue&&(this.queue.forEach(this.insertRule,this),this.queue=void 0)),i):i:(this.deployed=!1,i)):null},n.replaceRule=function(e,t,n){var r=this.rules.get(e);if(!r)return this.addRule(e,t,n);var i=this.rules.replace(e,t,n);return i&&this.options.jss.plugins.onProcessRule(i),this.attached?this.deployed?(this.renderer&&(i?r.renderable&&this.renderer.replaceRule(r.renderable,i):this.renderer.deleteRule(r)),i):i:(this.deployed=!1,i)},n.insertRule=function(e){this.renderer&&this.renderer.insertRule(e)},n.addRules=function(e,t){var n=[];for(var r in e){var i=this.addRule(r,e[r],t);i&&n.push(i)}return n},n.getRule=function(e){return this.rules.get(e)},n.deleteRule=function(e){var t="object"==typeof e?e:this.rules.get(e);return!(!t||this.attached&&!t.renderable)&&(this.rules.remove(t),!(this.attached&&t.renderable&&this.renderer)||this.renderer.deleteRule(t.renderable))},n.indexOf=function(e){return this.rules.indexOf(e)},n.deploy=function(){return this.renderer&&this.renderer.deploy(),this.deployed=!0,this},n.update=function(){var e;return(e=this.rules).update.apply(e,arguments),this},n.updateOne=function(e,t,n){return this.rules.updateOne(e,t,n),this},n.toString=function(e){return this.rules.toString(e)},e}(),K=function(){function e(){this.plugins={internal:[],external:[]},this.registry={}}var t=e.prototype;return t.onCreateRule=function(e,t,n){for(var r=0;r<this.registry.onCreateRule.length;r++){var i=this.registry.onCreateRule[r](e,t,n);if(i)return i}return null},t.onProcessRule=function(e){if(!e.isProcessed){for(var t=e.options.sheet,n=0;n<this.registry.onProcessRule.length;n++)this.registry.onProcessRule[n](e,t);e.style&&this.onProcessStyle(e.style,e,t),e.isProcessed=!0}},t.onProcessStyle=function(e,t,n){for(var r=0;r<this.registry.onProcessStyle.length;r++)t.style=this.registry.onProcessStyle[r](t.style,t,n)},t.onProcessSheet=function(e){for(var t=0;t<this.registry.onProcessSheet.length;t++)this.registry.onProcessSheet[t](e)},t.onUpdate=function(e,t,n,r){for(var i=0;i<this.registry.onUpdate.length;i++)this.registry.onUpdate[i](e,t,n,r)},t.onChangeValue=function(e,t,n){for(var r=e,i=0;i<this.registry.onChangeValue.length;i++)r=this.registry.onChangeValue[i](r,t,n);return r},t.use=function(e,t){void 0===t&&(t={queue:"external"});var n=this.plugins[t.queue];-1===n.indexOf(e)&&(n.push(e),this.registry=[].concat(this.plugins.external,this.plugins.internal).reduce((function(e,t){for(var n in t)n in e&&e[n].push(t[n]);return e}),{onCreateRule:[],onProcessRule:[],onProcessStyle:[],onProcessSheet:[],onChangeValue:[],onUpdate:[]}))},e}();var Q=function(){function e(){this.registry=[]}var t=e.prototype;return t.add=function(e){var t=this.registry,n=e.options.index;if(-1===t.indexOf(e))if(0===t.length||n>=this.index)t.push(e);else for(var r=0;r<t.length;r++)if(t[r].options.index>n)return void t.splice(r,0,e)},t.reset=function(){this.registry=[]},t.remove=function(e){var t=this.registry.indexOf(e);this.registry.splice(t,1)},t.toString=function(e){for(var t=void 0===e?{}:e,n=t.attached,r=function(e,t){if(null==e)return{};var n,r,i={},s=Object.keys(e);for(r=0;r<s.length;r++)n=s[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(t,["attached"]),i=d(r).linebreak,s="",o=0;o<this.registry.length;o++){var u=this.registry[o];null!=n&&u.attached!==n||(s&&(s+=i),s+=u.toString(r))}return s},a(e,[{key:"index",get:function(){return 0===this.registry.length?0:this.registry[this.registry.length-1].options.index}}]),e}(),X=new Q,Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window&&window.Math===Math?window:"undefined"!=typeof self&&self.Math===Math?self:Function("return this")(),Z="2f1acc6c3a606b082e5eef5e54414ffb";null==Y[Z]&&(Y[Z]=0);var ee=Y[Z]++,te=function(e){void 0===e&&(e={});var t=0;return function(n,r){t+=1;var i="",s="";return r&&(r.options.classNamePrefix&&(s=r.options.classNamePrefix),null!=r.options.jss.id&&(i=String(r.options.jss.id))),e.minify?""+(s||"c")+ee+i+t:s+n.key+"-"+ee+(i?"-"+i:"")+"-"+t}},ne=function(e){var t;return function(){return t||(t=e()),t}},re=function(e,t){try{return e.attributeStyleMap?e.attributeStyleMap.get(t):e.style.getPropertyValue(t)}catch(e){return""}},ie=function(e,t,n){try{var r=n;if(Array.isArray(n)&&(r=f(n,!0),"!important"===n[n.length-1]))return e.style.setProperty(t,r,"important"),!0;e.attributeStyleMap?e.attributeStyleMap.set(t,r):e.style.setProperty(t,r)}catch(e){return!1}return!0},se=function(e,t){try{e.attributeStyleMap?e.attributeStyleMap.delete(t):e.style.removeProperty(t)}catch(e){}},oe=function(e,t){return e.selectorText=t,e.selectorText===t},ue=ne((function(){return document.querySelector("head")}));function ae(e){var t=X.registry;if(t.length>0){var n=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.attached&&r.options.index>t.index&&r.options.insertionPoint===t.insertionPoint)return r}return null}(t,e);if(n&&n.renderer)return{parent:n.renderer.element.parentNode,node:n.renderer.element};if((n=function(e,t){for(var n=e.length-1;n>=0;n--){var r=e[n];if(r.attached&&r.options.insertionPoint===t.insertionPoint)return r}return null}(t,e))&&n.renderer)return{parent:n.renderer.element.parentNode,node:n.renderer.element.nextSibling}}var r=e.insertionPoint;if(r&&"string"==typeof r){var i=function(e){for(var t=ue(),n=0;n<t.childNodes.length;n++){var r=t.childNodes[n];if(8===r.nodeType&&r.nodeValue.trim()===e)return r}return null}(r);if(i)return{parent:i.parentNode,node:i.nextSibling}}return!1}var he=ne((function(){var e=document.querySelector('meta[property="csp-nonce"]');return e?e.getAttribute("content"):null})),le=function(e,t,n){try{"insertRule"in e?e.insertRule(t,n):"appendRule"in e&&e.appendRule(t)}catch(e){return!1}return e.cssRules[n]},ce=function(e,t){var n=e.cssRules.length;return void 0===t||t>n?n:t},fe=function(){function e(e){this.getPropertyValue=re,this.setProperty=ie,this.removeProperty=se,this.setSelector=oe,this.hasInsertedRules=!1,this.cssRules=[],e&&X.add(e),this.sheet=e;var t,n=this.sheet?this.sheet.options:{},r=n.media,i=n.meta,s=n.element;this.element=s||((t=document.createElement("style")).textContent="\n",t),this.element.setAttribute("data-jss",""),r&&this.element.setAttribute("media",r),i&&this.element.setAttribute("data-meta",i);var o=he();o&&this.element.setAttribute("nonce",o)}var t=e.prototype;return t.attach=function(){if(!this.element.parentNode&&this.sheet){!function(e,t){var n=t.insertionPoint,r=ae(t);if(!1!==r&&r.parent)r.parent.insertBefore(e,r.node);else if(n&&"number"==typeof n.nodeType){var i=n,s=i.parentNode;s&&s.insertBefore(e,i.nextSibling)}else ue().appendChild(e)}(this.element,this.sheet.options);var e=Boolean(this.sheet&&this.sheet.deployed);this.hasInsertedRules&&e&&(this.hasInsertedRules=!1,this.deploy())}},t.detach=function(){if(this.sheet){var e=this.element.parentNode;e&&e.removeChild(this.element),this.sheet.options.link&&(this.cssRules=[],this.element.textContent="\n")}},t.deploy=function(){var e=this.sheet;e&&(e.options.link?this.insertRules(e.rules):this.element.textContent="\n"+e.toString()+"\n")},t.insertRules=function(e,t){for(var n=0;n<e.index.length;n++)this.insertRule(e.index[n],n,t)},t.insertRule=function(e,t,n){if(void 0===n&&(n=this.element.sheet),e.rules){var r=e,i=n;if("conditional"===e.type||"keyframes"===e.type){var s=ce(n,t);if(!1===(i=le(n,r.toString({children:!1}),s)))return!1;this.refCssRule(e,s,i)}return this.insertRules(r.rules,i),i}var o=e.toString();if(!o)return!1;var u=ce(n,t),a=le(n,o,u);return!1!==a&&(this.hasInsertedRules=!0,this.refCssRule(e,u,a),a)},t.refCssRule=function(e,t,n){e.renderable=n,e.options.parent instanceof H&&this.cssRules.splice(t,0,n)},t.deleteRule=function(e){var t=this.element.sheet,n=this.indexOf(e);return-1!==n&&(t.deleteRule(n),this.cssRules.splice(n,1),!0)},t.indexOf=function(e){return this.cssRules.indexOf(e)},t.replaceRule=function(e,t){var n=this.indexOf(e);return-1!==n&&(this.element.sheet.deleteRule(n),this.cssRules.splice(n,1),this.insertRule(t,n))},t.getRules=function(){return this.element.sheet.cssRules},e}(),de=0,pe=function(){function e(e){this.id=de++,this.version="10.9.0",this.plugins=new K,this.options={id:{minify:!1},createGenerateId:te,Renderer:r?fe:null,plugins:[]},this.generateId=te({minify:!1});for(var t=0;t<D.length;t++)this.plugins.use(D[t],{queue:"internal"});this.setup(e)}var n=e.prototype;return n.setup=function(e){return void 0===e&&(e={}),e.createGenerateId&&(this.options.createGenerateId=e.createGenerateId),e.id&&(this.options.id=t({},this.options.id,e.id)),(e.createGenerateId||e.id)&&(this.generateId=this.options.createGenerateId(this.options.id)),null!=e.insertionPoint&&(this.options.insertionPoint=e.insertionPoint),"Renderer"in e&&(this.options.Renderer=e.Renderer),e.plugins&&this.use.apply(this,e.plugins),this},n.createStyleSheet=function(e,n){void 0===n&&(n={});var r=n.index;"number"!=typeof r&&(r=0===X.index?0:X.index+1);var i=new H(e,t({},n,{jss:this,generateId:n.generateId||this.generateId,insertionPoint:this.options.insertionPoint,Renderer:this.options.Renderer,index:r}));return this.plugins.onProcessSheet(i),i},n.removeStyleSheet=function(e){return e.detach(),X.remove(e),this},n.createRule=function(e,n,r){if(void 0===n&&(n={}),void 0===r&&(r={}),"object"==typeof e)return this.createRule(void 0,e,n);var i=t({},r,{name:e,jss:this,Renderer:this.options.Renderer});i.generateId||(i.generateId=this.generateId),i.classes||(i.classes={}),i.keyframes||(i.keyframes={});var s=o(e,n,i);return s&&this.plugins.onProcessRule(s),s},n.use=function(){for(var e=this,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return n.forEach((function(t){e.plugins.use(t)})),this},e}(),ye=function(e){return new pe(e)},ve=function(){function e(){this.length=0,this.sheets=new WeakMap}var t=e.prototype;return t.get=function(e){var t=this.sheets.get(e);return t&&t.sheet},t.add=function(e,t){this.sheets.has(e)||(this.length++,this.sheets.set(e,{sheet:t,refs:0}))},t.manage=function(e){var t=this.sheets.get(e);if(t)return 0===t.refs&&t.sheet.attach(),t.refs++,t.sheet},t.unmanage=function(e){var t=this.sheets.get(e);t&&t.refs>0&&(t.refs--,0===t.refs&&t.sheet.detach())},a(e,[{key:"size",get:function(){return this.length}}]),e}(),ge="object"==typeof CSS&&null!=CSS&&"number"in CSS; | ||
/** | ||
@@ -3,0 +3,0 @@ * A better abstraction over CSS. |
{ | ||
"name": "jss", | ||
"description": "A lib for generating Style Sheets with JavaScript.", | ||
"version": "10.8.2", | ||
"version": "10.9.0", | ||
"license": "MIT", | ||
@@ -50,3 +50,3 @@ "homepage": "https://cssinjs.org/", | ||
}, | ||
"gitHead": "e693eca21f1557ea350fba0a7a3db0949cb7cac5" | ||
"gitHead": "359b55916cbc15653a3ca052841296bcd325bc86" | ||
} |
@@ -11,3 +11,3 @@ # jss | ||
See our website [jss](https://cssinjs.org/setup?v=v10.8.2) for more information. | ||
See our website [jss](https://cssinjs.org/setup?v=v10.9.0) for more information. | ||
@@ -14,0 +14,0 @@ ## Install |
@@ -385,3 +385,3 @@ import warning from 'tiny-warning' | ||
if (rule.options.parent instanceof StyleSheet) { | ||
this.cssRules[index] = cssRule | ||
this.cssRules.splice(index, 0, cssRule) | ||
} | ||
@@ -411,4 +411,2 @@ } | ||
* Generate a new CSS rule and replace the existing one. | ||
* | ||
* Only used for some old browsers because they can't set a selector. | ||
*/ | ||
@@ -415,0 +413,0 @@ replaceRule(cssRule, rule) { |
@@ -89,4 +89,5 @@ import {Properties as CSSProperties} from 'csstype' | ||
constructor(options: RuleListOptions) | ||
add(name: string, decl: JssStyle, options?: RuleOptions): Rule | ||
get(name: string): Rule | ||
add(name: string, decl: JssStyle, options?: RuleOptions): Rule | null | ||
replace(name: string, decl: JssStyle, options?: RuleOptions): Rule | null | ||
get(nameOrSelector: string): Rule | ||
remove(rule: Rule): void | ||
@@ -219,4 +220,13 @@ indexOf(rule: Rule): number | ||
addRule(style: JssStyle, options?: Partial<RuleOptions>): Rule | ||
addRule(name: RuleName, style: JssStyle, options?: Partial<RuleOptions>): Rule | ||
addRule(name: RuleName, style: JssStyle, options?: Partial<RuleOptions>): Rule | null | ||
/** | ||
* Replace a rule in the current stylesheet. | ||
*/ | ||
replaceRule( | ||
name: RuleName, | ||
style: JssStyle, | ||
options?: Partial<RuleOptions> | ||
): [Rule | null, Rule | null] | ||
insertRule(rule: Rule): void | ||
@@ -232,5 +242,5 @@ /** | ||
/** | ||
* Get a rule by name. | ||
* Get a rule by name or selector. | ||
*/ | ||
getRule(name: RuleName): Rule | ||
getRule(nameOrSelector: RuleName | string): Rule | ||
/** | ||
@@ -237,0 +247,0 @@ * Delete a rule by name. |
@@ -60,2 +60,11 @@ import RuleList from '../RuleList' | ||
/** | ||
* Replace rule, run plugins. | ||
*/ | ||
replaceRule(name, style, options) { | ||
const newRule = this.rules.replace(name, style, options) | ||
if (newRule) this.options.jss.plugins.onProcessRule(newRule) | ||
return newRule | ||
} | ||
/** | ||
* Generates a CSS string. | ||
@@ -62,0 +71,0 @@ */ |
@@ -89,9 +89,25 @@ import createRule from './utils/createRule' | ||
/** | ||
* Get a rule. | ||
* Replace rule. | ||
* Create a new rule and remove old one instead of overwriting | ||
* because we want to invoke onCreateRule hook to make plugins work. | ||
*/ | ||
get(name) { | ||
return this.map[name] | ||
replace(name, decl, ruleOptions) { | ||
const oldRule = this.get(name) | ||
const oldIndex = this.index.indexOf(oldRule) | ||
if (oldRule) { | ||
this.remove(oldRule) | ||
} | ||
let options = ruleOptions | ||
if (oldIndex !== -1) options = {...ruleOptions, index: oldIndex} | ||
return this.add(name, decl, options) | ||
} | ||
/** | ||
* Get a rule by name or selector. | ||
*/ | ||
get(nameOrSelector) { | ||
return this.map[nameOrSelector] | ||
} | ||
/** | ||
* Delete a rule. | ||
@@ -167,3 +183,3 @@ */ | ||
if (name) { | ||
this.updateOne(this.map[name], data, options) | ||
this.updateOne(this.get(name), data, options) | ||
} else { | ||
@@ -170,0 +186,0 @@ for (let index = 0; index < this.index.length; index++) { |
@@ -91,2 +91,36 @@ import RuleList from './RuleList' | ||
/** | ||
* Replace a rule in the current stylesheet. | ||
*/ | ||
replaceRule(nameOrSelector, decl, options) { | ||
const oldRule = this.rules.get(nameOrSelector) | ||
if (!oldRule) return this.addRule(nameOrSelector, decl, options) | ||
const newRule = this.rules.replace(nameOrSelector, decl, options) | ||
if (newRule) { | ||
this.options.jss.plugins.onProcessRule(newRule) | ||
} | ||
if (this.attached) { | ||
if (!this.deployed) return newRule | ||
// Don't replace / delete rule directly if there is no stringified version yet. | ||
// It will be inserted all together when .attach is called. | ||
if (this.renderer) { | ||
if (!newRule) { | ||
this.renderer.deleteRule(oldRule) | ||
} else if (oldRule.renderable) { | ||
this.renderer.replaceRule(oldRule.renderable, newRule) | ||
} | ||
} | ||
return newRule | ||
} | ||
// We can't replace rules to a detached style node. | ||
// We will redeploy the sheet once user will attach it. | ||
this.deployed = false | ||
return newRule | ||
} | ||
/** | ||
* Insert rule into the StyleSheet | ||
@@ -114,6 +148,6 @@ */ | ||
/** | ||
* Get a rule by name. | ||
* Get a rule by name or selector. | ||
*/ | ||
getRule(name) { | ||
return this.rules.get(name) | ||
getRule(nameOrSelector) { | ||
return this.rules.get(nameOrSelector) | ||
} | ||
@@ -120,0 +154,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
469155
10060