@wgalleti/primevue-components 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/WDateRange.vue.d.ts +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/ui/WAttentionList.vue.d.ts +34 -0
- package/dist/components/ui/WEmptyState.vue.d.ts +21 -3
- package/dist/components/ui/WKpiCard.vue.d.ts +2 -0
- package/dist/components/ui/WTabPane.d.ts +4 -0
- package/dist/{components-BRNk60nY.cjs → components-B9N5YvzN.cjs} +7 -7
- package/dist/components-B9N5YvzN.cjs.map +1 -0
- package/dist/{components-DsMEndfN.js → components-C5a424TI.js} +1362 -1269
- package/dist/components-C5a424TI.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +2 -2
- package/dist/composables/index.d.ts +3 -0
- package/dist/composables/useAppConfirm.d.ts +1 -0
- package/dist/composables/usePendingForms.d.ts +15 -0
- package/dist/composables/usePublishedVersion.d.ts +69 -0
- package/dist/composables-BZTlY1QU.cjs +2 -0
- package/dist/composables-BZTlY1QU.cjs.map +1 -0
- package/dist/composables-Bu1oxAgP.js +763 -0
- package/dist/composables-Bu1oxAgP.js.map +1 -0
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.js +42 -41
- package/dist/index.js.map +1 -1
- package/dist/primevue-components.css +1 -1
- package/dist/routeTabs-BnVpnSeJ.cjs.map +1 -1
- package/dist/routeTabs-D6m8PuP6.js.map +1 -1
- package/dist/types/attentionList.d.ts +22 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/kpi.d.ts +9 -0
- package/dist/types/manager.d.ts +2 -0
- package/dist/types/plugin.d.ts +6 -0
- package/dist/{useFormKeyboardNav-TqhfyJIg.js → useFormKeyboardNav-DNaAWyrr.js} +29 -5
- package/dist/useFormKeyboardNav-DNaAWyrr.js.map +1 -0
- package/dist/{useFormKeyboardNav-BTGDH0gB.cjs → useFormKeyboardNav-DkUCe_b7.cjs} +3 -3
- package/dist/useFormKeyboardNav-DkUCe_b7.cjs.map +1 -0
- package/dist/vite/buildIdentity.d.ts +39 -0
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite.cjs +2 -0
- package/dist/vite.cjs.map +1 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +26 -0
- package/dist/vite.js.map +1 -0
- package/package.json +8 -3
- package/dist/components-BRNk60nY.cjs.map +0 -1
- package/dist/components-DsMEndfN.js.map +0 -1
- package/dist/composables-B9ywPF1T.js +0 -650
- package/dist/composables-B9ywPF1T.js.map +0 -1
- package/dist/composables-BpUFAr7n.cjs +0 -2
- package/dist/composables-BpUFAr7n.cjs.map +0 -1
- package/dist/useFormKeyboardNav-BTGDH0gB.cjs.map +0 -1
- package/dist/useFormKeyboardNav-TqhfyJIg.js.map +0 -1
|
@@ -0,0 +1,763 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, h as r, m as i, o as a, p as o, r as s, s as c, u as l } from "./useFormKeyboardNav-DNaAWyrr.js";
|
|
2
|
+
import { a as u, i as d, n as f } from "./routeTabs-D6m8PuP6.js";
|
|
3
|
+
import { t as p } from "./labels-CXBhCk2N.js";
|
|
4
|
+
import { computed as m, getCurrentScope as h, inject as g, onScopeDispose as _, reactive as v, ref as y, shallowReactive as b, toValue as x, watch as S } from "vue";
|
|
5
|
+
//#region src/composables/usePendingForms.ts
|
|
6
|
+
var C = /* @__PURE__ */ new Set(), w = !1, T = 0;
|
|
7
|
+
function E(e) {
|
|
8
|
+
C.size !== 0 && (e.preventDefault(), e.returnValue = "");
|
|
9
|
+
}
|
|
10
|
+
function D() {
|
|
11
|
+
w || typeof window > "u" || (window.addEventListener("beforeunload", E), w = !0);
|
|
12
|
+
}
|
|
13
|
+
function O() {
|
|
14
|
+
return [...C];
|
|
15
|
+
}
|
|
16
|
+
function k(e, t) {
|
|
17
|
+
t ? (C.add(e), D()) : C.delete(e);
|
|
18
|
+
}
|
|
19
|
+
function A(e, t) {
|
|
20
|
+
let n = t ?? `w-form-${++T}`;
|
|
21
|
+
S(() => !!x(e), (e) => k(n, e), { immediate: !0 }), h() && _(() => k(n, !1));
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/composables/useCrudManager.ts
|
|
25
|
+
function j(e, t) {
|
|
26
|
+
let n = {};
|
|
27
|
+
for (let r of Object.keys(t)) JSON.stringify(e[r]) !== JSON.stringify(t[r]) && (n[r] = t[r]);
|
|
28
|
+
return n;
|
|
29
|
+
}
|
|
30
|
+
function M(h) {
|
|
31
|
+
let { endpoint: _, form: b, pk: x = "id", searchDebounce: C = 300, partialUpdate: w = !0, refetchOnSave: T = !0, fetchDetailOnEdit: E = !1, filterParams: D = void 0, createDefaults: O = void 0, transformItems: k = void 0, transformPayload: M = void 0, onAfterSave: N = void 0, onAfterDelete: P = void 0 } = h, F = g(u);
|
|
32
|
+
if (!F) throw Error("[wPrimeVueComponents] dataProvider não encontrado. Registre o WPrimeVuePlugin antes de usar useCrudManager.");
|
|
33
|
+
let I = F, L = g(d), R = h.pageSize ?? L?.defaultPageSize ?? 20, z = {
|
|
34
|
+
...p,
|
|
35
|
+
...h.labels
|
|
36
|
+
}, B = a(), { confirmDelete: ee, confirmDiscard: te } = e(), ne = {
|
|
37
|
+
...h,
|
|
38
|
+
keyboardNav: h.keyboardNav ?? L?.keyboardNav ?? !1
|
|
39
|
+
}, V = y([]), H = y([]), re = y({}), ie = y(!1), ae = 0, oe = y(!1), U = y(""), W = y(!1), G = y(!1), K = y(null), q = v({}), J = null, Y = v({
|
|
40
|
+
page: 1,
|
|
41
|
+
pageSize: R,
|
|
42
|
+
rows: 0,
|
|
43
|
+
totalPages: 0
|
|
44
|
+
}), X = v({
|
|
45
|
+
field: null,
|
|
46
|
+
order: 0
|
|
47
|
+
}), Z = v({});
|
|
48
|
+
function se() {
|
|
49
|
+
return t(b);
|
|
50
|
+
}
|
|
51
|
+
let ce = se();
|
|
52
|
+
for (let e of Object.keys(ce)) q[e] = ce[e];
|
|
53
|
+
let Q = m(() => K.value !== null && !G.value), le = m(() => G.value), ue = m(() => G.value ? z.viewTitle ?? "Visualizar Registro" : Q.value ? z.editTitle : z.createTitle), de = m(() => Y.page <= 1), fe = m(() => Y.page >= Y.totalPages), pe = null;
|
|
54
|
+
async function $(e = {}) {
|
|
55
|
+
let t = ++ae;
|
|
56
|
+
ie.value = !0;
|
|
57
|
+
try {
|
|
58
|
+
let n = {
|
|
59
|
+
page: Y.page,
|
|
60
|
+
page_size: Y.pageSize,
|
|
61
|
+
...e
|
|
62
|
+
};
|
|
63
|
+
U.value && (n.search = U.value), X.field && X.order !== 0 && (n.ordering = X.order === -1 ? `-${X.field}` : X.field), D && Object.assign(n, D());
|
|
64
|
+
for (let [e, t] of Object.entries(Z)) t != null && t !== "" && (n[e] = t);
|
|
65
|
+
let r = await I.list(_, n);
|
|
66
|
+
if (t !== ae) return;
|
|
67
|
+
V.value = k ? k(r.data) : r.data, H.value = [], Y.rows = r.rows, re.value = r.extras ?? {}, r.page && (Y.page = r.page), r.page_size && (Y.pageSize = r.page_size), Y.totalPages = Math.ceil(Y.rows / Y.pageSize) || 0;
|
|
68
|
+
} finally {
|
|
69
|
+
t === ae && (ie.value = !1);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function me() {
|
|
73
|
+
await $();
|
|
74
|
+
}
|
|
75
|
+
async function he() {
|
|
76
|
+
await $();
|
|
77
|
+
}
|
|
78
|
+
async function ge(e = 200) {
|
|
79
|
+
let t = {};
|
|
80
|
+
U.value && (t.search = U.value), X.field && X.order !== 0 && (t.ordering = X.order === -1 ? `-${X.field}` : X.field), D && Object.assign(t, D());
|
|
81
|
+
for (let [e, n] of Object.entries(Z)) n != null && n !== "" && (t[e] = n);
|
|
82
|
+
let n = [], r = 1;
|
|
83
|
+
for (; r <= 1e4;) {
|
|
84
|
+
let i = await I.list(_, {
|
|
85
|
+
...t,
|
|
86
|
+
page: r,
|
|
87
|
+
page_size: e
|
|
88
|
+
});
|
|
89
|
+
n.push(...i.data);
|
|
90
|
+
let a = i.rows ?? n.length;
|
|
91
|
+
if (i.data.length === 0 || n.length >= a) break;
|
|
92
|
+
r++;
|
|
93
|
+
}
|
|
94
|
+
return n;
|
|
95
|
+
}
|
|
96
|
+
function _e(e) {
|
|
97
|
+
U.value = e, pe && clearTimeout(pe), pe = setTimeout(() => {
|
|
98
|
+
Y.page = 1, $();
|
|
99
|
+
}, C);
|
|
100
|
+
}
|
|
101
|
+
function ve(e) {
|
|
102
|
+
let t = e.target;
|
|
103
|
+
_e(t.value);
|
|
104
|
+
}
|
|
105
|
+
function ye(e) {
|
|
106
|
+
Y.page = e, $();
|
|
107
|
+
}
|
|
108
|
+
function be() {
|
|
109
|
+
ye(1);
|
|
110
|
+
}
|
|
111
|
+
function xe() {
|
|
112
|
+
ye(Y.totalPages);
|
|
113
|
+
}
|
|
114
|
+
function Se(e) {
|
|
115
|
+
Y.page = e.page + 1, Y.pageSize = e.rows, $();
|
|
116
|
+
}
|
|
117
|
+
function Ce(e) {
|
|
118
|
+
X.field = e.sortField ?? null, X.order = e.sortOrder ?? 0, Y.page = 1, $();
|
|
119
|
+
}
|
|
120
|
+
function we() {
|
|
121
|
+
let e = se();
|
|
122
|
+
for (let t of Object.keys(e)) q[t] = e[t];
|
|
123
|
+
}
|
|
124
|
+
function Te(e, t) {
|
|
125
|
+
q[e] = t;
|
|
126
|
+
}
|
|
127
|
+
function Ee() {
|
|
128
|
+
if (G.value = !1, K.value = null, J = null, we(), O) {
|
|
129
|
+
let e = O();
|
|
130
|
+
for (let [t, n] of Object.entries(e)) q[t] = n;
|
|
131
|
+
}
|
|
132
|
+
W.value = !0;
|
|
133
|
+
}
|
|
134
|
+
function De(e) {
|
|
135
|
+
J = l(e, b, q);
|
|
136
|
+
}
|
|
137
|
+
async function Oe(e) {
|
|
138
|
+
try {
|
|
139
|
+
return (await I.get(_, e[x])).data;
|
|
140
|
+
} catch (e) {
|
|
141
|
+
return B.error(s(e, "Erro ao carregar registro")), null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function ke(e, t) {
|
|
145
|
+
return E ? Oe(e).then((e) => {
|
|
146
|
+
e && t(e);
|
|
147
|
+
}) : t(e);
|
|
148
|
+
}
|
|
149
|
+
function Ae(e) {
|
|
150
|
+
return ke(e, (e) => {
|
|
151
|
+
G.value = !1, K.value = e, De(e), W.value = !0;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function je(e) {
|
|
155
|
+
return ke(e, (e) => {
|
|
156
|
+
G.value = !0, K.value = e, De(e), W.value = !0;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function Me(e) {
|
|
160
|
+
return ke(e, (e) => Ne(e));
|
|
161
|
+
}
|
|
162
|
+
function Ne(e) {
|
|
163
|
+
G.value = !1, K.value = null, J = null, we();
|
|
164
|
+
for (let t of b) {
|
|
165
|
+
if (t.field === x) continue;
|
|
166
|
+
let n = e[t.field] === void 0 ? q[t.field] : e[t.field];
|
|
167
|
+
n && (t.type === "date" || t.type === "datetime") && typeof n == "string" && (n = o(n)), q[t.field] = n;
|
|
168
|
+
}
|
|
169
|
+
if (O) {
|
|
170
|
+
let e = O();
|
|
171
|
+
for (let [t, n] of Object.entries(e)) q[t] = n;
|
|
172
|
+
}
|
|
173
|
+
W.value = !0;
|
|
174
|
+
}
|
|
175
|
+
let Pe = "";
|
|
176
|
+
S(W, (e) => {
|
|
177
|
+
e && (Pe = JSON.stringify(q));
|
|
178
|
+
}, { flush: "sync" });
|
|
179
|
+
let Fe = m(() => W.value && !G.value && JSON.stringify(q) !== Pe);
|
|
180
|
+
A(Fe), f()?.registerCloseGuard(() => !Fe.value || te());
|
|
181
|
+
function Ie(e) {
|
|
182
|
+
return c(e, b);
|
|
183
|
+
}
|
|
184
|
+
async function Le() {
|
|
185
|
+
let e = n(b, q, Q.value);
|
|
186
|
+
if (e) return B.error(e), null;
|
|
187
|
+
oe.value = !0;
|
|
188
|
+
try {
|
|
189
|
+
let e = Ie(q);
|
|
190
|
+
if (!Q.value && O) {
|
|
191
|
+
let t = O();
|
|
192
|
+
for (let [n, r] of Object.entries(t)) {
|
|
193
|
+
let t = e[n];
|
|
194
|
+
(t == null || t === "") && (e[n] = r);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (Q.value && w && J && (e = j(Ie(J), e), Object.keys(e).length === 0 && !M)) {
|
|
198
|
+
W.value = !1;
|
|
199
|
+
let e = K.value;
|
|
200
|
+
return K.value = null, J = null, e;
|
|
201
|
+
}
|
|
202
|
+
M && (e = M(e, Q.value));
|
|
203
|
+
let t = b.some((t) => t.type === "image" && e[t.field] instanceof File), n = e, r;
|
|
204
|
+
if (t) {
|
|
205
|
+
let t = new Set(b.filter((e) => e.type === "image").map((e) => e.field)), i = new FormData();
|
|
206
|
+
for (let [n, r] of Object.entries(e)) if (r != null) {
|
|
207
|
+
if (r instanceof File) i.append(n, r);
|
|
208
|
+
else if (t.has(n)) continue;
|
|
209
|
+
else i.append(n, String(r));
|
|
210
|
+
}
|
|
211
|
+
n = i, r = { "Content-Type": "multipart/form-data" };
|
|
212
|
+
}
|
|
213
|
+
let i = r ? { headers: r } : void 0, a;
|
|
214
|
+
if (Q.value && K.value) {
|
|
215
|
+
let e = K.value[x];
|
|
216
|
+
if (a = await I.update(_, e, n, i), !T) {
|
|
217
|
+
let t = V.value.findIndex((t) => t[x] === e);
|
|
218
|
+
t !== -1 && (V.value[t] = a.data);
|
|
219
|
+
}
|
|
220
|
+
B.success(z.successUpdate);
|
|
221
|
+
} else a = await I.create(_, n, i), T || (V.value.unshift(a.data), Y.rows++), B.success(z.successCreate);
|
|
222
|
+
return W.value = !1, K.value = null, J = null, T && await $(), N && N(a.data, Q.value), a.data;
|
|
223
|
+
} catch (e) {
|
|
224
|
+
return B.error(s(e, "Erro ao salvar registro")), null;
|
|
225
|
+
} finally {
|
|
226
|
+
oe.value = !1;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async function Re(e, t, n) {
|
|
230
|
+
let a = e[x], o = b.find((e) => e.field === t), c = n;
|
|
231
|
+
o?.type === "date" && c instanceof Date ? c = i(c) : o?.type === "datetime" && c instanceof Date && (c = r(c));
|
|
232
|
+
try {
|
|
233
|
+
let e = await I.update(_, a, { [t]: c }), n = V.value.findIndex((e) => e[x] === a);
|
|
234
|
+
n !== -1 && (V.value[n] = {
|
|
235
|
+
...V.value[n],
|
|
236
|
+
...e.data
|
|
237
|
+
}), B.success(z.successUpdate);
|
|
238
|
+
} catch (e) {
|
|
239
|
+
B.error(s(e, "Erro ao salvar o campo"));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
async function ze(e) {
|
|
243
|
+
try {
|
|
244
|
+
let t = e[x];
|
|
245
|
+
await I.delete(_, t);
|
|
246
|
+
let n = V.value.findIndex((e) => e[x] === t);
|
|
247
|
+
n !== -1 && (V.value.splice(n, 1), Y.rows--), B.success(z.successDelete), P && P(e);
|
|
248
|
+
} catch (e) {
|
|
249
|
+
B.error(s(e, "Erro ao excluir registro"));
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function Be(e) {
|
|
253
|
+
ee(() => ze(e), z.deleteConfirmMessage);
|
|
254
|
+
}
|
|
255
|
+
function Ve() {
|
|
256
|
+
H.value = [];
|
|
257
|
+
}
|
|
258
|
+
function He(e, t) {
|
|
259
|
+
t == null || t === "" ? delete Z[e] : Z[e] = t, Y.page = 1, $();
|
|
260
|
+
}
|
|
261
|
+
function Ue() {
|
|
262
|
+
for (let e of Object.keys(Z)) delete Z[e];
|
|
263
|
+
Y.page = 1, $();
|
|
264
|
+
}
|
|
265
|
+
return {
|
|
266
|
+
items: V,
|
|
267
|
+
selectedItems: H,
|
|
268
|
+
columnFilters: Z,
|
|
269
|
+
extras: re,
|
|
270
|
+
loading: ie,
|
|
271
|
+
saving: oe,
|
|
272
|
+
search: U,
|
|
273
|
+
dialogVisible: W,
|
|
274
|
+
isDirty: Fe,
|
|
275
|
+
editingItem: K,
|
|
276
|
+
formData: q,
|
|
277
|
+
pagination: Y,
|
|
278
|
+
sort: X,
|
|
279
|
+
isEditing: Q,
|
|
280
|
+
isViewing: le,
|
|
281
|
+
viewMode: G,
|
|
282
|
+
dialogTitle: ue,
|
|
283
|
+
isFirstPage: de,
|
|
284
|
+
isLastPage: fe,
|
|
285
|
+
init: me,
|
|
286
|
+
fetchItems: $,
|
|
287
|
+
fetchAll: ge,
|
|
288
|
+
refresh: he,
|
|
289
|
+
setSearch: _e,
|
|
290
|
+
onSearch: ve,
|
|
291
|
+
onPage: Se,
|
|
292
|
+
onSort: Ce,
|
|
293
|
+
openCreateDialog: Ee,
|
|
294
|
+
openEditDialog: Ae,
|
|
295
|
+
openViewDialog: je,
|
|
296
|
+
openDuplicateDialog: Me,
|
|
297
|
+
save: Le,
|
|
298
|
+
updateField: Re,
|
|
299
|
+
confirmDelete: Be,
|
|
300
|
+
performDelete: ze,
|
|
301
|
+
setFormField: Te,
|
|
302
|
+
resetForm: we,
|
|
303
|
+
goToPage: ye,
|
|
304
|
+
firstPage: be,
|
|
305
|
+
lastPage: xe,
|
|
306
|
+
clearSelection: Ve,
|
|
307
|
+
setColumnFilter: He,
|
|
308
|
+
clearColumnFilters: Ue,
|
|
309
|
+
config: ne
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/composables/useSubviewCrud.ts
|
|
314
|
+
function N(r) {
|
|
315
|
+
let { rows: i, onChange: o, form: s, createDefaults: u = void 0, transformPayload: d = void 0, uniqueBy: f = void 0, uniqueMessage: h = "Este item já está na lista.", toForm: g = void 0, onAfterSave: _ = void 0, onAfterDelete: b = void 0, toast: x = !1 } = r, S = {
|
|
316
|
+
...p,
|
|
317
|
+
...r.labels
|
|
318
|
+
}, C = a(), { confirmDelete: w } = e(), T = m(() => i() ?? []), E = y(!1), D = y(!1), O = y(null), k = y(-1), A = v({}), j = t(s);
|
|
319
|
+
for (let e of Object.keys(j)) A[e] = j[e];
|
|
320
|
+
let M = m(() => k.value >= 0), N = m(() => M.value ? S.editTitle : S.createTitle);
|
|
321
|
+
function P() {
|
|
322
|
+
let e = t(s);
|
|
323
|
+
for (let t of Object.keys(e)) A[t] = e[t];
|
|
324
|
+
}
|
|
325
|
+
function F(e, t) {
|
|
326
|
+
A[e] = t;
|
|
327
|
+
}
|
|
328
|
+
function I() {
|
|
329
|
+
if (u) for (let [e, t] of Object.entries(u())) A[e] = t;
|
|
330
|
+
}
|
|
331
|
+
function L() {
|
|
332
|
+
O.value = null, k.value = -1, P(), I(), D.value = !0;
|
|
333
|
+
}
|
|
334
|
+
function R(e) {
|
|
335
|
+
if (l(e, s, A), g) for (let [t, n] of Object.entries(g(e))) A[t] = n;
|
|
336
|
+
}
|
|
337
|
+
function z(e, t) {
|
|
338
|
+
O.value = e, k.value = t, R(e), D.value = !0;
|
|
339
|
+
}
|
|
340
|
+
function B(e) {
|
|
341
|
+
O.value = null, k.value = -1, P(), R(e), I(), D.value = !0;
|
|
342
|
+
}
|
|
343
|
+
function ee(e) {
|
|
344
|
+
if (!f) return;
|
|
345
|
+
let t = typeof f == "function" ? f(e) : e[f];
|
|
346
|
+
if (t != null && t !== "") return String(t);
|
|
347
|
+
}
|
|
348
|
+
function te() {
|
|
349
|
+
let e = n(s, A, M.value);
|
|
350
|
+
if (e) return C.error(e), null;
|
|
351
|
+
let t = c(A, s);
|
|
352
|
+
if (!M.value && u) for (let [e, n] of Object.entries(u())) {
|
|
353
|
+
let r = t[e];
|
|
354
|
+
(r == null || r === "") && (t[e] = n);
|
|
355
|
+
}
|
|
356
|
+
d && (t = d(t, M.value));
|
|
357
|
+
let r = T.value, i = k.value, a = i >= 0, l = a ? {
|
|
358
|
+
...r[i],
|
|
359
|
+
...t
|
|
360
|
+
} : { ...t }, f = ee(l);
|
|
361
|
+
if (f !== void 0 && r.some((e, t) => t !== i && ee(e) === f)) return C.error(h), null;
|
|
362
|
+
let p = a ? r.map((e, t) => t === i ? l : e) : [...r, l];
|
|
363
|
+
return o(p), x && C.success(a ? S.successUpdate : S.successCreate), _?.(l, a), D.value = !1, O.value = null, k.value = -1, l;
|
|
364
|
+
}
|
|
365
|
+
function ne(e) {
|
|
366
|
+
let t = T.value, n = t[e];
|
|
367
|
+
n !== void 0 && (o(t.filter((t, n) => n !== e)), x && C.success(S.successDelete), b?.(n, e));
|
|
368
|
+
}
|
|
369
|
+
function V(e, t) {
|
|
370
|
+
w(() => ne(t), S.deleteConfirmMessage);
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
items: T,
|
|
374
|
+
saving: E,
|
|
375
|
+
dialogVisible: D,
|
|
376
|
+
editingItem: O,
|
|
377
|
+
editingIndex: k,
|
|
378
|
+
formData: A,
|
|
379
|
+
isEditing: M,
|
|
380
|
+
dialogTitle: N,
|
|
381
|
+
openCreateDialog: L,
|
|
382
|
+
openEditDialog: z,
|
|
383
|
+
openDuplicateDialog: B,
|
|
384
|
+
save: te,
|
|
385
|
+
confirmDelete: V,
|
|
386
|
+
performDelete: ne,
|
|
387
|
+
setFormField: F,
|
|
388
|
+
resetForm: P,
|
|
389
|
+
labels: S,
|
|
390
|
+
config: r
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
394
|
+
//#region src/composables/defineCrudConfig.ts
|
|
395
|
+
function P(e) {
|
|
396
|
+
return e;
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/composables/useApi.ts
|
|
400
|
+
function F(e) {
|
|
401
|
+
let { endpoint: t, searchDebounce: n = 300, immediate: r = !1 } = e, i = g(u);
|
|
402
|
+
if (!i) throw Error("[wPrimeVueComponents] dataProvider não encontrado. Registre o WPrimeVuePlugin antes de usar useApi.");
|
|
403
|
+
let a = i, o = g(d), s = e.pageSize ?? o?.defaultPageSize ?? 20, c = y([]), l = y(!1), f = y(""), p = y({}), m = v({}), h = v({
|
|
404
|
+
page: 1,
|
|
405
|
+
pageSize: s,
|
|
406
|
+
rows: 0,
|
|
407
|
+
totalPages: 0
|
|
408
|
+
}), _ = v({
|
|
409
|
+
field: null,
|
|
410
|
+
order: 0
|
|
411
|
+
}), b = null;
|
|
412
|
+
async function x(e = {}) {
|
|
413
|
+
l.value = !0;
|
|
414
|
+
try {
|
|
415
|
+
let n = {
|
|
416
|
+
page: h.page,
|
|
417
|
+
page_size: h.pageSize,
|
|
418
|
+
...e
|
|
419
|
+
};
|
|
420
|
+
f.value && (n.search = f.value), _.field && _.order !== 0 && (n.ordering = _.order === -1 ? `-${_.field}` : _.field);
|
|
421
|
+
for (let [e, t] of Object.entries(m)) t != null && t !== "" && (n[e] = t);
|
|
422
|
+
let r = await a.list(t, n);
|
|
423
|
+
c.value = r.data, h.rows = r.rows, r.page && (h.page = r.page), r.page_size && (h.pageSize = r.page_size), h.totalPages = Math.ceil(h.rows / h.pageSize) || 0, p.value = r.extras ?? {};
|
|
424
|
+
} finally {
|
|
425
|
+
l.value = !1;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
async function S() {
|
|
429
|
+
await x();
|
|
430
|
+
}
|
|
431
|
+
function C(e) {
|
|
432
|
+
f.value = e, b && clearTimeout(b), b = setTimeout(() => {
|
|
433
|
+
h.page = 1, x();
|
|
434
|
+
}, n);
|
|
435
|
+
}
|
|
436
|
+
function w(e, t) {
|
|
437
|
+
m[e] = t, h.page = 1, x();
|
|
438
|
+
}
|
|
439
|
+
function T() {
|
|
440
|
+
for (let e of Object.keys(m)) delete m[e];
|
|
441
|
+
h.page = 1, x();
|
|
442
|
+
}
|
|
443
|
+
function E(e) {
|
|
444
|
+
h.page = e.page + 1, h.pageSize = e.rows, x();
|
|
445
|
+
}
|
|
446
|
+
function D(e) {
|
|
447
|
+
_.field = e.sortField ?? null, _.order = e.sortOrder ?? 0, h.page = 1, x();
|
|
448
|
+
}
|
|
449
|
+
return r && x(), {
|
|
450
|
+
items: c,
|
|
451
|
+
loading: l,
|
|
452
|
+
search: f,
|
|
453
|
+
pagination: h,
|
|
454
|
+
sort: _,
|
|
455
|
+
extras: p,
|
|
456
|
+
fetchItems: x,
|
|
457
|
+
refresh: S,
|
|
458
|
+
setSearch: C,
|
|
459
|
+
setFilter: w,
|
|
460
|
+
clearFilters: T,
|
|
461
|
+
onPage: E,
|
|
462
|
+
onSort: D
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/composables/useRouteTabs.ts
|
|
467
|
+
function I(e) {
|
|
468
|
+
return {
|
|
469
|
+
fullPath: e.fullPath,
|
|
470
|
+
path: e.path,
|
|
471
|
+
name: e.name,
|
|
472
|
+
params: e.params,
|
|
473
|
+
query: e.query,
|
|
474
|
+
hash: e.hash,
|
|
475
|
+
meta: e.meta,
|
|
476
|
+
matched: e.matched,
|
|
477
|
+
redirectedFrom: e.redirectedFrom
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function L(e) {
|
|
481
|
+
let t = e.matched[e.matched.length - 1]?.props?.default;
|
|
482
|
+
return t === !0 ? { ...e.params } : typeof t == "function" ? t(e) ?? {} : t && typeof t == "object" ? { ...t } : {};
|
|
483
|
+
}
|
|
484
|
+
function R(e) {
|
|
485
|
+
let t = e.matched[e.matched.length - 1]?.components?.default;
|
|
486
|
+
return t && typeof t != "function" ? t : null;
|
|
487
|
+
}
|
|
488
|
+
function z(e) {
|
|
489
|
+
let { router: t, mode: n = "screen", moduleRoot: r, shouldRemount: i, resolveTabMeta: a = () => ({}), isTabRoute: o = () => !0, storage: s = typeof localStorage > "u" ? null : localStorage, storageKey: c = "w-route-tabs", homePath: l = "/", maxTabs: u } = e;
|
|
490
|
+
if (n === "module" && !r) throw Error("[useRouteTabs] mode \"module\" exige a opção moduleRoot(route).");
|
|
491
|
+
let d = (e) => n === "module" && r?.(e) || e.path, f = y([]), p = y(null), m = /* @__PURE__ */ new Map(), h = !1, g = null;
|
|
492
|
+
function _() {
|
|
493
|
+
return typeof c == "function" ? c() : c;
|
|
494
|
+
}
|
|
495
|
+
function v() {
|
|
496
|
+
if (!s) return;
|
|
497
|
+
let e = {
|
|
498
|
+
v: 1,
|
|
499
|
+
activeKey: p.value,
|
|
500
|
+
tabs: f.value.map(({ key: e, fullPath: t, title: n, icon: r, closable: i, group: a, color: o }) => ({
|
|
501
|
+
key: e,
|
|
502
|
+
fullPath: t,
|
|
503
|
+
title: n,
|
|
504
|
+
icon: r,
|
|
505
|
+
closable: i,
|
|
506
|
+
group: a,
|
|
507
|
+
color: o
|
|
508
|
+
}))
|
|
509
|
+
};
|
|
510
|
+
try {
|
|
511
|
+
s.setItem(_(), JSON.stringify(e));
|
|
512
|
+
} catch {}
|
|
513
|
+
}
|
|
514
|
+
function x() {
|
|
515
|
+
if (h = !0, g = _(), f.value = [], p.value = null, m.clear(), s) try {
|
|
516
|
+
let e = s.getItem(_());
|
|
517
|
+
if (!e) return;
|
|
518
|
+
let t = JSON.parse(e);
|
|
519
|
+
if (t?.v !== 1 || !Array.isArray(t.tabs)) return;
|
|
520
|
+
f.value = t.tabs.filter((e) => e && typeof e.key == "string" && typeof e.fullPath == "string").filter((e) => S(e.fullPath)).map((e) => ({
|
|
521
|
+
...e,
|
|
522
|
+
hydrated: !1,
|
|
523
|
+
remount: 0
|
|
524
|
+
}));
|
|
525
|
+
} catch {}
|
|
526
|
+
}
|
|
527
|
+
function S(e) {
|
|
528
|
+
try {
|
|
529
|
+
let n = t.resolve(e), r = n.matched[n.matched.length - 1];
|
|
530
|
+
return !r || r.redirect ? !1 : o(n);
|
|
531
|
+
} catch {
|
|
532
|
+
return !1;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
function C(e) {
|
|
536
|
+
return f.value.find((t) => t.key === e);
|
|
537
|
+
}
|
|
538
|
+
function w(e) {
|
|
539
|
+
if (e.group) {
|
|
540
|
+
for (let t = f.value.length - 1; t >= 0; --t) if (f.value[t].group === e.group) {
|
|
541
|
+
f.value.splice(t + 1, 0, e);
|
|
542
|
+
return;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
f.value.push(e);
|
|
546
|
+
}
|
|
547
|
+
function T(e) {
|
|
548
|
+
let t = a(e);
|
|
549
|
+
return t.title ? t.title : typeof e.name == "string" ? e.name : e.path;
|
|
550
|
+
}
|
|
551
|
+
function E(e, t) {
|
|
552
|
+
let r = m.get(e.key);
|
|
553
|
+
if (r && n === "module" && r.route.path !== t.path && (i?.(r.route, t) ?? !0)) {
|
|
554
|
+
m.delete(e.key), r = void 0, e.remount += 1;
|
|
555
|
+
let n = a(t);
|
|
556
|
+
e.title = n.title ?? T(t), n.icon && (e.icon = n.icon);
|
|
557
|
+
}
|
|
558
|
+
if (r) r.component = R(t), r.props = L(t), Object.assign(r.route, I(t));
|
|
559
|
+
else {
|
|
560
|
+
if (e.fullPath.split(/[?#]/)[0] !== t.path) {
|
|
561
|
+
let n = a(t);
|
|
562
|
+
e.title = n.title ?? T(t), n.icon && (e.icon = n.icon);
|
|
563
|
+
}
|
|
564
|
+
r = {
|
|
565
|
+
component: R(t),
|
|
566
|
+
props: L(t),
|
|
567
|
+
route: b(I(t)),
|
|
568
|
+
closeGuards: [],
|
|
569
|
+
activatedHooks: [],
|
|
570
|
+
deactivatedHooks: [],
|
|
571
|
+
defaultTitle: T(t)
|
|
572
|
+
}, m.set(e.key, r);
|
|
573
|
+
}
|
|
574
|
+
e.fullPath = t.fullPath, e.hydrated = !0;
|
|
575
|
+
}
|
|
576
|
+
function D() {
|
|
577
|
+
if (!u || f.value.length <= u) return;
|
|
578
|
+
let e = f.value.find((e) => e.key !== p.value && e.closable);
|
|
579
|
+
e && j(e.key);
|
|
580
|
+
}
|
|
581
|
+
n === "module" && t.beforeEach(async (e, t) => {
|
|
582
|
+
if (!h || !o(e) || !o(t)) return !0;
|
|
583
|
+
let n = d(e);
|
|
584
|
+
return n !== p.value || n !== d(t) || t.path === e.path || await k(n);
|
|
585
|
+
}), t.afterEach((e, t, n) => {
|
|
586
|
+
if (n) return;
|
|
587
|
+
if ((!h || s && _() !== g) && x(), !o(e)) {
|
|
588
|
+
p.value = null;
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
let r = d(e), i = C(r);
|
|
592
|
+
if (!i) {
|
|
593
|
+
let t = a(e);
|
|
594
|
+
i = {
|
|
595
|
+
key: r,
|
|
596
|
+
fullPath: e.fullPath,
|
|
597
|
+
title: t.title ?? T(e),
|
|
598
|
+
icon: t.icon,
|
|
599
|
+
closable: t.closable ?? !0,
|
|
600
|
+
group: t.group,
|
|
601
|
+
color: t.color,
|
|
602
|
+
hydrated: !1,
|
|
603
|
+
remount: 0
|
|
604
|
+
}, w(i);
|
|
605
|
+
}
|
|
606
|
+
E(i, e), p.value = r, D(), v();
|
|
607
|
+
});
|
|
608
|
+
async function O(e) {
|
|
609
|
+
let n = C(e);
|
|
610
|
+
!n || e === p.value || await t.push(n.fullPath);
|
|
611
|
+
}
|
|
612
|
+
async function k(e) {
|
|
613
|
+
let t = m.get(e);
|
|
614
|
+
if (!t) return !0;
|
|
615
|
+
for (let e of [...t.closeGuards]) if (!await e()) return !1;
|
|
616
|
+
return !0;
|
|
617
|
+
}
|
|
618
|
+
function A(e) {
|
|
619
|
+
f.value = f.value.filter((t) => t.key !== e), m.delete(e);
|
|
620
|
+
}
|
|
621
|
+
async function j(e) {
|
|
622
|
+
let n = C(e);
|
|
623
|
+
if (!n) return !0;
|
|
624
|
+
if (!n.closable || !await k(e)) return !1;
|
|
625
|
+
let r = f.value.findIndex((t) => t.key === e), i = e === p.value;
|
|
626
|
+
if (A(e), i) {
|
|
627
|
+
let e = f.value[r - 1] ?? f.value[r] ?? null;
|
|
628
|
+
e ? (p.value = null, await t.push(e.fullPath)) : (p.value = null, await t.push(l));
|
|
629
|
+
}
|
|
630
|
+
return v(), !0;
|
|
631
|
+
}
|
|
632
|
+
async function M(e) {
|
|
633
|
+
for (let t of f.value.filter((t) => t.key !== e && t.closable)) await k(t.key).then((e) => e && A(t.key));
|
|
634
|
+
v(), await O(e);
|
|
635
|
+
}
|
|
636
|
+
async function N() {
|
|
637
|
+
let e = !1;
|
|
638
|
+
for (let t of [...f.value]) {
|
|
639
|
+
if (!t.closable || !await k(t.key)) {
|
|
640
|
+
e ||= t.key === p.value;
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
A(t.key);
|
|
644
|
+
}
|
|
645
|
+
if (v(), !e && p.value) {
|
|
646
|
+
let e = f.value[0];
|
|
647
|
+
p.value = null, await t.push(e ? e.fullPath : l);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
function P(e) {
|
|
651
|
+
let t = C(e);
|
|
652
|
+
if (!t?.hydrated) return;
|
|
653
|
+
let n = m.get(e);
|
|
654
|
+
n && (n.closeGuards = [], n.activatedHooks = [], n.deactivatedHooks = []), t.remount += 1;
|
|
655
|
+
}
|
|
656
|
+
function F(e, t) {
|
|
657
|
+
let n = C(e);
|
|
658
|
+
n && (n.title = t ?? m.get(e)?.defaultTitle ?? n.title, v());
|
|
659
|
+
}
|
|
660
|
+
function z(e) {
|
|
661
|
+
return C(typeof e == "string" ? e : d(e))?.hydrated ?? !1;
|
|
662
|
+
}
|
|
663
|
+
return {
|
|
664
|
+
tabs: f,
|
|
665
|
+
activeKey: p,
|
|
666
|
+
activate: O,
|
|
667
|
+
close: j,
|
|
668
|
+
closeOthers: M,
|
|
669
|
+
closeAll: N,
|
|
670
|
+
reload: P,
|
|
671
|
+
setTitle: F,
|
|
672
|
+
isLive: z,
|
|
673
|
+
runtime: (e) => m.get(e)
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
//#endregion
|
|
677
|
+
//#region src/composables/usePublishedVersion.ts
|
|
678
|
+
var B = 6e4, ee = 3e5, te = /Failed to fetch dynamically imported module|Importing a module script failed|error loading dynamically imported module|Unable to preload CSS/i, ne = (e) => te.test(String(e?.message ?? e ?? "")), V = "w-chunk-reload";
|
|
679
|
+
function H(e) {
|
|
680
|
+
let t = !1, n = -Infinity, r = -Infinity, i = null, a = !1, o = !1;
|
|
681
|
+
async function s() {
|
|
682
|
+
try {
|
|
683
|
+
let r = await e.fetchVersion();
|
|
684
|
+
if (r.status !== 200) return;
|
|
685
|
+
let i = await r.json();
|
|
686
|
+
if (typeof i?.build != "string") return;
|
|
687
|
+
t = i.build !== e.currentBuild, n = e.now();
|
|
688
|
+
} catch {}
|
|
689
|
+
}
|
|
690
|
+
function c() {
|
|
691
|
+
return i || (e.now() - r < 6e4 ? Promise.resolve() : (r = e.now(), i = s().finally(() => {
|
|
692
|
+
i = null;
|
|
693
|
+
}), i));
|
|
694
|
+
}
|
|
695
|
+
function l() {
|
|
696
|
+
return t && !a && e.now() - n < 3e5 && e.online() && e.pending().length === 0;
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
check: c,
|
|
700
|
+
canReload: l,
|
|
701
|
+
get hasNewVersion() {
|
|
702
|
+
return t;
|
|
703
|
+
},
|
|
704
|
+
async onTabVisible() {
|
|
705
|
+
await c(), l() && (a = !0, e.reload());
|
|
706
|
+
},
|
|
707
|
+
onRouteChange(t, n, r) {
|
|
708
|
+
return !n.matched?.length || t.name !== void 0 && t.name === n.name || t.path === n.path || (c(), !l()) || (a = !0, e.goTo(r), !1);
|
|
709
|
+
},
|
|
710
|
+
onChunkError(t) {
|
|
711
|
+
if (!e.online() || !e.storage) return !1;
|
|
712
|
+
try {
|
|
713
|
+
if (e.storage.getItem(V) === e.currentBuild) return !1;
|
|
714
|
+
if (e.pending().length > 0) return o || e.warn(), o = !0, !1;
|
|
715
|
+
e.storage.setItem(V, e.currentBuild);
|
|
716
|
+
} catch {
|
|
717
|
+
return !1;
|
|
718
|
+
}
|
|
719
|
+
return a = !0, t ? e.goTo(t) : e.reload(), !0;
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
function re(e, t) {
|
|
724
|
+
if (t.enabled === !1 || typeof window > "u") return null;
|
|
725
|
+
let n = H({
|
|
726
|
+
currentBuild: t.buildId,
|
|
727
|
+
fetchVersion: () => fetch(t.versionUrl ?? "/version.json", { cache: "no-store" }),
|
|
728
|
+
now: () => Date.now(),
|
|
729
|
+
online: () => navigator.onLine !== !1,
|
|
730
|
+
pending: t.pending ?? O,
|
|
731
|
+
reload: () => window.location.reload(),
|
|
732
|
+
goTo: (e) => window.location.assign(e),
|
|
733
|
+
storage: (() => {
|
|
734
|
+
try {
|
|
735
|
+
return window.sessionStorage;
|
|
736
|
+
} catch {
|
|
737
|
+
return null;
|
|
738
|
+
}
|
|
739
|
+
})(),
|
|
740
|
+
warn: t.onBlocked ?? (() => {})
|
|
741
|
+
});
|
|
742
|
+
document.addEventListener("visibilitychange", () => {
|
|
743
|
+
document.visibilityState === "visible" && n.onTabVisible();
|
|
744
|
+
}), window.addEventListener("pageshow", (e) => {
|
|
745
|
+
e.persisted && n.onTabVisible();
|
|
746
|
+
});
|
|
747
|
+
let r;
|
|
748
|
+
return e.beforeEach((t, i) => {
|
|
749
|
+
let a = e.resolve(t.fullPath).href, o = n.onRouteChange(t, i, a);
|
|
750
|
+
return r = o ? a : void 0, o;
|
|
751
|
+
}), e.afterEach(() => {
|
|
752
|
+
r = void 0;
|
|
753
|
+
}), window.addEventListener("vite:preloadError", (e) => {
|
|
754
|
+
n.onChunkError(r) && e.preventDefault();
|
|
755
|
+
}), e.onError((t, i) => {
|
|
756
|
+
let a = i?.fullPath ? e.resolve(i.fullPath).href : r;
|
|
757
|
+
r = void 0, ne(t) && n.onChunkError(a);
|
|
758
|
+
}), n;
|
|
759
|
+
}
|
|
760
|
+
//#endregion
|
|
761
|
+
export { ne as a, P as c, O as d, k as f, re as i, N as l, ee as n, z as o, A as p, H as r, F as s, B as t, M as u };
|
|
762
|
+
|
|
763
|
+
//# sourceMappingURL=composables-Bu1oxAgP.js.map
|