@xto/feedback 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/es/index.mjs +171 -167
  2. package/lib/index.cjs +1 -1
  3. package/package.json +2 -2
package/es/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { defineComponent as N, ref as E, computed as I, watch as ne, openBlock as x, createBlock as X, Teleport as le, createVNode as ie, Transition as j, withCtx as F, createElementBlock as $, normalizeStyle as H, normalizeClass as m, unref as v, createElementVNode as z, withModifiers as pe, renderSlot as L, createTextVNode as W, toDisplayString as V, createCommentVNode as M, nextTick as Q, onUnmounted as ae, withDirectives as he, vShow as ge, onMounted as xe, reactive as be, createApp as me, h as b } from "vue";
1
+ import { defineComponent as O, ref as E, computed as I, watch as ne, openBlock as v, createBlock as X, Teleport as le, createVNode as ie, Transition as j, withCtx as F, createElementBlock as $, normalizeStyle as N, normalizeClass as g, unref as x, createElementVNode as z, withModifiers as pe, renderSlot as L, createTextVNode as W, toDisplayString as V, createCommentVNode as M, withDirectives as me, vShow as he, nextTick as Q, onUnmounted as ae, onMounted as ve, reactive as be, createApp as ge, h as b } from "vue";
2
2
  import { useNamespace as U, useZIndex as we, useEscape as Ce, nextMessageZIndex as ke } from "@xto/core";
