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