@overgaming/valiform 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { inject as A, shallowRef as B, isRef as
|
|
1
|
+
import { inject as A, shallowRef as B, isRef as te, ref as h, readonly as w, provide as x, defineComponent as R, useModel as W, isReactive as ne, reactive as re, computed as b, openBlock as L, createElementBlock as _, withModifiers as se, renderSlot as z, normalizeProps as I, guardReactiveProps as K, mergeModels as U, watch as Z, toValue as $, useId as oe, onMounted as ae, onUnmounted as ue, unref as ie } from "vue";
|
|
2
2
|
const k = Symbol("locale-context"), Y = (e = null) => {
|
|
3
3
|
const t = A(k, e);
|
|
4
4
|
if (!t && t !== null)
|
|
5
5
|
throw new Error("Context with localeContextKey not found");
|
|
6
6
|
return t;
|
|
7
|
-
},
|
|
7
|
+
}, ce = {
|
|
8
8
|
required: "This field is required",
|
|
9
9
|
email: "Please enter a valid email address",
|
|
10
10
|
min: ({ value: e }) => `Must be at least ${e}`,
|
|
@@ -39,227 +39,227 @@ const k = Symbol("locale-context"), Y = (e = null) => {
|
|
|
39
39
|
symbol: "Must contain only symbols",
|
|
40
40
|
uppercase: "Must contain only uppercase characters",
|
|
41
41
|
url: "Must be a valid URL"
|
|
42
|
-
}, G = B(/* @__PURE__ */ new Map()),
|
|
42
|
+
}, G = B(/* @__PURE__ */ new Map()), le = (e, t) => {
|
|
43
43
|
G.value.set(e, t);
|
|
44
44
|
}, P = (e) => {
|
|
45
45
|
Object.entries(e).forEach(([t, n]) => {
|
|
46
|
-
|
|
46
|
+
le(t, n);
|
|
47
47
|
});
|
|
48
|
-
},
|
|
49
|
-
function
|
|
48
|
+
}, fe = (e) => G.value.get(e);
|
|
49
|
+
function me(e) {
|
|
50
50
|
const t = e.accepted;
|
|
51
51
|
return typeof t == "function" ? t({}) : t ?? "Must be accepted";
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function de(e) {
|
|
54
54
|
return e ? ["yes", "on", "1", "true"].includes(String(e).toLowerCase()) : !1;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function ge(e, t = {}) {
|
|
57
57
|
const { messages: n = {} } = t;
|
|
58
|
-
return
|
|
58
|
+
return de(e) ? !0 : me(n);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function pe(e) {
|
|
61
61
|
const t = e.alpha;
|
|
62
62
|
return typeof t == "function" ? t({}) : t ?? "Must contain only alphabetical characters";
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function be(e) {
|
|
65
65
|
return e ? /^[a-zA-Z]+$/.test(String(e)) : !0;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function ye(e, t = {}) {
|
|
68
68
|
const { messages: n = {} } = t;
|
|
69
|
-
return
|
|
69
|
+
return be(e) ? !0 : pe(n);
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function $e(e) {
|
|
72
72
|
const t = e.alphanumeric;
|
|
73
73
|
return typeof t == "function" ? t({}) : t ?? "Must contain only letters and numbers";
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function he(e) {
|
|
76
76
|
return e ? /^[a-zA-Z0-9]+$/.test(String(e)) : !0;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function ve(e, t = {}) {
|
|
79
79
|
const { messages: n = {} } = t;
|
|
80
|
-
return
|
|
80
|
+
return he(e) ? !0 : $e(n);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function Me(e) {
|
|
83
83
|
const t = e.alphaSpaces;
|
|
84
84
|
return typeof t == "function" ? t({}) : t ?? "Must contain only letters and spaces";
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function Ne(e) {
|
|
87
87
|
return e ? /^[a-zA-Z\s]+$/.test(String(e)) : !0;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function we(e, t = {}) {
|
|
90
90
|
const { messages: n = {} } = t;
|
|
91
|
-
return
|
|
91
|
+
return Ne(e) ? !0 : Me(n);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function Ae(e, t, n) {
|
|
94
94
|
const r = e.between;
|
|
95
95
|
return typeof r == "function" ? r({ min: t, max: n }) : r ?? `Must be between ${t} and ${n}`;
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function De(e, t, n) {
|
|
98
98
|
if (!e && e !== 0) return !0;
|
|
99
99
|
const r = Number(e);
|
|
100
100
|
if (isNaN(r)) return !1;
|
|
101
101
|
const s = Number(t), o = Number(n);
|
|
102
102
|
return isNaN(s) || isNaN(o) ? !1 : r >= s && r <= o;
|
|
103
103
|
}
|
|
104
|
-
function
|
|
104
|
+
function Se(e, t = {}) {
|
|
105
105
|
const { args: n = [], messages: r = {} } = t, [s, o] = n;
|
|
106
|
-
return
|
|
106
|
+
return De(e, s, o) ? !0 : Ae(r, s, o);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Fe(e, t) {
|
|
109
109
|
const n = e.confirm;
|
|
110
110
|
return typeof n == "function" ? n({ fieldName: t }) : n ?? `Must match ${t}`;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function xe(e, t, n) {
|
|
113
113
|
var r;
|
|
114
114
|
return e ? n ? e === ((r = n[t]) == null ? void 0 : r.value) : !1 : !0;
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function je(e, t = {}) {
|
|
117
117
|
const { args: n = [], messages: r = {}, fields: s = {} } = t, [o] = n;
|
|
118
|
-
return
|
|
118
|
+
return xe(e, o, s) ? !0 : Fe(r, o);
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function Te(e) {
|
|
121
121
|
const t = e.containsAlpha;
|
|
122
122
|
return typeof t == "function" ? t({}) : t ?? "Must contain at least one letter";
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function Ve(e) {
|
|
125
125
|
return e ? /[a-zA-Z]/.test(String(e)) : !0;
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function qe(e, t = {}) {
|
|
128
128
|
const { messages: n = {} } = t;
|
|
129
|
-
return
|
|
129
|
+
return Ve(e) ? !0 : Te(n);
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function Ce(e) {
|
|
132
132
|
const t = e.containsAlphanumeric;
|
|
133
133
|
return typeof t == "function" ? t({}) : t ?? "Must contain at least one letter or number";
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function Pe(e) {
|
|
136
136
|
return e ? /[a-zA-Z0-9]/.test(String(e)) : !0;
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function Ee(e, t = {}) {
|
|
139
139
|
const { messages: n = {} } = t;
|
|
140
|
-
return
|
|
140
|
+
return Pe(e) ? !0 : Ce(n);
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function Oe(e) {
|
|
143
143
|
const t = e.containsAlphaSpaces;
|
|
144
144
|
return typeof t == "function" ? t({}) : t ?? "Must contain at least one letter or space";
|
|
145
145
|
}
|
|
146
|
-
function
|
|
146
|
+
function Be(e) {
|
|
147
147
|
return e ? /[a-zA-Z\s]/.test(String(e)) : !0;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function Re(e, t = {}) {
|
|
150
150
|
const { messages: n = {} } = t;
|
|
151
|
-
return
|
|
151
|
+
return Be(e) ? !0 : Oe(n);
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function We(e) {
|
|
154
154
|
const t = e.containsLowercase;
|
|
155
155
|
return typeof t == "function" ? t({}) : t ?? "Must contain at least one lowercase letter";
|
|
156
156
|
}
|
|
157
|
-
function
|
|
157
|
+
function Le(e) {
|
|
158
158
|
return e ? /[a-z]/.test(String(e)) : !0;
|
|
159
159
|
}
|
|
160
|
-
function
|
|
160
|
+
function _e(e, t = {}) {
|
|
161
161
|
const { messages: n = {} } = t;
|
|
162
|
-
return
|
|
162
|
+
return Le(e) ? !0 : We(n);
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function ze(e) {
|
|
165
165
|
const t = e.containsNumeric;
|
|
166
166
|
return typeof t == "function" ? t({}) : t ?? "Must contain at least one number";
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function Ie(e) {
|
|
169
169
|
return e ? /\d/.test(String(e)) : !0;
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function Ke(e, t = {}) {
|
|
172
172
|
const { messages: n = {} } = t;
|
|
173
|
-
return
|
|
173
|
+
return Ie(e) ? !0 : ze(n);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function Ue(e) {
|
|
176
176
|
const t = e.containsSymbol;
|
|
177
177
|
return typeof t == "function" ? t({}) : t ?? "Must contain at least one symbol";
|
|
178
178
|
}
|
|
179
|
-
function
|
|
179
|
+
function Ze(e) {
|
|
180
180
|
return e ? /[^\w\s]/.test(String(e)) : !0;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
182
|
+
function ke(e, t = {}) {
|
|
183
183
|
const { messages: n = {} } = t;
|
|
184
|
-
return
|
|
184
|
+
return Ze(e) ? !0 : Ue(n);
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function Ye(e) {
|
|
187
187
|
const t = e.containsUppercase;
|
|
188
188
|
return typeof t == "function" ? t({}) : t ?? "Must contain at least one uppercase letter";
|
|
189
189
|
}
|
|
190
|
-
function
|
|
190
|
+
function Ge(e) {
|
|
191
191
|
return e ? /[A-Z]/.test(String(e)) : !0;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function He(e, t = {}) {
|
|
194
194
|
const { messages: n = {} } = t;
|
|
195
|
-
return
|
|
195
|
+
return Ge(e) ? !0 : Ye(n);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function Je(e, t) {
|
|
198
198
|
const n = e.dateAfter;
|
|
199
199
|
return typeof n == "function" ? n({ date: t }) : n ?? (t ? `Must be after ${t}` : "Must be after today");
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function Qe(e, t) {
|
|
202
202
|
if (!e) return !0;
|
|
203
203
|
const n = new Date(String(e)), r = t ? new Date(t) : /* @__PURE__ */ new Date();
|
|
204
204
|
return !isNaN(n.getTime()) && !isNaN(r.getTime()) && n > r;
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function Xe(e, t = {}) {
|
|
207
207
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
208
|
-
return
|
|
208
|
+
return Qe(e, s) ? !0 : Je(r, s);
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function et(e, t) {
|
|
211
211
|
const n = e.dateAfterOrEqual;
|
|
212
212
|
return typeof n == "function" ? n({ date: t }) : n ?? (t ? `Must be after or equal to ${t}` : "Must be after or equal to today");
|
|
213
213
|
}
|
|
214
|
-
function
|
|
214
|
+
function tt(e, t) {
|
|
215
215
|
if (!e) return !0;
|
|
216
216
|
const n = new Date(String(e)), r = t ? new Date(t) : /* @__PURE__ */ new Date();
|
|
217
217
|
return !isNaN(n.getTime()) && !isNaN(r.getTime()) && n >= r;
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function nt(e, t = {}) {
|
|
220
220
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
221
|
-
return
|
|
221
|
+
return tt(e, s) ? !0 : et(r, s);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function rt(e, t) {
|
|
224
224
|
const n = e.dateBefore;
|
|
225
225
|
return typeof n == "function" ? n({ date: t }) : n ?? (t ? `Must be before ${t}` : "Must be before today");
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function st(e, t) {
|
|
228
228
|
if (!e) return !0;
|
|
229
229
|
const n = new Date(String(e)), r = t ? new Date(t) : /* @__PURE__ */ new Date();
|
|
230
230
|
return !isNaN(n.getTime()) && !isNaN(r.getTime()) && n < r;
|
|
231
231
|
}
|
|
232
|
-
function
|
|
232
|
+
function ot(e, t = {}) {
|
|
233
233
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
234
|
-
return
|
|
234
|
+
return st(e, s) ? !0 : rt(r, s);
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function at(e, t) {
|
|
237
237
|
const n = e.dateBeforeOrEqual;
|
|
238
238
|
return typeof n == "function" ? n({ date: t }) : n ?? (t ? `Must be before or equal to ${t}` : "Must be before or equal to today");
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function ut(e, t) {
|
|
241
241
|
if (!e) return !0;
|
|
242
242
|
const n = new Date(String(e)), r = t ? new Date(t) : /* @__PURE__ */ new Date();
|
|
243
243
|
return !isNaN(n.getTime()) && !isNaN(r.getTime()) && n <= r;
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function it(e, t = {}) {
|
|
246
246
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
247
|
-
return
|
|
247
|
+
return ut(e, s) ? !0 : at(r, s);
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function ct(e, t, n) {
|
|
250
250
|
const r = e.dateBetween;
|
|
251
251
|
return typeof r == "function" ? r({ startDate: t, endDate: n }) : r ?? `Must be between ${t} and ${n}`;
|
|
252
252
|
}
|
|
253
|
-
function
|
|
253
|
+
function lt(e, t, n) {
|
|
254
254
|
if (!e) return !0;
|
|
255
255
|
const r = new Date(String(e)), s = new Date(t), o = new Date(n);
|
|
256
256
|
return !isNaN(r.getTime()) && !isNaN(s.getTime()) && !isNaN(o.getTime()) && r >= s && r <= o;
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function ft(e, t = {}) {
|
|
259
259
|
const { args: n = [], messages: r = {} } = t, [s, o] = n;
|
|
260
|
-
return
|
|
260
|
+
return lt(e, s, o) ? !0 : ct(r, s, o);
|
|
261
261
|
}
|
|
262
|
-
const
|
|
262
|
+
const mt = (e) => {
|
|
263
263
|
const t = e.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), n = {
|
|
264
264
|
YYYY: "\\d{4}",
|
|
265
265
|
YY: "\\d{2}",
|
|
@@ -273,57 +273,57 @@ const dt = (e) => {
|
|
|
273
273
|
r = r.replace(new RegExp(s, "g"), n[s]);
|
|
274
274
|
}), new RegExp(`^${r}$`);
|
|
275
275
|
};
|
|
276
|
-
function
|
|
276
|
+
function dt(e, t) {
|
|
277
277
|
const n = e.dateFormat;
|
|
278
278
|
return typeof n == "function" ? n({ format: t }) : n ?? `Must match the format ${t}`;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
return e ? t && typeof t == "string" ?
|
|
280
|
+
function gt(e, t) {
|
|
281
|
+
return e ? t && typeof t == "string" ? mt(t).test(String(e)) : !isNaN(Date.parse(String(e))) : !0;
|
|
282
282
|
}
|
|
283
|
-
function
|
|
283
|
+
function pt(e, t = {}) {
|
|
284
284
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
285
|
-
return
|
|
285
|
+
return gt(e, s) ? !0 : dt(r, s);
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function bt(e) {
|
|
288
288
|
const t = e.email;
|
|
289
289
|
return typeof t == "function" ? t({}) : t ?? "Please enter a valid email address";
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function yt(e) {
|
|
292
292
|
return e ? /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(e)) : !0;
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function $t(e, t = {}) {
|
|
295
295
|
const { messages: n = {} } = t;
|
|
296
|
-
return
|
|
296
|
+
return yt(e) ? !0 : bt(n);
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function ht(e, t) {
|
|
299
299
|
const n = e.endsWith;
|
|
300
300
|
return typeof n == "function" ? n({ suffix: t.length === 1 ? t[0] : t }) : n ?? `Must end with: ${t.join(", ")}`;
|
|
301
301
|
}
|
|
302
|
-
function
|
|
302
|
+
function vt(e, ...t) {
|
|
303
303
|
if (!e) return !0;
|
|
304
304
|
const n = String(e);
|
|
305
305
|
return t.some((r) => n.endsWith(r));
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function Mt(e, t = {}) {
|
|
308
308
|
const { args: n = [], messages: r = {} } = t;
|
|
309
|
-
return
|
|
309
|
+
return vt(e, ...n) ? !0 : ht(r, n);
|
|
310
310
|
}
|
|
311
|
-
function
|
|
311
|
+
function Nt(e, t) {
|
|
312
312
|
const n = e.is;
|
|
313
313
|
return typeof n == "function" ? n({ allowedValues: t }) : n ?? `Must be one of: ${t.join(", ")}`;
|
|
314
314
|
}
|
|
315
|
-
function
|
|
315
|
+
function wt(e, ...t) {
|
|
316
316
|
return !e && e !== 0 && e !== !1 ? !0 : t.includes(String(e));
|
|
317
317
|
}
|
|
318
|
-
function
|
|
318
|
+
function At(e, t = {}) {
|
|
319
319
|
const { args: n = [], messages: r = {} } = t;
|
|
320
|
-
return
|
|
320
|
+
return wt(e, ...n) ? !0 : Nt(r, n);
|
|
321
321
|
}
|
|
322
|
-
function
|
|
322
|
+
function Dt(e, t, n) {
|
|
323
323
|
const r = e.length;
|
|
324
324
|
return n !== void 0 ? typeof r == "function" ? r({ min: t, max: n }) : r ?? `Must be between ${t} and ${n} characters` : typeof r == "function" ? r({ value: t }) : r ?? `Must be exactly ${t} characters`;
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function St(e, t, n) {
|
|
327
327
|
if (!e && e !== 0) return !0;
|
|
328
328
|
let r = 0;
|
|
329
329
|
if (typeof e == "string")
|
|
@@ -341,26 +341,26 @@ function Ft(e, t, n) {
|
|
|
341
341
|
const s = Number(t);
|
|
342
342
|
return !isNaN(s) && r === s;
|
|
343
343
|
}
|
|
344
|
-
function
|
|
344
|
+
function Ft(e, t = {}) {
|
|
345
345
|
const { args: n = [], messages: r = {} } = t, [s, o] = n;
|
|
346
|
-
return
|
|
346
|
+
return St(e, s, o) ? !0 : Dt(r, s, o);
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function xt(e) {
|
|
349
349
|
const t = e.lowercase;
|
|
350
350
|
return typeof t == "function" ? t({}) : t ?? "Must contain only lowercase characters";
|
|
351
351
|
}
|
|
352
|
-
function
|
|
352
|
+
function jt(e) {
|
|
353
353
|
return e ? /^[a-z]+$/.test(String(e)) : !0;
|
|
354
354
|
}
|
|
355
|
-
function
|
|
355
|
+
function Tt(e, t = {}) {
|
|
356
356
|
const { messages: n = {} } = t;
|
|
357
|
-
return
|
|
357
|
+
return jt(e) ? !0 : xt(n);
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function Vt(e, t, n) {
|
|
360
360
|
const r = t.matches;
|
|
361
361
|
return typeof r == "function" ? r({ value: e, pattern: n }) : r ?? "Format is not valid";
|
|
362
362
|
}
|
|
363
|
-
function
|
|
363
|
+
function qt(e, t) {
|
|
364
364
|
if (!e) return !0;
|
|
365
365
|
if (!t) return !1;
|
|
366
366
|
try {
|
|
@@ -373,15 +373,15 @@ function Ct(e, t) {
|
|
|
373
373
|
return !1;
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
-
function
|
|
376
|
+
function Ct(e, t = {}) {
|
|
377
377
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
378
|
-
return
|
|
378
|
+
return qt(e, s) ? !0 : Vt(e, r, s);
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function Pt(e, t) {
|
|
381
381
|
const n = e.max;
|
|
382
382
|
return typeof n == "function" ? n({ value: t }) : n ?? `Must be at most ${t}`;
|
|
383
383
|
}
|
|
384
|
-
function
|
|
384
|
+
function Et(e, t) {
|
|
385
385
|
if (!e && e !== 0) return !0;
|
|
386
386
|
const n = Number(t);
|
|
387
387
|
if (isNaN(n)) return !1;
|
|
@@ -392,15 +392,15 @@ function Ot(e, t) {
|
|
|
392
392
|
}
|
|
393
393
|
return Array.isArray(e) ? e.length <= n : !1;
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function Ot(e, t = {}) {
|
|
396
396
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
397
|
-
return
|
|
397
|
+
return Et(e, s) ? !0 : Pt(r, s);
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function Bt(e, t) {
|
|
400
400
|
const n = e.min;
|
|
401
401
|
return typeof n == "function" ? n({ value: t }) : n ?? `Must be at least ${t}`;
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function Rt(e, t) {
|
|
404
404
|
if (!e && e !== 0) return !0;
|
|
405
405
|
const n = Number(t);
|
|
406
406
|
if (isNaN(n)) return !1;
|
|
@@ -411,86 +411,86 @@ function Wt(e, t) {
|
|
|
411
411
|
}
|
|
412
412
|
return Array.isArray(e) ? e.length >= n : !1;
|
|
413
413
|
}
|
|
414
|
-
function
|
|
414
|
+
function Wt(e, t = {}) {
|
|
415
415
|
const { args: n = [], messages: r = {} } = t, [s] = n;
|
|
416
|
-
return
|
|
416
|
+
return Rt(e, s) ? !0 : Bt(r, s);
|
|
417
417
|
}
|
|
418
|
-
function
|
|
418
|
+
function Lt(e, t) {
|
|
419
419
|
const n = e.not;
|
|
420
420
|
return typeof n == "function" ? n({ disallowedValues: t }) : n ?? `Must not be one of: ${t.join(", ")}`;
|
|
421
421
|
}
|
|
422
|
-
function
|
|
422
|
+
function _t(e, ...t) {
|
|
423
423
|
return !e && e !== 0 && e !== !1 ? !0 : !t.includes(String(e));
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function zt(e, t = {}) {
|
|
426
426
|
const { args: n = [], messages: r = {} } = t;
|
|
427
|
-
return
|
|
427
|
+
return _t(e, ...n) ? !0 : Lt(r, n);
|
|
428
428
|
}
|
|
429
|
-
function
|
|
429
|
+
function It(e) {
|
|
430
430
|
const t = e.number;
|
|
431
431
|
return typeof t == "function" ? t({}) : t ?? "Must be a valid number";
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function Kt(e) {
|
|
434
434
|
if (e == null || e === "") return !0;
|
|
435
435
|
if (Number.isNaN(e)) return !1;
|
|
436
436
|
const t = Number(e);
|
|
437
437
|
return !isNaN(t) && isFinite(t);
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function Ut(e, t = {}) {
|
|
440
440
|
const { messages: n = {} } = t;
|
|
441
|
-
return
|
|
441
|
+
return Kt(e) ? !0 : It(n);
|
|
442
442
|
}
|
|
443
|
-
function
|
|
443
|
+
function Zt(e) {
|
|
444
444
|
const t = e.required;
|
|
445
445
|
return typeof t == "function" ? t({}) : t ?? "This field is required";
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function kt(e) {
|
|
448
448
|
return e == null || e === "" ? !1 : typeof e == "string" ? e.trim().length > 0 : Array.isArray(e) ? e.length > 0 : typeof e == "object" ? Object.keys(e).length > 0 : e === 0 ? !0 : !!e;
|
|
449
449
|
}
|
|
450
|
-
function
|
|
450
|
+
function Yt(e, t = {}) {
|
|
451
451
|
const { messages: n = {} } = t;
|
|
452
|
-
return
|
|
452
|
+
return kt(e) ? !0 : Zt(n);
|
|
453
453
|
}
|
|
454
|
-
function
|
|
454
|
+
function Gt(e, t) {
|
|
455
455
|
const n = e.startsWith;
|
|
456
456
|
return typeof n == "function" ? n({ prefix: t.length === 1 ? t[0] : t }) : n ?? `Must start with: ${t.join(", ")}`;
|
|
457
457
|
}
|
|
458
|
-
function
|
|
458
|
+
function Ht(e, ...t) {
|
|
459
459
|
if (!e) return !0;
|
|
460
460
|
const n = String(e);
|
|
461
461
|
return t.some((r) => n.startsWith(r));
|
|
462
462
|
}
|
|
463
|
-
function
|
|
463
|
+
function Jt(e, t = {}) {
|
|
464
464
|
const { args: n = [], messages: r = {} } = t;
|
|
465
|
-
return
|
|
465
|
+
return Ht(e, ...n) ? !0 : Gt(r, n);
|
|
466
466
|
}
|
|
467
|
-
function
|
|
467
|
+
function Qt(e) {
|
|
468
468
|
const t = e.symbol;
|
|
469
469
|
return typeof t == "function" ? t({}) : t ?? "Must contain only symbols";
|
|
470
470
|
}
|
|
471
|
-
function
|
|
471
|
+
function Xt(e) {
|
|
472
472
|
return e ? /^[^\w\s]+$/.test(String(e)) : !0;
|
|
473
473
|
}
|
|
474
|
-
function
|
|
474
|
+
function en(e, t = {}) {
|
|
475
475
|
const { messages: n = {} } = t;
|
|
476
|
-
return
|
|
476
|
+
return Xt(e) ? !0 : Qt(n);
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function tn(e) {
|
|
479
479
|
const t = e.uppercase;
|
|
480
480
|
return typeof t == "function" ? t({}) : t ?? "Must contain only uppercase characters";
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function nn(e) {
|
|
483
483
|
return e ? /^[A-Z]+$/.test(String(e)) : !0;
|
|
484
484
|
}
|
|
485
|
-
function
|
|
485
|
+
function rn(e, t = {}) {
|
|
486
486
|
const { messages: n = {} } = t;
|
|
487
|
-
return
|
|
487
|
+
return nn(e) ? !0 : tn(n);
|
|
488
488
|
}
|
|
489
|
-
function
|
|
489
|
+
function sn(e) {
|
|
490
490
|
const t = e.url;
|
|
491
491
|
return typeof t == "function" ? t({}) : t ?? "Must be a valid URL";
|
|
492
492
|
}
|
|
493
|
-
function
|
|
493
|
+
function on(e) {
|
|
494
494
|
if (!e) return !0;
|
|
495
495
|
try {
|
|
496
496
|
const t = new URL(String(e));
|
|
@@ -499,50 +499,50 @@ function an(e) {
|
|
|
499
499
|
return !1;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
|
-
function
|
|
502
|
+
function an(e, t = {}) {
|
|
503
503
|
const { messages: n = {} } = t;
|
|
504
|
-
return
|
|
504
|
+
return on(e) ? !0 : sn(n);
|
|
505
505
|
}
|
|
506
|
-
const
|
|
506
|
+
const un = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
507
507
|
__proto__: null,
|
|
508
|
-
accepted:
|
|
509
|
-
alpha:
|
|
510
|
-
alphaSpaces:
|
|
511
|
-
alphanumeric:
|
|
512
|
-
between:
|
|
513
|
-
confirm:
|
|
514
|
-
containsAlpha:
|
|
515
|
-
containsAlphaSpaces:
|
|
516
|
-
containsAlphanumeric:
|
|
517
|
-
containsLowercase:
|
|
518
|
-
containsNumeric:
|
|
519
|
-
containsSymbol:
|
|
520
|
-
containsUppercase:
|
|
521
|
-
dateAfter:
|
|
522
|
-
dateAfterOrEqual:
|
|
523
|
-
dateBefore:
|
|
524
|
-
dateBeforeOrEqual:
|
|
525
|
-
dateBetween:
|
|
526
|
-
dateFormat:
|
|
527
|
-
email:
|
|
528
|
-
endsWith:
|
|
529
|
-
is:
|
|
530
|
-
length:
|
|
531
|
-
lowercase:
|
|
532
|
-
matches:
|
|
533
|
-
max:
|
|
534
|
-
min:
|
|
535
|
-
not:
|
|
536
|
-
number:
|
|
537
|
-
required:
|
|
538
|
-
startsWith:
|
|
539
|
-
symbol:
|
|
540
|
-
uppercase:
|
|
541
|
-
url:
|
|
542
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
508
|
+
accepted: ge,
|
|
509
|
+
alpha: ye,
|
|
510
|
+
alphaSpaces: we,
|
|
511
|
+
alphanumeric: ve,
|
|
512
|
+
between: Se,
|
|
513
|
+
confirm: je,
|
|
514
|
+
containsAlpha: qe,
|
|
515
|
+
containsAlphaSpaces: Re,
|
|
516
|
+
containsAlphanumeric: Ee,
|
|
517
|
+
containsLowercase: _e,
|
|
518
|
+
containsNumeric: Ke,
|
|
519
|
+
containsSymbol: ke,
|
|
520
|
+
containsUppercase: He,
|
|
521
|
+
dateAfter: Xe,
|
|
522
|
+
dateAfterOrEqual: nt,
|
|
523
|
+
dateBefore: ot,
|
|
524
|
+
dateBeforeOrEqual: it,
|
|
525
|
+
dateBetween: ft,
|
|
526
|
+
dateFormat: pt,
|
|
527
|
+
email: $t,
|
|
528
|
+
endsWith: Mt,
|
|
529
|
+
is: At,
|
|
530
|
+
length: Ft,
|
|
531
|
+
lowercase: Tt,
|
|
532
|
+
matches: Ct,
|
|
533
|
+
max: Ot,
|
|
534
|
+
min: Wt,
|
|
535
|
+
not: zt,
|
|
536
|
+
number: Ut,
|
|
537
|
+
required: Yt,
|
|
538
|
+
startsWith: Jt,
|
|
539
|
+
symbol: en,
|
|
540
|
+
uppercase: rn,
|
|
541
|
+
url: an
|
|
542
|
+
}, Symbol.toStringTag, { value: "Module" })), An = {
|
|
543
543
|
install(e, t = {}) {
|
|
544
|
-
P(
|
|
545
|
-
const n =
|
|
544
|
+
P(un), t.rules && P(t.rules);
|
|
545
|
+
const n = te(t.locale) ? t.locale : h(t.locale ?? "en"), r = { en: ce };
|
|
546
546
|
t.locales && Object.keys(t.locales).forEach((o) => {
|
|
547
547
|
r[o] = { ...r[o] ?? {}, ...t.locales[o] };
|
|
548
548
|
});
|
|
@@ -555,37 +555,37 @@ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
555
555
|
}
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
|
-
}, H = Symbol("form-state-context"),
|
|
559
|
-
|
|
560
|
-
},
|
|
558
|
+
}, H = Symbol("form-state-context"), cn = (e) => {
|
|
559
|
+
x(H, e);
|
|
560
|
+
}, ln = (e = null) => {
|
|
561
561
|
const t = A(H, e);
|
|
562
562
|
if (!t && t !== null)
|
|
563
563
|
throw new Error("Context with formStateContextKey not found");
|
|
564
564
|
return t;
|
|
565
|
-
}, J = Symbol("form-context"),
|
|
566
|
-
|
|
567
|
-
},
|
|
565
|
+
}, J = Symbol("form-context"), fn = (e) => {
|
|
566
|
+
x(J, e);
|
|
567
|
+
}, Dn = (e = null) => {
|
|
568
568
|
const t = A(J, e);
|
|
569
569
|
if (!t && t !== null)
|
|
570
570
|
throw new Error("Context with formContextKey not found");
|
|
571
571
|
return t;
|
|
572
572
|
};
|
|
573
|
-
function
|
|
573
|
+
function mn(e, t) {
|
|
574
574
|
if (!(!e || !t))
|
|
575
575
|
return t.split(".").reduce((n, r) => n == null ? void 0 : n[r], e);
|
|
576
576
|
}
|
|
577
|
-
function
|
|
577
|
+
function dn(e, t, n) {
|
|
578
578
|
if (!e || !t) return e;
|
|
579
|
-
const r = t.split("."), s = r.pop(), o = r.reduce((a,
|
|
580
|
-
if (a[
|
|
579
|
+
const r = t.split("."), s = r.pop(), o = r.reduce((a, m, i) => {
|
|
580
|
+
if (a[m] === null || a[m] === void 0) {
|
|
581
581
|
const y = r[i + 1] || s;
|
|
582
|
-
a[
|
|
582
|
+
a[m] = /^\d+$/.test(y) ? [] : {};
|
|
583
583
|
}
|
|
584
|
-
return a[
|
|
584
|
+
return a[m];
|
|
585
585
|
}, e);
|
|
586
586
|
return o[s] = n, e;
|
|
587
587
|
}
|
|
588
|
-
const
|
|
588
|
+
const Sn = /* @__PURE__ */ R({
|
|
589
589
|
__name: "Form",
|
|
590
590
|
props: {
|
|
591
591
|
modelValue: {
|
|
@@ -596,75 +596,75 @@ const Fn = /* @__PURE__ */ R({
|
|
|
596
596
|
emits: /* @__PURE__ */ U(["submit"], ["update:modelValue"]),
|
|
597
597
|
setup(e, { emit: t }) {
|
|
598
598
|
const n = t, r = W(e, "modelValue");
|
|
599
|
-
|
|
600
|
-
const s = h({}), o = h([]), a = b(() => r.value),
|
|
599
|
+
ne(r.value) || (r.value = re(r.value ?? {}));
|
|
600
|
+
const s = h({}), o = h([]), a = b(() => r.value), m = b(() => o.value[0] ?? null), i = b(
|
|
601
601
|
() => Object.keys(s.value).every((u) => s.value[u].isValid)
|
|
602
602
|
), y = () => {
|
|
603
603
|
Object.keys(s.value).forEach((u) => {
|
|
604
|
-
var
|
|
605
|
-
(
|
|
604
|
+
var g, d;
|
|
605
|
+
(d = (g = s.value[u]).validate) == null || d.call(g);
|
|
606
606
|
});
|
|
607
|
-
},
|
|
608
|
-
y(), i.value && (o.value = [], n("submit", r.value, { setErrors:
|
|
609
|
-
},
|
|
610
|
-
var
|
|
607
|
+
}, c = () => {
|
|
608
|
+
y(), i.value && (o.value = [], n("submit", r.value, { setErrors: l, reset: f }));
|
|
609
|
+
}, l = (...u) => {
|
|
610
|
+
var g;
|
|
611
611
|
if (u.length === 1) {
|
|
612
|
-
const
|
|
613
|
-
if (typeof
|
|
614
|
-
Object.keys(
|
|
615
|
-
|
|
612
|
+
const d = u[0];
|
|
613
|
+
if (typeof d == "object" && !Array.isArray(d) && d !== null) {
|
|
614
|
+
Object.keys(d).forEach((v) => {
|
|
615
|
+
l(v, d[v]);
|
|
616
616
|
});
|
|
617
617
|
return;
|
|
618
618
|
}
|
|
619
|
-
o.value = Array.isArray(
|
|
619
|
+
o.value = Array.isArray(d) ? d : [d];
|
|
620
620
|
} else if (u.length === 2) {
|
|
621
|
-
const [
|
|
622
|
-
(
|
|
621
|
+
const [d, v] = u;
|
|
622
|
+
(g = s.value[d]) == null || g.setErrors(v);
|
|
623
623
|
}
|
|
624
|
-
},
|
|
624
|
+
}, f = () => {
|
|
625
625
|
o.value = [], Object.keys(s.value).forEach((u) => {
|
|
626
626
|
s.value[u].reset();
|
|
627
627
|
});
|
|
628
628
|
};
|
|
629
|
-
return
|
|
629
|
+
return cn({
|
|
630
630
|
getFields() {
|
|
631
631
|
return s.value;
|
|
632
632
|
},
|
|
633
633
|
getField(u) {
|
|
634
634
|
return s.value[u];
|
|
635
635
|
},
|
|
636
|
-
addField(u,
|
|
637
|
-
s.value[u] =
|
|
636
|
+
addField(u, g) {
|
|
637
|
+
s.value[u] = g;
|
|
638
638
|
},
|
|
639
639
|
removeField(u) {
|
|
640
640
|
delete s.value[u];
|
|
641
641
|
},
|
|
642
|
-
setFieldValue(u,
|
|
643
|
-
|
|
642
|
+
setFieldValue(u, g) {
|
|
643
|
+
dn(r.value, u, g);
|
|
644
644
|
},
|
|
645
645
|
getFieldValue(u) {
|
|
646
|
-
return
|
|
646
|
+
return mn(r.value, u);
|
|
647
647
|
}
|
|
648
|
-
}),
|
|
648
|
+
}), fn({
|
|
649
649
|
values: a,
|
|
650
650
|
isValid: i,
|
|
651
|
-
error:
|
|
651
|
+
error: m,
|
|
652
652
|
errors: o,
|
|
653
653
|
fields: s,
|
|
654
|
-
reset:
|
|
655
|
-
setErrors:
|
|
654
|
+
reset: f,
|
|
655
|
+
setErrors: l,
|
|
656
656
|
validate: y
|
|
657
|
-
}), (u,
|
|
658
|
-
onSubmit:
|
|
657
|
+
}), (u, g) => (L(), _("form", {
|
|
658
|
+
onSubmit: se(c, ["prevent"])
|
|
659
659
|
}, [
|
|
660
660
|
z(u.$slots, "default", I(K({
|
|
661
661
|
isValid: i.value,
|
|
662
|
-
error:
|
|
662
|
+
error: m.value,
|
|
663
663
|
errors: o.value,
|
|
664
664
|
values: a.value,
|
|
665
665
|
fields: s.value,
|
|
666
|
-
reset:
|
|
667
|
-
setErrors:
|
|
666
|
+
reset: f,
|
|
667
|
+
setErrors: l,
|
|
668
668
|
validate: y
|
|
669
669
|
})))
|
|
670
670
|
], 32));
|
|
@@ -685,26 +685,26 @@ function Q(e) {
|
|
|
685
685
|
}
|
|
686
686
|
return n;
|
|
687
687
|
}
|
|
688
|
-
const
|
|
688
|
+
const gn = (e, t, n = {}, r = {}) => {
|
|
689
689
|
if (!t) return !0;
|
|
690
690
|
const s = Q(t), o = [];
|
|
691
|
-
for (const [a,
|
|
692
|
-
const i =
|
|
691
|
+
for (const [a, m] of Object.entries(s)) {
|
|
692
|
+
const i = fe(a);
|
|
693
693
|
if (i) {
|
|
694
|
-
const
|
|
695
|
-
|
|
694
|
+
const c = { args: m === !0 ? [] : Array.isArray(m) ? m : [m], messages: n, fields: r }, l = i(e, c);
|
|
695
|
+
l !== !0 && o.push(l ?? "Invalid value");
|
|
696
696
|
} else
|
|
697
697
|
console.warn(`[Forms] Validation rule "${a}" not found.`);
|
|
698
698
|
}
|
|
699
699
|
return o.length === 0 ? !0 : o;
|
|
700
|
-
},
|
|
700
|
+
}, pn = (e, t) => {
|
|
701
701
|
const n = t(e);
|
|
702
702
|
return n === !0 ? !0 : typeof n == "string" ? [n] : Array.isArray(n) ? n : !!n ? !0 : ["Invalid value"];
|
|
703
703
|
};
|
|
704
704
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
705
705
|
const E = () => {
|
|
706
706
|
};
|
|
707
|
-
function
|
|
707
|
+
function bn(e, t) {
|
|
708
708
|
function n(...r) {
|
|
709
709
|
return new Promise((s, o) => {
|
|
710
710
|
Promise.resolve(e(() => t.apply(this, r), {
|
|
@@ -716,51 +716,51 @@ function yn(e, t) {
|
|
|
716
716
|
}
|
|
717
717
|
return n;
|
|
718
718
|
}
|
|
719
|
-
const
|
|
720
|
-
function
|
|
719
|
+
const yn = (e) => e();
|
|
720
|
+
function $n(e, t = {}) {
|
|
721
721
|
let n, r, s = E;
|
|
722
722
|
const o = (i) => {
|
|
723
723
|
clearTimeout(i), s(), s = E;
|
|
724
724
|
};
|
|
725
725
|
let a;
|
|
726
726
|
return (i) => {
|
|
727
|
-
const y = $(e),
|
|
728
|
-
return n && o(n), y <= 0 ||
|
|
729
|
-
s = t.rejectOnCancel ?
|
|
730
|
-
n && o(n), r = void 0,
|
|
731
|
-
},
|
|
732
|
-
r && o(r), r = void 0,
|
|
727
|
+
const y = $(e), c = $(t.maxWait);
|
|
728
|
+
return n && o(n), y <= 0 || c !== void 0 && c <= 0 ? (r && (o(r), r = void 0), Promise.resolve(i())) : new Promise((l, f) => {
|
|
729
|
+
s = t.rejectOnCancel ? f : l, a = i, c && !r && (r = setTimeout(() => {
|
|
730
|
+
n && o(n), r = void 0, l(a());
|
|
731
|
+
}, c)), n = setTimeout(() => {
|
|
732
|
+
r && o(r), r = void 0, l(i());
|
|
733
733
|
}, y);
|
|
734
734
|
});
|
|
735
735
|
};
|
|
736
736
|
}
|
|
737
|
-
function
|
|
738
|
-
const { eventFilter: r =
|
|
739
|
-
return Z(e,
|
|
737
|
+
function hn(e, t, n = {}) {
|
|
738
|
+
const { eventFilter: r = yn, ...s } = n;
|
|
739
|
+
return Z(e, bn(r, t), s);
|
|
740
740
|
}
|
|
741
741
|
function O(e, t, n = {}) {
|
|
742
742
|
const { debounce: r = 0, maxWait: s = void 0, ...o } = n;
|
|
743
|
-
return
|
|
743
|
+
return hn(e, t, {
|
|
744
744
|
...o,
|
|
745
|
-
eventFilter:
|
|
745
|
+
eventFilter: $n(r, { maxWait: s })
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
|
-
function
|
|
749
|
-
const n = h(!0), r = h(!1), s = h([]), o = h(null), a = b(() => $(t.rules) ?? null),
|
|
748
|
+
function vn(e, t = {}) {
|
|
749
|
+
const n = h(!0), r = h(!1), s = h([]), o = h(null), a = b(() => $(t.rules) ?? null), m = b(() => $(t.messages) ?? {}), i = b(() => $(t.fields) ?? {}), y = b(() => {
|
|
750
750
|
if (!a.value || typeof a.value != "string") return null;
|
|
751
751
|
const u = Q(a.value).confirm;
|
|
752
752
|
if (!u || u === !0) return null;
|
|
753
|
-
const
|
|
754
|
-
return (
|
|
755
|
-
}),
|
|
756
|
-
let
|
|
757
|
-
return typeof a.value == "function" ?
|
|
753
|
+
const g = i.value[u];
|
|
754
|
+
return (g == null ? void 0 : g.value) ?? null;
|
|
755
|
+
}), c = () => {
|
|
756
|
+
let f;
|
|
757
|
+
return typeof a.value == "function" ? f = pn($(e), a.value) : f = gn(
|
|
758
758
|
$(e),
|
|
759
759
|
a.value,
|
|
760
|
-
|
|
760
|
+
m.value,
|
|
761
761
|
i.value
|
|
762
|
-
),
|
|
763
|
-
},
|
|
762
|
+
), f === !0 ? (n.value = !0, s.value = [], !0) : Array.isArray(f) ? (n.value = !1, s.value = f, !1) : f;
|
|
763
|
+
}, l = () => {
|
|
764
764
|
o.value && clearTimeout(o.value), r.value = !0, n.value = !0, s.value = [], o.value = setTimeout(() => {
|
|
765
765
|
r.value = !1, o.value = null;
|
|
766
766
|
}, 1e3);
|
|
@@ -768,30 +768,30 @@ function Mn(e, t = {}) {
|
|
|
768
768
|
return O(
|
|
769
769
|
() => $(e),
|
|
770
770
|
() => {
|
|
771
|
-
r.value ||
|
|
771
|
+
r.value || c();
|
|
772
772
|
},
|
|
773
773
|
{ debounce: 300 }
|
|
774
774
|
), O(
|
|
775
775
|
() => $(y),
|
|
776
776
|
() => {
|
|
777
|
-
r.value || $(e) &&
|
|
777
|
+
r.value || $(e) && c();
|
|
778
778
|
},
|
|
779
779
|
{ debounce: 300 }
|
|
780
780
|
), {
|
|
781
|
-
validate:
|
|
782
|
-
reset:
|
|
781
|
+
validate: c,
|
|
782
|
+
reset: l,
|
|
783
783
|
isValid: w(n),
|
|
784
784
|
errors: w(s)
|
|
785
785
|
};
|
|
786
786
|
}
|
|
787
|
-
const X = Symbol("field-context"),
|
|
788
|
-
|
|
789
|
-
},
|
|
787
|
+
const X = Symbol("field-context"), Mn = (e) => {
|
|
788
|
+
x(X, e);
|
|
789
|
+
}, Fn = (e = null) => {
|
|
790
790
|
const t = A(X, e);
|
|
791
791
|
if (!t && t !== null)
|
|
792
792
|
throw new Error("Context with fieldContextKey not found");
|
|
793
793
|
return t;
|
|
794
|
-
},
|
|
794
|
+
}, xn = /* @__PURE__ */ R({
|
|
795
795
|
__name: "Field",
|
|
796
796
|
props: /* @__PURE__ */ U({
|
|
797
797
|
id: {},
|
|
@@ -805,29 +805,27 @@ const X = Symbol("field-context"), Nn = (e) => {
|
|
|
805
805
|
}),
|
|
806
806
|
emits: ["update:modelValue"],
|
|
807
807
|
setup(e) {
|
|
808
|
-
const t = e, n = W(e, "modelValue"), r =
|
|
808
|
+
const t = e, n = W(e, "modelValue"), r = oe(), s = ln(), o = Y(), a = b({
|
|
809
809
|
get: () => s ? s.getFieldValue(t.name) : n.value,
|
|
810
|
-
set: (
|
|
811
|
-
s ? s.setFieldValue(t.name,
|
|
810
|
+
set: (p) => {
|
|
811
|
+
s ? s.setFieldValue(t.name, p) : n.value = p;
|
|
812
812
|
}
|
|
813
|
-
}),
|
|
813
|
+
}), m = b(() => t.validation ?? null), i = b(() => ({
|
|
814
814
|
...o ? o.locales.value[o.locale.value] : {},
|
|
815
815
|
...t.validationMessages ?? {}
|
|
816
816
|
})), y = b({
|
|
817
817
|
get: () => s ? s.getFields() : {},
|
|
818
818
|
set: () => {
|
|
819
819
|
}
|
|
820
|
-
}),
|
|
821
|
-
u.value = Array.isArray(
|
|
822
|
-
},
|
|
823
|
-
a.value =
|
|
824
|
-
}, x = () => {
|
|
825
|
-
a.value = D, f.value = !1, c.value = !1, u.value = [], l.reset();
|
|
820
|
+
}), c = vn(a, { rules: m, messages: i, fields: y }), l = h(!1), f = h(!1), u = h([]), g = b(() => a.value ?? null), d = b(() => c.isValid.value && u.value.length === 0), v = b(() => [...c.errors.value, ...u.value]), M = b(() => v.value[0] ?? null), j = $(a), N = t.id ?? r, D = `${N}-error`, S = `${N}-help`, ee = (p) => {
|
|
821
|
+
u.value = Array.isArray(p) ? p : [p];
|
|
822
|
+
}, F = () => {
|
|
823
|
+
a.value = j, l.value = !1, f.value = !1, u.value = [], c.reset();
|
|
826
824
|
};
|
|
827
825
|
Z(
|
|
828
826
|
() => t.error,
|
|
829
|
-
(
|
|
830
|
-
|
|
827
|
+
(p) => {
|
|
828
|
+
p ? u.value = Array.isArray(p) ? p : [p] : u.value = [];
|
|
831
829
|
},
|
|
832
830
|
{ immediate: !0 }
|
|
833
831
|
);
|
|
@@ -836,62 +834,61 @@ const X = Symbol("field-context"), Nn = (e) => {
|
|
|
836
834
|
name: t.name,
|
|
837
835
|
modelValue: a.value,
|
|
838
836
|
"aria-invalid": !!M.value,
|
|
839
|
-
"aria-describedby": M.value ? `${
|
|
840
|
-
"aria-errormessage": M.value ?
|
|
841
|
-
"onUpdate:modelValue": (
|
|
842
|
-
a.value =
|
|
837
|
+
"aria-describedby": M.value ? `${D} ${S}` : S,
|
|
838
|
+
"aria-errormessage": M.value ? D : void 0,
|
|
839
|
+
"onUpdate:modelValue": (p) => {
|
|
840
|
+
a.value = p, !f.value && p !== j && (f.value = !0);
|
|
843
841
|
},
|
|
844
842
|
onBlur: () => {
|
|
845
|
-
|
|
843
|
+
l.value || (l.value = !0, c.validate());
|
|
846
844
|
}
|
|
847
|
-
})), V = { for: N }, q = { id:
|
|
848
|
-
return
|
|
845
|
+
})), V = { for: N }, q = { id: D, role: "alert", "aria-live": "polite" }, C = { id: S };
|
|
846
|
+
return ae(() => {
|
|
849
847
|
s && s.addField(t.name, {
|
|
850
|
-
value:
|
|
851
|
-
isValid:
|
|
852
|
-
isTouched:
|
|
853
|
-
isDirty:
|
|
848
|
+
value: g,
|
|
849
|
+
isValid: d,
|
|
850
|
+
isTouched: l,
|
|
851
|
+
isDirty: f,
|
|
854
852
|
error: M,
|
|
855
853
|
errors: v,
|
|
856
854
|
setErrors: ee,
|
|
857
|
-
reset:
|
|
858
|
-
validate:
|
|
855
|
+
reset: F,
|
|
856
|
+
validate: c.validate
|
|
859
857
|
});
|
|
860
|
-
}),
|
|
858
|
+
}), ue(() => {
|
|
861
859
|
s && s.removeField(t.name);
|
|
862
|
-
}),
|
|
860
|
+
}), Mn({
|
|
863
861
|
inputValue: a,
|
|
864
862
|
inputProps: T,
|
|
865
863
|
labelProps: V,
|
|
866
864
|
helpProps: C,
|
|
867
865
|
errorProps: q,
|
|
868
|
-
isValid:
|
|
869
|
-
isTouched:
|
|
870
|
-
isDirty:
|
|
866
|
+
isValid: d,
|
|
867
|
+
isTouched: l,
|
|
868
|
+
isDirty: f,
|
|
871
869
|
error: M,
|
|
872
870
|
errors: v,
|
|
873
|
-
validate:
|
|
874
|
-
reset:
|
|
875
|
-
}), (
|
|
876
|
-
z(
|
|
871
|
+
validate: c.validate,
|
|
872
|
+
reset: F
|
|
873
|
+
}), (p, Nn) => (L(), _("div", null, [
|
|
874
|
+
z(p.$slots, "default", I(K({
|
|
877
875
|
inputValue: a.value,
|
|
878
876
|
inputProps: T.value,
|
|
879
877
|
labelProps: V,
|
|
880
878
|
helpProps: C,
|
|
881
879
|
errorProps: q,
|
|
882
|
-
isValid:
|
|
883
|
-
isTouched:
|
|
884
|
-
isDirty:
|
|
880
|
+
isValid: d.value,
|
|
881
|
+
isTouched: l.value,
|
|
882
|
+
isDirty: f.value,
|
|
885
883
|
error: M.value,
|
|
886
884
|
errors: v.value,
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
reset: x
|
|
885
|
+
validate: ie(c).validate,
|
|
886
|
+
reset: F
|
|
890
887
|
})))
|
|
891
888
|
]));
|
|
892
889
|
}
|
|
893
890
|
});
|
|
894
|
-
function
|
|
891
|
+
function jn() {
|
|
895
892
|
const e = Y();
|
|
896
893
|
if (!e)
|
|
897
894
|
throw new Error(
|
|
@@ -903,7 +900,7 @@ function Tn() {
|
|
|
903
900
|
setLocale: e.setLocale
|
|
904
901
|
};
|
|
905
902
|
}
|
|
906
|
-
const
|
|
903
|
+
const Tn = {
|
|
907
904
|
required: "Este campo es obligatorio",
|
|
908
905
|
email: "Por favor ingresa un email válido",
|
|
909
906
|
min: ({ value: e }) => `Debe ser al menos ${e}`,
|
|
@@ -940,12 +937,12 @@ const Vn = {
|
|
|
940
937
|
url: "Debe ser una URL válida"
|
|
941
938
|
};
|
|
942
939
|
export {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
940
|
+
xn as Field,
|
|
941
|
+
Sn as Form,
|
|
942
|
+
An as FormsPlugin,
|
|
943
|
+
ce as en,
|
|
944
|
+
Tn as es,
|
|
945
|
+
Fn as useFieldContext,
|
|
946
|
+
Dn as useFormContext,
|
|
947
|
+
jn as useLocale
|
|
951
948
|
};
|