UNPKG

7.17 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.b=e()}(this,function(){"use strict";var i={ai:"alignItems",b:"bottom",bc:"backgroundColor",br:"borderRadius",bs:"boxShadow",c:"color",d:"display",f:"float",fd:"flexDirection",ff:"fontFamily",fs:"fontSize",h:"height",jc:"justifyContent",l:"left",lh:"lineHeight",ls:"letterSpacing",m:"margin",mb:"marginBottom",ml:"marginLeft",mr:"marginRight",mt:"marginTop",o:"opacity",p:"padding",pb:"paddingBottom",pl:"paddingLeft",pr:"paddingRight",pt:"paddingTop",r:"right",t:"top",ta:"textAlign",td:"textDecoration",tt:"textTransform",w:"width"},o=["float"].concat(Object.keys(function t(e){return e.hasOwnProperty("width")?e:t(Object.getPrototypeOf(e))}(document.documentElement.style)).filter(function(t){return-1===t.indexOf("-")&&"length"!==t}));var t=function(e,n){return void 0===n&&(n={}),function(t){return t in n?n[t]:n[t]=e(t)}};function l(t,e,n){e in t?l(t,"!"+e,n):t[e]=n}var a=Object.create(null,{}),c=Object.create(null,{}),u=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,n=t(function(t){var e=document.createElement("div");try{return e.style[t]="1px",e.style.setProperty(t,"1px"),"1px"===e.style[t].slice(-3)?"px":""}catch(t){return""}},{flex:"",boxShadow:"px",border:"px"});function f(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}function s(t){return t.slice("-"===t.charAt(0)?1:0).replace(/-([a-z])/g,function(t){return t[1].toUpperCase()})}function h(e,n,r,i){void 0===r&&(r="");var o={},c=[];return Object.keys(e).forEach(function(t){"@"===t.charAt(0)?c.push(t+"{"+h(e[t],n,r,i)+"}"):"object"==typeof e[t]?c=c.concat(h(e[t],n,r+t,i)):o[t]=e[t]}),Object.keys(o).length&&c.unshift(((i||" "===r.charAt(0)?"":"&")+"&"+r).replace(/&/g,n)+"{"+p(o)+"}"),c}var r=/,(?=(?:(?:[^"]*"){2})*[^"]*$)/;function p(i){return Object.keys(i).reduce(function(t,e){return t+(n=e.replace(/!/g,""),r=i[e],(u.test(n)?"-":"")+("-"===n.charAt(0)&&"-"===n.charAt(1)?n:n.replace(/([A-Z])/g,"-$1").toLowerCase())+":"+r+";");var n,r},"")}function y(t,e){return e in c?c[e]:d(t,e)}function d(t,e){return e+(isNaN(e)?"":n(t))}var e=window.document,g=e&&e.createElement("style");g&&e.head.appendChild(g);var b=g&&g.sheet,m=!1,_=Object.create(null,{}),v=[],j=0,O="b"+("000"+(46656*Math.random()|0).toString(36)).slice(-3)+("000"+(46656*Math.random()|0).toString(36)).slice(-3);function x(t,e){if(v.push(t),m)return g.textContent=v.join("\n");b&&b.insertRule(t,1<arguments.length?e:b.cssRules.length)}var A=Object.create(null);function k(t,e){var n=E(k);return f(n.__style,D.apply(null,arguments)),n}function w(t,e){Object.defineProperty(k,t,{configurable:!0,value:e})}function E(t){var e=Object.create(k,{__style:{value:t.__style},style:{enumerable:!0,get:function(){var n=this;return Object.keys(this.__style).reduce(function(t,e){return"number"!=typeof n.__style[e]&&"string"!=typeof n.__style[e]||(t[e.replace(/^!/,"")]=n.__style[e]),t},{})}}});return t===k&&(k.__style={}),e}function P(t,e,n){l(t,e.split(r).map(function(t){return(":"===(t=t.trim()).charAt(0)||"["===t.charAt(0)?"":" ")+t}).join(",&"),D(n))}function $(e){return function(t){return t||0===t?0<arguments.length&&l(this.__style,e,1===arguments.length?y(e,t):Array.prototype.slice.call(arguments).map(function(t){return d(e,t)}).join(" ")):delete this.__style[e],E(this)}}function C(t,e){h(D(e),t,"",!0).forEach(x)}function S(e,n){if(1===arguments.length)return Object.keys(e).forEach(function(t){return S(t,e[t])});delete k[e],"function"==typeof n?(S[e]=n,Object.defineProperty(k,e,{configurable:!0,value:function(){var t=n.apply(null,arguments);return f(this.__style,t.__style),E(this)}})):(S[e]=D(n),Object.defineProperty(k,e,{configurable:!0,get:function(){return f(this.__style,D(n)),E(this)}}))}function L(t){var e,n=(e=t).charAt(0)+(e.match(/([A-Z])/g)||[]).join("").toLowerCase(),r=i[n]&&i[n]!==t?t:n;return A[r]=t,r}Object.defineProperties(k,{__style:{configurable:!0,writable:!0,value:{}},valueOf:{configurable:!0,writable:!0,value:function(){return"."+this.class}}}),w("setDebug",function(t){m=t}),w("$keyframes",function(n){var t=Object.keys(n).reduce(function(t,e){return t+e+"{"+p(D(n[e]))+"}"},"");if(t in z)return z[t];var e=O+R++;return x("@keyframes "+(z[t]=e)+"{"+t+"}"),e}),w("$media",function(t,e){t&&l(this.__style,"@media "+t,D(e));return E(this)}),w("$import",function(t){t&&x("@import "+t+";",0);return E(this)}),w("$nest",function(e,t){var n=this;1===arguments.length?Object.keys(e).forEach(function(t){return P(n.__style,t,e[t])}):e&&P(this.__style,e,t);return E(this)}),w("getSheet",function(){var t=v.join("");return v=[],_=Object.create(null,{}),j=0,t}),w("helper",S),w("css",function(e,t){1===arguments.length?Object.keys(e).forEach(function(t){return C(t,e[t])}):C(e,t);return E(this)}),w("classPrefix",O),o.forEach(function(t){var e,n=t.match(u);if(n){var r=(e=t.replace(u,"$2")).charAt(0).toLowerCase()+e.slice(1);if(-1===o.indexOf(r))return"flexDirection"===r&&(c.flex="-"+n[1].toLowerCase()+"-flex"),w(r,$(a[r]=t)),void w(L(r),k[r])}w(t,$(t)),w(L(t),k[t])}),w("content",function(t){return this.__style.content='"'+t+'"',E(this)}),Object.defineProperty(k,"class",{set:function(t){this.__class=t},get:function(){return this.__class||function(t){var e=JSON.stringify(t);if(e in _)return _[e];for(var n=O+ ++j,r=h(t,"."+n),i=0;i<r.length;i++)x(r[i]);return _[e]=n}(this.__style)}}),[":active",":any",":checked",":default",":disabled",":empty",":enabled",":first",":first-child",":first-of-type",":fullscreen",":focus",":hover",":indeterminate",":in-range",":invalid",":last-child",":last-of-type",":left",":link",":only-child",":only-of-type",":optional",":out-of-range",":read-only",":read-write",":required",":right",":root",":scope",":target",":valid",":visited",":dir",":lang",":not",":nth-child",":nth-last-child",":nth-last-of-type",":nth-of-type","::after","::before","::first-letter","::first-line","::selection","::backdrop","::placeholder","::marker","::spelling-error","::grammar-error"].forEach(function(n){return w("$"+s(n.replace(/:/g,"")),function(t,e){return(t||e)&&l(this.__style,n+(e?"("+t+")":""),D(e||t)),E(this)})}),k.helper("$animate",function(t,e){return k.animation(k.$keyframes(e)+" "+t)});var M=t(function(t){var a,u="";return t.trim().split(/;|\n/).reduce(function(t,e){if(e=u+e.trim(),u=","===e.charAt(e.length-1)?e:"")return t;if(","===e.charAt(0))return t[a]+=e,t;var n=e.replace(/[ :]+/," ").split(" "),r=n[0],i=n.slice(1);if(!r)return t;var o="-"===r.charAt(0)&&"-"===r.charAt(1),c=o?r:s(r);return a=A[c]||c,c in S?f(t,"function"==typeof S[c]?S[c].apply(S,i).__style:S[c]):0<i.length&&l(t,a,i.map(function(t){return o?t:d(a,t)}).join(" ")),t},{})}),R=0,z={};function D(t,e){var n,r,i=arguments;if("string"==typeof t)return"string"==typeof e||"number"==typeof e?((n={})[t]=e,n):M(t);if(Array.isArray(t)&&"string"==typeof t[0]){for(var o="",c=0;c<t.length;c++)o+=t[c]+(i[c+1]||"");return M(o)}return t.__style||(r=t,Object.keys(r).reduce(function(t,e){var n=r[e];return(n||0===n||""===n)&&("content"===e&&'"'!==n.charAt(0)?t[e]='"'+n+'"':t[e in a?a[e]:e]=y(e,n)),t},{}))}return k});
2//# sourceMappingURL=bss.min.js.map