UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

2 lines (1 loc) 5 kB
function K(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function _(t,n){if(!isFinite(t)||t===0)return null;var o=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"),i=t.slice(0,o);return[i.length>1?i[0]+i.slice(2):i,+t.slice(o+1)]}function U(t){return t=_(Math.abs(t)),t?t[1]:NaN}function Q(t,n){return function(o,i){for(var e=o.length,f=[],c=0,h=t[0],x=0;e>0&&h>0&&(x+h+1>i&&(h=Math.max(1,i-x)),f.push(o.substring(e-=h,e+h)),!((x+=h+1)>i));)h=t[c=(c+1)%t.length];return f.reverse().join(n)}}function V(t){return function(n){return n.replace(/[0-9]/g,function(o){return t[+o]})}}var W=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function z(t){if(!(n=W.exec(t)))throw new Error("invalid format: "+t);var n;return new F({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}z.prototype=F.prototype;function F(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}F.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function tt(t){t:for(var n=t.length,o=1,i=-1,e;o<n;++o)switch(t[o]){case".":i=e=o;break;case"0":i===0&&(i=o),e=o;break;default:if(!+t[o])break t;i>0&&(i=0);break}return i>0?t.slice(0,i)+t.slice(e+1):t}var A;function nt(t,n){var o=_(t,n);if(!o)return A=void 0,t.toPrecision(n);var i=o[0],e=o[1],f=e-(A=Math.max(-8,Math.min(8,Math.floor(e/3)))*3)+1,c=i.length;return f===c?i:f>c?i+new Array(f-c+1).join("0"):f>0?i.slice(0,f)+"."+i.slice(f):"0."+new Array(1-f).join("0")+_(t,Math.max(0,n+f-1))[0]}function D(t,n){var o=_(t,n);if(!o)return t+"";var i=o[0],e=o[1];return e<0?"0."+new Array(-e).join("0")+i:i.length>e+1?i.slice(0,e+1)+"."+i.slice(e+1):i+new Array(e-i.length+2).join("0")}var G={"%":(t,n)=>(t*100).toFixed(n),b:t=>Math.round(t).toString(2),c:t=>t+"",d:K,e:(t,n)=>t.toExponential(n),f:(t,n)=>t.toFixed(n),g:(t,n)=>t.toPrecision(n),o:t=>Math.round(t).toString(8),p:(t,n)=>D(t*100,n),r:D,s:nt,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function I(t){return t}var X=Array.prototype.map,R=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function rt(t){var n=t.grouping===void 0||t.thousands===void 0?I:Q(X.call(t.grouping,Number),t.thousands+""),o=t.currency===void 0?"":t.currency[0]+"",i=t.currency===void 0?"":t.currency[1]+"",e=t.decimal===void 0?".":t.decimal+"",f=t.numerals===void 0?I:V(X.call(t.numerals,String)),c=t.percent===void 0?"%":t.percent+"",h=t.minus===void 0?"−":t.minus+"",x=t.nan===void 0?"NaN":t.nan+"";function O(a,g){a=z(a);var b=a.fill,M=a.align,d=a.sign,w=a.symbol,v=a.zero,N=a.width,E=a.comma,l=a.precision,$=a.trim,m=a.type;m==="n"?(E=!0,m="g"):G[m]||(l===void 0&&(l=12),$=!0,m="g"),(v||b==="0"&&M==="=")&&(v=!0,b="0",M="=");var B=(g&&g.prefix!==void 0?g.prefix:"")+(w==="$"?o:w==="#"&&/[boxX]/.test(m)?"0"+m.toLowerCase():""),H=(w==="$"?i:/[%p]/.test(m)?c:"")+(g&&g.suffix!==void 0?g.suffix:""),T=G[m],J=/[defgprs%]/.test(m);l=l===void 0?6:/[gprs]/.test(m)?Math.max(1,Math.min(21,l)):Math.max(0,Math.min(20,l));function C(r){var y=B,u=H,p,L,P;if(m==="c")u=T(r)+u,r="";else{r=+r;var S=r<0||1/r<0;if(r=isNaN(r)?x:T(Math.abs(r),l),$&&(r=tt(r)),S&&+r==0&&d!=="+"&&(S=!1),y=(S?d==="("?d:h:d==="-"||d==="("?"":d)+y,u=(m==="s"&&!isNaN(r)&&A!==void 0?R[8+A/3]:"")+u+(S&&d==="("?")":""),J){for(p=-1,L=r.length;++p<L;)if(P=r.charCodeAt(p),48>P||P>57){u=(P===46?e+r.slice(p+1):r.slice(p))+u,r=r.slice(0,p);break}}}E&&!v&&(r=n(r,1/0));var k=y.length+r.length+u.length,s=k<N?new Array(N-k+1).join(b):"";switch(E&&v&&(r=n(s+r,s.length?N-u.length:1/0),s=""),M){case"<":r=y+r+u+s;break;case"=":r=y+s+r+u;break;case"^":r=s.slice(0,k=s.length>>1)+y+r+u+s.slice(k);break;default:r=s+y+r+u;break}return f(r)}return C.toString=function(){return a+""},C}function q(a,g){var b=Math.max(-8,Math.min(8,Math.floor(U(g)/3)))*3,M=Math.pow(10,-b),d=O((a=z(a),a.type="f",a),{suffix:R[8+b/3]});return function(w){return d(M*w)}}return{format:O,formatPrefix:q}}var j,Y,Z;it({thousands:",",grouping:[3],currency:["$",""]});function it(t){return j=rt(t),Y=j.format,Z=j.formatPrefix,j}Object.defineProperty(exports,"exponent_default",{enumerable:!0,get:function(){return U}});Object.defineProperty(exports,"format",{enumerable:!0,get:function(){return Y}});Object.defineProperty(exports,"formatPrefix",{enumerable:!0,get:function(){return Z}});Object.defineProperty(exports,"formatSpecifier",{enumerable:!0,get:function(){return z}});