@taskctrl/canvas-grid 0.1.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 +176 -0
- package/dist/CanvasGrid.d.ts +3 -0
- package/dist/canvas-grid.cjs.js +1 -0
- package/dist/canvas-grid.es.js +1685 -0
- package/dist/capture.d.ts +17 -0
- package/dist/core/ColumnEngine.d.ts +43 -0
- package/dist/core/HitTest.d.ts +8 -0
- package/dist/core/RenderScheduler.d.ts +11 -0
- package/dist/core/SelectionEngine.d.ts +15 -0
- package/dist/core/TreeEngine.d.ts +20 -0
- package/dist/core/ViewState.d.ts +48 -0
- package/dist/dom/AriaLiveRegion.d.ts +9 -0
- package/dist/dom/ColumnHeaders.d.ts +14 -0
- package/dist/dom/ColumnVisibilityMenu.d.ts +7 -0
- package/dist/dom/HoverPortal.d.ts +9 -0
- package/dist/dom/RowSidebar.d.ts +16 -0
- package/dist/helpers/DrawHelpers.d.ts +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/layers/CellLayer.d.ts +14 -0
- package/dist/layers/GridLayer.d.ts +10 -0
- package/dist/layers/OverlayLayer.d.ts +22 -0
- package/dist/setupCanvas.d.ts +1 -0
- package/dist/types.d.ts +110 -0
- package/package.json +61 -0
|
@@ -0,0 +1,1685 @@
|
|
|
1
|
+
import { jsxs as de, jsx as H } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ne, useState as ve, useCallback as te, useEffect as re, memo as $t, forwardRef as Bt, useMemo as Ne, useImperativeHandle as Kt } from "react";
|
|
3
|
+
import { createPortal as Ft } from "react-dom";
|
|
4
|
+
class St {
|
|
5
|
+
constructor(e) {
|
|
6
|
+
this.scrollX = 0, this.scrollY = 0, this.canvasWidth = 0, this.canvasHeight = 0, this.rowHeight = 32, this.pinnedWidth = 0, this._columnOffsets = [], this._columnWidths = [], this._pinnedOffsets = [], this._pinnedWidths = [], this._scrollableOffsets = [], this._scrollableWidths = [], e && this.update(e);
|
|
7
|
+
}
|
|
8
|
+
update(e) {
|
|
9
|
+
e.scrollX !== void 0 && (this.scrollX = e.scrollX), e.scrollY !== void 0 && (this.scrollY = e.scrollY), e.canvasWidth !== void 0 && (this.canvasWidth = e.canvasWidth), e.canvasHeight !== void 0 && (this.canvasHeight = e.canvasHeight), e.rowHeight !== void 0 && (this.rowHeight = e.rowHeight);
|
|
10
|
+
}
|
|
11
|
+
setColumnOffsets(e) {
|
|
12
|
+
this._columnOffsets = e;
|
|
13
|
+
}
|
|
14
|
+
setColumnWidths(e) {
|
|
15
|
+
this._columnWidths = e;
|
|
16
|
+
}
|
|
17
|
+
setPinnedOffsets(e, o) {
|
|
18
|
+
this._pinnedOffsets = e, this._pinnedWidths = o;
|
|
19
|
+
}
|
|
20
|
+
setScrollableOffsets(e, o) {
|
|
21
|
+
this._scrollableOffsets = e, this._scrollableWidths = o;
|
|
22
|
+
}
|
|
23
|
+
// Row index → canvas Y pixel
|
|
24
|
+
rowToY(e) {
|
|
25
|
+
return e * this.rowHeight - this.scrollY;
|
|
26
|
+
}
|
|
27
|
+
// Canvas Y pixel → row index
|
|
28
|
+
yToRow(e) {
|
|
29
|
+
return Math.floor((e + this.scrollY) / this.rowHeight);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Column index → canvas X pixel.
|
|
33
|
+
* When pinned param is provided, uses the separate pinned/scrollable arrays.
|
|
34
|
+
* - pinned columns: offset directly (no scrollX applied)
|
|
35
|
+
* - scrollable columns: offset - scrollX + pinnedWidth
|
|
36
|
+
* When pinned param is omitted, falls back to legacy behavior (single array).
|
|
37
|
+
*/
|
|
38
|
+
colToX(e, o) {
|
|
39
|
+
return o === !0 ? this._pinnedOffsets[e] ?? 0 : o === !1 ? (this._scrollableOffsets[e] ?? 0) - this.scrollX + this.pinnedWidth : (this._columnOffsets[e] ?? 0) - this.scrollX;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Canvas X pixel → column index (-1 if not found).
|
|
43
|
+
* When usePinnedLayout is true, checks pinned columns first, then scrollable.
|
|
44
|
+
* Returns { index, pinned } to distinguish which array was hit.
|
|
45
|
+
*/
|
|
46
|
+
xToColPinned(e) {
|
|
47
|
+
for (let n = 0; n < this._pinnedOffsets.length; n++) {
|
|
48
|
+
const r = this._pinnedOffsets[n], c = this._pinnedWidths[n] ?? 0;
|
|
49
|
+
if (e >= r && e < r + c)
|
|
50
|
+
return { index: n, pinned: !0 };
|
|
51
|
+
}
|
|
52
|
+
const o = e - this.pinnedWidth + this.scrollX;
|
|
53
|
+
for (let n = 0; n < this._scrollableOffsets.length; n++) {
|
|
54
|
+
const r = this._scrollableOffsets[n], c = this._scrollableWidths[n] ?? 0;
|
|
55
|
+
if (o >= r && o < r + c)
|
|
56
|
+
return { index: n, pinned: !1 };
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
// Canvas X pixel → column index (-1 if not found) — legacy
|
|
61
|
+
xToCol(e) {
|
|
62
|
+
const o = e + this.scrollX;
|
|
63
|
+
for (let n = 0; n < this._columnOffsets.length; n++) {
|
|
64
|
+
const r = this._columnOffsets[n], c = this._columnWidths[n] ?? 0;
|
|
65
|
+
if (o >= r && o < r + c)
|
|
66
|
+
return n;
|
|
67
|
+
}
|
|
68
|
+
return -1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const Ct = ["grid", "cells", "overlay"];
|
|
72
|
+
class Ut {
|
|
73
|
+
constructor(e) {
|
|
74
|
+
this._dirty = { grid: !1, cells: !1, overlay: !1 }, this._rafId = null, this._drawFn = e;
|
|
75
|
+
}
|
|
76
|
+
markDirty(e) {
|
|
77
|
+
this._dirty[e] = !0, this._rafId === null && (this._rafId = requestAnimationFrame(() => this._flush()));
|
|
78
|
+
}
|
|
79
|
+
markAllDirty() {
|
|
80
|
+
for (const e of Ct)
|
|
81
|
+
this._dirty[e] = !0;
|
|
82
|
+
this._rafId === null && (this._rafId = requestAnimationFrame(() => this._flush()));
|
|
83
|
+
}
|
|
84
|
+
destroy() {
|
|
85
|
+
this._rafId !== null && (cancelAnimationFrame(this._rafId), this._rafId = null);
|
|
86
|
+
}
|
|
87
|
+
_flush() {
|
|
88
|
+
this._rafId = null;
|
|
89
|
+
for (const e of Ct)
|
|
90
|
+
this._dirty[e] && (this._dirty[e] = !1, this._drawFn(e));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class Nt {
|
|
94
|
+
constructor(e, o) {
|
|
95
|
+
this._rows = e, this._expandedRows = o, this._depthMap = /* @__PURE__ */ new Map(), this._childrenMap = /* @__PURE__ */ new Map(), this._buildMaps(), this._flattenedRows = this._buildFlattenedRows();
|
|
96
|
+
}
|
|
97
|
+
_buildMaps() {
|
|
98
|
+
for (const n of this._rows)
|
|
99
|
+
this._childrenMap.has(n.id) || this._childrenMap.set(n.id, []), n.parentId !== void 0 && (this._childrenMap.has(n.parentId) || this._childrenMap.set(n.parentId, []), this._childrenMap.get(n.parentId).push(n));
|
|
100
|
+
const o = this._rows.filter((n) => n.parentId === void 0).map((n) => ({ row: n, depth: 0 }));
|
|
101
|
+
for (; o.length > 0; ) {
|
|
102
|
+
const { row: n, depth: r } = o.pop();
|
|
103
|
+
this._depthMap.set(n.id, r);
|
|
104
|
+
const c = this._childrenMap.get(n.id) ?? [];
|
|
105
|
+
for (const a of c)
|
|
106
|
+
o.push({ row: a, depth: r + 1 });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
_buildFlattenedRows() {
|
|
110
|
+
const e = [], o = this._rows.filter((r) => r.parentId === void 0), n = (r) => {
|
|
111
|
+
if (e.push(r), this._expandedRows.has(r.id)) {
|
|
112
|
+
const c = this._childrenMap.get(r.id) ?? [];
|
|
113
|
+
for (const a of c)
|
|
114
|
+
n(a);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
for (const r of o)
|
|
118
|
+
n(r);
|
|
119
|
+
return e;
|
|
120
|
+
}
|
|
121
|
+
get flattenedRows() {
|
|
122
|
+
return this._flattenedRows;
|
|
123
|
+
}
|
|
124
|
+
getDepth(e) {
|
|
125
|
+
return this._depthMap.get(e) ?? 0;
|
|
126
|
+
}
|
|
127
|
+
hasChildren(e) {
|
|
128
|
+
const o = this._childrenMap.get(e);
|
|
129
|
+
return o !== void 0 && o.length > 0;
|
|
130
|
+
}
|
|
131
|
+
isExpanded(e) {
|
|
132
|
+
return this._expandedRows.has(e);
|
|
133
|
+
}
|
|
134
|
+
toggle(e) {
|
|
135
|
+
const o = new Set(this._expandedRows);
|
|
136
|
+
return o.has(e) ? o.delete(e) : o.add(e), o;
|
|
137
|
+
}
|
|
138
|
+
getVisibleRange(e, o, n) {
|
|
139
|
+
if (n <= 0 || this._flattenedRows.length === 0)
|
|
140
|
+
return { startIndex: 0, endIndex: 0 };
|
|
141
|
+
const r = Math.max(0, Math.floor(e / n)), c = Math.min(
|
|
142
|
+
this._flattenedRows.length - 1,
|
|
143
|
+
Math.ceil((e + o) / n) - 1
|
|
144
|
+
);
|
|
145
|
+
return { startIndex: r, endIndex: c };
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const jt = 30;
|
|
149
|
+
class Ie {
|
|
150
|
+
constructor(e) {
|
|
151
|
+
this._columns = e;
|
|
152
|
+
}
|
|
153
|
+
getVisibleColumns() {
|
|
154
|
+
return this._columns.filter((e) => !e.hidden);
|
|
155
|
+
}
|
|
156
|
+
/** Returns visible pinned-left columns, preserving order. */
|
|
157
|
+
getPinnedColumns() {
|
|
158
|
+
return this._columns.filter((e) => !e.hidden && e.pinned === "left");
|
|
159
|
+
}
|
|
160
|
+
/** Returns visible non-pinned columns, preserving order. */
|
|
161
|
+
getScrollableColumns() {
|
|
162
|
+
return this._columns.filter((e) => !e.hidden && e.pinned !== "left");
|
|
163
|
+
}
|
|
164
|
+
/** Total width of all pinned-left columns. */
|
|
165
|
+
getPinnedWidth() {
|
|
166
|
+
return this.getPinnedColumns().reduce((e, o) => e + o.width, 0);
|
|
167
|
+
}
|
|
168
|
+
getAllColumns() {
|
|
169
|
+
return [...this._columns];
|
|
170
|
+
}
|
|
171
|
+
getTotalWidth() {
|
|
172
|
+
return this.getVisibleColumns().reduce((e, o) => e + o.width, 0);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Returns X offset of a column in the logical layout:
|
|
176
|
+
* pinned columns come first (at offsets 0..pinnedWidth),
|
|
177
|
+
* scrollable columns follow (at offsets pinnedWidth..).
|
|
178
|
+
*/
|
|
179
|
+
getColumnX(e) {
|
|
180
|
+
const o = this.getPinnedColumns(), n = this.getScrollableColumns();
|
|
181
|
+
let r = 0;
|
|
182
|
+
for (const c of o) {
|
|
183
|
+
if (c.id === e) return r;
|
|
184
|
+
r += c.width;
|
|
185
|
+
}
|
|
186
|
+
for (const c of n) {
|
|
187
|
+
if (c.id === e) return r;
|
|
188
|
+
r += c.width;
|
|
189
|
+
}
|
|
190
|
+
return -1;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Given an absolute X (i.e. accounting for scroll in scrollable region),
|
|
194
|
+
* returns the column id at that position. Pinned columns are checked first
|
|
195
|
+
* since they overlay scrollable content.
|
|
196
|
+
*/
|
|
197
|
+
getColumnAtX(e) {
|
|
198
|
+
let o = 0;
|
|
199
|
+
for (const n of this.getPinnedColumns()) {
|
|
200
|
+
if (e >= o && e < o + n.width) return n.id;
|
|
201
|
+
o += n.width;
|
|
202
|
+
}
|
|
203
|
+
for (const n of this.getScrollableColumns()) {
|
|
204
|
+
if (e >= o && e < o + n.width) return n.id;
|
|
205
|
+
o += n.width;
|
|
206
|
+
}
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Returns the visible range of SCROLLABLE columns only (pinned are always visible).
|
|
211
|
+
* scrollX is applied only to the scrollable portion (offset relative to pinnedWidth).
|
|
212
|
+
*/
|
|
213
|
+
getVisibleRange(e, o) {
|
|
214
|
+
const n = this.getScrollableColumns();
|
|
215
|
+
if (n.length === 0) return { startIndex: 0, endIndex: 0 };
|
|
216
|
+
const r = this.getPinnedWidth(), c = o - r;
|
|
217
|
+
let a = 0, m = 0, f = n.length - 1;
|
|
218
|
+
for (let R = 0; R < n.length; R++)
|
|
219
|
+
a + n[R].width <= e && (m = R + 1), a < e + c && (f = R), a += n[R].width;
|
|
220
|
+
return m = Math.min(m, n.length - 1), f = Math.min(f, n.length - 1), { startIndex: m, endIndex: f };
|
|
221
|
+
}
|
|
222
|
+
/** Returns the range of pinned columns (always all of them). */
|
|
223
|
+
getPinnedRange() {
|
|
224
|
+
const e = this.getPinnedColumns();
|
|
225
|
+
return e.length === 0 ? { startIndex: 0, endIndex: -1 } : { startIndex: 0, endIndex: e.length - 1 };
|
|
226
|
+
}
|
|
227
|
+
resize(e, o) {
|
|
228
|
+
const n = this._columns.map((r) => {
|
|
229
|
+
if (r.id !== e) return r;
|
|
230
|
+
const c = r.minWidth ?? jt;
|
|
231
|
+
return { ...r, width: Math.max(c, o) };
|
|
232
|
+
});
|
|
233
|
+
return new Ie(n);
|
|
234
|
+
}
|
|
235
|
+
reorder(e, o) {
|
|
236
|
+
const n = [...this._columns], r = n.findIndex((m) => m.id === e);
|
|
237
|
+
if (r === -1) return new Ie(n);
|
|
238
|
+
const [c] = n.splice(r, 1), a = Math.max(0, Math.min(o, n.length));
|
|
239
|
+
return n.splice(a, 0, c), new Ie(n);
|
|
240
|
+
}
|
|
241
|
+
hide(e) {
|
|
242
|
+
const o = this._columns.map((n) => n.id === e ? { ...n, hidden: !0 } : n);
|
|
243
|
+
return new Ie(o);
|
|
244
|
+
}
|
|
245
|
+
show(e) {
|
|
246
|
+
const o = this._columns.map(
|
|
247
|
+
(n) => n.id === e ? { ...n, hidden: !1 } : n
|
|
248
|
+
);
|
|
249
|
+
return new Ie(o);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function Se(t, e) {
|
|
253
|
+
return `${t}|${e}`;
|
|
254
|
+
}
|
|
255
|
+
function je() {
|
|
256
|
+
return {
|
|
257
|
+
cells: /* @__PURE__ */ new Set(),
|
|
258
|
+
rows: /* @__PURE__ */ new Set(),
|
|
259
|
+
columns: /* @__PURE__ */ new Set(),
|
|
260
|
+
anchor: void 0
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
class qt {
|
|
264
|
+
constructor(e) {
|
|
265
|
+
e ? this._selection = {
|
|
266
|
+
cells: new Set(e.cells),
|
|
267
|
+
rows: new Set(e.rows),
|
|
268
|
+
columns: new Set(e.columns),
|
|
269
|
+
anchor: e.anchor
|
|
270
|
+
} : this._selection = je();
|
|
271
|
+
}
|
|
272
|
+
// Single click — clear previous, select one cell, set anchor
|
|
273
|
+
click(e, o, n, r) {
|
|
274
|
+
this._selection = je(), this._selection.cells.add(Se(e, o)), this._selection.anchor = { rowId: e, colId: o };
|
|
275
|
+
}
|
|
276
|
+
// Ctrl+click — toggle cell in/out of selection
|
|
277
|
+
ctrlClick(e, o) {
|
|
278
|
+
const n = Se(e, o);
|
|
279
|
+
this._selection.cells.has(n) ? this._selection.cells.delete(n) : this._selection.cells.add(n), this._selection.anchor = { rowId: e, colId: o };
|
|
280
|
+
}
|
|
281
|
+
// Shift+click — select rectangle from anchor to target
|
|
282
|
+
shiftClick(e, o, n, r) {
|
|
283
|
+
const c = this._selection.anchor;
|
|
284
|
+
if (!c) {
|
|
285
|
+
this.click(e, o, n, r);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const a = n.indexOf(c.rowId), m = n.indexOf(e), f = r.indexOf(c.colId), R = r.indexOf(o), y = Math.min(a, m), L = Math.max(a, m), O = Math.min(f, R), W = Math.max(f, R), S = /* @__PURE__ */ new Set();
|
|
289
|
+
for (let G = y; G <= L; G++)
|
|
290
|
+
for (let $ = O; $ <= W; $++)
|
|
291
|
+
S.add(Se(n[G], r[$]));
|
|
292
|
+
this._selection.cells = S, this._selection.rows = /* @__PURE__ */ new Set(), this._selection.columns = /* @__PURE__ */ new Set();
|
|
293
|
+
}
|
|
294
|
+
// Select entire row
|
|
295
|
+
selectRow(e, o) {
|
|
296
|
+
for (const n of o)
|
|
297
|
+
this._selection.cells.add(Se(e, n));
|
|
298
|
+
this._selection.rows.add(e), this._selection.anchor = { rowId: e, colId: o[0] ?? "" };
|
|
299
|
+
}
|
|
300
|
+
// Select entire column
|
|
301
|
+
selectColumn(e, o) {
|
|
302
|
+
for (const n of o)
|
|
303
|
+
this._selection.cells.add(Se(n, e));
|
|
304
|
+
this._selection.columns.add(e), this._selection.anchor = { rowId: o[0] ?? "", colId: e };
|
|
305
|
+
}
|
|
306
|
+
// Clear all selection
|
|
307
|
+
clear() {
|
|
308
|
+
this._selection = je();
|
|
309
|
+
}
|
|
310
|
+
isSelected(e, o) {
|
|
311
|
+
return this._selection.cells.has(Se(e, o));
|
|
312
|
+
}
|
|
313
|
+
isRowSelected(e) {
|
|
314
|
+
return this._selection.rows.has(e);
|
|
315
|
+
}
|
|
316
|
+
isColumnSelected(e) {
|
|
317
|
+
return this._selection.columns.has(e);
|
|
318
|
+
}
|
|
319
|
+
// Returns a shallow copy of the current selection
|
|
320
|
+
getSelection() {
|
|
321
|
+
return {
|
|
322
|
+
cells: new Set(this._selection.cells),
|
|
323
|
+
rows: new Set(this._selection.rows),
|
|
324
|
+
columns: new Set(this._selection.columns),
|
|
325
|
+
anchor: this._selection.anchor
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function Ve(t, e, o, n, r) {
|
|
330
|
+
const c = o.yToRow(e), a = n.flattenedRows;
|
|
331
|
+
if (c < 0 || c >= a.length) return null;
|
|
332
|
+
const m = r.getPinnedColumns(), f = r.getPinnedWidth();
|
|
333
|
+
if (m.length > 0) {
|
|
334
|
+
if (t < f) {
|
|
335
|
+
let W = 0;
|
|
336
|
+
for (const S of m) {
|
|
337
|
+
if (t >= W && t < W + S.width)
|
|
338
|
+
return { rowId: a[c].id, colId: S.id };
|
|
339
|
+
W += S.width;
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
const y = t - f + o.scrollX, L = r.getScrollableColumns();
|
|
344
|
+
let O = 0;
|
|
345
|
+
for (const W of L) {
|
|
346
|
+
if (y >= O && y < O + W.width)
|
|
347
|
+
return { rowId: a[c].id, colId: W.id };
|
|
348
|
+
O += W.width;
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
const R = r.getColumnAtX(t + o.scrollX);
|
|
353
|
+
return R === null ? null : { rowId: a[c].id, colId: R };
|
|
354
|
+
}
|
|
355
|
+
function Jt(t, e, o) {
|
|
356
|
+
const n = window.devicePixelRatio || 1;
|
|
357
|
+
(t.width !== Math.round(e * n) || t.height !== Math.round(o * n)) && (t.width = Math.round(e * n), t.height = Math.round(o * n), t.style.width = `${e}px`, t.style.height = `${o}px`);
|
|
358
|
+
const c = t.getContext("2d");
|
|
359
|
+
return c.setTransform(n, 0, 0, n, 0, 0), c;
|
|
360
|
+
}
|
|
361
|
+
function kt(t, e, o, n, r = {}) {
|
|
362
|
+
const { canvasWidth: c, canvasHeight: a, rowHeight: m } = e, { rowStyle: f } = r;
|
|
363
|
+
t.clearRect(0, 0, c, a), t.fillStyle = "#f3f4f6", t.fillRect(0, 0, c, a);
|
|
364
|
+
const R = o.getVisibleRange(e.scrollY, a, m), y = o.flattenedRows, L = n.getPinnedColumns(), O = n.getScrollableColumns(), W = n.getPinnedWidth(), S = L.length > 0;
|
|
365
|
+
if (y.length === 0 || L.length === 0 && O.length === 0) return;
|
|
366
|
+
const G = n.getTotalWidth(), $ = Math.min(c, G - e.scrollX + (S ? e.scrollX : 0)), X = S ? Math.min(c, W + n.getScrollableColumns().reduce((T, C) => T + C.width, 0) - e.scrollX) : $, l = y.length * m, Y = Math.min(a, l - e.scrollY);
|
|
367
|
+
for (let T = R.startIndex; T <= R.endIndex; T++) {
|
|
368
|
+
const C = y[T];
|
|
369
|
+
if (!C) continue;
|
|
370
|
+
const D = e.rowToY(T), w = o.getDepth(C.id);
|
|
371
|
+
let h = T % 2 === 0 ? "#ffffff" : "#f9fafb";
|
|
372
|
+
if (f) {
|
|
373
|
+
const u = f(C, w);
|
|
374
|
+
u != null && u.backgroundColor && (h = u.backgroundColor);
|
|
375
|
+
}
|
|
376
|
+
t.fillStyle = h, t.fillRect(0, D, Math.max(X, W), m), t.strokeStyle = "#d1d5db", t.lineWidth = 0.5, t.beginPath(), t.moveTo(0, D + m), t.lineTo(Math.max(X, W), D + m), t.stroke();
|
|
377
|
+
}
|
|
378
|
+
if (Y > 0) {
|
|
379
|
+
const T = n.getVisibleRange(e.scrollX, c);
|
|
380
|
+
t.strokeStyle = "#d1d5db", t.lineWidth = 0.5;
|
|
381
|
+
for (let C = T.startIndex; C <= T.endIndex; C++) {
|
|
382
|
+
const D = O[C];
|
|
383
|
+
if (!D) continue;
|
|
384
|
+
const w = e.colToX(C, !1);
|
|
385
|
+
t.beginPath(), t.moveTo(w + D.width, 0), t.lineTo(w + D.width, Y), t.stroke();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (S && Y > 0) {
|
|
389
|
+
t.fillStyle = "#ffffff", t.fillRect(0, 0, W, a);
|
|
390
|
+
for (let C = R.startIndex; C <= R.endIndex; C++) {
|
|
391
|
+
const D = y[C];
|
|
392
|
+
if (!D) continue;
|
|
393
|
+
const w = e.rowToY(C), h = o.getDepth(D.id);
|
|
394
|
+
let u = C % 2 === 0 ? "#ffffff" : "#f9fafb";
|
|
395
|
+
if (f) {
|
|
396
|
+
const x = f(D, h);
|
|
397
|
+
x != null && x.backgroundColor && (u = x.backgroundColor);
|
|
398
|
+
}
|
|
399
|
+
t.fillStyle = u, t.fillRect(0, w, W, m), t.strokeStyle = "#d1d5db", t.lineWidth = 0.5, t.beginPath(), t.moveTo(0, w + m), t.lineTo(W, w + m), t.stroke();
|
|
400
|
+
}
|
|
401
|
+
const T = n.getPinnedRange();
|
|
402
|
+
t.strokeStyle = "#d1d5db", t.lineWidth = 0.5;
|
|
403
|
+
for (let C = T.startIndex; C <= T.endIndex; C++) {
|
|
404
|
+
const D = L[C];
|
|
405
|
+
if (!D) continue;
|
|
406
|
+
const w = e.colToX(C, !0);
|
|
407
|
+
t.beginPath(), t.moveTo(w + D.width, 0), t.lineTo(w + D.width, Y), t.stroke();
|
|
408
|
+
}
|
|
409
|
+
t.strokeStyle = "#d1d5db", t.lineWidth = 1, t.beginPath(), t.moveTo(W, 0), t.lineTo(W, Y), t.stroke();
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
function Qt(t) {
|
|
413
|
+
function e(a, m, f, R, y, L) {
|
|
414
|
+
t.fillStyle = L, t.beginPath(), t.roundRect(a, m, f, R, y), t.fill();
|
|
415
|
+
}
|
|
416
|
+
function o(a, m, f, R) {
|
|
417
|
+
t.fillText(a, m, f, R);
|
|
418
|
+
}
|
|
419
|
+
function n(a, m) {
|
|
420
|
+
if (t.measureText(a).width <= m) return a;
|
|
421
|
+
let f = a;
|
|
422
|
+
for (; f.length > 0; )
|
|
423
|
+
if (f = f.slice(0, -1), t.measureText(f + "…").width <= m)
|
|
424
|
+
return f + "…";
|
|
425
|
+
return "…";
|
|
426
|
+
}
|
|
427
|
+
function r(a, m, f, R, y) {
|
|
428
|
+
const S = t.measureText(f).width + 16;
|
|
429
|
+
return e(a, m, S, 20, 20 / 2, R), t.fillStyle = y, t.fillText(f, a + 8, m + 20 / 2), S;
|
|
430
|
+
}
|
|
431
|
+
function c(a, m, f, R, y, L) {
|
|
432
|
+
e(a, m, f, R, R / 2, "#d1d5db");
|
|
433
|
+
const O = f * Math.max(0, Math.min(1, y));
|
|
434
|
+
O > 0 && e(a, m, O, R, R / 2, L);
|
|
435
|
+
}
|
|
436
|
+
return { roundRect: e, fillText: o, truncateText: n, badge: r, progressBar: c };
|
|
437
|
+
}
|
|
438
|
+
function _t(t, e, o, n, r, c) {
|
|
439
|
+
const { canvasWidth: a, canvasHeight: m, rowHeight: f } = e, { cellRenderer: R, getCellData: y, hoveredCell: L } = c;
|
|
440
|
+
t.clearRect(0, 0, a, m);
|
|
441
|
+
const O = o.getVisibleRange(e.scrollY, m, f), W = o.flattenedRows, S = n.getPinnedColumns(), G = n.getScrollableColumns(), $ = S.length > 0;
|
|
442
|
+
if (W.length === 0 || S.length === 0 && G.length === 0) return;
|
|
443
|
+
const X = Qt(t), l = (T, C, D, w) => {
|
|
444
|
+
const h = { x: D, y: w, width: C.width, height: f }, u = { rowId: T.id, colId: C.id, data: y(T.id, C.id) }, x = {
|
|
445
|
+
selected: r.isSelected(T.id, C.id),
|
|
446
|
+
hovered: L != null && L.rowId === T.id && L.colId === C.id,
|
|
447
|
+
rowSelected: r.isRowSelected(T.id),
|
|
448
|
+
colSelected: r.isColumnSelected(C.id),
|
|
449
|
+
filtered: !0,
|
|
450
|
+
depth: o.getDepth(T.id),
|
|
451
|
+
hasChildren: o.hasChildren(T.id),
|
|
452
|
+
expanded: o.isExpanded(T.id)
|
|
453
|
+
};
|
|
454
|
+
t.save(), t.beginPath(), t.rect(D, w, C.width, f), t.clip(), R(t, u, h, x, X), t.restore();
|
|
455
|
+
}, Y = n.getVisibleRange(e.scrollX, a);
|
|
456
|
+
for (let T = O.startIndex; T <= O.endIndex; T++) {
|
|
457
|
+
const C = W[T];
|
|
458
|
+
if (!C) continue;
|
|
459
|
+
const D = e.rowToY(T);
|
|
460
|
+
for (let w = Y.startIndex; w <= Y.endIndex; w++) {
|
|
461
|
+
const h = G[w];
|
|
462
|
+
if (!h) continue;
|
|
463
|
+
const u = e.colToX(w, $ ? !1 : void 0);
|
|
464
|
+
l(C, h, u, D);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if ($) {
|
|
468
|
+
n.getPinnedWidth();
|
|
469
|
+
const T = n.getPinnedRange();
|
|
470
|
+
for (let C = O.startIndex; C <= O.endIndex; C++) {
|
|
471
|
+
const D = W[C];
|
|
472
|
+
if (!D) continue;
|
|
473
|
+
const w = e.rowToY(C);
|
|
474
|
+
t.save(), t.fillStyle = "#ffffff", t.restore();
|
|
475
|
+
for (let h = T.startIndex; h <= T.endIndex; h++) {
|
|
476
|
+
const u = S[h];
|
|
477
|
+
if (!u) continue;
|
|
478
|
+
const x = e.colToX(h, !0);
|
|
479
|
+
l(D, u, x, w);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function Zt(t, e, o, n, r, c = {}) {
|
|
485
|
+
const { canvasWidth: a, canvasHeight: m, rowHeight: f } = e, { hoveredCell: R, hoveredRowId: y, selectedCell: L, resizingColumn: O, loading: W } = c;
|
|
486
|
+
t.clearRect(0, 0, a, m);
|
|
487
|
+
const S = o.getVisibleRange(e.scrollY, m, f), G = o.flattenedRows, $ = n.getPinnedColumns(), X = n.getScrollableColumns(), l = $.length > 0;
|
|
488
|
+
if (n.getPinnedWidth(), G.length === 0 || $.length === 0 && X.length === 0) return;
|
|
489
|
+
const Y = n.getVisibleRange(e.scrollX, a), T = n.getPinnedRange(), C = (w) => {
|
|
490
|
+
for (let h = Y.startIndex; h <= Y.endIndex; h++) {
|
|
491
|
+
const u = X[h];
|
|
492
|
+
if (!u) continue;
|
|
493
|
+
const x = l ? e.colToX(h, !1) : e.colToX(h);
|
|
494
|
+
w(u, x);
|
|
495
|
+
}
|
|
496
|
+
if (l)
|
|
497
|
+
for (let h = T.startIndex; h <= T.endIndex; h++) {
|
|
498
|
+
const u = $[h];
|
|
499
|
+
if (!u) continue;
|
|
500
|
+
const x = e.colToX(h, !0);
|
|
501
|
+
w(u, x);
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
if (L) {
|
|
505
|
+
for (let w = S.startIndex; w <= S.endIndex; w++) {
|
|
506
|
+
const h = G[w];
|
|
507
|
+
if (!h || h.id !== L.rowId) continue;
|
|
508
|
+
const u = e.rowToY(w);
|
|
509
|
+
C((x, F) => {
|
|
510
|
+
t.fillStyle = "rgba(59,130,246,0.06)", t.fillRect(F, u, x.width, f);
|
|
511
|
+
});
|
|
512
|
+
break;
|
|
513
|
+
}
|
|
514
|
+
C((w, h) => {
|
|
515
|
+
if (w.id === L.colId)
|
|
516
|
+
for (let u = S.startIndex; u <= S.endIndex; u++) {
|
|
517
|
+
if (!G[u]) continue;
|
|
518
|
+
const F = e.rowToY(u);
|
|
519
|
+
t.fillStyle = "rgba(59,130,246,0.06)", t.fillRect(h, F, w.width, f);
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
const D = (w, h, u, x, F) => {
|
|
524
|
+
const B = w.width, K = f, d = r.isSelected(u.id, w.id), M = r.isRowSelected(u.id), P = r.isColumnSelected(w.id), z = y != null && y === u.id, V = R != null && R.rowId === u.id && R.colId === w.id;
|
|
525
|
+
d ? (t.fillStyle = "rgba(59,130,246,0.12)", t.fillRect(h, x, B, K), t.strokeStyle = "#3b82f6", t.lineWidth = 2, t.strokeRect(h + 1, x + 1, B - 2, K - 2)) : M || P || V ? (t.fillStyle = "rgba(59,130,246,0.08)", t.fillRect(h, x, B, K)) : z && (t.fillStyle = "rgba(59,130,246,0.04)", t.fillRect(h, x, B, K));
|
|
526
|
+
};
|
|
527
|
+
for (let w = S.startIndex; w <= S.endIndex; w++) {
|
|
528
|
+
const h = G[w];
|
|
529
|
+
if (!h) continue;
|
|
530
|
+
const u = e.rowToY(w);
|
|
531
|
+
for (let x = Y.startIndex; x <= Y.endIndex; x++) {
|
|
532
|
+
const F = X[x];
|
|
533
|
+
if (!F) continue;
|
|
534
|
+
const B = l ? e.colToX(x, !1) : e.colToX(x);
|
|
535
|
+
D(F, B, h, u);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (l)
|
|
539
|
+
for (let w = S.startIndex; w <= S.endIndex; w++) {
|
|
540
|
+
const h = G[w];
|
|
541
|
+
if (!h) continue;
|
|
542
|
+
const u = e.rowToY(w);
|
|
543
|
+
for (let x = T.startIndex; x <= T.endIndex; x++) {
|
|
544
|
+
const F = $[x];
|
|
545
|
+
if (!F) continue;
|
|
546
|
+
const B = e.colToX(x, !0);
|
|
547
|
+
D(F, B, h, u);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (O && (t.save(), t.strokeStyle = "#3b82f6", t.lineWidth = 1, t.setLineDash([4, 4]), t.beginPath(), t.moveTo(O.x, 0), t.lineTo(O.x, m), t.stroke(), t.setLineDash([]), t.restore()), W) {
|
|
551
|
+
const h = m - 32;
|
|
552
|
+
t.fillStyle = "#f3f4f6", t.fillRect(0, h, a, 32), t.strokeStyle = "#e5e7eb", t.lineWidth = 1, t.beginPath(), t.moveTo(0, h), t.lineTo(a, h), t.stroke(), t.fillStyle = "#6b7280", t.font = "13px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText("Loading...", a / 2, h + 32 / 2);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
function en({
|
|
556
|
+
treeEngine: t,
|
|
557
|
+
width: e,
|
|
558
|
+
rowHeight: o,
|
|
559
|
+
scrollTop: n,
|
|
560
|
+
viewportHeight: r,
|
|
561
|
+
sidebarRenderer: c,
|
|
562
|
+
onToggle: a,
|
|
563
|
+
onRowClick: m,
|
|
564
|
+
hoveredRowId: f,
|
|
565
|
+
onRowHover: R
|
|
566
|
+
}) {
|
|
567
|
+
const y = t.flattenedRows, { startIndex: L, endIndex: O } = t.getVisibleRange(n, r, o), W = [];
|
|
568
|
+
for (let $ = L; $ <= O; $++) {
|
|
569
|
+
const X = y[$];
|
|
570
|
+
if (!X) continue;
|
|
571
|
+
const l = t.getDepth(X.id), Y = t.hasChildren(X.id), T = t.isExpanded(X.id), C = $ * o;
|
|
572
|
+
let D;
|
|
573
|
+
if (c)
|
|
574
|
+
D = c(X, l, T, Y);
|
|
575
|
+
else {
|
|
576
|
+
const h = l * 16 + 8;
|
|
577
|
+
D = /* @__PURE__ */ de(
|
|
578
|
+
"div",
|
|
579
|
+
{
|
|
580
|
+
style: {
|
|
581
|
+
display: "flex",
|
|
582
|
+
alignItems: "center",
|
|
583
|
+
height: "100%",
|
|
584
|
+
paddingLeft: h,
|
|
585
|
+
overflow: "hidden",
|
|
586
|
+
whiteSpace: "nowrap",
|
|
587
|
+
cursor: Y ? "pointer" : "default",
|
|
588
|
+
userSelect: "none"
|
|
589
|
+
},
|
|
590
|
+
onPointerDown: Y ? (u) => {
|
|
591
|
+
u.stopPropagation(), a(X.id);
|
|
592
|
+
} : void 0,
|
|
593
|
+
children: [
|
|
594
|
+
Y ? /* @__PURE__ */ H("span", { style: { marginRight: 4, flexShrink: 0, fontSize: 10, color: "#6b7280" }, children: T ? "▾" : "▸" }) : /* @__PURE__ */ H("span", { style: { width: 14, flexShrink: 0 } }),
|
|
595
|
+
/* @__PURE__ */ H("span", { style: { overflow: "hidden", textOverflow: "ellipsis", fontSize: 12 }, children: String(X.title ?? X.id) })
|
|
596
|
+
]
|
|
597
|
+
}
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
const w = f === X.id;
|
|
601
|
+
W.push(
|
|
602
|
+
/* @__PURE__ */ H(
|
|
603
|
+
"div",
|
|
604
|
+
{
|
|
605
|
+
role: "rowheader",
|
|
606
|
+
"aria-level": l + 1,
|
|
607
|
+
"aria-expanded": Y ? T : void 0,
|
|
608
|
+
style: {
|
|
609
|
+
position: "absolute",
|
|
610
|
+
top: C,
|
|
611
|
+
left: 0,
|
|
612
|
+
width: "100%",
|
|
613
|
+
height: o,
|
|
614
|
+
boxSizing: "border-box",
|
|
615
|
+
fontSize: 13,
|
|
616
|
+
color: "#374151",
|
|
617
|
+
borderBottom: "1px solid #e5e7eb",
|
|
618
|
+
cursor: m ? "pointer" : "default",
|
|
619
|
+
backgroundColor: w ? "rgba(59,130,246,0.04)" : void 0
|
|
620
|
+
},
|
|
621
|
+
onPointerDown: m ? (h) => m(X.id, h) : void 0,
|
|
622
|
+
onPointerEnter: () => R == null ? void 0 : R(X.id),
|
|
623
|
+
onPointerLeave: () => R == null ? void 0 : R(null),
|
|
624
|
+
children: D
|
|
625
|
+
},
|
|
626
|
+
String(X.id)
|
|
627
|
+
)
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
const S = y.length * o, G = Math.min(r, S - n);
|
|
631
|
+
return /* @__PURE__ */ de(
|
|
632
|
+
"div",
|
|
633
|
+
{
|
|
634
|
+
style: {
|
|
635
|
+
width: e,
|
|
636
|
+
height: r,
|
|
637
|
+
overflow: "hidden",
|
|
638
|
+
position: "relative",
|
|
639
|
+
flexShrink: 0,
|
|
640
|
+
backgroundColor: "#ffffff"
|
|
641
|
+
},
|
|
642
|
+
children: [
|
|
643
|
+
/* @__PURE__ */ H(
|
|
644
|
+
"div",
|
|
645
|
+
{
|
|
646
|
+
style: {
|
|
647
|
+
position: "absolute",
|
|
648
|
+
top: 0,
|
|
649
|
+
right: 0,
|
|
650
|
+
width: 1,
|
|
651
|
+
height: Math.max(0, G),
|
|
652
|
+
backgroundColor: "#e5e7eb",
|
|
653
|
+
zIndex: 1
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
),
|
|
657
|
+
/* @__PURE__ */ H(
|
|
658
|
+
"div",
|
|
659
|
+
{
|
|
660
|
+
style: {
|
|
661
|
+
position: "absolute",
|
|
662
|
+
top: 0,
|
|
663
|
+
left: 0,
|
|
664
|
+
width: "100%",
|
|
665
|
+
height: S,
|
|
666
|
+
transform: `translateY(-${n}px)`
|
|
667
|
+
},
|
|
668
|
+
children: W
|
|
669
|
+
}
|
|
670
|
+
)
|
|
671
|
+
]
|
|
672
|
+
}
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
const qe = 28, Je = 28, tn = 4;
|
|
676
|
+
function nn(t) {
|
|
677
|
+
switch (t) {
|
|
678
|
+
case "vertical":
|
|
679
|
+
return 120;
|
|
680
|
+
default:
|
|
681
|
+
return 32;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
function on({
|
|
685
|
+
columnEngine: t,
|
|
686
|
+
columnGroups: e,
|
|
687
|
+
scrollX: o,
|
|
688
|
+
orientation: n = "horizontal",
|
|
689
|
+
onColumnClick: r,
|
|
690
|
+
onColumnResize: c,
|
|
691
|
+
onColumnReorder: a,
|
|
692
|
+
columnHeaderRenderer: m
|
|
693
|
+
}) {
|
|
694
|
+
const f = t.getPinnedColumns(), R = t.getScrollableColumns(), y = t.getVisibleColumns(), L = t.getPinnedWidth(), O = /* @__PURE__ */ new Map();
|
|
695
|
+
if (e)
|
|
696
|
+
for (const d of e)
|
|
697
|
+
O.set(d.id, d);
|
|
698
|
+
const W = ne(null), [S, G] = ve(null), $ = ne(null), X = ne(!1), l = ne(null), Y = ne(null);
|
|
699
|
+
$.current = S;
|
|
700
|
+
const T = [...f, ...R], C = [];
|
|
701
|
+
if (e && e.length > 0) {
|
|
702
|
+
let d, M = 0, P = 0, z = !1;
|
|
703
|
+
for (const V of T) {
|
|
704
|
+
const q = t.getColumnX(V.id), J = V.pinned === "left";
|
|
705
|
+
if (V.group !== d) {
|
|
706
|
+
if (d !== void 0 && P > 0) {
|
|
707
|
+
const Q = O.get(d);
|
|
708
|
+
Q && C.push({ group: Q, startX: M, width: P, pinned: z });
|
|
709
|
+
}
|
|
710
|
+
d = V.group, M = q, P = V.width, z = J;
|
|
711
|
+
} else
|
|
712
|
+
P += V.width;
|
|
713
|
+
}
|
|
714
|
+
if (d !== void 0 && P > 0) {
|
|
715
|
+
const V = O.get(d);
|
|
716
|
+
V && C.push({ group: V, startX: M, width: P, pinned: z });
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
const D = C.length > 0, w = nn(n), h = D ? qe + w : w, u = te(
|
|
720
|
+
(d, M) => {
|
|
721
|
+
M.stopPropagation(), M.preventDefault();
|
|
722
|
+
const P = y.find((z) => z.id === d);
|
|
723
|
+
P && (W.current = { colId: d, startX: M.clientX, startWidth: P.width });
|
|
724
|
+
},
|
|
725
|
+
[y]
|
|
726
|
+
);
|
|
727
|
+
re(() => {
|
|
728
|
+
const d = (P) => {
|
|
729
|
+
const z = W.current;
|
|
730
|
+
if (!z) return;
|
|
731
|
+
const V = P.clientX - z.startX, q = Math.max(z.startWidth + V, 30);
|
|
732
|
+
c == null || c(z.colId, q);
|
|
733
|
+
}, M = () => {
|
|
734
|
+
W.current = null;
|
|
735
|
+
};
|
|
736
|
+
return document.addEventListener("mousemove", d), document.addEventListener("mouseup", M), () => {
|
|
737
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", M);
|
|
738
|
+
};
|
|
739
|
+
}, [c]);
|
|
740
|
+
const x = te(
|
|
741
|
+
(d) => {
|
|
742
|
+
const M = Y.current;
|
|
743
|
+
if (!M) return { dropIndex: 0 };
|
|
744
|
+
const P = M.getBoundingClientRect(), z = d - P.left + o;
|
|
745
|
+
let V = 0;
|
|
746
|
+
for (let q = 0; q < y.length; q++) {
|
|
747
|
+
const J = y[q], le = t.getColumnX(J.id) + J.width / 2;
|
|
748
|
+
z > le && (V = q + 1);
|
|
749
|
+
}
|
|
750
|
+
return { dropIndex: V };
|
|
751
|
+
},
|
|
752
|
+
[y, t, o]
|
|
753
|
+
), F = te(
|
|
754
|
+
(d, M) => {
|
|
755
|
+
M.target.dataset.resizeHandle || a && (M.preventDefault(), X.current = !1, l.current = { colId: d, startX: M.clientX, currentX: M.clientX });
|
|
756
|
+
},
|
|
757
|
+
[a]
|
|
758
|
+
);
|
|
759
|
+
re(() => {
|
|
760
|
+
if (!a) return;
|
|
761
|
+
const d = (z) => {
|
|
762
|
+
const V = l.current;
|
|
763
|
+
if (!V) return;
|
|
764
|
+
const q = Math.abs(z.clientX - V.startX);
|
|
765
|
+
if (!X.current && q >= tn) {
|
|
766
|
+
X.current = !0;
|
|
767
|
+
const J = y.find((Pe) => Pe.id === V.colId), Q = t.getColumnX(V.colId), { dropIndex: le } = x(z.clientX);
|
|
768
|
+
G({
|
|
769
|
+
colId: V.colId,
|
|
770
|
+
startX: V.startX,
|
|
771
|
+
currentX: z.clientX,
|
|
772
|
+
dropIndex: le,
|
|
773
|
+
ghostLeft: Q - o,
|
|
774
|
+
ghostWidth: (J == null ? void 0 : J.width) ?? 80,
|
|
775
|
+
ghostTitle: (J == null ? void 0 : J.title) ?? ""
|
|
776
|
+
});
|
|
777
|
+
return;
|
|
778
|
+
}
|
|
779
|
+
if (X.current) {
|
|
780
|
+
const { dropIndex: J } = x(z.clientX);
|
|
781
|
+
G((Q) => Q && { ...Q, currentX: z.clientX, dropIndex: J });
|
|
782
|
+
}
|
|
783
|
+
}, M = () => {
|
|
784
|
+
X.current && $.current && a($.current.colId, $.current.dropIndex), l.current = null, X.current = !1, G(null);
|
|
785
|
+
}, P = (z) => {
|
|
786
|
+
z.key === "Escape" && (l.current = null, X.current = !1, G(null));
|
|
787
|
+
};
|
|
788
|
+
return document.addEventListener("mousemove", d), document.addEventListener("mouseup", M), document.addEventListener("keydown", P), () => {
|
|
789
|
+
document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", M), document.removeEventListener("keydown", P);
|
|
790
|
+
};
|
|
791
|
+
}, [a, y, t, o, x]);
|
|
792
|
+
const B = () => {
|
|
793
|
+
if (!S) return 0;
|
|
794
|
+
const { dropIndex: d } = S;
|
|
795
|
+
if (d >= y.length) {
|
|
796
|
+
const M = y[y.length - 1];
|
|
797
|
+
return t.getColumnX(M.id) + M.width - o;
|
|
798
|
+
}
|
|
799
|
+
return t.getColumnX(y[d].id) - o;
|
|
800
|
+
}, K = (d, M, P) => {
|
|
801
|
+
const z = (S == null ? void 0 : S.colId) === d.id, q = d.pinned === "left" ? "horizontal" : n, J = m == null ? void 0 : m(d.id, d.title);
|
|
802
|
+
let Q;
|
|
803
|
+
return J ? Q = J : q === "vertical" ? Q = /* @__PURE__ */ H(
|
|
804
|
+
"div",
|
|
805
|
+
{
|
|
806
|
+
style: {
|
|
807
|
+
writingMode: "vertical-rl",
|
|
808
|
+
textOrientation: "mixed",
|
|
809
|
+
transform: "rotate(180deg)",
|
|
810
|
+
height: P - 16,
|
|
811
|
+
lineHeight: `${d.width}px`,
|
|
812
|
+
overflow: "hidden",
|
|
813
|
+
textOverflow: "ellipsis",
|
|
814
|
+
whiteSpace: "nowrap"
|
|
815
|
+
},
|
|
816
|
+
children: d.title
|
|
817
|
+
}
|
|
818
|
+
) : Q = /* @__PURE__ */ H("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1 }, children: d.title }), /* @__PURE__ */ de(
|
|
819
|
+
"div",
|
|
820
|
+
{
|
|
821
|
+
role: "columnheader",
|
|
822
|
+
title: d.title,
|
|
823
|
+
style: {
|
|
824
|
+
position: "absolute",
|
|
825
|
+
left: M,
|
|
826
|
+
width: d.width,
|
|
827
|
+
height: P,
|
|
828
|
+
boxSizing: "border-box",
|
|
829
|
+
borderRight: "1px solid #d1d5db",
|
|
830
|
+
display: "flex",
|
|
831
|
+
alignItems: q === "horizontal" ? "center" : "flex-end",
|
|
832
|
+
justifyContent: q === "horizontal" ? "flex-start" : "center",
|
|
833
|
+
paddingLeft: q === "horizontal" ? 8 : 0,
|
|
834
|
+
paddingBottom: q !== "horizontal" ? 6 : 0,
|
|
835
|
+
cursor: a ? "grab" : r ? "pointer" : "default",
|
|
836
|
+
userSelect: "none",
|
|
837
|
+
fontSize: 13,
|
|
838
|
+
fontWeight: 500,
|
|
839
|
+
color: "#6C737F",
|
|
840
|
+
opacity: z ? 0.4 : 1
|
|
841
|
+
},
|
|
842
|
+
onMouseDown: a ? (le) => F(d.id, le) : void 0,
|
|
843
|
+
onPointerDown: r && !a ? (le) => r(d.id, le) : void 0,
|
|
844
|
+
children: [
|
|
845
|
+
Q,
|
|
846
|
+
c && /* @__PURE__ */ H(
|
|
847
|
+
"div",
|
|
848
|
+
{
|
|
849
|
+
"data-resize-handle": "true",
|
|
850
|
+
style: {
|
|
851
|
+
position: "absolute",
|
|
852
|
+
right: 0,
|
|
853
|
+
top: 0,
|
|
854
|
+
width: 4,
|
|
855
|
+
height: "100%",
|
|
856
|
+
cursor: "col-resize",
|
|
857
|
+
zIndex: 1
|
|
858
|
+
},
|
|
859
|
+
onMouseDown: (le) => u(d.id, le)
|
|
860
|
+
}
|
|
861
|
+
)
|
|
862
|
+
]
|
|
863
|
+
},
|
|
864
|
+
d.id
|
|
865
|
+
);
|
|
866
|
+
};
|
|
867
|
+
return /* @__PURE__ */ de(
|
|
868
|
+
"div",
|
|
869
|
+
{
|
|
870
|
+
ref: Y,
|
|
871
|
+
style: {
|
|
872
|
+
flex: 1,
|
|
873
|
+
height: h + 1,
|
|
874
|
+
overflow: "hidden",
|
|
875
|
+
position: "relative",
|
|
876
|
+
backgroundColor: "#f9fafb"
|
|
877
|
+
},
|
|
878
|
+
children: [
|
|
879
|
+
/* @__PURE__ */ de(
|
|
880
|
+
"div",
|
|
881
|
+
{
|
|
882
|
+
style: {
|
|
883
|
+
position: "absolute",
|
|
884
|
+
top: 0,
|
|
885
|
+
left: 0,
|
|
886
|
+
transform: `translateX(-${o}px)`,
|
|
887
|
+
height: h
|
|
888
|
+
},
|
|
889
|
+
children: [
|
|
890
|
+
/* @__PURE__ */ H("div", { style: { position: "absolute", top: 0, height: h }, children: R.map((d) => {
|
|
891
|
+
const M = t.getColumnX(d.id);
|
|
892
|
+
return K(d, M, h);
|
|
893
|
+
}) }),
|
|
894
|
+
D && /* @__PURE__ */ H("div", { style: { position: "relative", height: qe, zIndex: 1 }, children: C.filter((d) => !d.pinned).map((d) => /* @__PURE__ */ H(
|
|
895
|
+
"div",
|
|
896
|
+
{
|
|
897
|
+
style: {
|
|
898
|
+
position: "absolute",
|
|
899
|
+
left: d.startX,
|
|
900
|
+
width: d.width,
|
|
901
|
+
height: qe,
|
|
902
|
+
borderBottom: `1px solid ${d.group.color ?? "#3b82f6"}`,
|
|
903
|
+
display: "flex",
|
|
904
|
+
alignItems: "center",
|
|
905
|
+
paddingLeft: 8,
|
|
906
|
+
boxSizing: "border-box",
|
|
907
|
+
fontSize: 11,
|
|
908
|
+
fontWeight: 600,
|
|
909
|
+
color: "#6b7280",
|
|
910
|
+
overflow: "hidden",
|
|
911
|
+
whiteSpace: "nowrap",
|
|
912
|
+
backgroundColor: "#f9fafb"
|
|
913
|
+
},
|
|
914
|
+
children: d.group.title
|
|
915
|
+
},
|
|
916
|
+
d.group.id
|
|
917
|
+
)) })
|
|
918
|
+
]
|
|
919
|
+
}
|
|
920
|
+
),
|
|
921
|
+
f.length > 0 && /* @__PURE__ */ de(
|
|
922
|
+
"div",
|
|
923
|
+
{
|
|
924
|
+
style: {
|
|
925
|
+
position: "absolute",
|
|
926
|
+
top: 0,
|
|
927
|
+
left: 0,
|
|
928
|
+
width: L,
|
|
929
|
+
height: h,
|
|
930
|
+
backgroundColor: "#f9fafb",
|
|
931
|
+
zIndex: 2,
|
|
932
|
+
display: "flex",
|
|
933
|
+
flexDirection: "column"
|
|
934
|
+
},
|
|
935
|
+
children: [
|
|
936
|
+
D && /* @__PURE__ */ H("div", { style: { position: "absolute", top: 0, left: 0, width: L, height: h - Je }, children: C.filter((d) => d.pinned).map((d) => /* @__PURE__ */ H(
|
|
937
|
+
"div",
|
|
938
|
+
{
|
|
939
|
+
style: {
|
|
940
|
+
position: "absolute",
|
|
941
|
+
left: d.startX,
|
|
942
|
+
width: d.width,
|
|
943
|
+
height: "100%",
|
|
944
|
+
borderBottom: "1px solid #d1d5db",
|
|
945
|
+
borderRight: "1px solid #d1d5db",
|
|
946
|
+
display: "flex",
|
|
947
|
+
alignItems: "center",
|
|
948
|
+
justifyContent: "center",
|
|
949
|
+
boxSizing: "border-box",
|
|
950
|
+
fontSize: 11,
|
|
951
|
+
fontWeight: 600,
|
|
952
|
+
color: "#6b7280",
|
|
953
|
+
overflow: "hidden",
|
|
954
|
+
whiteSpace: "nowrap",
|
|
955
|
+
backgroundColor: "#f9fafb"
|
|
956
|
+
},
|
|
957
|
+
children: d.group.title
|
|
958
|
+
},
|
|
959
|
+
d.group.id
|
|
960
|
+
)) }),
|
|
961
|
+
/* @__PURE__ */ H("div", { style: { position: "absolute", bottom: 0, left: 0, width: L, height: Je, borderTop: "1px solid #d1d5db" }, children: f.map((d) => {
|
|
962
|
+
const M = t.getColumnX(d.id);
|
|
963
|
+
return K(d, M, Je);
|
|
964
|
+
}) }),
|
|
965
|
+
/* @__PURE__ */ H(
|
|
966
|
+
"div",
|
|
967
|
+
{
|
|
968
|
+
style: {
|
|
969
|
+
position: "absolute",
|
|
970
|
+
top: 0,
|
|
971
|
+
right: 0,
|
|
972
|
+
width: 1,
|
|
973
|
+
height: "100%",
|
|
974
|
+
backgroundColor: "#d1d5db",
|
|
975
|
+
zIndex: 3
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
)
|
|
979
|
+
]
|
|
980
|
+
}
|
|
981
|
+
),
|
|
982
|
+
/* @__PURE__ */ H("div", { style: { position: "absolute", bottom: 0, left: 0, right: 0, height: 1, backgroundColor: "#d1d5db", zIndex: 5 } }),
|
|
983
|
+
S && /* @__PURE__ */ H("div", { style: { position: "absolute", top: 0, left: B(), width: 2, height: h, backgroundColor: "#3b82f6", pointerEvents: "none", zIndex: 10 } }),
|
|
984
|
+
S && /* @__PURE__ */ H("div", { style: { position: "fixed", top: 0, left: S.currentX - S.ghostWidth / 2, width: S.ghostWidth, height: 32, backgroundColor: "#dbeafe", border: "1px solid #3b82f6", borderRadius: 4, display: "flex", alignItems: "center", paddingLeft: 8, boxSizing: "border-box", fontSize: 12, fontWeight: 600, color: "#1d4ed8", opacity: 0.85, pointerEvents: "none", zIndex: 9999, whiteSpace: "nowrap", overflow: "hidden" }, children: S.ghostTitle })
|
|
985
|
+
]
|
|
986
|
+
}
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
function ln({
|
|
990
|
+
columnEngine: t,
|
|
991
|
+
onColumnVisibilityChange: e
|
|
992
|
+
}) {
|
|
993
|
+
const [o, n] = ve(!1), r = ne(null), c = t.getAllColumns();
|
|
994
|
+
return re(() => {
|
|
995
|
+
if (!o) return;
|
|
996
|
+
const a = (f) => {
|
|
997
|
+
r.current && !r.current.contains(f.target) && n(!1);
|
|
998
|
+
}, m = (f) => {
|
|
999
|
+
f.key === "Escape" && n(!1);
|
|
1000
|
+
};
|
|
1001
|
+
return document.addEventListener("mousedown", a), document.addEventListener("keydown", m), () => {
|
|
1002
|
+
document.removeEventListener("mousedown", a), document.removeEventListener("keydown", m);
|
|
1003
|
+
};
|
|
1004
|
+
}, [o]), /* @__PURE__ */ de("div", { ref: r, style: { position: "relative", display: "inline-block" }, children: [
|
|
1005
|
+
/* @__PURE__ */ H(
|
|
1006
|
+
"button",
|
|
1007
|
+
{
|
|
1008
|
+
onClick: () => n((a) => !a),
|
|
1009
|
+
style: {
|
|
1010
|
+
display: "flex",
|
|
1011
|
+
alignItems: "center",
|
|
1012
|
+
gap: 4,
|
|
1013
|
+
padding: "0 8px",
|
|
1014
|
+
height: 28,
|
|
1015
|
+
fontSize: 12,
|
|
1016
|
+
fontWeight: 600,
|
|
1017
|
+
color: "#374151",
|
|
1018
|
+
backgroundColor: o ? "#e5e7eb" : "#f9fafb",
|
|
1019
|
+
border: "1px solid #d1d5db",
|
|
1020
|
+
borderRadius: 4,
|
|
1021
|
+
cursor: "pointer",
|
|
1022
|
+
whiteSpace: "nowrap"
|
|
1023
|
+
},
|
|
1024
|
+
title: "Toggle column visibility",
|
|
1025
|
+
children: "Columns"
|
|
1026
|
+
}
|
|
1027
|
+
),
|
|
1028
|
+
o && /* @__PURE__ */ H(
|
|
1029
|
+
"div",
|
|
1030
|
+
{
|
|
1031
|
+
style: {
|
|
1032
|
+
position: "absolute",
|
|
1033
|
+
top: "100%",
|
|
1034
|
+
left: 0,
|
|
1035
|
+
marginTop: 4,
|
|
1036
|
+
minWidth: 160,
|
|
1037
|
+
backgroundColor: "#ffffff",
|
|
1038
|
+
border: "1px solid #d1d5db",
|
|
1039
|
+
borderRadius: 6,
|
|
1040
|
+
boxShadow: "0 4px 12px rgba(0,0,0,0.12)",
|
|
1041
|
+
zIndex: 1e3,
|
|
1042
|
+
padding: "4px 0"
|
|
1043
|
+
},
|
|
1044
|
+
children: c.map((a) => {
|
|
1045
|
+
const m = !a.hidden;
|
|
1046
|
+
return /* @__PURE__ */ de(
|
|
1047
|
+
"label",
|
|
1048
|
+
{
|
|
1049
|
+
style: {
|
|
1050
|
+
display: "flex",
|
|
1051
|
+
alignItems: "center",
|
|
1052
|
+
gap: 8,
|
|
1053
|
+
padding: "6px 12px",
|
|
1054
|
+
cursor: "pointer",
|
|
1055
|
+
fontSize: 13,
|
|
1056
|
+
color: "#374151",
|
|
1057
|
+
userSelect: "none"
|
|
1058
|
+
},
|
|
1059
|
+
onMouseEnter: (f) => {
|
|
1060
|
+
f.currentTarget.style.backgroundColor = "#f3f4f6";
|
|
1061
|
+
},
|
|
1062
|
+
onMouseLeave: (f) => {
|
|
1063
|
+
f.currentTarget.style.backgroundColor = "";
|
|
1064
|
+
},
|
|
1065
|
+
children: [
|
|
1066
|
+
/* @__PURE__ */ H(
|
|
1067
|
+
"input",
|
|
1068
|
+
{
|
|
1069
|
+
type: "checkbox",
|
|
1070
|
+
checked: m,
|
|
1071
|
+
onChange: (f) => {
|
|
1072
|
+
e(a.id, f.target.checked);
|
|
1073
|
+
},
|
|
1074
|
+
style: { cursor: "pointer", width: 14, height: 14 }
|
|
1075
|
+
}
|
|
1076
|
+
),
|
|
1077
|
+
/* @__PURE__ */ H("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: a.title })
|
|
1078
|
+
]
|
|
1079
|
+
},
|
|
1080
|
+
a.id
|
|
1081
|
+
);
|
|
1082
|
+
})
|
|
1083
|
+
}
|
|
1084
|
+
)
|
|
1085
|
+
] });
|
|
1086
|
+
}
|
|
1087
|
+
function sn({ content: t, position: e }) {
|
|
1088
|
+
return Ft(
|
|
1089
|
+
/* @__PURE__ */ H(
|
|
1090
|
+
"div",
|
|
1091
|
+
{
|
|
1092
|
+
style: {
|
|
1093
|
+
position: "fixed",
|
|
1094
|
+
left: e.left,
|
|
1095
|
+
top: e.top,
|
|
1096
|
+
zIndex: 9999,
|
|
1097
|
+
pointerEvents: "none"
|
|
1098
|
+
},
|
|
1099
|
+
children: t
|
|
1100
|
+
}
|
|
1101
|
+
),
|
|
1102
|
+
document.body
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
function rn({ message: t }) {
|
|
1106
|
+
return /* @__PURE__ */ H(
|
|
1107
|
+
"div",
|
|
1108
|
+
{
|
|
1109
|
+
role: "status",
|
|
1110
|
+
"aria-live": "polite",
|
|
1111
|
+
"aria-atomic": "true",
|
|
1112
|
+
style: {
|
|
1113
|
+
position: "absolute",
|
|
1114
|
+
width: 1,
|
|
1115
|
+
height: 1,
|
|
1116
|
+
padding: 0,
|
|
1117
|
+
margin: -1,
|
|
1118
|
+
overflow: "hidden",
|
|
1119
|
+
clip: "rect(0,0,0,0)",
|
|
1120
|
+
whiteSpace: "nowrap",
|
|
1121
|
+
borderWidth: 0
|
|
1122
|
+
},
|
|
1123
|
+
children: t
|
|
1124
|
+
}
|
|
1125
|
+
);
|
|
1126
|
+
}
|
|
1127
|
+
const Ge = 24, Qe = 32;
|
|
1128
|
+
function dn(t) {
|
|
1129
|
+
const {
|
|
1130
|
+
treeEngine: e,
|
|
1131
|
+
columnEngine: o,
|
|
1132
|
+
columnGroups: n,
|
|
1133
|
+
rowHeight: r,
|
|
1134
|
+
sidebarWidth: c,
|
|
1135
|
+
gridLayerConfig: a,
|
|
1136
|
+
cellLayerConfig: m,
|
|
1137
|
+
scale: f = 2
|
|
1138
|
+
} = t, R = n != null && n.length > 0, y = R ? Ge + Qe : Qe, L = o.getVisibleColumns(), O = e.flattenedRows, W = o.getTotalWidth(), S = O.length * r, G = c + W, $ = y + S, X = document.createElement("canvas");
|
|
1139
|
+
X.width = Math.round(G * f), X.height = Math.round($ * f), X.style.width = `${G}px`, X.style.height = `${$}px`;
|
|
1140
|
+
const l = X.getContext("2d");
|
|
1141
|
+
l.setTransform(f, 0, 0, f, 0, 0), l.fillStyle = "#ffffff", l.fillRect(0, 0, G, $);
|
|
1142
|
+
const Y = new St({
|
|
1143
|
+
scrollX: 0,
|
|
1144
|
+
scrollY: 0,
|
|
1145
|
+
canvasWidth: W,
|
|
1146
|
+
canvasHeight: S,
|
|
1147
|
+
rowHeight: r
|
|
1148
|
+
}), T = [], C = [];
|
|
1149
|
+
let D = 0;
|
|
1150
|
+
for (const u of L)
|
|
1151
|
+
T.push(D), C.push(u.width), D += u.width;
|
|
1152
|
+
Y.setColumnOffsets(T), Y.setColumnWidths(C), l.save(), l.translate(c, y), kt(l, Y, e, o, a), _t(l, Y, e, o, t.selectionEngine, m), l.restore(), l.save(), l.translate(0, y);
|
|
1153
|
+
const w = "#ffffff";
|
|
1154
|
+
l.fillStyle = w, l.fillRect(0, 0, c, S), l.strokeStyle = "#e5e7eb", l.lineWidth = 0.5, l.beginPath(), l.moveTo(c, 0), l.lineTo(c, S), l.stroke(), l.font = "13px system-ui, sans-serif", l.textBaseline = "middle", l.fillStyle = "#374151";
|
|
1155
|
+
for (let u = 0; u < O.length; u++) {
|
|
1156
|
+
const x = O[u];
|
|
1157
|
+
if (!x) continue;
|
|
1158
|
+
const F = e.getDepth(x.id), B = u * r, K = F * 16 + 8, d = String(x.title ?? x.id), M = c - K - 8;
|
|
1159
|
+
l.fillStyle = u % 2 === 0 ? "#ffffff" : "#f9fafb", l.fillRect(0, B, c, r), l.strokeStyle = "#e5e7eb", l.lineWidth = 0.5, l.beginPath(), l.moveTo(0, B + r), l.lineTo(c, B + r), l.stroke(), l.fillStyle = "#374151";
|
|
1160
|
+
let P = d;
|
|
1161
|
+
if (l.measureText(P).width > M && M > 0) {
|
|
1162
|
+
for (; P.length > 0 && l.measureText(P + "…").width > M; )
|
|
1163
|
+
P = P.slice(0, -1);
|
|
1164
|
+
P = P + "…";
|
|
1165
|
+
}
|
|
1166
|
+
l.fillText(P, K, B + r / 2);
|
|
1167
|
+
}
|
|
1168
|
+
if (l.restore(), l.save(), l.translate(0, 0), l.fillStyle = "#f9fafb", l.fillRect(0, 0, G, y), l.strokeStyle = "#e5e7eb", l.lineWidth = 1, l.beginPath(), l.moveTo(0, y), l.lineTo(G, y), l.stroke(), l.fillStyle = "#f9fafb", l.fillRect(0, 0, c, y), l.strokeStyle = "#e5e7eb", l.lineWidth = 0.5, l.beginPath(), l.moveTo(c, 0), l.lineTo(c, y), l.stroke(), R && n) {
|
|
1169
|
+
const u = /* @__PURE__ */ new Map();
|
|
1170
|
+
for (const d of n)
|
|
1171
|
+
u.set(d.id, d);
|
|
1172
|
+
let x, F = 0, B = 0;
|
|
1173
|
+
const K = (d, M, P) => {
|
|
1174
|
+
if (d === void 0 || P <= 0) return;
|
|
1175
|
+
const z = u.get(d);
|
|
1176
|
+
if (!z) return;
|
|
1177
|
+
const V = c + M;
|
|
1178
|
+
l.fillStyle = z.color ?? "#3b82f6", l.fillRect(V, Ge - 2, P, 2), l.font = "600 11px system-ui, sans-serif", l.fillStyle = "#6b7280", l.textBaseline = "middle", l.textAlign = "left", l.fillText(z.title, V + 8, Ge / 2);
|
|
1179
|
+
};
|
|
1180
|
+
for (const d of L) {
|
|
1181
|
+
const M = o.getColumnX(d.id);
|
|
1182
|
+
d.group !== x ? (K(x, F, B), x = d.group, F = M, B = d.width) : B += d.width;
|
|
1183
|
+
}
|
|
1184
|
+
K(x, F, B);
|
|
1185
|
+
}
|
|
1186
|
+
const h = R ? Ge : 0;
|
|
1187
|
+
l.font = "600 12px system-ui, sans-serif", l.textBaseline = "middle", l.textAlign = "left", l.fillStyle = "#374151";
|
|
1188
|
+
for (const u of L) {
|
|
1189
|
+
const x = o.getColumnX(u.id), F = c + x;
|
|
1190
|
+
l.strokeStyle = "#e5e7eb", l.lineWidth = 0.5, l.beginPath(), l.moveTo(F + u.width, h), l.lineTo(F + u.width, y), l.stroke(), l.fillStyle = "#374151";
|
|
1191
|
+
const B = u.width - 16;
|
|
1192
|
+
let K = u.title;
|
|
1193
|
+
if (B > 0 && l.measureText(K).width > B) {
|
|
1194
|
+
for (; K.length > 0 && l.measureText(K + "…").width > B; )
|
|
1195
|
+
K = K.slice(0, -1);
|
|
1196
|
+
K = K + "…";
|
|
1197
|
+
}
|
|
1198
|
+
l.fillText(K, F + 8, h + Qe / 2);
|
|
1199
|
+
}
|
|
1200
|
+
return l.restore(), X;
|
|
1201
|
+
}
|
|
1202
|
+
const yt = 180, xt = 32, cn = 24, It = 200;
|
|
1203
|
+
function Rt(t, e) {
|
|
1204
|
+
let o;
|
|
1205
|
+
switch (t) {
|
|
1206
|
+
case "vertical":
|
|
1207
|
+
o = 120;
|
|
1208
|
+
break;
|
|
1209
|
+
default:
|
|
1210
|
+
o = 32;
|
|
1211
|
+
}
|
|
1212
|
+
return e ? cn + o : o;
|
|
1213
|
+
}
|
|
1214
|
+
const un = $t(
|
|
1215
|
+
Bt(function(e, o) {
|
|
1216
|
+
const {
|
|
1217
|
+
rows: n,
|
|
1218
|
+
columns: r,
|
|
1219
|
+
columnGroups: c,
|
|
1220
|
+
getCellData: a,
|
|
1221
|
+
cellRenderer: m,
|
|
1222
|
+
sidebarRenderer: f,
|
|
1223
|
+
sidebarWidth: R = yt,
|
|
1224
|
+
rowHeight: y = xt,
|
|
1225
|
+
headerOrientation: L = "horizontal",
|
|
1226
|
+
rowStyle: O,
|
|
1227
|
+
selection: W,
|
|
1228
|
+
onSelectionChange: S,
|
|
1229
|
+
onCellClick: G,
|
|
1230
|
+
onCellDoubleClick: $,
|
|
1231
|
+
onCellContextMenu: X,
|
|
1232
|
+
onCellHover: l,
|
|
1233
|
+
onColumnHeaderClick: Y,
|
|
1234
|
+
onTreeToggle: T,
|
|
1235
|
+
defaultExpandedRows: C,
|
|
1236
|
+
onExpandChange: D,
|
|
1237
|
+
onLoadMore: w,
|
|
1238
|
+
hasMore: h,
|
|
1239
|
+
loading: u,
|
|
1240
|
+
hoverContent: x,
|
|
1241
|
+
hoverPosition: F,
|
|
1242
|
+
showColumnVisibilityMenu: B,
|
|
1243
|
+
ariaLabel: K = "Data grid"
|
|
1244
|
+
} = e, [d, M] = ve(
|
|
1245
|
+
() => new Set(C ?? [])
|
|
1246
|
+
), [P, z] = ve(0), [V, q] = ve(0), [J, Q] = ve(r), [le, Pe] = ve(null), [Tt, Ce] = ve(""), [Mt, $e] = ve(null), Ee = ne(null), Ze = ne(null);
|
|
1247
|
+
re(() => {
|
|
1248
|
+
Q(r);
|
|
1249
|
+
}, [r]);
|
|
1250
|
+
const et = ne(null), pe = ne([]), ce = ne(new St({ rowHeight: y })), N = ne(null), A = ne(e), fe = ne(null), Le = ne(null), Oe = ne(!1);
|
|
1251
|
+
A.current = e;
|
|
1252
|
+
const ke = Ne(
|
|
1253
|
+
() => new Nt(n, d),
|
|
1254
|
+
[n, d]
|
|
1255
|
+
), se = Ne(() => new Ie(J), [J]), tt = Ne(() => new qt(W), [W]);
|
|
1256
|
+
fe.current = { treeEngine: ke, columnEngine: se, selectionEngine: tt };
|
|
1257
|
+
const Be = se.getPinnedColumns().length > 0, _e = Be ? 0 : R, nt = te((i) => {
|
|
1258
|
+
const g = fe.current;
|
|
1259
|
+
if (!g) return;
|
|
1260
|
+
const { treeEngine: I, columnEngine: _, selectionEngine: v } = g, b = ce.current, s = i === "grid" ? 0 : i === "cells" ? 1 : 2, p = pe.current[s];
|
|
1261
|
+
if (!p) return;
|
|
1262
|
+
const k = Jt(p, b.canvasWidth, b.canvasHeight);
|
|
1263
|
+
i === "grid" ? kt(k, b, I, _, { rowStyle: A.current.rowStyle }) : i === "cells" ? _t(k, b, I, _, v, {
|
|
1264
|
+
cellRenderer: A.current.cellRenderer,
|
|
1265
|
+
getCellData: A.current.getCellData,
|
|
1266
|
+
hoveredCell: Le.current
|
|
1267
|
+
}) : Zt(k, b, I, _, v, {
|
|
1268
|
+
hoveredCell: Le.current,
|
|
1269
|
+
hoveredRowId: Ee.current,
|
|
1270
|
+
selectedCell: Ze.current,
|
|
1271
|
+
resizingColumn: le ?? void 0,
|
|
1272
|
+
loading: A.current.loading
|
|
1273
|
+
});
|
|
1274
|
+
}, [le]);
|
|
1275
|
+
re(() => {
|
|
1276
|
+
const i = se.getPinnedColumns(), g = se.getScrollableColumns(), I = se.getPinnedWidth(), _ = [], v = [];
|
|
1277
|
+
let b = 0;
|
|
1278
|
+
for (const oe of i)
|
|
1279
|
+
_.push(b), v.push(oe.width), b += oe.width;
|
|
1280
|
+
const s = [], p = [];
|
|
1281
|
+
let k = 0;
|
|
1282
|
+
for (const oe of g)
|
|
1283
|
+
s.push(k), p.push(oe.width), k += oe.width;
|
|
1284
|
+
const E = ce.current;
|
|
1285
|
+
E.pinnedWidth = I, E.setPinnedOffsets(_, v), E.setScrollableOffsets(s, p);
|
|
1286
|
+
const U = se.getVisibleColumns(), Z = [], ae = [];
|
|
1287
|
+
let ye = 0;
|
|
1288
|
+
for (const oe of U)
|
|
1289
|
+
Z.push(ye), ae.push(oe.width), ye += oe.width;
|
|
1290
|
+
E.setColumnOffsets(Z), E.setColumnWidths(ae), E.update({ rowHeight: y });
|
|
1291
|
+
}, [se, y]), re(() => {
|
|
1292
|
+
const i = new Ut(nt);
|
|
1293
|
+
return N.current = i, i.markAllDirty(), () => {
|
|
1294
|
+
i.destroy(), N.current = null;
|
|
1295
|
+
};
|
|
1296
|
+
}, [nt]), re(() => {
|
|
1297
|
+
const i = et.current;
|
|
1298
|
+
if (!i) return;
|
|
1299
|
+
const g = new ResizeObserver((I) => {
|
|
1300
|
+
var _, v;
|
|
1301
|
+
for (const b of I) {
|
|
1302
|
+
const { width: s, height: p } = b.contentRect, k = s - _e, E = Rt(A.current.headerOrientation ?? "horizontal", (((_ = A.current.columnGroups) == null ? void 0 : _.length) ?? 0) > 0), U = p - E;
|
|
1303
|
+
ce.current.update({
|
|
1304
|
+
canvasWidth: Math.max(0, k),
|
|
1305
|
+
canvasHeight: Math.max(0, U)
|
|
1306
|
+
}), (v = N.current) == null || v.markAllDirty();
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
return g.observe(i), () => g.disconnect();
|
|
1310
|
+
}, [_e]), re(() => {
|
|
1311
|
+
var i;
|
|
1312
|
+
(i = N.current) == null || i.markAllDirty();
|
|
1313
|
+
}, [ke, se, tt]), re(() => {
|
|
1314
|
+
var i;
|
|
1315
|
+
(i = N.current) == null || i.markDirty("overlay");
|
|
1316
|
+
}, [u]);
|
|
1317
|
+
const Ke = te((i) => {
|
|
1318
|
+
var ae;
|
|
1319
|
+
i.preventDefault();
|
|
1320
|
+
const g = ce.current, I = fe.current;
|
|
1321
|
+
if (!I) return;
|
|
1322
|
+
const _ = I.treeEngine.flattenedRows.length * g.rowHeight, v = I.columnEngine.getTotalWidth(), b = Math.max(0, _ - g.canvasHeight), s = v - I.columnEngine.getPinnedWidth(), p = g.canvasWidth - I.columnEngine.getPinnedWidth(), k = Math.max(0, s - p), E = Math.max(0, Math.min(b, g.scrollY + i.deltaY)), U = Math.max(0, Math.min(k, g.scrollX + i.deltaX));
|
|
1323
|
+
g.update({ scrollY: E, scrollX: U }), z(E), q(U), (ae = N.current) == null || ae.markAllDirty();
|
|
1324
|
+
const Z = A.current;
|
|
1325
|
+
Z.hasMore && Z.onLoadMore && !Z.loading && b - E < It ? Oe.current || (Oe.current = !0, Z.onLoadMore()) : b - E >= It && (Oe.current = !1);
|
|
1326
|
+
}, []);
|
|
1327
|
+
re(() => {
|
|
1328
|
+
const i = pe.current[2];
|
|
1329
|
+
if (i)
|
|
1330
|
+
return i.addEventListener("wheel", Ke, { passive: !1 }), () => i.removeEventListener("wheel", Ke);
|
|
1331
|
+
}, [Ke]), re(() => {
|
|
1332
|
+
u || (Oe.current = !1);
|
|
1333
|
+
}, [u]);
|
|
1334
|
+
const Wt = te((i) => {
|
|
1335
|
+
var p, k, E;
|
|
1336
|
+
const g = fe.current;
|
|
1337
|
+
if (!g) return;
|
|
1338
|
+
const I = pe.current[2];
|
|
1339
|
+
if (!I) return;
|
|
1340
|
+
const _ = I.getBoundingClientRect(), v = i.clientX - _.left, b = i.clientY - _.top, s = Ve(v, b, ce.current, g.treeEngine, g.columnEngine);
|
|
1341
|
+
Le.current = s, Ee.current = (s == null ? void 0 : s.rowId) ?? null, $e((s == null ? void 0 : s.rowId) ?? null), (p = N.current) == null || p.markDirty("overlay"), (E = (k = A.current).onCellHover) == null || E.call(k, (s == null ? void 0 : s.rowId) ?? null, (s == null ? void 0 : s.colId) ?? null, i.nativeEvent);
|
|
1342
|
+
}, []), Fe = te((i) => {
|
|
1343
|
+
M((g) => {
|
|
1344
|
+
var _, v;
|
|
1345
|
+
const I = new Set(g);
|
|
1346
|
+
return I.has(i) ? (I.delete(i), Ce(`Row ${i} collapsed`)) : (I.add(i), Ce(`Row ${i} expanded`)), (v = (_ = A.current).onExpandChange) == null || v.call(_, [...I]), I;
|
|
1347
|
+
});
|
|
1348
|
+
}, []), Dt = te((i) => {
|
|
1349
|
+
var Te, Me, We, De, Xe;
|
|
1350
|
+
const g = fe.current;
|
|
1351
|
+
if (!g) return;
|
|
1352
|
+
const I = pe.current[2];
|
|
1353
|
+
if (!I) return;
|
|
1354
|
+
const _ = I.getBoundingClientRect(), v = i.clientX - _.left, b = i.clientY - _.top, s = Ve(v, b, ce.current, g.treeEngine, g.columnEngine);
|
|
1355
|
+
if (!s) return;
|
|
1356
|
+
const { treeEngine: p, columnEngine: k, selectionEngine: E } = g, U = k.getPinnedColumns();
|
|
1357
|
+
if (U.length > 0) {
|
|
1358
|
+
const ue = U[0].id;
|
|
1359
|
+
if (p.hasChildren(s.rowId) && s.colId === ue) {
|
|
1360
|
+
A.current.onTreeToggle ? A.current.onTreeToggle(s.rowId) : Fe(s.rowId);
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
const Z = p.flattenedRows.map((ue) => ue.id), ae = k.getVisibleColumns().map((ue) => ue.id);
|
|
1365
|
+
i.ctrlKey || i.metaKey ? E.ctrlClick(s.rowId, s.colId) : i.shiftKey ? E.shiftClick(s.rowId, s.colId, Z, ae) : E.click(s.rowId, s.colId, Z, ae), Ze.current = { rowId: s.rowId, colId: s.colId }, (Me = (Te = A.current).onSelectionChange) == null || Me.call(Te, E.getSelection()), (De = (We = A.current).onCellClick) == null || De.call(We, s.rowId, s.colId, i.nativeEvent), (Xe = N.current) == null || Xe.markDirty("overlay");
|
|
1366
|
+
const ye = String(s.rowId), oe = k.getVisibleColumns().find((ue) => ue.id === s.colId), ze = (oe == null ? void 0 : oe.title) ?? s.colId;
|
|
1367
|
+
Ce(`Row ${ye}, Column ${ze} selected`);
|
|
1368
|
+
}, [Fe]), Xt = te((i) => {
|
|
1369
|
+
var p, k;
|
|
1370
|
+
const g = fe.current;
|
|
1371
|
+
if (!g) return;
|
|
1372
|
+
const I = pe.current[2];
|
|
1373
|
+
if (!I) return;
|
|
1374
|
+
const _ = I.getBoundingClientRect(), v = i.clientX - _.left, b = i.clientY - _.top, s = Ve(v, b, ce.current, g.treeEngine, g.columnEngine);
|
|
1375
|
+
s && ((k = (p = A.current).onCellDoubleClick) == null || k.call(p, s.rowId, s.colId, i.nativeEvent));
|
|
1376
|
+
}, []), Ht = te((i) => {
|
|
1377
|
+
var p, k;
|
|
1378
|
+
i.preventDefault();
|
|
1379
|
+
const g = fe.current;
|
|
1380
|
+
if (!g) return;
|
|
1381
|
+
const I = pe.current[2];
|
|
1382
|
+
if (!I) return;
|
|
1383
|
+
const _ = I.getBoundingClientRect(), v = i.clientX - _.left, b = i.clientY - _.top, s = Ve(v, b, ce.current, g.treeEngine, g.columnEngine);
|
|
1384
|
+
s && ((k = (p = A.current).onCellContextMenu) == null || k.call(p, s.rowId, s.colId, i.nativeEvent));
|
|
1385
|
+
}, []), Pt = te(() => {
|
|
1386
|
+
var i, g, I;
|
|
1387
|
+
Le.current = null, Ee.current = null, $e(null), (i = N.current) == null || i.markDirty("overlay"), (I = (g = A.current).onCellHover) == null || I.call(g, null, null, new PointerEvent("pointerleave"));
|
|
1388
|
+
}, []), Et = te(
|
|
1389
|
+
(i, g) => {
|
|
1390
|
+
var I, _;
|
|
1391
|
+
(_ = (I = A.current).onColumnHeaderClick) == null || _.call(I, i, g.nativeEvent);
|
|
1392
|
+
},
|
|
1393
|
+
[]
|
|
1394
|
+
), Lt = te(
|
|
1395
|
+
(i, g) => {
|
|
1396
|
+
var _, v, b, s;
|
|
1397
|
+
Q((p) => p.map((E) => {
|
|
1398
|
+
if (E.id !== i) return E;
|
|
1399
|
+
const U = E.minWidth ?? 30;
|
|
1400
|
+
return { ...E, width: Math.max(U, g) };
|
|
1401
|
+
}));
|
|
1402
|
+
const I = (_ = fe.current) == null ? void 0 : _.columnEngine;
|
|
1403
|
+
if (I) {
|
|
1404
|
+
const p = I.getColumnX(i), k = I.getVisibleColumns().find((E) => E.id === i);
|
|
1405
|
+
if (k) {
|
|
1406
|
+
const U = k.pinned === "left" ? p + Math.max(k.minWidth ?? 30, g) : p + Math.max(k.minWidth ?? 30, g) - ce.current.scrollX;
|
|
1407
|
+
Pe({ colId: i, x: U });
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
(b = (v = A.current).onColumnResize) == null || b.call(v, i, g), (s = N.current) == null || s.markAllDirty();
|
|
1411
|
+
},
|
|
1412
|
+
[]
|
|
1413
|
+
);
|
|
1414
|
+
re(() => {
|
|
1415
|
+
const i = () => {
|
|
1416
|
+
Pe(null);
|
|
1417
|
+
};
|
|
1418
|
+
return document.addEventListener("mouseup", i), () => document.removeEventListener("mouseup", i);
|
|
1419
|
+
}, []);
|
|
1420
|
+
const Ot = te(
|
|
1421
|
+
(i, g) => {
|
|
1422
|
+
var I, _, v;
|
|
1423
|
+
Q((b) => {
|
|
1424
|
+
const s = [...b], p = s.findIndex((U) => U.id === i);
|
|
1425
|
+
if (p === -1) return b;
|
|
1426
|
+
const [k] = s.splice(p, 1), E = Math.max(0, Math.min(g, s.length));
|
|
1427
|
+
return s.splice(E, 0, k), s;
|
|
1428
|
+
}), (_ = (I = A.current).onColumnReorder) == null || _.call(I, i, g), (v = N.current) == null || v.markAllDirty();
|
|
1429
|
+
},
|
|
1430
|
+
[]
|
|
1431
|
+
), zt = te(
|
|
1432
|
+
(i, g) => {
|
|
1433
|
+
var I, _, v;
|
|
1434
|
+
Q(
|
|
1435
|
+
(b) => b.map((s) => s.id === i ? { ...s, hidden: !g } : s)
|
|
1436
|
+
), (_ = (I = A.current).onColumnVisibilityChange) == null || _.call(I, i, g), (v = N.current) == null || v.markAllDirty();
|
|
1437
|
+
},
|
|
1438
|
+
[]
|
|
1439
|
+
), At = te((i) => {
|
|
1440
|
+
var ae, ye, oe, ze, Te, Me, We, De, Xe, ue, Ue, it, lt, st, rt, dt, ct, at, ht, ft, ut, gt, pt, mt;
|
|
1441
|
+
const g = fe.current;
|
|
1442
|
+
if (!g) return;
|
|
1443
|
+
const { treeEngine: I, columnEngine: _, selectionEngine: v } = g, b = ce.current, s = I.flattenedRows.map((j) => j.id), p = _.getVisibleColumns().map((j) => j.id);
|
|
1444
|
+
if (s.length === 0 || p.length === 0) return;
|
|
1445
|
+
const k = v.getSelection().anchor, E = i.ctrlKey || i.metaKey, U = (j, ee) => {
|
|
1446
|
+
const ie = s.length * b.rowHeight, me = _.getTotalWidth(), we = Math.max(0, ie - b.canvasHeight), Ae = Math.max(0, me - b.canvasWidth), xe = j * b.rowHeight, Re = xe + b.rowHeight;
|
|
1447
|
+
let he = b.scrollY;
|
|
1448
|
+
xe < b.scrollY ? he = xe : Re > b.scrollY + b.canvasHeight && (he = Re - b.canvasHeight), he = Math.max(0, Math.min(we, he));
|
|
1449
|
+
const be = _.getVisibleColumns()[ee], He = be ? _.getColumnX(be.id) : 0, Ye = He + ((be == null ? void 0 : be.width) ?? 0);
|
|
1450
|
+
let ge = b.scrollX;
|
|
1451
|
+
He < b.scrollX ? ge = He : Ye > b.scrollX + b.canvasWidth && (ge = Ye - b.canvasWidth), ge = Math.max(0, Math.min(Ae, ge)), (he !== b.scrollY || ge !== b.scrollX) && (b.update({ scrollY: he, scrollX: ge }), z(he), q(ge));
|
|
1452
|
+
}, Z = (j, ee, ie) => {
|
|
1453
|
+
var wt, bt, vt;
|
|
1454
|
+
let me = k ? s.indexOf(k.rowId) : -1, we = k ? p.indexOf(k.colId) : -1;
|
|
1455
|
+
me === -1 && (me = 0), we === -1 && (we = 0);
|
|
1456
|
+
const Ae = Math.max(0, Math.min(s.length - 1, me + j)), xe = Math.max(0, Math.min(p.length - 1, we + ee)), Re = s[Ae], he = p[xe];
|
|
1457
|
+
ie ? v.shiftClick(Re, he, s, p) : v.click(Re, he, s, p), (bt = (wt = A.current).onSelectionChange) == null || bt.call(wt, v.getSelection()), (vt = N.current) == null || vt.markDirty("overlay"), U(Ae, xe);
|
|
1458
|
+
const be = _.getVisibleColumns()[xe], He = String(Re), Ye = (be == null ? void 0 : be.title) ?? String(he), ge = v.getSelection().cells.size;
|
|
1459
|
+
ge > 1 ? Ce(`${ge} cells selected`) : Ce(`Row ${He}, Column ${Ye} selected`);
|
|
1460
|
+
};
|
|
1461
|
+
switch (i.key) {
|
|
1462
|
+
case "ArrowUp":
|
|
1463
|
+
i.preventDefault(), Z(-1, 0, i.shiftKey);
|
|
1464
|
+
break;
|
|
1465
|
+
case "ArrowDown":
|
|
1466
|
+
i.preventDefault(), Z(1, 0, i.shiftKey);
|
|
1467
|
+
break;
|
|
1468
|
+
case "ArrowLeft":
|
|
1469
|
+
i.preventDefault(), Z(0, -1, i.shiftKey);
|
|
1470
|
+
break;
|
|
1471
|
+
case "ArrowRight":
|
|
1472
|
+
i.preventDefault(), Z(0, 1, i.shiftKey);
|
|
1473
|
+
break;
|
|
1474
|
+
case "Tab": {
|
|
1475
|
+
if (i.preventDefault(), i.shiftKey) {
|
|
1476
|
+
const j = k ? s.indexOf(k.rowId) : 0;
|
|
1477
|
+
if ((k ? p.indexOf(k.colId) : 0) > 0)
|
|
1478
|
+
Z(0, -1, !1);
|
|
1479
|
+
else {
|
|
1480
|
+
const ie = Math.max(0, (j === -1 ? 0 : j) - 1), me = s[ie], we = p[p.length - 1];
|
|
1481
|
+
v.click(me, we, s, p), (Te = (ze = A.current).onSelectionChange) == null || Te.call(ze, v.getSelection()), (Me = N.current) == null || Me.markDirty("overlay"), U(ie, p.length - 1);
|
|
1482
|
+
}
|
|
1483
|
+
} else {
|
|
1484
|
+
const j = k ? s.indexOf(k.rowId) : 0;
|
|
1485
|
+
if ((k ? p.indexOf(k.colId) : -1) < p.length - 1)
|
|
1486
|
+
Z(0, 1, !1);
|
|
1487
|
+
else {
|
|
1488
|
+
const ie = Math.min(s.length - 1, (j === -1 ? 0 : j) + 1), me = s[ie], we = p[0];
|
|
1489
|
+
v.click(me, we, s, p), (ye = (ae = A.current).onSelectionChange) == null || ye.call(ae, v.getSelection()), (oe = N.current) == null || oe.markDirty("overlay"), U(ie, 0);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
case "Escape":
|
|
1495
|
+
i.preventDefault(), v.clear(), (De = (We = A.current).onSelectionChange) == null || De.call(We, v.getSelection()), (Xe = N.current) == null || Xe.markDirty("overlay"), Ce("Selection cleared");
|
|
1496
|
+
break;
|
|
1497
|
+
case "a":
|
|
1498
|
+
case "A":
|
|
1499
|
+
if (E) {
|
|
1500
|
+
i.preventDefault();
|
|
1501
|
+
for (const j of s)
|
|
1502
|
+
for (const ee of p)
|
|
1503
|
+
v.ctrlClick(j, ee);
|
|
1504
|
+
(Ue = (ue = A.current).onSelectionChange) == null || Ue.call(ue, v.getSelection()), (it = N.current) == null || it.markDirty("overlay"), Ce(`${s.length * p.length} cells selected`);
|
|
1505
|
+
}
|
|
1506
|
+
break;
|
|
1507
|
+
case "Home": {
|
|
1508
|
+
i.preventDefault();
|
|
1509
|
+
const j = k ? s.indexOf(k.rowId) : 0;
|
|
1510
|
+
if (E)
|
|
1511
|
+
v.click(s[0], p[0], s, p), (st = (lt = A.current).onSelectionChange) == null || st.call(lt, v.getSelection()), (rt = N.current) == null || rt.markDirty("overlay"), U(0, 0);
|
|
1512
|
+
else {
|
|
1513
|
+
const ee = j === -1 ? 0 : j;
|
|
1514
|
+
v.click(s[ee], p[0], s, p), (ct = (dt = A.current).onSelectionChange) == null || ct.call(dt, v.getSelection()), (at = N.current) == null || at.markDirty("overlay"), U(ee, 0);
|
|
1515
|
+
}
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1518
|
+
case "End": {
|
|
1519
|
+
i.preventDefault();
|
|
1520
|
+
const j = k ? s.indexOf(k.rowId) : 0;
|
|
1521
|
+
if (E) {
|
|
1522
|
+
const ee = s.length - 1, ie = p.length - 1;
|
|
1523
|
+
v.click(s[ee], p[ie], s, p), (ft = (ht = A.current).onSelectionChange) == null || ft.call(ht, v.getSelection()), (ut = N.current) == null || ut.markDirty("overlay"), U(ee, ie);
|
|
1524
|
+
} else {
|
|
1525
|
+
const ee = j === -1 ? 0 : j, ie = p.length - 1;
|
|
1526
|
+
v.click(s[ee], p[ie], s, p), (pt = (gt = A.current).onSelectionChange) == null || pt.call(gt, v.getSelection()), (mt = N.current) == null || mt.markDirty("overlay"), U(ee, ie);
|
|
1527
|
+
}
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
}, []);
|
|
1532
|
+
Kt(o, () => ({
|
|
1533
|
+
captureToCanvas(i) {
|
|
1534
|
+
const g = fe.current;
|
|
1535
|
+
if (!g)
|
|
1536
|
+
throw new Error("CanvasGrid: engines not initialized");
|
|
1537
|
+
const { treeEngine: I, columnEngine: _, selectionEngine: v } = g, b = A.current, s = b.rowHeight ?? xt, p = b.sidebarWidth ?? yt;
|
|
1538
|
+
return dn({
|
|
1539
|
+
treeEngine: I,
|
|
1540
|
+
columnEngine: _,
|
|
1541
|
+
selectionEngine: v,
|
|
1542
|
+
columnGroups: b.columnGroups,
|
|
1543
|
+
rowHeight: s,
|
|
1544
|
+
sidebarWidth: p,
|
|
1545
|
+
gridLayerConfig: { rowStyle: b.rowStyle },
|
|
1546
|
+
cellLayerConfig: {
|
|
1547
|
+
cellRenderer: b.cellRenderer,
|
|
1548
|
+
getCellData: b.getCellData,
|
|
1549
|
+
hoveredCell: null
|
|
1550
|
+
},
|
|
1551
|
+
scale: (i == null ? void 0 : i.scale) ?? 2
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
}), []);
|
|
1555
|
+
const Yt = c != null && c.length > 0, ot = Rt(L ?? "horizontal", Yt), Vt = _e + se.getTotalWidth() + 2, Gt = ot + ke.flattenedRows.length * y + 2;
|
|
1556
|
+
return /* @__PURE__ */ de(
|
|
1557
|
+
"div",
|
|
1558
|
+
{
|
|
1559
|
+
ref: et,
|
|
1560
|
+
tabIndex: 0,
|
|
1561
|
+
role: "grid",
|
|
1562
|
+
"aria-label": K,
|
|
1563
|
+
"aria-rowcount": ke.flattenedRows.length,
|
|
1564
|
+
"aria-colcount": se.getVisibleColumns().length,
|
|
1565
|
+
onKeyDown: At,
|
|
1566
|
+
style: {
|
|
1567
|
+
display: "flex",
|
|
1568
|
+
flexDirection: "column",
|
|
1569
|
+
width: Vt,
|
|
1570
|
+
height: Gt,
|
|
1571
|
+
maxWidth: "100%",
|
|
1572
|
+
maxHeight: "100%",
|
|
1573
|
+
overflow: "hidden",
|
|
1574
|
+
fontFamily: "system-ui, sans-serif",
|
|
1575
|
+
outline: "none",
|
|
1576
|
+
border: "1px solid #d1d5db",
|
|
1577
|
+
borderRadius: 4
|
|
1578
|
+
},
|
|
1579
|
+
children: [
|
|
1580
|
+
/* @__PURE__ */ de("div", { style: { display: "flex", flexDirection: "row", height: ot, flexShrink: 0 }, children: [
|
|
1581
|
+
!Be && /* @__PURE__ */ H(
|
|
1582
|
+
"div",
|
|
1583
|
+
{
|
|
1584
|
+
style: {
|
|
1585
|
+
width: _e,
|
|
1586
|
+
flexShrink: 0,
|
|
1587
|
+
borderRight: "1px solid #e5e7eb",
|
|
1588
|
+
borderBottom: "1px solid #e5e7eb",
|
|
1589
|
+
backgroundColor: "#f9fafb",
|
|
1590
|
+
display: "flex",
|
|
1591
|
+
flexDirection: "column",
|
|
1592
|
+
overflow: "hidden"
|
|
1593
|
+
},
|
|
1594
|
+
children: e.sidebarHeaderRenderer ? /* @__PURE__ */ H("div", { style: { width: "100%", flex: 1 }, children: e.sidebarHeaderRenderer() }) : B ? /* @__PURE__ */ H("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", flex: 1 }, children: /* @__PURE__ */ H(
|
|
1595
|
+
ln,
|
|
1596
|
+
{
|
|
1597
|
+
columnEngine: se,
|
|
1598
|
+
onColumnVisibilityChange: zt
|
|
1599
|
+
}
|
|
1600
|
+
) }) : null
|
|
1601
|
+
}
|
|
1602
|
+
),
|
|
1603
|
+
/* @__PURE__ */ H(
|
|
1604
|
+
on,
|
|
1605
|
+
{
|
|
1606
|
+
columnEngine: se,
|
|
1607
|
+
columnGroups: c,
|
|
1608
|
+
scrollX: V,
|
|
1609
|
+
orientation: L,
|
|
1610
|
+
onColumnClick: Y ? Et : void 0,
|
|
1611
|
+
onColumnResize: e.onColumnResize !== void 0 ? Lt : void 0,
|
|
1612
|
+
onColumnReorder: e.onColumnReorder !== void 0 ? Ot : void 0,
|
|
1613
|
+
columnHeaderRenderer: e.columnHeaderRenderer
|
|
1614
|
+
}
|
|
1615
|
+
)
|
|
1616
|
+
] }),
|
|
1617
|
+
/* @__PURE__ */ de("div", { style: { display: "flex", flexDirection: "row", flex: 1, overflow: "hidden" }, children: [
|
|
1618
|
+
!Be && /* @__PURE__ */ H(
|
|
1619
|
+
en,
|
|
1620
|
+
{
|
|
1621
|
+
treeEngine: ke,
|
|
1622
|
+
width: _e,
|
|
1623
|
+
rowHeight: y,
|
|
1624
|
+
scrollTop: P,
|
|
1625
|
+
viewportHeight: ce.current.canvasHeight || 600,
|
|
1626
|
+
sidebarRenderer: f,
|
|
1627
|
+
onToggle: Fe,
|
|
1628
|
+
onRowClick: e.onRowHeaderClick ? (i, g) => e.onRowHeaderClick(i, g.nativeEvent) : void 0,
|
|
1629
|
+
hoveredRowId: Mt,
|
|
1630
|
+
onRowHover: (i) => {
|
|
1631
|
+
var g;
|
|
1632
|
+
Ee.current = i, $e(i), (g = N.current) == null || g.markDirty("overlay");
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
),
|
|
1636
|
+
/* @__PURE__ */ de("div", { style: { flex: 1, position: "relative", overflow: "hidden" }, children: [
|
|
1637
|
+
/* @__PURE__ */ H(
|
|
1638
|
+
"canvas",
|
|
1639
|
+
{
|
|
1640
|
+
ref: (i) => {
|
|
1641
|
+
i && (pe.current[0] = i);
|
|
1642
|
+
},
|
|
1643
|
+
style: { position: "absolute", top: 0, left: 0, zIndex: 0 }
|
|
1644
|
+
}
|
|
1645
|
+
),
|
|
1646
|
+
/* @__PURE__ */ H(
|
|
1647
|
+
"canvas",
|
|
1648
|
+
{
|
|
1649
|
+
ref: (i) => {
|
|
1650
|
+
i && (pe.current[1] = i);
|
|
1651
|
+
},
|
|
1652
|
+
style: { position: "absolute", top: 0, left: 0, zIndex: 1 }
|
|
1653
|
+
}
|
|
1654
|
+
),
|
|
1655
|
+
/* @__PURE__ */ H(
|
|
1656
|
+
"canvas",
|
|
1657
|
+
{
|
|
1658
|
+
ref: (i) => {
|
|
1659
|
+
i && (pe.current[2] = i);
|
|
1660
|
+
},
|
|
1661
|
+
style: { position: "absolute", top: 0, left: 0, zIndex: 2 },
|
|
1662
|
+
onPointerMove: Wt,
|
|
1663
|
+
onPointerDown: Dt,
|
|
1664
|
+
onDoubleClick: Xt,
|
|
1665
|
+
onContextMenu: Ht,
|
|
1666
|
+
onPointerLeave: Pt
|
|
1667
|
+
}
|
|
1668
|
+
)
|
|
1669
|
+
] })
|
|
1670
|
+
] }),
|
|
1671
|
+
x != null && F != null && /* @__PURE__ */ H(sn, { content: x, position: F }),
|
|
1672
|
+
/* @__PURE__ */ H(rn, { message: Tt })
|
|
1673
|
+
]
|
|
1674
|
+
}
|
|
1675
|
+
);
|
|
1676
|
+
})
|
|
1677
|
+
);
|
|
1678
|
+
export {
|
|
1679
|
+
un as CanvasGrid,
|
|
1680
|
+
Ie as ColumnEngine,
|
|
1681
|
+
qt as SelectionEngine,
|
|
1682
|
+
Nt as TreeEngine,
|
|
1683
|
+
St as ViewState,
|
|
1684
|
+
Qt as createDrawHelpers
|
|
1685
|
+
};
|