comins-table 0.1.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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +219 -0
- package/dist/clipboard.d.ts +3 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +2 -0
- package/dist/component-renderer.d.ts +5 -0
- package/dist/component-renderer.d.ts.map +1 -0
- package/dist/core.d.ts +680 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +691 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1959 -0
- package/dist/index.js.map +1 -0
- package/dist/selection.d.ts +3 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +2 -0
- package/dist/summary.d.ts +14 -0
- package/dist/summary.d.ts.map +1 -0
- package/dist/tree.d.ts +20 -0
- package/dist/tree.d.ts.map +1 -0
- package/package.json +75 -0
- package/styles.css +1059 -0
package/dist/core.js
ADDED
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
function e(e, t) {
|
|
2
|
+
return t;
|
|
3
|
+
}
|
|
4
|
+
function t(e) {
|
|
5
|
+
return e;
|
|
6
|
+
}
|
|
7
|
+
function n(e) {
|
|
8
|
+
return e.map((e) => ({
|
|
9
|
+
...e,
|
|
10
|
+
id: e.id ?? e.field
|
|
11
|
+
}));
|
|
12
|
+
}
|
|
13
|
+
function r(e, t = []) {
|
|
14
|
+
let n = new Set(e.map((e) => e.id)), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = [];
|
|
15
|
+
for (let e of t) {
|
|
16
|
+
if (i.has(e.id)) continue;
|
|
17
|
+
let t = e.children.filter((e) => !n.has(e) || r.has(e) ? !1 : (r.add(e), !0));
|
|
18
|
+
i.add(e.id), t.length !== 0 && a.push({
|
|
19
|
+
...e,
|
|
20
|
+
children: t
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return a;
|
|
24
|
+
}
|
|
25
|
+
function i(e, t) {
|
|
26
|
+
let n = {};
|
|
27
|
+
for (let r of e) n[r.id] = {
|
|
28
|
+
hidden: t?.columns?.[r.id]?.hidden ?? r.hidden,
|
|
29
|
+
width: t?.columns?.[r.id]?.width ?? r.width
|
|
30
|
+
};
|
|
31
|
+
return n;
|
|
32
|
+
}
|
|
33
|
+
function a(e, t) {
|
|
34
|
+
let n = {};
|
|
35
|
+
for (let r of e) n[r.id] = { hidden: t?.groups?.[r.id]?.hidden ?? r.hidden };
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
38
|
+
function o(e) {
|
|
39
|
+
let t = /* @__PURE__ */ new Map();
|
|
40
|
+
for (let n of e) for (let e of n.children) t.set(e, n.id);
|
|
41
|
+
return t;
|
|
42
|
+
}
|
|
43
|
+
function s(e, t) {
|
|
44
|
+
return e.find((e) => e.id === t);
|
|
45
|
+
}
|
|
46
|
+
function c(e, t, n = []) {
|
|
47
|
+
let r = new Set(e.map((e) => e.id)), i = (t?.order ?? []).filter((e) => r.has(e)), a = e.map((e) => e.id).filter((e) => !i.includes(e)), s = [...i, ...a];
|
|
48
|
+
if (n.length === 0) return s;
|
|
49
|
+
let c = o(n), l = new Map(n.map((e) => [e.id, e])), u = /* @__PURE__ */ new Set(), d = [];
|
|
50
|
+
for (let e of s) {
|
|
51
|
+
let t = c.get(e);
|
|
52
|
+
if (!t) {
|
|
53
|
+
d.push(e);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (u.has(t)) continue;
|
|
57
|
+
let n = l.get(t);
|
|
58
|
+
if (!n) {
|
|
59
|
+
d.push(e);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
let r = s.filter((e) => n.children.includes(e));
|
|
63
|
+
d.push(...r), u.add(t);
|
|
64
|
+
}
|
|
65
|
+
return d;
|
|
66
|
+
}
|
|
67
|
+
function l() {
|
|
68
|
+
return {
|
|
69
|
+
cell: null,
|
|
70
|
+
range: null,
|
|
71
|
+
rowIds: []
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function u(e, t) {
|
|
75
|
+
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
76
|
+
}
|
|
77
|
+
function d(e, t, n = {}) {
|
|
78
|
+
let r = t.map(e.getRowId), i = n.resetSelection === !0 || !u(e.rowIds, r);
|
|
79
|
+
return {
|
|
80
|
+
...e,
|
|
81
|
+
rowIds: r,
|
|
82
|
+
rows: t,
|
|
83
|
+
selection: i ? l() : e.selection
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function f(e, t) {
|
|
87
|
+
return e.rowIds.findIndex((e) => e === t);
|
|
88
|
+
}
|
|
89
|
+
function p(e, t) {
|
|
90
|
+
return e.columns.find((e) => e.id === t);
|
|
91
|
+
}
|
|
92
|
+
function m(e, t) {
|
|
93
|
+
return t.split(".").reduce((e, t) => {
|
|
94
|
+
if (!(typeof e != "object" || !e)) return e[t];
|
|
95
|
+
}, e);
|
|
96
|
+
}
|
|
97
|
+
function h(e, t, n) {
|
|
98
|
+
if (!e || typeof e != "object") return e;
|
|
99
|
+
let r = t.split("."), [i] = r;
|
|
100
|
+
if (!i) return e;
|
|
101
|
+
if (r.length === 1) return {
|
|
102
|
+
...e,
|
|
103
|
+
[i]: n
|
|
104
|
+
};
|
|
105
|
+
let a = { ...e }, o = a;
|
|
106
|
+
return r.slice(0, -1).forEach((e, t) => {
|
|
107
|
+
let n = r[t + 1], i = o[e], a = i && typeof i == "object" && !Array.isArray(i) ? { ...i } : {};
|
|
108
|
+
o[e] = a, n && (o = a);
|
|
109
|
+
}), o[r.at(-1)] = n, a;
|
|
110
|
+
}
|
|
111
|
+
function g(e, t, n, r) {
|
|
112
|
+
let i = e.rowIds.indexOf(n);
|
|
113
|
+
return {
|
|
114
|
+
column: {
|
|
115
|
+
definition: r,
|
|
116
|
+
field: r.field,
|
|
117
|
+
id: r.id,
|
|
118
|
+
index: e.columns.findIndex((e) => e.id === r.id),
|
|
119
|
+
label: r.label
|
|
120
|
+
},
|
|
121
|
+
row: {
|
|
122
|
+
data: t,
|
|
123
|
+
dataIndex: i,
|
|
124
|
+
disabled: !1,
|
|
125
|
+
id: n,
|
|
126
|
+
index: i,
|
|
127
|
+
selected: e.selection.rowIds.includes(n)
|
|
128
|
+
},
|
|
129
|
+
selection: { selectedRowCount: e.selection.rowIds.length },
|
|
130
|
+
value: K(e, t, r.id)
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function _(e, t) {
|
|
134
|
+
return e === void 0 ? !0 : typeof e == "boolean" ? e : e(t);
|
|
135
|
+
}
|
|
136
|
+
function v(e, t, n, r) {
|
|
137
|
+
let i = g(e, t, n, r), a = r.cell?.props;
|
|
138
|
+
return typeof a == "function" ? a(i) : a;
|
|
139
|
+
}
|
|
140
|
+
function y(e, t) {
|
|
141
|
+
let n = W(e), r = f(e, t.anchor.rowId), i = f(e, t.focus.rowId), a = n.findIndex((e) => e.id === t.anchor.columnId), o = n.findIndex((e) => e.id === t.focus.columnId);
|
|
142
|
+
return r < 0 || i < 0 || a < 0 || o < 0 ? null : {
|
|
143
|
+
columnEnd: Math.max(a, o),
|
|
144
|
+
columnStart: Math.min(a, o),
|
|
145
|
+
rowEnd: Math.max(r, i),
|
|
146
|
+
rowStart: Math.min(r, i),
|
|
147
|
+
visibleColumns: n
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function b(e, t) {
|
|
151
|
+
return e && typeof e == "object" && "id" in e ? {
|
|
152
|
+
...e,
|
|
153
|
+
id: t
|
|
154
|
+
} : e;
|
|
155
|
+
}
|
|
156
|
+
function x(e, t) {
|
|
157
|
+
let n = 1, r = `${String(t)}-copy-${n}`, i = new Set(e.map(String));
|
|
158
|
+
for (; i.has(r);) n += 1, r = `${String(t)}-copy-${n}`;
|
|
159
|
+
return r;
|
|
160
|
+
}
|
|
161
|
+
function S(e, t, n, r, i) {
|
|
162
|
+
if (t === void 0) return !1;
|
|
163
|
+
let a = g(e, t, n, r), o = v(e, t, n, r);
|
|
164
|
+
return o?.disabled !== void 0 && _(o.disabled, a) === !0 ? !1 : _(i === "copy" ? o?.copyable : o?.pasteable, a);
|
|
165
|
+
}
|
|
166
|
+
function ee(e, t) {
|
|
167
|
+
return typeof e == "number" && typeof t == "number" ? e - t : String(e ?? "").localeCompare(String(t ?? ""));
|
|
168
|
+
}
|
|
169
|
+
function te({ columnLayout: o, columnGroups: s, columns: u, getRowId: d = e, pagination: f, rows: p, showHeader: m = !0, sort: h = null, theme: g = {} }) {
|
|
170
|
+
let _ = t(p), v = n(u), y = r(v, s);
|
|
171
|
+
return {
|
|
172
|
+
columnOrder: c(v, o, y),
|
|
173
|
+
columnGroups: y,
|
|
174
|
+
columnGroupState: a(y, o),
|
|
175
|
+
columns: v,
|
|
176
|
+
columnState: i(v, o),
|
|
177
|
+
getRowId: d,
|
|
178
|
+
pagination: {
|
|
179
|
+
pageIndex: f?.pageIndex ?? 0,
|
|
180
|
+
pageSize: f?.pageSize ?? Math.max(_.length, 1)
|
|
181
|
+
},
|
|
182
|
+
rowIds: _.map(d),
|
|
183
|
+
rows: _,
|
|
184
|
+
selection: l(),
|
|
185
|
+
showHeader: m,
|
|
186
|
+
sort: h,
|
|
187
|
+
theme: g
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function ne(e, t) {
|
|
191
|
+
return t ? e.rows.filter(t) : [...e.rows];
|
|
192
|
+
}
|
|
193
|
+
function C(e, n) {
|
|
194
|
+
return d(e, t(n), { resetSelection: !0 });
|
|
195
|
+
}
|
|
196
|
+
function w(e, t) {
|
|
197
|
+
return d(e, [...e.rows, ...t]);
|
|
198
|
+
}
|
|
199
|
+
function T(e, t) {
|
|
200
|
+
let n = new Map(t.map((e) => [e.id, e.patch]));
|
|
201
|
+
return d(e, e.rows.map((t, r) => {
|
|
202
|
+
let i = e.rowIds[r], a = i === void 0 ? void 0 : n.get(i);
|
|
203
|
+
return a ? typeof a == "function" ? a(t) : {
|
|
204
|
+
...t,
|
|
205
|
+
...a
|
|
206
|
+
} : t;
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
209
|
+
function re(e, t) {
|
|
210
|
+
let n = new Set(t);
|
|
211
|
+
return d(e, e.rows.filter((t, r) => {
|
|
212
|
+
let i = e.rowIds[r];
|
|
213
|
+
return i === void 0 || !n.has(i);
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
function ie(e, t) {
|
|
217
|
+
return {
|
|
218
|
+
...e,
|
|
219
|
+
theme: {
|
|
220
|
+
...e.theme,
|
|
221
|
+
...t
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function ae(e, t) {
|
|
226
|
+
return {
|
|
227
|
+
...e,
|
|
228
|
+
showHeader: t
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function oe(e, t) {
|
|
232
|
+
return {
|
|
233
|
+
...e,
|
|
234
|
+
pagination: {
|
|
235
|
+
pageIndex: t.pageIndex ?? e.pagination.pageIndex,
|
|
236
|
+
pageSize: t.pageSize ?? e.pagination.pageSize
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function E(e, t) {
|
|
241
|
+
return {
|
|
242
|
+
...e,
|
|
243
|
+
sort: t
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function se(e) {
|
|
247
|
+
return E(e, null);
|
|
248
|
+
}
|
|
249
|
+
function ce(e, t, n) {
|
|
250
|
+
return {
|
|
251
|
+
...e,
|
|
252
|
+
columnState: {
|
|
253
|
+
...e.columnState,
|
|
254
|
+
[t]: {
|
|
255
|
+
...e.columnState[t],
|
|
256
|
+
width: n
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function le(e, t, n) {
|
|
262
|
+
return {
|
|
263
|
+
...e,
|
|
264
|
+
columnState: {
|
|
265
|
+
...e.columnState,
|
|
266
|
+
[t]: {
|
|
267
|
+
...e.columnState[t],
|
|
268
|
+
hidden: n
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function ue(e, t, n) {
|
|
274
|
+
return s(e.columnGroups, t) ? {
|
|
275
|
+
...e,
|
|
276
|
+
columnGroupState: {
|
|
277
|
+
...e.columnGroupState,
|
|
278
|
+
[t]: {
|
|
279
|
+
...e.columnGroupState[t],
|
|
280
|
+
hidden: n
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
} : e;
|
|
284
|
+
}
|
|
285
|
+
function de(e, t) {
|
|
286
|
+
return e.columnState[t.id]?.width ?? t.width ?? 100;
|
|
287
|
+
}
|
|
288
|
+
function D(e) {
|
|
289
|
+
return Math.max(50, e.minWidth ?? 50);
|
|
290
|
+
}
|
|
291
|
+
function O(e) {
|
|
292
|
+
return e.maxWidth ?? Infinity;
|
|
293
|
+
}
|
|
294
|
+
function k(e, t, n) {
|
|
295
|
+
return Math.min(n, Math.max(t, e));
|
|
296
|
+
}
|
|
297
|
+
function A(e, t, n) {
|
|
298
|
+
let r = t.map((t) => k(de(e, t), D(t), O(t))), i = new Set(t.map((e, t) => t)), a = t.map(D), o = t.map(O), s = k(n, a.reduce((e, t) => e + t, 0), o.reduce((e, t) => e + t, 0));
|
|
299
|
+
for (; i.size > 0;) {
|
|
300
|
+
let e = s - r.reduce((e, t) => e + t, 0);
|
|
301
|
+
if (Math.abs(e) < .001) break;
|
|
302
|
+
let t = [...i], n = t.reduce((e, t) => e + Math.max(r[t] ?? 0, 0), 0), c = !1;
|
|
303
|
+
for (let s of t) {
|
|
304
|
+
let l = r[s] ?? 0, u = l + e * (n > 0 ? l / n : 1 / t.length), d = k(u, a[s] ?? 0, o[s] ?? Infinity);
|
|
305
|
+
r[s] = d, Math.abs(d - u) > .001 && (i.delete(s), c = !0);
|
|
306
|
+
}
|
|
307
|
+
if (!c) break;
|
|
308
|
+
}
|
|
309
|
+
return r;
|
|
310
|
+
}
|
|
311
|
+
function j(e, t, n) {
|
|
312
|
+
let r = s(e.columnGroups, t);
|
|
313
|
+
if (!r || e.columnGroupState[r.id]?.hidden === !0) return e;
|
|
314
|
+
let i = r.children.map((t) => p(e, t)).filter((e) => !!e).filter((t) => e.columnState[t.id]?.hidden !== !0);
|
|
315
|
+
if (i.length === 0) return e;
|
|
316
|
+
let a = A(e, i, n), o = { ...e.columnState };
|
|
317
|
+
return i.forEach((e, t) => {
|
|
318
|
+
o[e.id] = {
|
|
319
|
+
...o[e.id],
|
|
320
|
+
width: a[t]
|
|
321
|
+
};
|
|
322
|
+
}), {
|
|
323
|
+
...e,
|
|
324
|
+
columnState: o
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function M(e, t, n) {
|
|
328
|
+
let r = o(e.columnGroups).get(t), i = e.columnOrder.filter((e) => e !== t);
|
|
329
|
+
if (i.length === e.columnOrder.length) return e;
|
|
330
|
+
let a = Math.max(0, Math.min(n, i.length));
|
|
331
|
+
if (r) {
|
|
332
|
+
let t = s(e.columnGroups, r);
|
|
333
|
+
if (!t) return e;
|
|
334
|
+
let n = i.filter((e) => t.children.includes(e)), o = i.findIndex((e) => t.children.includes(e)), c = o + n.length;
|
|
335
|
+
if (a < o || a > c) return e;
|
|
336
|
+
} else if (e.columnGroups.length > 0) for (let t of e.columnGroups) {
|
|
337
|
+
let n = i.filter((e) => t.children.includes(e));
|
|
338
|
+
if (n.length === 0) continue;
|
|
339
|
+
let r = i.findIndex((e) => t.children.includes(e)), o = r + n.length;
|
|
340
|
+
if (a > r && a < o) return e;
|
|
341
|
+
}
|
|
342
|
+
return i.splice(a, 0, t), {
|
|
343
|
+
...e,
|
|
344
|
+
columnOrder: i
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function N(e, t, n) {
|
|
348
|
+
let r = s(e.columnGroups, t);
|
|
349
|
+
if (!r) return e;
|
|
350
|
+
let i = e.columnOrder.filter((e) => r.children.includes(e));
|
|
351
|
+
if (i.length === 0) return e;
|
|
352
|
+
let a = e.columnOrder.filter((e) => !r.children.includes(e)), o = Math.max(0, Math.min(n, a.length)), c = [
|
|
353
|
+
...a.slice(0, o),
|
|
354
|
+
...i,
|
|
355
|
+
...a.slice(o)
|
|
356
|
+
];
|
|
357
|
+
return {
|
|
358
|
+
...e,
|
|
359
|
+
columnOrder: c
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function P(e) {
|
|
363
|
+
let t = e.columnGroups.length === 0 ? void 0 : Object.fromEntries(e.columnGroups.map((t) => [t.id, { ...e.columnGroupState[t.id] }]));
|
|
364
|
+
return {
|
|
365
|
+
columns: { ...e.columnState },
|
|
366
|
+
...t ? { groups: t } : {},
|
|
367
|
+
order: [...e.columnOrder]
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function F(e, t) {
|
|
371
|
+
return {
|
|
372
|
+
...e,
|
|
373
|
+
columnOrder: c(e.columns, t, e.columnGroups),
|
|
374
|
+
columnGroupState: a(e.columnGroups, t),
|
|
375
|
+
columnState: i(e.columns, t)
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function I(e, t, n = {}) {
|
|
379
|
+
let r = e.selection.rowIds, i = r.includes(t), a = n.multi ? n.toggle && i ? r.filter((e) => e !== t) : i ? r : [...r, t] : n.toggle && i ? [] : [t];
|
|
380
|
+
return {
|
|
381
|
+
...e,
|
|
382
|
+
selection: {
|
|
383
|
+
...e.selection,
|
|
384
|
+
rowIds: a
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function L(e, t) {
|
|
389
|
+
return {
|
|
390
|
+
...e,
|
|
391
|
+
selection: {
|
|
392
|
+
...e.selection,
|
|
393
|
+
rowIds: [...t]
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function R(e, t) {
|
|
398
|
+
return {
|
|
399
|
+
...e,
|
|
400
|
+
selection: {
|
|
401
|
+
...e.selection,
|
|
402
|
+
cell: t,
|
|
403
|
+
range: null
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function z(e, t) {
|
|
408
|
+
return {
|
|
409
|
+
...e,
|
|
410
|
+
selection: {
|
|
411
|
+
...e.selection,
|
|
412
|
+
cell: t.focus,
|
|
413
|
+
range: t
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function B(e) {
|
|
418
|
+
return {
|
|
419
|
+
...e,
|
|
420
|
+
selection: {
|
|
421
|
+
...e.selection,
|
|
422
|
+
range: null
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function V(e) {
|
|
427
|
+
return {
|
|
428
|
+
...e,
|
|
429
|
+
selection: l()
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function H(e, t) {
|
|
433
|
+
return e.selection.rowIds.includes(t);
|
|
434
|
+
}
|
|
435
|
+
function fe(e, t) {
|
|
436
|
+
return e.selection.cell?.rowId === t.rowId && e.selection.cell.columnId === t.columnId;
|
|
437
|
+
}
|
|
438
|
+
function U(e, t = e.selection.range) {
|
|
439
|
+
if (!t) return [];
|
|
440
|
+
let n = W(e), r = y(e, t);
|
|
441
|
+
if (!r) return [];
|
|
442
|
+
let i = [];
|
|
443
|
+
for (let t = r.rowStart; t <= r.rowEnd; t += 1) {
|
|
444
|
+
let a = e.rowIds[t];
|
|
445
|
+
if (a !== void 0) for (let e = r.columnStart; e <= r.columnEnd; e += 1) {
|
|
446
|
+
let t = n[e];
|
|
447
|
+
t && i.push({
|
|
448
|
+
columnId: t.id,
|
|
449
|
+
rowId: a
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
return i;
|
|
454
|
+
}
|
|
455
|
+
function pe(e, t) {
|
|
456
|
+
return U(e).some((e) => e.rowId === t.rowId && e.columnId === t.columnId);
|
|
457
|
+
}
|
|
458
|
+
function W(e) {
|
|
459
|
+
let t = o(e.columnGroups);
|
|
460
|
+
return e.columnOrder.map((t) => p(e, t)).filter((e) => !!e).filter((n) => {
|
|
461
|
+
let r = t.get(n.id);
|
|
462
|
+
return e.columnState[n.id]?.hidden !== !0 && (!r || e.columnGroupState[r]?.hidden !== !0);
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
function me(e) {
|
|
466
|
+
let t = W(e);
|
|
467
|
+
if (e.columnGroups.length === 0) return [t.map((e) => ({
|
|
468
|
+
colSpan: 1,
|
|
469
|
+
column: e,
|
|
470
|
+
columnId: e.id,
|
|
471
|
+
kind: "column",
|
|
472
|
+
rowSpan: 1
|
|
473
|
+
}))];
|
|
474
|
+
let n = new Set(t.map((e) => e.id)), r = o(e.columnGroups), i = new Map(e.columnGroups.map((e) => [e.id, e])), a = /* @__PURE__ */ new Set(), s = [], c = [];
|
|
475
|
+
for (let t of e.columnOrder) {
|
|
476
|
+
if (!n.has(t)) continue;
|
|
477
|
+
let o = p(e, t);
|
|
478
|
+
if (!o) continue;
|
|
479
|
+
let l = r.get(t);
|
|
480
|
+
if (!l) {
|
|
481
|
+
s.push({
|
|
482
|
+
colSpan: 1,
|
|
483
|
+
column: o,
|
|
484
|
+
columnId: o.id,
|
|
485
|
+
kind: "column",
|
|
486
|
+
rowSpan: 2
|
|
487
|
+
});
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (a.has(l)) continue;
|
|
491
|
+
let u = i.get(l);
|
|
492
|
+
if (!u) continue;
|
|
493
|
+
let d = e.columnOrder.filter((e) => u.children.includes(e) && n.has(e)).map((t) => p(e, t)).filter((e) => !!e);
|
|
494
|
+
if (d.length === 0) {
|
|
495
|
+
a.add(l);
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
s.push({
|
|
499
|
+
colSpan: d.length,
|
|
500
|
+
group: u,
|
|
501
|
+
groupId: l,
|
|
502
|
+
kind: "group",
|
|
503
|
+
rowSpan: 1
|
|
504
|
+
}), c.push(...d.map((e) => ({
|
|
505
|
+
colSpan: 1,
|
|
506
|
+
column: e,
|
|
507
|
+
columnId: e.id,
|
|
508
|
+
groupId: l,
|
|
509
|
+
kind: "column",
|
|
510
|
+
rowSpan: 1
|
|
511
|
+
}))), a.add(l);
|
|
512
|
+
}
|
|
513
|
+
return [s, c];
|
|
514
|
+
}
|
|
515
|
+
function G(e) {
|
|
516
|
+
let t = e.rows.map((e, t) => t);
|
|
517
|
+
if (!e.sort) return t;
|
|
518
|
+
let n = p(e, e.sort.columnId);
|
|
519
|
+
return !n || !n.sort ? t : [...t].sort((t, r) => {
|
|
520
|
+
let i = e.rows[t], a = e.rows[r], o = K(e, i, n.id), s = K(e, a, n.id), c = typeof n.sort == "function" ? n.sort(o, s, i, a) : ee(o, s);
|
|
521
|
+
return e.sort?.direction === "desc" ? c * -1 : c;
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
function he(e, t) {
|
|
525
|
+
let n = E(e, t);
|
|
526
|
+
return d(n, G(n).map((e) => n.rows[e]));
|
|
527
|
+
}
|
|
528
|
+
function ge(e, t = {}) {
|
|
529
|
+
let n = t.pageIndex ?? e.pagination.pageIndex, r = t.pageSize ?? e.pagination.pageSize, i = Math.max(0, n) * Math.max(1, r);
|
|
530
|
+
return G(e).slice(i, i + Math.max(1, r)).map((t) => e.rows[t]);
|
|
531
|
+
}
|
|
532
|
+
function _e(e, { overscan: t = 2, rowHeight: n, scrollTop: r, viewportHeight: i }) {
|
|
533
|
+
let a = Math.max(1, n), o = G(e), s = o.length, c = s * a, l = Math.max(0, Math.floor(Math.max(0, r) / a) - Math.max(0, t)), u = Math.min(s, Math.ceil((Math.max(0, r) + Math.max(0, i)) / a) + Math.max(0, t)), d = l * a;
|
|
534
|
+
return {
|
|
535
|
+
bottomSpacerHeight: Math.max(0, c - d - (u - l) * a),
|
|
536
|
+
endIndex: u,
|
|
537
|
+
rows: o.slice(l, u).map((t) => e.rows[t]),
|
|
538
|
+
startIndex: l,
|
|
539
|
+
topSpacerHeight: d,
|
|
540
|
+
totalHeight: c
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
function ve(e, t, n) {
|
|
544
|
+
let r = f(e, t);
|
|
545
|
+
if (r < 0) return e;
|
|
546
|
+
let i = [...e.rows], [a] = i.splice(r, 1);
|
|
547
|
+
return a === void 0 ? e : (i.splice(Math.max(0, Math.min(n, i.length)), 0, a), d(e, i));
|
|
548
|
+
}
|
|
549
|
+
function K(e, t, n) {
|
|
550
|
+
let r = p(e, n);
|
|
551
|
+
return r ? m(t, r.field) : void 0;
|
|
552
|
+
}
|
|
553
|
+
function ye(e, t, n, r) {
|
|
554
|
+
let i = K(e, t, r.id);
|
|
555
|
+
return r.cell?.format ? r.cell.format(g(e, t, n, r)) : i == null ? "" : String(i);
|
|
556
|
+
}
|
|
557
|
+
function be(e, t, n, r) {
|
|
558
|
+
let i = v(e, t, n, r);
|
|
559
|
+
return i?.disabled !== void 0 && _(i.disabled, g(e, t, n, r)) === !0;
|
|
560
|
+
}
|
|
561
|
+
function xe(e, t, n, r) {
|
|
562
|
+
let i = g(e, t, n, r), a = v(e, t, n, r)?.className;
|
|
563
|
+
return typeof a == "function" ? a(i) : a;
|
|
564
|
+
}
|
|
565
|
+
function Se(e, t, n, r) {
|
|
566
|
+
let i = g(e, t, n, r), a = v(e, t, n, r)?.style;
|
|
567
|
+
return typeof a == "function" ? a(i) : a;
|
|
568
|
+
}
|
|
569
|
+
function Ce(e, t) {
|
|
570
|
+
let n = e.rows[f(e, t)];
|
|
571
|
+
if (n === void 0) throw Error(`Cannot copy missing row: ${String(t)}`);
|
|
572
|
+
return {
|
|
573
|
+
kind: "row",
|
|
574
|
+
row: n,
|
|
575
|
+
text: JSON.stringify(n)
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
function we(e, t, n) {
|
|
579
|
+
if (n.mode === "append") {
|
|
580
|
+
let r = n.getNewRowId?.(t.row);
|
|
581
|
+
return w(e, [r === void 0 ? t.row : b(t.row, r)]);
|
|
582
|
+
}
|
|
583
|
+
if (n.mode === "insert-after") {
|
|
584
|
+
let r = f(e, n.targetRowId);
|
|
585
|
+
if (r < 0) return e;
|
|
586
|
+
let i = e.getRowId(t.row, r), a = n.getPastedRowId?.(t.row) ?? x(e.rowIds, i), o = b(t.row, a), s = [...e.rows];
|
|
587
|
+
return s.splice(r + 1, 0, o), d(e, s);
|
|
588
|
+
}
|
|
589
|
+
return T(e, [{
|
|
590
|
+
id: n.targetRowId,
|
|
591
|
+
patch: b(t.row, n.targetRowId)
|
|
592
|
+
}]);
|
|
593
|
+
}
|
|
594
|
+
function q(e, { columnId: t, rowId: n }) {
|
|
595
|
+
let r = e.rows[f(e, n)], i = p(e, t);
|
|
596
|
+
if (!i || !S(e, r, n, i, "copy")) return null;
|
|
597
|
+
let a = K(e, r, t);
|
|
598
|
+
return {
|
|
599
|
+
kind: "cell",
|
|
600
|
+
text: a == null ? "" : String(a),
|
|
601
|
+
value: a
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
function J(e, { columnId: t, rowId: n }, r) {
|
|
605
|
+
let i = p(e, t), a = e.rows[f(e, n)];
|
|
606
|
+
return !r || !i || !S(e, a, n, i, "paste") ? e : T(e, [{
|
|
607
|
+
id: n,
|
|
608
|
+
patch: (e) => h(e, i.field, r.value)
|
|
609
|
+
}]);
|
|
610
|
+
}
|
|
611
|
+
function Y(e, t = e.selection.range) {
|
|
612
|
+
if (!t) return null;
|
|
613
|
+
let n = y(e, t);
|
|
614
|
+
if (!n) return null;
|
|
615
|
+
let r = [];
|
|
616
|
+
for (let t = n.rowStart; t <= n.rowEnd; t += 1) {
|
|
617
|
+
let i = e.rows[t], a = e.rowIds[t], o = [];
|
|
618
|
+
for (let t = n.columnStart; t <= n.columnEnd; t += 1) {
|
|
619
|
+
let r = n.visibleColumns[t];
|
|
620
|
+
if (i === void 0 || a === void 0 || !r || !S(e, i, a, r, "copy")) {
|
|
621
|
+
o.push(null);
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
let s = K(e, i, r.id);
|
|
625
|
+
o.push({
|
|
626
|
+
columnId: r.id,
|
|
627
|
+
text: s == null ? "" : String(s),
|
|
628
|
+
value: s
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
r.push(o);
|
|
632
|
+
}
|
|
633
|
+
return {
|
|
634
|
+
kind: "cell-range",
|
|
635
|
+
rows: r,
|
|
636
|
+
text: r.map((e) => e.map((e) => e?.text ?? "").join(" ")).join("\n")
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function Te(e, t, n) {
|
|
640
|
+
if (!n) return e;
|
|
641
|
+
let r = W(e), i = f(e, t.rowId), a = r.findIndex((e) => e.id === t.columnId), o = [...e.rows];
|
|
642
|
+
if (i < 0 || a < 0) return e;
|
|
643
|
+
let s = !1;
|
|
644
|
+
return n.rows.forEach((t, n) => {
|
|
645
|
+
let c = i + n, l = o[c], u = e.rowIds[c];
|
|
646
|
+
l === void 0 || u === void 0 || t.forEach((t, n) => {
|
|
647
|
+
let i = r[a + n];
|
|
648
|
+
!t || !i || !S(e, l, u, i, "paste") || (o[c] = h(o[c], i.field, t.value), s = !0);
|
|
649
|
+
});
|
|
650
|
+
}), s ? d(e, o) : e;
|
|
651
|
+
}
|
|
652
|
+
function Ee(e, { source: t, target: n }) {
|
|
653
|
+
let r = q(e, t);
|
|
654
|
+
return r ? U(e, n).reduce((e, t) => J(e, t, r), e) : e;
|
|
655
|
+
}
|
|
656
|
+
function X({ columnOrder: e, columns: t }) {
|
|
657
|
+
if (!e?.length) return t;
|
|
658
|
+
let n = new Map(t.map((e) => [e.id, e]));
|
|
659
|
+
return e.map((e) => n.get(e)).filter((e) => !!e);
|
|
660
|
+
}
|
|
661
|
+
function De(e) {
|
|
662
|
+
return e == null ? "" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? String(e) : JSON.stringify(e);
|
|
663
|
+
}
|
|
664
|
+
function Z(e) {
|
|
665
|
+
let t = De(e);
|
|
666
|
+
return /[",\r\n]/u.test(t) ? `"${t.replaceAll("\"", "\"\"")}"` : t;
|
|
667
|
+
}
|
|
668
|
+
function Q(e, t) {
|
|
669
|
+
return e.id && t?.[e.id] !== void 0 ? t[e.id] : e.label ?? e.id ?? "";
|
|
670
|
+
}
|
|
671
|
+
function $(e, t, n, r) {
|
|
672
|
+
return r === "formatted" && e.format ? e.format(t, n) : e.value(t, n);
|
|
673
|
+
}
|
|
674
|
+
function Oe({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
|
|
675
|
+
let a = X({
|
|
676
|
+
columnOrder: e,
|
|
677
|
+
columns: t
|
|
678
|
+
});
|
|
679
|
+
return [a.map((e) => Z(Q(e, n))).join(","), ...r.map((e, t) => a.map((n) => Z($(n, e, t, i))).join(","))].join("\n");
|
|
680
|
+
}
|
|
681
|
+
function ke({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
|
|
682
|
+
let a = X({
|
|
683
|
+
columnOrder: e,
|
|
684
|
+
columns: t
|
|
685
|
+
}), o = r.map((e, t) => Object.fromEntries(a.map((r) => [Q(r, n), $(r, e, t, i)])));
|
|
686
|
+
return JSON.stringify(o, null, 2);
|
|
687
|
+
}
|
|
688
|
+
//#endregion
|
|
689
|
+
export { w as addCominsRows, F as applyCominsColumnLayout, B as clearCominsCellRange, V as clearCominsSelection, se as clearCominsSortState, q as copyCominsCell, Y as copyCominsCellRange, Ce as copyCominsRow, te as createCominsTableState, re as deleteCominsRows, Oe as exportCominsRowsToCsv, ke as exportCominsRowsToJson, Ee as fillCominsCellRange, ye as formatCominsCellValue, xe as getCominsCellClassName, Se as getCominsCellStyle, K as getCominsCellValue, me as getCominsHeaderRows, ge as getCominsPageRows, U as getCominsSelectedCellRange, G as getCominsSortedRowIndexes, _e as getCominsVirtualRows, W as getCominsVisibleColumns, be as isCominsCellDisabled, pe as isCominsCellInSelectedRange, fe as isCominsCellSelected, H as isCominsRowSelected, M as moveCominsColumn, N as moveCominsColumnGroup, ve as moveCominsRow, J as pasteCominsCell, Te as pasteCominsCellRange, we as pasteCominsRow, ne as queryCominsRows, C as replaceCominsRows, R as selectCell, z as selectCellRange, I as selectRow, L as selectRows, P as serializeCominsColumnLayout, ue as setCominsColumnGroupHidden, j as setCominsColumnGroupWidth, le as setCominsColumnHidden, ce as setCominsColumnWidth, ae as setCominsHeaderVisible, oe as setCominsPagination, E as setCominsSortState, ie as setCominsTableTheme, he as sortCominsRows, T as updateCominsRows };
|
|
690
|
+
|
|
691
|
+
//# sourceMappingURL=core.js.map
|