@wgalleti/primevue-components 0.9.6 → 0.11.0

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 (37) hide show
  1. package/README.md +4 -0
  2. package/dist/WMapSelect.vue_vue_type_script_setup_true_lang-BOhO1F9v.js +4991 -0
  3. package/dist/WMapSelect.vue_vue_type_script_setup_true_lang-BOhO1F9v.js.map +1 -0
  4. package/dist/WMapSelect.vue_vue_type_script_setup_true_lang-BkZhQ_LO.cjs +12 -0
  5. package/dist/WMapSelect.vue_vue_type_script_setup_true_lang-BkZhQ_LO.cjs.map +1 -0
  6. package/dist/components/crud/WEditableTable.vue.d.ts +78 -0
  7. package/dist/components/form/WAutoCompleteFK.vue.d.ts +9 -1
  8. package/dist/components/form/WTreeSelect.vue.d.ts +124 -0
  9. package/dist/components/index.d.ts +6 -0
  10. package/dist/components/ui/WCheckList.vue.d.ts +36 -0
  11. package/dist/components/ui/WInfoCard.vue.d.ts +11 -1
  12. package/dist/components/ui/WMapSelect.vue.d.ts +133 -0
  13. package/dist/components/ui/WStepFlow.vue.d.ts +51 -0
  14. package/dist/components/ui/WStepSection.vue.d.ts +49 -0
  15. package/dist/components.cjs +1 -1
  16. package/dist/components.cjs.map +1 -1
  17. package/dist/components.js +29 -124
  18. package/dist/components.js.map +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.ts +5 -2
  22. package/dist/index.js +79 -70
  23. package/dist/index.js.map +1 -1
  24. package/dist/primevue-components.css +1 -1
  25. package/dist/types/checkList.d.ts +7 -0
  26. package/dist/types/editableTable.d.ts +39 -0
  27. package/dist/types/field.d.ts +27 -1
  28. package/dist/types/index.d.ts +3 -0
  29. package/dist/types/mapSelect.d.ts +31 -0
  30. package/dist/utils/stepFlow.d.ts +27 -0
  31. package/dist/utils/treeSelect.d.ts +76 -0
  32. package/package.json +5 -1
  33. package/skill/references/components.md +7 -0
  34. package/dist/WProgressFlow.vue_vue_type_script_setup_true_lang-Cc0DJRIy.cjs +0 -12
  35. package/dist/WProgressFlow.vue_vue_type_script_setup_true_lang-Cc0DJRIy.cjs.map +0 -1
  36. package/dist/WProgressFlow.vue_vue_type_script_setup_true_lang-DVjJq8Bs.js +0 -3632
  37. package/dist/WProgressFlow.vue_vue_type_script_setup_true_lang-DVjJq8Bs.js.map +0 -1
