@webx-ui/module-auth 0.4.1 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { inject as We, defineComponent as I, computed as B, ref as w, useTemplateRef as le, onBeforeUnmount as ze, resolveComponent as W, openBlock as k, createBlock as S, withCtx as l, createVNode as n, withModifiers as ae, createCommentVNode as P, createElementVNode as O, createTextVNode as L, toDisplayString as V, watch as oe, unref as e, isRef as pe, createElementBlock as K, resolveDynamicComponent as Be, createSlots as ne, Fragment as te, renderList as fe, h as he } from "vue";
2
- import { useTranslate as R, HttpError as Fe, useAdmin as q, useI18n as be } from "@webx-ui/module-admin";
3
- import { useModal as ye, WxDialog as we, WxFormItem as D, WxInput as Z, WxSelect as H, WxSpace as E, WxCheckbox as de, WxText as Y, WxButton as j, toast as G, WxTable as Te, WxActions as ce, WxAction as me, WxBadge as ee, WxAvatar as Me, createModal as ge, WxCard as Pe, confirm as Ne } from "@webx-ui/core";
4
- const _e = /* @__PURE__ */ Symbol("webx-auth");
5
- function xe() {
6
- const a = We(_e, null);
1
+ import { inject as pe, defineComponent as R, computed as B, ref as b, useTemplateRef as oe, onBeforeUnmount as Fe, resolveComponent as F, openBlock as k, createBlock as S, withCtx as l, createVNode as o, withModifiers as te, createCommentVNode as P, createElementVNode as O, createTextVNode as L, toDisplayString as C, watch as J, unref as e, isRef as fe, createElementBlock as K, resolveDynamicComponent as Be, createSlots as ne, Fragment as le, renderList as he, h as be } from "vue";
2
+ import { useTranslate as I, HttpError as Te, useAdmin as q, useI18n as ye } from "@webx-ui/module-admin";
3
+ import { useModal as we, WxDialog as ge, WxFormItem as D, WxInput as ee, WxSelect as H, WxSpace as E, WxCheckbox as de, WxText as Y, WxButton as j, toast as G, WxTable as Me, WxActions as ce, WxAction as me, WxBadge as ae, WxAvatar as Pe, createModal as _e, WxCard as Ne, confirm as Oe } from "@webx-ui/core";
4
+ const xe = /* @__PURE__ */ Symbol("webx-auth");
5
+ function ke() {
6
+ const a = pe(xe, null);
7
7
  if (a === null)
8
8
  throw new Error("useAuth() was called outside a panel that installed the auth plugin.");
9
9
  return a;
10
10
  }
11
- function Oe(a) {
11
+ function Ee(a) {
12
12
  const i = `${a.apiPath}/auth`;
13
13
  return {
14
14
  async me() {
@@ -21,16 +21,16 @@ function Oe(a) {
21
21
  }
22
22
  },
23
23
  async login(s) {
24
- const o = await a.http.post(`${i}/login`, {
24
+ const n = await a.http.post(`${i}/login`, {
25
25
  email: s.email,
26
26
  password: s.password,
27
27
  remember: s.remember ?? !1
28
28
  });
29
- return a.setUser(o.data), await a.reload(), o.data;
29
+ return a.setUser(n.data), await a.reload(), n.data;
30
30
  },
31
31
  async setLocale(s) {
32
- const o = await a.http.put(`${i}/locale`, { locale: s });
33
- a.setUser(o.data), await a.setLocale(s);
32
+ const n = await a.http.put(`${i}/locale`, { locale: s });
33
+ a.setUser(n.data), await a.setLocale(s);
34
34
  },
35
35
  async logout() {
36
36
  try {
@@ -41,13 +41,14 @@ function Oe(a) {
41
41
  }
42
42
  };
43
43
  }
44
- function Ee(a, i) {
45
- a.provide(_e, i);
44
+ const Ve = /* @__PURE__ */ Symbol("webx-auth-avatar");
45
+ function Re(a, i, s = null) {
46
+ a.provide(xe, i), a.provide(Ve, s);
46
47
  }
47
48
  function Ie(a) {
48
49
  return typeof a == "object" && a !== null && "status" in a && a.status === 401;
49
50
  }
50
- const Re = ["title", "aria-label", "aria-pressed"], De = /* @__PURE__ */ I({
51
+ const De = ["title", "aria-label", "aria-pressed"], Ke = /* @__PURE__ */ R({
51
52
  __name: "LoginCard",
52
53
  props: {
53
54
  emailLabel: { default: void 0 },
@@ -63,169 +64,170 @@ const Re = ["title", "aria-label", "aria-pressed"], De = /* @__PURE__ */ I({
63
64
  },
64
65
  emits: ["success"],
65
66
  setup(a, { expose: i, emit: s }) {
66
- const o = a, u = s, b = xe(), h = R("webx-auth"), r = B(() => ({
67
- email: o.emailLabel ?? h("card.email"),
68
- password: o.passwordLabel ?? h("card.password"),
69
- remember: o.rememberLabel ?? h("card.remember"),
70
- submit: o.submitLabel ?? h("card.submit"),
71
- capsLock: o.capsLockWarning ?? h("card.caps-lock"),
72
- reveal: o.revealLabel ?? h("card.reveal"),
73
- hide: o.hideLabel ?? h("card.hide")
74
- })), d = w(""), A = w(""), _ = w(!1), c = w(!1), t = w(!1), U = w(!1), C = w(""), $ = w({}), z = w(0), F = le("emailField");
75
- let T = null;
76
- ze(x);
77
- const m = B(() => z.value > 0), v = B(
78
- () => o.throttleMessage === void 0 ? h("card.throttled", { seconds: z.value }) : o.throttleMessage.replace(":seconds", String(z.value))
67
+ const n = a, r = s, y = ke(), v = I("webx-auth"), u = B(() => ({
68
+ email: n.emailLabel ?? v("card.email"),
69
+ password: n.passwordLabel ?? v("card.password"),
70
+ remember: n.rememberLabel ?? v("card.remember"),
71
+ submit: n.submitLabel ?? v("card.submit"),
72
+ capsLock: n.capsLockWarning ?? v("card.caps-lock"),
73
+ reveal: n.revealLabel ?? v("card.reveal"),
74
+ hide: n.hideLabel ?? v("card.hide")
75
+ })), m = b(""), V = b(""), _ = b(!1), d = b(!1), t = b(!1), $ = b(!1), A = b(""), U = b({}), W = b(0), T = oe("emailField");
76
+ let z = null;
77
+ Fe(x);
78
+ const c = B(() => W.value > 0), p = B(
79
+ () => n.throttleMessage === void 0 ? v("card.throttled", { seconds: W.value }) : n.throttleMessage.replace(":seconds", String(W.value))
79
80
  );
80
- async function f() {
81
- if (!(c.value || m.value)) {
82
- c.value = !0, C.value = "", $.value = {};
81
+ async function h() {
82
+ if (!(d.value || c.value)) {
83
+ d.value = !0, A.value = "", U.value = {};
83
84
  try {
84
- await b.login({
85
- email: d.value,
86
- password: A.value,
85
+ await y.login({
86
+ email: m.value,
87
+ password: V.value,
87
88
  remember: _.value
88
- }), A.value = "", u("success");
89
+ }), V.value = "", r("success");
89
90
  } catch (g) {
90
- Q(g);
91
+ X(g);
91
92
  } finally {
92
- c.value = !1;
93
+ d.value = !1;
93
94
  }
94
95
  }
95
96
  }
96
- function Q(g) {
97
- if (!(g instanceof Fe)) {
98
- C.value = g instanceof Error ? g.message : String(g);
97
+ function X(g) {
98
+ if (!(g instanceof Te)) {
99
+ A.value = g instanceof Error ? g.message : String(g);
99
100
  return;
100
101
  }
101
102
  if (g.isValidation) {
102
- $.value = g.errors;
103
+ U.value = g.errors;
103
104
  return;
104
105
  }
105
106
  if (g.isThrottled) {
106
- y(g.retryAfter ?? 60);
107
+ w(g.retryAfter ?? 60);
107
108
  return;
108
109
  }
109
- C.value = g.message;
110
+ A.value = g.message;
110
111
  }
111
- function y(g) {
112
- x(), z.value = g, T = setInterval(() => {
113
- z.value -= 1, z.value <= 0 && x();
112
+ function w(g) {
113
+ x(), W.value = g, z = setInterval(() => {
114
+ W.value -= 1, W.value <= 0 && x();
114
115
  }, 1e3);
115
116
  }
116
117
  function x() {
117
- T !== null && (clearInterval(T), T = null), z.value = 0;
118
+ z !== null && (clearInterval(z), z = null), W.value = 0;
118
119
  }
119
- function p(g) {
120
- U.value = g.getModifierState("CapsLock");
120
+ function f(g) {
121
+ $.value = g.getModifierState("CapsLock");
121
122
  }
122
- return i({ focus: () => F.value?.focus() }), (g, M) => {
123
- const ie = W("wx-alert"), X = W("wx-icon"), re = W("wx-input"), ue = W("wx-form-item"), Le = W("wx-checkbox"), $e = W("wx-button"), Se = W("wx-form"), Ue = W("wx-card");
124
- return k(), S(Ue, {
123
+ return i({ focus: () => T.value?.focus() }), (g, M) => {
124
+ const ie = F("wx-alert"), Z = F("wx-icon"), re = F("wx-input"), ue = F("wx-form-item"), Se = F("wx-checkbox"), Ue = F("wx-button"), We = F("wx-form"), ze = F("wx-card");
125
+ return k(), S(ze, {
125
126
  class: "wx-login",
126
127
  padding: 24
127
128
  }, {
128
129
  default: l(() => [
129
- n(Se, {
130
- errors: $.value,
131
- disabled: c.value,
130
+ o(We, {
131
+ errors: U.value,
132
+ disabled: d.value,
132
133
  gap: "md",
133
- onSubmit: ae(f, ["prevent"])
134
+ onSubmit: te(h, ["prevent"])
134
135
  }, {
135
136
  default: l(() => [
136
- C.value !== "" ? (k(), S(ie, {
137
+ A.value !== "" ? (k(), S(ie, {
137
138
  key: 0,
138
139
  type: "danger",
139
140
  variant: "soft",
140
141
  live: "",
141
- description: C.value,
142
+ description: A.value,
142
143
  class: "wx-login__message"
143
- }, null, 8, ["description"])) : m.value ? (k(), S(ie, {
144
+ }, null, 8, ["description"])) : c.value ? (k(), S(ie, {
144
145
  key: 1,
145
146
  type: "warning",
146
147
  variant: "soft",
147
148
  live: "",
148
- description: v.value,
149
+ description: p.value,
149
150
  class: "wx-login__message"
150
151
  }, null, 8, ["description"])) : P("", !0),
151
- n(ue, { name: "email" }, {
152
+ o(ue, { name: "email" }, {
152
153
  default: l(() => [
153
- n(re, {
154
+ o(re, {
154
155
  ref_key: "emailField",
155
- ref: F,
156
- modelValue: d.value,
157
- "onUpdate:modelValue": M[0] || (M[0] = (N) => d.value = N),
156
+ ref: T,
157
+ modelValue: m.value,
158
+ "onUpdate:modelValue": M[0] || (M[0] = (N) => m.value = N),
158
159
  type: "email",
159
- placeholder: r.value.email,
160
- "aria-label": r.value.email,
160
+ placeholder: u.value.email,
161
+ "aria-label": u.value.email,
161
162
  autocomplete: "username",
162
163
  autofocus: a.autofocus,
163
164
  inputmode: "email",
164
165
  size: "lg"
165
166
  }, {
166
167
  prefix: l(() => [
167
- n(X, { name: "mail" })
168
+ o(Z, { name: "mail" })
168
169
  ]),
169
170
  _: 1
170
171
  }, 8, ["modelValue", "placeholder", "aria-label", "autofocus"])
171
172
  ]),
172
173
  _: 1
173
174
  }),
174
- n(ue, {
175
+ o(ue, {
175
176
  name: "password",
176
- help: U.value ? r.value.capsLock : void 0
177
+ help: $.value ? u.value.capsLock : void 0
177
178
  }, {
178
179
  default: l(() => [
179
- n(re, {
180
- modelValue: A.value,
181
- "onUpdate:modelValue": M[2] || (M[2] = (N) => A.value = N),
180
+ o(re, {
181
+ modelValue: V.value,
182
+ "onUpdate:modelValue": M[2] || (M[2] = (N) => V.value = N),
182
183
  type: t.value ? "text" : "password",
183
- placeholder: r.value.password,
184
- "aria-label": r.value.password,
184
+ placeholder: u.value.password,
185
+ "aria-label": u.value.password,
185
186
  autocomplete: "current-password",
186
187
  size: "lg",
187
- onKeydown: p,
188
- onKeyup: p
188
+ onKeydown: f,
189
+ onKeyup: f
189
190
  }, {
190
191
  prefix: l(() => [
191
- n(X, { name: "lock" })
192
+ o(Z, { name: "lock" })
192
193
  ]),
193
194
  suffix: l(() => [
194
195
  O("button", {
195
196
  type: "button",
196
197
  class: "wx-login__reveal",
197
- title: t.value ? r.value.hide : r.value.reveal,
198
- "aria-label": t.value ? r.value.hide : r.value.reveal,
198
+ title: t.value ? u.value.hide : u.value.reveal,
199
+ "aria-label": t.value ? u.value.hide : u.value.reveal,
199
200
  "aria-pressed": t.value,
200
201
  tabindex: "-1",
201
202
  onClick: M[1] || (M[1] = (N) => t.value = !t.value)
202
203
  }, [
203
- n(X, {
204
+ o(Z, {
204
205
  name: t.value ? "eye-off" : "eye"
205
206
  }, null, 8, ["name"])
206
- ], 8, Re)
207
+ ], 8, De)
207
208
  ]),
208
209
  _: 1
209
210
  }, 8, ["modelValue", "type", "placeholder", "aria-label"])
210
211
  ]),
211
212
  _: 1
212
213
  }, 8, ["help"]),
213
- a.remember ? (k(), S(Le, {
214
+ a.remember ? (k(), S(Se, {
214
215
  key: 2,
215
216
  modelValue: _.value,
216
217
  "onUpdate:modelValue": M[3] || (M[3] = (N) => _.value = N),
217
- label: r.value.remember
218
+ label: u.value.remember,
219
+ class: "wx-login__remember"
218
220
  }, null, 8, ["modelValue", "label"])) : P("", !0),
219
- n($e, {
221
+ o(Ue, {
220
222
  type: "primary",
221
223
  "native-type": "submit",
222
224
  size: "lg",
223
225
  block: "",
224
- loading: c.value,
225
- disabled: m.value
226
+ loading: d.value,
227
+ disabled: c.value
226
228
  }, {
227
229
  default: l(() => [
228
- L(V(r.value.submit), 1)
230
+ L(C(u.value.submit), 1)
229
231
  ]),
230
232
  _: 1
231
233
  }, 8, ["loading", "disabled"])
@@ -237,12 +239,12 @@ const Re = ["title", "aria-label", "aria-pressed"], De = /* @__PURE__ */ I({
237
239
  });
238
240
  };
239
241
  }
240
- }), ke = (a, i) => {
242
+ }), Ae = (a, i) => {
241
243
  const s = a.__vccOpts || a;
242
- for (const [o, u] of i)
243
- s[o] = u;
244
+ for (const [n, r] of i)
245
+ s[n] = r;
244
246
  return s;
245
- }, Ke = /* @__PURE__ */ ke(De, [["__scopeId", "data-v-52bafd85"]]), Ve = {
247
+ }, je = /* @__PURE__ */ Ae(Ke, [["__scopeId", "data-v-3c206e31"]]), Ce = {
246
248
  card: {
247
249
  email: "Email",
248
250
  password: "Password",
@@ -307,46 +309,46 @@ const Re = ["title", "aria-label", "aria-pressed"], De = /* @__PURE__ */ I({
307
309
  }
308
310
  };
309
311
  function se(a) {
310
- const i = `${a.apiPath}/auth`, s = (o) => o.data;
312
+ const i = `${a.apiPath}/auth`, s = (n) => n.data;
311
313
  return {
312
- list: (o = {}) => a.http.get(`${i}/admins`, {
314
+ list: (n = {}) => a.http.get(`${i}/admins`, {
313
315
  query: {
314
- q: o.q || void 0,
315
- role: o.role ?? void 0,
316
- active: o.active ?? void 0,
317
- sort: o.sort,
318
- page: o.page,
319
- per_page: o.per_page
316
+ q: n.q || void 0,
317
+ role: n.role ?? void 0,
318
+ active: n.active ?? void 0,
319
+ sort: n.sort,
320
+ page: n.page,
321
+ per_page: n.per_page
320
322
  }
321
- }).then((u) => ({ ...u.meta, data: u.data })),
322
- get: (o) => a.http.get(`${i}/admins/${o}`).then(s),
323
- create: (o) => a.http.post(`${i}/admins`, o).then(s),
324
- update: (o, u) => a.http.patch(`${i}/admins/${o}`, u).then(s),
325
- remove: (o) => a.http.delete(`${i}/admins/${o}`),
323
+ }).then((r) => ({ ...r.meta, data: r.data })),
324
+ get: (n) => a.http.get(`${i}/admins/${n}`).then(s),
325
+ create: (n) => a.http.post(`${i}/admins`, n).then(s),
326
+ update: (n, r) => a.http.patch(`${i}/admins/${n}`, r).then(s),
327
+ remove: (n) => a.http.delete(`${i}/admins/${n}`),
326
328
  roles: () => a.http.get(`${i}/roles`).then(s)
327
329
  };
328
330
  }
329
331
  const ve = /* @__PURE__ */ new WeakSet();
330
- function J() {
332
+ function Q() {
331
333
  try {
332
334
  const { i18n: a } = q();
333
- ve.has(a) || (a.defaults("webx-auth", Ve), ve.add(a));
335
+ ve.has(a) || (a.defaults("webx-auth", Ce), ve.add(a));
334
336
  } catch {
335
337
  }
336
338
  }
337
- const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He = {
339
+ const qe = { class: "wx-admin-form" }, He = { class: "wx-admin-form__grid" }, Ye = {
338
340
  key: 0,
339
341
  class: "wx-admin-form__aside"
340
- }, Ye = { class: "wx-admin-form__fields" }, Ge = /* @__PURE__ */ I({
342
+ }, Ge = { class: "wx-admin-form__fields" }, Je = /* @__PURE__ */ R({
341
343
  __name: "AdminDialog",
342
344
  props: {
343
345
  admin: { default: null },
344
346
  avatarField: { default: void 0 }
345
347
  },
346
348
  setup(a) {
347
- const i = a, { resolve: s, dismiss: o, open: u } = ye(), b = q(), h = se(b), r = be();
348
- J();
349
- const d = R("webx-auth"), A = w([]), _ = w(!1), c = w({}), t = w({
349
+ const i = a, { resolve: s, dismiss: n, open: r } = we(), y = q(), v = se(y), u = ye();
350
+ Q();
351
+ const m = I("webx-auth"), V = b([]), _ = b(!1), d = b({}), t = b({
350
352
  name: "",
351
353
  email: "",
352
354
  password: "",
@@ -355,37 +357,37 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
355
357
  is_super: !1,
356
358
  locale: null,
357
359
  roles: []
358
- }), U = B({
360
+ }), $ = B({
359
361
  get: () => t.value.avatar ? { path: t.value.avatar } : null,
360
- set: (m) => {
361
- t.value.avatar = m?.path ?? null;
362
+ set: (c) => {
363
+ t.value.avatar = c?.path ?? null;
362
364
  }
363
- }), C = B(() => i.admin !== null), $ = B(() => A.value.map((m) => ({ value: m.id, label: m.name }))), z = B(() => [
364
- { value: "auto", label: d("admins.locale-auto") },
365
- ...r.state.panelLocales.map((m) => ({ value: m.code, label: m.nativeName }))
365
+ }), A = B(() => i.admin !== null), U = B(() => V.value.map((c) => ({ value: c.id, label: c.name }))), W = B(() => [
366
+ { value: "auto", label: m("admins.locale-auto") },
367
+ ...u.state.panelLocales.map((c) => ({ value: c.code, label: c.nativeName }))
366
368
  ]);
367
- h.roles().then((m) => A.value = m), oe(
369
+ v.roles().then((c) => V.value = c), J(
368
370
  () => i.admin,
369
- (m) => {
371
+ (c) => {
370
372
  t.value = {
371
- name: m?.name ?? "",
372
- email: m?.email ?? "",
373
+ name: c?.name ?? "",
374
+ email: c?.email ?? "",
373
375
  password: "",
374
- avatar: m?.avatar ?? null,
375
- is_active: m?.is_active ?? !0,
376
- is_super: m?.is_super ?? !1,
377
- locale: m?.locale ?? "auto",
378
- roles: m?.roles.map((v) => v.id) ?? []
379
- }, c.value = {};
376
+ avatar: c?.avatar ?? null,
377
+ is_active: c?.is_active ?? !0,
378
+ is_super: c?.is_super ?? !1,
379
+ locale: c?.locale ?? "auto",
380
+ roles: c?.roles.map((p) => p.id) ?? []
381
+ }, d.value = {};
380
382
  },
381
383
  { immediate: !0 }
382
384
  );
383
- function F(m) {
384
- return c.value[m]?.[0];
385
+ function T(c) {
386
+ return d.value[c]?.[0];
385
387
  }
386
- async function T() {
387
- _.value = !0, c.value = {};
388
- const m = {
388
+ async function z() {
389
+ _.value = !0, d.value = {};
390
+ const c = {
389
391
  name: t.value.name,
390
392
  email: t.value.email,
391
393
  avatar: t.value.avatar,
@@ -394,42 +396,42 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
394
396
  locale: t.value.locale === "auto" ? null : t.value.locale,
395
397
  roles: t.value.roles ?? []
396
398
  };
397
- t.value.password && (m.password = t.value.password);
399
+ t.value.password && (c.password = t.value.password);
398
400
  try {
399
- const v = i.admin ? await h.update(i.admin.id, m) : await h.create(m);
400
- G.success(d(C.value ? "admins.updated" : "admins.created")), s(v);
401
- } catch (v) {
402
- const f = v.body;
403
- f?.errors ? c.value = f.errors : f?.message && G.danger(f.message);
401
+ const p = i.admin ? await v.update(i.admin.id, c) : await v.create(c);
402
+ G.success(m(A.value ? "admins.updated" : "admins.created")), s(p);
403
+ } catch (p) {
404
+ const h = p.body;
405
+ h?.errors ? d.value = h.errors : h?.message && G.danger(h.message);
404
406
  } finally {
405
407
  _.value = !1;
406
408
  }
407
409
  }
408
- return (m, v) => (k(), S(e(we), {
409
- open: e(u),
410
- "onUpdate:open": v[9] || (v[9] = (f) => pe(u) ? u.value = f : null),
411
- title: C.value ? e(d)("admins.edit-short") : e(d)("admins.new-short"),
410
+ return (c, p) => (k(), S(e(ge), {
411
+ open: e(r),
412
+ "onUpdate:open": p[9] || (p[9] = (h) => fe(r) ? r.value = h : null),
413
+ title: A.value ? e(m)("admins.edit-short") : e(m)("admins.new-short"),
412
414
  width: 720
413
415
  }, {
414
416
  footer: l(() => [
415
- n(e(E), { size: "sm" }, {
417
+ o(e(E), { size: "sm" }, {
416
418
  default: l(() => [
417
- n(e(j), {
419
+ o(e(j), {
418
420
  variant: "outline",
419
- onClick: v[8] || (v[8] = (f) => e(o)())
421
+ onClick: p[8] || (p[8] = (h) => e(n)())
420
422
  }, {
421
423
  default: l(() => [
422
- L(V(e(d)("admins.cancel")), 1)
424
+ L(C(e(m)("admins.cancel")), 1)
423
425
  ]),
424
426
  _: 1
425
427
  }),
426
- n(e(j), {
428
+ o(e(j), {
427
429
  type: "primary",
428
430
  loading: _.value,
429
- onClick: T
431
+ onClick: z
430
432
  }, {
431
433
  default: l(() => [
432
- L(V(e(d)("admins.save")), 1)
434
+ L(C(e(m)("admins.save")), 1)
433
435
  ]),
434
436
  _: 1
435
437
  }, 8, ["loading"])
@@ -438,39 +440,39 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
438
440
  })
439
441
  ]),
440
442
  default: l(() => [
441
- O("div", je, [
442
- O("div", qe, [
443
- a.avatarField ? (k(), K("div", He, [
443
+ O("div", qe, [
444
+ O("div", He, [
445
+ a.avatarField ? (k(), K("div", Ye, [
444
446
  (k(), S(Be(a.avatarField), {
445
- modelValue: U.value,
446
- "onUpdate:modelValue": v[0] || (v[0] = (f) => U.value = f),
447
- label: e(d)("admins.avatar"),
447
+ modelValue: $.value,
448
+ "onUpdate:modelValue": p[0] || (p[0] = (h) => $.value = h),
449
+ label: e(m)("admins.avatar"),
448
450
  aspect: "1/1",
449
451
  captions: !1
450
452
  }, null, 8, ["modelValue", "label"]))
451
453
  ])) : P("", !0),
452
- O("div", Ye, [
453
- n(e(D), {
454
- label: e(d)("admins.name"),
455
- error: F("name")
454
+ O("div", Ge, [
455
+ o(e(D), {
456
+ label: e(m)("admins.name"),
457
+ error: T("name")
456
458
  }, {
457
459
  default: l(() => [
458
- n(e(Z), {
460
+ o(e(ee), {
459
461
  modelValue: t.value.name,
460
- "onUpdate:modelValue": v[1] || (v[1] = (f) => t.value.name = f),
462
+ "onUpdate:modelValue": p[1] || (p[1] = (h) => t.value.name = h),
461
463
  name: "name"
462
464
  }, null, 8, ["modelValue"])
463
465
  ]),
464
466
  _: 1
465
467
  }, 8, ["label", "error"]),
466
- n(e(D), {
467
- label: e(d)("admins.email"),
468
- error: F("email")
468
+ o(e(D), {
469
+ label: e(m)("admins.email"),
470
+ error: T("email")
469
471
  }, {
470
472
  default: l(() => [
471
- n(e(Z), {
473
+ o(e(ee), {
472
474
  modelValue: t.value.email,
473
- "onUpdate:modelValue": v[2] || (v[2] = (f) => t.value.email = f),
475
+ "onUpdate:modelValue": p[2] || (p[2] = (h) => t.value.email = h),
474
476
  type: "email",
475
477
  name: "email",
476
478
  autocomplete: "off"
@@ -478,15 +480,15 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
478
480
  ]),
479
481
  _: 1
480
482
  }, 8, ["label", "error"]),
481
- n(e(D), {
482
- label: e(d)("admins.password"),
483
- error: F("password"),
484
- help: C.value ? e(d)("admins.password-keep") : e(d)("admins.password-hint")
483
+ o(e(D), {
484
+ label: e(m)("admins.password"),
485
+ error: T("password"),
486
+ help: A.value ? e(m)("admins.password-keep") : e(m)("admins.password-hint")
485
487
  }, {
486
488
  default: l(() => [
487
- n(e(Z), {
489
+ o(e(ee), {
488
490
  modelValue: t.value.password,
489
- "onUpdate:modelValue": v[3] || (v[3] = (f) => t.value.password = f),
491
+ "onUpdate:modelValue": p[3] || (p[3] = (h) => t.value.password = h),
490
492
  type: "password",
491
493
  name: "password",
492
494
  autocomplete: "new-password"
@@ -494,53 +496,53 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
494
496
  ]),
495
497
  _: 1
496
498
  }, 8, ["label", "error", "help"]),
497
- n(e(D), {
498
- label: e(d)("admins.roles"),
499
- error: F("roles")
499
+ o(e(D), {
500
+ label: e(m)("admins.roles"),
501
+ error: T("roles")
500
502
  }, {
501
503
  default: l(() => [
502
- n(e(H), {
504
+ o(e(H), {
503
505
  modelValue: t.value.roles,
504
- "onUpdate:modelValue": v[4] || (v[4] = (f) => t.value.roles = f),
505
- options: $.value,
506
+ "onUpdate:modelValue": p[4] || (p[4] = (h) => t.value.roles = h),
507
+ options: U.value,
506
508
  multiple: ""
507
509
  }, null, 8, ["modelValue", "options"])
508
510
  ]),
509
511
  _: 1
510
512
  }, 8, ["label", "error"]),
511
- n(e(D), {
512
- label: e(d)("admins.locale")
513
+ o(e(D), {
514
+ label: e(m)("admins.locale")
513
515
  }, {
514
516
  default: l(() => [
515
- n(e(H), {
517
+ o(e(H), {
516
518
  modelValue: t.value.locale,
517
- "onUpdate:modelValue": v[5] || (v[5] = (f) => t.value.locale = f),
518
- options: z.value
519
+ "onUpdate:modelValue": p[5] || (p[5] = (h) => t.value.locale = h),
520
+ options: W.value
519
521
  }, null, 8, ["modelValue", "options"])
520
522
  ]),
521
523
  _: 1
522
524
  }, 8, ["label"]),
523
- n(e(E), { size: "md" }, {
525
+ o(e(E), { size: "md" }, {
524
526
  default: l(() => [
525
- n(e(de), {
527
+ o(e(de), {
526
528
  modelValue: t.value.is_active,
527
- "onUpdate:modelValue": v[6] || (v[6] = (f) => t.value.is_active = f),
528
- label: e(d)("admins.active")
529
+ "onUpdate:modelValue": p[6] || (p[6] = (h) => t.value.is_active = h),
530
+ label: e(m)("admins.active")
529
531
  }, null, 8, ["modelValue", "label"]),
530
- n(e(de), {
532
+ o(e(de), {
531
533
  modelValue: t.value.is_super,
532
- "onUpdate:modelValue": v[7] || (v[7] = (f) => t.value.is_super = f),
533
- label: e(d)("admins.super")
534
+ "onUpdate:modelValue": p[7] || (p[7] = (h) => t.value.is_super = h),
535
+ label: e(m)("admins.super")
534
536
  }, null, 8, ["modelValue", "label"])
535
537
  ]),
536
538
  _: 1
537
539
  }),
538
- n(e(Y), {
540
+ o(e(Y), {
539
541
  size: "sm",
540
542
  tone: "muted"
541
543
  }, {
542
544
  default: l(() => [
543
- L(V(e(d)("admins.super-hint")), 1)
545
+ L(C(e(m)("admins.super-hint")), 1)
544
546
  ]),
545
547
  _: 1
546
548
  })
@@ -551,7 +553,7 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
551
553
  _: 1
552
554
  }, 8, ["open", "title"]));
553
555
  }
554
- }), Je = { class: "wx-admin-list" }, Ae = /* @__PURE__ */ I({
556
+ }), Qe = { class: "wx-admin-list" }, Le = /* @__PURE__ */ R({
555
557
  __name: "AdminList",
556
558
  props: {
557
559
  picking: { type: Boolean, default: !1 },
@@ -562,25 +564,25 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
562
564
  },
563
565
  emits: ["open", "chosen", "selection", "remove"],
564
566
  setup(a, { expose: i, emit: s }) {
565
- const o = a, u = s, b = q(), h = se(b);
566
- J();
567
- const r = R("webx-auth"), d = w(null), A = w([]), _ = w(!1), c = w("all"), t = w("any"), U = w([]), C = w({});
568
- let $ = { page: 1, perPage: 20, sort: null, search: "" };
569
- const z = B(() => [
570
- { value: "all", label: r("admins.all-roles") },
571
- ...A.value.map((y) => ({ value: y.slug, label: y.name }))
572
- ]), F = B(() => [
573
- { value: "any", label: r("admins.any-state") },
574
- { value: "yes", label: r("admins.only-active") },
575
- { value: "no", label: r("admins.only-inactive") }
567
+ const n = a, r = s, y = q(), v = se(y);
568
+ Q();
569
+ const u = I("webx-auth"), m = b(null), V = b([]), _ = b(!1), d = b("all"), t = b("any"), $ = b([]), A = b({});
570
+ let U = { page: 1, perPage: 20, sort: null, search: "" };
571
+ const W = B(() => [
572
+ { value: "all", label: u("admins.all-roles") },
573
+ ...V.value.map((w) => ({ value: w.slug, label: w.name }))
576
574
  ]), T = B(() => [
577
- { key: "name", label: r("admins.name"), sortable: !0 },
578
- { key: "email", label: r("admins.email"), sortable: !0, hideBelow: 560 },
579
- { key: "roles", label: r("admins.roles"), hideBelow: 760 },
580
- { key: "is_active", label: r("admins.active"), align: "center", hideBelow: 660 },
575
+ { value: "any", label: u("admins.any-state") },
576
+ { value: "yes", label: u("admins.only-active") },
577
+ { value: "no", label: u("admins.only-inactive") }
578
+ ]), z = B(() => [
579
+ { key: "name", label: u("admins.name"), sortable: !0 },
580
+ { key: "email", label: u("admins.email"), sortable: !0, hideBelow: 560 },
581
+ { key: "roles", label: u("admins.roles"), hideBelow: 760 },
582
+ { key: "is_active", label: u("admins.active"), align: "center", hideBelow: 660 },
581
583
  {
582
584
  key: "last_login_at",
583
- label: r("admins.last-login"),
585
+ label: u("admins.last-login"),
584
586
  sortable: !0,
585
587
  hideBelow: 900,
586
588
  // The first thing to go when a row becomes a card: it is a date somebody scans down a
@@ -592,80 +594,80 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
592
594
  label: "",
593
595
  width: 56,
594
596
  align: "right",
595
- hidden: !o.removable,
597
+ hidden: !n.removable,
596
598
  // A card puts them along its top instead, through the `card-actions` slot.
597
599
  hideOnCards: !0
598
600
  }
599
601
  ]);
600
- h.roles().then((y) => A.value = y), oe([c, t], () => m($));
601
- async function m(y) {
602
- $ = y, _.value = !0;
602
+ v.roles().then((w) => V.value = w), J([d, t], () => c(U));
603
+ async function c(w) {
604
+ U = w, _.value = !0;
603
605
  try {
604
- d.value = await h.list({
605
- q: y.search,
606
- role: c.value === "all" ? null : c.value,
606
+ m.value = await v.list({
607
+ q: w.search,
608
+ role: d.value === "all" ? null : d.value,
607
609
  active: t.value === "any" ? null : t.value,
608
- sort: y.sort ? `${y.sort.order === "desc" ? "-" : ""}${y.sort.key}` : "name",
609
- page: y.page,
610
- per_page: y.perPage
611
- }), v();
610
+ sort: w.sort ? `${w.sort.order === "desc" ? "-" : ""}${w.sort.key}` : "name",
611
+ page: w.page,
612
+ per_page: w.perPage
613
+ }), p();
612
614
  } finally {
613
615
  _.value = !1;
614
616
  }
615
617
  }
616
- async function v() {
617
- const y = o.resolveAvatar;
618
- if (y)
619
- for (const x of d.value?.data ?? []) {
620
- if (!x.avatar || C.value[x.avatar]) continue;
621
- const p = await y(x.avatar);
622
- p && (C.value = { ...C.value, [x.avatar]: p });
618
+ async function p() {
619
+ const w = n.resolveAvatar;
620
+ if (w)
621
+ for (const x of m.value?.data ?? []) {
622
+ if (!x.avatar || A.value[x.avatar]) continue;
623
+ const f = await w(x.avatar);
624
+ f && (A.value = { ...A.value, [x.avatar]: f });
623
625
  }
624
626
  }
625
- function f(y) {
626
- if (!o.picking) {
627
- u("open", y);
627
+ function h(w) {
628
+ if (!n.picking) {
629
+ r("open", w);
628
630
  return;
629
631
  }
630
- o.multiple || u("chosen", [y]);
632
+ n.multiple || r("chosen", [w]);
631
633
  }
632
- function Q(y, x) {
633
- U.value = x, u("selection", x);
634
+ function X(w, x) {
635
+ $.value = x, r("selection", x);
634
636
  }
635
- return i({ reload: () => m($), chosen: () => U.value }), (y, x) => (k(), K("div", Je, [
636
- n(e(Te), {
637
- data: d.value,
638
- columns: T.value,
637
+ return i({ reload: () => c(U), chosen: () => $.value }), (w, x) => (k(), K("div", Qe, [
638
+ o(e(Me), {
639
+ data: m.value,
640
+ columns: z.value,
639
641
  "row-key": "id",
640
642
  searchable: "",
641
643
  hover: "",
642
644
  flush: "",
643
645
  loading: _.value,
644
- "search-placeholder": e(r)("admins.search"),
645
- "empty-text": e(r)("admins.empty"),
646
+ "search-placeholder": e(u)("admins.search"),
647
+ "empty-text": e(u)("admins.empty"),
646
648
  selectable: a.picking && a.multiple,
647
- onStateChange: m,
648
- onRowClick: f,
649
- onSelectionChange: Q
649
+ onStateChange: c,
650
+ onRowClick: h,
651
+ onSelectionChange: X
650
652
  }, ne({
651
- "cell-name": l(({ row: p }) => [
652
- n(e(E), {
653
+ "cell-name": l(({ row: f }) => [
654
+ o(e(E), {
653
655
  size: "sm",
654
656
  align: "center"
655
657
  }, {
656
658
  default: l(() => [
657
- n(e(Me), {
658
- name: p.name,
659
- src: p.avatar ? C.value[p.avatar] : void 0,
659
+ o(e(Pe), {
660
+ name: f.name,
661
+ src: f.avatar ? A.value[f.avatar] : void 0,
660
662
  size: "sm"
661
663
  }, null, 8, ["name", "src"]),
662
- O("span", null, V(p.name), 1),
663
- p.is_super ? (k(), S(e(ee), {
664
+ O("span", null, C(f.name), 1),
665
+ f.is_super ? (k(), S(e(ae), {
664
666
  key: 0,
665
667
  type: "warning"
666
668
  }, {
667
669
  default: l(() => [
668
- L(V(e(r)("admins.super")), 1)
670
+ L(C(e(u)("admins.super")), 1)
669
671
  ]),
670
672
  _: 1
671
673
  })) : P("", !0)
@@ -673,18 +675,18 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
673
675
  _: 2
674
676
  }, 1024)
675
677
  ]),
676
- "cell-roles": l(({ row: p }) => [
677
- p.roles.length > 0 ? (k(), S(e(E), {
678
+ "cell-roles": l(({ row: f }) => [
679
+ f.roles.length > 0 ? (k(), S(e(E), {
678
680
  key: 0,
679
681
  size: "xs",
680
682
  wrap: ""
681
683
  }, {
682
684
  default: l(() => [
683
- (k(!0), K(te, null, fe(p.roles, (g) => (k(), S(e(ee), {
685
+ (k(!0), K(le, null, he(f.roles, (g) => (k(), S(e(ae), {
684
686
  key: g.id
685
687
  }, {
686
688
  default: l(() => [
687
- L(V(g.name), 1)
689
+ L(C(g.name), 1)
688
690
  ]),
689
691
  _: 2
690
692
  }, 1024))), 128))
@@ -696,62 +698,62 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
696
698
  tone: "muted"
697
699
  }, {
698
700
  default: l(() => [
699
- L(V(e(r)("admins.no-roles")), 1)
701
+ L(C(e(u)("admins.no-roles")), 1)
700
702
  ]),
701
703
  _: 1
702
704
  }))
703
705
  ]),
704
- "cell-is_active": l(({ row: p }) => [
705
- n(e(ee), {
706
- type: p.is_active ? "success" : "default",
706
+ "cell-is_active": l(({ row: f }) => [
707
+ o(e(ae), {
708
+ type: f.is_active ? "success" : "default",
707
709
  dot: ""
708
710
  }, {
709
711
  default: l(() => [
710
- L(V(p.is_active ? e(r)("admins.active") : e(r)("admins.only-inactive")), 1)
712
+ L(C(f.is_active ? e(u)("admins.active") : e(u)("admins.only-inactive")), 1)
711
713
  ]),
712
714
  _: 2
713
715
  }, 1032, ["type"])
714
716
  ]),
715
- "card-actions": l(({ row: p }) => [
717
+ "card-actions": l(({ row: f }) => [
716
718
  a.removable ? (k(), S(e(ce), {
717
719
  key: 0,
718
720
  size: "sm",
719
- onClick: x[2] || (x[2] = ae(() => {
721
+ onClick: x[2] || (x[2] = te(() => {
720
722
  }, ["stop"]))
721
723
  }, {
722
724
  default: l(() => [
723
- n(e(me), {
725
+ o(e(me), {
724
726
  type: "remove",
725
- title: e(r)("admins.delete"),
726
- onClick: (g) => u("remove", p)
727
+ title: e(u)("admins.delete"),
728
+ onClick: (g) => r("remove", f)
727
729
  }, null, 8, ["title", "onClick"])
728
730
  ]),
729
731
  _: 2
730
732
  }, 1024)) : P("", !0)
731
733
  ]),
732
- "cell-actions": l(({ row: p }) => [
733
- n(e(ce), {
734
+ "cell-actions": l(({ row: f }) => [
735
+ o(e(ce), {
734
736
  size: "sm",
735
- onClick: x[3] || (x[3] = ae(() => {
737
+ onClick: x[3] || (x[3] = te(() => {
736
738
  }, ["stop"]))
737
739
  }, {
738
740
  default: l(() => [
739
- n(e(me), {
741
+ o(e(me), {
740
742
  type: "remove",
741
- title: e(r)("admins.delete"),
742
- onClick: (g) => u("remove", p)
743
+ title: e(u)("admins.delete"),
744
+ onClick: (g) => r("remove", f)
743
745
  }, null, 8, ["title", "onClick"])
744
746
  ]),
745
747
  _: 2
746
748
  }, 1024)
747
749
  ]),
748
- "cell-last_login_at": l(({ row: p }) => [
749
- n(e(Y), {
750
+ "cell-last_login_at": l(({ row: f }) => [
751
+ o(e(Y), {
750
752
  size: "sm",
751
- tone: p.last_login_at ? "default" : "muted"
753
+ tone: f.last_login_at ? "default" : "muted"
752
754
  }, {
753
755
  default: l(() => [
754
- L(V(p.last_login_at ? new Date(p.last_login_at).toLocaleString() : e(r)("admins.never")), 1)
756
+ L(C(f.last_login_at ? new Date(f.last_login_at).toLocaleString() : e(u)("admins.never")), 1)
755
757
  ]),
756
758
  _: 2
757
759
  }, 1032, ["tone"])
@@ -761,19 +763,19 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
761
763
  a.filters ? {
762
764
  name: "actions",
763
765
  fn: l(() => [
764
- n(e(E), { size: "sm" }, {
766
+ o(e(E), { size: "sm" }, {
765
767
  default: l(() => [
766
- n(e(H), {
767
- modelValue: c.value,
768
- "onUpdate:modelValue": x[0] || (x[0] = (p) => c.value = p),
769
- options: z.value,
768
+ o(e(H), {
769
+ modelValue: d.value,
770
+ "onUpdate:modelValue": x[0] || (x[0] = (f) => d.value = f),
771
+ options: W.value,
770
772
  size: "sm",
771
773
  style: { width: "180px" }
772
774
  }, null, 8, ["modelValue", "options"]),
773
- n(e(H), {
775
+ o(e(H), {
774
776
  modelValue: t.value,
775
- "onUpdate:modelValue": x[1] || (x[1] = (p) => t.value = p),
776
- options: F.value,
777
+ "onUpdate:modelValue": x[1] || (x[1] = (f) => t.value = f),
778
+ options: T.value,
777
779
  size: "sm",
778
780
  style: { width: "180px" }
779
781
  }, null, 8, ["modelValue", "options"])
@@ -786,60 +788,60 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
786
788
  ]), 1032, ["data", "columns", "loading", "search-placeholder", "empty-text", "selectable"])
787
789
  ]));
788
790
  }
789
- }), Qe = /* @__PURE__ */ I({
791
+ }), Xe = /* @__PURE__ */ R({
790
792
  __name: "AdminsPage",
791
793
  props: {
792
794
  avatarField: { default: void 0 },
793
795
  resolveAvatar: { type: Function, default: void 0 }
794
796
  },
795
797
  setup(a) {
796
- const i = a, s = q(), o = se(s);
797
- J();
798
- const u = R("webx-auth"), b = le("list"), h = w(null), r = ge(Ge), d = s.can("admins.manage");
799
- async function A(c) {
800
- h.value = c, await r({ admin: c, avatarField: i.avatarField }) && b.value?.reload();
798
+ const i = a, s = q(), n = se(s);
799
+ Q();
800
+ const r = I("webx-auth"), y = oe("list"), v = b(null), u = _e(Je), m = s.can("admins.manage");
801
+ async function V(d) {
802
+ v.value = d, await u({ admin: d, avatarField: i.avatarField }) && y.value?.reload();
801
803
  }
802
- async function _(c) {
803
- if (await Ne({
804
- title: u("admins.delete-title", { name: c.name }),
805
- message: u("admins.delete-text"),
806
- confirmText: u("admins.delete"),
807
- cancelText: u("admins.cancel"),
804
+ async function _(d) {
805
+ if (await Oe({
806
+ title: r("admins.delete-title", { name: d.name }),
807
+ message: r("admins.delete-text"),
808
+ confirmText: r("admins.delete"),
809
+ cancelText: r("admins.cancel"),
808
810
  tone: "danger"
809
811
  }))
810
812
  try {
811
- await o.remove(c.id), G.success(u("admins.deleted")), b.value?.reload();
812
- } catch (U) {
813
- const C = U.body;
814
- G.danger(C?.message ?? u("errors.forbidden"));
813
+ await n.remove(d.id), G.success(r("admins.deleted")), y.value?.reload();
814
+ } catch ($) {
815
+ const A = $.body;
816
+ G.danger(A?.message ?? r("errors.forbidden"));
815
817
  }
816
818
  }
817
- return (c, t) => (k(), S(e(Pe), null, ne({
819
+ return (d, t) => (k(), S(e(Ne), null, ne({
818
820
  header: l(() => [
819
- L(V(e(u)("admins.title")), 1)
821
+ L(C(e(r)("admins.title")), 1)
820
822
  ]),
821
823
  default: l(() => [
822
- n(Ae, {
824
+ o(Le, {
823
825
  ref_key: "list",
824
- ref: b,
825
- removable: e(d),
826
+ ref: y,
827
+ removable: e(m),
826
828
  "resolve-avatar": i.resolveAvatar,
827
- onOpen: A,
829
+ onOpen: V,
828
830
  onRemove: _
829
831
  }, null, 8, ["removable", "resolve-avatar"])
830
832
  ]),
831
833
  _: 2
832
834
  }, [
833
- e(d) ? {
835
+ e(m) ? {
834
836
  name: "extra",
835
837
  fn: l(() => [
836
- n(e(j), {
838
+ o(e(j), {
837
839
  type: "primary",
838
840
  icon: "add",
839
- onClick: t[0] || (t[0] = (U) => A(null))
841
+ onClick: t[0] || (t[0] = ($) => V(null))
840
842
  }, {
841
843
  default: l(() => [
842
- L(V(e(u)("admins.new-short")), 1)
844
+ L(C(e(r)("admins.new-short")), 1)
843
845
  ]),
844
846
  _: 1
845
847
  })
@@ -849,7 +851,7 @@ const je = { class: "wx-admin-form" }, qe = { class: "wx-admin-form__grid" }, He
849
851
  ]), 1024));
850
852
  }
851
853
  });
852
- function oa(a = {}) {
854
+ function na(a = {}) {
853
855
  const i = a.path ?? "/admins";
854
856
  return {
855
857
  id: "admins",
@@ -859,7 +861,7 @@ function oa(a = {}) {
859
861
  path: i,
860
862
  name: "webx.admins",
861
863
  component: {
862
- render: () => he(Qe, {
864
+ render: () => be(Xe, {
863
865
  avatarField: a.avatarField,
864
866
  resolveAvatar: a.resolveAvatar
865
867
  })
@@ -868,7 +870,7 @@ function oa(a = {}) {
868
870
  ]
869
871
  };
870
872
  }
871
- const Xe = /* @__PURE__ */ I({
873
+ const Ze = /* @__PURE__ */ R({
872
874
  __name: "AdminPicker",
873
875
  props: {
874
876
  multiple: { type: Boolean, default: !1 },
@@ -876,30 +878,30 @@ const Xe = /* @__PURE__ */ I({
876
878
  resolveAvatar: { type: Function, default: void 0 }
877
879
  },
878
880
  setup(a) {
879
- const i = a, { open: s, resolve: o, dismiss: u } = ye();
880
- J();
881
- const b = R("webx-auth"), h = le("list"), r = w(0);
882
- function d(_) {
883
- o(_);
881
+ const i = a, { open: s, resolve: n, dismiss: r } = we();
882
+ Q();
883
+ const y = I("webx-auth"), v = oe("list"), u = b(0);
884
+ function m(_) {
885
+ n(_);
884
886
  }
885
- function A(_) {
886
- r.value = _.length;
887
+ function V(_) {
888
+ u.value = _.length;
887
889
  }
888
- return (_, c) => (k(), S(e(we), {
890
+ return (_, d) => (k(), S(e(ge), {
889
891
  open: e(s),
890
- "onUpdate:open": c[2] || (c[2] = (t) => pe(s) ? s.value = t : null),
891
- title: a.title ?? e(b)(a.multiple ? "admins.select-many" : "admins.select-one"),
892
+ "onUpdate:open": d[2] || (d[2] = (t) => fe(s) ? s.value = t : null),
893
+ title: a.title ?? e(y)(a.multiple ? "admins.select-many" : "admins.select-one"),
892
894
  width: 880
893
895
  }, ne({
894
896
  default: l(() => [
895
- n(Ae, {
897
+ o(Le, {
896
898
  ref_key: "list",
897
- ref: h,
899
+ ref: v,
898
900
  picking: "",
899
901
  multiple: a.multiple,
900
902
  "resolve-avatar": i.resolveAvatar,
901
- onChosen: d,
902
- onSelection: A
903
+ onChosen: m,
904
+ onSelection: V
903
905
  }, null, 8, ["multiple", "resolve-avatar"])
904
906
  ]),
905
907
  _: 2
@@ -907,36 +909,36 @@ const Xe = /* @__PURE__ */ I({
907
909
  a.multiple ? {
908
910
  name: "footer",
909
911
  fn: l(() => [
910
- n(e(E), {
912
+ o(e(E), {
911
913
  size: "sm",
912
914
  align: "center"
913
915
  }, {
914
916
  default: l(() => [
915
- n(e(Y), {
917
+ o(e(Y), {
916
918
  size: "sm",
917
919
  tone: "muted"
918
920
  }, {
919
921
  default: l(() => [
920
- L(V(e(b)("admins.chosen", { count: r.value })), 1)
922
+ L(C(e(y)("admins.chosen", { count: u.value })), 1)
921
923
  ]),
922
924
  _: 1
923
925
  }),
924
- n(e(j), {
926
+ o(e(j), {
925
927
  variant: "outline",
926
- onClick: c[0] || (c[0] = (t) => e(u)())
928
+ onClick: d[0] || (d[0] = (t) => e(r)())
927
929
  }, {
928
930
  default: l(() => [
929
- L(V(e(b)("admins.cancel")), 1)
931
+ L(C(e(y)("admins.cancel")), 1)
930
932
  ]),
931
933
  _: 1
932
934
  }),
933
- n(e(j), {
935
+ o(e(j), {
934
936
  type: "primary",
935
- disabled: r.value === 0,
936
- onClick: c[1] || (c[1] = (t) => e(o)(h.value?.chosen() ?? []))
937
+ disabled: u.value === 0,
938
+ onClick: d[1] || (d[1] = (t) => e(n)(v.value?.chosen() ?? []))
937
939
  }, {
938
940
  default: l(() => [
939
- L(V(e(b)("admins.save")), 1)
941
+ L(C(e(y)("admins.save")), 1)
940
942
  ]),
941
943
  _: 1
942
944
  }, 8, ["disabled"])
@@ -948,86 +950,101 @@ const Xe = /* @__PURE__ */ I({
948
950
  } : void 0
949
951
  ]), 1032, ["open", "title"]));
950
952
  }
951
- }), Ce = ge(Xe);
952
- async function na(a = {}) {
953
- return (await Ce({ ...a, multiple: !1 }))?.[0];
953
+ }), $e = _e(Ze);
954
+ async function sa(a = {}) {
955
+ return (await $e({ ...a, multiple: !1 }))?.[0];
954
956
  }
955
- function sa(a = {}) {
956
- return Ce({ ...a, multiple: !0 });
957
+ function ia(a = {}) {
958
+ return $e({ ...a, multiple: !0 });
957
959
  }
958
- const Ze = ["title"], ea = /* @__PURE__ */ I({
960
+ const ea = ["title"], aa = /* @__PURE__ */ R({
959
961
  __name: "UserMenu",
960
962
  props: {
961
- signOutLabel: { default: void 0 }
963
+ signOutLabel: { default: void 0 },
964
+ resolveAvatar: { type: Function, default: void 0 }
962
965
  },
963
966
  setup(a) {
964
- const i = q(), s = xe(), o = be(), u = R("webx-auth"), b = B(() => i.state.user), h = B(
965
- () => o.state.panelLocales.length > 1 ? o.state.panelLocales : []
967
+ const i = a, s = q(), n = ke(), r = ye(), y = I("webx-auth"), v = B(() => s.state.user), u = B(
968
+ () => r.state.panelLocales.length > 1 ? r.state.panelLocales : []
969
+ ), m = pe(Ve, null), V = b(void 0);
970
+ J(
971
+ () => typeof v.value?.avatar == "string" ? v.value.avatar : null,
972
+ async (d) => {
973
+ const t = i.resolveAvatar ?? m;
974
+ if (d === null || d === "" || t === null) {
975
+ V.value = void 0;
976
+ return;
977
+ }
978
+ const $ = await t(d);
979
+ v.value?.avatar === d && (V.value = $ ?? void 0);
980
+ },
981
+ { immediate: !0 }
966
982
  );
967
- async function r(d) {
968
- d !== o.state.locale && await s.setLocale(d);
983
+ async function _(d) {
984
+ d !== r.state.locale && await n.setLocale(d);
969
985
  }
970
- return (d, A) => {
971
- const _ = W("wx-avatar"), c = W("wx-text"), t = W("wx-dropdown-item"), U = W("wx-divider"), C = W("wx-dropdown");
972
- return b.value !== null ? (k(), S(C, { key: 0 }, {
986
+ return (d, t) => {
987
+ const $ = F("wx-avatar"), A = F("wx-text"), U = F("wx-dropdown-item"), W = F("wx-divider"), T = F("wx-dropdown");
988
+ return v.value !== null ? (k(), S(T, { key: 0 }, {
973
989
  trigger: l(() => [
974
990
  O("button", {
975
991
  type: "button",
976
992
  class: "wx-user-menu__trigger",
977
- title: b.value.name
993
+ title: v.value.name
978
994
  }, [
979
- n(_, {
980
- name: b.value.name,
981
- size: "md"
982
- }, null, 8, ["name"])
983
- ], 8, Ze)
995
+ o($, {
996
+ name: v.value.name,
997
+ src: V.value,
998
+ size: "lg"
999
+ }, null, 8, ["name", "src"])
1000
+ ], 8, ea)
984
1001
  ]),
985
1002
  default: l(() => [
986
- n(t, { disabled: "" }, {
1003
+ o(U, { disabled: "" }, {
987
1004
  default: l(() => [
988
- n(c, { size: "sm" }, {
1005
+ o(A, { size: "sm" }, {
989
1006
  default: l(() => [
990
- L(V(b.value.email), 1)
1007
+ L(C(v.value.email), 1)
991
1008
  ]),
992
1009
  _: 1
993
1010
  })
994
1011
  ]),
995
1012
  _: 1
996
1013
  }),
997
- h.value.length > 0 ? (k(), K(te, { key: 0 }, [
998
- n(U, { spacing: 4 }),
999
- n(t, { disabled: "" }, {
1014
+ u.value.length > 0 ? (k(), K(le, { key: 0 }, [
1015
+ o(W, { spacing: "sm" }),
1016
+ o(U, { disabled: "" }, {
1000
1017
  default: l(() => [
1001
- n(c, {
1018
+ o(A, {
1002
1019
  size: "sm",
1003
1020
  tone: "muted"
1004
1021
  }, {
1005
1022
  default: l(() => [
1006
- L(V(e(u)("menu.language")), 1)
1023
+ L(C(e(y)("menu.language")), 1)
1007
1024
  ]),
1008
1025
  _: 1
1009
1026
  })
1010
1027
  ]),
1011
1028
  _: 1
1012
1029
  }),
1013
- (k(!0), K(te, null, fe(h.value, ($) => (k(), S(t, {
1014
- key: $.code,
1015
- icon: $.code === e(o).state.locale ? "check" : void 0,
1016
- onClick: (z) => r($.code)
1030
+ (k(!0), K(le, null, he(u.value, (z) => (k(), S(U, {
1031
+ key: z.code,
1032
+ icon: z.code === e(r).state.locale ? "check" : void 0,
1033
+ onClick: (c) => _(z.code)
1017
1034
  }, {
1018
1035
  default: l(() => [
1019
- L(V($.nativeName), 1)
1036
+ L(C(z.nativeName), 1)
1020
1037
  ]),
1021
1038
  _: 2
1022
1039
  }, 1032, ["icon", "onClick"]))), 128)),
1023
- n(U, { spacing: 4 })
1040
+ o(W, { spacing: "sm" })
1024
1041
  ], 64)) : P("", !0),
1025
- n(t, {
1042
+ o(U, {
1026
1043
  icon: "logout",
1027
- onClick: A[0] || (A[0] = ($) => e(s).logout())
1044
+ onClick: t[0] || (t[0] = (z) => e(n).logout())
1028
1045
  }, {
1029
1046
  default: l(() => [
1030
- L(V(a.signOutLabel ?? e(u)("menu.sign-out")), 1)
1047
+ L(C(a.signOutLabel ?? e(y)("menu.sign-out")), 1)
1031
1048
  ]),
1032
1049
  _: 1
1033
1050
  })
@@ -1036,28 +1053,28 @@ const Ze = ["title"], ea = /* @__PURE__ */ I({
1036
1053
  })) : P("", !0);
1037
1054
  };
1038
1055
  }
1039
- }), ia = /* @__PURE__ */ ke(ea, [["__scopeId", "data-v-b7b5c88d"]]);
1040
- function ra(a = {}) {
1056
+ }), ra = /* @__PURE__ */ Ae(aa, [["__scopeId", "data-v-d9c92170"]]);
1057
+ function ua(a = {}) {
1041
1058
  const i = a.path ?? "/login";
1042
1059
  return {
1043
1060
  install(s) {
1044
- const o = Oe(s.context);
1045
- s.i18n.defaults("webx-auth", Ve), Ee(s.app, o), s.context.useSessionLoader(() => o.me()), s.router.addRoute({
1061
+ const n = Ee(s.context);
1062
+ s.i18n.defaults("webx-auth", Ce), Re(s.app, n, a.resolveAvatar ?? null), s.context.useSessionLoader(() => n.me()), s.router.addRoute({
1046
1063
  path: i,
1047
1064
  name: "webx.login",
1048
1065
  meta: { public: !0 },
1049
- component: { render: () => he(Ke, { ...a.card }) }
1050
- }), s.router.beforeEach((u) => u.meta.public === !0 || s.context.state.status !== "unauthenticated" ? !0 : { path: i, query: u.fullPath === "/" ? {} : { next: u.fullPath } }), oe(
1066
+ component: { render: () => be(je, { ...a.card }) }
1067
+ }), s.router.beforeEach((r) => r.meta.public === !0 || s.context.state.status !== "unauthenticated" ? !0 : { path: i, query: r.fullPath === "/" ? {} : { next: r.fullPath } }), J(
1051
1068
  () => s.context.state.status,
1052
- (u) => {
1053
- const b = s.router.currentRoute.value;
1054
- if (u === "unauthenticated" && b.path !== i) {
1055
- s.router.replace({ path: i, query: { next: b.fullPath } });
1069
+ (r) => {
1070
+ const y = s.router.currentRoute.value;
1071
+ if (r === "unauthenticated" && y.path !== i) {
1072
+ s.router.replace({ path: i, query: { next: y.fullPath } });
1056
1073
  return;
1057
1074
  }
1058
- if (u === "ready" && b.path === i) {
1059
- const h = b.query.next;
1060
- s.router.replace(typeof h == "string" ? h : "/");
1075
+ if (r === "ready" && y.path === i) {
1076
+ const v = y.query.next;
1077
+ s.router.replace(typeof v == "string" ? v : "/");
1061
1078
  }
1062
1079
  }
1063
1080
  );
@@ -1065,19 +1082,20 @@ function ra(a = {}) {
1065
1082
  };
1066
1083
  }
1067
1084
  export {
1068
- Ae as WxAdminList,
1069
- Qe as WxAdminsPage,
1070
- Ke as WxLoginCard,
1071
- ia as WxUserMenu,
1072
- oa as admins,
1073
- ra as auth,
1074
- _e as authKey,
1075
- Ve as authMessages,
1085
+ Le as WxAdminList,
1086
+ Xe as WxAdminsPage,
1087
+ je as WxLoginCard,
1088
+ ra as WxUserMenu,
1089
+ na as admins,
1090
+ ua as auth,
1091
+ xe as authKey,
1092
+ Ce as authMessages,
1093
+ Ve as avatarResolverKey,
1076
1094
  se as createAdminsApi,
1077
- Oe as createAuthSession,
1078
- Ee as provideAuth,
1079
- na as selectAdmin,
1080
- sa as selectAdmins,
1081
- xe as useAuth
1095
+ Ee as createAuthSession,
1096
+ Re as provideAuth,
1097
+ sa as selectAdmin,
1098
+ ia as selectAdmins,
1099
+ ke as useAuth
1082
1100
  };
1083
1101
  //# sourceMappingURL=index.js.map