comins-table 0.1.6 → 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,757 +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) {
185
- let n = G(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);
186
- return r < 0 || i < 0 || a < 0 || o < 0 ? null : {
187
- columnEnd: Math.max(a, o),
188
- columnStart: Math.min(a, o),
189
- rowEnd: Math.max(r, i),
190
- rowStart: Math.min(r, i),
191
- visibleColumns: n
192
- };
193
- }
194
- function S(e, t) {
195
- return e && typeof e == "object" && "id" in e ? {
196
- ...e,
197
- id: t
198
- } : e;
199
- }
200
- function ee(e, t) {
201
- let n = 1, r = `${String(t)}-copy-${n}`, i = new Set(e.map(String));
202
- for (; i.has(r);) n += 1, r = `${String(t)}-copy-${n}`;
203
- return r;
204
- }
205
- function C(e, t, n, r, i) {
206
- if (t === void 0) return !1;
207
- let a = v(e, t, n, r), o = b(e, t, n, r);
208
- return o?.disabled !== void 0 && y(o.disabled, a) === !0 ? !1 : y(i === "copy" ? o?.copyable : o?.pasteable, a);
209
- }
210
- function te(e, t) {
211
- return typeof e == "number" && typeof t == "number" ? e - t : String(e ?? "").localeCompare(String(t ?? ""));
212
- }
213
- function w({ columnLayout: o, columnGroups: s, columns: u, getRowId: d = e, pagination: f, rows: p, showHeader: m = !0, sort: g = null, sortModel: _, theme: v = {} }) {
214
- let y = t(p), b = n(u), x = r(b, s), S = h(b, _ ?? (g ? [g] : []));
215
- return {
216
- columnOrder: c(b, o, x),
217
- columnGroups: x,
218
- columnGroupState: a(x, o),
219
- columns: b,
220
- columnState: i(b, o),
221
- getRowId: d,
222
- pagination: {
223
- pageIndex: f?.pageIndex ?? 0,
224
- pageSize: f?.pageSize ?? Math.max(y.length, 1)
225
- },
226
- rowIds: y.map(d),
227
- rows: y,
228
- selection: l(),
229
- showHeader: m,
230
- sort: S[0] ?? null,
231
- sortModel: S,
232
- theme: v
233
- };
234
- }
235
- function T(e, t) {
236
- return t ? e.rows.filter(t) : [...e.rows];
237
- }
238
- function ne(e, n) {
239
- return d(e, t(n), { resetSelection: !0 });
240
- }
241
- function E(e, t) {
242
- return d(e, [...e.rows, ...t]);
243
- }
244
- function D(e, t) {
245
- let n = new Map(t.map((e) => [e.id, e.patch]));
246
- return d(e, e.rows.map((t, r) => {
247
- let i = e.rowIds[r], a = i === void 0 ? void 0 : n.get(i);
248
- return a ? typeof a == "function" ? a(t) : {
249
- ...t,
250
- ...a
251
- } : t;
252
- }));
253
- }
254
- function re(e, t) {
255
- let n = new Set(t);
256
- return d(e, e.rows.filter((t, r) => {
257
- let i = e.rowIds[r];
258
- return i === void 0 || !n.has(i);
259
- }));
260
- }
261
- function ie(e, t) {
262
- return {
263
- ...e,
264
- theme: {
265
- ...e.theme,
266
- ...t
267
- }
268
- };
269
- }
270
- function ae(e, t) {
271
- return {
272
- ...e,
273
- showHeader: t
274
- };
275
- }
276
- function oe(e, t) {
277
- return {
278
- ...e,
279
- pagination: {
280
- pageIndex: t.pageIndex ?? e.pagination.pageIndex,
281
- pageSize: t.pageSize ?? e.pagination.pageSize
282
- }
283
- };
284
- }
285
- function O(e, t) {
286
- return k(e, t ? [t] : []);
287
- }
288
- function k(e, t) {
289
- let n = h(e.columns, t), r = n[0] ?? null;
290
- return m(e.sortModel, n) ? e : {
291
- ...e,
292
- sort: r,
293
- sortModel: n
294
- };
295
- }
296
- function A(e) {
297
- return k(e, []);
298
- }
299
- function se(e, t, n) {
300
- return {
301
- ...e,
302
- columnState: {
303
- ...e.columnState,
304
- [t]: {
305
- ...e.columnState[t],
306
- width: n
307
- }
308
- }
309
- };
310
- }
311
- function ce(e, t, n) {
312
- return {
313
- ...e,
314
- columnState: {
315
- ...e.columnState,
316
- [t]: {
317
- ...e.columnState[t],
318
- hidden: n
319
- }
320
- }
321
- };
322
- }
323
- function le(e, t, n) {
324
- return s(e.columnGroups, t) ? {
325
- ...e,
326
- columnGroupState: {
327
- ...e.columnGroupState,
328
- [t]: {
329
- ...e.columnGroupState[t],
330
- hidden: n
331
- }
332
- }
333
- } : e;
334
- }
335
- function ue(e, t) {
336
- return e.columnState[t.id]?.width ?? t.width ?? 100;
337
- }
338
- function j(e) {
339
- return Math.max(88, e.minWidth ?? 88);
340
- }
341
- function M(e) {
342
- return e.maxWidth ?? Infinity;
343
- }
344
- function N(e, t, n) {
345
- return Math.min(n, Math.max(t, e));
346
- }
347
- function P(e, t, n) {
348
- 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));
349
- for (; i.size > 0;) {
350
- let e = s - r.reduce((e, t) => e + t, 0);
351
- if (Math.abs(e) < .001) break;
352
- let t = [...i], n = t.reduce((e, t) => e + Math.max(r[t] ?? 0, 0), 0), c = !1;
353
- for (let s of t) {
354
- let l = r[s] ?? 0, u = l + e * (n > 0 ? l / n : 1 / t.length), d = N(u, a[s] ?? 0, o[s] ?? Infinity);
355
- r[s] = d, Math.abs(d - u) > .001 && (i.delete(s), c = !0);
356
- }
357
- if (!c) break;
358
- }
359
- return r;
360
- }
361
- function F(e, t, n) {
362
- let r = s(e.columnGroups, t);
363
- if (!r || e.columnGroupState[r.id]?.hidden === !0) return e;
364
- let i = r.children.map((t) => p(e, t)).filter((e) => !!e).filter((t) => e.columnState[t.id]?.hidden !== !0);
365
- if (i.length === 0) return e;
366
- let a = P(e, i, n), o = { ...e.columnState };
367
- return i.forEach((e, t) => {
368
- o[e.id] = {
369
- ...o[e.id],
370
- width: a[t]
371
- };
372
- }), {
373
- ...e,
374
- columnState: o
375
- };
376
- }
377
- function I(e, t) {
378
- let n = new Map(e.columnOrder.map((e, t) => [e, t])), r = new Map(t.map((e, t) => [e, t]));
379
- for (let t of e.columns) if (t.lockPosition && n.get(t.id) !== r.get(t.id)) return !0;
380
- for (let t of e.columnGroups) {
381
- if (!t.lockPosition) continue;
382
- 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);
383
- if (e.length !== i.length || e.some((e, t) => e !== i[t])) return !0;
384
- }
385
- return !1;
386
- }
387
- function L(e, t, n) {
388
- let r = p(e, t);
389
- if (!r || r.lockPosition) return e;
390
- let i = o(e.columnGroups).get(t), a = e.columnOrder.filter((e) => e !== t);
391
- if (a.length === e.columnOrder.length) return e;
392
- let c = Math.max(0, Math.min(n, a.length));
393
- if (i) {
394
- let t = s(e.columnGroups, i);
395
- if (!t) return e;
396
- let n = a.filter((e) => t.children.includes(e)), r = a.findIndex((e) => t.children.includes(e)), o = r + n.length;
397
- if (c < r || c > o) return e;
398
- } else if (e.columnGroups.length > 0) for (let t of e.columnGroups) {
399
- let n = a.filter((e) => t.children.includes(e));
400
- if (n.length === 0) continue;
401
- let r = a.findIndex((e) => t.children.includes(e)), i = r + n.length;
402
- if (c > r && c < i) return e;
403
- }
404
- return a.splice(c, 0, t), I(e, a) || a.every((t, n) => t === e.columnOrder[n]) ? e : {
405
- ...e,
406
- columnOrder: a
407
- };
408
- }
409
- function R(e, t, n) {
410
- let r = s(e.columnGroups, t);
411
- if (!r || r.lockPosition) return e;
412
- let i = e.columnOrder.filter((e) => r.children.includes(e));
413
- if (i.length === 0) return e;
414
- let a = e.columnOrder.filter((e) => !r.children.includes(e)), o = Math.max(0, Math.min(n, a.length)), c = [
415
- ...a.slice(0, o),
416
- ...i,
417
- ...a.slice(o)
418
- ];
419
- return I(e, c) || c.every((t, n) => t === e.columnOrder[n]) ? e : {
420
- ...e,
421
- columnOrder: c
422
- };
423
- }
424
- function z(e) {
425
- let t = e.columnGroups.length === 0 ? void 0 : Object.fromEntries(e.columnGroups.map((t) => [t.id, { ...e.columnGroupState[t.id] }]));
426
- return {
427
- columns: { ...e.columnState },
428
- ...t ? { groups: t } : {},
429
- order: [...e.columnOrder]
430
- };
431
- }
432
- function B(e, t) {
433
- return {
434
- ...e,
435
- columnOrder: c(e.columns, t, e.columnGroups),
436
- columnGroupState: a(e.columnGroups, t),
437
- columnState: i(e.columns, t)
438
- };
439
- }
440
- function V(e, t, n = {}) {
441
- 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];
442
- return {
443
- ...e,
444
- selection: {
445
- ...e.selection,
446
- rowIds: a
447
- }
448
- };
449
- }
450
- function H(e, t) {
451
- return {
452
- ...e,
453
- selection: {
454
- ...e.selection,
455
- rowIds: [...t]
456
- }
457
- };
458
- }
459
- function U(e, t) {
460
- return {
461
- ...e,
462
- selection: {
463
- ...e.selection,
464
- cell: t,
465
- range: null
466
- }
467
- };
468
- }
469
- function de(e, t) {
470
- return {
471
- ...e,
472
- selection: {
473
- ...e.selection,
474
- cell: t.focus,
475
- range: t
476
- }
477
- };
478
- }
479
- function fe(e) {
480
- return {
481
- ...e,
482
- selection: {
483
- ...e.selection,
484
- range: null
485
- }
486
- };
487
- }
488
- function pe(e) {
489
- return {
490
- ...e,
491
- selection: l()
492
- };
493
- }
494
- function me(e, t) {
495
- return e.selection.rowIds.includes(t);
496
- }
497
- function he(e, t) {
498
- return e.selection.cell?.rowId === t.rowId && e.selection.cell.columnId === t.columnId;
499
- }
500
- function W(e, t = e.selection.range) {
501
- if (!t) return [];
502
- let n = G(e), r = x(e, t);
503
- if (!r) return [];
504
- let i = [];
505
- for (let t = r.rowStart; t <= r.rowEnd; t += 1) {
506
- let a = e.rowIds[t];
507
- if (a !== void 0) for (let e = r.columnStart; e <= r.columnEnd; e += 1) {
508
- let t = n[e];
509
- t && i.push({
510
- columnId: t.id,
511
- rowId: a
512
- });
513
- }
514
- }
515
- return i;
516
- }
517
- function ge(e, t) {
518
- return W(e).some((e) => e.rowId === t.rowId && e.columnId === t.columnId);
519
- }
520
- function G(e) {
521
- let t = o(e.columnGroups);
522
- return e.columnOrder.map((t) => p(e, t)).filter((e) => !!e).filter((n) => {
523
- let r = t.get(n.id);
524
- return e.columnState[n.id]?.hidden !== !0 && (!r || e.columnGroupState[r]?.hidden !== !0);
525
- });
526
- }
527
- function _e(e) {
528
- let t = G(e);
529
- if (e.columnGroups.length === 0) return [t.map((e) => ({
530
- colSpan: 1,
531
- column: e,
532
- columnId: e.id,
533
- kind: "column",
534
- rowSpan: 1
535
- }))];
536
- 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 = [];
537
- for (let t of e.columnOrder) {
538
- if (!n.has(t)) continue;
539
- let o = p(e, t);
540
- if (!o) continue;
541
- let l = r.get(t);
542
- if (!l) {
543
- s.push({
544
- colSpan: 1,
545
- column: o,
546
- columnId: o.id,
547
- kind: "column",
548
- rowSpan: 2
549
- });
550
- continue;
551
- }
552
- if (a.has(l)) continue;
553
- let u = i.get(l);
554
- if (!u) continue;
555
- let d = e.columnOrder.filter((e) => u.children.includes(e) && n.has(e)).map((t) => p(e, t)).filter((e) => !!e);
556
- if (d.length === 0) {
557
- a.add(l);
558
- continue;
559
- }
560
- s.push({
561
- colSpan: d.length,
562
- group: u,
563
- groupId: l,
564
- kind: "group",
565
- rowSpan: 1
566
- }), c.push(...d.map((e) => ({
567
- colSpan: 1,
568
- column: e,
569
- columnId: e.id,
570
- groupId: l,
571
- kind: "column",
572
- rowSpan: 1
573
- }))), a.add(l);
574
- }
575
- return [s, c];
576
- }
577
- function K(e) {
578
- let t = e.rows.map((e, t) => t);
579
- return e.sortModel.length === 0 ? t : [...t].sort((t, n) => {
580
- let r = e.rows[t], i = e.rows[n];
581
- for (let t of e.sortModel) {
582
- let n = p(e, t.columnId);
583
- if (!n?.sort) continue;
584
- 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);
585
- if (s !== 0) return t.direction === "desc" ? s * -1 : s;
586
- }
587
- return t - n;
588
- });
589
- }
590
- function ve(e, t) {
591
- let n = O(e, t);
592
- return d(n, K(n).map((e) => n.rows[e]));
593
- }
594
- function ye(e, t = {}) {
595
- let n = t.pageIndex ?? e.pagination.pageIndex, r = t.pageSize ?? e.pagination.pageSize, i = Math.max(0, n) * Math.max(1, r);
596
- return K(e).slice(i, i + Math.max(1, r)).map((t) => e.rows[t]);
597
- }
598
- function be(e, { overscan: t = 2, rowHeight: n, scrollTop: r, viewportHeight: i }) {
599
- 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;
600
- return {
601
- bottomSpacerHeight: Math.max(0, c - d - (u - l) * a),
602
- endIndex: u,
603
- rows: o.slice(l, u).map((t) => e.rows[t]),
604
- startIndex: l,
605
- topSpacerHeight: d,
606
- totalHeight: c
607
- };
608
- }
609
- function xe(e, t, n) {
610
- let r = f(e, t);
611
- if (r < 0) return e;
612
- let i = [...e.rows], [a] = i.splice(r, 1);
613
- return a === void 0 ? e : (i.splice(Math.max(0, Math.min(n, i.length)), 0, a), d(e, i));
614
- }
615
- function q(e, t, n) {
616
- let r = p(e, n);
617
- return r ? g(t, r.field) : void 0;
618
- }
619
- function Se(e, t, n, r) {
620
- let i = q(e, t, r.id);
621
- return r.cell?.format ? r.cell.format(v(e, t, n, r)) : i == null ? "" : String(i);
622
- }
623
- function Ce(e, t, n, r) {
624
- let i = b(e, t, n, r);
625
- return i?.disabled !== void 0 && y(i.disabled, v(e, t, n, r)) === !0;
626
- }
627
- function we(e, t, n, r) {
628
- let i = v(e, t, n, r), a = b(e, t, n, r)?.className;
629
- return typeof a == "function" ? a(i) : a;
630
- }
631
- function Te(e, t, n, r) {
632
- let i = v(e, t, n, r), a = b(e, t, n, r)?.style;
633
- return typeof a == "function" ? a(i) : a;
634
- }
635
- function Ee(e, t) {
636
- let n = e.rows[f(e, t)];
637
- if (n === void 0) throw Error(`Cannot copy missing row: ${String(t)}`);
638
- return {
639
- kind: "row",
640
- row: n,
641
- text: JSON.stringify(n)
642
- };
643
- }
644
- function De(e, t, n) {
645
- if (n.mode === "append") {
646
- let r = n.getNewRowId?.(t.row);
647
- return E(e, [r === void 0 ? t.row : S(t.row, r)]);
648
- }
649
- if (n.mode === "insert-after") {
650
- let r = f(e, n.targetRowId);
651
- if (r < 0) return e;
652
- let i = e.getRowId(t.row, r), a = n.getPastedRowId?.(t.row) ?? ee(e.rowIds, i), o = S(t.row, a), s = [...e.rows];
653
- return s.splice(r + 1, 0, o), d(e, s);
654
- }
655
- return D(e, [{
656
- id: n.targetRowId,
657
- patch: S(t.row, n.targetRowId)
658
- }]);
659
- }
660
- function J(e, { columnId: t, rowId: n }) {
661
- let r = e.rows[f(e, n)], i = p(e, t);
662
- if (!i || !C(e, r, n, i, "copy")) return null;
663
- let a = q(e, r, t);
664
- return {
665
- kind: "cell",
666
- text: a == null ? "" : String(a),
667
- value: a
668
- };
669
- }
670
- function Y(e, { columnId: t, rowId: n }, r) {
671
- let i = p(e, t), a = e.rows[f(e, n)];
672
- return !r || !i || !C(e, a, n, i, "paste") ? e : D(e, [{
673
- id: n,
674
- patch: (e) => _(e, i.field, r.value)
675
- }]);
676
- }
677
- function Oe(e, t = e.selection.range) {
678
- if (!t) return null;
679
- let n = x(e, t);
680
- if (!n) return null;
681
- let r = [];
682
- for (let t = n.rowStart; t <= n.rowEnd; t += 1) {
683
- let i = e.rows[t], a = e.rowIds[t], o = [];
684
- for (let t = n.columnStart; t <= n.columnEnd; t += 1) {
685
- let r = n.visibleColumns[t];
686
- if (i === void 0 || a === void 0 || !r || !C(e, i, a, r, "copy")) {
687
- o.push(null);
688
- continue;
689
- }
690
- let s = q(e, i, r.id);
691
- o.push({
692
- columnId: r.id,
693
- text: s == null ? "" : String(s),
694
- value: s
695
- });
696
- }
697
- r.push(o);
698
- }
699
- return {
700
- kind: "cell-range",
701
- rows: r,
702
- text: r.map((e) => e.map((e) => e?.text ?? "").join(" ")).join("\n")
703
- };
704
- }
705
- function ke(e, t, n) {
706
- if (!n) return e;
707
- let r = G(e), i = f(e, t.rowId), a = r.findIndex((e) => e.id === t.columnId), o = [...e.rows];
708
- if (i < 0 || a < 0) return e;
709
- let s = !1;
710
- return n.rows.forEach((t, n) => {
711
- let c = i + n, l = o[c], u = e.rowIds[c];
712
- l === void 0 || u === void 0 || t.forEach((t, n) => {
713
- let i = r[a + n];
714
- !t || !i || !C(e, l, u, i, "paste") || (o[c] = _(o[c], i.field, t.value), s = !0);
715
- });
716
- }), s ? d(e, o) : e;
717
- }
718
- function Ae(e, { source: t, target: n }) {
719
- let r = J(e, t);
720
- return r ? W(e, n).reduce((e, t) => Y(e, t, r), e) : e;
721
- }
722
- function X({ columnOrder: e, columns: t }) {
723
- if (!e?.length) return t;
724
- let n = new Map(t.map((e) => [e.id, e]));
725
- return e.map((e) => n.get(e)).filter((e) => !!e);
726
- }
727
- function je(e) {
728
- return e == null ? "" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? String(e) : JSON.stringify(e);
729
- }
730
- function Z(e) {
731
- let t = je(e);
732
- return /[",\r\n]/u.test(t) ? `"${t.replaceAll("\"", "\"\"")}"` : t;
733
- }
734
- function Q(e, t) {
735
- return e.id && t?.[e.id] !== void 0 ? t[e.id] : e.label ?? e.id ?? "";
736
- }
737
- function $(e, t, n, r) {
738
- return r === "formatted" && e.format ? e.format(t, n) : e.value(t, n);
739
- }
740
- function Me({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
741
- let a = X({
742
- columnOrder: e,
743
- columns: t
744
- });
745
- return [a.map((e) => Z(Q(e, n))).join(","), ...r.map((e, t) => a.map((n) => Z($(n, e, t, i))).join(","))].join("\n");
746
- }
747
- function Ne({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
748
- let a = X({
749
- columnOrder: e,
750
- columns: t
751
- }), o = r.map((e, t) => Object.fromEntries(a.map((r) => [Q(r, n), $(r, e, t, i)])));
752
- return JSON.stringify(o, null, 2);
753
- }
754
- //#endregion
755
- export { E as addCominsRows, B as applyCominsColumnLayout, fe as clearCominsCellRange, pe as clearCominsSelection, A as clearCominsSortState, J as copyCominsCell, Oe as copyCominsCellRange, Ee as copyCominsRow, w as createCominsTableState, re as deleteCominsRows, Me as exportCominsRowsToCsv, Ne as exportCominsRowsToJson, Ae as fillCominsCellRange, Se as formatCominsCellValue, we as getCominsCellClassName, Te as getCominsCellStyle, q as getCominsCellValue, _e as getCominsHeaderRows, ye as getCominsPageRows, W as getCominsSelectedCellRange, K as getCominsSortedRowIndexes, be as getCominsVirtualRows, G as getCominsVisibleColumns, Ce as isCominsCellDisabled, ge as isCominsCellInSelectedRange, he as isCominsCellSelected, me as isCominsRowSelected, L as moveCominsColumn, R as moveCominsColumnGroup, xe as moveCominsRow, Y as pasteCominsCell, ke as pasteCominsCellRange, De 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 };
756
-
757
- //# 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 };