comins-table 0.1.5 → 0.1.7

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
@@ -44,25 +44,58 @@ function s(e, t) {
44
44
  return e.find((e) => e.id === t);
45
45
  }
46
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;
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);
61
75
  }
62
- let r = s.filter((e) => n.children.includes(e));
63
- d.push(...r), u.add(t);
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);
64
83
  }
65
- return d;
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
+ });
66
99
  }
67
100
  function l() {
68
101
  return {
@@ -138,7 +171,7 @@ function v(e, t, n, r) {
138
171
  selected: e.selection.rowIds.includes(n)
139
172
  },
140
173
  selection: { selectedRowCount: e.selection.rowIds.length },
141
- value: K(e, t, r.id)
174
+ value: q(e, t, r.id)
142
175
  };
143
176
  }
144
177
  function y(e, t) {
@@ -148,14 +181,15 @@ function b(e, t, n, r) {
148
181
  let i = v(e, t, n, r), a = r.cell?.props;
149
182
  return typeof a == "function" ? a(i) : a;
150
183
  }
151
- function x(e, t) {
152
- 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);
153
- return r < 0 || i < 0 || a < 0 || o < 0 ? null : {
154
- columnEnd: Math.max(a, o),
155
- columnStart: Math.min(a, o),
156
- rowEnd: Math.max(r, i),
157
- rowStart: Math.min(r, i),
158
- visibleColumns: n
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
159
193
  };
160
194
  }
161
195
  function S(e, t) {
@@ -164,20 +198,20 @@ function S(e, t) {
164
198
  id: t
165
199
  } : e;
166
200
  }
