@number-flow/vue 0.4.1 → 0.4.2
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 +126 -125
- package/dist/index.umd.cjs +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { defineComponent as V, provide as H, renderSlot as G, watch as I, nextTick as k, onUnmounted as z, ref as
|
|
2
|
-
import { NumberFlowLite as c, formatToData as tt, renderInnerHTML as et, define as it, canAnimate as
|
|
3
|
-
import { NumberFlowLite as
|
|
1
|
+
import { defineComponent as V, provide as H, renderSlot as G, watch as I, nextTick as k, onUnmounted as z, ref as S, computed as T, inject as Y, openBlock as Z, createElementBlock as q, mergeProps as J, unref as j, 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
4
|
import { BROWSER as f } from "esm-env";
|
|
5
|
-
const W = Symbol(),
|
|
5
|
+
const W = Symbol(), Ct = /* @__PURE__ */ V({
|
|
6
6
|
__name: "NumberFlowGroup",
|
|
7
7
|
setup(a) {
|
|
8
8
|
const t = /* @__PURE__ */ new Set();
|
|
9
9
|
let e = !1;
|
|
10
|
-
return H(W, (
|
|
11
|
-
t.add(
|
|
12
|
-
|
|
10
|
+
return H(W, (n, o) => {
|
|
11
|
+
t.add(n), I(
|
|
12
|
+
o,
|
|
13
13
|
async () => {
|
|
14
|
-
e || (e = !0, t.forEach(async (
|
|
15
|
-
var
|
|
16
|
-
!
|
|
14
|
+
e || (e = !0, t.forEach(async (s) => {
|
|
15
|
+
var r;
|
|
16
|
+
!s.value || !s.value.created || (s.value.willUpdate(), await k(), (r = s.value) == null || r.didUpdate());
|
|
17
17
|
}), await k(), e = !1);
|
|
18
18
|
}
|
|
19
19
|
// { flush: 'pre' } // default
|
|
20
20
|
), z(() => {
|
|
21
|
-
t.delete(
|
|
21
|
+
t.delete(n);
|
|
22
22
|
});
|
|
23
|
-
}), (
|
|
23
|
+
}), (n, o) => G(n.$slots, "default");
|
|
24
24
|
}
|
|
25
25
|
}), u = (a, t, e) => {
|
|
26
|
-
const i = document.createElement(a), [
|
|
27
|
-
return
|
|
28
|
-
},
|
|
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
29
|
var e;
|
|
30
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
31
|
}, at = (a) => a.offsetWidth > 0 && a.offsetHeight > 0;
|
|
32
|
-
function
|
|
32
|
+
function rt(a, t, { reverse: e = !1 } = {}) {
|
|
33
33
|
const i = a.length;
|
|
34
|
-
for (let
|
|
35
|
-
t(a[
|
|
34
|
+
for (let n = e ? i - 1 : 0; e ? n >= 0 : n < i; e ? n-- : n++)
|
|
35
|
+
t(a[n], n);
|
|
36
36
|
}
|
|
37
|
-
const
|
|
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
38
|
try {
|
|
39
39
|
return CSS.registerProperty({
|
|
40
40
|
name: y,
|
|
@@ -42,7 +42,7 @@ const rt = String.raw, lt = f && typeof CSS < "u" && CSS.supports && CSS.support
|
|
|
42
42
|
inherits: !1,
|
|
43
43
|
initialValue: "0"
|
|
44
44
|
}), CSS.registerProperty({
|
|
45
|
-
name:
|
|
45
|
+
name: w,
|
|
46
46
|
syntax: "<length>",
|
|
47
47
|
inherits: !0,
|
|
48
48
|
initialValue: "0px"
|
|
@@ -60,7 +60,7 @@ const rt = String.raw, lt = f && typeof CSS < "u" && CSS.supports && CSS.support
|
|
|
60
60
|
} catch {
|
|
61
61
|
return !1;
|
|
62
62
|
}
|
|
63
|
-
})(), ct = "var(--number-flow-char-height, 1em)", p = "var(--number-flow-mask-height, 0.25em)",
|
|
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:not(:has(.digit.is-spinning)){-webkit-mask-image:none}.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
64
|
}, ut = ht && lt && dt;
|
|
65
65
|
let v;
|
|
66
66
|
class mt extends pt {
|
|
@@ -80,25 +80,25 @@ class mt extends pt {
|
|
|
80
80
|
var e;
|
|
81
81
|
if (t == null)
|
|
82
82
|
return;
|
|
83
|
-
const { pre: i, integer:
|
|
83
|
+
const { pre: i, integer: n, fraction: o, post: s, value: r } = t;
|
|
84
84
|
if (this.created) {
|
|
85
85
|
const l = this._data;
|
|
86
|
-
this._data = t, this.computedTrend = typeof this.trend == "function" ? this.trend(l.value,
|
|
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
87
|
at(this), (e = this.plugins) == null || e.forEach((h) => {
|
|
88
88
|
var d;
|
|
89
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:
|
|
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
91
|
} else {
|
|
92
92
|
if (this._data = t, this.attachShadow({ mode: "open" }), typeof CSSStyleSheet < "u" && this.shadowRoot.adoptedStyleSheets)
|
|
93
|
-
v || (v = new CSSStyleSheet(), v.replaceSync(
|
|
93
|
+
v || (v = new CSSStyleSheet(), v.replaceSync(L)), this.shadowRoot.adoptedStyleSheets = [v];
|
|
94
94
|
else {
|
|
95
95
|
const l = document.createElement("style");
|
|
96
|
-
l.textContent =
|
|
96
|
+
l.textContent = L, this.shadowRoot.appendChild(l);
|
|
97
97
|
}
|
|
98
98
|
this._pre = new F(this, i, {
|
|
99
99
|
justify: "right",
|
|
100
100
|
part: "left"
|
|
101
|
-
}), this.shadowRoot.appendChild(this._pre.el), this._num = new ft(this,
|
|
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
102
|
justify: "left",
|
|
103
103
|
part: "right"
|
|
104
104
|
}), this.shadowRoot.appendChild(this._post.el);
|
|
@@ -133,7 +133,7 @@ mt.defaultProps = {
|
|
|
133
133
|
digits: void 0
|
|
134
134
|
};
|
|
135
135
|
class ft {
|
|
136
|
-
constructor(t, e, i, { className:
|
|
136
|
+
constructor(t, e, i, { className: n, ...o } = {}) {
|
|
137
137
|
this.flow = t, this._integer = new B(t, e, {
|
|
138
138
|
justify: "right",
|
|
139
139
|
part: "integer"
|
|
@@ -143,9 +143,9 @@ class ft {
|
|
|
143
143
|
}), this._inner = u("span", {
|
|
144
144
|
className: "number__inner"
|
|
145
145
|
}, [this._integer.el, this._fraction.el]), this.el = u("span", {
|
|
146
|
-
...
|
|
146
|
+
...o,
|
|
147
147
|
part: "number",
|
|
148
|
-
className: `number ${
|
|
148
|
+
className: `number ${n ?? ""}`
|
|
149
149
|
}, [this._inner]);
|
|
150
150
|
}
|
|
151
151
|
willUpdate() {
|
|
@@ -157,10 +157,10 @@ class ft {
|
|
|
157
157
|
didUpdate() {
|
|
158
158
|
const t = this.el.getBoundingClientRect();
|
|
159
159
|
this._integer.didUpdate(), this._fraction.didUpdate();
|
|
160
|
-
const e = this._prevLeft - t.left, i = this.el.offsetWidth,
|
|
160
|
+
const e = this._prevLeft - t.left, i = this.el.offsetWidth, n = this._prevWidth - i;
|
|
161
161
|
this.el.style.setProperty("--width", String(i)), this.el.animate({
|
|
162
|
-
[
|
|
163
|
-
[E]: [
|
|
162
|
+
[w]: [`${e}px`, "0px"],
|
|
163
|
+
[E]: [n, 0]
|
|
164
164
|
}, {
|
|
165
165
|
...this.flow.transformTiming,
|
|
166
166
|
composite: "accumulate"
|
|
@@ -168,51 +168,51 @@ class ft {
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
class X {
|
|
171
|
-
constructor(t, e, { justify: i, className:
|
|
171
|
+
constructor(t, e, { justify: i, className: n, ...o }, s) {
|
|
172
172
|
this.flow = t, this.children = /* @__PURE__ */ new Map(), this.onCharRemove = (l) => () => {
|
|
173
173
|
this.children.delete(l);
|
|
174
174
|
}, this.justify = i;
|
|
175
|
-
const
|
|
175
|
+
const r = e.map((l) => this.addChar(l).el);
|
|
176
176
|
this.el = u("span", {
|
|
177
|
-
...
|
|
178
|
-
className: `section section--justify-${i} ${
|
|
179
|
-
},
|
|
177
|
+
...o,
|
|
178
|
+
className: `section section--justify-${i} ${n ?? ""}`
|
|
179
|
+
}, s ? s(r) : r);
|
|
180
180
|
}
|
|
181
181
|
addChar(t, { startDigitsAtZero: e = !1, ...i } = {}) {
|
|
182
|
-
const
|
|
182
|
+
const n = 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, {
|
|
186
186
|
...i,
|
|
187
187
|
onRemove: this.onCharRemove(t.key)
|
|
188
188
|
});
|
|
189
|
-
return this.children.set(t.key,
|
|
189
|
+
return this.children.set(t.key, n), n;
|
|
190
190
|
}
|
|
191
191
|
unpop(t) {
|
|
192
|
-
t.el.
|
|
192
|
+
t.el.removeAttribute("inert"), t.el.style.top = "", t.el.style[this.justify] = "";
|
|
193
193
|
}
|
|
194
194
|
pop(t) {
|
|
195
195
|
t.forEach((e) => {
|
|
196
|
-
e.el.style.top = `${e.el.offsetTop}px`, e.el.style[this.justify] = `${
|
|
196
|
+
e.el.style.top = `${e.el.offsetTop}px`, e.el.style[this.justify] = `${st(e.el, this.justify)}px`;
|
|
197
197
|
}), t.forEach((e) => {
|
|
198
|
-
e.el.
|
|
198
|
+
e.el.setAttribute("inert", ""), e.present = !1;
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
201
|
addNewAndUpdateExisting(t) {
|
|
202
|
-
const e = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(),
|
|
203
|
-
if (
|
|
204
|
-
let
|
|
205
|
-
this.children.has(
|
|
206
|
-
}, { reverse:
|
|
207
|
-
const
|
|
208
|
-
e.forEach((
|
|
209
|
-
|
|
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
210
|
});
|
|
211
211
|
}
|
|
212
|
-
e.forEach((
|
|
213
|
-
|
|
214
|
-
}), i.forEach((
|
|
215
|
-
|
|
212
|
+
e.forEach((s, r) => {
|
|
213
|
+
s.update(r.value);
|
|
214
|
+
}), i.forEach((s, r) => {
|
|
215
|
+
s.update(r.value);
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
willUpdate() {
|
|
@@ -221,7 +221,7 @@ class X {
|
|
|
221
221
|
}
|
|
222
222
|
didUpdate() {
|
|
223
223
|
const t = this.el.getBoundingClientRect();
|
|
224
|
-
this.children.forEach((
|
|
224
|
+
this.children.forEach((n) => n.didUpdate(t));
|
|
225
225
|
const e = t[this.justify], i = this._prevOffset - e;
|
|
226
226
|
i && this.children.size && this.el.animate({
|
|
227
227
|
transform: [`translateX(${i}px)`, "none"]
|
|
@@ -234,8 +234,8 @@ class X {
|
|
|
234
234
|
class B extends X {
|
|
235
235
|
update(t) {
|
|
236
236
|
const e = /* @__PURE__ */ new Map();
|
|
237
|
-
this.children.forEach((i,
|
|
238
|
-
t.find((
|
|
237
|
+
this.children.forEach((i, n) => {
|
|
238
|
+
t.find((o) => o.key === n) || e.set(n, i), this.unpop(i);
|
|
239
239
|
}), this.addNewAndUpdateExisting(t), e.forEach((i) => {
|
|
240
240
|
i instanceof D && i.update(0);
|
|
241
241
|
}), this.pop(e);
|
|
@@ -244,17 +244,17 @@ class B extends X {
|
|
|
244
244
|
class F extends X {
|
|
245
245
|
update(t) {
|
|
246
246
|
const e = /* @__PURE__ */ new Map();
|
|
247
|
-
this.children.forEach((i,
|
|
248
|
-
t.find((
|
|
247
|
+
this.children.forEach((i, n) => {
|
|
248
|
+
t.find((o) => o.key === n) || e.set(n, i);
|
|
249
249
|
}), this.pop(e), this.addNewAndUpdateExisting(t);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
class
|
|
253
|
-
constructor(t, e, { onRemove: i, animateIn:
|
|
252
|
+
class x {
|
|
253
|
+
constructor(t, e, { onRemove: i, animateIn: n = !1 } = {}) {
|
|
254
254
|
this.flow = t, this.el = e, this._present = !0, this._remove = () => {
|
|
255
|
-
var
|
|
256
|
-
this.el.remove(), (
|
|
257
|
-
}, this.el.classList.add("animate-presence"), this.flow.computedAnimated &&
|
|
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
258
|
[y]: [-0.9999, 0]
|
|
259
259
|
}, {
|
|
260
260
|
...this.flow.opacityTiming,
|
|
@@ -266,7 +266,7 @@ class T {
|
|
|
266
266
|
}
|
|
267
267
|
set present(t) {
|
|
268
268
|
if (this._present !== t) {
|
|
269
|
-
if (this._present = t, !this.flow.computedAnimated) {
|
|
269
|
+
if (this._present = t, t ? this.el.removeAttribute("inert") : this.el.setAttribute("inert", ""), !this.flow.computedAnimated) {
|
|
270
270
|
t || this._remove();
|
|
271
271
|
return;
|
|
272
272
|
}
|
|
@@ -281,46 +281,47 @@ class T {
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
class O extends
|
|
285
|
-
constructor(t, e, i,
|
|
286
|
-
super(t.flow, i,
|
|
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
287
|
}
|
|
288
288
|
}
|
|
289
289
|
class D extends O {
|
|
290
|
-
constructor(t, e, i,
|
|
291
|
-
var
|
|
292
|
-
const l = (((
|
|
293
|
-
const
|
|
294
|
-
|
|
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;
|
|
295
297
|
}), d = u("span", {
|
|
296
298
|
part: `digit ${e}-digit`,
|
|
297
299
|
className: "digit"
|
|
298
300
|
}, h);
|
|
299
|
-
d.style.setProperty("--current", String(i)), d.style.setProperty("--length", String(l)), super(t, i, d,
|
|
301
|
+
d.style.setProperty("--current", String(i)), d.style.setProperty("--length", String(l)), super(t, i, d, o), this.pos = n, this._onAnimationsFinish = () => {
|
|
300
302
|
this.el.classList.remove("is-spinning");
|
|
301
303
|
}, this._numbers = h, this.length = l;
|
|
302
304
|
}
|
|
303
305
|
willUpdate(t) {
|
|
304
306
|
const e = this.el.getBoundingClientRect();
|
|
305
307
|
this._prevValue = this.value;
|
|
306
|
-
const i = e[this.section.justify] - t[this.section.justify],
|
|
307
|
-
this._prevCenter = this.section.justify === "left" ? i +
|
|
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;
|
|
308
310
|
}
|
|
309
311
|
update(t) {
|
|
310
|
-
|
|
311
|
-
(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;
|
|
312
|
+
this.el.style.setProperty("--current", String(t)), this._numbers.forEach((e, i) => i === t ? e.removeAttribute("inert") : e.setAttribute("inert", "")), this.value = t;
|
|
312
313
|
}
|
|
313
314
|
didUpdate(t) {
|
|
314
|
-
const e = this.el.getBoundingClientRect(), i = e[this.section.justify] - t[this.section.justify],
|
|
315
|
-
|
|
316
|
-
transform: [`translateX(${
|
|
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"]
|
|
317
318
|
}, {
|
|
318
319
|
...this.flow.transformTiming,
|
|
319
320
|
composite: "accumulate"
|
|
320
321
|
});
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
[R]: [-
|
|
322
|
+
const r = this.getDelta();
|
|
323
|
+
r && (this.el.classList.add("is-spinning"), this.el.animate({
|
|
324
|
+
[R]: [-r, 0]
|
|
324
325
|
}, {
|
|
325
326
|
...this.flow.spinTiming ?? this.flow.transformTiming,
|
|
326
327
|
composite: "accumulate"
|
|
@@ -329,27 +330,27 @@ class D extends O {
|
|
|
329
330
|
getDelta() {
|
|
330
331
|
var t;
|
|
331
332
|
if (this.flow.plugins)
|
|
332
|
-
for (const
|
|
333
|
-
const
|
|
334
|
-
if (
|
|
335
|
-
return
|
|
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;
|
|
336
337
|
}
|
|
337
338
|
const e = this.value - this._prevValue, i = this.flow.computedTrend || Math.sign(e);
|
|
338
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;
|
|
339
340
|
}
|
|
340
341
|
}
|
|
341
342
|
class gt extends O {
|
|
342
|
-
constructor(t, e, i,
|
|
343
|
-
const
|
|
343
|
+
constructor(t, e, i, n) {
|
|
344
|
+
const o = u("span", {
|
|
344
345
|
className: "symbol__value",
|
|
345
346
|
textContent: i
|
|
346
347
|
});
|
|
347
348
|
super(t, i, u("span", {
|
|
348
349
|
part: `symbol ${e}`,
|
|
349
350
|
className: "symbol"
|
|
350
|
-
}, [
|
|
351
|
-
this._children.delete(
|
|
352
|
-
}, this._children.set(i, new
|
|
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, {
|
|
353
354
|
onRemove: this._onChildRemove(i)
|
|
354
355
|
}));
|
|
355
356
|
}
|
|
@@ -362,15 +363,15 @@ class gt extends O {
|
|
|
362
363
|
update(t) {
|
|
363
364
|
if (this.value !== t) {
|
|
364
365
|
const e = this._children.get(this.value);
|
|
365
|
-
if (e.present = !1,
|
|
366
|
+
if (e.present = !1, this._children.has(t)) {
|
|
366
367
|
const i = this._children.get(t);
|
|
367
|
-
i.present = !0
|
|
368
|
+
i.present = !0;
|
|
368
369
|
} else {
|
|
369
370
|
const i = u("span", {
|
|
370
371
|
className: "symbol__value",
|
|
371
372
|
textContent: t
|
|
372
373
|
});
|
|
373
|
-
this.el.appendChild(i), this._children.set(t, new
|
|
374
|
+
this.el.appendChild(i), this._children.set(t, new x(this.flow, i, {
|
|
374
375
|
animateIn: !0,
|
|
375
376
|
onRemove: this._onChildRemove(t)
|
|
376
377
|
}));
|
|
@@ -387,16 +388,16 @@ class gt extends O {
|
|
|
387
388
|
}, { ...this.flow.transformTiming, composite: "accumulate" });
|
|
388
389
|
}
|
|
389
390
|
}
|
|
390
|
-
const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), $ = /* @__PURE__ */ new WeakMap(),
|
|
391
|
+
const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), $ = /* @__PURE__ */ new WeakMap(), $t = {
|
|
391
392
|
onUpdate(a, t, e) {
|
|
392
393
|
if ($.set(e, void 0), !e.computedTrend)
|
|
393
394
|
return;
|
|
394
|
-
const i = t.integer.concat(t.fraction).filter((
|
|
395
|
-
$.set(e, vt(
|
|
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));
|
|
396
397
|
},
|
|
397
398
|
getDelta(a, t, e) {
|
|
398
|
-
const i = a - t,
|
|
399
|
-
if (!i &&
|
|
399
|
+
const i = a - t, n = $.get(e.flow);
|
|
400
|
+
if (!i && n != null && n >= e.pos)
|
|
400
401
|
return e.length * e.flow.computedTrend;
|
|
401
402
|
}
|
|
402
403
|
}, yt = ["aria-label", "manual", "trend", "plugins", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "digits", "innerHTML", "data"], St = /* @__PURE__ */ V({
|
|
@@ -420,16 +421,16 @@ const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), $ = /* @__P
|
|
|
420
421
|
},
|
|
421
422
|
emits: ["animationsstart", "animationsfinish"],
|
|
422
423
|
setup(a, { expose: t, emit: e }) {
|
|
423
|
-
const i =
|
|
424
|
+
const i = S();
|
|
424
425
|
t({ el: i });
|
|
425
|
-
const
|
|
426
|
-
return l == null || l(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({
|
|
427
428
|
ref_key: "el",
|
|
428
429
|
ref: i,
|
|
429
|
-
"aria-label":
|
|
430
|
+
"aria-label": s.value.valueAsString
|
|
430
431
|
}, h.$attrs, {
|
|
431
432
|
role: "img",
|
|
432
|
-
manual: !!
|
|
433
|
+
manual: !!j(l),
|
|
433
434
|
trend: h.trend,
|
|
434
435
|
plugins: h.plugins,
|
|
435
436
|
animated: h.animated,
|
|
@@ -439,40 +440,40 @@ const vt = (a, t) => a == null ? t : t == null ? a : Math.max(a, t), $ = /* @__P
|
|
|
439
440
|
respectMotionPreference: h.respectMotionPreference,
|
|
440
441
|
"data-will-change": h.willChange ? "" : void 0,
|
|
441
442
|
digits: h.digits,
|
|
442
|
-
innerHTML:
|
|
443
|
+
innerHTML: j(r),
|
|
443
444
|
"data-allow-mismatch": "",
|
|
444
|
-
onAnimationsstart: d[0] || (d[0] = (U) =>
|
|
445
|
-
onAnimationsfinish: d[1] || (d[1] = (U) =>
|
|
446
|
-
data:
|
|
445
|
+
onAnimationsstart: d[0] || (d[0] = (U) => n("animationsstart")),
|
|
446
|
+
onAnimationsfinish: d[1] || (d[1] = (U) => n("animationsfinish")),
|
|
447
|
+
data: s.value
|
|
447
448
|
}), null, 16, yt));
|
|
448
449
|
}
|
|
449
450
|
});
|
|
450
451
|
it("number-flow-vue", c);
|
|
451
|
-
function
|
|
452
|
+
function Tt({
|
|
452
453
|
respectMotionPreference: a = !0
|
|
453
454
|
} = {}) {
|
|
454
|
-
const t =
|
|
455
|
+
const t = S(!1), e = S(!1);
|
|
455
456
|
return K(() => {
|
|
456
457
|
var i;
|
|
457
|
-
t.value =
|
|
458
|
+
t.value = nt, e.value = ((i = C) == null ? void 0 : i.matches) ?? !1;
|
|
458
459
|
}), Q((i) => {
|
|
459
|
-
var
|
|
460
|
+
var o;
|
|
460
461
|
if (!P(a)) return;
|
|
461
|
-
const
|
|
462
|
-
e.value =
|
|
462
|
+
const n = ({ matches: s }) => {
|
|
463
|
+
e.value = s;
|
|
463
464
|
};
|
|
464
|
-
(
|
|
465
|
-
var
|
|
466
|
-
(
|
|
465
|
+
(o = C) == null || o.addEventListener("change", n), i(() => {
|
|
466
|
+
var s;
|
|
467
|
+
(s = C) == null || s.removeEventListener("change", n);
|
|
467
468
|
});
|
|
468
|
-
}),
|
|
469
|
+
}), T(
|
|
469
470
|
() => t.value && (!P(a) || !e.value)
|
|
470
471
|
);
|
|
471
472
|
}
|
|
472
473
|
export {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
Et as NumberFlowElement,
|
|
475
|
+
Ct as NumberFlowGroup,
|
|
476
|
+
$t as continuous,
|
|
476
477
|
St as default,
|
|
477
|
-
|
|
478
|
+
Tt as useCanAnimate
|
|
478
479
|
};
|
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 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"}})});
|
|
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)"),k=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)",U=`calc(${m} / 2)`,$="var(--number-flow-mask-width, 0.5em)",g=`calc(${$} / var(--scale-x))`,_="#000 0, transparent 71%",x=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:not(:has(.digit.is-spinning)){-webkit-mask-image:none}.number__inner{padding:${U} ${$};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:${U} 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||!(k!=null&&k.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(x)),this.shadowRoot.adoptedStyleSheets=[b];else{const h=document.createElement("style");h.textContent=x,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 P{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 P{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 P{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"}})});
|
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.2",
|
|
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.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@playwright/test": "^1.48.0",
|