@overgaming/valiform 0.2.1 → 0.3.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 +41 -55
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +347 -346
- package/dist/src/components/Field.vue.d.ts +0 -1
- package/dist/src/components/__tests__/components/ExampleField.vue.d.ts +0 -1
- package/dist/src/context/useFieldContext.d.ts +37 -1
- package/dist/src/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
const
|
|
3
|
-
const t =
|
|
1
|
+
import { inject as N, shallowRef as R, isRef as te, ref as h, readonly as A, provide as j, defineComponent as W, useModel as L, isReactive as ne, reactive as re, computed as b, openBlock as _, createElementBlock as z, withModifiers as se, renderSlot as I, normalizeProps as U, guardReactiveProps as K, mergeModels as Z, watch as k, toValue as $, useId as oe, onMounted as ae, onUnmounted as ue, unref as ie } from "vue";
|
|
2
|
+
const Y = Symbol("locale-context"), G = (e = null) => {
|
|
3
|
+
const t = N(Y, 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
|
-
},
|
|
43
|
-
|
|
44
|
-
},
|
|
42
|
+
}, H = R(/* @__PURE__ */ new Map()), le = (e, t) => {
|
|
43
|
+
H.value.set(e, t);
|
|
44
|
+
}, E = (e) => {
|
|
45
45
|
Object.entries(e).forEach(([t, n]) => {
|
|
46
|
-
|
|
46
|
+
le(t, n);
|
|
47
47
|
});
|
|
48
|
-
},
|
|
49
|
-
function
|
|
48
|
+
}, fe = (e) => H.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
131
|
function Pe(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 Ce(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 Ce(e) ? !0 : Pe(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
171
|
function Ue(e, t = {}) {
|
|
172
172
|
const { messages: n = {} } = t;
|
|
173
|
-
return
|
|
173
|
+
return Ie(e) ? !0 : ze(n);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function Ke(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 : Ke(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 {
|
|
@@ -375,13 +375,13 @@ function Ct(e, t) {
|
|
|
375
375
|
}
|
|
376
376
|
function Pt(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 Ct(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 : Ct(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,22 +411,22 @@ 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
|
}
|
|
@@ -436,61 +436,61 @@ function Ut(e) {
|
|
|
436
436
|
const t = Number(e);
|
|
437
437
|
return !isNaN(t) && isFinite(t);
|
|
438
438
|
}
|
|
439
|
-
function
|
|
439
|
+
function Kt(e, t = {}) {
|
|
440
440
|
const { messages: n = {} } = t;
|
|
441
|
-
return Ut(e) ? !0 :
|
|
441
|
+
return Ut(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,93 +499,93 @@ 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:
|
|
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
518
|
containsNumeric: Ue,
|
|
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:
|
|
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
532
|
matches: Pt,
|
|
533
|
-
max:
|
|
534
|
-
min:
|
|
535
|
-
not:
|
|
536
|
-
number:
|
|
537
|
-
required:
|
|
538
|
-
startsWith:
|
|
539
|
-
symbol:
|
|
540
|
-
uppercase:
|
|
541
|
-
url:
|
|
542
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
533
|
+
max: Ot,
|
|
534
|
+
min: Wt,
|
|
535
|
+
not: zt,
|
|
536
|
+
number: Kt,
|
|
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
|
-
|
|
545
|
-
const n =
|
|
544
|
+
E(un), t.rules && E(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
|
});
|
|
549
|
-
const s =
|
|
550
|
-
e.provide(
|
|
551
|
-
locale:
|
|
552
|
-
locales:
|
|
549
|
+
const s = R(r);
|
|
550
|
+
e.provide(Y, {
|
|
551
|
+
locale: A(n),
|
|
552
|
+
locales: A(s),
|
|
553
553
|
setLocale: (o) => {
|
|
554
554
|
s.value[o] ? n.value = o : console.warn(`Locale "${o}" not available.`);
|
|
555
555
|
}
|
|
556
556
|
});
|
|
557
557
|
}
|
|
558
|
-
},
|
|
559
|
-
j(
|
|
560
|
-
},
|
|
561
|
-
const t =
|
|
558
|
+
}, J = Symbol("form-state-context"), cn = (e) => {
|
|
559
|
+
j(J, e);
|
|
560
|
+
}, ln = (e = null) => {
|
|
561
|
+
const t = N(J, e);
|
|
562
562
|
if (!t && t !== null)
|
|
563
563
|
throw new Error("Context with formStateContextKey not found");
|
|
564
564
|
return t;
|
|
565
|
-
},
|
|
566
|
-
j(
|
|
567
|
-
},
|
|
568
|
-
const t =
|
|
565
|
+
}, Q = Symbol("form-context"), fn = (e) => {
|
|
566
|
+
j(Q, e);
|
|
567
|
+
}, Dn = (e = null) => {
|
|
568
|
+
const t = N(Q, 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__ */ W({
|
|
589
589
|
__name: "Form",
|
|
590
590
|
props: {
|
|
591
591
|
modelValue: {
|
|
@@ -593,84 +593,84 @@ const Fn = /* @__PURE__ */ R({
|
|
|
593
593
|
},
|
|
594
594
|
modelModifiers: {}
|
|
595
595
|
},
|
|
596
|
-
emits: /* @__PURE__ */
|
|
596
|
+
emits: /* @__PURE__ */ Z(["submit"], ["update:modelValue"]),
|
|
597
597
|
setup(e, { emit: t }) {
|
|
598
|
-
const n = t, r =
|
|
599
|
-
|
|
600
|
-
const s = h({}), o = h([]), a = b(() => r.value),
|
|
598
|
+
const n = t, r = L(e, "modelValue");
|
|
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) => (_(), z("form", {
|
|
658
|
+
onSubmit: se(c, ["prevent"])
|
|
659
659
|
}, [
|
|
660
|
-
|
|
660
|
+
I(u.$slots, "default", U(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));
|
|
671
671
|
}
|
|
672
672
|
});
|
|
673
|
-
function
|
|
673
|
+
function X(e) {
|
|
674
674
|
if (!e || typeof e != "string")
|
|
675
675
|
return {};
|
|
676
676
|
const t = e.split("|").filter(Boolean), n = {};
|
|
@@ -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
|
-
const s =
|
|
691
|
-
for (const [a,
|
|
692
|
-
const i =
|
|
690
|
+
const s = X(t), o = [];
|
|
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
|
-
const
|
|
705
|
+
const O = () => {
|
|
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,84 +716,88 @@ function yn(e, t) {
|
|
|
716
716
|
}
|
|
717
717
|
return n;
|
|
718
718
|
}
|
|
719
|
-
const
|
|
720
|
-
function
|
|
721
|
-
let n, r, s =
|
|
719
|
+
const yn = (e) => e();
|
|
720
|
+
function $n(e, t = {}) {
|
|
721
|
+
let n, r, s = O;
|
|
722
722
|
const o = (i) => {
|
|
723
|
-
clearTimeout(i), s(), s =
|
|
723
|
+
clearTimeout(i), s(), s = O;
|
|
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
|
|
737
|
+
function hn(e, t, n = {}) {
|
|
738
|
+
const { eventFilter: r = yn, ...s } = n;
|
|
739
|
+
return k(e, bn(r, t), s);
|
|
740
740
|
}
|
|
741
|
-
function
|
|
741
|
+
function B(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
|
-
const u =
|
|
751
|
+
const u = X(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);
|
|
767
767
|
};
|
|
768
|
-
return
|
|
768
|
+
return B(
|
|
769
769
|
() => $(e),
|
|
770
770
|
() => {
|
|
771
|
-
r.value ||
|
|
771
|
+
r.value || c();
|
|
772
772
|
},
|
|
773
773
|
{ debounce: 300 }
|
|
774
|
-
),
|
|
774
|
+
), B(
|
|
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:
|
|
783
|
-
isValid:
|
|
784
|
-
errors:
|
|
781
|
+
validate: c,
|
|
782
|
+
reset: l,
|
|
783
|
+
isValid: A(n),
|
|
784
|
+
errors: A(s)
|
|
785
785
|
};
|
|
786
786
|
}
|
|
787
|
-
const
|
|
788
|
-
j(
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
if (
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
787
|
+
const x = Symbol("field-context"), Mn = (e) => {
|
|
788
|
+
j(x, e);
|
|
789
|
+
};
|
|
790
|
+
function Fn(e) {
|
|
791
|
+
if (e === void 0) {
|
|
792
|
+
const t = N(x);
|
|
793
|
+
if (!t) throw new Error("useFieldContext() must be called inside a Field component");
|
|
794
|
+
return t;
|
|
795
|
+
}
|
|
796
|
+
return N(x, e);
|
|
797
|
+
}
|
|
798
|
+
const xn = /* @__PURE__ */ W({
|
|
795
799
|
__name: "Field",
|
|
796
|
-
props: /* @__PURE__ */
|
|
800
|
+
props: /* @__PURE__ */ Z({
|
|
797
801
|
id: {},
|
|
798
802
|
name: {},
|
|
799
803
|
validation: { type: [String, Function, null] },
|
|
@@ -805,94 +809,91 @@ const X = Symbol("field-context"), Nn = (e) => {
|
|
|
805
809
|
}),
|
|
806
810
|
emits: ["update:modelValue"],
|
|
807
811
|
setup(e) {
|
|
808
|
-
const t = e, n =
|
|
812
|
+
const t = e, n = L(e, "modelValue"), r = oe(), s = ln(), o = G(), a = b({
|
|
809
813
|
get: () => s ? s.getFieldValue(t.name) : n.value,
|
|
810
|
-
set: (
|
|
811
|
-
s ? s.setFieldValue(t.name,
|
|
814
|
+
set: (p) => {
|
|
815
|
+
s ? s.setFieldValue(t.name, p) : n.value = p;
|
|
812
816
|
}
|
|
813
|
-
}),
|
|
817
|
+
}), m = b(() => t.validation ?? null), i = b(() => ({
|
|
814
818
|
...o ? o.locales.value[o.locale.value] : {},
|
|
815
819
|
...t.validationMessages ?? {}
|
|
816
820
|
})), y = b({
|
|
817
821
|
get: () => s ? s.getFields() : {},
|
|
818
822
|
set: () => {
|
|
819
823
|
}
|
|
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();
|
|
824
|
+
}), 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), T = $(a), w = t.id ?? r, D = `${w}-error`, S = `${w}-help`, ee = (p) => {
|
|
825
|
+
u.value = Array.isArray(p) ? p : [p];
|
|
826
|
+
}, F = () => {
|
|
827
|
+
a.value = T, l.value = !1, f.value = !1, u.value = [], c.reset();
|
|
826
828
|
};
|
|
827
|
-
|
|
829
|
+
k(
|
|
828
830
|
() => t.error,
|
|
829
|
-
(
|
|
830
|
-
|
|
831
|
+
(p) => {
|
|
832
|
+
p ? u.value = Array.isArray(p) ? p : [p] : u.value = [];
|
|
831
833
|
},
|
|
832
834
|
{ immediate: !0 }
|
|
833
835
|
);
|
|
834
|
-
const
|
|
835
|
-
id:
|
|
836
|
+
const V = b(() => ({
|
|
837
|
+
id: w,
|
|
836
838
|
name: t.name,
|
|
837
839
|
modelValue: a.value,
|
|
838
840
|
"aria-invalid": !!M.value,
|
|
839
|
-
"aria-describedby": M.value ? `${
|
|
840
|
-
"aria-errormessage": M.value ?
|
|
841
|
-
"onUpdate:modelValue": (
|
|
842
|
-
a.value =
|
|
841
|
+
"aria-describedby": M.value ? `${D} ${S}` : S,
|
|
842
|
+
"aria-errormessage": M.value ? D : void 0,
|
|
843
|
+
"onUpdate:modelValue": (p) => {
|
|
844
|
+
a.value = p, !f.value && p !== T && (f.value = !0);
|
|
843
845
|
},
|
|
844
846
|
onBlur: () => {
|
|
845
|
-
|
|
847
|
+
l.value || (l.value = !0, c.validate());
|
|
846
848
|
}
|
|
847
|
-
})),
|
|
848
|
-
return
|
|
849
|
+
})), q = { for: w }, P = { id: D, role: "alert", "aria-live": "polite" }, C = { id: S };
|
|
850
|
+
return ae(() => {
|
|
849
851
|
s && s.addField(t.name, {
|
|
850
|
-
value:
|
|
851
|
-
isValid:
|
|
852
|
-
isTouched:
|
|
853
|
-
isDirty:
|
|
852
|
+
value: g,
|
|
853
|
+
isValid: d,
|
|
854
|
+
isTouched: l,
|
|
855
|
+
isDirty: f,
|
|
854
856
|
error: M,
|
|
855
857
|
errors: v,
|
|
856
858
|
setErrors: ee,
|
|
857
|
-
reset:
|
|
858
|
-
validate:
|
|
859
|
+
reset: F,
|
|
860
|
+
validate: c.validate
|
|
859
861
|
});
|
|
860
|
-
}),
|
|
862
|
+
}), ue(() => {
|
|
861
863
|
s && s.removeField(t.name);
|
|
862
|
-
}),
|
|
864
|
+
}), Mn({
|
|
863
865
|
inputValue: a,
|
|
864
|
-
inputProps:
|
|
865
|
-
labelProps:
|
|
866
|
+
inputProps: V,
|
|
867
|
+
labelProps: q,
|
|
866
868
|
helpProps: C,
|
|
867
|
-
errorProps:
|
|
868
|
-
isValid:
|
|
869
|
-
isTouched:
|
|
870
|
-
isDirty:
|
|
869
|
+
errorProps: P,
|
|
870
|
+
isValid: d,
|
|
871
|
+
isTouched: l,
|
|
872
|
+
isDirty: f,
|
|
871
873
|
error: M,
|
|
872
874
|
errors: v,
|
|
873
|
-
validate:
|
|
874
|
-
reset:
|
|
875
|
-
}), (
|
|
876
|
-
|
|
875
|
+
validate: c.validate,
|
|
876
|
+
reset: F
|
|
877
|
+
}), (p, Nn) => (_(), z("div", null, [
|
|
878
|
+
I(p.$slots, "default", U(K({
|
|
877
879
|
inputValue: a.value,
|
|
878
|
-
inputProps:
|
|
879
|
-
labelProps:
|
|
880
|
+
inputProps: V.value,
|
|
881
|
+
labelProps: q,
|
|
880
882
|
helpProps: C,
|
|
881
|
-
errorProps:
|
|
882
|
-
isValid:
|
|
883
|
-
isTouched:
|
|
884
|
-
isDirty:
|
|
883
|
+
errorProps: P,
|
|
884
|
+
isValid: d.value,
|
|
885
|
+
isTouched: l.value,
|
|
886
|
+
isDirty: f.value,
|
|
885
887
|
error: M.value,
|
|
886
888
|
errors: v.value,
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
reset: x
|
|
889
|
+
validate: ie(c).validate,
|
|
890
|
+
reset: F
|
|
890
891
|
})))
|
|
891
892
|
]));
|
|
892
893
|
}
|
|
893
894
|
});
|
|
894
|
-
function
|
|
895
|
-
const e =
|
|
895
|
+
function jn() {
|
|
896
|
+
const e = G();
|
|
896
897
|
if (!e)
|
|
897
898
|
throw new Error(
|
|
898
899
|
"[Valiform] useLocale() must be used inside a component with FormsPlugin installed."
|
|
@@ -903,7 +904,7 @@ function Tn() {
|
|
|
903
904
|
setLocale: e.setLocale
|
|
904
905
|
};
|
|
905
906
|
}
|
|
906
|
-
const
|
|
907
|
+
const Tn = {
|
|
907
908
|
required: "Este campo es obligatorio",
|
|
908
909
|
email: "Por favor ingresa un email válido",
|
|
909
910
|
min: ({ value: e }) => `Debe ser al menos ${e}`,
|
|
@@ -940,12 +941,12 @@ const Vn = {
|
|
|
940
941
|
url: "Debe ser una URL válida"
|
|
941
942
|
};
|
|
942
943
|
export {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
944
|
+
xn as Field,
|
|
945
|
+
Sn as Form,
|
|
946
|
+
An as FormsPlugin,
|
|
947
|
+
ce as en,
|
|
948
|
+
Tn as es,
|
|
949
|
+
Fn as useFieldContext,
|
|
950
|
+
Dn as useFormContext,
|
|
951
|
+
jn as useLocale
|
|
951
952
|
};
|