@taskctrl/canvas-grid 0.1.1 → 0.1.3

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