@feedmepos/mf-menu 0.18.17 → 0.19.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.
Files changed (90) hide show
  1. package/dist/ApplyProduct.vue_vue_type_script_setup_true_lang-DFJJHptK.js +158 -0
  2. package/dist/{ApplyProducts.vue_vue_type_script_setup_true_lang-BJ0b_uKf.js → ApplyProducts.vue_vue_type_script_setup_true_lang-CXoRwrTi.js} +2 -2
  3. package/dist/Catalog-CXzqtCF8.js +551 -0
  4. package/dist/Category-DKbtLbq8.js +387 -0
  5. package/dist/CookingGuide-BKon8TdH.js +862 -0
  6. package/dist/Group-D1UDksBG.js +46 -0
  7. package/dist/{Group-jEtbECLb.js → Group-izOWb_Bh.js} +1 -1
  8. package/dist/Group.vue_vue_type_script_setup_true_lang-DAlQcgYp.js +558 -0
  9. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-Q7es2wmt.js +237 -0
  10. package/dist/{ImportProductDialog.vue_vue_type_script_setup_true_lang-Bw4uxqAp.js → ImportProductDialog.vue_vue_type_script_setup_true_lang-Db0uYw5O.js} +11723 -11723
  11. package/dist/Ingredient-BIJu9P_9.js +484 -0
  12. package/dist/LinkProductSideSheet-BNdFZThd.js +104 -0
  13. package/dist/PrintRoute--fYPFcy7.js +417 -0
  14. package/dist/{Product-Bnr9oFr2.js → Product-vLtISbkD.js} +1 -1
  15. package/dist/Product.vue_vue_type_script_setup_true_lang-BHCihe6o.js +826 -0
  16. package/dist/Products-JaCNtcHS.js +236 -0
  17. package/dist/Publish-jpmiyB-b.js +525 -0
  18. package/dist/Recipe-B6y-oLPG.js +320 -0
  19. package/dist/Scheduler-Dj1rlr-U.js +222 -0
  20. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-BVAkohGJ.js +48 -0
  21. package/dist/ServingSequence-BhIfCyXl.js +4 -0
  22. package/dist/{Setting-DN8TQdIR.js → Setting-B5R1JfaL.js} +1 -1
  23. package/dist/Setting.vue_vue_type_script_setup_true_lang-xXtg0JOn.js +253 -0
  24. package/dist/Takeaway-BSFSz_JL.js +63 -0
  25. package/dist/{Takeaway-y0Nk0JAb.js → Takeaway-DjFTtbw6.js} +1 -1
  26. package/dist/Takeaway.vue_vue_type_script_setup_true_lang-BUGL0wfZ.js +302 -0
  27. package/dist/TaxSetting-D9Q8XNgJ.js +25 -0
  28. package/dist/Unit-Cr_8O3zB.js +142 -0
  29. package/dist/Variant-loUMfNRB.js +222 -0
  30. package/dist/_id_-0w7KjYyQ.js +189 -0
  31. package/dist/{app-D7e31gIv.js → app-t9ONnc0s.js} +31701 -26207
  32. package/dist/app.js +7 -6
  33. package/dist/apps/mf-menu/src/app.d.ts +2784 -0
  34. package/dist/apps/mf-menu/src/components/feature/Fields/OrderFrom.vue.d.ts +2 -2
  35. package/dist/apps/mf-menu/src/components/feature/LinkProduct/LinkProductSideSheet.vue.d.ts +2 -2
  36. package/dist/apps/mf-menu/src/manager/menu/catalog.d.ts +1 -0
  37. package/dist/apps/mf-menu/src/stores/manager/item.d.ts +1 -1
  38. package/dist/apps/mf-menu/src/stores/menu.d.ts +16 -16
  39. package/dist/apps/mf-menu/src/views/Publish/UpdateCatalogDialog.vue.d.ts +12 -12
  40. package/dist/apps/mf-menu/src/views/Scheduler/FilterForm.vue.d.ts +4 -4
  41. package/dist/apps/mf-menu/src/views/Scheduler/SchedulerDialog.vue.d.ts +4 -4
  42. package/dist/apps/mf-menu/tsconfig.app.tsbuildinfo +1 -1
  43. package/dist/assets/{linked-status-D5tq3eE2.js → linked-status-DLL4aRiX.js} +8 -8
  44. package/dist/assets/{validate-menu-AcCpPyQZ.js → validate-menu-CoXc16jh.js} +8 -8
  45. package/dist/{catalog-Ck7lLTN2.js → catalog-4OmC0JA3.js} +66 -62
  46. package/dist/category-BE33DRqp.js +155 -0
  47. package/dist/{currency-CclA5a-2.js → currency-JHgYNbTQ.js} +1 -1
  48. package/dist/{index-DDd9B_ur.js → index-CE3zjhyh.js} +732 -740
  49. package/dist/index-pSg9p-28.js +238 -0
  50. package/dist/item-CEPx51U1.js +6371 -0
  51. package/dist/{lodash-BIQx_fko.js → lodash-VivR_BQ2.js} +1 -1
  52. package/dist/{menu-CYzbNubv.js → menu-ETQrtbbU.js} +1 -1
  53. package/dist/{object-DUtbNpoS.js → object-DEM5FMTB.js} +4 -4
  54. package/dist/scheduler-SRT_5Nio.js +491 -0
  55. package/dist/string-DpfFixWH.js +4 -0
  56. package/dist/style.css +1 -1
  57. package/dist/takeaway-RcvqKigG.js +267 -0
  58. package/dist/{toExcel-BXPcj8Gp.js → toExcel-BcgskY3F.js} +2 -2
  59. package/dist/unit-DLL7xIF1.js +350 -0
  60. package/package.json +4 -2
  61. package/dist/ApplyProduct.vue_vue_type_script_setup_true_lang-D9QsJ4vO.js +0 -155
  62. package/dist/Catalog-CZW54QJU.js +0 -570
  63. package/dist/Category-DvsP_L7d.js +0 -405
  64. package/dist/CookingGuide-DC3uXetk.js +0 -848
  65. package/dist/Group-DK5xqeYX.js +0 -44
  66. package/dist/Group.vue_vue_type_script_setup_true_lang-DGZ9hnPg.js +0 -538
  67. package/dist/GroupMarkupPriceDialog.vue_vue_type_script_setup_true_lang-BQXqlXw4.js +0 -234
  68. package/dist/Ingredient-354LLwdX.js +0 -498
  69. package/dist/LinkProductSideSheet-anxSsu0z.js +0 -102
  70. package/dist/PrintRoute-DrSvtNLX.js +0 -425
  71. package/dist/Product.vue_vue_type_script_setup_true_lang-bBY54Q_1.js +0 -815
  72. package/dist/Products-CZyueqSO.js +0 -234
  73. package/dist/Publish-kRM1UuPk.js +0 -518
  74. package/dist/Recipe-nKpLIJs8.js +0 -345
  75. package/dist/Scheduler-DmZ8atXG.js +0 -233
  76. package/dist/SchedulerSelector.vue_vue_type_script_setup_true_lang-CdsxA-p0.js +0 -48
  77. package/dist/ServingSequence-j00_ko5R.js +0 -4
  78. package/dist/Setting.vue_vue_type_script_setup_true_lang-Cx06MCJs.js +0 -247
  79. package/dist/Takeaway-BXZXCAaM.js +0 -61
  80. package/dist/Takeaway.vue_vue_type_script_setup_true_lang-9WVkdLZF.js +0 -316
  81. package/dist/TaxSetting-DdHx7ACN.js +0 -21
  82. package/dist/Unit-biPvleyL.js +0 -161
  83. package/dist/Variant-BP1IRNQx.js +0 -231
  84. package/dist/_id_-BiaNDI2N.js +0 -188
  85. package/dist/category-KiA5-36F.js +0 -154
  86. package/dist/index-BFeZlU8X.js +0 -232
  87. package/dist/item-Bcg7SiYv.js +0 -6325
  88. package/dist/scheduler-D1tgE0_9.js +0 -480
  89. package/dist/takeaway-BKsoD4EL.js +0 -264
  90. package/dist/unit-CswFvAyc.js +0 -346
