@toolbox-web/grid 1.8.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +554 -519
- package/all.js.map +1 -1
- package/index.js +333 -311
- package/index.js.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/utils.d.ts +46 -0
- package/lib/core/internal/utils.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +2 -5
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +13 -6
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +92 -65
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +24 -7
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/types.d.ts +51 -2
- package/lib/plugins/pinned-columns/types.d.ts.map +1 -1
- package/lib/plugins/print/index.js +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +245 -102
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +1 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +6 -6
- package/lib/plugins/tree/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +23 -23
- 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/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.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/print.umd.js +1 -1
- package/umd/plugins/print.umd.js.map +1 -1
- package/umd/plugins/responsive.umd.js +1 -1
- package/umd/plugins/responsive.umd.js.map +1 -1
- package/umd/plugins/row-reorder.umd.js +1 -1
- package/umd/plugins/row-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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsivePlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/responsive/ResponsivePlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;
|
|
1
|
+
{"version":3,"file":"ResponsivePlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/responsive/ResponsivePlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAGxH,OAAO,KAAK,EAAE,gBAAgB,EAA8C,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEpH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,gBAAgB,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,cAAc,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;;IAC1F,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,SAAkB,OAAO,WAAW;IACpC,SAAkB,MAAM,SAAU;IAElC;;OAEG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAe/C;IAgBF;;;OAGG;IACH,YAAY,IAAI,OAAO;IAIvB;;;;OAIG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAYrC;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKlC;;;;OAIG;IACH,eAAe,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,IAAI;IAQ1E;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;OAGG;IACH,mBAAmB,IAAI,gBAAgB,GAAG,IAAI;IAIrC,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IA+J/B,MAAM,IAAI,IAAI;IAcvB;;;OAGG;IACM,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAOjD;;;;OAIG;IACM,WAAW,IAAI,IAAI;IAyL5B;;;;;;;;;;OAUG;IACM,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAqCtF;;;;;;;;;;;;;OAaG;IACM,SAAS,CAAC,CAAC,EAAE,aAAa,GAAG,OAAO;IAkK7C;;;;;;;;;;OAUG;IACM,cAAc,IAAI,MAAM;IAyBjC;;;;;OAKG;IACM,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM;CA8H9D"}
|
|
@@ -1,54 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const R = /{{\s*([^}]+)\s*}}/g, u = "__DG_EMPTY__", y = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, _ = /__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/, C = /* @__PURE__ */ new Set([
|
|
2
|
+
"script",
|
|
3
|
+
"iframe",
|
|
4
|
+
"object",
|
|
5
|
+
"embed",
|
|
6
|
+
"form",
|
|
7
|
+
"input",
|
|
8
|
+
"button",
|
|
9
|
+
"textarea",
|
|
10
|
+
"select",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"base",
|
|
14
|
+
"style",
|
|
15
|
+
"template",
|
|
16
|
+
"slot",
|
|
17
|
+
"portal",
|
|
18
|
+
"frame",
|
|
19
|
+
"frameset",
|
|
20
|
+
"applet",
|
|
21
|
+
"noscript",
|
|
22
|
+
"noembed",
|
|
23
|
+
"plaintext",
|
|
24
|
+
"xmp",
|
|
25
|
+
"listing"
|
|
26
|
+
]), m = /^on\w+$/i, E = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), A = /^\s*(javascript|vbscript|data|blob):/i;
|
|
27
|
+
function S(r) {
|
|
28
|
+
if (!r || typeof r != "string") return "";
|
|
29
|
+
if (r.indexOf("<") === -1) return r;
|
|
30
|
+
const t = document.createElement("template");
|
|
31
|
+
return t.innerHTML = r, k(t.content), t.innerHTML;
|
|
3
32
|
}
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (d && h > 0) {
|
|
12
|
-
const c = o._focusRow * r;
|
|
13
|
-
c < d.scrollTop ? d.scrollTop = c : c + r > d.scrollTop + h && (d.scrollTop = c - h + r);
|
|
33
|
+
function k(r) {
|
|
34
|
+
const t = [], e = r.querySelectorAll("*");
|
|
35
|
+
for (const i of e) {
|
|
36
|
+
const n = i.tagName.toLowerCase();
|
|
37
|
+
if (C.has(n)) {
|
|
38
|
+
t.push(i);
|
|
39
|
+
continue;
|
|
14
40
|
}
|
|
41
|
+
if ((n === "svg" || i.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(i.attributes).some(
|
|
42
|
+
(o) => m.test(o.name) || o.name === "href" || o.name === "xlink:href"
|
|
43
|
+
)) {
|
|
44
|
+
t.push(i);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const a = [];
|
|
48
|
+
for (const s of i.attributes) {
|
|
49
|
+
const o = s.name.toLowerCase();
|
|
50
|
+
if (m.test(o)) {
|
|
51
|
+
a.push(s.name);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (E.has(o) && A.test(s.value)) {
|
|
55
|
+
a.push(s.name);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (o === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(s.value)) {
|
|
59
|
+
a.push(s.name);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
a.forEach((s) => i.removeAttribute(s));
|
|
64
|
+
}
|
|
65
|
+
t.forEach((i) => i.remove());
|
|
66
|
+
}
|
|
67
|
+
function H(r, t) {
|
|
68
|
+
if (!r || r.indexOf("{{") === -1) return r;
|
|
69
|
+
const e = [], i = r.replace(R, (o, d) => {
|
|
70
|
+
const l = T(d, t);
|
|
71
|
+
return e.push({ expr: d.trim(), result: l }), l;
|
|
72
|
+
}), n = L(i), a = e.length && e.every((o) => o.result === "" || o.result === u);
|
|
73
|
+
return /Reflect\.|\bProxy\b|ownKeys\(/.test(r) || a ? "" : n;
|
|
74
|
+
}
|
|
75
|
+
function T(r, t) {
|
|
76
|
+
if (r = (r || "").trim(), !r || /\b(Reflect|Proxy|ownKeys)\b/.test(r)) return u;
|
|
77
|
+
if (r === "value") return t.value == null ? u : String(t.value);
|
|
78
|
+
if (r.startsWith("row.") && !/[()?]/.test(r) && !r.includes(":")) {
|
|
79
|
+
const i = r.slice(4), n = t.row ? t.row[i] : void 0;
|
|
80
|
+
return n == null ? u : String(n);
|
|
81
|
+
}
|
|
82
|
+
if (r.length > 80 || !y.test(r) || _.test(r)) return u;
|
|
83
|
+
const e = r.match(/\./g);
|
|
84
|
+
if (e && e.length > 1) return u;
|
|
85
|
+
try {
|
|
86
|
+
const n = new Function("value", "row", `return (${r});`)(t.value, t.row), a = n == null ? "" : String(n);
|
|
87
|
+
return /Reflect|Proxy|ownKeys/.test(a) ? u : a || u;
|
|
88
|
+
} catch {
|
|
89
|
+
return u;
|
|
15
90
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
91
|
+
}
|
|
92
|
+
function L(r) {
|
|
93
|
+
return r && r.replace(new RegExp(u, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
|
|
94
|
+
}
|
|
95
|
+
function x(r) {
|
|
96
|
+
r && r.querySelectorAll(".cell-focus").forEach((t) => t.classList.remove("cell-focus"));
|
|
97
|
+
}
|
|
98
|
+
const M = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', D = document.createElement("template");
|
|
99
|
+
D.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
|
|
100
|
+
const q = document.createElement("template");
|
|
101
|
+
q.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
102
|
+
function g(r, t) {
|
|
103
|
+
if (r._virtualization?.enabled) {
|
|
104
|
+
const { rowHeight: s, container: o, viewportEl: d } = r._virtualization, l = o, h = d?.clientHeight ?? l?.clientHeight ?? 0;
|
|
105
|
+
if (l && h > 0) {
|
|
106
|
+
const c = r._focusRow * s;
|
|
107
|
+
c < l.scrollTop ? l.scrollTop = c : c + s > l.scrollTop + h && (l.scrollTop = c - h + s);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const e = r._activeEditRows !== void 0 && r._activeEditRows !== -1;
|
|
111
|
+
e || r.refreshVirtualWindow(!1), x(r._bodyEl), Array.from(r._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
|
|
112
|
+
s.setAttribute("aria-selected", "false");
|
|
19
113
|
});
|
|
20
|
-
const i =
|
|
114
|
+
const i = r._focusRow, n = r._virtualization.start ?? 0, a = r._virtualization.end ?? r._rows.length;
|
|
21
115
|
if (i >= n && i < a) {
|
|
22
|
-
const
|
|
23
|
-
let
|
|
24
|
-
if ((!
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
30
|
-
const h =
|
|
31
|
-
|
|
116
|
+
const s = r._bodyEl.querySelectorAll(".data-grid-row")[i - n];
|
|
117
|
+
let o = s?.children[r._focusCol];
|
|
118
|
+
if ((!o || !o.classList?.contains("cell")) && (o = s?.querySelector(`.cell[data-col="${r._focusCol}"]`) ?? s?.querySelector(".cell[data-col]")), o) {
|
|
119
|
+
o.classList.add("cell-focus"), o.setAttribute("aria-selected", "true");
|
|
120
|
+
const d = r.querySelector(".tbw-scroll-area");
|
|
121
|
+
if (d && o && !e) {
|
|
122
|
+
const l = r._getHorizontalScrollOffsets?.(s ?? void 0, o) ?? { left: 0, right: 0 };
|
|
123
|
+
if (!l.skipScroll) {
|
|
124
|
+
const h = o.getBoundingClientRect(), c = d.getBoundingClientRect(), f = h.left - c.left + d.scrollLeft, w = f + h.width, p = d.scrollLeft + l.left, b = d.scrollLeft + d.clientWidth - l.right;
|
|
125
|
+
f < p ? d.scrollLeft = f - l.left : w > b && (d.scrollLeft = w - d.clientWidth + l.right);
|
|
32
126
|
}
|
|
33
127
|
}
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
128
|
+
if (r._activeEditRows !== void 0 && r._activeEditRows !== -1 && o.classList.contains("editing")) {
|
|
129
|
+
const l = o.querySelector(M);
|
|
130
|
+
if (l && document.activeElement !== l)
|
|
37
131
|
try {
|
|
38
|
-
|
|
132
|
+
l.focus({ preventScroll: !0 });
|
|
39
133
|
} catch {
|
|
40
134
|
}
|
|
41
|
-
} else if (!
|
|
42
|
-
|
|
135
|
+
} else if (!o.contains(document.activeElement)) {
|
|
136
|
+
o.hasAttribute("tabindex") || o.setAttribute("tabindex", "-1");
|
|
43
137
|
try {
|
|
44
|
-
|
|
138
|
+
o.focus({ preventScroll: !0 });
|
|
45
139
|
} catch {
|
|
46
140
|
}
|
|
47
141
|
}
|
|
48
142
|
}
|
|
49
143
|
}
|
|
50
144
|
}
|
|
51
|
-
const
|
|
145
|
+
const v = '<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>', N = {
|
|
52
146
|
expand: "▶",
|
|
53
147
|
collapse: "▼",
|
|
54
148
|
sortAsc: "▲",
|
|
@@ -57,11 +151,11 @@ const f = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
57
151
|
submenuArrow: "▶",
|
|
58
152
|
dragHandle: "⋮⋮",
|
|
59
153
|
toolPanel: "☰",
|
|
60
|
-
filter:
|
|
61
|
-
filterActive:
|
|
154
|
+
filter: v,
|
|
155
|
+
filterActive: v,
|
|
62
156
|
print: "🖨️"
|
|
63
157
|
};
|
|
64
|
-
class
|
|
158
|
+
class P {
|
|
65
159
|
/**
|
|
66
160
|
* Plugin dependencies - declare other plugins this one requires.
|
|
67
161
|
*
|
|
@@ -342,7 +436,7 @@ class C {
|
|
|
342
436
|
*/
|
|
343
437
|
get gridIcons() {
|
|
344
438
|
const t = this.grid?.gridConfig?.icons ?? {};
|
|
345
|
-
return { ...
|
|
439
|
+
return { ...N, ...t };
|
|
346
440
|
}
|
|
347
441
|
// #region Animation Helpers
|
|
348
442
|
/**
|
|
@@ -418,11 +512,11 @@ class C {
|
|
|
418
512
|
}
|
|
419
513
|
// #endregion
|
|
420
514
|
}
|
|
421
|
-
const
|
|
422
|
-
class
|
|
515
|
+
const I = 'tbw-grid[data-responsive-animate] .data-grid-row,tbw-grid[data-responsive-animate] .data-grid-row>.cell{transition:opacity var(--tbw-responsive-duration, .2s) ease-out,transform var(--tbw-responsive-duration, .2s) ease-out}tbw-grid[data-responsive][data-responsive-animate] .data-grid-row{animation:responsive-card-enter var(--tbw-responsive-duration, .2s) ease-out}@keyframes responsive-card-enter{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}tbw-grid[data-responsive] .header{display:none!important}tbw-grid[data-responsive] .footer-row{display:none}tbw-grid[data-responsive] .tbw-scroll-area{overflow-x:hidden;min-width:0!important}tbw-grid[data-responsive] .rows-body-wrapper{min-width:0!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row){display:block!important;grid-template-columns:none!important;padding:var(--tbw-cell-padding);padding-inline-start:var(--tbw-spacing-xl);border-bottom:1px solid var(--tbw-color-border);min-height:auto!important;height:auto!important;contain:none!important;content-visibility:visible!important;background:var(--tbw-color-bg);position:relative}tbw-grid[data-responsive] .data-grid-row:not(.group-row):nth-child(2n){background:var(--tbw-color-row-alt)}tbw-grid[data-responsive] .data-grid-row:not(.group-row):hover{background:var(--tbw-color-row-hover)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]{background:var(--tbw-color-selection)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)[aria-selected=true]:before{content:"";position:absolute;inset-inline-start:0;top:0;bottom:0;width:4px;background:var(--tbw-color-accent)}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell{display:flex!important;justify-content:space-between;align-items:center;padding:var(--tbw-spacing-xs) var(--tbw-spacing-md);width:100%!important;min-width:0!important;min-height:auto!important;height:auto!important;line-height:1.5!important;position:static!important;left:auto!important;right:auto!important;border:none!important;border-bottom:none!important;border-inline-end:none!important;background:transparent!important;white-space:normal!important;overflow:visible!important}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:before{content:attr(data-header) ": ";font-weight:600;color:var(--tbw-color-header-fg);flex-shrink:0;margin-inline-end:var(--tbw-spacing-md);min-width:100px}tbw-grid[data-responsive] .data-grid-row:not(.group-row)>.cell:after{content:none}tbw-grid[data-responsive] .cell[data-utility]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-value-only]{justify-content:flex-start!important;font-weight:500}tbw-grid[data-responsive] .cell[data-responsive-value-only]:before{display:none!important}tbw-grid:not([data-responsive]) .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .tbw-footer,tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows{display:none!important}tbw-grid[data-responsive] .tbw-pinned-rows,tbw-grid[data-responsive] .tbw-aggregation-rows,tbw-grid[data-responsive] .tbw-aggregation-row{min-width:0!important}tbw-grid[data-responsive] .data-grid-row.responsive-card{display:block!important;padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border)}tbw-grid[data-responsive] .data-grid-row.responsive-card>*{width:100%}tbw-grid[data-responsive] .data-grid-row.responsive-card .cell:before{display:none}';
|
|
516
|
+
class B extends P {
|
|
423
517
|
name = "responsive";
|
|
424
518
|
version = "1.0.0";
|
|
425
|
-
styles =
|
|
519
|
+
styles = I;
|
|
426
520
|
/**
|
|
427
521
|
* Plugin manifest declaring incompatibilities with other plugins.
|
|
428
522
|
*/
|
|
@@ -446,13 +540,13 @@ class A extends C {
|
|
|
446
540
|
#w = !1;
|
|
447
541
|
#a = 0;
|
|
448
542
|
/** Set of column fields to completely hide */
|
|
449
|
-
#
|
|
543
|
+
#s = /* @__PURE__ */ new Set();
|
|
450
544
|
/** Set of column fields to show value only (no header label) */
|
|
451
|
-
#
|
|
545
|
+
#l = /* @__PURE__ */ new Set();
|
|
452
546
|
/** Currently active breakpoint, or null if none */
|
|
453
|
-
#
|
|
547
|
+
#c = null;
|
|
454
548
|
/** Sorted breakpoints from largest to smallest */
|
|
455
|
-
#
|
|
549
|
+
#d = [];
|
|
456
550
|
/**
|
|
457
551
|
* Check if currently in responsive mode.
|
|
458
552
|
* @returns `true` if the grid is in card layout mode
|
|
@@ -466,7 +560,7 @@ class A extends C {
|
|
|
466
560
|
* @param enabled - Whether to enable responsive mode
|
|
467
561
|
*/
|
|
468
562
|
setResponsive(t) {
|
|
469
|
-
t !== this.#t && (this.#t = t, this.#
|
|
563
|
+
t !== this.#t && (this.#t = t, this.#h(), this.emit("responsive-change", {
|
|
470
564
|
isResponsive: t,
|
|
471
565
|
width: this.#a,
|
|
472
566
|
breakpoint: this.config.breakpoint ?? 0
|
|
@@ -477,7 +571,7 @@ class A extends C {
|
|
|
477
571
|
* @param width - New breakpoint width in pixels
|
|
478
572
|
*/
|
|
479
573
|
setBreakpoint(t) {
|
|
480
|
-
this.config.breakpoint = t, this.#
|
|
574
|
+
this.config.breakpoint = t, this.#m(this.#a);
|
|
481
575
|
}
|
|
482
576
|
/**
|
|
483
577
|
* Set a custom card renderer.
|
|
@@ -499,23 +593,72 @@ class A extends C {
|
|
|
499
593
|
* @returns The active BreakpointConfig, or null if no breakpoint is active
|
|
500
594
|
*/
|
|
501
595
|
getActiveBreakpoint() {
|
|
502
|
-
return this.#
|
|
596
|
+
return this.#c;
|
|
503
597
|
}
|
|
504
598
|
attach(t) {
|
|
505
|
-
super.attach(t), this.#
|
|
599
|
+
super.attach(t), this.#R(), this.#u(this.config.hiddenColumns), this.config.breakpoints?.length && (this.#d = [...this.config.breakpoints].sort((e, i) => i.maxWidth - e.maxWidth)), this.#e = new ResizeObserver((e) => {
|
|
506
600
|
const i = e[0]?.contentRect.width ?? 0;
|
|
507
601
|
this.#a = i, clearTimeout(this.#n), this.#n = setTimeout(() => {
|
|
508
|
-
this.#
|
|
602
|
+
this.#m(i);
|
|
509
603
|
}, this.config.debounceMs ?? 100);
|
|
510
604
|
}), this.#e.observe(this.gridElement);
|
|
511
605
|
}
|
|
606
|
+
// #region Light DOM Parsing
|
|
607
|
+
/**
|
|
608
|
+
* Parse `<tbw-grid-responsive-card>` elements from the grid's light DOM.
|
|
609
|
+
*
|
|
610
|
+
* Allows declarative configuration:
|
|
611
|
+
* ```html
|
|
612
|
+
* <tbw-grid [rows]="data">
|
|
613
|
+
* <tbw-grid-responsive-card breakpoint="500" card-row-height="80">
|
|
614
|
+
* <div class="custom-card">
|
|
615
|
+
* <strong>{{ row.name }}</strong>
|
|
616
|
+
* <span>{{ row.email }}</span>
|
|
617
|
+
* </div>
|
|
618
|
+
* </tbw-grid-responsive-card>
|
|
619
|
+
* </tbw-grid>
|
|
620
|
+
* ```
|
|
621
|
+
*
|
|
622
|
+
* Attributes:
|
|
623
|
+
* - `breakpoint`: number - Width threshold for responsive mode
|
|
624
|
+
* - `card-row-height`: number | 'auto' - Card height (default: 'auto')
|
|
625
|
+
* - `hidden-columns`: string - Comma-separated fields to hide
|
|
626
|
+
* - `hide-header`: 'true' | 'false' - Hide header row (default: 'true')
|
|
627
|
+
* - `debounce-ms`: number - Resize debounce delay (default: 100)
|
|
628
|
+
*/
|
|
629
|
+
#R() {
|
|
630
|
+
const t = this.grid;
|
|
631
|
+
if (!t || typeof t.querySelector != "function") return;
|
|
632
|
+
const e = t.querySelector("tbw-grid-responsive-card");
|
|
633
|
+
if (!e) return;
|
|
634
|
+
const i = t;
|
|
635
|
+
if (i.__frameworkAdapter?.parseResponsiveCardElement) {
|
|
636
|
+
const c = i.__frameworkAdapter.parseResponsiveCardElement(e);
|
|
637
|
+
c && (this.config = { ...this.config, cardRenderer: c });
|
|
638
|
+
}
|
|
639
|
+
const n = e.getAttribute("breakpoint"), a = e.getAttribute("card-row-height"), s = e.getAttribute("hidden-columns"), o = e.getAttribute("hide-header"), d = e.getAttribute("debounce-ms"), l = {};
|
|
640
|
+
if (n !== null) {
|
|
641
|
+
const c = parseInt(n, 10);
|
|
642
|
+
isNaN(c) || (l.breakpoint = c);
|
|
643
|
+
}
|
|
644
|
+
if (a !== null && (l.cardRowHeight = a === "auto" ? "auto" : parseInt(a, 10)), s !== null && (l.hiddenColumns = s.split(",").map((c) => c.trim()).filter((c) => c.length > 0)), o !== null && (l.hideHeader = o !== "false"), d !== null) {
|
|
645
|
+
const c = parseInt(d, 10);
|
|
646
|
+
isNaN(c) || (l.debounceMs = c);
|
|
647
|
+
}
|
|
648
|
+
const h = e.innerHTML.trim();
|
|
649
|
+
h && !this.config.cardRenderer && !i.__frameworkAdapter?.parseResponsiveCardElement && (l.cardRenderer = (c) => {
|
|
650
|
+
const f = H(h, { value: c, row: c }), w = S(f), p = document.createElement("div");
|
|
651
|
+
return p.className = "tbw-responsive-card-content", p.innerHTML = w, p;
|
|
652
|
+
}), Object.keys(l).length > 0 && (this.config = { ...this.config, ...l });
|
|
653
|
+
}
|
|
654
|
+
// #endregion
|
|
512
655
|
/**
|
|
513
656
|
* Build the hidden and value-only column sets from config.
|
|
514
657
|
*/
|
|
515
|
-
#
|
|
516
|
-
if (this.#
|
|
658
|
+
#u(t) {
|
|
659
|
+
if (this.#s.clear(), this.#l.clear(), !!t)
|
|
517
660
|
for (const e of t)
|
|
518
|
-
typeof e == "string" ? this.#
|
|
661
|
+
typeof e == "string" ? this.#s.add(e) : e.showValue ? this.#l.add(e.field) : this.#s.add(e.field);
|
|
519
662
|
}
|
|
520
663
|
detach() {
|
|
521
664
|
this.#e?.disconnect(), this.#e = void 0, clearTimeout(this.#n), this.#n = void 0, this.gridElement && this.gridElement.removeAttribute("data-responsive"), super.detach();
|
|
@@ -534,24 +677,24 @@ class A extends C {
|
|
|
534
677
|
* In multi-breakpoint mode, applies whenever there's an active breakpoint.
|
|
535
678
|
*/
|
|
536
679
|
afterRender() {
|
|
537
|
-
if (this.#
|
|
680
|
+
if (this.#E(), !(this.#d.length > 0 ? this.#c !== null : this.#t))
|
|
538
681
|
return;
|
|
539
|
-
const e = this.#
|
|
682
|
+
const e = this.#s.size > 0, i = this.#l.size > 0;
|
|
540
683
|
if (!e && !i)
|
|
541
684
|
return;
|
|
542
685
|
const n = this.gridElement.querySelectorAll(".cell[data-field]");
|
|
543
686
|
for (const a of n) {
|
|
544
|
-
const
|
|
545
|
-
|
|
687
|
+
const s = a.getAttribute("data-field");
|
|
688
|
+
s && (this.#s.has(s) ? (a.setAttribute("data-responsive-hidden", ""), a.removeAttribute("data-responsive-value-only")) : this.#l.has(s) ? (a.setAttribute("data-responsive-value-only", ""), a.removeAttribute("data-responsive-hidden")) : (a.removeAttribute("data-responsive-hidden"), a.removeAttribute("data-responsive-value-only")));
|
|
546
689
|
}
|
|
547
690
|
}
|
|
548
691
|
/**
|
|
549
692
|
* Check if width has crossed any breakpoint threshold.
|
|
550
693
|
* Handles both single breakpoint (legacy) and multi-breakpoint modes.
|
|
551
694
|
*/
|
|
552
|
-
#
|
|
553
|
-
if (this.#
|
|
554
|
-
this.#
|
|
695
|
+
#m(t) {
|
|
696
|
+
if (this.#d.length > 0) {
|
|
697
|
+
this.#y(t);
|
|
555
698
|
return;
|
|
556
699
|
}
|
|
557
700
|
const e = this.config.breakpoint ?? 0;
|
|
@@ -559,7 +702,7 @@ class A extends C {
|
|
|
559
702
|
"[tbw-grid:ResponsivePlugin] No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."
|
|
560
703
|
));
|
|
561
704
|
const i = e > 0 && t < e;
|
|
562
|
-
i !== this.#t && (this.#t = i, this.#
|
|
705
|
+
i !== this.#t && (this.#t = i, this.#h(), this.emit("responsive-change", {
|
|
563
706
|
isResponsive: i,
|
|
564
707
|
width: t,
|
|
565
708
|
breakpoint: e
|
|
@@ -569,14 +712,14 @@ class A extends C {
|
|
|
569
712
|
* Check breakpoints in multi-breakpoint mode.
|
|
570
713
|
* Evaluates breakpoints from largest to smallest, applying the first match.
|
|
571
714
|
*/
|
|
572
|
-
#
|
|
715
|
+
#y(t) {
|
|
573
716
|
let e = null;
|
|
574
|
-
for (const n of this.#
|
|
717
|
+
for (const n of this.#d)
|
|
575
718
|
t <= n.maxWidth && (e = n);
|
|
576
|
-
if (e !== this.#
|
|
577
|
-
this.#
|
|
719
|
+
if (e !== this.#c) {
|
|
720
|
+
this.#c = e, e?.hiddenColumns ? this.#u(e.hiddenColumns) : this.#u(this.config.hiddenColumns);
|
|
578
721
|
const n = e?.cardLayout === !0;
|
|
579
|
-
n !== this.#t && (this.#t = n, this.#
|
|
722
|
+
n !== this.#t && (this.#t = n, this.#h()), this.emit("responsive-change", {
|
|
580
723
|
isResponsive: this.#t,
|
|
581
724
|
width: t,
|
|
582
725
|
breakpoint: e?.maxWidth ?? 0
|
|
@@ -589,7 +732,7 @@ class A extends C {
|
|
|
589
732
|
* Apply the responsive state to the grid element.
|
|
590
733
|
* Handles scroll reset when entering responsive mode and row height restoration on exit.
|
|
591
734
|
*/
|
|
592
|
-
#
|
|
735
|
+
#h() {
|
|
593
736
|
this.gridElement.toggleAttribute("data-responsive", this.#t);
|
|
594
737
|
const t = this.config.animate !== !1;
|
|
595
738
|
this.gridElement.toggleAttribute("data-responsive-animate", t), this.config.animationDuration && this.gridElement.style.setProperty("--tbw-responsive-duration", `${this.config.animationDuration}ms`);
|
|
@@ -602,7 +745,7 @@ class A extends C {
|
|
|
602
745
|
const i = this.gridElement.querySelectorAll(".data-grid-row");
|
|
603
746
|
for (const n of i)
|
|
604
747
|
n.style.height = "", n.classList.remove("responsive-card");
|
|
605
|
-
this.#i && this.#i > 0 && e._virtualization && (e._virtualization.rowHeight = this.#i, this.#i = void 0), this.#r = void 0, this.#
|
|
748
|
+
this.#i && this.#i > 0 && e._virtualization && (e._virtualization.rowHeight = this.#i, this.#i = void 0), this.#r = void 0, this.#o = void 0, this.#g = void 0;
|
|
606
749
|
}
|
|
607
750
|
}
|
|
608
751
|
/**
|
|
@@ -646,23 +789,23 @@ class A extends C {
|
|
|
646
789
|
switch (t.key) {
|
|
647
790
|
case "ArrowDown":
|
|
648
791
|
if (this.grid._focusCol < i)
|
|
649
|
-
return this.grid._focusCol += 1, t.preventDefault(),
|
|
792
|
+
return this.grid._focusCol += 1, t.preventDefault(), g(this.grid), !0;
|
|
650
793
|
if (this.grid._focusRow < e)
|
|
651
|
-
return this.grid._focusRow += 1, this.grid._focusCol = 0, t.preventDefault(),
|
|
794
|
+
return this.grid._focusRow += 1, this.grid._focusCol = 0, t.preventDefault(), g(this.grid), !0;
|
|
652
795
|
break;
|
|
653
796
|
case "ArrowUp":
|
|
654
797
|
if (this.grid._focusCol > 0)
|
|
655
|
-
return this.grid._focusCol -= 1, t.preventDefault(),
|
|
798
|
+
return this.grid._focusCol -= 1, t.preventDefault(), g(this.grid), !0;
|
|
656
799
|
if (this.grid._focusRow > 0)
|
|
657
|
-
return this.grid._focusRow -= 1, this.grid._focusCol = i, t.preventDefault(),
|
|
800
|
+
return this.grid._focusRow -= 1, this.grid._focusCol = i, t.preventDefault(), g(this.grid), !0;
|
|
658
801
|
break;
|
|
659
802
|
case "ArrowRight":
|
|
660
803
|
if (this.grid._focusRow < e)
|
|
661
|
-
return this.grid._focusRow += 1, t.preventDefault(),
|
|
804
|
+
return this.grid._focusRow += 1, t.preventDefault(), g(this.grid), !0;
|
|
662
805
|
break;
|
|
663
806
|
case "ArrowLeft":
|
|
664
807
|
if (this.grid._focusRow > 0)
|
|
665
|
-
return this.grid._focusRow -= 1, t.preventDefault(),
|
|
808
|
+
return this.grid._focusRow -= 1, t.preventDefault(), g(this.grid), !0;
|
|
666
809
|
break;
|
|
667
810
|
}
|
|
668
811
|
return !1;
|
|
@@ -673,7 +816,7 @@ class A extends C {
|
|
|
673
816
|
/** Measured card height from DOM for virtualization calculations */
|
|
674
817
|
#r;
|
|
675
818
|
/** Measured group row height from DOM for virtualization calculations */
|
|
676
|
-
#
|
|
819
|
+
#o;
|
|
677
820
|
/** Last known card row count for detecting changes (e.g., group expand/collapse) */
|
|
678
821
|
#g;
|
|
679
822
|
/**
|
|
@@ -681,7 +824,7 @@ class A extends C {
|
|
|
681
824
|
* Prioritizes DOM-measured height (actual rendered size) over config,
|
|
682
825
|
* since content can overflow the configured height.
|
|
683
826
|
*/
|
|
684
|
-
#
|
|
827
|
+
#v() {
|
|
685
828
|
if (this.#r && this.#r > 0)
|
|
686
829
|
return this.#r;
|
|
687
830
|
const t = this.config.cardRowHeight;
|
|
@@ -691,14 +834,14 @@ class A extends C {
|
|
|
691
834
|
* Get the effective group row height for virtualization calculations.
|
|
692
835
|
* Uses DOM-measured height, falling back to original row height.
|
|
693
836
|
*/
|
|
694
|
-
#
|
|
695
|
-
return this.#
|
|
837
|
+
#b() {
|
|
838
|
+
return this.#o && this.#o > 0 ? this.#o : this.#i ?? 28;
|
|
696
839
|
}
|
|
697
840
|
/**
|
|
698
841
|
* Check if there are any group rows in the current dataset.
|
|
699
842
|
* Used to determine if we have mixed row heights.
|
|
700
843
|
*/
|
|
701
|
-
#
|
|
844
|
+
#f() {
|
|
702
845
|
for (const t of this.rows)
|
|
703
846
|
if (t.__isGroupRow)
|
|
704
847
|
return !0;
|
|
@@ -707,7 +850,7 @@ class A extends C {
|
|
|
707
850
|
/**
|
|
708
851
|
* Count group rows and card rows in the current dataset.
|
|
709
852
|
*/
|
|
710
|
-
#
|
|
853
|
+
#_() {
|
|
711
854
|
let t = 0, e = 0;
|
|
712
855
|
for (const i of this.rows)
|
|
713
856
|
i.__isGroupRow ? t++ : e++;
|
|
@@ -725,10 +868,10 @@ class A extends C {
|
|
|
725
868
|
* - Extra for cards: cardCount * (cardHeight - baseHeight)
|
|
726
869
|
*/
|
|
727
870
|
getExtraHeight() {
|
|
728
|
-
if (!this.#t || !this.config.cardRenderer || !this.#
|
|
871
|
+
if (!this.#t || !this.config.cardRenderer || !this.#f())
|
|
729
872
|
return 0;
|
|
730
|
-
const t = this.#i ?? 28, e = this.#
|
|
731
|
-
return
|
|
873
|
+
const t = this.#i ?? 28, e = this.#b(), i = this.#v(), { groupCount: n, cardCount: a } = this.#_(), s = n * Math.max(0, e - t), o = a * Math.max(0, i - t);
|
|
874
|
+
return s + o;
|
|
732
875
|
}
|
|
733
876
|
/**
|
|
734
877
|
* Return extra height that appears before a given row index.
|
|
@@ -737,26 +880,26 @@ class A extends C {
|
|
|
737
880
|
* Like getExtraHeight, this accounts for both group and card row heights.
|
|
738
881
|
*/
|
|
739
882
|
getExtraHeightBefore(t) {
|
|
740
|
-
if (!this.#t || !this.config.cardRenderer || !this.#
|
|
883
|
+
if (!this.#t || !this.config.cardRenderer || !this.#f())
|
|
741
884
|
return 0;
|
|
742
|
-
const e = this.#i ?? 28, i = this.#
|
|
743
|
-
let
|
|
744
|
-
const
|
|
885
|
+
const e = this.#i ?? 28, i = this.#b(), n = this.#v(), a = Math.max(0, i - e), s = Math.max(0, n - e);
|
|
886
|
+
let o = 0, d = 0;
|
|
887
|
+
const l = this.rows, h = Math.min(t, l.length);
|
|
745
888
|
for (let c = 0; c < h; c++)
|
|
746
|
-
|
|
747
|
-
return
|
|
889
|
+
l[c].__isGroupRow ? o++ : d++;
|
|
890
|
+
return o * a + d * s;
|
|
748
891
|
}
|
|
749
892
|
/**
|
|
750
893
|
* Count the number of card rows (non-group rows) in the current dataset.
|
|
751
894
|
*/
|
|
752
|
-
#
|
|
895
|
+
#C() {
|
|
753
896
|
let t = 0;
|
|
754
897
|
for (const e of this.rows)
|
|
755
898
|
e.__isGroupRow || t++;
|
|
756
899
|
return t;
|
|
757
900
|
}
|
|
758
901
|
/** Pending refresh scheduled via microtask */
|
|
759
|
-
#
|
|
902
|
+
#p = !1;
|
|
760
903
|
/**
|
|
761
904
|
* Measure card height from DOM after render and detect row count changes.
|
|
762
905
|
* Called in afterRender to ensure scroll calculations are accurate.
|
|
@@ -772,29 +915,29 @@ class A extends C {
|
|
|
772
915
|
*
|
|
773
916
|
* The refresh is deferred via microtask to avoid nested render cycles.
|
|
774
917
|
*/
|
|
775
|
-
#
|
|
918
|
+
#E() {
|
|
776
919
|
if (!this.#t || !this.config.cardRenderer)
|
|
777
920
|
return;
|
|
778
921
|
let t = !1;
|
|
779
|
-
const e = this.grid, i = this.#
|
|
922
|
+
const e = this.grid, i = this.#f(), n = this.#C();
|
|
780
923
|
if (n !== this.#g && (this.#g = n, t = !0), i) {
|
|
781
|
-
const
|
|
782
|
-
if (
|
|
783
|
-
const
|
|
784
|
-
|
|
924
|
+
const s = this.gridElement.querySelector(".data-grid-row.group-row");
|
|
925
|
+
if (s) {
|
|
926
|
+
const o = s.getBoundingClientRect().height;
|
|
927
|
+
o > 0 && o !== this.#o && (this.#o = o, t = !0);
|
|
785
928
|
}
|
|
786
929
|
}
|
|
787
930
|
const a = this.gridElement.querySelector(".data-grid-row.responsive-card");
|
|
788
931
|
if (a) {
|
|
789
|
-
const
|
|
790
|
-
|
|
932
|
+
const s = a.getBoundingClientRect().height;
|
|
933
|
+
s > 0 && s !== this.#r && (this.#r = s, t = !0, !i && e._virtualization && (e._virtualization.rowHeight = s));
|
|
791
934
|
}
|
|
792
|
-
t && !this.#
|
|
793
|
-
this.#
|
|
935
|
+
t && !this.#p && (this.#p = !0, queueMicrotask(() => {
|
|
936
|
+
this.#p = !1, this.grid && this.#t && this.grid.refreshVirtualWindow?.(!0, !0);
|
|
794
937
|
}));
|
|
795
938
|
}
|
|
796
939
|
}
|
|
797
940
|
export {
|
|
798
|
-
|
|
941
|
+
B as ResponsivePlugin
|
|
799
942
|
};
|
|
800
943
|
//# sourceMappingURL=index.js.map
|