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