geekin-devtoys 0.3.6 → 0.3.7

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.
@@ -1,529 +0,0 @@
1
- import { inject as pe, reactive as ie, computed as d, h as f, defineComponent as x, ref as k, watch as N, onUnmounted as oe, createBlock as _, openBlock as r, Teleport as ne, createVNode as R, unref as I, normalizeStyle as ge, normalizeClass as ae, withCtx as T, createElementVNode as c, toDisplayString as M, createElementBlock as b, createCommentVNode as w, resolveDynamicComponent as ve, renderSlot as P, useId as J, onMounted as ye, Transition as he, withModifiers as ke, mergeProps as _e, Fragment as Q, renderList as we, createTextVNode as F } from "vue";
2
- import { A as be } from "../AnimatePresence-nl0c23TZ.mjs";
3
- import { m as ze } from "../index-Bbr5fWvI.mjs";
4
- import { _ as K } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
5
- const Ce = /* @__PURE__ */ Symbol("GDialogProManager"), ee = {
6
- small: "380px",
7
- medium: "480px",
8
- large: "580px"
9
- }, W = {
10
- ICON_WIDTH: 92,
11
- ICON_HEIGHT: 34,
12
- GAP: 8,
13
- BOTTOM_OFFSET: 18,
14
- RIGHT_OFFSET: 18,
15
- MAX_PER_ROW: 8
16
- };
17
- function Te(l) {
18
- const m = /* @__PURE__ */ new Map(), { ICON_WIDTH: a, ICON_HEIGHT: s, GAP: p, BOTTOM_OFFSET: e, RIGHT_OFFSET: i, MAX_PER_ROW: u } = W;
19
- return l.forEach((g, v) => {
20
- const o = Math.floor(v / u), n = v % u;
21
- m.set(g, {
22
- right: i + n * (a + p),
23
- bottom: e + o * (s + p)
24
- });
25
- }), m;
26
- }
27
- function Je() {
28
- const l = ie(/* @__PURE__ */ new Map()), m = d(() => {
29
- const o = [];
30
- return l.forEach((n) => {
31
- n.isMinimized && o.push(n.id);
32
- }), o;
33
- }), a = d(() => Te(m.value));
34
- function s(o) {
35
- l.set(o.id, { attentionTick: 0, ...o });
36
- }
37
- function p(o) {
38
- l.delete(o);
39
- }
40
- function e(o) {
41
- const n = l.get(o);
42
- if (n) {
43
- if (n.isMinimized) {
44
- n.attentionTick = (n.attentionTick ?? 0) + 1;
45
- return;
46
- }
47
- n.isMinimized = !0;
48
- }
49
- }
50
- function i(o) {
51
- const n = l.get(o);
52
- n?.isMinimized && (n.attentionTick = (n.attentionTick ?? 0) + 1);
53
- }
54
- function u(o) {
55
- const n = l.get(o);
56
- n && (n.isMinimized = !1);
57
- }
58
- function g(o) {
59
- return d(
60
- () => a.value.get(o) ?? {
61
- right: W.RIGHT_OFFSET,
62
- bottom: W.BOTTOM_OFFSET
63
- }
64
- );
65
- }
66
- const v = d(() => m.value.map((o) => l.get(o)).filter(Boolean));
67
- return {
68
- dialogs: l,
69
- register: s,
70
- unregister: p,
71
- minimize: e,
72
- remindMinimized: i,
73
- restore: u,
74
- getPosition: g,
75
- minimizedList: v
76
- };
77
- }
78
- function Me() {
79
- return pe(Ce, null);
80
- }
81
- const L = {
82
- viewBox: "0 0 16 16",
83
- fill: "none",
84
- xmlns: "http://www.w3.org/2000/svg",
85
- "aria-hidden": "true"
86
- }, Ie = () => f("svg", L, [
87
- f("path", {
88
- d: "M3.5 8h9",
89
- stroke: "currentColor",
90
- "stroke-width": 1.6,
91
- "stroke-linecap": "round"
92
- })
93
- ]), Oe = () => f("svg", L, [
94
- f("path", {
95
- d: "M13.5 8a5.5 5.5 0 1 1-1.6-3.9",
96
- stroke: "currentColor",
97
- "stroke-width": 1.6,
98
- "stroke-linecap": "round"
99
- }),
100
- f("path", {
101
- d: "M13.5 2v3.5H10",
102
- stroke: "currentColor",
103
- "stroke-width": 1.6,
104
- "stroke-linecap": "round",
105
- "stroke-linejoin": "round"
106
- })
107
- ]), Be = () => f("svg", L, [
108
- f("circle", {
109
- cx: 8,
110
- cy: 8,
111
- r: 6,
112
- stroke: "currentColor",
113
- "stroke-width": 1.6
114
- }),
115
- f("path", {
116
- d: "M5.3 8.2l1.9 1.9 3.5-4",
117
- stroke: "currentColor",
118
- "stroke-width": 1.6,
119
- "stroke-linecap": "round",
120
- "stroke-linejoin": "round"
121
- })
122
- ]), Ee = () => f("svg", L, [
123
- f("path", {
124
- d: "M2.5 4.5a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v4.5a2 2 0 0 1-2 2H7.2L4.8 13.6V11a2 2 0 0 1-2-2V4.5z",
125
- stroke: "currentColor",
126
- "stroke-width": 1.4,
127
- "stroke-linejoin": "round"
128
- }),
129
- f("circle", { cx: 5.8, cy: 6.7, r: 0.7, fill: "currentColor" }),
130
- f("circle", { cx: 8, cy: 6.7, r: 0.7, fill: "currentColor" }),
131
- f("circle", { cx: 10.2, cy: 6.7, r: 0.7, fill: "currentColor" })
132
- ]), $e = {
133
- class: "g-dialog-pro-minimized-icon__icon",
134
- "aria-hidden": "true"
135
- }, De = { class: "g-dialog-pro-minimized-icon__title" }, Se = /* @__PURE__ */ x({
136
- name: "GDialogMinimizedIcon",
137
- __name: "GDialogMinimizedIcon",
138
- props: {
139
- title: {},
140
- position: {},
141
- attentionTick: { default: 0 }
142
- },
143
- emits: ["restore"],
144
- setup(l, { emit: m }) {
145
- const a = l, s = m, p = d(() => a.title || "弹窗"), e = d(() => `恢复 ${p.value}`), i = { opacity: 0, scale: 0.8, x: -24, y: 12 }, u = { opacity: 1, scale: 1, x: 0, y: 0 }, g = { opacity: 0, scale: 0.8, x: -24, y: 12 }, v = { duration: 0.28, ease: [0.2, 0.8, 0.2, 1] }, o = { scale: 1.04, y: -2 }, n = { scale: 0.98 }, B = d(() => ({
146
- position: "fixed",
147
- right: `${a.position.right}px`,
148
- bottom: `${a.position.bottom}px`
149
- })), z = k(!1);
150
- let E;
151
- N(() => a.attentionTick, (A, y) => {
152
- y === void 0 || A === y || (z.value = !1, window.clearTimeout(E), window.requestAnimationFrame(() => {
153
- z.value = !0, E = window.setTimeout(() => {
154
- z.value = !1;
155
- }, 580);
156
- }));
157
- }), oe(() => {
158
- window.clearTimeout(E);
159
- });
160
- function S() {
161
- s("restore");
162
- }
163
- return (A, y) => (r(), _(ne, { to: "body" }, [
164
- R(I(ze).div, {
165
- class: ae(["g-dialog-pro-minimized-icon", { "is-attention": z.value }]),
166
- type: "button",
167
- style: ge(B.value),
168
- title: e.value,
169
- "aria-label": e.value,
170
- initial: i,
171
- animate: u,
172
- exit: g,
173
- transition: v,
174
- "while-hover": o,
175
- "while-press": n,
176
- onClick: S
177
- }, {
178
- default: T(() => [
179
- y[0] || (y[0] = c("span", {
180
- class: "g-dialog-pro-minimized-icon__glow",
181
- "aria-hidden": "true"
182
- }, null, -1)),
183
- y[1] || (y[1] = c("span", {
184
- class: "g-dialog-pro-minimized-icon__wave",
185
- "aria-hidden": "true"
186
- }, null, -1)),
187
- c("span", $e, [
188
- R(I(Ee))
189
- ]),
190
- c("span", De, M(p.value), 1)
191
- ]),
192
- _: 1,
193
- __: [0, 1]
194
- }, 8, ["class", "style", "title", "aria-label"])
195
- ]));
196
- }
197
- }), j = /* @__PURE__ */ K(Se, [["__scopeId", "data-v-e312df81"]]), Ae = ["disabled"], Ge = {
198
- key: 0,
199
- class: "g-btn__icon g-btn__loading",
200
- "aria-hidden": "true"
201
- }, Fe = {
202
- key: 1,
203
- class: "g-btn__icon",
204
- "aria-hidden": "true"
205
- }, Pe = {
206
- key: 2,
207
- class: "g-btn__text"
208
- }, Re = /* @__PURE__ */ x({
209
- name: "GButton",
210
- __name: "GButton",
211
- props: {
212
- type: { default: "default" },
213
- icon: {},
214
- loading: { type: Boolean, default: !1 },
215
- disabled: { type: Boolean, default: !1 },
216
- plain: { type: Boolean, default: !1 },
217
- size: { default: "default" }
218
- },
219
- emits: ["click"],
220
- setup(l, { emit: m }) {
221
- const a = l, s = m;
222
- function p(e) {
223
- a.disabled || a.loading || s("click", e);
224
- }
225
- return (e, i) => (r(), b("button", {
226
- type: "button",
227
- class: ae(["g-btn", [
228
- `g-btn--${e.type}`,
229
- `g-btn--size-${e.size}`,
230
- {
231
- "is-plain": e.plain,
232
- "is-disabled": e.disabled,
233
- "is-loading": e.loading
234
- }
235
- ]]),
236
- disabled: e.disabled || e.loading,
237
- onClick: p
238
- }, [
239
- e.loading ? (r(), b("span", Ge, i[0] || (i[0] = [
240
- c("svg", {
241
- viewBox: "0 0 16 16",
242
- fill: "none",
243
- xmlns: "http://www.w3.org/2000/svg"
244
- }, [
245
- c("circle", {
246
- cx: "8",
247
- cy: "8",
248
- r: "6",
249
- stroke: "currentColor",
250
- "stroke-width": "1.6",
251
- "stroke-opacity": "0.25"
252
- }),
253
- c("path", {
254
- d: "M14 8a6 6 0 0 0-6-6",
255
- stroke: "currentColor",
256
- "stroke-width": "1.6",
257
- "stroke-linecap": "round"
258
- })
259
- ], -1)
260
- ]))) : e.icon ? (r(), b("span", Fe, [
261
- (r(), _(ve(e.icon)))
262
- ])) : w("", !0),
263
- e.$slots.default ? (r(), b("span", Pe, [
264
- P(e.$slots, "default", {}, void 0, !0)
265
- ])) : w("", !0)
266
- ], 10, Ae));
267
- }
268
- }), O = /* @__PURE__ */ K(Re, [["__scopeId", "data-v-25d59287"]]), Le = { class: "g-dialog-pro-header" }, Ve = { class: "g-dialog-pro-title" }, He = {
269
- class: "g-dialog-pro-operation-container",
270
- "aria-label": "弹窗操作"
271
- }, Ne = ["aria-label", "title"], We = { class: "g-dialog-pro-body" }, je = {
272
- key: 0,
273
- class: "g-dialog-pro-footer"
274
- }, xe = { class: "g-dialog-pro-actions" }, te = "关闭", Ke = /* @__PURE__ */ x({
275
- name: "GDialogPro",
276
- inheritAttrs: !1,
277
- __name: "index",
278
- props: {
279
- title: { default: "" },
280
- size: { default: "medium" },
281
- modelValue: { type: Boolean },
282
- hideFooter: { type: Boolean, default: !1 },
283
- actions: {},
284
- showCancel: { type: Boolean, default: !0 },
285
- showReset: { type: Boolean, default: !0 },
286
- showSave: { type: Boolean, default: !0 },
287
- cancelText: { default: "取消" },
288
- resetText: { default: "重置" },
289
- saveText: { default: "保存" },
290
- saveLoading: { type: Boolean, default: !1 },
291
- saveDisabled: { type: Boolean, default: !1 },
292
- beforeClose: {}
293
- },
294
- emits: ["cancel", "reset", "save", "minimize", "action", "update:modelValue"],
295
- setup(l, { emit: m }) {
296
- const a = l, s = m, p = d(() => a.modelValue), e = J ? J() : `g-dialog-pro-${Date.now()}-${Math.random().toString(36).slice(2)}`, i = Me(), u = k(!1), g = k(!0), v = k(0), o = k(!1), n = k(!1), B = k(!1), z = d(() => i ? i.dialogs.get(e)?.isMinimized ?? !1 : u.value), E = d(() => i ? i.dialogs.get(e)?.attentionTick ?? 0 : v.value), S = d(() => i ? !n.value : g.value), A = d(() => i ? i.getPosition(e).value : { right: 20, bottom: 20 });
297
- ye(() => {
298
- i?.register({
299
- id: e,
300
- title: a.title,
301
- isMinimized: !1
302
- }), document.addEventListener("keydown", U);
303
- }), oe(() => {
304
- i?.unregister(e), document.removeEventListener("keydown", U);
305
- }), N(
306
- () => a.title,
307
- (t) => {
308
- if (i) {
309
- const C = i.dialogs.get(e);
310
- C && (C.title = t);
311
- }
312
- }
313
- ), N(
314
- () => a.modelValue,
315
- (t) => {
316
- if (t === !1) {
317
- if (o.value) return;
318
- i ? (i.restore(e), n.value = !1) : (g.value = !0, u.value = !1);
319
- }
320
- t === !0 && (i?.dialogs.get(e)?.isMinimized ? i.remindMinimized(e) : u.value && (v.value += 1));
321
- }
322
- );
323
- const y = d(() => Object.prototype.hasOwnProperty.call(ee, a.size) ? ee[a.size] : a.size), le = d(() => D.value ? {} : { width: y.value });
324
- async function $(t) {
325
- if (!a.beforeClose) return !0;
326
- try {
327
- return await a.beforeClose(t) !== !1;
328
- } catch {
329
- return !1;
330
- }
331
- }
332
- async function G() {
333
- await $("close") && s("update:modelValue", !1);
334
- }
335
- function se() {
336
- G();
337
- }
338
- function U(t) {
339
- t.key === "Escape" && (!a.modelValue || !S.value || z.value || (t.stopPropagation(), G()));
340
- }
341
- async function X() {
342
- await $("cancel") && s("cancel");
343
- }
344
- function Y() {
345
- s("reset");
346
- }
347
- async function Z() {
348
- await $("save") && s("save");
349
- }
350
- const V = ie({});
351
- async function re(t) {
352
- if (await $("action") && (s("action", t.key), !!t.onClick))
353
- try {
354
- const C = t.onClick();
355
- C instanceof Promise && (V[t.key] = !0, await C);
356
- } finally {
357
- V[t.key] = !1;
358
- }
359
- }
360
- const D = k(!1), ce = () => {
361
- D.value = !D.value;
362
- }, q = d(() => D.value ? "退出全屏" : "全屏"), de = async () => {
363
- if (!await $("minimize")) return;
364
- if (i ? i.dialogs.get(e)?.isMinimized ?? !1 : u.value) {
365
- i ? i.minimize(e) : v.value += 1, s("minimize", { id: e });
366
- return;
367
- }
368
- o.value = !0, i ? i.minimize(e) : u.value = !0, s("update:modelValue", !1), s("minimize", { id: e });
369
- }, ue = () => {
370
- B.value = !0, o.value = !1, i ? (n.value = !1, i.restore(e)) : (g.value = !0, u.value = !1), s("update:modelValue", !0);
371
- }, fe = () => {
372
- o.value && (i ? n.value = !0 : g.value = !1, o.value = !1);
373
- }, me = () => {
374
- B.value = !1;
375
- };
376
- return (t, C) => (r(), _(ne, { to: "body" }, [
377
- R(he, {
378
- name: "g-dialog-pro-fade",
379
- onAfterEnter: me,
380
- onAfterLeave: fe
381
- }, {
382
- default: T(() => [
383
- S.value && p.value ? (r(), b("div", {
384
- key: 0,
385
- class: "g-dialog-pro-overlay",
386
- onClick: ke(se, ["self"])
387
- }, [
388
- c("div", _e(t.$attrs, {
389
- class: ["g-dialog-pro", {
390
- "is-fullscreen": D.value,
391
- "is-leave-to-minimize": o.value,
392
- "is-enter-from-minimize": B.value
393
- }],
394
- style: le.value,
395
- role: "dialog",
396
- "aria-modal": "true"
397
- }), [
398
- c("header", Le, [
399
- c("p", Ve, M(t.title), 1),
400
- c("div", He, [
401
- c("button", {
402
- type: "button",
403
- class: "g-dialog-pro-control g-dialog-pro-control--minimize",
404
- "aria-label": "最小化",
405
- title: "最小化",
406
- onClick: de
407
- }),
408
- c("button", {
409
- type: "button",
410
- class: "g-dialog-pro-control g-dialog-pro-control--fullscreen",
411
- "aria-label": q.value,
412
- title: q.value,
413
- onClick: ce
414
- }, null, 8, Ne),
415
- c("button", {
416
- type: "button",
417
- class: "g-dialog-pro-control g-dialog-pro-control--close",
418
- "aria-label": te,
419
- title: te,
420
- onClick: G
421
- })
422
- ])
423
- ]),
424
- c("div", We, [
425
- P(t.$slots, "default", {}, void 0, !0)
426
- ]),
427
- t.hideFooter ? w("", !0) : (r(), b("footer", je, [
428
- P(t.$slots, "footer", {
429
- cancel: X,
430
- reset: Y,
431
- save: Z,
432
- close: G,
433
- loading: t.saveLoading
434
- }, () => [
435
- c("div", xe, [
436
- t.actions && t.actions.length ? (r(!0), b(Q, { key: 0 }, we(t.actions, (h) => (r(), _(O, {
437
- key: h.key,
438
- type: h.type,
439
- icon: h.icon,
440
- loading: h.loading || V[h.key],
441
- disabled: h.disabled,
442
- plain: h.plain,
443
- size: "small",
444
- onClick: (Ue) => re(h)
445
- }, {
446
- default: T(() => [
447
- F(M(h.label), 1)
448
- ]),
449
- _: 2
450
- }, 1032, ["type", "icon", "loading", "disabled", "plain", "onClick"]))), 128)) : (r(), b(Q, { key: 1 }, [
451
- t.showCancel ? (r(), _(O, {
452
- key: 0,
453
- icon: I(Ie),
454
- size: "small",
455
- onClick: X
456
- }, {
457
- default: T(() => [
458
- F(M(t.cancelText), 1)
459
- ]),
460
- _: 1
461
- }, 8, ["icon"])) : w("", !0),
462
- t.showReset ? (r(), _(O, {
463
- key: 1,
464
- icon: I(Oe),
465
- size: "small",
466
- onClick: Y
467
- }, {
468
- default: T(() => [
469
- F(M(t.resetText), 1)
470
- ]),
471
- _: 1
472
- }, 8, ["icon"])) : w("", !0),
473
- t.showSave ? (r(), _(O, {
474
- key: 2,
475
- type: "primary",
476
- icon: I(Be),
477
- loading: t.saveLoading,
478
- disabled: t.saveDisabled,
479
- size: "small",
480
- onClick: Z
481
- }, {
482
- default: T(() => [
483
- F(M(t.saveText), 1)
484
- ]),
485
- _: 1
486
- }, 8, ["icon", "loading", "disabled"])) : w("", !0)
487
- ], 64)),
488
- P(t.$slots, "moreOperations", {}, void 0, !0)
489
- ])
490
- ], !0)
491
- ]))
492
- ], 16)
493
- ])) : w("", !0)
494
- ]),
495
- _: 3
496
- }),
497
- R(I(be), null, {
498
- default: T(() => [
499
- z.value ? (r(), _(j, {
500
- key: 0,
501
- title: t.title,
502
- position: A.value,
503
- "attention-tick": E.value,
504
- onRestore: ue
505
- }, null, 8, ["title", "position", "attention-tick"])) : w("", !0)
506
- ]),
507
- _: 1
508
- })
509
- ]));
510
- }
511
- }), H = /* @__PURE__ */ K(Ke, [["__scopeId", "data-v-cac8c7e5"]]);
512
- H.install = (l) => {
513
- l.component(H.name, H), l.component(j.name, j), l.component(O.name, O);
514
- };
515
- export {
516
- Ee as ChatDotRound,
517
- Be as CircleCheck,
518
- Ce as DIALOG_MANAGER_KEY,
519
- ee as DIALOG_SIZES,
520
- O as GButton,
521
- j as GDialogMinimizedIcon,
522
- H as GDialogPro,
523
- W as MINIMIZED_LAYOUT,
524
- Oe as Refresh,
525
- Ie as Remove,
526
- Je as createDialogManager,
527
- H as default,
528
- Me as useDialogManager
529
- };
@@ -1,17 +0,0 @@
1
- import { DialogPosition } from './useDialogManager';
2
- interface Props {
3
- /** 弹窗标题 */
4
- title: string;
5
- /** 图标位置 */
6
- position: DialogPosition;
7
- /** 提醒动画触发次数 */
8
- attentionTick?: number;
9
- }
10
- declare const _default: import('vue').DefineComponent<Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
11
- restore: () => any;
12
- }, string, import('vue').PublicProps, Readonly<Props> & Readonly<{
13
- onRestore?: (() => any) | undefined;
14
- }>, {
15
- attentionTick: number;
16
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
17
- export default _default;
@@ -1,55 +0,0 @@
1
- import { Component, InjectionKey } from 'vue';
2
- import { DialogManager } from './useDialogManager';
3
- /**
4
- * 弹窗管理器注入键(GDialogPro 独立,不与 GDialog 共享)
5
- */
6
- export declare const DIALOG_MANAGER_KEY: InjectionKey<DialogManager>;
7
- /**
8
- * 预设对话框尺寸
9
- */
10
- export declare const DIALOG_SIZES: {
11
- readonly small: "380px";
12
- readonly medium: "480px";
13
- readonly large: "580px";
14
- };
15
- /**
16
- * 关闭来源(用于 beforeClose 钩子)
17
- * - cancel:底部取消按钮
18
- * - close:标题栏关闭按钮 / ESC / 蒙层
19
- * - minimize:标题栏最小化按钮
20
- * - save:底部保存按钮
21
- * - action:自定义底部操作(actions 配置项)
22
- */
23
- export type DialogCloseAction = 'cancel' | 'close' | 'minimize' | 'save' | 'action';
24
- /**
25
- * 自定义底部操作按钮
26
- */
27
- export interface FooterAction {
28
- /** 唯一标识,作为 emit('action', key) 的载荷 */
29
- key: string;
30
- /** 按钮文案 */
31
- label: string;
32
- /** 按钮类型(语义与常见 UI 库一致) */
33
- type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default' | 'text';
34
- /** 按钮图标组件 */
35
- icon?: Component;
36
- /** loading 态 */
37
- loading?: boolean;
38
- /** 禁用态 */
39
- disabled?: boolean;
40
- /** 是否朴素按钮 */
41
- plain?: boolean;
42
- /** 点击回调(与 emit('action', key) 同时触发,回调返回 Promise 时按钮自动 loading) */
43
- onClick?: () => void | Promise<void>;
44
- }
45
- /**
46
- * 最小化图标布局常量
47
- */
48
- export declare const MINIMIZED_LAYOUT: {
49
- readonly ICON_WIDTH: 92;
50
- readonly ICON_HEIGHT: 34;
51
- readonly GAP: 8;
52
- readonly BOTTOM_OFFSET: 18;
53
- readonly RIGHT_OFFSET: 18;
54
- readonly MAX_PER_ROW: 8;
55
- };