@feedmepos/mf-media 1.0.2-dev.2 → 1.0.2-dev.3

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