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