geekin-devtoys 0.3.7 → 0.3.10
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/lib/GBubble/index.js +1 -2
- package/lib/GBubble/index.mjs +3 -210
- package/lib/GBubble-C3cM9Put.mjs +216 -0
- package/lib/GBubble-Dph0YDkU.js +2 -0
- package/lib/GButton/index.js +1 -0
- package/lib/GButton/index.mjs +84 -0
- package/lib/GButton/style.css +1 -0
- package/lib/GButton.d.ts +1 -0
- package/lib/GCard/index.js +1 -1
- package/lib/GCard/index.mjs +1 -1
- package/lib/GDialog/index.js +1 -1
- package/lib/GDialog/index.mjs +271 -342
- package/lib/GDialog/style.css +1 -1
- package/lib/GInput/index.js +1 -0
- package/lib/GInput/index.mjs +145 -0
- package/lib/GInput/style.css +1 -0
- package/lib/GInput.d.ts +1 -0
- package/lib/GInputTreeTag/index.js +1 -1
- package/lib/GInputTreeTag/index.mjs +77 -75
- package/lib/GInputTreeTag/style.css +1 -1
- package/lib/GPie3D/index.js +1 -1
- package/lib/GPie3D/index.mjs +1 -1
- package/lib/GPluginVideo/index.js +1 -1
- package/lib/GPluginVideo/index.mjs +149 -2072
- package/lib/GPluginVideo/web-control.esm.min.js +2 -0
- package/lib/GProgress/index.js +1 -1
- package/lib/GProgress/index.mjs +1 -1
- package/lib/GRing/index.js +1 -1
- package/lib/GRing/index.mjs +1 -1
- package/lib/GScroller/index.js +1 -1
- package/lib/GScroller/index.mjs +135 -152
- package/lib/GShinyText/index.js +1 -1
- package/lib/GShinyText/index.mjs +45 -119
- package/lib/GSteps/index.js +1 -1
- package/lib/GSteps/index.mjs +89 -43
- package/lib/GSteps/style.css +1 -1
- package/lib/GTable/index.js +1 -1
- package/lib/GTable/index.mjs +1 -1
- package/lib/GTag/index.js +1 -0
- package/lib/GTag/index.mjs +73 -0
- package/lib/GTag.d.ts +1 -0
- package/lib/GVideo/index.js +2 -2
- package/lib/GVideo/index.mjs +159 -158
- package/lib/GVideo/style.css +1 -1
- package/lib/assets/GTag.css +1 -0
- package/lib/components/GButton/index.d.ts +38 -0
- package/lib/components/GDialog/const.d.ts +4 -4
- package/lib/components/GDialog/icons.d.ts +4 -4
- package/lib/components/GInput/index.d.ts +64 -0
- package/lib/components/GInputTreeTag/index.d.ts +32 -24
- package/lib/components/GProgress/index.d.ts +1 -1
- package/lib/components/GRing/index.d.ts +1 -1
- package/lib/components/GScreen/index.d.ts +1 -1
- package/lib/components/GTag/index.d.ts +41 -0
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +42 -33
- package/lib/index/style.css +25 -0
- package/lib/index.d.ts +4 -1
- package/package.json +20 -20
- package/lib/AnimatePresence-26Wy0TGN.js +0 -9
- package/lib/AnimatePresence-nl0c23TZ.mjs +0 -136
- package/lib/_plugin-vue_export-helper-BHFhmbuH.js +0 -1
- package/lib/_plugin-vue_export-helper-CHgC5LLL.mjs +0 -9
- package/lib/components/GDialog/GButton.d.ts +0 -42
- package/lib/index-B8Ap0044.js +0 -1
- package/lib/index-Bbr5fWvI.mjs +0 -5158
package/lib/GBubble/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
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
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("../GBubble-Dph0YDkU.js");exports.GBubble=e.GBubble;exports.default=e.GBubble;
|
package/lib/GBubble/index.mjs
CHANGED
|
@@ -1,212 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _ as st } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
3
|
-
const it = /* @__PURE__ */ Q({
|
|
4
|
-
__name: "index",
|
|
5
|
-
props: {
|
|
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 }
|
|
15
|
-
},
|
|
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();
|
|
27
|
-
}, G = () => {
|
|
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],
|
|
39
|
-
// 随机初始速度(更缓慢移动)
|
|
40
|
-
vx: (Math.random() - 0.5) * 0.2,
|
|
41
|
-
vy: (Math.random() - 0.5) * 0.2,
|
|
42
|
-
value: d.value
|
|
43
|
-
});
|
|
44
|
-
});
|
|
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;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
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);
|
|
64
|
-
if (v > 0) {
|
|
65
|
-
const R = v * M, C = i / v * R, I = r / v * R;
|
|
66
|
-
n[s].x += C, n[s].y += I;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
let B = 0;
|
|
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));
|
|
73
|
-
}
|
|
74
|
-
if (B < 0.1)
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
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(
|
|
84
|
-
n.radius,
|
|
85
|
-
Math.min(f - n.radius, n.x)
|
|
86
|
-
), n.y = Math.max(
|
|
87
|
-
n.radius,
|
|
88
|
-
Math.min(m - n.radius, n.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)
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
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,
|
|
108
|
-
0,
|
|
109
|
-
// 渐变中心(稍微偏移,增加立体感)
|
|
110
|
-
l,
|
|
111
|
-
u,
|
|
112
|
-
x
|
|
113
|
-
// 渐变边缘
|
|
114
|
-
);
|
|
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(`
|
|
121
|
-
`);
|
|
122
|
-
i.forEach((r, v) => {
|
|
123
|
-
const R = u - (i.length - 1) * o / 2 + v * o;
|
|
124
|
-
t.fillText(r, l, R);
|
|
125
|
-
});
|
|
126
|
-
}), X.animation && (D = requestAnimationFrame(H));
|
|
127
|
-
}, J = () => {
|
|
128
|
-
c.forEach((t) => {
|
|
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) {
|
|
130
|
-
t.vx += (Math.random() - 0.5) * 0.1, t.vy += (Math.random() - 0.5) * 0.1;
|
|
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);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
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;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
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;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
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);
|
|
157
|
-
}, N = (t) => {
|
|
158
|
-
if (_.value) {
|
|
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
|
|
166
|
-
);
|
|
167
|
-
} else
|
|
168
|
-
z.value = t.clientX + 10, L.value = t.clientY + 10;
|
|
169
|
-
}, O = () => {
|
|
170
|
-
q.value = !1, k.value = null, $.value = -1;
|
|
171
|
-
};
|
|
172
|
-
return Z(
|
|
173
|
-
() => X.data,
|
|
174
|
-
() => {
|
|
175
|
-
G(), H();
|
|
176
|
-
},
|
|
177
|
-
{ deep: !0 }
|
|
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", {
|
|
183
|
-
class: "bubble-chart-container",
|
|
184
|
-
ref_key: "containerRef",
|
|
185
|
-
ref: _
|
|
186
|
-
}, [
|
|
187
|
-
nt("canvas", {
|
|
188
|
-
ref_key: "canvasRef",
|
|
189
|
-
ref: A,
|
|
190
|
-
onMousemove: K,
|
|
191
|
-
onMouseleave: O
|
|
192
|
-
}, null, 544),
|
|
193
|
-
q.value ? (U(), T("div", {
|
|
194
|
-
key: 0,
|
|
195
|
-
class: "bubble-tooltip",
|
|
196
|
-
style: at({
|
|
197
|
-
left: `${z.value}px`,
|
|
198
|
-
top: `${L.value}px`
|
|
199
|
-
})
|
|
200
|
-
}, [
|
|
201
|
-
ot(t.$slots, "tooltip", { data: k.value }, void 0, !0)
|
|
202
|
-
], 4)) : et("", !0)
|
|
203
|
-
], 512));
|
|
204
|
-
}
|
|
205
|
-
}), W = /* @__PURE__ */ st(it, [["__scopeId", "data-v-f39dd155"]]);
|
|
206
|
-
W.install = (P) => {
|
|
207
|
-
P.component(W.name, W);
|
|
208
|
-
};
|
|
1
|
+
import { G, G as b } from "../GBubble-C3cM9Put.mjs";
|
|
209
2
|
export {
|
|
210
|
-
|
|
211
|
-
|
|
3
|
+
G as GBubble,
|
|
4
|
+
b as default
|
|
212
5
|
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { defineComponent as Q, ref as A, watch as Z, onMounted as b, onUnmounted as tt, createElementBlock as T, openBlock as O, createElementVNode as nt, createCommentVNode as et, normalizeStyle as at, renderSlot as ot } from "vue";
|
|
2
|
+
const st = /* @__PURE__ */ Q({
|
|
3
|
+
__name: "index",
|
|
4
|
+
props: {
|
|
5
|
+
data: { default: () => [] },
|
|
6
|
+
config: { default: () => ({
|
|
7
|
+
minRadius: 25,
|
|
8
|
+
maxRadius: 100,
|
|
9
|
+
padding: 10,
|
|
10
|
+
colors: ["#1E88E5", "#26A69A", "#4CAF50", "#F57C00", "#9C27B0", "#FF5722", "#607D8B"],
|
|
11
|
+
textColor: "#FFFFFF"
|
|
12
|
+
}) },
|
|
13
|
+
animation: { type: Boolean, default: !0 }
|
|
14
|
+
},
|
|
15
|
+
setup(S) {
|
|
16
|
+
const X = S, F = A(null), _ = A(null);
|
|
17
|
+
let w = null, f = 0, m = 0;
|
|
18
|
+
const Y = {
|
|
19
|
+
...X.config
|
|
20
|
+
}, D = A(!1), z = A(0), L = A(0), I = A(null);
|
|
21
|
+
let $ = A(-1), c = [], P = null;
|
|
22
|
+
const j = () => {
|
|
23
|
+
if (!_.value || !F.value) return;
|
|
24
|
+
const t = F.value, e = _.value;
|
|
25
|
+
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", w = e.getContext("2d"), W(), G();
|
|
26
|
+
}, W = () => {
|
|
27
|
+
c = [];
|
|
28
|
+
const t = X.data, e = t.map((d) => d.value), h = Math.max(...e), l = Math.min(...e), u = h - l;
|
|
29
|
+
t.forEach((d, n) => {
|
|
30
|
+
const y = u > 0 ? (d.value - l) / u : 0.5, a = Y.minRadius + (Y.maxRadius - Y.minRadius) * y, M = n / t.length * Math.PI * 2, B = f / 2, s = m / 2, o = Math.min(f, m) / 3;
|
|
31
|
+
let i = B + Math.cos(M) * o, r = s + Math.sin(M) * o;
|
|
32
|
+
i = Math.max(a, Math.min(f - a, i)), r = Math.max(a, Math.min(m - a, r)), c.push({
|
|
33
|
+
x: i,
|
|
34
|
+
y: r,
|
|
35
|
+
radius: a,
|
|
36
|
+
data: d,
|
|
37
|
+
color: Y.colors[n % Y.colors.length],
|
|
38
|
+
// 随机初始速度(更缓慢移动)
|
|
39
|
+
vx: (Math.random() - 0.5) * 0.2,
|
|
40
|
+
vy: (Math.random() - 0.5) * 0.2,
|
|
41
|
+
value: d.value
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
const v = 1500, p = 0.2, g = 0.9;
|
|
45
|
+
for (let d = 0; d < v; d++) {
|
|
46
|
+
const n = c.map(() => ({ x: 0, y: 0 }));
|
|
47
|
+
for (let s = 0; s < c.length; s++) {
|
|
48
|
+
const o = c[s];
|
|
49
|
+
for (let i = s + 1; i < c.length; i++) {
|
|
50
|
+
const r = c[i], x = o.x - r.x, R = o.y - r.y, C = Math.sqrt(x * x + R * R), V = o.radius + r.radius + Y.padding;
|
|
51
|
+
if (C < V) {
|
|
52
|
+
const E = (V - C) * p, q = x / C * E, k = R / C * E;
|
|
53
|
+
n[s].x += q, n[s].y += k, n[i].x -= q, n[i].y -= k;
|
|
54
|
+
} else if (C > 0) {
|
|
55
|
+
const E = 1 / C * p * 5, q = x / C * E, k = R / C * E;
|
|
56
|
+
n[s].x += q, n[s].y += k, n[i].x -= q, n[i].y -= k;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const y = f / 2, a = m / 2, M = 0.01;
|
|
61
|
+
for (let s = 0; s < c.length; s++) {
|
|
62
|
+
const o = c[s], i = y - o.x, r = a - o.y, x = Math.sqrt(i * i + r * r);
|
|
63
|
+
if (x > 0) {
|
|
64
|
+
const R = x * M, C = i / x * R, V = r / x * R;
|
|
65
|
+
n[s].x += C, n[s].y += V;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let B = 0;
|
|
69
|
+
for (let s = 0; s < c.length; s++) {
|
|
70
|
+
const o = c[s], i = n[s], r = i.x * g, x = i.y * g, R = Math.sqrt(r * r + x * x);
|
|
71
|
+
B += R, o.x += r, o.y += x, 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));
|
|
72
|
+
}
|
|
73
|
+
if (B < 0.1)
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
for (let d = 0; d < c.length; d++) {
|
|
77
|
+
const n = c[d];
|
|
78
|
+
for (let y = d + 1; y < c.length; y++) {
|
|
79
|
+
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 + Y.padding;
|
|
80
|
+
if (s < o) {
|
|
81
|
+
const i = Math.atan2(B, M), r = (o - s) / 2;
|
|
82
|
+
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(
|
|
83
|
+
n.radius,
|
|
84
|
+
Math.min(f - n.radius, n.x)
|
|
85
|
+
), n.y = Math.max(
|
|
86
|
+
n.radius,
|
|
87
|
+
Math.min(m - n.radius, n.y)
|
|
88
|
+
), a.x = Math.max(
|
|
89
|
+
a.radius,
|
|
90
|
+
Math.min(f - a.radius, a.x)
|
|
91
|
+
), a.y = Math.max(
|
|
92
|
+
a.radius,
|
|
93
|
+
Math.min(m - a.radius, a.y)
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}, G = () => {
|
|
99
|
+
if (!w) return;
|
|
100
|
+
const t = w;
|
|
101
|
+
t.clearRect(0, 0, f, m), X.animation && U(), c.forEach((e, h) => {
|
|
102
|
+
const { x: l, y: u, radius: v, color: p } = e;
|
|
103
|
+
t.beginPath(), t.arc(l, u, v, 0, Math.PI * 2);
|
|
104
|
+
const g = t.createRadialGradient(
|
|
105
|
+
l - v * 0.3,
|
|
106
|
+
u - v * 0.3,
|
|
107
|
+
0,
|
|
108
|
+
// 渐变中心(稍微偏移,增加立体感)
|
|
109
|
+
l,
|
|
110
|
+
u,
|
|
111
|
+
v
|
|
112
|
+
// 渐变边缘
|
|
113
|
+
);
|
|
114
|
+
g.addColorStop(0, p), g.addColorStop(1, p + "40"), t.fillStyle = g, t.fill();
|
|
115
|
+
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 * v * 0.6, s = u + a / M * v * 0.6;
|
|
116
|
+
t.beginPath(), t.arc(B, s, v * 0.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";
|
|
117
|
+
const o = Math.max(10, v / 2.5);
|
|
118
|
+
t.font = `${o}px Arial`;
|
|
119
|
+
const i = e.data.name.split(`
|
|
120
|
+
`);
|
|
121
|
+
i.forEach((r, x) => {
|
|
122
|
+
const R = u - (i.length - 1) * o / 2 + x * o;
|
|
123
|
+
t.fillText(r, l, R);
|
|
124
|
+
});
|
|
125
|
+
}), X.animation && (P = requestAnimationFrame(G));
|
|
126
|
+
}, U = () => {
|
|
127
|
+
c.forEach((t) => {
|
|
128
|
+
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) {
|
|
129
|
+
t.vx += (Math.random() - 0.5) * 0.1, t.vy += (Math.random() - 0.5) * 0.1;
|
|
130
|
+
const e = 0.3, h = Math.sqrt(t.vx * t.vx + t.vy * t.vy);
|
|
131
|
+
h > e && (t.vx = t.vx / h * e, t.vy = t.vy / h * e);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
for (let t = 0; t < c.length; t++)
|
|
135
|
+
for (let e = t + 1; e < c.length; e++) {
|
|
136
|
+
const h = c[t], l = c[e], u = h.x - l.x, v = h.y - l.y, p = Math.sqrt(u * u + v * v), g = h.radius + l.radius;
|
|
137
|
+
if (p < g) {
|
|
138
|
+
const d = Math.atan2(v, u), n = g - p, y = Math.cos(d) * n / 2, a = Math.sin(d) * n / 2;
|
|
139
|
+
h.x += y, h.y += a, l.x -= y, l.y -= a;
|
|
140
|
+
const M = h.vx, B = h.vy;
|
|
141
|
+
h.vx = l.vx * 0.8, h.vy = l.vy * 0.8, l.vx = M * 0.8, l.vy = B * 0.8;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}, J = (t) => {
|
|
145
|
+
if (!_.value) return;
|
|
146
|
+
const e = _.value.getBoundingClientRect(), h = t.clientX - e.left, l = t.clientY - e.top;
|
|
147
|
+
let u = -1;
|
|
148
|
+
for (let v = 0; v < c.length; v++) {
|
|
149
|
+
const p = c[v], g = h - p.x, d = l - p.y;
|
|
150
|
+
if (Math.sqrt(g * g + d * d) <= p.radius) {
|
|
151
|
+
u = v;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
u !== $.value ? ($.value = u, u >= 0 ? (D.value = !0, I.value = c[u].data, N(t)) : (D.value = !1, I.value = null)) : u >= 0 && N(t);
|
|
156
|
+
}, N = (t) => {
|
|
157
|
+
if (F.value) {
|
|
158
|
+
const e = F.value.getBoundingClientRect(), h = 120, l = 60;
|
|
159
|
+
z.value = Math.min(
|
|
160
|
+
t.clientX + 10 - e.left,
|
|
161
|
+
e.width - h
|
|
162
|
+
), L.value = Math.min(
|
|
163
|
+
t.clientY + 10 - e.top,
|
|
164
|
+
e.height - l
|
|
165
|
+
);
|
|
166
|
+
} else
|
|
167
|
+
z.value = t.clientX + 10, L.value = t.clientY + 10;
|
|
168
|
+
}, K = () => {
|
|
169
|
+
D.value = !1, I.value = null, $.value = -1;
|
|
170
|
+
};
|
|
171
|
+
return Z(
|
|
172
|
+
() => X.data,
|
|
173
|
+
() => {
|
|
174
|
+
W(), G();
|
|
175
|
+
},
|
|
176
|
+
{ deep: !0 }
|
|
177
|
+
), b(() => {
|
|
178
|
+
j(), window.addEventListener("resize", j);
|
|
179
|
+
}), tt(() => {
|
|
180
|
+
window.removeEventListener("resize", j), P && (cancelAnimationFrame(P), P = null);
|
|
181
|
+
}), (t, e) => (O(), T("div", {
|
|
182
|
+
class: "bubble-chart-container",
|
|
183
|
+
ref_key: "containerRef",
|
|
184
|
+
ref: F
|
|
185
|
+
}, [
|
|
186
|
+
nt("canvas", {
|
|
187
|
+
ref_key: "canvasRef",
|
|
188
|
+
ref: _,
|
|
189
|
+
onMousemove: J,
|
|
190
|
+
onMouseleave: K
|
|
191
|
+
}, null, 544),
|
|
192
|
+
D.value ? (O(), T("div", {
|
|
193
|
+
key: 0,
|
|
194
|
+
class: "bubble-tooltip",
|
|
195
|
+
style: at({
|
|
196
|
+
left: `${z.value}px`,
|
|
197
|
+
top: `${L.value}px`
|
|
198
|
+
})
|
|
199
|
+
}, [
|
|
200
|
+
ot(t.$slots, "tooltip", { data: I.value }, void 0, !0)
|
|
201
|
+
], 4)) : et("", !0)
|
|
202
|
+
], 512));
|
|
203
|
+
}
|
|
204
|
+
}), it = (S, X) => {
|
|
205
|
+
const F = S.__vccOpts || S;
|
|
206
|
+
for (const [_, w] of X)
|
|
207
|
+
F[_] = w;
|
|
208
|
+
return F;
|
|
209
|
+
}, H = /* @__PURE__ */ it(st, [["__scopeId", "data-v-f39dd155"]]);
|
|
210
|
+
H.install = (S) => {
|
|
211
|
+
S.component(H.name, H);
|
|
212
|
+
};
|
|
213
|
+
export {
|
|
214
|
+
H as G,
|
|
215
|
+
it as _
|
|
216
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const f=require("vue"),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(E){const X=E,Y=f.ref(null),A=f.ref(null);let S=null,m=0,y=0;const _={...X.config},D=f.ref(!1),L=f.ref(0),$=f.ref(0),I=f.ref(null);let j=f.ref(-1),c=[],P=null;const G=()=>{if(!A.value||!Y.value)return;const t=Y.value,e=A.value;t.style.width="100%",t.style.height="100%",m=t.clientWidth,y=t.clientHeight,e.width=m,e.height=y,e.style.width=m+"px",e.style.height=y+"px",S=e.getContext("2d"),W(),H()},W=()=>{c=[];const t=X.data,e=t.map(d=>d.value),h=Math.max(...e),l=Math.min(...e),u=h-l;t.forEach((d,n)=>{const M=u>0?(d.value-l)/u:.5,a=_.minRadius+(_.maxRadius-_.minRadius)*M,p=n/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:_.colors[n%_.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 n=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),V=o.radius+r.radius+_.padding;if(F<V){const k=(V-F)*g,q=x/F*k,w=C/F*k;n[s].x+=q,n[s].y+=w,n[i].x-=q,n[i].y-=w}else if(F>0){const k=1/F*g*5,q=x/F*k,w=C/F*k;n[s].x+=q,n[s].y+=w,n[i].x-=q,n[i].y-=w}}}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,V=r/x*C;n[s].x+=F,n[s].y+=V}}let R=0;for(let s=0;s<c.length;s++){const o=c[s],i=n[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 n=c[d];for(let M=d+1;M<c.length;M++){const a=c[M],p=n.x-a.x,R=n.y-a.y,s=Math.sqrt(p*p+R*R),o=n.radius+a.radius+_.padding;if(s<o){const i=Math.atan2(R,p),r=(o-s)/2;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(n.radius,Math.min(m-n.radius,n.x)),n.y=Math.max(n.radius,Math.min(y-n.radius,n.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))}}}},H=()=>{if(!S)return;const t=S;t.clearRect(0,0,m,y),X.animation&&O(),c.forEach((e,h)=>{const{x:l,y:u,radius:v,color:g}=e;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,n=y*.2,M=d-l,a=n-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=_.textColor??"",t.textAlign="center",t.textBaseline="middle";const o=Math.max(10,v/2.5);t.font=`${o}px Arial`;const i=e.data.name.split(`
|
|
2
|
+
`);i.forEach((r,x)=>{const C=u-(i.length-1)*o/2+x*o;t.fillText(r,l,C)})}),X.animation&&(P=requestAnimationFrame(H))},O=()=>{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 e=.3,h=Math.sqrt(t.vx*t.vx+t.vy*t.vy);h>e&&(t.vx=t.vx/h*e,t.vy=t.vy/h*e)}});for(let t=0;t<c.length;t++)for(let e=t+1;e<c.length;e++){const h=c[t],l=c[e],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),n=B-g,M=Math.cos(d)*n/2,a=Math.sin(d)*n/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}}},U=t=>{if(!A.value)return;const e=A.value.getBoundingClientRect(),h=t.clientX-e.left,l=t.clientY-e.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!==j.value?(j.value=u,u>=0?(D.value=!0,I.value=c[u].data,N(t)):(D.value=!1,I.value=null)):u>=0&&N(t)},N=t=>{if(Y.value){const e=Y.value.getBoundingClientRect(),h=120,l=60;L.value=Math.min(t.clientX+10-e.left,e.width-h),$.value=Math.min(t.clientY+10-e.top,e.height-l)}else L.value=t.clientX+10,$.value=t.clientY+10},J=()=>{D.value=!1,I.value=null,j.value=-1};return f.watch(()=>X.data,()=>{W(),H()},{deep:!0}),f.onMounted(()=>{G(),window.addEventListener("resize",G)}),f.onUnmounted(()=>{window.removeEventListener("resize",G),P&&(cancelAnimationFrame(P),P=null)}),(t,e)=>(f.openBlock(),f.createElementBlock("div",{class:"bubble-chart-container",ref_key:"containerRef",ref:Y},[f.createElementVNode("canvas",{ref_key:"canvasRef",ref:A,onMousemove:U,onMouseleave:J},null,544),D.value?(f.openBlock(),f.createElementBlock("div",{key:0,class:"bubble-tooltip",style:f.normalizeStyle({left:`${L.value}px`,top:`${$.value}px`})},[f.renderSlot(t.$slots,"tooltip",{data:I.value},void 0,!0)],4)):f.createCommentVNode("",!0)],512))}}),T=(E,X)=>{const Y=E.__vccOpts||E;for(const[A,S]of X)Y[A]=S;return Y},z=T(K,[["__scopeId","data-v-f39dd155"]]);z.install=E=>{E.component(z.name,z)};exports.GBubble=z;exports._export_sfc=T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("motion-v"),k=require("../GBubble-Dph0YDkU.js"),B=["type","disabled"],h={key:0,class:"g-button__loading"},_={key:1,class:"g-button__icon"},f={key:2,class:"g-button__text"},v=e.defineComponent({name:"GButton",__name:"index",props:{type:{},size:{},loading:{type:Boolean},disabled:{type:Boolean},block:{type:Boolean},nativeType:{}},emits:["click"],setup(i,{emit:d}){const s=i,u=d,p=t=>{if(!(s.disabled||s.loading)){if(s.type!=="link"&&!b.value){const o=t.currentTarget.getBoundingClientRect(),c=t.clientX!==0||t.clientY!==0,g={id:++m,x:c?t.clientX-o.left:o.width/2,y:c?t.clientY-o.top:o.height/2,size:Math.hypot(o.width,o.height)*2};l.value.push(g)}u("click",t)}},l=e.ref([]);let m=0;const y=t=>{l.value=l.value.filter(a=>a.id!==t)},b=r.useReducedMotion();return(t,a)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["g-button",["g-button--"+t.type,"g-button--"+t.size,{"is-block":t.block,"is-loading":t.loading,"is-disabled":t.disabled}]]),type:t.nativeType,disabled:t.disabled||t.loading,onClick:p},[t.loading?(e.openBlock(),e.createElementBlock("span",h)):e.createCommentVNode("",!0),t.$slots.icon?(e.openBlock(),e.createElementBlock("span",_,[e.renderSlot(t.$slots,"icon",{},void 0,!0)])):e.createCommentVNode("",!0),t.$slots.default?(e.openBlock(),e.createElementBlock("span",f,[e.renderSlot(t.$slots,"default",{},void 0,!0)])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,o=>(e.openBlock(),e.createBlock(e.unref(r.motion).span,{key:o.id,class:"g-button__wave",initial:{x:"-50%",y:"-50%",scale:0,opacity:.2},animate:{x:"-50%",y:"-50%",scale:1,opacity:0},transition:{duration:.6,ease:"easeOut"},style:e.normalizeStyle({left:o.x+"px",top:o.y+"px",width:o.size+"px",height:o.size+"px"}),onAnimationComplete:c=>y(o.id)},null,8,["style","onAnimationComplete"]))),128))],10,B))}}),n=k._export_sfc(v,[["__scopeId","data-v-054c5b31"]]);n.install=i=>{i.component(n.name,n)};exports.GButton=n;exports.default=n;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { defineComponent as k, ref as _, createElementBlock as n, openBlock as o, normalizeClass as B, createCommentVNode as c, renderSlot as p, Fragment as v, renderList as z, createBlock as C, unref as $, normalizeStyle as M } from "vue";
|
|
2
|
+
import { useReducedMotion as T, motion as w } from "motion-v";
|
|
3
|
+
import { _ as A } from "../GBubble-C3cM9Put.mjs";
|
|
4
|
+
const G = ["type", "disabled"], I = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "g-button__loading"
|
|
7
|
+
}, R = {
|
|
8
|
+
key: 1,
|
|
9
|
+
class: "g-button__icon"
|
|
10
|
+
}, S = {
|
|
11
|
+
key: 2,
|
|
12
|
+
class: "g-button__text"
|
|
13
|
+
}, X = /* @__PURE__ */ k({
|
|
14
|
+
name: "GButton",
|
|
15
|
+
__name: "index",
|
|
16
|
+
props: {
|
|
17
|
+
type: {},
|
|
18
|
+
size: {},
|
|
19
|
+
loading: { type: Boolean },
|
|
20
|
+
disabled: { type: Boolean },
|
|
21
|
+
block: { type: Boolean },
|
|
22
|
+
nativeType: {}
|
|
23
|
+
},
|
|
24
|
+
emits: ["click"],
|
|
25
|
+
setup(s, { emit: u }) {
|
|
26
|
+
const l = s, m = u, y = (e) => {
|
|
27
|
+
if (!(l.disabled || l.loading)) {
|
|
28
|
+
if (l.type !== "link" && !h.value) {
|
|
29
|
+
const t = e.currentTarget.getBoundingClientRect(), d = e.clientX !== 0 || e.clientY !== 0, f = {
|
|
30
|
+
id: ++g,
|
|
31
|
+
x: d ? e.clientX - t.left : t.width / 2,
|
|
32
|
+
y: d ? e.clientY - t.top : t.height / 2,
|
|
33
|
+
// 直径覆盖整个按钮对角线,保证涟漪能填满按钮
|
|
34
|
+
size: Math.hypot(t.width, t.height) * 2
|
|
35
|
+
};
|
|
36
|
+
i.value.push(f);
|
|
37
|
+
}
|
|
38
|
+
m("click", e);
|
|
39
|
+
}
|
|
40
|
+
}, i = _([]);
|
|
41
|
+
let g = 0;
|
|
42
|
+
const b = (e) => {
|
|
43
|
+
i.value = i.value.filter((a) => a.id !== e);
|
|
44
|
+
}, h = T();
|
|
45
|
+
return (e, a) => (o(), n("button", {
|
|
46
|
+
class: B(["g-button", [
|
|
47
|
+
"g-button--" + e.type,
|
|
48
|
+
"g-button--" + e.size,
|
|
49
|
+
{
|
|
50
|
+
"is-block": e.block,
|
|
51
|
+
"is-loading": e.loading,
|
|
52
|
+
"is-disabled": e.disabled
|
|
53
|
+
}
|
|
54
|
+
]]),
|
|
55
|
+
type: e.nativeType,
|
|
56
|
+
disabled: e.disabled || e.loading,
|
|
57
|
+
onClick: y
|
|
58
|
+
}, [
|
|
59
|
+
e.loading ? (o(), n("span", I)) : c("", !0),
|
|
60
|
+
e.$slots.icon ? (o(), n("span", R, [
|
|
61
|
+
p(e.$slots, "icon", {}, void 0, !0)
|
|
62
|
+
])) : c("", !0),
|
|
63
|
+
e.$slots.default ? (o(), n("span", S, [
|
|
64
|
+
p(e.$slots, "default", {}, void 0, !0)
|
|
65
|
+
])) : c("", !0),
|
|
66
|
+
(o(!0), n(v, null, z(i.value, (t) => (o(), C($(w).span, {
|
|
67
|
+
key: t.id,
|
|
68
|
+
class: "g-button__wave",
|
|
69
|
+
initial: { x: "-50%", y: "-50%", scale: 0, opacity: 0.2 },
|
|
70
|
+
animate: { x: "-50%", y: "-50%", scale: 1, opacity: 0 },
|
|
71
|
+
transition: { duration: 0.6, ease: "easeOut" },
|
|
72
|
+
style: M({ left: t.x + "px", top: t.y + "px", width: t.size + "px", height: t.size + "px" }),
|
|
73
|
+
onAnimationComplete: (d) => b(t.id)
|
|
74
|
+
}, null, 8, ["style", "onAnimationComplete"]))), 128))
|
|
75
|
+
], 10, G));
|
|
76
|
+
}
|
|
77
|
+
}), r = /* @__PURE__ */ A(X, [["__scopeId", "data-v-054c5b31"]]);
|
|
78
|
+
r.install = (s) => {
|
|
79
|
+
s.component(r.name, r);
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
r as GButton,
|
|
83
|
+
r as default
|
|
84
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@charset "UTF-8";.g-button[data-v-054c5b31]{--g-button-wave-color: currentcolor;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:6px;height:32px;padding:0 15px;font-size:var(--g-button-font-size, 14px);line-height:1;white-space:nowrap;cursor:pointer;-webkit-user-select:none;user-select:none;overflow:hidden;color:var(--g-text-color, rgba(0, 0, 0, .88));background:var(--g-button-bg-color, var(--g-button-default-color, #e8e8eb));border:none;border-radius:var(--g-button-radius, 6px);outline:none;transition:all .2s cubic-bezier(.645,.045,.355,1)}.g-button[data-v-054c5b31]:not(.is-disabled):hover,.g-button[data-v-054c5b31]:not(.is-disabled):focus-visible{border-color:var(--g-primary-color, #039be5);color:var(--g-primary-color, #039be5)}.g-button[data-v-054c5b31]:not(.is-disabled):active{border-color:color-mix(in srgb,var(--g-primary-color, #039be5) 70%,#000);color:color-mix(in srgb,var(--g-primary-color, #039be5) 70%,#000)}.g-button.is-block[data-v-054c5b31]{display:flex;width:100%}.g-button.is-disabled[data-v-054c5b31]{cursor:not-allowed;opacity:.5}.g-button--large[data-v-054c5b31]{height:40px;padding:0 20px;font-size:16px;border-radius:calc(var(--g-button-radius, 6px) + 2px)}.g-button--small[data-v-054c5b31]{height:24px;padding:0 7px;font-size:12px;border-radius:calc(var(--g-button-radius, 6px) - 2px)}.g-button--primary[data-v-054c5b31]{--g-button-wave-color: #fff;color:#fff;background:var(--g-primary-color, #039be5);border-color:var(--g-primary-color, #039be5)}.g-button--primary[data-v-054c5b31]:not(.is-disabled):hover,.g-button--primary[data-v-054c5b31]:not(.is-disabled):focus-visible{color:#fff;background:color-mix(in srgb,var(--g-primary-color, #039be5) 85%,#fff)}.g-button--primary[data-v-054c5b31]:not(.is-disabled):active{color:#fff;background:color-mix(in srgb,var(--g-primary-color, #039be5) 70%,#000)}.g-button--success[data-v-054c5b31],.g-button--warning[data-v-054c5b31],.g-button--danger[data-v-054c5b31]{--g-button-wave-color: #fff;color:#fff}.g-button--success[data-v-054c5b31]:not(.is-disabled):hover,.g-button--success[data-v-054c5b31]:not(.is-disabled):focus-visible,.g-button--warning[data-v-054c5b31]:not(.is-disabled):hover,.g-button--warning[data-v-054c5b31]:not(.is-disabled):focus-visible,.g-button--danger[data-v-054c5b31]:not(.is-disabled):hover,.g-button--danger[data-v-054c5b31]:not(.is-disabled):focus-visible{color:#fff;background:color-mix(in srgb,var(--g-button-type-color) 85%,#fff)}.g-button--success[data-v-054c5b31]:not(.is-disabled):active,.g-button--warning[data-v-054c5b31]:not(.is-disabled):active,.g-button--danger[data-v-054c5b31]:not(.is-disabled):active{color:#fff;background:color-mix(in srgb,var(--g-button-type-color) 70%,#000)}.g-button--success[data-v-054c5b31]{--g-button-type-color: var(--g-success-color, #50c189);background:var(--g-button-type-color);border-color:var(--g-button-type-color)}.g-button--warning[data-v-054c5b31]{--g-button-type-color: var(--g-warning-color, #f78716);background:var(--g-button-type-color);border-color:var(--g-button-type-color)}.g-button--danger[data-v-054c5b31]{--g-button-type-color: var(--g-danger-color, #e1594d);background:var(--g-button-type-color);border-color:var(--g-button-type-color)}.g-button--emphasis[data-v-054c5b31]{--g-button-wave-color: var(--g-emphasis-text-color, #fff);color:var(--g-emphasis-text-color, #fff);background:var(--g-emphasis-color, #000)}.g-button--emphasis[data-v-054c5b31]:not(.is-disabled):hover,.g-button--emphasis[data-v-054c5b31]:not(.is-disabled):focus-visible{color:var(--g-emphasis-text-color, #fff);background:color-mix(in srgb,var(--g-emphasis-color, #000) 85%,var(--g-emphasis-text-color, #fff))}.g-button--emphasis[data-v-054c5b31]:not(.is-disabled):active{color:var(--g-emphasis-text-color, #fff);background:color-mix(in srgb,var(--g-emphasis-color, #000) 70%,var(--g-emphasis-text-color, #fff))}.g-button--link[data-v-054c5b31]{height:auto;padding:2px 5px;background:transparent;border-color:transparent}.g-button--link[data-v-054c5b31]:not(.is-disabled):hover,.g-button--link[data-v-054c5b31]:not(.is-disabled):focus-visible{color:color-mix(in srgb,var(--g-primary-color, #039be5) 85%,#fff);background:transparent}.g-button__loading[data-v-054c5b31]{width:1em;height:1em;border:2px solid currentcolor;border-top-color:transparent;border-radius:50%;animation:g-button-spin-054c5b31 .6s linear infinite}.g-button__icon[data-v-054c5b31]{display:inline-flex;align-items:center}.g-button__icon[data-v-054c5b31] svg{width:1em;height:1em;display:block}.g-button__wave[data-v-054c5b31]{position:absolute;border-radius:50%;background:var(--g-button-wave-color);opacity:.2;pointer-events:none}@keyframes g-button-spin-054c5b31{to{transform:rotate(360deg)}}
|
package/lib/GButton.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/lib/GCard/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),U=require("../
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),U=require("../GBubble-Dph0YDkU.js"),W={class:"g-card__content"},H=a.defineComponent({__name:"index",props:{className:{default:""},edgeSensitivity:{default:30},glowColor:{default:"40 80 80"},backgroundColor:{},borderRadius:{default:28},glowRadius:{default:40},glowIntensity:{default:1},coneSpread:{default:25},animated:{type:Boolean,default:!1},colors:{default:()=>["#c084fc","#f472b6","#38bdf8"]},fillOpacity:{default:.5},shadow:{type:Boolean,default:!0},glow:{type:Boolean,default:!0}},setup(v){function B(e){const t=e.match(/([\d.]+)\s*([\d.]+)%?\s*([\d.]+)%?/);return t?{h:parseFloat(t[1]),s:parseFloat(t[2]),l:parseFloat(t[3])}:{h:40,s:80,l:80}}function O(e,t){const{h:n,s:o,l}=B(e),c=`${n}deg ${o}% ${l}%`;return[[0,0,0,1,100,!0],[0,0,1,0,60,!0],[0,0,3,0,50,!0],[0,0,6,0,40,!0],[0,0,15,0,30,!0],[0,0,25,2,20,!0],[0,0,50,2,10,!0],[0,0,1,0,60,!1],[0,0,3,0,50,!1],[0,0,6,0,40,!1],[0,0,15,0,30,!1],[0,0,25,2,20,!1],[0,0,50,2,10,!1]].map(([d,s,$,k,T,q])=>{const D=Math.min(T*t,100);return`${q?"inset ":""}${d}px ${s}px ${$}px ${k}px hsl(${c} / ${D}%)`}).join(", ")}function C(e){return 1-Math.pow(1-e,3)}function w(e){return e*e*e}function b({start:e=0,end:t=100,duration:n=1e3,delay:o=0,ease:l=C,onUpdate:c,onEnd:i}){const d=performance.now()+o;function s(){const $=performance.now()-d,k=Math.min($/n,1);c(e+(t-e)*l(k)),k<1?requestAnimationFrame(s):i&&i()}setTimeout(()=>requestAnimationFrame(s),o)}const P=["80% 55%","69% 34%","8% 6%","41% 38%","86% 85%","82% 18%","51% 4%"],E=[0,1,2,0,1,2,1];function N(e){const t=[];for(let n=0;n<7;n++){const o=e[Math.min(E[n],e.length-1)];t.push(`radial-gradient(at ${P[n]}, ${o} 0px, transparent 50%)`)}return t.push(`linear-gradient(${e[0]} 0 100%)`),t}const r=v,S=a.computed(()=>r.backgroundColor??"transparent"),x=a.useTemplateRef("cardRef"),y=a.ref(!1),f=a.ref(45),p=a.ref(0),h=a.ref(!1),M=e=>{const{width:t,height:n}=e.getBoundingClientRect();return[t/2,n/2]},z=(e,t,n)=>{const[o,l]=M(e),c=t-o,i=n-l;let d=1/0,s=1/0;return c!==0&&(d=o/Math.abs(c)),i!==0&&(s=l/Math.abs(i)),Math.min(Math.max(1/Math.min(d,s),0),1)},V=(e,t,n)=>{const[o,l]=M(e),c=t-o,i=n-l;if(c===0&&i===0)return 0;let s=Math.atan2(i,c)*(180/Math.PI)+90;return s<0&&(s+=360),s},A=e=>{const t=x.value;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left,l=e.clientY-n.top;p.value=z(t,o,l),f.value=V(t,o,l)};a.watch(()=>r.animated,()=>{if(!r.animated)return;const e=110,t=465;h.value=!0,f.value=e,b({duration:500,onUpdate:n=>p.value=n/100}),b({ease:w,duration:1500,end:50,onUpdate:n=>{f.value=(t-e)*(n/100)+e}}),b({ease:C,delay:1500,duration:2250,start:50,end:100,onUpdate:n=>{f.value=(t-e)*(n/100)+e}}),b({ease:w,delay:2500,duration:1500,start:100,end:0,onUpdate:n=>p.value=n/100,onEnd:()=>h.value=!1})},{immediate:!0});const _=a.computed(()=>r.edgeSensitivity+20),g=a.computed(()=>y.value||h.value),I=a.computed(()=>g.value?Math.max(0,(p.value*100-_.value)/(100-_.value)):0),F=a.computed(()=>g.value?Math.max(0,(p.value*100-r.edgeSensitivity)/(100-r.edgeSensitivity)):0),R=a.computed(()=>N(r.colors)),j=a.computed(()=>R.value.map(e=>`${e} border-box`)),G=a.computed(()=>R.value.map(e=>`${e} padding-box`)),u=a.computed(()=>`${f.value.toFixed(3)}deg`);return(e,t)=>(a.openBlock(),a.createElementBlock("div",{ref_key:"cardRef",ref:x,onPointermove:A,onPointerenter:t[0]||(t[0]=n=>y.value=!0),onPointerleave:t[1]||(t[1]=n=>y.value=!1),class:a.normalizeClass(["g-card",{"g-card--shadow":r.shadow},r.className]),style:a.normalizeStyle({background:S.value,borderRadius:r.borderRadius+"px"})},[r.glow?(a.openBlock(),a.createElementBlock(a.Fragment,{key:0},[a.createElementVNode("div",{class:"g-card__border",style:a.normalizeStyle({background:[`linear-gradient(${S.value} 0 100%) padding-box`,"linear-gradient(rgb(255 255 255 / 0%) 0% 100%) border-box",...j.value].join(", "),opacity:I.value,maskImage:`conic-gradient(from ${u.value} at center, black ${r.coneSpread}%, transparent ${r.coneSpread+15}%, transparent ${100-r.coneSpread-15}%, black ${100-r.coneSpread}%)`,WebkitMaskImage:`conic-gradient(from ${u.value} at center, black ${r.coneSpread}%, transparent ${r.coneSpread+15}%, transparent ${100-r.coneSpread-15}%, black ${100-r.coneSpread}%)`,transition:g.value?"opacity 0.25s ease-out":"opacity 0.75s ease-in-out"})},null,4),a.createElementVNode("div",{class:"g-card__fill",style:a.normalizeStyle({background:G.value.join(", "),maskImage:["linear-gradient(to bottom, black, black)","radial-gradient(ellipse at 50% 50%, black 40%, transparent 65%)","radial-gradient(ellipse at 66% 66%, black 5%, transparent 40%)","radial-gradient(ellipse at 33% 33%, black 5%, transparent 40%)","radial-gradient(ellipse at 66% 33%, black 5%, transparent 40%)","radial-gradient(ellipse at 33% 66%, black 5%, transparent 40%)",`conic-gradient(from ${u.value} at center, transparent 5%, black 15%, black 85%, transparent 95%)`].join(", "),WebkitMaskImage:["linear-gradient(to bottom, black, black)","radial-gradient(ellipse at 50% 50%, black 40%, transparent 65%)","radial-gradient(ellipse at 66% 66%, black 5%, transparent 40%)","radial-gradient(ellipse at 33% 33%, black 5%, transparent 40%)","radial-gradient(ellipse at 66% 33%, black 5%, transparent 40%)","radial-gradient(ellipse at 33% 66%, black 5%, transparent 40%)",`conic-gradient(from ${u.value} at center, transparent 5%, black 15%, black 85%, transparent 95%)`].join(", "),opacity:I.value*r.fillOpacity,transition:g.value?"opacity 0.25s ease-out":"opacity 0.75s ease-in-out"})},null,4),a.createElementVNode("span",{class:"g-card__glow",style:a.normalizeStyle({inset:`-${r.glowRadius}px`,maskImage:`conic-gradient(from ${u.value} at center, black 2.5%, transparent 10%, transparent 90%, black 97.5%)`,WebkitMaskImage:`conic-gradient(from ${u.value} at center, black 2.5%, transparent 10%, transparent 90%, black 97.5%)`,opacity:F.value,transition:g.value?"opacity 0.25s ease-out":"opacity 0.75s ease-in-out"})},[a.createElementVNode("span",{class:"g-card__glow-inner",style:a.normalizeStyle({inset:`${r.glowRadius}px`,boxShadow:O(r.glowColor,r.glowIntensity)})},null,4)],4)],64)):a.createCommentVNode("",!0),a.createElementVNode("div",W,[a.renderSlot(e.$slots,"default",{},void 0,!0)])],38))}}),m=U._export_sfc(H,[["__scopeId","data-v-c2ad9d99"]]),L=[{name:"Daylight",colors:["#5464f6ff","#c084fc","#38bdf8"],glowColor:"220 80 60",backgroundColor:"#f8fafc",dark:!1},{name:"Quartz",colors:["#f472b6","#fb7185","#f9a8d4"],glowColor:"340 80 65",backgroundColor:"#f8fafc",dark:!1},{name:"Matcha",colors:["#34d399","#86efac","#fbbf24"],glowColor:"150 60 50",backgroundColor:"#f8fafc",dark:!1},{name:"Ocean",colors:["#0ea5e9","#22d3ee","#6366f1"],glowColor:"200 90 65",backgroundColor:"#f8fafc",dark:!1},{name:"Daylight",colors:["#c084fc","#f472b6","#38bdf8"],glowColor:"280 80 75",backgroundColor:"#1d1e1f",dark:!0},{name:"Quartz",colors:["#f97316","#f43f5e","#facc15"],glowColor:"20 90 65",backgroundColor:"#1d1e1f",dark:!0},{name:"Matcha",colors:["#34d399","#10b981","#a7f3d0"],glowColor:"150 70 65",backgroundColor:"#1d1e1f",dark:!0},{name:"Ocean",colors:["#0ea5e9","#22d3ee","#6366f1"],glowColor:"200 90 65",backgroundColor:"#1d1e1f",dark:!0}];m.install=v=>{v.component(m.name,m)};exports.GCard=m;exports.cardPresets=L;exports.default=m;
|
package/lib/GCard/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as X, computed as i, useTemplateRef as Y, ref as y, watch as J, createElementBlock as A, openBlock as F, normalizeStyle as b, normalizeClass as K, createCommentVNode as Z, createElementVNode as m, Fragment as ee, renderSlot as ae } from "vue";
|
|
2
|
-
import { _ as te } from "../
|
|
2
|
+
import { _ as te } from "../GBubble-C3cM9Put.mjs";
|
|
3
3
|
const ne = { class: "g-card__content" }, re = /* @__PURE__ */ X({
|
|
4
4
|
__name: "index",
|
|
5
5
|
props: {
|