@feedmepos/mf-common 1.29.12 → 1.29.13

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,5 +1,5 @@
1
1
  import { defineComponent as C, computed as y, resolveComponent as N, openBlock as h, createElementBlock as v, createVNode as S, toDisplayString as F, unref as w, h as c } from "vue";
2
- import { t as x, u as B } from "./app-7e617adf.js";
2
+ import { t as x, u as B } from "./app-279f08b9.js";
3
3
  import { components as p } from "@feedmepos/ui-library";
4
4
  import { c as O } from "./object-27ce045b.js";
5
5
  import "pinia";
@@ -1,5 +1,5 @@
1
1
  import { ref as pr, computed as Ut, defineComponent as dd, onMounted as cd, watch as ks, resolveComponent as ii, openBlock as jt, createElementBlock as an, createElementVNode as At, toDisplayString as js, unref as Tt, createVNode as Kt, isRef as fd, createCommentVNode as Lr, Fragment as so, renderList as lo, createBlock as ui, withCtx as co, normalizeClass as Go, Transition as Ms } from "vue";
2
- import { c as gr, l as U, d as Me, e as Qe, f as $d, u as Ho, g as hd, a as pd, O as Ss, t as gd, b as bd } from "./app-7e617adf.js";
2
+ import { f as gr, l as U, g as Me, h as Qe, j as $d, u as Ho, k as hd, d as pd, O as Ss, t as gd, e as bd } from "./app-279f08b9.js";
3
3
  import { FmButtonVariant as Vr } from "@feedmepos/ui-library";
4
4
  import { defineStore as md } from "pinia";
5
5
  import { c as Hr } from "./object-27ce045b.js";
