echo-library-vue 1.0.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.
@@ -0,0 +1,676 @@
1
+ import { defineComponent as Y, computed as w, createElementBlock as F, openBlock as _, normalizeStyle as H, normalizeClass as D, renderSlot as K, createBlock as V, createCommentVNode as S, unref as W, ref as C, watch as J, onMounted as me, createElementVNode as p, withDirectives as ge, vModelText as _e, Fragment as oe, renderList as le, onUnmounted as be, resolveComponent as we, createVNode as ae, resolveDynamicComponent as ee, Transition as ye, withCtx as ke, toDisplayString as Q } from "vue";
2
+ const Ce = /* @__PURE__ */ Y({
3
+ __name: "index",
4
+ props: {
5
+ name: {},
6
+ size: { default: 16 },
7
+ color: { default: "currentColor" },
8
+ spin: { type: Boolean, default: !1 }
9
+ },
10
+ emits: ["click"],
11
+ setup(n, { emit: l }) {
12
+ const t = n, r = l, e = w(() => [
13
+ "echo-icon",
14
+ `echo-icon--${t.name}`,
15
+ {
16
+ "echo-icon--spin": t.spin
17
+ }
18
+ ]), u = w(() => ({
19
+ fontSize: typeof t.size == "number" ? `${t.size}px` : t.size,
20
+ color: t.color
21
+ })), s = (d) => {
22
+ r("click", d);
23
+ };
24
+ return (d, h) => (_(), F("i", {
25
+ class: D(e.value),
26
+ style: H(u.value),
27
+ onClick: s
28
+ }, [
29
+ K(d.$slots, "default", {}, void 0, !0)
30
+ ], 6));
31
+ }
32
+ }), q = (n, l) => {
33
+ const t = n.__vccOpts || n;
34
+ for (const [r, e] of l)
35
+ t[r] = e;
36
+ return t;
37
+ }, U = /* @__PURE__ */ q(Ce, [["__scopeId", "data-v-cf0db90e"]]), xe = ["disabled"], Me = {
38
+ key: 2,
39
+ class: "echo-button__text"
40
+ }, $e = /* @__PURE__ */ Y({
41
+ __name: "index",
42
+ props: {
43
+ type: { default: "primary" },
44
+ size: { default: "medium" },
45
+ disabled: { type: Boolean, default: !1 },
46
+ loading: { type: Boolean, default: !1 },
47
+ round: { type: Boolean, default: !1 },
48
+ plain: { type: Boolean, default: !1 },
49
+ icon: { default: "" }
50
+ },
51
+ emits: ["click"],
52
+ setup(n, { emit: l }) {
53
+ const t = n, r = l, e = w(() => [
54
+ "echo-button",
55
+ `echo-button--${t.type}`,
56
+ `echo-button--${t.size}`,
57
+ {
58
+ "echo-button--disabled": t.disabled,
59
+ "echo-button--loading": t.loading,
60
+ "echo-button--round": t.round,
61
+ "echo-button--plain": t.plain
62
+ }
63
+ ]), u = (s) => {
64
+ t.disabled || t.loading || r("click", s);
65
+ };
66
+ return (s, d) => (_(), F("button", {
67
+ class: D(e.value),
68
+ disabled: n.disabled || n.loading,
69
+ onClick: u
70
+ }, [
71
+ n.loading ? (_(), V(W(U), {
72
+ key: 0,
73
+ name: "loading",
74
+ class: D(["echo-button__loading", { "echo-button__loading--spinning": n.loading }])
75
+ }, null, 8, ["class"])) : n.icon ? (_(), V(W(U), {
76
+ key: 1,
77
+ name: n.icon,
78
+ class: "echo-button__icon"
79
+ }, null, 8, ["name"])) : S("", !0),
80
+ s.$slots.default ? (_(), F("span", Me, [
81
+ K(s.$slots, "default", {}, void 0, !0)
82
+ ])) : S("", !0)
83
+ ], 10, xe));
84
+ }
85
+ }), se = /* @__PURE__ */ q($e, [["__scopeId", "data-v-131d4d78"]]), Fe = [
86
+ "#FFFFFF",
87
+ "#000000",
88
+ "#FF0000",
89
+ "#00FF00",
90
+ "#0000FF",
91
+ "#FF1900",
92
+ "#F47365",
93
+ "#F89C5A",
94
+ "#FAC858",
95
+ "#73B06F",
96
+ "#6ECBE6",
97
+ "#926383",
98
+ "#C89616",
99
+ "#8E00A7",
100
+ "#BF3DCE",
101
+ "#FC3CAD",
102
+ "#FF89CF",
103
+ "#5D61FF",
104
+ "#00BEFF",
105
+ "#1BC7B1"
106
+ ], Ee = (n, l, t) => {
107
+ n /= 255, l /= 255, t /= 255;
108
+ const r = Math.max(n, l, t), e = Math.min(n, l, t);
109
+ let u = 0, s = 0;
110
+ const d = (r + e) / 2;
111
+ if (r !== e) {
112
+ const h = r - e;
113
+ switch (s = d > 0.5 ? h / (2 - r - e) : h / (r + e), r) {
114
+ case n:
115
+ u = ((l - t) / h + (l < t ? 6 : 0)) / 6;
116
+ break;
117
+ case l:
118
+ u = ((t - n) / h + 2) / 6;
119
+ break;
120
+ case t:
121
+ u = ((n - l) / h + 4) / 6;
122
+ break;
123
+ }
124
+ }
125
+ return {
126
+ h: Math.round(u * 360),
127
+ s: Math.round(s * 100),
128
+ l: Math.round(d * 100)
129
+ };
130
+ };
131
+ function Be(n, l, t) {
132
+ n /= 360, l /= 100, t /= 100;
133
+ let r, e, u;
134
+ if (l === 0)
135
+ r = e = u = t;
136
+ else {
137
+ const s = (x, B, b) => (b < 0 && (b += 1), b > 1 && (b -= 1), b < 0.16666666666666666 ? x + (B - x) * 6 * b : b < 0.5 ? B : b < 0.6666666666666666 ? x + (B - x) * (0.6666666666666666 - b) * 6 : x), d = t < 0.5 ? t * (1 + l) : t + l - t * l, h = 2 * t - d;
138
+ r = s(h, d, n + 1 / 3), e = s(h, d, n), u = s(h, d, n - 1 / 3);
139
+ }
140
+ return {
141
+ r: Math.round(r * 255),
142
+ g: Math.round(e * 255),
143
+ b: Math.round(u * 255)
144
+ };
145
+ }
146
+ function te(n) {
147
+ const l = n.replace("#", "");
148
+ return /^[0-9A-Fa-f]{6}$/.test(l) || /^[0-9A-Fa-f]{8}$/.test(l);
149
+ }
150
+ function Le(n, l) {
151
+ const t = n.replace("#", "");
152
+ if (!/^[0-9A-Fa-f]{6}$/.test(t) && !/^[0-9A-Fa-f]{8}$/.test(t))
153
+ return null;
154
+ const r = parseInt(t.substring(0, 2), 16), e = parseInt(t.substring(2, 4), 16), u = parseInt(t.substring(4, 6), 16);
155
+ let s = 1;
156
+ return t.length === 8 && (s = parseInt(t.substring(6, 8), 16) / 255), { r, g: e, b: u, a: s };
157
+ }
158
+ function Re(n, l, t, r = 1) {
159
+ const e = (s) => {
160
+ const d = Math.round(Math.max(0, Math.min(255, s))).toString(16);
161
+ return d.length === 1 ? "0" + d : d;
162
+ }, u = e(r * 255);
163
+ return `#${e(n)}${e(l)}${e(t)}${u}`.toUpperCase();
164
+ }
165
+ function re(n, l, t, r = 1) {
166
+ return { ...Be(n, l, t), a: r };
167
+ }
168
+ function ie(n, l, t, r = 1) {
169
+ return { ...Ee(n, l, t), a: r };
170
+ }
171
+ function ne(n, l, t, r = 1) {
172
+ const e = re(n, l, t, r);
173
+ return Re(e.r, e.g, e.b, e.a);
174
+ }
175
+ function Ie(n) {
176
+ const l = Le(n);
177
+ return l ? ie(l.r, l.g, l.b, l.a) : null;
178
+ }
179
+ function De(n, l, t, r = 1) {
180
+ return `rgba(${n}, ${l}, ${t}, ${r})`;
181
+ }
182
+ const Ae = { class: "color-picker__main" }, He = {
183
+ class: "color-picker__saturation-panel-black",
184
+ style: { background: "linear-gradient(to bottom, transparent, #000)" }
185
+ }, ze = { class: "color-picker__controls" }, Te = { class: "color-picker__controls__input-group" }, Se = ["placeholder"], Pe = { class: "color-picker__controls__eyedropper" }, Ve = ["disabled"], Ue = { class: "color-picker__color-list" }, Oe = ["title", "onClick"], Ne = /* @__PURE__ */ Y({
186
+ __name: "index",
187
+ props: {
188
+ color: {},
189
+ theme: { default: "light" },
190
+ type: { default: "hex" },
191
+ mode: { default: "solid" },
192
+ showAlpha: { type: Boolean, default: !0 },
193
+ showEyeDropper: { type: Boolean, default: !0 },
194
+ showPickerMode: { type: Boolean, default: !0 },
195
+ showColorList: { type: Boolean, default: !0 },
196
+ defaultColors: { default: () => Fe }
197
+ },
198
+ emits: ["update:color", "colorChange"],
199
+ setup(n, { emit: l }) {
200
+ const t = n, r = l, e = C({
201
+ h: 0,
202
+ // 色相 0-360
203
+ s: 0,
204
+ // 饱和度 0-100
205
+ l: 0
206
+ // 明度 0-100
207
+ }), u = C(""), s = C(1), d = C(!0), h = C(null), x = C(null), B = C(null), b = C(null), O = w(() => {
208
+ switch (t.type) {
209
+ case "hex":
210
+ return s.value === 1 ? A.value : G.value;
211
+ case "rgb":
212
+ return s.value === 1 ? y.value : z.value;
213
+ case "hsl":
214
+ return s.value === 1 ? N.value : j.value;
215
+ default:
216
+ return "";
217
+ }
218
+ }), y = w(() => `rgb(${e.value.h}, ${e.value.s}%, ${e.value.l}%)`), z = w(() => {
219
+ const o = re(e.value.h, e.value.s, e.value.l, s.value);
220
+ return De(o.r, o.g, o.b, o.a);
221
+ }), A = w(() => ne(e.value.h, e.value.s, e.value.l, s.value)), G = w(() => ne(e.value.h, e.value.s, e.value.l, s.value)), N = w(() => `hsl(${e.value.h}, ${e.value.s}%, ${e.value.l}%)`), j = w(() => `hsla(${e.value.h}, ${e.value.s}%, ${e.value.l}%, ${s.value})`), R = (o) => {
222
+ switch (t.type) {
223
+ case "hex":
224
+ return Ie(o);
225
+ case "rgb":
226
+ const [a, i, c, m = 1] = o.split(",").map(Number);
227
+ return ie(a, i, c, m);
228
+ case "hsl":
229
+ return console.log(7777, o), null;
230
+ default:
231
+ return null;
232
+ }
233
+ };
234
+ J(
235
+ () => t.color,
236
+ (o) => {
237
+ if (o) {
238
+ const a = R(o);
239
+ if (a) {
240
+ const { h: i, s: c, l: m, a: f } = a;
241
+ e.value.h = i, e.value.s = c, e.value.l = m, s.value = f;
242
+ }
243
+ u.value = o;
244
+ }
245
+ }
246
+ ), J([A, s], () => {
247
+ const o = s.value === 1 ? A.value : G.value;
248
+ o !== t.color && (r("update:color", o), r("colorChange", o), u.value = o);
249
+ });
250
+ let T = !1, L = null;
251
+ const g = (o) => {
252
+ var m;
253
+ if (!x.value) return;
254
+ const a = (m = x.value) == null ? void 0 : m.getBoundingClientRect(), i = Math.max(0, Math.min(o.clientX - a.left, a.width)), c = Math.max(0, Math.min(o.clientY - a.top, a.height));
255
+ e.value.s = Math.round(i / a.width * 100), e.value.l = Math.round((1 - c / a.height) * 100);
256
+ }, k = (o) => {
257
+ var c, m;
258
+ o.preventDefault(), T = !0, g(o);
259
+ const a = (f) => {
260
+ T && (f.preventDefault(), L && (cancelAnimationFrame(L), L = null), L = requestAnimationFrame(() => {
261
+ g(f);
262
+ }));
263
+ }, i = () => {
264
+ var f, E;
265
+ T && (T = !1, L && (cancelAnimationFrame(L), L = null), (f = h.value) == null || f.removeEventListener("mousemove", a), (E = h.value) == null || E.removeEventListener("mouseup", i));
266
+ };
267
+ (c = h.value) == null || c.addEventListener("mousemove", a), (m = h.value) == null || m.addEventListener("mouseup", i);
268
+ };
269
+ let M = !1, v = null;
270
+ const $ = (o) => {
271
+ var c;
272
+ if (!B.value) return;
273
+ const a = (c = B.value) == null ? void 0 : c.getBoundingClientRect(), i = Math.max(0, Math.min(o.clientX - a.left, a.width));
274
+ e.value.h = Math.round(i / a.width * 360);
275
+ }, X = (o) => {
276
+ var c, m;
277
+ o.preventDefault(), M = !0, $(o);
278
+ const a = (f) => {
279
+ M && (f.preventDefault(), v && (cancelAnimationFrame(v), v = null), v = requestAnimationFrame(() => {
280
+ $(f);
281
+ }));
282
+ }, i = () => {
283
+ var f, E;
284
+ M && (M = !1, v && (cancelAnimationFrame(v), v = null), (f = h.value) == null || f.removeEventListener("mousemove", a), (E = h.value) == null || E.removeEventListener("mouseup", i));
285
+ };
286
+ (c = h.value) == null || c.addEventListener("mousemove", a), (m = h.value) == null || m.addEventListener("mouseup", i);
287
+ };
288
+ let P = !1, I = null;
289
+ const Z = (o) => {
290
+ var c;
291
+ if (!b.value) return;
292
+ const a = (c = b.value) == null ? void 0 : c.getBoundingClientRect(), i = Math.max(0, Math.min(o.clientX - a.left, a.width));
293
+ s.value = Math.round(i / a.width * 100) / 100;
294
+ }, he = (o) => {
295
+ var c, m;
296
+ o.preventDefault(), P = !0, Z(o);
297
+ const a = (f) => {
298
+ P && (f.preventDefault(), I && (cancelAnimationFrame(I), I = null), I = requestAnimationFrame(() => {
299
+ Z(f);
300
+ }));
301
+ }, i = () => {
302
+ var f, E;
303
+ P && (P = !1, I && (cancelAnimationFrame(I), I = null), (f = h.value) == null || f.removeEventListener("mousemove", a), (E = h.value) == null || E.removeEventListener("mouseup", i));
304
+ };
305
+ (c = h.value) == null || c.addEventListener("mousemove", a), (m = h.value) == null || m.addEventListener("mouseup", i);
306
+ }, ve = (o) => {
307
+ const a = o.target.value, i = R(u.value);
308
+ if (i) {
309
+ const { h: c, s: m, l: f, a: E } = i;
310
+ e.value.h = c, e.value.s = m, e.value.l = f, s.value = E;
311
+ }
312
+ u.value = a.trim().toUpperCase();
313
+ }, fe = async () => {
314
+ if (d.value)
315
+ try {
316
+ const a = await new window.EyeDropper().open();
317
+ if (a.sRGBHex) {
318
+ const i = R(a.sRGBHex);
319
+ if (i) {
320
+ const { h: c, s: m, l: f, a: E } = i;
321
+ e.value.h = c, e.value.s = m, e.value.l = f, s.value = E;
322
+ }
323
+ }
324
+ } catch (o) {
325
+ o.name !== "AbortError" && console.error("颜色拾取失败", o);
326
+ }
327
+ }, pe = (o) => {
328
+ if (!te(o)) return;
329
+ const a = R(o);
330
+ if (a) {
331
+ const { h: i, s: c, l: m, a: f } = a;
332
+ e.value.h = i, e.value.s = c, e.value.l = m, s.value = f;
333
+ }
334
+ u.value = O.value;
335
+ };
336
+ return me(() => {
337
+ if (d.value = !!window.EyeDropper, t.color && te(t.color)) {
338
+ const o = R(t.color);
339
+ if (o) {
340
+ const { h: a, s: i, l: c, a: m } = o;
341
+ e.value.h = a, e.value.s = i, e.value.l = c, s.value = m;
342
+ }
343
+ u.value = t.color;
344
+ }
345
+ }), (o, a) => (_(), F("div", {
346
+ ref_key: "colorPickerRef",
347
+ ref: h,
348
+ class: D(["color-picker", [`color-picker--${n.theme}`]])
349
+ }, [
350
+ p("div", Ae, [
351
+ p("div", {
352
+ ref_key: "saturationPanelRef",
353
+ ref: x,
354
+ class: "color-picker__saturation-panel",
355
+ style: H({ background: `linear-gradient(to right, #fff, hsl(${e.value.h}, 100%, 50%))` }),
356
+ onMousedown: k
357
+ }, [
358
+ p("div", He, [
359
+ p("div", {
360
+ class: "color-picker__saturation-panel-pointer",
361
+ style: H({
362
+ left: `${e.value.s}%`,
363
+ top: `${100 - e.value.l}%`,
364
+ background: A.value
365
+ })
366
+ }, null, 4)
367
+ ])
368
+ ], 36),
369
+ p("div", {
370
+ ref_key: "hueBarRef",
371
+ ref: B,
372
+ class: "color-picker__hue-bar",
373
+ onMousedown: X
374
+ }, [
375
+ p("div", {
376
+ class: "color-picker__hue-bar-pointer",
377
+ style: H({ left: `${e.value.h / 360 * 100}%` })
378
+ }, null, 4)
379
+ ], 544),
380
+ p("div", {
381
+ ref_key: "alphaBarRef",
382
+ ref: b,
383
+ class: "color-picker__alpha-bar",
384
+ onMousedown: he
385
+ }, [
386
+ p("div", {
387
+ class: "color-picker__alpha-bar-bg",
388
+ style: H({
389
+ background: `linear-gradient(to right, transparent, ${A.value})`
390
+ })
391
+ }, null, 4),
392
+ p("div", {
393
+ class: "color-picker__alpha-bar-pointer",
394
+ style: H({ left: `${s.value * 100}%` })
395
+ }, null, 4)
396
+ ], 544)
397
+ ]),
398
+ p("div", ze, [
399
+ p("div", {
400
+ class: "color-picker__controls__preview",
401
+ style: H({ background: z.value })
402
+ }, null, 4),
403
+ p("div", Te, [
404
+ ge(p("input", {
405
+ type: "text",
406
+ name: "color-input",
407
+ "onUpdate:modelValue": a[0] || (a[0] = (i) => u.value = i),
408
+ class: "color-picker__controls__input-group__input",
409
+ placeholder: s.value < 1 ? "#000000FF" : "#000000",
410
+ onInput: ve
411
+ }, null, 40, Se), [
412
+ [_e, u.value]
413
+ ])
414
+ ]),
415
+ p("div", Pe, [
416
+ p("button", {
417
+ class: "color-picker__controls__eyedropper-btn",
418
+ onClick: fe,
419
+ disabled: !d.value,
420
+ title: "吸取颜色"
421
+ }, [...a[1] || (a[1] = [
422
+ p("svg", {
423
+ t: "1768013548643",
424
+ class: "icon",
425
+ viewBox: "0 0 1109 1024",
426
+ version: "1.1",
427
+ xmlns: "http://www.w3.org/2000/svg",
428
+ "p-id": "1740",
429
+ width: "40",
430
+ height: "40"
431
+ }, [
432
+ p("path", {
433
+ d: "M968.525486 0c22.934274 0 45.015973 9.122555 61.214903 25.15097l53.200696 52.518635a85.257525 85.257525 0 0 1 0 121.321459l-123.367639 121.918261 20.206033 19.950261 4.689164 5.200709a54.564816 54.564816 0 0 1-4.689164 72.724669l-39.218461 38.706916a56.269967 56.269967 0 0 1-78.777953 0.085258l-1.278863-1.278863-486.990984 479.147291a125.072789 125.072789 0 0 1-71.786836 35.381873l-10.230903 0.937833-20.035519 19.609231a109.300147 109.300147 0 0 1-176.056789-30.692709c-17.90408-38.024856-11.850796-83.04083 15.346354-115.012402l6.394315-6.820602 19.95026-19.609231c1.449378-27.197151 11.936054-52.944923 29.669619-73.577244l6.991117-7.502662L660.74582 258.756589l-5.456481-5.371224-9.719358-9.548843-4.689164-5.200709a54.650074 54.650074 0 0 1 4.689164-72.809927l39.047946-38.621658a56.269967 56.269967 0 0 1 78.863211 0l20.206033 19.95026L907.140068 25.236227c16.369445-16.19893 38.365886-25.236227 61.385418-25.236227z",
434
+ fill: "#64666F",
435
+ "p-id": "1741"
436
+ }),
437
+ p("path", {
438
+ d: "M699.111707 292.433311L227.637592 763.05485a68.802823 68.802823 0 0 0-19.097685 37.342796l-0.682061 6.991117-1.193605 20.717579-33.76198 33.847238a52.00709 52.00709 0 0 0-1.70515 70.337458 51.580803 51.580803 0 0 0 69.57014 7.502662l5.115452-4.518649 34.10301-34.10301 20.632321-1.02309a66.330355 66.330355 0 0 0 38.792174-15.090582l5.285966-4.859679 471.3036-470.536281-116.80281-117.314355H699.111707z",
439
+ fill: "#F7F8FA",
440
+ "p-id": "1742"
441
+ })
442
+ ], -1)
443
+ ])], 8, Ve)
444
+ ])
445
+ ]),
446
+ p("div", Ue, [
447
+ (_(!0), F(oe, null, le(n.defaultColors, (i, c) => (_(), F("div", {
448
+ class: "color-picker__color-list__item",
449
+ key: c,
450
+ style: H({ backgroundColor: i }),
451
+ title: i,
452
+ onClick: (m) => pe(i)
453
+ }, null, 12, Oe))), 128))
454
+ ])
455
+ ], 2));
456
+ }
457
+ }), ue = /* @__PURE__ */ q(Ne, [["__scopeId", "data-v-df743242"]]), Xe = { class: "echo-dropdown__menu__list" }, We = ["onClick"], Ye = { class: "echo-dropdown__menu__list__item__label" }, qe = /* @__PURE__ */ Y({
458
+ __name: "index",
459
+ props: {
460
+ trigger: { default: "click" },
461
+ placement: { default: "bottom-start" },
462
+ items: { default: () => [] },
463
+ disabled: { type: Boolean, default: !1 },
464
+ getPopupContainer: {},
465
+ className: {},
466
+ style: {},
467
+ hideOnClick: { type: Boolean, default: !0 },
468
+ icon: {}
469
+ },
470
+ emits: ["select", "openChange"],
471
+ setup(n, { emit: l }) {
472
+ const t = n, r = l, e = C(!1), u = C(null), s = C(null), d = C(null), h = w(() => ({
473
+ "is-disabled": t.disabled,
474
+ "is-visible": e.value
475
+ })), x = w(() => [`echo-dropdown__menu--${t.placement || "bottom-start"}`]), B = w(() => ({})), b = () => {
476
+ t.disabled || t.trigger === "click" && (e.value = !e.value);
477
+ }, O = () => {
478
+ t.disabled || t.trigger === "hover" && (e.value = !0);
479
+ }, y = () => {
480
+ t.trigger === "hover" && setTimeout(() => {
481
+ z.value || (e.value = !1);
482
+ }, 100);
483
+ }, z = C(!1), A = () => {
484
+ z.value = !0;
485
+ }, G = () => {
486
+ z.value = !1, t.trigger === "hover" && N();
487
+ }, N = () => {
488
+ e.value && (e.value = !1, r("openChange", !1));
489
+ }, j = (g, k) => {
490
+ g.disabled || (r("select", g, k), t.hideOnClick && N());
491
+ }, R = () => {
492
+ var I;
493
+ if (!s.value || !d.value) return;
494
+ const g = (I = s.value) == null ? void 0 : I.getBoundingClientRect(), k = d.value.getBoundingClientRect(), M = t.placement || "bottom-start";
495
+ let v = 0, $ = 0;
496
+ M.includes("bottom") ? v = g.bottom + window.scrollY : M.includes("top") ? v = g.top - k.height + window.scrollY : v = g.top, M.includes("start") || M.includes("left") ? $ = g.left + window.scrollX : M.includes("end") || M.includes("right") ? $ = g.right - k.width + window.scrollX : $ = g.left + (g.width - k.width) / 2;
497
+ const X = window.innerWidth, P = window.innerHeight;
498
+ $ < 0 && ($ = 8), $ + k.width > X && ($ = X - k.width - 8), v < 0 && (v = 8), v + k.height > P && (v = P - k.height - 8), d.value.style.left = `${$}px`, d.value.style.top = `${v}px`;
499
+ }, T = (g) => {
500
+ u.value && !u.value.contains(g.target) && e.value && t.trigger === "click" && N();
501
+ }, L = () => {
502
+ e.value && R();
503
+ };
504
+ return J(e, (g) => {
505
+ g ? (document.addEventListener("click", T), window.addEventListener("resize", L), window.addEventListener("scroll", R, !0)) : (document.removeEventListener("click", T), window.removeEventListener("resize", L), window.removeEventListener("scroll", R, !0));
506
+ }), be(() => {
507
+ document.removeEventListener("click", T), window.removeEventListener("resize", L), window.removeEventListener("scroll", R, !0);
508
+ }), (g, k) => {
509
+ const M = we("svg-icon");
510
+ return _(), F("div", {
511
+ ref_key: "dropdownRef",
512
+ ref: u,
513
+ class: D(["echo-dropdown", [h.value]])
514
+ }, [
515
+ p("div", {
516
+ ref_key: "triggerRef",
517
+ ref: s,
518
+ class: D(["echo-dropdown__trigger", { "is-disabled": n.disabled }]),
519
+ onClick: b,
520
+ onMouseenter: O,
521
+ onMouseleave: y
522
+ }, [
523
+ K(g.$slots, "default", {}, () => [
524
+ k[0] || (k[0] = p("span", null, "下拉菜单", -1)),
525
+ n.icon ? (_(), V(ee(n.icon), {
526
+ key: 0,
527
+ class: "echo-dropdown__trigger__icon"
528
+ })) : (_(), V(M, {
529
+ key: 1,
530
+ name: "arrow-down",
531
+ class: "echo-dropdown__trigger__icon"
532
+ }))
533
+ ], !0)
534
+ ], 34),
535
+ ae(ye, { name: "echo-dropdown-fade" }, {
536
+ default: ke(() => [
537
+ e.value ? (_(), F("div", {
538
+ key: 0,
539
+ ref_key: "menuRef",
540
+ ref: d,
541
+ class: D(["echo-dropdown__menu", [x.value]]),
542
+ style: H(B.value),
543
+ onMouseenter: A,
544
+ onMouseleave: G
545
+ }, [
546
+ p("ul", Xe, [
547
+ n.items && n.items.length > 0 ? (_(!0), F(oe, { key: 0 }, le(n.items, (v, $) => (_(), F("li", {
548
+ key: v.key,
549
+ class: D(["echo-dropdown__menu__list__item", [
550
+ {
551
+ "is-disabled": v.disabled,
552
+ "is-divider": v.divider,
553
+ "is-checked": v.checked
554
+ }
555
+ ]]),
556
+ onClick: (X) => j(v, $)
557
+ }, [
558
+ v.icon ? (_(), V(ee(v.icon), {
559
+ key: 0,
560
+ class: "echo-dropdown__menu__list__item__icon"
561
+ })) : S("", !0),
562
+ p("span", Ye, Q(v.label), 1)
563
+ ], 10, We))), 128)) : K(g.$slots, "menu", { key: 1 }, void 0, !0)
564
+ ])
565
+ ], 38)) : S("", !0)
566
+ ]),
567
+ _: 3
568
+ })
569
+ ], 2);
570
+ };
571
+ }
572
+ }), ce = /* @__PURE__ */ q(qe, [["__scopeId", "data-v-f896e925"]]), Ge = { class: "echo-input__wrapper" }, Ke = ["type", "value", "placeholder", "disabled", "readonly", "maxlength"], je = {
573
+ key: 0,
574
+ class: "echo-input__word-limit"
575
+ }, Je = /* @__PURE__ */ Y({
576
+ __name: "index",
577
+ props: {
578
+ modelValue: { default: "" },
579
+ type: { default: "text" },
580
+ placeholder: { default: "" },
581
+ disabled: { type: Boolean, default: !1 },
582
+ readonly: { type: Boolean, default: !1 },
583
+ clearable: { type: Boolean, default: !1 },
584
+ size: { default: "medium" },
585
+ prefixIcon: { default: "" },
586
+ suffixIcon: { default: "" },
587
+ maxlength: { default: void 0 },
588
+ showWordLimit: { type: Boolean, default: !1 }
589
+ },
590
+ emits: ["update:modelValue", "focus", "blur", "clear"],
591
+ setup(n, { emit: l }) {
592
+ const t = n, r = l, e = C(), u = w(() => String(t.modelValue).length), s = w(() => [
593
+ "echo-input",
594
+ `echo-input--${t.size}`,
595
+ {
596
+ "echo-input--disabled": t.disabled,
597
+ "echo-input--with-prefix": t.prefixIcon,
598
+ "echo-input--with-suffix": t.suffixIcon || t.clearable
599
+ }
600
+ ]), d = w(() => [
601
+ "echo-input__inner",
602
+ {
603
+ "echo-input__inner--disabled": t.disabled
604
+ }
605
+ ]), h = (y) => {
606
+ const A = y.target.value;
607
+ r("update:modelValue", A);
608
+ }, x = (y) => {
609
+ r("focus", y);
610
+ }, B = (y) => {
611
+ r("blur", y);
612
+ }, b = (y) => {
613
+ }, O = () => {
614
+ var y;
615
+ r("update:modelValue", ""), r("clear"), (y = e.value) == null || y.focus();
616
+ };
617
+ return (y, z) => (_(), F("div", {
618
+ class: D(s.value)
619
+ }, [
620
+ p("div", Ge, [
621
+ n.prefixIcon ? (_(), V(W(U), {
622
+ key: 0,
623
+ name: n.prefixIcon,
624
+ class: "echo-input__prefix-icon"
625
+ }, null, 8, ["name"])) : S("", !0),
626
+ p("input", {
627
+ ref_key: "inputRef",
628
+ ref: e,
629
+ class: D(d.value),
630
+ type: n.type,
631
+ value: n.modelValue,
632
+ placeholder: n.placeholder,
633
+ disabled: n.disabled,
634
+ readonly: n.readonly,
635
+ maxlength: n.maxlength,
636
+ onInput: h,
637
+ onFocus: x,
638
+ onBlur: B,
639
+ onKeydown: b
640
+ }, null, 42, Ke),
641
+ n.suffixIcon ? (_(), V(W(U), {
642
+ key: 1,
643
+ name: n.suffixIcon,
644
+ class: "echo-input__suffix-icon"
645
+ }, null, 8, ["name"])) : S("", !0),
646
+ n.clearable && n.modelValue ? (_(), F("button", {
647
+ key: 2,
648
+ type: "button",
649
+ class: "echo-input__clear",
650
+ onClick: O
651
+ }, [
652
+ ae(W(U), { name: "close" })
653
+ ])) : S("", !0)
654
+ ]),
655
+ n.showWordLimit && n.maxlength ? (_(), F("div", je, Q(u.value) + "/" + Q(n.maxlength), 1)) : S("", !0)
656
+ ], 2));
657
+ }
658
+ }), de = /* @__PURE__ */ q(Je, [["__scopeId", "data-v-52972a06"]]), Ze = se, et = de, tt = ue, nt = ce, ot = U, lt = {
659
+ install(n) {
660
+ n.component("EchoColorPicker", ue), n.component("EchoDropdown", ce), n.component("EchoIcon", U), n.component("EchoInput", de), n.component("EchoButton", se);
661
+ }
662
+ };
663
+ export {
664
+ se as Button,
665
+ ue as ColorPicker,
666
+ ce as Dropdown,
667
+ Ze as EchoButton,
668
+ tt as EchoColorPicker,
669
+ nt as EchoDropdown,
670
+ ot as EchoIcon,
671
+ et as EchoInput,
672
+ lt as EchoLibrary,
673
+ U as Icon,
674
+ de as Input
675
+ };
676
+ //# sourceMappingURL=index.esm.js.map