@webx-ui/module-menu 0.1.22 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MenusPage-UQffRtpG.js +265 -0
- package/dist/MenusPage-UQffRtpG.js.map +1 -0
- package/dist/index-tmF0XKBt.js +750 -0
- package/dist/index-tmF0XKBt.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -1001
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,750 @@
|
|
|
1
|
+
import { defineComponent as O, resolveComponent as de, openBlock as w, createBlock as k, unref as e, normalizeClass as Q, createSlots as re, withCtx as r, createElementVNode as D, createVNode as c, createTextVNode as I, toDisplayString as C, createCommentVNode as N, createElementBlock as K, Fragment as X, ref as V, computed as E, isRef as ne, useTemplateRef as me, onMounted as ce, nextTick as pe, withKeys as Y, defineAsyncComponent as fe } from "vue";
|
|
2
|
+
import { WxSortableList as he, WxText as L, WxTooltip as Z, WxIcon as q, useModal as le, useLocales as ve, WxDialog as ae, WxFormItem as z, WxInput as H, WxSelect as ee, WxCheckbox as be, WxSwitch as ye, WxSpace as ie, WxButton as A, createModal as ge, WxAction as we, WxSkeleton as _e, WxEmpty as ke, toast as T, confirm as xe } from "@webx-ui/core";
|
|
3
|
+
import { useTranslate as P, WxRowMenu as Ie, useAdmin as j, emptyLink as Ce, WxLinkPicker as $e, useErrorText as Ve } from "@webx-ui/module-admin";
|
|
4
|
+
function Fe(i = {}) {
|
|
5
|
+
const n = i.path ?? "/menus";
|
|
6
|
+
return {
|
|
7
|
+
id: "menu",
|
|
8
|
+
path: n,
|
|
9
|
+
routes: [{ path: n, name: "webx.menus", component: () => import("./MenusPage-UQffRtpG.js") }]
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function ue(i) {
|
|
13
|
+
const n = `${i.apiPath}/menus`, u = (t) => t.data;
|
|
14
|
+
return {
|
|
15
|
+
list: () => i.http.get(n).then(u),
|
|
16
|
+
create: (t) => i.http.post(n, t).then(u),
|
|
17
|
+
update: (t, l) => i.http.patch(`${n}/${encodeURIComponent(t)}`, l).then(u),
|
|
18
|
+
remove: (t) => i.http.delete(`${n}/${encodeURIComponent(t)}`).then(() => {
|
|
19
|
+
}),
|
|
20
|
+
items: (t) => i.http.get(`${n}/${encodeURIComponent(t)}/items`).then(u),
|
|
21
|
+
addItem: (t, l) => i.http.post(`${n}/${encodeURIComponent(t)}/items`, l).then(u),
|
|
22
|
+
saveItem: (t, l, v) => i.http.patch(`${n}/${encodeURIComponent(t)}/items/${l}`, v).then(u),
|
|
23
|
+
moveItem: (t, l, v, o) => i.http.post(`${n}/${encodeURIComponent(t)}/items/${l}/move`, {
|
|
24
|
+
parent_id: v,
|
|
25
|
+
index: o
|
|
26
|
+
}).then(() => {
|
|
27
|
+
}),
|
|
28
|
+
removeItem: (t, l) => i.http.delete(`${n}/${encodeURIComponent(t)}/items/${l}`).then((v) => v.data.deleted),
|
|
29
|
+
flush: (t) => i.http.post(`${n}/${encodeURIComponent(t)}/cache/flush`, {}).then(() => {
|
|
30
|
+
}),
|
|
31
|
+
flushAll: () => i.http.post(`${n}/cache/flush`, {}).then(() => {
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const We = {
|
|
36
|
+
module: {
|
|
37
|
+
title: "Menus"
|
|
38
|
+
},
|
|
39
|
+
menu: {
|
|
40
|
+
menus: "Menus",
|
|
41
|
+
"new-menu": "New menu",
|
|
42
|
+
"new-menu-title": "New menu",
|
|
43
|
+
"field-key": "Key",
|
|
44
|
+
"key-help": "What a template calls it by: menu('header').",
|
|
45
|
+
"field-name": "Name",
|
|
46
|
+
create: "Create",
|
|
47
|
+
cancel: "Cancel",
|
|
48
|
+
save: "Save",
|
|
49
|
+
rename: "Rename",
|
|
50
|
+
"rename-title": "Rename menu",
|
|
51
|
+
renamed: "Menu saved",
|
|
52
|
+
delete: "Delete",
|
|
53
|
+
"delete-menu-title": "Delete “:menu”?",
|
|
54
|
+
"delete-menu-text": "The menu goes, and every item in it. Nothing it points at is touched.",
|
|
55
|
+
deleted: "Menu deleted",
|
|
56
|
+
declared: "A template of this site asks for it",
|
|
57
|
+
"no-menus": "No menus yet.",
|
|
58
|
+
"no-menus-help": "A menu is declared in the configuration, or made here.",
|
|
59
|
+
"choose-menu": "Choose a menu",
|
|
60
|
+
"choose-menu-help": "Its items are arranged on the right.",
|
|
61
|
+
back: "Back",
|
|
62
|
+
"new-item": "New item",
|
|
63
|
+
"item-title": "Menu item",
|
|
64
|
+
"empty-tree": "Nothing in this menu yet.",
|
|
65
|
+
"empty-tree-help": "An item points at a page, at an address of your own, or at nothing.",
|
|
66
|
+
edit: "Edit",
|
|
67
|
+
duplicate: "Duplicate",
|
|
68
|
+
duplicated: "Item duplicated",
|
|
69
|
+
"delete-item-title": "Delete “:item”?",
|
|
70
|
+
"delete-item-text": "Only this item goes.",
|
|
71
|
+
"delete-item-branch": "Items that go with it: :count.",
|
|
72
|
+
"item-deleted": "Item deleted",
|
|
73
|
+
"item-saved": "Item saved",
|
|
74
|
+
"move-failed": "The item could not be moved.",
|
|
75
|
+
"untitled-item": "Untitled",
|
|
76
|
+
heading: "Heading",
|
|
77
|
+
"goes-nowhere": "Goes nowhere",
|
|
78
|
+
unavailable: "Not on the site",
|
|
79
|
+
hidden: "Hidden",
|
|
80
|
+
external: "An address off this site",
|
|
81
|
+
"new-tab": "Opens in a new tab",
|
|
82
|
+
"missing-target": "What this pointed at is gone",
|
|
83
|
+
"field-label": "Label",
|
|
84
|
+
"label-help": "Left empty, the item is called what the thing it points at is called.",
|
|
85
|
+
"field-where": "Where it goes",
|
|
86
|
+
"field-variant": "Look",
|
|
87
|
+
"field-heading": "A heading for the items under it",
|
|
88
|
+
"heading-help": "Drawn as a caption. It may still be a link.",
|
|
89
|
+
"field-visible": "Shown on the site",
|
|
90
|
+
"field-locales": "Languages",
|
|
91
|
+
"locales-all": "Every language",
|
|
92
|
+
"locales-help": "None chosen means every language.",
|
|
93
|
+
"cache-built": "Cache built",
|
|
94
|
+
"cache-empty": "Cache not built",
|
|
95
|
+
"cache-off": "Cache off",
|
|
96
|
+
flush: "Reset the cache of this menu",
|
|
97
|
+
"flush-all": "Reset every menu",
|
|
98
|
+
flushed: "Cache reset"
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
function G(i, n) {
|
|
102
|
+
for (const u of i) {
|
|
103
|
+
if (u.id === n) return u;
|
|
104
|
+
const t = G(u.children, n);
|
|
105
|
+
if (t !== null) return t;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
function oe(i) {
|
|
110
|
+
return i.children.reduce((n, u) => n + 1 + oe(u), 0);
|
|
111
|
+
}
|
|
112
|
+
function Me(i, n) {
|
|
113
|
+
const u = n.find((t) => !i.includes(t));
|
|
114
|
+
if (u !== void 0) return u;
|
|
115
|
+
if (n.length !== i.length) return null;
|
|
116
|
+
for (const t of n) {
|
|
117
|
+
if (n.indexOf(t) === i.indexOf(t)) continue;
|
|
118
|
+
const l = n.filter((o) => o !== t), v = i.filter((o) => o !== t);
|
|
119
|
+
if (l.length === v.length && l.every((o, s) => o === v[s]))
|
|
120
|
+
return t;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const Ue = ["disabled", "onClick"], Re = { class: "wx-menu-item__line" }, Te = /* @__PURE__ */ O({
|
|
125
|
+
name: "WxMenuBranch",
|
|
126
|
+
__name: "MenuBranch",
|
|
127
|
+
props: {
|
|
128
|
+
items: {},
|
|
129
|
+
parentId: { default: null },
|
|
130
|
+
disabled: { type: Boolean, default: !1 }
|
|
131
|
+
},
|
|
132
|
+
emits: ["reorder", "edit", "duplicate", "remove"],
|
|
133
|
+
setup(i, { emit: n }) {
|
|
134
|
+
const u = i, t = n, l = P("webx-menu");
|
|
135
|
+
function v(d) {
|
|
136
|
+
return d.label === "" ? l("menu.untitled-item") : d.label;
|
|
137
|
+
}
|
|
138
|
+
function o(d) {
|
|
139
|
+
return d.target === "none" ? l("menu.goes-nowhere") : d.target === "entity" && d.resolved === null ? l("menu.missing-target") : d.href ?? l("menu.goes-nowhere");
|
|
140
|
+
}
|
|
141
|
+
function s(d) {
|
|
142
|
+
return d.target === "url" && /^[a-z][a-z0-9+.-]*:/i.test(d.url ?? "");
|
|
143
|
+
}
|
|
144
|
+
function y(d) {
|
|
145
|
+
return u.disabled ? [] : [
|
|
146
|
+
{ key: "edit", icon: "edit", label: l("menu.edit"), run: () => t("edit", d) },
|
|
147
|
+
{
|
|
148
|
+
key: "duplicate",
|
|
149
|
+
icon: "copy",
|
|
150
|
+
label: l("menu.duplicate"),
|
|
151
|
+
run: () => t("duplicate", d)
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
key: "delete",
|
|
155
|
+
icon: "trash",
|
|
156
|
+
label: l("menu.delete"),
|
|
157
|
+
danger: !0,
|
|
158
|
+
run: () => t("remove", d)
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
}
|
|
162
|
+
return (d, p) => {
|
|
163
|
+
const x = de("wx-menu-branch");
|
|
164
|
+
return w(), k(e(he), {
|
|
165
|
+
class: Q(["wx-menu-branch", { "is-nested": u.parentId !== null }]),
|
|
166
|
+
"model-value": u.items,
|
|
167
|
+
plain: "",
|
|
168
|
+
size: "sm",
|
|
169
|
+
group: "wx-menu-items",
|
|
170
|
+
"item-key": "id",
|
|
171
|
+
"item-label": v,
|
|
172
|
+
disabled: u.disabled,
|
|
173
|
+
"empty-text": "",
|
|
174
|
+
"onUpdate:modelValue": p[4] || (p[4] = (m) => t("reorder", u.parentId, m))
|
|
175
|
+
}, re({
|
|
176
|
+
empty: r(() => [
|
|
177
|
+
p[5] || (p[5] = D("span", { class: "wx-menu-branch__drop" }, null, -1))
|
|
178
|
+
]),
|
|
179
|
+
default: r(({ item: m }) => [
|
|
180
|
+
D("div", {
|
|
181
|
+
class: Q(["wx-menu-item", { "is-off": !m.visible || !m.available }])
|
|
182
|
+
}, [
|
|
183
|
+
D("button", {
|
|
184
|
+
type: "button",
|
|
185
|
+
class: "wx-menu-item__open",
|
|
186
|
+
disabled: u.disabled,
|
|
187
|
+
onClick: (f) => t("edit", m)
|
|
188
|
+
}, [
|
|
189
|
+
D("span", Re, [
|
|
190
|
+
c(e(L), {
|
|
191
|
+
truncate: "",
|
|
192
|
+
weight: m.is_heading ? "semibold" : "medium"
|
|
193
|
+
}, {
|
|
194
|
+
default: r(() => [
|
|
195
|
+
I(C(v(m)), 1)
|
|
196
|
+
]),
|
|
197
|
+
_: 2
|
|
198
|
+
}, 1032, ["weight"]),
|
|
199
|
+
s(m) ? (w(), k(e(Z), {
|
|
200
|
+
key: 0,
|
|
201
|
+
content: e(l)("menu.external")
|
|
202
|
+
}, {
|
|
203
|
+
default: r(() => [
|
|
204
|
+
c(e(q), {
|
|
205
|
+
class: "wx-menu-item__mark",
|
|
206
|
+
name: "link",
|
|
207
|
+
label: e(l)("menu.external")
|
|
208
|
+
}, null, 8, ["label"])
|
|
209
|
+
]),
|
|
210
|
+
_: 1
|
|
211
|
+
}, 8, ["content"])) : N("", !0),
|
|
212
|
+
m.new_tab ? (w(), k(e(Z), {
|
|
213
|
+
key: 1,
|
|
214
|
+
content: e(l)("menu.new-tab")
|
|
215
|
+
}, {
|
|
216
|
+
default: r(() => [
|
|
217
|
+
c(e(q), {
|
|
218
|
+
class: "wx-menu-item__mark",
|
|
219
|
+
name: "external-link",
|
|
220
|
+
label: e(l)("menu.new-tab")
|
|
221
|
+
}, null, 8, ["label"])
|
|
222
|
+
]),
|
|
223
|
+
_: 1
|
|
224
|
+
}, 8, ["content"])) : N("", !0)
|
|
225
|
+
]),
|
|
226
|
+
c(e(L), {
|
|
227
|
+
size: "sm",
|
|
228
|
+
tone: "muted",
|
|
229
|
+
truncate: ""
|
|
230
|
+
}, {
|
|
231
|
+
default: r(() => [
|
|
232
|
+
m.is_heading ? (w(), K(X, { key: 0 }, [
|
|
233
|
+
I(C(e(l)("menu.heading")), 1)
|
|
234
|
+
], 64)) : (w(), K(X, { key: 1 }, [
|
|
235
|
+
I(C(o(m)), 1)
|
|
236
|
+
], 64))
|
|
237
|
+
]),
|
|
238
|
+
_: 2
|
|
239
|
+
}, 1024)
|
|
240
|
+
], 8, Ue),
|
|
241
|
+
m.visible ? m.available ? N("", !0) : (w(), k(e(L), {
|
|
242
|
+
key: 1,
|
|
243
|
+
class: "wx-menu-item__state",
|
|
244
|
+
size: "sm",
|
|
245
|
+
tone: "warning"
|
|
246
|
+
}, {
|
|
247
|
+
default: r(() => [
|
|
248
|
+
I(C(e(l)("menu.unavailable")), 1)
|
|
249
|
+
]),
|
|
250
|
+
_: 1
|
|
251
|
+
})) : (w(), k(e(L), {
|
|
252
|
+
key: 0,
|
|
253
|
+
class: "wx-menu-item__state",
|
|
254
|
+
size: "sm",
|
|
255
|
+
tone: "muted"
|
|
256
|
+
}, {
|
|
257
|
+
default: r(() => [
|
|
258
|
+
I(C(e(l)("menu.hidden")), 1)
|
|
259
|
+
]),
|
|
260
|
+
_: 1
|
|
261
|
+
}))
|
|
262
|
+
], 2),
|
|
263
|
+
c(x, {
|
|
264
|
+
items: m.children,
|
|
265
|
+
"parent-id": m.id,
|
|
266
|
+
disabled: u.disabled,
|
|
267
|
+
onReorder: p[0] || (p[0] = (f, W) => t("reorder", f, W)),
|
|
268
|
+
onEdit: p[1] || (p[1] = (f) => t("edit", f)),
|
|
269
|
+
onDuplicate: p[2] || (p[2] = (f) => t("duplicate", f)),
|
|
270
|
+
onRemove: p[3] || (p[3] = (f) => t("remove", f))
|
|
271
|
+
}, null, 8, ["items", "parent-id", "disabled"])
|
|
272
|
+
]),
|
|
273
|
+
_: 2
|
|
274
|
+
}, [
|
|
275
|
+
u.disabled ? void 0 : {
|
|
276
|
+
name: "actions",
|
|
277
|
+
fn: r(({ item: m }) => [
|
|
278
|
+
c(e(Ie), {
|
|
279
|
+
actions: y(m),
|
|
280
|
+
label: v(m)
|
|
281
|
+
}, null, 8, ["actions", "label"])
|
|
282
|
+
]),
|
|
283
|
+
key: "0"
|
|
284
|
+
}
|
|
285
|
+
]), 1032, ["class", "model-value", "disabled"]);
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}), se = (i, n) => {
|
|
289
|
+
const u = i.__vccOpts || i;
|
|
290
|
+
for (const [t, l] of n)
|
|
291
|
+
u[t] = l;
|
|
292
|
+
return u;
|
|
293
|
+
}, ze = /* @__PURE__ */ se(Te, [["__scopeId", "data-v-fdb72572"]]), te = /* @__PURE__ */ new WeakSet();
|
|
294
|
+
function J() {
|
|
295
|
+
try {
|
|
296
|
+
const { i18n: i } = j();
|
|
297
|
+
te.has(i) || (i.defaults("webx-menu", We), te.add(i));
|
|
298
|
+
} catch {
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const De = /* @__PURE__ */ O({
|
|
302
|
+
name: "WxMenuItemDialog",
|
|
303
|
+
__name: "MenuItemDialog",
|
|
304
|
+
props: {
|
|
305
|
+
menu: {},
|
|
306
|
+
item: { default: null }
|
|
307
|
+
},
|
|
308
|
+
setup(i) {
|
|
309
|
+
const n = i, { open: u, resolve: t, dismiss: l } = le(), v = ve();
|
|
310
|
+
J();
|
|
311
|
+
const o = P("webx-menu"), s = V(n.item === null ? Ce() : $(n.item)), y = V({ ...n.item?.title ?? {} }), d = V(n.item?.variant ?? n.menu.variants[0] ?? "link"), p = V(n.item?.is_heading ?? !1), x = V(n.item?.visible ?? !0), m = V([...n.item?.locales ?? []]), f = E(() => n.item?.resolved?.title ?? ""), W = E(
|
|
312
|
+
() => n.menu.variants.map((g) => ({ value: g, label: g }))
|
|
313
|
+
), M = E(
|
|
314
|
+
() => v.list.value.map((g) => ({ value: g.code, label: g.label ?? g.code }))
|
|
315
|
+
);
|
|
316
|
+
function $(g) {
|
|
317
|
+
return {
|
|
318
|
+
target: g.target,
|
|
319
|
+
entity_type: g.entity_type,
|
|
320
|
+
entity_id: g.entity_id,
|
|
321
|
+
url: g.url,
|
|
322
|
+
hash: g.hash,
|
|
323
|
+
new_tab: g.new_tab,
|
|
324
|
+
rel: g.rel
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function U() {
|
|
328
|
+
t({
|
|
329
|
+
title: y.value,
|
|
330
|
+
link: s.value,
|
|
331
|
+
variant: d.value,
|
|
332
|
+
is_heading: p.value,
|
|
333
|
+
locales: m.value,
|
|
334
|
+
visible: x.value
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
return (g, b) => (w(), k(e(ae), {
|
|
338
|
+
open: e(u),
|
|
339
|
+
"onUpdate:open": b[7] || (b[7] = (_) => ne(u) ? u.value = _ : null),
|
|
340
|
+
title: e(o)("menu.item-title"),
|
|
341
|
+
width: 520
|
|
342
|
+
}, {
|
|
343
|
+
footer: r(() => [
|
|
344
|
+
c(e(ie), { size: "sm" }, {
|
|
345
|
+
default: r(() => [
|
|
346
|
+
c(e(A), {
|
|
347
|
+
variant: "outline",
|
|
348
|
+
onClick: b[6] || (b[6] = (_) => e(l)())
|
|
349
|
+
}, {
|
|
350
|
+
default: r(() => [
|
|
351
|
+
I(C(e(o)("menu.cancel")), 1)
|
|
352
|
+
]),
|
|
353
|
+
_: 1
|
|
354
|
+
}),
|
|
355
|
+
c(e(A), {
|
|
356
|
+
type: "primary",
|
|
357
|
+
onClick: U
|
|
358
|
+
}, {
|
|
359
|
+
default: r(() => [
|
|
360
|
+
I(C(e(o)("menu.save")), 1)
|
|
361
|
+
]),
|
|
362
|
+
_: 1
|
|
363
|
+
})
|
|
364
|
+
]),
|
|
365
|
+
_: 1
|
|
366
|
+
})
|
|
367
|
+
]),
|
|
368
|
+
default: r(() => [
|
|
369
|
+
c(e(z), {
|
|
370
|
+
label: e(o)("menu.field-where")
|
|
371
|
+
}, {
|
|
372
|
+
default: r(() => [
|
|
373
|
+
c(e($e), {
|
|
374
|
+
modelValue: s.value,
|
|
375
|
+
"onUpdate:modelValue": b[0] || (b[0] = (_) => s.value = _)
|
|
376
|
+
}, null, 8, ["modelValue"])
|
|
377
|
+
]),
|
|
378
|
+
_: 1
|
|
379
|
+
}, 8, ["label"]),
|
|
380
|
+
c(e(z), {
|
|
381
|
+
label: e(o)("menu.field-label"),
|
|
382
|
+
help: e(o)("menu.label-help")
|
|
383
|
+
}, {
|
|
384
|
+
default: r(() => [
|
|
385
|
+
c(e(H), {
|
|
386
|
+
modelValue: y.value,
|
|
387
|
+
"onUpdate:modelValue": b[1] || (b[1] = (_) => y.value = _),
|
|
388
|
+
localized: "",
|
|
389
|
+
placeholder: f.value,
|
|
390
|
+
"aria-label": e(o)("menu.field-label")
|
|
391
|
+
}, null, 8, ["modelValue", "placeholder", "aria-label"])
|
|
392
|
+
]),
|
|
393
|
+
_: 1
|
|
394
|
+
}, 8, ["label", "help"]),
|
|
395
|
+
W.value.length > 1 ? (w(), k(e(z), {
|
|
396
|
+
key: 0,
|
|
397
|
+
label: e(o)("menu.field-variant")
|
|
398
|
+
}, {
|
|
399
|
+
default: r(() => [
|
|
400
|
+
c(e(ee), {
|
|
401
|
+
modelValue: d.value,
|
|
402
|
+
"onUpdate:modelValue": b[2] || (b[2] = (_) => d.value = _),
|
|
403
|
+
options: W.value,
|
|
404
|
+
"aria-label": e(o)("menu.field-variant")
|
|
405
|
+
}, null, 8, ["modelValue", "options", "aria-label"])
|
|
406
|
+
]),
|
|
407
|
+
_: 1
|
|
408
|
+
}, 8, ["label"])) : N("", !0),
|
|
409
|
+
M.value.length > 1 ? (w(), k(e(z), {
|
|
410
|
+
key: 1,
|
|
411
|
+
label: e(o)("menu.field-locales"),
|
|
412
|
+
help: e(o)("menu.locales-help")
|
|
413
|
+
}, {
|
|
414
|
+
default: r(() => [
|
|
415
|
+
c(e(ee), {
|
|
416
|
+
modelValue: m.value,
|
|
417
|
+
"onUpdate:modelValue": b[3] || (b[3] = (_) => m.value = _),
|
|
418
|
+
options: M.value,
|
|
419
|
+
multiple: "",
|
|
420
|
+
clearable: "",
|
|
421
|
+
placeholder: e(o)("menu.locales-all"),
|
|
422
|
+
"aria-label": e(o)("menu.field-locales")
|
|
423
|
+
}, null, 8, ["modelValue", "options", "placeholder", "aria-label"])
|
|
424
|
+
]),
|
|
425
|
+
_: 1
|
|
426
|
+
}, 8, ["label", "help"])) : N("", !0),
|
|
427
|
+
c(e(z), {
|
|
428
|
+
help: e(o)("menu.heading-help")
|
|
429
|
+
}, {
|
|
430
|
+
default: r(() => [
|
|
431
|
+
c(e(be), {
|
|
432
|
+
modelValue: p.value,
|
|
433
|
+
"onUpdate:modelValue": b[4] || (b[4] = (_) => p.value = _)
|
|
434
|
+
}, {
|
|
435
|
+
default: r(() => [
|
|
436
|
+
I(C(e(o)("menu.field-heading")), 1)
|
|
437
|
+
]),
|
|
438
|
+
_: 1
|
|
439
|
+
}, 8, ["modelValue"])
|
|
440
|
+
]),
|
|
441
|
+
_: 1
|
|
442
|
+
}, 8, ["help"]),
|
|
443
|
+
c(e(z), null, {
|
|
444
|
+
default: r(() => [
|
|
445
|
+
c(e(ye), {
|
|
446
|
+
modelValue: x.value,
|
|
447
|
+
"onUpdate:modelValue": b[5] || (b[5] = (_) => x.value = _),
|
|
448
|
+
label: e(o)("menu.field-visible")
|
|
449
|
+
}, null, 8, ["modelValue", "label"])
|
|
450
|
+
]),
|
|
451
|
+
_: 1
|
|
452
|
+
})
|
|
453
|
+
]),
|
|
454
|
+
_: 1
|
|
455
|
+
}, 8, ["open", "title"]));
|
|
456
|
+
}
|
|
457
|
+
}), Ne = { class: "wx-menu-pane" }, Be = { class: "wx-menu-pane__head" }, Le = { class: "wx-menu-pane__name" }, Se = { class: "wx-menu-pane__body" }, Ae = /* @__PURE__ */ O({
|
|
458
|
+
name: "WxMenuTreePane",
|
|
459
|
+
__name: "MenuTreePane",
|
|
460
|
+
props: {
|
|
461
|
+
menu: {},
|
|
462
|
+
inline: { type: Boolean, default: !0 },
|
|
463
|
+
back: { type: Function, default: void 0 }
|
|
464
|
+
},
|
|
465
|
+
emits: ["changed"],
|
|
466
|
+
setup(i, { expose: n, emit: u }) {
|
|
467
|
+
const t = i, l = u, v = j(), o = ue(v);
|
|
468
|
+
J();
|
|
469
|
+
const s = P("webx-menu"), y = Ve(), d = V([]), p = V(!0), x = E(() => v.can("menu.manage")), m = ge(De);
|
|
470
|
+
async function f() {
|
|
471
|
+
p.value = !0;
|
|
472
|
+
try {
|
|
473
|
+
d.value = await o.items(t.menu.key);
|
|
474
|
+
} catch (a) {
|
|
475
|
+
T.danger(y(a));
|
|
476
|
+
} finally {
|
|
477
|
+
p.value = !1;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
f();
|
|
481
|
+
function W(a) {
|
|
482
|
+
return a === null ? d.value : G(d.value, a)?.children ?? [];
|
|
483
|
+
}
|
|
484
|
+
function M(a, h) {
|
|
485
|
+
if (a === null) {
|
|
486
|
+
d.value = h;
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const R = G(d.value, a);
|
|
490
|
+
R !== null && (R.children = h);
|
|
491
|
+
}
|
|
492
|
+
async function $(a, h) {
|
|
493
|
+
const R = W(a).map((S) => S.id);
|
|
494
|
+
M(a, h);
|
|
495
|
+
const B = h.map((S) => S.id), F = Me(R, B);
|
|
496
|
+
if (F !== null)
|
|
497
|
+
try {
|
|
498
|
+
await o.moveItem(t.menu.key, F, a, B.indexOf(F)), l("changed");
|
|
499
|
+
} catch (S) {
|
|
500
|
+
T.danger(y(S, s("menu.move-failed"))), await f();
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
async function U() {
|
|
504
|
+
const a = await m({ menu: t.menu, item: null });
|
|
505
|
+
if (a)
|
|
506
|
+
try {
|
|
507
|
+
await o.addItem(t.menu.key, a), T.success(s("menu.item-saved")), await f(), l("changed");
|
|
508
|
+
} catch (h) {
|
|
509
|
+
T.danger(y(h));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
async function g(a) {
|
|
513
|
+
const h = await m({ menu: t.menu, item: a });
|
|
514
|
+
if (h)
|
|
515
|
+
try {
|
|
516
|
+
await o.saveItem(t.menu.key, a.id, h), T.success(s("menu.item-saved")), await f(), l("changed");
|
|
517
|
+
} catch (R) {
|
|
518
|
+
T.danger(y(R));
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
async function b(a) {
|
|
522
|
+
try {
|
|
523
|
+
const h = await o.addItem(t.menu.key, {
|
|
524
|
+
title: a.title,
|
|
525
|
+
link: {
|
|
526
|
+
target: a.target,
|
|
527
|
+
entity_type: a.entity_type,
|
|
528
|
+
entity_id: a.entity_id,
|
|
529
|
+
url: a.url,
|
|
530
|
+
hash: a.hash,
|
|
531
|
+
new_tab: a.new_tab,
|
|
532
|
+
rel: a.rel
|
|
533
|
+
},
|
|
534
|
+
variant: a.variant,
|
|
535
|
+
is_heading: a.is_heading,
|
|
536
|
+
locales: a.locales,
|
|
537
|
+
visible: a.visible,
|
|
538
|
+
parent_id: a.parent_id
|
|
539
|
+
}), R = W(a.parent_id);
|
|
540
|
+
await o.moveItem(
|
|
541
|
+
t.menu.key,
|
|
542
|
+
h.id,
|
|
543
|
+
a.parent_id,
|
|
544
|
+
R.findIndex((B) => B.id === a.id) + 1
|
|
545
|
+
), T.success(s("menu.duplicated")), await f(), l("changed");
|
|
546
|
+
} catch (h) {
|
|
547
|
+
T.danger(y(h));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
async function _(a) {
|
|
551
|
+
const h = oe(a);
|
|
552
|
+
if (await xe({
|
|
553
|
+
title: s("menu.delete-item-title", { item: a.label || s("menu.untitled-item") }),
|
|
554
|
+
message: h === 0 ? s("menu.delete-item-text") : s("menu.delete-item-branch", { count: h }),
|
|
555
|
+
confirmText: s("menu.delete"),
|
|
556
|
+
cancelText: s("menu.cancel"),
|
|
557
|
+
tone: "danger"
|
|
558
|
+
}))
|
|
559
|
+
try {
|
|
560
|
+
await o.removeItem(t.menu.key, a.id), T.success(s("menu.item-deleted")), await f(), l("changed");
|
|
561
|
+
} catch (B) {
|
|
562
|
+
T.danger(y(B));
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
return n({ reload: f }), (a, h) => (w(), K("div", Ne, [
|
|
566
|
+
D("header", Be, [
|
|
567
|
+
t.inline ? N("", !0) : (w(), k(e(we), {
|
|
568
|
+
key: 0,
|
|
569
|
+
icon: "arrow-left",
|
|
570
|
+
size: "sm",
|
|
571
|
+
title: e(s)("menu.back"),
|
|
572
|
+
onClick: h[0] || (h[0] = (R) => t.back?.())
|
|
573
|
+
}, null, 8, ["title"])),
|
|
574
|
+
D("div", Le, [
|
|
575
|
+
c(e(L), {
|
|
576
|
+
weight: "semibold",
|
|
577
|
+
truncate: ""
|
|
578
|
+
}, {
|
|
579
|
+
default: r(() => [
|
|
580
|
+
I(C(t.menu.title), 1)
|
|
581
|
+
]),
|
|
582
|
+
_: 1
|
|
583
|
+
}),
|
|
584
|
+
c(e(L), {
|
|
585
|
+
size: "sm",
|
|
586
|
+
tone: "muted",
|
|
587
|
+
mono: "",
|
|
588
|
+
truncate: ""
|
|
589
|
+
}, {
|
|
590
|
+
default: r(() => [
|
|
591
|
+
I(C(t.menu.key), 1)
|
|
592
|
+
]),
|
|
593
|
+
_: 1
|
|
594
|
+
})
|
|
595
|
+
]),
|
|
596
|
+
x.value ? (w(), k(e(A), {
|
|
597
|
+
key: 1,
|
|
598
|
+
variant: "outline",
|
|
599
|
+
size: "sm",
|
|
600
|
+
onClick: U
|
|
601
|
+
}, {
|
|
602
|
+
icon: r(() => [
|
|
603
|
+
c(e(q), { name: "plus" })
|
|
604
|
+
]),
|
|
605
|
+
default: r(() => [
|
|
606
|
+
I(" " + C(e(s)("menu.new-item")), 1)
|
|
607
|
+
]),
|
|
608
|
+
_: 1
|
|
609
|
+
})) : N("", !0)
|
|
610
|
+
]),
|
|
611
|
+
D("div", Se, [
|
|
612
|
+
p.value ? (w(), k(e(_e), {
|
|
613
|
+
key: 0,
|
|
614
|
+
rows: 5
|
|
615
|
+
})) : d.value.length === 0 ? (w(), k(e(ke), {
|
|
616
|
+
key: 1,
|
|
617
|
+
title: e(s)("menu.empty-tree"),
|
|
618
|
+
description: e(s)("menu.empty-tree-help")
|
|
619
|
+
}, null, 8, ["title", "description"])) : (w(), k(ze, {
|
|
620
|
+
key: 2,
|
|
621
|
+
items: d.value,
|
|
622
|
+
disabled: !x.value,
|
|
623
|
+
onReorder: $,
|
|
624
|
+
onEdit: g,
|
|
625
|
+
onDuplicate: b,
|
|
626
|
+
onRemove: _
|
|
627
|
+
}, null, 8, ["items", "disabled"]))
|
|
628
|
+
])
|
|
629
|
+
]));
|
|
630
|
+
}
|
|
631
|
+
}), Ke = /* @__PURE__ */ se(Ae, [["__scopeId", "data-v-7c72f6db"]]), qe = /* @__PURE__ */ O({
|
|
632
|
+
name: "WxMenuCreateDialog",
|
|
633
|
+
__name: "MenuCreateDialog",
|
|
634
|
+
props: {
|
|
635
|
+
menu: { default: null }
|
|
636
|
+
},
|
|
637
|
+
setup(i) {
|
|
638
|
+
const n = i, { open: u, resolve: t, dismiss: l } = le(), v = j(), o = ue(v);
|
|
639
|
+
J();
|
|
640
|
+
const s = P("webx-menu"), y = n.menu !== null, d = V(n.menu?.key ?? ""), p = V(n.menu?.title ?? ""), x = V(!1), m = V({}), f = me("field");
|
|
641
|
+
ce(async () => {
|
|
642
|
+
await pe(), f.value?.querySelector("input")?.focus();
|
|
643
|
+
});
|
|
644
|
+
async function W() {
|
|
645
|
+
if (!(p.value.trim() === "" || x.value)) {
|
|
646
|
+
x.value = !0, m.value = {};
|
|
647
|
+
try {
|
|
648
|
+
const M = { key: d.value.trim(), title: p.value.trim() };
|
|
649
|
+
t(
|
|
650
|
+
y && n.menu !== null ? await o.update(n.menu.key, n.menu.can.rename ? M : { title: M.title }) : await o.create(M)
|
|
651
|
+
);
|
|
652
|
+
} catch (M) {
|
|
653
|
+
m.value = M.body?.errors ?? {};
|
|
654
|
+
} finally {
|
|
655
|
+
x.value = !1;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return (M, $) => (w(), k(e(ae), {
|
|
660
|
+
open: e(u),
|
|
661
|
+
"onUpdate:open": $[3] || ($[3] = (U) => ne(u) ? u.value = U : null),
|
|
662
|
+
title: y ? e(s)("menu.rename-title") : e(s)("menu.new-menu-title"),
|
|
663
|
+
width: 440
|
|
664
|
+
}, {
|
|
665
|
+
footer: r(() => [
|
|
666
|
+
c(e(ie), { size: "sm" }, {
|
|
667
|
+
default: r(() => [
|
|
668
|
+
c(e(A), {
|
|
669
|
+
variant: "outline",
|
|
670
|
+
onClick: $[2] || ($[2] = (U) => e(l)())
|
|
671
|
+
}, {
|
|
672
|
+
default: r(() => [
|
|
673
|
+
I(C(e(s)("menu.cancel")), 1)
|
|
674
|
+
]),
|
|
675
|
+
_: 1
|
|
676
|
+
}),
|
|
677
|
+
c(e(A), {
|
|
678
|
+
type: "primary",
|
|
679
|
+
loading: x.value,
|
|
680
|
+
disabled: p.value.trim() === "" || d.value.trim() === "",
|
|
681
|
+
onClick: W
|
|
682
|
+
}, {
|
|
683
|
+
default: r(() => [
|
|
684
|
+
I(C(y ? e(s)("menu.save") : e(s)("menu.create")), 1)
|
|
685
|
+
]),
|
|
686
|
+
_: 1
|
|
687
|
+
}, 8, ["loading", "disabled"])
|
|
688
|
+
]),
|
|
689
|
+
_: 1
|
|
690
|
+
})
|
|
691
|
+
]),
|
|
692
|
+
default: r(() => [
|
|
693
|
+
c(e(z), {
|
|
694
|
+
label: e(s)("menu.field-name"),
|
|
695
|
+
error: m.value.title?.[0],
|
|
696
|
+
required: ""
|
|
697
|
+
}, {
|
|
698
|
+
default: r(() => [
|
|
699
|
+
D("div", {
|
|
700
|
+
ref_key: "field",
|
|
701
|
+
ref: f
|
|
702
|
+
}, [
|
|
703
|
+
c(e(H), {
|
|
704
|
+
modelValue: p.value,
|
|
705
|
+
"onUpdate:modelValue": $[0] || ($[0] = (U) => p.value = U),
|
|
706
|
+
"aria-label": e(s)("menu.field-name"),
|
|
707
|
+
onKeyup: Y(W, ["enter"])
|
|
708
|
+
}, null, 8, ["modelValue", "aria-label"])
|
|
709
|
+
], 512)
|
|
710
|
+
]),
|
|
711
|
+
_: 1
|
|
712
|
+
}, 8, ["label", "error"]),
|
|
713
|
+
c(e(z), {
|
|
714
|
+
label: e(s)("menu.field-key"),
|
|
715
|
+
error: m.value.key?.[0],
|
|
716
|
+
help: e(s)("menu.key-help"),
|
|
717
|
+
required: ""
|
|
718
|
+
}, {
|
|
719
|
+
default: r(() => [
|
|
720
|
+
c(e(H), {
|
|
721
|
+
modelValue: d.value,
|
|
722
|
+
"onUpdate:modelValue": $[1] || ($[1] = (U) => d.value = U),
|
|
723
|
+
disabled: y && !n.menu?.can.rename,
|
|
724
|
+
"aria-label": e(s)("menu.field-key"),
|
|
725
|
+
onKeyup: Y(W, ["enter"])
|
|
726
|
+
}, null, 8, ["modelValue", "disabled", "aria-label"])
|
|
727
|
+
]),
|
|
728
|
+
_: 1
|
|
729
|
+
}, 8, ["label", "error", "help"])
|
|
730
|
+
]),
|
|
731
|
+
_: 1
|
|
732
|
+
}, 8, ["open", "title"]));
|
|
733
|
+
}
|
|
734
|
+
}), He = fe(() => import("./MenusPage-UQffRtpG.js"));
|
|
735
|
+
export {
|
|
736
|
+
Ke as M,
|
|
737
|
+
He as W,
|
|
738
|
+
qe as _,
|
|
739
|
+
se as a,
|
|
740
|
+
ze as b,
|
|
741
|
+
ue as c,
|
|
742
|
+
De as d,
|
|
743
|
+
oe as e,
|
|
744
|
+
G as f,
|
|
745
|
+
We as g,
|
|
746
|
+
Me as h,
|
|
747
|
+
Fe as m,
|
|
748
|
+
J as u
|
|
749
|
+
};
|
|
750
|
+
//# sourceMappingURL=index-tmF0XKBt.js.map
|