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

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