-
Notifications
You must be signed in to change notification settings - Fork 14
/
bss.min.js
3 lines (3 loc) · 8.04 KB
/
bss.min.js
1
2
3
(function(b,m){typeof exports=="object"&&typeof module!="undefined"?module.exports=m():typeof define=="function"&&define.amd?define(m):(b=typeof globalThis!="undefined"?globalThis:b||self,b.b=m())})(this,function(){"use strict";var b=[":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"],m={ai:"alignItems",b:"bottom",bc:"backgroundColor",br:"borderRadius",bs:"boxShadow",bi:"backgroundImage",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"};const k=["float"].concat(Object.keys(typeof document=="undefined"?{}:E(document.documentElement.style)).filter(t=>t.indexOf("-")===-1&&t!=="length"));function E(t){return t?t.hasOwnProperty("width")?t:E(Object.getPrototypeOf(t)):{}}const J=/^-?-?[a-z][a-z-_0-9]*$/i,M=(t,e={})=>n=>n in e?e[n]:e[n]=t(n);function _(t,e,n){e in t?_(t,"!"+e,n):t[e]=L(e,n)}const x=Object.create(null,{}),w=Object.create(null,{}),P=/^(o|O|ms|MS|Ms|moz|Moz|webkit|Webkit|WebKit)([A-Z])/,K=M(t=>{const e=document.createElement("div");try{return e.style[t]="1px",e.style.setProperty(t,"1px"),e.style[t].slice(-3)==="1px"?"px":""}catch(n){return""}},{flex:"",boxShadow:"px",border:"px",borderTop:"px",borderRight:"px",borderBottom:"px",borderLeft:"px"});function v(t){return t.charAt(0).toLowerCase()+t.slice(1)}function u(t,e){for(const n in e)e.hasOwnProperty(n)&&(t[n]=typeof e[n]=="string"?e[n]:u(t[n]||{},e[n]));return t}const G=/-([a-z])/g;function R(t){return t.slice(t.charAt(0)==="-"?1:0).replace(G,function(e){return e[1].toUpperCase()})}const Q=/(\B[A-Z])/g;function X(t){return t.replace(Q,"-$1").toLowerCase()}const Y=/([A-Z])/g;function tt(t){return t.charAt(0)+(t.match(Y)||[]).join("").toLowerCase()}const et=/&/g;function p(t,e,n="",r){const s={},f=n.indexOf("&")>-1&&n.indexOf(",")===-1?"":"&";let h=[];return Object.keys(t).forEach(c=>{c.charAt(0)==="@"?h.push(c+"{"+p(t[c],e,n,r).join("")+"}"):typeof t[c]=="object"?h=h.concat(p(t[c],e,n+c,r)):s[c]=t[c]}),Object.keys(s).length&&h.unshift(((r||n.charAt(0)===" "?"":"&")+f+n).replace(et,e).trim()+"{"+z(s)+"}"),h}const nt=/,(?=(?:(?:[^"]*"){2})*[^"]*$)/;function z(t){return Object.keys(t).reduce((e,n)=>e+rt(n.charAt(0)==="!"?n.slice(1):n,t[n]),"")}function rt(t,e){return t=t in x?x[t]:t,(P.test(t)?"-":"")+(N(t)?t:X(t))+":"+e+";"}function L(t,e){return Array.isArray(e)?e.map(n=>D(t,n)).join(" "):typeof e=="string"?L(t,e.split(" ")):D(t,e)}function D(t,e){return e in w?w[e]:e+(isNaN(e)||e===null||e===0||e==="0"||typeof e=="boolean"||N(t)?"":K(t))}function N(t){return t.charAt(0)==="-"&&t.charAt(1)==="-"}const O="b"+("000"+(Math.random()*46656|0).toString(36)).slice(-3)+("000"+(Math.random()*46656|0).toString(36)).slice(-3),g=typeof document=="object"&&document.createElement("style");g&&document.head&&document.head.appendChild(g),g&&(g.id=O);const S=g&&g.sheet;let B=!1,j=Object.create(null,{}),y=[],V=0;function st(t){B=t}function it(){const t=y.join("");return y=[],j=Object.create(null,{}),V=0,t}function ot(){return y}function A(t,e){if(y.push(t),B)return g.textContent=y.join(`
`);try{S&&S.insertRule(t,arguments.length>1?e:S.cssRules.length)}catch(n){}}function ct(t){const e=JSON.stringify(t);if(e in j)return j[e];const n=O+ ++V,r=p(t,"."+n);for(let s=0;s<r.length;s++)A(r[s]);return j[e]=n,n}const C=Object.create(null);function i(t,e){const n=a(i);return t&&u(n.__style,d.apply(null,arguments)),n}function o(t,e){Object.defineProperty(i,t,{configurable:!0,value:e})}Object.defineProperties(i,{__style:{configurable:!0,writable:!0,value:{}},valueOf:{configurable:!0,writable:!0,value:function(){return"."+this.class}},toString:{configurable:!0,writable:!0,value:function(){return this.class}}}),o("setDebug",st),o("$keyframes",yt),o("$media",ft),o("$import",ut),o("$nest",at),o("getSheet",it),o("getRules",ot),o("helper",l),o("css",dt),o("classPrefix",O);function a(t){const e=Object.create(i,{__style:{value:u({},t.__style)},style:{enumerable:!0,get:function(){return Object.keys(this.__style).reduce((n,r)=>((typeof this.__style[r]=="number"||typeof this.__style[r]=="string")&&(n[r.charAt(0)==="!"?r.slice(1):r]=this.__style[r]),n),{})}}});return t===i&&(i.__style={}),e}k.forEach(t=>{const e=t.match(P);if(e){const n=v(t.replace(P,"$2"));if(k.indexOf(n)===-1){n==="flexDirection"&&(w.flex="-"+e[1].toLowerCase()+"-flex"),x[n]=t,o(n,I(t)),o(Z(n),i[n]);return}}o(t,I(t)),o(Z(t),i[t])}),o("content",function(e){const n=a(this);return e==null||e===!1?delete n.__style.content:n.__style.content='"'+e+'"',n}),Object.defineProperty(i,"class",{set:function(t){this.__class=t},get:function(){return this.__class||ct(this.__style)}});function ft(t,e){const n=a(this);return t&&(n.__style["@media "+t]=d(e)),n}const lt=/^('|"|url\('|url\(")/i;function ut(t){return t&&A("@import "+(lt.test(t)?t:'"'+t+'"')+";",0),a(this)}function at(t,e){const n=a(this);return arguments.length===1?Object.keys(t).forEach(r=>H(n.__style,r,t[r])):t&&H(n.__style,t,e),n}function H(t,e,n){const r=e.split(nt).map(s=>(s=s.trim(),(s.charAt(0)===":"||s.charAt(0)==="["?"":" ")+s)).join(",&");r in t?u(t[r],d(n)):t[r]=d(n)}b.forEach(t=>o("$"+R(t.replace(/:/g,"")),function(n,r){const s=a(this);return T(n)?s.__style[t]=d.apply(null,arguments):(n||r)&&(s.__style[t+(r?"("+n+")":"")]=d(r||n)),s}));function I(t){return function(n){const r=a(this);return!n&&n!==0?delete r.__style[t]:arguments.length>0&&_(r.__style,t,Array.prototype.slice.call(arguments)),r}}function dt(t,e){return arguments.length===1?Object.keys(t).forEach(n=>W(n,t[n])):W(t,e),a(this)}function W(t,e){p(d(e),t,"",!0).forEach(n=>A(n))}function l(t,e){if(arguments.length===1)return Object.keys(t).forEach(n=>l(n,t[n]));delete i[t],typeof e=="function"?(l[t]=e,Object.defineProperty(i,t,{configurable:!0,value:function(r){const s=a(this),f=T(r)?e(U(r,arguments)):e.apply(null,arguments);return u(s.__style,f.__style),s}})):(l[t]=d(e),Object.defineProperty(i,t,{configurable:!0,get:function(){const n=a(this);return u(n.__style,d(e)),n}}))}i.helper("$animate",(t,e)=>i.animation(i.$keyframes(e)+" "+t));function Z(t){const e=tt(t),n=m[e]&&m[e]!==t?t:e;return C[n]=t,n}const ht=/;(?![^("]*[)"])|\n/,gt=/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*(?![^("]*[)"])/g,mt=/[ :]+/,F=M(t=>{let e="",n;return t.trim().replace(gt,"").split(ht).reduce((r,s)=>{if(!s)return r;s=e+s.trim();const[f,...h]=s.replace(mt," ").split(" ");if(e=s.charAt(s.length-1)===","?s:"",e)return r;if(s.charAt(0)===","||!J.test(f))return r[n]+=" "+s,r;if(!f)return r;const c=f.charAt(0)==="-"&&f.charAt(1)==="-"?f:R(f);return n=C[c]||c,f in l?typeof l[f]=="function"?u(r,l[f](...h).__style):u(r,l[f]):c in l?typeof l[c]=="function"?u(r,l[c](...h).__style):u(r,l[c]):h.length>0&&_(r,n,h),r},{})});let bt=0;const $={};function yt(t){const e=Object.keys(t).reduce((r,s)=>r+s+"{"+z(d(t[s]))+"}","");if(e in $)return $[e];const n=O+bt++;return $[e]=n,A("@keyframes "+n+"{"+e+"}"),n}function d(t,e){return typeof t=="string"?typeof e=="string"||typeof e=="number"?{[t]:e}:F(t):T(t)?F(U(t,arguments)):t.__style||q(t)}function T(t){return Array.isArray(t)&&typeof t[0]=="string"}function U(t,e){let n="";for(let r=0;r<t.length;r++)n+=t[r]+(e[r+1]||e[r+1]===0?e[r+1]:"");return n}function q(t){return Object.keys(t).reduce((e,n)=>{const r=t[n];return n=C[n]||n,!r&&r!==0&&r!==""||(n==="content"&&r.charAt(0)!=='"'?e[n]='"'+r+'"':typeof r=="object"?e[n]=q(r):_(e,n,r)),e},{})}return i});
//# sourceMappingURL=bss.min.js.map