@me-framework/me-ui-antdv-next 0.0.29 → 0.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,107 @@
1
1
  import e from "../icon/index.js";
2
- import { computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, nextTick as l, onMounted as u, openBlock as d, reactive as f, ref as p, resolveComponent as m, unref as h, watch as g, withCtx as _ } from "vue";
3
- import { useDraggable as v } from "vue-draggable-plus";
2
+ import t from "../modal/index.js";
3
+ import { Fragment as n, computed as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, nextTick as d, normalizeClass as f, onMounted as p, openBlock as m, reactive as h, ref as g, resolveComponent as _, unref as v, watch as y, withCtx as b } from "vue";
4
+ import { useDraggable as x } from "vue-draggable-plus";
5
+ import S from "dayjs";
6
+ //#region src/components/input-property/types.ts
7
+ var C = [
8
+ {
9
+ label: "字符串",
10
+ value: "string"
11
+ },
12
+ {
13
+ label: "整数",
14
+ value: "int"
15
+ },
16
+ {
17
+ label: "浮点数",
18
+ value: "float"
19
+ },
20
+ {
21
+ label: "布尔",
22
+ value: "boolean"
23
+ },
24
+ {
25
+ label: "日期",
26
+ value: "date"
27
+ },
28
+ {
29
+ label: "时间",
30
+ value: "time"
31
+ }
32
+ ], w = 2, T = "YYYY-MM-DD", E = "HH:mm:ss", ee = [{
33
+ label: "是",
34
+ value: !0
35
+ }, {
36
+ label: "否",
37
+ value: !1
38
+ }];
39
+ //#endregion
4
40
  //#region src/components/input-property/validate.ts
