@scbt-ecom/ui 0.46.1 → 0.46.3
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/hooks.js +3 -2
- package/dist/{index-CA6dELVX.js → index-PVEZwXww.js} +3466 -3474
- package/dist/index-PVEZwXww.js.map +1 -0
- package/dist/shared/hooks/index.d.ts +1 -0
- package/dist/shared/hooks/useFloating.d.ts +8 -0
- package/dist/shared/validation/base/email.validators.d.ts +1 -1
- package/dist/shared/validation/base/phone.validators.d.ts +1 -1
- package/dist/shared/validation/base/url.validators.d.ts +2 -2
- package/dist/ui.js +25 -25
- package/dist/{useDebounce-QgEEiWs9.js → useFloating-9_G5403U.js} +342 -321
- package/dist/useFloating-9_G5403U.js.map +1 -0
- package/dist/validation.js +207 -207
- package/dist/validation.js.map +1 -1
- package/dist/widget.js +2 -2
- package/package.json +1 -1
- package/dist/index-CA6dELVX.js.map +0 -1
- package/dist/useDebounce-QgEEiWs9.js.map +0 -1
package/dist/validation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z as
|
|
2
|
-
import { T as
|
|
3
|
-
const
|
|
1
|
+
import { z as o, p as f, i as N, f as T, D as L, s as D } from "./utils-SIizw_5C.js";
|
|
2
|
+
import { T as c } from "./typeGuards-yOWv7RXH.js";
|
|
3
|
+
const Z = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/, h = /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i, I = {
|
|
4
4
|
REQUIRED: "Поле обязательно к заполнению",
|
|
5
5
|
MIN_LENGTH: "Минимальная длина символов должна быть не менее",
|
|
6
6
|
MAX_LENGTH: "Максимальная длина символов должна быть не более",
|
|
@@ -13,58 +13,58 @@ const S = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
13
13
|
FUTURE_DATE_NOT_ALLOWED: "Нельзя выбрать дату позже текущей",
|
|
14
14
|
INVALID_URL: "Некорректная ссылка"
|
|
15
15
|
}, P = (e) => {
|
|
16
|
-
const t = e.trim().replace(/\s+/g, " ").split(" "), [
|
|
16
|
+
const t = e.trim().replace(/\s+/g, " ").split(" "), [d, s, ...n] = t, i = n == null ? void 0 : n.join(" ");
|
|
17
17
|
return {
|
|
18
|
-
surname:
|
|
18
|
+
surname: d,
|
|
19
19
|
name: s,
|
|
20
|
-
patronymic:
|
|
20
|
+
patronymic: i
|
|
21
21
|
};
|
|
22
|
-
}, oe =
|
|
22
|
+
}, oe = o.string({ invalid_type_error: "Обязательно к заполнению", required_error: "Обязательно к заполнению" }).superRefine((e, t) => {
|
|
23
23
|
e === "" && t.addIssue({
|
|
24
|
-
code:
|
|
24
|
+
code: o.ZodIssueCode.custom,
|
|
25
25
|
message: "Введите имя и фамилию"
|
|
26
|
-
}),
|
|
27
|
-
code:
|
|
26
|
+
}), Z.test(e) || t.addIssue({
|
|
27
|
+
code: o.ZodIssueCode.custom,
|
|
28
28
|
message: "Должна быть только кириллица"
|
|
29
29
|
});
|
|
30
|
-
const { surname:
|
|
31
|
-
(!
|
|
32
|
-
code:
|
|
30
|
+
const { surname: d, name: s, patronymic: n } = P(e);
|
|
31
|
+
(!d || !s) && t.addIssue({
|
|
32
|
+
code: o.ZodIssueCode.custom,
|
|
33
33
|
message: "Введите имя и фамилию"
|
|
34
34
|
}), A.test(s) || t.addIssue({
|
|
35
|
-
code:
|
|
35
|
+
code: o.ZodIssueCode.custom,
|
|
36
36
|
message: "Неверно введено имя"
|
|
37
|
-
}), A.test(
|
|
38
|
-
code:
|
|
37
|
+
}), A.test(d) || t.addIssue({
|
|
38
|
+
code: o.ZodIssueCode.custom,
|
|
39
39
|
message: "Неверно введена фамилия"
|
|
40
|
-
}),
|
|
41
|
-
code:
|
|
40
|
+
}), n && (h.test(n) || t.addIssue({
|
|
41
|
+
code: o.ZodIssueCode.custom,
|
|
42
42
|
message: "Неверно введено отчество"
|
|
43
43
|
}));
|
|
44
|
-
}), ae =
|
|
45
|
-
const [
|
|
46
|
-
+
|
|
47
|
-
code:
|
|
44
|
+
}), ae = o.string().length(10, { message: I.INVALID_DATE }).superRefine((e, t) => {
|
|
45
|
+
const [d, s, n] = (e == null ? void 0 : e.split(".")) ?? "", i = f(`${d}/${s}/${n}`, "dd/MM/yyyy", /* @__PURE__ */ new Date());
|
|
46
|
+
+n <= 1950 && t.addIssue({
|
|
47
|
+
code: o.ZodIssueCode.custom,
|
|
48
48
|
message: I.INVALID_DATE
|
|
49
|
-
}), N(
|
|
50
|
-
code:
|
|
49
|
+
}), N(i) || t.addIssue({
|
|
50
|
+
code: o.ZodIssueCode.custom,
|
|
51
51
|
message: I.INVALID_DATE
|
|
52
|
-
}), (/* @__PURE__ */ new Date()).getTime() < new Date(
|
|
53
|
-
code:
|
|
52
|
+
}), (/* @__PURE__ */ new Date()).getTime() < new Date(i).getTime() && t.addIssue({
|
|
53
|
+
code: o.ZodIssueCode.custom,
|
|
54
54
|
message: I.FUTURE_DATE_NOT_ALLOWED
|
|
55
55
|
});
|
|
56
|
-
}), re =
|
|
57
|
-
const
|
|
58
|
-
["3", "4", "5", "6", "9"].includes(
|
|
59
|
-
code:
|
|
56
|
+
}), re = o.string().superRefine((e, t) => {
|
|
57
|
+
const d = e.charAt(0);
|
|
58
|
+
["3", "4", "5", "6", "9"].includes(d) || t.addIssue({
|
|
59
|
+
code: o.ZodIssueCode.custom,
|
|
60
60
|
message: "Код города/оператора должен начинаться с цифры 3, 4, 5, 6 или 9"
|
|
61
61
|
}), e.length !== 10 && t.addIssue({
|
|
62
|
-
code:
|
|
62
|
+
code: o.ZodIssueCode.custom,
|
|
63
63
|
message: "Введите номер телефона полностью"
|
|
64
64
|
});
|
|
65
|
-
}).transform((e) => `7${e}`), ue =
|
|
65
|
+
}).transform((e) => `7${e}`), ue = o.coerce.number().min(1e3, `${I.FIX_LENGTH} 4`).max(9999, `${I.FIX_LENGTH} 4`).nullable().superRefine((e, t) => {
|
|
66
66
|
e === null && t.addIssue({
|
|
67
|
-
code:
|
|
67
|
+
code: o.ZodIssueCode.invalid_type,
|
|
68
68
|
expected: "number",
|
|
69
69
|
received: "null",
|
|
70
70
|
message: `${I.FIX_LENGTH} 4`
|
|
@@ -88,94 +88,94 @@ const S = /^[\u0400-\u04FF\u00CB\u00EB -]+$/, A = /^(?:[^-]+(?:-[^-]+){0,4}|[^-]
|
|
|
88
88
|
DATE_NON_EMPTY: () => "Укажите дату",
|
|
89
89
|
VALUE_OUT_OF_RANGE: (e) => `Выберите один из вариантов ${e.join(", ")}`,
|
|
90
90
|
DATE_MIN: (e) => {
|
|
91
|
-
const t =
|
|
91
|
+
const t = c.isString(e) ? new Date(e) : e;
|
|
92
92
|
return `Выбранная дата должна быть не раньше ${T(t)}`;
|
|
93
93
|
},
|
|
94
94
|
DATE_MAX: (e) => {
|
|
95
|
-
const t =
|
|
95
|
+
const t = c.isString(e) ? new Date(e) : e;
|
|
96
96
|
return `Выбранная дата должна быть не позже ${T(t)}`;
|
|
97
97
|
},
|
|
98
98
|
INVALID_URL: () => "Ссылка введена некорректно. Пример: https://example.com, example.com"
|
|
99
99
|
}, V = (e) => {
|
|
100
|
-
const { iso: t = !0, pattern:
|
|
101
|
-
return
|
|
102
|
-
const l =
|
|
100
|
+
const { iso: t = !0, pattern: d = L, min: s, max: n, message: i } = e || {};
|
|
101
|
+
return o.string().min(8, (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()).superRefine((u, a) => {
|
|
102
|
+
const l = d.replace(/\W/g, "").length;
|
|
103
103
|
if (u.replace(/[._-]/g, "").length < l && a.addIssue({
|
|
104
|
-
code:
|
|
104
|
+
code: o.ZodIssueCode.too_small,
|
|
105
105
|
minimum: l,
|
|
106
106
|
type: "date",
|
|
107
107
|
inclusive: !0,
|
|
108
|
-
message: (
|
|
108
|
+
message: (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()
|
|
109
109
|
}), t) {
|
|
110
|
-
let
|
|
110
|
+
let _ = null;
|
|
111
111
|
try {
|
|
112
|
-
|
|
112
|
+
_ = new Date(u);
|
|
113
113
|
} catch {
|
|
114
114
|
a.addIssue({
|
|
115
|
-
code:
|
|
116
|
-
message: (
|
|
115
|
+
code: o.ZodIssueCode.invalid_date,
|
|
116
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
s &&
|
|
120
|
-
code:
|
|
121
|
-
message: (
|
|
122
|
-
}),
|
|
123
|
-
code:
|
|
124
|
-
message: (
|
|
119
|
+
s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && a.addIssue({
|
|
120
|
+
code: o.ZodIssueCode.invalid_date,
|
|
121
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
122
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
123
|
+
code: o.ZodIssueCode.invalid_date,
|
|
124
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
125
125
|
});
|
|
126
126
|
} else {
|
|
127
|
-
const
|
|
128
|
-
N(
|
|
129
|
-
code:
|
|
130
|
-
message: (
|
|
131
|
-
}), s &&
|
|
132
|
-
code:
|
|
133
|
-
message: (
|
|
134
|
-
}),
|
|
135
|
-
code:
|
|
136
|
-
message: (
|
|
127
|
+
const _ = f(u, d, /* @__PURE__ */ new Date());
|
|
128
|
+
N(_) || a.addIssue({
|
|
129
|
+
code: o.ZodIssueCode.invalid_date,
|
|
130
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
131
|
+
}), s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && a.addIssue({
|
|
132
|
+
code: o.ZodIssueCode.invalid_date,
|
|
133
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
134
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
135
|
+
code: o.ZodIssueCode.invalid_date,
|
|
136
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
}).default("");
|
|
140
140
|
}, y = (e) => {
|
|
141
|
-
const { iso: t = !0, pattern:
|
|
142
|
-
return
|
|
143
|
-
if (
|
|
144
|
-
const l =
|
|
141
|
+
const { iso: t = !0, pattern: d = L, min: s, max: n, message: i } = e || {};
|
|
142
|
+
return o.string().transform((u) => u || void 0).superRefine((u, a) => {
|
|
143
|
+
if (c.isString(u) && u.length) {
|
|
144
|
+
const l = d.replace(/\W/g, "").length;
|
|
145
145
|
if (u.replace(/[._-]/g, "").length < l && a.addIssue({
|
|
146
|
-
code:
|
|
146
|
+
code: o.ZodIssueCode.too_small,
|
|
147
147
|
minimum: l,
|
|
148
148
|
type: "date",
|
|
149
149
|
inclusive: !0,
|
|
150
|
-
message: (
|
|
150
|
+
message: (i == null ? void 0 : i.min) || r.DATE_NON_EMPTY()
|
|
151
151
|
}), t) {
|
|
152
|
-
let
|
|
152
|
+
let _ = null;
|
|
153
153
|
try {
|
|
154
|
-
|
|
154
|
+
_ = new Date(u);
|
|
155
155
|
} catch {
|
|
156
156
|
a.addIssue({
|
|
157
|
-
code:
|
|
158
|
-
message: (
|
|
157
|
+
code: o.ZodIssueCode.invalid_date,
|
|
158
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
|
-
s &&
|
|
162
|
-
code:
|
|
163
|
-
message: (
|
|
164
|
-
}),
|
|
165
|
-
code:
|
|
166
|
-
message: (
|
|
161
|
+
s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && a.addIssue({
|
|
162
|
+
code: o.ZodIssueCode.invalid_date,
|
|
163
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
164
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
165
|
+
code: o.ZodIssueCode.invalid_date,
|
|
166
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
167
167
|
});
|
|
168
168
|
} else {
|
|
169
|
-
const
|
|
170
|
-
N(
|
|
171
|
-
code:
|
|
172
|
-
message: (
|
|
173
|
-
}), s &&
|
|
174
|
-
code:
|
|
175
|
-
message: (
|
|
176
|
-
}),
|
|
177
|
-
code:
|
|
178
|
-
message: (
|
|
169
|
+
const _ = f(u, d, /* @__PURE__ */ new Date());
|
|
170
|
+
N(_) || a.addIssue({
|
|
171
|
+
code: o.ZodIssueCode.invalid_date,
|
|
172
|
+
message: (i == null ? void 0 : i.invalidDate) || r.DATE_INVALID_FORMAT()
|
|
173
|
+
}), s && _.getTime() < (c.isString(s) ? new Date(s).getTime() : s.getTime()) && a.addIssue({
|
|
174
|
+
code: o.ZodIssueCode.invalid_date,
|
|
175
|
+
message: (i == null ? void 0 : i.min) || r.DATE_MIN(s)
|
|
176
|
+
}), n && _.getTime() > (c.isString(n) ? new Date(n).getTime() : n.getTime()) && a.addIssue({
|
|
177
|
+
code: o.ZodIssueCode.invalid_date,
|
|
178
|
+
message: (i == null ? void 0 : i.max) || r.DATE_MAX(n)
|
|
179
179
|
});
|
|
180
180
|
}
|
|
181
181
|
}
|
|
@@ -186,132 +186,132 @@ function H(e) {
|
|
|
186
186
|
return t ? V(e) : y(e);
|
|
187
187
|
}
|
|
188
188
|
const M = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g, U = (e) => {
|
|
189
|
-
const { message: t, regexp:
|
|
190
|
-
return
|
|
189
|
+
const { message: t, regexp: d = M } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
|
|
190
|
+
return o.string().min(1, (t == null ? void 0 : t.min) || r.EMAIL_NON_EMPTY()).regex(s, (t == null ? void 0 : t.invalid) || r.EMAIL_INVALID()).default("");
|
|
191
191
|
}, Y = (e) => {
|
|
192
|
-
const { message: t, regexp:
|
|
193
|
-
return
|
|
194
|
-
(
|
|
192
|
+
const { message: t, regexp: d = M } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
|
|
193
|
+
return o.string().refine(
|
|
194
|
+
(n) => c.isStringEmpty(n) ? !0 : s.test(n),
|
|
195
195
|
{
|
|
196
196
|
message: (t == null ? void 0 : t.invalid) || r.EMAIL_INVALID()
|
|
197
197
|
}
|
|
198
|
-
).optional().transform((
|
|
198
|
+
).optional().transform((n) => (n == null ? void 0 : n.length) === 0 ? void 0 : n);
|
|
199
199
|
};
|
|
200
|
-
function
|
|
200
|
+
function w(e) {
|
|
201
201
|
const { required: t = !0 } = e || {};
|
|
202
202
|
return t ? U(e) : Y(e);
|
|
203
203
|
}
|
|
204
204
|
const O = (e) => {
|
|
205
|
-
const { min: t, max:
|
|
206
|
-
let
|
|
207
|
-
return t && (
|
|
208
|
-
},
|
|
209
|
-
function
|
|
205
|
+
const { min: t, max: d, message: s } = e || {};
|
|
206
|
+
let n = o.coerce.number();
|
|
207
|
+
return t && (n = n.min(t, (s == null ? void 0 : s.min) || r.MIN_VALUE(t))), d && (n = n.max(d, (s == null ? void 0 : s.min) || r.MAX_VALUE(d))), n.default(0);
|
|
208
|
+
}, F = (e) => O(e).optional().transform((t) => t || void 0);
|
|
209
|
+
function G(e) {
|
|
210
210
|
const { required: t = !0 } = e || {};
|
|
211
|
-
return t ? O(e) :
|
|
211
|
+
return t ? O(e) : F(e);
|
|
212
212
|
}
|
|
213
213
|
const X = (e) => {
|
|
214
|
-
const { ignoreMask: t = !0, maskSymbols:
|
|
215
|
-
let i =
|
|
216
|
-
const
|
|
217
|
-
["3", "4", "5", "6", "7", "9"].includes(
|
|
218
|
-
code:
|
|
214
|
+
const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n = c.isString(d) ? new RegExp(d) : d;
|
|
215
|
+
let i = o.string().superRefine((u, a) => {
|
|
216
|
+
const l = u.replace(n, ""), E = l.charAt(1);
|
|
217
|
+
["3", "4", "5", "6", "7", "9"].includes(E) || a.addIssue({
|
|
218
|
+
code: o.ZodIssueCode.invalid_string,
|
|
219
219
|
validation: "regex",
|
|
220
220
|
message: (s == null ? void 0 : s.invalidOperator) || r.PHONE_INVALID_OPERATOR()
|
|
221
|
-
}),
|
|
222
|
-
code:
|
|
221
|
+
}), l.length < 11 && a.addIssue({
|
|
222
|
+
code: o.ZodIssueCode.too_small,
|
|
223
223
|
minimum: 11,
|
|
224
224
|
inclusive: !0,
|
|
225
225
|
type: "string",
|
|
226
226
|
message: (s == null ? void 0 : s.min) || r.PHONE_NON_EMPTY()
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
|
-
return t && (i = i.transform((
|
|
229
|
+
return t && (i = i.transform((u) => u.replace(n, ""))), i.default("");
|
|
230
230
|
}, $ = (e) => {
|
|
231
|
-
const { ignoreMask: t = !0, maskSymbols:
|
|
232
|
-
let i =
|
|
233
|
-
const
|
|
234
|
-
["3", "4", "5", "6", "7", "9"].includes(
|
|
235
|
-
code:
|
|
231
|
+
const { ignoreMask: t = !0, maskSymbols: d = /[()+_ -]/g, message: s } = e || {}, n = c.isString(d) ? new RegExp(d) : d;
|
|
232
|
+
let i = o.string().superRefine((u, a) => {
|
|
233
|
+
const l = u.replace(n, ""), E = l.charAt(1);
|
|
234
|
+
["3", "4", "5", "6", "7", "9"].includes(E) || a.addIssue({
|
|
235
|
+
code: o.ZodIssueCode.invalid_string,
|
|
236
236
|
validation: "regex",
|
|
237
237
|
message: (s == null ? void 0 : s.invalidOperator) || r.PHONE_INVALID_OPERATOR()
|
|
238
|
-
}),
|
|
239
|
-
code:
|
|
238
|
+
}), l.length < 11 && a.addIssue({
|
|
239
|
+
code: o.ZodIssueCode.too_small,
|
|
240
240
|
minimum: 11,
|
|
241
241
|
inclusive: !0,
|
|
242
242
|
type: "string",
|
|
243
243
|
message: (s == null ? void 0 : s.min) || r.PHONE_NON_EMPTY()
|
|
244
244
|
});
|
|
245
245
|
});
|
|
246
|
-
return t && (i = i.transform((
|
|
246
|
+
return t && (i = i.transform((u) => u.replace(n, ""))), i.transform((u) => u || void 0);
|
|
247
247
|
};
|
|
248
|
-
function
|
|
248
|
+
function x(e) {
|
|
249
249
|
const { required: t = !0 } = e || {};
|
|
250
250
|
return t ? X(e) : $(e);
|
|
251
251
|
}
|
|
252
|
-
const
|
|
253
|
-
var s,
|
|
254
|
-
const { message: t } = e || {},
|
|
252
|
+
const b = (e) => {
|
|
253
|
+
var s, n;
|
|
254
|
+
const { message: t } = e || {}, d = o.string().min(1, (t == null ? void 0 : t.single) || r.SELECT_NON_EMPTY()).nullable().refine((i) => !!i, (t == null ? void 0 : t.single) || r.SELECT_NON_EMPTY()).default(null);
|
|
255
255
|
if (e != null && e.multiple) {
|
|
256
|
-
let
|
|
257
|
-
return e != null && e.length ?
|
|
256
|
+
let i = o.array(d).min((e == null ? void 0 : e.minLength) || 0, (t == null ? void 0 : t.multiple) || r.SELECT_MULTIPLE_MIN_LENGTH((e == null ? void 0 : e.minLength) || 0));
|
|
257
|
+
return e != null && e.length ? i.length(e.length, ((s = e.message) == null ? void 0 : s.length) || r.SELECT_FIX_LENGTH(e.length)).default([]) : (e != null && e.maxLength && (i = i.max(
|
|
258
258
|
e.maxLength,
|
|
259
|
-
((
|
|
260
|
-
)),
|
|
259
|
+
((n = e.message) == null ? void 0 : n.maxLength) || r.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
|
|
260
|
+
)), i.default([]));
|
|
261
261
|
}
|
|
262
|
-
return
|
|
262
|
+
return d;
|
|
263
263
|
};
|
|
264
|
-
function
|
|
265
|
-
const t =
|
|
266
|
-
return e != null && e.multiple ?
|
|
264
|
+
function q(e) {
|
|
265
|
+
const t = o.string().nullable().optional();
|
|
266
|
+
return e != null && e.multiple ? o.array(t).optional() : t;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function v(e) {
|
|
269
269
|
const { required: t = !0 } = e || {};
|
|
270
|
-
return t ?
|
|
270
|
+
return t ? b(e) : q(e);
|
|
271
271
|
}
|
|
272
272
|
const z = (e) => {
|
|
273
|
-
const { min: t, max:
|
|
274
|
-
let
|
|
275
|
-
return t && (
|
|
276
|
-
},
|
|
277
|
-
const { min: t, max:
|
|
278
|
-
let
|
|
279
|
-
return t && (
|
|
273
|
+
const { min: t, max: d, length: s, message: n } = e || {};
|
|
274
|
+
let i = o.string({ message: n == null ? void 0 : n.root });
|
|
275
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })), d && (i = i.max(d, { message: (n == null ? void 0 : n.max) || r.MAX_LENGTH(d) })), s && (i = i.length(s, { message: (n == null ? void 0 : n.length) || r.FIX_LENGTH(s) })), i.refine((u) => !!u.length, { message: (n == null ? void 0 : n.min) || r.NON_EMPTY() }).default("");
|
|
276
|
+
}, p = (e) => {
|
|
277
|
+
const { min: t, max: d, length: s, message: n } = e || {};
|
|
278
|
+
let i = o.string({ message: n == null ? void 0 : n.root });
|
|
279
|
+
return t && (i = i.min(t, { message: (n == null ? void 0 : n.min) || r.MIN_LENGTH(t) })), d && (i = i.max(d, { message: (n == null ? void 0 : n.max) || r.MAX_LENGTH(d) })), s && (i = i.length(s, { message: (n == null ? void 0 : n.length) || r.FIX_LENGTH(s) })), i.optional().transform((u) => u != null && u.length ? u : void 0);
|
|
280
280
|
};
|
|
281
|
-
function
|
|
282
|
-
const { required: t = !0, ...
|
|
283
|
-
return t ? z(
|
|
281
|
+
function B(e) {
|
|
282
|
+
const { required: t = !0, ...d } = e || {};
|
|
283
|
+
return t ? z(d) : p(d);
|
|
284
284
|
}
|
|
285
285
|
const C = (e, t) => {
|
|
286
|
-
const { message:
|
|
287
|
-
return
|
|
286
|
+
const { message: d, ...s } = t || {}, [n, i, ...u] = e.map((l) => o.literal(l)), a = d ? typeof d == "function" ? d(e) : d : r.VALUE_OUT_OF_RANGE(e);
|
|
287
|
+
return o.union([n, i, ...u], {
|
|
288
288
|
message: a,
|
|
289
289
|
...s
|
|
290
290
|
}).nullable().refine(Boolean, r.NON_EMPTY()).default(null);
|
|
291
|
-
},
|
|
292
|
-
function
|
|
293
|
-
const { required:
|
|
294
|
-
return
|
|
291
|
+
}, k = (e, t) => C(e, t).optional();
|
|
292
|
+
function j(e, t) {
|
|
293
|
+
const { required: d, ...s } = t || {};
|
|
294
|
+
return d ? C(e, s) : k(e, s);
|
|
295
295
|
}
|
|
296
|
-
const
|
|
297
|
-
const { message: t, regexp:
|
|
298
|
-
return D().min(1, (t == null ? void 0 : t.min) || r.NON_EMPTY()).regex(
|
|
296
|
+
const R = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/, W = (e) => {
|
|
297
|
+
const { message: t, regexp: d = R } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
|
|
298
|
+
return D().min(1, (t == null ? void 0 : t.min) || r.NON_EMPTY()).regex(s, (t == null ? void 0 : t.invalid) || r.INVALID_URL()).default("");
|
|
299
299
|
}, K = (e) => {
|
|
300
|
-
const { message: t, regexp:
|
|
301
|
-
return D().refine((
|
|
300
|
+
const { message: t, regexp: d = R } = e || {}, s = c.isString(d) ? new RegExp(d) : d;
|
|
301
|
+
return D().refine((n) => c.isStringEmpty(n) ? !0 : s.test(n), (t == null ? void 0 : t.invalid) || r.INVALID_URL()).optional().transform((n) => n != null && n.length ? n : void 0);
|
|
302
302
|
};
|
|
303
303
|
function Q(e) {
|
|
304
304
|
const { required: t = !0 } = e || {};
|
|
305
|
-
return t ?
|
|
305
|
+
return t ? W(e) : K(e);
|
|
306
306
|
}
|
|
307
307
|
const J = {
|
|
308
|
-
getStringSchema:
|
|
309
|
-
getEmailSchema:
|
|
310
|
-
getSelectSchema:
|
|
311
|
-
getNumberSchema:
|
|
312
|
-
getPhoneSchema:
|
|
308
|
+
getStringSchema: B,
|
|
309
|
+
getEmailSchema: w,
|
|
310
|
+
getSelectSchema: v,
|
|
311
|
+
getNumberSchema: G,
|
|
312
|
+
getPhoneSchema: x,
|
|
313
313
|
getDateSchema: H,
|
|
314
|
-
getUnionSchema:
|
|
314
|
+
getUnionSchema: j,
|
|
315
315
|
getUrlSchema: Q
|
|
316
316
|
};
|
|
317
317
|
class ce {
|
|
@@ -345,46 +345,46 @@ class ce {
|
|
|
345
345
|
* // }
|
|
346
346
|
* // }
|
|
347
347
|
*/
|
|
348
|
-
static getZodDefaults(t,
|
|
349
|
-
const { fillArrayWithValue: s } =
|
|
350
|
-
if (t instanceof
|
|
351
|
-
return t.innerType() instanceof
|
|
352
|
-
const
|
|
348
|
+
static getZodDefaults(t, d) {
|
|
349
|
+
const { fillArrayWithValue: s } = d || {};
|
|
350
|
+
if (t instanceof o.ZodEffects)
|
|
351
|
+
return t.innerType() instanceof o.ZodEffects ? this.getZodDefaults(t.innerType(), d) : this.getZodDefaults(o.ZodObject.create(t.innerType().shape), d);
|
|
352
|
+
const n = (a) => {
|
|
353
353
|
switch (!0) {
|
|
354
|
-
case a instanceof
|
|
354
|
+
case a instanceof o.ZodDefault:
|
|
355
355
|
return a._def.defaultValue();
|
|
356
|
-
case a instanceof
|
|
356
|
+
case a instanceof o.ZodOptional:
|
|
357
357
|
return;
|
|
358
|
-
case a instanceof
|
|
358
|
+
case a instanceof o.ZodNullable:
|
|
359
359
|
return null;
|
|
360
|
-
case a instanceof
|
|
361
|
-
return s ? [
|
|
362
|
-
case a instanceof
|
|
363
|
-
return this.getZodDefaults(a,
|
|
364
|
-
case a instanceof
|
|
365
|
-
return
|
|
366
|
-
case a instanceof
|
|
360
|
+
case a instanceof o.ZodArray:
|
|
361
|
+
return s ? [n(a.element)] : [];
|
|
362
|
+
case a instanceof o.ZodObject:
|
|
363
|
+
return this.getZodDefaults(a, d);
|
|
364
|
+
case a instanceof o.ZodUnion:
|
|
365
|
+
return n(a._def.options[0]);
|
|
366
|
+
case a instanceof o.ZodLiteral:
|
|
367
367
|
return a._def.value;
|
|
368
|
-
case a instanceof
|
|
368
|
+
case a instanceof o.ZodEnum:
|
|
369
369
|
return a._def.values[0];
|
|
370
|
-
case a instanceof
|
|
370
|
+
case a instanceof o.ZodString:
|
|
371
371
|
return "";
|
|
372
|
-
case a instanceof
|
|
372
|
+
case a instanceof o.ZodNumber:
|
|
373
373
|
return 0;
|
|
374
|
-
case a instanceof
|
|
374
|
+
case a instanceof o.ZodBoolean:
|
|
375
375
|
return !1;
|
|
376
376
|
case !("innerType" in a._def):
|
|
377
377
|
return;
|
|
378
378
|
default:
|
|
379
|
-
return
|
|
379
|
+
return n(a._def.innerType);
|
|
380
380
|
}
|
|
381
|
-
},
|
|
381
|
+
}, i = {};
|
|
382
382
|
return Object.entries(t.shape).map(([a, l]) => {
|
|
383
|
-
|
|
384
|
-
}),
|
|
383
|
+
i[a] = n(l);
|
|
384
|
+
}), i;
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
|
-
const
|
|
387
|
+
const g = {
|
|
388
388
|
NON_EMPTY: () => "Поле обязательно для заполнения",
|
|
389
389
|
VALUE_NO_WHITESPACE: () => "Укажите фамилию, имя и отчество через пробел",
|
|
390
390
|
ONLY_CYRILLIC: () => "Данные должны быть написаны кириллицей",
|
|
@@ -392,43 +392,43 @@ const E = {
|
|
|
392
392
|
INVALID_NAME: () => "Неверно введено имя",
|
|
393
393
|
INVALID_SURNAME: () => "Неверно введена фамилия",
|
|
394
394
|
INVALID_PATRONYMIC: () => "Неверно введено отчество"
|
|
395
|
-
},
|
|
395
|
+
}, m = {
|
|
396
396
|
ONLY_CYRILLIC: /[\u0400-\u04FF\u00CB\u00EB -]/g,
|
|
397
397
|
CHECK_HYPHEN: /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/,
|
|
398
398
|
PATRONYMIC: /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i
|
|
399
399
|
}, ee = (e) => {
|
|
400
|
-
const [t,
|
|
401
|
-
return { surname: t, name:
|
|
402
|
-
},
|
|
403
|
-
const { message: t } = e || {}, { nameOrSurnameEmpty:
|
|
404
|
-
return
|
|
405
|
-
const { name: l, surname:
|
|
406
|
-
|
|
407
|
-
code:
|
|
400
|
+
const [t, d, ...s] = e.trim().replace(/\s+/g, " ").split(" "), n = s.join(" ");
|
|
401
|
+
return { surname: t, name: d, patronymic: n };
|
|
402
|
+
}, S = (e) => {
|
|
403
|
+
const { message: t } = e || {}, { nameOrSurnameEmpty: d, invalidSurname: s, invalidPatronymic: n, invalidName: i } = t || {};
|
|
404
|
+
return o.string().superRefine((u, a) => {
|
|
405
|
+
const { name: l, surname: E, patronymic: _ } = ee(u);
|
|
406
|
+
m.ONLY_CYRILLIC.test(u) || a.addIssue({
|
|
407
|
+
code: o.ZodIssueCode.invalid_string,
|
|
408
408
|
validation: "regex",
|
|
409
|
-
message:
|
|
410
|
-
}), (!l || !
|
|
411
|
-
code:
|
|
409
|
+
message: g.ONLY_CYRILLIC()
|
|
410
|
+
}), (!l || !E) && a.addIssue({
|
|
411
|
+
code: o.ZodIssueCode.invalid_string,
|
|
412
412
|
validation: "regex",
|
|
413
|
-
message:
|
|
414
|
-
}),
|
|
415
|
-
code:
|
|
413
|
+
message: d || g.NAME_OR_SURNAME_NON_EMPTY()
|
|
414
|
+
}), m.CHECK_HYPHEN.test(l) || a.addIssue({
|
|
415
|
+
code: o.ZodIssueCode.invalid_string,
|
|
416
416
|
validation: "regex",
|
|
417
|
-
message:
|
|
418
|
-
}),
|
|
419
|
-
code:
|
|
417
|
+
message: i || g.INVALID_NAME()
|
|
418
|
+
}), m.CHECK_HYPHEN.test(E) || a.addIssue({
|
|
419
|
+
code: o.ZodIssueCode.invalid_string,
|
|
420
420
|
validation: "regex",
|
|
421
|
-
message: s ||
|
|
422
|
-
}),
|
|
423
|
-
code:
|
|
421
|
+
message: s || g.INVALID_SURNAME()
|
|
422
|
+
}), _ && (m.PATRONYMIC.test(_) || a.addIssue({
|
|
423
|
+
code: o.ZodIssueCode.invalid_string,
|
|
424
424
|
validation: "regex",
|
|
425
|
-
message:
|
|
425
|
+
message: n || g.INVALID_PATRONYMIC()
|
|
426
426
|
}));
|
|
427
427
|
}).transform((u) => u.trimEnd()).default("");
|
|
428
|
-
}, te = (e) =>
|
|
428
|
+
}, te = (e) => S(e).optional().transform((t) => t != null && t.length ? t : void 0);
|
|
429
429
|
function ne(e) {
|
|
430
|
-
const { required: t = !0, ...
|
|
431
|
-
return t ?
|
|
430
|
+
const { required: t = !0, ...d } = e || {};
|
|
431
|
+
return t ? S(d) : te(d);
|
|
432
432
|
}
|
|
433
433
|
const ie = {
|
|
434
434
|
getFioSchema: ne
|
|
@@ -439,7 +439,7 @@ const ie = {
|
|
|
439
439
|
export {
|
|
440
440
|
A as RgxCheckForHyphen,
|
|
441
441
|
h as RgxPatronymic,
|
|
442
|
-
|
|
442
|
+
Z as RgxUnicode,
|
|
443
443
|
I as VALIDATION_MESSAGES,
|
|
444
444
|
ce as ZodUtils,
|
|
445
445
|
r as baseDefaultMessages,
|