@@ -0,0 +1,461 @@
1
+ import { computed as m, ref as k, shallowRef as ye, watch as B, getCurrentInstance as we, onMounted as _e, defineComponent as xe, mergeModels as ke, useModel as Ce, resolveComponent as L, openBlock as x, createElementBlock as S, createElementVNode as R, createVNode as V, withCtx as D, normalizeClass as Re, toDisplayString as Se, createCommentVNode as G, createBlock as H, withModifiers as X, unref as y, isRef as Ve, Fragment as N, mergeProps as q, normalizeProps as J, guardReactiveProps as Z, renderList as ee, renderSlot as Fe, nextTick as Oe } from "vue";
2
+ import { a as Le, b as Me, c as Ae, i as ze, t as Be, u as Te, d as Pe, O as Q, e as He } from "./app-279f08b9.js";
3
+ import "@feedmepos/ui-library";
4
+ import "pinia";
5
+ import "vue-router";
6
+ function M(l) {
7
+ var e;
8
+ const n = Me(l);
9
+ return (e = n == null ? void 0 : n.$el) != null ? e : n;
10
+ }
11
+ const te = ze ? window : void 0;
12
+ function $e() {
13
+ const l = k(!1), e = we();
14
+ return e && _e(() => {
15
+ l.value = !0;
16
+ }, e), l;
17
+ }
18
+ function We(l) {
19
+ const e = $e();
20
+ return m(() => (e.value, !!l()));
21
+ }
22
+ function Ee(l, e, n = {}) {
23
+ const { window: t = te, ...r } = n;
24
+ let s;
25
+ const f = We(() => t && "ResizeObserver" in t), c = () => {
26
+ s && (s.disconnect(), s = void 0);
27
+ }, v = m(() => Array.isArray(l) ? l.map((o) => M(o)) : [M(l)]), a = B(
28
+ v,
29
+ (o) => {
30
+ if (c(), f.value && t) {
31
+ s = new ResizeObserver(e);
32
+ for (const p of o)
33
+ p && s.observe(p, r);
34
+ }
35
+ },
36
+ { immediate: !0, flush: "post" }
37
+ ), h = () => {
38
+ c(), a();
39
+ };
40
+ return Ae(h), {
41
+ isSupported: f,
42
+ stop: h
43
+ };
44
+ }
45
+ function Ie(l, e = { width: 0, height: 0 }, n = {}) {
46
+ const { window: t = te, box: r = "content-box" } = n, s = m(() => {
47
+ var o, p;
48
+ return (p = (o = M(l)) == null ? void 0 : o.namespaceURI) == null ? void 0 : p.includes("svg");
49
+ }), f = k(e.width), c = k(e.height), { stop: v } = Ee(
50
+ l,
51
+ ([o]) => {
52
+ const p = r === "border-box" ? o.borderBoxSize : r === "content-box" ? o.contentBoxSize : o.devicePixelContentBoxSize;
53
+ if (t && s.value) {
54
+ const d = M(l);
55
+ if (d) {
56
+ const g = d.getBoundingClientRect();
57
+ f.value = g.width, c.value = g.height;
58
+ }
59
+ } else if (p) {
60
+ const d = Array.isArray(p) ? p : [p];
61
+ f.value = d.reduce((g, { inlineSize: w }) => g + w, 0), c.value = d.reduce((g, { blockSize: w }) => g + w, 0);
62
+ } else
63
+ f.value = o.contentRect.width, c.value = o.contentRect.height;
64
+ },
65
+ n
66
+ );
67
+ Le(() => {
68
+ const o = M(l);
69
+ o && (f.value = "offsetWidth" in o ? o.offsetWidth : e.width, c.value = "offsetHeight" in o ? o.offsetHeight : e.height);
70
+ });
71
+ const a = B(
72
+ () => M(l),
73
+ (o) => {
74
+ f.value = o ? e.width : 0, c.value = o ? e.height : 0;
75
+ }
76
+ );
77
+ function h() {
78
+ v(), a();
79
+ }
80
+ return {
81
+ width: f,
82
+ height: c,
83
+ stop: h
84
+ };
85
+ }
86
+ function De(l, e) {
87
+ const { containerStyle: n, wrapperProps: t, scrollTo: r, calculateRange: s, currentList: f, containerRef: c } = "itemHeight" in e ? Qe(e, l) : Ne(e, l);
88
+ return {
89
+ list: f,
90
+ scrollTo: r,
91
+ containerProps: {
92
+ ref: c,
93
+ onScroll: () => {
94
+ s();
95
+ },
96
+ style: n
97
+ },
98
+ wrapperProps: t
99
+ };
100
+ }
101
+ function le(l) {
102
+ const e = k(null), n = Ie(e), t = k([]), r = ye(l);
103
+ return { state: k({ start: 0, end: 10 }), source: r, currentList: t, size: n, containerRef: e };
104
+ }
105
+ function ne(l, e, n) {
106
+ return (t) => {
107
+ if (typeof n == "number")
108
+ return Math.ceil(t / n);
109
+ const { start: r = 0 } = l.value;
110
+ let s = 0, f = 0;
111
+ for (let c = r; c < e.value.length; c++) {
112
+ const v = n(c);
113
+ if (s += v, f = c, s > t)
114
+ break;
115
+ }
116
+ return f - r;
117
+ };
118
+ }
119
+ function re(l, e) {
120
+ return (n) => {
121
+ if (typeof e == "number")
122
+ return Math.floor(n / e) + 1;
123
+ let t = 0, r = 0;
124
+ for (let s = 0; s < l.value.length; s++) {
125
+ const f = e(s);
126
+ if (t += f, t >= n) {
127
+ r = s;
128
+ break;
129
+ }
130
+ }
131
+ return r + 1;
132
+ };
133
+ }
134
+ function ae(l, e, n, t, { containerRef: r, state: s, currentList: f, source: c }) {
135
+ return () => {
136
+ const v = r.value;
137
+ if (v) {
138
+ const a = n(l === "vertical" ? v.scrollTop : v.scrollLeft), h = t(l === "vertical" ? v.clientHeight : v.clientWidth), o = a - e, p = a + h + e;
139
+ s.value = {
140
+ start: o < 0 ? 0 : o,
141
+ end: p > c.value.length ? c.value.length : p
142
+ }, f.value = c.value.slice(s.value.start, s.value.end).map((d, g) => ({
143
+ data: d,
144
+ index: g + s.value.start
145
+ }));
146
+ }
147
+ };
148
+ }
149
+ function oe(l, e) {
150
+ return (n) => typeof l == "number" ? n * l : e.value.slice(0, n).reduce((r, s, f) => r + l(f), 0);
151
+ }
152
+ function ue(l, e, n, t) {
153
+ B([l.width, l.height, e, n], () => {
154
+ t();
155
+ });
156
+ }
157
+ function se(l, e) {
158
+ return m(() => typeof l == "number" ? e.value.length * l : e.value.reduce((n, t, r) => n + l(r), 0));
159
+ }
160
+ const Ge = {
161
+ horizontal: "scrollLeft",
162
+ vertical: "scrollTop"
163
+ };
164
+ function ie(l, e, n, t) {
165
+ return (r) => {
166
+ t.value && (t.value[Ge[l]] = n(r), e());
167
+ };
168
+ }
169
+ function Ne(l, e) {
170
+ const n = le(e), { state: t, source: r, currentList: s, size: f, containerRef: c } = n, v = { overflowX: "auto" }, { itemWidth: a, overscan: h = 5 } = l, o = ne(t, r, a), p = re(r, a), d = ae("horizontal", h, p, o, n), g = oe(a, r), w = m(() => g(t.value.start)), A = se(a, r);
171
+ ue(f, e, c, d);
172
+ const z = ie("horizontal", d, g, c), F = m(() => ({
173
+ style: {
174
+ height: "100%",
175
+ width: `${A.value - w.value}px`,
176
+ marginLeft: `${w.value}px`,
177
+ display: "flex"
178
+ }
179
+ }));
180
+ return {
181
+ scrollTo: z,
182
+ calculateRange: d,
183
+ wrapperProps: F,
184
+ containerStyle: v,
185
+ currentList: s,
186
+ containerRef: c
187
+ };
188
+ }
189
+ function Qe(l, e) {
190
+ const n = le(e), { state: t, source: r, currentList: s, size: f, containerRef: c } = n, v = { overflowY: "auto" }, { itemHeight: a, overscan: h = 5 } = l, o = ne(t, r, a), p = re(r, a), d = ae("vertical", h, p, o, n), g = oe(a, r), w = m(() => g(t.value.start)), A = se(a, r);
191
+ ue(f, e, c, d);
192
+ const z = ie("vertical", d, g, c), F = m(() => ({
193
+ style: {
194
+ width: "100%",
195
+ height: `${A.value - w.value}px`,
196
+ marginTop: `${w.value}px`
197
+ }
198
+ }));
199
+ return {
200
+ calculateRange: d,
201
+ scrollTo: z,
202
+ containerStyle: v,
203
+ wrapperProps: F,
204
+ currentList: s,
205
+ containerRef: c
206
+ };
207
+ }
208
+ function Ue(l, e, n = l) {
209
+ const t = k(!0), r = m(() => {
210
+ if (!t.value && !e.value)
211
+ return !0;
212
+ if (e.value && e.value.length > 0) {
213
+ const v = new Set(n.value.map((a) => a.value));
214
+ return e.value.length === n.value.length && e.value.every((a) => v.has(a));
215
+ }
216
+ return !1;
217
+ }), s = m(() => {
218
+ var v, a, h, o;
219
+ return !!((v = e.value) != null && v.length && ((a = e.value) == null ? void 0 : a.length) > 0 && ((h = e.value) == null ? void 0 : h.length) < ((o = l.value) == null ? void 0 : o.length));
220
+ });
221
+ return { allCleared: t, allSelected: r, indeterminate: s, toggleAll: () => {
222
+ if (r.value) {
223
+ e.value = void 0, t.value = !0;
224
+ return;
225
+ }
226
+ const v = n.value.map((a) => a.value);
227
+ v.length === l.value.length ? (e.value = void 0, t.value = !1) : (e.value = v, t.value = !1);
228
+ }, toggleOption: (v) => {
229
+ var h, o, p;
230
+ let a;
231
+ e.value === void 0 && t.value ? a = [v] : e.value === void 0 && !t.value ? a = (h = l.value.map((d) => d.value)) == null ? void 0 : h.filter((d) => d !== v) : (o = e.value) != null && o.includes(v) ? a = (p = e.value) == null ? void 0 : p.filter((d) => d !== v) : a = [...e.value || [], v], a.length === 0 ? (e.value = void 0, t.value = !0) : a.length === l.value.length ? (e.value = void 0, t.value = !1) : e.value = a;
232
+ } };
233
+ }
234
+ const Ye = { class: "w-full flex flex-col gap-8" }, Ke = { class: "flex items-center gap-8" }, je = { class: "inline-flex items-center" }, Xe = { class: "flex flex-col w-[360px] min-h-0 gap-8" }, qe = { class: "flex gap-4 px-[6px]" }, Je = { class: "flex-1" }, Ze = { class: "flex-1 min-h-0" }, et = { key: 0 }, tt = 40, it = /* @__PURE__ */ xe({
235
+ __name: "RestaurantSelector",
236
+ props: /* @__PURE__ */ ke({
237
+ multiple: { type: Boolean, default: !1 },
238
+ excludeRestaurants: {},
239
+ managableOnly: { type: Boolean, default: !0 },
240
+ disabled: { type: Boolean, default: !1 },
241
+ variant: { default: "default" },
242
+ autoSelectFirst: { type: Boolean, default: !1 }
243
+ }, {
244
+ modelValue: {},
245
+ modelModifiers: {}
246
+ }),
247
+ emits: ["update:modelValue"],
248
+ setup(l) {
249
+ const e = l, { t: n } = Be(), t = Ce(l, "modelValue"), { restaurants: r, restaurantAttributeSettings: s } = Te(), f = m(() => r.value.length === 0);
250
+ function c(u) {
251
+ const i = r.value.map((O) => {
252
+ var P;
253
+ return (P = O.customAttributes) == null ? void 0 : P[u];
254
+ }).filter((O) => typeof O == "string" && !!O);
255
+ return [...new Set(i)];
256
+ }
257
+ const v = m(() => s.value.map((u) => {
258
+ const i = c(u.key);
259
+ return {
260
+ ...u,
261
+ values: i
262
+ };
263
+ })), { searchKey: a, filter: h } = Pe(), o = k(null);
264
+ function p(u) {
265
+ var i;
266
+ if (e.multiple)
267
+ throw new Error("Single selection is not supported for multiple selection");
268
+ t.value = u, (i = o.value) == null || i.toggleMenu(!1);
269
+ }
270
+ const d = (u) => {
271
+ const { name: i, code: b } = u.profile;
272
+ return {
273
+ label: `${i} (${b ?? "--"})`,
274
+ value: u._id
275
+ };
276
+ }, g = m(() => r.value.map(d)), w = m(
277
+ () => r.value.filter((u) => e.managableOnly ? u.managable : !0).filter((u) => e.multiple ? !0 : Q(u.customAttributes || {}, C.value)).map(d).filter(({ label: u }) => h([u])).filter((u) => {
278
+ var i;
279
+ return !((i = e.excludeRestaurants) != null && i.includes(u.value));
280
+ })
281
+ ), A = m(() => {
282
+ var u;
283
+ return t.value ? t.value.length === 1 ? (u = g.value.find((i) => {
284
+ var b;
285
+ return i.value === ((b = t.value) == null ? void 0 : b[0]);
286
+ })) == null ? void 0 : u.label : n("portalshell.components.restaurantSelector.restaurantCount", {
287
+ count: t.value.length
288
+ }) : n("portalshell.components.restaurantSelector.allRestaurants");
289
+ }), z = m(() => {
290
+ var u;
291
+ return t.value ? ((u = g.value.find((i) => i.value === t.value)) == null ? void 0 : u.label) || n("portalshell.components.restaurantSelector.unknownRestaurant") : n("portalshell.components.restaurantSelector.selectRestaurant");
292
+ }), F = m(() => e.multiple ? A.value : z.value), $ = m(() => e.disabled ? "neutral-gray-200" : e.variant === "dark" ? "neutral-black" : "neutral-gray-400"), ce = m(() => e.disabled ? "text-fm-color-neutral-gray-200" : e.variant === "dark" ? "text-fm-color-neutral-black" : "text-fm-color-neutral-gray-400"), { allSelected: U, toggleAll: ve, toggleOption: fe, indeterminate: de } = Ue(
293
+ g,
294
+ t,
295
+ w
296
+ ), {
297
+ list: Y,
298
+ containerProps: K,
299
+ wrapperProps: j
300
+ } = De(w, {
301
+ itemHeight: tt,
302
+ overscan: 10
303
+ }), T = k(!1), pe = m(() => s.value.length > 0), W = k(null);
304
+ async function me() {
305
+ e.disabled || (T.value ? T.value = !1 : (T.value = !0, await Oe(), W.value && W.value.toggleProperty(!0)));
306
+ }
307
+ const C = k((() => ({
308
+ logic: "AND",
309
+ rules: []
310
+ }))()), he = m(() => {
311
+ var u, i;
312
+ return ((i = (u = C.value) == null ? void 0 : u.rules) == null ? void 0 : i.length) || 0;
313
+ });
314
+ return B(
315
+ [C, r],
316
+ () => {
317
+ var u;
318
+ if (e.multiple) {
319
+ if (!C.value || C.value.rules.length === 0) {
320
+ t.value = null;
321
+ return;
322
+ }
323
+ const i = r.value.filter((b) => Q(b.customAttributes || {}, C.value));
324
+ t.value = i.map((b) => b._id);
325
+ } else {
326
+ const i = r.value.filter((b) => Q(b.customAttributes || {}, C.value));
327
+ i.length === 0 ? t.value = null : t.value = (u = i[0]) == null ? void 0 : u._id;
328
+ }
329
+ },
330
+ {
331
+ deep: !0
332
+ }
333
+ ), B(
334
+ [() => e.autoSelectFirst, w],
335
+ ([u, i]) => {
336
+ u && i.length > 0 && !t.value && (t.value = i[0].value);
337
+ },
338
+ { immediate: !0 }
339
+ ), (u, i) => {
340
+ const b = L("FmIcon"), O = L("FmCircularProgress"), P = L("FmChip"), ge = L("FmSearch"), E = L("FmMenuItem"), be = L("FmMenu");
341
+ return x(), S("div", Ye, [
342
+ R("div", Ke, [
343
+ V(be, {
344
+ "close-on-click": !1,
345
+ disabled: u.disabled || f.value,
346
+ ref_key: "menuRef",
347
+ ref: o,
348
+ "z-index": 50,
349
+ "selector-for-dismiss-away-event-exclusion": ".fm-dialog, .fm-select__menu__wrapper"
350
+ }, {
351
+ "menu-button": D(() => [
352
+ R("div", je, [
353
+ V(P, { disabled: u.disabled }, {
354
+ default: D(() => [
355
+ V(b, {
356
+ color: $.value,
357
+ name: "storefront",
358
+ outline: "",
359
+ size: "sm"
360
+ }, null, 8, ["color"]),
361
+ F.value ? (x(), S("div", {
362
+ key: 0,
363
+ class: Re([
364
+ "fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap",
365
+ ce.value
366
+ ])
367
+ }, Se(F.value), 3)) : G("", !0),
368
+ f.value ? (x(), H(O, {
369
+ key: 1,
370
+ size: "md"
371
+ })) : (x(), H(b, {
372
+ key: 2,
373
+ color: $.value,
374
+ name: "keyboard_arrow_down",
375
+ size: "sm"
376
+ }, null, 8, ["color"])),
377
+ pe.value ? (x(), S("div", {
378
+ key: 3,
379
+ class: "pl-8 flex items-center justify-center border-l border-fm-color-neutral-gray-200",
380
+ onClick: X(me, ["stop"])
381
+ }, [
382
+ V(b, {
383
+ name: "filter_alt",
384
+ size: "sm",
385
+ outline: he.value === 0,
386
+ color: $.value,
387
+ onClick: i[0] || (i[0] = X(() => {
388
+ }, ["prevent"]))
389
+ }, null, 8, ["outline", "color"])
390
+ ])) : G("", !0)
391
+ ]),
392
+ _: 1
393
+ }, 8, ["disabled"])
394
+ ])
395
+ ]),
396
+ default: D(() => [
397
+ R("div", Xe, [
398
+ R("div", qe, [
399
+ R("div", Je, [
400
+ V(ge, {
401
+ modelValue: y(a),
402
+ "onUpdate:modelValue": i[1] || (i[1] = (_) => Ve(a) ? a.value = _ : null),
403
+ placeholder: y(n)("common.search")
404
+ }, null, 8, ["modelValue", "placeholder"])
405
+ ])
406
+ ]),
407
+ R("div", Ze, [
408
+ u.multiple ? (x(), S(N, { key: 0 }, [
409
+ V(E, {
410
+ label: "All",
411
+ "has-checkbox": "",
412
+ "model-value": y(U),
413
+ indeterminate: y(de),
414
+ onClick: y(ve)
415
+ }, null, 8, ["model-value", "indeterminate", "onClick"]),
416
+ R("div", q(y(K), { style: { maxHeight: "320px", overflowY: "auto" } }), [
417
+ R("div", J(Z(y(j))), [
418
+ (x(!0), S(N, null, ee(y(Y), ({ data: _ }) => {
419
+ var I;
420
+ return x(), H(E, {
421
+ key: _.value,
422
+ label: _.label,
423
+ "has-checkbox": "",
424
+ "model-value": y(U) || ((I = t.value) == null ? void 0 : I.includes(_.value)),
425
+ onClick: (nt) => y(fe)(_.value)
426
+ }, null, 8, ["label", "model-value", "onClick"]);
427
+ }), 128))
428
+ ], 16)
429
+ ], 16)
430
+ ], 64)) : (x(), S("div", q({ key: 1 }, y(K), { style: { maxHeight: "320px", overflowY: "auto" } }), [
431
+ R("div", J(Z(y(j))), [
432
+ (x(!0), S(N, null, ee(y(Y), ({ data: _ }) => (x(), H(E, {
433
+ key: _.value,
434
+ label: _.label,
435
+ onClick: (I) => p(_.value)
436
+ }, null, 8, ["label", "onClick"]))), 128))
437
+ ], 16)
438
+ ], 16))
439
+ ])
440
+ ])
441
+ ]),
442
+ _: 1
443
+ }, 8, ["disabled"]),
444
+ Fe(u.$slots, "append-right")
445
+ ]),
446
+ T.value ? (x(), S("div", et, [
447
+ V(y(He), {
448
+ ref_key: "filterRef",
449
+ ref: W,
450
+ attributes: v.value,
451
+ modelValue: C.value,
452
+ "onUpdate:modelValue": i[2] || (i[2] = (_) => C.value = _)
453
+ }, null, 8, ["attributes", "modelValue"])
454
+ ])) : G("", !0)
455
+ ]);
456
+ };
457
+ }
458
+ });
459
+ export {
460
+ it as default
461
+ };