@@ -1,3632 +0,0 @@
1
- import { defineComponent as ie, openBlock as o, createElementBlock as c, createBlock as C, unref as u, toDisplayString as A, inject as Vt, ref as T, computed as P, onMounted as pt, nextTick as ut, watch as Ee, reactive as Me, resolveDirective as St, Fragment as Q, createElementVNode as m, mergeProps as Ht, createVNode as F, createSlots as Je, withCtx as q, withDirectives as se, createCommentVNode as b, renderList as ae, normalizeStyle as ve, createTextVNode as Ae, normalizeClass as ee, onBeforeUnmount as Gt, renderSlot as N, isRef as Yt, withModifiers as Jt, normalizeProps as ct, guardReactiveProps as mt, useSlots as Xt, createStaticVNode as Zt } from "vue";
2
- import Dt from "primevue/datatable";
3
- import Oe from "primevue/column";
4
- import O from "primevue/button";
5
- import re from "primevue/inputtext";
6
- import ot from "primevue/inputnumber";
7
- import ft from "primevue/select";
8
- import Et from "primevue/popover";
9
- import Qt from "primevue/checkbox";
10
- import je from "primevue/iconfield";
11
- import qe from "primevue/inputicon";
12
- import _t from "primevue/paginator";
13
- import el from "primevue/contextmenu";
14
- import nt from "primevue/dialog";
15
- import Ft from "primevue/tag";
16
- import { f as ht, b as tl, a as ll, e as yt, c as al, d as ol } from "./useFormKeyboardNav-D4Irq5RE.js";
17
- import nl from "primevue/textarea";
18
- import Pt from "primevue/autocomplete";
19
- import il from "primevue/toggleswitch";
20
- import sl from "primevue/colorpicker";
21
- import rl from "primevue/password";
22
- import gt from "primevue/chip";
23
- import { W as ul } from "./plugin-BKa0eSEM.js";
24
- import It from "primevue/datepicker";
25
- import dl from "primevue/inputgroup";
26
- import bt from "primevue/inputgroupaddon";
27
- import cl from "primevue/slider";
28
- import et from "primevue/skeleton";
29
- const ml = {
30
- key: 0,
31
- class: "text-muted-color text-xs"
32
- }, fl = ["src", "alt"], vl = {
33
- key: 3,
34
- class: "text-muted-color tabular-nums text-[0.8125rem]"
35
- }, pl = {
36
- key: 4,
37
- class: "text-muted-color tabular-nums text-[0.8125rem]"
38
- }, hl = {
39
- key: 5,
40
- class: "font-semibold tabular-nums text-[0.8125rem]"
41
- }, yl = {
42
- key: 6,
43
- class: "font-semibold tabular-nums text-[0.8125rem]"
44
- }, gl = {
45
- key: 7,
46
- class: "text-[0.8125rem]"
47
- }, vt = /* @__PURE__ */ ie({
48
- __name: "WCrudColumnRenderer",
49
- props: {
50
- column: {},
51
- value: {},
52
- rowData: {}
53
- },
54
- setup(e) {
55
- const { formatDate: a, formatDateTime: t, formatCurrency: n, formatNumber: s } = ht();
56
- return (p, k) => e.value == null ? (o(), c("span", ml, "—")) : e.column.type === "image" ? (o(), c("img", {
57
- key: 1,
58
- src: String(e.value),
59
- alt: e.column.header,
60
- class: "size-9 rounded-lg object-cover ring-1 ring-surface-200 dark:ring-surface-700"
61
- }, null, 8, fl)) : e.column.type === "boolean" ? (o(), C(u(Ft), {
62
- key: 2,
63
- value: e.column.tagValue ? e.column.tagValue(e.value, e.rowData) : e.value ? "Ativo" : "Inativo",
64
- severity: e.column.tagSeverity ? e.column.tagSeverity(e.value, e.rowData) : e.value ? "success" : "danger",
65
- class: "text-xs"
66
- }, null, 8, ["value", "severity"])) : e.column.type === "date" ? (o(), c("span", vl, A(u(a)(e.value)), 1)) : e.column.type === "datetime" ? (o(), c("span", pl, A(u(t)(e.value)), 1)) : e.column.type === "currency" ? (o(), c("span", hl, A(u(n)(e.value)), 1)) : e.column.type === "number" ? (o(), c("span", yl, A(e.column.format ? e.column.format(e.value, e.rowData) : u(s)(e.value, e.column.decimals ?? 0)), 1)) : (o(), c("span", gl, A(e.column.format ? e.column.format(e.value, e.rowData) : e.value), 1));
67
- }
68
- });
69
- var bl = Object.defineProperty, wl = (e, a, t) => a in e ? bl(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t, Xe = (e, a, t) => wl(e, typeof a != "symbol" ? a + "" : a, t);
70
- const wt = {
71
- "#": { pattern: /[0-9]/ },
72
- "@": { pattern: /[a-zA-Z]/ },
73
- "*": { pattern: /[a-zA-Z0-9]/ }
74
- }, kt = (e, a, t) => e.replaceAll(a, "").replace(t, ".").replace("..", ".").replace(/[^.\d]/g, ""), $t = (e, a, t) => {
75
- var n;
76
- return new Intl.NumberFormat(((n = t.number) == null ? void 0 : n.locale) ?? "en", {
77
- minimumFractionDigits: e,
78
- maximumFractionDigits: a,
79
- roundingMode: "trunc"
80
- });
81
- }, kl = (e, a = !0, t) => {
82
- var n, s, p, k;
83
- const I = ((n = t.number) == null ? void 0 : n.unsigned) !== !0 && e.startsWith("-") ? "-" : "", S = ((s = t.number) == null ? void 0 : s.fraction) ?? 0;
84
- let x = $t(0, S, t);
85
- const M = x.formatToParts(1000.12), $ = ((p = M.find((R) => R.type === "group")) == null ? void 0 : p.value) ?? " ", Z = ((k = M.find((R) => R.type === "decimal")) == null ? void 0 : k.value) ?? ".", K = kt(e, $, Z);
86
- if (Number.isNaN(parseFloat(K))) return I;
87
- const H = K.split(".");
88
- if (H[1] != null && H[1].length >= 1) {
89
- const R = H[1].length <= S ? H[1].length : S;
90
- x = $t(R, S, t);
91
- }
92
- let Y = x.format(parseFloat(K));
93
- return a ? S > 0 && K.endsWith(".") && !K.slice(0, -1).includes(".") && (Y += Z) : Y = kt(Y, $, Z), I + Y;
94
- }, Rt = (e) => JSON.parse(e.replaceAll("'", '"')), $l = (e, a = {}) => {
95
- const t = { ...a };
96
- e.dataset.maska != null && e.dataset.maska !== "" && (t.mask = xl(e.dataset.maska)), e.dataset.maskaEager != null && (t.eager = tt(e.dataset.maskaEager)), e.dataset.maskaReversed != null && (t.reversed = tt(e.dataset.maskaReversed)), e.dataset.maskaTokensReplace != null && (t.tokensReplace = tt(e.dataset.maskaTokensReplace)), e.dataset.maskaTokens != null && (t.tokens = Cl(e.dataset.maskaTokens));
97
- const n = {};
98
- return e.dataset.maskaNumberLocale != null && (n.locale = e.dataset.maskaNumberLocale), e.dataset.maskaNumberFraction != null && (n.fraction = parseInt(e.dataset.maskaNumberFraction)), e.dataset.maskaNumberUnsigned != null && (n.unsigned = tt(e.dataset.maskaNumberUnsigned)), (e.dataset.maskaNumber != null || Object.values(n).length > 0) && (t.number = n), t;
99
- }, tt = (e) => e !== "" ? !!JSON.parse(e) : !0, xl = (e) => e.startsWith("[") && e.endsWith("]") ? Rt(e) : e, Cl = (e) => {
100
- if (e.startsWith("{") && e.endsWith("}"))
101
- return Rt(e);
102
- const a = {};
103
- return e.split("|").forEach((t) => {
104
- const n = t.split(":");
105
- a[n[0]] = {
106
- pattern: Mt() ? new RegExp(n[1], "u") : new RegExp(n[1]),
107
- optional: n[2] === "optional",
108
- multiple: n[2] === "multiple",
109
- repeated: n[2] === "repeated"
110
- };
111
- }), a;
112
- }, Mt = () => {
113
- try {
114
- return new RegExp("\\p{L}", "u"), !0;
115
- } catch {
116
- return !1;
117
- }
118
- };
119
- class Vl {
120
- constructor(a = {}) {
121
- Xe(this, "opts", {}), Xe(this, "memo", /* @__PURE__ */ new Map());
122
- const t = { ...a };
123
- if (t.tokens != null) {
124
- t.tokens = t.tokensReplace ? { ...t.tokens } : { ...wt, ...t.tokens };
125
- for (const n of Object.values(t.tokens))
126
- typeof n.pattern == "string" && (n.pattern = Mt() ? new RegExp(n.pattern, "u") : new RegExp(n.pattern));
127
- } else
128
- t.tokens = wt;
129
- Array.isArray(t.mask) && (t.mask.length > 1 ? t.mask = [...t.mask].sort((n, s) => n.length - s.length) : t.mask = t.mask[0] ?? ""), t.mask === "" && (t.mask = null), this.opts = t;
130
- }
131
- masked(a) {
132
- return this.process(String(a), this.findMask(String(a)));
133
- }
134
- unmasked(a) {
135
- return this.process(String(a), this.findMask(String(a)), !1);
136
- }
137
- isEager() {
138
- return this.opts.eager === !0;
139
- }
140
- isReversed() {
141
- return this.opts.reversed === !0;
142
- }
143
- completed(a) {
144
- const t = this.findMask(String(a));
145
- if (this.opts.mask == null || t == null) return !1;
146
- const n = this.process(String(a), t).length;
147
- return typeof this.opts.mask == "string" ? n >= this.opts.mask.length : n >= t.length;
148
- }
149
- findMask(a) {
150
- const t = this.opts.mask;
151
- if (t == null)
152
- return null;
153
- if (typeof t == "string")
154
- return t;
155
- if (typeof t == "function")
156
- return t(a);
157
- const n = this.process(a, t.slice(-1).pop() ?? "", !1);
158
- return t.find((s) => this.process(a, s, !1).length >= n.length) ?? "";
159
- }
160
- escapeMask(a) {
161
- const t = [], n = [];
162
- return a.split("").forEach((s, p) => {
163
- s === "!" && a[p - 1] !== "!" ? n.push(p - n.length) : t.push(s);
164
- }), { mask: t.join(""), escaped: n };
165
- }
166
- process(a, t, n = !0) {
167
- if (this.opts.number != null) return kl(a, n, this.opts);
168
- if (t == null) return a;
169
- const s = `v=${a},mr=${t},m=${n ? 1 : 0}`;
170
- if (this.memo.has(s)) return this.memo.get(s);
171
- const { mask: p, escaped: k } = this.escapeMask(t), I = [], S = this.opts.tokens != null ? this.opts.tokens : {}, x = this.isReversed() ? -1 : 1, M = this.isReversed() ? "unshift" : "push", $ = this.isReversed() ? 0 : p.length - 1, Z = this.isReversed() ? () => R > -1 && L > -1 : () => R < p.length && L < a.length, K = (D) => !this.isReversed() && D <= $ || this.isReversed() && D >= $;
172
- let H, Y = -1, R = this.isReversed() ? p.length - 1 : 0, L = this.isReversed() ? a.length - 1 : 0, W = !1;
173
- for (; Z(); ) {
174
- const D = p.charAt(R), j = S[D], oe = (j == null ? void 0 : j.transform) != null ? j.transform(a.charAt(L)) : a.charAt(L);
175
- if (!k.includes(R) && j != null ? (oe.match(j.pattern) != null ? (I[M](oe), j.repeated ? (Y === -1 ? Y = R : R === $ && R !== Y && (R = Y - x), $ === Y && (R -= x)) : j.multiple && (W = !0, R -= x), R += x) : j.multiple ? W && (R += x, L -= x, W = !1) : oe === H ? H = void 0 : j.optional && (R += x, L -= x), L += x) : (n && !this.isEager() && I[M](D), oe === D && !this.isEager() ? L += x : H = D, this.isEager() || (R += x)), this.isEager())
176
- for (; K(R) && (S[p.charAt(R)] == null || k.includes(R)); ) {
177
- if (n) {
178
- if (I[M](p.charAt(R)), a.charAt(L) === p.charAt(R)) {
179
- R += x, L += x;
180
- continue;
181
- }
182
- } else p.charAt(R) === a.charAt(L) && (L += x);
183
- R += x;
184
- }
185
- }
186
- return this.memo.set(s, I.join("")), this.memo.get(s);
187
- }
188
- }
189
- class Sl {
190
- constructor(a, t = {}) {
191
- Xe(this, "items", /* @__PURE__ */ new Map()), Xe(this, "eventAbortController"), Xe(this, "onInput", (n) => {
192
- if (n instanceof CustomEvent && n.type === "input" && !n.isTrusted && !n.bubbles)
193
- return;
194
- const s = n.target, p = this.items.get(s);
195
- if (p === void 0) return;
196
- const k = "inputType" in n && n.inputType.startsWith("delete"), I = p.isEager(), S = k && I && p.unmasked(s.value) === "" ? "" : s.value;
197
- this.fixCursor(s, k, () => this.setValue(s, S));
198
- }), this.options = t, this.eventAbortController = new AbortController(), this.init(this.getInputs(a));
199
- }
200
- update(a = {}) {
201
- this.options = { ...a }, this.init(Array.from(this.items.keys()));
202
- }
203
- updateValue(a) {
204
- var t;
205
- a.value !== "" && a.value !== ((t = this.processInput(a)) == null ? void 0 : t.masked) && this.setValue(a, a.value);
206
- }
207
- destroy() {
208
- this.eventAbortController.abort(), this.items.clear();
209
- }
210
- init(a) {
211
- const t = this.getOptions(this.options);
212
- for (const n of a) {
213
- if (!this.items.has(n)) {
214
- const { signal: p } = this.eventAbortController;
215
- n.addEventListener("input", this.onInput, { capture: !0, signal: p });
216
- }
217
- const s = new Vl($l(n, t));
218
- this.items.set(n, s), queueMicrotask(() => this.updateValue(n)), n.selectionStart === null && s.isEager() && console.warn("Maska: input of `%s` type is not supported", n.type);
219
- }
220
- }
221
- getInputs(a) {
222
- return typeof a == "string" ? Array.from(document.querySelectorAll(a)) : "length" in a ? Array.from(a) : [a];
223
- }
224
- getOptions(a) {
225
- const { onMaska: t, preProcess: n, postProcess: s, ...p } = a;
226
- return p;
227
- }
228
- fixCursor(a, t, n) {
229
- var s, p;
230
- const k = a.selectionStart, I = a.value;
231
- if (n(), k === null || k === I.length && !t) return;
232
- const S = a.value, x = I.slice(0, k), M = S.slice(0, k), $ = (s = this.processInput(a, x)) == null ? void 0 : s.unmasked, Z = (p = this.processInput(a, M)) == null ? void 0 : p.unmasked;
233
- if ($ === void 0 || Z === void 0) return;
234
- let K = k;
235
- x !== M && (K += t ? S.length - I.length : $.length - Z.length), a.setSelectionRange(K, K);
236
- }
237
- setValue(a, t) {
238
- const n = this.processInput(a, t);
239
- n !== void 0 && (a.value = n.masked, this.options.onMaska != null && (Array.isArray(this.options.onMaska) ? this.options.onMaska.forEach((s) => s(n)) : this.options.onMaska(n)), a.dispatchEvent(new CustomEvent("maska", { detail: n })), a.dispatchEvent(new CustomEvent("input", { detail: n.masked })));
240
- }
241
- processInput(a, t) {
242
- const n = this.items.get(a);
243
- if (n === void 0) return;
244
- let s = t ?? a.value;
245
- this.options.preProcess != null && (s = this.options.preProcess(s));
246
- let p = n.masked(s);
247
- return this.options.postProcess != null && (p = this.options.postProcess(p)), {
248
- masked: p,
249
- unmasked: n.unmasked(s),
250
- completed: n.completed(s)
251
- };
252
- }
253
- }
254
- const dt = /* @__PURE__ */ new WeakMap(), Dl = (e, a) => {
255
- if (e.arg == null || e.instance == null) return;
256
- const t = "setup" in e.instance.$.type;
257
- e.arg in e.instance ? e.instance[e.arg] = a : t && console.warn("Maska: please expose `%s` using defineExpose", e.arg);
258
- }, at = (e, a) => {
259
- var t;
260
- const n = e instanceof HTMLInputElement ? e : e.querySelector("input");
261
- if (n == null || (n == null ? void 0 : n.type) === "file") return;
262
- let s = {};
263
- if (a.value != null && (s = typeof a.value == "string" ? { mask: a.value } : { ...a.value }), a.arg != null) {
264
- const p = (k) => {
265
- const I = a.modifiers.unmasked ? k.unmasked : a.modifiers.completed ? k.completed : k.masked;
266
- Dl(a, I);
267
- };
268
- s.onMaska = s.onMaska == null ? p : Array.isArray(s.onMaska) ? [...s.onMaska, p] : [s.onMaska, p];
269
- }
270
- dt.has(n) ? (t = dt.get(n)) == null || t.update(s) : dt.set(n, new Sl(n, s));
271
- }, El = {
272
- string: "text",
273
- integer: "number",
274
- decimal: "number",
275
- float: "number",
276
- boolean: "switch",
277
- choice: "select",
278
- fk: "fk",
279
- date: "date",
280
- datetime: "datetime",
281
- email: "email",
282
- url: "text",
283
- slug: "text",
284
- text: "textarea"
285
- };
286
- function Fl(e) {
287
- var n;
288
- const a = El[e.type] ?? "text", t = {
289
- field: e.name,
290
- label: e.label,
291
- type: a,
292
- required: e.required ?? !1
293
- };
294
- return (e.type === "decimal" || e.type === "float") && (t.minFractionDigits = 2, t.maxFractionDigits = 2), e.type === "boolean" && (t.defaultValue = !1), e.type === "choice" && ((n = e.choices) != null && n.length) && (t.options = e.choices.map((s) => ({
295
- label: s.label,
296
- value: s.value
297
- }))), e.type === "fk" && (t.endpoint = e.endpoint, e.option_label && (t.optionLabel = e.option_label), e.option_value && (t.optionValue = e.option_value)), t;
298
- }
299
- function Pl(e) {
300
- return e.filter((a) => !a.read_only && a.name !== "id").map(Fl);
301
- }
302
- const Il = {
303
- boolean: "boolean",
304
- date: "date",
305
- datetime: "datetime",
306
- decimal: "number",
307
- float: "number",
308
- integer: "number"
309
- };
310
- function Rl(e) {
311
- return {
312
- field: e.type === "fk" ? `${e.name}_nome` : e.name,
313
- header: e.label,
314
- type: Il[e.type],
315
- sortable: !0
316
- };
317
- }
318
- function Ml(e, a = 6) {
319
- return e.filter((t) => !t.read_only && t.name !== "id").slice(0, a).map(Rl);
320
- }
321
- const Al = {
322
- key: 2,
323
- class: "w-autocompletefk-chip-hidden"
324
- }, Ul = ["disabled"], Bl = { class: "w-autocompletefk-toolbar" }, Tl = { class: "w-autocompletefk-toolbar-actions" }, Nl = { class: "flex items-center justify-end gap-1" }, Ll = { class: "w-autocompletefk-footer" }, Ol = /* @__PURE__ */ ie({
325
- inheritAttrs: !1,
326
- __name: "WAutoCompleteFK",
327
- props: {
328
- modelValue: {},
329
- endpoint: {},
330
- endpointParams: {},
331
- drilldown: {},
332
- multiple: { type: Boolean, default: !1 },
333
- maxChips: { default: 0 },
334
- optionLabel: { default: "nome" },
335
- optionValue: { default: "id" },
336
- placeholder: { default: "Buscar..." },
337
- blockedPlaceholder: {},
338
- disabled: { type: Boolean, default: !1 },
339
- showClear: { type: Boolean, default: !0 },
340
- forceSelection: { type: Boolean, default: !0 },
341
- columns: {},
342
- minLength: { default: 0 },
343
- dialogHeader: {},
344
- canCreate: { type: Boolean, default: void 0 },
345
- canEdit: { type: Boolean, default: void 0 },
346
- canDelete: { type: Boolean, default: void 0 },
347
- crudFields: {},
348
- crudColumns: {},
349
- dialogWidth: { default: "480px" },
350
- autofocus: { type: Boolean, default: !1 }
351
- },
352
- emits: ["update:modelValue"],
353
- setup(e, { emit: a }) {
354
- const t = e, n = a, s = Vt(ul);
355
- if (!s)
356
- throw new Error("[wPrimeVueComponents] dataProvider não encontrado. Registre o WPrimeVuePlugin.");
357
- const p = s, k = tl(), { confirmDelete: I } = ll(), S = T(null), x = T([]), M = T([]), $ = T(!1), Z = P(() => t.multiple ? x.value : S.value);
358
- function K(i) {
359
- return i && typeof i == "object" ? i[t.optionValue] : i;
360
- }
361
- function H(i) {
362
- const g = /* @__PURE__ */ new Set(), V = [];
363
- for (const E of i) {
364
- const U = K(E);
365
- g.has(U) || (g.add(U), V.push(E));
366
- }
367
- return V;
368
- }
369
- function Y() {
370
- n("update:modelValue", t.multiple ? [...x.value] : S.value);
371
- }
372
- function R(i) {
373
- const g = i == null ? void 0 : i[t.optionLabel];
374
- return g == null ? "" : String(g);
375
- }
376
- const L = P(
377
- () => t.maxChips > 0 ? Math.max(0, x.value.length - t.maxChips) : 0
378
- ), W = P(
379
- () => x.value.slice(t.maxChips).map(R).join(", ")
380
- );
381
- function D(i, g) {
382
- var V;
383
- (V = i == null ? void 0 : i.stopPropagation) == null || V.call(i), g(i);
384
- }
385
- function j() {
386
- if (!t.disabled) {
387
- if (t.multiple) {
388
- if (!x.value.length) return;
389
- x.value = [];
390
- } else {
391
- if (!S.value) return;
392
- S.value = null;
393
- }
394
- Y();
395
- }
396
- }
397
- const oe = P(
398
- () => t.multiple && t.maxChips > 0 ? { "--w-fk-chip-max": `max(6rem, calc((100% - 6rem) / ${t.maxChips}))` } : void 0
399
- ), ye = P(() => !t.showClear || t.disabled ? !1 : t.multiple ? x.value.length > 0 : S.value !== null);
400
- let xe = null;
401
- const Ce = T(null);
402
- pt(() => {
403
- t.autofocus && ut(() => {
404
- var g, V, E, U;
405
- const i = (E = (V = (g = Ce.value) == null ? void 0 : g.$el) == null ? void 0 : V.querySelector) == null ? void 0 : E.call(V, "input");
406
- i && (i.setAttribute("autofocus", ""), i.focus(), (U = i.select) == null || U.call(i));
407
- });
408
- });
409
- function ge(i) {
410
- return i == null || i === "";
411
- }
412
- function Ve(i) {
413
- if (i && typeof i == "object") {
414
- const g = i;
415
- return g.id ?? g.value ?? g;
416
- }
417
- return i;
418
- }
419
- const ue = P(() => {
420
- const i = t.drilldown;
421
- return i ? Array.isArray(i) ? i : [i] : [];
422
- }), Se = P(
423
- () => ue.value.some(
424
- (i) => (i.required ?? !0) && ge(Ve(i.value))
425
- )
426
- );
427
- function ce() {
428
- const i = {};
429
- for (const g of ue.value) {
430
- const V = Ve(g.value);
431
- ge(V) || (i[g.field] = V);
432
- }
433
- return i;
434
- }
435
- const de = P(
436
- () => Se.value && t.blockedPlaceholder ? t.blockedPlaceholder : t.placeholder
437
- ), me = P(
438
- () => t.multiple && x.value.length ? void 0 : de.value
439
- );
440
- async function pe(i) {
441
- try {
442
- return (await p.get(t.endpoint, i)).data;
443
- } catch {
444
- return null;
445
- }
446
- }
447
- async function be(i) {
448
- S.value = await pe(i);
449
- }
450
- async function he(i) {
451
- return (await Promise.all(
452
- i.map(async (V) => {
453
- if (V && typeof V == "object") {
454
- const U = V;
455
- if (t.optionLabel in U) return U;
456
- const $e = U[t.optionValue];
457
- return $e != null ? await pe($e) : null;
458
- }
459
- return x.value.find((U) => U[t.optionValue] === V) ?? await pe(V);
460
- })
461
- )).filter((V) => V !== null);
462
- }
463
- async function De(i) {
464
- if (Se.value) {
465
- M.value = [];
466
- return;
467
- }
468
- $.value = !0;
469
- try {
470
- const g = {
471
- page_size: 20,
472
- ...t.endpointParams,
473
- ...ce()
474
- };
475
- i && (g.search = i);
476
- const V = await p.list(t.endpoint, g);
477
- M.value = V.data;
478
- } catch {
479
- M.value = [];
480
- } finally {
481
- $.value = !1;
482
- }
483
- }
484
- function v(i) {
485
- const g = i.query || "";
486
- if (g.length < t.minLength) {
487
- M.value = [];
488
- return;
489
- }
490
- xe && clearTimeout(xe), xe = setTimeout(() => De(g), 300);
491
- }
492
- function y(i) {
493
- t.multiple || (S.value = i.value, n("update:modelValue", i.value));
494
- }
495
- function h(i) {
496
- t.multiple && (x.value = H(
497
- Array.isArray(i) ? i : []
498
- ), Y());
499
- }
500
- function l() {
501
- t.multiple || (S.value = null, Y());
502
- }
503
- Ee(
504
- () => t.modelValue,
505
- async (i) => {
506
- if (t.multiple) {
507
- const g = i == null ? [] : Array.isArray(i) ? i : [i], V = g.map(K), E = x.value.map((U) => U[t.optionValue]);
508
- if (V.length === E.length && V.every((U, $e) => U === E[$e])) return;
509
- x.value = await he(g);
510
- return;
511
- }
512
- if (i != null) {
513
- if (typeof i == "object" && i !== null && t.optionLabel in i) {
514
- S.value = i;
515
- return;
516
- }
517
- (!S.value || S.value[t.optionValue] !== i) && await be(i);
518
- } else
519
- S.value = null;
520
- },
521
- { immediate: !0 }
522
- );
523
- const w = T(!1), _ = T([]), X = T(!1), te = T(""), J = T(1), le = T(15), we = T(0), ne = T(null), fe = P(() => {
524
- const i = ne.value;
525
- return i ? Array.isArray(i) ? i : [i] : [];
526
- }), Re = T(null), Fe = T(0);
527
- let Ue = null;
528
- const Be = T([]), ze = P(() => {
529
- var i;
530
- return (i = t.crudFields) != null && i.length ? !0 : Be.value.length > 0;
531
- }), it = P(() => t.canCreate ?? ze.value), Ze = P(() => t.canEdit ?? ze.value), Pe = P(() => t.canDelete ?? ze.value), We = P(() => Ze.value || Pe.value), d = P(() => {
532
- var i;
533
- return (i = t.crudFields) != null && i.length ? t.crudFields : Pl(Be.value);
534
- }), f = P(() => {
535
- var i, g;
536
- return (i = t.crudColumns) != null && i.length ? t.crudColumns : (g = t.columns) != null && g.length ? t.columns.map((V) => ({
537
- field: V.field,
538
- header: V.header,
539
- sortable: !0
540
- })) : Be.value.length ? Ml(Be.value) : [{ field: t.optionLabel, header: t.optionLabel, sortable: !0 }];
541
- });
542
- async function z() {
543
- var i, g, V;
544
- if (Se.value) {
545
- _.value = [], we.value = 0;
546
- return;
547
- }
548
- X.value = !0;
549
- try {
550
- const E = {
551
- page: J.value,
552
- page_size: le.value,
553
- ...t.endpointParams,
554
- ...ce()
555
- };
556
- te.value && (E.search = te.value), Re.value && Fe.value !== 0 && (E.ordering = Fe.value === -1 ? `-${Re.value}` : Re.value);
557
- const U = await p.list(t.endpoint, E);
558
- _.value = U.data, we.value = U.rows, (i = U.extras) != null && i.fields && !((g = t.columns) != null && g.length) && !((V = t.crudFields) != null && V.length) && (Be.value = U.extras.fields);
559
- } catch {
560
- _.value = [], we.value = 0;
561
- } finally {
562
- X.value = !1;
563
- }
564
- }
565
- function r(i) {
566
- i.key === "F2" && !t.disabled && (i.preventDefault(), B());
567
- }
568
- function B() {
569
- t.disabled || (te.value = "", J.value = 1, Re.value = null, Fe.value = 0, ne.value = t.multiple ? [...x.value] : null, w.value = !0, z());
570
- }
571
- function G(i) {
572
- J.value = i.page + 1, le.value = i.rows, z();
573
- }
574
- function ke(i) {
575
- Re.value = i.sortField ?? null, Fe.value = i.sortOrder ?? 0, J.value = 1, z();
576
- }
577
- function Ke() {
578
- if (t.multiple) {
579
- x.value = H(fe.value), Y(), w.value = !1;
580
- return;
581
- }
582
- const i = fe.value[0];
583
- i && (S.value = i, n("update:modelValue", i), w.value = !1);
584
- }
585
- function Qe(i) {
586
- if (t.multiple) {
587
- ne.value = H([...fe.value, i.data]);
588
- return;
589
- }
590
- S.value = i.data, n("update:modelValue", i.data), w.value = !1;
591
- }
592
- const He = T(null), Ge = T(null);
593
- let Te = "";
594
- function _e() {
595
- Te = "", ut(() => {
596
- var g, V, E;
597
- const i = (g = He.value) == null ? void 0 : g.$el;
598
- (V = i == null ? void 0 : i.focus) == null || V.call(i), (E = i == null ? void 0 : i.select) == null || E.call(i);
599
- });
600
- }
601
- function Ie() {
602
- ut(() => {
603
- var g;
604
- const i = (g = Ge.value) == null ? void 0 : g.querySelector(".p-datatable-tbody > tr");
605
- i == null || i.focus();
606
- });
607
- }
608
- function Ut(i) {
609
- if (i.key !== "Enter" || i.isComposing) return;
610
- i.preventDefault();
611
- const g = te.value.trim();
612
- if (g === "" || g === Te) {
613
- Ie();
614
- return;
615
- }
616
- Ue && clearTimeout(Ue), Te = g, J.value = 1, z();
617
- }
618
- function Bt(i) {
619
- i.key === "Enter" && (i.preventDefault(), i.stopPropagation(), (t.multiple || fe.value.length) && Ke());
620
- }
621
- Ee(te, () => {
622
- Ue && clearTimeout(Ue), Ue = setTimeout(() => {
623
- J.value = 1, Te = te.value.trim(), z();
624
- }, 300);
625
- }), Ee(
626
- () => ue.value.map((i) => Ve(i.value)),
627
- (i, g) => {
628
- if (w.value && (J.value = 1, z()), !g) return;
629
- const V = i.some((U, $e) => U !== g[$e]), E = g.some((U) => !ge(U));
630
- if (!(!V || !E)) {
631
- if (t.multiple) {
632
- if (!x.value.length) return;
633
- x.value = [], Y();
634
- return;
635
- }
636
- S.value && (S.value = null, n("update:modelValue", null));
637
- }
638
- }
639
- );
640
- const Ye = T(!1), st = T(!1), Ne = T(null), Le = Me({}), rt = P(() => Ne.value !== null), Tt = P(() => rt.value ? "Editar Registro" : "Novo Registro");
641
- function Nt() {
642
- const i = {};
643
- for (const g of d.value)
644
- i[g.field] = g.defaultValue !== void 0 ? typeof g.defaultValue == "function" ? g.defaultValue() : g.defaultValue : null;
645
- return i;
646
- }
647
- function Lt() {
648
- const i = Nt();
649
- for (const g of Object.keys(Le))
650
- delete Le[g];
651
- for (const [g, V] of Object.entries(i))
652
- Le[g] = V;
653
- }
654
- function Ot() {
655
- Ne.value = null, Lt(), Ye.value = !0;
656
- }
657
- function zt(i) {
658
- Ne.value = i;
659
- for (const g of d.value)
660
- Le[g.field] = i[g.field] !== void 0 ? i[g.field] : null;
661
- Ye.value = !0;
662
- }
663
- function Wt(i, g) {
664
- Le[i] = g;
665
- }
666
- async function jt() {
667
- st.value = !0;
668
- try {
669
- const i = { ...Le };
670
- for (const V of d.value) {
671
- const E = i[V.field];
672
- if (V.type === "fk" && E !== null && typeof E == "object") {
673
- const U = V.optionValue || "id";
674
- i[V.field] = E[U] ?? E;
675
- }
676
- }
677
- let g;
678
- if (rt.value && Ne.value) {
679
- const V = Ne.value[t.optionValue];
680
- g = await p.update(t.endpoint, V, i);
681
- const E = _.value.findIndex((U) => U[t.optionValue] === V);
682
- E !== -1 && (_.value[E] = g.data), k.success("Registro atualizado com sucesso");
683
- } else {
684
- const V = ce();
685
- for (const [E, U] of Object.entries(V)) {
686
- const $e = i[E];
687
- ($e == null || $e === "") && (i[E] = U);
688
- }
689
- g = await p.create(t.endpoint, i), _.value.unshift(g.data), we.value++, k.success("Registro criado com sucesso");
690
- }
691
- Ye.value = !1, Ne.value = null, ne.value = t.multiple ? H([...fe.value, g.data]) : g.data;
692
- } catch (i) {
693
- k.error(yt(i, "Erro ao salvar registro"));
694
- } finally {
695
- st.value = !1;
696
- }
697
- }
698
- function qt(i) {
699
- I(async () => {
700
- var g;
701
- try {
702
- const V = i[t.optionValue];
703
- await p.delete(t.endpoint, V);
704
- const E = _.value.findIndex((U) => U[t.optionValue] === V);
705
- E !== -1 && (_.value.splice(E, 1), we.value--), t.multiple ? (x.value.some((U) => U[t.optionValue] === V) && (x.value = x.value.filter((U) => U[t.optionValue] !== V), Y()), ne.value = fe.value.filter((U) => U[t.optionValue] !== V)) : (S.value && S.value[t.optionValue] === V && (S.value = null, n("update:modelValue", null)), ((g = fe.value[0]) == null ? void 0 : g[t.optionValue]) === V && (ne.value = null)), k.success("Registro excluído com sucesso");
706
- } catch (V) {
707
- k.error(yt(V, "Erro ao excluir registro"));
708
- }
709
- });
710
- }
711
- return (i, g) => {
712
- const V = St("tooltip");
713
- return o(), c(Q, null, [
714
- m("div", Ht({
715
- class: ["w-autocompletefk", { "w-autocompletefk-has-clear": ye.value }],
716
- style: oe.value
717
- }, i.$attrs), [
718
- F(u(Pt), {
719
- ref_key: "acRef",
720
- ref: Ce,
721
- "model-value": Z.value,
722
- suggestions: M.value,
723
- multiple: e.multiple,
724
- "option-label": e.optionLabel,
725
- placeholder: me.value,
726
- disabled: e.disabled,
727
- "force-selection": e.forceSelection,
728
- loading: $.value,
729
- "show-clear": !1,
730
- fluid: "",
731
- onComplete: v,
732
- onItemSelect: y,
733
- "onUpdate:modelValue": h,
734
- onClear: l,
735
- onKeydown: r
736
- }, Je({ _: 2 }, [
737
- e.multiple ? {
738
- name: "chip",
739
- fn: q(({ value: E, index: U, removeCallback: $e }) => [
740
- !e.maxChips || U < e.maxChips ? se((o(), C(u(gt), {
741
- key: 0,
742
- class: "p-autocomplete-chip w-autocompletefk-chip",
743
- label: R(E),
744
- removable: "",
745
- onClick: B,
746
- onRemove: (Kt) => D(Kt, $e)
747
- }, null, 8, ["label", "onRemove"])), [
748
- [
749
- V,
750
- R(E),
751
- void 0,
752
- { top: !0 }
753
- ]
754
- ]) : U === e.maxChips ? se((o(), C(u(gt), {
755
- key: 1,
756
- class: "p-autocomplete-chip w-autocompletefk-chip w-autocompletefk-chip-more",
757
- label: `+${L.value}`,
758
- onClick: B
759
- }, null, 8, ["label"])), [
760
- [
761
- V,
762
- W.value,
763
- void 0,
764
- { top: !0 }
765
- ]
766
- ]) : (o(), c("span", Al))
767
- ]),
768
- key: "0"
769
- } : void 0
770
- ]), 1032, ["model-value", "suggestions", "multiple", "option-label", "placeholder", "disabled", "force-selection", "loading"]),
771
- ye.value ? se((o(), c("button", {
772
- key: 0,
773
- type: "button",
774
- "data-kbd-skip": "",
775
- tabindex: "-1",
776
- class: "w-autocompletefk-clear",
777
- onClick: j
778
- }, [...g[6] || (g[6] = [
779
- m("i", { class: "pi pi-times" }, null, -1)
780
- ])])), [
781
- [
782
- V,
783
- "Limpar",
784
- void 0,
785
- { top: !0 }
786
- ]
787
- ]) : b("", !0),
788
- se((o(), c("button", {
789
- type: "button",
790
- disabled: e.disabled,
791
- "data-kbd-skip": "",
792
- tabindex: "-1",
793
- class: "w-autocompletefk-trigger",
794
- onClick: B
795
- }, [...g[7] || (g[7] = [
796
- m("i", { class: "pi pi-search" }, null, -1)
797
- ])], 8, Ul)), [
798
- [
799
- V,
800
- "Pesquisar (F2)",
801
- void 0,
802
- { top: !0 }
803
- ]
804
- ])
805
- ], 16),
806
- F(u(nt), {
807
- visible: w.value,
808
- "onUpdate:visible": g[4] || (g[4] = (E) => w.value = E),
809
- header: e.dialogHeader || "Pesquisar",
810
- style: { width: "80vw" },
811
- modal: "",
812
- draggable: !1,
813
- class: "w-autocompletefk-dialog",
814
- onShow: _e
815
- }, {
816
- footer: q(() => [
817
- m("div", Ll, [
818
- F(u(O), {
819
- label: "Cancelar",
820
- severity: "secondary",
821
- text: "",
822
- onClick: g[3] || (g[3] = (E) => w.value = !1)
823
- }),
824
- F(u(O), {
825
- label: e.multiple && fe.value.length ? `Selecionar (${fe.value.length})` : "Selecionar",
826
- icon: "pi pi-check",
827
- disabled: !e.multiple && !fe.value.length,
828
- onClick: Ke
829
- }, null, 8, ["label", "disabled"])
830
- ])
831
- ]),
832
- default: q(() => [
833
- m("div", Bl, [
834
- F(u(je), { class: "w-autocompletefk-toolbar-search" }, {
835
- default: q(() => [
836
- F(u(qe), { class: "pi pi-search" }),
837
- F(u(re), {
838
- ref_key: "modalSearchInput",
839
- ref: He,
840
- modelValue: te.value,
841
- "onUpdate:modelValue": g[0] || (g[0] = (E) => te.value = E),
842
- placeholder: "Pesquisar...",
843
- class: "w-full",
844
- autofocus: "",
845
- onKeydown: Ut
846
- }, null, 8, ["modelValue"])
847
- ]),
848
- _: 1
849
- }),
850
- m("div", Tl, [
851
- it.value ? (o(), C(u(O), {
852
- key: 0,
853
- label: "Novo",
854
- icon: "pi pi-plus",
855
- size: "small",
856
- onClick: Ot
857
- })) : b("", !0)
858
- ])
859
- ]),
860
- m("div", {
861
- ref_key: "modalTableWrap",
862
- ref: Ge,
863
- onKeydownCapture: Bt
864
- }, [
865
- F(u(Dt), {
866
- selection: ne.value,
867
- "onUpdate:selection": g[1] || (g[1] = (E) => ne.value = E),
868
- "meta-key-selection": !1,
869
- value: _.value,
870
- loading: X.value,
871
- paginator: "",
872
- lazy: "",
873
- "striped-rows": "",
874
- "removable-sort": "",
875
- size: "small",
876
- rows: le.value,
877
- "total-records": we.value,
878
- "sort-field": Re.value ?? void 0,
879
- "sort-order": Fe.value,
880
- "selection-mode": e.multiple ? "multiple" : "single",
881
- "data-key": e.optionValue,
882
- onPage: G,
883
- onSort: g[2] || (g[2] = (E) => ke({ sortField: E.sortField, sortOrder: E.sortOrder })),
884
- onRowDblclick: Qe
885
- }, {
886
- empty: q(() => [...g[8] || (g[8] = [
887
- m("div", { class: "w-autocompletefk-empty" }, "Nenhum registro encontrado", -1)
888
- ])]),
889
- default: q(() => [
890
- F(u(Oe), {
891
- "selection-mode": e.multiple ? "multiple" : "single",
892
- "header-style": "width: 3rem"
893
- }, null, 8, ["selection-mode"]),
894
- (o(!0), c(Q, null, ae(f.value, (E) => (o(), C(u(Oe), {
895
- key: E.field,
896
- field: E.field,
897
- header: E.header,
898
- sortable: E.sortable ?? !0,
899
- style: ve(E.style)
900
- }, {
901
- body: q(({ data: U }) => [
902
- E.type ? (o(), C(vt, {
903
- key: 0,
904
- column: E,
905
- value: U[E.field],
906
- "row-data": U
907
- }, null, 8, ["column", "value", "row-data"])) : (o(), c(Q, { key: 1 }, [
908
- Ae(A(U[E.field]), 1)
909
- ], 64))
910
- ]),
911
- _: 2
912
- }, 1032, ["field", "header", "sortable", "style"]))), 128)),
913
- We.value ? (o(), C(u(Oe), {
914
- key: 0,
915
- header: "",
916
- style: { width: "6rem" }
917
- }, {
918
- body: q(({ data: E }) => [
919
- m("div", Nl, [
920
- Ze.value ? se((o(), C(u(O), {
921
- key: 0,
922
- icon: "pi pi-pencil",
923
- text: "",
924
- rounded: "",
925
- size: "small",
926
- onClick: (U) => zt(E)
927
- }, null, 8, ["onClick"])), [
928
- [
929
- V,
930
- "Editar",
931
- void 0,
932
- { top: !0 }
933
- ]
934
- ]) : b("", !0),
935
- Pe.value ? se((o(), C(u(O), {
936
- key: 1,
937
- icon: "pi pi-trash",
938
- text: "",
939
- rounded: "",
940
- size: "small",
941
- severity: "danger",
942
- onClick: (U) => qt(E)
943
- }, null, 8, ["onClick"])), [
944
- [
945
- V,
946
- "Excluir",
947
- void 0,
948
- { top: !0 }
949
- ]
950
- ]) : b("", !0)
951
- ])
952
- ]),
953
- _: 1
954
- })) : b("", !0)
955
- ]),
956
- _: 1
957
- }, 8, ["selection", "value", "loading", "rows", "total-records", "sort-field", "sort-order", "selection-mode", "data-key"])
958
- ], 544)
959
- ]),
960
- _: 1
961
- }, 8, ["visible", "header"]),
962
- ze.value ? (o(), C(At, {
963
- key: 0,
964
- visible: Ye.value,
965
- title: Tt.value,
966
- fields: d.value,
967
- "form-data": Le,
968
- "is-editing": rt.value,
969
- saving: st.value,
970
- width: e.dialogWidth,
971
- "onUpdate:visible": g[5] || (g[5] = (E) => {
972
- Ye.value = E, E || (Ne.value = null);
973
- }),
974
- "onUpdate:field": Wt,
975
- onSave: jt
976
- }, null, 8, ["visible", "title", "fields", "form-data", "is-editing", "saving", "width"])) : b("", !0)
977
- ], 64);
978
- };
979
- }
980
- }), zl = { class: "w-datepicker" }, Wl = { class: "w-datepicker-panel" }, jl = { class: "w-datepicker-actions" }, xt = /* @__PURE__ */ ie({
981
- __name: "WDatePicker",
982
- props: {
983
- modelValue: { default: null },
984
- valueFormat: { default: "iso" },
985
- showTime: { type: Boolean, default: !1 },
986
- autonow: { type: Boolean, default: !1 },
987
- minDate: {},
988
- maxDate: {},
989
- disabled: { type: Boolean, default: !1 },
990
- showClear: { type: Boolean, default: !0 },
991
- placeholder: {},
992
- invalid: { type: Boolean, default: !1 },
993
- inputId: {}
994
- },
995
- emits: ["update:modelValue"],
996
- setup(e, { emit: a }) {
997
- const t = e, n = a, s = al({
998
- showTime: () => t.showTime,
999
- valueFormat: () => t.valueFormat
1000
- }), p = T(""), k = T(null), I = T(null), S = P(() => ({ mask: s.mask() })), x = P(() => s.toDate(t.minDate) ?? void 0), M = P(() => s.toDate(t.maxDate) ?? void 0);
1001
- Ee(
1002
- () => t.modelValue,
1003
- (D) => {
1004
- const j = s.toDate(D);
1005
- k.value = j, p.value = s.toDisplay(j);
1006
- },
1007
- { immediate: !0 }
1008
- );
1009
- function $(D) {
1010
- n("update:modelValue", s.toValue(D));
1011
- }
1012
- function Z() {
1013
- if (p.value === "") {
1014
- $(null);
1015
- return;
1016
- }
1017
- const D = s.fromDisplay(p.value);
1018
- D && $(D);
1019
- }
1020
- function K() {
1021
- p.value = s.toDisplay(s.toDate(t.modelValue));
1022
- }
1023
- function H(D) {
1024
- D.key === "F2" && !t.disabled && (D.preventDefault(), R());
1025
- }
1026
- function Y(D) {
1027
- var oe;
1028
- $(D ?? null), t.showTime || (oe = I.value) == null || oe.hide();
1029
- }
1030
- function R() {
1031
- $(s.today());
1032
- }
1033
- function L() {
1034
- var D;
1035
- $(null), (D = I.value) == null || D.hide();
1036
- }
1037
- function W(D) {
1038
- var j;
1039
- t.disabled || (j = I.value) == null || j.toggle(D);
1040
- }
1041
- return pt(() => {
1042
- t.autonow && t.modelValue == null && R();
1043
- }), (D, j) => (o(), c("div", zl, [
1044
- F(u(je), null, {
1045
- default: q(() => [
1046
- se(F(u(re), {
1047
- id: e.inputId,
1048
- modelValue: p.value,
1049
- "onUpdate:modelValue": j[0] || (j[0] = (oe) => p.value = oe),
1050
- placeholder: e.placeholder ?? u(s).placeholder(),
1051
- disabled: e.disabled,
1052
- invalid: e.invalid,
1053
- fluid: "",
1054
- autocomplete: "off",
1055
- inputmode: "numeric",
1056
- onInput: Z,
1057
- onBlur: K,
1058
- onKeydown: H
1059
- }, null, 8, ["id", "modelValue", "placeholder", "disabled", "invalid"]), [
1060
- [u(at), S.value]
1061
- ]),
1062
- F(u(qe), {
1063
- class: ee(["pi pi-calendar w-datepicker-icon", { "w-datepicker-icon-disabled": e.disabled }]),
1064
- role: "button",
1065
- tabindex: "-1",
1066
- "aria-label": "Abrir calendário",
1067
- onClick: W
1068
- }, null, 8, ["class"])
1069
- ]),
1070
- _: 1
1071
- }),
1072
- F(u(Et), {
1073
- ref_key: "op",
1074
- ref: I
1075
- }, {
1076
- default: q(() => [
1077
- m("div", Wl, [
1078
- F(u(It), {
1079
- "model-value": k.value ?? void 0,
1080
- inline: "",
1081
- "show-time": e.showTime,
1082
- "hour-format": "24",
1083
- "min-date": x.value,
1084
- "max-date": M.value,
1085
- "onUpdate:modelValue": Y
1086
- }, null, 8, ["model-value", "show-time", "min-date", "max-date"]),
1087
- m("div", jl, [
1088
- F(u(O), {
1089
- label: "Hoje",
1090
- text: "",
1091
- size: "small",
1092
- onClick: R
1093
- }),
1094
- e.showClear ? (o(), C(u(O), {
1095
- key: 0,
1096
- label: "Limpar",
1097
- text: "",
1098
- size: "small",
1099
- severity: "secondary",
1100
- onClick: L
1101
- })) : b("", !0)
1102
- ])
1103
- ])
1104
- ]),
1105
- _: 1
1106
- }, 512)
1107
- ]));
1108
- }
1109
- }), ql = /* @__PURE__ */ ie({
1110
- __name: "WMoneyInput",
1111
- props: {
1112
- modelValue: {},
1113
- decimals: { default: 2 },
1114
- currency: { type: Boolean, default: !1 },
1115
- prefix: {},
1116
- suffix: {},
1117
- locale: { default: "pt-BR" },
1118
- disabled: { type: Boolean, default: !1 },
1119
- placeholder: {},
1120
- invalid: { type: Boolean }
1121
- },
1122
- emits: ["update:modelValue"],
1123
- setup(e, { emit: a }) {
1124
- const t = e, n = a, s = P(() => t.prefix ?? (t.currency ? "R$" : void 0)), p = P(() => !!s.value || !!t.suffix), k = P(() => {
1125
- const S = t.modelValue;
1126
- return S == null || Number.isNaN(S) ? "" : new Intl.NumberFormat(t.locale, {
1127
- minimumFractionDigits: t.decimals,
1128
- maximumFractionDigits: t.decimals
1129
- }).format(S);
1130
- });
1131
- function I(S) {
1132
- const x = S.target.value.replace(/\D/g, "");
1133
- if (!x) {
1134
- n("update:modelValue", null);
1135
- return;
1136
- }
1137
- const M = Number(x) / Math.pow(10, t.decimals);
1138
- n("update:modelValue", M);
1139
- }
1140
- return (S, x) => p.value ? (o(), C(u(dl), {
1141
- key: 0,
1142
- class: "w-money-input"
1143
- }, {
1144
- default: q(() => [
1145
- s.value ? (o(), C(u(bt), { key: 0 }, {
1146
- default: q(() => [
1147
- Ae(A(s.value), 1)
1148
- ]),
1149
- _: 1
1150
- })) : b("", !0),
1151
- F(u(re), {
1152
- "model-value": k.value,
1153
- inputmode: "numeric",
1154
- class: "w-money-input__field",
1155
- placeholder: e.placeholder,
1156
- disabled: e.disabled,
1157
- invalid: e.invalid,
1158
- onInput: I
1159
- }, null, 8, ["model-value", "placeholder", "disabled", "invalid"]),
1160
- e.suffix ? (o(), C(u(bt), { key: 1 }, {
1161
- default: q(() => [
1162
- Ae(A(e.suffix), 1)
1163
- ]),
1164
- _: 1
1165
- })) : b("", !0)
1166
- ]),
1167
- _: 1
1168
- })) : (o(), C(u(re), {
1169
- key: 1,
1170
- "model-value": k.value,
1171
- inputmode: "numeric",
1172
- fluid: "",
1173
- class: "w-money-input__field",
1174
- placeholder: e.placeholder,
1175
- disabled: e.disabled,
1176
- invalid: e.invalid,
1177
- onInput: I
1178
- }, null, 8, ["model-value", "placeholder", "disabled", "invalid"]));
1179
- }
1180
- }), Kl = { class: "w-imgcropper" }, Hl = ["src"], Gl = { class: "w-imgcropper-actions" }, Yl = ["accept"], Jl = { class: "w-imgcropper-stage" }, Xl = ["src"], Zl = { class: "w-imgcropper-zoom" }, lt = 300, Ql = /* @__PURE__ */ ie({
1181
- __name: "WImageCropper",
1182
- props: {
1183
- modelValue: { default: null },
1184
- accept: { default: "image/*" },
1185
- maxSize: { default: 5242880 },
1186
- aspectRatio: { default: 1 },
1187
- circular: { type: Boolean, default: !1 },
1188
- width: { default: 200 },
1189
- height: { default: 200 }
1190
- },
1191
- emits: ["update:modelValue", "error"],
1192
- setup(e, { emit: a }) {
1193
- const t = e, n = a, s = T(null);
1194
- Ee(
1195
- () => t.modelValue,
1196
- (y) => {
1197
- s.value && (URL.revokeObjectURL(s.value), s.value = null), y instanceof File && (s.value = URL.createObjectURL(y));
1198
- },
1199
- { immediate: !0 }
1200
- ), Gt(() => {
1201
- s.value && URL.revokeObjectURL(s.value);
1202
- });
1203
- const p = P(() => t.modelValue instanceof File ? s.value : typeof t.modelValue == "string" && t.modelValue ? t.modelValue : null), k = T(null);
1204
- function I() {
1205
- var y;
1206
- (y = k.value) == null || y.click();
1207
- }
1208
- function S(y) {
1209
- const h = (t.accept || "").trim();
1210
- return !h || h === "*" || h.includes("image/*") ? y.type.startsWith("image/") : h.split(",").map((l) => l.trim()).filter(Boolean).some((l) => l.endsWith("/*") ? y.type.startsWith(l.slice(0, -1)) : l.startsWith(".") ? y.name.toLowerCase().endsWith(l.toLowerCase()) : y.type === l);
1211
- }
1212
- let x = "image.png", M = "image/png", $ = null;
1213
- function Z(y) {
1214
- var _;
1215
- const h = y.target, l = (_ = h.files) == null ? void 0 : _[0];
1216
- if (h.value = "", !l) return;
1217
- if (!S(l)) {
1218
- n("error", "Tipo de arquivo não suportado.");
1219
- return;
1220
- }
1221
- if (l.size > t.maxSize) {
1222
- n("error", `Imagem acima do limite de ${(t.maxSize / 1048576).toFixed(1)}MB.`);
1223
- return;
1224
- }
1225
- x = l.name, M = l.type || "image/png";
1226
- const w = new FileReader();
1227
- w.onload = () => {
1228
- const X = new Image();
1229
- X.onload = () => {
1230
- $ = X, R.value = X.naturalWidth, L.value = X.naturalHeight, W.value = 1, Y.value = X.src, D.x = (oe.value - ge.value) / 2, D.y = (ye.value - Ve.value) / 2, H.value = !0;
1231
- }, X.onerror = () => n("error", "Não foi possível carregar a imagem."), X.src = String(w.result);
1232
- }, w.onerror = () => n("error", "Falha ao ler o arquivo."), w.readAsDataURL(l);
1233
- }
1234
- function K() {
1235
- n("update:modelValue", null);
1236
- }
1237
- const H = T(!1), Y = T(""), R = T(0), L = T(0), W = T(1), D = Me({ x: 0, y: 0 }), j = P(() => t.circular ? 1 : t.aspectRatio || 1), oe = P(() => j.value >= 1 ? lt : Math.round(lt * j.value)), ye = P(() => j.value >= 1 ? Math.round(lt / j.value) : lt), xe = P(
1238
- () => R.value && L.value ? Math.max(oe.value / R.value, ye.value / L.value) : 1
1239
- ), Ce = P(() => xe.value * W.value), ge = P(() => R.value * Ce.value), Ve = P(() => L.value * Ce.value);
1240
- function ue() {
1241
- D.x = Math.min(0, Math.max(oe.value - ge.value, D.x)), D.y = Math.min(0, Math.max(ye.value - Ve.value, D.y));
1242
- }
1243
- Ee(W, ue);
1244
- const Se = P(() => ({
1245
- width: `${ge.value}px`,
1246
- height: `${Ve.value}px`,
1247
- transform: `translate(${D.x}px, ${D.y}px)`
1248
- })), ce = T(!1);
1249
- let de = { x: 0, y: 0, ox: 0, oy: 0 };
1250
- function me(y) {
1251
- var h, l;
1252
- ce.value = !0, (l = (h = y.currentTarget).setPointerCapture) == null || l.call(h, y.pointerId), de = { x: y.clientX, y: y.clientY, ox: D.x, oy: D.y };
1253
- }
1254
- function pe(y) {
1255
- ce.value && (D.x = de.ox + (y.clientX - de.x), D.y = de.oy + (y.clientY - de.y), ue());
1256
- }
1257
- function be() {
1258
- ce.value = !1;
1259
- }
1260
- function he() {
1261
- return t.circular ? "image/png" : M === "image/jpeg" || M === "image/png" || M === "image/webp" ? M : "image/png";
1262
- }
1263
- function De(y) {
1264
- const h = y === "image/png" ? "png" : y === "image/webp" ? "webp" : "jpg";
1265
- return `${x.replace(/\.[^.]+$/, "") || "image"}.${h}`;
1266
- }
1267
- function v() {
1268
- if (!$) return;
1269
- const y = Ce.value, h = -D.x / y, l = -D.y / y, w = oe.value / y, _ = ye.value / y, X = document.createElement("canvas");
1270
- X.width = Math.max(1, Math.round(w)), X.height = Math.max(1, Math.round(_));
1271
- const te = X.getContext("2d");
1272
- if (!te) {
1273
- n("error", "Canvas indisponível neste ambiente.");
1274
- return;
1275
- }
1276
- t.circular && (te.beginPath(), te.ellipse(
1277
- X.width / 2,
1278
- X.height / 2,
1279
- X.width / 2,
1280
- X.height / 2,
1281
- 0,
1282
- 0,
1283
- Math.PI * 2
1284
- ), te.clip()), te.drawImage($, h, l, w, _, 0, 0, X.width, X.height);
1285
- const J = he();
1286
- X.toBlob(
1287
- (le) => {
1288
- if (!le) {
1289
- n("error", "Falha ao processar a imagem.");
1290
- return;
1291
- }
1292
- n("update:modelValue", new File([le], De(J), { type: J })), H.value = !1;
1293
- },
1294
- J,
1295
- 0.92
1296
- );
1297
- }
1298
- return (y, h) => (o(), c("div", Kl, [
1299
- m("div", {
1300
- class: ee(["w-imgcropper-preview", { "is-circular": e.circular, "is-empty": !p.value }]),
1301
- style: ve({ width: `${e.width}px`, height: `${e.height}px` })
1302
- }, [
1303
- p.value ? (o(), c(Q, { key: 0 }, [
1304
- m("img", {
1305
- src: p.value,
1306
- alt: "",
1307
- class: "w-imgcropper-img"
1308
- }, null, 8, Hl),
1309
- m("div", Gl, [
1310
- F(u(O), {
1311
- type: "button",
1312
- icon: "pi pi-pencil",
1313
- rounded: "",
1314
- text: "",
1315
- "aria-label": "Trocar imagem",
1316
- onClick: I
1317
- }),
1318
- F(u(O), {
1319
- type: "button",
1320
- icon: "pi pi-trash",
1321
- rounded: "",
1322
- text: "",
1323
- severity: "danger",
1324
- "aria-label": "Remover imagem",
1325
- onClick: K
1326
- })
1327
- ])
1328
- ], 64)) : N(y.$slots, "placeholder", { open: I }, () => [
1329
- m("button", {
1330
- type: "button",
1331
- class: "w-imgcropper-empty",
1332
- onClick: I
1333
- }, [...h[3] || (h[3] = [
1334
- m("i", { class: "pi pi-image" }, null, -1),
1335
- m("span", null, "Selecionar imagem", -1)
1336
- ])])
1337
- ], !0, 1)
1338
- ], 6),
1339
- m("input", {
1340
- ref_key: "fileInput",
1341
- ref: k,
1342
- type: "file",
1343
- accept: e.accept,
1344
- class: "w-imgcropper-file",
1345
- onChange: Z
1346
- }, null, 40, Yl),
1347
- F(u(nt), {
1348
- visible: H.value,
1349
- "onUpdate:visible": h[2] || (h[2] = (l) => H.value = l),
1350
- modal: "",
1351
- header: "Ajustar imagem",
1352
- "dismissable-mask": !1,
1353
- style: { width: "auto" }
1354
- }, {
1355
- footer: q(() => [
1356
- F(u(O), {
1357
- type: "button",
1358
- label: "Cancelar",
1359
- text: "",
1360
- onClick: h[1] || (h[1] = (l) => H.value = !1)
1361
- }),
1362
- F(u(O), {
1363
- type: "button",
1364
- label: "Confirmar",
1365
- onClick: v
1366
- })
1367
- ]),
1368
- default: q(() => [
1369
- m("div", Jl, [
1370
- m("div", {
1371
- class: ee(["w-imgcropper-viewport", { "is-circular": e.circular }]),
1372
- style: ve({ width: `${oe.value}px`, height: `${ye.value}px` }),
1373
- onPointerdown: me,
1374
- onPointermove: pe,
1375
- onPointerup: be,
1376
- onPointerleave: be
1377
- }, [
1378
- Y.value ? (o(), c("img", {
1379
- key: 0,
1380
- src: Y.value,
1381
- alt: "",
1382
- class: "w-imgcropper-cropimg",
1383
- style: ve(Se.value),
1384
- draggable: "false"
1385
- }, null, 12, Xl)) : b("", !0),
1386
- m("div", {
1387
- class: ee(["w-imgcropper-stencil", { "is-circular": e.circular }])
1388
- }, null, 2)
1389
- ], 38),
1390
- m("div", Zl, [
1391
- h[4] || (h[4] = m("i", { class: "pi pi-search-minus" }, null, -1)),
1392
- F(u(cl), {
1393
- modelValue: W.value,
1394
- "onUpdate:modelValue": h[0] || (h[0] = (l) => W.value = l),
1395
- min: 1,
1396
- max: 4,
1397
- step: 0.01,
1398
- class: "w-imgcropper-slider"
1399
- }, null, 8, ["modelValue"]),
1400
- h[5] || (h[5] = m("i", { class: "pi pi-search-plus" }, null, -1))
1401
- ])
1402
- ])
1403
- ]),
1404
- _: 1
1405
- }, 8, ["visible"])
1406
- ]));
1407
- }
1408
- }), _l = (e, a) => {
1409
- const t = e.__vccOpts || e;
1410
- for (const [n, s] of a)
1411
- t[n] = s;
1412
- return t;
1413
- }, ea = /* @__PURE__ */ _l(Ql, [["__scopeId", "data-v-95684d2d"]]), ta = { class: "w-transfer__pane" }, la = { class: "w-transfer__head" }, aa = { class: "w-transfer__count" }, oa = { class: "w-transfer__list" }, na = ["onClick"], ia = {
1414
- key: 0,
1415
- class: "w-transfer__empty"
1416
- }, sa = { class: "w-transfer__controls" }, ra = { class: "w-transfer__pane" }, ua = { class: "w-transfer__head" }, da = { class: "w-transfer__count" }, ca = { class: "w-transfer__list" }, ma = ["onClick"], fa = {
1417
- key: 0,
1418
- class: "w-transfer__empty"
1419
- }, va = /* @__PURE__ */ ie({
1420
- __name: "WTransferList",
1421
- props: {
1422
- source: {},
1423
- selected: { default: () => [] },
1424
- trackBy: { default: "id" },
1425
- optionLabel: { default: "nome" },
1426
- searchFields: {},
1427
- disabled: { type: Boolean }
1428
- },
1429
- emits: ["update:selected"],
1430
- setup(e, { emit: a }) {
1431
- const t = e, n = a, s = T(""), p = T(""), k = P(() => new Set(t.selected)), I = P(() => t.searchFields ?? [t.optionLabel]);
1432
- function S(L) {
1433
- return L[t.trackBy];
1434
- }
1435
- function x(L) {
1436
- return String(L[t.optionLabel] ?? "");
1437
- }
1438
- function M(L, W) {
1439
- if (!W) return !0;
1440
- const D = W.toLowerCase();
1441
- return I.value.some(
1442
- (j) => String(L[j] ?? "").toLowerCase().includes(D)
1443
- );
1444
- }
1445
- const $ = P(
1446
- () => t.source.filter((L) => !k.value.has(S(L)) && M(L, s.value))
1447
- ), Z = P(
1448
- () => t.source.filter((L) => k.value.has(S(L)) && M(L, p.value))
1449
- );
1450
- function K(L) {
1451
- t.disabled || n("update:selected", [...t.selected, S(L)]);
1452
- }
1453
- function H(L) {
1454
- if (t.disabled) return;
1455
- const W = S(L);
1456
- n(
1457
- "update:selected",
1458
- t.selected.filter((D) => D !== W)
1459
- );
1460
- }
1461
- function Y() {
1462
- t.disabled || n("update:selected", t.source.map(S));
1463
- }
1464
- function R() {
1465
- t.disabled || n("update:selected", []);
1466
- }
1467
- return (L, W) => (o(), c("div", {
1468
- class: ee(["w-transfer", { "w-transfer--disabled": e.disabled }])
1469
- }, [
1470
- m("div", ta, [
1471
- m("div", la, [
1472
- W[2] || (W[2] = m("span", { class: "w-transfer__title" }, "Disponíveis", -1)),
1473
- m("span", aa, A($.value.length), 1)
1474
- ]),
1475
- F(u(je), { class: "w-transfer__search" }, {
1476
- default: q(() => [
1477
- F(u(qe), { class: "pi pi-search" }),
1478
- F(u(re), {
1479
- modelValue: s.value,
1480
- "onUpdate:modelValue": W[0] || (W[0] = (D) => s.value = D),
1481
- placeholder: "Buscar...",
1482
- fluid: ""
1483
- }, null, 8, ["modelValue"])
1484
- ]),
1485
- _: 1
1486
- }),
1487
- m("ul", oa, [
1488
- (o(!0), c(Q, null, ae($.value, (D) => (o(), c("li", {
1489
- key: `a-${S(D)}`,
1490
- class: "w-transfer__item",
1491
- onClick: (j) => K(D)
1492
- }, [
1493
- m("span", null, A(x(D)), 1),
1494
- W[3] || (W[3] = m("i", { class: "pi pi-angle-right" }, null, -1))
1495
- ], 8, na))), 128)),
1496
- $.value.length ? b("", !0) : (o(), c("li", ia, "Nenhum item"))
1497
- ])
1498
- ]),
1499
- m("div", sa, [
1500
- F(u(O), {
1501
- type: "button",
1502
- icon: "pi pi-angle-double-right",
1503
- text: "",
1504
- rounded: "",
1505
- disabled: e.disabled || !$.value.length,
1506
- onClick: Y
1507
- }, null, 8, ["disabled"]),
1508
- F(u(O), {
1509
- type: "button",
1510
- icon: "pi pi-angle-double-left",
1511
- text: "",
1512
- rounded: "",
1513
- disabled: e.disabled || !e.selected.length,
1514
- onClick: R
1515
- }, null, 8, ["disabled"])
1516
- ]),
1517
- m("div", ra, [
1518
- m("div", ua, [
1519
- W[4] || (W[4] = m("span", { class: "w-transfer__title" }, "Selecionados", -1)),
1520
- m("span", da, A(Z.value.length), 1)
1521
- ]),
1522
- F(u(je), { class: "w-transfer__search" }, {
1523
- default: q(() => [
1524
- F(u(qe), { class: "pi pi-search" }),
1525
- F(u(re), {
1526
- modelValue: p.value,
1527
- "onUpdate:modelValue": W[1] || (W[1] = (D) => p.value = D),
1528
- placeholder: "Buscar...",
1529
- fluid: ""
1530
- }, null, 8, ["modelValue"])
1531
- ]),
1532
- _: 1
1533
- }),
1534
- m("ul", ca, [
1535
- (o(!0), c(Q, null, ae(Z.value, (D) => (o(), c("li", {
1536
- key: `s-${S(D)}`,
1537
- class: "w-transfer__item",
1538
- onClick: (j) => H(D)
1539
- }, [
1540
- W[5] || (W[5] = m("i", { class: "pi pi-angle-left" }, null, -1)),
1541
- m("span", null, A(x(D)), 1)
1542
- ], 8, ma))), 128)),
1543
- Z.value.length ? b("", !0) : (o(), c("li", fa, "Nenhum item"))
1544
- ])
1545
- ])
1546
- ], 2));
1547
- }
1548
- });
1549
- async function pa(e) {
1550
- const a = e.replace(/\D/g, "");
1551
- if (a.length !== 8) return null;
1552
- try {
1553
- const t = await fetch(`https://viacep.com.br/ws/${a}/json/`);
1554
- if (!t.ok) return null;
1555
- const n = await t.json();
1556
- return n.erro ? null : n;
1557
- } catch {
1558
- return null;
1559
- }
1560
- }
1561
- const ha = { class: "w-crud-form" }, ya = {
1562
- key: 0,
1563
- class: "w-crud-form-group-header"
1564
- }, ga = { class: "w-crud-form-group-title" }, ba = {
1565
- key: 0,
1566
- class: "w-crud-form-group-desc"
1567
- }, wa = { class: "w-crud-form-switch-label" }, ka = { class: "w-crud-form-label" }, $a = {
1568
- key: 0,
1569
- class: "w-crud-form-required"
1570
- }, xa = { class: "w-crud-form-color-row" }, Ca = { class: "w-crud-form-label" }, Va = {
1571
- key: 0,
1572
- class: "w-crud-form-error"
1573
- }, Sa = { class: "w-crud-form-label" }, Da = {
1574
- key: 0,
1575
- class: "w-crud-form-required"
1576
- }, Ea = { class: "w-crud-form-label" }, Fa = {
1577
- key: 0,
1578
- class: "w-crud-form-required"
1579
- }, Pa = {
1580
- key: 1,
1581
- class: "pi pi-spin pi-spinner w-crud-form-cep-spinner"
1582
- }, Ia = {
1583
- key: 16,
1584
- class: "w-crud-form-cep-error"
1585
- }, Ra = {
1586
- key: 17,
1587
- class: "w-crud-form-error"
1588
- }, Ma = /* @__PURE__ */ ie({
1589
- __name: "WFormRenderer",
1590
- props: {
1591
- fields: {},
1592
- formData: {},
1593
- isEditing: { type: Boolean },
1594
- disabled: { type: Boolean, default: !1 },
1595
- columns: { default: 2 }
1596
- },
1597
- emits: ["update:field"],
1598
- setup(e, { expose: a, emit: t }) {
1599
- const n = e, s = t, p = Me({}), k = Me({}), I = Me({}), S = Me({});
1600
- function x(v, y) {
1601
- const h = y.target.value, l = h.replace(/\D/g, "");
1602
- s("update:field", v.field, h), I[v.field] = null, S[v.field] && (clearTimeout(S[v.field]), S[v.field] = null), l.length === 8 && (S[v.field] = setTimeout(async () => {
1603
- k[v.field] = !0, I[v.field] = null;
1604
- try {
1605
- const w = await pa(l);
1606
- if (!w)
1607
- I[v.field] = "CEP não encontrado. Preencha os campos manualmente.";
1608
- else {
1609
- const _ = v.cepFields || {}, X = Object.keys(_);
1610
- for (const te of X) {
1611
- const J = _[te];
1612
- if (!J) continue;
1613
- const le = n.formData[J];
1614
- (le == null || le === "") && s("update:field", J, w[te] ?? "");
1615
- }
1616
- }
1617
- } finally {
1618
- k[v.field] = !1;
1619
- }
1620
- }, 400));
1621
- }
1622
- const M = P(
1623
- () => n.fields.filter((v) => v.visible === void 0 || v.visible === !0 ? !0 : typeof v.visible == "function" ? v.visible(n.formData, n.isEditing) : v.visible)
1624
- );
1625
- function $(v) {
1626
- return n.disabled || v.readonly || v.computed || v.disabledOnEdit && n.isEditing ? !0 : typeof v.disabled == "function" ? v.disabled(n.formData, n.isEditing) : !!v.disabled;
1627
- }
1628
- function Z(v) {
1629
- const y = v.endpointParams;
1630
- return typeof y == "function" ? y() : y;
1631
- }
1632
- const K = P(
1633
- () => n.fields.filter((v) => typeof v.calculate == "function")
1634
- );
1635
- Ee(
1636
- () => K.value.map((v) => v.calculate(n.formData, n.isEditing)),
1637
- (v) => {
1638
- K.value.forEach((y, h) => {
1639
- n.formData[y.field] !== v[h] && s("update:field", y.field, v[h]);
1640
- });
1641
- },
1642
- { immediate: !0 }
1643
- );
1644
- function H(v) {
1645
- return Yt(v) ? v.value : v;
1646
- }
1647
- const Y = P(() => {
1648
- const v = n.isEditing ? "edit" : "create", y = n.fields.find((l) => l.autofocus === !0 || l.autofocus === v);
1649
- if (y) return y.field;
1650
- const h = M.value.find((l) => !(l.type === "switch" || l.type === "fk" || l.type === "select" || l.type === "image" || l.disabled === !0 || l.disabledOnEdit && n.isEditing));
1651
- return (h == null ? void 0 : h.field) ?? null;
1652
- });
1653
- function R(v) {
1654
- return v.field === Y.value;
1655
- }
1656
- function L(v) {
1657
- if (v)
1658
- return v.replace(/9/g, "#").replace(/a/g, "S").replace(/\*/g, "X");
1659
- }
1660
- function W(v) {
1661
- if (!v) return "";
1662
- const y = String(v).replace(/\D/g, "").slice(0, 14);
1663
- return y.length <= 11 ? y.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})$/, "$1-$2") : y.replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1/$2").replace(/(\d{4})(\d{1,2})$/, "$1-$2");
1664
- }
1665
- function D(v, y) {
1666
- const h = y.target.value.replace(/\D/g, "").slice(0, 14);
1667
- s("update:field", v, h);
1668
- }
1669
- const j = Me({});
1670
- function oe(v) {
1671
- const y = n.formData[v.field];
1672
- if (y == null) return null;
1673
- const h = v.optionValue || "value";
1674
- return (H(v.options) || []).find((w) => w[h] === y) ?? null;
1675
- }
1676
- function ye(v) {
1677
- return j[v.field] || [];
1678
- }
1679
- function xe(v, y) {
1680
- const h = (y.query || "").toLowerCase(), l = H(v.options) || [], w = v.optionLabel || "label";
1681
- j[v.field] = l.filter(
1682
- (_) => String(_[w] || "").toLowerCase().includes(h)
1683
- );
1684
- }
1685
- function Ce(v, y) {
1686
- const h = v.optionValue || "value";
1687
- s("update:field", v.field, y.value[h]);
1688
- }
1689
- function ge(v) {
1690
- const y = n.formData[v.field];
1691
- return y ? String(y).replace("#", "") : "FFFFFF";
1692
- }
1693
- function Ve(v, y) {
1694
- s("update:field", v.field, `#${y}`);
1695
- }
1696
- function ue(v) {
1697
- const y = v.dependsOn;
1698
- return y ? (Array.isArray(y) ? y : [y]).map((l) => ({
1699
- field: l.param || l.field,
1700
- value: n.formData[l.field],
1701
- required: l.required
1702
- })) : void 0;
1703
- }
1704
- function Se(v) {
1705
- if (typeof v.validate == "function") {
1706
- const y = v.validate(n.formData[v.field]);
1707
- p[v.field] = y || null;
1708
- }
1709
- }
1710
- function ce() {
1711
- const v = [];
1712
- for (const y of n.fields)
1713
- if (typeof y.validate == "function") {
1714
- const h = y.validate(n.formData[y.field]);
1715
- p[y.field] = h || null, h && v.push(h);
1716
- }
1717
- return v;
1718
- }
1719
- function de() {
1720
- Object.keys(p).forEach((v) => delete p[v]);
1721
- }
1722
- function me(v) {
1723
- return Math.max(1, Math.floor(v.columns ?? n.columns));
1724
- }
1725
- function pe(v, y) {
1726
- const h = v.colSpan;
1727
- return h == null || h === "full" ? y : h === 0.5 ? Math.max(1, Math.round(y / 2)) : Math.min(Math.max(1, Math.floor(h)), y);
1728
- }
1729
- function be(v, y) {
1730
- return { "--w-col-span": pe(v, me(y)) };
1731
- }
1732
- function he(v, y) {
1733
- return pe(v, me(y)) === me(y) ? "w-crud-form-col-full" : "w-crud-form-col-half";
1734
- }
1735
- const De = P(() => {
1736
- var l, w, _, X, te;
1737
- const v = /* @__PURE__ */ new Map(), y = [], h = /* @__PURE__ */ new Map();
1738
- for (const J of M.value) {
1739
- const le = ((l = J.fieldGroup) == null ? void 0 : l.id) ?? "__default__";
1740
- v.has(le) || (v.set(le, {
1741
- id: le,
1742
- title: (w = J.fieldGroup) == null ? void 0 : w.title,
1743
- description: (_ = J.fieldGroup) == null ? void 0 : _.description,
1744
- columns: (X = J.fieldGroup) == null ? void 0 : X.columns,
1745
- fields: []
1746
- }), y.push(le), ((te = J.fieldGroup) == null ? void 0 : te.order) != null && h.set(le, J.fieldGroup.order)), v.get(le).fields.push(J);
1747
- }
1748
- return y.slice().sort((J, le) => {
1749
- const we = h.get(J), ne = h.get(le);
1750
- return we != null && ne != null ? we - ne : we != null ? -1 : ne != null ? 1 : y.indexOf(J) - y.indexOf(le);
1751
- }).map((J) => v.get(J));
1752
- });
1753
- return a({ validateAll: ce, clearErrors: de }), (v, y) => (o(), c("div", ha, [
1754
- (o(!0), c(Q, null, ae(De.value, (h) => (o(), c("div", {
1755
- key: h.id,
1756
- class: "w-crud-form-group"
1757
- }, [
1758
- h.title ? (o(), c("div", ya, [
1759
- m("h3", ga, A(h.title), 1),
1760
- h.description ? (o(), c("p", ba, A(h.description), 1)) : b("", !0)
1761
- ])) : b("", !0),
1762
- m("div", {
1763
- class: "w-crud-form-fields",
1764
- style: ve({ "--w-form-cols": me(h) })
1765
- }, [
1766
- (o(!0), c(Q, null, ae(h.fields, (l) => N(v.$slots, `field-${l.field}`, {
1767
- field: l,
1768
- formData: e.formData,
1769
- isEditing: e.isEditing,
1770
- setFormField: (w, _) => s("update:field", w, _)
1771
- }, () => [
1772
- l.type === "switch" ? (o(), c("div", {
1773
- key: 0,
1774
- class: "w-crud-form-switch",
1775
- style: ve(be(l, h))
1776
- }, [
1777
- F(u(il), {
1778
- "model-value": e.formData[l.field],
1779
- disabled: $(l),
1780
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1781
- }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"]),
1782
- m("label", wa, A(l.switchLabel || l.label), 1)
1783
- ], 4)) : l.type === "color" ? (o(), c("div", {
1784
- key: 1,
1785
- class: ee(he(l, h)),
1786
- style: ve(be(l, h))
1787
- }, [
1788
- m("label", ka, [
1789
- Ae(A(l.label) + " ", 1),
1790
- l.required ? (o(), c("span", $a, "*")) : b("", !0)
1791
- ]),
1792
- m("div", xa, [
1793
- F(u(sl), {
1794
- "model-value": ge(l),
1795
- disabled: $(l),
1796
- "onUpdate:modelValue": (w) => Ve(l, w)
1797
- }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"]),
1798
- F(u(re), {
1799
- "model-value": e.formData[l.field],
1800
- class: "w-28",
1801
- maxlength: "7",
1802
- placeholder: "#000000",
1803
- disabled: $(l),
1804
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1805
- }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"])
1806
- ])
1807
- ], 6)) : l.type === "image" ? (o(), c("div", {
1808
- key: 2,
1809
- class: ee(he(l, h)),
1810
- style: ve(be(l, h))
1811
- }, [
1812
- m("label", Ca, A(l.label), 1),
1813
- N(v.$slots, `image-${l.field}`, {
1814
- field: l,
1815
- formData: e.formData
1816
- }, () => [
1817
- F(ea, {
1818
- "model-value": e.formData[l.field],
1819
- accept: l.accept || "image/*",
1820
- "onUpdate:modelValue": (w) => s("update:field", l.field, w),
1821
- onError: (w) => {
1822
- p[l.field] = w;
1823
- }
1824
- }, null, 8, ["model-value", "accept", "onUpdate:modelValue", "onError"])
1825
- ]),
1826
- p[l.field] ? (o(), c("small", Va, A(p[l.field]), 1)) : b("", !0)
1827
- ], 6)) : l.type === "transfer" ? (o(), c("div", {
1828
- key: 3,
1829
- class: ee(he(l, h)),
1830
- style: ve(be(l, h))
1831
- }, [
1832
- m("label", Sa, [
1833
- Ae(A(l.label) + " ", 1),
1834
- l.required ? (o(), c("span", Da, "*")) : b("", !0)
1835
- ]),
1836
- F(va, {
1837
- source: H(l.options) || [],
1838
- selected: e.formData[l.field] || [],
1839
- "track-by": l.optionValue || "id",
1840
- "option-label": l.optionLabel || "nome",
1841
- "search-fields": l.searchFields,
1842
- disabled: $(l),
1843
- "onUpdate:selected": (w) => s("update:field", l.field, w)
1844
- }, null, 8, ["source", "selected", "track-by", "option-label", "search-fields", "disabled", "onUpdate:selected"])
1845
- ], 6)) : (o(), c("div", {
1846
- key: 4,
1847
- class: ee(he(l, h)),
1848
- style: ve(be(l, h))
1849
- }, [
1850
- m("label", Ea, [
1851
- Ae(A(l.label) + " ", 1),
1852
- l.required ? (o(), c("span", Fa, "*")) : b("", !0),
1853
- k[l.field] ? (o(), c("i", Pa)) : b("", !0)
1854
- ]),
1855
- (!l.type || l.type === "text") && l.mask ? se((o(), C(u(re), {
1856
- key: 0,
1857
- "model-value": e.formData[l.field],
1858
- fluid: "",
1859
- autofocus: R(l) || void 0,
1860
- placeholder: l.placeholder,
1861
- disabled: $(l),
1862
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1863
- }, null, 8, ["model-value", "autofocus", "placeholder", "disabled", "onUpdate:modelValue"])), [
1864
- [u(at), { mask: L(l.mask) }]
1865
- ]) : !l.type || l.type === "text" ? (o(), C(u(re), {
1866
- key: 1,
1867
- "model-value": e.formData[l.field],
1868
- fluid: "",
1869
- autofocus: R(l) || void 0,
1870
- placeholder: l.placeholder,
1871
- disabled: $(l),
1872
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1873
- }, null, 8, ["model-value", "autofocus", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "email" ? (o(), C(u(re), {
1874
- key: 2,
1875
- "model-value": e.formData[l.field],
1876
- type: "email",
1877
- fluid: "",
1878
- autofocus: R(l) || void 0,
1879
- placeholder: l.placeholder,
1880
- disabled: $(l),
1881
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1882
- }, null, 8, ["model-value", "autofocus", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "password" ? (o(), C(u(rl), {
1883
- key: 3,
1884
- "model-value": e.formData[l.field],
1885
- fluid: "",
1886
- "toggle-mask": "",
1887
- feedback: l.feedback !== !1,
1888
- placeholder: l.placeholder,
1889
- disabled: $(l),
1890
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1891
- }, null, 8, ["model-value", "feedback", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "number" ? (o(), C(u(ot), {
1892
- key: 4,
1893
- "model-value": e.formData[l.field],
1894
- fluid: "",
1895
- locale: "pt-BR",
1896
- min: l.min,
1897
- max: l.max,
1898
- "min-fraction-digits": l.minFractionDigits,
1899
- "max-fraction-digits": l.maxFractionDigits,
1900
- suffix: l.suffix,
1901
- prefix: l.prefix,
1902
- placeholder: l.placeholder,
1903
- disabled: $(l),
1904
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1905
- }, null, 8, ["model-value", "min", "max", "min-fraction-digits", "max-fraction-digits", "suffix", "prefix", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "currency" && l.fillFromRight ? (o(), C(ql, {
1906
- key: 5,
1907
- "model-value": e.formData[l.field],
1908
- decimals: l.decimals ?? 2,
1909
- currency: "",
1910
- prefix: l.prefix,
1911
- suffix: l.suffix,
1912
- placeholder: l.placeholder,
1913
- disabled: $(l),
1914
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1915
- }, null, 8, ["model-value", "decimals", "prefix", "suffix", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "currency" ? (o(), C(u(ot), {
1916
- key: 6,
1917
- "model-value": e.formData[l.field],
1918
- fluid: "",
1919
- mode: "currency",
1920
- currency: "BRL",
1921
- locale: "pt-BR",
1922
- min: l.min,
1923
- max: l.max,
1924
- placeholder: l.placeholder,
1925
- disabled: $(l),
1926
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1927
- }, null, 8, ["model-value", "min", "max", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "select" ? (o(), C(u(ft), {
1928
- key: 7,
1929
- "model-value": e.formData[l.field],
1930
- fluid: "",
1931
- options: H(l.options),
1932
- "option-label": l.optionLabel || "label",
1933
- "option-value": l.optionValue || "value",
1934
- "show-clear": l.showClear !== !1,
1935
- placeholder: l.placeholder,
1936
- disabled: $(l),
1937
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1938
- }, null, 8, ["model-value", "options", "option-label", "option-value", "show-clear", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "autocomplete" ? (o(), C(u(Pt), {
1939
- key: 8,
1940
- "model-value": oe(l),
1941
- fluid: "",
1942
- suggestions: ye(l),
1943
- "option-label": l.optionLabel || "label",
1944
- placeholder: l.placeholder,
1945
- disabled: $(l),
1946
- onComplete: (w) => xe(l, w),
1947
- onItemSelect: (w) => Ce(l, w),
1948
- onClear: (w) => s("update:field", l.field, null)
1949
- }, null, 8, ["model-value", "suggestions", "option-label", "placeholder", "disabled", "onComplete", "onItemSelect", "onClear"])) : l.type === "fk" ? (o(), C(Ol, {
1950
- key: 9,
1951
- "model-value": e.formData[l.field],
1952
- autofocus: R(l) || void 0,
1953
- endpoint: l.endpoint,
1954
- "endpoint-params": Z(l),
1955
- drilldown: ue(l),
1956
- "blocked-placeholder": l.blockedPlaceholder,
1957
- "option-label": l.optionLabel || "nome",
1958
- placeholder: l.placeholder,
1959
- disabled: $(l),
1960
- "show-clear": l.showClear !== !1,
1961
- "dialog-header": l.label,
1962
- "crud-fields": l.crudFields,
1963
- "crud-columns": l.crudColumns,
1964
- "can-create": l.canCreate,
1965
- "can-edit": l.canEdit,
1966
- "can-delete": l.canDelete,
1967
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1968
- }, null, 8, ["model-value", "autofocus", "endpoint", "endpoint-params", "drilldown", "blocked-placeholder", "option-label", "placeholder", "disabled", "show-clear", "dialog-header", "crud-fields", "crud-columns", "can-create", "can-edit", "can-delete", "onUpdate:modelValue"])) : l.type === "date" ? (o(), C(xt, {
1969
- key: 10,
1970
- "model-value": e.formData[l.field],
1971
- "value-format": "date",
1972
- autonow: l.autonow,
1973
- "min-date": l.minDate,
1974
- "max-date": l.maxDate,
1975
- placeholder: l.placeholder,
1976
- disabled: $(l),
1977
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1978
- }, null, 8, ["model-value", "autonow", "min-date", "max-date", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "datetime" ? (o(), C(xt, {
1979
- key: 11,
1980
- "model-value": e.formData[l.field],
1981
- "value-format": "date",
1982
- "show-time": "",
1983
- autonow: l.autonow,
1984
- "min-date": l.minDate,
1985
- "max-date": l.maxDate,
1986
- placeholder: l.placeholder,
1987
- disabled: $(l),
1988
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
1989
- }, null, 8, ["model-value", "autonow", "min-date", "max-date", "placeholder", "disabled", "onUpdate:modelValue"])) : l.type === "cpf_cnpj" ? (o(), C(u(re), {
1990
- key: 12,
1991
- "model-value": W(e.formData[l.field]),
1992
- fluid: "",
1993
- maxlength: "18",
1994
- placeholder: l.placeholder || "000.000.000-00",
1995
- disabled: $(l),
1996
- invalid: !!p[l.field],
1997
- onInput: (w) => D(l.field, w),
1998
- onBlur: (w) => Se(l)
1999
- }, null, 8, ["model-value", "placeholder", "disabled", "invalid", "onInput", "onBlur"])) : l.type === "mask" ? se((o(), C(u(re), {
2000
- key: 13,
2001
- "model-value": e.formData[l.field],
2002
- fluid: "",
2003
- placeholder: l.placeholder,
2004
- disabled: $(l),
2005
- invalid: !!p[l.field],
2006
- "onUpdate:modelValue": (w) => s("update:field", l.field, w),
2007
- onBlur: (w) => Se(l)
2008
- }, null, 8, ["model-value", "placeholder", "disabled", "invalid", "onUpdate:modelValue", "onBlur"])), [
2009
- [u(at), { mask: L(l.mask) }]
2010
- ]) : l.type === "cep" ? se((o(), C(u(re), {
2011
- key: 14,
2012
- "model-value": e.formData[l.field],
2013
- fluid: "",
2014
- placeholder: l.placeholder || "00000-000",
2015
- disabled: $(l),
2016
- invalid: !!I[l.field],
2017
- onInput: (w) => x(l, w)
2018
- }, null, 8, ["model-value", "placeholder", "disabled", "invalid", "onInput"])), [
2019
- [u(at), { mask: "#####-###" }]
2020
- ]) : l.type === "textarea" ? (o(), C(u(nl), {
2021
- key: 15,
2022
- "model-value": e.formData[l.field],
2023
- fluid: "",
2024
- autofocus: R(l) || void 0,
2025
- rows: l.rows || 3,
2026
- placeholder: l.placeholder,
2027
- disabled: $(l),
2028
- "onUpdate:modelValue": (w) => s("update:field", l.field, w)
2029
- }, null, 8, ["model-value", "autofocus", "rows", "placeholder", "disabled", "onUpdate:modelValue"])) : b("", !0),
2030
- I[l.field] ? (o(), c("small", Ia, A(I[l.field]), 1)) : p[l.field] ? (o(), c("small", Ra, A(p[l.field]), 1)) : b("", !0)
2031
- ], 6))
2032
- ], void 0, l.field)), 128))
2033
- ], 4)
2034
- ]))), 128))
2035
- ]));
2036
- }
2037
- }), Aa = { class: "w-crud-form-footer" }, At = /* @__PURE__ */ ie({
2038
- __name: "WCrudFormDialog",
2039
- props: {
2040
- visible: { type: Boolean },
2041
- title: {},
2042
- fields: {},
2043
- formData: {},
2044
- isEditing: { type: Boolean },
2045
- saving: { type: Boolean },
2046
- disabled: { type: Boolean, default: !1 },
2047
- width: { default: "480px" },
2048
- formColumns: { default: void 0 },
2049
- keyboardNav: { type: Boolean }
2050
- },
2051
- emits: ["update:visible", "update:field", "save"],
2052
- setup(e, { emit: a }) {
2053
- const t = e, n = a, s = T(null), p = T(null);
2054
- function k() {
2055
- s.value ? s.value.validateAll().length === 0 && n("save") : n("save");
2056
- }
2057
- const { focusFirst: I, handleKeydown: S } = ol(p, {
2058
- enabled: () => t.keyboardNav === !0,
2059
- onSubmit: k
2060
- });
2061
- return Ee(
2062
- () => t.visible,
2063
- (x) => {
2064
- x && s.value && s.value.clearErrors();
2065
- }
2066
- ), (x, M) => (o(), C(u(nt), {
2067
- visible: e.visible,
2068
- header: e.title,
2069
- style: ve({ width: e.width }),
2070
- modal: "",
2071
- draggable: !1,
2072
- class: "w-crud-form-dialog",
2073
- "onUpdate:visible": M[3] || (M[3] = ($) => n("update:visible", $)),
2074
- onShow: u(I)
2075
- }, {
2076
- default: q(() => [
2077
- m("form", {
2078
- ref_key: "formRef",
2079
- ref: p,
2080
- class: "w-crud-form",
2081
- onSubmit: Jt(k, ["prevent"]),
2082
- onKeydown: M[2] || (M[2] = //@ts-ignore
2083
- (...$) => u(S) && u(S)(...$))
2084
- }, [
2085
- F(Ma, {
2086
- ref_key: "rendererRef",
2087
- ref: s,
2088
- fields: e.fields,
2089
- "form-data": e.formData,
2090
- "is-editing": e.isEditing,
2091
- disabled: e.disabled,
2092
- columns: e.formColumns,
2093
- "onUpdate:field": M[0] || (M[0] = ($, Z) => n("update:field", $, Z))
2094
- }, Je({ _: 2 }, [
2095
- ae(e.fields, ($) => ({
2096
- name: `field-${$.field}`,
2097
- fn: q((Z) => [
2098
- N(x.$slots, `field-${$.field}`, ct(mt(Z)))
2099
- ])
2100
- })),
2101
- ae(e.fields.filter(($) => $.type === "image"), ($) => ({
2102
- name: `image-${$.field}`,
2103
- fn: q((Z) => [
2104
- N(x.$slots, `image-${$.field}`, ct(mt(Z)))
2105
- ])
2106
- }))
2107
- ]), 1032, ["fields", "form-data", "is-editing", "disabled", "columns"]),
2108
- m("div", Aa, [
2109
- N(x.$slots, "footer", {
2110
- saving: e.saving,
2111
- disabled: e.disabled
2112
- }, () => [
2113
- F(u(O), {
2114
- type: "button",
2115
- label: e.disabled ? "Fechar" : "Cancelar",
2116
- severity: "secondary",
2117
- text: "",
2118
- disabled: e.saving,
2119
- "data-kbd-skip": "",
2120
- onClick: M[1] || (M[1] = ($) => n("update:visible", !1))
2121
- }, null, 8, ["label", "disabled"]),
2122
- e.disabled ? b("", !0) : (o(), C(u(O), {
2123
- key: 0,
2124
- type: "submit",
2125
- label: e.isEditing ? "Atualizar" : "Salvar",
2126
- icon: "pi pi-check",
2127
- loading: e.saving
2128
- }, null, 8, ["label", "loading"]))
2129
- ])
2130
- ])
2131
- ], 544)
2132
- ]),
2133
- _: 3
2134
- }, 8, ["visible", "header", "style", "onShow"]));
2135
- }
2136
- });
2137
- function Ua(e, a) {
2138
- const t = a[e.field];
2139
- return e.format ? e.format(t, a) : t == null ? "" : typeof t == "boolean" ? t ? "Sim" : "Não" : String(t);
2140
- }
2141
- function Ct(e, a) {
2142
- return e.includes('"') || e.includes(a) || e.includes(`
2143
- `) || e.includes("\r") ? `"${e.replace(/"/g, '""')}"` : e;
2144
- }
2145
- function Ba(e, a, t = {}) {
2146
- const n = t.separator ?? ";", s = a.map((k) => Ct(k.header, n)).join(n), p = e.map((k) => a.map((I) => Ct(Ua(I, k), n)).join(n));
2147
- return "\uFEFF" + [s, ...p].join(`\r
2148
- `);
2149
- }
2150
- function Ta(e, a = "export.csv") {
2151
- const t = new Blob([e], { type: "text/csv;charset=utf-8;" }), n = URL.createObjectURL(t), s = document.createElement("a");
2152
- s.href = n, s.download = a, document.body.appendChild(s), s.click(), document.body.removeChild(s), URL.revokeObjectURL(n);
2153
- }
2154
- const Na = { class: "w-crud" }, La = {
2155
- key: 0,
2156
- class: "w-crud-header"
2157
- }, Oa = { class: "w-crud-header-content" }, za = { class: "w-crud-title" }, Wa = {
2158
- key: 0,
2159
- class: "w-crud-subtitle"
2160
- }, ja = { class: "w-crud-header-actions" }, qa = {
2161
- key: 0,
2162
- class: "w-crud-kpis"
2163
- }, Ka = { class: "w-crud-kpi-content" }, Ha = { class: "w-crud-kpi-label" }, Ga = { class: "w-crud-kpi-value" }, Ya = { class: "w-crud-content-main" }, Ja = {
2164
- key: 0,
2165
- class: "w-crud-filters",
2166
- style: { display: "flex", "flex-wrap": "wrap", gap: "0.5rem", "align-items": "center", "margin-bottom": "0.75rem" }
2167
- }, Xa = {
2168
- key: 1,
2169
- class: "w-crud-table"
2170
- }, Za = {
2171
- key: 0,
2172
- class: "w-crud-bulkbar",
2173
- style: { display: "flex", "align-items": "center", gap: "0.5rem", "margin-bottom": "0.5rem", padding: "0.5rem 0.75rem", "border-radius": "8px", background: "var(--p-primary-50, #eef2ff)", color: "var(--p-primary-700, #3730a3)" }
2174
- }, Qa = { style: { "font-weight": "600", "font-size": "0.85rem", "margin-right": "auto" } }, _a = { class: "w-crud-toolbar" }, eo = { class: "w-crud-toolbar-start" }, to = { class: "w-crud-toolbar-end" }, lo = { style: { display: "flex", "flex-direction": "column", gap: "0.35rem", "min-width": "180px" } }, ao = ["for"], oo = {
2175
- key: 2,
2176
- class: "w-crud-view-toggle"
2177
- }, no = { class: "w-crud-actions" }, io = {
2178
- key: 2,
2179
- class: "w-crud-cards-wrap"
2180
- }, so = { class: "w-crud-toolbar w-crud-toolbar--standalone" }, ro = { class: "w-crud-toolbar-start" }, uo = { class: "w-crud-toolbar-end" }, co = {
2181
- key: 1,
2182
- class: "w-crud-view-toggle"
2183
- }, mo = {
2184
- key: 0,
2185
- class: "w-crud-cards-loading"
2186
- }, fo = ["onClick", "onDblclick", "onContextmenu"], vo = { class: "w-crud-card-body" }, po = {
2187
- key: 0,
2188
- class: "w-crud-card-label"
2189
- }, ho = { class: "w-crud-card-value" }, yo = {
2190
- key: 0,
2191
- class: "w-crud-card-actions"
2192
- }, go = {
2193
- key: 0,
2194
- class: "w-crud-rail"
2195
- }, bo = {
2196
- key: 1,
2197
- class: "w-crud-rail-sep"
2198
- }, wo = {
2199
- key: 2,
2200
- class: "w-crud-rail-sep"
2201
- }, Xn = /* @__PURE__ */ ie({
2202
- __name: "WCrudView",
2203
- props: {
2204
- crud: {},
2205
- title: {},
2206
- subtitle: {},
2207
- showSearch: { type: Boolean, default: !0 },
2208
- showHeader: { type: Boolean, default: !0 },
2209
- dialogWidth: { default: "480px" },
2210
- formColumns: {},
2211
- autoInit: { type: Boolean, default: !0 },
2212
- showKpi: { type: Boolean, default: !1 },
2213
- kpiIcon: { default: "pi pi-list" },
2214
- kpiLabel: { default: "Total de Registros" },
2215
- extraKpis: { default: () => [] },
2216
- expandable: { type: Boolean, default: !1 },
2217
- viewToggle: { type: Boolean, default: !0 },
2218
- defaultView: { default: "table" },
2219
- cardFields: { default: 4 },
2220
- cardBare: { type: Boolean },
2221
- actionRail: { type: Boolean, default: !0 },
2222
- contextMenu: { type: Boolean, default: !0 },
2223
- showPrint: { type: Boolean, default: !1 },
2224
- exportCsv: { type: Boolean, default: !0 },
2225
- csvFilename: { default: "export.csv" },
2226
- csvScope: { default: "all" },
2227
- csvPageSize: { default: 200 },
2228
- persistState: {}
2229
- },
2230
- emits: ["row-expand", "row-collapse", "print"],
2231
- setup(e, { emit: a }) {
2232
- const t = e, n = a, s = Xt(), { formatNumber: p } = ht(), k = T({});
2233
- function I() {
2234
- return t.persistState ? `wcrud:view:${t.persistState}` : null;
2235
- }
2236
- function S() {
2237
- const d = I();
2238
- if (d) {
2239
- const f = localStorage.getItem(d);
2240
- if (f === "table" || f === "cards") return f;
2241
- }
2242
- return t.defaultView;
2243
- }
2244
- const x = T(S());
2245
- function M(d) {
2246
- return x.value === d;
2247
- }
2248
- function $(d) {
2249
- x.value = d;
2250
- const f = I();
2251
- f && localStorage.setItem(f, d);
2252
- }
2253
- const Z = P(
2254
- () => (t.crud.pagination.page - 1) * t.crud.pagination.pageSize
2255
- ), K = Me({ hidden: [] }), H = T(null);
2256
- function Y() {
2257
- return t.persistState ? `wcrud:cols:${t.persistState}` : null;
2258
- }
2259
- function R() {
2260
- const d = Y();
2261
- if (d)
2262
- try {
2263
- const f = JSON.parse(localStorage.getItem(d) || "{}");
2264
- Array.isArray(f.hidden) && (K.hidden = f.hidden);
2265
- } catch {
2266
- }
2267
- }
2268
- function L() {
2269
- const d = Y();
2270
- d && localStorage.setItem(d, JSON.stringify({ hidden: K.hidden }));
2271
- }
2272
- function W() {
2273
- return t.persistState ? `wcrud:filters:${t.persistState}` : null;
2274
- }
2275
- function D() {
2276
- const d = W();
2277
- if (d)
2278
- try {
2279
- const f = JSON.parse(localStorage.getItem(d) || "{}");
2280
- if (f && typeof f.columnFilters == "object" && f.columnFilters)
2281
- for (const [z, r] of Object.entries(f.columnFilters))
2282
- r != null && r !== "" && (t.crud.columnFilters[z] = r);
2283
- typeof f.search == "string" && f.search && (t.crud.search.value = f.search);
2284
- } catch {
2285
- }
2286
- }
2287
- function j() {
2288
- const d = W();
2289
- d && localStorage.setItem(
2290
- d,
2291
- JSON.stringify({
2292
- columnFilters: { ...t.crud.columnFilters },
2293
- search: t.crud.search.value
2294
- })
2295
- );
2296
- }
2297
- Ee(t.crud.columnFilters, j, { deep: !0 }), Ee(t.crud.search, j);
2298
- const oe = P(() => t.crud.config.columns.filter((d) => d.visible !== !1));
2299
- function ye(d, f) {
2300
- K.hidden = f ? K.hidden.filter((z) => z !== d) : [.../* @__PURE__ */ new Set([...K.hidden, d])], L();
2301
- }
2302
- const xe = P(
2303
- () => t.crud.config.columns.filter((d) => d.visible !== !1 && !K.hidden.includes(d.field)).map((d) => d.type === "number" && !d.align ? { ...d, align: "right" } : d.type === "currency" && !d.align ? { ...d, align: "right" } : d)
2304
- );
2305
- function Ce(d) {
2306
- if (d.align === "right") return "text-right";
2307
- if (d.align === "center") return "text-center";
2308
- }
2309
- const ge = P(() => xe.value.slice(0, t.cardFields)), Ve = P(() => {
2310
- const d = [];
2311
- return t.crud.config.canEdit !== !1 && d.push({ action: "edit", icon: "pi pi-pencil", tooltip: "Editar" }), t.crud.config.canCreate !== !1 && d.push({
2312
- action: "duplicate",
2313
- icon: "pi pi-copy",
2314
- tooltip: "Duplicar",
2315
- severity: "info"
2316
- }), t.crud.config.canDelete !== !1 && d.push({
2317
- action: "delete",
2318
- icon: "pi pi-trash",
2319
- tooltip: "Excluir",
2320
- severity: "danger"
2321
- }), d;
2322
- }), ue = P(
2323
- () => t.crud.config.rowActions ?? Ve.value
2324
- ), Se = P(
2325
- () => ue.value.length > 0 || !!s["row-actions"]
2326
- );
2327
- function ce(d, f) {
2328
- if (d.handler) {
2329
- d.handler(f);
2330
- return;
2331
- }
2332
- d.action === "edit" ? t.crud.openEditDialog(f) : d.action === "view" ? t.crud.openViewDialog(f) : d.action === "duplicate" ? t.crud.openDuplicateDialog(f) : d.action === "delete" && (s["delete-message"] ? (de.value = f, me.value = !0) : t.crud.confirmDelete(f));
2333
- }
2334
- const de = T(null), me = T(!1), pe = T(!1);
2335
- async function be() {
2336
- if (de.value) {
2337
- pe.value = !0;
2338
- try {
2339
- await t.crud.performDelete(de.value), me.value = !1, de.value = null;
2340
- } finally {
2341
- pe.value = !1;
2342
- }
2343
- }
2344
- }
2345
- function he(d, f) {
2346
- return d.visible ? d.visible(f) : !0;
2347
- }
2348
- function De(d, f) {
2349
- return d.disabled ? d.disabled(f) : !1;
2350
- }
2351
- const v = P(() => {
2352
- const d = [];
2353
- return t.showKpi && d.push({
2354
- icon: t.kpiIcon,
2355
- label: t.kpiLabel,
2356
- value: p(t.crud.pagination.rows, 0)
2357
- }), d.push(...t.extraKpis), d;
2358
- }), y = P(() => t.crud.config.canCreate !== !1), h = T(null), l = P(() => t.crud.config.selectionMode === "multiple"), w = P(() => t.crud.config.editMode === "cell"), _ = P(() => new Map(t.crud.config.form.map((d) => [d.field, d]))), X = ["text", "email", "number", "currency"];
2359
- function te(d) {
2360
- const f = _.value.get(d);
2361
- return f && X.includes(f.type || "text") ? f : void 0;
2362
- }
2363
- function J(d) {
2364
- d.newValue !== (d.value ?? d.data[d.field]) && t.crud.updateField(d.data, d.field, d.newValue);
2365
- }
2366
- const le = P(
2367
- () => t.crud.config.columns.filter((d) => d.filter)
2368
- ), we = [
2369
- { label: "Sim", value: !0 },
2370
- { label: "Não", value: !1 }
2371
- ];
2372
- function ne(d) {
2373
- var f;
2374
- return ((f = d.filter) == null ? void 0 : f.param) || d.field;
2375
- }
2376
- const fe = {};
2377
- function Re(d, f) {
2378
- const z = ne(d);
2379
- fe[z] && clearTimeout(fe[z]), fe[z] = setTimeout(() => t.crud.setColumnFilter(z, f || null), 300);
2380
- }
2381
- const Fe = T(null);
2382
- function Ue(d) {
2383
- h.value = d;
2384
- }
2385
- function Be(d) {
2386
- var f;
2387
- t.contextMenu && (h.value = d.data, (f = Fe.value) == null || f.show(d.originalEvent));
2388
- }
2389
- function ze(d, f) {
2390
- var z;
2391
- t.contextMenu && (d.preventDefault(), h.value = f, (z = Fe.value) == null || z.show(d));
2392
- }
2393
- const it = P(() => {
2394
- const d = h.value;
2395
- if (!d) return [];
2396
- const f = [
2397
- {
2398
- label: "Ver detalhes",
2399
- icon: "pi pi-eye",
2400
- command: () => t.crud.openViewDialog(d)
2401
- }
2402
- ];
2403
- for (const z of ue.value)
2404
- he(z, d) && f.push({
2405
- label: z.tooltip ?? z.action,
2406
- icon: z.icon,
2407
- class: z.severity === "danger" ? "w-crud-ctx-danger" : void 0,
2408
- disabled: De(z, d),
2409
- command: () => ce(z, d)
2410
- });
2411
- return t.showPrint && f.push({
2412
- label: "Imprimir",
2413
- icon: "pi pi-print",
2414
- command: () => n("print", d)
2415
- }), t.exportCsv && (f.push({ separator: !0 }), f.push({
2416
- label: t.csvScope === "all" ? "Exportar tudo (CSV)" : "Exportar página (CSV)",
2417
- icon: "pi pi-download",
2418
- command: () => We()
2419
- })), f;
2420
- });
2421
- function Ze() {
2422
- h.value && n("print", h.value);
2423
- }
2424
- const Pe = T(!1);
2425
- async function We() {
2426
- if (!Pe.value) {
2427
- Pe.value = !0;
2428
- try {
2429
- const d = t.csvScope === "page" ? t.crud.items.value : await t.crud.fetchAll(t.csvPageSize), f = Ba(d, xe.value);
2430
- Ta(f, t.csvFilename);
2431
- } finally {
2432
- Pe.value = !1;
2433
- }
2434
- }
2435
- }
2436
- return pt(() => {
2437
- R(), D(), t.autoInit && t.crud.init();
2438
- }), (d, f) => {
2439
- const z = St("tooltip");
2440
- return o(), c("div", Na, [
2441
- e.showHeader ? (o(), c("div", La, [
2442
- m("div", Oa, [
2443
- m("h1", za, A(e.title), 1),
2444
- e.subtitle ? (o(), c("p", Wa, A(e.subtitle), 1)) : b("", !0)
2445
- ]),
2446
- m("div", ja, [
2447
- N(d.$slots, "header-actions"),
2448
- y.value && !e.actionRail ? (o(), C(u(O), {
2449
- key: 0,
2450
- label: "Novo",
2451
- icon: "pi pi-plus",
2452
- onClick: f[0] || (f[0] = (r) => e.crud.openCreateDialog())
2453
- })) : b("", !0)
2454
- ])
2455
- ])) : b("", !0),
2456
- N(d.$slots, "before-table", {}, () => [
2457
- v.value.length ? (o(), c("div", qa, [
2458
- (o(!0), c(Q, null, ae(v.value, (r, B) => (o(), c("div", {
2459
- key: B,
2460
- class: "w-crud-kpi"
2461
- }, [
2462
- m("div", {
2463
- class: ee(["w-crud-kpi-icon", r.severity ? `w-crud-kpi-icon--${r.severity}` : ""])
2464
- }, [
2465
- m("i", {
2466
- class: ee([r.icon]),
2467
- style: ve(r.color ? `color: ${r.color}` : "")
2468
- }, null, 6)
2469
- ], 2),
2470
- m("div", Ka, [
2471
- m("div", Ha, A(r.label), 1),
2472
- m("div", Ga, A(r.value), 1)
2473
- ])
2474
- ]))), 128))
2475
- ])) : b("", !0)
2476
- ]),
2477
- m("div", {
2478
- class: ee(["w-crud-content", { "w-crud-content--rail": e.actionRail }])
2479
- }, [
2480
- m("div", Ya, [
2481
- le.value.length ? (o(), c("div", Ja, [
2482
- (o(!0), c(Q, null, ae(le.value, (r) => {
2483
- var B, G, ke, Ke, Qe, He, Ge, Te, _e;
2484
- return o(), c(Q, {
2485
- key: r.field
2486
- }, [
2487
- (((B = r.filter) == null ? void 0 : B.type) || "text") === "text" ? (o(), C(u(re), {
2488
- key: 0,
2489
- "model-value": e.crud.columnFilters[ne(r)] ?? "",
2490
- placeholder: ((G = r.filter) == null ? void 0 : G.placeholder) || r.header,
2491
- size: "small",
2492
- onInput: (Ie) => Re(r, Ie.target.value)
2493
- }, null, 8, ["model-value", "placeholder", "onInput"])) : ((ke = r.filter) == null ? void 0 : ke.type) === "select" ? (o(), C(u(ft), {
2494
- key: 1,
2495
- "model-value": e.crud.columnFilters[ne(r)],
2496
- options: (Ke = r.filter) == null ? void 0 : Ke.options,
2497
- "option-label": "label",
2498
- "option-value": "value",
2499
- placeholder: ((Qe = r.filter) == null ? void 0 : Qe.placeholder) || r.header,
2500
- "show-clear": "",
2501
- size: "small",
2502
- "onUpdate:modelValue": (Ie) => e.crud.setColumnFilter(ne(r), Ie)
2503
- }, null, 8, ["model-value", "options", "placeholder", "onUpdate:modelValue"])) : ((He = r.filter) == null ? void 0 : He.type) === "boolean" ? (o(), C(u(ft), {
2504
- key: 2,
2505
- "model-value": e.crud.columnFilters[ne(r)],
2506
- options: we,
2507
- "option-label": "label",
2508
- "option-value": "value",
2509
- placeholder: ((Ge = r.filter) == null ? void 0 : Ge.placeholder) || r.header,
2510
- "show-clear": "",
2511
- size: "small",
2512
- "onUpdate:modelValue": (Ie) => e.crud.setColumnFilter(ne(r), Ie)
2513
- }, null, 8, ["model-value", "placeholder", "onUpdate:modelValue"])) : ((Te = r.filter) == null ? void 0 : Te.type) === "numeric" ? (o(), C(u(ot), {
2514
- key: 3,
2515
- "model-value": e.crud.columnFilters[ne(r)] ?? null,
2516
- placeholder: ((_e = r.filter) == null ? void 0 : _e.placeholder) || r.header,
2517
- size: "small",
2518
- "onUpdate:modelValue": (Ie) => e.crud.setColumnFilter(ne(r), Ie)
2519
- }, null, 8, ["model-value", "placeholder", "onUpdate:modelValue"])) : b("", !0)
2520
- ], 64);
2521
- }), 128)),
2522
- Object.keys(e.crud.columnFilters).length ? (o(), C(u(O), {
2523
- key: 0,
2524
- label: "Limpar filtros",
2525
- icon: "pi pi-filter-slash",
2526
- text: "",
2527
- size: "small",
2528
- onClick: f[1] || (f[1] = (r) => e.crud.clearColumnFilters())
2529
- })) : b("", !0)
2530
- ])) : b("", !0),
2531
- x.value === "table" ? (o(), c("div", Xa, [
2532
- l.value && e.crud.selectedItems.value.length ? (o(), c("div", Za, [
2533
- m("span", Qa, A(e.crud.selectedItems.value.length) + " selecionado(s) ", 1),
2534
- N(d.$slots, "bulk-actions", {
2535
- selected: e.crud.selectedItems.value,
2536
- crud: e.crud
2537
- }, () => [
2538
- (o(!0), c(Q, null, ae(e.crud.config.bulkActions || [], (r) => (o(), C(u(O), {
2539
- key: r.action,
2540
- label: r.label,
2541
- icon: r.icon,
2542
- severity: r.severity,
2543
- size: "small",
2544
- disabled: r.disabled ? r.disabled(e.crud.selectedItems.value) : !1,
2545
- onClick: (B) => r.handler(e.crud.selectedItems.value)
2546
- }, null, 8, ["label", "icon", "severity", "disabled", "onClick"]))), 128))
2547
- ]),
2548
- se(F(u(O), {
2549
- icon: "pi pi-times",
2550
- text: "",
2551
- rounded: "",
2552
- size: "small",
2553
- onClick: f[2] || (f[2] = (r) => e.crud.clearSelection())
2554
- }, null, 512), [
2555
- [
2556
- z,
2557
- "Limpar seleção",
2558
- void 0,
2559
- { top: !0 }
2560
- ]
2561
- ])
2562
- ])) : b("", !0),
2563
- F(u(Dt), {
2564
- "expanded-rows": k.value,
2565
- "onUpdate:expandedRows": f[7] || (f[7] = (r) => k.value = r),
2566
- value: e.crud.items.value,
2567
- loading: e.crud.loading.value,
2568
- paginator: "",
2569
- rows: e.crud.pagination.pageSize,
2570
- "total-records": e.crud.pagination.rows,
2571
- "rows-per-page-options": [10, 20, 50],
2572
- "paginator-template": "CurrentPageReport PrevPageLink NextPageLink",
2573
- "current-page-report-template": "Página {currentPage} de {totalPages}",
2574
- pt: { pcPaginator: { root: { class: "w-crud-paginator" } } },
2575
- lazy: "",
2576
- "striped-rows": "",
2577
- "removable-sort": "",
2578
- size: "small",
2579
- "sort-field": e.crud.sort.field ?? void 0,
2580
- "sort-order": e.crud.sort.order,
2581
- "data-key": e.crud.config.pk || "id",
2582
- "edit-mode": w.value ? "cell" : void 0,
2583
- selection: l.value ? e.crud.selectedItems.value : e.actionRail || e.contextMenu ? h.value : void 0,
2584
- "selection-mode": l.value ? void 0 : e.actionRail || e.contextMenu ? "single" : void 0,
2585
- "context-menu": e.contextMenu,
2586
- "context-menu-selection": e.contextMenu ? h.value : void 0,
2587
- "onUpdate:selection": f[8] || (f[8] = (r) => l.value ? e.crud.selectedItems.value = r : h.value = r),
2588
- "onUpdate:contextMenuSelection": f[9] || (f[9] = (r) => h.value = r),
2589
- onRowContextmenu: Be,
2590
- onPage: e.crud.onPage,
2591
- onSort: f[10] || (f[10] = (r) => e.crud.onSort({ sortField: r.sortField, sortOrder: r.sortOrder })),
2592
- onRowExpand: f[11] || (f[11] = (r) => n("row-expand", r.data)),
2593
- onRowCollapse: f[12] || (f[12] = (r) => n("row-collapse", r.data)),
2594
- onCellEditComplete: J
2595
- }, Je({
2596
- header: q(() => [
2597
- m("div", _a, [
2598
- m("div", eo, [
2599
- e.showSearch ? (o(), C(u(je), { key: 0 }, {
2600
- default: q(() => [
2601
- F(u(qe), { class: "pi pi-search" }),
2602
- F(u(re), {
2603
- "model-value": e.crud.search.value,
2604
- placeholder: "Buscar...",
2605
- class: "w-72",
2606
- onInput: e.crud.onSearch
2607
- }, null, 8, ["model-value", "onInput"])
2608
- ]),
2609
- _: 1
2610
- })) : b("", !0),
2611
- N(d.$slots, "toolbar-start"),
2612
- N(d.$slots, "toolbar-filters")
2613
- ]),
2614
- m("div", to, [
2615
- N(d.$slots, "toolbar-actions"),
2616
- e.persistState ? (o(), c(Q, { key: 0 }, [
2617
- se(F(u(O), {
2618
- icon: "pi pi-sliders-h",
2619
- text: "",
2620
- size: "small",
2621
- onClick: f[3] || (f[3] = (r) => {
2622
- var B;
2623
- return (B = H.value) == null ? void 0 : B.toggle(r);
2624
- })
2625
- }, null, 512), [
2626
- [
2627
- z,
2628
- "Colunas",
2629
- void 0,
2630
- { top: !0 }
2631
- ]
2632
- ]),
2633
- F(u(Et), {
2634
- ref_key: "chooser",
2635
- ref: H
2636
- }, {
2637
- default: q(() => [
2638
- m("div", lo, [
2639
- (o(!0), c(Q, null, ae(oe.value, (r) => (o(), c("div", {
2640
- key: r.field,
2641
- style: { display: "flex", "align-items": "center", gap: "0.5rem" }
2642
- }, [
2643
- F(u(Qt), {
2644
- "model-value": !K.hidden.includes(r.field),
2645
- "input-id": `wcrud-col-${r.field}`,
2646
- binary: "",
2647
- "onUpdate:modelValue": (B) => ye(r.field, !!B)
2648
- }, null, 8, ["model-value", "input-id", "onUpdate:modelValue"]),
2649
- m("label", {
2650
- for: `wcrud-col-${r.field}`,
2651
- style: { "font-size": "0.85rem", cursor: "pointer" }
2652
- }, A(r.header), 9, ao)
2653
- ]))), 128))
2654
- ])
2655
- ]),
2656
- _: 1
2657
- }, 512)
2658
- ], 64)) : b("", !0),
2659
- e.exportCsv ? se((o(), C(u(O), {
2660
- key: 1,
2661
- icon: "pi pi-download",
2662
- text: "",
2663
- size: "small",
2664
- loading: Pe.value,
2665
- onClick: We
2666
- }, null, 8, ["loading"])), [
2667
- [
2668
- z,
2669
- e.csvScope === "all" ? "Exportar tudo (CSV)" : "Exportar página (CSV)",
2670
- void 0,
2671
- { top: !0 }
2672
- ]
2673
- ]) : b("", !0),
2674
- e.viewToggle ? (o(), c("div", oo, [
2675
- F(u(O), {
2676
- icon: "pi pi-table",
2677
- size: "small",
2678
- text: !M("table"),
2679
- outlined: M("table"),
2680
- onClick: f[4] || (f[4] = (r) => $("table"))
2681
- }, null, 8, ["text", "outlined"]),
2682
- F(u(O), {
2683
- icon: "pi pi-th-large",
2684
- size: "small",
2685
- text: !M("cards"),
2686
- outlined: M("cards"),
2687
- onClick: f[5] || (f[5] = (r) => $("cards"))
2688
- }, null, 8, ["text", "outlined"])
2689
- ])) : b("", !0),
2690
- !e.showHeader && y.value && !e.actionRail ? (o(), C(u(O), {
2691
- key: 3,
2692
- label: "Novo",
2693
- icon: "pi pi-plus",
2694
- onClick: f[6] || (f[6] = (r) => e.crud.openCreateDialog())
2695
- })) : b("", !0)
2696
- ])
2697
- ])
2698
- ]),
2699
- empty: q(() => [
2700
- N(d.$slots, "empty", {}, () => [
2701
- f[22] || (f[22] = m("div", { class: "w-crud-empty" }, [
2702
- m("div", { class: "w-crud-empty-icon" }, [
2703
- m("i", { class: "pi pi-inbox" })
2704
- ]),
2705
- m("p", { class: "w-crud-empty-title" }, "Nenhum registro encontrado"),
2706
- m("p", { class: "w-crud-empty-text" }, "Tente ajustar sua busca ou crie um novo registro")
2707
- ], -1))
2708
- ])
2709
- ]),
2710
- default: q(() => [
2711
- l.value ? (o(), C(u(Oe), {
2712
- key: 0,
2713
- "selection-mode": "multiple",
2714
- style: { width: "3rem" }
2715
- })) : b("", !0),
2716
- e.expandable ? (o(), C(u(Oe), {
2717
- key: 1,
2718
- expander: "",
2719
- style: { width: "3rem" }
2720
- })) : b("", !0),
2721
- (o(!0), c(Q, null, ae(xe.value, (r) => (o(), C(u(Oe), {
2722
- key: r.field,
2723
- field: r.field,
2724
- header: r.header,
2725
- sortable: r.sortable,
2726
- style: ve(r.style),
2727
- "header-class": Ce(r),
2728
- "body-class": Ce(r)
2729
- }, Je({
2730
- body: q(({ data: B }) => [
2731
- N(d.$slots, `column-${r.field}`, {
2732
- data: B,
2733
- value: B[r.field]
2734
- }, () => [
2735
- F(vt, {
2736
- column: r,
2737
- value: B[r.field],
2738
- "row-data": B
2739
- }, null, 8, ["column", "value", "row-data"])
2740
- ])
2741
- ]),
2742
- _: 2
2743
- }, [
2744
- w.value && te(r.field) ? {
2745
- name: "editor",
2746
- fn: q(({ data: B }) => {
2747
- var G;
2748
- return [
2749
- ["number", "currency"].includes(((G = te(r.field)) == null ? void 0 : G.type) || "") ? (o(), C(u(ot), {
2750
- key: 0,
2751
- "model-value": B[r.field] ?? null,
2752
- fluid: "",
2753
- "onUpdate:modelValue": (ke) => {
2754
- B[r.field] = ke;
2755
- }
2756
- }, null, 8, ["model-value", "onUpdate:modelValue"])) : (o(), C(u(re), {
2757
- key: 1,
2758
- "model-value": B[r.field] ?? "",
2759
- fluid: "",
2760
- "onUpdate:modelValue": (ke) => {
2761
- B[r.field] = ke;
2762
- }
2763
- }, null, 8, ["model-value", "onUpdate:modelValue"]))
2764
- ];
2765
- }),
2766
- key: "0"
2767
- } : void 0
2768
- ]), 1032, ["field", "header", "sortable", "style", "header-class", "body-class"]))), 128)),
2769
- Se.value && !e.actionRail ? (o(), C(u(Oe), {
2770
- key: 2,
2771
- "header-class": "w-crud-actions-header",
2772
- style: ve({
2773
- width: `${(ue.value.length + (u(s)["row-actions"] ? 1 : 0)) * 2.5 + 1}rem`
2774
- })
2775
- }, {
2776
- body: q(({ data: r }) => [
2777
- m("div", no, [
2778
- (o(!0), c(Q, null, ae(ue.value, (B) => (o(), c(Q, {
2779
- key: B.action
2780
- }, [
2781
- he(B, r) ? se((o(), C(u(O), {
2782
- key: 0,
2783
- icon: B.icon,
2784
- text: "",
2785
- rounded: "",
2786
- size: "small",
2787
- severity: B.severity,
2788
- disabled: De(B, r),
2789
- onClick: (G) => ce(B, r)
2790
- }, null, 8, ["icon", "severity", "disabled", "onClick"])), [
2791
- [
2792
- z,
2793
- B.tooltip,
2794
- void 0,
2795
- { top: !0 }
2796
- ]
2797
- ]) : b("", !0)
2798
- ], 64))), 128)),
2799
- N(d.$slots, "row-actions", {
2800
- data: r,
2801
- crud: e.crud
2802
- })
2803
- ])
2804
- ]),
2805
- _: 3
2806
- }, 8, ["style"])) : b("", !0)
2807
- ]),
2808
- _: 2
2809
- }, [
2810
- e.expandable ? {
2811
- name: "expansion",
2812
- fn: q((r) => [
2813
- N(d.$slots, "expansion", {
2814
- data: r.data
2815
- })
2816
- ]),
2817
- key: "0"
2818
- } : void 0
2819
- ]), 1032, ["expanded-rows", "value", "loading", "rows", "total-records", "sort-field", "sort-order", "data-key", "edit-mode", "selection", "selection-mode", "context-menu", "context-menu-selection", "onPage"])
2820
- ])) : (o(), c("div", io, [
2821
- m("div", so, [
2822
- m("div", ro, [
2823
- e.showSearch ? (o(), C(u(je), { key: 0 }, {
2824
- default: q(() => [
2825
- F(u(qe), { class: "pi pi-search" }),
2826
- F(u(re), {
2827
- "model-value": e.crud.search.value,
2828
- placeholder: "Buscar...",
2829
- class: "w-72",
2830
- onInput: e.crud.onSearch
2831
- }, null, 8, ["model-value", "onInput"])
2832
- ]),
2833
- _: 1
2834
- })) : b("", !0),
2835
- N(d.$slots, "toolbar-start"),
2836
- N(d.$slots, "toolbar-filters")
2837
- ]),
2838
- m("div", uo, [
2839
- N(d.$slots, "toolbar-actions"),
2840
- e.exportCsv ? se((o(), C(u(O), {
2841
- key: 0,
2842
- icon: "pi pi-download",
2843
- text: "",
2844
- size: "small",
2845
- loading: Pe.value,
2846
- onClick: We
2847
- }, null, 8, ["loading"])), [
2848
- [
2849
- z,
2850
- e.csvScope === "all" ? "Exportar tudo (CSV)" : "Exportar página (CSV)",
2851
- void 0,
2852
- { top: !0 }
2853
- ]
2854
- ]) : b("", !0),
2855
- e.viewToggle ? (o(), c("div", co, [
2856
- F(u(O), {
2857
- icon: "pi pi-table",
2858
- size: "small",
2859
- text: !M("table"),
2860
- outlined: M("table"),
2861
- onClick: f[13] || (f[13] = (r) => $("table"))
2862
- }, null, 8, ["text", "outlined"]),
2863
- F(u(O), {
2864
- icon: "pi pi-th-large",
2865
- size: "small",
2866
- text: !M("cards"),
2867
- outlined: M("cards"),
2868
- onClick: f[14] || (f[14] = (r) => $("cards"))
2869
- }, null, 8, ["text", "outlined"])
2870
- ])) : b("", !0),
2871
- !e.showHeader && y.value && !e.actionRail ? (o(), C(u(O), {
2872
- key: 2,
2873
- label: "Novo",
2874
- icon: "pi pi-plus",
2875
- onClick: f[15] || (f[15] = (r) => e.crud.openCreateDialog())
2876
- })) : b("", !0)
2877
- ])
2878
- ]),
2879
- e.crud.loading.value ? (o(), c("div", mo, [...f[23] || (f[23] = [
2880
- m("i", { class: "pi pi-spin pi-spinner" }, null, -1)
2881
- ])])) : e.crud.items.value.length ? (o(), c("div", {
2882
- key: 2,
2883
- class: ee(["w-crud-cards", { "w-crud-cards--bare": e.cardBare }])
2884
- }, [
2885
- (o(!0), c(Q, null, ae(e.crud.items.value, (r, B) => (o(), c("div", {
2886
- key: r[e.crud.config.pk || "id"] ?? B,
2887
- class: ee(
2888
- e.cardBare ? "w-crud-card-bare" : ["w-crud-card", { "w-crud-card--selected": h.value === r }]
2889
- ),
2890
- onClick: (G) => !e.cardBare && Ue(r),
2891
- onDblclick: (G) => !e.cardBare && e.crud.config.canEdit !== !1 && e.crud.openEditDialog(r),
2892
- onContextmenu: (G) => !e.cardBare && ze(G, r)
2893
- }, [
2894
- N(d.$slots, "card", {
2895
- data: r,
2896
- crud: e.crud,
2897
- columns: ge.value,
2898
- index: B
2899
- }, () => [
2900
- m("div", vo, [
2901
- (o(!0), c(Q, null, ae(ge.value, (G, ke) => (o(), c("div", {
2902
- key: G.field,
2903
- class: ee(["w-crud-card-row", { "w-crud-card-row--title": ke === 0 }])
2904
- }, [
2905
- ke !== 0 ? (o(), c("span", po, A(G.header), 1)) : b("", !0),
2906
- m("span", ho, [
2907
- N(d.$slots, `column-${G.field}`, {
2908
- data: r,
2909
- value: r[G.field]
2910
- }, () => [
2911
- F(vt, {
2912
- column: G,
2913
- value: r[G.field],
2914
- "row-data": r
2915
- }, null, 8, ["column", "value", "row-data"])
2916
- ])
2917
- ])
2918
- ], 2))), 128))
2919
- ]),
2920
- Se.value && !e.actionRail ? (o(), c("div", yo, [
2921
- (o(!0), c(Q, null, ae(ue.value, (G) => (o(), c(Q, {
2922
- key: G.action
2923
- }, [
2924
- he(G, r) ? se((o(), C(u(O), {
2925
- key: 0,
2926
- icon: G.icon,
2927
- text: "",
2928
- rounded: "",
2929
- size: "small",
2930
- severity: G.severity,
2931
- disabled: De(G, r),
2932
- onClick: (ke) => ce(G, r)
2933
- }, null, 8, ["icon", "severity", "disabled", "onClick"])), [
2934
- [
2935
- z,
2936
- G.tooltip,
2937
- void 0,
2938
- { top: !0 }
2939
- ]
2940
- ]) : b("", !0)
2941
- ], 64))), 128)),
2942
- N(d.$slots, "row-actions", {
2943
- data: r,
2944
- crud: e.crud
2945
- })
2946
- ])) : b("", !0)
2947
- ])
2948
- ], 42, fo))), 128))
2949
- ], 2)) : N(d.$slots, "empty", {}, () => [
2950
- f[24] || (f[24] = Zt('<div class="w-crud-empty"><div class="w-crud-empty-icon"><i class="pi pi-inbox"></i></div><p class="w-crud-empty-title">Nenhum registro encontrado</p><p class="w-crud-empty-text">Tente ajustar sua busca ou crie um novo registro</p></div>', 1))
2951
- ], void 0, 1),
2952
- e.crud.items.value.length ? (o(), C(u(_t), {
2953
- key: 3,
2954
- rows: e.crud.pagination.pageSize,
2955
- "total-records": e.crud.pagination.rows,
2956
- first: Z.value,
2957
- "rows-per-page-options": [10, 20, 50],
2958
- template: "CurrentPageReport PrevPageLink NextPageLink",
2959
- "current-page-report-template": "Página {currentPage} de {totalPages}",
2960
- class: "w-crud-paginator",
2961
- onPage: e.crud.onPage
2962
- }, null, 8, ["rows", "total-records", "first", "onPage"])) : b("", !0)
2963
- ]))
2964
- ]),
2965
- e.actionRail ? (o(), c("aside", go, [
2966
- y.value ? se((o(), C(u(O), {
2967
- key: 0,
2968
- icon: "pi pi-plus",
2969
- rounded: "",
2970
- onClick: f[16] || (f[16] = (r) => e.crud.openCreateDialog())
2971
- }, null, 512)), [
2972
- [
2973
- z,
2974
- "Novo",
2975
- void 0,
2976
- { left: !0 }
2977
- ]
2978
- ]) : b("", !0),
2979
- y.value && ue.value.length ? (o(), c("div", bo)) : b("", !0),
2980
- (o(!0), c(Q, null, ae(ue.value, (r) => (o(), c(Q, {
2981
- key: r.action
2982
- }, [
2983
- !h.value || he(r, h.value) ? se((o(), C(u(O), {
2984
- key: 0,
2985
- icon: r.icon,
2986
- text: "",
2987
- rounded: "",
2988
- severity: r.severity,
2989
- disabled: !h.value || De(r, h.value),
2990
- onClick: (B) => h.value && ce(r, h.value)
2991
- }, null, 8, ["icon", "severity", "disabled", "onClick"])), [
2992
- [
2993
- z,
2994
- r.tooltip,
2995
- void 0,
2996
- { left: !0 }
2997
- ]
2998
- ]) : b("", !0)
2999
- ], 64))), 128)),
3000
- N(d.$slots, "rail-actions", {
3001
- selected: h.value,
3002
- crud: e.crud
3003
- }),
3004
- e.showPrint || e.exportCsv ? (o(), c("div", wo)) : b("", !0),
3005
- e.showPrint ? se((o(), C(u(O), {
3006
- key: 3,
3007
- icon: "pi pi-print",
3008
- text: "",
3009
- rounded: "",
3010
- disabled: !h.value,
3011
- onClick: Ze
3012
- }, null, 8, ["disabled"])), [
3013
- [
3014
- z,
3015
- "Imprimir",
3016
- void 0,
3017
- { left: !0 }
3018
- ]
3019
- ]) : b("", !0),
3020
- e.exportCsv ? se((o(), C(u(O), {
3021
- key: 4,
3022
- icon: "pi pi-download",
3023
- text: "",
3024
- rounded: "",
3025
- loading: Pe.value,
3026
- onClick: We
3027
- }, null, 8, ["loading"])), [
3028
- [
3029
- z,
3030
- e.csvScope === "all" ? "Exportar tudo (CSV)" : "Exportar página (CSV)",
3031
- void 0,
3032
- { left: !0 }
3033
- ]
3034
- ]) : b("", !0)
3035
- ])) : b("", !0)
3036
- ], 2),
3037
- e.contextMenu ? (o(), C(u(el), {
3038
- key: 1,
3039
- ref_key: "cm",
3040
- ref: Fe,
3041
- model: it.value
3042
- }, null, 8, ["model"])) : b("", !0),
3043
- N(d.$slots, "form-dialog", {
3044
- crud: e.crud,
3045
- dialogWidth: e.dialogWidth
3046
- }, () => {
3047
- var r;
3048
- return [
3049
- F(At, {
3050
- visible: e.crud.dialogVisible.value,
3051
- title: e.crud.dialogTitle.value,
3052
- fields: e.crud.config.form,
3053
- "form-data": e.crud.formData,
3054
- "is-editing": e.crud.isEditing.value,
3055
- saving: e.crud.saving.value,
3056
- disabled: ((r = e.crud.viewMode) == null ? void 0 : r.value) ?? !1,
3057
- width: e.dialogWidth,
3058
- "form-columns": e.formColumns ?? e.crud.config.formColumns,
3059
- "keyboard-nav": e.crud.config.keyboardNav,
3060
- "onUpdate:visible": f[17] || (f[17] = (B) => {
3061
- e.crud.dialogVisible.value = B, B || (e.crud.editingItem.value = null);
3062
- }),
3063
- "onUpdate:field": f[18] || (f[18] = (B, G) => e.crud.setFormField(B, G)),
3064
- onSave: f[19] || (f[19] = (B) => e.crud.save())
3065
- }, Je({ _: 2 }, [
3066
- ae(e.crud.config.form, (B) => ({
3067
- name: `field-${B.field}`,
3068
- fn: q((G) => [
3069
- N(d.$slots, `field-${B.field}`, ct(mt(G)))
3070
- ])
3071
- }))
3072
- ]), 1032, ["visible", "title", "fields", "form-data", "is-editing", "saving", "disabled", "width", "form-columns", "keyboard-nav"])
3073
- ];
3074
- }),
3075
- d.$slots["delete-message"] ? (o(), C(u(nt), {
3076
- key: 2,
3077
- visible: me.value,
3078
- "onUpdate:visible": f[21] || (f[21] = (r) => me.value = r),
3079
- header: "Confirmar Exclusão",
3080
- modal: "",
3081
- draggable: !1,
3082
- class: "w-crud-delete-dialog",
3083
- style: { width: "30rem" }
3084
- }, {
3085
- footer: q(() => [
3086
- F(u(O), {
3087
- type: "button",
3088
- label: "Cancelar",
3089
- severity: "secondary",
3090
- text: "",
3091
- disabled: pe.value,
3092
- onClick: f[20] || (f[20] = (r) => me.value = !1)
3093
- }, null, 8, ["disabled"]),
3094
- F(u(O), {
3095
- type: "button",
3096
- label: "Excluir",
3097
- icon: "pi pi-trash",
3098
- severity: "danger",
3099
- loading: pe.value,
3100
- onClick: be
3101
- }, null, 8, ["loading"])
3102
- ]),
3103
- default: q(() => [
3104
- N(d.$slots, "delete-message", { item: de.value })
3105
- ]),
3106
- _: 3
3107
- }, 8, ["visible"])) : b("", !0)
3108
- ]);
3109
- };
3110
- }
3111
- }), Zn = /* @__PURE__ */ ie({
3112
- __name: "WDateRange",
3113
- props: {
3114
- modelValue: { default: null },
3115
- placeholder: { default: "Selecione o período" },
3116
- minDate: {},
3117
- maxDate: {},
3118
- showButtonBar: { type: Boolean, default: !0 },
3119
- disabled: { type: Boolean, default: !1 }
3120
- },
3121
- emits: ["update:modelValue"],
3122
- setup(e, { emit: a }) {
3123
- const t = a;
3124
- function n(s) {
3125
- t("update:modelValue", s ?? null);
3126
- }
3127
- return (s, p) => (o(), C(u(It), {
3128
- "model-value": e.modelValue ?? void 0,
3129
- "selection-mode": "range",
3130
- placeholder: e.placeholder,
3131
- "min-date": e.minDate,
3132
- "max-date": e.maxDate,
3133
- "show-button-bar": e.showButtonBar,
3134
- disabled: e.disabled,
3135
- "date-format": "dd/mm/yy",
3136
- fluid: "",
3137
- "onUpdate:modelValue": n
3138
- }, null, 8, ["model-value", "placeholder", "min-date", "max-date", "show-button-bar", "disabled"]));
3139
- }
3140
- }), ko = /* @__PURE__ */ ie({
3141
- __name: "WStatusTag",
3142
- props: {
3143
- value: {},
3144
- map: {}
3145
- },
3146
- setup(e) {
3147
- const a = e, t = {
3148
- ativo: { label: "Ativo", severity: "success" },
3149
- ativa: { label: "Ativa", severity: "success" },
3150
- inativo: { label: "Inativo", severity: "danger" },
3151
- inativa: { label: "Inativa", severity: "danger" },
3152
- suspensa: { label: "Suspensa", severity: "warn" },
3153
- suspenso: { label: "Suspenso", severity: "warn" },
3154
- cancelada: { label: "Cancelada", severity: "danger" },
3155
- cancelado: { label: "Cancelado", severity: "danger" },
3156
- pendente: { label: "Pendente", severity: "warn" },
3157
- confirmada: { label: "Confirmada", severity: "success" },
3158
- confirmado: { label: "Confirmado", severity: "success" },
3159
- vencida: { label: "Vencida", severity: "danger" },
3160
- vencido: { label: "Vencido", severity: "danger" },
3161
- concluido: { label: "Concluído", severity: "success" },
3162
- concluida: { label: "Concluída", severity: "success" },
3163
- em_progresso: { label: "Em Progresso", severity: "info" },
3164
- em_andamento: { label: "Em Andamento", severity: "info" },
3165
- expirado: { label: "Expirado", severity: "secondary" },
3166
- expirada: { label: "Expirada", severity: "secondary" },
3167
- aberto: { label: "Aberto", severity: "info" },
3168
- aberta: { label: "Aberta", severity: "info" },
3169
- fechado: { label: "Fechado", severity: "secondary" },
3170
- fechada: { label: "Fechada", severity: "secondary" },
3171
- pago: { label: "Pago", severity: "success" },
3172
- paga: { label: "Paga", severity: "success" },
3173
- inadimplente: { label: "Inadimplente", severity: "danger" }
3174
- }, n = P(() => (a.map ?? t)[a.value] ?? { label: a.value, severity: "secondary" });
3175
- return (s, p) => (o(), C(u(Ft), {
3176
- value: n.value.label,
3177
- severity: n.value.severity
3178
- }, null, 8, ["value", "severity"]));
3179
- }
3180
- }), $o = { class: "w-page-header" }, xo = { class: "w-page-header-content" }, Co = { class: "w-page-header-title" }, Vo = {
3181
- key: 0,
3182
- class: "w-page-header-subtitle"
3183
- }, So = { class: "w-page-header-actions" }, Qn = /* @__PURE__ */ ie({
3184
- __name: "WPageHeader",
3185
- props: {
3186
- title: {},
3187
- subtitle: {},
3188
- actionLabel: {},
3189
- actionIcon: {}
3190
- },
3191
- emits: ["action"],
3192
- setup(e, { emit: a }) {
3193
- const t = a;
3194
- return (n, s) => (o(), c("div", $o, [
3195
- m("div", xo, [
3196
- m("h2", Co, A(e.title), 1),
3197
- e.subtitle ? (o(), c("p", Vo, A(e.subtitle), 1)) : b("", !0)
3198
- ]),
3199
- m("div", So, [
3200
- N(n.$slots, "actions"),
3201
- e.actionLabel ? (o(), C(u(O), {
3202
- key: 0,
3203
- label: e.actionLabel,
3204
- icon: e.actionIcon,
3205
- onClick: s[0] || (s[0] = (p) => t("action"))
3206
- }, null, 8, ["label", "icon"])) : b("", !0)
3207
- ])
3208
- ]));
3209
- }
3210
- }), Do = { class: "w-empty-state" }, Eo = { class: "w-empty-state-icon" }, Fo = { class: "w-empty-state-title" }, Po = {
3211
- key: 0,
3212
- class: "w-empty-state-description"
3213
- }, _n = /* @__PURE__ */ ie({
3214
- __name: "WEmptyState",
3215
- props: {
3216
- icon: {},
3217
- title: {},
3218
- description: {},
3219
- actionLabel: {},
3220
- actionIcon: {}
3221
- },
3222
- emits: ["action"],
3223
- setup(e, { emit: a }) {
3224
- const t = a;
3225
- return (n, s) => (o(), c("div", Do, [
3226
- m("div", Eo, [
3227
- m("i", {
3228
- class: ee(e.icon)
3229
- }, null, 2)
3230
- ]),
3231
- m("p", Fo, A(e.title), 1),
3232
- e.description ? (o(), c("p", Po, A(e.description), 1)) : b("", !0),
3233
- e.actionLabel ? (o(), C(u(O), {
3234
- key: 1,
3235
- label: e.actionLabel,
3236
- icon: e.actionIcon,
3237
- size: "small",
3238
- class: "mt-3",
3239
- onClick: s[0] || (s[0] = (p) => t("action"))
3240
- }, null, 8, ["label", "icon"])) : b("", !0)
3241
- ]));
3242
- }
3243
- });
3244
- /*!
3245
- * vue-router v4.6.4
3246
- * (c) 2025 Eduardo San Martin Morote
3247
- * @license MIT
3248
- */
3249
- Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
3250
- Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : "");
3251
- Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
3252
- const Io = Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
3253
- Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
3254
- Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
3255
- /*!
3256
- * vue-router v4.6.4
3257
- * (c) 2025 Eduardo San Martin Morote
3258
- * @license MIT
3259
- */
3260
- function Ro() {
3261
- return Vt(Io);
3262
- }
3263
- const Mo = { class: "w-detail-header" }, Ao = { class: "w-detail-header-left" }, Uo = { class: "w-detail-header-content" }, Bo = { class: "w-detail-header-title" }, To = {
3264
- key: 0,
3265
- class: "w-detail-header-subtitle"
3266
- }, No = { class: "w-detail-header-actions" }, ei = /* @__PURE__ */ ie({
3267
- __name: "WDetailHeader",
3268
- props: {
3269
- title: {},
3270
- subtitle: {},
3271
- icon: {},
3272
- backRoute: {},
3273
- backTo: {},
3274
- status: {},
3275
- statusMap: {}
3276
- },
3277
- setup(e) {
3278
- const a = e, t = Ro();
3279
- function n() {
3280
- a.backTo ? t.push(typeof a.backTo == "string" ? { name: a.backTo } : a.backTo) : a.backRoute ? t.push({ name: a.backRoute }) : t.back();
3281
- }
3282
- return (s, p) => (o(), c("div", Mo, [
3283
- m("div", Ao, [
3284
- F(u(O), {
3285
- icon: "pi pi-arrow-left",
3286
- text: "",
3287
- rounded: "",
3288
- onClick: n
3289
- }),
3290
- e.icon ? (o(), c("i", {
3291
- key: 0,
3292
- class: ee([e.icon, "w-detail-header-icon"])
3293
- }, null, 2)) : b("", !0),
3294
- m("div", Uo, [
3295
- m("h2", Bo, A(e.title), 1),
3296
- e.subtitle ? (o(), c("p", To, A(e.subtitle), 1)) : b("", !0)
3297
- ]),
3298
- e.status ? (o(), C(ko, {
3299
- key: 1,
3300
- value: e.status,
3301
- map: e.statusMap
3302
- }, null, 8, ["value", "map"])) : b("", !0)
3303
- ]),
3304
- m("div", No, [
3305
- N(s.$slots, "actions")
3306
- ])
3307
- ]));
3308
- }
3309
- }), Lo = { class: "w-info-card" }, Oo = {
3310
- key: 0,
3311
- class: "w-info-card-title"
3312
- }, zo = { class: "w-info-card-grid" }, Wo = { class: "w-info-card-label" }, jo = { class: "w-info-card-value" }, ti = /* @__PURE__ */ ie({
3313
- __name: "WInfoCard",
3314
- props: {
3315
- title: {},
3316
- fields: {}
3317
- },
3318
- setup(e) {
3319
- const { formatCurrency: a, formatDate: t, formatNumber: n } = ht();
3320
- function s(p) {
3321
- const k = p.value;
3322
- return k == null || k === "" ? "-" : p.format === "currency" ? a(Number(k)) : p.format === "date" ? t(String(k)) : p.format === "datetime" ? t(String(k), "DD/MM/YYYY HH:mm") : p.format === "number" ? n(Number(k)) : String(k);
3323
- }
3324
- return (p, k) => (o(), c("div", Lo, [
3325
- e.title ? (o(), c("h3", Oo, A(e.title), 1)) : b("", !0),
3326
- m("div", zo, [
3327
- (o(!0), c(Q, null, ae(e.fields, (I) => (o(), c("div", {
3328
- key: I.label,
3329
- class: "w-info-card-field"
3330
- }, [
3331
- m("span", Wo, A(I.label), 1),
3332
- m("span", jo, A(s(I)), 1)
3333
- ]))), 128))
3334
- ])
3335
- ]));
3336
- }
3337
- }), qo = {
3338
- key: 0,
3339
- class: "w-kpi-card__loading"
3340
- }, Ko = { class: "w-kpi-card__loading-content" }, Ho = { class: "w-kpi-card__header" }, Go = {
3341
- key: 0,
3342
- class: "w-kpi-card__icon"
3343
- }, Yo = {
3344
- key: 1,
3345
- class: "w-kpi-card__trend"
3346
- }, Jo = { class: "w-kpi-card__content" }, Xo = { class: "w-kpi-card__label" }, Zo = { class: "w-kpi-card__value" }, Qo = {
3347
- key: 0,
3348
- class: "w-kpi-card__hint"
3349
- }, _o = {
3350
- key: 0,
3351
- class: "w-kpi-card__footer"
3352
- }, en = /* @__PURE__ */ ie({
3353
- __name: "WKpiCard",
3354
- props: {
3355
- label: {},
3356
- value: {},
3357
- icon: {},
3358
- hint: {},
3359
- severity: {},
3360
- trend: {},
3361
- loading: { type: Boolean }
3362
- },
3363
- setup(e) {
3364
- return (a, t) => (o(), c("article", {
3365
- class: ee(["w-kpi-card", e.severity ? `w-kpi-card--${e.severity}` : ""])
3366
- }, [
3367
- e.loading ? (o(), c("div", qo, [
3368
- F(u(et), {
3369
- shape: "circle",
3370
- size: "2.75rem"
3371
- }),
3372
- m("div", Ko, [
3373
- F(u(et), {
3374
- width: "6rem",
3375
- height: "0.75rem"
3376
- }),
3377
- F(u(et), {
3378
- width: "7.5rem",
3379
- height: "1.5rem"
3380
- }),
3381
- F(u(et), {
3382
- width: "5rem",
3383
- height: "0.75rem"
3384
- })
3385
- ])
3386
- ])) : (o(), c(Q, { key: 1 }, [
3387
- m("div", Ho, [
3388
- e.icon || a.$slots.icon ? (o(), c("div", Go, [
3389
- N(a.$slots, "icon", {}, () => [
3390
- e.icon ? (o(), c("i", {
3391
- key: 0,
3392
- class: ee(e.icon)
3393
- }, null, 2)) : b("", !0)
3394
- ])
3395
- ])) : b("", !0),
3396
- e.trend || a.$slots.trend ? (o(), c("div", Yo, [
3397
- N(a.$slots, "trend", {}, () => [
3398
- e.trend ? (o(), c("span", {
3399
- key: 0,
3400
- class: ee(["w-kpi-card__trend-badge", e.trend.direction ? `w-kpi-card__trend-badge--${e.trend.direction}` : ""])
3401
- }, A(e.trend.value), 3)) : b("", !0)
3402
- ])
3403
- ])) : b("", !0)
3404
- ]),
3405
- m("div", Jo, [
3406
- m("p", Xo, A(e.label), 1),
3407
- m("div", Zo, [
3408
- N(a.$slots, "value", {}, () => [
3409
- Ae(A(e.value), 1)
3410
- ])
3411
- ]),
3412
- e.hint || a.$slots.hint ? (o(), c("p", Qo, [
3413
- N(a.$slots, "hint", {}, () => [
3414
- Ae(A(e.hint), 1)
3415
- ])
3416
- ])) : b("", !0)
3417
- ]),
3418
- a.$slots.footer ? (o(), c("footer", _o, [
3419
- N(a.$slots, "footer")
3420
- ])) : b("", !0)
3421
- ], 64))
3422
- ], 2));
3423
- }
3424
- }), li = /* @__PURE__ */ ie({
3425
- __name: "WKpiGrid",
3426
- props: {
3427
- items: { default: () => [] },
3428
- columns: { default: 4 },
3429
- dense: { type: Boolean, default: !1 }
3430
- },
3431
- setup(e) {
3432
- const a = e, t = P(() => [
3433
- a.columns === "auto" ? "w-kpi-grid--auto" : `w-kpi-grid--cols-${a.columns}`,
3434
- { "w-kpi-grid--dense": a.dense }
3435
- ]);
3436
- return (n, s) => (o(), c("div", {
3437
- class: ee(["w-kpi-grid", t.value])
3438
- }, [
3439
- n.$slots.item ? (o(!0), c(Q, { key: 0 }, ae(e.items, (p, k) => N(n.$slots, "item", {
3440
- key: k,
3441
- item: p,
3442
- index: k
3443
- })), 128)) : (o(!0), c(Q, { key: 1 }, ae(e.items, (p, k) => (o(), C(en, {
3444
- key: k,
3445
- label: p.label,
3446
- value: p.value,
3447
- icon: p.icon,
3448
- severity: p.severity || "primary",
3449
- hint: p.hint,
3450
- trend: p.trend,
3451
- loading: p.loading
3452
- }, null, 8, ["label", "value", "icon", "severity", "hint", "trend", "loading"]))), 128))
3453
- ], 2));
3454
- }
3455
- }), tn = { class: "w-section-header__main" }, ln = {
3456
- key: 0,
3457
- class: "w-section-header__icon"
3458
- }, an = { class: "w-section-header__content" }, on = { class: "w-section-header__title-row" }, nn = { class: "w-section-header__title" }, sn = {
3459
- key: 0,
3460
- class: "w-section-header__subtitle"
3461
- }, rn = {
3462
- key: 0,
3463
- class: "w-section-header__actions"
3464
- }, ai = /* @__PURE__ */ ie({
3465
- __name: "WSectionHeader",
3466
- props: {
3467
- title: {},
3468
- subtitle: {},
3469
- icon: {},
3470
- compact: { type: Boolean }
3471
- },
3472
- setup(e) {
3473
- return (a, t) => (o(), c("div", {
3474
- class: ee(["w-section-header", { "w-section-header--compact": e.compact }])
3475
- }, [
3476
- m("div", tn, [
3477
- e.icon || a.$slots.icon ? (o(), c("div", ln, [
3478
- N(a.$slots, "icon", {}, () => [
3479
- e.icon ? (o(), c("i", {
3480
- key: 0,
3481
- class: ee(e.icon)
3482
- }, null, 2)) : b("", !0)
3483
- ])
3484
- ])) : b("", !0),
3485
- m("div", an, [
3486
- m("div", on, [
3487
- m("h3", nn, A(e.title), 1),
3488
- N(a.$slots, "meta")
3489
- ]),
3490
- e.subtitle ? (o(), c("p", sn, A(e.subtitle), 1)) : b("", !0)
3491
- ])
3492
- ]),
3493
- a.$slots.actions ? (o(), c("div", rn, [
3494
- N(a.$slots, "actions")
3495
- ])) : b("", !0)
3496
- ], 2));
3497
- }
3498
- }), un = {
3499
- key: 0,
3500
- class: "w-form-section__header"
3501
- }, dn = { class: "w-form-section__content" }, cn = { class: "w-form-section__title" }, mn = {
3502
- key: 0,
3503
- class: "w-form-section__description"
3504
- }, fn = {
3505
- key: 0,
3506
- class: "w-form-section__actions"
3507
- }, vn = { class: "w-form-section__body" }, oi = /* @__PURE__ */ ie({
3508
- __name: "WFormSection",
3509
- props: {
3510
- title: {},
3511
- description: {},
3512
- variant: {}
3513
- },
3514
- setup(e) {
3515
- return (a, t) => (o(), c("section", {
3516
- class: ee(["w-form-section", e.variant ? `w-form-section--${e.variant}` : ""])
3517
- }, [
3518
- e.title || e.description || a.$slots.actions ? (o(), c("div", un, [
3519
- m("div", dn, [
3520
- m("h3", cn, A(e.title), 1),
3521
- e.description ? (o(), c("p", mn, A(e.description), 1)) : b("", !0)
3522
- ]),
3523
- a.$slots.actions ? (o(), c("div", fn, [
3524
- N(a.$slots, "actions")
3525
- ])) : b("", !0)
3526
- ])) : b("", !0),
3527
- m("div", vn, [
3528
- N(a.$slots, "default")
3529
- ])
3530
- ], 2));
3531
- }
3532
- }), pn = {
3533
- key: 0,
3534
- class: "w-action-bar__primary"
3535
- }, hn = {
3536
- key: 1,
3537
- class: "w-action-bar__filters"
3538
- }, yn = {
3539
- key: 2,
3540
- class: "w-action-bar__secondary"
3541
- }, ni = /* @__PURE__ */ ie({
3542
- __name: "WActionBar",
3543
- props: {
3544
- align: { default: "between" },
3545
- stackOnMobile: { type: Boolean, default: !0 }
3546
- },
3547
- setup(e) {
3548
- return (a, t) => (o(), c("div", {
3549
- class: ee(["w-action-bar", [`w-action-bar--${e.align}`, { "w-action-bar--stack": e.stackOnMobile }]])
3550
- }, [
3551
- a.$slots.primary || a.$slots.default ? (o(), c("div", pn, [
3552
- N(a.$slots, "primary", {}, () => [
3553
- N(a.$slots, "default")
3554
- ])
3555
- ])) : b("", !0),
3556
- a.$slots.filters ? (o(), c("div", hn, [
3557
- N(a.$slots, "filters")
3558
- ])) : b("", !0),
3559
- a.$slots.secondary ? (o(), c("div", yn, [
3560
- N(a.$slots, "secondary")
3561
- ])) : b("", !0)
3562
- ], 2));
3563
- }
3564
- }), gn = { class: "w-progress-flow__marker" }, bn = { class: "w-progress-flow__content" }, wn = { class: "w-progress-flow__label" }, kn = {
3565
- key: 0,
3566
- class: "w-progress-flow__description"
3567
- }, ii = /* @__PURE__ */ ie({
3568
- __name: "WProgressFlow",
3569
- props: {
3570
- steps: {},
3571
- currentStep: {},
3572
- orientation: { default: "horizontal" }
3573
- },
3574
- setup(e) {
3575
- const a = e, t = P(() => a.steps.findIndex((s) => s.key === a.currentStep));
3576
- function n(s) {
3577
- return s < t.value ? "done" : s === t.value ? "current" : "pending";
3578
- }
3579
- return (s, p) => (o(), c("div", {
3580
- class: ee(["w-progress-flow", `w-progress-flow--${e.orientation}`])
3581
- }, [
3582
- (o(!0), c(Q, null, ae(e.steps, (k, I) => (o(), c("div", {
3583
- key: k.key,
3584
- class: ee(["w-progress-flow__step", `w-progress-flow__step--${n(I)}`])
3585
- }, [
3586
- N(s.$slots, "step", {
3587
- step: k,
3588
- index: I,
3589
- state: n(I)
3590
- }, () => [
3591
- m("div", gn, [
3592
- m("span", null, A(I + 1), 1)
3593
- ]),
3594
- m("div", bn, [
3595
- m("p", wn, A(k.label), 1),
3596
- k.description ? (o(), c("p", kn, A(k.description), 1)) : b("", !0)
3597
- ])
3598
- ])
3599
- ], 2))), 128))
3600
- ], 2));
3601
- }
3602
- });
3603
- export {
3604
- ea as W,
3605
- ni as _,
3606
- Ol as a,
3607
- vt as b,
3608
- At as c,
3609
- Xn as d,
3610
- xt as e,
3611
- Zn as f,
3612
- ei as g,
3613
- _n as h,
3614
- Ma as i,
3615
- oi as j,
3616
- ti as k,
3617
- en as l,
3618
- li as m,
3619
- ql as n,
3620
- Qn as o,
3621
- ii as p,
3622
- ai as q,
3623
- ko as r,
3624
- va as s,
3625
- Ta as t,
3626
- Rl as u,
3627
- Fl as v,
3628
- Ml as w,
3629
- Pl as x,
3630
- Ba as y
3631
- };
3632
- //# sourceMappingURL=WProgressFlow.vue_vue_type_script_setup_true_lang-DVjJq8Bs.js.map