cos-design 2.1.0 → 2.2.0

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.js CHANGED
@@ -1,428 +1,563 @@
1
- import { jsx as o, jsxs as N } from "react/jsx-runtime";
2
- import { useRef as P, useCallback as X, useEffect as w, useState as $ } from "react";
3
- import './index.css';const et = "cos-canvasClock", nt = "cos-canvasTarget", G = {
4
- canvasClock: et,
5
- canvasTarget: nt
6
- }, Gt = ({ width: e = 400, height: s = 400 }) => {
7
- const d = P(null), l = Math.min(e, s), r = l / 2 - 16, m = l / 2, y = X(
8
- (t) => {
9
- t.clearRect(0, 0, l, l), t.save(), t.translate(m, m), t.beginPath(), t.arc(0, 0, r, 0, Math.PI * 2), t.fillStyle = "#fff", t.fill(), t.strokeStyle = "#d1d5db", t.lineWidth = 2, t.stroke();
10
- for (let x = 0; x < 60; x++) {
11
- const i = x / 60 * Math.PI * 2, h = r - (x % 5 === 0 ? 14 : 8);
12
- t.beginPath(), t.moveTo(Math.cos(i) * h, Math.sin(i) * h), t.lineTo(Math.cos(i) * r, Math.sin(i) * r), t.strokeStyle = x % 5 === 0 ? "#374151" : "#9ca3af", t.lineWidth = x % 5 === 0 ? 2 : 1, t.stroke();
13
- }
14
- t.fillStyle = "#111827", t.font = `bold ${Math.floor(l / 22)}px system-ui, sans-serif`, t.textAlign = "center", t.textBaseline = "middle";
15
- for (let x = 1; x <= 12; x++) {
16
- const i = x / 12 * Math.PI * 2 - Math.PI / 2, h = r - 32;
17
- t.fillText(String(x), Math.cos(i) * h, Math.sin(i) * h);
18
- }
19
- const c = /* @__PURE__ */ new Date(), g = c.getHours() % 12, f = c.getMinutes(), v = c.getSeconds(), M = c.getMilliseconds(), a = (x, i, h, p, n) => {
20
- t.save(), t.rotate(x), t.beginPath(), t.moveTo(0, h), t.lineTo(i, 0), t.lineTo(0, -h), t.closePath(), t.fillStyle = p, t.shadowColor = n, t.shadowBlur = 4, t.fill(), t.restore();
21
- }, u = (g + f / 60) / 12 * Math.PI * 2 - Math.PI / 2, T = (f + v / 60) / 60 * Math.PI * 2 - Math.PI / 2, b = (v + M / 1e3) / 60 * Math.PI * 2 - Math.PI / 2;
22
- a(u, r * 0.5, 4, "#111827", "rgb(0 0 0 / 40%)"), a(T, r * 0.72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), a(b, r * 0.85, 2, "#e9686b", "rgb(233 104 107 / 40%)"), t.beginPath(), t.arc(0, 0, 5, 0, Math.PI * 2), t.fillStyle = "#111827", t.fill(), t.restore();
23
- },
24
- [m, r, l]
25
- );
26
- return w(() => {
27
- const t = d.current;
28
- if (!t) return;
29
- const c = window.devicePixelRatio || 1;
30
- t.width = l * c, t.height = l * c;
31
- const g = t.getContext("2d");
32
- if (!g) return;
33
- g.setTransform(c, 0, 0, c, 0, 0);
34
- let f = 0;
35
- const v = () => {
36
- y(g), f = requestAnimationFrame(v);
37
- };
38
- return v(), () => cancelAnimationFrame(f);
39
- }, [y, l]), /* @__PURE__ */ o("div", { className: G.canvasClock, style: { width: l, height: l }, children: /* @__PURE__ */ o("canvas", { ref: d, className: G.canvasTarget, style: { width: l, height: l } }) });
40
- }, st = "cos-chargeContainer", at = "cos-contrast", ot = "cos-text", rt = "cos-circle", ct = "cos-button", E = {
41
- chargeContainer: st,
42
- contrast: at,
43
- text: ot,
44
- circle: rt,
45
- button: ct
46
- }, Jt = (e) => {
47
- const { initQuantity: s = 0 } = e, [d, l] = $(s);
48
- return w(() => {
49
- let r = d;
50
- setInterval(() => {
51
- r = Number(Number(r += 0.01).toFixed(2)), l(r);
52
- }, 500);
53
- }, []), /* @__PURE__ */ o("div", { className: E.chargeContainer, children: /* @__PURE__ */ N("div", { className: E.contrast, children: [
54
- /* @__PURE__ */ N("div", { className: E.text, children: [
55
- d ? d.toString().padEnd(4, "0") : 0,
56
- "%"
57
- ] }),
58
- /* @__PURE__ */ o("span", {}),
59
- /* @__PURE__ */ o("span", {}),
60
- /* @__PURE__ */ o("span", {}),
61
- /* @__PURE__ */ o("span", {}),
62
- /* @__PURE__ */ o("span", {}),
63
- /* @__PURE__ */ o("span", {}),
64
- /* @__PURE__ */ o("span", {}),
65
- /* @__PURE__ */ o("span", {}),
66
- /* @__PURE__ */ o("span", {}),
67
- /* @__PURE__ */ o("span", {}),
68
- /* @__PURE__ */ o("span", {}),
69
- /* @__PURE__ */ o("span", {}),
70
- /* @__PURE__ */ o("span", {}),
71
- /* @__PURE__ */ o("span", {}),
72
- /* @__PURE__ */ o("span", {}),
73
- /* @__PURE__ */ o("div", { className: E.circle }),
74
- /* @__PURE__ */ o("div", { className: E.button })
75
- ] }) });
76
- }, lt = "cos-fireworks", it = "cos-canvas", dt = "cos-hint", Q = {
77
- fireworks: lt,
78
- canvas: it,
79
- hint: dt
80
- }, J = ["#ff6b6b", "#ffd93d", "#6bcb77", "#4d96ff", "#a66cff", "#ff85c0"], z = () => J[Math.floor(Math.random() * J.length)], ft = (e, s, d) => {
81
- const l = 60 + Math.floor(Math.random() * 30);
82
- return Array.from({ length: l }, () => {
83
- const r = Math.random() * Math.PI * 2, m = Math.random() * 4 + 2;
84
- return {
85
- x: e,
86
- y: s,
87
- vx: Math.cos(r) * m,
88
- vy: Math.sin(r) * m,
89
- alpha: 1,
90
- color: Math.random() > 0.3 ? d : z(),
91
- decay: Math.random() * 0.015 + 0.01
92
- };
93
- });
94
- }, Kt = ({ width: e = 800, height: s = 500, auto: d = !0 }) => {
95
- const l = P(null), r = P([]), m = P(0), y = X(
96
- (c) => {
97
- const g = c ?? Math.random() * e * 0.6 + e * 0.2;
98
- r.current.push({
99
- x: g,
100
- y: s,
101
- vy: -(Math.random() * 4 + 6),
102
- targetY: Math.random() * s * 0.4 + s * 0.1,
103
- color: z(),
104
- exploded: !1,
105
- particles: []
106
- });
107
- },
108
- [s, e]
109
- );
110
- w(() => {
111
- const c = l.current;
112
- if (!c) return;
113
- const g = window.devicePixelRatio || 1;
114
- c.width = e * g, c.height = s * g;
115
- const f = c.getContext("2d");
116
- if (!f) return;
117
- f.setTransform(g, 0, 0, g, 0, 0);
118
- let v = 0;
119
- const M = () => {
120
- m.current = requestAnimationFrame(M), f.fillStyle = "rgb(15 23 42 / 25%)", f.fillRect(0, 0, e, s), d && Math.random() < 0.03 && y(), r.current = r.current.filter((a) => a.exploded ? (a.particles = a.particles.filter((u) => (u.x += u.vx, u.y += u.vy, u.vy += 0.06, u.alpha -= u.decay, u.alpha <= 0 ? !1 : (f.beginPath(), f.arc(u.x, u.y, 2, 0, Math.PI * 2), f.fillStyle = u.color, f.globalAlpha = u.alpha, f.fill(), f.globalAlpha = 1, !0))), a.particles.length > 0) : (a.y += a.vy, a.vy *= 0.98, f.beginPath(), f.arc(a.x, a.y, 2.5, 0, Math.PI * 2), f.fillStyle = a.color, f.fill(), (a.vy >= 0 || a.y <= a.targetY) && (a.exploded = !0, a.particles = ft(a.x, a.y, a.color)), !0));
121
- };
122
- return M(), d && (v = window.setInterval(() => y(), 1200)), () => {
123
- cancelAnimationFrame(m.current), clearInterval(v);
124
- };
125
- }, [d, s, y, e]);
126
- const t = (c) => {
127
- const g = c.currentTarget.getBoundingClientRect();
128
- y(c.clientX - g.left);
129
- };
130
- return /* @__PURE__ */ N("div", { className: Q.fireworks, style: { width: e, height: s }, children: [
131
- /* @__PURE__ */ o("canvas", { ref: l, className: Q.canvas, style: { width: e, height: s }, onClick: t }),
132
- /* @__PURE__ */ o("p", { className: Q.hint, children: "点击画布燃放烟花" })
133
- ] });
134
- }, ut = "cos-matrixRain", mt = "cos-canvas", ht = "cos-overlay", yt = "cos-title", vt = "cos-subtitle", q = {
135
- matrixRain: ut,
136
- canvas: mt,
137
- overlay: ht,
138
- title: yt,
139
- subtitle: vt
140
- }, K = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", Vt = ({ width: e = 800, height: s = 500, density: d = 0.6, color: l = "#00ff41" }) => {
141
- const r = P(null);
142
- return w(() => {
143
- const m = r.current;
144
- if (!m) return;
145
- const y = window.devicePixelRatio || 1;
146
- m.width = e * y, m.height = s * y;
147
- const t = m.getContext("2d");
148
- if (!t) return;
149
- t.setTransform(y, 0, 0, y, 0, 0);
150
- const c = 16, g = Math.floor(e / c * d), f = Array.from({ length: g }, () => Math.random() * -50);
151
- let v = 0;
152
- const M = () => {
153
- t.fillStyle = "rgb(0 0 0 / 8%)", t.fillRect(0, 0, e, s), t.fillStyle = l, t.font = `${c}px monospace`, f.forEach((a, u) => {
154
- const T = K[Math.floor(Math.random() * K.length)], b = u / d * c;
155
- t.fillStyle = l, t.fillText(T, b, a * c), a * c > s && Math.random() > 0.975 && (f[u] = 0), f[u] += 1;
156
- }), v = requestAnimationFrame(M);
157
- };
158
- return M(), () => cancelAnimationFrame(v);
159
- }, [l, d, s, e]), /* @__PURE__ */ N("div", { className: q.matrixRain, style: { width: e, height: s }, children: [
160
- /* @__PURE__ */ o("canvas", { ref: r, className: q.canvas, style: { width: e, height: s } }),
161
- /* @__PURE__ */ N("div", { className: q.overlay, children: [
162
- /* @__PURE__ */ o("h2", { className: q.title, children: "MATRIX" }),
163
- /* @__PURE__ */ o("p", { className: q.subtitle, children: "数字雨效果" })
164
- ] })
165
- ] });
166
- }, gt = "cos-neonText", pt = "cos-text", Mt = "cos-flicker", bt = "cos-reflection", O = {
167
- neonText: gt,
168
- text: pt,
169
- flicker: Mt,
170
- reflection: bt
171
- }, zt = ({ text: e = "NEON", color: s = "#ff00de", fontSize: d = 72, flicker: l = !0 }) => /* @__PURE__ */ N("div", { className: O.neonText, children: [
172
- /* @__PURE__ */ o(
173
- "h1",
174
- {
175
- className: `${O.text} ${l ? O.flicker : ""}`,
176
- style: {
177
- fontSize: d,
178
- "--neon-color": s
179
- },
180
- children: e
181
- }
182
- ),
183
- /* @__PURE__ */ o("p", { className: O.reflection, style: { fontSize: d * 0.35, color: s }, children: e })
184
- ] }), xt = "cos-particleNetwork", Nt = "cos-canvas", Ct = "cos-hint", U = {
185
- particleNetwork: xt,
186
- canvas: Nt,
187
- hint: Ct
188
- }, te = ({
189
- width: e = 800,
190
- height: s = 500,
191
- particleCount: d = 60,
192
- linkDistance: l = 120,
193
- color: r = "#38bdf8"
194
- }) => {
195
- const m = P(null), y = P([]), t = P({ x: -1e3, y: -1e3 }), c = X(() => {
196
- y.current = Array.from({ length: d }, () => ({
197
- x: Math.random() * e,
198
- y: Math.random() * s,
199
- vx: (Math.random() - 0.5) * 1.2,
200
- vy: (Math.random() - 0.5) * 1.2,
201
- radius: Math.random() * 2 + 1
202
- }));
203
- }, [s, d, e]);
204
- w(() => {
205
- c();
206
- }, [c]), w(() => {
207
- const v = m.current;
208
- if (!v) return;
209
- const M = window.devicePixelRatio || 1;
210
- v.width = e * M, v.height = s * M;
211
- const a = v.getContext("2d");
212
- if (!a) return;
213
- a.setTransform(M, 0, 0, M, 0, 0);
214
- let u = 0;
215
- const T = () => {
216
- a.fillStyle = "#0f172a", a.fillRect(0, 0, e, s);
217
- const b = y.current, x = t.current;
218
- b.forEach((i) => {
219
- i.x += i.vx, i.y += i.vy, (i.x < 0 || i.x > e) && (i.vx *= -1), (i.y < 0 || i.y > s) && (i.vy *= -1);
220
- const h = x.x - i.x, p = x.y - i.y;
221
- Math.sqrt(h * h + p * p) < 150 && (i.vx -= h * 3e-4, i.vy -= p * 3e-4);
222
- });
223
- for (let i = 0; i < b.length; i++)
224
- for (let h = i + 1; h < b.length; h++) {
225
- const p = b[i].x - b[h].x, n = b[i].y - b[h].y, C = Math.sqrt(p * p + n * n);
226
- C < l && (a.beginPath(), a.moveTo(b[i].x, b[i].y), a.lineTo(b[h].x, b[h].y), a.strokeStyle = r, a.globalAlpha = 1 - C / l, a.lineWidth = 0.8, a.stroke(), a.globalAlpha = 1);
227
- }
228
- b.forEach((i) => {
229
- a.beginPath(), a.arc(i.x, i.y, i.radius, 0, Math.PI * 2), a.fillStyle = r, a.fill();
230
- }), u = requestAnimationFrame(T);
231
- };
232
- return T(), () => cancelAnimationFrame(u);
233
- }, [r, s, c, l, e]);
234
- const g = (v) => {
235
- const M = v.currentTarget.getBoundingClientRect();
236
- t.current = { x: v.clientX - M.left, y: v.clientY - M.top };
237
- }, f = () => {
238
- t.current = { x: -1e3, y: -1e3 };
239
- };
240
- return /* @__PURE__ */ N("div", { className: U.particleNetwork, style: { width: e, height: s }, children: [
241
- /* @__PURE__ */ o(
242
- "canvas",
243
- {
244
- ref: m,
245
- className: U.canvas,
246
- style: { width: e, height: s },
247
- onMouseMove: g,
248
- onMouseLeave: f
249
- }
250
- ),
251
- /* @__PURE__ */ o("p", { className: U.hint, children: "移动鼠标与粒子互动" })
252
- ] });
253
- }, Pt = "cos-returnCityContainer", It = "cos-star", wt = "cos-glassWrap", Tt = "cos-glassItem", H = {
254
- returnCityContainer: Pt,
255
- star: It,
256
- glassWrap: wt,
257
- glassItem: Tt
258
- }, ee = () => {
259
- const e = (d, l) => {
260
- for (let r = 0; r < l; r++)
261
- setTimeout(function() {
262
- const m = document.createElement("div");
263
- m.className = H.star;
264
- const y = document.body.clientWidth, t = document.body.clientHeight, c = Math.random() * y + "px", g = Math.random() * t + "px";
265
- m.style.top = g, m.style.left = c, d.append(m);
266
- }, Math.random() * 2e3);
267
- }, s = () => {
268
- const l = "150px", r = document.getElementById("glassWrap");
269
- if (r)
270
- for (let m = 0; m < 6; m++) {
271
- const y = document.createElement("div");
272
- y.className = H.glassItem, y.style.transform = `rotateY(${m * 60}deg) translateZ(${l})`, r.appendChild(y), setTimeout(() => {
273
- y.style.top = "0px", y.style.opacity = "1";
274
- }, m * 300);
275
- }
276
- };
277
- return w(() => {
278
- const d = document.getElementById("returnCityContainer");
279
- d && e(d, document.documentElement.clientWidth / 20), s();
280
- }, []), /* @__PURE__ */ o("div", { id: "returnCityContainer", className: H.returnCityContainer, children: /* @__PURE__ */ o("div", { id: "glassWrap", className: H.glassWrap }) });
281
- }, Rt = "cos-turntable", At = "cos-wheelWrap", St = "cos-canvas", Ft = "cos-pointer", Bt = "cos-spinBtn", $t = "cos-result", F = {
282
- turntable: Rt,
283
- wheelWrap: At,
284
- canvas: St,
285
- pointer: Ft,
286
- spinBtn: Bt,
287
- result: $t
288
- }, V = ["#FF6B6B", "#4ECDC4", "#FFE66D", "#A78BFA", "#60A5FA", "#F472B6", "#34D399", "#FB923C"], Wt = [
289
- { label: "一等奖" },
290
- { label: "二等奖" },
291
- { label: "三等奖" },
292
- { label: "谢谢参与" },
293
- { label: "优惠券" },
294
- { label: "再来一次" }
295
- ], kt = (e) => 1 - Math.pow(1 - e, 3), ne = ({
296
- prizes: e = Wt,
297
- size: s = 360,
298
- spinDuration: d = 4e3,
299
- spinRounds: l = 5,
300
- buttonText: r = "开始抽奖",
301
- onSpinEnd: m
302
- }) => {
303
- const y = P(null), t = P(0), c = P(0), g = P(1), [f, v] = $(!1), [M, a] = $(null), u = s + 48, T = (h, p) => p.color ?? V[h % V.length], b = X(
304
- (h) => {
305
- const p = y.current;
306
- if (!p) return;
307
- const n = p.getContext("2d");
308
- if (!n) return;
309
- const C = u / 2, R = s / 2, W = Math.PI * 2 / e.length;
310
- n.clearRect(0, 0, u, u), n.save(), n.translate(C, C), n.rotate(h), e.forEach((I, S) => {
311
- const A = S * W - Math.PI / 2, k = A + W, Y = T(S, I);
312
- n.beginPath(), n.moveTo(0, 0), n.arc(0, 0, R, A, k), n.closePath(), n.fillStyle = Y, n.fill(), n.strokeStyle = "rgb(255 255 255 / 35%)", n.lineWidth = 2, n.stroke(), n.save(), n.rotate(A + W / 2), n.textAlign = "right", n.fillStyle = "#fff", n.font = `bold ${Math.max(12, Math.floor(s / 22))}px system-ui, sans-serif`, n.shadowColor = "rgb(0 0 0 / 30%)", n.shadowBlur = 4, n.fillText(I.label, R - 18, 6), n.restore();
313
- }), n.beginPath(), n.arc(0, 0, R, 0, Math.PI * 2), n.strokeStyle = "#fbbf24", n.lineWidth = 6, n.stroke(), n.beginPath(), n.arc(0, 0, R - 4, 0, Math.PI * 2), n.strokeStyle = "#f59e0b", n.lineWidth = 2, n.stroke(), n.restore(), n.save(), n.translate(C, C);
314
- for (let I = 0; I < 12; I++) {
315
- const S = I / 12 * Math.PI * 2, A = Math.cos(S) * (R + 14), k = Math.sin(S) * (R + 14);
316
- n.beginPath(), n.arc(A, k, 3, 0, Math.PI * 2), n.fillStyle = I % 2 === 0 ? "#fde68a" : "#f59e0b", n.fill();
317
- }
318
- n.restore();
319
- },
320
- [u, e, s]
321
- );
322
- w(() => {
323
- const h = y.current;
324
- if (!h) return;
325
- const p = window.devicePixelRatio || 1;
326
- g.current = p, h.width = u * p, h.height = u * p;
327
- const n = h.getContext("2d");
328
- n && n.setTransform(p, 0, 0, p, 0, 0), b(t.current);
329
- }, [u, b]), w(() => () => {
330
- c.current && cancelAnimationFrame(c.current);
331
- }, []);
332
- const x = (h) => {
333
- const p = 360 / e.length, n = (h * (180 / Math.PI) % 360 + 360) % 360;
334
- return Math.floor((360 - n + p / 2) % 360 / p) % e.length;
335
- }, i = () => {
336
- if (f || e.length === 0) return;
337
- v(!0), a(null);
338
- const h = Math.PI * 2 / e.length, n = Math.floor(Math.random() * e.length) * h + h / 2, C = t.current, R = l * Math.PI * 2, W = C + R + (Math.PI * 2 - n) - C % (Math.PI * 2), I = C, S = performance.now(), A = (k) => {
339
- const Y = k - S, j = Math.min(Y / d, 1), tt = kt(j), L = I + (W - I) * tt;
340
- if (t.current = L, b(L), j < 1)
341
- c.current = requestAnimationFrame(A);
342
- else {
343
- const Z = x(L), _ = e[Z];
344
- t.current = L, v(!1), a(_), m == null || m(_, Z);
345
- }
346
- };
347
- c.current = requestAnimationFrame(A);
348
- };
349
- return /* @__PURE__ */ N("div", { className: F.turntable, style: { width: u, height: u + 80 }, children: [
350
- /* @__PURE__ */ N("div", { className: F.wheelWrap, style: { width: u, height: u }, children: [
351
- /* @__PURE__ */ o("div", { className: F.pointer }),
352
- /* @__PURE__ */ o("canvas", { ref: y, className: F.canvas, style: { width: u, height: u } }),
353
- /* @__PURE__ */ o("button", { type: "button", className: F.spinBtn, onClick: i, disabled: f, children: f ? "抽奖中..." : r })
354
- ] }),
355
- M && !f && /* @__PURE__ */ N("p", { className: F.result, children: [
356
- "恭喜获得:",
357
- /* @__PURE__ */ o("strong", { children: M.label })
358
- ] })
359
- ] });
360
- }, Et = "cos-typewriter", qt = "cos-terminal", Dt = "cos-dots", Lt = "cos-text", Ot = "cos-prompt", Ht = "cos-cursor", B = {
361
- typewriter: Et,
362
- terminal: qt,
363
- dots: Dt,
364
- text: Lt,
365
- prompt: Ot,
366
- cursor: Ht
367
- }, Xt = ["Hello, cos-design!", "欢迎来到组件库 ✨", "Build something fun 🚀"], se = ({
368
- texts: e = Xt,
369
- speed: s = 100,
370
- deleteSpeed: d = 50,
371
- pause: l = 2e3
372
- }) => {
373
- const [r, m] = $(""), [y, t] = $(0), [c, g] = $(!1);
374
- return w(() => {
375
- const f = e[y % e.length];
376
- let v;
377
- if (!c && r === f)
378
- v = setTimeout(() => g(!0), l);
379
- else if (c && r === "")
380
- g(!1), t((M) => (M + 1) % e.length);
381
- else {
382
- const M = c ? f.slice(0, r.length - 1) : f.slice(0, r.length + 1);
383
- v = setTimeout(() => m(M), c ? d : s);
384
- }
385
- return () => clearTimeout(v);
386
- }, [r, c, y, e, s, d, l]), /* @__PURE__ */ o("div", { className: B.typewriter, children: /* @__PURE__ */ N("div", { className: B.terminal, children: [
387
- /* @__PURE__ */ N("div", { className: B.dots, children: [
388
- /* @__PURE__ */ o("span", {}),
389
- /* @__PURE__ */ o("span", {}),
390
- /* @__PURE__ */ o("span", {})
391
- ] }),
392
- /* @__PURE__ */ N("p", { className: B.text, children: [
393
- /* @__PURE__ */ o("span", { className: B.prompt, children: ">" }),
394
- r,
395
- /* @__PURE__ */ o("span", { className: B.cursor, children: "|" })
396
- ] })
397
- ] }) });
398
- }, Yt = "cos-waveButton", Qt = "cos-btn", Ut = "cos-label", jt = "cos-wave", D = {
399
- waveButton: Yt,
400
- btn: Qt,
401
- label: Ut,
402
- wave: jt
403
- }, ae = ({ text: e = "点我试试", onClick: s, color: d = "#38bdf8" }) => /* @__PURE__ */ o("div", { className: D.waveButton, children: /* @__PURE__ */ N(
404
- "button",
405
- {
406
- type: "button",
407
- className: D.btn,
408
- style: { "--wave-color": d },
409
- onClick: s,
410
- children: [
411
- /* @__PURE__ */ o("span", { className: D.wave }),
412
- /* @__PURE__ */ o("span", { className: D.wave }),
413
- /* @__PURE__ */ o("span", { className: D.label, children: e })
414
- ]
415
- }
416
- ) });
417
- export {
418
- Gt as CanvasClock,
419
- Jt as Charge,
420
- Kt as Fireworks,
421
- Vt as MatrixRain,
422
- zt as NeonText,
423
- te as ParticleNetwork,
424
- ee as ReturnCity,
425
- ne as Turntable,
426
- se as Typewriter,
427
- ae as WaveButton
428
- };
1
+ import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
3
+ import './index.css';var o = {
4
+ canvasClock: "cos-canvasClock",
5
+ canvasTarget: "cos-canvasTarget"
6
+ }, s = ({ width: r = 400, height: a = 400 }) => {
7
+ let s = n(null), c = Math.min(r, a), l = c / 2 - 16, u = c / 2, d = e((e) => {
8
+ e.clearRect(0, 0, c, c), e.save(), e.translate(u, u), e.beginPath(), e.arc(0, 0, l, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill(), e.strokeStyle = "#d1d5db", e.lineWidth = 2, e.stroke();
9
+ for (let t = 0; t < 60; t++) {
10
+ let n = t / 60 * Math.PI * 2, r = l - (t % 5 == 0 ? 14 : 8);
11
+ e.beginPath(), e.moveTo(Math.cos(n) * r, Math.sin(n) * r), e.lineTo(Math.cos(n) * l, Math.sin(n) * l), e.strokeStyle = t % 5 == 0 ? "#374151" : "#9ca3af", e.lineWidth = t % 5 == 0 ? 2 : 1, e.stroke();
12
+ }
13
+ e.fillStyle = "#111827", e.font = `bold ${Math.floor(c / 22)}px system-ui, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
14
+ for (let t = 1; t <= 12; t++) {
15
+ let n = t / 12 * Math.PI * 2 - Math.PI / 2, r = l - 32;
16
+ e.fillText(String(t), Math.cos(n) * r, Math.sin(n) * r);
17
+ }
18
+ let t = /* @__PURE__ */ new Date(), n = t.getHours() % 12, r = t.getMinutes(), i = t.getSeconds(), a = t.getMilliseconds(), o = (t, n, r, i, a) => {
19
+ e.save(), e.rotate(t), e.beginPath(), e.moveTo(0, r), e.lineTo(n, 0), e.lineTo(0, -r), e.closePath(), e.fillStyle = i, e.shadowColor = a, e.shadowBlur = 4, e.fill(), e.restore();
20
+ }, s = (n + r / 60) / 12 * Math.PI * 2 - Math.PI / 2, d = (r + i / 60) / 60 * Math.PI * 2 - Math.PI / 2, f = (i + a / 1e3) / 60 * Math.PI * 2 - Math.PI / 2;
21
+ o(s, l * .5, 4, "#111827", "rgb(0 0 0 / 40%)"), o(d, l * .72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), o(f, l * .85, 2, "#e9686b", "rgb(233 104 107 / 40%)"), e.beginPath(), e.arc(0, 0, 5, 0, Math.PI * 2), e.fillStyle = "#111827", e.fill(), e.restore();
22
+ }, [
23
+ u,
24
+ l,
25
+ c
26
+ ]);
27
+ return t(() => {
28
+ let e = s.current;
29
+ if (!e) return;
30
+ let t = window.devicePixelRatio || 1;
31
+ e.width = c * t, e.height = c * t;
32
+ let n = e.getContext("2d");
33
+ if (!n) return;
34
+ n.setTransform(t, 0, 0, t, 0, 0);
35
+ let r = 0, i = () => {
36
+ d(n), r = requestAnimationFrame(i);
37
+ };
38
+ return i(), () => cancelAnimationFrame(r);
39
+ }, [d, c]), /* @__PURE__ */ i("div", {
40
+ className: o.canvasClock,
41
+ style: {
42
+ width: c,
43
+ height: c
44
+ },
45
+ children: /* @__PURE__ */ i("canvas", {
46
+ ref: s,
47
+ className: o.canvasTarget,
48
+ style: {
49
+ width: c,
50
+ height: c
51
+ }
52
+ })
53
+ });
54
+ }, c = {
55
+ chargeContainer: "cos-chargeContainer",
56
+ contrast: "cos-contrast",
57
+ hueRotate: "cos-hueRotate",
58
+ text: "cos-text",
59
+ moveUp: "cos-moveUp",
60
+ circle: "cos-circle",
61
+ circleRotate: "cos-circleRotate",
62
+ button: "cos-button"
63
+ }, l = (e) => {
64
+ let { initQuantity: n = 0 } = e, [o, s] = r(n);
65
+ return t(() => {
66
+ let e = o;
67
+ setInterval(() => {
68
+ e = Number(Number(e += .01).toFixed(2)), s(e);
69
+ }, 500);
70
+ }, []), /* @__PURE__ */ i("div", {
71
+ className: c.chargeContainer,
72
+ children: /* @__PURE__ */ a("div", {
73
+ className: c.contrast,
74
+ children: [
75
+ /* @__PURE__ */ a("div", {
76
+ className: c.text,
77
+ children: [o ? o.toString().padEnd(4, "0") : 0, "%"]
78
+ }),
79
+ /* @__PURE__ */ i("span", {}),
80
+ /* @__PURE__ */ i("span", {}),
81
+ /* @__PURE__ */ i("span", {}),
82
+ /* @__PURE__ */ i("span", {}),
83
+ /* @__PURE__ */ i("span", {}),
84
+ /* @__PURE__ */ i("span", {}),
85
+ /* @__PURE__ */ i("span", {}),
86
+ /* @__PURE__ */ i("span", {}),
87
+ /* @__PURE__ */ i("span", {}),
88
+ /* @__PURE__ */ i("span", {}),
89
+ /* @__PURE__ */ i("span", {}),
90
+ /* @__PURE__ */ i("span", {}),
91
+ /* @__PURE__ */ i("span", {}),
92
+ /* @__PURE__ */ i("span", {}),
93
+ /* @__PURE__ */ i("span", {}),
94
+ /* @__PURE__ */ i("div", { className: c.circle }),
95
+ /* @__PURE__ */ i("div", { className: c.button })
96
+ ]
97
+ })
98
+ });
99
+ }, u = {
100
+ fireworks: "cos-fireworks",
101
+ canvas: "cos-canvas",
102
+ hint: "cos-hint"
103
+ }, d = [
104
+ "#ff6b6b",
105
+ "#ffd93d",
106
+ "#6bcb77",
107
+ "#4d96ff",
108
+ "#a66cff",
109
+ "#ff85c0"
110
+ ], f = () => d[Math.floor(Math.random() * d.length)], p = (e, t, n) => {
111
+ let r = 60 + Math.floor(Math.random() * 30);
112
+ return Array.from({ length: r }, () => {
113
+ let r = Math.random() * Math.PI * 2, i = Math.random() * 4 + 2;
114
+ return {
115
+ x: e,
116
+ y: t,
117
+ vx: Math.cos(r) * i,
118
+ vy: Math.sin(r) * i,
119
+ alpha: 1,
120
+ color: Math.random() > .3 ? n : f(),
121
+ decay: Math.random() * .015 + .01
122
+ };
123
+ });
124
+ }, m = ({ width: r = 800, height: o = 500, auto: s = !0 }) => {
125
+ let c = n(null), l = n([]), d = n(0), m = e((e) => {
126
+ let t = e ?? Math.random() * r * .6 + r * .2;
127
+ l.current.push({
128
+ x: t,
129
+ y: o,
130
+ vy: -(Math.random() * 4 + 6),
131
+ targetY: Math.random() * o * .4 + o * .1,
132
+ color: f(),
133
+ exploded: !1,
134
+ particles: []
135
+ });
136
+ }, [o, r]);
137
+ return t(() => {
138
+ let e = c.current;
139
+ if (!e) return;
140
+ let t = window.devicePixelRatio || 1;
141
+ e.width = r * t, e.height = o * t;
142
+ let n = e.getContext("2d");
143
+ if (!n) return;
144
+ n.setTransform(t, 0, 0, t, 0, 0);
145
+ let i = 0, a = () => {
146
+ d.current = requestAnimationFrame(a), n.fillStyle = "rgb(15 23 42 / 25%)", n.fillRect(0, 0, r, o), s && Math.random() < .03 && m(), l.current = l.current.filter((e) => e.exploded ? (e.particles = e.particles.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += .06, e.alpha -= e.decay, e.alpha <= 0 ? !1 : (n.beginPath(), n.arc(e.x, e.y, 2, 0, Math.PI * 2), n.fillStyle = e.color, n.globalAlpha = e.alpha, n.fill(), n.globalAlpha = 1, !0))), e.particles.length > 0) : (e.y += e.vy, e.vy *= .98, n.beginPath(), n.arc(e.x, e.y, 2.5, 0, Math.PI * 2), n.fillStyle = e.color, n.fill(), (e.vy >= 0 || e.y <= e.targetY) && (e.exploded = !0, e.particles = p(e.x, e.y, e.color)), !0));
147
+ };
148
+ return a(), s && (i = window.setInterval(() => m(), 1200)), () => {
149
+ cancelAnimationFrame(d.current), clearInterval(i);
150
+ };
151
+ }, [
152
+ s,
153
+ o,
154
+ m,
155
+ r
156
+ ]), /* @__PURE__ */ a("div", {
157
+ className: u.fireworks,
158
+ style: {
159
+ width: r,
160
+ height: o
161
+ },
162
+ children: [/* @__PURE__ */ i("canvas", {
163
+ ref: c,
164
+ className: u.canvas,
165
+ style: {
166
+ width: r,
167
+ height: o
168
+ },
169
+ onClick: (e) => {
170
+ let t = e.currentTarget.getBoundingClientRect();
171
+ m(e.clientX - t.left);
172
+ }
173
+ }), /* @__PURE__ */ i("p", {
174
+ className: u.hint,
175
+ children: "点击画布燃放烟花"
176
+ })]
177
+ });
178
+ }, h = {
179
+ matrixRain: "cos-matrixRain",
180
+ canvas: "cos-canvas",
181
+ overlay: "cos-overlay",
182
+ title: "cos-title",
183
+ flicker: "cos-flicker",
184
+ subtitle: "cos-subtitle"
185
+ }, g = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", _ = ({ width: e = 800, height: r = 500, density: o = .6, color: s = "#00ff41" }) => {
186
+ let c = n(null);
187
+ return t(() => {
188
+ let t = c.current;
189
+ if (!t) return;
190
+ let n = window.devicePixelRatio || 1;
191
+ t.width = e * n, t.height = r * n;
192
+ let i = t.getContext("2d");
193
+ if (!i) return;
194
+ i.setTransform(n, 0, 0, n, 0, 0);
195
+ let a = Math.floor(e / 16 * o), l = Array.from({ length: a }, () => Math.random() * -50), u = 0, d = () => {
196
+ i.fillStyle = "rgb(0 0 0 / 8%)", i.fillRect(0, 0, e, r), i.fillStyle = s, i.font = "16px monospace", l.forEach((e, t) => {
197
+ let n = g[Math.floor(Math.random() * 53)], a = t / o * 16;
198
+ i.fillStyle = s, i.fillText(n, a, e * 16), e * 16 > r && Math.random() > .975 && (l[t] = 0), l[t] += 1;
199
+ }), u = requestAnimationFrame(d);
200
+ };
201
+ return d(), () => cancelAnimationFrame(u);
202
+ }, [
203
+ s,
204
+ o,
205
+ r,
206
+ e
207
+ ]), /* @__PURE__ */ a("div", {
208
+ className: h.matrixRain,
209
+ style: {
210
+ width: e,
211
+ height: r
212
+ },
213
+ children: [/* @__PURE__ */ i("canvas", {
214
+ ref: c,
215
+ className: h.canvas,
216
+ style: {
217
+ width: e,
218
+ height: r
219
+ }
220
+ }), /* @__PURE__ */ a("div", {
221
+ className: h.overlay,
222
+ children: [/* @__PURE__ */ i("h2", {
223
+ className: h.title,
224
+ children: "MATRIX"
225
+ }), /* @__PURE__ */ i("p", {
226
+ className: h.subtitle,
227
+ children: "数字雨效果"
228
+ })]
229
+ })]
230
+ });
231
+ }, v = {
232
+ neonText: "cos-neonText",
233
+ text: "cos-text",
234
+ flicker: "cos-flicker",
235
+ "neon-flicker": "cos-neon-flicker",
236
+ reflection: "cos-reflection"
237
+ }, y = ({ text: e = "NEON", color: t = "#ff00de", fontSize: n = 72, flicker: r = !0 }) => /* @__PURE__ */ a("div", {
238
+ className: v.neonText,
239
+ children: [/* @__PURE__ */ i("h1", {
240
+ className: `${v.text} ${r ? v.flicker : ""}`,
241
+ style: {
242
+ fontSize: n,
243
+ "--neon-color": t
244
+ },
245
+ children: e
246
+ }), /* @__PURE__ */ i("p", {
247
+ className: v.reflection,
248
+ style: {
249
+ fontSize: n * .35,
250
+ color: t
251
+ },
252
+ children: e
253
+ })]
254
+ }), b = {
255
+ particleNetwork: "cos-particleNetwork",
256
+ canvas: "cos-canvas",
257
+ hint: "cos-hint"
258
+ }, x = ({ width: r = 800, height: o = 500, particleCount: s = 60, linkDistance: c = 120, color: l = "#38bdf8" }) => {
259
+ let u = n(null), d = n([]), f = n({
260
+ x: -1e3,
261
+ y: -1e3
262
+ }), p = e(() => {
263
+ d.current = Array.from({ length: s }, () => ({
264
+ x: Math.random() * r,
265
+ y: Math.random() * o,
266
+ vx: (Math.random() - .5) * 1.2,
267
+ vy: (Math.random() - .5) * 1.2,
268
+ radius: Math.random() * 2 + 1
269
+ }));
270
+ }, [
271
+ o,
272
+ s,
273
+ r
274
+ ]);
275
+ return t(() => {
276
+ p();
277
+ }, [p]), t(() => {
278
+ let e = u.current;
279
+ if (!e) return;
280
+ let t = window.devicePixelRatio || 1;
281
+ e.width = r * t, e.height = o * t;
282
+ let n = e.getContext("2d");
283
+ if (!n) return;
284
+ n.setTransform(t, 0, 0, t, 0, 0);
285
+ let i = 0, a = () => {
286
+ n.fillStyle = "#0f172a", n.fillRect(0, 0, r, o);
287
+ let e = d.current, t = f.current;
288
+ e.forEach((e) => {
289
+ e.x += e.vx, e.y += e.vy, (e.x < 0 || e.x > r) && (e.vx *= -1), (e.y < 0 || e.y > o) && (e.vy *= -1);
290
+ let n = t.x - e.x, i = t.y - e.y;
291
+ Math.sqrt(n * n + i * i) < 150 && (e.vx -= n * 3e-4, e.vy -= i * 3e-4);
292
+ });
293
+ for (let t = 0; t < e.length; t++) for (let r = t + 1; r < e.length; r++) {
294
+ let i = e[t].x - e[r].x, a = e[t].y - e[r].y, o = Math.sqrt(i * i + a * a);
295
+ o < c && (n.beginPath(), n.moveTo(e[t].x, e[t].y), n.lineTo(e[r].x, e[r].y), n.strokeStyle = l, n.globalAlpha = 1 - o / c, n.lineWidth = .8, n.stroke(), n.globalAlpha = 1);
296
+ }
297
+ e.forEach((e) => {
298
+ n.beginPath(), n.arc(e.x, e.y, e.radius, 0, Math.PI * 2), n.fillStyle = l, n.fill();
299
+ }), i = requestAnimationFrame(a);
300
+ };
301
+ return a(), () => cancelAnimationFrame(i);
302
+ }, [
303
+ l,
304
+ o,
305
+ p,
306
+ c,
307
+ r
308
+ ]), /* @__PURE__ */ a("div", {
309
+ className: b.particleNetwork,
310
+ style: {
311
+ width: r,
312
+ height: o
313
+ },
314
+ children: [/* @__PURE__ */ i("canvas", {
315
+ ref: u,
316
+ className: b.canvas,
317
+ style: {
318
+ width: r,
319
+ height: o
320
+ },
321
+ onMouseMove: (e) => {
322
+ let t = e.currentTarget.getBoundingClientRect();
323
+ f.current = {
324
+ x: e.clientX - t.left,
325
+ y: e.clientY - t.top
326
+ };
327
+ },
328
+ onMouseLeave: () => {
329
+ f.current = {
330
+ x: -1e3,
331
+ y: -1e3
332
+ };
333
+ }
334
+ }), /* @__PURE__ */ i("p", {
335
+ className: b.hint,
336
+ children: "移动鼠标与粒子互动"
337
+ })]
338
+ });
339
+ }, S = {
340
+ returnCityContainer: "cos-returnCityContainer",
341
+ star: "cos-star",
342
+ glassWrap: "cos-glassWrap",
343
+ rotate: "cos-rotate",
344
+ glassItem: "cos-glassItem"
345
+ }, C = () => {
346
+ let e = (e, t) => {
347
+ for (let n = 0; n < t; n++) setTimeout(function() {
348
+ let t = document.createElement("div");
349
+ t.className = S.star;
350
+ let n = document.body.clientWidth, r = document.body.clientHeight, i = Math.random() * n + "px", a = Math.random() * r + "px";
351
+ t.style.top = a, t.style.left = i, e.append(t);
352
+ }, Math.random() * 2e3);
353
+ }, n = () => {
354
+ let e = document.getElementById("glassWrap");
355
+ if (e) for (let t = 0; t < 6; t++) {
356
+ let n = document.createElement("div");
357
+ n.className = S.glassItem, n.style.transform = `rotateY(${360 / 6 * t}deg) translateZ(150px)`, e.appendChild(n), setTimeout(() => {
358
+ n.style.top = "0px", n.style.opacity = "1";
359
+ }, t * 300);
360
+ }
361
+ };
362
+ return t(() => {
363
+ let t = document.getElementById("returnCityContainer");
364
+ t && e(t, document.documentElement.clientWidth / 20), n();
365
+ }, []), /* @__PURE__ */ i("div", {
366
+ id: "returnCityContainer",
367
+ className: S.returnCityContainer,
368
+ children: /* @__PURE__ */ i("div", {
369
+ id: "glassWrap",
370
+ className: S.glassWrap
371
+ })
372
+ });
373
+ }, w = {
374
+ turntable: "cos-turntable",
375
+ wheelWrap: "cos-wheelWrap",
376
+ canvas: "cos-canvas",
377
+ pointer: "cos-pointer",
378
+ spinBtn: "cos-spinBtn",
379
+ result: "cos-result",
380
+ "fade-in": "cos-fade-in"
381
+ }, T = [
382
+ "#FF6B6B",
383
+ "#4ECDC4",
384
+ "#FFE66D",
385
+ "#A78BFA",
386
+ "#60A5FA",
387
+ "#F472B6",
388
+ "#34D399",
389
+ "#FB923C"
390
+ ], E = [
391
+ { label: "一等奖" },
392
+ { label: "二等奖" },
393
+ { label: "三等奖" },
394
+ { label: "谢谢参与" },
395
+ { label: "优惠券" },
396
+ { label: "再来一次" }
397
+ ], D = (e) => 1 - (1 - e) ** 3, O = ({ prizes: o = E, size: s = 360, spinDuration: c = 4e3, spinRounds: l = 5, buttonText: u = "开始抽奖", onSpinEnd: d }) => {
398
+ let f = n(null), p = n(0), m = n(0), h = n(1), [g, _] = r(!1), [v, y] = r(null), b = s + 48, x = (e, t) => t.color ?? T[e % T.length], S = e((e) => {
399
+ let t = f.current;
400
+ if (!t) return;
401
+ let n = t.getContext("2d");
402
+ if (!n) return;
403
+ let r = b / 2, i = s / 2, a = Math.PI * 2 / o.length;
404
+ n.clearRect(0, 0, b, b), n.save(), n.translate(r, r), n.rotate(e), o.forEach((e, t) => {
405
+ let r = t * a - Math.PI / 2, o = r + a, c = x(t, e);
406
+ n.beginPath(), n.moveTo(0, 0), n.arc(0, 0, i, r, o), n.closePath(), n.fillStyle = c, n.fill(), n.strokeStyle = "rgb(255 255 255 / 35%)", n.lineWidth = 2, n.stroke(), n.save(), n.rotate(r + a / 2), n.textAlign = "right", n.fillStyle = "#fff", n.font = `bold ${Math.max(12, Math.floor(s / 22))}px system-ui, sans-serif`, n.shadowColor = "rgb(0 0 0 / 30%)", n.shadowBlur = 4, n.fillText(e.label, i - 18, 6), n.restore();
407
+ }), n.beginPath(), n.arc(0, 0, i, 0, Math.PI * 2), n.strokeStyle = "#fbbf24", n.lineWidth = 6, n.stroke(), n.beginPath(), n.arc(0, 0, i - 4, 0, Math.PI * 2), n.strokeStyle = "#f59e0b", n.lineWidth = 2, n.stroke(), n.restore(), n.save(), n.translate(r, r);
408
+ for (let e = 0; e < 12; e++) {
409
+ let t = e / 12 * Math.PI * 2, r = Math.cos(t) * (i + 14), a = Math.sin(t) * (i + 14);
410
+ n.beginPath(), n.arc(r, a, 3, 0, Math.PI * 2), n.fillStyle = e % 2 == 0 ? "#fde68a" : "#f59e0b", n.fill();
411
+ }
412
+ n.restore();
413
+ }, [
414
+ b,
415
+ o,
416
+ s
417
+ ]);
418
+ t(() => {
419
+ let e = f.current;
420
+ if (!e) return;
421
+ let t = window.devicePixelRatio || 1;
422
+ h.current = t, e.width = b * t, e.height = b * t;
423
+ let n = e.getContext("2d");
424
+ n && n.setTransform(t, 0, 0, t, 0, 0), S(p.current);
425
+ }, [b, S]), t(() => () => {
426
+ m.current && cancelAnimationFrame(m.current);
427
+ }, []);
428
+ let C = (e) => {
429
+ let t = 360 / o.length, n = (180 / Math.PI * e % 360 + 360) % 360;
430
+ return Math.floor((360 - n + t / 2) % 360 / t) % o.length;
431
+ };
432
+ return /* @__PURE__ */ a("div", {
433
+ className: w.turntable,
434
+ style: {
435
+ width: b,
436
+ height: b + 80
437
+ },
438
+ children: [/* @__PURE__ */ a("div", {
439
+ className: w.wheelWrap,
440
+ style: {
441
+ width: b,
442
+ height: b
443
+ },
444
+ children: [
445
+ /* @__PURE__ */ i("div", { className: w.pointer }),
446
+ /* @__PURE__ */ i("canvas", {
447
+ ref: f,
448
+ className: w.canvas,
449
+ style: {
450
+ width: b,
451
+ height: b
452
+ }
453
+ }),
454
+ /* @__PURE__ */ i("button", {
455
+ type: "button",
456
+ className: w.spinBtn,
457
+ onClick: () => {
458
+ if (g || o.length === 0) return;
459
+ _(!0), y(null);
460
+ let e = Math.PI * 2 / o.length, t = Math.floor(Math.random() * o.length) * e + e / 2, n = p.current, r = n + l * Math.PI * 2 + (Math.PI * 2 - t) - n % (Math.PI * 2), i = n, a = performance.now(), s = (e) => {
461
+ let t = e - a, n = Math.min(t / c, 1), l = D(n), u = i + (r - i) * l;
462
+ if (p.current = u, S(u), n < 1) m.current = requestAnimationFrame(s);
463
+ else {
464
+ let e = C(u), t = o[e];
465
+ p.current = u, _(!1), y(t), d?.(t, e);
466
+ }
467
+ };
468
+ m.current = requestAnimationFrame(s);
469
+ },
470
+ disabled: g,
471
+ children: g ? "抽奖中..." : u
472
+ })
473
+ ]
474
+ }), v && !g && /* @__PURE__ */ a("p", {
475
+ className: w.result,
476
+ children: ["恭喜获得:", /* @__PURE__ */ i("strong", { children: v.label })]
477
+ })]
478
+ });
479
+ }, k = {
480
+ typewriter: "cos-typewriter",
481
+ terminal: "cos-terminal",
482
+ dots: "cos-dots",
483
+ text: "cos-text",
484
+ prompt: "cos-prompt",
485
+ cursor: "cos-cursor",
486
+ blink: "cos-blink"
487
+ }, A = [
488
+ "Hello, cos-design!",
489
+ "欢迎来到组件库 ✨",
490
+ "Build something fun 🚀"
491
+ ], j = ({ texts: e = A, speed: n = 100, deleteSpeed: o = 50, pause: s = 2e3 }) => {
492
+ let [c, l] = r(""), [u, d] = r(0), [f, p] = r(!1);
493
+ return t(() => {
494
+ let t = e[u % e.length], r;
495
+ if (!f && c === t) r = setTimeout(() => p(!0), s);
496
+ else if (f && c === "") r = setTimeout(() => {
497
+ p(!1), d((t) => (t + 1) % e.length);
498
+ }, 0);
499
+ else {
500
+ let e = f ? t.slice(0, c.length - 1) : t.slice(0, c.length + 1);
501
+ r = setTimeout(() => l(e), f ? o : n);
502
+ }
503
+ return () => clearTimeout(r);
504
+ }, [
505
+ c,
506
+ f,
507
+ u,
508
+ e,
509
+ n,
510
+ o,
511
+ s
512
+ ]), /* @__PURE__ */ i("div", {
513
+ className: k.typewriter,
514
+ children: /* @__PURE__ */ a("div", {
515
+ className: k.terminal,
516
+ children: [/* @__PURE__ */ a("div", {
517
+ className: k.dots,
518
+ children: [
519
+ /* @__PURE__ */ i("span", {}),
520
+ /* @__PURE__ */ i("span", {}),
521
+ /* @__PURE__ */ i("span", {})
522
+ ]
523
+ }), /* @__PURE__ */ a("p", {
524
+ className: k.text,
525
+ children: [
526
+ /* @__PURE__ */ i("span", {
527
+ className: k.prompt,
528
+ children: ">"
529
+ }),
530
+ c,
531
+ /* @__PURE__ */ i("span", {
532
+ className: k.cursor,
533
+ children: "|"
534
+ })
535
+ ]
536
+ })]
537
+ })
538
+ });
539
+ }, M = {
540
+ waveButton: "cos-waveButton",
541
+ btn: "cos-btn",
542
+ label: "cos-label",
543
+ wave: "cos-wave",
544
+ ripple: "cos-ripple"
545
+ }, N = ({ text: e = "点我试试", onClick: t, color: n = "#38bdf8" }) => /* @__PURE__ */ i("div", {
546
+ className: M.waveButton,
547
+ children: /* @__PURE__ */ a("button", {
548
+ type: "button",
549
+ className: M.btn,
550
+ style: { "--wave-color": n },
551
+ onClick: t,
552
+ children: [
553
+ /* @__PURE__ */ i("span", { className: M.wave }),
554
+ /* @__PURE__ */ i("span", { className: M.wave }),
555
+ /* @__PURE__ */ i("span", {
556
+ className: M.label,
557
+ children: e
558
+ })
559
+ ]
560
+ })
561
+ });
562
+ //#endregion
563
+ export { s as CanvasClock, l as Charge, m as Fireworks, _ as MatrixRain, y as NeonText, x as ParticleNetwork, C as ReturnCity, O as Turntable, j as Typewriter, N as WaveButton };