3
- const Ze = /* @__PURE__ */ N({
3
+ const Ze = /* @__PURE__ */ O({
4
4
  name: "XModal",
5
5
  __name: "index",
6
6
  props: {
@@ -19,16 +19,16 @@ const Ze = /* @__PURE__ */ N({
19
19
  setup(e, { emit: l }) {
20
20
  const t = e, a = l, o = U("modal"), { next: i } = we(), f = E(i()), d = I({
21
21
  get: () => t.modelValue,
22
- set: (g) => a("update:modelValue", g)
22
+ set: (p) => a("update:modelValue", p)
23
23
  }), u = E(), n = () => {
24
24
  d.value = !1, a("close");
25
- }, p = () => {
25
+ }, m = () => {
26
26
  t.closeOnClickModal && t.modal && n();
27
27
  };
28
28
  Ce(() => {
29
29
  t.closeOnPressEscape && d.value && n();
30
- }), ne(() => t.modelValue, (g) => {
31
- g && (f.value = i(), a("open"));
30
+ }), ne(() => t.modelValue, (p) => {
31
+ p && (f.value = i(), a("open"));
32
32
  });
33
33
  const r = I(() => ({
34
34
  paddingTop: t.top
@@ -36,49 +36,49 @@ const Ze = /* @__PURE__ */ N({
36
36
  width: typeof t.width == "number" ? `${t.width}px` : t.width,
37
37
  zIndex: f.value
38
38
  }));
39
- return (g, B) => (x(), X(le, { to: "body" }, [
39
+ return (p, B) => (v(), X(le, { to: "body" }, [
40
40
  ie(j, { name: "x-modal-fade" }, {
41
41
  default: F(() => [
42
- e.modelValue ? (x(), $("div", {
42
+ e.modelValue ? (v(), $("div", {
43
43
  key: 0,
44
- class: m(v(o).e("wrapper")),
45
- style: H(r.value),
46
- onClick: p
44
+ class: g(x(o).e("wrapper")),
45
+ style: N(r.value),
46
+ onClick: m
47
47
  }, [
48
48
  z("div", {
49
49
  ref_key: "modalRef",
50
50
  ref: u,
51
- class: m(v(o).b()),
52
- style: H(h.value),
51
+ class: g(x(o).b()),
52
+ style: N(h.value),
53
53
  onClick: B[0] || (B[0] = pe(() => {
54
54
  }, ["stop"]))
55
55
  }, [
56
56
  z("div", {
57
- class: m(v(o).e("header"))
57
+ class: g(x(o).e("header"))
58
58
  }, [
59
59
  z("span", {
60
- class: m(v(o).e("title"))
60
+ class: g(x(o).e("title"))
61
61
  }, [
62
- L(g.$slots, "title", {}, () => [
62
+ L(p.$slots, "title", {}, () => [
63
63
  W(V(e.title), 1)
64
64
  ])
65
65
  ], 2),
66
- e.showClose ? (x(), $("button", {
66
+ e.showClose ? (v(), $("button", {
67
67
  key: 0,
68
- class: m(v(o).e("close")),
68
+ class: g(x(o).e("close")),
69
69
  onClick: n
70
70
  }, " ✕ ", 2)) : M("", !0)
71
71
  ], 2),
72
72
  z("div", {
73
- class: m(v(o).e("body"))
73
+ class: g(x(o).e("body"))
74
74
  }, [
75
- L(g.$slots, "default")
75
+ L(p.$slots, "default")
76
76
  ], 2),
77
- g.$slots.footer ? (x(), $("div", {
77
+ p.$slots.footer ? (v(), $("div", {
78
78
  key: 0,
79
- class: m(v(o).e("footer"))
79
+ class: g(x(o).e("footer"))
80
80
  }, [
81
- L(g.$slots, "footer")
81
+ L(p.$slots, "footer")
82
82
  ], 2)) : M("", !0)
83
83
  ], 6)
84
84
  ], 6)) : M("", !0)
@@ -87,13 +87,16 @@ const Ze = /* @__PURE__ */ N({
87
87
  })
88
88
  ]));
89
89
  }
90
- }), Ke = /* @__PURE__ */ N({
90
+ }), Ke = /* @__PURE__ */ O({
91
91
  name: "XDrawer",
92
+ inheritAttrs: !1,
92
93
  __name: "index",
93
94
  props: {
94
95
  modelValue: { type: Boolean, default: !1 },
95
96
  title: { default: "" },
97
+ placement: { default: void 0 },
96
98
  direction: { default: "rtl" },
99
+ width: { default: void 0 },
97
100
  size: { default: "30%" },
98
101
  withHeader: { type: Boolean, default: !0 },
99
102
  showClose: { type: Boolean, default: !0 },
@@ -114,66 +117,67 @@ const Ze = /* @__PURE__ */ N({
114
117
  });
115
118
  const n = I(() => ({
116
119
  zIndex: i.value
117
- })), p = I(() => {
118
- const r = typeof t.size == "number" ? `${t.size}px` : t.size;
120
+ })), m = I(() => {
121
+ const r = t.direction ?? t.placement ?? "rtl", h = t.size ?? t.width ?? "30%", p = typeof h == "number" ? `${h}px` : h;
119
122
  return {
120
- ltr: { width: r, height: "100%" },
121
- rtl: { width: r, height: "100%" },
122
- ttb: { width: "100%", height: r },
123
- btt: { width: "100%", height: r }
124
- }[t.direction];
123
+ ltr: { width: p, height: "100%" },
124
+ rtl: { width: p, height: "100%" },
125
+ ttb: { width: "100%", height: p },
126
+ btt: { width: "100%", height: p }
127
+ }[r];
125
128
  });
126
- return (r, h) => (x(), X(le, { to: "body" }, [
129
+ return (r, h) => (v(), X(le, { to: "body" }, [
127
130
  ie(j, { name: "x-drawer-fade" }, {
128
131
  default: F(() => [
129
- e.modelValue ? (x(), $("div", {
130
- key: 0,
131
- class: m(v(o).e("overlay")),
132
- style: H(n.value),
132
+ me(z("div", {
133
+ class: g(x(o).e("overlay")),
134
+ style: N(n.value),
133
135
  onClick: d
134
136
  }, [
135
137
  z("div", {
136
- class: m([v(o).b(), v(o).m(e.direction)]),
137
- style: H(p.value),
138
+ class: g([x(o).b(), x(o).m(e.direction ?? e.placement)]),
139
+ style: N(m.value),
138
140
  onClick: h[0] || (h[0] = pe(() => {
139
141
  }, ["stop"]))
140
142
  }, [
141
- e.withHeader ? (x(), $("div", {
143
+ e.withHeader ? (v(), $("div", {
142
144
  key: 0,
143
- class: m(v(o).e("header"))
145
+ class: g(x(o).e("header"))
144
146
  }, [
145
147
  z("span", {
146
- class: m(v(o).e("title"))
148
+ class: g(x(o).e("title"))
147
149
  }, [
148
150
  L(r.$slots, "title", {}, () => [
149
151
  W(V(e.title), 1)
150
152
  ])
151
153
  ], 2),
152
- e.showClose ? (x(), $("button", {
154
+ e.showClose ? (v(), $("button", {
153
155
  key: 0,
154
- class: m(v(o).e("close")),
156
+ class: g(x(o).e("close")),
155
157
  onClick: f
156
158
  }, " ✕ ", 2)) : M("", !0)
157
159
  ], 2)) : M("", !0),
158
160
  z("div", {
159
- class: m(v(o).e("body"))
161
+ class: g(x(o).e("body"))
160
162
  }, [
161
163
  L(r.$slots, "default")
162
164
  ], 2),
163
- r.$slots.footer ? (x(), $("div", {
165
+ r.$slots.footer ? (v(), $("div", {
164
166
  key: 1,
165
- class: m(v(o).e("footer"))
167
+ class: g(x(o).e("footer"))
166
168
  }, [
167
169
  L(r.$slots, "footer")
168
170
  ], 2)) : M("", !0)
169
171
  ], 6)
170
- ], 6)) : M("", !0)
172
+ ], 6), [
173
+ [he, e.modelValue]
174
+ ])
171
175
  ]),
172
176
  _: 3
173
177
  })
174
178
  ]));
175
179
  }
176
- }), Ue = /* @__PURE__ */ N({
180
+ }), Ue = /* @__PURE__ */ O({
177
181
  name: "XAlert",
178
182
  __name: "index",
179
183
  props: {
@@ -199,39 +203,39 @@ const Ze = /* @__PURE__ */ N({
199
203
  ]), u = (n) => {
200
204
  i.value = !1, a("close", n);
201
205
  };
202
- return (n, p) => (x(), X(j, { name: "x-alert-fade" }, {
206
+ return (n, m) => (v(), X(j, { name: "x-alert-fade" }, {
203
207
  default: F(() => [
204
- i.value ? (x(), $("div", {
208
+ i.value ? (v(), $("div", {
205
209
  key: 0,
206
- class: m(d.value)
210
+ class: g(d.value)
207
211
  }, [
208
- e.showIcon ? (x(), $("span", {
212
+ e.showIcon ? (v(), $("span", {
209
213
  key: 0,
210
- class: m(v(o).e("icon"))
214
+ class: g(x(o).e("icon"))
211
215
  }, V(f[e.type]), 3)) : M("", !0),
212
216
  z("div", {
213
- class: m(v(o).e("content"))
217
+ class: g(x(o).e("content"))
214
218
  }, [
215
- e.title || n.$slots.title ? (x(), $("span", {
219
+ e.title || n.$slots.title ? (v(), $("span", {
216
220
  key: 0,
217
- class: m(v(o).e("title"))
221
+ class: g(x(o).e("title"))
218
222
  }, [
219
223
  L(n.$slots, "title", {}, () => [
220
224
  W(V(e.title), 1)
221
225
  ])
222
226
  ], 2)) : M("", !0),
223
- e.description || n.$slots.default ? (x(), $("span", {
227
+ e.description || n.$slots.default ? (v(), $("span", {
224
228
  key: 1,
225
- class: m(v(o).e("description"))
229
+ class: g(x(o).e("description"))
226
230
  }, [
227
231
  L(n.$slots, "default", {}, () => [
228
232
  W(V(e.description), 1)
229
233
  ])
230
234
  ], 2)) : M("", !0)
231
235
  ], 2),
232
- e.closable ? (x(), $("button", {
236
+ e.closable ? (v(), $("button", {
233
237
  key: 1,
234
- class: m(v(o).e("close")),
238
+ class: g(x(o).e("close")),
235
239
  onClick: u
236
240
  }, " ✕ ", 2)) : M("", !0)
237
241
  ], 2)) : M("", !0)
@@ -239,7 +243,7 @@ const Ze = /* @__PURE__ */ N({
239
243
  _: 3
240
244
  }));
241
245
  }
242
- }), Ye = /* @__PURE__ */ N({
246
+ }), Ye = /* @__PURE__ */ O({
243
247
  name: "XTooltip",
244
248
  __name: "index",
245
249
  props: {
@@ -258,34 +262,34 @@ const Ze = /* @__PURE__ */ N({
258
262
  setup(e, { emit: l }) {
259
263
  const t = e, a = l, o = U("tooltip"), i = E(!1), f = E(), d = E();
260
264
  let u, n;
261
- const p = E({}), r = () => {
265
+ const m = E({}), r = () => {
262
266
  if (!f.value || !d.value) return;
263
- const k = f.value.getBoundingClientRect(), O = d.value;
264
- O.style.visibility = "hidden", O.style.display = "block";
265
- const _ = O.offsetWidth, D = O.offsetHeight, A = t.offset, ce = window.innerWidth, de = window.innerHeight;
267
+ const k = f.value.getBoundingClientRect(), _ = d.value;
268
+ _.style.visibility = "hidden", _.style.display = "block";
269
+ const H = _.offsetWidth, D = _.offsetHeight, A = t.offset, ce = window.innerWidth, de = window.innerHeight;
266
270
  let P = 0, R = 0, Y = t.placement;
267
271
  switch (t.placement) {
268
272
  case "top":
269
- P = k.top - D - A, R = k.left + (k.width - _) / 2;
273
+ P = k.top - D - A, R = k.left + (k.width - H) / 2;
270
274
  break;
271
275
  case "bottom":
272
- P = k.bottom + A, R = k.left + (k.width - _) / 2;
276
+ P = k.bottom + A, R = k.left + (k.width - H) / 2;
273
277
  break;
274
278
  case "left":
275
- P = k.top + (k.height - D) / 2, R = k.left - _ - A;
279
+ P = k.top + (k.height - D) / 2, R = k.left - H - A;
276
280
  break;
277
281
  case "right":
278
282
  P = k.top + (k.height - D) / 2, R = k.right + A;
279
283
  break;
280
284
  }
281
- t.placement === "top" && P < 0 ? (Y = "bottom", P = k.bottom + A) : t.placement === "bottom" && P + D > de ? (Y = "top", P = k.top - D - A) : t.placement === "left" && R < 0 ? (Y = "right", R = k.right + A) : t.placement === "right" && R + _ > ce && (Y = "left", R = k.left - _ - A), R < 8 && (R = 8), R + _ > ce - 8 && (R = ce - _ - 8), P < 8 && (P = 8), P + D > de - 8 && (P = de - D - 8), p.value = {
285
+ t.placement === "top" && P < 0 ? (Y = "bottom", P = k.bottom + A) : t.placement === "bottom" && P + D > de ? (Y = "top", P = k.top - D - A) : t.placement === "left" && R < 0 ? (Y = "right", R = k.right + A) : t.placement === "right" && R + H > ce && (Y = "left", R = k.left - H - A), R < 8 && (R = 8), R + H > ce - 8 && (R = ce - H - 8), P < 8 && (P = 8), P + D > de - 8 && (P = de - D - 8), m.value = {
282
286
  position: "fixed",
283
287
  top: `${P}px`,
284
288
  left: `${R}px`,
285
289
  visibility: "visible",
286
290
  zIndex: "2000"
287
291
  }, h.value = Y;
288
- }, h = E(t.placement), g = () => {
292
+ }, h = E(t.placement), p = () => {
289
293
  t.disabled || (clearTimeout(n), u = setTimeout(() => {
290
294
  i.value = !0, a("update:visible", !0), a("show"), Q(() => {
291
295
  r();
@@ -296,20 +300,20 @@ const Ze = /* @__PURE__ */ N({
296
300
  i.value = !1, a("update:visible", !1), a("hide");
297
301
  }, t.closeDelay);
298
302
  }, w = () => {
299
- i.value ? B() : g();
303
+ i.value ? B() : p();
300
304
  }, C = () => {
301
- t.trigger === "hover" && g();
305
+ t.trigger === "hover" && p();
302
306
  }, s = () => {
303
307
  t.trigger === "hover" && B();
304
308
  }, c = () => {
305
309
  t.trigger === "click" && w();
306
310
  }, Z = () => {
307
- t.trigger === "focus" && g();
311
+ t.trigger === "focus" && p();
308
312
  }, S = () => {
309
313
  t.trigger === "focus" && B();
310
314
  }, T = (k) => {
311
- var O, _;
312
- t.trigger === "click" && !((O = f.value) != null && O.contains(k.target)) && !((_ = d.value) != null && _.contains(k.target)) && B();
315
+ var _, H;
316
+ t.trigger === "click" && !((_ = f.value) != null && _.contains(k.target)) && !((H = d.value) != null && H.contains(k.target)) && B();
313
317
  }, y = () => {
314
318
  i.value && r();
315
319
  };
@@ -327,13 +331,13 @@ const Ze = /* @__PURE__ */ N({
327
331
  o.e("arrow"),
328
332
  o.e(`arrow-${h.value}`)
329
333
  ]);
330
- return (k, O) => (x(), $("div", {
331
- class: m(v(o).e("wrapper"))
334
+ return (k, _) => (v(), $("div", {
335
+ class: g(x(o).e("wrapper"))
332
336
  }, [
333
337
  z("div", {
334
338
  ref_key: "triggerRef",
335
339
  ref: f,
336
- class: m(v(o).e("trigger")),
340
+ class: g(x(o).e("trigger")),
337
341
  onMouseenter: C,
338
342
  onMouseleave: s,
339
343
  onClick: c,
@@ -342,28 +346,28 @@ const Ze = /* @__PURE__ */ N({
342
346
  }, [
343
347
  L(k.$slots, "default")
344
348
  ], 34),
345
- (x(), X(le, { to: "body" }, [
349
+ (v(), X(le, { to: "body" }, [
346
350
  ie(j, {
347
351
  name: `x-tooltip-${e.transition}`
348
352
  }, {
349
353
  default: F(() => [
350
- he(z("div", {
354
+ me(z("div", {
351
355
  ref_key: "tooltipRef",
352
356
  ref: d,
353
- class: m(ee.value),
354
- style: H(p.value),
357
+ class: g(ee.value),
358
+ style: N(m.value),
355
359
  onMouseenter: C,
356
360
  onMouseleave: s
357
361
  }, [
358
362
  L(k.$slots, "content", {}, () => [
359
363
  W(V(e.content), 1)
360
364
  ]),
361
- e.visibleArrow ? (x(), $("div", {
365
+ e.visibleArrow ? (v(), $("div", {
362
366
  key: 0,
363
- class: m(te.value)
367
+ class: g(te.value)
364
368
  }, null, 2)) : M("", !0)
365
369
  ], 38), [
366
- [ge, i.value]
370
+ [he, i.value]
367
371
  ])
368
372
  ]),
369
373
  _: 3
@@ -371,7 +375,7 @@ const Ze = /* @__PURE__ */ N({
371
375
  ]))
372
376
  ], 2));
373
377
  }
374
- }), Be = { class: "x-popconfirm-wrapper" }, Te = { class: "x-popconfirm__main" }, $e = { class: "x-popconfirm__title" }, Ee = { class: "x-popconfirm__action" }, qe = /* @__PURE__ */ N({
378
+ }), Be = { class: "x-popconfirm-wrapper" }, Te = { class: "x-popconfirm__main" }, $e = { class: "x-popconfirm__title" }, Ee = { class: "x-popconfirm__action" }, qe = /* @__PURE__ */ O({
375
379
  name: "XPopconfirm",
376
380
  __name: "index",
377
381
  props: {
@@ -447,21 +451,21 @@ const Ze = /* @__PURE__ */ N({
447
451
  }, n = (s) => {
448
452
  var c, Z;
449
453
  o.value && ((c = i.value) != null && c.contains(s.target) || (Z = f.value) != null && Z.contains(s.target) || (o.value = !1));
450
- }, p = (s) => {
454
+ }, m = (s) => {
451
455
  t.disabled || (s.stopPropagation(), o.value = !o.value, o.value && setTimeout(u, 0));
452
456
  }, r = () => {
453
457
  o.value = !1, a("confirm");
454
458
  }, h = () => {
455
459
  o.value = !1, a("cancel");
456
- }, g = () => {
460
+ }, p = () => {
457
461
  o.value && u();
458
462
  }, B = () => {
459
463
  o.value && u();
460
464
  };
461
465
  ne(o, (s) => {
462
- s ? (setTimeout(u, 0), document.addEventListener("click", n), window.addEventListener("scroll", g, !0), window.addEventListener("resize", B)) : (document.removeEventListener("click", n), window.removeEventListener("scroll", g, !0), window.removeEventListener("resize", B));
466
+ s ? (setTimeout(u, 0), document.addEventListener("click", n), window.addEventListener("scroll", p, !0), window.addEventListener("resize", B)) : (document.removeEventListener("click", n), window.removeEventListener("scroll", p, !0), window.removeEventListener("resize", B));
463
467
  }), ae(() => {
464
- document.removeEventListener("click", n), window.removeEventListener("scroll", g, !0), window.removeEventListener("resize", B);
468
+ document.removeEventListener("click", n), window.removeEventListener("scroll", p, !0), window.removeEventListener("resize", B);
465
469
  });
466
470
  const w = I(() => ({
467
471
  width: typeof t.width == "number" ? `${t.width}px` : t.width
@@ -491,37 +495,37 @@ const Ze = /* @__PURE__ */ N({
491
495
  }
492
496
  return c;
493
497
  });
494
- return (s, c) => (x(), $("span", Be, [
498
+ return (s, c) => (v(), $("span", Be, [
495
499
  z("span", {
496
500
  ref_key: "triggerRef",
497
501
  ref: i,
498
502
  class: "x-popconfirm-trigger",
499
- onClick: p
503
+ onClick: m
500
504
  }, [
501
505
  L(s.$slots, "default")
502
506
  ], 512),
503
- (x(), X(le, { to: "body" }, [
507
+ (v(), X(le, { to: "body" }, [
504
508
  ie(j, { name: "x-popconfirm-fade" }, {
505
509
  default: F(() => [
506
- o.value ? (x(), $("div", {
510
+ o.value ? (v(), $("div", {
507
511
  key: 0,
508
512
  ref_key: "popperRef",
509
513
  ref: f,
510
514
  class: "x-popconfirm",
511
- style: H({ ...d.value, ...w.value }),
515
+ style: N({ ...d.value, ...w.value }),
512
516
  onClick: c[0] || (c[0] = pe(() => {
513
517
  }, ["stop"]))
514
518
  }, [
515
- e.showArrow ? (x(), $("span", {
519
+ e.showArrow ? (v(), $("span", {
516
520
  key: 0,
517
521
  class: "x-popconfirm__arrow",
518
- style: H(C.value)
522
+ style: N(C.value)
519
523
  }, null, 4)) : M("", !0),
520
524
  z("div", Te, [
521
- e.hideIcon ? M("", !0) : (x(), $("span", {
525
+ e.hideIcon ? M("", !0) : (v(), $("span", {
522
526
  key: 0,
523
527
  class: "x-popconfirm__icon",
524
- style: H({ color: e.iconColor })
528
+ style: N({ color: e.iconColor })
525
529
  }, [
526
530
  L(s.$slots, "icon", {}, () => [
527
531
  W(V(e.icon || "⚠"), 1)
@@ -534,14 +538,14 @@ const Ze = /* @__PURE__ */ N({
534
538
  ])
535
539
  ]),
536
540
  z("div", Ee, [
537
- e.hideCancelButton ? M("", !0) : (x(), $("button", {
541
+ e.hideCancelButton ? M("", !0) : (v(), $("button", {
538
542
  key: 0,
539
543
  class: "x-button p-button--default p-button--small",
540
544
  onClick: h
541
545
  }, V(e.cancelButtonText), 1)),
542
- e.hideConfirmButton ? M("", !0) : (x(), $("button", {
546
+ e.hideConfirmButton ? M("", !0) : (v(), $("button", {
543
547
  key: 1,
544
- class: m(["x-button x-button--small", `x-button--${e.confirmButtonType}`]),
548
+ class: g(["x-button x-button--small", `x-button--${e.confirmButtonType}`]),
545
549
  onClick: r
546
550
  }, V(e.confirmButtonText), 3))
547
551
  ])
@@ -552,7 +556,7 @@ const Ze = /* @__PURE__ */ N({
552
556
  ]))
553
557
  ]));
554
558
  }
555
- }), Ge = /* @__PURE__ */ N({
559
+ }), Ge = /* @__PURE__ */ O({
556
560
  name: "XBacktop",
557
561
  __name: "index",
558
562
  props: {
@@ -574,30 +578,30 @@ const Ze = /* @__PURE__ */ N({
574
578
  right: `${t.right}px`,
575
579
  bottom: `${t.bottom}px`
576
580
  }));
577
- return xe(() => {
581
+ return ve(() => {
578
582
  window.addEventListener("scroll", f, { passive: !0, capture: !0 }), setTimeout(f, 100);
579
583
  }), ae(() => {
580
584
  window.removeEventListener("scroll", f, !0);
581
- }), (n, p) => (x(), X(j, { name: "x-fade" }, {
585
+ }), (n, m) => (v(), X(j, { name: "x-fade" }, {
582
586
  default: F(() => [
583
- he(z("div", {
584
- class: m(v(o).b()),
585
- style: H(u.value),
587
+ me(z("div", {
588
+ class: g(x(o).b()),
589
+ style: N(u.value),
586
590
  onClick: d
587
591
  }, [
588
592
  L(n.$slots, "default", {}, () => [
589
593
  z("span", {
590
- class: m(v(o).e("icon"))
594
+ class: g(x(o).e("icon"))
591
595
  }, "↑", 2)
592
596
  ])
593
597
  ], 6), [
594
- [ge, i.value]
598
+ [he, i.value]
595
599
  ])
596
600
  ]),
597
601
  _: 3
598
602
  }));
599
603
  }
600
- }), Me = /* @__PURE__ */ N({
604
+ }), Me = /* @__PURE__ */ O({
601
605
  name: "XMessage",
602
606
  __name: "index",
603
607
  props: {
@@ -623,7 +627,7 @@ const Ze = /* @__PURE__ */ N({
623
627
  i.is("center", a.center),
624
628
  i.is("closable", a.showClose),
625
629
  a.customClass
626
- ]), p = I(() => ({
630
+ ]), m = I(() => ({
627
631
  top: `${a.offset}px`,
628
632
  zIndex: d.value
629
633
  }));
@@ -632,7 +636,7 @@ const Ze = /* @__PURE__ */ N({
632
636
  a.duration > 0 && (r = setTimeout(() => {
633
637
  B();
634
638
  }, a.duration));
635
- }, g = () => {
639
+ }, p = () => {
636
640
  r && (clearTimeout(r), r = null);
637
641
  }, B = () => {
638
642
  var C;
@@ -640,37 +644,37 @@ const Ze = /* @__PURE__ */ N({
640
644
  }, w = () => {
641
645
  o("destroy");
642
646
  };
643
- return xe(() => {
647
+ return ve(() => {
644
648
  h(), f.value = !0;
645
649
  }), ae(() => {
646
- g();
650
+ p();
647
651
  }), l({
648
652
  close: B
649
- }), (C, s) => (x(), X(j, {
653
+ }), (C, s) => (v(), X(j, {
650
654
  name: "x-message-fade",
651
655
  onAfterLeave: w
652
656
  }, {
653
657
  default: F(() => [
654
- f.value ? (x(), $("div", {
658
+ f.value ? (v(), $("div", {
655
659
  key: 0,
656
- class: m(n.value),
657
- style: H(p.value),
658
- onMouseenter: g,
660
+ class: g(n.value),
661
+ style: N(m.value),
662
+ onMouseenter: p,
659
663
  onMouseleave: h
660
664
  }, [
661
665
  z("span", {
662
- class: m(v(i).e("icon"))
666
+ class: g(x(i).e("icon"))
663
667
  }, V(u[e.type]), 3),
664
668
  z("span", {
665
- class: m(v(i).e("content"))
669
+ class: g(x(i).e("content"))
666
670
  }, [
667
671
  L(C.$slots, "default", {}, () => [
668
672
  W(V(e.message), 1)
669
673
  ])
670
674
  ], 2),
671
- e.showClose ? (x(), $("button", {
675
+ e.showClose ? (v(), $("button", {
672
676
  key: 0,
673
- class: m(v(i).e("close")),
677
+ class: g(x(i).e("close")),
674
678
  onClick: B
675
679
  }, " ✕ ", 2)) : M("", !0)
676
680
  ], 38)) : M("", !0)
@@ -683,7 +687,7 @@ let ze = 1;
683
687
  const Se = () => {
684
688
  q.slice().forEach((e) => e.close());
685
689
  };
686
- function ve(e) {
690
+ function xe(e) {
687
691
  const l = ze++, t = document.createElement("div");
688
692
  document.body.appendChild(t);
689
693
  const a = {
@@ -701,24 +705,24 @@ function ve(e) {
701
705
  C && C.offsetHeight && (d += C.offsetHeight + 16);
702
706
  }), f.offset = d;
703
707
  let u = null, n = !1;
704
- const p = () => {
708
+ const m = () => {
705
709
  n || (f.visible = !1, setTimeout(() => {
706
710
  if (n) return;
707
711
  n = !0;
708
712
  const w = q.findIndex((C) => C.id === l);
709
713
  w !== -1 && q.splice(w, 1);
710
714
  try {
711
- g.unmount();
715
+ p.unmount();
712
716
  } catch {
713
717
  }
714
718
  t.parentNode && t.parentNode.removeChild(t);
715
719
  }, 300));
716
720
  }, r = () => {
717
721
  const w = e.duration ?? 3e3;
718
- w > 0 && (u = setTimeout(p, w));
722
+ w > 0 && (u = setTimeout(m, w));
719
723
  }, h = () => {
720
724
  u && (clearTimeout(u), u = null);
721
- }, g = me({
725
+ }, p = ge({
722
726
  render() {
723
727
  if (!f.visible) return null;
724
728
  const w = [
@@ -760,7 +764,7 @@ function ve(e) {
760
764
  padding: "0"
761
765
  },
762
766
  onClick: (C) => {
763
- C.stopPropagation(), p();
767
+ C.stopPropagation(), m();
764
768
  }
765
769
  }, "✕")
766
770
  ), b("div", {
@@ -787,16 +791,16 @@ function ve(e) {
787
791
  }, w);
788
792
  }
789
793
  });
790
- g.mount(t), Q(() => {
794
+ p.mount(t), Q(() => {
791
795
  f.visible = !0, r();
792
796
  });
793
- const B = { id: l, app: g, container: t, close: p };
794
- return q.push(B), { close: p };
797
+ const B = { id: l, app: p, container: t, close: m };
798
+ return q.push(B), { close: m };
795
799
  }
796
800
  function Ie(e) {
797
- return ve(typeof e == "string" ? { message: e } : e);
801
+ return xe(typeof e == "string" ? { message: e } : e);
798
802
  }
799
- const oe = (e) => (l) => ve({ ...typeof l == "string" ? { message: l } : l, type: e }), ue = Object.assign(Ie, {
803
+ const oe = (e) => (l) => xe({ ...typeof l == "string" ? { message: l } : l, type: e }), ue = Object.assign(Ie, {
800
804
  info: oe("info"),
801
805
  success: oe("success"),
802
806
  warning: oe("warning"),
@@ -819,10 +823,10 @@ function re(e) {
819
823
  const t = document.createElement("div");
820
824
  document.body.appendChild(t);
821
825
  let a = !1;
822
- const o = N({
826
+ const o = O({
823
827
  name: "TMessageBox",
824
828
  setup() {
825
- const d = E(!1), u = E(e.inputValue ?? ""), n = E(""), p = 2e3 + G.length + 1, r = (C) => {
829
+ const d = E(!1), u = E(e.inputValue ?? ""), n = E(""), m = 2e3 + G.length + 1, r = (C) => {
826
830
  a || (a = !0, d.value = !1, setTimeout(() => {
827
831
  const s = G.findIndex((c) => c.container === t);
828
832
  s !== -1 && G.splice(s, 1);
@@ -841,7 +845,7 @@ function re(e) {
841
845
  return;
842
846
  }
843
847
  n.value = "", r("confirm");
844
- }, g = () => {
848
+ }, p = () => {
845
849
  r("cancel");
846
850
  }, B = () => {
847
851
  r("close");
@@ -854,9 +858,9 @@ function re(e) {
854
858
  visible: d,
855
859
  inputValue: u,
856
860
  inputError: n,
857
- zIndex: p,
861
+ zIndex: m,
858
862
  handleConfirm: h,
859
- handleCancel: g,
863
+ handleCancel: p,
860
864
  handleClose: B,
861
865
  handleMaskClick: w
862
866
  };
@@ -877,10 +881,10 @@ function re(e) {
877
881
  onClick: this.handleClose
878
882
  }, "✕")
879
883
  );
880
- const p = [];
881
- p.push(
884
+ const m = [];
885
+ m.push(
882
886
  b("div", { class: "x-message-box__content" }, e.message || "")
883
- ), e.showInput && p.push(
887
+ ), e.showInput && m.push(
884
888
  b("div", { class: "x-message-box__input", style: { marginTop: "12px" } }, [
885
889
  b("input", {
886
890
  class: ["x-message-box__input-inner", this.inputError ? "is-error" : ""].filter(Boolean),
@@ -955,7 +959,7 @@ function re(e) {
955
959
  fontSize: "14px",
956
960
  color: "#606266"
957
961
  }
958
- }, p),
962
+ }, m),
959
963
  // Footer
960
964
  b("div", {
961
965
  class: "x-message-box__footer",
@@ -967,7 +971,7 @@ function re(e) {
967
971
  ])
968
972
  ]);
969
973
  }
970
- }), i = me(o);
974
+ }), i = ge(o);
971
975
  i.mount(t);
972
976
  const f = {
973
977
  app: i,
@@ -999,7 +1003,7 @@ async function Ve(e, l, t) {
999
1003
  showCancelButton: !0
1000
1004
  });
1001
1005
  }
1002
- async function _e(e, l, t) {
1006
+ async function He(e, l, t) {
1003
1007
  return re({
1004
1008
  message: e,
1005
1009
  title: l,
@@ -1009,21 +1013,21 @@ async function _e(e, l, t) {
1009
1013
  showCancelButton: !0
1010
1014
  });
1011
1015
  }
1012
- function He(e) {
1016
+ function Ne(e) {
1013
1017
  return re(e);
1014
1018
  }
1015
- const K = Object.assign(He, {
1019
+ const K = Object.assign(Ne, {
1016
1020
  alert: Re,
1017
1021
  confirm: Ve,
1018
- prompt: _e,
1022
+ prompt: He,
1019
1023
  closeAll: Le
1020
1024
  }), tt = K, ot = {
1021
1025
  install(e) {
1022
1026
  e.config.globalProperties.$msgbox = K, e.config.globalProperties.$alert = K.alert, e.config.globalProperties.$confirm = K.confirm, e.config.globalProperties.$prompt = K.prompt, e.provide("messageBox", K);
1023
1027
  }
1024
1028
  }, J = [];
1025
- let Ne = 1;
1026
- const Oe = () => {
1029
+ let Oe = 1;
1030
+ const _e = () => {
1027
1031
  J.slice().forEach((e) => e.close());
1028
1032
  }, Ae = {
1029
1033
  success: { icon: "✓", color: "#67c23a" },
@@ -1064,13 +1068,13 @@ const Oe = () => {
1064
1068
  return t;
1065
1069
  };
1066
1070
  function ye(e) {
1067
- const l = Ne++, t = e.position || "top-right", a = document.createElement("div");
1071
+ const l = Oe++, t = e.position || "top-right", a = document.createElement("div");
1068
1072
  document.body.appendChild(a);
1069
1073
  let o = null, i = !1;
1070
- const f = N({
1074
+ const f = O({
1071
1075
  name: "TNotification",
1072
1076
  setup() {
1073
- const n = E(!1), p = () => {
1077
+ const n = E(!1), m = () => {
1074
1078
  i || (i = !0, n.value = !1, setTimeout(() => {
1075
1079
  var C;
1076
1080
  const w = J.findIndex((s) => s.id === l);
@@ -1083,15 +1087,15 @@ function ye(e) {
1083
1087
  }, 300));
1084
1088
  }, r = () => {
1085
1089
  const w = e.duration ?? 4500;
1086
- w > 0 && (o = setTimeout(p, w));
1090
+ w > 0 && (o = setTimeout(m, w));
1087
1091
  }, h = () => {
1088
1092
  o && (clearTimeout(o), o = null);
1089
- }, g = I(() => (e.offset ?? 0) + We(t, l)), B = I(() => De(t, g.value));
1093
+ }, p = I(() => (e.offset ?? 0) + We(t, l)), B = I(() => De(t, p.value));
1090
1094
  return Q(() => {
1091
1095
  n.value = !0, r();
1092
1096
  }), {
1093
1097
  visible: n,
1094
- close: p,
1098
+ close: m,
1095
1099
  positionStyles: B,
1096
1100
  startTimer: r,
1097
1101
  clearTimer: h
@@ -1099,7 +1103,7 @@ function ye(e) {
1099
1103
  },
1100
1104
  render() {
1101
1105
  if (!this.visible) return null;
1102
- const n = e.type, p = n ? Ae[n] : null, r = [];
1106
+ const n = e.type, m = n ? Ae[n] : null, r = [];
1103
1107
  e.title && r.push(
1104
1108
  b("div", {
1105
1109
  class: "x-notification__title",
@@ -1131,7 +1135,7 @@ function ye(e) {
1131
1135
  }, e.message)
1132
1136
  ));
1133
1137
  const h = [];
1134
- return p && h.push(
1138
+ return m && h.push(
1135
1139
  b("div", {
1136
1140
  class: "x-notification__icon",
1137
1141
  style: {
@@ -1142,9 +1146,9 @@ function ye(e) {
1142
1146
  height: "24px",
1143
1147
  marginRight: "12px",
1144
1148
  fontSize: "18px",
1145
- color: p.color
1149
+ color: m.color
1146
1150
  }
1147
- }, p.icon)
1151
+ }, m.icon)
1148
1152
  ), h.push(
1149
1153
  b("div", {
1150
1154
  class: "x-notification__main",
@@ -1166,8 +1170,8 @@ function ye(e) {
1166
1170
  color: "#909399",
1167
1171
  padding: "0"
1168
1172
  },
1169
- onClick: (g) => {
1170
- g.stopPropagation(), this.close();
1173
+ onClick: (p) => {
1174
+ p.stopPropagation(), this.close();
1171
1175
  }
1172
1176
  }, "✕")
1173
1177
  ), b("div", {
@@ -1187,7 +1191,7 @@ function ye(e) {
1187
1191
  onMouseleave: this.startTimer
1188
1192
  }, h);
1189
1193
  }
1190
- }), d = me(f);
1194
+ }), d = ge(f);
1191
1195
  d.mount(a);
1192
1196
  const u = {
1193
1197
  id: l,
@@ -1195,8 +1199,8 @@ function ye(e) {
1195
1199
  container: a,
1196
1200
  position: t,
1197
1201
  close: () => {
1198
- var p;
1199
- const n = (p = d._instance) == null ? void 0 : p.proxy;
1202
+ var m;
1203
+ const n = (m = d._instance) == null ? void 0 : m.proxy;
1200
1204
  n != null && n.close && n.close();
1201
1205
  }
1202
1206
  };
@@ -1210,7 +1214,7 @@ const se = (e) => (l) => ye({ ...typeof l == "string" ? { message: l } : l, type
1210
1214
  success: se("success"),
1211
1215
  warning: se("warning"),
1212
1216
  error: se("error"),
1213
- closeAll: Oe
1217
+ closeAll: _e
1214
1218
  }), st = fe, nt = {
1215
1219
  install(e) {
1216
1220
  e.config.globalProperties.$notify = fe, e.provide("notification", fe);
package/lib/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),z=require("@xto/core"),q=e.defineComponent({name:"XModal",__name:"index",props:{modelValue:{type:Boolean,default:!1},title:{default:""},width:{default:"50%"},top:{default:"15vh"},modal:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},showClose:{type:Boolean,default:!0},center:{type:Boolean,default:!1},destroyOnClose:{type:Boolean,default:!1}},emits:["update:modelValue","close","open"],setup(t,{emit:a}){const o=t,r=a,n=z.useNamespace("modal"),{next:i}=z.useZIndex(),m=e.ref(i()),u=e.computed({get:()=>o.modelValue,set:g=>r("update:modelValue",g)}),f=e.ref(),l=()=>{u.value=!1,r("close")},p=()=>{o.closeOnClickModal&&o.modal&&l()};z.useEscape(()=>{o.closeOnPressEscape&&u.value&&l()}),e.watch(()=>o.modelValue,g=>{g&&(m.value=i(),r("open"))});const c=e.computed(()=>({paddingTop:o.top})),h=e.computed(()=>({width:typeof o.width=="number"?`${o.width}px`:o.width,zIndex:m.value}));return(g,C)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"x-modal-fade"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(n).e("wrapper")),style:e.normalizeStyle(c.value),onClick:p},[e.createElementVNode("div",{ref_key:"modalRef",ref:f,class:e.normalizeClass(e.unref(n).b()),style:e.normalizeStyle(h.value),onClick:C[0]||(C[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("header"))},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n).e("title"))},[e.renderSlot(g.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])],2),t.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(e.unref(n).e("close")),onClick:l}," ✕ ",2)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("body"))},[e.renderSlot(g.$slots,"default")],2),g.$slots.footer?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(n).e("footer"))},[e.renderSlot(g.$slots,"footer")],2)):e.createCommentVNode("",!0)],6)],6)):e.createCommentVNode("",!0)]),_:3})]))}}),K=e.defineComponent({name:"XDrawer",__name:"index",props:{modelValue:{type:Boolean,default:!1},title:{default:""},direction:{default:"rtl"},size:{default:"30%"},withHeader:{type:Boolean,default:!0},showClose:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},destroyOnClose:{type:Boolean,default:!1}},emits:["update:modelValue","close","open"],setup(t,{emit:a}){const o=t,r=a,n=z.useNamespace("drawer"),i=e.ref(2e3),m=()=>{r("update:modelValue",!1),r("close")},u=()=>{o.closeOnClickModal&&m()},f=c=>{c.key==="Escape"&&o.modelValue&&m()};e.watch(()=>o.modelValue,c=>{c?(i.value=2e3+Math.floor(Math.random()*100),r("open"),document.addEventListener("keydown",f)):document.removeEventListener("keydown",f)});const l=e.computed(()=>({zIndex:i.value})),p=e.computed(()=>{const c=typeof o.size=="number"?`${o.size}px`:o.size;return{ltr:{width:c,height:"100%"},rtl:{width:c,height:"100%"},ttb:{width:"100%",height:c},btt:{width:"100%",height:c}}[o.direction]});return(c,h)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"x-drawer-fade"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(n).e("overlay")),style:e.normalizeStyle(l.value),onClick:u},[e.createElementVNode("div",{class:e.normalizeClass([e.unref(n).b(),e.unref(n).m(t.direction)]),style:e.normalizeStyle(p.value),onClick:h[0]||(h[0]=e.withModifiers(()=>{},["stop"]))},[t.withHeader?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(n).e("header"))},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n).e("title"))},[e.renderSlot(c.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])],2),t.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(e.unref(n).e("close")),onClick:m}," ✕ ",2)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("body"))},[e.renderSlot(c.$slots,"default")],2),c.$slots.footer?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(e.unref(n).e("footer"))},[e.renderSlot(c.$slots,"footer")],2)):e.createCommentVNode("",!0)],6)],6)):e.createCommentVNode("",!0)]),_:3})]))}}),Y=e.defineComponent({name:"XAlert",__name:"index",props:{type:{default:"info"},title:{default:""},description:{},closable:{type:Boolean,default:!0},showIcon:{type:Boolean,default:!1},center:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:a}){const o=t,r=a,n=z.useNamespace("alert"),i=e.ref(!0),m={success:"✓",warning:"⚠",error:"✕",info:"ℹ"},u=e.computed(()=>[n.b(),n.m(o.type),n.is("center",o.center),n.is("with-description",o.description)]),f=l=>{i.value=!1,r("close",l)};return(l,p)=>(e.openBlock(),e.createBlock(e.Transition,{name:"x-alert-fade"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(u.value)},[t.showIcon?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(n).e("icon"))},e.toDisplayString(m[t.type]),3)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("content"))},[t.title||l.$slots.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(n).e("title"))},[e.renderSlot(l.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])],2)):e.createCommentVNode("",!0),t.description||l.$slots.default?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(e.unref(n).e("description"))},[e.renderSlot(l.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.description),1)])],2)):e.createCommentVNode("",!0)],2),t.closable?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(e.unref(n).e("close")),onClick:f}," ✕ ",2)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)]),_:3}))}}),G=e.defineComponent({name:"XTooltip",__name:"index",props:{content:{default:""},placement:{default:"top"},effect:{default:"dark"},disabled:{type:Boolean,default:!1},offset:{default:8},transition:{default:"fade"},visibleArrow:{type:Boolean,default:!0},trigger:{default:"hover"},openDelay:{default:0},closeDelay:{default:0}},emits:["update:visible","show","hide"],setup(t,{emit:a}){const o=t,r=a,n=z.useNamespace("tooltip"),i=e.ref(!1),m=e.ref(),u=e.ref();let f,l;const p=e.ref({}),c=()=>{if(!m.value||!u.value)return;const b=m.value.getBoundingClientRect(),S=u.value;S.style.visibility="hidden",S.style.display="block";const E=S.offsetWidth,V=S.offsetHeight,N=o.offset,W=window.innerWidth,j=window.innerHeight;let B=0,T=0,I=o.placement;switch(o.placement){case"top":B=b.top-V-N,T=b.left+(b.width-E)/2;break;case"bottom":B=b.bottom+N,T=b.left+(b.width-E)/2;break;case"left":B=b.top+(b.height-V)/2,T=b.left-E-N;break;case"right":B=b.top+(b.height-V)/2,T=b.right+N;break}o.placement==="top"&&B<0?(I="bottom",B=b.bottom+N):o.placement==="bottom"&&B+V>j?(I="top",B=b.top-V-N):o.placement==="left"&&T<0?(I="right",T=b.right+N):o.placement==="right"&&T+E>W&&(I="left",T=b.left-E-N),T<8&&(T=8),T+E>W-8&&(T=W-E-8),B<8&&(B=8),B+V>j-8&&(B=j-V-8),p.value={position:"fixed",top:`${B}px`,left:`${T}px`,visibility:"visible",zIndex:"2000"},h.value=I},h=e.ref(o.placement),g=()=>{o.disabled||(clearTimeout(l),f=setTimeout(()=>{i.value=!0,r("update:visible",!0),r("show"),e.nextTick(()=>{c()})},o.openDelay))},C=()=>{clearTimeout(f),l=setTimeout(()=>{i.value=!1,r("update:visible",!1),r("hide")},o.closeDelay)},y=()=>{i.value?C():g()},v=()=>{o.trigger==="hover"&&g()},s=()=>{o.trigger==="hover"&&C()},d=()=>{o.trigger==="click"&&y()},$=()=>{o.trigger==="focus"&&g()},w=()=>{o.trigger==="focus"&&C()},k=b=>{var S,E;o.trigger==="click"&&!((S=m.value)!=null&&S.contains(b.target))&&!((E=u.value)!=null&&E.contains(b.target))&&C()},x=()=>{i.value&&c()};e.watch(i,b=>{b?e.nextTick(()=>{c(),o.trigger==="click"&&document.addEventListener("click",k),window.addEventListener("scroll",x,!0),window.addEventListener("resize",x)}):(document.removeEventListener("click",k),window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x))}),e.onUnmounted(()=>{clearTimeout(f),clearTimeout(l),document.removeEventListener("click",k),window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)});const D=e.computed(()=>[n.b(),n.m(o.effect)]),_=e.computed(()=>[n.e("arrow"),n.e(`arrow-${h.value}`)]);return(b,S)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(n).e("wrapper"))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:e.normalizeClass(e.unref(n).e("trigger")),onMouseenter:v,onMouseleave:s,onClick:d,onFocus:$,onBlur:w},[e.renderSlot(b.$slots,"default")],34),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:`x-tooltip-${t.transition}`},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"tooltipRef",ref:u,class:e.normalizeClass(D.value),style:e.normalizeStyle(p.value),onMouseenter:v,onMouseleave:s},[e.renderSlot(b.$slots,"content",{},()=>[e.createTextVNode(e.toDisplayString(t.content),1)]),t.visibleArrow?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(_.value)},null,2)):e.createCommentVNode("",!0)],38),[[e.vShow,i.value]])]),_:3},8,["name"])]))],2))}}),J={class:"x-popconfirm-wrapper"},Q={class:"x-popconfirm__main"},ee={class:"x-popconfirm__title"},te={class:"x-popconfirm__action"},oe=e.defineComponent({name:"XPopconfirm",__name:"index",props:{title:{default:""},confirmButtonText:{default:"确定"},cancelButtonText:{default:"取消"},confirmButtonType:{default:"primary"},cancelButtonType:{default:"default"},icon:{default:""},iconColor:{default:"#faad14"},hideIcon:{type:Boolean,default:!1},hideCancelButton:{type:Boolean,default:!1},hideConfirmButton:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},width:{default:200},placement:{default:"top"},offset:{default:12},showArrow:{type:Boolean,default:!0}},emits:["confirm","cancel"],setup(t,{emit:a}){const o=t,r=a,n=e.ref(!1),i=e.ref(null),m=e.ref(null),u=e.ref({}),f=()=>{if(!i.value||!m.value)return;const s=i.value.getBoundingClientRect(),d=m.value.getBoundingClientRect(),$=o.placement,w=o.offset;let k=0,x=0;switch($){case"top":k=s.top-d.height-w,x=s.left+(s.width-d.width)/2;break;case"top-start":k=s.top-d.height-w,x=s.left;break;case"top-end":k=s.top-d.height-w,x=s.right-d.width;break;case"bottom":k=s.bottom+w,x=s.left+(s.width-d.width)/2;break;case"bottom-start":k=s.bottom+w,x=s.left;break;case"bottom-end":k=s.bottom+w,x=s.right-d.width;break;case"left":k=s.top+(s.height-d.height)/2,x=s.left-d.width-w;break;case"left-start":k=s.top,x=s.left-d.width-w;break;case"left-end":k=s.bottom-d.height,x=s.left-d.width-w;break;case"right":k=s.top+(s.height-d.height)/2,x=s.right+w;break;case"right-start":k=s.top,x=s.right+w;break;case"right-end":k=s.bottom-d.height,x=s.right+w;break;default:k=s.top-d.height-w,x=s.left+(s.width-d.width)/2}const D=window.innerWidth,_=window.innerHeight;x<0&&(x=10),x+d.width>D&&(x=D-d.width-10),k<0&&(k=10),k+d.height>_&&(k=_-d.height-10),u.value={position:"fixed",top:`${k}px`,left:`${x}px`,zIndex:"2000"}},l=s=>{var d,$;n.value&&((d=i.value)!=null&&d.contains(s.target)||($=m.value)!=null&&$.contains(s.target)||(n.value=!1))},p=s=>{o.disabled||(s.stopPropagation(),n.value=!n.value,n.value&&setTimeout(f,0))},c=()=>{n.value=!1,r("confirm")},h=()=>{n.value=!1,r("cancel")},g=()=>{n.value&&f()},C=()=>{n.value&&f()};e.watch(n,s=>{s?(setTimeout(f,0),document.addEventListener("click",l),window.addEventListener("scroll",g,!0),window.addEventListener("resize",C)):(document.removeEventListener("click",l),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",C))}),e.onUnmounted(()=>{document.removeEventListener("click",l),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",C)});const y=e.computed(()=>({width:typeof o.width=="number"?`${o.width}px`:o.width})),v=e.computed(()=>{const s=o.placement,d={};switch(s){case"top":case"top-start":case"top-end":d.bottom="-6px",d.transform="rotate(45deg)";break;case"bottom":case"bottom-start":case"bottom-end":d.top="-6px",d.transform="rotate(225deg)";break;case"left":case"left-start":case"left-end":d.right="-6px",d.transform="rotate(315deg)";break;case"right":case"right-start":case"right-end":d.left="-6px",d.transform="rotate(135deg)";break}return d});return(s,d)=>(e.openBlock(),e.createElementBlock("span",J,[e.createElementVNode("span",{ref_key:"triggerRef",ref:i,class:"x-popconfirm-trigger",onClick:p},[e.renderSlot(s.$slots,"default")],512),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"x-popconfirm-fade"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"popperRef",ref:m,class:"x-popconfirm",style:e.normalizeStyle({...u.value,...y.value}),onClick:d[0]||(d[0]=e.withModifiers(()=>{},["stop"]))},[t.showArrow?(e.openBlock(),e.createElementBlock("span",{key:0,class:"x-popconfirm__arrow",style:e.normalizeStyle(v.value)},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",Q,[t.hideIcon?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"x-popconfirm__icon",style:e.normalizeStyle({color:t.iconColor})},[e.renderSlot(s.$slots,"icon",{},()=>[e.createTextVNode(e.toDisplayString(t.icon||"⚠"),1)])],4)),e.createElementVNode("div",ee,[e.renderSlot(s.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])])]),e.createElementVNode("div",te,[t.hideCancelButton?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"x-button p-button--default p-button--small",onClick:h},e.toDisplayString(t.cancelButtonText),1)),t.hideConfirmButton?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["x-button x-button--small",`x-button--${t.confirmButtonType}`]),onClick:c},e.toDisplayString(t.confirmButtonText),3))])],4)):e.createCommentVNode("",!0)]),_:3})]))]))}}),ne=e.defineComponent({name:"XBacktop",__name:"index",props:{visibilityHeight:{default:200},right:{default:40},bottom:{default:40}},emits:["click"],setup(t,{emit:a}){const o=t,r=a,n=z.useNamespace("backtop"),i=e.ref(!1),m=()=>{const l=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0;i.value=l>=o.visibilityHeight},u=l=>{window.scrollTo({top:0,behavior:"smooth"}),r("click",l)},f=e.computed(()=>({right:`${o.right}px`,bottom:`${o.bottom}px`}));return e.onMounted(()=>{window.addEventListener("scroll",m,{passive:!0,capture:!0}),setTimeout(m,100)}),e.onUnmounted(()=>{window.removeEventListener("scroll",m,!0)}),(l,p)=>(e.openBlock(),e.createBlock(e.Transition,{name:"x-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).b()),style:e.normalizeStyle(f.value),onClick:u},[e.renderSlot(l.$slots,"default",{},()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n).e("icon"))},"↑",2)])],6),[[e.vShow,i.value]])]),_:3}))}}),se=e.defineComponent({name:"XMessage",__name:"index",props:{message:{default:""},type:{default:"info"},duration:{default:3e3},showClose:{type:Boolean,default:!1},center:{type:Boolean,default:!1},offset:{default:20},customClass:{},onClose:{}},emits:["close","destroy"],setup(t,{expose:a,emit:o}){const r=t,n=o,i=z.useNamespace("message"),m=e.ref(!1),u=e.ref(z.nextMessageZIndex()),f={success:"✓",warning:"⚠",error:"✕",info:"ℹ"},l=e.computed(()=>[i.b(),i.m(r.type),i.is("center",r.center),i.is("closable",r.showClose),r.customClass]),p=e.computed(()=>({top:`${r.offset}px`,zIndex:u.value}));let c=null;const h=()=>{r.duration>0&&(c=setTimeout(()=>{C()},r.duration))},g=()=>{c&&(clearTimeout(c),c=null)},C=()=>{var v;m.value=!1,(v=r.onClose)==null||v.call(r),n("close")},y=()=>{n("destroy")};return e.onMounted(()=>{h(),m.value=!0}),e.onUnmounted(()=>{g()}),a({close:C}),(v,s)=>(e.openBlock(),e.createBlock(e.Transition,{name:"x-message-fade",onAfterLeave:y},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(l.value),style:e.normalizeStyle(p.value),onMouseenter:g,onMouseleave:h},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(i).e("icon"))},e.toDisplayString(f[t.type]),3),e.createElementVNode("span",{class:e.normalizeClass(e.unref(i).e("content"))},[e.renderSlot(v.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.message),1)])],2),t.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(e.unref(i).e("close")),onClick:C}," ✕ ",2)):e.createCommentVNode("",!0)],38)):e.createCommentVNode("",!0)]),_:3}))}}),L=[];let le=1;const ae=()=>{L.slice().forEach(t=>t.close())};function U(t){const a=le++,o=document.createElement("div");document.body.appendChild(o);const r={success:{bg:"#f0f9eb",border:"#67c23a",icon:"✓"},warning:{bg:"#fdf6ec",border:"#e6a23c",icon:"⚠"},error:{bg:"#fef0f0",border:"#f56c6c",icon:"✕"},info:{bg:"#f4f4f5",border:"#909399",icon:"ℹ"}},n=t.type||"info",i=r[n]||r.info,m=e.reactive({visible:!1,offset:t.offset??20});let u=t.offset??20;L.forEach(y=>{const v=y.container.firstElementChild;v&&v.offsetHeight&&(u+=v.offsetHeight+16)}),m.offset=u;let f=null,l=!1;const p=()=>{l||(m.visible=!1,setTimeout(()=>{if(l)return;l=!0;const y=L.findIndex(v=>v.id===a);y!==-1&&L.splice(y,1);try{g.unmount()}catch{}o.parentNode&&o.parentNode.removeChild(o)},300))},c=()=>{const y=t.duration??3e3;y>0&&(f=setTimeout(p,y))},h=()=>{f&&(clearTimeout(f),f=null)},g=e.createApp({render(){if(!m.visible)return null;const y=[e.h("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",marginRight:"10px",fontSize:"16px",color:i.border}},i.icon),e.h("span",{style:{flex:"1",fontSize:"14px",color:"#606266",lineHeight:"1.4"}},t.message||"")];return t.showClose&&y.push(e.h("button",{style:{position:"absolute",top:"50%",right:"12px",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"14px",color:"#909399",padding:"0"},onClick:v=>{v.stopPropagation(),p()}},"✕")),e.h("div",{class:["x-message",`x-message--${n}`,t.center?"is-center":"",t.showClose?"is-closable":""],style:{position:"fixed",left:"50%",top:`${m.offset}px`,transform:"translateX(-50%)",display:"flex",alignItems:"center",padding:t.showClose?"12px 40px 12px 16px":"12px 16px",borderRadius:"4px",boxShadow:"0 2px 12px rgba(0,0,0,0.1)",minWidth:"280px",maxWidth:"480px",backgroundColor:i.bg,border:`1px solid ${i.border}`,zIndex:2e3+a,transition:"opacity 0.3s, transform 0.3s"},onMouseenter:h,onMouseleave:c},y)}});g.mount(o),e.nextTick(()=>{m.visible=!0,c()});const C={id:a,app:g,container:o,close:p};return L.push(C),{close:p}}function ie(t){return U(typeof t=="string"?{message:t}:t)}const H=t=>a=>U({...typeof a=="string"?{message:a}:a,type:t}),X=Object.assign(ie,{info:H("info"),success:H("success"),warning:H("warning"),error:H("error"),closeAll:ae}),re=X,ce=se,de={install(t){t.config.globalProperties.$message=X,t.provide("message",X)}},P=[],ue=()=>{P.slice().forEach(t=>t.close())},fe={success:{icon:"✓",color:"#67c23a"},warning:{icon:"⚠",color:"#e6a23c"},error:{icon:"✕",color:"#f56c6c"},info:{icon:"ℹ",color:"#909399"}};function A(t){return new Promise(a=>{const o=document.createElement("div");document.body.appendChild(o);let r=!1;const n=e.defineComponent({name:"TMessageBox",setup(){const u=e.ref(!1),f=e.ref(t.inputValue??""),l=e.ref(""),p=2e3+P.length+1,c=v=>{r||(r=!0,u.value=!1,setTimeout(()=>{const s=P.findIndex(d=>d.container===o);s!==-1&&P.splice(s,1);try{i.unmount()}catch{}o.parentNode&&o.parentNode.removeChild(o),a({action:v,value:v==="confirm"?f.value:void 0})},300))},h=()=>{if(t.showInput&&t.inputPattern&&!t.inputPattern.test(f.value)){l.value=t.inputErrorMessage||"输入格式不正确";return}l.value="",c("confirm")},g=()=>{c("cancel")},C=()=>{c("close")},y=()=>{t.closeOnClickModal!==!1&&C()};return e.nextTick(()=>{u.value=!0}),{visible:u,inputValue:f,inputError:l,zIndex:p,handleConfirm:h,handleCancel:g,handleClose:C,handleMaskClick:y}},render(){if(!this.visible)return null;const u=t.type,f=u?fe[u]:null,l=[];f&&l.push(e.h("span",{class:"x-message-box__icon",style:{color:f.color,marginRight:"10px",fontSize:"20px"}},f.icon)),l.push(e.h("span",{class:"x-message-box__title"},t.title||"提示")),t.showClose!==!1&&l.push(e.h("button",{class:"x-message-box__close",onClick:this.handleClose},"✕"));const p=[];p.push(e.h("div",{class:"x-message-box__content"},t.message||"")),t.showInput&&p.push(e.h("div",{class:"x-message-box__input",style:{marginTop:"12px"}},[e.h("input",{class:["x-message-box__input-inner",this.inputError?"is-error":""].filter(Boolean),type:t.inputType||"text",placeholder:t.inputPlaceholder||"请输入",value:this.inputValue,onInput:h=>{this.inputValue=h.target.value,this.inputError=""},onKeyup:h=>{h.key==="Enter"&&this.handleConfirm()}}),this.inputError?e.h("div",{class:"x-message-box__error",style:{color:"#f56c6c",fontSize:"12px",marginTop:"4px"}},this.inputError):null]));const c=[];return t.showCancelButton&&c.push(e.h("button",{class:"x-button p-button--default",onClick:this.handleCancel},t.cancelButtonText||"取消")),t.showConfirmButton!==!1&&c.push(e.h("button",{class:"x-button p-button--primary",onClick:this.handleConfirm,style:{marginLeft:"10px"}},t.confirmButtonText||"确定")),e.h("div",{class:["x-message-box-wrapper",t.center?"is-center":""],style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:this.zIndex},onClick:this.handleMaskClick},[e.h("div",{class:["x-message-box",t.customClass],style:{backgroundColor:"#fff",borderRadius:"4px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",minWidth:"300px",maxWidth:"500px"},onClick:h=>h.stopPropagation()},[e.h("div",{class:"x-message-box__header",style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid #eee"}},l),e.h("div",{class:"x-message-box__body",style:{padding:"20px",fontSize:"14px",color:"#606266"}},p),e.h("div",{class:"x-message-box__footer",style:{padding:"10px 20px 16px",textAlign:"right"}},c)])])}}),i=e.createApp(n);i.mount(o);const m={app:i,container:o,close:()=>{var f;const u=(f=i._instance)==null?void 0:f.proxy;u!=null&&u.handleClose&&u.handleClose()}};P.push(m)})}async function me(t,a,o){return A({message:t,title:a,...o,showConfirmButton:!0,showCancelButton:!1})}async function pe(t,a,o){return A({message:t,title:a,...o,showConfirmButton:!0,showCancelButton:!0})}async function he(t,a,o){return A({message:t,title:a,...o,showInput:!0,showConfirmButton:!0,showCancelButton:!0})}function ge(t){return A(t)}const M=Object.assign(ge,{alert:me,confirm:pe,prompt:he,closeAll:ue}),xe=M,ye={install(t){t.config.globalProperties.$msgbox=M,t.config.globalProperties.$alert=M.alert,t.config.globalProperties.$confirm=M.confirm,t.config.globalProperties.$prompt=M.prompt,t.provide("messageBox",M)}},R=[];let ve=1;const be=()=>{R.slice().forEach(t=>t.close())},Ce={success:{icon:"✓",color:"#67c23a"},warning:{icon:"⚠",color:"#e6a23c"},error:{icon:"✕",color:"#f56c6c"},info:{icon:"ℹ",color:"#909399"}},ke=(t,a)=>{const o=R.filter(n=>n.position===t);let r=16;for(const n of o)if(n.id<a){const i=n.container.firstElementChild;i&&(r+=i.offsetHeight+16)}return r},we=(t,a)=>{const o={position:"fixed",width:"330px",zIndex:"2010"};switch(t){case"top-right":o.top=`${a}px`,o.right="16px";break;case"top-left":o.top=`${a}px`,o.left="16px";break;case"bottom-right":o.bottom=`${a}px`,o.right="16px";break;case"bottom-left":o.bottom=`${a}px`,o.left="16px";break;default:o.top=`${a}px`,o.right="16px"}return o};function Z(t){const a=ve++,o=t.position||"top-right",r=document.createElement("div");document.body.appendChild(r);let n=null,i=!1;const m=e.defineComponent({name:"TNotification",setup(){const l=e.ref(!1),p=()=>{i||(i=!0,l.value=!1,setTimeout(()=>{var v;const y=R.findIndex(s=>s.id===a);y!==-1&&R.splice(y,1),n&&clearTimeout(n),(v=t.onClose)==null||v.call(t);try{u.unmount()}catch{}r.parentNode&&r.parentNode.removeChild(r)},300))},c=()=>{const y=t.duration??4500;y>0&&(n=setTimeout(p,y))},h=()=>{n&&(clearTimeout(n),n=null)},g=e.computed(()=>(t.offset??0)+ke(o,a)),C=e.computed(()=>we(o,g.value));return e.nextTick(()=>{l.value=!0,c()}),{visible:l,close:p,positionStyles:C,startTimer:c,clearTimer:h}},render(){if(!this.visible)return null;const l=t.type,p=l?Ce[l]:null,c=[];t.title&&c.push(e.h("div",{class:"x-notification__title",style:{fontWeight:"600",fontSize:"16px",color:"#303133",marginBottom:t.message?"6px":"0"}},t.title)),t.message&&(t.dangerouslyUseHTMLString?c.push(e.h("div",{class:"x-notification__content",style:{fontSize:"14px",color:"#606266",lineHeight:"1.5"},innerHTML:t.message})):c.push(e.h("div",{class:"x-notification__content",style:{fontSize:"14px",color:"#606266",lineHeight:"1.5"}},t.message)));const h=[];return p&&h.push(e.h("div",{class:"x-notification__icon",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",marginRight:"12px",fontSize:"18px",color:p.color}},p.icon)),h.push(e.h("div",{class:"x-notification__main",style:{flex:"1"}},c)),t.showClose!==!1&&h.push(e.h("button",{class:"x-notification__close",style:{position:"absolute",top:"18px",right:"15px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",color:"#909399",padding:"0"},onClick:g=>{g.stopPropagation(),this.close()}},"✕")),e.h("div",{class:["x-notification",t.customClass],style:{...this.positionStyles,display:"flex",alignItems:"flex-start",padding:"14px 26px 14px 13px",borderRadius:"8px",backgroundColor:"#fff",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",transition:"opacity 0.3s, transform 0.3s",boxSizing:"border-box"},onMouseenter:this.clearTimer,onMouseleave:this.startTimer},h)}}),u=e.createApp(m);u.mount(r);const f={id:a,app:u,container:r,position:o,close:()=>{var p;const l=(p=u._instance)==null?void 0:p.proxy;l!=null&&l.close&&l.close()}};return R.push(f),{close:f.close}}function Be(t){return Z(typeof t=="string"?{message:t}:t)}const O=t=>a=>Z({...typeof a=="string"?{message:a}:a,type:t}),F=Object.assign(Be,{info:O("info"),success:O("success"),warning:O("warning"),error:O("error"),closeAll:be}),Te=F,Ee={install(t){t.config.globalProperties.$notify=F,t.provide("notification",F)}};exports.Alert=Y;exports.Backtop=ne;exports.Drawer=K;exports.Message=re;exports.MessageBox=xe;exports.MessageComponent=ce;exports.Modal=q;exports.Notification=Te;exports.Popconfirm=oe;exports.TMessage=de;exports.TMessageBox=ye;exports.TNotification=Ee;exports.Tooltip=G;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),z=require("@xto/core"),q=e.defineComponent({name:"XModal",__name:"index",props:{modelValue:{type:Boolean,default:!1},title:{default:""},width:{default:"50%"},top:{default:"15vh"},modal:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},showClose:{type:Boolean,default:!0},center:{type:Boolean,default:!1},destroyOnClose:{type:Boolean,default:!1}},emits:["update:modelValue","close","open"],setup(t,{emit:i}){const o=t,r=i,n=z.useNamespace("modal"),{next:a}=z.useZIndex(),m=e.ref(a()),u=e.computed({get:()=>o.modelValue,set:p=>r("update:modelValue",p)}),f=e.ref(),l=()=>{u.value=!1,r("close")},h=()=>{o.closeOnClickModal&&o.modal&&l()};z.useEscape(()=>{o.closeOnPressEscape&&u.value&&l()}),e.watch(()=>o.modelValue,p=>{p&&(m.value=a(),r("open"))});const c=e.computed(()=>({paddingTop:o.top})),g=e.computed(()=>({width:typeof o.width=="number"?`${o.width}px`:o.width,zIndex:m.value}));return(p,C)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"x-modal-fade"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(n).e("wrapper")),style:e.normalizeStyle(c.value),onClick:h},[e.createElementVNode("div",{ref_key:"modalRef",ref:f,class:e.normalizeClass(e.unref(n).b()),style:e.normalizeStyle(g.value),onClick:C[0]||(C[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("header"))},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n).e("title"))},[e.renderSlot(p.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])],2),t.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(e.unref(n).e("close")),onClick:l}," ✕ ",2)):e.createCommentVNode("",!0)],2),e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("body"))},[e.renderSlot(p.$slots,"default")],2),p.$slots.footer?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(n).e("footer"))},[e.renderSlot(p.$slots,"footer")],2)):e.createCommentVNode("",!0)],6)],6)):e.createCommentVNode("",!0)]),_:3})]))}}),K=e.defineComponent({name:"XDrawer",inheritAttrs:!1,__name:"index",props:{modelValue:{type:Boolean,default:!1},title:{default:""},placement:{default:void 0},direction:{default:"rtl"},width:{default:void 0},size:{default:"30%"},withHeader:{type:Boolean,default:!0},showClose:{type:Boolean,default:!0},closeOnClickModal:{type:Boolean,default:!0},destroyOnClose:{type:Boolean,default:!1}},emits:["update:modelValue","close","open"],setup(t,{emit:i}){const o=t,r=i,n=z.useNamespace("drawer"),a=e.ref(2e3),m=()=>{r("update:modelValue",!1),r("close")},u=()=>{o.closeOnClickModal&&m()},f=c=>{c.key==="Escape"&&o.modelValue&&m()};e.watch(()=>o.modelValue,c=>{c?(a.value=2e3+Math.floor(Math.random()*100),r("open"),document.addEventListener("keydown",f)):document.removeEventListener("keydown",f)});const l=e.computed(()=>({zIndex:a.value})),h=e.computed(()=>{const c=o.direction??o.placement??"rtl",g=o.size??o.width??"30%",p=typeof g=="number"?`${g}px`:g;return{ltr:{width:p,height:"100%"},rtl:{width:p,height:"100%"},ttb:{width:"100%",height:p},btt:{width:"100%",height:p}}[c]});return(c,g)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"x-drawer-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("overlay")),style:e.normalizeStyle(l.value),onClick:u},[e.createElementVNode("div",{class:e.normalizeClass([e.unref(n).b(),e.unref(n).m(t.direction??t.placement)]),style:e.normalizeStyle(h.value),onClick:g[0]||(g[0]=e.withModifiers(()=>{},["stop"]))},[t.withHeader?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(n).e("header"))},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n).e("title"))},[e.renderSlot(c.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])],2),t.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(e.unref(n).e("close")),onClick:m}," ✕ ",2)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("body"))},[e.renderSlot(c.$slots,"default")],2),c.$slots.footer?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(e.unref(n).e("footer"))},[e.renderSlot(c.$slots,"footer")],2)):e.createCommentVNode("",!0)],6)],6),[[e.vShow,t.modelValue]])]),_:3})]))}}),Y=e.defineComponent({name:"XAlert",__name:"index",props:{type:{default:"info"},title:{default:""},description:{},closable:{type:Boolean,default:!0},showIcon:{type:Boolean,default:!1},center:{type:Boolean,default:!1}},emits:["close"],setup(t,{emit:i}){const o=t,r=i,n=z.useNamespace("alert"),a=e.ref(!0),m={success:"✓",warning:"⚠",error:"✕",info:"ℹ"},u=e.computed(()=>[n.b(),n.m(o.type),n.is("center",o.center),n.is("with-description",o.description)]),f=l=>{a.value=!1,r("close",l)};return(l,h)=>(e.openBlock(),e.createBlock(e.Transition,{name:"x-alert-fade"},{default:e.withCtx(()=>[a.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(u.value)},[t.showIcon?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(n).e("icon"))},e.toDisplayString(m[t.type]),3)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).e("content"))},[t.title||l.$slots.title?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(n).e("title"))},[e.renderSlot(l.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])],2)):e.createCommentVNode("",!0),t.description||l.$slots.default?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(e.unref(n).e("description"))},[e.renderSlot(l.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.description),1)])],2)):e.createCommentVNode("",!0)],2),t.closable?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(e.unref(n).e("close")),onClick:f}," ✕ ",2)):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0)]),_:3}))}}),G=e.defineComponent({name:"XTooltip",__name:"index",props:{content:{default:""},placement:{default:"top"},effect:{default:"dark"},disabled:{type:Boolean,default:!1},offset:{default:8},transition:{default:"fade"},visibleArrow:{type:Boolean,default:!0},trigger:{default:"hover"},openDelay:{default:0},closeDelay:{default:0}},emits:["update:visible","show","hide"],setup(t,{emit:i}){const o=t,r=i,n=z.useNamespace("tooltip"),a=e.ref(!1),m=e.ref(),u=e.ref();let f,l;const h=e.ref({}),c=()=>{if(!m.value||!u.value)return;const b=m.value.getBoundingClientRect(),S=u.value;S.style.visibility="hidden",S.style.display="block";const E=S.offsetWidth,V=S.offsetHeight,N=o.offset,W=window.innerWidth,j=window.innerHeight;let B=0,T=0,I=o.placement;switch(o.placement){case"top":B=b.top-V-N,T=b.left+(b.width-E)/2;break;case"bottom":B=b.bottom+N,T=b.left+(b.width-E)/2;break;case"left":B=b.top+(b.height-V)/2,T=b.left-E-N;break;case"right":B=b.top+(b.height-V)/2,T=b.right+N;break}o.placement==="top"&&B<0?(I="bottom",B=b.bottom+N):o.placement==="bottom"&&B+V>j?(I="top",B=b.top-V-N):o.placement==="left"&&T<0?(I="right",T=b.right+N):o.placement==="right"&&T+E>W&&(I="left",T=b.left-E-N),T<8&&(T=8),T+E>W-8&&(T=W-E-8),B<8&&(B=8),B+V>j-8&&(B=j-V-8),h.value={position:"fixed",top:`${B}px`,left:`${T}px`,visibility:"visible",zIndex:"2000"},g.value=I},g=e.ref(o.placement),p=()=>{o.disabled||(clearTimeout(l),f=setTimeout(()=>{a.value=!0,r("update:visible",!0),r("show"),e.nextTick(()=>{c()})},o.openDelay))},C=()=>{clearTimeout(f),l=setTimeout(()=>{a.value=!1,r("update:visible",!1),r("hide")},o.closeDelay)},y=()=>{a.value?C():p()},v=()=>{o.trigger==="hover"&&p()},s=()=>{o.trigger==="hover"&&C()},d=()=>{o.trigger==="click"&&y()},$=()=>{o.trigger==="focus"&&p()},k=()=>{o.trigger==="focus"&&C()},w=b=>{var S,E;o.trigger==="click"&&!((S=m.value)!=null&&S.contains(b.target))&&!((E=u.value)!=null&&E.contains(b.target))&&C()},x=()=>{a.value&&c()};e.watch(a,b=>{b?e.nextTick(()=>{c(),o.trigger==="click"&&document.addEventListener("click",w),window.addEventListener("scroll",x,!0),window.addEventListener("resize",x)}):(document.removeEventListener("click",w),window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x))}),e.onUnmounted(()=>{clearTimeout(f),clearTimeout(l),document.removeEventListener("click",w),window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)});const R=e.computed(()=>[n.b(),n.m(o.effect)]),H=e.computed(()=>[n.e("arrow"),n.e(`arrow-${g.value}`)]);return(b,S)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(n).e("wrapper"))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:e.normalizeClass(e.unref(n).e("trigger")),onMouseenter:v,onMouseleave:s,onClick:d,onFocus:$,onBlur:k},[e.renderSlot(b.$slots,"default")],34),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:`x-tooltip-${t.transition}`},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{ref_key:"tooltipRef",ref:u,class:e.normalizeClass(R.value),style:e.normalizeStyle(h.value),onMouseenter:v,onMouseleave:s},[e.renderSlot(b.$slots,"content",{},()=>[e.createTextVNode(e.toDisplayString(t.content),1)]),t.visibleArrow?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(H.value)},null,2)):e.createCommentVNode("",!0)],38),[[e.vShow,a.value]])]),_:3},8,["name"])]))],2))}}),J={class:"x-popconfirm-wrapper"},Q={class:"x-popconfirm__main"},ee={class:"x-popconfirm__title"},te={class:"x-popconfirm__action"},oe=e.defineComponent({name:"XPopconfirm",__name:"index",props:{title:{default:""},confirmButtonText:{default:"确定"},cancelButtonText:{default:"取消"},confirmButtonType:{default:"primary"},cancelButtonType:{default:"default"},icon:{default:""},iconColor:{default:"#faad14"},hideIcon:{type:Boolean,default:!1},hideCancelButton:{type:Boolean,default:!1},hideConfirmButton:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},width:{default:200},placement:{default:"top"},offset:{default:12},showArrow:{type:Boolean,default:!0}},emits:["confirm","cancel"],setup(t,{emit:i}){const o=t,r=i,n=e.ref(!1),a=e.ref(null),m=e.ref(null),u=e.ref({}),f=()=>{if(!a.value||!m.value)return;const s=a.value.getBoundingClientRect(),d=m.value.getBoundingClientRect(),$=o.placement,k=o.offset;let w=0,x=0;switch($){case"top":w=s.top-d.height-k,x=s.left+(s.width-d.width)/2;break;case"top-start":w=s.top-d.height-k,x=s.left;break;case"top-end":w=s.top-d.height-k,x=s.right-d.width;break;case"bottom":w=s.bottom+k,x=s.left+(s.width-d.width)/2;break;case"bottom-start":w=s.bottom+k,x=s.left;break;case"bottom-end":w=s.bottom+k,x=s.right-d.width;break;case"left":w=s.top+(s.height-d.height)/2,x=s.left-d.width-k;break;case"left-start":w=s.top,x=s.left-d.width-k;break;case"left-end":w=s.bottom-d.height,x=s.left-d.width-k;break;case"right":w=s.top+(s.height-d.height)/2,x=s.right+k;break;case"right-start":w=s.top,x=s.right+k;break;case"right-end":w=s.bottom-d.height,x=s.right+k;break;default:w=s.top-d.height-k,x=s.left+(s.width-d.width)/2}const R=window.innerWidth,H=window.innerHeight;x<0&&(x=10),x+d.width>R&&(x=R-d.width-10),w<0&&(w=10),w+d.height>H&&(w=H-d.height-10),u.value={position:"fixed",top:`${w}px`,left:`${x}px`,zIndex:"2000"}},l=s=>{var d,$;n.value&&((d=a.value)!=null&&d.contains(s.target)||($=m.value)!=null&&$.contains(s.target)||(n.value=!1))},h=s=>{o.disabled||(s.stopPropagation(),n.value=!n.value,n.value&&setTimeout(f,0))},c=()=>{n.value=!1,r("confirm")},g=()=>{n.value=!1,r("cancel")},p=()=>{n.value&&f()},C=()=>{n.value&&f()};e.watch(n,s=>{s?(setTimeout(f,0),document.addEventListener("click",l),window.addEventListener("scroll",p,!0),window.addEventListener("resize",C)):(document.removeEventListener("click",l),window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",C))}),e.onUnmounted(()=>{document.removeEventListener("click",l),window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",C)});const y=e.computed(()=>({width:typeof o.width=="number"?`${o.width}px`:o.width})),v=e.computed(()=>{const s=o.placement,d={};switch(s){case"top":case"top-start":case"top-end":d.bottom="-6px",d.transform="rotate(45deg)";break;case"bottom":case"bottom-start":case"bottom-end":d.top="-6px",d.transform="rotate(225deg)";break;case"left":case"left-start":case"left-end":d.right="-6px",d.transform="rotate(315deg)";break;case"right":case"right-start":case"right-end":d.left="-6px",d.transform="rotate(135deg)";break}return d});return(s,d)=>(e.openBlock(),e.createElementBlock("span",J,[e.createElementVNode("span",{ref_key:"triggerRef",ref:a,class:"x-popconfirm-trigger",onClick:h},[e.renderSlot(s.$slots,"default")],512),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"x-popconfirm-fade"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"popperRef",ref:m,class:"x-popconfirm",style:e.normalizeStyle({...u.value,...y.value}),onClick:d[0]||(d[0]=e.withModifiers(()=>{},["stop"]))},[t.showArrow?(e.openBlock(),e.createElementBlock("span",{key:0,class:"x-popconfirm__arrow",style:e.normalizeStyle(v.value)},null,4)):e.createCommentVNode("",!0),e.createElementVNode("div",Q,[t.hideIcon?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",{key:0,class:"x-popconfirm__icon",style:e.normalizeStyle({color:t.iconColor})},[e.renderSlot(s.$slots,"icon",{},()=>[e.createTextVNode(e.toDisplayString(t.icon||"⚠"),1)])],4)),e.createElementVNode("div",ee,[e.renderSlot(s.$slots,"title",{},()=>[e.createTextVNode(e.toDisplayString(t.title),1)])])]),e.createElementVNode("div",te,[t.hideCancelButton?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:0,class:"x-button p-button--default p-button--small",onClick:g},e.toDisplayString(t.cancelButtonText),1)),t.hideConfirmButton?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["x-button x-button--small",`x-button--${t.confirmButtonType}`]),onClick:c},e.toDisplayString(t.confirmButtonText),3))])],4)):e.createCommentVNode("",!0)]),_:3})]))]))}}),ne=e.defineComponent({name:"XBacktop",__name:"index",props:{visibilityHeight:{default:200},right:{default:40},bottom:{default:40}},emits:["click"],setup(t,{emit:i}){const o=t,r=i,n=z.useNamespace("backtop"),a=e.ref(!1),m=()=>{const l=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0;a.value=l>=o.visibilityHeight},u=l=>{window.scrollTo({top:0,behavior:"smooth"}),r("click",l)},f=e.computed(()=>({right:`${o.right}px`,bottom:`${o.bottom}px`}));return e.onMounted(()=>{window.addEventListener("scroll",m,{passive:!0,capture:!0}),setTimeout(m,100)}),e.onUnmounted(()=>{window.removeEventListener("scroll",m,!0)}),(l,h)=>(e.openBlock(),e.createBlock(e.Transition,{name:"x-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(e.unref(n).b()),style:e.normalizeStyle(f.value),onClick:u},[e.renderSlot(l.$slots,"default",{},()=>[e.createElementVNode("span",{class:e.normalizeClass(e.unref(n).e("icon"))},"↑",2)])],6),[[e.vShow,a.value]])]),_:3}))}}),se=e.defineComponent({name:"XMessage",__name:"index",props:{message:{default:""},type:{default:"info"},duration:{default:3e3},showClose:{type:Boolean,default:!1},center:{type:Boolean,default:!1},offset:{default:20},customClass:{},onClose:{}},emits:["close","destroy"],setup(t,{expose:i,emit:o}){const r=t,n=o,a=z.useNamespace("message"),m=e.ref(!1),u=e.ref(z.nextMessageZIndex()),f={success:"✓",warning:"⚠",error:"✕",info:"ℹ"},l=e.computed(()=>[a.b(),a.m(r.type),a.is("center",r.center),a.is("closable",r.showClose),r.customClass]),h=e.computed(()=>({top:`${r.offset}px`,zIndex:u.value}));let c=null;const g=()=>{r.duration>0&&(c=setTimeout(()=>{C()},r.duration))},p=()=>{c&&(clearTimeout(c),c=null)},C=()=>{var v;m.value=!1,(v=r.onClose)==null||v.call(r),n("close")},y=()=>{n("destroy")};return e.onMounted(()=>{g(),m.value=!0}),e.onUnmounted(()=>{p()}),i({close:C}),(v,s)=>(e.openBlock(),e.createBlock(e.Transition,{name:"x-message-fade",onAfterLeave:y},{default:e.withCtx(()=>[m.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(l.value),style:e.normalizeStyle(h.value),onMouseenter:p,onMouseleave:g},[e.createElementVNode("span",{class:e.normalizeClass(e.unref(a).e("icon"))},e.toDisplayString(f[t.type]),3),e.createElementVNode("span",{class:e.normalizeClass(e.unref(a).e("content"))},[e.renderSlot(v.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(t.message),1)])],2),t.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(e.unref(a).e("close")),onClick:C}," ✕ ",2)):e.createCommentVNode("",!0)],38)):e.createCommentVNode("",!0)]),_:3}))}}),L=[];let le=1;const ie=()=>{L.slice().forEach(t=>t.close())};function U(t){const i=le++,o=document.createElement("div");document.body.appendChild(o);const r={success:{bg:"#f0f9eb",border:"#67c23a",icon:"✓"},warning:{bg:"#fdf6ec",border:"#e6a23c",icon:"⚠"},error:{bg:"#fef0f0",border:"#f56c6c",icon:"✕"},info:{bg:"#f4f4f5",border:"#909399",icon:"ℹ"}},n=t.type||"info",a=r[n]||r.info,m=e.reactive({visible:!1,offset:t.offset??20});let u=t.offset??20;L.forEach(y=>{const v=y.container.firstElementChild;v&&v.offsetHeight&&(u+=v.offsetHeight+16)}),m.offset=u;let f=null,l=!1;const h=()=>{l||(m.visible=!1,setTimeout(()=>{if(l)return;l=!0;const y=L.findIndex(v=>v.id===i);y!==-1&&L.splice(y,1);try{p.unmount()}catch{}o.parentNode&&o.parentNode.removeChild(o)},300))},c=()=>{const y=t.duration??3e3;y>0&&(f=setTimeout(h,y))},g=()=>{f&&(clearTimeout(f),f=null)},p=e.createApp({render(){if(!m.visible)return null;const y=[e.h("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",marginRight:"10px",fontSize:"16px",color:a.border}},a.icon),e.h("span",{style:{flex:"1",fontSize:"14px",color:"#606266",lineHeight:"1.4"}},t.message||"")];return t.showClose&&y.push(e.h("button",{style:{position:"absolute",top:"50%",right:"12px",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"14px",color:"#909399",padding:"0"},onClick:v=>{v.stopPropagation(),h()}},"✕")),e.h("div",{class:["x-message",`x-message--${n}`,t.center?"is-center":"",t.showClose?"is-closable":""],style:{position:"fixed",left:"50%",top:`${m.offset}px`,transform:"translateX(-50%)",display:"flex",alignItems:"center",padding:t.showClose?"12px 40px 12px 16px":"12px 16px",borderRadius:"4px",boxShadow:"0 2px 12px rgba(0,0,0,0.1)",minWidth:"280px",maxWidth:"480px",backgroundColor:a.bg,border:`1px solid ${a.border}`,zIndex:2e3+i,transition:"opacity 0.3s, transform 0.3s"},onMouseenter:g,onMouseleave:c},y)}});p.mount(o),e.nextTick(()=>{m.visible=!0,c()});const C={id:i,app:p,container:o,close:h};return L.push(C),{close:h}}function ae(t){return U(typeof t=="string"?{message:t}:t)}const O=t=>i=>U({...typeof i=="string"?{message:i}:i,type:t}),X=Object.assign(ae,{info:O("info"),success:O("success"),warning:O("warning"),error:O("error"),closeAll:ie}),re=X,ce=se,de={install(t){t.config.globalProperties.$message=X,t.provide("message",X)}},P=[],ue=()=>{P.slice().forEach(t=>t.close())},fe={success:{icon:"✓",color:"#67c23a"},warning:{icon:"⚠",color:"#e6a23c"},error:{icon:"✕",color:"#f56c6c"},info:{icon:"ℹ",color:"#909399"}};function _(t){return new Promise(i=>{const o=document.createElement("div");document.body.appendChild(o);let r=!1;const n=e.defineComponent({name:"TMessageBox",setup(){const u=e.ref(!1),f=e.ref(t.inputValue??""),l=e.ref(""),h=2e3+P.length+1,c=v=>{r||(r=!0,u.value=!1,setTimeout(()=>{const s=P.findIndex(d=>d.container===o);s!==-1&&P.splice(s,1);try{a.unmount()}catch{}o.parentNode&&o.parentNode.removeChild(o),i({action:v,value:v==="confirm"?f.value:void 0})},300))},g=()=>{if(t.showInput&&t.inputPattern&&!t.inputPattern.test(f.value)){l.value=t.inputErrorMessage||"输入格式不正确";return}l.value="",c("confirm")},p=()=>{c("cancel")},C=()=>{c("close")},y=()=>{t.closeOnClickModal!==!1&&C()};return e.nextTick(()=>{u.value=!0}),{visible:u,inputValue:f,inputError:l,zIndex:h,handleConfirm:g,handleCancel:p,handleClose:C,handleMaskClick:y}},render(){if(!this.visible)return null;const u=t.type,f=u?fe[u]:null,l=[];f&&l.push(e.h("span",{class:"x-message-box__icon",style:{color:f.color,marginRight:"10px",fontSize:"20px"}},f.icon)),l.push(e.h("span",{class:"x-message-box__title"},t.title||"提示")),t.showClose!==!1&&l.push(e.h("button",{class:"x-message-box__close",onClick:this.handleClose},"✕"));const h=[];h.push(e.h("div",{class:"x-message-box__content"},t.message||"")),t.showInput&&h.push(e.h("div",{class:"x-message-box__input",style:{marginTop:"12px"}},[e.h("input",{class:["x-message-box__input-inner",this.inputError?"is-error":""].filter(Boolean),type:t.inputType||"text",placeholder:t.inputPlaceholder||"请输入",value:this.inputValue,onInput:g=>{this.inputValue=g.target.value,this.inputError=""},onKeyup:g=>{g.key==="Enter"&&this.handleConfirm()}}),this.inputError?e.h("div",{class:"x-message-box__error",style:{color:"#f56c6c",fontSize:"12px",marginTop:"4px"}},this.inputError):null]));const c=[];return t.showCancelButton&&c.push(e.h("button",{class:"x-button p-button--default",onClick:this.handleCancel},t.cancelButtonText||"取消")),t.showConfirmButton!==!1&&c.push(e.h("button",{class:"x-button p-button--primary",onClick:this.handleConfirm,style:{marginLeft:"10px"}},t.confirmButtonText||"确定")),e.h("div",{class:["x-message-box-wrapper",t.center?"is-center":""],style:{position:"fixed",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:this.zIndex},onClick:this.handleMaskClick},[e.h("div",{class:["x-message-box",t.customClass],style:{backgroundColor:"#fff",borderRadius:"4px",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.1)",minWidth:"300px",maxWidth:"500px"},onClick:g=>g.stopPropagation()},[e.h("div",{class:"x-message-box__header",style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 20px",borderBottom:"1px solid #eee"}},l),e.h("div",{class:"x-message-box__body",style:{padding:"20px",fontSize:"14px",color:"#606266"}},h),e.h("div",{class:"x-message-box__footer",style:{padding:"10px 20px 16px",textAlign:"right"}},c)])])}}),a=e.createApp(n);a.mount(o);const m={app:a,container:o,close:()=>{var f;const u=(f=a._instance)==null?void 0:f.proxy;u!=null&&u.handleClose&&u.handleClose()}};P.push(m)})}async function me(t,i,o){return _({message:t,title:i,...o,showConfirmButton:!0,showCancelButton:!1})}async function pe(t,i,o){return _({message:t,title:i,...o,showConfirmButton:!0,showCancelButton:!0})}async function he(t,i,o){return _({message:t,title:i,...o,showInput:!0,showConfirmButton:!0,showCancelButton:!0})}function ge(t){return _(t)}const M=Object.assign(ge,{alert:me,confirm:pe,prompt:he,closeAll:ue}),xe=M,ye={install(t){t.config.globalProperties.$msgbox=M,t.config.globalProperties.$alert=M.alert,t.config.globalProperties.$confirm=M.confirm,t.config.globalProperties.$prompt=M.prompt,t.provide("messageBox",M)}},D=[];let ve=1;const be=()=>{D.slice().forEach(t=>t.close())},Ce={success:{icon:"✓",color:"#67c23a"},warning:{icon:"⚠",color:"#e6a23c"},error:{icon:"✕",color:"#f56c6c"},info:{icon:"ℹ",color:"#909399"}},we=(t,i)=>{const o=D.filter(n=>n.position===t);let r=16;for(const n of o)if(n.id<i){const a=n.container.firstElementChild;a&&(r+=a.offsetHeight+16)}return r},ke=(t,i)=>{const o={position:"fixed",width:"330px",zIndex:"2010"};switch(t){case"top-right":o.top=`${i}px`,o.right="16px";break;case"top-left":o.top=`${i}px`,o.left="16px";break;case"bottom-right":o.bottom=`${i}px`,o.right="16px";break;case"bottom-left":o.bottom=`${i}px`,o.left="16px";break;default:o.top=`${i}px`,o.right="16px"}return o};function Z(t){const i=ve++,o=t.position||"top-right",r=document.createElement("div");document.body.appendChild(r);let n=null,a=!1;const m=e.defineComponent({name:"TNotification",setup(){const l=e.ref(!1),h=()=>{a||(a=!0,l.value=!1,setTimeout(()=>{var v;const y=D.findIndex(s=>s.id===i);y!==-1&&D.splice(y,1),n&&clearTimeout(n),(v=t.onClose)==null||v.call(t);try{u.unmount()}catch{}r.parentNode&&r.parentNode.removeChild(r)},300))},c=()=>{const y=t.duration??4500;y>0&&(n=setTimeout(h,y))},g=()=>{n&&(clearTimeout(n),n=null)},p=e.computed(()=>(t.offset??0)+we(o,i)),C=e.computed(()=>ke(o,p.value));return e.nextTick(()=>{l.value=!0,c()}),{visible:l,close:h,positionStyles:C,startTimer:c,clearTimer:g}},render(){if(!this.visible)return null;const l=t.type,h=l?Ce[l]:null,c=[];t.title&&c.push(e.h("div",{class:"x-notification__title",style:{fontWeight:"600",fontSize:"16px",color:"#303133",marginBottom:t.message?"6px":"0"}},t.title)),t.message&&(t.dangerouslyUseHTMLString?c.push(e.h("div",{class:"x-notification__content",style:{fontSize:"14px",color:"#606266",lineHeight:"1.5"},innerHTML:t.message})):c.push(e.h("div",{class:"x-notification__content",style:{fontSize:"14px",color:"#606266",lineHeight:"1.5"}},t.message)));const g=[];return h&&g.push(e.h("div",{class:"x-notification__icon",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"24px",height:"24px",marginRight:"12px",fontSize:"18px",color:h.color}},h.icon)),g.push(e.h("div",{class:"x-notification__main",style:{flex:"1"}},c)),t.showClose!==!1&&g.push(e.h("button",{class:"x-notification__close",style:{position:"absolute",top:"18px",right:"15px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",color:"#909399",padding:"0"},onClick:p=>{p.stopPropagation(),this.close()}},"✕")),e.h("div",{class:["x-notification",t.customClass],style:{...this.positionStyles,display:"flex",alignItems:"flex-start",padding:"14px 26px 14px 13px",borderRadius:"8px",backgroundColor:"#fff",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",transition:"opacity 0.3s, transform 0.3s",boxSizing:"border-box"},onMouseenter:this.clearTimer,onMouseleave:this.startTimer},g)}}),u=e.createApp(m);u.mount(r);const f={id:i,app:u,container:r,position:o,close:()=>{var h;const l=(h=u._instance)==null?void 0:h.proxy;l!=null&&l.close&&l.close()}};return D.push(f),{close:f.close}}function Be(t){return Z(typeof t=="string"?{message:t}:t)}const A=t=>i=>Z({...typeof i=="string"?{message:i}:i,type:t}),F=Object.assign(Be,{info:A("info"),success:A("success"),warning:A("warning"),error:A("error"),closeAll:be}),Te=F,Ee={install(t){t.config.globalProperties.$notify=F,t.provide("notification",F)}};exports.Alert=Y;exports.Backtop=ne;exports.Drawer=K;exports.Message=re;exports.MessageBox=xe;exports.MessageComponent=ce;exports.Modal=q;exports.Notification=Te;exports.Popconfirm=oe;exports.TMessage=de;exports.TMessageBox=ye;exports.TNotification=Ee;exports.Tooltip=G;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xto/feedback",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Xto Feedback - Feedback components",
5
5
  "main": "./lib/index.cjs",
6
6
  "module": "./es/index.mjs",
@@ -35,4 +35,4 @@
35
35
  "vitest": "^1.4.0",
36
36
  "vue": "^3.4.21"
37
37
  }
38
- }
38
+ }