@toolbox-web/grid 1.17.0 → 1.18.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 +126 -41
- package/all.js +1045 -935
- package/all.js.map +1 -1
- package/index.js +39 -33
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +12 -2
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/types.d.ts +34 -1
- package/lib/core/types.d.ts.map +1 -1
- 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/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +155 -145
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +31 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/filter-model.d.ts +30 -3
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
- package/lib/plugins/filtering/index.d.ts +1 -0
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +471 -361
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +32 -0
- package/lib/plugins/filtering/types.d.ts.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/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +4 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +49 -39
- 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 +81 -78
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +58 -55
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +5 -2
- package/lib/plugins/row-reorder/index.js.map +1 -1
- 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 +29 -29
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +2 -2
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function P(o) {
|
|
2
2
|
o && o.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
3
3
|
}
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
4
|
+
const y = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', D = document.createElement("template");
|
|
5
|
+
D.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
|
|
6
|
+
const H = document.createElement("template");
|
|
7
|
+
H.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
8
8
|
function L(o, e) {
|
|
9
9
|
if (o._virtualization?.enabled) {
|
|
10
10
|
const { rowHeight: n, container: l, viewportEl: c } = o._virtualization, a = l, d = c?.clientHeight ?? a?.clientHeight ?? 0;
|
|
@@ -14,7 +14,7 @@ function L(o, e) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
const t = o._activeEditRows !== void 0 && o._activeEditRows !== -1;
|
|
17
|
-
t || o.refreshVirtualWindow(!1),
|
|
17
|
+
t || o.refreshVirtualWindow(!1), P(o._bodyEl), Array.from(o._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((n) => {
|
|
18
18
|
n.setAttribute("aria-selected", "false");
|
|
19
19
|
});
|
|
20
20
|
const i = o._focusRow, r = o._virtualization.start ?? 0, s = o._virtualization.end ?? o._rows.length;
|
|
@@ -36,24 +36,27 @@ function L(o, e) {
|
|
|
36
36
|
f < p ? c.scrollLeft = f - a.left : E > m && (c.scrollLeft = E - c.clientWidth + a.right);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
40
|
-
const a = l.querySelector(
|
|
39
|
+
if (t && l.classList.contains("editing")) {
|
|
40
|
+
const a = l.querySelector(y);
|
|
41
41
|
if (a && document.activeElement !== a)
|
|
42
42
|
try {
|
|
43
43
|
a.focus({ preventScroll: !0 });
|
|
44
44
|
} catch {
|
|
45
45
|
}
|
|
46
|
-
} else if (!l.contains(document.activeElement)) {
|
|
46
|
+
} else if (t && !l.contains(document.activeElement)) {
|
|
47
47
|
l.hasAttribute("tabindex") || l.setAttribute("tabindex", "-1");
|
|
48
48
|
try {
|
|
49
49
|
l.focus({ preventScroll: !0 });
|
|
50
50
|
} catch {
|
|
51
51
|
}
|
|
52
|
+
} else if (!t) {
|
|
53
|
+
const a = o;
|
|
54
|
+
document.activeElement !== a && a.focus({ preventScroll: !0 });
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
const I = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',
|
|
59
|
+
const I = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', O = {
|
|
57
60
|
expand: "▶",
|
|
58
61
|
collapse: "▼",
|
|
59
62
|
sortAsc: "▲",
|
|
@@ -66,7 +69,7 @@ const I = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
66
69
|
filterActive: I,
|
|
67
70
|
print: "🖨️"
|
|
68
71
|
};
|
|
69
|
-
class
|
|
72
|
+
class B {
|
|
70
73
|
/**
|
|
71
74
|
* Plugin dependencies - declare other plugins this one requires.
|
|
72
75
|
*
|
|
@@ -356,7 +359,7 @@ class O {
|
|
|
356
359
|
*/
|
|
357
360
|
get gridIcons() {
|
|
358
361
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
359
|
-
return { ...
|
|
362
|
+
return { ...O, ...e };
|
|
360
363
|
}
|
|
361
364
|
// #region Animation Helpers
|
|
362
365
|
/**
|
|
@@ -432,8 +435,8 @@ class O {
|
|
|
432
435
|
}
|
|
433
436
|
// #endregion
|
|
434
437
|
}
|
|
435
|
-
const
|
|
436
|
-
function
|
|
438
|
+
const x = "@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--tbw-invalid-bg: light-dark(#fef2f2, #450a0a);--tbw-invalid-border-color: light-dark(#ef4444, #f87171)}tbw-grid:not(.tbw-grid-mode) .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}tbw-grid .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}tbw-grid .data-grid-row>.cell.editing input:not([type=checkbox]),tbw-grid .data-grid-row>.cell.editing select,tbw-grid .data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}tbw-grid .tbw-editor-host{display:contents}tbw-grid .data-grid-row>.cell[data-invalid=true]{background:var(--tbw-invalid-bg);outline:1px solid var(--tbw-invalid-border-color);outline-offset:-1px}}";
|
|
439
|
+
function G(o) {
|
|
437
440
|
const e = o.options;
|
|
438
441
|
return e ? typeof e == "function" ? e() : e : [];
|
|
439
442
|
}
|
|
@@ -453,7 +456,7 @@ function $() {
|
|
|
453
456
|
return e.type = "checkbox", e.checked = !!o.value, e.addEventListener("change", () => o.commit(e.checked)), e;
|
|
454
457
|
};
|
|
455
458
|
}
|
|
456
|
-
function
|
|
459
|
+
function z(o) {
|
|
457
460
|
return (e) => {
|
|
458
461
|
const t = o.editorParams, i = document.createElement("input");
|
|
459
462
|
i.type = "date", e.value instanceof Date ? i.valueAsDate = e.value : typeof e.value == "string" && e.value && (i.value = e.value.split("T")[0]), t?.min && (i.min = t.min), t?.max && (i.max = t.max), t?.placeholder && (i.placeholder = t.placeholder);
|
|
@@ -465,14 +468,14 @@ function G(o) {
|
|
|
465
468
|
}), i;
|
|
466
469
|
};
|
|
467
470
|
}
|
|
468
|
-
function
|
|
471
|
+
function F(o) {
|
|
469
472
|
return (e) => {
|
|
470
473
|
const t = o.editorParams, i = document.createElement("select");
|
|
471
474
|
if (o.multi && (i.multiple = !0), t?.includeEmpty) {
|
|
472
475
|
const n = document.createElement("option");
|
|
473
476
|
n.value = "", n.textContent = t.emptyLabel ?? "", i.appendChild(n);
|
|
474
477
|
}
|
|
475
|
-
|
|
478
|
+
G(o).forEach((n) => {
|
|
476
479
|
const l = document.createElement("option");
|
|
477
480
|
l.value = String(n.value), l.textContent = n.label, (o.multi && Array.isArray(e.value) && e.value.includes(n.value) || !o.multi && e.value === n.value) && (l.selected = !0), i.appendChild(l);
|
|
478
481
|
});
|
|
@@ -488,7 +491,7 @@ function z(o) {
|
|
|
488
491
|
}), i;
|
|
489
492
|
};
|
|
490
493
|
}
|
|
491
|
-
function
|
|
494
|
+
function K(o) {
|
|
492
495
|
return (e) => {
|
|
493
496
|
const t = o.editorParams, i = document.createElement("input");
|
|
494
497
|
i.type = "text", i.value = e.value != null ? String(e.value) : "", t?.maxLength !== void 0 && (i.maxLength = t.maxLength), t?.pattern && (i.pattern = t.pattern), t?.placeholder && (i.placeholder = t.placeholder);
|
|
@@ -501,21 +504,21 @@ function F(o) {
|
|
|
501
504
|
}), i;
|
|
502
505
|
};
|
|
503
506
|
}
|
|
504
|
-
function
|
|
507
|
+
function j(o) {
|
|
505
508
|
switch (o.type) {
|
|
506
509
|
case "number":
|
|
507
510
|
return N(o);
|
|
508
511
|
case "boolean":
|
|
509
512
|
return $();
|
|
510
513
|
case "date":
|
|
511
|
-
return G(o);
|
|
512
|
-
case "select":
|
|
513
514
|
return z(o);
|
|
514
|
-
|
|
515
|
+
case "select":
|
|
515
516
|
return F(o);
|
|
517
|
+
default:
|
|
518
|
+
return K(o);
|
|
516
519
|
}
|
|
517
520
|
}
|
|
518
|
-
function
|
|
521
|
+
function W(o, e) {
|
|
519
522
|
if (e.editor) return e.editor;
|
|
520
523
|
if (e.__editorTemplate) return "template";
|
|
521
524
|
if (!e.type) return;
|
|
@@ -532,11 +535,11 @@ function j(o, e) {
|
|
|
532
535
|
function S(o) {
|
|
533
536
|
return !(typeof o != "string" || o === "__proto__" || o === "constructor" || o === "prototype");
|
|
534
537
|
}
|
|
535
|
-
function
|
|
538
|
+
function U(o) {
|
|
536
539
|
const e = (o.__editingCellCount ?? 0) + 1;
|
|
537
540
|
o.__editingCellCount = e, o.setAttribute("data-has-editing", "");
|
|
538
541
|
}
|
|
539
|
-
function
|
|
542
|
+
function Q(o) {
|
|
540
543
|
o.__editingCellCount = 0, o.removeAttribute("data-has-editing");
|
|
541
544
|
}
|
|
542
545
|
function _(o, e, t) {
|
|
@@ -544,13 +547,13 @@ function _(o, e, t) {
|
|
|
544
547
|
}
|
|
545
548
|
function T(o) {
|
|
546
549
|
}
|
|
547
|
-
function
|
|
550
|
+
function X(o, e, t, i) {
|
|
548
551
|
const r = o.querySelector("input,textarea,select");
|
|
549
552
|
r && (r.addEventListener("blur", () => {
|
|
550
553
|
t(_(r, e, i));
|
|
551
554
|
}), r instanceof HTMLInputElement && r.type === "checkbox" ? r.addEventListener("change", () => t(r.checked)) : r instanceof HTMLSelectElement && r.addEventListener("change", () => t(_(r, e, i))));
|
|
552
555
|
}
|
|
553
|
-
class
|
|
556
|
+
class Z extends B {
|
|
554
557
|
/**
|
|
555
558
|
* Plugin manifest - declares owned properties for configuration validation.
|
|
556
559
|
* @internal
|
|
@@ -590,7 +593,7 @@ class X extends O {
|
|
|
590
593
|
/** @internal */
|
|
591
594
|
name = "editing";
|
|
592
595
|
/** @internal */
|
|
593
|
-
styles =
|
|
596
|
+
styles = x;
|
|
594
597
|
/** @internal */
|
|
595
598
|
get defaultConfig() {
|
|
596
599
|
return {
|
|
@@ -607,10 +610,15 @@ class X extends O {
|
|
|
607
610
|
// #region Editing State (fully owned by plugin)
|
|
608
611
|
/** Currently active edit row index, or -1 if not editing */
|
|
609
612
|
#e = -1;
|
|
613
|
+
/** Row ID of the currently active edit row (stable across _rows replacement) */
|
|
614
|
+
#l;
|
|
615
|
+
/** Reference to the row object at edit-open time. Used as fallback in
|
|
616
|
+
* #exitRowEdit when no row ID is available (prevents stale-index access). */
|
|
617
|
+
#f;
|
|
610
618
|
/** Currently active edit column index, or -1 if not editing */
|
|
611
|
-
#
|
|
619
|
+
#h = -1;
|
|
612
620
|
/** Snapshots of row data before editing started */
|
|
613
|
-
#
|
|
621
|
+
#c = /* @__PURE__ */ new Map();
|
|
614
622
|
/** Set of row IDs that have been modified (ID-based for stability) */
|
|
615
623
|
#r = /* @__PURE__ */ new Set();
|
|
616
624
|
/** Set of cells currently in edit mode: "rowIndex:colIndex" */
|
|
@@ -620,11 +628,11 @@ class X extends O {
|
|
|
620
628
|
* Keyed by "rowIndex:field" → callback that pushes updated values to the editor.
|
|
621
629
|
* Populated during #injectEditor, cleaned up when editors are removed.
|
|
622
630
|
*/
|
|
623
|
-
#
|
|
631
|
+
#a = /* @__PURE__ */ new Map();
|
|
624
632
|
/** Flag to restore focus after next render (used when exiting edit mode) */
|
|
625
|
-
#
|
|
633
|
+
#g = !1;
|
|
626
634
|
/** Row index pending animation after render, or -1 if none */
|
|
627
|
-
#
|
|
635
|
+
#p = -1;
|
|
628
636
|
/**
|
|
629
637
|
* Invalid cell tracking: Map<rowId, Map<field, message>>
|
|
630
638
|
* Used for validation feedback without canceling edits.
|
|
@@ -642,12 +650,12 @@ class X extends O {
|
|
|
642
650
|
* This is set when Escape is pressed (navigation mode) and cleared
|
|
643
651
|
* when Enter is pressed or user explicitly clicks an input.
|
|
644
652
|
*/
|
|
645
|
-
#
|
|
653
|
+
#d = !1;
|
|
646
654
|
/**
|
|
647
655
|
* When true, only a single cell is being edited (triggered by F2 or `beginCellEdit`).
|
|
648
656
|
* Tab and Arrow keys commit and close the editor instead of navigating to adjacent cells.
|
|
649
657
|
*/
|
|
650
|
-
#
|
|
658
|
+
#u = !1;
|
|
651
659
|
// #endregion
|
|
652
660
|
// #region Lifecycle
|
|
653
661
|
/** @internal */
|
|
@@ -687,7 +695,7 @@ class X extends O {
|
|
|
687
695
|
(r) => {
|
|
688
696
|
const s = r.detail;
|
|
689
697
|
if (s.source === "user") return;
|
|
690
|
-
const n = `${s.rowIndex}:${s.field}`, l = this.#
|
|
698
|
+
const n = `${s.rowIndex}:${s.field}`, l = this.#a.get(n);
|
|
691
699
|
l && l(s.newValue);
|
|
692
700
|
},
|
|
693
701
|
{ signal: t }
|
|
@@ -695,8 +703,8 @@ class X extends O {
|
|
|
695
703
|
"focusin",
|
|
696
704
|
(r) => {
|
|
697
705
|
const s = r.target;
|
|
698
|
-
if (s.matches(
|
|
699
|
-
if (this.#
|
|
706
|
+
if (s.matches(y)) {
|
|
707
|
+
if (this.#d) {
|
|
700
708
|
s.blur(), this.gridElement.focus();
|
|
701
709
|
return;
|
|
702
710
|
}
|
|
@@ -708,7 +716,7 @@ class X extends O {
|
|
|
708
716
|
"focusout",
|
|
709
717
|
(r) => {
|
|
710
718
|
const s = r.relatedTarget;
|
|
711
|
-
(!s || !this.gridElement.contains(s) || !s.matches(
|
|
719
|
+
(!s || !this.gridElement.contains(s) || !s.matches(y)) && (this.#n = !1);
|
|
712
720
|
},
|
|
713
721
|
{ signal: t }
|
|
714
722
|
), this.gridElement.addEventListener(
|
|
@@ -718,14 +726,14 @@ class X extends O {
|
|
|
718
726
|
if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(r) === !1)
|
|
719
727
|
return;
|
|
720
728
|
const s = document.activeElement;
|
|
721
|
-
s && this.gridElement.contains(s) && (s.blur(), this.gridElement.focus()), this.#n = !1, this.#
|
|
729
|
+
s && this.gridElement.contains(s) && (s.blur(), this.gridElement.focus()), this.#n = !1, this.#d = !0, r.preventDefault(), r.stopPropagation();
|
|
722
730
|
}
|
|
723
731
|
},
|
|
724
732
|
{ capture: !0, signal: t }
|
|
725
733
|
), this.gridElement.addEventListener(
|
|
726
734
|
"mousedown",
|
|
727
735
|
(r) => {
|
|
728
|
-
r.target.matches(
|
|
736
|
+
r.target.matches(y) && (this.#d = !1);
|
|
729
737
|
},
|
|
730
738
|
{ signal: t }
|
|
731
739
|
));
|
|
@@ -733,7 +741,7 @@ class X extends O {
|
|
|
733
741
|
/** @internal */
|
|
734
742
|
detach() {
|
|
735
743
|
const e = this.gridElement;
|
|
736
|
-
e._isGridEditMode = !1, this.gridElement.classList.remove("tbw-grid-mode"), this.#e = -1, this.#
|
|
744
|
+
e._isGridEditMode = !1, this.gridElement.classList.remove("tbw-grid-mode"), this.#e = -1, this.#l = void 0, this.#f = void 0, this.#h = -1, this.#c.clear(), this.#r.clear(), this.#o.clear(), this.#a.clear(), this.#n = !1, this.#d = !1, this.#u = !1, super.detach();
|
|
737
745
|
}
|
|
738
746
|
/**
|
|
739
747
|
* Handle plugin queries.
|
|
@@ -787,10 +795,10 @@ class X extends O {
|
|
|
787
795
|
return this.#s(r, !1), e.key === "ArrowDown" ? t._focusRow = Math.min(i, t._focusRow + 1) : t._focusRow = Math.max(0, t._focusRow - 1), e.preventDefault(), L(t), this.requestAfterRender(), !0;
|
|
788
796
|
}
|
|
789
797
|
if (e.key === "Tab" && (this.#e !== -1 || this.#t)) {
|
|
790
|
-
if (e.preventDefault(), this.#
|
|
798
|
+
if (e.preventDefault(), this.#u)
|
|
791
799
|
return this.#s(this.#e, !1), !0;
|
|
792
800
|
const i = !e.shiftKey;
|
|
793
|
-
return this.#
|
|
801
|
+
return this.#_(i), !0;
|
|
794
802
|
}
|
|
795
803
|
if (e.key === " " || e.key === "Spacebar") {
|
|
796
804
|
if (this.#e !== -1)
|
|
@@ -802,7 +810,7 @@ class X extends O {
|
|
|
802
810
|
const l = s.field;
|
|
803
811
|
if (S(l)) {
|
|
804
812
|
const a = !n[l];
|
|
805
|
-
return this.#
|
|
813
|
+
return this.#v(i, s, a, n), e.preventDefault(), this.requestRender(), !0;
|
|
806
814
|
}
|
|
807
815
|
}
|
|
808
816
|
}
|
|
@@ -810,7 +818,7 @@ class X extends O {
|
|
|
810
818
|
}
|
|
811
819
|
if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
|
|
812
820
|
if (this.#t && !this.#n)
|
|
813
|
-
return this.#
|
|
821
|
+
return this.#R(), !0;
|
|
814
822
|
if (this.#e !== -1)
|
|
815
823
|
return !!(this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1);
|
|
816
824
|
const i = this.config.editOn ?? t.effectiveConfig?.editOn;
|
|
@@ -883,9 +891,9 @@ class X extends O {
|
|
|
883
891
|
*/
|
|
884
892
|
afterRender() {
|
|
885
893
|
const e = this.grid;
|
|
886
|
-
if (this.#
|
|
887
|
-
const t = this.#
|
|
888
|
-
this.#
|
|
894
|
+
if (this.#g && (this.#g = !1, this.#y(e)), this.#p !== -1) {
|
|
895
|
+
const t = this.#p;
|
|
896
|
+
this.#p = -1, e.animateRow?.(t, "change");
|
|
889
897
|
}
|
|
890
898
|
if (!this.#t && this.#o.size !== 0)
|
|
891
899
|
for (const t of this.#o) {
|
|
@@ -894,7 +902,7 @@ class X extends O {
|
|
|
894
902
|
const c = l.querySelector(`.cell[data-col="${n}"]`);
|
|
895
903
|
if (!c || c.classList.contains("editing")) continue;
|
|
896
904
|
const a = e._rows[s], d = e._visibleColumns[n];
|
|
897
|
-
a && d && this.#
|
|
905
|
+
a && d && this.#w(a, s, d, n, c, !0);
|
|
898
906
|
}
|
|
899
907
|
}
|
|
900
908
|
/**
|
|
@@ -905,7 +913,7 @@ class X extends O {
|
|
|
905
913
|
afterCellRender(e) {
|
|
906
914
|
if (!this.#t) return;
|
|
907
915
|
const { row: t, rowIndex: i, column: r, colIndex: s, cellElement: n } = e;
|
|
908
|
-
r.editable && (n.classList.contains("editing") || this.#
|
|
916
|
+
r.editable && (n.classList.contains("editing") || this.#w(t, i, r, s, n, !0));
|
|
909
917
|
}
|
|
910
918
|
/**
|
|
911
919
|
* On scroll render, reapply editors to recycled cells.
|
|
@@ -944,7 +952,7 @@ class X extends O {
|
|
|
944
952
|
* Get the currently active edit column index, or -1 if not editing.
|
|
945
953
|
*/
|
|
946
954
|
get activeEditCol() {
|
|
947
|
-
return this.#
|
|
955
|
+
return this.#h;
|
|
948
956
|
}
|
|
949
957
|
/**
|
|
950
958
|
* Check if a specific row is currently being edited.
|
|
@@ -1003,7 +1011,7 @@ class X extends O {
|
|
|
1003
1011
|
*/
|
|
1004
1012
|
setInvalid(e, t, i = "") {
|
|
1005
1013
|
let r = this.#i.get(e);
|
|
1006
|
-
r || (r = /* @__PURE__ */ new Map(), this.#i.set(e, r)), r.set(t, i), this.#
|
|
1014
|
+
r || (r = /* @__PURE__ */ new Map(), this.#i.set(e, r)), r.set(t, i), this.#m(e, t, !0);
|
|
1007
1015
|
}
|
|
1008
1016
|
/**
|
|
1009
1017
|
* Clear the invalid state for a specific cell.
|
|
@@ -1013,7 +1021,7 @@ class X extends O {
|
|
|
1013
1021
|
*/
|
|
1014
1022
|
clearInvalid(e, t) {
|
|
1015
1023
|
const i = this.#i.get(e);
|
|
1016
|
-
i && (i.delete(t), i.size === 0 && this.#i.delete(e)), this.#
|
|
1024
|
+
i && (i.delete(t), i.size === 0 && this.#i.delete(e)), this.#m(e, t, !1);
|
|
1017
1025
|
}
|
|
1018
1026
|
/**
|
|
1019
1027
|
* Clear all invalid cells for a specific row.
|
|
@@ -1024,7 +1032,7 @@ class X extends O {
|
|
|
1024
1032
|
const t = this.#i.get(e);
|
|
1025
1033
|
if (t) {
|
|
1026
1034
|
const i = Array.from(t.keys());
|
|
1027
|
-
this.#i.delete(e), i.forEach((r) => this.#
|
|
1035
|
+
this.#i.delete(e), i.forEach((r) => this.#m(e, r, !1));
|
|
1028
1036
|
}
|
|
1029
1037
|
}
|
|
1030
1038
|
/**
|
|
@@ -1033,7 +1041,7 @@ class X extends O {
|
|
|
1033
1041
|
clearAllInvalid() {
|
|
1034
1042
|
const e = Array.from(this.#i.entries());
|
|
1035
1043
|
this.#i.clear(), e.forEach(([t, i]) => {
|
|
1036
|
-
i.forEach((r, s) => this.#
|
|
1044
|
+
i.forEach((r, s) => this.#m(t, s, !1));
|
|
1037
1045
|
});
|
|
1038
1046
|
}
|
|
1039
1047
|
/**
|
|
@@ -1078,7 +1086,7 @@ class X extends O {
|
|
|
1078
1086
|
/**
|
|
1079
1087
|
* Sync the data-invalid attribute on a cell element.
|
|
1080
1088
|
*/
|
|
1081
|
-
#
|
|
1089
|
+
#m(e, t, i) {
|
|
1082
1090
|
const r = this.grid, s = r._visibleColumns?.findIndex((d) => d.field === t);
|
|
1083
1091
|
if (s === -1 || s === void 0) return;
|
|
1084
1092
|
const l = r._rows?.findIndex((d) => {
|
|
@@ -1106,7 +1114,7 @@ class X extends O {
|
|
|
1106
1114
|
*/
|
|
1107
1115
|
resetChangedRows(e) {
|
|
1108
1116
|
const t = this.changedRows, i = this.changedRowIds;
|
|
1109
|
-
this.#r.clear(), this.#
|
|
1117
|
+
this.#r.clear(), this.#E(), e || this.emit("changed-rows-reset", { rows: t, ids: i }), this.grid._rowPool?.forEach((s) => s.classList.remove("changed"));
|
|
1110
1118
|
}
|
|
1111
1119
|
/**
|
|
1112
1120
|
* Programmatically begin editing a cell.
|
|
@@ -1118,7 +1126,7 @@ class X extends O {
|
|
|
1118
1126
|
const i = this.grid, r = i._visibleColumns.findIndex((c) => c.field === t);
|
|
1119
1127
|
if (r === -1 || !i._visibleColumns[r]?.editable) return;
|
|
1120
1128
|
const l = i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${r}"]`);
|
|
1121
|
-
l && (this.#
|
|
1129
|
+
l && (this.#u = !0, this.#C(e, r, l));
|
|
1122
1130
|
}
|
|
1123
1131
|
/**
|
|
1124
1132
|
* Programmatically begin editing all editable cells in a row.
|
|
@@ -1131,18 +1139,18 @@ class X extends O {
|
|
|
1131
1139
|
if ((this.config.editOn ?? t.effectiveConfig?.editOn) === !1 || !t._columns?.some((l) => l.editable)) return;
|
|
1132
1140
|
const s = t.findRenderedRowElement?.(e);
|
|
1133
1141
|
if (!s) return;
|
|
1134
|
-
this.#
|
|
1142
|
+
this.#u = !1;
|
|
1135
1143
|
const n = t._rows[e];
|
|
1136
|
-
this.#
|
|
1144
|
+
this.#b(e, n), Array.from(s.children).forEach((l, c) => {
|
|
1137
1145
|
const a = t._visibleColumns[c];
|
|
1138
1146
|
if (a?.editable) {
|
|
1139
1147
|
const d = l;
|
|
1140
|
-
d.classList.contains("editing") || this.#
|
|
1148
|
+
d.classList.contains("editing") || this.#w(n, e, a, c, d, !0);
|
|
1141
1149
|
}
|
|
1142
1150
|
}), setTimeout(() => {
|
|
1143
1151
|
let l = s.querySelector(`.cell[data-col="${t._focusCol}"]`);
|
|
1144
1152
|
if (l?.classList.contains("editing") || (l = s.querySelector(".cell.editing")), l?.classList.contains("editing")) {
|
|
1145
|
-
const c = l.querySelector(
|
|
1153
|
+
const c = l.querySelector(y);
|
|
1146
1154
|
try {
|
|
1147
1155
|
c?.focus({ preventScroll: !0 });
|
|
1148
1156
|
} catch {
|
|
@@ -1168,21 +1176,21 @@ class X extends O {
|
|
|
1168
1176
|
/**
|
|
1169
1177
|
* Begin editing a single cell.
|
|
1170
1178
|
*/
|
|
1171
|
-
#
|
|
1179
|
+
#C(e, t, i) {
|
|
1172
1180
|
const r = this.grid, s = r._rows[e], n = r._visibleColumns[t];
|
|
1173
|
-
!s || !n?.editable || i.classList.contains("editing") || (this.#e !== e && this.#
|
|
1181
|
+
!s || !n?.editable || i.classList.contains("editing") || (this.#e !== e && this.#b(e, s), this.#h = t, this.#w(s, e, n, t, i, !1));
|
|
1174
1182
|
}
|
|
1175
1183
|
/**
|
|
1176
1184
|
* Focus the editor input in the currently focused cell (grid mode only).
|
|
1177
1185
|
* Used when pressing Enter to enter edit mode from navigation mode.
|
|
1178
1186
|
*/
|
|
1179
|
-
#
|
|
1187
|
+
#R() {
|
|
1180
1188
|
const e = this.grid, t = e._focusRow, i = e._focusCol;
|
|
1181
1189
|
if (t < 0 || i < 0) return;
|
|
1182
1190
|
const s = e.findRenderedRowElement?.(t)?.querySelector(`.cell[data-col="${i}"]`);
|
|
1183
1191
|
if (s?.classList.contains("editing")) {
|
|
1184
|
-
const n = s.querySelector(
|
|
1185
|
-
n && (this.#
|
|
1192
|
+
const n = s.querySelector(y);
|
|
1193
|
+
n && (this.#d = !1, n.focus(), this.#n = !0, n instanceof HTMLInputElement && (n.type === "text" || n.type === "number") && n.select());
|
|
1186
1194
|
}
|
|
1187
1195
|
}
|
|
1188
1196
|
/**
|
|
@@ -1190,43 +1198,44 @@ class X extends O {
|
|
|
1190
1198
|
* Moves to next/previous editable cell, staying in edit mode.
|
|
1191
1199
|
* Wraps to next/previous row when reaching row boundaries.
|
|
1192
1200
|
*/
|
|
1193
|
-
#
|
|
1201
|
+
#_(e) {
|
|
1194
1202
|
const t = this.grid, i = t._rows, r = this.#t ? t._focusRow : this.#e, s = t._visibleColumns.map((a, d) => a.editable ? d : -1).filter((a) => a >= 0);
|
|
1195
1203
|
if (s.length === 0) return;
|
|
1196
1204
|
const l = s.indexOf(t._focusCol) + (e ? 1 : -1);
|
|
1197
1205
|
if (l >= 0 && l < s.length) {
|
|
1198
1206
|
t._focusCol = s[l];
|
|
1199
1207
|
const d = t.findRenderedRowElement?.(r)?.querySelector(`.cell[data-col="${s[l]}"]`);
|
|
1200
|
-
d?.classList.contains("editing") && d.querySelector(
|
|
1208
|
+
d?.classList.contains("editing") && d.querySelector(y)?.focus({ preventScroll: !0 }), L(t, { forceHorizontalScroll: !0 });
|
|
1201
1209
|
return;
|
|
1202
1210
|
}
|
|
1203
1211
|
const c = r + (e ? 1 : -1);
|
|
1204
1212
|
c >= 0 && c < i.length && (this.#t ? (t._focusRow = c, t._focusCol = e ? s[0] : s[s.length - 1], L(t, { forceHorizontalScroll: !0 }), this.requestAfterRender(), setTimeout(() => {
|
|
1205
1213
|
const d = t.findRenderedRowElement?.(c)?.querySelector(`.cell[data-col="${t._focusCol}"]`);
|
|
1206
|
-
d?.classList.contains("editing") && d.querySelector(
|
|
1214
|
+
d?.classList.contains("editing") && d.querySelector(y)?.focus({ preventScroll: !0 });
|
|
1207
1215
|
}, 0)) : (this.#s(r, !1), t._focusRow = c, t._focusCol = e ? s[0] : s[s.length - 1], this.beginBulkEdit(c), L(t, { forceHorizontalScroll: !0 })));
|
|
1208
1216
|
}
|
|
1209
1217
|
/**
|
|
1210
1218
|
* Sync the internal grid state with the plugin's editing state.
|
|
1211
1219
|
*/
|
|
1212
|
-
#
|
|
1220
|
+
#E() {
|
|
1213
1221
|
const e = this.grid;
|
|
1214
|
-
e._activeEditRows = this.#e, e._rowEditSnapshots = this.#
|
|
1222
|
+
e._activeEditRows = this.#e, e._rowEditSnapshots = this.#c;
|
|
1215
1223
|
}
|
|
1216
1224
|
/**
|
|
1217
1225
|
* Snapshot original row data and mark as editing.
|
|
1218
1226
|
*/
|
|
1219
|
-
#
|
|
1220
|
-
if (this.#e !== e
|
|
1227
|
+
#b(e, t) {
|
|
1228
|
+
if (this.#e !== e) {
|
|
1229
|
+
this.#c.set(e, { ...t }), this.#e = e, this.#f = t;
|
|
1221
1230
|
const i = this.grid;
|
|
1222
|
-
let r = "";
|
|
1223
1231
|
try {
|
|
1224
|
-
|
|
1232
|
+
this.#l = i.getRowId?.(t) ?? void 0;
|
|
1225
1233
|
} catch {
|
|
1234
|
+
this.#l = void 0;
|
|
1226
1235
|
}
|
|
1227
|
-
this.emit("edit-open", {
|
|
1236
|
+
this.#E(), this.#t || this.emit("edit-open", {
|
|
1228
1237
|
rowIndex: e,
|
|
1229
|
-
rowId:
|
|
1238
|
+
rowId: this.#l ?? "",
|
|
1230
1239
|
row: t
|
|
1231
1240
|
});
|
|
1232
1241
|
}
|
|
@@ -1236,54 +1245,55 @@ class X extends O {
|
|
|
1236
1245
|
*/
|
|
1237
1246
|
#s(e, t) {
|
|
1238
1247
|
if (this.#e !== e) return;
|
|
1239
|
-
const i = this.grid, r = this.#
|
|
1240
|
-
let l;
|
|
1241
|
-
|
|
1248
|
+
const i = this.grid, r = this.#c.get(e), s = i.findRenderedRowElement?.(e);
|
|
1249
|
+
let n = this.#l;
|
|
1250
|
+
const c = (n ? i._getRowEntry(n) : void 0)?.row ?? this.#f ?? i._rows[e];
|
|
1251
|
+
if (!n && c)
|
|
1242
1252
|
try {
|
|
1243
|
-
|
|
1253
|
+
n = i.getRowId?.(c);
|
|
1244
1254
|
} catch {
|
|
1245
1255
|
}
|
|
1246
|
-
if (!t &&
|
|
1247
|
-
const
|
|
1248
|
-
if (isNaN(
|
|
1249
|
-
const
|
|
1250
|
-
if (!
|
|
1256
|
+
if (!t && s && c && s.querySelectorAll(".cell.editing").forEach((d) => {
|
|
1257
|
+
const g = Number(d.getAttribute("data-col"));
|
|
1258
|
+
if (isNaN(g)) return;
|
|
1259
|
+
const f = i._visibleColumns[g];
|
|
1260
|
+
if (!f || d.hasAttribute("data-editor-managed"))
|
|
1251
1261
|
return;
|
|
1252
|
-
const
|
|
1253
|
-
if (
|
|
1254
|
-
const
|
|
1255
|
-
|
|
1262
|
+
const E = d.querySelector("input,textarea,select");
|
|
1263
|
+
if (E) {
|
|
1264
|
+
const p = f.field, m = c[p], C = _(E, f, m);
|
|
1265
|
+
m !== C && this.#v(e, f, C, c);
|
|
1256
1266
|
}
|
|
1257
|
-
}), t && r &&
|
|
1258
|
-
Object.keys(r).forEach((
|
|
1259
|
-
|
|
1260
|
-
}),
|
|
1261
|
-
else if (!t &&
|
|
1262
|
-
const
|
|
1267
|
+
}), t && r && c)
|
|
1268
|
+
Object.keys(r).forEach((a) => {
|
|
1269
|
+
c[a] = r[a];
|
|
1270
|
+
}), n && (this.#r.delete(n), this.clearRowInvalid(n));
|
|
1271
|
+
else if (!t && c) {
|
|
1272
|
+
const a = this.#L(r, c), d = n ? this.#r.has(n) : a, g = this.emitCancelable("row-commit", {
|
|
1263
1273
|
rowIndex: e,
|
|
1264
|
-
rowId:
|
|
1265
|
-
row:
|
|
1274
|
+
rowId: n ?? "",
|
|
1275
|
+
row: c,
|
|
1266
1276
|
oldValue: r,
|
|
1267
|
-
newValue:
|
|
1268
|
-
changed:
|
|
1277
|
+
newValue: c,
|
|
1278
|
+
changed: d,
|
|
1269
1279
|
changedRows: this.changedRows,
|
|
1270
1280
|
changedRowIds: this.changedRowIds
|
|
1271
1281
|
});
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
}),
|
|
1282
|
+
g && r ? (Object.keys(r).forEach((f) => {
|
|
1283
|
+
c[f] = r[f];
|
|
1284
|
+
}), n && (this.#r.delete(n), this.clearRowInvalid(n))) : !g && a && this.isAnimationEnabled && (this.#p = e);
|
|
1275
1285
|
}
|
|
1276
|
-
this.#
|
|
1277
|
-
for (const
|
|
1278
|
-
|
|
1279
|
-
for (const
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
}),
|
|
1286
|
+
this.#c.delete(e), this.#e = -1, this.#l = void 0, this.#f = void 0, this.#h = -1, this.#u = !1, this.#E();
|
|
1287
|
+
for (const a of this.#o)
|
|
1288
|
+
a.startsWith(`${e}:`) && this.#o.delete(a);
|
|
1289
|
+
for (const a of this.#a.keys())
|
|
1290
|
+
a.startsWith(`${e}:`) && this.#a.delete(a);
|
|
1291
|
+
this.#g = !0, s ? (s.querySelectorAll(".cell.editing").forEach((a) => {
|
|
1292
|
+
a.classList.remove("editing"), Q(a.parentElement);
|
|
1293
|
+
}), i.refreshVirtualWindow(!0)) : (this.#y(i), this.#g = !1), !this.#t && c && this.emit("edit-close", {
|
|
1284
1294
|
rowIndex: e,
|
|
1285
|
-
rowId:
|
|
1286
|
-
row:
|
|
1295
|
+
rowId: n ?? "",
|
|
1296
|
+
row: c,
|
|
1287
1297
|
reverted: t
|
|
1288
1298
|
});
|
|
1289
1299
|
}
|
|
@@ -1291,7 +1301,7 @@ class X extends O {
|
|
|
1291
1301
|
* Commit a single cell value change.
|
|
1292
1302
|
* Uses ID-based change tracking for stability when rows are reordered.
|
|
1293
1303
|
*/
|
|
1294
|
-
#
|
|
1304
|
+
#v(e, t, i, r) {
|
|
1295
1305
|
const s = t.field;
|
|
1296
1306
|
if (!S(s)) return;
|
|
1297
1307
|
const n = r[s];
|
|
@@ -1321,7 +1331,7 @@ class X extends O {
|
|
|
1321
1331
|
updateRow: d,
|
|
1322
1332
|
setInvalid: f
|
|
1323
1333
|
})) return;
|
|
1324
|
-
c && !g && this.isCellInvalid(c, s) && this.clearInvalid(c, s), r[s] = i, c && this.#r.add(c), this.#
|
|
1334
|
+
c && !g && this.isCellInvalid(c, s) && this.clearInvalid(c, s), r[s] = i, c && this.#r.add(c), this.#E(), this.emitPluginEvent("cell-edit-committed", {
|
|
1325
1335
|
rowIndex: e,
|
|
1326
1336
|
field: s,
|
|
1327
1337
|
oldValue: n,
|
|
@@ -1333,7 +1343,7 @@ class X extends O {
|
|
|
1333
1343
|
/**
|
|
1334
1344
|
* Inject an editor into a cell.
|
|
1335
1345
|
*/
|
|
1336
|
-
#
|
|
1346
|
+
#w(e, t, i, r, s, n) {
|
|
1337
1347
|
if (!i.editable || s.classList.contains("editing")) return;
|
|
1338
1348
|
let l;
|
|
1339
1349
|
try {
|
|
@@ -1343,16 +1353,16 @@ class X extends O {
|
|
|
1343
1353
|
const c = l ? (u) => this.grid.updateRow(l, u, "cascade") : T, a = S(i.field) ? e[i.field] : void 0;
|
|
1344
1354
|
s.classList.add("editing"), this.#o.add(`${t}:${r}`);
|
|
1345
1355
|
const d = s.parentElement;
|
|
1346
|
-
d &&
|
|
1356
|
+
d && U(d);
|
|
1347
1357
|
let g = !1;
|
|
1348
1358
|
const f = (u) => {
|
|
1349
1359
|
if (g || !this.#t && this.#e === -1) return;
|
|
1350
|
-
const h = this.grid.
|
|
1351
|
-
this.#
|
|
1360
|
+
const h = this.grid, v = l ? h._getRowEntry(l) : void 0, b = v?.row ?? e, M = v?.index ?? t;
|
|
1361
|
+
this.#v(M, i, u, b);
|
|
1352
1362
|
}, E = () => {
|
|
1353
1363
|
if (g = !0, S(i.field)) {
|
|
1354
|
-
const u = this.grid.
|
|
1355
|
-
|
|
1364
|
+
const u = this.grid, v = (l ? u._getRowEntry(l) : void 0)?.row ?? e;
|
|
1365
|
+
v[i.field] = a;
|
|
1356
1366
|
}
|
|
1357
1367
|
}, p = document.createElement("div");
|
|
1358
1368
|
p.className = "tbw-editor-host", s.innerHTML = "", s.appendChild(p), p.addEventListener("keydown", (u) => {
|
|
@@ -1377,15 +1387,15 @@ class X extends O {
|
|
|
1377
1387
|
u.stopPropagation(), u.preventDefault(), E(), this.#s(t, !0);
|
|
1378
1388
|
}
|
|
1379
1389
|
});
|
|
1380
|
-
const m = i,
|
|
1381
|
-
this.#
|
|
1390
|
+
const m = i, C = m.__editorTemplate, w = W(this.grid, m) ?? j(i), k = a, q = `${t}:${i.field}`, A = [];
|
|
1391
|
+
this.#a.set(q, (u) => {
|
|
1382
1392
|
for (const h of A) h(u);
|
|
1383
1393
|
});
|
|
1384
|
-
const
|
|
1394
|
+
const R = (u) => {
|
|
1385
1395
|
A.push(u);
|
|
1386
1396
|
};
|
|
1387
|
-
if (w === "template" &&
|
|
1388
|
-
this.#
|
|
1397
|
+
if (w === "template" && C)
|
|
1398
|
+
this.#S(p, m, e, a, f, E, n, t), R((u) => {
|
|
1389
1399
|
const h = p.querySelector(
|
|
1390
1400
|
"input,textarea,select"
|
|
1391
1401
|
);
|
|
@@ -1393,10 +1403,10 @@ class X extends O {
|
|
|
1393
1403
|
});
|
|
1394
1404
|
else if (typeof w == "string") {
|
|
1395
1405
|
const u = document.createElement(w);
|
|
1396
|
-
u.value = k, u.addEventListener("change", () => f(u.value)),
|
|
1406
|
+
u.value = k, u.addEventListener("change", () => f(u.value)), R((h) => {
|
|
1397
1407
|
u.value = h;
|
|
1398
1408
|
}), p.appendChild(u), n || queueMicrotask(() => {
|
|
1399
|
-
p.querySelector(
|
|
1409
|
+
p.querySelector(y)?.focus({ preventScroll: !0 });
|
|
1400
1410
|
});
|
|
1401
1411
|
} else if (typeof w == "function") {
|
|
1402
1412
|
const u = {
|
|
@@ -1408,17 +1418,17 @@ class X extends O {
|
|
|
1408
1418
|
commit: f,
|
|
1409
1419
|
cancel: E,
|
|
1410
1420
|
updateRow: c,
|
|
1411
|
-
onValueChange:
|
|
1421
|
+
onValueChange: R
|
|
1412
1422
|
}, h = w(u);
|
|
1413
|
-
typeof h == "string" ? (p.innerHTML = h,
|
|
1423
|
+
typeof h == "string" ? (p.innerHTML = h, X(p, i, f, a), R((v) => {
|
|
1414
1424
|
const b = p.querySelector(
|
|
1415
1425
|
"input,textarea,select"
|
|
1416
1426
|
);
|
|
1417
|
-
b && (b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked = !!
|
|
1418
|
-
})) : h instanceof Node && (p.appendChild(h), h instanceof HTMLInputElement || h instanceof HTMLSelectElement || h instanceof HTMLTextAreaElement ?
|
|
1427
|
+
b && (b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked = !!v : b.value = String(v ?? ""));
|
|
1428
|
+
})) : h instanceof Node && (p.appendChild(h), h instanceof HTMLInputElement || h instanceof HTMLSelectElement || h instanceof HTMLTextAreaElement ? R((b) => {
|
|
1419
1429
|
h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!b : h.value = String(b ?? "");
|
|
1420
1430
|
}) : s.setAttribute("data-editor-managed", "")), n || queueMicrotask(() => {
|
|
1421
|
-
p.querySelector(
|
|
1431
|
+
p.querySelector(y)?.focus({ preventScroll: !0 });
|
|
1422
1432
|
});
|
|
1423
1433
|
} else if (w && typeof w == "object") {
|
|
1424
1434
|
const u = document.createElement("div");
|
|
@@ -1432,13 +1442,13 @@ class X extends O {
|
|
|
1432
1442
|
commit: f,
|
|
1433
1443
|
cancel: E,
|
|
1434
1444
|
updateRow: c,
|
|
1435
|
-
onValueChange:
|
|
1445
|
+
onValueChange: R
|
|
1436
1446
|
};
|
|
1437
1447
|
if (w.mount)
|
|
1438
1448
|
try {
|
|
1439
1449
|
w.mount({ placeholder: u, context: h, spec: w });
|
|
1440
|
-
} catch (
|
|
1441
|
-
console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`,
|
|
1450
|
+
} catch (v) {
|
|
1451
|
+
console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`, v);
|
|
1442
1452
|
}
|
|
1443
1453
|
else
|
|
1444
1454
|
this.grid.dispatchEvent(
|
|
@@ -1449,7 +1459,7 @@ class X extends O {
|
|
|
1449
1459
|
/**
|
|
1450
1460
|
* Render a template-based editor.
|
|
1451
1461
|
*/
|
|
1452
|
-
#
|
|
1462
|
+
#S(e, t, i, r, s, n, l, c) {
|
|
1453
1463
|
const a = t.__editorTemplate;
|
|
1454
1464
|
if (!a) return;
|
|
1455
1465
|
const d = a.cloneNode(!0), g = t.__compiledEditor;
|
|
@@ -1463,8 +1473,8 @@ class X extends O {
|
|
|
1463
1473
|
}) : d.querySelectorAll("*").forEach((E) => {
|
|
1464
1474
|
E.childNodes.length === 1 && E.firstChild?.nodeType === Node.TEXT_NODE && (E.textContent = E.textContent?.replace(/{{\s*value\s*}}/g, r == null ? "" : String(r)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (p, m) => {
|
|
1465
1475
|
if (!S(m)) return "";
|
|
1466
|
-
const
|
|
1467
|
-
return
|
|
1476
|
+
const C = i[m];
|
|
1477
|
+
return C == null ? "" : String(C);
|
|
1468
1478
|
}) || "");
|
|
1469
1479
|
});
|
|
1470
1480
|
const f = d.querySelector(
|
|
@@ -1495,7 +1505,7 @@ class X extends O {
|
|
|
1495
1505
|
* Compare snapshot vs current row to detect if any values changed during this edit session.
|
|
1496
1506
|
* Uses shallow comparison of all properties.
|
|
1497
1507
|
*/
|
|
1498
|
-
#
|
|
1508
|
+
#L(e, t) {
|
|
1499
1509
|
if (!e) return !1;
|
|
1500
1510
|
const i = e, r = t, s = /* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(r)]);
|
|
1501
1511
|
for (const n of s)
|
|
@@ -1506,7 +1516,7 @@ class X extends O {
|
|
|
1506
1516
|
/**
|
|
1507
1517
|
* Restore focus to cell after exiting edit mode.
|
|
1508
1518
|
*/
|
|
1509
|
-
#
|
|
1519
|
+
#y(e) {
|
|
1510
1520
|
queueMicrotask(() => {
|
|
1511
1521
|
try {
|
|
1512
1522
|
const t = e._focusRow, i = e._focusCol, r = e.findRenderedRowElement?.(t);
|
|
@@ -1524,7 +1534,7 @@ class X extends O {
|
|
|
1524
1534
|
// #endregion
|
|
1525
1535
|
}
|
|
1526
1536
|
export {
|
|
1527
|
-
|
|
1528
|
-
|
|
1537
|
+
Z as EditingPlugin,
|
|
1538
|
+
j as defaultEditorFor
|
|
1529
1539
|
};
|
|
1530
1540
|
//# sourceMappingURL=index.js.map
|