@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 CHANGED
@@ -1,45 +1,45 @@
1
- import { defineComponent as R, useModel as L, ref as _, watch as H, openBlock as h, createBlock as k, unref as e, mergeModels as P, computed as C, resolveDirective as Se, withCtx as b, createElementBlock as W, Fragment as K, renderList as Q, withDirectives as Be, createCommentVNode as T, createVNode as y, createTextVNode as F, toDisplayString as z, isRef as te, useTemplateRef as Z, onMounted as ge, nextTick as Pe, createElementVNode as E, withKeys as qe, normalizeClass as Oe } from "vue";
2
- import { WxTree as Le, WxSelectionArea as Ne, WxFileCard as Ae, WxEmpty as Xe, toast as O, WxAction as M, WxInput as j, WxDropdown as ce, WxDropdownItem as me, WxActions as ee, useModal as ae, WxDialog as le, WxSelect as Ie, WxSpace as G, WxButton as N, useElementWidth as He, createModal as Y, WxPagination as Ke, WxDrawer as je, confirm as pe, openImageEditor as Ge, WxCard as Ye, WxImage as Je } from "@webx-ui/core";
3
- import { useTranslate as S, useAdmin as ye } from "@webx-ui/admin";
4
- const ve = /* @__PURE__ */ R({
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__ */ P({
6
+ props: /* @__PURE__ */ B({
7
7
  directories: {}
8
8
  }, {
9
9
  selected: { default: null },
10
10
  selectedModifiers: {}
11
11
  }),
12
- emits: /* @__PURE__ */ P(["move"], ["update:selected"]),
13
- setup(t, { emit: r }) {
14
- const g = t, n = L(t, "selected"), c = r, i = S("webx-media"), a = _([]), u = _([]);
15
- H(
16
- () => g.directories,
17
- (l) => {
18
- a.value = l.map(x), u.value = p(l);
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(l) {
22
+ function x(i) {
23
23
  return {
24
- ...l,
25
- label: l.is_root ? i("manager.root") : l.title,
26
- children: (l.children ?? []).map(x)
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(l) {
30
- return l.flatMap((f) => [f.id, ...p(f.children ?? [])]);
29
+ function p(i) {
30
+ return i.flatMap((f) => [f.id, ...p(f.children ?? [])]);
31
31
  }
32
- function d(l) {
33
- const f = l.zone === "inside" ? l.target : l.parent;
34
- f && c("move", l.node.id, f.id);
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 (l, f) => (h(), k(e(Le), {
37
- selected: n.value,
38
- "onUpdate:selected": f[0] || (f[0] = (m) => n.value = m),
39
- expanded: u.value,
40
- "onUpdate:expanded": f[1] || (f[1] = (m) => u.value = m),
41
- modelValue: a.value,
42
- "onUpdate:modelValue": f[2] || (f[2] = (m) => a.value = m),
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
- }), Qe = /* @__PURE__ */ R({
50
+ }), Ze = /* @__PURE__ */ R({
51
51
  __name: "FileGrid",
52
- props: /* @__PURE__ */ P({
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__ */ P(["open", "rename", "edit", "remove"], ["update:selected"]),
62
- setup(t, { emit: r }) {
63
- const g = t, n = L(t, "selected"), c = r, i = S("webx-media"), a = C(
64
- () => g.query ? i("manager.empty-search", { query: g.query }) : i("manager.empty")
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 u() {
67
- O.success(i("manager.link-copied"));
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 l = !1;
72
+ let i = !1;
73
73
  try {
74
- l = document.execCommand("copy");
74
+ i = document.execCommand("copy");
75
75
  } catch {
76
- l = !1;
76
+ i = !1;
77
77
  }
78
- if (d.remove(), l) {
79
- u();
78
+ if (d.remove(), i) {
79
+ s();
80
80
  return;
81
81
  }
82
- O.danger(`${i("errors.copy")} ${p.url}`, { duration: 0 });
82
+ P.danger(`${o("errors.copy")} ${p.url}`, { duration: 0 });
83
83
  }
84
84
  return (p, d) => {
85
- const l = Se("wx-select");
86
- return t.files.length > 0 ? (h(), k(e(Ne), {
85
+ const i = Se("wx-select");
86
+ return a.files.length > 0 ? (b(), k(e(Ae), {
87
87
  key: 0,
88
- modelValue: n.value,
89
- "onUpdate:modelValue": d[0] || (d[0] = (f) => n.value = f),
88
+ modelValue: l.value,
89
+ "onUpdate:modelValue": d[0] || (d[0] = (f) => l.value = f),
90
90
  class: "wx-media-grid",
91
- multiple: !t.single
91
+ multiple: !a.single
92
92
  }, {
93
- default: b(({ isSelected: f }) => [
94
- (h(!0), W(K, null, Q(t.files, (m) => Be((h(), k(e(Ae), {
95
- key: m.id,
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: m.name,
98
- url: m.url,
99
- thumbnail: t.api.thumb(m, 320, 320) ?? void 0,
100
- type: m.mime,
101
- selected: f(m.id),
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: m.editable,
103
+ editable: c.editable,
104
104
  removable: "",
105
105
  copyable: "",
106
- "rename-label": e(i)("manager.rename"),
107
- "edit-label": e(i)("manager.edit"),
108
- "remove-label": e(i)("manager.delete"),
109
- "copy-label": e(i)("manager.copy-link"),
110
- "copied-label": e(i)("manager.link-copied"),
111
- onRename: (w) => c("rename", m, w),
112
- onEdit: (w) => c("edit", m),
113
- onRemove: (w) => c("remove", m),
114
- onCopy: u,
115
- onCopyError: (w) => x(m),
116
- onDblclick: (w) => c("open", m)
117
- }, null, 8, ["name", "url", "thumbnail", "type", "selected", "editable", "rename-label", "edit-label", "remove-label", "copy-label", "copied-label", "onRename", "onEdit", "onRemove", "onCopyError", "onDblclick"])), [
118
- [l, m.id]
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"])) : (h(), k(e(Xe), {
125
+ }, 8, ["modelValue", "multiple"])) : (b(), k(e(Xe), {
123
126
  key: 1,
124
- description: a.value
127
+ description: t.value
125
128
  }, null, 8, ["description"]));
126
129
  };
127
130
  }
128
- }), Ze = { class: "wx-media-toolbar" }, et = /* @__PURE__ */ R({
131
+ }), et = { class: "wx-media-toolbar" }, tt = /* @__PURE__ */ R({
129
132
  __name: "MediaToolbar",
130
- props: /* @__PURE__ */ P({
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__ */ P(["upload", "move", "remove", "folders"], ["update:search", "update:type", "update:sort"]),
144
- setup(t, { emit: r }) {
145
- const g = t, n = L(t, "search"), c = L(t, "type"), i = L(t, "sort"), a = r, u = S("webx-media"), x = C(() => [
146
- { value: "all", label: u("manager.all-types") },
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: u(`manager.${f}`)
152
+ label: s(`manager.${f}`)
150
153
  }))
151
154
  ]), p = C(() => [
152
- { value: "-created_at", label: u("manager.sort-newest") },
153
- { value: "created_at", label: u("manager.sort-oldest") },
154
- { value: "name", label: u("manager.sort-name") },
155
- { value: "-size", label: u("manager.sort-size") }
156
- ]), d = C(() => x.value.find((f) => f.value === c.value)?.label ?? ""), l = C(() => p.value.find((f) => f.value === i.value)?.label ?? "");
157
- return (f, m) => (h(), W("header", Ze, [
158
- t.compact ? (h(), k(e(M), {
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(u)("manager.folders"),
164
+ title: e(s)("manager.folders"),
162
165
  size: "sm",
163
- onClick: m[0] || (m[0] = (w) => a("folders"))
166
+ onClick: c[0] || (c[0] = (h) => t("folders"))
164
167
  }, null, 8, ["title"])) : T("", !0),
165
- y(e(j), {
166
- modelValue: n.value,
167
- "onUpdate:modelValue": m[1] || (m[1] = (w) => n.value = w),
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(u)("manager.search"),
172
+ placeholder: e(s)("manager.search"),
170
173
  clearable: "",
171
174
  size: "sm"
172
175
  }, null, 8, ["modelValue", "placeholder"]),
173
- y(e(ce), null, {
174
- trigger: b(() => [
175
- y(e(M), {
176
+ y(e(me), null, {
177
+ trigger: w(() => [
178
+ y(e(_), {
176
179
  icon: "filter",
177
- title: `${e(u)("manager.all-types")}: ${d.value}`,
180
+ title: `${e(s)("manager.all-types")}: ${d.value}`,
178
181
  size: "sm"
179
182
  }, null, 8, ["title"])
180
183
  ]),
181
- default: b(() => [
182
- (h(!0), W(K, null, Q(x.value, (w) => (h(), k(e(me), {
183
- key: String(w.value),
184
- active: w.value === c.value,
185
- onClick: (B) => c.value = w.value
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: b(() => [
188
- F(z(w.label), 1)
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(ce), null, {
196
- trigger: b(() => [
197
- y(e(M), {
198
+ y(e(me), null, {
199
+ trigger: w(() => [
200
+ y(e(_), {
198
201
  icon: "arrow-down",
199
- title: l.value,
202
+ title: i.value,
200
203
  size: "sm"
201
204
  }, null, 8, ["title"])
202
205
  ]),
203
- default: b(() => [
204
- (h(!0), W(K, null, Q(p.value, (w) => (h(), k(e(me), {
205
- key: w.value,
206
- active: w.value === i.value,
207
- onClick: (B) => i.value = w.value
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: b(() => [
210
- F(z(w.label), 1)
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
- t.canUpload ? (h(), k(e(M), {
220
+ a.canUpload ? (b(), k(e(_), {
218
221
  key: 1,
219
222
  type: "upload",
220
- title: e(u)("manager.upload"),
223
+ title: e(s)("manager.upload"),
221
224
  size: "sm",
222
- onClick: m[2] || (m[2] = (w) => a("upload"))
225
+ onClick: c[2] || (c[2] = (h) => t("upload"))
223
226
  }, null, 8, ["title"])) : T("", !0),
224
- t.canManage ? (h(), k(e(ee), {
227
+ a.canManage ? (b(), k(e(te), {
225
228
  key: 2,
226
229
  size: "sm"
227
230
  }, {
228
- default: b(() => [
229
- y(e(M), {
231
+ default: w(() => [
232
+ y(e(_), {
230
233
  icon: "folder",
231
- title: e(u)("manager.move"),
232
- disabled: g.selected === 0,
233
- onClick: m[3] || (m[3] = (w) => a("move"))
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(M), {
238
+ y(e(_), {
236
239
  type: "remove",
237
- title: e(u)("manager.delete"),
238
- disabled: g.selected === 0,
239
- onClick: m[4] || (m[4] = (w) => a("remove"))
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
- }), tt = /* @__PURE__ */ R({
249
+ }), at = /* @__PURE__ */ R({
247
250
  __name: "MoveDialog",
248
251
  props: {
249
252
  directories: {},
250
253
  from: {},
251
254
  count: {}
252
255
  },
253
- setup(t) {
254
- const r = t, { open: g, resolve: n, dismiss: c } = ae(), i = S("webx-media"), a = C(
255
- () => x(r.directories).filter((p) => p.value !== r.from)
256
- ), u = _(a.value[0]?.value ?? null);
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 ? i("manager.root") : d.title)
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) => (h(), k(e(le), {
268
- open: e(g),
269
- "onUpdate:open": d[3] || (d[3] = (l) => te(g) ? g.value = l : null),
270
- title: e(i)("manager.move-to"),
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: b(() => [
274
- y(e(G), { size: "sm" }, {
275
- default: b(() => [
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] = (l) => e(c)())
281
+ onClick: d[1] || (d[1] = (i) => e(m)())
279
282
  }, {
280
- default: b(() => [
281
- F(z(e(i)("manager.cancel")), 1)
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: u.value === null,
288
- onClick: d[2] || (d[2] = (l) => e(n)(u.value))
290
+ disabled: s.value === null,
291
+ onClick: d[2] || (d[2] = (i) => e(l)(s.value))
289
292
  }, {
290
- default: b(() => [
291
- F(z(e(i)("manager.move")), 1)
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: b(() => [
302
+ default: w(() => [
300
303
  y(e(Ie), {
301
- modelValue: u.value,
302
- "onUpdate:modelValue": d[0] || (d[0] = (l) => u.value = l),
303
- options: a.value
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
- }), at = /* @__PURE__ */ R({
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(t) {
318
- const r = t, { open: g, resolve: n, dismiss: c } = ae(), i = S("webx-media"), a = _(r.value), u = Z("input");
319
- ge(async () => {
320
- await Pe(), u.value?.querySelector("input")?.focus();
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 = a.value.trim();
324
- p !== "" && n(p);
326
+ const p = t.value.trim();
327
+ p !== "" && l(p);
325
328
  }
326
- return (p, d) => (h(), k(e(le), {
327
- open: e(g),
328
- "onUpdate:open": d[2] || (d[2] = (l) => te(g) ? g.value = l : null),
329
- title: t.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: b(() => [
333
- y(e(G), { size: "sm" }, {
334
- default: b(() => [
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] = (l) => e(c)())
340
+ onClick: d[1] || (d[1] = (i) => e(m)())
338
341
  }, {
339
- default: b(() => [
340
- F(z(e(i)("manager.cancel")), 1)
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: a.value.trim() === "",
349
+ disabled: t.value.trim() === "",
347
350
  onClick: x
348
351
  }, {
349
- default: b(() => [
350
- F(z(t.confirmText ?? e(i)("manager.save")), 1)
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: b(() => [
359
- E("div", {
361
+ default: w(() => [
362
+ V("div", {
360
363
  ref_key: "input",
361
- ref: u
364
+ ref: s
362
365
  }, [
363
- y(e(j), {
364
- modelValue: a.value,
365
- "onUpdate:modelValue": d[0] || (d[0] = (l) => a.value = l),
366
- placeholder: t.label ?? e(i)("manager.folder-name"),
367
- "aria-label": t.label ?? e(i)("manager.folder-name"),
368
- onKeyup: qe(x, ["enter"])
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 lt(t) {
377
- const r = `${t.apiPath}/media`, g = (n) => n.data;
379
+ function ot(a) {
380
+ const v = `${a.apiPath}/media`, u = (l) => l.data;
378
381
  return {
379
- directories: () => t.http.get(`${r}/directories`).then(g),
380
- createDirectory: (n, c) => t.http.post(`${r}/directories`, { parent_id: n, title: c }).then(g),
381
- renameDirectory: (n, c) => t.http.patch(`${r}/directories/${n}`, { title: c }).then(g),
382
- moveDirectory: (n, c) => t.http.patch(`${r}/directories/${n}/move`, { parent_id: c }).then(g),
383
- deleteDirectory: (n, c = !1) => t.http.delete(`${r}/directories/${n}`, {
384
- query: { force: c ? 1 : void 0 }
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: (n = {}) => t.http.get(`${r}/files`, {
389
+ files: (l = {}) => a.http.get(`${v}/files`, {
387
390
  query: {
388
- directory_id: n.directory_id ?? void 0,
389
- q: n.q || void 0,
390
- type: n.type ?? void 0,
391
- sort: n.sort,
392
- page: n.page,
393
- per_page: n.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: (n) => t.http.get(`${r}/files/${n}`).then(g),
397
- async upload(n, c, i) {
398
- const a = new FormData();
399
- return a.append("directory_id", String(n)), c.forEach((u) => a.append("files[]", u)), new Promise((u, x) => {
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", `${r}/files`), p.responseType = "json", p.withCredentials = !0, p.setRequestHeader("Accept", "application/json"), p.setRequestHeader("X-Requested-With", "XMLHttpRequest"), p.setRequestHeader("X-Webx-Locale", t.i18n.state.locale);
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", (l) => {
404
- l.lengthComputable && i?.(Math.round(l.loaded / l.total * 100));
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 l = p.response;
407
- if (p.status >= 200 && p.status < 300 && l?.data) {
408
- u(l.data);
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(l?.message ?? "Upload failed"), {
415
+ Object.assign(new Error(i?.message ?? "Upload failed"), {
413
416
  status: p.status,
414
- body: l
417
+ body: i
415
418
  })
416
419
  );
417
- }), p.addEventListener("error", () => x(new Error("Upload failed"))), p.send(a);
420
+ }), p.addEventListener("error", () => x(new Error("Upload failed"))), p.send(t);
418
421
  });
419
422
  },
420
- rename: (n, c) => t.http.patch(`${r}/files/${n}`, { name: c }).then(g),
421
- move: (n, c) => t.http.post(`${r}/files/move`, { ids: n, directory_id: c }).then((i) => i.data.moved),
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: (n) => t.http.post(`${r}/files/delete`, { ids: n }).then((c) => c.data.deleted),
425
- removeOne: (n) => t.http.delete(`${r}/files/${n}`),
426
- edit: (n, c) => t.http.post(`${r}/files/${n}/edit`, c).then(g),
427
- copy: (n) => t.http.post(`${r}/files/${n}/copy`).then(g),
428
- restoreOriginal: (n) => t.http.post(`${r}/files/${n}/restore-original`).then(g),
429
- thumb(n, c, i, a = "cover") {
430
- if (!n.thumb)
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 u = new URL(n.thumb, window.location.origin);
433
- return u.searchParams.set("w", String(c)), i && u.searchParams.set("h", String(i)), u.searchParams.set("fit", a), u.pathname + u.search;
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 t = document.cookie.split("; ").find((r) => r.startsWith("XSRF-TOKEN="));
439
- return t ? decodeURIComponent(t.slice(11)) : null;
441
+ const a = document.cookie.split("; ").find((v) => v.startsWith("XSRF-TOKEN="));
442
+ return a ? decodeURIComponent(a.slice(11)) : null;
440
443
  }
441
- const ot = {
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
- }, fe = /* @__PURE__ */ new WeakSet();
512
- function we() {
536
+ }, ge = /* @__PURE__ */ new WeakSet();
537
+ function be() {
513
538
  try {
514
- const { i18n: t } = ye();
515
- fe.has(t) || (t.defaults("webx-media", ot), fe.add(t));
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 it = {
544
+ const rt = {
520
545
  key: 0,
521
546
  class: "wx-media__folders"
522
- }, rt = { class: "wx-media__files" }, st = { class: "wx-media__status" }, dt = { key: 0 }, ut = { class: "wx-media__drawer" }, he = /* @__PURE__ */ R({
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(t, { emit: r }) {
530
- const g = t, n = r, c = ye(), i = lt(c);
531
- we();
532
- const a = S("webx-media"), u = Z("root"), x = He(u), p = C(() => x.value > 0 && x.value < 640), d = _([]), l = _(null), f = _(null), m = _([]), w = _(""), B = _(g.accept ?? "all"), X = _("-created_at"), J = _(!1), A = _(!1), ne = Z("picker"), xe = C(() => f.value?.data ?? []), I = C(() => c.can("media.manage")), ke = C(() => c.can("media.upload") || I.value), D = C(() => We(l.value));
533
- ge(V), H([l, B, X], () => U(1)), H(
534
- w,
535
- Re(() => U(1), 300)
536
- ), H(p, (s) => {
537
- s || (A.value = !1);
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 V() {
540
- d.value = await i.directories(), l.value ??= d.value[0]?.id ?? null, await U(1);
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 U(s = f.value?.meta.current_page ?? 1) {
543
- J.value = !0;
589
+ async function L(r = c.value?.meta.current_page ?? 1) {
590
+ Q.value = !0;
544
591
  try {
545
- f.value = await i.files({
546
- directory_id: w.value ? null : l.value,
547
- q: w.value,
548
- type: B.value === "all" ? null : B.value,
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: s
551
- }), m.value = [];
597
+ page: r
598
+ }), h.value = [];
552
599
  } finally {
553
- J.value = !1;
600
+ Q.value = !1;
554
601
  }
555
602
  }
556
- function $e() {
603
+ function Me() {
557
604
  ne.value?.click();
558
605
  }
559
- async function _e(s) {
560
- const o = s.target, v = Array.from(o.files ?? []);
561
- if (o.value = "", !(v.length === 0 || l.value === null))
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 i.upload(l.value, v), q = $.filter((Fe) => Fe.duplicate).length;
564
- $.length > q && O.success(a("manager.uploaded", { count: $.length - q })), q > 0 && O.info(a("manager.duplicate-added")), await Promise.all([V(), U(1)]);
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
- O.danger(ue($) ?? a("errors.upload"));
613
+ P.danger(ce($) ?? t("errors.upload"));
567
614
  }
568
615
  }
569
- const oe = Y(at);
570
- async function ie() {
571
- const s = await oe({
572
- title: a("manager.new-folder"),
573
- confirmText: a("manager.new-folder")
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
- s === void 0 || l.value === null || (await i.createDirectory(l.value, s), await V());
622
+ r === void 0 || f.value === null || (await o.createDirectory(f.value, r), await W());
576
623
  }
577
- async function re() {
578
- const s = D.value;
579
- if (!s || s.is_root)
624
+ async function se() {
625
+ const r = D.value;
626
+ if (!r || r.is_root)
580
627
  return;
581
- const o = await oe({
582
- title: a("manager.rename"),
583
- value: s.title,
584
- confirmText: a("manager.save")
628
+ const n = await ie({
629
+ title: t("manager.rename"),
630
+ value: r.title,
631
+ confirmText: t("manager.save")
585
632
  });
586
- o !== void 0 && (await i.renameDirectory(s.id, o), await V());
633
+ n !== void 0 && (await o.renameDirectory(r.id, n), await W());
587
634
  }
588
- async function se() {
589
- const s = D.value;
590
- if (!(!s || s.is_root)) {
635
+ async function de() {
636
+ const r = D.value;
637
+ if (!(!r || r.is_root)) {
591
638
  try {
592
- await i.deleteDirectory(s.id);
593
- } catch (o) {
594
- const v = Ve(o);
595
- if (!v)
596
- throw o;
597
- if (!await pe({
598
- title: a("dialogs.delete-folder-title", { title: s.title }),
599
- message: `${a("dialogs.delete-folder-contents", v)} ${a("dialogs.delete-folder-warning")}`,
600
- confirmText: a("dialogs.confirm"),
601
- cancelText: a("manager.cancel"),
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 i.deleteDirectory(s.id, !0);
652
+ await o.deleteDirectory(r.id, !0);
606
653
  }
607
- l.value = null, await V();
654
+ f.value = null, await W();
608
655
  }
609
656
  }
610
- async function de(s, o) {
657
+ async function ue(r, n) {
611
658
  try {
612
- await i.moveDirectory(s, o);
613
- } catch (v) {
614
- O.danger(ue(v) ?? a("errors.directory-into-itself"));
659
+ await o.moveDirectory(r, n);
660
+ } catch (g) {
661
+ P.danger(ce(g) ?? t("errors.directory-into-itself"));
615
662
  }
616
- await V();
663
+ await W();
617
664
  }
618
- const Me = Y(tt);
619
- async function Ce() {
620
- const s = await Me({
621
- directories: d.value,
622
- from: l.value,
623
- count: m.value.length
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
- s !== void 0 && (await i.move([...m.value], s), await Promise.all([V(), U()]));
672
+ r !== void 0 && (await o.move([...h.value], r), await Promise.all([W(), L()]));
626
673
  }
627
- async function Te() {
628
- const s = [...m.value];
629
- await pe({
630
- title: a("dialogs.delete-files-title", { count: s.length }),
631
- message: a("dialogs.delete-files-text"),
632
- confirmText: a("dialogs.confirm"),
633
- cancelText: a("manager.cancel"),
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 i.remove(s), await Promise.all([V(), U()]));
682
+ }) && (await o.remove(r), await Promise.all([W(), L()]));
636
683
  }
637
- async function ze(s, o) {
638
- await i.rename(s.id, o), await U();
684
+ async function De(r, n) {
685
+ await o.rename(r.id, n), await L();
639
686
  }
640
- async function De(s) {
641
- await i.removeOne(s.id), await Promise.all([V(), U()]);
687
+ async function Le(r) {
688
+ await o.removeOne(r.id), await Promise.all([W(), L()]);
642
689
  }
643
- async function Ue(s) {
644
- const o = await Ge({ src: s.url, fileName: s.file_name, filters: !1 });
645
- o && (await i.edit(s.id, {
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: o.crop,
649
- rotate: (o.rotation % 360 + 360) % 360,
650
- flip: o.flipX ? "horizontal" : o.flipY ? "vertical" : void 0,
651
- resize: { width: o.width, height: o.height }
652
- }), await U());
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(s) {
655
- const o = (v) => {
656
- for (const $ of v) {
657
- if ($.id === s)
709
+ function We(r) {
710
+ const n = (g) => {
711
+ for (const $ of g) {
712
+ if ($.id === r)
658
713
  return $;
659
- const q = o($.children ?? []);
660
- if (q)
661
- return q;
714
+ const O = n($.children ?? []);
715
+ if (O)
716
+ return O;
662
717
  }
663
718
  return null;
664
719
  };
665
- return s === null ? null : o(d.value);
720
+ return r === null ? null : n(i.value);
666
721
  }
667
- function Ve(s) {
668
- const o = s?.body;
669
- return o?.code === "directory_not_empty" ? o.counts ?? null : null;
722
+ function Ve(r) {
723
+ const n = r?.body;
724
+ return n?.code === "directory_not_empty" ? n.counts ?? null : null;
670
725
  }
671
- function ue(s) {
672
- return s?.message ?? null;
726
+ function ce(r) {
727
+ return r?.message ?? null;
673
728
  }
674
- function Ee(s) {
675
- const o = ["B", "KB", "MB", "GB", "TB"];
676
- let v = s, $ = 0;
677
- for (; v >= 1024 && $ < o.length - 1; )
678
- v /= 1024, $++;
679
- return `${v >= 10 || $ === 0 ? Math.round(v) : v.toFixed(1)} ${o[$]}`;
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 Re(s, o) {
682
- let v;
736
+ function Ee(r, n) {
737
+ let g;
683
738
  return () => {
684
- clearTimeout(v), v = setTimeout(s, o);
739
+ clearTimeout(g), g = setTimeout(r, n);
685
740
  };
686
741
  }
687
- return (s, o) => (h(), W("div", {
742
+ return (r, n) => (b(), U("div", {
688
743
  ref_key: "root",
689
- ref: u,
690
- class: Oe(["wx-media", { "wx-media--compact": p.value }])
744
+ ref: x,
745
+ class: qe(["wx-media", { "wx-media--compact": d.value }])
691
746
  }, [
692
- p.value ? T("", !0) : (h(), W("aside", it, [
693
- y(ve, {
694
- selected: l.value,
695
- "onUpdate:selected": o[0] || (o[0] = (v) => l.value = v),
696
- directories: d.value,
697
- onMove: de
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 ? (h(), k(e(ee), {
754
+ I.value ? (b(), k(e(te), {
700
755
  key: 0,
701
756
  size: "sm",
702
757
  align: "start"
703
758
  }, {
704
- default: b(() => [
705
- y(e(M), {
759
+ default: w(() => [
760
+ y(e(_), {
706
761
  type: "add",
707
- title: e(a)("manager.new-folder"),
708
- onClick: ie
762
+ title: e(t)("manager.new-folder"),
763
+ onClick: re
709
764
  }, null, 8, ["title"]),
710
- y(e(M), {
765
+ y(e(_), {
711
766
  type: "edit",
712
- title: e(a)("manager.rename"),
767
+ title: e(t)("manager.rename"),
713
768
  disabled: !D.value || D.value.is_root,
714
- onClick: re
769
+ onClick: se
715
770
  }, null, 8, ["title", "disabled"]),
716
- y(e(M), {
771
+ y(e(_), {
717
772
  type: "remove",
718
- title: e(a)("manager.delete"),
773
+ title: e(t)("manager.delete"),
719
774
  disabled: !D.value || D.value.is_root,
720
- onClick: se
775
+ onClick: de
721
776
  }, null, 8, ["title", "disabled"])
722
777
  ]),
723
778
  _: 1
724
779
  })) : T("", !0)
725
780
  ])),
726
- E("section", rt, [
727
- y(et, {
728
- search: w.value,
729
- "onUpdate:search": o[1] || (o[1] = (v) => w.value = v),
730
- type: B.value,
731
- "onUpdate:type": o[2] || (o[2] = (v) => B.value = v),
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": o[3] || (o[3] = (v) => X.value = v),
734
- "can-upload": ke.value && !t.picking,
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: m.value.length,
737
- compact: p.value,
738
- onUpload: $e,
739
- onMove: Ce,
740
- onRemove: Te,
741
- onFolders: o[4] || (o[4] = (v) => A.value = !0)
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
- E("input", {
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(Qe, {
752
- selected: m.value,
753
- "onUpdate:selected": o[5] || (o[5] = (v) => m.value = v),
754
- files: xe.value,
755
- api: e(i),
756
- query: w.value,
757
- single: t.picking,
758
- onRename: ze,
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: De,
761
- onOpen: o[6] || (o[6] = (v) => n("pick", v))
815
+ onRemove: Le,
816
+ onOpen: n[6] || (n[6] = (g) => l("pick", g))
762
817
  }, null, 8, ["selected", "files", "api", "query", "single"]),
763
- E("footer", st, [
764
- E("span", null, z(e(a)("manager.status-files", { count: f.value?.stats.files ?? 0 })), 1),
765
- m.value.length > 0 ? (h(), W("span", dt, z(e(a)("manager.status-selected", { count: m.value.length })), 1)) : T("", !0),
766
- E("span", null, z(e(a)("manager.status-size", { size: Ee(f.value?.stats.size ?? 0) })), 1)
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
- f.value && f.value.meta.last_page > 1 ? (h(), k(e(Ke), {
823
+ c.value && c.value.meta.last_page > 1 ? (b(), k(e(je), {
769
824
  key: 0,
770
- page: f.value.meta.current_page,
771
- "per-page": f.value.meta.per_page,
772
- total: f.value.meta.total,
773
- "last-page": f.value.meta.last_page,
774
- disabled: J.value,
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: o[7] || (o[7] = ({ page: v }) => U(v))
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(je), {
780
- open: A.value,
781
- "onUpdate:open": o[10] || (o[10] = (v) => A.value = v),
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(a)("manager.folders"),
838
+ title: e(t)("manager.folders"),
784
839
  size: 280
785
840
  }, {
786
- default: b(() => [
787
- E("div", ut, [
788
- y(ve, {
789
- selected: l.value,
841
+ default: w(() => [
842
+ V("div", ct, [
843
+ y(fe, {
844
+ selected: f.value,
790
845
  "onUpdate:selected": [
791
- o[8] || (o[8] = (v) => l.value = v),
792
- o[9] || (o[9] = (v) => A.value = !1)
846
+ n[8] || (n[8] = (g) => f.value = g),
847
+ n[9] || (n[9] = (g) => H.value = !1)
793
848
  ],
794
- directories: d.value,
795
- onMove: de
849
+ directories: i.value,
850
+ onMove: ue
796
851
  }, null, 8, ["selected", "directories"]),
797
- I.value ? (h(), k(e(ee), {
852
+ I.value ? (b(), k(e(te), {
798
853
  key: 0,
799
854
  size: "sm",
800
855
  align: "start"
801
856
  }, {
802
- default: b(() => [
803
- y(e(M), {
857
+ default: w(() => [
858
+ y(e(_), {
804
859
  type: "add",
805
- title: e(a)("manager.new-folder"),
806
- onClick: ie
860
+ title: e(t)("manager.new-folder"),
861
+ onClick: re
807
862
  }, null, 8, ["title"]),
808
- y(e(M), {
863
+ y(e(_), {
809
864
  type: "edit",
810
- title: e(a)("manager.rename"),
865
+ title: e(t)("manager.rename"),
811
866
  disabled: !D.value || D.value.is_root,
812
- onClick: re
867
+ onClick: se
813
868
  }, null, 8, ["title", "disabled"]),
814
- y(e(M), {
869
+ y(e(_), {
815
870
  type: "remove",
816
- title: e(a)("manager.delete"),
871
+ title: e(t)("manager.delete"),
817
872
  disabled: !D.value || D.value.is_root,
818
- onClick: se
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
- }), ct = /* @__PURE__ */ R({
884
+ }), mt = /* @__PURE__ */ R({
830
885
  __name: "MediaPage",
831
- setup(t) {
832
- return (r, g) => (h(), k(e(Ye), {
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: b(() => [
837
- y(he)
891
+ default: w(() => [
892
+ y(we)
838
893
  ]),
839
894
  _: 1
840
895
  }));
841
896
  }
842
- }), mt = { class: "wx-media-picker" }, be = /* @__PURE__ */ R({
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(t) {
850
- const { open: r, resolve: g } = ae(), n = S("webx-media");
851
- return (c, i) => (h(), k(e(le), {
852
- open: e(r),
853
- "onUpdate:open": i[1] || (i[1] = (a) => te(r) ? r.value = a : null),
854
- title: t.title ?? e(n)("module.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: b(() => [
858
- E("div", mt, [
859
- y(he, {
860
- picking: !t.manage,
861
- accept: t.manage ? null : t.accept,
862
- onPick: i[0] || (i[0] = (a) => e(g)(a))
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
- }), pt = Y(be), bt = Y(
870
- be,
924
+ }), vt = J(xe), xt = J(
925
+ xe,
871
926
  { props: { manage: !0 } }
872
- ), vt = { class: "wx-media-field" }, ft = {
927
+ ), ft = { class: "wx-media-field" }, gt = {
873
928
  key: 0,
874
929
  class: "wx-media-field__label"
875
- }, gt = { class: "wx-media-field__body" }, xt = /* @__PURE__ */ R({
930
+ }, yt = { class: "wx-media-field__body" }, kt = /* @__PURE__ */ R({
876
931
  __name: "MediaField",
877
- props: /* @__PURE__ */ P({
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(t) {
887
- const r = L(t, "modelValue");
888
- we();
889
- const g = S("webx-media"), n = C(() => r.value?.url ?? null);
890
- async function c() {
891
- const a = await pt({ accept: "image" });
892
- a && (r.value = { ...r.value, path: a.path, url: a.url });
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 i() {
895
- r.value = null;
949
+ function t() {
950
+ u.value = null;
896
951
  }
897
- return (a, u) => (h(), W("div", vt, [
898
- t.label ? (h(), W("span", ft, z(t.label), 1)) : T("", !0),
899
- E("div", gt, [
900
- n.value ? (h(), k(e(Je), {
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: n.value,
958
+ src: m.value,
904
959
  fit: "cover"
905
960
  }, null, 8, ["src"])) : T("", !0),
906
- y(e(G), {
961
+ y(e(Y), {
907
962
  direction: "vertical",
908
963
  size: "sm",
909
964
  class: "wx-media-field__controls"
910
965
  }, {
911
- default: b(() => [
912
- y(e(G), { size: "xs" }, {
913
- default: b(() => [
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: c
972
+ onClick: o
918
973
  }, {
919
- default: b(() => [
920
- F(z(e(g)("manager.select")), 1)
974
+ default: w(() => [
975
+ F(z(e(l)("manager.select")), 1)
921
976
  ]),
922
977
  _: 1
923
978
  }),
924
- r.value ? (h(), k(e(N), {
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: i
984
+ onClick: t
930
985
  }, {
931
- default: b(() => [
932
- F(z(e(g)("manager.delete")), 1)
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
- t.captions && r.value ? (h(), W(K, { key: 0 }, [
940
- y(e(j), {
941
- "model-value": r.value.alt ?? "",
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": u[0] || (u[0] = (x) => r.value = { ...r.value, alt: String(x) })
999
+ "onUpdate:modelValue": x[0] || (x[0] = (p) => u.value = { ...u.value, alt: String(p) })
945
1000
  }, null, 8, ["model-value"]),
946
- y(e(j), {
947
- "model-value": r.value.title ?? "",
1001
+ y(e(G), {
1002
+ "model-value": u.value.title ?? "",
948
1003
  size: "sm",
949
1004
  placeholder: "title",
950
- "onUpdate:modelValue": u[1] || (u[1] = (x) => r.value = { ...r.value, title: String(x) })
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 kt(t = {}) {
961
- const r = t.path ?? "/media";
1015
+ function $t(a = {}) {
1016
+ const v = a.path ?? "/media";
962
1017
  return {
963
1018
  id: "media",
964
- path: r,
1019
+ path: v,
965
1020
  routes: [
966
1021
  {
967
- path: r,
1022
+ path: v,
968
1023
  name: "webx.media",
969
- component: ct
1024
+ component: mt
970
1025
  }
971
1026
  ]
972
1027
  };
973
1028
  }
974
1029
  export {
975
- xt as WxMediaField,
976
- he as WxMediaManager,
977
- ct as WxMediaPage,
978
- be as WxMediaPicker,
979
- lt as createMediaApi,
980
- kt as media,
981
- ot as mediaMessages,
982
- bt as openMediaLibrary,
983
- pt as openMediaPicker
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