@@ -1,264 +0,0 @@
1
- import { defineComponent as S, ref as m, computed as E, watch as q, onMounted as L, onBeforeUnmount as P, resolveComponent as _, openBlock as M, createBlock as U, withModifiers as C, withCtx as g, renderSlot as N, createElementBlock as A, Fragment as I, createVNode as p, unref as V, createElementVNode as D, toDisplayString as K, createCommentVNode as O } from "vue";
2
- import { components as z } from "@feedmepos/ui-library";
3
- import { c as x, u as R, S as W, g as j, m as T, d as H, b as Y } from "./app-D7e31gIv.js";
4
- import { f as Z } from "./currency-CclA5a-2.js";
5
- import { _ as G } from "./ApplyProduct.vue_vue_type_script_setup_true_lang-D9QsJ4vO.js";
6
- import { _ as J } from "./FormSection.vue_vue_type_script_setup_true_lang-BWJUD8NZ.js";
7
- import { u as Q, l as X } from "./lodash-BIQx_fko.js";
8
- const ee = /* @__PURE__ */ S({
9
- __name: "CurrencyInput",
10
- props: {
11
- modelValue: {},
12
- label: {},
13
- placeholder: {},
14
- nullable: { type: Boolean },
15
- showCurrency: { type: Boolean },
16
- min: {},
17
- max: {},
18
- required: { type: [Boolean, String] },
19
- rules: {},
20
- disable: { type: Boolean },
21
- minLength: {},
22
- maxLength: {},
23
- inputmode: {},
24
- type: {},
25
- readonly: { type: Boolean },
26
- labelMark: {},
27
- prependIcon: {},
28
- appendIcon: {},
29
- showValidBorder: { type: Boolean },
30
- labelInfo: {},
31
- showWordCount: { type: Boolean },
32
- invalid: { type: Boolean },
33
- autofocus: { type: Boolean },
34
- formatter: { type: Function },
35
- decimal: {},
36
- datalist: {},
37
- shiftDatalist: { type: Boolean },
38
- datalistMaxHeight: {},
39
- datalistMinHeight: {},
40
- offsetDatalist: {},
41
- datalistPlacement: {},
42
- datalistZIndex: {},
43
- datalistWidth: {},
44
- disabled: { type: Boolean },
45
- focused: { type: Boolean },
46
- helperText: {},
47
- helperState: {}
48
- },
49
- emits: ["update:model-value"],
50
- setup(f, { emit: s }) {
51
- const a = f, u = m(!1), c = m(!1), n = m(), F = E(() => a.modelValue ? (c.value && !u.value && (u.value = !0), x.Dinero.fromFdoDinero(a.modelValue).toUnit().toFixed(2)) : "");
52
- q(
53
- () => c.value,
54
- (e) => {
55
- var t, l, o, B, b;
56
- e ? (l = (t = n.value) == null ? void 0 : t.inputEl) == null || l.select() : (u.value = !1, (o = n.value) != null && o.inputEl && v((b = (B = n.value) == null ? void 0 : B.inputEl) == null ? void 0 : b.value));
57
- }
58
- );
59
- const h = s, i = typeof a.required == "string" ? a.required : `The ${a.label ?? "field"} is required`, y = [
60
- (e) => a.required ? !!e || i : !0,
61
- (e) => a.min !== void 0 && e && parseFloat(e.toString()) < a.min ? `Min value is ${a.min}` : !0,
62
- (e) => a.max !== void 0 && e && parseFloat(e.toString()) > a.max ? `Max value is ${a.max}` : !0,
63
- ...a.rules ?? []
64
- ];
65
- function v(e) {
66
- if (typeof e != "number" && !e && a.nullable)
67
- h("update:model-value", void 0);
68
- else {
69
- if (typeof e == "string" && e === "-")
70
- return;
71
- let t = parseFloat((e || "").toString());
72
- t = Number.isNaN(t) ? 0 : t, h("update:model-value", x.Dinero.fromNumber({ number: t }).toObject());
73
- }
74
- }
75
- const r = E(() => typeof a.min == "number" && a.min >= 0), w = (e) => {
76
- var t, l, o;
77
- if (!(e.ctrlKey || e.metaKey)) {
78
- if (e.key === "Enter") {
79
- (t = n.value) != null && t.inputEl && v((o = (l = n.value) == null ? void 0 : l.inputEl) == null ? void 0 : o.value);
80
- return;
81
- }
82
- if (e.key === "-" && r.value) {
83
- e.preventDefault();
84
- return;
85
- }
86
- e.key >= "0" && e.key <= "9" || e.key === "." || e.key === "," || e.key === "-" || e.key === "Backspace" || e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Tab" || e.preventDefault();
87
- }
88
- };
89
- return L(() => {
90
- var e;
91
- n.value && ((e = n.value.inputEl) == null || e.addEventListener("keydown", w));
92
- }), P(() => {
93
- var e;
94
- n.value && ((e = n.value.inputEl) == null || e.removeEventListener("keydown", w));
95
- }), (e, t) => {
96
- const l = _("fm-text-field");
97
- return M(), U(l, {
98
- ref_key: "inputRef",
99
- ref: n,
100
- autofocus: a.autofocus,
101
- disabled: a.disable,
102
- label: e.label,
103
- "model-value": F.value,
104
- placeholder: a.placeholder,
105
- "prepend-icon": e.showCurrency ? "attach_money" : void 0,
106
- rules: y,
107
- inputmode: "decimal",
108
- onFocusChanged: t[0] || (t[0] = (o) => c.value = o),
109
- onWheel: t[1] || (t[1] = C(() => {
110
- }, ["prevent"])),
111
- onTouchmove: t[2] || (t[2] = C(() => {
112
- }, ["prevent"])),
113
- onScroll: t[3] || (t[3] = C(() => {
114
- }, ["prevent"]))
115
- }, {
116
- append: g(() => [
117
- N(e.$slots, "append")
118
- ]),
119
- _: 3
120
- }, 8, ["autofocus", "disabled", "label", "model-value", "placeholder", "prepend-icon"]);
121
- };
122
- }
123
- }), ae = { class: "fm-typo-en-title-md-600" }, te = { class: "space-y-32" }, le = { class: "flex gap-8 items-center justify-start" }, oe = /* @__PURE__ */ S({
124
- __name: "Form",
125
- props: {
126
- action: {},
127
- initialValue: {},
128
- fallback: {},
129
- applyProduct: { type: Boolean },
130
- bindToVariant: { type: Boolean }
131
- },
132
- emits: ["update:takeaway"],
133
- setup(f, { expose: s, emit: a }) {
134
- const u = f, c = a, n = R(), F = E(() => n.rules.takeaway), h = m(!1), i = m(!1), y = (l) => {
135
- j.isBoolean(l) ? i.value = l : i.value = !i.value;
136
- };
137
- function v() {
138
- var o;
139
- const l = {
140
- ...T.generator.initMenuV4Takeaway(),
141
- usedBy: [],
142
- ...H(u.initialValue ?? {})
143
- };
144
- return (o = u.fallback) != null && o.price && (l.price = null), l;
145
- }
146
- const r = m(v()), w = E(() => u.action === "add" ? "Add takeaway" : "Update takeaway"), e = Q(
147
- () => !X.isEqual(
148
- r.value,
149
- u.initialValue || {
150
- ...T.generator.initMenuV4Takeaway(),
151
- usedBy: []
152
- }
153
- ),
154
- () => i.value = !1
155
- );
156
- function t() {
157
- c("update:takeaway", r.value), y(!1);
158
- }
159
- return q(
160
- () => i.value,
161
- () => {
162
- i.value && (r.value = v());
163
- }
164
- ), s({
165
- trigger: y,
166
- show: i
167
- }), (l, o) => {
168
- const B = _("fm-text-field"), b = _("fm-button"), $ = _("fm-side-sheet");
169
- return M(), A(I, null, [
170
- N(l.$slots, "default", { trigger: y }),
171
- p($, {
172
- id: "group-form",
173
- modelValue: i.value,
174
- "onUpdate:modelValue": o[4] || (o[4] = (d) => i.value = d),
175
- "is-container": V(z).FmForm,
176
- "is-container-props": {
177
- onValidationSuccess: t,
178
- blameFormChildOnValidationFailed: !0
179
- },
180
- "max-width": 560,
181
- "z-index": 103,
182
- "onOn:clickedAway": V(e)
183
- }, {
184
- "side-sheet-header": g(() => [
185
- D("p", ae, K(w.value), 1)
186
- ]),
187
- "side-sheet-footer": g(() => [
188
- D("div", le, [
189
- p(b, {
190
- label: V(W)(l.action),
191
- loading: h.value,
192
- size: "lg",
193
- type: "submit",
194
- variant: "primary"
195
- }, null, 8, ["label", "loading"]),
196
- p(b, {
197
- label: "Cancel",
198
- size: "lg",
199
- variant: "tertiary",
200
- onClick: o[3] || (o[3] = () => i.value = !1)
201
- })
202
- ])
203
- ]),
204
- default: g(() => [
205
- D("div", te, [
206
- p(J, null, {
207
- default: g(() => {
208
- var d;
209
- return [
210
- p(B, {
211
- modelValue: r.value.name,
212
- "onUpdate:modelValue": o[0] || (o[0] = (k) => r.value.name = k),
213
- disabled: !F.value.name,
214
- rules: [(k) => !!k || "Takeaway title is required"],
215
- autofocus: "",
216
- label: "Takeaway title",
217
- placeholder: "Enter takeaway title here",
218
- required: "",
219
- title: "Takeaway title"
220
- }, null, 8, ["modelValue", "disabled", "rules"]),
221
- p(ee, {
222
- modelValue: r.value.price,
223
- "onUpdate:modelValue": o[1] || (o[1] = (k) => r.value.price = k),
224
- min: 0,
225
- nullable: !!l.fallback,
226
- placeholder: (d = l.fallback) != null && d.price ? V(Z)(l.fallback.price, !1) : void 0,
227
- label: "Price",
228
- "show-currency": "",
229
- title: "Price"
230
- }, null, 8, ["modelValue", "nullable", "placeholder"])
231
- ];
232
- }),
233
- _: 1
234
- }),
235
- l.applyProduct ? (M(), U(G, {
236
- key: 0,
237
- overrides: r.value.usedBy,
238
- "onUpdate:overrides": o[2] || (o[2] = (d) => r.value.usedBy = d),
239
- "select-variant": l.bindToVariant,
240
- editable: "",
241
- title: "Product"
242
- }, null, 8, ["overrides", "select-variant"])) : O("", !0)
243
- ])
244
- ]),
245
- _: 1
246
- }, 8, ["modelValue", "is-container", "is-container-props", "onOn:clickedAway"])
247
- ], 64);
248
- };
249
- }
250
- }), me = oe;
251
- function fe(f) {
252
- return f.map((s) => ({
253
- module: Y.F_MENU_MODULE_V4_KEY.enum.item,
254
- id: s._id,
255
- discriminator: s.combinationKey,
256
- data: void 0
257
- }));
258
- }
259
- export {
260
- me as T,
261
- ee as _,
262
- oe as a,
263
- fe as l
264
- };
@@ -1,346 +0,0 @@
1
- import { defineStore as G } from "pinia";
2
- import { useSnackbar as P, components as W, useDialog as H, FmButtonVariant as J } from "@feedmepos/ui-library";
3
- import { r as $, s as Q, t as q, d as x, i as B, a as L, m as w, g as X, p as Z, b as h, h as M, u as ee, l as te } from "./app-D7e31gIv.js";
4
- import { defineComponent as N, computed as F, ref as A, watch as S, resolveComponent as f, openBlock as _, createBlock as ne, withCtx as g, createVNode as u, createElementVNode as p, normalizeClass as ae, createElementBlock as E, toDisplayString as k, Fragment as T, renderSlot as le, unref as O, renderList as oe, getCurrentInstance as ie } from "vue";
5
- import "./vuedraggable-WU01qJgi.js";
6
- import { u as se, l as ue } from "./lodash-BIQx_fko.js";
7
- /* empty css */
8
- const re = ["value", "disabled"], me = /* @__PURE__ */ N({
9
- __name: "NumberPrecisionInput",
10
- props: {
11
- modelValue: {},
12
- label: {},
13
- helperText: {},
14
- step: {},
15
- rules: {},
16
- disabled: { type: Boolean }
17
- },
18
- emits: ["update:modelValue"],
19
- setup(b, { emit: y }) {
20
- const a = b, r = y, V = F(() => $(a.step ?? 1).precision), m = A(a.modelValue.toString());
21
- S([() => m.value], ([e]) => {
22
- e === "-" || e === "." ? r("update:modelValue", 0) : r("update:modelValue", +e);
23
- });
24
- const t = (e) => {
25
- if (e.ctrlKey || e.altKey || e.metaKey || ["Backspace", "Tab", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(
26
- e.key
27
- ))
28
- return;
29
- const l = e.currentTarget, n = +`${l.value}${e.key}`;
30
- if (isFinite(n)) {
31
- $(n).precision > V.value && e.preventDefault();
32
- return;
33
- }
34
- l.value.length === 0 && (e.key === "-" || e.key === ".") || e.preventDefault();
35
- };
36
- return (e, l) => {
37
- const n = f("FmField"), d = f("FmFormGroup");
38
- return _(), ne(d, {
39
- disabled: e.disabled,
40
- modelValue: e.modelValue,
41
- rules: e.rules,
42
- "helper-text": e.helperText,
43
- label: e.label
44
- }, {
45
- default: g(({ invalid: v }) => [
46
- u(n, { invalid: v }, {
47
- default: g(() => [
48
- p("input", {
49
- value: m.value,
50
- onInput: l[0] || (l[0] = (i) => m.value = i.target.value),
51
- onKeydown: t,
52
- inputmode: "numeric",
53
- class: ae({
54
- "fm-text-field--input fm-typo-en-body-lg-400": !0,
55
- "text-fm-color-typo-primary": !e.disabled,
56
- "text-fm-color-typo-disabled": e.disabled
57
- }),
58
- disabled: e.disabled
59
- }, null, 42, re)
60
- ]),
61
- _: 2
62
- }, 1032, ["invalid"])
63
- ]),
64
- _: 1
65
- }, 8, ["disabled", "modelValue", "rules", "helper-text", "label"]);
66
- };
67
- }
68
- }), de = { class: "flex flex-col gap-8" }, ce = { class: "flex justify-between" }, pe = { class: "col q-mb-sm t-body-bold" }, ve = { class: "flex flex-row gap-8" }, fe = { class: "q-mt-xs q-pl-sm t-system text-fsecondary" }, be = /* @__PURE__ */ N({
69
- __name: "UnitMeasurement",
70
- props: {
71
- title: {
72
- type: String,
73
- required: !0
74
- },
75
- unitName: {
76
- type: String,
77
- required: !0
78
- },
79
- precision: {
80
- type: Number,
81
- required: !0
82
- },
83
- modelValue: {
84
- type: Object,
85
- required: !0
86
- }
87
- },
88
- emits: ["update:model-value", "delete"],
89
- setup(b, { emit: y }) {
90
- const a = b, r = F(() => Q(a.modelValue.conversion)), V = F(() => `1 ${a.modelValue.name} equal to ${r.value} ${a.unitName}`);
91
- function m(l) {
92
- t("conversion", q(l, a.precision));
93
- }
94
- function t(l, n) {
95
- const d = x(a.modelValue);
96
- d[l] = n, e("update:model-value", d);
97
- }
98
- const e = y;
99
- return S(
100
- () => a.precision,
101
- () => m(r.value)
102
- ), (l, n) => {
103
- const d = f("FmButton"), v = f("FmTextField");
104
- return _(), E("div", de, [
105
- p("div", ce, [
106
- p("div", pe, k(b.title), 1),
107
- u(d, {
108
- icon: "delete",
109
- variant: "secondary",
110
- onClick: n[0] || (n[0] = (i) => e("delete"))
111
- })
112
- ]),
113
- p("div", ve, [
114
- u(v, {
115
- "model-value": a.modelValue.name,
116
- rules: [(i) => i ? !0 : "Name is required"],
117
- label: "Name",
118
- "onUpdate:modelValue": n[1] || (n[1] = (i) => t("name", i.trim()))
119
- }, null, 8, ["model-value", "rules"]),
120
- u(v, {
121
- "model-value": a.modelValue.abbrev,
122
- rules: [(i) => i ? !0 : "Symbol is required"],
123
- label: "Symbol",
124
- "onUpdate:modelValue": n[2] || (n[2] = (i) => t("abbrev", i.trim()))
125
- }, null, 8, ["model-value", "rules"])
126
- ]),
127
- u(me, {
128
- label: "Conversion",
129
- "model-value": r.value,
130
- "onUpdate:modelValue": m,
131
- step: 1 / Math.pow(10, a.precision)
132
- }, null, 8, ["model-value", "step"]),
133
- p("div", fe, "Preview: " + k(V.value), 1)
134
- ]);
135
- };
136
- }
137
- }), ye = { class: "fm-typo-en-title-md-600" }, Ve = { class: "pt-8 space-y-40" }, _e = { class: "flex flex-row gap-16" }, ge = { class: "flex gap-8 items-center justify-start" }, Fe = /* @__PURE__ */ N({
138
- __name: "Form",
139
- props: {
140
- initialValue: {}
141
- },
142
- setup(b, { expose: y }) {
143
- const a = b, r = B(L(P())), V = F(() => a.initialValue ? "Update unit" : "Add unit"), m = F(() => a.initialValue ? "Update" : "Add"), t = A(a.initialValue ? x(a.initialValue) : w.generator.initUnit()), e = A(!1), l = A(!1), n = (o) => {
144
- X.isBoolean(o) ? l.value = o : l.value = !l.value;
145
- };
146
- function d() {
147
- t.value.measurements = t.value.measurements.map((o) => ({
148
- ...o,
149
- conversion: Z(o.conversion, t.value.precision)
150
- }));
151
- }
152
- function v() {
153
- t.value.measurements.push({
154
- id: (/* @__PURE__ */ new Date()).toISOString(),
155
- name: "",
156
- abbrev: "",
157
- conversion: q(0, t.value.precision)
158
- });
159
- }
160
- function i(o) {
161
- t.value.measurements.splice(o, 1);
162
- }
163
- const j = se(
164
- () => !ue.isEqual(t.value, a.initialValue || w.generator.initUnit()),
165
- () => {
166
- l.value = !1;
167
- }
168
- ), I = async () => {
169
- try {
170
- e.value = !0;
171
- const o = x(t.value);
172
- a.initialValue ? await r.updateMenu(
173
- {
174
- module: h.F_MENU_MODULE_V4_KEY.enum.unit,
175
- operation: M.F_OPERATION_TYPE.update,
176
- data: o
177
- },
178
- o.name
179
- ) : await r.updateMenu(
180
- {
181
- module: h.F_MENU_MODULE_V4_KEY.enum.unit,
182
- operation: M.F_OPERATION_TYPE.create,
183
- data: o
184
- },
185
- o.name
186
- ), n(!1), t.value = w.generator.initUnit();
187
- } finally {
188
- e.value = !1;
189
- }
190
- };
191
- return S(
192
- () => l.value,
193
- (o) => {
194
- o && (t.value = a.initialValue ? x(a.initialValue) : w.generator.initUnit());
195
- }
196
- ), y({
197
- show: l,
198
- trigger: n
199
- }), (o, c) => {
200
- const C = f("FmTextField"), K = f("FmStepperField"), R = f("FmButton"), D = f("fm-button"), Y = f("fm-side-sheet");
201
- return _(), E(T, null, [
202
- le(o.$slots, "default", { trigger: n }),
203
- u(Y, {
204
- id: "unit-form",
205
- modelValue: l.value,
206
- "onUpdate:modelValue": c[4] || (c[4] = (s) => l.value = s),
207
- "is-container": O(W).FmForm,
208
- "is-container-props": {
209
- onValidationSuccess: I,
210
- blameFormChildOnValidationFailed: !0
211
- },
212
- "max-width": 560,
213
- "z-index": 100,
214
- "onOn:clickedAway": O(j)
215
- }, {
216
- "side-sheet-header": g(() => [
217
- p("p", ye, k(V.value), 1)
218
- ]),
219
- "side-sheet-footer": g(() => [
220
- p("div", ge, [
221
- u(D, {
222
- label: m.value,
223
- loading: e.value,
224
- size: "lg",
225
- type: "submit",
226
- variant: "primary"
227
- }, null, 8, ["label", "loading"]),
228
- u(D, {
229
- label: "Cancel",
230
- size: "lg",
231
- variant: "tertiary",
232
- onClick: c[3] || (c[3] = () => l.value = !1)
233
- })
234
- ])
235
- ]),
236
- default: g(() => [
237
- p("div", Ve, [
238
- p("div", _e, [
239
- u(C, {
240
- class: "flex-2",
241
- label: "Name",
242
- modelValue: t.value.name,
243
- "onUpdate:modelValue": c[0] || (c[0] = (s) => t.value.name = s),
244
- rules: [(s) => s ? !0 : "Unit name is required"]
245
- }, null, 8, ["modelValue", "rules"]),
246
- u(C, {
247
- class: "flex-1",
248
- label: "Symbol",
249
- modelValue: t.value.abbrev,
250
- "onUpdate:modelValue": c[1] || (c[1] = (s) => t.value.abbrev = s),
251
- rules: [(s) => s ? !0 : "Unit symbol is required"]
252
- }, null, 8, ["modelValue", "rules"])
253
- ]),
254
- p("div", null, [
255
- u(K, {
256
- modelValue: t.value.precision,
257
- "onUpdate:modelValue": [
258
- c[2] || (c[2] = (s) => t.value.precision = s),
259
- d
260
- ],
261
- label: "Precision",
262
- placeholder: "Enter a number",
263
- step: 1,
264
- min: 0,
265
- max: 5
266
- }, null, 8, ["modelValue"])
267
- ]),
268
- u(R, {
269
- label: "Add measurement",
270
- variant: "secondary",
271
- onClick: v
272
- }),
273
- (_(!0), E(T, null, oe(t.value.measurements, (s, U) => (_(), E("div", {
274
- key: s.id
275
- }, [
276
- u(be, {
277
- modelValue: t.value.measurements[U],
278
- "onUpdate:modelValue": (z) => t.value.measurements[U] = z,
279
- "unit-name": t.value.name,
280
- title: `Measurement ${U + 1}`,
281
- precision: t.value.precision,
282
- onDelete: () => i(U)
283
- }, null, 8, ["modelValue", "onUpdate:modelValue", "unit-name", "title", "precision", "onDelete"])
284
- ]))), 128))
285
- ])
286
- ]),
287
- _: 1
288
- }, 8, ["modelValue", "is-container", "is-container-props", "onOn:clickedAway"])
289
- ], 64);
290
- };
291
- }
292
- }), Ue = Fe, Ne = G("unit-manager", () => {
293
- const b = H(), y = P(), a = L(y), r = B(a);
294
- ee();
295
- const V = ie(), m = (n) => {
296
- var v, i;
297
- const { vNode: d } = te(
298
- Ue,
299
- V,
300
- n
301
- );
302
- (i = (v = d.component) == null ? void 0 : v.exposed) == null || i.trigger();
303
- };
304
- async function t() {
305
- m({});
306
- }
307
- async function e(n) {
308
- m({
309
- initialValue: n
310
- });
311
- }
312
- async function l(n) {
313
- b.open({
314
- title: "Remove unit",
315
- message: `Do you want to remove unit ${n.name}?`,
316
- primaryActions: {
317
- text: "Remove",
318
- close: !0,
319
- variant: J.Destructive
320
- },
321
- secondaryActions: {
322
- text: "Cancel",
323
- close: !0
324
- }
325
- }).onPrimary(async () => {
326
- await r.updateMenu(
327
- {
328
- module: h.F_MENU_MODULE_V4_KEY.enum.unit,
329
- operation: M.F_OPERATION_TYPE.delete,
330
- data: n._id
331
- },
332
- n.name,
333
- !0
334
- );
335
- });
336
- }
337
- return {
338
- createUnit: t,
339
- deleteUnit: l,
340
- updateUnit: e
341
- };
342
- });
343
- export {
344
- Ue as U,
345
- Ne as u
346
- };