@toolbox-web/grid 1.21.1 → 1.22.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 +6 -8
- package/all.js +2 -6850
- package/all.js.map +1 -1
- package/index.js +1 -4352
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +75 -8
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +8 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/styles/index.d.ts.map +1 -1
- package/lib/core/types.d.ts +84 -2
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +1 -733
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +5 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -560
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/column-virtualization/types.d.ts +5 -0
- package/lib/plugins/column-virtualization/types.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -754
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/context-menu/types.d.ts +5 -0
- package/lib/plugins/context-menu/types.d.ts.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.d.ts +1 -1
- package/lib/plugins/editing/index.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +1 -1539
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +49 -0
- package/lib/plugins/editing/types.d.ts.map +1 -1
- package/lib/plugins/export/index.js +1 -589
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/export/types.d.ts +5 -0
- package/lib/plugins/export/types.d.ts.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1283
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +7 -2
- package/lib/plugins/filtering/types.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +1 -726
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-columns/types.d.ts +3 -0
- package/lib/plugins/grouping-columns/types.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +2 -905
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +5 -0
- package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -950
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +5 -0
- package/lib/plugins/master-detail/types.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -553
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/multi-sort/types.d.ts +5 -0
- package/lib/plugins/multi-sort/types.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -688
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/types.d.ts +3 -0
- package/lib/plugins/pinned-columns/types.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +1 -704
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/types.d.ts +5 -0
- package/lib/plugins/pinned-rows/types.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +1 -1191
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/pivot/types.d.ts +5 -0
- package/lib/plugins/pivot/types.d.ts.map +1 -1
- package/lib/plugins/print/index.js +1 -691
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/print/types.d.ts +3 -0
- package/lib/plugins/print/types.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +1 -703
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/reorder/types.d.ts +5 -0
- package/lib/plugins/reorder/types.d.ts.map +1 -1
- package/lib/plugins/responsive/index.js +1 -971
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/responsive/types.d.ts +5 -0
- package/lib/plugins/responsive/types.d.ts.map +1 -1
- package/lib/plugins/row-reorder/index.js +1 -728
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/row-reorder/types.d.ts +5 -0
- package/lib/plugins/row-reorder/types.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +1 -1071
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +3 -0
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js +1 -521
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/server-side/types.d.ts +5 -0
- package/lib/plugins/server-side/types.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +1 -686
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/types.d.ts +5 -0
- package/lib/plugins/tree/types.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -584
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/undo-redo/types.d.ts +5 -0
- package/lib/plugins/undo-redo/types.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +1 -792
- package/lib/plugins/visibility/index.js.map +1 -1
- package/lib/plugins/visibility/types.d.ts +5 -0
- package/lib/plugins/visibility/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +1 -186
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +1 -90
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +1 -6
- package/umd/plugins/clipboard.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/export.umd.js +1 -13
- package/umd/plugins/export.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 -4
- 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/print.umd.js +1 -75
- package/umd/plugins/print.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/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 -3
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.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/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,4352 +1 @@
|
|
|
1
|
-
function ht() {
|
|
2
|
-
return {
|
|
3
|
-
rowCount: -1,
|
|
4
|
-
colCount: -1,
|
|
5
|
-
ariaLabel: void 0,
|
|
6
|
-
ariaDescribedBy: void 0
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
function ut(t, e, i, o, n) {
|
|
10
|
-
if (o === t.rowCount && n === t.colCount)
|
|
11
|
-
return !1;
|
|
12
|
-
const r = t.rowCount;
|
|
13
|
-
return t.rowCount = o, t.colCount = n, e && (e.setAttribute("aria-rowcount", String(o)), e.setAttribute("aria-colcount", String(n))), o !== r && i && (o > 0 ? i.setAttribute("role", "rowgroup") : i.removeAttribute("role")), !0;
|
|
14
|
-
}
|
|
15
|
-
function ft(t, e) {
|
|
16
|
-
const i = t?.gridAriaLabel;
|
|
17
|
-
return i || (t?.shell?.header?.title ?? e?.lightDomTitle ?? void 0);
|
|
18
|
-
}
|
|
19
|
-
function gt(t, e, i, o) {
|
|
20
|
-
if (!e) return !1;
|
|
21
|
-
let n = !1;
|
|
22
|
-
const r = ft(i, o);
|
|
23
|
-
r !== t.ariaLabel && (t.ariaLabel = r, r ? e.setAttribute("aria-label", r) : e.removeAttribute("aria-label"), n = !0);
|
|
24
|
-
const s = i?.gridAriaDescribedBy;
|
|
25
|
-
return s !== t.ariaDescribedBy && (t.ariaDescribedBy = s, s ? e.setAttribute("aria-describedby", s) : e.removeAttribute("aria-describedby"), n = !0), n;
|
|
26
|
-
}
|
|
27
|
-
const X = {
|
|
28
|
-
STRETCH: "stretch",
|
|
29
|
-
FIXED: "fixed"
|
|
30
|
-
}, pt = {
|
|
31
|
-
mode: "reduced-motion",
|
|
32
|
-
duration: 200,
|
|
33
|
-
easing: "ease-out"
|
|
34
|
-
}, Re = '<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>', M = {
|
|
35
|
-
expand: "▶",
|
|
36
|
-
collapse: "▼",
|
|
37
|
-
sortAsc: "▲",
|
|
38
|
-
sortDesc: "▼",
|
|
39
|
-
sortNone: "⇅",
|
|
40
|
-
submenuArrow: "▶",
|
|
41
|
-
dragHandle: "⋮⋮",
|
|
42
|
-
toolPanel: "☰",
|
|
43
|
-
filter: Re,
|
|
44
|
-
filterActive: Re,
|
|
45
|
-
print: "🖨️"
|
|
46
|
-
};
|
|
47
|
-
function wt(t) {
|
|
48
|
-
return Array.from(t.querySelectorAll("tbw-grid-column")).map((i) => {
|
|
49
|
-
const o = i.getAttribute("field") || "";
|
|
50
|
-
if (!o) return null;
|
|
51
|
-
const n = i.getAttribute("type") || void 0, s = n && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select"])).has(n) ? n : void 0, l = i.getAttribute("header") || void 0, a = i.hasAttribute("sortable"), c = i.hasAttribute("editable"), h = { field: o, type: s, header: l, sortable: a, editable: c }, f = i.getAttribute("width");
|
|
52
|
-
if (f) {
|
|
53
|
-
const b = parseFloat(f);
|
|
54
|
-
!isNaN(b) && /^\d+(\.\d+)?$/.test(f.trim()) ? h.width = b : h.width = f;
|
|
55
|
-
}
|
|
56
|
-
const p = i.getAttribute("minWidth") || i.getAttribute("min-width");
|
|
57
|
-
if (p) {
|
|
58
|
-
const b = parseFloat(p);
|
|
59
|
-
isNaN(b) || (h.minWidth = b);
|
|
60
|
-
}
|
|
61
|
-
i.hasAttribute("resizable") && (h.resizable = !0), i.hasAttribute("sizable") && (h.resizable = !0);
|
|
62
|
-
const g = i.getAttribute("editor"), u = i.getAttribute("renderer");
|
|
63
|
-
g && (h.__editorName = g), u && (h.__rendererName = u);
|
|
64
|
-
const d = i.getAttribute("options");
|
|
65
|
-
d && (h.options = d.split(",").map((b) => {
|
|
66
|
-
const [T, N] = b.includes(":") ? b.split(":") : [b.trim(), b.trim()];
|
|
67
|
-
return { value: T.trim(), label: N?.trim() || T.trim() };
|
|
68
|
-
}));
|
|
69
|
-
const w = i.querySelector("tbw-grid-column-view"), C = i.querySelector("tbw-grid-column-editor"), m = i.querySelector("tbw-grid-column-header");
|
|
70
|
-
w && (h.__viewTemplate = w), C && (h.__editorTemplate = C), m && (h.__headerTemplate = m);
|
|
71
|
-
const R = globalThis.DataGridElement?.getAdapters?.() ?? [], E = w ?? i, x = R.find((b) => b.canHandle(E));
|
|
72
|
-
if (x) {
|
|
73
|
-
const b = x.createRenderer(E);
|
|
74
|
-
b && (h.viewRenderer = b);
|
|
75
|
-
}
|
|
76
|
-
const y = C ?? i, v = R.find((b) => b.canHandle(y));
|
|
77
|
-
if (v) {
|
|
78
|
-
const b = v.createEditor(y);
|
|
79
|
-
b && (h.editor = b);
|
|
80
|
-
}
|
|
81
|
-
return h;
|
|
82
|
-
}).filter((i) => !!i);
|
|
83
|
-
}
|
|
84
|
-
function Ae(t, e) {
|
|
85
|
-
if ((!t || !t.length) && (!e || !e.length)) return [];
|
|
86
|
-
if (!t || !t.length) return e || [];
|
|
87
|
-
if (!e || !e.length) return t;
|
|
88
|
-
const i = {};
|
|
89
|
-
e.forEach((n) => {
|
|
90
|
-
const r = i[n.field];
|
|
91
|
-
if (r) {
|
|
92
|
-
n.header && !r.header && (r.header = n.header), n.type && !r.type && (r.type = n.type), n.sortable && (r.sortable = !0), n.editable && (r.editable = !0), n.resizable && (r.resizable = !0), n.width != null && r.width == null && (r.width = n.width), n.minWidth != null && r.minWidth == null && (r.minWidth = n.minWidth), n.__viewTemplate && (r.__viewTemplate = n.__viewTemplate), n.__editorTemplate && (r.__editorTemplate = n.__editorTemplate), n.__headerTemplate && (r.__headerTemplate = n.__headerTemplate);
|
|
93
|
-
const s = n.renderer || n.viewRenderer, l = r.renderer || r.viewRenderer;
|
|
94
|
-
s && !l && (r.viewRenderer = s, n.renderer && (r.renderer = s)), n.editor && !r.editor && (r.editor = n.editor);
|
|
95
|
-
} else
|
|
96
|
-
i[n.field] = { ...n };
|
|
97
|
-
});
|
|
98
|
-
const o = t.map((n) => {
|
|
99
|
-
const r = i[n.field];
|
|
100
|
-
if (!r) return n;
|
|
101
|
-
const s = { ...n };
|
|
102
|
-
r.header && !s.header && (s.header = r.header), r.type && !s.type && (s.type = r.type), s.sortable = n.sortable || r.sortable, (n.resizable === !0 || r.resizable === !0) && (s.resizable = !0), s.editable = n.editable || r.editable, r.width != null && s.width == null && (s.width = r.width), r.minWidth != null && s.minWidth == null && (s.minWidth = r.minWidth), r.__viewTemplate && (s.__viewTemplate = r.__viewTemplate), r.__editorTemplate && (s.__editorTemplate = r.__editorTemplate), r.__headerTemplate && (s.__headerTemplate = r.__headerTemplate);
|
|
103
|
-
const l = r.renderer || r.viewRenderer, a = s.renderer || s.viewRenderer;
|
|
104
|
-
return l && !a && (s.viewRenderer = l, r.renderer && (s.renderer = l)), r.editor && !s.editor && (s.editor = r.editor), delete i[n.field], s;
|
|
105
|
-
});
|
|
106
|
-
return Object.keys(i).forEach((n) => o.push(i[n])), o;
|
|
107
|
-
}
|
|
108
|
-
function Ye(t, e) {
|
|
109
|
-
try {
|
|
110
|
-
t.part?.add?.(e);
|
|
111
|
-
} catch {
|
|
112
|
-
}
|
|
113
|
-
const i = t.getAttribute("part");
|
|
114
|
-
i ? i.split(/\s+/).includes(e) || t.setAttribute("part", i + " " + e) : t.setAttribute("part", e);
|
|
115
|
-
}
|
|
116
|
-
function Te(t) {
|
|
117
|
-
const e = t.effectiveConfig?.fitMode || t.fitMode || X.STRETCH;
|
|
118
|
-
if (e !== X.STRETCH && e !== X.FIXED || t.__didInitialAutoSize || !t.isConnected) return;
|
|
119
|
-
const i = Array.from(t._headerRowEl?.children || []);
|
|
120
|
-
if (!i.length) return;
|
|
121
|
-
let o = !1;
|
|
122
|
-
t._visibleColumns.forEach((n, r) => {
|
|
123
|
-
if (n.width) return;
|
|
124
|
-
const s = i[r];
|
|
125
|
-
let l = s ? s.scrollWidth : 0;
|
|
126
|
-
for (const a of t._rowPool) {
|
|
127
|
-
const c = a.children[r];
|
|
128
|
-
if (c) {
|
|
129
|
-
const h = c.scrollWidth;
|
|
130
|
-
h > l && (l = h);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
l > 0 && (n.width = l + 2, n.__autoSized = !0, o = !0);
|
|
134
|
-
}), o && B(t), t.__didInitialAutoSize = !0;
|
|
135
|
-
}
|
|
136
|
-
const bt = /^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;
|
|
137
|
-
function xe(t, e) {
|
|
138
|
-
return typeof t == "number" ? `${t}px` : (bt.test(t) || console.warn(`[tbw-grid] Column '${e ?? "?"}' has an invalid CSS width value: '${t}'. Expected a number (px) or a valid CSS unit string (e.g. '30%', '2fr', 'calc(...)').`), t);
|
|
139
|
-
}
|
|
140
|
-
function B(t) {
|
|
141
|
-
(t.effectiveConfig?.fitMode || t.fitMode || X.STRETCH) === X.STRETCH ? t._gridTemplate = t._visibleColumns.map((i) => {
|
|
142
|
-
if (i.width != null) return xe(i.width, i.field);
|
|
143
|
-
const o = i.minWidth;
|
|
144
|
-
return o != null ? `minmax(${o}px, 1fr)` : "1fr";
|
|
145
|
-
}).join(" ").trim() : t._gridTemplate = t._visibleColumns.map((i) => i.width != null ? xe(i.width, i.field) : "max-content").join(" "), t.style.setProperty("--tbw-column-template", t._gridTemplate);
|
|
146
|
-
}
|
|
147
|
-
function mt(t) {
|
|
148
|
-
return t == null ? "string" : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t instanceof Date || typeof t == "string" && /\d{4}-\d{2}-\d{2}/.test(t) && !isNaN(Date.parse(t)) ? "date" : "string";
|
|
149
|
-
}
|
|
150
|
-
function vt(t, e) {
|
|
151
|
-
const i = t[0] || {}, o = Object.keys(i).map((r) => {
|
|
152
|
-
const s = i[r], l = mt(s);
|
|
153
|
-
return { field: r, header: r.charAt(0).toUpperCase() + r.slice(1), type: l };
|
|
154
|
-
}), n = {};
|
|
155
|
-
return o.forEach((r) => {
|
|
156
|
-
n[r.field] = r.type || "string";
|
|
157
|
-
}), { columns: o, typeMap: n };
|
|
158
|
-
}
|
|
159
|
-
const Ct = /{{\s*([^}]+)\s*}}/g, z = "__DG_EMPTY__", yt = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, _t = /__(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/;
|
|
160
|
-
function Et(t) {
|
|
161
|
-
return !t || typeof t != "string" ? "" : t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
162
|
-
}
|
|
163
|
-
const St = /* @__PURE__ */ new Set([
|
|
164
|
-
"script",
|
|
165
|
-
"iframe",
|
|
166
|
-
"object",
|
|
167
|
-
"embed",
|
|
168
|
-
"form",
|
|
169
|
-
"input",
|
|
170
|
-
"button",
|
|
171
|
-
"textarea",
|
|
172
|
-
"select",
|
|
173
|
-
"link",
|
|
174
|
-
"meta",
|
|
175
|
-
"base",
|
|
176
|
-
"style",
|
|
177
|
-
"template",
|
|
178
|
-
"slot",
|
|
179
|
-
"portal",
|
|
180
|
-
"frame",
|
|
181
|
-
"frameset",
|
|
182
|
-
"applet",
|
|
183
|
-
"noscript",
|
|
184
|
-
"noembed",
|
|
185
|
-
"plaintext",
|
|
186
|
-
"xmp",
|
|
187
|
-
"listing"
|
|
188
|
-
]), He = /^on\w+$/i, Rt = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), At = /^\s*(javascript|vbscript|data|blob):/i;
|
|
189
|
-
function k(t) {
|
|
190
|
-
if (!t || typeof t != "string") return "";
|
|
191
|
-
if (t.indexOf("<") === -1) return t;
|
|
192
|
-
const e = document.createElement("template");
|
|
193
|
-
return e.innerHTML = t, Tt(e.content), e.innerHTML;
|
|
194
|
-
}
|
|
195
|
-
function Tt(t) {
|
|
196
|
-
const e = [], i = t.querySelectorAll("*");
|
|
197
|
-
for (const o of i) {
|
|
198
|
-
const n = o.tagName.toLowerCase();
|
|
199
|
-
if (St.has(n)) {
|
|
200
|
-
e.push(o);
|
|
201
|
-
continue;
|
|
202
|
-
}
|
|
203
|
-
if ((n === "svg" || o.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(o.attributes).some(
|
|
204
|
-
(l) => He.test(l.name) || l.name === "href" || l.name === "xlink:href"
|
|
205
|
-
)) {
|
|
206
|
-
e.push(o);
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
const r = [];
|
|
210
|
-
for (const s of o.attributes) {
|
|
211
|
-
const l = s.name.toLowerCase();
|
|
212
|
-
if (He.test(l)) {
|
|
213
|
-
r.push(s.name);
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
if (Rt.has(l) && At.test(s.value)) {
|
|
217
|
-
r.push(s.name);
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (l === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(s.value)) {
|
|
221
|
-
r.push(s.name);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
r.forEach((s) => o.removeAttribute(s));
|
|
226
|
-
}
|
|
227
|
-
e.forEach((o) => o.remove());
|
|
228
|
-
}
|
|
229
|
-
function Ce(t, e) {
|
|
230
|
-
if (!t || t.indexOf("{{") === -1) return t;
|
|
231
|
-
const i = [], o = t.replace(Ct, (l, a) => {
|
|
232
|
-
const c = xt(a, e);
|
|
233
|
-
return i.push({ expr: a.trim(), result: c }), c;
|
|
234
|
-
}), n = Ht(o), r = i.length && i.every((l) => l.result === "" || l.result === z);
|
|
235
|
-
return $.test(t) || r ? "" : n;
|
|
236
|
-
}
|
|
237
|
-
function xt(t, e) {
|
|
238
|
-
if (t = (t || "").trim(), !t || $.test(t)) return z;
|
|
239
|
-
if (t === "value") return e.value == null ? z : String(e.value);
|
|
240
|
-
if (t.startsWith("row.") && !/[()?]/.test(t) && !t.includes(":")) {
|
|
241
|
-
const o = t.slice(4), n = e.row ? e.row[o] : void 0;
|
|
242
|
-
return n == null ? z : String(n);
|
|
243
|
-
}
|
|
244
|
-
if (t.length > 80 || !yt.test(t) || _t.test(t)) return z;
|
|
245
|
-
const i = t.match(/\./g);
|
|
246
|
-
if (i && i.length > 1) return z;
|
|
247
|
-
try {
|
|
248
|
-
const n = new Function("value", "row", `return (${t});`)(e.value, e.row), r = n == null ? "" : String(n);
|
|
249
|
-
return $.test(r) ? z : r || z;
|
|
250
|
-
} catch {
|
|
251
|
-
return z;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
const $ = /Reflect|Proxy|ownKeys/;
|
|
255
|
-
function Ht(t) {
|
|
256
|
-
return t && t.replace(new RegExp(z, "g"), "").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g, "");
|
|
257
|
-
}
|
|
258
|
-
function ge(t) {
|
|
259
|
-
if ($.test(t.textContent || "")) {
|
|
260
|
-
for (const e of t.childNodes)
|
|
261
|
-
e.nodeType === Node.TEXT_NODE && $.test(e.textContent || "") && (e.textContent = "");
|
|
262
|
-
$.test(t.textContent || "") && (t.textContent = "");
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
function Le(t) {
|
|
266
|
-
const e = $.test(t), i = ((o) => e ? "" : Ce(t, o));
|
|
267
|
-
return i.__blocked = e, i;
|
|
268
|
-
}
|
|
269
|
-
const Lt = 100;
|
|
270
|
-
class Pt {
|
|
271
|
-
#a;
|
|
272
|
-
#n;
|
|
273
|
-
#u;
|
|
274
|
-
#d;
|
|
275
|
-
#h;
|
|
276
|
-
#l = {};
|
|
277
|
-
#o = {};
|
|
278
|
-
#f = !0;
|
|
279
|
-
#w = [];
|
|
280
|
-
#v;
|
|
281
|
-
#s;
|
|
282
|
-
#C;
|
|
283
|
-
#r;
|
|
284
|
-
#g;
|
|
285
|
-
constructor(e) {
|
|
286
|
-
this.#r = e;
|
|
287
|
-
}
|
|
288
|
-
get original() {
|
|
289
|
-
return this.#l;
|
|
290
|
-
}
|
|
291
|
-
get effective() {
|
|
292
|
-
return this.#o;
|
|
293
|
-
}
|
|
294
|
-
get columns() {
|
|
295
|
-
return this.#o.columns ?? [];
|
|
296
|
-
}
|
|
297
|
-
set columns(e) {
|
|
298
|
-
this.#o.columns = e;
|
|
299
|
-
}
|
|
300
|
-
get lightDomColumnsCache() {
|
|
301
|
-
return this.#d;
|
|
302
|
-
}
|
|
303
|
-
set lightDomColumnsCache(e) {
|
|
304
|
-
this.#d = e;
|
|
305
|
-
}
|
|
306
|
-
get originalColumnNodes() {
|
|
307
|
-
return this.#h;
|
|
308
|
-
}
|
|
309
|
-
set originalColumnNodes(e) {
|
|
310
|
-
this.#h = e;
|
|
311
|
-
}
|
|
312
|
-
get lightDomTitle() {
|
|
313
|
-
return this.#g;
|
|
314
|
-
}
|
|
315
|
-
set lightDomTitle(e) {
|
|
316
|
-
this.#g = e;
|
|
317
|
-
}
|
|
318
|
-
get initialColumnState() {
|
|
319
|
-
return this.#C;
|
|
320
|
-
}
|
|
321
|
-
set initialColumnState(e) {
|
|
322
|
-
this.#C = e;
|
|
323
|
-
}
|
|
324
|
-
get sourcesChanged() {
|
|
325
|
-
return this.#f;
|
|
326
|
-
}
|
|
327
|
-
markSourcesChanged() {
|
|
328
|
-
this.#f = !0;
|
|
329
|
-
}
|
|
330
|
-
setGridConfig(e) {
|
|
331
|
-
this.#a = e, this.#f = !0, this.#d = void 0;
|
|
332
|
-
}
|
|
333
|
-
getGridConfig() {
|
|
334
|
-
return this.#a;
|
|
335
|
-
}
|
|
336
|
-
setColumns(e) {
|
|
337
|
-
this.#n = e, this.#f = !0;
|
|
338
|
-
}
|
|
339
|
-
getColumns() {
|
|
340
|
-
return this.#n;
|
|
341
|
-
}
|
|
342
|
-
setFitMode(e) {
|
|
343
|
-
this.#u = e, this.#f = !0;
|
|
344
|
-
}
|
|
345
|
-
getFitMode() {
|
|
346
|
-
return this.#u;
|
|
347
|
-
}
|
|
348
|
-
merge() {
|
|
349
|
-
const e = (this.#o.columns?.length ?? 0) > 0;
|
|
350
|
-
if (!this.#f && e)
|
|
351
|
-
return;
|
|
352
|
-
const i = this.#N();
|
|
353
|
-
this.#f = !1, this.#l = i, Object.freeze(this.#l), this.#l.columns && Object.freeze(this.#l.columns), this.#o = this.#x(this.#l), this.#m();
|
|
354
|
-
}
|
|
355
|
-
#x(e) {
|
|
356
|
-
const i = { ...e };
|
|
357
|
-
return e.columns && (i.columns = e.columns.map((o) => ({ ...o }))), e.shell && (i.shell = {
|
|
358
|
-
...e.shell,
|
|
359
|
-
header: e.shell.header ? { ...e.shell.header } : void 0,
|
|
360
|
-
toolPanel: e.shell.toolPanel ? { ...e.shell.toolPanel } : void 0,
|
|
361
|
-
toolPanels: e.shell.toolPanels?.map((o) => ({ ...o })),
|
|
362
|
-
headerContents: e.shell.headerContents?.map((o) => ({ ...o }))
|
|
363
|
-
}), i;
|
|
364
|
-
}
|
|
365
|
-
#m() {
|
|
366
|
-
const e = this.#o;
|
|
367
|
-
this.#O(), typeof e.rowHeight == "number" && e.rowHeight > 0 && this.#r.setRowHeight(e.rowHeight), e.fitMode === "fixed" && this.columns.forEach((o) => {
|
|
368
|
-
o.width == null && (o.width = 80);
|
|
369
|
-
}), this.#r.applyAnimationConfig(e);
|
|
370
|
-
}
|
|
371
|
-
#O() {
|
|
372
|
-
const e = this.#o.typeDefaults;
|
|
373
|
-
if (!e) return;
|
|
374
|
-
const i = this.columns;
|
|
375
|
-
for (const o of i) {
|
|
376
|
-
if (!o.type) continue;
|
|
377
|
-
const n = e[o.type];
|
|
378
|
-
n && (!o.renderer && !o.viewRenderer && n.renderer && (o.renderer = n.renderer), !o.format && n.format && (o.format = n.format), !o.editor && n.editor && (o.editor = n.editor), !o.editorParams && n.editorParams && (o.editorParams = n.editorParams));
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
#N() {
|
|
382
|
-
const e = this.#a ? { ...this.#a } : {}, i = Array.isArray(e.columns) ? [...e.columns] : [], o = (this.#d ?? []).map((s) => ({
|
|
383
|
-
...s
|
|
384
|
-
}));
|
|
385
|
-
let n = Ae(
|
|
386
|
-
i,
|
|
387
|
-
o
|
|
388
|
-
);
|
|
389
|
-
this.#n && this.#n.length && (n = Ae(
|
|
390
|
-
this.#n,
|
|
391
|
-
o
|
|
392
|
-
));
|
|
393
|
-
const r = this.#r.getRows();
|
|
394
|
-
return n.length === 0 && r.length && (n = vt(r).columns), n.length && (n.forEach((s) => {
|
|
395
|
-
s.sortable === void 0 && (s.sortable = !0), s.resizable === void 0 && (s.resizable = !0), s.__originalWidth === void 0 && typeof s.width == "number" && (s.__originalWidth = s.width);
|
|
396
|
-
}), n.forEach((s) => {
|
|
397
|
-
s.__viewTemplate && !s.__compiledView && (s.__compiledView = Le(s.__viewTemplate.innerHTML)), s.__editorTemplate && !s.__compiledEditor && (s.__compiledEditor = Le(s.__editorTemplate.innerHTML));
|
|
398
|
-
}), e.columns = n), this.#u && (e.fitMode = this.#u), e.fitMode || (e.fitMode = "stretch"), this.#b(e), e.columnState && !this.#C && (this.#C = e.columnState), e;
|
|
399
|
-
}
|
|
400
|
-
#b(e) {
|
|
401
|
-
e.shell = e.shell ? { ...e.shell } : {}, e.shell.header = e.shell.header ? { ...e.shell.header } : {};
|
|
402
|
-
const i = this.#r.getShellLightDomTitle();
|
|
403
|
-
i && (this.#g = i), this.#g && !e.shell.header.title && (e.shell.header.title = this.#g);
|
|
404
|
-
const o = this.#r.getShellLightDomHeaderContent();
|
|
405
|
-
o?.length > 0 && (e.shell.header.lightDomContent = o), this.#r.getShellHasToolButtonsContainer() && (e.shell.header.hasToolButtonsContainer = !0);
|
|
406
|
-
const n = this.#r.getShellToolPanels();
|
|
407
|
-
if (n.size > 0) {
|
|
408
|
-
const f = Array.from(n.values());
|
|
409
|
-
f.sort((p, g) => (p.order ?? 100) - (g.order ?? 100)), e.shell.toolPanels = f;
|
|
410
|
-
}
|
|
411
|
-
const r = this.#r.getShellHeaderContents();
|
|
412
|
-
if (r.size > 0) {
|
|
413
|
-
const f = Array.from(r.values());
|
|
414
|
-
f.sort((p, g) => (p.order ?? 100) - (g.order ?? 100)), e.shell.headerContents = f;
|
|
415
|
-
}
|
|
416
|
-
const s = this.#r.getShellToolbarContents(), l = Array.from(s.values()), a = this.#a?.shell?.header?.toolbarContents ?? [], c = new Set(a.map((f) => f.id)), h = [...a];
|
|
417
|
-
for (const f of l)
|
|
418
|
-
c.has(f.id) || h.push(f);
|
|
419
|
-
h.sort((f, p) => (f.order ?? 0) - (p.order ?? 0)), e.shell.header.toolbarContents = h;
|
|
420
|
-
}
|
|
421
|
-
collectState(e) {
|
|
422
|
-
const i = this.columns, o = this.#y();
|
|
423
|
-
return {
|
|
424
|
-
columns: i.map((n, r) => {
|
|
425
|
-
const s = {
|
|
426
|
-
field: n.field,
|
|
427
|
-
order: r,
|
|
428
|
-
visible: !n.hidden
|
|
429
|
-
}, l = n;
|
|
430
|
-
l.__renderedWidth !== void 0 ? s.width = l.__renderedWidth : n.width !== void 0 && (s.width = typeof n.width == "string" ? parseFloat(n.width) : n.width);
|
|
431
|
-
const a = o.get(n.field);
|
|
432
|
-
a && (s.sort = a);
|
|
433
|
-
for (const c of e)
|
|
434
|
-
if (c.getColumnState) {
|
|
435
|
-
const h = c.getColumnState(n.field);
|
|
436
|
-
h && Object.assign(s, h);
|
|
437
|
-
}
|
|
438
|
-
return s;
|
|
439
|
-
})
|
|
440
|
-
};
|
|
441
|
-
}
|
|
442
|
-
applyState(e, i) {
|
|
443
|
-
if (!e.columns || e.columns.length === 0) return;
|
|
444
|
-
const o = this.columns, n = new Map(e.columns.map((l) => [l.field, l])), r = o.map((l) => {
|
|
445
|
-
const a = n.get(l.field);
|
|
446
|
-
if (!a) return l;
|
|
447
|
-
const c = { ...l };
|
|
448
|
-
return a.width !== void 0 && (c.width = a.width, c.__renderedWidth = a.width), a.visible !== void 0 && (c.hidden = !a.visible), c;
|
|
449
|
-
});
|
|
450
|
-
r.sort((l, a) => {
|
|
451
|
-
const c = n.get(l.field)?.order ?? 1 / 0, h = n.get(a.field)?.order ?? 1 / 0;
|
|
452
|
-
return c - h;
|
|
453
|
-
}), this.columns = r;
|
|
454
|
-
const s = e.columns.filter((l) => l.sort !== void 0).sort((l, a) => (l.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
|
|
455
|
-
if (s.length > 0) {
|
|
456
|
-
const l = s[0];
|
|
457
|
-
l.sort && this.#r.setSortState({
|
|
458
|
-
field: l.field,
|
|
459
|
-
direction: l.sort.direction === "asc" ? 1 : -1
|
|
460
|
-
});
|
|
461
|
-
} else
|
|
462
|
-
this.#r.setSortState(null);
|
|
463
|
-
for (const l of i)
|
|
464
|
-
if (l.applyColumnState)
|
|
465
|
-
for (const a of e.columns)
|
|
466
|
-
l.applyColumnState(a.field, a);
|
|
467
|
-
}
|
|
468
|
-
resetState(e) {
|
|
469
|
-
this.#C = void 0, this.#r.setSortState(null), this.#o = this.#x(this.#l), this.#m();
|
|
470
|
-
for (const i of e)
|
|
471
|
-
if (i.applyColumnState)
|
|
472
|
-
for (const o of this.columns)
|
|
473
|
-
i.applyColumnState(o.field, {
|
|
474
|
-
field: o.field,
|
|
475
|
-
order: 0,
|
|
476
|
-
visible: !0
|
|
477
|
-
});
|
|
478
|
-
this.requestStateChange(e);
|
|
479
|
-
}
|
|
480
|
-
#y() {
|
|
481
|
-
const e = /* @__PURE__ */ new Map(), i = this.#r.getSortState();
|
|
482
|
-
return i && e.set(i.field, {
|
|
483
|
-
direction: i.direction === 1 ? "asc" : "desc",
|
|
484
|
-
priority: 0
|
|
485
|
-
}), e;
|
|
486
|
-
}
|
|
487
|
-
requestStateChange(e) {
|
|
488
|
-
this.#s && clearTimeout(this.#s), this.#s = setTimeout(() => {
|
|
489
|
-
this.#s = void 0;
|
|
490
|
-
const i = this.collectState(e);
|
|
491
|
-
this.#r.emit("column-state-change", i);
|
|
492
|
-
}, Lt);
|
|
493
|
-
}
|
|
494
|
-
setColumnVisible(e, i) {
|
|
495
|
-
const o = this.columns, n = o.find((s) => s.field === e);
|
|
496
|
-
return !n || !i && n.lockVisible || !i && o.filter((l) => !l.hidden && l.field !== e).length === 0 || !!n.hidden === !i ? !1 : (n.hidden = !i, this.#r.emit("column-visibility", {
|
|
497
|
-
field: e,
|
|
498
|
-
visible: i,
|
|
499
|
-
visibleColumns: o.filter((s) => !s.hidden).map((s) => s.field)
|
|
500
|
-
}), this.#r.clearRowPool(), this.#r.setup(), !0);
|
|
501
|
-
}
|
|
502
|
-
toggleColumnVisibility(e) {
|
|
503
|
-
const i = this.columns.find((o) => o.field === e);
|
|
504
|
-
return i ? this.setColumnVisible(e, !!i.hidden) : !1;
|
|
505
|
-
}
|
|
506
|
-
isColumnVisible(e) {
|
|
507
|
-
const i = this.columns.find((o) => o.field === e);
|
|
508
|
-
return i ? !i.hidden : !1;
|
|
509
|
-
}
|
|
510
|
-
showAllColumns() {
|
|
511
|
-
const e = this.columns;
|
|
512
|
-
e.some((i) => i.hidden) && (e.forEach((i) => i.hidden = !1), this.#r.emit("column-visibility", {
|
|
513
|
-
visibleColumns: e.map((i) => i.field)
|
|
514
|
-
}), this.#r.clearRowPool(), this.#r.setup());
|
|
515
|
-
}
|
|
516
|
-
getAllColumns() {
|
|
517
|
-
return this.columns.map((e) => ({
|
|
518
|
-
field: e.field,
|
|
519
|
-
header: e.header || e.field,
|
|
520
|
-
visible: !e.hidden,
|
|
521
|
-
lockVisible: e.lockVisible,
|
|
522
|
-
utility: e.meta?.utility === !0
|
|
523
|
-
}));
|
|
524
|
-
}
|
|
525
|
-
getColumnOrder() {
|
|
526
|
-
return this.columns.map((e) => e.field);
|
|
527
|
-
}
|
|
528
|
-
setColumnOrder(e) {
|
|
529
|
-
if (!e.length) return;
|
|
530
|
-
const i = new Map(this.columns.map((n) => [n.field, n])), o = [];
|
|
531
|
-
for (const n of e) {
|
|
532
|
-
const r = i.get(n);
|
|
533
|
-
r && (o.push(r), i.delete(n));
|
|
534
|
-
}
|
|
535
|
-
for (const n of i.values())
|
|
536
|
-
o.push(n);
|
|
537
|
-
this.columns = o, this.#r.renderHeader(), this.#r.updateTemplate(), this.#r.refreshVirtualWindow();
|
|
538
|
-
}
|
|
539
|
-
parseLightDomColumns(e) {
|
|
540
|
-
this.#d || (this.#h = Array.from(e.querySelectorAll("tbw-grid-column")), this.#d = this.#h.length ? wt(e) : []);
|
|
541
|
-
}
|
|
542
|
-
clearLightDomCache() {
|
|
543
|
-
this.#d = void 0;
|
|
544
|
-
}
|
|
545
|
-
#p = /* @__PURE__ */ new Map();
|
|
546
|
-
registerLightDomHandler(e, i) {
|
|
547
|
-
this.#p.set(e.toLowerCase(), i);
|
|
548
|
-
}
|
|
549
|
-
unregisterLightDomHandler(e) {
|
|
550
|
-
this.#p.delete(e.toLowerCase());
|
|
551
|
-
}
|
|
552
|
-
observeLightDOM(e) {
|
|
553
|
-
this.#v && this.#v.disconnect();
|
|
554
|
-
const i = /* @__PURE__ */ new Set();
|
|
555
|
-
let o = null;
|
|
556
|
-
const n = () => {
|
|
557
|
-
o = null;
|
|
558
|
-
for (const r of i)
|
|
559
|
-
this.#p.get(r)?.();
|
|
560
|
-
i.clear();
|
|
561
|
-
};
|
|
562
|
-
this.#v = new MutationObserver((r) => {
|
|
563
|
-
for (const s of r) {
|
|
564
|
-
for (const l of s.addedNodes) {
|
|
565
|
-
if (l.nodeType !== Node.ELEMENT_NODE) continue;
|
|
566
|
-
const c = l.tagName.toLowerCase();
|
|
567
|
-
this.#p.has(c) && i.add(c);
|
|
568
|
-
}
|
|
569
|
-
if (s.type === "attributes" && s.target.nodeType === Node.ELEMENT_NODE) {
|
|
570
|
-
const a = s.target.tagName.toLowerCase();
|
|
571
|
-
this.#p.has(a) && i.add(a);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
i.size > 0 && !o && (o = setTimeout(n, 0));
|
|
575
|
-
}), this.#v.observe(e, {
|
|
576
|
-
childList: !0,
|
|
577
|
-
subtree: !0,
|
|
578
|
-
attributes: !0,
|
|
579
|
-
attributeFilter: ["title", "field", "header", "width", "hidden", "id", "icon", "tooltip", "order"]
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
onChange(e) {
|
|
583
|
-
this.#w.push(e);
|
|
584
|
-
}
|
|
585
|
-
notifyChange() {
|
|
586
|
-
for (const e of this.#w)
|
|
587
|
-
e();
|
|
588
|
-
}
|
|
589
|
-
dispose() {
|
|
590
|
-
this.#v?.disconnect(), this.#w = [], this.#s && clearTimeout(this.#s);
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
function ye() {
|
|
594
|
-
if (typeof window < "u" && window.location) {
|
|
595
|
-
const t = window.location.hostname;
|
|
596
|
-
if (t === "localhost" || t === "127.0.0.1" || t === "::1")
|
|
597
|
-
return !0;
|
|
598
|
-
}
|
|
599
|
-
return typeof process < "u" && process.env?.NODE_ENV !== "production";
|
|
600
|
-
}
|
|
601
|
-
function je(t) {
|
|
602
|
-
return `<span role="checkbox" aria-checked="${t}" aria-label="${t}">${t ? "🗹" : "☐"}</span>`;
|
|
603
|
-
}
|
|
604
|
-
function Ke(t) {
|
|
605
|
-
if (t == null || t === "") return "";
|
|
606
|
-
if (t instanceof Date)
|
|
607
|
-
return isNaN(t.getTime()) ? "" : t.toLocaleDateString();
|
|
608
|
-
if (typeof t == "number" || typeof t == "string") {
|
|
609
|
-
const e = new Date(t);
|
|
610
|
-
return isNaN(e.getTime()) ? "" : e.toLocaleDateString();
|
|
611
|
-
}
|
|
612
|
-
return "";
|
|
613
|
-
}
|
|
614
|
-
function Qe(t) {
|
|
615
|
-
if (!t) return -1;
|
|
616
|
-
const e = t.getAttribute("data-row");
|
|
617
|
-
if (e) return parseInt(e, 10);
|
|
618
|
-
const i = t.closest(".data-grid-row");
|
|
619
|
-
if (!i) return -1;
|
|
620
|
-
const o = i.parentElement;
|
|
621
|
-
if (!o) return -1;
|
|
622
|
-
const n = o.querySelectorAll(":scope > .data-grid-row");
|
|
623
|
-
for (let r = 0; r < n.length; r++)
|
|
624
|
-
if (n[r] === i) return r;
|
|
625
|
-
return -1;
|
|
626
|
-
}
|
|
627
|
-
function zt(t) {
|
|
628
|
-
if (!t) return -1;
|
|
629
|
-
const e = t.getAttribute("data-col");
|
|
630
|
-
return e ? parseInt(e, 10) : -1;
|
|
631
|
-
}
|
|
632
|
-
function _e(t) {
|
|
633
|
-
t && t.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
634
|
-
}
|
|
635
|
-
function Ot(t) {
|
|
636
|
-
try {
|
|
637
|
-
if (getComputedStyle(t).direction === "rtl") return "rtl";
|
|
638
|
-
} catch {
|
|
639
|
-
}
|
|
640
|
-
try {
|
|
641
|
-
if (t.closest?.("[dir]")?.getAttribute("dir") === "rtl") return "rtl";
|
|
642
|
-
} catch {
|
|
643
|
-
}
|
|
644
|
-
return "ltr";
|
|
645
|
-
}
|
|
646
|
-
function Pe(t) {
|
|
647
|
-
return Ot(t) === "rtl";
|
|
648
|
-
}
|
|
649
|
-
function ro(t, e) {
|
|
650
|
-
return t === "left" || t === "right" ? t : e === "rtl" ? t === "start" ? "right" : "left" : t === "start" ? "left" : "right";
|
|
651
|
-
}
|
|
652
|
-
function Ze(t, e) {
|
|
653
|
-
const i = e.renderer || e.viewRenderer;
|
|
654
|
-
if (i) return i;
|
|
655
|
-
if (!e.type) return;
|
|
656
|
-
const o = t.__frameworkAdapter;
|
|
657
|
-
if (o?.getTypeDefault) {
|
|
658
|
-
const n = o.getTypeDefault(e.type);
|
|
659
|
-
if (n?.renderer)
|
|
660
|
-
return n.renderer;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
function Je(t, e) {
|
|
664
|
-
if (e.format) return e.format;
|
|
665
|
-
if (!e.type) return;
|
|
666
|
-
const i = t.__frameworkAdapter;
|
|
667
|
-
if (i?.getTypeDefault) {
|
|
668
|
-
const o = i.getTypeDefault(e.type);
|
|
669
|
-
if (o?.format)
|
|
670
|
-
return o.format;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
const et = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
|
|
674
|
-
function se(t) {
|
|
675
|
-
return (t.__editingCellCount ?? 0) > 0;
|
|
676
|
-
}
|
|
677
|
-
function le(t) {
|
|
678
|
-
t.__editingCellCount = 0, t.removeAttribute("data-has-editing"), t.querySelectorAll(".cell.editing").forEach((i) => i.classList.remove("editing"));
|
|
679
|
-
}
|
|
680
|
-
const tt = document.createElement("template");
|
|
681
|
-
tt.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
|
|
682
|
-
const it = document.createElement("template");
|
|
683
|
-
it.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
684
|
-
function Dt() {
|
|
685
|
-
return tt.content.firstElementChild.cloneNode(!0);
|
|
686
|
-
}
|
|
687
|
-
function Mt() {
|
|
688
|
-
return it.content.firstElementChild.cloneNode(!0);
|
|
689
|
-
}
|
|
690
|
-
function W(t) {
|
|
691
|
-
t.__cellDisplayCache = void 0, t.__cellCacheEpoch = void 0, t.__hasSpecialColumns = void 0;
|
|
692
|
-
}
|
|
693
|
-
function kt(t, e, i, o, n) {
|
|
694
|
-
const r = Math.max(0, i - e), s = t._bodyEl, l = t._visibleColumns, a = l.length;
|
|
695
|
-
let c = t.__cachedHeaderRowCount;
|
|
696
|
-
for (c === void 0 && (c = t.querySelector(".header-group-row") ? 2 : 1, t.__cachedHeaderRowCount = c); t._rowPool.length < r; ) {
|
|
697
|
-
const p = Mt();
|
|
698
|
-
t._rowPool.push(p);
|
|
699
|
-
}
|
|
700
|
-
if (t._rowPool.length > r) {
|
|
701
|
-
for (let p = r; p < t._rowPool.length; p++) {
|
|
702
|
-
const g = t._rowPool[p];
|
|
703
|
-
g.parentNode === s && g.remove();
|
|
704
|
-
}
|
|
705
|
-
t._rowPool.length = r;
|
|
706
|
-
}
|
|
707
|
-
const h = n && t.__hasRenderRowPlugins !== !1, f = t._hasAfterRowRenderHook?.() ?? !1;
|
|
708
|
-
for (let p = 0; p < r; p++) {
|
|
709
|
-
const g = e + p, u = t._rows[g], d = t._rowPool[p];
|
|
710
|
-
if (d.setAttribute("aria-rowindex", String(g + c + 1)), h && n(u, d, g)) {
|
|
711
|
-
d.__epoch = o, d.__rowDataRef = u, d.parentNode !== s && s.appendChild(d);
|
|
712
|
-
continue;
|
|
713
|
-
}
|
|
714
|
-
const w = d.__epoch, C = d.__rowDataRef;
|
|
715
|
-
let m = d.children.length;
|
|
716
|
-
m > a && d.lastElementChild?.classList.contains("tbw-row-loading-overlay") && m--;
|
|
717
|
-
const R = w === o && m === a, E = C !== u, x = !!t._isGridEditMode;
|
|
718
|
-
let y = !1;
|
|
719
|
-
if (R && E) {
|
|
720
|
-
for (let S = 0; S < a; S++)
|
|
721
|
-
if (l[S].externalView && !d.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
|
|
722
|
-
y = !0;
|
|
723
|
-
break;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
if (!R || y) {
|
|
727
|
-
const S = se(d), L = x || t._activeEditRows === g;
|
|
728
|
-
S && !L ? (d.__isCustomRow && (d.className = "data-grid-row", d.setAttribute("role", "row"), d.__isCustomRow = !1), le(d), G(t, d, u, g), d.__epoch = o, d.__rowDataRef = u) : S && L ? (ae(t, d, u, g), d.__rowDataRef = u) : (d.__isCustomRow && (d.className = "data-grid-row", d.setAttribute("role", "row"), d.__isCustomRow = !1), G(t, d, u, g), d.__epoch = o, d.__rowDataRef = u);
|
|
729
|
-
} else if (E) {
|
|
730
|
-
const S = se(d), L = x || t._activeEditRows === g;
|
|
731
|
-
S && !L ? (le(d), G(t, d, u, g), d.__epoch = o, d.__rowDataRef = u) : (ae(t, d, u, g), d.__rowDataRef = u);
|
|
732
|
-
} else {
|
|
733
|
-
const S = se(d), L = x || t._activeEditRows === g;
|
|
734
|
-
S && !L ? (le(d), G(t, d, u, g), d.__epoch = o, d.__rowDataRef = u) : ae(t, d, u, g);
|
|
735
|
-
}
|
|
736
|
-
let v = !1;
|
|
737
|
-
const b = t.changedRowIds;
|
|
738
|
-
if (b && b.length > 0)
|
|
739
|
-
try {
|
|
740
|
-
const S = t.getRowId?.(u);
|
|
741
|
-
S && (v = b.includes(S));
|
|
742
|
-
} catch {
|
|
743
|
-
}
|
|
744
|
-
const T = d.classList.contains("changed");
|
|
745
|
-
v !== T && d.classList.toggle("changed", v);
|
|
746
|
-
const N = t.effectiveConfig?.rowClass;
|
|
747
|
-
if (N) {
|
|
748
|
-
const S = d.getAttribute("data-dynamic-classes");
|
|
749
|
-
S && S.split(" ").forEach((L) => L && d.classList.remove(L));
|
|
750
|
-
try {
|
|
751
|
-
const L = N(u);
|
|
752
|
-
if (L && L.length > 0) {
|
|
753
|
-
const re = L.filter((Y) => Y && typeof Y == "string");
|
|
754
|
-
re.forEach((Y) => d.classList.add(Y)), d.setAttribute("data-dynamic-classes", re.join(" "));
|
|
755
|
-
} else
|
|
756
|
-
d.removeAttribute("data-dynamic-classes");
|
|
757
|
-
} catch (L) {
|
|
758
|
-
console.warn("[tbw-grid] rowClass callback error:", L), d.removeAttribute("data-dynamic-classes");
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
f && t._afterRowRender?.({
|
|
762
|
-
row: u,
|
|
763
|
-
rowIndex: g,
|
|
764
|
-
rowElement: d
|
|
765
|
-
}), d.parentNode !== s && s.appendChild(d);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
function ae(t, e, i, o) {
|
|
769
|
-
const n = e.children, r = t._visibleColumns, s = r.length, l = n.length, a = s < l ? s : l, c = t._focusRow, h = t._focusCol, f = t._hasAfterCellRenderHook?.() ?? !1;
|
|
770
|
-
let p = t.__hasSpecialColumns;
|
|
771
|
-
if (p === void 0) {
|
|
772
|
-
p = !1;
|
|
773
|
-
const u = t.__frameworkAdapter;
|
|
774
|
-
for (let d = 0; d < s; d++) {
|
|
775
|
-
const w = r[d];
|
|
776
|
-
if (w.__viewTemplate || w.__compiledView || w.renderer || w.viewRenderer || w.externalView || w.format || w.type === "date" || w.type === "boolean" || w.type && u?.getTypeDefault?.(w.type)?.renderer || w.type && u?.getTypeDefault?.(w.type)?.format) {
|
|
777
|
-
p = !0;
|
|
778
|
-
break;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
t.__hasSpecialColumns = p;
|
|
782
|
-
}
|
|
783
|
-
const g = String(o);
|
|
784
|
-
if (!p) {
|
|
785
|
-
for (let u = 0; u < a; u++) {
|
|
786
|
-
const d = n[u];
|
|
787
|
-
if (d.classList.contains("editing")) continue;
|
|
788
|
-
d.firstElementChild && t.__frameworkAdapter?.releaseCell?.(d);
|
|
789
|
-
const w = r[u], C = i[w.field];
|
|
790
|
-
d.textContent = C == null ? "" : String(C), d.getAttribute("data-row") !== g && d.setAttribute("data-row", g);
|
|
791
|
-
const m = c === o && h === u, _ = d.classList.contains("cell-focus");
|
|
792
|
-
m !== _ && (d.classList.toggle("cell-focus", m), d.setAttribute("aria-selected", String(m))), f && t._afterCellRender?.({
|
|
793
|
-
row: i,
|
|
794
|
-
rowIndex: o,
|
|
795
|
-
column: w,
|
|
796
|
-
colIndex: u,
|
|
797
|
-
value: C,
|
|
798
|
-
cellElement: d,
|
|
799
|
-
rowElement: e
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
return;
|
|
803
|
-
}
|
|
804
|
-
for (let u = 0; u < a; u++)
|
|
805
|
-
if (r[u].externalView && !n[u].querySelector("[data-external-view]")) {
|
|
806
|
-
G(t, e, i, o);
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
for (let u = 0; u < a; u++) {
|
|
810
|
-
const d = r[u], w = n[u];
|
|
811
|
-
w.getAttribute("data-row") !== g && w.setAttribute("data-row", g);
|
|
812
|
-
const C = c === o && h === u, m = w.classList.contains("cell-focus");
|
|
813
|
-
C !== m && (w.classList.toggle("cell-focus", C), w.setAttribute("aria-selected", String(C)));
|
|
814
|
-
const _ = d.cellClass;
|
|
815
|
-
if (_) {
|
|
816
|
-
const v = w.getAttribute("data-dynamic-classes");
|
|
817
|
-
v && v.split(" ").forEach((b) => b && w.classList.remove(b));
|
|
818
|
-
try {
|
|
819
|
-
const b = i[d.field], T = _(b, i, d);
|
|
820
|
-
if (T && T.length > 0) {
|
|
821
|
-
const N = T.filter((S) => S && typeof S == "string");
|
|
822
|
-
N.forEach((S) => w.classList.add(S)), w.setAttribute("data-dynamic-classes", N.join(" "));
|
|
823
|
-
} else
|
|
824
|
-
w.removeAttribute("data-dynamic-classes");
|
|
825
|
-
} catch (b) {
|
|
826
|
-
console.warn(`[tbw-grid] cellClass callback error for column '${d.field}':`, b), w.removeAttribute("data-dynamic-classes");
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
if (w.classList.contains("editing")) continue;
|
|
830
|
-
const R = Ze(t, d);
|
|
831
|
-
if (R) {
|
|
832
|
-
const v = i[d.field], b = R({
|
|
833
|
-
row: i,
|
|
834
|
-
value: v,
|
|
835
|
-
field: d.field,
|
|
836
|
-
column: d,
|
|
837
|
-
cellEl: w
|
|
838
|
-
});
|
|
839
|
-
typeof b == "string" ? (t.__frameworkAdapter?.releaseCell?.(w), w.innerHTML = k(b)) : b instanceof Node ? b.parentElement !== w && (t.__frameworkAdapter?.releaseCell?.(w), w.innerHTML = "", w.appendChild(b)) : b == null && (t.__frameworkAdapter?.releaseCell?.(w), w.textContent = v == null ? "" : String(v)), f && t._afterCellRender?.({
|
|
840
|
-
row: i,
|
|
841
|
-
rowIndex: o,
|
|
842
|
-
column: d,
|
|
843
|
-
colIndex: u,
|
|
844
|
-
value: v,
|
|
845
|
-
cellElement: w,
|
|
846
|
-
rowElement: e
|
|
847
|
-
});
|
|
848
|
-
continue;
|
|
849
|
-
}
|
|
850
|
-
if (d.__compiledView) {
|
|
851
|
-
const v = i[d.field], b = d.__compiledView({ row: i, value: v, field: d.field, column: d });
|
|
852
|
-
d.__compiledView.__blocked ? w.textContent = "" : (w.firstElementChild && t.__frameworkAdapter?.releaseCell?.(w), w.innerHTML = k(b), ge(w)), f && t._afterCellRender?.({
|
|
853
|
-
row: i,
|
|
854
|
-
rowIndex: o,
|
|
855
|
-
column: d,
|
|
856
|
-
colIndex: u,
|
|
857
|
-
value: v,
|
|
858
|
-
cellElement: w,
|
|
859
|
-
rowElement: e
|
|
860
|
-
});
|
|
861
|
-
continue;
|
|
862
|
-
}
|
|
863
|
-
if (d.__viewTemplate) {
|
|
864
|
-
const v = i[d.field], b = d.__viewTemplate.innerHTML;
|
|
865
|
-
/Reflect\.|\bProxy\b|ownKeys\(/.test(b) ? w.textContent = "" : (w.firstElementChild && t.__frameworkAdapter?.releaseCell?.(w), w.innerHTML = k(Ce(b, { row: i, value: v })), ge(w)), f && t._afterCellRender?.({
|
|
866
|
-
row: i,
|
|
867
|
-
rowIndex: o,
|
|
868
|
-
column: d,
|
|
869
|
-
colIndex: u,
|
|
870
|
-
value: v,
|
|
871
|
-
cellElement: w,
|
|
872
|
-
rowElement: e
|
|
873
|
-
});
|
|
874
|
-
continue;
|
|
875
|
-
}
|
|
876
|
-
if (d.externalView)
|
|
877
|
-
continue;
|
|
878
|
-
const E = i[d.field];
|
|
879
|
-
let x;
|
|
880
|
-
const y = Je(t, d);
|
|
881
|
-
if (y) {
|
|
882
|
-
try {
|
|
883
|
-
const v = y(E, i);
|
|
884
|
-
x = v == null ? "" : String(v);
|
|
885
|
-
} catch (v) {
|
|
886
|
-
console.warn(`[tbw-grid] Format error in column '${d.field}':`, v), x = E == null ? "" : String(E);
|
|
887
|
-
}
|
|
888
|
-
w.textContent = x;
|
|
889
|
-
} else d.type === "date" ? (x = Ke(E), w.textContent = x) : d.type === "boolean" ? w.innerHTML = je(!!E) : (x = E == null ? "" : String(E), w.textContent = x);
|
|
890
|
-
f && t._afterCellRender?.({
|
|
891
|
-
row: i,
|
|
892
|
-
rowIndex: o,
|
|
893
|
-
column: d,
|
|
894
|
-
colIndex: u,
|
|
895
|
-
value: E,
|
|
896
|
-
cellElement: w,
|
|
897
|
-
rowElement: e
|
|
898
|
-
});
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
function G(t, e, i, o) {
|
|
902
|
-
e.classList.remove("tbw-row-loading"), e.removeAttribute("aria-busy");
|
|
903
|
-
const n = t.__frameworkAdapter;
|
|
904
|
-
if (n?.releaseCell) {
|
|
905
|
-
const p = e.children;
|
|
906
|
-
for (let g = p.length - 1; g >= 0; g--)
|
|
907
|
-
n.releaseCell(p[g]);
|
|
908
|
-
}
|
|
909
|
-
e.innerHTML = "";
|
|
910
|
-
const r = t._visibleColumns, s = r.length, l = t._focusRow, a = t._focusCol, c = t, h = t._hasAfterCellRenderHook?.() ?? !1, f = document.createDocumentFragment();
|
|
911
|
-
for (let p = 0; p < s; p++) {
|
|
912
|
-
const g = r[p], u = Dt();
|
|
913
|
-
u.setAttribute("aria-colindex", String(p + 1)), u.setAttribute("data-col", String(p)), u.setAttribute("data-row", String(o)), u.setAttribute("data-field", g.field), u.setAttribute("data-header", g.header ?? g.field), g.type && u.setAttribute("data-type", g.type);
|
|
914
|
-
let d = i[g.field];
|
|
915
|
-
const w = Je(t, g);
|
|
916
|
-
if (w)
|
|
917
|
-
try {
|
|
918
|
-
d = w(d, i);
|
|
919
|
-
} catch (y) {
|
|
920
|
-
console.warn(`[tbw-grid] Format error in column '${g.field}':`, y);
|
|
921
|
-
}
|
|
922
|
-
const C = g.__compiledView, m = g.__viewTemplate, _ = Ze(t, g), R = g.externalView;
|
|
923
|
-
let E = !1;
|
|
924
|
-
if (_) {
|
|
925
|
-
const y = _({ row: i, value: d, field: g.field, column: g, cellEl: u });
|
|
926
|
-
typeof y == "string" ? (u.innerHTML = k(y), E = !0) : y instanceof Node ? y.parentElement !== u && (u.textContent = "", u.appendChild(y)) : y == null && (u.textContent = d == null ? "" : String(d));
|
|
927
|
-
} else if (R) {
|
|
928
|
-
const y = R, v = document.createElement("div");
|
|
929
|
-
v.setAttribute("data-external-view", ""), v.setAttribute("data-field", g.field), u.appendChild(v);
|
|
930
|
-
const b = { row: i, value: d, field: g.field, column: g };
|
|
931
|
-
if (y.mount)
|
|
932
|
-
try {
|
|
933
|
-
y.mount({ placeholder: v, context: b, spec: y });
|
|
934
|
-
} catch (T) {
|
|
935
|
-
console.warn(`[tbw-grid] External view mount error for column '${g.field}':`, T);
|
|
936
|
-
}
|
|
937
|
-
else
|
|
938
|
-
queueMicrotask(() => {
|
|
939
|
-
try {
|
|
940
|
-
c.dispatchEvent(
|
|
941
|
-
new CustomEvent("mount-external-view", {
|
|
942
|
-
bubbles: !0,
|
|
943
|
-
composed: !0,
|
|
944
|
-
detail: { placeholder: v, spec: y, context: b }
|
|
945
|
-
})
|
|
946
|
-
);
|
|
947
|
-
} catch (T) {
|
|
948
|
-
console.warn(`[tbw-grid] External view event dispatch error for column '${g.field}':`, T);
|
|
949
|
-
}
|
|
950
|
-
});
|
|
951
|
-
v.setAttribute("data-mounted", "");
|
|
952
|
-
} else if (C) {
|
|
953
|
-
const y = C({ row: i, value: d, field: g.field, column: g }), v = C.__blocked;
|
|
954
|
-
u.innerHTML = v ? "" : k(y), E = !0, v && (u.textContent = "", u.setAttribute("data-blocked-template", ""));
|
|
955
|
-
} else if (m) {
|
|
956
|
-
const y = m.innerHTML;
|
|
957
|
-
/Reflect\.|\bProxy\b|ownKeys\(/.test(y) ? (u.textContent = "", u.setAttribute("data-blocked-template", "")) : (u.innerHTML = k(Ce(y, { row: i, value: d })), E = !0);
|
|
958
|
-
} else
|
|
959
|
-
w ? u.textContent = d == null ? "" : String(d) : g.type === "date" ? u.textContent = Ke(d) : g.type === "boolean" ? u.innerHTML = je(!!d) : u.textContent = d == null ? "" : String(d);
|
|
960
|
-
if (E) {
|
|
961
|
-
ge(u);
|
|
962
|
-
const y = u.textContent || "";
|
|
963
|
-
/Proxy|Reflect\.ownKeys/.test(y) && (u.textContent = y.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(u.textContent || "") && (u.textContent = ""));
|
|
964
|
-
}
|
|
965
|
-
u.hasAttribute("data-blocked-template") && (u.textContent || "").trim().length && (u.textContent = ""), g.editable ? u.tabIndex = 0 : g.type === "boolean" && (u.hasAttribute("tabindex") || (u.tabIndex = 0)), l === o && a === p ? (u.classList.add("cell-focus"), u.setAttribute("aria-selected", "true")) : u.setAttribute("aria-selected", "false");
|
|
966
|
-
const x = g.cellClass;
|
|
967
|
-
if (x)
|
|
968
|
-
try {
|
|
969
|
-
const y = i[g.field], v = x(y, i, g);
|
|
970
|
-
if (v && v.length > 0) {
|
|
971
|
-
const b = v.filter((T) => T && typeof T == "string");
|
|
972
|
-
b.forEach((T) => u.classList.add(T)), u.setAttribute("data-dynamic-classes", b.join(" "));
|
|
973
|
-
}
|
|
974
|
-
} catch (y) {
|
|
975
|
-
console.warn(`[tbw-grid] cellClass callback error for column '${g.field}':`, y);
|
|
976
|
-
}
|
|
977
|
-
h && t._afterCellRender?.({
|
|
978
|
-
row: i,
|
|
979
|
-
rowIndex: o,
|
|
980
|
-
column: g,
|
|
981
|
-
colIndex: p,
|
|
982
|
-
value: d,
|
|
983
|
-
cellElement: u,
|
|
984
|
-
rowElement: e
|
|
985
|
-
}), f.appendChild(u);
|
|
986
|
-
}
|
|
987
|
-
e.appendChild(f);
|
|
988
|
-
}
|
|
989
|
-
function ze(t, e, i) {
|
|
990
|
-
if (e.target?.closest(".resize-handle")) return;
|
|
991
|
-
const o = i.querySelector(".cell[data-row]"), n = Qe(o);
|
|
992
|
-
if (n < 0) return;
|
|
993
|
-
const r = t._rows[n];
|
|
994
|
-
if (!r || t._dispatchRowClick?.(e, n, r, i))
|
|
995
|
-
return;
|
|
996
|
-
const s = e.target?.closest(".cell[data-col]");
|
|
997
|
-
if (s) {
|
|
998
|
-
const l = Number(s.getAttribute("data-col"));
|
|
999
|
-
if (!isNaN(l)) {
|
|
1000
|
-
if (t._dispatchCellClick?.(e, n, l, s))
|
|
1001
|
-
return;
|
|
1002
|
-
const a = t._focusRow !== n || t._focusCol !== l;
|
|
1003
|
-
if (t._focusRow = n, t._focusCol = l, s.classList.contains("editing")) {
|
|
1004
|
-
a && (_e(t._bodyEl ?? t), s.classList.add("cell-focus"));
|
|
1005
|
-
const c = s.querySelector(et);
|
|
1006
|
-
try {
|
|
1007
|
-
c?.focus({ preventScroll: !0 });
|
|
1008
|
-
} catch {
|
|
1009
|
-
}
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
F(t);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
function It(t, e) {
|
|
1017
|
-
if (t._dispatchKeyDown?.(e))
|
|
1018
|
-
return;
|
|
1019
|
-
const i = t._rows.length - 1, o = t._visibleColumns.length - 1, n = t._activeEditRows !== void 0 && t._activeEditRows !== -1, s = t._visibleColumns[t._focusCol]?.type, l = e.composedPath?.() ?? [], a = l.length ? l[0] : e.target, c = (h) => {
|
|
1020
|
-
if (!h) return !1;
|
|
1021
|
-
const f = h.tagName;
|
|
1022
|
-
return !!(f === "INPUT" || f === "SELECT" || f === "TEXTAREA" || h.isContentEditable);
|
|
1023
|
-
};
|
|
1024
|
-
if (!(c(a) && (e.key === "Home" || e.key === "End")) && !(c(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(c(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(c(a) && (e.key === "Enter" || e.key === "Escape")) && !(n && s === "select" && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
|
|
1025
|
-
switch (e.key) {
|
|
1026
|
-
case "Tab": {
|
|
1027
|
-
e.preventDefault(), !e.shiftKey ? t._focusCol < o ? t._focusCol += 1 : (typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow < i && (t._focusRow += 1, t._focusCol = 0)) : t._focusCol > 0 ? t._focusCol -= 1 : t._focusRow > 0 && (typeof t.commitActiveRowEdit == "function" && t._activeEditRows === t._focusRow && t.commitActiveRowEdit(), t._focusRow -= 1, t._focusCol = o), F(t);
|
|
1028
|
-
return;
|
|
1029
|
-
}
|
|
1030
|
-
case "ArrowDown":
|
|
1031
|
-
n && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = Math.min(i, t._focusRow + 1), e.preventDefault();
|
|
1032
|
-
break;
|
|
1033
|
-
case "ArrowUp":
|
|
1034
|
-
n && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = Math.max(0, t._focusRow - 1), e.preventDefault();
|
|
1035
|
-
break;
|
|
1036
|
-
case "ArrowRight": {
|
|
1037
|
-
Pe(t) ? t._focusCol = Math.max(0, t._focusCol - 1) : t._focusCol = Math.min(o, t._focusCol + 1), e.preventDefault();
|
|
1038
|
-
break;
|
|
1039
|
-
}
|
|
1040
|
-
case "ArrowLeft": {
|
|
1041
|
-
Pe(t) ? t._focusCol = Math.min(o, t._focusCol + 1) : t._focusCol = Math.max(0, t._focusCol - 1), e.preventDefault();
|
|
1042
|
-
break;
|
|
1043
|
-
}
|
|
1044
|
-
case "Home":
|
|
1045
|
-
(e.ctrlKey || e.metaKey) && (n && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = 0), t._focusCol = 0, e.preventDefault(), F(t, { forceScrollLeft: !0 });
|
|
1046
|
-
return;
|
|
1047
|
-
case "End":
|
|
1048
|
-
(e.ctrlKey || e.metaKey) && (n && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = i), t._focusCol = o, e.preventDefault(), F(t, { forceScrollRight: !0 });
|
|
1049
|
-
return;
|
|
1050
|
-
case "PageDown":
|
|
1051
|
-
t._focusRow = Math.min(i, t._focusRow + 20), e.preventDefault();
|
|
1052
|
-
break;
|
|
1053
|
-
case "PageUp":
|
|
1054
|
-
t._focusRow = Math.max(0, t._focusRow - 20), e.preventDefault();
|
|
1055
|
-
break;
|
|
1056
|
-
case "Enter": {
|
|
1057
|
-
const h = t._focusRow, f = t._focusCol, p = t._visibleColumns[f], g = t._rows[h], u = p?.field ?? "", d = u && g ? g[u] : void 0, w = t.querySelector(
|
|
1058
|
-
`[data-row="${h}"][data-col="${f}"]`
|
|
1059
|
-
), C = {
|
|
1060
|
-
rowIndex: h,
|
|
1061
|
-
colIndex: f,
|
|
1062
|
-
column: p,
|
|
1063
|
-
field: u,
|
|
1064
|
-
value: d,
|
|
1065
|
-
row: g,
|
|
1066
|
-
cellEl: w,
|
|
1067
|
-
trigger: "keyboard",
|
|
1068
|
-
originalEvent: e
|
|
1069
|
-
}, m = new CustomEvent("cell-activate", {
|
|
1070
|
-
cancelable: !0,
|
|
1071
|
-
detail: C
|
|
1072
|
-
});
|
|
1073
|
-
t.dispatchEvent(m);
|
|
1074
|
-
const _ = new CustomEvent("activate-cell", {
|
|
1075
|
-
cancelable: !0,
|
|
1076
|
-
detail: { row: h, col: f }
|
|
1077
|
-
});
|
|
1078
|
-
if (t.dispatchEvent(_), m.defaultPrevented || _.defaultPrevented) {
|
|
1079
|
-
e.preventDefault();
|
|
1080
|
-
return;
|
|
1081
|
-
}
|
|
1082
|
-
break;
|
|
1083
|
-
}
|
|
1084
|
-
default:
|
|
1085
|
-
return;
|
|
1086
|
-
}
|
|
1087
|
-
F(t);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
function F(t, e) {
|
|
1091
|
-
if (t._virtualization?.enabled) {
|
|
1092
|
-
const { rowHeight: s, container: l, viewportEl: a } = t._virtualization, c = l, h = a?.clientHeight ?? c?.clientHeight ?? 0;
|
|
1093
|
-
if (c && h > 0) {
|
|
1094
|
-
const f = t._focusRow * s;
|
|
1095
|
-
f < c.scrollTop ? c.scrollTop = f : f + s > c.scrollTop + h && (c.scrollTop = f - h + s);
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
const i = t._activeEditRows !== void 0 && t._activeEditRows !== -1;
|
|
1099
|
-
i || t.refreshVirtualWindow(!1), _e(t._bodyEl), Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
|
|
1100
|
-
s.setAttribute("aria-selected", "false");
|
|
1101
|
-
});
|
|
1102
|
-
const o = t._focusRow, n = t._virtualization.start ?? 0, r = t._virtualization.end ?? t._rows.length;
|
|
1103
|
-
if (o >= n && o < r) {
|
|
1104
|
-
const s = t._bodyEl.querySelectorAll(".data-grid-row")[o - n];
|
|
1105
|
-
let l = s?.children[t._focusCol];
|
|
1106
|
-
if ((!l || !l.classList?.contains("cell")) && (l = s?.querySelector(`.cell[data-col="${t._focusCol}"]`) ?? s?.querySelector(".cell[data-col]")), l) {
|
|
1107
|
-
l.classList.add("cell-focus"), l.setAttribute("aria-selected", "true");
|
|
1108
|
-
const a = t.querySelector(".tbw-scroll-area");
|
|
1109
|
-
if (a && l && (!i || e?.forceHorizontalScroll))
|
|
1110
|
-
if (e?.forceScrollLeft)
|
|
1111
|
-
a.scrollLeft = 0;
|
|
1112
|
-
else if (e?.forceScrollRight)
|
|
1113
|
-
a.scrollLeft = a.scrollWidth - a.clientWidth;
|
|
1114
|
-
else {
|
|
1115
|
-
const c = t._getHorizontalScrollOffsets?.(s ?? void 0, l) ?? { left: 0, right: 0 };
|
|
1116
|
-
if (!c.skipScroll) {
|
|
1117
|
-
const h = l.getBoundingClientRect(), f = a.getBoundingClientRect(), p = h.left - f.left + a.scrollLeft, g = p + h.width, u = a.scrollLeft + c.left, d = a.scrollLeft + a.clientWidth - c.right;
|
|
1118
|
-
p < u ? a.scrollLeft = p - c.left : g > d && (a.scrollLeft = g - a.clientWidth + c.right);
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
if (i && l.classList.contains("editing")) {
|
|
1122
|
-
const c = l.querySelector(et);
|
|
1123
|
-
if (c && document.activeElement !== c)
|
|
1124
|
-
try {
|
|
1125
|
-
c.focus({ preventScroll: !0 });
|
|
1126
|
-
} catch {
|
|
1127
|
-
}
|
|
1128
|
-
} else if (i && !l.contains(document.activeElement)) {
|
|
1129
|
-
l.hasAttribute("tabindex") || l.setAttribute("tabindex", "-1");
|
|
1130
|
-
try {
|
|
1131
|
-
l.focus({ preventScroll: !0 });
|
|
1132
|
-
} catch {
|
|
1133
|
-
}
|
|
1134
|
-
} else if (!i) {
|
|
1135
|
-
const c = t;
|
|
1136
|
-
document.activeElement !== c && c.focus({ preventScroll: !0 });
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
const ie = /* @__PURE__ */ new WeakMap();
|
|
1142
|
-
function Nt(t, e) {
|
|
1143
|
-
const i = Qe(e), o = zt(e);
|
|
1144
|
-
if (i < 0 || o < 0) return;
|
|
1145
|
-
t._focusRow = i, t._focusCol = o, _e(t._bodyEl), e.classList.add("cell-focus"), e.setAttribute("aria-selected", "true");
|
|
1146
|
-
const n = e.closest("tbw-grid");
|
|
1147
|
-
n && document.activeElement !== n && n.focus({ preventScroll: !0 });
|
|
1148
|
-
}
|
|
1149
|
-
function Ee(t, e, i, o) {
|
|
1150
|
-
let n = null;
|
|
1151
|
-
const r = i.composedPath?.();
|
|
1152
|
-
if (r && r.length > 0 ? n = r[0] : n = i.target, n && !e.contains(n)) {
|
|
1153
|
-
const d = document.elementFromPoint(i.clientX, i.clientY);
|
|
1154
|
-
d && (n = d);
|
|
1155
|
-
}
|
|
1156
|
-
const s = n?.closest?.("[data-col]"), l = n?.closest?.(".data-grid-row"), a = n?.closest?.(".header-row");
|
|
1157
|
-
let c, h, f, p, g, u;
|
|
1158
|
-
return s && (c = parseInt(s.getAttribute("data-row") ?? "-1", 10), h = parseInt(s.getAttribute("data-col") ?? "-1", 10), c >= 0 && h >= 0 && (f = t._rows[c], u = t._visibleColumns[h], p = u?.field, g = f && p ? f[p] : void 0)), {
|
|
1159
|
-
type: o,
|
|
1160
|
-
row: f,
|
|
1161
|
-
rowIndex: c !== void 0 && c >= 0 ? c : void 0,
|
|
1162
|
-
colIndex: h !== void 0 && h >= 0 ? h : void 0,
|
|
1163
|
-
field: p,
|
|
1164
|
-
value: g,
|
|
1165
|
-
column: u,
|
|
1166
|
-
originalEvent: i,
|
|
1167
|
-
cellElement: s ?? void 0,
|
|
1168
|
-
rowElement: l ?? void 0,
|
|
1169
|
-
isHeader: !!a,
|
|
1170
|
-
cell: c !== void 0 && h !== void 0 && c >= 0 && h >= 0 ? { row: c, col: h } : void 0
|
|
1171
|
-
};
|
|
1172
|
-
}
|
|
1173
|
-
function qt(t, e, i) {
|
|
1174
|
-
const o = Ee(t, e, i, "mousedown");
|
|
1175
|
-
(t._dispatchCellMouseDown?.(o) ?? !1) && ie.set(t, !0);
|
|
1176
|
-
}
|
|
1177
|
-
function $t(t, e, i) {
|
|
1178
|
-
if (!ie.get(t)) return;
|
|
1179
|
-
const o = Ee(t, e, i, "mousemove");
|
|
1180
|
-
t._dispatchCellMouseMove?.(o);
|
|
1181
|
-
}
|
|
1182
|
-
function Wt(t, e, i) {
|
|
1183
|
-
if (!ie.get(t)) return;
|
|
1184
|
-
const o = Ee(t, e, i, "mouseup");
|
|
1185
|
-
t._dispatchCellMouseUp?.(o), ie.set(t, !1);
|
|
1186
|
-
}
|
|
1187
|
-
function Ft(t, e, i) {
|
|
1188
|
-
e.addEventListener(
|
|
1189
|
-
"mousedown",
|
|
1190
|
-
(o) => {
|
|
1191
|
-
const n = o.target.closest(".cell[data-col]");
|
|
1192
|
-
n && (n.classList.contains("editing") || (o.preventDefault(), Nt(t, n)));
|
|
1193
|
-
},
|
|
1194
|
-
{ signal: i }
|
|
1195
|
-
), e.addEventListener(
|
|
1196
|
-
"click",
|
|
1197
|
-
(o) => {
|
|
1198
|
-
const n = o.target.closest(".data-grid-row");
|
|
1199
|
-
if (n && ze(t, o, n), !document.activeElement?.closest(".cell.editing")) {
|
|
1200
|
-
const r = o.target.closest("tbw-grid");
|
|
1201
|
-
r && r.focus({ preventScroll: !0 });
|
|
1202
|
-
}
|
|
1203
|
-
},
|
|
1204
|
-
{ signal: i }
|
|
1205
|
-
), e.addEventListener(
|
|
1206
|
-
"dblclick",
|
|
1207
|
-
(o) => {
|
|
1208
|
-
const n = o.target.closest(".data-grid-row");
|
|
1209
|
-
n && ze(t, o, n);
|
|
1210
|
-
},
|
|
1211
|
-
{ signal: i }
|
|
1212
|
-
);
|
|
1213
|
-
}
|
|
1214
|
-
function Vt(t, e, i, o) {
|
|
1215
|
-
e.addEventListener("keydown", (n) => It(t, n), { signal: o }), i.addEventListener("mousedown", (n) => qt(t, i, n), { signal: o }), document.addEventListener("mousemove", (n) => $t(t, i, n), { signal: o }), document.addEventListener("mouseup", (n) => Wt(t, i, n), { signal: o });
|
|
1216
|
-
}
|
|
1217
|
-
function Ut(t, e) {
|
|
1218
|
-
return t == null && e == null ? 0 : t == null ? -1 : e == null || t > e ? 1 : t < e ? -1 : 0;
|
|
1219
|
-
}
|
|
1220
|
-
function ot(t, e, i) {
|
|
1221
|
-
const n = i.find((l) => l.field === e.field)?.sortComparator ?? Ut, { field: r, direction: s } = e;
|
|
1222
|
-
return [...t].sort((l, a) => n(l[r], a[r], l, a) * s);
|
|
1223
|
-
}
|
|
1224
|
-
function Oe(t, e, i, o) {
|
|
1225
|
-
t._rows = e, t.__rowRenderEpoch++, t._rowPool.forEach((n) => n.__epoch = -1), oe(t), t.refreshVirtualWindow(!0), t.dispatchEvent(
|
|
1226
|
-
new CustomEvent("sort-change", { detail: { field: i.field, direction: o } })
|
|
1227
|
-
), t.requestStateChange?.();
|
|
1228
|
-
}
|
|
1229
|
-
function De(t, e) {
|
|
1230
|
-
!t._sortState || t._sortState.field !== e.field ? (t._sortState || (t.__originalOrder = t._rows.slice()), Me(t, e, 1)) : t._sortState.direction === 1 ? Me(t, e, -1) : (t._sortState = null, t.__rowRenderEpoch++, t._rowPool.forEach((o) => o.__epoch = -1), t._rows = t.__originalOrder.slice(), oe(t), t._headerRowEl?.querySelectorAll('[role="columnheader"].sortable')?.forEach((o) => {
|
|
1231
|
-
o.getAttribute("aria-sort") ? (o.getAttribute("aria-sort") === "ascending" || o.getAttribute("aria-sort") === "descending") && (t._sortState || o.setAttribute("aria-sort", "none")) : o.setAttribute("aria-sort", "none");
|
|
1232
|
-
}), t.refreshVirtualWindow(!0), t.dispatchEvent(
|
|
1233
|
-
new CustomEvent("sort-change", { detail: { field: e.field, direction: 0 } })
|
|
1234
|
-
), t.requestStateChange?.());
|
|
1235
|
-
}
|
|
1236
|
-
function Bt(t, e) {
|
|
1237
|
-
if (!t._sortState) return e;
|
|
1238
|
-
t.__originalOrder = [...e];
|
|
1239
|
-
const o = (t.effectiveConfig?.sortHandler ?? ot)(e, t._sortState, t._columns);
|
|
1240
|
-
return o && typeof o.then == "function" ? e : o;
|
|
1241
|
-
}
|
|
1242
|
-
function Me(t, e, i) {
|
|
1243
|
-
t._sortState = { field: e.field, direction: i };
|
|
1244
|
-
const o = { field: e.field, direction: i }, n = t._columns, s = (t.effectiveConfig?.sortHandler ?? ot)(t._rows, o, n);
|
|
1245
|
-
s && typeof s.then == "function" ? s.then((l) => {
|
|
1246
|
-
Oe(t, l, e, i);
|
|
1247
|
-
}) : Oe(t, s, e, i);
|
|
1248
|
-
}
|
|
1249
|
-
function V(t, e) {
|
|
1250
|
-
return t.effectiveConfig?.sortable !== !1 && e.sortable === !0;
|
|
1251
|
-
}
|
|
1252
|
-
function j(t, e) {
|
|
1253
|
-
return t.effectiveConfig?.resizable !== !1 && e.resizable !== !1;
|
|
1254
|
-
}
|
|
1255
|
-
function Gt(t, e) {
|
|
1256
|
-
typeof e == "string" ? t.textContent = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
|
|
1257
|
-
}
|
|
1258
|
-
function K(t, e) {
|
|
1259
|
-
const i = document.createElement("span");
|
|
1260
|
-
Ye(i, "sort-indicator");
|
|
1261
|
-
const o = t._sortState?.field === e.field ? t._sortState.direction : 0, n = { ...M, ...t.icons }, r = o === 1 ? n.sortAsc : o === -1 ? n.sortDesc : n.sortNone;
|
|
1262
|
-
return Gt(i, r), i;
|
|
1263
|
-
}
|
|
1264
|
-
function Q(t, e, i) {
|
|
1265
|
-
const o = document.createElement("div");
|
|
1266
|
-
return o.className = "resize-handle", o.setAttribute("aria-hidden", "true"), o.addEventListener("mousedown", (n) => {
|
|
1267
|
-
n.stopPropagation(), n.preventDefault(), t._resizeController.start(n, e, i);
|
|
1268
|
-
}), o.addEventListener("dblclick", (n) => {
|
|
1269
|
-
n.stopPropagation(), n.preventDefault(), t._resizeController.resetColumn(e);
|
|
1270
|
-
}), o;
|
|
1271
|
-
}
|
|
1272
|
-
function Z(t, e, i, o) {
|
|
1273
|
-
o.classList.add("sortable"), o.tabIndex = 0;
|
|
1274
|
-
const n = t._sortState?.field === e.field ? t._sortState.direction : 0;
|
|
1275
|
-
o.setAttribute("aria-sort", n === 0 ? "none" : n === 1 ? "ascending" : "descending"), o.addEventListener("click", (r) => {
|
|
1276
|
-
t._resizeController?.isResizing || t._dispatchHeaderClick?.(r, e, o) || De(t, e);
|
|
1277
|
-
}), o.addEventListener("keydown", (r) => {
|
|
1278
|
-
if (r.key === "Enter" || r.key === " ") {
|
|
1279
|
-
if (r.preventDefault(), t._dispatchHeaderClick?.(r, e, o)) return;
|
|
1280
|
-
De(t, e);
|
|
1281
|
-
}
|
|
1282
|
-
});
|
|
1283
|
-
}
|
|
1284
|
-
function Xt(t, e) {
|
|
1285
|
-
if (e != null)
|
|
1286
|
-
if (typeof e == "string") {
|
|
1287
|
-
const i = document.createElement("span");
|
|
1288
|
-
for (i.innerHTML = k(e); i.firstChild; )
|
|
1289
|
-
t.appendChild(i.firstChild);
|
|
1290
|
-
} else e instanceof Node && t.appendChild(e);
|
|
1291
|
-
}
|
|
1292
|
-
function oe(t) {
|
|
1293
|
-
t._headerRowEl = t.findHeaderRow();
|
|
1294
|
-
const e = t._headerRowEl;
|
|
1295
|
-
e && (e.innerHTML = "", t._visibleColumns.forEach((i, o) => {
|
|
1296
|
-
const n = document.createElement("div");
|
|
1297
|
-
n.className = "cell", Ye(n, "header-cell"), n.setAttribute("role", "columnheader"), n.setAttribute("aria-colindex", String(o + 1)), n.setAttribute("data-field", i.field), n.setAttribute("data-col", String(o)), i.type && n.setAttribute("data-type", i.type);
|
|
1298
|
-
const r = i.header ?? i.field, s = t._sortState?.field === i.field ? t._sortState.direction : 0, l = s === 1 ? "asc" : s === -1 ? "desc" : null;
|
|
1299
|
-
if (i.headerRenderer) {
|
|
1300
|
-
const a = {
|
|
1301
|
-
column: i,
|
|
1302
|
-
value: r,
|
|
1303
|
-
sortState: l,
|
|
1304
|
-
filterActive: !1,
|
|
1305
|
-
cellEl: n,
|
|
1306
|
-
renderSortIcon: () => V(t, i) ? K(t, i) : null,
|
|
1307
|
-
renderFilterButton: () => null
|
|
1308
|
-
}, c = i.headerRenderer(a);
|
|
1309
|
-
Xt(n, c), V(t, i) && Z(t, i, o, n), j(t, i) && (n.classList.add("resizable"), n.appendChild(Q(t, o, n)));
|
|
1310
|
-
} else if (i.headerLabelRenderer) {
|
|
1311
|
-
const a = {
|
|
1312
|
-
column: i,
|
|
1313
|
-
value: r
|
|
1314
|
-
}, c = i.headerLabelRenderer(a), h = document.createElement("span");
|
|
1315
|
-
c == null ? h.textContent = r : typeof c == "string" ? h.innerHTML = k(c) : c instanceof Node && h.appendChild(c), n.appendChild(h), V(t, i) && (Z(t, i, o, n), n.appendChild(K(t, i))), j(t, i) && (n.classList.add("resizable"), n.appendChild(Q(t, o, n)));
|
|
1316
|
-
} else if (i.__headerTemplate)
|
|
1317
|
-
Array.from(i.__headerTemplate.childNodes).forEach((a) => n.appendChild(a.cloneNode(!0))), V(t, i) && (Z(t, i, o, n), n.appendChild(K(t, i))), j(t, i) && (n.classList.add("resizable"), n.appendChild(Q(t, o, n)));
|
|
1318
|
-
else {
|
|
1319
|
-
const a = document.createElement("span");
|
|
1320
|
-
a.textContent = r, n.appendChild(a), V(t, i) && (Z(t, i, o, n), n.appendChild(K(t, i))), j(t, i) && (n.classList.add("resizable"), n.appendChild(Q(t, o, n)));
|
|
1321
|
-
}
|
|
1322
|
-
e.appendChild(n);
|
|
1323
|
-
}), e.querySelectorAll(".cell.sortable").forEach((i) => {
|
|
1324
|
-
i.getAttribute("aria-sort") || i.setAttribute("aria-sort", "none");
|
|
1325
|
-
}), e.children.length > 0 ? (e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1")) : (e.removeAttribute("role"), e.removeAttribute("aria-rowindex")));
|
|
1326
|
-
}
|
|
1327
|
-
const nt = typeof requestIdleCallback == "function";
|
|
1328
|
-
function Yt(t, e) {
|
|
1329
|
-
return nt ? requestIdleCallback(t, e) : window.setTimeout(() => {
|
|
1330
|
-
const i = Date.now();
|
|
1331
|
-
t({
|
|
1332
|
-
didTimeout: !1,
|
|
1333
|
-
timeRemaining: () => Math.max(0, 50 - (Date.now() - i))
|
|
1334
|
-
});
|
|
1335
|
-
}, 1);
|
|
1336
|
-
}
|
|
1337
|
-
function ke(t) {
|
|
1338
|
-
nt ? cancelIdleCallback(t) : clearTimeout(t);
|
|
1339
|
-
}
|
|
1340
|
-
function jt(t) {
|
|
1341
|
-
const e = document.createElement("div");
|
|
1342
|
-
return e.className = `tbw-spinner tbw-spinner--${t}`, e.setAttribute("role", "progressbar"), e.setAttribute("aria-label", "Loading"), e;
|
|
1343
|
-
}
|
|
1344
|
-
function Kt(t, e) {
|
|
1345
|
-
if (e) {
|
|
1346
|
-
const o = e({ size: t });
|
|
1347
|
-
if (typeof o == "string") {
|
|
1348
|
-
const n = document.createElement("div");
|
|
1349
|
-
return n.innerHTML = o, n;
|
|
1350
|
-
}
|
|
1351
|
-
return o;
|
|
1352
|
-
}
|
|
1353
|
-
return jt(t);
|
|
1354
|
-
}
|
|
1355
|
-
function Qt(t) {
|
|
1356
|
-
const e = document.createElement("div");
|
|
1357
|
-
return e.className = "tbw-loading-overlay", e.setAttribute("role", "status"), e.setAttribute("aria-live", "polite"), e.appendChild(Kt("large", t)), e;
|
|
1358
|
-
}
|
|
1359
|
-
function Zt(t, e) {
|
|
1360
|
-
t.appendChild(e);
|
|
1361
|
-
}
|
|
1362
|
-
function Jt(t) {
|
|
1363
|
-
t?.remove();
|
|
1364
|
-
}
|
|
1365
|
-
function ei(t, e) {
|
|
1366
|
-
if (e) {
|
|
1367
|
-
if (t.classList.add("tbw-row-loading"), t.setAttribute("aria-busy", "true"), !t.querySelector(".tbw-row-loading-overlay")) {
|
|
1368
|
-
const i = document.createElement("div");
|
|
1369
|
-
i.className = "tbw-row-loading-overlay", i.setAttribute("aria-hidden", "true");
|
|
1370
|
-
const o = document.createElement("div");
|
|
1371
|
-
o.className = "tbw-row-loading-spinner", i.appendChild(o), t.appendChild(i);
|
|
1372
|
-
}
|
|
1373
|
-
} else
|
|
1374
|
-
t.classList.remove("tbw-row-loading"), t.removeAttribute("aria-busy"), t.querySelector(".tbw-row-loading-overlay")?.remove();
|
|
1375
|
-
}
|
|
1376
|
-
function ti(t, e) {
|
|
1377
|
-
e ? (t.classList.add("tbw-cell-loading"), t.setAttribute("aria-busy", "true")) : (t.classList.remove("tbw-cell-loading"), t.removeAttribute("aria-busy"));
|
|
1378
|
-
}
|
|
1379
|
-
var A = ((t) => (t[t.STYLE = 1] = "STYLE", t[t.VIRTUALIZATION = 2] = "VIRTUALIZATION", t[t.HEADER = 3] = "HEADER", t[t.ROWS = 4] = "ROWS", t[t.COLUMNS = 5] = "COLUMNS", t[t.FULL = 6] = "FULL", t))(A || {});
|
|
1380
|
-
class ii {
|
|
1381
|
-
#a;
|
|
1382
|
-
#n = 0;
|
|
1383
|
-
#u = 0;
|
|
1384
|
-
#d = null;
|
|
1385
|
-
#h = null;
|
|
1386
|
-
#l = null;
|
|
1387
|
-
#o = !1;
|
|
1388
|
-
constructor(e) {
|
|
1389
|
-
this.#a = e;
|
|
1390
|
-
}
|
|
1391
|
-
requestPhase(e, i) {
|
|
1392
|
-
e > this.#n && (this.#n = e), this.#u === 0 && (this.#f(), this.#u = requestAnimationFrame(() => this.#w()));
|
|
1393
|
-
}
|
|
1394
|
-
whenReady() {
|
|
1395
|
-
return this.#d ? this.#d : Promise.resolve();
|
|
1396
|
-
}
|
|
1397
|
-
setInitialReadyResolver(e) {
|
|
1398
|
-
this.#l = e;
|
|
1399
|
-
}
|
|
1400
|
-
cancel() {
|
|
1401
|
-
this.#u !== 0 && (cancelAnimationFrame(this.#u), this.#u = 0), this.#n = 0, this.#h && (this.#h(), this.#h = null, this.#d = null);
|
|
1402
|
-
}
|
|
1403
|
-
get isPending() {
|
|
1404
|
-
return this.#n !== 0;
|
|
1405
|
-
}
|
|
1406
|
-
get pendingPhase() {
|
|
1407
|
-
return this.#n;
|
|
1408
|
-
}
|
|
1409
|
-
#f() {
|
|
1410
|
-
this.#d || (this.#d = new Promise((e) => {
|
|
1411
|
-
this.#h = e;
|
|
1412
|
-
}));
|
|
1413
|
-
}
|
|
1414
|
-
#w() {
|
|
1415
|
-
if (this.#u = 0, !this.#a.isConnected()) {
|
|
1416
|
-
this.#n = 0, this.#h && (this.#h(), this.#h = null, this.#d = null);
|
|
1417
|
-
return;
|
|
1418
|
-
}
|
|
1419
|
-
const e = this.#n;
|
|
1420
|
-
this.#n = 0, e >= 5 && this.#a.mergeConfig(), e >= 4 && this.#a.processRows(), e >= 5 && (this.#a.processColumns(), this.#a.updateTemplate()), e >= 3 && this.#a.renderHeader(), e >= 2 && this.#a.renderVirtualWindow(), e >= 1 && this.#a.afterRender(), !this.#o && this.#l && (this.#o = !0, this.#l()), this.#h && (this.#h(), this.#h = null, this.#d = null);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
function Ie(t) {
|
|
1424
|
-
let e = null, i = null, o = null, n = null;
|
|
1425
|
-
const r = (a) => {
|
|
1426
|
-
if (!e) return;
|
|
1427
|
-
const c = a.clientX - e.startX, h = Math.max(40, e.startWidth + c), f = t._visibleColumns[e.colIndex];
|
|
1428
|
-
f.width = h, f.__userResized = !0, f.__renderedWidth = h, i == null && (i = requestAnimationFrame(() => {
|
|
1429
|
-
i = null, t.updateTemplate?.();
|
|
1430
|
-
})), t.dispatchEvent(
|
|
1431
|
-
new CustomEvent("column-resize", { detail: { field: f.field, width: h } })
|
|
1432
|
-
);
|
|
1433
|
-
};
|
|
1434
|
-
let s = !1;
|
|
1435
|
-
const l = () => {
|
|
1436
|
-
const a = e !== null;
|
|
1437
|
-
a && (s = !0, requestAnimationFrame(() => {
|
|
1438
|
-
s = !1;
|
|
1439
|
-
})), window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", l), o !== null && (document.documentElement.style.cursor = o, o = null), n !== null && (document.body.style.userSelect = n, n = null), e = null, a && t.requestStateChange && t.requestStateChange();
|
|
1440
|
-
};
|
|
1441
|
-
return {
|
|
1442
|
-
get isResizing() {
|
|
1443
|
-
return e !== null || s;
|
|
1444
|
-
},
|
|
1445
|
-
start(a, c, h) {
|
|
1446
|
-
a.preventDefault();
|
|
1447
|
-
const f = t._visibleColumns[c], p = typeof f?.width == "number" ? f.width : void 0, g = f?.__renderedWidth ?? p ?? h.getBoundingClientRect().width;
|
|
1448
|
-
e = { startX: a.clientX, colIndex: c, startWidth: g }, window.addEventListener("mousemove", r), window.addEventListener("mouseup", l), o === null && (o = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", n === null && (n = document.body.style.userSelect), document.body.style.userSelect = "none";
|
|
1449
|
-
},
|
|
1450
|
-
resetColumn(a) {
|
|
1451
|
-
const c = t._visibleColumns[a];
|
|
1452
|
-
c && (c.__userResized = !1, c.__renderedWidth = void 0, c.width = c.__originalWidth, t.updateTemplate?.(), t.requestStateChange?.(), t.dispatchEvent(
|
|
1453
|
-
new CustomEvent("column-resize-reset", { detail: { field: c.field, width: c.width } })
|
|
1454
|
-
));
|
|
1455
|
-
},
|
|
1456
|
-
dispose() {
|
|
1457
|
-
l();
|
|
1458
|
-
}
|
|
1459
|
-
};
|
|
1460
|
-
}
|
|
1461
|
-
const ce = "data-animating", oi = {
|
|
1462
|
-
change: "--tbw-row-change-duration",
|
|
1463
|
-
insert: "--tbw-row-insert-duration",
|
|
1464
|
-
remove: "--tbw-row-remove-duration"
|
|
1465
|
-
}, ni = {
|
|
1466
|
-
change: 500,
|
|
1467
|
-
insert: 300,
|
|
1468
|
-
remove: 200
|
|
1469
|
-
};
|
|
1470
|
-
function ri(t) {
|
|
1471
|
-
const e = t.trim().toLowerCase();
|
|
1472
|
-
return e.endsWith("ms") ? parseFloat(e) : e.endsWith("s") ? parseFloat(e) * 1e3 : parseFloat(e);
|
|
1473
|
-
}
|
|
1474
|
-
function si(t, e) {
|
|
1475
|
-
const i = oi[e], o = getComputedStyle(t).getPropertyValue(i);
|
|
1476
|
-
if (o) {
|
|
1477
|
-
const n = ri(o);
|
|
1478
|
-
if (!isNaN(n) && n > 0)
|
|
1479
|
-
return n;
|
|
1480
|
-
}
|
|
1481
|
-
return ni[e];
|
|
1482
|
-
}
|
|
1483
|
-
function li(t, e, i) {
|
|
1484
|
-
t.removeAttribute(ce), t.offsetWidth, t.setAttribute(ce, e);
|
|
1485
|
-
const o = si(t, e);
|
|
1486
|
-
setTimeout(() => {
|
|
1487
|
-
e !== "remove" && t.removeAttribute(ce), i?.();
|
|
1488
|
-
}, o);
|
|
1489
|
-
}
|
|
1490
|
-
function Se(t, e, i) {
|
|
1491
|
-
if (e < 0)
|
|
1492
|
-
return Promise.resolve(!1);
|
|
1493
|
-
const o = t.findRenderedRowElement?.(e);
|
|
1494
|
-
return o ? new Promise((n) => {
|
|
1495
|
-
li(o, i, () => n(!0));
|
|
1496
|
-
}) : Promise.resolve(!1);
|
|
1497
|
-
}
|
|
1498
|
-
function ai(t, e, i) {
|
|
1499
|
-
return Promise.all(e.map((o) => Se(t, o, i))).then(
|
|
1500
|
-
(o) => o.filter(Boolean).length
|
|
1501
|
-
);
|
|
1502
|
-
}
|
|
1503
|
-
function ci(t, e, i) {
|
|
1504
|
-
const o = t._rows ?? [], n = t.getRowId;
|
|
1505
|
-
if (!n)
|
|
1506
|
-
return Promise.resolve(!1);
|
|
1507
|
-
const r = o.findIndex((s) => {
|
|
1508
|
-
if (s == null) return !1;
|
|
1509
|
-
try {
|
|
1510
|
-
return n(s) === e;
|
|
1511
|
-
} catch {
|
|
1512
|
-
return !1;
|
|
1513
|
-
}
|
|
1514
|
-
});
|
|
1515
|
-
return r < 0 ? Promise.resolve(!1) : Se(t, r, i);
|
|
1516
|
-
}
|
|
1517
|
-
function J(t, e, i) {
|
|
1518
|
-
const o = document.createElement(t);
|
|
1519
|
-
if (e)
|
|
1520
|
-
for (const n in e) {
|
|
1521
|
-
const r = e[n];
|
|
1522
|
-
r != null && o.setAttribute(n, r);
|
|
1523
|
-
}
|
|
1524
|
-
return o;
|
|
1525
|
-
}
|
|
1526
|
-
function P(t, e) {
|
|
1527
|
-
const i = document.createElement("div");
|
|
1528
|
-
if (t && (i.className = t), e)
|
|
1529
|
-
for (const o in e) {
|
|
1530
|
-
const n = e[o];
|
|
1531
|
-
n != null && i.setAttribute(o, n);
|
|
1532
|
-
}
|
|
1533
|
-
return i;
|
|
1534
|
-
}
|
|
1535
|
-
function rt(t, e, i) {
|
|
1536
|
-
const o = document.createElement("button");
|
|
1537
|
-
if (t && (o.className = t), e)
|
|
1538
|
-
for (const n in e) {
|
|
1539
|
-
const r = e[n];
|
|
1540
|
-
r != null && o.setAttribute(n, r);
|
|
1541
|
-
}
|
|
1542
|
-
return o;
|
|
1543
|
-
}
|
|
1544
|
-
const st = document.createElement("template");
|
|
1545
|
-
st.innerHTML = `
|
|
1546
|
-
<div class="tbw-scroll-area">
|
|
1547
|
-
<div class="rows-body-wrapper">
|
|
1548
|
-
<div class="rows-body" role="grid">
|
|
1549
|
-
<div class="header" role="rowgroup">
|
|
1550
|
-
<div class="header-row" role="row" part="header-row"></div>
|
|
1551
|
-
</div>
|
|
1552
|
-
<div class="rows-container" role="presentation">
|
|
1553
|
-
<div class="rows-viewport" role="presentation">
|
|
1554
|
-
<div class="rows"></div>
|
|
1555
|
-
</div>
|
|
1556
|
-
</div>
|
|
1557
|
-
</div>
|
|
1558
|
-
</div>
|
|
1559
|
-
</div>
|
|
1560
|
-
<div class="faux-vscroll">
|
|
1561
|
-
<div class="faux-vscroll-spacer"></div>
|
|
1562
|
-
</div>
|
|
1563
|
-
`;
|
|
1564
|
-
function lt() {
|
|
1565
|
-
return st.content.cloneNode(!0);
|
|
1566
|
-
}
|
|
1567
|
-
function Ne(t) {
|
|
1568
|
-
const e = document.createDocumentFragment(), i = P(t.hasShell ? "tbw-grid-root has-shell" : "tbw-grid-root");
|
|
1569
|
-
if (t.hasShell && t.shellHeader && t.shellBody)
|
|
1570
|
-
i.appendChild(t.shellHeader), i.appendChild(t.shellBody);
|
|
1571
|
-
else {
|
|
1572
|
-
const o = P("tbw-grid-content");
|
|
1573
|
-
o.appendChild(lt()), i.appendChild(o);
|
|
1574
|
-
}
|
|
1575
|
-
return e.appendChild(i), e;
|
|
1576
|
-
}
|
|
1577
|
-
function di(t) {
|
|
1578
|
-
const e = P("tbw-shell-header", { part: "shell-header", role: "presentation" });
|
|
1579
|
-
if (t.title) {
|
|
1580
|
-
const r = P("tbw-shell-title");
|
|
1581
|
-
r.textContent = t.title, e.appendChild(r);
|
|
1582
|
-
}
|
|
1583
|
-
const i = P("tbw-shell-content", {
|
|
1584
|
-
part: "shell-content",
|
|
1585
|
-
role: "presentation",
|
|
1586
|
-
"data-light-dom-header-content": ""
|
|
1587
|
-
});
|
|
1588
|
-
e.appendChild(i);
|
|
1589
|
-
const o = P("tbw-shell-toolbar", { part: "shell-toolbar", role: "presentation" });
|
|
1590
|
-
for (const r of t.configButtons)
|
|
1591
|
-
r.hasRender && o.appendChild(P("tbw-toolbar-content-slot", { "data-toolbar-content": r.id }));
|
|
1592
|
-
for (const r of t.apiButtons)
|
|
1593
|
-
r.hasRender && o.appendChild(P("tbw-toolbar-content-slot", { "data-toolbar-content": r.id }));
|
|
1594
|
-
if ((t.configButtons.some((r) => r.hasRender) || t.apiButtons.some((r) => r.hasRender)) && t.hasPanels && o.appendChild(P("tbw-toolbar-separator")), t.hasPanels) {
|
|
1595
|
-
const r = rt(t.isPanelOpen ? "tbw-toolbar-btn active" : "tbw-toolbar-btn", {
|
|
1596
|
-
"data-panel-toggle": "",
|
|
1597
|
-
title: "Settings",
|
|
1598
|
-
"aria-label": "Toggle settings panel",
|
|
1599
|
-
"aria-pressed": String(t.isPanelOpen),
|
|
1600
|
-
"aria-controls": "tbw-tool-panel"
|
|
1601
|
-
});
|
|
1602
|
-
r.innerHTML = t.toolPanelIcon, o.appendChild(r);
|
|
1603
|
-
}
|
|
1604
|
-
return e.appendChild(o), e;
|
|
1605
|
-
}
|
|
1606
|
-
function hi(t) {
|
|
1607
|
-
const e = P("tbw-shell-body"), i = t.panels.length > 0, o = t.panels.length === 1, n = P("tbw-grid-content");
|
|
1608
|
-
n.appendChild(lt());
|
|
1609
|
-
let r = null;
|
|
1610
|
-
if (i) {
|
|
1611
|
-
r = J("aside", {
|
|
1612
|
-
class: t.isPanelOpen ? "tbw-tool-panel open" : "tbw-tool-panel",
|
|
1613
|
-
part: "tool-panel",
|
|
1614
|
-
"data-position": t.position,
|
|
1615
|
-
role: "presentation",
|
|
1616
|
-
id: "tbw-tool-panel"
|
|
1617
|
-
});
|
|
1618
|
-
const s = t.position === "left" ? "right" : "left";
|
|
1619
|
-
r.appendChild(
|
|
1620
|
-
P("tbw-tool-panel-resize", {
|
|
1621
|
-
"data-resize-handle": "",
|
|
1622
|
-
"data-handle-position": s,
|
|
1623
|
-
"aria-hidden": "true"
|
|
1624
|
-
})
|
|
1625
|
-
);
|
|
1626
|
-
const l = P("tbw-tool-panel-content", { role: "presentation" }), a = P("tbw-accordion");
|
|
1627
|
-
for (const c of t.panels) {
|
|
1628
|
-
const h = `tbw-accordion-section${c.isExpanded ? " expanded" : ""}${o ? " single" : ""}`, f = P(h, { "data-section": c.id }), p = rt("tbw-accordion-header", {
|
|
1629
|
-
"aria-expanded": String(c.isExpanded),
|
|
1630
|
-
"aria-controls": `tbw-section-${c.id}`
|
|
1631
|
-
});
|
|
1632
|
-
if (o && p.setAttribute("aria-disabled", "true"), c.icon) {
|
|
1633
|
-
const u = J("span", { class: "tbw-accordion-icon" });
|
|
1634
|
-
u.innerHTML = c.icon, p.appendChild(u);
|
|
1635
|
-
}
|
|
1636
|
-
const g = J("span", { class: "tbw-accordion-title" });
|
|
1637
|
-
if (g.textContent = c.title, p.appendChild(g), !o) {
|
|
1638
|
-
const u = J("span", { class: "tbw-accordion-chevron" });
|
|
1639
|
-
u.innerHTML = c.isExpanded ? t.collapseIcon : t.expandIcon, p.appendChild(u);
|
|
1640
|
-
}
|
|
1641
|
-
f.appendChild(p), f.appendChild(
|
|
1642
|
-
P("tbw-accordion-content", {
|
|
1643
|
-
id: `tbw-section-${c.id}`,
|
|
1644
|
-
role: "presentation"
|
|
1645
|
-
})
|
|
1646
|
-
), a.appendChild(f);
|
|
1647
|
-
}
|
|
1648
|
-
l.appendChild(a), r.appendChild(l);
|
|
1649
|
-
}
|
|
1650
|
-
return t.position === "left" && r ? (e.appendChild(r), e.appendChild(n)) : (e.appendChild(n), r && e.appendChild(r)), e;
|
|
1651
|
-
}
|
|
1652
|
-
function q(t) {
|
|
1653
|
-
return t ? typeof t == "string" ? t : t.outerHTML : "";
|
|
1654
|
-
}
|
|
1655
|
-
function ui() {
|
|
1656
|
-
return {
|
|
1657
|
-
toolPanels: /* @__PURE__ */ new Map(),
|
|
1658
|
-
headerContents: /* @__PURE__ */ new Map(),
|
|
1659
|
-
toolbarContents: /* @__PURE__ */ new Map(),
|
|
1660
|
-
hasToolButtonsContainer: !1,
|
|
1661
|
-
lightDomHeaderContent: [],
|
|
1662
|
-
lightDomTitle: null,
|
|
1663
|
-
lightDomToolPanelIds: /* @__PURE__ */ new Set(),
|
|
1664
|
-
lightDomToolbarContentIds: /* @__PURE__ */ new Set(),
|
|
1665
|
-
apiToolPanelIds: /* @__PURE__ */ new Set(),
|
|
1666
|
-
isPanelOpen: !1,
|
|
1667
|
-
expandedSections: /* @__PURE__ */ new Set(),
|
|
1668
|
-
headerContentCleanups: /* @__PURE__ */ new Map(),
|
|
1669
|
-
panelCleanups: /* @__PURE__ */ new Map(),
|
|
1670
|
-
toolbarContentCleanups: /* @__PURE__ */ new Map(),
|
|
1671
|
-
lightDomContentMoved: !1
|
|
1672
|
-
};
|
|
1673
|
-
}
|
|
1674
|
-
function at(t) {
|
|
1675
|
-
return !!(t?.header?.title || t?.header?.toolbarContents?.length || t?.toolPanels?.length || t?.headerContents?.length || t?.header?.lightDomContent?.length || t?.header?.hasToolButtonsContainer);
|
|
1676
|
-
}
|
|
1677
|
-
function fi(t, e, i = "☰") {
|
|
1678
|
-
const o = t?.header?.title ?? e.lightDomTitle ?? "", n = !!o, r = q(i), s = t?.header?.toolbarContents ?? [], l = [...e.toolbarContents.values()], a = new Set(s.map((d) => d.id)), c = [...s];
|
|
1679
|
-
for (const d of l)
|
|
1680
|
-
a.has(d.id) || c.push(d);
|
|
1681
|
-
const h = c.length > 0, f = e.toolPanels.size > 0, p = h && f, g = [...c].sort((d, w) => (d.order ?? 0) - (w.order ?? 0));
|
|
1682
|
-
let u = "";
|
|
1683
|
-
for (const d of g)
|
|
1684
|
-
u += `<div class="tbw-toolbar-content-slot" data-toolbar-content="${d.id}"></div>`;
|
|
1685
|
-
if (p && (u += '<div class="tbw-toolbar-separator"></div>'), f) {
|
|
1686
|
-
const d = e.isPanelOpen;
|
|
1687
|
-
u += `<button class="${d ? "tbw-toolbar-btn active" : "tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${d}" aria-controls="tbw-tool-panel">${r}</button>`;
|
|
1688
|
-
}
|
|
1689
|
-
return `
|
|
1690
|
-
<div class="tbw-shell-header" part="shell-header" role="presentation">
|
|
1691
|
-
${n ? `<div class="tbw-shell-title">${Et(o)}</div>` : ""}
|
|
1692
|
-
<div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>
|
|
1693
|
-
<div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">
|
|
1694
|
-
${u}
|
|
1695
|
-
</div>
|
|
1696
|
-
</div>
|
|
1697
|
-
`;
|
|
1698
|
-
}
|
|
1699
|
-
function qe(t, e) {
|
|
1700
|
-
const i = t.querySelector("tbw-grid-header");
|
|
1701
|
-
if (!i) return;
|
|
1702
|
-
if (!e.lightDomTitle) {
|
|
1703
|
-
const n = i.getAttribute("title");
|
|
1704
|
-
n && (e.lightDomTitle = n);
|
|
1705
|
-
}
|
|
1706
|
-
const o = i.querySelectorAll("tbw-grid-header-content");
|
|
1707
|
-
o.length > 0 && e.lightDomHeaderContent.length === 0 && (e.lightDomHeaderContent = Array.from(o)), i.style.display = "none";
|
|
1708
|
-
}
|
|
1709
|
-
function $e(t, e, i) {
|
|
1710
|
-
const o = t.querySelector(":scope > tbw-grid-tool-buttons");
|
|
1711
|
-
if (!o) return;
|
|
1712
|
-
e.hasToolButtonsContainer = !0;
|
|
1713
|
-
const n = "light-dom-toolbar-content";
|
|
1714
|
-
if (e.lightDomToolbarContentIds.has(n)) return;
|
|
1715
|
-
const r = {
|
|
1716
|
-
id: n,
|
|
1717
|
-
order: 0,
|
|
1718
|
-
render: ((s) => {
|
|
1719
|
-
for (; o.firstChild; )
|
|
1720
|
-
s.appendChild(o.firstChild);
|
|
1721
|
-
return () => {
|
|
1722
|
-
for (; s.firstChild; )
|
|
1723
|
-
o.appendChild(s.firstChild);
|
|
1724
|
-
};
|
|
1725
|
-
})
|
|
1726
|
-
};
|
|
1727
|
-
e.toolbarContents.set(n, r), e.lightDomToolbarContentIds.add(n), o.style.display = "none";
|
|
1728
|
-
}
|
|
1729
|
-
function We(t, e, i) {
|
|
1730
|
-
t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach((n) => {
|
|
1731
|
-
const r = n, s = r.getAttribute("id"), l = r.getAttribute("title");
|
|
1732
|
-
if (!s || !l) {
|
|
1733
|
-
console.warn(
|
|
1734
|
-
`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s ?? ""}", title="${l ?? ""}"`
|
|
1735
|
-
);
|
|
1736
|
-
return;
|
|
1737
|
-
}
|
|
1738
|
-
const a = r.getAttribute("icon") ?? void 0, c = r.getAttribute("tooltip") ?? void 0, h = parseInt(r.getAttribute("order") ?? "100", 10);
|
|
1739
|
-
let f;
|
|
1740
|
-
const p = i?.(r);
|
|
1741
|
-
if (p)
|
|
1742
|
-
f = p;
|
|
1743
|
-
else {
|
|
1744
|
-
const d = r.innerHTML.trim();
|
|
1745
|
-
f = (w) => {
|
|
1746
|
-
const C = document.createElement("div");
|
|
1747
|
-
return C.innerHTML = d, w.appendChild(C), () => C.remove();
|
|
1748
|
-
};
|
|
1749
|
-
}
|
|
1750
|
-
const g = e.toolPanels.get(s);
|
|
1751
|
-
if (g) {
|
|
1752
|
-
if (p) {
|
|
1753
|
-
g.render = f, g.order = h, g.icon = a, g.tooltip = c;
|
|
1754
|
-
const d = e.panelCleanups.get(s);
|
|
1755
|
-
d && (d(), e.panelCleanups.delete(s));
|
|
1756
|
-
}
|
|
1757
|
-
return;
|
|
1758
|
-
}
|
|
1759
|
-
const u = {
|
|
1760
|
-
id: s,
|
|
1761
|
-
title: l,
|
|
1762
|
-
icon: a,
|
|
1763
|
-
tooltip: c,
|
|
1764
|
-
order: h,
|
|
1765
|
-
render: f
|
|
1766
|
-
};
|
|
1767
|
-
e.toolPanels.set(s, u), e.lightDomToolPanelIds.add(s), r.style.display = "none";
|
|
1768
|
-
});
|
|
1769
|
-
}
|
|
1770
|
-
function gi(t, e, i, o) {
|
|
1771
|
-
const n = t.querySelector(".tbw-shell-toolbar");
|
|
1772
|
-
n && n.addEventListener("click", (s) => {
|
|
1773
|
-
if (s.target.closest("[data-panel-toggle]")) {
|
|
1774
|
-
o.onPanelToggle();
|
|
1775
|
-
return;
|
|
1776
|
-
}
|
|
1777
|
-
});
|
|
1778
|
-
const r = t.querySelector(".tbw-accordion");
|
|
1779
|
-
r && r.addEventListener("click", (s) => {
|
|
1780
|
-
const a = s.target.closest(".tbw-accordion-header");
|
|
1781
|
-
if (a) {
|
|
1782
|
-
const h = a.closest("[data-section]")?.getAttribute("data-section");
|
|
1783
|
-
h && o.onSectionToggle(h);
|
|
1784
|
-
}
|
|
1785
|
-
});
|
|
1786
|
-
}
|
|
1787
|
-
function pi(t, e, i, o) {
|
|
1788
|
-
if (!e?.toolPanel?.closeOnClickOutside)
|
|
1789
|
-
return () => {
|
|
1790
|
-
};
|
|
1791
|
-
const n = (r) => {
|
|
1792
|
-
if (!i.isPanelOpen) return;
|
|
1793
|
-
const s = r.target;
|
|
1794
|
-
s && (s.closest(".tbw-tool-panel") || s.closest("[data-panel-toggle]") || o());
|
|
1795
|
-
};
|
|
1796
|
-
return t.addEventListener("mousedown", n), () => t.removeEventListener("mousedown", n);
|
|
1797
|
-
}
|
|
1798
|
-
function wi(t, e, i) {
|
|
1799
|
-
const o = t.querySelector(".tbw-tool-panel"), n = t.querySelector("[data-resize-handle]"), r = t.querySelector(".tbw-shell-body");
|
|
1800
|
-
if (!o || !n || !r)
|
|
1801
|
-
return () => {
|
|
1802
|
-
};
|
|
1803
|
-
const s = e?.toolPanel?.position ?? "right", l = 200;
|
|
1804
|
-
let a = 0, c = 0, h = 0, f = !1;
|
|
1805
|
-
const p = (d) => {
|
|
1806
|
-
if (!f) return;
|
|
1807
|
-
d.preventDefault();
|
|
1808
|
-
const w = s === "left" ? d.clientX - a : a - d.clientX, C = Math.min(h, Math.max(l, c + w));
|
|
1809
|
-
o.style.width = `${C}px`;
|
|
1810
|
-
}, g = () => {
|
|
1811
|
-
if (!f) return;
|
|
1812
|
-
f = !1, n.classList.remove("resizing"), o.style.transition = "", document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
1813
|
-
const d = o.getBoundingClientRect().width;
|
|
1814
|
-
i(d), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g);
|
|
1815
|
-
}, u = (d) => {
|
|
1816
|
-
d.preventDefault(), f = !0, a = d.clientX, c = o.getBoundingClientRect().width, h = r.getBoundingClientRect().width - 20, n.classList.add("resizing"), o.style.transition = "none", document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("mousemove", p), document.addEventListener("mouseup", g);
|
|
1817
|
-
};
|
|
1818
|
-
return n.addEventListener("mousedown", u), () => {
|
|
1819
|
-
n.removeEventListener("mousedown", u), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", g);
|
|
1820
|
-
};
|
|
1821
|
-
}
|
|
1822
|
-
function de(t, e, i) {
|
|
1823
|
-
const o = e?.header?.toolbarContents ?? [], n = [...i.toolbarContents.values()], r = new Set(o.map((l) => l.id)), s = [...o];
|
|
1824
|
-
for (const l of n)
|
|
1825
|
-
r.has(l.id) || s.push(l);
|
|
1826
|
-
for (const l of s) {
|
|
1827
|
-
if (i.toolbarContentCleanups.has(l.id) || !l.render) continue;
|
|
1828
|
-
const a = t.querySelector(`[data-toolbar-content="${l.id}"]`);
|
|
1829
|
-
if (!a) continue;
|
|
1830
|
-
const c = l.render(a);
|
|
1831
|
-
c && i.toolbarContentCleanups.set(l.id, c);
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
function pe(t, e) {
|
|
1835
|
-
const i = e.lightDomHeaderContent.length > 0 && !e.lightDomContentMoved, o = e.headerContents.size > 0;
|
|
1836
|
-
if (!i && !o) return;
|
|
1837
|
-
const n = t.querySelector(".tbw-shell-content");
|
|
1838
|
-
if (!n) return;
|
|
1839
|
-
if (i) {
|
|
1840
|
-
for (const s of e.lightDomHeaderContent)
|
|
1841
|
-
s.style.display = "", n.appendChild(s);
|
|
1842
|
-
e.lightDomContentMoved = !0;
|
|
1843
|
-
}
|
|
1844
|
-
const r = [...e.headerContents.values()].sort((s, l) => (s.order ?? 100) - (l.order ?? 100));
|
|
1845
|
-
for (const s of r) {
|
|
1846
|
-
const l = e.headerContentCleanups.get(s.id);
|
|
1847
|
-
l && (l(), e.headerContentCleanups.delete(s.id));
|
|
1848
|
-
let a = n.querySelector(`[data-header-content="${s.id}"]`);
|
|
1849
|
-
a || (a = document.createElement("div"), a.setAttribute("data-header-content", s.id), n.appendChild(a));
|
|
1850
|
-
const c = s.render(a);
|
|
1851
|
-
c && e.headerContentCleanups.set(s.id, c);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
function bi(t, e, i) {
|
|
1855
|
-
if (!e.isPanelOpen) return;
|
|
1856
|
-
const o = q(i?.expand ?? M.expand), n = q(i?.collapse ?? M.collapse);
|
|
1857
|
-
for (const [r, s] of e.toolPanels) {
|
|
1858
|
-
const l = e.expandedSections.has(r), a = t.querySelector(`[data-section="${r}"]`), c = a?.querySelector(".tbw-accordion-content");
|
|
1859
|
-
if (!a || !c) continue;
|
|
1860
|
-
a.classList.toggle("expanded", l);
|
|
1861
|
-
const h = a.querySelector(".tbw-accordion-header");
|
|
1862
|
-
h && h.setAttribute("aria-expanded", String(l));
|
|
1863
|
-
const f = a.querySelector(".tbw-accordion-chevron");
|
|
1864
|
-
if (f && (f.innerHTML = l ? n : o), l) {
|
|
1865
|
-
if (c.children.length === 0) {
|
|
1866
|
-
const p = s.render(c);
|
|
1867
|
-
p && e.panelCleanups.set(r, p);
|
|
1868
|
-
}
|
|
1869
|
-
} else {
|
|
1870
|
-
const p = e.panelCleanups.get(r);
|
|
1871
|
-
p && (p(), e.panelCleanups.delete(r)), c.innerHTML = "";
|
|
1872
|
-
}
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
function Fe(t, e) {
|
|
1876
|
-
const i = t.querySelector("[data-panel-toggle]");
|
|
1877
|
-
i && (i.classList.toggle("active", e.isPanelOpen), i.setAttribute("aria-pressed", String(e.isPanelOpen)));
|
|
1878
|
-
}
|
|
1879
|
-
function Ve(t, e) {
|
|
1880
|
-
const i = t.querySelector(".tbw-tool-panel");
|
|
1881
|
-
i && (i.classList.toggle("open", e.isPanelOpen), e.isPanelOpen || (i.style.width = ""));
|
|
1882
|
-
}
|
|
1883
|
-
function he(t) {
|
|
1884
|
-
for (const e of t.toolbarContentCleanups.values())
|
|
1885
|
-
e();
|
|
1886
|
-
t.toolbarContentCleanups.clear();
|
|
1887
|
-
}
|
|
1888
|
-
function mi(t) {
|
|
1889
|
-
for (const e of t.headerContentCleanups.values())
|
|
1890
|
-
e();
|
|
1891
|
-
t.headerContentCleanups.clear();
|
|
1892
|
-
for (const e of t.panelCleanups.values())
|
|
1893
|
-
e();
|
|
1894
|
-
t.panelCleanups.clear();
|
|
1895
|
-
for (const e of t.toolbarContentCleanups.values())
|
|
1896
|
-
e();
|
|
1897
|
-
t.toolbarContentCleanups.clear();
|
|
1898
|
-
for (const e of t.toolbarContents.values())
|
|
1899
|
-
e.onDestroy?.();
|
|
1900
|
-
if (t.isPanelOpen)
|
|
1901
|
-
for (const e of t.expandedSections)
|
|
1902
|
-
t.toolPanels.get(e)?.onClose?.();
|
|
1903
|
-
t.isPanelOpen = !1, t.expandedSections.clear(), t.toolPanels.clear(), t.headerContents.clear(), t.toolbarContents.clear(), t.lightDomHeaderContent = [], t.lightDomToolPanelIds.clear(), t.lightDomToolbarContentIds.clear(), t.lightDomContentMoved = !1;
|
|
1904
|
-
}
|
|
1905
|
-
function vi(t, e) {
|
|
1906
|
-
let i = !1;
|
|
1907
|
-
const o = {
|
|
1908
|
-
get isInitialized() {
|
|
1909
|
-
return i;
|
|
1910
|
-
},
|
|
1911
|
-
setInitialized(n) {
|
|
1912
|
-
i = n;
|
|
1913
|
-
},
|
|
1914
|
-
get isPanelOpen() {
|
|
1915
|
-
return t.isPanelOpen;
|
|
1916
|
-
},
|
|
1917
|
-
get activePanel() {
|
|
1918
|
-
return t.isPanelOpen && t.expandedSections.size > 0 ? [...t.expandedSections][0] : null;
|
|
1919
|
-
},
|
|
1920
|
-
get expandedSections() {
|
|
1921
|
-
return [...t.expandedSections];
|
|
1922
|
-
},
|
|
1923
|
-
openToolPanel() {
|
|
1924
|
-
if (t.isPanelOpen) return;
|
|
1925
|
-
if (t.toolPanels.size === 0) {
|
|
1926
|
-
console.warn("[tbw-grid] No tool panels registered");
|
|
1927
|
-
return;
|
|
1928
|
-
}
|
|
1929
|
-
if (t.isPanelOpen = !0, t.expandedSections.size === 0 && t.toolPanels.size > 0) {
|
|
1930
|
-
const s = [...t.toolPanels.values()].sort((l, a) => (l.order ?? 100) - (a.order ?? 100))[0];
|
|
1931
|
-
s && t.expandedSections.add(s.id);
|
|
1932
|
-
}
|
|
1933
|
-
const n = e.getShadow();
|
|
1934
|
-
Fe(n, t), Ve(n, t), bi(n, t, e.getAccordionIcons()), e.emit("tool-panel-open", { sections: o.expandedSections });
|
|
1935
|
-
},
|
|
1936
|
-
closeToolPanel() {
|
|
1937
|
-
if (!t.isPanelOpen) return;
|
|
1938
|
-
for (const r of t.panelCleanups.values())
|
|
1939
|
-
r();
|
|
1940
|
-
t.panelCleanups.clear();
|
|
1941
|
-
for (const r of t.toolPanels.values())
|
|
1942
|
-
r.onClose?.();
|
|
1943
|
-
t.isPanelOpen = !1;
|
|
1944
|
-
const n = e.getShadow();
|
|
1945
|
-
Fe(n, t), Ve(n, t), e.emit("tool-panel-close", {});
|
|
1946
|
-
},
|
|
1947
|
-
toggleToolPanel() {
|
|
1948
|
-
t.isPanelOpen ? o.closeToolPanel() : o.openToolPanel();
|
|
1949
|
-
},
|
|
1950
|
-
toggleToolPanelSection(n) {
|
|
1951
|
-
const r = t.toolPanels.get(n);
|
|
1952
|
-
if (!r) {
|
|
1953
|
-
console.warn(`[tbw-grid] Tool panel section "${n}" not found`);
|
|
1954
|
-
return;
|
|
1955
|
-
}
|
|
1956
|
-
if (t.toolPanels.size === 1)
|
|
1957
|
-
return;
|
|
1958
|
-
const s = e.getShadow(), l = t.expandedSections.has(n);
|
|
1959
|
-
if (l) {
|
|
1960
|
-
const a = t.panelCleanups.get(n);
|
|
1961
|
-
a && (a(), t.panelCleanups.delete(n)), r.onClose?.(), t.expandedSections.delete(n), ue(s, n, !1);
|
|
1962
|
-
} else {
|
|
1963
|
-
for (const [a, c] of t.toolPanels)
|
|
1964
|
-
if (a !== n && t.expandedSections.has(a)) {
|
|
1965
|
-
const h = t.panelCleanups.get(a);
|
|
1966
|
-
h && (h(), t.panelCleanups.delete(a)), c.onClose?.(), t.expandedSections.delete(a), ue(s, a, !1);
|
|
1967
|
-
const f = s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);
|
|
1968
|
-
f && (f.innerHTML = "");
|
|
1969
|
-
}
|
|
1970
|
-
t.expandedSections.add(n), ue(s, n, !0), Ci(s, t, n);
|
|
1971
|
-
}
|
|
1972
|
-
e.emit("tool-panel-section-toggle", { id: n, expanded: !l });
|
|
1973
|
-
},
|
|
1974
|
-
getToolPanels() {
|
|
1975
|
-
return [...t.toolPanels.values()];
|
|
1976
|
-
},
|
|
1977
|
-
registerToolPanel(n) {
|
|
1978
|
-
if (t.toolPanels.has(n.id)) {
|
|
1979
|
-
console.warn(`[tbw-grid] Tool panel "${n.id}" already registered`);
|
|
1980
|
-
return;
|
|
1981
|
-
}
|
|
1982
|
-
t.toolPanels.set(n.id, n), i && e.refreshShellHeader();
|
|
1983
|
-
},
|
|
1984
|
-
unregisterToolPanel(n) {
|
|
1985
|
-
if (t.expandedSections.has(n)) {
|
|
1986
|
-
const r = t.panelCleanups.get(n);
|
|
1987
|
-
r && (r(), t.panelCleanups.delete(n)), t.expandedSections.delete(n);
|
|
1988
|
-
}
|
|
1989
|
-
t.toolPanels.delete(n), i && e.refreshShellHeader();
|
|
1990
|
-
},
|
|
1991
|
-
getHeaderContents() {
|
|
1992
|
-
return [...t.headerContents.values()];
|
|
1993
|
-
},
|
|
1994
|
-
registerHeaderContent(n) {
|
|
1995
|
-
if (t.headerContents.has(n.id)) {
|
|
1996
|
-
console.warn(`[tbw-grid] Header content "${n.id}" already registered`);
|
|
1997
|
-
return;
|
|
1998
|
-
}
|
|
1999
|
-
t.headerContents.set(n.id, n), i && pe(e.getShadow(), t);
|
|
2000
|
-
},
|
|
2001
|
-
unregisterHeaderContent(n) {
|
|
2002
|
-
const r = t.headerContentCleanups.get(n);
|
|
2003
|
-
r && (r(), t.headerContentCleanups.delete(n)), t.headerContents.get(n)?.onDestroy?.(), t.headerContents.delete(n), e.getShadow().querySelector(`[data-header-content="${n}"]`)?.remove();
|
|
2004
|
-
},
|
|
2005
|
-
getToolbarContents() {
|
|
2006
|
-
return [...t.toolbarContents.values()].sort((n, r) => (n.order ?? 0) - (r.order ?? 0));
|
|
2007
|
-
},
|
|
2008
|
-
registerToolbarContent(n) {
|
|
2009
|
-
if (t.toolbarContents.has(n.id)) {
|
|
2010
|
-
console.warn(`[tbw-grid] Toolbar content "${n.id}" already registered`);
|
|
2011
|
-
return;
|
|
2012
|
-
}
|
|
2013
|
-
t.toolbarContents.set(n.id, n), i && e.refreshShellHeader();
|
|
2014
|
-
},
|
|
2015
|
-
unregisterToolbarContent(n) {
|
|
2016
|
-
const r = t.toolbarContentCleanups.get(n);
|
|
2017
|
-
r && (r(), t.toolbarContentCleanups.delete(n));
|
|
2018
|
-
const s = t.toolbarContents.get(n);
|
|
2019
|
-
s?.onDestroy && s.onDestroy(), t.toolbarContents.delete(n), i && e.refreshShellHeader();
|
|
2020
|
-
}
|
|
2021
|
-
};
|
|
2022
|
-
return o;
|
|
2023
|
-
}
|
|
2024
|
-
function ue(t, e, i) {
|
|
2025
|
-
const o = t.querySelector(`[data-section="${e}"]`);
|
|
2026
|
-
o && o.classList.toggle("expanded", i);
|
|
2027
|
-
}
|
|
2028
|
-
function Ci(t, e, i) {
|
|
2029
|
-
const o = e.toolPanels.get(i);
|
|
2030
|
-
if (!o?.render) return;
|
|
2031
|
-
const n = t.querySelector(`[data-section="${i}"] .tbw-accordion-content`);
|
|
2032
|
-
if (!n) return;
|
|
2033
|
-
const r = o.render(n);
|
|
2034
|
-
r && e.panelCleanups.set(i, r);
|
|
2035
|
-
}
|
|
2036
|
-
function yi(t, e, i, o) {
|
|
2037
|
-
const n = at(e), r = [], s = [
|
|
2038
|
-
"tbw-grid-header",
|
|
2039
|
-
"tbw-grid-tool-buttons",
|
|
2040
|
-
"tbw-grid-tool-panel",
|
|
2041
|
-
"tbw-grid-column",
|
|
2042
|
-
"tbw-grid-detail",
|
|
2043
|
-
"tbw-grid-responsive-card"
|
|
2044
|
-
];
|
|
2045
|
-
for (const l of s)
|
|
2046
|
-
t.querySelectorAll(`:scope > ${l}`).forEach((c) => r.push(c));
|
|
2047
|
-
t.replaceChildren();
|
|
2048
|
-
for (const l of r)
|
|
2049
|
-
t.appendChild(l);
|
|
2050
|
-
if (n) {
|
|
2051
|
-
const l = q(o?.toolPanel ?? M.toolPanel), a = q(o?.expand ?? M.expand), c = q(o?.collapse ?? M.collapse), f = [...e?.header?.toolbarContents ?? []].sort((_, R) => (_.order ?? 0) - (R.order ?? 0)), g = [...e?.toolPanels ?? []].sort((_, R) => (_.order ?? 100) - (R.order ?? 100)), u = {
|
|
2052
|
-
title: e?.header?.title ?? void 0,
|
|
2053
|
-
hasPanels: g.length > 0,
|
|
2054
|
-
isPanelOpen: i.isPanelOpen,
|
|
2055
|
-
toolPanelIcon: l,
|
|
2056
|
-
configButtons: f.map((_) => ({
|
|
2057
|
-
id: _.id,
|
|
2058
|
-
hasElement: !1,
|
|
2059
|
-
hasRender: !!_.render
|
|
2060
|
-
})),
|
|
2061
|
-
apiButtons: []
|
|
2062
|
-
}, d = {
|
|
2063
|
-
position: e?.toolPanel?.position ?? "right",
|
|
2064
|
-
isPanelOpen: i.isPanelOpen,
|
|
2065
|
-
expandIcon: a,
|
|
2066
|
-
collapseIcon: c,
|
|
2067
|
-
panels: g.map((_) => ({
|
|
2068
|
-
id: _.id,
|
|
2069
|
-
title: _.title,
|
|
2070
|
-
icon: q(_.icon),
|
|
2071
|
-
isExpanded: i.expandedSections.has(_.id)
|
|
2072
|
-
}))
|
|
2073
|
-
}, w = di(u), C = hi(d), m = Ne({
|
|
2074
|
-
hasShell: !0,
|
|
2075
|
-
shellHeader: w,
|
|
2076
|
-
shellBody: C
|
|
2077
|
-
});
|
|
2078
|
-
t.appendChild(m);
|
|
2079
|
-
} else {
|
|
2080
|
-
const l = Ne({ hasShell: !1 });
|
|
2081
|
-
t.appendChild(l);
|
|
2082
|
-
}
|
|
2083
|
-
return n;
|
|
2084
|
-
}
|
|
2085
|
-
const Ue = "tbw-grid-styles";
|
|
2086
|
-
let te = "";
|
|
2087
|
-
const we = /* @__PURE__ */ new Map();
|
|
2088
|
-
function _i() {
|
|
2089
|
-
let t = document.getElementById(Ue);
|
|
2090
|
-
return t || (t = document.createElement("style"), t.id = Ue, t.setAttribute("data-tbw-grid", "true"), document.head.appendChild(t)), t;
|
|
2091
|
-
}
|
|
2092
|
-
function be() {
|
|
2093
|
-
const t = _i(), e = Array.from(we.values()).join(`
|
|
2094
|
-
`);
|
|
2095
|
-
t.textContent = `${te}
|
|
2096
|
-
|
|
2097
|
-
/* Plugin Styles */
|
|
2098
|
-
${e}`;
|
|
2099
|
-
}
|
|
2100
|
-
function Ei(t) {
|
|
2101
|
-
let e = !1;
|
|
2102
|
-
for (const { name: i, styles: o } of t)
|
|
2103
|
-
we.has(i) || (we.set(i, o), e = !0);
|
|
2104
|
-
return e && be(), e;
|
|
2105
|
-
}
|
|
2106
|
-
function Si() {
|
|
2107
|
-
try {
|
|
2108
|
-
for (const t of Array.from(document.styleSheets))
|
|
2109
|
-
try {
|
|
2110
|
-
const i = Array.from(t.cssRules || []).map((o) => o.cssText).join(`
|
|
2111
|
-
`);
|
|
2112
|
-
if (i.includes(".tbw-grid-root") && i.includes("tbw-grid"))
|
|
2113
|
-
return i;
|
|
2114
|
-
} catch {
|
|
2115
|
-
continue;
|
|
2116
|
-
}
|
|
2117
|
-
} catch (t) {
|
|
2118
|
-
console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:", t);
|
|
2119
|
-
}
|
|
2120
|
-
return null;
|
|
2121
|
-
}
|
|
2122
|
-
async function Ri(t) {
|
|
2123
|
-
if (te)
|
|
2124
|
-
return;
|
|
2125
|
-
if (typeof t == "string" && t.length > 0) {
|
|
2126
|
-
te = t, be();
|
|
2127
|
-
return;
|
|
2128
|
-
}
|
|
2129
|
-
await new Promise((i) => setTimeout(i, 50));
|
|
2130
|
-
const e = Si();
|
|
2131
|
-
e ? (te = e, be()) : (typeof process > "u" || process.env?.NODE_ENV !== "test") && console.warn(
|
|
2132
|
-
"[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.",
|
|
2133
|
-
"Available stylesheets:",
|
|
2134
|
-
Array.from(document.styleSheets).map((i) => i.href || "(inline)")
|
|
2135
|
-
);
|
|
2136
|
-
}
|
|
2137
|
-
function Ai() {
|
|
2138
|
-
return {
|
|
2139
|
-
startY: null,
|
|
2140
|
-
startX: null,
|
|
2141
|
-
scrollTop: null,
|
|
2142
|
-
scrollLeft: null,
|
|
2143
|
-
lastY: null,
|
|
2144
|
-
lastX: null,
|
|
2145
|
-
lastTime: null,
|
|
2146
|
-
velocityY: 0,
|
|
2147
|
-
velocityX: 0,
|
|
2148
|
-
momentumRaf: 0
|
|
2149
|
-
};
|
|
2150
|
-
}
|
|
2151
|
-
function Ti(t) {
|
|
2152
|
-
t.startY = null, t.startX = null, t.scrollTop = null, t.scrollLeft = null, t.lastY = null, t.lastX = null, t.lastTime = null;
|
|
2153
|
-
}
|
|
2154
|
-
function ct(t) {
|
|
2155
|
-
t.momentumRaf && (cancelAnimationFrame(t.momentumRaf), t.momentumRaf = 0);
|
|
2156
|
-
}
|
|
2157
|
-
function xi(t, e, i) {
|
|
2158
|
-
if (t.touches.length !== 1) return;
|
|
2159
|
-
ct(e);
|
|
2160
|
-
const o = t.touches[0];
|
|
2161
|
-
e.startY = o.clientY, e.startX = o.clientX, e.lastY = o.clientY, e.lastX = o.clientX, e.lastTime = performance.now(), e.scrollTop = i.fauxScrollbar.scrollTop, e.scrollLeft = i.scrollArea?.scrollLeft ?? 0, e.velocityY = 0, e.velocityX = 0;
|
|
2162
|
-
}
|
|
2163
|
-
function Hi(t, e, i) {
|
|
2164
|
-
if (t.touches.length !== 1 || e.startY === null || e.startX === null || e.scrollTop === null || e.scrollLeft === null)
|
|
2165
|
-
return !1;
|
|
2166
|
-
const o = t.touches[0], n = o.clientY, r = o.clientX, s = performance.now(), l = e.startY - n, a = e.startX - r;
|
|
2167
|
-
if (e.lastTime !== null && e.lastY !== null && e.lastX !== null) {
|
|
2168
|
-
const d = s - e.lastTime;
|
|
2169
|
-
d > 0 && (e.velocityY = (e.lastY - n) / d, e.velocityX = (e.lastX - r) / d);
|
|
2170
|
-
}
|
|
2171
|
-
e.lastY = n, e.lastX = r, e.lastTime = s;
|
|
2172
|
-
const { scrollTop: c, scrollHeight: h, clientHeight: f } = i.fauxScrollbar, p = h - f, g = l > 0 && c < p || l < 0 && c > 0;
|
|
2173
|
-
let u = !1;
|
|
2174
|
-
if (i.scrollArea) {
|
|
2175
|
-
const { scrollLeft: d, scrollWidth: w, clientWidth: C } = i.scrollArea, m = w - C;
|
|
2176
|
-
u = a > 0 && d < m || a < 0 && d > 0;
|
|
2177
|
-
}
|
|
2178
|
-
return g && (i.fauxScrollbar.scrollTop = e.scrollTop + l), u && i.scrollArea && (i.scrollArea.scrollLeft = e.scrollLeft + a), g || u;
|
|
2179
|
-
}
|
|
2180
|
-
function Li(t, e) {
|
|
2181
|
-
(Math.abs(t.velocityY) > 0.1 || Math.abs(t.velocityX) > 0.1) && Pi(t, e), Ti(t);
|
|
2182
|
-
}
|
|
2183
|
-
function Pi(t, e) {
|
|
2184
|
-
const n = () => {
|
|
2185
|
-
t.velocityY *= 0.95, t.velocityX *= 0.95;
|
|
2186
|
-
const r = t.velocityY * 16, s = t.velocityX * 16;
|
|
2187
|
-
Math.abs(t.velocityY) > 0.01 && (e.fauxScrollbar.scrollTop += r), Math.abs(t.velocityX) > 0.01 && e.scrollArea && (e.scrollArea.scrollLeft += s), Math.abs(t.velocityY) > 0.01 || Math.abs(t.velocityX) > 0.01 ? t.momentumRaf = requestAnimationFrame(n) : t.momentumRaf = 0;
|
|
2188
|
-
};
|
|
2189
|
-
t.momentumRaf = requestAnimationFrame(n);
|
|
2190
|
-
}
|
|
2191
|
-
function zi(t, e, i, o) {
|
|
2192
|
-
t.addEventListener("touchstart", (n) => xi(n, e, i), {
|
|
2193
|
-
passive: !0,
|
|
2194
|
-
signal: o
|
|
2195
|
-
}), t.addEventListener(
|
|
2196
|
-
"touchmove",
|
|
2197
|
-
(n) => {
|
|
2198
|
-
Hi(n, e, i) && n.preventDefault();
|
|
2199
|
-
},
|
|
2200
|
-
{ passive: !1, signal: o }
|
|
2201
|
-
), t.addEventListener("touchend", () => Li(e, i), { passive: !0, signal: o });
|
|
2202
|
-
}
|
|
2203
|
-
const Oi = [
|
|
2204
|
-
{
|
|
2205
|
-
property: "editable",
|
|
2206
|
-
pluginName: "editing",
|
|
2207
|
-
level: "column",
|
|
2208
|
-
description: 'the "editable" column property',
|
|
2209
|
-
isUsed: (t) => t === !0
|
|
2210
|
-
},
|
|
2211
|
-
{
|
|
2212
|
-
property: "editor",
|
|
2213
|
-
pluginName: "editing",
|
|
2214
|
-
level: "column",
|
|
2215
|
-
description: 'the "editor" column property'
|
|
2216
|
-
},
|
|
2217
|
-
{
|
|
2218
|
-
property: "editorParams",
|
|
2219
|
-
pluginName: "editing",
|
|
2220
|
-
level: "column",
|
|
2221
|
-
description: 'the "editorParams" column property'
|
|
2222
|
-
},
|
|
2223
|
-
{
|
|
2224
|
-
property: "group",
|
|
2225
|
-
pluginName: "groupingColumns",
|
|
2226
|
-
level: "column",
|
|
2227
|
-
description: 'the "group" column property'
|
|
2228
|
-
},
|
|
2229
|
-
{
|
|
2230
|
-
property: "pinned",
|
|
2231
|
-
pluginName: "pinnedColumns",
|
|
2232
|
-
level: "column",
|
|
2233
|
-
description: 'the "pinned" column property',
|
|
2234
|
-
isUsed: (t) => t === "left" || t === "right" || t === "start" || t === "end"
|
|
2235
|
-
},
|
|
2236
|
-
{
|
|
2237
|
-
property: "sticky",
|
|
2238
|
-
pluginName: "pinnedColumns",
|
|
2239
|
-
level: "column",
|
|
2240
|
-
description: 'the "sticky" column property (deprecated, use "pinned")',
|
|
2241
|
-
isUsed: (t) => t === "left" || t === "right" || t === "start" || t === "end"
|
|
2242
|
-
}
|
|
2243
|
-
], Di = [
|
|
2244
|
-
{
|
|
2245
|
-
property: "columnGroups",
|
|
2246
|
-
pluginName: "groupingColumns",
|
|
2247
|
-
level: "config",
|
|
2248
|
-
description: 'the "columnGroups" config property',
|
|
2249
|
-
isUsed: (t) => Array.isArray(t) && t.length > 0
|
|
2250
|
-
}
|
|
2251
|
-
];
|
|
2252
|
-
function Mi(t) {
|
|
2253
|
-
return t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
2254
|
-
}
|
|
2255
|
-
function me(t) {
|
|
2256
|
-
return `import { ${O(t)}Plugin } from '@toolbox-web/grid/plugins/${Mi(t)}';`;
|
|
2257
|
-
}
|
|
2258
|
-
function O(t) {
|
|
2259
|
-
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
2260
|
-
}
|
|
2261
|
-
function Be(t, e) {
|
|
2262
|
-
return t.some((i) => i.name === e);
|
|
2263
|
-
}
|
|
2264
|
-
function ki(t, e) {
|
|
2265
|
-
const i = Oi, o = Di, n = /* @__PURE__ */ new Map();
|
|
2266
|
-
function r(l, a, c, h, f = !1) {
|
|
2267
|
-
n.has(l) || n.set(l, { description: a, importHint: c, fields: [], isConfigProperty: f });
|
|
2268
|
-
const p = n.get(l);
|
|
2269
|
-
p.fields.includes(h) || p.fields.push(h);
|
|
2270
|
-
}
|
|
2271
|
-
for (const l of o) {
|
|
2272
|
-
const a = t[l.property];
|
|
2273
|
-
(l.isUsed ? l.isUsed(a) : a !== void 0) && !Be(e, l.pluginName) && r(l.pluginName, l.description, me(l.pluginName), l.property, !0);
|
|
2274
|
-
}
|
|
2275
|
-
const s = t.columns;
|
|
2276
|
-
if (s && s.length > 0)
|
|
2277
|
-
for (const l of s)
|
|
2278
|
-
for (const a of i) {
|
|
2279
|
-
const c = l[a.property];
|
|
2280
|
-
if ((a.isUsed ? a.isUsed(c) : c !== void 0) && !Be(e, a.pluginName)) {
|
|
2281
|
-
const f = l.field || "<unknown>";
|
|
2282
|
-
r(a.pluginName, a.description, me(a.pluginName), f);
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
if (n.size > 0) {
|
|
2286
|
-
const l = [];
|
|
2287
|
-
for (const [a, { description: c, importHint: h, fields: f, isConfigProperty: p }] of n)
|
|
2288
|
-
if (p)
|
|
2289
|
-
l.push(
|
|
2290
|
-
`Config uses ${c}, but the required plugin is not loaded.
|
|
2291
|
-
→ Add the plugin to your gridConfig.plugins array:
|
|
2292
|
-
${h}
|
|
2293
|
-
plugins: [new ${O(a)}Plugin(), ...]`
|
|
2294
|
-
);
|
|
2295
|
-
else {
|
|
2296
|
-
const g = f.slice(0, 3).join(", ") + (f.length > 3 ? `, ... (${f.length} total)` : "");
|
|
2297
|
-
l.push(
|
|
2298
|
-
`Column(s) [${g}] use ${c}, but the required plugin is not loaded.
|
|
2299
|
-
→ Add the plugin to your gridConfig.plugins array:
|
|
2300
|
-
${h}
|
|
2301
|
-
plugins: [new ${O(a)}Plugin(), ...]`
|
|
2302
|
-
);
|
|
2303
|
-
}
|
|
2304
|
-
throw new Error(
|
|
2305
|
-
`[tbw-grid] Configuration error:
|
|
2306
|
-
|
|
2307
|
-
${l.join(`
|
|
2308
|
-
|
|
2309
|
-
`)}
|
|
2310
|
-
|
|
2311
|
-
This validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`
|
|
2312
|
-
);
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
function Ii(t) {
|
|
2316
|
-
const e = [], i = [];
|
|
2317
|
-
for (const o of t) {
|
|
2318
|
-
const r = o.constructor.manifest;
|
|
2319
|
-
if (r?.configRules)
|
|
2320
|
-
for (const s of r.configRules) {
|
|
2321
|
-
const l = o.config;
|
|
2322
|
-
if (s.check(l)) {
|
|
2323
|
-
const c = `${`[tbw-grid:${O(o.name)}Plugin]`} Configuration warning: ${s.message}`;
|
|
2324
|
-
s.severity === "error" ? e.push(c) : i.push(c);
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
if (i.length > 0 && ye())
|
|
2329
|
-
for (const o of i)
|
|
2330
|
-
console.warn(o);
|
|
2331
|
-
if (e.length > 0)
|
|
2332
|
-
throw new Error(`[tbw-grid] Configuration error:
|
|
2333
|
-
|
|
2334
|
-
${e.join(`
|
|
2335
|
-
|
|
2336
|
-
`)}`);
|
|
2337
|
-
}
|
|
2338
|
-
function Ni(t, e) {
|
|
2339
|
-
const i = t.name, n = t.constructor.dependencies ?? [];
|
|
2340
|
-
for (const r of n) {
|
|
2341
|
-
const s = r.name, l = r.required ?? !0, a = r.reason;
|
|
2342
|
-
if (!e.some((h) => h.name === s)) {
|
|
2343
|
-
const h = a ?? `${O(i)}Plugin requires ${O(s)}Plugin`, f = me(s);
|
|
2344
|
-
if (l)
|
|
2345
|
-
throw new Error(
|
|
2346
|
-
`[tbw-grid] Plugin dependency error:
|
|
2347
|
-
|
|
2348
|
-
${h}.
|
|
2349
|
-
|
|
2350
|
-
→ Add the plugin to your gridConfig.plugins array BEFORE ${O(i)}Plugin:
|
|
2351
|
-
${f}
|
|
2352
|
-
plugins: [new ${O(s)}Plugin(), new ${O(i)}Plugin()]`
|
|
2353
|
-
);
|
|
2354
|
-
console.info(
|
|
2355
|
-
`[tbw-grid] ${O(i)}Plugin: Optional "${s}" plugin not found. Some features may be unavailable.`
|
|
2356
|
-
);
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
function qi(t) {
|
|
2361
|
-
if (!ye()) return;
|
|
2362
|
-
const e = new Set(t.map((o) => o.name)), i = /* @__PURE__ */ new Set();
|
|
2363
|
-
for (const o of t) {
|
|
2364
|
-
const r = o.constructor.manifest;
|
|
2365
|
-
if (r?.incompatibleWith) {
|
|
2366
|
-
for (const s of r.incompatibleWith)
|
|
2367
|
-
if (e.has(s.name)) {
|
|
2368
|
-
const l = [o.name, s.name].sort().join("↔");
|
|
2369
|
-
if (i.has(l)) continue;
|
|
2370
|
-
i.add(l), console.warn(
|
|
2371
|
-
`[tbw-grid] Plugin incompatibility warning:
|
|
2372
|
-
|
|
2373
|
-
${O(o.name)}Plugin and ${O(s.name)}Plugin are both loaded, but they are currently incompatible.
|
|
2374
|
-
|
|
2375
|
-
→ ${s.reason}
|
|
2376
|
-
|
|
2377
|
-
Consider removing one of these plugins to avoid unexpected behavior.`
|
|
2378
|
-
);
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
function dt(t, e) {
|
|
2384
|
-
return !t || typeof t != "object" ? t : "__rowCacheKey" in t ? t.__rowCacheKey : "rowId" in t && t.rowId != null ? `id:${t.rowId}` : e ? `id:${e(t)}` : t;
|
|
2385
|
-
}
|
|
2386
|
-
function $i(t, e, i) {
|
|
2387
|
-
const o = dt(e, i);
|
|
2388
|
-
if (typeof o == "string")
|
|
2389
|
-
return t.byKey.get(o);
|
|
2390
|
-
if (o && typeof o == "object")
|
|
2391
|
-
return t.byRef.get(o);
|
|
2392
|
-
}
|
|
2393
|
-
function Wi(t, e, i, o) {
|
|
2394
|
-
const n = dt(e, o);
|
|
2395
|
-
typeof n == "string" ? t.byKey.set(n, i) : n && typeof n == "object" && t.byRef.set(n, i);
|
|
2396
|
-
}
|
|
2397
|
-
function Fi(t, e, i, o, n) {
|
|
2398
|
-
const r = new Array(t.length);
|
|
2399
|
-
let s = 0;
|
|
2400
|
-
for (let l = 0; l < t.length; l++) {
|
|
2401
|
-
const a = t[l];
|
|
2402
|
-
let c = n?.(a, l), h = c !== void 0;
|
|
2403
|
-
c === void 0 && (c = $i(e, a, o.rowId), h = c !== void 0), c === void 0 && (c = i, h = !1), r[l] = { offset: s, height: c, measured: h }, s += c;
|
|
2404
|
-
}
|
|
2405
|
-
return r;
|
|
2406
|
-
}
|
|
2407
|
-
function ve(t, e, i) {
|
|
2408
|
-
if (e < 0 || e >= t.length) return;
|
|
2409
|
-
const o = t[e], n = i - o.height;
|
|
2410
|
-
if (n !== 0) {
|
|
2411
|
-
o.height = i, o.measured = !0;
|
|
2412
|
-
for (let r = e + 1; r < t.length; r++)
|
|
2413
|
-
t[r].offset += n;
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
function Vi(t) {
|
|
2417
|
-
if (t.length === 0) return 0;
|
|
2418
|
-
const e = t[t.length - 1];
|
|
2419
|
-
return e.offset + e.height;
|
|
2420
|
-
}
|
|
2421
|
-
function Ge(t, e) {
|
|
2422
|
-
if (t.length === 0) return -1;
|
|
2423
|
-
if (e <= 0) return 0;
|
|
2424
|
-
let i = 0, o = t.length - 1;
|
|
2425
|
-
for (; i <= o; ) {
|
|
2426
|
-
const n = Math.floor((i + o) / 2), r = t[n], s = r.offset + r.height;
|
|
2427
|
-
if (e < r.offset)
|
|
2428
|
-
o = n - 1;
|
|
2429
|
-
else if (e >= s)
|
|
2430
|
-
i = n + 1;
|
|
2431
|
-
else
|
|
2432
|
-
return n;
|
|
2433
|
-
}
|
|
2434
|
-
return Math.max(0, Math.min(i, t.length - 1));
|
|
2435
|
-
}
|
|
2436
|
-
function Ui(t, e) {
|
|
2437
|
-
let i = 0, o = 0;
|
|
2438
|
-
for (const n of t)
|
|
2439
|
-
n.measured && (i += n.height, o++);
|
|
2440
|
-
return o > 0 ? i / o : e;
|
|
2441
|
-
}
|
|
2442
|
-
function Bi(t) {
|
|
2443
|
-
let e = 0;
|
|
2444
|
-
for (const i of t)
|
|
2445
|
-
i.measured && e++;
|
|
2446
|
-
return e;
|
|
2447
|
-
}
|
|
2448
|
-
function Gi(t, e) {
|
|
2449
|
-
const { positionCache: i, heightCache: o, rows: n, start: r, end: s, getPluginHeight: l, getRowId: a } = t;
|
|
2450
|
-
let c = !1;
|
|
2451
|
-
e.forEach((p) => {
|
|
2452
|
-
const g = p.dataset.rowIndex;
|
|
2453
|
-
if (!g) return;
|
|
2454
|
-
const u = parseInt(g, 10);
|
|
2455
|
-
if (u < r || u >= s || u >= n.length) return;
|
|
2456
|
-
const d = n[u], w = l?.(d, u);
|
|
2457
|
-
if (w !== void 0) {
|
|
2458
|
-
const m = i[u];
|
|
2459
|
-
(!m.measured || Math.abs(m.height - w) > 1) && (ve(i, u, w), c = !0);
|
|
2460
|
-
return;
|
|
2461
|
-
}
|
|
2462
|
-
const C = p.offsetHeight;
|
|
2463
|
-
if (C > 0) {
|
|
2464
|
-
const m = i[u];
|
|
2465
|
-
(!m.measured || Math.abs(m.height - C) > 1) && (ve(i, u, C), Wi(o, d, C, a), c = !0);
|
|
2466
|
-
}
|
|
2467
|
-
});
|
|
2468
|
-
const h = c ? Bi(i) : 0, f = c ? Ui(i, t.defaultHeight) : 0;
|
|
2469
|
-
return { hasChanges: c, measuredCount: h, averageHeight: f };
|
|
2470
|
-
}
|
|
2471
|
-
function Xi(t, e, i, o) {
|
|
2472
|
-
let n = 0, r = 0;
|
|
2473
|
-
for (let s = 0; s < t.length; s++) {
|
|
2474
|
-
const l = t[s];
|
|
2475
|
-
l.measured && o?.(e[s], s) === void 0 && (r += l.height, n++);
|
|
2476
|
-
}
|
|
2477
|
-
return {
|
|
2478
|
-
measuredCount: n,
|
|
2479
|
-
averageHeight: n > 0 ? r / n : i
|
|
2480
|
-
};
|
|
2481
|
-
}
|
|
2482
|
-
function so(t) {
|
|
2483
|
-
const { totalRows: e, viewportHeight: i, scrollTop: o, rowHeight: n, overscan: r } = t, s = Math.ceil(i / n);
|
|
2484
|
-
let l = Math.floor(o / n) - r;
|
|
2485
|
-
l < 0 && (l = 0);
|
|
2486
|
-
let a = l + s + r * 2;
|
|
2487
|
-
return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - s - r * 2)), {
|
|
2488
|
-
start: l,
|
|
2489
|
-
end: a,
|
|
2490
|
-
offsetY: l * n,
|
|
2491
|
-
totalHeight: e * n
|
|
2492
|
-
};
|
|
2493
|
-
}
|
|
2494
|
-
function lo(t, e) {
|
|
2495
|
-
return t <= e;
|
|
2496
|
-
}
|
|
2497
|
-
class ne {
|
|
2498
|
-
constructor(e) {
|
|
2499
|
-
this.grid = e;
|
|
2500
|
-
}
|
|
2501
|
-
plugins = [];
|
|
2502
|
-
getPlugins() {
|
|
2503
|
-
return this.plugins;
|
|
2504
|
-
}
|
|
2505
|
-
pluginMap = /* @__PURE__ */ new Map();
|
|
2506
|
-
cellRenderers = /* @__PURE__ */ new Map();
|
|
2507
|
-
headerRenderers = /* @__PURE__ */ new Map();
|
|
2508
|
-
cellEditors = /* @__PURE__ */ new Map();
|
|
2509
|
-
eventListeners = /* @__PURE__ */ new Map();
|
|
2510
|
-
queryHandlers = /* @__PURE__ */ new Map();
|
|
2511
|
-
static deprecationWarned = /* @__PURE__ */ new WeakSet();
|
|
2512
|
-
attachAll(e) {
|
|
2513
|
-
for (const i of e)
|
|
2514
|
-
this.attach(i);
|
|
2515
|
-
}
|
|
2516
|
-
attach(e) {
|
|
2517
|
-
if (Ni(e, this.plugins), this.pluginMap.set(e.constructor, e), this.plugins.push(e), e.cellRenderers)
|
|
2518
|
-
for (const [i, o] of Object.entries(e.cellRenderers))
|
|
2519
|
-
this.cellRenderers.set(i, o);
|
|
2520
|
-
if (e.headerRenderers)
|
|
2521
|
-
for (const [i, o] of Object.entries(e.headerRenderers))
|
|
2522
|
-
this.headerRenderers.set(i, o);
|
|
2523
|
-
if (e.cellEditors)
|
|
2524
|
-
for (const [i, o] of Object.entries(e.cellEditors))
|
|
2525
|
-
this.cellEditors.set(i, o);
|
|
2526
|
-
this.registerQueryHandlers(e), this.warnDeprecatedHooks(e), e.attach(this.grid);
|
|
2527
|
-
for (const i of this.plugins)
|
|
2528
|
-
i !== e && i.onPluginAttached && i.onPluginAttached(e.name, e);
|
|
2529
|
-
}
|
|
2530
|
-
registerQueryHandlers(e) {
|
|
2531
|
-
const o = e.constructor.manifest;
|
|
2532
|
-
if (o?.queries)
|
|
2533
|
-
for (const n of o.queries) {
|
|
2534
|
-
let r = this.queryHandlers.get(n.type);
|
|
2535
|
-
r || (r = /* @__PURE__ */ new Set(), this.queryHandlers.set(n.type, r)), r.add(e);
|
|
2536
|
-
}
|
|
2537
|
-
}
|
|
2538
|
-
warnDeprecatedHooks(e) {
|
|
2539
|
-
const i = e.constructor;
|
|
2540
|
-
if (ne.deprecationWarned.has(i) || !ye()) return;
|
|
2541
|
-
const o = typeof e.getExtraHeight == "function" || typeof e.getExtraHeightBefore == "function", n = typeof e.getRowHeight == "function";
|
|
2542
|
-
o && !n && (ne.deprecationWarned.add(i), console.warn(
|
|
2543
|
-
`[tbw-grid] Deprecation warning: "${e.name}" uses getExtraHeight() / getExtraHeightBefore() which are deprecated and will be removed in v3.0.
|
|
2544
|
-
→ Migrate to getRowHeight(row, index) for better variable row height support.
|
|
2545
|
-
→ See: https://toolbox-web.dev/docs/grid/plugins/migration#row-height-hooks`
|
|
2546
|
-
));
|
|
2547
|
-
}
|
|
2548
|
-
unregisterQueryHandlers(e) {
|
|
2549
|
-
for (const [i, o] of this.queryHandlers)
|
|
2550
|
-
o.delete(e), o.size === 0 && this.queryHandlers.delete(i);
|
|
2551
|
-
}
|
|
2552
|
-
detachAll() {
|
|
2553
|
-
for (const e of this.plugins)
|
|
2554
|
-
for (const i of this.plugins)
|
|
2555
|
-
i !== e && i.onPluginDetached && i.onPluginDetached(e.name);
|
|
2556
|
-
for (let e = this.plugins.length - 1; e >= 0; e--) {
|
|
2557
|
-
const i = this.plugins[e];
|
|
2558
|
-
this.unsubscribeAll(i), this.unregisterQueryHandlers(i), i.detach();
|
|
2559
|
-
}
|
|
2560
|
-
this.plugins = [], this.pluginMap.clear(), this.cellRenderers.clear(), this.headerRenderers.clear(), this.cellEditors.clear(), this.eventListeners.clear(), this.queryHandlers.clear();
|
|
2561
|
-
}
|
|
2562
|
-
getPlugin(e) {
|
|
2563
|
-
return this.pluginMap.get(e);
|
|
2564
|
-
}
|
|
2565
|
-
getPluginByName(e) {
|
|
2566
|
-
return this.plugins.find((i) => i.name === e);
|
|
2567
|
-
}
|
|
2568
|
-
hasPlugin(e) {
|
|
2569
|
-
return this.pluginMap.has(e);
|
|
2570
|
-
}
|
|
2571
|
-
getAll() {
|
|
2572
|
-
return this.plugins;
|
|
2573
|
-
}
|
|
2574
|
-
getRegisteredPluginNames() {
|
|
2575
|
-
return this.plugins.map((e) => e.name);
|
|
2576
|
-
}
|
|
2577
|
-
getCellRenderer(e) {
|
|
2578
|
-
return this.cellRenderers.get(e);
|
|
2579
|
-
}
|
|
2580
|
-
getHeaderRenderer(e) {
|
|
2581
|
-
return this.headerRenderers.get(e);
|
|
2582
|
-
}
|
|
2583
|
-
getCellEditor(e) {
|
|
2584
|
-
return this.cellEditors.get(e);
|
|
2585
|
-
}
|
|
2586
|
-
getPluginStyles() {
|
|
2587
|
-
return this.plugins.filter((e) => e.styles).map((e) => ({ name: e.name, styles: e.styles }));
|
|
2588
|
-
}
|
|
2589
|
-
processRows(e) {
|
|
2590
|
-
let i = [...e];
|
|
2591
|
-
for (const o of this.plugins)
|
|
2592
|
-
o.processRows && (i = o.processRows(i));
|
|
2593
|
-
return i;
|
|
2594
|
-
}
|
|
2595
|
-
processColumns(e) {
|
|
2596
|
-
let i = [...e];
|
|
2597
|
-
for (const o of this.plugins)
|
|
2598
|
-
o.processColumns && (i = o.processColumns(i));
|
|
2599
|
-
return i;
|
|
2600
|
-
}
|
|
2601
|
-
beforeRender() {
|
|
2602
|
-
for (const e of this.plugins)
|
|
2603
|
-
e.beforeRender?.();
|
|
2604
|
-
}
|
|
2605
|
-
afterRender() {
|
|
2606
|
-
for (const e of this.plugins)
|
|
2607
|
-
e.afterRender?.();
|
|
2608
|
-
}
|
|
2609
|
-
afterCellRender(e) {
|
|
2610
|
-
for (const i of this.plugins)
|
|
2611
|
-
i.afterCellRender?.(e);
|
|
2612
|
-
}
|
|
2613
|
-
hasAfterCellRenderHook() {
|
|
2614
|
-
return this.plugins.some((e) => typeof e.afterCellRender == "function");
|
|
2615
|
-
}
|
|
2616
|
-
afterRowRender(e) {
|
|
2617
|
-
for (const i of this.plugins)
|
|
2618
|
-
i.afterRowRender?.(e);
|
|
2619
|
-
}
|
|
2620
|
-
hasAfterRowRenderHook() {
|
|
2621
|
-
return this.plugins.some((e) => typeof e.afterRowRender == "function");
|
|
2622
|
-
}
|
|
2623
|
-
onScrollRender() {
|
|
2624
|
-
for (const e of this.plugins)
|
|
2625
|
-
e.onScrollRender?.();
|
|
2626
|
-
}
|
|
2627
|
-
getExtraHeight() {
|
|
2628
|
-
let e = 0;
|
|
2629
|
-
for (const i of this.plugins)
|
|
2630
|
-
typeof i.getExtraHeight == "function" && (e += i.getExtraHeight());
|
|
2631
|
-
return e;
|
|
2632
|
-
}
|
|
2633
|
-
hasExtraHeight() {
|
|
2634
|
-
for (const e of this.plugins)
|
|
2635
|
-
if (typeof e.getExtraHeight == "function" && e.getExtraHeight() > 0)
|
|
2636
|
-
return !0;
|
|
2637
|
-
return !1;
|
|
2638
|
-
}
|
|
2639
|
-
getExtraHeightBefore(e) {
|
|
2640
|
-
let i = 0;
|
|
2641
|
-
for (const o of this.plugins)
|
|
2642
|
-
typeof o.getExtraHeightBefore == "function" && (i += o.getExtraHeightBefore(e));
|
|
2643
|
-
return i;
|
|
2644
|
-
}
|
|
2645
|
-
getRowHeight(e, i) {
|
|
2646
|
-
for (const o of this.plugins)
|
|
2647
|
-
if (typeof o.getRowHeight == "function") {
|
|
2648
|
-
const n = o.getRowHeight(e, i);
|
|
2649
|
-
if (n !== void 0)
|
|
2650
|
-
return n;
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
hasRowHeightPlugin() {
|
|
2654
|
-
for (const e of this.plugins)
|
|
2655
|
-
if (typeof e.getRowHeight == "function")
|
|
2656
|
-
return !0;
|
|
2657
|
-
return !1;
|
|
2658
|
-
}
|
|
2659
|
-
adjustVirtualStart(e, i, o) {
|
|
2660
|
-
let n = e;
|
|
2661
|
-
for (const r of this.plugins)
|
|
2662
|
-
if (typeof r.adjustVirtualStart == "function") {
|
|
2663
|
-
const s = r.adjustVirtualStart(e, i, o);
|
|
2664
|
-
s < n && (n = s);
|
|
2665
|
-
}
|
|
2666
|
-
return n;
|
|
2667
|
-
}
|
|
2668
|
-
renderRow(e, i, o) {
|
|
2669
|
-
for (const n of this.plugins)
|
|
2670
|
-
if (n.renderRow?.(e, i, o))
|
|
2671
|
-
return !0;
|
|
2672
|
-
return !1;
|
|
2673
|
-
}
|
|
2674
|
-
queryPlugins(e) {
|
|
2675
|
-
const i = [], o = this.queryHandlers.get(e.type);
|
|
2676
|
-
if (o && o.size > 0) {
|
|
2677
|
-
for (const n of o) {
|
|
2678
|
-
const r = n.handleQuery?.(e) ?? n.onPluginQuery?.(e);
|
|
2679
|
-
r !== void 0 && i.push(r);
|
|
2680
|
-
}
|
|
2681
|
-
return i;
|
|
2682
|
-
}
|
|
2683
|
-
for (const n of this.plugins) {
|
|
2684
|
-
const r = n.handleQuery?.(e) ?? n.onPluginQuery?.(e);
|
|
2685
|
-
r !== void 0 && i.push(r);
|
|
2686
|
-
}
|
|
2687
|
-
return i;
|
|
2688
|
-
}
|
|
2689
|
-
subscribe(e, i, o) {
|
|
2690
|
-
let n = this.eventListeners.get(i);
|
|
2691
|
-
n || (n = /* @__PURE__ */ new Map(), this.eventListeners.set(i, n)), n.set(e, o);
|
|
2692
|
-
}
|
|
2693
|
-
unsubscribe(e, i) {
|
|
2694
|
-
const o = this.eventListeners.get(i);
|
|
2695
|
-
o && (o.delete(e), o.size === 0 && this.eventListeners.delete(i));
|
|
2696
|
-
}
|
|
2697
|
-
unsubscribeAll(e) {
|
|
2698
|
-
for (const [i, o] of this.eventListeners)
|
|
2699
|
-
o.delete(e), o.size === 0 && this.eventListeners.delete(i);
|
|
2700
|
-
}
|
|
2701
|
-
emitPluginEvent(e, i) {
|
|
2702
|
-
const o = this.eventListeners.get(e);
|
|
2703
|
-
if (o)
|
|
2704
|
-
for (const n of o.values())
|
|
2705
|
-
try {
|
|
2706
|
-
n(i);
|
|
2707
|
-
} catch (r) {
|
|
2708
|
-
console.error(`[tbw-grid] Error in plugin event handler for "${e}":`, r);
|
|
2709
|
-
}
|
|
2710
|
-
}
|
|
2711
|
-
onKeyDown(e) {
|
|
2712
|
-
for (const i of this.plugins)
|
|
2713
|
-
if (i.onKeyDown?.(e))
|
|
2714
|
-
return !0;
|
|
2715
|
-
return !1;
|
|
2716
|
-
}
|
|
2717
|
-
onCellClick(e) {
|
|
2718
|
-
for (const i of this.plugins)
|
|
2719
|
-
if (i.onCellClick?.(e))
|
|
2720
|
-
return !0;
|
|
2721
|
-
return !1;
|
|
2722
|
-
}
|
|
2723
|
-
onRowClick(e) {
|
|
2724
|
-
for (const i of this.plugins)
|
|
2725
|
-
if (i.onRowClick?.(e))
|
|
2726
|
-
return !0;
|
|
2727
|
-
return !1;
|
|
2728
|
-
}
|
|
2729
|
-
onHeaderClick(e) {
|
|
2730
|
-
for (const i of this.plugins)
|
|
2731
|
-
if (i.onHeaderClick?.(e))
|
|
2732
|
-
return !0;
|
|
2733
|
-
return !1;
|
|
2734
|
-
}
|
|
2735
|
-
onScroll(e) {
|
|
2736
|
-
for (const i of this.plugins)
|
|
2737
|
-
i.onScroll?.(e);
|
|
2738
|
-
}
|
|
2739
|
-
onCellMouseDown(e) {
|
|
2740
|
-
for (const i of this.plugins)
|
|
2741
|
-
if (i.onCellMouseDown?.(e))
|
|
2742
|
-
return !0;
|
|
2743
|
-
return !1;
|
|
2744
|
-
}
|
|
2745
|
-
onCellMouseMove(e) {
|
|
2746
|
-
for (const i of this.plugins)
|
|
2747
|
-
if (i.onCellMouseMove?.(e))
|
|
2748
|
-
return !0;
|
|
2749
|
-
return !1;
|
|
2750
|
-
}
|
|
2751
|
-
onCellMouseUp(e) {
|
|
2752
|
-
for (const i of this.plugins)
|
|
2753
|
-
if (i.onCellMouseUp?.(e))
|
|
2754
|
-
return !0;
|
|
2755
|
-
return !1;
|
|
2756
|
-
}
|
|
2757
|
-
getHorizontalScrollOffsets(e, i) {
|
|
2758
|
-
let o = 0, n = 0, r = !1;
|
|
2759
|
-
for (const s of this.plugins) {
|
|
2760
|
-
const l = s.getHorizontalScrollOffsets?.(e, i);
|
|
2761
|
-
l && (o += l.left, n += l.right, l.skipScroll && (r = !0));
|
|
2762
|
-
}
|
|
2763
|
-
return { left: o, right: n, skipScroll: r };
|
|
2764
|
-
}
|
|
2765
|
-
getToolPanels() {
|
|
2766
|
-
const e = [];
|
|
2767
|
-
for (const i of this.plugins) {
|
|
2768
|
-
const o = i.getToolPanel?.();
|
|
2769
|
-
o && e.push({ plugin: i, panel: o });
|
|
2770
|
-
}
|
|
2771
|
-
return e.sort((i, o) => (i.panel.order ?? 0) - (o.panel.order ?? 0));
|
|
2772
|
-
}
|
|
2773
|
-
getHeaderContents() {
|
|
2774
|
-
const e = [];
|
|
2775
|
-
for (const i of this.plugins) {
|
|
2776
|
-
const o = i.getHeaderContent?.();
|
|
2777
|
-
o && e.push({ plugin: i, content: o });
|
|
2778
|
-
}
|
|
2779
|
-
return e.sort((i, o) => (i.content.order ?? 0) - (o.content.order ?? 0));
|
|
2780
|
-
}
|
|
2781
|
-
}
|
|
2782
|
-
const Yi = "@layer tbw-base{tbw-grid{.tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}.tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}&[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}", ji = '@layer tbw-base{tbw-grid{color-scheme:inherit;position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);font-feature-settings:"tnum","lnum";background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none;&,*{box-sizing:border-box}.tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select:none}}.rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}.rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}.rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}.rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip;.rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}}.faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}.faux-vscroll-spacer{width:1px}&[data-has-focus]{.cell-focus,.row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}}.sticky-left,.sticky-right{position:sticky;z-index:25}.sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}.sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}}}', Ki = '@layer tbw-base{tbw-grid{.header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}.header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}.header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start));&:not(:last-child){border-right:2px solid var(--tbw-color-border)}}.header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing);>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0;>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}&:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}&[aria-sort=ascending]>span[part~=sort-indicator],&[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}&:last-child{border-right:0;.resize-handle{right:0;width:calc(var(--tbw-resize-handle-width) / 2)}}&.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}&.resizable{position:relative}&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}}.sortable{cursor:pointer;user-select:none}.resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius);&:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}&:hover{background:var(--tbw-resize-handle-color-hover);&:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}}}}}', Qi = '@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none;&:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}&:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}}', Zi = "@layer tbw-base{@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight;.cell:focus,.cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}.data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}}", Ji = "@layer tbw-base{tbw-grid{.data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;&:nth-child(2n){background:var(--tbw-color-row-alt)}&:hover{background:var(--tbw-color-row-hover)}>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis;>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}&:last-child{border-right:0}&[data-type=boolean]{text-align:center;input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}}&.selected:focus-visible,&:focus-visible:not(.cell-focus){outline:none}&.sticky-left,&.sticky-right{background:var(--tbw-color-panel-bg)}}}.selecting .data-grid-row>.cell{user-select:none}}}", eo = "@layer tbw-base{tbw-grid{.tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}.tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}.tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}.tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease);&:hover{background:var(--tbw-color-row-hover)}&:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}&.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}&:disabled{opacity:.5;cursor:not-allowed}}.tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}.tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}.tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}.tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}}}", to = "@layer tbw-base{tbw-grid{.tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow);&[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}&.open{width:var(--tbw-tool-panel-width)}}.tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);&[data-handle-position=left]{left:0}&[data-handle-position=right]{right:0}&:hover,&.resizing{background:var(--tbw-color-accent)}}.tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}.tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px;&:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}}.tbw-tool-panel-content{flex:1;overflow:auto}.tbw-accordion{display:flex;flex-direction:column;gap:0}.tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border);&:last-child{border-bottom:none}&.single .tbw-accordion-header{cursor:default;&:hover{background:transparent}}&.expanded{.tbw-accordion-chevron{transform:rotate(90deg)}.tbw-accordion-content{display:block}}}.tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;user-select:none;&:hover{background:var(--tbw-color-row-hover)}}.tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}.tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}.tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tbw-accordion-content{display:none}}}", io = "@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm)}}", oo = `/**
|
|
2783
|
-
* tbw-grid Light DOM Styles
|
|
2784
|
-
*
|
|
2785
|
-
* This stylesheet uses CSS nesting to scope all styles to the tbw-grid element.
|
|
2786
|
-
* All selectors are automatically prefixed with \`tbw-grid\` for encapsulation.
|
|
2787
|
-
*
|
|
2788
|
-
* CSS Cascade Layers are used to control style priority:
|
|
2789
|
-
* - tbw-base: Core grid styles (lowest priority)
|
|
2790
|
-
* - tbw-plugins: Plugin styles (override base)
|
|
2791
|
-
* - tbw-theme: Theme overrides (override plugins)
|
|
2792
|
-
* - Unlayered CSS: User customizations (highest priority - always wins)
|
|
2793
|
-
*
|
|
2794
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_nesting
|
|
2795
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/@layer
|
|
2796
|
-
*/
|
|
2797
|
-
|
|
2798
|
-
/* Declare layer order - earlier layers have lower priority */
|
|
2799
|
-
@layer tbw-base, tbw-plugins, tbw-theme;
|
|
2800
|
-
|
|
2801
|
-
${io}
|
|
2802
|
-
${ji}
|
|
2803
|
-
${Ki}
|
|
2804
|
-
${Ji}
|
|
2805
|
-
${eo}
|
|
2806
|
-
${to}
|
|
2807
|
-
${Qi}
|
|
2808
|
-
${Yi}
|
|
2809
|
-
${Zi}
|
|
2810
|
-
`;
|
|
2811
|
-
class I extends HTMLElement {
|
|
2812
|
-
static tagName = "tbw-grid";
|
|
2813
|
-
static version = "1.21.1";
|
|
2814
|
-
static #a = 0;
|
|
2815
|
-
static adapters = [];
|
|
2816
|
-
static registerAdapter(e) {
|
|
2817
|
-
this.adapters.push(e);
|
|
2818
|
-
}
|
|
2819
|
-
static getAdapters() {
|
|
2820
|
-
return this.adapters;
|
|
2821
|
-
}
|
|
2822
|
-
static clearAdapters() {
|
|
2823
|
-
this.adapters = [];
|
|
2824
|
-
}
|
|
2825
|
-
static get observedAttributes() {
|
|
2826
|
-
return ["rows", "columns", "grid-config", "fit-mode", "loading"];
|
|
2827
|
-
}
|
|
2828
|
-
get #n() {
|
|
2829
|
-
return this;
|
|
2830
|
-
}
|
|
2831
|
-
#u = !1;
|
|
2832
|
-
#d;
|
|
2833
|
-
#h;
|
|
2834
|
-
#l = [];
|
|
2835
|
-
get #o() {
|
|
2836
|
-
return this.#i?.effective ?? {};
|
|
2837
|
-
}
|
|
2838
|
-
#f = !1;
|
|
2839
|
-
#w = !1;
|
|
2840
|
-
#v = {
|
|
2841
|
-
rows: !1,
|
|
2842
|
-
columns: !1,
|
|
2843
|
-
gridConfig: !1,
|
|
2844
|
-
fitMode: !1
|
|
2845
|
-
};
|
|
2846
|
-
#s;
|
|
2847
|
-
#C = 0;
|
|
2848
|
-
#r = null;
|
|
2849
|
-
#g = !1;
|
|
2850
|
-
#x = !1;
|
|
2851
|
-
#m = 0;
|
|
2852
|
-
#O;
|
|
2853
|
-
#N = Ai();
|
|
2854
|
-
#b;
|
|
2855
|
-
#y;
|
|
2856
|
-
#p;
|
|
2857
|
-
#R;
|
|
2858
|
-
#ee = {
|
|
2859
|
-
scrollTop: 0,
|
|
2860
|
-
scrollLeft: 0,
|
|
2861
|
-
scrollHeight: 0,
|
|
2862
|
-
scrollWidth: 0,
|
|
2863
|
-
clientHeight: 0,
|
|
2864
|
-
clientWidth: 0
|
|
2865
|
-
};
|
|
2866
|
-
#t;
|
|
2867
|
-
#_;
|
|
2868
|
-
#q = !1;
|
|
2869
|
-
#D;
|
|
2870
|
-
#G;
|
|
2871
|
-
#M;
|
|
2872
|
-
#i;
|
|
2873
|
-
#e = ui();
|
|
2874
|
-
#c;
|
|
2875
|
-
#$;
|
|
2876
|
-
#W;
|
|
2877
|
-
#k = !1;
|
|
2878
|
-
#E = /* @__PURE__ */ new Set();
|
|
2879
|
-
#H = /* @__PURE__ */ new Map();
|
|
2880
|
-
#F;
|
|
2881
|
-
#S = /* @__PURE__ */ new Map();
|
|
2882
|
-
_rows = [];
|
|
2883
|
-
#X = [];
|
|
2884
|
-
get _columns() {
|
|
2885
|
-
return this.#o.columns ?? [];
|
|
2886
|
-
}
|
|
2887
|
-
set _columns(e) {
|
|
2888
|
-
this.#o.columns = e;
|
|
2889
|
-
}
|
|
2890
|
-
get _visibleColumns() {
|
|
2891
|
-
return this._columns.filter((e) => !e.hidden);
|
|
2892
|
-
}
|
|
2893
|
-
_headerRowEl;
|
|
2894
|
-
_bodyEl;
|
|
2895
|
-
_rowPool = [];
|
|
2896
|
-
_resizeController;
|
|
2897
|
-
_virtualization = {
|
|
2898
|
-
enabled: !0,
|
|
2899
|
-
rowHeight: 28,
|
|
2900
|
-
bypassThreshold: 24,
|
|
2901
|
-
start: 0,
|
|
2902
|
-
end: 0,
|
|
2903
|
-
container: null,
|
|
2904
|
-
viewportEl: null,
|
|
2905
|
-
totalHeightEl: null,
|
|
2906
|
-
positionCache: null,
|
|
2907
|
-
heightCache: {
|
|
2908
|
-
byKey: /* @__PURE__ */ new Map(),
|
|
2909
|
-
byRef: /* @__PURE__ */ new WeakMap()
|
|
2910
|
-
},
|
|
2911
|
-
averageHeight: 28,
|
|
2912
|
-
measuredCount: 0,
|
|
2913
|
-
variableHeights: !1,
|
|
2914
|
-
cachedViewportHeight: 0,
|
|
2915
|
-
cachedFauxHeight: 0,
|
|
2916
|
-
cachedScrollAreaHeight: 0,
|
|
2917
|
-
scrollAreaEl: null
|
|
2918
|
-
};
|
|
2919
|
-
_focusRow = 0;
|
|
2920
|
-
_focusCol = 0;
|
|
2921
|
-
_restoreFocusAfterRender = !1;
|
|
2922
|
-
_sortState = null;
|
|
2923
|
-
_gridTemplate = "";
|
|
2924
|
-
__rowRenderEpoch = 0;
|
|
2925
|
-
__didInitialAutoSize = !1;
|
|
2926
|
-
get __lightDomColumnsCache() {
|
|
2927
|
-
return this.#i?.lightDomColumnsCache;
|
|
2928
|
-
}
|
|
2929
|
-
set __lightDomColumnsCache(e) {
|
|
2930
|
-
this.#i && (this.#i.lightDomColumnsCache = e);
|
|
2931
|
-
}
|
|
2932
|
-
get __originalColumnNodes() {
|
|
2933
|
-
return this.#i?.originalColumnNodes;
|
|
2934
|
-
}
|
|
2935
|
-
set __originalColumnNodes(e) {
|
|
2936
|
-
this.#i && (this.#i.originalColumnNodes = e);
|
|
2937
|
-
}
|
|
2938
|
-
__originalOrder = [];
|
|
2939
|
-
__frameworkAdapter;
|
|
2940
|
-
__rowsBodyEl = null;
|
|
2941
|
-
get rows() {
|
|
2942
|
-
return this._rows;
|
|
2943
|
-
}
|
|
2944
|
-
set rows(e) {
|
|
2945
|
-
const i = this.#l;
|
|
2946
|
-
this.#l = e, i !== e && this.#B("rows");
|
|
2947
|
-
}
|
|
2948
|
-
get sourceRows() {
|
|
2949
|
-
return this.#l;
|
|
2950
|
-
}
|
|
2951
|
-
get columns() {
|
|
2952
|
-
return [...this._columns];
|
|
2953
|
-
}
|
|
2954
|
-
set columns(e) {
|
|
2955
|
-
const i = this.#i?.getColumns();
|
|
2956
|
-
this.#i?.setColumns(e), i !== e && this.#B("columns");
|
|
2957
|
-
}
|
|
2958
|
-
get gridConfig() {
|
|
2959
|
-
return this.#o;
|
|
2960
|
-
}
|
|
2961
|
-
set gridConfig(e) {
|
|
2962
|
-
const i = this.#i?.getGridConfig();
|
|
2963
|
-
this.#i?.setGridConfig(e), i !== e && (this.#i.clearLightDomCache(), this.#B("gridConfig"));
|
|
2964
|
-
}
|
|
2965
|
-
get fitMode() {
|
|
2966
|
-
return this.#o.fitMode ?? "stretch";
|
|
2967
|
-
}
|
|
2968
|
-
set fitMode(e) {
|
|
2969
|
-
const i = this.#i?.getFitMode();
|
|
2970
|
-
this.#i?.setFitMode(e), i !== e && this.#B("fitMode");
|
|
2971
|
-
}
|
|
2972
|
-
get loading() {
|
|
2973
|
-
return this.#k;
|
|
2974
|
-
}
|
|
2975
|
-
set loading(e) {
|
|
2976
|
-
const i = this.#k;
|
|
2977
|
-
this.#k = e, e ? this.setAttribute("loading", "") : this.removeAttribute("loading"), i !== e && this.#ue();
|
|
2978
|
-
}
|
|
2979
|
-
setRowLoading(e, i) {
|
|
2980
|
-
const o = this.#E.has(e);
|
|
2981
|
-
i ? this.#E.add(e) : this.#E.delete(e), o !== i && this.#K(e, i);
|
|
2982
|
-
}
|
|
2983
|
-
setCellLoading(e, i, o) {
|
|
2984
|
-
let n = this.#H.get(e);
|
|
2985
|
-
const r = n?.has(i) ?? !1;
|
|
2986
|
-
o ? (n || (n = /* @__PURE__ */ new Set(), this.#H.set(e, n)), n.add(i)) : (n?.delete(i), n?.size === 0 && this.#H.delete(e)), r !== o && this.#fe(e, i, o);
|
|
2987
|
-
}
|
|
2988
|
-
isRowLoading(e) {
|
|
2989
|
-
return this.#E.has(e);
|
|
2990
|
-
}
|
|
2991
|
-
isCellLoading(e, i) {
|
|
2992
|
-
return this.#H.get(e)?.has(i) ?? !1;
|
|
2993
|
-
}
|
|
2994
|
-
clearAllLoading() {
|
|
2995
|
-
this.loading = !1;
|
|
2996
|
-
for (const e of this.#E)
|
|
2997
|
-
this.#K(e, !1);
|
|
2998
|
-
this.#E.clear();
|
|
2999
|
-
for (const [e, i] of this.#H)
|
|
3000
|
-
for (const o of i)
|
|
3001
|
-
this.#fe(e, o, !1);
|
|
3002
|
-
this.#H.clear();
|
|
3003
|
-
}
|
|
3004
|
-
get effectiveConfig() {
|
|
3005
|
-
return this.#o;
|
|
3006
|
-
}
|
|
3007
|
-
get disconnectSignal() {
|
|
3008
|
-
return this.#b || (this.#b = new AbortController()), this.#b.signal;
|
|
3009
|
-
}
|
|
3010
|
-
constructor() {
|
|
3011
|
-
super(), this.#me(), this.#d = new Promise((e) => this.#h = e), this.#s = new ii({
|
|
3012
|
-
mergeConfig: () => {
|
|
3013
|
-
this.#i.parseLightDomColumns(this), this.#i.merge(), this.#ie(), ki(this.#o, this.#t?.getPlugins() ?? []), Ii(this.#t?.getPlugins() ?? []), qi(this.#t?.getPlugins() ?? []), this.#Oe(), this.#X = [...this._columns];
|
|
3014
|
-
},
|
|
3015
|
-
processColumns: () => this.#He(),
|
|
3016
|
-
processRows: () => this.#Pe(),
|
|
3017
|
-
renderHeader: () => oe(this),
|
|
3018
|
-
updateTemplate: () => B(this),
|
|
3019
|
-
renderVirtualWindow: () => this.refreshVirtualWindow(!0, !0),
|
|
3020
|
-
afterRender: () => {
|
|
3021
|
-
this.#t?.afterRender(), this._virtualization.enabled && this._virtualization.totalHeightEl && queueMicrotask(() => {
|
|
3022
|
-
if (!this._virtualization.totalHeightEl) return;
|
|
3023
|
-
const i = this.#T(this._rows.length);
|
|
3024
|
-
this._virtualization.totalHeightEl.style.height = `${i}px`;
|
|
3025
|
-
}), this.#o.fitMode === "fixed" && !this.__didInitialAutoSize && (this.__didInitialAutoSize = !0, Te(this)), this._restoreFocusAfterRender && (this._restoreFocusAfterRender = !1, F(this)), this._virtualization.enabled && !this.#U && this.#ye(), this.#x && (this.#x = !1, requestAnimationFrame(() => {
|
|
3026
|
-
requestAnimationFrame(() => {
|
|
3027
|
-
this.#Ce();
|
|
3028
|
-
});
|
|
3029
|
-
})), this.#k && this.#ue();
|
|
3030
|
-
},
|
|
3031
|
-
isConnected: () => this.isConnected && this.#f
|
|
3032
|
-
}), this.#s.setInitialReadyResolver(() => this.#h?.()), this.#c = vi(this.#e, {
|
|
3033
|
-
getShadow: () => this.#n,
|
|
3034
|
-
getShellConfig: () => this.#o?.shell,
|
|
3035
|
-
getAccordionIcons: () => ({
|
|
3036
|
-
expand: this.#o?.icons?.expand ?? M.expand,
|
|
3037
|
-
collapse: this.#o?.icons?.collapse ?? M.collapse
|
|
3038
|
-
}),
|
|
3039
|
-
emit: (e, i) => this.#L(e, i),
|
|
3040
|
-
refreshShellHeader: () => this.refreshShellHeader()
|
|
3041
|
-
}), this.#i = new Pt({
|
|
3042
|
-
getRows: () => this.#l,
|
|
3043
|
-
getSortState: () => this._sortState,
|
|
3044
|
-
setSortState: (e) => {
|
|
3045
|
-
this._sortState = e;
|
|
3046
|
-
},
|
|
3047
|
-
onConfigChange: () => {
|
|
3048
|
-
this.#s.requestPhase(A.FULL, "configChange");
|
|
3049
|
-
},
|
|
3050
|
-
emit: (e, i) => this.#L(e, i),
|
|
3051
|
-
clearRowPool: () => {
|
|
3052
|
-
this._rowPool.length = 0, this._bodyEl && (this._bodyEl.innerHTML = ""), this.__rowRenderEpoch++;
|
|
3053
|
-
},
|
|
3054
|
-
setup: () => this.#z(),
|
|
3055
|
-
renderHeader: () => oe(this),
|
|
3056
|
-
updateTemplate: () => B(this),
|
|
3057
|
-
refreshVirtualWindow: () => this.#s.requestPhase(A.VIRTUALIZATION, "configManager"),
|
|
3058
|
-
getVirtualization: () => this._virtualization,
|
|
3059
|
-
setRowHeight: (e) => {
|
|
3060
|
-
this._virtualization.rowHeight = e;
|
|
3061
|
-
},
|
|
3062
|
-
applyAnimationConfig: (e) => this.#ze(e),
|
|
3063
|
-
getShellLightDomTitle: () => this.#e.lightDomTitle,
|
|
3064
|
-
getShellToolPanels: () => this.#e.toolPanels,
|
|
3065
|
-
getShellHeaderContents: () => this.#e.headerContents,
|
|
3066
|
-
getShellToolbarContents: () => this.#e.toolbarContents,
|
|
3067
|
-
getShellLightDomHeaderContent: () => this.#e.lightDomHeaderContent,
|
|
3068
|
-
getShellHasToolButtonsContainer: () => this.#e.hasToolButtonsContainer
|
|
3069
|
-
});
|
|
3070
|
-
}
|
|
3071
|
-
async #me() {
|
|
3072
|
-
await Ri(oo);
|
|
3073
|
-
}
|
|
3074
|
-
getPlugin(e) {
|
|
3075
|
-
return this.#t?.getPlugin(e);
|
|
3076
|
-
}
|
|
3077
|
-
getPluginByName(e) {
|
|
3078
|
-
return this.#t?.getPluginByName(e);
|
|
3079
|
-
}
|
|
3080
|
-
requestRender() {
|
|
3081
|
-
this.#s.requestPhase(A.ROWS, "plugin:requestRender");
|
|
3082
|
-
}
|
|
3083
|
-
requestColumnsRender() {
|
|
3084
|
-
this.#s.requestPhase(A.COLUMNS, "plugin:requestColumnsRender");
|
|
3085
|
-
}
|
|
3086
|
-
requestRenderWithFocus() {
|
|
3087
|
-
this._restoreFocusAfterRender = !0, this.#s.requestPhase(A.ROWS, "plugin:requestRenderWithFocus");
|
|
3088
|
-
}
|
|
3089
|
-
updateTemplate() {
|
|
3090
|
-
B(this);
|
|
3091
|
-
}
|
|
3092
|
-
requestAfterRender() {
|
|
3093
|
-
this.#s.requestPhase(A.STYLE, "plugin:requestAfterRender");
|
|
3094
|
-
}
|
|
3095
|
-
#te() {
|
|
3096
|
-
this.#t = new ne(this);
|
|
3097
|
-
const e = this.#o?.plugins, i = Array.isArray(e) ? e : [];
|
|
3098
|
-
this.#t.attachAll(i);
|
|
3099
|
-
}
|
|
3100
|
-
#V() {
|
|
3101
|
-
const e = this.#t?.getPluginStyles() ?? [];
|
|
3102
|
-
Ei(e);
|
|
3103
|
-
}
|
|
3104
|
-
#ie() {
|
|
3105
|
-
const e = this.#o?.plugins, i = Array.isArray(e) ? e : [];
|
|
3106
|
-
if (this.#_ === i)
|
|
3107
|
-
return;
|
|
3108
|
-
if (this.#_ && this.#_.length === i.length && this.#_.every((n, r) => n === i[r])) {
|
|
3109
|
-
this.#_ = i;
|
|
3110
|
-
return;
|
|
3111
|
-
}
|
|
3112
|
-
this.#t && this.#t.detachAll();
|
|
3113
|
-
for (const n of this.#e.toolPanels.keys()) {
|
|
3114
|
-
const r = this.#e.lightDomToolPanelIds.has(n), s = this.#e.apiToolPanelIds.has(n);
|
|
3115
|
-
if (!r && !s) {
|
|
3116
|
-
const l = this.#e.panelCleanups.get(n);
|
|
3117
|
-
l && (l(), this.#e.panelCleanups.delete(n)), this.#e.toolPanels.delete(n);
|
|
3118
|
-
}
|
|
3119
|
-
}
|
|
3120
|
-
for (const n of this.#e.headerContents.keys()) {
|
|
3121
|
-
const r = this.#e.headerContentCleanups.get(n);
|
|
3122
|
-
r && (r(), this.#e.headerContentCleanups.delete(n)), this.#e.headerContents.delete(n);
|
|
3123
|
-
}
|
|
3124
|
-
this.#te(), this.#V(), this.#_ = i, this.#se(), this.#oe();
|
|
3125
|
-
const o = this.#g;
|
|
3126
|
-
if (this.#g = this.#t?.getAll().some((n) => n.onScroll) ?? !1, !o && this.#g) {
|
|
3127
|
-
const r = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
|
|
3128
|
-
this.#Y(r);
|
|
3129
|
-
}
|
|
3130
|
-
}
|
|
3131
|
-
#ve() {
|
|
3132
|
-
this.#t?.detachAll();
|
|
3133
|
-
}
|
|
3134
|
-
#oe() {
|
|
3135
|
-
if (!this.#t) return;
|
|
3136
|
-
const e = this.#t.getToolPanels();
|
|
3137
|
-
for (const { panel: o } of e)
|
|
3138
|
-
this.#e.toolPanels.has(o.id) || this.#e.toolPanels.set(o.id, o);
|
|
3139
|
-
const i = this.#t.getHeaderContents();
|
|
3140
|
-
for (const { content: o } of i)
|
|
3141
|
-
this.#e.headerContents.has(o.id) || this.#e.headerContents.set(o.id, o);
|
|
3142
|
-
}
|
|
3143
|
-
#ne() {
|
|
3144
|
-
const e = I.getAdapters();
|
|
3145
|
-
if (e.length === 0 && !this.__frameworkAdapter) return;
|
|
3146
|
-
const i = this.__frameworkAdapter;
|
|
3147
|
-
return (o) => {
|
|
3148
|
-
if (i?.createToolPanelRenderer) {
|
|
3149
|
-
const n = i.createToolPanelRenderer(o);
|
|
3150
|
-
if (n) return n;
|
|
3151
|
-
}
|
|
3152
|
-
for (const n of e)
|
|
3153
|
-
if (n.createToolPanelRenderer) {
|
|
3154
|
-
const r = n.createToolPanelRenderer(o);
|
|
3155
|
-
if (r) return r;
|
|
3156
|
-
}
|
|
3157
|
-
};
|
|
3158
|
-
}
|
|
3159
|
-
connectedCallback() {
|
|
3160
|
-
this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", I.version), this.id || (this.id = `tbw-grid-${++I.#a}`), this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#b && (this.#b.abort(), this.#q = !1), this.#b = new AbortController(), this.#R && (ke(this.#R), this.#R = void 0), this.#I(), this.#i.parseLightDomColumns(this), this.#i.merge(), this.#te();
|
|
3161
|
-
const e = this.#o?.plugins;
|
|
3162
|
-
this.#_ = Array.isArray(e) ? e : [], this.#oe(), this.#u || (this.#J(), this.#V(), this.#u = !0), this.#re(), this.#R = Yt(
|
|
3163
|
-
() => {
|
|
3164
|
-
this.#Ie();
|
|
3165
|
-
},
|
|
3166
|
-
{ timeout: 100 }
|
|
3167
|
-
);
|
|
3168
|
-
}
|
|
3169
|
-
disconnectedCallback() {
|
|
3170
|
-
this.#R && (ke(this.#R), this.#R = void 0), this.#m && (clearTimeout(this.#m), this.#m = 0), this.#ve(), mi(this.#e), this.#c.setInitialized(!1), this.#$?.(), this.#$ = void 0, this.#W?.(), this.#W = void 0, ct(this.#N), this.#b && (this.#b.abort(), this.#b = void 0), this.#D?.abort(), this.#D = void 0, this.#q = !1, this._resizeController && this._resizeController.dispose(), this.#y && (this.#y.disconnect(), this.#y = void 0), this.#p && (this.#p.disconnect(), this.#p = void 0, this.#U = !1), W(this), this.#A.clear(), this.#_ = void 0;
|
|
3171
|
-
for (const e of this._rowPool)
|
|
3172
|
-
e.remove();
|
|
3173
|
-
this._rowPool.length = 0, this.__rowsBodyEl = null, this.#f = !1;
|
|
3174
|
-
}
|
|
3175
|
-
attributeChangedCallback(e, i, o) {
|
|
3176
|
-
if (e === "loading") {
|
|
3177
|
-
const n = o !== null && o !== "false";
|
|
3178
|
-
this.loading !== n && (this.loading = n);
|
|
3179
|
-
return;
|
|
3180
|
-
}
|
|
3181
|
-
if (!(i === o || !o || o === "null" || o === "undefined"))
|
|
3182
|
-
if (e === "rows" || e === "columns" || e === "grid-config")
|
|
3183
|
-
try {
|
|
3184
|
-
const n = JSON.parse(o);
|
|
3185
|
-
e === "rows" ? this.rows = n : e === "columns" ? this.columns = n : e === "grid-config" && (this.gridConfig = n);
|
|
3186
|
-
} catch {
|
|
3187
|
-
console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`, o);
|
|
3188
|
-
}
|
|
3189
|
-
else e === "fit-mode" && (this.fitMode = o);
|
|
3190
|
-
}
|
|
3191
|
-
#re() {
|
|
3192
|
-
const i = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
|
|
3193
|
-
if (this._headerRowEl = i?.querySelector(".header-row"), this._virtualization.totalHeightEl = i?.querySelector(".faux-vscroll-spacer"), this._virtualization.viewportEl = i?.querySelector(".rows-viewport"), this._bodyEl = i?.querySelector(".rows"), this.__rowsBodyEl = i?.querySelector(".rows-body"), this.#c.isInitialized) {
|
|
3194
|
-
pe(this.#n, this.#e), de(this.#n, this.#o?.shell, this.#e);
|
|
3195
|
-
const n = this.#o?.shell?.toolPanel?.defaultOpen;
|
|
3196
|
-
n && this.#e.toolPanels.has(n) && (this.openToolPanel(), this.#e.expandedSections.add(n));
|
|
3197
|
-
}
|
|
3198
|
-
if (this.setAttribute("data-upgraded", ""), this.#f = !0, this._resizeController = Ie(this), this.#z(), this.#Y(i), this.#q)
|
|
3199
|
-
return;
|
|
3200
|
-
this.#q = !0;
|
|
3201
|
-
const o = this.disconnectSignal;
|
|
3202
|
-
Vt(this, this, this.#n, o), this.#se(), queueMicrotask(() => this.#_e()), this.#s.requestPhase(A.FULL, "afterConnect");
|
|
3203
|
-
}
|
|
3204
|
-
#se() {
|
|
3205
|
-
const e = this.#o.rowHeight, i = this.#t.hasRowHeightPlugin();
|
|
3206
|
-
typeof e == "function" || i ? this._virtualization.variableHeights || (this._virtualization.variableHeights = !0, this._virtualization.rowHeight = typeof e == "number" && e > 0 ? e : this._virtualization.rowHeight || 28, this.#Z(), typeof e != "function" && (this.#x = !0)) : !i && typeof e != "function" && this._virtualization.variableHeights ? (this._virtualization.variableHeights = !1, this._virtualization.positionCache = null) : typeof e == "number" && e > 0 ? (this._virtualization.rowHeight = e, this._virtualization.variableHeights = !1) : requestAnimationFrame(() => this.#le());
|
|
3207
|
-
}
|
|
3208
|
-
#le() {
|
|
3209
|
-
if (this.#t.hasExtraHeight())
|
|
3210
|
-
return;
|
|
3211
|
-
const e = this._bodyEl?.querySelector(".data-grid-row");
|
|
3212
|
-
if (!e) return;
|
|
3213
|
-
const i = e.querySelectorAll(".cell");
|
|
3214
|
-
let o = 0;
|
|
3215
|
-
i.forEach((s) => {
|
|
3216
|
-
const l = s.offsetHeight;
|
|
3217
|
-
l > o && (o = l);
|
|
3218
|
-
});
|
|
3219
|
-
const n = e.getBoundingClientRect(), r = Math.max(n.height, o);
|
|
3220
|
-
r > 0 && Math.abs(r - this._virtualization.rowHeight) > 1 && (this._virtualization.rowHeight = r, this.#s.requestPhase(A.VIRTUALIZATION, "measureRowHeight"));
|
|
3221
|
-
}
|
|
3222
|
-
#Ce() {
|
|
3223
|
-
const e = this._bodyEl?.querySelector(".data-grid-row");
|
|
3224
|
-
if (!e) return;
|
|
3225
|
-
const i = e.querySelectorAll(".cell");
|
|
3226
|
-
let o = 0;
|
|
3227
|
-
i.forEach((s) => {
|
|
3228
|
-
const l = s.offsetHeight;
|
|
3229
|
-
l > o && (o = l);
|
|
3230
|
-
});
|
|
3231
|
-
const n = e.getBoundingClientRect(), r = Math.max(n.height, o);
|
|
3232
|
-
if (r > 0 && (Math.abs(r - this._virtualization.rowHeight) > 1 && (this._virtualization.rowHeight = r), this.#Z(), this._virtualization.totalHeightEl)) {
|
|
3233
|
-
const l = this.#T(this._rows.length);
|
|
3234
|
-
this._virtualization.totalHeightEl.style.height = `${l}px`;
|
|
3235
|
-
}
|
|
3236
|
-
}
|
|
3237
|
-
#Y(e) {
|
|
3238
|
-
this.#D?.abort(), this.#D = new AbortController();
|
|
3239
|
-
const i = this.#D.signal, o = e?.querySelector(".faux-vscroll"), n = e?.querySelector(".rows");
|
|
3240
|
-
if (this._virtualization.container = o ?? this, this.#g = this.#t?.getAll().some((r) => r.onScroll) ?? !1, o && n) {
|
|
3241
|
-
o.addEventListener(
|
|
3242
|
-
"scroll",
|
|
3243
|
-
() => {
|
|
3244
|
-
if (!this._virtualization.enabled && !this.#g) return;
|
|
3245
|
-
const a = o.scrollTop, c = this._virtualization.rowHeight;
|
|
3246
|
-
if (this._rows.length <= this._virtualization.bypassThreshold)
|
|
3247
|
-
n.style.transform = `translateY(${-a}px)`;
|
|
3248
|
-
else {
|
|
3249
|
-
const h = this._virtualization.positionCache;
|
|
3250
|
-
let f, p;
|
|
3251
|
-
if (this._virtualization.variableHeights && h && h.length > 0) {
|
|
3252
|
-
f = Ge(h, a), f === -1 && (f = 0);
|
|
3253
|
-
const u = f - f % 2;
|
|
3254
|
-
p = h[u]?.offset ?? u * c;
|
|
3255
|
-
} else
|
|
3256
|
-
f = Math.floor(a / c), p = (f - f % 2) * c;
|
|
3257
|
-
const g = -(a - p);
|
|
3258
|
-
n.style.transform = `translateY(${g}px)`;
|
|
3259
|
-
}
|
|
3260
|
-
this.#r = a, this.#C || (this.#C = requestAnimationFrame(() => {
|
|
3261
|
-
this.#C = 0, this.#r !== null && (this.#De(this.#r), this.#r = null);
|
|
3262
|
-
}));
|
|
3263
|
-
},
|
|
3264
|
-
{ passive: !0, signal: i }
|
|
3265
|
-
);
|
|
3266
|
-
const r = this.#n.querySelector(".tbw-scroll-area");
|
|
3267
|
-
this.#G = r, this._virtualization.scrollAreaEl = r, r && this.#g && r.addEventListener(
|
|
3268
|
-
"scroll",
|
|
3269
|
-
() => {
|
|
3270
|
-
const a = this.#ee;
|
|
3271
|
-
a.scrollTop = o.scrollTop, a.scrollLeft = r.scrollLeft, a.scrollHeight = o.scrollHeight, a.scrollWidth = r.scrollWidth, a.clientHeight = o.clientHeight, a.clientWidth = r.clientWidth, this.#t?.onScroll(a);
|
|
3272
|
-
},
|
|
3273
|
-
{ passive: !0, signal: i }
|
|
3274
|
-
);
|
|
3275
|
-
const s = this.#n.querySelector(".tbw-grid-content"), l = this.#G;
|
|
3276
|
-
s && (s.addEventListener(
|
|
3277
|
-
"wheel",
|
|
3278
|
-
(a) => {
|
|
3279
|
-
const c = a.shiftKey || Math.abs(a.deltaX) > Math.abs(a.deltaY);
|
|
3280
|
-
if (c && l) {
|
|
3281
|
-
const h = a.shiftKey ? a.deltaY : a.deltaX, { scrollLeft: f, scrollWidth: p, clientWidth: g } = l;
|
|
3282
|
-
(h > 0 && f < p - g || h < 0 && f > 0) && (a.preventDefault(), l.scrollLeft += h);
|
|
3283
|
-
} else if (!c) {
|
|
3284
|
-
const { scrollTop: h, scrollHeight: f, clientHeight: p } = o;
|
|
3285
|
-
(a.deltaY > 0 && h < f - p || a.deltaY < 0 && h > 0) && (a.preventDefault(), o.scrollTop += a.deltaY);
|
|
3286
|
-
}
|
|
3287
|
-
},
|
|
3288
|
-
{ passive: !1, signal: i }
|
|
3289
|
-
), zi(
|
|
3290
|
-
s,
|
|
3291
|
-
this.#N,
|
|
3292
|
-
{ fauxScrollbar: o, scrollArea: l },
|
|
3293
|
-
i
|
|
3294
|
-
));
|
|
3295
|
-
}
|
|
3296
|
-
this._bodyEl && Ft(this, this._bodyEl, i), this.#y?.disconnect(), this._virtualization.viewportEl && (this.#y = new ResizeObserver(() => {
|
|
3297
|
-
this.#Ne(), this.#s.requestPhase(A.VIRTUALIZATION, "resize-observer");
|
|
3298
|
-
}), this.#y.observe(this._virtualization.viewportEl)), this.#n.addEventListener(
|
|
3299
|
-
"focusin",
|
|
3300
|
-
() => {
|
|
3301
|
-
this.dataset.hasFocus = "";
|
|
3302
|
-
},
|
|
3303
|
-
{ signal: i }
|
|
3304
|
-
), this.#n.addEventListener(
|
|
3305
|
-
"focusout",
|
|
3306
|
-
(r) => {
|
|
3307
|
-
const s = r.relatedTarget;
|
|
3308
|
-
(!s || !this.#n.contains(s)) && delete this.dataset.hasFocus;
|
|
3309
|
-
},
|
|
3310
|
-
{ signal: i }
|
|
3311
|
-
);
|
|
3312
|
-
}
|
|
3313
|
-
#U = !1;
|
|
3314
|
-
#ye() {
|
|
3315
|
-
if (this.#U) return;
|
|
3316
|
-
const e = this._bodyEl?.querySelector(".data-grid-row");
|
|
3317
|
-
e && (this.#U = !0, this.#p?.disconnect(), this.#p = new ResizeObserver(() => {
|
|
3318
|
-
this.#le();
|
|
3319
|
-
}), this.#p.observe(e));
|
|
3320
|
-
}
|
|
3321
|
-
addEventListener(e, i, o) {
|
|
3322
|
-
super.addEventListener(e, i, o);
|
|
3323
|
-
}
|
|
3324
|
-
removeEventListener(e, i, o) {
|
|
3325
|
-
super.removeEventListener(e, i, o);
|
|
3326
|
-
}
|
|
3327
|
-
#L(e, i) {
|
|
3328
|
-
this.dispatchEvent(new CustomEvent(e, { detail: i, bubbles: !0, composed: !0 }));
|
|
3329
|
-
}
|
|
3330
|
-
#_e() {
|
|
3331
|
-
this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((i, o) => {
|
|
3332
|
-
const n = o === this._focusRow;
|
|
3333
|
-
i.setAttribute("aria-selected", String(n)), i.querySelectorAll(".cell").forEach((r, s) => {
|
|
3334
|
-
r.setAttribute("aria-selected", String(n && s === this._focusCol));
|
|
3335
|
-
});
|
|
3336
|
-
});
|
|
3337
|
-
}
|
|
3338
|
-
#B(e) {
|
|
3339
|
-
this.#v[e] = !0, !this.#w && (this.#w = !0, queueMicrotask(() => this.#Ee()));
|
|
3340
|
-
}
|
|
3341
|
-
#Ee() {
|
|
3342
|
-
if (!this.#w || !this.#f) {
|
|
3343
|
-
this.#w = !1;
|
|
3344
|
-
return;
|
|
3345
|
-
}
|
|
3346
|
-
const e = this.#v;
|
|
3347
|
-
if (this.#w = !1, this.#v = {
|
|
3348
|
-
rows: !1,
|
|
3349
|
-
columns: !1,
|
|
3350
|
-
gridConfig: !1,
|
|
3351
|
-
fitMode: !1
|
|
3352
|
-
}, e.gridConfig) {
|
|
3353
|
-
this.#Te(), e.rows && this.#ae();
|
|
3354
|
-
return;
|
|
3355
|
-
}
|
|
3356
|
-
e.columns && this.#Re(), e.rows && this.#ae(), e.fitMode && this.#Ae();
|
|
3357
|
-
}
|
|
3358
|
-
#ae() {
|
|
3359
|
-
this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#P(), this.#s.requestPhase(A.ROWS, "applyRowsUpdate");
|
|
3360
|
-
}
|
|
3361
|
-
#P() {
|
|
3362
|
-
this.#S.clear();
|
|
3363
|
-
const e = this.#o.getRowId;
|
|
3364
|
-
this._rows.forEach((i, o) => {
|
|
3365
|
-
const n = this.#ce(i, e);
|
|
3366
|
-
n !== void 0 && this.#S.set(n, { row: i, index: o });
|
|
3367
|
-
});
|
|
3368
|
-
}
|
|
3369
|
-
#ce(e, i) {
|
|
3370
|
-
if (i)
|
|
3371
|
-
return i(e);
|
|
3372
|
-
const o = e;
|
|
3373
|
-
if ("id" in o && o.id != null) return String(o.id);
|
|
3374
|
-
if ("_id" in o && o._id != null) return String(o._id);
|
|
3375
|
-
}
|
|
3376
|
-
#Se(e, i) {
|
|
3377
|
-
const o = this.#ce(e, i);
|
|
3378
|
-
if (o === void 0)
|
|
3379
|
-
throw new Error(
|
|
3380
|
-
'[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.'
|
|
3381
|
-
);
|
|
3382
|
-
return o;
|
|
3383
|
-
}
|
|
3384
|
-
#Re() {
|
|
3385
|
-
W(this), this.#i.merge(), this.#z();
|
|
3386
|
-
}
|
|
3387
|
-
#Ae() {
|
|
3388
|
-
this.#i.merge(), this.#o.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, Te(this)) : (this._columns.forEach((i) => {
|
|
3389
|
-
!i.__userResized && i.__autoSized && delete i.width;
|
|
3390
|
-
}), B(this));
|
|
3391
|
-
}
|
|
3392
|
-
#Te() {
|
|
3393
|
-
qe(this, this.#e), $e(this, this.#e);
|
|
3394
|
-
const e = !!this.#n.querySelector(".has-shell"), i = !!this.#n.querySelector(".tbw-tool-panel"), o = this.#n.querySelectorAll(".tbw-accordion-section").length;
|
|
3395
|
-
this.#i.parseLightDomColumns(this), this.#i.merge(), this.#ie(), We(this, this.#e, this.#ne()), this.#i.markSourcesChanged(), this.#i.merge();
|
|
3396
|
-
const n = at(this.#o?.shell), r = (this.#o?.shell?.toolPanels?.length ?? 0) > 0, s = this.#o?.shell?.toolPanels?.length ?? 0;
|
|
3397
|
-
if (e !== n || !i && r || i && s !== o) {
|
|
3398
|
-
he(this.#e), this.#J(), this.#V(), this.#re(), this.#P();
|
|
3399
|
-
return;
|
|
3400
|
-
}
|
|
3401
|
-
e && this.#xe(), this.#P(), this.#s.requestPhase(A.COLUMNS, "applyGridConfigUpdate");
|
|
3402
|
-
}
|
|
3403
|
-
#xe() {
|
|
3404
|
-
const e = this.#n.querySelector(".tbw-shell-header");
|
|
3405
|
-
if (!e) return;
|
|
3406
|
-
const i = this.#o.shell?.header?.title ?? this.#e.lightDomTitle;
|
|
3407
|
-
let o = e.querySelector(".tbw-shell-title");
|
|
3408
|
-
i ? (o || (o = document.createElement("h2"), o.className = "tbw-shell-title", o.setAttribute("part", "shell-title"), e.insertBefore(o, e.firstChild)), o.textContent = i) : o && o.remove();
|
|
3409
|
-
}
|
|
3410
|
-
#He() {
|
|
3411
|
-
if (this.__rowRenderEpoch++, this.#t) {
|
|
3412
|
-
const e = this.#X.length > 0 ? this.#X : this._columns, i = e.filter((r) => !r.hidden), o = e.filter((r) => r.hidden), n = this.#t.processColumns([...i]);
|
|
3413
|
-
if (n !== i) {
|
|
3414
|
-
const r = new Set(n.map((l) => l.field));
|
|
3415
|
-
!i.some((l) => r.has(l.field)) && n.length > 0 ? this._columns = [...n, ...o] : this._columns = this.#Le(
|
|
3416
|
-
e,
|
|
3417
|
-
n,
|
|
3418
|
-
o
|
|
3419
|
-
);
|
|
3420
|
-
} else
|
|
3421
|
-
this._columns = [...e];
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
#Le(e, i, o) {
|
|
3425
|
-
if (o.length === 0) return i;
|
|
3426
|
-
const n = /* @__PURE__ */ new Map();
|
|
3427
|
-
for (const a of i)
|
|
3428
|
-
n.set(a.field, a);
|
|
3429
|
-
const r = new Set(e.map((a) => a.field)), s = [];
|
|
3430
|
-
for (const a of i)
|
|
3431
|
-
r.has(a.field) || s.push(a);
|
|
3432
|
-
const l = [];
|
|
3433
|
-
for (const a of e) {
|
|
3434
|
-
const c = n.get(a.field);
|
|
3435
|
-
c ? l.push(c) : a.hidden && l.push(a);
|
|
3436
|
-
}
|
|
3437
|
-
return l.push(...s), l;
|
|
3438
|
-
}
|
|
3439
|
-
#Pe() {
|
|
3440
|
-
W(this);
|
|
3441
|
-
const e = Array.isArray(this.#l) ? [...this.#l] : [], i = Bt(this, e), o = this.#t?.processRows(i) ?? i;
|
|
3442
|
-
this._rows = o, this.#P(), this._virtualization.variableHeights && this.#Z();
|
|
3443
|
-
}
|
|
3444
|
-
#ze(e) {
|
|
3445
|
-
const i = {
|
|
3446
|
-
...pt,
|
|
3447
|
-
...e.animation
|
|
3448
|
-
}, o = i.mode ?? "reduced-motion";
|
|
3449
|
-
let n = 1;
|
|
3450
|
-
o === !1 || o === "off" ? n = 0 : (o === !0 || o === "on") && (n = 1), this.style.setProperty("--tbw-animation-duration", `${i.duration}ms`), this.style.setProperty("--tbw-animation-easing", i.easing ?? "ease-out"), this.style.setProperty("--tbw-animation-enabled", String(n)), this.dataset.animationMode = typeof o == "boolean" ? o ? "on" : "off" : o;
|
|
3451
|
-
}
|
|
3452
|
-
#j(e, i, o = this.__rowRenderEpoch) {
|
|
3453
|
-
if (this.#O || (this.#O = (n, r, s) => this.#t?.renderRow(n, r, s) ?? !1), kt(this, e, i, o, this.#O), this.#E.size > 0)
|
|
3454
|
-
for (const n of this.#E)
|
|
3455
|
-
this.#K(n, !0);
|
|
3456
|
-
}
|
|
3457
|
-
#de = ht();
|
|
3458
|
-
#he(e, i) {
|
|
3459
|
-
ut(this.#de, this.__rowsBodyEl, this._bodyEl, e, i);
|
|
3460
|
-
}
|
|
3461
|
-
#Oe() {
|
|
3462
|
-
gt(this.#de, this.__rowsBodyEl, this.#o, this.#e);
|
|
3463
|
-
}
|
|
3464
|
-
#ue() {
|
|
3465
|
-
const e = this.querySelector(".tbw-grid-root");
|
|
3466
|
-
e && (this.#k ? (this.#F || (this.#F = Qt(this.#o?.loadingRenderer)), Zt(e, this.#F)) : Jt(this.#F));
|
|
3467
|
-
}
|
|
3468
|
-
#K(e, i) {
|
|
3469
|
-
const o = this.#S.get(e);
|
|
3470
|
-
if (!o) return;
|
|
3471
|
-
const n = this.findRenderedRowElement?.(o.index);
|
|
3472
|
-
n && ei(n, i);
|
|
3473
|
-
}
|
|
3474
|
-
#fe(e, i, o) {
|
|
3475
|
-
const n = this.#S.get(e);
|
|
3476
|
-
if (!n) return;
|
|
3477
|
-
const r = this.findRenderedRowElement?.(n.index);
|
|
3478
|
-
if (!r) return;
|
|
3479
|
-
const s = this._visibleColumns.findIndex((a) => a.field === i);
|
|
3480
|
-
if (s < 0) return;
|
|
3481
|
-
const l = r.children[s];
|
|
3482
|
-
l && ti(l, o);
|
|
3483
|
-
}
|
|
3484
|
-
#z() {
|
|
3485
|
-
if (this.isConnected && !(!this._headerRowEl || !this._bodyEl)) {
|
|
3486
|
-
if (this.#i.parseLightDomColumns(this), this.#M) {
|
|
3487
|
-
const e = this.#M;
|
|
3488
|
-
this.#M = void 0, this.#i.merge();
|
|
3489
|
-
const i = this.#t?.getAll() ?? [];
|
|
3490
|
-
this.#i.applyState(e, i);
|
|
3491
|
-
}
|
|
3492
|
-
this._bodyEl && (this._bodyEl.style.display = "", this._bodyEl.style.gridTemplateColumns = ""), this.#s.requestPhase(A.FULL, "setup");
|
|
3493
|
-
}
|
|
3494
|
-
}
|
|
3495
|
-
#De(e) {
|
|
3496
|
-
let i = 0, o = 0, n = 0, r = 0, s = 0;
|
|
3497
|
-
if (this.#g) {
|
|
3498
|
-
const a = this._virtualization.container, c = this.#G;
|
|
3499
|
-
i = c?.scrollLeft ?? 0, o = a?.scrollHeight ?? 0, n = c?.scrollWidth ?? 0, r = a?.clientHeight ?? 0, s = c?.clientWidth ?? 0;
|
|
3500
|
-
}
|
|
3501
|
-
if (this.refreshVirtualWindow(!1) && this.#t?.onScrollRender(), this._virtualization.variableHeights && (this.#m && clearTimeout(this.#m), this.#m = window.setTimeout(() => {
|
|
3502
|
-
this.#m = 0, this.#we(this._virtualization.start, this._virtualization.end);
|
|
3503
|
-
}, 100)), this.#g) {
|
|
3504
|
-
const a = this.#ee;
|
|
3505
|
-
a.scrollTop = e, a.scrollLeft = i, a.scrollHeight = o, a.scrollWidth = n, a.clientHeight = r, a.clientWidth = s, this.#t?.onScroll(a);
|
|
3506
|
-
}
|
|
3507
|
-
}
|
|
3508
|
-
findHeaderRow() {
|
|
3509
|
-
return this.#n.querySelector(".header-row");
|
|
3510
|
-
}
|
|
3511
|
-
findRenderedRowElement(e) {
|
|
3512
|
-
return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find((i) => {
|
|
3513
|
-
const o = i.querySelector(".cell[data-row]");
|
|
3514
|
-
return o && Number(o.getAttribute("data-row")) === e;
|
|
3515
|
-
}) || null;
|
|
3516
|
-
}
|
|
3517
|
-
_dispatchCellClick(e, i, o, n) {
|
|
3518
|
-
const r = this._rows[i], s = this._visibleColumns[o];
|
|
3519
|
-
if (!r || !s) return !1;
|
|
3520
|
-
const l = s.field, a = r[l], c = new CustomEvent("cell-activate", {
|
|
3521
|
-
cancelable: !0,
|
|
3522
|
-
bubbles: !0,
|
|
3523
|
-
composed: !0,
|
|
3524
|
-
detail: {
|
|
3525
|
-
rowIndex: i,
|
|
3526
|
-
colIndex: o,
|
|
3527
|
-
column: s,
|
|
3528
|
-
field: l,
|
|
3529
|
-
value: a,
|
|
3530
|
-
row: r,
|
|
3531
|
-
cellEl: n,
|
|
3532
|
-
trigger: "pointer",
|
|
3533
|
-
originalEvent: e
|
|
3534
|
-
}
|
|
3535
|
-
});
|
|
3536
|
-
if (this.dispatchEvent(c), c.defaultPrevented)
|
|
3537
|
-
return !0;
|
|
3538
|
-
const h = {
|
|
3539
|
-
row: r,
|
|
3540
|
-
rowIndex: i,
|
|
3541
|
-
colIndex: o,
|
|
3542
|
-
column: s,
|
|
3543
|
-
field: l,
|
|
3544
|
-
value: a,
|
|
3545
|
-
cellEl: n,
|
|
3546
|
-
originalEvent: e
|
|
3547
|
-
}, f = this.#t?.onCellClick(h) ?? !1;
|
|
3548
|
-
return this.#L("cell-click", h), f;
|
|
3549
|
-
}
|
|
3550
|
-
_dispatchRowClick(e, i, o, n) {
|
|
3551
|
-
if (!o) return !1;
|
|
3552
|
-
const r = {
|
|
3553
|
-
rowIndex: i,
|
|
3554
|
-
row: o,
|
|
3555
|
-
rowEl: n,
|
|
3556
|
-
originalEvent: e
|
|
3557
|
-
}, s = this.#t?.onRowClick(r) ?? !1;
|
|
3558
|
-
return this.#L("row-click", r), s;
|
|
3559
|
-
}
|
|
3560
|
-
_dispatchHeaderClick(e, i, o) {
|
|
3561
|
-
if (!i) return !1;
|
|
3562
|
-
const n = {
|
|
3563
|
-
colIndex: this._columns.indexOf(i),
|
|
3564
|
-
field: i.field,
|
|
3565
|
-
column: i,
|
|
3566
|
-
headerEl: o,
|
|
3567
|
-
originalEvent: e
|
|
3568
|
-
};
|
|
3569
|
-
return this.#t?.onHeaderClick(n) ?? !1;
|
|
3570
|
-
}
|
|
3571
|
-
_dispatchKeyDown(e) {
|
|
3572
|
-
return this.#t?.onKeyDown(e) ?? !1;
|
|
3573
|
-
}
|
|
3574
|
-
_getHorizontalScrollOffsets(e, i) {
|
|
3575
|
-
return this.#t?.getHorizontalScrollOffsets(e, i) ?? { left: 0, right: 0 };
|
|
3576
|
-
}
|
|
3577
|
-
queryPlugins(e) {
|
|
3578
|
-
return this.#t?.queryPlugins(e) ?? [];
|
|
3579
|
-
}
|
|
3580
|
-
query(e, i) {
|
|
3581
|
-
return this.#t?.queryPlugins({ type: e, context: i }) ?? [];
|
|
3582
|
-
}
|
|
3583
|
-
_dispatchCellMouseDown(e) {
|
|
3584
|
-
return this.#t?.onCellMouseDown(e) ?? !1;
|
|
3585
|
-
}
|
|
3586
|
-
_dispatchCellMouseMove(e) {
|
|
3587
|
-
this.#t?.onCellMouseMove(e);
|
|
3588
|
-
}
|
|
3589
|
-
_dispatchCellMouseUp(e) {
|
|
3590
|
-
this.#t?.onCellMouseUp(e);
|
|
3591
|
-
}
|
|
3592
|
-
_afterCellRender(e) {
|
|
3593
|
-
this.#t?.afterCellRender(e);
|
|
3594
|
-
}
|
|
3595
|
-
_hasAfterCellRenderHook() {
|
|
3596
|
-
return this.#t?.hasAfterCellRenderHook() ?? !1;
|
|
3597
|
-
}
|
|
3598
|
-
_afterRowRender(e) {
|
|
3599
|
-
this.#t?.afterRowRender(e);
|
|
3600
|
-
}
|
|
3601
|
-
_hasAfterRowRenderHook() {
|
|
3602
|
-
return this.#t?.hasAfterRowRenderHook() ?? !1;
|
|
3603
|
-
}
|
|
3604
|
-
async ready() {
|
|
3605
|
-
return this.#d;
|
|
3606
|
-
}
|
|
3607
|
-
async forceLayout() {
|
|
3608
|
-
return this.#s.requestPhase(A.FULL, "forceLayout"), this.#s.whenReady();
|
|
3609
|
-
}
|
|
3610
|
-
async getConfig() {
|
|
3611
|
-
return Object.freeze({ ...this.#o || {} });
|
|
3612
|
-
}
|
|
3613
|
-
getRowId(e) {
|
|
3614
|
-
return this.#Se(e, this.#o.getRowId);
|
|
3615
|
-
}
|
|
3616
|
-
getRow(e) {
|
|
3617
|
-
return this.#S.get(e)?.row;
|
|
3618
|
-
}
|
|
3619
|
-
_getRowEntry(e) {
|
|
3620
|
-
return this.#S.get(e);
|
|
3621
|
-
}
|
|
3622
|
-
updateRow(e, i, o = "api") {
|
|
3623
|
-
const n = this.#S.get(e);
|
|
3624
|
-
if (!n)
|
|
3625
|
-
throw new Error(
|
|
3626
|
-
`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`
|
|
3627
|
-
);
|
|
3628
|
-
const { row: r, index: s } = n, l = [];
|
|
3629
|
-
for (const [a, c] of Object.entries(i)) {
|
|
3630
|
-
const h = r[a];
|
|
3631
|
-
h !== c && (l.push({ field: a, oldValue: h, newValue: c }), r[a] = c);
|
|
3632
|
-
}
|
|
3633
|
-
for (const { field: a, oldValue: c, newValue: h } of l)
|
|
3634
|
-
this.#L("cell-change", {
|
|
3635
|
-
row: r,
|
|
3636
|
-
rowId: e,
|
|
3637
|
-
rowIndex: s,
|
|
3638
|
-
field: a,
|
|
3639
|
-
oldValue: c,
|
|
3640
|
-
newValue: h,
|
|
3641
|
-
changes: i,
|
|
3642
|
-
source: o
|
|
3643
|
-
});
|
|
3644
|
-
l.length > 0 && this.#s.requestPhase(A.ROWS, "updateRow");
|
|
3645
|
-
}
|
|
3646
|
-
updateRows(e, i = "api") {
|
|
3647
|
-
let o = !1;
|
|
3648
|
-
for (const { id: n, changes: r } of e) {
|
|
3649
|
-
const s = this.#S.get(n);
|
|
3650
|
-
if (!s)
|
|
3651
|
-
throw new Error(
|
|
3652
|
-
`[tbw-grid] Row with ID "${n}" not found. Ensure the row exists and getRowId is correctly configured.`
|
|
3653
|
-
);
|
|
3654
|
-
const { row: l, index: a } = s;
|
|
3655
|
-
for (const [c, h] of Object.entries(r)) {
|
|
3656
|
-
const f = l[c];
|
|
3657
|
-
f !== h && (o = !0, l[c] = h, this.#L("cell-change", {
|
|
3658
|
-
row: l,
|
|
3659
|
-
rowId: n,
|
|
3660
|
-
rowIndex: a,
|
|
3661
|
-
field: c,
|
|
3662
|
-
oldValue: f,
|
|
3663
|
-
newValue: h,
|
|
3664
|
-
changes: r,
|
|
3665
|
-
source: i
|
|
3666
|
-
}));
|
|
3667
|
-
}
|
|
3668
|
-
}
|
|
3669
|
-
o && this.#s.requestPhase(A.ROWS, "updateRows");
|
|
3670
|
-
}
|
|
3671
|
-
animateRow(e, i) {
|
|
3672
|
-
return Se(this, e, i);
|
|
3673
|
-
}
|
|
3674
|
-
animateRows(e, i) {
|
|
3675
|
-
return ai(this, e, i);
|
|
3676
|
-
}
|
|
3677
|
-
animateRowById(e, i) {
|
|
3678
|
-
return ci(this, e, i);
|
|
3679
|
-
}
|
|
3680
|
-
async insertRow(e, i, o = !0) {
|
|
3681
|
-
const n = Math.max(0, Math.min(e, this._rows.length));
|
|
3682
|
-
this.#l = [...this.#l, i];
|
|
3683
|
-
const r = [...this._rows];
|
|
3684
|
-
r.splice(n, 0, i), this._rows = r, this._sortState && (this.__originalOrder = [...this.__originalOrder, i]), W(this), this.#P(), this.__rowRenderEpoch++;
|
|
3685
|
-
for (const s of this._rowPool) s.__epoch = -1;
|
|
3686
|
-
this.refreshVirtualWindow(!0), o && (await new Promise((s) => requestAnimationFrame(() => s())), await this.animateRow(n, "insert"));
|
|
3687
|
-
}
|
|
3688
|
-
async removeRow(e, i = !0) {
|
|
3689
|
-
const o = this._rows[e];
|
|
3690
|
-
if (!o) return;
|
|
3691
|
-
i && await this.animateRow(e, "remove");
|
|
3692
|
-
const n = this._rows.indexOf(o);
|
|
3693
|
-
if (n < 0) return o;
|
|
3694
|
-
const r = [...this._rows];
|
|
3695
|
-
r.splice(n, 1), this._rows = r;
|
|
3696
|
-
const s = this.#l.indexOf(o);
|
|
3697
|
-
if (s >= 0) {
|
|
3698
|
-
const l = [...this.#l];
|
|
3699
|
-
l.splice(s, 1), this.#l = l;
|
|
3700
|
-
}
|
|
3701
|
-
if (this._sortState) {
|
|
3702
|
-
const l = this.__originalOrder.indexOf(o);
|
|
3703
|
-
if (l >= 0) {
|
|
3704
|
-
const a = [...this.__originalOrder];
|
|
3705
|
-
a.splice(l, 1), this.__originalOrder = a;
|
|
3706
|
-
}
|
|
3707
|
-
}
|
|
3708
|
-
W(this), this.#P(), this.__rowRenderEpoch++;
|
|
3709
|
-
for (const l of this._rowPool) l.__epoch = -1;
|
|
3710
|
-
return this.refreshVirtualWindow(!0), i && requestAnimationFrame(() => {
|
|
3711
|
-
this.querySelectorAll('[data-animating="remove"]').forEach((l) => {
|
|
3712
|
-
l.removeAttribute("data-animating");
|
|
3713
|
-
});
|
|
3714
|
-
}), o;
|
|
3715
|
-
}
|
|
3716
|
-
suspendProcessing() {
|
|
3717
|
-
}
|
|
3718
|
-
setColumnVisible(e, i) {
|
|
3719
|
-
const o = this.#i.setColumnVisible(e, i);
|
|
3720
|
-
return o && this.requestStateChange(), o;
|
|
3721
|
-
}
|
|
3722
|
-
toggleColumnVisibility(e) {
|
|
3723
|
-
const i = this.#i.toggleColumnVisibility(e);
|
|
3724
|
-
return i && this.requestStateChange(), i;
|
|
3725
|
-
}
|
|
3726
|
-
isColumnVisible(e) {
|
|
3727
|
-
return this.#i.isColumnVisible(e);
|
|
3728
|
-
}
|
|
3729
|
-
showAllColumns() {
|
|
3730
|
-
this.#i.showAllColumns(), this.requestStateChange();
|
|
3731
|
-
}
|
|
3732
|
-
getAllColumns() {
|
|
3733
|
-
return this.#i.getAllColumns();
|
|
3734
|
-
}
|
|
3735
|
-
setColumnOrder(e) {
|
|
3736
|
-
this.#i.setColumnOrder(e), this.requestStateChange();
|
|
3737
|
-
}
|
|
3738
|
-
getColumnOrder() {
|
|
3739
|
-
return this.#i.getColumnOrder();
|
|
3740
|
-
}
|
|
3741
|
-
getColumnState() {
|
|
3742
|
-
const e = this.#t?.getAll() ?? [];
|
|
3743
|
-
return this.#i.collectState(e);
|
|
3744
|
-
}
|
|
3745
|
-
set columnState(e) {
|
|
3746
|
-
e && (this.#M = e, this.#i.initialColumnState = e, this.#u && this.#Me(e));
|
|
3747
|
-
}
|
|
3748
|
-
get columnState() {
|
|
3749
|
-
return this.getColumnState();
|
|
3750
|
-
}
|
|
3751
|
-
#Me(e) {
|
|
3752
|
-
const i = this.#t?.getAll() ?? [];
|
|
3753
|
-
this.#i.applyState(e, i), this.#z();
|
|
3754
|
-
}
|
|
3755
|
-
requestStateChange() {
|
|
3756
|
-
const e = this.#t?.getAll() ?? [];
|
|
3757
|
-
this.#i.requestStateChange(e);
|
|
3758
|
-
}
|
|
3759
|
-
resetColumnState() {
|
|
3760
|
-
this.#M = void 0, this.__originalOrder = [];
|
|
3761
|
-
const e = this.#t?.getAll() ?? [];
|
|
3762
|
-
this.#i.resetState(e), this.#i.merge(), this.#z();
|
|
3763
|
-
}
|
|
3764
|
-
get isToolPanelOpen() {
|
|
3765
|
-
return this.#c.isPanelOpen;
|
|
3766
|
-
}
|
|
3767
|
-
get defaultRowHeight() {
|
|
3768
|
-
return this._virtualization.rowHeight;
|
|
3769
|
-
}
|
|
3770
|
-
get expandedToolPanelSections() {
|
|
3771
|
-
return this.#c.expandedSections;
|
|
3772
|
-
}
|
|
3773
|
-
openToolPanel() {
|
|
3774
|
-
this.#c.openToolPanel();
|
|
3775
|
-
}
|
|
3776
|
-
closeToolPanel() {
|
|
3777
|
-
this.#c.closeToolPanel();
|
|
3778
|
-
}
|
|
3779
|
-
toggleToolPanel() {
|
|
3780
|
-
this.#c.toggleToolPanel();
|
|
3781
|
-
}
|
|
3782
|
-
toggleToolPanelSection(e) {
|
|
3783
|
-
this.#c.toggleToolPanelSection(e);
|
|
3784
|
-
}
|
|
3785
|
-
getToolPanels() {
|
|
3786
|
-
return this.#c.getToolPanels();
|
|
3787
|
-
}
|
|
3788
|
-
registerToolPanel(e) {
|
|
3789
|
-
this.#e.apiToolPanelIds.add(e.id), this.#c.registerToolPanel(e);
|
|
3790
|
-
}
|
|
3791
|
-
unregisterToolPanel(e) {
|
|
3792
|
-
this.#e.apiToolPanelIds.delete(e), this.#c.unregisterToolPanel(e);
|
|
3793
|
-
}
|
|
3794
|
-
getHeaderContents() {
|
|
3795
|
-
return this.#c.getHeaderContents();
|
|
3796
|
-
}
|
|
3797
|
-
registerHeaderContent(e) {
|
|
3798
|
-
this.#c.registerHeaderContent(e);
|
|
3799
|
-
}
|
|
3800
|
-
unregisterHeaderContent(e) {
|
|
3801
|
-
this.#c.unregisterHeaderContent(e);
|
|
3802
|
-
}
|
|
3803
|
-
getToolbarContents() {
|
|
3804
|
-
return this.#c.getToolbarContents();
|
|
3805
|
-
}
|
|
3806
|
-
registerToolbarContent(e) {
|
|
3807
|
-
this.#c.registerToolbarContent(e);
|
|
3808
|
-
}
|
|
3809
|
-
unregisterToolbarContent(e) {
|
|
3810
|
-
this.#c.unregisterToolbarContent(e);
|
|
3811
|
-
}
|
|
3812
|
-
#Q = !1;
|
|
3813
|
-
refreshShellHeader() {
|
|
3814
|
-
this.#Q || (this.#Q = !0, queueMicrotask(() => {
|
|
3815
|
-
this.#Q = !1, this.isConnected && (this.#I(), this.#i.markSourcesChanged(), this.#i.merge(), he(this.#e), this.#J(), this.#V(), this.#ke());
|
|
3816
|
-
}));
|
|
3817
|
-
}
|
|
3818
|
-
#ke() {
|
|
3819
|
-
const i = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
|
|
3820
|
-
if (this._headerRowEl = i?.querySelector(".header-row"), this._virtualization.totalHeightEl = i?.querySelector(".faux-vscroll-spacer"), this._virtualization.viewportEl = i?.querySelector(".rows-viewport"), this._bodyEl = i?.querySelector(".rows"), this.__rowsBodyEl = i?.querySelector(".rows-body"), this.#c.isInitialized) {
|
|
3821
|
-
pe(this.#n, this.#e), de(this.#n, this.#o?.shell, this.#e);
|
|
3822
|
-
const o = this.#o?.shell?.toolPanel?.defaultOpen;
|
|
3823
|
-
o && this.#e.toolPanels.has(o) && (this.openToolPanel(), this.#e.expandedSections.add(o));
|
|
3824
|
-
}
|
|
3825
|
-
this._resizeController = Ie(this), this.#Y(i), this.#s.requestPhase(A.COLUMNS, "shellRefresh");
|
|
3826
|
-
}
|
|
3827
|
-
#A = /* @__PURE__ */ new Map();
|
|
3828
|
-
registerStyles(e, i) {
|
|
3829
|
-
let o = this.#A.get(e);
|
|
3830
|
-
o || (o = new CSSStyleSheet(), this.#A.set(e, o)), o.replaceSync(i), this.#ge();
|
|
3831
|
-
}
|
|
3832
|
-
unregisterStyles(e) {
|
|
3833
|
-
this.#A.delete(e) && this.#ge();
|
|
3834
|
-
}
|
|
3835
|
-
getRegisteredStyles() {
|
|
3836
|
-
return Array.from(this.#A.keys());
|
|
3837
|
-
}
|
|
3838
|
-
#ge() {
|
|
3839
|
-
const e = Array.from(this.#A.values()), i = document.adoptedStyleSheets.filter(
|
|
3840
|
-
(o) => !Array.from(this.#A.values()).includes(o)
|
|
3841
|
-
);
|
|
3842
|
-
document.adoptedStyleSheets = [...i, ...e];
|
|
3843
|
-
}
|
|
3844
|
-
#I() {
|
|
3845
|
-
qe(this, this.#e), $e(this, this.#e), We(this, this.#e, this.#ne());
|
|
3846
|
-
}
|
|
3847
|
-
#pe() {
|
|
3848
|
-
const e = this.#n.querySelector(".tbw-shell-header");
|
|
3849
|
-
if (!e) return;
|
|
3850
|
-
he(this.#e);
|
|
3851
|
-
const i = fi(
|
|
3852
|
-
this.#o.shell,
|
|
3853
|
-
this.#e,
|
|
3854
|
-
this.#o.icons?.toolPanel
|
|
3855
|
-
), o = document.createElement("div");
|
|
3856
|
-
o.innerHTML = i;
|
|
3857
|
-
const n = o.firstElementChild;
|
|
3858
|
-
n && (e.replaceWith(n), this.#be(), de(this.#n, this.#o?.shell, this.#e));
|
|
3859
|
-
}
|
|
3860
|
-
#Ie() {
|
|
3861
|
-
const e = () => {
|
|
3862
|
-
const o = this.#e.lightDomTitle, n = this.#e.hasToolButtonsContainer;
|
|
3863
|
-
this.#I();
|
|
3864
|
-
const r = this.#e.lightDomTitle, s = this.#e.hasToolButtonsContainer;
|
|
3865
|
-
(r && !o || s && !n) && (this.#i.markSourcesChanged(), this.#i.merge(), this.#pe());
|
|
3866
|
-
}, i = () => {
|
|
3867
|
-
this.__lightDomColumnsCache = void 0, this.#z();
|
|
3868
|
-
};
|
|
3869
|
-
this.#i.registerLightDomHandler("tbw-grid-header", e), this.#i.registerLightDomHandler("tbw-grid-tool-buttons", e), this.#i.registerLightDomHandler("tbw-grid-tool-panel", e), this.#i.registerLightDomHandler("tbw-grid-column", i), this.#i.registerLightDomHandler("tbw-grid-detail", i), this.#i.observeLightDOM(this);
|
|
3870
|
-
}
|
|
3871
|
-
refreshColumns() {
|
|
3872
|
-
this.__lightDomColumnsCache = void 0, W(this), this.#i.parseLightDomColumns(this);
|
|
3873
|
-
const e = this.#e.lightDomTitle, i = this.#e.hasToolButtonsContainer;
|
|
3874
|
-
this.#I();
|
|
3875
|
-
const o = this.#e.lightDomTitle, n = this.#e.hasToolButtonsContainer;
|
|
3876
|
-
(o && !e || n && !i) && (this.#i.markSourcesChanged(), this.#i.merge(), this.#pe()), this.#s.requestPhase(A.COLUMNS, "refreshColumns");
|
|
3877
|
-
}
|
|
3878
|
-
#Ne() {
|
|
3879
|
-
const e = this._virtualization.container, i = this._virtualization.viewportEl ?? e;
|
|
3880
|
-
i && (this._virtualization.cachedViewportHeight = i.clientHeight), e && (this._virtualization.cachedFauxHeight = e.clientHeight);
|
|
3881
|
-
const o = this._virtualization.scrollAreaEl;
|
|
3882
|
-
o && (this._virtualization.cachedScrollAreaHeight = o.clientHeight);
|
|
3883
|
-
}
|
|
3884
|
-
#T(e, i = !1) {
|
|
3885
|
-
const o = this._virtualization;
|
|
3886
|
-
let n, r, s;
|
|
3887
|
-
if (i) {
|
|
3888
|
-
const p = o.container ?? this, g = o.viewportEl ?? p, u = o.scrollAreaEl;
|
|
3889
|
-
n = p.clientHeight, r = g.clientHeight, s = u ? u.clientHeight : n, o.cachedFauxHeight = n, o.cachedViewportHeight = r, o.cachedScrollAreaHeight = s;
|
|
3890
|
-
} else
|
|
3891
|
-
n = o.cachedFauxHeight, r = o.cachedViewportHeight, s = o.cachedScrollAreaHeight || n;
|
|
3892
|
-
const l = s - r, a = Math.max(0, n - s);
|
|
3893
|
-
let c, h = 0;
|
|
3894
|
-
return o.variableHeights && o.positionCache ? c = Vi(o.positionCache) : (c = e * o.rowHeight, h = this.#t?.getExtraHeight() ?? 0), c + l + h + a;
|
|
3895
|
-
}
|
|
3896
|
-
#Z() {
|
|
3897
|
-
if (!this._virtualization.variableHeights) return;
|
|
3898
|
-
const e = this._rows, i = this._virtualization.rowHeight || 28, o = this.#o.rowHeight, n = this.#o.getRowId, r = n ? (l) => n(l) : void 0;
|
|
3899
|
-
this._virtualization.positionCache = Fi(
|
|
3900
|
-
e,
|
|
3901
|
-
this._virtualization.heightCache,
|
|
3902
|
-
i,
|
|
3903
|
-
{ rowId: r },
|
|
3904
|
-
(l, a) => {
|
|
3905
|
-
const c = this.#t?.getRowHeight?.(l, a);
|
|
3906
|
-
if (c !== void 0) return c;
|
|
3907
|
-
if (o) {
|
|
3908
|
-
const h = o(l, a);
|
|
3909
|
-
if (h !== void 0 && h > 0) return h;
|
|
3910
|
-
}
|
|
3911
|
-
}
|
|
3912
|
-
);
|
|
3913
|
-
const s = Xi(
|
|
3914
|
-
this._virtualization.positionCache,
|
|
3915
|
-
e,
|
|
3916
|
-
i,
|
|
3917
|
-
(l, a) => this.#t?.getRowHeight?.(l, a)
|
|
3918
|
-
);
|
|
3919
|
-
this._virtualization.measuredCount = s.measuredCount, s.measuredCount > 0 && (this._virtualization.averageHeight = s.averageHeight);
|
|
3920
|
-
}
|
|
3921
|
-
invalidateRowHeight(e, i) {
|
|
3922
|
-
if (!this._virtualization.variableHeights || !this._virtualization.positionCache || e < 0 || e >= this._rows.length) return;
|
|
3923
|
-
const o = this._virtualization.positionCache, n = this._rows[e];
|
|
3924
|
-
let r = i;
|
|
3925
|
-
r === void 0 && (r = this.#t?.getRowHeight?.(n, e)), r === void 0 && (r = this._virtualization.rowHeight);
|
|
3926
|
-
const s = o[e];
|
|
3927
|
-
if (!(!s || Math.abs(s.height - r) < 1) && (ve(o, e, r), this._virtualization.totalHeightEl)) {
|
|
3928
|
-
const l = this.#T(this._rows.length);
|
|
3929
|
-
this._virtualization.totalHeightEl.style.height = `${l}px`;
|
|
3930
|
-
}
|
|
3931
|
-
}
|
|
3932
|
-
#we(e, i) {
|
|
3933
|
-
if (!this._virtualization.variableHeights || !this._virtualization.positionCache || !this._bodyEl) return;
|
|
3934
|
-
const o = this._bodyEl.querySelectorAll(".data-grid-row"), n = this.#o.getRowId, r = Gi(
|
|
3935
|
-
{
|
|
3936
|
-
positionCache: this._virtualization.positionCache,
|
|
3937
|
-
heightCache: this._virtualization.heightCache,
|
|
3938
|
-
rows: this._rows,
|
|
3939
|
-
defaultHeight: this._virtualization.rowHeight,
|
|
3940
|
-
start: e,
|
|
3941
|
-
end: i,
|
|
3942
|
-
getPluginHeight: (s, l) => this.#t?.getRowHeight?.(s, l),
|
|
3943
|
-
getRowId: n ? (s) => n(s) : void 0
|
|
3944
|
-
},
|
|
3945
|
-
o
|
|
3946
|
-
);
|
|
3947
|
-
if (r.hasChanges && (this._virtualization.measuredCount = r.measuredCount, this._virtualization.averageHeight = r.averageHeight, this._virtualization.totalHeightEl)) {
|
|
3948
|
-
const s = this.#T(this._rows.length);
|
|
3949
|
-
this._virtualization.totalHeightEl.style.height = `${s}px`;
|
|
3950
|
-
}
|
|
3951
|
-
}
|
|
3952
|
-
refreshVirtualWindow(e = !1, i = !1) {
|
|
3953
|
-
if (!this._bodyEl) return !1;
|
|
3954
|
-
const o = this._rows.length;
|
|
3955
|
-
if (!this._virtualization.enabled)
|
|
3956
|
-
return this.#j(0, o), i || this.#t?.afterRender(), !0;
|
|
3957
|
-
if (this._rows.length <= this._virtualization.bypassThreshold)
|
|
3958
|
-
return this._virtualization.start = 0, this._virtualization.end = o, e && (this._bodyEl.style.transform = "translateY(0px)"), this.#j(0, o, this.__rowRenderEpoch), e && this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${this.#T(o, !0)}px`), this.#he(o, this._visibleColumns.length), i || this.#t?.afterRender(), !0;
|
|
3959
|
-
const n = this._virtualization.container ?? this, r = this._virtualization.viewportEl ?? n, s = e ? this._virtualization.cachedViewportHeight = r.clientHeight : this._virtualization.cachedViewportHeight || (this._virtualization.cachedViewportHeight = r.clientHeight), l = this._virtualization.rowHeight, a = n.scrollTop;
|
|
3960
|
-
let c;
|
|
3961
|
-
const h = this._virtualization.positionCache;
|
|
3962
|
-
if (this._virtualization.variableHeights && h && h.length > 0)
|
|
3963
|
-
c = Ge(h, a), c === -1 && (c = 0);
|
|
3964
|
-
else {
|
|
3965
|
-
c = Math.floor(a / l);
|
|
3966
|
-
let m = 0;
|
|
3967
|
-
const _ = 10;
|
|
3968
|
-
for (; m < _; ) {
|
|
3969
|
-
const R = this.#t?.getExtraHeightBefore?.(c) ?? 0, E = Math.floor((a - R) / l);
|
|
3970
|
-
if (E >= c || E < 0) break;
|
|
3971
|
-
c = E, m++;
|
|
3972
|
-
}
|
|
3973
|
-
}
|
|
3974
|
-
c = c - c % 2, c < 0 && (c = 0);
|
|
3975
|
-
const f = this.#t?.adjustVirtualStart(c, a, l);
|
|
3976
|
-
f !== void 0 && f < c && (c = f, c = c - c % 2, c < 0 && (c = 0));
|
|
3977
|
-
let p;
|
|
3978
|
-
if (this._virtualization.variableHeights && h && h.length > 0) {
|
|
3979
|
-
const m = s + l * 3;
|
|
3980
|
-
let _ = 0;
|
|
3981
|
-
for (p = c; p < o && _ < m; )
|
|
3982
|
-
_ += h[p].height, p++;
|
|
3983
|
-
const R = Math.ceil(s / l) + 3;
|
|
3984
|
-
p - c < R && (p = Math.min(c + R, o));
|
|
3985
|
-
} else {
|
|
3986
|
-
const m = Math.ceil(s / l) + 3;
|
|
3987
|
-
p = c + m;
|
|
3988
|
-
}
|
|
3989
|
-
p > o && (p = o);
|
|
3990
|
-
const g = this._virtualization.start, u = this._virtualization.end;
|
|
3991
|
-
if (!e && c === g && p === u)
|
|
3992
|
-
return !1;
|
|
3993
|
-
this._virtualization.start = c, this._virtualization.end = p;
|
|
3994
|
-
const d = e ? this._virtualization.cachedFauxHeight = n.clientHeight : this._virtualization.cachedFauxHeight || (this._virtualization.cachedFauxHeight = n.clientHeight);
|
|
3995
|
-
if (e) {
|
|
3996
|
-
const m = this._virtualization.scrollAreaEl;
|
|
3997
|
-
m && (this._virtualization.cachedScrollAreaHeight = m.clientHeight);
|
|
3998
|
-
}
|
|
3999
|
-
if (d === 0 && s > 0)
|
|
4000
|
-
return this.#s.requestPhase(A.VIRTUALIZATION, "stale-refs-retry"), !1;
|
|
4001
|
-
if (e && this._virtualization.totalHeightEl) {
|
|
4002
|
-
const m = this.#T(o);
|
|
4003
|
-
this._virtualization.totalHeightEl.style.height = `${m}px`;
|
|
4004
|
-
}
|
|
4005
|
-
let w;
|
|
4006
|
-
if (this._virtualization.variableHeights && h && h[c])
|
|
4007
|
-
w = h[c].offset;
|
|
4008
|
-
else {
|
|
4009
|
-
const m = this.#t?.getExtraHeightBefore?.(c) ?? 0;
|
|
4010
|
-
w = c * l + m;
|
|
4011
|
-
}
|
|
4012
|
-
const C = -(a - w);
|
|
4013
|
-
return this._bodyEl.style.transform = `translateY(${C}px)`, this.#j(c, p, this.__rowRenderEpoch), e && this._virtualization.variableHeights && this.#we(c, p), this.#he(o, this._visibleColumns.length), e && !i && (this.#t?.afterRender(), queueMicrotask(() => {
|
|
4014
|
-
if (!this._virtualization.totalHeightEl) return;
|
|
4015
|
-
const m = this.#T(o);
|
|
4016
|
-
this._virtualization.cachedFauxHeight === 0 && this._virtualization.cachedViewportHeight > 0 || (this._virtualization.totalHeightEl.style.height = `${m}px`);
|
|
4017
|
-
})), !0;
|
|
4018
|
-
}
|
|
4019
|
-
#J() {
|
|
4020
|
-
this.#I(), this.#i.markSourcesChanged(), this.#i.merge();
|
|
4021
|
-
const e = this.#o?.shell;
|
|
4022
|
-
yi(
|
|
4023
|
-
this.#n,
|
|
4024
|
-
e,
|
|
4025
|
-
{ isPanelOpen: this.#e.isPanelOpen, expandedSections: this.#e.expandedSections },
|
|
4026
|
-
this.#o?.icons
|
|
4027
|
-
) && (this.#be(), this.#c.setInitialized(!0));
|
|
4028
|
-
}
|
|
4029
|
-
#be() {
|
|
4030
|
-
gi(this.#n, this.#o?.shell, this.#e, {
|
|
4031
|
-
onPanelToggle: () => this.toggleToolPanel(),
|
|
4032
|
-
onSectionToggle: (e) => this.toggleToolPanelSection(e)
|
|
4033
|
-
}), this.#$?.(), this.#$ = wi(this.#n, this.#o?.shell, (e) => {
|
|
4034
|
-
this.style.setProperty("--tbw-tool-panel-width", `${e}px`);
|
|
4035
|
-
}), this.#W?.(), this.#W = pi(
|
|
4036
|
-
this,
|
|
4037
|
-
this.#o?.shell,
|
|
4038
|
-
this.#e,
|
|
4039
|
-
() => this.closeToolPanel()
|
|
4040
|
-
);
|
|
4041
|
-
}
|
|
4042
|
-
}
|
|
4043
|
-
customElements.get(I.tagName) || customElements.define(I.tagName, I);
|
|
4044
|
-
globalThis.DataGridElement = I;
|
|
4045
|
-
const ao = {
|
|
4046
|
-
CAN_MOVE_COLUMN: "canMoveColumn",
|
|
4047
|
-
GET_CONTEXT_MENU_ITEMS: "getContextMenuItems"
|
|
4048
|
-
};
|
|
4049
|
-
class co {
|
|
4050
|
-
static dependencies;
|
|
4051
|
-
static manifest;
|
|
4052
|
-
version = "1.21.1";
|
|
4053
|
-
styles;
|
|
4054
|
-
cellRenderers;
|
|
4055
|
-
headerRenderers;
|
|
4056
|
-
cellEditors;
|
|
4057
|
-
grid;
|
|
4058
|
-
config;
|
|
4059
|
-
userConfig;
|
|
4060
|
-
#a;
|
|
4061
|
-
get defaultConfig() {
|
|
4062
|
-
return {};
|
|
4063
|
-
}
|
|
4064
|
-
constructor(e = {}) {
|
|
4065
|
-
this.userConfig = e;
|
|
4066
|
-
}
|
|
4067
|
-
attach(e) {
|
|
4068
|
-
this.#a?.abort(), this.#a = new AbortController(), this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
4069
|
-
}
|
|
4070
|
-
detach() {
|
|
4071
|
-
this.#a?.abort(), this.#a = void 0;
|
|
4072
|
-
}
|
|
4073
|
-
getPlugin(e) {
|
|
4074
|
-
return this.grid?.getPlugin(e);
|
|
4075
|
-
}
|
|
4076
|
-
emit(e, i) {
|
|
4077
|
-
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: i, bubbles: !0 }));
|
|
4078
|
-
}
|
|
4079
|
-
emitCancelable(e, i) {
|
|
4080
|
-
const o = new CustomEvent(e, { detail: i, bubbles: !0, cancelable: !0 });
|
|
4081
|
-
return this.grid?.dispatchEvent?.(o), o.defaultPrevented;
|
|
4082
|
-
}
|
|
4083
|
-
on(e, i) {
|
|
4084
|
-
this.grid?._pluginManager?.subscribe(this, e, i);
|
|
4085
|
-
}
|
|
4086
|
-
off(e) {
|
|
4087
|
-
this.grid?._pluginManager?.unsubscribe(this, e);
|
|
4088
|
-
}
|
|
4089
|
-
emitPluginEvent(e, i) {
|
|
4090
|
-
this.grid?._pluginManager?.emitPluginEvent(e, i);
|
|
4091
|
-
}
|
|
4092
|
-
requestRender() {
|
|
4093
|
-
this.grid?.requestRender?.();
|
|
4094
|
-
}
|
|
4095
|
-
requestColumnsRender() {
|
|
4096
|
-
this.grid?.requestColumnsRender?.();
|
|
4097
|
-
}
|
|
4098
|
-
requestRenderWithFocus() {
|
|
4099
|
-
this.grid?.requestRenderWithFocus?.();
|
|
4100
|
-
}
|
|
4101
|
-
requestAfterRender() {
|
|
4102
|
-
this.grid?.requestAfterRender?.();
|
|
4103
|
-
}
|
|
4104
|
-
get rows() {
|
|
4105
|
-
return this.grid?.rows ?? [];
|
|
4106
|
-
}
|
|
4107
|
-
get sourceRows() {
|
|
4108
|
-
return this.grid?.sourceRows ?? [];
|
|
4109
|
-
}
|
|
4110
|
-
get columns() {
|
|
4111
|
-
return this.grid?.columns ?? [];
|
|
4112
|
-
}
|
|
4113
|
-
get visibleColumns() {
|
|
4114
|
-
return this.grid?._visibleColumns ?? [];
|
|
4115
|
-
}
|
|
4116
|
-
get gridElement() {
|
|
4117
|
-
return this.grid;
|
|
4118
|
-
}
|
|
4119
|
-
get disconnectSignal() {
|
|
4120
|
-
return this.#a?.signal ?? this.grid?.disconnectSignal;
|
|
4121
|
-
}
|
|
4122
|
-
get gridIcons() {
|
|
4123
|
-
const e = this.grid?.gridConfig?.icons ?? {};
|
|
4124
|
-
return { ...M, ...e };
|
|
4125
|
-
}
|
|
4126
|
-
get isAnimationEnabled() {
|
|
4127
|
-
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
4128
|
-
if (e === !1 || e === "off") return !1;
|
|
4129
|
-
if (e === !0 || e === "on") return !0;
|
|
4130
|
-
const i = this.gridElement;
|
|
4131
|
-
return i ? getComputedStyle(i).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
4132
|
-
}
|
|
4133
|
-
get animationDuration() {
|
|
4134
|
-
const e = this.gridElement;
|
|
4135
|
-
if (e) {
|
|
4136
|
-
const i = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), o = parseInt(i, 10);
|
|
4137
|
-
if (!isNaN(o)) return o;
|
|
4138
|
-
}
|
|
4139
|
-
return 200;
|
|
4140
|
-
}
|
|
4141
|
-
resolveIcon(e, i) {
|
|
4142
|
-
return i !== void 0 ? i : this.gridIcons[e];
|
|
4143
|
-
}
|
|
4144
|
-
setIcon(e, i) {
|
|
4145
|
-
typeof i == "string" ? e.innerHTML = i : i instanceof HTMLElement && (e.innerHTML = "", e.appendChild(i.cloneNode(!0)));
|
|
4146
|
-
}
|
|
4147
|
-
warn(e) {
|
|
4148
|
-
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
4149
|
-
}
|
|
4150
|
-
}
|
|
4151
|
-
const H = {
|
|
4152
|
-
ROOT: "tbw-grid-root",
|
|
4153
|
-
HEADER: "header",
|
|
4154
|
-
HEADER_ROW: "header-row",
|
|
4155
|
-
HEADER_CELL: "header-cell",
|
|
4156
|
-
ROWS_VIEWPORT: "rows-viewport",
|
|
4157
|
-
ROWS_SPACER: "rows-spacer",
|
|
4158
|
-
ROWS_CONTAINER: "rows",
|
|
4159
|
-
DATA_ROW: "data-row",
|
|
4160
|
-
GROUP_ROW: "group-row",
|
|
4161
|
-
DATA_CELL: "data-cell",
|
|
4162
|
-
SELECTED: "selected",
|
|
4163
|
-
FOCUSED: "focused",
|
|
4164
|
-
EDITING: "editing",
|
|
4165
|
-
EXPANDED: "expanded",
|
|
4166
|
-
COLLAPSED: "collapsed",
|
|
4167
|
-
DRAGGING: "dragging",
|
|
4168
|
-
RESIZING: "resizing",
|
|
4169
|
-
SORTABLE: "sortable",
|
|
4170
|
-
SORTED_ASC: "sorted-asc",
|
|
4171
|
-
SORTED_DESC: "sorted-desc",
|
|
4172
|
-
HIDDEN: "hidden",
|
|
4173
|
-
STICKY_LEFT: "sticky-left",
|
|
4174
|
-
STICKY_RIGHT: "sticky-right",
|
|
4175
|
-
PINNED_TOP: "pinned-top",
|
|
4176
|
-
PINNED_BOTTOM: "pinned-bottom",
|
|
4177
|
-
TREE_TOGGLE: "tree-toggle",
|
|
4178
|
-
TREE_INDENT: "tree-indent",
|
|
4179
|
-
GROUP_TOGGLE: "group-toggle",
|
|
4180
|
-
GROUP_LABEL: "group-label",
|
|
4181
|
-
GROUP_COUNT: "group-count",
|
|
4182
|
-
RANGE_SELECTION: "range-selection",
|
|
4183
|
-
SELECTION_OVERLAY: "selection-overlay"
|
|
4184
|
-
}, ee = {
|
|
4185
|
-
ROW_INDEX: "data-row-index",
|
|
4186
|
-
COL_INDEX: "data-col-index",
|
|
4187
|
-
FIELD: "data-field",
|
|
4188
|
-
GROUP_KEY: "data-group-key",
|
|
4189
|
-
TREE_LEVEL: "data-tree-level",
|
|
4190
|
-
STICKY: "data-sticky"
|
|
4191
|
-
}, ho = {
|
|
4192
|
-
ROOT: `.${H.ROOT}`,
|
|
4193
|
-
HEADER: `.${H.HEADER}`,
|
|
4194
|
-
HEADER_ROW: `.${H.HEADER_ROW}`,
|
|
4195
|
-
HEADER_CELL: `.${H.HEADER_CELL}`,
|
|
4196
|
-
ROWS_VIEWPORT: `.${H.ROWS_VIEWPORT}`,
|
|
4197
|
-
ROWS_CONTAINER: `.${H.ROWS_CONTAINER}`,
|
|
4198
|
-
DATA_ROW: `.${H.DATA_ROW}`,
|
|
4199
|
-
DATA_CELL: `.${H.DATA_CELL}`,
|
|
4200
|
-
GROUP_ROW: `.${H.GROUP_ROW}`,
|
|
4201
|
-
ROW_BY_INDEX: (t) => `.${H.DATA_ROW}[${ee.ROW_INDEX}="${t}"]`,
|
|
4202
|
-
CELL_BY_FIELD: (t) => `.${H.DATA_CELL}[${ee.FIELD}="${t}"]`,
|
|
4203
|
-
CELL_AT: (t, e) => `.${H.DATA_ROW}[${ee.ROW_INDEX}="${t}"] .${H.DATA_CELL}[${ee.COL_INDEX}="${e}"]`,
|
|
4204
|
-
SELECTED_ROWS: `.${H.DATA_ROW}.${H.SELECTED}`,
|
|
4205
|
-
EDITING_CELL: `.${H.DATA_CELL}.${H.EDITING}`
|
|
4206
|
-
}, uo = {
|
|
4207
|
-
COLOR_BG: "--tbw-color-bg",
|
|
4208
|
-
COLOR_FG: "--tbw-color-fg",
|
|
4209
|
-
COLOR_FG_MUTED: "--tbw-color-fg-muted",
|
|
4210
|
-
COLOR_BORDER: "--tbw-color-border",
|
|
4211
|
-
COLOR_ACCENT: "--tbw-color-accent",
|
|
4212
|
-
COLOR_HEADER_BG: "--tbw-color-header-bg",
|
|
4213
|
-
COLOR_HEADER_FG: "--tbw-color-header-fg",
|
|
4214
|
-
COLOR_SELECTION: "--tbw-color-selection",
|
|
4215
|
-
COLOR_ROW_HOVER: "--tbw-color-row-hover",
|
|
4216
|
-
COLOR_ROW_ALT: "--tbw-color-row-alt",
|
|
4217
|
-
ROW_HEIGHT: "--tbw-row-height",
|
|
4218
|
-
HEADER_HEIGHT: "--tbw-header-height",
|
|
4219
|
-
CELL_PADDING: "--tbw-cell-padding",
|
|
4220
|
-
FONT_FAMILY: "--tbw-font-family",
|
|
4221
|
-
FONT_SIZE: "--tbw-font-size",
|
|
4222
|
-
BORDER_RADIUS: "--tbw-border-radius",
|
|
4223
|
-
FOCUS_OUTLINE: "--tbw-focus-outline"
|
|
4224
|
-
};
|
|
4225
|
-
function fo(t) {
|
|
4226
|
-
const e = document.createElement("tbw-grid");
|
|
4227
|
-
return t && (e.gridConfig = t), e;
|
|
4228
|
-
}
|
|
4229
|
-
function go(t, e = document) {
|
|
4230
|
-
return e.querySelector(t);
|
|
4231
|
-
}
|
|
4232
|
-
const po = {
|
|
4233
|
-
CELL_CHANGE: "cell-change",
|
|
4234
|
-
CELL_COMMIT: "cell-commit",
|
|
4235
|
-
ROW_COMMIT: "row-commit",
|
|
4236
|
-
EDIT_OPEN: "edit-open",
|
|
4237
|
-
EDIT_CLOSE: "edit-close",
|
|
4238
|
-
CHANGED_ROWS_RESET: "changed-rows-reset",
|
|
4239
|
-
MOUNT_EXTERNAL_VIEW: "mount-external-view",
|
|
4240
|
-
MOUNT_EXTERNAL_EDITOR: "mount-external-editor",
|
|
4241
|
-
SORT_CHANGE: "sort-change",
|
|
4242
|
-
COLUMN_RESIZE: "column-resize",
|
|
4243
|
-
ACTIVATE_CELL: "activate-cell",
|
|
4244
|
-
CELL_ACTIVATE: "cell-activate",
|
|
4245
|
-
GROUP_TOGGLE: "group-toggle",
|
|
4246
|
-
COLUMN_STATE_CHANGE: "column-state-change"
|
|
4247
|
-
}, wo = {
|
|
4248
|
-
SELECTION_CHANGE: "selection-change",
|
|
4249
|
-
TREE_EXPAND: "tree-expand",
|
|
4250
|
-
FILTER_CHANGE: "filter-change",
|
|
4251
|
-
SORT_MODEL_CHANGE: "sort-model-change",
|
|
4252
|
-
EXPORT_START: "export-start",
|
|
4253
|
-
EXPORT_COMPLETE: "export-complete",
|
|
4254
|
-
CLIPBOARD_COPY: "clipboard-copy",
|
|
4255
|
-
CLIPBOARD_PASTE: "clipboard-paste",
|
|
4256
|
-
CONTEXT_MENU_OPEN: "context-menu-open",
|
|
4257
|
-
CONTEXT_MENU_CLOSE: "context-menu-close",
|
|
4258
|
-
HISTORY_CHANGE: "history-change",
|
|
4259
|
-
SERVER_LOADING: "server-loading",
|
|
4260
|
-
SERVER_ERROR: "server-error",
|
|
4261
|
-
COLUMN_VISIBILITY_CHANGE: "column-visibility-change",
|
|
4262
|
-
COLUMN_REORDER: "column-reorder",
|
|
4263
|
-
DETAIL_EXPAND: "detail-expand",
|
|
4264
|
-
GROUP_EXPAND: "group-expand"
|
|
4265
|
-
}, fe = {
|
|
4266
|
-
sum: (t, e) => t.reduce((i, o) => i + (Number(o[e]) || 0), 0),
|
|
4267
|
-
avg: (t, e) => {
|
|
4268
|
-
const i = t.reduce((o, n) => o + (Number(n[e]) || 0), 0);
|
|
4269
|
-
return t.length ? i / t.length : 0;
|
|
4270
|
-
},
|
|
4271
|
-
count: (t) => t.length,
|
|
4272
|
-
min: (t, e) => t.length ? Math.min(...t.map((i) => Number(i[e]) || 1 / 0)) : 0,
|
|
4273
|
-
max: (t, e) => t.length ? Math.max(...t.map((i) => Number(i[e]) || -1 / 0)) : 0,
|
|
4274
|
-
first: (t, e) => t[0]?.[e],
|
|
4275
|
-
last: (t, e) => t[t.length - 1]?.[e]
|
|
4276
|
-
}, U = /* @__PURE__ */ new Map(), D = {
|
|
4277
|
-
register(t, e) {
|
|
4278
|
-
U.set(t, e);
|
|
4279
|
-
},
|
|
4280
|
-
unregister(t) {
|
|
4281
|
-
U.delete(t);
|
|
4282
|
-
},
|
|
4283
|
-
get(t) {
|
|
4284
|
-
if (t !== void 0)
|
|
4285
|
-
return typeof t == "function" ? t : U.get(t) ?? fe[t];
|
|
4286
|
-
},
|
|
4287
|
-
run(t, e, i, o) {
|
|
4288
|
-
const n = this.get(t);
|
|
4289
|
-
return n ? n(e, i, o) : void 0;
|
|
4290
|
-
},
|
|
4291
|
-
has(t) {
|
|
4292
|
-
return U.has(t) || t in fe;
|
|
4293
|
-
},
|
|
4294
|
-
list() {
|
|
4295
|
-
return [...Object.keys(fe), ...U.keys()];
|
|
4296
|
-
}
|
|
4297
|
-
}, Xe = {
|
|
4298
|
-
sum: (t) => t.reduce((e, i) => e + i, 0),
|
|
4299
|
-
avg: (t) => t.length ? t.reduce((e, i) => e + i, 0) / t.length : 0,
|
|
4300
|
-
count: (t) => t.length,
|
|
4301
|
-
min: (t) => t.length ? Math.min(...t) : 0,
|
|
4302
|
-
max: (t) => t.length ? Math.max(...t) : 0,
|
|
4303
|
-
first: (t) => t[0] ?? 0,
|
|
4304
|
-
last: (t) => t[t.length - 1] ?? 0
|
|
4305
|
-
};
|
|
4306
|
-
function no(t) {
|
|
4307
|
-
return Xe[t] ?? Xe.sum;
|
|
4308
|
-
}
|
|
4309
|
-
function bo(t, e) {
|
|
4310
|
-
return no(t)(e);
|
|
4311
|
-
}
|
|
4312
|
-
const mo = D.register.bind(D), vo = D.unregister.bind(D), Co = D.get.bind(D), yo = D.run.bind(D), _o = D.list.bind(D);
|
|
4313
|
-
export {
|
|
4314
|
-
co as BaseGridPlugin,
|
|
4315
|
-
pt as DEFAULT_ANIMATION_CONFIG,
|
|
4316
|
-
M as DEFAULT_GRID_ICONS,
|
|
4317
|
-
po as DGEvents,
|
|
4318
|
-
I as DataGridElement,
|
|
4319
|
-
et as F,
|
|
4320
|
-
X as FitModeEnum,
|
|
4321
|
-
uo as GridCSSVars,
|
|
4322
|
-
H as GridClasses,
|
|
4323
|
-
ee as GridDataAttrs,
|
|
4324
|
-
I as GridElement,
|
|
4325
|
-
ho as GridSelectors,
|
|
4326
|
-
ao as PLUGIN_QUERIES,
|
|
4327
|
-
wo as PluginEvents,
|
|
4328
|
-
ne as PluginManager,
|
|
4329
|
-
A as RenderPhase,
|
|
4330
|
-
Ce as a,
|
|
4331
|
-
D as aggregatorRegistry,
|
|
4332
|
-
k as b,
|
|
4333
|
-
ot as builtInSort,
|
|
4334
|
-
so as c,
|
|
4335
|
-
fo as createGrid,
|
|
4336
|
-
Qe as d,
|
|
4337
|
-
Ut as defaultComparator,
|
|
4338
|
-
F as e,
|
|
4339
|
-
_e as f,
|
|
4340
|
-
Ot as g,
|
|
4341
|
-
Co as getAggregator,
|
|
4342
|
-
no as getValueAggregator,
|
|
4343
|
-
_o as listAggregators,
|
|
4344
|
-
go as queryGrid,
|
|
4345
|
-
ro as r,
|
|
4346
|
-
mo as registerAggregator,
|
|
4347
|
-
yo as runAggregator,
|
|
4348
|
-
bo as runValueAggregator,
|
|
4349
|
-
lo as s,
|
|
4350
|
-
vo as unregisterAggregator
|
|
4351
|
-
};
|
|
4352
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
const e={STRETCH:"stretch",FIXED:"fixed"},t={mode:"reduced-motion",duration:200,easing:"ease-out"},i='<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',o={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:i,filterActive:i,print:"🖨️"};function n(e,t){if(!(e&&e.length||t&&t.length))return[];if(!e||!e.length)return t||[];if(!t||!t.length)return e;const i={};t.forEach(e=>{const t=i[e.field];if(t){e.header&&!t.header&&(t.header=e.header),e.type&&!t.type&&(t.type=e.type),e.sortable&&(t.sortable=!0),e.editable&&(t.editable=!0),e.resizable&&(t.resizable=!0),null!=e.width&&null==t.width&&(t.width=e.width),null!=e.minWidth&&null==t.minWidth&&(t.minWidth=e.minWidth),e.__viewTemplate&&(t.__viewTemplate=e.__viewTemplate),e.__editorTemplate&&(t.__editorTemplate=e.__editorTemplate),e.__headerTemplate&&(t.__headerTemplate=e.__headerTemplate);const i=e.renderer||e.viewRenderer,o=t.renderer||t.viewRenderer;i&&!o&&(t.viewRenderer=i,e.renderer&&(t.renderer=i)),e.editor&&!t.editor&&(t.editor=e.editor)}else i[e.field]={...e}});const o=e.map(e=>{const t=i[e.field];if(!t)return e;const o={...e};t.header&&!o.header&&(o.header=t.header),t.type&&!o.type&&(o.type=t.type),o.sortable=e.sortable||t.sortable,!0!==e.resizable&&!0!==t.resizable||(o.resizable=!0),o.editable=e.editable||t.editable,null!=t.width&&null==o.width&&(o.width=t.width),null!=t.minWidth&&null==o.minWidth&&(o.minWidth=t.minWidth),t.__viewTemplate&&(o.__viewTemplate=t.__viewTemplate),t.__editorTemplate&&(o.__editorTemplate=t.__editorTemplate),t.__headerTemplate&&(o.__headerTemplate=t.__headerTemplate);const n=t.renderer||t.viewRenderer,r=o.renderer||o.viewRenderer;return n&&!r&&(o.viewRenderer=n,t.renderer&&(o.renderer=n)),t.editor&&!o.editor&&(o.editor=t.editor),delete i[e.field],o});return Object.keys(i).forEach(e=>o.push(i[e])),o}function r(e,t){try{e.part?.add?.(t)}catch{}const i=e.getAttribute("part");i?i.split(/\s+/).includes(t)||e.setAttribute("part",i+" "+t):e.setAttribute("part",t)}function s(t){const i=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;if(i!==e.STRETCH&&i!==e.FIXED)return;if(t.__didInitialAutoSize)return;if(!t.isConnected)return;const o=Array.from(t._headerRowEl?.children||[]);if(!o.length)return;let n=!1;t._visibleColumns.forEach((e,i)=>{if(e.width)return;const r=o[i];let s=r?r.scrollWidth:0;for(const o of t._rowPool){const e=o.children[i];if(e){const t=e.scrollWidth;t>s&&(s=t)}}s>0&&(e.width=s+2,e.__autoSized=!0,n=!0)}),n&&c(t),t.__didInitialAutoSize=!0}const l=/^(?:\d+(?:\.\d+)?(?:px|%|fr|em|rem|ch|vw|vh|vmin|vmax)|calc\(.+\)|min-content|max-content|minmax\(.+\)|fit-content\(.+\)|auto)$/i;function a(e,t){return"number"==typeof e?`${e}px`:(l.test(e)||console.warn(`[tbw-grid] Column '${t??"?"}' has an invalid CSS width value: '${e}'. Expected a number (px) or a valid CSS unit string (e.g. '30%', '2fr', 'calc(...)').`),e)}function c(t){const i=t.effectiveConfig?.fitMode||t.fitMode||e.STRETCH;t._gridTemplate=i===e.STRETCH?t._visibleColumns.map(e=>{if(null!=e.width)return a(e.width,e.field);const t=e.minWidth;return null!=t?`minmax(${t}px, 1fr)`:"1fr"}).join(" ").trim():t._visibleColumns.map(e=>null!=e.width?a(e.width,e.field):"max-content").join(" "),t.style.setProperty("--tbw-column-template",t._gridTemplate)}function d(e,t){const i=e[0]||{},o=Object.keys(i).map(e=>{const t=i[e],o=null==(n=t)?"string":"number"==typeof n?"number":"boolean"==typeof n?"boolean":n instanceof Date||"string"==typeof n&&/\d{4}-\d{2}-\d{2}/.test(n)&&!isNaN(Date.parse(n))?"date":"string";var n;return{field:e,header:e.charAt(0).toUpperCase()+e.slice(1),type:o}}),n={};return o.forEach(e=>{n[e.field]=e.type||"string"}),{columns:o,typeMap:n}}const h=/{{\s*([^}]+)\s*}}/g,u="__DG_EMPTY__",g=/^[\w$. '?+\-*/%:()!<>=,&|]+$/,f=/__(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/;const p=/* @__PURE__ */new Set(["script","iframe","object","embed","form","input","button","textarea","select","link","meta","base","style","template","slot","portal","frame","frameset","applet","noscript","noembed","plaintext","xmp","listing"]),w=/^on\w+$/i,b=/* @__PURE__ */new Set(["href","src","action","formaction","data","srcdoc","xlink:href","poster","srcset"]),m=/^\s*(javascript|vbscript|data|blob):/i;function v(e){if(!e||"string"!=typeof e)return"";if(-1===e.indexOf("<"))return e;const t=document.createElement("template");return t.innerHTML=e,function(e){const t=[],i=e.querySelectorAll("*");for(const o of i){const e=o.tagName.toLowerCase();if(p.has(e)){t.push(o);continue}if("svg"===e||"http://www.w3.org/2000/svg"===o.namespaceURI){if(Array.from(o.attributes).some(e=>w.test(e.name)||"href"===e.name||"xlink:href"===e.name)){t.push(o);continue}}const i=[];for(const t of o.attributes){const e=t.name.toLowerCase();w.test(e)?i.push(t.name):(b.has(e)&&m.test(t.value)||"style"===e&&/expression\s*\(|javascript:|behavior\s*:/i.test(t.value))&&i.push(t.name)}i.forEach(e=>o.removeAttribute(e))}t.forEach(e=>e.remove())}(t.content),t.innerHTML}function C(e,t){if(!e||-1===e.indexOf("{{"))return e;const i=[],o=e.replace(h,(e,o)=>{const n=function(e,t){if(e=(e||"").trim(),!e)return u;if(y.test(e))return u;if("value"===e)return null==t.value?u:String(t.value);if(e.startsWith("row.")&&!/[()?]/.test(e)&&!e.includes(":")){const i=e.slice(4),o=t.row?t.row[i]:void 0;return null==o?u:String(o)}if(e.length>80)return u;if(!g.test(e)||f.test(e))return u;const i=e.match(/\./g);if(i&&i.length>1)return u;try{const i=new Function("value","row",`return (${e});`)(t.value,t.row),o=null==i?"":String(i);return y.test(o)?u:o||u}catch{return u}}(o,t);return i.push({expr:o.trim(),result:n}),n}),n=(r=o)?r.replace(new RegExp(u,"g"),"").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g,""):r;var r;const s=i.length&&i.every(e=>""===e.result||e.result===u);return y.test(e)||s?"":n}const y=/Reflect|Proxy|ownKeys/;function _(e){if(y.test(e.textContent||"")){for(const t of e.childNodes)t.nodeType===Node.TEXT_NODE&&y.test(t.textContent||"")&&(t.textContent="");y.test(e.textContent||"")&&(e.textContent="")}}function S(e){const t=y.test(e),i=i=>{if(t)return"";return C(e,i)};return i.__blocked=t,i}class R{#e;#t;#i;#o;#n;#r={};#s={};#l=!0;#a=[];#c;#d;#h;#u;#g;constructor(e){this.#u=e}get original(){return this.#r}get effective(){return this.#s}get columns(){return this.#s.columns??[]}set columns(e){this.#s.columns=e}get lightDomColumnsCache(){return this.#o}set lightDomColumnsCache(e){this.#o=e}get originalColumnNodes(){return this.#n}set originalColumnNodes(e){this.#n=e}get lightDomTitle(){return this.#g}set lightDomTitle(e){this.#g=e}get initialColumnState(){return this.#h}set initialColumnState(e){this.#h=e}get sourcesChanged(){return this.#l}markSourcesChanged(){this.#l=!0}setGridConfig(e){this.#e=e,this.#l=!0,this.#o=void 0}getGridConfig(){return this.#e}setColumns(e){this.#t=e,this.#l=!0}getColumns(){return this.#t}setFitMode(e){this.#i=e,this.#l=!0}getFitMode(){return this.#i}merge(){const e=(this.#s.columns?.length??0)>0;if(!this.#l&&e)return;const t=this.#f();this.#l=!1,this.#r=t,Object.freeze(this.#r),this.#r.columns&&Object.freeze(this.#r.columns),this.#s=this.#p(this.#r),this.#w()}#p(e){const t={...e};return e.columns&&(t.columns=e.columns.map(e=>({...e}))),e.shell&&(t.shell={...e.shell,header:e.shell.header?{...e.shell.header}:void 0,toolPanel:e.shell.toolPanel?{...e.shell.toolPanel}:void 0,toolPanels:e.shell.toolPanels?.map(e=>({...e})),headerContents:e.shell.headerContents?.map(e=>({...e}))}),t}#w(){const e=this.#s;if(this.#b(),"number"==typeof e.rowHeight&&e.rowHeight>0&&this.#u.setRowHeight(e.rowHeight),"fixed"===e.fitMode){this.columns.forEach(e=>{null==e.width&&(e.width=80)})}this.#u.applyAnimationConfig(e)}#b(){const e=this.#s.typeDefaults;if(!e)return;const t=this.columns;for(const i of t){if(!i.type)continue;const t=e[i.type];t&&(i.renderer||i.viewRenderer||!t.renderer||(i.renderer=t.renderer),!i.format&&t.format&&(i.format=t.format),!i.editor&&t.editor&&(i.editor=t.editor),!i.editorParams&&t.editorParams&&(i.editorParams=t.editorParams))}}#f(){const e=this.#e?{...this.#e}:{},t=Array.isArray(e.columns)?[...e.columns]:[],i=(this.#o??[]).map(e=>({...e}));let o=n(t,i);this.#t&&this.#t.length&&(o=n(this.#t,i));const r=this.#u.getRows();if(0===o.length&&r.length){o=d(r).columns}return o.length&&(o.forEach(e=>{void 0===e.sortable&&(e.sortable=!0),void 0===e.resizable&&(e.resizable=!0),void 0===e.__originalWidth&&"number"==typeof e.width&&(e.__originalWidth=e.width)}),o.forEach(e=>{e.__viewTemplate&&!e.__compiledView&&(e.__compiledView=S(e.__viewTemplate.innerHTML)),e.__editorTemplate&&!e.__compiledEditor&&(e.__compiledEditor=S(e.__editorTemplate.innerHTML))}),e.columns=o),this.#i&&(e.fitMode=this.#i),e.fitMode||(e.fitMode="stretch"),this.#m(e),e.columnState&&!this.#h&&(this.#h=e.columnState),e}#m(e){e.shell=e.shell?{...e.shell}:{},e.shell.header=e.shell.header?{...e.shell.header}:{};const t=this.#u.getShellLightDomTitle();t&&(this.#g=t),this.#g&&!e.shell.header.title&&(e.shell.header.title=this.#g);const i=this.#u.getShellLightDomHeaderContent();i?.length>0&&(e.shell.header.lightDomContent=i),this.#u.getShellHasToolButtonsContainer()&&(e.shell.header.hasToolButtonsContainer=!0);const o=this.#u.getShellToolPanels();if(o.size>0){const t=Array.from(o.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.toolPanels=t}const n=this.#u.getShellHeaderContents();if(n.size>0){const t=Array.from(n.values());t.sort((e,t)=>(e.order??100)-(t.order??100)),e.shell.headerContents=t}const r=this.#u.getShellToolbarContents(),s=Array.from(r.values()),l=this.#e?.shell?.header?.toolbarContents??[],a=new Set(l.map(e=>e.id)),c=[...l];for(const d of s)a.has(d.id)||c.push(d);c.sort((e,t)=>(e.order??0)-(t.order??0)),e.shell.header.toolbarContents=c}collectState(e){const t=this.columns,i=this.#v();return{columns:t.map((t,o)=>{const n={field:t.field,order:o,visible:!t.hidden},r=t;void 0!==r.__renderedWidth?n.width=r.__renderedWidth:void 0!==t.width&&(n.width="string"==typeof t.width?parseFloat(t.width):t.width);const s=i.get(t.field);s&&(n.sort=s);for(const i of e)if(i.getColumnState){const e=i.getColumnState(t.field);e&&Object.assign(n,e)}return n})}}applyState(e,t){if(!e.columns||0===e.columns.length)return;const i=this.columns,o=new Map(e.columns.map(e=>[e.field,e])),n=i.map(e=>{const t=o.get(e.field);if(!t)return e;const i={...e};return void 0!==t.width&&(i.width=t.width,i.__renderedWidth=t.width),void 0!==t.visible&&(i.hidden=!t.visible),i});n.sort((e,t)=>(o.get(e.field)?.order??1/0)-(o.get(t.field)?.order??1/0)),this.columns=n;const r=e.columns.filter(e=>void 0!==e.sort).sort((e,t)=>(e.sort?.priority??0)-(t.sort?.priority??0));if(r.length>0){const e=r[0];e.sort&&this.#u.setSortState({field:e.field,direction:"asc"===e.sort.direction?1:-1})}else this.#u.setSortState(null);for(const s of t)if(s.applyColumnState)for(const t of e.columns)s.applyColumnState(t.field,t)}resetState(e){this.#h=void 0,this.#u.setSortState(null),this.#s=this.#p(this.#r),this.#w();for(const t of e)if(t.applyColumnState)for(const e of this.columns)t.applyColumnState(e.field,{field:e.field,order:0,visible:!0});this.requestStateChange(e)}#v(){const e=/* @__PURE__ */new Map,t=this.#u.getSortState();return t&&e.set(t.field,{direction:1===t.direction?"asc":"desc",priority:0}),e}requestStateChange(e){this.#d&&clearTimeout(this.#d),this.#d=setTimeout(()=>{this.#d=void 0;const t=this.collectState(e);this.#u.emit("column-state-change",t)},100)}setColumnVisible(e,t){const i=this.columns,o=i.find(t=>t.field===e);if(!o)return!1;if(!t&&o.lockVisible)return!1;if(!t){if(0===i.filter(t=>!t.hidden&&t.field!==e).length)return!1}return!!o.hidden!=!t&&(o.hidden=!t,this.#u.emit("column-visibility",{field:e,visible:t,visibleColumns:i.filter(e=>!e.hidden).map(e=>e.field)}),this.#u.clearRowPool(),this.#u.setup(),!0)}toggleColumnVisibility(e){const t=this.columns.find(t=>t.field===e);return!!t&&this.setColumnVisible(e,!!t.hidden)}isColumnVisible(e){const t=this.columns.find(t=>t.field===e);return!!t&&!t.hidden}showAllColumns(){const e=this.columns;e.some(e=>e.hidden)&&(e.forEach(e=>e.hidden=!1),this.#u.emit("column-visibility",{visibleColumns:e.map(e=>e.field)}),this.#u.clearRowPool(),this.#u.setup())}getAllColumns(){return this.columns.map(e=>({field:e.field,header:e.header||e.field,visible:!e.hidden,lockVisible:e.lockVisible,utility:!0===e.meta?.utility}))}getColumnOrder(){return this.columns.map(e=>e.field)}setColumnOrder(e){if(!e.length)return;const t=new Map(this.columns.map(e=>[e.field,e])),i=[];for(const o of e){const e=t.get(o);e&&(i.push(e),t.delete(o))}for(const o of t.values())i.push(o);this.columns=i,this.#u.renderHeader(),this.#u.updateTemplate(),this.#u.refreshVirtualWindow()}parseLightDomColumns(e){this.#o||(this.#n=Array.from(e.querySelectorAll("tbw-grid-column")),this.#o=this.#n.length?function(e){return Array.from(e.querySelectorAll("tbw-grid-column")).map(e=>{const t=e.getAttribute("field")||"";if(!t)return null;const i=e.getAttribute("type")||void 0,o={field:t,type:i&&/* @__PURE__ */new Set(["number","string","date","boolean","select"]).has(i)?i:void 0,header:e.getAttribute("header")||void 0,sortable:e.hasAttribute("sortable"),editable:e.hasAttribute("editable")},n=e.getAttribute("width");if(n){const e=parseFloat(n);!isNaN(e)&&/^\d+(\.\d+)?$/.test(n.trim())?o.width=e:o.width=n}const r=e.getAttribute("minWidth")||e.getAttribute("min-width");if(r){const e=parseFloat(r);isNaN(e)||(o.minWidth=e)}e.hasAttribute("resizable")&&(o.resizable=!0),e.hasAttribute("sizable")&&(o.resizable=!0);const s=e.getAttribute("editor"),l=e.getAttribute("renderer");s&&(o.__editorName=s),l&&(o.__rendererName=l);const a=e.getAttribute("options");a&&(o.options=a.split(",").map(e=>{const[t,i]=e.includes(":")?e.split(":"):[e.trim(),e.trim()];return{value:t.trim(),label:i?.trim()||t.trim()}}));const c=e.querySelector("tbw-grid-column-view"),d=e.querySelector("tbw-grid-column-editor"),h=e.querySelector("tbw-grid-column-header");c&&(o.__viewTemplate=c),d&&(o.__editorTemplate=d),h&&(o.__headerTemplate=h);const u=globalThis.DataGridElement,g=u?.getAdapters?.()??[],f=c??e,p=g.find(e=>e.canHandle(f));if(p){const e=p.createRenderer(f);e&&(o.viewRenderer=e)}const w=d??e,b=g.find(e=>e.canHandle(w));if(b){const e=b.createEditor(w);e&&(o.editor=e)}return o}).filter(e=>!!e)}(e):[])}clearLightDomCache(){this.#o=void 0}#C=/* @__PURE__ */new Map;registerLightDomHandler(e,t){this.#C.set(e.toLowerCase(),t)}unregisterLightDomHandler(e){this.#C.delete(e.toLowerCase())}observeLightDOM(e){this.#c&&this.#c.disconnect();const t=/* @__PURE__ */new Set;let i=null;const o=()=>{i=null;for(const e of t){const t=this.#C.get(e);t?.()}t.clear()};this.#c=new MutationObserver(e=>{for(const i of e){for(const e of i.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;const i=e.tagName.toLowerCase();this.#C.has(i)&&t.add(i)}if("attributes"===i.type&&i.target.nodeType===Node.ELEMENT_NODE){const e=i.target.tagName.toLowerCase();this.#C.has(e)&&t.add(e)}}t.size>0&&!i&&(i=setTimeout(o,0))}),this.#c.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["title","field","header","width","hidden","id","icon","tooltip","order"]})}onChange(e){this.#a.push(e)}notifyChange(){for(const e of this.#a)e()}dispose(){this.#c?.disconnect(),this.#a=[],this.#d&&clearTimeout(this.#d)}}function E(){if("undefined"!=typeof window&&window.location){const e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e||"::1"===e)return!0}return"undefined"!=typeof process&&"production"!==process.env?.NODE_ENV}function x(e){return`<span role="checkbox" aria-checked="${e}" aria-label="${e}">${e?"🗹":"☐"}</span>`}function A(e){if(null==e||""===e)return"";if(e instanceof Date)return isNaN(e.getTime())?"":e.toLocaleDateString();if("number"==typeof e||"string"==typeof e){const t=new Date(e);return isNaN(t.getTime())?"":t.toLocaleDateString()}return""}function T(e){if(!e)return-1;const t=e.getAttribute("data-row");if(t)return parseInt(t,10);const i=e.closest(".data-grid-row");if(!i)return-1;const o=i.parentElement;if(!o)return-1;const n=o.querySelectorAll(":scope > .data-grid-row");for(let r=0;r<n.length;r++)if(n[r]===i)return r;return-1}function H(e){e&&e.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus"))}function P(e){try{if("rtl"===getComputedStyle(e).direction)return"rtl"}catch{}try{const t=e.closest?.("[dir]")?.getAttribute("dir");if("rtl"===t)return"rtl"}catch{}return"ltr"}function M(e){return"rtl"===P(e)}function L(e,t){return"left"===e||"right"===e?e:"rtl"===t?"start"===e?"right":"left":"start"===e?"left":"right"}function z(e,t){const i=t.renderer||t.viewRenderer;if(i)return i;if(!t.type)return;const o=e.__frameworkAdapter;if(o?.getTypeDefault){const e=o.getTypeDefault(t.type);if(e?.renderer)return e.renderer}}function k(e,t){if(t.format)return t.format;if(!t.type)return;const i=e.__frameworkAdapter;if(i?.getTypeDefault){const e=i.getTypeDefault(t.type);if(e?.format)return e.format}}const O='input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';function D(e){return(e.__editingCellCount??0)>0}function I(e){e.__editingCellCount=0,e.removeAttribute("data-has-editing");e.querySelectorAll(".cell.editing").forEach(e=>e.classList.remove("editing"))}const N=document.createElement("template");N.innerHTML='<div class="cell" role="gridcell" part="cell"></div>';const q=document.createElement("template");function $(){return N.content.firstElementChild.cloneNode(!0)}function W(){return q.content.firstElementChild.cloneNode(!0)}function F(e){e.__cellDisplayCache=void 0,e.__cellCacheEpoch=void 0,e.__hasSpecialColumns=void 0}function U(e,t,i,o){const n=t.children,r=e._visibleColumns,s=r.length,l=n.length,a=s<l?s:l,c=e._focusRow,d=e._focusCol,h=e._hasAfterCellRenderHook?.()??!1;let u=e.__hasSpecialColumns;if(void 0===u){u=!1;const t=e.__frameworkAdapter;for(let e=0;e<s;e++){const i=r[e];if(i.__viewTemplate||i.__compiledView||i.renderer||i.viewRenderer||i.externalView||i.format||"date"===i.type||"boolean"===i.type||i.type&&t?.getTypeDefault?.(i.type)?.renderer||i.type&&t?.getTypeDefault?.(i.type)?.format){u=!0;break}}e.__hasSpecialColumns=u}const g=String(o);if(u){for(let s=0;s<a;s++){if(r[s].externalView){if(!n[s].querySelector("[data-external-view]"))return void V(e,t,i,o)}}for(let s=0;s<a;s++){const l=r[s],a=n[s];a.getAttribute("data-row")!==g&&a.setAttribute("data-row",g);const u=a.classList.contains("editing");if(!u){const e=c===o&&d===s;e!==a.classList.contains("cell-focus")&&(a.classList.toggle("cell-focus",e),a.setAttribute("aria-selected",String(e)))}const p=l.cellClass;if(p){const e=a.getAttribute("data-dynamic-classes");e&&e.split(" ").forEach(e=>e&&a.classList.remove(e));try{const e=p(i[l.field],i,l);if(e&&e.length>0){const t=e.filter(e=>e&&"string"==typeof e);t.forEach(e=>a.classList.add(e)),a.setAttribute("data-dynamic-classes",t.join(" "))}else a.removeAttribute("data-dynamic-classes")}catch(f){console.warn(`[tbw-grid] cellClass callback error for column '${l.field}':`,f),a.removeAttribute("data-dynamic-classes")}}if(u)continue;const w=z(e,l);if(w){const n=i[l.field],r=w({row:i,value:n,field:l.field,column:l,cellEl:a});"string"==typeof r?(e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=v(r)):r instanceof Node?r.parentElement!==a&&(e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML="",a.appendChild(r)):null==r&&(e.__frameworkAdapter?.releaseCell?.(a),a.textContent=null==n?"":String(n)),h&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:n,cellElement:a,rowElement:t});continue}if(l.__compiledView){const n=i[l.field],r=l.__compiledView({row:i,value:n,field:l.field,column:l});l.__compiledView.__blocked?a.textContent="":(a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=v(r),_(a)),h&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:n,cellElement:a,rowElement:t});continue}if(l.__viewTemplate){const n=i[l.field],r=l.__viewTemplate.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(r)?a.textContent="":(a.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(a),a.innerHTML=v(C(r,{row:i,value:n})),_(a)),h&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:n,cellElement:a,rowElement:t});continue}if(l.externalView)continue;const b=i[l.field];let m;const y=k(e,l);if(y){try{const e=y(b,i);m=null==e?"":String(e)}catch(f){console.warn(`[tbw-grid] Format error in column '${l.field}':`,f),m=null==b?"":String(b)}a.textContent=m}else"date"===l.type?(m=A(b),a.textContent=m):"boolean"===l.type?a.innerHTML=x(!!b):(m=null==b?"":String(b),a.textContent=m);h&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:s,value:b,cellElement:a,rowElement:t})}}else for(let p=0;p<a;p++){const s=n[p];if(s.classList.contains("editing"))continue;s.firstElementChild&&e.__frameworkAdapter?.releaseCell?.(s);const l=r[p],a=i[l.field];s.textContent=null==a?"":String(a),s.getAttribute("data-row")!==g&&s.setAttribute("data-row",g);const u=c===o&&d===p;u!==s.classList.contains("cell-focus")&&(s.classList.toggle("cell-focus",u),s.setAttribute("aria-selected",String(u))),h&&e._afterCellRender?.({row:i,rowIndex:o,column:l,colIndex:p,value:a,cellElement:s,rowElement:t})}}function V(e,t,i,o){t.classList.remove("tbw-row-loading"),t.removeAttribute("aria-busy");const n=e.__frameworkAdapter;if(n?.releaseCell){const e=t.children;for(let t=e.length-1;t>=0;t--)n.releaseCell(e[t])}t.innerHTML="";const r=e._visibleColumns,s=r.length,l=e._focusRow,a=e._focusCol,c=e,d=e._hasAfterCellRenderHook?.()??!1,h=document.createDocumentFragment();for(let g=0;g<s;g++){const n=r[g],s=$();s.setAttribute("aria-colindex",String(g+1)),s.setAttribute("data-col",String(g)),s.setAttribute("data-row",String(o)),s.setAttribute("data-field",n.field),s.setAttribute("data-header",n.header??n.field),n.type&&s.setAttribute("data-type",n.type);let f=i[n.field];const p=k(e,n);if(p)try{f=p(f,i)}catch(u){console.warn(`[tbw-grid] Format error in column '${n.field}':`,u)}const w=n.__compiledView,b=n.__viewTemplate,m=z(e,n),y=n.externalView;let S=!1;if(m){const e=m({row:i,value:f,field:n.field,column:n,cellEl:s});"string"==typeof e?(s.innerHTML=v(e),S=!0):e instanceof Node?e.parentElement!==s&&(s.textContent="",s.appendChild(e)):null==e&&(s.textContent=null==f?"":String(f))}else if(y){const e=y,t=document.createElement("div");t.setAttribute("data-external-view",""),t.setAttribute("data-field",n.field),s.appendChild(t);const o={row:i,value:f,field:n.field,column:n};if(e.mount)try{e.mount({placeholder:t,context:o,spec:e})}catch(u){console.warn(`[tbw-grid] External view mount error for column '${n.field}':`,u)}else queueMicrotask(()=>{try{c.dispatchEvent(new CustomEvent("mount-external-view",{bubbles:!0,composed:!0,detail:{placeholder:t,spec:e,context:o}}))}catch(u){console.warn(`[tbw-grid] External view event dispatch error for column '${n.field}':`,u)}});t.setAttribute("data-mounted","")}else if(w){const e=w({row:i,value:f,field:n.field,column:n}),t=w.__blocked;s.innerHTML=t?"":v(e),S=!0,t&&(s.textContent="",s.setAttribute("data-blocked-template",""))}else if(b){const e=b.innerHTML;/Reflect\.|\bProxy\b|ownKeys\(/.test(e)?(s.textContent="",s.setAttribute("data-blocked-template","")):(s.innerHTML=v(C(e,{row:i,value:f})),S=!0)}else p?s.textContent=null==f?"":String(f):"date"===n.type?s.textContent=A(f):"boolean"===n.type?s.innerHTML=x(!!f):s.textContent=null==f?"":String(f);if(S){_(s);const e=s.textContent||"";/Proxy|Reflect\.ownKeys/.test(e)&&(s.textContent=e.replace(/Proxy|Reflect\.ownKeys/g,"").trim(),/Proxy|Reflect\.ownKeys/.test(s.textContent||"")&&(s.textContent=""))}s.hasAttribute("data-blocked-template")&&(s.textContent||"").trim().length&&(s.textContent=""),n.editable?s.tabIndex=0:"boolean"===n.type&&(s.hasAttribute("tabindex")||(s.tabIndex=0)),l===o&&a===g?(s.classList.add("cell-focus"),s.setAttribute("aria-selected","true")):s.setAttribute("aria-selected","false");const R=n.cellClass;if(R)try{const e=R(i[n.field],i,n);if(e&&e.length>0){const t=e.filter(e=>e&&"string"==typeof e);t.forEach(e=>s.classList.add(e)),s.setAttribute("data-dynamic-classes",t.join(" "))}}catch(u){console.warn(`[tbw-grid] cellClass callback error for column '${n.field}':`,u)}d&&e._afterCellRender?.({row:i,rowIndex:o,column:n,colIndex:g,value:f,cellElement:s,rowElement:t}),h.appendChild(s)}t.appendChild(h)}function B(e,t,i){if(t.target?.closest(".resize-handle"))return;const o=T(i.querySelector(".cell[data-row]"));if(o<0)return;const n=e._rows[o];if(!n)return;if(e._dispatchRowClick?.(t,o,n,i))return;const r=t.target?.closest(".cell[data-col]");if(r){const i=Number(r.getAttribute("data-col"));if(!isNaN(i)){if(e._dispatchCellClick?.(t,o,i,r))return;const n=e._focusRow!==o||e._focusCol!==i;if(e._focusRow=o,e._focusCol=i,r.classList.contains("editing")){n&&(H(e._bodyEl??e),r.classList.add("cell-focus"));const t=r.querySelector(O);try{t?.focus({preventScroll:!0})}catch{}return}G(e)}}}function G(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:i,viewportEl:o}=e._virtualization,n=i,r=o?.clientHeight??n?.clientHeight??0;if(n&&r>0){const i=e._focusRow*t;i<n.scrollTop?n.scrollTop=i:i+t>n.scrollTop+r&&(n.scrollTop=i-r+t)}}const i=void 0!==e._activeEditRows&&-1!==e._activeEditRows;i||e.refreshVirtualWindow(!1),H(e._bodyEl),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const o=e._focusRow,n=e._virtualization.start??0,r=e._virtualization.end??e._rows.length;if(o>=n&&o<r){const r=e._bodyEl.querySelectorAll(".data-grid-row")[o-n];let s=r?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=r?.querySelector(`.cell[data-col="${e._focusCol}"]`)??r?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const o=e.querySelector(".tbw-scroll-area");if(o&&s&&(!i||t?.forceHorizontalScroll))if(t?.forceScrollLeft)o.scrollLeft=0;else if(t?.forceScrollRight)o.scrollLeft=o.scrollWidth-o.clientWidth;else{const t=e._getHorizontalScrollOffsets?.(r??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),i=o.getBoundingClientRect(),n=e.left-i.left+o.scrollLeft,r=n+e.width,l=o.scrollLeft+t.left,a=o.scrollLeft+o.clientWidth-t.right;n<l?o.scrollLeft=n-t.left:r>a&&(o.scrollLeft=r-o.clientWidth+t.right)}}if(i&&s.classList.contains("editing")){const e=s.querySelector(O);if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(i&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else if(!i){const t=e;document.activeElement!==t&&t.focus({preventScroll:!0})}}}}q.innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const X=/* @__PURE__ */new WeakMap;function Y(e,t){const i=T(t),o=function(e){if(!e)return-1;const t=e.getAttribute("data-col");return t?parseInt(t,10):-1}(t);if(i<0||o<0)return;e._focusRow=i,e._focusCol=o,H(e._bodyEl),t.classList.add("cell-focus"),t.setAttribute("aria-selected","true");const n=t.closest("tbw-grid");n&&document.activeElement!==n&&n.focus({preventScroll:!0})}function j(e,t,i,o){let n=null;const r=i.composedPath?.();if(n=r&&r.length>0?r[0]:i.target,n&&!t.contains(n)){const e=document.elementFromPoint(i.clientX,i.clientY);e&&(n=e)}const s=n?.closest?.("[data-col]"),l=n?.closest?.(".data-grid-row"),a=n?.closest?.(".header-row");let c,d,h,u,g,f;return s&&(c=parseInt(s.getAttribute("data-row")??"-1",10),d=parseInt(s.getAttribute("data-col")??"-1",10),c>=0&&d>=0&&(h=e._rows[c],f=e._visibleColumns[d],u=f?.field,g=h&&u?h[u]:void 0)),{type:o,row:h,rowIndex:void 0!==c&&c>=0?c:void 0,colIndex:void 0!==d&&d>=0?d:void 0,field:u,value:g,column:f,originalEvent:i,cellElement:s??void 0,rowElement:l??void 0,isHeader:!!a,cell:void 0!==c&&void 0!==d&&c>=0&&d>=0?{row:c,col:d}:void 0}}function K(e,t,i,o){t.addEventListener("keydown",t=>function(e,t){if(e._dispatchKeyDown?.(t))return;const i=e._rows.length-1,o=e._visibleColumns.length-1,n=void 0!==e._activeEditRows&&-1!==e._activeEditRows,r=e._visibleColumns[e._focusCol],s=r?.type,l=t.composedPath?.()??[],a=l.length?l[0]:t.target,c=e=>{if(!e)return!1;const t=e.tagName;return"INPUT"===t||"SELECT"===t||"TEXTAREA"===t||!!e.isContentEditable};if((!c(a)||"Home"!==t.key&&"End"!==t.key)&&!(c(a)&&("ArrowUp"===t.key||"ArrowDown"===t.key)&&"INPUT"===a.tagName&&"number"===a.type||c(a)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)||c(a)&&("Enter"===t.key||"Escape"===t.key)||n&&"select"===s&&("ArrowDown"===t.key||"ArrowUp"===t.key))){switch(t.key){case"Tab":return t.preventDefault(),t.shiftKey?e._focusCol>0?e._focusCol-=1:e._focusRow>0&&("function"==typeof e.commitActiveRowEdit&&e._activeEditRows===e._focusRow&&e.commitActiveRowEdit(),e._focusRow-=1,e._focusCol=o):e._focusCol<o?e._focusCol+=1:("function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow<i&&(e._focusRow+=1,e._focusCol=0)),void G(e);case"ArrowDown":n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.min(i,e._focusRow+1),t.preventDefault();break;case"ArrowUp":n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=Math.max(0,e._focusRow-1),t.preventDefault();break;case"ArrowRight":{const i=M(e);e._focusCol=i?Math.max(0,e._focusCol-1):Math.min(o,e._focusCol+1),t.preventDefault();break}case"ArrowLeft":{const i=M(e);e._focusCol=i?Math.min(o,e._focusCol+1):Math.max(0,e._focusCol-1),t.preventDefault();break}case"Home":return t.ctrlKey||t.metaKey?(n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=0,e._focusCol=0):e._focusCol=0,t.preventDefault(),void G(e,{forceScrollLeft:!0});case"End":return t.ctrlKey||t.metaKey?(n&&"function"==typeof e.commitActiveRowEdit&&e.commitActiveRowEdit(),e._focusRow=i,e._focusCol=o):e._focusCol=o,t.preventDefault(),void G(e,{forceScrollRight:!0});case"PageDown":e._focusRow=Math.min(i,e._focusRow+20),t.preventDefault();break;case"PageUp":e._focusRow=Math.max(0,e._focusRow-20),t.preventDefault();break;case"Enter":{const i=e._focusRow,o=e._focusCol,n=e._visibleColumns[o],r=e._rows[i],s=n?.field??"",l=s&&r?r[s]:void 0,a=e.querySelector(`[data-row="${i}"][data-col="${o}"]`),c=new CustomEvent("cell-activate",{cancelable:!0,detail:{rowIndex:i,colIndex:o,column:n,field:s,value:l,row:r,cellEl:a,trigger:"keyboard",originalEvent:t}});e.dispatchEvent(c);const d=new CustomEvent("activate-cell",{cancelable:!0,detail:{row:i,col:o}});if(e.dispatchEvent(d),c.defaultPrevented||d.defaultPrevented)return void t.preventDefault();break}default:return}G(e)}}(e,t),{signal:o}),i.addEventListener("mousedown",t=>function(e,t,i){const o=j(e,t,i,"mousedown");e._dispatchCellMouseDown?.(o)&&X.set(e,!0)}(e,i,t),{signal:o}),document.addEventListener("mousemove",t=>function(e,t,i){if(!X.get(e))return;const o=j(e,t,i,"mousemove");e._dispatchCellMouseMove?.(o)}(e,i,t),{signal:o}),document.addEventListener("mouseup",t=>function(e,t,i){if(!X.get(e))return;const o=j(e,t,i,"mouseup");e._dispatchCellMouseUp?.(o),X.set(e,!1)}(e,i,t),{signal:o})}function Z(e,t){return null==e&&null==t?0:null==e?-1:null==t||e>t?1:e<t?-1:0}function Q(e,t,i){const o=i.find(e=>e.field===t.field),n=o?.sortComparator??Z,{field:r,direction:s}=t;return[...e].sort((e,t)=>n(e[r],t[r],e,t)*s)}function J(e,t,i,o){e._rows=t,e.__rowRenderEpoch++,e._rowPool.forEach(e=>e.__epoch=-1),le(e),e.refreshVirtualWindow(!0),e.dispatchEvent(new CustomEvent("sort-change",{detail:{field:i.field,direction:o}})),e.requestStateChange?.()}function ee(e,t){if(e._sortState&&e._sortState.field===t.field)if(1===e._sortState.direction)te(e,t,-1);else{e._sortState=null,e.__rowRenderEpoch++,e._rowPool.forEach(e=>e.__epoch=-1),e._rows=e.__originalOrder.slice(),le(e);const i=e._headerRowEl?.querySelectorAll('[role="columnheader"].sortable');i?.forEach(t=>{t.getAttribute("aria-sort")&&("ascending"!==t.getAttribute("aria-sort")&&"descending"!==t.getAttribute("aria-sort")||e._sortState)||t.setAttribute("aria-sort","none")}),e.refreshVirtualWindow(!0),e.dispatchEvent(new CustomEvent("sort-change",{detail:{field:t.field,direction:0}})),e.requestStateChange?.()}else e._sortState||(e.__originalOrder=e._rows.slice()),te(e,t,1)}function te(e,t,i){e._sortState={field:t.field,direction:i};const o={field:t.field,direction:i},n=e._columns,r=(e.effectiveConfig?.sortHandler??Q)(e._rows,o,n);r&&"function"==typeof r.then?r.then(o=>{J(e,o,t,i)}):J(e,r,t,i)}function ie(e,t){return!1!==e.effectiveConfig?.sortable&&!0===t.sortable}function oe(e,t){return!1!==e.effectiveConfig?.resizable&&!1!==t.resizable}function ne(e,t){const i=document.createElement("span");r(i,"sort-indicator");const n=e._sortState?.field===t.field?e._sortState.direction:0,s={...o,...e.icons};return function(e,t){"string"==typeof t?e.textContent=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}(i,1===n?s.sortAsc:-1===n?s.sortDesc:s.sortNone),i}function re(e,t,i){const o=document.createElement("div");return o.className="resize-handle",o.setAttribute("aria-hidden","true"),o.addEventListener("mousedown",o=>{o.stopPropagation(),o.preventDefault(),e._resizeController.start(o,t,i)}),o.addEventListener("dblclick",i=>{i.stopPropagation(),i.preventDefault(),e._resizeController.resetColumn(t)}),o}function se(e,t,i,o){o.classList.add("sortable"),o.tabIndex=0;const n=e._sortState?.field===t.field?e._sortState.direction:0;o.setAttribute("aria-sort",0===n?"none":1===n?"ascending":"descending"),o.addEventListener("click",i=>{e._resizeController?.isResizing||e._dispatchHeaderClick?.(i,t,o)||ee(e,t)}),o.addEventListener("keydown",i=>{if("Enter"===i.key||" "===i.key){if(i.preventDefault(),e._dispatchHeaderClick?.(i,t,o))return;ee(e,t)}})}function le(e){e._headerRowEl=e.findHeaderRow();const t=e._headerRowEl;t&&(t.innerHTML="",e._visibleColumns.forEach((i,o)=>{const n=document.createElement("div");n.className="cell",r(n,"header-cell"),n.setAttribute("role","columnheader"),n.setAttribute("aria-colindex",String(o+1)),n.setAttribute("data-field",i.field),n.setAttribute("data-col",String(o)),i.type&&n.setAttribute("data-type",i.type);const s=i.header??i.field,l=e._sortState?.field===i.field?e._sortState.direction:0,a=1===l?"asc":-1===l?"desc":null;if(i.headerRenderer){const t={column:i,value:s,sortState:a,filterActive:!1,cellEl:n,renderSortIcon:()=>ie(e,i)?ne(e,i):null,renderFilterButton:()=>null},r=i.headerRenderer(t);!function(e,t){if(null!=t)if("string"==typeof t){const i=document.createElement("span");for(i.innerHTML=v(t);i.firstChild;)e.appendChild(i.firstChild)}else t instanceof Node&&e.appendChild(t)}(n,r),ie(e,i)&&se(e,i,0,n),oe(e,i)&&(n.classList.add("resizable"),n.appendChild(re(e,o,n)))}else if(i.headerLabelRenderer){const t={column:i,value:s},r=i.headerLabelRenderer(t),l=document.createElement("span");null==r?l.textContent=s:"string"==typeof r?l.innerHTML=v(r):r instanceof Node&&l.appendChild(r),n.appendChild(l),ie(e,i)&&(se(e,i,0,n),n.appendChild(ne(e,i))),oe(e,i)&&(n.classList.add("resizable"),n.appendChild(re(e,o,n)))}else if(i.__headerTemplate)Array.from(i.__headerTemplate.childNodes).forEach(e=>n.appendChild(e.cloneNode(!0))),ie(e,i)&&(se(e,i,0,n),n.appendChild(ne(e,i))),oe(e,i)&&(n.classList.add("resizable"),n.appendChild(re(e,o,n)));else{const t=document.createElement("span");t.textContent=s,n.appendChild(t),ie(e,i)&&(se(e,i,0,n),n.appendChild(ne(e,i))),oe(e,i)&&(n.classList.add("resizable"),n.appendChild(re(e,o,n)))}t.appendChild(n)}),t.querySelectorAll(".cell.sortable").forEach(e=>{e.getAttribute("aria-sort")||e.setAttribute("aria-sort","none")}),t.children.length>0?(t.setAttribute("role","row"),t.setAttribute("aria-rowindex","1")):(t.removeAttribute("role"),t.removeAttribute("aria-rowindex")))}const ae="function"==typeof requestIdleCallback;function ce(e){ae?cancelIdleCallback(e):clearTimeout(e)}function de(e,t){if(t){const i=t({size:e});if("string"==typeof i){const e=document.createElement("div");return e.innerHTML=i,e}return i}return function(e){const t=document.createElement("div");return t.className=`tbw-spinner tbw-spinner--${e}`,t.setAttribute("role","progressbar"),t.setAttribute("aria-label","Loading"),t}(e)}var he,ue=((he=ue||{})[he.STYLE=1]="STYLE",he[he.VIRTUALIZATION=2]="VIRTUALIZATION",he[he.HEADER=3]="HEADER",he[he.ROWS=4]="ROWS",he[he.COLUMNS=5]="COLUMNS",he[he.FULL=6]="FULL",he);class ge{#u;#y=0;#_=0;#S=null;#R=null;#E=null;#x=!1;constructor(e){this.#u=e}requestPhase(e,t){e>this.#y&&(this.#y=e),0===this.#_&&(this.#A(),this.#_=requestAnimationFrame(()=>this.#T()))}whenReady(){return this.#S?this.#S:Promise.resolve()}setInitialReadyResolver(e){this.#E=e}cancel(){0!==this.#_&&(cancelAnimationFrame(this.#_),this.#_=0),this.#y=0,this.#R&&(this.#R(),this.#R=null,this.#S=null)}get isPending(){return 0!==this.#y}get pendingPhase(){return this.#y}#A(){this.#S||(this.#S=new Promise(e=>{this.#R=e}))}#T(){if(this.#_=0,!this.#u.isConnected())return this.#y=0,void(this.#R&&(this.#R(),this.#R=null,this.#S=null));const e=this.#y;this.#y=0,e>=5&&this.#u.mergeConfig(),e>=4&&this.#u.processRows(),e>=5&&(this.#u.processColumns(),this.#u.updateTemplate()),e>=3&&this.#u.renderHeader(),e>=2&&this.#u.renderVirtualWindow(),e>=1&&this.#u.afterRender(),!this.#x&&this.#E&&(this.#x=!0,this.#E()),this.#R&&(this.#R(),this.#R=null,this.#S=null)}}function fe(e){let t=null,i=null,o=null,n=null;const r=o=>{if(!t)return;const n=o.clientX-t.startX,r=Math.max(40,t.startWidth+n),s=e._visibleColumns[t.colIndex];s.width=r,s.__userResized=!0,s.__renderedWidth=r,null==i&&(i=requestAnimationFrame(()=>{i=null,e.updateTemplate?.()})),e.dispatchEvent(new CustomEvent("column-resize",{detail:{field:s.field,width:r}}))};let s=!1;const l=()=>{const i=null!==t;i&&(s=!0,requestAnimationFrame(()=>{s=!1})),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",l),null!==o&&(document.documentElement.style.cursor=o,o=null),null!==n&&(document.body.style.userSelect=n,n=null),t=null,i&&e.requestStateChange&&e.requestStateChange()};return{get isResizing(){return null!==t||s},start(i,s,a){i.preventDefault();const c=e._visibleColumns[s],d="number"==typeof c?.width?c.width:void 0,h=c?.__renderedWidth??d??a.getBoundingClientRect().width;t={startX:i.clientX,colIndex:s,startWidth:h},window.addEventListener("mousemove",r),window.addEventListener("mouseup",l),null===o&&(o=document.documentElement.style.cursor),document.documentElement.style.cursor="e-resize",null===n&&(n=document.body.style.userSelect),document.body.style.userSelect="none"},resetColumn(t){const i=e._visibleColumns[t];i&&(i.__userResized=!1,i.__renderedWidth=void 0,i.width=i.__originalWidth,e.updateTemplate?.(),e.requestStateChange?.(),e.dispatchEvent(new CustomEvent("column-resize-reset",{detail:{field:i.field,width:i.width}})))},dispose(){l()}}}const pe="data-animating",we={change:"--tbw-row-change-duration",insert:"--tbw-row-insert-duration",remove:"--tbw-row-remove-duration"},be={change:500,insert:300,remove:200};function me(e,t){const i=we[t],o=getComputedStyle(e).getPropertyValue(i);if(o){const e=function(e){const t=e.trim().toLowerCase();return t.endsWith("ms")?parseFloat(t):t.endsWith("s")?1e3*parseFloat(t):parseFloat(t)}(o);if(!isNaN(e)&&e>0)return e}return be[t]}function ve(e,t,i){if(t<0)return Promise.resolve(!1);const o=e.findRenderedRowElement?.(t);return o?new Promise(e=>{!function(e,t,i){e.removeAttribute(pe),e.offsetWidth,e.setAttribute(pe,t);const o=me(e,t);setTimeout(()=>{"remove"!==t&&e.removeAttribute(pe),i?.()},o)}(o,i,()=>e(!0))}):Promise.resolve(!1)}function Ce(e,t,i){const o=document.createElement(e);if(t)for(const n in t){const e=t[n];null!=e&&o.setAttribute(n,e)}return o}function ye(e,t){const i=document.createElement("div");if(e&&(i.className=e),t)for(const o in t){const e=t[o];null!=e&&i.setAttribute(o,e)}return i}function _e(e,t,i){const o=document.createElement("button");if(e&&(o.className=e),t)for(const n in t){const e=t[n];null!=e&&o.setAttribute(n,e)}return o}const Se=document.createElement("template");function Re(){return Se.content.cloneNode(!0)}function Ee(e){const t=document.createDocumentFragment(),i=ye(e.hasShell?"tbw-grid-root has-shell":"tbw-grid-root");if(e.hasShell&&e.shellHeader&&e.shellBody)i.appendChild(e.shellHeader),i.appendChild(e.shellBody);else{const e=ye("tbw-grid-content");e.appendChild(Re()),i.appendChild(e)}return t.appendChild(i),t}function xe(e){return e?"string"==typeof e?e:e.outerHTML:""}function Ae(e){return!!e?.header?.title||(!!e?.header?.toolbarContents?.length||(!!e?.toolPanels?.length||(!!e?.headerContents?.length||(!!e?.header?.lightDomContent?.length||!!e?.header?.hasToolButtonsContainer))))}function Te(e,t){const i=e.querySelector("tbw-grid-header");if(!i)return;if(!t.lightDomTitle){const e=i.getAttribute("title");e&&(t.lightDomTitle=e)}const o=i.querySelectorAll("tbw-grid-header-content");o.length>0&&0===t.lightDomHeaderContent.length&&(t.lightDomHeaderContent=Array.from(o)),i.style.display="none"}function He(e,t,i){const o=e.querySelector(":scope > tbw-grid-tool-buttons");if(!o)return;t.hasToolButtonsContainer=!0;const n="light-dom-toolbar-content";if(t.lightDomToolbarContentIds.has(n))return;const r={id:n,order:0,render:e=>{for(;o.firstChild;)e.appendChild(o.firstChild);return()=>{for(;e.firstChild;)o.appendChild(e.firstChild)}}};t.toolbarContents.set(n,r),t.lightDomToolbarContentIds.add(n),o.style.display="none"}function Pe(e,t,i){e.querySelectorAll(":scope > tbw-grid-tool-panel").forEach(e=>{const o=e,n=o.getAttribute("id"),r=o.getAttribute("title");if(!n||!r)return void console.warn(`[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${n??""}", title="${r??""}"`);const s=o.getAttribute("icon")??void 0,l=o.getAttribute("tooltip")??void 0,a=parseInt(o.getAttribute("order")??"100",10);let c;const d=i?.(o);if(d)c=d;else{const e=o.innerHTML.trim();c=t=>{const i=document.createElement("div");return i.innerHTML=e,t.appendChild(i),()=>i.remove()}}const h=t.toolPanels.get(n);if(h){if(d){h.render=c,h.order=a,h.icon=s,h.tooltip=l;const e=t.panelCleanups.get(n);e&&(e(),t.panelCleanups.delete(n))}return}const u={id:n,title:r,icon:s,tooltip:l,order:a,render:c};t.toolPanels.set(n,u),t.lightDomToolPanelIds.add(n),o.style.display="none"})}function Me(e,t,i){const o=t?.header?.toolbarContents??[],n=[...i.toolbarContents.values()],r=new Set(o.map(e=>e.id)),s=[...o];for(const l of n)r.has(l.id)||s.push(l);for(const l of s){if(i.toolbarContentCleanups.has(l.id))continue;if(!l.render)continue;const t=e.querySelector(`[data-toolbar-content="${l.id}"]`);if(!t)continue;const o=l.render(t);o&&i.toolbarContentCleanups.set(l.id,o)}}function Le(e,t){const i=t.lightDomHeaderContent.length>0&&!t.lightDomContentMoved,o=t.headerContents.size>0;if(!i&&!o)return;const n=e.querySelector(".tbw-shell-content");if(!n)return;if(i){for(const e of t.lightDomHeaderContent)e.style.display="",n.appendChild(e);t.lightDomContentMoved=!0}const r=[...t.headerContents.values()].sort((e,t)=>(e.order??100)-(t.order??100));for(const s of r){const e=t.headerContentCleanups.get(s.id);e&&(e(),t.headerContentCleanups.delete(s.id));let i=n.querySelector(`[data-header-content="${s.id}"]`);i||(i=document.createElement("div"),i.setAttribute("data-header-content",s.id),n.appendChild(i));const o=s.render(i);o&&t.headerContentCleanups.set(s.id,o)}}function ze(e,t){const i=e.querySelector("[data-panel-toggle]");i&&(i.classList.toggle("active",t.isPanelOpen),i.setAttribute("aria-pressed",String(t.isPanelOpen)))}function ke(e,t){const i=e.querySelector(".tbw-tool-panel");i&&(i.classList.toggle("open",t.isPanelOpen),t.isPanelOpen||(i.style.width=""))}function Oe(e){for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear()}function De(e,t){let i=!1;const n={get isInitialized(){return i},setInitialized(e){i=e},get isPanelOpen(){return e.isPanelOpen},get activePanel(){return e.isPanelOpen&&e.expandedSections.size>0?[...e.expandedSections][0]:null},get expandedSections(){return[...e.expandedSections]},openToolPanel(){if(e.isPanelOpen)return;if(0===e.toolPanels.size)return void console.warn("[tbw-grid] No tool panels registered");if(e.isPanelOpen=!0,0===e.expandedSections.size&&e.toolPanels.size>0){const t=[...e.toolPanels.values()].sort((e,t)=>(e.order??100)-(t.order??100))[0];t&&e.expandedSections.add(t.id)}const i=t.getShadow();ze(i,e),ke(i,e),function(e,t,i){if(!t.isPanelOpen)return;const n=xe(i?.expand??o.expand),r=xe(i?.collapse??o.collapse);for(const[o,s]of t.toolPanels){const i=t.expandedSections.has(o),l=e.querySelector(`[data-section="${o}"]`),a=l?.querySelector(".tbw-accordion-content");if(!l||!a)continue;l.classList.toggle("expanded",i);const c=l.querySelector(".tbw-accordion-header");c&&c.setAttribute("aria-expanded",String(i));const d=l.querySelector(".tbw-accordion-chevron");if(d&&(d.innerHTML=i?r:n),i){if(0===a.children.length){const e=s.render(a);e&&t.panelCleanups.set(o,e)}}else{const e=t.panelCleanups.get(o);e&&(e(),t.panelCleanups.delete(o)),a.innerHTML=""}}}(i,e,t.getAccordionIcons()),t.emit("tool-panel-open",{sections:n.expandedSections})},closeToolPanel(){if(!e.isPanelOpen)return;for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolPanels.values())t.onClose?.();e.isPanelOpen=!1;const i=t.getShadow();ze(i,e),ke(i,e),t.emit("tool-panel-close",{})},toggleToolPanel(){e.isPanelOpen?n.closeToolPanel():n.openToolPanel()},toggleToolPanelSection(i){const o=e.toolPanels.get(i);if(!o)return void console.warn(`[tbw-grid] Tool panel section "${i}" not found`);if(1===e.toolPanels.size)return;const n=t.getShadow(),r=e.expandedSections.has(i);if(r){const t=e.panelCleanups.get(i);t&&(t(),e.panelCleanups.delete(i)),o.onClose?.(),e.expandedSections.delete(i),Ie(n,i,!1)}else{for(const[t,o]of e.toolPanels)if(t!==i&&e.expandedSections.has(t)){const i=e.panelCleanups.get(t);i&&(i(),e.panelCleanups.delete(t)),o.onClose?.(),e.expandedSections.delete(t),Ie(n,t,!1);const r=n.querySelector(`[data-section="${t}"] .tbw-accordion-content`);r&&(r.innerHTML="")}e.expandedSections.add(i),Ie(n,i,!0),function(e,t,i){const o=t.toolPanels.get(i);if(!o?.render)return;const n=e.querySelector(`[data-section="${i}"] .tbw-accordion-content`);if(!n)return;const r=o.render(n);r&&t.panelCleanups.set(i,r)}(n,e,i)}t.emit("tool-panel-section-toggle",{id:i,expanded:!r})},getToolPanels:()=>[...e.toolPanels.values()],registerToolPanel(o){e.toolPanels.has(o.id)?console.warn(`[tbw-grid] Tool panel "${o.id}" already registered`):(e.toolPanels.set(o.id,o),i&&t.refreshShellHeader())},unregisterToolPanel(o){if(e.expandedSections.has(o)){const t=e.panelCleanups.get(o);t&&(t(),e.panelCleanups.delete(o)),e.expandedSections.delete(o)}e.toolPanels.delete(o),i&&t.refreshShellHeader()},getHeaderContents:()=>[...e.headerContents.values()],registerHeaderContent(o){e.headerContents.has(o.id)?console.warn(`[tbw-grid] Header content "${o.id}" already registered`):(e.headerContents.set(o.id,o),i&&Le(t.getShadow(),e))},unregisterHeaderContent(i){const o=e.headerContentCleanups.get(i);o&&(o(),e.headerContentCleanups.delete(i));const n=e.headerContents.get(i);n?.onDestroy?.(),e.headerContents.delete(i);const r=t.getShadow().querySelector(`[data-header-content="${i}"]`);r?.remove()},getToolbarContents:()=>[...e.toolbarContents.values()].sort((e,t)=>(e.order??0)-(t.order??0)),registerToolbarContent(o){e.toolbarContents.has(o.id)?console.warn(`[tbw-grid] Toolbar content "${o.id}" already registered`):(e.toolbarContents.set(o.id,o),i&&t.refreshShellHeader())},unregisterToolbarContent(o){const n=e.toolbarContentCleanups.get(o);n&&(n(),e.toolbarContentCleanups.delete(o));const r=e.toolbarContents.get(o);r?.onDestroy&&r.onDestroy(),e.toolbarContents.delete(o),i&&t.refreshShellHeader()}};return n}function Ie(e,t,i){const o=e.querySelector(`[data-section="${t}"]`);o&&o.classList.toggle("expanded",i)}function Ne(e,t,i,n){const r=Ae(t),s=[],l=["tbw-grid-header","tbw-grid-tool-buttons","tbw-grid-tool-panel","tbw-grid-column","tbw-grid-detail","tbw-grid-responsive-card"];for(const o of l){e.querySelectorAll(`:scope > ${o}`).forEach(e=>s.push(e))}e.replaceChildren();for(const o of s)e.appendChild(o);if(r){const r=xe(n?.toolPanel??o.toolPanel),s=xe(n?.expand??o.expand),l=xe(n?.collapse??o.collapse),a=[...t?.header?.toolbarContents??[]].sort((e,t)=>(e.order??0)-(t.order??0)),c=[...t?.toolPanels??[]].sort((e,t)=>(e.order??100)-(t.order??100)),d={title:t?.header?.title??void 0,hasPanels:c.length>0,isPanelOpen:i.isPanelOpen,toolPanelIcon:r,configButtons:a.map(e=>({id:e.id,hasElement:!1,hasRender:!!e.render})),apiButtons:[]},h={position:t?.toolPanel?.position??"right",isPanelOpen:i.isPanelOpen,expandIcon:s,collapseIcon:l,panels:c.map(e=>({id:e.id,title:e.title,icon:xe(e.icon),isExpanded:i.expandedSections.has(e.id)}))},u=Ee({hasShell:!0,shellHeader:function(e){const t=ye("tbw-shell-header",{part:"shell-header",role:"presentation"});if(e.title){const i=ye("tbw-shell-title");i.textContent=e.title,t.appendChild(i)}const i=ye("tbw-shell-content",{part:"shell-content",role:"presentation","data-light-dom-header-content":""});t.appendChild(i);const o=ye("tbw-shell-toolbar",{part:"shell-toolbar",role:"presentation"});for(const n of e.configButtons)n.hasRender&&o.appendChild(ye("tbw-toolbar-content-slot",{"data-toolbar-content":n.id}));for(const n of e.apiButtons)n.hasRender&&o.appendChild(ye("tbw-toolbar-content-slot",{"data-toolbar-content":n.id}));if((e.configButtons.some(e=>e.hasRender)||e.apiButtons.some(e=>e.hasRender))&&e.hasPanels&&o.appendChild(ye("tbw-toolbar-separator")),e.hasPanels){const t=_e(e.isPanelOpen?"tbw-toolbar-btn active":"tbw-toolbar-btn",{"data-panel-toggle":"",title:"Settings","aria-label":"Toggle settings panel","aria-pressed":String(e.isPanelOpen),"aria-controls":"tbw-tool-panel"});t.innerHTML=e.toolPanelIcon,o.appendChild(t)}return t.appendChild(o),t}(d),shellBody:function(e){const t=ye("tbw-shell-body"),i=e.panels.length>0,o=1===e.panels.length,n=ye("tbw-grid-content");n.appendChild(Re());let r=null;if(i){r=Ce("aside",{class:e.isPanelOpen?"tbw-tool-panel open":"tbw-tool-panel",part:"tool-panel","data-position":e.position,role:"presentation",id:"tbw-tool-panel"});const t="left"===e.position?"right":"left";r.appendChild(ye("tbw-tool-panel-resize",{"data-resize-handle":"","data-handle-position":t,"aria-hidden":"true"}));const i=ye("tbw-tool-panel-content",{role:"presentation"}),n=ye("tbw-accordion");for(const r of e.panels){const t=ye(`tbw-accordion-section${r.isExpanded?" expanded":""}${o?" single":""}`,{"data-section":r.id}),i=_e("tbw-accordion-header",{"aria-expanded":String(r.isExpanded),"aria-controls":`tbw-section-${r.id}`});if(o&&i.setAttribute("aria-disabled","true"),r.icon){const e=Ce("span",{class:"tbw-accordion-icon"});e.innerHTML=r.icon,i.appendChild(e)}const s=Ce("span",{class:"tbw-accordion-title"});if(s.textContent=r.title,i.appendChild(s),!o){const t=Ce("span",{class:"tbw-accordion-chevron"});t.innerHTML=r.isExpanded?e.collapseIcon:e.expandIcon,i.appendChild(t)}t.appendChild(i),t.appendChild(ye("tbw-accordion-content",{id:`tbw-section-${r.id}`,role:"presentation"})),n.appendChild(t)}i.appendChild(n),r.appendChild(i)}return"left"===e.position&&r?(t.appendChild(r),t.appendChild(n)):(t.appendChild(n),r&&t.appendChild(r)),t}(h)});e.appendChild(u)}else{const t=Ee({hasShell:!1});e.appendChild(t)}return r}Se.innerHTML='\n <div class="tbw-scroll-area">\n <div class="rows-body-wrapper">\n <div class="rows-body" role="grid">\n <div class="header" role="rowgroup">\n <div class="header-row" role="row" part="header-row"></div>\n </div>\n <div class="rows-container" role="presentation">\n <div class="rows-viewport" role="presentation">\n <div class="rows"></div>\n </div>\n </div>\n </div>\n </div>\n </div>\n <div class="faux-vscroll">\n <div class="faux-vscroll-spacer"></div>\n </div>\n';const qe="tbw-grid-styles";let $e="";const We=/* @__PURE__ */new Map;function Fe(){const e=function(){let e=document.getElementById(qe);return e||(e=document.createElement("style"),e.id=qe,e.setAttribute("data-tbw-grid","true"),document.head.appendChild(e)),e}(),t=Array.from(We.values()).join("\n");e.textContent=`${$e}\n\n/* Plugin Styles */\n${t}`}async function Ue(e){if($e)return;if("string"==typeof e&&e.length>0)return $e=e,void Fe();await new Promise(e=>setTimeout(e,50));const t=function(){try{for(const e of Array.from(document.styleSheets))try{const t=Array.from(e.cssRules||[]).map(e=>e.cssText).join("\n");if(t.includes(".tbw-grid-root")&&t.includes("tbw-grid"))return t}catch{continue}}catch(e){console.warn("[tbw-grid] Failed to extract grid.css from document stylesheets:",e)}return null}();t?($e=t,Fe()):"undefined"!=typeof process&&"test"===process.env?.NODE_ENV||console.warn("[tbw-grid] Could not find grid.css in document.styleSheets. Grid styling will not work.","Available stylesheets:",Array.from(document.styleSheets).map(e=>e.href||"(inline)"))}function Ve(e){e.momentumRaf&&(cancelAnimationFrame(e.momentumRaf),e.momentumRaf=0)}function Be(e,t){(Math.abs(e.velocityY)>.1||Math.abs(e.velocityX)>.1)&&function(e,t){const i=.95,o=.01,n=()=>{e.velocityY*=i,e.velocityX*=i;const r=16*e.velocityY,s=16*e.velocityX;Math.abs(e.velocityY)>o&&(t.fauxScrollbar.scrollTop+=r),Math.abs(e.velocityX)>o&&t.scrollArea&&(t.scrollArea.scrollLeft+=s),Math.abs(e.velocityY)>o||Math.abs(e.velocityX)>o?e.momentumRaf=requestAnimationFrame(n):e.momentumRaf=0};e.momentumRaf=requestAnimationFrame(n)}(e,t),function(e){e.startY=null,e.startX=null,e.scrollTop=null,e.scrollLeft=null,e.lastY=null,e.lastX=null,e.lastTime=null}(e)}function Ge(e,t,i,o){e.addEventListener("touchstart",e=>function(e,t,i){if(1!==e.touches.length)return;Ve(t);const o=e.touches[0];t.startY=o.clientY,t.startX=o.clientX,t.lastY=o.clientY,t.lastX=o.clientX,t.lastTime=performance.now(),t.scrollTop=i.fauxScrollbar.scrollTop,t.scrollLeft=i.scrollArea?.scrollLeft??0,t.velocityY=0,t.velocityX=0}(e,t,i),{passive:!0,signal:o}),e.addEventListener("touchmove",e=>{const o=function(e,t,i){if(1!==e.touches.length||null===t.startY||null===t.startX||null===t.scrollTop||null===t.scrollLeft)return!1;const o=e.touches[0],n=o.clientY,r=o.clientX,s=performance.now(),l=t.startY-n,a=t.startX-r;if(null!==t.lastTime&&null!==t.lastY&&null!==t.lastX){const e=s-t.lastTime;e>0&&(t.velocityY=(t.lastY-n)/e,t.velocityX=(t.lastX-r)/e)}t.lastY=n,t.lastX=r,t.lastTime=s;const{scrollTop:c,scrollHeight:d,clientHeight:h}=i.fauxScrollbar,u=l>0&&c<d-h||l<0&&c>0;let g=!1;if(i.scrollArea){const{scrollLeft:e,scrollWidth:t,clientWidth:o}=i.scrollArea;g=a>0&&e<t-o||a<0&&e>0}return u&&(i.fauxScrollbar.scrollTop=t.scrollTop+l),g&&i.scrollArea&&(i.scrollArea.scrollLeft=t.scrollLeft+a),u||g}(e,t,i);o&&e.preventDefault()},{passive:!1,signal:o}),e.addEventListener("touchend",()=>Be(t,i),{passive:!0,signal:o})}const Xe=[{property:"editable",pluginName:"editing",level:"column",description:'the "editable" column property',isUsed:e=>!0===e},{property:"editor",pluginName:"editing",level:"column",description:'the "editor" column property'},{property:"editorParams",pluginName:"editing",level:"column",description:'the "editorParams" column property'},{property:"group",pluginName:"groupingColumns",level:"column",description:'the "group" column property'},{property:"pinned",pluginName:"pinnedColumns",level:"column",description:'the "pinned" column property',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e},{property:"sticky",pluginName:"pinnedColumns",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:e=>"left"===e||"right"===e||"start"===e||"end"===e}],Ye=[{property:"columnGroups",pluginName:"groupingColumns",level:"config",description:'the "columnGroups" config property',isUsed:e=>Array.isArray(e)&&e.length>0}];function je(e){return`import { ${Ke(e)}Plugin } from '@toolbox-web/grid/plugins/${t=e,t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}';`;var t}function Ke(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Ze(e,t){return e.some(e=>e.name===t)}function Qe(e,t){return e&&"object"==typeof e?"__rowCacheKey"in e?e.__rowCacheKey:"rowId"in e&&null!=e.rowId?`id:${e.rowId}`:t?`id:${t(e)}`:e:e}function Je(e,t,i){const o=Qe(t,i);return"string"==typeof o?e.byKey.get(o):o&&"object"==typeof o?e.byRef.get(o):void 0}function et(e,t,i){if(t<0||t>=e.length)return;const o=e[t],n=i-o.height;if(0!==n){o.height=i,o.measured=!0;for(let i=t+1;i<e.length;i++)e[i].offset+=n}}function tt(e,t){if(0===e.length)return-1;if(t<=0)return 0;let i=0,o=e.length-1;for(;i<=o;){const n=Math.floor((i+o)/2),r=e[n],s=r.offset+r.height;if(t<r.offset)o=n-1;else{if(!(t>=s))return n;i=n+1}}return Math.max(0,Math.min(i,e.length-1))}function it(e,t){const{positionCache:i,heightCache:o,rows:n,start:r,end:s,getPluginHeight:l,getRowId:a}=e;let c=!1;t.forEach(e=>{const t=e.dataset.rowIndex;if(!t)return;const d=parseInt(t,10);if(d<r||d>=s||d>=n.length)return;const h=n[d],u=l?.(h,d);if(void 0!==u){const e=i[d];return void((!e.measured||Math.abs(e.height-u)>1)&&(et(i,d,u),c=!0))}const g=e.offsetHeight;if(g>0){const e=i[d];(!e.measured||Math.abs(e.height-g)>1)&&(et(i,d,g),function(e,t,i,o){const n=Qe(t,o);"string"==typeof n?e.byKey.set(n,i):n&&"object"==typeof n&&e.byRef.set(n,i)}(o,h,g,a),c=!0)}});const d=c?function(e){let t=0;for(const i of e)i.measured&&t++;return t}(i):0,h=c?function(e,t){let i=0,o=0;for(const n of e)n.measured&&(i+=n.height,o++);return o>0?i/o:t}(i,e.defaultHeight):0;return{hasChanges:c,measuredCount:d,averageHeight:h}}function ot(e){const{totalRows:t,viewportHeight:i,scrollTop:o,rowHeight:n,overscan:r}=e,s=Math.ceil(i/n);let l=Math.floor(o/n)-r;l<0&&(l=0);let a=l+s+2*r;return a>t&&(a=t),a===t&&l>0&&(l=Math.max(0,a-s-2*r)),{start:l,end:a,offsetY:l*n,totalHeight:t*n}}function nt(e,t){return e<=t}class rt{constructor(e){this.grid=e}plugins=[];getPlugins(){return this.plugins}pluginMap=/* @__PURE__ */new Map;cellRenderers=/* @__PURE__ */new Map;headerRenderers=/* @__PURE__ */new Map;cellEditors=/* @__PURE__ */new Map;eventListeners=/* @__PURE__ */new Map;queryHandlers=/* @__PURE__ */new Map;static deprecationWarned=/* @__PURE__ */new WeakSet;attachAll(e){for(const t of e)this.attach(t)}attach(e){if(function(e,t){const i=e.name,o=e.constructor.dependencies??[];for(const n of o){const e=n.name,o=n.required??!0,r=n.reason;if(!t.some(t=>t.name===e)){const t=r??`${Ke(i)}Plugin requires ${Ke(e)}Plugin`,n=je(e);if(o)throw new Error(`[tbw-grid] Plugin dependency error:\n\n${t}.\n\n → Add the plugin to your gridConfig.plugins array BEFORE ${Ke(i)}Plugin:\n ${n}\n plugins: [new ${Ke(e)}Plugin(), new ${Ke(i)}Plugin()]`);console.info(`[tbw-grid] ${Ke(i)}Plugin: Optional "${e}" plugin not found. Some features may be unavailable.`)}}}(e,this.plugins),this.pluginMap.set(e.constructor,e),this.plugins.push(e),e.cellRenderers)for(const[t,i]of Object.entries(e.cellRenderers))this.cellRenderers.set(t,i);if(e.headerRenderers)for(const[t,i]of Object.entries(e.headerRenderers))this.headerRenderers.set(t,i);if(e.cellEditors)for(const[t,i]of Object.entries(e.cellEditors))this.cellEditors.set(t,i);this.registerQueryHandlers(e),this.warnDeprecatedHooks(e),e.attach(this.grid);for(const t of this.plugins)t!==e&&t.onPluginAttached&&t.onPluginAttached(e.name,e)}registerQueryHandlers(e){const t=e.constructor.manifest;if(t?.queries)for(const i of t.queries){let t=this.queryHandlers.get(i.type);t||(t=/* @__PURE__ */new Set,this.queryHandlers.set(i.type,t)),t.add(e)}}warnDeprecatedHooks(e){const t=e.constructor;if(rt.deprecationWarned.has(t))return;if(!E())return;const i="function"==typeof e.getExtraHeight||"function"==typeof e.getExtraHeightBefore,o="function"==typeof e.getRowHeight;i&&!o&&(rt.deprecationWarned.add(t),console.warn(`[tbw-grid] Deprecation warning: "${e.name}" uses getExtraHeight() / getExtraHeightBefore() which are deprecated and will be removed in v3.0.\n → Migrate to getRowHeight(row, index) for better variable row height support.\n → See: https://toolbox-web.dev/docs/grid/plugins/migration#row-height-hooks`))}unregisterQueryHandlers(e){for(const[t,i]of this.queryHandlers)i.delete(e),0===i.size&&this.queryHandlers.delete(t)}detachAll(){for(const e of this.plugins)for(const t of this.plugins)t!==e&&t.onPluginDetached&&t.onPluginDetached(e.name);for(let e=this.plugins.length-1;e>=0;e--){const t=this.plugins[e];this.unsubscribeAll(t),this.unregisterQueryHandlers(t),t.detach()}this.plugins=[],this.pluginMap.clear(),this.cellRenderers.clear(),this.headerRenderers.clear(),this.cellEditors.clear(),this.eventListeners.clear(),this.queryHandlers.clear()}getPlugin(e){return this.pluginMap.get(e)}getPluginByName(e){return this.plugins.find(t=>t.name===e)}hasPlugin(e){return this.pluginMap.has(e)}getAll(){return this.plugins}getRegisteredPluginNames(){return this.plugins.map(e=>e.name)}getCellRenderer(e){return this.cellRenderers.get(e)}getHeaderRenderer(e){return this.headerRenderers.get(e)}getCellEditor(e){return this.cellEditors.get(e)}getPluginStyles(){return this.plugins.filter(e=>e.styles).map(e=>({name:e.name,styles:e.styles}))}processRows(e){let t=[...e];for(const i of this.plugins)i.processRows&&(t=i.processRows(t));return t}processColumns(e){let t=[...e];for(const i of this.plugins)i.processColumns&&(t=i.processColumns(t));return t}beforeRender(){for(const e of this.plugins)e.beforeRender?.()}afterRender(){for(const e of this.plugins)e.afterRender?.()}afterCellRender(e){for(const t of this.plugins)t.afterCellRender?.(e)}hasAfterCellRenderHook(){return this.plugins.some(e=>"function"==typeof e.afterCellRender)}afterRowRender(e){for(const t of this.plugins)t.afterRowRender?.(e)}hasAfterRowRenderHook(){return this.plugins.some(e=>"function"==typeof e.afterRowRender)}onScrollRender(){for(const e of this.plugins)e.onScrollRender?.()}getExtraHeight(){let e=0;for(const t of this.plugins)"function"==typeof t.getExtraHeight&&(e+=t.getExtraHeight());return e}hasExtraHeight(){for(const e of this.plugins)if("function"==typeof e.getExtraHeight&&e.getExtraHeight()>0)return!0;return!1}getExtraHeightBefore(e){let t=0;for(const i of this.plugins)"function"==typeof i.getExtraHeightBefore&&(t+=i.getExtraHeightBefore(e));return t}getRowHeight(e,t){for(const i of this.plugins)if("function"==typeof i.getRowHeight){const o=i.getRowHeight(e,t);if(void 0!==o)return o}}hasRowHeightPlugin(){for(const e of this.plugins)if("function"==typeof e.getRowHeight)return!0;return!1}adjustVirtualStart(e,t,i){let o=e;for(const n of this.plugins)if("function"==typeof n.adjustVirtualStart){const r=n.adjustVirtualStart(e,t,i);r<o&&(o=r)}return o}renderRow(e,t,i){for(const o of this.plugins)if(o.renderRow?.(e,t,i))return!0;return!1}queryPlugins(e){const t=[],i=this.queryHandlers.get(e.type);if(i&&i.size>0){for(const o of i){const i=o.handleQuery?.(e)??o.onPluginQuery?.(e);void 0!==i&&t.push(i)}return t}for(const o of this.plugins){const i=o.handleQuery?.(e)??o.onPluginQuery?.(e);void 0!==i&&t.push(i)}return t}subscribe(e,t,i){let o=this.eventListeners.get(t);o||(o=/* @__PURE__ */new Map,this.eventListeners.set(t,o)),o.set(e,i)}unsubscribe(e,t){const i=this.eventListeners.get(t);i&&(i.delete(e),0===i.size&&this.eventListeners.delete(t))}unsubscribeAll(e){for(const[t,i]of this.eventListeners)i.delete(e),0===i.size&&this.eventListeners.delete(t)}emitPluginEvent(e,t){const i=this.eventListeners.get(e);if(i)for(const n of i.values())try{n(t)}catch(o){console.error(`[tbw-grid] Error in plugin event handler for "${e}":`,o)}}onKeyDown(e){for(const t of this.plugins)if(t.onKeyDown?.(e))return!0;return!1}onCellClick(e){for(const t of this.plugins)if(t.onCellClick?.(e))return!0;return!1}onRowClick(e){for(const t of this.plugins)if(t.onRowClick?.(e))return!0;return!1}onHeaderClick(e){for(const t of this.plugins)if(t.onHeaderClick?.(e))return!0;return!1}onScroll(e){for(const t of this.plugins)t.onScroll?.(e)}onCellMouseDown(e){for(const t of this.plugins)if(t.onCellMouseDown?.(e))return!0;return!1}onCellMouseMove(e){for(const t of this.plugins)if(t.onCellMouseMove?.(e))return!0;return!1}onCellMouseUp(e){for(const t of this.plugins)if(t.onCellMouseUp?.(e))return!0;return!1}getHorizontalScrollOffsets(e,t){let i=0,o=0,n=!1;for(const r of this.plugins){const s=r.getHorizontalScrollOffsets?.(e,t);s&&(i+=s.left,o+=s.right,s.skipScroll&&(n=!0))}return{left:i,right:o,skipScroll:n}}getToolPanels(){const e=[];for(const t of this.plugins){const i=t.getToolPanel?.();i&&e.push({plugin:t,panel:i})}return e.sort((e,t)=>(e.panel.order??0)-(t.panel.order??0))}getHeaderContents(){const e=[];for(const t of this.plugins){const i=t.getHeaderContent?.();i&&e.push({plugin:t,content:i})}return e.sort((e,t)=>(e.content.order??0)-(t.content.order??0))}}class st extends HTMLElement{static tagName="tbw-grid";static version="1.22.0";static#H=0;static adapters=[];static registerAdapter(e){this.adapters.push(e)}static getAdapters(){return this.adapters}static clearAdapters(){this.adapters=[]}static get observedAttributes(){return["rows","columns","grid-config","fit-mode","loading"]}get#P(){return this}#M=!1;#S;#R;#L=[];get#s(){return this.#z?.effective??{}}#k=!1;#O=!1;#D={rows:!1,columns:!1,gridConfig:!1,fitMode:!1};#I;#N=0;#q=null;#$=!1;#W=!1;#F=0;#U;#V={startY:null,startX:null,scrollTop:null,scrollLeft:null,lastY:null,lastX:null,lastTime:null,velocityY:0,velocityX:0,momentumRaf:0};#B;#G;#X;#Y;#j={scrollTop:0,scrollLeft:0,scrollHeight:0,scrollWidth:0,clientHeight:0,clientWidth:0};#K;#Z;#Q=!1;#J;#ee;#h;#z;#te=function(){return{toolPanels:/* @__PURE__ */new Map,headerContents:/* @__PURE__ */new Map,toolbarContents:/* @__PURE__ */new Map,hasToolButtonsContainer:!1,lightDomHeaderContent:[],lightDomTitle:null,lightDomToolPanelIds:/* @__PURE__ */new Set,lightDomToolbarContentIds:/* @__PURE__ */new Set,apiToolPanelIds:/* @__PURE__ */new Set,isPanelOpen:!1,expandedSections:/* @__PURE__ */new Set,headerContentCleanups:/* @__PURE__ */new Map,panelCleanups:/* @__PURE__ */new Map,toolbarContentCleanups:/* @__PURE__ */new Map,lightDomContentMoved:!1}}();#ie;#oe;#ne;#re=!1;#se=/* @__PURE__ */new Set;#le=/* @__PURE__ */new Map;#ae;#ce=/* @__PURE__ */new Map;_rows=[];#de=[];get _columns(){return this.#s.columns??[]}set _columns(e){this.#s.columns=e}get _visibleColumns(){return this._columns.filter(e=>!e.hidden)}_headerRowEl;_bodyEl;_rowPool=[];_resizeController;_virtualization={enabled:!0,rowHeight:28,bypassThreshold:24,start:0,end:0,container:null,viewportEl:null,totalHeightEl:null,positionCache:null,heightCache:{byKey:/* @__PURE__ */new Map,byRef:/* @__PURE__ */new WeakMap},averageHeight:28,measuredCount:0,variableHeights:!1,cachedViewportHeight:0,cachedFauxHeight:0,cachedScrollAreaHeight:0,scrollAreaEl:null};_focusRow=0;_focusCol=0;_restoreFocusAfterRender=!1;_sortState=null;_gridTemplate="";__rowRenderEpoch=0;__didInitialAutoSize=!1;get __lightDomColumnsCache(){return this.#z?.lightDomColumnsCache}set __lightDomColumnsCache(e){this.#z&&(this.#z.lightDomColumnsCache=e)}get __originalColumnNodes(){return this.#z?.originalColumnNodes}set __originalColumnNodes(e){this.#z&&(this.#z.originalColumnNodes=e)}__originalOrder=[];__frameworkAdapter;__rowsBodyEl=null;get rows(){return this._rows}set rows(e){const t=this.#L;this.#L=e,t!==e&&this.#he("rows")}get sourceRows(){return this.#L}get columns(){return[...this._columns]}set columns(e){const t=this.#z?.getColumns();this.#z?.setColumns(e),t!==e&&this.#he("columns")}get gridConfig(){return this.#s}set gridConfig(e){const t=this.#z?.getGridConfig();this.#z?.setGridConfig(e),t!==e&&(this.#z.clearLightDomCache(),this.#he("gridConfig"))}get fitMode(){return this.#s.fitMode??"stretch"}set fitMode(e){const t=this.#z?.getFitMode();this.#z?.setFitMode(e),t!==e&&this.#he("fitMode")}get loading(){return this.#re}set loading(e){const t=this.#re;this.#re=e,e?this.setAttribute("loading",""):this.removeAttribute("loading"),t!==e&&this.#ue()}setRowLoading(e,t){const i=this.#se.has(e);t?this.#se.add(e):this.#se.delete(e),i!==t&&this.#ge(e,t)}setCellLoading(e,t,i){let o=this.#le.get(e);const n=o?.has(t)??!1;i?(o||(o=/* @__PURE__ */new Set,this.#le.set(e,o)),o.add(t)):(o?.delete(t),0===o?.size&&this.#le.delete(e)),n!==i&&this.#fe(e,t,i)}isRowLoading(e){return this.#se.has(e)}isCellLoading(e,t){return this.#le.get(e)?.has(t)??!1}clearAllLoading(){this.loading=!1;for(const e of this.#se)this.#ge(e,!1);this.#se.clear();for(const[e,t]of this.#le)for(const i of t)this.#fe(e,i,!1);this.#le.clear()}get effectiveConfig(){return this.#s}get disconnectSignal(){return this.#B||(this.#B=new AbortController),this.#B.signal}constructor(){super(),this.#pe(),this.#S=new Promise(e=>this.#R=e),this.#I=new ge({mergeConfig:()=>{this.#z.parseLightDomColumns(this),this.#z.merge(),this.#we(),function(e,t){const i=Xe,o=Ye,n=/* @__PURE__ */new Map;function r(e,t,i,o,r=!1){n.has(e)||n.set(e,{description:t,importHint:i,fields:[],isConfigProperty:r});const s=n.get(e);s.fields.includes(o)||s.fields.push(o)}for(const l of o){const i=e[l.property];(l.isUsed?l.isUsed(i):void 0!==i)&&!Ze(t,l.pluginName)&&r(l.pluginName,l.description,je(l.pluginName),l.property,!0)}const s=e.columns;if(s&&s.length>0)for(const l of s)for(const e of i){const i=l[e.property];if((e.isUsed?e.isUsed(i):void 0!==i)&&!Ze(t,e.pluginName)){const t=l.field||"<unknown>";r(e.pluginName,e.description,je(e.pluginName),t)}}if(n.size>0){const e=[];for(const[t,{description:i,importHint:o,fields:r,isConfigProperty:s}]of n)if(s)e.push(`Config uses ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${o}\n plugins: [new ${Ke(t)}Plugin(), ...]`);else{const n=r.slice(0,3).join(", ")+(r.length>3?`, ... (${r.length} total)`:"");e.push(`Column(s) [${n}] use ${i}, but the required plugin is not loaded.\n → Add the plugin to your gridConfig.plugins array:\n ${o}\n plugins: [new ${Ke(t)}Plugin(), ...]`)}throw new Error(`[tbw-grid] Configuration error:\n\n${e.join("\n\n")}\n\nThis validation helps catch misconfigurations early. The properties listed above require their respective plugins to function.`)}}(this.#s,this.#K?.getPlugins()??[]),function(e){const t=[],i=[];for(const o of e){const e=o.constructor.manifest;if(e?.configRules)for(const n of e.configRules){const e=o.config;if(n.check(e)){const e=`[tbw-grid:${Ke(o.name)}Plugin] Configuration warning: ${n.message}`;"error"===n.severity?t.push(e):i.push(e)}}}if(i.length>0&&E())for(const o of i)console.warn(o);if(t.length>0)throw new Error(`[tbw-grid] Configuration error:\n\n${t.join("\n\n")}`)}(this.#K?.getPlugins()??[]),function(e){if(!E())return;const t=new Set(e.map(e=>e.name)),i=/* @__PURE__ */new Set;for(const o of e){const e=o.constructor.manifest;if(e?.incompatibleWith)for(const n of e.incompatibleWith)if(t.has(n.name)){const e=[o.name,n.name].sort().join("↔");if(i.has(e))continue;i.add(e),console.warn(`[tbw-grid] Plugin incompatibility warning:\n\n${Ke(o.name)}Plugin and ${Ke(n.name)}Plugin are both loaded, but they are currently incompatible.\n\n → ${n.reason}\n\n Consider removing one of these plugins to avoid unexpected behavior.`)}}}(this.#K?.getPlugins()??[]),this.#be(),this.#de=[...this._columns]},processColumns:()=>this.#me(),processRows:()=>this.#ve(),renderHeader:()=>le(this),updateTemplate:()=>c(this),renderVirtualWindow:()=>this.refreshVirtualWindow(!0,!0),afterRender:()=>{this.#K?.afterRender(),this._virtualization.enabled&&this._virtualization.totalHeightEl&&queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#Ce(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`});"fixed"!==this.#s.fitMode||this.__didInitialAutoSize||(this.__didInitialAutoSize=!0,s(this)),this._restoreFocusAfterRender&&(this._restoreFocusAfterRender=!1,G(this)),this._virtualization.enabled&&!this.#ye&&this.#_e(),this.#W&&(this.#W=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#Se()})})),this.#re&&this.#ue()},isConnected:()=>this.isConnected&&this.#k}),this.#I.setInitialReadyResolver(()=>this.#R?.()),this.#ie=De(this.#te,{getShadow:()=>this.#P,getShellConfig:()=>this.#s?.shell,getAccordionIcons:()=>({expand:this.#s?.icons?.expand??o.expand,collapse:this.#s?.icons?.collapse??o.collapse}),emit:(e,t)=>this.#Re(e,t),refreshShellHeader:()=>this.refreshShellHeader()}),this.#z=new R({getRows:()=>this.#L,getSortState:()=>this._sortState,setSortState:e=>{this._sortState=e},onConfigChange:()=>{this.#I.requestPhase(ue.FULL,"configChange")},emit:(e,t)=>this.#Re(e,t),clearRowPool:()=>{this._rowPool.length=0,this._bodyEl&&(this._bodyEl.innerHTML=""),this.__rowRenderEpoch++},setup:()=>this.#Ee(),renderHeader:()=>le(this),updateTemplate:()=>c(this),refreshVirtualWindow:()=>this.#I.requestPhase(ue.VIRTUALIZATION,"configManager"),getVirtualization:()=>this._virtualization,setRowHeight:e=>{this._virtualization.rowHeight=e},applyAnimationConfig:e=>this.#xe(e),getShellLightDomTitle:()=>this.#te.lightDomTitle,getShellToolPanels:()=>this.#te.toolPanels,getShellHeaderContents:()=>this.#te.headerContents,getShellToolbarContents:()=>this.#te.toolbarContents,getShellLightDomHeaderContent:()=>this.#te.lightDomHeaderContent,getShellHasToolButtonsContainer:()=>this.#te.hasToolButtonsContainer})}async#pe(){await Ue('@layer tbw-base, tbw-plugins, tbw-theme;\n\n@layer tbw-base{tbw-grid{--tbw-base-icon-size: 1em;--tbw-base-radius: .25em;--tbw-font-size: 1em;--tbw-font-size-sm: .9285em;--tbw-font-size-xs: .7857em;--tbw-font-size-2xs: .7142em;--tbw-spacing-xs: .25em;--tbw-spacing-sm: .375em;--tbw-spacing-md: .5em;--tbw-spacing-lg: .75em;--tbw-spacing-xl: 1em;--tbw-icon-size: var(--tbw-base-icon-size);--tbw-icon-size-sm: .875em;--tbw-checkbox-size: var(--tbw-base-icon-size);--tbw-toggle-size: 1.25em;--tbw-border-radius: var(--tbw-base-radius);--tbw-color-bg: transparent;--tbw-color-panel-bg: light-dark(#eeeeee, #222222);--tbw-color-fg: light-dark(#222222, #eeeeee);--tbw-color-fg-muted: light-dark(#555555, #aaaaaa);--tbw-color-accent: light-dark(#3b82f6, #3b82f6);--tbw-color-accent-fg: light-dark(#ffffff, #000000);--tbw-color-success: light-dark(hsl(122, 39%, 40%), hsl(122, 39%, 49%));--tbw-color-warning: light-dark(hsl(38, 92%, 50%), hsl(38, 92%, 50%));--tbw-color-error: light-dark(hsl(0, 65%, 51%), hsl(0, 65%, 55%));--tbw-color-danger: var(--tbw-color-error);--tbw-color-selection: light-dark(#fff7d6, #333333);--tbw-color-row-alt: var(--tbw-color-bg);--tbw-color-row-hover: light-dark(#f0f6ff, #1c1c1c);--tbw-color-header-bg: color-mix(in hsl, var(--tbw-color-panel-bg) 85%, var(--tbw-color-fg));--tbw-color-header-fg: color-mix(in hsl, var(--tbw-color-fg) 75%, var(--tbw-color-panel-bg));--tbw-color-border: light-dark(#d0d0d4, #454545);--tbw-color-border-strong: light-dark(#777777, #666666);--tbw-color-border-cell: var(--tbw-color-border);--tbw-color-border-header: var(--tbw-color-border);--tbw-color-shadow: light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3));--tbw-font-family: inherit;--tbw-font-size-header: var(--tbw-font-size);--tbw-font-weight-header: bold;--tbw-cell-padding-header: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-cell-padding-v: var(--tbw-spacing-xs);--tbw-cell-padding-h: var(--tbw-spacing-md);--tbw-cell-padding: var(--tbw-cell-padding-v) var(--tbw-cell-padding-h);--tbw-cell-padding-input: var(--tbw-spacing-xs) var(--tbw-spacing-sm);--tbw-row-height: 1.75em;--tbw-header-height: 1.875em;--tbw-cell-white-space: nowrap;--tbw-border-width: 1px;--tbw-border-style: solid;--tbw-border-input: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-strong);--tbw-border-header: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-header);--tbw-row-divider: var(--tbw-border-width) var(--tbw-border-style) var(--tbw-color-border-cell);--tbw-row-hover-outline: 0;--tbw-color-active-row-bg: var(--tbw-color-selection);--tbw-active-row-outline: 0;--tbw-focus-outline-width: 2px;--tbw-focus-outline: var(--tbw-focus-outline-width) var(--tbw-border-style) var(--tbw-color-accent);--tbw-focus-outline-offset: -2px;--tbw-focus-background: rgba(from var(--tbw-color-accent) r g b / 12%);--tbw-range-border-color: var(--tbw-color-accent);--tbw-range-selection-bg: rgba(from var(--tbw-range-border-color) r g b / 12%);--tbw-resize-handle-width: var(--tbw-spacing-sm);--tbw-resize-handle-color: transparent;--tbw-resize-handle-color-hover: var(--tbw-color-accent);--tbw-resize-handle-border-radius: 0;--tbw-resize-indicator-width: 2px;--tbw-resize-indicator-color: var(--tbw-color-accent);--tbw-resize-indicator-opacity: .6;--tbw-transition-duration: .12s;--tbw-transition-ease: ease;--tbw-animation-duration: .2s;--tbw-animation-easing: ease-out;--tbw-animation-enabled: 1;--tbw-row-change-duration: .5s;--tbw-row-insert-duration: .3s;--tbw-row-remove-duration: .2s;--tbw-row-change-color: rgba(from var(--tbw-color-accent) r g b / 25%);--tbw-sort-indicator-color: var(--tbw-color-fg-muted);--tbw-sort-indicator-active-color: var(--tbw-color-accent);--tbw-sort-indicator-display: inline-flex;--tbw-sort-indicator-visibility: visible;--tbw-header-text-transform: none;--tbw-header-letter-spacing: normal;--tbw-color-header-separator: var(--tbw-color-border-cell);--tbw-density-scale: 1;--tbw-shell-header-height: 2.75em;--tbw-shell-header-bg: var(--tbw-color-panel-bg);--tbw-shell-header-border: var(--tbw-color-border);--tbw-shell-title-font-size: var(--tbw-font-size);--tbw-shell-title-font-weight: 600;--tbw-tool-panel-width: 17.5em;--tbw-tool-panel-bg: var(--tbw-color-panel-bg);--tbw-tool-panel-border: var(--tbw-color-border);--tbw-tool-panel-header-height: 2.5em;--tbw-tool-panel-transition: var(--tbw-animation-duration) var(--tbw-animation-easing);--tbw-toolbar-button-size: 2em;--tbw-toolbar-button-gap: var(--tbw-spacing-xs);--tbw-panel-padding: var(--tbw-spacing-lg);--tbw-panel-gap: var(--tbw-spacing-md);--tbw-menu-item-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-menu-item-gap: var(--tbw-spacing-md);--tbw-menu-min-width: 10rem;--tbw-button-padding: var(--tbw-spacing-sm) var(--tbw-spacing-lg);--tbw-button-padding-sm: var(--tbw-spacing-xs) var(--tbw-spacing-md);--tbw-input-height: var(--tbw-row-height);--tbw-input-padding: 0 var(--tbw-spacing-md);--tbw-detail-padding: var(--tbw-spacing-xl);--tbw-detail-max-height: 31.25rem;--tbw-indicator-size: var(--tbw-spacing-sm)}}\n@layer tbw-base{tbw-grid{color-scheme:inherit;position:relative;display:block;width:100%;height:100%;min-height:0;contain:content;font-family:var(--tbw-font-family);font-size:var(--tbw-font-size);font-feature-settings:"tnum","lnum";background:var(--tbw-color-bg);color:var(--tbw-color-fg);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);overflow:clip;outline:none;&,*{box-sizing:border-box}.tbw-grid-root{position:relative;display:flex;flex-direction:column;height:100%;&.has-shell{display:flex;flex-direction:column;height:100%}&:has(.selected){user-select:none}}.rows-body-wrapper{flex:1;min-height:0;display:flex;flex-direction:row;width:100%;min-width:fit-content}.rows-body{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:visible}.rows-container{display:flex;flex-direction:row;flex:1;min-height:0;overflow:visible}.rows-viewport{flex:1;min-width:0;position:relative;display:block;overflow:clip;.rows{position:absolute;top:0;left:0;min-width:100%;will-change:transform;z-index:var(--tbw-z-layer-rows, 1)}}.faux-vscroll{position:sticky;inset-inline-end:0;flex-shrink:0;width:auto;overflow-y:auto;overflow-x:hidden;z-index:var(--tbw-z-layer-header, 30)}.faux-vscroll-spacer{width:1px}&[data-has-focus]{.cell-focus,.row-focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}}.sticky-left,.sticky-right{position:sticky;z-index:25}.sticky-left{box-shadow:1px 0 0 var(--tbw-color-border)}.sticky-right{box-shadow:-1px 0 0 var(--tbw-color-border)}}}\n@layer tbw-base{tbw-grid{.header{display:block;flex-shrink:0;z-index:var(--tbw-z-layer-header, 30);background:var(--tbw-color-header-bg);overflow:visible}.header-group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-color-header-bg);z-index:var(--tbw-z-layer-header, 30)}.header-group-cell{display:flex;align-items:center;justify-content:flex-start;padding:var(--tbw-cell-padding-header, 2px 8px);color:var(--tbw-color-header-group-fg, var(--tbw-color-header-fg));font-weight:var(--tbw-font-weight-header-group, var(--tbw-font-weight-header));justify-content:var(--tbw-align-header-group, var(--tbw-align-header, flex-start));&:not(:last-child){border-right:2px solid var(--tbw-color-border)}}.header-row{display:grid;grid-template-columns:var(--tbw-column-template);color:var(--tbw-color-header-fg);font-size:var(--tbw-font-size-header);min-height:var(--tbw-header-height);border-bottom:var(--tbw-border-header);z-index:var(--tbw-z-layer-header, 30);text-transform:var(--tbw-header-text-transform);letter-spacing:var(--tbw-header-letter-spacing);>.cell{display:flex;align-items:center;gap:4px;padding:var(--tbw-cell-padding-header, 2px 8px);background-color:var(--tbw-color-header-bg);font-weight:var(--tbw-font-weight-header);border-right:1px solid var(--tbw-color-border-cell);overflow:visible;min-width:0;>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:inherit}>span[part~=sort-indicator]{flex-shrink:0;opacity:.6;color:var(--tbw-sort-indicator-color);display:var(--tbw-sort-indicator-display, inline-flex);visibility:var(--tbw-sort-indicator-visibility, visible);transition:opacity .15s,visibility 0s,display 0s allow-discrete;transition-behavior:allow-discrete}&:hover>span[part~=sort-indicator]{display:inline-flex;visibility:visible}&[aria-sort=ascending]>span[part~=sort-indicator],&[aria-sort=descending]>span[part~=sort-indicator]{display:inline-flex;visibility:visible;opacity:1;color:var(--tbw-sort-indicator-active-color)}&:last-child{border-right:0;.resize-handle{right:0;width:calc(var(--tbw-resize-handle-width) / 2)}}&.grouped.group-end:not(:last-child){border-right:2px solid var(--tbw-color-border)}&.resizable{position:relative}&.sticky-left,&.sticky-right{background:var(--tbw-color-header-bg);z-index:35}}}.sortable{cursor:pointer;user-select:none}.resize-handle{position:absolute;top:0;right:calc(var(--tbw-resize-handle-width) / -2);width:var(--tbw-resize-handle-width);height:100%;cursor:e-resize;user-select:none;touch-action:none;z-index:20;background:var(--tbw-resize-handle-color);transition:background .12s ease;border-radius:var(--tbw-resize-handle-border-radius);&:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);width:var(--tbw-resize-indicator-width, 2px);height:0;background:var(--tbw-resize-indicator-color, var(--tbw-color-accent));opacity:0;pointer-events:none;transition:opacity .12s ease,height 0s .12s;z-index:1000}&:hover{background:var(--tbw-resize-handle-color-hover);&:after{height:100vh;opacity:var(--tbw-resize-indicator-opacity, .6);transition:opacity .12s ease,height 0s}}}}}\n@layer tbw-base{tbw-grid{.data-grid-row{display:grid;grid-template-columns:var(--tbw-column-template);contain:layout style;&:nth-child(2n){background:var(--tbw-color-row-alt)}&:hover{background:var(--tbw-color-row-hover)}>.cell{display:block;padding:var(--tbw-cell-padding, 2px 8px);border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height);align-content:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0;white-space:var(--tbw-cell-white-space, nowrap);text-overflow:ellipsis;>*{overflow:hidden;text-overflow:ellipsis;white-space:inherit;min-width:0}&:last-child{border-right:0}&[data-type=boolean]{text-align:center;input[type=checkbox]{margin:0;width:var(--tbw-checkbox-size);height:var(--tbw-checkbox-size);vertical-align:middle}}&.selected:focus-visible,&:focus-visible:not(.cell-focus){outline:none}&.sticky-left,&.sticky-right{background:var(--tbw-color-panel-bg)}}}.selecting .data-grid-row>.cell{user-select:none}}}\n@layer tbw-base{tbw-grid{.tbw-shell-header{display:flex;align-items:center;gap:8px;min-height:var(--tbw-shell-header-height);padding:0 8px;background:var(--tbw-shell-header-bg);border-bottom:1px solid var(--tbw-shell-header-border);flex-shrink:0}.tbw-shell-title{font-size:var(--tbw-shell-title-font-size);font-weight:var(--tbw-shell-title-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-shell-content{flex:1;display:flex;align-items:center;gap:12px;min-width:0;overflow:hidden}.tbw-shell-toolbar{display:flex;align-items:center;gap:var(--tbw-toolbar-button-gap);flex-shrink:0}.tbw-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toolbar-button-size);height:var(--tbw-toolbar-button-size);padding:0;border:1px solid transparent;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg);cursor:pointer;font-size:16px;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease),border-color var(--tbw-transition-duration) var(--tbw-transition-ease);&:hover{background:var(--tbw-color-row-hover)}&:focus-visible{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}&.active{background:var(--tbw-focus-background);border-color:var(--tbw-color-accent)}&:disabled{opacity:.5;cursor:not-allowed}}.tbw-toolbar-separator{width:1px;height:20px;background:var(--tbw-color-border);margin:0 4px}.tbw-shell-body{position:relative;display:flex;flex:1;min-height:0;overflow:visible}.tbw-grid-content{flex:1;min-width:0;min-height:0;display:flex;flex-direction:row;overflow:hidden}.tbw-scroll-area{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow-x:auto;overflow-y:hidden;overflow-anchor:none}}}\n@layer tbw-base{tbw-grid{.tbw-tool-panel{position:absolute;top:0;bottom:0;right:0;width:0;overflow:hidden;background:var(--tbw-tool-panel-bg);border-left:1px solid var(--tbw-tool-panel-border);transition:width var(--tbw-tool-panel-transition);display:flex;flex-direction:column;z-index:30;box-shadow:-2px 0 8px var(--tbw-color-shadow);&[data-position=left]{right:auto;left:0;border-left:none;border-right:1px solid var(--tbw-tool-panel-border);box-shadow:2px 0 8px var(--tbw-color-shadow)}&.open{width:var(--tbw-tool-panel-width)}}.tbw-tool-panel-resize{position:absolute;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background var(--tbw-transition-duration) var(--tbw-transition-ease);&[data-handle-position=left]{left:0}&[data-handle-position=right]{right:0}&:hover,&.resizing{background:var(--tbw-color-accent)}}.tbw-tool-panel-header{display:flex;align-items:center;justify-content:space-between;min-height:var(--tbw-tool-panel-header-height);padding:0 12px;border-bottom:1px solid var(--tbw-tool-panel-border);flex-shrink:0}.tbw-tool-panel-title{font-weight:600;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tbw-tool-panel-close{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:none;border-radius:var(--tbw-border-radius);background:transparent;color:var(--tbw-color-fg-muted);cursor:pointer;font-size:14px;&:hover{background:var(--tbw-color-row-hover);color:var(--tbw-color-fg)}}.tbw-tool-panel-content{flex:1;overflow:auto}.tbw-accordion{display:flex;flex-direction:column;gap:0}.tbw-accordion-section{border-bottom:1px solid var(--tbw-tool-panel-border);&:last-child{border-bottom:none}&.single .tbw-accordion-header{cursor:default;&:hover{background:transparent}}&.expanded{.tbw-accordion-chevron{transform:rotate(90deg)}.tbw-accordion-content{display:block}}}.tbw-accordion-header{display:flex;align-items:center;gap:8px;width:100%;padding:10px 12px;border:none;background:transparent;color:var(--tbw-color-fg);font-size:13px;font-weight:600;text-align:start;cursor:pointer;user-select:none;&:hover{background:var(--tbw-color-row-hover)}}.tbw-accordion-chevron{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:10px;color:var(--tbw-color-fg-muted);transition:transform .15s ease;flex-shrink:0}.tbw-accordion-icon{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;font-size:14px;flex-shrink:0}.tbw-accordion-title{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tbw-accordion-content{display:none}}}\n@layer tbw-base{.tbw-loading-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:1000;pointer-events:all;animation:tbw-fade-in .15s ease-out}.tbw-spinner{--tbw-spinner-size: 48px;--tbw-spinner-border-width: 3px;--tbw-spinner-color: var(--tbw-color-accent);--tbw-spinner-track-color: var(--tbw-color-border);width:var(--tbw-spinner-size);height:var(--tbw-spinner-size);border:var(--tbw-spinner-border-width) solid var(--tbw-spinner-track-color);border-top-color:var(--tbw-spinner-color);border-radius:50%;animation:tbw-spin .8s linear infinite}.tbw-spinner--large{--tbw-spinner-size: min(48px, calc(100% - 16px) )}.tbw-spinner--small{--tbw-spinner-size: calc(var(--tbw-row-height, 28px) * .6);--tbw-spinner-border-width: 2px}.data-grid-row.tbw-row-loading{position:relative;pointer-events:none}.tbw-row-loading-overlay{position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out;pointer-events:none;display:flex;align-items:center}.tbw-row-loading-spinner{--_spinner-size: calc(var(--tbw-row-height, 28px) * .6);margin-left:var(--tbw-spacing-md);width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite}.cell.tbw-cell-loading{position:relative;pointer-events:none;&:before{content:"";position:absolute;inset:0;background:light-dark(rgba(255,255,255,.7),rgba(0,0,0,.5));z-index:26;animation:tbw-fade-in .15s ease-out}&:after{--_spinner-size: calc(var(--tbw-row-height, 28px) * .5);content:"";position:absolute;left:var(--tbw-spacing-sm);top:0;bottom:0;margin:auto 0;width:var(--_spinner-size);height:var(--_spinner-size);border:2px solid var(--tbw-spinner-track-color, var(--tbw-color-border));border-top-color:var(--tbw-spinner-color, var(--tbw-color-accent));border-radius:50%;animation:tbw-spin .8s linear infinite;z-index:27}}}\n@layer tbw-base{tbw-grid{.tbw-expanding{animation:tbw-expand var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}.tbw-collapsing{animation:tbw-collapse var(--tbw-animation-duration) var(--tbw-animation-easing) forwards;overflow:hidden}&[data-animation-mode=off]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}tbw-grid .data-grid-row[data-animating=change]{animation:tbw-row-change var(--tbw-row-change-duration) ease-out}tbw-grid .data-grid-row[data-animating=insert]{animation:tbw-row-insert var(--tbw-row-insert-duration) ease-out;will-change:max-height,opacity}tbw-grid .data-grid-row[data-animating=remove]{animation:tbw-row-remove var(--tbw-row-remove-duration) ease-out forwards;will-change:max-height,opacity,transform;pointer-events:none}}@keyframes tbw-expand{0%{opacity:0;max-height:0;transform:translateY(-8px)}to{opacity:1;max-height:500px;transform:translateY(0)}}@keyframes tbw-collapse{0%{opacity:1;max-height:500px;transform:translateY(0)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-row-change{0%{background-color:transparent}20%{background-color:var(--tbw-row-change-color)}to{background-color:transparent}}@keyframes tbw-row-insert{0%{opacity:0;max-height:0;overflow:hidden}to{opacity:1;max-height:var(--tbw-row-height, 28px);overflow:hidden}}@keyframes tbw-row-remove{0%{opacity:1;transform:translateY(0);max-height:var(--tbw-row-height, 28px)}to{opacity:0;max-height:0;transform:translateY(-8px)}}@keyframes tbw-spin{to{transform:rotate(360deg)}}@keyframes tbw-fade-in{0%{opacity:0}to{opacity:1}}\n@layer tbw-base{@media(forced-colors:active){tbw-grid{--tbw-color-border: CanvasText;--tbw-color-border-strong: CanvasText;--tbw-color-border-cell: CanvasText;--tbw-color-border-header: CanvasText;--tbw-color-fg: CanvasText;--tbw-color-bg: Canvas;--tbw-color-panel-bg: Canvas;--tbw-color-header-bg: Canvas;--tbw-color-header-fg: CanvasText;--tbw-color-accent: Highlight;--tbw-color-accent-fg: HighlightText;--tbw-color-selection: Highlight;--tbw-color-row-hover: Highlight;--tbw-focus-outline: 2px solid Highlight;--tbw-range-border-color: Highlight;.cell:focus,.cell.active-cell{outline:2px solid Highlight!important;outline-offset:-2px}.data-grid-row[aria-selected=true]{background:Highlight!important;color:HighlightText!important}}}@media(prefers-reduced-motion:reduce){tbw-grid[data-animation-mode=reduced-motion]{--tbw-animation-enabled: 0;--tbw-animation-duration: 0ms;.data-grid-row[data-animating]{animation:none}}}}\n')}getPlugin(e){return this.#K?.getPlugin(e)}getPluginByName(e){return this.#K?.getPluginByName(e)}requestRender(){this.#I.requestPhase(ue.ROWS,"plugin:requestRender")}requestColumnsRender(){this.#I.requestPhase(ue.COLUMNS,"plugin:requestColumnsRender")}requestRenderWithFocus(){this._restoreFocusAfterRender=!0,this.#I.requestPhase(ue.ROWS,"plugin:requestRenderWithFocus")}updateTemplate(){c(this)}requestAfterRender(){this.#I.requestPhase(ue.STYLE,"plugin:requestAfterRender")}#Ae(){this.#K=new rt(this);const e=this.#s?.plugins,t=Array.isArray(e)?e:[];this.#K.attachAll(t)}#Te(){!function(e){let t=!1;for(const{name:i,styles:o}of e)We.has(i)||(We.set(i,o),t=!0);t&&Fe()}(this.#K?.getPluginStyles()??[])}#we(){const e=this.#s?.plugins,t=Array.isArray(e)?e:[];if(this.#Z===t)return;if(this.#Z&&this.#Z.length===t.length&&this.#Z.every((e,i)=>e===t[i]))return void(this.#Z=t);this.#K&&this.#K.detachAll();for(const o of this.#te.toolPanels.keys()){const e=this.#te.lightDomToolPanelIds.has(o),t=this.#te.apiToolPanelIds.has(o);if(!e&&!t){const e=this.#te.panelCleanups.get(o);e&&(e(),this.#te.panelCleanups.delete(o)),this.#te.toolPanels.delete(o)}}for(const o of this.#te.headerContents.keys()){const e=this.#te.headerContentCleanups.get(o);e&&(e(),this.#te.headerContentCleanups.delete(o)),this.#te.headerContents.delete(o)}this.#Ae(),this.#Te(),this.#Z=t,this.#He(),this.#Pe();const i=this.#$;if(this.#$=this.#K?.getAll().some(e=>e.onScroll)??!1,!i&&this.#$){const e=this.#P.querySelector(".tbw-grid-content")??this.#P.querySelector(".tbw-grid-root");this.#Me(e)}}#Le(){this.#K?.detachAll()}#Pe(){if(!this.#K)return;const e=this.#K.getToolPanels();for(const{panel:i}of e)this.#te.toolPanels.has(i.id)||this.#te.toolPanels.set(i.id,i);const t=this.#K.getHeaderContents();for(const{content:i}of t)this.#te.headerContents.has(i.id)||this.#te.headerContents.set(i.id,i)}#ze(){const e=st.getAdapters();if(0===e.length&&!this.__frameworkAdapter)return;const t=this.__frameworkAdapter;return i=>{if(t?.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}for(const t of e)if(t.createToolPanelRenderer){const e=t.createToolPanelRenderer(i);if(e)return e}}}connectedCallback(){this.hasAttribute("tabindex")||(this.tabIndex=0),this.hasAttribute("version")||this.setAttribute("version",st.version),this.id||(this.id="tbw-grid-"+ ++st.#H),this._rows=Array.isArray(this.#L)?[...this.#L]:[],this.#B&&(this.#B.abort(),this.#Q=!1),this.#B=new AbortController,this.#Y&&(ce(this.#Y),this.#Y=void 0),this.#ke(),this.#z.parseLightDomColumns(this),this.#z.merge(),this.#Ae();const e=this.#s?.plugins;var t,i;this.#Z=Array.isArray(e)?e:[],this.#Pe(),this.#M||(this.#Oe(),this.#Te(),this.#M=!0),this.#De(),this.#Y=(t=()=>{this.#Ie()},i={timeout:100},ae?requestIdleCallback(t,i):window.setTimeout(()=>{const e=Date.now();t({didTimeout:!1,timeRemaining:()=>Math.max(0,50-(Date.now()-e))})},1))}disconnectedCallback(){this.#Y&&(ce(this.#Y),this.#Y=void 0),this.#F&&(clearTimeout(this.#F),this.#F=0),this.#Le(),function(e){for(const t of e.headerContentCleanups.values())t();e.headerContentCleanups.clear();for(const t of e.panelCleanups.values())t();e.panelCleanups.clear();for(const t of e.toolbarContentCleanups.values())t();e.toolbarContentCleanups.clear();for(const t of e.toolbarContents.values())t.onDestroy?.();if(e.isPanelOpen)for(const t of e.expandedSections){const i=e.toolPanels.get(t);i?.onClose?.()}e.isPanelOpen=!1,e.expandedSections.clear(),e.toolPanels.clear(),e.headerContents.clear(),e.toolbarContents.clear(),e.lightDomHeaderContent=[],e.lightDomToolPanelIds.clear(),e.lightDomToolbarContentIds.clear(),e.lightDomContentMoved=!1}(this.#te),this.#ie.setInitialized(!1),this.#oe?.(),this.#oe=void 0,this.#ne?.(),this.#ne=void 0,Ve(this.#V),this.#B&&(this.#B.abort(),this.#B=void 0),this.#J?.abort(),this.#J=void 0,this.#Q=!1,this._resizeController&&this._resizeController.dispose(),this.#G&&(this.#G.disconnect(),this.#G=void 0),this.#X&&(this.#X.disconnect(),this.#X=void 0,this.#ye=!1),F(this),this.#Ne.clear(),this.#Z=void 0;for(const e of this._rowPool)e.remove();this._rowPool.length=0,this.__rowsBodyEl=null,this.#k=!1}attributeChangedCallback(e,t,i){if("loading"===e){const e=null!==i&&"false"!==i;return void(this.loading!==e&&(this.loading=e))}if(t!==i&&i&&"null"!==i&&"undefined"!==i)if("rows"===e||"columns"===e||"grid-config"===e)try{const t=JSON.parse(i);"rows"===e?this.rows=t:"columns"===e?this.columns=t:"grid-config"===e&&(this.gridConfig=t)}catch{console.warn(`[tbw-grid] Invalid JSON for '${e}' attribute:`,i)}else"fit-mode"===e&&(this.fitMode=i)}#De(){const e=this.#P.querySelector(".tbw-grid-content")??this.#P.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#ie.isInitialized){Le(this.#P,this.#te),Me(this.#P,this.#s?.shell,this.#te);const e=this.#s?.shell?.toolPanel?.defaultOpen;e&&this.#te.toolPanels.has(e)&&(this.openToolPanel(),this.#te.expandedSections.add(e))}if(this.setAttribute("data-upgraded",""),this.#k=!0,this._resizeController=fe(this),this.#Ee(),this.#Me(e),this.#Q)return;this.#Q=!0;const t=this.disconnectSignal;K(this,this,this.#P,t),this.#He(),queueMicrotask(()=>this.#qe()),this.#I.requestPhase(ue.FULL,"afterConnect")}#He(){const e=this.#s.rowHeight,t=this.#K.hasRowHeightPlugin();"function"==typeof e||t?this._virtualization.variableHeights||(this._virtualization.variableHeights=!0,this._virtualization.rowHeight="number"==typeof e&&e>0?e:this._virtualization.rowHeight||28,this.#$e(),"function"!=typeof e&&(this.#W=!0)):!t&&"function"!=typeof e&&this._virtualization.variableHeights?(this._virtualization.variableHeights=!1,this._virtualization.positionCache=null):"number"==typeof e&&e>0?(this._virtualization.rowHeight=e,this._virtualization.variableHeights=!1):requestAnimationFrame(()=>this.#We())}#We(){if(this.#K.hasExtraHeight())return;const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const o=e.getBoundingClientRect(),n=Math.max(o.height,i);n>0&&Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n,this.#I.requestPhase(ue.VIRTUALIZATION,"measureRowHeight"))}#Se(){const e=this._bodyEl?.querySelector(".data-grid-row");if(!e)return;const t=e.querySelectorAll(".cell");let i=0;t.forEach(e=>{const t=e.offsetHeight;t>i&&(i=t)});const o=e.getBoundingClientRect(),n=Math.max(o.height,i);if(n>0){if(Math.abs(n-this._virtualization.rowHeight)>1&&(this._virtualization.rowHeight=n),this.#$e(),this._virtualization.totalHeightEl){const e=this.#Ce(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}}#Me(e){this.#J?.abort(),this.#J=new AbortController;const t=this.#J.signal,i=e?.querySelector(".faux-vscroll"),o=e?.querySelector(".rows");if(this._virtualization.container=i??this,this.#$=this.#K?.getAll().some(e=>e.onScroll)??!1,i&&o){i.addEventListener("scroll",()=>{if(!this._virtualization.enabled&&!this.#$)return;const e=i.scrollTop,t=this._virtualization.rowHeight;if(this._rows.length<=this._virtualization.bypassThreshold)o.style.transform=`translateY(${-e}px)`;else{const i=this._virtualization.positionCache;let n,r;if(this._virtualization.variableHeights&&i&&i.length>0){n=tt(i,e),-1===n&&(n=0);const o=n-n%2;r=i[o]?.offset??o*t}else{n=Math.floor(e/t);r=(n-n%2)*t}const s=-(e-r);o.style.transform=`translateY(${s}px)`}this.#q=e,this.#N||(this.#N=requestAnimationFrame(()=>{this.#N=0,null!==this.#q&&(this.#Fe(this.#q),this.#q=null)}))},{passive:!0,signal:t});const e=this.#P.querySelector(".tbw-scroll-area");this.#ee=e,this._virtualization.scrollAreaEl=e,e&&this.#$&&e.addEventListener("scroll",()=>{const t=this.#j;t.scrollTop=i.scrollTop,t.scrollLeft=e.scrollLeft,t.scrollHeight=i.scrollHeight,t.scrollWidth=e.scrollWidth,t.clientHeight=i.clientHeight,t.clientWidth=e.clientWidth,this.#K?.onScroll(t)},{passive:!0,signal:t});const n=this.#P.querySelector(".tbw-grid-content"),r=this.#ee;n&&(n.addEventListener("wheel",e=>{const t=e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY);if(t&&r){const t=e.shiftKey?e.deltaY:e.deltaX,{scrollLeft:i,scrollWidth:o,clientWidth:n}=r;(t>0&&i<o-n||t<0&&i>0)&&(e.preventDefault(),r.scrollLeft+=t)}else if(!t){const{scrollTop:t,scrollHeight:o,clientHeight:n}=i;(e.deltaY>0&&t<o-n||e.deltaY<0&&t>0)&&(e.preventDefault(),i.scrollTop+=e.deltaY)}},{passive:!1,signal:t}),Ge(n,this.#V,{fauxScrollbar:i,scrollArea:r},t))}var n,r,s;this._bodyEl&&(n=this,r=this._bodyEl,s=t,r.addEventListener("mousedown",e=>{const t=e.target.closest(".cell[data-col]");t&&(t.classList.contains("editing")||(e.preventDefault(),Y(n,t)))},{signal:s}),r.addEventListener("click",e=>{const t=e.target.closest(".data-grid-row");if(t&&B(n,e,t),!document.activeElement?.closest(".cell.editing")){const t=e.target.closest("tbw-grid");t&&t.focus({preventScroll:!0})}},{signal:s}),r.addEventListener("dblclick",e=>{const t=e.target.closest(".data-grid-row");t&&B(n,e,t)},{signal:s})),this.#G?.disconnect(),this._virtualization.viewportEl&&(this.#G=new ResizeObserver(()=>{this.#Ue(),this.#I.requestPhase(ue.VIRTUALIZATION,"resize-observer")}),this.#G.observe(this._virtualization.viewportEl)),this.#P.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:t}),this.#P.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&(this.#P.contains(t)||this.#Ve(t))||delete this.dataset.hasFocus},{signal:t})}#ye=!1;#_e(){if(this.#ye)return;const e=this._bodyEl?.querySelector(".data-grid-row");e&&(this.#ye=!0,this.#X?.disconnect(),this.#X=new ResizeObserver(()=>{this.#We()}),this.#X.observe(e))}addEventListener(e,t,i){super.addEventListener(e,t,i)}removeEventListener(e,t,i){super.removeEventListener(e,t,i)}#Re(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}#qe(){const e=this._bodyEl?.querySelectorAll(".data-grid-row");e?.forEach((e,t)=>{const i=t===this._focusRow;e.setAttribute("aria-selected",String(i)),e.querySelectorAll(".cell").forEach((e,t)=>{e.setAttribute("aria-selected",String(i&&t===this._focusCol))})})}#he(e){this.#D[e]=!0,this.#O||(this.#O=!0,queueMicrotask(()=>this.#Be()))}#Be(){if(!this.#O||!this.#k)return void(this.#O=!1);const e=this.#D;if(this.#O=!1,this.#D={rows:!1,columns:!1,gridConfig:!1,fitMode:!1},e.gridConfig)return this.#Ge(),void(e.rows&&this.#Xe());e.columns&&this.#Ye(),e.rows&&this.#Xe(),e.fitMode&&this.#je()}#Xe(){this._rows=Array.isArray(this.#L)?[...this.#L]:[],this.#Ke(),this.#I.requestPhase(ue.ROWS,"applyRowsUpdate")}#Ke(){this.#ce.clear();const e=this.#s.getRowId;this._rows.forEach((t,i)=>{const o=this.#Ze(t,e);void 0!==o&&this.#ce.set(o,{row:t,index:i})})}#Ze(e,t){if(t)return t(e);const i=e;return"id"in i&&null!=i.id?String(i.id):"_id"in i&&null!=i._id?String(i._id):void 0}#Qe(e,t){const i=this.#Ze(e,t);if(void 0===i)throw new Error('[tbw-grid] Cannot determine row ID. Configure getRowId in gridConfig or ensure rows have an "id" property.');return i}#Ye(){F(this),this.#z.merge(),this.#Ee()}#je(){this.#z.merge();"fixed"===this.#s.fitMode?(this.__didInitialAutoSize=!1,s(this)):(this._columns.forEach(e=>{!e.__userResized&&e.__autoSized&&delete e.width}),c(this))}#Ge(){Te(this,this.#te),He(this,this.#te);const e=!!this.#P.querySelector(".has-shell"),t=!!this.#P.querySelector(".tbw-tool-panel"),i=this.#P.querySelectorAll(".tbw-accordion-section").length;this.#z.parseLightDomColumns(this),this.#z.merge(),this.#we(),Pe(this,this.#te,this.#ze()),this.#z.markSourcesChanged(),this.#z.merge();const o=Ae(this.#s?.shell),n=(this.#s?.shell?.toolPanels?.length??0)>0,r=this.#s?.shell?.toolPanels?.length??0;if(e!==o||!t&&n||t&&r!==i)return Oe(this.#te),this.#Oe(),this.#Te(),this.#De(),void this.#Ke();e&&this.#Je(),this.#Ke(),this.#I.requestPhase(ue.COLUMNS,"applyGridConfigUpdate")}#Je(){const e=this.#P.querySelector(".tbw-shell-header");if(!e)return;const t=this.#s.shell?.header?.title??this.#te.lightDomTitle;let i=e.querySelector(".tbw-shell-title");t?(i||(i=document.createElement("h2"),i.className="tbw-shell-title",i.setAttribute("part","shell-title"),e.insertBefore(i,e.firstChild)),i.textContent=t):i&&i.remove()}#me(){if(this.__rowRenderEpoch++,this.#K){const e=this.#de.length>0?this.#de:this._columns,t=e.filter(e=>!e.hidden),i=e.filter(e=>e.hidden),o=this.#K.processColumns([...t]);if(o!==t){const n=new Set(o.map(e=>e.field));!t.some(e=>n.has(e.field))&&o.length>0?this._columns=[...o,...i]:this._columns=this.#et(e,o,i)}else this._columns=[...e]}}#et(e,t,i){if(0===i.length)return t;const o=/* @__PURE__ */new Map;for(const l of t)o.set(l.field,l);const n=new Set(e.map(e=>e.field)),r=[];for(const l of t)n.has(l.field)||r.push(l);const s=[];for(const l of e){const e=o.get(l.field);e?s.push(e):l.hidden&&s.push(l)}return s.push(...r),s}#ve(){F(this);const e=function(e,t){if(!e._sortState)return t;e.__originalOrder=[...t];const i=(e.effectiveConfig?.sortHandler??Q)(t,e._sortState,e._columns);return i&&"function"==typeof i.then?t:i}(this,Array.isArray(this.#L)?[...this.#L]:[]),t=this.#K?.processRows(e)??e;this._rows=t,this.#Ke(),this._virtualization.variableHeights&&this.#$e()}#xe(e){const i={...t,...e.animation},o=i.mode??"reduced-motion";let n=1;!1===o||"off"===o?n=0:!0!==o&&"on"!==o||(n=1),this.style.setProperty("--tbw-animation-duration",`${i.duration}ms`),this.style.setProperty("--tbw-animation-easing",i.easing??"ease-out"),this.style.setProperty("--tbw-animation-enabled",String(n)),this.dataset.animationMode="boolean"==typeof o?o?"on":"off":o}#tt(e,t,i=this.__rowRenderEpoch){if(this.#U||(this.#U=(e,t,i)=>this.#K?.renderRow(e,t,i)??!1),function(e,t,i,o,n){const r=Math.max(0,i-t),s=e._bodyEl,l=e._visibleColumns,a=l.length;let c=e.__cachedHeaderRowCount;for(void 0===c&&(c=e.querySelector(".header-group-row")?2:1,e.__cachedHeaderRowCount=c);e._rowPool.length<r;){const t=W();e._rowPool.push(t)}if(e._rowPool.length>r){for(let t=r;t<e._rowPool.length;t++){const i=e._rowPool[t];i.parentNode===s&&i.remove()}e._rowPool.length=r}const d=n&&!1!==e.__hasRenderRowPlugins,h=e._hasAfterRowRenderHook?.()??!1;for(let g=0;g<r;g++){const i=t+g,r=e._rows[i],f=e._rowPool[g];if(f.setAttribute("aria-rowindex",String(i+c+1)),d&&n(r,f,i)){f.__epoch=o,f.__rowDataRef=r,f.parentNode!==s&&s.appendChild(f);continue}const p=f.__epoch,w=f.__rowDataRef;let b=f.children.length;b>a&&f.lastElementChild?.classList.contains("tbw-row-loading-overlay")&&b--;const m=p===o&&b===a,v=w!==r,C=!!e._isGridEditMode;let y=!1;if(m&&v)for(let e=0;e<a;e++)if(l[e].externalView&&!f.querySelector(`.cell[data-col="${e}"] [data-external-view]`)){y=!0;break}if(!m||y){const t=D(f),n=C||e._activeEditRows===i;t&&!n?(f.__isCustomRow&&(f.className="data-grid-row",f.setAttribute("role","row"),f.__isCustomRow=!1),I(f),V(e,f,r,i),f.__epoch=o,f.__rowDataRef=r):t&&n?(U(e,f,r,i),f.__rowDataRef=r):(f.__isCustomRow&&(f.className="data-grid-row",f.setAttribute("role","row"),f.__isCustomRow=!1),V(e,f,r,i),f.__epoch=o,f.__rowDataRef=r)}else if(v){const t=D(f),n=C||e._activeEditRows===i;t&&!n?(I(f),V(e,f,r,i),f.__epoch=o,f.__rowDataRef=r):(U(e,f,r,i),f.__rowDataRef=r)}else{const t=D(f),n=C||e._activeEditRows===i;t&&!n?(I(f),V(e,f,r,i),f.__epoch=o,f.__rowDataRef=r):U(e,f,r,i)}let _=!1;const S=e.changedRowIds;if(S&&S.length>0)try{const t=e.getRowId?.(r);t&&(_=S.includes(t))}catch{}_!==f.classList.contains("changed")&&f.classList.toggle("changed",_);const R=e.effectiveConfig?.rowClass;if(R){const e=f.getAttribute("data-dynamic-classes");e&&e.split(" ").forEach(e=>e&&f.classList.remove(e));try{const e=R(r);if(e&&e.length>0){const t=e.filter(e=>e&&"string"==typeof e);t.forEach(e=>f.classList.add(e)),f.setAttribute("data-dynamic-classes",t.join(" "))}else f.removeAttribute("data-dynamic-classes")}catch(u){console.warn("[tbw-grid] rowClass callback error:",u),f.removeAttribute("data-dynamic-classes")}}h&&e._afterRowRender?.({row:r,rowIndex:i,rowElement:f}),f.parentNode!==s&&s.appendChild(f)}}(this,e,t,i,this.#U),this.#se.size>0)for(const o of this.#se)this.#ge(o,!0)}#it={rowCount:-1,colCount:-1,ariaLabel:void 0,ariaDescribedBy:void 0};#ot(e,t){!function(e,t,i,o,n){if(o===e.rowCount&&n===e.colCount)return!1;const r=e.rowCount;e.rowCount=o,e.colCount=n,t&&(t.setAttribute("aria-rowcount",String(o)),t.setAttribute("aria-colcount",String(n))),o!==r&&i&&(o>0?i.setAttribute("role","rowgroup"):i.removeAttribute("role"))}(this.#it,this.__rowsBodyEl,this._bodyEl,e,t)}#be(){!function(e,t,i,o){if(!t)return!1;let n=!1;const r=function(e,t){const i=e?.gridAriaLabel;return i||(e?.shell?.header?.title??t?.lightDomTitle??void 0)}(i,o);r!==e.ariaLabel&&(e.ariaLabel=r,r?t.setAttribute("aria-label",r):t.removeAttribute("aria-label"),n=!0);const s=i?.gridAriaDescribedBy;s!==e.ariaDescribedBy&&(e.ariaDescribedBy=s,s?t.setAttribute("aria-describedby",s):t.removeAttribute("aria-describedby"),n=!0)}(this.#it,this.__rowsBodyEl,this.#s,this.#te)}#ue(){const e=this.querySelector(".tbw-grid-root");var t;e&&(this.#re?(this.#ae||(this.#ae=function(e){const t=document.createElement("div");return t.className="tbw-loading-overlay",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.appendChild(de("large",e)),t}(this.#s?.loadingRenderer)),function(e,t){e.appendChild(t)}(e,this.#ae)):(t=this.#ae,t?.remove()))}#ge(e,t){const i=this.#ce.get(e);if(!i)return;const o=this.findRenderedRowElement?.(i.index);o&&function(e,t){if(t){if(e.classList.add("tbw-row-loading"),e.setAttribute("aria-busy","true"),!e.querySelector(".tbw-row-loading-overlay")){const t=document.createElement("div");t.className="tbw-row-loading-overlay",t.setAttribute("aria-hidden","true");const i=document.createElement("div");i.className="tbw-row-loading-spinner",t.appendChild(i),e.appendChild(t)}}else e.classList.remove("tbw-row-loading"),e.removeAttribute("aria-busy"),e.querySelector(".tbw-row-loading-overlay")?.remove()}(o,t)}#fe(e,t,i){const o=this.#ce.get(e);if(!o)return;const n=this.findRenderedRowElement?.(o.index);if(!n)return;const r=this._visibleColumns.findIndex(e=>e.field===t);if(r<0)return;const s=n.children[r];s&&function(e,t){t?(e.classList.add("tbw-cell-loading"),e.setAttribute("aria-busy","true")):(e.classList.remove("tbw-cell-loading"),e.removeAttribute("aria-busy"))}(s,i)}#Ee(){if(this.isConnected&&this._headerRowEl&&this._bodyEl){if(this.#z.parseLightDomColumns(this),this.#h){const e=this.#h;this.#h=void 0,this.#z.merge();const t=this.#K?.getAll()??[];this.#z.applyState(e,t)}this._bodyEl&&(this._bodyEl.style.display="",this._bodyEl.style.gridTemplateColumns=""),this.#I.requestPhase(ue.FULL,"setup")}}#Fe(e){let t=0,i=0,o=0,n=0,r=0;if(this.#$){const e=this._virtualization.container,s=this.#ee;t=s?.scrollLeft??0,i=e?.scrollHeight??0,o=s?.scrollWidth??0,n=e?.clientHeight??0,r=s?.clientWidth??0}if(this.refreshVirtualWindow(!1)&&this.#K?.onScrollRender(),this._virtualization.variableHeights&&(this.#F&&clearTimeout(this.#F),this.#F=window.setTimeout(()=>{this.#F=0,this.#nt(this._virtualization.start,this._virtualization.end)},100)),this.#$){const s=this.#j;s.scrollTop=e,s.scrollLeft=t,s.scrollHeight=i,s.scrollWidth=o,s.clientHeight=n,s.clientWidth=r,this.#K?.onScroll(s)}}findHeaderRow(){return this.#P.querySelector(".header-row")}findRenderedRowElement(e){return Array.from(this._bodyEl.querySelectorAll(".data-grid-row")).find(t=>{const i=t.querySelector(".cell[data-row]");return i&&Number(i.getAttribute("data-row"))===e})||null}_dispatchCellClick(e,t,i,o){const n=this._rows[t],r=this._visibleColumns[i];if(!n||!r)return!1;const s=r.field,l=n[s],a=new CustomEvent("cell-activate",{cancelable:!0,bubbles:!0,composed:!0,detail:{rowIndex:t,colIndex:i,column:r,field:s,value:l,row:n,cellEl:o,trigger:"pointer",originalEvent:e}});if(this.dispatchEvent(a),a.defaultPrevented)return!0;const c={row:n,rowIndex:t,colIndex:i,column:r,field:s,value:l,cellEl:o,originalEvent:e},d=this.#K?.onCellClick(c)??!1;return this.#Re("cell-click",c),d}_dispatchRowClick(e,t,i,o){if(!i)return!1;const n={rowIndex:t,row:i,rowEl:o,originalEvent:e},r=this.#K?.onRowClick(n)??!1;return this.#Re("row-click",n),r}_dispatchHeaderClick(e,t,i){if(!t)return!1;const o={colIndex:this._columns.indexOf(t),field:t.field,column:t,headerEl:i,originalEvent:e};return this.#K?.onHeaderClick(o)??!1}_dispatchKeyDown(e){return this.#K?.onKeyDown(e)??!1}_getHorizontalScrollOffsets(e,t){return this.#K?.getHorizontalScrollOffsets(e,t)??{left:0,right:0}}queryPlugins(e){return this.#K?.queryPlugins(e)??[]}query(e,t){return this.#K?.queryPlugins({type:e,context:t})??[]}_dispatchCellMouseDown(e){return this.#K?.onCellMouseDown(e)??!1}_dispatchCellMouseMove(e){this.#K?.onCellMouseMove(e)}_dispatchCellMouseUp(e){this.#K?.onCellMouseUp(e)}_afterCellRender(e){this.#K?.afterCellRender(e)}_hasAfterCellRenderHook(){return this.#K?.hasAfterCellRenderHook()??!1}_afterRowRender(e){this.#K?.afterRowRender(e)}_hasAfterRowRenderHook(){return this.#K?.hasAfterRowRenderHook()??!1}async ready(){return this.#S}async forceLayout(){return this.#I.requestPhase(ue.FULL,"forceLayout"),this.#I.whenReady()}async getConfig(){return Object.freeze({...this.#s||{}})}getRowId(e){return this.#Qe(e,this.#s.getRowId)}getRow(e){return this.#ce.get(e)?.row}_getRowEntry(e){return this.#ce.get(e)}updateRow(e,t,i="api"){const o=this.#ce.get(e);if(!o)throw new Error(`[tbw-grid] Row with ID "${e}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:n,index:r}=o,s=[];for(const[l,a]of Object.entries(t)){const e=n[l];e!==a&&(s.push({field:l,oldValue:e,newValue:a}),n[l]=a)}for(const{field:l,oldValue:a,newValue:c}of s)this.#Re("cell-change",{row:n,rowId:e,rowIndex:r,field:l,oldValue:a,newValue:c,changes:t,source:i});s.length>0&&this.#I.requestPhase(ue.ROWS,"updateRow")}updateRows(e,t="api"){let i=!1;for(const{id:o,changes:n}of e){const e=this.#ce.get(o);if(!e)throw new Error(`[tbw-grid] Row with ID "${o}" not found. Ensure the row exists and getRowId is correctly configured.`);const{row:r,index:s}=e;for(const[l,a]of Object.entries(n)){const e=r[l];e!==a&&(i=!0,r[l]=a,this.#Re("cell-change",{row:r,rowId:o,rowIndex:s,field:l,oldValue:e,newValue:a,changes:n,source:t}))}}i&&this.#I.requestPhase(ue.ROWS,"updateRows")}animateRow(e,t){return ve(this,e,t)}animateRows(e,t){return function(e,t,i){return Promise.all(t.map(t=>ve(e,t,i))).then(e=>e.filter(Boolean).length)}(this,e,t)}animateRowById(e,t){return function(e,t,i){const o=e._rows??[],n=e.getRowId;if(!n)return Promise.resolve(!1);const r=o.findIndex(e=>{if(null==e)return!1;try{return n(e)===t}catch{return!1}});return r<0?Promise.resolve(!1):ve(e,r,i)}(this,e,t)}async insertRow(e,t,i=!0){const o=Math.max(0,Math.min(e,this._rows.length));this.#L=[...this.#L,t];const n=[...this._rows];n.splice(o,0,t),this._rows=n,this._sortState&&(this.__originalOrder=[...this.__originalOrder,t]),F(this),this.#Ke(),this.__rowRenderEpoch++;for(const r of this._rowPool)r.__epoch=-1;this.refreshVirtualWindow(!0),i&&(await new Promise(e=>requestAnimationFrame(()=>e())),await this.animateRow(o,"insert"))}async removeRow(e,t=!0){const i=this._rows[e];if(!i)return;t&&await this.animateRow(e,"remove");const o=this._rows.indexOf(i);if(o<0)return i;const n=[...this._rows];n.splice(o,1),this._rows=n;const r=this.#L.indexOf(i);if(r>=0){const e=[...this.#L];e.splice(r,1),this.#L=e}if(this._sortState){const e=this.__originalOrder.indexOf(i);if(e>=0){const t=[...this.__originalOrder];t.splice(e,1),this.__originalOrder=t}}F(this),this.#Ke(),this.__rowRenderEpoch++;for(const s of this._rowPool)s.__epoch=-1;return this.refreshVirtualWindow(!0),t&&requestAnimationFrame(()=>{this.querySelectorAll('[data-animating="remove"]').forEach(e=>{e.removeAttribute("data-animating")})}),i}suspendProcessing(){}setColumnVisible(e,t){const i=this.#z.setColumnVisible(e,t);return i&&this.requestStateChange(),i}toggleColumnVisibility(e){const t=this.#z.toggleColumnVisibility(e);return t&&this.requestStateChange(),t}isColumnVisible(e){return this.#z.isColumnVisible(e)}showAllColumns(){this.#z.showAllColumns(),this.requestStateChange()}getAllColumns(){return this.#z.getAllColumns()}setColumnOrder(e){this.#z.setColumnOrder(e),this.requestStateChange()}getColumnOrder(){return this.#z.getColumnOrder()}getColumnState(){const e=this.#K?.getAll()??[];return this.#z.collectState(e)}set columnState(e){e&&(this.#h=e,this.#z.initialColumnState=e,this.#M&&this.#rt(e))}get columnState(){return this.getColumnState()}#rt(e){const t=this.#K?.getAll()??[];this.#z.applyState(e,t),this.#Ee()}requestStateChange(){const e=this.#K?.getAll()??[];this.#z.requestStateChange(e)}resetColumnState(){this.#h=void 0,this.__originalOrder=[];const e=this.#K?.getAll()??[];this.#z.resetState(e),this.#z.merge(),this.#Ee()}get isToolPanelOpen(){return this.#ie.isPanelOpen}get defaultRowHeight(){return this._virtualization.rowHeight}get expandedToolPanelSections(){return this.#ie.expandedSections}openToolPanel(){this.#ie.openToolPanel()}closeToolPanel(){this.#ie.closeToolPanel()}toggleToolPanel(){this.#ie.toggleToolPanel()}toggleToolPanelSection(e){this.#ie.toggleToolPanelSection(e)}getToolPanels(){return this.#ie.getToolPanels()}registerToolPanel(e){this.#te.apiToolPanelIds.add(e.id),this.#ie.registerToolPanel(e)}unregisterToolPanel(e){this.#te.apiToolPanelIds.delete(e),this.#ie.unregisterToolPanel(e)}getHeaderContents(){return this.#ie.getHeaderContents()}registerHeaderContent(e){this.#ie.registerHeaderContent(e)}unregisterHeaderContent(e){this.#ie.unregisterHeaderContent(e)}getToolbarContents(){return this.#ie.getToolbarContents()}registerToolbarContent(e){this.#ie.registerToolbarContent(e)}unregisterToolbarContent(e){this.#ie.unregisterToolbarContent(e)}#st=!1;refreshShellHeader(){this.#st||(this.#st=!0,queueMicrotask(()=>{this.#st=!1,this.isConnected&&(this.#ke(),this.#z.markSourcesChanged(),this.#z.merge(),Oe(this.#te),this.#Oe(),this.#Te(),this.#lt())}))}#lt(){const e=this.#P.querySelector(".tbw-grid-content")??this.#P.querySelector(".tbw-grid-root");if(this._headerRowEl=e?.querySelector(".header-row"),this._virtualization.totalHeightEl=e?.querySelector(".faux-vscroll-spacer"),this._virtualization.viewportEl=e?.querySelector(".rows-viewport"),this._bodyEl=e?.querySelector(".rows"),this.__rowsBodyEl=e?.querySelector(".rows-body"),this.#ie.isInitialized){Le(this.#P,this.#te),Me(this.#P,this.#s?.shell,this.#te);const e=this.#s?.shell?.toolPanel?.defaultOpen;e&&this.#te.toolPanels.has(e)&&(this.openToolPanel(),this.#te.expandedSections.add(e))}this._resizeController=fe(this),this.#Me(e),this.#I.requestPhase(ue.COLUMNS,"shellRefresh")}#Ne=/* @__PURE__ */new Map;registerStyles(e,t){let i=this.#Ne.get(e);i||(i=new CSSStyleSheet,this.#Ne.set(e,i)),i.replaceSync(t),this.#at()}unregisterStyles(e){this.#Ne.delete(e)&&this.#at()}getRegisteredStyles(){return Array.from(this.#Ne.keys())}#at(){const e=Array.from(this.#Ne.values()),t=document.adoptedStyleSheets.filter(e=>!Array.from(this.#Ne.values()).includes(e));document.adoptedStyleSheets=[...t,...e]}#ct=/* @__PURE__ */new Set;#dt=/* @__PURE__ */new Map;registerExternalFocusContainer(e){if(this.#ct.has(e))return;this.#ct.add(e);const t=new AbortController,i=t.signal;e.addEventListener("focusin",()=>{this.dataset.hasFocus=""},{signal:i}),e.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&this.containsFocus(t)||delete this.dataset.hasFocus},{signal:i}),this.#dt.set(e,()=>t.abort())}unregisterExternalFocusContainer(e){this.#ct.delete(e);const t=this.#dt.get(e);t&&(t(),this.#dt.delete(e))}containsFocus(e){const t=e??document.activeElement;return!!t&&(!!this.contains(t)||this.#Ve(t))}#Ve(e){for(const t of this.#ct)if(t.contains(e))return!0;return!1}#ke(){Te(this,this.#te),He(this,this.#te),Pe(this,this.#te,this.#ze())}#ht(){const e=this.#P.querySelector(".tbw-shell-header");if(!e)return;Oe(this.#te);const t=function(e,t,i="☰"){const o=e?.header?.title??t.lightDomTitle??"",n=!!o,r=xe(i),s=e?.header?.toolbarContents??[],l=[...t.toolbarContents.values()],a=new Set(s.map(e=>e.id)),c=[...s];for(const w of l)a.has(w.id)||c.push(w);const d=c.length>0,h=t.toolPanels.size>0,u=d&&h,g=[...c].sort((e,t)=>(e.order??0)-(t.order??0));let f="";for(const w of g)f+=`<div class="tbw-toolbar-content-slot" data-toolbar-content="${w.id}"></div>`;if(u&&(f+='<div class="tbw-toolbar-separator"></div>'),h){const e=t.isPanelOpen;f+=`<button class="${e?"tbw-toolbar-btn active":"tbw-toolbar-btn"}" data-panel-toggle title="Settings" aria-label="Toggle settings panel" aria-pressed="${e}" aria-controls="tbw-tool-panel">${r}</button>`}return`\n <div class="tbw-shell-header" part="shell-header" role="presentation">\n ${n?`<div class="tbw-shell-title">${p=o,p&&"string"==typeof p?p.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}</div>`:""}\n <div class="tbw-shell-content" part="shell-content" role="presentation" data-light-dom-header-content></div>\n <div class="tbw-shell-toolbar" part="shell-toolbar" role="presentation">\n ${f}\n </div>\n </div>\n `;var p}(this.#s.shell,this.#te,this.#s.icons?.toolPanel),i=document.createElement("div");i.innerHTML=t;const o=i.firstElementChild;o&&(e.replaceWith(o),this.#ut(),Me(this.#P,this.#s?.shell,this.#te))}#Ie(){const e=()=>{const e=this.#te.lightDomTitle,t=this.#te.hasToolButtonsContainer;this.#ke();const i=this.#te.lightDomTitle,o=this.#te.hasToolButtonsContainer;(i&&!e||o&&!t)&&(this.#z.markSourcesChanged(),this.#z.merge(),this.#ht())},t=()=>{this.__lightDomColumnsCache=void 0,this.#Ee()};this.#z.registerLightDomHandler("tbw-grid-header",e),this.#z.registerLightDomHandler("tbw-grid-tool-buttons",e),this.#z.registerLightDomHandler("tbw-grid-tool-panel",e),this.#z.registerLightDomHandler("tbw-grid-column",t),this.#z.registerLightDomHandler("tbw-grid-detail",t),this.#z.observeLightDOM(this)}refreshColumns(){this.__lightDomColumnsCache=void 0,F(this),this.#z.parseLightDomColumns(this);const e=this.#te.lightDomTitle,t=this.#te.hasToolButtonsContainer;this.#ke();const i=this.#te.lightDomTitle,o=this.#te.hasToolButtonsContainer;(i&&!e||o&&!t)&&(this.#z.markSourcesChanged(),this.#z.merge(),this.#ht()),this.#I.requestPhase(ue.COLUMNS,"refreshColumns")}#Ue(){const e=this._virtualization.container,t=this._virtualization.viewportEl??e;t&&(this._virtualization.cachedViewportHeight=t.clientHeight),e&&(this._virtualization.cachedFauxHeight=e.clientHeight);const i=this._virtualization.scrollAreaEl;i&&(this._virtualization.cachedScrollAreaHeight=i.clientHeight)}#Ce(e,t=!1){const i=this._virtualization;let o,n,r;if(t){const e=i.container??this,t=i.viewportEl??e,s=i.scrollAreaEl;o=e.clientHeight,n=t.clientHeight,r=s?s.clientHeight:o,i.cachedFauxHeight=o,i.cachedViewportHeight=n,i.cachedScrollAreaHeight=r}else o=i.cachedFauxHeight,n=i.cachedViewportHeight,r=i.cachedScrollAreaHeight||o;const s=r-n,l=Math.max(0,o-r);let a,c=0;i.variableHeights&&i.positionCache?a=function(e){if(0===e.length)return 0;const t=e[e.length-1];return t.offset+t.height}(i.positionCache):(a=e*i.rowHeight,c=this.#K?.getExtraHeight()??0);return a+s+c+l}#$e(){if(!this._virtualization.variableHeights)return;const e=this._rows,t=this._virtualization.rowHeight||28,i=this.#s.rowHeight,o=this.#s.getRowId,n=o?e=>o(e):void 0;this._virtualization.positionCache=function(e,t,i,o,n){const r=new Array(e.length);let s=0;for(let l=0;l<e.length;l++){const a=e[l];let c=n?.(a,l),d=void 0!==c;void 0===c&&(c=Je(t,a,o.rowId),d=void 0!==c),void 0===c&&(c=i,d=!1),r[l]={offset:s,height:c,measured:d},s+=c}return r}(e,this._virtualization.heightCache,t,{rowId:n},(e,t)=>{const o=this.#K?.getRowHeight?.(e,t);if(void 0!==o)return o;if(i){const o=i(e,t);if(void 0!==o&&o>0)return o}});const r=function(e,t,i,o){let n=0,r=0;for(let s=0;s<e.length;s++){const i=e[s];if(i.measured){const e=o?.(t[s],s);void 0===e&&(r+=i.height,n++)}}return{measuredCount:n,averageHeight:n>0?r/n:i}}(this._virtualization.positionCache,e,t,(e,t)=>this.#K?.getRowHeight?.(e,t));this._virtualization.measuredCount=r.measuredCount,r.measuredCount>0&&(this._virtualization.averageHeight=r.averageHeight)}invalidateRowHeight(e,t){if(!this._virtualization.variableHeights)return;if(!this._virtualization.positionCache)return;if(e<0||e>=this._rows.length)return;const i=this._virtualization.positionCache,o=this._rows[e];let n=t;void 0===n&&(n=this.#K?.getRowHeight?.(o,e)),void 0===n&&(n=this._virtualization.rowHeight);const r=i[e];if(r&&!(Math.abs(r.height-n)<1)&&(et(i,e,n),this._virtualization.totalHeightEl)){const e=this.#Ce(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}#nt(e,t){if(!this._virtualization.variableHeights)return;if(!this._virtualization.positionCache)return;if(!this._bodyEl)return;const i=this._bodyEl.querySelectorAll(".data-grid-row"),o=this.#s.getRowId,n=it({positionCache:this._virtualization.positionCache,heightCache:this._virtualization.heightCache,rows:this._rows,defaultHeight:this._virtualization.rowHeight,start:e,end:t,getPluginHeight:(e,t)=>this.#K?.getRowHeight?.(e,t),getRowId:o?e=>o(e):void 0},i);if(n.hasChanges&&(this._virtualization.measuredCount=n.measuredCount,this._virtualization.averageHeight=n.averageHeight,this._virtualization.totalHeightEl)){const e=this.#Ce(this._rows.length);this._virtualization.totalHeightEl.style.height=`${e}px`}}refreshVirtualWindow(e=!1,t=!1){if(!this._bodyEl)return!1;const i=this._rows.length;if(!this._virtualization.enabled)return this.#tt(0,i),t||this.#K?.afterRender(),!0;if(this._rows.length<=this._virtualization.bypassThreshold)return this._virtualization.start=0,this._virtualization.end=i,e&&(this._bodyEl.style.transform="translateY(0px)"),this.#tt(0,i,this.__rowRenderEpoch),e&&this._virtualization.totalHeightEl&&(this._virtualization.totalHeightEl.style.height=`${this.#Ce(i,!0)}px`),this.#ot(i,this._visibleColumns.length),t||this.#K?.afterRender(),!0;const o=this._virtualization.container??this,n=this._virtualization.viewportEl??o,r=e?this._virtualization.cachedViewportHeight=n.clientHeight:this._virtualization.cachedViewportHeight||(this._virtualization.cachedViewportHeight=n.clientHeight),s=this._virtualization.rowHeight,l=o.scrollTop;let a;const c=this._virtualization.positionCache;if(this._virtualization.variableHeights&&c&&c.length>0)a=tt(c,l),-1===a&&(a=0);else{a=Math.floor(l/s);let e=0;const t=10;for(;e<t;){const t=this.#K?.getExtraHeightBefore?.(a)??0,i=Math.floor((l-t)/s);if(i>=a||i<0)break;a=i,e++}}a-=a%2,a<0&&(a=0);const d=this.#K?.adjustVirtualStart(a,l,s);let h;if(void 0!==d&&d<a&&(a=d,a-=a%2,a<0&&(a=0)),this._virtualization.variableHeights&&c&&c.length>0){const e=r+3*s;let t=0;for(h=a;h<i&&t<e;)t+=c[h].height,h++;const o=Math.ceil(r/s)+3;h-a<o&&(h=Math.min(a+o,i))}else{h=a+(Math.ceil(r/s)+3)}h>i&&(h=i);const u=this._virtualization.start,g=this._virtualization.end;if(!e&&a===u&&h===g)return!1;this._virtualization.start=a,this._virtualization.end=h;const f=e?this._virtualization.cachedFauxHeight=o.clientHeight:this._virtualization.cachedFauxHeight||(this._virtualization.cachedFauxHeight=o.clientHeight);if(e){const e=this._virtualization.scrollAreaEl;e&&(this._virtualization.cachedScrollAreaHeight=e.clientHeight)}if(0===f&&r>0)return this.#I.requestPhase(ue.VIRTUALIZATION,"stale-refs-retry"),!1;if(e&&this._virtualization.totalHeightEl){const e=this.#Ce(i);this._virtualization.totalHeightEl.style.height=`${e}px`}let p;if(this._virtualization.variableHeights&&c&&c[a])p=c[a].offset;else{p=a*s+(this.#K?.getExtraHeightBefore?.(a)??0)}const w=-(l-p);return this._bodyEl.style.transform=`translateY(${w}px)`,this.#tt(a,h,this.__rowRenderEpoch),e&&this._virtualization.variableHeights&&this.#nt(a,h),this.#ot(i,this._visibleColumns.length),e&&!t&&(this.#K?.afterRender(),queueMicrotask(()=>{if(!this._virtualization.totalHeightEl)return;const e=this.#Ce(i);0===this._virtualization.cachedFauxHeight&&this._virtualization.cachedViewportHeight>0||(this._virtualization.totalHeightEl.style.height=`${e}px`)})),!0}#Oe(){this.#ke(),this.#z.markSourcesChanged(),this.#z.merge();const e=this.#s?.shell;Ne(this.#P,e,{isPanelOpen:this.#te.isPanelOpen,expandedSections:this.#te.expandedSections},this.#s?.icons)&&(this.#ut(),this.#ie.setInitialized(!0))}#ut(){!function(e,t,i,o){const n=e.querySelector(".tbw-shell-toolbar");n&&n.addEventListener("click",e=>{e.target.closest("[data-panel-toggle]")&&o.onPanelToggle()});const r=e.querySelector(".tbw-accordion");r&&r.addEventListener("click",e=>{const t=e.target.closest(".tbw-accordion-header");if(t){const e=t.closest("[data-section]"),i=e?.getAttribute("data-section");i&&o.onSectionToggle(i)}})}(this.#P,this.#s,this.#te,{onPanelToggle:()=>this.toggleToolPanel(),onSectionToggle:e=>this.toggleToolPanelSection(e)}),this.#oe?.(),this.#oe=function(e,t,i){const o=e.querySelector(".tbw-tool-panel"),n=e.querySelector("[data-resize-handle]"),r=e.querySelector(".tbw-shell-body");if(!o||!n||!r)return()=>{};const s=t?.toolPanel?.position??"right";let l=0,a=0,c=0,d=!1;const h=e=>{if(!d)return;e.preventDefault();const t="left"===s?e.clientX-l:l-e.clientX,i=Math.min(c,Math.max(200,a+t));o.style.width=`${i}px`},u=()=>{if(!d)return;d=!1,n.classList.remove("resizing"),o.style.transition="",document.body.style.cursor="",document.body.style.userSelect="";const e=o.getBoundingClientRect().width;i(e),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)},g=e=>{e.preventDefault(),d=!0,l=e.clientX,a=o.getBoundingClientRect().width,c=r.getBoundingClientRect().width-20,n.classList.add("resizing"),o.style.transition="none",document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",h),document.addEventListener("mouseup",u)};return n.addEventListener("mousedown",g),()=>{n.removeEventListener("mousedown",g),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}}(this.#P,this.#s?.shell,e=>{this.style.setProperty("--tbw-tool-panel-width",`${e}px`)}),this.#ne?.(),this.#ne=function(e,t,i,o){if(!t?.toolPanel?.closeOnClickOutside)return()=>{};const n=e=>{if(!i.isPanelOpen)return;const t=e.target;t&&(t.closest(".tbw-tool-panel")||t.closest("[data-panel-toggle]")||o())};return e.addEventListener("mousedown",n),()=>e.removeEventListener("mousedown",n)}(this,this.#s?.shell,this.#te,()=>this.closeToolPanel())}}customElements.get(st.tagName)||customElements.define(st.tagName,st),globalThis.DataGridElement=st;const lt={CAN_MOVE_COLUMN:"canMoveColumn",GET_CONTEXT_MENU_ITEMS:"getContextMenuItems"};class at{static dependencies;static manifest;version="1.22.0";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#gt;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#gt?.abort(),this.#gt=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#gt?.abort(),this.#gt=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#gt?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...o,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(t,10);if(!isNaN(i))return i}return 200}resolveIcon(e,t){return void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const ct={ROOT:"tbw-grid-root",HEADER:"header",HEADER_ROW:"header-row",HEADER_CELL:"header-cell",ROWS_VIEWPORT:"rows-viewport",ROWS_SPACER:"rows-spacer",ROWS_CONTAINER:"rows",DATA_ROW:"data-row",GROUP_ROW:"group-row",DATA_CELL:"data-cell",SELECTED:"selected",FOCUSED:"focused",EDITING:"editing",EXPANDED:"expanded",COLLAPSED:"collapsed",DRAGGING:"dragging",RESIZING:"resizing",SORTABLE:"sortable",SORTED_ASC:"sorted-asc",SORTED_DESC:"sorted-desc",HIDDEN:"hidden",STICKY_LEFT:"sticky-left",STICKY_RIGHT:"sticky-right",PINNED_TOP:"pinned-top",PINNED_BOTTOM:"pinned-bottom",TREE_TOGGLE:"tree-toggle",TREE_INDENT:"tree-indent",GROUP_TOGGLE:"group-toggle",GROUP_LABEL:"group-label",GROUP_COUNT:"group-count",RANGE_SELECTION:"range-selection",SELECTION_OVERLAY:"selection-overlay"},dt={ROW_INDEX:"data-row-index",COL_INDEX:"data-col-index",FIELD:"data-field",GROUP_KEY:"data-group-key",TREE_LEVEL:"data-tree-level",STICKY:"data-sticky"},ht={ROOT:`.${ct.ROOT}`,HEADER:`.${ct.HEADER}`,HEADER_ROW:`.${ct.HEADER_ROW}`,HEADER_CELL:`.${ct.HEADER_CELL}`,ROWS_VIEWPORT:`.${ct.ROWS_VIEWPORT}`,ROWS_CONTAINER:`.${ct.ROWS_CONTAINER}`,DATA_ROW:`.${ct.DATA_ROW}`,DATA_CELL:`.${ct.DATA_CELL}`,GROUP_ROW:`.${ct.GROUP_ROW}`,ROW_BY_INDEX:e=>`.${ct.DATA_ROW}[${dt.ROW_INDEX}="${e}"]`,CELL_BY_FIELD:e=>`.${ct.DATA_CELL}[${dt.FIELD}="${e}"]`,CELL_AT:(e,t)=>`.${ct.DATA_ROW}[${dt.ROW_INDEX}="${e}"] .${ct.DATA_CELL}[${dt.COL_INDEX}="${t}"]`,SELECTED_ROWS:`.${ct.DATA_ROW}.${ct.SELECTED}`,EDITING_CELL:`.${ct.DATA_CELL}.${ct.EDITING}`},ut={COLOR_BG:"--tbw-color-bg",COLOR_FG:"--tbw-color-fg",COLOR_FG_MUTED:"--tbw-color-fg-muted",COLOR_BORDER:"--tbw-color-border",COLOR_ACCENT:"--tbw-color-accent",COLOR_HEADER_BG:"--tbw-color-header-bg",COLOR_HEADER_FG:"--tbw-color-header-fg",COLOR_SELECTION:"--tbw-color-selection",COLOR_ROW_HOVER:"--tbw-color-row-hover",COLOR_ROW_ALT:"--tbw-color-row-alt",ROW_HEIGHT:"--tbw-row-height",HEADER_HEIGHT:"--tbw-header-height",CELL_PADDING:"--tbw-cell-padding",FONT_FAMILY:"--tbw-font-family",FONT_SIZE:"--tbw-font-size",BORDER_RADIUS:"--tbw-border-radius",FOCUS_OUTLINE:"--tbw-focus-outline"};function gt(e){const t=document.createElement("tbw-grid");return e&&(t.gridConfig=e),t}function ft(e,t=document){return t.querySelector(e)}const pt={CELL_CHANGE:"cell-change",CELL_COMMIT:"cell-commit",ROW_COMMIT:"row-commit",EDIT_OPEN:"edit-open",EDIT_CLOSE:"edit-close",CHANGED_ROWS_RESET:"changed-rows-reset",MOUNT_EXTERNAL_VIEW:"mount-external-view",MOUNT_EXTERNAL_EDITOR:"mount-external-editor",SORT_CHANGE:"sort-change",COLUMN_RESIZE:"column-resize",ACTIVATE_CELL:"activate-cell",CELL_ACTIVATE:"cell-activate",GROUP_TOGGLE:"group-toggle",COLUMN_STATE_CHANGE:"column-state-change"},wt={SELECTION_CHANGE:"selection-change",TREE_EXPAND:"tree-expand",FILTER_CHANGE:"filter-change",SORT_MODEL_CHANGE:"sort-model-change",EXPORT_START:"export-start",EXPORT_COMPLETE:"export-complete",CLIPBOARD_COPY:"clipboard-copy",CLIPBOARD_PASTE:"clipboard-paste",CONTEXT_MENU_OPEN:"context-menu-open",CONTEXT_MENU_CLOSE:"context-menu-close",HISTORY_CHANGE:"history-change",SERVER_LOADING:"server-loading",SERVER_ERROR:"server-error",COLUMN_VISIBILITY_CHANGE:"column-visibility-change",COLUMN_REORDER:"column-reorder",DETAIL_EXPAND:"detail-expand",GROUP_EXPAND:"group-expand"},bt={sum:(e,t)=>e.reduce((e,i)=>e+(Number(i[t])||0),0),avg:(e,t)=>{const i=e.reduce((e,i)=>e+(Number(i[t])||0),0);return e.length?i/e.length:0},count:e=>e.length,min:(e,t)=>e.length?Math.min(...e.map(e=>Number(e[t])||1/0)):0,max:(e,t)=>e.length?Math.max(...e.map(e=>Number(e[t])||-1/0)):0,first:(e,t)=>e[0]?.[t],last:(e,t)=>e[e.length-1]?.[t]},mt=/* @__PURE__ */new Map,vt={register(e,t){mt.set(e,t)},unregister(e){mt.delete(e)},get(e){if(void 0!==e)return"function"==typeof e?e:mt.get(e)??bt[e]},run(e,t,i,o){const n=this.get(e);return n?n(t,i,o):void 0},has:e=>mt.has(e)||e in bt,list:()=>[...Object.keys(bt),...mt.keys()]},Ct={sum:e=>e.reduce((e,t)=>e+t,0),avg:e=>e.length?e.reduce((e,t)=>e+t,0)/e.length:0,count:e=>e.length,min:e=>e.length?Math.min(...e):0,max:e=>e.length?Math.max(...e):0,first:e=>e[0]??0,last:e=>e[e.length-1]??0};function yt(e){return Ct[e]??Ct.sum}function _t(e,t){return yt(e)(t)}const St=vt.register.bind(vt),Rt=vt.unregister.bind(vt),Et=vt.get.bind(vt),xt=vt.run.bind(vt),At=vt.list.bind(vt);export{at as BaseGridPlugin,t as DEFAULT_ANIMATION_CONFIG,o as DEFAULT_GRID_ICONS,pt as DGEvents,st as DataGridElement,O as F,e as FitModeEnum,ut as GridCSSVars,ct as GridClasses,dt as GridDataAttrs,st as GridElement,ht as GridSelectors,lt as PLUGIN_QUERIES,wt as PluginEvents,rt as PluginManager,ue as RenderPhase,C as a,vt as aggregatorRegistry,v as b,Q as builtInSort,ot as c,gt as createGrid,T as d,Z as defaultComparator,G as e,H as f,P as g,Et as getAggregator,yt as getValueAggregator,At as listAggregators,ft as queryGrid,L as r,St as registerAggregator,xt as runAggregator,_t as runValueAggregator,nt as s,Rt as unregisterAggregator};//# sourceMappingURL=index.js.map
|