@toolbox-web/grid 1.3.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.
Files changed (57) hide show
  1. package/all.js +469 -444
  2. package/all.js.map +1 -1
  3. package/index.js +242 -240
  4. package/index.js.map +1 -1
  5. package/lib/core/types.d.ts +4 -0
  6. package/lib/core/types.d.ts.map +1 -1
  7. package/lib/plugins/clipboard/index.js +18 -16
  8. package/lib/plugins/clipboard/index.js.map +1 -1
  9. package/lib/plugins/column-virtualization/index.js +43 -41
  10. package/lib/plugins/column-virtualization/index.js.map +1 -1
  11. package/lib/plugins/context-menu/index.js +24 -22
  12. package/lib/plugins/context-menu/index.js.map +1 -1
  13. package/lib/plugins/editing/index.js +48 -46
  14. package/lib/plugins/editing/index.js.map +1 -1
  15. package/lib/plugins/export/index.js +22 -20
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
  18. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  19. package/lib/plugins/filtering/index.js +160 -125
  20. package/lib/plugins/filtering/index.js.map +1 -1
  21. package/lib/plugins/grouping-columns/index.js +20 -18
  22. package/lib/plugins/grouping-columns/index.js.map +1 -1
  23. package/lib/plugins/grouping-rows/index.js +66 -64
  24. package/lib/plugins/grouping-rows/index.js.map +1 -1
  25. package/lib/plugins/master-detail/index.js +51 -49
  26. package/lib/plugins/master-detail/index.js.map +1 -1
  27. package/lib/plugins/multi-sort/index.js +17 -15
  28. package/lib/plugins/multi-sort/index.js.map +1 -1
  29. package/lib/plugins/pinned-columns/index.js +24 -22
  30. package/lib/plugins/pinned-columns/index.js.map +1 -1
  31. package/lib/plugins/pinned-rows/index.js +25 -23
  32. package/lib/plugins/pinned-rows/index.js.map +1 -1
  33. package/lib/plugins/pivot/index.js +49 -47
  34. package/lib/plugins/pivot/index.js.map +1 -1
  35. package/lib/plugins/reorder/index.js +24 -22
  36. package/lib/plugins/reorder/index.js.map +1 -1
  37. package/lib/plugins/responsive/index.js +19 -17
  38. package/lib/plugins/responsive/index.js.map +1 -1
  39. package/lib/plugins/row-reorder/index.js +38 -36
  40. package/lib/plugins/row-reorder/index.js.map +1 -1
  41. package/lib/plugins/selection/index.js +41 -39
  42. package/lib/plugins/selection/index.js.map +1 -1
  43. package/lib/plugins/server-side/index.js +34 -32
  44. package/lib/plugins/server-side/index.js.map +1 -1
  45. package/lib/plugins/tree/index.js +25 -23
  46. package/lib/plugins/tree/index.js.map +1 -1
  47. package/lib/plugins/undo-redo/index.js +22 -20
  48. package/lib/plugins/undo-redo/index.js.map +1 -1
  49. package/lib/plugins/visibility/index.js +21 -19
  50. package/lib/plugins/visibility/index.js.map +1 -1
  51. package/package.json +1 -1
  52. package/umd/grid.all.umd.js +19 -19
  53. package/umd/grid.all.umd.js.map +1 -1
  54. package/umd/grid.umd.js +9 -9
  55. package/umd/grid.umd.js.map +1 -1
  56. package/umd/plugins/filtering.umd.js +1 -1
  57. package/umd/plugins/filtering.umd.js.map +1 -1
