@yourgoods/ui-smart 0.52.0 → 0.53.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.
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as oe, ref as T, reactive as Z, watch as Y, computed as b, toRefs as ce, createElementBlock as I, openBlock as y, createElementVNode as x, createCommentVNode as D, toDisplayString as _, createVNode as $, unref as u, isRef as ee, withCtx as G, createTextVNode as ie, Fragment as Ae, createBlock as H, resolveDynamicComponent as he, onMounted as Fe } from "vue";
2
- import { _ as ve, c as ke, u as Re, a as ze, P as Me, b as We } from "./useRateLimitToast-DlqIYV_M.js";
3
- import { C as F, _ as He, B as qe, p as W, g as je } from "./index-dOnVTlJF.js";
2
+ import { _ as ve, c as ke, u as Re, a as ze, P as Me, b as We } from "./useRateLimitToast-dTazeFjT.js";
3
+ import { C as F, _ as He, B as qe, p as W, g as je } from "./index-BCa-BxGo.js";
4
4
  import { PInput as J, IconMailMd as pe, PButton as ne, IconEyeMd as Ve, IconEyeClosedMd as be, PDialog as Ge, PTopBar as Ye, IconCrossMd as Je } from "@profeat/ui-kit";
5
5
  const Ke = { class: "dialogDefaultContainerInsideContent" }, Qe = { class: "dialogDefaultContainerTextHint" }, Xe = {
6
6
  key: 0,
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as ye, ref as a, reactive as _, computed as u, watch as Z, onMounted as Ce, createElementBlock as S, openBlock as g, Fragment as ge, createVNode as n, unref as o, withCtx as m, createCommentVNode as ee, createElementVNode as r, toDisplayString as V, createBlock as B, resolveDynamicComponent as $, createTextVNode as z } from "vue";
2
- import { C as I, p as D, g as Ve } from "./index-dOnVTlJF.js";
2
+ import { C as I, p as D, g as Ve } from "./index-BCa-BxGo.js";
3
3
  import { PDialog as be, PInput as M, IconEyeMd as O, IconEyeClosedMd as U, PButton as F, PTopBar as Te, IconCrossMd as Ie, PTeleportContainer as xe } from "@profeat/ui-kit";
