@number-flow/vue 0.2.2 → 0.2.4

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