number-flow 0.1.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Number Flow
2
+
3
+ WIP.
@@ -0,0 +1,35 @@
1
+ type NumberPartType = Exclude<Intl.NumberFormatPartTypes, 'minusSign' | 'plusSign'> | 'sign';
2
+ type IntegerPart = {
3
+ type: NumberPartType & 'integer';
4
+ value: number;
5
+ };
6
+ type FractionPart = {
7
+ type: NumberPartType & 'fraction';
8
+ value: number;
9
+ };
10
+ type DigitPart = IntegerPart | FractionPart;
11
+ type SymbolPart = {
12
+ type: Exclude<NumberPartType, 'integer' | 'fraction'>;
13
+ value: string;
14
+ };
15
+ export type NumberPart = DigitPart | SymbolPart;
16
+ export type NumberPartKey = string;
17
+ type KeyedPart = {
18
+ key: NumberPartKey;
19
+ };
20
+ export type KeyedDigitPart = DigitPart & KeyedPart;
21
+ export type KeyedSymbolPart = SymbolPart & KeyedPart;
22
+ export type KeyedNumberPart = KeyedDigitPart | KeyedSymbolPart;
23
+ export type Format = Omit<Intl.NumberFormatOptions, 'notation'> & {
24
+ notation?: Exclude<Intl.NumberFormatOptions['notation'], 'scientific' | 'engineering'>;
25
+ };
26
+ export type Value = Parameters<typeof Intl.NumberFormat.prototype.formatToParts>[0];
27
+ export declare function partitionParts(value: Value, formatter: Intl.NumberFormat): {
28
+ pre: KeyedNumberPart[];
29
+ integer: KeyedNumberPart[];
30
+ fraction: KeyedNumberPart[];
31
+ post: KeyedNumberPart[];
32
+ formatted: string;
33
+ };
34
+ export type PartitionedParts = ReturnType<typeof partitionParts>;
35
+ export {};
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var St=Object.defineProperty;var et=n=>{throw TypeError(n)};var kt=(n,i,t)=>i in n?St(n,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[i]=t;var u=(n,i,t)=>kt(n,typeof i!="symbol"?i+"":i,t),it=(n,i,t)=>i.has(n)||et("Cannot "+t);var o=(n,i,t)=>(it(n,i,"read from private field"),t?t.call(n):i.get(n)),r=(n,i,t)=>i.has(n)?et("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(n):i.set(n,t),h=(n,i,t,s)=>(it(n,i,"write to private field"),s?s.call(n,t):i.set(n,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("esm-env"),y=(n,i,t)=>{const s=document.createElement(n),[e,a]=Array.isArray(i)?[void 0,i]:[i,t];return e&&Object.assign(s,e),a==null||a.forEach(l=>s.appendChild(l)),s},Ct=(n,i)=>{typeof Element.prototype.replaceChildren>"u"?(n.innerHTML="",i.forEach(t=>n.appendChild(t))):n.replaceChildren(...i)},vt=(n,i)=>{var t;return i==="left"?n.offsetLeft:(((t=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:t.offsetWidth)??0)-n.offsetWidth-n.offsetLeft};function $t(n,i,{reverse:t=!1}={}){const s=n.length;for(let e=t?s-1:0;t?e>=0:e<s;t?e--:e++)i(n[e],e)}function Rt(n,i){const t=i.formatToParts(n),s=[],e=[],a=[],l=[],f={},c=p=>(f[p]||(f[p]=0),`${p}:${f[p]++}`);let d="",b=!1,T=!1;for(const p of t){d+=p.value;const m=p.type==="minusSign"||p.type==="plusSign"?"sign":p.type;m==="integer"?(b=!0,e.push(...p.value.split("").map(Z=>({type:m,value:parseInt(Z)})))):m==="group"?e.push({type:m,value:p.value}):m==="decimal"?(T=!0,a.push({type:m,value:p.value,key:c(m)})):m==="fraction"?a.push(...p.value.split("").map(Z=>({type:m,value:parseInt(Z),key:c(m)}))):(b||T?l:s).push({type:m,value:p.value,key:c(m)})}const x=[];for(let p=e.length-1;p>=0;p--)x.unshift({...e[p],key:c(e[p].type)});return{pre:s,integer:x,fraction:a,post:l,formatted:d}}const jt=V.BROWSER?HTMLElement:class{},Tt=String.raw,ct=V.BROWSER&&typeof CSS<"u"&&CSS.supports("transition-timing-function","linear(1, 2)"),ht=V.BROWSER&&typeof CSS<"u"&&typeof CSS.registerProperty<"u",J=V.BROWSER&&typeof CSS<"u"&&typeof CSS.supports("animation-composition","accumulate")<"u";if(ht)try{CSS.registerProperty({name:"--_number-flow-scale-x",syntax:"<number>",inherits:!1,initialValue:"1"})}catch{}const dt="var(--number-flow-char-height, 1em)",g="var(--number-flow-mask-height, 0.15em)",E="var(--number-flow-mask-width, 0.5em)",G=`${E} * 1/var(--_number-flow-scale-x)`,st=`calc(${G})`,nt=`linear-gradient(to bottom, transparent 0, #000 ${g}, #000 calc(100% - ${g}), transparent 100%)`,K="#000 0, transparent 71%",ft="span",Et={fontKerning:"none",display:"inline-block",lineHeight:dt,padding:`${g} 0`},ot=Tt`:host{display:inline-block;direction:ltr;user-select:none;pointer-events:none;white-space:nowrap;position:relative;line-height:${dt} !important;isolation:isolate;}::slotted(${ft}){position:absolute;left:0;top:0;color:transparent !important;z-index:-1;user-select:text;pointer-events:auto;}.section{display:inline-block;padding-bottom:${g};padding-top:${g};vertical-align:top;user-select:none;}.section:not(.section--masked),.section--masked .section__inner{position:relative;isolation:isolate;}.section__inner{display:inline-block;transform-origin:inherit;}.section--justify-left{transform-origin:center left;}.section--justify-right{transform-origin:center right;}.section--masked{overflow:clip;position:relative;z-index:-1;--_number-flow-scale-x:1;-webkit-mask-repeat:no-repeat;-webkit-mask-size:calc(100% - ${G}) 100%,100% calc(100% - ${g} * 2),${st} ${g},${st} ${g};}.section--masked.section--justify-left{padding-right:${E};margin-right:calc(-1 * ${E});-webkit-mask-image:${nt},linear-gradient(to right,#000 0,#000 calc(100% - ${G}),transparent 100%),radial-gradient(at bottom left,${K}),radial-gradient(at top left,${K});-webkit-mask-position:left,center,right top,right bottom;}.section--masked.section--justify-right{padding-left:${E};margin-left:calc(-1 * ${E});-webkit-mask-image:${nt},linear-gradient(to left,#000 0,#000 calc(100% - ${G}),transparent 100%),radial-gradient(at bottom right,${K}),radial-gradient(at top right,${K});-webkit-mask-position:right,center,left top,left bottom;}.section__exiting{position:absolute !important;z-index:-1;}.digit{display:inline-block;position:relative;}.digit__stack{display:flex;flex-direction:column;align-items:center;gap:${g};position:absolute;width:100%;}.digit__stack > *{display:inline-block;}.digit__lt{bottom:calc(100% + ${g});}.digit__gt{top:calc(100% + ${g});}.symbol{display:inline-block;position:relative;isolation:isolate;}.symbol__value{display:inline-block;white-space:pre;}.symbol__exiting{position:absolute;z-index:-1;}.section--justify-left .symbol__exiting{left:0;}.section--justify-right .symbol__exiting{right:0;}`;function Ut(n,i,t=60){const s=Math.trunc(n/1e3*t);return Array.from({length:s},(e,a)=>i(a/(s-1)))}function Mt(n,i,t=60){if(ht)return[i(0),i(1)];const s=Math.max(Math.trunc(n/1e3*t),0),e=Array.from({length:s},(a,l)=>({...i(l/s),offset:(l+.5)/s}));return e.unshift({...i(0),offset:0}),e}const at=(n,i,t)=>n+(i-n)*t,pt=900,ut=[0,.0050235113985758065,.018768235438646315,.0394665067267097,.06561435806809059,.09593671402266707,.12935688367555642,.16496984329827014,.2020188582086,.2398750451603972,.2780195227408494,.316027838175776,.35355639522427323,.3903306400002338,.42613479005042487,.4608029172568362,.494211217479539,.5262713196397582,.5569245044497536,.5861367184830215,.6138942829733466,.6402002088371546,.6650710401106178,.688534157441182,.7106254816148533,.7313875244620506,.7508677409782638,.7691171422207626,.7861891335875677,.8021385475282429,.8170208436473976,.830891452602792,.8438052432253264,.8558160949464902,.8669765599529741,.8773376015362415,.8869483969005642,.8958561942662493,.9041062154819053,.9117415965639958,.9188033596342844,.9253304106443357,.9313595580771787,.9369255485137984,.9420611155589194,.9467970391476751,.9511622127120402,.9551837160819846,.9588868923388109,.9622954271337615,.9654314292396703,.9683155113223428,.9709668701061009,.9734033652684989,.9756415965361696,.9776969785701735,.9795838133278193,.9813153596710892,.9829039000616127,.9843608042404175,.985696589839041,.986920979908387,.9880429573842098,.989070816534304,.990012211453356,.9908742016877166,.9916632950848158,.9923854879711473,.9930463027692117,.9936508231680027,.994203726963899,.9947093166895601,.9951715481478591,.9955940569663103,.9959801832850321,.9963329946882337,.9966553074856583,.9969497064465007,.9972185630841328,.9974640525856172,.9976881694755444,.9978927420992383,.9980794460059083,.998249816307907,.9984052590879293,.998547061921768,.9986764035801687,.9987943629693811,.9989019273662413,1],mt=900,gt=[.32,.72,0,1],yt={duration:500,easing:"ease-out"},tt=ct?{duration:pt,easing:`linear(${ut.join(",")})`}:{duration:mt,easing:`cubic-bezier(${gt.join(",")})`},wt=tt;let q;var U,_,S,k,C;class At extends jt{constructor(){super(...arguments);u(this,"xTiming",tt);u(this,"yTiming",wt);u(this,"fadeTiming",yt);u(this,"root",!1);u(this,"manual",!1);r(this,U,!1);r(this,_);r(this,S);r(this,k);r(this,C)}static define(){V.BROWSER&&customElements.define("number-flow",this)}set parts(t){if(t==null)return;const{pre:s,integer:e,fraction:a,post:l}=t;if(o(this,U))this.manual||this.willUpdate(),o(this,_).update(s),o(this,S).update(e),o(this,k).update(a),o(this,C).update(l),this.manual||this.didUpdate();else{if(this.attachShadow({mode:"open"}),typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)q||(q=new CSSStyleSheet,q.replaceSync(ot)),this.shadowRoot.adoptedStyleSheets=[q];else{const f=document.createElement("style");f.textContent=ot,this.shadowRoot.appendChild(f)}this.shadowRoot.appendChild(y("slot")),h(this,_,new rt(this,s,{inert:!0,ariaHidden:"true",justify:"right"})),this.shadowRoot.appendChild(o(this,_).el),h(this,S,new lt(this,e,{inert:!0,ariaHidden:"true",justify:"right"})),this.shadowRoot.appendChild(o(this,S).el),h(this,k,new lt(this,a,{inert:!0,ariaHidden:"true",justify:"left"})),this.shadowRoot.appendChild(o(this,k).el),h(this,C,new rt(this,l,{inert:!0,ariaHidden:"true",justify:"left"})),this.shadowRoot.appendChild(o(this,C).el)}h(this,U,!0)}willUpdate(){const t=this.root?this.getBoundingClientRect():new DOMRect;o(this,_).willUpdate(t),o(this,S).willUpdate(t),o(this,k).willUpdate(t),o(this,C).willUpdate(t)}didUpdate(){const t=this.root?this.getBoundingClientRect():new DOMRect;o(this,_).didUpdate(t),o(this,S).didUpdate(t),o(this,k).didUpdate(t),o(this,C).didUpdate(t)}}U=new WeakMap,_=new WeakMap,S=new WeakMap,k=new WeakMap,C=new WeakMap;class bt{constructor(i,t,{justify:s,className:e,...a},l){u(this,"flow");u(this,"el");u(this,"justify");u(this,"children",new Map);u(this,"onCharRemove",i=>()=>{this.children.delete(i)});this.flow=i,this.justify=s;const f=t.map(c=>this.addChar(c).el);f.push(document.createTextNode("​")),this.el=y("span",{...a,className:`section section--justify-${s} ${e??""}`},l?l(f):f)}addChar(i,{startDigitsAtZero:t=!1,...s}={}){const e=i.type==="integer"||i.type==="fraction"?new _t(this,i.type,t?0:i.value,{...s,onRemove:this.onCharRemove(i.key)}):new Bt(this,i.type,i.value,{...s,onRemove:this.onCharRemove(i.key)});return this.children.set(i.key,e),e}unpop(i){i.el.classList.remove("section__exiting"),i.el.style[this.justify]=""}pop(i){i.forEach(t=>{t.el.style[this.justify]=`${vt(t.el,this.justify)}px`}),i.forEach(t=>{t.el.classList.add("section__exiting"),t.present=!1})}addNewAndUpdateExisting(i,t=this.el){const s=new Map,e=new Map,a=this.justify==="left",l=a?"prepend":"append";$t(i,c=>{let d;this.children.has(c.key)?(d=this.children.get(c.key),e.set(c,d),this.unpop(d),d.present=!0):(d=this.addChar(c,{startDigitsAtZero:!0,animateIn:!0}),s.set(c,d)),t[l](d.el)},{reverse:a});const f=t.getBoundingClientRect();s.forEach(c=>{c.willUpdate(f)}),s.forEach((c,d)=>{c.update(d.value)}),e.forEach((c,d)=>{c.update(d.value)})}}var v,M,A,B,L,N;class lt extends bt{constructor(t,s,{className:e,...a}){let l;super(t,s,{...a,className:`${e??""} section--masked`},f=>[l=y("span",{className:"section__inner"},f)]);r(this,v);r(this,M);r(this,A);r(this,B);r(this,L);r(this,N);h(this,v,l)}willUpdate(t){const s=this.el.getBoundingClientRect();h(this,M,s.width),h(this,A,s[this.justify]-t[this.justify]);const e=o(this,v).getBoundingClientRect();this.children.forEach(a=>a.willUpdate(e))}update(t){const s=new Map;this.children.forEach((e,a)=>{t.find(l=>l.key===a)||s.set(a,e),this.unpop(e)}),this.addNewAndUpdateExisting(t,o(this,v)),s.forEach(e=>{e instanceof _t&&e.update(0)}),this.pop(s)}didUpdate(t){var c,d,b,T;(c=o(this,B))==null||c.cancel(),(d=o(this,N))==null||d.cancel(),(b=o(this,L))==null||b.cancel();const s=this.el.getBoundingClientRect(),e=s[this.justify]-t[this.justify],a=o(this,A)-e,l=Math.max(o(this,M),.01)/Math.max(s.width,.01),f=o(this,v).getBoundingClientRect();this.children.forEach(x=>x.didUpdate(f)),h(this,B,this.el.animate({transform:[`translateX(${a}px) scaleX(${l})`,"none"]},this.flow.xTiming)),l!==1&&(h(this,N,(T=o(this,v))==null?void 0:T.animate({transform:Ut(1e3,x=>`scaleX(${1/at(l,1,x)})`)},this.flow.xTiming)),h(this,L,this.el.animate(Mt(1e3,x=>({"--_number-flow-scale-x":at(l,1,x)})),this.flow.xTiming)))}}v=new WeakMap,M=new WeakMap,A=new WeakMap,B=new WeakMap,L=new WeakMap,N=new WeakMap;var P,X;class rt extends bt{constructor(){super(...arguments);r(this,P);r(this,X)}willUpdate(t){const s=this.el.getBoundingClientRect();h(this,P,s[this.justify]-t[this.justify]),this.children.forEach(e=>e.willUpdate(s))}update(t){const s=new Map;this.children.forEach((e,a)=>{t.find(l=>l.key===a)||s.set(a,e)}),this.pop(s),this.addNewAndUpdateExisting(t)}didUpdate(t){var a;(a=o(this,X))==null||a.cancel();const s=this.el.getBoundingClientRect(),e=s[this.justify]-t[this.justify];this.children.forEach(l=>l.didUpdate(s)),h(this,X,this.el.animate({transform:[`translateX(${o(this,P)-e}px)`,"none"]},this.flow.xTiming))}}P=new WeakMap,X=new WeakMap;var R,W,j;class Q{constructor(i,t,{onRemove:s,animateIn:e=!1}={}){u(this,"flow");u(this,"el");r(this,R,!0);r(this,W);r(this,j);this.flow=i,this.el=t,e&&this.el.animate({opacity:["0","1"]},i.fadeTiming),h(this,W,s)}get present(){return o(this,R)}set present(i){var s;if(o(this,R)===i)return;const t=getComputedStyle(this.el).getPropertyValue("opacity");(s=o(this,j))==null||s.cancel(),h(this,j,this.el.animate({opacity:[t,i?"1":"0"]},this.flow.fadeTiming)),i||(o(this,j).onfinish=()=>{var e;this.el.remove(),(e=o(this,W))==null||e.call(this)}),h(this,R,i)}}R=new WeakMap,W=new WeakMap,j=new WeakMap;class xt extends Q{constructor(t,s,e,a){super(t.flow,e,a);u(this,"section");u(this,"value");u(this,"el");this.section=t,this.value=s,this.el=e}}var $,H,O,D,F;class _t extends xt{constructor(t,s,e,a){super(t,e,y("span",{className:"digit",textContent:e+""}),a);r(this,$);r(this,H);r(this,O);r(this,D);r(this,F)}willUpdate(t){h(this,$,this.value);const s=this.el.getBoundingClientRect();h(this,H,s.y-t.y);const e=s[this.section.justify]-t[this.section.justify],a=s.width/2;h(this,O,this.section.justify==="left"?e+a:e-a)}update(t){this.value=t,o(this,$)!==t&&Ct(this.el,[...t===0?[]:[y("span",{className:"digit__stack digit__lt"},Array.from({length:t},(s,e)=>y("span",{textContent:e+""})))],document.createTextNode(t+""),...t===9?[]:[y("span",{className:"digit__stack digit__gt"},Array.from({length:9-t},(s,e)=>y("span",{textContent:t+e+1+""})))]])}didUpdate(t){var d,b;(d=o(this,D))==null||d.cancel(),o(this,$)!==this.value&&((b=o(this,F))==null||b.cancel());const s=this.el.getBoundingClientRect(),e=s[this.section.justify]-t[this.section.justify],a=s.width/2,l=this.section.justify==="left"?e+a:e-a,f=`translateX(${o(this,O)-l}px)`,c=`translateY(calc((100% + ${g}) * ${this.value-o(this,$)} + ${o(this,H)}px))`;h(this,D,this.el.animate({transform:[J?f:`${f} ${c}`,"none"]},{...this.flow.xTiming,composite:"accumulate"})),J&&o(this,$)!==this.value&&h(this,F,this.el.animate({transform:[c,"none"]},{...this.flow.yTiming,composite:"accumulate"}))}}$=new WeakMap,H=new WeakMap,O=new WeakMap,D=new WeakMap,F=new WeakMap;var w,z,I,Y;class Bt extends xt{constructor(t,s,e,a){const l=y("span",{className:"symbol__value",textContent:e});super(t,e,y("span",{className:"symbol"},[l]),a);u(this,"type");r(this,w,new Map);r(this,z);r(this,I,t=>()=>{o(this,w).delete(t)});r(this,Y);this.type=s,o(this,w).set(e,new Q(this.flow,l,{onRemove:o(this,I).call(this,e)}))}willUpdate(t){if(this.type==="decimal")return;const s=this.el.getBoundingClientRect();h(this,z,s[this.section.justify]-t[this.section.justify])}update(t){if(this.value!==t){const s=o(this,w).get(this.value);if(s.present=!1,s.el.classList.add("symbol__exiting"),o(this,w).has(t)){const e=o(this,w).get(t);e.present=!0,e.el.classList.remove("symbol__exiting")}else{const e=y("span",{className:"symbol__value",textContent:t});this.el.appendChild(e),o(this,w).set(t,new Q(this.flow,e,{animateIn:!0,onRemove:o(this,I).call(this,t)}))}}this.value=t}didUpdate(t){var a;if(this.type==="decimal")return;(a=o(this,Y))==null||a.cancel();const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify];h(this,Y,this.el.animate({transform:[`translateX(${o(this,z)-e}px)`,"none"]},this.flow.xTiming))}}w=new WeakMap,z=new WeakMap,I=new WeakMap,Y=new WeakMap;exports.NumberFlowLite=At;exports.SlottedTag=ft;exports.defaultFadeTiming=yt;exports.defaultXTiming=tt;exports.defaultXTimingFallbackDuration=mt;exports.defaultXTimingFallbackPoints=gt;exports.defaultXTimingLinearDuration=pt;exports.defaultXTimingLinearPoints=ut;exports.defaultYTiming=wt;exports.partitionParts=Rt;exports.slottedStyles=Et;exports.supportsAnimationComposition=J;exports.supportsLinear=ct;
@@ -0,0 +1,23 @@
1
+ import { type PartitionedParts } from './formatter';
2
+ import { ServerSafeHTMLElement } from './ssr';
3
+ export { SlottedTag, slottedStyles, supportsAnimationComposition, supportsLinear } from './styles';
4
+ export * from './formatter';
5
+ export declare const defaultXTimingLinearDuration = 900;
6
+ export declare const defaultXTimingLinearPoints: number[];
7
+ export declare const defaultXTimingFallbackDuration = 900;
8
+ export declare const defaultXTimingFallbackPoints: number[];
9
+ export declare const defaultFadeTiming: EffectTiming;
10
+ export declare const defaultXTiming: EffectTiming;
11
+ export declare const defaultYTiming: EffectTiming;
12
+ export declare class NumberFlowLite extends ServerSafeHTMLElement {
13
+ #private;
14
+ static define(): void;
15
+ xTiming: EffectTiming;
16
+ yTiming: EffectTiming;
17
+ fadeTiming: EffectTiming;
18
+ root: boolean;
19
+ manual: boolean;
20
+ set parts(newVal: PartitionedParts | undefined);
21
+ willUpdate(): void;
22
+ didUpdate(): void;
23
+ }
package/dist/index.js ADDED
@@ -0,0 +1,439 @@
1
+ var ut = Object.defineProperty;
2
+ var Q = (n) => {
3
+ throw TypeError(n);
4
+ };
5
+ var mt = (n, i, t) => i in n ? ut(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t;
6
+ var u = (n, i, t) => mt(n, typeof i != "symbol" ? i + "" : i, t), tt = (n, i, t) => i.has(n) || Q("Cannot " + t);
7
+ var o = (n, i, t) => (tt(n, i, "read from private field"), t ? t.call(n) : i.get(n)), r = (n, i, t) => i.has(n) ? Q("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(n) : i.set(n, t), h = (n, i, t, s) => (tt(n, i, "write to private field"), s ? s.call(n, t) : i.set(n, t), t);
8
+ import { BROWSER as Y } from "esm-env";
9
+ const y = (n, i, t) => {
10
+ const s = document.createElement(n), [e, a] = Array.isArray(i) ? [void 0, i] : [i, t];
11
+ return e && Object.assign(s, e), a == null || a.forEach((l) => s.appendChild(l)), s;
12
+ }, gt = (n, i) => {
13
+ typeof Element.prototype.replaceChildren > "u" ? (n.innerHTML = "", i.forEach((t) => n.appendChild(t))) : n.replaceChildren(...i);
14
+ }, yt = (n, i) => {
15
+ var t;
16
+ return i === "left" ? n.offsetLeft : (((t = n.offsetParent instanceof HTMLElement ? n.offsetParent : null) == null ? void 0 : t.offsetWidth) ?? 0) - n.offsetWidth - n.offsetLeft;
17
+ };
18
+ function wt(n, i, { reverse: t = !1 } = {}) {
19
+ const s = n.length;
20
+ for (let e = t ? s - 1 : 0; t ? e >= 0 : e < s; t ? e-- : e++)
21
+ i(n[e], e);
22
+ }
23
+ function Nt(n, i) {
24
+ const t = i.formatToParts(n), s = [], e = [], a = [], l = [], f = {}, c = (p) => (f[p] || (f[p] = 0), `${p}:${f[p]++}`);
25
+ let d = "", x = !1, U = !1;
26
+ for (const p of t) {
27
+ d += p.value;
28
+ const m = p.type === "minusSign" || p.type === "plusSign" ? "sign" : p.type;
29
+ m === "integer" ? (x = !0, e.push(...p.value.split("").map((q) => ({ type: m, value: parseInt(q) })))) : m === "group" ? e.push({ type: m, value: p.value }) : m === "decimal" ? (U = !0, a.push({ type: m, value: p.value, key: c(m) })) : m === "fraction" ? a.push(...p.value.split("").map((q) => ({ type: m, value: parseInt(q), key: c(m) }))) : (x || U ? l : s).push({
30
+ type: m,
31
+ value: p.value,
32
+ key: c(m)
33
+ });
34
+ }
35
+ const _ = [];
36
+ for (let p = e.length - 1; p >= 0; p--)
37
+ _.unshift({ ...e[p], key: c(e[p].type) });
38
+ return { pre: s, integer: _, fraction: a, post: l, formatted: d };
39
+ }
40
+ const xt = Y ? HTMLElement : class {
41
+ }, _t = String.raw, bt = Y && typeof CSS < "u" && CSS.supports("transition-timing-function", "linear(1, 2)"), rt = Y && typeof CSS < "u" && typeof CSS.registerProperty < "u", et = Y && typeof CSS < "u" && typeof CSS.supports("animation-composition", "accumulate") < "u";
42
+ if (rt)
43
+ try {
44
+ CSS.registerProperty({
45
+ name: "--_number-flow-scale-x",
46
+ syntax: "<number>",
47
+ inherits: !1,
48
+ initialValue: "1"
49
+ });
50
+ } catch {
51
+ }
52
+ const ct = "var(--number-flow-char-height, 1em)", g = "var(--number-flow-mask-height, 0.15em)", E = "var(--number-flow-mask-width, 0.5em)", Z = `${E} * 1/var(--_number-flow-scale-x)`, it = `calc(${Z})`, st = `linear-gradient(to bottom, transparent 0, #000 ${g}, #000 calc(100% - ${g}), transparent 100%)`, K = "#000 0, transparent 71%", kt = "span", Bt = {
53
+ fontKerning: "none",
54
+ display: "inline-block",
55
+ lineHeight: ct,
56
+ padding: `${g} 0`
57
+ }, nt = _t`:host{display:inline-block;direction:ltr;user-select:none;pointer-events:none;white-space:nowrap;position:relative;line-height:${ct} !important;isolation:isolate;}::slotted(${kt}){position:absolute;left:0;top:0;color:transparent !important;z-index:-1;user-select:text;pointer-events:auto;}.section{display:inline-block;padding-bottom:${g};padding-top:${g};vertical-align:top;user-select:none;}.section:not(.section--masked),.section--masked .section__inner{position:relative;isolation:isolate;}.section__inner{display:inline-block;transform-origin:inherit;}.section--justify-left{transform-origin:center left;}.section--justify-right{transform-origin:center right;}.section--masked{overflow:clip;position:relative;z-index:-1;--_number-flow-scale-x:1;-webkit-mask-repeat:no-repeat;-webkit-mask-size:calc(100% - ${Z}) 100%,100% calc(100% - ${g} * 2),${it} ${g},${it} ${g};}.section--masked.section--justify-left{padding-right:${E};margin-right:calc(-1 * ${E});-webkit-mask-image:${st},linear-gradient(to right,#000 0,#000 calc(100% - ${Z}),transparent 100%),radial-gradient(at bottom left,${K}),radial-gradient(at top left,${K});-webkit-mask-position:left,center,right top,right bottom;}.section--masked.section--justify-right{padding-left:${E};margin-left:calc(-1 * ${E});-webkit-mask-image:${st},linear-gradient(to left,#000 0,#000 calc(100% - ${Z}),transparent 100%),radial-gradient(at bottom right,${K}),radial-gradient(at top right,${K});-webkit-mask-position:right,center,left top,left bottom;}.section__exiting{position:absolute !important;z-index:-1;}.digit{display:inline-block;position:relative;}.digit__stack{display:flex;flex-direction:column;align-items:center;gap:${g};position:absolute;width:100%;}.digit__stack > *{display:inline-block;}.digit__lt{bottom:calc(100% + ${g});}.digit__gt{top:calc(100% + ${g});}.symbol{display:inline-block;position:relative;isolation:isolate;}.symbol__value{display:inline-block;white-space:pre;}.symbol__exiting{position:absolute;z-index:-1;}.section--justify-left .symbol__exiting{left:0;}.section--justify-right .symbol__exiting{right:0;}`;
58
+ function Ct(n, i, t = 60) {
59
+ const s = Math.trunc(n / 1e3 * t);
60
+ return Array.from({ length: s }, (e, a) => i(a / (s - 1)));
61
+ }
62
+ function $t(n, i, t = 60) {
63
+ if (rt)
64
+ return [i(0), i(1)];
65
+ const s = Math.max(Math.trunc(n / 1e3 * t), 0), e = Array.from({ length: s }, (a, l) => ({
66
+ ...i(l / s),
67
+ offset: (l + 0.5) / s
68
+ }));
69
+ return e.unshift({
70
+ ...i(0),
71
+ offset: 0
72
+ }), e;
73
+ }
74
+ const ot = (n, i, t) => n + (i - n) * t, vt = 900, St = [0, 0.0050235113985758065, 0.018768235438646315, 0.0394665067267097, 0.06561435806809059, 0.09593671402266707, 0.12935688367555642, 0.16496984329827014, 0.2020188582086, 0.2398750451603972, 0.2780195227408494, 0.316027838175776, 0.35355639522427323, 0.3903306400002338, 0.42613479005042487, 0.4608029172568362, 0.494211217479539, 0.5262713196397582, 0.5569245044497536, 0.5861367184830215, 0.6138942829733466, 0.6402002088371546, 0.6650710401106178, 0.688534157441182, 0.7106254816148533, 0.7313875244620506, 0.7508677409782638, 0.7691171422207626, 0.7861891335875677, 0.8021385475282429, 0.8170208436473976, 0.830891452602792, 0.8438052432253264, 0.8558160949464902, 0.8669765599529741, 0.8773376015362415, 0.8869483969005642, 0.8958561942662493, 0.9041062154819053, 0.9117415965639958, 0.9188033596342844, 0.9253304106443357, 0.9313595580771787, 0.9369255485137984, 0.9420611155589194, 0.9467970391476751, 0.9511622127120402, 0.9551837160819846, 0.9588868923388109, 0.9622954271337615, 0.9654314292396703, 0.9683155113223428, 0.9709668701061009, 0.9734033652684989, 0.9756415965361696, 0.9776969785701735, 0.9795838133278193, 0.9813153596710892, 0.9829039000616127, 0.9843608042404175, 0.985696589839041, 0.986920979908387, 0.9880429573842098, 0.989070816534304, 0.990012211453356, 0.9908742016877166, 0.9916632950848158, 0.9923854879711473, 0.9930463027692117, 0.9936508231680027, 0.994203726963899, 0.9947093166895601, 0.9951715481478591, 0.9955940569663103, 0.9959801832850321, 0.9963329946882337, 0.9966553074856583, 0.9969497064465007, 0.9972185630841328, 0.9974640525856172, 0.9976881694755444, 0.9978927420992383, 0.9980794460059083, 0.998249816307907, 0.9984052590879293, 0.998547061921768, 0.9986764035801687, 0.9987943629693811, 0.9989019273662413, 1], jt = 900, Rt = [0.32, 0.72, 0, 1], Ut = { duration: 500, easing: "ease-out" }, ht = bt ? {
75
+ duration: vt,
76
+ easing: `linear(${St.join(",")})`
77
+ } : {
78
+ duration: jt,
79
+ // Spring-like cubic-bezier stolen from Vaul: https://vaul.emilkowal.ski/
80
+ easing: `cubic-bezier(${Rt.join(",")})`
81
+ }, Et = ht;
82
+ let G;
83
+ var T, b, k, C, $;
84
+ class Lt extends xt {
85
+ constructor() {
86
+ super(...arguments);
87
+ u(this, "xTiming", ht);
88
+ u(this, "yTiming", Et);
89
+ u(this, "fadeTiming", Ut);
90
+ u(this, "root", !1);
91
+ u(this, "manual", !1);
92
+ r(this, T, !1);
93
+ r(this, b);
94
+ r(this, k);
95
+ r(this, C);
96
+ r(this, $);
97
+ }
98
+ static define() {
99
+ Y && customElements.define("number-flow", this);
100
+ }
101
+ set parts(t) {
102
+ if (t == null)
103
+ return;
104
+ const { pre: s, integer: e, fraction: a, post: l } = t;
105
+ if (o(this, T))
106
+ this.manual || this.willUpdate(), o(this, b).update(s), o(this, k).update(e), o(this, C).update(a), o(this, $).update(l), this.manual || this.didUpdate();
107
+ else {
108
+ if (this.attachShadow({ mode: "open" }), typeof CSSStyleSheet < "u" && this.shadowRoot.adoptedStyleSheets)
109
+ G || (G = new CSSStyleSheet(), G.replaceSync(nt)), this.shadowRoot.adoptedStyleSheets = [G];
110
+ else {
111
+ const f = document.createElement("style");
112
+ f.textContent = nt, this.shadowRoot.appendChild(f);
113
+ }
114
+ this.shadowRoot.appendChild(y("slot")), h(this, b, new lt(this, s, {
115
+ // part: 'pre',
116
+ inert: !0,
117
+ ariaHidden: "true",
118
+ justify: "right"
119
+ })), this.shadowRoot.appendChild(o(this, b).el), h(this, k, new at(this, e, {
120
+ // part: 'integer',
121
+ inert: !0,
122
+ ariaHidden: "true",
123
+ justify: "right"
124
+ })), this.shadowRoot.appendChild(o(this, k).el), h(this, C, new at(this, a, {
125
+ // part: 'fraction',
126
+ inert: !0,
127
+ ariaHidden: "true",
128
+ justify: "left"
129
+ })), this.shadowRoot.appendChild(o(this, C).el), h(this, $, new lt(this, l, {
130
+ // part: 'post',
131
+ inert: !0,
132
+ ariaHidden: "true",
133
+ justify: "left"
134
+ })), this.shadowRoot.appendChild(o(this, $).el);
135
+ }
136
+ h(this, T, !0);
137
+ }
138
+ willUpdate() {
139
+ const t = this.root ? this.getBoundingClientRect() : new DOMRect();
140
+ o(this, b).willUpdate(t), o(this, k).willUpdate(t), o(this, C).willUpdate(t), o(this, $).willUpdate(t);
141
+ }
142
+ didUpdate() {
143
+ const t = this.root ? this.getBoundingClientRect() : new DOMRect();
144
+ o(this, b).didUpdate(t), o(this, k).didUpdate(t), o(this, C).didUpdate(t), o(this, $).didUpdate(t);
145
+ }
146
+ }
147
+ T = new WeakMap(), b = new WeakMap(), k = new WeakMap(), C = new WeakMap(), $ = new WeakMap();
148
+ class dt {
149
+ constructor(i, t, { justify: s, className: e, ...a }, l) {
150
+ u(this, "flow");
151
+ u(this, "el");
152
+ u(this, "justify");
153
+ // All children in the DOM:
154
+ u(this, "children", /* @__PURE__ */ new Map());
155
+ u(this, "onCharRemove", (i) => () => {
156
+ this.children.delete(i);
157
+ });
158
+ this.flow = i, this.justify = s;
159
+ const f = t.map((c) => this.addChar(c).el);
160
+ f.push(document.createTextNode("​")), this.el = y("span", {
161
+ ...a,
162
+ className: `section section--justify-${s} ${e ?? ""}`
163
+ }, l ? l(f) : f);
164
+ }
165
+ addChar(i, { startDigitsAtZero: t = !1, ...s } = {}) {
166
+ const e = i.type === "integer" || i.type === "fraction" ? new pt(this, i.type, t ? 0 : i.value, {
167
+ ...s,
168
+ onRemove: this.onCharRemove(i.key)
169
+ }) : new Tt(this, i.type, i.value, {
170
+ ...s,
171
+ onRemove: this.onCharRemove(i.key)
172
+ });
173
+ return this.children.set(i.key, e), e;
174
+ }
175
+ unpop(i) {
176
+ i.el.classList.remove("section__exiting"), i.el.style[this.justify] = "";
177
+ }
178
+ pop(i) {
179
+ i.forEach((t) => {
180
+ t.el.style[this.justify] = `${yt(t.el, this.justify)}px`;
181
+ }), i.forEach((t) => {
182
+ t.el.classList.add("section__exiting"), t.present = !1;
183
+ });
184
+ }
185
+ addNewAndUpdateExisting(i, t = this.el) {
186
+ const s = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), a = this.justify === "left", l = a ? "prepend" : "append";
187
+ wt(i, (c) => {
188
+ let d;
189
+ this.children.has(c.key) ? (d = this.children.get(c.key), e.set(c, d), this.unpop(d), d.present = !0) : (d = this.addChar(c, { startDigitsAtZero: !0, animateIn: !0 }), s.set(c, d)), t[l](d.el);
190
+ }, { reverse: a });
191
+ const f = t.getBoundingClientRect();
192
+ s.forEach((c) => {
193
+ c.willUpdate(f);
194
+ }), s.forEach((c, d) => {
195
+ c.update(d.value);
196
+ }), e.forEach((c, d) => {
197
+ c.update(d.value);
198
+ });
199
+ }
200
+ }
201
+ var v, M, A, N, B, L;
202
+ class at extends dt {
203
+ constructor(t, s, { className: e, ...a }) {
204
+ let l;
205
+ super(t, s, {
206
+ ...a,
207
+ className: `${e ?? ""} section--masked`
208
+ }, (f) => [
209
+ l = y("span", {
210
+ className: "section__inner"
211
+ }, f)
212
+ ]);
213
+ r(this, v);
214
+ r(this, M);
215
+ r(this, A);
216
+ r(this, N);
217
+ r(this, B);
218
+ r(this, L);
219
+ h(this, v, l);
220
+ }
221
+ willUpdate(t) {
222
+ const s = this.el.getBoundingClientRect();
223
+ h(this, M, s.width), h(this, A, s[this.justify] - t[this.justify]);
224
+ const e = o(this, v).getBoundingClientRect();
225
+ this.children.forEach((a) => a.willUpdate(e));
226
+ }
227
+ update(t) {
228
+ const s = /* @__PURE__ */ new Map();
229
+ this.children.forEach((e, a) => {
230
+ t.find((l) => l.key === a) || s.set(a, e), this.unpop(e);
231
+ }), this.addNewAndUpdateExisting(t, o(this, v)), s.forEach((e) => {
232
+ e instanceof pt && e.update(0);
233
+ }), this.pop(s);
234
+ }
235
+ didUpdate(t) {
236
+ var c, d, x, U;
237
+ (c = o(this, N)) == null || c.cancel(), (d = o(this, L)) == null || d.cancel(), (x = o(this, B)) == null || x.cancel();
238
+ const s = this.el.getBoundingClientRect(), e = s[this.justify] - t[this.justify], a = o(this, A) - e, l = Math.max(o(this, M), 0.01) / Math.max(s.width, 0.01), f = o(this, v).getBoundingClientRect();
239
+ this.children.forEach((_) => _.didUpdate(f)), h(this, N, this.el.animate({
240
+ transform: [`translateX(${a}px) scaleX(${l})`, "none"]
241
+ }, this.flow.xTiming)), l !== 1 && (h(this, L, (U = o(this, v)) == null ? void 0 : U.animate({
242
+ // 1/x isn't linear so we need to do sampling:
243
+ transform: Ct(1e3, (_) => `scaleX(${1 / ot(l, 1, _)})`)
244
+ }, this.flow.xTiming)), h(this, B, this.el.animate($t(1e3, (_) => ({
245
+ "--_number-flow-scale-x": ot(l, 1, _)
246
+ })), this.flow.xTiming)));
247
+ }
248
+ }
249
+ v = new WeakMap(), M = new WeakMap(), A = new WeakMap(), N = new WeakMap(), B = new WeakMap(), L = new WeakMap();
250
+ var P, H;
251
+ class lt extends dt {
252
+ constructor() {
253
+ super(...arguments);
254
+ r(this, P);
255
+ r(this, H);
256
+ }
257
+ willUpdate(t) {
258
+ const s = this.el.getBoundingClientRect();
259
+ h(this, P, s[this.justify] - t[this.justify]), this.children.forEach((e) => e.willUpdate(s));
260
+ }
261
+ update(t) {
262
+ const s = /* @__PURE__ */ new Map();
263
+ this.children.forEach((e, a) => {
264
+ t.find((l) => l.key === a) || s.set(a, e);
265
+ }), this.pop(s), this.addNewAndUpdateExisting(t);
266
+ }
267
+ didUpdate(t) {
268
+ var a;
269
+ (a = o(this, H)) == null || a.cancel();
270
+ const s = this.el.getBoundingClientRect(), e = s[this.justify] - t[this.justify];
271
+ this.children.forEach((l) => l.didUpdate(s)), h(this, H, this.el.animate({
272
+ transform: [`translateX(${o(this, P) - e}px)`, "none"]
273
+ }, this.flow.xTiming));
274
+ }
275
+ }
276
+ P = new WeakMap(), H = new WeakMap();
277
+ var j, X, R;
278
+ class J {
279
+ constructor(i, t, { onRemove: s, animateIn: e = !1 } = {}) {
280
+ u(this, "flow");
281
+ u(this, "el");
282
+ r(this, j, !0);
283
+ r(this, X);
284
+ r(this, R);
285
+ this.flow = i, this.el = t, e && this.el.animate({
286
+ opacity: ["0", "1"]
287
+ }, i.fadeTiming), h(this, X, s);
288
+ }
289
+ get present() {
290
+ return o(this, j);
291
+ }
292
+ set present(i) {
293
+ var s;
294
+ if (o(this, j) === i)
295
+ return;
296
+ const t = getComputedStyle(this.el).getPropertyValue("opacity");
297
+ (s = o(this, R)) == null || s.cancel(), h(this, R, this.el.animate({
298
+ opacity: [t, i ? "1" : "0"]
299
+ }, this.flow.fadeTiming)), i || (o(this, R).onfinish = () => {
300
+ var e;
301
+ this.el.remove(), (e = o(this, X)) == null || e.call(this);
302
+ }), h(this, j, i);
303
+ }
304
+ }
305
+ j = new WeakMap(), X = new WeakMap(), R = new WeakMap();
306
+ class ft extends J {
307
+ constructor(t, s, e, a) {
308
+ super(t.flow, e, a);
309
+ u(this, "section");
310
+ u(this, "value");
311
+ u(this, "el");
312
+ this.section = t, this.value = s, this.el = e;
313
+ }
314
+ }
315
+ var S, W, D, z, O;
316
+ class pt extends ft {
317
+ constructor(t, s, e, a) {
318
+ super(t, e, y("span", {
319
+ className: "digit",
320
+ // part: `digit ${type} ${value}`,
321
+ textContent: e + ""
322
+ }), a);
323
+ r(this, S);
324
+ // Relative to parent:
325
+ r(this, W);
326
+ r(this, D);
327
+ r(this, z);
328
+ r(this, O);
329
+ }
330
+ willUpdate(t) {
331
+ h(this, S, this.value);
332
+ const s = this.el.getBoundingClientRect();
333
+ h(this, W, s.y - t.y);
334
+ const e = s[this.section.justify] - t[this.section.justify], a = s.width / 2;
335
+ h(this, D, this.section.justify === "left" ? e + a : e - a);
336
+ }
337
+ update(t) {
338
+ this.value = t, o(this, S) !== t && gt(this.el, [
339
+ ...t === 0 ? [] : [
340
+ y("span", { className: "digit__stack digit__lt" }, Array.from({ length: t }, (s, e) => y("span", { textContent: e + "" })))
341
+ ],
342
+ document.createTextNode(t + ""),
343
+ ...t === 9 ? [] : [
344
+ y("span", { className: "digit__stack digit__gt" }, Array.from({ length: 9 - t }, (s, e) => y("span", { textContent: t + e + 1 + "" })))
345
+ ]
346
+ ]);
347
+ }
348
+ didUpdate(t) {
349
+ var d, x;
350
+ (d = o(this, z)) == null || d.cancel(), o(this, S) !== this.value && ((x = o(this, O)) == null || x.cancel());
351
+ const s = this.el.getBoundingClientRect(), e = s[this.section.justify] - t[this.section.justify], a = s.width / 2, l = this.section.justify === "left" ? e + a : e - a, f = `translateX(${o(this, D) - l}px)`, c = `translateY(calc((100% + ${g}) * ${this.value - o(this, S)} + ${o(this, W)}px))`;
352
+ h(this, z, this.el.animate({
353
+ transform: [et ? f : `${f} ${c}`, "none"]
354
+ }, {
355
+ ...this.flow.xTiming,
356
+ composite: "accumulate"
357
+ // in case there's an in-flight y animation
358
+ })), et && o(this, S) !== this.value && h(this, O, this.el.animate({
359
+ transform: [c, "none"]
360
+ }, {
361
+ ...this.flow.yTiming,
362
+ composite: "accumulate"
363
+ }));
364
+ }
365
+ }
366
+ S = new WeakMap(), W = new WeakMap(), D = new WeakMap(), z = new WeakMap(), O = new WeakMap();
367
+ var w, F, I, V;
368
+ class Tt extends ft {
369
+ constructor(t, s, e, a) {
370
+ const l = y("span", {
371
+ className: "symbol__value",
372
+ textContent: e
373
+ });
374
+ super(t, e, y("span", {
375
+ className: "symbol"
376
+ }, [l]), a);
377
+ u(this, "type");
378
+ r(this, w, /* @__PURE__ */ new Map());
379
+ r(this, F);
380
+ r(this, I, (t) => () => {
381
+ o(this, w).delete(t);
382
+ });
383
+ r(this, V);
384
+ this.type = s, o(this, w).set(e, new J(this.flow, l, {
385
+ onRemove: o(this, I).call(this, e)
386
+ }));
387
+ }
388
+ willUpdate(t) {
389
+ if (this.type === "decimal")
390
+ return;
391
+ const s = this.el.getBoundingClientRect();
392
+ h(this, F, s[this.section.justify] - t[this.section.justify]);
393
+ }
394
+ update(t) {
395
+ if (this.value !== t) {
396
+ const s = o(this, w).get(this.value);
397
+ if (s.present = !1, s.el.classList.add("symbol__exiting"), o(this, w).has(t)) {
398
+ const e = o(this, w).get(t);
399
+ e.present = !0, e.el.classList.remove("symbol__exiting");
400
+ } else {
401
+ const e = y("span", {
402
+ className: "symbol__value",
403
+ textContent: t
404
+ });
405
+ this.el.appendChild(e), o(this, w).set(t, new J(this.flow, e, {
406
+ animateIn: !0,
407
+ onRemove: o(this, I).call(this, t)
408
+ }));
409
+ }
410
+ }
411
+ this.value = t;
412
+ }
413
+ didUpdate(t) {
414
+ var a;
415
+ if (this.type === "decimal")
416
+ return;
417
+ (a = o(this, V)) == null || a.cancel();
418
+ const e = this.el.getBoundingClientRect()[this.section.justify] - t[this.section.justify];
419
+ h(this, V, this.el.animate({
420
+ transform: [`translateX(${o(this, F) - e}px)`, "none"]
421
+ }, this.flow.xTiming));
422
+ }
423
+ }
424
+ w = new WeakMap(), F = new WeakMap(), I = new WeakMap(), V = new WeakMap();
425
+ export {
426
+ Lt as NumberFlowLite,
427
+ kt as SlottedTag,
428
+ Ut as defaultFadeTiming,
429
+ ht as defaultXTiming,
430
+ jt as defaultXTimingFallbackDuration,
431
+ Rt as defaultXTimingFallbackPoints,
432
+ vt as defaultXTimingLinearDuration,
433
+ St as defaultXTimingLinearPoints,
434
+ Et as defaultYTiming,
435
+ Nt as partitionParts,
436
+ Bt as slottedStyles,
437
+ et as supportsAnimationComposition,
438
+ bt as supportsLinear
439
+ };
package/dist/ssr.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const ServerSafeHTMLElement: {
2
+ new (): HTMLElement;
3
+ prototype: HTMLElement;
4
+ };
@@ -0,0 +1,14 @@
1
+ export declare const supportsLinear: boolean;
2
+ export declare const supportsAtProperty: boolean;
3
+ export declare const supportsAnimationComposition: boolean;
4
+ export declare const charHeight = "var(--number-flow-char-height, 1em)";
5
+ export declare const maskHeight = "var(--number-flow-mask-height, 0.15em)";
6
+ export declare const SlottedTag = "span";
7
+ export declare const slottedStyles: {
8
+ readonly fontKerning: "none";
9
+ readonly display: "inline-block";
10
+ readonly lineHeight: "var(--number-flow-char-height, 1em)";
11
+ readonly padding: "var(--number-flow-mask-height, 0.15em) 0";
12
+ };
13
+ declare const styles: string;
14
+ export default styles;
@@ -0,0 +1,6 @@
1
+ export declare function frames<F extends string | (number | null)>(durationMs: number, frame: (t: number) => F, fps?: number): F[];
2
+ export type CustomPropertyKeyframes = {
3
+ [property: `--${string}`]: string | number | null | undefined;
4
+ };
5
+ export declare function customPropertyFrames(durationMs: number, frame: (t: number) => CustomPropertyKeyframes, fps?: number): CustomPropertyKeyframes[];
6
+ export declare const lerp: (min: number, max: number, weight: number) => number;
@@ -0,0 +1,3 @@
1
+ export declare const css: (template: {
2
+ raw: readonly string[] | ArrayLike<string>;
3
+ }, ...substitutions: any[]) => string;
@@ -0,0 +1,11 @@
1
+ type ExcludeReadonly<T> = {
2
+ -readonly [K in keyof T as T[K] extends Readonly<any> ? never : K]: T[K];
3
+ };
4
+ export type HTMLProps<K extends keyof HTMLElementTagNameMap> = Partial<ExcludeReadonly<HTMLElementTagNameMap[K]> & {
5
+ part: string;
6
+ }>;
7
+ export declare const createElement: <K extends keyof HTMLElementTagNameMap>(tagName: K, optionsOrChildren?: HTMLProps<K> | Node[], _children?: Node[]) => HTMLElementTagNameMap[K];
8
+ export declare const replaceChildren: (el: HTMLElement, children: Node[]) => void;
9
+ export type Justify = 'left' | 'right';
10
+ export declare const offset: (el: HTMLElement, justify: Justify) => number;
11
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare function forEach<T>(arr: T[], fn: (item: T, index: number) => void, { reverse }?: {
2
+ reverse?: boolean | undefined;
3
+ }): void;
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "number-flow",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "type": "module",
7
+ "version": "0.1.0",
8
+ "author": {
9
+ "name": "Maxwell Barvian",
10
+ "email": "max@barvian.me",
11
+ "url": "https://barvian.me"
12
+ },
13
+ "description": "A lightweight component to transition and format numbers.",
14
+ "license": "MIT",
15
+ "homepage": "https://number-flow.barvian.me/",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/barvian/number-flow",
19
+ "directory": "src"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/barvian/number-flow/issues"
23
+ },
24
+ "keywords": [
25
+ "accessible",
26
+ "odometer",
27
+ "animation",
28
+ "number-format",
29
+ "number-animation",
30
+ "animated-number"
31
+ ],
32
+ "files": [
33
+ "dist",
34
+ "README.md"
35
+ ],
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "default": "./dist/index.js",
40
+ "require": "./dist/index.cjs"
41
+ }
42
+ },
43
+ "devDependencies": {
44
+ "@rollup/plugin-typescript": "^12.1.0",
45
+ "babel-plugin-styled-components": "^2.1.4",
46
+ "magic-string": "^0.30.11",
47
+ "parse-literals": "^1.2.1",
48
+ "vite": "^5.4.3",
49
+ "typescript": "^5.6.2",
50
+ "tslib": "^2.7.0"
51
+ },
52
+ "dependencies": {
53
+ "esm-env": "^1.0.0"
54
+ },
55
+ "scripts": {
56
+ "build": "vite build --mode production",
57
+ "dev": "vite build --mode development --watch"
58
+ }
59
+ }