167
- function C(e, t) {
201
+ function ee(e, t) {
168
202
  let n = 1, r = `${String(t)}-copy-${n}`, i = new Set(e.map(String));
169
203
  for (; i.has(r);) n += 1, r = `${String(t)}-copy-${n}`;
170
204
  return r;
171
205
  }
172
- function w(e, t, n, r, i) {
206
+ function C(e, t, n, r, i) {
173
207
  if (t === void 0) return !1;
174
208
  let a = v(e, t, n, r), o = b(e, t, n, r);
175
209
  return o?.disabled !== void 0 && y(o.disabled, a) === !0 ? !1 : y(i === "copy" ? o?.copyable : o?.pasteable, a);
176
210
  }
177
- function T(e, t) {
211
+ function te(e, t) {
178
212
  return typeof e == "number" && typeof t == "number" ? e - t : String(e ?? "").localeCompare(String(t ?? ""));
179
213
  }
180
- function ee({ columnLayout: o, columnGroups: s, columns: u, getRowId: d = e, pagination: f, rows: p, showHeader: m = !0, sort: g = null, sortModel: _, theme: v = {} }) {
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 = {} }) {
181
215
  let y = t(p), b = n(u), x = r(b, s), S = h(b, _ ?? (g ? [g] : []));
182
216
  return {
183
217
  columnOrder: c(b, o, x),
@@ -199,7 +233,7 @@ function ee({ columnLayout: o, columnGroups: s, columns: u, getRowId: d = e, pag
199
233
  theme: v
200
234
  };
201
235
  }
202
- function te(e, t) {
236
+ function T(e, t) {
203
237
  return t ? e.rows.filter(t) : [...e.rows];
204
238
  }
205
239
  function ne(e, n) {
@@ -260,10 +294,10 @@ function k(e, t) {
260
294
  sortModel: n
261
295
  };
262
296
  }
263
- function se(e) {
297
+ function A(e) {
264
298
  return k(e, []);
265
299
  }
266
- function ce(e, t, n) {
300
+ function se(e, t, n) {
267
301
  return {
268
302
  ...e,
269
303
  columnState: {
@@ -275,7 +309,7 @@ function ce(e, t, n) {
275
309
  }
276
310
  };
277
311
  }
278
- function le(e, t, n) {
312
+ function ce(e, t, n) {
279
313
  return {
280
314
  ...e,
281
315
  columnState: {
@@ -287,7 +321,7 @@ function le(e, t, n) {
287
321
  }
288
322
  };
289
323
  }
290
- function ue(e, t, n) {
324
+ function le(e, t, n) {
291
325
  return s(e.columnGroups, t) ? {
292
326
  ...e,
293
327
  columnGroupState: {
@@ -299,38 +333,38 @@ function ue(e, t, n) {
299
333
  }
300
334
  } : e;
301
335
  }
302
- function de(e, t) {
336
+ function ue(e, t) {
303
337
  return e.columnState[t.id]?.width ?? t.width ?? 100;
304
338
  }
305
- function A(e) {
306
- return Math.max(50, e.minWidth ?? 50);
307
- }
308
339
  function j(e) {
340
+ return Math.max(88, e.minWidth ?? 88);
341
+ }
342
+ function M(e) {
309
343
  return e.maxWidth ?? Infinity;
310
344
  }
311
- function M(e, t, n) {
345
+ function N(e, t, n) {
312
346
  return Math.min(n, Math.max(t, e));
313
347
  }
314
- function N(e, t, n) {
315
- let r = t.map((t) => M(de(e, t), A(t), j(t))), i = new Set(t.map((e, t) => t)), a = t.map(A), o = t.map(j), s = M(n, a.reduce((e, t) => e + t, 0), o.reduce((e, t) => e + t, 0));
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));
316
350
  for (; i.size > 0;) {
317
351
  let e = s - r.reduce((e, t) => e + t, 0);
318
352
  if (Math.abs(e) < .001) break;
319
353
  let t = [...i], n = t.reduce((e, t) => e + Math.max(r[t] ?? 0, 0), 0), c = !1;
320
354
  for (let s of t) {
321
- let l = r[s] ?? 0, u = l + e * (n > 0 ? l / n : 1 / t.length), d = M(u, a[s] ?? 0, o[s] ?? Infinity);
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);
322
356
  r[s] = d, Math.abs(d - u) > .001 && (i.delete(s), c = !0);
323
357
  }
324
358
  if (!c) break;
325
359
  }
326
360
  return r;
327
361
  }
328
- function P(e, t, n) {
362
+ function F(e, t, n) {
329
363
  let r = s(e.columnGroups, t);
330
364
  if (!r || e.columnGroupState[r.id]?.hidden === !0) return e;
331
365
  let i = r.children.map((t) => p(e, t)).filter((e) => !!e).filter((t) => e.columnState[t.id]?.hidden !== !0);
332
366
  if (i.length === 0) return e;
333
- let a = N(e, i, n), o = { ...e.columnState };
367
+ let a = P(e, i, n), o = { ...e.columnState };
334
368
  return i.forEach((e, t) => {
335
369
  o[e.id] = {
336
370
  ...o[e.id],
@@ -341,29 +375,41 @@ function P(e, t, n) {
341
375
  columnState: o
342
376
  };
343
377
  }
344
- function F(e, t, n) {
345
- let r = o(e.columnGroups).get(t), i = e.columnOrder.filter((e) => e !== t);
346
- if (i.length === e.columnOrder.length) return e;
347
- let a = Math.max(0, Math.min(n, i.length));
348
- if (r) {
349
- let t = s(e.columnGroups, r);
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);
350
396
  if (!t) return e;
351
- let n = i.filter((e) => t.children.includes(e)), o = i.findIndex((e) => t.children.includes(e)), c = o + n.length;
352
- if (a < o || a > c) 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;
353
399
  } else if (e.columnGroups.length > 0) for (let t of e.columnGroups) {
354
- let n = i.filter((e) => t.children.includes(e));
400
+ let n = a.filter((e) => t.children.includes(e));
355
401
  if (n.length === 0) continue;
356
- let r = i.findIndex((e) => t.children.includes(e)), o = r + n.length;
357
- if (a > r && a < o) return e;
402
+ let r = a.findIndex((e) => t.children.includes(e)), i = r + n.length;
403
+ if (c > r && c < i) return e;
358
404
  }
359
- return i.splice(a, 0, t), {
405
+ return a.splice(c, 0, t), I(e, a) || a.every((t, n) => t === e.columnOrder[n]) ? e : {
360
406
  ...e,
361
- columnOrder: i
407
+ columnOrder: a
362
408
  };
363
409
  }
364
- function I(e, t, n) {
410
+ function R(e, t, n) {
365
411
  let r = s(e.columnGroups, t);
366
- if (!r) return e;
412
+ if (!r || r.lockPosition) return e;
367
413
  let i = e.columnOrder.filter((e) => r.children.includes(e));
368
414
  if (i.length === 0) return e;
369
415
  let a = e.columnOrder.filter((e) => !r.children.includes(e)), o = Math.max(0, Math.min(n, a.length)), c = [
@@ -371,12 +417,12 @@ function I(e, t, n) {
371
417
  ...i,
372
418
  ...a.slice(o)
373
419
  ];
374
- return {
420
+ return I(e, c) || c.every((t, n) => t === e.columnOrder[n]) ? e : {
375
421
  ...e,
376
422
  columnOrder: c
377
423
  };
378
424
  }
379
- function L(e) {
425
+ function z(e) {
380
426
  let t = e.columnGroups.length === 0 ? void 0 : Object.fromEntries(e.columnGroups.map((t) => [t.id, { ...e.columnGroupState[t.id] }]));
381
427
  return {
382
428
  columns: { ...e.columnState },
@@ -384,7 +430,7 @@ function L(e) {
384
430
  order: [...e.columnOrder]
385
431
  };
386
432
  }
387
- function R(e, t) {
433
+ function B(e, t) {
388
434
  return {
389
435
  ...e,
390
436
  columnOrder: c(e.columns, t, e.columnGroups),
@@ -392,7 +438,7 @@ function R(e, t) {
392
438
  columnState: i(e.columns, t)
393
439
  };
394
440
  }
395
- function z(e, t, n = {}) {
441
+ function V(e, t, n = {}) {
396
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];
397
443
  return {
398
444
  ...e,
@@ -402,7 +448,7 @@ function z(e, t, n = {}) {
402
448
  }
403
449
  };
404
450
  }
405
- function B(e, t) {
451
+ function H(e, t) {
406
452
  return {
407
453
  ...e,
408
454
  selection: {
@@ -411,7 +457,7 @@ function B(e, t) {
411
457
  }
412
458
  };
413
459
  }
414
- function V(e, t) {
460
+ function U(e, t) {
415
461
  return {
416
462
  ...e,
417
463
  selection: {
@@ -421,7 +467,7 @@ function V(e, t) {
421
467
  }
422
468
  };
423
469
  }
424
- function H(e, t) {
470
+ function de(e, t) {
425
471
  return {
426
472
  ...e,
427
473
  selection: {
@@ -452,27 +498,27 @@ function me(e, t) {
452
498
  function he(e, t) {
453
499
  return e.selection.cell?.rowId === t.rowId && e.selection.cell.columnId === t.columnId;
454
500
  }
455
- function U(e, t = e.selection.range) {
501
+ function W(e, t = e.selection.range, n = e.rowIds) {
456
502
  if (!t) return [];
457
- let n = W(e), r = x(e, t);
458
- if (!r) return [];
459
- let i = [];
460
- for (let t = r.rowStart; t <= r.rowEnd; t += 1) {
461
- let a = e.rowIds[t];
462
- if (a !== void 0) for (let e = r.columnStart; e <= r.columnEnd; e += 1) {
463
- let t = n[e];
464
- t && i.push({
465
- columnId: t.id,
466
- rowId: a
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
467
513
  });
468
514
  }
469
515
  }
470
- return i;
516
+ return a;
471
517
  }
472
- function ge(e, t) {
473
- return U(e).some((e) => e.rowId === t.rowId && e.columnId === t.columnId);
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);
474
520
  }
475
- function W(e) {
521
+ function G(e) {
476
522
  let t = o(e.columnGroups);
477
523
  return e.columnOrder.map((t) => p(e, t)).filter((e) => !!e).filter((n) => {
478
524
  let r = t.get(n.id);
@@ -480,7 +526,7 @@ function W(e) {
480
526
  });
481
527
  }
482
528
  function _e(e) {
483
- let t = W(e);
529
+ let t = G(e);
484
530
  if (e.columnGroups.length === 0) return [t.map((e) => ({
485
531
  colSpan: 1,
486
532
  column: e,
@@ -529,14 +575,14 @@ function _e(e) {
529
575
  }
530
576
  return [s, c];
531
577
  }
532
- function G(e) {
533
- let t = e.rows.map((e, t) => t);
534
- return e.sortModel.length === 0 ? t : [...t].sort((t, n) => {
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) => {
535
581
  let r = e.rows[t], i = e.rows[n];
536
582
  for (let t of e.sortModel) {
537
583
  let n = p(e, t.columnId);
538
584
  if (!n?.sort) continue;
539
- let a = K(e, r, n.id), o = K(e, i, n.id), s = typeof n.sort == "function" ? n.sort(a, o, r, i) : T(a, o);
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);
540
586
  if (s !== 0) return t.direction === "desc" ? s * -1 : s;
541
587
  }
542
588
  return t - n;
@@ -544,14 +590,14 @@ function G(e) {
544
590
  }
545
591
  function ve(e, t) {
546
592
  let n = O(e, t);
547
- return d(n, G(n).map((e) => n.rows[e]));
593
+ return d(n, K(n).map((e) => n.rows[e]));
548
594
  }
549
595
  function ye(e, t = {}) {
550
596
  let n = t.pageIndex ?? e.pagination.pageIndex, r = t.pageSize ?? e.pagination.pageSize, i = Math.max(0, n) * Math.max(1, r);
551
- return G(e).slice(i, i + Math.max(1, r)).map((t) => e.rows[t]);
597
+ return K(e).slice(i, i + Math.max(1, r)).map((t) => e.rows[t]);
552
598
  }
553
599
  function be(e, { overscan: t = 2, rowHeight: n, scrollTop: r, viewportHeight: i }) {
554
- 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;
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;
555
601
  return {
556
602
  bottomSpacerHeight: Math.max(0, c - d - (u - l) * a),
557
603
  endIndex: u,
@@ -567,27 +613,55 @@ function xe(e, t, n) {
567
613
  let i = [...e.rows], [a] = i.splice(r, 1);
568
614
  return a === void 0 ? e : (i.splice(Math.max(0, Math.min(n, i.length)), 0, a), d(e, i));
569
615
  }
570
- function K(e, t, n) {
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) {
571
645
  let r = p(e, n);
572
646
  return r ? g(t, r.field) : void 0;
573
647
  }
574
- function Se(e, t, n, r) {
575
- let i = K(e, t, r.id);
648
+ function Ce(e, t, n, r) {
649
+ let i = q(e, t, r.id);
576
650
  return r.cell?.format ? r.cell.format(v(e, t, n, r)) : i == null ? "" : String(i);
577
651
  }
578
- function Ce(e, t, n, r) {
652
+ function we(e, t, n, r) {
579
653
  let i = b(e, t, n, r);
580
654
  return i?.disabled !== void 0 && y(i.disabled, v(e, t, n, r)) === !0;
581
655
  }
582
- function we(e, t, n, r) {
656
+ function Te(e, t, n, r) {
583
657
  let i = v(e, t, n, r), a = b(e, t, n, r)?.className;
584
658
  return typeof a == "function" ? a(i) : a;
585
659
  }
586
- function Te(e, t, n, r) {
660
+ function Ee(e, t, n, r) {
587
661
  let i = v(e, t, n, r), a = b(e, t, n, r)?.style;
588
662
  return typeof a == "function" ? a(i) : a;
589
663
  }
590
- function Ee(e, t) {
664
+ function De(e, t) {
591
665
  let n = e.rows[f(e, t)];
592
666
  if (n === void 0) throw Error(`Cannot copy missing row: ${String(t)}`);
593
667
  return {
@@ -596,7 +670,7 @@ function Ee(e, t) {
596
670
  text: JSON.stringify(n)
597
671
  };
598
672
  }
599
- function q(e, t, n) {
673
+ function Oe(e, t, n) {
600
674
  if (n.mode === "append") {
601
675
  let r = n.getNewRowId?.(t.row);
602
676
  return E(e, [r === void 0 ? t.row : S(t.row, r)]);
@@ -604,7 +678,7 @@ function q(e, t, n) {
604
678
  if (n.mode === "insert-after") {
605
679
  let r = f(e, n.targetRowId);
606
680
  if (r < 0) return e;
607
- let i = e.getRowId(t.row, r), a = n.getPastedRowId?.(t.row) ?? C(e.rowIds, i), o = S(t.row, a), s = [...e.rows];
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];
608
682
  return s.splice(r + 1, 0, o), d(e, s);
609
683
  }
610
684
  return D(e, [{
@@ -614,8 +688,8 @@ function q(e, t, n) {
614
688
  }
615
689
  function J(e, { columnId: t, rowId: n }) {
616
690
  let r = e.rows[f(e, n)], i = p(e, t);
617
- if (!i || !w(e, r, n, i, "copy")) return null;
618
- let a = K(e, r, t);
691
+ if (!i || !C(e, r, n, i, "copy")) return null;
692
+ let a = q(e, r, t);
619
693
  return {
620
694
  kind: "cell",
621
695
  text: a == null ? "" : String(a),
@@ -624,66 +698,66 @@ function J(e, { columnId: t, rowId: n }) {
624
698
  }
625
699
  function Y(e, { columnId: t, rowId: n }, r) {
626
700
  let i = p(e, t), a = e.rows[f(e, n)];
627
- return !r || !i || !w(e, a, n, i, "paste") ? e : D(e, [{
701
+ return !r || !i || !C(e, a, n, i, "paste") ? e : D(e, [{
628
702
  id: n,
629
703
  patch: (e) => _(e, i.field, r.value)
630
704
  }]);
631
705
  }
632
- function De(e, t = e.selection.range) {
706
+ function ke(e, t = e.selection.range, n = e.rowIds) {
633
707
  if (!t) return null;
634
- let n = x(e, t);
635
- if (!n) return null;
636
- let r = [];
637
- for (let t = n.rowStart; t <= n.rowEnd; t += 1) {
638
- let i = e.rows[t], a = e.rowIds[t], o = [];
639
- for (let t = n.columnStart; t <= n.columnEnd; t += 1) {
640
- let r = n.visibleColumns[t];
641
- if (i === void 0 || a === void 0 || !r || !w(e, i, a, r, "copy")) {
642
- o.push(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);
643
717
  continue;
644
718
  }
645
- let s = K(e, i, r.id);
646
- o.push({
647
- columnId: r.id,
648
- text: s == null ? "" : String(s),
649
- value: s
719
+ let a = q(e, o, i.id);
720
+ s.push({
721
+ columnId: i.id,
722
+ text: a == null ? "" : String(a),
723
+ value: a
650
724
  });
651
725
  }
652
- r.push(o);
726
+ i.push(s);
653
727
  }
654
728
  return {
655
729
  kind: "cell-range",
656
- rows: r,
657
- text: r.map((e) => e.map((e) => e?.text ?? "").join(" ")).join("\n")
730
+ rows: i,
731
+ text: i.map((e) => e.map((e) => e?.text ?? "").join(" ")).join("\n")
658
732
  };
659
733
  }
660
- function Oe(e, t, n) {
734
+ function Ae(e, t, n, r = e.rowIds) {
661
735
  if (!n) return e;
662
- let r = W(e), i = f(e, t.rowId), a = r.findIndex((e) => e.id === t.columnId), o = [...e.rows];
663
- if (i < 0 || a < 0) return e;
664
- let s = !1;
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;
665
739
  return n.rows.forEach((t, n) => {
666
- let c = i + n, l = o[c], u = e.rowIds[c];
667
- l === void 0 || u === void 0 || t.forEach((t, n) => {
668
- let i = r[a + n];
669
- !t || !i || !w(e, l, u, i, "paste") || (o[c] = _(o[c], i.field, t.value), s = !0);
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);
670
744
  });
671
- }), s ? d(e, o) : e;
745
+ }), c ? d(e, s) : e;
672
746
  }
673
- function ke(e, { source: t, target: n }) {
747
+ function je(e, { source: t, target: n }) {
674
748
  let r = J(e, t);
675
- return r ? U(e, n).reduce((e, t) => Y(e, t, r), e) : e;
749
+ return r ? W(e, n).reduce((e, t) => Y(e, t, r), e) : e;
676
750
  }
677
751
  function X({ columnOrder: e, columns: t }) {
678
752
  if (!e?.length) return t;
679
753
  let n = new Map(t.map((e) => [e.id, e]));
680
754
  return e.map((e) => n.get(e)).filter((e) => !!e);
681
755
  }
682
- function Ae(e) {
756
+ function Me(e) {
683
757
  return e == null ? "" : typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? String(e) : JSON.stringify(e);
684
758
  }
685
759
  function Z(e) {
686
- let t = Ae(e);
760
+ let t = Me(e);
687
761
  return /[",\r\n]/u.test(t) ? `"${t.replaceAll("\"", "\"\"")}"` : t;
688
762
  }
689
763
  function Q(e, t) {
@@ -692,14 +766,14 @@ function Q(e, t) {
692
766
  function $(e, t, n, r) {
693
767
  return r === "formatted" && e.format ? e.format(t, n) : e.value(t, n);
694
768
  }
695
- function je({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
769
+ function Ne({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
696
770
  let a = X({
697
771
  columnOrder: e,
698
772
  columns: t
699
773
  });
700
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");
701
775
  }
702
- function Me({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
776
+ function Pe({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSource: i = "raw" }) {
703
777
  let a = X({
704
778
  columnOrder: e,
705
779
  columns: t
@@ -707,6 +781,6 @@ function Me({ columnOrder: e, columns: t, headerOverrides: n, rows: r, valueSour
707
781
  return JSON.stringify(o, null, 2);
708
782
  }
709
783
  //#endregion
710
- export { E as addCominsRows, R as applyCominsColumnLayout, fe as clearCominsCellRange, pe as clearCominsSelection, se as clearCominsSortState, J as copyCominsCell, De as copyCominsCellRange, Ee as copyCominsRow, ee as createCominsTableState, re as deleteCominsRows, je as exportCominsRowsToCsv, Me as exportCominsRowsToJson, ke as fillCominsCellRange, Se as formatCominsCellValue, we as getCominsCellClassName, Te as getCominsCellStyle, K as getCominsCellValue, _e as getCominsHeaderRows, ye as getCominsPageRows, U as getCominsSelectedCellRange, G as getCominsSortedRowIndexes, be as getCominsVirtualRows, W as getCominsVisibleColumns, Ce as isCominsCellDisabled, ge as isCominsCellInSelectedRange, he as isCominsCellSelected, me as isCominsRowSelected, F as moveCominsColumn, I as moveCominsColumnGroup, xe as moveCominsRow, Y as pasteCominsCell, Oe as pasteCominsCellRange, q as pasteCominsRow, te as queryCominsRows, ne as replaceCominsRows, V as selectCell, H as selectCellRange, z as selectRow, B as selectRows, L as serializeCominsColumnLayout, ue as setCominsColumnGroupHidden, P as setCominsColumnGroupWidth, le as setCominsColumnHidden, ce as setCominsColumnWidth, ae as setCominsHeaderVisible, oe as setCominsPagination, k as setCominsSortModel, O as setCominsSortState, ie as setCominsTableTheme, ve as sortCominsRows, D as updateCominsRows };
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 };
711
785
 
712
786
  //# sourceMappingURL=core.js.map