@wgalleti/primevue-components 0.16.0 → 0.18.0

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