@feedmepos/mf-common 1.15.0 → 1.16.0-beta.2

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.
@@ -0,0 +1,217 @@
1
+ import { ref as C, computed as i, defineComponent as J, mergeModels as X, useModel as Y, watch as Z, resolveComponent as x, openBlock as v, createElementBlock as h, createElementVNode as k, createVNode as m, withCtx as O, normalizeClass as ee, toDisplayString as le, createCommentVNode as B, withModifiers as E, unref as y, Fragment as L, renderList as $, createBlock as D, renderSlot as te, nextTick as ae } from "vue";
2
+ import { x as z, v as ne } from "./app-f61631fd.js";
3
+ import { storeToRefs as re } from "pinia";
4
+ import { n as ue, u as oe } from "./app-fb5d961e.js";
5
+ import "@feedmepos/ui-library";
6
+ import "vue-router";
7
+ function se(p, t) {
8
+ const r = C(!0), n = i(() => {
9
+ var u, a;
10
+ return !r.value && (!t.value || ((u = t.value) == null ? void 0 : u.length) === ((a = p.value) == null ? void 0 : a.length));
11
+ }), g = i(() => {
12
+ var u, a, f, b;
13
+ return !!((u = t.value) != null && u.length && ((a = t.value) == null ? void 0 : a.length) > 0 && ((f = t.value) == null ? void 0 : f.length) < ((b = p.value) == null ? void 0 : b.length));
14
+ });
15
+ return { allCleared: r, allSelected: n, indeterminate: g, toggleAll: () => {
16
+ t.value = void 0, r.value = !r.value;
17
+ }, toggleOption: (u) => {
18
+ var f, b, w;
19
+ let a;
20
+ t.value === void 0 && r.value ? a = [u] : t.value === void 0 && !r.value ? a = (f = p.value.map((c) => c.value)) == null ? void 0 : f.filter((c) => c !== u) : (b = t.value) != null && b.includes(u) ? a = (w = t.value) == null ? void 0 : w.filter((c) => c !== u) : a = [...t.value || [], u], a.length === 0 ? (t.value = void 0, r.value = !0) : a.length === p.value.length ? (t.value = void 0, r.value = !1) : t.value = a;
21
+ } };
22
+ }
23
+ const ie = { class: "flex flex-col gap-8" }, ce = { class: "flex items-center gap-8" }, de = { class: "inline-flex items-center" }, ve = { class: "flex flex-col w-[360px] min-h-0 gap-8" }, fe = { class: "flex gap-4 px-[6px]" }, me = { class: "flex-1" }, pe = { class: "flex-1 overflow-y-auto min-h-0" }, ge = { key: 0 }, Fe = /* @__PURE__ */ J({
24
+ __name: "RestaurantSelector",
25
+ props: /* @__PURE__ */ X({
26
+ multiple: { type: Boolean, default: !1 },
27
+ excludeRestaurants: {},
28
+ managableOnly: { type: Boolean, default: !0 },
29
+ disabled: { type: Boolean, default: !1 }
30
+ }, {
31
+ modelValue: {},
32
+ modelModifiers: {}
33
+ }),
34
+ emits: ["update:modelValue"],
35
+ setup(p) {
36
+ const t = p, { t: r } = ue(), n = Y(p, "modelValue"), { restaurants: g, restaurantAttributeSettings: A } = re(oe());
37
+ function I(e) {
38
+ const l = g.value.map((_) => {
39
+ var F;
40
+ return (F = _.customAttributes) == null ? void 0 : F[e];
41
+ }).filter((_) => typeof _ == "string" && !!_);
42
+ return [...new Set(l)];
43
+ }
44
+ const u = i(() => A.value.map((e) => {
45
+ const l = I(e.key);
46
+ return {
47
+ ...e,
48
+ values: l
49
+ };
50
+ })), a = C(""), f = C(null);
51
+ function b(e) {
52
+ var l;
53
+ if (t.multiple)
54
+ throw new Error("Single selection is not supported for multiple selection");
55
+ n.value = e, (l = f.value) == null || l.toggleMenu(!1);
56
+ }
57
+ const w = i(() => g.value.map((e) => ({
58
+ label: e.profile.name,
59
+ value: e._id
60
+ }))), c = i(
61
+ () => g.value.filter((e) => t.managableOnly ? e.managable : !0).filter((e) => a.value ? e.profile.name.toLowerCase().includes(a.value.toLowerCase()) : !0).filter((e) => t.multiple ? !0 : z(e.customAttributes, d.value)).map((e) => ({
62
+ label: e.profile.name,
63
+ value: e._id
64
+ })).filter((e) => {
65
+ var l;
66
+ return !((l = t.excludeRestaurants) != null && l.includes(e.value));
67
+ })
68
+ ), T = i(() => {
69
+ var e;
70
+ return n.value ? n.value.length === 1 ? (e = w.value.find((l) => {
71
+ var o;
72
+ return l.value === ((o = n.value) == null ? void 0 : o[0]);
73
+ })) == null ? void 0 : e.label : r("portalshell.components.restaurantSelector.restaurantCount", {
74
+ count: n.value.length
75
+ }) : r("portalshell.components.restaurantSelector.allRestaurants");
76
+ }), U = i(() => {
77
+ var e;
78
+ return n.value ? ((e = w.value.find((l) => l.value === n.value)) == null ? void 0 : e.label) || r("portalshell.components.restaurantSelector.unknownRestaurant") : r("portalshell.components.restaurantSelector.selectRestaurant");
79
+ }), N = i(() => t.multiple ? T.value : U.value), { allCleared: be, allSelected: Q, toggleAll: j, toggleOption: K, indeterminate: P } = se(
80
+ c,
81
+ n
82
+ ), S = C(!1), W = i(() => A.value.length > 0), V = C(null);
83
+ async function q() {
84
+ t.disabled || (S.value ? S.value = !1 : (S.value = !0, await ae(), V.value && V.value.toggleProperty(!0)));
85
+ }
86
+ const d = C((() => ({
87
+ logic: "AND",
88
+ rules: []
89
+ }))()), G = i(() => {
90
+ var e, l;
91
+ return ((l = (e = d.value) == null ? void 0 : e.rules) == null ? void 0 : l.length) || 0;
92
+ });
93
+ return Z(d, () => {
94
+ var e;
95
+ if (t.multiple) {
96
+ if (!d.value || d.value.rules.length === 0) {
97
+ n.value = null;
98
+ return;
99
+ }
100
+ const l = g.value.filter((o) => z(o.customAttributes, d.value));
101
+ n.value = l.map((o) => o._id);
102
+ } else {
103
+ const l = g.value.filter((o) => z(o.customAttributes, d.value));
104
+ l.length === 0 ? n.value = null : n.value = (e = l[0]) == null ? void 0 : e._id;
105
+ }
106
+ }), (e, l) => {
107
+ const o = x("FmIcon"), _ = x("FmChip"), F = x("FmSearch"), R = x("FmMenuItem"), H = x("FmMenu");
108
+ return v(), h("div", ie, [
109
+ k("div", ce, [
110
+ m(H, {
111
+ "close-on-click": !1,
112
+ disabled: t.disabled,
113
+ ref_key: "menuRef",
114
+ ref: f,
115
+ "z-index": 50,
116
+ "selector-for-dismiss-away-event-exclusion": ".fm-dialog, .fm-select__menu__wrapper"
117
+ }, {
118
+ "menu-button": O(() => [
119
+ k("div", de, [
120
+ m(_, {
121
+ disabled: t.disabled
122
+ }, {
123
+ default: O(() => [
124
+ m(o, {
125
+ color: e.disabled ? "neutral-gray-200" : "neutral-gray-400",
126
+ name: "storefront",
127
+ outline: "",
128
+ size: "sm"
129
+ }, null, 8, ["color"]),
130
+ N.value ? (v(), h("div", {
131
+ key: 0,
132
+ class: ee([
133
+ "fm-typo-en-body-md-600 select-none text-ellipsis overflow-hidden whitespace-nowrap",
134
+ e.disabled ? "text-fm-color-neutral-gray-200" : "text-fm-color-neutral-gray-400"
135
+ ])
136
+ }, le(N.value), 3)) : B("", !0),
137
+ m(o, {
138
+ color: e.disabled ? "neutral-gray-200" : "neutral-gray-400",
139
+ name: "keyboard_arrow_down",
140
+ size: "sm"
141
+ }, null, 8, ["color"]),
142
+ W.value ? (v(), h("div", {
143
+ key: 1,
144
+ class: "pl-8 flex items-center justify-center border-l border-fm-color-neutral-gray-200",
145
+ onClick: E(q, ["stop"])
146
+ }, [
147
+ m(o, {
148
+ name: "filter_alt",
149
+ outline: G.value === 0,
150
+ color: e.disabled ? "neutral-gray-200" : "neutral-gray-400",
151
+ onClick: l[0] || (l[0] = E(() => {
152
+ }, ["prevent"]))
153
+ }, null, 8, ["outline", "color"])
154
+ ])) : B("", !0)
155
+ ]),
156
+ _: 1
157
+ }, 8, ["disabled"])
158
+ ])
159
+ ]),
160
+ default: O(() => [
161
+ k("div", ve, [
162
+ k("div", fe, [
163
+ k("div", me, [
164
+ m(F, {
165
+ modelValue: a.value,
166
+ "onUpdate:modelValue": l[1] || (l[1] = (s) => a.value = s),
167
+ placeholder: y(r)("common.search")
168
+ }, null, 8, ["modelValue", "placeholder"])
169
+ ])
170
+ ]),
171
+ k("div", pe, [
172
+ e.multiple ? (v(), h(L, { key: 0 }, [
173
+ m(R, {
174
+ label: "All",
175
+ "has-checkbox": "",
176
+ "model-value": y(Q),
177
+ indeterminate: y(P),
178
+ onClick: y(j)
179
+ }, null, 8, ["model-value", "indeterminate", "onClick"]),
180
+ (v(!0), h(L, null, $(c.value, (s) => {
181
+ var M;
182
+ return v(), D(R, {
183
+ key: s.value,
184
+ label: s.label,
185
+ "has-checkbox": "",
186
+ "model-value": y(Q) || ((M = n.value) == null ? void 0 : M.includes(s.value)),
187
+ onClick: (ye) => y(K)(s.value)
188
+ }, null, 8, ["label", "model-value", "onClick"]);
189
+ }), 128))
190
+ ], 64)) : (v(!0), h(L, { key: 1 }, $(c.value, (s) => (v(), D(R, {
191
+ key: s.value,
192
+ label: s.label,
193
+ onClick: (M) => b(s.value)
194
+ }, null, 8, ["label", "onClick"]))), 128))
195
+ ])
196
+ ])
197
+ ]),
198
+ _: 1
199
+ }, 8, ["disabled"]),
200
+ te(e.$slots, "append-right")
201
+ ]),
202
+ S.value ? (v(), h("div", ge, [
203
+ m(y(ne), {
204
+ ref_key: "filterRef",
205
+ ref: V,
206
+ attributes: u.value,
207
+ modelValue: d.value,
208
+ "onUpdate:modelValue": l[2] || (l[2] = (s) => d.value = s)
209
+ }, null, 8, ["attributes", "modelValue"])
210
+ ])) : B("", !0)
211
+ ]);
212
+ };
213
+ }
214
+ });
215
+ export {
216
+ Fe as default
217
+ };
@@ -1,5 +1,5 @@
1
1
  import { FdoAgent, FdoBusiness, FdoPermissionRule, FdoRestaurant, FdoRestaurantSetting, type FdoUser, type FdoPublicSetting } from "@feedmepos/core/entity";
