@toolbox-web/grid 1.2.0 → 1.3.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/README.md +80 -22
- package/all.js +619 -571
- package/all.js.map +1 -1
- package/index.js +362 -302
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +64 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts +37 -0
- package/lib/core/internal/row-animation.d.ts.map +1 -0
- package/lib/core/types.d.ts +17 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +82 -76
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +1 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +43 -41
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +24 -22
- 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 +83 -52
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +22 -20
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +160 -125
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +20 -18
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +66 -64
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +51 -49
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +17 -15
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +24 -22
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +25 -23
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +49 -47
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +24 -22
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +19 -17
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +38 -36
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +13 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +1 -1
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +118 -85
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +50 -6
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +34 -32
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +25 -23
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +22 -20
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +21 -19
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +21 -4
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +19 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +9 -9
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.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/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditingPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/editing/EditingPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"EditingPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/editing/EditingPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACtG,OAAO,KAAK,EACV,YAAY,EAIZ,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EAA4C,aAAa,EAAkC,MAAM,SAAS,CAAC;AAMvH;;GAEG;AACH,eAAO,MAAM,yBAAyB,8GACiE,CAAC;AAwDxG;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAElE;AAWD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAGjE;AA4DD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,qBAAa,aAAa,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,cAAc,CAAC,aAAa,CAAC;;IAC3E;;;OAGG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAmB/C;IAEF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,aAAa;IAC1B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,CAI7D;IA0BD,gBAAgB;IACP,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IA2DxC,gBAAgB;IACP,MAAM,IAAI,IAAI;IAavB;;;;;OAKG;IACM,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IA2B3D;;;OAGG;IACM,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI;IA0GxD;;;;OAIG;IACM,cAAc,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE;IAsCtE;;;;;OAKG;IACM,WAAW,IAAI,IAAI;IAgC5B;;;OAGG;IACM,cAAc,IAAI,IAAI;IAQ/B;;;OAGG;IACH,IAAI,WAAW,IAAI,CAAC,EAAE,CAOrB;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,EAAE,CAE5B;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAIvC;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI1D;;;OAGG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAYvC;;;OAGG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIxC;;;;OAIG;IACH,gBAAgB,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAexC;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAepD;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IA2CrC;;;OAGG;IACH,mBAAmB,IAAI,IAAI;IAM3B;;OAEG;IACH,mBAAmB,IAAI,IAAI;CAqd5B"}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
|
-
const
|
|
1
|
+
const R = "data-animating", A = {
|
|
2
|
+
change: "--tbw-row-change-duration",
|
|
3
|
+
insert: "--tbw-row-insert-duration",
|
|
4
|
+
remove: "--tbw-row-remove-duration"
|
|
5
|
+
}, T = {
|
|
6
|
+
change: 500,
|
|
7
|
+
insert: 300,
|
|
8
|
+
remove: 200
|
|
9
|
+
};
|
|
10
|
+
function P(s) {
|
|
11
|
+
const e = s.trim().toLowerCase();
|
|
12
|
+
return e.endsWith("ms") ? parseFloat(e) : e.endsWith("s") ? parseFloat(e) * 1e3 : parseFloat(e);
|
|
13
|
+
}
|
|
14
|
+
function I(s, e) {
|
|
15
|
+
const i = A[e], t = getComputedStyle(s).getPropertyValue(i);
|
|
16
|
+
if (t) {
|
|
17
|
+
const r = P(t);
|
|
18
|
+
if (!isNaN(r) && r > 0)
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
21
|
+
return T[e];
|
|
22
|
+
}
|
|
23
|
+
function D(s, e, i) {
|
|
24
|
+
s.removeAttribute(R), s.offsetWidth, s.setAttribute(R, e);
|
|
25
|
+
const t = I(s, e);
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
s.removeAttribute(R);
|
|
28
|
+
}, t);
|
|
29
|
+
}
|
|
30
|
+
const L = '<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 = {
|
|
2
31
|
expand: "▶",
|
|
3
32
|
collapse: "▼",
|
|
4
33
|
sortAsc: "▲",
|
|
@@ -6,9 +35,11 @@ const L = {
|
|
|
6
35
|
sortNone: "⇅",
|
|
7
36
|
submenuArrow: "▶",
|
|
8
37
|
dragHandle: "⋮⋮",
|
|
9
|
-
toolPanel: "☰"
|
|
38
|
+
toolPanel: "☰",
|
|
39
|
+
filter: L,
|
|
40
|
+
filterActive: L
|
|
10
41
|
};
|
|
11
|
-
class
|
|
42
|
+
class q {
|
|
12
43
|
/**
|
|
13
44
|
* Plugin dependencies - declare other plugins this one requires.
|
|
14
45
|
*
|
|
@@ -232,7 +263,7 @@ class k {
|
|
|
232
263
|
*/
|
|
233
264
|
get gridIcons() {
|
|
234
265
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
235
|
-
return { ...
|
|
266
|
+
return { ...O, ...e };
|
|
236
267
|
}
|
|
237
268
|
// #region Animation Helpers
|
|
238
269
|
/**
|
|
@@ -308,12 +339,12 @@ class k {
|
|
|
308
339
|
}
|
|
309
340
|
// #endregion
|
|
310
341
|
}
|
|
311
|
-
const
|
|
312
|
-
function
|
|
342
|
+
const N = "@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}}";
|
|
343
|
+
function M(s) {
|
|
313
344
|
const e = s.options;
|
|
314
345
|
return e ? typeof e == "function" ? e() : e : [];
|
|
315
346
|
}
|
|
316
|
-
function
|
|
347
|
+
function H(s) {
|
|
317
348
|
return (e) => {
|
|
318
349
|
const i = s.editorParams, t = document.createElement("input");
|
|
319
350
|
t.type = "number", t.value = e.value != null ? String(e.value) : "", i?.min !== void 0 && (t.min = String(i.min)), i?.max !== void 0 && (t.max = String(i.max)), i?.step !== void 0 && (t.step = String(i.step)), i?.placeholder && (t.placeholder = i.placeholder);
|
|
@@ -323,13 +354,13 @@ function T(s) {
|
|
|
323
354
|
}), t;
|
|
324
355
|
};
|
|
325
356
|
}
|
|
326
|
-
function
|
|
357
|
+
function x() {
|
|
327
358
|
return (s) => {
|
|
328
359
|
const e = document.createElement("input");
|
|
329
360
|
return e.type = "checkbox", e.checked = !!s.value, e.addEventListener("change", () => s.commit(e.checked)), e;
|
|
330
361
|
};
|
|
331
362
|
}
|
|
332
|
-
function
|
|
363
|
+
function G(s) {
|
|
333
364
|
return (e) => {
|
|
334
365
|
const i = s.editorParams, t = document.createElement("input");
|
|
335
366
|
return t.type = "date", e.value instanceof Date && (t.valueAsDate = e.value), i?.min && (t.min = i.min), i?.max && (t.max = i.max), i?.placeholder && (t.placeholder = i.placeholder), t.addEventListener("change", () => e.commit(t.valueAsDate)), t.addEventListener("keydown", (r) => {
|
|
@@ -337,14 +368,14 @@ function q(s) {
|
|
|
337
368
|
}), t;
|
|
338
369
|
};
|
|
339
370
|
}
|
|
340
|
-
function
|
|
371
|
+
function $(s) {
|
|
341
372
|
return (e) => {
|
|
342
373
|
const i = s.editorParams, t = document.createElement("select");
|
|
343
374
|
if (s.multi && (t.multiple = !0), i?.includeEmpty) {
|
|
344
375
|
const o = document.createElement("option");
|
|
345
376
|
o.value = "", o.textContent = i.emptyLabel ?? "", t.appendChild(o);
|
|
346
377
|
}
|
|
347
|
-
|
|
378
|
+
M(s).forEach((o) => {
|
|
348
379
|
const a = document.createElement("option");
|
|
349
380
|
a.value = String(o.value), a.textContent = o.label, (s.multi && Array.isArray(e.value) && e.value.includes(o.value) || !s.multi && e.value === o.value) && (a.selected = !0), t.appendChild(a);
|
|
350
381
|
});
|
|
@@ -360,7 +391,7 @@ function D(s) {
|
|
|
360
391
|
}), t;
|
|
361
392
|
};
|
|
362
393
|
}
|
|
363
|
-
function
|
|
394
|
+
function F(s) {
|
|
364
395
|
return (e) => {
|
|
365
396
|
const i = s.editorParams, t = document.createElement("input");
|
|
366
397
|
return t.type = "text", t.value = e.value != null ? String(e.value) : "", i?.maxLength !== void 0 && (t.maxLength = i.maxLength), i?.pattern && (t.pattern = i.pattern), i?.placeholder && (t.placeholder = i.placeholder), t.addEventListener("blur", () => e.commit(t.value)), t.addEventListener("keydown", (r) => {
|
|
@@ -368,22 +399,22 @@ function O(s) {
|
|
|
368
399
|
}), t;
|
|
369
400
|
};
|
|
370
401
|
}
|
|
371
|
-
function
|
|
402
|
+
function z(s) {
|
|
372
403
|
switch (s.type) {
|
|
373
404
|
case "number":
|
|
374
|
-
return
|
|
405
|
+
return H(s);
|
|
375
406
|
case "boolean":
|
|
376
|
-
return
|
|
407
|
+
return x();
|
|
377
408
|
case "date":
|
|
378
|
-
return
|
|
409
|
+
return G(s);
|
|
379
410
|
case "select":
|
|
380
|
-
return
|
|
411
|
+
return $(s);
|
|
381
412
|
default:
|
|
382
|
-
return
|
|
413
|
+
return F(s);
|
|
383
414
|
}
|
|
384
415
|
}
|
|
385
|
-
const
|
|
386
|
-
function
|
|
416
|
+
const _ = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
|
|
417
|
+
function B(s, e) {
|
|
387
418
|
if (e.editor) return e.editor;
|
|
388
419
|
if (e.__editorTemplate) return "template";
|
|
389
420
|
if (!e.type) return;
|
|
@@ -397,28 +428,28 @@ function H(s, e) {
|
|
|
397
428
|
return n.editor;
|
|
398
429
|
}
|
|
399
430
|
}
|
|
400
|
-
function
|
|
431
|
+
function v(s) {
|
|
401
432
|
return !(typeof s != "string" || s === "__proto__" || s === "constructor" || s === "prototype");
|
|
402
433
|
}
|
|
403
|
-
function
|
|
434
|
+
function U(s) {
|
|
404
435
|
const e = (s.__editingCellCount ?? 0) + 1;
|
|
405
436
|
s.__editingCellCount = e, s.setAttribute("data-has-editing", "");
|
|
406
437
|
}
|
|
407
|
-
function
|
|
438
|
+
function j(s) {
|
|
408
439
|
s.__editingCellCount = 0, s.removeAttribute("data-has-editing");
|
|
409
440
|
}
|
|
410
|
-
function
|
|
441
|
+
function E(s, e) {
|
|
411
442
|
return s instanceof HTMLInputElement ? s.type === "checkbox" ? s.checked : s.type === "number" ? s.value === "" ? null : Number(s.value) : s.type === "date" ? s.valueAsDate : s.value : e?.type === "number" && s.value !== "" ? Number(s.value) : s.value;
|
|
412
443
|
}
|
|
413
|
-
function
|
|
444
|
+
function k(s) {
|
|
414
445
|
}
|
|
415
|
-
function
|
|
446
|
+
function V(s, e, i) {
|
|
416
447
|
const t = s.querySelector("input,textarea,select");
|
|
417
448
|
t && (t.addEventListener("blur", () => {
|
|
418
|
-
i(
|
|
419
|
-
}), t instanceof HTMLInputElement && t.type === "checkbox" ? t.addEventListener("change", () => i(t.checked)) : t instanceof HTMLSelectElement && t.addEventListener("change", () => i(
|
|
449
|
+
i(E(t, e));
|
|
450
|
+
}), t instanceof HTMLInputElement && t.type === "checkbox" ? t.addEventListener("change", () => i(t.checked)) : t instanceof HTMLSelectElement && t.addEventListener("change", () => i(E(t, e))));
|
|
420
451
|
}
|
|
421
|
-
class
|
|
452
|
+
class W extends q {
|
|
422
453
|
/**
|
|
423
454
|
* Plugin manifest - declares owned properties for configuration validation.
|
|
424
455
|
* @internal
|
|
@@ -446,7 +477,7 @@ class $ extends k {
|
|
|
446
477
|
/** @internal */
|
|
447
478
|
name = "editing";
|
|
448
479
|
/** @internal */
|
|
449
|
-
styles =
|
|
480
|
+
styles = N;
|
|
450
481
|
/** @internal */
|
|
451
482
|
get defaultConfig() {
|
|
452
483
|
return {
|
|
@@ -530,7 +561,7 @@ class $ extends k {
|
|
|
530
561
|
const n = i._visibleColumns[r], o = i._rows[t];
|
|
531
562
|
if (n?.editable && n.type === "boolean" && o) {
|
|
532
563
|
const a = n.field;
|
|
533
|
-
if (
|
|
564
|
+
if (v(a)) {
|
|
534
565
|
const c = !o[a];
|
|
535
566
|
return this.#l(t, n, c, o), e.preventDefault(), this.requestRender(), !0;
|
|
536
567
|
}
|
|
@@ -725,7 +756,7 @@ class $ extends k {
|
|
|
725
756
|
}), setTimeout(() => {
|
|
726
757
|
let a = n.querySelector(`.cell[data-col="${i._focusCol}"]`);
|
|
727
758
|
if (a?.classList.contains("editing") || (a = n.querySelector(".cell.editing")), a?.classList.contains("editing")) {
|
|
728
|
-
const l = a.querySelector(
|
|
759
|
+
const l = a.querySelector(_);
|
|
729
760
|
try {
|
|
730
761
|
l?.focus({ preventScroll: !0 });
|
|
731
762
|
} catch {
|
|
@@ -787,7 +818,7 @@ class $ extends k {
|
|
|
787
818
|
if (!g) return;
|
|
788
819
|
const d = c.querySelector("input,textarea,select");
|
|
789
820
|
if (d) {
|
|
790
|
-
const h =
|
|
821
|
+
const h = E(d, g);
|
|
791
822
|
n[g.field] !== h && this.#l(e, g, h, n);
|
|
792
823
|
}
|
|
793
824
|
}), i && r && n)
|
|
@@ -803,13 +834,13 @@ class $ extends k {
|
|
|
803
834
|
changed: l,
|
|
804
835
|
changedRows: this.changedRows,
|
|
805
836
|
changedRowIds: this.changedRowIds
|
|
806
|
-
});
|
|
837
|
+
}), l && this.isAnimationEnabled && t.animateRow?.(e, "change");
|
|
807
838
|
}
|
|
808
839
|
this.#r.delete(e), this.#e = -1, this.#s = -1, this.#a();
|
|
809
840
|
for (const l of this.#n)
|
|
810
841
|
l.startsWith(`${e}:`) && this.#n.delete(l);
|
|
811
842
|
o && (o.querySelectorAll(".cell.editing").forEach((l) => {
|
|
812
|
-
l.classList.remove("editing"),
|
|
843
|
+
l.classList.remove("editing"), j(l.parentElement);
|
|
813
844
|
}), this.requestRender()), this.#o = !0, o || (this.#u(t), this.#o = !1);
|
|
814
845
|
}
|
|
815
846
|
/**
|
|
@@ -818,7 +849,7 @@ class $ extends k {
|
|
|
818
849
|
*/
|
|
819
850
|
#l(e, i, t, r) {
|
|
820
851
|
const n = i.field;
|
|
821
|
-
if (!
|
|
852
|
+
if (!v(n)) return;
|
|
822
853
|
const o = r[n];
|
|
823
854
|
if (o === t) return;
|
|
824
855
|
const a = this.grid;
|
|
@@ -827,7 +858,7 @@ class $ extends k {
|
|
|
827
858
|
l = this.grid.getRowId(r);
|
|
828
859
|
} catch {
|
|
829
860
|
}
|
|
830
|
-
const c = l ? !this.#t.has(l) : !0, f = l ? (h) => this.grid.updateRow(l, h, "cascade") :
|
|
861
|
+
const c = l ? !this.#t.has(l) : !0, f = l ? (h) => this.grid.updateRow(l, h, "cascade") : k;
|
|
831
862
|
if (this.emitCancelable("cell-commit", {
|
|
832
863
|
row: r,
|
|
833
864
|
rowId: l ?? "",
|
|
@@ -842,7 +873,7 @@ class $ extends k {
|
|
|
842
873
|
})) return;
|
|
843
874
|
r[n] = t, l && this.#t.add(l), this.#a();
|
|
844
875
|
const d = a.findRenderedRowElement?.(e);
|
|
845
|
-
d && d.classList.add("changed");
|
|
876
|
+
d && (d.classList.add("changed"), D(d, "change"));
|
|
846
877
|
}
|
|
847
878
|
/**
|
|
848
879
|
* Inject an editor into a cell.
|
|
@@ -854,26 +885,26 @@ class $ extends k {
|
|
|
854
885
|
a = this.grid.getRowId(e);
|
|
855
886
|
} catch {
|
|
856
887
|
}
|
|
857
|
-
const l = a ? (u) => this.grid.updateRow(a, u, "cascade") :
|
|
888
|
+
const l = a ? (u) => this.grid.updateRow(a, u, "cascade") : k, c = v(t.field) ? e[t.field] : void 0;
|
|
858
889
|
n.classList.add("editing"), this.#n.add(`${i}:${r}`);
|
|
859
890
|
const f = n.parentElement;
|
|
860
|
-
f &&
|
|
891
|
+
f && U(f);
|
|
861
892
|
let g = !1;
|
|
862
893
|
const d = (u) => {
|
|
863
894
|
g || this.#e === -1 || this.#l(i, t, u, e);
|
|
864
895
|
}, h = () => {
|
|
865
|
-
g = !0,
|
|
896
|
+
g = !0, v(t.field) && (e[t.field] = c);
|
|
866
897
|
}, p = document.createElement("div");
|
|
867
898
|
p.className = "tbw-editor-host", n.innerHTML = "", n.appendChild(p), p.addEventListener("keydown", (u) => {
|
|
868
899
|
u.key === "Enter" && (u.stopPropagation(), u.preventDefault(), g = !0, this.#i(i, !1)), u.key === "Escape" && (u.stopPropagation(), u.preventDefault(), h(), this.#i(i, !0));
|
|
869
900
|
});
|
|
870
|
-
const m = t, y = m.__editorTemplate, b =
|
|
901
|
+
const m = t, y = m.__editorTemplate, b = B(this.grid, m) ?? z(t), C = c;
|
|
871
902
|
if (b === "template" && y)
|
|
872
903
|
this.#h(p, m, e, c, d, h, o, i);
|
|
873
904
|
else if (typeof b == "string") {
|
|
874
905
|
const u = document.createElement(b);
|
|
875
906
|
u.value = C, u.addEventListener("change", () => d(u.value)), p.appendChild(u), o || queueMicrotask(() => {
|
|
876
|
-
p.querySelector(
|
|
907
|
+
p.querySelector(_)?.focus({ preventScroll: !0 });
|
|
877
908
|
});
|
|
878
909
|
} else if (typeof b == "function") {
|
|
879
910
|
const u = {
|
|
@@ -886,8 +917,8 @@ class $ extends k {
|
|
|
886
917
|
cancel: h,
|
|
887
918
|
updateRow: l
|
|
888
919
|
}, w = b(u);
|
|
889
|
-
typeof w == "string" ? (p.innerHTML = w,
|
|
890
|
-
p.querySelector(
|
|
920
|
+
typeof w == "string" ? (p.innerHTML = w, V(p, t, d)) : w instanceof Node && p.appendChild(w), o || queueMicrotask(() => {
|
|
921
|
+
p.querySelector(_)?.focus({ preventScroll: !0 });
|
|
891
922
|
});
|
|
892
923
|
} else if (b && typeof b == "object") {
|
|
893
924
|
const u = document.createElement("div");
|
|
@@ -905,8 +936,8 @@ class $ extends k {
|
|
|
905
936
|
if (b.mount)
|
|
906
937
|
try {
|
|
907
938
|
b.mount({ placeholder: u, context: w, spec: b });
|
|
908
|
-
} catch (
|
|
909
|
-
console.warn(`[tbw-grid] External editor mount error for column '${t.field}':`,
|
|
939
|
+
} catch (S) {
|
|
940
|
+
console.warn(`[tbw-grid] External editor mount error for column '${t.field}':`, S);
|
|
910
941
|
}
|
|
911
942
|
else
|
|
912
943
|
this.grid.dispatchEvent(
|
|
@@ -930,7 +961,7 @@ class $ extends k {
|
|
|
930
961
|
cancel: o
|
|
931
962
|
}) : f.querySelectorAll("*").forEach((h) => {
|
|
932
963
|
h.childNodes.length === 1 && h.firstChild?.nodeType === Node.TEXT_NODE && (h.textContent = h.textContent?.replace(/{{\s*value\s*}}/g, r == null ? "" : String(r)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (p, m) => {
|
|
933
|
-
if (!
|
|
964
|
+
if (!v(m)) return "";
|
|
934
965
|
const y = t[m];
|
|
935
966
|
return y == null ? "" : String(y);
|
|
936
967
|
}) || "");
|
|
@@ -942,10 +973,10 @@ class $ extends k {
|
|
|
942
973
|
d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked = !!r : d.value = String(r ?? "");
|
|
943
974
|
let h = !1;
|
|
944
975
|
d.addEventListener("blur", () => {
|
|
945
|
-
h || n(
|
|
976
|
+
h || n(E(d, i));
|
|
946
977
|
}), d.addEventListener("keydown", (p) => {
|
|
947
978
|
const m = p;
|
|
948
|
-
m.key === "Enter" && (m.stopPropagation(), m.preventDefault(), h = !0, n(
|
|
979
|
+
m.key === "Enter" && (m.stopPropagation(), m.preventDefault(), h = !0, n(E(d, i)), this.#i(l, !1)), m.key === "Escape" && (m.stopPropagation(), m.preventDefault(), o(), this.#i(l, !0));
|
|
949
980
|
}), d instanceof HTMLInputElement && d.type === "checkbox" && d.addEventListener("change", () => n(d.checked)), a || setTimeout(() => d.focus({ preventScroll: !0 }), 0);
|
|
950
981
|
}
|
|
951
982
|
e.appendChild(f);
|
|
@@ -971,7 +1002,7 @@ class $ extends k {
|
|
|
971
1002
|
// #endregion
|
|
972
1003
|
}
|
|
973
1004
|
export {
|
|
974
|
-
|
|
975
|
-
|
|
1005
|
+
W as EditingPlugin,
|
|
1006
|
+
z as defaultEditorFor
|
|
976
1007
|
};
|
|
977
1008
|
//# sourceMappingURL=index.js.map
|