@webx-ui/module-media 0.3.0 → 0.4.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/README.md +3 -3
- package/dist/MediaField.d.ts +11 -2
- package/dist/api.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +359 -354
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +1 -1
- package/dist/types.d.ts +2 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { WxTree as He, WxSelectionArea as
|
|
3
|
-
import { useTranslate as B, useAdmin as ie } from "@webx-ui/admin";
|
|
4
|
-
const ge = /* @__PURE__ */
|
|
1
|
+
import { defineComponent as S, useModel as A, ref as M, watch as q, openBlock as b, createBlock as $, unref as e, mergeModels as F, computed as D, resolveDirective as Pe, withCtx as w, createElementBlock as W, Fragment as Q, renderList as Z, withDirectives as Oe, createCommentVNode as U, createVNode as h, createTextVNode as P, toDisplayString as L, isRef as te, useTemplateRef as ee, onMounted as he, nextTick as qe, createElementVNode as _, withKeys as Ne, normalizeClass as Ae, normalizeStyle as me } from "vue";
|
|
2
|
+
import { WxTree as He, WxSelectionArea as Ie, WxFileCard as Xe, WxEmpty as Ke, toast as N, WxAction as T, WxInput as j, WxDropdown as pe, WxDropdownItem as fe, WxActions as G, useModal as ae, WxDialog as le, WxSelect as je, WxSpace as be, WxButton as I, useElementWidth as Ge, createModal as Y, WxPagination as Ye, WxDrawer as Je, confirm as ve, openImageEditor as Qe, WxCard as Ze, WxImage as et, WxPopover as tt, WxPopconfirm as at } from "@webx-ui/core";
|
|
3
|
+
import { useTranslate as B, useAdmin as ie } from "@webx-ui/module-admin";
|
|
4
|
+
const ge = /* @__PURE__ */ S({
|
|
5
5
|
__name: "DirectoryTree",
|
|
6
6
|
props: /* @__PURE__ */ F({
|
|
7
7
|
directories: {}
|
|
@@ -10,36 +10,36 @@ const ge = /* @__PURE__ */ E({
|
|
|
10
10
|
selectedModifiers: {}
|
|
11
11
|
}),
|
|
12
12
|
emits: /* @__PURE__ */ F(["move"], ["update:selected"]),
|
|
13
|
-
setup(a, { emit:
|
|
14
|
-
const m = a, l = A(a, "selected"),
|
|
13
|
+
setup(a, { emit: d }) {
|
|
14
|
+
const m = a, l = A(a, "selected"), v = d, i = B("webx-media"), t = M([]), p = M([]);
|
|
15
15
|
q(
|
|
16
16
|
() => m.directories,
|
|
17
|
-
(
|
|
18
|
-
t.value =
|
|
17
|
+
(n) => {
|
|
18
|
+
t.value = n.map(k), p.value = g(n);
|
|
19
19
|
},
|
|
20
20
|
{ immediate: !0, deep: !0 }
|
|
21
21
|
);
|
|
22
|
-
function
|
|
22
|
+
function k(n) {
|
|
23
23
|
return {
|
|
24
|
-
...
|
|
25
|
-
label:
|
|
26
|
-
children: (
|
|
24
|
+
...n,
|
|
25
|
+
label: n.is_root ? i("manager.root") : n.title,
|
|
26
|
+
children: (n.children ?? []).map(k)
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function g(
|
|
30
|
-
return
|
|
29
|
+
function g(n) {
|
|
30
|
+
return n.flatMap((f) => [f.id, ...g(f.children ?? [])]);
|
|
31
31
|
}
|
|
32
|
-
function u(
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
function u(n) {
|
|
33
|
+
const f = n.zone === "inside" ? n.target : n.parent;
|
|
34
|
+
f && v("move", n.node.id, f.id);
|
|
35
35
|
}
|
|
36
|
-
return (
|
|
36
|
+
return (n, f) => (b(), $(e(He), {
|
|
37
37
|
selected: l.value,
|
|
38
|
-
"onUpdate:selected":
|
|
38
|
+
"onUpdate:selected": f[0] || (f[0] = (c) => l.value = c),
|
|
39
39
|
expanded: p.value,
|
|
40
|
-
"onUpdate:expanded":
|
|
40
|
+
"onUpdate:expanded": f[1] || (f[1] = (c) => p.value = c),
|
|
41
41
|
modelValue: t.value,
|
|
42
|
-
"onUpdate:modelValue":
|
|
42
|
+
"onUpdate:modelValue": f[2] || (f[2] = (c) => t.value = c),
|
|
43
43
|
class: "wx-media-tree",
|
|
44
44
|
"node-key": "id",
|
|
45
45
|
draggable: "",
|
|
@@ -47,7 +47,7 @@ const ge = /* @__PURE__ */ E({
|
|
|
47
47
|
onDrop: u
|
|
48
48
|
}, null, 8, ["selected", "expanded", "modelValue"]));
|
|
49
49
|
}
|
|
50
|
-
}), lt = /* @__PURE__ */
|
|
50
|
+
}), lt = /* @__PURE__ */ S({
|
|
51
51
|
__name: "FileGrid",
|
|
52
52
|
props: /* @__PURE__ */ F({
|
|
53
53
|
files: {},
|
|
@@ -59,76 +59,76 @@ const ge = /* @__PURE__ */ E({
|
|
|
59
59
|
selectedModifiers: {}
|
|
60
60
|
}),
|
|
61
61
|
emits: /* @__PURE__ */ F(["open", "rename", "edit", "remove"], ["update:selected"]),
|
|
62
|
-
setup(a, { emit:
|
|
63
|
-
const m = a, l = A(a, "selected"),
|
|
64
|
-
() => m.query ?
|
|
62
|
+
setup(a, { emit: d }) {
|
|
63
|
+
const m = a, l = A(a, "selected"), v = d, i = B("webx-media"), t = D(
|
|
64
|
+
() => m.query ? i("manager.empty-search", { query: m.query }) : i("manager.empty")
|
|
65
65
|
);
|
|
66
66
|
function p() {
|
|
67
|
-
N.success(
|
|
67
|
+
N.success(i("manager.link-copied"));
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function k(g) {
|
|
70
70
|
const u = document.createElement("textarea");
|
|
71
71
|
u.value = g.url, u.setAttribute("readonly", ""), u.style.position = "fixed", u.style.opacity = "0", document.body.appendChild(u), u.select();
|
|
72
|
-
let
|
|
72
|
+
let n = !1;
|
|
73
73
|
try {
|
|
74
|
-
|
|
74
|
+
n = document.execCommand("copy");
|
|
75
75
|
} catch {
|
|
76
|
-
|
|
76
|
+
n = !1;
|
|
77
77
|
}
|
|
78
|
-
if (u.remove(),
|
|
78
|
+
if (u.remove(), n) {
|
|
79
79
|
p();
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
N.danger(`${
|
|
82
|
+
N.danger(`${i("errors.copy")} ${g.url}`, { duration: 0 });
|
|
83
83
|
}
|
|
84
84
|
return (g, u) => {
|
|
85
|
-
const
|
|
86
|
-
return a.files.length > 0 ? (b(),
|
|
85
|
+
const n = Pe("wx-select");
|
|
86
|
+
return a.files.length > 0 ? (b(), $(e(Ie), {
|
|
87
87
|
key: 0,
|
|
88
88
|
modelValue: l.value,
|
|
89
|
-
"onUpdate:modelValue": u[0] || (u[0] = (
|
|
89
|
+
"onUpdate:modelValue": u[0] || (u[0] = (f) => l.value = f),
|
|
90
90
|
class: "wx-media-grid",
|
|
91
91
|
multiple: !a.single
|
|
92
92
|
}, {
|
|
93
|
-
default: w(({ isSelected:
|
|
94
|
-
(b(!0),
|
|
95
|
-
key:
|
|
93
|
+
default: w(({ isSelected: f }) => [
|
|
94
|
+
(b(!0), W(Q, null, Z(a.files, (c) => Oe((b(), $(e(Xe), {
|
|
95
|
+
key: c.id,
|
|
96
96
|
class: "wx-media-grid__card",
|
|
97
|
-
name:
|
|
98
|
-
url:
|
|
99
|
-
thumbnail: a.api.thumb(
|
|
100
|
-
type:
|
|
101
|
-
selected:
|
|
97
|
+
name: c.name,
|
|
98
|
+
url: c.url,
|
|
99
|
+
thumbnail: a.api.thumb(c, 320, 320) ?? void 0,
|
|
100
|
+
type: c.mime,
|
|
101
|
+
selected: f(c.id),
|
|
102
102
|
renamable: "",
|
|
103
|
-
editable:
|
|
103
|
+
editable: c.editable,
|
|
104
104
|
removable: "",
|
|
105
105
|
copyable: "",
|
|
106
|
-
"rename-label": e(
|
|
107
|
-
"edit-label": e(
|
|
108
|
-
"remove-label": e(
|
|
109
|
-
"remove-confirm-text": e(
|
|
110
|
-
"cancel-label": e(
|
|
111
|
-
"save-label": e(
|
|
112
|
-
"copy-label": e(
|
|
113
|
-
"copied-label": e(
|
|
114
|
-
onRename: (
|
|
115
|
-
onEdit: (
|
|
116
|
-
onRemove: (
|
|
106
|
+
"rename-label": e(i)("manager.rename"),
|
|
107
|
+
"edit-label": e(i)("manager.edit"),
|
|
108
|
+
"remove-label": e(i)("manager.delete"),
|
|
109
|
+
"remove-confirm-text": e(i)("dialogs.delete-file", { name: c.name }),
|
|
110
|
+
"cancel-label": e(i)("manager.cancel"),
|
|
111
|
+
"save-label": e(i)("manager.save"),
|
|
112
|
+
"copy-label": e(i)("manager.copy-link"),
|
|
113
|
+
"copied-label": e(i)("manager.link-copied"),
|
|
114
|
+
onRename: (s) => v("rename", c, s),
|
|
115
|
+
onEdit: (s) => v("edit", c),
|
|
116
|
+
onRemove: (s) => v("remove", c),
|
|
117
117
|
onCopy: p,
|
|
118
|
-
onCopyError: (
|
|
119
|
-
onDblclick: (
|
|
118
|
+
onCopyError: (s) => k(c),
|
|
119
|
+
onDblclick: (s) => v("open", c)
|
|
120
120
|
}, null, 8, ["name", "url", "thumbnail", "type", "selected", "editable", "rename-label", "edit-label", "remove-label", "remove-confirm-text", "cancel-label", "save-label", "copy-label", "copied-label", "onRename", "onEdit", "onRemove", "onCopyError", "onDblclick"])), [
|
|
121
|
-
[
|
|
121
|
+
[n, c.id]
|
|
122
122
|
])), 128))
|
|
123
123
|
]),
|
|
124
124
|
_: 1
|
|
125
|
-
}, 8, ["modelValue", "multiple"])) : (b(),
|
|
125
|
+
}, 8, ["modelValue", "multiple"])) : (b(), $(e(Ke), {
|
|
126
126
|
key: 1,
|
|
127
127
|
description: t.value
|
|
128
128
|
}, null, 8, ["description"]));
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
|
-
}), it = { class: "wx-media-toolbar" }, ot = /* @__PURE__ */
|
|
131
|
+
}), it = { class: "wx-media-toolbar" }, ot = /* @__PURE__ */ S({
|
|
132
132
|
__name: "MediaToolbar",
|
|
133
133
|
props: /* @__PURE__ */ F({
|
|
134
134
|
canUpload: { type: Boolean },
|
|
@@ -145,36 +145,36 @@ const ge = /* @__PURE__ */ E({
|
|
|
145
145
|
sortModifiers: {}
|
|
146
146
|
}),
|
|
147
147
|
emits: /* @__PURE__ */ F(["upload", "move", "remove", "folders"], ["update:search", "update:type", "update:sort"]),
|
|
148
|
-
setup(a, { emit:
|
|
149
|
-
const m = a, l = A(a, "search"),
|
|
148
|
+
setup(a, { emit: d }) {
|
|
149
|
+
const m = a, l = A(a, "search"), v = A(a, "type"), i = A(a, "sort"), t = d, p = B("webx-media"), k = D(() => [
|
|
150
150
|
{ value: "all", label: p("manager.all-types") },
|
|
151
|
-
...["image", "video", "audio", "document", "other"].map((
|
|
152
|
-
value:
|
|
153
|
-
label: p(`manager.${
|
|
151
|
+
...["image", "video", "audio", "document", "other"].map((f) => ({
|
|
152
|
+
value: f,
|
|
153
|
+
label: p(`manager.${f}`)
|
|
154
154
|
}))
|
|
155
|
-
]), g =
|
|
155
|
+
]), g = D(() => [
|
|
156
156
|
{ value: "-created_at", label: p("manager.sort-newest") },
|
|
157
157
|
{ value: "created_at", label: p("manager.sort-oldest") },
|
|
158
158
|
{ value: "name", label: p("manager.sort-name") },
|
|
159
159
|
{ value: "-size", label: p("manager.sort-size") }
|
|
160
|
-
]), u =
|
|
161
|
-
return (
|
|
162
|
-
a.compact ? (b(),
|
|
160
|
+
]), u = D(() => k.value.find((f) => f.value === v.value)?.label ?? ""), n = D(() => g.value.find((f) => f.value === i.value)?.label ?? "");
|
|
161
|
+
return (f, c) => (b(), W("header", it, [
|
|
162
|
+
a.compact ? (b(), $(e(T), {
|
|
163
163
|
key: 0,
|
|
164
164
|
icon: "folder",
|
|
165
165
|
title: e(p)("manager.folders"),
|
|
166
166
|
size: "sm",
|
|
167
|
-
onClick:
|
|
168
|
-
}, null, 8, ["title"])) :
|
|
167
|
+
onClick: c[0] || (c[0] = (s) => t("folders"))
|
|
168
|
+
}, null, 8, ["title"])) : U("", !0),
|
|
169
169
|
h(e(j), {
|
|
170
170
|
modelValue: l.value,
|
|
171
|
-
"onUpdate:modelValue":
|
|
171
|
+
"onUpdate:modelValue": c[1] || (c[1] = (s) => l.value = s),
|
|
172
172
|
class: "wx-media-toolbar__search",
|
|
173
173
|
placeholder: e(p)("manager.search"),
|
|
174
174
|
clearable: "",
|
|
175
175
|
size: "sm"
|
|
176
176
|
}, null, 8, ["modelValue", "placeholder"]),
|
|
177
|
-
a.fixedType ?
|
|
177
|
+
a.fixedType ? U("", !0) : (b(), $(e(pe), { key: 1 }, {
|
|
178
178
|
trigger: w(() => [
|
|
179
179
|
h(e(T), {
|
|
180
180
|
icon: "filter",
|
|
@@ -183,13 +183,13 @@ const ge = /* @__PURE__ */ E({
|
|
|
183
183
|
}, null, 8, ["title"])
|
|
184
184
|
]),
|
|
185
185
|
default: w(() => [
|
|
186
|
-
(b(!0),
|
|
187
|
-
key: String(
|
|
188
|
-
active:
|
|
189
|
-
onClick: (
|
|
186
|
+
(b(!0), W(Q, null, Z(k.value, (s) => (b(), $(e(fe), {
|
|
187
|
+
key: String(s.value),
|
|
188
|
+
active: s.value === v.value,
|
|
189
|
+
onClick: (x) => v.value = s.value
|
|
190
190
|
}, {
|
|
191
191
|
default: w(() => [
|
|
192
|
-
|
|
192
|
+
P(L(s.label), 1)
|
|
193
193
|
]),
|
|
194
194
|
_: 2
|
|
195
195
|
}, 1032, ["active", "onClick"]))), 128))
|
|
@@ -200,32 +200,32 @@ const ge = /* @__PURE__ */ E({
|
|
|
200
200
|
trigger: w(() => [
|
|
201
201
|
h(e(T), {
|
|
202
202
|
icon: "arrow-down",
|
|
203
|
-
title:
|
|
203
|
+
title: n.value,
|
|
204
204
|
size: "sm"
|
|
205
205
|
}, null, 8, ["title"])
|
|
206
206
|
]),
|
|
207
207
|
default: w(() => [
|
|
208
|
-
(b(!0),
|
|
209
|
-
key:
|
|
210
|
-
active:
|
|
211
|
-
onClick: (
|
|
208
|
+
(b(!0), W(Q, null, Z(g.value, (s) => (b(), $(e(fe), {
|
|
209
|
+
key: s.value,
|
|
210
|
+
active: s.value === i.value,
|
|
211
|
+
onClick: (x) => i.value = s.value
|
|
212
212
|
}, {
|
|
213
213
|
default: w(() => [
|
|
214
|
-
|
|
214
|
+
P(L(s.label), 1)
|
|
215
215
|
]),
|
|
216
216
|
_: 2
|
|
217
217
|
}, 1032, ["active", "onClick"]))), 128))
|
|
218
218
|
]),
|
|
219
219
|
_: 1
|
|
220
220
|
}),
|
|
221
|
-
a.canUpload ? (b(),
|
|
221
|
+
a.canUpload ? (b(), $(e(T), {
|
|
222
222
|
key: 2,
|
|
223
223
|
type: "upload",
|
|
224
224
|
title: e(p)("manager.upload"),
|
|
225
225
|
size: "sm",
|
|
226
|
-
onClick:
|
|
227
|
-
}, null, 8, ["title"])) :
|
|
228
|
-
a.canManage ? (b(),
|
|
226
|
+
onClick: c[2] || (c[2] = (s) => t("upload"))
|
|
227
|
+
}, null, 8, ["title"])) : U("", !0),
|
|
228
|
+
a.canManage ? (b(), $(e(G), {
|
|
229
229
|
key: 3,
|
|
230
230
|
size: "sm"
|
|
231
231
|
}, {
|
|
@@ -234,20 +234,20 @@ const ge = /* @__PURE__ */ E({
|
|
|
234
234
|
icon: "folder",
|
|
235
235
|
title: e(p)("manager.move"),
|
|
236
236
|
disabled: m.selected === 0,
|
|
237
|
-
onClick:
|
|
237
|
+
onClick: c[3] || (c[3] = (s) => t("move"))
|
|
238
238
|
}, null, 8, ["title", "disabled"]),
|
|
239
239
|
h(e(T), {
|
|
240
240
|
type: "remove",
|
|
241
241
|
title: e(p)("manager.delete"),
|
|
242
242
|
disabled: m.selected === 0,
|
|
243
|
-
onClick:
|
|
243
|
+
onClick: c[4] || (c[4] = (s) => t("remove"))
|
|
244
244
|
}, null, 8, ["title", "disabled"])
|
|
245
245
|
]),
|
|
246
246
|
_: 1
|
|
247
|
-
})) :
|
|
247
|
+
})) : U("", !0)
|
|
248
248
|
]));
|
|
249
249
|
}
|
|
250
|
-
}), nt = /* @__PURE__ */
|
|
250
|
+
}), nt = /* @__PURE__ */ S({
|
|
251
251
|
__name: "MoveDialog",
|
|
252
252
|
props: {
|
|
253
253
|
directories: {},
|
|
@@ -255,44 +255,44 @@ const ge = /* @__PURE__ */ E({
|
|
|
255
255
|
count: {}
|
|
256
256
|
},
|
|
257
257
|
setup(a) {
|
|
258
|
-
const
|
|
259
|
-
() =>
|
|
258
|
+
const d = a, { open: m, resolve: l, dismiss: v } = ae(), i = B("webx-media"), t = D(
|
|
259
|
+
() => k(d.directories).filter((g) => g.value !== d.from)
|
|
260
260
|
), p = M(t.value[0]?.value ?? null);
|
|
261
|
-
function
|
|
261
|
+
function k(g) {
|
|
262
262
|
return g.flatMap((u) => [
|
|
263
263
|
{
|
|
264
264
|
value: u.id,
|
|
265
265
|
// Indented, so the tree is still readable once it is a flat list.
|
|
266
|
-
label: " ".repeat(u.depth * 3) + (u.is_root ?
|
|
266
|
+
label: " ".repeat(u.depth * 3) + (u.is_root ? i("manager.root") : u.title)
|
|
267
267
|
},
|
|
268
|
-
...
|
|
268
|
+
...k(u.children ?? [])
|
|
269
269
|
]);
|
|
270
270
|
}
|
|
271
|
-
return (g, u) => (b(),
|
|
271
|
+
return (g, u) => (b(), $(e(le), {
|
|
272
272
|
open: e(m),
|
|
273
|
-
"onUpdate:open": u[3] || (u[3] = (
|
|
274
|
-
title: e(
|
|
273
|
+
"onUpdate:open": u[3] || (u[3] = (n) => te(m) ? m.value = n : null),
|
|
274
|
+
title: e(i)("manager.move-to"),
|
|
275
275
|
width: 420
|
|
276
276
|
}, {
|
|
277
277
|
footer: w(() => [
|
|
278
278
|
h(e(be), { size: "sm" }, {
|
|
279
279
|
default: w(() => [
|
|
280
|
-
h(e(
|
|
280
|
+
h(e(I), {
|
|
281
281
|
variant: "outline",
|
|
282
|
-
onClick: u[1] || (u[1] = (
|
|
282
|
+
onClick: u[1] || (u[1] = (n) => e(v)())
|
|
283
283
|
}, {
|
|
284
284
|
default: w(() => [
|
|
285
|
-
|
|
285
|
+
P(L(e(i)("manager.cancel")), 1)
|
|
286
286
|
]),
|
|
287
287
|
_: 1
|
|
288
288
|
}),
|
|
289
|
-
h(e(
|
|
289
|
+
h(e(I), {
|
|
290
290
|
type: "primary",
|
|
291
291
|
disabled: p.value === null,
|
|
292
|
-
onClick: u[2] || (u[2] = (
|
|
292
|
+
onClick: u[2] || (u[2] = (n) => e(l)(p.value))
|
|
293
293
|
}, {
|
|
294
294
|
default: w(() => [
|
|
295
|
-
|
|
295
|
+
P(L(e(i)("manager.move")), 1)
|
|
296
296
|
]),
|
|
297
297
|
_: 1
|
|
298
298
|
}, 8, ["disabled"])
|
|
@@ -303,14 +303,14 @@ const ge = /* @__PURE__ */ E({
|
|
|
303
303
|
default: w(() => [
|
|
304
304
|
h(e(je), {
|
|
305
305
|
modelValue: p.value,
|
|
306
|
-
"onUpdate:modelValue": u[0] || (u[0] = (
|
|
306
|
+
"onUpdate:modelValue": u[0] || (u[0] = (n) => p.value = n),
|
|
307
307
|
options: t.value
|
|
308
308
|
}, null, 8, ["modelValue", "options"])
|
|
309
309
|
]),
|
|
310
310
|
_: 1
|
|
311
311
|
}, 8, ["open", "title"]));
|
|
312
312
|
}
|
|
313
|
-
}), rt = /* @__PURE__ */
|
|
313
|
+
}), rt = /* @__PURE__ */ S({
|
|
314
314
|
__name: "NameDialog",
|
|
315
315
|
props: {
|
|
316
316
|
title: {},
|
|
@@ -319,39 +319,39 @@ const ge = /* @__PURE__ */ E({
|
|
|
319
319
|
confirmText: { default: void 0 }
|
|
320
320
|
},
|
|
321
321
|
setup(a) {
|
|
322
|
-
const
|
|
322
|
+
const d = a, { open: m, resolve: l, dismiss: v } = ae(), i = B("webx-media"), t = M(d.value), p = ee("input");
|
|
323
323
|
he(async () => {
|
|
324
324
|
await qe(), p.value?.querySelector("input")?.focus();
|
|
325
325
|
});
|
|
326
|
-
function
|
|
326
|
+
function k() {
|
|
327
327
|
const g = t.value.trim();
|
|
328
328
|
g !== "" && l(g);
|
|
329
329
|
}
|
|
330
|
-
return (g, u) => (b(),
|
|
330
|
+
return (g, u) => (b(), $(e(le), {
|
|
331
331
|
open: e(m),
|
|
332
|
-
"onUpdate:open": u[2] || (u[2] = (
|
|
332
|
+
"onUpdate:open": u[2] || (u[2] = (n) => te(m) ? m.value = n : null),
|
|
333
333
|
title: a.title,
|
|
334
334
|
width: 420
|
|
335
335
|
}, {
|
|
336
336
|
footer: w(() => [
|
|
337
337
|
h(e(be), { size: "sm" }, {
|
|
338
338
|
default: w(() => [
|
|
339
|
-
h(e(
|
|
339
|
+
h(e(I), {
|
|
340
340
|
variant: "outline",
|
|
341
|
-
onClick: u[1] || (u[1] = (
|
|
341
|
+
onClick: u[1] || (u[1] = (n) => e(v)())
|
|
342
342
|
}, {
|
|
343
343
|
default: w(() => [
|
|
344
|
-
|
|
344
|
+
P(L(e(i)("manager.cancel")), 1)
|
|
345
345
|
]),
|
|
346
346
|
_: 1
|
|
347
347
|
}),
|
|
348
|
-
h(e(
|
|
348
|
+
h(e(I), {
|
|
349
349
|
type: "primary",
|
|
350
350
|
disabled: t.value.trim() === "",
|
|
351
|
-
onClick:
|
|
351
|
+
onClick: k
|
|
352
352
|
}, {
|
|
353
353
|
default: w(() => [
|
|
354
|
-
|
|
354
|
+
P(L(a.confirmText ?? e(i)("manager.save")), 1)
|
|
355
355
|
]),
|
|
356
356
|
_: 1
|
|
357
357
|
}, 8, ["disabled"])
|
|
@@ -360,16 +360,16 @@ const ge = /* @__PURE__ */ E({
|
|
|
360
360
|
})
|
|
361
361
|
]),
|
|
362
362
|
default: w(() => [
|
|
363
|
-
|
|
363
|
+
_("div", {
|
|
364
364
|
ref_key: "input",
|
|
365
365
|
ref: p
|
|
366
366
|
}, [
|
|
367
367
|
h(e(j), {
|
|
368
368
|
modelValue: t.value,
|
|
369
|
-
"onUpdate:modelValue": u[0] || (u[0] = (
|
|
370
|
-
placeholder: a.label ?? e(
|
|
371
|
-
"aria-label": a.label ?? e(
|
|
372
|
-
onKeyup: Ne(
|
|
369
|
+
"onUpdate:modelValue": u[0] || (u[0] = (n) => t.value = n),
|
|
370
|
+
placeholder: a.label ?? e(i)("manager.folder-name"),
|
|
371
|
+
"aria-label": a.label ?? e(i)("manager.folder-name"),
|
|
372
|
+
onKeyup: Ne(k, ["enter"])
|
|
373
373
|
}, null, 8, ["modelValue", "placeholder", "aria-label"])
|
|
374
374
|
], 512)
|
|
375
375
|
]),
|
|
@@ -378,16 +378,16 @@ const ge = /* @__PURE__ */ E({
|
|
|
378
378
|
}
|
|
379
379
|
});
|
|
380
380
|
function we(a) {
|
|
381
|
-
const
|
|
381
|
+
const d = `${a.apiPath}/media`, m = (l) => l.data;
|
|
382
382
|
return {
|
|
383
|
-
directories: () => a.http.get(`${
|
|
384
|
-
createDirectory: (l,
|
|
385
|
-
renameDirectory: (l,
|
|
386
|
-
moveDirectory: (l,
|
|
387
|
-
deleteDirectory: (l,
|
|
388
|
-
query: { force:
|
|
383
|
+
directories: () => a.http.get(`${d}/directories`).then(m),
|
|
384
|
+
createDirectory: (l, v) => a.http.post(`${d}/directories`, { parent_id: l, title: v }).then(m),
|
|
385
|
+
renameDirectory: (l, v) => a.http.patch(`${d}/directories/${l}`, { title: v }).then(m),
|
|
386
|
+
moveDirectory: (l, v) => a.http.patch(`${d}/directories/${l}/move`, { parent_id: v }).then(m),
|
|
387
|
+
deleteDirectory: (l, v = !1) => a.http.delete(`${d}/directories/${l}`, {
|
|
388
|
+
query: { force: v ? 1 : void 0 }
|
|
389
389
|
}),
|
|
390
|
-
files: (l = {}) => a.http.get(`${
|
|
390
|
+
files: (l = {}) => a.http.get(`${d}/files`, {
|
|
391
391
|
query: {
|
|
392
392
|
directory_id: l.directory_id ?? void 0,
|
|
393
393
|
q: l.q || void 0,
|
|
@@ -397,50 +397,50 @@ function we(a) {
|
|
|
397
397
|
per_page: l.per_page
|
|
398
398
|
}
|
|
399
399
|
}),
|
|
400
|
-
file: (l) => a.http.get(`${
|
|
401
|
-
fileByPath: (l) => a.http.get(`${
|
|
402
|
-
async upload(l,
|
|
400
|
+
file: (l) => a.http.get(`${d}/files/${l}`).then(m),
|
|
401
|
+
fileByPath: (l) => a.http.get(`${d}/files/by-path?path=${encodeURIComponent(l)}`).then(m).catch(() => null),
|
|
402
|
+
async upload(l, v, i) {
|
|
403
403
|
const t = new FormData();
|
|
404
|
-
return t.append("directory_id", String(l)),
|
|
404
|
+
return t.append("directory_id", String(l)), v.forEach((p) => t.append("files[]", p)), new Promise((p, k) => {
|
|
405
405
|
const g = new XMLHttpRequest();
|
|
406
|
-
g.open("POST", `${
|
|
406
|
+
g.open("POST", `${d}/files`), g.responseType = "json", g.withCredentials = !0, g.setRequestHeader("Accept", "application/json"), g.setRequestHeader("X-Requested-With", "XMLHttpRequest"), g.setRequestHeader("X-Webx-Locale", a.i18n.state.locale);
|
|
407
407
|
const u = st();
|
|
408
|
-
u && g.setRequestHeader("X-XSRF-TOKEN", u), g.upload.addEventListener("progress", (
|
|
409
|
-
|
|
408
|
+
u && g.setRequestHeader("X-XSRF-TOKEN", u), g.upload.addEventListener("progress", (n) => {
|
|
409
|
+
n.lengthComputable && i?.(Math.round(n.loaded / n.total * 100));
|
|
410
410
|
}), g.addEventListener("load", () => {
|
|
411
|
-
const
|
|
412
|
-
if (g.status >= 200 && g.status < 300 &&
|
|
413
|
-
p(
|
|
411
|
+
const n = g.response;
|
|
412
|
+
if (g.status >= 200 && g.status < 300 && n?.data) {
|
|
413
|
+
p(n.data);
|
|
414
414
|
return;
|
|
415
415
|
}
|
|
416
|
-
|
|
417
|
-
Object.assign(new Error(
|
|
416
|
+
k(
|
|
417
|
+
Object.assign(new Error(n?.message ?? "Upload failed"), {
|
|
418
418
|
status: g.status,
|
|
419
|
-
body:
|
|
419
|
+
body: n
|
|
420
420
|
})
|
|
421
421
|
);
|
|
422
|
-
}), g.addEventListener("error", () =>
|
|
422
|
+
}), g.addEventListener("error", () => k(new Error("Upload failed"))), g.send(t);
|
|
423
423
|
});
|
|
424
424
|
},
|
|
425
|
-
rename: (l,
|
|
426
|
-
move: (l,
|
|
425
|
+
rename: (l, v) => a.http.patch(`${d}/files/${l}`, { name: v }).then(m),
|
|
426
|
+
move: (l, v) => a.http.post(`${d}/files/move`, { ids: l, directory_id: v }).then((i) => i.data.moved),
|
|
427
427
|
// A POST for the batch, not a DELETE: the panel's own client sends no body on DELETE, and
|
|
428
428
|
// a list of ids in a query string is a worse answer than an honest verb.
|
|
429
|
-
remove: (l) => a.http.post(`${
|
|
430
|
-
removeOne: (l) => a.http.delete(`${
|
|
431
|
-
edit: (l,
|
|
432
|
-
copy: (l) => a.http.post(`${
|
|
433
|
-
restoreOriginal: (l) => a.http.post(`${
|
|
434
|
-
thumb(l,
|
|
429
|
+
remove: (l) => a.http.post(`${d}/files/delete`, { ids: l }).then((v) => v.data.deleted),
|
|
430
|
+
removeOne: (l) => a.http.delete(`${d}/files/${l}`),
|
|
431
|
+
edit: (l, v) => a.http.post(`${d}/files/${l}/edit`, v).then(m),
|
|
432
|
+
copy: (l) => a.http.post(`${d}/files/${l}/copy`).then(m),
|
|
433
|
+
restoreOriginal: (l) => a.http.post(`${d}/files/${l}/restore-original`).then(m),
|
|
434
|
+
thumb(l, v, i, t = "cover") {
|
|
435
435
|
if (!l.thumb)
|
|
436
436
|
return null;
|
|
437
437
|
const p = new URL(l.thumb, window.location.origin);
|
|
438
|
-
return p.searchParams.set("w", String(
|
|
438
|
+
return p.searchParams.set("w", String(v)), i && p.searchParams.set("h", String(i)), p.searchParams.set("fit", t), p.pathname + p.search;
|
|
439
439
|
}
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
442
|
function st() {
|
|
443
|
-
const a = document.cookie.split("; ").find((
|
|
443
|
+
const a = document.cookie.split("; ").find((d) => d.startsWith("XSRF-TOKEN="));
|
|
444
444
|
return a ? decodeURIComponent(a.slice(11)) : null;
|
|
445
445
|
}
|
|
446
446
|
const dt = {
|
|
@@ -559,15 +559,15 @@ function xe() {
|
|
|
559
559
|
const ut = {
|
|
560
560
|
key: 0,
|
|
561
561
|
class: "wx-media__folders"
|
|
562
|
-
}, ct = { class: "wx-media__files" }, mt = ["accept"], pt = { class: "wx-media__status" }, ft = { key: 0 }, vt = { class: "wx-media__drawer" }, ke = /* @__PURE__ */
|
|
562
|
+
}, ct = { class: "wx-media__files" }, mt = ["accept"], pt = { class: "wx-media__status" }, ft = { key: 0 }, vt = { class: "wx-media__drawer" }, ke = /* @__PURE__ */ S({
|
|
563
563
|
__name: "MediaManager",
|
|
564
564
|
props: {
|
|
565
565
|
picking: { type: Boolean, default: !1 },
|
|
566
566
|
accept: { default: null }
|
|
567
567
|
},
|
|
568
568
|
emits: ["pick"],
|
|
569
|
-
setup(a, { emit:
|
|
570
|
-
const m = a, l =
|
|
569
|
+
setup(a, { emit: d }) {
|
|
570
|
+
const m = a, l = d, v = ie(), i = we(v);
|
|
571
571
|
xe();
|
|
572
572
|
const t = B("webx-media");
|
|
573
573
|
function p() {
|
|
@@ -591,33 +591,33 @@ const ut = {
|
|
|
591
591
|
errorText: t("editor.error")
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
|
-
const
|
|
594
|
+
const k = ee("root"), g = Ge(k), u = D(() => g.value > 0 && g.value < 640), n = M([]), f = M(null), c = M(null), s = M([]), x = M(""), z = M(m.accept ?? "all");
|
|
595
595
|
q(
|
|
596
596
|
() => m.accept,
|
|
597
|
-
(
|
|
598
|
-
|
|
597
|
+
(r) => {
|
|
598
|
+
z.value = r ?? "all";
|
|
599
599
|
}
|
|
600
600
|
);
|
|
601
|
-
const
|
|
602
|
-
he(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
), q(u, (
|
|
606
|
-
|
|
601
|
+
const X = M("-created_at"), J = M(!1), H = M(!1), oe = ee("picker"), _e = D(() => c.value?.data ?? []), K = D(() => v.can("media.manage")), Ce = D(() => v.can("media.upload") || K.value), R = D(() => Ve(f.value));
|
|
602
|
+
he(E), q([f, z, X], () => V(1)), q(
|
|
603
|
+
x,
|
|
604
|
+
Be(() => V(1), 300)
|
|
605
|
+
), q(u, (r) => {
|
|
606
|
+
r || (H.value = !1);
|
|
607
607
|
});
|
|
608
|
-
async function
|
|
609
|
-
|
|
608
|
+
async function E() {
|
|
609
|
+
n.value = await i.directories(), f.value ??= n.value[0]?.id ?? null, await V(1);
|
|
610
610
|
}
|
|
611
|
-
async function
|
|
611
|
+
async function V(r = c.value?.meta.current_page ?? 1) {
|
|
612
612
|
J.value = !0;
|
|
613
613
|
try {
|
|
614
|
-
|
|
615
|
-
directory_id:
|
|
616
|
-
q:
|
|
617
|
-
type:
|
|
618
|
-
sort:
|
|
619
|
-
page:
|
|
620
|
-
}),
|
|
614
|
+
c.value = await i.files({
|
|
615
|
+
directory_id: x.value ? null : f.value,
|
|
616
|
+
q: x.value,
|
|
617
|
+
type: z.value === "all" ? null : z.value,
|
|
618
|
+
sort: X.value,
|
|
619
|
+
page: r
|
|
620
|
+
}), s.value = [];
|
|
621
621
|
} finally {
|
|
622
622
|
J.value = !1;
|
|
623
623
|
}
|
|
@@ -625,155 +625,155 @@ const ut = {
|
|
|
625
625
|
function Me() {
|
|
626
626
|
oe.value?.click();
|
|
627
627
|
}
|
|
628
|
-
async function Te(
|
|
629
|
-
const
|
|
630
|
-
if (
|
|
628
|
+
async function Te(r) {
|
|
629
|
+
const o = r.target, y = Array.from(o.files ?? []);
|
|
630
|
+
if (o.value = "", !(y.length === 0 || f.value === null))
|
|
631
631
|
try {
|
|
632
|
-
const C = await
|
|
633
|
-
C.length > O && N.success(t("manager.uploaded", { count: C.length - O })), O > 0 && N.info(t("manager.duplicate-added")), await Promise.all([
|
|
632
|
+
const C = await i.upload(f.value, y), O = C.filter((Fe) => Fe.duplicate).length;
|
|
633
|
+
C.length > O && N.success(t("manager.uploaded", { count: C.length - O })), O > 0 && N.info(t("manager.duplicate-added")), await Promise.all([E(), V(1)]);
|
|
634
634
|
} catch (C) {
|
|
635
635
|
N.danger(ce(C) ?? t("errors.upload"));
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
638
|
const ne = Y(rt);
|
|
639
639
|
async function re() {
|
|
640
|
-
const
|
|
640
|
+
const r = await ne({
|
|
641
641
|
title: t("manager.new-folder"),
|
|
642
642
|
confirmText: t("manager.new-folder")
|
|
643
643
|
});
|
|
644
|
-
|
|
644
|
+
r === void 0 || f.value === null || (await i.createDirectory(f.value, r), await E());
|
|
645
645
|
}
|
|
646
646
|
async function se() {
|
|
647
|
-
const
|
|
648
|
-
if (!
|
|
647
|
+
const r = R.value;
|
|
648
|
+
if (!r || r.is_root)
|
|
649
649
|
return;
|
|
650
|
-
const
|
|
650
|
+
const o = await ne({
|
|
651
651
|
title: t("manager.rename"),
|
|
652
|
-
value:
|
|
652
|
+
value: r.title,
|
|
653
653
|
confirmText: t("manager.save")
|
|
654
654
|
});
|
|
655
|
-
|
|
655
|
+
o !== void 0 && (await i.renameDirectory(r.id, o), await E());
|
|
656
656
|
}
|
|
657
657
|
async function de() {
|
|
658
|
-
const
|
|
659
|
-
if (!(!
|
|
658
|
+
const r = R.value;
|
|
659
|
+
if (!(!r || r.is_root)) {
|
|
660
660
|
try {
|
|
661
|
-
await
|
|
662
|
-
} catch (
|
|
663
|
-
const y = Ee(
|
|
661
|
+
await i.deleteDirectory(r.id);
|
|
662
|
+
} catch (o) {
|
|
663
|
+
const y = Ee(o);
|
|
664
664
|
if (!y)
|
|
665
|
-
throw
|
|
665
|
+
throw o;
|
|
666
666
|
if (!await ve({
|
|
667
|
-
title: t("dialogs.delete-folder-title", { title:
|
|
667
|
+
title: t("dialogs.delete-folder-title", { title: r.title }),
|
|
668
668
|
message: `${t("dialogs.delete-folder-contents", y)} ${t("dialogs.delete-folder-warning")}`,
|
|
669
669
|
confirmText: t("dialogs.confirm"),
|
|
670
670
|
cancelText: t("manager.cancel"),
|
|
671
671
|
tone: "danger"
|
|
672
672
|
}))
|
|
673
673
|
return;
|
|
674
|
-
await
|
|
674
|
+
await i.deleteDirectory(r.id, !0);
|
|
675
675
|
}
|
|
676
|
-
|
|
676
|
+
f.value = null, await E();
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
async function ue(
|
|
679
|
+
async function ue(r, o) {
|
|
680
680
|
try {
|
|
681
|
-
await
|
|
681
|
+
await i.moveDirectory(r, o);
|
|
682
682
|
} catch (y) {
|
|
683
683
|
N.danger(ce(y) ?? t("errors.directory-into-itself"));
|
|
684
684
|
}
|
|
685
|
-
await
|
|
685
|
+
await E();
|
|
686
686
|
}
|
|
687
687
|
const ze = Y(nt);
|
|
688
688
|
async function We() {
|
|
689
|
-
const
|
|
690
|
-
directories:
|
|
691
|
-
from:
|
|
692
|
-
count:
|
|
689
|
+
const r = await ze({
|
|
690
|
+
directories: n.value,
|
|
691
|
+
from: f.value,
|
|
692
|
+
count: s.value.length
|
|
693
693
|
});
|
|
694
|
-
|
|
694
|
+
r !== void 0 && (await i.move([...s.value], r), await Promise.all([E(), V()]));
|
|
695
695
|
}
|
|
696
696
|
async function De() {
|
|
697
|
-
const
|
|
697
|
+
const r = [...s.value];
|
|
698
698
|
await ve({
|
|
699
|
-
title: t("dialogs.delete-files-title", { count:
|
|
699
|
+
title: t("dialogs.delete-files-title", { count: r.length }),
|
|
700
700
|
message: t("dialogs.delete-files-text"),
|
|
701
701
|
confirmText: t("dialogs.confirm"),
|
|
702
702
|
cancelText: t("manager.cancel"),
|
|
703
703
|
tone: "danger"
|
|
704
|
-
}) && (await
|
|
704
|
+
}) && (await i.remove(r), await Promise.all([E(), V()]));
|
|
705
705
|
}
|
|
706
|
-
async function Le(
|
|
707
|
-
await
|
|
706
|
+
async function Le(r, o) {
|
|
707
|
+
await i.rename(r.id, o), await V();
|
|
708
708
|
}
|
|
709
|
-
async function Ue(
|
|
710
|
-
await
|
|
709
|
+
async function Ue(r) {
|
|
710
|
+
await i.removeOne(r.id), await Promise.all([E(), V()]);
|
|
711
711
|
}
|
|
712
|
-
async function Re(
|
|
713
|
-
const
|
|
714
|
-
src:
|
|
715
|
-
fileName:
|
|
712
|
+
async function Re(r) {
|
|
713
|
+
const o = await Qe({
|
|
714
|
+
src: r.source ?? r.url,
|
|
715
|
+
fileName: r.file_name,
|
|
716
716
|
filters: !1,
|
|
717
717
|
// The editor is a component of the design system: its words are props with English
|
|
718
718
|
// defaults, not lines in the panel's dictionary. Whoever opens it is the one who knows
|
|
719
719
|
// what language the panel is being read in.
|
|
720
720
|
...p()
|
|
721
721
|
});
|
|
722
|
-
|
|
722
|
+
o && (await i.edit(r.id, {
|
|
723
723
|
// The editor's frame is read against the picture as it is on screen — already turned — and
|
|
724
724
|
// the server applies the operations in that order for the same reason.
|
|
725
|
-
crop:
|
|
726
|
-
rotate: (
|
|
727
|
-
flip:
|
|
728
|
-
resize: { width:
|
|
729
|
-
}), await
|
|
725
|
+
crop: o.crop,
|
|
726
|
+
rotate: (o.rotation % 360 + 360) % 360,
|
|
727
|
+
flip: o.flipX ? "horizontal" : o.flipY ? "vertical" : void 0,
|
|
728
|
+
resize: { width: o.width, height: o.height }
|
|
729
|
+
}), await V());
|
|
730
730
|
}
|
|
731
|
-
function Ve(
|
|
732
|
-
const
|
|
731
|
+
function Ve(r) {
|
|
732
|
+
const o = (y) => {
|
|
733
733
|
for (const C of y) {
|
|
734
|
-
if (C.id ===
|
|
734
|
+
if (C.id === r)
|
|
735
735
|
return C;
|
|
736
|
-
const O =
|
|
736
|
+
const O = o(C.children ?? []);
|
|
737
737
|
if (O)
|
|
738
738
|
return O;
|
|
739
739
|
}
|
|
740
740
|
return null;
|
|
741
741
|
};
|
|
742
|
-
return
|
|
742
|
+
return r === null ? null : o(n.value);
|
|
743
743
|
}
|
|
744
|
-
function Ee(
|
|
745
|
-
const
|
|
746
|
-
return
|
|
744
|
+
function Ee(r) {
|
|
745
|
+
const o = r?.body;
|
|
746
|
+
return o?.code === "directory_not_empty" ? o.counts ?? null : null;
|
|
747
747
|
}
|
|
748
|
-
function ce(
|
|
749
|
-
return
|
|
748
|
+
function ce(r) {
|
|
749
|
+
return r?.message ?? null;
|
|
750
750
|
}
|
|
751
|
-
function
|
|
752
|
-
const
|
|
753
|
-
let y =
|
|
754
|
-
for (; y >= 1024 && C <
|
|
751
|
+
function Se(r) {
|
|
752
|
+
const o = ["B", "KB", "MB", "GB", "TB"];
|
|
753
|
+
let y = r, C = 0;
|
|
754
|
+
for (; y >= 1024 && C < o.length - 1; )
|
|
755
755
|
y /= 1024, C++;
|
|
756
|
-
return `${y >= 10 || C === 0 ? Math.round(y) : y.toFixed(1)} ${
|
|
756
|
+
return `${y >= 10 || C === 0 ? Math.round(y) : y.toFixed(1)} ${o[C]}`;
|
|
757
757
|
}
|
|
758
|
-
function
|
|
758
|
+
function Be(r, o) {
|
|
759
759
|
let y;
|
|
760
760
|
return () => {
|
|
761
|
-
clearTimeout(y), y = setTimeout(
|
|
761
|
+
clearTimeout(y), y = setTimeout(r, o);
|
|
762
762
|
};
|
|
763
763
|
}
|
|
764
|
-
return (
|
|
764
|
+
return (r, o) => (b(), W("div", {
|
|
765
765
|
ref_key: "root",
|
|
766
|
-
ref:
|
|
766
|
+
ref: k,
|
|
767
767
|
class: Ae(["wx-media", { "wx-media--compact": u.value }])
|
|
768
768
|
}, [
|
|
769
|
-
u.value ?
|
|
769
|
+
u.value ? U("", !0) : (b(), W("aside", ut, [
|
|
770
770
|
h(ge, {
|
|
771
|
-
selected:
|
|
772
|
-
"onUpdate:selected":
|
|
773
|
-
directories:
|
|
771
|
+
selected: f.value,
|
|
772
|
+
"onUpdate:selected": o[0] || (o[0] = (y) => f.value = y),
|
|
773
|
+
directories: n.value,
|
|
774
774
|
onMove: ue
|
|
775
775
|
}, null, 8, ["selected", "directories"]),
|
|
776
|
-
K.value ? (b(),
|
|
776
|
+
K.value ? (b(), $(e(G), {
|
|
777
777
|
key: 0,
|
|
778
778
|
size: "sm",
|
|
779
779
|
align: "start"
|
|
@@ -787,38 +787,38 @@ const ut = {
|
|
|
787
787
|
h(e(T), {
|
|
788
788
|
type: "edit",
|
|
789
789
|
title: e(t)("manager.rename"),
|
|
790
|
-
disabled: !
|
|
790
|
+
disabled: !R.value || R.value.is_root,
|
|
791
791
|
onClick: se
|
|
792
792
|
}, null, 8, ["title", "disabled"]),
|
|
793
793
|
h(e(T), {
|
|
794
794
|
type: "remove",
|
|
795
795
|
title: e(t)("manager.delete"),
|
|
796
|
-
disabled: !
|
|
796
|
+
disabled: !R.value || R.value.is_root,
|
|
797
797
|
onClick: de
|
|
798
798
|
}, null, 8, ["title", "disabled"])
|
|
799
799
|
]),
|
|
800
800
|
_: 1
|
|
801
|
-
})) :
|
|
801
|
+
})) : U("", !0)
|
|
802
802
|
])),
|
|
803
|
-
|
|
803
|
+
_("section", ct, [
|
|
804
804
|
h(ot, {
|
|
805
|
-
search:
|
|
806
|
-
"onUpdate:search":
|
|
807
|
-
type:
|
|
808
|
-
"onUpdate:type":
|
|
809
|
-
sort:
|
|
810
|
-
"onUpdate:sort":
|
|
805
|
+
search: x.value,
|
|
806
|
+
"onUpdate:search": o[1] || (o[1] = (y) => x.value = y),
|
|
807
|
+
type: z.value,
|
|
808
|
+
"onUpdate:type": o[2] || (o[2] = (y) => z.value = y),
|
|
809
|
+
sort: X.value,
|
|
810
|
+
"onUpdate:sort": o[3] || (o[3] = (y) => X.value = y),
|
|
811
811
|
"can-upload": Ce.value,
|
|
812
812
|
"fixed-type": a.accept !== null,
|
|
813
813
|
"can-manage": K.value,
|
|
814
|
-
selected:
|
|
814
|
+
selected: s.value.length,
|
|
815
815
|
compact: u.value,
|
|
816
816
|
onUpload: Me,
|
|
817
817
|
onMove: We,
|
|
818
818
|
onRemove: De,
|
|
819
|
-
onFolders:
|
|
819
|
+
onFolders: o[4] || (o[4] = (y) => H.value = !0)
|
|
820
820
|
}, null, 8, ["search", "type", "sort", "can-upload", "fixed-type", "can-manage", "selected", "compact"]),
|
|
821
|
-
|
|
821
|
+
_("input", {
|
|
822
822
|
ref_key: "picker",
|
|
823
823
|
ref: oe,
|
|
824
824
|
type: "file",
|
|
@@ -828,52 +828,52 @@ const ut = {
|
|
|
828
828
|
onChange: Te
|
|
829
829
|
}, null, 40, mt),
|
|
830
830
|
h(lt, {
|
|
831
|
-
selected:
|
|
832
|
-
"onUpdate:selected":
|
|
831
|
+
selected: s.value,
|
|
832
|
+
"onUpdate:selected": o[5] || (o[5] = (y) => s.value = y),
|
|
833
833
|
files: _e.value,
|
|
834
|
-
api: e(
|
|
835
|
-
query:
|
|
834
|
+
api: e(i),
|
|
835
|
+
query: x.value,
|
|
836
836
|
single: a.picking,
|
|
837
837
|
onRename: Le,
|
|
838
838
|
onEdit: Re,
|
|
839
839
|
onRemove: Ue,
|
|
840
|
-
onOpen:
|
|
840
|
+
onOpen: o[6] || (o[6] = (y) => l("pick", y))
|
|
841
841
|
}, null, 8, ["selected", "files", "api", "query", "single"]),
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
842
|
+
_("footer", pt, [
|
|
843
|
+
_("span", null, L(e(t)("manager.status-files", { count: c.value?.stats.files ?? 0 })), 1),
|
|
844
|
+
s.value.length > 0 ? (b(), W("span", ft, L(e(t)("manager.status-selected", { count: s.value.length })), 1)) : U("", !0),
|
|
845
|
+
_("span", null, L(e(t)("manager.status-size", { size: Se(c.value?.stats.size ?? 0) })), 1)
|
|
846
846
|
]),
|
|
847
|
-
|
|
847
|
+
c.value && c.value.meta.last_page > 1 ? (b(), $(e(Ye), {
|
|
848
848
|
key: 0,
|
|
849
|
-
page:
|
|
850
|
-
"per-page":
|
|
851
|
-
total:
|
|
852
|
-
"last-page":
|
|
849
|
+
page: c.value.meta.current_page,
|
|
850
|
+
"per-page": c.value.meta.per_page,
|
|
851
|
+
total: c.value.meta.total,
|
|
852
|
+
"last-page": c.value.meta.last_page,
|
|
853
853
|
disabled: J.value,
|
|
854
854
|
size: "sm",
|
|
855
|
-
onChange:
|
|
856
|
-
}, null, 8, ["page", "per-page", "total", "last-page", "disabled"])) :
|
|
855
|
+
onChange: o[7] || (o[7] = ({ page: y }) => V(y))
|
|
856
|
+
}, null, 8, ["page", "per-page", "total", "last-page", "disabled"])) : U("", !0)
|
|
857
857
|
]),
|
|
858
858
|
h(e(Je), {
|
|
859
859
|
open: H.value,
|
|
860
|
-
"onUpdate:open":
|
|
860
|
+
"onUpdate:open": o[10] || (o[10] = (y) => H.value = y),
|
|
861
861
|
side: "left",
|
|
862
862
|
title: e(t)("manager.folders"),
|
|
863
863
|
size: 280
|
|
864
864
|
}, {
|
|
865
865
|
default: w(() => [
|
|
866
|
-
|
|
866
|
+
_("div", vt, [
|
|
867
867
|
h(ge, {
|
|
868
|
-
selected:
|
|
868
|
+
selected: f.value,
|
|
869
869
|
"onUpdate:selected": [
|
|
870
|
-
|
|
871
|
-
|
|
870
|
+
o[8] || (o[8] = (y) => f.value = y),
|
|
871
|
+
o[9] || (o[9] = (y) => H.value = !1)
|
|
872
872
|
],
|
|
873
|
-
directories:
|
|
873
|
+
directories: n.value,
|
|
874
874
|
onMove: ue
|
|
875
875
|
}, null, 8, ["selected", "directories"]),
|
|
876
|
-
K.value ? (b(),
|
|
876
|
+
K.value ? (b(), $(e(G), {
|
|
877
877
|
key: 0,
|
|
878
878
|
size: "sm",
|
|
879
879
|
align: "start"
|
|
@@ -887,28 +887,28 @@ const ut = {
|
|
|
887
887
|
h(e(T), {
|
|
888
888
|
type: "edit",
|
|
889
889
|
title: e(t)("manager.rename"),
|
|
890
|
-
disabled: !
|
|
890
|
+
disabled: !R.value || R.value.is_root,
|
|
891
891
|
onClick: se
|
|
892
892
|
}, null, 8, ["title", "disabled"]),
|
|
893
893
|
h(e(T), {
|
|
894
894
|
type: "remove",
|
|
895
895
|
title: e(t)("manager.delete"),
|
|
896
|
-
disabled: !
|
|
896
|
+
disabled: !R.value || R.value.is_root,
|
|
897
897
|
onClick: de
|
|
898
898
|
}, null, 8, ["title", "disabled"])
|
|
899
899
|
]),
|
|
900
900
|
_: 1
|
|
901
|
-
})) :
|
|
901
|
+
})) : U("", !0)
|
|
902
902
|
])
|
|
903
903
|
]),
|
|
904
904
|
_: 1
|
|
905
905
|
}, 8, ["open", "title"])
|
|
906
906
|
], 2));
|
|
907
907
|
}
|
|
908
|
-
}), gt = /* @__PURE__ */
|
|
908
|
+
}), gt = /* @__PURE__ */ S({
|
|
909
909
|
__name: "MediaPage",
|
|
910
910
|
setup(a) {
|
|
911
|
-
return (
|
|
911
|
+
return (d, m) => (b(), $(e(Ze), {
|
|
912
912
|
class: "wx-media-page",
|
|
913
913
|
padding: "md"
|
|
914
914
|
}, {
|
|
@@ -918,7 +918,7 @@ const ut = {
|
|
|
918
918
|
_: 1
|
|
919
919
|
}));
|
|
920
920
|
}
|
|
921
|
-
}), yt = { class: "wx-media-picker" }, $e = /* @__PURE__ */
|
|
921
|
+
}), yt = { class: "wx-media-picker" }, $e = /* @__PURE__ */ S({
|
|
922
922
|
__name: "MediaPicker",
|
|
923
923
|
props: {
|
|
924
924
|
accept: { default: "image" },
|
|
@@ -926,19 +926,19 @@ const ut = {
|
|
|
926
926
|
manage: { type: Boolean, default: !1 }
|
|
927
927
|
},
|
|
928
928
|
setup(a) {
|
|
929
|
-
const { open:
|
|
930
|
-
return (
|
|
931
|
-
open: e(
|
|
932
|
-
"onUpdate:open":
|
|
929
|
+
const { open: d, resolve: m } = ae(), l = B("webx-media");
|
|
930
|
+
return (v, i) => (b(), $(e(le), {
|
|
931
|
+
open: e(d),
|
|
932
|
+
"onUpdate:open": i[1] || (i[1] = (t) => te(d) ? d.value = t : null),
|
|
933
933
|
title: a.title ?? e(l)("module.title"),
|
|
934
934
|
width: 960
|
|
935
935
|
}, {
|
|
936
936
|
default: w(() => [
|
|
937
|
-
|
|
937
|
+
_("div", yt, [
|
|
938
938
|
h(ke, {
|
|
939
939
|
picking: !a.manage,
|
|
940
940
|
accept: a.manage ? null : a.accept,
|
|
941
|
-
onPick:
|
|
941
|
+
onPick: i[0] || (i[0] = (t) => e(m)(t))
|
|
942
942
|
}, null, 8, ["picking", "accept"])
|
|
943
943
|
])
|
|
944
944
|
]),
|
|
@@ -957,12 +957,13 @@ const ut = {
|
|
|
957
957
|
}, _t = {
|
|
958
958
|
key: 0,
|
|
959
959
|
class: "wx-media-field__bar"
|
|
960
|
-
}, Ct = { class: "wx-media-field__captions" }, Mt = { class: "wx-media-field__caption" }, Tt = { class: "wx-media-field__caption" }, zt = { class: "wx-media-field__captions-footer" }, Rt = /* @__PURE__ */
|
|
960
|
+
}, Ct = { class: "wx-media-field__captions" }, Mt = { class: "wx-media-field__caption" }, Tt = { class: "wx-media-field__caption" }, zt = { class: "wx-media-field__captions-footer" }, Rt = /* @__PURE__ */ S({
|
|
961
961
|
__name: "MediaField",
|
|
962
962
|
props: /* @__PURE__ */ F({
|
|
963
963
|
label: { default: void 0 },
|
|
964
964
|
accept: { default: "image" },
|
|
965
965
|
captions: { type: Boolean, default: !0 },
|
|
966
|
+
aspect: { default: "16/9" },
|
|
966
967
|
height: { default: 220 },
|
|
967
968
|
disabled: { type: Boolean, default: !1 }
|
|
968
969
|
}, {
|
|
@@ -971,67 +972,71 @@ const ut = {
|
|
|
971
972
|
}),
|
|
972
973
|
emits: ["update:modelValue"],
|
|
973
974
|
setup(a) {
|
|
974
|
-
const
|
|
975
|
+
const d = a, m = A(a, "modelValue");
|
|
975
976
|
xe();
|
|
976
|
-
const l = B("webx-media"),
|
|
977
|
+
const l = B("webx-media"), v = we(ie()), i = {
|
|
978
|
+
"16/9": "16 / 9",
|
|
979
|
+
"4/3": "4 / 3",
|
|
980
|
+
"1/1": "1 / 1"
|
|
981
|
+
}, t = M(!1), p = M({});
|
|
977
982
|
q(
|
|
978
983
|
() => m.value?.path,
|
|
979
|
-
async (
|
|
980
|
-
if (!
|
|
981
|
-
const
|
|
982
|
-
|
|
984
|
+
async (s) => {
|
|
985
|
+
if (!s || m.value?.url || p.value[s]) return;
|
|
986
|
+
const x = await v.fileByPath(s);
|
|
987
|
+
x && (p.value = { ...p.value, [s]: x.url });
|
|
983
988
|
},
|
|
984
989
|
{ immediate: !0 }
|
|
985
990
|
);
|
|
986
|
-
const
|
|
987
|
-
const
|
|
988
|
-
return
|
|
989
|
-
}),
|
|
990
|
-
height: typeof
|
|
991
|
-
|
|
992
|
-
function
|
|
993
|
-
return m.value?.[
|
|
991
|
+
const k = D(() => {
|
|
992
|
+
const s = m.value;
|
|
993
|
+
return s ? s.url ?? p.value[s.path] ?? null : null;
|
|
994
|
+
}), g = D(
|
|
995
|
+
() => d.aspect ? { aspectRatio: i[d.aspect] ?? d.aspect } : { height: typeof d.height == "number" ? `${d.height}px` : d.height }
|
|
996
|
+
);
|
|
997
|
+
function u(s) {
|
|
998
|
+
return m.value?.[s] ?? {};
|
|
994
999
|
}
|
|
995
|
-
function
|
|
996
|
-
m.value && (m.value = { ...m.value, [
|
|
1000
|
+
function n(s, x) {
|
|
1001
|
+
m.value && (m.value = { ...m.value, [s]: x });
|
|
997
1002
|
}
|
|
998
|
-
async function
|
|
999
|
-
if (
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1003
|
+
async function f() {
|
|
1004
|
+
if (d.disabled) return;
|
|
1005
|
+
const s = await ht({ accept: d.accept });
|
|
1006
|
+
s && (m.value = { ...m.value, path: s.path, url: s.url });
|
|
1002
1007
|
}
|
|
1003
|
-
function
|
|
1004
|
-
m.value = null,
|
|
1008
|
+
function c() {
|
|
1009
|
+
m.value = null, t.value = !1;
|
|
1005
1010
|
}
|
|
1006
|
-
return (
|
|
1007
|
-
a.label ? (b(),
|
|
1008
|
-
m.value ? (b(),
|
|
1011
|
+
return (s, x) => (b(), W("div", bt, [
|
|
1012
|
+
a.label ? (b(), W("span", wt, L(a.label), 1)) : U("", !0),
|
|
1013
|
+
m.value ? (b(), W("div", {
|
|
1009
1014
|
key: 2,
|
|
1010
1015
|
class: "wx-media-field__frame",
|
|
1011
|
-
style: me(
|
|
1016
|
+
style: me(g.value)
|
|
1012
1017
|
}, [
|
|
1013
|
-
|
|
1018
|
+
_("button", {
|
|
1014
1019
|
type: "button",
|
|
1015
1020
|
class: "wx-media-field__picture",
|
|
1016
1021
|
disabled: a.disabled,
|
|
1017
1022
|
title: e(l)("field.replace"),
|
|
1018
|
-
onClick:
|
|
1023
|
+
onClick: f
|
|
1019
1024
|
}, [
|
|
1020
|
-
|
|
1025
|
+
k.value ? (b(), $(e(et), {
|
|
1021
1026
|
key: 0,
|
|
1022
|
-
src:
|
|
1027
|
+
src: k.value,
|
|
1023
1028
|
fit: "contain",
|
|
1024
1029
|
width: "100%",
|
|
1025
1030
|
height: "100%"
|
|
1026
|
-
}, null, 8, ["src"])) : (b(),
|
|
1031
|
+
}, null, 8, ["src"])) : (b(), W("span", $t, L(e(l)("field.no-preview")), 1))
|
|
1027
1032
|
], 8, kt),
|
|
1028
|
-
a.disabled ?
|
|
1033
|
+
a.disabled ? U("", !0) : (b(), W("div", _t, [
|
|
1029
1034
|
h(e(G), { size: "sm" }, {
|
|
1030
1035
|
default: w(() => [
|
|
1031
|
-
a.captions ? (b(),
|
|
1036
|
+
a.captions ? (b(), $(e(tt), {
|
|
1032
1037
|
key: 0,
|
|
1033
|
-
open:
|
|
1034
|
-
"onUpdate:open":
|
|
1038
|
+
open: t.value,
|
|
1039
|
+
"onUpdate:open": x[3] || (x[3] = (z) => t.value = z),
|
|
1035
1040
|
title: e(l)("field.captions"),
|
|
1036
1041
|
width: 360,
|
|
1037
1042
|
side: "top",
|
|
@@ -1044,41 +1049,41 @@ const ut = {
|
|
|
1044
1049
|
}, null, 8, ["title"])
|
|
1045
1050
|
]),
|
|
1046
1051
|
default: w(() => [
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1052
|
+
_("div", Ct, [
|
|
1053
|
+
_("div", Mt, [
|
|
1054
|
+
x[4] || (x[4] = _("label", {
|
|
1050
1055
|
class: "wx-media-field__caption-label",
|
|
1051
1056
|
for: "wx-media-alt"
|
|
1052
1057
|
}, "alt", -1)),
|
|
1053
1058
|
h(e(j), {
|
|
1054
1059
|
id: "wx-media-alt",
|
|
1055
1060
|
localized: "",
|
|
1056
|
-
"model-value":
|
|
1061
|
+
"model-value": u("alt"),
|
|
1057
1062
|
placeholder: e(l)("field.alt-hint"),
|
|
1058
|
-
"onUpdate:modelValue":
|
|
1063
|
+
"onUpdate:modelValue": x[0] || (x[0] = (z) => n("alt", z))
|
|
1059
1064
|
}, null, 8, ["model-value", "placeholder"])
|
|
1060
1065
|
]),
|
|
1061
|
-
|
|
1062
|
-
|
|
1066
|
+
_("div", Tt, [
|
|
1067
|
+
x[5] || (x[5] = _("label", {
|
|
1063
1068
|
class: "wx-media-field__caption-label",
|
|
1064
1069
|
for: "wx-media-title"
|
|
1065
1070
|
}, "title", -1)),
|
|
1066
1071
|
h(e(j), {
|
|
1067
1072
|
id: "wx-media-title",
|
|
1068
1073
|
localized: "",
|
|
1069
|
-
"model-value":
|
|
1074
|
+
"model-value": u("title"),
|
|
1070
1075
|
placeholder: e(l)("field.title-hint"),
|
|
1071
|
-
"onUpdate:modelValue":
|
|
1076
|
+
"onUpdate:modelValue": x[1] || (x[1] = (z) => n("title", z))
|
|
1072
1077
|
}, null, 8, ["model-value", "placeholder"])
|
|
1073
1078
|
]),
|
|
1074
|
-
|
|
1075
|
-
h(e(
|
|
1079
|
+
_("div", zt, [
|
|
1080
|
+
h(e(I), {
|
|
1076
1081
|
size: "sm",
|
|
1077
1082
|
type: "primary",
|
|
1078
|
-
onClick:
|
|
1083
|
+
onClick: x[2] || (x[2] = (z) => t.value = !1)
|
|
1079
1084
|
}, {
|
|
1080
1085
|
default: w(() => [
|
|
1081
|
-
|
|
1086
|
+
P(L(e(l)("manager.save")), 1)
|
|
1082
1087
|
]),
|
|
1083
1088
|
_: 1
|
|
1084
1089
|
})
|
|
@@ -1086,7 +1091,7 @@ const ut = {
|
|
|
1086
1091
|
])
|
|
1087
1092
|
]),
|
|
1088
1093
|
_: 1
|
|
1089
|
-
}, 8, ["open", "title"])) :
|
|
1094
|
+
}, 8, ["open", "title"])) : U("", !0),
|
|
1090
1095
|
h(e(at), {
|
|
1091
1096
|
title: e(l)("field.clear-title"),
|
|
1092
1097
|
description: e(l)("field.clear-text"),
|
|
@@ -1094,7 +1099,7 @@ const ut = {
|
|
|
1094
1099
|
"cancel-text": e(l)("manager.cancel"),
|
|
1095
1100
|
"confirm-type": "danger",
|
|
1096
1101
|
side: "top",
|
|
1097
|
-
onConfirm:
|
|
1102
|
+
onConfirm: c
|
|
1098
1103
|
}, {
|
|
1099
1104
|
trigger: w(() => [
|
|
1100
1105
|
h(e(T), {
|
|
@@ -1108,29 +1113,29 @@ const ut = {
|
|
|
1108
1113
|
_: 1
|
|
1109
1114
|
})
|
|
1110
1115
|
]))
|
|
1111
|
-
], 4)) : (b(),
|
|
1116
|
+
], 4)) : (b(), W("div", {
|
|
1112
1117
|
key: 1,
|
|
1113
1118
|
class: "wx-media-field__frame is-empty",
|
|
1114
|
-
style: me(
|
|
1119
|
+
style: me(g.value)
|
|
1115
1120
|
}, [
|
|
1116
|
-
|
|
1121
|
+
_("button", {
|
|
1117
1122
|
type: "button",
|
|
1118
1123
|
class: "wx-media-field__pick",
|
|
1119
1124
|
disabled: a.disabled,
|
|
1120
|
-
onClick:
|
|
1121
|
-
},
|
|
1125
|
+
onClick: f
|
|
1126
|
+
}, L(e(l)("field.select")), 9, xt)
|
|
1122
1127
|
], 4))
|
|
1123
1128
|
]));
|
|
1124
1129
|
}
|
|
1125
1130
|
});
|
|
1126
1131
|
function Vt(a = {}) {
|
|
1127
|
-
const
|
|
1132
|
+
const d = a.path ?? "/media";
|
|
1128
1133
|
return {
|
|
1129
1134
|
id: "media",
|
|
1130
|
-
path:
|
|
1135
|
+
path: d,
|
|
1131
1136
|
routes: [
|
|
1132
1137
|
{
|
|
1133
|
-
path:
|
|
1138
|
+
path: d,
|
|
1134
1139
|
name: "webx.media",
|
|
1135
1140
|
component: gt
|
|
1136
1141
|
}
|