5
- function y() {
41
+ function D() {
6
42
  return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
7
43
  }
8
- function b(e) {
44
+ var O = /^\d{4}-\d{2}-\d{2}$/, k = /^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/;
45
+ function A(e) {
46
+ return Math.round((e + 2 ** -52) * 100) / 100;
47
+ }
48
+ function j(e) {
49
+ if (typeof e == "number") return Number.isInteger(e) ? "int" : "float";
50
+ if (typeof e == "boolean") return "boolean";
51
+ if (typeof e == "string") {
52
+ if (O.test(e)) return "date";
53
+ if (k.test(e)) return "time";
54
+ }
55
+ return "string";
56
+ }
57
+ function M(e, t) {
58
+ return t === "string" ? e == null ? "" : String(e) : t === "boolean" ? P(e) : t === "int" || t === "float" ? N(e, t === "float") : re(e, t === "date" ? T : E);
59
+ }
60
+ function N(e, t) {
61
+ if (e == null) return "";
62
+ let n = (e) => t ? A(e) : e;
63
+ if (typeof e == "number") return n(e);
64
+ let r = String(e).trim();
65
+ if (r === "") return "";
66
+ let i = Number(r);
67
+ return Number.isNaN(i) ? e : n(i);
68
+ }
69
+ function te(e, t) {
70
+ if (t === "string") return e;
71
+ if (t === "boolean") return P(e);
72
+ if (t === "int" || t === "float") return ne(e, t === "float");
73
+ let n = t === "date" ? T : E;
74
+ return e == null || e === "" ? "" : S.isDayjs(e) ? e.format(n) : typeof e == "string" ? e : "";
75
+ }
76
+ function ne(e, t) {
77
+ if (e == null) return e;
78
+ let n = (e) => t ? A(e) : e;
79
+ if (typeof e == "number") return n(e);
80
+ let r = String(e).trim();
81
+ if (r === "") return "";
82
+ let i = Number(r);
83
+ return Number.isNaN(i) ? e : n(i);
84
+ }
85
+ function P(e) {
86
+ if (typeof e == "boolean") return e;
87
+ if (e == null || e === "") return !1;
88
+ if (typeof e == "number") return e !== 0;
89
+ let t = String(e).trim().toLowerCase();
90
+ return t === "true" || t === "1" || t === "yes" || t === "on";
91
+ }
92
+ function re(e, t) {
93
+ if (e == null || e === "") return "";
94
+ if (S.isDayjs(e)) return e.format(t);
95
+ let n = S(e);
96
+ return n.isValid() ? n.format(t) : e;
97
+ }
98
+ function F(e) {
9
99
  return e.trim().toLowerCase();
10
100
  }
11
- function x(e) {
101
+ function ie(e) {
12
102
  let t = /* @__PURE__ */ new Map(), n = [];
13
103
  for (let r of e) {
14
- let e = b(r.key);
104
+ let e = F(r.key);
15
105
  if (e) {
16
106
  if (t.has(e)) {
17
107
  let i = t.get(e);
@@ -23,21 +113,114 @@ function x(e) {
23
113
  }
24
114
  return n;
25
115
  }
26
- function S(e, t) {
116
+ function ae(e, t) {
27
117
  if (!e) return !1;
28
- let n = b(e);
29
- return t.some((e) => b(e) === n);
118
+ let n = F(e);
119
+ return t.some((e) => F(e) === n);
120
+ }
121
+ var oe = {
122
+ minLength: ["string"],
123
+ maxLength: ["string"],
124
+ pattern: ["string"],
125
+ min: [
126
+ "int",
127
+ "float",
128
+ "date",
129
+ "time"
130
+ ],
131
+ max: [
132
+ "int",
133
+ "float",
134
+ "date",
135
+ "time"
136
+ ]
137
+ }, I = ["required", "message"];
138
+ function L(e, t) {
139
+ if (I.includes(e)) return !0;
140
+ let n = oe[e];
141
+ return n ? n.includes(t) : !1;
142
+ }
143
+ function R(e) {
144
+ return typeof e == "number" && Number.isFinite(e);
145
+ }
146
+ function z(e) {
147
+ if (!e) return;
148
+ let t = {};
149
+ return e.required === !0 && (t.required = !0), R(e.minLength) && (t.minLength = e.minLength), R(e.maxLength) && (t.maxLength = e.maxLength), typeof e.pattern == "string" && e.pattern.trim() !== "" && (t.pattern = e.pattern), (R(e.min) || typeof e.min == "string" && e.min.trim() !== "") && (t.min = e.min), (R(e.max) || typeof e.max == "string" && e.max.trim() !== "") && (t.max = e.max), typeof e.message == "string" && e.message.trim() !== "" && (t.message = e.message), Object.keys(t).length > 0 ? t : void 0;
150
+ }
151
+ function se(e, t) {
152
+ if (!e) return;
153
+ let n = {};
154
+ return e.required === !0 && (n.required = !0), typeof e.message == "string" && e.message.trim() !== "" && (n.message = e.message), t === "string" ? (R(e.minLength) && (n.minLength = e.minLength), R(e.maxLength) && (n.maxLength = e.maxLength), typeof e.pattern == "string" && e.pattern.trim() !== "" && (n.pattern = e.pattern)) : (t === "int" || t === "float" || t === "date" || t === "time") && ((R(e.min) || typeof e.min == "string" && e.min.trim() !== "") && (n.min = e.min), (R(e.max) || typeof e.max == "string" && e.max.trim() !== "") && (n.max = e.max)), z(n);
155
+ }
156
+ function B(e, t) {
157
+ return typeof e.message == "string" && e.message.trim() !== "" ? e.message : t;
158
+ }
159
+ function V(e, t, n) {
160
+ let r = z(n);
161
+ if (!r) return null;
162
+ let i = e === "" || e == null;
163
+ if (r.required && i) return B(r, "不能为空");
164
+ if (t === "string") {
165
+ if (typeof e != "string" || i) return null;
166
+ if (r.minLength != null && e.length < r.minLength) return B(r, `最短长度不能小于 ${r.minLength}`);
167
+ if (r.maxLength != null && e.length > r.maxLength) return B(r, `最大长度不能大于 ${r.maxLength}`);
168
+ if (r.pattern) {
169
+ let t = null;
170
+ try {
171
+ t = new RegExp(r.pattern);
172
+ } catch {}
173
+ if (t && !t.test(e)) return B(r, "格式不正确");
174
+ }
175
+ }
176
+ if (t === "int" || t === "float") {
177
+ if (i) return null;
178
+ let t = Number(e);
179
+ if (Number.isNaN(t)) return null;
180
+ if (r.min != null && t < Number(r.min)) return B(r, `不能小于 ${r.min}`);
181
+ if (r.max != null && t > Number(r.max)) return B(r, `不能大于 ${r.max}`);
182
+ }
183
+ if (t === "date" || t === "time") {
184
+ if (i) return null;
185
+ let t = String(e);
186
+ if (r.min != null && t < String(r.min)) return B(r, `不能早于 ${r.min}`);
187
+ if (r.max != null && t > String(r.max)) return B(r, `不能晚于 ${r.max}`);
188
+ }
189
+ return null;
190
+ }
191
+ function ce(e) {
192
+ let t = {};
193
+ for (let n of e) {
194
+ let e = n.key.trim();
195
+ if (!e) continue;
196
+ let r = z(n.rules);
197
+ r && (t[e] = r);
198
+ }
199
+ return t;
200
+ }
201
+ function H(e, t, n) {
202
+ return V(e, t, n);
203
+ }
204
+ function le(e) {
205
+ let t = {};
206
+ for (let n of e) {
207
+ let e = n.key.trim();
208
+ if (!e) continue;
209
+ let r = H(n.value, n.type, n.rules);
210
+ r && (t[e] = r);
211
+ }
212
+ return t;
30
213
  }
31
214
  //#endregion
32
215
  //#region src/components/input-property/index.vue?vue&type=script&setup=true&lang.ts
33
- var C = { class: "me-input-property__toolbar" }, w = {
216
+ var ue = { class: "me-input-property__toolbar" }, de = {
34
217
  key: 0,
35
218
  class: "me-input-property__actions"
36
- }, T = {
219
+ }, fe = {
37
220
  key: 0,
38
221
  class: "me-input-property__drag",
39
222
  title: "拖拽排序"
40
- }, E = /* @__PURE__ */ c({
223
+ }, U = /* @__PURE__ */ u({
41
224
  name: "MeInputProperty",
42
225
  __name: "index",
43
226
  props: {
@@ -51,197 +234,413 @@ var C = { class: "me-input-property__toolbar" }, w = {
51
234
  type: Boolean,
52
235
  default: !0
53
236
  },
237
+ showType: {
238
+ type: Boolean,
239
+ default: !0
240
+ },
241
+ showRules: {
242
+ type: Boolean,
243
+ default: !0
244
+ },
245
+ validate: {
246
+ type: Boolean,
247
+ default: !1
248
+ },
54
249
  keyPlaceholder: { default: "请输入 key" },
55
250
  valuePlaceholder: { default: "请输入 value" },
56
- emptyText: { default: "暂无属性,点击「新增属性」添加" }
251
+ emptyText: { default: "暂无属性,点击「新增属性」添加" },
252
+ rules: {}
57
253
  },
58
254
  emits: ["update:modelValue", "change"],
59
- setup(c, { emit: b }) {
60
- let E = c, D = b, O = p([]), k = p([]), A = !1, j = t(() => [
61
- {
62
- title: "Key",
255
+ setup(u, { emit: S }) {
256
+ let w = u, O = S, k = g([]), A = g([]), N = !1, ne = r(() => {
257
+ let e = [{
258
+ title: "属性",
63
259
  key: "key",
64
260
  dataIndex: "key",
65
261
  width: 180
66
- },
67
- {
68
- title: "Value",
262
+ }, {
263
+ title: "值",
69
264
  key: "value",
70
265
  dataIndex: "value"
71
- },
72
- {
266
+ }];
267
+ return w.showRules && e.push({
268
+ title: "校验",
269
+ key: "rules",
270
+ dataIndex: "rules",
271
+ width: 48,
272
+ align: "center"
273
+ }), e.push({
73
274
  title: "操作",
74
275
  key: "action",
75
276
  dataIndex: "action",
76
277
  width: 72,
77
278
  align: "center"
279
+ }), e;
280
+ }), P = r(() => w.draggable && !w.disabled);
281
+ function re(e) {
282
+ let t = /* @__PURE__ */ new Map();
283
+ for (let e of k.value) {
284
+ let n = e.key.trim();
285
+ n && t.set(n, e);
78
286
  }
79
- ]), M = t(() => E.draggable && !E.disabled);
80
- function N(e) {
81
- O.value = Object.entries(e).map(([e, t]) => ({
82
- id: y(),
83
- key: e,
84
- value: t
85
- })), z();
287
+ k.value = Object.entries(e).map(([e, n]) => {
288
+ let r = t.get(e.trim());
289
+ return {
290
+ id: D(),
291
+ key: e,
292
+ type: j(n),
293
+ value: n,
294
+ rules: r?.rules ?? w.rules?.[e.trim()]
295
+ };
296
+ }), U();
86
297
  }
87
- function P() {
298
+ function F() {
88
299
  let e = {};
89
- for (let t of O.value) {
300
+ for (let t of k.value) {
90
301
  let n = t.key.trim();
91
- n && (e[n] = t.value);
302
+ n && (e[n] = te(t.value, t.type));
92
303
  }
93
- A = !0, D("update:modelValue", e), D("change", e);
304
+ N = !0, O("update:modelValue", e);
305
+ let t = w.validate ? {
306
+ duplicatedKeys: A.value,
307
+ hasEmptyKey: k.value.some((e) => !e.key.trim()),
308
+ rowRules: ce(k.value),
309
+ valueErrors: le(k.value)
310
+ } : {
311
+ duplicatedKeys: [],
312
+ hasEmptyKey: !1,
313
+ rowRules: {},
314
+ valueErrors: {}
315
+ };
316
+ O("change", e, t);
94
317
  }
95
- g(() => E.modelValue, (e) => {
318
+ y(() => w.modelValue, (e) => {
96
319
  if (e) {
97
- if (A) {
98
- A = !1;
320
+ if (N) {
321
+ N = !1;
99
322
  return;
100
323
  }
101
- N(e);
324
+ re(e);
102
325
  }
103
326
  }, { immediate: !0 });
104
- function F(e) {
105
- z(), P();
327
+ function oe(e) {
328
+ U(), F();
106
329
  }
107
330
  function I(e) {
108
- z(), P();
331
+ U(), F();
109
332
  }
110
- function L() {
111
- O.value = [...O.value, {
112
- id: y(),
333
+ function L(e, t) {
334
+ e.type !== t && (e.type = t, e.value = M(e.value, t), e.rules = se(e.rules, t), U(), F());
335
+ }
336
+ function R(e, t) {
337
+ e.value = t, U(), F();
338
+ }
339
+ function B() {
340
+ k.value = [...k.value, {
341
+ id: D(),
113
342
  key: "",
343
+ type: "string",
114
344
  value: ""
115
- }], z(), P();
345
+ }], U(), F();
116
346
  }
117
- function R(e) {
118
- let t = O.value.indexOf(e);
119
- t !== -1 && (O.value.splice(t, 1), z(), P());
347
+ function V(e) {
348
+ let t = k.value.indexOf(e);
349
+ t !== -1 && (k.value.splice(t, 1), U(), F());
120
350
  }
121
- function z() {
122
- k.value = x(O.value);
351
+ function U() {
352
+ A.value = ie(k.value);
123
353
  }
124
- function B(e) {
125
- return S(e, k.value);
354
+ function W(e) {
355
+ return ae(e, A.value);
126
356
  }
127
- function V(e) {
128
- return B(e) ? "Key 不能重复(忽略大小写)" : "";
357
+ function pe(e) {
358
+ return w.validate ? e.trim() ? W(e) ? "Key 不能重复(忽略大小写)" : "" : "Key 不能为空" : "";
359
+ }
360
+ function me(e) {
361
+ return w.validate ? !e.key.trim() || W(e.key) : !1;
362
+ }
363
+ function G(e) {
364
+ return w.disabled || !w.validate ? "" : H(e.value, e.type, e.rules) ?? "";
365
+ }
366
+ function he(e) {
367
+ return !!z(e.rules);
368
+ }
369
+ let K = g(!1), q = g(null), ge = g(), J = h({}), Y = r(() => q.value?.type ?? "string"), _e = Object.fromEntries(C.map((e) => [e.value, e.label])), ve = r(() => {
370
+ let e = q.value;
371
+ return e ? `校验规则${e.key.trim() ? ` · ${e.key.trim()}` : ""}(${_e[e.type] ?? e.type})` : "校验规则";
372
+ });
373
+ function ye(e) {
374
+ return e === "int" || e === "float";
375
+ }
376
+ function be(e) {
377
+ q.value = e, Object.keys(J).forEach((e) => delete J[e]), Object.assign(J, z(e.rules) ?? {}), K.value = !0;
378
+ }
379
+ function xe() {
380
+ q.value && ge.value?.validate().then(() => {
381
+ q.value && (q.value.rules = z(J), K.value = !1, q.value = null, U(), F());
382
+ }).catch(() => {});
383
+ }
384
+ function Se() {
385
+ K.value = !1, q.value = null;
386
+ }
387
+ function Ce(e, t) {
388
+ return typeof e == "string" && typeof t == "string" ? e < t ? -1 : +(e > t) : Number(e) - Number(t);
129
389
  }
130
- let H = p(null), U = p(null);
131
- function W() {
132
- U.value ||= H.value?.querySelector("tbody") ?? null;
390
+ let we = r(() => {
391
+ let e = J.minLength ?? null, t = J.maxLength ?? null, n = J.min ?? null, r = J.max ?? null;
392
+ return {
393
+ minLength: [{ validator: (e, n) => n != null && t != null && n > t ? Promise.reject(/* @__PURE__ */ Error("最短长度不能大于最大长度")) : Promise.resolve() }],
394
+ maxLength: [{ validator: (t, n) => n != null && e != null && n < e ? Promise.reject(/* @__PURE__ */ Error("最大长度不能小于最短长度")) : Promise.resolve() }],
395
+ pattern: [{ validator: (e, t) => {
396
+ if (t && typeof t == "string") try {
397
+ new RegExp(t);
398
+ } catch {
399
+ return Promise.reject(/* @__PURE__ */ Error("正则不合法,无法编译"));
400
+ }
401
+ return Promise.resolve();
402
+ } }],
403
+ min: [{ validator: (e, t) => t != null && r != null && Ce(t, r) > 0 ? Promise.reject(/* @__PURE__ */ Error("最小值不能大于最大值")) : Promise.resolve() }],
404
+ max: [{ validator: (e, t) => t != null && n != null && Ce(t, n) < 0 ? Promise.reject(/* @__PURE__ */ Error("最大值不能小于最小值")) : Promise.resolve() }]
405
+ };
406
+ }), X = g(null), Z = g(null);
407
+ function Te() {
408
+ Z.value ||= X.value?.querySelector("tbody") ?? null;
133
409
  }
134
- u(async () => {
135
- await l(), W(), U.value && Y.start(U.value);
410
+ p(async () => {
411
+ await d(), Te(), Z.value && ke.start(Z.value);
136
412
  });
137
- let G = p(null);
138
- function K() {
139
- G.value && (G.value.style.display = "none");
413
+ let Q = g(null);
414
+ function $() {
415
+ Q.value && (Q.value.style.display = "none");
140
416
  }
141
- function q(e) {
142
- let t = U.value, n = H.value, r = G.value, i = e?.related, a = i instanceof Element ? i.closest("tr") : null;
417
+ function Ee(e) {
418
+ let t = Z.value, n = X.value, r = Q.value, i = e?.related, a = i instanceof Element ? i.closest("tr") : null;
143
419
  if (!t || !n || !r || !a || !t.contains(a)) {
144
- K();
420
+ $();
145
421
  return;
146
422
  }
147
423
  let o = a.getBoundingClientRect(), s = n.getBoundingClientRect(), c = e.willInsertAfter ? o.bottom : o.top;
148
424
  r.style.top = `${c - s.top - 1}px`, r.style.left = "0px", r.style.width = `${n.clientWidth}px`, r.style.display = "block";
149
425
  }
150
- let J = f({
426
+ function De(e) {
427
+ if (!e) return;
428
+ let t = document.querySelector(".me-input-property__drag-fallback");
429
+ if (!t) return;
430
+ let n = Array.from(e.querySelectorAll("td")), r = Array.from(t.querySelectorAll("td"));
431
+ if (!n.length || n.length !== r.length) return;
432
+ let i = e.getBoundingClientRect();
433
+ t.style.width = `${i.width}px`, t.style.height = `${i.height}px`, t.style.opacity = "1", n.forEach((e, t) => {
434
+ r[t].style.width = `${e.getBoundingClientRect().width}px`;
435
+ });
436
+ }
437
+ let Oe = h({
151
438
  handle: ".me-input-property__drag",
152
439
  animation: 150,
153
440
  forceFallback: !0,
154
441
  fallbackOnBody: !0,
155
442
  fallbackClass: "me-input-property__drag-fallback",
156
443
  ghostClass: "me-input-property__row--ghost",
157
- disabled: t(() => !M.value),
158
- onStart: () => K(),
159
- onMove: ((e) => (q(e), !0)),
444
+ disabled: r(() => !P.value),
445
+ onStart: (e) => {
446
+ $(), De(e.item);
447
+ },
448
+ onMove: ((e) => (Ee(e), !0)),
160
449
  onEnd: () => {
161
- K(), z(), P();
450
+ $(), U(), F();
162
451
  }
163
- }), Y = v(U, O, {
164
- ...J,
452
+ }), ke = x(Z, k, {
453
+ ...Oe,
165
454
  immediate: !1
166
455
  });
167
- return g(M, (e) => {
168
- Y.option("disabled", !e);
169
- }), (t, l) => {
170
- let u = m("a-button"), f = m("a-input"), p = m("a-tooltip"), g = m("a-table");
171
- return d(), i("div", {
456
+ return y(P, (e) => {
457
+ ke.option("disabled", !e);
458
+ }), (r, d) => {
459
+ let p = _("a-button"), h = _("a-input"), g = _("a-tooltip"), y = _("a-select"), x = _("a-input-number"), S = _("a-date-picker"), w = _("a-time-picker"), D = _("a-space-compact"), O = _("a-table"), A = _("a-checkbox"), j = _("a-form-item"), M = _("a-form");
460
+ return m(), o("div", {
172
461
  ref_key: "rootEl",
173
- ref: H,
462
+ ref: X,
174
463
  class: "me-input-property"
175
464
  }, [
176
- a("div", C, [s(u, {
465
+ s("div", ue, [l(p, {
177
466
  size: "small",
178
467
  class: "me-input-property__add-btn",
179
- disabled: c.disabled,
180
- onClick: L
468
+ disabled: u.disabled,
469
+ onClick: B
181
470
  }, {
182
- icon: _(() => [s(h(e), {
471
+ icon: b(() => [l(v(e), {
183
472
  name: "Plus",
184
473
  size: 14
185
474
  })]),
186
- default: _(() => [l[0] ||= o(" 新增属性 ", -1)]),
475
+ default: b(() => [d[12] ||= c(" 新增属性 ", -1)]),
187
476
  _: 1
188
477
  }, 8, ["disabled"])]),
189
- s(g, {
190
- columns: j.value,
191
- "data-source": O.value,
478
+ l(O, {
479
+ columns: ne.value,
480
+ "data-source": k.value,
192
481
  "row-key": (e) => e.id,
193
482
  pagination: !1,
194
- size: c.size,
195
- locale: { emptyText: c.emptyText },
483
+ size: u.size,
484
+ locale: { emptyText: u.emptyText },
196
485
  class: "me-input-property__table"
197
486
  }, {
198
- bodyCell: _(({ column: t, record: a }) => [t.key === "action" ? (d(), i("div", w, [M.value ? (d(), i("span", T, [s(h(e), {
487
+ bodyCell: b(({ column: t, record: n }) => [t.key === "action" ? (m(), o("div", de, [P.value ? (m(), o("span", fe, [l(v(e), {
199
488
  name: "GripVertical",
200
489
  size: 14
201
- })])) : r("", !0), s(u, {
490
+ })])) : a("", !0), l(p, {
202
491
  type: "text",
203
492
  size: "small",
204
493
  class: "me-input-property__del",
205
- disabled: c.disabled,
494
+ disabled: u.disabled,
206
495
  title: "删除该属性",
207
- onClick: (e) => R(a)
496
+ onClick: (e) => V(n)
208
497
  }, {
209
- default: _(() => [s(h(e), {
498
+ default: b(() => [l(v(e), {
210
499
  name: "Trash2",
211
500
  size: 14
212
501
  })]),
213
502
  _: 1
214
- }, 8, ["disabled", "onClick"])])) : t.key === "key" ? (d(), n(p, {
503
+ }, 8, ["disabled", "onClick"])])) : t.key === "key" ? (m(), i(g, {
215
504
  key: 1,
216
- title: c.disabled ? "" : V(a.key),
217
- visible: !c.disabled && B(a.key)
505
+ title: u.disabled ? "" : pe(n.key),
506
+ visible: !u.disabled && me(n)
218
507
  }, {
219
- default: _(() => [s(f, {
220
- value: a.key,
221
- "onUpdate:value": [(e) => a.key = e, (e) => F(a)],
222
- disabled: c.disabled,
223
- placeholder: c.keyPlaceholder,
224
- status: !c.disabled && B(a.key) ? "error" : ""
508
+ default: b(() => [l(h, {
509
+ value: n.key,
510
+ "onUpdate:value": [(e) => n.key = e, (e) => oe(n)],
511
+ class: f(["me-input-property__key-input", { "me-input-property__field--error": !u.disabled && me(n) }]),
512
+ disabled: u.disabled,
513
+ placeholder: u.keyPlaceholder
225
514
  }, null, 8, [
226
515
  "value",
227
516
  "onUpdate:value",
517
+ "class",
228
518
  "disabled",
229
- "placeholder",
230
- "status"
519
+ "placeholder"
231
520
  ])]),
232
521
  _: 2
233
- }, 1032, ["title", "visible"])) : t.key === "value" ? (d(), n(f, {
522
+ }, 1032, ["title", "visible"])) : t.key === "value" ? (m(), i(g, {
234
523
  key: 2,
235
- value: a.value,
236
- "onUpdate:value": [(e) => a.value = e, (e) => I(a)],
237
- disabled: c.disabled,
238
- placeholder: c.valuePlaceholder
239
- }, null, 8, [
240
- "value",
241
- "onUpdate:value",
242
- "disabled",
243
- "placeholder"
244
- ])) : r("", !0)]),
524
+ title: G(n),
525
+ visible: !!G(n)
526
+ }, {
527
+ default: b(() => [l(D, {
528
+ block: !0,
529
+ class: f(["me-input-property__value", { "me-input-property__field--error": !!G(n) }])
530
+ }, {
531
+ default: b(() => [u.showType ? (m(), i(y, {
532
+ key: 0,
533
+ value: n.type,
534
+ disabled: u.disabled,
535
+ options: v(C),
536
+ class: "me-input-property__value-type",
537
+ onChange: (e) => L(n, e)
538
+ }, null, 8, [
539
+ "value",
540
+ "disabled",
541
+ "options",
542
+ "onChange"
543
+ ])) : a("", !0), n.type === "string" ? (m(), i(h, {
544
+ key: 1,
545
+ value: n.value,
546
+ "onUpdate:value": [(e) => n.value = e, (e) => I(n)],
547
+ class: "me-input-property__value-editor",
548
+ disabled: u.disabled,
549
+ placeholder: u.valuePlaceholder
550
+ }, null, 8, [
551
+ "value",
552
+ "onUpdate:value",
553
+ "disabled",
554
+ "placeholder"
555
+ ])) : n.type === "int" ? (m(), i(x, {
556
+ key: 2,
557
+ value: n.value,
558
+ "onUpdate:value": [(e) => n.value = e, (e) => I(n)],
559
+ class: "me-input-property__value-editor",
560
+ disabled: u.disabled,
561
+ placeholder: u.valuePlaceholder
562
+ }, null, 8, [
563
+ "value",
564
+ "onUpdate:value",
565
+ "disabled",
566
+ "placeholder"
567
+ ])) : n.type === "float" ? (m(), i(x, {
568
+ key: 3,
569
+ value: n.value,
570
+ "onUpdate:value": [(e) => n.value = e, (e) => I(n)],
571
+ class: "me-input-property__value-editor",
572
+ disabled: u.disabled,
573
+ placeholder: u.valuePlaceholder,
574
+ precision: v(2)
575
+ }, null, 8, [
576
+ "value",
577
+ "onUpdate:value",
578
+ "disabled",
579
+ "placeholder",
580
+ "precision"
581
+ ])) : n.type === "date" ? (m(), i(S, {
582
+ key: 4,
583
+ value: n.value,
584
+ "onUpdate:value": [(e) => n.value = e, (e) => I(n)],
585
+ class: "me-input-property__value-editor",
586
+ "value-format": v(T),
587
+ disabled: u.disabled
588
+ }, null, 8, [
589
+ "value",
590
+ "onUpdate:value",
591
+ "value-format",
592
+ "disabled"
593
+ ])) : n.type === "time" ? (m(), i(w, {
594
+ key: 5,
595
+ value: n.value,
596
+ "onUpdate:value": [(e) => n.value = e, (e) => I(n)],
597
+ class: "me-input-property__value-editor",
598
+ "value-format": v(E),
599
+ disabled: u.disabled
600
+ }, null, 8, [
601
+ "value",
602
+ "onUpdate:value",
603
+ "value-format",
604
+ "disabled"
605
+ ])) : n.type === "boolean" ? (m(), i(y, {
606
+ key: 6,
607
+ value: n.value,
608
+ class: "me-input-property__value-editor",
609
+ disabled: u.disabled,
610
+ options: v(ee),
611
+ onChange: (e) => R(n, e)
612
+ }, null, 8, [
613
+ "value",
614
+ "disabled",
615
+ "options",
616
+ "onChange"
617
+ ])) : a("", !0)]),
618
+ _: 2
619
+ }, 1032, ["class"])]),
620
+ _: 2
621
+ }, 1032, ["title", "visible"])) : t.key === "rules" ? (m(), i(g, {
622
+ key: 3,
623
+ title: "配置校验规则"
624
+ }, {
625
+ default: b(() => [l(p, {
626
+ type: "text",
627
+ size: "small",
628
+ class: f(["me-input-property__rules-btn", { "is-active": he(n) }]),
629
+ disabled: u.disabled,
630
+ onClick: (e) => be(n)
631
+ }, {
632
+ default: b(() => [l(v(e), {
633
+ name: "WandSparkles",
634
+ size: 14
635
+ })]),
636
+ _: 1
637
+ }, 8, [
638
+ "class",
639
+ "disabled",
640
+ "onClick"
641
+ ])]),
642
+ _: 2
643
+ }, 1024)) : a("", !0)]),
245
644
  _: 1
246
645
  }, 8, [
247
646
  "columns",
@@ -250,9 +649,162 @@ var C = { class: "me-input-property__toolbar" }, w = {
250
649
  "size",
251
650
  "locale"
252
651
  ]),
253
- a("div", {
652
+ l(v(t), {
653
+ open: K.value,
654
+ "onUpdate:open": d[11] ||= (e) => K.value = e,
655
+ width: 480,
656
+ fullscreen: !1,
657
+ title: ve.value,
658
+ "ok-text": "保存",
659
+ "cancel-text": "取消",
660
+ onOk: xe,
661
+ onCancel: Se
662
+ }, {
663
+ default: b(() => [l(M, {
664
+ ref_key: "ruleFormRef",
665
+ ref: ge,
666
+ model: J,
667
+ rules: we.value,
668
+ layout: "vertical",
669
+ class: "me-input-property__rule-form"
670
+ }, {
671
+ default: b(() => [
672
+ l(j, { name: "required" }, {
673
+ default: b(() => [l(A, {
674
+ checked: J.required,
675
+ "onUpdate:checked": d[0] ||= (e) => J.required = e
676
+ }, {
677
+ default: b(() => [...d[13] ||= [c("必填(值不能为空)", -1)]]),
678
+ _: 1
679
+ }, 8, ["checked"])]),
680
+ _: 1
681
+ }),
682
+ Y.value === "string" ? (m(), o(n, { key: 0 }, [
683
+ l(j, {
684
+ name: "minLength",
685
+ label: "最短长度"
686
+ }, {
687
+ default: b(() => [l(x, {
688
+ value: J.minLength,
689
+ "onUpdate:value": d[1] ||= (e) => J.minLength = e,
690
+ min: 0,
691
+ precision: 0,
692
+ placeholder: "不限",
693
+ class: "me-input-property__rule-input"
694
+ }, null, 8, ["value"])]),
695
+ _: 1
696
+ }),
697
+ l(j, {
698
+ name: "maxLength",
699
+ label: "最大长度"
700
+ }, {
701
+ default: b(() => [l(x, {
702
+ value: J.maxLength,
703
+ "onUpdate:value": d[2] ||= (e) => J.maxLength = e,
704
+ min: 0,
705
+ precision: 0,
706
+ placeholder: "不限",
707
+ class: "me-input-property__rule-input"
708
+ }, null, 8, ["value"])]),
709
+ _: 1
710
+ }),
711
+ l(j, {
712
+ name: "pattern",
713
+ label: "正则模式",
714
+ extra: "校验值格式,如 ^[a-zA-Z0-9]+$"
715
+ }, {
716
+ default: b(() => [l(h, {
717
+ value: J.pattern,
718
+ "onUpdate:value": d[3] ||= (e) => J.pattern = e,
719
+ placeholder: "如 ^[a-zA-Z0-9]+$",
720
+ "allow-clear": ""
721
+ }, null, 8, ["value"])]),
722
+ _: 1
723
+ })
724
+ ], 64)) : a("", !0),
725
+ ye(Y.value) ? (m(), o(n, { key: 1 }, [l(j, {
726
+ name: "min",
727
+ label: "最小值"
728
+ }, {
729
+ default: b(() => [l(x, {
730
+ value: J.min,
731
+ "onUpdate:value": d[4] ||= (e) => J.min = e,
732
+ precision: Y.value === "float" ? v(2) : 0,
733
+ placeholder: "不限",
734
+ class: "me-input-property__rule-input"
735
+ }, null, 8, ["value", "precision"])]),
736
+ _: 1
737
+ }), l(j, {
738
+ name: "max",
739
+ label: "最大值"
740
+ }, {
741
+ default: b(() => [l(x, {
742
+ value: J.max,
743
+ "onUpdate:value": d[5] ||= (e) => J.max = e,
744
+ precision: Y.value === "float" ? v(2) : 0,
745
+ placeholder: "不限",
746
+ class: "me-input-property__rule-input"
747
+ }, null, 8, ["value", "precision"])]),
748
+ _: 1
749
+ })], 64)) : a("", !0),
750
+ Y.value === "date" || Y.value === "time" ? (m(), o(n, { key: 2 }, [l(j, {
751
+ name: "min",
752
+ label: "最早边界"
753
+ }, {
754
+ default: b(() => [Y.value === "date" ? (m(), i(S, {
755
+ key: 0,
756
+ value: J.min,
757
+ "onUpdate:value": d[6] ||= (e) => J.min = e,
758
+ "value-format": v(T),
759
+ style: { width: "100%" }
760
+ }, null, 8, ["value", "value-format"])) : (m(), i(w, {
761
+ key: 1,
762
+ value: J.min,
763
+ "onUpdate:value": d[7] ||= (e) => J.min = e,
764
+ "value-format": v(E),
765
+ style: { width: "100%" }
766
+ }, null, 8, ["value", "value-format"]))]),
767
+ _: 1
768
+ }), l(j, {
769
+ name: "max",
770
+ label: "最晚边界"
771
+ }, {
772
+ default: b(() => [Y.value === "date" ? (m(), i(S, {
773
+ key: 0,
774
+ value: J.max,
775
+ "onUpdate:value": d[8] ||= (e) => J.max = e,
776
+ "value-format": v(T),
777
+ style: { width: "100%" }
778
+ }, null, 8, ["value", "value-format"])) : (m(), i(w, {
779
+ key: 1,
780
+ value: J.max,
781
+ "onUpdate:value": d[9] ||= (e) => J.max = e,
782
+ "value-format": v(E),
783
+ style: { width: "100%" }
784
+ }, null, 8, ["value", "value-format"]))]),
785
+ _: 1
786
+ })], 64)) : a("", !0),
787
+ l(j, {
788
+ name: "message",
789
+ label: "自定义错误提示",
790
+ extra: "可选,覆盖所有校验规则的默认提示文案"
791
+ }, {
792
+ default: b(() => [l(h, {
793
+ value: J.message,
794
+ "onUpdate:value": d[10] ||= (e) => J.message = e,
795
+ placeholder: "如:该属性不合法",
796
+ "allow-clear": ""
797
+ }, null, 8, ["value"])]),
798
+ _: 1
799
+ })
800
+ ]),
801
+ _: 1
802
+ }, 8, ["model", "rules"])]),
803
+ _: 1
804
+ }, 8, ["open", "title"]),
805
+ s("div", {
254
806
  ref_key: "dropLineEl",
255
- ref: G,
807
+ ref: Q,
256
808
  class: "me-input-property__drop-line"
257
809
  }, null, 512)
258
810
  ], 512);
@@ -261,9 +813,9 @@ var C = { class: "me-input-property__toolbar" }, w = {
261
813
  });
262
814
  //#endregion
263
815
  //#region src/components/input-property/index.ts
264
- E.install = (e) => {
265
- e.component("MeInputProperty", E);
816
+ U.install = (e) => {
817
+ e.component("MeInputProperty", U);
266
818
  };
267
- var D = E;
819
+ var W = U;
268
820
  //#endregion
269
- export { E as MeInputProperty, x as checkDuplicateKeys, D as default, y as genId, S as isDuplicateKey, b as normalizeKey };
821
+ export { ee as BOOLEAN_OPTIONS, T as DATE_FORMAT, w as FLOAT_PRECISION, U as MeInputProperty, E as TIME_FORMAT, C as VALUE_TYPE_OPTIONS, ie as checkDuplicateKeys, W as default, te as exportValue, D as genId, j as inferValueType, ae as isDuplicateKey, L as isRuleApplicable, F as normalizeKey, z as normalizeRuleSet, M as normalizeValue, se as sanitizeRulesForType, ce as toRuleMap, le as toValueErrorMap, V as validateValue, H as valueError };