@toolbox-web/grid 1.16.0 → 1.16.1
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/all.js +12 -12
- package/all.js.map +1 -1
- package/index.js +11 -5
- package/index.js.map +1 -1
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/copy.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +55 -55
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +3 -3
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-delegation.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/core/internal/event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"event-delegation.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/core/internal/event-delegation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAoK7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAqD3G;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,WAAW,EACvB,MAAM,EAAE,WAAW,GAClB,IAAI,CAUN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipboardPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/clipboard/ClipboardPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAKxG,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,WAAW,EAGjB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;;IAClE;;;;;OAKG;IACH,gBAAgB;IAChB,gBAAyB,YAAY,EAAE,gBAAgB,EAAE,CAEvD;IAEF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,eAAe;IAE5B,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC,CAO/D;IAGD,qDAAqD;IACrD,OAAO,CAAC,UAAU,CAAoD;IAKtE,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"ClipboardPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/clipboard/ClipboardPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAKxG,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,WAAW,EAGjB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,q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AE,eAAe,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,MAAM,CAmB5G;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAuC7D;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAkBpE"}
|
|
@@ -379,9 +379,9 @@ class x {
|
|
|
379
379
|
}
|
|
380
380
|
function C(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((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));
|
|
385
385
|
}
|
|
386
386
|
return n;
|
|
387
387
|
}
|
|
@@ -394,24 +394,25 @@ function I(a) {
|
|
|
394
394
|
async function v(a) {
|
|
395
395
|
try {
|
|
396
396
|
return await navigator.clipboard.writeText(a), !0;
|
|
397
|
-
} catch {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
397
|
+
} catch (e) {
|
|
398
|
+
console.warn("[copyToClipboard] Clipboard API failed:", e);
|
|
399
|
+
const t = document.createElement("textarea");
|
|
400
|
+
t.value = a, t.style.position = "fixed", t.style.opacity = "0", t.style.pointerEvents = "none", document.body.appendChild(t), t.select();
|
|
401
|
+
const n = document.execCommand("copy");
|
|
402
|
+
return document.body.removeChild(t), n;
|
|
402
403
|
}
|
|
403
404
|
}
|
|
404
405
|
function y(a, e) {
|
|
405
406
|
const t = e.delimiter ?? " ", n = e.newline ?? `
|
|
406
|
-
`,
|
|
407
|
+
`, r = a.replace(/\r\n/g, `
|
|
407
408
|
`).replace(/\r/g, `
|
|
408
|
-
`),
|
|
409
|
+
`), s = [];
|
|
409
410
|
let o = [], l = "", c = !1;
|
|
410
|
-
for (let i = 0; i <
|
|
411
|
-
const d =
|
|
412
|
-
d === '"' && !c ? c = !0 : d === '"' && c ?
|
|
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;
|
|
413
414
|
}
|
|
414
|
-
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() !== "")) && s.push(o), s;
|
|
415
416
|
}
|
|
416
417
|
async function S() {
|
|
417
418
|
try {
|
|
@@ -421,13 +422,13 @@ async function S() {
|
|
|
421
422
|
}
|
|
422
423
|
}
|
|
423
424
|
function _(a, e) {
|
|
424
|
-
const { rows: t, target: n, fields:
|
|
425
|
+
const { rows: t, target: n, fields: r } = a;
|
|
425
426
|
if (!n) return;
|
|
426
|
-
const
|
|
427
|
+
const s = e.rows, o = e.effectiveConfig.columns ?? [], l = o.map((u) => u.field), c = /* @__PURE__ */ new Map();
|
|
427
428
|
o.forEach((u) => {
|
|
428
429
|
c.set(u.field, u.editable === !0);
|
|
429
430
|
});
|
|
430
|
-
const i = [...
|
|
431
|
+
const i = [...s], d = n.bounds ? n.bounds.endRow : 1 / 0;
|
|
431
432
|
t.forEach((u, g) => {
|
|
432
433
|
const f = n.row + g;
|
|
433
434
|
if (!(f > d)) {
|
|
@@ -439,13 +440,13 @@ function _(a, e) {
|
|
|
439
440
|
l.forEach((p) => m[p] = ""), i.push(m);
|
|
440
441
|
}
|
|
441
442
|
i[f] = { ...i[f] }, u.forEach((m, p) => {
|
|
442
|
-
const h =
|
|
443
|
+
const h = r[p];
|
|
443
444
|
h && c.get(h) && (i[f][h] = m);
|
|
444
445
|
});
|
|
445
446
|
}
|
|
446
447
|
}), e.rows = i;
|
|
447
448
|
}
|
|
448
|
-
class
|
|
449
|
+
class D extends x {
|
|
449
450
|
/**
|
|
450
451
|
* Plugin dependencies - ClipboardPlugin works best with SelectionPlugin.
|
|
451
452
|
*
|
|
@@ -475,11 +476,9 @@ class M extends x {
|
|
|
475
476
|
// #region Lifecycle
|
|
476
477
|
/** @internal */
|
|
477
478
|
attach(e) {
|
|
478
|
-
super.attach(e), e.addEventListener(
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
{ signal: this.disconnectSignal }
|
|
482
|
-
);
|
|
479
|
+
super.attach(e), e.addEventListener("paste", (n) => this.#s(n), {
|
|
480
|
+
signal: this.disconnectSignal
|
|
481
|
+
});
|
|
483
482
|
}
|
|
484
483
|
/** @internal */
|
|
485
484
|
detach() {
|
|
@@ -489,7 +488,7 @@ class M extends x {
|
|
|
489
488
|
// #region Event Handlers
|
|
490
489
|
/** @internal */
|
|
491
490
|
onKeyDown(e) {
|
|
492
|
-
return (e.ctrlKey || e.metaKey) && e.key === "c" ? (this.#e(e.target), !0) : !1;
|
|
491
|
+
return (e.ctrlKey || e.metaKey) && e.key === "c" ? (e.preventDefault(), this.#e(e.target), !0) : !1;
|
|
493
492
|
}
|
|
494
493
|
// #endregion
|
|
495
494
|
// #region Private Methods
|
|
@@ -504,9 +503,9 @@ class M extends x {
|
|
|
504
503
|
if (t && t.ranges.length === 0) {
|
|
505
504
|
const n = this.#o(e);
|
|
506
505
|
if (!n) return;
|
|
507
|
-
const
|
|
508
|
-
if (!
|
|
509
|
-
this.copy({ rowIndices: [n.row], columns: [
|
|
506
|
+
const r = this.columns[n.col];
|
|
507
|
+
if (!r) return;
|
|
508
|
+
this.copy({ rowIndices: [n.row], columns: [r.field] });
|
|
510
509
|
return;
|
|
511
510
|
}
|
|
512
511
|
this.copy();
|
|
@@ -526,11 +525,11 @@ class M extends x {
|
|
|
526
525
|
* - Range/row: paste is clipped to fit within selection bounds
|
|
527
526
|
* - No selection: paste starts at row 0, col 0
|
|
528
527
|
*/
|
|
529
|
-
#
|
|
528
|
+
#s(e) {
|
|
530
529
|
const t = e.clipboardData?.getData("text/plain");
|
|
531
530
|
if (!t) return;
|
|
532
531
|
e.preventDefault();
|
|
533
|
-
const n = y(t, this.config),
|
|
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;
|
|
534
533
|
for (let h = 0; h < m && l + h <= d; h++) {
|
|
535
534
|
const w = this.columns[l + h];
|
|
536
535
|
w && !w.hidden && f.push(w.field);
|
|
@@ -576,39 +575,39 @@ class M extends x {
|
|
|
576
575
|
if (e?.columns)
|
|
577
576
|
n = C(this.columns, e.columns);
|
|
578
577
|
else if (t?.ranges.length && t.mode !== "row") {
|
|
579
|
-
const
|
|
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);
|
|
580
579
|
n = C(this.columns.slice(o, l + 1));
|
|
581
580
|
} else
|
|
582
581
|
n = C(this.columns);
|
|
583
|
-
let
|
|
582
|
+
let r;
|
|
584
583
|
if (e?.rowIndices)
|
|
585
|
-
|
|
584
|
+
r = E(this.rows, e.rowIndices);
|
|
586
585
|
else if (t?.ranges.length) {
|
|
587
|
-
const
|
|
588
|
-
|
|
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 = [];
|
|
589
588
|
for (let c = o; c <= l; c++) {
|
|
590
589
|
const i = this.rows[c];
|
|
591
|
-
i &&
|
|
590
|
+
i && r.push(i);
|
|
592
591
|
}
|
|
593
592
|
} else
|
|
594
|
-
|
|
595
|
-
return { columns: n, rows:
|
|
593
|
+
r = this.rows;
|
|
594
|
+
return { columns: n, rows: r };
|
|
596
595
|
}
|
|
597
596
|
/**
|
|
598
597
|
* Build delimited text from resolved columns and rows.
|
|
599
598
|
*/
|
|
600
|
-
#
|
|
601
|
-
const
|
|
599
|
+
#r(e, t, n) {
|
|
600
|
+
const r = n?.delimiter ?? this.config.delimiter ?? " ", s = n?.newline ?? this.config.newline ?? `
|
|
602
601
|
`, o = n?.includeHeaders ?? this.config.includeHeaders ?? !1, l = n?.processCell ?? this.config.processCell, c = [];
|
|
603
|
-
o && c.push(e.map((i) => i.header || i.field).join(
|
|
602
|
+
o && c.push(e.map((i) => i.header || i.field).join(r));
|
|
604
603
|
for (const i of t) {
|
|
605
604
|
const d = e.map((u) => {
|
|
606
605
|
const g = i[u.field];
|
|
607
606
|
return l ? l(g, u.field, i) : I(g);
|
|
608
607
|
});
|
|
609
|
-
c.push(d.join(
|
|
608
|
+
c.push(d.join(r));
|
|
610
609
|
}
|
|
611
|
-
return c.join(
|
|
610
|
+
return c.join(s);
|
|
612
611
|
}
|
|
613
612
|
/**
|
|
614
613
|
* Get focused cell coordinates from DOM.
|
|
@@ -617,12 +616,12 @@ class M extends x {
|
|
|
617
616
|
#o(e) {
|
|
618
617
|
const t = e.closest("[data-field-cache]");
|
|
619
618
|
if (!t) return null;
|
|
620
|
-
const n = t.dataset.fieldCache,
|
|
621
|
-
if (!n || !
|
|
622
|
-
const
|
|
623
|
-
if (isNaN(
|
|
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;
|
|
624
623
|
const o = this.columns.findIndex((l) => l.field === n);
|
|
625
|
-
return o === -1 ? null : { row:
|
|
624
|
+
return o === -1 ? null : { row: s, col: o };
|
|
626
625
|
}
|
|
627
626
|
// #endregion
|
|
628
627
|
// #region Public API
|
|
@@ -649,7 +648,7 @@ class M extends x {
|
|
|
649
648
|
*/
|
|
650
649
|
getSelectionAsText(e) {
|
|
651
650
|
const { columns: t, rows: n } = this.#n(e);
|
|
652
|
-
return t.length === 0 || n.length === 0 ? "" : this.#
|
|
651
|
+
return t.length === 0 || n.length === 0 ? "" : this.#r(t, n, e);
|
|
653
652
|
}
|
|
654
653
|
/**
|
|
655
654
|
* Copy data to the system clipboard.
|
|
@@ -682,13 +681,14 @@ class M extends x {
|
|
|
682
681
|
*/
|
|
683
682
|
async copy(e) {
|
|
684
683
|
const { columns: t, rows: n } = this.#n(e);
|
|
685
|
-
if (t.length === 0 || n.length === 0)
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
684
|
+
if (t.length === 0 || n.length === 0)
|
|
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,
|
|
689
689
|
rowCount: n.length,
|
|
690
690
|
columnCount: t.length
|
|
691
|
-
}),
|
|
691
|
+
}), r;
|
|
692
692
|
}
|
|
693
693
|
/**
|
|
694
694
|
* Copy specific rows by index to clipboard.
|
|
@@ -728,7 +728,7 @@ class M extends x {
|
|
|
728
728
|
// #endregion
|
|
729
729
|
}
|
|
730
730
|
export {
|
|
731
|
-
|
|
731
|
+
D as ClipboardPlugin,
|
|
732
732
|
_ as defaultPasteHandler
|
|
733
733
|
};
|
|
734
734
|
//# sourceMappingURL=index.js.map
|