@wgalleti/primevue-components 0.6.1 → 0.7.1

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