@webx-ui/module-admin 0.3.0 → 0.4.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/AdminNav.d.ts +3 -0
- package/dist/Screen.d.ts +39 -0
- package/dist/admin.d.ts +18 -1
- package/dist/createAdmin.d.ts +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +415 -307
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +27 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,64 +1,93 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
import { useRouter as
|
|
3
|
-
import { useResponsiveShell as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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);
|
|
7
8
|
if (e === null)
|
|
8
9
|
throw new Error("useAdmin() was called outside a panel created by createAdmin().");
|
|
9
10
|
return e;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
12
|
+
function fe(e) {
|
|
13
|
+
const n = C({
|
|
13
14
|
status: "loading",
|
|
14
15
|
manifest: null,
|
|
15
16
|
user: null,
|
|
16
17
|
error: null
|
|
17
|
-
}),
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
18
|
+
}), o = k(() => {
|
|
19
|
+
const t = n.manifest;
|
|
20
|
+
if (t === null)
|
|
20
21
|
return [];
|
|
21
|
-
const
|
|
22
|
-
for (const
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
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)
|
|
25
26
|
continue;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
id:
|
|
29
|
-
title:
|
|
30
|
-
icon:
|
|
31
|
-
path:
|
|
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,
|
|
32
|
+
path: v,
|
|
33
|
+
group: c.group ?? null
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
|
-
return
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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);
|
|
43
|
+
} else
|
|
44
|
+
a.push(s);
|
|
45
|
+
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) ?? []
|
|
51
|
+
}))
|
|
52
|
+
};
|
|
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;
|
|
64
|
+
}
|
|
65
|
+
let r = null;
|
|
66
|
+
async function i() {
|
|
67
|
+
n.status = "loading", n.error = null;
|
|
39
68
|
try {
|
|
40
|
-
if (
|
|
41
|
-
|
|
69
|
+
if (r !== null && (n.user = await r(), n.user === null)) {
|
|
70
|
+
n.manifest = null, n.status = "unauthenticated";
|
|
42
71
|
return;
|
|
43
72
|
}
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
} catch (
|
|
47
|
-
if (
|
|
48
|
-
|
|
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";
|
|
49
78
|
return;
|
|
50
79
|
}
|
|
51
|
-
|
|
80
|
+
n.error = t instanceof Error ? t.message : String(t), n.status = "error";
|
|
52
81
|
}
|
|
53
82
|
}
|
|
54
|
-
async function
|
|
83
|
+
async function l(t) {
|
|
55
84
|
if (e.loadDictionary === void 0) {
|
|
56
|
-
e.i18n.state.locale =
|
|
85
|
+
e.i18n.state.locale = t;
|
|
57
86
|
return;
|
|
58
87
|
}
|
|
59
|
-
if (await e.loadDictionary(
|
|
88
|
+
if (await e.loadDictionary(t), n.manifest !== null)
|
|
60
89
|
try {
|
|
61
|
-
|
|
90
|
+
n.manifest = await e.loadManifest();
|
|
62
91
|
} catch {
|
|
63
92
|
}
|
|
64
93
|
}
|
|
@@ -66,187 +95,209 @@ function le(e) {
|
|
|
66
95
|
http: e.http,
|
|
67
96
|
basePath: e.basePath,
|
|
68
97
|
apiPath: e.apiPath,
|
|
69
|
-
state:
|
|
98
|
+
state: n,
|
|
70
99
|
i18n: e.i18n,
|
|
71
100
|
modules: e.modules,
|
|
72
|
-
nav:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
101
|
+
nav: o,
|
|
102
|
+
groups: u,
|
|
103
|
+
types: f,
|
|
104
|
+
reload: i,
|
|
105
|
+
setLocale: l,
|
|
106
|
+
setUser(t) {
|
|
107
|
+
n.user = t;
|
|
108
|
+
},
|
|
109
|
+
useSessionLoader(t) {
|
|
110
|
+
r = t;
|
|
77
111
|
},
|
|
78
|
-
|
|
79
|
-
|
|
112
|
+
can(t) {
|
|
113
|
+
const a = n.user;
|
|
114
|
+
return a === null ? !1 : a.isSuper || a.permissions.includes(t);
|
|
80
115
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
116
|
+
loadScreen: p,
|
|
117
|
+
screenPatch(t) {
|
|
118
|
+
return e.screens?.[t] ?? [];
|
|
84
119
|
}
|
|
85
120
|
};
|
|
86
121
|
}
|
|
87
|
-
function
|
|
88
|
-
e.provide(
|
|
122
|
+
function me(e, n) {
|
|
123
|
+
e.provide(F, n);
|
|
89
124
|
}
|
|
90
|
-
function
|
|
125
|
+
function pe(e) {
|
|
91
126
|
return typeof e == "object" && e !== null && "status" in e && e.status === 401;
|
|
92
127
|
}
|
|
93
|
-
const
|
|
94
|
-
function
|
|
95
|
-
const e =
|
|
128
|
+
const O = /* @__PURE__ */ Symbol("webx-i18n");
|
|
129
|
+
function De() {
|
|
130
|
+
const e = R(O, null);
|
|
96
131
|
if (e === null)
|
|
97
132
|
throw new Error("useI18n() was called outside a panel created by createAdmin().");
|
|
98
133
|
return e;
|
|
99
134
|
}
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
return
|
|
135
|
+
function j(e) {
|
|
136
|
+
const n = R(O, null);
|
|
137
|
+
return n === null ? X().scope(e) : n.scope(e);
|
|
103
138
|
}
|
|
104
|
-
function
|
|
105
|
-
e.provide(
|
|
139
|
+
function he(e, n) {
|
|
140
|
+
e.provide(O, n);
|
|
106
141
|
}
|
|
107
|
-
function
|
|
108
|
-
const
|
|
109
|
-
locale: e.locale ??
|
|
110
|
-
fallback:
|
|
142
|
+
function X(e = {}) {
|
|
143
|
+
const n = e.fallback ?? "en", o = C({
|
|
144
|
+
locale: e.locale ?? n,
|
|
145
|
+
fallback: n,
|
|
111
146
|
panelLocales: [],
|
|
112
147
|
contentLocales: []
|
|
113
|
-
}),
|
|
114
|
-
function
|
|
115
|
-
let
|
|
116
|
-
for (const
|
|
117
|
-
if (typeof
|
|
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)
|
|
118
153
|
return null;
|
|
119
|
-
|
|
154
|
+
t = t[a];
|
|
120
155
|
}
|
|
121
|
-
return typeof
|
|
156
|
+
return typeof t == "string" ? t : null;
|
|
122
157
|
}
|
|
123
|
-
function
|
|
124
|
-
const [
|
|
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
|
|
125
160
|
// label says nothing to anybody trying to fix it.
|
|
126
|
-
|
|
127
|
-
return
|
|
161
|
+
i;
|
|
162
|
+
return l === void 0 ? s : ve(s, l);
|
|
128
163
|
}
|
|
129
164
|
return {
|
|
130
|
-
state:
|
|
131
|
-
defaults(
|
|
132
|
-
|
|
165
|
+
state: o,
|
|
166
|
+
defaults(r, i) {
|
|
167
|
+
u[r] = { ...u[r], ...i };
|
|
133
168
|
},
|
|
134
|
-
load(
|
|
135
|
-
|
|
169
|
+
load(r, i, l) {
|
|
170
|
+
f.value = r ?? {}, o.locale = i ?? o.locale, l !== void 0 && (o.fallback = l);
|
|
136
171
|
},
|
|
137
|
-
scope(
|
|
138
|
-
return (
|
|
172
|
+
scope(r) {
|
|
173
|
+
return (i, l) => p(r, i, l);
|
|
139
174
|
},
|
|
140
|
-
t: (
|
|
175
|
+
t: (r, i) => p("", r, i)
|
|
141
176
|
};
|
|
142
177
|
}
|
|
143
|
-
function
|
|
144
|
-
let
|
|
145
|
-
for (const [
|
|
146
|
-
|
|
147
|
-
return
|
|
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;
|
|
148
183
|
}
|
|
149
|
-
const
|
|
184
|
+
const we = /* @__PURE__ */ M({
|
|
150
185
|
__name: "AdminNav",
|
|
151
186
|
props: {
|
|
152
187
|
collapsed: { type: Boolean }
|
|
153
188
|
},
|
|
154
189
|
emits: ["select"],
|
|
155
|
-
setup(e, { emit:
|
|
156
|
-
const
|
|
157
|
-
get: () =>
|
|
158
|
-
set: (
|
|
159
|
-
const
|
|
160
|
-
|
|
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);
|
|
161
196
|
}
|
|
162
197
|
});
|
|
163
|
-
return (
|
|
164
|
-
const
|
|
165
|
-
return
|
|
166
|
-
modelValue:
|
|
167
|
-
"onUpdate:modelValue":
|
|
198
|
+
return (i, l) => {
|
|
199
|
+
const t = y("wx-menu-item"), a = y("wx-submenu"), c = y("wx-menu");
|
|
200
|
+
return w(), S(c, {
|
|
201
|
+
modelValue: r.value,
|
|
202
|
+
"onUpdate:modelValue": l[0] || (l[0] = (s) => r.value = s),
|
|
168
203
|
collapsed: e.collapsed,
|
|
169
|
-
label: d(
|
|
170
|
-
onSelect:
|
|
204
|
+
label: d(f)("nav.sections"),
|
|
205
|
+
onSelect: l[1] || (l[1] = (s) => o("select"))
|
|
171
206
|
}, {
|
|
172
|
-
default:
|
|
173
|
-
(
|
|
174
|
-
key:
|
|
175
|
-
value:
|
|
176
|
-
icon:
|
|
177
|
-
label:
|
|
178
|
-
}, null, 8, ["value", "icon", "label"]))), 128))
|
|
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
|
|
213
|
+
}, 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,
|
|
218
|
+
icon: "gear"
|
|
219
|
+
}, {
|
|
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
|
|
226
|
+
}, null, 8, ["value", "icon", "label"]))), 128))
|
|
227
|
+
]),
|
|
228
|
+
_: 2
|
|
229
|
+
}, 1032, ["value", "title"]))), 128))
|
|
179
230
|
]),
|
|
180
231
|
_: 1
|
|
181
232
|
}, 8, ["modelValue", "collapsed", "label"]);
|
|
182
233
|
};
|
|
183
234
|
}
|
|
184
|
-
}),
|
|
235
|
+
}), ge = {
|
|
185
236
|
key: 0,
|
|
186
237
|
class: "wx-root wx-admin-plain"
|
|
187
|
-
},
|
|
238
|
+
}, ye = {
|
|
188
239
|
key: 1,
|
|
189
240
|
class: "wx-root wx-admin-plain"
|
|
190
|
-
},
|
|
241
|
+
}, be = {
|
|
191
242
|
key: 2,
|
|
192
243
|
class: "wx-root wx-admin-plain"
|
|
193
|
-
},
|
|
244
|
+
}, xe = /* @__PURE__ */ M({
|
|
194
245
|
__name: "AdminShell",
|
|
195
246
|
setup(e) {
|
|
196
|
-
const
|
|
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, {
|
|
197
248
|
persist: "webx-admin-shell"
|
|
198
249
|
});
|
|
199
|
-
return (
|
|
200
|
-
const
|
|
201
|
-
return
|
|
202
|
-
|
|
203
|
-
d(
|
|
204
|
-
|
|
205
|
-
])) : d(
|
|
206
|
-
|
|
207
|
-
label: d(
|
|
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")
|
|
208
259
|
}, null, 8, ["label"])
|
|
209
|
-
])) : d(
|
|
210
|
-
|
|
260
|
+
])) : d(n).state.status === "error" ? (w(), _("div", be, [
|
|
261
|
+
b(h, {
|
|
211
262
|
status: "error",
|
|
212
|
-
title: d(
|
|
213
|
-
description: d(
|
|
263
|
+
title: d(o)("shell.error-title"),
|
|
264
|
+
description: d(n).state.error
|
|
214
265
|
}, {
|
|
215
|
-
default:
|
|
216
|
-
|
|
266
|
+
default: x(() => [
|
|
267
|
+
b(v, {
|
|
217
268
|
type: "primary",
|
|
218
|
-
onClick:
|
|
269
|
+
onClick: a[0] || (a[0] = (L) => d(n).reload())
|
|
219
270
|
}, {
|
|
220
|
-
default:
|
|
221
|
-
|
|
271
|
+
default: x(() => [
|
|
272
|
+
I(W(d(o)("shell.retry")), 1)
|
|
222
273
|
]),
|
|
223
274
|
_: 1
|
|
224
275
|
})
|
|
225
276
|
]),
|
|
226
277
|
_: 1
|
|
227
278
|
}, 8, ["title", "description"])
|
|
228
|
-
])) : (
|
|
279
|
+
])) : (w(), _("div", {
|
|
229
280
|
key: 3,
|
|
230
281
|
ref_key: "shellEl",
|
|
231
|
-
ref:
|
|
282
|
+
ref: u,
|
|
232
283
|
class: "wx-root wx-admin"
|
|
233
284
|
}, [
|
|
234
|
-
|
|
235
|
-
default:
|
|
236
|
-
|
|
237
|
-
end:
|
|
238
|
-
|
|
285
|
+
b(V, { viewport: "" }, {
|
|
286
|
+
default: x(() => [
|
|
287
|
+
b(K, null, {
|
|
288
|
+
end: x(() => [
|
|
289
|
+
$(t.$slots, "user", {}, void 0, !0)
|
|
239
290
|
]),
|
|
240
|
-
default:
|
|
241
|
-
|
|
242
|
-
icon: d(
|
|
243
|
-
title: d(
|
|
244
|
-
onClick: d(
|
|
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)
|
|
245
296
|
}, null, 8, ["icon", "title", "onClick"]),
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
default:
|
|
249
|
-
|
|
297
|
+
$(t.$slots, "brand", {}, () => [
|
|
298
|
+
b(E, { weight: "semibold" }, {
|
|
299
|
+
default: x(() => [
|
|
300
|
+
I(W(d(n).state.manifest?.title), 1)
|
|
250
301
|
]),
|
|
251
302
|
_: 1
|
|
252
303
|
})
|
|
@@ -254,26 +305,26 @@ const de = /* @__PURE__ */ O({
|
|
|
254
305
|
]),
|
|
255
306
|
_: 3
|
|
256
307
|
}),
|
|
257
|
-
|
|
258
|
-
default:
|
|
259
|
-
d(
|
|
308
|
+
b(V, { direction: "horizontal" }, {
|
|
309
|
+
default: x(() => [
|
|
310
|
+
d(p) ? (w(), S(q, {
|
|
260
311
|
key: 0,
|
|
261
|
-
collapsed: d(
|
|
312
|
+
collapsed: d(m),
|
|
262
313
|
width: 220,
|
|
263
314
|
scroll: ""
|
|
264
315
|
}, {
|
|
265
|
-
default:
|
|
266
|
-
|
|
316
|
+
default: x(() => [
|
|
317
|
+
$(t.$slots, "nav", { collapsed: d(m) }, void 0, !0)
|
|
267
318
|
]),
|
|
268
319
|
_: 3
|
|
269
|
-
}, 8, ["collapsed"])) :
|
|
270
|
-
|
|
320
|
+
}, 8, ["collapsed"])) : J("", !0),
|
|
321
|
+
b(B, {
|
|
271
322
|
padding: "md",
|
|
272
323
|
scroll: "",
|
|
273
324
|
class: "wx-admin__screen"
|
|
274
325
|
}, {
|
|
275
|
-
default:
|
|
276
|
-
|
|
326
|
+
default: x(() => [
|
|
327
|
+
b(c)
|
|
277
328
|
]),
|
|
278
329
|
_: 1
|
|
279
330
|
})
|
|
@@ -283,19 +334,19 @@ const de = /* @__PURE__ */ O({
|
|
|
283
334
|
]),
|
|
284
335
|
_: 3
|
|
285
336
|
}),
|
|
286
|
-
|
|
287
|
-
open: d(
|
|
288
|
-
"onUpdate:open":
|
|
289
|
-
title: d(
|
|
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"),
|
|
290
341
|
side: "left",
|
|
291
342
|
size: 260,
|
|
292
343
|
closable: ""
|
|
293
344
|
}, {
|
|
294
|
-
default:
|
|
295
|
-
|
|
345
|
+
default: x(() => [
|
|
346
|
+
$(t.$slots, "nav", {
|
|
296
347
|
collapsed: !1,
|
|
297
|
-
onSelect:
|
|
298
|
-
(...
|
|
348
|
+
onSelect: a[1] || (a[1] = //@ts-ignore
|
|
349
|
+
(...L) => d(l) && d(l)(...L))
|
|
299
350
|
}, void 0, !0)
|
|
300
351
|
]),
|
|
301
352
|
_: 3
|
|
@@ -304,15 +355,15 @@ const de = /* @__PURE__ */ O({
|
|
|
304
355
|
], 64);
|
|
305
356
|
};
|
|
306
357
|
}
|
|
307
|
-
}),
|
|
308
|
-
const
|
|
309
|
-
for (const [
|
|
310
|
-
|
|
311
|
-
return
|
|
312
|
-
},
|
|
313
|
-
class
|
|
314
|
-
constructor(
|
|
315
|
-
super(
|
|
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";
|
|
316
367
|
}
|
|
317
368
|
status;
|
|
318
369
|
errors;
|
|
@@ -329,86 +380,86 @@ class ge extends Error {
|
|
|
329
380
|
return this.status === 429;
|
|
330
381
|
}
|
|
331
382
|
}
|
|
332
|
-
const
|
|
333
|
-
function
|
|
334
|
-
const
|
|
335
|
-
let
|
|
336
|
-
async function
|
|
337
|
-
|
|
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);
|
|
338
389
|
}
|
|
339
|
-
async function l
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
const
|
|
390
|
+
async function i(l, t, a, c = {}, s = !1) {
|
|
391
|
+
const v = Ee.has(l);
|
|
392
|
+
v && await r();
|
|
393
|
+
const h = {
|
|
343
394
|
Accept: "application/json",
|
|
344
395
|
"X-Requested-With": "XMLHttpRequest",
|
|
345
396
|
// Standing headers first, so a caller can still override one for a single request.
|
|
346
|
-
...
|
|
347
|
-
...
|
|
397
|
+
...m?.(),
|
|
398
|
+
...c.headers
|
|
348
399
|
};
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
|
|
400
|
+
if (v) {
|
|
401
|
+
const E = H("XSRF-TOKEN");
|
|
402
|
+
E !== null && (h["X-XSRF-TOKEN"] = E);
|
|
352
403
|
}
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
method:
|
|
404
|
+
a !== void 0 && (h["Content-Type"] = "application/json");
|
|
405
|
+
const g = await u(Ae(n, t, c.query), {
|
|
406
|
+
method: l,
|
|
356
407
|
credentials: "same-origin",
|
|
357
|
-
headers:
|
|
358
|
-
signal:
|
|
359
|
-
body:
|
|
408
|
+
headers: h,
|
|
409
|
+
signal: c.signal,
|
|
410
|
+
body: a === void 0 ? void 0 : JSON.stringify(a)
|
|
360
411
|
});
|
|
361
|
-
if (
|
|
362
|
-
return await
|
|
363
|
-
if (
|
|
364
|
-
throw await
|
|
365
|
-
if (
|
|
366
|
-
return await
|
|
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();
|
|
367
418
|
}
|
|
368
419
|
return {
|
|
369
|
-
get: (
|
|
370
|
-
post: (
|
|
371
|
-
put: (
|
|
372
|
-
patch: (
|
|
373
|
-
delete: (
|
|
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)
|
|
374
425
|
};
|
|
375
426
|
}
|
|
376
|
-
async function
|
|
377
|
-
let
|
|
427
|
+
async function $e(e) {
|
|
428
|
+
let n = null;
|
|
378
429
|
try {
|
|
379
|
-
|
|
430
|
+
n = await e.json();
|
|
380
431
|
} catch {
|
|
381
432
|
}
|
|
382
|
-
const
|
|
383
|
-
return new
|
|
384
|
-
c,
|
|
385
|
-
e.status,
|
|
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(
|
|
386
435
|
u,
|
|
387
|
-
|
|
388
|
-
|
|
436
|
+
e.status,
|
|
437
|
+
f,
|
|
438
|
+
Number.isFinite(p) ? p : null,
|
|
439
|
+
n
|
|
389
440
|
);
|
|
390
441
|
}
|
|
391
|
-
function
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
return
|
|
395
|
-
const
|
|
396
|
-
for (const [
|
|
397
|
-
|
|
398
|
-
const
|
|
399
|
-
return
|
|
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}`;
|
|
400
451
|
}
|
|
401
|
-
function
|
|
452
|
+
function H(e) {
|
|
402
453
|
if (typeof document > "u")
|
|
403
454
|
return null;
|
|
404
|
-
for (const
|
|
405
|
-
const [
|
|
406
|
-
if (
|
|
407
|
-
return decodeURIComponent(
|
|
455
|
+
for (const n of document.cookie.split(";")) {
|
|
456
|
+
const [o, ...u] = n.trim().split("=");
|
|
457
|
+
if (o === e)
|
|
458
|
+
return decodeURIComponent(u.join("="));
|
|
408
459
|
}
|
|
409
460
|
return null;
|
|
410
461
|
}
|
|
411
|
-
const
|
|
462
|
+
const Ue = {
|
|
412
463
|
shell: {
|
|
413
464
|
loading: "Loading the panel…",
|
|
414
465
|
"error-title": "The panel could not start",
|
|
@@ -422,119 +473,176 @@ const Se = {
|
|
|
422
473
|
collapse: "Collapse the menu",
|
|
423
474
|
language: "Language"
|
|
424
475
|
}
|
|
425
|
-
},
|
|
426
|
-
function
|
|
427
|
-
const
|
|
428
|
-
for (const
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
history:
|
|
432
|
-
routes:
|
|
433
|
-
}),
|
|
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({
|
|
434
485
|
baseUrl: "",
|
|
435
486
|
onUnauthenticated: () => {
|
|
436
|
-
|
|
487
|
+
t.setUser(null), t.state.status = "unauthenticated";
|
|
437
488
|
},
|
|
438
489
|
// Every request says which language the panel is currently showing. It decides what
|
|
439
490
|
// the server writes its own messages in — a 422 under a field — for anybody who has
|
|
440
491
|
// not stored a preference yet, which is everybody until they choose one. Without it,
|
|
441
492
|
// signing in on a Russian sign-in screen lands in an English panel.
|
|
442
|
-
headers: () => ({ "X-Webx-Locale":
|
|
493
|
+
headers: () => ({ "X-Webx-Locale": r.state.locale })
|
|
443
494
|
});
|
|
444
|
-
|
|
445
|
-
async function
|
|
446
|
-
const
|
|
447
|
-
|
|
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);
|
|
448
499
|
}
|
|
449
|
-
const
|
|
450
|
-
http:
|
|
451
|
-
basePath:
|
|
452
|
-
apiPath:
|
|
453
|
-
modules:
|
|
454
|
-
i18n:
|
|
455
|
-
loadDictionary:
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
500
|
+
const t = fe({
|
|
501
|
+
http: i,
|
|
502
|
+
basePath: u,
|
|
503
|
+
apiPath: o,
|
|
504
|
+
modules: f,
|
|
505
|
+
i18n: r,
|
|
506
|
+
loadDictionary: l,
|
|
507
|
+
types: e.types,
|
|
508
|
+
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, {
|
|
514
|
+
list: k(
|
|
515
|
+
() => r.state.contentLocales.map((h) => ({
|
|
516
|
+
code: h.code,
|
|
517
|
+
label: h.code.toUpperCase()
|
|
465
518
|
}))
|
|
466
519
|
),
|
|
467
|
-
active:
|
|
468
|
-
get: () =>
|
|
469
|
-
set: (
|
|
470
|
-
|
|
520
|
+
active: k({
|
|
521
|
+
get: () => c.value || (r.state.contentLocales[0]?.code ?? ""),
|
|
522
|
+
set: (h) => {
|
|
523
|
+
c.value = h;
|
|
471
524
|
}
|
|
472
525
|
})
|
|
473
526
|
});
|
|
474
|
-
const
|
|
475
|
-
app:
|
|
476
|
-
router:
|
|
477
|
-
context:
|
|
478
|
-
i18n:
|
|
527
|
+
const s = {
|
|
528
|
+
app: a,
|
|
529
|
+
router: p,
|
|
530
|
+
context: t,
|
|
531
|
+
i18n: r,
|
|
479
532
|
async mount() {
|
|
480
|
-
await Promise.all([
|
|
481
|
-
}),
|
|
533
|
+
await Promise.all([v(), l(r.state.locale)]).catch(() => {
|
|
534
|
+
}), a.mount(e.el ?? "#webx-app"), await t.reload();
|
|
482
535
|
}
|
|
483
536
|
};
|
|
484
|
-
async function
|
|
485
|
-
const
|
|
486
|
-
|
|
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;
|
|
487
540
|
}
|
|
488
|
-
for (const
|
|
489
|
-
|
|
490
|
-
return
|
|
541
|
+
for (const h of e.plugins ?? [])
|
|
542
|
+
h.install(s);
|
|
543
|
+
return a.use(p), s;
|
|
491
544
|
}
|
|
492
|
-
function
|
|
493
|
-
const
|
|
545
|
+
function Te(e) {
|
|
546
|
+
const n = {
|
|
494
547
|
// The menu is the panel's own: it is the manifest, drawn.
|
|
495
|
-
nav: (
|
|
548
|
+
nav: (o) => A(we, { collapsed: o.collapsed === !0 })
|
|
496
549
|
};
|
|
497
|
-
return e.brand !== void 0 && (
|
|
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) };
|
|
498
551
|
}
|
|
499
|
-
function
|
|
500
|
-
const e =
|
|
552
|
+
function Pe() {
|
|
553
|
+
const e = Re(z);
|
|
501
554
|
return e !== null ? e : typeof document < "u" && document.documentElement.lang !== "" ? document.documentElement.lang : typeof navigator > "u" ? "en" : navigator.language;
|
|
502
555
|
}
|
|
503
|
-
function
|
|
556
|
+
function Ce(e) {
|
|
504
557
|
try {
|
|
505
|
-
localStorage.setItem(
|
|
558
|
+
localStorage.setItem(z, e);
|
|
506
559
|
} catch {
|
|
507
560
|
}
|
|
508
561
|
}
|
|
509
|
-
function
|
|
562
|
+
function Re(e) {
|
|
510
563
|
try {
|
|
511
564
|
return localStorage.getItem(e);
|
|
512
565
|
} catch {
|
|
513
566
|
return null;
|
|
514
567
|
}
|
|
515
568
|
}
|
|
516
|
-
function
|
|
517
|
-
typeof document > "u" || (document.documentElement.lang = e, document.documentElement.dir =
|
|
569
|
+
function Me(e, n) {
|
|
570
|
+
typeof document > "u" || (document.documentElement.lang = e, document.documentElement.dir = n.find((o) => o.code === e)?.direction ?? "ltr");
|
|
518
571
|
}
|
|
519
|
-
function
|
|
572
|
+
function Ne() {
|
|
520
573
|
return typeof document > "u" ? null : document.querySelector('meta[name="webx-manifest"]')?.getAttribute("content") ?? null;
|
|
521
574
|
}
|
|
575
|
+
const Oe = { class: "wx-screen-host" }, Fe = /* @__PURE__ */ M({
|
|
576
|
+
__name: "Screen",
|
|
577
|
+
props: /* @__PURE__ */ D({
|
|
578
|
+
name: {},
|
|
579
|
+
errors: { default: void 0 },
|
|
580
|
+
disabled: { type: Boolean, default: !1 },
|
|
581
|
+
labelPosition: { default: void 0 },
|
|
582
|
+
labelWidth: { default: void 0 },
|
|
583
|
+
size: { default: void 0 }
|
|
584
|
+
}, {
|
|
585
|
+
modelValue: { default: () => ({}) },
|
|
586
|
+
modelModifiers: {}
|
|
587
|
+
}),
|
|
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;
|
|
593
|
+
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);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
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), {
|
|
604
|
+
key: 0,
|
|
605
|
+
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), {
|
|
609
|
+
key: 1,
|
|
610
|
+
rows: 4
|
|
611
|
+
})) : (w(), S(d(de), {
|
|
612
|
+
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,
|
|
618
|
+
errors: e.errors,
|
|
619
|
+
translate: d(p).i18n.t,
|
|
620
|
+
can: d(p).can,
|
|
621
|
+
disabled: e.disabled,
|
|
622
|
+
"label-position": e.labelPosition,
|
|
623
|
+
"label-width": e.labelWidth,
|
|
624
|
+
size: e.size
|
|
625
|
+
}, null, 8, ["modelValue", "root", "patch", "types", "errors", "translate", "can", "disabled", "label-position", "label-width", "size"]))
|
|
626
|
+
]));
|
|
627
|
+
}
|
|
628
|
+
});
|
|
522
629
|
export {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
H as
|
|
537
|
-
|
|
538
|
-
|
|
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
|
|
539
647
|
};
|
|
540
648
|
//# sourceMappingURL=index.js.map
|