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