@mtn-ui/components 1.0.5 → 1.0.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.
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { cn as _e, withInstall as ge, PERMISSION_CHECKER_KEY as Z, defaultPermissionChecker as J } from "@mtn-ui/shared";
2
- import { defineComponent as _, createVNode as v, inject as Q, ref as D, computed as c, mergeProps as S, Fragment as I, h as Ee, Comment as Ne, Text as $e, useSlots as Oe, createElementBlock as w, openBlock as u, createElementVNode as re, unref as B, withCtx as f, createBlock as g, createCommentVNode as Le, renderList as O, resolveDynamicComponent as A, createSlots as j, createTextVNode as W, toDisplayString as q, cloneVNode as ae, watch as le, nextTick as ue, onBeforeUnmount as Re, renderSlot as V, isVNode as Ve } from "vue";
3
- import { cva as je } from "class-variance-authority";
4
- import { Button as ve, Space as se, Dropdown as ce, Menu as G, Popconfirm as We, message as de, Modal as Fe, Table as Ge } from "ant-design-vue";
5
- import { useElementSize as He, useDebounceFn as Ke } from "@vueuse/core";
6
- import { MoreOutlined as Ue, DeleteOutlined as fe, ExclamationCircleOutlined as qe } from "@ant-design/icons-vue";
7
- const Ye = {
1
+ import { cn as Le, withInstall as Ce, PERMISSION_CHECKER_KEY as ie, defaultPermissionChecker as re } from "@mtn-ui/shared";
2
+ import { defineComponent as N, createVNode as h, inject as ae, ref as M, computed as p, mergeProps as C, Fragment as E, h as Ve, Comment as Re, Text as Ue, useSlots as We, shallowRef as Fe, watch as J, createElementBlock as x, openBlock as s, createElementVNode as me, unref as S, withCtx as y, createBlock as k, createCommentVNode as Ge, renderList as j, resolveDynamicComponent as z, createSlots as U, createTextVNode as W, toDisplayString as te, cloneVNode as ye, nextTick as ge, onBeforeUnmount as He, renderSlot as R, isVNode as Ke } from "vue";
3
+ import { cva as Ye } from "class-variance-authority";
4
+ import { Button as Te, Space as ve, Dropdown as be, Menu as Z, Popconfirm as qe, message as ke, Modal as Ze, Table as Je } from "ant-design-vue";
5
+ import { useElementSize as Qe, useDebounceFn as ze } from "@vueuse/core";
6
+ import { MoreOutlined as Xe, DeleteOutlined as he, ExclamationCircleOutlined as et } from "@ant-design/icons-vue";
7
+ const tt = {
8
8
  type: {
9
9
  type: String,
10
10
  default: "default"
@@ -12,7 +12,7 @@ const Ye = {
12
12
  color: {
13
13
  type: String
14
14
  }
15
- }, Ze = je("inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border transition-colors", {
15
+ }, nt = Ye("inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border transition-colors", {
16
16
  variants: {
17
17
  type: {
18
18
  default: "bg-gray-100 text-gray-800 border-gray-200",
@@ -25,26 +25,26 @@ const Ye = {
25
25
  defaultVariants: {
26
26
  type: "default"
27
27
  }
28
- }), Je = /* @__PURE__ */ _({
28
+ }), ot = /* @__PURE__ */ N({
29
29
  name: "MTag",
30
- props: Ye,
30
+ props: tt,
31
31
  setup(e, {
32
- slots: n,
32
+ slots: o,
33
33
  attrs: t
34
34
  }) {
35
35
  return () => {
36
36
  var l;
37
37
  const {
38
- type: o
38
+ type: i
39
39
  } = e;
40
- return v("span", {
41
- class: _e(Ze({
42
- type: o
40
+ return h("span", {
41
+ class: Le(nt({
42
+ type: i
43
43
  }), t.class)
44
- }, [(l = n.default) == null ? void 0 : l.call(n)]);
44
+ }, [(l = o.default) == null ? void 0 : l.call(o)]);
45
45
  };
46
46
  }
47
- }), Qe = ge(Je), be = {
47
+ }), it = Ce(ot), Ae = {
48
48
  // 按钮类型
49
49
  type: {
50
50
  type: String,
@@ -105,19 +105,19 @@ const Ye = {
105
105
  default: "hide"
106
106
  }
107
107
  };
108
- function ke(e) {
109
- const { permission: n, permissionAction: t = "hide" } = e, o = Q(Z, D(J)), l = c(() => n ? o.value(n) : !0), p = c(() => !l.value && t === "hide"), m = c(() => !l.value && t === "disable");
108
+ function Pe(e) {
109
+ const { permission: o, permissionAction: t = "hide" } = e, i = ae(ie, M(re)), l = p(() => o ? i.value(o) : !0), g = p(() => !l.value && t === "hide"), m = p(() => !l.value && t === "disable");
110
110
  return {
111
111
  hasPermission: l,
112
- shouldHide: p,
112
+ shouldHide: g,
113
113
  shouldDisable: m
114
114
  };
115
115
  }
116
- function Xe(e, n) {
116
+ function rt(e, o) {
117
117
  return e.map((t) => {
118
118
  if (!t || t.type === "divider" || !t.permission)
119
119
  return t;
120
- if (!n(t.permission)) {
120
+ if (!o(t.permission)) {
121
121
  const l = t.permissionAction || "hide";
122
122
  if (l === "hide")
123
123
  return null;
@@ -127,29 +127,29 @@ function Xe(e, n) {
127
127
  return t;
128
128
  }).filter(Boolean);
129
129
  }
130
- const H = /* @__PURE__ */ _({
130
+ const Q = /* @__PURE__ */ N({
131
131
  name: "MButton",
132
- props: be,
132
+ props: Ae,
133
133
  emits: ["click"],
134
134
  setup(e, {
135
- slots: n,
135
+ slots: o,
136
136
  attrs: t,
137
- emit: o
137
+ emit: i
138
138
  }) {
139
139
  const {
140
140
  shouldHide: l,
141
- shouldDisable: p
142
- } = ke({
141
+ shouldDisable: g
142
+ } = Pe({
143
143
  permission: e.permission,
144
144
  permissionAction: e.permissionAction
145
- }), m = (y) => {
146
- o("click", y);
145
+ }), m = (f) => {
146
+ i("click", f);
147
147
  };
148
- return () => l.value ? null : v(ve, S({
148
+ return () => l.value ? null : h(Te, C({
149
149
  type: e.type,
150
150
  size: e.size,
151
151
  loading: e.loading,
152
- disabled: e.disabled || p.value,
152
+ disabled: e.disabled || g.value,
153
153
  danger: e.danger,
154
154
  block: e.block,
155
155
  ghost: e.ghost,
@@ -161,12 +161,16 @@ const H = /* @__PURE__ */ _({
161
161
  onClick: m
162
162
  }), {
163
163
  default: () => {
164
- var y;
165
- return [(y = n.default) == null ? void 0 : y.call(n)];
164
+ var f;
165
+ return (f = o.default) == null ? void 0 : f.call(o);
166
+ },
167
+ icon: () => {
168
+ var f;
169
+ return (f = o.icon) == null ? void 0 : f.call(o);
166
170
  }
167
171
  });
168
172
  }
169
- }), et = {
173
+ }), at = {
170
174
  // 按钮组尺寸
171
175
  size: {
172
176
  type: String,
@@ -192,16 +196,16 @@ const H = /* @__PURE__ */ _({
192
196
  type: Boolean,
193
197
  default: !1
194
198
  }
195
- }, he = /* @__PURE__ */ _({
199
+ }, xe = /* @__PURE__ */ N({
196
200
  name: "MButtonGroup",
197
- props: et,
201
+ props: at,
198
202
  setup(e, {
199
- slots: n,
203
+ slots: o,
200
204
  attrs: t
201
205
  }) {
202
- return () => v(I, null, [e.compact ? (
206
+ return () => h(E, null, [e.compact ? (
203
207
  // 紧凑模式:按钮紧密连接
204
- v(se.Compact, S({
208
+ h(ve.Compact, C({
205
209
  size: e.size,
206
210
  direction: e.vertical ? "vertical" : "horizontal",
207
211
  block: e.block
@@ -209,26 +213,26 @@ const H = /* @__PURE__ */ _({
209
213
  class: ["mtn-button-group", "mtn-button-group--compact", t.class]
210
214
  }), {
211
215
  default: () => {
212
- var o;
213
- return [(o = n.default) == null ? void 0 : o.call(n)];
216
+ var i;
217
+ return [(i = o.default) == null ? void 0 : i.call(o)];
214
218
  }
215
219
  })
216
220
  ) : (
217
221
  // 普通模式:按钮有间距
218
- v(se, S({
222
+ h(ve, C({
219
223
  size: typeof e.gap == "number" ? e.gap : parseInt(e.gap) || 8,
220
224
  direction: e.vertical ? "vertical" : "horizontal"
221
225
  }, t, {
222
226
  class: ["mtn-button-group", "mtn-button-group--normal", t.class]
223
227
  }), {
224
228
  default: () => {
225
- var o;
226
- return [(o = n.default) == null ? void 0 : o.call(n)];
229
+ var i;
230
+ return [(i = o.default) == null ? void 0 : i.call(o)];
227
231
  }
228
232
  })
229
233
  )]);
230
234
  }
231
- }), tt = {
235
+ }), lt = {
232
236
  // 按钮文字
233
237
  text: {
234
238
  type: String,
@@ -284,77 +288,77 @@ const H = /* @__PURE__ */ _({
284
288
  type: String,
285
289
  default: "hide"
286
290
  }
287
- }, Y = /* @__PURE__ */ _({
291
+ }, oe = /* @__PURE__ */ N({
288
292
  name: "MDropdownButton",
289
- props: tt,
293
+ props: lt,
290
294
  emits: ["click"],
291
295
  setup(e, {
292
- slots: n,
296
+ slots: o,
293
297
  attrs: t,
294
- emit: o
298
+ emit: i
295
299
  }) {
296
300
  const {
297
301
  shouldHide: l,
298
- shouldDisable: p
299
- } = ke({
302
+ shouldDisable: g
303
+ } = Pe({
300
304
  permission: e.permission,
301
305
  permissionAction: e.permissionAction
302
- }), m = Q(Z, D(J)), y = (b) => {
303
- o("click", b);
306
+ }), m = ae(ie, M(re)), f = (v) => {
307
+ i("click", v);
304
308
  };
305
309
  return () => {
306
310
  if (l.value)
307
311
  return null;
308
- const b = {};
309
- if (n.overlay)
310
- b.overlay = n.overlay;
312
+ const v = {};
313
+ if (o.overlay)
314
+ v.overlay = o.overlay;
311
315
  else if (e.menu && e.menu.length > 0) {
312
- const k = Xe(e.menu, m.value);
313
- b.overlay = () => Ee(G, {
314
- items: k
316
+ const B = rt(e.menu, m.value);
317
+ v.overlay = () => Ve(Z, {
318
+ items: B
315
319
  });
316
320
  }
317
- return n.icon && (b.icon = n.icon), !(n.default || e.text) ? v(ce, S({
321
+ return o.icon && (v.icon = o.icon), !(o.default || e.text) ? h(be, C({
318
322
  placement: e.placement,
319
323
  trigger: e.trigger
320
324
  }, t, {
321
325
  class: ["mtn-dropdown-button", t.class]
322
326
  }), {
323
- default: () => [v(ve, {
327
+ default: () => [h(Te, {
324
328
  type: e.type,
325
329
  size: e.size === "middle" ? void 0 : e.size,
326
- disabled: e.disabled || p.value,
330
+ disabled: e.disabled || g.value,
327
331
  loading: e.loading,
328
332
  danger: e.danger,
329
- onClick: y
333
+ onClick: f
330
334
  }, {
331
335
  default: () => {
332
- var k;
333
- return [(k = n.icon) == null ? void 0 : k.call(n)];
336
+ var B;
337
+ return [(B = o.icon) == null ? void 0 : B.call(o)];
334
338
  }
335
339
  })],
336
- ...b
337
- }) : v(ce.Button, S({
340
+ ...v
341
+ }) : h(be.Button, C({
338
342
  type: e.type,
339
343
  size: e.size === "middle" ? void 0 : e.size,
340
- disabled: e.disabled || p.value,
344
+ disabled: e.disabled || g.value,
341
345
  loading: e.loading,
342
346
  danger: e.danger,
343
347
  placement: e.placement,
344
348
  trigger: e.trigger
345
349
  }, t, {
346
350
  class: ["mtn-dropdown-button", t.class],
347
- onClick: y
351
+ onClick: f
348
352
  }), {
349
353
  default: () => {
350
- var k;
351
- return [((k = n.default) == null ? void 0 : k.call(n)) || e.text];
354
+ var B;
355
+ return [((B = o.default) == null ? void 0 : B.call(o)) || e.text];
352
356
  },
353
- ...b
357
+ ...v
354
358
  });
355
359
  };
356
360
  }
357
- }), nt = {
361
+ }), ut = {
358
362
  // ===== 配置化 API =====
359
363
  /**
360
364
  * 操作项配置列表
@@ -443,215 +447,266 @@ const H = /* @__PURE__ */ _({
443
447
  default: !1
444
448
  }
445
449
  };
446
- function ot(e) {
450
+ function st(e) {
447
451
  return e ? e.filter(
448
- (n) => n.type !== Ne && n.type !== $e && n.type !== Symbol.for("v-fgt")
452
+ (o) => o.type !== Re && o.type !== Ue && o.type !== Symbol.for("v-fgt")
449
453
  ) : [];
450
454
  }
451
- function pe(e, n) {
452
- var t, o;
455
+ function Se(e, o) {
456
+ var t, i;
453
457
  if (e.key !== null && e.key !== void 0)
454
458
  return typeof e.key == "symbol" ? e.key.toString() : e.key;
455
- if (((t = e.props) == null ? void 0 : t.key) !== null && ((o = e.props) == null ? void 0 : o.key) !== void 0) {
459
+ if (((t = e.props) == null ? void 0 : t.key) !== null && ((i = e.props) == null ? void 0 : i.key) !== void 0) {
456
460
  const l = e.props.key;
457
461
  return typeof l == "symbol" ? l.toString() : l;
458
462
  }
459
- return `button-${n}`;
463
+ return `button-${o}`;
460
464
  }
461
- const me = "link", ye = "small", it = /* @__PURE__ */ _({
465
+ const ne = "link", Be = "small", ct = 150, dt = /* @__PURE__ */ N({
462
466
  name: "MActionGroup",
463
467
  inheritAttrs: !1,
464
468
  __name: "action-group",
465
- props: nt,
469
+ props: ut,
466
470
  emits: ["action-click"],
467
- setup(e, { emit: n }) {
468
- const t = e, o = n, l = Oe(), p = D(), m = D(), y = D(), { width: b } = He(p), F = Q(Z, D(J)), k = c(() => t.mode === "table"), M = c(
469
- () => k.value ? "small" : t.size
470
- ), a = c(
471
- () => k.value ? "link" : "default"
472
- ), s = c(
473
- () => k.value ? "" : t.moreText
474
- ), P = c(() => t.moreIcon || Ue);
475
- function z(i) {
476
- return i ? F.value(i) : !0;
471
+ setup(e, { emit: o }) {
472
+ const t = e, i = o, l = We(), g = M(), m = M(), f = M(), { width: v } = Qe(g), F = ae(ie, M(re));
473
+ function B(n) {
474
+ if (!n) return;
475
+ const c = n;
476
+ return c.name || c.__name || c.displayName;
477
477
  }
478
- const E = c(() => {
479
- var i;
480
- return ot((i = l.default) == null ? void 0 : i.call(l));
481
- }), N = c(() => t.actions ? t.actions.filter((i) => z(i.permission)) : []), $ = c(() => {
482
- if (t.disableCollapse)
483
- return t.actions ? N.value.length : E.value.length;
484
- const i = t.actions ? N.value.length : E.value.length;
485
- return i <= 1 ? i : m.value && y.value && b.value ? Se() : Math.min(t.maxItems, i);
486
- });
487
- function Se() {
488
- if (!m.value || !y.value || !b.value)
489
- return t.maxItems;
490
- const i = y.value.offsetWidth, h = Array.from(
478
+ const D = p(() => t.mode === "table"), a = p(
479
+ () => D.value ? "small" : t.size
480
+ ), u = p(
481
+ () => D.value ? "link" : "default"
482
+ ), A = p(
483
+ () => D.value ? "" : t.moreText
484
+ ), _ = p(() => t.moreIcon || Xe);
485
+ function G(n) {
486
+ return n ? F.value(n) : !0;
487
+ }
488
+ const H = p(() => st(l.default ? l.default() : void 0)), I = Fe([]);
489
+ function le(n) {
490
+ var r, d, b;
491
+ return [
492
+ n.key ?? "",
493
+ n.label ?? "",
494
+ B(n.icon) ?? "",
495
+ B(n.component) ?? "",
496
+ Array.isArray(n.permission) ? n.permission.join(",") : n.permission ?? "",
497
+ n.permissionAction ?? "",
498
+ String(n.disabled ?? !1),
499
+ String(((r = n.componentProps) == null ? void 0 : r.confirm) ?? ""),
500
+ String(((d = n.componentProps) == null ? void 0 : d.showSuccess) ?? ""),
501
+ String(((b = n.componentProps) == null ? void 0 : b.danger) ?? "")
502
+ ].join("|");
503
+ }
504
+ J(
505
+ () => t.actions,
506
+ (n) => {
507
+ if (!n) {
508
+ I.value = [];
509
+ return;
510
+ }
511
+ if (I.value.length !== n.length) {
512
+ I.value = n;
513
+ return;
514
+ }
515
+ const c = n.map(le).join("||"), r = I.value.map(le).join("||");
516
+ c !== r && (I.value = n);
517
+ },
518
+ { immediate: !0, deep: !1 }
519
+ );
520
+ const K = p(() => I.value.length ? I.value.filter((n) => G(n.permission)) : []), T = p(() => t.actions ? K.value.length : H.value.length);
521
+ function _e() {
522
+ if (!m.value || !f.value || !v.value)
523
+ return Math.min(t.maxItems, T.value);
524
+ const n = f.value.offsetWidth, c = Array.from(
491
525
  m.value.querySelectorAll(".measure-item")
492
526
  );
493
- if (h.length === 0) return t.maxItems;
494
- let r = i, d = 0;
495
- for (let C = 0; C < h.length - 1; C++) {
496
- const x = h[C].offsetWidth + t.gap;
497
- if (r + x <= b.value)
498
- r += x, d++;
527
+ if (c.length === 0) return Math.min(t.maxItems, T.value);
528
+ let r = n, d = 0;
529
+ for (let b = 0; b < c.length - 1; b++) {
530
+ const w = c[b].offsetWidth + t.gap;
531
+ if (r + w <= v.value)
532
+ r += w, d++;
499
533
  else
500
534
  break;
501
535
  }
502
- const T = t.actions ? N.value.length : E.value.length;
503
- return Math.max(0, Math.min(d, t.maxItems, T));
536
+ return Math.max(0, Math.min(d, t.maxItems, T.value));
504
537
  }
505
- const Te = c(() => t.actions ? N.value.slice(0, $.value) : []), X = c(() => t.actions ? N.value.slice($.value) : []), Ce = c(() => {
538
+ const L = M(t.maxItems), De = ze(() => {
539
+ L.value = _e();
540
+ }, ct);
541
+ J(
542
+ [v, T, () => t.maxItems, () => t.gap],
543
+ () => {
544
+ if (t.disableCollapse) {
545
+ L.value = T.value;
546
+ return;
547
+ }
548
+ if (T.value <= 1) {
549
+ L.value = T.value;
550
+ return;
551
+ }
552
+ m.value && f.value && v.value ? De() : L.value = Math.min(t.maxItems, T.value);
553
+ },
554
+ { immediate: !0 }
555
+ );
556
+ const O = p(() => t.disableCollapse || T.value <= 1 ? T.value : m.value && f.value && v.value ? L.value : Math.min(t.maxItems, T.value)), Ie = p(() => t.actions ? K.value.slice(0, O.value) : []), ue = p(() => t.actions ? K.value.slice(O.value) : []), we = p(() => {
506
557
  if (t.actions) return [];
507
- const i = E.value;
508
- return $.value >= i.length ? i : i.slice(0, $.value);
509
- }), ee = c(() => {
558
+ const n = H.value;
559
+ return O.value >= n.length ? n : n.slice(0, O.value);
560
+ }), se = p(() => {
510
561
  if (t.actions) return [];
511
- const i = E.value;
512
- return $.value >= i.length ? [] : i.slice($.value);
513
- }), ze = c(() => t.actions ? X.value.filter((i) => z(i.permission)) : []), Ae = c(() => t.actions ? [] : ee.value.filter((i) => {
514
- const h = i.props || {};
515
- return h.permission && h.permissionAction === "hide" ? z(h.permission) : !0;
516
- })), Pe = c(() => t.disableCollapse ? !1 : (t.actions ? X.value.length : ee.value.length) > 0);
517
- function K(i) {
518
- return i.component || H;
562
+ const n = H.value;
563
+ return O.value >= n.length ? [] : n.slice(O.value);
564
+ }), Ee = p(() => t.actions ? [] : se.value.filter((n) => {
565
+ const c = n.props || {};
566
+ return c.permission && c.permissionAction === "hide" ? G(c.permission) : !0;
567
+ })), Ne = p(() => t.disableCollapse ? !1 : (t.actions ? ue.value.length : se.value.length) > 0);
568
+ function X(n) {
569
+ return n.component || Q;
519
570
  }
520
- function te(i, h) {
521
- return i.key || i.label || `action-${h}`;
571
+ function ce(n, c) {
572
+ return n.key || n.label || `action-${c}`;
522
573
  }
523
- function ne(i) {
574
+ function de(n) {
524
575
  const {
525
- label: h,
576
+ label: c,
526
577
  key: r,
527
578
  onClick: d,
528
- permission: T,
529
- permissionAction: C,
530
- icon: L,
531
- component: x,
532
- componentProps: R,
533
- slot: we,
534
- type: U,
535
- size: De,
536
- disabled: Me,
537
- ...Ie
538
- } = i;
579
+ permission: b,
580
+ permissionAction: P,
581
+ icon: w,
582
+ component: $,
583
+ componentProps: V,
584
+ slot: Y,
585
+ type: ee,
586
+ size: q,
587
+ disabled: $e,
588
+ ...je
589
+ } = n;
539
590
  return {
540
- component: x,
541
- componentProps: R,
542
- type: U,
543
- size: De,
544
- rest: Ie,
545
- permission: T,
546
- permissionAction: C,
547
- disabled: Me
591
+ component: $,
592
+ componentProps: V,
593
+ type: ee,
594
+ size: q,
595
+ rest: je,
596
+ permission: b,
597
+ permissionAction: P,
598
+ disabled: $e
548
599
  };
549
600
  }
550
- function oe(i) {
551
- const { component: h, componentProps: r, type: d, rest: T, permission: C, permissionAction: L, disabled: x } = ne(i), R = {
552
- type: d || a.value,
553
- size: M.value,
554
- disabled: x || !z(C) && L === "disable",
555
- ...T
601
+ function fe(n) {
602
+ const { component: c, componentProps: r, type: d, rest: b, permission: P, permissionAction: w, disabled: $ } = de(n), V = {
603
+ type: d || u.value,
604
+ size: a.value,
605
+ disabled: $ || !G(P) && w === "disable",
606
+ ...b
556
607
  };
557
- return h && r ? { ...R, ...r } : R;
608
+ if (c && r) {
609
+ const Y = { ...V, ...r };
610
+ return D.value && (Y.type = "link"), Y;
611
+ }
612
+ return V;
558
613
  }
559
- function xe(i) {
560
- const { component: h, componentProps: r, rest: d, permission: T, permissionAction: C, disabled: L } = ne(i), x = {
561
- type: me,
562
- size: ye,
563
- disabled: L || !z(T) && C === "disable",
614
+ function Oe(n) {
615
+ const { component: c, componentProps: r, rest: d, permission: b, permissionAction: P, disabled: w } = de(n), $ = {
616
+ type: ne,
617
+ size: Be,
618
+ disabled: w || !G(b) && P === "disable",
564
619
  ...d
565
620
  };
566
- if (h && r) {
567
- const { type: R, size: we, ...U } = r;
568
- return { ...x, ...U };
621
+ if (c && r) {
622
+ const { type: V, size: Y, ...ee } = r, q = { ...$, ...ee };
623
+ return q.type = ne, q;
569
624
  }
570
- return x;
625
+ return $;
571
626
  }
572
- function ie(i) {
573
- i.onClick && i.onClick(i), o("action-click", i);
627
+ function pe(n) {
628
+ n.onClick && n.onClick(n), i("action-click", n);
574
629
  }
575
- return (i, h) => (u(), w("div", {
630
+ return (n, c) => (s(), x("div", {
576
631
  ref_key: "containerRef",
577
- ref: p,
632
+ ref: g,
578
633
  class: "mtn-action-group"
579
634
  }, [
580
- v(B(he), S({
581
- size: M.value,
582
- compact: i.compact,
583
- vertical: i.vertical,
584
- block: i.block
585
- }, i.$attrs), {
586
- default: f(() => [
587
- t.actions ? (u(!0), w(I, { key: 0 }, O(Te.value, (r, d) => (u(), g(A(K(r)), S({
588
- key: te(r, d)
589
- }, { ref_for: !0 }, oe(r), {
590
- onClick: (T) => ie(r)
591
- }), j({
592
- default: f(() => [
593
- W(" " + q(r.label), 1)
635
+ h(S(xe), C({
636
+ size: a.value,
637
+ compact: n.compact,
638
+ vertical: n.vertical,
639
+ block: n.block
640
+ }, n.$attrs), {
641
+ default: y(() => [
642
+ t.actions ? (s(!0), x(E, { key: 0 }, j(Ie.value, (r, d) => (s(), k(z(X(r)), C({
643
+ key: ce(r, d)
644
+ }, { ref_for: !0 }, fe(r), {
645
+ onClick: (b) => pe(r)
646
+ }), U({
647
+ default: y(() => [
648
+ W(" " + te(r.label), 1)
594
649
  ]),
595
650
  _: 2
596
651
  }, [
597
- r.icon && !r.component ? {
652
+ r.icon ? {
598
653
  name: "icon",
599
- fn: f(() => [
600
- (u(), g(A(r.icon)))
654
+ fn: y(() => [
655
+ (s(), k(z(r.icon)))
601
656
  ]),
602
657
  key: "0"
603
658
  } : void 0
604
- ]), 1040, ["onClick"]))), 128)) : (u(!0), w(I, { key: 1 }, O(Ce.value, (r, d) => {
605
- var T, C;
606
- return u(), g(A(ae(r, {
607
- type: ((T = r.props) == null ? void 0 : T.type) ?? (k.value ? a.value : void 0),
608
- size: ((C = r.props) == null ? void 0 : C.size) ?? M.value
659
+ ]), 1040, ["onClick"]))), 128)) : (s(!0), x(E, { key: 1 }, j(we.value, (r, d) => {
660
+ var b, P;
661
+ return s(), k(z(ye(r, {
662
+ type: ((b = r.props) == null ? void 0 : b.type) ?? (D.value ? u.value : void 0),
663
+ size: ((P = r.props) == null ? void 0 : P.size) ?? a.value
609
664
  })), {
610
- key: B(pe)(r, d)
665
+ key: S(Se)(r, d)
611
666
  });
612
667
  }), 128)),
613
- Pe.value ? (u(), g(B(Y), S({
668
+ Ne.value ? (s(), k(S(oe), C({
614
669
  key: 2,
615
- text: s.value,
616
- size: M.value,
617
- type: a.value
670
+ text: A.value,
671
+ size: a.value,
672
+ type: u.value
618
673
  }, t.moreProps), {
619
- icon: f(() => [
620
- (u(), g(A(P.value)))
674
+ icon: y(() => [
675
+ (s(), k(z(_.value)))
621
676
  ]),
622
- overlay: f(() => [
623
- v(B(G), null, {
624
- default: f(() => [
625
- t.actions ? (u(!0), w(I, { key: 0 }, O(ze.value, (r, d) => (u(), g(B(G).Item, {
626
- key: te(r, d)
677
+ overlay: y(() => [
678
+ h(S(Z), null, {
679
+ default: y(() => [
680
+ t.actions ? (s(!0), x(E, { key: 0 }, j(ue.value, (r, d) => (s(), k(S(Z).Item, {
681
+ key: ce(r, d)
627
682
  }, {
628
- default: f(() => [
629
- (u(), g(A(K(r)), S({ ref_for: !0 }, xe(r), {
630
- onClick: (T) => ie(r)
631
- }), j({
632
- default: f(() => [
633
- W(" " + q(r.label), 1)
683
+ default: y(() => [
684
+ (s(), k(z(X(r)), C({ ref_for: !0 }, Oe(r), {
685
+ onClick: (b) => pe(r)
686
+ }), U({
687
+ default: y(() => [
688
+ W(" " + te(r.label), 1)
634
689
  ]),
635
690
  _: 2
636
691
  }, [
637
- r.icon && !r.component ? {
692
+ r.icon ? {
638
693
  name: "icon",
639
- fn: f(() => [
640
- (u(), g(A(r.icon)))
694
+ fn: y(() => [
695
+ (s(), k(z(r.icon)))
641
696
  ]),
642
697
  key: "0"
643
698
  } : void 0
644
699
  ]), 1040, ["onClick"]))
645
700
  ]),
646
701
  _: 2
647
- }, 1024))), 128)) : (u(!0), w(I, { key: 1 }, O(Ae.value, (r, d) => (u(), g(B(G).Item, {
648
- key: B(pe)(r, d)
702
+ }, 1024))), 128)) : (s(!0), x(E, { key: 1 }, j(Ee.value, (r, d) => (s(), k(S(Z).Item, {
703
+ key: S(Se)(r, d)
649
704
  }, {
650
- default: f(() => [
651
- (u(), g(A(ae(r, {
705
+ default: y(() => [
706
+ (s(), k(z(ye(r, {
652
707
  ...r.props,
653
- type: me,
654
- size: ye
708
+ type: ne,
709
+ size: Be
655
710
  }))))
656
711
  ]),
657
712
  _: 2
@@ -661,51 +716,51 @@ const me = "link", ye = "small", it = /* @__PURE__ */ _({
661
716
  })
662
717
  ]),
663
718
  _: 1
664
- }, 16, ["text", "size", "type"])) : Le("", !0)
719
+ }, 16, ["text", "size", "type"])) : Ge("", !0)
665
720
  ]),
666
721
  _: 1
667
722
  }, 16, ["size", "compact", "vertical", "block"]),
668
- re("div", {
723
+ me("div", {
669
724
  ref_key: "measureRef",
670
725
  ref: m,
671
726
  class: "mtn-action-group-measure"
672
727
  }, [
673
- t.actions ? (u(!0), w(I, { key: 0 }, O(N.value, (r, d) => (u(), w("span", {
728
+ t.actions ? (s(!0), x(E, { key: 0 }, j(K.value, (r, d) => (s(), x("span", {
674
729
  key: d,
675
730
  class: "measure-item"
676
731
  }, [
677
- (u(), g(A(K(r)), S({ ref_for: !0 }, oe(r)), j({
678
- default: f(() => [
679
- W(" " + q(r.label), 1)
732
+ (s(), k(z(X(r)), C({ ref_for: !0 }, fe(r)), U({
733
+ default: y(() => [
734
+ W(" " + te(r.label), 1)
680
735
  ]),
681
736
  _: 2
682
737
  }, [
683
- r.icon && !r.component ? {
738
+ r.icon ? {
684
739
  name: "icon",
685
- fn: f(() => [
686
- (u(), g(A(r.icon)))
740
+ fn: y(() => [
741
+ (s(), k(z(r.icon)))
687
742
  ]),
688
743
  key: "0"
689
744
  } : void 0
690
745
  ]), 1040))
691
- ]))), 128)) : (u(!0), w(I, { key: 1 }, O(E.value, (r, d) => (u(), w("span", {
746
+ ]))), 128)) : (s(!0), x(E, { key: 1 }, j(H.value, (r, d) => (s(), x("span", {
692
747
  key: d,
693
748
  class: "measure-item"
694
749
  }, [
695
- (u(), g(A(r)))
750
+ (s(), k(z(r)))
696
751
  ]))), 128)),
697
- re("span", {
752
+ me("span", {
698
753
  ref_key: "moreTriggerRef",
699
- ref: y,
754
+ ref: f,
700
755
  class: "measure-item"
701
756
  }, [
702
- v(B(Y), {
703
- text: s.value,
704
- size: M.value,
705
- type: a.value
757
+ h(S(oe), {
758
+ text: A.value,
759
+ size: a.value,
760
+ type: u.value
706
761
  }, {
707
- icon: f(() => [
708
- (u(), g(A(P.value)))
762
+ icon: y(() => [
763
+ (s(), k(z(_.value)))
709
764
  ]),
710
765
  _: 1
711
766
  }, 8, ["text", "size", "type"])
@@ -713,14 +768,14 @@ const me = "link", ye = "small", it = /* @__PURE__ */ _({
713
768
  ], 512)
714
769
  ], 512));
715
770
  }
716
- }), Be = (e, n) => {
771
+ }), Me = (e, o) => {
717
772
  const t = e.__vccOpts || e;
718
- for (const [o, l] of n)
719
- t[o] = l;
773
+ for (const [i, l] of o)
774
+ t[i] = l;
720
775
  return t;
721
- }, rt = /* @__PURE__ */ Be(it, [["__scopeId", "data-v-b8d47218"]]), at = {
776
+ }, ft = /* @__PURE__ */ Me(dt, [["__scopeId", "data-v-845c43ad"]]), pt = {
722
777
  // 继承 Button 的所有 props
723
- ...be,
778
+ ...Ae,
724
779
  // 覆盖 loading prop,使其默认值为 undefined,以便自动 loading 功能正常工作
725
780
  loading: {
726
781
  type: Boolean,
@@ -796,106 +851,106 @@ const me = "link", ye = "small", it = /* @__PURE__ */ _({
796
851
  type: Function,
797
852
  default: void 0
798
853
  }
799
- }, lt = /* @__PURE__ */ _({
854
+ }, mt = /* @__PURE__ */ N({
800
855
  name: "MDeleteButton",
801
856
  inheritAttrs: !1,
802
857
  __name: "delete-button",
803
- props: at,
858
+ props: pt,
804
859
  emits: ["delete", "success", "error"],
805
- setup(e, { emit: n }) {
806
- const t = n, o = e, l = D(!1), p = D(null), m = c(() => o.loading !== void 0 ? o.loading : o.autoLoading ? l.value : !1), y = c(() => typeof o.confirm == "function" ? o.confirm(o.count) : o.confirm);
807
- le(m, (a) => {
808
- p.value && ue(() => {
809
- var s;
810
- (s = p.value) == null || s.update({
860
+ setup(e, { emit: o }) {
861
+ const t = o, i = e, l = M(!1), g = M(null), m = p(() => i.loading !== void 0 ? i.loading : i.autoLoading ? l.value : !1), f = p(() => typeof i.confirm == "function" ? i.confirm(i.count) : i.confirm);
862
+ J(m, (a) => {
863
+ g.value && ge(() => {
864
+ var u;
865
+ (u = g.value) == null || u.update({
811
866
  okButtonProps: { loading: a }
812
867
  });
813
868
  });
814
- }, { flush: "post" }), Re(() => {
815
- p.value && (p.value.destroy(), p.value = null);
869
+ }, { flush: "post" }), He(() => {
870
+ g.value && (g.value.destroy(), g.value = null);
816
871
  });
817
- const b = async () => {
872
+ const v = async () => {
818
873
  try {
819
- if (o.beforeDelete && await o.beforeDelete() === !1)
874
+ if (i.beforeDelete && await i.beforeDelete() === !1)
820
875
  return;
821
- o.autoLoading && o.loading === void 0 && (l.value = !0);
876
+ i.autoLoading && i.loading === void 0 && (l.value = !0);
822
877
  let a = !1;
823
- const s = () => {
824
- a || (a = !0, o.autoLoading && o.loading === void 0 && (l.value = !1));
878
+ const u = () => {
879
+ a || (a = !0, i.autoLoading && i.loading === void 0 && (l.value = !1));
825
880
  };
826
- if (o.onDelete) {
827
- const P = o.onDelete(s);
828
- if (P && typeof P.then == "function")
881
+ if (i.onDelete) {
882
+ const A = i.onDelete(u);
883
+ if (A && typeof A.then == "function")
829
884
  try {
830
- const z = await P;
831
- a || s(), F(z);
832
- } catch (z) {
833
- throw a || s(), z;
885
+ const _ = await A;
886
+ a || u(), F(_);
887
+ } catch (_) {
888
+ throw a || u(), _;
834
889
  }
835
890
  } else
836
- t("delete", s), o.autoLoading && o.loading === void 0 && setTimeout(() => {
837
- a || s();
891
+ t("delete", u), i.autoLoading && i.loading === void 0 && setTimeout(() => {
892
+ a || u();
838
893
  }, 5e3);
839
894
  } catch (a) {
840
- o.autoLoading && o.loading === void 0 && (l.value = !1);
841
- const s = a instanceof Error ? a : new Error(String(a));
842
- t("error", s), o.showError && de.error(s.message || "删除失败,请重试");
895
+ i.autoLoading && i.loading === void 0 && (l.value = !1);
896
+ const u = a instanceof Error ? a : new Error(String(a));
897
+ t("error", u), i.showError && ke.error(u.message || "删除失败,请重试");
843
898
  }
844
899
  }, F = (a) => {
845
- o.showSuccess && de.success(o.successText || "删除成功"), t("success", a);
846
- }, k = o.debounce > 0 ? Ke(b, o.debounce) : b, M = () => {
847
- if (!y.value) {
848
- k();
900
+ i.showSuccess && ke.success(i.successText || "删除成功"), t("success", a);
901
+ }, B = i.debounce > 0 ? ze(v, i.debounce) : v, D = () => {
902
+ if (!f.value) {
903
+ B();
849
904
  return;
850
905
  }
851
- if (o.confirmType === "popconfirm") return;
852
- ue(() => {
853
- p.value = Fe.confirm({
854
- title: o.confirmTitle,
855
- content: y.value,
856
- okText: o.okText,
857
- cancelText: o.cancelText,
906
+ if (i.confirmType === "popconfirm") return;
907
+ ge(() => {
908
+ g.value = Ze.confirm({
909
+ title: i.confirmTitle,
910
+ content: f.value,
911
+ okText: i.okText,
912
+ cancelText: i.cancelText,
858
913
  okType: "danger",
859
914
  okButtonProps: { loading: m.value },
860
915
  onOk: async () => {
861
916
  try {
862
- return await b(), new Promise((s) => {
917
+ return await v(), new Promise((u) => {
863
918
  if (!m.value) {
864
- s();
919
+ u();
865
920
  return;
866
921
  }
867
- const P = le(m, (z) => {
868
- z || (P(), s());
922
+ const A = J(m, (_) => {
923
+ _ || (A(), u());
869
924
  });
870
925
  });
871
- } catch (s) {
872
- throw s;
926
+ } catch (u) {
927
+ throw u;
873
928
  }
874
929
  },
875
930
  onCancel: () => {
876
- p.value = null;
931
+ g.value = null;
877
932
  },
878
933
  afterClose: () => {
879
- p.value = null;
934
+ g.value = null;
880
935
  }
881
936
  });
882
937
  });
883
938
  };
884
- return (a, s) => y.value && a.confirmType === "popconfirm" ? (u(), g(B(We), {
939
+ return (a, u) => f.value && a.confirmType === "popconfirm" ? (s(), k(S(qe), {
885
940
  key: 0,
886
- title: y.value,
941
+ title: f.value,
887
942
  "ok-text": a.okText,
888
943
  "cancel-text": a.cancelText,
889
944
  "ok-button-props": { loading: m.value, danger: !0 },
890
- onConfirm: B(k)
945
+ onConfirm: S(B)
891
946
  }, {
892
- icon: f(() => [
893
- V(a.$slots, "popconfirmIcon", {}, () => [
894
- v(B(qe), { class: "text-[--color-ant-error]" })
947
+ icon: y(() => [
948
+ R(a.$slots, "popconfirmIcon", {}, () => [
949
+ h(S(et), { class: "text-[--color-ant-error]" })
895
950
  ], !0)
896
951
  ]),
897
- default: f(() => [
898
- v(B(H), S(a.$attrs, {
952
+ default: y(() => [
953
+ h(S(Q), C(a.$attrs, {
899
954
  type: a.type,
900
955
  size: a.size,
901
956
  danger: !0,
@@ -904,19 +959,19 @@ const me = "link", ye = "small", it = /* @__PURE__ */ _({
904
959
  permission: a.permission,
905
960
  "permission-action": a.permissionAction,
906
961
  class: "group"
907
- }), j({
908
- default: f(() => [
909
- V(a.$slots, "default", {}, () => [
910
- s[0] || (s[0] = W("删除", -1))
962
+ }), U({
963
+ default: y(() => [
964
+ R(a.$slots, "default", {}, () => [
965
+ u[0] || (u[0] = W("删除", -1))
911
966
  ], !0)
912
967
  ]),
913
968
  _: 2
914
969
  }, [
915
970
  a.hideIcon ? void 0 : {
916
971
  name: "icon",
917
- fn: f(() => [
918
- V(a.$slots, "icon", {}, () => [
919
- v(B(fe))
972
+ fn: y(() => [
973
+ R(a.$slots, "icon", {}, () => [
974
+ h(S(he))
920
975
  ], !0)
921
976
  ]),
922
977
  key: "0"
@@ -924,7 +979,7 @@ const me = "link", ye = "small", it = /* @__PURE__ */ _({
924
979
  ]), 1040, ["type", "size", "loading", "disabled", "permission", "permission-action"])
925
980
  ]),
926
981
  _: 3
927
- }, 8, ["title", "ok-text", "cancel-text", "ok-button-props", "onConfirm"])) : (u(), g(B(H), S({ key: 1 }, a.$attrs, {
982
+ }, 8, ["title", "ok-text", "cancel-text", "ok-button-props", "onConfirm"])) : (s(), k(S(Q), C({ key: 1 }, a.$attrs, {
928
983
  type: a.type,
929
984
  size: a.size,
930
985
  danger: !0,
@@ -932,27 +987,27 @@ const me = "link", ye = "small", it = /* @__PURE__ */ _({
932
987
  disabled: a.disabled,
933
988
  permission: a.permission,
934
989
  "permission-action": a.permissionAction,
935
- onClick: M
936
- }), j({
937
- default: f(() => [
938
- V(a.$slots, "default", {}, () => [
939
- s[1] || (s[1] = W("删除", -1))
990
+ onClick: D
991
+ }), U({
992
+ default: y(() => [
993
+ R(a.$slots, "default", {}, () => [
994
+ u[1] || (u[1] = W("删除", -1))
940
995
  ], !0)
941
996
  ]),
942
997
  _: 2
943
998
  }, [
944
999
  a.hideIcon ? void 0 : {
945
1000
  name: "icon",
946
- fn: f(() => [
947
- V(a.$slots, "icon", {}, () => [
948
- v(B(fe))
1001
+ fn: y(() => [
1002
+ R(a.$slots, "icon", {}, () => [
1003
+ h(S(he))
949
1004
  ], !0)
950
1005
  ]),
951
1006
  key: "0"
952
1007
  }
953
1008
  ]), 1040, ["type", "size", "loading", "disabled", "permission", "permission-action"]));
954
1009
  }
955
- }), ut = /* @__PURE__ */ Be(lt, [["__scopeId", "data-v-a943bc19"]]), st = {
1010
+ }), yt = /* @__PURE__ */ Me(mt, [["__scopeId", "data-v-a943bc19"]]), gt = {
956
1011
  // 继承 antd 的所有 props
957
1012
  columns: {
958
1013
  type: Array,
@@ -984,39 +1039,39 @@ const me = "link", ye = "small", it = /* @__PURE__ */ _({
984
1039
  }
985
1040
  // 可以添加更多自定义 props
986
1041
  };
987
- function ct(e) {
988
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !Ve(e);
1042
+ function vt(e) {
1043
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !Ke(e);
989
1044
  }
990
- const dt = /* @__PURE__ */ _({
1045
+ const bt = /* @__PURE__ */ N({
991
1046
  name: "MTable",
992
- props: st,
1047
+ props: gt,
993
1048
  setup(e, {
994
- slots: n,
1049
+ slots: o,
995
1050
  attrs: t
996
1051
  }) {
997
- return () => v(Ge, S(e, t, {
1052
+ return () => h(Je, C(e, t, {
998
1053
  class: "mtn-table"
999
- }), ct(n) ? n : {
1000
- default: () => [n]
1054
+ }), vt(o) ? o : {
1055
+ default: () => [o]
1001
1056
  });
1002
1057
  }
1003
- }), ft = ge(dt), pt = [H, he, Y, rt, ut, Qe, ft], ht = {
1058
+ }), kt = Ce(bt), ht = [Q, xe, oe, ft, yt, it, kt], Pt = {
1004
1059
  install(e) {
1005
- pt.forEach((n) => {
1006
- e.component(n.name || "", n);
1060
+ ht.forEach((o) => {
1061
+ e.component(o.name || "", o);
1007
1062
  });
1008
1063
  }
1009
1064
  };
1010
1065
  export {
1011
- rt as ActionGroup,
1012
- H as Button,
1013
- he as ButtonGroup,
1014
- ut as DeleteButton,
1015
- Y as DropdownButton,
1016
- ft as Table,
1017
- Qe as Tag,
1018
- et as buttonGroupProps,
1019
- ht as default,
1020
- st as tableProps,
1021
- Ye as tagProps
1066
+ ft as ActionGroup,
1067
+ Q as Button,
1068
+ xe as ButtonGroup,
1069
+ yt as DeleteButton,
1070
+ oe as DropdownButton,
1071
+ kt as Table,
1072
+ it as Tag,
1073
+ at as buttonGroupProps,
1074
+ Pt as default,
1075
+ gt as tableProps,
1076
+ tt as tagProps
1022
1077
  };