2
- import { type AxiosInstance } from "axios";
2
+ import { type AxiosInstance, type AxiosResponse } from "axios";
3
3
  export declare function readUserAdminPermission(): Promise<FdoPermissionRule[]>;
4
4
  export declare function readUserBusinessPermission(businessId: string): Promise<FdoPermissionRule[]>;
5
5
  export declare function readManagableBusinesses(): Promise<FdoBusiness[]>;
@@ -18,6 +18,7 @@ export type PublicSettingApi = FdoPublicSetting & {
18
18
  };
19
19
  export declare function getPublicSetting(): Promise<PublicSettingApi>;
20
20
  export declare const baseClientInstance: (url: string) => AxiosInstance;
21
+ export declare function extractAxiosData<T>(response: AxiosResponse<T>): T;
21
22
  export declare const accountService: {
22
23
  updateUserProfile(profile: {
23
24
  displayName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAA;AAC/B,OAAc,EAAc,KAAK,aAAa,EAAsB,MAAM,OAAO,CAAA;AAIjF,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAE5E;AAED,wBAAsB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAOjG;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAEtE;AAED,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAI/F;AAED,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAI1F;AAED,wBAAsB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAEzF;AAED,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAE/D;AAED,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEpE;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAErD;AAED,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE,OAAO,CAAA;SAChB,CAAA;KACF,CAAC;CACH,CAAA;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAElE;AA2BD,eAAO,MAAM,kBAAkB,QAAS,MAAM,K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CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEpE;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAErD;AAED,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG;IAChD,UAAU,EAAE;QACV,IAAI,EAAE;YACJ,MAAM,EAAE,OAAO,CAAA;SAChB,CAAA;KACF,CAAA;CACF,CAAA;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAElE;AA2BD,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,aAGhD,CAAA;AASD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAEjE;AA+BD,eAAO,MAAM,cAAc;+BACQ;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,QAAQ;QAChF,WAAW,EAAE,MAAM,CAAA;KACpB,CAAC;uBAIuB,QAAQ,OAAO,CAAC;;qBAQ1B,MAAM;kBACT,MAAM;QACd,QAAQ;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;;qBAUrB,MAAM;kBACT,MAAM;QACd,QAAQ;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;CAKrC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { FdoMenuV4 } from "@feedmepos/menu/entity";
2
+ export interface CustomApiConfig {
3
+ businessId?: string;
4
+ userToken?: string;
5
+ }
6
+ export declare function queryMenu(custom?: CustomApiConfig): Promise<FdoMenuV4>;
7
+ //# sourceMappingURL=menu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../../../src/api/menu.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAKvD,MAAM,WAAW,eAAe;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AASD,wBAAsB,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,CAE5E"}