@yourgoods/ui-smart 0.1.1 → 0.2.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,29 +1,29 @@
1
- import { defineComponent as Pe, ref as r, reactive as N, computed as u, watch as X, onMounted as ye, createElementBlock as _, openBlock as C, Fragment as Ce, createVNode as n, unref as o, withCtx as P, createCommentVNode as Y, createElementVNode as l, toDisplayString as g, createBlock as S, resolveDynamicComponent as B, createTextVNode as R } from "vue";
2
- import { C as V, p as E, g as ge } from "./index-DtHlzO1x.js";
1
+ import { defineComponent as Pe, ref as r, reactive as N, computed as u, watch as X, onMounted as ye, createElementBlock as _, openBlock as g, Fragment as Ce, createVNode as n, unref as o, withCtx as P, createCommentVNode as Y, createElementVNode as l, toDisplayString as V, createBlock as S, resolveDynamicComponent as B, createTextVNode as R } from "vue";
2
+ import { C as b, p as E, g as ge } from "./index-D9_chX1D.js";
3
3
  import { PDialog as Ve, PInput as $, IconEyeMd as z, IconEyeClosedMd as M, PButton as O, PTopBar as be, IconCrossMd as Ie, PTeleportContainer as Te } from "@profeat/ui-kit";
4
- function xe(b) {
4
+ function xe(I) {
5
5
  return { showPasswordRateLimitToast: (y) => {
6
6
  if (!y) return;
7
- const { attemptsLeft: a, retryAfterSec: I } = y;
7
+ const { attemptsLeft: a, retryAfterSec: C } = y;
8
8
  if (a === 2) {
9
- b("on-toast", {
9
+ I("on-toast", {
10
10
  color: "error",
11
11
  text: "Осталось 2 попытки. Ввод пароля будет заблокирован на 5 минут."
12
12
  });
13
13
  return;
14
14
  }
15
15
  if (a === 1) {
16
- b("on-toast", {
16
+ I("on-toast", {
17
17
  color: "error",
18
18
  text: "Осталась 1 попытка. После исчерпания лимита ввод пароля будет заблокирован на 1 час."
19
19
  });
20
20
  return;
21
21
  }
22
22
  if (a === 0) {
23
- const p = I && I > 0 ? I : 3600;
24
- b("on-toast", {
23
+ const v = C && C > 0 ? C : 3600;
24
+ I("on-toast", {
25
25
  color: "error",
26
- text: `Достигнут лимит попыток ввода пароля. Попробуйте снова через ${Math.ceil(p / 60)} минут.`
26
+ text: `Достигнут лимит попыток ввода пароля. Попробуйте снова через ${Math.ceil(v / 60)} минут.`
27
27
  });
28
28
  return;
29
29
  }
@@ -44,32 +44,32 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
44
44
  oldPassword: { default: "" }
45
45
  },
46
46
  emits: ["update:modelValue", "submit", "edit", "close", "on-update-jwt", "on-password-error", "on-password-success", "on-toast"],
47
- setup(b, { emit: U }) {
48
- const y = b, a = U, I = r(!0), p = r(y.modelValue), v = N({ oldPassword: y.oldPassword ?? "" }), d = r(""), f = r(""), F = N({ oldPassword: !1 }), w = N({ newPassword: !1, newPasswordConfirm: !1 }), i = r(V.OLD), m = r(null), H = r(!1), { showPasswordRateLimitToast: ee } = xe(a), x = r(!1), se = u(() => x.value ? "text" : "password"), te = () => x.value = !x.value, k = r(!1), D = r(!1), oe = u(() => k.value ? "text" : "password"), ae = u(() => D.value ? "text" : "password"), re = () => {
47
+ setup(I, { emit: U }) {
48
+ const y = I, a = U, C = r(!0), v = r(y.modelValue), p = N({ oldPassword: y.oldPassword ?? "" }), d = r(""), f = r(""), F = N({ oldPassword: !1 }), w = N({ newPassword: !1, newPasswordConfirm: !1 }), i = r(b.OLD), m = r(null), H = r(!1), { showPasswordRateLimitToast: ee } = xe(a), x = r(!1), se = u(() => x.value ? "text" : "password"), te = () => x.value = !x.value, k = r(!1), D = r(!1), oe = u(() => k.value ? "text" : "password"), ae = u(() => D.value ? "text" : "password"), re = () => {
49
49
  k.value = !k.value;
50
50
  }, le = () => {
51
51
  D.value = !D.value;
52
- }, T = r(!1), ne = u(() => T.value ? "Неверный текущий пароль" : F.oldPassword && !v.oldPassword.trim() ? "Введите пароль" : ""), de = u(() => !v.oldPassword.trim()), ie = u(() => H.value || !d.value.trim() || !f.value.trim() ? !0 : q.value);
52
+ }, T = r(!1), ne = u(() => T.value ? "Неверный текущий пароль" : F.oldPassword && !p.oldPassword.trim() ? "Введите пароль" : ""), de = u(() => !p.oldPassword.trim()), ie = u(() => H.value || !d.value.trim() || !f.value.trim() ? !0 : q.value);
53
53
  X(
54
54
  () => y.modelValue,
55
- (t) => p.value = t
56
- ), X(p, (t) => a("update:modelValue", t));
55
+ (t) => v.value = t
56
+ ), X(v, (t) => a("update:modelValue", t));
57
57
  const ue = async (t = "email") => {
58
58
  var s;
59
59
  const e = await ge("/users/profile/session/get-edit-session", { params: { field: t } });
60
60
  return ((s = e.data) == null ? void 0 : s.data) ?? e.data;
61
61
  }, h = async (t = "email") => {
62
62
  var s;
63
- const e = await E("/users/profile/session/create-if-not-exists", { field: t, oldValue: v.oldPassword });
63
+ const e = await E("/users/profile/session/create-if-not-exists", { field: t, oldValue: p.oldPassword });
64
64
  return ((s = e.data) == null ? void 0 : s.data) ?? e.data;
65
65
  }, we = async () => {
66
66
  var c, J, K, Q;
67
67
  if (!m.value) throw new Error("Нет sessionId");
68
- const t = await E("/users/profile/password/match", { sessionId: m.value, password: v.oldPassword }), e = ((c = t.data) == null ? void 0 : c.data) ?? t.data, s = ((K = (J = t.data) == null ? void 0 : J.data) == null ? void 0 : K.passwordRateLimit) ?? ((Q = t.data) == null ? void 0 : Q.passwordRateLimit);
68
+ const t = await E("/users/profile/password/match", { sessionId: m.value, password: p.oldPassword }), e = ((c = t.data) == null ? void 0 : c.data) ?? t.data, s = ((K = (J = t.data) == null ? void 0 : J.data) == null ? void 0 : K.passwordRateLimit) ?? ((Q = t.data) == null ? void 0 : Q.passwordRateLimit);
69
69
  return ee(s), { success: (e == null ? void 0 : e.success) ?? !1, message: (e == null ? void 0 : e.message) ?? "" };
70
70
  }, ce = async () => {
71
71
  await E("/users/profile/password/init", { never_: "never" });
72
- }, pe = async () => {
72
+ }, ve = async () => {
73
73
  await E("/users/profile/password/update", {
74
74
  sessionId: m.value,
75
75
  newPassword: d.value.trim(),
@@ -87,14 +87,14 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
87
87
  m.value = s.sessionId, i.value = s.step;
88
88
  }
89
89
  }, L = () => {
90
- a("close"), p.value = !1;
90
+ a("close"), v.value = !1;
91
91
  }, A = (t) => {
92
92
  F[t] = !0, T.value = !1;
93
- }, ve = async () => {
93
+ }, pe = async () => {
94
94
  var t, e;
95
95
  T.value = !1;
96
96
  try {
97
- if (await j("password"), i.value !== V.OLD) return;
97
+ if (await j("password"), i.value !== b.OLD) return;
98
98
  const { success: s } = await we();
99
99
  if (!s) {
100
100
  T.value = !0;
@@ -112,23 +112,24 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
112
112
  }, fe = async () => {
113
113
  if (!q.value)
114
114
  try {
115
- await pe(), i.value = V.COMPLETED, a("on-update-jwt", "password", "edit", d.value), a("on-toast", { color: "success", text: "Пароль изменён" }), a("close");
115
+ await ve(), i.value = b.COMPLETED, a("on-update-jwt", "password", "edit", d.value), a("on-toast", { color: "success", text: "Пароль изменён" }), a("close");
116
116
  } catch {
117
117
  }
118
118
  }, me = async () => {
119
- d.value = "", f.value = "", w.newPassword = !1, w.newPasswordConfirm = !1, i.value = V.OLD, v.oldPassword = "", a("close");
119
+ d.value = "", f.value = "", w.newPassword = !1, w.newPasswordConfirm = !1, i.value = b.OLD, p.oldPassword = "", a("close");
120
120
  }, G = u(() => w.newPassword ? d.value.trim() ? d.value.trim().length < Z ? `Пароль слишком короткий. Введите хотя бы ${Z} символов` : "" : "Введите пароль" : ""), W = u(() => w.newPasswordConfirm ? f.value.trim() ? f.value !== d.value ? "Пароли не совпадают" : "" : "Повторите пароль" : ""), q = u(() => !!G.value || !!W.value);
121
121
  return ye(async () => {
122
+ C.value = !0;
122
123
  try {
123
124
  await ce(), await j("password");
124
125
  } finally {
125
- I.value = !1;
126
+ C.value = !1;
126
127
  }
127
- }), (t, e) => (C(), _(Ce, null, [
128
+ }), (t, e) => (g(), _(Ce, null, [
128
129
  n(o(Ve), {
129
- modelValue: p.value,
130
+ modelValue: v.value,
130
131
  "onUpdate:modelValue": [
131
- e[9] || (e[9] = (s) => p.value = s),
132
+ e[9] || (e[9] = (s) => v.value = s),
132
133
  L
133
134
  ],
134
135
  width: "small",
@@ -145,7 +146,7 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
145
146
  "no-padding": !1
146
147
  }, {
147
148
  title: P(() => [
148
- l("span", De, g(t.title), 1)
149
+ l("span", De, V(t.title), 1)
149
150
  ]),
150
151
  "right-button": P(() => [
151
152
  n(o(Ie), {
@@ -158,13 +159,13 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
158
159
  ])
159
160
  ]),
160
161
  default: P(() => [
161
- i.value === o(V).OLD ? (C(), _("div", Ee, [
162
+ i.value === o(b).OLD ? (g(), _("div", Ee, [
162
163
  l("div", he, [
163
- l("div", Le, g(t.hintText), 1),
164
+ l("div", Le, V(t.hintText), 1),
164
165
  l("div", Ne, [
165
166
  n(o($), {
166
- modelValue: v.oldPassword,
167
- "onUpdate:modelValue": e[0] || (e[0] = (s) => v.oldPassword = s),
167
+ modelValue: p.oldPassword,
168
+ "onUpdate:modelValue": e[0] || (e[0] = (s) => p.oldPassword = s),
168
169
  size: "large",
169
170
  "text-size": "medium",
170
171
  label: "Текущий пароль",
@@ -173,7 +174,7 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
173
174
  onBlur: e[1] || (e[1] = (s) => A("oldPassword")),
174
175
  onInput: e[2] || (e[2] = (s) => A("oldPassword"))
175
176
  }, null, 8, ["modelValue", "type", "error"]),
176
- (C(), S(B(x.value ? o(z) : o(M)), {
177
+ (g(), S(B(x.value ? o(z) : o(M)), {
177
178
  class: "icon-locked",
178
179
  onClick: te
179
180
  }))
@@ -181,19 +182,19 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
181
182
  n(o(O), {
182
183
  style: { width: "100%" },
183
184
  disabled: de.value,
184
- onClick: ve
185
+ onClick: pe
185
186
  }, {
186
187
  default: P(() => e[10] || (e[10] = [
187
- R(g("Продолжить"))
188
+ R(V("Продолжить"))
188
189
  ])),
189
190
  _: 1,
190
191
  __: [10]
191
192
  }, 8, ["disabled"])
192
193
  ])
193
194
  ])) : Y("", !0),
194
- i.value === o(V).NEW ? (C(), _("div", _e, [
195
+ i.value === o(b).NEW ? (g(), _("div", _e, [
195
196
  l("div", Se, [
196
- e[14] || (e[14] = l("div", { class: "dialogDefaultContainerTextHint" }, g("Установите новый пароль для защиты аккаунта. Пароль должен содержать не менее 8 символов."), -1)),
197
+ e[14] || (e[14] = l("div", { class: "dialogDefaultContainerTextHint" }, V("Установите новый пароль для защиты аккаунта. Пароль должен содержать не менее 8 символов."), -1)),
197
198
  l("div", Be, [
198
199
  n(o($), {
199
200
  modelValue: d.value,
@@ -206,7 +207,7 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
206
207
  onBlur: e[4] || (e[4] = (s) => w.newPassword = !0),
207
208
  onInput: e[5] || (e[5] = (s) => w.newPassword = !0)
208
209
  }, null, 8, ["modelValue", "type", "error"]),
209
- (C(), S(B(k.value ? o(z) : o(M)), {
210
+ (g(), S(B(k.value ? o(z) : o(M)), {
210
211
  class: "icon-locked",
211
212
  onClick: re
212
213
  }))
@@ -223,7 +224,7 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
223
224
  onBlur: e[7] || (e[7] = (s) => w.newPasswordConfirm = !0),
224
225
  onInput: e[8] || (e[8] = (s) => w.newPasswordConfirm = !0)
225
226
  }, null, 8, ["modelValue", "type", "error"]),
226
- (C(), S(B(D.value ? o(z) : o(M)), {
227
+ (g(), S(B(D.value ? o(z) : o(M)), {
227
228
  class: "icon-locked",
228
229
  onClick: le
229
230
  }))
@@ -236,7 +237,7 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
236
237
  onClick: me
237
238
  }, {
238
239
  default: P(() => e[11] || (e[11] = [
239
- R(g("Отмена"))
240
+ R(V("Отмена"))
240
241
  ])),
241
242
  _: 1,
242
243
  __: [11]
@@ -248,7 +249,7 @@ const ke = { class: "text-center w-full" }, De = { class: "dialogTitle" }, Ee =
248
249
  onClick: fe
249
250
  }, {
250
251
  default: P(() => e[12] || (e[12] = [
251
- R(g("Сохранить"))
252
+ R(V("Сохранить"))
252
253
  ])),
253
254
  _: 1,
254
255
  __: [12]