yc-project-template 1.0.0
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/README.md +48 -0
- package/dist/AppManage-yJ4SOsDj.js +77 -0
- package/dist/DeptTree-BJ-YyoZO.js +88 -0
- package/dist/DictionaryModal-jyoOTJD4.js +157 -0
- package/dist/DictionaryValueModal-D6wJ04-c.js +173 -0
- package/dist/Login-CorWfiLZ.js +169 -0
- package/dist/NotFound-B_crl8rg.js +21 -0
- package/dist/OrgModal-DgTQN71P.js +114 -0
- package/dist/PageTemplate-BXwP32sO.js +149 -0
- package/dist/RoleModal-QaUkdPyy.js +126 -0
- package/dist/UserModal-MQeOVpvt.js +200 -0
- package/dist/YcSearchForm-BWweEnqG.js +326 -0
- package/dist/YcTree-COox_XNx.js +124 -0
- package/dist/el-col-B8XtMrKy.js +135 -0
- package/dist/el-dropdown-item-zXcF1C0U.js +862 -0
- package/dist/el-form-item-DGYKf4A6.js +1178 -0
- package/dist/favicon.ico +0 -0
- package/dist/globalComponents-NGC1jMmM.js +112761 -0
- package/dist/index-CMXoxgLU.js +1062 -0
- package/dist/index-Cc-Qq-qP.js +17 -0
- package/dist/index-DBq96lnF.js +393 -0
- package/dist/index-zZ1bb-CY.js +278 -0
- package/dist/rsaCrypto-B9Iz2FB1.js +2084 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/useMenu-CCb03now.js +18 -0
- package/dist/yc-project-template.css +1 -0
- package/dist/yc-project-template.es.js +5 -0
- package/dist/yc-project-template.umd.js +746 -0
- package/package.json +123 -0
|
@@ -0,0 +1,1178 @@
|
|
|
1
|
+
import { ref as L, computed as _, defineComponent as qe, reactive as pe, watch as re, provide as De, toRefs as ze, createElementBlock as Ue, openBlock as ve, normalizeClass as G, renderSlot as ee, inject as ne, onMounted as Ge, onBeforeUnmount as Ye, onUpdated as lt, createVNode as ie, Fragment as ut, nextTick as Ze, useSlots as dt, unref as T, createElementVNode as Se, withCtx as ue, createBlock as ct, createCommentVNode as je, resolveDynamicComponent as pt, normalizeStyle as Re, createTextVNode as vt, toDisplayString as Ne, TransitionGroup as mt } from "vue";
|
|
2
|
+
import { M as ht, N as ae, O as Ve, P as ke, D as xe, G as se, Q as Je, R as me, S as Y, H as Ke, T as He, I as Oe, U as Ee, V as Qe, W as he, X as gt, Y as yt, Z as bt, $ as wt, a0 as We, a1 as de, L as Ft, a2 as qt } from "./globalComponents-NGC1jMmM.js";
|
|
3
|
+
var xt = 4;
|
|
4
|
+
function Ie(i) {
|
|
5
|
+
return ht(i, xt);
|
|
6
|
+
}
|
|
7
|
+
const Ot = xe({
|
|
8
|
+
size: {
|
|
9
|
+
type: String,
|
|
10
|
+
values: Je
|
|
11
|
+
},
|
|
12
|
+
disabled: Boolean
|
|
13
|
+
}), Et = xe({
|
|
14
|
+
...Ot,
|
|
15
|
+
model: Object,
|
|
16
|
+
rules: {
|
|
17
|
+
type: se(Object)
|
|
18
|
+
},
|
|
19
|
+
labelPosition: {
|
|
20
|
+
type: String,
|
|
21
|
+
values: ["left", "right", "top"],
|
|
22
|
+
default: "right"
|
|
23
|
+
},
|
|
24
|
+
requireAsteriskPosition: {
|
|
25
|
+
type: String,
|
|
26
|
+
values: ["left", "right"],
|
|
27
|
+
default: "left"
|
|
28
|
+
},
|
|
29
|
+
labelWidth: {
|
|
30
|
+
type: [String, Number],
|
|
31
|
+
default: ""
|
|
32
|
+
},
|
|
33
|
+
labelSuffix: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: ""
|
|
36
|
+
},
|
|
37
|
+
inline: Boolean,
|
|
38
|
+
inlineMessage: Boolean,
|
|
39
|
+
statusIcon: Boolean,
|
|
40
|
+
showMessage: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !0
|
|
43
|
+
},
|
|
44
|
+
validateOnRuleChange: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: !0
|
|
47
|
+
},
|
|
48
|
+
hideRequiredAsterisk: Boolean,
|
|
49
|
+
scrollToError: Boolean,
|
|
50
|
+
scrollIntoViewOptions: {
|
|
51
|
+
type: se([Object, Boolean]),
|
|
52
|
+
default: !0
|
|
53
|
+
}
|
|
54
|
+
}), _t = {
|
|
55
|
+
validate: (i, e, t) => (ae(i) || Ve(i)) && ke(e) && Ve(t)
|
|
56
|
+
}, Pt = "ElForm";
|
|
57
|
+
function At() {
|
|
58
|
+
const i = L([]), e = _(() => {
|
|
59
|
+
if (!i.value.length)
|
|
60
|
+
return "0";
|
|
61
|
+
const s = Math.max(...i.value);
|
|
62
|
+
return s ? `${s}px` : "";
|
|
63
|
+
});
|
|
64
|
+
function t(s) {
|
|
65
|
+
const a = i.value.indexOf(s);
|
|
66
|
+
return a === -1 && e.value === "0" && Y(Pt, `unexpected width ${s}`), a;
|
|
67
|
+
}
|
|
68
|
+
function r(s, a) {
|
|
69
|
+
if (s && a) {
|
|
70
|
+
const o = t(a);
|
|
71
|
+
i.value.splice(o, 1, s);
|
|
72
|
+
} else s && i.value.push(s);
|
|
73
|
+
}
|
|
74
|
+
function n(s) {
|
|
75
|
+
const a = t(s);
|
|
76
|
+
a > -1 && i.value.splice(a, 1);
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
autoLabelWidth: e,
|
|
80
|
+
registerLabelWidth: r,
|
|
81
|
+
deregisterLabelWidth: n
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
const H = (i, e) => {
|
|
85
|
+
const t = me(e).map(
|
|
86
|
+
(r) => ae(r) ? r.join(".") : r
|
|
87
|
+
);
|
|
88
|
+
return t.length > 0 ? i.filter(
|
|
89
|
+
(r) => r.propString && t.includes(r.propString)
|
|
90
|
+
) : i;
|
|
91
|
+
}, Q = "ElForm", St = qe({
|
|
92
|
+
name: Q,
|
|
93
|
+
__name: "form",
|
|
94
|
+
props: Et,
|
|
95
|
+
emits: _t,
|
|
96
|
+
setup(i, { expose: e, emit: t }) {
|
|
97
|
+
const r = i, n = t, s = L(), a = pe([]), o = He(), f = Oe("form"), F = _(() => {
|
|
98
|
+
const { labelPosition: c, inline: m } = r;
|
|
99
|
+
return [
|
|
100
|
+
f.b(),
|
|
101
|
+
f.m(o.value || "default"),
|
|
102
|
+
{
|
|
103
|
+
[f.m(`label-${c}`)]: c,
|
|
104
|
+
[f.m("inline")]: m
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
}), p = (c) => H(a, [c])[0], g = (c) => {
|
|
108
|
+
a.push(c);
|
|
109
|
+
}, w = (c) => {
|
|
110
|
+
c.prop && a.splice(a.indexOf(c), 1);
|
|
111
|
+
}, O = (c = []) => {
|
|
112
|
+
if (!r.model) {
|
|
113
|
+
Y(Q, "model is required for resetFields to work.");
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
H(a, c).forEach((m) => m.resetField());
|
|
117
|
+
}, P = (c = []) => {
|
|
118
|
+
H(a, c).forEach((m) => m.clearValidate());
|
|
119
|
+
}, d = _(() => {
|
|
120
|
+
const c = !!r.model;
|
|
121
|
+
return c || Y(Q, "model is required for validate to work."), c;
|
|
122
|
+
}), y = (c) => {
|
|
123
|
+
if (a.length === 0)
|
|
124
|
+
return [];
|
|
125
|
+
const m = H(a, c);
|
|
126
|
+
return m.length ? m : (Y(Q, "please pass correct props!"), []);
|
|
127
|
+
}, l = async (c) => v(void 0, c), R = async (c = []) => {
|
|
128
|
+
if (!d.value)
|
|
129
|
+
return !1;
|
|
130
|
+
const m = y(c);
|
|
131
|
+
if (m.length === 0)
|
|
132
|
+
return !0;
|
|
133
|
+
let x = {};
|
|
134
|
+
for (const E of m)
|
|
135
|
+
try {
|
|
136
|
+
await E.validate(""), E.validateState === "error" && !E.error && E.resetField();
|
|
137
|
+
} catch (N) {
|
|
138
|
+
x = {
|
|
139
|
+
...x,
|
|
140
|
+
...N
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return Object.keys(x).length === 0 ? !0 : Promise.reject(x);
|
|
144
|
+
}, v = async (c = [], m) => {
|
|
145
|
+
let x = !1;
|
|
146
|
+
const E = !Qe(m);
|
|
147
|
+
try {
|
|
148
|
+
return x = await R(c), x === !0 && await m?.(x), x;
|
|
149
|
+
} catch (N) {
|
|
150
|
+
if (N instanceof Error)
|
|
151
|
+
throw N;
|
|
152
|
+
const B = N;
|
|
153
|
+
if (r.scrollToError && s.value) {
|
|
154
|
+
const $ = s.value.querySelector(`.${f.b()}-item.is-error`);
|
|
155
|
+
$?.scrollIntoView(r.scrollIntoViewOptions);
|
|
156
|
+
}
|
|
157
|
+
return !x && await m?.(!1, B), E && Promise.reject(B);
|
|
158
|
+
}
|
|
159
|
+
}, q = (c) => {
|
|
160
|
+
var m;
|
|
161
|
+
const x = p(c);
|
|
162
|
+
x && ((m = x.$el) == null || m.scrollIntoView(r.scrollIntoViewOptions));
|
|
163
|
+
};
|
|
164
|
+
return re(
|
|
165
|
+
() => r.rules,
|
|
166
|
+
() => {
|
|
167
|
+
r.validateOnRuleChange && l().catch((c) => Y(c));
|
|
168
|
+
},
|
|
169
|
+
{ deep: !0, flush: "post" }
|
|
170
|
+
), De(
|
|
171
|
+
Ee,
|
|
172
|
+
pe({
|
|
173
|
+
...ze(r),
|
|
174
|
+
emit: n,
|
|
175
|
+
resetFields: O,
|
|
176
|
+
clearValidate: P,
|
|
177
|
+
validateField: v,
|
|
178
|
+
getField: p,
|
|
179
|
+
addField: g,
|
|
180
|
+
removeField: w,
|
|
181
|
+
...At()
|
|
182
|
+
})
|
|
183
|
+
), e({
|
|
184
|
+
validate: l,
|
|
185
|
+
validateField: v,
|
|
186
|
+
resetFields: O,
|
|
187
|
+
clearValidate: P,
|
|
188
|
+
scrollToField: q,
|
|
189
|
+
getField: p,
|
|
190
|
+
fields: a
|
|
191
|
+
}), (c, m) => (ve(), Ue(
|
|
192
|
+
"form",
|
|
193
|
+
{
|
|
194
|
+
ref_key: "formRef",
|
|
195
|
+
ref: s,
|
|
196
|
+
class: G(F.value)
|
|
197
|
+
},
|
|
198
|
+
[
|
|
199
|
+
ee(c.$slots, "default")
|
|
200
|
+
],
|
|
201
|
+
2
|
|
202
|
+
));
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
var jt = /* @__PURE__ */ Ke(St, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/form/src/form.vue"]]);
|
|
206
|
+
function C() {
|
|
207
|
+
return C = Object.assign ? Object.assign.bind() : function(i) {
|
|
208
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
209
|
+
var t = arguments[e];
|
|
210
|
+
for (var r in t)
|
|
211
|
+
Object.prototype.hasOwnProperty.call(t, r) && (i[r] = t[r]);
|
|
212
|
+
}
|
|
213
|
+
return i;
|
|
214
|
+
}, C.apply(this, arguments);
|
|
215
|
+
}
|
|
216
|
+
function Rt(i, e) {
|
|
217
|
+
i.prototype = Object.create(e.prototype), i.prototype.constructor = i, J(i, e);
|
|
218
|
+
}
|
|
219
|
+
function ge(i) {
|
|
220
|
+
return ge = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t) {
|
|
221
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
222
|
+
}, ge(i);
|
|
223
|
+
}
|
|
224
|
+
function J(i, e) {
|
|
225
|
+
return J = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(r, n) {
|
|
226
|
+
return r.__proto__ = n, r;
|
|
227
|
+
}, J(i, e);
|
|
228
|
+
}
|
|
229
|
+
function Nt() {
|
|
230
|
+
if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
|
|
231
|
+
if (typeof Proxy == "function") return !0;
|
|
232
|
+
try {
|
|
233
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
234
|
+
})), !0;
|
|
235
|
+
} catch {
|
|
236
|
+
return !1;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function te(i, e, t) {
|
|
240
|
+
return Nt() ? te = Reflect.construct.bind() : te = function(n, s, a) {
|
|
241
|
+
var o = [null];
|
|
242
|
+
o.push.apply(o, s);
|
|
243
|
+
var f = Function.bind.apply(n, o), F = new f();
|
|
244
|
+
return a && J(F, a.prototype), F;
|
|
245
|
+
}, te.apply(null, arguments);
|
|
246
|
+
}
|
|
247
|
+
function Vt(i) {
|
|
248
|
+
return Function.toString.call(i).indexOf("[native code]") !== -1;
|
|
249
|
+
}
|
|
250
|
+
function ye(i) {
|
|
251
|
+
var e = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
252
|
+
return ye = function(r) {
|
|
253
|
+
if (r === null || !Vt(r)) return r;
|
|
254
|
+
if (typeof r != "function")
|
|
255
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
256
|
+
if (typeof e < "u") {
|
|
257
|
+
if (e.has(r)) return e.get(r);
|
|
258
|
+
e.set(r, n);
|
|
259
|
+
}
|
|
260
|
+
function n() {
|
|
261
|
+
return te(r, arguments, ge(this).constructor);
|
|
262
|
+
}
|
|
263
|
+
return n.prototype = Object.create(r.prototype, {
|
|
264
|
+
constructor: {
|
|
265
|
+
value: n,
|
|
266
|
+
enumerable: !1,
|
|
267
|
+
writable: !0,
|
|
268
|
+
configurable: !0
|
|
269
|
+
}
|
|
270
|
+
}), J(n, r);
|
|
271
|
+
}, ye(i);
|
|
272
|
+
}
|
|
273
|
+
var Wt = /%[sdj%]/g, Xe = function() {
|
|
274
|
+
};
|
|
275
|
+
typeof process < "u" && process.env && process.env.NODE_ENV !== "production" && typeof window < "u" && typeof document < "u" && (Xe = function(e, t) {
|
|
276
|
+
typeof console < "u" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING > "u" && t.every(function(r) {
|
|
277
|
+
return typeof r == "string";
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
function be(i) {
|
|
281
|
+
if (!i || !i.length) return null;
|
|
282
|
+
var e = {};
|
|
283
|
+
return i.forEach(function(t) {
|
|
284
|
+
var r = t.field;
|
|
285
|
+
e[r] = e[r] || [], e[r].push(t);
|
|
286
|
+
}), e;
|
|
287
|
+
}
|
|
288
|
+
function W(i) {
|
|
289
|
+
for (var e = arguments.length, t = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++)
|
|
290
|
+
t[r - 1] = arguments[r];
|
|
291
|
+
var n = 0, s = t.length;
|
|
292
|
+
if (typeof i == "function")
|
|
293
|
+
return i.apply(null, t);
|
|
294
|
+
if (typeof i == "string") {
|
|
295
|
+
var a = i.replace(Wt, function(o) {
|
|
296
|
+
if (o === "%%")
|
|
297
|
+
return "%";
|
|
298
|
+
if (n >= s)
|
|
299
|
+
return o;
|
|
300
|
+
switch (o) {
|
|
301
|
+
case "%s":
|
|
302
|
+
return String(t[n++]);
|
|
303
|
+
case "%d":
|
|
304
|
+
return Number(t[n++]);
|
|
305
|
+
case "%j":
|
|
306
|
+
try {
|
|
307
|
+
return JSON.stringify(t[n++]);
|
|
308
|
+
} catch {
|
|
309
|
+
return "[Circular]";
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
default:
|
|
313
|
+
return o;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
return a;
|
|
317
|
+
}
|
|
318
|
+
return i;
|
|
319
|
+
}
|
|
320
|
+
function It(i) {
|
|
321
|
+
return i === "string" || i === "url" || i === "hex" || i === "email" || i === "date" || i === "pattern";
|
|
322
|
+
}
|
|
323
|
+
function A(i, e) {
|
|
324
|
+
return !!(i == null || e === "array" && Array.isArray(i) && !i.length || It(e) && typeof i == "string" && !i);
|
|
325
|
+
}
|
|
326
|
+
function Mt(i, e, t) {
|
|
327
|
+
var r = [], n = 0, s = i.length;
|
|
328
|
+
function a(o) {
|
|
329
|
+
r.push.apply(r, o || []), n++, n === s && t(r);
|
|
330
|
+
}
|
|
331
|
+
i.forEach(function(o) {
|
|
332
|
+
e(o, a);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
function Me(i, e, t) {
|
|
336
|
+
var r = 0, n = i.length;
|
|
337
|
+
function s(a) {
|
|
338
|
+
if (a && a.length) {
|
|
339
|
+
t(a);
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
var o = r;
|
|
343
|
+
r = r + 1, o < n ? e(i[o], s) : t([]);
|
|
344
|
+
}
|
|
345
|
+
s([]);
|
|
346
|
+
}
|
|
347
|
+
function $t(i) {
|
|
348
|
+
var e = [];
|
|
349
|
+
return Object.keys(i).forEach(function(t) {
|
|
350
|
+
e.push.apply(e, i[t] || []);
|
|
351
|
+
}), e;
|
|
352
|
+
}
|
|
353
|
+
var $e = /* @__PURE__ */ (function(i) {
|
|
354
|
+
Rt(e, i);
|
|
355
|
+
function e(t, r) {
|
|
356
|
+
var n;
|
|
357
|
+
return n = i.call(this, "Async Validation Error") || this, n.errors = t, n.fields = r, n;
|
|
358
|
+
}
|
|
359
|
+
return e;
|
|
360
|
+
})(/* @__PURE__ */ ye(Error));
|
|
361
|
+
function Lt(i, e, t, r, n) {
|
|
362
|
+
if (e.first) {
|
|
363
|
+
var s = new Promise(function(w, O) {
|
|
364
|
+
var P = function(l) {
|
|
365
|
+
return r(l), l.length ? O(new $e(l, be(l))) : w(n);
|
|
366
|
+
}, d = $t(i);
|
|
367
|
+
Me(d, t, P);
|
|
368
|
+
});
|
|
369
|
+
return s.catch(function(w) {
|
|
370
|
+
return w;
|
|
371
|
+
}), s;
|
|
372
|
+
}
|
|
373
|
+
var a = e.firstFields === !0 ? Object.keys(i) : e.firstFields || [], o = Object.keys(i), f = o.length, F = 0, p = [], g = new Promise(function(w, O) {
|
|
374
|
+
var P = function(y) {
|
|
375
|
+
if (p.push.apply(p, y), F++, F === f)
|
|
376
|
+
return r(p), p.length ? O(new $e(p, be(p))) : w(n);
|
|
377
|
+
};
|
|
378
|
+
o.length || (r(p), w(n)), o.forEach(function(d) {
|
|
379
|
+
var y = i[d];
|
|
380
|
+
a.indexOf(d) !== -1 ? Me(y, t, P) : Mt(y, t, P);
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
return g.catch(function(w) {
|
|
384
|
+
return w;
|
|
385
|
+
}), g;
|
|
386
|
+
}
|
|
387
|
+
function Bt(i) {
|
|
388
|
+
return !!(i && i.message !== void 0);
|
|
389
|
+
}
|
|
390
|
+
function Tt(i, e) {
|
|
391
|
+
for (var t = i, r = 0; r < e.length; r++) {
|
|
392
|
+
if (t == null)
|
|
393
|
+
return t;
|
|
394
|
+
t = t[e[r]];
|
|
395
|
+
}
|
|
396
|
+
return t;
|
|
397
|
+
}
|
|
398
|
+
function Le(i, e) {
|
|
399
|
+
return function(t) {
|
|
400
|
+
var r;
|
|
401
|
+
return i.fullFields ? r = Tt(e, i.fullFields) : r = e[t.field || i.fullField], Bt(t) ? (t.field = t.field || i.fullField, t.fieldValue = r, t) : {
|
|
402
|
+
message: typeof t == "function" ? t() : t,
|
|
403
|
+
fieldValue: r,
|
|
404
|
+
field: t.field || i.fullField
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
function Be(i, e) {
|
|
409
|
+
if (e) {
|
|
410
|
+
for (var t in e)
|
|
411
|
+
if (e.hasOwnProperty(t)) {
|
|
412
|
+
var r = e[t];
|
|
413
|
+
typeof r == "object" && typeof i[t] == "object" ? i[t] = C({}, i[t], r) : i[t] = r;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return i;
|
|
417
|
+
}
|
|
418
|
+
var et = function(e, t, r, n, s, a) {
|
|
419
|
+
e.required && (!r.hasOwnProperty(e.field) || A(t, a || e.type)) && n.push(W(s.messages.required, e.fullField));
|
|
420
|
+
}, Ct = function(e, t, r, n, s) {
|
|
421
|
+
(/^\s+$/.test(t) || t === "") && n.push(W(s.messages.whitespace, e.fullField));
|
|
422
|
+
}, X, Dt = (function() {
|
|
423
|
+
if (X)
|
|
424
|
+
return X;
|
|
425
|
+
var i = "[a-fA-F\\d:]", e = function(q) {
|
|
426
|
+
return q && q.includeBoundaries ? "(?:(?<=\\s|^)(?=" + i + ")|(?<=" + i + ")(?=\\s|$))" : "";
|
|
427
|
+
}, t = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}", r = "[a-fA-F\\d]{1,4}", n = (`
|
|
428
|
+
(?:
|
|
429
|
+
(?:` + r + ":){7}(?:" + r + `|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
430
|
+
(?:` + r + ":){6}(?:" + t + "|:" + r + `|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
|
|
431
|
+
(?:` + r + ":){5}(?::" + t + "|(?::" + r + `){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
|
|
432
|
+
(?:` + r + ":){4}(?:(?::" + r + "){0,1}:" + t + "|(?::" + r + `){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
|
|
433
|
+
(?:` + r + ":){3}(?:(?::" + r + "){0,2}:" + t + "|(?::" + r + `){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
|
|
434
|
+
(?:` + r + ":){2}(?:(?::" + r + "){0,3}:" + t + "|(?::" + r + `){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
|
|
435
|
+
(?:` + r + ":){1}(?:(?::" + r + "){0,4}:" + t + "|(?::" + r + `){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
|
|
436
|
+
(?::(?:(?::` + r + "){0,5}:" + t + "|(?::" + r + `){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
|
|
437
|
+
)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
|
|
438
|
+
`).replace(/\s*\/\/.*$/gm, "").replace(/\n/g, "").trim(), s = new RegExp("(?:^" + t + "$)|(?:^" + n + "$)"), a = new RegExp("^" + t + "$"), o = new RegExp("^" + n + "$"), f = function(q) {
|
|
439
|
+
return q && q.exact ? s : new RegExp("(?:" + e(q) + t + e(q) + ")|(?:" + e(q) + n + e(q) + ")", "g");
|
|
440
|
+
};
|
|
441
|
+
f.v4 = function(v) {
|
|
442
|
+
return v && v.exact ? a : new RegExp("" + e(v) + t + e(v), "g");
|
|
443
|
+
}, f.v6 = function(v) {
|
|
444
|
+
return v && v.exact ? o : new RegExp("" + e(v) + n + e(v), "g");
|
|
445
|
+
};
|
|
446
|
+
var F = "(?:(?:[a-z]+:)?//)", p = "(?:\\S+(?::\\S*)?@)?", g = f.v4().source, w = f.v6().source, O = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)", P = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*", d = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))", y = "(?::\\d{2,5})?", l = '(?:[/?#][^\\s"]*)?', R = "(?:" + F + "|www\\.)" + p + "(?:localhost|" + g + "|" + w + "|" + O + P + d + ")" + y + l;
|
|
447
|
+
return X = new RegExp("(?:^" + R + "$)", "i"), X;
|
|
448
|
+
}), Te = {
|
|
449
|
+
// http://emailregex.com/
|
|
450
|
+
email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
|
|
451
|
+
// url: new RegExp(
|
|
452
|
+
// '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
|
|
453
|
+
// 'i',
|
|
454
|
+
// ),
|
|
455
|
+
hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
|
|
456
|
+
}, Z = {
|
|
457
|
+
integer: function(e) {
|
|
458
|
+
return Z.number(e) && parseInt(e, 10) === e;
|
|
459
|
+
},
|
|
460
|
+
float: function(e) {
|
|
461
|
+
return Z.number(e) && !Z.integer(e);
|
|
462
|
+
},
|
|
463
|
+
array: function(e) {
|
|
464
|
+
return Array.isArray(e);
|
|
465
|
+
},
|
|
466
|
+
regexp: function(e) {
|
|
467
|
+
if (e instanceof RegExp)
|
|
468
|
+
return !0;
|
|
469
|
+
try {
|
|
470
|
+
return !!new RegExp(e);
|
|
471
|
+
} catch {
|
|
472
|
+
return !1;
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
date: function(e) {
|
|
476
|
+
return typeof e.getTime == "function" && typeof e.getMonth == "function" && typeof e.getYear == "function" && !isNaN(e.getTime());
|
|
477
|
+
},
|
|
478
|
+
number: function(e) {
|
|
479
|
+
return isNaN(e) ? !1 : typeof e == "number";
|
|
480
|
+
},
|
|
481
|
+
object: function(e) {
|
|
482
|
+
return typeof e == "object" && !Z.array(e);
|
|
483
|
+
},
|
|
484
|
+
method: function(e) {
|
|
485
|
+
return typeof e == "function";
|
|
486
|
+
},
|
|
487
|
+
email: function(e) {
|
|
488
|
+
return typeof e == "string" && e.length <= 320 && !!e.match(Te.email);
|
|
489
|
+
},
|
|
490
|
+
url: function(e) {
|
|
491
|
+
return typeof e == "string" && e.length <= 2048 && !!e.match(Dt());
|
|
492
|
+
},
|
|
493
|
+
hex: function(e) {
|
|
494
|
+
return typeof e == "string" && !!e.match(Te.hex);
|
|
495
|
+
}
|
|
496
|
+
}, zt = function(e, t, r, n, s) {
|
|
497
|
+
if (e.required && t === void 0) {
|
|
498
|
+
et(e, t, r, n, s);
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
var a = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"], o = e.type;
|
|
502
|
+
a.indexOf(o) > -1 ? Z[o](t) || n.push(W(s.messages.types[o], e.fullField, e.type)) : o && typeof t !== e.type && n.push(W(s.messages.types[o], e.fullField, e.type));
|
|
503
|
+
}, Ut = function(e, t, r, n, s) {
|
|
504
|
+
var a = typeof e.len == "number", o = typeof e.min == "number", f = typeof e.max == "number", F = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, p = t, g = null, w = typeof t == "number", O = typeof t == "string", P = Array.isArray(t);
|
|
505
|
+
if (w ? g = "number" : O ? g = "string" : P && (g = "array"), !g)
|
|
506
|
+
return !1;
|
|
507
|
+
P && (p = t.length), O && (p = t.replace(F, "_").length), a ? p !== e.len && n.push(W(s.messages[g].len, e.fullField, e.len)) : o && !f && p < e.min ? n.push(W(s.messages[g].min, e.fullField, e.min)) : f && !o && p > e.max ? n.push(W(s.messages[g].max, e.fullField, e.max)) : o && f && (p < e.min || p > e.max) && n.push(W(s.messages[g].range, e.fullField, e.min, e.max));
|
|
508
|
+
}, U = "enum", Gt = function(e, t, r, n, s) {
|
|
509
|
+
e[U] = Array.isArray(e[U]) ? e[U] : [], e[U].indexOf(t) === -1 && n.push(W(s.messages[U], e.fullField, e[U].join(", ")));
|
|
510
|
+
}, Yt = function(e, t, r, n, s) {
|
|
511
|
+
if (e.pattern) {
|
|
512
|
+
if (e.pattern instanceof RegExp)
|
|
513
|
+
e.pattern.lastIndex = 0, e.pattern.test(t) || n.push(W(s.messages.pattern.mismatch, e.fullField, t, e.pattern));
|
|
514
|
+
else if (typeof e.pattern == "string") {
|
|
515
|
+
var a = new RegExp(e.pattern);
|
|
516
|
+
a.test(t) || n.push(W(s.messages.pattern.mismatch, e.fullField, t, e.pattern));
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}, h = {
|
|
520
|
+
required: et,
|
|
521
|
+
whitespace: Ct,
|
|
522
|
+
type: zt,
|
|
523
|
+
range: Ut,
|
|
524
|
+
enum: Gt,
|
|
525
|
+
pattern: Yt
|
|
526
|
+
}, Zt = function(e, t, r, n, s) {
|
|
527
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
528
|
+
if (o) {
|
|
529
|
+
if (A(t, "string") && !e.required)
|
|
530
|
+
return r();
|
|
531
|
+
h.required(e, t, n, a, s, "string"), A(t, "string") || (h.type(e, t, n, a, s), h.range(e, t, n, a, s), h.pattern(e, t, n, a, s), e.whitespace === !0 && h.whitespace(e, t, n, a, s));
|
|
532
|
+
}
|
|
533
|
+
r(a);
|
|
534
|
+
}, kt = function(e, t, r, n, s) {
|
|
535
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
536
|
+
if (o) {
|
|
537
|
+
if (A(t) && !e.required)
|
|
538
|
+
return r();
|
|
539
|
+
h.required(e, t, n, a, s), t !== void 0 && h.type(e, t, n, a, s);
|
|
540
|
+
}
|
|
541
|
+
r(a);
|
|
542
|
+
}, Jt = function(e, t, r, n, s) {
|
|
543
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
544
|
+
if (o) {
|
|
545
|
+
if (t === "" && (t = void 0), A(t) && !e.required)
|
|
546
|
+
return r();
|
|
547
|
+
h.required(e, t, n, a, s), t !== void 0 && (h.type(e, t, n, a, s), h.range(e, t, n, a, s));
|
|
548
|
+
}
|
|
549
|
+
r(a);
|
|
550
|
+
}, Kt = function(e, t, r, n, s) {
|
|
551
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
552
|
+
if (o) {
|
|
553
|
+
if (A(t) && !e.required)
|
|
554
|
+
return r();
|
|
555
|
+
h.required(e, t, n, a, s), t !== void 0 && h.type(e, t, n, a, s);
|
|
556
|
+
}
|
|
557
|
+
r(a);
|
|
558
|
+
}, Ht = function(e, t, r, n, s) {
|
|
559
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
560
|
+
if (o) {
|
|
561
|
+
if (A(t) && !e.required)
|
|
562
|
+
return r();
|
|
563
|
+
h.required(e, t, n, a, s), A(t) || h.type(e, t, n, a, s);
|
|
564
|
+
}
|
|
565
|
+
r(a);
|
|
566
|
+
}, Qt = function(e, t, r, n, s) {
|
|
567
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
568
|
+
if (o) {
|
|
569
|
+
if (A(t) && !e.required)
|
|
570
|
+
return r();
|
|
571
|
+
h.required(e, t, n, a, s), t !== void 0 && (h.type(e, t, n, a, s), h.range(e, t, n, a, s));
|
|
572
|
+
}
|
|
573
|
+
r(a);
|
|
574
|
+
}, Xt = function(e, t, r, n, s) {
|
|
575
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
576
|
+
if (o) {
|
|
577
|
+
if (A(t) && !e.required)
|
|
578
|
+
return r();
|
|
579
|
+
h.required(e, t, n, a, s), t !== void 0 && (h.type(e, t, n, a, s), h.range(e, t, n, a, s));
|
|
580
|
+
}
|
|
581
|
+
r(a);
|
|
582
|
+
}, er = function(e, t, r, n, s) {
|
|
583
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
584
|
+
if (o) {
|
|
585
|
+
if (t == null && !e.required)
|
|
586
|
+
return r();
|
|
587
|
+
h.required(e, t, n, a, s, "array"), t != null && (h.type(e, t, n, a, s), h.range(e, t, n, a, s));
|
|
588
|
+
}
|
|
589
|
+
r(a);
|
|
590
|
+
}, tr = function(e, t, r, n, s) {
|
|
591
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
592
|
+
if (o) {
|
|
593
|
+
if (A(t) && !e.required)
|
|
594
|
+
return r();
|
|
595
|
+
h.required(e, t, n, a, s), t !== void 0 && h.type(e, t, n, a, s);
|
|
596
|
+
}
|
|
597
|
+
r(a);
|
|
598
|
+
}, rr = "enum", nr = function(e, t, r, n, s) {
|
|
599
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
600
|
+
if (o) {
|
|
601
|
+
if (A(t) && !e.required)
|
|
602
|
+
return r();
|
|
603
|
+
h.required(e, t, n, a, s), t !== void 0 && h[rr](e, t, n, a, s);
|
|
604
|
+
}
|
|
605
|
+
r(a);
|
|
606
|
+
}, ir = function(e, t, r, n, s) {
|
|
607
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
608
|
+
if (o) {
|
|
609
|
+
if (A(t, "string") && !e.required)
|
|
610
|
+
return r();
|
|
611
|
+
h.required(e, t, n, a, s), A(t, "string") || h.pattern(e, t, n, a, s);
|
|
612
|
+
}
|
|
613
|
+
r(a);
|
|
614
|
+
}, ar = function(e, t, r, n, s) {
|
|
615
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
616
|
+
if (o) {
|
|
617
|
+
if (A(t, "date") && !e.required)
|
|
618
|
+
return r();
|
|
619
|
+
if (h.required(e, t, n, a, s), !A(t, "date")) {
|
|
620
|
+
var f;
|
|
621
|
+
t instanceof Date ? f = t : f = new Date(t), h.type(e, f, n, a, s), f && h.range(e, f.getTime(), n, a, s);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
r(a);
|
|
625
|
+
}, sr = function(e, t, r, n, s) {
|
|
626
|
+
var a = [], o = Array.isArray(t) ? "array" : typeof t;
|
|
627
|
+
h.required(e, t, n, a, s, o), r(a);
|
|
628
|
+
}, ce = function(e, t, r, n, s) {
|
|
629
|
+
var a = e.type, o = [], f = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
630
|
+
if (f) {
|
|
631
|
+
if (A(t, a) && !e.required)
|
|
632
|
+
return r();
|
|
633
|
+
h.required(e, t, n, o, s, a), A(t, a) || h.type(e, t, n, o, s);
|
|
634
|
+
}
|
|
635
|
+
r(o);
|
|
636
|
+
}, or = function(e, t, r, n, s) {
|
|
637
|
+
var a = [], o = e.required || !e.required && n.hasOwnProperty(e.field);
|
|
638
|
+
if (o) {
|
|
639
|
+
if (A(t) && !e.required)
|
|
640
|
+
return r();
|
|
641
|
+
h.required(e, t, n, a, s);
|
|
642
|
+
}
|
|
643
|
+
r(a);
|
|
644
|
+
}, k = {
|
|
645
|
+
string: Zt,
|
|
646
|
+
method: kt,
|
|
647
|
+
number: Jt,
|
|
648
|
+
boolean: Kt,
|
|
649
|
+
regexp: Ht,
|
|
650
|
+
integer: Qt,
|
|
651
|
+
float: Xt,
|
|
652
|
+
array: er,
|
|
653
|
+
object: tr,
|
|
654
|
+
enum: nr,
|
|
655
|
+
pattern: ir,
|
|
656
|
+
date: ar,
|
|
657
|
+
url: ce,
|
|
658
|
+
hex: ce,
|
|
659
|
+
email: ce,
|
|
660
|
+
required: sr,
|
|
661
|
+
any: or
|
|
662
|
+
};
|
|
663
|
+
function we() {
|
|
664
|
+
return {
|
|
665
|
+
default: "Validation error on field %s",
|
|
666
|
+
required: "%s is required",
|
|
667
|
+
enum: "%s must be one of %s",
|
|
668
|
+
whitespace: "%s cannot be empty",
|
|
669
|
+
date: {
|
|
670
|
+
format: "%s date %s is invalid for format %s",
|
|
671
|
+
parse: "%s date could not be parsed, %s is invalid ",
|
|
672
|
+
invalid: "%s date %s is invalid"
|
|
673
|
+
},
|
|
674
|
+
types: {
|
|
675
|
+
string: "%s is not a %s",
|
|
676
|
+
method: "%s is not a %s (function)",
|
|
677
|
+
array: "%s is not an %s",
|
|
678
|
+
object: "%s is not an %s",
|
|
679
|
+
number: "%s is not a %s",
|
|
680
|
+
date: "%s is not a %s",
|
|
681
|
+
boolean: "%s is not a %s",
|
|
682
|
+
integer: "%s is not an %s",
|
|
683
|
+
float: "%s is not a %s",
|
|
684
|
+
regexp: "%s is not a valid %s",
|
|
685
|
+
email: "%s is not a valid %s",
|
|
686
|
+
url: "%s is not a valid %s",
|
|
687
|
+
hex: "%s is not a valid %s"
|
|
688
|
+
},
|
|
689
|
+
string: {
|
|
690
|
+
len: "%s must be exactly %s characters",
|
|
691
|
+
min: "%s must be at least %s characters",
|
|
692
|
+
max: "%s cannot be longer than %s characters",
|
|
693
|
+
range: "%s must be between %s and %s characters"
|
|
694
|
+
},
|
|
695
|
+
number: {
|
|
696
|
+
len: "%s must equal %s",
|
|
697
|
+
min: "%s cannot be less than %s",
|
|
698
|
+
max: "%s cannot be greater than %s",
|
|
699
|
+
range: "%s must be between %s and %s"
|
|
700
|
+
},
|
|
701
|
+
array: {
|
|
702
|
+
len: "%s must be exactly %s in length",
|
|
703
|
+
min: "%s cannot be less than %s in length",
|
|
704
|
+
max: "%s cannot be greater than %s in length",
|
|
705
|
+
range: "%s must be between %s and %s in length"
|
|
706
|
+
},
|
|
707
|
+
pattern: {
|
|
708
|
+
mismatch: "%s value %s does not match pattern %s"
|
|
709
|
+
},
|
|
710
|
+
clone: function() {
|
|
711
|
+
var e = JSON.parse(JSON.stringify(this));
|
|
712
|
+
return e.clone = this.clone, e;
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
var Fe = we(), K = /* @__PURE__ */ (function() {
|
|
717
|
+
function i(t) {
|
|
718
|
+
this.rules = null, this._messages = Fe, this.define(t);
|
|
719
|
+
}
|
|
720
|
+
var e = i.prototype;
|
|
721
|
+
return e.define = function(r) {
|
|
722
|
+
var n = this;
|
|
723
|
+
if (!r)
|
|
724
|
+
throw new Error("Cannot configure a schema with no rules");
|
|
725
|
+
if (typeof r != "object" || Array.isArray(r))
|
|
726
|
+
throw new Error("Rules must be an object");
|
|
727
|
+
this.rules = {}, Object.keys(r).forEach(function(s) {
|
|
728
|
+
var a = r[s];
|
|
729
|
+
n.rules[s] = Array.isArray(a) ? a : [a];
|
|
730
|
+
});
|
|
731
|
+
}, e.messages = function(r) {
|
|
732
|
+
return r && (this._messages = Be(we(), r)), this._messages;
|
|
733
|
+
}, e.validate = function(r, n, s) {
|
|
734
|
+
var a = this;
|
|
735
|
+
n === void 0 && (n = {}), s === void 0 && (s = function() {
|
|
736
|
+
});
|
|
737
|
+
var o = r, f = n, F = s;
|
|
738
|
+
if (typeof f == "function" && (F = f, f = {}), !this.rules || Object.keys(this.rules).length === 0)
|
|
739
|
+
return F && F(null, o), Promise.resolve(o);
|
|
740
|
+
function p(d) {
|
|
741
|
+
var y = [], l = {};
|
|
742
|
+
function R(q) {
|
|
743
|
+
if (Array.isArray(q)) {
|
|
744
|
+
var c;
|
|
745
|
+
y = (c = y).concat.apply(c, q);
|
|
746
|
+
} else
|
|
747
|
+
y.push(q);
|
|
748
|
+
}
|
|
749
|
+
for (var v = 0; v < d.length; v++)
|
|
750
|
+
R(d[v]);
|
|
751
|
+
y.length ? (l = be(y), F(y, l)) : F(null, o);
|
|
752
|
+
}
|
|
753
|
+
if (f.messages) {
|
|
754
|
+
var g = this.messages();
|
|
755
|
+
g === Fe && (g = we()), Be(g, f.messages), f.messages = g;
|
|
756
|
+
} else
|
|
757
|
+
f.messages = this.messages();
|
|
758
|
+
var w = {}, O = f.keys || Object.keys(this.rules);
|
|
759
|
+
O.forEach(function(d) {
|
|
760
|
+
var y = a.rules[d], l = o[d];
|
|
761
|
+
y.forEach(function(R) {
|
|
762
|
+
var v = R;
|
|
763
|
+
typeof v.transform == "function" && (o === r && (o = C({}, o)), l = o[d] = v.transform(l)), typeof v == "function" ? v = {
|
|
764
|
+
validator: v
|
|
765
|
+
} : v = C({}, v), v.validator = a.getValidationMethod(v), v.validator && (v.field = d, v.fullField = v.fullField || d, v.type = a.getType(v), w[d] = w[d] || [], w[d].push({
|
|
766
|
+
rule: v,
|
|
767
|
+
value: l,
|
|
768
|
+
source: o,
|
|
769
|
+
field: d
|
|
770
|
+
}));
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
var P = {};
|
|
774
|
+
return Lt(w, f, function(d, y) {
|
|
775
|
+
var l = d.rule, R = (l.type === "object" || l.type === "array") && (typeof l.fields == "object" || typeof l.defaultField == "object");
|
|
776
|
+
R = R && (l.required || !l.required && d.value), l.field = d.field;
|
|
777
|
+
function v(m, x) {
|
|
778
|
+
return C({}, x, {
|
|
779
|
+
fullField: l.fullField + "." + m,
|
|
780
|
+
fullFields: l.fullFields ? [].concat(l.fullFields, [m]) : [m]
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
function q(m) {
|
|
784
|
+
m === void 0 && (m = []);
|
|
785
|
+
var x = Array.isArray(m) ? m : [m];
|
|
786
|
+
!f.suppressWarning && x.length && i.warning("async-validator:", x), x.length && l.message !== void 0 && (x = [].concat(l.message));
|
|
787
|
+
var E = x.map(Le(l, o));
|
|
788
|
+
if (f.first && E.length)
|
|
789
|
+
return P[l.field] = 1, y(E);
|
|
790
|
+
if (!R)
|
|
791
|
+
y(E);
|
|
792
|
+
else {
|
|
793
|
+
if (l.required && !d.value)
|
|
794
|
+
return l.message !== void 0 ? E = [].concat(l.message).map(Le(l, o)) : f.error && (E = [f.error(l, W(f.messages.required, l.field))]), y(E);
|
|
795
|
+
var N = {};
|
|
796
|
+
l.defaultField && Object.keys(d.value).map(function(V) {
|
|
797
|
+
N[V] = l.defaultField;
|
|
798
|
+
}), N = C({}, N, d.rule.fields);
|
|
799
|
+
var B = {};
|
|
800
|
+
Object.keys(N).forEach(function(V) {
|
|
801
|
+
var I = N[V], oe = Array.isArray(I) ? I : [I];
|
|
802
|
+
B[V] = oe.map(v.bind(null, V));
|
|
803
|
+
});
|
|
804
|
+
var $ = new i(B);
|
|
805
|
+
$.messages(f.messages), d.rule.options && (d.rule.options.messages = f.messages, d.rule.options.error = f.error), $.validate(d.value, d.rule.options || f, function(V) {
|
|
806
|
+
var I = [];
|
|
807
|
+
E && E.length && I.push.apply(I, E), V && V.length && I.push.apply(I, V), y(I.length ? I : null);
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
var c;
|
|
812
|
+
if (l.asyncValidator)
|
|
813
|
+
c = l.asyncValidator(l, d.value, q, d.source, f);
|
|
814
|
+
else if (l.validator) {
|
|
815
|
+
try {
|
|
816
|
+
c = l.validator(l, d.value, q, d.source, f);
|
|
817
|
+
} catch (m) {
|
|
818
|
+
console.error == null, f.suppressValidatorError || setTimeout(function() {
|
|
819
|
+
throw m;
|
|
820
|
+
}, 0), q(m.message);
|
|
821
|
+
}
|
|
822
|
+
c === !0 ? q() : c === !1 ? q(typeof l.message == "function" ? l.message(l.fullField || l.field) : l.message || (l.fullField || l.field) + " fails") : c instanceof Array ? q(c) : c instanceof Error && q(c.message);
|
|
823
|
+
}
|
|
824
|
+
c && c.then && c.then(function() {
|
|
825
|
+
return q();
|
|
826
|
+
}, function(m) {
|
|
827
|
+
return q(m);
|
|
828
|
+
});
|
|
829
|
+
}, function(d) {
|
|
830
|
+
p(d);
|
|
831
|
+
}, o);
|
|
832
|
+
}, e.getType = function(r) {
|
|
833
|
+
if (r.type === void 0 && r.pattern instanceof RegExp && (r.type = "pattern"), typeof r.validator != "function" && r.type && !k.hasOwnProperty(r.type))
|
|
834
|
+
throw new Error(W("Unknown rule type %s", r.type));
|
|
835
|
+
return r.type || "string";
|
|
836
|
+
}, e.getValidationMethod = function(r) {
|
|
837
|
+
if (typeof r.validator == "function")
|
|
838
|
+
return r.validator;
|
|
839
|
+
var n = Object.keys(r), s = n.indexOf("message");
|
|
840
|
+
return s !== -1 && n.splice(s, 1), n.length === 1 && n[0] === "required" ? k.required : k[this.getType(r)] || void 0;
|
|
841
|
+
}, i;
|
|
842
|
+
})();
|
|
843
|
+
K.register = function(e, t) {
|
|
844
|
+
if (typeof t != "function")
|
|
845
|
+
throw new Error("Cannot register a validator by type, validator is not a function");
|
|
846
|
+
k[e] = t;
|
|
847
|
+
};
|
|
848
|
+
K.warning = Xe;
|
|
849
|
+
K.messages = Fe;
|
|
850
|
+
K.validators = k;
|
|
851
|
+
const fr = [
|
|
852
|
+
"",
|
|
853
|
+
"error",
|
|
854
|
+
"validating",
|
|
855
|
+
"success"
|
|
856
|
+
], lr = xe({
|
|
857
|
+
label: String,
|
|
858
|
+
labelWidth: {
|
|
859
|
+
type: [String, Number]
|
|
860
|
+
},
|
|
861
|
+
labelPosition: {
|
|
862
|
+
type: String,
|
|
863
|
+
values: ["left", "right", "top", ""],
|
|
864
|
+
default: ""
|
|
865
|
+
},
|
|
866
|
+
prop: {
|
|
867
|
+
type: se([String, Array])
|
|
868
|
+
},
|
|
869
|
+
required: {
|
|
870
|
+
type: Boolean,
|
|
871
|
+
default: void 0
|
|
872
|
+
},
|
|
873
|
+
rules: {
|
|
874
|
+
type: se([Object, Array])
|
|
875
|
+
},
|
|
876
|
+
error: String,
|
|
877
|
+
validateStatus: {
|
|
878
|
+
type: String,
|
|
879
|
+
values: fr
|
|
880
|
+
},
|
|
881
|
+
for: String,
|
|
882
|
+
inlineMessage: {
|
|
883
|
+
type: Boolean,
|
|
884
|
+
default: void 0
|
|
885
|
+
},
|
|
886
|
+
showMessage: {
|
|
887
|
+
type: Boolean,
|
|
888
|
+
default: !0
|
|
889
|
+
},
|
|
890
|
+
size: {
|
|
891
|
+
type: String,
|
|
892
|
+
values: Je
|
|
893
|
+
}
|
|
894
|
+
}), Ce = "ElLabelWrap";
|
|
895
|
+
var ur = qe({
|
|
896
|
+
name: Ce,
|
|
897
|
+
props: {
|
|
898
|
+
isAutoWidth: Boolean,
|
|
899
|
+
updateAll: Boolean
|
|
900
|
+
},
|
|
901
|
+
setup(i, {
|
|
902
|
+
slots: e
|
|
903
|
+
}) {
|
|
904
|
+
const t = ne(Ee, void 0), r = ne(he);
|
|
905
|
+
r || gt(Ce, "usage: <el-form-item><label-wrap /></el-form-item>");
|
|
906
|
+
const n = Oe("form"), s = L(), a = L(0), o = () => {
|
|
907
|
+
var p;
|
|
908
|
+
if ((p = s.value) != null && p.firstElementChild) {
|
|
909
|
+
const g = window.getComputedStyle(s.value.firstElementChild).width;
|
|
910
|
+
return Math.ceil(Number.parseFloat(g));
|
|
911
|
+
} else
|
|
912
|
+
return 0;
|
|
913
|
+
}, f = (p = "update") => {
|
|
914
|
+
Ze(() => {
|
|
915
|
+
e.default && i.isAutoWidth && (p === "update" ? a.value = o() : p === "remove" && t?.deregisterLabelWidth(a.value));
|
|
916
|
+
});
|
|
917
|
+
}, F = () => f("update");
|
|
918
|
+
return Ge(() => {
|
|
919
|
+
F();
|
|
920
|
+
}), Ye(() => {
|
|
921
|
+
f("remove");
|
|
922
|
+
}), lt(() => F()), re(a, (p, g) => {
|
|
923
|
+
i.updateAll && t?.registerLabelWidth(p, g);
|
|
924
|
+
}), yt(_(() => {
|
|
925
|
+
var p, g;
|
|
926
|
+
return (g = (p = s.value) == null ? void 0 : p.firstElementChild) != null ? g : null;
|
|
927
|
+
}), F), () => {
|
|
928
|
+
var p, g;
|
|
929
|
+
if (!e)
|
|
930
|
+
return null;
|
|
931
|
+
const {
|
|
932
|
+
isAutoWidth: w
|
|
933
|
+
} = i;
|
|
934
|
+
if (w) {
|
|
935
|
+
const O = t?.autoLabelWidth, P = r?.hasLabel, d = {};
|
|
936
|
+
if (P && O && O !== "auto") {
|
|
937
|
+
const y = Math.max(0, Number.parseInt(O, 10) - a.value), R = (r.labelPosition || t.labelPosition) === "left" ? "marginRight" : "marginLeft";
|
|
938
|
+
y && (d[R] = `${y}px`);
|
|
939
|
+
}
|
|
940
|
+
return ie("div", {
|
|
941
|
+
ref: s,
|
|
942
|
+
class: [n.be("item", "label-wrap")],
|
|
943
|
+
style: d
|
|
944
|
+
}, [(p = e.default) == null ? void 0 : p.call(e)]);
|
|
945
|
+
} else
|
|
946
|
+
return ie(ut, {
|
|
947
|
+
ref: s
|
|
948
|
+
}, [(g = e.default) == null ? void 0 : g.call(e)]);
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
const dr = ["role", "aria-labelledby"], cr = qe({
|
|
953
|
+
name: "ElFormItem",
|
|
954
|
+
__name: "form-item",
|
|
955
|
+
props: lr,
|
|
956
|
+
setup(i, { expose: e }) {
|
|
957
|
+
const t = i, r = dt(), n = ne(Ee, void 0), s = ne(he, void 0), a = He(void 0, { formItem: !1 }), o = Oe("form-item"), f = bt().value, F = L([]), p = L(""), g = wt(p, 100), w = L(""), O = L();
|
|
958
|
+
let P, d = !1;
|
|
959
|
+
const y = _(
|
|
960
|
+
() => t.labelPosition || n?.labelPosition
|
|
961
|
+
), l = _(() => {
|
|
962
|
+
var u;
|
|
963
|
+
return y.value === "top" ? {} : { width: We((u = t.labelWidth) != null ? u : n?.labelWidth) };
|
|
964
|
+
}), R = _(() => {
|
|
965
|
+
var u;
|
|
966
|
+
if (y.value === "top" || n?.inline)
|
|
967
|
+
return {};
|
|
968
|
+
if (!t.label && !t.labelWidth && B)
|
|
969
|
+
return {};
|
|
970
|
+
const b = We((u = t.labelWidth) != null ? u : n?.labelWidth);
|
|
971
|
+
return !t.label && !r.label ? { marginLeft: b } : {};
|
|
972
|
+
}), v = _(() => [
|
|
973
|
+
o.b(),
|
|
974
|
+
o.m(a.value),
|
|
975
|
+
o.is("error", p.value === "error"),
|
|
976
|
+
o.is("validating", p.value === "validating"),
|
|
977
|
+
o.is("success", p.value === "success"),
|
|
978
|
+
o.is("required", rt.value || t.required),
|
|
979
|
+
o.is("no-asterisk", n?.hideRequiredAsterisk),
|
|
980
|
+
n?.requireAsteriskPosition === "right" ? "asterisk-right" : "asterisk-left",
|
|
981
|
+
{
|
|
982
|
+
[o.m("feedback")]: n?.statusIcon,
|
|
983
|
+
[o.m(`label-${y.value}`)]: y.value
|
|
984
|
+
}
|
|
985
|
+
]), q = _(
|
|
986
|
+
() => ke(t.inlineMessage) ? t.inlineMessage : n?.inlineMessage || !1
|
|
987
|
+
), c = _(() => [
|
|
988
|
+
o.e("error"),
|
|
989
|
+
{ [o.em("error", "inline")]: q.value }
|
|
990
|
+
]), m = _(() => t.prop ? ae(t.prop) ? t.prop.join(".") : t.prop : ""), x = _(() => !!(t.label || r.label)), E = _(() => {
|
|
991
|
+
var u;
|
|
992
|
+
return (u = t.for) != null ? u : F.value.length === 1 ? F.value[0] : void 0;
|
|
993
|
+
}), N = _(() => !E.value && x.value), B = !!s, $ = _(() => {
|
|
994
|
+
const u = n?.model;
|
|
995
|
+
if (!(!u || !t.prop))
|
|
996
|
+
return de(u, t.prop).value;
|
|
997
|
+
}), V = _(() => {
|
|
998
|
+
const { required: u } = t, b = [];
|
|
999
|
+
t.rules && b.push(...me(t.rules));
|
|
1000
|
+
const j = n?.rules;
|
|
1001
|
+
if (j && t.prop) {
|
|
1002
|
+
const S = de(
|
|
1003
|
+
j,
|
|
1004
|
+
t.prop
|
|
1005
|
+
).value;
|
|
1006
|
+
S && b.push(...me(S));
|
|
1007
|
+
}
|
|
1008
|
+
if (u !== void 0) {
|
|
1009
|
+
const S = b.map((M, z) => [M, z]).filter(([M]) => "required" in M);
|
|
1010
|
+
if (S.length > 0)
|
|
1011
|
+
for (const [M, z] of S)
|
|
1012
|
+
M.required !== u && (b[z] = { ...M, required: u });
|
|
1013
|
+
else
|
|
1014
|
+
b.push({ required: u });
|
|
1015
|
+
}
|
|
1016
|
+
return b;
|
|
1017
|
+
}), I = _(() => V.value.length > 0), oe = (u) => V.value.filter((j) => !j.trigger || !u ? !0 : ae(j.trigger) ? j.trigger.includes(u) : j.trigger === u).map(({ trigger: j, ...S }) => S), rt = _(
|
|
1018
|
+
() => V.value.some((u) => u.required)
|
|
1019
|
+
), nt = _(
|
|
1020
|
+
() => {
|
|
1021
|
+
var u;
|
|
1022
|
+
return g.value === "error" && t.showMessage && ((u = n?.showMessage) != null ? u : !0);
|
|
1023
|
+
}
|
|
1024
|
+
), _e = _(
|
|
1025
|
+
() => `${t.label || ""}${n?.labelSuffix || ""}`
|
|
1026
|
+
), D = (u) => {
|
|
1027
|
+
p.value = u;
|
|
1028
|
+
}, it = (u) => {
|
|
1029
|
+
var b, j;
|
|
1030
|
+
const { errors: S, fields: M } = u;
|
|
1031
|
+
D("error"), w.value = S ? (j = (b = S?.[0]) == null ? void 0 : b.message) != null ? j : `${t.prop} is required` : "", n?.emit("validate", t.prop, !1, w.value);
|
|
1032
|
+
}, at = () => {
|
|
1033
|
+
D("success"), n?.emit("validate", t.prop, !0, "");
|
|
1034
|
+
}, st = async (u) => {
|
|
1035
|
+
const b = m.value;
|
|
1036
|
+
return new K({
|
|
1037
|
+
[b]: u
|
|
1038
|
+
}).validate({ [b]: $.value }, { firstFields: !0 }).then(() => (at(), !0)).catch((S) => (it(S), Promise.reject(S)));
|
|
1039
|
+
}, Pe = async (u, b) => {
|
|
1040
|
+
if (d || !t.prop)
|
|
1041
|
+
return !1;
|
|
1042
|
+
const j = Qe(b);
|
|
1043
|
+
if (!I.value)
|
|
1044
|
+
return b?.(!1), !1;
|
|
1045
|
+
const S = oe(u);
|
|
1046
|
+
return S.length === 0 ? (b?.(!0), !0) : (D("validating"), st(S).then(() => (b?.(!0), !0)).catch((M) => {
|
|
1047
|
+
const { fields: z } = M;
|
|
1048
|
+
return b?.(!1, z), j ? !1 : Promise.reject(z);
|
|
1049
|
+
}));
|
|
1050
|
+
}, fe = () => {
|
|
1051
|
+
D(""), w.value = "", d = !1;
|
|
1052
|
+
}, Ae = async () => {
|
|
1053
|
+
const u = n?.model;
|
|
1054
|
+
if (!u || !t.prop)
|
|
1055
|
+
return;
|
|
1056
|
+
const b = de(u, t.prop);
|
|
1057
|
+
d = !0, b.value = Ie(P), await Ze(), fe(), d = !1;
|
|
1058
|
+
}, ot = (u) => {
|
|
1059
|
+
F.value.includes(u) || F.value.push(u);
|
|
1060
|
+
}, ft = (u) => {
|
|
1061
|
+
F.value = F.value.filter((b) => b !== u);
|
|
1062
|
+
};
|
|
1063
|
+
re(
|
|
1064
|
+
() => t.error,
|
|
1065
|
+
(u) => {
|
|
1066
|
+
w.value = u || "", D(u ? "error" : "");
|
|
1067
|
+
},
|
|
1068
|
+
{ immediate: !0 }
|
|
1069
|
+
), re(
|
|
1070
|
+
() => t.validateStatus,
|
|
1071
|
+
(u) => D(u || "")
|
|
1072
|
+
);
|
|
1073
|
+
const le = pe({
|
|
1074
|
+
...ze(t),
|
|
1075
|
+
$el: O,
|
|
1076
|
+
size: a,
|
|
1077
|
+
validateMessage: w,
|
|
1078
|
+
validateState: p,
|
|
1079
|
+
labelId: f,
|
|
1080
|
+
inputIds: F,
|
|
1081
|
+
isGroup: N,
|
|
1082
|
+
hasLabel: x,
|
|
1083
|
+
fieldValue: $,
|
|
1084
|
+
addInputId: ot,
|
|
1085
|
+
removeInputId: ft,
|
|
1086
|
+
resetField: Ae,
|
|
1087
|
+
clearValidate: fe,
|
|
1088
|
+
validate: Pe,
|
|
1089
|
+
propString: m
|
|
1090
|
+
});
|
|
1091
|
+
return De(he, le), Ge(() => {
|
|
1092
|
+
t.prop && (n?.addField(le), P = Ie($.value));
|
|
1093
|
+
}), Ye(() => {
|
|
1094
|
+
n?.removeField(le);
|
|
1095
|
+
}), e({
|
|
1096
|
+
size: a,
|
|
1097
|
+
validateMessage: w,
|
|
1098
|
+
validateState: p,
|
|
1099
|
+
validate: Pe,
|
|
1100
|
+
clearValidate: fe,
|
|
1101
|
+
resetField: Ae
|
|
1102
|
+
}), (u, b) => {
|
|
1103
|
+
var j;
|
|
1104
|
+
return ve(), Ue("div", {
|
|
1105
|
+
ref_key: "formItemRef",
|
|
1106
|
+
ref: O,
|
|
1107
|
+
class: G(v.value),
|
|
1108
|
+
role: N.value ? "group" : void 0,
|
|
1109
|
+
"aria-labelledby": N.value ? T(f) : void 0
|
|
1110
|
+
}, [
|
|
1111
|
+
ie(T(ur), {
|
|
1112
|
+
"is-auto-width": l.value.width === "auto",
|
|
1113
|
+
"update-all": ((j = T(n)) == null ? void 0 : j.labelWidth) === "auto"
|
|
1114
|
+
}, {
|
|
1115
|
+
default: ue(() => [
|
|
1116
|
+
u.label || u.$slots.label ? (ve(), ct(pt(E.value ? "label" : "div"), {
|
|
1117
|
+
key: 0,
|
|
1118
|
+
id: T(f),
|
|
1119
|
+
for: E.value,
|
|
1120
|
+
class: G(T(o).e("label")),
|
|
1121
|
+
style: Re(l.value)
|
|
1122
|
+
}, {
|
|
1123
|
+
default: ue(() => [
|
|
1124
|
+
ee(u.$slots, "label", { label: _e.value }, () => [
|
|
1125
|
+
vt(
|
|
1126
|
+
Ne(_e.value),
|
|
1127
|
+
1
|
|
1128
|
+
)
|
|
1129
|
+
])
|
|
1130
|
+
]),
|
|
1131
|
+
_: 3
|
|
1132
|
+
}, 8, ["id", "for", "class", "style"])) : je("v-if", !0)
|
|
1133
|
+
]),
|
|
1134
|
+
_: 3
|
|
1135
|
+
}, 8, ["is-auto-width", "update-all"]),
|
|
1136
|
+
Se(
|
|
1137
|
+
"div",
|
|
1138
|
+
{
|
|
1139
|
+
class: G(T(o).e("content")),
|
|
1140
|
+
style: Re(R.value)
|
|
1141
|
+
},
|
|
1142
|
+
[
|
|
1143
|
+
ee(u.$slots, "default"),
|
|
1144
|
+
ie(mt, {
|
|
1145
|
+
name: `${T(o).namespace.value}-zoom-in-top`
|
|
1146
|
+
}, {
|
|
1147
|
+
default: ue(() => [
|
|
1148
|
+
nt.value ? ee(u.$slots, "error", {
|
|
1149
|
+
key: 0,
|
|
1150
|
+
error: w.value
|
|
1151
|
+
}, () => [
|
|
1152
|
+
Se(
|
|
1153
|
+
"div",
|
|
1154
|
+
{
|
|
1155
|
+
class: G(c.value)
|
|
1156
|
+
},
|
|
1157
|
+
Ne(w.value),
|
|
1158
|
+
3
|
|
1159
|
+
)
|
|
1160
|
+
]) : je("v-if", !0)
|
|
1161
|
+
]),
|
|
1162
|
+
_: 3
|
|
1163
|
+
}, 8, ["name"])
|
|
1164
|
+
],
|
|
1165
|
+
6
|
|
1166
|
+
)
|
|
1167
|
+
], 10, dr);
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
var tt = /* @__PURE__ */ Ke(cr, [["__file", "/home/runner/work/element-plus/element-plus/packages/components/form/src/form-item.vue"]]);
|
|
1172
|
+
const mr = Ft(jt, {
|
|
1173
|
+
FormItem: tt
|
|
1174
|
+
}), hr = qt(tt);
|
|
1175
|
+
export {
|
|
1176
|
+
mr as E,
|
|
1177
|
+
hr as a
|
|
1178
|
+
};
|