@verdnatura/vn-front-lib 0.1.6 → 0.1.8

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,1227 @@
1
+ import { _ as e, g as t, h as n, m as r, p as i, t as a, u as o, v as s } from "./composables-xGr9z2hA.js";
2
+ import { useStateStore as c } from "./stores.js";
3
+ import { onBeforeSave as l } from "./filters.js";
4
+ import { Fragment as u, Teleport as d, Transition as f, computed as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, createSlots as v, createTextVNode as y, createVNode as b, mergeModels as x, mergeProps as ee, nextTick as S, normalizeClass as C, normalizeStyle as w, onMounted as T, onUnmounted as E, openBlock as D, ref as O, renderSlot as k, toDisplayString as A, unref as j, useAttrs as te, useModel as M, vShow as N, watch as P, withCtx as F, withDirectives as I, withKeys as L, withModifiers as ne } from "vue";
5
+ import * as R from "quasar";
6
+ import { QAvatar as z, QBtn as B, QBtnGroup as re, QCard as ie, QCardActions as V, QCardSection as ae, QDate as oe, QDialog as H, QForm as se, QIcon as U, QInnerLoading as ce, QInput as W, QMenu as G, QSkeleton as K, QSpace as q, QTooltip as J, date as Y, getCssVar as X } from "quasar";
7
+ import { useI18n as le } from "vue-i18n";
8
+ import ue from "axios";
9
+ import { onBeforeRouteLeave as de, useRoute as fe, useRouter as pe } from "vue-router";
10
+ //#region lib/components/dialogs/VnConfirm.vue?vue&type=i18n&index=0&lang.i18n
11
+ function me(e) {
12
+ let t = e;
13
+ t.__i18n = t.__i18n || [], t.__i18n.push({
14
+ locale: "",
15
+ resource: { es: {
16
+ Confirm: {
17
+ t: 0,
18
+ b: {
19
+ t: 2,
20
+ i: [{ t: 3 }],
21
+ s: "Confirmar"
22
+ }
23
+ },
24
+ "Are you sure you want to continue?": {
25
+ t: 0,
26
+ b: {
27
+ t: 2,
28
+ i: [{ t: 3 }],
29
+ s: "¿Seguro que quieres continuar?"
30
+ }
31
+ }
32
+ } }
33
+ });
34
+ }
35
+ //#endregion
36
+ //#region \0plugin-vue:export-helper
37
+ var Z = (e, t) => {
38
+ let n = e.__vccOpts || e;
39
+ for (let [e, r] of t) n[e] = r;
40
+ return n;
41
+ }, he = { class: "text-h6" }, Q = ["innerHTML"], ge = {
42
+ __name: "VnConfirm",
43
+ props: {
44
+ icon: {
45
+ type: String,
46
+ default: null
47
+ },
48
+ title: {
49
+ type: String,
50
+ default: null
51
+ },
52
+ message: {
53
+ type: [String, Boolean],
54
+ default: null
55
+ },
56
+ data: {
57
+ type: Object,
58
+ required: !1,
59
+ default: null
60
+ },
61
+ promise: {
62
+ type: Function,
63
+ required: !1,
64
+ default: null
65
+ },
66
+ persistent: {
67
+ type: Boolean,
68
+ default: !1
69
+ },
70
+ closable: {
71
+ type: Boolean,
72
+ default: !0
73
+ },
74
+ cardClass: {
75
+ type: String,
76
+ default: null
77
+ }
78
+ },
79
+ emits: [
80
+ "confirm",
81
+ "cancel",
82
+ ...R.useDialogPluginComponent.emits
83
+ ],
84
+ setup(e, { expose: t, emit: n }) {
85
+ let { t: r } = le(), i = e, a = n;
86
+ t({
87
+ show: () => o.value.show(),
88
+ hide: () => o.value.hide()
89
+ });
90
+ let { dialogRef: o, onDialogHide: s, onDialogOK: c, onDialogCancel: l } = R.useDialogPluginComponent(), u = i.title || r("Confirm"), d = i.message || i.message !== !1 && r("Are you sure you want to continue?"), f = O(!1);
91
+ async function p() {
92
+ if (f.value = !0, i.promise) try {
93
+ await i.promise(i.data);
94
+ } finally {
95
+ f.value = !1;
96
+ }
97
+ c(i.data);
98
+ }
99
+ function v() {
100
+ a("cancel"), l();
101
+ }
102
+ return (t, n) => (D(), m(j(H), {
103
+ ref_key: "dialogRef",
104
+ ref: o,
105
+ persistent: e.persistent,
106
+ onHide: j(s)
107
+ }, {
108
+ default: F(() => [b(j(ie), { class: C(["q-pa-sm", e.cardClass]) }, {
109
+ default: F(() => [
110
+ b(j(ae), { class: "row items-center q-pb-none" }, {
111
+ default: F(() => [
112
+ e.icon ? (D(), m(j(z), {
113
+ key: 0,
114
+ icon: e.icon,
115
+ color: "primary",
116
+ "text-color": "white",
117
+ size: "xl"
118
+ }, null, 8, ["icon"])) : h("", !0),
119
+ _("span", he, A(j(u)), 1),
120
+ b(j(q)),
121
+ e.closable ? (D(), m(j(B), {
122
+ key: 1,
123
+ icon: "close",
124
+ disable: f.value,
125
+ flat: "",
126
+ round: "",
127
+ dense: "",
128
+ onClick: n[0] ||= (e) => v()
129
+ }, null, 8, ["disable"])) : h("", !0)
130
+ ]),
131
+ _: 1
132
+ }),
133
+ b(j(ae), {
134
+ class: "q-pb-none",
135
+ "data-cy": "VnConfirm_message"
136
+ }, {
137
+ default: F(() => [j(d) === !1 ? h("", !0) : (D(), g("span", {
138
+ key: 0,
139
+ innerHTML: j(d)
140
+ }, null, 8, Q))]),
141
+ _: 1
142
+ }),
143
+ b(j(ae), { class: "row items-center q-pt-none" }, {
144
+ default: F(() => [k(t.$slots, "custom-html", {}, void 0, !0)]),
145
+ _: 3
146
+ }),
147
+ t.$slots.actions ? (D(), m(j(V), {
148
+ key: 0,
149
+ align: "right"
150
+ }, {
151
+ default: F(() => [k(t.$slots, "actions", { actions: {
152
+ confirm: p,
153
+ cancel: v
154
+ } }, void 0, !0)]),
155
+ _: 3
156
+ })) : (D(), m(j(V), {
157
+ key: 1,
158
+ align: "right"
159
+ }, {
160
+ default: F(() => [b(j(B), {
161
+ label: j(r)("globals.cancel"),
162
+ color: "primary",
163
+ disable: f.value,
164
+ flat: "",
165
+ onClick: n[1] ||= (e) => v(),
166
+ "data-cy": "VnConfirm_cancel"
167
+ }, null, 8, ["label", "disable"]), b(j(B), {
168
+ label: j(r)("globals.confirm"),
169
+ title: j(r)("globals.confirm"),
170
+ color: "primary",
171
+ loading: f.value,
172
+ onClick: n[2] ||= (e) => p(),
173
+ unelevated: "",
174
+ autofocus: "",
175
+ "data-cy": "VnConfirm_confirm"
176
+ }, null, 8, [
177
+ "label",
178
+ "title",
179
+ "loading"
180
+ ])]),
181
+ _: 1
182
+ }))
183
+ ]),
184
+ _: 3
185
+ }, 8, ["class"])]),
186
+ _: 3
187
+ }, 8, ["persistent", "onHide"]));
188
+ }
189
+ };
190
+ typeof me == "function" && me(ge);
191
+ var _e = /*#__PURE__*/ Z(ge, [["__scopeId", "data-v-087d2dc1"]]), ve = { class: "row q-gutter-md q-mb-md" }, ye = { class: "row q-gutter-md q-mb-md" }, $ = { class: "row q-gutter-md q-mb-md" }, be = {
192
+ __name: "VnSkeletonForm",
193
+ setup(e) {
194
+ return (e, t) => (D(), g(u, null, [
195
+ _("div", ve, [b(j(K), {
196
+ type: "QInput",
197
+ class: "col",
198
+ square: ""
199
+ }), b(j(K), {
200
+ type: "QInput",
201
+ class: "col",
202
+ square: ""
203
+ })]),
204
+ _("div", ye, [b(j(K), {
205
+ type: "QInput",
206
+ class: "col",
207
+ square: ""
208
+ }), b(j(K), {
209
+ type: "QInput",
210
+ class: "col",
211
+ square: ""
212
+ })]),
213
+ _("div", $, [b(j(K), {
214
+ type: "QInput",
215
+ class: "col",
216
+ square: ""
217
+ }), b(j(K), {
218
+ type: "QInput",
219
+ class: "col",
220
+ square: ""
221
+ })])
222
+ ], 64));
223
+ }
224
+ }, xe = /*#__PURE__*/ Z({
225
+ __name: "VnSpinner",
226
+ props: {
227
+ size: {
228
+ type: String,
229
+ default: "40px"
230
+ },
231
+ noTransition: {
232
+ type: Boolean,
233
+ default: !1
234
+ }
235
+ },
236
+ setup(e) {
237
+ let t = {
238
+ xs: "16px",
239
+ sm: "24px",
240
+ md: "40px",
241
+ lg: "56px",
242
+ xl: "72px"
243
+ };
244
+ return (n, r) => e.noTransition ? (D(), g("div", {
245
+ key: 1,
246
+ class: "vn-spinner",
247
+ style: w({
248
+ width: t[e.size] || e.size,
249
+ height: t[e.size] || e.size
250
+ })
251
+ }, null, 4)) : (D(), m(f, {
252
+ key: 0,
253
+ name: "vn-spinner-fade",
254
+ appear: ""
255
+ }, {
256
+ default: F(() => [_("div", {
257
+ class: "vn-spinner",
258
+ style: w({
259
+ width: t[e.size] || e.size,
260
+ height: t[e.size] || e.size
261
+ })
262
+ }, null, 4)]),
263
+ _: 1
264
+ }));
265
+ }
266
+ }, [["__scopeId", "data-v-e5edebae"]]), Se = /*#__PURE__*/ Z({
267
+ __name: "VnDate",
268
+ props: {
269
+ modelValue: {
270
+ type: [String, Number],
271
+ default: ""
272
+ },
273
+ modelModifiers: {}
274
+ },
275
+ emits: ["update:modelValue"],
276
+ setup(e) {
277
+ let t = M(e, "modelValue");
278
+ return (e, n) => (D(), m(j(oe), {
279
+ modelValue: t.value,
280
+ "onUpdate:modelValue": n[0] ||= (e) => t.value = e,
281
+ "today-btn": !0,
282
+ options: e.$attrs.options,
283
+ autocomplete: "off"
284
+ }, null, 8, ["modelValue", "options"]));
285
+ }
286
+ }, [["__scopeId", "data-v-8338d4d1"]]);
287
+ //#endregion
288
+ //#region lib/components/inputs/VnInput.vue?vue&type=i18n&index=0&lang.i18n
289
+ function Ce(e) {
290
+ let t = e;
291
+ t.__i18n = t.__i18n || [], t.__i18n.push({
292
+ locale: "",
293
+ resource: {
294
+ en: {
295
+ inputMin: {
296
+ t: 0,
297
+ b: {
298
+ t: 2,
299
+ i: [{
300
+ t: 3,
301
+ v: "Must be more than "
302
+ }, {
303
+ t: 4,
304
+ k: "value"
305
+ }]
306
+ }
307
+ },
308
+ maxLength: {
309
+ t: 0,
310
+ b: {
311
+ t: 2,
312
+ i: [
313
+ {
314
+ t: 3,
315
+ v: "The value exceeds "
316
+ },
317
+ {
318
+ t: 4,
319
+ k: "value"
320
+ },
321
+ {
322
+ t: 3,
323
+ v: " characters"
324
+ }
325
+ ]
326
+ }
327
+ },
328
+ inputMax: {
329
+ t: 0,
330
+ b: {
331
+ t: 2,
332
+ i: [{
333
+ t: 3,
334
+ v: "Must be less than "
335
+ }, {
336
+ t: 4,
337
+ k: "value"
338
+ }]
339
+ }
340
+ }
341
+ },
342
+ es: {
343
+ inputMin: {
344
+ t: 0,
345
+ b: {
346
+ t: 2,
347
+ i: [{
348
+ t: 3,
349
+ v: "Debe ser mayor a "
350
+ }, {
351
+ t: 4,
352
+ k: "value"
353
+ }]
354
+ }
355
+ },
356
+ maxLength: {
357
+ t: 0,
358
+ b: {
359
+ t: 2,
360
+ i: [
361
+ {
362
+ t: 3,
363
+ v: "El valor excede los "
364
+ },
365
+ {
366
+ t: 4,
367
+ k: "value"
368
+ },
369
+ {
370
+ t: 3,
371
+ v: " carácteres"
372
+ }
373
+ ]
374
+ }
375
+ },
376
+ inputMax: {
377
+ t: 0,
378
+ b: {
379
+ t: 2,
380
+ i: [{
381
+ t: 3,
382
+ v: "Debe ser menor a "
383
+ }, {
384
+ t: 4,
385
+ k: "value"
386
+ }]
387
+ }
388
+ },
389
+ "Convert to uppercase": {
390
+ t: 0,
391
+ b: {
392
+ t: 2,
393
+ i: [{ t: 3 }],
394
+ s: "Convertir a mayúsculas"
395
+ }
396
+ },
397
+ Remove: {
398
+ t: 0,
399
+ b: {
400
+ t: 2,
401
+ i: [{ t: 3 }],
402
+ s: "Eliminar"
403
+ }
404
+ }
405
+ }
406
+ }
407
+ });
408
+ }
409
+ //#endregion
410
+ //#region lib/components/inputs/VnInput.vue
411
+ var we = {
412
+ __name: "VnInput",
413
+ props: /*@__PURE__*/ x({
414
+ isOutlined: {
415
+ type: Boolean,
416
+ default: !1
417
+ },
418
+ info: {
419
+ type: String,
420
+ default: ""
421
+ },
422
+ clearable: {
423
+ type: Boolean,
424
+ default: !0
425
+ },
426
+ emptyToNull: {
427
+ type: Boolean,
428
+ default: !0
429
+ },
430
+ insertable: {
431
+ type: Boolean,
432
+ default: !1
433
+ },
434
+ maxlength: {
435
+ type: Number,
436
+ default: null
437
+ },
438
+ uppercase: {
439
+ type: Boolean,
440
+ default: !1
441
+ },
442
+ clearOnHover: {
443
+ type: Boolean,
444
+ default: !1
445
+ }
446
+ }, {
447
+ modelValue: { default: null },
448
+ modelModifiers: {}
449
+ }),
450
+ emits: /*@__PURE__*/ x(["remove"], ["update:modelValue"]),
451
+ setup(e, { expose: n, emit: r }) {
452
+ let i = te(), { isRequired: a, requiredFieldRule: o } = t(i), { t: s } = le(), c = r, l = e, u = M(e, "modelValue"), d = [
453
+ "number",
454
+ "search",
455
+ "tel",
456
+ "url",
457
+ "password"
458
+ ], f = (e) => {
459
+ let t = e;
460
+ l.emptyToNull && t === "" && (t = null), u.value = t;
461
+ }, _ = O(null), x = O(!1), C = p(() => l.isOutlined ? {
462
+ dense: !0,
463
+ outlined: !0,
464
+ rounded: !0
465
+ } : {}), E = (e) => {
466
+ _.value?.focus(e);
467
+ }, P = (e) => {
468
+ S(() => {
469
+ let t = e.target || _.value?.$el?.querySelector("input"), n = e.target.type || t?.getAttribute("type");
470
+ if (n !== "email") {
471
+ if (!d.includes(n)) {
472
+ if (t?.setSelectionRange) {
473
+ let e = t.value?.length ?? 0;
474
+ t.setSelectionRange(e, e);
475
+ }
476
+ return;
477
+ }
478
+ t?.select?.();
479
+ }
480
+ });
481
+ };
482
+ n({
483
+ focus: E,
484
+ vnInputRef: _
485
+ });
486
+ let L = p(() => [
487
+ o,
488
+ ...i.rules ?? [],
489
+ (e) => {
490
+ let t = l.maxlength;
491
+ if (t && +e?.length > t) return s("maxLength", { value: t });
492
+ let { min: n, max: r } = i, a = n === void 0 ? void 0 : Number(n), o = r === void 0 ? void 0 : Number(r);
493
+ return a !== void 0 && a >= 0 && Math.floor(e) < a ? s("inputMin", { value: a }) : o !== void 0 && o > 0 && Math.floor(e) > o ? s("inputMax", { value: o }) : !0;
494
+ }
495
+ ]), ne = (e) => {
496
+ e.key !== "Backspace" && l.insertable && e.key.match(/[0-9]/) && R(e);
497
+ }, R = (e) => {
498
+ e.preventDefault();
499
+ let t = e.target, n = t.selectionStart, r = l.maxlength, i = u.value;
500
+ i ||= e.key;
501
+ let a = e.key;
502
+ a && !isNaN(a) && n < r && f(i.substring(0, n) + a + i.substring(n + 1)), S(() => {
503
+ t.setSelectionRange(n + 1, n + 1);
504
+ });
505
+ }, z = () => {
506
+ u.value = u.value?.toUpperCase() || "";
507
+ };
508
+ return T(() => {
509
+ i.autofocus && E();
510
+ }), (t, n) => (D(), g("div", {
511
+ onMouseover: n[1] ||= (e) => x.value = !0,
512
+ onMouseleave: n[2] ||= (e) => x.value = !1
513
+ }, [b(j(W), ee({
514
+ ref_key: "vnInputRef",
515
+ ref: _,
516
+ "model-value": j(u),
517
+ "onUpdate:modelValue": f
518
+ }, {
519
+ ...j(i),
520
+ ...C.value
521
+ }, {
522
+ class: { required: j(a) },
523
+ onKeydown: ne,
524
+ onFocus: P,
525
+ clearable: !1,
526
+ rules: L.value,
527
+ "lazy-rules": !0,
528
+ "hide-bottom-space": "",
529
+ "data-cy": (j(i)["data-cy"] ?? j(i).label) + "_input",
530
+ dense: ""
531
+ }), v({
532
+ append: F(() => [
533
+ I(b(j(U), {
534
+ name: "close",
535
+ size: "xs",
536
+ class: "cursor-pointer",
537
+ style: w({ visibility: x.value && j(u) && !j(i).disabled && !j(i).readonly && l.clearable ? "visible" : "hidden" }),
538
+ onClick: n[0] ||= () => {
539
+ f(null), _.value?.focus(), c("remove");
540
+ }
541
+ }, {
542
+ default: F(() => [b(j(J), null, {
543
+ default: F(() => [y(A(j(s)("Remove")), 1)]),
544
+ _: 1
545
+ })]),
546
+ _: 1
547
+ }, 8, ["style"]), [[N, !e.clearOnHover || x.value]]),
548
+ !j(i).disabled && !j(i).readonly && l.uppercase ? (D(), m(j(U), {
549
+ key: 0,
550
+ name: "match_case",
551
+ size: "xs",
552
+ onClick: z,
553
+ class: "uppercase-icon"
554
+ }, {
555
+ default: F(() => [b(j(J), null, {
556
+ default: F(() => [y(A(j(s)("Convert to uppercase")), 1)]),
557
+ _: 1
558
+ })]),
559
+ _: 1
560
+ })) : h("", !0),
561
+ t.$slots.append && !j(i).disabled ? k(t.$slots, "append", {}, void 0, void 0, 1) : h("", !0),
562
+ e.info ? (D(), m(j(U), {
563
+ key: 2,
564
+ name: "info"
565
+ }, {
566
+ default: F(() => [b(j(J), { "max-width": "350px" }, {
567
+ default: F(() => [y(A(e.info), 1)]),
568
+ _: 1
569
+ })]),
570
+ _: 1
571
+ })) : h("", !0)
572
+ ]),
573
+ _: 2
574
+ }, [t.$slots.hint ? {
575
+ name: "hint",
576
+ fn: F(() => [k(t.$slots, "hint")]),
577
+ key: "0"
578
+ } : void 0, t.$slots.prepend ? {
579
+ name: "prepend",
580
+ fn: F(() => [k(t.$slots, "prepend")]),
581
+ key: "1"
582
+ } : void 0]), 1040, [
583
+ "model-value",
584
+ "class",
585
+ "rules",
586
+ "data-cy"
587
+ ])], 32));
588
+ }
589
+ };
590
+ typeof Ce == "function" && Ce(we);
591
+ //#endregion
592
+ //#region lib/components/inputs/VnInputDate.vue?vue&type=i18n&index=0&lang.i18n
593
+ function Te(e) {
594
+ let t = e;
595
+ t.__i18n = t.__i18n || [], t.__i18n.push({
596
+ locale: "",
597
+ resource: { es: {
598
+ "Open date": {
599
+ t: 0,
600
+ b: {
601
+ t: 2,
602
+ i: [{ t: 3 }],
603
+ s: "Abrir fecha"
604
+ }
605
+ },
606
+ Remove: {
607
+ t: 0,
608
+ b: {
609
+ t: 2,
610
+ i: [{ t: 3 }],
611
+ s: "Eliminar"
612
+ }
613
+ }
614
+ } }
615
+ });
616
+ }
617
+ //#endregion
618
+ //#region lib/components/inputs/VnInputDate.vue
619
+ var Ee = "DD/MM/YYYY", De = {
620
+ __name: "VnInputDate",
621
+ props: /*@__PURE__*/ x({
622
+ isOutlined: {
623
+ type: Boolean,
624
+ default: !1
625
+ },
626
+ showEvent: {
627
+ type: Boolean,
628
+ default: !0
629
+ },
630
+ hideYearNavigation: {
631
+ type: Boolean,
632
+ default: !1
633
+ },
634
+ clearOnHover: {
635
+ type: Boolean,
636
+ default: !1
637
+ }
638
+ }, {
639
+ modelValue: { type: [
640
+ String,
641
+ Date,
642
+ Object
643
+ ] },
644
+ modelModifiers: {}
645
+ }),
646
+ emits: ["update:modelValue"],
647
+ setup(e) {
648
+ let n = te(), { t: r } = le(), { isRequired: i, requiredFieldRule: a } = t(n), o = M(e, "modelValue"), s = e, c = O(null), l = X("negative"), u = O(""), d = O(), f = O(), _ = [a, ...n.rules ?? []], v = p(() => o.value?.neq || o.value?.nin || o.value), x = p(() => {
649
+ if (v.value) return Array.isArray(v.value) ? v.value.map((e) => Y.formatDate(new Date(e), Ee)).join(", ") : Y.formatDate(new Date(v.value), Ee);
650
+ }), C = p(() => {
651
+ let e = Array.isArray(v.value) ? v.value[0] : v.value;
652
+ return e && Y.formatDate(new Date(e), "YYYY/MM/DD");
653
+ }), w = p(() => s.isOutlined ? {
654
+ dense: !0,
655
+ outlined: !0,
656
+ rounded: !0
657
+ } : {}), T = O(""), E = n["data-cy"] ?? n.label, k = E + "_menu", N = E + "_inputDate", I = (e) => {
658
+ if (!e && n.clearable) {
659
+ T.value = null, o.value = null;
660
+ return;
661
+ }
662
+ T.value = e.replace(/[^0-9./-]/g, "");
663
+ }, R = (e) => {
664
+ e && (T.value = e.split("/").reverse().join("/"), z(), d.value = !1);
665
+ };
666
+ P(() => o.value, () => {
667
+ let e = Array.isArray(v.value) ? v.value[0] : v.value;
668
+ T.value = e ? Y.formatDate(new Date(e), Ee) : "";
669
+ }, { immediate: !0 }), P(d, (e) => {
670
+ e && s.hideYearNavigation && S(() => {
671
+ let e = [
672
+ "back",
673
+ "type",
674
+ "forward"
675
+ ];
676
+ document.querySelectorAll(".q-date__navigation").forEach((t) => {
677
+ for (let n = 0; n < e.length; n++) t.lastElementChild && t.removeChild(t.lastElementChild);
678
+ });
679
+ });
680
+ });
681
+ let z = () => {
682
+ let e = T.value;
683
+ if (!e || e === o.value) {
684
+ u.value = "";
685
+ return;
686
+ }
687
+ if (!/^([0]?[1-9]|[12][0-9]|3[01])([./-])([0]?[1-9]|1[0-2])([./-](\d{1,4}))?$/.test(e)) {
688
+ u.value = l;
689
+ return;
690
+ }
691
+ e = e.replace(/[.-]/g, "/");
692
+ let t = e.split("/");
693
+ if (t.length < 2) {
694
+ u.value = l;
695
+ return;
696
+ }
697
+ let [n, r, i] = t;
698
+ n.length === 1 && (n = "0" + n), r.length === 1 && (r = "0" + r);
699
+ let a = Date.vnNew().getFullYear();
700
+ i ||= a;
701
+ let s = a.toString().slice(0, 1);
702
+ switch (i.length) {
703
+ case 1:
704
+ i = `${s}00${i}`;
705
+ break;
706
+ case 2:
707
+ i = `${s}0${i}`;
708
+ break;
709
+ case 3: i = `${s}${i}`;
710
+ }
711
+ let c = `${i}/${r}/${n}`;
712
+ c = Y.formatDate(new Date(c).toISOString(), "YYYY-MM-DDTHH:mm:ss.SSSZ");
713
+ let [d, f, p] = c.split("-").map((e) => parseInt(e)), m = new Date(d, f - 1, p);
714
+ if (!(m instanceof Date && !isNaN(m) && m.getFullYear() === parseInt(i) && m.getMonth() === parseInt(r) - 1 && m.getDate() === parseInt(n))) {
715
+ u.value = l;
716
+ return;
717
+ }
718
+ if (v.value) {
719
+ let e = Array.isArray(v.value) ? v.value[0] : v.value, t = e instanceof Date ? e : new Date(e);
720
+ m.setHours(t.getHours(), t.getMinutes(), t.getSeconds(), t.getMilliseconds());
721
+ }
722
+ let h = m.toISOString();
723
+ o.value?.neq ? o.value = { neq: h } : o.value?.nin ? o.value = { nin: [...o.value.nin, h] } : o.value = h, u.value = "";
724
+ }, B = (e) => {
725
+ z(), S(() => {
726
+ let e = new KeyboardEvent("keydown", {
727
+ key: "Enter",
728
+ code: "Enter",
729
+ bubbles: !0,
730
+ cancelable: !0
731
+ });
732
+ c.value?.$el?.dispatchEvent(e);
733
+ });
734
+ };
735
+ return (t, a) => (D(), g("div", {
736
+ onMouseover: a[8] ||= (e) => f.value = !0,
737
+ onMouseleave: a[9] ||= (e) => f.value = !1
738
+ }, [b(j(W), ee({
739
+ ref_key: "vnInputDateRef",
740
+ ref: c,
741
+ modelValue: T.value,
742
+ "onUpdate:modelValue": a[5] ||= (e) => T.value = e,
743
+ class: "vn-input-date",
744
+ placeholder: "dd/mm/aaaa"
745
+ }, {
746
+ ...j(n),
747
+ ...w.value
748
+ }, {
749
+ class: { required: j(i) },
750
+ rules: _,
751
+ clearable: !1,
752
+ "input-style": { color: u.value },
753
+ "input-class": { "text-strike": !!(o.value?.neq || o.value?.nin) },
754
+ title: x.value,
755
+ onClick: a[6] ||= (e) => d.value = !d.value,
756
+ onKeydown: [a[7] ||= (e) => d.value = !1, L(ne(B, ["prevent"]), ["enter"])],
757
+ onFocusout: z,
758
+ "hide-bottom-space": "",
759
+ "data-cy": N,
760
+ "onUpdate:modelValue": I,
761
+ autocomplete: "off"
762
+ }), {
763
+ append: F(() => [(j(n).clearable == null || j(n).clearable) && (!e.clearOnHover || f.value) && T.value && !j(n).disable ? (D(), m(j(U), {
764
+ key: 0,
765
+ name: "close",
766
+ size: "xs",
767
+ class: "cursor-pointer",
768
+ onClick: a[0] ||= (e) => {
769
+ c.value.focus(), T.value = null, o.value = null, d.value = !1;
770
+ }
771
+ }, {
772
+ default: F(() => [b(j(J), null, {
773
+ default: F(() => [y(A(j(r)("Remove")), 1)]),
774
+ _: 1
775
+ })]),
776
+ _: 1
777
+ })) : h("", !0)]),
778
+ default: F(() => [t.$q.screen.gt.xs ? (D(), m(j(G), {
779
+ key: 0,
780
+ "transition-show": "scale",
781
+ "transition-hide": "scale",
782
+ modelValue: d.value,
783
+ "onUpdate:modelValue": a[2] ||= (e) => d.value = e,
784
+ anchor: "bottom left",
785
+ self: "top start",
786
+ "no-focus": !0,
787
+ "no-parent-event": !0,
788
+ "data-cy": k
789
+ }, {
790
+ default: F(() => [b(Se, {
791
+ modelValue: C.value,
792
+ "onUpdate:modelValue": [a[1] ||= (e) => C.value = e, R]
793
+ }, null, 8, ["modelValue"])]),
794
+ _: 1
795
+ }, 8, ["modelValue"])) : (D(), m(j(H), {
796
+ key: 1,
797
+ modelValue: d.value,
798
+ "onUpdate:modelValue": a[4] ||= (e) => d.value = e
799
+ }, {
800
+ default: F(() => [b(Se, {
801
+ modelValue: C.value,
802
+ "onUpdate:modelValue": [a[3] ||= (e) => C.value = e, R]
803
+ }, null, 8, ["modelValue"])]),
804
+ _: 1
805
+ }, 8, ["modelValue"]))]),
806
+ _: 1
807
+ }, 16, [
808
+ "modelValue",
809
+ "class",
810
+ "input-style",
811
+ "input-class",
812
+ "title",
813
+ "onKeydown"
814
+ ])], 32));
815
+ }
816
+ };
817
+ typeof Te == "function" && Te(De);
818
+ //#endregion
819
+ //#region lib/components/models/VnFetch.vue
820
+ var Oe = {
821
+ __name: "VnFetch",
822
+ props: {
823
+ autoLoad: {
824
+ type: Boolean,
825
+ default: !1
826
+ },
827
+ url: {
828
+ type: String,
829
+ default: ""
830
+ },
831
+ filter: {
832
+ type: Object,
833
+ default: null
834
+ },
835
+ where: {
836
+ type: Object,
837
+ default: null
838
+ },
839
+ sortBy: {
840
+ type: String,
841
+ default: ""
842
+ },
843
+ limit: {
844
+ type: [String, Number],
845
+ default: ""
846
+ },
847
+ params: {
848
+ type: Object,
849
+ default: null
850
+ }
851
+ },
852
+ emits: ["onFetch"],
853
+ setup(e, { expose: t, emit: n }) {
854
+ let r = e, i = n;
855
+ t({ fetch: a }), T(async () => {
856
+ r.autoLoad && await a();
857
+ });
858
+ async function a(e = {}) {
859
+ try {
860
+ let t = {
861
+ ...e,
862
+ ...r.filter
863
+ };
864
+ r.where && !e.where && (t.where = r.where), r.sortBy && (t.order = r.sortBy), r.limit && (t.limit = r.limit);
865
+ let { data: n } = await ue.get(r.url, { params: {
866
+ filter: JSON.stringify(t),
867
+ ...r.params
868
+ } });
869
+ return i("onFetch", n), n;
870
+ } catch {}
871
+ }
872
+ return (e, t) => (D(), g("template"));
873
+ }
874
+ }, ke = {
875
+ class: "column items-center full-width",
876
+ style: { position: "relative" }
877
+ }, Ae = ["textContent"], je = /*#__PURE__*/ Z({
878
+ __name: "VnForm",
879
+ props: {
880
+ url: {
881
+ type: String,
882
+ default: ""
883
+ },
884
+ model: {
885
+ type: String,
886
+ default: null
887
+ },
888
+ filter: {
889
+ type: Object,
890
+ default: null
891
+ },
892
+ urlUpdate: {
893
+ type: String,
894
+ default: null
895
+ },
896
+ urlCreate: {
897
+ type: String,
898
+ default: null
899
+ },
900
+ defaultActions: {
901
+ type: Boolean,
902
+ default: !0
903
+ },
904
+ defaultButtons: {
905
+ type: Object,
906
+ default: () => {}
907
+ },
908
+ autoLoad: {
909
+ type: Boolean,
910
+ default: !1
911
+ },
912
+ formInitialData: {
913
+ type: Object,
914
+ default: () => {}
915
+ },
916
+ observeFormChanges: {
917
+ type: Boolean,
918
+ default: !0,
919
+ description: "Esto se usa principalmente para permitir guardar sin hacer cambios (Útil para la feature de clonar ya que en este caso queremos poder guardar de primeras)"
920
+ },
921
+ mapper: {
922
+ type: Function,
923
+ default: l
924
+ },
925
+ clearStoreOnUnmount: {
926
+ type: Boolean,
927
+ default: !0
928
+ },
929
+ saveFn: {
930
+ type: Function,
931
+ default: null
932
+ },
933
+ goTo: {
934
+ type: String,
935
+ default: "",
936
+ description: "It is used for redirect on click \"save and continue\""
937
+ },
938
+ reload: {
939
+ type: Boolean,
940
+ default: !0
941
+ },
942
+ defaultTrim: {
943
+ type: Boolean,
944
+ default: !0
945
+ },
946
+ maxWidth: {
947
+ type: [String, Boolean],
948
+ default: "800px"
949
+ },
950
+ onDataSaved: {
951
+ type: Function,
952
+ default: () => {}
953
+ },
954
+ preventSubmit: {
955
+ type: Boolean,
956
+ default: !1
957
+ },
958
+ customMethod: {
959
+ type: String,
960
+ default: null
961
+ },
962
+ formUrl: {
963
+ type: [String, Boolean],
964
+ default: "createForm"
965
+ },
966
+ paddingClass: {
967
+ type: String,
968
+ default: "q-pa-md"
969
+ },
970
+ showTitle: {
971
+ type: Boolean,
972
+ default: !1
973
+ },
974
+ title: {
975
+ type: String,
976
+ default: null
977
+ }
978
+ },
979
+ emits: [
980
+ "onFetch",
981
+ "onDataSaved",
982
+ "onDataSaveFail",
983
+ "submit"
984
+ ],
985
+ setup(t, { expose: s, emit: l }) {
986
+ let { push: f } = pe(), v = R.useQuasar(), y = a(), x = c(), { t: C } = le(), { validate: w, validations: te } = e(), { notify: M } = o(), N = fe(), I = O(null), L = t, z = l, V = p(() => L.model ?? `formModel_${N?.meta?.title ?? N.name}`).value, oe = O(!1), H = r(V), U = O(!1), W = O(!1), G = O(!L.observeFormChanges), K = {}, q = p(() => y.get(V)), J = O(), Y = p(() => I.value?.$el), X = p(() => ({
987
+ save: {
988
+ dataCy: "saveDefaultBtn",
989
+ color: "primary",
990
+ icon: "save",
991
+ label: "globals.save",
992
+ click: async (e) => me(e),
993
+ type: "submit"
994
+ },
995
+ reset: {
996
+ dataCy: "resetDefaultBtn",
997
+ color: "primary",
998
+ icon: "restart_alt",
999
+ label: "globals.reset",
1000
+ click: () => ve()
1001
+ },
1002
+ ...L.defaultButtons
1003
+ })), me = async (e) => {
1004
+ await I.value.validate() && await Q(e);
1005
+ };
1006
+ function Z() {
1007
+ K = L.formUrl ? JSON.parse(N?.query[L.formUrl] ?? "{}") : void 0;
1008
+ }
1009
+ T(async () => {
1010
+ !H.store.url && L.url && H.setOptions({
1011
+ url: L.url,
1012
+ filter: L.filter
1013
+ }), Z(), S(() => oe.value = !0), L.formInitialData && K && y.set(V, {
1014
+ ...L.formInitialData,
1015
+ ...K
1016
+ }), L.formInitialData || (L.autoLoad && L.url ? await he() : H.store.data && $("onFetch", { val: H.store.data })), L.observeFormChanges && P(() => J.value, (e, t) => {
1017
+ t && (G.value = !W.value && JSON.stringify(e) !== JSON.stringify(q.value), W.value = !1);
1018
+ }, { deep: !0 });
1019
+ }), L.url || P(() => H.store.data, (e) => $("onFetch", { val: e })), P(q, async (e) => {
1020
+ e && (J.value = JSON.parse(JSON.stringify(e))), await S(), Y.value && i(Y.value);
1021
+ }, { immediate: !0 }), P(() => [L.url, L.filter], async () => {
1022
+ y.set(V, null), ve(), await he();
1023
+ }), L.formInitialData && P(() => L.formInitialData, (e) => {
1024
+ e && y.set(V, {
1025
+ ...e,
1026
+ ...K
1027
+ });
1028
+ }), de((e, t, n) => {
1029
+ G.value && L.observeFormChanges ? v.dialog({
1030
+ component: _e,
1031
+ componentProps: {
1032
+ title: C("globals.unsavedPopup.title"),
1033
+ message: C("globals.unsavedPopup.subtitle"),
1034
+ promise: () => n()
1035
+ }
1036
+ }) : n();
1037
+ }), E(() => {
1038
+ if (G.value) return y.set(V, q.value);
1039
+ L.clearStoreOnUnmount && y.unset(V);
1040
+ });
1041
+ async function he() {
1042
+ try {
1043
+ let e;
1044
+ e = L.model ? (await H.addFilter({ filter: L.filter })).response?.data : (await ue.get(L.url, { params: { filter: JSON.stringify(L.filter) } })).data, Array.isArray(e) && (e = e[0] ?? {}), $("onFetch", { val: e });
1045
+ } catch (e) {
1046
+ throw y.set(V, {}), e;
1047
+ }
1048
+ }
1049
+ async function Q() {
1050
+ if (L.observeFormChanges && !G.value) return M("globals.noChanges", "negative");
1051
+ U.value = !0;
1052
+ try {
1053
+ J.value = Se(J.value);
1054
+ let e = L.urlCreate ? "post" : "patch", t = e === "post" ? L.mapper(J.value) : L.mapper(J.value, q.value), n = L.urlCreate || L.urlUpdate || L.url || H.store.url, r = await Promise.resolve(L.saveFn ? L.saveFn(t) : ue[L.customMethod ?? e](n, t));
1055
+ L.urlCreate && M("globals.dataCreated", "positive"), G.value = !1, $("onDataSaved", {
1056
+ val: J.value,
1057
+ res: r?.data,
1058
+ old: q.value,
1059
+ rawRes: r
1060
+ }), L.reload && await H.fetch({});
1061
+ } catch (e) {
1062
+ throw z("onDataSaveFail", J.value), e;
1063
+ } finally {
1064
+ U.value = !1;
1065
+ }
1066
+ }
1067
+ async function ge() {
1068
+ await Q(!0), f({ path: L.goTo });
1069
+ }
1070
+ function ve() {
1071
+ J.value = JSON.parse(JSON.stringify(q.value)), $("onFetch", { val: q.value }), L.observeFormChanges && (G.value = !1, W.value = !0);
1072
+ }
1073
+ function ye(e, t, n) {
1074
+ t(() => {
1075
+ let { options: t, filterFn: r } = n;
1076
+ t.value = r(t, e);
1077
+ }, (e) => {
1078
+ e.setOptionIndex(-1), e.moveOptionSelection(1, !0);
1079
+ });
1080
+ }
1081
+ async function $(e, { val: t, res: n, old: r, rawRes: a } = {
1082
+ val: null,
1083
+ res: null,
1084
+ old: null,
1085
+ rawRes: null
1086
+ }) {
1087
+ y.set(V, t), L.url || (H.store.data = t), z(e, y.get(V), n, r, J, a), Y.value && i(Y.value);
1088
+ }
1089
+ function Se(e) {
1090
+ if (!L.defaultTrim) return e;
1091
+ for (let t in e) typeof e[t] == "string" && (e[t] = e[t].trim());
1092
+ return e;
1093
+ }
1094
+ async function Ce(e) {
1095
+ if (e.key === "Enter" && !L.preventSubmit && G.value) {
1096
+ let t = e.target;
1097
+ if (t.type == "textarea" && e.shiftKey) {
1098
+ let { selectionStart: e, selectionEnd: n } = t;
1099
+ t.value = t.value.substring(0, e) + "\n" + t.value.substring(n), e = n = e + 1;
1100
+ return;
1101
+ }
1102
+ await I.value.submit(e);
1103
+ }
1104
+ }
1105
+ return s({
1106
+ submitForm: me,
1107
+ myForm: I,
1108
+ save: Q,
1109
+ isLoading: U,
1110
+ hasChanges: G,
1111
+ reset: ve,
1112
+ fetch: he,
1113
+ formData: J
1114
+ }), (e, r) => (D(), g(u, null, [_("div", ke, [b(j(ce), {
1115
+ showing: U.value,
1116
+ label: j(C)("globals.pleaseWait"),
1117
+ color: "primary",
1118
+ style: { "min-width": "100%" }
1119
+ }, {
1120
+ default: F(() => [b(j(xe), { size: "md" })]),
1121
+ _: 1
1122
+ }, 8, ["showing", "label"]), J.value ? (D(), m(j(se), ee({
1123
+ key: 0,
1124
+ id: "vnForm"
1125
+ }, e.$attrs, {
1126
+ ref_key: "myForm",
1127
+ ref: I,
1128
+ onSubmit: ne(Q, ["prevent"]),
1129
+ onKeyup: ne(Ce, ["prevent"]),
1130
+ onReset: ve,
1131
+ class: ["full-width", [t.paddingClass]],
1132
+ style: {
1133
+ maxWidth: t.maxWidth || "none",
1134
+ width: "100%"
1135
+ }
1136
+ }), {
1137
+ default: F(() => [b(j(ie), { class: "q-pa-none" }, {
1138
+ default: F(() => [t.showTitle ? (D(), m(j(ae), {
1139
+ key: 0,
1140
+ class: "vn-basic-data__header q-px-none q-pb-none"
1141
+ }, {
1142
+ default: F(() => [_("span", {
1143
+ class: "text-h6",
1144
+ textContent: A(t.title || e.$t("globals.pageTitles.basicData"))
1145
+ }, null, 8, Ae)]),
1146
+ _: 1
1147
+ })) : h("", !0), J.value ? k(e.$slots, "form", {
1148
+ data: J.value,
1149
+ validate: j(w),
1150
+ validations: j(te)(),
1151
+ filter: ye
1152
+ }, void 0, !0, 1) : (D(), m(j(be), { key: 2 }))]),
1153
+ _: 3
1154
+ })]),
1155
+ _: 3
1156
+ }, 16, ["class", "style"])) : h("", !0)]), L.defaultActions && j(x)?.isSubToolbarShown() && oe.value ? (D(), m(d, {
1157
+ key: 0,
1158
+ to: "#st-actions"
1159
+ }, [b(j(re), {
1160
+ push: "",
1161
+ class: "q-gutter-x-sm"
1162
+ }, {
1163
+ default: F(() => [
1164
+ k(e.$slots, "moreActions", {}, void 0, !0),
1165
+ b(j(B), {
1166
+ label: j(n)(X.value.reset.label),
1167
+ color: X.value.reset.color,
1168
+ icon: X.value.reset.icon,
1169
+ flat: "",
1170
+ onClick: X.value.reset.click,
1171
+ disable: !G.value,
1172
+ title: j(C)(X.value.reset.label),
1173
+ "data-cy": "resetDefaultBtn"
1174
+ }, null, 8, [
1175
+ "label",
1176
+ "color",
1177
+ "icon",
1178
+ "onClick",
1179
+ "disable",
1180
+ "title"
1181
+ ]),
1182
+ b(j(B), {
1183
+ "data-cy": "saveDefaultBtn",
1184
+ label: j(n)("globals.save"),
1185
+ color: "primary",
1186
+ icon: "save",
1187
+ onClick: X.value.save.click,
1188
+ disable: !G.value,
1189
+ title: j(C)(X.value.save.label),
1190
+ flat: !!L.goTo
1191
+ }, null, 8, [
1192
+ "label",
1193
+ "onClick",
1194
+ "disable",
1195
+ "title",
1196
+ "flat"
1197
+ ]),
1198
+ L.goTo ? (D(), m(j(B), {
1199
+ key: 0,
1200
+ "data-cy": "saveAndContinueDefaultBtn",
1201
+ onClick: ge,
1202
+ label: j(n)("globals.saveAndContinue") + " " + j(C)("globals." + L.goTo.split("/").pop()),
1203
+ title: j(C)("globals.saveAndContinue") + " " + j(C)("globals." + L.goTo.split("/").pop()),
1204
+ disable: !G.value,
1205
+ color: "primary",
1206
+ icon: "save"
1207
+ }, null, 8, [
1208
+ "label",
1209
+ "title",
1210
+ "disable"
1211
+ ])) : h("", !0)
1212
+ ]),
1213
+ _: 3
1214
+ })])) : h("", !0)], 64));
1215
+ }
1216
+ }, [["__scopeId", "data-v-addfa85d"]]), Me = /* @__PURE__ */ s({
1217
+ VnConfirm: () => _e,
1218
+ VnDate: () => Se,
1219
+ VnFetch: () => Oe,
1220
+ VnForm: () => je,
1221
+ VnInput: () => we,
1222
+ VnInputDate: () => De,
1223
+ VnSkeletonForm: () => be,
1224
+ VnSpinner: () => xe
1225
+ });
1226
+ //#endregion
1227
+ export { we as a, be as c, De as i, _e as l, je as n, Se as o, Oe as r, xe as s, Me as t };