@webx-ui/module-media 0.5.1 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { defineComponent as S, useModel as A, ref as M, watch as q, openBlock as b, createBlock as $, unref as e, mergeModels as F, computed as D, resolveDirective as Pe, withCtx as w, createElementBlock as W, Fragment as Q, renderList as Z, withDirectives as Oe, createCommentVNode as U, createVNode as h, createTextVNode as P, toDisplayString as L, isRef as te, useTemplateRef as ee, onMounted as he, nextTick as qe, createElementVNode as _, withKeys as Ne, normalizeClass as Ae, normalizeStyle as me } from "vue";
2
- import { useTranslate as B, useAdmin as ae } from "@webx-ui/module-admin";
3
- import { WxTree as He, WxSelectionArea as Ie, WxFileCard as Xe, WxEmpty as Ke, toast as N, WxAction as T, WxInput as j, WxDropdown as pe, WxDropdownItem as fe, WxActions as G, useModal as le, WxDialog as ie, WxSelect as je, WxSpace as be, WxButton as I, useElementWidth as Ge, createModal as Y, WxPagination as Ye, WxDrawer as Je, confirm as ve, openImageEditor as Qe, WxImage as Ze, WxPopover as et, WxPopconfirm as tt, WxCard as at } from "@webx-ui/core";
4
- function we(a) {
5
- const d = `${a.apiPath}/media`, m = (l) => l.data;
1
+ import { defineComponent as O, useModel as I, ref as L, watch as K, openBlock as b, createBlock as T, unref as e, mergeModels as j, computed as U, resolveDirective as Ke, withCtx as x, createElementBlock as W, Fragment as se, renderList as re, withDirectives as je, createCommentVNode as R, createVNode as v, createTextVNode as N, toDisplayString as z, isRef as me, useTemplateRef as de, onMounted as Fe, nextTick as Ge, createElementVNode as M, withKeys as Ye, normalizeClass as ue, createSlots as Je, inject as Qe, normalizeStyle as ce, mergeProps as pe } from "vue";
2
+ import { useTranslate as X, useAdmin as fe, adminKey as Ze } from "@webx-ui/module-admin";
3
+ import { WxTree as et, WxSelectionArea as tt, WxFileCard as Ue, WxEmpty as lt, toast as Q, WxAction as D, WxInput as Z, WxDropdown as Ce, WxDropdownItem as Ve, WxActions as le, useModal as ve, WxDialog as ge, WxSelect as at, WxSpace as ye, WxButton as H, useElementWidth as it, createModal as ae, WxPagination as nt, WxDrawer as ot, confirm as Me, openImageEditor as st, WxSortableList as rt, WxPopover as We, WxPopconfirm as Le, WxImage as dt, WxCard as ut } from "@webx-ui/core";
4
+ function he(t) {
5
+ const i = `${t.apiPath}/media`, o = (l) => l.data;
6
6
  return {
7
- directories: () => a.http.get(`${d}/directories`).then(m),
8
- createDirectory: (l, v) => a.http.post(`${d}/directories`, { parent_id: l, title: v }).then(m),
9
- renameDirectory: (l, v) => a.http.patch(`${d}/directories/${l}`, { title: v }).then(m),
10
- moveDirectory: (l, v) => a.http.patch(`${d}/directories/${l}/move`, { parent_id: v }).then(m),
11
- deleteDirectory: (l, v = !1) => a.http.delete(`${d}/directories/${l}`, {
12
- query: { force: v ? 1 : void 0 }
7
+ directories: () => t.http.get(`${i}/directories`).then(o),
8
+ createDirectory: (l, c) => t.http.post(`${i}/directories`, { parent_id: l, title: c }).then(o),
9
+ renameDirectory: (l, c) => t.http.patch(`${i}/directories/${l}`, { title: c }).then(o),
10
+ moveDirectory: (l, c) => t.http.patch(`${i}/directories/${l}/move`, { parent_id: c }).then(o),
11
+ deleteDirectory: (l, c = !1) => t.http.delete(`${i}/directories/${l}`, {
12
+ query: { force: c ? 1 : void 0 }
13
13
  }),
14
- files: (l = {}) => a.http.get(`${d}/files`, {
14
+ files: (l = {}) => t.http.get(`${i}/files`, {
15
15
  query: {
16
16
  directory_id: l.directory_id ?? void 0,
17
17
  q: l.q || void 0,
@@ -21,91 +21,101 @@ function we(a) {
21
21
  per_page: l.per_page
22
22
  }
23
23
  }),
24
- file: (l) => a.http.get(`${d}/files/${l}`).then(m),
25
- fileByPath: (l) => a.http.get(`${d}/files/by-path?path=${encodeURIComponent(l)}`).then(m).catch(() => null),
26
- async upload(l, v, i) {
27
- const t = new FormData();
28
- return t.append("directory_id", String(l)), v.forEach((p) => t.append("files[]", p)), new Promise((p, k) => {
29
- const g = new XMLHttpRequest();
30
- g.open("POST", `${d}/files`), g.responseType = "json", g.withCredentials = !0, g.setRequestHeader("Accept", "application/json"), g.setRequestHeader("X-Requested-With", "XMLHttpRequest"), g.setRequestHeader("X-Webx-Locale", a.i18n.state.locale);
31
- const u = lt();
32
- u && g.setRequestHeader("X-XSRF-TOKEN", u), g.upload.addEventListener("progress", (n) => {
33
- n.lengthComputable && i?.(Math.round(n.loaded / n.total * 100));
34
- }), g.addEventListener("load", () => {
35
- const n = g.response;
36
- if (g.status >= 200 && g.status < 300 && n?.data) {
37
- p(n.data);
24
+ file: (l) => t.http.get(`${i}/files/${l}`).then(o),
25
+ fileByPath: (l) => t.http.get(`${i}/files/by-path?path=${encodeURIComponent(l)}`).then(o).catch(() => null),
26
+ async upload(l, c, s) {
27
+ const a = new FormData();
28
+ return a.append("directory_id", String(l)), c.forEach((n) => a.append("files[]", n)), new Promise((n, k) => {
29
+ const w = new XMLHttpRequest();
30
+ w.open("POST", `${i}/files`), w.responseType = "json", w.withCredentials = !0, w.setRequestHeader("Accept", "application/json"), w.setRequestHeader("X-Requested-With", "XMLHttpRequest"), w.setRequestHeader("X-Webx-Locale", t.i18n.state.locale);
31
+ const u = ct();
32
+ u && w.setRequestHeader("X-XSRF-TOKEN", u), w.upload.addEventListener("progress", (r) => {
33
+ r.lengthComputable && s?.(Math.round(r.loaded / r.total * 100));
34
+ }), w.addEventListener("load", () => {
35
+ const r = w.response;
36
+ if (w.status >= 200 && w.status < 300 && r?.data) {
37
+ n(r.data);
38
38
  return;
39
39
  }
40
40
  k(
41
- Object.assign(new Error(n?.message ?? "Upload failed"), {
42
- status: g.status,
43
- body: n
41
+ Object.assign(new Error(r?.message ?? "Upload failed"), {
42
+ status: w.status,
43
+ body: r
44
44
  })
45
45
  );
46
- }), g.addEventListener("error", () => k(new Error("Upload failed"))), g.send(t);
46
+ }), w.addEventListener("error", () => k(new Error("Upload failed"))), w.send(a);
47
47
  });
48
48
  },
49
- rename: (l, v) => a.http.patch(`${d}/files/${l}`, { name: v }).then(m),
50
- move: (l, v) => a.http.post(`${d}/files/move`, { ids: l, directory_id: v }).then((i) => i.data.moved),
49
+ rename: (l, c) => t.http.patch(`${i}/files/${l}`, { name: c }).then(o),
50
+ move: (l, c) => t.http.post(`${i}/files/move`, { ids: l, directory_id: c }).then((s) => s.data.moved),
51
51
  // A POST for the batch, not a DELETE: the panel's own client sends no body on DELETE, and
52
52
  // a list of ids in a query string is a worse answer than an honest verb.
53
- remove: (l) => a.http.post(`${d}/files/delete`, { ids: l }).then((v) => v.data.deleted),
54
- removeOne: (l) => a.http.delete(`${d}/files/${l}`),
55
- edit: (l, v) => a.http.post(`${d}/files/${l}/edit`, v).then(m),
56
- copy: (l) => a.http.post(`${d}/files/${l}/copy`).then(m),
57
- restoreOriginal: (l) => a.http.post(`${d}/files/${l}/restore-original`).then(m),
58
- thumb(l, v, i, t = "cover") {
53
+ remove: (l) => t.http.post(`${i}/files/delete`, { ids: l }).then((c) => c.data.deleted),
54
+ removeOne: (l) => t.http.delete(`${i}/files/${l}`),
55
+ edit: (l, c) => t.http.post(`${i}/files/${l}/edit`, c).then(o),
56
+ copy: (l) => t.http.post(`${i}/files/${l}/copy`).then(o),
57
+ restoreOriginal: (l) => t.http.post(`${i}/files/${l}/restore-original`).then(o),
58
+ thumb(l, c, s, a = "cover") {
59
59
  if (!l.thumb)
60
60
  return null;
61
- const p = new URL(l.thumb, window.location.origin);
62
- return p.searchParams.set("w", String(v)), i && p.searchParams.set("h", String(i)), p.searchParams.set("fit", t), p.pathname + p.search;
61
+ const n = new URL(l.thumb, window.location.origin);
62
+ return n.searchParams.set("w", String(c)), s && n.searchParams.set("h", String(s)), n.searchParams.set("fit", a), n.pathname + n.search;
63
63
  }
64
64
  };
65
65
  }
66
- function lt() {
67
- const a = document.cookie.split("; ").find((d) => d.startsWith("XSRF-TOKEN="));
68
- return a ? decodeURIComponent(a.slice(11)) : null;
66
+ function ct() {
67
+ const t = document.cookie.split("; ").find((i) => i.startsWith("XSRF-TOKEN="));
68
+ return t ? decodeURIComponent(t.slice(11)) : null;
69
69
  }
70
- const ge = /* @__PURE__ */ S({
70
+ function Re(t) {
71
+ const i = ["B", "KB", "MB", "GB", "TB"];
72
+ let o = t, l = 0;
73
+ for (; o >= 1024 && l < i.length - 1; )
74
+ o /= 1024, l++;
75
+ return `${o >= 10 || l === 0 ? Math.round(o) : o.toFixed(1)} ${i[l]}`;
76
+ }
77
+ function mt(t) {
78
+ return t.split("/").pop() || t;
79
+ }
80
+ const Te = /* @__PURE__ */ O({
71
81
  __name: "DirectoryTree",
72
- props: /* @__PURE__ */ F({
82
+ props: /* @__PURE__ */ j({
73
83
  directories: {}
74
84
  }, {
75
85
  selected: { default: null },
76
86
  selectedModifiers: {}
77
87
  }),
78
- emits: /* @__PURE__ */ F(["move"], ["update:selected"]),
79
- setup(a, { emit: d }) {
80
- const m = a, l = A(a, "selected"), v = d, i = B("webx-media"), t = M([]), p = M([]);
81
- q(
82
- () => m.directories,
83
- (n) => {
84
- t.value = n.map(k), p.value = g(n);
88
+ emits: /* @__PURE__ */ j(["move"], ["update:selected"]),
89
+ setup(t, { emit: i }) {
90
+ const o = t, l = I(t, "selected"), c = i, s = X("webx-media"), a = L([]), n = L([]);
91
+ K(
92
+ () => o.directories,
93
+ (r) => {
94
+ a.value = r.map(k), n.value = w(r);
85
95
  },
86
96
  { immediate: !0, deep: !0 }
87
97
  );
88
- function k(n) {
98
+ function k(r) {
89
99
  return {
90
- ...n,
91
- label: n.is_root ? i("manager.root") : n.title,
92
- children: (n.children ?? []).map(k)
100
+ ...r,
101
+ label: r.is_root ? s("manager.root") : r.title,
102
+ children: (r.children ?? []).map(k)
93
103
  };
94
104
  }
95
- function g(n) {
96
- return n.flatMap((f) => [f.id, ...g(f.children ?? [])]);
105
+ function w(r) {
106
+ return r.flatMap((g) => [g.id, ...w(g.children ?? [])]);
97
107
  }
98
- function u(n) {
99
- const f = n.zone === "inside" ? n.target : n.parent;
100
- f && v("move", n.node.id, f.id);
108
+ function u(r) {
109
+ const g = r.zone === "inside" ? r.target : r.parent;
110
+ g && c("move", r.node.id, g.id);
101
111
  }
102
- return (n, f) => (b(), $(e(He), {
112
+ return (r, g) => (b(), T(e(et), {
103
113
  selected: l.value,
104
- "onUpdate:selected": f[0] || (f[0] = (c) => l.value = c),
105
- expanded: p.value,
106
- "onUpdate:expanded": f[1] || (f[1] = (c) => p.value = c),
107
- modelValue: t.value,
108
- "onUpdate:modelValue": f[2] || (f[2] = (c) => t.value = c),
114
+ "onUpdate:selected": g[0] || (g[0] = (f) => l.value = f),
115
+ expanded: n.value,
116
+ "onUpdate:expanded": g[1] || (g[1] = (f) => n.value = f),
117
+ modelValue: a.value,
118
+ "onUpdate:modelValue": g[2] || (g[2] = (f) => a.value = f),
109
119
  class: "wx-media-tree",
110
120
  "node-key": "id",
111
121
  draggable: "",
@@ -113,9 +123,9 @@ const ge = /* @__PURE__ */ S({
113
123
  onDrop: u
114
124
  }, null, 8, ["selected", "expanded", "modelValue"]));
115
125
  }
116
- }), it = /* @__PURE__ */ S({
126
+ }), pt = /* @__PURE__ */ O({
117
127
  __name: "FileGrid",
118
- props: /* @__PURE__ */ F({
128
+ props: /* @__PURE__ */ j({
119
129
  files: {},
120
130
  api: {},
121
131
  query: {},
@@ -124,79 +134,79 @@ const ge = /* @__PURE__ */ S({
124
134
  selected: { default: () => [] },
125
135
  selectedModifiers: {}
126
136
  }),
127
- emits: /* @__PURE__ */ F(["open", "rename", "edit", "remove"], ["update:selected"]),
128
- setup(a, { emit: d }) {
129
- const m = a, l = A(a, "selected"), v = d, i = B("webx-media"), t = D(
130
- () => m.query ? i("manager.empty-search", { query: m.query }) : i("manager.empty")
137
+ emits: /* @__PURE__ */ j(["open", "rename", "edit", "remove"], ["update:selected"]),
138
+ setup(t, { emit: i }) {
139
+ const o = t, l = I(t, "selected"), c = i, s = X("webx-media"), a = U(
140
+ () => o.query ? s("manager.empty-search", { query: o.query }) : s("manager.empty")
131
141
  );
132
- function p() {
133
- N.success(i("manager.link-copied"));
142
+ function n() {
143
+ Q.success(s("manager.link-copied"));
134
144
  }
135
- function k(g) {
145
+ function k(w) {
136
146
  const u = document.createElement("textarea");
137
- u.value = g.url, u.setAttribute("readonly", ""), u.style.position = "fixed", u.style.opacity = "0", document.body.appendChild(u), u.select();
138
- let n = !1;
147
+ u.value = w.url, u.setAttribute("readonly", ""), u.style.position = "fixed", u.style.opacity = "0", document.body.appendChild(u), u.select();
148
+ let r = !1;
139
149
  try {
140
- n = document.execCommand("copy");
150
+ r = document.execCommand("copy");
141
151
  } catch {
142
- n = !1;
152
+ r = !1;
143
153
  }
144
- if (u.remove(), n) {
145
- p();
154
+ if (u.remove(), r) {
155
+ n();
146
156
  return;
147
157
  }
148
- N.danger(`${i("errors.copy")} ${g.url}`, { duration: 0 });
158
+ Q.danger(`${s("errors.copy")} ${w.url}`, { duration: 0 });
149
159
  }
150
- return (g, u) => {
151
- const n = Pe("wx-select");
152
- return a.files.length > 0 ? (b(), $(e(Ie), {
160
+ return (w, u) => {
161
+ const r = Ke("wx-select");
162
+ return t.files.length > 0 ? (b(), T(e(tt), {
153
163
  key: 0,
154
164
  modelValue: l.value,
155
- "onUpdate:modelValue": u[0] || (u[0] = (f) => l.value = f),
165
+ "onUpdate:modelValue": u[0] || (u[0] = (g) => l.value = g),
156
166
  class: "wx-media-grid",
157
- multiple: !a.single
167
+ multiple: !t.single
158
168
  }, {
159
- default: w(({ isSelected: f }) => [
160
- (b(!0), W(Q, null, Z(a.files, (c) => Oe((b(), $(e(Xe), {
161
- key: c.id,
169
+ default: x(({ isSelected: g }) => [
170
+ (b(!0), W(se, null, re(t.files, (f) => je((b(), T(e(Ue), {
171
+ key: f.id,
162
172
  class: "wx-media-grid__card",
163
- name: c.name,
164
- url: c.url,
165
- thumbnail: a.api.thumb(c, 320, 320) ?? void 0,
166
- type: c.mime,
167
- selected: f(c.id),
173
+ name: f.name,
174
+ url: f.url,
175
+ thumbnail: t.api.thumb(f, 320, 320) ?? void 0,
176
+ type: f.mime,
177
+ selected: g(f.id),
168
178
  renamable: "",
169
- editable: c.editable,
179
+ editable: f.editable,
170
180
  removable: "",
171
181
  copyable: "",
172
- "rename-label": e(i)("manager.rename"),
173
- "edit-label": e(i)("manager.edit"),
174
- "remove-label": e(i)("manager.delete"),
175
- "remove-confirm-text": e(i)("dialogs.delete-file", { name: c.name }),
176
- "cancel-label": e(i)("manager.cancel"),
177
- "save-label": e(i)("manager.save"),
178
- "copy-label": e(i)("manager.copy-link"),
179
- "copied-label": e(i)("manager.link-copied"),
180
- onRename: (s) => v("rename", c, s),
181
- onEdit: (s) => v("edit", c),
182
- onRemove: (s) => v("remove", c),
183
- onCopy: p,
184
- onCopyError: (s) => k(c),
185
- onDblclick: (s) => v("open", c)
182
+ "rename-label": e(s)("manager.rename"),
183
+ "edit-label": e(s)("manager.edit"),
184
+ "remove-label": e(s)("manager.delete"),
185
+ "remove-confirm-text": e(s)("dialogs.delete-file", { name: f.name }),
186
+ "cancel-label": e(s)("manager.cancel"),
187
+ "save-label": e(s)("manager.save"),
188
+ "copy-label": e(s)("manager.copy-link"),
189
+ "copied-label": e(s)("manager.link-copied"),
190
+ onRename: (d) => c("rename", f, d),
191
+ onEdit: (d) => c("edit", f),
192
+ onRemove: (d) => c("remove", f),
193
+ onCopy: n,
194
+ onCopyError: (d) => k(f),
195
+ onDblclick: (d) => c("open", f)
186
196
  }, 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"])), [
187
- [n, c.id]
197
+ [r, f.id]
188
198
  ])), 128))
189
199
  ]),
190
200
  _: 1
191
- }, 8, ["modelValue", "multiple"])) : (b(), $(e(Ke), {
201
+ }, 8, ["modelValue", "multiple"])) : (b(), T(e(lt), {
192
202
  key: 1,
193
- description: t.value
203
+ description: a.value
194
204
  }, null, 8, ["description"]));
195
205
  };
196
206
  }
197
- }), ot = { class: "wx-media-toolbar" }, nt = /* @__PURE__ */ S({
207
+ }), ft = { class: "wx-media-toolbar" }, vt = /* @__PURE__ */ O({
198
208
  __name: "MediaToolbar",
199
- props: /* @__PURE__ */ F({
209
+ props: /* @__PURE__ */ j({
200
210
  canUpload: { type: Boolean },
201
211
  canManage: { type: Boolean },
202
212
  selected: {},
@@ -210,155 +220,155 @@ const ge = /* @__PURE__ */ S({
210
220
  sort: { default: "-created_at" },
211
221
  sortModifiers: {}
212
222
  }),
213
- emits: /* @__PURE__ */ F(["upload", "move", "remove", "folders"], ["update:search", "update:type", "update:sort"]),
214
- setup(a, { emit: d }) {
215
- const m = a, l = A(a, "search"), v = A(a, "type"), i = A(a, "sort"), t = d, p = B("webx-media"), k = D(() => [
216
- { value: "all", label: p("manager.all-types") },
217
- ...["image", "video", "audio", "document", "other"].map((f) => ({
218
- value: f,
219
- label: p(`manager.${f}`)
223
+ emits: /* @__PURE__ */ j(["upload", "move", "remove", "folders"], ["update:search", "update:type", "update:sort"]),
224
+ setup(t, { emit: i }) {
225
+ const o = t, l = I(t, "search"), c = I(t, "type"), s = I(t, "sort"), a = i, n = X("webx-media"), k = U(() => [
226
+ { value: "all", label: n("manager.all-types") },
227
+ ...["image", "video", "audio", "document", "other"].map((g) => ({
228
+ value: g,
229
+ label: n(`manager.${g}`)
220
230
  }))
221
- ]), g = D(() => [
222
- { value: "-created_at", label: p("manager.sort-newest") },
223
- { value: "created_at", label: p("manager.sort-oldest") },
224
- { value: "name", label: p("manager.sort-name") },
225
- { value: "-size", label: p("manager.sort-size") }
226
- ]), u = D(() => k.value.find((f) => f.value === v.value)?.label ?? ""), n = D(() => g.value.find((f) => f.value === i.value)?.label ?? "");
227
- return (f, c) => (b(), W("header", ot, [
228
- a.compact ? (b(), $(e(T), {
231
+ ]), w = U(() => [
232
+ { value: "-created_at", label: n("manager.sort-newest") },
233
+ { value: "created_at", label: n("manager.sort-oldest") },
234
+ { value: "name", label: n("manager.sort-name") },
235
+ { value: "-size", label: n("manager.sort-size") }
236
+ ]), u = U(() => k.value.find((g) => g.value === c.value)?.label ?? ""), r = U(() => w.value.find((g) => g.value === s.value)?.label ?? "");
237
+ return (g, f) => (b(), W("header", ft, [
238
+ t.compact ? (b(), T(e(D), {
229
239
  key: 0,
230
240
  icon: "folder",
231
- title: e(p)("manager.folders"),
241
+ title: e(n)("manager.folders"),
232
242
  size: "sm",
233
- onClick: c[0] || (c[0] = (s) => t("folders"))
234
- }, null, 8, ["title"])) : U("", !0),
235
- h(e(j), {
243
+ onClick: f[0] || (f[0] = (d) => a("folders"))
244
+ }, null, 8, ["title"])) : R("", !0),
245
+ v(e(Z), {
236
246
  modelValue: l.value,
237
- "onUpdate:modelValue": c[1] || (c[1] = (s) => l.value = s),
247
+ "onUpdate:modelValue": f[1] || (f[1] = (d) => l.value = d),
238
248
  class: "wx-media-toolbar__search",
239
- placeholder: e(p)("manager.search"),
249
+ placeholder: e(n)("manager.search"),
240
250
  clearable: "",
241
251
  size: "sm"
242
252
  }, null, 8, ["modelValue", "placeholder"]),
243
- a.fixedType ? U("", !0) : (b(), $(e(pe), { key: 1 }, {
244
- trigger: w(() => [
245
- h(e(T), {
253
+ t.fixedType ? R("", !0) : (b(), T(e(Ce), { key: 1 }, {
254
+ trigger: x(() => [
255
+ v(e(D), {
246
256
  icon: "filter",
247
- title: `${e(p)("manager.all-types")}: ${u.value}`,
257
+ title: `${e(n)("manager.all-types")}: ${u.value}`,
248
258
  size: "sm"
249
259
  }, null, 8, ["title"])
250
260
  ]),
251
- default: w(() => [
252
- (b(!0), W(Q, null, Z(k.value, (s) => (b(), $(e(fe), {
253
- key: String(s.value),
254
- active: s.value === v.value,
255
- onClick: (x) => v.value = s.value
261
+ default: x(() => [
262
+ (b(!0), W(se, null, re(k.value, (d) => (b(), T(e(Ve), {
263
+ key: String(d.value),
264
+ active: d.value === c.value,
265
+ onClick: ($) => c.value = d.value
256
266
  }, {
257
- default: w(() => [
258
- P(L(s.label), 1)
267
+ default: x(() => [
268
+ N(z(d.label), 1)
259
269
  ]),
260
270
  _: 2
261
271
  }, 1032, ["active", "onClick"]))), 128))
262
272
  ]),
263
273
  _: 1
264
274
  })),
265
- h(e(pe), null, {
266
- trigger: w(() => [
267
- h(e(T), {
275
+ v(e(Ce), null, {
276
+ trigger: x(() => [
277
+ v(e(D), {
268
278
  icon: "arrow-down",
269
- title: n.value,
279
+ title: r.value,
270
280
  size: "sm"
271
281
  }, null, 8, ["title"])
272
282
  ]),
273
- default: w(() => [
274
- (b(!0), W(Q, null, Z(g.value, (s) => (b(), $(e(fe), {
275
- key: s.value,
276
- active: s.value === i.value,
277
- onClick: (x) => i.value = s.value
283
+ default: x(() => [
284
+ (b(!0), W(se, null, re(w.value, (d) => (b(), T(e(Ve), {
285
+ key: d.value,
286
+ active: d.value === s.value,
287
+ onClick: ($) => s.value = d.value
278
288
  }, {
279
- default: w(() => [
280
- P(L(s.label), 1)
289
+ default: x(() => [
290
+ N(z(d.label), 1)
281
291
  ]),
282
292
  _: 2
283
293
  }, 1032, ["active", "onClick"]))), 128))
284
294
  ]),
285
295
  _: 1
286
296
  }),
287
- a.canUpload ? (b(), $(e(T), {
297
+ t.canUpload ? (b(), T(e(D), {
288
298
  key: 2,
289
299
  type: "upload",
290
- title: e(p)("manager.upload"),
300
+ title: e(n)("manager.upload"),
291
301
  size: "sm",
292
- onClick: c[2] || (c[2] = (s) => t("upload"))
293
- }, null, 8, ["title"])) : U("", !0),
294
- a.canManage ? (b(), $(e(G), {
302
+ onClick: f[2] || (f[2] = (d) => a("upload"))
303
+ }, null, 8, ["title"])) : R("", !0),
304
+ t.canManage ? (b(), T(e(le), {
295
305
  key: 3,
296
306
  size: "sm"
297
307
  }, {
298
- default: w(() => [
299
- h(e(T), {
308
+ default: x(() => [
309
+ v(e(D), {
300
310
  icon: "folder",
301
- title: e(p)("manager.move"),
302
- disabled: m.selected === 0,
303
- onClick: c[3] || (c[3] = (s) => t("move"))
311
+ title: e(n)("manager.move"),
312
+ disabled: o.selected === 0,
313
+ onClick: f[3] || (f[3] = (d) => a("move"))
304
314
  }, null, 8, ["title", "disabled"]),
305
- h(e(T), {
315
+ v(e(D), {
306
316
  type: "remove",
307
- title: e(p)("manager.delete"),
308
- disabled: m.selected === 0,
309
- onClick: c[4] || (c[4] = (s) => t("remove"))
317
+ title: e(n)("manager.delete"),
318
+ disabled: o.selected === 0,
319
+ onClick: f[4] || (f[4] = (d) => a("remove"))
310
320
  }, null, 8, ["title", "disabled"])
311
321
  ]),
312
322
  _: 1
313
- })) : U("", !0)
323
+ })) : R("", !0)
314
324
  ]));
315
325
  }
316
- }), rt = /* @__PURE__ */ S({
326
+ }), gt = /* @__PURE__ */ O({
317
327
  __name: "MoveDialog",
318
328
  props: {
319
329
  directories: {},
320
330
  from: {},
321
331
  count: {}
322
332
  },
323
- setup(a) {
324
- const d = a, { open: m, resolve: l, dismiss: v } = le(), i = B("webx-media"), t = D(
325
- () => k(d.directories).filter((g) => g.value !== d.from)
326
- ), p = M(t.value[0]?.value ?? null);
327
- function k(g) {
328
- return g.flatMap((u) => [
333
+ setup(t) {
334
+ const i = t, { open: o, resolve: l, dismiss: c } = ve(), s = X("webx-media"), a = U(
335
+ () => k(i.directories).filter((w) => w.value !== i.from)
336
+ ), n = L(a.value[0]?.value ?? null);
337
+ function k(w) {
338
+ return w.flatMap((u) => [
329
339
  {
330
340
  value: u.id,
331
341
  // Indented, so the tree is still readable once it is a flat list.
332
- label: " ".repeat(u.depth * 3) + (u.is_root ? i("manager.root") : u.title)
342
+ label: " ".repeat(u.depth * 3) + (u.is_root ? s("manager.root") : u.title)
333
343
  },
334
344
  ...k(u.children ?? [])
335
345
  ]);
336
346
  }
337
- return (g, u) => (b(), $(e(ie), {
338
- open: e(m),
339
- "onUpdate:open": u[3] || (u[3] = (n) => te(m) ? m.value = n : null),
340
- title: e(i)("manager.move-to"),
347
+ return (w, u) => (b(), T(e(ge), {
348
+ open: e(o),
349
+ "onUpdate:open": u[3] || (u[3] = (r) => me(o) ? o.value = r : null),
350
+ title: e(s)("manager.move-to"),
341
351
  width: 420
342
352
  }, {
343
- footer: w(() => [
344
- h(e(be), { size: "sm" }, {
345
- default: w(() => [
346
- h(e(I), {
353
+ footer: x(() => [
354
+ v(e(ye), { size: "sm" }, {
355
+ default: x(() => [
356
+ v(e(H), {
347
357
  variant: "outline",
348
- onClick: u[1] || (u[1] = (n) => e(v)())
358
+ onClick: u[1] || (u[1] = (r) => e(c)())
349
359
  }, {
350
- default: w(() => [
351
- P(L(e(i)("manager.cancel")), 1)
360
+ default: x(() => [
361
+ N(z(e(s)("manager.cancel")), 1)
352
362
  ]),
353
363
  _: 1
354
364
  }),
355
- h(e(I), {
365
+ v(e(H), {
356
366
  type: "primary",
357
- disabled: p.value === null,
358
- onClick: u[2] || (u[2] = (n) => e(l)(p.value))
367
+ disabled: n.value === null,
368
+ onClick: u[2] || (u[2] = (r) => e(l)(n.value))
359
369
  }, {
360
- default: w(() => [
361
- P(L(e(i)("manager.move")), 1)
370
+ default: x(() => [
371
+ N(z(e(s)("manager.move")), 1)
362
372
  ]),
363
373
  _: 1
364
374
  }, 8, ["disabled"])
@@ -366,17 +376,17 @@ const ge = /* @__PURE__ */ S({
366
376
  _: 1
367
377
  })
368
378
  ]),
369
- default: w(() => [
370
- h(e(je), {
371
- modelValue: p.value,
372
- "onUpdate:modelValue": u[0] || (u[0] = (n) => p.value = n),
373
- options: t.value
379
+ default: x(() => [
380
+ v(e(at), {
381
+ modelValue: n.value,
382
+ "onUpdate:modelValue": u[0] || (u[0] = (r) => n.value = r),
383
+ options: a.value
374
384
  }, null, 8, ["modelValue", "options"])
375
385
  ]),
376
386
  _: 1
377
387
  }, 8, ["open", "title"]));
378
388
  }
379
- }), st = /* @__PURE__ */ S({
389
+ }), yt = /* @__PURE__ */ O({
380
390
  __name: "NameDialog",
381
391
  props: {
382
392
  title: {},
@@ -384,40 +394,40 @@ const ge = /* @__PURE__ */ S({
384
394
  value: { default: "" },
385
395
  confirmText: { default: void 0 }
386
396
  },
387
- setup(a) {
388
- const d = a, { open: m, resolve: l, dismiss: v } = le(), i = B("webx-media"), t = M(d.value), p = ee("input");
389
- he(async () => {
390
- await qe(), p.value?.querySelector("input")?.focus();
397
+ setup(t) {
398
+ const i = t, { open: o, resolve: l, dismiss: c } = ve(), s = X("webx-media"), a = L(i.value), n = de("input");
399
+ Fe(async () => {
400
+ await Ge(), n.value?.querySelector("input")?.focus();
391
401
  });
392
402
  function k() {
393
- const g = t.value.trim();
394
- g !== "" && l(g);
403
+ const w = a.value.trim();
404
+ w !== "" && l(w);
395
405
  }
396
- return (g, u) => (b(), $(e(ie), {
397
- open: e(m),
398
- "onUpdate:open": u[2] || (u[2] = (n) => te(m) ? m.value = n : null),
399
- title: a.title,
406
+ return (w, u) => (b(), T(e(ge), {
407
+ open: e(o),
408
+ "onUpdate:open": u[2] || (u[2] = (r) => me(o) ? o.value = r : null),
409
+ title: t.title,
400
410
  width: 420
401
411
  }, {
402
- footer: w(() => [
403
- h(e(be), { size: "sm" }, {
404
- default: w(() => [
405
- h(e(I), {
412
+ footer: x(() => [
413
+ v(e(ye), { size: "sm" }, {
414
+ default: x(() => [
415
+ v(e(H), {
406
416
  variant: "outline",
407
- onClick: u[1] || (u[1] = (n) => e(v)())
417
+ onClick: u[1] || (u[1] = (r) => e(c)())
408
418
  }, {
409
- default: w(() => [
410
- P(L(e(i)("manager.cancel")), 1)
419
+ default: x(() => [
420
+ N(z(e(s)("manager.cancel")), 1)
411
421
  ]),
412
422
  _: 1
413
423
  }),
414
- h(e(I), {
424
+ v(e(H), {
415
425
  type: "primary",
416
- disabled: t.value.trim() === "",
426
+ disabled: a.value.trim() === "",
417
427
  onClick: k
418
428
  }, {
419
- default: w(() => [
420
- P(L(a.confirmText ?? e(i)("manager.save")), 1)
429
+ default: x(() => [
430
+ N(z(t.confirmText ?? e(s)("manager.save")), 1)
421
431
  ]),
422
432
  _: 1
423
433
  }, 8, ["disabled"])
@@ -425,24 +435,24 @@ const ge = /* @__PURE__ */ S({
425
435
  _: 1
426
436
  })
427
437
  ]),
428
- default: w(() => [
429
- _("div", {
438
+ default: x(() => [
439
+ M("div", {
430
440
  ref_key: "input",
431
- ref: p
441
+ ref: n
432
442
  }, [
433
- h(e(j), {
434
- modelValue: t.value,
435
- "onUpdate:modelValue": u[0] || (u[0] = (n) => t.value = n),
436
- placeholder: a.label ?? e(i)("manager.folder-name"),
437
- "aria-label": a.label ?? e(i)("manager.folder-name"),
438
- onKeyup: Ne(k, ["enter"])
443
+ v(e(Z), {
444
+ modelValue: a.value,
445
+ "onUpdate:modelValue": u[0] || (u[0] = (r) => a.value = r),
446
+ placeholder: t.label ?? e(s)("manager.folder-name"),
447
+ "aria-label": t.label ?? e(s)("manager.folder-name"),
448
+ onKeyup: Ye(k, ["enter"])
439
449
  }, null, 8, ["modelValue", "placeholder", "aria-label"])
440
450
  ], 512)
441
451
  ]),
442
452
  _: 1
443
453
  }, 8, ["open", "title"]));
444
454
  }
445
- }), dt = {
455
+ }), ht = {
446
456
  module: {
447
457
  title: "Files"
448
458
  },
@@ -481,7 +491,9 @@ const ge = /* @__PURE__ */ S({
481
491
  "link-copied": "Link copied",
482
492
  "status-files": "Files: :count",
483
493
  "status-selected": "selected: :count",
484
- "status-size": "size: :size"
494
+ "status-size": "size: :size",
495
+ pick: "Choose (:count)",
496
+ chosen: "Chosen :count of :max"
485
497
  },
486
498
  // The picture field on a form, which is the module used from outside its own section.
487
499
  field: {
@@ -494,7 +506,17 @@ const ge = /* @__PURE__ */ S({
494
506
  "no-preview": "No preview",
495
507
  "clear-title": "Clear the field?",
496
508
  "clear-text": "The file stays in the library — only this record stops using it.",
497
- "clear-confirm": "Clear"
509
+ "clear-confirm": "Clear",
510
+ add: "Add",
511
+ empty: "Nothing chosen yet",
512
+ reorder: "Reorder",
513
+ open: "Open in the library",
514
+ missing: "No longer in the library",
515
+ "remove-title": "Take it out of the list?",
516
+ "remove-text": "The file stays in the library — only this record stops using it.",
517
+ "remove-confirm": "Remove",
518
+ count: ":count of :max",
519
+ "at-least": "At least :count"
498
520
  },
499
521
  // The image editor is a component of the design system, so its words are props rather than
500
522
  // lines in the dictionary — the manager hands it these when it opens it.
@@ -536,7 +558,8 @@ const ge = /* @__PURE__ */ S({
536
558
  copy: "The clipboard is not available here. The address:",
537
559
  "unsupported-type": "Only these can be uploaded: :types.",
538
560
  "file-too-large": "The file is larger than :size MB.",
539
- "too-many-files": "No more than :count files at a time."
561
+ "too-many-files": "No more than :count files at a time.",
562
+ "file-not-found": "There is no such file in the library."
540
563
  },
541
564
  files: {
542
565
  copy: ":name (copy)"
@@ -545,407 +568,779 @@ const ge = /* @__PURE__ */ S({
545
568
  title: "name",
546
569
  parent_id: "parent folder",
547
570
  directory_id: "folder",
548
- files: "files"
571
+ files: "files",
572
+ item: "File :number: :message",
573
+ shape: "This is not a file from the library.",
574
+ accept: "This field takes :kind only.",
575
+ localized: "A field of files cannot be translated — the captions inside it are.",
576
+ kind: {
577
+ image: "images",
578
+ video: "video",
579
+ audio: "audio",
580
+ document: "documents",
581
+ other: "other files"
582
+ }
549
583
  }
550
- }, ye = /* @__PURE__ */ new WeakSet();
551
- function xe() {
584
+ }, ze = /* @__PURE__ */ new WeakSet();
585
+ function be() {
552
586
  try {
553
- const { i18n: a } = ae();
554
- ye.has(a) || (a.defaults("webx-media", dt), ye.add(a));
587
+ const { i18n: t } = fe();
588
+ ze.has(t) || (t.defaults("webx-media", ht), ze.add(t));
555
589
  } catch {
556
590
  }
557
591
  }
558
- const ut = {
592
+ const bt = {
559
593
  key: 0,
560
594
  class: "wx-media__folders"
561
- }, ct = { class: "wx-media__files" }, mt = ["accept"], pt = { class: "wx-media__status" }, ft = { key: 0 }, vt = { class: "wx-media__drawer" }, ke = /* @__PURE__ */ S({
595
+ }, wt = { class: "wx-media__files" }, xt = ["accept"], kt = { class: "wx-media__status" }, $t = { key: 0 }, _t = { class: "wx-media__drawer" }, De = /* @__PURE__ */ O({
562
596
  __name: "MediaManager",
563
597
  props: {
564
598
  picking: { type: Boolean, default: !1 },
565
- accept: { default: null }
599
+ accept: { default: null },
600
+ multiple: { type: Boolean, default: !1 },
601
+ max: { default: null }
566
602
  },
567
- emits: ["pick"],
568
- setup(a, { emit: d }) {
569
- const m = a, l = d, v = ae(), i = we(v);
570
- xe();
571
- const t = B("webx-media");
572
- function p() {
603
+ emits: ["pick", "selection"],
604
+ setup(t, { emit: i }) {
605
+ const o = t, l = i, c = fe(), s = he(c);
606
+ be();
607
+ const a = X("webx-media");
608
+ function n() {
573
609
  return {
574
- title: t("editor.title"),
575
- saveLabel: t("editor.save"),
576
- cancelLabel: t("editor.cancel"),
577
- resetLabel: t("editor.reset"),
578
- rotateLeftLabel: t("editor.rotate-left"),
579
- rotateRightLabel: t("editor.rotate-right"),
580
- flipHorizontalLabel: t("editor.flip-horizontal"),
581
- flipVerticalLabel: t("editor.flip-vertical"),
582
- ratioLabel: t("editor.ratio"),
583
- cropLabel: t("editor.crop"),
584
- outputLabel: t("editor.output"),
585
- outputHint: t("editor.output-hint"),
586
- widthLabel: t("editor.width"),
587
- heightLabel: t("editor.height"),
588
- freeLabel: t("editor.free"),
589
- originalLabel: t("editor.original"),
590
- errorText: t("editor.error")
610
+ title: a("editor.title"),
611
+ saveLabel: a("editor.save"),
612
+ cancelLabel: a("editor.cancel"),
613
+ resetLabel: a("editor.reset"),
614
+ rotateLeftLabel: a("editor.rotate-left"),
615
+ rotateRightLabel: a("editor.rotate-right"),
616
+ flipHorizontalLabel: a("editor.flip-horizontal"),
617
+ flipVerticalLabel: a("editor.flip-vertical"),
618
+ ratioLabel: a("editor.ratio"),
619
+ cropLabel: a("editor.crop"),
620
+ outputLabel: a("editor.output"),
621
+ outputHint: a("editor.output-hint"),
622
+ widthLabel: a("editor.width"),
623
+ heightLabel: a("editor.height"),
624
+ freeLabel: a("editor.free"),
625
+ originalLabel: a("editor.original"),
626
+ errorText: a("editor.error")
591
627
  };
592
628
  }
593
- const k = ee("root"), g = Ge(k), u = D(() => g.value > 0 && g.value < 640), n = M([]), f = M(null), c = M(null), s = M([]), x = M(""), z = M(m.accept ?? "all");
594
- q(
595
- () => m.accept,
596
- (r) => {
597
- z.value = r ?? "all";
629
+ const k = de("root"), w = it(k), u = U(() => w.value > 0 && w.value < 640), r = L([]), g = L(null), f = L(null), d = L([]), $ = L(""), B = L(o.accept ?? "all");
630
+ K(
631
+ () => o.accept,
632
+ (m) => {
633
+ B.value = m ?? "all";
598
634
  }
599
635
  );
600
- const X = M("-created_at"), J = M(!1), H = M(!1), oe = ee("picker"), _e = D(() => c.value?.data ?? []), K = D(() => v.can("media.manage")), Ce = D(() => v.can("media.upload") || K.value), R = D(() => Ve(f.value));
601
- he(E), q([f, z, X], () => V(1)), q(
602
- x,
603
- Be(() => V(1), 300)
604
- ), q(u, (r) => {
605
- r || (H.value = !1);
636
+ const Y = L("-created_at"), ee = L(!1), P = L(!1), ie = de("picker"), te = U(() => f.value?.data ?? []), G = U(() => c.can("media.manage")), ne = U(() => c.can("media.upload") || G.value), E = U(() => qe(g.value)), oe = U(() => o.picking && !o.multiple);
637
+ K(d, (m) => {
638
+ if (o.max !== null && o.max > 0 && m.length > o.max) {
639
+ d.value = m.slice(0, o.max);
640
+ return;
641
+ }
642
+ l(
643
+ "selection",
644
+ te.value.filter((p) => m.includes(p.id))
645
+ );
646
+ }), Fe(A), K([g, B, Y], () => S(1)), K(
647
+ $,
648
+ He(() => S(1), 300)
649
+ ), K(u, (m) => {
650
+ m || (P.value = !1);
606
651
  });
607
- async function E() {
608
- n.value = await i.directories(), f.value ??= n.value[0]?.id ?? null, await V(1);
652
+ async function A() {
653
+ r.value = await s.directories(), g.value ??= r.value[0]?.id ?? null, await S(1);
609
654
  }
610
- async function V(r = c.value?.meta.current_page ?? 1) {
611
- J.value = !0;
655
+ async function S(m = f.value?.meta.current_page ?? 1) {
656
+ ee.value = !0;
612
657
  try {
613
- c.value = await i.files({
614
- directory_id: x.value ? null : f.value,
615
- q: x.value,
616
- type: z.value === "all" ? null : z.value,
617
- sort: X.value,
618
- page: r
619
- }), s.value = [];
658
+ f.value = await s.files({
659
+ directory_id: $.value ? null : g.value,
660
+ q: $.value,
661
+ type: B.value === "all" ? null : B.value,
662
+ sort: Y.value,
663
+ page: m
664
+ }), d.value = [];
620
665
  } finally {
621
- J.value = !1;
666
+ ee.value = !1;
622
667
  }
623
668
  }
624
- function Me() {
625
- oe.value?.click();
669
+ function y() {
670
+ ie.value?.click();
626
671
  }
627
- async function Te(r) {
628
- const o = r.target, y = Array.from(o.files ?? []);
629
- if (o.value = "", !(y.length === 0 || f.value === null))
672
+ async function h(m) {
673
+ const p = m.target, _ = Array.from(p.files ?? []);
674
+ if (p.value = "", !(_.length === 0 || g.value === null))
630
675
  try {
631
- const C = await i.upload(f.value, y), O = C.filter((Fe) => Fe.duplicate).length;
632
- C.length > O && N.success(t("manager.uploaded", { count: C.length - O })), O > 0 && N.info(t("manager.duplicate-added")), await Promise.all([E(), V(1)]);
633
- } catch (C) {
634
- N.danger(ce(C) ?? t("errors.upload"));
676
+ const q = await s.upload(g.value, _), J = q.filter((Xe) => Xe.duplicate).length;
677
+ q.length > J && Q.success(a("manager.uploaded", { count: q.length - J })), J > 0 && Q.info(a("manager.duplicate-added")), await Promise.all([A(), S(1)]);
678
+ } catch (q) {
679
+ Q.danger(_e(q) ?? a("errors.upload"));
635
680
  }
636
681
  }
637
- const ne = Y(st);
638
- async function re() {
639
- const r = await ne({
640
- title: t("manager.new-folder"),
641
- confirmText: t("manager.new-folder")
682
+ const V = ae(yt);
683
+ async function C() {
684
+ const m = await V({
685
+ title: a("manager.new-folder"),
686
+ confirmText: a("manager.new-folder")
642
687
  });
643
- r === void 0 || f.value === null || (await i.createDirectory(f.value, r), await E());
688
+ m === void 0 || g.value === null || (await s.createDirectory(g.value, m), await A());
644
689
  }
645
- async function se() {
646
- const r = R.value;
647
- if (!r || r.is_root)
690
+ async function F() {
691
+ const m = E.value;
692
+ if (!m || m.is_root)
648
693
  return;
649
- const o = await ne({
650
- title: t("manager.rename"),
651
- value: r.title,
652
- confirmText: t("manager.save")
694
+ const p = await V({
695
+ title: a("manager.rename"),
696
+ value: m.title,
697
+ confirmText: a("manager.save")
653
698
  });
654
- o !== void 0 && (await i.renameDirectory(r.id, o), await E());
699
+ p !== void 0 && (await s.renameDirectory(m.id, p), await A());
655
700
  }
656
- async function de() {
657
- const r = R.value;
658
- if (!(!r || r.is_root)) {
701
+ async function ke() {
702
+ const m = E.value;
703
+ if (!(!m || m.is_root)) {
659
704
  try {
660
- await i.deleteDirectory(r.id);
661
- } catch (o) {
662
- const y = Ee(o);
663
- if (!y)
664
- throw o;
665
- if (!await ve({
666
- title: t("dialogs.delete-folder-title", { title: r.title }),
667
- message: `${t("dialogs.delete-folder-contents", y)} ${t("dialogs.delete-folder-warning")}`,
668
- confirmText: t("dialogs.confirm"),
669
- cancelText: t("manager.cancel"),
705
+ await s.deleteDirectory(m.id);
706
+ } catch (p) {
707
+ const _ = Ie(p);
708
+ if (!_)
709
+ throw p;
710
+ if (!await Me({
711
+ title: a("dialogs.delete-folder-title", { title: m.title }),
712
+ message: `${a("dialogs.delete-folder-contents", _)} ${a("dialogs.delete-folder-warning")}`,
713
+ confirmText: a("dialogs.confirm"),
714
+ cancelText: a("manager.cancel"),
670
715
  tone: "danger"
671
716
  }))
672
717
  return;
673
- await i.deleteDirectory(r.id, !0);
718
+ await s.deleteDirectory(m.id, !0);
674
719
  }
675
- f.value = null, await E();
720
+ g.value = null, await A();
676
721
  }
677
722
  }
678
- async function ue(r, o) {
723
+ async function $e(m, p) {
679
724
  try {
680
- await i.moveDirectory(r, o);
681
- } catch (y) {
682
- N.danger(ce(y) ?? t("errors.directory-into-itself"));
725
+ await s.moveDirectory(m, p);
726
+ } catch (_) {
727
+ Q.danger(_e(_) ?? a("errors.directory-into-itself"));
683
728
  }
684
- await E();
729
+ await A();
685
730
  }
686
- const ze = Y(rt);
687
- async function We() {
688
- const r = await ze({
689
- directories: n.value,
690
- from: f.value,
691
- count: s.value.length
731
+ const Be = ae(gt);
732
+ async function Se() {
733
+ const m = await Be({
734
+ directories: r.value,
735
+ from: g.value,
736
+ count: d.value.length
692
737
  });
693
- r !== void 0 && (await i.move([...s.value], r), await Promise.all([E(), V()]));
738
+ m !== void 0 && (await s.move([...d.value], m), await Promise.all([A(), S()]));
694
739
  }
695
- async function De() {
696
- const r = [...s.value];
697
- await ve({
698
- title: t("dialogs.delete-files-title", { count: r.length }),
699
- message: t("dialogs.delete-files-text"),
700
- confirmText: t("dialogs.confirm"),
701
- cancelText: t("manager.cancel"),
740
+ async function Oe() {
741
+ const m = [...d.value];
742
+ await Me({
743
+ title: a("dialogs.delete-files-title", { count: m.length }),
744
+ message: a("dialogs.delete-files-text"),
745
+ confirmText: a("dialogs.confirm"),
746
+ cancelText: a("manager.cancel"),
702
747
  tone: "danger"
703
- }) && (await i.remove(r), await Promise.all([E(), V()]));
748
+ }) && (await s.remove(m), await Promise.all([A(), S()]));
704
749
  }
705
- async function Le(r, o) {
706
- await i.rename(r.id, o), await V();
750
+ async function Ee(m, p) {
751
+ await s.rename(m.id, p), await S();
707
752
  }
708
- async function Ue(r) {
709
- await i.removeOne(r.id), await Promise.all([E(), V()]);
753
+ async function Pe(m) {
754
+ await s.removeOne(m.id), await Promise.all([A(), S()]);
710
755
  }
711
- async function Re(r) {
712
- const o = await Qe({
713
- src: r.source ?? r.url,
714
- fileName: r.file_name,
756
+ async function Ae(m) {
757
+ const p = await st({
758
+ src: m.source ?? m.url,
759
+ fileName: m.file_name,
715
760
  filters: !1,
716
761
  // The editor is a component of the design system: its words are props with English
717
762
  // defaults, not lines in the panel's dictionary. Whoever opens it is the one who knows
718
763
  // what language the panel is being read in.
719
- ...p()
764
+ ...n()
720
765
  });
721
- o && (await i.edit(r.id, {
766
+ p && (await s.edit(m.id, {
722
767
  // The editor's frame is read against the picture as it is on screen — already turned — and
723
768
  // the server applies the operations in that order for the same reason.
724
- crop: o.crop,
725
- rotate: (o.rotation % 360 + 360) % 360,
726
- flip: o.flipX ? "horizontal" : o.flipY ? "vertical" : void 0,
727
- resize: { width: o.width, height: o.height }
728
- }), await V());
769
+ crop: p.crop,
770
+ rotate: (p.rotation % 360 + 360) % 360,
771
+ flip: p.flipX ? "horizontal" : p.flipY ? "vertical" : void 0,
772
+ resize: { width: p.width, height: p.height }
773
+ }), await S());
774
+ }
775
+ function Ne(m) {
776
+ o.multiple || l("pick", m);
729
777
  }
730
- function Ve(r) {
731
- const o = (y) => {
732
- for (const C of y) {
733
- if (C.id === r)
734
- return C;
735
- const O = o(C.children ?? []);
736
- if (O)
737
- return O;
778
+ function qe(m) {
779
+ const p = (_) => {
780
+ for (const q of _) {
781
+ if (q.id === m)
782
+ return q;
783
+ const J = p(q.children ?? []);
784
+ if (J)
785
+ return J;
738
786
  }
739
787
  return null;
740
788
  };
741
- return r === null ? null : o(n.value);
742
- }
743
- function Ee(r) {
744
- const o = r?.body;
745
- return o?.code === "directory_not_empty" ? o.counts ?? null : null;
789
+ return m === null ? null : p(r.value);
746
790
  }
747
- function ce(r) {
748
- return r?.message ?? null;
791
+ function Ie(m) {
792
+ const p = m?.body;
793
+ return p?.code === "directory_not_empty" ? p.counts ?? null : null;
749
794
  }
750
- function Se(r) {
751
- const o = ["B", "KB", "MB", "GB", "TB"];
752
- let y = r, C = 0;
753
- for (; y >= 1024 && C < o.length - 1; )
754
- y /= 1024, C++;
755
- return `${y >= 10 || C === 0 ? Math.round(y) : y.toFixed(1)} ${o[C]}`;
795
+ function _e(m) {
796
+ return m?.message ?? null;
756
797
  }
757
- function Be(r, o) {
758
- let y;
798
+ function He(m, p) {
799
+ let _;
759
800
  return () => {
760
- clearTimeout(y), y = setTimeout(r, o);
801
+ clearTimeout(_), _ = setTimeout(m, p);
761
802
  };
762
803
  }
763
- return (r, o) => (b(), W("div", {
804
+ return (m, p) => (b(), W("div", {
764
805
  ref_key: "root",
765
806
  ref: k,
766
- class: Ae(["wx-media", { "wx-media--compact": u.value }])
807
+ class: ue(["wx-media", { "wx-media--compact": u.value }])
767
808
  }, [
768
- u.value ? U("", !0) : (b(), W("aside", ut, [
769
- h(ge, {
770
- selected: f.value,
771
- "onUpdate:selected": o[0] || (o[0] = (y) => f.value = y),
772
- directories: n.value,
773
- onMove: ue
809
+ u.value ? R("", !0) : (b(), W("aside", bt, [
810
+ v(Te, {
811
+ selected: g.value,
812
+ "onUpdate:selected": p[0] || (p[0] = (_) => g.value = _),
813
+ directories: r.value,
814
+ onMove: $e
774
815
  }, null, 8, ["selected", "directories"]),
775
- K.value ? (b(), $(e(G), {
816
+ G.value ? (b(), T(e(le), {
776
817
  key: 0,
777
818
  size: "sm",
778
819
  align: "start"
779
820
  }, {
780
- default: w(() => [
781
- h(e(T), {
821
+ default: x(() => [
822
+ v(e(D), {
782
823
  type: "add",
783
- title: e(t)("manager.new-folder"),
784
- onClick: re
824
+ title: e(a)("manager.new-folder"),
825
+ onClick: C
785
826
  }, null, 8, ["title"]),
786
- h(e(T), {
827
+ v(e(D), {
787
828
  type: "edit",
788
- title: e(t)("manager.rename"),
789
- disabled: !R.value || R.value.is_root,
790
- onClick: se
829
+ title: e(a)("manager.rename"),
830
+ disabled: !E.value || E.value.is_root,
831
+ onClick: F
791
832
  }, null, 8, ["title", "disabled"]),
792
- h(e(T), {
833
+ v(e(D), {
793
834
  type: "remove",
794
- title: e(t)("manager.delete"),
795
- disabled: !R.value || R.value.is_root,
796
- onClick: de
835
+ title: e(a)("manager.delete"),
836
+ disabled: !E.value || E.value.is_root,
837
+ onClick: ke
797
838
  }, null, 8, ["title", "disabled"])
798
839
  ]),
799
840
  _: 1
800
- })) : U("", !0)
841
+ })) : R("", !0)
801
842
  ])),
802
- _("section", ct, [
803
- h(nt, {
804
- search: x.value,
805
- "onUpdate:search": o[1] || (o[1] = (y) => x.value = y),
806
- type: z.value,
807
- "onUpdate:type": o[2] || (o[2] = (y) => z.value = y),
808
- sort: X.value,
809
- "onUpdate:sort": o[3] || (o[3] = (y) => X.value = y),
810
- "can-upload": Ce.value,
811
- "fixed-type": a.accept !== null,
812
- "can-manage": K.value,
813
- selected: s.value.length,
843
+ M("section", wt, [
844
+ v(vt, {
845
+ search: $.value,
846
+ "onUpdate:search": p[1] || (p[1] = (_) => $.value = _),
847
+ type: B.value,
848
+ "onUpdate:type": p[2] || (p[2] = (_) => B.value = _),
849
+ sort: Y.value,
850
+ "onUpdate:sort": p[3] || (p[3] = (_) => Y.value = _),
851
+ "can-upload": ne.value,
852
+ "fixed-type": t.accept !== null,
853
+ "can-manage": G.value,
854
+ selected: d.value.length,
814
855
  compact: u.value,
815
- onUpload: Me,
816
- onMove: We,
817
- onRemove: De,
818
- onFolders: o[4] || (o[4] = (y) => H.value = !0)
856
+ onUpload: y,
857
+ onMove: Se,
858
+ onRemove: Oe,
859
+ onFolders: p[4] || (p[4] = (_) => P.value = !0)
819
860
  }, null, 8, ["search", "type", "sort", "can-upload", "fixed-type", "can-manage", "selected", "compact"]),
820
- _("input", {
861
+ M("input", {
821
862
  ref_key: "picker",
822
- ref: oe,
863
+ ref: ie,
823
864
  type: "file",
824
865
  multiple: "",
825
866
  hidden: "",
826
- accept: a.accept === null ? void 0 : `${a.accept}/*`,
827
- onChange: Te
828
- }, null, 40, mt),
829
- h(it, {
830
- selected: s.value,
831
- "onUpdate:selected": o[5] || (o[5] = (y) => s.value = y),
832
- files: _e.value,
833
- api: e(i),
834
- query: x.value,
835
- single: a.picking,
836
- onRename: Le,
837
- onEdit: Re,
838
- onRemove: Ue,
839
- onOpen: o[6] || (o[6] = (y) => l("pick", y))
867
+ accept: t.accept === null ? void 0 : `${t.accept}/*`,
868
+ onChange: h
869
+ }, null, 40, xt),
870
+ v(pt, {
871
+ selected: d.value,
872
+ "onUpdate:selected": p[5] || (p[5] = (_) => d.value = _),
873
+ files: te.value,
874
+ api: e(s),
875
+ query: $.value,
876
+ single: oe.value,
877
+ onRename: Ee,
878
+ onEdit: Ae,
879
+ onRemove: Pe,
880
+ onOpen: Ne
840
881
  }, null, 8, ["selected", "files", "api", "query", "single"]),
841
- _("footer", pt, [
842
- _("span", null, L(e(t)("manager.status-files", { count: c.value?.stats.files ?? 0 })), 1),
843
- s.value.length > 0 ? (b(), W("span", ft, L(e(t)("manager.status-selected", { count: s.value.length })), 1)) : U("", !0),
844
- _("span", null, L(e(t)("manager.status-size", { size: Se(c.value?.stats.size ?? 0) })), 1)
882
+ M("footer", kt, [
883
+ M("span", null, z(e(a)("manager.status-files", { count: f.value?.stats.files ?? 0 })), 1),
884
+ d.value.length > 0 ? (b(), W("span", $t, z(e(a)("manager.status-selected", { count: d.value.length })), 1)) : R("", !0),
885
+ M("span", null, z(e(a)("manager.status-size", { size: e(Re)(f.value?.stats.size ?? 0) })), 1)
845
886
  ]),
846
- c.value && c.value.meta.last_page > 1 ? (b(), $(e(Ye), {
887
+ f.value && f.value.meta.last_page > 1 ? (b(), T(e(nt), {
847
888
  key: 0,
848
- page: c.value.meta.current_page,
849
- "per-page": c.value.meta.per_page,
850
- total: c.value.meta.total,
851
- "last-page": c.value.meta.last_page,
852
- disabled: J.value,
889
+ page: f.value.meta.current_page,
890
+ "per-page": f.value.meta.per_page,
891
+ total: f.value.meta.total,
892
+ "last-page": f.value.meta.last_page,
893
+ disabled: ee.value,
853
894
  size: "sm",
854
- onChange: o[7] || (o[7] = ({ page: y }) => V(y))
855
- }, null, 8, ["page", "per-page", "total", "last-page", "disabled"])) : U("", !0)
895
+ onChange: p[6] || (p[6] = ({ page: _ }) => S(_))
896
+ }, null, 8, ["page", "per-page", "total", "last-page", "disabled"])) : R("", !0)
856
897
  ]),
857
- h(e(Je), {
858
- open: H.value,
859
- "onUpdate:open": o[10] || (o[10] = (y) => H.value = y),
898
+ v(e(ot), {
899
+ open: P.value,
900
+ "onUpdate:open": p[9] || (p[9] = (_) => P.value = _),
860
901
  side: "left",
861
- title: e(t)("manager.folders"),
902
+ title: e(a)("manager.folders"),
862
903
  size: 280
863
904
  }, {
864
- default: w(() => [
865
- _("div", vt, [
866
- h(ge, {
867
- selected: f.value,
905
+ default: x(() => [
906
+ M("div", _t, [
907
+ v(Te, {
908
+ selected: g.value,
868
909
  "onUpdate:selected": [
869
- o[8] || (o[8] = (y) => f.value = y),
870
- o[9] || (o[9] = (y) => H.value = !1)
910
+ p[7] || (p[7] = (_) => g.value = _),
911
+ p[8] || (p[8] = (_) => P.value = !1)
871
912
  ],
872
- directories: n.value,
873
- onMove: ue
913
+ directories: r.value,
914
+ onMove: $e
874
915
  }, null, 8, ["selected", "directories"]),
875
- K.value ? (b(), $(e(G), {
916
+ G.value ? (b(), T(e(le), {
876
917
  key: 0,
877
918
  size: "sm",
878
919
  align: "start"
879
920
  }, {
880
- default: w(() => [
881
- h(e(T), {
921
+ default: x(() => [
922
+ v(e(D), {
882
923
  type: "add",
883
- title: e(t)("manager.new-folder"),
884
- onClick: re
924
+ title: e(a)("manager.new-folder"),
925
+ onClick: C
885
926
  }, null, 8, ["title"]),
886
- h(e(T), {
927
+ v(e(D), {
887
928
  type: "edit",
888
- title: e(t)("manager.rename"),
889
- disabled: !R.value || R.value.is_root,
890
- onClick: se
929
+ title: e(a)("manager.rename"),
930
+ disabled: !E.value || E.value.is_root,
931
+ onClick: F
891
932
  }, null, 8, ["title", "disabled"]),
892
- h(e(T), {
933
+ v(e(D), {
893
934
  type: "remove",
894
- title: e(t)("manager.delete"),
895
- disabled: !R.value || R.value.is_root,
896
- onClick: de
935
+ title: e(a)("manager.delete"),
936
+ disabled: !E.value || E.value.is_root,
937
+ onClick: ke
897
938
  }, null, 8, ["title", "disabled"])
898
939
  ]),
899
940
  _: 1
900
- })) : U("", !0)
941
+ })) : R("", !0)
901
942
  ])
902
943
  ]),
903
944
  _: 1
904
945
  }, 8, ["open", "title"])
905
946
  ], 2));
906
947
  }
907
- }), gt = { class: "wx-media-picker" }, $e = /* @__PURE__ */ S({
948
+ }), Ct = { class: "wx-media-picker" }, Vt = {
949
+ key: 0,
950
+ class: "wx-media-picker__count"
951
+ }, we = /* @__PURE__ */ O({
908
952
  __name: "MediaPicker",
909
953
  props: {
910
954
  accept: { default: "image" },
911
955
  title: { default: void 0 },
912
- manage: { type: Boolean, default: !1 }
956
+ manage: { type: Boolean, default: !1 },
957
+ multiple: { type: Boolean, default: !1 },
958
+ max: { default: null }
913
959
  },
914
- setup(a) {
915
- const { open: d, resolve: m } = le(), l = B("webx-media");
916
- return (v, i) => (b(), $(e(ie), {
917
- open: e(d),
918
- "onUpdate:open": i[1] || (i[1] = (t) => te(d) ? d.value = t : null),
919
- title: a.title ?? e(l)("module.title"),
960
+ setup(t) {
961
+ const { open: i, resolve: o, dismiss: l } = ve(), c = X("webx-media"), s = L([]);
962
+ return (a, n) => (b(), T(e(ge), {
963
+ open: e(i),
964
+ "onUpdate:open": n[4] || (n[4] = (k) => me(i) ? i.value = k : null),
965
+ title: t.title ?? e(c)("module.title"),
920
966
  width: 960
921
- }, {
922
- default: w(() => [
923
- _("div", gt, [
924
- h(ke, {
925
- picking: !a.manage,
926
- accept: a.manage ? null : a.accept,
927
- onPick: i[0] || (i[0] = (t) => e(m)(t))
928
- }, null, 8, ["picking", "accept"])
967
+ }, Je({
968
+ default: x(() => [
969
+ M("div", Ct, [
970
+ v(De, {
971
+ picking: !t.manage,
972
+ accept: t.manage ? null : t.accept,
973
+ multiple: t.multiple && !t.manage,
974
+ max: t.max,
975
+ onPick: n[0] || (n[0] = (k) => e(o)(k)),
976
+ onSelection: n[1] || (n[1] = (k) => s.value = k)
977
+ }, null, 8, ["picking", "accept", "multiple", "max"])
929
978
  ])
930
979
  ]),
931
- _: 1
932
- }, 8, ["open", "title"]));
980
+ _: 2
981
+ }, [
982
+ t.multiple && !t.manage ? {
983
+ name: "footer",
984
+ fn: x(() => [
985
+ v(e(ye), { size: "sm" }, {
986
+ default: x(() => [
987
+ t.max !== null && t.max > 0 ? (b(), W("span", Vt, z(e(c)("manager.chosen", { count: s.value.length, max: t.max })), 1)) : R("", !0),
988
+ v(e(H), {
989
+ variant: "outline",
990
+ onClick: n[2] || (n[2] = (k) => e(l)())
991
+ }, {
992
+ default: x(() => [
993
+ N(z(e(c)("manager.cancel")), 1)
994
+ ]),
995
+ _: 1
996
+ }),
997
+ v(e(H), {
998
+ class: "wx-media-picker__confirm",
999
+ type: "primary",
1000
+ disabled: s.value.length === 0,
1001
+ onClick: n[3] || (n[3] = (k) => e(o)(s.value))
1002
+ }, {
1003
+ default: x(() => [
1004
+ N(z(e(c)("manager.pick", { count: s.value.length })), 1)
1005
+ ]),
1006
+ _: 1
1007
+ }, 8, ["disabled"])
1008
+ ]),
1009
+ _: 1
1010
+ })
1011
+ ]),
1012
+ key: "0"
1013
+ } : void 0
1014
+ ]), 1032, ["open", "title"]));
933
1015
  }
934
- }), yt = Y($e), Rt = Y(
935
- $e,
1016
+ }), Mt = ae(we), Tt = ae(we, {
1017
+ props: { multiple: !0 }
1018
+ }), zt = ae(
1019
+ we,
936
1020
  { props: { manage: !0 } }
937
- ), ht = { class: "wx-media-field" }, bt = {
1021
+ ), Ft = {
1022
+ key: 0,
1023
+ class: "wx-media-list__label"
1024
+ }, Ut = {
1025
+ key: 0,
1026
+ class: "wx-media-list__missing"
1027
+ }, Wt = { key: 1 }, Lt = {
1028
+ key: 0,
1029
+ class: "wx-media-list__tools"
1030
+ }, Rt = { class: "wx-media-list__captions" }, Dt = { class: "wx-media-list__caption" }, Bt = { class: "wx-media-list__caption" }, St = { class: "wx-media-list__captions-footer" }, Ot = { class: "wx-media-list__footer" }, Et = {
1031
+ key: 0,
1032
+ class: "wx-media-list__hint"
1033
+ }, xe = /* @__PURE__ */ O({
1034
+ __name: "MediaList",
1035
+ props: /* @__PURE__ */ j({
1036
+ label: { default: void 0 },
1037
+ layout: { default: "grid" },
1038
+ accept: { default: null },
1039
+ captions: { type: Boolean, default: !0 },
1040
+ max: { default: null },
1041
+ min: { default: null },
1042
+ columns: { default: null },
1043
+ aspect: { default: null },
1044
+ single: { type: Boolean, default: !1 },
1045
+ disabled: { type: Boolean, default: !1 }
1046
+ }, {
1047
+ modelValue: { default: () => [] },
1048
+ modelModifiers: {}
1049
+ }),
1050
+ emits: ["update:modelValue"],
1051
+ setup(t) {
1052
+ const i = t, o = I(t, "modelValue");
1053
+ be();
1054
+ const l = X("webx-media"), c = Qe(Ze, null), s = c ? he(c) : null, a = {
1055
+ "16/9": "16 / 9",
1056
+ "4/3": "4 / 3",
1057
+ "1/1": "1 / 1"
1058
+ }, n = U({
1059
+ get: () => Array.isArray(o.value) ? o.value : [],
1060
+ set: (y) => {
1061
+ o.value = y;
1062
+ }
1063
+ }), k = U(() => i.single ? 1 : i.max ?? null), w = U(() => k.value !== null && n.value.length >= k.value), u = L({}), r = /* @__PURE__ */ new Set();
1064
+ async function g(y) {
1065
+ if (!s) return;
1066
+ const h = y.filter((C) => !(C in u.value) && !r.has(C));
1067
+ if (h.length === 0) return;
1068
+ h.forEach((C) => r.add(C));
1069
+ const V = await Promise.all(
1070
+ h.map(async (C) => [C, await s.fileByPath(C)])
1071
+ );
1072
+ h.forEach((C) => r.delete(C)), u.value = { ...u.value, ...Object.fromEntries(V) };
1073
+ }
1074
+ K(
1075
+ () => n.value.map((y) => y.path),
1076
+ (y) => {
1077
+ g(y.filter(Boolean));
1078
+ },
1079
+ { immediate: !0 }
1080
+ );
1081
+ function f(y) {
1082
+ u.value = { ...u.value, ...Object.fromEntries(y.map((h) => [h.path, h])) };
1083
+ }
1084
+ function d(y) {
1085
+ return u.value[y.path];
1086
+ }
1087
+ function $(y) {
1088
+ return d(y) === null;
1089
+ }
1090
+ function B(y) {
1091
+ return d(y)?.name ?? mt(y.path);
1092
+ }
1093
+ function Y(y) {
1094
+ const h = d(y);
1095
+ return h && s ? s.thumb(h, 320, 320) ?? void 0 : void 0;
1096
+ }
1097
+ function ee(y) {
1098
+ const h = d(y);
1099
+ if (!h) return "";
1100
+ const V = Re(h.size);
1101
+ return h.width && h.height ? `${h.width}×${h.height} · ${V}` : V;
1102
+ }
1103
+ const P = L(null);
1104
+ function ie(y, h) {
1105
+ return n.value.findIndex((C) => C.path === y.path) === h ? y.path : `${y.path}#${h}`;
1106
+ }
1107
+ function te(y, h) {
1108
+ return n.value[y]?.[h] ?? {};
1109
+ }
1110
+ function G(y, h, V) {
1111
+ const C = n.value[y];
1112
+ if (!C) return;
1113
+ const F = [...n.value];
1114
+ F[y] = { ...C, [h]: V }, n.value = F;
1115
+ }
1116
+ async function ne() {
1117
+ if (i.disabled) return;
1118
+ const y = k.value === null ? null : k.value - n.value.length, h = await Tt({ accept: i.accept, max: y });
1119
+ if (!h || h.length === 0) return;
1120
+ f(h);
1121
+ const V = new Set(n.value.map((F) => F.path)), C = h.filter((F) => !V.has(F.path)).map((F) => ({ path: F.path }));
1122
+ n.value = i.single ? C.slice(0, 1) : [...n.value, ...C];
1123
+ }
1124
+ function E(y) {
1125
+ n.value = n.value.filter((h, V) => V !== y), P.value = null;
1126
+ }
1127
+ async function oe(y) {
1128
+ await zt({});
1129
+ const h = { ...u.value };
1130
+ delete h[y.path], u.value = h, g([y.path]);
1131
+ }
1132
+ const A = U(() => {
1133
+ const y = i.columns ? `repeat(${i.columns}, minmax(0, 1fr))` : "repeat(auto-fill, minmax(140px, 1fr))";
1134
+ return i.aspect ? {
1135
+ "--wx-media-list-columns": y,
1136
+ "--wx-media-list-aspect": a[i.aspect] ?? i.aspect
1137
+ } : { "--wx-media-list-columns": y };
1138
+ }), S = U(() => {
1139
+ const y = n.value.length;
1140
+ return i.min && y < i.min ? l("field.at-least", { count: i.min }) : k.value === null ? "" : l("field.count", { count: y, max: k.value });
1141
+ });
1142
+ return (y, h) => (b(), W("div", {
1143
+ class: ue(["wx-media-list", [`wx-media-list--${t.layout}`, { "is-disabled": t.disabled }]]),
1144
+ style: ce(A.value)
1145
+ }, [
1146
+ t.label ? (b(), W("span", Ft, z(t.label), 1)) : R("", !0),
1147
+ v(e(rt), {
1148
+ modelValue: n.value,
1149
+ "onUpdate:modelValue": h[1] || (h[1] = (V) => n.value = V),
1150
+ plain: "",
1151
+ disabled: t.disabled,
1152
+ handle: t.layout === "grid" ? "row" : "grip",
1153
+ "item-key": ie,
1154
+ "item-label": B,
1155
+ "drag-label": e(l)("field.reorder"),
1156
+ "empty-text": e(l)("field.empty")
1157
+ }, {
1158
+ default: x(({ item: V, index: C }) => [
1159
+ M("div", {
1160
+ class: ue(["wx-media-list__cell", { "is-broken": $(V), "is-busy": P.value === C }])
1161
+ }, [
1162
+ v(e(Ue), {
1163
+ name: B(V),
1164
+ thumbnail: Y(V),
1165
+ type: d(V)?.mime,
1166
+ size: t.layout === "rows" ? "sm" : "md"
1167
+ }, {
1168
+ meta: x(() => [
1169
+ $(V) ? (b(), W("span", Ut, z(e(l)("field.missing")), 1)) : (b(), W("span", Wt, z(ee(V)), 1))
1170
+ ]),
1171
+ _: 2
1172
+ }, 1032, ["name", "thumbnail", "type", "size"]),
1173
+ t.disabled ? R("", !0) : (b(), W("div", Lt, [
1174
+ v(e(le), { size: "sm" }, {
1175
+ default: x(() => [
1176
+ t.captions ? (b(), T(e(We), {
1177
+ key: 0,
1178
+ open: P.value === C,
1179
+ title: e(l)("field.captions"),
1180
+ width: 360,
1181
+ side: "top",
1182
+ teleport: "",
1183
+ "onUpdate:open": (F) => P.value = F ? C : null
1184
+ }, {
1185
+ trigger: x(() => [
1186
+ v(e(D), {
1187
+ type: "edit",
1188
+ title: e(l)("field.captions")
1189
+ }, null, 8, ["title"])
1190
+ ]),
1191
+ default: x(() => [
1192
+ M("div", Rt, [
1193
+ M("div", Dt, [
1194
+ h[2] || (h[2] = M("span", { class: "wx-media-list__caption-label" }, "alt", -1)),
1195
+ v(e(Z), {
1196
+ localized: "",
1197
+ "model-value": te(C, "alt"),
1198
+ placeholder: e(l)("field.alt-hint"),
1199
+ "onUpdate:modelValue": (F) => G(C, "alt", F)
1200
+ }, null, 8, ["model-value", "placeholder", "onUpdate:modelValue"])
1201
+ ]),
1202
+ M("div", Bt, [
1203
+ h[3] || (h[3] = M("span", { class: "wx-media-list__caption-label" }, "title", -1)),
1204
+ v(e(Z), {
1205
+ localized: "",
1206
+ "model-value": te(C, "title"),
1207
+ placeholder: e(l)("field.title-hint"),
1208
+ "onUpdate:modelValue": (F) => G(C, "title", F)
1209
+ }, null, 8, ["model-value", "placeholder", "onUpdate:modelValue"])
1210
+ ]),
1211
+ M("div", St, [
1212
+ v(e(H), {
1213
+ size: "sm",
1214
+ type: "primary",
1215
+ onClick: h[0] || (h[0] = (F) => P.value = null)
1216
+ }, {
1217
+ default: x(() => [
1218
+ N(z(e(l)("manager.save")), 1)
1219
+ ]),
1220
+ _: 1
1221
+ })
1222
+ ])
1223
+ ])
1224
+ ]),
1225
+ _: 2
1226
+ }, 1032, ["open", "title", "onUpdate:open"])) : R("", !0),
1227
+ $(V) ? R("", !0) : (b(), T(e(D), {
1228
+ key: 1,
1229
+ type: "goto",
1230
+ title: e(l)("field.open"),
1231
+ onClick: (F) => oe(V)
1232
+ }, null, 8, ["title", "onClick"])),
1233
+ v(e(Le), {
1234
+ title: e(l)("field.remove-title"),
1235
+ description: e(l)("field.remove-text"),
1236
+ "confirm-text": e(l)("field.remove-confirm"),
1237
+ "cancel-text": e(l)("manager.cancel"),
1238
+ "confirm-type": "danger",
1239
+ side: "top",
1240
+ onConfirm: (F) => E(C)
1241
+ }, {
1242
+ trigger: x(() => [
1243
+ v(e(D), {
1244
+ type: "remove",
1245
+ title: e(l)("field.remove-confirm")
1246
+ }, null, 8, ["title"])
1247
+ ]),
1248
+ _: 1
1249
+ }, 8, ["title", "description", "confirm-text", "cancel-text", "onConfirm"])
1250
+ ]),
1251
+ _: 2
1252
+ }, 1024)
1253
+ ]))
1254
+ ], 2)
1255
+ ]),
1256
+ _: 1
1257
+ }, 8, ["modelValue", "disabled", "handle", "drag-label", "empty-text"]),
1258
+ M("div", Ot, [
1259
+ v(e(H), {
1260
+ size: "sm",
1261
+ variant: "outline",
1262
+ disabled: t.disabled || w.value,
1263
+ onClick: ne
1264
+ }, {
1265
+ default: x(() => [
1266
+ N(z(e(l)("field.add")), 1)
1267
+ ]),
1268
+ _: 1
1269
+ }, 8, ["disabled"]),
1270
+ S.value ? (b(), W("span", Et, z(S.value), 1)) : R("", !0)
1271
+ ])
1272
+ ], 6));
1273
+ }
1274
+ }), Pt = /* @__PURE__ */ O({
1275
+ name: "WxFileField",
1276
+ inheritAttrs: !1,
1277
+ __name: "FileField",
1278
+ props: {
1279
+ modelValue: { default: null },
1280
+ modelModifiers: {}
1281
+ },
1282
+ emits: ["update:modelValue"],
1283
+ setup(t) {
1284
+ const i = I(t, "modelValue"), o = U({
1285
+ get: () => i.value ? [i.value] : [],
1286
+ set: (l) => {
1287
+ i.value = l[0] ?? null;
1288
+ }
1289
+ });
1290
+ return (l, c) => (b(), T(xe, pe(l.$attrs, {
1291
+ modelValue: o.value,
1292
+ "onUpdate:modelValue": c[0] || (c[0] = (s) => o.value = s),
1293
+ layout: "rows",
1294
+ single: ""
1295
+ }), null, 16, ["modelValue"]));
1296
+ }
1297
+ }), At = /* @__PURE__ */ O({
1298
+ name: "WxFilesField",
1299
+ inheritAttrs: !1,
1300
+ __name: "FilesField",
1301
+ props: {
1302
+ modelValue: { default: () => [] },
1303
+ modelModifiers: {}
1304
+ },
1305
+ emits: ["update:modelValue"],
1306
+ setup(t) {
1307
+ const i = I(t, "modelValue");
1308
+ return (o, l) => (b(), T(xe, pe(o.$attrs, {
1309
+ modelValue: i.value,
1310
+ "onUpdate:modelValue": l[0] || (l[0] = (c) => i.value = c),
1311
+ layout: "rows"
1312
+ }), null, 16, ["modelValue"]));
1313
+ }
1314
+ }), Nt = /* @__PURE__ */ O({
1315
+ name: "WxGalleryField",
1316
+ inheritAttrs: !1,
1317
+ __name: "GalleryField",
1318
+ props: {
1319
+ modelValue: { default: () => [] },
1320
+ modelModifiers: {}
1321
+ },
1322
+ emits: ["update:modelValue"],
1323
+ setup(t) {
1324
+ const i = I(t, "modelValue");
1325
+ return (o, l) => (b(), T(xe, pe(o.$attrs, {
1326
+ modelValue: i.value,
1327
+ "onUpdate:modelValue": l[0] || (l[0] = (c) => i.value = c),
1328
+ layout: "grid",
1329
+ accept: "image"
1330
+ }), null, 16, ["modelValue"]));
1331
+ }
1332
+ }), qt = { class: "wx-media-field" }, It = {
938
1333
  key: 0,
939
1334
  class: "wx-media-field__label"
940
- }, wt = ["disabled"], xt = ["disabled", "title"], kt = {
1335
+ }, Ht = ["disabled"], Xt = ["disabled", "title"], Kt = {
941
1336
  key: 1,
942
1337
  class: "wx-media-field__missing"
943
- }, $t = {
1338
+ }, jt = {
944
1339
  key: 0,
945
1340
  class: "wx-media-field__bar"
946
- }, _t = { class: "wx-media-field__captions" }, Ct = { class: "wx-media-field__caption" }, Mt = { class: "wx-media-field__caption" }, Tt = { class: "wx-media-field__captions-footer" }, zt = /* @__PURE__ */ S({
1341
+ }, Gt = { class: "wx-media-field__captions" }, Yt = { class: "wx-media-field__caption" }, Jt = { class: "wx-media-field__caption" }, Qt = { class: "wx-media-field__captions-footer" }, Zt = /* @__PURE__ */ O({
947
1342
  __name: "MediaField",
948
- props: /* @__PURE__ */ F({
1343
+ props: /* @__PURE__ */ j({
949
1344
  label: { default: void 0 },
950
1345
  accept: { default: "image" },
951
1346
  captions: { type: Boolean, default: !0 },
@@ -957,119 +1352,119 @@ const ut = {
957
1352
  modelModifiers: {}
958
1353
  }),
959
1354
  emits: ["update:modelValue"],
960
- setup(a) {
961
- const d = a, m = A(a, "modelValue");
962
- xe();
963
- const l = B("webx-media"), v = we(ae()), i = {
1355
+ setup(t) {
1356
+ const i = t, o = I(t, "modelValue");
1357
+ be();
1358
+ const l = X("webx-media"), c = he(fe()), s = {
964
1359
  "16/9": "16 / 9",
965
1360
  "4/3": "4 / 3",
966
1361
  "1/1": "1 / 1"
967
- }, t = M(!1), p = M({});
968
- q(
969
- () => m.value?.path,
970
- async (s) => {
971
- if (!s || m.value?.url || p.value[s]) return;
972
- const x = await v.fileByPath(s);
973
- x && (p.value = { ...p.value, [s]: x.url });
1362
+ }, a = L(!1), n = L({});
1363
+ K(
1364
+ () => o.value?.path,
1365
+ async (d) => {
1366
+ if (!d || o.value?.url || n.value[d]) return;
1367
+ const $ = await c.fileByPath(d);
1368
+ $ && (n.value = { ...n.value, [d]: $.url });
974
1369
  },
975
1370
  { immediate: !0 }
976
1371
  );
977
- const k = D(() => {
978
- const s = m.value;
979
- return s ? s.url ?? p.value[s.path] ?? null : null;
980
- }), g = D(
981
- () => d.aspect ? { aspectRatio: i[d.aspect] ?? d.aspect } : { height: typeof d.height == "number" ? `${d.height}px` : d.height }
1372
+ const k = U(() => {
1373
+ const d = o.value;
1374
+ return d ? d.url ?? n.value[d.path] ?? null : null;
1375
+ }), w = U(
1376
+ () => i.aspect ? { aspectRatio: s[i.aspect] ?? i.aspect } : { height: typeof i.height == "number" ? `${i.height}px` : i.height }
982
1377
  );
983
- function u(s) {
984
- return m.value?.[s] ?? {};
1378
+ function u(d) {
1379
+ return o.value?.[d] ?? {};
985
1380
  }
986
- function n(s, x) {
987
- m.value && (m.value = { ...m.value, [s]: x });
1381
+ function r(d, $) {
1382
+ o.value && (o.value = { ...o.value, [d]: $ });
988
1383
  }
989
- async function f() {
990
- if (d.disabled) return;
991
- const s = await yt({ accept: d.accept });
992
- s && (m.value = { ...m.value, path: s.path, url: s.url });
1384
+ async function g() {
1385
+ if (i.disabled) return;
1386
+ const d = await Mt({ accept: i.accept });
1387
+ d && (o.value = { ...o.value, path: d.path, url: d.url });
993
1388
  }
994
- function c() {
995
- m.value = null, t.value = !1;
1389
+ function f() {
1390
+ o.value = null, a.value = !1;
996
1391
  }
997
- return (s, x) => (b(), W("div", ht, [
998
- a.label ? (b(), W("span", bt, L(a.label), 1)) : U("", !0),
999
- m.value ? (b(), W("div", {
1392
+ return (d, $) => (b(), W("div", qt, [
1393
+ t.label ? (b(), W("span", It, z(t.label), 1)) : R("", !0),
1394
+ o.value ? (b(), W("div", {
1000
1395
  key: 2,
1001
1396
  class: "wx-media-field__frame",
1002
- style: me(g.value)
1397
+ style: ce(w.value)
1003
1398
  }, [
1004
- _("button", {
1399
+ M("button", {
1005
1400
  type: "button",
1006
1401
  class: "wx-media-field__picture",
1007
- disabled: a.disabled,
1402
+ disabled: t.disabled,
1008
1403
  title: e(l)("field.replace"),
1009
- onClick: f
1404
+ onClick: g
1010
1405
  }, [
1011
- k.value ? (b(), $(e(Ze), {
1406
+ k.value ? (b(), T(e(dt), {
1012
1407
  key: 0,
1013
1408
  src: k.value,
1014
1409
  fit: "contain",
1015
1410
  width: "100%",
1016
1411
  height: "100%"
1017
- }, null, 8, ["src"])) : (b(), W("span", kt, L(e(l)("field.no-preview")), 1))
1018
- ], 8, xt),
1019
- a.disabled ? U("", !0) : (b(), W("div", $t, [
1020
- h(e(G), { size: "sm" }, {
1021
- default: w(() => [
1022
- a.captions ? (b(), $(e(et), {
1412
+ }, null, 8, ["src"])) : (b(), W("span", Kt, z(e(l)("field.no-preview")), 1))
1413
+ ], 8, Xt),
1414
+ t.disabled ? R("", !0) : (b(), W("div", jt, [
1415
+ v(e(le), { size: "sm" }, {
1416
+ default: x(() => [
1417
+ t.captions ? (b(), T(e(We), {
1023
1418
  key: 0,
1024
- open: t.value,
1025
- "onUpdate:open": x[3] || (x[3] = (z) => t.value = z),
1419
+ open: a.value,
1420
+ "onUpdate:open": $[3] || ($[3] = (B) => a.value = B),
1026
1421
  title: e(l)("field.captions"),
1027
1422
  width: 360,
1028
1423
  side: "top",
1029
1424
  teleport: ""
1030
1425
  }, {
1031
- trigger: w(() => [
1032
- h(e(T), {
1426
+ trigger: x(() => [
1427
+ v(e(D), {
1033
1428
  type: "edit",
1034
1429
  title: e(l)("field.edit")
1035
1430
  }, null, 8, ["title"])
1036
1431
  ]),
1037
- default: w(() => [
1038
- _("div", _t, [
1039
- _("div", Ct, [
1040
- x[4] || (x[4] = _("label", {
1432
+ default: x(() => [
1433
+ M("div", Gt, [
1434
+ M("div", Yt, [
1435
+ $[4] || ($[4] = M("label", {
1041
1436
  class: "wx-media-field__caption-label",
1042
1437
  for: "wx-media-alt"
1043
1438
  }, "alt", -1)),
1044
- h(e(j), {
1439
+ v(e(Z), {
1045
1440
  id: "wx-media-alt",
1046
1441
  localized: "",
1047
1442
  "model-value": u("alt"),
1048
1443
  placeholder: e(l)("field.alt-hint"),
1049
- "onUpdate:modelValue": x[0] || (x[0] = (z) => n("alt", z))
1444
+ "onUpdate:modelValue": $[0] || ($[0] = (B) => r("alt", B))
1050
1445
  }, null, 8, ["model-value", "placeholder"])
1051
1446
  ]),
1052
- _("div", Mt, [
1053
- x[5] || (x[5] = _("label", {
1447
+ M("div", Jt, [
1448
+ $[5] || ($[5] = M("label", {
1054
1449
  class: "wx-media-field__caption-label",
1055
1450
  for: "wx-media-title"
1056
1451
  }, "title", -1)),
1057
- h(e(j), {
1452
+ v(e(Z), {
1058
1453
  id: "wx-media-title",
1059
1454
  localized: "",
1060
1455
  "model-value": u("title"),
1061
1456
  placeholder: e(l)("field.title-hint"),
1062
- "onUpdate:modelValue": x[1] || (x[1] = (z) => n("title", z))
1457
+ "onUpdate:modelValue": $[1] || ($[1] = (B) => r("title", B))
1063
1458
  }, null, 8, ["model-value", "placeholder"])
1064
1459
  ]),
1065
- _("div", Tt, [
1066
- h(e(I), {
1460
+ M("div", Qt, [
1461
+ v(e(H), {
1067
1462
  size: "sm",
1068
1463
  type: "primary",
1069
- onClick: x[2] || (x[2] = (z) => t.value = !1)
1464
+ onClick: $[2] || ($[2] = (B) => a.value = !1)
1070
1465
  }, {
1071
- default: w(() => [
1072
- P(L(e(l)("manager.save")), 1)
1466
+ default: x(() => [
1467
+ N(z(e(l)("manager.save")), 1)
1073
1468
  ]),
1074
1469
  _: 1
1075
1470
  })
@@ -1077,18 +1472,18 @@ const ut = {
1077
1472
  ])
1078
1473
  ]),
1079
1474
  _: 1
1080
- }, 8, ["open", "title"])) : U("", !0),
1081
- h(e(tt), {
1475
+ }, 8, ["open", "title"])) : R("", !0),
1476
+ v(e(Le), {
1082
1477
  title: e(l)("field.clear-title"),
1083
1478
  description: e(l)("field.clear-text"),
1084
1479
  "confirm-text": e(l)("field.clear-confirm"),
1085
1480
  "cancel-text": e(l)("manager.cancel"),
1086
1481
  "confirm-type": "danger",
1087
1482
  side: "top",
1088
- onConfirm: c
1483
+ onConfirm: f
1089
1484
  }, {
1090
- trigger: w(() => [
1091
- h(e(T), {
1485
+ trigger: x(() => [
1486
+ v(e(D), {
1092
1487
  type: "remove",
1093
1488
  title: e(l)("field.clear-confirm")
1094
1489
  }, null, 8, ["title"])
@@ -1102,59 +1497,68 @@ const ut = {
1102
1497
  ], 4)) : (b(), W("div", {
1103
1498
  key: 1,
1104
1499
  class: "wx-media-field__frame is-empty",
1105
- style: me(g.value)
1500
+ style: ce(w.value)
1106
1501
  }, [
1107
- _("button", {
1502
+ M("button", {
1108
1503
  type: "button",
1109
1504
  class: "wx-media-field__pick",
1110
- disabled: a.disabled,
1111
- onClick: f
1112
- }, L(e(l)("field.select")), 9, wt)
1505
+ disabled: t.disabled,
1506
+ onClick: g
1507
+ }, z(e(l)("field.select")), 9, Ht)
1113
1508
  ], 4))
1114
1509
  ]));
1115
1510
  }
1116
- }), Wt = /* @__PURE__ */ S({
1511
+ }), el = /* @__PURE__ */ O({
1117
1512
  __name: "MediaPage",
1118
- setup(a) {
1119
- return (d, m) => (b(), $(e(at), {
1513
+ setup(t) {
1514
+ return (i, o) => (b(), T(e(ut), {
1120
1515
  class: "wx-media-page",
1121
1516
  padding: "md"
1122
1517
  }, {
1123
- default: w(() => [
1124
- h(ke)
1518
+ default: x(() => [
1519
+ v(De)
1125
1520
  ]),
1126
1521
  _: 1
1127
1522
  }));
1128
1523
  }
1129
1524
  });
1130
- function Vt(a = {}) {
1131
- const d = a.path ?? "/media";
1525
+ function il(t = {}) {
1526
+ const i = t.path ?? "/media";
1132
1527
  return {
1133
1528
  id: "media",
1134
- path: d,
1529
+ path: i,
1135
1530
  routes: [
1136
1531
  {
1137
- path: d,
1532
+ path: i,
1138
1533
  name: "webx.media",
1139
- component: Wt
1534
+ component: el
1140
1535
  }
1141
1536
  ],
1142
- // What a screen means by `wx-media`: the field over the library. The server registers
1143
- // the same name for the value it stores.
1537
+ // What a screen means by these four: the fields over the library. The server registers the
1538
+ // same names for the values it stores. Three of them are one component with a layout and a
1539
+ // limit — the names are what an author picks from a list, and nobody picks "media with
1540
+ // `multiple: true` and `accept: document`".
1144
1541
  types: {
1145
- "wx-media": { component: zt, kind: "field" }
1542
+ "wx-media": { component: Zt, kind: "field" },
1543
+ "wx-gallery": { component: Nt, kind: "field" },
1544
+ "wx-file": { component: Pt, kind: "field" },
1545
+ "wx-files": { component: At, kind: "field" }
1146
1546
  }
1147
1547
  };
1148
1548
  }
1149
1549
  export {
1150
- zt as WxMediaField,
1151
- ke as WxMediaManager,
1152
- Wt as WxMediaPage,
1153
- $e as WxMediaPicker,
1154
- we as createMediaApi,
1155
- Vt as media,
1156
- dt as mediaMessages,
1157
- Rt as openMediaLibrary,
1158
- yt as openMediaPicker
1550
+ Pt as WxFileField,
1551
+ At as WxFilesField,
1552
+ Nt as WxGalleryField,
1553
+ Zt as WxMediaField,
1554
+ De as WxMediaManager,
1555
+ el as WxMediaPage,
1556
+ we as WxMediaPicker,
1557
+ he as createMediaApi,
1558
+ il as media,
1559
+ ht as mediaMessages,
1560
+ Tt as openMediaFiles,
1561
+ zt as openMediaLibrary,
1562
+ Mt as openMediaPicker
1159
1563
  };
1160
1564
  //# sourceMappingURL=index.js.map