@toolbox-web/grid 0.4.2 → 0.6.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 +2 -3
- package/all.js +1063 -1024
- package/all.js.map +1 -1
- package/index.js +1078 -912
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +28 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/dom-builder.d.ts +2 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts +21 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/resize.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +19 -13
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +13 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/expander-column.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +6 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/types.d.ts +41 -3
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +22 -11
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +59 -48
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +71 -60
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +93 -80
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +29 -18
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +9 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +199 -165
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +79 -49
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +98 -87
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +70 -57
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +48 -37
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +71 -66
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +63 -52
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +310 -299
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.d.ts +1 -1
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +79 -68
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +115 -105
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +15 -4
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +41 -30
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +29 -18
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +59 -47
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +6 -6
- package/public.d.ts +42 -0
- package/public.d.ts.map +1 -1
- package/themes/dg-theme-bootstrap.css +55 -53
- package/themes/dg-theme-contrast.css +42 -40
- package/themes/dg-theme-large.css +38 -37
- package/themes/dg-theme-material.css +54 -52
- package/themes/dg-theme-standard.css +19 -17
- package/themes/dg-theme-vibrant.css +16 -14
- package/umd/grid.all.umd.js +23 -22
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -14
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.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/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.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/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -185,10 +185,21 @@ class S {
|
|
|
185
185
|
return this.grid;
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
188
|
-
* Get the
|
|
188
|
+
* Get the render root of the grid for DOM queries.
|
|
189
|
+
* @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
|
|
190
|
+
*
|
|
191
|
+
* With Shadow DOM removed, the grid element itself is the render root.
|
|
192
|
+
* All new code should use `this.gridElement` for DOM queries.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // OLD (deprecated)
|
|
196
|
+
* const rows = this.shadowRoot?.querySelector('.rows');
|
|
197
|
+
*
|
|
198
|
+
* // NEW (preferred)
|
|
199
|
+
* const rows = this.gridElement.querySelector('.rows');
|
|
189
200
|
*/
|
|
190
201
|
get shadowRoot() {
|
|
191
|
-
return this.
|
|
202
|
+
return this.gridElement;
|
|
192
203
|
}
|
|
193
204
|
/**
|
|
194
205
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -239,7 +250,7 @@ class S {
|
|
|
239
250
|
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
240
251
|
if (e === !1 || e === "off") return !1;
|
|
241
252
|
if (e === !0 || e === "on") return !0;
|
|
242
|
-
const t = this.
|
|
253
|
+
const t = this.gridElement;
|
|
243
254
|
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
244
255
|
}
|
|
245
256
|
/**
|
|
@@ -255,7 +266,7 @@ class S {
|
|
|
255
266
|
* ```
|
|
256
267
|
*/
|
|
257
268
|
get animationDuration() {
|
|
258
|
-
const e = this.
|
|
269
|
+
const e = this.gridElement;
|
|
259
270
|
if (e) {
|
|
260
271
|
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), i = parseInt(t, 10);
|
|
261
272
|
if (!isNaN(i)) return i;
|
|
@@ -292,7 +303,8 @@ class S {
|
|
|
292
303
|
}
|
|
293
304
|
// #endregion
|
|
294
305
|
}
|
|
295
|
-
|
|
306
|
+
const L = "@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-grid .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}}";
|
|
307
|
+
function k(l) {
|
|
296
308
|
switch (l.type) {
|
|
297
309
|
case "number":
|
|
298
310
|
return (e) => {
|
|
@@ -320,14 +332,14 @@ function L(l) {
|
|
|
320
332
|
i.multi && (t.multiple = !0);
|
|
321
333
|
const s = i.options;
|
|
322
334
|
(typeof s == "function" ? s() : s || []).forEach((r) => {
|
|
323
|
-
const
|
|
324
|
-
|
|
335
|
+
const a = document.createElement("option");
|
|
336
|
+
a.value = String(r.value), a.textContent = r.label, (i.multi && Array.isArray(e.value) && e.value.includes(r.value) || !i.multi && e.value === r.value) && (a.selected = !0), t.appendChild(a);
|
|
325
337
|
});
|
|
326
338
|
const o = () => {
|
|
327
339
|
if (i.multi) {
|
|
328
340
|
const r = [];
|
|
329
|
-
Array.from(t.selectedOptions).forEach((
|
|
330
|
-
r.push(
|
|
341
|
+
Array.from(t.selectedOptions).forEach((a) => {
|
|
342
|
+
r.push(a.value);
|
|
331
343
|
}), e.commit(r);
|
|
332
344
|
} else
|
|
333
345
|
e.commit(t.value);
|
|
@@ -346,30 +358,31 @@ function L(l) {
|
|
|
346
358
|
}
|
|
347
359
|
}
|
|
348
360
|
const C = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
|
|
349
|
-
function
|
|
361
|
+
function w(l) {
|
|
350
362
|
return !(typeof l != "string" || l === "__proto__" || l === "constructor" || l === "prototype");
|
|
351
363
|
}
|
|
352
|
-
function
|
|
364
|
+
function O(l) {
|
|
353
365
|
return (l.__editingCellCount ?? 0) > 0;
|
|
354
366
|
}
|
|
355
|
-
function
|
|
367
|
+
function A(l) {
|
|
356
368
|
const e = (l.__editingCellCount ?? 0) + 1;
|
|
357
369
|
l.__editingCellCount = e, l.setAttribute("data-has-editing", "");
|
|
358
370
|
}
|
|
359
|
-
function
|
|
371
|
+
function q(l) {
|
|
360
372
|
l.__editingCellCount = 0, l.removeAttribute("data-has-editing");
|
|
361
373
|
}
|
|
362
|
-
function
|
|
374
|
+
function v(l, e) {
|
|
363
375
|
return l instanceof HTMLInputElement ? l.type === "checkbox" ? l.checked : l.type === "number" ? l.value === "" ? null : Number(l.value) : l.type === "date" ? l.valueAsDate : l.value : e?.type === "number" && l.value !== "" ? Number(l.value) : l.value;
|
|
364
376
|
}
|
|
365
|
-
function
|
|
377
|
+
function T(l, e, t) {
|
|
366
378
|
const i = l.querySelector("input,textarea,select");
|
|
367
379
|
i && (i.addEventListener("blur", () => {
|
|
368
|
-
t(
|
|
369
|
-
}), i instanceof HTMLInputElement && i.type === "checkbox" ? i.addEventListener("change", () => t(i.checked)) : i instanceof HTMLSelectElement && i.addEventListener("change", () => t(
|
|
380
|
+
t(v(i, e));
|
|
381
|
+
}), i instanceof HTMLInputElement && i.type === "checkbox" ? i.addEventListener("change", () => t(i.checked)) : i instanceof HTMLSelectElement && i.addEventListener("change", () => t(v(i, e))));
|
|
370
382
|
}
|
|
371
|
-
class
|
|
383
|
+
class N extends S {
|
|
372
384
|
name = "editing";
|
|
385
|
+
styles = L;
|
|
373
386
|
get defaultConfig() {
|
|
374
387
|
return {
|
|
375
388
|
editOn: "click"
|
|
@@ -448,9 +461,9 @@ class O extends S {
|
|
|
448
461
|
const n = t._visibleColumns[s], o = t._rows[i];
|
|
449
462
|
if (n?.editable && n.type === "boolean" && o) {
|
|
450
463
|
const r = n.field;
|
|
451
|
-
if (
|
|
464
|
+
if (w(r)) {
|
|
452
465
|
const f = !o[r];
|
|
453
|
-
return this.#
|
|
466
|
+
return this.#a(i, n, f, o), e.preventDefault(), this.requestRender(), !0;
|
|
454
467
|
}
|
|
455
468
|
}
|
|
456
469
|
}
|
|
@@ -479,10 +492,10 @@ class O extends S {
|
|
|
479
492
|
for (const t of this.#n) {
|
|
480
493
|
const [i, s] = t.split(":"), n = parseInt(i, 10), o = parseInt(s, 10), r = e.findRenderedRowElement?.(n);
|
|
481
494
|
if (!r) continue;
|
|
482
|
-
const
|
|
483
|
-
if (!
|
|
495
|
+
const a = r.querySelector(`.cell[data-col="${o}"]`);
|
|
496
|
+
if (!a || a.classList.contains("editing")) continue;
|
|
484
497
|
const f = e._rows[n], d = e._visibleColumns[o];
|
|
485
|
-
f && d && this.#
|
|
498
|
+
f && d && this.#c(f, n, d, o, a, !0);
|
|
486
499
|
}
|
|
487
500
|
}
|
|
488
501
|
/**
|
|
@@ -547,7 +560,7 @@ class O extends S {
|
|
|
547
560
|
* Programmatically begin editing a cell.
|
|
548
561
|
*/
|
|
549
562
|
beginCellEdit(e, t) {
|
|
550
|
-
const i = this.grid, s = i._visibleColumns.findIndex((
|
|
563
|
+
const i = this.grid, s = i._visibleColumns.findIndex((a) => a.field === t);
|
|
551
564
|
if (s === -1 || !i._visibleColumns[s]?.editable) return;
|
|
552
565
|
const r = i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${s}"]`);
|
|
553
566
|
r && this.#f(e, s, r);
|
|
@@ -561,18 +574,18 @@ class O extends S {
|
|
|
561
574
|
const n = t.findRenderedRowElement?.(e);
|
|
562
575
|
if (!n) return;
|
|
563
576
|
const o = t._rows[e];
|
|
564
|
-
this.#d(e, o), Array.from(n.children).forEach((r,
|
|
565
|
-
const f = t._visibleColumns[
|
|
577
|
+
this.#d(e, o), Array.from(n.children).forEach((r, a) => {
|
|
578
|
+
const f = t._visibleColumns[a];
|
|
566
579
|
if (f?.editable) {
|
|
567
580
|
const d = r;
|
|
568
|
-
d.classList.contains("editing") || this.#
|
|
581
|
+
d.classList.contains("editing") || this.#c(o, e, f, a, d, !0);
|
|
569
582
|
}
|
|
570
583
|
}), setTimeout(() => {
|
|
571
584
|
let r = n.querySelector(`.cell[data-col="${t._focusCol}"]`);
|
|
572
585
|
if (r?.classList.contains("editing") || (r = n.querySelector(".cell.editing")), r?.classList.contains("editing")) {
|
|
573
|
-
const
|
|
586
|
+
const a = r.querySelector(C);
|
|
574
587
|
try {
|
|
575
|
-
|
|
588
|
+
a?.focus({ preventScroll: !0 });
|
|
576
589
|
} catch {
|
|
577
590
|
}
|
|
578
591
|
}
|
|
@@ -597,7 +610,7 @@ class O extends S {
|
|
|
597
610
|
*/
|
|
598
611
|
#f(e, t, i) {
|
|
599
612
|
const s = this.grid, n = s._rows[e], o = s._visibleColumns[t];
|
|
600
|
-
!n || !o?.editable || i.classList.contains("editing") || (this.#e !== e && this.#d(e, n), this.#r = t, this.#
|
|
613
|
+
!n || !o?.editable || i.classList.contains("editing") || (this.#e !== e && this.#d(e, n), this.#r = t, this.#c(n, e, o, t, i, !1));
|
|
601
614
|
}
|
|
602
615
|
/**
|
|
603
616
|
* Sync the internal grid state with the plugin's editing state.
|
|
@@ -618,15 +631,15 @@ class O extends S {
|
|
|
618
631
|
#i(e, t) {
|
|
619
632
|
if (this.#e !== e) return;
|
|
620
633
|
const i = this.grid, s = this.#s.get(e), n = i._rows[e], o = i.findRenderedRowElement?.(e);
|
|
621
|
-
if (!t && o && n && o.querySelectorAll(".cell.editing").forEach((
|
|
622
|
-
const f = Number(
|
|
634
|
+
if (!t && o && n && o.querySelectorAll(".cell.editing").forEach((a) => {
|
|
635
|
+
const f = Number(a.getAttribute("data-col"));
|
|
623
636
|
if (isNaN(f)) return;
|
|
624
637
|
const d = i._visibleColumns[f];
|
|
625
638
|
if (!d) return;
|
|
626
|
-
const
|
|
627
|
-
if (
|
|
628
|
-
const
|
|
629
|
-
n[d.field] !==
|
|
639
|
+
const b = a.querySelector("input,textarea,select");
|
|
640
|
+
if (b) {
|
|
641
|
+
const c = v(b, d);
|
|
642
|
+
n[d.field] !== c && this.#a(e, d, c, n);
|
|
630
643
|
}
|
|
631
644
|
}), t && s && n)
|
|
632
645
|
Object.keys(s).forEach((r) => {
|
|
@@ -646,15 +659,15 @@ class O extends S {
|
|
|
646
659
|
for (const r of this.#n)
|
|
647
660
|
r.startsWith(`${e}:`) && this.#n.delete(r);
|
|
648
661
|
o && (o.querySelectorAll(".cell.editing").forEach((r) => {
|
|
649
|
-
r.classList.remove("editing"),
|
|
662
|
+
r.classList.remove("editing"), q(r.parentElement);
|
|
650
663
|
}), this.requestRender()), this.#o = !0, o || (this.#u(i), this.#o = !1);
|
|
651
664
|
}
|
|
652
665
|
/**
|
|
653
666
|
* Commit a single cell value change.
|
|
654
667
|
*/
|
|
655
|
-
#
|
|
668
|
+
#a(e, t, i, s) {
|
|
656
669
|
const n = t.field;
|
|
657
|
-
if (!
|
|
670
|
+
if (!w(n)) return;
|
|
658
671
|
const o = s[n];
|
|
659
672
|
if (o === i) return;
|
|
660
673
|
const r = !this.#t.has(e);
|
|
@@ -675,58 +688,58 @@ class O extends S {
|
|
|
675
688
|
/**
|
|
676
689
|
* Inject an editor into a cell.
|
|
677
690
|
*/
|
|
678
|
-
#
|
|
691
|
+
#c(e, t, i, s, n, o) {
|
|
679
692
|
if (!i.editable || n.classList.contains("editing")) return;
|
|
680
|
-
const r =
|
|
693
|
+
const r = w(i.field) ? e[i.field] : void 0;
|
|
681
694
|
n.classList.add("editing"), this.#n.add(`${t}:${s}`);
|
|
682
|
-
const
|
|
683
|
-
|
|
695
|
+
const a = n.parentElement;
|
|
696
|
+
a && A(a);
|
|
684
697
|
let f = !1;
|
|
685
698
|
const d = (h) => {
|
|
686
|
-
f || this.#e === -1 || this.#
|
|
687
|
-
},
|
|
688
|
-
f = !0,
|
|
689
|
-
},
|
|
690
|
-
|
|
691
|
-
h.key === "Enter" && (h.stopPropagation(), h.preventDefault(), f = !0, this.#i(t, !1)), h.key === "Escape" && (h.stopPropagation(), h.preventDefault(),
|
|
699
|
+
f || this.#e === -1 || this.#a(t, i, h, e);
|
|
700
|
+
}, b = () => {
|
|
701
|
+
f = !0, w(i.field) && (e[i.field] = r);
|
|
702
|
+
}, c = document.createElement("div");
|
|
703
|
+
c.className = "tbw-editor-host", n.innerHTML = "", n.appendChild(c), c.addEventListener("keydown", (h) => {
|
|
704
|
+
h.key === "Enter" && (h.stopPropagation(), h.preventDefault(), f = !0, this.#i(t, !1)), h.key === "Escape" && (h.stopPropagation(), h.preventDefault(), b(), this.#i(t, !0));
|
|
692
705
|
});
|
|
693
|
-
const g = i,
|
|
694
|
-
if (u === "template" &&
|
|
695
|
-
this.#h(
|
|
706
|
+
const g = i, E = g.__editorTemplate, u = g.editor || (E ? "template" : k(i)), m = r;
|
|
707
|
+
if (u === "template" && E)
|
|
708
|
+
this.#h(c, g, e, r, d, b, o, t);
|
|
696
709
|
else if (typeof u == "string") {
|
|
697
710
|
const h = document.createElement(u);
|
|
698
|
-
h.value = m, h.addEventListener("change", () => d(h.value)),
|
|
699
|
-
|
|
711
|
+
h.value = m, h.addEventListener("change", () => d(h.value)), c.appendChild(h), o || queueMicrotask(() => {
|
|
712
|
+
c.querySelector(C)?.focus({ preventScroll: !0 });
|
|
700
713
|
});
|
|
701
714
|
} else if (typeof u == "function") {
|
|
702
|
-
const h = { row: e, value: m, field: i.field, column: i, commit: d, cancel:
|
|
703
|
-
typeof
|
|
704
|
-
|
|
715
|
+
const h = { row: e, value: m, field: i.field, column: i, commit: d, cancel: b }, p = u(h);
|
|
716
|
+
typeof p == "string" ? (c.innerHTML = p, T(c, i, d)) : p instanceof Node && c.appendChild(p), o || queueMicrotask(() => {
|
|
717
|
+
c.querySelector(C)?.focus({ preventScroll: !0 });
|
|
705
718
|
});
|
|
706
719
|
} else if (u && typeof u == "object") {
|
|
707
|
-
const h = this.grid,
|
|
708
|
-
|
|
709
|
-
const
|
|
720
|
+
const h = this.grid, p = document.createElement("div");
|
|
721
|
+
p.setAttribute("data-external-editor", ""), p.setAttribute("data-field", i.field), c.appendChild(p);
|
|
722
|
+
const y = { row: e, value: m, field: i.field, column: i, commit: d, cancel: b };
|
|
710
723
|
if (u.mount)
|
|
711
724
|
try {
|
|
712
|
-
u.mount({ placeholder:
|
|
725
|
+
u.mount({ placeholder: p, context: y, spec: u });
|
|
713
726
|
} catch (R) {
|
|
714
727
|
console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`, R);
|
|
715
728
|
}
|
|
716
729
|
else
|
|
717
730
|
h.dispatchEvent(
|
|
718
|
-
new CustomEvent("mount-external-editor", { detail: { placeholder:
|
|
731
|
+
new CustomEvent("mount-external-editor", { detail: { placeholder: p, spec: u, context: y } })
|
|
719
732
|
);
|
|
720
733
|
}
|
|
721
734
|
}
|
|
722
735
|
/**
|
|
723
736
|
* Render a template-based editor.
|
|
724
737
|
*/
|
|
725
|
-
#h(e, t, i, s, n, o, r,
|
|
738
|
+
#h(e, t, i, s, n, o, r, a) {
|
|
726
739
|
const f = t.__editorTemplate;
|
|
727
740
|
if (!f) return;
|
|
728
|
-
const d = f.cloneNode(!0),
|
|
729
|
-
|
|
741
|
+
const d = f.cloneNode(!0), b = t.__compiledEditor;
|
|
742
|
+
b ? d.innerHTML = b({
|
|
730
743
|
row: i,
|
|
731
744
|
value: s,
|
|
732
745
|
field: t.field,
|
|
@@ -734,24 +747,24 @@ class O extends S {
|
|
|
734
747
|
commit: n,
|
|
735
748
|
cancel: o
|
|
736
749
|
}) : d.querySelectorAll("*").forEach((g) => {
|
|
737
|
-
g.childNodes.length === 1 && g.firstChild?.nodeType === Node.TEXT_NODE && (g.textContent = g.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (
|
|
738
|
-
if (!
|
|
750
|
+
g.childNodes.length === 1 && g.firstChild?.nodeType === Node.TEXT_NODE && (g.textContent = g.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (E, u) => {
|
|
751
|
+
if (!w(u)) return "";
|
|
739
752
|
const m = i[u];
|
|
740
753
|
return m == null ? "" : String(m);
|
|
741
754
|
}) || "");
|
|
742
755
|
});
|
|
743
|
-
const
|
|
756
|
+
const c = d.querySelector(
|
|
744
757
|
"input,textarea,select"
|
|
745
758
|
);
|
|
746
|
-
if (
|
|
747
|
-
|
|
759
|
+
if (c) {
|
|
760
|
+
c instanceof HTMLInputElement && c.type === "checkbox" ? c.checked = !!s : c.value = String(s ?? "");
|
|
748
761
|
let g = !1;
|
|
749
|
-
|
|
750
|
-
g || n(
|
|
751
|
-
}),
|
|
752
|
-
const u =
|
|
753
|
-
u.key === "Enter" && (u.stopPropagation(), u.preventDefault(), g = !0, n(
|
|
754
|
-
}),
|
|
762
|
+
c.addEventListener("blur", () => {
|
|
763
|
+
g || n(v(c, t));
|
|
764
|
+
}), c.addEventListener("keydown", (E) => {
|
|
765
|
+
const u = E;
|
|
766
|
+
u.key === "Enter" && (u.stopPropagation(), u.preventDefault(), g = !0, n(v(c, t)), this.#i(a, !1)), u.key === "Escape" && (u.stopPropagation(), u.preventDefault(), o(), this.#i(a, !0));
|
|
767
|
+
}), c instanceof HTMLInputElement && c.type === "checkbox" && c.addEventListener("change", () => n(c.checked)), r || setTimeout(() => c.focus({ preventScroll: !0 }), 0);
|
|
755
768
|
}
|
|
756
769
|
e.appendChild(d);
|
|
757
770
|
}
|
|
@@ -776,10 +789,10 @@ class O extends S {
|
|
|
776
789
|
// #endregion
|
|
777
790
|
}
|
|
778
791
|
export {
|
|
779
|
-
|
|
792
|
+
N as EditingPlugin,
|
|
780
793
|
C as FOCUSABLE_EDITOR_SELECTOR,
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
794
|
+
q as clearEditingState,
|
|
795
|
+
k as defaultEditorFor,
|
|
796
|
+
O as hasEditingCells
|
|
784
797
|
};
|
|
785
798
|
//# sourceMappingURL=index.js.map
|