4
4
  function ke(b) {
5
5
  return { showPasswordRateLimitToast: (P) => {
@@ -1,7 +1,7 @@
1
1
  import { createElementBlock as S, openBlock as v, createElementVNode as H, defineComponent as he, reactive as ve, watch as _, ref as O, toRefs as Ce, computed as I, createCommentVNode as B, createVNode as b, toDisplayString as G, createBlock as J, createTextVNode as Z, unref as r, isRef as le, withCtx as X, onMounted as We, Fragment as je } from "vue";
2
- import { _ as we, c as Ne, a as He, u as Ge, P as Oe, b as Je } from "./useRateLimitToast-DlqIYV_M.js";
2
+ import { _ as we, c as Ne, a as He, u as Ge, P as Oe, b as Je } from "./useRateLimitToast-dTazeFjT.js";
3
3
  import { IconTelegramSm as Pe, PInput as se, IconPhoneMd as Re, IconMailMd as Ke, PButton as ze, PDialog as Qe, PTopBar as Xe, IconCrossMd as Ye, PTeleportContainer as Ze } from "@profeat/ui-kit";
4
- import { C as j, t as De, p as te, g as Ae } from "./index-dOnVTlJF.js";
4
+ import { C as j, t as De, p as te, g as Ae } from "./index-BCa-BxGo.js";
5
5
  const _e = {
6
6
  xmlns: "http://www.w3.org/2000/svg",
7
7
  width: "12",
@@ -0,0 +1,19 @@
1
+ import { SmartInputConfig } from './types';
2
+ declare const _default: import('vue').DefineComponent<{
3
+ modelValue?: string;
4
+ disabled?: boolean;
5
+ config?: SmartInputConfig;
6
+ }, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
7
+ "update:modelValue": (value: string) => any;
8
+ "validity-change": (valid: boolean) => any;
9
+ "type-change": (type: "email" | "phone" | null) => any;
10
+ }, string, import('vue').PublicProps, Readonly<{
11
+ modelValue?: string;
12
+ disabled?: boolean;
13
+ config?: SmartInputConfig;
14
+ }> & Readonly<{
15
+ "onUpdate:modelValue"?: ((value: string) => any) | undefined;
16
+ "onValidity-change"?: ((valid: boolean) => any) | undefined;
17
+ "onType-change"?: ((type: "email" | "phone" | null) => any) | undefined;
18
+ }>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
19
+ export default _default;
@@ -0,0 +1,16 @@
1
+ type InputMode = 'phone' | 'email' | 'auto';
2
+ export interface PhoneValidationConfig {
3
+ enabled: boolean;
4
+ minDigits?: number;
5
+ maxDigits?: number;
6
+ autoPlus?: boolean;
7
+ }
8
+ export interface EmailValidationConfig {
9
+ enabled: boolean;
10
+ }
11
+ export interface SmartInputConfig {
12
+ mode?: InputMode;
13
+ phone?: PhoneValidationConfig;
14
+ email?: EmailValidationConfig;
15
+ }
16
+ export {};
@@ -0,0 +1,2 @@
1
+ import { SmartInputConfig } from '../types';
2
+ export declare function detectInputType(value: string, config: SmartInputConfig): 'phone' | 'email' | null;
@@ -0,0 +1,2 @@
1
+ export declare const EMAIL_REGEX: RegExp;
2
+ export declare function isValidEmail(value: string): boolean;
@@ -0,0 +1,4 @@
1
+ export declare function normalizePhoneInput(raw: string, autoPlus: boolean): string;
2
+ export declare function limitPhoneLength(value: string, maxDigits: number): string;
3
+ export declare function isValidPhone(value: string, minDigits?: number, maxDigits?: number): boolean;
4
+ export declare function hasInvalidPhoneChars(raw: string): boolean;
@@ -1 +1,2 @@
1
1
  export { default as PEditUserContact } from './PEditUserContact/index.vue';
2
+ export { default as PEmailOrPhoneInput } from './PEmailOrPhoneInput/index.vue';
@@ -1,13 +1,13 @@
1
- import { ref as w, shallowRef as Le, defineComponent as H, defineAsyncComponent as J, watch as ze, createBlock as I, createCommentVNode as C, unref as m, openBlock as y, resolveDynamicComponent as Me, mergeProps as Re, computed as T, reactive as q, onMounted as Ge, createElementBlock as k, Fragment as me, createVNode as g, createElementVNode as Y, withCtx as F, toDisplayString as D, createTextVNode as _, Teleport as ue, Transition as je, withDirectives as Je, vShow as qe } from "vue";
2
- import Ye from "axios";
3
- import { PInputFileUploader as _e, PInput as L, IconFilledEditMd as z, PButton as de, PImageCropper as We, PToast as Ke, PTeleportContainer as pe, PToastContainer as Ze } from "@profeat/ui-kit";
4
- function He(i, r = 2) {
5
- if (i === 0)
1
+ import { ref as y, shallowRef as _e, defineComponent as j, defineAsyncComponent as q, watch as me, createBlock as I, createCommentVNode as C, unref as f, openBlock as w, resolveDynamicComponent as Oe, mergeProps as Re, computed as U, reactive as W, onMounted as Ge, createElementBlock as k, Fragment as ce, createVNode as h, createElementVNode as Y, withCtx as x, toDisplayString as $, createTextVNode as X, Teleport as ue, Transition as je, withDirectives as Je, vShow as qe } from "vue";
2
+ import We from "axios";
3
+ import { PInputFileUploader as Ye, PInput as L, IconFilledEditMd as R, PButton as de, PImageCropper as Xe, PToast as Ke, PTeleportContainer as pe, PToastContainer as Ze, IconPhoneMd as He, IconMailMd as Qe } from "@profeat/ui-kit";
4
+ function et(n, s = 2) {
5
+ if (n === 0)
6
6
  return "0 B";
7
- const n = 1024, s = ["B", "KB", "MB", "GB", "TB", "PB", "EB"], v = Math.floor(Math.log(i) / Math.log(n));
8
- return `${Number.parseFloat((i / n ** v).toFixed(r))} ${s[v]}`;
7
+ const a = 1024, l = ["B", "KB", "MB", "GB", "TB", "PB", "EB"], g = Math.floor(Math.log(n) / Math.log(a));
8
+ return `${Number.parseFloat((n / a ** g).toFixed(s))} ${l[g]}`;
9
9
  }
10
- const Qe = {
10
+ const tt = {
11
11
  "image/jpeg": "JPEG",
12
12
  "image/png": "PNG",
13
13
  "application/pdf": "PDF",
@@ -15,67 +15,67 @@ const Qe = {
15
15
  "application/zip": "ZIP Archive"
16
16
  // ...
17
17
  };
18
- function Xe(i) {
19
- return i.map((r) => {
20
- var n;
21
- return Qe[r] || ((n = r.split("/")[1]) == null ? void 0 : n.toUpperCase());
18
+ function at(n) {
19
+ return n.map((s) => {
20
+ var a;
21
+ return tt[s] || ((a = s.split("/")[1]) == null ? void 0 : a.toUpperCase());
22
22
  });
23
23
  }
24
- const Na = {
24
+ const xt = {
25
25
  OLD: "old",
26
26
  NEW: "new",
27
27
  COMPLETED: "completed"
28
- }, Pa = {
28
+ }, $t = {
29
29
  VERIFY_EMAIL: "verify-email"
30
30
  };
31
- let K = null;
32
- function ea(i, r, n) {
33
- K = Ye.create({
34
- baseURL: r,
31
+ let Z = null;
32
+ function ot(n, s, a) {
33
+ Z = We.create({
34
+ baseURL: s,
35
35
  headers: {
36
- Authorization: `Bearer ${i}`,
37
- "x-throttler-prefix": n ?? "throttler_profile_edit"
36
+ Authorization: `Bearer ${n}`,
37
+ "x-throttler-prefix": a ?? "throttler_profile_edit"
38
38
  // здесь можно словить баг, который может быть сложно отследить, если будет передаваться пустой прелфикс
39
39
  // 'Content-Type': 'application/json',
40
40
  },
41
- validateStatus: (s) => s >= 200 && s < 300
41
+ validateStatus: (l) => l >= 200 && l < 300
42
42
  });
43
43
  }
44
44
  function Q() {
45
- if (!K)
45
+ if (!Z)
46
46
  throw new Error("Axios instance not initialized. Call initAxios(token, baseUrl) first.");
47
- return K;
47
+ return Z;
48
48
  }
49
- async function Z(i, r, n) {
50
- return Q().post(i, r, n);
49
+ async function H(n, s, a) {
50
+ return Q().post(n, s, a);
51
51
  }
52
- async function aa(i, r) {
53
- return Q().get(i, r);
52
+ async function nt(n, s) {
53
+ return Q().get(n, s);
54
54
  }
55
- async function ta(i, r) {
56
- return Q().delete(i, r);
55
+ async function rt(n, s) {
56
+ return Q().delete(n, s);
57
57
  }
58
- async function oa(i) {
59
- const r = await Z("/users/profile/me", i);
60
- if (r.status !== 200 && r.status !== 201 || !r.data)
58
+ async function lt(n) {
59
+ const s = await H("/users/profile/me", n);
60
+ if (s.status !== 200 && s.status !== 201 || !s.data)
61
61
  throw new Error("Ошибка при получении профиля пользователя");
62
- return r.data;
62
+ return s.data;
63
63
  }
64
- const M = w(null), W = Le(null);
65
- function X() {
64
+ const G = y(null), K = _e(null);
65
+ function ee() {
66
66
  return {
67
- currentDialog: M,
68
- dialogPayload: W,
69
- openDialog: (s, v) => {
70
- M.value = s, W.value = v ?? null;
67
+ currentDialog: G,
68
+ dialogPayload: K,
69
+ openDialog: (l, g) => {
70
+ G.value = l, K.value = g ?? null;
71
71
  },
72
72
  closeDialog: () => {
73
- M.value = null, W.value = null;
73
+ G.value = null, K.value = null;
74
74
  },
75
- isDialogOpen: (s) => M.value === s
75
+ isDialogOpen: (l) => G.value === l
76
76
  };
77
77
  }
78
- const na = {
78
+ const st = {
79
79
  ru: {
80
80
  Имя: "Имя",
81
81
  Фамилия: "Фамилия",
@@ -208,7 +208,7 @@ const na = {
208
208
  "Введите новый номер телефона": "Enter a new phone number",
209
209
  "Телефон успешно изменен": "Phone number successfully changed"
210
210
  }
211
- }, ra = /* @__PURE__ */ H({
211
+ }, it = /* @__PURE__ */ j({
212
212
  __name: "DialogManager",
213
213
  props: {
214
214
  language: {},
@@ -216,54 +216,54 @@ const na = {
216
216
  disableAddPhone: { type: Boolean }
217
217
  },
218
218
  emits: ["clean-input-errors", "on-update-jwt", "update-phone-field", "update-email-field", "on-password-error", "on-toast"],
219
- setup(i, { emit: r }) {
220
- const n = r, s = w(!0), { currentDialog: v, dialogPayload: c, closeDialog: U } = X(), u = {
221
- email: J(() => import("./ProfileEmailDialog-BzqSGu9T.js")),
222
- phone: J(() => import("./ProfilePhoneDialog-DnQ9YIj0.js")),
223
- password: J(() => import("./ProfilePasswordDialog-CgOw023B.js"))
224
- }, l = ({ email: h }) => {
225
- n("update-email-field", h);
226
- }, p = ({ phone: h }) => {
227
- n("update-phone-field", h);
219
+ setup(n, { emit: s }) {
220
+ const a = s, l = y(!0), { currentDialog: g, dialogPayload: v, closeDialog: T } = ee(), d = {
221
+ email: q(() => import("./ProfileEmailDialog-CtmmQtpD.js")),
222
+ phone: q(() => import("./ProfilePhoneDialog-Ctd2paLO.js")),
223
+ password: q(() => import("./ProfilePasswordDialog-CYTRqVVd.js"))
224
+ }, c = ({ email: m }) => {
225
+ a("update-email-field", m);
226
+ }, i = ({ phone: m }) => {
227
+ a("update-phone-field", m);
228
228
  };
229
- return ze(v, (h) => {
230
- s.value = !!h;
231
- }), (h, d) => m(v) ? (y(), I(Me(u[m(v)]), Re({
229
+ return me(g, (m) => {
230
+ l.value = !!m;
231
+ }), (m, u) => f(g) ? (w(), I(Oe(d[f(g)]), Re({
232
232
  key: 0,
233
- modelValue: s.value,
234
- "onUpdate:modelValue": d[0] || (d[0] = (f) => s.value = f),
235
- language: h.language,
236
- provider: h.provider,
237
- "disable-add-phone": h.disableAddPhone
238
- }, m(c), {
239
- onClose: m(U),
240
- onCleanInputErrors: d[1] || (d[1] = (f) => n("clean-input-errors")),
241
- onOnUpdateJwt: d[2] || (d[2] = (f, N, o) => n("on-update-jwt", f, N, o)),
242
- onSubmitEmail: l,
243
- onSubmitPhone: p,
244
- onOnPasswordError: d[3] || (d[3] = (f, N) => n("on-password-error", f, N)),
245
- onOnToast: d[4] || (d[4] = (f) => n("on-toast", f))
233
+ modelValue: l.value,
234
+ "onUpdate:modelValue": u[0] || (u[0] = (p) => l.value = p),
235
+ language: m.language,
236
+ provider: m.provider,
237
+ "disable-add-phone": m.disableAddPhone
238
+ }, f(v), {
239
+ onClose: f(T),
240
+ onCleanInputErrors: u[1] || (u[1] = (p) => a("clean-input-errors")),
241
+ onOnUpdateJwt: u[2] || (u[2] = (p, b, r) => a("on-update-jwt", p, b, r)),
242
+ onSubmitEmail: c,
243
+ onSubmitPhone: i,
244
+ onOnPasswordError: u[3] || (u[3] = (p, b) => a("on-password-error", p, b)),
245
+ onOnToast: u[4] || (u[4] = (p) => a("on-toast", p))
246
246
  }), null, 16, ["modelValue", "language", "provider", "disable-add-phone", "onClose"])) : C("", !0);
247
247
  }
248
- }), sa = { class: "base-container" }, la = {
248
+ }), ut = { class: "base-container" }, dt = {
249
249
  key: 0,
250
250
  style: { color: "#E46060" }
251
- }, ia = { key: 1 }, ua = {
251
+ }, mt = { key: 1 }, ct = {
252
252
  key: 1,
253
253
  class: "input-wrapper"
254
- }, da = {
254
+ }, pt = {
255
255
  key: 2,
256
256
  class: "input-wrapper"
257
- }, ma = {
257
+ }, ft = {
258
258
  key: 3,
259
259
  class: "input-wrapper"
260
- }, pa = {
260
+ }, gt = {
261
261
  key: 4,
262
262
  class: "input-wrapper"
263
- }, ca = { class: "buttons-container" }, fa = {
263
+ }, vt = { class: "buttons-container" }, ht = {
264
264
  key: 0,
265
265
  class: "centered-overlay"
266
- }, ga = { class: "toastWrapper" }, va = /* @__PURE__ */ H({
266
+ }, yt = { class: "toastWrapper" }, wt = /* @__PURE__ */ j({
267
267
  __name: "PEditUserContact",
268
268
  props: {
269
269
  language: {},
@@ -277,8 +277,8 @@ const na = {
277
277
  disableAddPhone: { type: Boolean }
278
278
  },
279
279
  emits: ["open-email-dialog", "open-phone-dialog", "open-password-dialog", "on-update-jwt", "on-password-error", "update-tokens"],
280
- setup(i, { emit: r }) {
281
- const n = i, s = r, v = T(() => n.language ?? "ru"), c = (e) => na[v.value][e] || e, { openDialog: U } = X(), u = q({ firstName: "", lastName: "" }), l = w({ firstName: "", lastName: "" }), p = q({ firstName: !1, lastName: !1, email: !1, phone: !1 }), h = w(""), d = w(""), f = w(""), N = w(!1), o = q({
280
+ setup(n, { emit: s }) {
281
+ const a = n, l = s, g = U(() => a.language ?? "ru"), v = (e) => st[g.value][e] || e, { openDialog: T } = ee(), d = W({ firstName: "", lastName: "" }), c = y({ firstName: "", lastName: "" }), i = W({ firstName: !1, lastName: !1, email: !1, phone: !1 }), m = y(""), u = y(""), p = y(""), b = y(!1), r = W({
282
282
  value: null,
283
283
  loading: !1,
284
284
  accept: ["image/png", "image/jpeg"],
@@ -286,334 +286,334 @@ const na = {
286
286
  // 10 MB
287
287
  imageBinary: null,
288
288
  imageContent: ""
289
- }), B = w(""), S = w(!1), R = w(!0), G = w(!0), ee = w(void 0), ae = w(""), ce = T(() => oe(u.firstName, p.firstName)), fe = T(() => oe(u.lastName, p.lastName)), ge = T(() => p.email && !d.value.trim() ? "Введите e-mail" : ""), ve = T(() => p.phone && !f.value.trim() ? "Введите номер телефона" : ""), A = (e) => n.fields.some((a) => a.key === e), te = (e) => e && e.trim() ? "edit" : "bind", j = () => setTimeout(() => {
289
+ }), B = y(""), D = y(!1), A = y(!0), F = y(!0), V = y(void 0), te = y(""), ge = U(() => oe(d.firstName, i.firstName)), ve = U(() => oe(d.lastName, i.lastName)), he = U(() => i.email && !u.value.trim() ? "Введите e-mail" : ""), ye = U(() => i.phone && !p.value.trim() ? "Введите номер телефона" : ""), S = (e) => a.fields.some((t) => t.key === e), ae = (e) => e && e.trim() ? "edit" : "bind", J = () => setTimeout(() => {
290
290
  var e;
291
291
  return (e = document.activeElement) == null ? void 0 : e.blur();
292
- }, 0), he = T(() => !!(d.value && d.value.trim() !== "")), we = T(() => o.imageContent ? c("Загрузить другое фото") : c("Загрузить фото")), oe = (e, a) => {
293
- if (!a) return "";
294
- const t = e.trim();
295
- return t ? t.length < 2 ? "Поле должно содержать минимум 2 символа" : "" : "Введите значение";
296
- }, ye = (e) => U("email", { mode: e ? "edit" : "bind", initialEmail: e }), Ee = () => {
297
- j(), p.email = !1, G.value = !1, s("open-email-dialog", d.value, te(d.value)), ye(d.value);
298
- }, be = () => {
299
- j(), p.phone = !1, R.value = !1, s("open-phone-dialog", f.value, te(f.value));
300
- }, Ne = async (e, a, t) => {
301
- e === "email" && t && (d.value = t), e === "phone" && t && (f.value = t), s("on-update-jwt");
302
- }, Pe = (e) => {
303
- f.value = e;
304
- }, Ce = (e) => {
305
- d.value = e;
306
- }, ke = (e, a) => {
307
- S.value = !0, s("on-password-error", e, a);
308
- }, Te = () => {
309
- R.value = !1, G.value = !1;
310
- }, V = (e) => {
311
- S.value = !0, ee.value = e.color ?? "", ae.value = e.text ?? "";
312
- }, x = (e) => {
313
- if (p[e] = !0, e === "firstName" || e === "lastName") {
314
- const a = u[e];
315
- a.length > 40 && (u[e] = a.slice(0, 40));
292
+ }, 0), we = U(() => !!(u.value && u.value.trim() !== "")), be = U(() => r.imageContent ? v("Загрузить другое фото") : v("Загрузить фото")), oe = (e, t) => {
293
+ if (!t) return "";
294
+ const o = e.trim();
295
+ return o ? o.length < 2 ? "Поле должно содержать минимум 2 символа" : "" : "Введите значение";
296
+ }, Ee = (e) => T("email", { mode: e ? "edit" : "bind", initialEmail: e }), Pe = () => {
297
+ J(), i.email = !1, F.value = !1, l("open-email-dialog", u.value, ae(u.value)), Ee(u.value);
298
+ }, Ne = () => {
299
+ J(), i.phone = !1, A.value = !1, l("open-phone-dialog", p.value, ae(p.value));
300
+ }, Ce = async (e, t, o) => {
301
+ e === "email" && o && (u.value = o), e === "phone" && o && (p.value = o), l("on-update-jwt");
302
+ }, ke = (e) => {
303
+ p.value = e;
304
+ }, Te = (e) => {
305
+ u.value = e;
306
+ }, Ue = (e, t) => {
307
+ D.value = !0, l("on-password-error", e, t);
308
+ }, Be = () => {
309
+ A.value = !1, F.value = !1;
310
+ }, M = (e) => {
311
+ D.value = !0, V.value = e.color ?? "", te.value = e.text ?? "";
312
+ }, z = (e) => {
313
+ if (i[e] = !0, e === "firstName" || e === "lastName") {
314
+ const t = d[e];
315
+ t.length > 40 && (d[e] = t.slice(0, 40));
316
316
  }
317
- }, Ue = (e) => {
318
- var $, O;
317
+ }, De = (e) => {
318
+ var _, O;
319
319
  if (B.value = "", !e) {
320
320
  ne();
321
321
  return;
322
322
  }
323
- const a = (($ = e.fileBinary) == null ? void 0 : $.type) ?? "", t = ((O = e.fileBinary) == null ? void 0 : O.size) ?? 0, P = !["image/png", "image/jpeg"].includes(a), b = t > o.uploadLimit;
324
- if (P || b) {
323
+ const t = ((_ = e.fileBinary) == null ? void 0 : _.type) ?? "", o = ((O = e.fileBinary) == null ? void 0 : O.size) ?? 0, N = !["image/png", "image/jpeg"].includes(t), P = o > r.uploadLimit;
324
+ if (N || P) {
325
325
  B.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", ne();
326
326
  return;
327
327
  }
328
- o.value = e, o.imageBinary = e.fileBinary ?? null, o.imageContent = e.fileContent ?? "", N.value = !0;
328
+ r.value = e, r.imageBinary = e.fileBinary ?? null, r.imageContent = e.fileContent ?? "", b.value = !0;
329
329
  }, ne = () => {
330
- o.value = null, o.imageBinary = null, o.imageContent = "", N.value = !1;
331
- }, Be = async () => {
330
+ r.value = null, r.imageBinary = null, r.imageContent = "", b.value = !1;
331
+ }, Ie = async () => {
332
332
  try {
333
- const a = (await ta("/users/profile/delete/avatar")).data;
334
- return (a == null ? void 0 : a.success) === !0;
333
+ const t = (await rt("/users/profile/delete/avatar")).data;
334
+ return (t == null ? void 0 : t.success) === !0;
335
335
  } catch (e) {
336
336
  return console.error("Ошибка при удалении аватара:", e), !1;
337
337
  }
338
338
  }, Ae = () => {
339
- B.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", o.value = null, o.imageBinary = null, o.imageContent = "", N.value = !1;
340
- }, re = async (e, a, t = "image/png") => {
339
+ B.value = "Файл не подходит. Пожалуйста, загрузите PNG или JPEG размером до 10 МБ", r.value = null, r.imageBinary = null, r.imageContent = "", b.value = !1;
340
+ }, re = async (e, t, o = "image/png") => {
341
341
  if (!e) return null;
342
- const P = await (await fetch(e)).blob();
343
- return new File([P], a, { type: t });
342
+ const N = await (await fetch(e)).blob();
343
+ return new File([N], t, { type: o });
344
344
  }, Fe = () => {
345
- o.value = null, o.imageBinary = null, o.imageContent = "", N.value = !1;
346
- }, De = async (e) => {
347
- N.value = !1;
348
- const a = o.imageContent;
349
- if (o.imageContent = e, !o.imageBinary) return;
350
- const t = await re(
345
+ r.value = null, r.imageBinary = null, r.imageContent = "", b.value = !1;
346
+ }, Ve = async (e) => {
347
+ b.value = !1;
348
+ const t = r.imageContent;
349
+ if (r.imageContent = e, !r.imageBinary) return;
350
+ const o = await re(
351
351
  e,
352
- o.imageBinary.name,
353
- o.imageBinary.type || "image/png"
352
+ r.imageBinary.name,
353
+ r.imageBinary.type || "image/png"
354
354
  );
355
- if (!t) {
356
- o.imageContent = a;
355
+ if (!o) {
356
+ r.imageContent = t;
357
357
  return;
358
358
  }
359
359
  try {
360
- o.loading = !0;
360
+ r.loading = !0;
361
361
  const E = new FormData();
362
- E.append("file", t), await Z(`/users/profile/avatar/${h.value}`, E, { headers: { "Content-Type": void 0 } });
362
+ E.append("file", o), await H(`/users/profile/avatar/${m.value}`, E, { headers: { "Content-Type": void 0 } });
363
363
  } catch (E) {
364
- console.error(E), V({
364
+ console.error(E), M({
365
365
  color: "error",
366
- text: c("Не удалось сохранить изменения. Попробуйте позже")
367
- }), o.imageContent = a;
366
+ text: v("Не удалось сохранить изменения. Попробуйте позже")
367
+ }), r.imageContent = t;
368
368
  } finally {
369
- o.loading = !1;
369
+ r.loading = !1;
370
370
  }
371
- }, Ie = async (e) => {
372
- o.imageContent = e ?? "", o.imageBinary && (o.imageBinary = await re(
371
+ }, Se = async (e) => {
372
+ r.imageContent = e ?? "", r.imageBinary && (r.imageBinary = await re(
373
373
  e ?? "",
374
- o.imageBinary.name,
375
- o.imageBinary.type || "image/png"
374
+ r.imageBinary.name,
375
+ r.imageBinary.type || "image/png"
376
376
  ));
377
- }, se = w(!1), le = async (e) => {
378
- var t, E;
379
- const a = (t = u[e]) == null ? void 0 : t.trim();
380
- if (a)
377
+ }, le = y(!1), se = async (e) => {
378
+ var o, E;
379
+ const t = (o = d[e]) == null ? void 0 : o.trim();
380
+ if (t)
381
381
  try {
382
- se.value = !0;
383
- const b = (E = (await Z("/users/profile/update-name", { [e]: a })).data) == null ? void 0 : E.data;
384
- b != null && b.user && (u.firstName = b.user.firstName ?? u.firstName, u.lastName = b.user.lastName ?? u.lastName, l.value = {
385
- firstName: u.firstName,
386
- lastName: u.lastName
382
+ le.value = !0;
383
+ const P = (E = (await H("/users/profile/update-name", { [e]: t })).data) == null ? void 0 : E.data;
384
+ P != null && P.user && (d.firstName = P.user.firstName ?? d.firstName, d.lastName = P.user.lastName ?? d.lastName, c.value = {
385
+ firstName: d.firstName,
386
+ lastName: d.lastName
387
387
  });
388
- } catch (P) {
389
- throw P;
388
+ } catch (N) {
389
+ throw N;
390
390
  } finally {
391
- se.value = !1;
391
+ le.value = !1;
392
392
  }
393
- }, Se = async () => {
393
+ }, xe = async () => {
394
394
  var e;
395
- if (!n.accessToken)
395
+ if (!a.accessToken)
396
396
  throw console.error("Access token не передан в props"), new Error("Access token is required");
397
397
  try {
398
- const t = (e = (await oa({
399
- accessToken: n.accessToken,
400
- refreshToken: n.refreshToken ?? "",
398
+ const o = (e = (await lt({
399
+ accessToken: a.accessToken,
400
+ refreshToken: a.refreshToken ?? "",
401
401
  excludeFields: []
402
402
  })).data) == null ? void 0 : e.user;
403
- if (!t)
403
+ if (!o)
404
404
  throw console.error("Данные пользователя отсутствуют в ответе сервера"), new Error("User data is missing from the response");
405
405
  const {
406
406
  userId: E,
407
- privateFirstName: P,
408
- privateLastName: b,
409
- email: $,
407
+ privateFirstName: N,
408
+ privateLastName: P,
409
+ email: _,
410
410
  phoneNumber: O
411
- } = t;
412
- h.value = E ?? "", u.firstName = P ?? "", u.lastName = b ?? "", d.value = $ ?? "", f.value = O ?? "", o.imageContent = await Ve(), l.value = {
413
- firstName: P ?? "",
414
- lastName: b ?? ""
411
+ } = o;
412
+ m.value = E ?? "", d.firstName = N ?? "", d.lastName = P ?? "", u.value = _ ?? "", p.value = O ?? "", r.imageContent = await $e(), c.value = {
413
+ firstName: N ?? "",
414
+ lastName: P ?? ""
415
415
  };
416
- } catch (a) {
417
- console.error("Критическая ошибка при загрузке профиля:", a);
416
+ } catch (t) {
417
+ console.error("Критическая ошибка при загрузке профиля:", t);
418
418
  }
419
- }, Ve = async () => {
419
+ }, $e = async () => {
420
420
  var e;
421
421
  try {
422
- const t = (e = (await aa("/users/profile/avatar")).data) == null ? void 0 : e.data;
423
- return t ? xe(t) : "";
424
- } catch (a) {
425
- return console.error("Ошибка при загрузке метаданных аватара:", a), "";
422
+ const o = (e = (await nt("/users/profile/avatar")).data) == null ? void 0 : e.data;
423
+ return o ? Le(o) : "";
424
+ } catch (t) {
425
+ return console.error("Ошибка при загрузке метаданных аватара:", t), "";
426
426
  }
427
427
  };
428
- function xe(e) {
428
+ function Le(e) {
429
429
  if (!e)
430
430
  return "";
431
431
  try {
432
- return new URL(e.key, n.awsStorageUrl).toString();
433
- } catch (a) {
434
- return console.error("Ошибка при составлении URL аватара:", a), "";
432
+ return new URL(e.key, a.awsStorageUrl).toString();
433
+ } catch (t) {
434
+ return console.error("Ошибка при составлении URL аватара:", t), "";
435
435
  }
436
436
  }
437
- const ie = T(() => {
438
- if (!l.value.firstName && !l.value.lastName)
437
+ const ie = U(() => {
438
+ if (!c.value.firstName && !c.value.lastName)
439
439
  return !1;
440
- const e = u.firstName.trim(), a = u.lastName.trim(), t = l.value.firstName.trim(), E = l.value.lastName.trim(), P = e !== t || a !== E, b = e.length >= 2 && a.length >= 2;
441
- return P && b;
442
- }), $e = async () => {
440
+ const e = d.firstName.trim(), t = d.lastName.trim(), o = c.value.firstName.trim(), E = c.value.lastName.trim(), N = e !== o || t !== E, P = e.length >= 2 && t.length >= 2;
441
+ return N && P;
442
+ }), Me = async () => {
443
443
  if (ie.value)
444
444
  try {
445
- await Promise.all([le("firstName"), le("lastName")]), s("on-update-jwt"), V({ color: "success", text: "Изменения сохранены" });
445
+ await Promise.all([se("firstName"), se("lastName")]), l("on-update-jwt"), M({ color: "success", text: "Изменения сохранены" });
446
446
  } catch (e) {
447
- console.error(e), V({
447
+ console.error(e), M({
448
448
  color: "error",
449
- text: c("Не удалось сохранить изменения. Попробуйте позже")
449
+ text: v("Не удалось сохранить изменения. Попробуйте позже")
450
450
  });
451
451
  }
452
- }, Oe = () => {
453
- j(), s("open-password-dialog");
452
+ }, ze = () => {
453
+ J(), l("open-password-dialog");
454
454
  };
455
455
  return Ge(async () => {
456
- if (!n.accessToken) throw new Error("Access token не передан в props");
457
- if (!n.requestUrl) throw new Error("auth-backend url не передан в props");
458
- ea(n.accessToken, n.requestUrl, n.throttlerPrefix), await Se();
459
- }), (e, a) => (y(), k(me, null, [
460
- g(ra, {
461
- language: v.value,
456
+ if (!a.accessToken) throw new Error("Access token не передан в props");
457
+ if (!a.requestUrl) throw new Error("auth-backend url не передан в props");
458
+ ot(a.accessToken, a.requestUrl, a.throttlerPrefix), await xe();
459
+ }), (e, t) => (w(), k(ce, null, [
460
+ h(it, {
461
+ language: g.value,
462
462
  provider: e.provider,
463
463
  "disable-add-phone": e.disableAddPhone,
464
- onCleanInputErrors: Te,
465
- onOnUpdateJwt: Ne,
466
- onUpdatePhoneField: Pe,
467
- onUpdateEmailField: Ce,
468
- onOnPasswordError: ke,
469
- onOnToast: V
464
+ onCleanInputErrors: Be,
465
+ onOnUpdateJwt: Ce,
466
+ onUpdatePhoneField: ke,
467
+ onUpdateEmailField: Te,
468
+ onOnPasswordError: Ue,
469
+ onOnToast: M
470
470
  }, null, 8, ["language", "provider", "disable-add-phone"]),
471
- Y("div", sa, [
472
- A("avatar") ? (y(), I(m(_e), {
471
+ Y("div", ut, [
472
+ S("avatar") ? (w(), I(f(Ye), {
473
473
  key: 0,
474
- modelValue: o.value,
474
+ modelValue: r.value,
475
475
  "onUpdate:modelValue": [
476
- a[0] || (a[0] = (t) => o.value = t),
477
- a[1] || (a[1] = (t) => Ue(t))
476
+ t[0] || (t[0] = (o) => r.value = o),
477
+ t[1] || (t[1] = (o) => De(o))
478
478
  ],
479
479
  type: "img",
480
480
  class: "avatar-input",
481
- src: o.imageContent,
482
- loading: o.loading,
483
- label: c("Загрузить фото"),
484
- "upload-limit": o.uploadLimit,
481
+ src: r.imageContent,
482
+ loading: r.loading,
483
+ label: v("Загрузить фото"),
484
+ "upload-limit": r.uploadLimit,
485
485
  accept: "image/jpeg, image/png",
486
- onDelete: Be,
486
+ onDelete: Ie,
487
487
  "onChange:error": Ae
488
488
  }, {
489
- afterLoadLabel: F(() => [
490
- _(D(we.value), 1)
489
+ afterLoadLabel: x(() => [
490
+ X($(be.value), 1)
491
491
  ]),
492
- subtext: F(() => [
493
- B.value ? (y(), k("span", la, D(B.value), 1)) : (y(), k("span", ia, D(`${c("Формат")} ${m(Xe)(o.accept).join(", ")} ${c("до")} ${m(He)(o.uploadLimit)}`), 1))
492
+ subtext: x(() => [
493
+ B.value ? (w(), k("span", dt, $(B.value), 1)) : (w(), k("span", mt, $(`${v("Формат")} ${f(at)(r.accept).join(", ")} ${v("до")} ${f(et)(r.uploadLimit)}`), 1))
494
494
  ]),
495
495
  _: 1
496
496
  }, 8, ["modelValue", "src", "loading", "label", "upload-limit"])) : C("", !0),
497
- A("firstName") ? (y(), k("div", ua, [
498
- g(m(L), {
499
- modelValue: u.firstName,
500
- "onUpdate:modelValue": a[2] || (a[2] = (t) => u.firstName = t),
497
+ S("firstName") ? (w(), k("div", ct, [
498
+ h(f(L), {
499
+ modelValue: d.firstName,
500
+ "onUpdate:modelValue": t[2] || (t[2] = (o) => d.firstName = o),
501
501
  size: "large",
502
- label: c("Имя"),
503
- error: ce.value,
504
- onBlur: a[3] || (a[3] = (t) => p.firstName = !0),
505
- onInput: a[4] || (a[4] = (t) => x("firstName"))
502
+ label: v("Имя"),
503
+ error: ge.value,
504
+ onBlur: t[3] || (t[3] = (o) => i.firstName = !0),
505
+ onInput: t[4] || (t[4] = (o) => z("firstName"))
506
506
  }, null, 8, ["modelValue", "label", "error"]),
507
- g(m(z), { class: "icon-locked" })
507
+ h(f(R), { class: "icon-locked" })
508
508
  ])) : C("", !0),
509
- A("lastName") ? (y(), k("div", da, [
510
- g(m(L), {
511
- modelValue: u.lastName,
512
- "onUpdate:modelValue": a[5] || (a[5] = (t) => u.lastName = t),
509
+ S("lastName") ? (w(), k("div", pt, [
510
+ h(f(L), {
511
+ modelValue: d.lastName,
512
+ "onUpdate:modelValue": t[5] || (t[5] = (o) => d.lastName = o),
513
513
  size: "large",
514
- label: c("Фамилия"),
515
- error: fe.value,
516
- onBlur: a[6] || (a[6] = (t) => p.lastName = !0),
517
- onInput: a[7] || (a[7] = (t) => x("lastName"))
514
+ label: v("Фамилия"),
515
+ error: ve.value,
516
+ onBlur: t[6] || (t[6] = (o) => i.lastName = !0),
517
+ onInput: t[7] || (t[7] = (o) => z("lastName"))
518
518
  }, null, 8, ["modelValue", "label", "error"]),
519
- g(m(z), { class: "icon-locked" })
519
+ h(f(R), { class: "icon-locked" })
520
520
  ])) : C("", !0),
521
- A("email") ? (y(), k("div", ma, [
522
- g(m(L), {
523
- modelValue: d.value,
524
- "onUpdate:modelValue": a[8] || (a[8] = (t) => d.value = t),
521
+ S("email") ? (w(), k("div", ft, [
522
+ h(f(L), {
523
+ modelValue: u.value,
524
+ "onUpdate:modelValue": t[8] || (t[8] = (o) => u.value = o),
525
525
  size: "large",
526
526
  "text-size": "medium",
527
527
  label: "E-mail",
528
528
  type: "email",
529
529
  readonly: "",
530
530
  style: { cursor: "pointer" },
531
- error: ge.value && G.value,
532
- onBlur: a[9] || (a[9] = (t) => p.email = !0),
533
- onInput: a[10] || (a[10] = (t) => x("email")),
534
- onClick: Ee
531
+ error: he.value && F.value,
532
+ onBlur: t[9] || (t[9] = (o) => i.email = !0),
533
+ onInput: t[10] || (t[10] = (o) => z("email")),
534
+ onClick: Pe
535
535
  }, null, 8, ["modelValue", "error"]),
536
- g(m(z), { class: "icon-locked" })
536
+ h(f(R), { class: "icon-locked" })
537
537
  ])) : C("", !0),
538
- A("phone") ? (y(), k("div", pa, [
539
- g(m(L), {
540
- modelValue: f.value,
541
- "onUpdate:modelValue": a[11] || (a[11] = (t) => f.value = t),
538
+ S("phone") ? (w(), k("div", gt, [
539
+ h(f(L), {
540
+ modelValue: p.value,
541
+ "onUpdate:modelValue": t[11] || (t[11] = (o) => p.value = o),
542
542
  size: "large",
543
543
  "text-size": "medium",
544
- label: c("Номер телефона"),
544
+ label: v("Номер телефона"),
545
545
  type: "tel",
546
546
  readonly: "",
547
547
  style: { cursor: "pointer" },
548
- error: ve.value && R.value,
549
- onBlur: a[12] || (a[12] = (t) => p.phone = !0),
550
- onInput: a[13] || (a[13] = (t) => x("phone")),
551
- onClick: be
548
+ error: ye.value && A.value,
549
+ onBlur: t[12] || (t[12] = (o) => i.phone = !0),
550
+ onInput: t[13] || (t[13] = (o) => z("phone")),
551
+ onClick: Ne
552
552
  }, null, 8, ["modelValue", "label", "error"]),
553
- g(m(z), { class: "icon-locked" })
553
+ h(f(R), { class: "icon-locked" })
554
554
  ])) : C("", !0),
555
- Y("div", ca, [
556
- he.value ? (y(), I(m(de), {
555
+ Y("div", vt, [
556
+ we.value ? (w(), I(f(de), {
557
557
  key: 0,
558
558
  color: "secondary",
559
- onClick: Oe
559
+ onClick: ze
560
560
  }, {
561
- default: F(() => [
562
- _(D(c("Сменить пароль")), 1)
561
+ default: x(() => [
562
+ X($(v("Сменить пароль")), 1)
563
563
  ]),
564
564
  _: 1
565
565
  })) : C("", !0),
566
- g(m(de), {
566
+ h(f(de), {
567
567
  disabled: !ie.value,
568
- onClick: $e
568
+ onClick: Me
569
569
  }, {
570
- default: F(() => [
571
- _(D(c("Сохранить")), 1)
570
+ default: x(() => [
571
+ X($(v("Сохранить")), 1)
572
572
  ]),
573
573
  _: 1
574
574
  }, 8, ["disabled"])
575
575
  ])
576
576
  ]),
577
- N.value ? (y(), I(ue, {
577
+ b.value ? (w(), I(ue, {
578
578
  key: 0,
579
579
  to: "body"
580
580
  }, [
581
- N.value ? (y(), k("div", fa, [
582
- g(m(We), {
581
+ b.value ? (w(), k("div", ht, [
582
+ h(f(Xe), {
583
583
  "circle-mode": !0,
584
- "model-value": o.imageContent,
584
+ "model-value": r.imageContent,
585
585
  onClose: Fe,
586
- onSave: a[14] || (a[14] = (t) => De(t)),
587
- "onUpdate:modelValue": a[15] || (a[15] = (t) => Ie(t))
586
+ onSave: t[14] || (t[14] = (o) => Ve(o)),
587
+ "onUpdate:modelValue": t[15] || (t[15] = (o) => Se(o))
588
588
  }, null, 8, ["model-value"])
589
589
  ])) : C("", !0)
590
590
  ])) : C("", !0),
591
- (y(), I(ue, { to: "#toast-root" }, [
592
- Y("div", ga, [
593
- g(je, { name: "list" }, {
594
- default: F(() => [
595
- Je(g(m(Ke), {
591
+ (w(), I(ue, { to: "#toast-root" }, [
592
+ Y("div", yt, [
593
+ h(je, { name: "list" }, {
594
+ default: x(() => [
595
+ Je(h(f(Ke), {
596
596
  class: "toast",
597
- color: ee.value,
598
- text: ae.value,
599
- onClose: a[16] || (a[16] = (t) => S.value = !1)
597
+ color: V.value,
598
+ text: te.value,
599
+ onClose: t[16] || (t[16] = (o) => D.value = !1)
600
600
  }, null, 8, ["color", "text"]), [
601
- [qe, S.value]
601
+ [qe, D.value]
602
602
  ])
603
603
  ]),
604
604
  _: 1
605
605
  })
606
606
  ])
607
607
  ])),
608
- g(m(pe))
608
+ h(f(pe))
609
609
  ], 64));
610
610
  }
611
- }), ha = (i, r) => {
612
- const n = i.__vccOpts || i;
613
- for (const [s, v] of r)
614
- n[s] = v;
615
- return n;
616
- }, wa = /* @__PURE__ */ ha(va, [["__scopeId", "data-v-a56fcdbb"]]), Ca = /* @__PURE__ */ H({
611
+ }), fe = (n, s) => {
612
+ const a = n.__vccOpts || n;
613
+ for (const [l, g] of s)
614
+ a[l] = g;
615
+ return a;
616
+ }, bt = /* @__PURE__ */ fe(wt, [["__scopeId", "data-v-a56fcdbb"]]), Lt = /* @__PURE__ */ j({
617
617
  __name: "index",
618
618
  props: {
619
619
  throttlerPrefix: {},
@@ -627,43 +627,142 @@ const na = {
627
627
  disableAddPhone: { type: Boolean }
628
628
  },
629
629
  emits: ["on-update-jwt", "update-tokens"],
630
- setup(i, { emit: r }) {
631
- const n = r, { openDialog: s } = X(), v = (l, p) => {
632
- s("email", { initialEmail: l, mode: p });
633
- }, c = (l, p) => {
634
- s("phone", { initialPhone: l, mode: p });
635
- }, U = () => {
636
- s("password");
637
- }, u = (l, p, h) => {
638
- n("on-update-jwt", l, p, h);
630
+ setup(n, { emit: s }) {
631
+ const a = s, { openDialog: l } = ee(), g = (c, i) => {
632
+ l("email", { initialEmail: c, mode: i });
633
+ }, v = (c, i) => {
634
+ l("phone", { initialPhone: c, mode: i });
635
+ }, T = () => {
636
+ l("password");
637
+ }, d = (c, i, m) => {
638
+ a("on-update-jwt", c, i, m);
639
639
  };
640
- return (l, p) => (y(), k(me, null, [
641
- g(m(Ze)),
642
- g(wa, {
643
- "throttler-prefix": l.throttlerPrefix,
644
- provider: l.provider,
645
- "request-url": l.requestUrl,
646
- language: l.language,
647
- fields: l.fields,
648
- "access-token": l.accessToken,
649
- "refresh-token": l.refreshToken,
650
- "aws-storage-url": l.awsStorageUrl,
651
- "disable-add-phone": l.disableAddPhone,
652
- onOpenEmailDialog: v,
653
- onOpenPhoneDialog: c,
654
- onOpenPasswordDialog: U,
655
- onOnUpdateJwt: u
640
+ return (c, i) => (w(), k(ce, null, [
641
+ h(f(Ze)),
642
+ h(bt, {
643
+ "throttler-prefix": c.throttlerPrefix,
644
+ provider: c.provider,
645
+ "request-url": c.requestUrl,
646
+ language: c.language,
647
+ fields: c.fields,
648
+ "access-token": c.accessToken,
649
+ "refresh-token": c.refreshToken,
650
+ "aws-storage-url": c.awsStorageUrl,
651
+ "disable-add-phone": c.disableAddPhone,
652
+ onOpenEmailDialog: g,
653
+ onOpenPhoneDialog: v,
654
+ onOpenPasswordDialog: T,
655
+ onOnUpdateJwt: d
656
656
  }, null, 8, ["throttler-prefix", "provider", "request-url", "language", "fields", "access-token", "refresh-token", "aws-storage-url", "disable-add-phone"]),
657
- g(m(pe))
657
+ h(f(pe))
658
658
  ], 64));
659
659
  }
660
- });
660
+ }), Et = 10, Pt = 15;
661
+ function Nt(n, s) {
662
+ let a = n.replace(/[^\d+]/g, "");
663
+ return s && a && !a.startsWith("+") && (a = `+${a}`), a.startsWith("+") ? `+${a.slice(1).replace(/\D/g, "")}` : a;
664
+ }
665
+ function Ct(n, s) {
666
+ return n.startsWith("+") ? `+${n.slice(1).slice(0, s)}` : n;
667
+ }
668
+ function kt(n, s = Et, a = Pt) {
669
+ if (!n.startsWith("+"))
670
+ return !1;
671
+ const l = n.slice(1);
672
+ return !(!/^\d+$/.test(l) || l.length < s || l.length > a);
673
+ }
674
+ function Tt(n) {
675
+ return /[^\d+]/.test(n);
676
+ }
677
+ const Ut = /^[\w.%+-]+@[a-z0-9.-]+\.[a-z]{2,}$/i;
678
+ function Bt(n) {
679
+ return Ut.test(n);
680
+ }
681
+ function Dt(n, s) {
682
+ var a, l;
683
+ return n.startsWith("+") || /^\d+$/.test(n) ? (a = s.phone) != null && a.enabled ? "phone" : null : n.includes("@") && (l = s.email) != null && l.enabled ? "email" : null;
684
+ }
685
+ const It = { class: "smart-input" }, At = /* @__PURE__ */ j({
686
+ __name: "index",
687
+ props: {
688
+ modelValue: {},
689
+ disabled: { type: Boolean },
690
+ config: {}
691
+ },
692
+ emits: ["update:modelValue", "validity-change", "type-change"],
693
+ setup(n, { emit: s }) {
694
+ const a = n, l = s, g = U(() => {
695
+ var i, m, u, p, b, r, B, D, A, F, V;
696
+ return {
697
+ mode: ((i = a.config) == null ? void 0 : i.mode) ?? "auto",
698
+ phone: {
699
+ enabled: ((u = (m = a.config) == null ? void 0 : m.phone) == null ? void 0 : u.enabled) ?? !0,
700
+ minDigits: ((b = (p = a.config) == null ? void 0 : p.phone) == null ? void 0 : b.minDigits) ?? 10,
701
+ maxDigits: ((B = (r = a.config) == null ? void 0 : r.phone) == null ? void 0 : B.maxDigits) ?? 15,
702
+ autoPlus: ((A = (D = a.config) == null ? void 0 : D.phone) == null ? void 0 : A.autoPlus) ?? !0
703
+ },
704
+ email: {
705
+ enabled: ((V = (F = a.config) == null ? void 0 : F.email) == null ? void 0 : V.enabled) ?? !0
706
+ }
707
+ };
708
+ }), v = y(a.modelValue ?? ""), T = y(null), d = y("");
709
+ me(
710
+ () => a.modelValue,
711
+ (i) => {
712
+ i !== void 0 && (v.value = i);
713
+ }
714
+ );
715
+ function c(i) {
716
+ let m = i;
717
+ d.value = "";
718
+ const u = g.value.mode === "auto" ? Dt(i, g.value) : g.value.mode;
719
+ if (T.value = u, l("type-change", u), u === "phone") {
720
+ Tt(i) && (d.value = "Допустимы только цифры и знак + в начале"), m = Nt(
721
+ i,
722
+ g.value.phone.autoPlus
723
+ ), m = Ct(
724
+ m,
725
+ g.value.phone.maxDigits
726
+ );
727
+ const p = kt(
728
+ m,
729
+ g.value.phone.minDigits,
730
+ g.value.phone.maxDigits
731
+ );
732
+ l("validity-change", p), !p && !d.value && (d.value = "Это не похоже на номер телефона");
733
+ }
734
+ if (u === "email") {
735
+ const p = Bt(m);
736
+ l("validity-change", p), p || (d.value = "Это не похоже на email");
737
+ }
738
+ v.value = m, l("update:modelValue", m);
739
+ }
740
+ return (i, m) => (w(), k("div", It, [
741
+ h(f(L), {
742
+ "model-value": v.value,
743
+ readonly: i.disabled,
744
+ error: d.value,
745
+ label: "Email или телефон",
746
+ onInput: m[0] || (m[0] = (u) => c(u.target.value))
747
+ }, null, 8, ["model-value", "readonly", "error"]),
748
+ T.value === "phone" ? (w(), I(f(He), {
749
+ key: 0,
750
+ class: "smart-input__icon"
751
+ })) : C("", !0),
752
+ T.value === "email" ? (w(), I(f(Qe), {
753
+ key: 1,
754
+ class: "smart-input__icon"
755
+ })) : C("", !0)
756
+ ]));
757
+ }
758
+ }), Mt = /* @__PURE__ */ fe(At, [["__scopeId", "data-v-fb092119"]]);
661
759
  export {
662
- Pa as B,
663
- Na as C,
664
- ha as _,
665
- Ca as a,
666
- aa as g,
667
- Z as p,
668
- na as t
760
+ $t as B,
761
+ xt as C,
762
+ fe as _,
763
+ Lt as a,
764
+ nt as g,
765
+ Mt as i,
766
+ H as p,
767
+ st as t
669
768
  };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".avatar-input[data-v-a56fcdbb] .p-input-file .overlay{visibility:hidden}.avatar-input[data-v-a56fcdbb] .p-input-file:hover .overlay{visibility:visible}.icon-locked{pointer-events:auto;position:absolute;right:1rem;top:1rem;color:#b6c7d6}.input-wrapper{position:relative;width:100%}.dialogTitle{z-index:10;width:100%;font-size:16px;font-weight:600;line-height:24px;text-align:center;color:#2b3238}.dialogDefaultContainer{display:flex;align-items:flex-start;flex-direction:column;width:100%;gap:32px;margin-top:16px;padding:10px 16px}.dialogDefaultContainerTextHint{font-weight:400;font-size:14px;line-height:20px;text-align:center;color:#1b1b1b}.dialogDefaultContainerRateLimitText{font-weight:600;font-size:14px;line-height:20px;color:#d0dbe4}.dialogDefaultContainerInsideContent{width:100%;display:flex;flex-direction:column;gap:24px}.dialogDefaultContainerRateLimitTextActive{color:#1c7ef1;cursor:pointer}.dialogDefaultContainerSendCodeBySmsText{color:#1c7ef1;cursor:pointer;font-size:14px;font-weight:600;display:flex;align-items:center;text-align:center}.chip{display:flex;align-items:center;justify-content:center;flex-direction:row;gap:4px;height:24px;font-size:12px;font-weight:600;color:#1b1b1b;padding:4px;line-height:16px;background-color:#b6d7ff4d;border-radius:4px;text-align:center;margin-left:5px}.cross{cursor:pointer;text-align:end}.finalLimitWrapper{display:flex;flex-direction:column;align-items:center;padding:12px 0;gap:12px;width:fit-content;min-height:94px;background:#e4606026;border-radius:8px}.finalLimitText{text-align:center;max-width:100%;word-wrap:break-word;font-family:Inter,sans-serif;font-size:14px;line-height:20px;color:#5d7285}.finalLimitLink{font-family:Inter,sans-serif;font-weight:600;font-size:14px;line-height:20px;color:#1c7ef1;text-align:center;cursor:pointer;text-decoration:none}.finalLimitLink:hover{text-decoration:underline}.toastWrapper{position:fixed;bottom:1rem;right:1rem;z-index:9999}.toast{width:100%}.base-container{margin-top:1.5rem;display:flex;flex-direction:column;gap:1.25rem;width:490px;height:428px}.icon-disabled{pointer-events:none;position:absolute;right:1rem;top:1rem;color:#b6c7d6}.centered-overlay{position:absolute;left:50%;top:50%;z-index:1000;height:100%;width:100%;transform:translate(-50%,-50%)}.buttons-container{display:flex;flex-wrap:wrap;gap:12px;justify-content:flex-start}.buttons-container PButton{flex:1 1 100%}._loaderOverlay_cpu73_1[data-v-9e697525]{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;background:#ffffffb3;border-radius:16px;z-index:99}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { a as o } from "./index-dOnVTlJF.js";
1
+ (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode(".avatar-input[data-v-a56fcdbb] .p-input-file .overlay{visibility:hidden}.avatar-input[data-v-a56fcdbb] .p-input-file:hover .overlay{visibility:visible}.smart-input[data-v-fb092119]{position:relative;width:100%}.smart-input__icon[data-v-fb092119]{position:absolute;top:16px;right:16px;pointer-events:none;opacity:.5}.icon-locked{pointer-events:auto;position:absolute;right:1rem;top:1rem;color:#b6c7d6}.input-wrapper{position:relative;width:100%}.dialogTitle{z-index:10;width:100%;font-size:16px;font-weight:600;line-height:24px;text-align:center;color:#2b3238}.dialogDefaultContainer{display:flex;align-items:flex-start;flex-direction:column;width:100%;gap:32px;margin-top:16px;padding:10px 16px}.dialogDefaultContainerTextHint{font-weight:400;font-size:14px;line-height:20px;text-align:center;color:#1b1b1b}.dialogDefaultContainerRateLimitText{font-weight:600;font-size:14px;line-height:20px;color:#d0dbe4}.dialogDefaultContainerInsideContent{width:100%;display:flex;flex-direction:column;gap:24px}.dialogDefaultContainerRateLimitTextActive{color:#1c7ef1;cursor:pointer}.dialogDefaultContainerSendCodeBySmsText{color:#1c7ef1;cursor:pointer;font-size:14px;font-weight:600;display:flex;align-items:center;text-align:center}.chip{display:flex;align-items:center;justify-content:center;flex-direction:row;gap:4px;height:24px;font-size:12px;font-weight:600;color:#1b1b1b;padding:4px;line-height:16px;background-color:#b6d7ff4d;border-radius:4px;text-align:center;margin-left:5px}.cross{cursor:pointer;text-align:end}.finalLimitWrapper{display:flex;flex-direction:column;align-items:center;padding:12px 0;gap:12px;width:100%;min-height:94px;background:#e4606026;border-radius:8px}.finalLimitText{text-align:center;max-width:100%;word-wrap:break-word;font-family:Inter,sans-serif;font-size:14px;line-height:20px;color:#5d7285}.finalLimitLink{font-family:Inter,sans-serif;font-weight:600;font-size:14px;line-height:20px;color:#1c7ef1;text-align:center;cursor:pointer;text-decoration:none}.finalLimitLink:hover{text-decoration:underline}.toastWrapper{position:fixed;bottom:1rem;right:1rem;z-index:9999}.toast{width:100%}.base-container{margin-top:1.5rem;display:flex;flex-direction:column;gap:1.25rem;width:490px;height:428px}.icon-disabled{pointer-events:none;position:absolute;right:1rem;top:1rem;color:#b6c7d6}.centered-overlay{position:absolute;left:50%;top:50%;z-index:1000;height:100%;width:100%;transform:translate(-50%,-50%)}.buttons-container{display:flex;flex-wrap:wrap;gap:12px;justify-content:flex-start}.buttons-container PButton{flex:1 1 100%}._loaderOverlay_cpu73_1[data-v-9e697525]{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;background:#ffffffb3;border-radius:16px;z-index:99}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import { a as o, i as r } from "./index-BCa-BxGo.js";
3
3
  export {
4
- o as PEditUserContact
4
+ o as PEditUserContact,
5
+ r as PEmailOrPhoneInput
5
6
  };
@@ -1,6 +1,6 @@
1
1
  import { ref as n, defineComponent as L, createElementBlock as p, openBlock as v, normalizeClass as c, createVNode as w, unref as _, computed as T, renderSlot as d, createCommentVNode as h, createElementVNode as i, toDisplayString as y, createTextVNode as f } from "vue";
2
2
  import { PLoader as $ } from "@profeat/ui-kit";
3
- import { _ as b, g as C, p as R } from "./index-dOnVTlJF.js";
3
+ import { _ as b, g as C, p as R } from "./index-BCa-BxGo.js";
4
4
  function g(s) {
5
5
  const e = Math.floor(s / 60), a = s % 60;
6
6
  return `${String(e).padStart(2, "0")}:${String(a).padStart(2, "0")}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yourgoods/ui-smart",
3
- "version": "0.52.0",
3
+ "version": "0.53.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",