@toolbox-web/grid 1.19.3 → 1.21.0

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.
Files changed (58) hide show
  1. package/README.md +40 -14
  2. package/all.js +25 -23
  3. package/all.js.map +1 -1
  4. package/index.js +410 -365
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +81 -12
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/event-delegation.d.ts.map +1 -1
  9. package/lib/core/internal/row-animation.d.ts +6 -6
  10. package/lib/core/internal/row-animation.d.ts.map +1 -1
  11. package/lib/core/internal/sorting.d.ts +6 -0
  12. package/lib/core/internal/sorting.d.ts.map +1 -1
  13. package/lib/core/types.d.ts +10 -6
  14. package/lib/core/types.d.ts.map +1 -1
  15. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  16. package/lib/plugins/clipboard/index.js +54 -54
  17. package/lib/plugins/clipboard/index.js.map +1 -1
  18. package/lib/plugins/column-virtualization/index.js.map +1 -1
  19. package/lib/plugins/context-menu/index.js.map +1 -1
  20. package/lib/plugins/editing/index.js.map +1 -1
  21. package/lib/plugins/export/index.js.map +1 -1
  22. package/lib/plugins/filtering/index.js.map +1 -1
  23. package/lib/plugins/grouping-columns/index.js.map +1 -1
  24. package/lib/plugins/grouping-rows/index.js.map +1 -1
  25. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  26. package/lib/plugins/master-detail/index.js +1 -1
  27. package/lib/plugins/master-detail/index.js.map +1 -1
  28. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +8 -0
  29. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  30. package/lib/plugins/multi-sort/index.js +23 -12
  31. package/lib/plugins/multi-sort/index.js.map +1 -1
  32. package/lib/plugins/pinned-columns/index.js.map +1 -1
  33. package/lib/plugins/pinned-rows/index.js.map +1 -1
  34. package/lib/plugins/pivot/index.js.map +1 -1
  35. package/lib/plugins/print/index.js.map +1 -1
  36. package/lib/plugins/reorder/index.js.map +1 -1
  37. package/lib/plugins/responsive/index.js.map +1 -1
  38. package/lib/plugins/row-reorder/index.js.map +1 -1
  39. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  40. package/lib/plugins/selection/index.js +93 -95
  41. package/lib/plugins/selection/index.js.map +1 -1
  42. package/lib/plugins/server-side/index.js.map +1 -1
  43. package/lib/plugins/tree/index.js.map +1 -1
  44. package/lib/plugins/undo-redo/index.js.map +1 -1
  45. package/lib/plugins/visibility/index.js.map +1 -1
  46. package/package.json +1 -1
  47. package/umd/grid.all.umd.js +20 -20
  48. package/umd/grid.all.umd.js.map +1 -1
  49. package/umd/grid.umd.js +15 -15
  50. package/umd/grid.umd.js.map +1 -1
  51. package/umd/plugins/clipboard.umd.js +4 -4
  52. package/umd/plugins/clipboard.umd.js.map +1 -1
  53. package/umd/plugins/master-detail.umd.js +1 -1
  54. package/umd/plugins/master-detail.umd.js.map +1 -1
  55. package/umd/plugins/multi-sort.umd.js +1 -1
  56. package/umd/plugins/multi-sort.umd.js.map +1 -1
  57. package/umd/plugins/selection.umd.js +1 -1
  58. package/umd/plugins/selection.umd.js.map +1 -1
@@ -11,7 +11,7 @@ const b = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
11
11
  filterActive: b,
12
12
  print: "🖨️"
13
13
  };
