@taskctrl/canvas-grid 0.1.0 → 0.1.2

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.
@@ -1,7 +1,7 @@
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 {
1
+ import { jsxs as be, jsx as _ } from "react/jsx-runtime";
2
+ import { useRef as ce, useState as me, useCallback as le, useEffect as we, memo as wn, forwardRef as bn, useMemo as mt, useImperativeHandle as vn } from "react";
3
+ import { createPortal as Cn } from "react-dom";
4
+ class Zt {
5
5
  constructor(e) {
6
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
7
  }
@@ -68,8 +68,8 @@ class St {
68
68
  return -1;
69
69
  }
70
70
  }
71
- const Ct = ["grid", "cells", "overlay"];
72
- class Ut {
71
+ const Kt = ["grid", "cells", "overlay"];
72
+ class yn {
73
73
  constructor(e) {
74
74
  this._dirty = { grid: !1, cells: !1, overlay: !1 }, this._rafId = null, this._drawFn = e;
75
75
  }
@@ -77,7 +77,7 @@ class Ut {
77
77
  this._dirty[e] = !0, this._rafId === null && (this._rafId = requestAnimationFrame(() => this._flush()));
78
78
  }
79
79
  markAllDirty() {
80
- for (const e of Ct)
80
+ for (const e of Kt)
81
81
  this._dirty[e] = !0;
82
82
  this._rafId === null && (this._rafId = requestAnimationFrame(() => this._flush()));
83
83
  }
@@ -86,11 +86,11 @@ class Ut {
86
86
  }
87
87
  _flush() {
88
88
  this._rafId = null;
89
- for (const e of Ct)
89
+ for (const e of Kt)
90
90
  this._dirty[e] && (this._dirty[e] = !1, this._drawFn(e));
91
91
  }
92
92
  }
93
- class Nt {
93
+ class xn {
94
94
  constructor(e, o) {
95
95
  this._rows = e, this._expandedRows = o, this._depthMap = /* @__PURE__ */ new Map(), this._childrenMap = /* @__PURE__ */ new Map(), this._buildMaps(), this._flattenedRows = this._buildFlattenedRows();
96
96
  }
@@ -145,8 +145,8 @@ class Nt {
145
145
  return { startIndex: r, endIndex: c };
146
146
  }
147
147
  }
148
- const jt = 30;
149
- class Ie {
148
+ const In = 30;
149
+ class Pe {
150
150
  constructor(e) {
151
151
  this._columns = e;
152
152
  }
@@ -214,10 +214,10 @@ class Ie {
214
214
  const n = this.getScrollableColumns();
215
215
  if (n.length === 0) return { startIndex: 0, endIndex: 0 };
216
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 };
217
+ let a = 0, f = 0, u = n.length - 1;
218
+ for (let S = 0; S < n.length; S++)
219
+ a + n[S].width <= e && (f = S + 1), a < e + c && (u = S), a += n[S].width;
220
+ return f = Math.min(f, n.length - 1), u = Math.min(u, n.length - 1), { startIndex: f, endIndex: u };
221
221
  }
222
222
  /** Returns the range of pinned columns (always all of them). */
223
223
  getPinnedRange() {
@@ -227,32 +227,32 @@ class Ie {
227
227
  resize(e, o) {
228
228
  const n = this._columns.map((r) => {
229
229
  if (r.id !== e) return r;
230
- const c = r.minWidth ?? jt;
230
+ const c = r.minWidth ?? In;
231
231
  return { ...r, width: Math.max(c, o) };
232
232
  });
233
- return new Ie(n);
233
+ return new Pe(n);
234
234
  }
235
235
  reorder(e, o) {
236
- const n = [...this._columns], r = n.findIndex((m) => m.id === e);
237
- if (r === -1) return new Ie(n);
236
+ const n = [...this._columns], r = n.findIndex((f) => f.id === e);
237
+ if (r === -1) return new Pe(n);
238
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);
239
+ return n.splice(a, 0, c), new Pe(n);
240
240
  }
241
241
  hide(e) {
242
242
  const o = this._columns.map((n) => n.id === e ? { ...n, hidden: !0 } : n);
243
- return new Ie(o);
243
+ return new Pe(o);
244
244
  }
245
245
  show(e) {
246
246
  const o = this._columns.map(
247
247
  (n) => n.id === e ? { ...n, hidden: !1 } : n
248
248
  );
249
- return new Ie(o);
249
+ return new Pe(o);
250
250
  }
251
251
  }
252
- function Se(t, e) {
252
+ function ze(t, e) {
253
253
  return `${t}|${e}`;
254
254
  }
255
- function je() {
255
+ function wt() {
256
256
  return {
257
257
  cells: /* @__PURE__ */ new Set(),
258
258
  rows: /* @__PURE__ */ new Set(),
@@ -260,22 +260,22 @@ function je() {
260
260
  anchor: void 0
261
261
  };
262
262
  }
263
- class qt {
263
+ class Rn {
264
264
  constructor(e) {
265
265
  e ? this._selection = {
266
266
  cells: new Set(e.cells),
267
267
  rows: new Set(e.rows),
268
268
  columns: new Set(e.columns),
269
269
  anchor: e.anchor
270
- } : this._selection = je();
270
+ } : this._selection = wt();
271
271
  }
272
272
  // Single click — clear previous, select one cell, set anchor
273
273
  click(e, o, n, r) {
274
- this._selection = je(), this._selection.cells.add(Se(e, o)), this._selection.anchor = { rowId: e, colId: o };
274
+ this._selection = wt(), this._selection.cells.add(ze(e, o)), this._selection.anchor = { rowId: e, colId: o };
275
275
  }
276
276
  // Ctrl+click — toggle cell in/out of selection
277
277
  ctrlClick(e, o) {
278
- const n = Se(e, o);
278
+ const n = ze(e, o);
279
279
  this._selection.cells.has(n) ? this._selection.cells.delete(n) : this._selection.cells.add(n), this._selection.anchor = { rowId: e, colId: o };
280
280
  }
281
281
  // Shift+click — select rectangle from anchor to target
@@ -285,30 +285,30 @@ class qt {
285
285
  this.click(e, o, n, r);
286
286
  return;
287
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();
288
+ const a = n.indexOf(c.rowId), f = n.indexOf(e), u = r.indexOf(c.colId), S = r.indexOf(o), W = Math.min(a, f), L = Math.max(a, f), x = Math.min(u, S), H = Math.max(u, S), D = /* @__PURE__ */ new Set();
289
+ for (let B = W; B <= L; B++)
290
+ for (let E = x; E <= H; E++)
291
+ D.add(ze(n[B], r[E]));
292
+ this._selection.cells = D, this._selection.rows = /* @__PURE__ */ new Set(), this._selection.columns = /* @__PURE__ */ new Set();
293
293
  }
294
294
  // Select entire row
295
295
  selectRow(e, o) {
296
296
  for (const n of o)
297
- this._selection.cells.add(Se(e, n));
297
+ this._selection.cells.add(ze(e, n));
298
298
  this._selection.rows.add(e), this._selection.anchor = { rowId: e, colId: o[0] ?? "" };
299
299
  }
300
300
  // Select entire column
301
301
  selectColumn(e, o) {
302
302
  for (const n of o)
303
- this._selection.cells.add(Se(n, e));
303
+ this._selection.cells.add(ze(n, e));
304
304
  this._selection.columns.add(e), this._selection.anchor = { rowId: o[0] ?? "", colId: e };
305
305
  }
306
306
  // Clear all selection
307
307
  clear() {
308
- this._selection = je();
308
+ this._selection = wt();
309
309
  }
310
310
  isSelected(e, o) {
311
- return this._selection.cells.has(Se(e, o));
311
+ return this._selection.cells.has(ze(e, o));
312
312
  }
313
313
  isRowSelected(e) {
314
314
  return this._selection.rows.has(e);
@@ -326,233 +326,233 @@ class qt {
326
326
  };
327
327
  }
328
328
  }
329
- function Ve(t, e, o, n, r) {
329
+ function rt(t, e, o, n, r) {
330
330
  const c = o.yToRow(e), a = n.flattenedRows;
331
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;
332
+ const f = r.getPinnedColumns(), u = r.getPinnedWidth();
333
+ if (f.length > 0) {
334
+ if (t < u) {
335
+ let H = 0;
336
+ for (const D of f) {
337
+ if (t >= H && t < H + D.width)
338
+ return { rowId: a[c].id, colId: D.id };
339
+ H += D.width;
340
340
  }
341
341
  return null;
342
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;
343
+ const W = t - u + o.scrollX, L = r.getScrollableColumns();
344
+ let x = 0;
345
+ for (const H of L) {
346
+ if (W >= x && W < x + H.width)
347
+ return { rowId: a[c].id, colId: H.id };
348
+ x += H.width;
349
349
  }
350
350
  return null;
351
351
  }
352
- const R = r.getColumnAtX(t + o.scrollX);
353
- return R === null ? null : { rowId: a[c].id, colId: R };
352
+ const S = r.getColumnAtX(t + o.scrollX);
353
+ return S === null ? null : { rowId: a[c].id, colId: S };
354
354
  }
355
- function Jt(t, e, o) {
355
+ function Sn(t, e, o) {
356
356
  const n = window.devicePixelRatio || 1;
357
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
358
  const c = t.getContext("2d");
359
359
  return c.setTransform(n, 0, 0, n, 0, 0), c;
360
360
  }
361
- function kt(t, e, o, n, r = {}) {
362
- const { canvasWidth: c, canvasHeight: a, rowHeight: m } = e, { rowStyle: f } = r;
361
+ function Jt(t, e, o, n, r = {}) {
362
+ const { canvasWidth: c, canvasHeight: a, rowHeight: f } = e, { rowStyle: u } = r;
363
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);
364
+ const S = o.getVisibleRange(e.scrollY, a, f), W = o.flattenedRows, L = n.getPinnedColumns(), x = n.getScrollableColumns(), H = n.getPinnedWidth(), D = L.length > 0;
365
+ if (W.length === 0 || L.length === 0 && x.length === 0) return;
366
+ const B = n.getTotalWidth(), E = Math.min(c, B - e.scrollX + (D ? e.scrollX : 0)), Y = D ? Math.min(c, H + n.getScrollableColumns().reduce((I, w) => I + w.width, 0) - e.scrollX) : E, J = W.length * f, z = Math.min(a, J - e.scrollY);
367
+ for (let I = S.startIndex; I <= S.endIndex; I++) {
368
+ const w = W[I];
369
+ if (!w) continue;
370
+ const T = e.rowToY(I), p = o.getDepth(w.id);
371
+ let b = I % 2 === 0 ? "#ffffff" : "#f9fafb";
372
+ if (u) {
373
+ const M = u(w, p);
374
+ M != null && M.backgroundColor && (b = M.backgroundColor);
375
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();
376
+ t.fillStyle = b, t.fillRect(0, T, Math.max(Y, H), f), t.strokeStyle = "#d1d5db", t.lineWidth = 0.5, t.beginPath(), t.moveTo(0, T + f), t.lineTo(Math.max(Y, H), T + f), t.stroke();
377
377
  }
378
- if (Y > 0) {
379
- const T = n.getVisibleRange(e.scrollX, c);
378
+ if (z > 0) {
379
+ const I = n.getVisibleRange(e.scrollX, c);
380
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();
381
+ for (let w = I.startIndex; w <= I.endIndex; w++) {
382
+ const T = x[w];
383
+ if (!T) continue;
384
+ const p = e.colToX(w, !1);
385
+ t.beginPath(), t.moveTo(p + T.width, 0), t.lineTo(p + T.width, z), t.stroke();
386
386
  }
387
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);
388
+ if (D && z > 0) {
389
+ t.fillStyle = "#ffffff", t.fillRect(0, 0, H, a);
390
+ for (let w = S.startIndex; w <= S.endIndex; w++) {
391
+ const T = W[w];
392
+ if (!T) continue;
393
+ const p = e.rowToY(w), b = o.getDepth(T.id);
394
+ let M = w % 2 === 0 ? "#ffffff" : "#f9fafb";
395
+ if (u) {
396
+ const R = u(T, b);
397
+ R != null && R.backgroundColor && (M = R.backgroundColor);
398
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();
399
+ t.fillStyle = M, t.fillRect(0, p, H, f), t.strokeStyle = "#d1d5db", t.lineWidth = 0.5, t.beginPath(), t.moveTo(0, p + f), t.lineTo(H, p + f), t.stroke();
400
400
  }
401
- const T = n.getPinnedRange();
401
+ const I = n.getPinnedRange();
402
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();
403
+ for (let w = I.startIndex; w <= I.endIndex; w++) {
404
+ const T = L[w];
405
+ if (!T) continue;
406
+ const p = e.colToX(w, !0);
407
+ t.beginPath(), t.moveTo(p + T.width, 0), t.lineTo(p + T.width, z), t.stroke();
408
408
  }
409
- t.strokeStyle = "#d1d5db", t.lineWidth = 1, t.beginPath(), t.moveTo(W, 0), t.lineTo(W, Y), t.stroke();
409
+ t.strokeStyle = "#d1d5db", t.lineWidth = 1, t.beginPath(), t.moveTo(H, 0), t.lineTo(H, z), t.stroke();
410
410
  }
411
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 + "…";
412
+ function kn(t) {
413
+ function e(a, f, u, S, W, L) {
414
+ t.fillStyle = L, t.beginPath(), t.roundRect(a, f, u, S, W), t.fill();
415
+ }
416
+ function o(a, f, u, S) {
417
+ t.fillText(a, f, u, S);
418
+ }
419
+ function n(a, f) {
420
+ if (t.measureText(a).width <= f) return a;
421
+ let u = a;
422
+ for (; u.length > 0; )
423
+ if (u = u.slice(0, -1), t.measureText(u + "…").width <= f)
424
+ return u + "…";
425
425
  return "…";
426
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;
427
+ function r(a, f, u, S, W) {
428
+ const D = t.measureText(u).width + 16;
429
+ return e(a, f, D, 20, 20 / 2, S), t.fillStyle = W, t.fillText(u, a + 8, f + 20 / 2), D;
430
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);
431
+ function c(a, f, u, S, W, L) {
432
+ e(a, f, u, S, S / 2, "#d1d5db");
433
+ const x = u * Math.max(0, Math.min(1, W));
434
+ x > 0 && e(a, f, x, S, S / 2, L);
435
435
  }
436
436
  return { roundRect: e, fillText: o, truncateText: n, badge: r, progressBar: c };
437
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),
438
+ function Qt(t, e, o, n, r, c) {
439
+ const { canvasWidth: a, canvasHeight: f, rowHeight: u } = e, { cellRenderer: S, getCellData: W, hoveredCell: L } = c;
440
+ c.clearBackground !== !1 && t.clearRect(0, 0, a, f);
441
+ const x = o.getVisibleRange(e.scrollY, f, u), H = o.flattenedRows, D = n.getPinnedColumns(), B = n.getScrollableColumns(), E = D.length > 0;
442
+ if (H.length === 0 || D.length === 0 && B.length === 0) return;
443
+ const Y = kn(t), J = (I, w, T, p) => {
444
+ const b = { x: T, y: p, width: w.width, height: u }, M = { rowId: I.id, colId: w.id, data: W(I.id, w.id) }, R = {
445
+ selected: r.isSelected(I.id, w.id),
446
+ hovered: L != null && L.rowId === I.id && L.colId === w.id,
447
+ rowSelected: r.isRowSelected(I.id),
448
+ colSelected: r.isColumnSelected(w.id),
449
449
  filtered: !0,
450
- depth: o.getDepth(T.id),
451
- hasChildren: o.hasChildren(T.id),
452
- expanded: o.isExpanded(T.id)
450
+ depth: o.getDepth(I.id),
451
+ hasChildren: o.hasChildren(I.id),
452
+ expanded: o.isExpanded(I.id)
453
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);
454
+ t.save(), t.beginPath(), t.rect(T, p, w.width, u), t.clip(), S(t, M, b, R, Y), t.restore();
455
+ }, z = n.getVisibleRange(e.scrollX, a);
456
+ for (let I = x.startIndex; I <= x.endIndex; I++) {
457
+ const w = H[I];
458
+ if (!w) continue;
459
+ const T = e.rowToY(I);
460
+ for (let p = z.startIndex; p <= z.endIndex; p++) {
461
+ const b = B[p];
462
+ if (!b) continue;
463
+ const M = e.colToX(p, E ? !1 : void 0);
464
+ J(w, b, M, T);
465
465
  }
466
466
  }
467
- if ($) {
467
+ if (E) {
468
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);
469
+ const I = n.getPinnedRange();
470
+ for (let w = x.startIndex; w <= x.endIndex; w++) {
471
+ const T = H[w];
472
+ if (!T) continue;
473
+ const p = e.rowToY(w);
474
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);
475
+ for (let b = I.startIndex; b <= I.endIndex; b++) {
476
+ const M = D[b];
477
+ if (!M) continue;
478
+ const R = e.colToX(b, !0);
479
+ J(T, M, R, p);
480
480
  }
481
481
  }
482
482
  }
483
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);
484
+ function Mn(t, e, o, n, r, c = {}) {
485
+ const { canvasWidth: a, canvasHeight: f, rowHeight: u } = e, { hoveredCell: S, hoveredRowId: W, selectedCell: L, resizingColumn: x, loading: H } = c;
486
+ t.clearRect(0, 0, a, f);
487
+ const D = o.getVisibleRange(e.scrollY, f, u), B = o.flattenedRows, E = n.getPinnedColumns(), Y = n.getScrollableColumns(), J = E.length > 0;
488
+ if (n.getPinnedWidth(), B.length === 0 || E.length === 0 && Y.length === 0) return;
489
+ const z = n.getVisibleRange(e.scrollX, a), I = n.getPinnedRange(), w = (p) => {
490
+ for (let b = z.startIndex; b <= z.endIndex; b++) {
491
+ const M = Y[b];
492
+ if (!M) continue;
493
+ const R = J ? e.colToX(b, !1) : e.colToX(b);
494
+ p(M, R);
495
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);
496
+ if (J)
497
+ for (let b = I.startIndex; b <= I.endIndex; b++) {
498
+ const M = E[b];
499
+ if (!M) continue;
500
+ const R = e.colToX(b, !0);
501
+ p(M, R);
502
502
  }
503
503
  };
504
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);
505
+ for (let p = D.startIndex; p <= D.endIndex; p++) {
506
+ const b = B[p];
507
+ if (!b || b.id !== L.rowId) continue;
508
+ const M = e.rowToY(p);
509
+ w((R, N) => {
510
+ t.fillStyle = "rgba(59,130,246,0.06)", t.fillRect(N, M, R.width, u);
511
511
  });
512
512
  break;
513
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);
514
+ w((p, b) => {
515
+ if (p.id === L.colId)
516
+ for (let M = D.startIndex; M <= D.endIndex; M++) {
517
+ if (!B[M]) continue;
518
+ const N = e.rowToY(M);
519
+ t.fillStyle = "rgba(59,130,246,0.06)", t.fillRect(b, N, p.width, u);
520
520
  }
521
521
  });
522
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));
523
+ const T = (p, b, M, R, N) => {
524
+ const l = p.width, ne = u, De = r.isSelected(M.id, p.id), ke = r.isRowSelected(M.id), d = r.isColumnSelected(p.id), P = W != null && W === M.id, $ = S != null && S.rowId === M.id && S.colId === p.id;
525
+ De ? (t.fillStyle = "rgba(59,130,246,0.12)", t.fillRect(b, R, l, ne), t.strokeStyle = "#3b82f6", t.lineWidth = 2, t.strokeRect(b + 1, R + 1, l - 2, ne - 2)) : ke || d || $ ? (t.fillStyle = "rgba(59,130,246,0.08)", t.fillRect(b, R, l, ne)) : P && (t.fillStyle = "rgba(59,130,246,0.04)", t.fillRect(b, R, l, ne));
526
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);
527
+ for (let p = D.startIndex; p <= D.endIndex; p++) {
528
+ const b = B[p];
529
+ if (!b) continue;
530
+ const M = e.rowToY(p);
531
+ for (let R = z.startIndex; R <= z.endIndex; R++) {
532
+ const N = Y[R];
533
+ if (!N) continue;
534
+ const l = J ? e.colToX(R, !1) : e.colToX(R);
535
+ T(N, l, b, M);
536
536
  }
537
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);
538
+ if (J)
539
+ for (let p = D.startIndex; p <= D.endIndex; p++) {
540
+ const b = B[p];
541
+ if (!b) continue;
542
+ const M = e.rowToY(p);
543
+ for (let R = I.startIndex; R <= I.endIndex; R++) {
544
+ const N = E[R];
545
+ if (!N) continue;
546
+ const l = e.colToX(R, !0);
547
+ T(N, l, b, M);
548
548
  }
549
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);
550
+ if (x && (t.save(), t.strokeStyle = "#3b82f6", t.lineWidth = 1, t.setLineDash([4, 4]), t.beginPath(), t.moveTo(x.x, 0), t.lineTo(x.x, f), t.stroke(), t.setLineDash([]), t.restore()), H) {
551
+ const b = f - 32;
552
+ t.fillStyle = "#f3f4f6", t.fillRect(0, b, a, 32), t.strokeStyle = "#e5e7eb", t.lineWidth = 1, t.beginPath(), t.moveTo(0, b), t.lineTo(a, b), t.stroke(), t.fillStyle = "#6b7280", t.font = "13px system-ui, sans-serif", t.textAlign = "center", t.textBaseline = "middle", t.fillText("Loading...", a / 2, b + 32 / 2);
553
553
  }
554
554
  }
555
- function en({
555
+ function _n({
556
556
  treeEngine: t,
557
557
  width: e,
558
558
  rowHeight: o,
@@ -560,54 +560,54 @@ function en({
560
560
  viewportHeight: r,
561
561
  sidebarRenderer: c,
562
562
  onToggle: a,
563
- onRowClick: m,
564
- hoveredRowId: f,
565
- onRowHover: R
563
+ onRowClick: f,
564
+ hoveredRowId: u,
565
+ onRowHover: S
566
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;
567
+ const W = t.flattenedRows, { startIndex: L, endIndex: x } = t.getVisibleRange(n, r, o), H = [];
568
+ for (let E = L; E <= x; E++) {
569
+ const Y = W[E];
570
+ if (!Y) continue;
571
+ const J = t.getDepth(Y.id), z = t.hasChildren(Y.id), I = t.isExpanded(Y.id), w = E * o;
572
+ let T;
573
573
  if (c)
574
- D = c(X, l, T, Y);
574
+ T = c(Y, J, I, z);
575
575
  else {
576
- const h = l * 16 + 8;
577
- D = /* @__PURE__ */ de(
576
+ const b = J * 16 + 8;
577
+ T = /* @__PURE__ */ be(
578
578
  "div",
579
579
  {
580
580
  style: {
581
581
  display: "flex",
582
582
  alignItems: "center",
583
583
  height: "100%",
584
- paddingLeft: h,
584
+ paddingLeft: b,
585
585
  overflow: "hidden",
586
586
  whiteSpace: "nowrap",
587
- cursor: Y ? "pointer" : "default",
587
+ cursor: z ? "pointer" : "default",
588
588
  userSelect: "none"
589
589
  },
590
- onPointerDown: Y ? (u) => {
591
- u.stopPropagation(), a(X.id);
590
+ onPointerDown: z ? (M) => {
591
+ M.stopPropagation(), a(Y.id);
592
592
  } : void 0,
593
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) })
594
+ z ? /* @__PURE__ */ _("span", { style: { marginRight: 4, flexShrink: 0, fontSize: 10, color: "#6b7280" }, children: I ? "▾" : "▸" }) : /* @__PURE__ */ _("span", { style: { width: 14, flexShrink: 0 } }),
595
+ /* @__PURE__ */ _("span", { style: { overflow: "hidden", textOverflow: "ellipsis", fontSize: 12 }, children: String(Y.title ?? Y.id) })
596
596
  ]
597
597
  }
598
598
  );
599
599
  }
600
- const w = f === X.id;
601
- W.push(
602
- /* @__PURE__ */ H(
600
+ const p = u === Y.id;
601
+ H.push(
602
+ /* @__PURE__ */ _(
603
603
  "div",
604
604
  {
605
605
  role: "rowheader",
606
- "aria-level": l + 1,
607
- "aria-expanded": Y ? T : void 0,
606
+ "aria-level": J + 1,
607
+ "aria-expanded": z ? I : void 0,
608
608
  style: {
609
609
  position: "absolute",
610
- top: C,
610
+ top: w,
611
611
  left: 0,
612
612
  width: "100%",
613
613
  height: o,
@@ -615,20 +615,20 @@ function en({
615
615
  fontSize: 13,
616
616
  color: "#374151",
617
617
  borderBottom: "1px solid #e5e7eb",
618
- cursor: m ? "pointer" : "default",
619
- backgroundColor: w ? "rgba(59,130,246,0.04)" : void 0
618
+ cursor: f ? "pointer" : "default",
619
+ backgroundColor: p ? "rgba(59,130,246,0.04)" : void 0
620
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
621
+ onPointerDown: f ? (b) => f(Y.id, b) : void 0,
622
+ onPointerEnter: () => S == null ? void 0 : S(Y.id),
623
+ onPointerLeave: () => S == null ? void 0 : S(null),
624
+ children: T
625
625
  },
626
- String(X.id)
626
+ String(Y.id)
627
627
  )
628
628
  );
629
629
  }
630
- const S = y.length * o, G = Math.min(r, S - n);
631
- return /* @__PURE__ */ de(
630
+ const D = W.length * o, B = Math.min(r, D - n);
631
+ return /* @__PURE__ */ be(
632
632
  "div",
633
633
  {
634
634
  style: {
@@ -640,7 +640,7 @@ function en({
640
640
  backgroundColor: "#ffffff"
641
641
  },
642
642
  children: [
643
- /* @__PURE__ */ H(
643
+ /* @__PURE__ */ _(
644
644
  "div",
645
645
  {
646
646
  style: {
@@ -648,13 +648,13 @@ function en({
648
648
  top: 0,
649
649
  right: 0,
650
650
  width: 1,
651
- height: Math.max(0, G),
651
+ height: Math.max(0, B),
652
652
  backgroundColor: "#e5e7eb",
653
653
  zIndex: 1
654
654
  }
655
655
  }
656
656
  ),
657
- /* @__PURE__ */ H(
657
+ /* @__PURE__ */ _(
658
658
  "div",
659
659
  {
660
660
  style: {
@@ -662,18 +662,18 @@ function en({
662
662
  top: 0,
663
663
  left: 0,
664
664
  width: "100%",
665
- height: S,
665
+ height: D,
666
666
  transform: `translateY(-${n}px)`
667
667
  },
668
- children: W
668
+ children: H
669
669
  }
670
670
  )
671
671
  ]
672
672
  }
673
673
  );
674
674
  }
675
- const qe = 28, Je = 28, tn = 4;
676
- function nn(t) {
675
+ const bt = 28, vt = 28, Tn = 4;
676
+ function Wn(t) {
677
677
  switch (t) {
678
678
  case "vertical":
679
679
  return 120;
@@ -681,133 +681,156 @@ function nn(t) {
681
681
  return 32;
682
682
  }
683
683
  }
684
- function on({
684
+ function Hn({ active: t }) {
685
+ return /* @__PURE__ */ _(
686
+ "svg",
687
+ {
688
+ width: 13,
689
+ height: 13,
690
+ viewBox: "0 0 24 24",
691
+ fill: "none",
692
+ stroke: t ? "#2563eb" : "#9ca3af",
693
+ strokeWidth: 2,
694
+ strokeLinecap: "round",
695
+ strokeLinejoin: "round",
696
+ "aria-hidden": "true",
697
+ children: /* @__PURE__ */ _("polygon", { points: "22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" })
698
+ }
699
+ );
700
+ }
701
+ function Dn({
685
702
  columnEngine: t,
686
703
  columnGroups: e,
687
704
  scrollX: o,
688
705
  orientation: n = "horizontal",
689
- onColumnClick: r,
690
- onColumnResize: c,
691
- onColumnReorder: a,
692
- columnHeaderRenderer: m
706
+ columnHeaderHeight: r,
707
+ onColumnClick: c,
708
+ onColumnResize: a,
709
+ onColumnReorder: f,
710
+ onColumnFilterClick: u,
711
+ columnHeaderRenderer: S
693
712
  }) {
694
- const f = t.getPinnedColumns(), R = t.getScrollableColumns(), y = t.getVisibleColumns(), L = t.getPinnedWidth(), O = /* @__PURE__ */ new Map();
713
+ const W = t.getPinnedColumns(), L = t.getScrollableColumns(), x = t.getVisibleColumns(), H = t.getPinnedWidth(), D = /* @__PURE__ */ new Map();
695
714
  if (e)
696
715
  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 = [];
716
+ D.set(d.id, d);
717
+ const B = ce(null), [E, Y] = me(null), J = ce(null), z = ce(!1), I = ce(null), w = ce(null);
718
+ J.current = E;
719
+ const T = [...W, ...L], p = [];
701
720
  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 });
721
+ let d, P = 0, $ = 0, V = !1;
722
+ for (const G of T) {
723
+ const U = t.getColumnX(G.id), F = G.pinned === "left";
724
+ if (G.group !== d) {
725
+ if (d !== void 0 && $ > 0) {
726
+ const se = D.get(d);
727
+ se && p.push({ group: se, startX: P, width: $, pinned: V });
709
728
  }
710
- d = V.group, M = q, P = V.width, z = J;
729
+ d = G.group, P = U, $ = G.width, V = F;
711
730
  } else
712
- P += V.width;
731
+ $ += G.width;
713
732
  }
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 });
733
+ if (d !== void 0 && $ > 0) {
734
+ const G = D.get(d);
735
+ G && p.push({ group: G, startX: P, width: $, pinned: V });
717
736
  }
718
737
  }
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 });
738
+ const b = p.length > 0, M = r ?? Wn(n), R = b ? bt + M : M, N = le(
739
+ (d, P) => {
740
+ P.stopPropagation(), P.preventDefault();
741
+ const $ = x.find((V) => V.id === d);
742
+ $ && (B.current = { colId: d, startX: P.clientX, startWidth: $.width });
724
743
  },
725
- [y]
744
+ [x]
726
745
  );
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;
746
+ we(() => {
747
+ const d = ($) => {
748
+ const V = B.current;
749
+ if (!V) return;
750
+ const G = $.clientX - V.startX, U = Math.max(V.startWidth + G, 30);
751
+ a == null || a(V.colId, U);
752
+ }, P = () => {
753
+ B.current = null;
735
754
  };
736
- return document.addEventListener("mousemove", d), document.addEventListener("mouseup", M), () => {
737
- document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", M);
755
+ return document.addEventListener("mousemove", d), document.addEventListener("mouseup", P), () => {
756
+ document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", P);
738
757
  };
739
- }, [c]);
740
- const x = te(
758
+ }, [a]);
759
+ const l = le(
741
760
  (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);
761
+ const P = w.current;
762
+ if (!P) return { dropIndex: 0 };
763
+ const $ = P.getBoundingClientRect(), V = d - $.left + o;
764
+ let G = 0;
765
+ for (let U = 0; U < x.length; U++) {
766
+ const F = x[U], pe = t.getColumnX(F.id) + F.width / 2;
767
+ V > pe && (G = U + 1);
749
768
  }
750
- return { dropIndex: V };
769
+ return { dropIndex: G };
751
770
  },
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 });
771
+ [x, t, o]
772
+ ), ne = le(
773
+ (d, P) => {
774
+ P.target.dataset.resizeHandle || f && (P.preventDefault(), z.current = !1, I.current = { colId: d, startX: P.clientX, currentX: P.clientX });
756
775
  },
757
- [a]
776
+ [f]
758
777
  );
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) ?? ""
778
+ we(() => {
779
+ if (!f) return;
780
+ const d = (V) => {
781
+ const G = I.current;
782
+ if (!G) return;
783
+ const U = Math.abs(V.clientX - G.startX);
784
+ if (!z.current && U >= Tn) {
785
+ z.current = !0;
786
+ const F = x.find((te) => te.id === G.colId), se = t.getColumnX(G.colId), { dropIndex: pe } = l(V.clientX);
787
+ Y({
788
+ colId: G.colId,
789
+ startX: G.startX,
790
+ currentX: V.clientX,
791
+ dropIndex: pe,
792
+ ghostLeft: se - o,
793
+ ghostWidth: (F == null ? void 0 : F.width) ?? 80,
794
+ ghostTitle: (F == null ? void 0 : F.title) ?? ""
776
795
  });
777
796
  return;
778
797
  }
779
- if (X.current) {
780
- const { dropIndex: J } = x(z.clientX);
781
- G((Q) => Q && { ...Q, currentX: z.clientX, dropIndex: J });
798
+ if (z.current) {
799
+ const { dropIndex: F } = l(V.clientX);
800
+ Y((se) => se && { ...se, currentX: V.clientX, dropIndex: F });
782
801
  }
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));
802
+ }, P = () => {
803
+ z.current && J.current && f(J.current.colId, J.current.dropIndex), I.current = null, z.current = !1, Y(null);
804
+ }, $ = (V) => {
805
+ V.key === "Escape" && (I.current = null, z.current = !1, Y(null));
787
806
  };
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);
807
+ return document.addEventListener("mousemove", d), document.addEventListener("mouseup", P), document.addEventListener("keydown", $), () => {
808
+ document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", P), document.removeEventListener("keydown", $);
790
809
  };
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;
810
+ }, [f, x, t, o, l]);
811
+ const De = () => {
812
+ if (!E) return 0;
813
+ const { dropIndex: d } = E;
814
+ if (d >= x.length) {
815
+ const P = x[x.length - 1];
816
+ return t.getColumnX(P.id) + P.width - o;
798
817
  }
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(
818
+ return t.getColumnX(x[d].id) - o;
819
+ }, ke = (d, P, $) => {
820
+ const V = (E == null ? void 0 : E.colId) === d.id, U = d.pinned === "left" ? "horizontal" : n, F = S == null ? void 0 : S(d.id, d.title, {
821
+ width: d.width,
822
+ height: $,
823
+ orientation: U
824
+ }), se = d.filterable && !!u;
825
+ let pe;
826
+ return F ? pe = F : U === "vertical" ? pe = /* @__PURE__ */ _(
804
827
  "div",
805
828
  {
806
829
  style: {
807
830
  writingMode: "vertical-rl",
808
831
  textOrientation: "mixed",
809
832
  transform: "rotate(180deg)",
810
- height: P - 16,
833
+ height: $ - 16,
811
834
  lineHeight: `${d.width}px`,
812
835
  overflow: "hidden",
813
836
  textOverflow: "ellipsis",
@@ -815,35 +838,64 @@ function on({
815
838
  },
816
839
  children: d.title
817
840
  }
818
- ) : Q = /* @__PURE__ */ H("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1 }, children: d.title }), /* @__PURE__ */ de(
841
+ ) : pe = /* @__PURE__ */ _("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1 }, children: d.title }), /* @__PURE__ */ be(
819
842
  "div",
820
843
  {
821
844
  role: "columnheader",
822
- title: d.title,
845
+ "aria-label": d.title,
823
846
  style: {
824
847
  position: "absolute",
825
- left: M,
848
+ left: P,
826
849
  width: d.width,
827
- height: P,
850
+ height: $,
828
851
  boxSizing: "border-box",
829
852
  borderRight: "1px solid #d1d5db",
830
853
  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",
854
+ alignItems: U === "horizontal" ? "center" : "flex-end",
855
+ justifyContent: U === "horizontal" ? "flex-start" : "center",
856
+ paddingLeft: U === "horizontal" ? 8 : 0,
857
+ paddingBottom: U !== "horizontal" ? 6 : 0,
858
+ cursor: f ? "grab" : c ? "pointer" : "default",
836
859
  userSelect: "none",
837
860
  fontSize: 13,
838
861
  fontWeight: 500,
839
862
  color: "#6C737F",
840
- opacity: z ? 0.4 : 1
863
+ opacity: V ? 0.4 : 1
841
864
  },
842
- onMouseDown: a ? (le) => F(d.id, le) : void 0,
843
- onPointerDown: r && !a ? (le) => r(d.id, le) : void 0,
865
+ onMouseDown: f ? (te) => ne(d.id, te) : void 0,
866
+ onPointerDown: c && !f ? (te) => c(d.id, te) : void 0,
844
867
  children: [
845
- Q,
846
- c && /* @__PURE__ */ H(
868
+ pe,
869
+ se && /* @__PURE__ */ _(
870
+ "button",
871
+ {
872
+ type: "button",
873
+ "aria-label": "Filter column",
874
+ "data-cg-filter-icon": d.id,
875
+ style: {
876
+ position: "absolute",
877
+ top: 2,
878
+ right: 5,
879
+ zIndex: 2,
880
+ display: "flex",
881
+ alignItems: "center",
882
+ justifyContent: "center",
883
+ padding: 1,
884
+ border: "none",
885
+ borderRadius: 3,
886
+ background: "transparent",
887
+ cursor: "pointer",
888
+ lineHeight: 0
889
+ },
890
+ onMouseDown: (te) => te.stopPropagation(),
891
+ onPointerDown: (te) => te.stopPropagation(),
892
+ onClick: (te) => {
893
+ te.stopPropagation(), u == null || u(d.id, te.currentTarget.getBoundingClientRect());
894
+ },
895
+ children: /* @__PURE__ */ _(Hn, { active: d.filterActive })
896
+ }
897
+ ),
898
+ a && /* @__PURE__ */ _(
847
899
  "div",
848
900
  {
849
901
  "data-resize-handle": "true",
@@ -856,7 +908,7 @@ function on({
856
908
  cursor: "col-resize",
857
909
  zIndex: 1
858
910
  },
859
- onMouseDown: (le) => u(d.id, le)
911
+ onMouseDown: (te) => N(d.id, te)
860
912
  }
861
913
  )
862
914
  ]
@@ -864,19 +916,21 @@ function on({
864
916
  d.id
865
917
  );
866
918
  };
867
- return /* @__PURE__ */ de(
919
+ return /* @__PURE__ */ be(
868
920
  "div",
869
921
  {
870
- ref: Y,
922
+ ref: w,
871
923
  style: {
872
924
  flex: 1,
873
- height: h + 1,
925
+ // Exactly totalHeight so the bottom-border row isn't pushed under the
926
+ // body (a +1 here gets clipped/covered, hiding the header border).
927
+ height: R,
874
928
  overflow: "hidden",
875
929
  position: "relative",
876
930
  backgroundColor: "#f9fafb"
877
931
  },
878
932
  children: [
879
- /* @__PURE__ */ de(
933
+ /* @__PURE__ */ be(
880
934
  "div",
881
935
  {
882
936
  style: {
@@ -884,21 +938,21 @@ function on({
884
938
  top: 0,
885
939
  left: 0,
886
940
  transform: `translateX(-${o}px)`,
887
- height: h
941
+ height: R
888
942
  },
889
943
  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);
944
+ /* @__PURE__ */ _("div", { style: { position: "absolute", top: 0, height: R }, children: L.map((d) => {
945
+ const P = t.getColumnX(d.id);
946
+ return ke(d, P, R);
893
947
  }) }),
894
- D && /* @__PURE__ */ H("div", { style: { position: "relative", height: qe, zIndex: 1 }, children: C.filter((d) => !d.pinned).map((d) => /* @__PURE__ */ H(
948
+ b && /* @__PURE__ */ _("div", { style: { position: "relative", height: bt, zIndex: 1 }, children: p.filter((d) => !d.pinned).map((d) => /* @__PURE__ */ _(
895
949
  "div",
896
950
  {
897
951
  style: {
898
952
  position: "absolute",
899
953
  left: d.startX,
900
954
  width: d.width,
901
- height: qe,
955
+ height: bt,
902
956
  borderBottom: `1px solid ${d.group.color ?? "#3b82f6"}`,
903
957
  display: "flex",
904
958
  alignItems: "center",
@@ -918,22 +972,22 @@ function on({
918
972
  ]
919
973
  }
920
974
  ),
921
- f.length > 0 && /* @__PURE__ */ de(
975
+ W.length > 0 && /* @__PURE__ */ be(
922
976
  "div",
923
977
  {
924
978
  style: {
925
979
  position: "absolute",
926
980
  top: 0,
927
981
  left: 0,
928
- width: L,
929
- height: h,
982
+ width: H,
983
+ height: R,
930
984
  backgroundColor: "#f9fafb",
931
985
  zIndex: 2,
932
986
  display: "flex",
933
987
  flexDirection: "column"
934
988
  },
935
989
  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(
990
+ b && /* @__PURE__ */ _("div", { style: { position: "absolute", top: 0, left: 0, width: H, height: R - vt }, children: p.filter((d) => d.pinned).map((d) => /* @__PURE__ */ _(
937
991
  "div",
938
992
  {
939
993
  style: {
@@ -958,11 +1012,11 @@ function on({
958
1012
  },
959
1013
  d.group.id
960
1014
  )) }),
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);
1015
+ /* @__PURE__ */ _("div", { style: { position: "absolute", bottom: 0, left: 0, width: H, height: vt, borderTop: "1px solid #d1d5db" }, children: W.map((d) => {
1016
+ const P = t.getColumnX(d.id);
1017
+ return ke(d, P, vt);
964
1018
  }) }),
965
- /* @__PURE__ */ H(
1019
+ /* @__PURE__ */ _(
966
1020
  "div",
967
1021
  {
968
1022
  style: {
@@ -979,30 +1033,30 @@ function on({
979
1033
  ]
980
1034
  }
981
1035
  ),
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 })
1036
+ /* @__PURE__ */ _("div", { style: { position: "absolute", bottom: 0, left: 0, right: 0, height: 1, backgroundColor: "#d1d5db", zIndex: 5 } }),
1037
+ E && /* @__PURE__ */ _("div", { style: { position: "absolute", top: 0, left: De(), width: 2, height: R, backgroundColor: "#3b82f6", pointerEvents: "none", zIndex: 10 } }),
1038
+ E && /* @__PURE__ */ _("div", { style: { position: "fixed", top: 0, left: E.currentX - E.ghostWidth / 2, width: E.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: E.ghostTitle })
985
1039
  ]
986
1040
  }
987
1041
  );
988
1042
  }
989
- function ln({
1043
+ function Xn({
990
1044
  columnEngine: t,
991
1045
  onColumnVisibilityChange: e
992
1046
  }) {
993
- const [o, n] = ve(!1), r = ne(null), c = t.getAllColumns();
994
- return re(() => {
1047
+ const [o, n] = me(!1), r = ce(null), c = t.getAllColumns();
1048
+ return we(() => {
995
1049
  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);
1050
+ const a = (u) => {
1051
+ r.current && !r.current.contains(u.target) && n(!1);
1052
+ }, f = (u) => {
1053
+ u.key === "Escape" && n(!1);
1000
1054
  };
1001
- return document.addEventListener("mousedown", a), document.addEventListener("keydown", m), () => {
1002
- document.removeEventListener("mousedown", a), document.removeEventListener("keydown", m);
1055
+ return document.addEventListener("mousedown", a), document.addEventListener("keydown", f), () => {
1056
+ document.removeEventListener("mousedown", a), document.removeEventListener("keydown", f);
1003
1057
  };
1004
- }, [o]), /* @__PURE__ */ de("div", { ref: r, style: { position: "relative", display: "inline-block" }, children: [
1005
- /* @__PURE__ */ H(
1058
+ }, [o]), /* @__PURE__ */ be("div", { ref: r, style: { position: "relative", display: "inline-block" }, children: [
1059
+ /* @__PURE__ */ _(
1006
1060
  "button",
1007
1061
  {
1008
1062
  onClick: () => n((a) => !a),
@@ -1025,7 +1079,7 @@ function ln({
1025
1079
  children: "Columns"
1026
1080
  }
1027
1081
  ),
1028
- o && /* @__PURE__ */ H(
1082
+ o && /* @__PURE__ */ _(
1029
1083
  "div",
1030
1084
  {
1031
1085
  style: {
@@ -1042,8 +1096,8 @@ function ln({
1042
1096
  padding: "4px 0"
1043
1097
  },
1044
1098
  children: c.map((a) => {
1045
- const m = !a.hidden;
1046
- return /* @__PURE__ */ de(
1099
+ const f = !a.hidden;
1100
+ return /* @__PURE__ */ be(
1047
1101
  "label",
1048
1102
  {
1049
1103
  style: {
@@ -1056,25 +1110,25 @@ function ln({
1056
1110
  color: "#374151",
1057
1111
  userSelect: "none"
1058
1112
  },
1059
- onMouseEnter: (f) => {
1060
- f.currentTarget.style.backgroundColor = "#f3f4f6";
1113
+ onMouseEnter: (u) => {
1114
+ u.currentTarget.style.backgroundColor = "#f3f4f6";
1061
1115
  },
1062
- onMouseLeave: (f) => {
1063
- f.currentTarget.style.backgroundColor = "";
1116
+ onMouseLeave: (u) => {
1117
+ u.currentTarget.style.backgroundColor = "";
1064
1118
  },
1065
1119
  children: [
1066
- /* @__PURE__ */ H(
1120
+ /* @__PURE__ */ _(
1067
1121
  "input",
1068
1122
  {
1069
1123
  type: "checkbox",
1070
- checked: m,
1071
- onChange: (f) => {
1072
- e(a.id, f.target.checked);
1124
+ checked: f,
1125
+ onChange: (u) => {
1126
+ e(a.id, u.target.checked);
1073
1127
  },
1074
1128
  style: { cursor: "pointer", width: 14, height: 14 }
1075
1129
  }
1076
1130
  ),
1077
- /* @__PURE__ */ H("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: a.title })
1131
+ /* @__PURE__ */ _("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: a.title })
1078
1132
  ]
1079
1133
  },
1080
1134
  a.id
@@ -1084,9 +1138,9 @@ function ln({
1084
1138
  )
1085
1139
  ] });
1086
1140
  }
1087
- function sn({ content: t, position: e }) {
1088
- return Ft(
1089
- /* @__PURE__ */ H(
1141
+ function Pn({ content: t, position: e }) {
1142
+ return Cn(
1143
+ /* @__PURE__ */ _(
1090
1144
  "div",
1091
1145
  {
1092
1146
  style: {
@@ -1102,8 +1156,8 @@ function sn({ content: t, position: e }) {
1102
1156
  document.body
1103
1157
  );
1104
1158
  }
1105
- function rn({ message: t }) {
1106
- return /* @__PURE__ */ H(
1159
+ function En({ message: t }) {
1160
+ return /* @__PURE__ */ _(
1107
1161
  "div",
1108
1162
  {
1109
1163
  role: "status",
@@ -1124,8 +1178,9 @@ function rn({ message: t }) {
1124
1178
  }
1125
1179
  );
1126
1180
  }
1127
- const Ge = 24, Qe = 32;
1128
- function dn(t) {
1181
+ const Ze = 28, Ln = 32, On = 120;
1182
+ function An(t) {
1183
+ var Ye, Ve;
1129
1184
  const {
1130
1185
  treeEngine: e,
1131
1186
  columnEngine: o,
@@ -1133,330 +1188,369 @@ function dn(t) {
1133
1188
  rowHeight: r,
1134
1189
  sidebarWidth: c,
1135
1190
  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({
1191
+ cellLayerConfig: f,
1192
+ headerOrientation: u = "horizontal",
1193
+ scale: S = 2
1194
+ } = t, W = n != null && n.length > 0, L = t.columnHeaderHeight ?? (u === "vertical" ? On : Ln), x = W ? Ze + L : L, H = o.getVisibleColumns(), D = e.flattenedRows, B = Math.max(0, ((Ye = t.rowRange) == null ? void 0 : Ye.start) ?? 0), E = Math.min(D.length, ((Ve = t.rowRange) == null ? void 0 : Ve.end) ?? D.length), Y = Math.max(0, E - B), J = B * r, z = o.getTotalWidth(), I = Y * r, w = c + z, T = x + I, p = 16384, M = Math.min(
1195
+ p / w,
1196
+ p / T,
1197
+ Math.sqrt(256e6 / (w * T))
1198
+ );
1199
+ let R = Math.min(S, M);
1200
+ (!Number.isFinite(R) || R <= 0) && (R = 1);
1201
+ const N = document.createElement("canvas");
1202
+ N.width = Math.round(w * R), N.height = Math.round(T * R), N.style.width = `${w}px`, N.style.height = `${T}px`;
1203
+ const l = N.getContext("2d");
1204
+ l.setTransform(R, 0, 0, R, 0, 0), l.fillStyle = "#ffffff", l.fillRect(0, 0, w, T);
1205
+ const ne = new Zt({
1143
1206
  scrollX: 0,
1144
- scrollY: 0,
1145
- canvasWidth: W,
1146
- canvasHeight: S,
1207
+ scrollY: J,
1208
+ canvasWidth: z,
1209
+ canvasHeight: I,
1147
1210
  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 + "…";
1211
+ }), De = [], ke = [];
1212
+ let d = 0;
1213
+ for (const O of H)
1214
+ De.push(d), ke.push(O.width), d += O.width;
1215
+ ne.setColumnOffsets(De), ne.setColumnWidths(ke);
1216
+ const P = o.getPinnedColumns(), $ = o.getScrollableColumns(), V = [], G = [];
1217
+ let U = 0;
1218
+ for (const O of P)
1219
+ V.push(U), G.push(O.width), U += O.width;
1220
+ const F = [], se = [];
1221
+ let pe = 0;
1222
+ for (const O of $)
1223
+ F.push(pe), se.push(O.width), pe += O.width;
1224
+ if (ne.pinnedWidth = o.getPinnedWidth(), ne.setPinnedOffsets(V, G), ne.setScrollableOffsets(F, se), l.save(), l.translate(c, x), Jt(l, ne, e, o, a), Qt(l, ne, e, o, t.selectionEngine, {
1225
+ ...f,
1226
+ clearBackground: !1
1227
+ }), l.restore(), c > 0) {
1228
+ l.save(), l.translate(0, x);
1229
+ const O = "#ffffff";
1230
+ l.fillStyle = O, l.fillRect(0, 0, c, I), l.strokeStyle = "#e5e7eb", l.lineWidth = 0.5, l.beginPath(), l.moveTo(c, 0), l.lineTo(c, I), l.stroke(), l.font = "13px system-ui, sans-serif", l.textBaseline = "middle", l.fillStyle = "#374151";
1231
+ for (let oe = B; oe < E; oe++) {
1232
+ const q = D[oe];
1233
+ if (!q) continue;
1234
+ const xe = e.getDepth(q.id), Q = (oe - B) * r, ie = xe * 16 + 8, Me = String(q.title ?? q.id), ve = c - ie - 8;
1235
+ l.fillStyle = oe % 2 === 0 ? "#ffffff" : "#f9fafb", l.fillRect(0, Q, c, r), l.strokeStyle = "#e5e7eb", l.lineWidth = 0.5, l.beginPath(), l.moveTo(0, Q + r), l.lineTo(c, Q + r), l.stroke(), l.fillStyle = "#374151";
1236
+ let he = Me;
1237
+ if (l.measureText(he).width > ve && ve > 0) {
1238
+ for (; he.length > 0 && l.measureText(he + "…").width > ve; )
1239
+ he = he.slice(0, -1);
1240
+ he = he + "…";
1241
+ }
1242
+ l.fillText(he, ie, Q + r / 2);
1165
1243
  }
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);
1244
+ l.restore();
1245
+ }
1246
+ if (l.save(), l.translate(0, 0), l.fillStyle = "#f9fafb", l.fillRect(0, 0, w, x), l.fillStyle = "#d1d5db", l.fillRect(0, 0, w, 1), l.strokeStyle = "#d1d5db", l.lineWidth = 1, l.beginPath(), l.moveTo(0, x), l.lineTo(w, x), l.stroke(), l.fillStyle = "#f9fafb", l.fillRect(0, 0, c, x), l.strokeStyle = "#d1d5db", l.lineWidth = 1, l.beginPath(), l.moveTo(c, 0), l.lineTo(c, x), l.stroke(), W && n) {
1247
+ const O = /* @__PURE__ */ new Map();
1248
+ for (const ie of n)
1249
+ O.set(ie.id, ie);
1250
+ let oe, q = 0, xe = 0;
1251
+ const Q = (ie, Me, ve) => {
1252
+ if (ie === void 0 || ve <= 0) return;
1253
+ const he = O.get(ie);
1254
+ if (!he) return;
1255
+ const Ee = c + Me;
1256
+ l.strokeStyle = "#d1d5db", l.lineWidth = 1, l.beginPath(), l.moveTo(Ee, Ze), l.lineTo(Ee + ve, Ze), l.stroke(), l.font = "600 11px system-ui, sans-serif", l.fillStyle = "#6b7280", l.textBaseline = "middle", l.textAlign = "left", l.fillText(he.title, Ee + 8, Ze / 2);
1179
1257
  };
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;
1258
+ for (const ie of H) {
1259
+ const Me = o.getColumnX(ie.id);
1260
+ ie.group !== oe ? (Q(oe, q, xe), oe = ie.group, q = Me, xe = ie.width) : xe += ie.width;
1183
1261
  }
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);
1262
+ Q(oe, q, xe);
1263
+ }
1264
+ const te = W ? Ze : 0, Je = (O, oe) => {
1265
+ if (oe <= 0 || l.measureText(O).width <= oe) return O;
1266
+ let q = O;
1267
+ for (; q.length > 0 && l.measureText(q + "…").width > oe; )
1268
+ q = q.slice(0, -1);
1269
+ return q + "…";
1270
+ };
1271
+ for (const O of H) {
1272
+ const oe = o.getColumnX(O.id), q = c + oe, xe = u === "vertical" && O.pinned !== "left";
1273
+ if (l.strokeStyle = "#d1d5db", l.lineWidth = 1, l.beginPath(), l.moveTo(q + O.width, te), l.lineTo(q + O.width, x), l.stroke(), !!O.title)
1274
+ if (l.fillStyle = "#6b7280", l.textBaseline = "middle", xe) {
1275
+ const Q = L - 12;
1276
+ l.save(), l.translate(q + O.width / 2 + 4, x - 6), l.rotate(-Math.PI / 2), l.font = "11px system-ui, sans-serif", l.textAlign = "left", l.fillText(Je(O.title, Q), 0, 0, Q), l.restore();
1277
+ } else {
1278
+ l.font = "600 12px system-ui, sans-serif", l.textAlign = "left";
1279
+ const Q = O.width - 16, ie = u === "vertical" ? x - 14 : te + L / 2;
1280
+ l.fillText(Je(O.title, Q), q + 8, ie, Q);
1281
+ }
1199
1282
  }
1200
- return l.restore(), X;
1283
+ return l.restore(), l.fillStyle = "#d1d5db", l.fillRect(0, 0, w, 1), l.fillRect(0, T - 1, w, 1), l.fillRect(0, 0, 1, T), l.fillRect(w - 1, 0, 1, T), N;
1201
1284
  }
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;
1285
+ const Ut = 180, Nt = 32, zn = 28, jt = 200;
1286
+ function qt(t, e, o) {
1287
+ const n = o ?? (t === "vertical" ? 120 : 32);
1288
+ return e ? zn + n : n;
1213
1289
  }
1214
- const un = $t(
1215
- Bt(function(e, o) {
1290
+ const Gn = wn(
1291
+ bn(function(e, o) {
1216
1292
  const {
1217
1293
  rows: n,
1218
1294
  columns: r,
1219
1295
  columnGroups: c,
1220
1296
  getCellData: a,
1221
- cellRenderer: m,
1222
- sidebarRenderer: f,
1223
- sidebarWidth: R = yt,
1224
- rowHeight: y = xt,
1297
+ cellRenderer: f,
1298
+ sidebarRenderer: u,
1299
+ sidebarWidth: S = Ut,
1300
+ rowHeight: W = Nt,
1225
1301
  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,
1302
+ columnHeaderHeight: x,
1303
+ maxHeight: H,
1304
+ rowStyle: D,
1305
+ selection: B,
1306
+ onSelectionChange: E,
1307
+ onCellClick: Y,
1308
+ onCellDoubleClick: J,
1309
+ onCellContextMenu: z,
1310
+ onCellHover: I,
1311
+ onColumnHeaderClick: w,
1234
1312
  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);
1313
+ defaultExpandedRows: p,
1314
+ onExpandChange: b,
1315
+ onLoadMore: M,
1316
+ hasMore: R,
1317
+ loading: N,
1318
+ hoverContent: l,
1319
+ hoverPosition: ne,
1320
+ showColumnVisibilityMenu: De,
1321
+ ariaLabel: ke = "Data grid"
1322
+ } = e, [d, P] = me(
1323
+ () => new Set(p ?? [])
1324
+ ), [$, V] = me(0), [G, U] = me(0), [F, se] = me({ width: 0, height: 0 }), [pe, te] = me(!1), [Je, Ye] = me(!1), [Ve, O] = me(r), [oe, q] = me(null), [xe, Q] = me(""), [ie, Me] = me(null), ve = ce(null), he = ce(null);
1325
+ we(() => {
1326
+ O(r);
1249
1327
  }, [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);
1328
+ const Ee = ce(null), _e = ce([]), fe = ce(new Zt({ rowHeight: W })), j = ce(null), A = ce(e), Ce = ce(null), Qe = ce(null), et = ce(!1);
1251
1329
  A.current = e;
1252
- const ke = Ne(
1253
- () => new Nt(n, d),
1330
+ const Le = mt(
1331
+ () => new xn(n, d),
1254
1332
  [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;
1333
+ ), ue = mt(() => new Pe(Ve), [Ve]), Ct = mt(() => new Rn(B), [B]);
1334
+ Ce.current = { treeEngine: Le, columnEngine: ue, selectionEngine: Ct };
1335
+ const ct = ue.getPinnedColumns().length > 0, Be = ct ? 0 : S, yt = le((i) => {
1336
+ const h = Ce.current;
1337
+ if (!h) return;
1338
+ const { treeEngine: C, columnEngine: k, selectionEngine: v } = h, m = fe.current, s = i === "grid" ? 0 : i === "cells" ? 1 : 2, g = _e.current[s];
1259
1339
  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, {
1340
+ const y = Sn(g, m.canvasWidth, m.canvasHeight);
1341
+ i === "grid" ? Jt(y, m, C, k, { rowStyle: A.current.rowStyle }) : i === "cells" ? Qt(y, m, C, k, v, {
1264
1342
  cellRenderer: A.current.cellRenderer,
1265
1343
  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,
1344
+ hoveredCell: Qe.current
1345
+ }) : Mn(y, m, C, k, v, {
1346
+ hoveredCell: Qe.current,
1347
+ hoveredRowId: ve.current,
1348
+ selectedCell: he.current,
1349
+ resizingColumn: oe ?? void 0,
1272
1350
  loading: A.current.loading
1273
1351
  });
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;
1352
+ }, [oe]);
1353
+ we(() => {
1354
+ const i = ue.getPinnedColumns(), h = ue.getScrollableColumns(), C = ue.getPinnedWidth(), k = [], v = [];
1355
+ let m = 0;
1356
+ for (const de of i)
1357
+ k.push(m), v.push(de.width), m += de.width;
1358
+ const s = [], g = [];
1359
+ let y = 0;
1360
+ for (const de of h)
1361
+ s.push(y), g.push(de.width), y += de.width;
1362
+ const X = fe.current;
1363
+ X.pinnedWidth = C, X.setPinnedOffsets(k, v), X.setScrollableOffsets(s, g);
1364
+ const K = ue.getVisibleColumns(), Z = [], ge = [];
1365
+ let Ie = 0;
1366
+ for (const de of K)
1367
+ Z.push(Ie), ge.push(de.width), Ie += de.width;
1368
+ X.setColumnOffsets(Z), X.setColumnWidths(ge), X.update({ rowHeight: W });
1369
+ }, [ue, W]), we(() => {
1370
+ const i = new yn(yt);
1371
+ return j.current = i, i.markAllDirty(), () => {
1372
+ i.destroy(), j.current = null;
1295
1373
  };
1296
- }, [nt]), re(() => {
1297
- const i = et.current;
1374
+ }, [yt]), we(() => {
1375
+ const i = Ee.current;
1298
1376
  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();
1377
+ const h = new ResizeObserver((C) => {
1378
+ var k, v;
1379
+ for (const m of C) {
1380
+ const { width: s, height: g } = m.contentRect, y = s - Be, X = qt(A.current.headerOrientation ?? "horizontal", (((k = A.current.columnGroups) == null ? void 0 : k.length) ?? 0) > 0, A.current.columnHeaderHeight), K = g - X;
1381
+ fe.current.update({
1382
+ canvasWidth: Math.max(0, y),
1383
+ canvasHeight: Math.max(0, K)
1384
+ }), se({
1385
+ width: Math.max(0, y),
1386
+ height: Math.max(0, K)
1387
+ }), (v = j.current) == null || v.markAllDirty();
1307
1388
  }
1308
1389
  });
1309
- return g.observe(i), () => g.disconnect();
1310
- }, [_e]), re(() => {
1390
+ return h.observe(i), () => h.disconnect();
1391
+ }, [Be]), we(() => {
1311
1392
  var i;
1312
- (i = N.current) == null || i.markAllDirty();
1313
- }, [ke, se, tt]), re(() => {
1393
+ (i = j.current) == null || i.markAllDirty();
1394
+ }, [Le, ue, Ct]), we(() => {
1314
1395
  var i;
1315
- (i = N.current) == null || i.markDirty("overlay");
1316
- }, [u]);
1317
- const Ke = te((i) => {
1318
- var ae;
1396
+ (i = j.current) == null || i.markDirty("overlay");
1397
+ }, [N]);
1398
+ const dt = le((i) => {
1399
+ var ge;
1319
1400
  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();
1401
+ const h = fe.current, C = Ce.current;
1402
+ if (!C) return;
1403
+ const k = C.treeEngine.flattenedRows.length * h.rowHeight, v = C.columnEngine.getTotalWidth(), m = Math.max(0, k - h.canvasHeight), s = v - C.columnEngine.getPinnedWidth(), g = h.canvasWidth - C.columnEngine.getPinnedWidth(), y = Math.max(0, s - g), X = Math.max(0, Math.min(m, h.scrollY + i.deltaY)), K = Math.max(0, Math.min(y, h.scrollX + i.deltaX));
1404
+ h.update({ scrollY: X, scrollX: K }), V(X), U(K), (ge = j.current) == null || ge.markAllDirty();
1324
1405
  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);
1406
+ Z.hasMore && Z.onLoadMore && !Z.loading && m - X < jt ? et.current || (et.current = !0, Z.onLoadMore()) : m - X >= jt && (et.current = !1);
1326
1407
  }, []);
1327
- re(() => {
1328
- const i = pe.current[2];
1408
+ we(() => {
1409
+ const i = _e.current[2];
1329
1410
  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;
1411
+ return i.addEventListener("wheel", dt, { passive: !1 }), () => i.removeEventListener("wheel", dt);
1412
+ }, [dt]), we(() => {
1413
+ N || (et.current = !1);
1414
+ }, [N]);
1415
+ const en = le((i) => {
1416
+ var g, y, X;
1417
+ const h = Ce.current;
1418
+ if (!h) return;
1419
+ const C = _e.current[2];
1420
+ if (!C) return;
1421
+ const k = C.getBoundingClientRect(), v = i.clientX - k.left, m = i.clientY - k.top, s = rt(v, m, fe.current, h.treeEngine, h.columnEngine);
1422
+ Qe.current = s, ve.current = (s == null ? void 0 : s.rowId) ?? null, Me((s == null ? void 0 : s.rowId) ?? null), (g = j.current) == null || g.markDirty("overlay"), (X = (y = A.current).onCellHover) == null || X.call(y, (s == null ? void 0 : s.rowId) ?? null, (s == null ? void 0 : s.colId) ?? null, i.nativeEvent);
1423
+ }, []), at = le((i) => {
1424
+ P((h) => {
1425
+ var k, v;
1426
+ const C = new Set(h);
1427
+ return C.has(i) ? (C.delete(i), Q(`Row ${i} collapsed`)) : (C.add(i), Q(`Row ${i} expanded`)), (v = (k = A.current).onExpandChange) == null || v.call(k, [...C]), C;
1347
1428
  });
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);
1429
+ }, []), tn = le((i) => {
1430
+ var Fe, Ke, Ue, Ne, je;
1431
+ const h = Ce.current;
1432
+ if (!h) return;
1433
+ const C = _e.current[2];
1434
+ if (!C) return;
1435
+ const k = C.getBoundingClientRect(), v = i.clientX - k.left, m = i.clientY - k.top, s = rt(v, m, fe.current, h.treeEngine, h.columnEngine);
1355
1436
  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);
1437
+ const { treeEngine: g, columnEngine: y, selectionEngine: X } = h, K = y.getPinnedColumns();
1438
+ if (K.length > 0) {
1439
+ const Re = K[0].id;
1440
+ if (g.hasChildren(s.rowId) && s.colId === Re) {
1441
+ A.current.onTreeToggle ? A.current.onTreeToggle(s.rowId) : at(s.rowId);
1361
1442
  return;
1362
1443
  }
1363
1444
  }
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;
1445
+ const Z = g.flattenedRows.map((Re) => Re.id), ge = y.getVisibleColumns().map((Re) => Re.id);
1446
+ i.ctrlKey || i.metaKey ? X.ctrlClick(s.rowId, s.colId) : i.shiftKey ? X.shiftClick(s.rowId, s.colId, Z, ge) : X.click(s.rowId, s.colId, Z, ge), he.current = { rowId: s.rowId, colId: s.colId }, (Ke = (Fe = A.current).onSelectionChange) == null || Ke.call(Fe, X.getSelection()), (Ne = (Ue = A.current).onCellClick) == null || Ne.call(Ue, s.rowId, s.colId, i.nativeEvent), (je = j.current) == null || je.markDirty("overlay");
1447
+ const Ie = String(s.rowId), de = y.getVisibleColumns().find((Re) => Re.id === s.colId), it = (de == null ? void 0 : de.title) ?? s.colId;
1448
+ Q(`Row ${Ie}, Column ${it} selected`);
1449
+ }, [at]), nn = le((i) => {
1450
+ var g, y;
1451
+ const h = Ce.current;
1452
+ if (!h) return;
1453
+ const C = _e.current[2];
1454
+ if (!C) return;
1455
+ const k = C.getBoundingClientRect(), v = i.clientX - k.left, m = i.clientY - k.top, s = rt(v, m, fe.current, h.treeEngine, h.columnEngine);
1456
+ s && ((y = (g = A.current).onCellDoubleClick) == null || y.call(g, s.rowId, s.colId, i.nativeEvent));
1457
+ }, []), on = le((i) => {
1458
+ var g, y;
1378
1459
  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);
1460
+ const h = Ce.current;
1461
+ if (!h) return;
1462
+ const C = _e.current[2];
1463
+ if (!C) return;
1464
+ const k = C.getBoundingClientRect(), v = i.clientX - k.left, m = i.clientY - k.top, s = rt(v, m, fe.current, h.treeEngine, h.columnEngine);
1465
+ s && ((y = (g = A.current).onCellContextMenu) == null || y.call(g, s.rowId, s.colId, i.nativeEvent));
1466
+ }, []), ln = le(() => {
1467
+ var i, h, C;
1468
+ Qe.current = null, ve.current = null, Me(null), (i = j.current) == null || i.markDirty("overlay"), (C = (h = A.current).onCellHover) == null || C.call(h, null, null, new PointerEvent("pointerleave"));
1469
+ }, []), sn = le(
1470
+ (i, h) => {
1471
+ var C, k;
1472
+ (k = (C = A.current).onColumnHeaderClick) == null || k.call(C, i, h.nativeEvent);
1392
1473
  },
1393
1474
  []
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) };
1475
+ ), rn = le(
1476
+ (i, h) => {
1477
+ var k, v, m, s;
1478
+ O((g) => g.map((X) => {
1479
+ if (X.id !== i) return X;
1480
+ const K = X.minWidth ?? 30;
1481
+ return { ...X, width: Math.max(K, h) };
1401
1482
  }));
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 });
1483
+ const C = (k = Ce.current) == null ? void 0 : k.columnEngine;
1484
+ if (C) {
1485
+ const g = C.getColumnX(i), y = C.getVisibleColumns().find((X) => X.id === i);
1486
+ if (y) {
1487
+ const K = y.pinned === "left" ? g + Math.max(y.minWidth ?? 30, h) : g + Math.max(y.minWidth ?? 30, h) - fe.current.scrollX;
1488
+ q({ colId: i, x: K });
1408
1489
  }
1409
1490
  }
1410
- (b = (v = A.current).onColumnResize) == null || b.call(v, i, g), (s = N.current) == null || s.markAllDirty();
1491
+ (m = (v = A.current).onColumnResize) == null || m.call(v, i, h), (s = j.current) == null || s.markAllDirty();
1411
1492
  },
1412
1493
  []
1413
1494
  );
1414
- re(() => {
1495
+ we(() => {
1415
1496
  const i = () => {
1416
- Pe(null);
1497
+ q(null);
1417
1498
  };
1418
1499
  return document.addEventListener("mouseup", i), () => document.removeEventListener("mouseup", i);
1419
1500
  }, []);
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();
1501
+ const cn = le(
1502
+ (i, h) => {
1503
+ var C, k, v;
1504
+ O((m) => {
1505
+ const s = [...m], g = s.findIndex((K) => K.id === i);
1506
+ if (g === -1) return m;
1507
+ const [y] = s.splice(g, 1), X = Math.max(0, Math.min(h, s.length));
1508
+ return s.splice(X, 0, y), s;
1509
+ }), (k = (C = A.current).onColumnReorder) == null || k.call(C, i, h), (v = j.current) == null || v.markAllDirty();
1429
1510
  },
1430
1511
  []
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();
1512
+ ), dn = le(
1513
+ (i, h) => {
1514
+ var C, k, v;
1515
+ O(
1516
+ (m) => m.map((s) => s.id === i ? { ...s, hidden: !h } : s)
1517
+ ), (k = (C = A.current).onColumnVisibilityChange) == null || k.call(C, i, h), (v = j.current) == null || v.markAllDirty();
1437
1518
  },
1438
1519
  []
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`);
1520
+ ), xt = le(
1521
+ (i, h, C, k) => {
1522
+ h.preventDefault(), h.stopPropagation(), Ye(!0);
1523
+ const v = i === "y" ? h.clientY : h.clientX, m = i === "y" ? fe.current.scrollY : fe.current.scrollX, s = (y) => {
1524
+ var Ie;
1525
+ const X = (i === "y" ? y.clientY : y.clientX) - v, K = C > 0 ? X / C * k : 0, Z = Math.max(0, Math.min(k, m + K)), ge = fe.current;
1526
+ i === "y" ? (ge.update({ scrollY: Z }), V(Z)) : (ge.update({ scrollX: Z }), U(Z)), (Ie = j.current) == null || Ie.markAllDirty();
1527
+ }, g = () => {
1528
+ Ye(!1), document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", g);
1529
+ };
1530
+ document.addEventListener("mousemove", s), document.addEventListener("mouseup", g);
1531
+ },
1532
+ []
1533
+ ), an = le((i) => {
1534
+ var ge, Ie, de, it, Fe, Ke, Ue, Ne, je, Re, pt, Wt, Ht, Dt, Xt, Pt, Et, Lt, Ot, At, zt, Yt, Vt, Bt;
1535
+ const h = Ce.current;
1536
+ if (!h) return;
1537
+ const { treeEngine: C, columnEngine: k, selectionEngine: v } = h, m = fe.current, s = C.flattenedRows.map((ee) => ee.id), g = k.getVisibleColumns().map((ee) => ee.id);
1538
+ if (s.length === 0 || g.length === 0) return;
1539
+ const y = v.getSelection().anchor, X = i.ctrlKey || i.metaKey, K = (ee, re) => {
1540
+ const ae = s.length * m.rowHeight, Te = k.getTotalWidth(), We = Math.max(0, ae - m.canvasHeight), lt = Math.max(0, Te - m.canvasWidth), Xe = ee * m.rowHeight, Ae = Xe + m.rowHeight;
1541
+ let ye = m.scrollY;
1542
+ Xe < m.scrollY ? ye = Xe : Ae > m.scrollY + m.canvasHeight && (ye = Ae - m.canvasHeight), ye = Math.max(0, Math.min(We, ye));
1543
+ const He = k.getVisibleColumns()[re], qe = He ? k.getColumnX(He.id) : 0, st = qe + ((He == null ? void 0 : He.width) ?? 0);
1544
+ let Se = m.scrollX;
1545
+ qe < m.scrollX ? Se = qe : st > m.scrollX + m.canvasWidth && (Se = st - m.canvasWidth), Se = Math.max(0, Math.min(lt, Se)), (ye !== m.scrollY || Se !== m.scrollX) && (m.update({ scrollY: ye, scrollX: Se }), V(ye), U(Se));
1546
+ }, Z = (ee, re, ae) => {
1547
+ var Gt, $t, Ft;
1548
+ let Te = y ? s.indexOf(y.rowId) : -1, We = y ? g.indexOf(y.colId) : -1;
1549
+ Te === -1 && (Te = 0), We === -1 && (We = 0);
1550
+ const lt = Math.max(0, Math.min(s.length - 1, Te + ee)), Xe = Math.max(0, Math.min(g.length - 1, We + re)), Ae = s[lt], ye = g[Xe];
1551
+ ae ? v.shiftClick(Ae, ye, s, g) : v.click(Ae, ye, s, g), ($t = (Gt = A.current).onSelectionChange) == null || $t.call(Gt, v.getSelection()), (Ft = j.current) == null || Ft.markDirty("overlay"), K(lt, Xe);
1552
+ const He = k.getVisibleColumns()[Xe], qe = String(Ae), st = (He == null ? void 0 : He.title) ?? String(ye), Se = v.getSelection().cells.size;
1553
+ Se > 1 ? Q(`${Se} cells selected`) : Q(`Row ${qe}, Column ${st} selected`);
1460
1554
  };
1461
1555
  switch (i.key) {
1462
1556
  case "ArrowUp":
@@ -1473,103 +1567,123 @@ const un = $t(
1473
1567
  break;
1474
1568
  case "Tab": {
1475
1569
  if (i.preventDefault(), i.shiftKey) {
1476
- const j = k ? s.indexOf(k.rowId) : 0;
1477
- if ((k ? p.indexOf(k.colId) : 0) > 0)
1570
+ const ee = y ? s.indexOf(y.rowId) : 0;
1571
+ if ((y ? g.indexOf(y.colId) : 0) > 0)
1478
1572
  Z(0, -1, !1);
1479
1573
  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);
1574
+ const ae = Math.max(0, (ee === -1 ? 0 : ee) - 1), Te = s[ae], We = g[g.length - 1];
1575
+ v.click(Te, We, s, g), (Fe = (it = A.current).onSelectionChange) == null || Fe.call(it, v.getSelection()), (Ke = j.current) == null || Ke.markDirty("overlay"), K(ae, g.length - 1);
1482
1576
  }
1483
1577
  } else {
1484
- const j = k ? s.indexOf(k.rowId) : 0;
1485
- if ((k ? p.indexOf(k.colId) : -1) < p.length - 1)
1578
+ const ee = y ? s.indexOf(y.rowId) : 0;
1579
+ if ((y ? g.indexOf(y.colId) : -1) < g.length - 1)
1486
1580
  Z(0, 1, !1);
1487
1581
  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);
1582
+ const ae = Math.min(s.length - 1, (ee === -1 ? 0 : ee) + 1), Te = s[ae], We = g[0];
1583
+ v.click(Te, We, s, g), (Ie = (ge = A.current).onSelectionChange) == null || Ie.call(ge, v.getSelection()), (de = j.current) == null || de.markDirty("overlay"), K(ae, 0);
1490
1584
  }
1491
1585
  }
1492
1586
  break;
1493
1587
  }
1494
1588
  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");
1589
+ i.preventDefault(), v.clear(), (Ne = (Ue = A.current).onSelectionChange) == null || Ne.call(Ue, v.getSelection()), (je = j.current) == null || je.markDirty("overlay"), Q("Selection cleared");
1496
1590
  break;
1497
1591
  case "a":
1498
1592
  case "A":
1499
- if (E) {
1593
+ if (X) {
1500
1594
  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`);
1595
+ for (const ee of s)
1596
+ for (const re of g)
1597
+ v.ctrlClick(ee, re);
1598
+ (pt = (Re = A.current).onSelectionChange) == null || pt.call(Re, v.getSelection()), (Wt = j.current) == null || Wt.markDirty("overlay"), Q(`${s.length * g.length} cells selected`);
1505
1599
  }
1506
1600
  break;
1507
1601
  case "Home": {
1508
1602
  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);
1603
+ const ee = y ? s.indexOf(y.rowId) : 0;
1604
+ if (X)
1605
+ v.click(s[0], g[0], s, g), (Dt = (Ht = A.current).onSelectionChange) == null || Dt.call(Ht, v.getSelection()), (Xt = j.current) == null || Xt.markDirty("overlay"), K(0, 0);
1512
1606
  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);
1607
+ const re = ee === -1 ? 0 : ee;
1608
+ v.click(s[re], g[0], s, g), (Et = (Pt = A.current).onSelectionChange) == null || Et.call(Pt, v.getSelection()), (Lt = j.current) == null || Lt.markDirty("overlay"), K(re, 0);
1515
1609
  }
1516
1610
  break;
1517
1611
  }
1518
1612
  case "End": {
1519
1613
  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);
1614
+ const ee = y ? s.indexOf(y.rowId) : 0;
1615
+ if (X) {
1616
+ const re = s.length - 1, ae = g.length - 1;
1617
+ v.click(s[re], g[ae], s, g), (At = (Ot = A.current).onSelectionChange) == null || At.call(Ot, v.getSelection()), (zt = j.current) == null || zt.markDirty("overlay"), K(re, ae);
1524
1618
  } 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);
1619
+ const re = ee === -1 ? 0 : ee, ae = g.length - 1;
1620
+ v.click(s[re], g[ae], s, g), (Vt = (Yt = A.current).onSelectionChange) == null || Vt.call(Yt, v.getSelection()), (Bt = j.current) == null || Bt.markDirty("overlay"), K(re, ae);
1527
1621
  }
1528
1622
  break;
1529
1623
  }
1530
1624
  }
1531
1625
  }, []);
1532
- Kt(o, () => ({
1626
+ vn(o, () => ({
1533
1627
  captureToCanvas(i) {
1534
- const g = fe.current;
1535
- if (!g)
1628
+ const h = Ce.current;
1629
+ if (!h)
1536
1630
  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: _,
1631
+ const { treeEngine: C, columnEngine: k, selectionEngine: v } = h, m = A.current, s = m.rowHeight ?? Nt, g = m.sidebarWidth ?? Ut;
1632
+ return An({
1633
+ treeEngine: C,
1634
+ columnEngine: k,
1541
1635
  selectionEngine: v,
1542
- columnGroups: b.columnGroups,
1636
+ columnGroups: m.columnGroups,
1543
1637
  rowHeight: s,
1544
- sidebarWidth: p,
1545
- gridLayerConfig: { rowStyle: b.rowStyle },
1638
+ sidebarWidth: g,
1639
+ headerOrientation: m.headerOrientation ?? "horizontal",
1640
+ columnHeaderHeight: m.columnHeaderHeight,
1641
+ gridLayerConfig: { rowStyle: m.rowStyle },
1546
1642
  cellLayerConfig: {
1547
- cellRenderer: b.cellRenderer,
1548
- getCellData: b.getCellData,
1643
+ cellRenderer: m.cellRenderer,
1644
+ getCellData: m.getCellData,
1549
1645
  hoveredCell: null
1550
1646
  },
1551
- scale: (i == null ? void 0 : i.scale) ?? 2
1647
+ scale: (i == null ? void 0 : i.scale) ?? 2,
1648
+ rowRange: i == null ? void 0 : i.rowRange
1552
1649
  });
1650
+ },
1651
+ getRowCount() {
1652
+ var i;
1653
+ return ((i = Ce.current) == null ? void 0 : i.treeEngine.flattenedRows.length) ?? 0;
1553
1654
  }
1554
1655
  }), []);
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(
1656
+ const hn = c != null && c.length > 0, It = qt(
1657
+ L ?? "horizontal",
1658
+ hn,
1659
+ x
1660
+ ), fn = Be + ue.getTotalWidth() + 2, un = It + Le.flattenedRows.length * W + 2, Oe = 12, Rt = 24, tt = pe || Je, St = Le.flattenedRows.length * W, gn = ue.getTotalWidth(), ht = ue.getPinnedWidth(), nt = Math.max(0, St - F.height), kt = gn - ht, ft = Math.max(0, F.width - ht), ot = Math.max(0, kt - ft), Mt = 2, _t = nt > Mt && F.height > 0, Tt = ot > Mt && F.width > 0, Ge = F.height - (Tt ? Oe : 0), ut = Math.min(
1661
+ Ge,
1662
+ Math.max(Rt, Ge * (F.height / St))
1663
+ ), pn = nt > 0 ? $ / nt * (Ge - ut) : 0, $e = ft - (_t ? Oe : 0), gt = Math.min(
1664
+ $e,
1665
+ Math.max(
1666
+ Rt,
1667
+ $e * (ft / kt)
1668
+ )
1669
+ ), mn = ot > 0 ? G / ot * ($e - gt) : 0;
1670
+ return /* @__PURE__ */ be(
1557
1671
  "div",
1558
1672
  {
1559
- ref: et,
1673
+ ref: Ee,
1560
1674
  tabIndex: 0,
1561
1675
  role: "grid",
1562
- "aria-label": K,
1563
- "aria-rowcount": ke.flattenedRows.length,
1564
- "aria-colcount": se.getVisibleColumns().length,
1565
- onKeyDown: At,
1676
+ "aria-label": ke,
1677
+ "aria-rowcount": Le.flattenedRows.length,
1678
+ "aria-colcount": ue.getVisibleColumns().length,
1679
+ onKeyDown: an,
1566
1680
  style: {
1567
1681
  display: "flex",
1568
1682
  flexDirection: "column",
1569
- width: Vt,
1570
- height: Gt,
1683
+ width: fn,
1684
+ height: un,
1571
1685
  maxWidth: "100%",
1572
- maxHeight: "100%",
1686
+ maxHeight: H ?? "100%",
1573
1687
  overflow: "hidden",
1574
1688
  fontFamily: "system-ui, sans-serif",
1575
1689
  outline: "none",
@@ -1577,12 +1691,12 @@ const un = $t(
1577
1691
  borderRadius: 4
1578
1692
  },
1579
1693
  children: [
1580
- /* @__PURE__ */ de("div", { style: { display: "flex", flexDirection: "row", height: ot, flexShrink: 0 }, children: [
1581
- !Be && /* @__PURE__ */ H(
1694
+ /* @__PURE__ */ be("div", { style: { display: "flex", flexDirection: "row", height: It, flexShrink: 0 }, children: [
1695
+ !ct && /* @__PURE__ */ _(
1582
1696
  "div",
1583
1697
  {
1584
1698
  style: {
1585
- width: _e,
1699
+ width: Be,
1586
1700
  flexShrink: 0,
1587
1701
  borderRight: "1px solid #e5e7eb",
1588
1702
  borderBottom: "1px solid #e5e7eb",
@@ -1591,95 +1705,169 @@ const un = $t(
1591
1705
  flexDirection: "column",
1592
1706
  overflow: "hidden"
1593
1707
  },
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,
1708
+ children: e.sidebarHeaderRenderer ? /* @__PURE__ */ _("div", { style: { width: "100%", flex: 1 }, children: e.sidebarHeaderRenderer() }) : De ? /* @__PURE__ */ _("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", flex: 1 }, children: /* @__PURE__ */ _(
1709
+ Xn,
1596
1710
  {
1597
- columnEngine: se,
1598
- onColumnVisibilityChange: zt
1711
+ columnEngine: ue,
1712
+ onColumnVisibilityChange: dn
1599
1713
  }
1600
1714
  ) }) : null
1601
1715
  }
1602
1716
  ),
1603
- /* @__PURE__ */ H(
1604
- on,
1717
+ /* @__PURE__ */ _(
1718
+ Dn,
1605
1719
  {
1606
- columnEngine: se,
1720
+ columnEngine: ue,
1607
1721
  columnGroups: c,
1608
- scrollX: V,
1722
+ scrollX: G,
1609
1723
  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,
1724
+ columnHeaderHeight: x,
1725
+ onColumnClick: w ? sn : void 0,
1726
+ onColumnResize: e.onColumnResize !== void 0 ? rn : void 0,
1727
+ onColumnReorder: e.onColumnReorder !== void 0 ? cn : void 0,
1728
+ onColumnFilterClick: e.onColumnFilterClick,
1613
1729
  columnHeaderRenderer: e.columnHeaderRenderer
1614
1730
  }
1615
1731
  )
1616
1732
  ] }),
1617
- /* @__PURE__ */ de("div", { style: { display: "flex", flexDirection: "row", flex: 1, overflow: "hidden" }, children: [
1618
- !Be && /* @__PURE__ */ H(
1619
- en,
1733
+ /* @__PURE__ */ be("div", { style: { display: "flex", flexDirection: "row", flex: 1, overflow: "hidden" }, children: [
1734
+ !ct && /* @__PURE__ */ _(
1735
+ _n,
1620
1736
  {
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,
1737
+ treeEngine: Le,
1738
+ width: Be,
1739
+ rowHeight: W,
1740
+ scrollTop: $,
1741
+ viewportHeight: fe.current.canvasHeight || 600,
1742
+ sidebarRenderer: u,
1743
+ onToggle: at,
1744
+ onRowClick: e.onRowHeaderClick ? (i, h) => e.onRowHeaderClick(i, h.nativeEvent) : void 0,
1745
+ hoveredRowId: ie,
1630
1746
  onRowHover: (i) => {
1631
- var g;
1632
- Ee.current = i, $e(i), (g = N.current) == null || g.markDirty("overlay");
1747
+ var h;
1748
+ ve.current = i, Me(i), (h = j.current) == null || h.markDirty("overlay");
1633
1749
  }
1634
1750
  }
1635
1751
  ),
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
- ] })
1752
+ /* @__PURE__ */ be(
1753
+ "div",
1754
+ {
1755
+ style: { flex: 1, position: "relative", overflow: "hidden" },
1756
+ onMouseEnter: () => te(!0),
1757
+ onMouseLeave: () => te(!1),
1758
+ children: [
1759
+ /* @__PURE__ */ _(
1760
+ "canvas",
1761
+ {
1762
+ ref: (i) => {
1763
+ i && (_e.current[0] = i);
1764
+ },
1765
+ style: { position: "absolute", top: 0, left: 0, zIndex: 0 }
1766
+ }
1767
+ ),
1768
+ /* @__PURE__ */ _(
1769
+ "canvas",
1770
+ {
1771
+ ref: (i) => {
1772
+ i && (_e.current[1] = i);
1773
+ },
1774
+ style: { position: "absolute", top: 0, left: 0, zIndex: 1 }
1775
+ }
1776
+ ),
1777
+ /* @__PURE__ */ _(
1778
+ "canvas",
1779
+ {
1780
+ ref: (i) => {
1781
+ i && (_e.current[2] = i);
1782
+ },
1783
+ style: { position: "absolute", top: 0, left: 0, zIndex: 2 },
1784
+ onPointerMove: en,
1785
+ onPointerDown: tn,
1786
+ onDoubleClick: nn,
1787
+ onContextMenu: on,
1788
+ onPointerLeave: ln
1789
+ }
1790
+ ),
1791
+ _t && /* @__PURE__ */ _(
1792
+ "div",
1793
+ {
1794
+ style: {
1795
+ position: "absolute",
1796
+ top: 0,
1797
+ right: 0,
1798
+ width: Oe,
1799
+ height: Ge,
1800
+ zIndex: 3,
1801
+ opacity: tt ? 1 : 0,
1802
+ transition: "opacity 150ms ease",
1803
+ pointerEvents: tt ? "auto" : "none"
1804
+ },
1805
+ children: /* @__PURE__ */ _(
1806
+ "div",
1807
+ {
1808
+ onMouseDown: (i) => xt("y", i, Ge - ut, nt),
1809
+ style: {
1810
+ position: "absolute",
1811
+ top: pn,
1812
+ left: 2,
1813
+ width: Oe - 4,
1814
+ height: ut,
1815
+ borderRadius: 8,
1816
+ backgroundColor: "rgba(0, 0, 0, 0.3)",
1817
+ cursor: "pointer"
1818
+ }
1819
+ }
1820
+ )
1821
+ }
1822
+ ),
1823
+ Tt && /* @__PURE__ */ _(
1824
+ "div",
1825
+ {
1826
+ style: {
1827
+ position: "absolute",
1828
+ bottom: 0,
1829
+ left: ht,
1830
+ height: Oe,
1831
+ width: $e,
1832
+ zIndex: 3,
1833
+ opacity: tt ? 1 : 0,
1834
+ transition: "opacity 150ms ease",
1835
+ pointerEvents: tt ? "auto" : "none"
1836
+ },
1837
+ children: /* @__PURE__ */ _(
1838
+ "div",
1839
+ {
1840
+ onMouseDown: (i) => xt("x", i, $e - gt, ot),
1841
+ style: {
1842
+ position: "absolute",
1843
+ left: mn,
1844
+ top: 2,
1845
+ height: Oe - 4,
1846
+ width: gt,
1847
+ borderRadius: 8,
1848
+ backgroundColor: "rgba(0, 0, 0, 0.3)",
1849
+ cursor: "pointer"
1850
+ }
1851
+ }
1852
+ )
1853
+ }
1854
+ )
1855
+ ]
1856
+ }
1857
+ )
1670
1858
  ] }),
1671
- x != null && F != null && /* @__PURE__ */ H(sn, { content: x, position: F }),
1672
- /* @__PURE__ */ H(rn, { message: Tt })
1859
+ l != null && ne != null && /* @__PURE__ */ _(Pn, { content: l, position: ne }),
1860
+ /* @__PURE__ */ _(En, { message: xe })
1673
1861
  ]
1674
1862
  }
1675
1863
  );
1676
1864
  })
1677
1865
  );
1678
1866
  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
1867
+ Gn as CanvasGrid,
1868
+ Pe as ColumnEngine,
1869
+ Rn as SelectionEngine,
1870
+ xn as TreeEngine,
1871
+ Zt as ViewState,
1872
+ kn as createDrawHelpers
1685
1873
  };