comins-table 0.1.7 → 0.1.8

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