geekin-devtoys 0.2.10 → 0.2.12

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.
Files changed (56) hide show
  1. package/lib/GBubble/index.js +2 -2
  2. package/lib/GBubble/index.mjs +143 -166
  3. package/lib/GBubble/style.css +1 -1
  4. package/lib/GBubble.d.ts +1 -0
  5. package/lib/GCount/index.js +1 -1
  6. package/lib/GCount/index.mjs +65 -52
  7. package/lib/GCount.d.ts +1 -0
  8. package/lib/GDialog/index.js +1 -1
  9. package/lib/GDialog/index.mjs +109 -99
  10. package/lib/GDialog/style.css +1 -1
  11. package/lib/GDialog.d.ts +1 -0
  12. package/lib/GPie3D/index.js +1 -0
  13. package/lib/GPie3D/index.mjs +227 -0
  14. package/lib/GPie3D.d.ts +1 -0
  15. package/lib/GPluginVideo/index.js +1 -14
  16. package/lib/GPluginVideo/index.mjs +1431 -3470
  17. package/lib/GPluginVideo.d.ts +1 -0
  18. package/lib/GProgress/index.js +1 -1
  19. package/lib/GProgress/index.mjs +21 -54
  20. package/lib/GProgress/style.css +1 -1
  21. package/lib/GProgress.d.ts +1 -0
  22. package/lib/GScreen/index.js +1 -1
  23. package/lib/GScreen/index.mjs +36 -173
  24. package/lib/GScreen.d.ts +1 -0
  25. package/lib/GTable/index.js +1 -1
  26. package/lib/GTable/index.mjs +135 -1436
  27. package/lib/GTable/style.css +1 -1
  28. package/lib/GTable.d.ts +1 -0
  29. package/lib/GVideo/index.js +2 -7
  30. package/lib/GVideo/index.mjs +125 -6899
  31. package/lib/GVideo/style.css +1 -1
  32. package/lib/GVideo.d.ts +1 -0
  33. package/lib/assets/GPie3D.css +1 -0
  34. package/lib/components/GBubble/index.d.ts +61 -0
  35. package/lib/components/GCount/index.d.ts +39 -0
  36. package/lib/components/GDialog/GDialogMinimizedIcon.d.ts +17 -0
  37. package/lib/components/GDialog/const.d.ts +25 -0
  38. package/lib/components/GDialog/index.d.ts +53 -0
  39. package/lib/components/GDialog/useDialogManager.d.ts +58 -0
  40. package/lib/components/GPie3D/index.d.ts +118 -0
  41. package/lib/components/GPluginVideo/index.d.ts +3 -0
  42. package/lib/components/GProgress/index.d.ts +48 -0
  43. package/lib/components/GScreen/index.d.ts +55 -0
  44. package/lib/components/GTable/index.d.ts +119 -0
  45. package/lib/components/GVideo/index.d.ts +3 -0
  46. package/lib/index/index.js +1 -1
  47. package/lib/index/index.mjs +24 -27
  48. package/lib/index-B1MYKy3L.js +1 -0
  49. package/lib/index-Dxw2pU4z.mjs +106 -0
  50. package/lib/index.d.ts +13 -0
  51. package/package.json +33 -10
  52. package/lib/GPercent/index.js +0 -1
  53. package/lib/GPercent/index.mjs +0 -127
  54. package/lib/GPercent/style.css +0 -1
  55. package/lib/index-BVvzBt8u.mjs +0 -53
  56. package/lib/index-CC5ivGYd.js +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("vue"),J=require("../_plugin-vue_export-helper-BHFhmbuH.js"),K={__name:"index",props:{data:{type:Array,default:()=>[]},config:{type:Object,default:()=>({minRadius:25,maxRadius:100,padding:10,colors:["#1E88E5","#26A69A","#4CAF50","#F57C00","#9C27B0","#FF5722","#607D8B"],textColor:"#FFFFFF"})},animation:{type:Boolean,default:!0}},setup(j){const X=j,S=f.ref(null),A=f.ref(null);let x=null,m=0,y=0;const C={...X.config},P=f.ref(!1),z=f.ref(0),H=f.ref(0),V=f.ref(null);let L=f.ref(-1),l=[];const $=()=>{if(!A.value||!S.value)return;const t=S.value,o=A.value;t.style.width="100%",t.style.height="100%",m=t.clientWidth,y=t.clientHeight,o.width=m,o.height=y,o.style.width=m+"px",o.style.height=y+"px",x=o.getContext("2d"),T(),G()},T=()=>{l=[];const t=X.data,o=t.map(u=>u.value),s=Math.max(...o),r=Math.min(...o),d=s-r;t.forEach((u,e)=>{const M=d>0?(u.value-r)/d:.5,n=C.minRadius+(C.maxRadius-C.minRadius)*M,g=e/t.length*Math.PI*2,R=m/2,i=y/2,a=Math.min(m,y)/3;let c=R+Math.cos(g)*a,h=i+Math.sin(g)*a;c=Math.max(n,Math.min(m-n,c)),h=Math.max(n,Math.min(y-n,h)),l.push({x:c,y:h,radius:n,data:u,color:C.colors[e%C.colors.length],vx:(Math.random()-.5)*.2,vy:(Math.random()-.5)*.2})});const p=1500,F=.2,B=.9;for(let u=0;u<p;u++){const e=l.map(()=>({x:0,y:0}));for(let i=0;i<l.length;i++){const a=l[i];for(let c=i+1;c<l.length;c++){const h=l[c],v=a.x-h.x,Y=a.y-h.y,_=Math.sqrt(v*v+Y*Y),I=a.radius+h.radius+C.padding;if(_<I){const q=(I-_)*F,E=v/_*q,w=Y/_*q;e[i].x+=E,e[i].y+=w,e[c].x-=E,e[c].y-=w}else if(_>0){const q=1/_*F*5,E=v/_*q,w=Y/_*q;e[i].x+=E,e[i].y+=w,e[c].x-=E,e[c].y-=w}}}const M=m/2,n=y/2,g=.01;for(let i=0;i<l.length;i++){const a=l[i],c=M-a.x,h=n-a.y,v=Math.sqrt(c*c+h*h);if(v>0){const Y=v*g,_=c/v*Y,I=h/v*Y;e[i].x+=_,e[i].y+=I}}let R=0;for(let i=0;i<l.length;i++){const a=l[i],c=e[i],h=c.x*B,v=c.y*B,Y=Math.sqrt(h*h+v*v);R+=Y,a.x+=h,a.y+=v,a.x=Math.max(a.radius,Math.min(m-a.radius,a.x)),a.y=Math.max(a.radius,Math.min(y-a.radius,a.y))}if(R<.1)break}for(let u=0;u<l.length;u++){const e=l[u];for(let M=u+1;M<l.length;M++){const n=l[M],g=e.x-n.x,R=e.y-n.y,i=Math.sqrt(g*g+R*R),a=e.radius+n.radius+C.padding;if(i<a){const c=Math.atan2(R,g),h=(a-i)/2;e.x+=Math.cos(c)*h,e.y+=Math.sin(c)*h,n.x-=Math.cos(c)*h,n.y-=Math.sin(c)*h,e.x=Math.max(e.radius,Math.min(m-e.radius,e.x)),e.y=Math.max(e.radius,Math.min(y-e.radius,e.y)),n.x=Math.max(n.radius,Math.min(m-n.radius,n.x)),n.y=Math.max(n.radius,Math.min(y-n.radius,n.y))}}}};let D=null;const G=()=>{x&&(x.clearRect(0,0,m,y),X.animation&&N(),l.forEach((t,o)=>{const{x:s,y:r,radius:d,color:p,data:F}=t;x.beginPath(),x.arc(s,r,d,0,Math.PI*2);const B=x.createRadialGradient(s-d*.3,r-d*.3,0,s,r,d);B.addColorStop(0,p),B.addColorStop(1,p+"40"),x.fillStyle=B,x.fill();const u=m*.2,e=y*.2,M=u-s,n=e-r,g=Math.sqrt(M*M+n*n),R=s+M/g*d*.6,i=r+n/g*d*.6;x.beginPath(),x.arc(R,i,d*.3,0,Math.PI*2),x.fillStyle="rgba(255, 255, 255, 0.1)",x.fill(),x.fillStyle=C.textColor,x.textAlign="center",x.textBaseline="middle";const a=Math.max(10,d/2.5);x.font=`${a}px Arial`;const c=F.name.split(`
2
- `);c.forEach((h,v)=>{const Y=r-(c.length-1)*a/2+v*a;x.fillText(h,s,Y)})}),X.animation&&(D=requestAnimationFrame(G)))},N=()=>{l.forEach(t=>{if(t.x+=t.vx,t.y+=t.vy,t.x-t.radius<0&&(t.x=t.radius,t.vx=-t.vx*.8),t.x+t.radius>m&&(t.x=m-t.radius,t.vx=-t.vx*.8),t.y-t.radius<0&&(t.y=t.radius,t.vy=-t.vy*.8),t.y+t.radius>y&&(t.y=y-t.radius,t.vy=-t.vy*.8),Math.random()<.01){t.vx+=(Math.random()-.5)*.1,t.vy+=(Math.random()-.5)*.1;const o=.3,s=Math.sqrt(t.vx*t.vx+t.vy*t.vy);s>o&&(t.vx=t.vx/s*o,t.vy=t.vy/s*o)}});for(let t=0;t<l.length;t++)for(let o=t+1;o<l.length;o++){const s=l[t],r=l[o],d=s.x-r.x,p=s.y-r.y,F=Math.sqrt(d*d+p*p),B=s.radius+r.radius;if(F<B){const u=Math.atan2(p,d),e=B-F,M=Math.cos(u)*e/2,n=Math.sin(u)*e/2;s.x+=M,s.y+=n,r.x-=M,r.y-=n;const g=s.vx,R=s.vy;s.vx=r.vx*.8,s.vy=r.vy*.8,r.vx=g*.8,r.vy=R*.8}}},O=t=>{if(!A.value)return;const o=A.value.getBoundingClientRect(),s=t.clientX-o.left,r=t.clientY-o.top;let d=-1;for(let p=0;p<l.length;p++){const F=l[p],B=s-F.x,u=r-F.y;if(Math.sqrt(B*B+u*u)<=F.radius){d=p;break}}d!==L.value?(L.value=d,d>=0?(P.value=!0,V.value=l[d].data,W(t)):(P.value=!1,V.value=null)):d>=0&&W(t)},W=t=>{if(S.value){const o=S.value.getBoundingClientRect(),s=120,r=60;z.value=Math.min(t.clientX+10-o.left,o.width-s),H.value=Math.min(t.clientY+10-o.top,o.height-r)}else z.value=t.clientX+10,H.value=t.clientY+10},U=()=>{P.value=!1,V.value=null,L.value=-1};return f.watch(()=>X.data,()=>{T(),G()},{deep:!0}),f.onMounted(()=>{$(),window.addEventListener("resize",$)}),f.onUnmounted(()=>{window.removeEventListener("resize",$),D&&(cancelAnimationFrame(D),D=null)}),(t,o)=>(f.openBlock(),f.createElementBlock("div",{class:"bubble-chart-container",ref_key:"containerRef",ref:S},[f.createElementVNode("canvas",{ref_key:"canvasRef",ref:A,onMousemove:O,onMouseleave:U},null,544),P.value?(f.openBlock(),f.createElementBlock("div",{key:0,class:"bubble-tooltip",style:f.normalizeStyle({left:`${z.value}px`,top:`${H.value}px`})},[f.renderSlot(t.$slots,"tooltip",{data:V.value},void 0,!0)],4)):f.createCommentVNode("",!0)],512))}},k=J._export_sfc(K,[["__scopeId","data-v-6eab8e5c"]]);k.install=j=>{j.component(k.name,k)};exports.GBubble=k;exports.default=k;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("vue"),J=require("../_plugin-vue_export-helper-BHFhmbuH.js"),K=f.defineComponent({__name:"index",props:{data:{default:()=>[]},config:{default:()=>({minRadius:25,maxRadius:100,padding:10,colors:["#1E88E5","#26A69A","#4CAF50","#F57C00","#9C27B0","#FF5722","#607D8B"],textColor:"#FFFFFF"})},animation:{type:Boolean,default:!0}},setup(I){const _=I,X=f.ref(null),S=f.ref(null);let j=null,m=0,y=0;const Y={..._.config},k=f.ref(!1),z=f.ref(0),H=f.ref(0),P=f.ref(null);let L=f.ref(-1),c=[],V=null;const $=()=>{if(!S.value||!X.value)return;const t=X.value,n=S.value;t.style.width="100%",t.style.height="100%",m=t.clientWidth,y=t.clientHeight,n.width=m,n.height=y,n.style.width=m+"px",n.style.height=y+"px",j=n.getContext("2d"),T(),G()},T=()=>{c=[];const t=_.data,n=t.map(d=>d.value),h=Math.max(...n),l=Math.min(...n),u=h-l;t.forEach((d,e)=>{const M=u>0?(d.value-l)/u:.5,a=Y.minRadius+(Y.maxRadius-Y.minRadius)*M,p=e/t.length*Math.PI*2,R=m/2,s=y/2,o=Math.min(m,y)/3;let i=R+Math.cos(p)*o,r=s+Math.sin(p)*o;i=Math.max(a,Math.min(m-a,i)),r=Math.max(a,Math.min(y-a,r)),c.push({x:i,y:r,radius:a,data:d,color:Y.colors[e%Y.colors.length],vx:(Math.random()-.5)*.2,vy:(Math.random()-.5)*.2,value:d.value})});const v=1500,g=.2,B=.9;for(let d=0;d<v;d++){const e=c.map(()=>({x:0,y:0}));for(let s=0;s<c.length;s++){const o=c[s];for(let i=s+1;i<c.length;i++){const r=c[i],x=o.x-r.x,C=o.y-r.y,F=Math.sqrt(x*x+C*C),D=o.radius+r.radius+Y.padding;if(F<D){const q=(D-F)*g,A=x/F*q,E=C/F*q;e[s].x+=A,e[s].y+=E,e[i].x-=A,e[i].y-=E}else if(F>0){const q=1/F*g*5,A=x/F*q,E=C/F*q;e[s].x+=A,e[s].y+=E,e[i].x-=A,e[i].y-=E}}}const M=m/2,a=y/2,p=.01;for(let s=0;s<c.length;s++){const o=c[s],i=M-o.x,r=a-o.y,x=Math.sqrt(i*i+r*r);if(x>0){const C=x*p,F=i/x*C,D=r/x*C;e[s].x+=F,e[s].y+=D}}let R=0;for(let s=0;s<c.length;s++){const o=c[s],i=e[s],r=i.x*B,x=i.y*B,C=Math.sqrt(r*r+x*x);R+=C,o.x+=r,o.y+=x,o.x=Math.max(o.radius,Math.min(m-o.radius,o.x)),o.y=Math.max(o.radius,Math.min(y-o.radius,o.y))}if(R<.1)break}for(let d=0;d<c.length;d++){const e=c[d];for(let M=d+1;M<c.length;M++){const a=c[M],p=e.x-a.x,R=e.y-a.y,s=Math.sqrt(p*p+R*R),o=e.radius+a.radius+Y.padding;if(s<o){const i=Math.atan2(R,p),r=(o-s)/2;e.x+=Math.cos(i)*r,e.y+=Math.sin(i)*r,a.x-=Math.cos(i)*r,a.y-=Math.sin(i)*r,e.x=Math.max(e.radius,Math.min(m-e.radius,e.x)),e.y=Math.max(e.radius,Math.min(y-e.radius,e.y)),a.x=Math.max(a.radius,Math.min(m-a.radius,a.x)),a.y=Math.max(a.radius,Math.min(y-a.radius,a.y))}}}},G=()=>{if(!j)return;const t=j;t.clearRect(0,0,m,y),_.animation&&N(),c.forEach((n,h)=>{const{x:l,y:u,radius:v,color:g}=n;t.beginPath(),t.arc(l,u,v,0,Math.PI*2);const B=t.createRadialGradient(l-v*.3,u-v*.3,0,l,u,v);B.addColorStop(0,g),B.addColorStop(1,g+"40"),t.fillStyle=B,t.fill();const d=m*.2,e=y*.2,M=d-l,a=e-u,p=Math.sqrt(M*M+a*a),R=l+M/p*v*.6,s=u+a/p*v*.6;t.beginPath(),t.arc(R,s,v*.3,0,Math.PI*2),t.fillStyle="rgba(255, 255, 255, 0.1)",t.fill(),t.fillStyle=Y.textColor??"",t.textAlign="center",t.textBaseline="middle";const o=Math.max(10,v/2.5);t.font=`${o}px Arial`;const i=n.data.name.split(`
2
+ `);i.forEach((r,x)=>{const C=u-(i.length-1)*o/2+x*o;t.fillText(r,l,C)})}),_.animation&&(V=requestAnimationFrame(G))},N=()=>{c.forEach(t=>{if(t.x+=t.vx,t.y+=t.vy,t.x-t.radius<0&&(t.x=t.radius,t.vx=-t.vx*.8),t.x+t.radius>m&&(t.x=m-t.radius,t.vx=-t.vx*.8),t.y-t.radius<0&&(t.y=t.radius,t.vy=-t.vy*.8),t.y+t.radius>y&&(t.y=y-t.radius,t.vy=-t.vy*.8),Math.random()<.01){t.vx+=(Math.random()-.5)*.1,t.vy+=(Math.random()-.5)*.1;const n=.3,h=Math.sqrt(t.vx*t.vx+t.vy*t.vy);h>n&&(t.vx=t.vx/h*n,t.vy=t.vy/h*n)}});for(let t=0;t<c.length;t++)for(let n=t+1;n<c.length;n++){const h=c[t],l=c[n],u=h.x-l.x,v=h.y-l.y,g=Math.sqrt(u*u+v*v),B=h.radius+l.radius;if(g<B){const d=Math.atan2(v,u),e=B-g,M=Math.cos(d)*e/2,a=Math.sin(d)*e/2;h.x+=M,h.y+=a,l.x-=M,l.y-=a;const p=h.vx,R=h.vy;h.vx=l.vx*.8,h.vy=l.vy*.8,l.vx=p*.8,l.vy=R*.8}}},O=t=>{if(!S.value)return;const n=S.value.getBoundingClientRect(),h=t.clientX-n.left,l=t.clientY-n.top;let u=-1;for(let v=0;v<c.length;v++){const g=c[v],B=h-g.x,d=l-g.y;if(Math.sqrt(B*B+d*d)<=g.radius){u=v;break}}u!==L.value?(L.value=u,u>=0?(k.value=!0,P.value=c[u].data,W(t)):(k.value=!1,P.value=null)):u>=0&&W(t)},W=t=>{if(X.value){const n=X.value.getBoundingClientRect(),h=120,l=60;z.value=Math.min(t.clientX+10-n.left,n.width-h),H.value=Math.min(t.clientY+10-n.top,n.height-l)}else z.value=t.clientX+10,H.value=t.clientY+10},U=()=>{k.value=!1,P.value=null,L.value=-1};return f.watch(()=>_.data,()=>{T(),G()},{deep:!0}),f.onMounted(()=>{$(),window.addEventListener("resize",$)}),f.onUnmounted(()=>{window.removeEventListener("resize",$),V&&(cancelAnimationFrame(V),V=null)}),(t,n)=>(f.openBlock(),f.createElementBlock("div",{class:"bubble-chart-container",ref_key:"containerRef",ref:X},[f.createElementVNode("canvas",{ref_key:"canvasRef",ref:S,onMousemove:O,onMouseleave:U},null,544),k.value?(f.openBlock(),f.createElementBlock("div",{key:0,class:"bubble-tooltip",style:f.normalizeStyle({left:`${z.value}px`,top:`${H.value}px`})},[f.renderSlot(t.$slots,"tooltip",{data:P.value},void 0,!0)],4)):f.createCommentVNode("",!0)],512))}}),w=J._export_sfc(K,[["__scopeId","data-v-f39dd155"]]);w.install=I=>{I.component(w.name,w)};exports.GBubble=w;exports.default=w;
@@ -1,233 +1,210 @@
1
- import { ref as X, watch as Q, onMounted as Z, onUnmounted as b, createElementBlock as T, openBlock as O, createElementVNode as tt, createCommentVNode as nt, normalizeStyle as et, renderSlot as at } from "vue";
2
- import { _ as ot } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
3
- const st = {
1
+ import { defineComponent as Q, ref as Y, watch as Z, onMounted as b, onUnmounted as tt, createElementBlock as T, openBlock as U, createElementVNode as nt, createCommentVNode as et, normalizeStyle as at, renderSlot as ot } from "vue";
2
+ import { _ as st } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
3
+ const it = /* @__PURE__ */ Q({
4
4
  __name: "index",
5
5
  props: {
6
- /**
7
- * @description 要展示的数据项数组
8
- * @version 0.1.6
9
- * @default []
10
- */
11
- data: {
12
- type: Array,
13
- default: () => []
14
- },
15
- /**
16
- * @description 自定义气泡样式配置
17
- * @version 0.1.6
18
- * @default {}
19
- */
20
- config: {
21
- type: Object,
22
- default: () => ({
23
- minRadius: 25,
24
- maxRadius: 100,
25
- padding: 10,
26
- colors: ["#1E88E5", "#26A69A", "#4CAF50", "#F57C00", "#9C27B0", "#FF5722", "#607D8B"],
27
- textColor: "#FFFFFF"
28
- })
29
- },
30
- /**
31
- * @description 是否开启气泡图的动画效果
32
- * @version 0.1.6
33
- * @default true
34
- */
35
- animation: {
36
- type: Boolean,
37
- default: !0
38
- }
6
+ data: { default: () => [] },
7
+ config: { default: () => ({
8
+ minRadius: 25,
9
+ maxRadius: 100,
10
+ padding: 10,
11
+ colors: ["#1E88E5", "#26A69A", "#4CAF50", "#F57C00", "#9C27B0", "#FF5722", "#607D8B"],
12
+ textColor: "#FFFFFF"
13
+ }) },
14
+ animation: { type: Boolean, default: !0 }
39
15
  },
40
- setup(V) {
41
- const A = V, _ = X(null), S = X(null);
42
- let x = null, f = 0, m = 0;
43
- const C = {
44
- ...A.config
45
- }, k = X(!1), j = X(0), z = X(0), D = X(null);
46
- let L = X(-1), l = [];
47
- const $ = () => {
48
- if (!S.value || !_.value) return;
49
- const t = _.value, o = S.value;
50
- t.style.width = "100%", t.style.height = "100%", f = t.clientWidth, m = t.clientHeight, o.width = f, o.height = m, o.style.width = f + "px", o.style.height = m + "px", x = o.getContext("2d"), G(), H();
16
+ setup(P) {
17
+ const X = P, _ = Y(null), A = Y(null);
18
+ let V = null, f = 0, m = 0;
19
+ const F = {
20
+ ...X.config
21
+ }, q = Y(!1), z = Y(0), L = Y(0), k = Y(null);
22
+ let $ = Y(-1), c = [], D = null;
23
+ const j = () => {
24
+ if (!A.value || !_.value) return;
25
+ const t = _.value, e = A.value;
26
+ t.style.width = "100%", t.style.height = "100%", f = t.clientWidth, m = t.clientHeight, e.width = f, e.height = m, e.style.width = f + "px", e.style.height = m + "px", V = e.getContext("2d"), G(), H();
51
27
  }, G = () => {
52
- l = [];
53
- const t = A.data, o = t.map((u) => u.value), s = Math.max(...o), r = Math.min(...o), d = s - r;
54
- t.forEach((u, n) => {
55
- const y = d > 0 ? (u.value - r) / d : 0.5, e = C.minRadius + (C.maxRadius - C.minRadius) * y, p = n / t.length * Math.PI * 2, B = f / 2, i = m / 2, a = Math.min(f, m) / 3;
56
- let c = B + Math.cos(p) * a, h = i + Math.sin(p) * a;
57
- c = Math.max(e, Math.min(f - e, c)), h = Math.max(e, Math.min(m - e, h)), l.push({
58
- x: c,
59
- y: h,
60
- radius: e,
61
- data: u,
62
- color: C.colors[n % C.colors.length],
28
+ c = [];
29
+ const t = X.data, e = t.map((d) => d.value), h = Math.max(...e), l = Math.min(...e), u = h - l;
30
+ t.forEach((d, n) => {
31
+ const y = u > 0 ? (d.value - l) / u : 0.5, a = F.minRadius + (F.maxRadius - F.minRadius) * y, M = n / t.length * Math.PI * 2, B = f / 2, s = m / 2, o = Math.min(f, m) / 3;
32
+ let i = B + Math.cos(M) * o, r = s + Math.sin(M) * o;
33
+ i = Math.max(a, Math.min(f - a, i)), r = Math.max(a, Math.min(m - a, r)), c.push({
34
+ x: i,
35
+ y: r,
36
+ radius: a,
37
+ data: d,
38
+ color: F.colors[n % F.colors.length],
63
39
  // 随机初始速度(更缓慢移动)
64
40
  vx: (Math.random() - 0.5) * 0.2,
65
- vy: (Math.random() - 0.5) * 0.2
41
+ vy: (Math.random() - 0.5) * 0.2,
42
+ value: d.value
66
43
  });
67
44
  });
68
- const M = 1500, R = 0.2, g = 0.9;
69
- for (let u = 0; u < M; u++) {
70
- const n = l.map(() => ({ x: 0, y: 0 }));
71
- for (let i = 0; i < l.length; i++) {
72
- const a = l[i];
73
- for (let c = i + 1; c < l.length; c++) {
74
- const h = l[c], v = a.x - h.x, F = a.y - h.y, Y = Math.sqrt(v * v + F * F), P = a.radius + h.radius + C.padding;
75
- if (Y < P) {
76
- const w = (P - Y) * R, E = v / Y * w, q = F / Y * w;
77
- n[i].x += E, n[i].y += q, n[c].x -= E, n[c].y -= q;
78
- } else if (Y > 0) {
79
- const w = 1 / Y * R * 5, E = v / Y * w, q = F / Y * w;
80
- n[i].x += E, n[i].y += q, n[c].x -= E, n[c].y -= q;
45
+ const x = 1500, p = 0.2, g = 0.9;
46
+ for (let d = 0; d < x; d++) {
47
+ const n = c.map(() => ({ x: 0, y: 0 }));
48
+ for (let s = 0; s < c.length; s++) {
49
+ const o = c[s];
50
+ for (let i = s + 1; i < c.length; i++) {
51
+ const r = c[i], v = o.x - r.x, R = o.y - r.y, C = Math.sqrt(v * v + R * R), I = o.radius + r.radius + F.padding;
52
+ if (C < I) {
53
+ const S = (I - C) * p, w = v / C * S, E = R / C * S;
54
+ n[s].x += w, n[s].y += E, n[i].x -= w, n[i].y -= E;
55
+ } else if (C > 0) {
56
+ const S = 1 / C * p * 5, w = v / C * S, E = R / C * S;
57
+ n[s].x += w, n[s].y += E, n[i].x -= w, n[i].y -= E;
81
58
  }
82
59
  }
83
60
  }
84
- const y = f / 2, e = m / 2, p = 0.01;
85
- for (let i = 0; i < l.length; i++) {
86
- const a = l[i], c = y - a.x, h = e - a.y, v = Math.sqrt(c * c + h * h);
61
+ const y = f / 2, a = m / 2, M = 0.01;
62
+ for (let s = 0; s < c.length; s++) {
63
+ const o = c[s], i = y - o.x, r = a - o.y, v = Math.sqrt(i * i + r * r);
87
64
  if (v > 0) {
88
- const F = v * p, Y = c / v * F, P = h / v * F;
89
- n[i].x += Y, n[i].y += P;
65
+ const R = v * M, C = i / v * R, I = r / v * R;
66
+ n[s].x += C, n[s].y += I;
90
67
  }
91
68
  }
92
69
  let B = 0;
93
- for (let i = 0; i < l.length; i++) {
94
- const a = l[i], c = n[i], h = c.x * g, v = c.y * g, F = Math.sqrt(h * h + v * v);
95
- B += F, a.x += h, a.y += v, a.x = Math.max(a.radius, Math.min(f - a.radius, a.x)), a.y = Math.max(a.radius, Math.min(m - a.radius, a.y));
70
+ for (let s = 0; s < c.length; s++) {
71
+ const o = c[s], i = n[s], r = i.x * g, v = i.y * g, R = Math.sqrt(r * r + v * v);
72
+ B += R, o.x += r, o.y += v, o.x = Math.max(o.radius, Math.min(f - o.radius, o.x)), o.y = Math.max(o.radius, Math.min(m - o.radius, o.y));
96
73
  }
97
74
  if (B < 0.1)
98
75
  break;
99
76
  }
100
- for (let u = 0; u < l.length; u++) {
101
- const n = l[u];
102
- for (let y = u + 1; y < l.length; y++) {
103
- const e = l[y], p = n.x - e.x, B = n.y - e.y, i = Math.sqrt(p * p + B * B), a = n.radius + e.radius + C.padding;
104
- if (i < a) {
105
- const c = Math.atan2(B, p), h = (a - i) / 2;
106
- n.x += Math.cos(c) * h, n.y += Math.sin(c) * h, e.x -= Math.cos(c) * h, e.y -= Math.sin(c) * h, n.x = Math.max(
77
+ for (let d = 0; d < c.length; d++) {
78
+ const n = c[d];
79
+ for (let y = d + 1; y < c.length; y++) {
80
+ const a = c[y], M = n.x - a.x, B = n.y - a.y, s = Math.sqrt(M * M + B * B), o = n.radius + a.radius + F.padding;
81
+ if (s < o) {
82
+ const i = Math.atan2(B, M), r = (o - s) / 2;
83
+ n.x += Math.cos(i) * r, n.y += Math.sin(i) * r, a.x -= Math.cos(i) * r, a.y -= Math.sin(i) * r, n.x = Math.max(
107
84
  n.radius,
108
85
  Math.min(f - n.radius, n.x)
109
86
  ), n.y = Math.max(
110
87
  n.radius,
111
88
  Math.min(m - n.radius, n.y)
112
- ), e.x = Math.max(
113
- e.radius,
114
- Math.min(f - e.radius, e.x)
115
- ), e.y = Math.max(
116
- e.radius,
117
- Math.min(m - e.radius, e.y)
89
+ ), a.x = Math.max(
90
+ a.radius,
91
+ Math.min(f - a.radius, a.x)
92
+ ), a.y = Math.max(
93
+ a.radius,
94
+ Math.min(m - a.radius, a.y)
118
95
  );
119
96
  }
120
97
  }
121
98
  }
122
- };
123
- let I = null;
124
- const H = () => {
125
- x && (x.clearRect(0, 0, f, m), A.animation && U(), l.forEach((t, o) => {
126
- const { x: s, y: r, radius: d, color: M, data: R } = t;
127
- x.beginPath(), x.arc(s, r, d, 0, Math.PI * 2);
128
- const g = x.createRadialGradient(
129
- s - d * 0.3,
130
- r - d * 0.3,
99
+ }, H = () => {
100
+ if (!V) return;
101
+ const t = V;
102
+ t.clearRect(0, 0, f, m), X.animation && J(), c.forEach((e, h) => {
103
+ const { x: l, y: u, radius: x, color: p } = e;
104
+ t.beginPath(), t.arc(l, u, x, 0, Math.PI * 2);
105
+ const g = t.createRadialGradient(
106
+ l - x * 0.3,
107
+ u - x * 0.3,
131
108
  0,
132
109
  // 渐变中心(稍微偏移,增加立体感)
133
- s,
134
- r,
135
- d
110
+ l,
111
+ u,
112
+ x
136
113
  // 渐变边缘
137
114
  );
138
- g.addColorStop(0, M), g.addColorStop(1, M + "40"), x.fillStyle = g, x.fill();
139
- const u = f * 0.2, n = m * 0.2, y = u - s, e = n - r, p = Math.sqrt(y * y + e * e), B = s + y / p * d * 0.6, i = r + e / p * d * 0.6;
140
- x.beginPath(), x.arc(B, i, d * 0.3, 0, Math.PI * 2), x.fillStyle = "rgba(255, 255, 255, 0.1)", x.fill(), x.fillStyle = C.textColor, x.textAlign = "center", x.textBaseline = "middle";
141
- const a = Math.max(10, d / 2.5);
142
- x.font = `${a}px Arial`;
143
- const c = R.name.split(`
115
+ g.addColorStop(0, p), g.addColorStop(1, p + "40"), t.fillStyle = g, t.fill();
116
+ const d = f * 0.2, n = m * 0.2, y = d - l, a = n - u, M = Math.sqrt(y * y + a * a), B = l + y / M * x * 0.6, s = u + a / M * x * 0.6;
117
+ t.beginPath(), t.arc(B, s, x * 0.3, 0, Math.PI * 2), t.fillStyle = "rgba(255, 255, 255, 0.1)", t.fill(), t.fillStyle = F.textColor ?? "", t.textAlign = "center", t.textBaseline = "middle";
118
+ const o = Math.max(10, x / 2.5);
119
+ t.font = `${o}px Arial`;
120
+ const i = e.data.name.split(`
144
121
  `);
145
- c.forEach((h, v) => {
146
- const F = r - (c.length - 1) * a / 2 + v * a;
147
- x.fillText(h, s, F);
122
+ i.forEach((r, v) => {
123
+ const R = u - (i.length - 1) * o / 2 + v * o;
124
+ t.fillText(r, l, R);
148
125
  });
149
- }), A.animation && (I = requestAnimationFrame(H)));
150
- }, U = () => {
151
- l.forEach((t) => {
126
+ }), X.animation && (D = requestAnimationFrame(H));
127
+ }, J = () => {
128
+ c.forEach((t) => {
152
129
  if (t.x += t.vx, t.y += t.vy, t.x - t.radius < 0 && (t.x = t.radius, t.vx = -t.vx * 0.8), t.x + t.radius > f && (t.x = f - t.radius, t.vx = -t.vx * 0.8), t.y - t.radius < 0 && (t.y = t.radius, t.vy = -t.vy * 0.8), t.y + t.radius > m && (t.y = m - t.radius, t.vy = -t.vy * 0.8), Math.random() < 0.01) {
153
130
  t.vx += (Math.random() - 0.5) * 0.1, t.vy += (Math.random() - 0.5) * 0.1;
154
- const o = 0.3, s = Math.sqrt(t.vx * t.vx + t.vy * t.vy);
155
- s > o && (t.vx = t.vx / s * o, t.vy = t.vy / s * o);
131
+ const e = 0.3, h = Math.sqrt(t.vx * t.vx + t.vy * t.vy);
132
+ h > e && (t.vx = t.vx / h * e, t.vy = t.vy / h * e);
156
133
  }
157
134
  });
158
- for (let t = 0; t < l.length; t++)
159
- for (let o = t + 1; o < l.length; o++) {
160
- const s = l[t], r = l[o], d = s.x - r.x, M = s.y - r.y, R = Math.sqrt(d * d + M * M), g = s.radius + r.radius;
161
- if (R < g) {
162
- const u = Math.atan2(M, d), n = g - R, y = Math.cos(u) * n / 2, e = Math.sin(u) * n / 2;
163
- s.x += y, s.y += e, r.x -= y, r.y -= e;
164
- const p = s.vx, B = s.vy;
165
- s.vx = r.vx * 0.8, s.vy = r.vy * 0.8, r.vx = p * 0.8, r.vy = B * 0.8;
135
+ for (let t = 0; t < c.length; t++)
136
+ for (let e = t + 1; e < c.length; e++) {
137
+ const h = c[t], l = c[e], u = h.x - l.x, x = h.y - l.y, p = Math.sqrt(u * u + x * x), g = h.radius + l.radius;
138
+ if (p < g) {
139
+ const d = Math.atan2(x, u), n = g - p, y = Math.cos(d) * n / 2, a = Math.sin(d) * n / 2;
140
+ h.x += y, h.y += a, l.x -= y, l.y -= a;
141
+ const M = h.vx, B = h.vy;
142
+ h.vx = l.vx * 0.8, h.vy = l.vy * 0.8, l.vx = M * 0.8, l.vy = B * 0.8;
166
143
  }
167
144
  }
168
- }, J = (t) => {
169
- if (!S.value) return;
170
- const o = S.value.getBoundingClientRect(), s = t.clientX - o.left, r = t.clientY - o.top;
171
- let d = -1;
172
- for (let M = 0; M < l.length; M++) {
173
- const R = l[M], g = s - R.x, u = r - R.y;
174
- if (Math.sqrt(g * g + u * u) <= R.radius) {
175
- d = M;
145
+ }, K = (t) => {
146
+ if (!A.value) return;
147
+ const e = A.value.getBoundingClientRect(), h = t.clientX - e.left, l = t.clientY - e.top;
148
+ let u = -1;
149
+ for (let x = 0; x < c.length; x++) {
150
+ const p = c[x], g = h - p.x, d = l - p.y;
151
+ if (Math.sqrt(g * g + d * d) <= p.radius) {
152
+ u = x;
176
153
  break;
177
154
  }
178
155
  }
179
- d !== L.value ? (L.value = d, d >= 0 ? (k.value = !0, D.value = l[d].data, N(t)) : (k.value = !1, D.value = null)) : d >= 0 && N(t);
156
+ u !== $.value ? ($.value = u, u >= 0 ? (q.value = !0, k.value = c[u].data, N(t)) : (q.value = !1, k.value = null)) : u >= 0 && N(t);
180
157
  }, N = (t) => {
181
158
  if (_.value) {
182
- const o = _.value.getBoundingClientRect(), s = 120, r = 60;
183
- j.value = Math.min(
184
- t.clientX + 10 - o.left,
185
- o.width - s
186
- ), z.value = Math.min(
187
- t.clientY + 10 - o.top,
188
- o.height - r
159
+ const e = _.value.getBoundingClientRect(), h = 120, l = 60;
160
+ z.value = Math.min(
161
+ t.clientX + 10 - e.left,
162
+ e.width - h
163
+ ), L.value = Math.min(
164
+ t.clientY + 10 - e.top,
165
+ e.height - l
189
166
  );
190
167
  } else
191
- j.value = t.clientX + 10, z.value = t.clientY + 10;
192
- }, K = () => {
193
- k.value = !1, D.value = null, L.value = -1;
168
+ z.value = t.clientX + 10, L.value = t.clientY + 10;
169
+ }, O = () => {
170
+ q.value = !1, k.value = null, $.value = -1;
194
171
  };
195
- return Q(
196
- () => A.data,
172
+ return Z(
173
+ () => X.data,
197
174
  () => {
198
175
  G(), H();
199
176
  },
200
177
  { deep: !0 }
201
- ), Z(() => {
202
- $(), window.addEventListener("resize", $);
203
- }), b(() => {
204
- window.removeEventListener("resize", $), I && (cancelAnimationFrame(I), I = null);
205
- }), (t, o) => (O(), T("div", {
178
+ ), b(() => {
179
+ j(), window.addEventListener("resize", j);
180
+ }), tt(() => {
181
+ window.removeEventListener("resize", j), D && (cancelAnimationFrame(D), D = null);
182
+ }), (t, e) => (U(), T("div", {
206
183
  class: "bubble-chart-container",
207
184
  ref_key: "containerRef",
208
185
  ref: _
209
186
  }, [
210
- tt("canvas", {
187
+ nt("canvas", {
211
188
  ref_key: "canvasRef",
212
- ref: S,
213
- onMousemove: J,
214
- onMouseleave: K
189
+ ref: A,
190
+ onMousemove: K,
191
+ onMouseleave: O
215
192
  }, null, 544),
216
- k.value ? (O(), T("div", {
193
+ q.value ? (U(), T("div", {
217
194
  key: 0,
218
195
  class: "bubble-tooltip",
219
- style: et({
220
- left: `${j.value}px`,
221
- top: `${z.value}px`
196
+ style: at({
197
+ left: `${z.value}px`,
198
+ top: `${L.value}px`
222
199
  })
223
200
  }, [
224
- at(t.$slots, "tooltip", { data: D.value }, void 0, !0)
225
- ], 4)) : nt("", !0)
201
+ ot(t.$slots, "tooltip", { data: k.value }, void 0, !0)
202
+ ], 4)) : et("", !0)
226
203
  ], 512));
227
204
  }
228
- }, W = /* @__PURE__ */ ot(st, [["__scopeId", "data-v-6eab8e5c"]]);
229
- W.install = (V) => {
230
- V.component(W.name, W);
205
+ }), W = /* @__PURE__ */ st(it, [["__scopeId", "data-v-f39dd155"]]);
206
+ W.install = (P) => {
207
+ P.component(W.name, W);
231
208
  };
232
209
  export {
233
210
  W as GBubble,
@@ -1 +1 @@
1
- .bubble-chart-container[data-v-6eab8e5c]{position:relative;width:100%;height:100%;overflow:hidden}canvas[data-v-6eab8e5c]{display:block;width:100%;height:100%}.bubble-tooltip[data-v-6eab8e5c]{position:absolute;background:#000c;color:#fff;padding:8px 12px;border-radius:4px;font-size:14px;pointer-events:none;z-index:10;min-width:80px;box-shadow:0 2px 8px #0000004d;border:1px solid #1982e0}
1
+ .bubble-chart-container[data-v-f39dd155]{position:relative;width:100%;height:100%;overflow:hidden}canvas[data-v-f39dd155]{display:block;width:100%;height:100%}.bubble-tooltip[data-v-f39dd155]{position:absolute;background:#000c;color:#fff;padding:8px 12px;border-radius:4px;font-size:14px;pointer-events:none;z-index:10;min-width:80px;box-shadow:0 2px 8px #0000004d;border:1px solid #1982e0}
@@ -0,0 +1 @@
1
+ export {}
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),i=t.defineComponent({name:"GCount",__name:"index",props:{to:{},from:{default:0},direction:{default:"up"},delay:{default:0},duration:{default:2},className:{default:""},startWhen:{type:Boolean,default:!0},separator:{default:""},onStart:{},onEnd:{}},setup(p){const e=p,o=t.useTemplateRef("elementRef"),r=t.ref(e.direction==="down"?e.to:e.from),c=t.ref(!1),n=t.ref(null),m=t.ref(!1);let s=null;const h=t.computed(()=>20+40*(1/e.duration)),F=t.computed(()=>100*(1/e.duration));let u=0;const _=a=>{const l={useGrouping:!!e.separator,minimumFractionDigits:0,maximumFractionDigits:0},f=Intl.NumberFormat("en-US",l).format(Number(a.toFixed(0)));return e.separator?f.replace(/,/g,e.separator):f},d=()=>{o.value&&(o.value.textContent=_(r.value))},v=a=>{const l=e.direction==="down"?e.from:e.to,f=r.value,b=l-f,S=b*F.value,I=u*h.value,M=S-I;u+=M*.016,r.value+=u*.016,d(),Math.abs(b)>.01||Math.abs(u)>.01?n.value=requestAnimationFrame(v):(r.value=l,d(),n.value=null,e.onEnd&&e.onEnd())},g=()=>{m.value||!c.value||!e.startWhen||(m.value=!0,e.onStart&&e.onStart(),setTimeout(()=>{u=0,n.value=requestAnimationFrame(v)},e.delay*1e3))},w=()=>{o.value&&(s=new IntersectionObserver(([a])=>{a.isIntersecting&&!c.value&&(c.value=!0,g())},{threshold:0,rootMargin:"0px"}),s.observe(o.value))},y=()=>{n.value&&(cancelAnimationFrame(n.value),n.value=null),s&&(s.disconnect(),s=null)};return t.watch([()=>e.from,()=>e.to,()=>e.direction],()=>{r.value=e.direction==="down"?e.to:e.from,d(),m.value=!1},{immediate:!0}),t.watch(()=>e.startWhen,()=>{e.startWhen&&c.value&&!m.value&&g()}),t.onMounted(()=>{d(),w()}),t.onUnmounted(()=>{y()}),(a,l)=>(t.openBlock(),t.createElementBlock("span",{ref_key:"elementRef",ref:o,class:t.normalizeClass(a.className)},null,2))}});i.install=p=>{p.component(i.name,i)};exports.GCount=i;exports.default=i;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),d=t.defineComponent({__name:"index",props:{num:{default:0},delay:{default:0},duration:{default:2},className:{default:""},startWhen:{type:Boolean,default:!0},separator:{default:""},decimalPlaces:{default:0}},emits:["start","end"],setup(x,{expose:S,emit:C}){const e=x,A=C;S({reset:O,start:M});const a=t.useTemplateRef("elementRef"),I=()=>0,u=t.ref(I()),s=t.ref(!1),c=t.ref(!1);let l=null,m=null,r=null,f=!1,v=0,p=0,o=0;const N=n=>1-Math.pow(1-n,3),T=n=>{const i=Math.max(0,Math.floor(e.decimalPlaces)),_={useGrouping:!!e.separator,minimumFractionDigits:i,maximumFractionDigits:i},g=Number(n.toFixed(i)),w=Intl.NumberFormat("en-US",_).format(g);return e.separator?w.replace(/,/g,e.separator):w},h=()=>{a.value&&(a.value.textContent=T(u.value))},y=()=>{l!==null&&(cancelAnimationFrame(l),l=null)},b=()=>{m!==null&&(clearTimeout(m),m=null)},F=n=>{if(!f)return;o||(o=n);const i=(n-o)/1e3,_=Math.max(.001,e.duration),g=Math.min(1,i/_),w=N(g);u.value=v+(p-v)*w,h(),g<1?l=requestAnimationFrame(F):(u.value=p,h(),l=null,A("end"))};function M(){c.value||!s.value||!e.startWhen||(c.value=!0,A("start"),b(),m=setTimeout(()=>{m=null,f&&(v=u.value,p=e.num,o=0,l=requestAnimationFrame(F))},e.delay*1e3))}function W(){!f||!s.value||!e.startWhen||(y(),b(),v=u.value,p=e.num,o=0,l=requestAnimationFrame(F))}function O(){y(),b(),o=0,c.value=!1,u.value=I(),h()}const R=()=>{a.value&&(r=new IntersectionObserver(([n])=>{n.isIntersecting&&!s.value&&(s.value=!0,M(),r&&a.value&&r.unobserve(a.value))},{threshold:0,rootMargin:"0px"}),r.observe(a.value))},q=()=>{f=!1,y(),b(),r&&(r.disconnect(),r=null)};return t.watch(()=>e.num,()=>{c.value?W():s.value&&e.startWhen&&M()}),t.watch(()=>e.startWhen,()=>{e.startWhen&&s.value&&!c.value&&M()}),t.onMounted(()=>{f=!0,h(),R()}),t.onUnmounted(()=>{q()}),(n,i)=>(t.openBlock(),t.createElementBlock("span",{ref_key:"elementRef",ref:a,class:t.normalizeClass(n.className)},null,2))}});d.install=x=>{x.component(d.name,d)};exports.GCount=d;exports.default=d;
@@ -1,79 +1,92 @@
1
- import { defineComponent as S, useTemplateRef as E, ref as f, computed as b, watch as F, onMounted as M, onUnmounted as R, createElementBlock as W, openBlock as k, normalizeClass as B } from "vue";
2
- const p = /* @__PURE__ */ S({
3
- name: "GCount",
1
+ import { defineComponent as q, useTemplateRef as B, ref as y, watch as N, onMounted as V, onUnmounted as E, createElementBlock as G, openBlock as P, normalizeClass as U } from "vue";
2
+ const A = /* @__PURE__ */ q({
4
3
  __name: "index",
5
4
  props: {
6
- to: {},
7
- from: { default: 0 },
8
- direction: { default: "up" },
5
+ num: { default: 0 },
9
6
  delay: { default: 0 },
10
7
  duration: { default: 2 },
11
8
  className: { default: "" },
12
9
  startWhen: { type: Boolean, default: !0 },
13
10
  separator: { default: "" },
14
- onStart: {},
15
- onEnd: {}
11
+ decimalPlaces: { default: 0 }
16
12
  },
17
- setup(d) {
18
- const e = d, a = E("elementRef"), o = f(e.direction === "down" ? e.to : e.from), i = f(!1), t = f(null), u = f(!1);
19
- let r = null;
20
- const w = b(() => 20 + 40 * (1 / e.duration)), x = b(() => 100 * (1 / e.duration));
21
- let s = 0;
22
- const y = (n) => {
23
- const l = {
13
+ emits: ["start", "end"],
14
+ setup(w, { expose: W, emit: _ }) {
15
+ const e = w, I = _;
16
+ W({
17
+ reset: D,
18
+ start: h
19
+ });
20
+ const n = B("elementRef"), C = () => 0, r = y(C()), s = y(!1), i = y(!1);
21
+ let a = null, c = null, l = null, m = !1, f = 0, d = 0, u = 0;
22
+ const R = (t) => 1 - Math.pow(1 - t, 3), S = (t) => {
23
+ const o = Math.max(0, Math.floor(e.decimalPlaces)), g = {
24
24
  useGrouping: !!e.separator,
25
- minimumFractionDigits: 0,
26
- maximumFractionDigits: 0
27
- }, m = Intl.NumberFormat("en-US", l).format(Number(n.toFixed(0)));
28
- return e.separator ? m.replace(/,/g, e.separator) : m;
29
- }, c = () => {
30
- a.value && (a.value.textContent = y(o.value));
31
- }, v = (n) => {
32
- const l = e.direction === "down" ? e.from : e.to, m = o.value, h = l - m, _ = h * x.value, A = s * w.value, C = _ - A;
33
- s += C * 0.016, o.value += s * 0.016, c(), Math.abs(h) > 0.01 || Math.abs(s) > 0.01 ? t.value = requestAnimationFrame(v) : (o.value = l, c(), t.value = null, e.onEnd && e.onEnd());
34
- }, g = () => {
35
- u.value || !i.value || !e.startWhen || (u.value = !0, e.onStart && e.onStart(), setTimeout(() => {
36
- s = 0, t.value = requestAnimationFrame(v);
25
+ minimumFractionDigits: o,
26
+ maximumFractionDigits: o
27
+ }, b = Number(t.toFixed(o)), x = Intl.NumberFormat("en-US", g).format(b);
28
+ return e.separator ? x.replace(/,/g, e.separator) : x;
29
+ }, v = () => {
30
+ n.value && (n.value.textContent = S(r.value));
31
+ }, F = () => {
32
+ a !== null && (cancelAnimationFrame(a), a = null);
33
+ }, p = () => {
34
+ c !== null && (clearTimeout(c), c = null);
35
+ }, M = (t) => {
36
+ if (!m) return;
37
+ u || (u = t);
38
+ const o = (t - u) / 1e3, g = Math.max(1e-3, e.duration), b = Math.min(1, o / g), x = R(b);
39
+ r.value = f + (d - f) * x, v(), b < 1 ? a = requestAnimationFrame(M) : (r.value = d, v(), a = null, I("end"));
40
+ };
41
+ function h() {
42
+ i.value || !s.value || !e.startWhen || (i.value = !0, I("start"), p(), c = setTimeout(() => {
43
+ c = null, m && (f = r.value, d = e.num, u = 0, a = requestAnimationFrame(M));
37
44
  }, e.delay * 1e3));
38
- }, I = () => {
39
- a.value && (r = new IntersectionObserver(
40
- ([n]) => {
41
- n.isIntersecting && !i.value && (i.value = !0, g());
45
+ }
46
+ function T() {
47
+ !m || !s.value || !e.startWhen || (F(), p(), f = r.value, d = e.num, u = 0, a = requestAnimationFrame(M));
48
+ }
49
+ function D() {
50
+ F(), p(), u = 0, i.value = !1, r.value = C(), v();
51
+ }
52
+ const O = () => {
53
+ n.value && (l = new IntersectionObserver(
54
+ ([t]) => {
55
+ t.isIntersecting && !s.value && (s.value = !0, h(), l && n.value && l.unobserve(n.value));
42
56
  },
43
57
  {
44
58
  threshold: 0,
45
59
  rootMargin: "0px"
46
60
  }
47
- ), r.observe(a.value));
48
- }, N = () => {
49
- t.value && (cancelAnimationFrame(t.value), t.value = null), r && (r.disconnect(), r = null);
61
+ ), l.observe(n.value));
62
+ }, k = () => {
63
+ m = !1, F(), p(), l && (l.disconnect(), l = null);
50
64
  };
51
- return F(
52
- [() => e.from, () => e.to, () => e.direction],
65
+ return N(
66
+ () => e.num,
53
67
  () => {
54
- o.value = e.direction === "down" ? e.to : e.from, c(), u.value = !1;
55
- },
56
- { immediate: !0 }
57
- ), F(
68
+ i.value ? T() : s.value && e.startWhen && h();
69
+ }
70
+ ), N(
58
71
  () => e.startWhen,
59
72
  () => {
60
- e.startWhen && i.value && !u.value && g();
73
+ e.startWhen && s.value && !i.value && h();
61
74
  }
62
- ), M(() => {
63
- c(), I();
64
- }), R(() => {
65
- N();
66
- }), (n, l) => (k(), W("span", {
75
+ ), V(() => {
76
+ m = !0, v(), O();
77
+ }), E(() => {
78
+ k();
79
+ }), (t, o) => (P(), G("span", {
67
80
  ref_key: "elementRef",
68
- ref: a,
69
- class: B(n.className)
81
+ ref: n,
82
+ class: U(t.className)
70
83
  }, null, 2));
71
84
  }
72
85
  });
73
- p.install = (d) => {
74
- d.component(p.name, p);
86
+ A.install = (w) => {
87
+ w.component(A.name, A);
75
88
  };
76
89
  export {
77
- p as GCount,
78
- p as default
90
+ A as GCount,
91
+ A as default
79
92
  };
@@ -0,0 +1 @@
1
+ export {}