@feedmepos/mf-media 0.0.8 → 0.0.9

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.
@@ -2,7 +2,7 @@ import { defineComponent as j, computed as S, resolveComponent as B, openBlock a
2
2
  import { defineStore as re, storeToRefs as de } from "pinia";
3
3
  import { useI18n as N, useCoreStore as ce } from "@feedmepos/mf-common";
4
4
  import { useDialog as ue, useSnackbar as me } from "@feedmepos/ui-library";
5
- import { z as W, p as fe, G as pe, K as ve } from "./media-picker-1af09b4a.js";
5
+ import { z as W, x as fe, G as pe, K as ve } from "./media-picker-e86c4195.js";
6
6
  const xe = { class: "rounded-xl border border-fm-color-neutral-gray-200 bg-white overflow-hidden" }, ge = ["src", "alt"], ye = {
7
7
  key: 1,
8
8
  class: "absolute inset-0 flex flex-col items-center justify-center gap-4 p-12 text-center"
@@ -0,0 +1,285 @@
1
+ import { defineComponent as ve, computed as C, ref as i, onMounted as me, watch as M, resolveComponent as h, openBlock as w, createElementBlock as S, createElementVNode as c, toDisplayString as x, unref as t, createVNode as s, createBlock as fe, createCommentVNode as J, withCtx as N } from "vue";
2
+ import { useCoreStore as pe, useI18n as ge } from "@feedmepos/mf-common";
3
+ import { useDialog as be } from "@feedmepos/ui-library";
4
+ import { k as ye, a as we, $ as xe, b as _e, v as $, P as ke, x as Be, c as Ce, V as he, d as Se, O as Pe, q as Ve, Q as K, _ as De } from "./media-picker-e86c4195.js";
5
+ const Ie = { class: "p-24 relative min-h-full" }, ze = { class: "flex items-center justify-between mb-16" }, Ae = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2" }, Te = { class: "flex gap-8" }, Fe = { class: "flex flex-col gap-12 mb-16" }, Re = { class: "flex items-center gap-12" }, Oe = { class: "flex-1 text-xs text-fm-color-typo-secondary" }, Ue = {
6
+ key: 0,
7
+ class: "text-fm-color-typo-primary font-semibold"
8
+ }, Me = { key: 1 }, Ne = {
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
+ }, $e = { class: "text-sm font-semibold" }, je = { class: "flex justify-end gap-8 w-full" }, He = /* @__PURE__ */ ve({
12
+ __name: "AssetLibrary",
13
+ setup(qe) {
14
+ const j = pe(), { t: l } = ge(), r = C(() => {
15
+ var e;
16
+ return ((e = j.currentBusiness.value) == null ? void 0 : e.id) ?? "";
17
+ }), P = C(() => {
18
+ var e;
19
+ return (e = j.currentRestaurant.value) == null ? void 0 : e._id;
20
+ }), _ = be(), V = i(!1);
21
+ function W(e) {
22
+ console.log("[media-debug] MediaPickerModal selected", e.ratio ?? "original", e.url), m();
23
+ }
24
+ const k = i(""), g = i([]), p = i([]), b = i([]), D = i(!1), v = i(1), I = i(0), z = i(0), A = i(!1), q = i("recent"), X = {
25
+ recent: { sortBy: "createdAt", descending: !0 },
26
+ name: { sortBy: "fileName", descending: !1 },
27
+ size: { sortBy: "fileSizeBytes", descending: !0 }
28
+ }, E = [{ icon: "grid_view" }, { icon: "view_list" }], T = i(E[0]), Y = C(() => T.value.icon === "grid_view" ? "grid" : "list"), F = ye(() => r.value);
29
+ async function m() {
30
+ if (r.value) {
31
+ p.value.length === 0 && (D.value = !0), A.value = !0;
32
+ try {
33
+ const [e, a] = await Promise.all([
34
+ he({
35
+ businessId: r.value,
36
+ restaurantId: P.value,
37
+ search: k.value || void 0,
38
+ tags: g.value.length ? g.value : void 0,
39
+ // AI-composed images are assets from the moment their bytes land — they have to be, or
40
+ // their URL could not render — so the library hides them until "save to the asset
41
+ // centre" removes this tag.
42
+ excludeTags: [Se],
43
+ skip: Pe(v.value, $),
44
+ limit: $,
45
+ ...X[q.value]
46
+ }),
47
+ Ve(r.value)
48
+ ]);
49
+ p.value = e.resources, I.value = e.meta.totalResources, z.value = e.meta.totalPages, b.value = a, await F.load(e.resources.map((o) => o.refId).filter((o) => !!o));
50
+ } finally {
51
+ D.value = !1, A.value = !1;
52
+ }
53
+ }
54
+ }
55
+ async function R() {
56
+ v.value = 1, B(), await m();
57
+ }
58
+ async function O() {
59
+ await m();
60
+ const e = De(v.value, z.value);
61
+ e !== v.value && (v.value = e, await m());
62
+ }
63
+ async function Z(e) {
64
+ e !== v.value && (v.value = e, B(), await m());
65
+ }
66
+ me(m), M(r, R), M([g, q], R);
67
+ let G;
68
+ M(k, () => {
69
+ clearTimeout(G), G = setTimeout(R, 250);
70
+ });
71
+ const u = i(/* @__PURE__ */ new Set());
72
+ function ee(e) {
73
+ const a = new Set(u.value);
74
+ a.has(e.id) ? a.delete(e.id) : a.add(e.id), u.value = a;
75
+ }
76
+ function B() {
77
+ u.value = /* @__PURE__ */ new Set();
78
+ }
79
+ function ae() {
80
+ u.value = new Set(p.value.map((e) => e.id));
81
+ }
82
+ function le() {
83
+ const e = u.value.size;
84
+ _.open({
85
+ title: l("media.library.deleteBulkTitle"),
86
+ message: l("media.library.deleteBulkMessage", { count: e, disclaimer: l("media.library.deleteDisclaimer") }),
87
+ primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
88
+ secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
89
+ }).onPrimary(async () => {
90
+ await Promise.all(
91
+ [...u.value].map((a) => {
92
+ const o = p.value.find((U) => U.id === a);
93
+ return o ? K(r.value, o) : Promise.resolve();
94
+ })
95
+ ), B(), await O(), _.close();
96
+ });
97
+ }
98
+ function te(e) {
99
+ _.open({
100
+ title: l("media.library.deleteOneTitle"),
101
+ message: l("media.library.deleteOneMessage", { fileName: e.fileName, disclaimer: l("media.library.deleteDisclaimer") }),
102
+ primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
103
+ secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
104
+ }).onPrimary(async () => {
105
+ await K(r.value, e);
106
+ const a = new Set(u.value);
107
+ a.delete(e.id), u.value = a, await O(), _.close();
108
+ });
109
+ }
110
+ const d = i(null), ne = C(
111
+ () => {
112
+ var e;
113
+ return (e = d.value) != null && e.refId ? F.byRefId.value.get(d.value.refId) ?? null : null;
114
+ }
115
+ );
116
+ function ie(e) {
117
+ d.value = e;
118
+ }
119
+ async function Q() {
120
+ await m(), d.value && (d.value = p.value.find((e) => {
121
+ var a;
122
+ return e.id === ((a = d.value) == null ? void 0 : a.id);
123
+ }) ?? null);
124
+ }
125
+ async function se() {
126
+ d.value = null, await O();
127
+ }
128
+ const y = i(!1), f = i(null);
129
+ function oe() {
130
+ var e;
131
+ (e = f.value) == null || e.reset(), y.value = !0;
132
+ }
133
+ async function ue() {
134
+ var e;
135
+ (e = f.value) != null && e.stagedCount || (y.value = !1), await m();
136
+ }
137
+ return (e, a) => {
138
+ const o = h("FmButton"), U = h("FmSearch"), re = h("FmButtonGroup"), de = h("FmDialog");
139
+ return w(), S("div", Ie, [
140
+ c("div", ze, [
141
+ c("h1", Ae, x(t(l)("media.title")), 1),
142
+ c("div", Te, [
143
+ s(o, {
144
+ label: t(l)("media.library.testPickerButton"),
145
+ variant: "tertiary",
146
+ onClick: a[0] || (a[0] = (n) => V.value = !0)
147
+ }, null, 8, ["label"]),
148
+ s(o, {
149
+ label: t(l)("media.library.uploadButton"),
150
+ "prepend-icon": "add",
151
+ variant: "primary",
152
+ onClick: oe
153
+ }, null, 8, ["label"])
154
+ ])
155
+ ]),
156
+ c("div", Fe, [
157
+ s(U, {
158
+ modelValue: k.value,
159
+ "onUpdate:modelValue": a[1] || (a[1] = (n) => k.value = n),
160
+ placeholder: t(l)("media.library.searchPlaceholder"),
161
+ class: "max-w-[280px]"
162
+ }, null, 8, ["modelValue", "placeholder"]),
163
+ b.value.length ? (w(), fe(t(we), {
164
+ key: 0,
165
+ modelValue: g.value,
166
+ "onUpdate:modelValue": a[2] || (a[2] = (n) => g.value = n),
167
+ tags: b.value
168
+ }, null, 8, ["modelValue", "tags"])) : J("", !0),
169
+ c("div", Re, [
170
+ c("div", Oe, [
171
+ u.value.size > 0 ? (w(), S("span", Ue, x(t(l)("media.library.selectedCount", { count: u.value.size })), 1)) : (w(), S("span", Me, x(t(l)("media.library.totalSummary", { count: I.value })), 1))
172
+ ]),
173
+ s(o, {
174
+ label: t(l)("media.library.selectAllButton"),
175
+ variant: "tertiary",
176
+ size: "md",
177
+ onClick: ae
178
+ }, null, 8, ["label"]),
179
+ s(re, {
180
+ modelValue: T.value,
181
+ "onUpdate:modelValue": a[3] || (a[3] = (n) => T.value = n),
182
+ items: E
183
+ }, null, 8, ["modelValue"])
184
+ ])
185
+ ]),
186
+ s(t(xe), {
187
+ assets: p.value,
188
+ loading: D.value,
189
+ view: Y.value,
190
+ selectable: "",
191
+ "selected-ids": u.value,
192
+ "variants-by-ref-id": t(F).byRefId.value,
193
+ onOpen: ie,
194
+ onToggle: ee,
195
+ onDelete: te
196
+ }, null, 8, ["assets", "loading", "view", "selected-ids", "variants-by-ref-id"]),
197
+ s(t(_e), {
198
+ page: v.value,
199
+ "page-size": t($),
200
+ "total-resources": I.value,
201
+ "total-pages": z.value,
202
+ disabled: A.value,
203
+ "onUpdate:page": Z
204
+ }, null, 8, ["page", "page-size", "total-resources", "total-pages", "disabled"]),
205
+ u.value.size > 0 ? (w(), S("div", Ne, [
206
+ c("span", $e, x(t(l)("media.library.selectedCount", { count: u.value.size })), 1),
207
+ s(o, {
208
+ label: t(l)("media.library.cancelButton"),
209
+ variant: "tertiary",
210
+ size: "md",
211
+ onClick: B
212
+ }, null, 8, ["label"]),
213
+ s(o, {
214
+ label: t(l)("media.library.deleteSelectedButton"),
215
+ variant: "destructive",
216
+ size: "md",
217
+ "prepend-icon": "delete",
218
+ onClick: le
219
+ }, null, 8, ["label"])
220
+ ])) : J("", !0),
221
+ s(t(ke), {
222
+ asset: d.value,
223
+ image: ne.value,
224
+ "business-id": r.value,
225
+ onClose: a[4] || (a[4] = (n) => d.value = null),
226
+ onRenamed: Q,
227
+ onDeleted: se,
228
+ onChanged: Q
229
+ }, null, 8, ["asset", "image", "business-id"]),
230
+ s(t(Be), {
231
+ open: V.value,
232
+ "onUpdate:open": a[5] || (a[5] = (n) => V.value = n),
233
+ "business-id": r.value,
234
+ "restaurant-id": P.value,
235
+ onSelect: W
236
+ }, null, 8, ["open", "business-id", "restaurant-id"]),
237
+ s(de, {
238
+ modelValue: y.value,
239
+ "onUpdate:modelValue": a[9] || (a[9] = (n) => y.value = n),
240
+ "max-width": 480
241
+ }, {
242
+ "dialog-header": N(() => [
243
+ c("div", null, x(t(l)("media.library.uploadDialogTitle")), 1)
244
+ ]),
245
+ "dialog-footer": N(() => {
246
+ var n, L;
247
+ return [
248
+ c("div", je, [
249
+ s(o, {
250
+ label: t(l)("media.library.cancelButton"),
251
+ variant: "tertiary",
252
+ onClick: a[7] || (a[7] = (ce) => y.value = !1)
253
+ }, null, 8, ["label"]),
254
+ s(o, {
255
+ label: t(l)("media.library.uploadSubmitButton", { count: ((n = f.value) == null ? void 0 : n.stagedCount) ?? 0 }),
256
+ variant: "primary",
257
+ disabled: !((L = f.value) != null && L.stagedCount) || f.value.uploading,
258
+ onClick: a[8] || (a[8] = (ce) => {
259
+ var H;
260
+ return (H = f.value) == null ? void 0 : H.upload();
261
+ })
262
+ }, null, 8, ["label", "disabled"])
263
+ ])
264
+ ];
265
+ }),
266
+ default: N(() => [
267
+ s(t(Ce), {
268
+ ref_key: "uploadPanelRef",
269
+ ref: f,
270
+ "business-id": r.value,
271
+ "restaurant-id": P.value,
272
+ "available-tags": b.value,
273
+ onTagCreated: a[6] || (a[6] = (n) => b.value.push(n)),
274
+ onUploaded: ue
275
+ }, null, 8, ["business-id", "restaurant-id", "available-tags"])
276
+ ]),
277
+ _: 1
278
+ }, 8, ["modelValue"])
279
+ ]);
280
+ };
281
+ }
282
+ });
283
+ export {
284
+ He as default
285
+ };
package/dist/app.js CHANGED
@@ -94,7 +94,7 @@ const tt = {
94
94
  searchPlaceholder: "Search file name…",
95
95
  selectAllButton: "Select All",
96
96
  selectedCount: "{count} selected",
97
- totalSummary: "{count} items · {size} used",
97
+ totalSummary: "{count} items",
98
98
  cancelButton: "Cancel",
99
99
  deleteSelectedButton: "Delete Selected",
100
100
  uploadDialogTitle: "Upload Assets",
@@ -201,7 +201,7 @@ const tt = {
201
201
  searchPlaceholder: "Rechercher un nom de fichier…",
202
202
  selectAllButton: "Tout sélectionner",
203
203
  selectedCount: "{count} sélectionné(s)",
204
- totalSummary: "{count} éléments · {size} utilisés",
204
+ totalSummary: "{count} éléments",
205
205
  cancelButton: "Annuler",
206
206
  deleteSelectedButton: "Supprimer la sélection",
207
207
  uploadDialogTitle: "Importer un média",
@@ -308,7 +308,7 @@ const tt = {
308
308
  searchPlaceholder: "Cari nama file…",
309
309
  selectAllButton: "Pilih Semua",
310
310
  selectedCount: "{count} item dipilih",
311
- totalSummary: "{count} item · {size} terpakai",
311
+ totalSummary: "{count} item",
312
312
  cancelButton: "Batal",
313
313
  deleteSelectedButton: "Hapus yang Dipilih",
314
314
  uploadDialogTitle: "Unggah Media",
@@ -415,7 +415,7 @@ const tt = {
415
415
  searchPlaceholder: "ファイル名で検索…",
416
416
  selectAllButton: "すべて選択",
417
417
  selectedCount: "{count} 件選択中",
418
- totalSummary: "合計 {count} 件 · 使用容量 {size}",
418
+ totalSummary: "合計 {count} 件",
419
419
  cancelButton: "キャンセル",
420
420
  deleteSelectedButton: "選択した項目を削除",
421
421
  uploadDialogTitle: "素材をアップロード",
@@ -522,7 +522,7 @@ const tt = {
522
522
  searchPlaceholder: "ค้นหาชื่อไฟล์…",
523
523
  selectAllButton: "เลือกทั้งหมด",
524
524
  selectedCount: "เลือกแล้ว {count} รายการ",
525
- totalSummary: "ทั้งหมด {count} รายการ · ใช้ไป {size}",
525
+ totalSummary: "ทั้งหมด {count} รายการ",
526
526
  cancelButton: "ยกเลิก",
527
527
  deleteSelectedButton: "ลบที่เลือก",
528
528
  uploadDialogTitle: "อัปโหลดสื่อ",
@@ -629,7 +629,7 @@ const tt = {
629
629
  searchPlaceholder: "搜索文件名…",
630
630
  selectAllButton: "全选",
631
631
  selectedCount: "已选 {count} 项",
632
- totalSummary: "共 {count} 项 · 已用 {size}",
632
+ totalSummary: "共 {count} 项",
633
633
  cancelButton: "取消",
634
634
  deleteSelectedButton: "删除所选",
635
635
  uploadDialogTitle: "上传素材",
@@ -736,7 +736,7 @@ const tt = {
736
736
  searchPlaceholder: "搜尋檔案名稱…",
737
737
  selectAllButton: "全選",
738
738
  selectedCount: "已選 {count} 項",
739
- totalSummary: "共 {count} 項 · 已用 {size}",
739
+ totalSummary: "共 {count} 項",
740
740
  cancelButton: "取消",
741
741
  deleteSelectedButton: "刪除所選",
742
742
  uploadDialogTitle: "上傳素材",
@@ -2524,7 +2524,7 @@ const Ka = [
2524
2524
  {
2525
2525
  path: "/library",
2526
2526
  name: "$media-library",
2527
- component: ne(_(() => import("./AssetLibrary-145d5ac2.js"))),
2527
+ component: ne(_(() => import("./AssetLibrary-4c2864d0.js"))),
2528
2528
  meta: {
2529
2529
  validationManifest: {
2530
2530
  requiredCaslPermissions: [
@@ -2539,7 +2539,7 @@ const Ka = [
2539
2539
  {
2540
2540
  path: "/studio",
2541
2541
  name: "$media-studio",
2542
- component: ne(_(() => import("./AiStudio-40fbac7c.js"))),
2542
+ component: ne(_(() => import("./AiStudio-a4b7098a.js"))),
2543
2543
  meta: {
2544
2544
  validationManifest: {
2545
2545
  requiredCaslPermissions: [