@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.
- package/README.md +40 -14
- package/all.js +25 -23
- package/all.js.map +1 -1
- package/index.js +410 -365
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +81 -12
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts +6 -6
- package/lib/core/internal/row-animation.d.ts.map +1 -1
- package/lib/core/internal/sorting.d.ts +6 -0
- package/lib/core/internal/sorting.d.ts.map +1 -1
- package/lib/core/types.d.ts +10 -6
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +54 -54
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +8 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +23 -12
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +93 -95
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +20 -20
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +4 -4
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- 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
|
|
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
|
|
380
|
+
function w(a, e, t = !0) {
|
|
381
381
|
let n = a;
|
|
382
|
-
if (t && (n = n.filter((
|
|
383
|
-
const
|
|
384
|
-
n = n.filter((
|
|
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
|
|
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
|
|
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
|
|
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
|
-
`,
|
|
407
|
+
`, s = a.replace(/\r\n/g, `
|
|
408
408
|
`).replace(/\r/g, `
|
|
409
|
-
`),
|
|
409
|
+
`), r = [];
|
|
410
410
|
let o = [], l = "", c = !1;
|
|
411
|
-
for (let i = 0; i <
|
|
412
|
-
const d =
|
|
413
|
-
d === '"' && !c ? c = !0 : d === '"' && c ?
|
|
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() !== "")) &&
|
|
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:
|
|
425
|
+
const { rows: t, target: n, fields: s } = a;
|
|
426
426
|
if (!n) return;
|
|
427
|
-
const
|
|
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 = [...
|
|
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 =
|
|
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
|
|
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.#
|
|
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
|
|
507
|
-
if (!
|
|
508
|
-
this.copy({ rowIndices: [n.row], columns: [
|
|
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
|
-
#
|
|
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),
|
|
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
|
|
535
|
-
|
|
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 =
|
|
576
|
+
n = w(this.columns, e.columns);
|
|
577
577
|
else if (t?.ranges.length && t.mode !== "row") {
|
|
578
|
-
const
|
|
579
|
-
n =
|
|
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 =
|
|
582
|
-
let
|
|
581
|
+
n = w(this.columns);
|
|
582
|
+
let s;
|
|
583
583
|
if (e?.rowIndices)
|
|
584
|
-
|
|
584
|
+
s = x(this.rows, e.rowIndices);
|
|
585
585
|
else if (t?.ranges.length) {
|
|
586
|
-
const
|
|
587
|
-
|
|
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 &&
|
|
590
|
+
i && s.push(i);
|
|
591
591
|
}
|
|
592
592
|
} else
|
|
593
|
-
|
|
594
|
-
return { columns: n, rows:
|
|
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
|
-
#
|
|
600
|
-
const
|
|
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(
|
|
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) :
|
|
606
|
+
return l ? l(g, u.field, i) : E(g);
|
|
607
607
|
});
|
|
608
|
-
c.push(d.join(
|
|
608
|
+
c.push(d.join(s));
|
|
609
609
|
}
|
|
610
|
-
return c.join(
|
|
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,
|
|
620
|
-
if (!n || !
|
|
621
|
-
const
|
|
622
|
-
if (isNaN(
|
|
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:
|
|
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.#
|
|
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
|
|
687
|
-
return await
|
|
688
|
-
text:
|
|
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
|
-
}),
|
|
691
|
+
}), s;
|
|
692
692
|
}
|
|
693
693
|
/**
|
|
694
694
|
* Copy specific rows by index to clipboard.
|