@number-flow/vue 0.2.7 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +60 -58
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("number-flow"),g=require("esm-env"),c=Symbol(),v=e.defineComponent({__name:"NumberFlowGroup",setup(r){const l=new Set;let u=!1;const i=(a,s)=>{l.add(a),e.watch(s,async()=>{u||(u=!0,l.forEach(async n=>{var m;!n.value||!n.value.created||(n.value.willUpdate(),await e.nextTick(),(m=n.value)==null||m.didUpdate())}),await e.nextTick(),u=!1)}),e.onUnmounted(()=>{l.delete(a)})};return e.provide(c,i),(a,s)=>e.renderSlot(a.$slots,"default")}}),w=["aria-label","manual","trend","continuous","animated","transformTiming","spinTiming","opacityTiming","respectMotionPreference","data-will-change","digits","innerHTML","data"],b=e.defineComponent({inheritAttrs:!1,__name:"index",props:{transformTiming:{default:()=>t.NumberFlowLite.defaultProps.transformTiming},spinTiming:{default:()=>t.NumberFlowLite.defaultProps.spinTiming},opacityTiming:{default:()=>t.NumberFlowLite.defaultProps.opacityTiming},animated:{type:Boolean,default:()=>t.NumberFlowLite.defaultProps.animated},respectMotionPreference:{type:Boolean,default:()=>t.NumberFlowLite.defaultProps.respectMotionPreference},trend:{type:[Number,Function],default:()=>t.NumberFlowLite.defaultProps.trend},continuous:{type:Boolean,default:()=>t.NumberFlowLite.defaultProps.continuous},digits:{default:()=>t.NumberFlowLite.defaultProps.digits},locales:{},format:{},value:{},prefix:{},suffix:{},willChange:{type:Boolean,default:!1}},emits:["animationsstart","animationsfinish"],setup(r,{expose:l,emit:u}){const i=e.ref();l({el:i});const a=u,s=e.computed(()=>new Intl.NumberFormat(r.locales,r.format)),n=e.computed(()=>t.formatToData(r.value,s.value,r.prefix,r.suffix)),m=g.BROWSER?void 0:t.renderInnerHTML(n.value),d=e.inject(c,void 0);return d==null||d(i,n),(o,f)=>(e.openBlock(),e.createElementBlock("number-flow-vue",e.mergeProps({ref_key:"el",ref:i,"aria-label":n.value.valueAsString},o.$attrs,{role:"img",manual:!!e.unref(d),trend:o.trend,continuous:o.continuous,animated:o.animated,transformTiming:o.transformTiming,spinTiming:o.spinTiming,opacityTiming:o.opacityTiming,respectMotionPreference:o.respectMotionPreference,"data-will-change":o.willChange?"":void 0,digits:o.digits,innerHTML:e.unref(m),"data-allow-mismatch":"",onAnimationsstart:f[0]||(f[0]=p=>a("animationsstart")),onAnimationsfinish:f[1]||(f[1]=p=>a("animationsfinish")),data:n.value}),null,16,w))}});t.define("number-flow-vue",t.NumberFlowLite);function T({respectMotionPreference:r=!0}={}){const l=e.ref(!1),u=e.ref(!1);return e.onMounted(()=>{var i;l.value=t.canAnimate,u.value=((i=t.prefersReducedMotion)==null?void 0:i.matches)??!1}),e.watchEffect(i=>{var s;if(!e.toValue(r))return;const a=({matches:n})=>{u.value=n};(s=t.prefersReducedMotion)==null||s.addEventListener("change",a),i(()=>{var n;(n=t.prefersReducedMotion)==null||n.removeEventListener("change",a)})}),e.computed(()=>l.value&&(!e.toValue(r)||!u.value))}Object.defineProperty(exports,"NumberFlowElement",{enumerable:!0,get:()=>t.NumberFlowLite});exports.NumberFlowGroup=v;exports.default=b;exports.useCanAnimate=T;
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { NumberFlowLite as
|
|
3
|
-
import { NumberFlowLite as
|
|
1
|
+
import { defineComponent as h, provide as P, renderSlot as b, watch as M, nextTick as g, onUnmounted as B, ref as c, computed as p, inject as A, openBlock as E, createElementBlock as F, mergeProps as L, unref as v, onMounted as N, watchEffect as $, toValue as T } from "vue";
|
|
2
|
+
import { NumberFlowLite as r, formatToData as k, renderInnerHTML as C, define as S, canAnimate as G, prefersReducedMotion as f } from "number-flow";
|
|
3
|
+
import { NumberFlowLite as x } from "number-flow";
|
|
4
4
|
import { BROWSER as H } from "esm-env";
|
|
5
|
-
const
|
|
5
|
+
const w = Symbol(), j = /* @__PURE__ */ h({
|
|
6
6
|
__name: "NumberFlowGroup",
|
|
7
|
-
setup(
|
|
8
|
-
const
|
|
9
|
-
let
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
setup(a) {
|
|
8
|
+
const s = /* @__PURE__ */ new Set();
|
|
9
|
+
let i = !1;
|
|
10
|
+
return P(w, (t, l) => {
|
|
11
|
+
s.add(t), M(
|
|
12
|
+
l,
|
|
13
13
|
async () => {
|
|
14
|
-
|
|
14
|
+
i || (i = !0, s.forEach(async (e) => {
|
|
15
15
|
var u;
|
|
16
16
|
!e.value || !e.value.created || (e.value.willUpdate(), await g(), (u = e.value) == null || u.didUpdate());
|
|
17
|
-
}), await g(),
|
|
17
|
+
}), await g(), i = !1);
|
|
18
18
|
}
|
|
19
19
|
// { flush: 'pre' } // default
|
|
20
|
-
),
|
|
21
|
-
|
|
20
|
+
), B(() => {
|
|
21
|
+
s.delete(t);
|
|
22
22
|
});
|
|
23
|
-
}), (
|
|
23
|
+
}), (t, l) => b(t.$slots, "default");
|
|
24
24
|
}
|
|
25
|
-
}), R = ["aria-label", "manual", "trend", "continuous", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "innerHTML", "data"],
|
|
25
|
+
}), R = ["aria-label", "manual", "trend", "continuous", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "digits", "innerHTML", "data"], D = /* @__PURE__ */ h({
|
|
26
26
|
inheritAttrs: !1,
|
|
27
27
|
__name: "index",
|
|
28
28
|
props: {
|
|
29
|
-
transformTiming: { default: () =>
|
|
30
|
-
spinTiming: { default: () =>
|
|
31
|
-
opacityTiming: { default: () =>
|
|
32
|
-
animated: { type: Boolean, default: () =>
|
|
33
|
-
respectMotionPreference: { type: Boolean, default: () =>
|
|
34
|
-
trend: { type: [
|
|
35
|
-
continuous: { type: Boolean, default: () =>
|
|
29
|
+
transformTiming: { default: () => r.defaultProps.transformTiming },
|
|
30
|
+
spinTiming: { default: () => r.defaultProps.spinTiming },
|
|
31
|
+
opacityTiming: { default: () => r.defaultProps.opacityTiming },
|
|
32
|
+
animated: { type: Boolean, default: () => r.defaultProps.animated },
|
|
33
|
+
respectMotionPreference: { type: Boolean, default: () => r.defaultProps.respectMotionPreference },
|
|
34
|
+
trend: { type: [Number, Function], default: () => r.defaultProps.trend },
|
|
35
|
+
continuous: { type: Boolean, default: () => r.defaultProps.continuous },
|
|
36
|
+
digits: { default: () => r.defaultProps.digits },
|
|
36
37
|
locales: {},
|
|
37
38
|
format: {},
|
|
38
39
|
value: {},
|
|
@@ -41,58 +42,59 @@ const y = Symbol(), j = /* @__PURE__ */ w({
|
|
|
41
42
|
willChange: { type: Boolean, default: !1 }
|
|
42
43
|
},
|
|
43
44
|
emits: ["animationsstart", "animationsfinish"],
|
|
44
|
-
setup(
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
return m == null || m(
|
|
45
|
+
setup(a, { expose: s, emit: i }) {
|
|
46
|
+
const o = c();
|
|
47
|
+
s({ el: o });
|
|
48
|
+
const t = i, l = p(() => new Intl.NumberFormat(a.locales, a.format)), e = p(() => k(a.value, l.value, a.prefix, a.suffix)), u = H ? void 0 : C(e.value), m = A(w, void 0);
|
|
49
|
+
return m == null || m(o, e), (n, d) => (E(), F("number-flow-vue", L({
|
|
49
50
|
ref_key: "el",
|
|
50
|
-
ref:
|
|
51
|
+
ref: o,
|
|
51
52
|
"aria-label": e.value.valueAsString
|
|
52
|
-
},
|
|
53
|
+
}, n.$attrs, {
|
|
53
54
|
role: "img",
|
|
54
55
|
manual: !!v(m),
|
|
55
|
-
trend:
|
|
56
|
-
continuous:
|
|
57
|
-
animated:
|
|
58
|
-
transformTiming:
|
|
59
|
-
spinTiming:
|
|
60
|
-
opacityTiming:
|
|
61
|
-
respectMotionPreference:
|
|
62
|
-
"data-will-change":
|
|
56
|
+
trend: n.trend,
|
|
57
|
+
continuous: n.continuous,
|
|
58
|
+
animated: n.animated,
|
|
59
|
+
transformTiming: n.transformTiming,
|
|
60
|
+
spinTiming: n.spinTiming,
|
|
61
|
+
opacityTiming: n.opacityTiming,
|
|
62
|
+
respectMotionPreference: n.respectMotionPreference,
|
|
63
|
+
"data-will-change": n.willChange ? "" : void 0,
|
|
64
|
+
digits: n.digits,
|
|
63
65
|
innerHTML: v(u),
|
|
64
66
|
"data-allow-mismatch": "",
|
|
65
|
-
onAnimationsstart:
|
|
66
|
-
onAnimationsfinish:
|
|
67
|
+
onAnimationsstart: d[0] || (d[0] = (y) => t("animationsstart")),
|
|
68
|
+
onAnimationsfinish: d[1] || (d[1] = (y) => t("animationsfinish")),
|
|
67
69
|
data: e.value
|
|
68
70
|
}), null, 16, R));
|
|
69
71
|
}
|
|
70
72
|
});
|
|
71
|
-
|
|
72
|
-
function
|
|
73
|
-
respectMotionPreference:
|
|
73
|
+
S("number-flow-vue", r);
|
|
74
|
+
function O({
|
|
75
|
+
respectMotionPreference: a = !0
|
|
74
76
|
} = {}) {
|
|
75
|
-
const
|
|
76
|
-
return
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
}), $((
|
|
80
|
-
var
|
|
81
|
-
if (!T(
|
|
82
|
-
const
|
|
83
|
-
|
|
77
|
+
const s = c(!1), i = c(!1);
|
|
78
|
+
return N(() => {
|
|
79
|
+
var o;
|
|
80
|
+
s.value = G, i.value = ((o = f) == null ? void 0 : o.matches) ?? !1;
|
|
81
|
+
}), $((o) => {
|
|
82
|
+
var l;
|
|
83
|
+
if (!T(a)) return;
|
|
84
|
+
const t = ({ matches: e }) => {
|
|
85
|
+
i.value = e;
|
|
84
86
|
};
|
|
85
|
-
(
|
|
87
|
+
(l = f) == null || l.addEventListener("change", t), o(() => {
|
|
86
88
|
var e;
|
|
87
|
-
(e =
|
|
89
|
+
(e = f) == null || e.removeEventListener("change", t);
|
|
88
90
|
});
|
|
89
91
|
}), p(
|
|
90
|
-
() =>
|
|
92
|
+
() => s.value && (!T(a) || !i.value)
|
|
91
93
|
);
|
|
92
94
|
}
|
|
93
95
|
export {
|
|
94
|
-
|
|
96
|
+
x as NumberFlowElement,
|
|
95
97
|
j as NumberFlowGroup,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
D as default,
|
|
99
|
+
O as useCanAnimate
|
|
98
100
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.3.1",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "Maxwell Barvian",
|
|
9
9
|
"email": "max@barvian.me",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"esm-env": "^1.1.4",
|
|
47
|
-
"number-flow": "0.
|
|
47
|
+
"number-flow": "0.4.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@playwright/test": "^1.48.0",
|