@feedmepos/mf-media 0.0.8 → 0.0.10-dev.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/AiStudio-9f9c1203.js +797 -0
- package/dist/AssetLibrary-7609684b.js +269 -0
- package/dist/app.js +395 -409
- package/dist/media-picker-cf281640.js +4297 -0
- package/dist/src/app.d.ts +7 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/AiStudio-40fbac7c.js +0 -792
- package/dist/AssetLibrary-145d5ac2.js +0 -267
- package/dist/media-picker-1af09b4a.js +0 -4106
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { defineComponent as de, computed as C, ref as s, onMounted as ce, watch as M, resolveComponent as k, openBlock as w, createElementBlock as S, createElementVNode as c, toDisplayString as _, unref as t, createVNode as u, createBlock as ve, createCommentVNode as J, withCtx as U } from "vue";
|
|
2
|
+
import { useCoreStore as me, useI18n as fe } from "@feedmepos/mf-common";
|
|
3
|
+
import { useDialog as pe } from "@feedmepos/ui-library";
|
|
4
|
+
import { _ as ge, a as ye, M as be, C as we, T as N, A as _e, x as xe, q as he, v as Be, L as Ce, H as ke, e as K, E as Se } from "./media-picker-cf281640.js";
|
|
5
|
+
const Ve = { class: "p-24 relative min-h-full" }, De = { class: "flex items-center justify-between mb-8" }, Ae = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2" }, Ie = { class: "flex gap-8" }, Te = { class: "flex flex-col gap-12 mb-16" }, ze = { class: "flex items-center gap-12" }, Pe = { class: "flex-1 text-xs text-fm-color-typo-secondary" }, Fe = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "text-fm-color-typo-primary font-semibold"
|
|
8
|
+
}, Re = { key: 1 }, Me = {
|
|
9
|
+
key: 0,
|
|
10
|
+
class: "fixed bottom-24 left-1/2 -translate-x-1/2 flex items-center gap-12 bg-white border rounded-lg shadow-lg px-16 py-8 z-30"
|
|
11
|
+
}, Ue = { class: "text-sm font-semibold" }, Ne = { class: "flex justify-end gap-8 w-full" }, qe = /* @__PURE__ */ de({
|
|
12
|
+
__name: "AssetLibrary",
|
|
13
|
+
setup(Oe) {
|
|
14
|
+
const O = me(), { t: l } = fe(), r = C(() => {
|
|
15
|
+
var e;
|
|
16
|
+
return ((e = O.currentBusiness.value) == null ? void 0 : e.id) ?? "";
|
|
17
|
+
}), E = C(() => {
|
|
18
|
+
var e;
|
|
19
|
+
return (e = O.currentRestaurant.value) == null ? void 0 : e._id;
|
|
20
|
+
}), x = pe(), h = s(""), g = s([]), p = s([]), y = s([]), V = s(!1), v = s(1), D = s(0), A = s(0), I = s(!1), L = s("recent"), Q = {
|
|
21
|
+
recent: { sortBy: "createdAt", descending: !0 },
|
|
22
|
+
name: { sortBy: "fileName", descending: !1 },
|
|
23
|
+
size: { sortBy: "fileSizeBytes", descending: !0 }
|
|
24
|
+
}, $ = [{ icon: "grid_view" }, { icon: "view_list" }], T = s($[0]), W = C(() => T.value.icon === "grid_view" ? "grid" : "list"), z = ge(() => r.value);
|
|
25
|
+
async function m() {
|
|
26
|
+
if (r.value) {
|
|
27
|
+
p.value.length === 0 && (V.value = !0), I.value = !0;
|
|
28
|
+
try {
|
|
29
|
+
const [e, a] = await Promise.all([
|
|
30
|
+
he({
|
|
31
|
+
businessId: r.value,
|
|
32
|
+
restaurantId: E.value,
|
|
33
|
+
search: h.value || void 0,
|
|
34
|
+
tags: g.value.length ? g.value : void 0,
|
|
35
|
+
// AI-composed images are assets from the moment their bytes land — they have to be, or
|
|
36
|
+
// their URL could not render — so the library hides them until "save to the asset
|
|
37
|
+
// centre" removes this tag.
|
|
38
|
+
excludeTags: [Be],
|
|
39
|
+
skip: Ce(v.value, N),
|
|
40
|
+
limit: N,
|
|
41
|
+
...Q[L.value]
|
|
42
|
+
}),
|
|
43
|
+
ke(r.value)
|
|
44
|
+
]);
|
|
45
|
+
p.value = e.resources, D.value = e.meta.totalResources, A.value = e.meta.totalPages, y.value = a, await z.load(e.resources.map((i) => i.refId).filter((i) => !!i));
|
|
46
|
+
} finally {
|
|
47
|
+
V.value = !1, I.value = !1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function P() {
|
|
52
|
+
v.value = 1, B(), await m();
|
|
53
|
+
}
|
|
54
|
+
async function F() {
|
|
55
|
+
await m();
|
|
56
|
+
const e = Se(v.value, A.value);
|
|
57
|
+
e !== v.value && (v.value = e, await m());
|
|
58
|
+
}
|
|
59
|
+
async function X(e) {
|
|
60
|
+
e !== v.value && (v.value = e, B(), await m());
|
|
61
|
+
}
|
|
62
|
+
ce(m), M(r, P), M([g, L], P);
|
|
63
|
+
let j;
|
|
64
|
+
M(h, () => {
|
|
65
|
+
clearTimeout(j), j = setTimeout(P, 250);
|
|
66
|
+
});
|
|
67
|
+
const n = s(/* @__PURE__ */ new Set());
|
|
68
|
+
function Y(e) {
|
|
69
|
+
const a = new Set(n.value);
|
|
70
|
+
a.has(e.id) ? a.delete(e.id) : a.add(e.id), n.value = a;
|
|
71
|
+
}
|
|
72
|
+
function B() {
|
|
73
|
+
n.value = /* @__PURE__ */ new Set();
|
|
74
|
+
}
|
|
75
|
+
function Z() {
|
|
76
|
+
n.value = new Set(p.value.map((e) => e.id));
|
|
77
|
+
}
|
|
78
|
+
function ee() {
|
|
79
|
+
const e = n.value.size;
|
|
80
|
+
x.open({
|
|
81
|
+
title: l("media.library.deleteBulkTitle"),
|
|
82
|
+
message: l("media.library.deleteBulkMessage", { count: e, disclaimer: l("media.library.deleteDisclaimer") }),
|
|
83
|
+
primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
|
|
84
|
+
secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
|
|
85
|
+
}).onPrimary(async () => {
|
|
86
|
+
await Promise.all(
|
|
87
|
+
[...n.value].map((a) => {
|
|
88
|
+
const i = p.value.find((R) => R.id === a);
|
|
89
|
+
return i ? K(r.value, i) : Promise.resolve();
|
|
90
|
+
})
|
|
91
|
+
), B(), await F(), x.close();
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function ae(e) {
|
|
95
|
+
x.open({
|
|
96
|
+
title: l("media.library.deleteOneTitle"),
|
|
97
|
+
message: l("media.library.deleteOneMessage", { fileName: e.fileName, disclaimer: l("media.library.deleteDisclaimer") }),
|
|
98
|
+
primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
|
|
99
|
+
secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
|
|
100
|
+
}).onPrimary(async () => {
|
|
101
|
+
await K(r.value, e);
|
|
102
|
+
const a = new Set(n.value);
|
|
103
|
+
a.delete(e.id), n.value = a, await F(), x.close();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const d = s(null), le = C(
|
|
107
|
+
() => {
|
|
108
|
+
var e;
|
|
109
|
+
return (e = d.value) != null && e.refId ? z.byRefId.value.get(d.value.refId) ?? null : null;
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
function te(e) {
|
|
113
|
+
d.value = e;
|
|
114
|
+
}
|
|
115
|
+
async function q() {
|
|
116
|
+
await m(), d.value && (d.value = p.value.find((e) => {
|
|
117
|
+
var a;
|
|
118
|
+
return e.id === ((a = d.value) == null ? void 0 : a.id);
|
|
119
|
+
}) ?? null);
|
|
120
|
+
}
|
|
121
|
+
async function se() {
|
|
122
|
+
d.value = null, await F();
|
|
123
|
+
}
|
|
124
|
+
const b = s(!1), f = s(null);
|
|
125
|
+
function ne() {
|
|
126
|
+
var e;
|
|
127
|
+
(e = f.value) == null || e.reset(), b.value = !0;
|
|
128
|
+
}
|
|
129
|
+
async function ie() {
|
|
130
|
+
var e;
|
|
131
|
+
(e = f.value) != null && e.stagedCount || (b.value = !1), await m();
|
|
132
|
+
}
|
|
133
|
+
return (e, a) => {
|
|
134
|
+
const i = k("FmButton"), R = k("FmSearch"), oe = k("FmButtonGroup"), ue = k("FmDialog");
|
|
135
|
+
return w(), S("div", Ve, [
|
|
136
|
+
c("div", De, [
|
|
137
|
+
c("h1", Ae, _(t(l)("media.title")), 1),
|
|
138
|
+
c("div", Ie, [
|
|
139
|
+
u(i, {
|
|
140
|
+
label: t(l)("media.library.uploadButton"),
|
|
141
|
+
"prepend-icon": "add",
|
|
142
|
+
variant: "primary",
|
|
143
|
+
onClick: ne
|
|
144
|
+
}, null, 8, ["label"])
|
|
145
|
+
])
|
|
146
|
+
]),
|
|
147
|
+
c("div", Te, [
|
|
148
|
+
u(R, {
|
|
149
|
+
modelValue: h.value,
|
|
150
|
+
"onUpdate:modelValue": a[0] || (a[0] = (o) => h.value = o),
|
|
151
|
+
placeholder: t(l)("media.library.searchPlaceholder"),
|
|
152
|
+
class: "max-w-[280px]"
|
|
153
|
+
}, null, 8, ["modelValue", "placeholder"]),
|
|
154
|
+
y.value.length ? (w(), ve(t(ye), {
|
|
155
|
+
key: 0,
|
|
156
|
+
modelValue: g.value,
|
|
157
|
+
"onUpdate:modelValue": a[1] || (a[1] = (o) => g.value = o),
|
|
158
|
+
tags: y.value
|
|
159
|
+
}, null, 8, ["modelValue", "tags"])) : J("", !0),
|
|
160
|
+
c("div", ze, [
|
|
161
|
+
c("div", Pe, [
|
|
162
|
+
n.value.size > 0 ? (w(), S("span", Fe, _(t(l)("media.library.selectedCount", { count: n.value.size })), 1)) : (w(), S("span", Re, _(t(l)("media.library.totalSummary", { count: D.value })), 1))
|
|
163
|
+
]),
|
|
164
|
+
u(i, {
|
|
165
|
+
label: t(l)("media.library.selectAllButton"),
|
|
166
|
+
variant: "tertiary",
|
|
167
|
+
size: "md",
|
|
168
|
+
onClick: Z
|
|
169
|
+
}, null, 8, ["label"]),
|
|
170
|
+
u(oe, {
|
|
171
|
+
modelValue: T.value,
|
|
172
|
+
"onUpdate:modelValue": a[2] || (a[2] = (o) => T.value = o),
|
|
173
|
+
items: $
|
|
174
|
+
}, null, 8, ["modelValue"])
|
|
175
|
+
])
|
|
176
|
+
]),
|
|
177
|
+
u(t(be), {
|
|
178
|
+
assets: p.value,
|
|
179
|
+
loading: V.value,
|
|
180
|
+
view: W.value,
|
|
181
|
+
selectable: "",
|
|
182
|
+
"selected-ids": n.value,
|
|
183
|
+
"variants-by-ref-id": t(z).byRefId.value,
|
|
184
|
+
onOpen: te,
|
|
185
|
+
onToggle: Y,
|
|
186
|
+
onDelete: ae
|
|
187
|
+
}, null, 8, ["assets", "loading", "view", "selected-ids", "variants-by-ref-id"]),
|
|
188
|
+
u(t(we), {
|
|
189
|
+
page: v.value,
|
|
190
|
+
"page-size": t(N),
|
|
191
|
+
"total-resources": D.value,
|
|
192
|
+
"total-pages": A.value,
|
|
193
|
+
disabled: I.value,
|
|
194
|
+
"onUpdate:page": X
|
|
195
|
+
}, null, 8, ["page", "page-size", "total-resources", "total-pages", "disabled"]),
|
|
196
|
+
n.value.size > 0 ? (w(), S("div", Me, [
|
|
197
|
+
c("span", Ue, _(t(l)("media.library.selectedCount", { count: n.value.size })), 1),
|
|
198
|
+
u(i, {
|
|
199
|
+
label: t(l)("media.library.cancelButton"),
|
|
200
|
+
variant: "tertiary",
|
|
201
|
+
size: "md",
|
|
202
|
+
onClick: B
|
|
203
|
+
}, null, 8, ["label"]),
|
|
204
|
+
u(i, {
|
|
205
|
+
label: t(l)("media.library.deleteSelectedButton"),
|
|
206
|
+
variant: "destructive",
|
|
207
|
+
size: "md",
|
|
208
|
+
"prepend-icon": "delete",
|
|
209
|
+
onClick: ee
|
|
210
|
+
}, null, 8, ["label"])
|
|
211
|
+
])) : J("", !0),
|
|
212
|
+
u(t(_e), {
|
|
213
|
+
asset: d.value,
|
|
214
|
+
image: le.value,
|
|
215
|
+
"business-id": r.value,
|
|
216
|
+
onClose: a[3] || (a[3] = (o) => d.value = null),
|
|
217
|
+
onRenamed: q,
|
|
218
|
+
onDeleted: se,
|
|
219
|
+
onChanged: q
|
|
220
|
+
}, null, 8, ["asset", "image", "business-id"]),
|
|
221
|
+
u(ue, {
|
|
222
|
+
modelValue: b.value,
|
|
223
|
+
"onUpdate:modelValue": a[7] || (a[7] = (o) => b.value = o),
|
|
224
|
+
"max-width": 480
|
|
225
|
+
}, {
|
|
226
|
+
"dialog-header": U(() => [
|
|
227
|
+
c("div", null, _(t(l)("media.library.uploadDialogTitle")), 1)
|
|
228
|
+
]),
|
|
229
|
+
"dialog-footer": U(() => {
|
|
230
|
+
var o, G;
|
|
231
|
+
return [
|
|
232
|
+
c("div", Ne, [
|
|
233
|
+
u(i, {
|
|
234
|
+
label: t(l)("media.library.cancelButton"),
|
|
235
|
+
variant: "tertiary",
|
|
236
|
+
onClick: a[5] || (a[5] = (re) => b.value = !1)
|
|
237
|
+
}, null, 8, ["label"]),
|
|
238
|
+
u(i, {
|
|
239
|
+
label: t(l)("media.library.uploadSubmitButton", { count: ((o = f.value) == null ? void 0 : o.stagedCount) ?? 0 }),
|
|
240
|
+
variant: "primary",
|
|
241
|
+
disabled: !((G = f.value) != null && G.stagedCount) || f.value.uploading,
|
|
242
|
+
onClick: a[6] || (a[6] = (re) => {
|
|
243
|
+
var H;
|
|
244
|
+
return (H = f.value) == null ? void 0 : H.upload();
|
|
245
|
+
})
|
|
246
|
+
}, null, 8, ["label", "disabled"])
|
|
247
|
+
])
|
|
248
|
+
];
|
|
249
|
+
}),
|
|
250
|
+
default: U(() => [
|
|
251
|
+
u(t(xe), {
|
|
252
|
+
ref_key: "uploadPanelRef",
|
|
253
|
+
ref: f,
|
|
254
|
+
"business-id": r.value,
|
|
255
|
+
"restaurant-id": E.value,
|
|
256
|
+
"available-tags": y.value,
|
|
257
|
+
onTagCreated: a[4] || (a[4] = (o) => y.value.push(o)),
|
|
258
|
+
onUploaded: ie
|
|
259
|
+
}, null, 8, ["business-id", "restaurant-id", "available-tags"])
|
|
260
|
+
]),
|
|
261
|
+
_: 1
|
|
262
|
+
}, 8, ["modelValue"])
|
|
263
|
+
]);
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
export {
|
|
268
|
+
qe as default
|
|
269
|
+
};
|