@scbt-ecom/ui 0.74.1 → 0.75.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/dist/index-BcOxdcOI.js +561 -0
- package/dist/{index-CrR6G9lz.js.map → index-BcOxdcOI.js.map} +1 -1
- package/dist/{index-B6MrMsbc.js → index-DRIZ5Qrl.js} +4897 -4883
- package/dist/{index-B6MrMsbc.js.map → index-DRIZ5Qrl.js.map} +1 -1
- package/dist/shared/ui/formElements/controlled/slider/SliderControl.d.ts +1 -1
- package/dist/shared/ui/formElements/uncontrolled/index.d.ts +1 -1
- package/dist/shared/ui/formElements/uncontrolled/slider/index.d.ts +1 -0
- package/dist/shared/ui/formElements/uncontrolled/slider/model/index.d.ts +2 -0
- package/dist/shared/ui/formElements/uncontrolled/slider/model/types.d.ts +10 -0
- package/dist/shared/ui/formElements/uncontrolled/slider/ui/Slider.d.ts +3 -1
- package/dist/shared/ui/formElements/uncontrolled/slider/ui/sliderAlgorithmic/SliderAlgorithmic.d.ts +1 -1
- package/dist/shared/ui/formElements/uncontrolled/slider/ui/sliderMarks/SliderMarks.d.ts +1 -1
- package/dist/shared/ui/formElements/uncontrolled/slider/ui/sliderStep/SliderStep.d.ts +1 -1
- package/dist/ui.js +3 -3
- package/dist/{utils-k3uzuyeN.js → utils-CaWgHX_C.js} +1224 -1256
- package/dist/utils-CaWgHX_C.js.map +1 -0
- package/dist/validation.js +47 -47
- package/dist/validation.js.map +1 -1
- package/dist/widget.js +953 -891
- package/dist/widget.js.map +1 -1
- package/dist/widgets/calculator/ui/calculatorFields/CalculatorFields.d.ts +4 -1
- package/dist/widgets/calculator/ui/calculatorFields/hooks/index.d.ts +1 -0
- package/dist/widgets/calculator/ui/calculatorFields/hooks/useAdditionalSlider.d.ts +19 -0
- package/dist/widgets/calculator/ui/calculatorFields/ui/AdditionalSlider.d.ts +8 -0
- package/dist/widgets/calculator/ui/calculatorFields/ui/FieldsGroup.d.ts +6 -1
- package/dist/widgets/calculator/ui/calculatorFields/ui/index.d.ts +1 -0
- package/dist/widgets/model/utils.d.ts +1 -1
- package/package.json +1 -1
- package/dist/index-CrR6G9lz.js +0 -446
- package/dist/utils-k3uzuyeN.js.map +0 -1
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import { B as b, D as V, E as h, I as U, N as Y, O as w, P as x, a as T, b as H, d as v, e as G, f as q, g as F, h as j, j as X, k as $, l as B, m as I, n as z, o as k, q as K, r as W, t as J, Z as Q, u as ee, v as te, w as ne, x as ae, y as ie, z as oe, A as re, C as se, F as de, G as le, H as ue, J as ce, K as fe, L as _e, M as ge, Q as me, R as Ee, S as Te, T as Ne, U as Ie, V as Ze, W as ye, X as Ae, Y as Le, _ as pe, $ as Oe, a0 as De, a1 as Me, a2 as Se, c as Re, a3 as Pe, a4 as Ce, a5 as be, a6 as Ve, a7 as he, a8 as Z, a9 as Ue, aa as Ye, ab as we, ac as xe, ad as He, ae as ve, af as Ge, ag as qe, ah as Fe, ai as je, aj as Xe, ak as $e, al as Be, am as ze, an as ke, ao as Ke, ap as We, aq as Je, ar as Qe, as as et, at as tt, au as nt, av as at, aw as it, ax as ot, ay as rt, az as st, aA as dt, aB as lt, aC as ut, aD as ct, aE as ft, aF as _t, aG as gt, aH as mt, s as N, aI as Et, aJ as Tt, aK as Nt, aL as It, aM as Zt, aN as yt, aO as At, aP as y, aQ as A, p as L, i as p } from "./utils-CaWgHX_C.js";
|
|
2
|
+
import { T as f } from "./typeGuards-CSiImkUY.js";
|
|
3
|
+
const d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
|
+
__proto__: null,
|
|
5
|
+
BRAND: b,
|
|
6
|
+
DIRTY: V,
|
|
7
|
+
EMPTY_PATH: h,
|
|
8
|
+
INVALID: U,
|
|
9
|
+
NEVER: Y,
|
|
10
|
+
OK: w,
|
|
11
|
+
ParseStatus: x,
|
|
12
|
+
Schema: T,
|
|
13
|
+
ZodAny: H,
|
|
14
|
+
ZodArray: v,
|
|
15
|
+
ZodBigInt: G,
|
|
16
|
+
ZodBoolean: q,
|
|
17
|
+
ZodBranded: F,
|
|
18
|
+
ZodCatch: j,
|
|
19
|
+
ZodDate: X,
|
|
20
|
+
ZodDefault: $,
|
|
21
|
+
ZodDiscriminatedUnion: B,
|
|
22
|
+
ZodEffects: I,
|
|
23
|
+
ZodEnum: z,
|
|
24
|
+
ZodError: k,
|
|
25
|
+
get ZodFirstPartyTypeKind() {
|
|
26
|
+
return K;
|
|
27
|
+
},
|
|
28
|
+
ZodFunction: W,
|
|
29
|
+
ZodIntersection: J,
|
|
30
|
+
ZodIssueCode: Q,
|
|
31
|
+
ZodLazy: ee,
|
|
32
|
+
ZodLiteral: te,
|
|
33
|
+
ZodMap: ne,
|
|
34
|
+
ZodNaN: ae,
|
|
35
|
+
ZodNativeEnum: ie,
|
|
36
|
+
ZodNever: oe,
|
|
37
|
+
ZodNull: re,
|
|
38
|
+
ZodNullable: se,
|
|
39
|
+
ZodNumber: de,
|
|
40
|
+
ZodObject: le,
|
|
41
|
+
ZodOptional: ue,
|
|
42
|
+
ZodParsedType: ce,
|
|
43
|
+
ZodPipeline: fe,
|
|
44
|
+
ZodPromise: _e,
|
|
45
|
+
ZodReadonly: ge,
|
|
46
|
+
ZodRecord: me,
|
|
47
|
+
ZodSchema: T,
|
|
48
|
+
ZodSet: Ee,
|
|
49
|
+
ZodString: Te,
|
|
50
|
+
ZodSymbol: Ne,
|
|
51
|
+
ZodTransformer: I,
|
|
52
|
+
ZodTuple: Ie,
|
|
53
|
+
ZodType: T,
|
|
54
|
+
ZodUndefined: Ze,
|
|
55
|
+
ZodUnion: ye,
|
|
56
|
+
ZodUnknown: Ae,
|
|
57
|
+
ZodVoid: Le,
|
|
58
|
+
addIssueToContext: pe,
|
|
59
|
+
any: Oe,
|
|
60
|
+
array: De,
|
|
61
|
+
bigint: Me,
|
|
62
|
+
boolean: Se,
|
|
63
|
+
coerce: Re,
|
|
64
|
+
custom: Pe,
|
|
65
|
+
date: Ce,
|
|
66
|
+
datetimeRegex: be,
|
|
67
|
+
defaultErrorMap: Ve,
|
|
68
|
+
discriminatedUnion: he,
|
|
69
|
+
effect: Z,
|
|
70
|
+
enum: Ue,
|
|
71
|
+
function: Ye,
|
|
72
|
+
getErrorMap: we,
|
|
73
|
+
getParsedType: xe,
|
|
74
|
+
instanceof: He,
|
|
75
|
+
intersection: ve,
|
|
76
|
+
isAborted: Ge,
|
|
77
|
+
isAsync: qe,
|
|
78
|
+
isDirty: Fe,
|
|
79
|
+
isValid: je,
|
|
80
|
+
late: Xe,
|
|
81
|
+
lazy: $e,
|
|
82
|
+
literal: Be,
|
|
83
|
+
makeIssue: ze,
|
|
84
|
+
map: ke,
|
|
85
|
+
nan: Ke,
|
|
86
|
+
nativeEnum: We,
|
|
87
|
+
never: Je,
|
|
88
|
+
null: Qe,
|
|
89
|
+
nullable: et,
|
|
90
|
+
number: tt,
|
|
91
|
+
object: nt,
|
|
92
|
+
get objectUtil() {
|
|
93
|
+
return at;
|
|
94
|
+
},
|
|
95
|
+
oboolean: it,
|
|
96
|
+
onumber: ot,
|
|
97
|
+
optional: rt,
|
|
98
|
+
ostring: st,
|
|
99
|
+
pipeline: dt,
|
|
100
|
+
preprocess: lt,
|
|
101
|
+
promise: ut,
|
|
102
|
+
quotelessJson: ct,
|
|
103
|
+
record: ft,
|
|
104
|
+
set: _t,
|
|
105
|
+
setErrorMap: gt,
|
|
106
|
+
strictObject: mt,
|
|
107
|
+
string: N,
|
|
108
|
+
symbol: Et,
|
|
109
|
+
transformer: Z,
|
|
110
|
+
tuple: Tt,
|
|
111
|
+
undefined: Nt,
|
|
112
|
+
union: It,
|
|
113
|
+
unknown: Zt,
|
|
114
|
+
get util() {
|
|
115
|
+
return yt;
|
|
116
|
+
},
|
|
117
|
+
void: At
|
|
118
|
+
}, Symbol.toStringTag, { value: "Module" })), O = (e) => {
|
|
119
|
+
const { defaultValue: t } = e || {};
|
|
120
|
+
return d.boolean().default(t ?? !1);
|
|
121
|
+
}, Lt = (e) => O(e).optional();
|
|
122
|
+
function pt(e) {
|
|
123
|
+
const { required: t = !0, ...i } = e || {};
|
|
124
|
+
return t ? O(i) : Lt(i);
|
|
125
|
+
}
|
|
126
|
+
const l = {
|
|
127
|
+
NON_EMPTY: () => "Поле не может быть пустым",
|
|
128
|
+
MIN_LENGTH: (e) => `Поле должно содержать минимум символов: ${e}`,
|
|
129
|
+
MAX_LENGTH: (e) => `Поле должно содержать максимум символов: ${e}`,
|
|
130
|
+
FIX_LENGTH: (e) => `Поле должно быть фиксированной длины символов: ${e}`,
|
|
131
|
+
MIN_VALUE: (e) => `Значение не может быть меньше чем ${e}`,
|
|
132
|
+
MAX_VALUE: (e) => `Значение не может быть больше чем ${e}`,
|
|
133
|
+
PHONE_NON_EMPTY: () => "Номер телефона должен состоять из 11 цифр",
|
|
134
|
+
PHONE_INVALID_OPERATOR: () => "Код города/оператора должен начинаться с цифры 3, 4, 5, 6 или 9",
|
|
135
|
+
EMAIL_INVALID: () => "Email введен некорректно. Пример: example@domain.ru",
|
|
136
|
+
EMAIL_NON_EMPTY: () => "Введите адрес электронной почты",
|
|
137
|
+
SELECT_NON_EMPTY: () => "Выберите один из вариантов",
|
|
138
|
+
SELECT_MULTIPLE_MIN_LENGTH: (e) => `Выберите не менее ${e} вариантов`,
|
|
139
|
+
SELECT_MULTIPLE_MAX_LENGTH: (e) => `Выберите не более ${e} вариантов`,
|
|
140
|
+
SELECT_FIX_LENGTH: (e) => `Поле должно быть фиксированного количества вариантов: ${e}`,
|
|
141
|
+
DATE_INVALID_FORMAT: () => "Дата указана некорректно",
|
|
142
|
+
DATE_NON_EMPTY: () => "Укажите дату",
|
|
143
|
+
VALUE_OUT_OF_RANGE: (e) => `Выберите один из вариантов ${e.join(", ")}`,
|
|
144
|
+
DATE_MIN: (e) => {
|
|
145
|
+
const t = f.isString(e) ? new Date(e) : e;
|
|
146
|
+
return `Выбранная дата должна быть не раньше ${y(t)}`;
|
|
147
|
+
},
|
|
148
|
+
DATE_MAX: (e) => {
|
|
149
|
+
const t = f.isString(e) ? new Date(e) : e;
|
|
150
|
+
return `Выбранная дата должна быть не позже ${y(t)}`;
|
|
151
|
+
},
|
|
152
|
+
INVALID_REGEX_STRING: () => "Поле не соответствует требованиям",
|
|
153
|
+
INVALID_URL: () => "Ссылка введена некорректно. Пример: https://example.com, example.com"
|
|
154
|
+
}, Ot = (e) => {
|
|
155
|
+
const { iso: t = !0, pattern: i = A, min: n, max: a, defaultValue: o, message: r } = e || {};
|
|
156
|
+
return d.string().min(8, (r == null ? void 0 : r.min) || l.DATE_NON_EMPTY()).superRefine((u, s) => {
|
|
157
|
+
const c = i.replace(/\W/g, "").length;
|
|
158
|
+
if (u.replace(/[._-]/g, "").length < c && s.addIssue({
|
|
159
|
+
code: d.ZodIssueCode.too_small,
|
|
160
|
+
minimum: c,
|
|
161
|
+
type: "date",
|
|
162
|
+
inclusive: !0,
|
|
163
|
+
message: (r == null ? void 0 : r.min) || l.DATE_NON_EMPTY()
|
|
164
|
+
}), t) {
|
|
165
|
+
let g = null;
|
|
166
|
+
try {
|
|
167
|
+
g = new Date(u);
|
|
168
|
+
} catch {
|
|
169
|
+
s.addIssue({
|
|
170
|
+
code: d.ZodIssueCode.invalid_date,
|
|
171
|
+
message: (r == null ? void 0 : r.invalidDate) || l.DATE_INVALID_FORMAT()
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
n && g.getTime() < (f.isString(n) ? new Date(n).getTime() : n.getTime()) && s.addIssue({
|
|
175
|
+
code: d.ZodIssueCode.invalid_date,
|
|
176
|
+
message: (r == null ? void 0 : r.min) || l.DATE_MIN(n)
|
|
177
|
+
}), a && g.getTime() > (f.isString(a) ? new Date(a).getTime() : a.getTime()) && s.addIssue({
|
|
178
|
+
code: d.ZodIssueCode.invalid_date,
|
|
179
|
+
message: (r == null ? void 0 : r.max) || l.DATE_MAX(a)
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
const g = L(u, i, /* @__PURE__ */ new Date());
|
|
183
|
+
p(g) || s.addIssue({
|
|
184
|
+
code: d.ZodIssueCode.invalid_date,
|
|
185
|
+
message: (r == null ? void 0 : r.invalidDate) || l.DATE_INVALID_FORMAT()
|
|
186
|
+
}), n && g.getTime() < (f.isString(n) ? new Date(n).getTime() : n.getTime()) && s.addIssue({
|
|
187
|
+
code: d.ZodIssueCode.invalid_date,
|
|
188
|
+
message: (r == null ? void 0 : r.min) || l.DATE_MIN(n)
|
|
189
|
+
}), a && g.getTime() > (f.isString(a) ? new Date(a).getTime() : a.getTime()) && s.addIssue({
|
|
190
|
+
code: d.ZodIssueCode.invalid_date,
|
|
191
|
+
message: (r == null ? void 0 : r.max) || l.DATE_MAX(a)
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}).default(o ?? "");
|
|
195
|
+
}, Dt = (e) => {
|
|
196
|
+
const { iso: t = !0, pattern: i = A, min: n, max: a, message: o } = e || {};
|
|
197
|
+
return d.string().transform((r) => r || void 0).superRefine((r, u) => {
|
|
198
|
+
if (f.isString(r) && r.length) {
|
|
199
|
+
const s = i.replace(/\W/g, "").length;
|
|
200
|
+
if (r.replace(/[._-]/g, "").length < s && u.addIssue({
|
|
201
|
+
code: d.ZodIssueCode.too_small,
|
|
202
|
+
minimum: s,
|
|
203
|
+
type: "date",
|
|
204
|
+
inclusive: !0,
|
|
205
|
+
message: (o == null ? void 0 : o.min) || l.DATE_NON_EMPTY()
|
|
206
|
+
}), t) {
|
|
207
|
+
let _ = null;
|
|
208
|
+
try {
|
|
209
|
+
_ = new Date(r);
|
|
210
|
+
} catch {
|
|
211
|
+
u.addIssue({
|
|
212
|
+
code: d.ZodIssueCode.invalid_date,
|
|
213
|
+
message: (o == null ? void 0 : o.invalidDate) || l.DATE_INVALID_FORMAT()
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
n && _.getTime() < (f.isString(n) ? new Date(n).getTime() : n.getTime()) && u.addIssue({
|
|
217
|
+
code: d.ZodIssueCode.invalid_date,
|
|
218
|
+
message: (o == null ? void 0 : o.min) || l.DATE_MIN(n)
|
|
219
|
+
}), a && _.getTime() > (f.isString(a) ? new Date(a).getTime() : a.getTime()) && u.addIssue({
|
|
220
|
+
code: d.ZodIssueCode.invalid_date,
|
|
221
|
+
message: (o == null ? void 0 : o.max) || l.DATE_MAX(a)
|
|
222
|
+
});
|
|
223
|
+
} else {
|
|
224
|
+
const _ = L(r, i, /* @__PURE__ */ new Date());
|
|
225
|
+
p(_) || u.addIssue({
|
|
226
|
+
code: d.ZodIssueCode.invalid_date,
|
|
227
|
+
message: (o == null ? void 0 : o.invalidDate) || l.DATE_INVALID_FORMAT()
|
|
228
|
+
}), n && _.getTime() < (f.isString(n) ? new Date(n).getTime() : n.getTime()) && u.addIssue({
|
|
229
|
+
code: d.ZodIssueCode.invalid_date,
|
|
230
|
+
message: (o == null ? void 0 : o.min) || l.DATE_MIN(n)
|
|
231
|
+
}), a && _.getTime() > (f.isString(a) ? new Date(a).getTime() : a.getTime()) && u.addIssue({
|
|
232
|
+
code: d.ZodIssueCode.invalid_date,
|
|
233
|
+
message: (o == null ? void 0 : o.max) || l.DATE_MAX(a)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}).optional();
|
|
238
|
+
};
|
|
239
|
+
function Mt(e) {
|
|
240
|
+
const { required: t = !0 } = e || {};
|
|
241
|
+
return t ? Ot(e) : Dt(e);
|
|
242
|
+
}
|
|
243
|
+
const D = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/g, St = (e) => {
|
|
244
|
+
const { message: t, defaultValue: i, regexp: n = D } = e || {}, a = f.isString(n) ? new RegExp(n) : n;
|
|
245
|
+
return d.string().min(1, (t == null ? void 0 : t.min) || l.EMAIL_NON_EMPTY()).regex(a, (t == null ? void 0 : t.invalid) || l.EMAIL_INVALID()).default(i ?? "");
|
|
246
|
+
}, Rt = (e) => {
|
|
247
|
+
const { message: t, regexp: i = D } = e || {}, n = f.isString(i) ? new RegExp(i) : i;
|
|
248
|
+
return d.string().refine(
|
|
249
|
+
(a) => f.isStringEmpty(a) ? !0 : n.test(a),
|
|
250
|
+
{
|
|
251
|
+
message: (t == null ? void 0 : t.invalid) || l.EMAIL_INVALID()
|
|
252
|
+
}
|
|
253
|
+
).optional().transform((a) => (a == null ? void 0 : a.length) === 0 ? void 0 : a);
|
|
254
|
+
};
|
|
255
|
+
function Pt(e) {
|
|
256
|
+
const { required: t = !0 } = e || {};
|
|
257
|
+
return t ? St(e) : Rt(e);
|
|
258
|
+
}
|
|
259
|
+
const M = (e) => {
|
|
260
|
+
const { min: t, max: i, message: n, defaultValue: a } = e || {};
|
|
261
|
+
let o = d.coerce.number();
|
|
262
|
+
return t && (o = o.min(t, (n == null ? void 0 : n.min) || l.MIN_VALUE(t))), i && (o = o.max(i, (n == null ? void 0 : n.min) || l.MAX_VALUE(i))), o.default(a ?? 0);
|
|
263
|
+
}, Ct = (e) => M(e).optional().transform((t) => t || void 0);
|
|
264
|
+
function bt(e) {
|
|
265
|
+
const { required: t = !0 } = e || {};
|
|
266
|
+
return t ? M(e) : Ct(e);
|
|
267
|
+
}
|
|
268
|
+
const Vt = (e) => {
|
|
269
|
+
const {
|
|
270
|
+
ignoreMask: t = !0,
|
|
271
|
+
maskSymbols: i = /[()+_ -]/g,
|
|
272
|
+
message: n,
|
|
273
|
+
defaultValue: a,
|
|
274
|
+
validOperatorCodes: o = ["3", "4", "5", "6", "7", "9"]
|
|
275
|
+
} = e || {}, r = f.isString(i) ? new RegExp(i) : i;
|
|
276
|
+
let u = d.string().superRefine((s, c) => {
|
|
277
|
+
const _ = s.replace(r, ""), g = _.charAt(1);
|
|
278
|
+
o.includes(g) || c.addIssue({
|
|
279
|
+
code: d.ZodIssueCode.invalid_string,
|
|
280
|
+
validation: "regex",
|
|
281
|
+
message: (n == null ? void 0 : n.invalidOperator) || l.PHONE_INVALID_OPERATOR()
|
|
282
|
+
}), _.length < 11 && c.addIssue({
|
|
283
|
+
code: d.ZodIssueCode.too_small,
|
|
284
|
+
minimum: 11,
|
|
285
|
+
inclusive: !0,
|
|
286
|
+
type: "string",
|
|
287
|
+
message: (n == null ? void 0 : n.min) || l.PHONE_NON_EMPTY()
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
return t && (u = u.transform((s) => s.replace(r, ""))), u.default(a ?? "");
|
|
291
|
+
}, ht = (e) => {
|
|
292
|
+
const {
|
|
293
|
+
ignoreMask: t = !0,
|
|
294
|
+
maskSymbols: i = /[()+_ -]/g,
|
|
295
|
+
message: n,
|
|
296
|
+
validOperatorCodes: a = ["3", "4", "5", "6", "7", "9"]
|
|
297
|
+
} = e || {}, o = f.isString(i) ? new RegExp(i) : i;
|
|
298
|
+
let r = d.string().superRefine((u, s) => {
|
|
299
|
+
const c = u.replace(o, ""), _ = c.charAt(1);
|
|
300
|
+
a.includes(_) || s.addIssue({
|
|
301
|
+
code: d.ZodIssueCode.invalid_string,
|
|
302
|
+
validation: "regex",
|
|
303
|
+
message: (n == null ? void 0 : n.invalidOperator) || l.PHONE_INVALID_OPERATOR()
|
|
304
|
+
}), c.length < 11 && s.addIssue({
|
|
305
|
+
code: d.ZodIssueCode.too_small,
|
|
306
|
+
minimum: 11,
|
|
307
|
+
inclusive: !0,
|
|
308
|
+
type: "string",
|
|
309
|
+
message: (n == null ? void 0 : n.min) || l.PHONE_NON_EMPTY()
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
return t && (r = r.transform((u) => u.replace(o, ""))), r.transform((u) => u || void 0);
|
|
313
|
+
};
|
|
314
|
+
function Ut(e) {
|
|
315
|
+
const { required: t = !0 } = e || {};
|
|
316
|
+
return t ? Vt(e) : ht(e);
|
|
317
|
+
}
|
|
318
|
+
const S = (e, t) => {
|
|
319
|
+
const { message: i, defaultValue: n = "" } = t || {};
|
|
320
|
+
return d.string().nonempty(l.NON_EMPTY()).regex(e, i || l.INVALID_REGEX_STRING()).default(n);
|
|
321
|
+
}, Yt = (e, t) => S(e, t).optional().transform((i) => i != null && i.length ? i : void 0);
|
|
322
|
+
function wt(e, t) {
|
|
323
|
+
const { required: i = !0, ...n } = t || {};
|
|
324
|
+
return i ? S(e, n) : Yt(e, n);
|
|
325
|
+
}
|
|
326
|
+
const xt = (e) => {
|
|
327
|
+
var a, o;
|
|
328
|
+
const { message: t, defaultValue: i } = e || {}, n = d.string().min(1, (t == null ? void 0 : t.single) || l.SELECT_NON_EMPTY()).nullable().refine((r) => !!r, (t == null ? void 0 : t.single) || l.SELECT_NON_EMPTY()).default(i ?? null);
|
|
329
|
+
if (e != null && e.multiple) {
|
|
330
|
+
let r = d.array(n).min((e == null ? void 0 : e.minLength) || 0, (t == null ? void 0 : t.multiple) || l.SELECT_MULTIPLE_MIN_LENGTH((e == null ? void 0 : e.minLength) || 0));
|
|
331
|
+
return e != null && e.length ? r.length(e.length, ((a = e.message) == null ? void 0 : a.length) || l.SELECT_FIX_LENGTH(e.length)).default([]) : (e != null && e.maxLength && (r = r.max(
|
|
332
|
+
e.maxLength,
|
|
333
|
+
((o = e.message) == null ? void 0 : o.maxLength) || l.SELECT_MULTIPLE_MAX_LENGTH(e.maxLength)
|
|
334
|
+
)), r.default([]));
|
|
335
|
+
}
|
|
336
|
+
return n;
|
|
337
|
+
};
|
|
338
|
+
function Ht(e) {
|
|
339
|
+
const t = d.string().nullable().optional();
|
|
340
|
+
return e != null && e.multiple ? d.array(t).optional() : t;
|
|
341
|
+
}
|
|
342
|
+
function vt(e) {
|
|
343
|
+
const { required: t = !0 } = e || {};
|
|
344
|
+
return t ? xt(e) : Ht(e);
|
|
345
|
+
}
|
|
346
|
+
const Gt = (e) => {
|
|
347
|
+
const { min: t, max: i, length: n, defaultValue: a, message: o } = e || {};
|
|
348
|
+
let r = d.string({ message: o == null ? void 0 : o.root });
|
|
349
|
+
return t && (r = r.min(t, { message: (o == null ? void 0 : o.min) || l.MIN_LENGTH(t) })), i && (r = r.max(i, { message: (o == null ? void 0 : o.max) || l.MAX_LENGTH(i) })), n && (r = r.length(n, { message: (o == null ? void 0 : o.length) || l.FIX_LENGTH(n) })), r.refine((u) => !!u.length, { message: (o == null ? void 0 : o.min) || l.NON_EMPTY() }).default(a ?? "");
|
|
350
|
+
}, qt = (e) => {
|
|
351
|
+
const { min: t, max: i, length: n, message: a } = e || {};
|
|
352
|
+
let o = d.string({ message: a == null ? void 0 : a.root });
|
|
353
|
+
return t && (o = o.min(t, { message: (a == null ? void 0 : a.min) || l.MIN_LENGTH(t) })), i && (o = o.max(i, { message: (a == null ? void 0 : a.max) || l.MAX_LENGTH(i) })), n && (o = o.length(n, { message: (a == null ? void 0 : a.length) || l.FIX_LENGTH(n) })), o.optional().transform((r) => r != null && r.length ? r : void 0);
|
|
354
|
+
};
|
|
355
|
+
function Ft(e) {
|
|
356
|
+
const { required: t = !0, ...i } = e || {};
|
|
357
|
+
return t ? Gt(i) : qt(i);
|
|
358
|
+
}
|
|
359
|
+
const R = (e, t) => {
|
|
360
|
+
const { message: i, ...n } = t || {}, [a, o, ...r] = e.map((s) => d.literal(s)), u = i ? typeof i == "function" ? i(e) : i : l.VALUE_OUT_OF_RANGE(e);
|
|
361
|
+
return d.union([a, o, ...r], {
|
|
362
|
+
message: u,
|
|
363
|
+
...n
|
|
364
|
+
}).nullable().refine(Boolean, l.NON_EMPTY()).default(null);
|
|
365
|
+
}, jt = (e, t) => R(e, t).optional();
|
|
366
|
+
function Xt(e, t) {
|
|
367
|
+
const { required: i, ...n } = t || {};
|
|
368
|
+
return i ? R(e, n) : jt(e, n);
|
|
369
|
+
}
|
|
370
|
+
const P = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([-.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/, $t = (e) => {
|
|
371
|
+
const { message: t, defaultValue: i, regexp: n = P } = e || {}, a = f.isString(n) ? new RegExp(n) : n;
|
|
372
|
+
return N().min(1, (t == null ? void 0 : t.min) || l.NON_EMPTY()).regex(a, (t == null ? void 0 : t.invalid) || l.INVALID_URL()).default(i ?? "");
|
|
373
|
+
}, Bt = (e) => {
|
|
374
|
+
const { message: t, regexp: i = P } = e || {}, n = f.isString(i) ? new RegExp(i) : i;
|
|
375
|
+
return N().refine((a) => f.isStringEmpty(a) ? !0 : n.test(a), (t == null ? void 0 : t.invalid) || l.INVALID_URL()).optional().transform((a) => a != null && a.length ? a : void 0);
|
|
376
|
+
};
|
|
377
|
+
function zt(e) {
|
|
378
|
+
const { required: t = !0 } = e || {};
|
|
379
|
+
return t ? $t(e) : Bt(e);
|
|
380
|
+
}
|
|
381
|
+
const kt = {
|
|
382
|
+
getStringSchema: Ft,
|
|
383
|
+
getEmailSchema: Pt,
|
|
384
|
+
getSelectSchema: vt,
|
|
385
|
+
getNumberSchema: bt,
|
|
386
|
+
getPhoneSchema: Ut,
|
|
387
|
+
getDateSchema: Mt,
|
|
388
|
+
getUnionSchema: Xt,
|
|
389
|
+
getUrlSchema: zt,
|
|
390
|
+
getRegexSchema: wt,
|
|
391
|
+
getBooleanSchema: pt
|
|
392
|
+
};
|
|
393
|
+
class nn {
|
|
394
|
+
/**
|
|
395
|
+
* Функция для получения значения по умолчанию исходя из схемы
|
|
396
|
+
* @param zodSchema схема формы
|
|
397
|
+
* @param options настройки генерации значений по умолчанию
|
|
398
|
+
* @returns объект значений по умолчанию
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* const schema = z.object({
|
|
402
|
+
* name: zodValidators.base.getStringSchema(),
|
|
403
|
+
* role: zodValidators.base.getUnionSchema(['UNKNOWN', 'ADMIN', 'MODERATOR', 'USER'] as const),
|
|
404
|
+
* info: z.object({
|
|
405
|
+
* address: zodValidators.base.getStringSchema(),
|
|
406
|
+
* phone: zodValidators.base.getPhoneSchema({ ignoreMask: true }),
|
|
407
|
+
* age: zodValidators.base.getNumberSchema()
|
|
408
|
+
* })
|
|
409
|
+
* })
|
|
410
|
+
*
|
|
411
|
+
* const defaultValues = ZodUtils.getZodDefaults(schema)
|
|
412
|
+
*
|
|
413
|
+
* // default values will be inferred from schema
|
|
414
|
+
* // {
|
|
415
|
+
* // name: '',
|
|
416
|
+
* // role: 'UNKNOWN',
|
|
417
|
+
* // info: {
|
|
418
|
+
* // address: '',
|
|
419
|
+
* // phone: '',
|
|
420
|
+
* // age: 0
|
|
421
|
+
* // }
|
|
422
|
+
* // }
|
|
423
|
+
*/
|
|
424
|
+
static getZodDefaults(t, i) {
|
|
425
|
+
const { fillArrayWithValue: n } = i || {}, a = (s) => {
|
|
426
|
+
const c = s._def.schema;
|
|
427
|
+
return c instanceof d.ZodEffects || c._def.typeName === "ZodEffects" ? a(c) : c instanceof d.ZodObject || c._def.typeName === "ZodObject" ? this.getZodDefaults(c, i) : o(c);
|
|
428
|
+
}, o = (s) => {
|
|
429
|
+
if (s instanceof d.ZodEffects || s._def.typeName === "ZodEffects")
|
|
430
|
+
return a(s);
|
|
431
|
+
switch (!0) {
|
|
432
|
+
case (s._def.typeName === "ZodDefault" || s instanceof d.ZodDefault):
|
|
433
|
+
return s._def.defaultValue();
|
|
434
|
+
case (s._def.typeName === "ZodOptional" || s instanceof d.ZodOptional):
|
|
435
|
+
return;
|
|
436
|
+
case s._def.typeName === "ZodEffects":
|
|
437
|
+
return a(s);
|
|
438
|
+
case (s._def.typeName === "ZodNullable" || s instanceof d.ZodNullable):
|
|
439
|
+
return null;
|
|
440
|
+
case (s._def.typeName === "ZodArray" || s instanceof d.ZodArray):
|
|
441
|
+
return n ? [o(s.element)] : [];
|
|
442
|
+
case (s._def.typeName === "ZodObject" || s instanceof d.ZodObject):
|
|
443
|
+
return this.getZodDefaults(s, i);
|
|
444
|
+
case (s._def.typeName === "ZodUnion" || s instanceof d.ZodUnion):
|
|
445
|
+
return o(s._def.options[0]);
|
|
446
|
+
case (s._def.typeName === "ZodLiteral" || s instanceof d.ZodLiteral):
|
|
447
|
+
return s._def.value;
|
|
448
|
+
case (s._def.typeName === "ZodDiscriminatedUnion" || s instanceof d.ZodDiscriminatedUnion):
|
|
449
|
+
return o(s._def.options[0]);
|
|
450
|
+
case (s._def.typeName === "ZodEnum" || s instanceof d.ZodEnum):
|
|
451
|
+
return s._def.values[0];
|
|
452
|
+
case (s._def.typeName === "ZodString" || s instanceof d.ZodString):
|
|
453
|
+
return "";
|
|
454
|
+
case (s._def.typeName === "ZodNumber" || s instanceof d.ZodNumber):
|
|
455
|
+
return 0;
|
|
456
|
+
case (s._def.typeName === "ZodBoolean" || s instanceof d.ZodBoolean):
|
|
457
|
+
return !1;
|
|
458
|
+
case !("innerType" in s._def):
|
|
459
|
+
return;
|
|
460
|
+
default:
|
|
461
|
+
return o(s._def.innerType);
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
if (t instanceof d.ZodEffects || t._def.typeName === "ZodEffects")
|
|
465
|
+
return a(t);
|
|
466
|
+
const r = {};
|
|
467
|
+
return Object.entries(t.shape).map(([s, c]) => {
|
|
468
|
+
r[s] = o(c);
|
|
469
|
+
}), r;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Функция для объединения zod схождений
|
|
473
|
+
* @param {ZodIntersection} zodSchema
|
|
474
|
+
* @returns объединенная схема двух схождений
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* let schema = z.object({
|
|
478
|
+
* foo: z.string()
|
|
479
|
+
* })
|
|
480
|
+
* // this will return intersection and we need
|
|
481
|
+
* // to merge its left to right schema's
|
|
482
|
+
* .and(
|
|
483
|
+
* z.object({
|
|
484
|
+
* bar: z.string()
|
|
485
|
+
* })
|
|
486
|
+
* )
|
|
487
|
+
*
|
|
488
|
+
* schema = ZodUtils.zodMergeIntersection(schema)
|
|
489
|
+
*
|
|
490
|
+
* // schema will be
|
|
491
|
+
* z.object({
|
|
492
|
+
* foo: z.string(),
|
|
493
|
+
* bar: z.string()
|
|
494
|
+
* })
|
|
495
|
+
*/
|
|
496
|
+
static zodMergeIntersection(t) {
|
|
497
|
+
const { left: i, right: n } = t._def, a = i instanceof d.ZodDiscriminatedUnion || i._def.typeName === "ZodDiscriminatedUnion" ? i._def.options[0] : i, o = n instanceof d.ZodDiscriminatedUnion || n._def.typeName === "ZodDiscriminatedUnion" ? n._def.options[0] : n;
|
|
498
|
+
if ((a._def.typeName === "ZodObject" || a instanceof d.ZodObject) && (o._def.typeName === "ZodObject" || o instanceof d.ZodObject))
|
|
499
|
+
return a.merge(o);
|
|
500
|
+
throw new Error(`Cannot merge schema type ${o._def.typeName} to ${a._def.typeName}`);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
const m = {
|
|
504
|
+
NON_EMPTY: () => "Поле обязательно для заполнения",
|
|
505
|
+
VALUE_NO_WHITESPACE: () => "Укажите фамилию, имя и отчество через пробел",
|
|
506
|
+
ONLY_CYRILLIC: () => "Данные должны быть написаны кириллицей",
|
|
507
|
+
NAME_OR_SURNAME_NON_EMPTY: () => "Укажите имя и фамилию",
|
|
508
|
+
INVALID_NAME: () => "Неверно введено имя",
|
|
509
|
+
INVALID_SURNAME: () => "Неверно введена фамилия",
|
|
510
|
+
INVALID_PATRONYMIC: () => "Неверно введено отчество"
|
|
511
|
+
}, E = {
|
|
512
|
+
ONLY_CYRILLIC: /[\u0400-\u04FF\u00CB\u00EB -]/g,
|
|
513
|
+
CHECK_HYPHEN: /^(?:[^-]+(?:-[^-]+){0,4}|[^-]+)$/,
|
|
514
|
+
PATRONYMIC: /^[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4}(?:\s+[a-zA-Zа-яА-ЯёЁ]+(?:\s*-\s*[a-zA-Zа-яА-ЯёЁ]+){0,4})?$/i
|
|
515
|
+
}, Kt = (e) => {
|
|
516
|
+
const [t, i, ...n] = e.trim().replace(/\s+/g, " ").split(" "), a = n.join(" ");
|
|
517
|
+
return { surname: t, name: i, patronymic: a };
|
|
518
|
+
}, C = (e) => {
|
|
519
|
+
const { message: t } = e || {}, { nameOrSurnameEmpty: i, invalidSurname: n, invalidPatronymic: a, invalidName: o } = t || {};
|
|
520
|
+
return d.string().superRefine((r, u) => {
|
|
521
|
+
const { name: s, surname: c, patronymic: _ } = Kt(r);
|
|
522
|
+
E.ONLY_CYRILLIC.test(r) || u.addIssue({
|
|
523
|
+
code: d.ZodIssueCode.invalid_string,
|
|
524
|
+
validation: "regex",
|
|
525
|
+
message: m.ONLY_CYRILLIC()
|
|
526
|
+
}), (!s || !c) && u.addIssue({
|
|
527
|
+
code: d.ZodIssueCode.invalid_string,
|
|
528
|
+
validation: "regex",
|
|
529
|
+
message: i || m.NAME_OR_SURNAME_NON_EMPTY()
|
|
530
|
+
}), E.CHECK_HYPHEN.test(s) || u.addIssue({
|
|
531
|
+
code: d.ZodIssueCode.invalid_string,
|
|
532
|
+
validation: "regex",
|
|
533
|
+
message: o || m.INVALID_NAME()
|
|
534
|
+
}), E.CHECK_HYPHEN.test(c) || u.addIssue({
|
|
535
|
+
code: d.ZodIssueCode.invalid_string,
|
|
536
|
+
validation: "regex",
|
|
537
|
+
message: n || m.INVALID_SURNAME()
|
|
538
|
+
}), _ && (E.PATRONYMIC.test(_) || u.addIssue({
|
|
539
|
+
code: d.ZodIssueCode.invalid_string,
|
|
540
|
+
validation: "regex",
|
|
541
|
+
message: a || m.INVALID_PATRONYMIC()
|
|
542
|
+
}));
|
|
543
|
+
}).transform((r) => r.trimEnd()).default("");
|
|
544
|
+
}, Wt = (e) => C(e).optional().transform((t) => t != null && t.length ? t : void 0);
|
|
545
|
+
function Jt(e) {
|
|
546
|
+
const { required: t = !0, ...i } = e || {};
|
|
547
|
+
return t ? C(i) : Wt(i);
|
|
548
|
+
}
|
|
549
|
+
const Qt = {
|
|
550
|
+
getFioSchema: Jt
|
|
551
|
+
}, an = {
|
|
552
|
+
base: kt,
|
|
553
|
+
dadata: Qt
|
|
554
|
+
};
|
|
555
|
+
export {
|
|
556
|
+
nn as Z,
|
|
557
|
+
kt as a,
|
|
558
|
+
l as b,
|
|
559
|
+
an as z
|
|
560
|
+
};
|
|
561
|
+
//# sourceMappingURL=index-BcOxdcOI.js.map
|