@mikestools/usetable 0.0.1
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/README.md +519 -0
- package/dist/index.d.ts +504 -0
- package/dist/usetable.js +1615 -0
- package/dist/usetable.umd.cjs +7 -0
- package/package.json +102 -0
package/dist/usetable.js
ADDED
|
@@ -0,0 +1,1615 @@
|
|
|
1
|
+
import { shallowRef as Ft, ref as p, watch as L, computed as m, customRef as Ce } from "vue";
|
|
2
|
+
function Tt(l) {
|
|
3
|
+
return typeof l != "object" || l === null || !("row" in l) || !("column" in l) || !("message" in l) || !("value" in l) ? !1 : typeof l.row == "number" && typeof l.column == "number" && typeof l.message == "string";
|
|
4
|
+
}
|
|
5
|
+
function Gr(l) {
|
|
6
|
+
return Array.isArray(l) && l.every(Tt);
|
|
7
|
+
}
|
|
8
|
+
function Xr(l) {
|
|
9
|
+
return typeof l != "object" || l === null || !("valid" in l) || !("errors" in l) ? !1 : typeof l.valid == "boolean" && Array.isArray(l.errors) && l.errors.every(Tt);
|
|
10
|
+
}
|
|
11
|
+
function me(l) {
|
|
12
|
+
return l === null || typeof l != "object" || "nodeType" in l ? !1 : "value" in l;
|
|
13
|
+
}
|
|
14
|
+
const zr = /* @__PURE__ */ new Set([
|
|
15
|
+
"opacity",
|
|
16
|
+
"z-index",
|
|
17
|
+
"font-weight",
|
|
18
|
+
"line-height",
|
|
19
|
+
"flex",
|
|
20
|
+
"flex-grow",
|
|
21
|
+
"flex-shrink",
|
|
22
|
+
"flex-basis",
|
|
23
|
+
"order",
|
|
24
|
+
"zoom",
|
|
25
|
+
"counter-increment",
|
|
26
|
+
"counter-reset",
|
|
27
|
+
"orphans",
|
|
28
|
+
"widows",
|
|
29
|
+
"fill-opacity",
|
|
30
|
+
"flood-opacity",
|
|
31
|
+
"stop-opacity",
|
|
32
|
+
"stroke-opacity",
|
|
33
|
+
"stroke-miterlimit",
|
|
34
|
+
"column-count",
|
|
35
|
+
"tab-size"
|
|
36
|
+
]);
|
|
37
|
+
function Pr(l) {
|
|
38
|
+
return !zr.has(l);
|
|
39
|
+
}
|
|
40
|
+
function ve(l, u) {
|
|
41
|
+
if (!u) return;
|
|
42
|
+
if (u.class !== void 0 && (typeof u.class == "string" ? l.className = u.class : Array.isArray(u.class) ? l.className = u.class.join(" ") : l.className = Object.entries(u.class).filter(([, h]) => h).map(([h]) => h).join(" ")), u.style !== void 0) {
|
|
43
|
+
if (typeof u.style == "string")
|
|
44
|
+
l.setAttribute("style", u.style);
|
|
45
|
+
else if (typeof u.style == "object")
|
|
46
|
+
for (const [h, v] of Object.entries(u.style)) {
|
|
47
|
+
if (v == null) continue;
|
|
48
|
+
const C = h.replace(/([A-Z])/g, "-$1").toLowerCase(), le = typeof v == "number" && Pr(C) ? `${v}px` : String(v);
|
|
49
|
+
l.style.setProperty(C, le);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (u.dataset)
|
|
53
|
+
for (const [h, v] of Object.entries(u.dataset))
|
|
54
|
+
v != null && (l.dataset[h] = String(v));
|
|
55
|
+
u.id !== void 0 && (l.id = u.id), u.title !== void 0 && (l.title = u.title);
|
|
56
|
+
const c = /* @__PURE__ */ new Set(["class", "style", "dataset", "id", "title"]);
|
|
57
|
+
for (const [h, v] of Object.entries(u))
|
|
58
|
+
c.has(h) || v === void 0 || v === null || (h.startsWith("on") && typeof v == "function" ? l.addEventListener(h.slice(2).toLowerCase(), v) : h.startsWith("data-") || h.startsWith("aria-") || h === "role" ? l.setAttribute(h, String(v)) : h in l ? typeof v == "boolean" ? v ? l.setAttribute(h, "") : l.removeAttribute(h) : l.setAttribute(h, String(v)) : typeof v == "boolean" ? v && l.setAttribute(h, "") : l.setAttribute(h, String(v)));
|
|
59
|
+
}
|
|
60
|
+
function ye(l, u) {
|
|
61
|
+
const c = document.createElement("th");
|
|
62
|
+
return c.textContent = l, u?.scope || (c.scope = "col"), ve(c, u), c;
|
|
63
|
+
}
|
|
64
|
+
function S(l, u) {
|
|
65
|
+
let c = u, h, v, C;
|
|
66
|
+
u instanceof Node ? c = u : me(u) && (c = u.value, h = u.attributes, v = u.columnSpan, C = u.rowSpan), c == null ? l.textContent = "" : c instanceof Node ? (l.textContent = "", l.appendChild(c)) : l.textContent = String(c), v !== void 0 && v > 1 && (l.colSpan = v), C !== void 0 && C > 0 && (l.rowSpan = C), ve(l, h);
|
|
67
|
+
}
|
|
68
|
+
function te(l) {
|
|
69
|
+
return l.children.length === 1 && l.textContent === l.children[0]?.textContent ? l.children[0] : l.textContent || "";
|
|
70
|
+
}
|
|
71
|
+
function Br(l) {
|
|
72
|
+
const u = p(l);
|
|
73
|
+
return {
|
|
74
|
+
element: u,
|
|
75
|
+
cellIndex: m(() => u.value.cellIndex),
|
|
76
|
+
columnSpan: m({ get: () => u.value.colSpan, set: (c) => {
|
|
77
|
+
u.value.colSpan = c;
|
|
78
|
+
} }),
|
|
79
|
+
rowSpan: m({ get: () => u.value.rowSpan, set: (c) => {
|
|
80
|
+
u.value.rowSpan = c;
|
|
81
|
+
} }),
|
|
82
|
+
headers: m({ get: () => u.value.headers, set: (c) => {
|
|
83
|
+
u.value.headers = c;
|
|
84
|
+
} }),
|
|
85
|
+
abbr: m({ get: () => u.value.abbr, set: (c) => {
|
|
86
|
+
u.value.abbr = c;
|
|
87
|
+
} }),
|
|
88
|
+
scope: m({ get: () => u.value.scope, set: (c) => {
|
|
89
|
+
u.value.scope = c;
|
|
90
|
+
} })
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function Ht(l) {
|
|
94
|
+
const u = p(l), c = Ce(() => ({ get: () => Array.from(u.value.cells), set: () => {
|
|
95
|
+
} })), h = Ce(() => ({ get: () => u.value.cells.length, set: () => {
|
|
96
|
+
} }));
|
|
97
|
+
return {
|
|
98
|
+
element: u,
|
|
99
|
+
cells: c,
|
|
100
|
+
cellCount: h,
|
|
101
|
+
rowIndex: m(() => u.value.rowIndex),
|
|
102
|
+
sectionRowIndex: m(() => u.value.sectionRowIndex),
|
|
103
|
+
insertCell: (v) => u.value.insertCell(v),
|
|
104
|
+
deleteCell: (v) => u.value.deleteCell(v),
|
|
105
|
+
getCell: (v) => {
|
|
106
|
+
const C = u.value.cells[v];
|
|
107
|
+
return C ? Br(C) : void 0;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function Oe(l) {
|
|
112
|
+
const u = p(l), c = Ce(() => ({ get: () => Array.from(u.value.rows), set: () => {
|
|
113
|
+
} })), h = Ce(() => ({ get: () => u.value.rows.length, set: () => {
|
|
114
|
+
} }));
|
|
115
|
+
return {
|
|
116
|
+
element: u,
|
|
117
|
+
rows: c,
|
|
118
|
+
rowCount: h,
|
|
119
|
+
insertRow: (v) => u.value.insertRow(v),
|
|
120
|
+
deleteRow: (v) => u.value.deleteRow(v),
|
|
121
|
+
getRow: (v) => {
|
|
122
|
+
const C = u.value.rows[v];
|
|
123
|
+
return C ? Ht(C) : void 0;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function Mt(l) {
|
|
128
|
+
return l.includes(",") || l.includes('"') || l.includes(`
|
|
129
|
+
`) ? `"${l.replace(/"/g, '""')}"` : l;
|
|
130
|
+
}
|
|
131
|
+
function Lt(l) {
|
|
132
|
+
const u = [];
|
|
133
|
+
let c = "", h = !1;
|
|
134
|
+
for (let v = 0; v < l.length; v++) {
|
|
135
|
+
const C = l[v];
|
|
136
|
+
C === '"' ? h && v + 1 < l.length && l[v + 1] === '"' ? (c += '"', v++) : h = !h : C === "," && !h ? (u.push(c), c = "") : c += C;
|
|
137
|
+
}
|
|
138
|
+
return u.push(c), u;
|
|
139
|
+
}
|
|
140
|
+
function qr(l) {
|
|
141
|
+
const u = Ft([]), c = Ft([]), h = p(null), v = p(null), C = p(null), le = p(0), b = () => {
|
|
142
|
+
le.value++;
|
|
143
|
+
}, T = () => {
|
|
144
|
+
l.value && (u.value = Array.from(l.value.rows), c.value = Array.from(l.value.tBodies), h.value = l.value.caption, v.value = l.value.tHead, C.value = l.value.tFoot);
|
|
145
|
+
}, F = () => {
|
|
146
|
+
T(), b();
|
|
147
|
+
};
|
|
148
|
+
T(), L(l, F, { immediate: !0, deep: !1 });
|
|
149
|
+
const Re = m(() => u.value), kt = m(() => Re.value.length), Se = m(() => c.value), Nt = m(() => Se.value.length), Vt = m({
|
|
150
|
+
get: () => h.value,
|
|
151
|
+
set: (e) => {
|
|
152
|
+
l.value.caption = e, h.value = e;
|
|
153
|
+
}
|
|
154
|
+
}), zt = m({
|
|
155
|
+
get: () => v.value,
|
|
156
|
+
set: (e) => {
|
|
157
|
+
l.value.tHead = e, v.value = e;
|
|
158
|
+
}
|
|
159
|
+
}), Pt = m({
|
|
160
|
+
get: () => C.value,
|
|
161
|
+
set: (e) => {
|
|
162
|
+
l.value.tFoot = e, C.value = e;
|
|
163
|
+
}
|
|
164
|
+
}), g = m({
|
|
165
|
+
get: () => {
|
|
166
|
+
le.value;
|
|
167
|
+
const e = l.value.tHead;
|
|
168
|
+
return !e || e.rows.length === 0 ? [] : Array.from(e.rows[0].cells).map((t) => t.textContent || "");
|
|
169
|
+
},
|
|
170
|
+
set: (e) => {
|
|
171
|
+
let t = l.value.tHead;
|
|
172
|
+
for (t || (t = l.value.createTHead()); t.rows.length > 0; ) t.deleteRow(0);
|
|
173
|
+
const o = t.insertRow();
|
|
174
|
+
e.forEach((n) => {
|
|
175
|
+
const s = document.createElement("th");
|
|
176
|
+
s.textContent = n, s.scope = "col", o.appendChild(s);
|
|
177
|
+
}), F();
|
|
178
|
+
}
|
|
179
|
+
}), i = m({
|
|
180
|
+
get: () => {
|
|
181
|
+
le.value;
|
|
182
|
+
const e = c.value[0];
|
|
183
|
+
return e ? Array.from(e.rows).map((t) => Array.from(t.cells).map(te)) : [];
|
|
184
|
+
},
|
|
185
|
+
set: (e) => {
|
|
186
|
+
let t = c.value[0];
|
|
187
|
+
for (t || (t = l.value.createTBody()); t.rows.length > 0; ) t.deleteRow(0);
|
|
188
|
+
e.forEach((o) => {
|
|
189
|
+
const n = t.insertRow();
|
|
190
|
+
o.forEach((s) => S(n.insertCell(), s));
|
|
191
|
+
}), F();
|
|
192
|
+
}
|
|
193
|
+
}), Bt = m(() => g.value.length), je = () => {
|
|
194
|
+
const e = l.value.createCaption();
|
|
195
|
+
return T(), e;
|
|
196
|
+
}, We = () => {
|
|
197
|
+
l.value.deleteCaption(), T();
|
|
198
|
+
}, Kt = () => {
|
|
199
|
+
const e = l.value.createTHead();
|
|
200
|
+
return T(), e;
|
|
201
|
+
}, Ue = () => {
|
|
202
|
+
l.value.deleteTHead(), T();
|
|
203
|
+
}, Je = () => {
|
|
204
|
+
const e = l.value.createTFoot();
|
|
205
|
+
return T(), e;
|
|
206
|
+
}, Qe = () => {
|
|
207
|
+
l.value.deleteTFoot(), T();
|
|
208
|
+
}, $t = () => {
|
|
209
|
+
const e = l.value.createTBody();
|
|
210
|
+
return T(), e;
|
|
211
|
+
}, Ot = (e) => {
|
|
212
|
+
const t = l.value.insertRow(e);
|
|
213
|
+
return T(), t;
|
|
214
|
+
}, jt = (e) => {
|
|
215
|
+
l.value.deleteRow(e), T();
|
|
216
|
+
}, Wt = () => {
|
|
217
|
+
const e = l.value.tHead;
|
|
218
|
+
return e ? Oe(e) : void 0;
|
|
219
|
+
}, Ut = () => {
|
|
220
|
+
const e = l.value.tFoot;
|
|
221
|
+
return e ? Oe(e) : void 0;
|
|
222
|
+
}, Jt = (e) => {
|
|
223
|
+
const t = Se.value[e];
|
|
224
|
+
return t ? Oe(t) : void 0;
|
|
225
|
+
}, Qt = (e) => {
|
|
226
|
+
const t = Re.value[e];
|
|
227
|
+
return t ? Ht(t) : void 0;
|
|
228
|
+
}, we = (e, t) => {
|
|
229
|
+
let o = c.value[0];
|
|
230
|
+
o || (o = l.value.createTBody(), F());
|
|
231
|
+
const n = t === void 0 || t === -1 ? o.rows.length : t, s = o.insertRow(n);
|
|
232
|
+
return e.forEach((r) => S(s.insertCell(), r)), F(), s;
|
|
233
|
+
}, _e = (e) => {
|
|
234
|
+
const t = c.value[0];
|
|
235
|
+
t && (e === -1 && t.rows.length > 0 ? t.deleteRow(-1) : e >= 0 && e < t.rows.length && t.deleteRow(e), F());
|
|
236
|
+
}, Ye = (e = "", t = "", o) => {
|
|
237
|
+
const n = g.value.length, s = o === void 0 || o === -1 ? n : o;
|
|
238
|
+
let r = l.value.tHead;
|
|
239
|
+
r || (r = l.value.createTHead(), r.insertRow()), r.rows.length === 0 && r.insertRow();
|
|
240
|
+
const a = r.rows[0], f = ye(e);
|
|
241
|
+
s >= a.cells.length ? a.appendChild(f) : a.insertBefore(f, a.cells[s]);
|
|
242
|
+
const d = c.value[0];
|
|
243
|
+
d && Array.from(d.rows).forEach((y) => {
|
|
244
|
+
const R = y.insertCell(s >= y.cells.length ? -1 : s);
|
|
245
|
+
S(R, t);
|
|
246
|
+
});
|
|
247
|
+
const w = l.value.tFoot;
|
|
248
|
+
if (w && w.rows.length > 0) {
|
|
249
|
+
const y = w.rows[0];
|
|
250
|
+
y.insertCell(s >= y.cells.length ? -1 : s).textContent = "";
|
|
251
|
+
}
|
|
252
|
+
F();
|
|
253
|
+
}, Ze = (e) => {
|
|
254
|
+
if (e < 0 || e >= g.value.length) return;
|
|
255
|
+
const t = l.value.tHead;
|
|
256
|
+
t && t.rows.length > 0 && t.rows[0].cells[e] && t.rows[0].deleteCell(e);
|
|
257
|
+
const o = c.value[0];
|
|
258
|
+
o && Array.from(o.rows).forEach((s) => {
|
|
259
|
+
s.cells[e] && s.deleteCell(e);
|
|
260
|
+
});
|
|
261
|
+
const n = l.value.tFoot;
|
|
262
|
+
n && n.rows.length > 0 && n.rows[0].cells[e] && n.rows[0].deleteCell(e), F();
|
|
263
|
+
}, be = (e, t, o) => {
|
|
264
|
+
const n = c.value[0];
|
|
265
|
+
if (!n) return;
|
|
266
|
+
const s = n.rows[e];
|
|
267
|
+
if (!s) return;
|
|
268
|
+
const r = s.cells[t];
|
|
269
|
+
r && (S(r, o), b());
|
|
270
|
+
}, ae = (e, t) => i.value[e]?.[t], _t = (e) => {
|
|
271
|
+
const t = l.value.caption || je();
|
|
272
|
+
t.textContent = e;
|
|
273
|
+
}, j = (e) => {
|
|
274
|
+
g.value = [...e];
|
|
275
|
+
}, Yt = (e) => {
|
|
276
|
+
let t = l.value.tFoot;
|
|
277
|
+
for (t || (t = Je()); t.rows.length > 0; ) t.deleteRow(0);
|
|
278
|
+
const o = t.insertRow();
|
|
279
|
+
e.forEach((n) => S(o.insertCell(), n));
|
|
280
|
+
}, V = (e) => {
|
|
281
|
+
i.value = e.map((t) => [...t]);
|
|
282
|
+
}, Zt = () => {
|
|
283
|
+
i.value = [];
|
|
284
|
+
}, Gt = () => {
|
|
285
|
+
for (We(), Ue(), Qe(); c.value.length > 0; ) {
|
|
286
|
+
const e = c.value[0];
|
|
287
|
+
e && l.value.removeChild(e), F();
|
|
288
|
+
}
|
|
289
|
+
}, Xt = () => {
|
|
290
|
+
F();
|
|
291
|
+
}, qt = (e, t, o) => {
|
|
292
|
+
let n = c.value[0];
|
|
293
|
+
n || (n = l.value.createTBody(), F());
|
|
294
|
+
const s = o === void 0 || o === -1 ? n.rows.length : o, r = n.insertRow(s);
|
|
295
|
+
return ve(r, t), e.forEach((a) => S(r.insertCell(), a)), F(), r;
|
|
296
|
+
}, It = (e, t) => {
|
|
297
|
+
const o = g.value.length, n = t === void 0 || t === -1 ? o : t, s = typeof e.header == "string" ? e.header : String(e.header.value), r = typeof e.header == "string" ? void 0 : e.header.attributes, a = e.defaultValue ?? "";
|
|
298
|
+
let f = l.value.tHead;
|
|
299
|
+
f || (f = l.value.createTHead(), f.insertRow()), f.rows.length === 0 && f.insertRow();
|
|
300
|
+
const d = f.rows[0], w = ye(s, r);
|
|
301
|
+
n >= d.cells.length ? d.appendChild(w) : d.insertBefore(w, d.cells[n]);
|
|
302
|
+
const y = c.value[0];
|
|
303
|
+
y && Array.from(y.rows).forEach((R) => {
|
|
304
|
+
const re = R.insertCell(n >= R.cells.length ? -1 : n);
|
|
305
|
+
e.defaultAttributes && ve(re, e.defaultAttributes), S(re, a);
|
|
306
|
+
}), F();
|
|
307
|
+
}, xt = (e) => {
|
|
308
|
+
let t = l.value.tHead;
|
|
309
|
+
for (t || (t = l.value.createTHead()); t.rows.length > 0; ) t.deleteRow(0);
|
|
310
|
+
const o = t.insertRow();
|
|
311
|
+
e.forEach((n) => {
|
|
312
|
+
if (typeof n == "string")
|
|
313
|
+
o.appendChild(ye(n));
|
|
314
|
+
else {
|
|
315
|
+
const s = ye(String(n.value), n.attributes);
|
|
316
|
+
n.columnSpan !== void 0 && (s.colSpan = n.columnSpan), n.rowSpan !== void 0 && (s.rowSpan = n.rowSpan), o.appendChild(s);
|
|
317
|
+
}
|
|
318
|
+
}), F();
|
|
319
|
+
}, Ge = (e, t, o, n) => {
|
|
320
|
+
const s = c.value[0];
|
|
321
|
+
if (!s) return;
|
|
322
|
+
const r = s.rows[e];
|
|
323
|
+
if (!r) return;
|
|
324
|
+
const a = r.cells[t];
|
|
325
|
+
a && (S(a, o), ve(a, n), b());
|
|
326
|
+
}, eo = (e) => {
|
|
327
|
+
const t = i.value[e];
|
|
328
|
+
return t ? [...t] : void 0;
|
|
329
|
+
}, Xe = (e, t) => {
|
|
330
|
+
const o = c.value[0];
|
|
331
|
+
if (!o) return;
|
|
332
|
+
const n = o.rows[e];
|
|
333
|
+
n && (t.forEach((s, r) => {
|
|
334
|
+
n.cells[r] && S(n.cells[r], s);
|
|
335
|
+
}), b());
|
|
336
|
+
}, to = () => i.value.map((e) => [...e]), oo = (e) => e < 0 || e >= g.value.length ? [] : i.value.map((t) => t[e]), no = (e, t) => {
|
|
337
|
+
const o = c.value[0];
|
|
338
|
+
!o || e < 0 || e >= g.value.length || (t.forEach((n, s) => {
|
|
339
|
+
const r = o.rows[s];
|
|
340
|
+
r && r.cells[e] && S(r.cells[e], n);
|
|
341
|
+
}), b());
|
|
342
|
+
}, so = (e, t, o, n) => {
|
|
343
|
+
const s = [];
|
|
344
|
+
for (let r = e; r < t && r < i.value.length; r++) {
|
|
345
|
+
const a = i.value[r], f = [];
|
|
346
|
+
for (let d = o; d < n && d < a.length; d++) f.push(a[d]);
|
|
347
|
+
s.push(f);
|
|
348
|
+
}
|
|
349
|
+
return s;
|
|
350
|
+
}, ro = (e, t, o) => {
|
|
351
|
+
const n = c.value[0];
|
|
352
|
+
n && (o.forEach((s, r) => {
|
|
353
|
+
const a = n.rows[e + r];
|
|
354
|
+
a && s.forEach((f, d) => {
|
|
355
|
+
const w = a.cells[t + d];
|
|
356
|
+
w && S(w, f);
|
|
357
|
+
});
|
|
358
|
+
}), b());
|
|
359
|
+
}, lo = () => [...g.value], ao = () => {
|
|
360
|
+
const e = l.value.tFoot;
|
|
361
|
+
if (!(!e || e.rows.length === 0))
|
|
362
|
+
return Array.from(e.rows[0].cells).map(te);
|
|
363
|
+
}, co = (e, t) => {
|
|
364
|
+
const o = l.value.tFoot;
|
|
365
|
+
if (!o || o.rows.length === 0) return;
|
|
366
|
+
const n = o.rows[0].cells[e];
|
|
367
|
+
n && S(n, t);
|
|
368
|
+
}, uo = (e) => {
|
|
369
|
+
const t = l.value.tFoot;
|
|
370
|
+
if (!t || t.rows.length === 0) return;
|
|
371
|
+
const o = t.rows[0].cells[e];
|
|
372
|
+
return o ? te(o) : void 0;
|
|
373
|
+
}, Ee = (e, t, o) => {
|
|
374
|
+
Ge(e, t, o.value, o.attributes);
|
|
375
|
+
const n = c.value[0];
|
|
376
|
+
if (n && n.rows[e]) {
|
|
377
|
+
const s = n.rows[e].cells[t];
|
|
378
|
+
s && (o.columnSpan !== void 0 && (s.colSpan = o.columnSpan), o.rowSpan !== void 0 && (s.rowSpan = o.rowSpan));
|
|
379
|
+
}
|
|
380
|
+
}, Ae = (e, t) => {
|
|
381
|
+
const o = c.value[0];
|
|
382
|
+
if (!o) return;
|
|
383
|
+
const n = o.rows[e];
|
|
384
|
+
n && (t.forEach((s, r) => {
|
|
385
|
+
const a = n.cells[r];
|
|
386
|
+
a && S(a, s);
|
|
387
|
+
}), b());
|
|
388
|
+
}, qe = (e, t) => {
|
|
389
|
+
const o = c.value[0];
|
|
390
|
+
return o ? o.rows[e]?.cells[t] : void 0;
|
|
391
|
+
}, io = (e) => c.value[0]?.rows[e], fo = (e) => e.filter((t) => t >= 0 && t < i.value.length).map((t) => [...i.value[t]]), vo = (e) => e.filter((t) => t >= 0 && t < g.value.length).map((t) => i.value.map((o) => o[t])), wo = (e) => {
|
|
392
|
+
e.forEach((t, o) => Ae(o, t));
|
|
393
|
+
}, ho = (e) => {
|
|
394
|
+
e.forEach((t, [o, n]) => {
|
|
395
|
+
me(t) ? Ee(o, n, t) : be(o, n, t);
|
|
396
|
+
});
|
|
397
|
+
}, go = () => {
|
|
398
|
+
const e = c.value[0];
|
|
399
|
+
return e ? Array.from(e.rows) : [];
|
|
400
|
+
}, po = (e) => {
|
|
401
|
+
const t = c.value[0];
|
|
402
|
+
return !t || e < 0 || e >= t.rows.length ? [] : Array.from(t.rows[e].cells);
|
|
403
|
+
}, yo = (e, t) => {
|
|
404
|
+
e < 0 || t.forEach((o, n) => {
|
|
405
|
+
const s = e + n;
|
|
406
|
+
if (s < i.value.length)
|
|
407
|
+
Ae(s, o);
|
|
408
|
+
else {
|
|
409
|
+
const r = o.map((a) => me(a) ? a.value : a);
|
|
410
|
+
we(r, s), o.forEach((a, f) => {
|
|
411
|
+
me(a) && (a.attributes || a.columnSpan !== void 0 || a.rowSpan !== void 0) && Ee(s, f, a);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}, mo = (e, t, o) => {
|
|
416
|
+
const n = i.value[e]?.[t], s = o(n);
|
|
417
|
+
return s === !0 ? !0 : { row: e, column: t, value: n, message: typeof s == "string" ? s : "Validation failed" };
|
|
418
|
+
}, Co = (e, t) => {
|
|
419
|
+
const o = i.value[e];
|
|
420
|
+
if (!o) return [{ row: e, column: -1, value: void 0, message: "Row not found" }];
|
|
421
|
+
const n = t([...o]);
|
|
422
|
+
return n === !0 ? !0 : [{ row: e, column: -1, value: o, message: typeof n == "string" ? n : "Validation failed" }];
|
|
423
|
+
}, Ro = (e, t) => {
|
|
424
|
+
const o = [];
|
|
425
|
+
return i.value.forEach((n, s) => {
|
|
426
|
+
const r = n[e], a = t(r);
|
|
427
|
+
a !== !0 && o.push({ row: s, column: e, value: r, message: typeof a == "string" ? a : "Validation failed" });
|
|
428
|
+
}), o.length === 0 ? !0 : o;
|
|
429
|
+
}, So = (e) => {
|
|
430
|
+
const t = [];
|
|
431
|
+
return i.value.forEach((o, n) => {
|
|
432
|
+
o.forEach((s, r) => {
|
|
433
|
+
const a = e(s, n, r);
|
|
434
|
+
a !== null && t.push({ row: n, column: r, value: s, message: a });
|
|
435
|
+
});
|
|
436
|
+
}), { valid: t.length === 0, errors: t };
|
|
437
|
+
}, bo = (e) => i.value.reduce((t, o) => {
|
|
438
|
+
const n = Number(o[e]);
|
|
439
|
+
return t + (isNaN(n) ? 0 : n);
|
|
440
|
+
}, 0), Eo = (e) => {
|
|
441
|
+
let t = 0;
|
|
442
|
+
const o = i.value.reduce((n, s) => {
|
|
443
|
+
const r = Number(s[e]);
|
|
444
|
+
return isNaN(r) ? n : (t++, n + r);
|
|
445
|
+
}, 0);
|
|
446
|
+
return t > 0 ? o / t : 0;
|
|
447
|
+
}, Ao = (e) => {
|
|
448
|
+
const t = i.value.map((o) => o[e]).filter((o) => o != null);
|
|
449
|
+
if (t.length !== 0)
|
|
450
|
+
return t.reduce((o, n) => o < n ? o : n);
|
|
451
|
+
}, Do = (e) => {
|
|
452
|
+
const t = i.value.map((o) => o[e]).filter((o) => o != null);
|
|
453
|
+
if (t.length !== 0)
|
|
454
|
+
return t.reduce((o, n) => o > n ? o : n);
|
|
455
|
+
}, Fo = (e, t) => {
|
|
456
|
+
const o = i.value.map((n) => n[e]);
|
|
457
|
+
return t ? o.filter(t).length : o.length;
|
|
458
|
+
}, Mo = (e, t) => i.value.reduce((o, n, s) => t.reducer(o, n[e], s), t.initial), Lo = (e, t) => {
|
|
459
|
+
const o = c.value[0];
|
|
460
|
+
o && (Array.from(o.rows).forEach((n, s) => {
|
|
461
|
+
const r = n.cells[e];
|
|
462
|
+
if (r) {
|
|
463
|
+
const a = t(te(r), s);
|
|
464
|
+
S(r, a);
|
|
465
|
+
}
|
|
466
|
+
}), b());
|
|
467
|
+
}, To = (e, t) => {
|
|
468
|
+
const o = c.value[0];
|
|
469
|
+
if (!o) return;
|
|
470
|
+
const n = o.rows[e];
|
|
471
|
+
n && (Array.from(n.cells).forEach((s, r) => {
|
|
472
|
+
const a = t(te(s), r);
|
|
473
|
+
S(s, a);
|
|
474
|
+
}), b());
|
|
475
|
+
}, Ho = (e) => {
|
|
476
|
+
const t = c.value[0];
|
|
477
|
+
t && (Array.from(t.rows).forEach((o, n) => {
|
|
478
|
+
Array.from(o.cells).forEach((s, r) => {
|
|
479
|
+
const a = e(te(s), n, r);
|
|
480
|
+
S(s, a);
|
|
481
|
+
});
|
|
482
|
+
}), b());
|
|
483
|
+
}, ko = () => {
|
|
484
|
+
const e = [];
|
|
485
|
+
return g.value.length > 0 && e.push(g.value.map((t) => Mt(t)).join(",")), i.value.forEach((t) => {
|
|
486
|
+
e.push(t.map((o) => Mt(String(o ?? ""))).join(","));
|
|
487
|
+
}), e.join(`
|
|
488
|
+
`);
|
|
489
|
+
}, No = () => JSON.stringify({ headers: g.value, data: i.value }), Vo = (e) => {
|
|
490
|
+
V(e);
|
|
491
|
+
}, zo = (e) => {
|
|
492
|
+
const t = e.split(`
|
|
493
|
+
`).filter((s) => s.trim());
|
|
494
|
+
if (t.length === 0) return;
|
|
495
|
+
const o = Lt(t[0]);
|
|
496
|
+
j(o);
|
|
497
|
+
const n = t.slice(1).map(Lt);
|
|
498
|
+
V(n);
|
|
499
|
+
}, Po = (e) => {
|
|
500
|
+
const t = JSON.parse(e);
|
|
501
|
+
t.headers && j(t.headers), t.data && V(t.data);
|
|
502
|
+
}, Bo = (e, t) => {
|
|
503
|
+
const o = [], n = t?.caseSensitive ? e : e.toLowerCase();
|
|
504
|
+
return i.value.forEach((s, r) => {
|
|
505
|
+
s.forEach((a, f) => {
|
|
506
|
+
const d = String(a ?? "");
|
|
507
|
+
(t?.caseSensitive ? d : d.toLowerCase()).includes(n) && o.push({ row: r, column: f, value: a });
|
|
508
|
+
});
|
|
509
|
+
}), o;
|
|
510
|
+
}, Ko = (e, t, o) => {
|
|
511
|
+
const n = [], s = o?.caseSensitive ? t : t.toLowerCase();
|
|
512
|
+
return i.value.forEach((r, a) => {
|
|
513
|
+
const f = r[e], d = String(f ?? "");
|
|
514
|
+
(o?.caseSensitive ? d : d.toLowerCase()).includes(s) && n.push({ row: a, column: e, value: f });
|
|
515
|
+
}), n;
|
|
516
|
+
}, E = p(/* @__PURE__ */ new Set()), oe = p(/* @__PURE__ */ new Set()), Ie = (e) => {
|
|
517
|
+
E.value = /* @__PURE__ */ new Set([...E.value, e]);
|
|
518
|
+
}, xe = (e) => {
|
|
519
|
+
const t = new Set(E.value);
|
|
520
|
+
t.delete(e), E.value = t;
|
|
521
|
+
}, $o = (e) => {
|
|
522
|
+
E.value.has(e) ? xe(e) : Ie(e);
|
|
523
|
+
}, Oo = (e) => E.value.has(e), jo = (e, t) => {
|
|
524
|
+
oe.value = /* @__PURE__ */ new Set([...oe.value, `${e},${t}`]);
|
|
525
|
+
}, Wo = () => {
|
|
526
|
+
E.value = /* @__PURE__ */ new Set(), oe.value = /* @__PURE__ */ new Set();
|
|
527
|
+
}, De = /* @__PURE__ */ new Map();
|
|
528
|
+
function et(e, t, o, n) {
|
|
529
|
+
let s = e.textContent;
|
|
530
|
+
const r = () => {
|
|
531
|
+
const d = e.textContent ?? "";
|
|
532
|
+
if ("validator" in n && n.validator && n.validator(d, t, o) !== !0) {
|
|
533
|
+
e.textContent = s;
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
const w = "parser" in n && n.parser ? n.parser(d, t, o) : d;
|
|
537
|
+
b(), n.onEdit?.(w, t, o);
|
|
538
|
+
}, a = (d) => {
|
|
539
|
+
tt(d) && (d.key === "Enter" ? (d.preventDefault(), e.blur()) : d.key === "Escape" && (d.preventDefault(), e.textContent = s, e.blur()));
|
|
540
|
+
}, f = () => {
|
|
541
|
+
s = e.textContent;
|
|
542
|
+
};
|
|
543
|
+
e.addEventListener("blur", r), e.addEventListener("keydown", a), e.addEventListener("focus", f), De.set(e, { blur: r, keydown: a, focus: f });
|
|
544
|
+
}
|
|
545
|
+
function he(e) {
|
|
546
|
+
const t = De.get(e);
|
|
547
|
+
t && (e.removeEventListener("blur", t.blur), e.removeEventListener("keydown", t.keydown), e.removeEventListener("focus", t.focus), De.delete(e)), e.contentEditable = "false";
|
|
548
|
+
}
|
|
549
|
+
function tt(e) {
|
|
550
|
+
return "key" in e;
|
|
551
|
+
}
|
|
552
|
+
function Uo(e, t, o) {
|
|
553
|
+
return o.editableRows && !o.editableRows.includes(e) ? !1 : !(o.editableColumns && !o.editableColumns.includes(t));
|
|
554
|
+
}
|
|
555
|
+
let ge = null, Fe = null;
|
|
556
|
+
const Me = (e = {}) => {
|
|
557
|
+
ge = { cells: !0, ...e };
|
|
558
|
+
const t = c.value[0];
|
|
559
|
+
t && Array.from(t.rows).forEach((o, n) => {
|
|
560
|
+
Array.from(o.cells).forEach((s, r) => {
|
|
561
|
+
Uo(n, r, ge) && (s.contentEditable = "true", et(s, n, r, ge));
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
}, Jo = () => {
|
|
565
|
+
ge = null;
|
|
566
|
+
const e = c.value[0];
|
|
567
|
+
e && Array.from(e.rows).forEach((t) => {
|
|
568
|
+
Array.from(t.cells).forEach(he);
|
|
569
|
+
});
|
|
570
|
+
}, Qo = (e = {}) => {
|
|
571
|
+
Fe = e;
|
|
572
|
+
const o = l.value.tHead?.rows[0];
|
|
573
|
+
o && Array.from(o.cells).forEach((n, s) => {
|
|
574
|
+
n.contentEditable = "true", et(n, -1, s, Fe);
|
|
575
|
+
});
|
|
576
|
+
}, _o = () => {
|
|
577
|
+
Fe = null;
|
|
578
|
+
const t = l.value.tHead?.rows[0];
|
|
579
|
+
t && Array.from(t.cells).forEach(he);
|
|
580
|
+
}, Yo = (e, t = {}) => {
|
|
581
|
+
Me({ ...t, editableColumns: [e] });
|
|
582
|
+
}, Zo = (e) => {
|
|
583
|
+
const t = c.value[0];
|
|
584
|
+
t && Array.from(t.rows).forEach((o) => {
|
|
585
|
+
const n = o.cells[e];
|
|
586
|
+
n && he(n);
|
|
587
|
+
});
|
|
588
|
+
}, Go = (e, t = {}) => {
|
|
589
|
+
Me({ ...t, editableRows: [e] });
|
|
590
|
+
}, Xo = (e) => {
|
|
591
|
+
const t = c.value[0];
|
|
592
|
+
if (!t) return;
|
|
593
|
+
const o = t.rows[e];
|
|
594
|
+
o && Array.from(o.cells).forEach(he);
|
|
595
|
+
}, qo = () => {
|
|
596
|
+
const e = c.value[0];
|
|
597
|
+
if (!e) return () => {
|
|
598
|
+
};
|
|
599
|
+
const t = (o) => {
|
|
600
|
+
const n = o.target;
|
|
601
|
+
if (!(n instanceof HTMLTableCellElement) || n.tagName !== "TD" || !(n.parentElement instanceof HTMLTableRowElement)) return;
|
|
602
|
+
n.contentEditable = "true", n.focus();
|
|
603
|
+
const r = window.getSelection();
|
|
604
|
+
if (r) {
|
|
605
|
+
const w = document.createRange();
|
|
606
|
+
w.selectNodeContents(n), r.removeAllRanges(), r.addRange(w);
|
|
607
|
+
}
|
|
608
|
+
const a = n.textContent, f = () => {
|
|
609
|
+
n.contentEditable = "false", n.removeEventListener("blur", f), n.removeEventListener("keydown", d), b();
|
|
610
|
+
}, d = (w) => {
|
|
611
|
+
tt(w) && (w.key === "Enter" ? (w.preventDefault(), n.blur()) : w.key === "Escape" && (n.textContent = a, n.blur()));
|
|
612
|
+
};
|
|
613
|
+
n.addEventListener("blur", f), n.addEventListener("keydown", d);
|
|
614
|
+
};
|
|
615
|
+
return e.addEventListener("dblclick", t), () => e.removeEventListener("dblclick", t);
|
|
616
|
+
}, Io = (e) => {
|
|
617
|
+
const t = /* @__PURE__ */ new Map();
|
|
618
|
+
return i.value.forEach((o, n) => {
|
|
619
|
+
const s = e(o), r = t.get(s) || [];
|
|
620
|
+
r.push(n), t.set(s, r);
|
|
621
|
+
}), t;
|
|
622
|
+
}, Le = /* @__PURE__ */ new Map(), xo = (e) => {
|
|
623
|
+
const t = e.index ?? g.value.length, o = i.value.map((r) => [...r]);
|
|
624
|
+
Ye(e.label, void 0, t);
|
|
625
|
+
const n = c.value[0];
|
|
626
|
+
n && Array.from(n.rows).forEach((r, a) => {
|
|
627
|
+
const f = r.cells[t];
|
|
628
|
+
if (f) {
|
|
629
|
+
const d = o[a] ?? [], w = e.computeFunction(d);
|
|
630
|
+
S(f, w);
|
|
631
|
+
}
|
|
632
|
+
}), b();
|
|
633
|
+
const s = L(() => i.value, () => {
|
|
634
|
+
const r = c.value[0];
|
|
635
|
+
r && Array.from(r.rows).forEach((a, f) => {
|
|
636
|
+
const d = a.cells[t];
|
|
637
|
+
if (d) {
|
|
638
|
+
const y = (i.value[f] ?? []).filter((re, Vr) => Vr !== t), R = e.computeFunction(y);
|
|
639
|
+
S(d, R);
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}, { deep: !0, flush: "sync" });
|
|
643
|
+
return Le.set(t, { config: e, stopWatcher: s }), t;
|
|
644
|
+
}, en = (e) => {
|
|
645
|
+
const t = Le.get(e);
|
|
646
|
+
t && (t.stopWatcher && t.stopWatcher(), Le.delete(e), Ze(e));
|
|
647
|
+
};
|
|
648
|
+
let A = null;
|
|
649
|
+
const ce = () => {
|
|
650
|
+
if (!A) return;
|
|
651
|
+
const { currentPage: e, pageSize: t } = A, o = i.value.length, n = (e.value - 1) * t.value, s = Math.min(n + t.value, o), r = [];
|
|
652
|
+
for (let f = n; f < s; f++) r.push(f);
|
|
653
|
+
A.visibleRows.value = r;
|
|
654
|
+
const a = c.value[0];
|
|
655
|
+
a && Array.from(a.rows).forEach((f, d) => {
|
|
656
|
+
f.style.display = r.includes(d) ? "" : "none";
|
|
657
|
+
});
|
|
658
|
+
}, tn = (e) => {
|
|
659
|
+
const t = p(e.currentPage ?? 1), o = p(e.pageSize), n = p([]);
|
|
660
|
+
A = {
|
|
661
|
+
totalPages: m(() => Math.ceil(i.value.length / o.value) || 1),
|
|
662
|
+
currentPage: t,
|
|
663
|
+
pageSize: o,
|
|
664
|
+
visibleRows: n
|
|
665
|
+
}, ce(), L(() => i.value.length, () => {
|
|
666
|
+
const s = A.totalPages.value;
|
|
667
|
+
t.value > s && (t.value = s), ce();
|
|
668
|
+
});
|
|
669
|
+
}, on = () => {
|
|
670
|
+
A && A.currentPage.value < A.totalPages.value && (A.currentPage.value++, ce());
|
|
671
|
+
}, nn = () => {
|
|
672
|
+
A && A.currentPage.value > 1 && (A.currentPage.value--, ce());
|
|
673
|
+
}, sn = (e) => {
|
|
674
|
+
A && e >= 1 && e <= A.totalPages.value && (A.currentPage.value = e, ce());
|
|
675
|
+
};
|
|
676
|
+
let D = null;
|
|
677
|
+
const ot = () => {
|
|
678
|
+
if (!D) return;
|
|
679
|
+
const { scrollTop: e, rowHeight: t, overscan: o, containerHeight: n } = D, s = i.value.length, r = Math.floor(e.value / t), a = Math.min(Math.ceil((e.value + n) / t), s), f = Math.max(0, r - o), d = Math.min(s, a + o), w = [];
|
|
680
|
+
for (let R = f; R < d; R++) w.push(R);
|
|
681
|
+
D.visibleRows.value = w, D.startIndex.value = f, D.endIndex.value = d;
|
|
682
|
+
const y = c.value[0];
|
|
683
|
+
y && (Array.from(y.rows).forEach((R, re) => {
|
|
684
|
+
w.includes(re) ? (R.style.display = "", R.style.transform = `translateY(${re * t}px)`) : R.style.display = "none";
|
|
685
|
+
}), y.style.height = `${s * t}px`, y.style.position = "relative");
|
|
686
|
+
}, rn = (e) => {
|
|
687
|
+
const t = p(0);
|
|
688
|
+
D = {
|
|
689
|
+
scrollTop: t,
|
|
690
|
+
rowHeight: e.rowHeight,
|
|
691
|
+
overscan: e.overscan,
|
|
692
|
+
containerHeight: e.containerHeight,
|
|
693
|
+
visibleRows: p([]),
|
|
694
|
+
startIndex: p(0),
|
|
695
|
+
endIndex: p(0)
|
|
696
|
+
};
|
|
697
|
+
const o = l.value.parentElement;
|
|
698
|
+
if (o) {
|
|
699
|
+
const n = () => {
|
|
700
|
+
t.value = o.scrollTop, ot();
|
|
701
|
+
};
|
|
702
|
+
o.addEventListener("scroll", n), D.scrollHandler = n, D.container = o, ot();
|
|
703
|
+
const s = c.value[0];
|
|
704
|
+
s && Array.from(s.rows).forEach((r) => {
|
|
705
|
+
r.style.position = "absolute", r.style.width = "100%", r.style.left = "0";
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
}, ln = () => {
|
|
709
|
+
if (!D) return;
|
|
710
|
+
D.container && D.scrollHandler && D.container.removeEventListener("scroll", D.scrollHandler);
|
|
711
|
+
const e = c.value[0];
|
|
712
|
+
e && (e.style.height = "", e.style.position = "", Array.from(e.rows).forEach((t) => {
|
|
713
|
+
t.style.display = "", t.style.position = "", t.style.transform = "", t.style.width = "", t.style.left = "";
|
|
714
|
+
})), D = null;
|
|
715
|
+
}, an = () => ({
|
|
716
|
+
data: JSON.parse(JSON.stringify(i.value)),
|
|
717
|
+
headers: [...g.value]
|
|
718
|
+
}), nt = (e) => {
|
|
719
|
+
g.value = [...e.headers], i.value = e.data.map((t) => [...t]);
|
|
720
|
+
}, cn = (e) => {
|
|
721
|
+
const t = an();
|
|
722
|
+
try {
|
|
723
|
+
const o = e();
|
|
724
|
+
return o instanceof Promise ? o.catch((n) => {
|
|
725
|
+
throw nt(t), n;
|
|
726
|
+
}) : o;
|
|
727
|
+
} catch (o) {
|
|
728
|
+
throw nt(t), o;
|
|
729
|
+
}
|
|
730
|
+
}, un = (e) => L(() => i.value, (t) => {
|
|
731
|
+
e([...t.map((o) => [...o])]);
|
|
732
|
+
}, { deep: !0 }), W = p(null), B = p(!1), U = p(!1), fn = {
|
|
733
|
+
columnIndex: W,
|
|
734
|
+
ascending: B,
|
|
735
|
+
descending: U
|
|
736
|
+
}, st = (e, t) => {
|
|
737
|
+
const o = String(e ?? ""), n = String(t ?? ""), s = Number(o), r = Number(n);
|
|
738
|
+
return !isNaN(s) && !isNaN(r) ? s - r : o.localeCompare(n);
|
|
739
|
+
}, pe = (e, t, o) => {
|
|
740
|
+
const n = c.value[0];
|
|
741
|
+
if (!n || n.rows.length === 0) return;
|
|
742
|
+
const s = [];
|
|
743
|
+
for (let r = 0; r < n.rows.length; r++) {
|
|
744
|
+
const a = n.rows[r];
|
|
745
|
+
if (a) {
|
|
746
|
+
const f = a.cells[e], d = f ? te(f) : "";
|
|
747
|
+
s.push({ element: a, value: d });
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
s.sort((r, a) => {
|
|
751
|
+
const f = t(r.value, a.value);
|
|
752
|
+
return o ? f : -f;
|
|
753
|
+
}), s.forEach(({ element: r }) => {
|
|
754
|
+
n.appendChild(r);
|
|
755
|
+
}), W.value = e, B.value = o, U.value = !o, b();
|
|
756
|
+
}, dn = (e) => {
|
|
757
|
+
pe(e, st, !0);
|
|
758
|
+
}, vn = (e) => {
|
|
759
|
+
pe(e, st, !1);
|
|
760
|
+
}, wn = (e, t) => {
|
|
761
|
+
pe(e, t, !0);
|
|
762
|
+
}, hn = (e, t) => {
|
|
763
|
+
pe(e, t, !1);
|
|
764
|
+
}, gn = () => {
|
|
765
|
+
W.value = null, B.value = !1, U.value = !1;
|
|
766
|
+
}, pn = () => W.value, yn = () => W.value === null || B.value === U.value ? !1 : B.value, mn = () => W.value === null || B.value === U.value ? !1 : U.value, Cn = () => W.value === null || B.value === U.value ? !1 : B.value || U.value, Q = p([]), rt = m(() => Q.value.length > 0), Rn = m(() => rt.value ? Q.value.length : i.value.length), Sn = {
|
|
767
|
+
isFiltered: rt,
|
|
768
|
+
filteredRowCount: Rn,
|
|
769
|
+
filteredIndices: Q
|
|
770
|
+
}, lt = (e) => {
|
|
771
|
+
const t = c.value[0];
|
|
772
|
+
if (!t) return;
|
|
773
|
+
const o = [], n = i.value;
|
|
774
|
+
for (let s = 0; s < n.length; s++) {
|
|
775
|
+
const r = n[s];
|
|
776
|
+
r && e(r, s) && o.push(s);
|
|
777
|
+
}
|
|
778
|
+
Q.value = o;
|
|
779
|
+
for (let s = 0; s < t.rows.length; s++) {
|
|
780
|
+
const r = t.rows[s];
|
|
781
|
+
r && (r.style.display = o.includes(s) ? "" : "none");
|
|
782
|
+
}
|
|
783
|
+
}, Te = (e, t) => {
|
|
784
|
+
lt((o) => {
|
|
785
|
+
const n = o[e];
|
|
786
|
+
return t(n);
|
|
787
|
+
});
|
|
788
|
+
}, bn = (e, t) => {
|
|
789
|
+
const o = String(t ?? "");
|
|
790
|
+
Te(e, (n) => String(n ?? "") === o);
|
|
791
|
+
}, En = (e, t) => {
|
|
792
|
+
const o = new Set(t.map((n) => String(n ?? "")));
|
|
793
|
+
Te(e, (n) => o.has(String(n ?? "")));
|
|
794
|
+
}, An = () => {
|
|
795
|
+
const e = c.value[0];
|
|
796
|
+
if (e)
|
|
797
|
+
for (let t = 0; t < e.rows.length; t++) {
|
|
798
|
+
const o = e.rows[t];
|
|
799
|
+
o && (o.style.display = "");
|
|
800
|
+
}
|
|
801
|
+
Q.value = [];
|
|
802
|
+
}, Dn = () => Q.value;
|
|
803
|
+
let K = null;
|
|
804
|
+
const Fn = (e) => {
|
|
805
|
+
K = e;
|
|
806
|
+
}, Mn = () => {
|
|
807
|
+
K = null;
|
|
808
|
+
}, Ln = () => K !== null, Tn = (e) => {
|
|
809
|
+
if (!K) return;
|
|
810
|
+
const t = i.value[e];
|
|
811
|
+
if (t)
|
|
812
|
+
return K(t, e);
|
|
813
|
+
}, Hn = () => K ? i.value.map((e, t) => K(e, t)) : [], ue = (e) => {
|
|
814
|
+
if (!K) return;
|
|
815
|
+
const t = i.value;
|
|
816
|
+
for (let o = 0; o < t.length; o++) {
|
|
817
|
+
const n = t[o];
|
|
818
|
+
if (n && K(n, o) === e)
|
|
819
|
+
return o;
|
|
820
|
+
}
|
|
821
|
+
}, kn = (e) => {
|
|
822
|
+
const t = ue(e);
|
|
823
|
+
if (t === void 0) return;
|
|
824
|
+
const o = i.value[t];
|
|
825
|
+
return o ? [...o] : void 0;
|
|
826
|
+
}, Nn = (e, t) => {
|
|
827
|
+
const o = ue(e);
|
|
828
|
+
return o === void 0 ? !1 : (Xe(o, t), !0);
|
|
829
|
+
}, Vn = (e) => {
|
|
830
|
+
const t = ue(e);
|
|
831
|
+
return t === void 0 ? !1 : (_e(t), !0);
|
|
832
|
+
}, zn = (e) => ue(e) !== void 0, z = /* @__PURE__ */ new Map(), Pn = (e, t) => {
|
|
833
|
+
z.set(e, t);
|
|
834
|
+
}, Bn = (e) => {
|
|
835
|
+
z.clear(), e.forEach((t, o) => {
|
|
836
|
+
t && z.set(o, t);
|
|
837
|
+
});
|
|
838
|
+
}, Kn = (e) => {
|
|
839
|
+
z.delete(e);
|
|
840
|
+
}, $n = () => {
|
|
841
|
+
z.clear();
|
|
842
|
+
}, On = (e) => z.get(e), jn = (e) => z.has(e), He = (e, t) => {
|
|
843
|
+
if (t.parser)
|
|
844
|
+
return t.parser(e);
|
|
845
|
+
const o = String(e ?? "");
|
|
846
|
+
if (t.nullable && (e == null || o === ""))
|
|
847
|
+
return null;
|
|
848
|
+
switch (t.type) {
|
|
849
|
+
case "number":
|
|
850
|
+
return Number(o);
|
|
851
|
+
case "boolean":
|
|
852
|
+
return o === "true" || o === "1";
|
|
853
|
+
case "date":
|
|
854
|
+
return new Date(o);
|
|
855
|
+
default:
|
|
856
|
+
return o;
|
|
857
|
+
}
|
|
858
|
+
}, Wn = (e, t) => {
|
|
859
|
+
const o = ae(e, t), n = z.get(t);
|
|
860
|
+
return n ? He(o, n) : o;
|
|
861
|
+
}, at = (e) => {
|
|
862
|
+
const t = i.value[e];
|
|
863
|
+
return t ? t.map((o, n) => {
|
|
864
|
+
const s = z.get(n);
|
|
865
|
+
return s ? He(o, s) : o;
|
|
866
|
+
}) : [];
|
|
867
|
+
}, Un = (e) => {
|
|
868
|
+
const t = z.get(e);
|
|
869
|
+
return i.value.map((o) => {
|
|
870
|
+
const n = o[e];
|
|
871
|
+
return t ? He(n, t) : n;
|
|
872
|
+
});
|
|
873
|
+
}, Jn = () => i.value.map((e, t) => at(t)), ie = p(!1), ke = p(null), _ = /* @__PURE__ */ new Map(), Qn = () => {
|
|
874
|
+
ie.value = !1, ke.value = JSON.parse(JSON.stringify(i.value)), _.clear();
|
|
875
|
+
}, _n = () => {
|
|
876
|
+
ie.value = !0;
|
|
877
|
+
}, Yn = () => ie.value, Zn = () => _.size > 0, Gn = () => Array.from(_.values()), Xn = () => {
|
|
878
|
+
const e = /* @__PURE__ */ new Set();
|
|
879
|
+
for (const t of _.values())
|
|
880
|
+
e.add(t.row);
|
|
881
|
+
return Array.from(e).sort((t, o) => t - o);
|
|
882
|
+
}, qn = () => {
|
|
883
|
+
const e = /* @__PURE__ */ new Set();
|
|
884
|
+
for (const t of _.values())
|
|
885
|
+
e.add(t.column);
|
|
886
|
+
return Array.from(e).sort((t, o) => t - o);
|
|
887
|
+
};
|
|
888
|
+
L(() => i.value, (e) => {
|
|
889
|
+
if (ke.value === null) return;
|
|
890
|
+
const t = ke.value;
|
|
891
|
+
for (let o = 0; o < Math.max(e.length, t.length); o++) {
|
|
892
|
+
const n = e[o] ?? [], s = t[o] ?? [], r = Math.max(n.length, s.length);
|
|
893
|
+
for (let a = 0; a < r; a++) {
|
|
894
|
+
const f = n[a], d = s[a], w = `${o},${a}`;
|
|
895
|
+
String(f ?? "") !== String(d ?? "") ? (_.set(w, { row: o, column: a, oldValue: d, newValue: f }), ie.value = !0) : _.delete(w);
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}, { deep: !0 });
|
|
899
|
+
const $ = [], Y = [];
|
|
900
|
+
let Ne = 50, ne = "", Z = !1;
|
|
901
|
+
const ct = () => ({
|
|
902
|
+
data: JSON.parse(JSON.stringify(i.value)),
|
|
903
|
+
headers: [...g.value]
|
|
904
|
+
}), Ve = () => JSON.stringify({ data: i.value, headers: g.value });
|
|
905
|
+
L([() => i.value, () => g.value], () => {
|
|
906
|
+
if (Z) return;
|
|
907
|
+
const e = Ve();
|
|
908
|
+
if (e !== ne) {
|
|
909
|
+
if (ne !== "") {
|
|
910
|
+
const t = JSON.parse(ne);
|
|
911
|
+
(t.data.length > 0 || t.headers.length > 0) && ($.push({ data: t.data, headers: t.headers }), $.length > Ne && $.shift(), Y.length = 0);
|
|
912
|
+
}
|
|
913
|
+
ne = e;
|
|
914
|
+
}
|
|
915
|
+
}, { deep: !0, flush: "sync" });
|
|
916
|
+
const In = () => {
|
|
917
|
+
if ($.length === 0) return !1;
|
|
918
|
+
Z = !0, Y.push(ct());
|
|
919
|
+
const e = $.pop();
|
|
920
|
+
return e ? (V(e.data), j(e.headers), ne = Ve(), Z = !1, !0) : (Z = !1, !1);
|
|
921
|
+
}, xn = () => {
|
|
922
|
+
if (Y.length === 0) return !1;
|
|
923
|
+
Z = !0, $.push(ct());
|
|
924
|
+
const e = Y.pop();
|
|
925
|
+
return e ? (V(e.data), j(e.headers), ne = Ve(), Z = !1, !0) : (Z = !1, !1);
|
|
926
|
+
}, es = () => {
|
|
927
|
+
$.length = 0, Y.length = 0;
|
|
928
|
+
}, ts = () => $.length > 0, os = () => Y.length > 0, ns = () => $.length, ss = () => Y.length, rs = (e) => {
|
|
929
|
+
Ne = e;
|
|
930
|
+
}, ls = () => Ne, as = () => {
|
|
931
|
+
const e = i.value.length;
|
|
932
|
+
for (let t = 0; t < e; t++)
|
|
933
|
+
E.value.add(t);
|
|
934
|
+
}, cs = () => {
|
|
935
|
+
E.value.clear();
|
|
936
|
+
}, us = (e, t) => {
|
|
937
|
+
const o = Math.min(e, t), n = Math.max(e, t);
|
|
938
|
+
for (let s = o; s <= n; s++)
|
|
939
|
+
s >= 0 && s < i.value.length && E.value.add(s);
|
|
940
|
+
}, is = () => {
|
|
941
|
+
const e = i.value.length, t = /* @__PURE__ */ new Set();
|
|
942
|
+
for (let o = 0; o < e; o++)
|
|
943
|
+
E.value.has(o) || t.add(o);
|
|
944
|
+
E.value = t;
|
|
945
|
+
}, fs = () => {
|
|
946
|
+
const e = [], t = Array.from(E.value).sort((o, n) => o - n);
|
|
947
|
+
for (const o of t) {
|
|
948
|
+
const n = i.value[o];
|
|
949
|
+
n && e.push([...n]);
|
|
950
|
+
}
|
|
951
|
+
return e;
|
|
952
|
+
}, ut = () => Array.from(E.value).sort((e, t) => e - t), it = () => {
|
|
953
|
+
const e = [];
|
|
954
|
+
for (const t of oe.value) {
|
|
955
|
+
const o = t.split(",");
|
|
956
|
+
if (o.length === 2) {
|
|
957
|
+
const n = parseInt(o[0] ?? "", 10), s = parseInt(o[1] ?? "", 10);
|
|
958
|
+
!isNaN(n) && !isNaN(s) && e.push({ row: n, column: s });
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
return e.sort((t, o) => t.row === o.row ? t.column - o.column : t.row - o.row);
|
|
962
|
+
}, M = p(null), O = (e, t) => {
|
|
963
|
+
if (e >= 0 && e < i.value.length && t >= 0 && t < g.value.length) {
|
|
964
|
+
M.value = { row: e, column: t };
|
|
965
|
+
const o = qe(e, t);
|
|
966
|
+
o && o.focus();
|
|
967
|
+
}
|
|
968
|
+
}, ds = () => {
|
|
969
|
+
M.value = null;
|
|
970
|
+
}, vs = () => M.value ? { ...M.value } : null, ws = (e, t) => {
|
|
971
|
+
const o = M.value;
|
|
972
|
+
return o !== null && o.row === e && o.column === t;
|
|
973
|
+
}, ft = () => {
|
|
974
|
+
const e = M.value;
|
|
975
|
+
return !e || e.row <= 0 ? !1 : (O(e.row - 1, e.column), !0);
|
|
976
|
+
}, dt = () => {
|
|
977
|
+
const e = M.value;
|
|
978
|
+
return !e || e.row >= i.value.length - 1 ? !1 : (O(e.row + 1, e.column), !0);
|
|
979
|
+
}, vt = () => {
|
|
980
|
+
const e = M.value;
|
|
981
|
+
return !e || e.column <= 0 ? !1 : (O(e.row, e.column - 1), !0);
|
|
982
|
+
}, wt = () => {
|
|
983
|
+
const e = M.value;
|
|
984
|
+
return !e || e.column >= g.value.length - 1 ? !1 : (O(e.row, e.column + 1), !0);
|
|
985
|
+
}, ht = () => {
|
|
986
|
+
i.value.length > 0 && g.value.length > 0 && O(0, 0);
|
|
987
|
+
}, gt = () => {
|
|
988
|
+
const e = i.value.length, t = g.value.length;
|
|
989
|
+
e > 0 && t > 0 && O(e - 1, t - 1);
|
|
990
|
+
}, pt = () => {
|
|
991
|
+
const e = M.value;
|
|
992
|
+
e && O(e.row, 0);
|
|
993
|
+
}, yt = () => {
|
|
994
|
+
const e = M.value;
|
|
995
|
+
e && g.value.length > 0 && O(e.row, g.value.length - 1);
|
|
996
|
+
}, hs = () => {
|
|
997
|
+
const e = (t) => {
|
|
998
|
+
if (M.value)
|
|
999
|
+
switch (t.key) {
|
|
1000
|
+
case "ArrowUp":
|
|
1001
|
+
ft() && t.preventDefault();
|
|
1002
|
+
break;
|
|
1003
|
+
case "ArrowDown":
|
|
1004
|
+
dt() && t.preventDefault();
|
|
1005
|
+
break;
|
|
1006
|
+
case "ArrowLeft":
|
|
1007
|
+
vt() && t.preventDefault();
|
|
1008
|
+
break;
|
|
1009
|
+
case "ArrowRight":
|
|
1010
|
+
wt() && t.preventDefault();
|
|
1011
|
+
break;
|
|
1012
|
+
case "Home":
|
|
1013
|
+
t.ctrlKey ? ht() : pt(), t.preventDefault();
|
|
1014
|
+
break;
|
|
1015
|
+
case "End":
|
|
1016
|
+
t.ctrlKey ? gt() : yt(), t.preventDefault();
|
|
1017
|
+
break;
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
return l.value.addEventListener("keydown", e), () => l.value.removeEventListener("keydown", e);
|
|
1021
|
+
}, H = p(/* @__PURE__ */ new Set()), gs = m(() => g.value.length - H.value.size), mt = () => {
|
|
1022
|
+
const e = l.value.tHead, t = c.value[0], o = l.value.tFoot, n = (s) => {
|
|
1023
|
+
for (let r = 0; r < s.cells.length; r++) {
|
|
1024
|
+
const a = s.cells[r];
|
|
1025
|
+
a && (a.style.display = H.value.has(r) ? "none" : "");
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
if (e)
|
|
1029
|
+
for (let s = 0; s < e.rows.length; s++) {
|
|
1030
|
+
const r = e.rows[s];
|
|
1031
|
+
r && n(r);
|
|
1032
|
+
}
|
|
1033
|
+
if (t)
|
|
1034
|
+
for (let s = 0; s < t.rows.length; s++) {
|
|
1035
|
+
const r = t.rows[s];
|
|
1036
|
+
r && n(r);
|
|
1037
|
+
}
|
|
1038
|
+
if (o)
|
|
1039
|
+
for (let s = 0; s < o.rows.length; s++) {
|
|
1040
|
+
const r = o.rows[s];
|
|
1041
|
+
r && n(r);
|
|
1042
|
+
}
|
|
1043
|
+
}, Ct = (e) => {
|
|
1044
|
+
const t = new Set(H.value);
|
|
1045
|
+
t.add(e), H.value = t, mt();
|
|
1046
|
+
}, Rt = (e) => {
|
|
1047
|
+
const t = new Set(H.value);
|
|
1048
|
+
t.delete(e), H.value = t, mt();
|
|
1049
|
+
}, ps = (e) => {
|
|
1050
|
+
H.value.has(e) ? Rt(e) : Ct(e);
|
|
1051
|
+
}, ys = (e) => !H.value.has(e), ms = () => {
|
|
1052
|
+
const e = [];
|
|
1053
|
+
for (let t = 0; t < g.value.length; t++)
|
|
1054
|
+
H.value.has(t) || e.push(t);
|
|
1055
|
+
return e;
|
|
1056
|
+
}, Cs = () => Array.from(H.value).sort((e, t) => e - t), fe = (e, t) => {
|
|
1057
|
+
const o = c.value[0];
|
|
1058
|
+
if (!o || e < 0 || e >= o.rows.length || t < 0 || t >= o.rows.length || e === t) return;
|
|
1059
|
+
const n = o.rows[e];
|
|
1060
|
+
if (n) {
|
|
1061
|
+
if (t < e) {
|
|
1062
|
+
const s = o.rows[t];
|
|
1063
|
+
s && o.insertBefore(n, s);
|
|
1064
|
+
} else {
|
|
1065
|
+
const s = o.rows[t + 1];
|
|
1066
|
+
s ? o.insertBefore(n, s) : o.appendChild(n);
|
|
1067
|
+
}
|
|
1068
|
+
b();
|
|
1069
|
+
}
|
|
1070
|
+
}, Rs = (e) => e <= 0 ? !1 : (fe(e, e - 1), !0), Ss = (e) => {
|
|
1071
|
+
const t = c.value[0];
|
|
1072
|
+
return !t || e >= t.rows.length - 1 ? !1 : (fe(e, e + 1), !0);
|
|
1073
|
+
}, bs = (e) => {
|
|
1074
|
+
fe(e, 0);
|
|
1075
|
+
}, Es = (e) => {
|
|
1076
|
+
const t = c.value[0];
|
|
1077
|
+
t && fe(e, t.rows.length - 1);
|
|
1078
|
+
}, As = (e, t) => {
|
|
1079
|
+
const o = c.value[0];
|
|
1080
|
+
if (!o || e < 0 || e >= o.rows.length || t < 0 || t >= o.rows.length || e === t) return;
|
|
1081
|
+
const n = o.rows[e], s = o.rows[t];
|
|
1082
|
+
if (!n || !s) return;
|
|
1083
|
+
const r = document.createElement("tr");
|
|
1084
|
+
o.insertBefore(r, n), o.insertBefore(n, s), o.insertBefore(s, r), o.removeChild(r), b();
|
|
1085
|
+
}, de = (e, t) => {
|
|
1086
|
+
if (e < 0 || e >= g.value.length || t < 0 || t >= g.value.length || e === t) return;
|
|
1087
|
+
const o = [...g.value], [n] = o.splice(e, 1);
|
|
1088
|
+
n !== void 0 && o.splice(t, 0, n);
|
|
1089
|
+
const s = i.value.map((r) => {
|
|
1090
|
+
const a = [...r], [f] = a.splice(e, 1);
|
|
1091
|
+
return f !== void 0 && a.splice(t, 0, f), a;
|
|
1092
|
+
});
|
|
1093
|
+
j(o), V(s);
|
|
1094
|
+
}, Ds = (e) => e <= 0 ? !1 : (de(e, e - 1), !0), Fs = (e) => e >= g.value.length - 1 ? !1 : (de(e, e + 1), !0), Ms = (e) => {
|
|
1095
|
+
de(e, 0);
|
|
1096
|
+
}, Ls = (e) => {
|
|
1097
|
+
de(e, g.value.length - 1);
|
|
1098
|
+
}, Ts = (e, t) => {
|
|
1099
|
+
if (e < 0 || e >= g.value.length || t < 0 || t >= g.value.length || e === t) return;
|
|
1100
|
+
const o = [...g.value], n = o[e];
|
|
1101
|
+
o[e] = o[t] ?? "", o[t] = n ?? "";
|
|
1102
|
+
const s = i.value.map((r) => {
|
|
1103
|
+
const a = [...r], f = a[e];
|
|
1104
|
+
return a[e] = a[t], a[t] = f, a;
|
|
1105
|
+
});
|
|
1106
|
+
j(o), V(s);
|
|
1107
|
+
}, ze = (e) => e.map((t) => t.map((o) => String(o ?? "")).join(" ")).join(`
|
|
1108
|
+
`), Hs = () => {
|
|
1109
|
+
const e = it();
|
|
1110
|
+
if (e.length === 0) return "";
|
|
1111
|
+
const t = new Set(e.map((d) => d.row)), o = new Set(e.map((d) => d.column)), n = Math.min(...t), s = Math.max(...t), r = Math.min(...o), a = Math.max(...o), f = [];
|
|
1112
|
+
for (let d = n; d <= s; d++) {
|
|
1113
|
+
const w = [];
|
|
1114
|
+
for (let y = r; y <= a; y++)
|
|
1115
|
+
e.some((R) => R.row === d && R.column === y) ? w.push(ae(d, y)) : w.push("");
|
|
1116
|
+
f.push(w);
|
|
1117
|
+
}
|
|
1118
|
+
return ze(f);
|
|
1119
|
+
}, ks = () => {
|
|
1120
|
+
const t = ut().map((o) => i.value[o] ?? []);
|
|
1121
|
+
return ze(t);
|
|
1122
|
+
}, Ns = (e) => {
|
|
1123
|
+
const t = i.value[e];
|
|
1124
|
+
return t ? t.map((o) => String(o ?? "")).join(" ") : "";
|
|
1125
|
+
}, Vs = (e) => i.value.map((t) => String(t[e] ?? "")).join(`
|
|
1126
|
+
`), zs = (e, t) => String(ae(e, t) ?? ""), Ps = (e, t, o, n) => {
|
|
1127
|
+
const s = [], r = Math.min(e, o), a = Math.max(e, o), f = Math.min(t, n), d = Math.max(t, n);
|
|
1128
|
+
for (let w = r; w <= a; w++) {
|
|
1129
|
+
const y = [];
|
|
1130
|
+
for (let R = f; R <= d; R++)
|
|
1131
|
+
y.push(ae(w, R));
|
|
1132
|
+
s.push(y);
|
|
1133
|
+
}
|
|
1134
|
+
return ze(s);
|
|
1135
|
+
}, Bs = (e, t, o) => {
|
|
1136
|
+
const n = o.split(`
|
|
1137
|
+
`);
|
|
1138
|
+
for (let s = 0; s < n.length; s++) {
|
|
1139
|
+
const r = n[s];
|
|
1140
|
+
if (r === void 0) continue;
|
|
1141
|
+
const a = r.split(" ");
|
|
1142
|
+
for (let f = 0; f < a.length; f++) {
|
|
1143
|
+
const d = a[f];
|
|
1144
|
+
d !== void 0 && be(e + s, t + f, d);
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
}, P = p(/* @__PURE__ */ new Set()), k = p([]), N = p([]), St = (e) => {
|
|
1148
|
+
const t = new Set(P.value);
|
|
1149
|
+
t.add(e), P.value = t;
|
|
1150
|
+
}, bt = (e) => {
|
|
1151
|
+
const t = new Set(P.value);
|
|
1152
|
+
t.delete(e), P.value = t;
|
|
1153
|
+
}, Ks = (e) => {
|
|
1154
|
+
P.value.has(e) ? bt(e) : St(e);
|
|
1155
|
+
}, $s = () => {
|
|
1156
|
+
const e = /* @__PURE__ */ new Set();
|
|
1157
|
+
for (let t = 0; t < i.value.length; t++)
|
|
1158
|
+
e.add(t);
|
|
1159
|
+
P.value = e;
|
|
1160
|
+
}, Os = () => {
|
|
1161
|
+
P.value = /* @__PURE__ */ new Set();
|
|
1162
|
+
}, js = (e) => P.value.has(e), Ws = () => Array.from(P.value).sort((e, t) => e - t), Us = (e) => {
|
|
1163
|
+
k.value.includes(e) || (k.value = [...k.value, e], N.value = N.value.filter((t) => t !== e));
|
|
1164
|
+
}, Js = (e) => {
|
|
1165
|
+
N.value.includes(e) || (N.value = [...N.value, e], k.value = k.value.filter((t) => t !== e));
|
|
1166
|
+
}, Qs = (e) => {
|
|
1167
|
+
k.value = k.value.filter((t) => t !== e), N.value = N.value.filter((t) => t !== e);
|
|
1168
|
+
}, _s = () => {
|
|
1169
|
+
k.value = [], N.value = [];
|
|
1170
|
+
}, Ys = (e) => k.value.includes(e), Zs = (e) => N.value.includes(e), Gs = () => [...k.value], Xs = () => [...N.value], G = /* @__PURE__ */ new Map(), X = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), qs = (e, t, o, n) => {
|
|
1171
|
+
const s = `${e},${t}`;
|
|
1172
|
+
G.has(s) || G.set(s, /* @__PURE__ */ new Map()), G.get(s)?.set(o, n);
|
|
1173
|
+
}, Is = (e, t, o) => {
|
|
1174
|
+
const n = `${e},${t}`;
|
|
1175
|
+
return G.get(n)?.get(o);
|
|
1176
|
+
}, xs = (e, t, o) => {
|
|
1177
|
+
const n = `${e},${t}`;
|
|
1178
|
+
return G.get(n)?.has(o) ?? !1;
|
|
1179
|
+
}, er = (e, t) => {
|
|
1180
|
+
const o = `${e},${t}`;
|
|
1181
|
+
G.delete(o);
|
|
1182
|
+
}, tr = (e, t, o) => {
|
|
1183
|
+
const n = `${e},${t}`;
|
|
1184
|
+
G.get(n)?.delete(o);
|
|
1185
|
+
}, or = (e, t, o) => {
|
|
1186
|
+
X.has(e) || X.set(e, /* @__PURE__ */ new Map()), X.get(e)?.set(t, o);
|
|
1187
|
+
}, nr = (e, t) => X.get(e)?.get(t), sr = (e, t) => X.get(e)?.has(t) ?? !1, rr = (e) => {
|
|
1188
|
+
X.delete(e);
|
|
1189
|
+
}, lr = (e, t) => {
|
|
1190
|
+
X.get(e)?.delete(t);
|
|
1191
|
+
}, ar = (e, t, o) => {
|
|
1192
|
+
q.has(e) || q.set(e, /* @__PURE__ */ new Map()), q.get(e)?.set(t, o);
|
|
1193
|
+
}, cr = (e, t) => q.get(e)?.get(t), ur = (e, t) => q.get(e)?.has(t) ?? !1, ir = (e) => {
|
|
1194
|
+
q.delete(e);
|
|
1195
|
+
}, fr = (e, t) => {
|
|
1196
|
+
q.get(e)?.delete(t);
|
|
1197
|
+
}, dr = (e) => () => {
|
|
1198
|
+
}, vr = (e) => () => {
|
|
1199
|
+
}, wr = (e) => () => {
|
|
1200
|
+
}, hr = (e) => () => {
|
|
1201
|
+
}, gr = (e) => {
|
|
1202
|
+
const t = L(() => E.value, (o) => {
|
|
1203
|
+
e(o);
|
|
1204
|
+
}, { deep: !0 });
|
|
1205
|
+
return () => {
|
|
1206
|
+
t();
|
|
1207
|
+
};
|
|
1208
|
+
}, pr = (e) => {
|
|
1209
|
+
const t = L(() => oe.value, (o) => {
|
|
1210
|
+
e(o);
|
|
1211
|
+
}, { deep: !0 });
|
|
1212
|
+
return () => {
|
|
1213
|
+
t();
|
|
1214
|
+
};
|
|
1215
|
+
}, yr = (e) => {
|
|
1216
|
+
const t = L([W, B], ([o, n]) => {
|
|
1217
|
+
e(o, n);
|
|
1218
|
+
});
|
|
1219
|
+
return () => {
|
|
1220
|
+
t();
|
|
1221
|
+
};
|
|
1222
|
+
}, mr = (e) => {
|
|
1223
|
+
const t = L(() => Q.value, (o) => {
|
|
1224
|
+
e(o);
|
|
1225
|
+
});
|
|
1226
|
+
return () => {
|
|
1227
|
+
t();
|
|
1228
|
+
};
|
|
1229
|
+
}, Cr = (e) => {
|
|
1230
|
+
const t = L(() => M.value, (o) => {
|
|
1231
|
+
e(o ? { ...o } : null);
|
|
1232
|
+
});
|
|
1233
|
+
return () => {
|
|
1234
|
+
t();
|
|
1235
|
+
};
|
|
1236
|
+
}, Rr = (e) => {
|
|
1237
|
+
const t = L(() => H.value, (o, n) => {
|
|
1238
|
+
for (const s of o)
|
|
1239
|
+
n?.has(s) || e(s, !1);
|
|
1240
|
+
if (n)
|
|
1241
|
+
for (const s of n)
|
|
1242
|
+
o.has(s) || e(s, !0);
|
|
1243
|
+
});
|
|
1244
|
+
return () => {
|
|
1245
|
+
t();
|
|
1246
|
+
};
|
|
1247
|
+
};
|
|
1248
|
+
let J = 0, se = null;
|
|
1249
|
+
const Et = () => {
|
|
1250
|
+
J === 0 && (se = {
|
|
1251
|
+
data: JSON.parse(JSON.stringify(i.value)),
|
|
1252
|
+
headers: [...g.value]
|
|
1253
|
+
}), J++;
|
|
1254
|
+
}, At = () => {
|
|
1255
|
+
J > 0 && (J--, J === 0 && (se = null, b()));
|
|
1256
|
+
}, Dt = () => {
|
|
1257
|
+
J > 0 && se && (V(se.data), j(se.headers), J = 0, se = null);
|
|
1258
|
+
}, Sr = () => J > 0, br = (e) => {
|
|
1259
|
+
Et();
|
|
1260
|
+
try {
|
|
1261
|
+
e(), At();
|
|
1262
|
+
} catch (t) {
|
|
1263
|
+
throw Dt(), t;
|
|
1264
|
+
}
|
|
1265
|
+
}, Pe = p(!1), Be = /* @__PURE__ */ new Set(), Ke = /* @__PURE__ */ new Set(), $e = /* @__PURE__ */ new Set(), I = (e) => {
|
|
1266
|
+
Pe.value = e;
|
|
1267
|
+
}, Er = (e, t, o) => {
|
|
1268
|
+
const n = `${e},${t}`;
|
|
1269
|
+
o ? Be.add(n) : Be.delete(n);
|
|
1270
|
+
}, Ar = (e, t) => {
|
|
1271
|
+
t ? Ke.add(e) : Ke.delete(e);
|
|
1272
|
+
}, Dr = (e, t) => {
|
|
1273
|
+
t ? $e.add(e) : $e.delete(e);
|
|
1274
|
+
}, Fr = () => Pe.value, Mr = (e, t) => Be.has(`${e},${t}`), Lr = (e) => Ke.has(e), Tr = (e) => $e.has(e), Hr = async (e) => {
|
|
1275
|
+
I(!0);
|
|
1276
|
+
try {
|
|
1277
|
+
const t = await e();
|
|
1278
|
+
V(t);
|
|
1279
|
+
} finally {
|
|
1280
|
+
I(!1);
|
|
1281
|
+
}
|
|
1282
|
+
}, kr = async (e) => {
|
|
1283
|
+
I(!0);
|
|
1284
|
+
try {
|
|
1285
|
+
const t = await e();
|
|
1286
|
+
for (const o of t)
|
|
1287
|
+
we(o);
|
|
1288
|
+
} finally {
|
|
1289
|
+
I(!1);
|
|
1290
|
+
}
|
|
1291
|
+
}, Nr = async (e) => {
|
|
1292
|
+
I(!0);
|
|
1293
|
+
try {
|
|
1294
|
+
const t = await e();
|
|
1295
|
+
for (let o = t.length - 1; o >= 0; o--) {
|
|
1296
|
+
const n = t[o];
|
|
1297
|
+
n && we(n, 0);
|
|
1298
|
+
}
|
|
1299
|
+
} finally {
|
|
1300
|
+
I(!1);
|
|
1301
|
+
}
|
|
1302
|
+
}, x = p(0), ee = p(0);
|
|
1303
|
+
return {
|
|
1304
|
+
element: l,
|
|
1305
|
+
caption: Vt,
|
|
1306
|
+
tHead: zt,
|
|
1307
|
+
tFoot: Pt,
|
|
1308
|
+
rows: Re,
|
|
1309
|
+
rowCount: kt,
|
|
1310
|
+
tBodies: Se,
|
|
1311
|
+
tBodyCount: Nt,
|
|
1312
|
+
data: i,
|
|
1313
|
+
headers: g,
|
|
1314
|
+
columnCount: Bt,
|
|
1315
|
+
createCaption: je,
|
|
1316
|
+
deleteCaption: We,
|
|
1317
|
+
createTHead: Kt,
|
|
1318
|
+
deleteTHead: Ue,
|
|
1319
|
+
createTFoot: Je,
|
|
1320
|
+
deleteTFoot: Qe,
|
|
1321
|
+
createTBody: $t,
|
|
1322
|
+
insertRow: Ot,
|
|
1323
|
+
deleteRow: jt,
|
|
1324
|
+
getTHead: Wt,
|
|
1325
|
+
getTFoot: Ut,
|
|
1326
|
+
getTBody: Jt,
|
|
1327
|
+
getRow: Qt,
|
|
1328
|
+
addRow: we,
|
|
1329
|
+
removeRow: _e,
|
|
1330
|
+
addColumn: Ye,
|
|
1331
|
+
removeColumn: Ze,
|
|
1332
|
+
setCell: be,
|
|
1333
|
+
getCell: ae,
|
|
1334
|
+
setCaption: _t,
|
|
1335
|
+
setHeaders: j,
|
|
1336
|
+
setFooter: Yt,
|
|
1337
|
+
setData: V,
|
|
1338
|
+
clearData: Zt,
|
|
1339
|
+
reset: Gt,
|
|
1340
|
+
sync: Xt,
|
|
1341
|
+
addRowWithAttributes: qt,
|
|
1342
|
+
addColumnWithAttributes: It,
|
|
1343
|
+
setHeadersWithAttributes: xt,
|
|
1344
|
+
setCellWithAttributes: Ge,
|
|
1345
|
+
getRowData: eo,
|
|
1346
|
+
setRowData: Xe,
|
|
1347
|
+
getAllRowData: to,
|
|
1348
|
+
getColumnData: oo,
|
|
1349
|
+
setColumnData: no,
|
|
1350
|
+
getCellRange: so,
|
|
1351
|
+
setCellRange: ro,
|
|
1352
|
+
getHeaderData: lo,
|
|
1353
|
+
getFooterData: ao,
|
|
1354
|
+
setFooterCell: co,
|
|
1355
|
+
getFooterCell: uo,
|
|
1356
|
+
updateCell: Ee,
|
|
1357
|
+
updateRow: Ae,
|
|
1358
|
+
getCellElement: qe,
|
|
1359
|
+
getRowElement: io,
|
|
1360
|
+
selectRows: fo,
|
|
1361
|
+
selectColumns: vo,
|
|
1362
|
+
updateRows: wo,
|
|
1363
|
+
updateCells: ho,
|
|
1364
|
+
getRowElements: go,
|
|
1365
|
+
getRowCellElements: po,
|
|
1366
|
+
setRows: yo,
|
|
1367
|
+
validateCell: mo,
|
|
1368
|
+
validateRow: Co,
|
|
1369
|
+
validateColumn: Ro,
|
|
1370
|
+
validateAll: So,
|
|
1371
|
+
sum: bo,
|
|
1372
|
+
average: Eo,
|
|
1373
|
+
min: Ao,
|
|
1374
|
+
max: Do,
|
|
1375
|
+
count: Fo,
|
|
1376
|
+
aggregate: Mo,
|
|
1377
|
+
transformColumn: Lo,
|
|
1378
|
+
transformRow: To,
|
|
1379
|
+
transformCells: Ho,
|
|
1380
|
+
exportToCSV: ko,
|
|
1381
|
+
exportToJSON: No,
|
|
1382
|
+
importFromArray: Vo,
|
|
1383
|
+
importFromCSV: zo,
|
|
1384
|
+
importFromJSON: Po,
|
|
1385
|
+
search: Bo,
|
|
1386
|
+
searchColumn: Ko,
|
|
1387
|
+
selectedRows: E,
|
|
1388
|
+
selectedCells: oe,
|
|
1389
|
+
selectRow: Ie,
|
|
1390
|
+
deselectRow: xe,
|
|
1391
|
+
toggleRowSelection: $o,
|
|
1392
|
+
isRowSelected: Oo,
|
|
1393
|
+
selectCell: jo,
|
|
1394
|
+
clearSelection: Wo,
|
|
1395
|
+
enableCellEditing: Me,
|
|
1396
|
+
disableCellEditing: Jo,
|
|
1397
|
+
enableHeaderEditing: Qo,
|
|
1398
|
+
disableHeaderEditing: _o,
|
|
1399
|
+
enableColumnEditing: Yo,
|
|
1400
|
+
disableColumnEditing: Zo,
|
|
1401
|
+
enableRowEditing: Go,
|
|
1402
|
+
disableRowEditing: Xo,
|
|
1403
|
+
enableEditing: qo,
|
|
1404
|
+
groupBy: Io,
|
|
1405
|
+
addComputedColumn: xo,
|
|
1406
|
+
removeComputedColumn: en,
|
|
1407
|
+
get pagination() {
|
|
1408
|
+
return A;
|
|
1409
|
+
},
|
|
1410
|
+
paginate: tn,
|
|
1411
|
+
nextPage: on,
|
|
1412
|
+
previousPage: nn,
|
|
1413
|
+
goToPage: sn,
|
|
1414
|
+
get virtualScroll() {
|
|
1415
|
+
return D;
|
|
1416
|
+
},
|
|
1417
|
+
enableVirtualScrolling: rn,
|
|
1418
|
+
disableVirtualScrolling: ln,
|
|
1419
|
+
transaction: cn,
|
|
1420
|
+
onDataChange: un,
|
|
1421
|
+
sortState: fn,
|
|
1422
|
+
sortColumnAscending: dn,
|
|
1423
|
+
sortColumnDescending: vn,
|
|
1424
|
+
sortColumnAscendingWith: wn,
|
|
1425
|
+
sortColumnDescendingWith: hn,
|
|
1426
|
+
clearColumnSort: gn,
|
|
1427
|
+
getSortedColumnIndex: pn,
|
|
1428
|
+
isSortedAscending: yn,
|
|
1429
|
+
isSortedDescending: mn,
|
|
1430
|
+
isSorted: Cn,
|
|
1431
|
+
filterState: Sn,
|
|
1432
|
+
filterRows: lt,
|
|
1433
|
+
filterColumn: Te,
|
|
1434
|
+
filterColumnByValue: bn,
|
|
1435
|
+
filterColumnByValues: En,
|
|
1436
|
+
clearFilters: An,
|
|
1437
|
+
getFilteredRowIndices: Dn,
|
|
1438
|
+
setRowKeyFunction: Fn,
|
|
1439
|
+
clearRowKeyFunction: Mn,
|
|
1440
|
+
hasRowKeyFunction: Ln,
|
|
1441
|
+
getRowByKey: kn,
|
|
1442
|
+
getRowIndexByKey: ue,
|
|
1443
|
+
updateRowByKey: Nn,
|
|
1444
|
+
removeRowByKey: Vn,
|
|
1445
|
+
hasRowWithKey: zn,
|
|
1446
|
+
getRowKey: Tn,
|
|
1447
|
+
getAllRowKeys: Hn,
|
|
1448
|
+
setColumnDefinition: Pn,
|
|
1449
|
+
setColumnDefinitions: Bn,
|
|
1450
|
+
clearColumnDefinition: Kn,
|
|
1451
|
+
clearColumnDefinitions: $n,
|
|
1452
|
+
getColumnDefinition: On,
|
|
1453
|
+
hasColumnDefinition: jn,
|
|
1454
|
+
getParsedCell: Wn,
|
|
1455
|
+
getParsedRowData: at,
|
|
1456
|
+
getParsedColumnData: Un,
|
|
1457
|
+
getParsedData: Jn,
|
|
1458
|
+
dirtyState: ie,
|
|
1459
|
+
markClean: Qn,
|
|
1460
|
+
markDirty: _n,
|
|
1461
|
+
isDirty: Yn,
|
|
1462
|
+
hasChanges: Zn,
|
|
1463
|
+
getChangedCells: Gn,
|
|
1464
|
+
getChangedRowIndices: Xn,
|
|
1465
|
+
getChangedColumnIndices: qn,
|
|
1466
|
+
undo: In,
|
|
1467
|
+
redo: xn,
|
|
1468
|
+
clearHistory: es,
|
|
1469
|
+
canUndo: ts,
|
|
1470
|
+
canRedo: os,
|
|
1471
|
+
getUndoStackSize: ns,
|
|
1472
|
+
getRedoStackSize: ss,
|
|
1473
|
+
setHistoryLimit: rs,
|
|
1474
|
+
getHistoryLimit: ls,
|
|
1475
|
+
selectAllRows: as,
|
|
1476
|
+
deselectAllRows: cs,
|
|
1477
|
+
selectRowRange: us,
|
|
1478
|
+
invertRowSelection: is,
|
|
1479
|
+
getSelectedRowData: fs,
|
|
1480
|
+
getSelectedRowIndices: ut,
|
|
1481
|
+
getSelectedCellIndices: it,
|
|
1482
|
+
focusedCell: M,
|
|
1483
|
+
focusCell: O,
|
|
1484
|
+
clearCellFocus: ds,
|
|
1485
|
+
getFocusedCell: vs,
|
|
1486
|
+
isCellFocused: ws,
|
|
1487
|
+
moveFocusUp: ft,
|
|
1488
|
+
moveFocusDown: dt,
|
|
1489
|
+
moveFocusLeft: vt,
|
|
1490
|
+
moveFocusRight: wt,
|
|
1491
|
+
moveFocusToFirstCell: ht,
|
|
1492
|
+
moveFocusToLastCell: gt,
|
|
1493
|
+
moveFocusToRowStart: pt,
|
|
1494
|
+
moveFocusToRowEnd: yt,
|
|
1495
|
+
enableKeyboardNavigation: hs,
|
|
1496
|
+
visibleColumnCount: gs,
|
|
1497
|
+
hideColumn: Ct,
|
|
1498
|
+
showColumn: Rt,
|
|
1499
|
+
toggleColumnVisibility: ps,
|
|
1500
|
+
isColumnVisible: ys,
|
|
1501
|
+
getVisibleColumnIndices: ms,
|
|
1502
|
+
getHiddenColumnIndices: Cs,
|
|
1503
|
+
moveRow: fe,
|
|
1504
|
+
moveRowUp: Rs,
|
|
1505
|
+
moveRowDown: Ss,
|
|
1506
|
+
moveRowToTop: bs,
|
|
1507
|
+
moveRowToBottom: Es,
|
|
1508
|
+
swapRows: As,
|
|
1509
|
+
moveColumn: de,
|
|
1510
|
+
moveColumnLeft: Ds,
|
|
1511
|
+
moveColumnRight: Fs,
|
|
1512
|
+
moveColumnToStart: Ms,
|
|
1513
|
+
moveColumnToEnd: Ls,
|
|
1514
|
+
swapColumns: Ts,
|
|
1515
|
+
copySelectedCells: Hs,
|
|
1516
|
+
copySelectedRows: ks,
|
|
1517
|
+
copyRow: Ns,
|
|
1518
|
+
copyColumn: Vs,
|
|
1519
|
+
copyCell: zs,
|
|
1520
|
+
copyCellRange: Ps,
|
|
1521
|
+
pasteAtCell: Bs,
|
|
1522
|
+
expandedRows: P,
|
|
1523
|
+
pinnedTopRows: k,
|
|
1524
|
+
pinnedBottomRows: N,
|
|
1525
|
+
expandRow: St,
|
|
1526
|
+
collapseRow: bt,
|
|
1527
|
+
toggleRowExpansion: Ks,
|
|
1528
|
+
expandAllRows: $s,
|
|
1529
|
+
collapseAllRows: Os,
|
|
1530
|
+
isRowExpanded: js,
|
|
1531
|
+
getExpandedRowIndices: Ws,
|
|
1532
|
+
pinRowTop: Us,
|
|
1533
|
+
pinRowBottom: Js,
|
|
1534
|
+
unpinRow: Qs,
|
|
1535
|
+
unpinAllRows: _s,
|
|
1536
|
+
isRowPinnedTop: Ys,
|
|
1537
|
+
isRowPinnedBottom: Zs,
|
|
1538
|
+
getPinnedTopRowIndices: Gs,
|
|
1539
|
+
getPinnedBottomRowIndices: Xs,
|
|
1540
|
+
setCellMeta: qs,
|
|
1541
|
+
getCellMeta: Is,
|
|
1542
|
+
hasCellMeta: xs,
|
|
1543
|
+
clearCellMeta: er,
|
|
1544
|
+
clearCellMetaKey: tr,
|
|
1545
|
+
setRowMeta: or,
|
|
1546
|
+
getRowMeta: nr,
|
|
1547
|
+
hasRowMeta: sr,
|
|
1548
|
+
clearRowMeta: rr,
|
|
1549
|
+
clearRowMetaKey: lr,
|
|
1550
|
+
setColumnMeta: ar,
|
|
1551
|
+
getColumnMeta: cr,
|
|
1552
|
+
hasColumnMeta: ur,
|
|
1553
|
+
clearColumnMeta: ir,
|
|
1554
|
+
clearColumnMetaKey: fr,
|
|
1555
|
+
onRowAdd: dr,
|
|
1556
|
+
onRowRemove: vr,
|
|
1557
|
+
onRowUpdate: wr,
|
|
1558
|
+
onCellChange: hr,
|
|
1559
|
+
onRowSelectionChange: gr,
|
|
1560
|
+
onCellSelectionChange: pr,
|
|
1561
|
+
onSortChange: yr,
|
|
1562
|
+
onFilterChange: mr,
|
|
1563
|
+
onCellFocusChange: Cr,
|
|
1564
|
+
onColumnVisibilityChange: Rr,
|
|
1565
|
+
beginBatchUpdate: Et,
|
|
1566
|
+
endBatchUpdate: At,
|
|
1567
|
+
cancelBatchUpdate: Dt,
|
|
1568
|
+
isBatchUpdating: Sr,
|
|
1569
|
+
batchUpdate: br,
|
|
1570
|
+
tableLoading: Pe,
|
|
1571
|
+
setTableLoading: I,
|
|
1572
|
+
setCellLoading: Er,
|
|
1573
|
+
setRowLoading: Ar,
|
|
1574
|
+
setColumnLoading: Dr,
|
|
1575
|
+
isTableLoading: Fr,
|
|
1576
|
+
isCellLoading: Mr,
|
|
1577
|
+
isRowLoading: Lr,
|
|
1578
|
+
isColumnLoading: Tr,
|
|
1579
|
+
loadData: Hr,
|
|
1580
|
+
appendRowsAsync: kr,
|
|
1581
|
+
prependRowsAsync: Nr,
|
|
1582
|
+
frozenLeftColumnCount: x,
|
|
1583
|
+
frozenRightColumnCount: ee,
|
|
1584
|
+
freezeColumnsLeft: (e) => {
|
|
1585
|
+
x.value = Math.max(0, e);
|
|
1586
|
+
},
|
|
1587
|
+
freezeColumnsRight: (e) => {
|
|
1588
|
+
ee.value = Math.max(0, e);
|
|
1589
|
+
},
|
|
1590
|
+
unfreezeColumnsLeft: () => {
|
|
1591
|
+
x.value = 0;
|
|
1592
|
+
},
|
|
1593
|
+
unfreezeColumnsRight: () => {
|
|
1594
|
+
ee.value = 0;
|
|
1595
|
+
},
|
|
1596
|
+
unfreezeAllColumns: () => {
|
|
1597
|
+
x.value = 0, ee.value = 0;
|
|
1598
|
+
},
|
|
1599
|
+
getFrozenLeftColumnCount: () => x.value,
|
|
1600
|
+
getFrozenRightColumnCount: () => ee.value,
|
|
1601
|
+
isColumnFrozenLeft: (e) => e < x.value,
|
|
1602
|
+
isColumnFrozenRight: (e) => {
|
|
1603
|
+
const t = g.value.length;
|
|
1604
|
+
return e >= t - ee.value;
|
|
1605
|
+
},
|
|
1606
|
+
hasFrozenColumns: () => x.value > 0 || ee.value > 0
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
export {
|
|
1610
|
+
me as isCellConfig,
|
|
1611
|
+
Tt as isValidationError,
|
|
1612
|
+
Gr as isValidationErrorArray,
|
|
1613
|
+
Xr as isValidationResult,
|
|
1614
|
+
qr as useTable
|
|
1615
|
+
};
|