number-flow 0.5.0 → 0.5.1

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.
@@ -13,7 +13,7 @@ function B(n, t, { reverse: e = !1 } = {}) {
13
13
  for (let s = e ? i - 1 : 0; e ? s >= 0 : s < i; e ? s-- : s++)
14
14
  t(n[s], s);
15
15
  }
16
- const H = String.raw, T = String.raw, X = m && typeof CSS < "u" && CSS.supports && CSS.supports("animation-timing-function", "linear(1,2)"), F = m && typeof CSS < "u" && CSS.supports && CSS.supports("line-height", "mod(1,1)"), b = m && typeof matchMedia < "u" ? matchMedia("(prefers-reduced-motion: reduce)") : null, _ = "--_number-flow-d-opacity", E = "--_number-flow-d-width", w = "--_number-flow-dx", k = "--_number-flow-d", O = (() => {
16
+ const D = String.raw, T = String.raw, H = m && typeof CSS < "u" && CSS.supports && CSS.supports("animation-timing-function", "linear(1,2)"), X = m && typeof CSS < "u" && CSS.supports && CSS.supports("line-height", "mod(1,1)"), b = m && typeof matchMedia < "u" ? matchMedia("(prefers-reduced-motion: reduce)") : null, _ = "--_number-flow-d-opacity", E = "--_number-flow-d-width", w = "--_number-flow-dx", k = "--_number-flow-d", F = (() => {
17
17
  try {
18
18
  return CSS.registerProperty({
19
19
  name: _,
@@ -39,10 +39,10 @@ const H = String.raw, T = String.raw, X = m && typeof CSS < "u" && CSS.supports
39
39
  } catch {
40
40
  return !1;
41
41
  }
42
- })(), R = "var(--number-flow-char-height, 1em)", h = "var(--number-flow-mask-height, 0.25em)", S = `calc(${h} / 2)`, x = "var(--number-flow-mask-width, 0.5em)", d = `calc(${x} / var(--scale-x))`, u = "#000 0, transparent 71%", j = T`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${R} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${E}) / var(--width));transform:translateX(var(${w})) scaleX(var(--scale-x));margin:0 calc(-1 * ${x});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${d},#000 calc(100% - ${d}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${h},#000 calc(100% - ${h}),transparent 100% ),radial-gradient(at bottom right,${u}),radial-gradient(at bottom left,${u}),radial-gradient(at top left,${u}),radial-gradient(at top right,${u});-webkit-mask-size:100% calc(100% - ${h} * 2),calc(100% - ${d} * 2) 100%,${d} ${h},${d} ${h},${d} ${h},${d} ${h};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${S} ${x};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${w})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section__exiting,.symbol__exiting{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${S} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num:not(.is-current){position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num:not(.is-current){display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol__exiting{left:0}.section--justify-right .symbol__exiting{right:0}.animate-presence{opacity:calc(1 + var(${_}))}`, D = m ? HTMLElement : class {
43
- }, z = T`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:${R} !important}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${S} 0}.symbol{white-space:pre}`, I = (n) => `<span class="${n.type === "integer" || n.type === "fraction" ? "digit" : "symbol"}" part="${n.type === "integer" || n.type === "fraction" ? `digit ${n.type}-digit` : n.type}">${n.value}</span>`, g = (n, t) => `<span part="${t}">${n.reduce((e, i) => e + I(i), "")}</span>`, et = (n) => (
42
+ })(), R = "var(--number-flow-char-height, 1em)", h = "var(--number-flow-mask-height, 0.25em)", S = `calc(${h} / 2)`, x = "var(--number-flow-mask-width, 0.5em)", d = `calc(${x} / var(--scale-x))`, u = "#000 0, transparent 71%", j = T`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${R} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${E}) / var(--width));transform:translateX(var(${w})) scaleX(var(--scale-x));margin:0 calc(-1 * ${x});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${d},#000 calc(100% - ${d}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${h},#000 calc(100% - ${h}),transparent 100% ),radial-gradient(at bottom right,${u}),radial-gradient(at bottom left,${u}),radial-gradient(at top left,${u}),radial-gradient(at top right,${u});-webkit-mask-size:100% calc(100% - ${h} * 2),calc(100% - ${d} * 2) 100%,${d} ${h},${d} ${h},${d} ${h},${d} ${h};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${S} ${x};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${w})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section__exiting,.symbol__exiting{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${k})}.digit__num,.number .section::after{padding:${S} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num:not(.is-current){position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num:not(.is-current){display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol__exiting{left:0}.section--justify-right .symbol__exiting{right:0}.animate-presence{opacity:calc(1 + var(${_}))}`, O = m ? HTMLElement : class {
43
+ }, z = T`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:${R} !important}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${S} 0}.symbol{white-space:pre}`, I = (n) => `<span class="${n.type === "integer" || n.type === "fraction" ? "digit" : "symbol"}" part="${n.type === "integer" || n.type === "fraction" ? `digit ${n.type}-digit` : `symbol ${n.type}`}">${n.value}</span>`, g = (n, t) => `<span part="${t}">${n.reduce((e, i) => e + I(i), "")}</span>`, et = (n) => (
44
44
  // shadowroot="open" non-standard attribute for old Chrome:
45
- H`<template shadowroot="open" shadowrootmode="open"
45
+ D`<template shadowroot="open" shadowrootmode="open"
46
46
  ><style>
47
47
  ${z}</style
48
48
  >${g(n.pre, "left")}<span part="number" class="number"
@@ -52,9 +52,9 @@ const H = String.raw, T = String.raw, X = m && typeof CSS < "u" && CSS.supports
52
52
  style="font-kerning: none; display: inline-block; line-height: ${R} !important; padding: ${h} 0;"
53
53
  >${n.valueAsString}</span
54
54
  >`
55
- ), Y = F && X && O;
55
+ ), Y = X && H && F;
56
56
  let y;
57
- class G extends D {
57
+ class G extends O {
58
58
  constructor() {
59
59
  super(), this.created = !1, this.manual = !1;
60
60
  const { animated: t, ...e } = this.constructor.defaultProps;
@@ -309,7 +309,7 @@ class N extends P {
309
309
  ...this.flow.transformTiming,
310
310
  composite: "accumulate"
311
311
  });
312
- const o = this.getSpin();
312
+ const o = this.getDelta();
313
313
  o && (this.el.classList.add("is-spinning"), this.el.animate({
314
314
  [k]: [-o, 0]
315
315
  }, {
@@ -317,11 +317,11 @@ class N extends P {
317
317
  composite: "accumulate"
318
318
  }), this.flow.addEventListener("animationsfinish", this._onAnimationsFinish, { once: !0 }));
319
319
  }
320
- getSpin() {
320
+ getDelta() {
321
321
  var i;
322
322
  if (this.flow.plugins)
323
323
  for (const s of this.flow.plugins) {
324
- const a = (i = s.getSpin) == null ? void 0 : i.call(s, this.value, this._prevValue, this);
324
+ const a = (i = s.getDelta) == null ? void 0 : i.call(s, this.value, this._prevValue, this);
325
325
  if (a != null)
326
326
  return a;
327
327
  }
@@ -385,7 +385,7 @@ const J = (n, t) => n == null ? t : t == null ? n : Math.max(n, t), $ = /* @__PU
385
385
  const i = t.integer.concat(t.fraction).filter((o) => o.type === "integer" || o.type === "fraction"), s = n.integer.concat(n.fraction).filter((o) => o.type === "integer" || o.type === "fraction"), a = i.find((o) => !s.find((l) => l.pos === o.pos && l.value === o.value)), r = s.find((o) => !i.find((l) => o.pos === l.pos && o.value === l.value));
386
386
  $.set(e, J(a == null ? void 0 : a.pos, r == null ? void 0 : r.pos));
387
387
  },
388
- getSpin(n, t, e) {
388
+ getDelta(n, t, e) {
389
389
  const i = n - t, s = $.get(e.flow);
390
390
  if (!i && s != null && s >= e.pos)
391
391
  return e.length * e.flow.computedTrend;
@@ -1,4 +1,4 @@
1
- "use strict";const m=require("esm-env"),c=(n,t,e)=>{const i=document.createElement(n),[s,a]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),a==null||a.forEach(r=>i.appendChild(r)),i},B=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},O=n=>n.offsetWidth>0&&n.offsetHeight>0,H=(n,t)=>{m.BROWSER&&customElements.get(n)!==t&&customElements.define(n,t)};function F(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}const X=String.raw,T=String.raw,D=m.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("animation-timing-function","linear(1,2)"),z=m.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),_=m.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,w="--_number-flow-d-opacity",R="--_number-flow-d-width",v="--_number-flow-dx",E="--_number-flow-d",I=(()=>{try{return CSS.registerProperty({name:w,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:v,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:R,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:E,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),k="var(--number-flow-char-height, 1em)",h="var(--number-flow-mask-height, 0.25em)",$=`calc(${h} / 2)`,x="var(--number-flow-mask-width, 0.5em)",d=`calc(${x} / var(--scale-x))`,u="#000 0, transparent 71%",A=T`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${k} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${R}) / var(--width));transform:translateX(var(${v})) scaleX(var(--scale-x));margin:0 calc(-1 * ${x});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${d},#000 calc(100% - ${d}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${h},#000 calc(100% - ${h}),transparent 100% ),radial-gradient(at bottom right,${u}),radial-gradient(at bottom left,${u}),radial-gradient(at top left,${u}),radial-gradient(at top right,${u});-webkit-mask-size:100% calc(100% - ${h} * 2),calc(100% - ${d} * 2) 100%,${d} ${h},${d} ${h},${d} ${h},${d} ${h};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${$} ${x};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${v})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section__exiting,.symbol__exiting{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${E})}.digit__num,.number .section::after{padding:${$} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num:not(.is-current){position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num:not(.is-current){display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol__exiting{left:0}.section--justify-right .symbol__exiting{right:0}.animate-presence{opacity:calc(1 + var(${w}))}`,Y=m.BROWSER?HTMLElement:class{},q=T`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:${k} !important}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${$} 0}.symbol{white-space:pre}`,G=n=>`<span class="${n.type==="integer"||n.type==="fraction"?"digit":"symbol"}" part="${n.type==="integer"||n.type==="fraction"?`digit ${n.type}-digit`:n.type}">${n.value}</span>`,g=(n,t)=>`<span part="${t}">${n.reduce((e,i)=>e+G(i),"")}</span>`,Z=n=>X`<template shadowroot="open" shadowrootmode="open"
1
+ "use strict";const m=require("esm-env"),c=(n,t,e)=>{const i=document.createElement(n),[s,a]=Array.isArray(t)?[void 0,t]:[t,e];return s&&Object.assign(i,s),a==null||a.forEach(r=>i.appendChild(r)),i},B=(n,t)=>{var e;return t==="left"?n.offsetLeft:(((e=n.offsetParent instanceof HTMLElement?n.offsetParent:null)==null?void 0:e.offsetWidth)??0)-n.offsetWidth-n.offsetLeft},O=n=>n.offsetWidth>0&&n.offsetHeight>0,D=(n,t)=>{m.BROWSER&&customElements.get(n)!==t&&customElements.define(n,t)};function H(n,t,{reverse:e=!1}={}){const i=n.length;for(let s=e?i-1:0;e?s>=0:s<i;e?s--:s++)t(n[s],s)}const F=String.raw,T=String.raw,X=m.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("animation-timing-function","linear(1,2)"),z=m.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),_=m.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,w="--_number-flow-d-opacity",R="--_number-flow-d-width",v="--_number-flow-dx",E="--_number-flow-d",I=(()=>{try{return CSS.registerProperty({name:w,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:v,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:R,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:E,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),k="var(--number-flow-char-height, 1em)",h="var(--number-flow-mask-height, 0.25em)",S=`calc(${h} / 2)`,x="var(--number-flow-mask-width, 0.5em)",d=`calc(${x} / var(--scale-x))`,u="#000 0, transparent 71%",A=T`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${k} !important}.number,.number__inner{display:inline-block;transform-origin:left top}:host([data-will-change]) :is(.number,.number__inner,.section,.digit,.digit__num,.symbol){will-change:transform}.number{--scale-x:calc(1 + var(${R}) / var(--width));transform:translateX(var(${v})) scaleX(var(--scale-x));margin:0 calc(-1 * ${x});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${d},#000 calc(100% - ${d}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${h},#000 calc(100% - ${h}),transparent 100% ),radial-gradient(at bottom right,${u}),radial-gradient(at bottom left,${u}),radial-gradient(at top left,${u}),radial-gradient(at top right,${u});-webkit-mask-size:100% calc(100% - ${h} * 2),calc(100% - ${d} * 2) 100%,${d} ${h},${d} ${h},${d} ${h},${d} ${h};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${S} ${x};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${v})))}:host > :not(.number){z-index:5}.section,.symbol{display:inline-block;position:relative;isolation:isolate}.section::after{content:'\200b';display:inline-block}.section--justify-left{transform-origin:center left}.section--justify-right{transform-origin:center right}.section__exiting,.symbol__exiting{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${E})}.digit__num,.number .section::after{padding:${S} 0}.digit__num{display:inline-block;--offset-raw:mod(var(--length) + var(--n) - mod(var(--c),var(--length)),var(--length));--offset:calc( var(--offset-raw) - var(--length) * round(down,var(--offset-raw) / (var(--length) / 2),1) );--y:clamp(-100%,var(--offset) * 100%,100%);transform:translateY(var(--y))}.digit__num:not(.is-current){position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num:not(.is-current){display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol__exiting{left:0}.section--justify-right .symbol__exiting{right:0}.animate-presence{opacity:calc(1 + var(${w}))}`,Y=m.BROWSER?HTMLElement:class{},q=T`:host{display:inline-block;direction:ltr;white-space:nowrap;line-height:${k} !important}span{display:inline-block}:host([data-will-change]) span{will-change:transform}.number,.digit{padding:${S} 0}.symbol{white-space:pre}`,G=n=>`<span class="${n.type==="integer"||n.type==="fraction"?"digit":"symbol"}" part="${n.type==="integer"||n.type==="fraction"?`digit ${n.type}-digit`:`symbol ${n.type}`}">${n.value}</span>`,g=(n,t)=>`<span part="${t}">${n.reduce((e,i)=>e+G(i),"")}</span>`,Z=n=>F`<template shadowroot="open" shadowrootmode="open"
2
2
  ><style>
3
3
  ${q}</style
4
4
  >${g(n.pre,"left")}<span part="number" class="number"
@@ -7,4 +7,4 @@
7
7
  ><span
8
8
  style="font-kerning: none; display: inline-block; line-height: ${k} !important; padding: ${h} 0;"
9
9
  >${n.valueAsString}</span
10
- >`,P=z&&D&&I;let y;class W extends Y{constructor(){super(),this.created=!1,this.manual=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var o;if(t==null)return;const{pre:e,integer:i,fraction:s,post:a,value:r}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,r):this.trend,this.computedAnimated=P&&this._animated&&(!this.respectMotionPreference||!(_!=null&&_.matches))&&O(this),(o=this.plugins)==null||o.forEach(p=>{var f;return(f=p.onUpdate)==null?void 0:f.call(p,t,l,this)}),this.manual||this.willUpdate(),this._pre.update(e),this._num.update({integer:i,fraction:s}),this._post.update(a),this.manual||this.didUpdate()}else{if(this._data=t,this.attachShadow({mode:"open"}),typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)y||(y=new CSSStyleSheet,y.replaceSync(A)),this.shadowRoot.adoptedStyleSheets=[y];else{const l=document.createElement("style");l.textContent=A,this.shadowRoot.appendChild(l)}this._pre=new M(this,e,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new J(this,i,s),this.shadowRoot.appendChild(this._num.el),this._post=new M(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el)}this.created=!0}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}W.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class J{constructor(t,e,i,{className:s,...a}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=c("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=c("span",{...a,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[v]:[`${e}px`,"0px"],[R]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class N{constructor(t,e,{justify:i,className:s,...a},r){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=c("span",{...a,className:`section section--justify-${i} ${s??""}`},r?r(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new U(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new K(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.classList.remove("section__exiting"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${B(e.el,this.justify)}px`}),t.forEach(e=>{e.el.classList.add("section__exiting"),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",a=s?"prepend":"append";if(F(t,r=>{let o;this.children.has(r.key)?(o=this.children.get(r.key),i.set(r,o),this.unpop(o),o.present=!0):(o=this.addChar(r,{startDigitsAtZero:!0,animateIn:!0}),e.set(r,o)),this.el[a](o.el)},{reverse:s}),this.flow.computedAnimated){const r=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(r)})}e.forEach((r,o)=>{r.update(o.value)}),i.forEach((r,o)=>{r.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends N{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(a=>a.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof U&&i.update(0)}),this.pop(e)}}class M extends N{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(a=>a.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class C{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var a;this.el.remove(),(a=this._onRemove)==null||a.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[w]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[w]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class V extends C{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class U extends V{constructor(t,e,i,s,a){var p,f;const r=(((f=(p=t.flow.digits)==null?void 0:p[s])==null?void 0:f.max)??9)+1,o=Array.from({length:r}).map((et,b)=>{const j=c("span",{className:`digit__num${b===i?" is-current":""}`},[document.createTextNode(String(b))]);return j.style.setProperty("--n",String(b)),j}),l=c("span",{part:`digit ${e}-digit`,className:"digit"},o);l.style.setProperty("--current",String(i)),l.style.setProperty("--length",String(r)),super(t,i,l,a),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=o,this.length=r}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){var e,i;(e=this._numbers[this.value])==null||e.classList.remove("is-current"),this.el.style.setProperty("--current",String(t)),(i=this._numbers[t])==null||i.classList.add("is-current"),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,a=this.section.justify==="left"?i+s:i-s,r=this._prevCenter-a;r&&this.el.animate({transform:[`translateX(${r}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getSpin();o&&(this.el.classList.add("is-spinning"),this.el.animate({[E]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getSpin(){var i;if(this.flow.plugins)for(const s of this.flow.plugins){const a=(i=s.getSpin)==null?void 0:i.call(s,this.value,this._prevValue,this);if(a!=null)return a}const t=this.value-this._prevValue,e=this.flow.computedTrend||Math.sign(t);return e<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:e>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:t}}class K extends V{constructor(t,e,i,s){const a=c("span",{className:"symbol__value",textContent:i});super(t,i,c("span",{part:`symbol ${e}`,className:"symbol"},[a]),s),this.type=e,this._children=new Map,this._onChildRemove=r=>()=>{this._children.delete(r)},this._children.set(i,new C(this.flow,a,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);if(e.present=!1,e.el.classList.add("symbol__exiting"),this._children.has(t)){const i=this._children.get(t);i.present=!0,i.el.classList.remove("symbol__exiting")}else{const i=c("span",{className:"symbol__value",textContent:t});this.el.appendChild(i),this._children.set(t,new C(this.flow,i,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const i=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],s=this._prevOffset-i;s&&this.el.animate({transform:[`translateX(${s}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const Q=(n,t)=>n==null?t:t==null?n:Math.max(n,t),S=new WeakMap,tt={onUpdate(n,t,e){if(S.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),a=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),r=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));S.set(e,Q(a==null?void 0:a.pos,r==null?void 0:r.pos))},getSpin(n,t,e){const i=n-t,s=S.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}};exports.Digit=U;exports.NumberFlowLite=W;exports.canAnimate=P;exports.continuous=tt;exports.define=H;exports.prefersReducedMotion=_;exports.renderInnerHTML=Z;
10
+ >`,P=z&&X&&I;let y;class W extends Y{constructor(){super(),this.created=!1,this.manual=!1;const{animated:t,...e}=this.constructor.defaultProps;this._animated=this.computedAnimated=t,Object.assign(this,e)}get animated(){return this._animated}set animated(t){var e;this.animated!==t&&(this._animated=t,(e=this.shadowRoot)==null||e.getAnimations().forEach(i=>i.finish()))}set data(t){var o;if(t==null)return;const{pre:e,integer:i,fraction:s,post:a,value:r}=t;if(this.created){const l=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(l.value,r):this.trend,this.computedAnimated=P&&this._animated&&(!this.respectMotionPreference||!(_!=null&&_.matches))&&O(this),(o=this.plugins)==null||o.forEach(p=>{var f;return(f=p.onUpdate)==null?void 0:f.call(p,t,l,this)}),this.manual||this.willUpdate(),this._pre.update(e),this._num.update({integer:i,fraction:s}),this._post.update(a),this.manual||this.didUpdate()}else{if(this._data=t,this.attachShadow({mode:"open"}),typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)y||(y=new CSSStyleSheet,y.replaceSync(A)),this.shadowRoot.adoptedStyleSheets=[y];else{const l=document.createElement("style");l.textContent=A,this.shadowRoot.appendChild(l)}this._pre=new M(this,e,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new J(this,i,s),this.shadowRoot.appendChild(this._num.el),this._post=new M(this,a,{justify:"left",part:"right"}),this.shadowRoot.appendChild(this._post.el)}this.created=!0}willUpdate(){this._pre.willUpdate(),this._num.willUpdate(),this._post.willUpdate()}didUpdate(){if(!this.computedAnimated)return;this._abortAnimationsFinish?this._abortAnimationsFinish.abort():this.dispatchEvent(new Event("animationsstart")),this._pre.didUpdate(),this._num.didUpdate(),this._post.didUpdate();const t=new AbortController;Promise.all(this.shadowRoot.getAnimations().map(e=>e.finished)).then(()=>{t.signal.aborted||(this.dispatchEvent(new Event("animationsfinish")),this._abortAnimationsFinish=void 0)}),this._abortAnimationsFinish=t}}W.defaultProps={transformTiming:{duration:900,easing:"linear(0,.005,.019,.039,.066,.096,.129,.165,.202,.24,.278,.316,.354,.39,.426,.461,.494,.526,.557,.586,.614,.64,.665,.689,.711,.731,.751,.769,.786,.802,.817,.831,.844,.856,.867,.877,.887,.896,.904,.912,.919,.925,.931,.937,.942,.947,.951,.955,.959,.962,.965,.968,.971,.973,.976,.978,.98,.981,.983,.984,.986,.987,.988,.989,.99,.991,.992,.992,.993,.994,.994,.995,.995,.996,.996,.9963,.9967,.9969,.9972,.9975,.9977,.9979,.9981,.9982,.9984,.9985,.9987,.9988,.9989,1)"},spinTiming:void 0,opacityTiming:{duration:450,easing:"ease-out"},animated:!0,trend:(n,t)=>Math.sign(t-n),respectMotionPreference:!0,plugins:void 0,digits:void 0};class J{constructor(t,e,i,{className:s,...a}={}){this.flow=t,this._integer=new L(t,e,{justify:"right",part:"integer"}),this._fraction=new L(t,i,{justify:"left",part:"fraction"}),this._inner=c("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=c("span",{...a,part:"number",className:`number ${s??""}`},[this._inner])}willUpdate(){this._prevWidth=this.el.offsetWidth,this._prevLeft=this.el.getBoundingClientRect().left,this._integer.willUpdate(),this._fraction.willUpdate()}update({integer:t,fraction:e}){this._integer.update(t),this._fraction.update(e)}didUpdate(){const t=this.el.getBoundingClientRect();this._integer.didUpdate(),this._fraction.didUpdate();const e=this._prevLeft-t.left,i=this.el.offsetWidth,s=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[v]:[`${e}px`,"0px"],[R]:[s,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class N{constructor(t,e,{justify:i,className:s,...a},r){this.flow=t,this.children=new Map,this.onCharRemove=l=>()=>{this.children.delete(l)},this.justify=i;const o=e.map(l=>this.addChar(l).el);this.el=c("span",{...a,className:`section section--justify-${i} ${s??""}`},r?r(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const s=t.type==="integer"||t.type==="fraction"?new U(this,t.type,e?0:t.value,t.pos,{...i,onRemove:this.onCharRemove(t.key)}):new K(this,t.type,t.value,{...i,onRemove:this.onCharRemove(t.key)});return this.children.set(t.key,s),s}unpop(t){t.el.classList.remove("section__exiting"),t.el.style.top="",t.el.style[this.justify]=""}pop(t){t.forEach(e=>{e.el.style.top=`${e.el.offsetTop}px`,e.el.style[this.justify]=`${B(e.el,this.justify)}px`}),t.forEach(e=>{e.el.classList.add("section__exiting"),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,s=this.justify==="left",a=s?"prepend":"append";if(H(t,r=>{let o;this.children.has(r.key)?(o=this.children.get(r.key),i.set(r,o),this.unpop(o),o.present=!0):(o=this.addChar(r,{startDigitsAtZero:!0,animateIn:!0}),e.set(r,o)),this.el[a](o.el)},{reverse:s}),this.flow.computedAnimated){const r=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(r)})}e.forEach((r,o)=>{r.update(o.value)}),i.forEach((r,o)=>{r.update(o.value)})}willUpdate(){const t=this.el.getBoundingClientRect();this._prevOffset=t[this.justify],this.children.forEach(e=>e.willUpdate(t))}didUpdate(){const t=this.el.getBoundingClientRect();this.children.forEach(s=>s.didUpdate(t));const e=t[this.justify],i=this._prevOffset-e;i&&this.children.size&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}class L extends N{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(a=>a.key===s)||e.set(s,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof U&&i.update(0)}),this.pop(e)}}class M extends N{update(t){const e=new Map;this.children.forEach((i,s)=>{t.find(a=>a.key===s)||e.set(s,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class C{constructor(t,e,{onRemove:i,animateIn:s=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var a;this.el.remove(),(a=this._onRemove)==null||a.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&s&&this.el.animate({[w]:[-.9999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),this._onRemove=i}get present(){return this._present}set present(t){if(this._present!==t){if(this._present=t,!this.flow.computedAnimated){t||this._remove();return}this.el.style.setProperty("--_number-flow-d-opacity",t?"0":"-.999"),this.el.animate({[w]:t?[-.9999,0]:[.999,0]},{...this.flow.opacityTiming,composite:"accumulate"}),t?this.flow.removeEventListener("animationsfinish",this._remove):this.flow.addEventListener("animationsfinish",this._remove,{once:!0})}}}class V extends C{constructor(t,e,i,s){super(t.flow,i,s),this.section=t,this.value=e,this.el=i}}class U extends V{constructor(t,e,i,s,a){var p,f;const r=(((f=(p=t.flow.digits)==null?void 0:p[s])==null?void 0:f.max)??9)+1,o=Array.from({length:r}).map((et,b)=>{const j=c("span",{className:`digit__num${b===i?" is-current":""}`},[document.createTextNode(String(b))]);return j.style.setProperty("--n",String(b)),j}),l=c("span",{part:`digit ${e}-digit`,className:"digit"},o);l.style.setProperty("--current",String(i)),l.style.setProperty("--length",String(r)),super(t,i,l,a),this.pos=s,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=o,this.length=r}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],s=e.width/2;this._prevCenter=this.section.justify==="left"?i+s:i-s}update(t){var e,i;(e=this._numbers[this.value])==null||e.classList.remove("is-current"),this.el.style.setProperty("--current",String(t)),(i=this._numbers[t])==null||i.classList.add("is-current"),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],s=e.width/2,a=this.section.justify==="left"?i+s:i-s,r=this._prevCenter-a;r&&this.el.animate({transform:[`translateX(${r}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[E]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var i;if(this.flow.plugins)for(const s of this.flow.plugins){const a=(i=s.getDelta)==null?void 0:i.call(s,this.value,this._prevValue,this);if(a!=null)return a}const t=this.value-this._prevValue,e=this.flow.computedTrend||Math.sign(t);return e<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:e>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:t}}class K extends V{constructor(t,e,i,s){const a=c("span",{className:"symbol__value",textContent:i});super(t,i,c("span",{part:`symbol ${e}`,className:"symbol"},[a]),s),this.type=e,this._children=new Map,this._onChildRemove=r=>()=>{this._children.delete(r)},this._children.set(i,new C(this.flow,a,{onRemove:this._onChildRemove(i)}))}willUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect();this._prevOffset=e[this.section.justify]-t[this.section.justify]}update(t){if(this.value!==t){const e=this._children.get(this.value);if(e.present=!1,e.el.classList.add("symbol__exiting"),this._children.has(t)){const i=this._children.get(t);i.present=!0,i.el.classList.remove("symbol__exiting")}else{const i=c("span",{className:"symbol__value",textContent:t});this.el.appendChild(i),this._children.set(t,new C(this.flow,i,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const i=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],s=this._prevOffset-i;s&&this.el.animate({transform:[`translateX(${s}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const Q=(n,t)=>n==null?t:t==null?n:Math.max(n,t),$=new WeakMap,tt={onUpdate(n,t,e){if($.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),s=n.integer.concat(n.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),a=i.find(o=>!s.find(l=>l.pos===o.pos&&l.value===o.value)),r=s.find(o=>!i.find(l=>o.pos===l.pos&&o.value===l.value));$.set(e,Q(a==null?void 0:a.pos,r==null?void 0:r.pos))},getDelta(n,t,e){const i=n-t,s=$.get(e.flow);if(!i&&s!=null&&s>=e.pos)return e.length*e.flow.computedTrend}};exports.Digit=U;exports.NumberFlowLite=W;exports.canAnimate=P;exports.continuous=tt;exports.define=D;exports.prefersReducedMotion=_;exports.renderInnerHTML=Z;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./continuous-B1RI4VTB.js");function T(o,h,l,c){const u=h.formatToParts(o);l&&u.unshift({type:"prefix",value:l}),c&&u.push({type:"suffix",value:c});const f=[],i=[],a=[],g=[],r={},s=t=>`${t}:${r[t]=(r[t]??-1)+1}`;let y="",m=!1,v=!1;for(const t of u){y+=t.value;const e=t.type==="minusSign"||t.type==="plusSign"?"sign":t.type;e==="integer"?(m=!0,i.push(...t.value.split("").map(p=>({type:e,value:parseInt(p)})))):e==="group"?i.push({type:e,value:t.value}):e==="decimal"?(v=!0,a.push({type:e,value:t.value,key:s(e)})):e==="fraction"?a.push(...t.value.split("").map(p=>({type:e,value:parseInt(p),key:s(e),pos:-1-r[e]}))):(m||v?g:f).push({type:e,value:t.value,key:s(e)})}const d=[];for(let t=i.length-1;t>=0;t--){const e=i[t];d.unshift(e.type==="integer"?{...e,key:s(e.type),pos:r[e.type]}:{...e,key:s(e.type)})}return{pre:f,integer:d,fraction:a,post:g,valueAsString:y,value:typeof o=="string"?parseFloat(o):o}}exports.Digit=n.Digit;exports.NumberFlowLite=n.NumberFlowLite;exports.canAnimate=n.canAnimate;exports.continuous=n.continuous;exports.define=n.define;exports.prefersReducedMotion=n.prefersReducedMotion;exports.renderInnerHTML=n.renderInnerHTML;exports.formatToData=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./continuous-NkaCOHfo.js");function T(o,h,l,c){const u=h.formatToParts(o);l&&u.unshift({type:"prefix",value:l}),c&&u.push({type:"suffix",value:c});const f=[],i=[],a=[],g=[],r={},s=t=>`${t}:${r[t]=(r[t]??-1)+1}`;let y="",m=!1,v=!1;for(const t of u){y+=t.value;const e=t.type==="minusSign"||t.type==="plusSign"?"sign":t.type;e==="integer"?(m=!0,i.push(...t.value.split("").map(p=>({type:e,value:parseInt(p)})))):e==="group"?i.push({type:e,value:t.value}):e==="decimal"?(v=!0,a.push({type:e,value:t.value,key:s(e)})):e==="fraction"?a.push(...t.value.split("").map(p=>({type:e,value:parseInt(p),key:s(e),pos:-1-r[e]}))):(m||v?g:f).push({type:e,value:t.value,key:s(e)})}const d=[];for(let t=i.length-1;t>=0;t--){const e=i[t];d.unshift(e.type==="integer"?{...e,key:s(e.type),pos:r[e.type]}:{...e,key:s(e.type)})}return{pre:f,integer:d,fraction:a,post:g,valueAsString:y,value:typeof o=="string"?parseFloat(o):o}}exports.Digit=n.Digit;exports.NumberFlowLite=n.NumberFlowLite;exports.canAnimate=n.canAnimate;exports.continuous=n.continuous;exports.define=n.define;exports.prefersReducedMotion=n.prefersReducedMotion;exports.renderInnerHTML=n.renderInnerHTML;exports.formatToData=T;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { D as I, N as S, a as T, c as x, d as A, p as F, r as L } from "./continuous-TTdTdDlQ.mjs";
1
+ import { D as I, N as S, a as T, c as x, d as A, p as F, r as L } from "./continuous-DjSsg6E6.mjs";
2
2
  function d(n, h, u, l) {
3
3
  const r = h.formatToParts(n);
4
4
  u && r.unshift({ type: "prefix", value: u }), l && r.push({ type: "suffix", value: l });
package/dist/lite.d.ts CHANGED
@@ -101,7 +101,7 @@ export declare class Digit extends Char<KeyedDigitPart> {
101
101
  willUpdate(parentRect: DOMRect): void;
102
102
  update(value: KeyedDigitPart['value']): void;
103
103
  didUpdate(parentRect: DOMRect): void;
104
- getSpin(): number;
104
+ getDelta(): number;
105
105
  private _onAnimationsFinish;
106
106
  }
107
107
  declare class Sym extends Char<KeyedSymbolPart> {
@@ -2,6 +2,6 @@ import type { NumberFlowLite, Digit } from '../lite';
2
2
  import type { Data } from '../formatter';
3
3
  export type Plugin = {
4
4
  onUpdate?(data: Data, prev: Data, context: NumberFlowLite): void;
5
- getSpin?(value: number, prev: number, context: Digit): number | void;
5
+ getDelta?(value: number, prev: number, context: Digit): number | void;
6
6
  };
7
7
  export { continuous } from './continuous';
package/dist/plugins.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./continuous-B1RI4VTB.js");exports.continuous=o.continuous;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./continuous-NkaCOHfo.js");exports.continuous=o.continuous;
package/dist/plugins.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as n } from "./continuous-TTdTdDlQ.mjs";
1
+ import { c as n } from "./continuous-DjSsg6E6.mjs";
2
2
  export {
3
3
  n as continuous
4
4
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.5.0",
6
+ "version": "0.5.1",
7
7
  "author": {
8
8
  "name": "Maxwell Barvian",
9
9
  "email": "max@barvian.me",