@number-flow/vue 0.2.1 → 0.2.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.d.ts CHANGED
@@ -11,6 +11,24 @@ import { Ref } from 'vue';
11
11
  import { Trend } from 'number-flow';
12
12
  import { Value } from 'number-flow';
13
13
 
14
+ declare const __VLS_component: DefineComponent< {}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
15
+
16
+ declare function __VLS_template(): {
17
+ slots: {
18
+ default?(_: {}): any;
19
+ };
20
+ refs: {};
21
+ attrs: Partial<{}>;
22
+ };
23
+
24
+ declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
25
+
26
+ declare type __VLS_WithTemplateSlots<T, S> = T & {
27
+ new (): {
28
+ $slots: S;
29
+ };
30
+ };
31
+
14
32
  declare const _default: DefineComponent<Props, {
15
33
  el: Ref<NumberFlowElement | undefined, NumberFlowElement | undefined>;
16
34
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
@@ -26,6 +44,8 @@ export { Format }
26
44
 
27
45
  export { NumberFlowElement }
28
46
 
47
+ export declare const NumberFlowGroup: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
48
+
29
49
  declare type Props = Partial<Props_2> & {
30
50
  locales?: Intl.LocalesArgument;
31
51
  format?: Format;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),e=require("number-flow"),d=["trend","continuous","animated","transformTiming","spinTiming","opacityTiming","respectMotionPreference","data-will-change","innerHTML","parts"],c=n.defineComponent({inheritAttrs:!1,__name:"index",props:{transformTiming:{default:()=>e.NumberFlowLite.defaultProps.transformTiming},spinTiming:{default:()=>e.NumberFlowLite.defaultProps.spinTiming},opacityTiming:{default:()=>e.NumberFlowLite.defaultProps.opacityTiming},animated:{type:Boolean,default:()=>e.NumberFlowLite.defaultProps.animated},respectMotionPreference:{type:Boolean,default:()=>e.NumberFlowLite.defaultProps.respectMotionPreference},trend:{type:[Boolean,String],default:()=>e.NumberFlowLite.defaultProps.trend},continuous:{type:Boolean,default:()=>e.NumberFlowLite.defaultProps.continuous},locales:{},format:{},value:{},willChange:{type:Boolean,default:!1}},emits:["animationsstart","animationsfinish"],setup(a,{expose:l,emit:r}){const i=n.ref();l({el:i});const u=r,s=n.computed(()=>new Intl.NumberFormat(a.locales,a.format)),o=n.computed(()=>e.partitionParts(a.value,s.value));return(t,m)=>(n.openBlock(),n.createElementBlock("number-flow-vue",n.mergeProps({ref_key:"el",ref:i},t.$attrs,{trend:t.trend,continuous:t.continuous,animated:t.animated,transformTiming:t.transformTiming,spinTiming:t.spinTiming,opacityTiming:t.opacityTiming,respectMotionPreference:t.respectMotionPreference,"data-will-change":t.willChange?"":void 0,innerHTML:n.unref(e.render)({formatted:o.value.formatted,willChange:t.willChange}),onAnimationsstart:m[0]||(m[0]=f=>u("animationsstart")),onAnimationsfinish:m[1]||(m[1]=f=>u("animationsfinish")),parts:o.value}),null,16,d))}});e.define("number-flow-vue",e.NumberFlowLite);function p({respectMotionPreference:a=!0}={}){const l=n.ref(e.canAnimate),r=n.ref(!1);return n.onMounted(()=>{var i;l.value=e.canAnimate,r.value=((i=e.prefersReducedMotion)==null?void 0:i.matches)??!1}),n.watchEffect(i=>{var s;if(!n.toValue(a))return;const u=({matches:o})=>{r.value=o};(s=e.prefersReducedMotion)==null||s.addEventListener("change",u),i(()=>{var o;(o=e.prefersReducedMotion)==null||o.removeEventListener("change",u)})}),n.computed(()=>l.value&&(!n.toValue(a)||!r.value))}Object.defineProperty(exports,"NumberFlowElement",{enumerable:!0,get:()=>e.NumberFlowLite});exports.default=c;exports.useCanAnimate=p;
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;
package/dist/index.mjs CHANGED
@@ -1,70 +1,95 @@
1
- import { defineComponent as v, ref as f, computed as d, openBlock as T, createElementBlock as h, mergeProps as w, unref as P, onMounted as y, watchEffect as M, toValue as p } from "vue";
2
- import { NumberFlowLite as n, partitionParts as B, render as C, define as b, canAnimate as c, prefersReducedMotion as u } from "number-flow";
3
- import { NumberFlowLite as H } from "number-flow";
4
- const A = ["trend", "continuous", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "innerHTML", "parts"], F = /* @__PURE__ */ v({
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({
5
+ __name: "NumberFlowGroup",
6
+ setup(l) {
7
+ const o = /* @__PURE__ */ new Set();
8
+ let i = !1;
9
+ return y(h, (n, u) => {
10
+ o.add(n), b(
11
+ u,
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);
20
+ }
21
+ // { flush: 'pre' } // default
22
+ ), B(() => {
23
+ o.delete(n);
24
+ });
25
+ }), (n, u) => P(n.$slots, "default");
26
+ }
27
+ }), S = ["manual", "trend", "continuous", "animated", "transformTiming", "spinTiming", "opacityTiming", "respectMotionPreference", "data-will-change", "innerHTML", "parts"], j = /* @__PURE__ */ w({
5
28
  inheritAttrs: !1,
6
29
  __name: "index",
7
30
  props: {
8
- transformTiming: { default: () => n.defaultProps.transformTiming },
9
- spinTiming: { default: () => n.defaultProps.spinTiming },
10
- opacityTiming: { default: () => n.defaultProps.opacityTiming },
11
- animated: { type: Boolean, default: () => n.defaultProps.animated },
12
- respectMotionPreference: { type: Boolean, default: () => n.defaultProps.respectMotionPreference },
13
- trend: { type: [Boolean, String], default: () => n.defaultProps.trend },
14
- continuous: { type: Boolean, default: () => n.defaultProps.continuous },
31
+ transformTiming: { default: () => s.defaultProps.transformTiming },
32
+ spinTiming: { default: () => s.defaultProps.spinTiming },
33
+ opacityTiming: { default: () => s.defaultProps.opacityTiming },
34
+ animated: { type: Boolean, default: () => s.defaultProps.animated },
35
+ respectMotionPreference: { type: Boolean, default: () => s.defaultProps.respectMotionPreference },
36
+ trend: { type: [Boolean, String], default: () => s.defaultProps.trend },
37
+ continuous: { type: Boolean, default: () => s.defaultProps.continuous },
15
38
  locales: {},
16
39
  format: {},
17
40
  value: {},
18
41
  willChange: { type: Boolean, default: !1 }
19
42
  },
20
43
  emits: ["animationsstart", "animationsfinish"],
21
- setup(i, { expose: s, emit: o }) {
22
- const t = f();
23
- s({ el: t });
24
- const r = o, l = d(() => new Intl.NumberFormat(i.locales, i.format)), a = d(() => B(i.value, l.value));
25
- return (e, m) => (T(), h("number-flow-vue", w({
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({
26
49
  ref_key: "el",
27
- ref: t
28
- }, e.$attrs, {
29
- trend: e.trend,
30
- continuous: e.continuous,
31
- animated: e.animated,
32
- transformTiming: e.transformTiming,
33
- spinTiming: e.spinTiming,
34
- opacityTiming: e.opacityTiming,
35
- respectMotionPreference: e.respectMotionPreference,
36
- "data-will-change": e.willChange ? "" : void 0,
37
- innerHTML: P(C)({ formatted: a.value.formatted, willChange: e.willChange }),
38
- onAnimationsstart: m[0] || (m[0] = (g) => r("animationsstart")),
39
- onAnimationsfinish: m[1] || (m[1] = (g) => r("animationsfinish")),
40
- parts: a.value
41
- }), null, 16, A));
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));
42
66
  }
43
67
  });
44
- b("number-flow-vue", n);
45
- function N({
46
- respectMotionPreference: i = !0
68
+ G("number-flow-vue", s);
69
+ function I({
70
+ respectMotionPreference: l = !0
47
71
  } = {}) {
48
- const s = f(c), o = f(!1);
49
- return y(() => {
50
- var t;
51
- s.value = c, o.value = ((t = u) == null ? void 0 : t.matches) ?? !1;
52
- }), M((t) => {
53
- var l;
54
- if (!p(i)) return;
55
- const r = ({ matches: a }) => {
56
- o.value = a;
72
+ const o = d(v), i = d(!1);
73
+ 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;
79
+ const n = ({ matches: e }) => {
80
+ i.value = e;
57
81
  };
58
- (l = u) == null || l.addEventListener("change", r), t(() => {
59
- var a;
60
- (a = u) == null || a.removeEventListener("change", r);
82
+ (u = f) == null || u.addEventListener("change", n), r(() => {
83
+ var e;
84
+ (e = f) == null || e.removeEventListener("change", n);
61
85
  });
62
- }), d(
63
- () => s.value && (!p(i) || !o.value)
86
+ }), p(
87
+ () => o.value && (!g(l) || !i.value)
64
88
  );
65
89
  }
66
90
  export {
67
- H as NumberFlowElement,
68
- F as default,
69
- N as useCanAnimate
91
+ q as NumberFlowElement,
92
+ W as NumberFlowGroup,
93
+ j as default,
94
+ I as useCanAnimate
70
95
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.2.1",
6
+ "version": "0.2.2",
7
7
  "author": {
8
8
  "name": "Maxwell Barvian",
9
9
  "email": "max@barvian.me",