@webx-ui/module-auth 0.5.2 → 0.5.4

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