@webx-ui/module-admin 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,228 +1,316 @@
1
- import { inject as R, reactive as C, computed as k, defineComponent as M, resolveComponent as y, openBlock as w, createBlock as S, unref as d, withCtx as x, createElementBlock as _, Fragment as U, renderList as P, ref as T, createVNode as b, createTextVNode as I, toDisplayString as W, renderSlot as $, createCommentVNode as J, isRef as Q, createApp as Y, h as A, useModel as Z, watch as ee, mergeModels as D } from "vue";
2
- import { useRouter as te, useRoute as ne, createRouter as ae, createWebHistory as le } from "vue-router";
3
- import { useResponsiveShell as oe, WxToaster as se, WebxUI as re, localesKey as ie, WxAlert as ce, WxSkeleton as ue } from "@webx-ui/core";
4
- import { WxScreenRenderer as de } from "@webx-ui/schema";
5
- const F = /* @__PURE__ */ Symbol("webx-admin");
6
- function N() {
7
- const e = R(F, null);
1
+ import { defineComponent as T, useModel as se, openBlock as p, createElementBlock as y, normalizeClass as F, createBlock as b, unref as f, withCtx as w, createTextVNode as L, toDisplayString as E, createCommentVNode as z, renderSlot as S, Fragment as C, mergeModels as K, inject as V, reactive as q, computed as k, resolveComponent as $, renderList as I, ref as W, createVNode as _, createElementVNode as A, isRef as ye, createApp as be, h as P, watch as oe, withModifiers as ie, nextTick as xe, withKeys as _e } from "vue";
2
+ import { useRouter as ke, useRoute as $e, createRouter as Se, createWebHistory as Te, RouterLink as Le } from "vue-router";
3
+ import { WxHeading as Ee, WxTabs as ze, WxCard as ne, useResponsiveShell as Ce, shellLayoutFor as We, WxToaster as Ue, WebxUI as Ae, localesKey as Me, WxAlert as Pe, WxSkeleton as Re, WxActions as Be, WxDropdownItem as De, WxAction as G, WxPopover as Ie, WxInput as Ve, WxButton as Ne, WxDialog as je, WxTooltip as He, WxText as ae } from "@webx-ui/core";
4
+ import { WxScreenRenderer as Oe } from "@webx-ui/schema";
5
+ const Fe = ["data-wx-fill"], Ke = {
6
+ key: 0,
7
+ class: "wx-list-screen__head"
8
+ }, qe = {
9
+ key: 1,
10
+ class: "wx-list-screen__actions"
11
+ }, Xe = /* @__PURE__ */ T({
12
+ __name: "ListScreen",
13
+ props: /* @__PURE__ */ K({
14
+ title: { default: void 0 },
15
+ views: { default: void 0 },
16
+ card: { type: Boolean, default: !0 },
17
+ padding: { default: void 0 },
18
+ fill: { type: Boolean, default: !1 },
19
+ collapseBelow: { default: 560 }
20
+ }, {
21
+ view: { default: void 0 },
22
+ viewModifiers: {}
23
+ }),
24
+ emits: ["update:view"],
25
+ setup(e) {
26
+ const t = se(e, "view");
27
+ return (n, a) => (p(), y("div", {
28
+ class: F(["wx-list-screen", { "is-fill": e.fill }]),
29
+ "data-wx-fill": e.fill ? "" : void 0
30
+ }, [
31
+ e.title || n.$slots.actions ? (p(), y("div", Ke, [
32
+ e.title ? (p(), b(f(Ee), {
33
+ key: 0,
34
+ level: 2,
35
+ class: "wx-list-screen__title"
36
+ }, {
37
+ default: w(() => [
38
+ L(E(e.title), 1)
39
+ ]),
40
+ _: 1
41
+ })) : z("", !0),
42
+ n.$slots.actions ? (p(), y("div", qe, [
43
+ S(n.$slots, "actions", {}, void 0, !0)
44
+ ])) : z("", !0)
45
+ ])) : z("", !0),
46
+ e.views && e.views.length > 0 ? (p(), b(f(ze), {
47
+ key: 1,
48
+ modelValue: t.value,
49
+ "onUpdate:modelValue": a[0] || (a[0] = (i) => t.value = i),
50
+ class: "wx-list-screen__views",
51
+ items: e.views,
52
+ "collapse-below": e.collapseBelow,
53
+ "aria-label": e.title
54
+ }, {
55
+ default: w(() => [
56
+ e.card ? (p(), b(f(ne), {
57
+ key: 0,
58
+ class: "wx-list-screen__card",
59
+ padding: e.padding
60
+ }, {
61
+ default: w(() => [
62
+ S(n.$slots, "default", {}, void 0, !0)
63
+ ]),
64
+ _: 3
65
+ }, 8, ["padding"])) : S(n.$slots, "default", {}, void 0, !0, 1)
66
+ ]),
67
+ _: 3
68
+ }, 8, ["modelValue", "items", "collapse-below", "aria-label"])) : (p(), y(C, { key: 2 }, [
69
+ e.card ? (p(), b(f(ne), {
70
+ key: 0,
71
+ class: "wx-list-screen__card",
72
+ padding: e.padding
73
+ }, {
74
+ default: w(() => [
75
+ S(n.$slots, "default", {}, void 0, !0)
76
+ ]),
77
+ _: 3
78
+ }, 8, ["padding"])) : S(n.$slots, "default", {}, void 0, !0, 1)
79
+ ], 64))
80
+ ], 10, Fe));
81
+ }
82
+ }), N = (e, t) => {
83
+ const n = e.__vccOpts || e;
84
+ for (const [a, i] of t)
85
+ n[a] = i;
86
+ return n;
87
+ }, Ye = /* @__PURE__ */ N(Xe, [["__scopeId", "data-v-7586ed04"]]), Ge = {
88
+ "wx-list": { component: Ye, kind: "layout", labelProp: "title" }
89
+ }, re = /* @__PURE__ */ Symbol("webx-admin");
90
+ function J() {
91
+ const e = V(re, null);
8
92
  if (e === null)
9
93
  throw new Error("useAdmin() was called outside a panel created by createAdmin().");
10
94
  return e;
11
95
  }
12
- function fe(e) {
13
- const n = C({
96
+ function Je(e) {
97
+ const t = q({
14
98
  status: "loading",
15
99
  manifest: null,
16
100
  user: null,
17
101
  error: null
18
- }), o = k(() => {
19
- const t = n.manifest;
20
- if (t === null)
102
+ }), n = k(() => {
103
+ const l = t.manifest;
104
+ if (l === null)
21
105
  return [];
22
- const a = [];
23
- for (const c of t.modules) {
24
- const s = e.modules.find((h) => h.id === c.id);
25
- if (s === void 0)
106
+ const m = [];
107
+ for (const h of l.modules) {
108
+ const g = e.modules.find((x) => x.id === h.id);
109
+ if (g === void 0)
26
110
  continue;
27
- const v = s.path ?? s.routes?.[0]?.path;
28
- v !== void 0 && a.push({
29
- id: c.id,
30
- title: c.title,
31
- icon: c.icon,
111
+ const v = g.path ?? g.routes?.[0]?.path;
112
+ v !== void 0 && m.push({
113
+ id: h.id,
114
+ title: h.title,
115
+ icon: h.icon,
32
116
  path: v,
33
- group: c.group ?? null
117
+ group: h.group ?? null
34
118
  });
35
119
  }
36
- return a;
37
- }), u = k(() => {
38
- const t = n.manifest?.groups ?? [], a = [], c = /* @__PURE__ */ new Map();
39
- for (const s of o.value)
40
- if (s.group !== null && t.some((v) => v.id === s.group)) {
41
- const v = c.get(s.group) ?? [];
42
- v.push(s), c.set(s.group, v);
120
+ return m;
121
+ }), a = k(() => {
122
+ const l = t.manifest?.groups ?? [], m = [], h = /* @__PURE__ */ new Map();
123
+ for (const g of n.value)
124
+ if (g.group !== null && l.some((v) => v.id === g.group)) {
125
+ const v = h.get(g.group) ?? [];
126
+ v.push(g), h.set(g.group, v);
43
127
  } else
44
- a.push(s);
128
+ m.push(g);
45
129
  return {
46
- top: a,
47
- groups: t.filter((s) => c.has(s.id)).map((s) => ({
48
- id: s.id,
49
- title: s.title,
50
- entries: c.get(s.id) ?? []
130
+ top: m,
131
+ groups: l.filter((g) => h.has(g.id)).map((g) => ({
132
+ id: g.id,
133
+ title: g.title,
134
+ entries: h.get(g.id) ?? []
51
135
  }))
52
136
  };
53
- }), f = {};
54
- for (const t of e.modules)
55
- Object.assign(f, t.types);
56
- Object.assign(f, e.types);
57
- const m = /* @__PURE__ */ new Map();
58
- async function p(t) {
59
- const a = `${e.i18n.state.locale}:${t}`;
60
- let c = m.get(a);
61
- return c === void 0 && (c = e.http.get(`${e.apiPath}/screens/${t}`).then((s) => s.data.root).catch((s) => {
62
- throw m.delete(a), s;
63
- }), m.set(a, c)), c;
137
+ }), i = { ...Ge };
138
+ for (const l of e.modules)
139
+ Object.assign(i, l.types);
140
+ Object.assign(i, e.types);
141
+ const d = /* @__PURE__ */ new Map();
142
+ async function o(l) {
143
+ const m = `${e.i18n.state.locale}:${l}`;
144
+ let h = d.get(m);
145
+ return h === void 0 && (h = e.http.get(`${e.apiPath}/screens/${l}`).then((g) => g.data.root).catch((g) => {
146
+ throw d.delete(m), g;
147
+ }), d.set(m, h)), h;
64
148
  }
65
149
  let r = null;
66
- async function i() {
67
- n.status = "loading", n.error = null;
150
+ async function s() {
151
+ t.status = "loading", t.error = null;
68
152
  try {
69
- if (r !== null && (n.user = await r(), n.user === null)) {
70
- n.manifest = null, n.status = "unauthenticated";
153
+ if (r !== null && (t.user = await r(), t.user === null)) {
154
+ t.manifest = null, t.status = "unauthenticated";
71
155
  return;
72
156
  }
73
- const t = await e.loadManifest();
74
- n.manifest = t, e.i18n.state.contentLocales = t.locales ?? [], e.i18n.state.panelLocales = t.panelLocales ?? e.i18n.state.panelLocales, t.locale !== void 0 && t.locale !== e.i18n.state.locale && await l(t.locale), n.status = "ready";
75
- } catch (t) {
76
- if (pe(t)) {
77
- n.manifest = null, n.user = null, n.status = "unauthenticated";
157
+ const l = await e.loadManifest();
158
+ t.manifest = l, e.i18n.state.contentLocales = l.locales ?? [], e.i18n.state.panelLocales = l.panelLocales ?? e.i18n.state.panelLocales, l.locale !== void 0 && l.locale !== e.i18n.state.locale && await c(l.locale), t.status = "ready";
159
+ } catch (l) {
160
+ if (Ze(l)) {
161
+ t.manifest = null, t.user = null, t.status = "unauthenticated";
78
162
  return;
79
163
  }
80
- n.error = t instanceof Error ? t.message : String(t), n.status = "error";
164
+ t.error = l instanceof Error ? l.message : String(l), t.status = "error";
81
165
  }
82
166
  }
83
- async function l(t) {
84
- if (e.loadDictionary === void 0) {
85
- e.i18n.state.locale = t;
86
- return;
87
- }
88
- if (await e.loadDictionary(t), n.manifest !== null)
167
+ async function u() {
168
+ if (t.manifest !== null)
89
169
  try {
90
- n.manifest = await e.loadManifest();
170
+ t.manifest = await e.loadManifest();
91
171
  } catch {
92
172
  }
93
173
  }
174
+ async function c(l) {
175
+ if (e.loadDictionary === void 0) {
176
+ e.i18n.state.locale = l;
177
+ return;
178
+ }
179
+ await e.loadDictionary(l), await u();
180
+ }
94
181
  return {
95
182
  http: e.http,
96
183
  basePath: e.basePath,
97
184
  apiPath: e.apiPath,
98
- state: n,
185
+ state: t,
99
186
  i18n: e.i18n,
100
187
  modules: e.modules,
101
- nav: o,
102
- groups: u,
103
- types: f,
104
- reload: i,
105
- setLocale: l,
106
- setUser(t) {
107
- n.user = t;
188
+ nav: n,
189
+ groups: a,
190
+ types: i,
191
+ reload: s,
192
+ refreshManifest: u,
193
+ setLocale: c,
194
+ setUser(l) {
195
+ t.user = l;
108
196
  },
109
- useSessionLoader(t) {
110
- r = t;
197
+ useSessionLoader(l) {
198
+ r = l;
111
199
  },
112
- can(t) {
113
- const a = n.user;
114
- return a === null ? !1 : a.isSuper || a.permissions.includes(t);
200
+ can(l) {
201
+ const m = t.user;
202
+ return m === null ? !1 : m.isSuper || m.permissions.includes(l);
115
203
  },
116
- loadScreen: p,
117
- screenPatch(t) {
118
- return e.screens?.[t] ?? [];
204
+ loadScreen: o,
205
+ screenPatch(l) {
206
+ return e.screens?.[l] ?? [];
119
207
  }
120
208
  };
121
209
  }
122
- function me(e, n) {
123
- e.provide(F, n);
210
+ function Qe(e, t) {
211
+ e.provide(re, t);
124
212
  }
125
- function pe(e) {
213
+ function Ze(e) {
126
214
  return typeof e == "object" && e !== null && "status" in e && e.status === 401;
127
215
  }
128
- const O = /* @__PURE__ */ Symbol("webx-i18n");
129
- function De() {
130
- const e = R(O, null);
216
+ const j = /* @__PURE__ */ Symbol("webx-i18n");
217
+ function Nt() {
218
+ const e = V(j, null);
131
219
  if (e === null)
132
220
  throw new Error("useI18n() was called outside a panel created by createAdmin().");
133
221
  return e;
134
222
  }
135
- function j(e) {
136
- const n = R(O, null);
137
- return n === null ? X().scope(e) : n.scope(e);
223
+ function U(e) {
224
+ const t = V(j, null);
225
+ return t === null ? Q().scope(e) : t.scope(e);
138
226
  }
139
- function he(e, n) {
140
- e.provide(O, n);
227
+ function et(e, t) {
228
+ e.provide(j, t);
141
229
  }
142
- function X(e = {}) {
143
- const n = e.fallback ?? "en", o = C({
144
- locale: e.locale ?? n,
145
- fallback: n,
230
+ function Q(e = {}) {
231
+ const t = e.fallback ?? "en", n = q({
232
+ locale: e.locale ?? t,
233
+ fallback: t,
146
234
  panelLocales: [],
147
235
  contentLocales: []
148
- }), u = {}, f = C({ value: {} });
149
- function m(r, i, l) {
150
- let t = r[i]?.[l[0] ?? ""];
151
- for (const a of l.slice(1)) {
152
- if (typeof t != "object" || t === null)
236
+ }), a = {}, i = q({ value: {} });
237
+ function d(r, s, u) {
238
+ let c = r[s]?.[u[0] ?? ""];
239
+ for (const l of u.slice(1)) {
240
+ if (typeof c != "object" || c === null)
153
241
  return null;
154
- t = t[a];
242
+ c = c[l];
155
243
  }
156
- return typeof t == "string" ? t : null;
244
+ return typeof c == "string" ? c : null;
157
245
  }
158
- function p(r, i, l) {
159
- const [t, a] = i.includes("::") ? i.split("::", 2) : [r, i], c = a.split("."), s = m(f.value, t, c) ?? m(u, t, c) ?? // Not an empty string: a key on screen is ugly, but it says which key, and a blank
246
+ function o(r, s, u) {
247
+ const [c, l] = s.includes("::") ? s.split("::", 2) : [r, s], m = l.split("."), h = d(i.value, c, m) ?? d(a, c, m) ?? // Not an empty string: a key on screen is ugly, but it says which key, and a blank
160
248
  // label says nothing to anybody trying to fix it.
161
- i;
162
- return l === void 0 ? s : ve(s, l);
249
+ s;
250
+ return u === void 0 ? h : tt(h, u);
163
251
  }
164
252
  return {
165
- state: o,
166
- defaults(r, i) {
167
- u[r] = { ...u[r], ...i };
253
+ state: n,
254
+ defaults(r, s) {
255
+ a[r] = { ...a[r], ...s };
168
256
  },
169
- load(r, i, l) {
170
- f.value = r ?? {}, o.locale = i ?? o.locale, l !== void 0 && (o.fallback = l);
257
+ load(r, s, u) {
258
+ i.value = r ?? {}, n.locale = s ?? n.locale, u !== void 0 && (n.fallback = u);
171
259
  },
172
260
  scope(r) {
173
- return (i, l) => p(r, i, l);
261
+ return (s, u) => o(r, s, u);
174
262
  },
175
- t: (r, i) => p("", r, i)
263
+ t: (r, s) => o("", r, s)
176
264
  };
177
265
  }
178
- function ve(e, n) {
179
- let o = e;
180
- for (const [u, f] of Object.entries(n))
181
- o = o.replaceAll(`:${u}`, String(f));
182
- return o;
266
+ function tt(e, t) {
267
+ let n = e;
268
+ for (const [a, i] of Object.entries(t))
269
+ n = n.replaceAll(`:${a}`, String(i));
270
+ return n;
183
271
  }
184
- const we = /* @__PURE__ */ M({
272
+ const nt = /* @__PURE__ */ T({
185
273
  __name: "AdminNav",
186
274
  props: {
187
275
  collapsed: { type: Boolean }
188
276
  },
189
277
  emits: ["select"],
190
- setup(e, { emit: n }) {
191
- const o = n, u = N(), f = j("webx-admin"), m = te(), p = ne(), r = k({
192
- get: () => u.nav.value.find((l) => p.path.startsWith(l.path))?.id ?? "",
193
- set: (i) => {
194
- const l = u.nav.value.find((t) => t.id === i);
195
- l !== void 0 && m.push(l.path);
278
+ setup(e, { emit: t }) {
279
+ const n = t, a = J(), i = U("webx-admin"), d = ke(), o = $e(), r = k({
280
+ get: () => a.nav.value.find((u) => o.path.startsWith(u.path))?.id ?? "",
281
+ set: (s) => {
282
+ const u = a.nav.value.find((c) => c.id === s);
283
+ u !== void 0 && d.push(u.path);
196
284
  }
197
285
  });
198
- return (i, l) => {
199
- const t = y("wx-menu-item"), a = y("wx-submenu"), c = y("wx-menu");
200
- return w(), S(c, {
286
+ return (s, u) => {
287
+ const c = $("wx-menu-item"), l = $("wx-submenu"), m = $("wx-menu");
288
+ return p(), b(m, {
201
289
  modelValue: r.value,
202
- "onUpdate:modelValue": l[0] || (l[0] = (s) => r.value = s),
290
+ "onUpdate:modelValue": u[0] || (u[0] = (h) => r.value = h),
203
291
  collapsed: e.collapsed,
204
- label: d(f)("nav.sections"),
205
- onSelect: l[1] || (l[1] = (s) => o("select"))
292
+ label: f(i)("nav.sections"),
293
+ onSelect: u[1] || (u[1] = (h) => n("select"))
206
294
  }, {
207
- default: x(() => [
208
- (w(!0), _(U, null, P(d(u).groups.value.top, (s) => (w(), S(t, {
209
- key: s.id,
210
- value: s.id,
211
- icon: s.icon ?? void 0,
212
- label: s.title
295
+ default: w(() => [
296
+ (p(!0), y(C, null, I(f(a).groups.value.top, (h) => (p(), b(c, {
297
+ key: h.id,
298
+ value: h.id,
299
+ icon: h.icon ?? void 0,
300
+ label: h.title
213
301
  }, null, 8, ["value", "icon", "label"]))), 128)),
214
- (w(!0), _(U, null, P(d(u).groups.value.groups, (s) => (w(), S(a, {
215
- key: s.id,
216
- value: `group:${s.id}`,
217
- title: s.title,
302
+ (p(!0), y(C, null, I(f(a).groups.value.groups, (h) => (p(), b(l, {
303
+ key: h.id,
304
+ value: `group:${h.id}`,
305
+ title: h.title,
218
306
  icon: "gear"
219
307
  }, {
220
- default: x(() => [
221
- (w(!0), _(U, null, P(s.entries, (v) => (w(), S(t, {
222
- key: v.id,
223
- value: v.id,
224
- icon: v.icon ?? void 0,
225
- label: v.title
308
+ default: w(() => [
309
+ (p(!0), y(C, null, I(h.entries, (g) => (p(), b(c, {
310
+ key: g.id,
311
+ value: g.id,
312
+ icon: g.icon ?? void 0,
313
+ label: g.title
226
314
  }, null, 8, ["value", "icon", "label"]))), 128))
227
315
  ]),
228
316
  _: 2
@@ -232,138 +320,204 @@ const we = /* @__PURE__ */ M({
232
320
  }, 8, ["modelValue", "collapsed", "label"]);
233
321
  };
234
322
  }
235
- }), ge = {
323
+ }), at = {
236
324
  key: 0,
237
325
  class: "wx-root wx-admin-plain"
238
- }, ye = {
326
+ }, lt = {
239
327
  key: 1,
240
328
  class: "wx-root wx-admin-plain"
241
- }, be = {
329
+ }, st = {
242
330
  key: 2,
243
331
  class: "wx-root wx-admin-plain"
244
- }, xe = /* @__PURE__ */ M({
332
+ }, ot = ["src", "alt", "width", "height"], it = ["src", "alt", "width", "height"], rt = ["src", "alt"], ut = { class: "wx-admin__user" }, dt = { class: "wx-admin__user wx-admin__user--drawer" }, ct = /* @__PURE__ */ T({
245
333
  __name: "AdminShell",
246
334
  setup(e) {
247
- const n = N(), o = j("webx-admin"), u = T(null), { layout: f, collapsed: m, showAside: p, drawerOpen: r, toggle: i, close: l } = oe(u, {
248
- persist: "webx-admin-shell"
249
- });
250
- return (t, a) => {
251
- const c = y("router-view"), s = y("wx-loading"), v = y("wx-button"), h = y("wx-result"), g = y("wx-action"), E = y("wx-text"), K = y("wx-header"), q = y("wx-aside"), B = y("wx-main"), V = y("wx-container"), G = y("wx-drawer");
252
- return w(), _(U, null, [
253
- b(d(se)),
254
- d(n).state.status === "unauthenticated" ? (w(), _("div", ge, [
255
- b(c)
256
- ])) : d(n).state.status === "loading" ? (w(), _("div", ye, [
257
- b(s, {
258
- label: d(o)("shell.loading")
335
+ const t = J(), n = U("webx-admin"), a = W(null), { width: i, layout: d, collapsed: o, showAside: r, drawerOpen: s, toggle: u, close: c } = Ce(
336
+ a,
337
+ { persist: "webx-admin-shell" }
338
+ ), l = k(() => t.state.manifest?.title ?? ""), m = k(() => t.state.manifest?.branding?.logo ?? null), h = k(() => t.state.manifest?.branding?.mark ?? null), g = k(() => We(i.value, null));
339
+ return (v, x) => {
340
+ const M = $("router-view"), ce = $("wx-loading"), fe = $("wx-button"), me = $("wx-result"), Z = $("wx-action"), ee = $("wx-text"), he = $("wx-header"), pe = $("wx-aside"), ve = $("wx-main"), ge = $("wx-container"), we = $("wx-drawer");
341
+ return p(), y(C, null, [
342
+ _(f(Ue)),
343
+ f(t).state.status === "unauthenticated" ? (p(), y("div", at, [
344
+ _(M)
345
+ ])) : f(t).state.status === "loading" ? (p(), y("div", lt, [
346
+ _(ce, {
347
+ label: f(n)("shell.loading")
259
348
  }, null, 8, ["label"])
260
- ])) : d(n).state.status === "error" ? (w(), _("div", be, [
261
- b(h, {
349
+ ])) : f(t).state.status === "error" ? (p(), y("div", st, [
350
+ _(me, {
262
351
  status: "error",
263
- title: d(o)("shell.error-title"),
264
- description: d(n).state.error
352
+ title: f(n)("shell.error-title"),
353
+ description: f(t).state.error
265
354
  }, {
266
- default: x(() => [
267
- b(v, {
355
+ default: w(() => [
356
+ _(fe, {
268
357
  type: "primary",
269
- onClick: a[0] || (a[0] = (L) => d(n).reload())
358
+ onClick: x[0] || (x[0] = (te) => f(t).reload())
270
359
  }, {
271
- default: x(() => [
272
- I(W(d(o)("shell.retry")), 1)
360
+ default: w(() => [
361
+ L(E(f(n)("shell.retry")), 1)
273
362
  ]),
274
363
  _: 1
275
364
  })
276
365
  ]),
277
366
  _: 1
278
367
  }, 8, ["title", "description"])
279
- ])) : (w(), _("div", {
368
+ ])) : (p(), y("div", {
280
369
  key: 3,
281
370
  ref_key: "shellEl",
282
- ref: u,
283
- class: "wx-root wx-admin"
371
+ ref: a,
372
+ class: F(["wx-root wx-admin", `wx-admin--${g.value}`])
284
373
  }, [
285
- b(V, { viewport: "" }, {
286
- default: x(() => [
287
- b(K, null, {
288
- end: x(() => [
289
- $(t.$slots, "user", {}, void 0, !0)
374
+ _(ge, {
375
+ direction: f(d) === "drawer" ? "vertical" : "horizontal",
376
+ "full-height": "",
377
+ class: "wx-admin__frame"
378
+ }, {
379
+ default: w(() => [
380
+ f(d) === "drawer" ? (p(), b(he, {
381
+ key: 0,
382
+ class: "wx-admin__header",
383
+ floating: "",
384
+ sticky: "",
385
+ bordered: !1,
386
+ padding: "sm",
387
+ height: "var(--wx-admin-header-height)"
388
+ }, {
389
+ end: w(() => [
390
+ S(v.$slots, "user", { expanded: !1 }, void 0, !0)
290
391
  ]),
291
- default: x(() => [
292
- b(g, {
293
- icon: d(f) === "drawer" ? "menu" : "sidebar",
294
- title: d(f) === "drawer" ? d(o)("nav.menu") : d(o)("nav.collapse"),
295
- onClick: d(i)
296
- }, null, 8, ["icon", "title", "onClick"]),
297
- $(t.$slots, "brand", {}, () => [
298
- b(E, { weight: "semibold" }, {
299
- default: x(() => [
300
- I(W(d(n).state.manifest?.title), 1)
392
+ default: w(() => [
393
+ _(Z, {
394
+ icon: "menu",
395
+ title: f(n)("nav.menu"),
396
+ onClick: f(u)
397
+ }, null, 8, ["title", "onClick"]),
398
+ S(v.$slots, "brand", {}, () => [
399
+ m.value ? (p(), y("img", {
400
+ key: 0,
401
+ class: "wx-admin__logo",
402
+ src: m.value.url,
403
+ alt: l.value,
404
+ width: m.value.width ?? void 0,
405
+ height: m.value.height ?? void 0
406
+ }, null, 8, ot)) : (p(), b(ee, {
407
+ key: 1,
408
+ weight: "semibold",
409
+ truncate: ""
410
+ }, {
411
+ default: w(() => [
412
+ L(E(l.value), 1)
301
413
  ]),
302
414
  _: 1
303
- })
415
+ }))
304
416
  ], !0)
305
417
  ]),
306
418
  _: 3
307
- }),
308
- b(V, { direction: "horizontal" }, {
309
- default: x(() => [
310
- d(p) ? (w(), S(q, {
311
- key: 0,
312
- collapsed: d(m),
313
- width: 220,
314
- scroll: ""
315
- }, {
316
- default: x(() => [
317
- $(t.$slots, "nav", { collapsed: d(m) }, void 0, !0)
318
- ]),
319
- _: 3
320
- }, 8, ["collapsed"])) : J("", !0),
321
- b(B, {
322
- padding: "md",
323
- scroll: "",
324
- class: "wx-admin__screen"
325
- }, {
326
- default: x(() => [
327
- b(c)
328
- ]),
329
- _: 1
330
- })
419
+ })) : z("", !0),
420
+ f(r) ? (p(), b(pe, {
421
+ key: 1,
422
+ class: "wx-admin__aside",
423
+ sticky: "",
424
+ floating: "",
425
+ scroll: "",
426
+ bordered: !1,
427
+ collapsed: f(o),
428
+ width: 220,
429
+ "collapsed-width": 56
430
+ }, {
431
+ top: w(() => [
432
+ A("div", {
433
+ class: F(["wx-admin__brand", { "wx-admin__brand--stacked": f(o) && h.value }])
434
+ }, [
435
+ f(o) ? h.value ? (p(), y("img", {
436
+ key: 1,
437
+ class: "wx-admin__mark",
438
+ src: h.value.url,
439
+ alt: l.value
440
+ }, null, 8, rt)) : z("", !0) : S(v.$slots, "brand", {}, () => [
441
+ m.value ? (p(), y("img", {
442
+ key: 0,
443
+ class: "wx-admin__logo",
444
+ src: m.value.url,
445
+ alt: l.value,
446
+ width: m.value.width ?? void 0,
447
+ height: m.value.height ?? void 0
448
+ }, null, 8, it)) : (p(), b(ee, {
449
+ key: 1,
450
+ weight: "semibold",
451
+ truncate: "",
452
+ class: "wx-admin__title"
453
+ }, {
454
+ default: w(() => [
455
+ L(E(l.value), 1)
456
+ ]),
457
+ _: 1
458
+ }))
459
+ ], !0, 0),
460
+ _(Z, {
461
+ icon: "sidebar",
462
+ title: f(o) ? f(n)("nav.expand") : f(n)("nav.collapse"),
463
+ onClick: f(u)
464
+ }, null, 8, ["title", "onClick"])
465
+ ], 2)
466
+ ]),
467
+ bottom: w(() => [
468
+ A("div", ut, [
469
+ S(v.$slots, "user", {
470
+ expanded: !f(o)
471
+ }, void 0, !0)
472
+ ])
473
+ ]),
474
+ default: w(() => [
475
+ S(v.$slots, "nav", { collapsed: f(o) }, void 0, !0)
331
476
  ]),
332
477
  _: 3
478
+ }, 8, ["collapsed"])) : z("", !0),
479
+ _(ve, {
480
+ padding: "none",
481
+ class: "wx-admin__screen"
482
+ }, {
483
+ default: w(() => [
484
+ _(M)
485
+ ]),
486
+ _: 1
333
487
  })
334
488
  ]),
335
489
  _: 3
336
- }),
337
- b(G, {
338
- open: d(r),
339
- "onUpdate:open": a[2] || (a[2] = (L) => Q(r) ? r.value = L : null),
340
- title: d(o)("nav.menu"),
490
+ }, 8, ["direction"]),
491
+ _(we, {
492
+ open: f(s),
493
+ "onUpdate:open": x[1] || (x[1] = (te) => ye(s) ? s.value = te : null),
494
+ title: l.value === "" ? f(n)("nav.menu") : l.value,
341
495
  side: "left",
342
496
  size: 260,
497
+ "full-screen": !1,
343
498
  closable: ""
344
499
  }, {
345
- default: x(() => [
346
- $(t.$slots, "nav", {
500
+ footer: w(() => [
501
+ A("div", dt, [
502
+ S(v.$slots, "user", { expanded: !0 }, void 0, !0)
503
+ ])
504
+ ]),
505
+ default: w(() => [
506
+ S(v.$slots, "nav", {
347
507
  collapsed: !1,
348
- onSelect: a[1] || (a[1] = //@ts-ignore
349
- (...L) => d(l) && d(l)(...L))
508
+ select: f(c)
350
509
  }, void 0, !0)
351
510
  ]),
352
511
  _: 3
353
512
  }, 8, ["open", "title"])
354
- ], 512))
513
+ ], 2))
355
514
  ], 64);
356
515
  };
357
516
  }
358
- }), _e = (e, n) => {
359
- const o = e.__vccOpts || e;
360
- for (const [u, f] of n)
361
- o[u] = f;
362
- return o;
363
- }, Se = /* @__PURE__ */ _e(xe, [["__scopeId", "data-v-9ef35d4d"]]);
364
- class ke extends Error {
365
- constructor(n, o, u = {}, f = null, m = null) {
366
- super(n), this.status = o, this.errors = u, this.retryAfter = f, this.body = m, this.name = "HttpError";
517
+ }), ft = /* @__PURE__ */ N(ct, [["__scopeId", "data-v-ebc6adf3"]]);
518
+ class X extends Error {
519
+ constructor(t, n, a = {}, i = null, d = null) {
520
+ super(t), this.status = n, this.errors = a, this.retryAfter = i, this.body = d, this.name = "HttpError";
367
521
  }
368
522
  status;
369
523
  errors;
@@ -380,86 +534,86 @@ class ke extends Error {
380
534
  return this.status === 429;
381
535
  }
382
536
  }
383
- const Ee = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
384
- function Le(e = {}) {
385
- const n = (e.baseUrl ?? "").replace(/\/$/, ""), o = e.csrfUrl ?? "/sanctum/csrf-cookie", u = e.fetch ?? globalThis.fetch.bind(globalThis), f = e.onUnauthenticated, m = e.headers;
386
- let p = !1;
387
- async function r(l = !1) {
388
- p && !l && H("XSRF-TOKEN") !== null || (await u(o, { credentials: "same-origin" }), p = !0);
537
+ const mt = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH", "DELETE"]);
538
+ function ht(e = {}) {
539
+ const t = (e.baseUrl ?? "").replace(/\/$/, ""), n = e.csrfUrl ?? "/sanctum/csrf-cookie", a = e.fetch ?? globalThis.fetch.bind(globalThis), i = e.onUnauthenticated, d = e.headers;
540
+ let o = !1;
541
+ async function r(u = !1) {
542
+ o && !u && le("XSRF-TOKEN") !== null || (await a(n, { credentials: "same-origin" }), o = !0);
389
543
  }
390
- async function i(l, t, a, c = {}, s = !1) {
391
- const v = Ee.has(l);
392
- v && await r();
393
- const h = {
544
+ async function s(u, c, l, m = {}, h = !1) {
545
+ const g = mt.has(u);
546
+ g && await r();
547
+ const v = {
394
548
  Accept: "application/json",
395
549
  "X-Requested-With": "XMLHttpRequest",
396
550
  // Standing headers first, so a caller can still override one for a single request.
397
- ...m?.(),
398
- ...c.headers
551
+ ...d?.(),
552
+ ...m.headers
399
553
  };
400
- if (v) {
401
- const E = H("XSRF-TOKEN");
402
- E !== null && (h["X-XSRF-TOKEN"] = E);
554
+ if (g) {
555
+ const M = le("XSRF-TOKEN");
556
+ M !== null && (v["X-XSRF-TOKEN"] = M);
403
557
  }
404
- a !== void 0 && (h["Content-Type"] = "application/json");
405
- const g = await u(Ae(n, t, c.query), {
406
- method: l,
558
+ l !== void 0 && (v["Content-Type"] = "application/json");
559
+ const x = await a(vt(t, c, m.query), {
560
+ method: u,
407
561
  credentials: "same-origin",
408
- headers: h,
409
- signal: c.signal,
410
- body: a === void 0 ? void 0 : JSON.stringify(a)
562
+ headers: v,
563
+ signal: m.signal,
564
+ body: l === void 0 ? void 0 : JSON.stringify(l)
411
565
  });
412
- if (g.status === 419 && v && !s)
413
- return await r(!0), i(l, t, a, c, !0);
414
- if (g.status === 401 && f?.(), !g.ok)
415
- throw await $e(g);
416
- if (g.status !== 204)
417
- return await g.json();
566
+ if (x.status === 419 && g && !h)
567
+ return await r(!0), s(u, c, l, m, !0);
568
+ if (x.status === 401 && i?.(), !x.ok)
569
+ throw await pt(x);
570
+ if (x.status !== 204)
571
+ return await x.json();
418
572
  }
419
573
  return {
420
- get: (l, t) => i("GET", l, void 0, t),
421
- post: (l, t, a) => i("POST", l, t, a),
422
- put: (l, t, a) => i("PUT", l, t, a),
423
- patch: (l, t, a) => i("PATCH", l, t, a),
424
- delete: (l, t) => i("DELETE", l, void 0, t)
574
+ get: (u, c) => s("GET", u, void 0, c),
575
+ post: (u, c, l) => s("POST", u, c, l),
576
+ put: (u, c, l) => s("PUT", u, c, l),
577
+ patch: (u, c, l) => s("PATCH", u, c, l),
578
+ delete: (u, c) => s("DELETE", u, void 0, c)
425
579
  };
426
580
  }
427
- async function $e(e) {
428
- let n = null;
581
+ async function pt(e) {
582
+ let t = null;
429
583
  try {
430
- n = await e.json();
584
+ t = await e.json();
431
585
  } catch {
432
586
  }
433
- const o = n ?? {}, u = typeof o.message == "string" && o.message !== "" ? o.message : e.statusText || `Request failed with ${e.status}`, f = o.errors !== null && typeof o.errors == "object" ? o.errors : {}, m = e.headers.get("Retry-After"), p = m === null ? null : Number.parseInt(m, 10);
434
- return new ke(
435
- u,
587
+ const n = t ?? {}, a = typeof n.message == "string" && n.message !== "" ? n.message : e.statusText || `Request failed with ${e.status}`, i = n.errors !== null && typeof n.errors == "object" ? n.errors : {}, d = e.headers.get("Retry-After"), o = d === null ? null : Number.parseInt(d, 10);
588
+ return new X(
589
+ a,
436
590
  e.status,
437
- f,
438
- Number.isFinite(p) ? p : null,
439
- n
591
+ i,
592
+ Number.isFinite(o) ? o : null,
593
+ t
440
594
  );
441
595
  }
442
- function Ae(e, n, o) {
443
- const f = /^https?:\/\//i.test(n) ? n : `${e}/${n.replace(/^\//, "")}`;
444
- if (o === void 0)
445
- return f;
446
- const m = new URLSearchParams();
447
- for (const [r, i] of Object.entries(o))
448
- i != null && m.set(r, String(i));
449
- const p = m.toString();
450
- return p === "" ? f : `${f}${f.includes("?") ? "&" : "?"}${p}`;
596
+ function vt(e, t, n) {
597
+ const i = /^https?:\/\//i.test(t) ? t : `${e}/${t.replace(/^\//, "")}`;
598
+ if (n === void 0)
599
+ return i;
600
+ const d = new URLSearchParams();
601
+ for (const [r, s] of Object.entries(n))
602
+ s != null && d.set(r, String(s));
603
+ const o = d.toString();
604
+ return o === "" ? i : `${i}${i.includes("?") ? "&" : "?"}${o}`;
451
605
  }
452
- function H(e) {
606
+ function le(e) {
453
607
  if (typeof document > "u")
454
608
  return null;
455
- for (const n of document.cookie.split(";")) {
456
- const [o, ...u] = n.trim().split("=");
457
- if (o === e)
458
- return decodeURIComponent(u.join("="));
609
+ for (const t of document.cookie.split(";")) {
610
+ const [n, ...a] = t.trim().split("=");
611
+ if (n === e)
612
+ return decodeURIComponent(a.join("="));
459
613
  }
460
614
  return null;
461
615
  }
462
- const Ue = {
616
+ const ue = {
463
617
  shell: {
464
618
  loading: "Loading the panel…",
465
619
  "error-title": "The panel could not start",
@@ -471,20 +625,57 @@ const Ue = {
471
625
  sections: "Sections",
472
626
  menu: "Menu",
473
627
  collapse: "Collapse the menu",
474
- language: "Language"
628
+ expand: "Expand the menu",
629
+ language: "Language",
630
+ // The one menu group the panel names itself; a module's own group is named by the module.
631
+ system: "System"
632
+ },
633
+ // What a screen that edits one record offers whatever the record is: the way out of it, and
634
+ // the way to rename it. A module that opens an editor should not be inventing these.
635
+ editor: {
636
+ back: "Back",
637
+ rename: "Rename",
638
+ save: "Save"
639
+ },
640
+ // The page behind a '?'. Only the heading is the panel's: what the page says belongs to
641
+ // whatever is being explained, and travels with that module's own words.
642
+ help: {
643
+ title: "Help"
644
+ },
645
+ // When something happened, said the way a person would. The month names and the order of
646
+ // the parts come from `Intl` — only the words that no formatter knows are here.
647
+ dates: {
648
+ today: "today at :time",
649
+ yesterday: "yesterday at :time",
650
+ // Not an empty cell and not a dash: a column that says nothing leaves a reader wondering
651
+ // whether the panel failed to load it.
652
+ never: "never"
653
+ },
654
+ // How a request fails, in the panel's words rather than the server's (§13.3). `errors.ts`
655
+ // decides which of these a status gets.
656
+ errors: {
657
+ "signed-out": "You are signed out. Sign in again and try once more.",
658
+ forbidden: "You are not allowed to do that.",
659
+ gone: "It is not there any more — somebody may have deleted it.",
660
+ conflict: "Somebody changed this while you were working on it.",
661
+ throttled: "Too many attempts. Try again in a moment.",
662
+ "throttled-in": "Too many attempts. Try again in :seconds seconds.",
663
+ server: "The server could not do that. Try again in a moment.",
664
+ offline: "The server did not answer. Check the connection and try again.",
665
+ unknown: "That did not work."
475
666
  }
476
- }, z = "webx.locale";
477
- function He(e = {}) {
478
- const n = e.manifestUrl ?? Ne() ?? "/api/cms/manifest", o = e.apiPath ?? n.replace(/\/manifest\/?$/, ""), u = e.basePath ?? "/cms", f = e.modules ?? [], m = [...e.routes ?? []];
479
- for (const h of f)
480
- m.push(...h.routes ?? []);
481
- const p = ae({
482
- history: le(u),
483
- routes: m
484
- }), r = X({ locale: e.locale ?? Pe() }), i = e.http ?? Le({
667
+ }, de = "webx.locale";
668
+ function jt(e = {}) {
669
+ const t = e.manifestUrl ?? _t() ?? "/api/cms/manifest", n = e.apiPath ?? t.replace(/\/manifest\/?$/, ""), a = e.basePath ?? "/cms", i = e.modules ?? [], d = [...e.routes ?? []];
670
+ for (const v of i)
671
+ d.push(...v.routes ?? []);
672
+ const o = Se({
673
+ history: Te(a),
674
+ routes: d
675
+ }), r = Q({ locale: e.locale ?? wt() }), s = e.http ?? ht({
485
676
  baseUrl: "",
486
677
  onUnauthenticated: () => {
487
- t.setUser(null), t.state.status = "unauthenticated";
678
+ c.setUser(null), c.state.status = "unauthenticated";
488
679
  },
489
680
  // Every request says which language the panel is currently showing. It decides what
490
681
  // the server writes its own messages in — a 422 under a field — for anybody who has
@@ -492,89 +683,237 @@ function He(e = {}) {
492
683
  // signing in on a Russian sign-in screen lands in an English panel.
493
684
  headers: () => ({ "X-Webx-Locale": r.state.locale })
494
685
  });
495
- r.defaults("webx-admin", Ue);
496
- async function l(h) {
497
- const g = await i.get(`${o}/translations/${h}`);
498
- r.load(g.data.namespaces, g.data.locale, g.data.fallback), Ce(g.data.locale), Me(g.data.locale, r.state.panelLocales);
686
+ r.defaults("webx-admin", ue);
687
+ async function u(v) {
688
+ const x = await s.get(`${n}/translations/${v}`);
689
+ r.load(x.data.namespaces, x.data.locale, x.data.fallback), yt(x.data.locale), xt(x.data.locale, r.state.panelLocales);
499
690
  }
500
- const t = fe({
501
- http: i,
502
- basePath: u,
503
- apiPath: o,
504
- modules: f,
691
+ const c = Je({
692
+ http: s,
693
+ basePath: a,
694
+ apiPath: n,
695
+ modules: i,
505
696
  i18n: r,
506
- loadDictionary: l,
697
+ loadDictionary: u,
507
698
  types: e.types,
508
699
  screens: e.screens,
509
- loadManifest: async () => (await i.get(n)).data
510
- }), a = Y(Te(e));
511
- a.use(re), me(a, t), he(a, r);
512
- const c = T("");
513
- a.provide(ie, {
700
+ loadManifest: async () => (await s.get(t)).data
701
+ }), l = be(gt(e));
702
+ l.use(Ae), Qe(l, c), et(l, r);
703
+ const m = W("");
704
+ l.provide(Me, {
514
705
  list: k(
515
- () => r.state.contentLocales.map((h) => ({
516
- code: h.code,
517
- label: h.code.toUpperCase()
706
+ () => r.state.contentLocales.map((v) => ({
707
+ code: v.code,
708
+ label: v.code.toUpperCase()
518
709
  }))
519
710
  ),
520
711
  active: k({
521
- get: () => c.value || (r.state.contentLocales[0]?.code ?? ""),
522
- set: (h) => {
523
- c.value = h;
712
+ get: () => m.value || (r.state.contentLocales[0]?.code ?? ""),
713
+ set: (v) => {
714
+ m.value = v;
524
715
  }
525
716
  })
526
717
  });
527
- const s = {
528
- app: a,
529
- router: p,
530
- context: t,
718
+ const h = {
719
+ app: l,
720
+ router: o,
721
+ context: c,
531
722
  i18n: r,
532
723
  async mount() {
533
- await Promise.all([v(), l(r.state.locale)]).catch(() => {
534
- }), a.mount(e.el ?? "#webx-app"), await t.reload();
724
+ await Promise.all([g(), u(r.state.locale)]).catch(() => {
725
+ }), l.mount(e.el ?? "#webx-app"), await c.reload();
535
726
  }
536
727
  };
537
- async function v() {
538
- const h = await i.get(`${o}/locales`);
539
- r.state.panelLocales = h.data.panel, r.state.contentLocales = h.data.content;
728
+ async function g() {
729
+ const v = await s.get(`${n}/locales`);
730
+ r.state.panelLocales = v.data.panel, r.state.contentLocales = v.data.content;
540
731
  }
541
- for (const h of e.plugins ?? [])
542
- h.install(s);
543
- return a.use(p), s;
732
+ for (const v of e.plugins ?? [])
733
+ v.install(h);
734
+ return l.use(o), h;
544
735
  }
545
- function Te(e) {
546
- const n = {
736
+ function gt(e) {
737
+ const t = {
547
738
  // The menu is the panel's own: it is the manifest, drawn.
548
- nav: (o) => A(we, { collapsed: o.collapsed === !0 })
739
+ // The shell hands in what a choice means where it drew the menu — in the drawer it is what
740
+ // closes it, and a drawer that stays open over the section it just opened is a drawer the
741
+ // reader has to dismiss by hand.
742
+ nav: (n) => P(nt, { collapsed: n.collapsed === !0, onSelect: n.select })
549
743
  };
550
- return e.brand !== void 0 && (n.brand = () => A(e.brand)), e.userMenu !== void 0 && (n.user = () => A(e.userMenu)), { render: () => A(Se, null, n) };
744
+ return e.brand !== void 0 && (t.brand = () => P(e.brand)), e.userMenu !== void 0 && (t.user = (n) => P(e.userMenu, { expanded: n.expanded === !0 })), { render: () => P(ft, null, t) };
551
745
  }
552
- function Pe() {
553
- const e = Re(z);
746
+ function wt() {
747
+ const e = bt(de);
554
748
  return e !== null ? e : typeof document < "u" && document.documentElement.lang !== "" ? document.documentElement.lang : typeof navigator > "u" ? "en" : navigator.language;
555
749
  }
556
- function Ce(e) {
750
+ function yt(e) {
557
751
  try {
558
- localStorage.setItem(z, e);
752
+ localStorage.setItem(de, e);
559
753
  } catch {
560
754
  }
561
755
  }
562
- function Re(e) {
756
+ function bt(e) {
563
757
  try {
564
758
  return localStorage.getItem(e);
565
759
  } catch {
566
760
  return null;
567
761
  }
568
762
  }
569
- function Me(e, n) {
570
- typeof document > "u" || (document.documentElement.lang = e, document.documentElement.dir = n.find((o) => o.code === e)?.direction ?? "ltr");
763
+ function xt(e, t) {
764
+ typeof document > "u" || (document.documentElement.lang = e, document.documentElement.dir = t.find((n) => n.code === e)?.direction ?? "ltr");
571
765
  }
572
- function Ne() {
766
+ function _t() {
573
767
  return typeof document > "u" ? null : document.querySelector('meta[name="webx-manifest"]')?.getAttribute("content") ?? null;
574
768
  }
575
- const Oe = { class: "wx-screen-host" }, Fe = /* @__PURE__ */ M({
769
+ function kt(e) {
770
+ const t = e.replace(/\r\n?/g, `
771
+ `).split(`
772
+ `), n = [];
773
+ let a = 0;
774
+ for (; a < t.length; ) {
775
+ const i = t[a] ?? "";
776
+ if (i.trim() === "") {
777
+ a += 1;
778
+ continue;
779
+ }
780
+ if (/^```([\w-]*)\s*$/.exec(i)) {
781
+ const s = [];
782
+ for (a += 1; a < t.length && !/^```\s*$/.test(t[a] ?? ""); )
783
+ s.push(t[a] ?? ""), a += 1;
784
+ a += 1, n.push(`<pre><code>${Y(s.join(`
785
+ `))}</code></pre>`);
786
+ continue;
787
+ }
788
+ const o = /^(#{1,4})\s+(.*)$/.exec(i);
789
+ if (o) {
790
+ const s = Math.min(o[1].length + 1, 5);
791
+ n.push(`<h${s}>${H(o[2] ?? "")}</h${s}>`), a += 1;
792
+ continue;
793
+ }
794
+ if (B(i)) {
795
+ const s = /^\s*\d+[.)]\s+/.test(i), u = [];
796
+ for (; a < t.length && B(t[a] ?? ""); )
797
+ for (u.push((t[a] ?? "").replace(/^\s*(?:[-*+]|\d+[.)])\s+/, "")), a += 1; a < t.length; ) {
798
+ const l = t[a] ?? "";
799
+ if (l.trim() === "" || B(l) || /^(#{1,4})\s/.test(l) || /^```/.test(l))
800
+ break;
801
+ u[u.length - 1] += ` ${l.trim()}`, a += 1;
802
+ }
803
+ const c = s ? "ol" : "ul";
804
+ n.push(`<${c}>${u.map((l) => `<li>${H(l)}</li>`).join("")}</${c}>`);
805
+ continue;
806
+ }
807
+ const r = [];
808
+ for (; a < t.length; ) {
809
+ const s = t[a] ?? "";
810
+ if (s.trim() === "" || B(s) || /^(#{1,4})\s/.test(s) || /^```/.test(s)) break;
811
+ r.push(s.trim()), a += 1;
812
+ }
813
+ n.push(`<p>${H(r.join(" "))}</p>`);
814
+ }
815
+ return n.join("");
816
+ }
817
+ const R = "\0";
818
+ function B(e) {
819
+ return /^\s*(?:[-*+]|\d+[.)])\s+/.test(e);
820
+ }
821
+ function H(e) {
822
+ const t = [], n = e.replace(/`([^`]+)`/g, (i, d) => (t.push(`<code>${Y(d)}</code>`), `${R}${t.length - 1}${R}`));
823
+ return Y(n).replace(
824
+ /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,
825
+ '<a href="$2" target="_blank" rel="noopener">$1</a>'
826
+ ).replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>").replace(
827
+ new RegExp(`${R}(\\d+)${R}`, "g"),
828
+ (i, d) => t[Number(d)] ?? ""
829
+ );
830
+ }
831
+ function Y(e) {
832
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
833
+ }
834
+ function $t(e) {
835
+ const t = e.scope("webx-admin"), n = /* @__PURE__ */ new Map();
836
+ function a(d, o, r) {
837
+ const s = e.state.locale, u = `${s}:${d}`;
838
+ let c = n.get(u);
839
+ return c === void 0 && (c = new Intl.DateTimeFormat(s, o), n.set(u, c)), c.format(r);
840
+ }
841
+ const i = (d) => a("time", { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }, d);
842
+ return {
843
+ short(d) {
844
+ const o = O(d);
845
+ if (o === null)
846
+ return t("dates.never");
847
+ const r = /* @__PURE__ */ new Date(), s = Lt(o, r);
848
+ return s === 0 ? t("dates.today", { time: i(o) }) : s === -1 ? t("dates.yesterday", { time: i(o) }) : o.getFullYear() === r.getFullYear() ? a(
849
+ "this-year",
850
+ {
851
+ day: "numeric",
852
+ month: "long",
853
+ hour: "2-digit",
854
+ minute: "2-digit",
855
+ hourCycle: "h23"
856
+ },
857
+ o
858
+ ) : a("earlier", { day: "numeric", month: "long", year: "numeric" }, o);
859
+ },
860
+ exact(d) {
861
+ const o = O(d);
862
+ return o === null ? "" : a("exact", { dateStyle: "long", timeStyle: "medium", hourCycle: "h23" }, o);
863
+ },
864
+ iso(d) {
865
+ const o = O(d);
866
+ return o === null ? "" : o.toISOString();
867
+ }
868
+ };
869
+ }
870
+ function St() {
871
+ const e = V(j, null);
872
+ return $t(e ?? Tt());
873
+ }
874
+ let D = null;
875
+ function Tt() {
876
+ return D === null && (D = Q(), D.defaults("webx-admin", ue)), D;
877
+ }
878
+ function O(e) {
879
+ if (e == null || e === "")
880
+ return null;
881
+ const t = e instanceof Date ? e : new Date(e);
882
+ return Number.isNaN(t.getTime()) ? null : t;
883
+ }
884
+ function Lt(e, t) {
885
+ const n = (a) => Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
886
+ return Math.round((n(e) - n(t)) / 864e5);
887
+ }
888
+ function Et(e, t, n) {
889
+ const a = e instanceof X ? e.status : zt(e);
890
+ if (a === 422)
891
+ return Ct(e) ?? n ?? t("errors.unknown");
892
+ if (a === 401) return t("errors.signed-out");
893
+ if (a === 403) return t("errors.forbidden");
894
+ if (a === 404) return t("errors.gone");
895
+ if (a === 409) return t("errors.conflict");
896
+ if (a === 429) {
897
+ const i = e instanceof X ? e.retryAfter : null;
898
+ return i === null ? t("errors.throttled") : t("errors.throttled-in", { seconds: i });
899
+ }
900
+ return a !== null && a >= 500 ? t("errors.server") : a === null ? t("errors.offline") : n ?? t("errors.unknown");
901
+ }
902
+ function Ht() {
903
+ const e = U("webx-admin");
904
+ return (t, n) => Et(t, e, n);
905
+ }
906
+ function zt(e) {
907
+ const t = e?.status;
908
+ return typeof t == "number" ? t : null;
909
+ }
910
+ function Ct(e) {
911
+ const n = e?.body?.message;
912
+ return typeof n == "string" && n !== "" ? n : null;
913
+ }
914
+ const Wt = { class: "wx-screen-host" }, Ot = /* @__PURE__ */ T({
576
915
  __name: "Screen",
577
- props: /* @__PURE__ */ D({
916
+ props: /* @__PURE__ */ K({
578
917
  name: {},
579
918
  errors: { default: void 0 },
580
919
  disabled: { type: Boolean, default: !1 },
@@ -585,39 +924,39 @@ const Oe = { class: "wx-screen-host" }, Fe = /* @__PURE__ */ M({
585
924
  modelValue: { default: () => ({}) },
586
925
  modelModifiers: {}
587
926
  }),
588
- emits: /* @__PURE__ */ D(["loaded"], ["update:modelValue"]),
589
- setup(e, { expose: n, emit: o }) {
590
- const u = e, f = o, m = Z(e, "modelValue"), p = N(), r = j("webx-admin"), i = T(null), l = T(null);
591
- async function t() {
592
- i.value = null, l.value = null;
927
+ emits: /* @__PURE__ */ K(["loaded"], ["update:modelValue"]),
928
+ setup(e, { expose: t, emit: n }) {
929
+ const a = e, i = n, d = se(e, "modelValue"), o = J(), r = U("webx-admin"), s = W(null), u = W(null);
930
+ async function c() {
931
+ s.value = null, u.value = null;
593
932
  try {
594
- const a = await p.loadScreen(u.name);
595
- i.value = a, f("loaded", a);
596
- } catch (a) {
597
- l.value = a instanceof Error ? a.message : String(a);
933
+ const l = await o.loadScreen(a.name);
934
+ s.value = l, i("loaded", l);
935
+ } catch (l) {
936
+ u.value = l instanceof Error ? l.message : String(l);
598
937
  }
599
938
  }
600
- return ee([() => u.name, () => p.i18n.state.locale], () => {
601
- t();
602
- }, { immediate: !0 }), n({ reload: t }), (a, c) => (w(), _("div", Oe, [
603
- l.value ? (w(), S(d(ce), {
939
+ return oe([() => a.name, () => o.i18n.state.locale], () => {
940
+ c();
941
+ }, { immediate: !0 }), t({ reload: c }), (l, m) => (p(), y("div", Wt, [
942
+ u.value ? (p(), b(f(Pe), {
604
943
  key: 0,
605
944
  type: "danger",
606
- title: d(r)("shell.error-title"),
607
- description: l.value
608
- }, null, 8, ["title", "description"])) : i.value === null ? (w(), S(d(ue), {
945
+ title: f(r)("shell.error-title"),
946
+ description: u.value
947
+ }, null, 8, ["title", "description"])) : s.value === null ? (p(), b(f(Re), {
609
948
  key: 1,
610
949
  rows: 4
611
- })) : (w(), S(d(de), {
950
+ })) : (p(), b(f(Oe), {
612
951
  key: 2,
613
- modelValue: m.value,
614
- "onUpdate:modelValue": c[0] || (c[0] = (s) => m.value = s),
615
- root: i.value,
616
- patch: d(p).screenPatch(e.name),
617
- types: d(p).types,
952
+ modelValue: d.value,
953
+ "onUpdate:modelValue": m[0] || (m[0] = (h) => d.value = h),
954
+ root: s.value,
955
+ patch: f(o).screenPatch(e.name),
956
+ types: f(o).types,
618
957
  errors: e.errors,
619
- translate: d(p).i18n.t,
620
- can: d(p).can,
958
+ translate: f(o).i18n.t,
959
+ can: f(o).can,
621
960
  disabled: e.disabled,
622
961
  "label-position": e.labelPosition,
623
962
  "label-width": e.labelWidth,
@@ -625,24 +964,251 @@ const Oe = { class: "wx-screen-host" }, Fe = /* @__PURE__ */ M({
625
964
  }, null, 8, ["modelValue", "root", "patch", "types", "errors", "translate", "can", "disabled", "label-position", "label-width", "size"]))
626
965
  ]));
627
966
  }
967
+ }), Ut = {
968
+ key: 0,
969
+ class: "wx-dropdown__divider"
970
+ }, Ft = /* @__PURE__ */ T({
971
+ __name: "RowMenu",
972
+ props: {
973
+ actions: {},
974
+ label: { default: void 0 },
975
+ size: { default: "sm" }
976
+ },
977
+ setup(e) {
978
+ const t = e, n = k(() => [
979
+ ...t.actions.filter((i) => !i.danger),
980
+ ...t.actions.filter((i) => i.danger)
981
+ ]), a = k(() => {
982
+ const i = n.value.find((d) => d.danger);
983
+ return i && n.value[0] !== i ? i.key : null;
984
+ });
985
+ return (i, d) => n.value.length > 0 ? (p(), b(f(Be), {
986
+ key: 0,
987
+ collapse: "always",
988
+ align: "end",
989
+ size: e.size,
990
+ "aria-label": e.label,
991
+ onClick: d[0] || (d[0] = ie(() => {
992
+ }, ["stop"]))
993
+ }, {
994
+ collapsed: w(() => [
995
+ (p(!0), y(C, null, I(n.value, (o) => (p(), y(C, {
996
+ key: o.key
997
+ }, [
998
+ o.key === a.value ? (p(), y("hr", Ut)) : z("", !0),
999
+ _(f(De), {
1000
+ icon: o.icon,
1001
+ tone: o.danger ? "danger" : "default",
1002
+ href: o.href,
1003
+ target: o.href ? o.target ?? "_blank" : void 0,
1004
+ disabled: o.disabled,
1005
+ onClick: (r) => o.run?.()
1006
+ }, {
1007
+ default: w(() => [
1008
+ L(E(o.label), 1)
1009
+ ]),
1010
+ _: 2
1011
+ }, 1032, ["icon", "tone", "href", "target", "disabled", "onClick"])
1012
+ ], 64))), 128))
1013
+ ]),
1014
+ _: 1
1015
+ }, 8, ["size", "aria-label"])) : z("", !0);
1016
+ }
1017
+ }), Kt = /* @__PURE__ */ T({
1018
+ __name: "BackButton",
1019
+ props: {
1020
+ to: {},
1021
+ label: { default: void 0 },
1022
+ size: { default: "sm" }
1023
+ },
1024
+ setup(e) {
1025
+ const t = e, n = U("webx-admin"), a = k(() => t.label ?? n("editor.back"));
1026
+ return (i, d) => (p(), b(f(G), {
1027
+ icon: "arrow-left",
1028
+ class: "wx-back-button",
1029
+ as: f(Le),
1030
+ to: e.to,
1031
+ title: a.value,
1032
+ size: e.size,
1033
+ "tooltip-side": "bottom"
1034
+ }, null, 8, ["as", "to", "title", "size"]));
1035
+ }
1036
+ }), At = { class: "wx-rename__footer" }, Mt = /* @__PURE__ */ T({
1037
+ __name: "RenameButton",
1038
+ props: {
1039
+ name: { default: "" },
1040
+ label: { default: void 0 },
1041
+ placeholder: { default: void 0 },
1042
+ disabled: { type: Boolean, default: !1 },
1043
+ size: { default: "sm" }
1044
+ },
1045
+ emits: ["rename"],
1046
+ setup(e, { emit: t }) {
1047
+ const n = e, a = t, i = U("webx-admin"), d = W(!1), o = W(n.name), r = W(null), s = k(() => n.label ?? i("editor.rename"));
1048
+ oe(d, async (c) => {
1049
+ c && (o.value = n.name, await xe(), r.value?.focus(), r.value?.select());
1050
+ });
1051
+ function u() {
1052
+ const c = o.value.trim();
1053
+ if (c === "" || c === n.name) {
1054
+ d.value = !1;
1055
+ return;
1056
+ }
1057
+ a("rename", c), d.value = !1;
1058
+ }
1059
+ return (c, l) => (p(), b(f(Ie), {
1060
+ open: d.value,
1061
+ "onUpdate:open": l[2] || (l[2] = (m) => d.value = m),
1062
+ title: s.value,
1063
+ width: 320,
1064
+ side: "bottom",
1065
+ align: "start",
1066
+ teleport: ""
1067
+ }, {
1068
+ trigger: w(() => [
1069
+ _(f(G), {
1070
+ type: "edit",
1071
+ title: s.value,
1072
+ size: e.size,
1073
+ disabled: e.disabled
1074
+ }, null, 8, ["title", "size", "disabled"])
1075
+ ]),
1076
+ default: w(() => [
1077
+ A("form", {
1078
+ class: "wx-rename",
1079
+ onSubmit: ie(u, ["prevent"])
1080
+ }, [
1081
+ _(f(Ve), {
1082
+ ref_key: "field",
1083
+ ref: r,
1084
+ modelValue: o.value,
1085
+ "onUpdate:modelValue": l[0] || (l[0] = (m) => o.value = m),
1086
+ "aria-label": s.value,
1087
+ placeholder: e.placeholder,
1088
+ onKeydown: l[1] || (l[1] = _e((m) => d.value = !1, ["esc"]))
1089
+ }, null, 8, ["modelValue", "aria-label", "placeholder"]),
1090
+ A("div", At, [
1091
+ _(f(Ne), {
1092
+ type: "primary",
1093
+ size: "sm",
1094
+ "native-type": "submit"
1095
+ }, {
1096
+ default: w(() => [
1097
+ L(E(f(i)("editor.save")), 1)
1098
+ ]),
1099
+ _: 1
1100
+ })
1101
+ ])
1102
+ ], 32)
1103
+ ]),
1104
+ _: 1
1105
+ }, 8, ["open", "title"]));
1106
+ }
1107
+ }), qt = /* @__PURE__ */ N(Mt, [["__scopeId", "data-v-d879e8d3"]]), Pt = ["innerHTML"], Rt = /* @__PURE__ */ T({
1108
+ __name: "HelpButton",
1109
+ props: {
1110
+ body: {},
1111
+ title: { default: void 0 },
1112
+ label: { default: void 0 },
1113
+ size: { default: "sm" },
1114
+ width: { default: 720 }
1115
+ },
1116
+ setup(e) {
1117
+ const t = e, n = U("webx-admin"), a = W(!1), i = k(() => t.title ?? n("help.title")), d = k(() => kt(t.body));
1118
+ return (o, r) => (p(), y(C, null, [
1119
+ _(f(G), {
1120
+ type: "details",
1121
+ icon: "question",
1122
+ tone: "neutral",
1123
+ size: e.size,
1124
+ title: e.label ?? i.value,
1125
+ onClick: r[0] || (r[0] = (s) => a.value = !0)
1126
+ }, null, 8, ["size", "title"]),
1127
+ _(f(je), {
1128
+ open: a.value,
1129
+ "onUpdate:open": r[1] || (r[1] = (s) => a.value = s),
1130
+ title: i.value,
1131
+ width: e.width
1132
+ }, {
1133
+ default: w(() => [
1134
+ A("div", {
1135
+ class: "wx-help",
1136
+ innerHTML: d.value
1137
+ }, null, 8, Pt)
1138
+ ]),
1139
+ _: 1
1140
+ }, 8, ["open", "title", "width"])
1141
+ ], 64));
1142
+ }
1143
+ }), Xt = /* @__PURE__ */ N(Rt, [["__scopeId", "data-v-6c280d42"]]), Yt = /* @__PURE__ */ T({
1144
+ name: "WxDate",
1145
+ __name: "DateText",
1146
+ props: {
1147
+ value: {},
1148
+ size: { default: "sm" },
1149
+ tone: { default: "muted" }
1150
+ },
1151
+ setup(e) {
1152
+ const t = e, n = St(), a = k(() => n.short(t.value)), i = k(() => n.exact(t.value)), d = k(() => n.iso(t.value));
1153
+ return (o, r) => i.value ? (p(), b(f(He), {
1154
+ key: 0,
1155
+ content: i.value
1156
+ }, {
1157
+ default: w(() => [
1158
+ _(f(ae), {
1159
+ as: "time",
1160
+ datetime: d.value,
1161
+ size: e.size,
1162
+ tone: e.tone
1163
+ }, {
1164
+ default: w(() => [
1165
+ L(E(a.value), 1)
1166
+ ]),
1167
+ _: 1
1168
+ }, 8, ["datetime", "size", "tone"])
1169
+ ]),
1170
+ _: 1
1171
+ }, 8, ["content"])) : (p(), b(f(ae), {
1172
+ key: 1,
1173
+ size: e.size,
1174
+ tone: e.tone
1175
+ }, {
1176
+ default: w(() => [
1177
+ L(E(a.value), 1)
1178
+ ]),
1179
+ _: 1
1180
+ }, 8, ["size", "tone"]));
1181
+ }
628
1182
  });
629
1183
  export {
630
- we as AdminNav,
631
- Se as AdminShell,
632
- ke as HttpError,
633
- Fe as WxScreen,
634
- F as adminKey,
635
- Ue as adminMessages,
636
- He as createAdmin,
637
- fe as createAdminContext,
638
- Le as createHttp,
639
- X as createI18n,
640
- O as i18nKey,
641
- me as provideAdmin,
642
- he as provideI18n,
643
- H as readCookie,
644
- N as useAdmin,
645
- De as useI18n,
646
- j as useTranslate
1184
+ nt as AdminNav,
1185
+ ft as AdminShell,
1186
+ X as HttpError,
1187
+ Kt as WxBackButton,
1188
+ Yt as WxDate,
1189
+ Xt as WxHelpButton,
1190
+ Ye as WxListScreen,
1191
+ qt as WxRenameButton,
1192
+ Ft as WxRowMenu,
1193
+ Ot as WxScreen,
1194
+ re as adminKey,
1195
+ ue as adminMessages,
1196
+ Ge as adminTypes,
1197
+ jt as createAdmin,
1198
+ Je as createAdminContext,
1199
+ $t as createDates,
1200
+ ht as createHttp,
1201
+ Q as createI18n,
1202
+ Et as errorText,
1203
+ j as i18nKey,
1204
+ Qe as provideAdmin,
1205
+ et as provideI18n,
1206
+ le as readCookie,
1207
+ kt as renderMarkdown,
1208
+ J as useAdmin,
1209
+ St as useDates,
1210
+ Ht as useErrorText,
1211
+ Nt as useI18n,
1212
+ U as useTranslate
647
1213
  };
648
1214
  //# sourceMappingURL=index.js.map