@inandu-solutions/grid-vue 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +196 -3
- package/dist/components/DataRow.vue.d.ts +34 -0
- package/dist/components/EditCell.vue.d.ts +16 -0
- package/dist/components/FilterControl.vue.d.ts +16 -0
- package/dist/components/InanduGrid.vue.d.ts +231 -0
- package/dist/components/internal.d.ts +60 -0
- package/dist/components/types.d.ts +6 -0
- package/dist/composables/useInanduGrid.d.ts +260 -0
- package/dist/composables/useInanduGridServer.d.ts +53 -0
- package/dist/core/aggregate.d.ts +5 -0
- package/dist/core/columns.d.ts +11 -0
- package/dist/core/constants.d.ts +14 -0
- package/dist/core/dom.d.ts +8 -0
- package/dist/core/export/csv.d.ts +2 -0
- package/dist/core/export/download.d.ts +2 -0
- package/dist/core/export/markup.d.ts +2 -0
- package/dist/core/export/pdf.d.ts +3 -0
- package/dist/core/filter.d.ts +26 -0
- package/dist/core/format.d.ts +24 -0
- package/dist/core/i18n/en.d.ts +46 -0
- package/dist/core/i18n/es.d.ts +46 -0
- package/dist/core/i18n/fr.d.ts +46 -0
- package/dist/core/i18n/index.d.ts +8 -0
- package/dist/core/i18n/it.d.ts +46 -0
- package/dist/core/i18n/zh.d.ts +46 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/parse.d.ts +14 -0
- package/dist/core/sort.d.ts +1 -0
- package/dist/core/tree.d.ts +28 -0
- package/dist/core/types.d.ts +46 -0
- package/dist/inandu-grid-vue.cjs +3 -0
- package/dist/inandu-grid-vue.js +1973 -0
- package/dist/index.d.ts +13 -0
- package/dist/style.css +358 -0
- package/dist/utils/exporters.d.ts +29 -0
- package/dist/utils/measureColumn.d.ts +15 -0
- package/dist/utils/translate.d.ts +10 -0
- package/package.json +92 -6
|
@@ -0,0 +1,1973 @@
|
|
|
1
|
+
import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createTextVNode as o, createVNode as s, defineComponent as c, normalizeClass as l, normalizeStyle as u, onBeforeUnmount as d, onScopeDispose as f, openBlock as p, renderList as m, shallowRef as h, toDisplayString as g, toValue as _, unref as v, useSlots as y, watch as ee, withModifiers as b } from "vue";
|
|
2
|
+
//#region src/core/format.ts
|
|
3
|
+
var x = /^(\d+)?\.(\d+)-(\d+)$/;
|
|
4
|
+
function te(e, t, n) {
|
|
5
|
+
let r = {}, i = n ? x.exec(n) : null;
|
|
6
|
+
return i ? (i[1] && (r.minimumIntegerDigits = Number(i[1])), r.minimumFractionDigits = Number(i[2]), r.maximumFractionDigits = Number(i[3])) : r.maximumFractionDigits = 3, new Intl.NumberFormat(t || void 0, r).format(e);
|
|
7
|
+
}
|
|
8
|
+
function S(e) {
|
|
9
|
+
return e instanceof Date ? e : typeof e == "string" ? new Date(e.replace(/^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2})/, "$1T$2")) : new Date(e);
|
|
10
|
+
}
|
|
11
|
+
var C = /YYYY|sss|MM|DD|HH|mm|ss/g;
|
|
12
|
+
function w(e, t) {
|
|
13
|
+
let n = (e, t = 2) => String(e).padStart(t, "0");
|
|
14
|
+
return t.replace(C, (t) => {
|
|
15
|
+
switch (t) {
|
|
16
|
+
case "YYYY": return String(e.getFullYear());
|
|
17
|
+
case "MM": return n(e.getMonth() + 1);
|
|
18
|
+
case "DD": return n(e.getDate());
|
|
19
|
+
case "HH": return n(e.getHours());
|
|
20
|
+
case "mm": return n(e.getMinutes());
|
|
21
|
+
case "ss": return n(e.getSeconds());
|
|
22
|
+
case "sss": return n(e.getMilliseconds(), 3);
|
|
23
|
+
default: return t;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function T(e, t, n, r, i = te) {
|
|
28
|
+
if (e == null) return "";
|
|
29
|
+
switch (t) {
|
|
30
|
+
case "number": {
|
|
31
|
+
let t = typeof e == "number" ? e : Number(e);
|
|
32
|
+
return Number.isNaN(t) ? String(e) : i(t, r, n || void 0);
|
|
33
|
+
}
|
|
34
|
+
case "date": {
|
|
35
|
+
let t = S(e);
|
|
36
|
+
return Number.isNaN(t.getTime()) ? String(e) : w(t, n || "YYYY-MM-DD");
|
|
37
|
+
}
|
|
38
|
+
case "boolean": {
|
|
39
|
+
let [t, r] = (n || "true|false").split("|");
|
|
40
|
+
return e ? t : r;
|
|
41
|
+
}
|
|
42
|
+
default: return String(e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/core/sort.ts
|
|
47
|
+
function E(e, t, n) {
|
|
48
|
+
return e == null && t == null ? 0 : e == null ? -1 : t == null ? 1 : e instanceof Date && t instanceof Date ? e.getTime() - t.getTime() : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t), n || void 0);
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/core/tree.ts
|
|
52
|
+
function D(e, t) {
|
|
53
|
+
let { getChildren: n, isExpanded: r, match: i, compare: a } = t, o = [], s = /* @__PURE__ */ new Map(), c = (e) => {
|
|
54
|
+
if (!i) return !0;
|
|
55
|
+
let t = s.get(e);
|
|
56
|
+
if (t !== void 0) return t;
|
|
57
|
+
let r = i(e);
|
|
58
|
+
if (!r) {
|
|
59
|
+
let t = n(e);
|
|
60
|
+
r = !!t && t.some(c);
|
|
61
|
+
}
|
|
62
|
+
return s.set(e, r), r;
|
|
63
|
+
}, l = (e, t) => {
|
|
64
|
+
let s = i ? e.filter(c) : [...e];
|
|
65
|
+
a && (s = s.slice().sort(a));
|
|
66
|
+
for (let e of s) {
|
|
67
|
+
let a = n(e), s = (a ? i ? a.filter(c) : a : []).length > 0, u = s && (i ? !0 : r(e));
|
|
68
|
+
o.push({
|
|
69
|
+
row: e,
|
|
70
|
+
depth: t,
|
|
71
|
+
expandable: s,
|
|
72
|
+
expanded: u
|
|
73
|
+
}), u && l(a, t + 1);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return l(e, 0), o;
|
|
77
|
+
}
|
|
78
|
+
function ne(e, t) {
|
|
79
|
+
let n = [], r = (e) => {
|
|
80
|
+
for (let i of e) {
|
|
81
|
+
n.push(i);
|
|
82
|
+
let e = t(i);
|
|
83
|
+
e && e.length && r(e);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
return r(e), n;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/core/filter.ts
|
|
90
|
+
function re(e) {
|
|
91
|
+
return e ? Object.values(e).some((e) => Array.isArray(e) ? !0 : !!e) : !1;
|
|
92
|
+
}
|
|
93
|
+
function ie(e, t, n, r, i) {
|
|
94
|
+
let a = t[e.field()];
|
|
95
|
+
if (n.values !== void 0) return n.values.includes(T(a, e.type(), e.format(), r, i));
|
|
96
|
+
switch (e.type()) {
|
|
97
|
+
case "number": {
|
|
98
|
+
let e = !!n.min, t = !!n.max;
|
|
99
|
+
if (!e && !t) return !0;
|
|
100
|
+
let r = typeof a == "number" ? a : Number(a);
|
|
101
|
+
return !(a == null || Number.isNaN(r) || e && r < Number(n.min) || t && r > Number(n.max));
|
|
102
|
+
}
|
|
103
|
+
case "date": {
|
|
104
|
+
let e = !!n.from, t = !!n.to;
|
|
105
|
+
if (!e && !t) return !0;
|
|
106
|
+
if (a == null) return !1;
|
|
107
|
+
let r = S(a);
|
|
108
|
+
if (Number.isNaN(r.getTime()) || e && r < new Date(n.from)) return !1;
|
|
109
|
+
if (t) {
|
|
110
|
+
let e = new Date(n.to);
|
|
111
|
+
if (e.setHours(23, 59, 59, 999), r > e) return !1;
|
|
112
|
+
}
|
|
113
|
+
return !0;
|
|
114
|
+
}
|
|
115
|
+
case "boolean": return !n.bool || !!a == (n.bool === "true");
|
|
116
|
+
default: {
|
|
117
|
+
let t = (n.text ?? "").trim().toLowerCase();
|
|
118
|
+
return !t || T(a, e.type(), e.format(), r, i).toLowerCase().includes(t);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/core/aggregate.ts
|
|
124
|
+
var O = {
|
|
125
|
+
sum: "Σ",
|
|
126
|
+
avg: "x̄",
|
|
127
|
+
min: "min",
|
|
128
|
+
max: "max",
|
|
129
|
+
count: "#"
|
|
130
|
+
};
|
|
131
|
+
function ae(e, t) {
|
|
132
|
+
let n = {};
|
|
133
|
+
for (let r of t) {
|
|
134
|
+
let t = r.field(), i = r.aggregate();
|
|
135
|
+
if (i === "count") {
|
|
136
|
+
n[t] = e.length;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
let a = e.map((e) => e[t]).filter((e) => e != null && e !== "" && typeof e != "boolean").map((e) => Number(e)).filter((e) => Number.isFinite(e));
|
|
140
|
+
if (a.length === 0) n[t] = 0;
|
|
141
|
+
else switch (i) {
|
|
142
|
+
case "sum":
|
|
143
|
+
n[t] = a.reduce((e, t) => e + t, 0);
|
|
144
|
+
break;
|
|
145
|
+
case "avg":
|
|
146
|
+
n[t] = a.reduce((e, t) => e + t, 0) / a.length;
|
|
147
|
+
break;
|
|
148
|
+
case "min":
|
|
149
|
+
n[t] = a.reduce((e, t) => t < e ? t : e, Infinity);
|
|
150
|
+
break;
|
|
151
|
+
case "max": n[t] = a.reduce((e, t) => t > e ? t : e, -Infinity);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return n;
|
|
155
|
+
}
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region src/core/parse.ts
|
|
158
|
+
function oe(e, t) {
|
|
159
|
+
switch (t) {
|
|
160
|
+
case "number": {
|
|
161
|
+
if (e === "" || e === void 0) return;
|
|
162
|
+
let t = Number(e);
|
|
163
|
+
return Number.isNaN(t) ? void 0 : t;
|
|
164
|
+
}
|
|
165
|
+
case "date": {
|
|
166
|
+
let t = typeof e == "string" ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(e) : null, n = t ? new Date(Number(t[1]), Number(t[2]) - 1, Number(t[3])) : new Date(e);
|
|
167
|
+
return Number.isNaN(n.getTime()) ? void 0 : n;
|
|
168
|
+
}
|
|
169
|
+
case "boolean": return !!e;
|
|
170
|
+
default: return e;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function se(e, t) {
|
|
174
|
+
return t === "boolean" ? e.trim().toLowerCase() === "true" : oe(e, t);
|
|
175
|
+
}
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/core/dom.ts
|
|
178
|
+
function k(e) {
|
|
179
|
+
return e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/core/export/csv.ts
|
|
183
|
+
function A(e) {
|
|
184
|
+
return /[",\r\n]/.test(e) ? "\"" + e.replace(/"/g, "\"\"") + "\"" : e;
|
|
185
|
+
}
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/core/export/markup.ts
|
|
188
|
+
function j(e) {
|
|
189
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/core/export/pdf.ts
|
|
193
|
+
function M(e, t, n) {
|
|
194
|
+
if (e.getTextWidth(t) <= n) return t;
|
|
195
|
+
let r = t;
|
|
196
|
+
for (; r.length > 0 && e.getTextWidth(r + "…") > n;) r = r.slice(0, -1);
|
|
197
|
+
return r + "…";
|
|
198
|
+
}
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/core/export/download.ts
|
|
201
|
+
function N(e, t, n) {
|
|
202
|
+
let r = e instanceof Blob ? e : new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
203
|
+
a.href = i, a.download = t, a.click(), URL.revokeObjectURL(i);
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/core/i18n/en.ts
|
|
207
|
+
var P = {
|
|
208
|
+
MsgNoData: "No data",
|
|
209
|
+
MsgFirstPage: "First page",
|
|
210
|
+
MsgPreviousPage: "Previous page",
|
|
211
|
+
MsgNextPage: "Next page",
|
|
212
|
+
MsgLastPage: "Last page",
|
|
213
|
+
MsgSortBy: "Sort by {{column}}",
|
|
214
|
+
MsgPageOf: "Page {{page}} of {{total}}",
|
|
215
|
+
MsgFilterPlaceholder: "Search",
|
|
216
|
+
MsgFilterColumn: "Filter {{column}}",
|
|
217
|
+
MsgFilterMin: "Min",
|
|
218
|
+
MsgFilterMax: "Max",
|
|
219
|
+
MsgFilterFrom: "From",
|
|
220
|
+
MsgFilterTo: "To",
|
|
221
|
+
MsgAll: "All",
|
|
222
|
+
MsgCancelFilter: "Cancel filter",
|
|
223
|
+
MsgCancelAllFilters: "Clear filters",
|
|
224
|
+
MsgGroupByHint: "Drag a column header here to group by it",
|
|
225
|
+
MsgGroupedBy: "Grouped by {{column}}",
|
|
226
|
+
MsgGroupHeader: "{{column}}: {{value}} ({{count}})",
|
|
227
|
+
MsgCancelGrouping: "Cancel grouping",
|
|
228
|
+
MsgSelectAll: "Select all rows",
|
|
229
|
+
MsgSelectRow: "Select row {{index}}",
|
|
230
|
+
MsgExportCsv: "Export CSV",
|
|
231
|
+
MsgExportExcel: "Export Excel",
|
|
232
|
+
MsgExportPdf: "Export PDF",
|
|
233
|
+
MsgPrint: "Print",
|
|
234
|
+
MsgToggleColumns: "Columns",
|
|
235
|
+
MsgToggleColumn: "Toggle {{column}}",
|
|
236
|
+
MsgEditCell: "Edit {{column}}",
|
|
237
|
+
MsgEditRow: "Edit",
|
|
238
|
+
MsgSaveRow: "Save",
|
|
239
|
+
MsgCancelRowEdit: "Cancel",
|
|
240
|
+
MsgDeleteRow: "Delete",
|
|
241
|
+
MsgAddRow: "Add row",
|
|
242
|
+
MsgLoading: "Loading…",
|
|
243
|
+
MsgDragRow: "Drag to reorder row",
|
|
244
|
+
MsgAutosizeColumn: "Double-click to fit column to content",
|
|
245
|
+
MsgExpandDetail: "Expand row details",
|
|
246
|
+
MsgCollapseDetail: "Collapse row details",
|
|
247
|
+
MsgDeleteSelected: "Delete selected ({{count}})",
|
|
248
|
+
MsgValidationRequired: "This field is required",
|
|
249
|
+
MsgValidationMin: "Must be at least {{min}}",
|
|
250
|
+
MsgValidationMax: "Must be at most {{max}}",
|
|
251
|
+
MsgValidationPattern: "Invalid format"
|
|
252
|
+
}, F = {
|
|
253
|
+
MsgNoData: "Sin datos",
|
|
254
|
+
MsgFirstPage: "Primera página",
|
|
255
|
+
MsgPreviousPage: "Página anterior",
|
|
256
|
+
MsgNextPage: "Página siguiente",
|
|
257
|
+
MsgLastPage: "Última página",
|
|
258
|
+
MsgSortBy: "Ordenar por {{column}}",
|
|
259
|
+
MsgPageOf: "Página {{page}} de {{total}}",
|
|
260
|
+
MsgFilterPlaceholder: "Buscar",
|
|
261
|
+
MsgFilterColumn: "Filtrar {{column}}",
|
|
262
|
+
MsgFilterMin: "Mín",
|
|
263
|
+
MsgFilterMax: "Máx",
|
|
264
|
+
MsgFilterFrom: "Desde",
|
|
265
|
+
MsgFilterTo: "Hasta",
|
|
266
|
+
MsgAll: "Todos",
|
|
267
|
+
MsgCancelFilter: "Cancelar filtro",
|
|
268
|
+
MsgCancelAllFilters: "Cancelar filtros",
|
|
269
|
+
MsgGroupByHint: "Arrastra el encabezado de una columna aquí para agrupar por ella",
|
|
270
|
+
MsgGroupedBy: "Agrupado por {{column}}",
|
|
271
|
+
MsgGroupHeader: "{{column}}: {{value}} ({{count}})",
|
|
272
|
+
MsgCancelGrouping: "Cancelar agrupación",
|
|
273
|
+
MsgSelectAll: "Seleccionar todas las filas",
|
|
274
|
+
MsgSelectRow: "Seleccionar fila {{index}}",
|
|
275
|
+
MsgExportCsv: "Exportar CSV",
|
|
276
|
+
MsgExportExcel: "Exportar Excel",
|
|
277
|
+
MsgExportPdf: "Exportar PDF",
|
|
278
|
+
MsgPrint: "Imprimir",
|
|
279
|
+
MsgToggleColumns: "Columnas",
|
|
280
|
+
MsgToggleColumn: "Mostrar u ocultar {{column}}",
|
|
281
|
+
MsgEditCell: "Editar {{column}}",
|
|
282
|
+
MsgEditRow: "Editar",
|
|
283
|
+
MsgSaveRow: "Guardar",
|
|
284
|
+
MsgCancelRowEdit: "Cancelar",
|
|
285
|
+
MsgDeleteRow: "Eliminar",
|
|
286
|
+
MsgAddRow: "Agregar fila",
|
|
287
|
+
MsgLoading: "Cargando…",
|
|
288
|
+
MsgDragRow: "Arrastrar para reordenar fila",
|
|
289
|
+
MsgAutosizeColumn: "Doble clic para ajustar la columna al contenido",
|
|
290
|
+
MsgExpandDetail: "Expandir detalle de fila",
|
|
291
|
+
MsgCollapseDetail: "Contraer detalle de fila",
|
|
292
|
+
MsgDeleteSelected: "Eliminar seleccionados ({{count}})",
|
|
293
|
+
MsgValidationRequired: "Este campo es obligatorio",
|
|
294
|
+
MsgValidationMin: "Debe ser como mínimo {{min}}",
|
|
295
|
+
MsgValidationMax: "Debe ser como máximo {{max}}",
|
|
296
|
+
MsgValidationPattern: "Formato inválido"
|
|
297
|
+
}, I = {
|
|
298
|
+
MsgNoData: "Aucune donnée",
|
|
299
|
+
MsgFirstPage: "Première page",
|
|
300
|
+
MsgPreviousPage: "Page précédente",
|
|
301
|
+
MsgNextPage: "Page suivante",
|
|
302
|
+
MsgLastPage: "Dernière page",
|
|
303
|
+
MsgSortBy: "Trier par {{column}}",
|
|
304
|
+
MsgPageOf: "Page {{page}} sur {{total}}",
|
|
305
|
+
MsgFilterPlaceholder: "Rechercher",
|
|
306
|
+
MsgFilterColumn: "Filtrer {{column}}",
|
|
307
|
+
MsgFilterMin: "Min",
|
|
308
|
+
MsgFilterMax: "Max",
|
|
309
|
+
MsgFilterFrom: "De",
|
|
310
|
+
MsgFilterTo: "À",
|
|
311
|
+
MsgAll: "Tous",
|
|
312
|
+
MsgCancelFilter: "Annuler le filtre",
|
|
313
|
+
MsgCancelAllFilters: "Effacer les filtres",
|
|
314
|
+
MsgGroupByHint: "Faites glisser l'en-tête d'une colonne ici pour regrouper par celle-ci",
|
|
315
|
+
MsgGroupedBy: "Regroupé par {{column}}",
|
|
316
|
+
MsgGroupHeader: "{{column}} : {{value}} ({{count}})",
|
|
317
|
+
MsgCancelGrouping: "Annuler le regroupement",
|
|
318
|
+
MsgSelectAll: "Sélectionner toutes les lignes",
|
|
319
|
+
MsgSelectRow: "Sélectionner la ligne {{index}}",
|
|
320
|
+
MsgExportCsv: "Exporter CSV",
|
|
321
|
+
MsgExportExcel: "Exporter Excel",
|
|
322
|
+
MsgExportPdf: "Exporter PDF",
|
|
323
|
+
MsgPrint: "Imprimer",
|
|
324
|
+
MsgToggleColumns: "Colonnes",
|
|
325
|
+
MsgToggleColumn: "Afficher/masquer {{column}}",
|
|
326
|
+
MsgEditCell: "Modifier {{column}}",
|
|
327
|
+
MsgEditRow: "Modifier",
|
|
328
|
+
MsgSaveRow: "Enregistrer",
|
|
329
|
+
MsgCancelRowEdit: "Annuler",
|
|
330
|
+
MsgDeleteRow: "Supprimer",
|
|
331
|
+
MsgAddRow: "Ajouter une ligne",
|
|
332
|
+
MsgLoading: "Chargement…",
|
|
333
|
+
MsgDragRow: "Glisser pour réordonner la ligne",
|
|
334
|
+
MsgAutosizeColumn: "Double-cliquez pour ajuster la colonne au contenu",
|
|
335
|
+
MsgExpandDetail: "Développer les détails de la ligne",
|
|
336
|
+
MsgCollapseDetail: "Réduire les détails de la ligne",
|
|
337
|
+
MsgDeleteSelected: "Supprimer la sélection ({{count}})",
|
|
338
|
+
MsgValidationRequired: "Ce champ est obligatoire",
|
|
339
|
+
MsgValidationMin: "Doit être au moins {{min}}",
|
|
340
|
+
MsgValidationMax: "Doit être au plus {{max}}",
|
|
341
|
+
MsgValidationPattern: "Format invalide"
|
|
342
|
+
}, ce = {
|
|
343
|
+
MsgNoData: "Nessun dato",
|
|
344
|
+
MsgFirstPage: "Prima pagina",
|
|
345
|
+
MsgPreviousPage: "Pagina precedente",
|
|
346
|
+
MsgNextPage: "Pagina successiva",
|
|
347
|
+
MsgLastPage: "Ultima pagina",
|
|
348
|
+
MsgSortBy: "Ordina per {{column}}",
|
|
349
|
+
MsgPageOf: "Pagina {{page}} di {{total}}",
|
|
350
|
+
MsgFilterPlaceholder: "Cerca",
|
|
351
|
+
MsgFilterColumn: "Filtra {{column}}",
|
|
352
|
+
MsgFilterMin: "Min",
|
|
353
|
+
MsgFilterMax: "Max",
|
|
354
|
+
MsgFilterFrom: "Da",
|
|
355
|
+
MsgFilterTo: "A",
|
|
356
|
+
MsgAll: "Tutti",
|
|
357
|
+
MsgCancelFilter: "Annulla filtro",
|
|
358
|
+
MsgCancelAllFilters: "Cancella filtri",
|
|
359
|
+
MsgGroupByHint: "Trascina qui l'intestazione di una colonna per raggruppare per essa",
|
|
360
|
+
MsgGroupedBy: "Raggruppato per {{column}}",
|
|
361
|
+
MsgGroupHeader: "{{column}}: {{value}} ({{count}})",
|
|
362
|
+
MsgCancelGrouping: "Annulla raggruppamento",
|
|
363
|
+
MsgSelectAll: "Seleziona tutte le righe",
|
|
364
|
+
MsgSelectRow: "Seleziona riga {{index}}",
|
|
365
|
+
MsgExportCsv: "Esporta CSV",
|
|
366
|
+
MsgExportExcel: "Esporta Excel",
|
|
367
|
+
MsgExportPdf: "Esporta PDF",
|
|
368
|
+
MsgPrint: "Stampa",
|
|
369
|
+
MsgToggleColumns: "Colonne",
|
|
370
|
+
MsgToggleColumn: "Mostra/nascondi {{column}}",
|
|
371
|
+
MsgEditCell: "Modifica {{column}}",
|
|
372
|
+
MsgEditRow: "Modifica",
|
|
373
|
+
MsgSaveRow: "Salva",
|
|
374
|
+
MsgCancelRowEdit: "Annulla",
|
|
375
|
+
MsgDeleteRow: "Elimina",
|
|
376
|
+
MsgAddRow: "Aggiungi riga",
|
|
377
|
+
MsgLoading: "Caricamento…",
|
|
378
|
+
MsgDragRow: "Trascina per riordinare la riga",
|
|
379
|
+
MsgAutosizeColumn: "Doppio clic per adattare la colonna al contenuto",
|
|
380
|
+
MsgExpandDetail: "Espandi dettagli riga",
|
|
381
|
+
MsgCollapseDetail: "Comprimi dettagli riga",
|
|
382
|
+
MsgDeleteSelected: "Elimina selezionati ({{count}})",
|
|
383
|
+
MsgValidationRequired: "Questo campo è obbligatorio",
|
|
384
|
+
MsgValidationMin: "Deve essere almeno {{min}}",
|
|
385
|
+
MsgValidationMax: "Deve essere al massimo {{max}}",
|
|
386
|
+
MsgValidationPattern: "Formato non valido"
|
|
387
|
+
}, L = {
|
|
388
|
+
MsgNoData: "暂无数据",
|
|
389
|
+
MsgFirstPage: "首页",
|
|
390
|
+
MsgPreviousPage: "上一页",
|
|
391
|
+
MsgNextPage: "下一页",
|
|
392
|
+
MsgLastPage: "末页",
|
|
393
|
+
MsgSortBy: "按{{column}}排序",
|
|
394
|
+
MsgPageOf: "第 {{page}} 页,共 {{total}} 页",
|
|
395
|
+
MsgFilterPlaceholder: "搜索",
|
|
396
|
+
MsgFilterColumn: "筛选{{column}}",
|
|
397
|
+
MsgFilterMin: "最小",
|
|
398
|
+
MsgFilterMax: "最大",
|
|
399
|
+
MsgFilterFrom: "从",
|
|
400
|
+
MsgFilterTo: "到",
|
|
401
|
+
MsgAll: "全部",
|
|
402
|
+
MsgCancelFilter: "取消筛选",
|
|
403
|
+
MsgCancelAllFilters: "清除所有筛选",
|
|
404
|
+
MsgGroupByHint: "将列标题拖到此处以按其分组",
|
|
405
|
+
MsgGroupedBy: "按{{column}}分组",
|
|
406
|
+
MsgGroupHeader: "{{column}}: {{value}} ({{count}})",
|
|
407
|
+
MsgCancelGrouping: "取消分组",
|
|
408
|
+
MsgSelectAll: "选择所有行",
|
|
409
|
+
MsgSelectRow: "选择第 {{index}} 行",
|
|
410
|
+
MsgExportCsv: "导出 CSV",
|
|
411
|
+
MsgExportExcel: "导出 Excel",
|
|
412
|
+
MsgExportPdf: "导出 PDF",
|
|
413
|
+
MsgPrint: "打印",
|
|
414
|
+
MsgToggleColumns: "列",
|
|
415
|
+
MsgToggleColumn: "显示/隐藏{{column}}",
|
|
416
|
+
MsgEditCell: "编辑{{column}}",
|
|
417
|
+
MsgEditRow: "编辑",
|
|
418
|
+
MsgSaveRow: "保存",
|
|
419
|
+
MsgCancelRowEdit: "取消",
|
|
420
|
+
MsgDeleteRow: "删除",
|
|
421
|
+
MsgAddRow: "添加行",
|
|
422
|
+
MsgLoading: "加载中…",
|
|
423
|
+
MsgDragRow: "拖动以重新排序行",
|
|
424
|
+
MsgAutosizeColumn: "双击以使列适应内容",
|
|
425
|
+
MsgExpandDetail: "展开行详情",
|
|
426
|
+
MsgCollapseDetail: "收起行详情",
|
|
427
|
+
MsgDeleteSelected: "删除所选 ({{count}})",
|
|
428
|
+
MsgValidationRequired: "此字段为必填项",
|
|
429
|
+
MsgValidationMin: "不得小于 {{min}}",
|
|
430
|
+
MsgValidationMax: "不得大于 {{max}}",
|
|
431
|
+
MsgValidationPattern: "格式无效"
|
|
432
|
+
}, R = {
|
|
433
|
+
en: P,
|
|
434
|
+
es: F,
|
|
435
|
+
fr: I,
|
|
436
|
+
it: ce,
|
|
437
|
+
zh: L
|
|
438
|
+
};
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/utils/translate.ts
|
|
441
|
+
function le(e, t) {
|
|
442
|
+
return t ? e.replace(/\{\{(\w+)\}\}/g, (e, n) => n in t ? String(t[n]) : e) : e;
|
|
443
|
+
}
|
|
444
|
+
function ue(e) {
|
|
445
|
+
let t = R[e.split("-")[0]] ?? P;
|
|
446
|
+
return (e, n) => le(t[e] ?? P[e], n);
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/composables/useInanduGrid.ts
|
|
450
|
+
function de(e) {
|
|
451
|
+
return {
|
|
452
|
+
field: () => e.field,
|
|
453
|
+
type: () => e.type ?? "string",
|
|
454
|
+
format: () => e.format ?? "",
|
|
455
|
+
order: () => e.order,
|
|
456
|
+
aggregate: () => e.aggregate ?? ""
|
|
457
|
+
};
|
|
458
|
+
}
|
|
459
|
+
function fe(e) {
|
|
460
|
+
let n = (n) => t(() => _(e)[n]), r = n("rows"), i = n("columns"), a = t(() => _(e).locale ?? "en"), o = n("lang"), s = t(() => _(e).pageSize ?? 0), c = t(() => _(e).selectable ?? !1), l = n("treeChildrenKey"), u = t(() => _(e).treeDefaultExpanded ?? "none"), d = t(() => _(e).virtualScroll ?? !1), f = n("extraRowFilter"), p = n("serverSide"), m = t(() => !!p.value), g = () => _(e), v = h([]), y = h({}), b = h(""), x = h(0), te = h(void 0), C = t(() => m.value ? void 0 : te.value), w = h(/* @__PURE__ */ new Set()), O = h(void 0), k = h(!1), A = h({}), j = h({}), M = h(!1), N = h(/* @__PURE__ */ new Set()), P = h(void 0), F = h(void 0), I = h({}), ce = h({}), L = h(void 0), R = h(/* @__PURE__ */ new Set()), le = h(/* @__PURE__ */ new Set()), fe, pe = t(() => ue(o.value ?? a.value)), z = t(() => {
|
|
461
|
+
let e = P.value;
|
|
462
|
+
if (!e) return i.value;
|
|
463
|
+
let t = new Map(i.value.map((e) => [e.field, e])), n = [];
|
|
464
|
+
for (let r of e) {
|
|
465
|
+
let e = t.get(r);
|
|
466
|
+
e && (n.push(e), t.delete(r));
|
|
467
|
+
}
|
|
468
|
+
return n.push(...t.values()), n;
|
|
469
|
+
}), B = t(() => N.value.size === 0 ? z.value : z.value.filter((e) => !N.value.has(e.field))), me = t(() => z.value.filter((e) => e.hideable !== !1));
|
|
470
|
+
function he(e) {
|
|
471
|
+
let t = z.value.map((e) => e.field), n = new Set(t), r = e.filter((e) => n.has(e)), i = new Set(r), a = t.filter((e) => !i.has(e));
|
|
472
|
+
P.value = [...r, ...a];
|
|
473
|
+
}
|
|
474
|
+
function ge(e) {
|
|
475
|
+
F.value = e;
|
|
476
|
+
}
|
|
477
|
+
function _e(e) {
|
|
478
|
+
let t = F.value;
|
|
479
|
+
if (F.value = void 0, !t || t === e) return;
|
|
480
|
+
let n = z.value.find((e) => e.field === t);
|
|
481
|
+
if (!n || n.reorder === !1) return;
|
|
482
|
+
let r = z.value.map((e) => e.field), i = r.indexOf(t), a = r.indexOf(e);
|
|
483
|
+
i !== -1 && a !== -1 && (r.splice(i, 1), i < a && a--, r.splice(a, 0, t), he(r));
|
|
484
|
+
}
|
|
485
|
+
function ve(e) {
|
|
486
|
+
return N.value.has(e);
|
|
487
|
+
}
|
|
488
|
+
function ye(e) {
|
|
489
|
+
if (N.value.has(e)) {
|
|
490
|
+
let t = new Set(N.value);
|
|
491
|
+
t.delete(e), N.value = t;
|
|
492
|
+
} else B.value.length <= 1 || (N.value = new Set(N.value).add(e));
|
|
493
|
+
}
|
|
494
|
+
let V = t(() => B.value.filter((e) => e.editable));
|
|
495
|
+
function H(e) {
|
|
496
|
+
x.value = 0, b.value = e;
|
|
497
|
+
}
|
|
498
|
+
let U = t(() => new Map(B.value.map((e) => [e.field, de(e)]))), be = t(() => B.value.filter((e) => e.aggregate).map((e) => U.value.get(e.field)));
|
|
499
|
+
function xe(e, t) {
|
|
500
|
+
x.value = 0, y.value = {
|
|
501
|
+
...y.value,
|
|
502
|
+
[e]: t
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function W() {
|
|
506
|
+
x.value = 0, y.value = {};
|
|
507
|
+
}
|
|
508
|
+
function G(e, t) {
|
|
509
|
+
return B.value.some((n) => {
|
|
510
|
+
let r = U.value.get(n.field);
|
|
511
|
+
return T(e[n.field], r.type(), r.format(), a.value).toLowerCase().includes(t);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
function K(e, t) {
|
|
515
|
+
return t.every(([t, n]) => {
|
|
516
|
+
let r = U.value.get(t);
|
|
517
|
+
return !r || ie(r, e, n, a.value);
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
function Se(e, t) {
|
|
521
|
+
for (let { field: n, direction: r } of v.value) {
|
|
522
|
+
let i = E(e[n], t[n], a.value) * (r === "asc" ? 1 : -1);
|
|
523
|
+
if (i !== 0) return i;
|
|
524
|
+
}
|
|
525
|
+
return 0;
|
|
526
|
+
}
|
|
527
|
+
let q = t(() => {
|
|
528
|
+
let e = r.value;
|
|
529
|
+
if (m.value) return e;
|
|
530
|
+
let t = b.value.trim().toLowerCase();
|
|
531
|
+
t && (e = e.filter((e) => G(e, t)));
|
|
532
|
+
let n = Object.entries(y.value).filter(([, e]) => re(e));
|
|
533
|
+
n.length > 0 && (e = e.filter((e) => K(e, n)));
|
|
534
|
+
let i = f.value;
|
|
535
|
+
return i && (e = e.filter(i)), v.value.length > 0 && (e = [...e].sort(Se)), e;
|
|
536
|
+
}), Ce = t(() => {
|
|
537
|
+
let e = C.value;
|
|
538
|
+
if (!e) return null;
|
|
539
|
+
let t = U.value.get(e);
|
|
540
|
+
if (!t) return null;
|
|
541
|
+
let n = /* @__PURE__ */ new Map();
|
|
542
|
+
for (let r of q.value) {
|
|
543
|
+
let i = T(r[e], t.type(), t.format(), a.value), o = n.get(i);
|
|
544
|
+
o ? o.push(r) : n.set(i, [r]);
|
|
545
|
+
}
|
|
546
|
+
return Array.from(n.entries()).map(([e, t]) => ({
|
|
547
|
+
key: e,
|
|
548
|
+
rows: t,
|
|
549
|
+
aggregates: ae(t, be.value)
|
|
550
|
+
}));
|
|
551
|
+
}), we = t(() => ae(q.value, be.value)), J = t(() => !!l.value && !C.value && !d.value && !m.value);
|
|
552
|
+
function Y(e) {
|
|
553
|
+
let t = l.value, n = t ? e[t] : void 0;
|
|
554
|
+
return Array.isArray(n) ? n : void 0;
|
|
555
|
+
}
|
|
556
|
+
let X = t(() => {
|
|
557
|
+
if (!J.value) return [];
|
|
558
|
+
let e = b.value.trim().toLowerCase(), t = Object.entries(y.value).filter(([, e]) => re(e)), n = f.value, i = e || t.length > 0 || n ? (r) => e && !G(r, e) || !K(r, t) ? !1 : !n || n(r) : void 0, a = v.value.length > 0 ? Se : void 0, o = R.value;
|
|
559
|
+
return D(r.value, {
|
|
560
|
+
getChildren: Y,
|
|
561
|
+
isExpanded: (e) => o.has(e),
|
|
562
|
+
match: i,
|
|
563
|
+
compare: a
|
|
564
|
+
});
|
|
565
|
+
});
|
|
566
|
+
ee([
|
|
567
|
+
J,
|
|
568
|
+
r,
|
|
569
|
+
u
|
|
570
|
+
], () => {
|
|
571
|
+
if (!J.value || fe === r.value) return;
|
|
572
|
+
fe = r.value;
|
|
573
|
+
let e = u.value;
|
|
574
|
+
if (e === "none") {
|
|
575
|
+
R.value = /* @__PURE__ */ new Set();
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
let t = /* @__PURE__ */ new Set();
|
|
579
|
+
if (e === "all") for (let e of ne(r.value, Y)) Y(e)?.length && t.add(e);
|
|
580
|
+
else {
|
|
581
|
+
let n = (r, i) => {
|
|
582
|
+
if (!(i >= e)) for (let e of r) {
|
|
583
|
+
let r = Y(e);
|
|
584
|
+
r?.length && (t.add(e), n(r, i + 1));
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
n(r.value, 0);
|
|
588
|
+
}
|
|
589
|
+
R.value = t;
|
|
590
|
+
}, {
|
|
591
|
+
immediate: !0,
|
|
592
|
+
flush: "sync"
|
|
593
|
+
});
|
|
594
|
+
function Te(e) {
|
|
595
|
+
return R.value.has(e);
|
|
596
|
+
}
|
|
597
|
+
function Ee(e) {
|
|
598
|
+
let t = new Set(R.value);
|
|
599
|
+
t.has(e) ? t.delete(e) : t.add(e), R.value = t;
|
|
600
|
+
}
|
|
601
|
+
function De(e) {
|
|
602
|
+
if (!e) {
|
|
603
|
+
R.value = /* @__PURE__ */ new Set();
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
let t = /* @__PURE__ */ new Set();
|
|
607
|
+
for (let e of ne(r.value, Y)) Y(e)?.length && t.add(e);
|
|
608
|
+
R.value = t;
|
|
609
|
+
}
|
|
610
|
+
let Oe = t(() => d.value && !C.value && !m.value), Z = t(() => s.value > 0 && !C.value && !J.value && !Oe.value), ke = t(() => p.value ? p.value.totalItems : q.value.length), Ae = t(() => Z.value ? Math.max(1, Math.ceil(ke.value / s.value)) : 1), je = t(() => m.value ? x.value : Math.min(x.value, Ae.value - 1)), Q = t(() => {
|
|
611
|
+
if (J.value) return X.value.map((e) => e.row);
|
|
612
|
+
if (!Z.value || m.value) return q.value;
|
|
613
|
+
let e = je.value * s.value;
|
|
614
|
+
return q.value.slice(e, e + s.value);
|
|
615
|
+
});
|
|
616
|
+
ee([
|
|
617
|
+
m,
|
|
618
|
+
je,
|
|
619
|
+
s,
|
|
620
|
+
v,
|
|
621
|
+
y,
|
|
622
|
+
b
|
|
623
|
+
], () => {
|
|
624
|
+
m.value && g().onQueryChange?.({
|
|
625
|
+
page: je.value,
|
|
626
|
+
pageSize: s.value,
|
|
627
|
+
sortCriteria: v.value,
|
|
628
|
+
filterValues: y.value,
|
|
629
|
+
filterQuery: b.value
|
|
630
|
+
});
|
|
631
|
+
}, { immediate: !0 });
|
|
632
|
+
let $ = t(() => C.value ? q.value : Q.value);
|
|
633
|
+
function Me(e) {
|
|
634
|
+
return w.value.has(e);
|
|
635
|
+
}
|
|
636
|
+
function Ne(e) {
|
|
637
|
+
let t = new Set(w.value);
|
|
638
|
+
t.has(e) ? t.delete(e) : t.add(e), w.value = t;
|
|
639
|
+
}
|
|
640
|
+
let Pe = t(() => $.value.length > 0 && $.value.every((e) => w.value.has(e))), Fe = t(() => !Pe.value && $.value.some((e) => w.value.has(e)));
|
|
641
|
+
function Ie() {
|
|
642
|
+
let e = !Pe.value, t = new Set(w.value);
|
|
643
|
+
for (let n of $.value) e ? t.add(n) : t.delete(n);
|
|
644
|
+
w.value = t;
|
|
645
|
+
}
|
|
646
|
+
function Le() {
|
|
647
|
+
w.value = /* @__PURE__ */ new Set();
|
|
648
|
+
}
|
|
649
|
+
function Re(e, t = !1) {
|
|
650
|
+
x.value = 0;
|
|
651
|
+
let n = v.value, r = n.findIndex((t) => t.field === e);
|
|
652
|
+
if (t) {
|
|
653
|
+
if (r === -1) {
|
|
654
|
+
v.value = [...n, {
|
|
655
|
+
field: e,
|
|
656
|
+
direction: "asc"
|
|
657
|
+
}];
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
let t = [...n];
|
|
661
|
+
t[r] = {
|
|
662
|
+
field: e,
|
|
663
|
+
direction: n[r].direction === "asc" ? "desc" : "asc"
|
|
664
|
+
}, v.value = t;
|
|
665
|
+
} else n.length === 1 && n[0].field === e ? v.value = [{
|
|
666
|
+
field: e,
|
|
667
|
+
direction: n[0].direction === "asc" ? "desc" : "asc"
|
|
668
|
+
}] : v.value = [{
|
|
669
|
+
field: e,
|
|
670
|
+
direction: "asc"
|
|
671
|
+
}];
|
|
672
|
+
}
|
|
673
|
+
function ze(e) {
|
|
674
|
+
v.value = e;
|
|
675
|
+
}
|
|
676
|
+
function Be(e) {
|
|
677
|
+
return v.value.find((t) => t.field === e)?.direction;
|
|
678
|
+
}
|
|
679
|
+
function Ve(e) {
|
|
680
|
+
if (v.value.length < 2) return;
|
|
681
|
+
let t = v.value.findIndex((t) => t.field === e);
|
|
682
|
+
return t === -1 ? void 0 : t + 1;
|
|
683
|
+
}
|
|
684
|
+
function He(e) {
|
|
685
|
+
return O.value === e;
|
|
686
|
+
}
|
|
687
|
+
function Ue(e) {
|
|
688
|
+
return k.value ? !0 : O.value !== void 0 && O.value !== e;
|
|
689
|
+
}
|
|
690
|
+
function We(e, t) {
|
|
691
|
+
let n = t.type ?? "string";
|
|
692
|
+
if (n === "boolean") return !!e[t.field];
|
|
693
|
+
if (n === "date") {
|
|
694
|
+
let n = S(e[t.field]);
|
|
695
|
+
if (Number.isNaN(n.getTime())) return "";
|
|
696
|
+
let r = (e) => String(e).padStart(2, "0");
|
|
697
|
+
return `${n.getFullYear()}-${r(n.getMonth() + 1)}-${r(n.getDate())}`;
|
|
698
|
+
}
|
|
699
|
+
let r = e[t.field];
|
|
700
|
+
return r == null ? "" : String(r);
|
|
701
|
+
}
|
|
702
|
+
function Ge(e) {
|
|
703
|
+
let t = {};
|
|
704
|
+
for (let n of V.value) t[n.field] = We(e, n);
|
|
705
|
+
O.value = e, A.value = t, j.value = {};
|
|
706
|
+
}
|
|
707
|
+
function Ke() {
|
|
708
|
+
O.value = void 0, A.value = {}, j.value = {};
|
|
709
|
+
}
|
|
710
|
+
function qe(e, t) {
|
|
711
|
+
A.value = {
|
|
712
|
+
...A.value,
|
|
713
|
+
[e]: t
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
function Je(e, t, n, r) {
|
|
717
|
+
let i = pe.value;
|
|
718
|
+
if (e.required && (t === "" || t == null)) return i("MsgValidationRequired");
|
|
719
|
+
if ((e.type ?? "string") === "number" && typeof n == "number") {
|
|
720
|
+
if (e.min !== void 0 && n < e.min) return i("MsgValidationMin", { min: e.min });
|
|
721
|
+
if (e.max !== void 0 && n > e.max) return i("MsgValidationMax", { max: e.max });
|
|
722
|
+
}
|
|
723
|
+
if (e.pattern && typeof t == "string" && t !== "") {
|
|
724
|
+
let n;
|
|
725
|
+
try {
|
|
726
|
+
n = new RegExp(e.pattern);
|
|
727
|
+
} catch {
|
|
728
|
+
n = void 0;
|
|
729
|
+
}
|
|
730
|
+
if (n && !n.test(t)) return i("MsgValidationPattern");
|
|
731
|
+
}
|
|
732
|
+
return e.validator ? e.validator(n, r) : null;
|
|
733
|
+
}
|
|
734
|
+
function Ye(e, t, n = {}) {
|
|
735
|
+
return Je(e, t, t, n);
|
|
736
|
+
}
|
|
737
|
+
async function Xe(e) {
|
|
738
|
+
let t = V.value, n = {};
|
|
739
|
+
for (let r of t) n[r.field] = oe(e[r.field], r.type ?? "string");
|
|
740
|
+
let r = {}, i = {}, a = [];
|
|
741
|
+
for (let o of t) {
|
|
742
|
+
let t = o.field, s = Je(o, e[t], n[t], n);
|
|
743
|
+
s ? r[t] = s : o.asyncValidator ? a.push(o.asyncValidator(n[t], n).then((e) => {
|
|
744
|
+
e ? r[t] = e : n[t] !== void 0 && (i[t] = n[t]);
|
|
745
|
+
})) : n[t] !== void 0 && (i[t] = n[t]);
|
|
746
|
+
}
|
|
747
|
+
if (a.length > 0) {
|
|
748
|
+
M.value = !0;
|
|
749
|
+
try {
|
|
750
|
+
await Promise.all(a);
|
|
751
|
+
} finally {
|
|
752
|
+
M.value = !1;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return {
|
|
756
|
+
errors: r,
|
|
757
|
+
values: i
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
async function Ze(e) {
|
|
761
|
+
if (O.value !== e) return;
|
|
762
|
+
let { errors: t, values: n } = await Xe(A.value);
|
|
763
|
+
O.value === e && (Object.keys(t).length > 0 ? j.value = t : (O.value = void 0, A.value = {}, j.value = {}, g().onRowSave?.({
|
|
764
|
+
row: e,
|
|
765
|
+
values: n
|
|
766
|
+
})));
|
|
767
|
+
}
|
|
768
|
+
function Qe(e) {
|
|
769
|
+
let t = g().deleteConfirmMessage;
|
|
770
|
+
(!t || window.confirm(t)) && g().onRowDelete?.(e);
|
|
771
|
+
}
|
|
772
|
+
function $e() {
|
|
773
|
+
let e = g().bulkDeleteConfirmMessage;
|
|
774
|
+
if (e && !window.confirm(e)) return;
|
|
775
|
+
let t = Array.from(w.value);
|
|
776
|
+
Le(), g().onRowsDelete?.(t);
|
|
777
|
+
}
|
|
778
|
+
function et() {
|
|
779
|
+
k.value = !0, A.value = {}, j.value = {};
|
|
780
|
+
}
|
|
781
|
+
function tt() {
|
|
782
|
+
k.value = !1, A.value = {}, j.value = {};
|
|
783
|
+
}
|
|
784
|
+
async function nt() {
|
|
785
|
+
if (!k.value) return;
|
|
786
|
+
let { errors: e, values: t } = await Xe(A.value);
|
|
787
|
+
k.value && (Object.keys(e).length > 0 ? j.value = e : (k.value = !1, A.value = {}, j.value = {}, g().onRowCreate?.(t)));
|
|
788
|
+
}
|
|
789
|
+
function rt(e, t) {
|
|
790
|
+
let n = Q.value[e], r = U.value.get(t);
|
|
791
|
+
return !n || !r ? "" : T(n[t], r.type(), r.format(), a.value);
|
|
792
|
+
}
|
|
793
|
+
function it(e, t, n) {
|
|
794
|
+
let r = B.value, i = Q.value, a = r.findIndex((e) => e.field === t);
|
|
795
|
+
if (e === -1 || a === -1) return;
|
|
796
|
+
let o = [];
|
|
797
|
+
n.replace(/\r\n$|\r$|\n$/, "").split(/\r\n|\r|\n/).map((e) => e.split(" ")).forEach((t, n) => {
|
|
798
|
+
let s = i[e + n];
|
|
799
|
+
s && t.forEach((e, t) => {
|
|
800
|
+
let n = r[a + t];
|
|
801
|
+
n && n.editable && o.push({
|
|
802
|
+
row: s,
|
|
803
|
+
field: n.field,
|
|
804
|
+
value: se(e, n.type ?? "string")
|
|
805
|
+
});
|
|
806
|
+
});
|
|
807
|
+
}), o.length > 0 && g().onCellsPaste?.(o);
|
|
808
|
+
}
|
|
809
|
+
function at(e) {
|
|
810
|
+
let t = I.value[e];
|
|
811
|
+
return t === void 0 ? z.value.find((t) => t.field === e)?.width ?? 80 : t;
|
|
812
|
+
}
|
|
813
|
+
function ot(e) {
|
|
814
|
+
return I.value[e] !== void 0;
|
|
815
|
+
}
|
|
816
|
+
function st(e, t) {
|
|
817
|
+
z.value.some((t) => t.field === e) && (I.value = {
|
|
818
|
+
...I.value,
|
|
819
|
+
[e]: Math.max(30, t)
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
function ct(e) {
|
|
823
|
+
L.value = e;
|
|
824
|
+
}
|
|
825
|
+
function lt(e) {
|
|
826
|
+
return le.value.has(e);
|
|
827
|
+
}
|
|
828
|
+
function ut(e) {
|
|
829
|
+
let t = le.value, n = g().singleDetailExpand ? /* @__PURE__ */ new Set() : new Set(t);
|
|
830
|
+
t.has(e) ? n.delete(e) : n.add(e), le.value = n;
|
|
831
|
+
}
|
|
832
|
+
function dt(e) {
|
|
833
|
+
let t = L.value;
|
|
834
|
+
if (L.value = void 0, !t || t === e) return;
|
|
835
|
+
let n = [...q.value], r = n.indexOf(t), i = n.indexOf(e);
|
|
836
|
+
r !== -1 && i !== -1 && (n.splice(r, 1), r < i && i--, n.splice(i, 0, t), g().onRowOrderChange?.(n));
|
|
837
|
+
}
|
|
838
|
+
function ft(e) {
|
|
839
|
+
let t = ce.value[e];
|
|
840
|
+
if (t === "left" || t === "right") return t;
|
|
841
|
+
if (t !== "none") return z.value.find((t) => t.field === e)?.pinned;
|
|
842
|
+
}
|
|
843
|
+
function pt(e, t) {
|
|
844
|
+
ce.value = {
|
|
845
|
+
...ce.value,
|
|
846
|
+
[e]: t ?? "none"
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
function mt(e) {
|
|
850
|
+
let t = c.value ? 36 : 0;
|
|
851
|
+
for (let n of B.value) {
|
|
852
|
+
if (n.field === e) break;
|
|
853
|
+
ft(n.field) === "left" && (t += at(n.field));
|
|
854
|
+
}
|
|
855
|
+
return t;
|
|
856
|
+
}
|
|
857
|
+
function ht(e) {
|
|
858
|
+
let t = 0, n = !1;
|
|
859
|
+
for (let r of B.value) r.field === e ? n = !0 : n && ft(r.field) === "right" && (t += at(r.field));
|
|
860
|
+
return t;
|
|
861
|
+
}
|
|
862
|
+
function gt(e) {
|
|
863
|
+
x.value = e;
|
|
864
|
+
}
|
|
865
|
+
function _t(e) {
|
|
866
|
+
te.value = e;
|
|
867
|
+
}
|
|
868
|
+
return {
|
|
869
|
+
get visibleColumns() {
|
|
870
|
+
return B.value;
|
|
871
|
+
},
|
|
872
|
+
get allColumns() {
|
|
873
|
+
return z.value;
|
|
874
|
+
},
|
|
875
|
+
stickyOffset: mt,
|
|
876
|
+
stickyOffsetRight: ht,
|
|
877
|
+
columnPinnedSide: ft,
|
|
878
|
+
setColumnPinned: pt,
|
|
879
|
+
get hideableColumns() {
|
|
880
|
+
return me.value;
|
|
881
|
+
},
|
|
882
|
+
isColumnHidden: ve,
|
|
883
|
+
toggleColumnVisibility: ye,
|
|
884
|
+
setColumnOrder: he,
|
|
885
|
+
get draggingField() {
|
|
886
|
+
return F.value;
|
|
887
|
+
},
|
|
888
|
+
onColumnDragStart: ge,
|
|
889
|
+
onColumnDrop: _e,
|
|
890
|
+
effectiveWidth: at,
|
|
891
|
+
isColumnResized: ot,
|
|
892
|
+
setColumnWidth: st,
|
|
893
|
+
get draggingRow() {
|
|
894
|
+
return L.value;
|
|
895
|
+
},
|
|
896
|
+
onRowDragStart: ct,
|
|
897
|
+
onRowDrop: dt,
|
|
898
|
+
get hasTreeData() {
|
|
899
|
+
return J.value;
|
|
900
|
+
},
|
|
901
|
+
get treeRows() {
|
|
902
|
+
return X.value;
|
|
903
|
+
},
|
|
904
|
+
isTreeRowExpanded: Te,
|
|
905
|
+
toggleTreeRow: Ee,
|
|
906
|
+
setAllTreeRowsExpanded: De,
|
|
907
|
+
isRowExpanded: lt,
|
|
908
|
+
toggleRowExpanded: ut,
|
|
909
|
+
get hasVirtualScroll() {
|
|
910
|
+
return Oe.value;
|
|
911
|
+
},
|
|
912
|
+
get visibleRows() {
|
|
913
|
+
return Q.value;
|
|
914
|
+
},
|
|
915
|
+
get exportRows() {
|
|
916
|
+
return $.value;
|
|
917
|
+
},
|
|
918
|
+
get sortedRows() {
|
|
919
|
+
return q.value;
|
|
920
|
+
},
|
|
921
|
+
get filteredRowCount() {
|
|
922
|
+
return ke.value;
|
|
923
|
+
},
|
|
924
|
+
get locale() {
|
|
925
|
+
return a.value;
|
|
926
|
+
},
|
|
927
|
+
get sortCriteria() {
|
|
928
|
+
return v.value;
|
|
929
|
+
},
|
|
930
|
+
setSort: ze,
|
|
931
|
+
toggleSort: Re,
|
|
932
|
+
sortDirectionFor: Be,
|
|
933
|
+
sortPriorityFor: Ve,
|
|
934
|
+
get filterValues() {
|
|
935
|
+
return y.value;
|
|
936
|
+
},
|
|
937
|
+
setFilterValue: xe,
|
|
938
|
+
clearAllFilters: W,
|
|
939
|
+
get filterQuery() {
|
|
940
|
+
return b.value;
|
|
941
|
+
},
|
|
942
|
+
setFilterQuery: H,
|
|
943
|
+
get page() {
|
|
944
|
+
return je.value;
|
|
945
|
+
},
|
|
946
|
+
setPage: gt,
|
|
947
|
+
get pageCount() {
|
|
948
|
+
return Z.value ? Ae.value : 1;
|
|
949
|
+
},
|
|
950
|
+
get groupByField() {
|
|
951
|
+
return C.value;
|
|
952
|
+
},
|
|
953
|
+
setGroupByField: _t,
|
|
954
|
+
get groups() {
|
|
955
|
+
return Ce.value;
|
|
956
|
+
},
|
|
957
|
+
get totals() {
|
|
958
|
+
return we.value;
|
|
959
|
+
},
|
|
960
|
+
get selectedRows() {
|
|
961
|
+
return w.value;
|
|
962
|
+
},
|
|
963
|
+
isRowSelected: Me,
|
|
964
|
+
toggleRowSelection: Ne,
|
|
965
|
+
get allSelected() {
|
|
966
|
+
return Pe.value;
|
|
967
|
+
},
|
|
968
|
+
get someSelected() {
|
|
969
|
+
return Fe.value;
|
|
970
|
+
},
|
|
971
|
+
toggleSelectAll: Ie,
|
|
972
|
+
clearSelection: Le,
|
|
973
|
+
get editableColumns() {
|
|
974
|
+
return V.value;
|
|
975
|
+
},
|
|
976
|
+
get editingRow() {
|
|
977
|
+
return O.value;
|
|
978
|
+
},
|
|
979
|
+
get isAddingRow() {
|
|
980
|
+
return k.value;
|
|
981
|
+
},
|
|
982
|
+
get rowDraft() {
|
|
983
|
+
return A.value;
|
|
984
|
+
},
|
|
985
|
+
get fieldErrors() {
|
|
986
|
+
return j.value;
|
|
987
|
+
},
|
|
988
|
+
get isValidating() {
|
|
989
|
+
return M.value;
|
|
990
|
+
},
|
|
991
|
+
isEditingRow: He,
|
|
992
|
+
isAnotherRowEditing: Ue,
|
|
993
|
+
startEditingRow: Ge,
|
|
994
|
+
cancelRowEdit: Ke,
|
|
995
|
+
setRowDraftValue: qe,
|
|
996
|
+
saveRow: Ze,
|
|
997
|
+
deleteRow: Qe,
|
|
998
|
+
deleteSelectedRows: $e,
|
|
999
|
+
startAddingRow: et,
|
|
1000
|
+
cancelAddRow: tt,
|
|
1001
|
+
saveNewRow: nt,
|
|
1002
|
+
validateCell: Ye,
|
|
1003
|
+
copyCellText: rt,
|
|
1004
|
+
pasteAt: it
|
|
1005
|
+
};
|
|
1006
|
+
}
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/utils/exporters.ts
|
|
1009
|
+
function pe(e) {
|
|
1010
|
+
return e.headerText || e.field;
|
|
1011
|
+
}
|
|
1012
|
+
function z(e, t, n) {
|
|
1013
|
+
return T(t[e.field], e.type ?? "string", e.format ?? "", n);
|
|
1014
|
+
}
|
|
1015
|
+
function B(e, t, n) {
|
|
1016
|
+
return "" + [t.map((e) => A(pe(e))).join(","), ...e.map((e) => t.map((t) => A(z(t, e, n))).join(","))].join("\r\n");
|
|
1017
|
+
}
|
|
1018
|
+
function me(e, t, n, r = "inandu-grid") {
|
|
1019
|
+
N(B(e, t, n), `${r}-export.csv`, "text/csv;charset=utf-8;");
|
|
1020
|
+
}
|
|
1021
|
+
function he(e, t, n) {
|
|
1022
|
+
let r = (e, t) => {
|
|
1023
|
+
let n = t[e.field];
|
|
1024
|
+
return e.type === "number" && typeof n == "number" && Number.isFinite(n) ? n : void 0;
|
|
1025
|
+
}, i = (e, t) => {
|
|
1026
|
+
let i = r(e, t);
|
|
1027
|
+
return i === void 0 ? `<Cell><Data ss:Type="String">${j(z(e, t, n))}</Data></Cell>` : `<Cell><Data ss:Type="Number">${i}</Data></Cell>`;
|
|
1028
|
+
}, a = `<Row ss:StyleID="header">${t.map((e) => `<Cell><Data ss:Type="String">${j(pe(e))}</Data></Cell>`).join("")}</Row>`, o = e.map((e) => `<Row>${t.map((t) => i(t, e)).join("")}</Row>`).join("");
|
|
1029
|
+
return "<?xml version=\"1.0\"?><?mso-application progid=\"Excel.Sheet\"?><Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"><Styles><Style ss:ID=\"header\"><Font ss:Bold=\"1\"/></Style></Styles><Worksheet ss:Name=\"Sheet1\"><Table>" + a + o + "</Table></Worksheet></Workbook>";
|
|
1030
|
+
}
|
|
1031
|
+
function ge(e, t, n, r = "inandu-grid") {
|
|
1032
|
+
N(he(e, t, n), `${r}-export.xls`, "application/vnd.ms-excel");
|
|
1033
|
+
}
|
|
1034
|
+
function _e(e, t, n, r = "inandu-grid") {
|
|
1035
|
+
let i = t.map((e) => `<th>${j(pe(e))}</th>`).join(""), a = e.map((e) => `<tr>${t.map((t) => `<td>${j(z(t, e, n))}</td>`).join("")}</tr>`).join(""), o = `<!doctype html><html><head><meta charset="utf-8"><title>${j(r)}</title><style>table{border-collapse:collapse;width:100%}th,td{border:1px solid #333;padding:4px 8px;text-align:left}th{background:#eee}</style></head><body><table><thead><tr>${i}</tr></thead><tbody>${a}</tbody></table></body></html>`, s = window.open("", "_blank");
|
|
1036
|
+
s && (s.document.write(o), s.document.close(), s.focus(), setTimeout(() => s.print(), 0));
|
|
1037
|
+
}
|
|
1038
|
+
async function ve(e, t, n, r = "inandu-grid") {
|
|
1039
|
+
let { jsPDF: i } = await import("jspdf"), a = t.map(pe), o = new i({ orientation: "landscape" }), s = o.internal.pageSize.getWidth() - 20, c = o.internal.pageSize.getHeight() - 10, l = s / (t.length || 1), u = 10, d = (e, t) => {
|
|
1040
|
+
o.setFont("helvetica", t ? "bold" : "normal");
|
|
1041
|
+
let n = 10;
|
|
1042
|
+
e.forEach((e) => {
|
|
1043
|
+
o.text(M(o, e, l - 4), n + 2, u + 6), n += l;
|
|
1044
|
+
}), u += 8;
|
|
1045
|
+
};
|
|
1046
|
+
d(a, !0);
|
|
1047
|
+
for (let r of e) u + 8 > c && (o.addPage(), u = 10, d(a, !0)), d(t.map((e) => z(e, r, n)), !1);
|
|
1048
|
+
N(o.output("blob"), `${r}-export.pdf`);
|
|
1049
|
+
}
|
|
1050
|
+
//#endregion
|
|
1051
|
+
//#region src/utils/measureColumn.ts
|
|
1052
|
+
function ye(e, t, n) {
|
|
1053
|
+
let r = typeof CSS < "u" && CSS.escape ? CSS.escape(t) : k(t), i = Array.from(e.querySelectorAll(`td[data-field="${r}"]`)), a = e.querySelector(`th[data-field="${r}"]`), o = i[0] ?? a ?? e, s = getComputedStyle(o), c = document.createElement("span");
|
|
1054
|
+
c.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden;white-space:pre;pointer-events:none", c.style.font = s.font || `${s.fontStyle} ${s.fontWeight} ${s.fontSize}/${s.lineHeight} ${s.fontFamily}`, c.style.letterSpacing = s.letterSpacing, document.body.appendChild(c);
|
|
1055
|
+
let l = (parseFloat(s.paddingLeft) || 0) + (parseFloat(s.paddingRight) || 0) + 2, u = 0;
|
|
1056
|
+
c.textContent = n || t, u = Math.max(u, c.offsetWidth + 44);
|
|
1057
|
+
for (let e of i) c.textContent = (e.textContent ?? "").replace(/\s+/g, " ").trim(), u = Math.max(u, c.offsetWidth + l);
|
|
1058
|
+
return c.remove(), i.length || a ? Math.ceil(u) : 0;
|
|
1059
|
+
}
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region src/components/EditCell.vue?vue&type=script&setup=true&lang.ts
|
|
1062
|
+
var V = { class: "inandu-grid-edit-cell" }, H = ["aria-label", "checked"], U = [
|
|
1063
|
+
"aria-label",
|
|
1064
|
+
"type",
|
|
1065
|
+
"value"
|
|
1066
|
+
], be = {
|
|
1067
|
+
key: 2,
|
|
1068
|
+
class: "inandu-grid-field-error"
|
|
1069
|
+
}, xe = /* @__PURE__ */ c({
|
|
1070
|
+
__name: "EditCell",
|
|
1071
|
+
props: {
|
|
1072
|
+
column: {},
|
|
1073
|
+
value: {},
|
|
1074
|
+
error: {},
|
|
1075
|
+
t: { type: Function }
|
|
1076
|
+
},
|
|
1077
|
+
emits: ["change"],
|
|
1078
|
+
setup(e, { emit: n }) {
|
|
1079
|
+
let a = e, o = n, s = t(() => a.column.type ?? "string"), c = t(() => a.t("MsgEditCell", { column: a.column.headerText ?? a.column.field })), l = t(() => typeof a.value == "string" ? a.value : "");
|
|
1080
|
+
return (t, n) => (p(), i("span", V, [s.value === "boolean" ? (p(), i("input", {
|
|
1081
|
+
key: 0,
|
|
1082
|
+
"aria-label": c.value,
|
|
1083
|
+
type: "checkbox",
|
|
1084
|
+
checked: !!e.value,
|
|
1085
|
+
onChange: n[0] ||= (e) => o("change", e.target.checked)
|
|
1086
|
+
}, null, 40, H)) : (p(), i("input", {
|
|
1087
|
+
key: 1,
|
|
1088
|
+
"aria-label": c.value,
|
|
1089
|
+
type: s.value === "date" ? "date" : s.value === "number" ? "number" : "text",
|
|
1090
|
+
value: l.value,
|
|
1091
|
+
onInput: n[1] ||= (e) => o("change", e.target.value)
|
|
1092
|
+
}, null, 40, U)), e.error ? (p(), i("span", be, g(e.error), 1)) : r("", !0)]));
|
|
1093
|
+
}
|
|
1094
|
+
}), W = c({
|
|
1095
|
+
name: "InanduGridRenderNodes",
|
|
1096
|
+
props: { nodes: {
|
|
1097
|
+
type: null,
|
|
1098
|
+
default: null
|
|
1099
|
+
} },
|
|
1100
|
+
setup(e) {
|
|
1101
|
+
return () => e.nodes;
|
|
1102
|
+
}
|
|
1103
|
+
}), G = ["data-row-index"], K = { key: 0 }, Se = ["aria-label", "title"], q = { key: 1 }, Ce = ["aria-label"], we = ["aria-label", "checked"], J = [
|
|
1104
|
+
"data-field",
|
|
1105
|
+
"tabindex",
|
|
1106
|
+
"onMousedown",
|
|
1107
|
+
"onMouseenter"
|
|
1108
|
+
], Y = {
|
|
1109
|
+
key: 3,
|
|
1110
|
+
class: "inandu-grid-row-actions"
|
|
1111
|
+
}, X = ["disabled"], Te = ["disabled"], Ee = ["disabled"], De = ["disabled"], Oe = {
|
|
1112
|
+
key: 0,
|
|
1113
|
+
class: "inandu-grid-detail-row"
|
|
1114
|
+
}, Z = ["colspan"], ke = /* @__PURE__ */ c({
|
|
1115
|
+
__name: "DataRow",
|
|
1116
|
+
props: {
|
|
1117
|
+
ctx: {},
|
|
1118
|
+
row: {},
|
|
1119
|
+
rowIndex: {},
|
|
1120
|
+
hasRowDragHandle: {
|
|
1121
|
+
type: Boolean,
|
|
1122
|
+
default: !1
|
|
1123
|
+
},
|
|
1124
|
+
isDragOverRow: {
|
|
1125
|
+
type: Boolean,
|
|
1126
|
+
default: !1
|
|
1127
|
+
},
|
|
1128
|
+
hasMasterDetail: {
|
|
1129
|
+
type: Boolean,
|
|
1130
|
+
default: !1
|
|
1131
|
+
},
|
|
1132
|
+
isRowExpanded: {
|
|
1133
|
+
type: Boolean,
|
|
1134
|
+
default: !1
|
|
1135
|
+
}
|
|
1136
|
+
},
|
|
1137
|
+
emits: [
|
|
1138
|
+
"rowDragStart",
|
|
1139
|
+
"rowDragOver",
|
|
1140
|
+
"rowDragLeave",
|
|
1141
|
+
"rowDrop",
|
|
1142
|
+
"toggleExpanded"
|
|
1143
|
+
],
|
|
1144
|
+
setup(o, { emit: c }) {
|
|
1145
|
+
let d = o, f = c, h = t(() => d.ctx.isEditingRow(d.row)), _ = t(() => d.isRowExpanded ? d.ctx.t("MsgCollapseDetail") : d.ctx.t("MsgExpandDetail"));
|
|
1146
|
+
function y(e) {
|
|
1147
|
+
d.hasRowDragHandle && (e.preventDefault(), f("rowDragOver"));
|
|
1148
|
+
}
|
|
1149
|
+
function ee(e) {
|
|
1150
|
+
d.hasRowDragHandle && (e.preventDefault(), f("rowDrop"));
|
|
1151
|
+
}
|
|
1152
|
+
function b(e) {
|
|
1153
|
+
f("rowDragStart"), e.dataTransfer?.setData("text/plain", "row");
|
|
1154
|
+
}
|
|
1155
|
+
function x(e, t) {
|
|
1156
|
+
d.ctx.cellRangeSelection && d.ctx.onCellRangeMouseDown(e, d.rowIndex, t);
|
|
1157
|
+
}
|
|
1158
|
+
function te(e) {
|
|
1159
|
+
d.ctx.cellRangeSelection && d.ctx.onCellRangeMouseEnter(d.rowIndex, e);
|
|
1160
|
+
}
|
|
1161
|
+
return (t, c) => (p(), i(e, null, [a("tr", {
|
|
1162
|
+
"data-row-index": o.rowIndex,
|
|
1163
|
+
class: l(o.isDragOverRow ? "inandu-drag-over" : void 0),
|
|
1164
|
+
onDragover: y,
|
|
1165
|
+
onDragleave: c[6] ||= (e) => o.hasRowDragHandle && f("rowDragLeave"),
|
|
1166
|
+
onDrop: ee
|
|
1167
|
+
}, [
|
|
1168
|
+
o.hasMasterDetail ? (p(), i("td", K, [a("button", {
|
|
1169
|
+
type: "button",
|
|
1170
|
+
class: "inandu-grid-detail-toggle",
|
|
1171
|
+
"aria-label": _.value,
|
|
1172
|
+
title: _.value,
|
|
1173
|
+
onClick: c[0] ||= (e) => f("toggleExpanded")
|
|
1174
|
+
}, g(o.isRowExpanded ? "▾" : "▸"), 9, Se)])) : r("", !0),
|
|
1175
|
+
o.hasRowDragHandle ? (p(), i("td", q, [a("span", {
|
|
1176
|
+
class: "inandu-grid-row-drag-handle",
|
|
1177
|
+
"aria-label": o.ctx.t("MsgDragRow"),
|
|
1178
|
+
draggable: "true",
|
|
1179
|
+
onDragstart: b
|
|
1180
|
+
}, "⋮⋮", 40, Ce)])) : r("", !0),
|
|
1181
|
+
o.ctx.selectable ? (p(), i("td", {
|
|
1182
|
+
key: 2,
|
|
1183
|
+
style: u(o.ctx.selectColumnStyle)
|
|
1184
|
+
}, [a("input", {
|
|
1185
|
+
"aria-label": o.ctx.t("MsgSelectRow", { index: o.rowIndex + 1 }),
|
|
1186
|
+
type: "checkbox",
|
|
1187
|
+
checked: o.ctx.isRowSelected(o.row),
|
|
1188
|
+
onChange: c[1] ||= (e) => o.ctx.toggleRowSelection(o.row)
|
|
1189
|
+
}, null, 40, we)], 4)) : r("", !0),
|
|
1190
|
+
(p(!0), i(e, null, m(o.ctx.columns, (t, r) => (p(), i("td", {
|
|
1191
|
+
key: t.field,
|
|
1192
|
+
style: u(o.ctx.columnStyle(t)),
|
|
1193
|
+
"data-field": t.field,
|
|
1194
|
+
tabindex: o.ctx.clipboard ? 0 : void 0,
|
|
1195
|
+
class: l(o.ctx.cellRangeSelection && o.ctx.isCellInRange(o.rowIndex, r) ? "inandu-cell-range-selected" : void 0),
|
|
1196
|
+
onMousedown: (e) => x(e, r),
|
|
1197
|
+
onMouseenter: (e) => te(r)
|
|
1198
|
+
}, [h.value && t.editable ? (p(), i(e, { key: 0 }, [o.ctx.editorContent(t, o.row) === void 0 ? (p(), n(xe, {
|
|
1199
|
+
key: 1,
|
|
1200
|
+
column: t,
|
|
1201
|
+
value: o.ctx.rowDraft[t.field],
|
|
1202
|
+
error: o.ctx.fieldErrors[t.field],
|
|
1203
|
+
t: o.ctx.t,
|
|
1204
|
+
onChange: (e) => o.ctx.setRowDraftValue(t.field, e)
|
|
1205
|
+
}, null, 8, [
|
|
1206
|
+
"column",
|
|
1207
|
+
"value",
|
|
1208
|
+
"error",
|
|
1209
|
+
"t",
|
|
1210
|
+
"onChange"
|
|
1211
|
+
])) : (p(), n(v(W), {
|
|
1212
|
+
key: 0,
|
|
1213
|
+
nodes: o.ctx.editorContent(t, o.row)
|
|
1214
|
+
}, null, 8, ["nodes"]))], 64)) : (p(), n(v(W), {
|
|
1215
|
+
key: 1,
|
|
1216
|
+
nodes: o.ctx.cellContent(t, o.row)
|
|
1217
|
+
}, null, 8, ["nodes"]))], 46, J))), 128)),
|
|
1218
|
+
o.ctx.hasRowActions ? (p(), i("td", Y, [h.value ? (p(), i(e, { key: 0 }, [a("button", {
|
|
1219
|
+
type: "button",
|
|
1220
|
+
disabled: o.ctx.isValidating,
|
|
1221
|
+
onClick: c[2] ||= (e) => o.ctx.saveRow(o.row)
|
|
1222
|
+
}, g(o.ctx.t("MsgSaveRow")), 9, X), a("button", {
|
|
1223
|
+
type: "button",
|
|
1224
|
+
disabled: o.ctx.isValidating,
|
|
1225
|
+
onClick: c[3] ||= (e) => o.ctx.cancelRowEdit()
|
|
1226
|
+
}, g(o.ctx.t("MsgCancelRowEdit")), 9, Te)], 64)) : (p(), i(e, { key: 1 }, [o.ctx.editableColumnCount > 0 ? (p(), i("button", {
|
|
1227
|
+
key: 0,
|
|
1228
|
+
type: "button",
|
|
1229
|
+
disabled: o.ctx.isAnotherRowEditing(o.row),
|
|
1230
|
+
onClick: c[4] ||= (e) => o.ctx.startEditingRow(o.row)
|
|
1231
|
+
}, g(o.ctx.t("MsgEditRow")), 9, Ee)) : r("", !0), o.ctx.deletable ? (p(), i("button", {
|
|
1232
|
+
key: 1,
|
|
1233
|
+
type: "button",
|
|
1234
|
+
disabled: o.ctx.isAnotherRowEditing(o.row),
|
|
1235
|
+
onClick: c[5] ||= (e) => o.ctx.deleteRow(o.row)
|
|
1236
|
+
}, g(o.ctx.t("MsgDeleteRow")), 9, De)) : r("", !0)], 64))])) : r("", !0)
|
|
1237
|
+
], 42, G), o.hasMasterDetail && o.isRowExpanded ? (p(), i("tr", Oe, [a("td", { colspan: o.ctx.columns.length + o.ctx.extraColumnCount }, [s(v(W), { nodes: o.ctx.detailContent(o.row) }, null, 8, ["nodes"])], 8, Z)])) : r("", !0)], 64));
|
|
1238
|
+
}
|
|
1239
|
+
}), Ae = {
|
|
1240
|
+
key: 0,
|
|
1241
|
+
class: "inandu-grid-filter-range"
|
|
1242
|
+
}, je = ["aria-label", "value"], Q = ["aria-label", "value"], $ = {
|
|
1243
|
+
key: 1,
|
|
1244
|
+
class: "inandu-grid-filter-range"
|
|
1245
|
+
}, Me = ["aria-label", "value"], Ne = ["aria-label", "value"], Pe = ["aria-label", "value"], Fe = { value: "" }, Ie = ["aria-label", "value"], Le = /* @__PURE__ */ c({
|
|
1246
|
+
__name: "FilterControl",
|
|
1247
|
+
props: {
|
|
1248
|
+
column: {},
|
|
1249
|
+
value: {},
|
|
1250
|
+
t: { type: Function }
|
|
1251
|
+
},
|
|
1252
|
+
emits: ["change"],
|
|
1253
|
+
setup(e, { emit: n }) {
|
|
1254
|
+
let r = e, o = n, s = t(() => r.column.type ?? "string"), c = t(() => r.t("MsgFilterColumn", { column: r.column.headerText ?? r.column.field }));
|
|
1255
|
+
function l(e) {
|
|
1256
|
+
return e.target.value;
|
|
1257
|
+
}
|
|
1258
|
+
return (t, n) => s.value === "number" ? (p(), i("span", Ae, [a("input", {
|
|
1259
|
+
"aria-label": `${c.value} ${e.t("MsgFilterMin")}`,
|
|
1260
|
+
type: "number",
|
|
1261
|
+
value: e.value?.min ?? "",
|
|
1262
|
+
onInput: n[0] ||= (e) => o("change", { min: l(e) })
|
|
1263
|
+
}, null, 40, je), a("input", {
|
|
1264
|
+
"aria-label": `${c.value} ${e.t("MsgFilterMax")}`,
|
|
1265
|
+
type: "number",
|
|
1266
|
+
value: e.value?.max ?? "",
|
|
1267
|
+
onInput: n[1] ||= (e) => o("change", { max: l(e) })
|
|
1268
|
+
}, null, 40, Q)])) : s.value === "date" ? (p(), i("span", $, [a("input", {
|
|
1269
|
+
"aria-label": `${c.value} ${e.t("MsgFilterFrom")}`,
|
|
1270
|
+
type: "date",
|
|
1271
|
+
value: e.value?.from ?? "",
|
|
1272
|
+
onInput: n[2] ||= (e) => o("change", { from: l(e) })
|
|
1273
|
+
}, null, 40, Me), a("input", {
|
|
1274
|
+
"aria-label": `${c.value} ${e.t("MsgFilterTo")}`,
|
|
1275
|
+
type: "date",
|
|
1276
|
+
value: e.value?.to ?? "",
|
|
1277
|
+
onInput: n[3] ||= (e) => o("change", { to: l(e) })
|
|
1278
|
+
}, null, 40, Ne)])) : s.value === "boolean" ? (p(), i("select", {
|
|
1279
|
+
key: 2,
|
|
1280
|
+
"aria-label": c.value,
|
|
1281
|
+
value: e.value?.bool ?? "",
|
|
1282
|
+
onChange: n[4] ||= (e) => o("change", { bool: l(e) })
|
|
1283
|
+
}, [
|
|
1284
|
+
a("option", Fe, g(e.t("MsgAll")), 1),
|
|
1285
|
+
n[6] ||= a("option", { value: "true" }, "true", -1),
|
|
1286
|
+
n[7] ||= a("option", { value: "false" }, "false", -1)
|
|
1287
|
+
], 40, Pe)) : (p(), i("input", {
|
|
1288
|
+
key: 3,
|
|
1289
|
+
"aria-label": c.value,
|
|
1290
|
+
type: "text",
|
|
1291
|
+
value: e.value?.text ?? "",
|
|
1292
|
+
onInput: n[5] ||= (e) => o("change", { text: l(e) })
|
|
1293
|
+
}, null, 40, Ie));
|
|
1294
|
+
}
|
|
1295
|
+
}), Re = { class: "inandu-grid-vue" }, ze = { class: "inandu-grid-search" }, Be = [
|
|
1296
|
+
"aria-label",
|
|
1297
|
+
"placeholder",
|
|
1298
|
+
"value"
|
|
1299
|
+
], Ve = { class: "inandu-grid-toolbar" }, He = {
|
|
1300
|
+
key: 3,
|
|
1301
|
+
class: "inandu-grid-column-toggle"
|
|
1302
|
+
}, Ue = [
|
|
1303
|
+
"aria-label",
|
|
1304
|
+
"checked",
|
|
1305
|
+
"onChange"
|
|
1306
|
+
], We = {
|
|
1307
|
+
key: 0,
|
|
1308
|
+
class: "inandu-grid-group-by"
|
|
1309
|
+
}, Ge = ["value"], Ke = { value: "" }, qe = ["value"], Je = { key: 0 }, Ye = { key: 1 }, Xe = [
|
|
1310
|
+
"aria-label",
|
|
1311
|
+
"checked",
|
|
1312
|
+
"indeterminate"
|
|
1313
|
+
], Ze = [
|
|
1314
|
+
"data-field",
|
|
1315
|
+
"draggable",
|
|
1316
|
+
"aria-label",
|
|
1317
|
+
"onDragstart",
|
|
1318
|
+
"onDragover",
|
|
1319
|
+
"onDragleave",
|
|
1320
|
+
"onDrop",
|
|
1321
|
+
"onClick"
|
|
1322
|
+
], Qe = {
|
|
1323
|
+
key: 0,
|
|
1324
|
+
class: "inandu-grid-sort-priority"
|
|
1325
|
+
}, $e = ["onMousedown", "onDblclick"], et = { key: 3 }, tt = { class: "inandu-grid-filter-row" }, nt = { key: 0 }, rt = { key: 1 }, it = { key: 3 }, at = {
|
|
1326
|
+
key: 0,
|
|
1327
|
+
class: "inandu-grid-new-row"
|
|
1328
|
+
}, ot = {
|
|
1329
|
+
key: 1,
|
|
1330
|
+
class: "inandu-grid-row-actions"
|
|
1331
|
+
}, st = ["disabled"], ct = ["disabled"], lt = { key: 1 }, ut = ["colspan"], dt = ["aria-level", "aria-expanded"], ft = [
|
|
1332
|
+
"aria-label",
|
|
1333
|
+
"checked",
|
|
1334
|
+
"onChange"
|
|
1335
|
+
], pt = [
|
|
1336
|
+
"aria-label",
|
|
1337
|
+
"title",
|
|
1338
|
+
"onClick"
|
|
1339
|
+
], mt = {
|
|
1340
|
+
key: 1,
|
|
1341
|
+
class: "inandu-grid-tree-toggle-spacer",
|
|
1342
|
+
"aria-hidden": "true"
|
|
1343
|
+
}, ht = {
|
|
1344
|
+
key: 1,
|
|
1345
|
+
class: "inandu-grid-row-actions"
|
|
1346
|
+
}, gt = { class: "inandu-grid-group-row" }, _t = ["colspan"], vt = {
|
|
1347
|
+
key: 0,
|
|
1348
|
+
class: "inandu-grid-group-aggregates"
|
|
1349
|
+
}, yt = {
|
|
1350
|
+
key: 0,
|
|
1351
|
+
"aria-hidden": "true"
|
|
1352
|
+
}, bt = ["colspan"], xt = {
|
|
1353
|
+
key: 1,
|
|
1354
|
+
"aria-hidden": "true"
|
|
1355
|
+
}, St = ["colspan"], Ct = { key: 0 }, wt = { class: "inandu-grid-totals-row" }, Tt = { key: 0 }, Et = { key: 1 }, Dt = { key: 3 }, Ot = {
|
|
1356
|
+
key: 1,
|
|
1357
|
+
class: "inandu-grid-pagination"
|
|
1358
|
+
}, kt = ["disabled"], At = ["disabled"], jt = /* @__PURE__ */ c({
|
|
1359
|
+
name: "InanduGrid",
|
|
1360
|
+
__name: "InanduGrid",
|
|
1361
|
+
props: {
|
|
1362
|
+
rows: {},
|
|
1363
|
+
columns: {},
|
|
1364
|
+
locale: { default: "en" },
|
|
1365
|
+
lang: {},
|
|
1366
|
+
pageSize: { default: 0 },
|
|
1367
|
+
selectable: { type: Boolean },
|
|
1368
|
+
exportable: { type: Boolean },
|
|
1369
|
+
exportFilenameBase: { default: "inandu-grid" },
|
|
1370
|
+
deletable: { type: Boolean },
|
|
1371
|
+
deleteConfirmMessage: {},
|
|
1372
|
+
bulkDeleteConfirmMessage: {},
|
|
1373
|
+
creatable: { type: Boolean },
|
|
1374
|
+
clipboard: { type: Boolean },
|
|
1375
|
+
cellRangeSelection: { type: Boolean },
|
|
1376
|
+
multiRange: { type: Boolean },
|
|
1377
|
+
columnToggle: { type: Boolean },
|
|
1378
|
+
rowReorder: { type: Boolean },
|
|
1379
|
+
treeChildrenKey: {},
|
|
1380
|
+
treeDefaultExpanded: { default: "none" },
|
|
1381
|
+
renderDetail: {},
|
|
1382
|
+
singleDetailExpand: { type: Boolean },
|
|
1383
|
+
extraRowFilter: {},
|
|
1384
|
+
serverSide: {},
|
|
1385
|
+
virtualScroll: { type: Boolean },
|
|
1386
|
+
virtualRowHeight: { default: 40 },
|
|
1387
|
+
height: { default: 400 },
|
|
1388
|
+
overscan: { default: 4 },
|
|
1389
|
+
autosize: { type: Boolean }
|
|
1390
|
+
},
|
|
1391
|
+
emits: [
|
|
1392
|
+
"queryChange",
|
|
1393
|
+
"selectionChange",
|
|
1394
|
+
"rowSave",
|
|
1395
|
+
"rowCreate",
|
|
1396
|
+
"rowDelete",
|
|
1397
|
+
"rowsDelete",
|
|
1398
|
+
"cellsPaste",
|
|
1399
|
+
"cellRangeChange",
|
|
1400
|
+
"cellRangesChange",
|
|
1401
|
+
"rowOrderChange"
|
|
1402
|
+
],
|
|
1403
|
+
setup(c, { expose: f, emit: _ }) {
|
|
1404
|
+
function x(e, t) {
|
|
1405
|
+
return {
|
|
1406
|
+
minRow: Math.min(e.row, t.row),
|
|
1407
|
+
maxRow: Math.max(e.row, t.row),
|
|
1408
|
+
minCol: Math.min(e.col, t.col),
|
|
1409
|
+
maxCol: Math.max(e.col, t.col)
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
function te(e, t, n) {
|
|
1413
|
+
return t >= e.minRow && t <= e.maxRow && n >= e.minCol && n <= e.maxCol;
|
|
1414
|
+
}
|
|
1415
|
+
let S = c, C = _, w = y(), E = fe(() => ({
|
|
1416
|
+
rows: S.rows,
|
|
1417
|
+
columns: S.columns,
|
|
1418
|
+
locale: S.locale,
|
|
1419
|
+
lang: S.lang,
|
|
1420
|
+
pageSize: S.pageSize,
|
|
1421
|
+
selectable: S.selectable,
|
|
1422
|
+
deleteConfirmMessage: S.deleteConfirmMessage,
|
|
1423
|
+
bulkDeleteConfirmMessage: S.bulkDeleteConfirmMessage,
|
|
1424
|
+
onRowSave: (e) => C("rowSave", e),
|
|
1425
|
+
onRowCreate: (e) => C("rowCreate", e),
|
|
1426
|
+
onRowDelete: (e) => C("rowDelete", e),
|
|
1427
|
+
onRowsDelete: (e) => C("rowsDelete", e),
|
|
1428
|
+
onCellsPaste: (e) => C("cellsPaste", e),
|
|
1429
|
+
onRowOrderChange: (e) => C("rowOrderChange", e),
|
|
1430
|
+
treeChildrenKey: S.treeChildrenKey,
|
|
1431
|
+
treeDefaultExpanded: S.treeDefaultExpanded,
|
|
1432
|
+
singleDetailExpand: S.singleDetailExpand,
|
|
1433
|
+
extraRowFilter: S.extraRowFilter,
|
|
1434
|
+
virtualScroll: S.virtualScroll,
|
|
1435
|
+
serverSide: S.serverSide,
|
|
1436
|
+
onQueryChange: (e) => C("queryChange", e)
|
|
1437
|
+
}));
|
|
1438
|
+
f({ grid: E });
|
|
1439
|
+
let D = t(() => ue(S.lang ?? S.locale)), ne = h(void 0), re = h(void 0), ie = h(0), ae = h(null);
|
|
1440
|
+
ee(() => E.selectedRows, (e) => C("selectionChange", Array.from(e)), { immediate: !0 });
|
|
1441
|
+
let oe;
|
|
1442
|
+
function se(e, t) {
|
|
1443
|
+
e.preventDefault(), oe?.();
|
|
1444
|
+
let n = e.clientX, r = E.effectiveWidth(t), i = (e) => E.setColumnWidth(t, r + (e.clientX - n)), a = () => oe?.();
|
|
1445
|
+
window.addEventListener("mousemove", i), window.addEventListener("mouseup", a), oe = () => {
|
|
1446
|
+
window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a), oe = void 0;
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
function k(e, t) {
|
|
1450
|
+
if (!S.autosize || !ae.value) return;
|
|
1451
|
+
e.preventDefault(), e.stopPropagation();
|
|
1452
|
+
let n = ye(ae.value, t.field, t.headerText ?? t.field);
|
|
1453
|
+
n > 0 && E.setColumnWidth(t.field, Math.min(600, n));
|
|
1454
|
+
}
|
|
1455
|
+
let A = t(() => S.cellRangeSelection && !E.groupByField && !E.hasVirtualScroll && !E.hasTreeData), j = h(void 0), M = h(void 0), N = h([]), P = !1, F = t(() => j.value && M.value ? x(j.value, M.value) : void 0), I = t(() => F.value ? [...N.value, F.value] : N.value);
|
|
1456
|
+
function ce(e, t) {
|
|
1457
|
+
return I.value.some((n) => te(n, e, t));
|
|
1458
|
+
}
|
|
1459
|
+
function L(e) {
|
|
1460
|
+
return {
|
|
1461
|
+
rows: E.visibleRows.slice(e.minRow, e.maxRow + 1),
|
|
1462
|
+
fields: E.visibleColumns.slice(e.minCol, e.maxCol + 1).map((e) => e.field)
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
ee([
|
|
1466
|
+
A,
|
|
1467
|
+
I,
|
|
1468
|
+
() => E.visibleRows,
|
|
1469
|
+
() => E.visibleColumns
|
|
1470
|
+
], () => {
|
|
1471
|
+
A.value && (C("cellRangeChange", F.value ? L(F.value) : void 0), C("cellRangesChange", I.value.map(L)));
|
|
1472
|
+
}, { immediate: !0 });
|
|
1473
|
+
function R(e, t, n) {
|
|
1474
|
+
e.button === 0 && (P = !0, S.multiRange && (e.ctrlKey || e.metaKey) && !e.shiftKey ? (F.value && (N.value = [...N.value, F.value]), j.value = {
|
|
1475
|
+
row: t,
|
|
1476
|
+
col: n
|
|
1477
|
+
}) : (!e.shiftKey || !j.value) && (N.value = [], j.value = {
|
|
1478
|
+
row: t,
|
|
1479
|
+
col: n
|
|
1480
|
+
}), M.value = {
|
|
1481
|
+
row: t,
|
|
1482
|
+
col: n
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
function le(e, t) {
|
|
1486
|
+
P && (M.value = {
|
|
1487
|
+
row: e,
|
|
1488
|
+
col: t
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
let de = () => {
|
|
1492
|
+
P = !1;
|
|
1493
|
+
};
|
|
1494
|
+
ee(A, (e, t, n) => {
|
|
1495
|
+
e && (document.addEventListener("mouseup", de), n(() => document.removeEventListener("mouseup", de)));
|
|
1496
|
+
}, { immediate: !0 }), d(() => oe?.());
|
|
1497
|
+
function pe(e) {
|
|
1498
|
+
let t = E.visibleRows.slice(e.minRow, e.maxRow + 1), n = E.visibleColumns.slice(e.minCol, e.maxCol + 1);
|
|
1499
|
+
return t.map((e) => n.map((t) => T(e[t.field], t.type ?? "string", t.format ?? "", S.locale)).join(" ")).join("\n");
|
|
1500
|
+
}
|
|
1501
|
+
let z = t(() => E.visibleColumns.filter((e) => e.aggregate)), B = t(() => S.serverSide ? [] : E.visibleColumns.filter((e) => e.groupable !== !1)), he = t(() => E.groups ? E.groups.length === 0 : E.visibleRows.length === 0), V = t(() => E.editableColumns.length > 0 || S.deletable || S.creatable), H = t(() => S.rowReorder && !E.groupByField && !E.hasVirtualScroll), U = t(() => (!!w.detail || !!S.renderDetail) && !E.groupByField && !E.hasVirtualScroll), be = t(() => +!!U.value + +!!H.value + +!!S.selectable + +!!V.value), G = t(() => E.visibleColumns.length + be.value), K = t(() => E.hasVirtualScroll ? Math.max(0, Math.floor(ie.value / S.virtualRowHeight) - S.overscan) : 0), Se = t(() => E.hasVirtualScroll ? Math.min(E.visibleRows.length, Math.ceil((ie.value + S.height) / S.virtualRowHeight) + S.overscan) : E.visibleRows.length), q = t(() => E.hasVirtualScroll ? E.visibleRows.slice(K.value, Se.value) : E.visibleRows), Ce = t(() => K.value * S.virtualRowHeight), we = t(() => (E.visibleRows.length - Se.value) * S.virtualRowHeight);
|
|
1502
|
+
function J(e) {
|
|
1503
|
+
E.hasVirtualScroll && (ie.value = e.currentTarget.scrollTop);
|
|
1504
|
+
}
|
|
1505
|
+
function Y(e, t) {
|
|
1506
|
+
E.setFilterValue(e, {
|
|
1507
|
+
...E.filterValues[e],
|
|
1508
|
+
...t
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
function X(e) {
|
|
1512
|
+
let t = e.width !== void 0 || E.isColumnResized(e.field) ? { width: `${E.effectiveWidth(e.field)}px` } : {}, n = E.columnPinnedSide(e.field);
|
|
1513
|
+
return n === "left" ? {
|
|
1514
|
+
...t,
|
|
1515
|
+
position: "sticky",
|
|
1516
|
+
left: `${E.stickyOffset(e.field)}px`,
|
|
1517
|
+
zIndex: 1
|
|
1518
|
+
} : n === "right" ? {
|
|
1519
|
+
...t,
|
|
1520
|
+
position: "sticky",
|
|
1521
|
+
right: `${E.stickyOffsetRight(e.field)}px`,
|
|
1522
|
+
zIndex: 1
|
|
1523
|
+
} : t;
|
|
1524
|
+
}
|
|
1525
|
+
function Te(e, t) {
|
|
1526
|
+
E.onColumnDragStart(t), e.dataTransfer?.setData("text/plain", t);
|
|
1527
|
+
}
|
|
1528
|
+
function Ee(e, t) {
|
|
1529
|
+
e.preventDefault(), ne.value = t;
|
|
1530
|
+
}
|
|
1531
|
+
function De(e) {
|
|
1532
|
+
ne.value === e && (ne.value = void 0);
|
|
1533
|
+
}
|
|
1534
|
+
function Oe(e, t) {
|
|
1535
|
+
e.preventDefault(), ne.value = void 0, E.onColumnDrop(t);
|
|
1536
|
+
}
|
|
1537
|
+
let Z = t(() => S.selectable ? {
|
|
1538
|
+
position: "sticky",
|
|
1539
|
+
left: "0px",
|
|
1540
|
+
zIndex: 1
|
|
1541
|
+
} : void 0);
|
|
1542
|
+
function Ae(e, t) {
|
|
1543
|
+
let n = e.aggregate, r = t[e.field];
|
|
1544
|
+
if (!n || r === void 0) return "";
|
|
1545
|
+
let i = n === "count" ? String(r) : T(r, "number", e.format ?? "", S.locale);
|
|
1546
|
+
return `${e.headerText ?? e.field} ${O[n]}: ${i}`;
|
|
1547
|
+
}
|
|
1548
|
+
function je(e) {
|
|
1549
|
+
let t = {
|
|
1550
|
+
title: e.headerText ?? e.field,
|
|
1551
|
+
field: e.field
|
|
1552
|
+
}, n = w[`header-${e.field}`];
|
|
1553
|
+
return n ? n(t) : e.renderHeader ? e.renderHeader(t) : t.title;
|
|
1554
|
+
}
|
|
1555
|
+
function Q(e, t) {
|
|
1556
|
+
let n = {
|
|
1557
|
+
value: t[e.field],
|
|
1558
|
+
row: t,
|
|
1559
|
+
field: e.field
|
|
1560
|
+
}, r = w[`cell-${e.field}`];
|
|
1561
|
+
return r ? r(n) : e.renderCell ? e.renderCell(n) : T(t[e.field], e.type ?? "string", e.format ?? "", S.locale);
|
|
1562
|
+
}
|
|
1563
|
+
function $(e, t) {
|
|
1564
|
+
let n = w[`editor-${e.field}`];
|
|
1565
|
+
if (!n && !e.renderEditor) return;
|
|
1566
|
+
let r = {
|
|
1567
|
+
value: E.rowDraft[e.field],
|
|
1568
|
+
row: t,
|
|
1569
|
+
field: e.field,
|
|
1570
|
+
setValue: (t) => E.setRowDraftValue(e.field, t),
|
|
1571
|
+
error: E.fieldErrors[e.field]
|
|
1572
|
+
};
|
|
1573
|
+
return n ? n(r) : e.renderEditor(r);
|
|
1574
|
+
}
|
|
1575
|
+
function Me(e) {
|
|
1576
|
+
return w.detail ? w.detail({ row: e }) : S.renderDetail?.(e);
|
|
1577
|
+
}
|
|
1578
|
+
function Ne(e, t) {
|
|
1579
|
+
E.toggleColumnVisibility(t), e.target.checked = !E.isColumnHidden(t);
|
|
1580
|
+
}
|
|
1581
|
+
function Pe(e) {
|
|
1582
|
+
if (!S.clipboard || !(e.ctrlKey || e.metaKey)) return;
|
|
1583
|
+
let t = e.key.toLowerCase();
|
|
1584
|
+
if (t !== "c" && t !== "v") return;
|
|
1585
|
+
let n = e.target;
|
|
1586
|
+
if (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement) return;
|
|
1587
|
+
let r = n.closest("td[data-field]"), i = r?.getAttribute("data-field"), a = r?.closest("tr")?.getAttribute("data-row-index");
|
|
1588
|
+
if (!r || !i || a == null) return;
|
|
1589
|
+
let o = Number(a);
|
|
1590
|
+
if (e.preventDefault(), t === "c") {
|
|
1591
|
+
let e = F.value, t = A.value && e && (e.minRow !== e.maxRow || e.minCol !== e.maxCol) ? pe(e) : void 0;
|
|
1592
|
+
navigator.clipboard?.writeText(t ?? E.copyCellText(o, i))?.catch(() => void 0);
|
|
1593
|
+
} else navigator.clipboard?.readText()?.then((e) => E.pasteAt(o, i, e)).catch(() => void 0);
|
|
1594
|
+
}
|
|
1595
|
+
function Fe(e, t) {
|
|
1596
|
+
return e.id == null ? t : String(e.id);
|
|
1597
|
+
}
|
|
1598
|
+
let Ie = t(() => ({
|
|
1599
|
+
columns: E.visibleColumns,
|
|
1600
|
+
t: D.value,
|
|
1601
|
+
selectable: S.selectable,
|
|
1602
|
+
selectColumnStyle: Z.value,
|
|
1603
|
+
columnStyle: X,
|
|
1604
|
+
isRowSelected: E.isRowSelected,
|
|
1605
|
+
toggleRowSelection: E.toggleRowSelection,
|
|
1606
|
+
hasRowActions: V.value,
|
|
1607
|
+
editableColumnCount: E.editableColumns.length,
|
|
1608
|
+
isEditingRow: E.isEditingRow,
|
|
1609
|
+
isAnotherRowEditing: E.isAnotherRowEditing,
|
|
1610
|
+
startEditingRow: E.startEditingRow,
|
|
1611
|
+
cancelRowEdit: E.cancelRowEdit,
|
|
1612
|
+
saveRow: (e) => void E.saveRow(e),
|
|
1613
|
+
deleteRow: E.deleteRow,
|
|
1614
|
+
deletable: S.deletable,
|
|
1615
|
+
rowDraft: E.rowDraft,
|
|
1616
|
+
fieldErrors: E.fieldErrors,
|
|
1617
|
+
isValidating: E.isValidating,
|
|
1618
|
+
setRowDraftValue: E.setRowDraftValue,
|
|
1619
|
+
cellContent: Q,
|
|
1620
|
+
editorContent: $,
|
|
1621
|
+
detailContent: Me,
|
|
1622
|
+
clipboard: S.clipboard,
|
|
1623
|
+
cellRangeSelection: A.value,
|
|
1624
|
+
isCellInRange: ce,
|
|
1625
|
+
onCellRangeMouseDown: R,
|
|
1626
|
+
onCellRangeMouseEnter: le,
|
|
1627
|
+
extraColumnCount: be.value
|
|
1628
|
+
}));
|
|
1629
|
+
return (t, d) => (p(), i("div", Re, [
|
|
1630
|
+
a("div", ze, [a("input", {
|
|
1631
|
+
"aria-label": D.value("MsgFilterPlaceholder"),
|
|
1632
|
+
type: "text",
|
|
1633
|
+
placeholder: `${D.value("MsgFilterPlaceholder")}…`,
|
|
1634
|
+
value: v(E).filterQuery,
|
|
1635
|
+
onInput: d[0] ||= (e) => v(E).setFilterQuery(e.target.value)
|
|
1636
|
+
}, null, 40, Be)]),
|
|
1637
|
+
a("div", Ve, [
|
|
1638
|
+
c.exportable ? (p(), i(e, { key: 0 }, [
|
|
1639
|
+
a("button", {
|
|
1640
|
+
type: "button",
|
|
1641
|
+
onClick: d[1] ||= (e) => v(me)(v(E).exportRows, v(E).visibleColumns, c.locale, c.exportFilenameBase)
|
|
1642
|
+
}, g(D.value("MsgExportCsv")), 1),
|
|
1643
|
+
a("button", {
|
|
1644
|
+
type: "button",
|
|
1645
|
+
onClick: d[2] ||= (e) => v(ge)(v(E).exportRows, v(E).visibleColumns, c.locale, c.exportFilenameBase)
|
|
1646
|
+
}, g(D.value("MsgExportExcel")), 1),
|
|
1647
|
+
a("button", {
|
|
1648
|
+
type: "button",
|
|
1649
|
+
onClick: d[3] ||= (e) => void v(ve)(v(E).exportRows, v(E).visibleColumns, c.locale, c.exportFilenameBase)
|
|
1650
|
+
}, g(D.value("MsgExportPdf")), 1),
|
|
1651
|
+
a("button", {
|
|
1652
|
+
type: "button",
|
|
1653
|
+
onClick: d[4] ||= (e) => v(_e)(v(E).exportRows, v(E).visibleColumns, c.locale, c.exportFilenameBase)
|
|
1654
|
+
}, g(D.value("MsgPrint")), 1)
|
|
1655
|
+
], 64)) : r("", !0),
|
|
1656
|
+
c.creatable && v(E).editableColumns.length > 0 && !v(E).isAddingRow ? (p(), i("button", {
|
|
1657
|
+
key: 1,
|
|
1658
|
+
type: "button",
|
|
1659
|
+
onClick: d[5] ||= (e) => v(E).startAddingRow()
|
|
1660
|
+
}, g(D.value("MsgAddRow")), 1)) : r("", !0),
|
|
1661
|
+
c.selectable && c.deletable && v(E).selectedRows.size > 0 ? (p(), i("button", {
|
|
1662
|
+
key: 2,
|
|
1663
|
+
type: "button",
|
|
1664
|
+
onClick: d[6] ||= (e) => v(E).deleteSelectedRows()
|
|
1665
|
+
}, g(D.value("MsgDeleteSelected", { count: v(E).selectedRows.size })), 1)) : r("", !0),
|
|
1666
|
+
c.columnToggle ? (p(), i("details", He, [a("summary", null, g(D.value("MsgToggleColumns")), 1), a("ul", null, [(p(!0), i(e, null, m(v(E).hideableColumns, (e) => (p(), i("li", { key: e.field }, [a("label", null, [a("input", {
|
|
1667
|
+
"aria-label": D.value("MsgToggleColumn", { column: e.headerText ?? e.field }),
|
|
1668
|
+
type: "checkbox",
|
|
1669
|
+
checked: !v(E).isColumnHidden(e.field),
|
|
1670
|
+
onChange: (t) => Ne(t, e.field)
|
|
1671
|
+
}, null, 40, Ue), o(" " + g(e.headerText ?? e.field), 1)])]))), 128))])])) : r("", !0)
|
|
1672
|
+
]),
|
|
1673
|
+
B.value.length > 0 ? (p(), i("div", We, [a("label", null, [o(g(v(E).groupByField ? D.value("MsgGroupedBy", { column: B.value.find((e) => e.field === v(E).groupByField)?.headerText ?? v(E).groupByField }) : D.value("MsgGroupByHint")) + " ", 1), a("select", {
|
|
1674
|
+
"aria-label": "Group by",
|
|
1675
|
+
value: v(E).groupByField ?? "",
|
|
1676
|
+
onChange: d[7] ||= (e) => v(E).setGroupByField(e.target.value || void 0)
|
|
1677
|
+
}, [a("option", Ke, g(D.value("MsgCancelGrouping")), 1), (p(!0), i(e, null, m(B.value, (e) => (p(), i("option", {
|
|
1678
|
+
key: e.field,
|
|
1679
|
+
value: e.field
|
|
1680
|
+
}, g(e.headerText ?? e.field), 9, qe))), 128))], 40, Ge)])])) : r("", !0),
|
|
1681
|
+
a("div", {
|
|
1682
|
+
class: l(v(E).hasVirtualScroll ? "inandu-grid-viewport" : void 0),
|
|
1683
|
+
style: u(v(E).hasVirtualScroll ? {
|
|
1684
|
+
height: `${c.height}px`,
|
|
1685
|
+
overflow: "auto"
|
|
1686
|
+
} : void 0),
|
|
1687
|
+
onScroll: J
|
|
1688
|
+
}, [a("table", {
|
|
1689
|
+
ref_key: "tableRef",
|
|
1690
|
+
ref: ae,
|
|
1691
|
+
class: "inandu-grid",
|
|
1692
|
+
onKeydown: Pe
|
|
1693
|
+
}, [
|
|
1694
|
+
a("thead", null, [a("tr", null, [
|
|
1695
|
+
U.value ? (p(), i("th", Je)) : r("", !0),
|
|
1696
|
+
H.value ? (p(), i("th", Ye)) : r("", !0),
|
|
1697
|
+
c.selectable ? (p(), i("th", {
|
|
1698
|
+
key: 2,
|
|
1699
|
+
style: u(Z.value)
|
|
1700
|
+
}, [a("input", {
|
|
1701
|
+
"aria-label": D.value("MsgSelectAll"),
|
|
1702
|
+
type: "checkbox",
|
|
1703
|
+
checked: v(E).allSelected,
|
|
1704
|
+
indeterminate: v(E).someSelected,
|
|
1705
|
+
onChange: d[8] ||= (e) => v(E).toggleSelectAll()
|
|
1706
|
+
}, null, 40, Xe)], 4)) : r("", !0),
|
|
1707
|
+
(p(!0), i(e, null, m(v(E).visibleColumns, (e) => (p(), i("th", {
|
|
1708
|
+
key: e.field,
|
|
1709
|
+
"data-field": e.field,
|
|
1710
|
+
style: u(X(e)),
|
|
1711
|
+
class: l(ne.value === e.field ? "inandu-drag-over" : void 0),
|
|
1712
|
+
draggable: e.reorder !== !1,
|
|
1713
|
+
"aria-label": D.value("MsgSortBy", { column: e.headerText ?? e.field }),
|
|
1714
|
+
onDragstart: (t) => Te(t, e.field),
|
|
1715
|
+
onDragover: (t) => Ee(t, e.field),
|
|
1716
|
+
onDragleave: (t) => De(e.field),
|
|
1717
|
+
onDrop: (t) => Oe(t, e.field),
|
|
1718
|
+
onClick: (t) => v(E).toggleSort(e.field, t.shiftKey)
|
|
1719
|
+
}, [
|
|
1720
|
+
s(v(W), { nodes: je(e) }, null, 8, ["nodes"]),
|
|
1721
|
+
o(g(v(E).sortDirectionFor(e.field) ? v(E).sortDirectionFor(e.field) === "asc" ? " ▲" : " ▼" : ""), 1),
|
|
1722
|
+
v(E).sortPriorityFor(e.field) === void 0 ? r("", !0) : (p(), i("sup", Qe, g(v(E).sortPriorityFor(e.field)), 1)),
|
|
1723
|
+
a("span", {
|
|
1724
|
+
class: "inandu-grid-resize-handle",
|
|
1725
|
+
draggable: "false",
|
|
1726
|
+
onMousedown: (t) => se(t, e.field),
|
|
1727
|
+
onDblclick: (t) => k(t, e),
|
|
1728
|
+
onClick: d[9] ||= b(() => {}, ["stop"])
|
|
1729
|
+
}, null, 40, $e)
|
|
1730
|
+
], 46, Ze))), 128)),
|
|
1731
|
+
V.value ? (p(), i("th", et)) : r("", !0)
|
|
1732
|
+
]), a("tr", tt, [
|
|
1733
|
+
U.value ? (p(), i("th", nt)) : r("", !0),
|
|
1734
|
+
H.value ? (p(), i("th", rt)) : r("", !0),
|
|
1735
|
+
c.selectable ? (p(), i("th", {
|
|
1736
|
+
key: 2,
|
|
1737
|
+
style: u(Z.value)
|
|
1738
|
+
}, null, 4)) : r("", !0),
|
|
1739
|
+
(p(!0), i(e, null, m(v(E).visibleColumns, (e) => (p(), i("th", {
|
|
1740
|
+
key: e.field,
|
|
1741
|
+
style: u(X(e))
|
|
1742
|
+
}, [s(Le, {
|
|
1743
|
+
column: e,
|
|
1744
|
+
value: v(E).filterValues[e.field],
|
|
1745
|
+
t: D.value,
|
|
1746
|
+
onChange: (t) => Y(e.field, t)
|
|
1747
|
+
}, null, 8, [
|
|
1748
|
+
"column",
|
|
1749
|
+
"value",
|
|
1750
|
+
"t",
|
|
1751
|
+
"onChange"
|
|
1752
|
+
])], 4))), 128)),
|
|
1753
|
+
V.value ? (p(), i("th", it)) : r("", !0)
|
|
1754
|
+
])]),
|
|
1755
|
+
a("tbody", null, [v(E).isAddingRow ? (p(), i("tr", at, [
|
|
1756
|
+
c.selectable ? (p(), i("td", {
|
|
1757
|
+
key: 0,
|
|
1758
|
+
style: u(Z.value)
|
|
1759
|
+
}, null, 4)) : r("", !0),
|
|
1760
|
+
(p(!0), i(e, null, m(v(E).visibleColumns, (t) => (p(), i("td", {
|
|
1761
|
+
key: t.field,
|
|
1762
|
+
style: u(X(t))
|
|
1763
|
+
}, [t.editable ? (p(), i(e, { key: 0 }, [$(t, {}) === void 0 ? (p(), n(xe, {
|
|
1764
|
+
key: 1,
|
|
1765
|
+
column: t,
|
|
1766
|
+
value: v(E).rowDraft[t.field],
|
|
1767
|
+
error: v(E).fieldErrors[t.field],
|
|
1768
|
+
t: D.value,
|
|
1769
|
+
onChange: (e) => v(E).setRowDraftValue(t.field, e)
|
|
1770
|
+
}, null, 8, [
|
|
1771
|
+
"column",
|
|
1772
|
+
"value",
|
|
1773
|
+
"error",
|
|
1774
|
+
"t",
|
|
1775
|
+
"onChange"
|
|
1776
|
+
])) : (p(), n(v(W), {
|
|
1777
|
+
key: 0,
|
|
1778
|
+
nodes: $(t, {})
|
|
1779
|
+
}, null, 8, ["nodes"]))], 64)) : r("", !0)], 4))), 128)),
|
|
1780
|
+
V.value ? (p(), i("td", ot, [a("button", {
|
|
1781
|
+
type: "button",
|
|
1782
|
+
disabled: v(E).isValidating,
|
|
1783
|
+
onClick: d[10] ||= (e) => void v(E).saveNewRow()
|
|
1784
|
+
}, g(D.value("MsgSaveRow")), 9, st), a("button", {
|
|
1785
|
+
type: "button",
|
|
1786
|
+
disabled: v(E).isValidating,
|
|
1787
|
+
onClick: d[11] ||= (e) => v(E).cancelAddRow()
|
|
1788
|
+
}, g(D.value("MsgCancelRowEdit")), 9, ct)])) : r("", !0)
|
|
1789
|
+
])) : r("", !0), he.value ? (p(), i("tr", lt, [a("td", { colspan: G.value }, g(D.value("MsgNoData")), 9, ut)])) : v(E).hasTreeData ? (p(!0), i(e, { key: 2 }, m(v(E).treeRows, (t, o) => (p(), i("tr", {
|
|
1790
|
+
key: Fe(t.row, o),
|
|
1791
|
+
"aria-level": t.depth + 1,
|
|
1792
|
+
"aria-expanded": t.expandable ? v(E).isTreeRowExpanded(t.row) : void 0
|
|
1793
|
+
}, [
|
|
1794
|
+
c.selectable ? (p(), i("td", {
|
|
1795
|
+
key: 0,
|
|
1796
|
+
style: u(Z.value)
|
|
1797
|
+
}, [a("input", {
|
|
1798
|
+
"aria-label": D.value("MsgSelectRow", { index: o + 1 }),
|
|
1799
|
+
type: "checkbox",
|
|
1800
|
+
checked: v(E).isRowSelected(t.row),
|
|
1801
|
+
onChange: (e) => v(E).toggleRowSelection(t.row)
|
|
1802
|
+
}, null, 40, ft)], 4)) : r("", !0),
|
|
1803
|
+
(p(!0), i(e, null, m(v(E).visibleColumns, (e, r) => (p(), i("td", {
|
|
1804
|
+
key: e.field,
|
|
1805
|
+
style: u(X(e))
|
|
1806
|
+
}, [r === 0 ? (p(), i("span", {
|
|
1807
|
+
key: 0,
|
|
1808
|
+
class: "inandu-grid-tree-cell",
|
|
1809
|
+
style: u({ paddingInlineStart: `${t.depth * 16}px` })
|
|
1810
|
+
}, [t.expandable ? (p(), i("button", {
|
|
1811
|
+
key: 0,
|
|
1812
|
+
type: "button",
|
|
1813
|
+
class: "inandu-grid-tree-toggle",
|
|
1814
|
+
"aria-label": v(E).isTreeRowExpanded(t.row) ? D.value("MsgCollapseDetail") : D.value("MsgExpandDetail"),
|
|
1815
|
+
title: v(E).isTreeRowExpanded(t.row) ? D.value("MsgCollapseDetail") : D.value("MsgExpandDetail"),
|
|
1816
|
+
onClick: (e) => v(E).toggleTreeRow(t.row)
|
|
1817
|
+
}, g(v(E).isTreeRowExpanded(t.row) ? "▾" : "▸"), 9, pt)) : (p(), i("span", mt)), s(v(W), { nodes: Q(e, t.row) }, null, 8, ["nodes"])], 4)) : (p(), n(v(W), {
|
|
1818
|
+
key: 1,
|
|
1819
|
+
nodes: Q(e, t.row)
|
|
1820
|
+
}, null, 8, ["nodes"]))], 4))), 128)),
|
|
1821
|
+
V.value ? (p(), i("td", ht)) : r("", !0)
|
|
1822
|
+
], 8, dt))), 128)) : v(E).groups ? (p(!0), i(e, { key: 3 }, m(v(E).groups, (t) => (p(), i(e, { key: t.key }, [a("tr", gt, [a("td", { colspan: G.value }, [
|
|
1823
|
+
a("strong", null, g(t.key), 1),
|
|
1824
|
+
o(" (" + g(t.rows.length) + ") ", 1),
|
|
1825
|
+
z.value.length > 0 ? (p(), i("span", vt, [(p(!0), i(e, null, m(z.value, (e) => (p(), i("span", { key: e.field }, " · " + g(Ae(e, t.aggregates)), 1))), 128))])) : r("", !0)
|
|
1826
|
+
], 8, _t)]), (p(!0), i(e, null, m(t.rows, (e, r) => (p(), n(ke, {
|
|
1827
|
+
key: Fe(e, `${t.key}:${r}`),
|
|
1828
|
+
ctx: Ie.value,
|
|
1829
|
+
row: e,
|
|
1830
|
+
"row-index": r
|
|
1831
|
+
}, null, 8, [
|
|
1832
|
+
"ctx",
|
|
1833
|
+
"row",
|
|
1834
|
+
"row-index"
|
|
1835
|
+
]))), 128))], 64))), 128)) : (p(), i(e, { key: 4 }, [
|
|
1836
|
+
v(E).hasVirtualScroll && Ce.value > 0 ? (p(), i("tr", yt, [a("td", {
|
|
1837
|
+
style: u({
|
|
1838
|
+
height: `${Ce.value}px`,
|
|
1839
|
+
padding: 0,
|
|
1840
|
+
border: "none"
|
|
1841
|
+
}),
|
|
1842
|
+
colspan: G.value
|
|
1843
|
+
}, null, 12, bt)])) : r("", !0),
|
|
1844
|
+
(p(!0), i(e, null, m(q.value, (e, t) => (p(), n(ke, {
|
|
1845
|
+
key: Fe(e, K.value + t),
|
|
1846
|
+
ctx: Ie.value,
|
|
1847
|
+
row: e,
|
|
1848
|
+
"row-index": K.value + t,
|
|
1849
|
+
"has-row-drag-handle": H.value,
|
|
1850
|
+
"is-drag-over-row": v(E).draggingRow !== void 0 && re.value === e,
|
|
1851
|
+
"has-master-detail": U.value,
|
|
1852
|
+
"is-row-expanded": v(E).isRowExpanded(e),
|
|
1853
|
+
onRowDragStart: (t) => v(E).onRowDragStart(e),
|
|
1854
|
+
onRowDragOver: (t) => re.value = e,
|
|
1855
|
+
onRowDragLeave: (t) => re.value === e && (re.value = void 0),
|
|
1856
|
+
onRowDrop: (t) => v(E).onRowDrop(e),
|
|
1857
|
+
onToggleExpanded: (t) => v(E).toggleRowExpanded(e)
|
|
1858
|
+
}, null, 8, [
|
|
1859
|
+
"ctx",
|
|
1860
|
+
"row",
|
|
1861
|
+
"row-index",
|
|
1862
|
+
"has-row-drag-handle",
|
|
1863
|
+
"is-drag-over-row",
|
|
1864
|
+
"has-master-detail",
|
|
1865
|
+
"is-row-expanded",
|
|
1866
|
+
"onRowDragStart",
|
|
1867
|
+
"onRowDragOver",
|
|
1868
|
+
"onRowDragLeave",
|
|
1869
|
+
"onRowDrop",
|
|
1870
|
+
"onToggleExpanded"
|
|
1871
|
+
]))), 128)),
|
|
1872
|
+
v(E).hasVirtualScroll && we.value > 0 ? (p(), i("tr", xt, [a("td", {
|
|
1873
|
+
style: u({
|
|
1874
|
+
height: `${we.value}px`,
|
|
1875
|
+
padding: 0,
|
|
1876
|
+
border: "none"
|
|
1877
|
+
}),
|
|
1878
|
+
colspan: G.value
|
|
1879
|
+
}, null, 12, St)])) : r("", !0)
|
|
1880
|
+
], 64))]),
|
|
1881
|
+
z.value.length > 0 && !v(E).hasVirtualScroll ? (p(), i("tfoot", Ct, [a("tr", wt, [
|
|
1882
|
+
U.value ? (p(), i("td", Tt)) : r("", !0),
|
|
1883
|
+
H.value ? (p(), i("td", Et)) : r("", !0),
|
|
1884
|
+
c.selectable ? (p(), i("td", {
|
|
1885
|
+
key: 2,
|
|
1886
|
+
style: u(Z.value)
|
|
1887
|
+
}, null, 4)) : r("", !0),
|
|
1888
|
+
(p(!0), i(e, null, m(v(E).visibleColumns, (e) => (p(), i("td", {
|
|
1889
|
+
key: e.field,
|
|
1890
|
+
style: u(X(e))
|
|
1891
|
+
}, g(e.aggregate ? Ae(e, v(E).totals) : ""), 5))), 128)),
|
|
1892
|
+
V.value ? (p(), i("td", Dt)) : r("", !0)
|
|
1893
|
+
])])) : r("", !0)
|
|
1894
|
+
], 544)], 38),
|
|
1895
|
+
c.pageSize > 0 && !v(E).groupByField && !v(E).hasVirtualScroll ? (p(), i("div", Ot, [
|
|
1896
|
+
a("button", {
|
|
1897
|
+
type: "button",
|
|
1898
|
+
disabled: v(E).page === 0,
|
|
1899
|
+
onClick: d[12] ||= (e) => v(E).setPage(v(E).page - 1)
|
|
1900
|
+
}, "‹ " + g(D.value("MsgPreviousPage")), 9, kt),
|
|
1901
|
+
a("span", null, g(D.value("MsgPageOf", {
|
|
1902
|
+
page: v(E).page + 1,
|
|
1903
|
+
total: v(E).pageCount
|
|
1904
|
+
})) + " (" + g(v(E).filteredRowCount) + ")", 1),
|
|
1905
|
+
a("button", {
|
|
1906
|
+
type: "button",
|
|
1907
|
+
disabled: v(E).page >= v(E).pageCount - 1,
|
|
1908
|
+
onClick: d[13] ||= (e) => v(E).setPage(v(E).page + 1)
|
|
1909
|
+
}, g(D.value("MsgNextPage")) + " ›", 9, At)
|
|
1910
|
+
])) : r("", !0)
|
|
1911
|
+
]));
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1914
|
+
//#endregion
|
|
1915
|
+
//#region src/composables/useInanduGridServer.ts
|
|
1916
|
+
function Mt(e, t = {}) {
|
|
1917
|
+
let n = new URLSearchParams();
|
|
1918
|
+
n.set("page", String(e.page + 1)), e.pageSize > 0 && n.set("pageSize", String(e.pageSize)), e.sortCriteria.length > 0 && n.set("sort", e.sortCriteria.map((e) => (e.direction === "desc" ? "-" : "") + e.field).join(","));
|
|
1919
|
+
let r = e.filterQuery.trim();
|
|
1920
|
+
r && n.set("q", r);
|
|
1921
|
+
for (let [t, r] of Object.entries(e.filterValues)) re(r) && (r.values && r.values.length > 0 ? n.set(`${t}_in`, r.values.join(",")) : (r.text && n.set(`${t}_contains`, r.text), r.min && n.set(`${t}_gte`, r.min), r.max && n.set(`${t}_lte`, r.max), r.from && n.set(`${t}_gte`, r.from), r.to && n.set(`${t}_lte`, r.to), (r.bool === "true" || r.bool === "false") && n.set(`${t}_eq`, r.bool)));
|
|
1922
|
+
for (let [e, r] of Object.entries(t.extraParams ?? {})) n.set(e, r);
|
|
1923
|
+
return n;
|
|
1924
|
+
}
|
|
1925
|
+
function Nt(e) {
|
|
1926
|
+
let t = h(void 0), n = h([]), r = h(0), i = h(!1), a = h(void 0), o = h(0), s = !1, c;
|
|
1927
|
+
function l(t) {
|
|
1928
|
+
c?.();
|
|
1929
|
+
let o = new AbortController(), l = async () => {
|
|
1930
|
+
u(!0), a.value = void 0;
|
|
1931
|
+
try {
|
|
1932
|
+
let i = Mt(t, { extraParams: e.extraParams }).toString(), a = e.url + (e.url.includes("?") ? "&" : "?") + i, s = {
|
|
1933
|
+
...e.init,
|
|
1934
|
+
signal: o.signal
|
|
1935
|
+
}, c = await (e.fetcher ?? fetch)(a, s);
|
|
1936
|
+
if (!c.ok) throw Error(`Request failed: ${c.status} ${c.statusText}`);
|
|
1937
|
+
let l = await c.json();
|
|
1938
|
+
if (o.signal.aborted) return;
|
|
1939
|
+
n.value = l.data ?? [], r.value = l.total ?? 0;
|
|
1940
|
+
} catch (e) {
|
|
1941
|
+
if (o.signal.aborted) return;
|
|
1942
|
+
a.value = e instanceof Error ? e : Error(String(e));
|
|
1943
|
+
} finally {
|
|
1944
|
+
o.signal.aborted || u(!1);
|
|
1945
|
+
}
|
|
1946
|
+
};
|
|
1947
|
+
function u(e) {
|
|
1948
|
+
i.value = e;
|
|
1949
|
+
}
|
|
1950
|
+
let d = s ? e.debounceMs ?? 200 : 0;
|
|
1951
|
+
s = !0;
|
|
1952
|
+
let f = setTimeout(l, d);
|
|
1953
|
+
c = () => {
|
|
1954
|
+
clearTimeout(f), o.abort();
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
return ee([t, o], () => {
|
|
1958
|
+
t.value && l(t.value);
|
|
1959
|
+
}), f(() => c?.(), !0), {
|
|
1960
|
+
rows: n,
|
|
1961
|
+
total: r,
|
|
1962
|
+
loading: i,
|
|
1963
|
+
error: a,
|
|
1964
|
+
setQuery: (e) => {
|
|
1965
|
+
t.value = e;
|
|
1966
|
+
},
|
|
1967
|
+
reload: () => {
|
|
1968
|
+
o.value += 1;
|
|
1969
|
+
}
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
//#endregion
|
|
1973
|
+
export { O as AGGREGATE_SYMBOLS, R as INANDU_GRID_TRANSLATIONS, jt as InanduGrid, B as buildCsv, he as buildExcelXml, Mt as buildInanduGridQuery, E as compareCellValues, ae as computeGroupAggregates, ue as createTranslator, P as en, F as es, me as exportCsv, ge as exportExcel, ve as exportPdf, T as formatCellValue, I as fr, le as interpolate, ce as it, ie as matchesColumnFilter, ye as measureColumnContentWidth, _e as printTable, fe as useInanduGrid, Nt as useInanduGridServer, L as zh };
|