@feedmepos/mf-media 1.0.1-dev.4 → 1.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/src/app.d.ts CHANGED
@@ -95,6 +95,8 @@ export declare const i18nMessages: {
95
95
  uploadButton: string;
96
96
  testPickerButton: string;
97
97
  searchPlaceholder: string;
98
+ allRestaurantsOption: string;
99
+ allRefTypesOption: string;
98
100
  selectAllButton: string;
99
101
  selectedCount: string;
100
102
  totalSummary: string;
@@ -204,6 +206,8 @@ export declare const i18nMessages: {
204
206
  uploadButton: string;
205
207
  testPickerButton: string;
206
208
  searchPlaceholder: string;
209
+ allRestaurantsOption: string;
210
+ allRefTypesOption: string;
207
211
  selectAllButton: string;
208
212
  selectedCount: string;
209
213
  totalSummary: string;
@@ -313,6 +317,8 @@ export declare const i18nMessages: {
313
317
  uploadButton: string;
314
318
  testPickerButton: string;
315
319
  searchPlaceholder: string;
320
+ allRestaurantsOption: string;
321
+ allRefTypesOption: string;
316
322
  selectAllButton: string;
317
323
  selectedCount: string;
318
324
  totalSummary: string;
@@ -422,6 +428,8 @@ export declare const i18nMessages: {
422
428
  uploadButton: string;
423
429
  testPickerButton: string;
424
430
  searchPlaceholder: string;
431
+ allRestaurantsOption: string;
432
+ allRefTypesOption: string;
425
433
  selectAllButton: string;
426
434
  selectedCount: string;
427
435
  totalSummary: string;
@@ -531,6 +539,8 @@ export declare const i18nMessages: {
531
539
  uploadButton: string;
532
540
  testPickerButton: string;
533
541
  searchPlaceholder: string;
542
+ allRestaurantsOption: string;
543
+ allRefTypesOption: string;
534
544
  selectAllButton: string;
535
545
  selectedCount: string;
536
546
  totalSummary: string;
@@ -640,6 +650,8 @@ export declare const i18nMessages: {
640
650
  uploadButton: string;
641
651
  testPickerButton: string;
642
652
  searchPlaceholder: string;
653
+ allRestaurantsOption: string;
654
+ allRefTypesOption: string;
643
655
  selectAllButton: string;
644
656
  selectedCount: string;
645
657
  totalSummary: string;
@@ -749,6 +761,8 @@ export declare const i18nMessages: {
749
761
  uploadButton: string;
750
762
  testPickerButton: string;
751
763
  searchPlaceholder: string;
764
+ allRestaurantsOption: string;
765
+ allRefTypesOption: string;
752
766
  selectAllButton: string;
753
767
  selectedCount: string;
754
768
  totalSummary: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feedmepos/mf-media",
3
- "version": "1.0.1-dev.4",
3
+ "version": "1.0.2-dev.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -21,7 +21,7 @@
21
21
  "vue": "^3.5.16",
22
22
  "vue-i18n": "10.0.5",
23
23
  "vue-router": "^4.2.5",
24
- "@feedmepos/media-picker": "^1.0.2"
24
+ "@feedmepos/media-picker": "^2.0.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@rushstack/eslint-patch": "^1.3.3",
@@ -1,271 +0,0 @@
1
- import { defineComponent as de, computed as C, ref as n, onMounted as ce, watch as U, 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 N } 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 { o as ge, I as ye, g as be, f as we, c as O, m as _e, e as xe, d as he, U as Be, h as Ce, a as ke, E as Se, T as K, b as Ie } from "./media-picker-fdce9066.js";
5
- const Ve = { class: "p-24 relative min-h-full" }, De = { class: "flex items-center justify-between mb-8" }, Te = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2" }, ze = { class: "flex gap-8" }, Pe = { class: "flex flex-col gap-12 mb-16" }, Ae = { class: "flex items-center gap-12" }, Fe = { class: "flex-1 text-xs text-fm-color-typo-secondary" }, Re = {
6
- key: 0,
7
- class: "text-fm-color-typo-primary font-semibold"
8
- }, Ue = { 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
- }, Oe = { class: "text-sm font-semibold" }, Me = { class: "flex justify-end gap-8 w-full" }, qe = /* @__PURE__ */ de({
12
- __name: "AssetLibrary",
13
- setup(Ee) {
14
- const M = me(), { t: l } = fe(), r = C(() => {
15
- var e;
16
- return ((e = M.currentBusiness.value) == null ? void 0 : e.id) ?? "";
17
- }), E = C(() => {
18
- var e;
19
- return (e = M.currentRestaurant.value) == null ? void 0 : e._id;
20
- }), x = pe(), h = n(""), g = n([]), p = n([]), y = n([]), I = n(!1), v = n(1), V = n(0), D = n(0), T = n(!1), $ = n("recent"), Q = {
21
- recent: { sortBy: "createdAt", descending: !0 },
22
- name: { sortBy: "fileName", descending: !1 },
23
- size: { sortBy: "fileSizeBytes", descending: !0 }
24
- }, j = [{ icon: "grid_view" }, { icon: "view_list" }], z = n(j[0]), W = C(() => z.value.icon === "grid_view" ? "grid" : "list"), P = ge(() => r.value);
25
- async function m() {
26
- if (r.value) {
27
- p.value.length === 0 && (I.value = !0), T.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, O),
40
- limit: O,
41
- ...Q[$.value]
42
- }),
43
- ke(r.value)
44
- ]);
45
- p.value = e.resources, V.value = e.meta.totalResources, D.value = e.meta.totalPages, y.value = a, await P.load(
46
- e.resources.filter((s) => !Se(s)).map((s) => s.refId).filter((s) => !!s)
47
- );
48
- } finally {
49
- I.value = !1, T.value = !1;
50
- }
51
- }
52
- }
53
- async function A() {
54
- v.value = 1, B(), await m();
55
- }
56
- async function F() {
57
- await m();
58
- const e = Ie(v.value, D.value);
59
- e !== v.value && (v.value = e, await m());
60
- }
61
- async function X(e) {
62
- e !== v.value && (v.value = e, B(), await m());
63
- }
64
- ce(m), U(r, A), U([g, $], A);
65
- let G;
66
- U(h, () => {
67
- clearTimeout(G), G = setTimeout(A, 250);
68
- });
69
- const i = n(/* @__PURE__ */ new Set());
70
- function Y(e) {
71
- const a = new Set(i.value);
72
- a.has(e.id) ? a.delete(e.id) : a.add(e.id), i.value = a;
73
- }
74
- function B() {
75
- i.value = /* @__PURE__ */ new Set();
76
- }
77
- function Z() {
78
- i.value = new Set(p.value.map((e) => e.id));
79
- }
80
- function ee() {
81
- const e = i.value.size;
82
- x.open({
83
- title: l("media.library.deleteBulkTitle"),
84
- message: l("media.library.deleteBulkMessage", { count: e, disclaimer: l("media.library.deleteDisclaimer") }),
85
- primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
86
- secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
87
- }).onPrimary(async () => {
88
- await Promise.all(
89
- [...i.value].map((a) => {
90
- const s = p.value.find((R) => R.id === a);
91
- return s ? K(r.value, s) : Promise.resolve();
92
- })
93
- ), B(), await F(), x.close();
94
- });
95
- }
96
- function ae(e) {
97
- x.open({
98
- title: l("media.library.deleteOneTitle"),
99
- message: l("media.library.deleteOneMessage", { fileName: e.fileName, disclaimer: l("media.library.deleteDisclaimer") }),
100
- primaryActions: { text: l("media.library.deleteConfirmButton"), close: !1, variant: "destructive" },
101
- secondaryActions: { text: l("media.library.cancelButton"), close: !0 }
102
- }).onPrimary(async () => {
103
- await K(r.value, e);
104
- const a = new Set(i.value);
105
- a.delete(e.id), i.value = a, await F(), x.close();
106
- });
107
- }
108
- const d = n(null), le = C(
109
- () => {
110
- var e;
111
- return (e = d.value) != null && e.refId ? P.byRefId.value.get(d.value.refId) ?? null : null;
112
- }
113
- );
114
- function te(e) {
115
- d.value = e;
116
- }
117
- async function L() {
118
- await m(), d.value && (d.value = p.value.find((e) => {
119
- var a;
120
- return e.id === ((a = d.value) == null ? void 0 : a.id);
121
- }) ?? null);
122
- }
123
- async function se() {
124
- d.value = null, await F();
125
- }
126
- const b = n(!1), f = n(null);
127
- function ne() {
128
- var e;
129
- (e = f.value) == null || e.reset(), b.value = !0;
130
- }
131
- async function ie() {
132
- var e;
133
- (e = f.value) != null && e.stagedCount || (b.value = !1), await m();
134
- }
135
- return (e, a) => {
136
- const s = k("FmButton"), R = k("FmSearch"), oe = k("FmButtonGroup"), ue = k("FmDialog");
137
- return w(), S("div", Ve, [
138
- c("div", De, [
139
- c("h1", Te, _(t(l)("media.title")), 1),
140
- c("div", ze, [
141
- u(s, {
142
- label: t(l)("media.library.uploadButton"),
143
- "prepend-icon": "add",
144
- variant: "primary",
145
- onClick: ne
146
- }, null, 8, ["label"])
147
- ])
148
- ]),
149
- c("div", Pe, [
150
- u(R, {
151
- modelValue: h.value,
152
- "onUpdate:modelValue": a[0] || (a[0] = (o) => h.value = o),
153
- placeholder: t(l)("media.library.searchPlaceholder"),
154
- class: "max-w-[280px]"
155
- }, null, 8, ["modelValue", "placeholder"]),
156
- y.value.length ? (w(), ve(t(ye), {
157
- key: 0,
158
- modelValue: g.value,
159
- "onUpdate:modelValue": a[1] || (a[1] = (o) => g.value = o),
160
- tags: y.value
161
- }, null, 8, ["modelValue", "tags"])) : J("", !0),
162
- c("div", Ae, [
163
- c("div", Fe, [
164
- i.value.size > 0 ? (w(), S("span", Re, _(t(l)("media.library.selectedCount", { count: i.value.size })), 1)) : (w(), S("span", Ue, _(t(l)("media.library.totalSummary", { count: V.value })), 1))
165
- ]),
166
- u(s, {
167
- label: t(l)("media.library.selectAllButton"),
168
- variant: "tertiary",
169
- size: "md",
170
- onClick: Z
171
- }, null, 8, ["label"]),
172
- u(oe, {
173
- modelValue: z.value,
174
- "onUpdate:modelValue": a[2] || (a[2] = (o) => z.value = o),
175
- items: j
176
- }, null, 8, ["modelValue"])
177
- ])
178
- ]),
179
- u(t(be), {
180
- assets: p.value,
181
- loading: I.value,
182
- view: W.value,
183
- selectable: "",
184
- "selected-ids": i.value,
185
- "variants-by-ref-id": t(P).byRefId.value,
186
- onOpen: te,
187
- onToggle: Y,
188
- onDelete: ae
189
- }, null, 8, ["assets", "loading", "view", "selected-ids", "variants-by-ref-id"]),
190
- u(t(we), {
191
- page: v.value,
192
- "page-size": t(O),
193
- "total-resources": V.value,
194
- "total-pages": D.value,
195
- disabled: T.value,
196
- "onUpdate:page": X
197
- }, null, 8, ["page", "page-size", "total-resources", "total-pages", "disabled"]),
198
- i.value.size > 0 ? (w(), S("div", Ne, [
199
- c("span", Oe, _(t(l)("media.library.selectedCount", { count: i.value.size })), 1),
200
- u(s, {
201
- label: t(l)("media.library.cancelButton"),
202
- variant: "tertiary",
203
- size: "md",
204
- onClick: B
205
- }, null, 8, ["label"]),
206
- u(s, {
207
- label: t(l)("media.library.deleteSelectedButton"),
208
- variant: "destructive",
209
- size: "md",
210
- "prepend-icon": "delete",
211
- onClick: ee
212
- }, null, 8, ["label"])
213
- ])) : J("", !0),
214
- u(t(_e), {
215
- asset: d.value,
216
- image: le.value,
217
- "business-id": r.value,
218
- onClose: a[3] || (a[3] = (o) => d.value = null),
219
- onRenamed: L,
220
- onDeleted: se,
221
- onChanged: L
222
- }, null, 8, ["asset", "image", "business-id"]),
223
- u(ue, {
224
- modelValue: b.value,
225
- "onUpdate:modelValue": a[7] || (a[7] = (o) => b.value = o),
226
- "max-width": 480
227
- }, {
228
- "dialog-header": N(() => [
229
- c("div", null, _(t(l)("media.library.uploadDialogTitle")), 1)
230
- ]),
231
- "dialog-footer": N(() => {
232
- var o, q;
233
- return [
234
- c("div", Me, [
235
- u(s, {
236
- label: t(l)("media.library.cancelButton"),
237
- variant: "tertiary",
238
- onClick: a[5] || (a[5] = (re) => b.value = !1)
239
- }, null, 8, ["label"]),
240
- u(s, {
241
- label: t(l)("media.library.uploadSubmitButton", { count: ((o = f.value) == null ? void 0 : o.stagedCount) ?? 0 }),
242
- variant: "primary",
243
- disabled: !((q = f.value) != null && q.stagedCount) || f.value.uploading,
244
- onClick: a[6] || (a[6] = (re) => {
245
- var H;
246
- return (H = f.value) == null ? void 0 : H.upload();
247
- })
248
- }, null, 8, ["label", "disabled"])
249
- ])
250
- ];
251
- }),
252
- default: N(() => [
253
- u(t(xe), {
254
- ref_key: "uploadPanelRef",
255
- ref: f,
256
- "business-id": r.value,
257
- "restaurant-id": E.value,
258
- "available-tags": y.value,
259
- onTagCreated: a[4] || (a[4] = (o) => y.value.push(o)),
260
- onUploaded: ie
261
- }, null, 8, ["business-id", "restaurant-id", "available-tags"])
262
- ]),
263
- _: 1
264
- }, 8, ["modelValue"])
265
- ]);
266
- };
267
- }
268
- });
269
- export {
270
- qe as default
271
- };