14
- class x {
14
+ class v {
15
15
  /**
16
16
  * Plugin dependencies - declare other plugins this one requires.
17
17
  *
@@ -377,21 +377,21 @@ class x {
377
377
  }
378
378
  // #endregion
379
379
  }
380
- function C(a, e, t = !0) {
380
+ function w(a, e, t = !0) {
381
381
  let n = a;
382
- if (t && (n = n.filter((r) => !r.hidden && !r.field.startsWith("__") && r.meta?.utility !== !0)), e?.length) {
383
- const r = new Set(e);
384
- n = n.filter((s) => r.has(s.field));
382
+ if (t && (n = n.filter((s) => !s.hidden && !s.field.startsWith("__") && s.meta?.utility !== !0)), e?.length) {
383
+ const s = new Set(e);
384
+ n = n.filter((r) => s.has(r.field));
385
385
  }
386
386
  return n;
387
387
  }
388
- function E(a, e) {
388
+ function x(a, e) {
389
389
  return e?.length ? [...e].sort((t, n) => t - n).map((t) => a[t]).filter((t) => t != null) : a;
390
390
  }
391
- function I(a) {
391
+ function E(a) {
392
392
  return a == null ? "" : a instanceof Date ? a.toISOString() : typeof a == "object" ? JSON.stringify(a) : String(a);
393
393
  }
394
- async function v(a) {
394
+ async function I(a) {
395
395
  try {
396
396
  return await navigator.clipboard.writeText(a), !0;
397
397
  } catch (e) {
@@ -404,15 +404,15 @@ async function v(a) {
404
404
  }
405
405
  function y(a, e) {
406
406
  const t = e.delimiter ?? " ", n = e.newline ?? `
407
- `, r = a.replace(/\r\n/g, `
407
+ `, s = a.replace(/\r\n/g, `
408
408
  `).replace(/\r/g, `
409
- `), s = [];
409
+ `), r = [];
410
410
  let o = [], l = "", c = !1;
411
- for (let i = 0; i < r.length; i++) {
412
- const d = r[i];
413
- d === '"' && !c ? c = !0 : d === '"' && c ? r[i + 1] === '"' ? (l += '"', i++) : c = !1 : d === t && !c ? (o.push(l), l = "") : d === n && !c ? (o.push(l), l = "", (o.length > 1 || o.some((u) => u.trim() !== "")) && s.push(o), o = []) : l += d;
411
+ for (let i = 0; i < s.length; i++) {
412
+ const d = s[i];
413
+ d === '"' && !c ? c = !0 : d === '"' && c ? s[i + 1] === '"' ? (l += '"', i++) : c = !1 : d === t && !c ? (o.push(l), l = "") : d === n && !c ? (o.push(l), l = "", (o.length > 1 || o.some((u) => u.trim() !== "")) && r.push(o), o = []) : l += d;
414
414
  }
415
- return o.push(l), (o.length > 1 || o.some((i) => i.trim() !== "")) && s.push(o), s;
415
+ return o.push(l), (o.length > 1 || o.some((i) => i.trim() !== "")) && r.push(o), r;
416
416
  }
417
417
  async function S() {
418
418
  try {
@@ -422,13 +422,13 @@ async function S() {
422
422
  }
423
423
  }
424
424
  function _(a, e) {
425
- const { rows: t, target: n, fields: r } = a;
425
+ const { rows: t, target: n, fields: s } = a;
426
426
  if (!n) return;
427
- const s = e.rows, o = e.effectiveConfig.columns ?? [], l = o.map((u) => u.field), c = /* @__PURE__ */ new Map();
427
+ const r = e.rows, o = e.effectiveConfig.columns ?? [], l = o.map((u) => u.field), c = /* @__PURE__ */ new Map();
428
428
  o.forEach((u) => {
429
429
  c.set(u.field, u.editable === !0);
430
430
  });
431
- const i = [...s], d = n.bounds ? n.bounds.endRow : 1 / 0;
431
+ const i = [...r], d = n.bounds ? n.bounds.endRow : 1 / 0;
432
432
  t.forEach((u, g) => {
433
433
  const f = n.row + g;
434
434
  if (!(f > d)) {
@@ -440,13 +440,13 @@ function _(a, e) {
440
440
  l.forEach((p) => m[p] = ""), i.push(m);
441
441
  }
442
442
  i[f] = { ...i[f] }, u.forEach((m, p) => {
443
- const h = r[p];
443
+ const h = s[p];
444
444
  h && c.get(h) && (i[f][h] = m);
445
445
  });
446
446
  }
447
447
  }), e.rows = i;
448
448
  }
449
- class D extends x {
449
+ class D extends v {
450
450
  /**
451
451
  * Plugin dependencies - ClipboardPlugin works best with SelectionPlugin.
452
452
  *
@@ -476,7 +476,7 @@ class D extends x {
476
476
  // #region Lifecycle
477
477
  /** @internal */
478
478
  attach(e) {
479
- super.attach(e), e.addEventListener("paste", (n) => this.#s(n), {
479
+ super.attach(e), e.addEventListener("paste", (n) => this.#r(n), {
480
480
  signal: this.disconnectSignal
481
481
  });
482
482
  }
@@ -503,9 +503,9 @@ class D extends x {
503
503
  if (t && t.ranges.length === 0) {
504
504
  const n = this.#o(e);
505
505
  if (!n) return;
506
- const r = this.columns[n.col];
507
- if (!r) return;
508
- this.copy({ rowIndices: [n.row], columns: [r.field] });
506
+ const s = this.columns[n.col];
507
+ if (!s) return;
508
+ this.copy({ rowIndices: [n.row], columns: [s.field] });
509
509
  return;
510
510
  }
511
511
  this.copy();
@@ -525,14 +525,14 @@ class D extends x {
525
525
  * - Range/row: paste is clipped to fit within selection bounds
526
526
  * - No selection: paste starts at row 0, col 0
527
527
  */
528
- #s(e) {
528
+ #r(e) {
529
529
  const t = e.clipboardData?.getData("text/plain");
530
530
  if (!t) return;
531
531
  e.preventDefault();
532
- const n = y(t, this.config), r = this.#t(), s = r?.ranges?.[0], o = s?.from.row ?? 0, l = s?.from.col ?? 0, i = s && (r?.mode === "range" || r?.mode === "row") && (s.from.row !== s.to.row || s.from.col !== s.to.col) ? { endRow: s.to.row, endCol: s.to.col } : null, d = i?.endCol ?? this.columns.length - 1, u = this.columns[l], g = u ? { row: o, col: l, field: u.field, bounds: i } : null, f = [], m = n[0]?.length ?? 0;
532
+ const n = y(t, this.config), s = this.#t(), r = s?.ranges?.[0], o = r?.from.row ?? 0, l = r?.from.col ?? 0, i = r && (s?.mode === "range" || s?.mode === "row") && (r.from.row !== r.to.row || r.from.col !== r.to.col) ? { endRow: r.to.row, endCol: r.to.col } : null, d = i?.endCol ?? this.visibleColumns.length - 1, u = this.visibleColumns[l], g = u ? { row: o, col: l, field: u.field, bounds: i } : null, f = [], m = n[0]?.length ?? 0;
533
533
  for (let h = 0; h < m && l + h <= d; h++) {
534
- const w = this.columns[l + h];
535
- w && !w.hidden && f.push(w.field);
534
+ const C = this.visibleColumns[l + h];
535
+ C && f.push(C.field);
536
536
  }
537
537
  const p = { rows: n, text: t, target: g, fields: f };
538
538
  this.emit("paste", p), this.#i(p);
@@ -573,41 +573,41 @@ class D extends x {
573
573
  const t = this.#t();
574
574
  let n;
575
575
  if (e?.columns)
576
- n = C(this.columns, e.columns);
576
+ n = w(this.columns, e.columns);
577
577
  else if (t?.ranges.length && t.mode !== "row") {
578
- const s = t.ranges[t.ranges.length - 1], o = Math.min(s.from.col, s.to.col), l = Math.max(s.from.col, s.to.col);
579
- n = C(this.columns.slice(o, l + 1));
578
+ const r = t.ranges[t.ranges.length - 1], o = Math.min(r.from.col, r.to.col), l = Math.max(r.from.col, r.to.col);
579
+ n = w(this.visibleColumns.slice(o, l + 1));
580
580
  } else
581
- n = C(this.columns);
582
- let r;
581
+ n = w(this.columns);
582
+ let s;
583
583
  if (e?.rowIndices)
584
- r = E(this.rows, e.rowIndices);
584
+ s = x(this.rows, e.rowIndices);
585
585
  else if (t?.ranges.length) {
586
- const s = t.ranges[t.ranges.length - 1], o = Math.min(s.from.row, s.to.row), l = Math.max(s.from.row, s.to.row);
587
- r = [];
586
+ const r = t.ranges[t.ranges.length - 1], o = Math.min(r.from.row, r.to.row), l = Math.max(r.from.row, r.to.row);
587
+ s = [];
588
588
  for (let c = o; c <= l; c++) {
589
589
  const i = this.rows[c];
590
- i && r.push(i);
590
+ i && s.push(i);
591
591
  }
592
592
  } else
593
- r = this.rows;
594
- return { columns: n, rows: r };
593
+ s = this.rows;
594
+ return { columns: n, rows: s };
595
595
  }
596
596
  /**
597
597
  * Build delimited text from resolved columns and rows.
598
598
  */
599
- #r(e, t, n) {
600
- const r = n?.delimiter ?? this.config.delimiter ?? " ", s = n?.newline ?? this.config.newline ?? `
599
+ #s(e, t, n) {
600
+ const s = n?.delimiter ?? this.config.delimiter ?? " ", r = n?.newline ?? this.config.newline ?? `
601
601
  `, o = n?.includeHeaders ?? this.config.includeHeaders ?? !1, l = n?.processCell ?? this.config.processCell, c = [];
602
- o && c.push(e.map((i) => i.header || i.field).join(r));
602
+ o && c.push(e.map((i) => i.header || i.field).join(s));
603
603
  for (const i of t) {
604
604
  const d = e.map((u) => {
605
605
  const g = i[u.field];
606
- return l ? l(g, u.field, i) : I(g);
606
+ return l ? l(g, u.field, i) : E(g);
607
607
  });
608
- c.push(d.join(r));
608
+ c.push(d.join(s));
609
609
  }
610
- return c.join(s);
610
+ return c.join(r);
611
611
  }
612
612
  /**
613
613
  * Get focused cell coordinates from DOM.
@@ -616,12 +616,12 @@ class D extends x {
616
616
  #o(e) {
617
617
  const t = e.closest("[data-field-cache]");
618
618
  if (!t) return null;
619
- const n = t.dataset.fieldCache, r = t.dataset.row;
620
- if (!n || !r) return null;
621
- const s = parseInt(r, 10);
622
- if (isNaN(s)) return null;
619
+ const n = t.dataset.fieldCache, s = t.dataset.row;
620
+ if (!n || !s) return null;
621
+ const r = parseInt(s, 10);
622
+ if (isNaN(r)) return null;
623
623
  const o = this.columns.findIndex((l) => l.field === n);
624
- return o === -1 ? null : { row: s, col: o };
624
+ return o === -1 ? null : { row: r, col: o };
625
625
  }
626
626
  // #endregion
627
627
  // #region Public API
@@ -648,7 +648,7 @@ class D extends x {
648
648
  */
649
649
  getSelectionAsText(e) {
650
650
  const { columns: t, rows: n } = this.#n(e);
651
- return t.length === 0 || n.length === 0 ? "" : this.#r(t, n, e);
651
+ return t.length === 0 || n.length === 0 ? "" : this.#s(t, n, e);
652
652
  }
653
653
  /**
654
654
  * Copy data to the system clipboard.
@@ -683,12 +683,12 @@ class D extends x {
683
683
  const { columns: t, rows: n } = this.#n(e);
684
684
  if (t.length === 0 || n.length === 0)
685
685
  return "";
686
- const r = this.#r(t, n, e);
687
- return await v(r), this.lastCopied = { text: r, timestamp: Date.now() }, this.emit("copy", {
688
- text: r,
686
+ const s = this.#s(t, n, e);
687
+ return await I(s), this.lastCopied = { text: s, timestamp: Date.now() }, this.emit("copy", {
688
+ text: s,
689
689
  rowCount: n.length,
690
690
  columnCount: t.length
691
- }), r;
691
+ }), s;
692
692
  }
693
693
  /**
694
694
  * Copy specific rows by index to clipboard.