@yourgoods/ui-smart 0.53.36 → 0.53.37
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/{ProfileEmailDialog-BeE9t0G7.js → ProfileEmailDialog-aS-CW0cn.js} +2 -2
- package/dist/{ProfilePasswordDialog-DCrkegUa.js → ProfilePasswordDialog-Hew1T5DH.js} +1 -1
- package/dist/{ProfilePhoneDialog-CzsvzQvb.js → ProfilePhoneDialog-BysaY3fk.js} +2 -2
- package/dist/components/PEditUserContact/PEditUserContact.vue.d.ts +2 -1
- package/dist/components/PEditUserContact/ProfileDialogs/DialogManager.vue.d.ts +2 -1
- package/dist/components/PEditUserContact/ProfileDialogs/ProfilePhoneDialog.vue.d.ts +2 -1
- package/dist/components/PEditUserContact/index.vue.d.ts +2 -1
- package/dist/components/PEditUserContact/types.d.ts +0 -1
- package/dist/components/PEmailOrPhoneInput/index.vue.d.ts +14 -10
- package/dist/components/types.d.ts +1 -0
- package/dist/{index-DauIZ6x9.js → index-Dz48Vppw.js} +433 -402
- package/dist/index.js +2 -2
- package/dist/locales/index.d.ts +6 -0
- package/dist/{useRateLimitToast-ek5NysYs.js → useRateLimitToast-BjQhqrta.js} +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import
|
|
3
|
-
import { PInputFileUploader as
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
1
|
+
import { ref as b, shallowRef as Je, defineComponent as H, defineAsyncComponent as Q, watch as Pe, createBlock as z, createCommentVNode as U, unref as p, openBlock as N, resolveDynamicComponent as We, mergeProps as Ye, computed as V, reactive as ee, onMounted as Xe, createElementBlock as F, Fragment as Ne, createVNode as P, createElementVNode as ae, withCtx as O, toDisplayString as G, createTextVNode as te, Teleport as ge, Transition as Ke, withDirectives as Ze, vShow as He } from "vue";
|
|
2
|
+
import Qe from "axios";
|
|
3
|
+
import { PInputFileUploader as ea, PInput as j, IconFilledEditMd as K, PButton as ve, PImageCropper as aa, PToast as ta, PTeleportContainer as Ce, PToastContainer as na, IconPhoneMd as oa, IconMailMd as ra } from "@profeat/ui-kit";
|
|
4
|
+
function la(r, s = 2) {
|
|
5
|
+
if (r === 0)
|
|
6
6
|
return "0 B";
|
|
7
|
-
const
|
|
8
|
-
return `${Number.parseFloat((
|
|
7
|
+
const t = 1024, n = ["B", "KB", "MB", "GB", "TB", "PB", "EB"], f = Math.floor(Math.log(r) / Math.log(t));
|
|
8
|
+
return `${Number.parseFloat((r / t ** f).toFixed(s))} ${n[f]}`;
|
|
9
9
|
}
|
|
10
|
-
const
|
|
10
|
+
const sa = {
|
|
11
11
|
"image/jpeg": "JPEG",
|
|
12
12
|
"image/png": "PNG",
|
|
13
13
|
"application/pdf": "PDF",
|
|
@@ -15,10 +15,10 @@ const ra = {
|
|
|
15
15
|
"application/zip": "ZIP Archive"
|
|
16
16
|
// ...
|
|
17
17
|
};
|
|
18
|
-
function
|
|
19
|
-
return
|
|
20
|
-
var
|
|
21
|
-
return
|
|
18
|
+
function ia(r) {
|
|
19
|
+
return r.map((s) => {
|
|
20
|
+
var t;
|
|
21
|
+
return sa[s] || ((t = s.split("/")[1]) == null ? void 0 : t.toUpperCase());
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
const $a = {
|
|
@@ -28,54 +28,54 @@ const $a = {
|
|
|
28
28
|
}, za = {
|
|
29
29
|
VERIFY_EMAIL: "verify-email"
|
|
30
30
|
};
|
|
31
|
-
let
|
|
32
|
-
function
|
|
33
|
-
|
|
31
|
+
let oe = null;
|
|
32
|
+
function ua(r, s, t) {
|
|
33
|
+
oe = Qe.create({
|
|
34
34
|
baseURL: s,
|
|
35
35
|
headers: {
|
|
36
|
-
Authorization: `Bearer ${
|
|
37
|
-
"x-throttler-prefix":
|
|
36
|
+
Authorization: `Bearer ${r}`,
|
|
37
|
+
"x-throttler-prefix": t ?? "throttler_profile_edit"
|
|
38
38
|
// здесь можно словить баг, который может быть сложно отследить, если будет передаваться пустой прелфикс
|
|
39
39
|
// 'Content-Type': 'application/json',
|
|
40
40
|
},
|
|
41
41
|
validateStatus: (n) => n >= 200 && n < 300
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
if (!
|
|
44
|
+
function se() {
|
|
45
|
+
if (!oe)
|
|
46
46
|
throw new Error("Axios instance not initialized. Call initAxios(token, baseUrl) first.");
|
|
47
|
-
return
|
|
47
|
+
return oe;
|
|
48
48
|
}
|
|
49
|
-
async function
|
|
50
|
-
return
|
|
49
|
+
async function re(r, s, t) {
|
|
50
|
+
return se().post(r, s, t);
|
|
51
51
|
}
|
|
52
|
-
async function
|
|
53
|
-
return
|
|
52
|
+
async function da(r, s) {
|
|
53
|
+
return se().get(r, s);
|
|
54
54
|
}
|
|
55
|
-
async function
|
|
56
|
-
return
|
|
55
|
+
async function ma(r, s) {
|
|
56
|
+
return se().delete(r, s);
|
|
57
57
|
}
|
|
58
|
-
async function
|
|
59
|
-
const s = await
|
|
58
|
+
async function ca(r) {
|
|
59
|
+
const s = await re("/users/profile/me", r);
|
|
60
60
|
if (s.status !== 200 && s.status !== 201 || !s.data)
|
|
61
61
|
throw new Error("Ошибка при получении профиля пользователя");
|
|
62
62
|
return s.data;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
65
|
-
function
|
|
64
|
+
const Z = b(null), ne = Je(null);
|
|
65
|
+
function ie() {
|
|
66
66
|
return {
|
|
67
|
-
currentDialog:
|
|
68
|
-
dialogPayload:
|
|
69
|
-
openDialog: (n,
|
|
70
|
-
|
|
67
|
+
currentDialog: Z,
|
|
68
|
+
dialogPayload: ne,
|
|
69
|
+
openDialog: (n, f) => {
|
|
70
|
+
Z.value = n, ne.value = f ?? null;
|
|
71
71
|
},
|
|
72
72
|
closeDialog: () => {
|
|
73
|
-
|
|
73
|
+
Z.value = null, ne.value = null;
|
|
74
74
|
},
|
|
75
|
-
isDialogOpen: (n) =>
|
|
75
|
+
isDialogOpen: (n) => Z.value === n
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
const
|
|
78
|
+
const le = {
|
|
79
79
|
ru: {
|
|
80
80
|
Имя: "Имя",
|
|
81
81
|
Фамилия: "Фамилия",
|
|
@@ -140,7 +140,11 @@ const ma = {
|
|
|
140
140
|
"Повторите пароль": "Повторите пароль",
|
|
141
141
|
"E-mail успешно привязан к аккаунту": "E-mail успешно привязан к аккаунту",
|
|
142
142
|
"Введите новый номер телефона": "Введите новый номер телефона",
|
|
143
|
-
"Телефон успешно изменен": "Телефон успешно изменен"
|
|
143
|
+
"Телефон успешно изменен": "Телефон успешно изменен",
|
|
144
|
+
// перевод для общего phone\email компонента
|
|
145
|
+
"Допустимы только цифры и знак + в начале": "Допустимы только цифры и знак + в начале",
|
|
146
|
+
"Это не похоже на email": "Это не похоже на email",
|
|
147
|
+
"Email или телефон": "Email или телефон"
|
|
144
148
|
},
|
|
145
149
|
en: {
|
|
146
150
|
Имя: "First Name",
|
|
@@ -206,9 +210,13 @@ const ma = {
|
|
|
206
210
|
"Повторите пароль": "Repeat password",
|
|
207
211
|
"E-mail успешно привязан к аккаунту": "The email has been successfully linked to the account",
|
|
208
212
|
"Введите новый номер телефона": "Enter a new phone number",
|
|
209
|
-
"Телефон успешно изменен": "Phone number successfully changed"
|
|
213
|
+
"Телефон успешно изменен": "Phone number successfully changed",
|
|
214
|
+
// перевод для общего phone\email компонента
|
|
215
|
+
"Допустимы только цифры и знак + в начале": "Only numbers and + sign are allowed at the beginning",
|
|
216
|
+
"Это не похоже на email": "It’s not like email",
|
|
217
|
+
"Email или телефон": "Email or phone"
|
|
210
218
|
}
|
|
211
|
-
},
|
|
219
|
+
}, pa = /* @__PURE__ */ H({
|
|
212
220
|
__name: "DialogManager",
|
|
213
221
|
props: {
|
|
214
222
|
language: {},
|
|
@@ -216,54 +224,54 @@ const ma = {
|
|
|
216
224
|
disableAddPhone: { type: Boolean }
|
|
217
225
|
},
|
|
218
226
|
emits: ["clean-input-errors", "on-update-jwt", "update-phone-field", "update-email-field", "on-password-error", "on-toast"],
|
|
219
|
-
setup(
|
|
220
|
-
const
|
|
221
|
-
email:
|
|
222
|
-
phone:
|
|
223
|
-
password:
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
},
|
|
227
|
-
|
|
227
|
+
setup(r, { emit: s }) {
|
|
228
|
+
const t = s, n = b(!0), { currentDialog: f, dialogPayload: g, closeDialog: x } = ie(), m = {
|
|
229
|
+
email: Q(() => import("./ProfileEmailDialog-aS-CW0cn.js")),
|
|
230
|
+
phone: Q(() => import("./ProfilePhoneDialog-BysaY3fk.js")),
|
|
231
|
+
password: Q(() => import("./ProfilePasswordDialog-Hew1T5DH.js"))
|
|
232
|
+
}, i = ({ email: E }) => {
|
|
233
|
+
t("update-email-field", E);
|
|
234
|
+
}, v = ({ phone: E }) => {
|
|
235
|
+
t("update-phone-field", E);
|
|
228
236
|
};
|
|
229
|
-
return
|
|
237
|
+
return Pe(f, (E) => {
|
|
230
238
|
n.value = !!E;
|
|
231
|
-
}), (E,
|
|
239
|
+
}), (E, u) => p(f) ? (N(), z(We(m[p(f)]), Ye({
|
|
232
240
|
key: 0,
|
|
233
241
|
modelValue: n.value,
|
|
234
|
-
"onUpdate:modelValue":
|
|
242
|
+
"onUpdate:modelValue": u[0] || (u[0] = (c) => n.value = c),
|
|
235
243
|
language: E.language,
|
|
236
244
|
provider: E.provider,
|
|
237
245
|
"disable-add-phone": E.disableAddPhone
|
|
238
|
-
},
|
|
239
|
-
onClose:
|
|
240
|
-
onCleanInputErrors:
|
|
241
|
-
onOnUpdateJwt:
|
|
242
|
-
onSubmitEmail:
|
|
243
|
-
onSubmitPhone:
|
|
244
|
-
onOnPasswordError:
|
|
245
|
-
onOnToast:
|
|
246
|
-
}), null, 16, ["modelValue", "language", "provider", "disable-add-phone", "onClose"])) :
|
|
246
|
+
}, p(g), {
|
|
247
|
+
onClose: p(x),
|
|
248
|
+
onCleanInputErrors: u[1] || (u[1] = (c) => t("clean-input-errors")),
|
|
249
|
+
onOnUpdateJwt: u[2] || (u[2] = (c, w, l) => t("on-update-jwt", c, w, l)),
|
|
250
|
+
onSubmitEmail: i,
|
|
251
|
+
onSubmitPhone: v,
|
|
252
|
+
onOnPasswordError: u[3] || (u[3] = (c, w) => t("on-password-error", c, w)),
|
|
253
|
+
onOnToast: u[4] || (u[4] = (c) => t("on-toast", c))
|
|
254
|
+
}), null, 16, ["modelValue", "language", "provider", "disable-add-phone", "onClose"])) : U("", !0);
|
|
247
255
|
}
|
|
248
|
-
}),
|
|
256
|
+
}), fa = { class: "base-container" }, ga = {
|
|
249
257
|
key: 0,
|
|
250
258
|
style: { color: "#E46060" }
|
|
251
|
-
},
|
|
259
|
+
}, va = { key: 1 }, ha = {
|
|
252
260
|
key: 1,
|
|
253
261
|
class: "input-wrapper"
|
|
254
|
-
},
|
|
262
|
+
}, ya = {
|
|
255
263
|
key: 2,
|
|
256
264
|
class: "input-wrapper"
|
|
257
|
-
},
|
|
265
|
+
}, wa = {
|
|
258
266
|
key: 3,
|
|
259
267
|
class: "input-wrapper"
|
|
260
|
-
},
|
|
268
|
+
}, ba = {
|
|
261
269
|
key: 4,
|
|
262
270
|
class: "input-wrapper"
|
|
263
|
-
},
|
|
271
|
+
}, Ea = { class: "buttons-container" }, Pa = {
|
|
264
272
|
key: 0,
|
|
265
273
|
class: "centered-overlay"
|
|
266
|
-
},
|
|
274
|
+
}, Na = { class: "toastWrapper" }, Ca = /* @__PURE__ */ H({
|
|
267
275
|
__name: "PEditUserContact",
|
|
268
276
|
props: {
|
|
269
277
|
language: {},
|
|
@@ -277,8 +285,8 @@ const ma = {
|
|
|
277
285
|
disableAddPhone: { type: Boolean }
|
|
278
286
|
},
|
|
279
287
|
emits: ["open-email-dialog", "open-phone-dialog", "open-password-dialog", "on-update-jwt", "on-password-error", "update-tokens"],
|
|
280
|
-
setup(
|
|
281
|
-
const
|
|
288
|
+
setup(r, { emit: s }) {
|
|
289
|
+
const t = r, n = s, f = V(() => t.language ?? "ru"), g = (e) => le[f.value][e] || e, { openDialog: x } = ie(), m = ee({ firstName: "", lastName: "" }), i = b({ firstName: "", lastName: "" }), v = ee({ firstName: !1, lastName: !1, email: !1, phone: !1 }), E = b(""), u = b(""), c = b(""), w = b(!1), l = ee({
|
|
282
290
|
value: null,
|
|
283
291
|
loading: !1,
|
|
284
292
|
accept: ["image/png", "image/jpeg"],
|
|
@@ -286,334 +294,334 @@ const ma = {
|
|
|
286
294
|
// 10 MB
|
|
287
295
|
imageBinary: null,
|
|
288
296
|
imageContent: ""
|
|
289
|
-
}),
|
|
297
|
+
}), $ = b(""), L = b(!1), R = b(!0), d = b(!0), h = b(void 0), y = b(""), B = V(() => ue(m.firstName, v.firstName)), C = V(() => ue(m.lastName, v.lastName)), k = V(() => v.email && !u.value.trim() ? "Введите e-mail" : ""), M = V(() => v.phone && !c.value.trim() ? "Введите номер телефона" : ""), A = (e) => t.fields.some((a) => a.key === e), S = (e) => e && e.trim() ? "edit" : "bind", _ = () => setTimeout(() => {
|
|
290
298
|
var e;
|
|
291
299
|
return (e = document.activeElement) == null ? void 0 : e.blur();
|
|
292
|
-
}, 0),
|
|
300
|
+
}, 0), q = V(() => !!(u.value && u.value.trim() !== "")), Te = V(() => l.imageContent ? g("Загрузить другое фото") : g("Загрузить фото")), ue = (e, a) => {
|
|
293
301
|
if (!a) return "";
|
|
294
|
-
const
|
|
295
|
-
return
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
},
|
|
299
|
-
|
|
300
|
-
},
|
|
301
|
-
e === "email" &&
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
},
|
|
305
|
-
|
|
306
|
-
},
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
},
|
|
313
|
-
if (
|
|
314
|
-
const a =
|
|
315
|
-
a.length > 40 && (
|
|
302
|
+
const o = e.trim();
|
|
303
|
+
return o ? o.length < 2 ? "Поле должно содержать минимум 2 символа" : "" : "Введите значение";
|
|
304
|
+
}, Be = (e) => x("email", { mode: e ? "edit" : "bind", initialEmail: e }), De = () => {
|
|
305
|
+
_(), v.email = !1, d.value = !1, n("open-email-dialog", u.value, S(u.value)), Be(u.value);
|
|
306
|
+
}, Ie = () => {
|
|
307
|
+
_(), v.phone = !1, R.value = !1, n("open-phone-dialog", c.value, S(c.value));
|
|
308
|
+
}, Ue = async (e, a, o) => {
|
|
309
|
+
e === "email" && o && (u.value = o), e === "phone" && o && (c.value = o), n("on-update-jwt");
|
|
310
|
+
}, Ve = (e) => {
|
|
311
|
+
c.value = e;
|
|
312
|
+
}, Ae = (e) => {
|
|
313
|
+
u.value = e;
|
|
314
|
+
}, Fe = (e, a) => {
|
|
315
|
+
L.value = !0, n("on-password-error", e, a);
|
|
316
|
+
}, Se = () => {
|
|
317
|
+
R.value = !1, d.value = !1;
|
|
318
|
+
}, J = (e) => {
|
|
319
|
+
L.value = !0, h.value = e.color ?? "", y.value = e.text ?? "";
|
|
320
|
+
}, W = (e) => {
|
|
321
|
+
if (v[e] = !0, e === "firstName" || e === "lastName") {
|
|
322
|
+
const a = m[e];
|
|
323
|
+
a.length > 40 && (m[e] = a.slice(0, 40));
|
|
316
324
|
}
|
|
317
|
-
},
|
|
318
|
-
var
|
|
319
|
-
if (
|
|
320
|
-
|
|
325
|
+
}, Me = (e) => {
|
|
326
|
+
var Y, X;
|
|
327
|
+
if ($.value = "", !e) {
|
|
328
|
+
de();
|
|
321
329
|
return;
|
|
322
330
|
}
|
|
323
|
-
const a = ((
|
|
324
|
-
if (
|
|
325
|
-
|
|
331
|
+
const a = ((Y = e.fileBinary) == null ? void 0 : Y.type) ?? "", o = ((X = e.fileBinary) == null ? void 0 : X.size) ?? 0, I = !["image/png", "image/jpeg"].includes(a), D = o > l.uploadLimit;
|
|
332
|
+
if (I || D) {
|
|
333
|
+
$.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", de();
|
|
326
334
|
return;
|
|
327
335
|
}
|
|
328
|
-
|
|
329
|
-
},
|
|
330
|
-
|
|
331
|
-
},
|
|
336
|
+
l.value = e, l.imageBinary = e.fileBinary ?? null, l.imageContent = e.fileContent ?? "", w.value = !0;
|
|
337
|
+
}, de = () => {
|
|
338
|
+
l.value = null, l.imageBinary = null, l.imageContent = "", w.value = !1;
|
|
339
|
+
}, xe = async () => {
|
|
332
340
|
try {
|
|
333
|
-
const a = (await
|
|
341
|
+
const a = (await ma("/users/profile/delete/avatar")).data;
|
|
334
342
|
return (a == null ? void 0 : a.success) === !0;
|
|
335
343
|
} catch (e) {
|
|
336
344
|
return console.error("Ошибка при удалении аватара:", e), !1;
|
|
337
345
|
}
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
},
|
|
346
|
+
}, $e = () => {
|
|
347
|
+
$.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", l.value = null, l.imageBinary = null, l.imageContent = "", w.value = !1;
|
|
348
|
+
}, me = async (e, a, o = "image/png") => {
|
|
341
349
|
if (!e) return null;
|
|
342
|
-
const
|
|
343
|
-
return new File([
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
const a =
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
350
|
+
const I = await (await fetch(e)).blob();
|
|
351
|
+
return new File([I], a, { type: o });
|
|
352
|
+
}, ze = () => {
|
|
353
|
+
l.value = null, l.imageBinary = null, l.imageContent = "", w.value = !1;
|
|
354
|
+
}, Le = async (e) => {
|
|
355
|
+
w.value = !1;
|
|
356
|
+
const a = l.imageContent;
|
|
357
|
+
if (l.imageContent = e, !l.imageBinary) return;
|
|
358
|
+
const o = await me(
|
|
351
359
|
e,
|
|
352
|
-
|
|
353
|
-
|
|
360
|
+
l.imageBinary.name,
|
|
361
|
+
l.imageBinary.type || "image/png"
|
|
354
362
|
);
|
|
355
|
-
if (!
|
|
356
|
-
|
|
363
|
+
if (!o) {
|
|
364
|
+
l.imageContent = a;
|
|
357
365
|
return;
|
|
358
366
|
}
|
|
359
367
|
try {
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
} catch (
|
|
364
|
-
console.error(
|
|
368
|
+
l.loading = !0;
|
|
369
|
+
const T = new FormData();
|
|
370
|
+
T.append("file", o), await re(`/users/profile/avatar/${E.value}`, T, { headers: { "Content-Type": void 0 } });
|
|
371
|
+
} catch (T) {
|
|
372
|
+
console.error(T), J({
|
|
365
373
|
color: "error",
|
|
366
374
|
text: g("Не удалось сохранить изменения. Попробуйте позже")
|
|
367
|
-
}),
|
|
375
|
+
}), l.imageContent = a;
|
|
368
376
|
} finally {
|
|
369
|
-
|
|
377
|
+
l.loading = !1;
|
|
370
378
|
}
|
|
371
|
-
},
|
|
372
|
-
|
|
379
|
+
}, _e = async (e) => {
|
|
380
|
+
l.imageContent = e ?? "", l.imageBinary && (l.imageBinary = await me(
|
|
373
381
|
e ?? "",
|
|
374
|
-
|
|
375
|
-
|
|
382
|
+
l.imageBinary.name,
|
|
383
|
+
l.imageBinary.type || "image/png"
|
|
376
384
|
));
|
|
377
|
-
},
|
|
378
|
-
var
|
|
379
|
-
const a = (
|
|
385
|
+
}, ce = b(!1), pe = async (e) => {
|
|
386
|
+
var o, T;
|
|
387
|
+
const a = (o = m[e]) == null ? void 0 : o.trim();
|
|
380
388
|
if (a)
|
|
381
389
|
try {
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
firstName:
|
|
386
|
-
lastName:
|
|
390
|
+
ce.value = !0;
|
|
391
|
+
const D = (T = (await re("/users/profile/update-name", { [e]: a })).data) == null ? void 0 : T.data;
|
|
392
|
+
D != null && D.user && (m.firstName = D.user.firstName ?? m.firstName, m.lastName = D.user.lastName ?? m.lastName, i.value = {
|
|
393
|
+
firstName: m.firstName,
|
|
394
|
+
lastName: m.lastName
|
|
387
395
|
});
|
|
388
|
-
} catch (
|
|
389
|
-
throw
|
|
396
|
+
} catch (I) {
|
|
397
|
+
throw I;
|
|
390
398
|
} finally {
|
|
391
|
-
|
|
399
|
+
ce.value = !1;
|
|
392
400
|
}
|
|
393
|
-
},
|
|
401
|
+
}, Re = async () => {
|
|
394
402
|
var e;
|
|
395
|
-
if (!
|
|
403
|
+
if (!t.accessToken)
|
|
396
404
|
throw console.error("Access token не передан в props"), new Error("Access token is required");
|
|
397
405
|
try {
|
|
398
|
-
const
|
|
399
|
-
accessToken:
|
|
400
|
-
refreshToken:
|
|
406
|
+
const o = (e = (await ca({
|
|
407
|
+
accessToken: t.accessToken,
|
|
408
|
+
refreshToken: t.refreshToken ?? "",
|
|
401
409
|
excludeFields: []
|
|
402
410
|
})).data) == null ? void 0 : e.user;
|
|
403
|
-
if (!
|
|
411
|
+
if (!o)
|
|
404
412
|
throw console.error("Данные пользователя отсутствуют в ответе сервера"), new Error("User data is missing from the response");
|
|
405
413
|
const {
|
|
406
|
-
userId:
|
|
407
|
-
privateFirstName:
|
|
408
|
-
privateLastName:
|
|
409
|
-
email:
|
|
410
|
-
phoneNumber:
|
|
411
|
-
} =
|
|
412
|
-
E.value =
|
|
413
|
-
firstName:
|
|
414
|
-
lastName:
|
|
414
|
+
userId: T,
|
|
415
|
+
privateFirstName: I,
|
|
416
|
+
privateLastName: D,
|
|
417
|
+
email: Y,
|
|
418
|
+
phoneNumber: X
|
|
419
|
+
} = o;
|
|
420
|
+
E.value = T ?? "", m.firstName = I ?? "", m.lastName = D ?? "", u.value = Y ?? "", c.value = X ?? "", l.imageContent = await Oe(), i.value = {
|
|
421
|
+
firstName: I ?? "",
|
|
422
|
+
lastName: D ?? ""
|
|
415
423
|
};
|
|
416
424
|
} catch (a) {
|
|
417
425
|
console.error("Критическая ошибка при загрузке профиля:", a);
|
|
418
426
|
}
|
|
419
|
-
},
|
|
427
|
+
}, Oe = async () => {
|
|
420
428
|
var e;
|
|
421
429
|
try {
|
|
422
|
-
const
|
|
423
|
-
return
|
|
430
|
+
const o = (e = (await da("/users/profile/avatar")).data) == null ? void 0 : e.data;
|
|
431
|
+
return o ? Ge(o) : "";
|
|
424
432
|
} catch (a) {
|
|
425
433
|
return console.error("Ошибка при загрузке метаданных аватара:", a), "";
|
|
426
434
|
}
|
|
427
435
|
};
|
|
428
|
-
function
|
|
436
|
+
function Ge(e) {
|
|
429
437
|
if (!e)
|
|
430
438
|
return "";
|
|
431
439
|
try {
|
|
432
|
-
return new URL(e.key,
|
|
440
|
+
return new URL(e.key, t.awsStorageUrl).toString();
|
|
433
441
|
} catch (a) {
|
|
434
442
|
return console.error("Ошибка при составлении URL аватара:", a), "";
|
|
435
443
|
}
|
|
436
444
|
}
|
|
437
|
-
const
|
|
438
|
-
if (!
|
|
445
|
+
const fe = V(() => {
|
|
446
|
+
if (!i.value.firstName && !i.value.lastName)
|
|
439
447
|
return !1;
|
|
440
|
-
const e =
|
|
441
|
-
return
|
|
442
|
-
}),
|
|
443
|
-
if (
|
|
448
|
+
const e = m.firstName.trim(), a = m.lastName.trim(), o = i.value.firstName.trim(), T = i.value.lastName.trim(), I = e !== o || a !== T, D = e.length >= 2 && a.length >= 2;
|
|
449
|
+
return I && D;
|
|
450
|
+
}), je = async () => {
|
|
451
|
+
if (fe.value)
|
|
444
452
|
try {
|
|
445
|
-
await Promise.all([
|
|
453
|
+
await Promise.all([pe("firstName"), pe("lastName")]), n("on-update-jwt"), J({ color: "success", text: "Изменения сохранены" });
|
|
446
454
|
} catch (e) {
|
|
447
|
-
console.error(e),
|
|
455
|
+
console.error(e), J({
|
|
448
456
|
color: "error",
|
|
449
457
|
text: g("Не удалось сохранить изменения. Попробуйте позже")
|
|
450
458
|
});
|
|
451
459
|
}
|
|
452
|
-
},
|
|
453
|
-
|
|
460
|
+
}, qe = () => {
|
|
461
|
+
_(), n("open-password-dialog");
|
|
454
462
|
};
|
|
455
|
-
return
|
|
456
|
-
if (!
|
|
457
|
-
if (!
|
|
458
|
-
|
|
459
|
-
}), (e, a) => (
|
|
460
|
-
|
|
461
|
-
language:
|
|
463
|
+
return Xe(async () => {
|
|
464
|
+
if (!t.accessToken) throw new Error("Access token не передан в props");
|
|
465
|
+
if (!t.requestUrl) throw new Error("auth-backend url не передан в props");
|
|
466
|
+
ua(t.accessToken, t.requestUrl, t.throttlerPrefix), await Re();
|
|
467
|
+
}), (e, a) => (N(), F(Ne, null, [
|
|
468
|
+
P(pa, {
|
|
469
|
+
language: f.value,
|
|
462
470
|
provider: e.provider,
|
|
463
471
|
"disable-add-phone": e.disableAddPhone,
|
|
464
|
-
onCleanInputErrors:
|
|
465
|
-
onOnUpdateJwt:
|
|
466
|
-
onUpdatePhoneField:
|
|
467
|
-
onUpdateEmailField:
|
|
468
|
-
onOnPasswordError:
|
|
469
|
-
onOnToast:
|
|
472
|
+
onCleanInputErrors: Se,
|
|
473
|
+
onOnUpdateJwt: Ue,
|
|
474
|
+
onUpdatePhoneField: Ve,
|
|
475
|
+
onUpdateEmailField: Ae,
|
|
476
|
+
onOnPasswordError: Fe,
|
|
477
|
+
onOnToast: J
|
|
470
478
|
}, null, 8, ["language", "provider", "disable-add-phone"]),
|
|
471
|
-
|
|
472
|
-
|
|
479
|
+
ae("div", fa, [
|
|
480
|
+
A("avatar") ? (N(), z(p(ea), {
|
|
473
481
|
key: 0,
|
|
474
|
-
modelValue:
|
|
482
|
+
modelValue: l.value,
|
|
475
483
|
"onUpdate:modelValue": [
|
|
476
|
-
a[0] || (a[0] = (
|
|
477
|
-
a[1] || (a[1] = (
|
|
484
|
+
a[0] || (a[0] = (o) => l.value = o),
|
|
485
|
+
a[1] || (a[1] = (o) => Me(o))
|
|
478
486
|
],
|
|
479
487
|
type: "img",
|
|
480
488
|
class: "avatar-input",
|
|
481
|
-
src:
|
|
482
|
-
loading:
|
|
489
|
+
src: l.imageContent,
|
|
490
|
+
loading: l.loading,
|
|
483
491
|
label: g("Загрузить фото"),
|
|
484
|
-
"upload-limit":
|
|
492
|
+
"upload-limit": l.uploadLimit,
|
|
485
493
|
accept: "image/jpeg, image/png",
|
|
486
|
-
onDelete:
|
|
487
|
-
"onChange:error":
|
|
494
|
+
onDelete: xe,
|
|
495
|
+
"onChange:error": $e
|
|
488
496
|
}, {
|
|
489
|
-
afterLoadLabel:
|
|
490
|
-
|
|
497
|
+
afterLoadLabel: O(() => [
|
|
498
|
+
te(G(Te.value), 1)
|
|
491
499
|
]),
|
|
492
|
-
subtext:
|
|
493
|
-
|
|
500
|
+
subtext: O(() => [
|
|
501
|
+
$.value ? (N(), F("span", ga, G($.value), 1)) : (N(), F("span", va, G(`${g("Формат")} ${p(ia)(l.accept).join(", ")} ${g("до")} ${p(la)(l.uploadLimit)}`), 1))
|
|
494
502
|
]),
|
|
495
503
|
_: 1
|
|
496
|
-
}, 8, ["modelValue", "src", "loading", "label", "upload-limit"])) :
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
modelValue:
|
|
500
|
-
"onUpdate:modelValue": a[2] || (a[2] = (
|
|
504
|
+
}, 8, ["modelValue", "src", "loading", "label", "upload-limit"])) : U("", !0),
|
|
505
|
+
A("firstName") ? (N(), F("div", ha, [
|
|
506
|
+
P(p(j), {
|
|
507
|
+
modelValue: m.firstName,
|
|
508
|
+
"onUpdate:modelValue": a[2] || (a[2] = (o) => m.firstName = o),
|
|
501
509
|
size: "large",
|
|
502
510
|
label: g("Имя"),
|
|
503
|
-
error:
|
|
504
|
-
onBlur: a[3] || (a[3] = (
|
|
505
|
-
onInput: a[4] || (a[4] = (
|
|
511
|
+
error: B.value,
|
|
512
|
+
onBlur: a[3] || (a[3] = (o) => v.firstName = !0),
|
|
513
|
+
onInput: a[4] || (a[4] = (o) => W("firstName"))
|
|
506
514
|
}, null, 8, ["modelValue", "label", "error"]),
|
|
507
|
-
|
|
508
|
-
])) :
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
modelValue:
|
|
512
|
-
"onUpdate:modelValue": a[5] || (a[5] = (
|
|
515
|
+
P(p(K), { class: "icon-locked" })
|
|
516
|
+
])) : U("", !0),
|
|
517
|
+
A("lastName") ? (N(), F("div", ya, [
|
|
518
|
+
P(p(j), {
|
|
519
|
+
modelValue: m.lastName,
|
|
520
|
+
"onUpdate:modelValue": a[5] || (a[5] = (o) => m.lastName = o),
|
|
513
521
|
size: "large",
|
|
514
522
|
label: g("Фамилия"),
|
|
515
|
-
error:
|
|
516
|
-
onBlur: a[6] || (a[6] = (
|
|
517
|
-
onInput: a[7] || (a[7] = (
|
|
523
|
+
error: C.value,
|
|
524
|
+
onBlur: a[6] || (a[6] = (o) => v.lastName = !0),
|
|
525
|
+
onInput: a[7] || (a[7] = (o) => W("lastName"))
|
|
518
526
|
}, null, 8, ["modelValue", "label", "error"]),
|
|
519
|
-
|
|
520
|
-
])) :
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
modelValue:
|
|
524
|
-
"onUpdate:modelValue": a[8] || (a[8] = (
|
|
527
|
+
P(p(K), { class: "icon-locked" })
|
|
528
|
+
])) : U("", !0),
|
|
529
|
+
A("email") ? (N(), F("div", wa, [
|
|
530
|
+
P(p(j), {
|
|
531
|
+
modelValue: u.value,
|
|
532
|
+
"onUpdate:modelValue": a[8] || (a[8] = (o) => u.value = o),
|
|
525
533
|
size: "large",
|
|
526
534
|
"text-size": "medium",
|
|
527
535
|
label: "E-mail",
|
|
528
536
|
type: "email",
|
|
529
537
|
readonly: "",
|
|
530
538
|
style: { cursor: "pointer" },
|
|
531
|
-
error:
|
|
532
|
-
onBlur: a[9] || (a[9] = (
|
|
533
|
-
onInput: a[10] || (a[10] = (
|
|
534
|
-
onClick:
|
|
539
|
+
error: k.value && d.value,
|
|
540
|
+
onBlur: a[9] || (a[9] = (o) => v.email = !0),
|
|
541
|
+
onInput: a[10] || (a[10] = (o) => W("email")),
|
|
542
|
+
onClick: De
|
|
535
543
|
}, null, 8, ["modelValue", "error"]),
|
|
536
|
-
|
|
537
|
-
])) :
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
modelValue:
|
|
541
|
-
"onUpdate:modelValue": a[11] || (a[11] = (
|
|
544
|
+
P(p(K), { class: "icon-locked" })
|
|
545
|
+
])) : U("", !0),
|
|
546
|
+
A("phone") ? (N(), F("div", ba, [
|
|
547
|
+
P(p(j), {
|
|
548
|
+
modelValue: c.value,
|
|
549
|
+
"onUpdate:modelValue": a[11] || (a[11] = (o) => c.value = o),
|
|
542
550
|
size: "large",
|
|
543
551
|
"text-size": "medium",
|
|
544
552
|
label: g("Номер телефона"),
|
|
545
553
|
type: "tel",
|
|
546
554
|
readonly: "",
|
|
547
555
|
style: { cursor: "pointer" },
|
|
548
|
-
error:
|
|
549
|
-
onBlur: a[12] || (a[12] = (
|
|
550
|
-
onInput: a[13] || (a[13] = (
|
|
551
|
-
onClick:
|
|
556
|
+
error: M.value && R.value,
|
|
557
|
+
onBlur: a[12] || (a[12] = (o) => v.phone = !0),
|
|
558
|
+
onInput: a[13] || (a[13] = (o) => W("phone")),
|
|
559
|
+
onClick: Ie
|
|
552
560
|
}, null, 8, ["modelValue", "label", "error"]),
|
|
553
|
-
|
|
554
|
-
])) :
|
|
555
|
-
|
|
556
|
-
|
|
561
|
+
P(p(K), { class: "icon-locked" })
|
|
562
|
+
])) : U("", !0),
|
|
563
|
+
ae("div", Ea, [
|
|
564
|
+
q.value ? (N(), z(p(ve), {
|
|
557
565
|
key: 0,
|
|
558
566
|
color: "secondary",
|
|
559
|
-
onClick:
|
|
567
|
+
onClick: qe
|
|
560
568
|
}, {
|
|
561
|
-
default:
|
|
562
|
-
|
|
569
|
+
default: O(() => [
|
|
570
|
+
te(G(g("Сменить пароль")), 1)
|
|
563
571
|
]),
|
|
564
572
|
_: 1
|
|
565
|
-
})) :
|
|
566
|
-
|
|
567
|
-
disabled: !
|
|
568
|
-
onClick:
|
|
573
|
+
})) : U("", !0),
|
|
574
|
+
P(p(ve), {
|
|
575
|
+
disabled: !fe.value,
|
|
576
|
+
onClick: je
|
|
569
577
|
}, {
|
|
570
|
-
default:
|
|
571
|
-
|
|
578
|
+
default: O(() => [
|
|
579
|
+
te(G(g("Сохранить")), 1)
|
|
572
580
|
]),
|
|
573
581
|
_: 1
|
|
574
582
|
}, 8, ["disabled"])
|
|
575
583
|
])
|
|
576
584
|
]),
|
|
577
|
-
|
|
585
|
+
w.value ? (N(), z(ge, {
|
|
578
586
|
key: 0,
|
|
579
587
|
to: "body"
|
|
580
588
|
}, [
|
|
581
|
-
|
|
582
|
-
|
|
589
|
+
w.value ? (N(), F("div", Pa, [
|
|
590
|
+
P(p(aa), {
|
|
583
591
|
"circle-mode": !0,
|
|
584
|
-
"model-value":
|
|
585
|
-
onClose:
|
|
586
|
-
onSave: a[14] || (a[14] = (
|
|
587
|
-
"onUpdate:modelValue": a[15] || (a[15] = (
|
|
592
|
+
"model-value": l.imageContent,
|
|
593
|
+
onClose: ze,
|
|
594
|
+
onSave: a[14] || (a[14] = (o) => Le(o)),
|
|
595
|
+
"onUpdate:modelValue": a[15] || (a[15] = (o) => _e(o))
|
|
588
596
|
}, null, 8, ["model-value"])
|
|
589
|
-
])) :
|
|
590
|
-
])) :
|
|
591
|
-
(
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
default:
|
|
595
|
-
|
|
597
|
+
])) : U("", !0)
|
|
598
|
+
])) : U("", !0),
|
|
599
|
+
(N(), z(ge, { to: "#toast-root" }, [
|
|
600
|
+
ae("div", Na, [
|
|
601
|
+
P(Ke, { name: "list" }, {
|
|
602
|
+
default: O(() => [
|
|
603
|
+
Ze(P(p(ta), {
|
|
596
604
|
class: "toast",
|
|
597
|
-
color:
|
|
598
|
-
text:
|
|
599
|
-
onClose: a[16] || (a[16] = (
|
|
605
|
+
color: h.value,
|
|
606
|
+
text: y.value,
|
|
607
|
+
onClose: a[16] || (a[16] = (o) => L.value = !1)
|
|
600
608
|
}, null, 8, ["color", "text"]), [
|
|
601
|
-
[
|
|
609
|
+
[He, L.value]
|
|
602
610
|
])
|
|
603
611
|
]),
|
|
604
612
|
_: 1
|
|
605
613
|
})
|
|
606
614
|
])
|
|
607
615
|
])),
|
|
608
|
-
|
|
616
|
+
P(p(Ce))
|
|
609
617
|
], 64));
|
|
610
618
|
}
|
|
611
|
-
}),
|
|
612
|
-
const
|
|
613
|
-
for (const [n,
|
|
614
|
-
|
|
615
|
-
return
|
|
616
|
-
},
|
|
619
|
+
}), ke = (r, s) => {
|
|
620
|
+
const t = r.__vccOpts || r;
|
|
621
|
+
for (const [n, f] of s)
|
|
622
|
+
t[n] = f;
|
|
623
|
+
return t;
|
|
624
|
+
}, ka = /* @__PURE__ */ ke(Ca, [["__scopeId", "data-v-4e8a6f81"]]), La = /* @__PURE__ */ H({
|
|
617
625
|
__name: "index",
|
|
618
626
|
props: {
|
|
619
627
|
throttlerPrefix: {},
|
|
@@ -627,67 +635,67 @@ const ma = {
|
|
|
627
635
|
disableAddPhone: { type: Boolean }
|
|
628
636
|
},
|
|
629
637
|
emits: ["on-update-jwt", "update-tokens"],
|
|
630
|
-
setup(
|
|
631
|
-
const
|
|
632
|
-
n("email", { initialEmail:
|
|
633
|
-
}, g = (
|
|
634
|
-
n("phone", { initialPhone:
|
|
635
|
-
},
|
|
638
|
+
setup(r, { emit: s }) {
|
|
639
|
+
const t = s, { openDialog: n } = ie(), f = (i, v) => {
|
|
640
|
+
n("email", { initialEmail: i, mode: v });
|
|
641
|
+
}, g = (i, v) => {
|
|
642
|
+
n("phone", { initialPhone: i, mode: v });
|
|
643
|
+
}, x = () => {
|
|
636
644
|
n("password");
|
|
637
|
-
},
|
|
638
|
-
|
|
645
|
+
}, m = (i, v, E) => {
|
|
646
|
+
t("on-update-jwt", i, v, E);
|
|
639
647
|
};
|
|
640
|
-
return (
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
"throttler-prefix":
|
|
644
|
-
provider:
|
|
645
|
-
"request-url":
|
|
646
|
-
language:
|
|
647
|
-
fields:
|
|
648
|
-
"access-token":
|
|
649
|
-
"refresh-token":
|
|
650
|
-
"aws-storage-url":
|
|
651
|
-
"disable-add-phone":
|
|
652
|
-
onOpenEmailDialog:
|
|
648
|
+
return (i, v) => (N(), F(Ne, null, [
|
|
649
|
+
P(p(na)),
|
|
650
|
+
P(ka, {
|
|
651
|
+
"throttler-prefix": i.throttlerPrefix,
|
|
652
|
+
provider: i.provider,
|
|
653
|
+
"request-url": i.requestUrl,
|
|
654
|
+
language: i.language,
|
|
655
|
+
fields: i.fields,
|
|
656
|
+
"access-token": i.accessToken,
|
|
657
|
+
"refresh-token": i.refreshToken,
|
|
658
|
+
"aws-storage-url": i.awsStorageUrl,
|
|
659
|
+
"disable-add-phone": i.disableAddPhone,
|
|
660
|
+
onOpenEmailDialog: f,
|
|
653
661
|
onOpenPhoneDialog: g,
|
|
654
|
-
onOpenPasswordDialog:
|
|
655
|
-
onOnUpdateJwt:
|
|
662
|
+
onOpenPasswordDialog: x,
|
|
663
|
+
onOnUpdateJwt: m
|
|
656
664
|
}, null, 8, ["throttler-prefix", "provider", "request-url", "language", "fields", "access-token", "refresh-token", "aws-storage-url", "disable-add-phone"]),
|
|
657
|
-
|
|
665
|
+
P(p(Ce))
|
|
658
666
|
], 64));
|
|
659
667
|
}
|
|
660
|
-
}),
|
|
661
|
-
function
|
|
662
|
-
let n =
|
|
663
|
-
return
|
|
668
|
+
}), Ta = 10, Ba = 10, Da = 15;
|
|
669
|
+
function he(r, s, t) {
|
|
670
|
+
let n = r.replace(/[^\d+]/g, "").replace(/(?!^)\+/g, "");
|
|
671
|
+
return t != null && t.startsWith("ru") && n.startsWith("8") ? n = `+7${n.slice(1)}` : s && n && !n.startsWith("+") && (n = `+${n}`), n;
|
|
664
672
|
}
|
|
665
|
-
function
|
|
666
|
-
return
|
|
673
|
+
function ye(r) {
|
|
674
|
+
return r.startsWith("+") ? r.slice(1).replace(/\D/g, "") : r.replace(/\D/g, "");
|
|
667
675
|
}
|
|
668
|
-
function
|
|
669
|
-
if (!
|
|
676
|
+
function we(r, s = Ta, t = Da) {
|
|
677
|
+
if (!r.startsWith("+"))
|
|
670
678
|
return !1;
|
|
671
|
-
const n =
|
|
672
|
-
return !(!/^\d+$/.test(n) || n.length < s || n.length >
|
|
679
|
+
const n = r.slice(1);
|
|
680
|
+
return !(!/^\d+$/.test(n) || n.length < s || n.length > t);
|
|
673
681
|
}
|
|
674
|
-
function
|
|
675
|
-
return !/^\+?\d*$/.test(
|
|
682
|
+
function be(r) {
|
|
683
|
+
return !/^\+?\d*$/.test(r);
|
|
676
684
|
}
|
|
677
|
-
function Ia(
|
|
678
|
-
let
|
|
679
|
-
return
|
|
685
|
+
function Ia(r, s) {
|
|
686
|
+
let t = 0, n = !1;
|
|
687
|
+
return r.split("").filter((f, g) => f === "+" ? g !== 0 || n ? !1 : (n = !0, !0) : /\d/.test(f) ? (t++, t <= s) : !1).join("");
|
|
680
688
|
}
|
|
681
689
|
const Ua = /^[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i;
|
|
682
|
-
function
|
|
683
|
-
return Ua.test(
|
|
690
|
+
function Ee(r) {
|
|
691
|
+
return Ua.test(r);
|
|
684
692
|
}
|
|
685
|
-
function Va(
|
|
686
|
-
var n,
|
|
687
|
-
const
|
|
688
|
-
return (n = s.phone) != null && n.enabled && /\d/.test(
|
|
693
|
+
function Va(r, s) {
|
|
694
|
+
var n, f;
|
|
695
|
+
const t = r.trim();
|
|
696
|
+
return (n = s.phone) != null && n.enabled && /\d/.test(t) && !t.includes("@") ? "phone" : (f = s.email) != null && f.enabled ? "email" : null;
|
|
689
697
|
}
|
|
690
|
-
const Aa = { class: "smart-input" }, Fa = /* @__PURE__ */
|
|
698
|
+
const Aa = { class: "smart-input" }, Fa = /* @__PURE__ */ H({
|
|
691
699
|
__name: "index",
|
|
692
700
|
props: {
|
|
693
701
|
modelValue: {},
|
|
@@ -700,133 +708,156 @@ const Aa = { class: "smart-input" }, Fa = /* @__PURE__ */ X({
|
|
|
700
708
|
errorMessages: {}
|
|
701
709
|
},
|
|
702
710
|
emits: ["update:modelValue", "validity-change", "type-change"],
|
|
703
|
-
setup(
|
|
704
|
-
const
|
|
705
|
-
|
|
711
|
+
setup(r, { emit: s }) {
|
|
712
|
+
const t = r, n = s, f = V(() => t.locale ?? "ru"), g = (d) => le[f.value][d] || d, x = V(() => t.label ? g(t.label) : g("Email или телефон"));
|
|
713
|
+
function m(d, h) {
|
|
714
|
+
return h ? h in le[f.value] ? g(h) : h : g(d);
|
|
715
|
+
}
|
|
716
|
+
const i = V(() => {
|
|
717
|
+
var d, h, y, B, C, k, M, A, S, _, q;
|
|
706
718
|
return {
|
|
707
|
-
mode: ((
|
|
719
|
+
mode: ((d = t.config) == null ? void 0 : d.mode) ?? "auto",
|
|
708
720
|
phone: {
|
|
709
|
-
enabled: ((
|
|
710
|
-
minDigits: ((
|
|
711
|
-
maxDigits: ((
|
|
712
|
-
autoPlus: ((
|
|
721
|
+
enabled: ((y = (h = t.config) == null ? void 0 : h.phone) == null ? void 0 : y.enabled) ?? !0,
|
|
722
|
+
minDigits: ((C = (B = t.config) == null ? void 0 : B.phone) == null ? void 0 : C.minDigits) ?? 10,
|
|
723
|
+
maxDigits: ((M = (k = t.config) == null ? void 0 : k.phone) == null ? void 0 : M.maxDigits) ?? 15,
|
|
724
|
+
autoPlus: ((S = (A = t.config) == null ? void 0 : A.phone) == null ? void 0 : S.autoPlus) ?? !0
|
|
713
725
|
},
|
|
714
726
|
email: {
|
|
715
|
-
enabled: ((
|
|
727
|
+
enabled: ((q = (_ = t.config) == null ? void 0 : _.email) == null ? void 0 : q.enabled) ?? !0
|
|
716
728
|
}
|
|
717
729
|
};
|
|
718
|
-
}),
|
|
719
|
-
|
|
720
|
-
|
|
730
|
+
}), v = b(null), E = b(""), u = b(t.modelValue ?? ""), c = b(null), w = b("");
|
|
731
|
+
Pe(() => t.modelValue, (d) => {
|
|
732
|
+
d !== void 0 && (u.value = d, E.value = d);
|
|
721
733
|
});
|
|
722
|
-
function
|
|
723
|
-
var
|
|
724
|
-
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
|
|
734
|
+
function l(d) {
|
|
735
|
+
var C;
|
|
736
|
+
w.value = "";
|
|
737
|
+
const y = d.target.value;
|
|
738
|
+
if (y.trim() === "") {
|
|
739
|
+
c.value = null, w.value = "", n("type-change", null), n("update:modelValue", ""), n("validity-change", !1);
|
|
728
740
|
return;
|
|
729
741
|
}
|
|
730
|
-
const
|
|
731
|
-
if (
|
|
732
|
-
const
|
|
733
|
-
u.value =
|
|
742
|
+
const B = i.value.mode === "auto" ? Va(y, i.value) : i.value.mode;
|
|
743
|
+
if (c.value = B, n("type-change", B), B === "email") {
|
|
744
|
+
const k = Ee(y);
|
|
745
|
+
u.value = y, E.value = y, n("update:modelValue", y), n("validity-change", k);
|
|
734
746
|
return;
|
|
735
747
|
}
|
|
736
|
-
if (
|
|
737
|
-
const
|
|
738
|
-
|
|
748
|
+
if (B === "phone") {
|
|
749
|
+
const k = he(
|
|
750
|
+
y,
|
|
739
751
|
i.value.phone.autoPlus,
|
|
740
|
-
|
|
752
|
+
t.locale
|
|
741
753
|
);
|
|
742
|
-
if (
|
|
743
|
-
const
|
|
744
|
-
u.value =
|
|
754
|
+
if (ye(k).length > i.value.phone.maxDigits) {
|
|
755
|
+
const S = Ia(y, i.value.phone.maxDigits);
|
|
756
|
+
u.value = S, n("update:modelValue", S), R(S);
|
|
745
757
|
return;
|
|
746
758
|
}
|
|
747
|
-
if (u.value =
|
|
748
|
-
|
|
759
|
+
if (u.value = y, be(y)) {
|
|
760
|
+
w.value = m(
|
|
761
|
+
"Допустимы только цифры и знак + в начале",
|
|
762
|
+
(C = t.errorMessages) == null ? void 0 : C.invalidPhoneChars
|
|
763
|
+
), n("validity-change", !1);
|
|
749
764
|
return;
|
|
750
765
|
}
|
|
751
|
-
u.value =
|
|
752
|
-
const
|
|
753
|
-
|
|
766
|
+
u.value = k, n("update:modelValue", k), E.value = k;
|
|
767
|
+
const A = we(
|
|
768
|
+
k,
|
|
754
769
|
i.value.phone.minDigits,
|
|
755
770
|
i.value.phone.maxDigits
|
|
756
771
|
);
|
|
757
|
-
n("validity-change",
|
|
772
|
+
n("validity-change", A);
|
|
758
773
|
}
|
|
759
774
|
}
|
|
760
|
-
function
|
|
761
|
-
var
|
|
762
|
-
if (console.debug("✅[event] onBlur is working"), !!
|
|
763
|
-
if (
|
|
764
|
-
const
|
|
775
|
+
function $() {
|
|
776
|
+
var d, h, y, B;
|
|
777
|
+
if (console.debug("✅[event] onBlur is working"), !!c.value) {
|
|
778
|
+
if (c.value === "phone") {
|
|
779
|
+
const C = he(
|
|
765
780
|
u.value,
|
|
766
781
|
i.value.phone.autoPlus,
|
|
767
|
-
|
|
768
|
-
);
|
|
769
|
-
if (
|
|
770
|
-
|
|
782
|
+
t.locale
|
|
783
|
+
), k = ye(C);
|
|
784
|
+
if (be(C)) {
|
|
785
|
+
w.value = m(
|
|
786
|
+
"Допустимы только цифры и знак + в начале",
|
|
787
|
+
(d = t.errorMessages) == null ? void 0 : d.invalidPhoneChars
|
|
788
|
+
), n("validity-change", !1);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
if (k.length < Ba) {
|
|
792
|
+
w.value = m(
|
|
793
|
+
"Это не похоже на номер телефона",
|
|
794
|
+
(h = t.errorMessages) == null ? void 0 : h.invalidPhoneLength
|
|
795
|
+
), n("validity-change", !1);
|
|
771
796
|
return;
|
|
772
797
|
}
|
|
773
|
-
const
|
|
774
|
-
|
|
798
|
+
const M = we(
|
|
799
|
+
C,
|
|
775
800
|
i.value.phone.minDigits,
|
|
776
801
|
i.value.phone.maxDigits
|
|
777
802
|
);
|
|
778
|
-
|
|
803
|
+
w.value = M ? "" : m(
|
|
804
|
+
"Это не похоже на номер телефона",
|
|
805
|
+
(y = t.errorMessages) == null ? void 0 : y.invalidPhoneLength
|
|
806
|
+
), n("validity-change", M);
|
|
779
807
|
}
|
|
780
|
-
if (
|
|
781
|
-
const
|
|
782
|
-
|
|
808
|
+
if (c.value === "email") {
|
|
809
|
+
const C = Ee(u.value);
|
|
810
|
+
w.value = C ? "" : m(
|
|
811
|
+
"Это не похоже на email",
|
|
812
|
+
(B = t.errorMessages) == null ? void 0 : B.invalidEmail
|
|
813
|
+
), n("validity-change", C);
|
|
783
814
|
}
|
|
784
815
|
}
|
|
785
816
|
}
|
|
786
|
-
function
|
|
787
|
-
var
|
|
788
|
-
const
|
|
789
|
-
return
|
|
817
|
+
function L() {
|
|
818
|
+
var h;
|
|
819
|
+
const d = (h = v.value) == null ? void 0 : h.$el;
|
|
820
|
+
return d ? d.querySelector("input") : null;
|
|
790
821
|
}
|
|
791
|
-
function
|
|
792
|
-
const
|
|
793
|
-
if (!
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
822
|
+
function R(d) {
|
|
823
|
+
const h = L();
|
|
824
|
+
if (!h) return;
|
|
825
|
+
const y = h.selectionStart ?? d.length;
|
|
826
|
+
h.value = d, requestAnimationFrame(() => {
|
|
827
|
+
h.setSelectionRange(y, y);
|
|
797
828
|
});
|
|
798
829
|
}
|
|
799
|
-
return (
|
|
800
|
-
|
|
830
|
+
return (d, h) => (N(), F("div", Aa, [
|
|
831
|
+
P(p(j), {
|
|
801
832
|
ref_key: "inputRef",
|
|
802
|
-
ref:
|
|
833
|
+
ref: v,
|
|
803
834
|
"model-value": u.value,
|
|
804
|
-
readonly:
|
|
805
|
-
error:
|
|
806
|
-
type:
|
|
807
|
-
size:
|
|
808
|
-
label:
|
|
809
|
-
onInput:
|
|
810
|
-
onBlur:
|
|
835
|
+
readonly: d.disabled,
|
|
836
|
+
error: w.value,
|
|
837
|
+
type: d.type ?? "text",
|
|
838
|
+
size: d.size ?? "large",
|
|
839
|
+
label: x.value,
|
|
840
|
+
onInput: l,
|
|
841
|
+
onBlur: $
|
|
811
842
|
}, null, 8, ["model-value", "readonly", "error", "type", "size", "label"]),
|
|
812
|
-
|
|
843
|
+
c.value === "phone" ? (N(), z(p(oa), {
|
|
813
844
|
key: 0,
|
|
814
845
|
class: "smart-input__icon"
|
|
815
|
-
})) :
|
|
816
|
-
|
|
846
|
+
})) : U("", !0),
|
|
847
|
+
c.value === "email" ? (N(), z(p(ra), {
|
|
817
848
|
key: 1,
|
|
818
849
|
class: "smart-input__icon"
|
|
819
|
-
})) :
|
|
850
|
+
})) : U("", !0)
|
|
820
851
|
]));
|
|
821
852
|
}
|
|
822
|
-
}),
|
|
853
|
+
}), _a = /* @__PURE__ */ ke(Fa, [["__scopeId", "data-v-3f64f8a0"]]);
|
|
823
854
|
export {
|
|
824
855
|
za as B,
|
|
825
856
|
$a as C,
|
|
826
|
-
|
|
857
|
+
ke as _,
|
|
827
858
|
La as a,
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
859
|
+
da as g,
|
|
860
|
+
_a as i,
|
|
861
|
+
re as p,
|
|
862
|
+
le as t
|
|
832
863
|
};
|