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