@number-flow/vue 0.4.0 → 0.4.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.
- package/dist/index.js +25 -25
- package/dist/index.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { defineComponent as V, provide as
|
|
1
|
+
import { defineComponent as V, provide as H, renderSlot as G, watch as I, nextTick as k, onUnmounted as z, ref as C, computed as S, inject as Y, openBlock as Z, createElementBlock as q, mergeProps as J, unref as A, onMounted as K, watchEffect as Q, toValue as P } from "vue";
|
|
2
2
|
import { NumberFlowLite as c, formatToData as tt, renderInnerHTML as et, define as it, canAnimate as st, prefersReducedMotion as b } from "number-flow";
|
|
3
3
|
import { NumberFlowLite as Rt } from "number-flow";
|
|
4
4
|
import { BROWSER as f } from "esm-env";
|
|
5
|
-
const W = Symbol(),
|
|
5
|
+
const W = Symbol(), $t = /* @__PURE__ */ V({
|
|
6
6
|
__name: "NumberFlowGroup",
|
|
7
7
|
setup(a) {
|
|
8
8
|
const t = /* @__PURE__ */ new Set();
|
|
9
9
|
let e = !1;
|
|
10
|
-
return
|
|
11
|
-
t.add(s),
|
|
10
|
+
return H(W, (s, r) => {
|
|
11
|
+
t.add(s), I(
|
|
12
12
|
r,
|
|
13
13
|
async () => {
|
|
14
14
|
e || (e = !0, t.forEach(async (n) => {
|
|
@@ -17,10 +17,10 @@ const W = Symbol(), St = /* @__PURE__ */ V({
|
|
|
17
17
|
}), await k(), e = !1);
|
|
18
18
|
}
|
|
19
19
|
// { flush: 'pre' } // default
|
|
20
|
-
),
|
|
20
|
+
), z(() => {
|
|
21
21
|
t.delete(s);
|
|
22
22
|
});
|
|
23
|
-
}), (s, r) =>
|
|
23
|
+
}), (s, r) => G(s.$slots, "default");
|
|
24
24
|
}
|
|
25
25
|
}), u = (a, t, e) => {
|
|
26
26
|
const i = document.createElement(a), [s, r] = Array.isArray(t) ? [void 0, t] : [t, e];
|
|
@@ -179,7 +179,7 @@ class X {
|
|
|
179
179
|
}, n ? n(o) : o);
|
|
180
180
|
}
|
|
181
181
|
addChar(t, { startDigitsAtZero: e = !1, ...i } = {}) {
|
|
182
|
-
const s = t.type === "integer" || t.type === "fraction" ? new
|
|
182
|
+
const s = t.type === "integer" || t.type === "fraction" ? new D(this, t.type, e ? 0 : t.value, t.pos, {
|
|
183
183
|
...i,
|
|
184
184
|
onRemove: this.onCharRemove(t.key)
|
|
185
185
|
}) : new gt(this, t.type, t.value, {
|
|
@@ -237,7 +237,7 @@ class B extends X {
|
|
|
237
237
|
this.children.forEach((i, s) => {
|
|
238
238
|
t.find((r) => r.key === s) || e.set(s, i), this.unpop(i);
|
|
239
239
|
}), this.addNewAndUpdateExisting(t), e.forEach((i) => {
|
|
240
|
-
i instanceof
|
|
240
|
+
i instanceof D && i.update(0);
|
|
241
241
|
}), this.pop(e);
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -286,7 +286,7 @@ class O extends T {
|
|
|
286
286
|
super(t.flow, i, s), this.section = t, this.value = e, this.el = i;
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
|
-
class
|
|
289
|
+
class D extends O {
|
|
290
290
|
constructor(t, e, i, s, r) {
|
|
291
291
|
var n, o;
|
|
292
292
|
const l = (((o = (n = t.flow.digits) == null ? void 0 : n[s]) == null ? void 0 : o.max) ?? 9) + 1, h = Array.from({ length: l }).map((U, w) => {
|
|
@@ -318,7 +318,7 @@ class H extends O {
|
|
|
318
318
|
...this.flow.transformTiming,
|
|
319
319
|
composite: "accumulate"
|
|
320
320
|
});
|
|
321
|
-
const o = this.
|
|
321
|
+
const o = this.getDelta();
|
|
322
322
|
o && (this.el.classList.add("is-spinning"), this.el.animate({
|
|
323
323
|
[R]: [-o, 0]
|
|
324
324
|
}, {
|
|
@@ -326,11 +326,11 @@ class H extends O {
|
|
|
326
326
|
composite: "accumulate"
|
|
327
327
|
}), this.flow.addEventListener("animationsfinish", this._onAnimationsFinish, { once: !0 }));
|
|
328
328
|
}
|
|
329
|
-
|
|
329
|
+
getDelta() {
|
|
330
330
|
var t;
|
|
331
331
|
if (this.flow.plugins)
|
|
332
332
|
for (const s of this.flow.plugins) {
|
|
333
|
-
const r = (t = s.
|
|
333
|
+
const r = (t = s.getDelta) == null ? void 0 : t.call(s, this.value, this._prevValue, this);
|
|
334
334
|
if (r != null)
|
|
335
335
|
return r;
|
|
336
336
|
}
|
|
@@ -387,19 +387,19 @@ class gt extends O {
|
|
|
387
387
|
}, { ...this.flow.transformTiming, composite: "accumulate" });
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t),
|
|
390
|
+
const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), $ = /* @__PURE__ */ new WeakMap(), Ct = {
|
|
391
391
|
onUpdate(a, t, e) {
|
|
392
|
-
if (
|
|
392
|
+
if ($.set(e, void 0), !e.computedTrend)
|
|
393
393
|
return;
|
|
394
394
|
const i = t.integer.concat(t.fraction).filter((o) => o.type === "integer" || o.type === "fraction"), s = a.integer.concat(a.fraction).filter((o) => o.type === "integer" || o.type === "fraction"), r = i.find((o) => !s.find((l) => l.pos === o.pos && l.value === o.value)), n = s.find((o) => !i.find((l) => o.pos === l.pos && o.value === l.value));
|
|
395
|
-
|
|
395
|
+
$.set(e, vt(r == null ? void 0 : r.pos, n == null ? void 0 : n.pos));
|
|
396
396
|
},
|
|
397
|
-
|
|
398
|
-
const i = a - t, s =
|
|
397
|
+
getDelta(a, t, e) {
|
|
398
|
+
const i = a - t, s = $.get(e.flow);
|
|
399
399
|
if (!i && s != null && s >= e.pos)
|
|
400
400
|
return e.length * e.flow.computedTrend;
|
|
401
401
|
}
|
|
402
|
-
}, yt = ["aria-label", "manual", "trend", "plugins", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "digits", "innerHTML", "data"],
|
|
402
|
+
}, yt = ["aria-label", "manual", "trend", "plugins", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "digits", "innerHTML", "data"], St = /* @__PURE__ */ V({
|
|
403
403
|
inheritAttrs: !1,
|
|
404
404
|
__name: "index",
|
|
405
405
|
props: {
|
|
@@ -420,9 +420,9 @@ const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), S = /* @__P
|
|
|
420
420
|
},
|
|
421
421
|
emits: ["animationsstart", "animationsfinish"],
|
|
422
422
|
setup(a, { expose: t, emit: e }) {
|
|
423
|
-
const i =
|
|
423
|
+
const i = C();
|
|
424
424
|
t({ el: i });
|
|
425
|
-
const s = e, r =
|
|
425
|
+
const s = e, r = S(() => new Intl.NumberFormat(a.locales, a.format)), n = S(() => tt(a.value, r.value, a.prefix, a.suffix)), o = f ? void 0 : et(n.value), l = Y(W, void 0);
|
|
426
426
|
return l == null || l(i, n), (h, d) => (Z(), q("number-flow-vue", J({
|
|
427
427
|
ref_key: "el",
|
|
428
428
|
ref: i,
|
|
@@ -451,7 +451,7 @@ it("number-flow-vue", c);
|
|
|
451
451
|
function xt({
|
|
452
452
|
respectMotionPreference: a = !0
|
|
453
453
|
} = {}) {
|
|
454
|
-
const t =
|
|
454
|
+
const t = C(!1), e = C(!1);
|
|
455
455
|
return K(() => {
|
|
456
456
|
var i;
|
|
457
457
|
t.value = st, e.value = ((i = b) == null ? void 0 : i.matches) ?? !1;
|
|
@@ -465,14 +465,14 @@ function xt({
|
|
|
465
465
|
var n;
|
|
466
466
|
(n = b) == null || n.removeEventListener("change", s);
|
|
467
467
|
});
|
|
468
|
-
}),
|
|
468
|
+
}), S(
|
|
469
469
|
() => t.value && (!P(a) || !e.value)
|
|
470
470
|
);
|
|
471
471
|
}
|
|
472
472
|
export {
|
|
473
473
|
Rt as NumberFlowElement,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
$t as NumberFlowGroup,
|
|
475
|
+
Ct as continuous,
|
|
476
|
+
St as default,
|
|
477
477
|
xt as useCanAnimate
|
|
478
478
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(p,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue"),require("number-flow"),require("esm-env")):typeof define=="function"&&define.amd?define(["exports","vue","number-flow","esm-env"],l):(p=typeof globalThis<"u"?globalThis:p||self,l(p["number-flow-vue"]={},p.Vue,p.NumberFlow,p.Env))})(this,function(p,l,d,y){"use strict";const E=Symbol(),W=l.defineComponent({__name:"NumberFlowGroup",setup(a){const t=new Set;let e=!1;const i=(n,r)=>{t.add(n),l.watch(r,async()=>{e||(e=!0,t.forEach(async s=>{var o;!s.value||!s.value.created||(s.value.willUpdate(),await l.nextTick(),(o=s.value)==null||o.didUpdate())}),await l.nextTick(),e=!1)}),l.onUnmounted(()=>{t.delete(n)})};return l.provide(E,i),(n,r)=>l.renderSlot(n.$slots,"default")}}),f=(a,t,e)=>{const i=document.createElement(a),[n,r]=Array.isArray(t)?[void 0,t]:[t,e];return n&&Object.assign(i,n),r==null||r.forEach(s=>i.appendChild(s)),i},O=(a,t)=>{var e;return t==="left"?a.offsetLeft:(((e=a.offsetParent instanceof HTMLElement?a.offsetParent:null)==null?void 0:e.offsetWidth)??0)-a.offsetWidth-a.offsetLeft},X=a=>a.offsetWidth>0&&a.offsetHeight>0;function F(a,t,{reverse:e=!1}={}){const i=a.length;for(let n=e?i-1:0;e?n>=0:n<i;e?n--:n++)t(a[n],n)}const H=String.raw,I=y.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("animation-timing-function","linear(1,2)"),q=y.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),j=y.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,v="--_number-flow-d-opacity",S="--_number-flow-d-width",_="--_number-flow-dx",C="--_number-flow-d",z=(()=>{try{return CSS.registerProperty({name:v,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:_,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:S,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:C,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),D="var(--number-flow-char-height, 1em)",m="var(--number-flow-mask-height, 0.25em)",L=`calc(${m} / 2)`,$="var(--number-flow-mask-width, 0.5em)",g=`calc(${$} / var(--scale-x))`,w="#000 0, transparent 71%",U=H`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${D} !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(${S}) / var(--width));transform:translateX(var(${_})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${g},#000 calc(100% - ${g}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${m},#000 calc(100% - ${m}),transparent 100% ),radial-gradient(at bottom right,${w}),radial-gradient(at bottom left,${w}),radial-gradient(at top left,${w}),radial-gradient(at top right,${w});-webkit-mask-size:100% calc(100% - ${m} * 2),calc(100% - ${g} * 2) 100%,${g} ${m},${g} ${m},${g} ${m},${g} ${m};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${L} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${_})))}: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(${C})}.digit__num,.number .section::after{padding:${L} 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(${v}))}`,G=y.BROWSER?HTMLElement:class{},Y=q&&I&&z;let b;class Z extends G{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 e;if(t==null)return;const{pre:i,integer:n,fraction:r,post:s,value:o}=t;if(this.created){const h=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(h.value,o):this.trend,this.computedAnimated=Y&&this._animated&&(!this.respectMotionPreference||!(j!=null&&j.matches))&&X(this),(e=this.plugins)==null||e.forEach(c=>{var u;return(u=c.onUpdate)==null?void 0:u.call(c,t,h,this)}),this.manual||this.willUpdate(),this._pre.update(i),this._num.update({integer:n,fraction:r}),this._post.update(s),this.manual||this.didUpdate()}else{if(this._data=t,this.attachShadow({mode:"open"}),typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)b||(b=new CSSStyleSheet,b.replaceSync(U)),this.shadowRoot.adoptedStyleSheets=[b];else{const h=document.createElement("style");h.textContent=U,this.shadowRoot.appendChild(h)}this._pre=new A(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new J(this,n,r),this.shadowRoot.appendChild(this._num.el),this._post=new A(this,s,{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}}Z.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:(a,t)=>Math.sign(t-a),respectMotionPreference:!0,plugins:void 0,digits:void 0};class J{constructor(t,e,i,{className:n,...r}={}){this.flow=t,this._integer=new k(t,e,{justify:"right",part:"integer"}),this._fraction=new k(t,i,{justify:"left",part:"fraction"}),this._inner=f("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=f("span",{...r,part:"number",className:`number ${n??""}`},[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,n=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[_]:[`${e}px`,"0px"],[S]:[n,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class P{constructor(t,e,{justify:i,className:n,...r},s){this.flow=t,this.children=new Map,this.onCharRemove=h=>()=>{this.children.delete(h)},this.justify=i;const o=e.map(h=>this.addChar(h).el);this.el=f("span",{...r,className:`section section--justify-${i} ${n??""}`},s?s(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const n=t.type==="integer"||t.type==="fraction"?new N(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,n),n}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]=`${O(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,n=this.justify==="left",r=n?"prepend":"append";if(F(t,s=>{let o;this.children.has(s.key)?(o=this.children.get(s.key),i.set(s,o),this.unpop(o),o.present=!0):(o=this.addChar(s,{startDigitsAtZero:!0,animateIn:!0}),e.set(s,o)),this.el[r](o.el)},{reverse:n}),this.flow.computedAnimated){const s=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(s)})}e.forEach((s,o)=>{s.update(o.value)}),i.forEach((s,o)=>{s.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(n=>n.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 k extends P{update(t){const e=new Map;this.children.forEach((i,n)=>{t.find(r=>r.key===n)||e.set(n,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof N&&i.update(0)}),this.pop(e)}}class A extends P{update(t){const e=new Map;this.children.forEach((i,n)=>{t.find(r=>r.key===n)||e.set(n,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class R{constructor(t,e,{onRemove:i,animateIn:n=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&n&&this.el.animate({[v]:[-.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({[v]: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 M extends R{constructor(t,e,i,n){super(t.flow,i,n),this.section=t,this.value=e,this.el=i}}class N extends M{constructor(t,e,i,n,r){var s,o;const h=(((o=(s=t.flow.digits)==null?void 0:s[n])==null?void 0:o.max)??9)+1,c=Array.from({length:h}).map((B,x)=>{const V=f("span",{className:`digit__num${x===i?" is-current":""}`},[document.createTextNode(String(x))]);return V.style.setProperty("--n",String(x)),V}),u=f("span",{part:`digit ${e}-digit`,className:"digit"},c);u.style.setProperty("--current",String(i)),u.style.setProperty("--length",String(h)),super(t,i,u,r),this.pos=n,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=c,this.length=h}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],n=e.width/2;this._prevCenter=this.section.justify==="left"?i+n:i-n}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],n=e.width/2,r=this.section.justify==="left"?i+n:i-n,s=this._prevCenter-r;s&&this.el.animate({transform:[`translateX(${s}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getSpin();o&&(this.el.classList.add("is-spinning"),this.el.animate({[C]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getSpin(){var t;if(this.flow.plugins)for(const n of this.flow.plugins){const r=(t=n.getSpin)==null?void 0:t.call(n,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class K extends M{constructor(t,e,i,n){const r=f("span",{className:"symbol__value",textContent:i});super(t,i,f("span",{part:`symbol ${e}`,className:"symbol"},[r]),n),this.type=e,this._children=new Map,this._onChildRemove=s=>()=>{this._children.delete(s)},this._children.set(i,new R(this.flow,r,{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=f("span",{className:"symbol__value",textContent:t});this.el.appendChild(i),this._children.set(t,new R(this.flow,i,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const Q=(a,t)=>a==null?t:t==null?a:Math.max(a,t),T=new WeakMap,tt={onUpdate(a,t,e){if(T.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),n=a.integer.concat(a.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!n.find(h=>h.pos===o.pos&&h.value===o.value)),s=n.find(o=>!i.find(h=>o.pos===h.pos&&o.value===h.value));T.set(e,Q(r==null?void 0:r.pos,s==null?void 0:s.pos))},getSpin(a,t,e){const i=a-t,n=T.get(e.flow);if(!i&&n!=null&&n>=e.pos)return e.length*e.flow.computedTrend}},et=["aria-label","manual","trend","plugins","animated","transformTiming","spinTiming","opacityTiming","respectMotionPreference","data-will-change","digits","innerHTML","data"],it=l.defineComponent({inheritAttrs:!1,__name:"index",props:{transformTiming:{default:()=>d.NumberFlowLite.defaultProps.transformTiming},spinTiming:{default:()=>d.NumberFlowLite.defaultProps.spinTiming},opacityTiming:{default:()=>d.NumberFlowLite.defaultProps.opacityTiming},animated:{type:Boolean,default:()=>d.NumberFlowLite.defaultProps.animated},respectMotionPreference:{type:Boolean,default:()=>d.NumberFlowLite.defaultProps.respectMotionPreference},trend:{type:[Number,Function],default:()=>d.NumberFlowLite.defaultProps.trend},plugins:{default:()=>d.NumberFlowLite.defaultProps.plugins},digits:{default:()=>d.NumberFlowLite.defaultProps.digits},locales:{},format:{},value:{},prefix:{},suffix:{},willChange:{type:Boolean,default:!1}},emits:["animationsstart","animationsfinish"],setup(a,{expose:t,emit:e}){const i=l.ref();t({el:i});const n=e,r=l.computed(()=>new Intl.NumberFormat(a.locales,a.format)),s=l.computed(()=>d.formatToData(a.value,r.value,a.prefix,a.suffix)),o=y.BROWSER?void 0:d.renderInnerHTML(s.value),h=l.inject(E,void 0);return h==null||h(i,s),(c,u)=>(l.openBlock(),l.createElementBlock("number-flow-vue",l.mergeProps({ref_key:"el",ref:i,"aria-label":s.value.valueAsString},c.$attrs,{role:"img",manual:!!l.unref(h),trend:c.trend,plugins:c.plugins,animated:c.animated,transformTiming:c.transformTiming,spinTiming:c.spinTiming,opacityTiming:c.opacityTiming,respectMotionPreference:c.respectMotionPreference,"data-will-change":c.willChange?"":void 0,digits:c.digits,innerHTML:l.unref(o),"data-allow-mismatch":"",onAnimationsstart:u[0]||(u[0]=B=>n("animationsstart")),onAnimationsfinish:u[1]||(u[1]=B=>n("animationsfinish")),data:s.value}),null,16,et))}});d.define("number-flow-vue",d.NumberFlowLite);function nt({respectMotionPreference:a=!0}={}){const t=l.ref(!1),e=l.ref(!1);return l.onMounted(()=>{var i;t.value=d.canAnimate,e.value=((i=d.prefersReducedMotion)==null?void 0:i.matches)??!1}),l.watchEffect(i=>{var r;if(!l.toValue(a))return;const n=({matches:s})=>{e.value=s};(r=d.prefersReducedMotion)==null||r.addEventListener("change",n),i(()=>{var s;(s=d.prefersReducedMotion)==null||s.removeEventListener("change",n)})}),l.computed(()=>t.value&&(!l.toValue(a)||!e.value))}Object.defineProperty(p,"NumberFlowElement",{enumerable:!0,get:()=>d.NumberFlowLite}),p.NumberFlowGroup=W,p.continuous=tt,p.default=it,p.useCanAnimate=nt,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(p,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("vue"),require("number-flow"),require("esm-env")):typeof define=="function"&&define.amd?define(["exports","vue","number-flow","esm-env"],l):(p=typeof globalThis<"u"?globalThis:p||self,l(p["number-flow-vue"]={},p.Vue,p.NumberFlow,p.Env))})(this,function(p,l,d,y){"use strict";const E=Symbol(),W=l.defineComponent({__name:"NumberFlowGroup",setup(a){const t=new Set;let e=!1;const i=(n,r)=>{t.add(n),l.watch(r,async()=>{e||(e=!0,t.forEach(async s=>{var o;!s.value||!s.value.created||(s.value.willUpdate(),await l.nextTick(),(o=s.value)==null||o.didUpdate())}),await l.nextTick(),e=!1)}),l.onUnmounted(()=>{t.delete(n)})};return l.provide(E,i),(n,r)=>l.renderSlot(n.$slots,"default")}}),f=(a,t,e)=>{const i=document.createElement(a),[n,r]=Array.isArray(t)?[void 0,t]:[t,e];return n&&Object.assign(i,n),r==null||r.forEach(s=>i.appendChild(s)),i},O=(a,t)=>{var e;return t==="left"?a.offsetLeft:(((e=a.offsetParent instanceof HTMLElement?a.offsetParent:null)==null?void 0:e.offsetWidth)??0)-a.offsetWidth-a.offsetLeft},X=a=>a.offsetWidth>0&&a.offsetHeight>0;function D(a,t,{reverse:e=!1}={}){const i=a.length;for(let n=e?i-1:0;e?n>=0:n<i;e?n--:n++)t(a[n],n)}const F=String.raw,H=y.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("animation-timing-function","linear(1,2)"),I=y.BROWSER&&typeof CSS<"u"&&CSS.supports&&CSS.supports("line-height","mod(1,1)"),j=y.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,v="--_number-flow-d-opacity",S="--_number-flow-d-width",_="--_number-flow-dx",C="--_number-flow-d",q=(()=>{try{return CSS.registerProperty({name:v,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:_,syntax:"<length>",inherits:!0,initialValue:"0px"}),CSS.registerProperty({name:S,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:C,syntax:"<number>",inherits:!0,initialValue:"0"}),!0}catch{return!1}})(),z="var(--number-flow-char-height, 1em)",m="var(--number-flow-mask-height, 0.25em)",L=`calc(${m} / 2)`,$="var(--number-flow-mask-width, 0.5em)",g=`calc(${$} / var(--scale-x))`,w="#000 0, transparent 71%",U=F`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${z} !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(${S}) / var(--width));transform:translateX(var(${_})) scaleX(var(--scale-x));margin:0 calc(-1 * ${$});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${g},#000 calc(100% - ${g}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${m},#000 calc(100% - ${m}),transparent 100% ),radial-gradient(at bottom right,${w}),radial-gradient(at bottom left,${w}),radial-gradient(at top left,${w}),radial-gradient(at top right,${w});-webkit-mask-size:100% calc(100% - ${m} * 2),calc(100% - ${g} * 2) 100%,${g} ${m},${g} ${m},${g} ${m},${g} ${m};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${L} ${$};transform:scaleX(calc(1 / var(--scale-x))) translateX(calc(-1 * var(${_})))}: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(${C})}.digit__num,.number .section::after{padding:${L} 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(${v}))}`,G=y.BROWSER?HTMLElement:class{},Y=I&&H&&q;let b;class Z extends G{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 e;if(t==null)return;const{pre:i,integer:n,fraction:r,post:s,value:o}=t;if(this.created){const h=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(h.value,o):this.trend,this.computedAnimated=Y&&this._animated&&(!this.respectMotionPreference||!(j!=null&&j.matches))&&X(this),(e=this.plugins)==null||e.forEach(c=>{var u;return(u=c.onUpdate)==null?void 0:u.call(c,t,h,this)}),this.manual||this.willUpdate(),this._pre.update(i),this._num.update({integer:n,fraction:r}),this._post.update(s),this.manual||this.didUpdate()}else{if(this._data=t,this.attachShadow({mode:"open"}),typeof CSSStyleSheet<"u"&&this.shadowRoot.adoptedStyleSheets)b||(b=new CSSStyleSheet,b.replaceSync(U)),this.shadowRoot.adoptedStyleSheets=[b];else{const h=document.createElement("style");h.textContent=U,this.shadowRoot.appendChild(h)}this._pre=new A(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new J(this,n,r),this.shadowRoot.appendChild(this._num.el),this._post=new A(this,s,{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}}Z.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:(a,t)=>Math.sign(t-a),respectMotionPreference:!0,plugins:void 0,digits:void 0};class J{constructor(t,e,i,{className:n,...r}={}){this.flow=t,this._integer=new k(t,e,{justify:"right",part:"integer"}),this._fraction=new k(t,i,{justify:"left",part:"fraction"}),this._inner=f("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=f("span",{...r,part:"number",className:`number ${n??""}`},[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,n=this._prevWidth-i;this.el.style.setProperty("--width",String(i)),this.el.animate({[_]:[`${e}px`,"0px"],[S]:[n,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class P{constructor(t,e,{justify:i,className:n,...r},s){this.flow=t,this.children=new Map,this.onCharRemove=h=>()=>{this.children.delete(h)},this.justify=i;const o=e.map(h=>this.addChar(h).el);this.el=f("span",{...r,className:`section section--justify-${i} ${n??""}`},s?s(o):o)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const n=t.type==="integer"||t.type==="fraction"?new N(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,n),n}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]=`${O(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,n=this.justify==="left",r=n?"prepend":"append";if(D(t,s=>{let o;this.children.has(s.key)?(o=this.children.get(s.key),i.set(s,o),this.unpop(o),o.present=!0):(o=this.addChar(s,{startDigitsAtZero:!0,animateIn:!0}),e.set(s,o)),this.el[r](o.el)},{reverse:n}),this.flow.computedAnimated){const s=this.el.getBoundingClientRect();e.forEach(o=>{o.willUpdate(s)})}e.forEach((s,o)=>{s.update(o.value)}),i.forEach((s,o)=>{s.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(n=>n.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 k extends P{update(t){const e=new Map;this.children.forEach((i,n)=>{t.find(r=>r.key===n)||e.set(n,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof N&&i.update(0)}),this.pop(e)}}class A extends P{update(t){const e=new Map;this.children.forEach((i,n)=>{t.find(r=>r.key===n)||e.set(n,i)}),this.pop(e),this.addNewAndUpdateExisting(t)}}class R{constructor(t,e,{onRemove:i,animateIn:n=!1}={}){this.flow=t,this.el=e,this._present=!0,this._remove=()=>{var r;this.el.remove(),(r=this._onRemove)==null||r.call(this)},this.el.classList.add("animate-presence"),this.flow.computedAnimated&&n&&this.el.animate({[v]:[-.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({[v]: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 M extends R{constructor(t,e,i,n){super(t.flow,i,n),this.section=t,this.value=e,this.el=i}}class N extends M{constructor(t,e,i,n,r){var s,o;const h=(((o=(s=t.flow.digits)==null?void 0:s[n])==null?void 0:o.max)??9)+1,c=Array.from({length:h}).map((B,x)=>{const V=f("span",{className:`digit__num${x===i?" is-current":""}`},[document.createTextNode(String(x))]);return V.style.setProperty("--n",String(x)),V}),u=f("span",{part:`digit ${e}-digit`,className:"digit"},c);u.style.setProperty("--current",String(i)),u.style.setProperty("--length",String(h)),super(t,i,u,r),this.pos=n,this._onAnimationsFinish=()=>{this.el.classList.remove("is-spinning")},this._numbers=c,this.length=h}willUpdate(t){const e=this.el.getBoundingClientRect();this._prevValue=this.value;const i=e[this.section.justify]-t[this.section.justify],n=e.width/2;this._prevCenter=this.section.justify==="left"?i+n:i-n}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],n=e.width/2,r=this.section.justify==="left"?i+n:i-n,s=this._prevCenter-r;s&&this.el.animate({transform:[`translateX(${s}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const o=this.getDelta();o&&(this.el.classList.add("is-spinning"),this.el.animate({[C]:[-o,0]},{...this.flow.spinTiming??this.flow.transformTiming,composite:"accumulate"}),this.flow.addEventListener("animationsfinish",this._onAnimationsFinish,{once:!0}))}getDelta(){var t;if(this.flow.plugins)for(const n of this.flow.plugins){const r=(t=n.getDelta)==null?void 0:t.call(n,this.value,this._prevValue,this);if(r!=null)return r}const e=this.value-this._prevValue,i=this.flow.computedTrend||Math.sign(e);return i<0&&this.value>this._prevValue?this.value-this.length-this._prevValue:i>0&&this.value<this._prevValue?this.length-this._prevValue+this.value:e}}class K extends M{constructor(t,e,i,n){const r=f("span",{className:"symbol__value",textContent:i});super(t,i,f("span",{part:`symbol ${e}`,className:"symbol"},[r]),n),this.type=e,this._children=new Map,this._onChildRemove=s=>()=>{this._children.delete(s)},this._children.set(i,new R(this.flow,r,{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=f("span",{className:"symbol__value",textContent:t});this.el.appendChild(i),this._children.set(t,new R(this.flow,i,{animateIn:!0,onRemove:this._onChildRemove(t)}))}}this.value=t}didUpdate(t){if(this.type==="decimal")return;const e=this.el.getBoundingClientRect()[this.section.justify]-t[this.section.justify],i=this._prevOffset-e;i&&this.el.animate({transform:[`translateX(${i}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"})}}const Q=(a,t)=>a==null?t:t==null?a:Math.max(a,t),T=new WeakMap,tt={onUpdate(a,t,e){if(T.set(e,void 0),!e.computedTrend)return;const i=t.integer.concat(t.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),n=a.integer.concat(a.fraction).filter(o=>o.type==="integer"||o.type==="fraction"),r=i.find(o=>!n.find(h=>h.pos===o.pos&&h.value===o.value)),s=n.find(o=>!i.find(h=>o.pos===h.pos&&o.value===h.value));T.set(e,Q(r==null?void 0:r.pos,s==null?void 0:s.pos))},getDelta(a,t,e){const i=a-t,n=T.get(e.flow);if(!i&&n!=null&&n>=e.pos)return e.length*e.flow.computedTrend}},et=["aria-label","manual","trend","plugins","animated","transformTiming","spinTiming","opacityTiming","respectMotionPreference","data-will-change","digits","innerHTML","data"],it=l.defineComponent({inheritAttrs:!1,__name:"index",props:{transformTiming:{default:()=>d.NumberFlowLite.defaultProps.transformTiming},spinTiming:{default:()=>d.NumberFlowLite.defaultProps.spinTiming},opacityTiming:{default:()=>d.NumberFlowLite.defaultProps.opacityTiming},animated:{type:Boolean,default:()=>d.NumberFlowLite.defaultProps.animated},respectMotionPreference:{type:Boolean,default:()=>d.NumberFlowLite.defaultProps.respectMotionPreference},trend:{type:[Number,Function],default:()=>d.NumberFlowLite.defaultProps.trend},plugins:{default:()=>d.NumberFlowLite.defaultProps.plugins},digits:{default:()=>d.NumberFlowLite.defaultProps.digits},locales:{},format:{},value:{},prefix:{},suffix:{},willChange:{type:Boolean,default:!1}},emits:["animationsstart","animationsfinish"],setup(a,{expose:t,emit:e}){const i=l.ref();t({el:i});const n=e,r=l.computed(()=>new Intl.NumberFormat(a.locales,a.format)),s=l.computed(()=>d.formatToData(a.value,r.value,a.prefix,a.suffix)),o=y.BROWSER?void 0:d.renderInnerHTML(s.value),h=l.inject(E,void 0);return h==null||h(i,s),(c,u)=>(l.openBlock(),l.createElementBlock("number-flow-vue",l.mergeProps({ref_key:"el",ref:i,"aria-label":s.value.valueAsString},c.$attrs,{role:"img",manual:!!l.unref(h),trend:c.trend,plugins:c.plugins,animated:c.animated,transformTiming:c.transformTiming,spinTiming:c.spinTiming,opacityTiming:c.opacityTiming,respectMotionPreference:c.respectMotionPreference,"data-will-change":c.willChange?"":void 0,digits:c.digits,innerHTML:l.unref(o),"data-allow-mismatch":"",onAnimationsstart:u[0]||(u[0]=B=>n("animationsstart")),onAnimationsfinish:u[1]||(u[1]=B=>n("animationsfinish")),data:s.value}),null,16,et))}});d.define("number-flow-vue",d.NumberFlowLite);function nt({respectMotionPreference:a=!0}={}){const t=l.ref(!1),e=l.ref(!1);return l.onMounted(()=>{var i;t.value=d.canAnimate,e.value=((i=d.prefersReducedMotion)==null?void 0:i.matches)??!1}),l.watchEffect(i=>{var r;if(!l.toValue(a))return;const n=({matches:s})=>{e.value=s};(r=d.prefersReducedMotion)==null||r.addEventListener("change",n),i(()=>{var s;(s=d.prefersReducedMotion)==null||s.removeEventListener("change",n)})}),l.computed(()=>t.value&&(!l.toValue(a)||!e.value))}Object.defineProperty(p,"NumberFlowElement",{enumerable:!0,get:()=>d.NumberFlowLite}),p.NumberFlowGroup=W,p.continuous=tt,p.default=it,p.useCanAnimate=nt,Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.4.
|
|
7
|
+
"version": "0.4.1",
|
|
8
8
|
"author": {
|
|
9
9
|
"name": "Maxwell Barvian",
|
|
10
10
|
"email": "max@barvian.me",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"esm-env": "^1.1.4",
|
|
48
|
-
"number-flow": "0.5.
|
|
48
|
+
"number-flow": "0.5.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@playwright/test": "^1.48.0",
|