@@ -1,8 +1,8 @@
1
- const R = "data-animating", k = {
1
+ const R = "data-animating", A = {
2
2
  change: "--tbw-row-change-duration",
3
3
  insert: "--tbw-row-insert-duration",
4
4
  remove: "--tbw-row-remove-duration"
5
- }, A = {
5
+ }, T = {
6
6
  change: 500,
7
7
  insert: 300,
8
8
  remove: 200
@@ -11,23 +11,23 @@ function P(s) {
11
11
  const e = s.trim().toLowerCase();
12
12
  return e.endsWith("ms") ? parseFloat(e) : e.endsWith("s") ? parseFloat(e) * 1e3 : parseFloat(e);
13
13
  }
14
- function T(s, e) {
15
- const i = k[e], t = getComputedStyle(s).getPropertyValue(i);
14
+ function I(s, e) {
15
+ const i = A[e], t = getComputedStyle(s).getPropertyValue(i);
16
16
  if (t) {
17
17
  const r = P(t);
18
18
  if (!isNaN(r) && r > 0)
19
19
  return r;
20
20
  }
21
- return A[e];
21
+ return T[e];
22
22
  }
23
- function I(s, e, i) {
23
+ function D(s, e, i) {
24
24
  s.removeAttribute(R), s.offsetWidth, s.setAttribute(R, e);
25
- const t = T(s, e);
25
+ const t = I(s, e);
26
26
  setTimeout(() => {
27
27
  s.removeAttribute(R);
28
28
  }, t);
29
29
  }
30
- const D = {
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 = {
31
31
  expand: "▶",
32
32
  collapse: "▼",
33
33
  sortAsc: "▲",
@@ -35,7 +35,9 @@ const D = {
35
35
  sortNone: "⇅",
36
36
  submenuArrow: "▶",
37
37
  dragHandle: "⋮⋮",
38
- toolPanel: "☰"
38
+ toolPanel: "☰",
39
+ filter: L,
40
+ filterActive: L
39
41
  };
40
42
  class q {
41
43
  /**
@@ -261,7 +263,7 @@ class q {
261
263
  */
262
264
  get gridIcons() {
263
265
  const e = this.grid?.gridConfig?.icons ?? {};
264
- return { ...D, ...e };
266
+ return { ...O, ...e };
265
267
  }
266
268
  // #region Animation Helpers
267
269
  /**
@@ -337,8 +339,8 @@ class q {
337
339
  }
338
340
  // #endregion
339
341
  }
340
- const O = "@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}}";
341
- function N(s) {
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) {
342
344
  const e = s.options;
343
345
  return e ? typeof e == "function" ? e() : e : [];
344
346
  }
@@ -352,7 +354,7 @@ function H(s) {
352
354
  }), t;
353
355
  };
354
356
  }
355
- function M() {
357
+ function x() {
356
358
  return (s) => {
357
359
  const e = document.createElement("input");
358
360
  return e.type = "checkbox", e.checked = !!s.value, e.addEventListener("change", () => s.commit(e.checked)), e;
@@ -366,14 +368,14 @@ function G(s) {
366
368
  }), t;
367
369
  };
368
370
  }
369
- function x(s) {
371
+ function $(s) {
370
372
  return (e) => {
371
373
  const i = s.editorParams, t = document.createElement("select");
372
374
  if (s.multi && (t.multiple = !0), i?.includeEmpty) {
373
375
  const o = document.createElement("option");
374
376
  o.value = "", o.textContent = i.emptyLabel ?? "", t.appendChild(o);
375
377
  }
376
- N(s).forEach((o) => {
378
+ M(s).forEach((o) => {
377
379
  const a = document.createElement("option");
378
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);
379
381
  });
@@ -389,7 +391,7 @@ function x(s) {
389
391
  }), t;
390
392
  };
391
393
  }
392
- function $(s) {
394
+ function F(s) {
393
395
  return (e) => {
394
396
  const i = s.editorParams, t = document.createElement("input");
395
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) => {
@@ -397,18 +399,18 @@ function $(s) {
397
399
  }), t;
398
400
  };
399
401
  }
400
- function F(s) {
402
+ function z(s) {
401
403
  switch (s.type) {
402
404
  case "number":
403
405
  return H(s);
404
406
  case "boolean":
405
- return M();
407
+ return x();
406
408
  case "date":
407
409
  return G(s);
408
410
  case "select":
409
- return x(s);
410
- default:
411
411
  return $(s);
412
+ default:
413
+ return F(s);
412
414
  }
413
415
  }
414
416
  const _ = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
@@ -426,28 +428,28 @@ function B(s, e) {
426
428
  return n.editor;
427
429
  }
428
430
  }
429
- function E(s) {
431
+ function v(s) {
430
432
  return !(typeof s != "string" || s === "__proto__" || s === "constructor" || s === "prototype");
431
433
  }
432
- function z(s) {
434
+ function U(s) {
433
435
  const e = (s.__editingCellCount ?? 0) + 1;
434
436
  s.__editingCellCount = e, s.setAttribute("data-has-editing", "");
435
437
  }
436
- function U(s) {
438
+ function j(s) {
437
439
  s.__editingCellCount = 0, s.removeAttribute("data-has-editing");
438
440
  }
439
- function v(s, e) {
441
+ function E(s, e) {
440
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;
441
443
  }
442
- function L(s) {
444
+ function k(s) {
443
445
  }
444
- function j(s, e, i) {
446
+ function V(s, e, i) {
445
447
  const t = s.querySelector("input,textarea,select");
446
448
  t && (t.addEventListener("blur", () => {
447
- i(v(t, e));
448
- }), t instanceof HTMLInputElement && t.type === "checkbox" ? t.addEventListener("change", () => i(t.checked)) : t instanceof HTMLSelectElement && t.addEventListener("change", () => i(v(t, e))));
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))));
449
451
  }
450
- class V extends q {
452
+ class W extends q {
451
453
  /**
452
454
  * Plugin manifest - declares owned properties for configuration validation.
453
455
  * @internal
@@ -475,7 +477,7 @@ class V extends q {
475
477
  /** @internal */
476
478
  name = "editing";
477
479
  /** @internal */
478
- styles = O;
480
+ styles = N;
479
481
  /** @internal */
480
482
  get defaultConfig() {
481
483
  return {
@@ -559,7 +561,7 @@ class V extends q {
559
561
  const n = i._visibleColumns[r], o = i._rows[t];
560
562
  if (n?.editable && n.type === "boolean" && o) {
561
563
  const a = n.field;
562
- if (E(a)) {
564
+ if (v(a)) {
563
565
  const c = !o[a];
564
566
  return this.#l(t, n, c, o), e.preventDefault(), this.requestRender(), !0;
565
567
  }
@@ -816,7 +818,7 @@ class V extends q {
816
818
  if (!g) return;
817
819
  const d = c.querySelector("input,textarea,select");
818
820
  if (d) {
819
- const h = v(d, g);
821
+ const h = E(d, g);
820
822
  n[g.field] !== h && this.#l(e, g, h, n);
821
823
  }
822
824
  }), i && r && n)
@@ -838,7 +840,7 @@ class V extends q {
838
840
  for (const l of this.#n)
839
841
  l.startsWith(`${e}:`) && this.#n.delete(l);
840
842
  o && (o.querySelectorAll(".cell.editing").forEach((l) => {
841
- l.classList.remove("editing"), U(l.parentElement);
843
+ l.classList.remove("editing"), j(l.parentElement);
842
844
  }), this.requestRender()), this.#o = !0, o || (this.#u(t), this.#o = !1);
843
845
  }
844
846
  /**
@@ -847,7 +849,7 @@ class V extends q {
847
849
  */
848
850
  #l(e, i, t, r) {
849
851
  const n = i.field;
850
- if (!E(n)) return;
852
+ if (!v(n)) return;
851
853
  const o = r[n];
852
854
  if (o === t) return;
853
855
  const a = this.grid;
@@ -856,7 +858,7 @@ class V extends q {
856
858
  l = this.grid.getRowId(r);
857
859
  } catch {
858
860
  }
859
- const c = l ? !this.#t.has(l) : !0, f = l ? (h) => this.grid.updateRow(l, h, "cascade") : L;
861
+ const c = l ? !this.#t.has(l) : !0, f = l ? (h) => this.grid.updateRow(l, h, "cascade") : k;
860
862
  if (this.emitCancelable("cell-commit", {
861
863
  row: r,
862
864
  rowId: l ?? "",
@@ -871,7 +873,7 @@ class V extends q {
871
873
  })) return;
872
874
  r[n] = t, l && this.#t.add(l), this.#a();
873
875
  const d = a.findRenderedRowElement?.(e);
874
- d && (d.classList.add("changed"), I(d, "change"));
876
+ d && (d.classList.add("changed"), D(d, "change"));
875
877
  }
876
878
  /**
877
879
  * Inject an editor into a cell.
@@ -883,20 +885,20 @@ class V extends q {
883
885
  a = this.grid.getRowId(e);
884
886
  } catch {
885
887
  }
886
- const l = a ? (u) => this.grid.updateRow(a, u, "cascade") : L, c = E(t.field) ? e[t.field] : void 0;
888
+ const l = a ? (u) => this.grid.updateRow(a, u, "cascade") : k, c = v(t.field) ? e[t.field] : void 0;
887
889
  n.classList.add("editing"), this.#n.add(`${i}:${r}`);
888
890
  const f = n.parentElement;
889
- f && z(f);
891
+ f && U(f);
890
892
  let g = !1;
891
893
  const d = (u) => {
892
894
  g || this.#e === -1 || this.#l(i, t, u, e);
893
895
  }, h = () => {
894
- g = !0, E(t.field) && (e[t.field] = c);
896
+ g = !0, v(t.field) && (e[t.field] = c);
895
897
  }, p = document.createElement("div");
896
898
  p.className = "tbw-editor-host", n.innerHTML = "", n.appendChild(p), p.addEventListener("keydown", (u) => {
897
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));
898
900
  });
899
- const m = t, y = m.__editorTemplate, b = B(this.grid, m) ?? F(t), C = c;
901
+ const m = t, y = m.__editorTemplate, b = B(this.grid, m) ?? z(t), C = c;
900
902
  if (b === "template" && y)
901
903
  this.#h(p, m, e, c, d, h, o, i);
902
904
  else if (typeof b == "string") {
@@ -915,7 +917,7 @@ class V extends q {
915
917
  cancel: h,
916
918
  updateRow: l
917
919
  }, w = b(u);
918
- typeof w == "string" ? (p.innerHTML = w, j(p, t, d)) : w instanceof Node && p.appendChild(w), o || queueMicrotask(() => {
920
+ typeof w == "string" ? (p.innerHTML = w, V(p, t, d)) : w instanceof Node && p.appendChild(w), o || queueMicrotask(() => {
919
921
  p.querySelector(_)?.focus({ preventScroll: !0 });
920
922
  });
921
923
  } else if (b && typeof b == "object") {
@@ -959,7 +961,7 @@ class V extends q {
959
961
  cancel: o
960
962
  }) : f.querySelectorAll("*").forEach((h) => {
961
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) => {
962
- if (!E(m)) return "";
964
+ if (!v(m)) return "";
963
965
  const y = t[m];
964
966
  return y == null ? "" : String(y);
965
967
  }) || "");
@@ -971,10 +973,10 @@ class V extends q {
971
973
  d instanceof HTMLInputElement && d.type === "checkbox" ? d.checked = !!r : d.value = String(r ?? "");
972
974
  let h = !1;
973
975
  d.addEventListener("blur", () => {
974
- h || n(v(d, i));
976
+ h || n(E(d, i));
975
977
  }), d.addEventListener("keydown", (p) => {
976
978
  const m = p;
977
- m.key === "Enter" && (m.stopPropagation(), m.preventDefault(), h = !0, n(v(d, i)), this.#i(l, !1)), m.key === "Escape" && (m.stopPropagation(), m.preventDefault(), o(), this.#i(l, !0));
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));
978
980
  }), d instanceof HTMLInputElement && d.type === "checkbox" && d.addEventListener("change", () => n(d.checked)), a || setTimeout(() => d.focus({ preventScroll: !0 }), 0);
979
981
  }
980
982
  e.appendChild(f);
@@ -1000,7 +1002,7 @@ class V extends q {
1000
1002
  // #endregion
1001
1003
  }
1002
1004
  export {
1003
- V as EditingPlugin,
1004
- F as defaultEditorFor
1005
+ W as EditingPlugin,
1006
+ z as defaultEditorFor
1005
1007
  };
1006
1008
  //# sourceMappingURL=index.js.map