@webx-ui/module-media 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +541 -486
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { defineComponent as R, useModel as
|
|
2
|
-
import { WxTree as
|
|
3
|
-
import { useTranslate as S, useAdmin as
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as R, useModel as q, ref as M, watch as K, openBlock as b, createBlock as k, unref as e, mergeModels as B, computed as C, resolveDirective as Se, withCtx as w, createElementBlock as U, Fragment as j, renderList as Z, withDirectives as Be, createCommentVNode as T, createVNode as y, createTextVNode as F, toDisplayString as z, isRef as ae, useTemplateRef as ee, onMounted as ye, nextTick as Oe, createElementVNode as V, withKeys as Pe, normalizeClass as qe } from "vue";
|
|
2
|
+
import { WxTree as Ne, WxSelectionArea as Ae, WxFileCard as He, WxEmpty as Xe, toast as P, WxAction as _, WxInput as G, WxDropdown as me, WxDropdownItem as pe, WxActions as te, useModal as le, WxDialog as oe, WxSelect as Ie, WxSpace as Y, WxButton as N, useElementWidth as Ke, createModal as J, WxPagination as je, WxDrawer as Ge, confirm as ve, openImageEditor as Ye, WxCard as Je, WxImage as Qe } from "@webx-ui/core";
|
|
3
|
+
import { useTranslate as S, useAdmin as he } from "@webx-ui/admin";
|
|
4
|
+
const fe = /* @__PURE__ */ R({
|
|
5
5
|
__name: "DirectoryTree",
|
|
6
|
-
props: /* @__PURE__ */
|
|
6
|
+
props: /* @__PURE__ */ B({
|
|
7
7
|
directories: {}
|
|
8
8
|
}, {
|
|
9
9
|
selected: { default: null },
|
|
10
10
|
selectedModifiers: {}
|
|
11
11
|
}),
|
|
12
|
-
emits: /* @__PURE__ */
|
|
13
|
-
setup(
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
() =>
|
|
17
|
-
(
|
|
18
|
-
|
|
12
|
+
emits: /* @__PURE__ */ B(["move"], ["update:selected"]),
|
|
13
|
+
setup(a, { emit: v }) {
|
|
14
|
+
const u = a, l = q(a, "selected"), m = v, o = S("webx-media"), t = M([]), s = M([]);
|
|
15
|
+
K(
|
|
16
|
+
() => u.directories,
|
|
17
|
+
(i) => {
|
|
18
|
+
t.value = i.map(x), s.value = p(i);
|
|
19
19
|
},
|
|
20
20
|
{ immediate: !0, deep: !0 }
|
|
21
21
|
);
|
|
22
|
-
function x(
|
|
22
|
+
function x(i) {
|
|
23
23
|
return {
|
|
24
|
-
...
|
|
25
|
-
label:
|
|
26
|
-
children: (
|
|
24
|
+
...i,
|
|
25
|
+
label: i.is_root ? o("manager.root") : i.title,
|
|
26
|
+
children: (i.children ?? []).map(x)
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function p(
|
|
30
|
-
return
|
|
29
|
+
function p(i) {
|
|
30
|
+
return i.flatMap((f) => [f.id, ...p(f.children ?? [])]);
|
|
31
31
|
}
|
|
32
|
-
function d(
|
|
33
|
-
const f =
|
|
34
|
-
f &&
|
|
32
|
+
function d(i) {
|
|
33
|
+
const f = i.zone === "inside" ? i.target : i.parent;
|
|
34
|
+
f && m("move", i.node.id, f.id);
|
|
35
35
|
}
|
|
36
|
-
return (
|
|
37
|
-
selected:
|
|
38
|
-
"onUpdate:selected": f[0] || (f[0] = (
|
|
39
|
-
expanded:
|
|
40
|
-
"onUpdate:expanded": f[1] || (f[1] = (
|
|
41
|
-
modelValue:
|
|
42
|
-
"onUpdate:modelValue": f[2] || (f[2] = (
|
|
36
|
+
return (i, f) => (b(), k(e(Ne), {
|
|
37
|
+
selected: l.value,
|
|
38
|
+
"onUpdate:selected": f[0] || (f[0] = (c) => l.value = c),
|
|
39
|
+
expanded: s.value,
|
|
40
|
+
"onUpdate:expanded": f[1] || (f[1] = (c) => s.value = c),
|
|
41
|
+
modelValue: t.value,
|
|
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,9 +47,9 @@ const ve = /* @__PURE__ */ R({
|
|
|
47
47
|
onDrop: d
|
|
48
48
|
}, null, 8, ["selected", "expanded", "modelValue"]));
|
|
49
49
|
}
|
|
50
|
-
}),
|
|
50
|
+
}), Ze = /* @__PURE__ */ R({
|
|
51
51
|
__name: "FileGrid",
|
|
52
|
-
props: /* @__PURE__ */
|
|
52
|
+
props: /* @__PURE__ */ B({
|
|
53
53
|
files: {},
|
|
54
54
|
api: {},
|
|
55
55
|
query: {},
|
|
@@ -58,76 +58,79 @@ const ve = /* @__PURE__ */ R({
|
|
|
58
58
|
selected: { default: () => [] },
|
|
59
59
|
selectedModifiers: {}
|
|
60
60
|
}),
|
|
61
|
-
emits: /* @__PURE__ */
|
|
62
|
-
setup(
|
|
63
|
-
const
|
|
64
|
-
() =>
|
|
61
|
+
emits: /* @__PURE__ */ B(["open", "rename", "edit", "remove"], ["update:selected"]),
|
|
62
|
+
setup(a, { emit: v }) {
|
|
63
|
+
const u = a, l = q(a, "selected"), m = v, o = S("webx-media"), t = C(
|
|
64
|
+
() => u.query ? o("manager.empty-search", { query: u.query }) : o("manager.empty")
|
|
65
65
|
);
|
|
66
|
-
function
|
|
67
|
-
|
|
66
|
+
function s() {
|
|
67
|
+
P.success(o("manager.link-copied"));
|
|
68
68
|
}
|
|
69
69
|
function x(p) {
|
|
70
70
|
const d = document.createElement("textarea");
|
|
71
71
|
d.value = p.url, d.setAttribute("readonly", ""), d.style.position = "fixed", d.style.opacity = "0", document.body.appendChild(d), d.select();
|
|
72
|
-
let
|
|
72
|
+
let i = !1;
|
|
73
73
|
try {
|
|
74
|
-
|
|
74
|
+
i = document.execCommand("copy");
|
|
75
75
|
} catch {
|
|
76
|
-
|
|
76
|
+
i = !1;
|
|
77
77
|
}
|
|
78
|
-
if (d.remove(),
|
|
79
|
-
|
|
78
|
+
if (d.remove(), i) {
|
|
79
|
+
s();
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
P.danger(`${o("errors.copy")} ${p.url}`, { duration: 0 });
|
|
83
83
|
}
|
|
84
84
|
return (p, d) => {
|
|
85
|
-
const
|
|
86
|
-
return
|
|
85
|
+
const i = Se("wx-select");
|
|
86
|
+
return a.files.length > 0 ? (b(), k(e(Ae), {
|
|
87
87
|
key: 0,
|
|
88
|
-
modelValue:
|
|
89
|
-
"onUpdate:modelValue": d[0] || (d[0] = (f) =>
|
|
88
|
+
modelValue: l.value,
|
|
89
|
+
"onUpdate:modelValue": d[0] || (d[0] = (f) => l.value = f),
|
|
90
90
|
class: "wx-media-grid",
|
|
91
|
-
multiple: !
|
|
91
|
+
multiple: !a.single
|
|
92
92
|
}, {
|
|
93
|
-
default:
|
|
94
|
-
(
|
|
95
|
-
key:
|
|
93
|
+
default: w(({ isSelected: f }) => [
|
|
94
|
+
(b(!0), U(j, null, Z(a.files, (c) => Be((b(), k(e(He), {
|
|
95
|
+
key: c.id,
|
|
96
96
|
class: "wx-media-grid__card",
|
|
97
|
-
name:
|
|
98
|
-
url:
|
|
99
|
-
thumbnail:
|
|
100
|
-
type:
|
|
101
|
-
selected: f(
|
|
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
|
-
"
|
|
110
|
-
"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
106
|
+
"rename-label": e(o)("manager.rename"),
|
|
107
|
+
"edit-label": e(o)("manager.edit"),
|
|
108
|
+
"remove-label": e(o)("manager.delete"),
|
|
109
|
+
"remove-confirm-text": e(o)("dialogs.delete-file", { name: c.name }),
|
|
110
|
+
"cancel-label": e(o)("manager.cancel"),
|
|
111
|
+
"save-label": e(o)("manager.save"),
|
|
112
|
+
"copy-label": e(o)("manager.copy-link"),
|
|
113
|
+
"copied-label": e(o)("manager.link-copied"),
|
|
114
|
+
onRename: (h) => m("rename", c, h),
|
|
115
|
+
onEdit: (h) => m("edit", c),
|
|
116
|
+
onRemove: (h) => m("remove", c),
|
|
117
|
+
onCopy: s,
|
|
118
|
+
onCopyError: (h) => x(c),
|
|
119
|
+
onDblclick: (h) => m("open", c)
|
|
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
|
+
[i, c.id]
|
|
119
122
|
])), 128))
|
|
120
123
|
]),
|
|
121
124
|
_: 1
|
|
122
|
-
}, 8, ["modelValue", "multiple"])) : (
|
|
125
|
+
}, 8, ["modelValue", "multiple"])) : (b(), k(e(Xe), {
|
|
123
126
|
key: 1,
|
|
124
|
-
description:
|
|
127
|
+
description: t.value
|
|
125
128
|
}, null, 8, ["description"]));
|
|
126
129
|
};
|
|
127
130
|
}
|
|
128
|
-
}),
|
|
131
|
+
}), et = { class: "wx-media-toolbar" }, tt = /* @__PURE__ */ R({
|
|
129
132
|
__name: "MediaToolbar",
|
|
130
|
-
props: /* @__PURE__ */
|
|
133
|
+
props: /* @__PURE__ */ B({
|
|
131
134
|
canUpload: { type: Boolean },
|
|
132
135
|
canManage: { type: Boolean },
|
|
133
136
|
selected: {},
|
|
@@ -140,155 +143,155 @@ const ve = /* @__PURE__ */ R({
|
|
|
140
143
|
sort: { default: "-created_at" },
|
|
141
144
|
sortModifiers: {}
|
|
142
145
|
}),
|
|
143
|
-
emits: /* @__PURE__ */
|
|
144
|
-
setup(
|
|
145
|
-
const
|
|
146
|
-
{ value: "all", label:
|
|
146
|
+
emits: /* @__PURE__ */ B(["upload", "move", "remove", "folders"], ["update:search", "update:type", "update:sort"]),
|
|
147
|
+
setup(a, { emit: v }) {
|
|
148
|
+
const u = a, l = q(a, "search"), m = q(a, "type"), o = q(a, "sort"), t = v, s = S("webx-media"), x = C(() => [
|
|
149
|
+
{ value: "all", label: s("manager.all-types") },
|
|
147
150
|
...["image", "video", "audio", "document", "other"].map((f) => ({
|
|
148
151
|
value: f,
|
|
149
|
-
label:
|
|
152
|
+
label: s(`manager.${f}`)
|
|
150
153
|
}))
|
|
151
154
|
]), p = C(() => [
|
|
152
|
-
{ value: "-created_at", label:
|
|
153
|
-
{ value: "created_at", label:
|
|
154
|
-
{ value: "name", label:
|
|
155
|
-
{ value: "-size", label:
|
|
156
|
-
]), d = C(() => x.value.find((f) => f.value ===
|
|
157
|
-
return (f,
|
|
158
|
-
|
|
155
|
+
{ value: "-created_at", label: s("manager.sort-newest") },
|
|
156
|
+
{ value: "created_at", label: s("manager.sort-oldest") },
|
|
157
|
+
{ value: "name", label: s("manager.sort-name") },
|
|
158
|
+
{ value: "-size", label: s("manager.sort-size") }
|
|
159
|
+
]), d = C(() => x.value.find((f) => f.value === m.value)?.label ?? ""), i = C(() => p.value.find((f) => f.value === o.value)?.label ?? "");
|
|
160
|
+
return (f, c) => (b(), U("header", et, [
|
|
161
|
+
a.compact ? (b(), k(e(_), {
|
|
159
162
|
key: 0,
|
|
160
163
|
icon: "folder",
|
|
161
|
-
title: e(
|
|
164
|
+
title: e(s)("manager.folders"),
|
|
162
165
|
size: "sm",
|
|
163
|
-
onClick:
|
|
166
|
+
onClick: c[0] || (c[0] = (h) => t("folders"))
|
|
164
167
|
}, null, 8, ["title"])) : T("", !0),
|
|
165
|
-
y(e(
|
|
166
|
-
modelValue:
|
|
167
|
-
"onUpdate:modelValue":
|
|
168
|
+
y(e(G), {
|
|
169
|
+
modelValue: l.value,
|
|
170
|
+
"onUpdate:modelValue": c[1] || (c[1] = (h) => l.value = h),
|
|
168
171
|
class: "wx-media-toolbar__search",
|
|
169
|
-
placeholder: e(
|
|
172
|
+
placeholder: e(s)("manager.search"),
|
|
170
173
|
clearable: "",
|
|
171
174
|
size: "sm"
|
|
172
175
|
}, null, 8, ["modelValue", "placeholder"]),
|
|
173
|
-
y(e(
|
|
174
|
-
trigger:
|
|
175
|
-
y(e(
|
|
176
|
+
y(e(me), null, {
|
|
177
|
+
trigger: w(() => [
|
|
178
|
+
y(e(_), {
|
|
176
179
|
icon: "filter",
|
|
177
|
-
title: `${e(
|
|
180
|
+
title: `${e(s)("manager.all-types")}: ${d.value}`,
|
|
178
181
|
size: "sm"
|
|
179
182
|
}, null, 8, ["title"])
|
|
180
183
|
]),
|
|
181
|
-
default:
|
|
182
|
-
(
|
|
183
|
-
key: String(
|
|
184
|
-
active:
|
|
185
|
-
onClick: (
|
|
184
|
+
default: w(() => [
|
|
185
|
+
(b(!0), U(j, null, Z(x.value, (h) => (b(), k(e(pe), {
|
|
186
|
+
key: String(h.value),
|
|
187
|
+
active: h.value === m.value,
|
|
188
|
+
onClick: (E) => m.value = h.value
|
|
186
189
|
}, {
|
|
187
|
-
default:
|
|
188
|
-
F(z(
|
|
190
|
+
default: w(() => [
|
|
191
|
+
F(z(h.label), 1)
|
|
189
192
|
]),
|
|
190
193
|
_: 2
|
|
191
194
|
}, 1032, ["active", "onClick"]))), 128))
|
|
192
195
|
]),
|
|
193
196
|
_: 1
|
|
194
197
|
}),
|
|
195
|
-
y(e(
|
|
196
|
-
trigger:
|
|
197
|
-
y(e(
|
|
198
|
+
y(e(me), null, {
|
|
199
|
+
trigger: w(() => [
|
|
200
|
+
y(e(_), {
|
|
198
201
|
icon: "arrow-down",
|
|
199
|
-
title:
|
|
202
|
+
title: i.value,
|
|
200
203
|
size: "sm"
|
|
201
204
|
}, null, 8, ["title"])
|
|
202
205
|
]),
|
|
203
|
-
default:
|
|
204
|
-
(
|
|
205
|
-
key:
|
|
206
|
-
active:
|
|
207
|
-
onClick: (
|
|
206
|
+
default: w(() => [
|
|
207
|
+
(b(!0), U(j, null, Z(p.value, (h) => (b(), k(e(pe), {
|
|
208
|
+
key: h.value,
|
|
209
|
+
active: h.value === o.value,
|
|
210
|
+
onClick: (E) => o.value = h.value
|
|
208
211
|
}, {
|
|
209
|
-
default:
|
|
210
|
-
F(z(
|
|
212
|
+
default: w(() => [
|
|
213
|
+
F(z(h.label), 1)
|
|
211
214
|
]),
|
|
212
215
|
_: 2
|
|
213
216
|
}, 1032, ["active", "onClick"]))), 128))
|
|
214
217
|
]),
|
|
215
218
|
_: 1
|
|
216
219
|
}),
|
|
217
|
-
|
|
220
|
+
a.canUpload ? (b(), k(e(_), {
|
|
218
221
|
key: 1,
|
|
219
222
|
type: "upload",
|
|
220
|
-
title: e(
|
|
223
|
+
title: e(s)("manager.upload"),
|
|
221
224
|
size: "sm",
|
|
222
|
-
onClick:
|
|
225
|
+
onClick: c[2] || (c[2] = (h) => t("upload"))
|
|
223
226
|
}, null, 8, ["title"])) : T("", !0),
|
|
224
|
-
|
|
227
|
+
a.canManage ? (b(), k(e(te), {
|
|
225
228
|
key: 2,
|
|
226
229
|
size: "sm"
|
|
227
230
|
}, {
|
|
228
|
-
default:
|
|
229
|
-
y(e(
|
|
231
|
+
default: w(() => [
|
|
232
|
+
y(e(_), {
|
|
230
233
|
icon: "folder",
|
|
231
|
-
title: e(
|
|
232
|
-
disabled:
|
|
233
|
-
onClick:
|
|
234
|
+
title: e(s)("manager.move"),
|
|
235
|
+
disabled: u.selected === 0,
|
|
236
|
+
onClick: c[3] || (c[3] = (h) => t("move"))
|
|
234
237
|
}, null, 8, ["title", "disabled"]),
|
|
235
|
-
y(e(
|
|
238
|
+
y(e(_), {
|
|
236
239
|
type: "remove",
|
|
237
|
-
title: e(
|
|
238
|
-
disabled:
|
|
239
|
-
onClick:
|
|
240
|
+
title: e(s)("manager.delete"),
|
|
241
|
+
disabled: u.selected === 0,
|
|
242
|
+
onClick: c[4] || (c[4] = (h) => t("remove"))
|
|
240
243
|
}, null, 8, ["title", "disabled"])
|
|
241
244
|
]),
|
|
242
245
|
_: 1
|
|
243
246
|
})) : T("", !0)
|
|
244
247
|
]));
|
|
245
248
|
}
|
|
246
|
-
}),
|
|
249
|
+
}), at = /* @__PURE__ */ R({
|
|
247
250
|
__name: "MoveDialog",
|
|
248
251
|
props: {
|
|
249
252
|
directories: {},
|
|
250
253
|
from: {},
|
|
251
254
|
count: {}
|
|
252
255
|
},
|
|
253
|
-
setup(
|
|
254
|
-
const
|
|
255
|
-
() => x(
|
|
256
|
-
),
|
|
256
|
+
setup(a) {
|
|
257
|
+
const v = a, { open: u, resolve: l, dismiss: m } = le(), o = S("webx-media"), t = C(
|
|
258
|
+
() => x(v.directories).filter((p) => p.value !== v.from)
|
|
259
|
+
), s = M(t.value[0]?.value ?? null);
|
|
257
260
|
function x(p) {
|
|
258
261
|
return p.flatMap((d) => [
|
|
259
262
|
{
|
|
260
263
|
value: d.id,
|
|
261
264
|
// Indented, so the tree is still readable once it is a flat list.
|
|
262
|
-
label: " ".repeat(d.depth * 3) + (d.is_root ?
|
|
265
|
+
label: " ".repeat(d.depth * 3) + (d.is_root ? o("manager.root") : d.title)
|
|
263
266
|
},
|
|
264
267
|
...x(d.children ?? [])
|
|
265
268
|
]);
|
|
266
269
|
}
|
|
267
|
-
return (p, d) => (
|
|
268
|
-
open: e(
|
|
269
|
-
"onUpdate:open": d[3] || (d[3] = (
|
|
270
|
-
title: e(
|
|
270
|
+
return (p, d) => (b(), k(e(oe), {
|
|
271
|
+
open: e(u),
|
|
272
|
+
"onUpdate:open": d[3] || (d[3] = (i) => ae(u) ? u.value = i : null),
|
|
273
|
+
title: e(o)("manager.move-to"),
|
|
271
274
|
width: 420
|
|
272
275
|
}, {
|
|
273
|
-
footer:
|
|
274
|
-
y(e(
|
|
275
|
-
default:
|
|
276
|
+
footer: w(() => [
|
|
277
|
+
y(e(Y), { size: "sm" }, {
|
|
278
|
+
default: w(() => [
|
|
276
279
|
y(e(N), {
|
|
277
280
|
variant: "outline",
|
|
278
|
-
onClick: d[1] || (d[1] = (
|
|
281
|
+
onClick: d[1] || (d[1] = (i) => e(m)())
|
|
279
282
|
}, {
|
|
280
|
-
default:
|
|
281
|
-
F(z(e(
|
|
283
|
+
default: w(() => [
|
|
284
|
+
F(z(e(o)("manager.cancel")), 1)
|
|
282
285
|
]),
|
|
283
286
|
_: 1
|
|
284
287
|
}),
|
|
285
288
|
y(e(N), {
|
|
286
289
|
type: "primary",
|
|
287
|
-
disabled:
|
|
288
|
-
onClick: d[2] || (d[2] = (
|
|
290
|
+
disabled: s.value === null,
|
|
291
|
+
onClick: d[2] || (d[2] = (i) => e(l)(s.value))
|
|
289
292
|
}, {
|
|
290
|
-
default:
|
|
291
|
-
F(z(e(
|
|
293
|
+
default: w(() => [
|
|
294
|
+
F(z(e(o)("manager.move")), 1)
|
|
292
295
|
]),
|
|
293
296
|
_: 1
|
|
294
297
|
}, 8, ["disabled"])
|
|
@@ -296,17 +299,17 @@ const ve = /* @__PURE__ */ R({
|
|
|
296
299
|
_: 1
|
|
297
300
|
})
|
|
298
301
|
]),
|
|
299
|
-
default:
|
|
302
|
+
default: w(() => [
|
|
300
303
|
y(e(Ie), {
|
|
301
|
-
modelValue:
|
|
302
|
-
"onUpdate:modelValue": d[0] || (d[0] = (
|
|
303
|
-
options:
|
|
304
|
+
modelValue: s.value,
|
|
305
|
+
"onUpdate:modelValue": d[0] || (d[0] = (i) => s.value = i),
|
|
306
|
+
options: t.value
|
|
304
307
|
}, null, 8, ["modelValue", "options"])
|
|
305
308
|
]),
|
|
306
309
|
_: 1
|
|
307
310
|
}, 8, ["open", "title"]));
|
|
308
311
|
}
|
|
309
|
-
}),
|
|
312
|
+
}), lt = /* @__PURE__ */ R({
|
|
310
313
|
__name: "NameDialog",
|
|
311
314
|
props: {
|
|
312
315
|
title: {},
|
|
@@ -314,40 +317,40 @@ const ve = /* @__PURE__ */ R({
|
|
|
314
317
|
value: { default: "" },
|
|
315
318
|
confirmText: { default: void 0 }
|
|
316
319
|
},
|
|
317
|
-
setup(
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
await
|
|
320
|
+
setup(a) {
|
|
321
|
+
const v = a, { open: u, resolve: l, dismiss: m } = le(), o = S("webx-media"), t = M(v.value), s = ee("input");
|
|
322
|
+
ye(async () => {
|
|
323
|
+
await Oe(), s.value?.querySelector("input")?.focus();
|
|
321
324
|
});
|
|
322
325
|
function x() {
|
|
323
|
-
const p =
|
|
324
|
-
p !== "" &&
|
|
326
|
+
const p = t.value.trim();
|
|
327
|
+
p !== "" && l(p);
|
|
325
328
|
}
|
|
326
|
-
return (p, d) => (
|
|
327
|
-
open: e(
|
|
328
|
-
"onUpdate:open": d[2] || (d[2] = (
|
|
329
|
-
title:
|
|
329
|
+
return (p, d) => (b(), k(e(oe), {
|
|
330
|
+
open: e(u),
|
|
331
|
+
"onUpdate:open": d[2] || (d[2] = (i) => ae(u) ? u.value = i : null),
|
|
332
|
+
title: a.title,
|
|
330
333
|
width: 420
|
|
331
334
|
}, {
|
|
332
|
-
footer:
|
|
333
|
-
y(e(
|
|
334
|
-
default:
|
|
335
|
+
footer: w(() => [
|
|
336
|
+
y(e(Y), { size: "sm" }, {
|
|
337
|
+
default: w(() => [
|
|
335
338
|
y(e(N), {
|
|
336
339
|
variant: "outline",
|
|
337
|
-
onClick: d[1] || (d[1] = (
|
|
340
|
+
onClick: d[1] || (d[1] = (i) => e(m)())
|
|
338
341
|
}, {
|
|
339
|
-
default:
|
|
340
|
-
F(z(e(
|
|
342
|
+
default: w(() => [
|
|
343
|
+
F(z(e(o)("manager.cancel")), 1)
|
|
341
344
|
]),
|
|
342
345
|
_: 1
|
|
343
346
|
}),
|
|
344
347
|
y(e(N), {
|
|
345
348
|
type: "primary",
|
|
346
|
-
disabled:
|
|
349
|
+
disabled: t.value.trim() === "",
|
|
347
350
|
onClick: x
|
|
348
351
|
}, {
|
|
349
|
-
default:
|
|
350
|
-
F(z(
|
|
352
|
+
default: w(() => [
|
|
353
|
+
F(z(a.confirmText ?? e(o)("manager.save")), 1)
|
|
351
354
|
]),
|
|
352
355
|
_: 1
|
|
353
356
|
}, 8, ["disabled"])
|
|
@@ -355,17 +358,17 @@ const ve = /* @__PURE__ */ R({
|
|
|
355
358
|
_: 1
|
|
356
359
|
})
|
|
357
360
|
]),
|
|
358
|
-
default:
|
|
359
|
-
|
|
361
|
+
default: w(() => [
|
|
362
|
+
V("div", {
|
|
360
363
|
ref_key: "input",
|
|
361
|
-
ref:
|
|
364
|
+
ref: s
|
|
362
365
|
}, [
|
|
363
|
-
y(e(
|
|
364
|
-
modelValue:
|
|
365
|
-
"onUpdate:modelValue": d[0] || (d[0] = (
|
|
366
|
-
placeholder:
|
|
367
|
-
"aria-label":
|
|
368
|
-
onKeyup:
|
|
366
|
+
y(e(G), {
|
|
367
|
+
modelValue: t.value,
|
|
368
|
+
"onUpdate:modelValue": d[0] || (d[0] = (i) => t.value = i),
|
|
369
|
+
placeholder: a.label ?? e(o)("manager.folder-name"),
|
|
370
|
+
"aria-label": a.label ?? e(o)("manager.folder-name"),
|
|
371
|
+
onKeyup: Pe(x, ["enter"])
|
|
369
372
|
}, null, 8, ["modelValue", "placeholder", "aria-label"])
|
|
370
373
|
], 512)
|
|
371
374
|
]),
|
|
@@ -373,72 +376,72 @@ const ve = /* @__PURE__ */ R({
|
|
|
373
376
|
}, 8, ["open", "title"]));
|
|
374
377
|
}
|
|
375
378
|
});
|
|
376
|
-
function
|
|
377
|
-
const
|
|
379
|
+
function ot(a) {
|
|
380
|
+
const v = `${a.apiPath}/media`, u = (l) => l.data;
|
|
378
381
|
return {
|
|
379
|
-
directories: () =>
|
|
380
|
-
createDirectory: (
|
|
381
|
-
renameDirectory: (
|
|
382
|
-
moveDirectory: (
|
|
383
|
-
deleteDirectory: (
|
|
384
|
-
query: { force:
|
|
382
|
+
directories: () => a.http.get(`${v}/directories`).then(u),
|
|
383
|
+
createDirectory: (l, m) => a.http.post(`${v}/directories`, { parent_id: l, title: m }).then(u),
|
|
384
|
+
renameDirectory: (l, m) => a.http.patch(`${v}/directories/${l}`, { title: m }).then(u),
|
|
385
|
+
moveDirectory: (l, m) => a.http.patch(`${v}/directories/${l}/move`, { parent_id: m }).then(u),
|
|
386
|
+
deleteDirectory: (l, m = !1) => a.http.delete(`${v}/directories/${l}`, {
|
|
387
|
+
query: { force: m ? 1 : void 0 }
|
|
385
388
|
}),
|
|
386
|
-
files: (
|
|
389
|
+
files: (l = {}) => a.http.get(`${v}/files`, {
|
|
387
390
|
query: {
|
|
388
|
-
directory_id:
|
|
389
|
-
q:
|
|
390
|
-
type:
|
|
391
|
-
sort:
|
|
392
|
-
page:
|
|
393
|
-
per_page:
|
|
391
|
+
directory_id: l.directory_id ?? void 0,
|
|
392
|
+
q: l.q || void 0,
|
|
393
|
+
type: l.type ?? void 0,
|
|
394
|
+
sort: l.sort,
|
|
395
|
+
page: l.page,
|
|
396
|
+
per_page: l.per_page
|
|
394
397
|
}
|
|
395
398
|
}),
|
|
396
|
-
file: (
|
|
397
|
-
async upload(
|
|
398
|
-
const
|
|
399
|
-
return
|
|
399
|
+
file: (l) => a.http.get(`${v}/files/${l}`).then(u),
|
|
400
|
+
async upload(l, m, o) {
|
|
401
|
+
const t = new FormData();
|
|
402
|
+
return t.append("directory_id", String(l)), m.forEach((s) => t.append("files[]", s)), new Promise((s, x) => {
|
|
400
403
|
const p = new XMLHttpRequest();
|
|
401
|
-
p.open("POST", `${
|
|
404
|
+
p.open("POST", `${v}/files`), p.responseType = "json", p.withCredentials = !0, p.setRequestHeader("Accept", "application/json"), p.setRequestHeader("X-Requested-With", "XMLHttpRequest"), p.setRequestHeader("X-Webx-Locale", a.i18n.state.locale);
|
|
402
405
|
const d = nt();
|
|
403
|
-
d && p.setRequestHeader("X-XSRF-TOKEN", d), p.upload.addEventListener("progress", (
|
|
404
|
-
|
|
406
|
+
d && p.setRequestHeader("X-XSRF-TOKEN", d), p.upload.addEventListener("progress", (i) => {
|
|
407
|
+
i.lengthComputable && o?.(Math.round(i.loaded / i.total * 100));
|
|
405
408
|
}), p.addEventListener("load", () => {
|
|
406
|
-
const
|
|
407
|
-
if (p.status >= 200 && p.status < 300 &&
|
|
408
|
-
|
|
409
|
+
const i = p.response;
|
|
410
|
+
if (p.status >= 200 && p.status < 300 && i?.data) {
|
|
411
|
+
s(i.data);
|
|
409
412
|
return;
|
|
410
413
|
}
|
|
411
414
|
x(
|
|
412
|
-
Object.assign(new Error(
|
|
415
|
+
Object.assign(new Error(i?.message ?? "Upload failed"), {
|
|
413
416
|
status: p.status,
|
|
414
|
-
body:
|
|
417
|
+
body: i
|
|
415
418
|
})
|
|
416
419
|
);
|
|
417
|
-
}), p.addEventListener("error", () => x(new Error("Upload failed"))), p.send(
|
|
420
|
+
}), p.addEventListener("error", () => x(new Error("Upload failed"))), p.send(t);
|
|
418
421
|
});
|
|
419
422
|
},
|
|
420
|
-
rename: (
|
|
421
|
-
move: (
|
|
423
|
+
rename: (l, m) => a.http.patch(`${v}/files/${l}`, { name: m }).then(u),
|
|
424
|
+
move: (l, m) => a.http.post(`${v}/files/move`, { ids: l, directory_id: m }).then((o) => o.data.moved),
|
|
422
425
|
// A POST for the batch, not a DELETE: the panel's own client sends no body on DELETE, and
|
|
423
426
|
// a list of ids in a query string is a worse answer than an honest verb.
|
|
424
|
-
remove: (
|
|
425
|
-
removeOne: (
|
|
426
|
-
edit: (
|
|
427
|
-
copy: (
|
|
428
|
-
restoreOriginal: (
|
|
429
|
-
thumb(
|
|
430
|
-
if (!
|
|
427
|
+
remove: (l) => a.http.post(`${v}/files/delete`, { ids: l }).then((m) => m.data.deleted),
|
|
428
|
+
removeOne: (l) => a.http.delete(`${v}/files/${l}`),
|
|
429
|
+
edit: (l, m) => a.http.post(`${v}/files/${l}/edit`, m).then(u),
|
|
430
|
+
copy: (l) => a.http.post(`${v}/files/${l}/copy`).then(u),
|
|
431
|
+
restoreOriginal: (l) => a.http.post(`${v}/files/${l}/restore-original`).then(u),
|
|
432
|
+
thumb(l, m, o, t = "cover") {
|
|
433
|
+
if (!l.thumb)
|
|
431
434
|
return null;
|
|
432
|
-
const
|
|
433
|
-
return
|
|
435
|
+
const s = new URL(l.thumb, window.location.origin);
|
|
436
|
+
return s.searchParams.set("w", String(m)), o && s.searchParams.set("h", String(o)), s.searchParams.set("fit", t), s.pathname + s.search;
|
|
434
437
|
}
|
|
435
438
|
};
|
|
436
439
|
}
|
|
437
440
|
function nt() {
|
|
438
|
-
const
|
|
439
|
-
return
|
|
441
|
+
const a = document.cookie.split("; ").find((v) => v.startsWith("XSRF-TOKEN="));
|
|
442
|
+
return a ? decodeURIComponent(a.slice(11)) : null;
|
|
440
443
|
}
|
|
441
|
-
const
|
|
444
|
+
const it = {
|
|
442
445
|
module: {
|
|
443
446
|
title: "Files"
|
|
444
447
|
},
|
|
@@ -479,13 +482,35 @@ const ot = {
|
|
|
479
482
|
"status-selected": "selected: :count",
|
|
480
483
|
"status-size": "size: :size"
|
|
481
484
|
},
|
|
485
|
+
// The image editor is a component of the design system, so its words are props rather than
|
|
486
|
+
// lines in the dictionary — the manager hands it these when it opens it.
|
|
487
|
+
editor: {
|
|
488
|
+
title: "Edit picture",
|
|
489
|
+
save: "Save",
|
|
490
|
+
cancel: "Cancel",
|
|
491
|
+
reset: "Reset",
|
|
492
|
+
"rotate-left": "Turn left",
|
|
493
|
+
"rotate-right": "Turn right",
|
|
494
|
+
"flip-horizontal": "Mirror across",
|
|
495
|
+
"flip-vertical": "Mirror down",
|
|
496
|
+
ratio: "Ratio",
|
|
497
|
+
crop: "Crop",
|
|
498
|
+
output: "Output",
|
|
499
|
+
"output-hint": "The size of the picture you will get",
|
|
500
|
+
width: "Width",
|
|
501
|
+
height: "Height",
|
|
502
|
+
free: "Free",
|
|
503
|
+
original: "Original",
|
|
504
|
+
error: "This picture could not be loaded"
|
|
505
|
+
},
|
|
482
506
|
dialogs: {
|
|
483
507
|
"delete-files-title": "Delete :count file(s)?",
|
|
484
508
|
"delete-files-text": "Anywhere they are already used, they will stop opening.",
|
|
485
509
|
"delete-folder-title": "Delete the folder :title?",
|
|
486
510
|
"delete-folder-contents": "It holds :files file(s) and :directories folder(s).",
|
|
487
511
|
"delete-folder-warning": "Everything inside goes too, and pictures already placed in content will stop opening.",
|
|
488
|
-
confirm: "Delete"
|
|
512
|
+
confirm: "Delete",
|
|
513
|
+
"delete-file": "Delete :name?"
|
|
489
514
|
},
|
|
490
515
|
errors: {
|
|
491
516
|
"directory-not-empty": "This folder is not empty.",
|
|
@@ -508,239 +533,269 @@ const ot = {
|
|
|
508
533
|
directory_id: "folder",
|
|
509
534
|
files: "files"
|
|
510
535
|
}
|
|
511
|
-
},
|
|
512
|
-
function
|
|
536
|
+
}, ge = /* @__PURE__ */ new WeakSet();
|
|
537
|
+
function be() {
|
|
513
538
|
try {
|
|
514
|
-
const { i18n:
|
|
515
|
-
|
|
539
|
+
const { i18n: a } = he();
|
|
540
|
+
ge.has(a) || (a.defaults("webx-media", it), ge.add(a));
|
|
516
541
|
} catch {
|
|
517
542
|
}
|
|
518
543
|
}
|
|
519
|
-
const
|
|
544
|
+
const rt = {
|
|
520
545
|
key: 0,
|
|
521
546
|
class: "wx-media__folders"
|
|
522
|
-
},
|
|
547
|
+
}, st = { class: "wx-media__files" }, dt = { class: "wx-media__status" }, ut = { key: 0 }, ct = { class: "wx-media__drawer" }, we = /* @__PURE__ */ R({
|
|
523
548
|
__name: "MediaManager",
|
|
524
549
|
props: {
|
|
525
550
|
picking: { type: Boolean, default: !1 },
|
|
526
551
|
accept: { default: null }
|
|
527
552
|
},
|
|
528
553
|
emits: ["pick"],
|
|
529
|
-
setup(
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
554
|
+
setup(a, { emit: v }) {
|
|
555
|
+
const u = a, l = v, m = he(), o = ot(m);
|
|
556
|
+
be();
|
|
557
|
+
const t = S("webx-media");
|
|
558
|
+
function s() {
|
|
559
|
+
return {
|
|
560
|
+
title: t("editor.title"),
|
|
561
|
+
saveLabel: t("editor.save"),
|
|
562
|
+
cancelLabel: t("editor.cancel"),
|
|
563
|
+
resetLabel: t("editor.reset"),
|
|
564
|
+
rotateLeftLabel: t("editor.rotate-left"),
|
|
565
|
+
rotateRightLabel: t("editor.rotate-right"),
|
|
566
|
+
flipHorizontalLabel: t("editor.flip-horizontal"),
|
|
567
|
+
flipVerticalLabel: t("editor.flip-vertical"),
|
|
568
|
+
ratioLabel: t("editor.ratio"),
|
|
569
|
+
cropLabel: t("editor.crop"),
|
|
570
|
+
outputLabel: t("editor.output"),
|
|
571
|
+
outputHint: t("editor.output-hint"),
|
|
572
|
+
widthLabel: t("editor.width"),
|
|
573
|
+
heightLabel: t("editor.height"),
|
|
574
|
+
freeLabel: t("editor.free"),
|
|
575
|
+
originalLabel: t("editor.original"),
|
|
576
|
+
errorText: t("editor.error")
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
const x = ee("root"), p = Ke(x), d = C(() => p.value > 0 && p.value < 640), i = M([]), f = M(null), c = M(null), h = M([]), E = M(""), A = M(u.accept ?? "all"), X = M("-created_at"), Q = M(!1), H = M(!1), ne = ee("picker"), ke = C(() => c.value?.data ?? []), I = C(() => m.can("media.manage")), $e = C(() => m.can("media.upload") || I.value), D = C(() => We(f.value));
|
|
580
|
+
ye(W), K([f, A, X], () => L(1)), K(
|
|
581
|
+
E,
|
|
582
|
+
Ee(() => L(1), 300)
|
|
583
|
+
), K(d, (r) => {
|
|
584
|
+
r || (H.value = !1);
|
|
538
585
|
});
|
|
539
|
-
async function
|
|
540
|
-
|
|
586
|
+
async function W() {
|
|
587
|
+
i.value = await o.directories(), f.value ??= i.value[0]?.id ?? null, await L(1);
|
|
541
588
|
}
|
|
542
|
-
async function
|
|
543
|
-
|
|
589
|
+
async function L(r = c.value?.meta.current_page ?? 1) {
|
|
590
|
+
Q.value = !0;
|
|
544
591
|
try {
|
|
545
|
-
|
|
546
|
-
directory_id:
|
|
547
|
-
q:
|
|
548
|
-
type:
|
|
592
|
+
c.value = await o.files({
|
|
593
|
+
directory_id: E.value ? null : f.value,
|
|
594
|
+
q: E.value,
|
|
595
|
+
type: A.value === "all" ? null : A.value,
|
|
549
596
|
sort: X.value,
|
|
550
|
-
page:
|
|
551
|
-
}),
|
|
597
|
+
page: r
|
|
598
|
+
}), h.value = [];
|
|
552
599
|
} finally {
|
|
553
|
-
|
|
600
|
+
Q.value = !1;
|
|
554
601
|
}
|
|
555
602
|
}
|
|
556
|
-
function
|
|
603
|
+
function Me() {
|
|
557
604
|
ne.value?.click();
|
|
558
605
|
}
|
|
559
|
-
async function _e(
|
|
560
|
-
const
|
|
561
|
-
if (
|
|
606
|
+
async function _e(r) {
|
|
607
|
+
const n = r.target, g = Array.from(n.files ?? []);
|
|
608
|
+
if (n.value = "", !(g.length === 0 || f.value === null))
|
|
562
609
|
try {
|
|
563
|
-
const $ = await
|
|
564
|
-
$.length >
|
|
610
|
+
const $ = await o.upload(f.value, g), O = $.filter((Fe) => Fe.duplicate).length;
|
|
611
|
+
$.length > O && P.success(t("manager.uploaded", { count: $.length - O })), O > 0 && P.info(t("manager.duplicate-added")), await Promise.all([W(), L(1)]);
|
|
565
612
|
} catch ($) {
|
|
566
|
-
|
|
613
|
+
P.danger(ce($) ?? t("errors.upload"));
|
|
567
614
|
}
|
|
568
615
|
}
|
|
569
|
-
const
|
|
570
|
-
async function
|
|
571
|
-
const
|
|
572
|
-
title:
|
|
573
|
-
confirmText:
|
|
616
|
+
const ie = J(lt);
|
|
617
|
+
async function re() {
|
|
618
|
+
const r = await ie({
|
|
619
|
+
title: t("manager.new-folder"),
|
|
620
|
+
confirmText: t("manager.new-folder")
|
|
574
621
|
});
|
|
575
|
-
|
|
622
|
+
r === void 0 || f.value === null || (await o.createDirectory(f.value, r), await W());
|
|
576
623
|
}
|
|
577
|
-
async function
|
|
578
|
-
const
|
|
579
|
-
if (!
|
|
624
|
+
async function se() {
|
|
625
|
+
const r = D.value;
|
|
626
|
+
if (!r || r.is_root)
|
|
580
627
|
return;
|
|
581
|
-
const
|
|
582
|
-
title:
|
|
583
|
-
value:
|
|
584
|
-
confirmText:
|
|
628
|
+
const n = await ie({
|
|
629
|
+
title: t("manager.rename"),
|
|
630
|
+
value: r.title,
|
|
631
|
+
confirmText: t("manager.save")
|
|
585
632
|
});
|
|
586
|
-
|
|
633
|
+
n !== void 0 && (await o.renameDirectory(r.id, n), await W());
|
|
587
634
|
}
|
|
588
|
-
async function
|
|
589
|
-
const
|
|
590
|
-
if (!(!
|
|
635
|
+
async function de() {
|
|
636
|
+
const r = D.value;
|
|
637
|
+
if (!(!r || r.is_root)) {
|
|
591
638
|
try {
|
|
592
|
-
await
|
|
593
|
-
} catch (
|
|
594
|
-
const
|
|
595
|
-
if (!
|
|
596
|
-
throw
|
|
597
|
-
if (!await
|
|
598
|
-
title:
|
|
599
|
-
message: `${
|
|
600
|
-
confirmText:
|
|
601
|
-
cancelText:
|
|
639
|
+
await o.deleteDirectory(r.id);
|
|
640
|
+
} catch (n) {
|
|
641
|
+
const g = Ve(n);
|
|
642
|
+
if (!g)
|
|
643
|
+
throw n;
|
|
644
|
+
if (!await ve({
|
|
645
|
+
title: t("dialogs.delete-folder-title", { title: r.title }),
|
|
646
|
+
message: `${t("dialogs.delete-folder-contents", g)} ${t("dialogs.delete-folder-warning")}`,
|
|
647
|
+
confirmText: t("dialogs.confirm"),
|
|
648
|
+
cancelText: t("manager.cancel"),
|
|
602
649
|
tone: "danger"
|
|
603
650
|
}))
|
|
604
651
|
return;
|
|
605
|
-
await
|
|
652
|
+
await o.deleteDirectory(r.id, !0);
|
|
606
653
|
}
|
|
607
|
-
|
|
654
|
+
f.value = null, await W();
|
|
608
655
|
}
|
|
609
656
|
}
|
|
610
|
-
async function
|
|
657
|
+
async function ue(r, n) {
|
|
611
658
|
try {
|
|
612
|
-
await
|
|
613
|
-
} catch (
|
|
614
|
-
|
|
659
|
+
await o.moveDirectory(r, n);
|
|
660
|
+
} catch (g) {
|
|
661
|
+
P.danger(ce(g) ?? t("errors.directory-into-itself"));
|
|
615
662
|
}
|
|
616
|
-
await
|
|
663
|
+
await W();
|
|
617
664
|
}
|
|
618
|
-
const
|
|
619
|
-
async function
|
|
620
|
-
const
|
|
621
|
-
directories:
|
|
622
|
-
from:
|
|
623
|
-
count:
|
|
665
|
+
const Ce = J(at);
|
|
666
|
+
async function Te() {
|
|
667
|
+
const r = await Ce({
|
|
668
|
+
directories: i.value,
|
|
669
|
+
from: f.value,
|
|
670
|
+
count: h.value.length
|
|
624
671
|
});
|
|
625
|
-
|
|
672
|
+
r !== void 0 && (await o.move([...h.value], r), await Promise.all([W(), L()]));
|
|
626
673
|
}
|
|
627
|
-
async function
|
|
628
|
-
const
|
|
629
|
-
await
|
|
630
|
-
title:
|
|
631
|
-
message:
|
|
632
|
-
confirmText:
|
|
633
|
-
cancelText:
|
|
674
|
+
async function ze() {
|
|
675
|
+
const r = [...h.value];
|
|
676
|
+
await ve({
|
|
677
|
+
title: t("dialogs.delete-files-title", { count: r.length }),
|
|
678
|
+
message: t("dialogs.delete-files-text"),
|
|
679
|
+
confirmText: t("dialogs.confirm"),
|
|
680
|
+
cancelText: t("manager.cancel"),
|
|
634
681
|
tone: "danger"
|
|
635
|
-
}) && (await
|
|
682
|
+
}) && (await o.remove(r), await Promise.all([W(), L()]));
|
|
636
683
|
}
|
|
637
|
-
async function
|
|
638
|
-
await
|
|
684
|
+
async function De(r, n) {
|
|
685
|
+
await o.rename(r.id, n), await L();
|
|
639
686
|
}
|
|
640
|
-
async function
|
|
641
|
-
await
|
|
687
|
+
async function Le(r) {
|
|
688
|
+
await o.removeOne(r.id), await Promise.all([W(), L()]);
|
|
642
689
|
}
|
|
643
|
-
async function Ue(
|
|
644
|
-
const
|
|
645
|
-
|
|
690
|
+
async function Ue(r) {
|
|
691
|
+
const n = await Ye({
|
|
692
|
+
src: r.source ?? r.url,
|
|
693
|
+
fileName: r.file_name,
|
|
694
|
+
filters: !1,
|
|
695
|
+
// The editor is a component of the design system: its words are props with English
|
|
696
|
+
// defaults, not lines in the panel's dictionary. Whoever opens it is the one who knows
|
|
697
|
+
// what language the panel is being read in.
|
|
698
|
+
...s()
|
|
699
|
+
});
|
|
700
|
+
n && (await o.edit(r.id, {
|
|
646
701
|
// The editor's frame is read against the picture as it is on screen — already turned — and
|
|
647
702
|
// the server applies the operations in that order for the same reason.
|
|
648
|
-
crop:
|
|
649
|
-
rotate: (
|
|
650
|
-
flip:
|
|
651
|
-
resize: { width:
|
|
652
|
-
}), await
|
|
703
|
+
crop: n.crop,
|
|
704
|
+
rotate: (n.rotation % 360 + 360) % 360,
|
|
705
|
+
flip: n.flipX ? "horizontal" : n.flipY ? "vertical" : void 0,
|
|
706
|
+
resize: { width: n.width, height: n.height }
|
|
707
|
+
}), await L());
|
|
653
708
|
}
|
|
654
|
-
function We(
|
|
655
|
-
const
|
|
656
|
-
for (const $ of
|
|
657
|
-
if ($.id ===
|
|
709
|
+
function We(r) {
|
|
710
|
+
const n = (g) => {
|
|
711
|
+
for (const $ of g) {
|
|
712
|
+
if ($.id === r)
|
|
658
713
|
return $;
|
|
659
|
-
const
|
|
660
|
-
if (
|
|
661
|
-
return
|
|
714
|
+
const O = n($.children ?? []);
|
|
715
|
+
if (O)
|
|
716
|
+
return O;
|
|
662
717
|
}
|
|
663
718
|
return null;
|
|
664
719
|
};
|
|
665
|
-
return
|
|
720
|
+
return r === null ? null : n(i.value);
|
|
666
721
|
}
|
|
667
|
-
function Ve(
|
|
668
|
-
const
|
|
669
|
-
return
|
|
722
|
+
function Ve(r) {
|
|
723
|
+
const n = r?.body;
|
|
724
|
+
return n?.code === "directory_not_empty" ? n.counts ?? null : null;
|
|
670
725
|
}
|
|
671
|
-
function
|
|
672
|
-
return
|
|
726
|
+
function ce(r) {
|
|
727
|
+
return r?.message ?? null;
|
|
673
728
|
}
|
|
674
|
-
function
|
|
675
|
-
const
|
|
676
|
-
let
|
|
677
|
-
for (;
|
|
678
|
-
|
|
679
|
-
return `${
|
|
729
|
+
function Re(r) {
|
|
730
|
+
const n = ["B", "KB", "MB", "GB", "TB"];
|
|
731
|
+
let g = r, $ = 0;
|
|
732
|
+
for (; g >= 1024 && $ < n.length - 1; )
|
|
733
|
+
g /= 1024, $++;
|
|
734
|
+
return `${g >= 10 || $ === 0 ? Math.round(g) : g.toFixed(1)} ${n[$]}`;
|
|
680
735
|
}
|
|
681
|
-
function
|
|
682
|
-
let
|
|
736
|
+
function Ee(r, n) {
|
|
737
|
+
let g;
|
|
683
738
|
return () => {
|
|
684
|
-
clearTimeout(
|
|
739
|
+
clearTimeout(g), g = setTimeout(r, n);
|
|
685
740
|
};
|
|
686
741
|
}
|
|
687
|
-
return (
|
|
742
|
+
return (r, n) => (b(), U("div", {
|
|
688
743
|
ref_key: "root",
|
|
689
|
-
ref:
|
|
690
|
-
class:
|
|
744
|
+
ref: x,
|
|
745
|
+
class: qe(["wx-media", { "wx-media--compact": d.value }])
|
|
691
746
|
}, [
|
|
692
|
-
|
|
693
|
-
y(
|
|
694
|
-
selected:
|
|
695
|
-
"onUpdate:selected":
|
|
696
|
-
directories:
|
|
697
|
-
onMove:
|
|
747
|
+
d.value ? T("", !0) : (b(), U("aside", rt, [
|
|
748
|
+
y(fe, {
|
|
749
|
+
selected: f.value,
|
|
750
|
+
"onUpdate:selected": n[0] || (n[0] = (g) => f.value = g),
|
|
751
|
+
directories: i.value,
|
|
752
|
+
onMove: ue
|
|
698
753
|
}, null, 8, ["selected", "directories"]),
|
|
699
|
-
I.value ? (
|
|
754
|
+
I.value ? (b(), k(e(te), {
|
|
700
755
|
key: 0,
|
|
701
756
|
size: "sm",
|
|
702
757
|
align: "start"
|
|
703
758
|
}, {
|
|
704
|
-
default:
|
|
705
|
-
y(e(
|
|
759
|
+
default: w(() => [
|
|
760
|
+
y(e(_), {
|
|
706
761
|
type: "add",
|
|
707
|
-
title: e(
|
|
708
|
-
onClick:
|
|
762
|
+
title: e(t)("manager.new-folder"),
|
|
763
|
+
onClick: re
|
|
709
764
|
}, null, 8, ["title"]),
|
|
710
|
-
y(e(
|
|
765
|
+
y(e(_), {
|
|
711
766
|
type: "edit",
|
|
712
|
-
title: e(
|
|
767
|
+
title: e(t)("manager.rename"),
|
|
713
768
|
disabled: !D.value || D.value.is_root,
|
|
714
|
-
onClick:
|
|
769
|
+
onClick: se
|
|
715
770
|
}, null, 8, ["title", "disabled"]),
|
|
716
|
-
y(e(
|
|
771
|
+
y(e(_), {
|
|
717
772
|
type: "remove",
|
|
718
|
-
title: e(
|
|
773
|
+
title: e(t)("manager.delete"),
|
|
719
774
|
disabled: !D.value || D.value.is_root,
|
|
720
|
-
onClick:
|
|
775
|
+
onClick: de
|
|
721
776
|
}, null, 8, ["title", "disabled"])
|
|
722
777
|
]),
|
|
723
778
|
_: 1
|
|
724
779
|
})) : T("", !0)
|
|
725
780
|
])),
|
|
726
|
-
|
|
727
|
-
y(
|
|
728
|
-
search:
|
|
729
|
-
"onUpdate:search":
|
|
730
|
-
type:
|
|
731
|
-
"onUpdate:type":
|
|
781
|
+
V("section", st, [
|
|
782
|
+
y(tt, {
|
|
783
|
+
search: E.value,
|
|
784
|
+
"onUpdate:search": n[1] || (n[1] = (g) => E.value = g),
|
|
785
|
+
type: A.value,
|
|
786
|
+
"onUpdate:type": n[2] || (n[2] = (g) => A.value = g),
|
|
732
787
|
sort: X.value,
|
|
733
|
-
"onUpdate:sort":
|
|
734
|
-
"can-upload":
|
|
788
|
+
"onUpdate:sort": n[3] || (n[3] = (g) => X.value = g),
|
|
789
|
+
"can-upload": $e.value && !a.picking,
|
|
735
790
|
"can-manage": I.value,
|
|
736
|
-
selected:
|
|
737
|
-
compact:
|
|
738
|
-
onUpload:
|
|
739
|
-
onMove:
|
|
740
|
-
onRemove:
|
|
741
|
-
onFolders:
|
|
791
|
+
selected: h.value.length,
|
|
792
|
+
compact: d.value,
|
|
793
|
+
onUpload: Me,
|
|
794
|
+
onMove: Te,
|
|
795
|
+
onRemove: ze,
|
|
796
|
+
onFolders: n[4] || (n[4] = (g) => H.value = !0)
|
|
742
797
|
}, null, 8, ["search", "type", "sort", "can-upload", "can-manage", "selected", "compact"]),
|
|
743
|
-
|
|
798
|
+
V("input", {
|
|
744
799
|
ref_key: "picker",
|
|
745
800
|
ref: ne,
|
|
746
801
|
type: "file",
|
|
@@ -748,74 +803,74 @@ const it = {
|
|
|
748
803
|
hidden: "",
|
|
749
804
|
onChange: _e
|
|
750
805
|
}, null, 544),
|
|
751
|
-
y(
|
|
752
|
-
selected:
|
|
753
|
-
"onUpdate:selected":
|
|
754
|
-
files:
|
|
755
|
-
api: e(
|
|
756
|
-
query:
|
|
757
|
-
single:
|
|
758
|
-
onRename:
|
|
806
|
+
y(Ze, {
|
|
807
|
+
selected: h.value,
|
|
808
|
+
"onUpdate:selected": n[5] || (n[5] = (g) => h.value = g),
|
|
809
|
+
files: ke.value,
|
|
810
|
+
api: e(o),
|
|
811
|
+
query: E.value,
|
|
812
|
+
single: a.picking,
|
|
813
|
+
onRename: De,
|
|
759
814
|
onEdit: Ue,
|
|
760
|
-
onRemove:
|
|
761
|
-
onOpen:
|
|
815
|
+
onRemove: Le,
|
|
816
|
+
onOpen: n[6] || (n[6] = (g) => l("pick", g))
|
|
762
817
|
}, null, 8, ["selected", "files", "api", "query", "single"]),
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
818
|
+
V("footer", dt, [
|
|
819
|
+
V("span", null, z(e(t)("manager.status-files", { count: c.value?.stats.files ?? 0 })), 1),
|
|
820
|
+
h.value.length > 0 ? (b(), U("span", ut, z(e(t)("manager.status-selected", { count: h.value.length })), 1)) : T("", !0),
|
|
821
|
+
V("span", null, z(e(t)("manager.status-size", { size: Re(c.value?.stats.size ?? 0) })), 1)
|
|
767
822
|
]),
|
|
768
|
-
|
|
823
|
+
c.value && c.value.meta.last_page > 1 ? (b(), k(e(je), {
|
|
769
824
|
key: 0,
|
|
770
|
-
page:
|
|
771
|
-
"per-page":
|
|
772
|
-
total:
|
|
773
|
-
"last-page":
|
|
774
|
-
disabled:
|
|
825
|
+
page: c.value.meta.current_page,
|
|
826
|
+
"per-page": c.value.meta.per_page,
|
|
827
|
+
total: c.value.meta.total,
|
|
828
|
+
"last-page": c.value.meta.last_page,
|
|
829
|
+
disabled: Q.value,
|
|
775
830
|
size: "sm",
|
|
776
|
-
onChange:
|
|
831
|
+
onChange: n[7] || (n[7] = ({ page: g }) => L(g))
|
|
777
832
|
}, null, 8, ["page", "per-page", "total", "last-page", "disabled"])) : T("", !0)
|
|
778
833
|
]),
|
|
779
|
-
y(e(
|
|
780
|
-
open:
|
|
781
|
-
"onUpdate:open":
|
|
834
|
+
y(e(Ge), {
|
|
835
|
+
open: H.value,
|
|
836
|
+
"onUpdate:open": n[10] || (n[10] = (g) => H.value = g),
|
|
782
837
|
side: "left",
|
|
783
|
-
title: e(
|
|
838
|
+
title: e(t)("manager.folders"),
|
|
784
839
|
size: 280
|
|
785
840
|
}, {
|
|
786
|
-
default:
|
|
787
|
-
|
|
788
|
-
y(
|
|
789
|
-
selected:
|
|
841
|
+
default: w(() => [
|
|
842
|
+
V("div", ct, [
|
|
843
|
+
y(fe, {
|
|
844
|
+
selected: f.value,
|
|
790
845
|
"onUpdate:selected": [
|
|
791
|
-
|
|
792
|
-
|
|
846
|
+
n[8] || (n[8] = (g) => f.value = g),
|
|
847
|
+
n[9] || (n[9] = (g) => H.value = !1)
|
|
793
848
|
],
|
|
794
|
-
directories:
|
|
795
|
-
onMove:
|
|
849
|
+
directories: i.value,
|
|
850
|
+
onMove: ue
|
|
796
851
|
}, null, 8, ["selected", "directories"]),
|
|
797
|
-
I.value ? (
|
|
852
|
+
I.value ? (b(), k(e(te), {
|
|
798
853
|
key: 0,
|
|
799
854
|
size: "sm",
|
|
800
855
|
align: "start"
|
|
801
856
|
}, {
|
|
802
|
-
default:
|
|
803
|
-
y(e(
|
|
857
|
+
default: w(() => [
|
|
858
|
+
y(e(_), {
|
|
804
859
|
type: "add",
|
|
805
|
-
title: e(
|
|
806
|
-
onClick:
|
|
860
|
+
title: e(t)("manager.new-folder"),
|
|
861
|
+
onClick: re
|
|
807
862
|
}, null, 8, ["title"]),
|
|
808
|
-
y(e(
|
|
863
|
+
y(e(_), {
|
|
809
864
|
type: "edit",
|
|
810
|
-
title: e(
|
|
865
|
+
title: e(t)("manager.rename"),
|
|
811
866
|
disabled: !D.value || D.value.is_root,
|
|
812
|
-
onClick:
|
|
867
|
+
onClick: se
|
|
813
868
|
}, null, 8, ["title", "disabled"]),
|
|
814
|
-
y(e(
|
|
869
|
+
y(e(_), {
|
|
815
870
|
type: "remove",
|
|
816
|
-
title: e(
|
|
871
|
+
title: e(t)("manager.delete"),
|
|
817
872
|
disabled: !D.value || D.value.is_root,
|
|
818
|
-
onClick:
|
|
873
|
+
onClick: de
|
|
819
874
|
}, null, 8, ["title", "disabled"])
|
|
820
875
|
]),
|
|
821
876
|
_: 1
|
|
@@ -826,55 +881,55 @@ const it = {
|
|
|
826
881
|
}, 8, ["open", "title"])
|
|
827
882
|
], 2));
|
|
828
883
|
}
|
|
829
|
-
}),
|
|
884
|
+
}), mt = /* @__PURE__ */ R({
|
|
830
885
|
__name: "MediaPage",
|
|
831
|
-
setup(
|
|
832
|
-
return (
|
|
886
|
+
setup(a) {
|
|
887
|
+
return (v, u) => (b(), k(e(Je), {
|
|
833
888
|
class: "wx-media-page",
|
|
834
889
|
padding: "md"
|
|
835
890
|
}, {
|
|
836
|
-
default:
|
|
837
|
-
y(
|
|
891
|
+
default: w(() => [
|
|
892
|
+
y(we)
|
|
838
893
|
]),
|
|
839
894
|
_: 1
|
|
840
895
|
}));
|
|
841
896
|
}
|
|
842
|
-
}),
|
|
897
|
+
}), pt = { class: "wx-media-picker" }, xe = /* @__PURE__ */ R({
|
|
843
898
|
__name: "MediaPicker",
|
|
844
899
|
props: {
|
|
845
900
|
accept: { default: "image" },
|
|
846
901
|
title: { default: void 0 },
|
|
847
902
|
manage: { type: Boolean, default: !1 }
|
|
848
903
|
},
|
|
849
|
-
setup(
|
|
850
|
-
const { open:
|
|
851
|
-
return (
|
|
852
|
-
open: e(
|
|
853
|
-
"onUpdate:open":
|
|
854
|
-
title:
|
|
904
|
+
setup(a) {
|
|
905
|
+
const { open: v, resolve: u } = le(), l = S("webx-media");
|
|
906
|
+
return (m, o) => (b(), k(e(oe), {
|
|
907
|
+
open: e(v),
|
|
908
|
+
"onUpdate:open": o[1] || (o[1] = (t) => ae(v) ? v.value = t : null),
|
|
909
|
+
title: a.title ?? e(l)("module.title"),
|
|
855
910
|
width: 960
|
|
856
911
|
}, {
|
|
857
|
-
default:
|
|
858
|
-
|
|
859
|
-
y(
|
|
860
|
-
picking: !
|
|
861
|
-
accept:
|
|
862
|
-
onPick:
|
|
912
|
+
default: w(() => [
|
|
913
|
+
V("div", pt, [
|
|
914
|
+
y(we, {
|
|
915
|
+
picking: !a.manage,
|
|
916
|
+
accept: a.manage ? null : a.accept,
|
|
917
|
+
onPick: o[0] || (o[0] = (t) => e(u)(t))
|
|
863
918
|
}, null, 8, ["picking", "accept"])
|
|
864
919
|
])
|
|
865
920
|
]),
|
|
866
921
|
_: 1
|
|
867
922
|
}, 8, ["open", "title"]));
|
|
868
923
|
}
|
|
869
|
-
}),
|
|
870
|
-
|
|
924
|
+
}), vt = J(xe), xt = J(
|
|
925
|
+
xe,
|
|
871
926
|
{ props: { manage: !0 } }
|
|
872
|
-
),
|
|
927
|
+
), ft = { class: "wx-media-field" }, gt = {
|
|
873
928
|
key: 0,
|
|
874
929
|
class: "wx-media-field__label"
|
|
875
|
-
},
|
|
930
|
+
}, yt = { class: "wx-media-field__body" }, kt = /* @__PURE__ */ R({
|
|
876
931
|
__name: "MediaField",
|
|
877
|
-
props: /* @__PURE__ */
|
|
932
|
+
props: /* @__PURE__ */ B({
|
|
878
933
|
label: { default: void 0 },
|
|
879
934
|
accept: { default: "image" },
|
|
880
935
|
captions: { type: Boolean, default: !0 }
|
|
@@ -883,71 +938,71 @@ const it = {
|
|
|
883
938
|
modelModifiers: {}
|
|
884
939
|
}),
|
|
885
940
|
emits: ["update:modelValue"],
|
|
886
|
-
setup(
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
const
|
|
890
|
-
async function
|
|
891
|
-
const
|
|
892
|
-
|
|
941
|
+
setup(a) {
|
|
942
|
+
const v = a, u = q(a, "modelValue");
|
|
943
|
+
be();
|
|
944
|
+
const l = S("webx-media"), m = C(() => u.value?.url ?? null);
|
|
945
|
+
async function o() {
|
|
946
|
+
const s = await vt({ accept: v.accept });
|
|
947
|
+
s && (u.value = { ...u.value, path: s.path, url: s.url });
|
|
893
948
|
}
|
|
894
|
-
function
|
|
895
|
-
|
|
949
|
+
function t() {
|
|
950
|
+
u.value = null;
|
|
896
951
|
}
|
|
897
|
-
return (
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
952
|
+
return (s, x) => (b(), U("div", ft, [
|
|
953
|
+
a.label ? (b(), U("span", gt, z(a.label), 1)) : T("", !0),
|
|
954
|
+
V("div", yt, [
|
|
955
|
+
m.value ? (b(), k(e(Qe), {
|
|
901
956
|
key: 0,
|
|
902
957
|
class: "wx-media-field__preview",
|
|
903
|
-
src:
|
|
958
|
+
src: m.value,
|
|
904
959
|
fit: "cover"
|
|
905
960
|
}, null, 8, ["src"])) : T("", !0),
|
|
906
|
-
y(e(
|
|
961
|
+
y(e(Y), {
|
|
907
962
|
direction: "vertical",
|
|
908
963
|
size: "sm",
|
|
909
964
|
class: "wx-media-field__controls"
|
|
910
965
|
}, {
|
|
911
|
-
default:
|
|
912
|
-
y(e(
|
|
913
|
-
default:
|
|
966
|
+
default: w(() => [
|
|
967
|
+
y(e(Y), { size: "xs" }, {
|
|
968
|
+
default: w(() => [
|
|
914
969
|
y(e(N), {
|
|
915
970
|
size: "sm",
|
|
916
971
|
icon: "image",
|
|
917
|
-
onClick:
|
|
972
|
+
onClick: o
|
|
918
973
|
}, {
|
|
919
|
-
default:
|
|
920
|
-
F(z(e(
|
|
974
|
+
default: w(() => [
|
|
975
|
+
F(z(e(l)("manager.select")), 1)
|
|
921
976
|
]),
|
|
922
977
|
_: 1
|
|
923
978
|
}),
|
|
924
|
-
|
|
979
|
+
u.value ? (b(), k(e(N), {
|
|
925
980
|
key: 0,
|
|
926
981
|
size: "sm",
|
|
927
982
|
variant: "text",
|
|
928
983
|
type: "danger",
|
|
929
|
-
onClick:
|
|
984
|
+
onClick: t
|
|
930
985
|
}, {
|
|
931
|
-
default:
|
|
932
|
-
F(z(e(
|
|
986
|
+
default: w(() => [
|
|
987
|
+
F(z(e(l)("manager.delete")), 1)
|
|
933
988
|
]),
|
|
934
989
|
_: 1
|
|
935
990
|
})) : T("", !0)
|
|
936
991
|
]),
|
|
937
992
|
_: 1
|
|
938
993
|
}),
|
|
939
|
-
|
|
940
|
-
y(e(
|
|
941
|
-
"model-value":
|
|
994
|
+
a.captions && u.value ? (b(), U(j, { key: 0 }, [
|
|
995
|
+
y(e(G), {
|
|
996
|
+
"model-value": u.value.alt ?? "",
|
|
942
997
|
size: "sm",
|
|
943
998
|
placeholder: "alt",
|
|
944
|
-
"onUpdate:modelValue":
|
|
999
|
+
"onUpdate:modelValue": x[0] || (x[0] = (p) => u.value = { ...u.value, alt: String(p) })
|
|
945
1000
|
}, null, 8, ["model-value"]),
|
|
946
|
-
y(e(
|
|
947
|
-
"model-value":
|
|
1001
|
+
y(e(G), {
|
|
1002
|
+
"model-value": u.value.title ?? "",
|
|
948
1003
|
size: "sm",
|
|
949
1004
|
placeholder: "title",
|
|
950
|
-
"onUpdate:modelValue":
|
|
1005
|
+
"onUpdate:modelValue": x[1] || (x[1] = (p) => u.value = { ...u.value, title: String(p) })
|
|
951
1006
|
}, null, 8, ["model-value"])
|
|
952
1007
|
], 64)) : T("", !0)
|
|
953
1008
|
]),
|
|
@@ -957,29 +1012,29 @@ const it = {
|
|
|
957
1012
|
]));
|
|
958
1013
|
}
|
|
959
1014
|
});
|
|
960
|
-
function
|
|
961
|
-
const
|
|
1015
|
+
function $t(a = {}) {
|
|
1016
|
+
const v = a.path ?? "/media";
|
|
962
1017
|
return {
|
|
963
1018
|
id: "media",
|
|
964
|
-
path:
|
|
1019
|
+
path: v,
|
|
965
1020
|
routes: [
|
|
966
1021
|
{
|
|
967
|
-
path:
|
|
1022
|
+
path: v,
|
|
968
1023
|
name: "webx.media",
|
|
969
|
-
component:
|
|
1024
|
+
component: mt
|
|
970
1025
|
}
|
|
971
1026
|
]
|
|
972
1027
|
};
|
|
973
1028
|
}
|
|
974
1029
|
export {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1030
|
+
kt as WxMediaField,
|
|
1031
|
+
we as WxMediaManager,
|
|
1032
|
+
mt as WxMediaPage,
|
|
1033
|
+
xe as WxMediaPicker,
|
|
1034
|
+
ot as createMediaApi,
|
|
1035
|
+
$t as media,
|
|
1036
|
+
it as mediaMessages,
|
|
1037
|
+
xt as openMediaLibrary,
|
|
1038
|
+
vt as openMediaPicker
|
|
984
1039
|
};
|
|
985
1040
|
//# sourceMappingURL=index.js.map
|