@number-flow/vue 0.4.3 → 0.4.5

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.d.ts CHANGED
@@ -2,14 +2,14 @@ import { ComponentOptionsMixin } from 'vue';
2
2
  import { ComponentProvideOptions } from 'vue';
3
3
  import { ComputedRef } from 'vue';
4
4
  import { DefineComponent } from 'vue';
5
- import { Format } from 'number-flow';
5
+ import { Format } from 'number-flow/lite';
6
6
  import { MaybeRefOrGetter } from 'vue';
7
- import { NumberFlowLite as NumberFlowElement } from 'number-flow';
8
- import { Props as Props_2 } from 'number-flow';
7
+ import { default as NumberFlowElement } from 'number-flow/lite';
8
+ import { Props as Props_2 } from 'number-flow/lite';
9
9
  import { PublicProps } from 'vue';
10
10
  import { Ref } from 'vue';
11
- import { Trend } from 'number-flow';
12
- import { Value } from 'number-flow';
11
+ import { Trend } from 'number-flow/lite';
12
+ import { Value } from 'number-flow/lite';
13
13
 
14
14
  declare const __VLS_component: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
15
15
 
package/dist/index.js CHANGED
@@ -1,417 +1,40 @@
1
- import { defineComponent as V, provide as H, renderSlot as G, watch as I, nextTick as j, onUnmounted as z, ref as S, computed as T, inject as Y, openBlock as Z, createElementBlock as q, mergeProps as J, unref as k, onMounted as K, watchEffect as Q, toValue as P } from "vue";
2
- import { NumberFlowLite as c, formatToData as tt, renderInnerHTML as et, define as it, canAnimate as nt, prefersReducedMotion as C } from "number-flow";
3
- import { NumberFlowLite as Et } from "number-flow";
4
- import { BROWSER as f } from "esm-env";
5
- const W = Symbol(), Ct = /* @__PURE__ */ V({
1
+ import { defineComponent as T, provide as P, renderSlot as b, watch as M, nextTick as g, onUnmounted as B, ref as p, computed as c, inject as E, openBlock as A, createElementBlock as F, mergeProps as L, unref as v, onMounted as N, watchEffect as $, toValue as h } from "vue";
2
+ import r, { formatToData as k, renderInnerHTML as C, define as G, canAnimate as S, prefersReducedMotion as f } from "number-flow/lite";
3
+ import { default as q } from "number-flow/lite";
4
+ export * from "number-flow/plugins";
5
+ import { BROWSER as H } from "esm-env";
6
+ const w = Symbol(), j = /* @__PURE__ */ T({
6
7
  __name: "NumberFlowGroup",
7
8
  setup(a) {
8
- const t = /* @__PURE__ */ new Set();
9
- let e = !1;
10
- return H(W, (n, o) => {
11
- t.add(n), I(
12
- o,
9
+ const s = /* @__PURE__ */ new Set();
10
+ let i = !1;
11
+ return P(w, (t, l) => {
12
+ s.add(t), M(
13
+ l,
13
14
  async () => {
14
- e || (e = !0, t.forEach(async (s) => {
15
- var r;
16
- !s.value || !s.value.created || (s.value.willUpdate(), await j(), (r = s.value) == null || r.didUpdate());
17
- }), await j(), e = !1);
15
+ i || (i = !0, s.forEach(async (e) => {
16
+ var u;
17
+ !e.value || !e.value.created || (e.value.willUpdate(), await g(), (u = e.value) == null || u.didUpdate());
18
+ }), await g(), i = !1);
18
19
  }
19
20
  // { flush: 'pre' } // default
20
- ), z(() => {
21
- t.delete(n);
21
+ ), B(() => {
22
+ s.delete(t);
22
23
  });
23
- }), (n, o) => G(n.$slots, "default");
24
+ }), (t, l) => b(t.$slots, "default");
24
25
  }
25
- }), u = (a, t, e) => {
26
- const i = document.createElement(a), [n, o] = Array.isArray(t) ? [void 0, t] : [t, e];
27
- return n && Object.assign(i, n), o == null || o.forEach((s) => i.appendChild(s)), i;
28
- }, st = (a, t) => {
29
- var e;
30
- return t === "left" ? a.offsetLeft : (((e = a.offsetParent instanceof HTMLElement ? a.offsetParent : null) == null ? void 0 : e.offsetWidth) ?? 0) - a.offsetWidth - a.offsetLeft;
31
- }, at = (a) => a.offsetWidth > 0 && a.offsetHeight > 0;
32
- function rt(a, t, { reverse: e = !1 } = {}) {
33
- const i = a.length;
34
- for (let n = e ? i - 1 : 0; e ? n >= 0 : n < i; e ? n-- : n++)
35
- t(a[n], n);
36
- }
37
- const ot = String.raw, lt = f && typeof CSS < "u" && CSS.supports && CSS.supports("animation-timing-function", "linear(1,2)"), ht = f && typeof CSS < "u" && CSS.supports && CSS.supports("line-height", "mod(1,1)"), M = f && typeof matchMedia < "u" ? matchMedia("(prefers-reduced-motion: reduce)") : null, y = "--_number-flow-d-opacity", E = "--_number-flow-d-width", w = "--_number-flow-dx", R = "--_number-flow-d", dt = (() => {
38
- try {
39
- return CSS.registerProperty({
40
- name: y,
41
- syntax: "<number>",
42
- inherits: !1,
43
- initialValue: "0"
44
- }), CSS.registerProperty({
45
- name: w,
46
- syntax: "<length>",
47
- inherits: !0,
48
- initialValue: "0px"
49
- }), CSS.registerProperty({
50
- name: E,
51
- syntax: "<number>",
52
- inherits: !1,
53
- initialValue: "0"
54
- }), CSS.registerProperty({
55
- name: R,
56
- syntax: "<number>",
57
- inherits: !0,
58
- initialValue: "0"
59
- }), !0;
60
- } catch {
61
- return !1;
62
- }
63
- })(), ct = "var(--number-flow-char-height, 1em)", p = "var(--number-flow-mask-height, 0.25em)", N = `calc(${p} / 2)`, A = "var(--number-flow-mask-width, 0.5em)", m = `calc(${A} / var(--scale-x))`, g = "#000 0, transparent 71%", L = ot`:host{display:inline-block;direction:ltr;white-space:nowrap;isolation:isolate;line-height:${ct} !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 * ${A});position:relative;-webkit-mask-image:linear-gradient(to right,transparent 0,#000 ${m},#000 calc(100% - ${m}),transparent ),linear-gradient(to bottom,transparent 0,#000 ${p},#000 calc(100% - ${p}),transparent 100% ),radial-gradient(at bottom right,${g}),radial-gradient(at bottom left,${g}),radial-gradient(at top left,${g}),radial-gradient(at top right,${g});-webkit-mask-size:100% calc(100% - ${p} * 2),calc(100% - ${m} * 2) 100%,${m} ${p},${m} ${p},${m} ${p},${m} ${p};-webkit-mask-position:center,center,top left,top right,bottom right,bottom left;-webkit-mask-repeat:no-repeat}.number__inner{padding:${N} ${A};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 > [inert],.symbol > [inert]{margin:0 !important;position:absolute !important;z-index:-1}.digit{display:inline-block;position:relative;--c:var(--current) + var(${R})}.digit__num,.number .section::after{padding:${N} 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[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{right:0}.animate-presence{opacity:calc(1 + var(${y}))}`, pt = f ? HTMLElement : class {
64
- }, ut = ht && lt && dt;
65
- let v;
66
- class mt extends pt {
67
- constructor() {
68
- super(), this.created = !1, this.manual = !1;
69
- const { animated: t, ...e } = this.constructor.defaultProps;
70
- this._animated = this.computedAnimated = t, Object.assign(this, e);
71
- }
72
- get animated() {
73
- return this._animated;
74
- }
75
- set animated(t) {
76
- var e;
77
- this.animated !== t && (this._animated = t, (e = this.shadowRoot) == null || e.getAnimations().forEach((i) => i.finish()));
78
- }
79
- set data(t) {
80
- var e;
81
- if (t == null)
82
- return;
83
- const { pre: i, integer: n, fraction: o, post: s, value: r } = t;
84
- if (this.created) {
85
- const l = this._data;
86
- this._data = t, this.computedTrend = typeof this.trend == "function" ? this.trend(l.value, r) : this.trend, this.computedAnimated = ut && this._animated && (!this.respectMotionPreference || !(M != null && M.matches)) && // https://github.com/barvian/number-flow/issues/9
87
- at(this), (e = this.plugins) == null || e.forEach((h) => {
88
- var d;
89
- return (d = h.onUpdate) == null ? void 0 : d.call(h, t, l, this);
90
- }), this.manual || this.willUpdate(), this._pre.update(i), this._num.update({ integer: n, fraction: o }), this._post.update(s), this.manual || this.didUpdate();
91
- } else {
92
- if (this._data = t, this.attachShadow({ mode: "open" }), typeof CSSStyleSheet < "u" && this.shadowRoot.adoptedStyleSheets)
93
- v || (v = new CSSStyleSheet(), v.replaceSync(L)), this.shadowRoot.adoptedStyleSheets = [v];
94
- else {
95
- const l = document.createElement("style");
96
- l.textContent = L, this.shadowRoot.appendChild(l);
97
- }
98
- this._pre = new F(this, i, {
99
- justify: "right",
100
- part: "left"
101
- }), this.shadowRoot.appendChild(this._pre.el), this._num = new ft(this, n, o), this.shadowRoot.appendChild(this._num.el), this._post = new F(this, s, {
102
- justify: "left",
103
- part: "right"
104
- }), this.shadowRoot.appendChild(this._post.el);
105
- }
106
- this.created = !0;
107
- }
108
- willUpdate() {
109
- this._pre.willUpdate(), this._num.willUpdate(), this._post.willUpdate();
110
- }
111
- didUpdate() {
112
- if (!this.computedAnimated)
113
- return;
114
- this._abortAnimationsFinish ? this._abortAnimationsFinish.abort() : this.dispatchEvent(new Event("animationsstart")), this._pre.didUpdate(), this._num.didUpdate(), this._post.didUpdate();
115
- const t = new AbortController();
116
- Promise.all(this.shadowRoot.getAnimations().map((e) => e.finished)).then(() => {
117
- t.signal.aborted || (this.dispatchEvent(new Event("animationsfinish")), this._abortAnimationsFinish = void 0);
118
- }), this._abortAnimationsFinish = t;
119
- }
120
- }
121
- mt.defaultProps = {
122
- transformTiming: {
123
- duration: 900,
124
- // Make sure to keep this minified:
125
- 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)"
126
- },
127
- spinTiming: void 0,
128
- opacityTiming: { duration: 450, easing: "ease-out" },
129
- animated: !0,
130
- trend: (a, t) => Math.sign(t - a),
131
- respectMotionPreference: !0,
132
- plugins: void 0,
133
- digits: void 0
134
- };
135
- class ft {
136
- constructor(t, e, i, { className: n, ...o } = {}) {
137
- this.flow = t, this._integer = new B(t, e, {
138
- justify: "right",
139
- part: "integer"
140
- }), this._fraction = new B(t, i, {
141
- justify: "left",
142
- part: "fraction"
143
- }), this._inner = u("span", {
144
- className: "number__inner"
145
- }, [this._integer.el, this._fraction.el]), this.el = u("span", {
146
- ...o,
147
- part: "number",
148
- className: `number ${n ?? ""}`
149
- }, [this._inner]);
150
- }
151
- willUpdate() {
152
- this._prevWidth = this.el.offsetWidth, this._prevLeft = this.el.getBoundingClientRect().left, this._integer.willUpdate(), this._fraction.willUpdate();
153
- }
154
- update({ integer: t, fraction: e }) {
155
- this._integer.update(t), this._fraction.update(e);
156
- }
157
- didUpdate() {
158
- const t = this.el.getBoundingClientRect();
159
- this._integer.didUpdate(), this._fraction.didUpdate();
160
- const e = this._prevLeft - t.left, i = this.el.offsetWidth, n = this._prevWidth - i;
161
- this.el.style.setProperty("--width", String(i)), this.el.animate({
162
- [w]: [`${e}px`, "0px"],
163
- [E]: [n, 0]
164
- }, {
165
- ...this.flow.transformTiming,
166
- composite: "accumulate"
167
- });
168
- }
169
- }
170
- class X {
171
- constructor(t, e, { justify: i, className: n, ...o }, s) {
172
- this.flow = t, this.children = /* @__PURE__ */ new Map(), this.onCharRemove = (l) => () => {
173
- this.children.delete(l);
174
- }, this.justify = i;
175
- const r = e.map((l) => this.addChar(l).el);
176
- this.el = u("span", {
177
- ...o,
178
- className: `section section--justify-${i} ${n ?? ""}`
179
- }, s ? s(r) : r);
180
- }
181
- addChar(t, { startDigitsAtZero: e = !1, ...i } = {}) {
182
- const n = t.type === "integer" || t.type === "fraction" ? new D(this, t.type, e ? 0 : t.value, t.pos, {
183
- ...i,
184
- onRemove: this.onCharRemove(t.key)
185
- }) : new gt(this, t.type, t.value, {
186
- ...i,
187
- onRemove: this.onCharRemove(t.key)
188
- });
189
- return this.children.set(t.key, n), n;
190
- }
191
- unpop(t) {
192
- t.el.removeAttribute("inert"), t.el.style.top = "", t.el.style[this.justify] = "";
193
- }
194
- pop(t) {
195
- t.forEach((e) => {
196
- e.el.style.top = `${e.el.offsetTop}px`, e.el.style[this.justify] = `${st(e.el, this.justify)}px`;
197
- }), t.forEach((e) => {
198
- e.el.setAttribute("inert", ""), e.present = !1;
199
- });
200
- }
201
- addNewAndUpdateExisting(t) {
202
- const e = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), n = this.justify === "left", o = n ? "prepend" : "append";
203
- if (rt(t, (s) => {
204
- let r;
205
- this.children.has(s.key) ? (r = this.children.get(s.key), i.set(s, r), this.unpop(r), r.present = !0) : (r = this.addChar(s, { startDigitsAtZero: !0, animateIn: !0 }), e.set(s, r)), this.el[o](r.el);
206
- }, { reverse: n }), this.flow.computedAnimated) {
207
- const s = this.el.getBoundingClientRect();
208
- e.forEach((r) => {
209
- r.willUpdate(s);
210
- });
211
- }
212
- e.forEach((s, r) => {
213
- s.update(r.value);
214
- }), i.forEach((s, r) => {
215
- s.update(r.value);
216
- });
217
- }
218
- willUpdate() {
219
- const t = this.el.getBoundingClientRect();
220
- this._prevOffset = t[this.justify], this.children.forEach((e) => e.willUpdate(t));
221
- }
222
- didUpdate() {
223
- const t = this.el.getBoundingClientRect();
224
- this.children.forEach((n) => n.didUpdate(t));
225
- const e = t[this.justify], i = this._prevOffset - e;
226
- i && this.children.size && this.el.animate({
227
- transform: [`translateX(${i}px)`, "none"]
228
- }, {
229
- ...this.flow.transformTiming,
230
- composite: "accumulate"
231
- });
232
- }
233
- }
234
- class B extends X {
235
- update(t) {
236
- const e = /* @__PURE__ */ new Map();
237
- this.children.forEach((i, n) => {
238
- t.find((o) => o.key === n) || e.set(n, i), this.unpop(i);
239
- }), this.addNewAndUpdateExisting(t), e.forEach((i) => {
240
- i instanceof D && i.update(0);
241
- }), this.pop(e);
242
- }
243
- }
244
- class F extends X {
245
- update(t) {
246
- const e = /* @__PURE__ */ new Map();
247
- this.children.forEach((i, n) => {
248
- t.find((o) => o.key === n) || e.set(n, i);
249
- }), this.pop(e), this.addNewAndUpdateExisting(t);
250
- }
251
- }
252
- class x {
253
- constructor(t, e, { onRemove: i, animateIn: n = !1 } = {}) {
254
- this.flow = t, this.el = e, this._present = !0, this._remove = () => {
255
- var o;
256
- this.el.remove(), (o = this._onRemove) == null || o.call(this);
257
- }, this.el.classList.add("animate-presence"), this.flow.computedAnimated && n && this.el.animate({
258
- [y]: [-0.9999, 0]
259
- }, {
260
- ...this.flow.opacityTiming,
261
- composite: "accumulate"
262
- }), this._onRemove = i;
263
- }
264
- get present() {
265
- return this._present;
266
- }
267
- set present(t) {
268
- if (this._present !== t) {
269
- if (this._present = t, t ? this.el.removeAttribute("inert") : this.el.setAttribute("inert", ""), !this.flow.computedAnimated) {
270
- t || this._remove();
271
- return;
272
- }
273
- this.el.style.setProperty("--_number-flow-d-opacity", t ? "0" : "-.999"), this.el.animate({
274
- [y]: t ? [-0.9999, 0] : [0.999, 0]
275
- }, {
276
- ...this.flow.opacityTiming,
277
- composite: "accumulate"
278
- }), t ? this.flow.removeEventListener("animationsfinish", this._remove) : this.flow.addEventListener("animationsfinish", this._remove, {
279
- once: !0
280
- });
281
- }
282
- }
283
- }
284
- class O extends x {
285
- constructor(t, e, i, n) {
286
- super(t.flow, i, n), this.section = t, this.value = e, this.el = i;
287
- }
288
- }
289
- class D extends O {
290
- constructor(t, e, i, n, o) {
291
- var s, r;
292
- const l = (((r = (s = t.flow.digits) == null ? void 0 : s[n]) == null ? void 0 : r.max) ?? 9) + 1, h = Array.from({ length: l }).map((U, _) => {
293
- const b = u("span", { className: "digit__num" }, [
294
- document.createTextNode(String(_))
295
- ]);
296
- return _ !== i && b.setAttribute("inert", ""), b.style.setProperty("--n", String(_)), b;
297
- }), d = u("span", {
298
- part: `digit ${e}-digit`,
299
- className: "digit"
300
- }, h);
301
- d.style.setProperty("--current", String(i)), d.style.setProperty("--length", String(l)), super(t, i, d, o), this.pos = n, this._onAnimationsFinish = () => {
302
- this.el.classList.remove("is-spinning");
303
- }, this._numbers = h, this.length = l;
304
- }
305
- willUpdate(t) {
306
- const e = this.el.getBoundingClientRect();
307
- this._prevValue = this.value;
308
- const i = e[this.section.justify] - t[this.section.justify], n = e.width / 2;
309
- this._prevCenter = this.section.justify === "left" ? i + n : i - n;
310
- }
311
- update(t) {
312
- this.el.style.setProperty("--current", String(t)), this._numbers.forEach((e, i) => i === t ? e.removeAttribute("inert") : e.setAttribute("inert", "")), this.value = t;
313
- }
314
- didUpdate(t) {
315
- const e = this.el.getBoundingClientRect(), i = e[this.section.justify] - t[this.section.justify], n = e.width / 2, o = this.section.justify === "left" ? i + n : i - n, s = this._prevCenter - o;
316
- s && this.el.animate({
317
- transform: [`translateX(${s}px)`, "none"]
318
- }, {
319
- ...this.flow.transformTiming,
320
- composite: "accumulate"
321
- });
322
- const r = this.getDelta();
323
- r && (this.el.classList.add("is-spinning"), this.el.animate({
324
- [R]: [-r, 0]
325
- }, {
326
- ...this.flow.spinTiming ?? this.flow.transformTiming,
327
- composite: "accumulate"
328
- }), this.flow.addEventListener("animationsfinish", this._onAnimationsFinish, { once: !0 }));
329
- }
330
- getDelta() {
331
- var t;
332
- if (this.flow.plugins)
333
- for (const n of this.flow.plugins) {
334
- const o = (t = n.getDelta) == null ? void 0 : t.call(n, this.value, this._prevValue, this);
335
- if (o != null)
336
- return o;
337
- }
338
- const e = this.value - this._prevValue, i = this.flow.computedTrend || Math.sign(e);
339
- 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;
340
- }
341
- }
342
- class gt extends O {
343
- constructor(t, e, i, n) {
344
- const o = u("span", {
345
- className: "symbol__value",
346
- textContent: i
347
- });
348
- super(t, i, u("span", {
349
- part: `symbol ${e}`,
350
- className: "symbol"
351
- }, [o]), n), this.type = e, this._children = /* @__PURE__ */ new Map(), this._onChildRemove = (s) => () => {
352
- this._children.delete(s);
353
- }, this._children.set(i, new x(this.flow, o, {
354
- onRemove: this._onChildRemove(i)
355
- }));
356
- }
357
- willUpdate(t) {
358
- if (this.type === "decimal")
359
- return;
360
- const e = this.el.getBoundingClientRect();
361
- this._prevOffset = e[this.section.justify] - t[this.section.justify];
362
- }
363
- update(t) {
364
- if (this.value !== t) {
365
- const e = this._children.get(this.value);
366
- if (e.present = !1, this._children.has(t)) {
367
- const i = this._children.get(t);
368
- i.present = !0;
369
- } else {
370
- const i = u("span", {
371
- className: "symbol__value",
372
- textContent: t
373
- });
374
- this.el.appendChild(i), this._children.set(t, new x(this.flow, i, {
375
- animateIn: !0,
376
- onRemove: this._onChildRemove(t)
377
- }));
378
- }
379
- }
380
- this.value = t;
381
- }
382
- didUpdate(t) {
383
- if (this.type === "decimal")
384
- return;
385
- const e = this.el.getBoundingClientRect()[this.section.justify] - t[this.section.justify], i = this._prevOffset - e;
386
- i && this.el.animate({
387
- transform: [`translateX(${i}px)`, "none"]
388
- }, { ...this.flow.transformTiming, composite: "accumulate" });
389
- }
390
- }
391
- const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), $ = /* @__PURE__ */ new WeakMap(), $t = {
392
- onUpdate(a, t, e) {
393
- if ($.set(e, void 0), !e.computedTrend)
394
- return;
395
- const i = t.integer.concat(t.fraction).filter((r) => r.type === "integer" || r.type === "fraction"), n = a.integer.concat(a.fraction).filter((r) => r.type === "integer" || r.type === "fraction"), o = i.find((r) => !n.find((l) => l.pos === r.pos && l.value === r.value)), s = n.find((r) => !i.find((l) => r.pos === l.pos && r.value === l.value));
396
- $.set(e, vt(o == null ? void 0 : o.pos, s == null ? void 0 : s.pos));
397
- },
398
- getDelta(a, t, e) {
399
- const i = a - t, n = $.get(e.flow);
400
- if (!i && n != null && n >= e.pos)
401
- return e.length * e.flow.computedTrend;
402
- }
403
- }, yt = ["aria-label", "manual", "trend", "plugins", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "digits", "innerHTML", "data"], St = /* @__PURE__ */ V({
26
+ }), R = ["batched", "trend", "plugins", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "digits", "innerHTML", "data"], x = /* @__PURE__ */ T({
404
27
  inheritAttrs: !1,
405
28
  __name: "index",
406
29
  props: {
407
- transformTiming: { default: () => c.defaultProps.transformTiming },
408
- spinTiming: { default: () => c.defaultProps.spinTiming },
409
- opacityTiming: { default: () => c.defaultProps.opacityTiming },
410
- animated: { type: Boolean, default: () => c.defaultProps.animated },
411
- respectMotionPreference: { type: Boolean, default: () => c.defaultProps.respectMotionPreference },
412
- trend: { type: [Number, Function], default: () => c.defaultProps.trend },
413
- plugins: { default: () => c.defaultProps.plugins },
414
- digits: { default: () => c.defaultProps.digits },
30
+ transformTiming: { default: () => r.defaultProps.transformTiming },
31
+ spinTiming: { default: () => r.defaultProps.spinTiming },
32
+ opacityTiming: { default: () => r.defaultProps.opacityTiming },
33
+ animated: { type: Boolean, default: () => r.defaultProps.animated },
34
+ respectMotionPreference: { type: Boolean, default: () => r.defaultProps.respectMotionPreference },
35
+ trend: { type: [Number, Function], default: () => r.defaultProps.trend },
36
+ plugins: { default: () => r.defaultProps.plugins },
37
+ digits: { default: () => r.defaultProps.digits },
415
38
  locales: {},
416
39
  format: {},
417
40
  value: {},
@@ -420,60 +43,57 @@ const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), $ = /* @__P
420
43
  willChange: { type: Boolean, default: !1 }
421
44
  },
422
45
  emits: ["animationsstart", "animationsfinish"],
423
- setup(a, { expose: t, emit: e }) {
424
- const i = S();
425
- t({ el: i });
426
- const n = e, o = T(() => new Intl.NumberFormat(a.locales, a.format)), s = T(() => tt(a.value, o.value, a.prefix, a.suffix)), r = f ? void 0 : et(s.value), l = Y(W, void 0);
427
- return l == null || l(i, s), (h, d) => (Z(), q("number-flow-vue", J({
46
+ setup(a, { expose: s, emit: i }) {
47
+ const o = p();
48
+ s({ el: o });
49
+ const t = i, l = c(() => new Intl.NumberFormat(a.locales, a.format)), e = c(() => k(a.value, l.value, a.prefix, a.suffix)), u = H ? void 0 : C(e.value), m = E(w, void 0);
50
+ return m == null || m(o, e), (n, d) => (A(), F("number-flow-vue", L({
428
51
  ref_key: "el",
429
- ref: i,
430
- "aria-label": s.value.valueAsString
431
- }, h.$attrs, {
432
- role: "img",
433
- manual: !!k(l),
434
- trend: h.trend,
435
- plugins: h.plugins,
436
- animated: h.animated,
437
- transformTiming: h.transformTiming,
438
- spinTiming: h.spinTiming,
439
- opacityTiming: h.opacityTiming,
440
- respectMotionPreference: h.respectMotionPreference,
441
- "data-will-change": h.willChange ? "" : void 0,
442
- digits: h.digits,
443
- innerHTML: k(r),
52
+ ref: o
53
+ }, n.$attrs, {
54
+ batched: !!v(m),
55
+ trend: n.trend,
56
+ plugins: n.plugins,
57
+ animated: n.animated,
58
+ transformTiming: n.transformTiming,
59
+ spinTiming: n.spinTiming,
60
+ opacityTiming: n.opacityTiming,
61
+ respectMotionPreference: n.respectMotionPreference,
62
+ "data-will-change": n.willChange ? "" : void 0,
63
+ digits: n.digits,
64
+ innerHTML: v(u),
444
65
  "data-allow-mismatch": "",
445
- onAnimationsstart: d[0] || (d[0] = (U) => n("animationsstart")),
446
- onAnimationsfinish: d[1] || (d[1] = (U) => n("animationsfinish")),
447
- data: s.value
448
- }), null, 16, yt));
66
+ onAnimationsstart: d[0] || (d[0] = (y) => t("animationsstart")),
67
+ onAnimationsfinish: d[1] || (d[1] = (y) => t("animationsfinish")),
68
+ data: e.value
69
+ }), null, 16, R));
449
70
  }
450
71
  });
451
- it("number-flow-vue", c);
452
- function Tt({
72
+ G("number-flow-vue", r);
73
+ function D({
453
74
  respectMotionPreference: a = !0
454
75
  } = {}) {
455
- const t = S(!1), e = S(!1);
456
- return K(() => {
457
- var i;
458
- t.value = nt, e.value = ((i = C) == null ? void 0 : i.matches) ?? !1;
459
- }), Q((i) => {
76
+ const s = p(!1), i = p(!1);
77
+ return N(() => {
460
78
  var o;
461
- if (!P(a)) return;
462
- const n = ({ matches: s }) => {
463
- e.value = s;
79
+ s.value = S, i.value = ((o = f) == null ? void 0 : o.matches) ?? !1;
80
+ }), $((o) => {
81
+ var l;
82
+ if (!h(a)) return;
83
+ const t = ({ matches: e }) => {
84
+ i.value = e;
464
85
  };
465
- (o = C) == null || o.addEventListener("change", n), i(() => {
466
- var s;
467
- (s = C) == null || s.removeEventListener("change", n);
86
+ (l = f) == null || l.addEventListener("change", t), o(() => {
87
+ var e;
88
+ (e = f) == null || e.removeEventListener("change", t);
468
89
  });
469
- }), T(
470
- () => t.value && (!P(a) || !e.value)
90
+ }), c(
91
+ () => s.value && (!h(a) || !i.value)
471
92
  );
472
93
  }
473
94
  export {
474
- Et as NumberFlowElement,
475
- Ct as NumberFlowGroup,
476
- $t as continuous,
477
- St as default,
478
- Tt as useCanAnimate
95
+ q as NumberFlowElement,
96
+ j as NumberFlowGroup,
97
+ x as default,
98
+ D as useCanAnimate
479
99
  };
@@ -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 j=Symbol(),W=l.defineComponent({__name:"NumberFlowGroup",setup(a){const t=new Set;let e=!1;const i=(n,o)=>{t.add(n),l.watch(o,async()=>{e||(e=!0,t.forEach(async s=>{var r;!s.value||!s.value.created||(s.value.willUpdate(),await l.nextTick(),(r=s.value)==null||r.didUpdate())}),await l.nextTick(),e=!1)}),l.onUnmounted(()=>{t.delete(n)})};return l.provide(j,i),(n,o)=>l.renderSlot(n.$slots,"default")}}),f=(a,t,e)=>{const i=document.createElement(a),[n,o]=Array.isArray(t)?[void 0,t]:[t,e];return n&&Object.assign(i,n),o==null||o.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)"),U=y.BROWSER&&typeof matchMedia<"u"?matchMedia("(prefers-reduced-motion: reduce)"):null,v="--_number-flow-d-opacity",S="--_number-flow-d-width",w="--_number-flow-dx",C="--_number-flow-d",q=(()=>{try{return CSS.registerProperty({name:v,syntax:"<number>",inherits:!1,initialValue:"0"}),CSS.registerProperty({name:w,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)",x=`calc(${m} / 2)`,$="var(--number-flow-mask-width, 0.5em)",g=`calc(${$} / var(--scale-x))`,_="#000 0, transparent 71%",P=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(${w})) 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,${_}),radial-gradient(at bottom left,${_}),radial-gradient(at top left,${_}),radial-gradient(at top right,${_});-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:${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 > [inert],.symbol > [inert]{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:${x} 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[inert]{position:absolute;top:0;left:50%;transform:translateX(-50%) translateY(var(--y))}.digit:not(.is-spinning) .digit__num[inert]{display:none}.symbol__value{display:inline-block;mix-blend-mode:plus-lighter;white-space:pre}.section--justify-left .symbol > [inert]{left:0}.section--justify-right .symbol > [inert]{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:o,post:s,value:r}=t;if(this.created){const h=this._data;this._data=t,this.computedTrend=typeof this.trend=="function"?this.trend(h.value,r):this.trend,this.computedAnimated=Y&&this._animated&&(!this.respectMotionPreference||!(U!=null&&U.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:o}),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(P)),this.shadowRoot.adoptedStyleSheets=[b];else{const h=document.createElement("style");h.textContent=P,this.shadowRoot.appendChild(h)}this._pre=new N(this,i,{justify:"right",part:"left"}),this.shadowRoot.appendChild(this._pre.el),this._num=new J(this,n,o),this.shadowRoot.appendChild(this._num.el),this._post=new N(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,...o}={}){this.flow=t,this._integer=new M(t,e,{justify:"right",part:"integer"}),this._fraction=new M(t,i,{justify:"left",part:"fraction"}),this._inner=f("span",{className:"number__inner"},[this._integer.el,this._fraction.el]),this.el=f("span",{...o,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({[w]:[`${e}px`,"0px"],[S]:[n,0]},{...this.flow.transformTiming,composite:"accumulate"})}}class k{constructor(t,e,{justify:i,className:n,...o},s){this.flow=t,this.children=new Map,this.onCharRemove=h=>()=>{this.children.delete(h)},this.justify=i;const r=e.map(h=>this.addChar(h).el);this.el=f("span",{...o,className:`section section--justify-${i} ${n??""}`},s?s(r):r)}addChar(t,{startDigitsAtZero:e=!1,...i}={}){const n=t.type==="integer"||t.type==="fraction"?new B(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.removeAttribute("inert"),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.setAttribute("inert",""),e.present=!1})}addNewAndUpdateExisting(t){const e=new Map,i=new Map,n=this.justify==="left",o=n?"prepend":"append";if(D(t,s=>{let r;this.children.has(s.key)?(r=this.children.get(s.key),i.set(s,r),this.unpop(r),r.present=!0):(r=this.addChar(s,{startDigitsAtZero:!0,animateIn:!0}),e.set(s,r)),this.el[o](r.el)},{reverse:n}),this.flow.computedAnimated){const s=this.el.getBoundingClientRect();e.forEach(r=>{r.willUpdate(s)})}e.forEach((s,r)=>{s.update(r.value)}),i.forEach((s,r)=>{s.update(r.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 M extends k{update(t){const e=new Map;this.children.forEach((i,n)=>{t.find(o=>o.key===n)||e.set(n,i),this.unpop(i)}),this.addNewAndUpdateExisting(t),e.forEach(i=>{i instanceof B&&i.update(0)}),this.pop(e)}}class N extends k{update(t){const e=new Map;this.children.forEach((i,n)=>{t.find(o=>o.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 o;this.el.remove(),(o=this._onRemove)==null||o.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,t?this.el.removeAttribute("inert"):this.el.setAttribute("inert",""),!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 L extends R{constructor(t,e,i,n){super(t.flow,i,n),this.section=t,this.value=e,this.el=i}}class B extends L{constructor(t,e,i,n,o){var s,r;const h=(((r=(s=t.flow.digits)==null?void 0:s[n])==null?void 0:r.max)??9)+1,c=Array.from({length:h}).map((V,A)=>{const E=f("span",{className:"digit__num"},[document.createTextNode(String(A))]);return A!==i&&E.setAttribute("inert",""),E.style.setProperty("--n",String(A)),E}),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,o),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){this.el.style.setProperty("--current",String(t)),this._numbers.forEach((e,i)=>i===t?e.removeAttribute("inert"):e.setAttribute("inert","")),this.value=t}didUpdate(t){const e=this.el.getBoundingClientRect(),i=e[this.section.justify]-t[this.section.justify],n=e.width/2,o=this.section.justify==="left"?i+n:i-n,s=this._prevCenter-o;s&&this.el.animate({transform:[`translateX(${s}px)`,"none"]},{...this.flow.transformTiming,composite:"accumulate"});const r=this.getDelta();r&&(this.el.classList.add("is-spinning"),this.el.animate({[C]:[-r,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 o=(t=n.getDelta)==null?void 0:t.call(n,this.value,this._prevValue,this);if(o!=null)return o}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 L{constructor(t,e,i,n){const o=f("span",{className:"symbol__value",textContent:i});super(t,i,f("span",{part:`symbol ${e}`,className:"symbol"},[o]),n),this.type=e,this._children=new Map,this._onChildRemove=s=>()=>{this._children.delete(s)},this._children.set(i,new R(this.flow,o,{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,this._children.has(t)){const i=this._children.get(t);i.present=!0}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(r=>r.type==="integer"||r.type==="fraction"),n=a.integer.concat(a.fraction).filter(r=>r.type==="integer"||r.type==="fraction"),o=i.find(r=>!n.find(h=>h.pos===r.pos&&h.value===r.value)),s=n.find(r=>!i.find(h=>r.pos===h.pos&&r.value===h.value));T.set(e,Q(o==null?void 0:o.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,o=l.computed(()=>new Intl.NumberFormat(a.locales,a.format)),s=l.computed(()=>d.formatToData(a.value,o.value,a.prefix,a.suffix)),r=y.BROWSER?void 0:d.renderInnerHTML(s.value),h=l.inject(j,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(r),"data-allow-mismatch":"",onAnimationsstart:u[0]||(u[0]=V=>n("animationsstart")),onAnimationsfinish:u[1]||(u[1]=V=>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 o;if(!l.toValue(a))return;const n=({matches:s})=>{e.value=s};(o=d.prefersReducedMotion)==null||o.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(t,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("number-flow/lite"),require("number-flow/plugins"),require("esm-env")):typeof define=="function"&&define.amd?define(["exports","vue","number-flow/lite","number-flow/plugins","esm-env"],e):(t=typeof globalThis<"u"?globalThis:t||self,e(t["number-flow-vue"]={},t.Vue,t.NumberFlowLite,t.plugins,t.Env))})(this,function(t,e,n,p,h){"use strict";const g=Symbol(),T=e.defineComponent({__name:"NumberFlowGroup",setup(i){const f=new Set;let d=!1;const r=(o,l)=>{f.add(o),e.watch(l,async()=>{d||(d=!0,f.forEach(async a=>{var u;!a.value||!a.value.created||(a.value.willUpdate(),await e.nextTick(),(u=a.value)==null||u.didUpdate())}),await e.nextTick(),d=!1)}),e.onUnmounted(()=>{f.delete(o)})};return e.provide(g,r),(o,l)=>e.renderSlot(o.$slots,"default")}}),y=["batched","trend","plugins","animated","transformTiming","spinTiming","opacityTiming","respectMotionPreference","data-will-change","digits","innerHTML","data"],P=e.defineComponent({inheritAttrs:!1,__name:"index",props:{transformTiming:{default:()=>n.defaultProps.transformTiming},spinTiming:{default:()=>n.defaultProps.spinTiming},opacityTiming:{default:()=>n.defaultProps.opacityTiming},animated:{type:Boolean,default:()=>n.defaultProps.animated},respectMotionPreference:{type:Boolean,default:()=>n.defaultProps.respectMotionPreference},trend:{type:[Number,Function],default:()=>n.defaultProps.trend},plugins:{default:()=>n.defaultProps.plugins},digits:{default:()=>n.defaultProps.digits},locales:{},format:{},value:{},prefix:{},suffix:{},willChange:{type:Boolean,default:!1}},emits:["animationsstart","animationsfinish"],setup(i,{expose:f,emit:d}){const r=e.ref();f({el:r});const o=d,l=e.computed(()=>new Intl.NumberFormat(i.locales,i.format)),a=e.computed(()=>n.formatToData(i.value,l.value,i.prefix,i.suffix)),u=h.BROWSER?void 0:n.renderInnerHTML(a.value),m=e.inject(g,void 0);return m==null||m(r,a),(s,c)=>(e.openBlock(),e.createElementBlock("number-flow-vue",e.mergeProps({ref_key:"el",ref:r},s.$attrs,{batched:!!e.unref(m),trend:s.trend,plugins:s.plugins,animated:s.animated,transformTiming:s.transformTiming,spinTiming:s.spinTiming,opacityTiming:s.opacityTiming,respectMotionPreference:s.respectMotionPreference,"data-will-change":s.willChange?"":void 0,digits:s.digits,innerHTML:e.unref(u),"data-allow-mismatch":"",onAnimationsstart:c[0]||(c[0]=v=>o("animationsstart")),onAnimationsfinish:c[1]||(c[1]=v=>o("animationsfinish")),data:a.value}),null,16,y))}});n.define("number-flow-vue",n);function M({respectMotionPreference:i=!0}={}){const f=e.ref(!1),d=e.ref(!1);return e.onMounted(()=>{var r;f.value=n.canAnimate,d.value=((r=n.prefersReducedMotion)==null?void 0:r.matches)??!1}),e.watchEffect(r=>{var l;if(!e.toValue(i))return;const o=({matches:a})=>{d.value=a};(l=n.prefersReducedMotion)==null||l.addEventListener("change",o),r(()=>{var a;(a=n.prefersReducedMotion)==null||a.removeEventListener("change",o)})}),e.computed(()=>f.value&&(!e.toValue(i)||!d.value))}t.NumberFlowElement=n,t.NumberFlowGroup=T,t.default=P,t.useCanAnimate=M,Object.keys(p).forEach(i=>{i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:()=>p[i]})}),Object.defineProperties(t,{__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.3",
7
+ "version": "0.4.5",
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.3"
48
+ "number-flow": "0.5.5"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@playwright/test": "^1.48.0",