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