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