@cronocode/react-box 3.0.20 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/box.d.ts +7 -2
  2. package/box.mjs +4 -4
  3. package/components/baseSvg.cjs +1 -1
  4. package/components/baseSvg.d.ts +1 -1
  5. package/components/button.cjs +1 -1
  6. package/components/checkbox.cjs +1 -1
  7. package/components/dataGrid/components/dataGridBody.d.ts +7 -0
  8. package/components/dataGrid/components/dataGridBottomBar.d.ts +6 -0
  9. package/components/dataGrid/components/dataGridColumnGroups.d.ts +1 -1
  10. package/components/dataGrid/components/dataGridContent.d.ts +6 -0
  11. package/components/dataGrid/components/dataGridHeader.d.ts +6 -0
  12. package/components/dataGrid/components/dataGridHeaderCellContextMenu.d.ts +6 -0
  13. package/components/dataGrid/components/dataGridHeaderCellResizer.d.ts +6 -0
  14. package/components/dataGrid/components/dataGridPagination.d.ts +1 -1
  15. package/components/dataGrid/components/dataGridTopBar.d.ts +6 -0
  16. package/components/dataGrid/components/dataGridTopBarContextMenu.d.ts +6 -0
  17. package/components/dataGrid/contracts/dataGridContract.d.ts +16 -0
  18. package/components/dataGrid/models/columnModel.d.ts +1 -1
  19. package/components/dataGrid/models/gridModel.d.ts +15 -7
  20. package/components/dataGrid/models/groupRowModel.d.ts +3 -2
  21. package/components/dataGrid/models/rowModel.d.ts +8 -7
  22. package/components/dataGrid.cjs +1 -1
  23. package/components/dataGrid.d.ts +1 -1
  24. package/components/dataGrid.mjs +511 -576
  25. package/components/dropdown.cjs +1 -1
  26. package/components/dropdown.d.ts +1 -1
  27. package/components/dropdown.mjs +111 -135
  28. package/components/flex.cjs +1 -1
  29. package/components/form.cjs +1 -1
  30. package/components/form.mjs +1 -1
  31. package/components/grid.cjs +1 -1
  32. package/components/radioButton.cjs +1 -1
  33. package/components/radioButton.mjs +10 -10
  34. package/components/semantics.d.ts +25 -25
  35. package/components/semantics.mjs +1 -1
  36. package/components/textarea.cjs +1 -1
  37. package/components/textbox.cjs +1 -1
  38. package/components/tooltip.cjs +1 -1
  39. package/components/tooltip.d.ts +6 -3
  40. package/components/tooltip.mjs +34 -34
  41. package/core/boxStyles.d.ts +28 -4
  42. package/core/boxStylesFormatters.d.ts +1 -1
  43. package/core/coreTypes.d.ts +1 -1
  44. package/core/extends/boxComponents.d.ts +194 -18
  45. package/core.cjs +3 -3
  46. package/core.mjs +476 -306
  47. package/icons/expandIcon.d.ts +2 -0
  48. package/icons/sortIcon.d.ts +2 -0
  49. package/package.json +22 -14
  50. package/ssg.cjs +1 -1
  51. package/ssg.mjs +17 -16
  52. package/utils/object/objectUtils.d.ts +2 -2
  53. package/icons/arrowIcon.d.ts +0 -2
@@ -1,56 +1,32 @@
1
- var ae = Object.defineProperty;
2
- var ue = (u, e, t) => e in u ? ae(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
3
- var a = (u, e, t) => ue(u, typeof e != "symbol" ? e + "" : e, t);
4
- import { jsx as r, jsxs as c, Fragment as he } from "react/jsx-runtime";
5
- import g from "../box.mjs";
6
- import j from "./grid.mjs";
7
- import de, { useMemo as E, useState as z, forwardRef as ce, useRef as me, useCallback as ge, useImperativeHandle as pe } from "react";
8
- import { F as q, m as D, A as $, b as Y, D as fe, P as K, G as H, C as Ce, S as we, d as ye } from "../core.mjs";
9
- import p from "./button.mjs";
1
+ import { jsxs as h, jsx as s, Fragment as Re } from "react/jsx-runtime";
2
+ import m from "../box.mjs";
3
+ import w from "./flex.mjs";
4
+ import ve, { useCallback as P, useMemo as I, useState as U, useRef as xe } from "react";
5
+ import { F as Q, m as M, E as Z, b as ee, D as ke, S as O, P as j, G as F, C as Ge } from "../core.mjs";
6
+ import g from "./button.mjs";
10
7
  import V from "./checkbox.mjs";
11
- import C from "./flex.mjs";
12
- import J from "./tooltip.mjs";
13
- import ve from "./baseSvg.mjs";
14
- import Re from "./textbox.mjs";
15
- const be = "NO_PIN";
16
- class G {
8
+ import te from "./grid.mjs";
9
+ import { Span as L } from "./semantics.mjs";
10
+ import ie from "./tooltip.mjs";
11
+ import be from "./baseSvg.mjs";
12
+ function _e(a) {
13
+ const { grid: e } = a;
14
+ return /* @__PURE__ */ h(w, { component: "datagrid.bottomBar", children: [
15
+ /* @__PURE__ */ h(m, { children: [
16
+ "Rows: ",
17
+ e.props.data.length
18
+ ] }),
19
+ e.props.def.rowSelection && /* @__PURE__ */ h(m, { children: [
20
+ "Selected: ",
21
+ e.selectedRows.size
22
+ ] })
23
+ ] });
24
+ }
25
+ class D {
17
26
  constructor(e, t, i) {
18
- a(this, "columns", []);
19
- a(this, "_pin");
20
- a(this, "_inlineWidth");
21
- a(this, "resizeColumn", (e) => {
22
- this.grid.isResizeMode = !0;
23
- const t = e.pageX, { MIN_COLUMN_WIDTH_PX: i, update: o } = this.grid, s = this.leafs.sumBy((d) => d.inlineWidth) - this.leafs.length * i, n = this.leafs.toRecord((d) => [d.key, d.inlineWidth]), h = q.throttle((d) => {
24
- const w = (d.pageX - t) * (this.pin === "RIGHT" ? -1 : 1);
25
- this.leafs.forEach((y) => {
26
- const k = n[y.key], x = s > 0 ? (k - i) / s * w : w / this.leafs.length, v = Math.round(k + x);
27
- y.setWidth(v < i ? i : v);
28
- }), this.grid.headerRows.clear(), this.grid.sizes.clear(), o();
29
- }, 20), l = new AbortController(), m = (d) => {
30
- l.abort(), this.grid.isResizeMode = !1, o();
31
- };
32
- window.addEventListener("mousemove", h, l), window.addEventListener("mouseup", m, l);
33
- });
34
- a(this, "pinColumn", (e) => {
35
- this.isLeaf ? this._pin = e : this.columns.forEach((t) => t.pinColumn(e)), this.grid.pinColumn(this.uniqueKey, e);
36
- });
37
- a(this, "toggleGrouping", () => {
38
- this.grid.toggleGrouping(this.key);
39
- });
40
- a(this, "sortColumn", (...e) => {
41
- this.grid.setSortColumn(this.key, ...e);
42
- });
43
- a(this, "setWidth", (e) => {
44
- if (!this.isLeaf)
45
- throw new Error("Cannot set width for a parent column.");
46
- this._inlineWidth !== e && (this._inlineWidth = e, this.grid.setWidth(this.key, e));
47
- });
48
- a(this, "toggleVisibility", () => {
49
- this.grid.toggleColumnVisibility(this.key);
50
- });
51
- var o;
52
- this.def = e, this.grid = t, this.parent = i, this.columns = ((o = e.columns) == null ? void 0 : o.map((s) => new G(e.pin ? { ...s, pin: e.pin } : s, t, this))) ?? [], this.isLeaf && (this._inlineWidth = this.key == P ? void 0 : this.def.width ?? this.grid.DEFAULT_COLUMN_WIDTH_PX, this._pin = e.pin);
27
+ this.def = e, this.grid = t, this.parent = i, this.columns = e.columns?.map((o) => new D(e.pin ? { ...o, pin: e.pin } : o, t, this)) ?? [], this.isLeaf && (this._inlineWidth = this.key == T ? void 0 : this.def.width ?? this.grid.DEFAULT_COLUMN_WIDTH_PX, this._pin = e.pin);
53
28
  }
29
+ columns = [];
54
30
  get visibleColumns() {
55
31
  return this.columns.filter((e) => e.isVisible);
56
32
  }
@@ -66,6 +42,7 @@ class G {
66
42
  get isLeaf() {
67
43
  return this.columns.length === 0;
68
44
  }
45
+ _pin;
69
46
  get pin() {
70
47
  if (this.isLeaf) return this._pin;
71
48
  const e = [...new Set(this.columns.flatMap((t) => t.pin))];
@@ -77,7 +54,7 @@ class G {
77
54
  getPinnedColumn(e) {
78
55
  if (this.hasPin(e)) {
79
56
  if (this.isLeaf) return this;
80
- const t = new G({ ...this.def, pin: e }, this.grid, this.parent);
57
+ const t = new D({ ...this.def, pin: e }, this.grid, this.parent);
81
58
  return t.columns = this.columns.filter((i) => i.hasPin(e)).map((i) => {
82
59
  const o = i.getPinnedColumn(e);
83
60
  return o.parent = t, o;
@@ -94,6 +71,7 @@ class G {
94
71
  const e = [this];
95
72
  return e.push(...this.columns.flatMap((t) => t.flatColumns)), e;
96
73
  }
74
+ _inlineWidth;
97
75
  get inlineWidth() {
98
76
  if (this.isLeaf) return this._inlineWidth;
99
77
  const e = this.visibleColumns.map((t) => t.inlineWidth).filter((t) => typeof t == "number");
@@ -103,22 +81,22 @@ class G {
103
81
  get left() {
104
82
  let e = 0;
105
83
  if (this.parent) {
106
- const { visibleColumns: t, left: i } = this.parent, o = t.findIndex((s) => s === this);
107
- e += t.sumBy((s, n) => n < o ? s.inlineWidth ?? 0 : 0), e += i;
84
+ const { visibleColumns: t, left: i } = this.parent, o = t.findIndex((n) => n === this);
85
+ e += t.sumBy((n, r) => r < o ? n.inlineWidth ?? 0 : 0), e += i;
108
86
  } else {
109
87
  const t = this.grid.columns.value.left.filter((o) => o.isVisible), i = t.findIndex((o) => o === this);
110
- e += t.sumBy((o, s) => s < i ? o.inlineWidth ?? 0 : 0);
88
+ e += t.sumBy((o, n) => n < i ? o.inlineWidth ?? 0 : 0);
111
89
  }
112
90
  return e;
113
91
  }
114
92
  get right() {
115
93
  let e = 0;
116
94
  if (this.parent) {
117
- const { visibleColumns: t } = this.parent, i = t.reverse(), o = i.findIndex((s) => s === this);
118
- e += i.sumBy((s, n) => n < o ? s.inlineWidth ?? 0 : 0), e += this.parent.right;
95
+ const { visibleColumns: t } = this.parent, i = t.reverse(), o = i.findIndex((n) => n === this);
96
+ e += i.sumBy((n, r) => r < o ? n.inlineWidth ?? 0 : 0), e += this.parent.right;
119
97
  } else {
120
- const i = this.grid.columns.value.right.filter((s) => s.isVisible).reverse(), o = i.findIndex((s) => s === this);
121
- e += i.sumBy((s, n) => n < o ? s.inlineWidth ?? 0 : 0);
98
+ const i = this.grid.columns.value.right.filter((n) => n.isVisible).reverse(), o = i.findIndex((n) => n === this);
99
+ e += i.sumBy((n, r) => r < o ? n.inlineWidth ?? 0 : 0);
122
100
  }
123
101
  return e;
124
102
  }
@@ -131,7 +109,7 @@ class G {
131
109
  return (this.pin === "LEFT" ? this.grid.columns.value.left.filter((t) => t.isVisible).at(-1) : this.grid.columns.value.right.filter((t) => t.isVisible).at(0)) === this;
132
110
  }
133
111
  get isVisible() {
134
- return this.isLeaf ? !this.grid.hiddenColumns.includes(this.key) : this.leafs.some((e) => e.isVisible);
112
+ return this.isLeaf ? !this.grid.hiddenColumns.has(this.key) : this.leafs.some((e) => e.isVisible);
135
113
  }
136
114
  // Approved
137
115
  get leafs() {
@@ -152,29 +130,58 @@ class G {
152
130
  get gridRows() {
153
131
  return this.isLeaf ? this.grid.columns.value.maxDeath - this.death : 1;
154
132
  }
133
+ resizeColumn = (e) => {
134
+ this.grid.isResizeMode = !0;
135
+ const t = e.pageX, { MIN_COLUMN_WIDTH_PX: i, update: o } = this.grid, n = this.leafs.sumBy((u) => u.inlineWidth) - this.leafs.length * i, r = this.leafs.toRecord((u) => [u.key, u.inlineWidth]), c = Q.throttle((u) => {
136
+ const p = (u.pageX - t) * (this.pin === "RIGHT" ? -1 : 1);
137
+ this.leafs.forEach((C) => {
138
+ const x = r[C.key], k = n > 0 ? (x - i) / n * p : p / this.leafs.length, y = Math.round(x + k);
139
+ C.setWidth(y < i ? i : y);
140
+ }), this.grid.sizes.clear(), o();
141
+ }, 40), l = new AbortController(), d = (u) => {
142
+ l.abort(), this.grid.isResizeMode = !1, o();
143
+ };
144
+ window.addEventListener("mousemove", c, l), window.addEventListener("mouseup", d, l);
145
+ };
146
+ pinColumn = (e) => {
147
+ this.isLeaf ? this._pin = e : this.columns.forEach((t) => t.pinColumn(e)), this.grid.pinColumn(this.uniqueKey, e);
148
+ };
149
+ toggleGrouping = () => {
150
+ this.grid.toggleGrouping(this.key);
151
+ };
152
+ sortColumn = (...e) => {
153
+ this.grid.setSortColumn(this.key, ...e);
154
+ };
155
+ setWidth = (e) => {
156
+ if (!this.isLeaf)
157
+ throw new Error("Cannot set width for a parent column.");
158
+ this._inlineWidth !== e && (this._inlineWidth = e, this.grid.setWidth(this.key, e));
159
+ };
160
+ toggleVisibility = () => {
161
+ this.grid.toggleColumnVisibility(this.key);
162
+ };
155
163
  }
156
- class ke {
164
+ class Le {
157
165
  constructor(e, t, i) {
158
166
  this.grid = e, this.row = t, this.column = i;
159
167
  }
160
168
  get value() {
161
- return this.column.key === b ? this.row.rowIndex + 1 : this.column.key === f ? `> ${this.row.groupValue} (${this.row.count})` : null;
169
+ return this.column.key === v ? this.row.rowIndex + 1 : this.column.key === f ? `${this.row.groupValue} (${this.row.count})` : null;
162
170
  }
163
171
  }
164
- class Q {
165
- constructor(e, t, i, o, s) {
166
- a(this, "parentRow");
167
- this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = o, this.groupValue = s, i.forEach((n) => n.parentRow = this);
172
+ class oe {
173
+ constructor(e, t, i, o, n) {
174
+ this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = o, this.groupValue = n, i.forEach((r) => r.parentRow = this);
168
175
  }
169
- get rowKey() {
170
- var e;
171
- return `${((e = this.parentRow) == null ? void 0 : e.rowKey) ?? ""}${this.groupColumn.key}${this.groupValue}`;
176
+ get key() {
177
+ return `${this.parentRow?.key ?? ""}${this.groupColumn.key}${this.groupValue}`;
172
178
  }
179
+ parentRow;
173
180
  get cells() {
174
- return this.grid.columns.value.visibleLeafs.map((e) => new ke(this.grid, this, e));
181
+ return this.grid.columns.value.visibleLeafs.map((e) => new Le(this.grid, this, e));
175
182
  }
176
183
  get expanded() {
177
- return this.grid.expandedGroupRow[this.rowKey];
184
+ return this.grid.expandedGroupRow.has(this.key);
178
185
  }
179
186
  get depth() {
180
187
  return this.parentRow ? this.parentRow.depth + 1 : 0;
@@ -185,235 +192,367 @@ class Q {
185
192
  get flatRows() {
186
193
  return this.expanded ? [this, ...this.rows.flatMap((e) => e.flatRows)] : [this];
187
194
  }
195
+ get allRows() {
196
+ return this.rows.flatMap((e) => e.allRows);
197
+ }
188
198
  get groupingColumn() {
189
199
  return this.grid.columns.value.leafs.findOrThrow((e) => e.key === f);
190
200
  }
191
201
  get groupingColumnGridColumn() {
192
202
  const { visibleLeafs: e } = this.grid.columns.value, { groupingColumn: t } = this;
193
203
  return e.sumBy(
194
- (o) => o.pin === t.pin && o.key !== P && o.key !== T && o.key !== b ? 1 : 0
204
+ (o) => o.pin === t.pin && o.key !== T && o.key !== _ && o.key !== v ? 1 : 0
195
205
  );
196
206
  }
197
207
  toggleRow() {
198
- this.grid.toggleGroupRow(this.rowKey);
208
+ this.grid.toggleGroupRow(this.key);
199
209
  }
200
210
  }
201
- class xe {
211
+ class De {
202
212
  constructor(e, t, i) {
203
213
  this.grid = e, this.row = t, this.column = i;
204
214
  }
205
215
  get value() {
206
- return this.column.key === P ? null : this.column.key === b ? this.row.rowIndex + 1 : this.row.row[this.column.key];
216
+ return this.column.key === T ? null : this.column.key === v ? this.row.rowIndex + 1 : this.row.data[this.column.key];
207
217
  }
208
218
  }
209
- class X {
219
+ class K {
210
220
  constructor(e, t, i) {
211
- a(this, "parentRow");
212
- this.grid = e, this.row = t, this.rowIndex = i, this.grid = e, this.row = t;
213
- }
214
- get rowKey() {
215
- return this.getRowKey();
221
+ this.grid = e, this.data = t, this.rowIndex = i, this.grid = e, this.data = t, this.key = this.grid.getRowKey(t);
216
222
  }
223
+ key;
224
+ parentRow;
225
+ count = 1;
217
226
  get cells() {
218
- return this.grid.columns.value.visibleLeafs.map((e) => new xe(this.grid, this, e));
227
+ return this.grid.columns.value.visibleLeafs.map((e) => new De(this.grid, this, e));
219
228
  }
220
- get count() {
221
- return 1;
229
+ get selected() {
230
+ return this.grid.selectedRows.has(this.key);
222
231
  }
223
232
  get flatRows() {
224
- return [this];
233
+ return this;
225
234
  }
226
- getRowKey() {
227
- var i;
228
- const { rowKey: e } = this.grid.props.def, t = e ? typeof e == "function" ? e(this.row) : this.row[e] : this.rowIndex;
229
- return `${((i = this.parentRow) == null ? void 0 : i.rowKey) ?? ""}${t}`;
235
+ get allRows() {
236
+ return this;
230
237
  }
231
238
  }
232
- const P = "empty-cell", b = "row-number-cell", T = "row-selection-cell", f = "grouping-cell";
233
- class Le {
239
+ const Te = "NO_PIN", T = "empty-cell", v = "row-number-cell", _ = "row-selection-cell", f = "grouping-cell";
240
+ class Be {
234
241
  constructor(e, t) {
235
- a(this, "_sourceColumns", []);
236
- a(this, "columns", D(() => {
237
- const e = this._sourceColumns.map((l) => l.getPinnedColumn("LEFT")).filter((l) => !!l), t = this._sourceColumns.map((l) => l.getPinnedColumn()).filter((l) => !!l), i = this._sourceColumns.map((l) => l.getPinnedColumn("RIGHT")).filter((l) => !!l), o = [...e, ...t, ...i].flatMap((l) => l.flatColumns), s = o.filter((l) => l.isLeaf), n = o.filter((l) => l.isLeaf && l.isVisible), h = o.maxBy((l) => l.death) + 1;
238
- return {
239
- left: e,
240
- middle: t,
241
- right: i,
242
- flat: o,
243
- leafs: s,
244
- visibleLeafs: n,
245
- maxDeath: h
246
- };
247
- }));
248
- a(this, "headerRows", D(() => this.columns.value.flat.groupBy((t) => t.death).sortBy((t) => t.key).map((t) => {
249
- var o, s, n;
250
- const i = t.values.groupBy((h) => h.pin ?? be).toRecord((h) => [h.key, h.values]);
251
- return [
252
- ...((o = i.LEFT) == null ? void 0 : o.filter((h) => h.isVisible)) ?? [],
253
- ...((s = i.NO_PIN) == null ? void 0 : s.filter((h) => h.isVisible)) ?? [],
254
- ...((n = i.RIGHT) == null ? void 0 : n.filter((h) => h.isVisible)) ?? []
255
- ];
256
- })));
257
- a(this, "gridTemplateColumns", D(() => {
258
- const { visibleLeafs: e } = this.columns.value, t = e.sumBy((n) => n.pin === "RIGHT" ? 1 : 0), i = e.length - t - 1, o = i > 0 ? `repeat(${i}, max-content)` : "", s = t > 0 ? `repeat(${t}, max-content)` : "";
259
- return `${o} auto ${s}`;
260
- }));
261
- a(this, "rows", D(() => {
262
- let e = this.props.data;
263
- if (this._sortColumn && (e = e.sortBy((t) => t[this._sortColumn], this._sortDirection)), this.groupColumns.length > 0) {
264
- const t = (i, o, s) => {
265
- const n = o[0];
266
- o = o.removeBy((l) => l === n);
267
- const h = this.columns.value.leafs.findOrThrow((l) => l.key === n);
268
- return this._sortColumn === f && (i = i.sortBy((l) => l[n], this._sortDirection)), i.groupBy((l) => l[n]).map((l) => {
269
- let m;
270
- o.length > 0 ? m = t(l.values, o, s + 1) : m = l.values.map((w, y) => new X(this, w, s + 1 + y));
271
- const d = new Q(this, h, m, s, l.key);
272
- return s += 1, d.expanded && (s += m.length), d;
273
- });
274
- };
275
- return t(e, this.groupColumns, 0);
276
- }
277
- return e.map((t, i) => new X(this, t, i));
278
- }));
279
- a(this, "flatRows", D(() => this.rows.value.flatMap((e) => e.flatRows)));
280
- a(this, "sizes", D(() => {
281
- console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid sizes memo");
282
- const e = this.columns.value.flat.reduce((o, s) => {
283
- const { inlineWidth: n } = s;
284
- return typeof n == "number" && (o[s.widthVarName] = `${s.inlineWidth}px`), s.pin === "LEFT" && (o[s.leftVarName] = `${s.left}px`), s.pin === "RIGHT" && (o[s.rightVarName] = `${s.right}px`), o;
285
- }, {});
286
- e[this.leftEdgeVarName] = `${this.leftEdge}px`;
287
- const { visibleLeafs: t } = this.columns.value, i = t.find((o) => o.key === f);
288
- if (i) {
289
- const o = t.sumBy((s) => s.pin === i.pin && s.key !== b && s.key !== T ? s.inlineWidth ?? 0 : 0);
290
- e[i.groupColumnWidthVarName] = `${o}px`;
291
- }
292
- return this.groupColumns.forEach((o) => {
293
- const s = this.columns.value.leafs.findOrThrow((n) => n.key === o);
294
- e[s.groupColumnWidthVarName] = `${t.sumBy((n) => n.pin === s.pin ? n.inlineWidth ?? 0 : 0)}px`;
295
- }), e;
296
- }));
297
- a(this, "ROW_HEIGHT", 12);
298
- a(this, "MIN_COLUMN_WIDTH_PX", 48);
299
- a(this, "DEFAULT_COLUMN_WIDTH_PX", 200);
300
- a(this, "isResizeMode", !1);
301
- a(this, "expandedGroupRow", {});
302
- a(this, "leftEdgeVarName", "--left-edge");
303
- a(this, "setSortColumn", (e, ...t) => {
304
- if (t.length > 0)
305
- [this._sortDirection] = t, this._sortColumn = this._sortDirection ? e : void 0;
306
- else {
307
- const { _sortColumn: i, _sortDirection: o } = this;
308
- this._sortColumn = i === e && o === "DESC" ? void 0 : e, this._sortDirection = i === e && o === "ASC" ? "DESC" : "ASC";
309
- }
310
- this.headerRows.clear(), this.rows.clear(), this.flatRows.clear(), this.update();
311
- });
312
- a(this, "pinColumn", (e, t) => {
313
- const i = this.columns.value.flat.findOrThrow((o) => o.uniqueKey === e);
314
- i.pin !== t && i.pinColumn(t), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
315
- });
316
- a(this, "toggleGrouping", (e) => {
317
- this.groupColumns.includes(e) ? (this.groupColumns = this.groupColumns.removeBy((i) => i === e), this.hiddenColumns = this.hiddenColumns.removeBy((i) => i === e)) : (this.groupColumns = this.groupColumns.add(e), this.hiddenColumns = this.hiddenColumns.add(e));
318
- const t = this._sourceColumns.find((i) => i.key === f);
319
- if (this.groupColumns.length > 0 && !t) {
320
- const i = this._sourceColumns.sumBy((o) => o.key === b || o.key === T ? 1 : 0);
321
- this._sourceColumns.splice(i, 0, new G({ key: f }, this));
322
- } else this.groupColumns.length === 0 && t && (this._sourceColumns = this._sourceColumns.removeBy((i) => i.key === f));
323
- this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
324
- });
325
- a(this, "unGroupAll", () => {
326
- this.groupColumns = [], this._sourceColumns = this._sourceColumns.removeBy((e) => e.key === f), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
327
- });
328
- a(this, "toggleGroupRow", (e) => {
329
- e in this.expandedGroupRow ? delete this.expandedGroupRow[e] : this.expandedGroupRow[e] = !0, this.rows.clear(), this.flatRows.clear(), this.update();
330
- });
331
- a(this, "toggleColumnVisibility", (e) => {
332
- this.hiddenColumns.includes(e) ? this.hiddenColumns = this.hiddenColumns.removeBy((t) => t === e) : this.hiddenColumns = this.hiddenColumns.add(e), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
333
- });
334
- a(this, "setWidth", (e, t) => {
335
- const i = this.columns.value.leafs.find((s) => s.key === e);
336
- if (!i)
337
- throw new Error("Leaf column not found.");
338
- i.setWidth(t), this._sourceColumns.flatMap((s) => s.flatColumns).findOrThrow((s) => s.key === e).setWidth(t);
339
- });
340
- a(this, "groupColumns", []);
341
- a(this, "hiddenColumns", []);
342
- a(this, "_sortColumn");
343
- a(this, "_sortDirection", "ASC");
344
- this.props = e, this.update = t, this._sourceColumns = e.def.columns.map((i) => new G(i, this)), this._sourceColumns.push(new G({ key: P }, this)), this._sourceColumns.unshift(new G({ key: T, width: 50, align: "center" }, this)), this._sourceColumns.unshift(new G({ key: b, pin: "LEFT", width: 70, align: "right" }, this));
242
+ if (this.props = e, this.update = t, console.debug("\x1B[32m%s\x1B[0m", "[react-box]: DataGrid GridModel ctor"), this._sourceColumns = e.def.columns.map((i) => new D(i, this)), this._sourceColumns.push(new D({ key: T }, this)), e.def.rowSelection) {
243
+ const i = typeof e.def.rowSelection == "object" && e.def.rowSelection.pinned ? "LEFT" : void 0;
244
+ this._sourceColumns.unshift(new D({ key: _, pin: i, width: 50, align: "center" }, this));
245
+ }
246
+ if (e.def.showRowNumber) {
247
+ const i = typeof e.def.showRowNumber == "object" && e.def.showRowNumber.pinned ? "LEFT" : void 0;
248
+ this._sourceColumns.unshift(new D({ key: v, pin: i, width: 70, align: "right" }, this));
249
+ }
345
250
  }
251
+ _sourceColumns = [];
252
+ columns = M(() => {
253
+ console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid columns memo");
254
+ const e = this._sourceColumns.map((l) => l.getPinnedColumn("LEFT")).filter((l) => !!l), t = this._sourceColumns.map((l) => l.getPinnedColumn()).filter((l) => !!l), i = this._sourceColumns.map((l) => l.getPinnedColumn("RIGHT")).filter((l) => !!l), o = [...e, ...t, ...i].flatMap((l) => l.flatColumns), n = o.filter((l) => l.isLeaf), r = o.filter((l) => l.isLeaf && l.isVisible), c = o.maxBy((l) => l.death) + 1;
255
+ return {
256
+ left: e,
257
+ middle: t,
258
+ right: i,
259
+ flat: o,
260
+ leafs: n,
261
+ visibleLeafs: r,
262
+ maxDeath: c
263
+ };
264
+ });
265
+ headerRows = M(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid headerRows memo"), this.columns.value.flat.groupBy((t) => t.death).sortBy((t) => t.key).map((t) => {
266
+ const i = t.values.groupBy((o) => o.pin ?? Te).toRecord((o) => [o.key, o.values]);
267
+ return [
268
+ ...i.LEFT?.filter((o) => o.isVisible) ?? [],
269
+ ...i.NO_PIN?.filter((o) => o.isVisible) ?? [],
270
+ ...i.RIGHT?.filter((o) => o.isVisible) ?? []
271
+ ];
272
+ })));
273
+ gridTemplateColumns = M(() => {
274
+ console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid gridTemplateColumns memo");
275
+ const { visibleLeafs: e } = this.columns.value, t = e.sumBy((r) => r.pin === "RIGHT" ? 1 : 0), i = e.length - t - 1, o = i > 0 ? `repeat(${i}, max-content)` : "", n = t > 0 ? `repeat(${t}, max-content)` : "";
276
+ return `${o} auto ${n}`;
277
+ });
278
+ rows = M(() => {
279
+ console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid rows memo");
280
+ let e = this.props.data;
281
+ if (this._sortColumn && (e = e.sortBy((t) => t[this._sortColumn], this._sortDirection)), this.groupColumns.size > 0) {
282
+ const t = (i, o, n) => {
283
+ const r = o.values().next().value;
284
+ o.delete(r);
285
+ const c = this.columns.value.leafs.findOrThrow((l) => l.key === r);
286
+ return this._sortColumn === f && (i = i.sortBy((l) => l[r], this._sortDirection)), i.groupBy((l) => l[r]).map((l) => {
287
+ let d;
288
+ o.size > 0 ? d = t(l.values, new Set(o), n + 1) : d = l.values.map((p, C) => new K(this, p, n + 1 + C));
289
+ const u = new oe(this, c, d, n, l.key);
290
+ return n += 1, u.expanded && (n += d.length), u;
291
+ });
292
+ };
293
+ return t(e, new Set(this.groupColumns), 0);
294
+ }
295
+ return e.map((t, i) => new K(this, t, i));
296
+ });
297
+ flatRows = M(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid flatRows memo"), this.rows.value.flatMap((e) => e.flatRows)));
298
+ get rowHeight() {
299
+ return this.props.def.rowHeight ?? this.DEFAULT_ROW_HEIGHT_PX;
300
+ }
301
+ sizes = M(() => {
302
+ console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid sizes memo");
303
+ const e = this.columns.value.flat.reduce((o, n) => {
304
+ const { inlineWidth: r } = n;
305
+ return typeof r == "number" && (o[n.widthVarName] = `${n.inlineWidth}px`), n.pin === "LEFT" && (o[n.leftVarName] = `${n.left}px`), n.pin === "RIGHT" && (o[n.rightVarName] = `${n.right}px`), o;
306
+ }, {});
307
+ e[this.rowHeightVarName] = `${this.rowHeight}px`, e[this.leftEdgeVarName] = `${this.leftEdge}px`;
308
+ const { visibleLeafs: t } = this.columns.value, i = t.find((o) => o.key === f);
309
+ if (i) {
310
+ const o = t.sumBy((n) => n.pin === i.pin && n.key !== v && n.key !== _ ? n.inlineWidth ?? 0 : 0);
311
+ e[i.groupColumnWidthVarName] = `${o}px`;
312
+ }
313
+ return this.groupColumns.forEach((o) => {
314
+ const n = this.columns.value.leafs.findOrThrow((r) => r.key === o);
315
+ e[n.groupColumnWidthVarName] = `${t.sumBy((r) => r.pin === n.pin ? r.inlineWidth ?? 0 : 0)}px`;
316
+ }), e;
317
+ });
318
+ DEFAULT_ROW_HEIGHT_PX = 48;
319
+ MIN_COLUMN_WIDTH_PX = 48;
320
+ DEFAULT_COLUMN_WIDTH_PX = 200;
321
+ isResizeMode = !1;
322
+ expandedGroupRow = /* @__PURE__ */ new Set();
323
+ selectedRows = /* @__PURE__ */ new Set();
346
324
  get leftEdge() {
347
325
  return this.columns.value.left.sumBy((e) => e.inlineWidth ?? 0);
348
326
  }
349
327
  get rightEdge() {
350
328
  return this.columns.value.right.sumBy((e) => e.inlineWidth ?? 0);
351
329
  }
330
+ leftEdgeVarName = "--left-edge";
331
+ rowHeightVarName = "--row-height";
332
+ _idMap = /* @__PURE__ */ new WeakMap();
333
+ getRowKey(e) {
334
+ const { rowKey: t } = this.props.def;
335
+ return t ? typeof t == "function" ? t(e) : e[t] : (this._idMap.has(e) || this._idMap.set(e, crypto.randomUUID()), this._idMap.get(e));
336
+ }
337
+ setSortColumn = (e, ...t) => {
338
+ if (t.length > 0)
339
+ [this._sortDirection] = t, this._sortColumn = this._sortDirection ? e : void 0;
340
+ else {
341
+ const { _sortColumn: i, _sortDirection: o } = this;
342
+ this._sortColumn = i === e && o === "DESC" ? void 0 : e, this._sortDirection = i === e && o === "ASC" ? "DESC" : "ASC";
343
+ }
344
+ this.headerRows.clear(), this.rows.clear(), this.flatRows.clear(), this.update();
345
+ };
346
+ pinColumn = (e, t) => {
347
+ const i = this.columns.value.flat.findOrThrow((o) => o.uniqueKey === e);
348
+ i.pin !== t && i.pinColumn(t), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
349
+ };
350
+ toggleGrouping = (e) => {
351
+ this.groupColumns = new Set(this.groupColumns), this.hiddenColumns = new Set(this.hiddenColumns), this.groupColumns.has(e) ? (this.groupColumns.delete(e), this.hiddenColumns.delete(e)) : (this.groupColumns.add(e), this.hiddenColumns.add(e));
352
+ const t = this._sourceColumns.find((i) => i.key === f);
353
+ if (this.groupColumns.size > 0 && !t) {
354
+ const i = this._sourceColumns.sumBy((o) => o.key === v || o.key === _ ? 1 : 0);
355
+ this._sourceColumns.splice(i, 0, new D({ key: f }, this));
356
+ } else this.groupColumns.size === 0 && t && (this._sourceColumns = this._sourceColumns.removeBy((i) => i.key === f));
357
+ this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
358
+ };
359
+ unGroupAll = () => {
360
+ this.groupColumns = /* @__PURE__ */ new Set(), this._sourceColumns = this._sourceColumns.removeBy((e) => e.key === f), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
361
+ };
362
+ toggleGroupRow = (e) => {
363
+ this.expandedGroupRow = new Set(this.expandedGroupRow), this.expandedGroupRow.has(e) ? this.expandedGroupRow.delete(e) : this.expandedGroupRow.add(e), this.rows.clear(), this.flatRows.clear(), this.update();
364
+ };
365
+ toggleRowSelection = (e) => {
366
+ this.toggleRowsSelection([e]);
367
+ };
368
+ toggleRowsSelection = (e) => {
369
+ this.selectedRows = new Set(this.selectedRows);
370
+ const t = e.every((i) => this.selectedRows.has(i));
371
+ t ? e.forEach((i) => this.selectedRows.delete(i)) : e.forEach((i) => this.selectedRows.add(i)), this.flatRows.clear(), this.update(), this.props.onSelectionChange?.({
372
+ action: t ? "deselect" : "select",
373
+ affectedRowKeys: e,
374
+ selectedRowKeys: Array.from(this.selectedRows),
375
+ isAllSelected: this.selectedRows.size === this.props.data.length
376
+ });
377
+ };
378
+ toggleSelectAllRows = () => {
379
+ this.toggleRowsSelection(this.props.data.map((e) => this.getRowKey(e)));
380
+ };
381
+ toggleColumnVisibility = (e) => {
382
+ this.hiddenColumns = new Set(this.hiddenColumns), this.hiddenColumns.has(e) ? this.hiddenColumns.delete(e) : this.hiddenColumns.add(e), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
383
+ };
384
+ setWidth = (e, t) => {
385
+ const i = this.columns.value.leafs.find((n) => n.key === e);
386
+ if (!i)
387
+ throw new Error("Leaf column not found.");
388
+ i.setWidth(t), this._sourceColumns.flatMap((n) => n.flatColumns).findOrThrow((n) => n.key === e).setWidth(t);
389
+ };
390
+ groupColumns = /* @__PURE__ */ new Set();
391
+ hiddenColumns = /* @__PURE__ */ new Set();
392
+ _sortColumn;
352
393
  get sortColumn() {
353
394
  return this._sortColumn;
354
395
  }
396
+ _sortDirection = "ASC";
355
397
  get sortDirection() {
356
398
  return this._sortDirection;
357
399
  }
358
400
  }
359
- function _e(u) {
360
- const e = E(() => new Le(u, () => i((s) => s + 1)), [u]), [t, i] = z(0);
361
- return E(() => Object.create(Object.getPrototypeOf(e), Object.getOwnPropertyDescriptors(e)), [e, t]);
401
+ function W(a) {
402
+ const { children: e, column: t, style: i, ...o } = a, { key: n, pin: r, left: c, right: l, isEdge: d, align: u, widthVarName: p, leftVarName: C, rightVarName: x } = t, k = n === T, y = n === v, G = n === _, b = r === "LEFT", R = r === "RIGHT", B = b || R, S = b && c === 0, E = b && d, H = R && d, z = R && l === 0, A = !G && !k;
403
+ return /* @__PURE__ */ h(
404
+ w,
405
+ {
406
+ component: "datagrid.cell",
407
+ props: { role: "cell" },
408
+ variant: { isPinned: B, isFirstLeftPinned: S, isLastLeftPinned: E, isFirstRightPinned: H, isLastRightPinned: z, isRowNumber: y, isRowSelection: G },
409
+ jc: u,
410
+ style: {
411
+ width: `var(${p})`,
412
+ height: `var(${t.grid.rowHeightVarName})`,
413
+ left: b ? `var(${C})` : void 0,
414
+ right: R ? `var(${x})` : void 0,
415
+ ...i
416
+ },
417
+ ...o,
418
+ children: [
419
+ A && /* @__PURE__ */ s(m, { px: 4, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: e }),
420
+ G && e
421
+ ]
422
+ }
423
+ );
362
424
  }
363
- function Te(u) {
364
- const { column: e } = u, { key: t, pin: i, left: o, right: s, isEdge: n, isLeaf: h, leafs: l, grid: m, header: d, gridRows: w, widthVarName: y, leftVarName: k, rightVarName: x, inlineWidth: v } = e, L = t === P, _ = t === f, R = t === b, W = t === T, I = i === "LEFT", B = i === "RIGHT", S = I || i === "RIGHT", M = I && o === 0, O = I && n, ie = B && n, se = B && s === 0, A = h && !L && !R && !W, oe = h ? 1 : l.length, re = !R && !W, F = !R && !W, ne = E(() => {
365
- if (R) return null;
366
- if (W) return /* @__PURE__ */ r(V, { m: 1 });
367
- if (_) {
368
- if (m.groupColumns.length === 1) {
369
- const U = m.columns.value.leafs.findOrThrow((le) => le.key === m.groupColumns[0]);
370
- return U.header ?? U.key;
371
- }
372
- return "Group";
425
+ W.displayName = "DataGridCell";
426
+ function ne(a) {
427
+ const { row: e } = a, t = P(() => {
428
+ e.grid.toggleRowsSelection(e.allRows.map((i) => i.key));
429
+ }, []);
430
+ return /* @__PURE__ */ s(w, { className: "grid-row", display: "contents", props: { role: "rowgroup" }, children: e.cells.map((i) => {
431
+ const { key: o, pin: n, groupColumnWidthVarName: r } = i.column, c = n === "RIGHT";
432
+ if (o === f)
433
+ return /* @__PURE__ */ s(
434
+ W,
435
+ {
436
+ column: i.column,
437
+ style: {
438
+ width: `var(${r})`,
439
+ right: c ? "0" : void 0
440
+ },
441
+ br: e.groupingColumn.pin === "LEFT" ? 1 : void 0,
442
+ gridColumn: e.groupingColumnGridColumn,
443
+ pl: 4 * e.depth,
444
+ children: /* @__PURE__ */ h(g, { clean: !0, onClick: () => e.toggleRow(), cursor: "pointer", display: "flex", gap: 1, ai: "center", children: [
445
+ /* @__PURE__ */ s(Z, { fill: "currentColor", width: "14px", height: "14px", rotate: e.expanded ? 0 : -90 }),
446
+ i.value
447
+ ] })
448
+ },
449
+ o
450
+ );
451
+ if (o === _) {
452
+ const l = e.allRows, d = l.every((p) => p.selected), u = !d && l.some((p) => p.selected);
453
+ return /* @__PURE__ */ s(W, { column: i.column, children: /* @__PURE__ */ s(V, { variant: "datagrid", m: 1, checked: d, indeterminate: u, onChange: t }) }, o);
373
454
  }
374
- return d ?? t;
375
- }, [m.groupColumns]);
376
- return /* @__PURE__ */ r(
377
- C,
455
+ if (n !== e.groupingColumn.pin || o === T || o === v)
456
+ return /* @__PURE__ */ s(W, { column: i.column, children: i.value }, o);
457
+ }) });
458
+ }
459
+ ne.displayName = "DataGridGroupRow";
460
+ function se(a) {
461
+ const { row: e } = a, t = P((i) => {
462
+ e.grid.toggleRowSelection(e.key);
463
+ }, []);
464
+ return /* @__PURE__ */ s(w, { className: "grid-row", display: "contents", props: { role: "row" }, children: e.cells.map((i) => /* @__PURE__ */ s(W, { column: i.column, children: i.column.key === _ ? /* @__PURE__ */ s(V, { variant: "datagrid", checked: e.selected, onChange: t }) : i.value }, i.column.key)) });
465
+ }
466
+ se.displayName = "DataGridRow";
467
+ const Se = 10, J = 20;
468
+ function re(a) {
469
+ const { grid: e, scrollTop: t } = a, i = e.flatRows.value.length, o = Math.max(0, Math.floor(t / e.rowHeight) - J), n = e.props.def.visibleRowsCount ?? Se, r = I(() => {
470
+ console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render rows");
471
+ const c = n + J * 2;
472
+ return e.flatRows.value.take(c, o).map((d) => d instanceof oe ? /* @__PURE__ */ s(ne, { row: d }, d.key) : /* @__PURE__ */ s(se, { row: d }, d.key));
473
+ }, [e.flatRows.value, o]);
474
+ return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render DataGridBody"), /* @__PURE__ */ s(m, { style: { height: e.rowHeight * n + e.rowHeight / 5 }, children: /* @__PURE__ */ s(
475
+ m,
378
476
  {
379
- component: "datagrid.header.cell",
380
- variant: { isRowNumber: R, isPinned: S, isFirstLeftPinned: M, isLastLeftPinned: O, isFirstRightPinned: ie, isLastRightPinned: se, isSortable: A },
381
- gridRow: w,
382
- gridColumn: oe,
383
477
  style: {
384
- width: `var(${y})`,
385
- left: I ? `var(${k})` : void 0,
386
- right: B ? `var(${x})` : void 0
478
+ height: `${i * e.rowHeight}px`
387
479
  },
388
- children: !L && /* @__PURE__ */ c(he, { children: [
389
- /* @__PURE__ */ r(C, { width: "fit", height: "fit", jc: e.align, props: { onClick: A ? () => e.sortColumn() : void 0 }, children: /* @__PURE__ */ c(
390
- C,
391
- {
392
- overflow: "hidden",
393
- position: h ? void 0 : "sticky",
394
- ai: "center",
395
- transition: "none",
396
- pl: e.align ? void 0 : 4,
397
- style: {
398
- left: i ? void 0 : `var(${m.leftEdgeVarName})`
399
- },
400
- children: [
401
- /* @__PURE__ */ r(g, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: ne }),
402
- t === m.sortColumn && /* @__PURE__ */ r(g, { pl: (v ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ r($, { width: "16px", rotate: m.sortDirection === "ASC" ? 0 : 180, fill: "violet-950" }) }),
403
- F && /* @__PURE__ */ r(g, { minWidth: 10 })
404
- ]
405
- }
406
- ) }),
407
- re && /* @__PURE__ */ r(Ge, { column: e }),
408
- F && /* @__PURE__ */ r(Ee, { column: e })
409
- ] })
480
+ children: /* @__PURE__ */ s(
481
+ te,
482
+ {
483
+ width: "max-content",
484
+ minWidth: "fit",
485
+ transition: "none",
486
+ style: {
487
+ transform: `translateY(${o * e.rowHeight}px)`,
488
+ gridTemplateColumns: e.gridTemplateColumns.value
489
+ },
490
+ children: r
491
+ }
492
+ )
410
493
  }
411
- );
494
+ ) });
412
495
  }
413
- function Ge(u) {
414
- const { column: e } = u;
415
- return /* @__PURE__ */ r(
416
- C,
496
+ re.displayName = "DataGridBody";
497
+ function le(a) {
498
+ const { column: e } = a, [t, i, o] = ee({ hideOnScroll: !0, event: "mousedown" }), [n, r] = U({ top: 0, left: 0 }), c = I(() => n.left > window.innerWidth / 2, [n.left]), l = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "DESC"), d = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "ASC"), u = e.isLeaf && e.grid.sortColumn === e.key, p = e.pin !== "LEFT", C = e.pin !== "RIGHT", x = !!e.pin, k = e.isLeaf && e.key !== f, y = e.isLeaf && e.key === f, G = l || d || u, b = p || C || x;
499
+ return /* @__PURE__ */ s(w, { position: "absolute", right: e.pin === "RIGHT" ? 2.5 : 4, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu", onClick: () => i(!t), children: [
500
+ /* @__PURE__ */ s(L, { component: "datagrid.header.cell.contextMenu.icon", children: /* @__PURE__ */ s(ke, { fill: "currentColor" }) }),
501
+ t && /* @__PURE__ */ h(
502
+ ie,
503
+ {
504
+ component: "datagrid.header.cell.contextMenu.tooltip",
505
+ variant: { openLeft: c },
506
+ onPositionChange: r,
507
+ ref: o,
508
+ children: [
509
+ l && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("ASC"), children: [
510
+ /* @__PURE__ */ s(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(O, { width: "100%", fill: "currentColor" }) }),
511
+ "Sort Ascending"
512
+ ] }),
513
+ d && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("DESC"), children: [
514
+ /* @__PURE__ */ s(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(O, { width: "100%", fill: "currentColor", rotate: 180 }) }),
515
+ "Sort Descending"
516
+ ] }),
517
+ u && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
518
+ /* @__PURE__ */ s(m, { width: 4 }),
519
+ "Clear Sort"
520
+ ] }),
521
+ G && (b || k || y) && /* @__PURE__ */ s(m, { bb: 1, my: 2, borderColor: "gray-300" }),
522
+ p && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("LEFT"), children: [
523
+ /* @__PURE__ */ s(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(j, { width: "100%", fill: "currentColor" }) }),
524
+ "Pin Left"
525
+ ] }),
526
+ C && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("RIGHT"), children: [
527
+ /* @__PURE__ */ s(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(j, { width: "100%", fill: "currentColor", rotate: -90 }) }),
528
+ "Pin Right"
529
+ ] }),
530
+ x && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
531
+ /* @__PURE__ */ s(m, { width: 4 }),
532
+ "Unpin"
533
+ ] }),
534
+ G && b && (k || y) && /* @__PURE__ */ s(m, { bb: 1, my: 2, borderColor: "gray-300" }),
535
+ k && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: e.toggleGrouping, children: [
536
+ /* @__PURE__ */ s(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(F, { width: "100%", fill: "currentColor" }) }),
537
+ /* @__PURE__ */ h(m, { textWrap: "nowrap", children: [
538
+ "Group by ",
539
+ e.header ?? e.key
540
+ ] })
541
+ ] }),
542
+ y && /* @__PURE__ */ h(g, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: e.grid.unGroupAll, children: [
543
+ /* @__PURE__ */ s(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(F, { width: "100%", fill: "currentColor" }) }),
544
+ /* @__PURE__ */ s(m, { textWrap: "nowrap", children: "Un-Group All" })
545
+ ] })
546
+ ]
547
+ }
548
+ )
549
+ ] }) });
550
+ }
551
+ le.displayName = "DataGridHeaderCellContextMenu";
552
+ function ae(a) {
553
+ const { column: e } = a;
554
+ return /* @__PURE__ */ s(
555
+ w,
417
556
  {
418
557
  height: "fit",
419
558
  ai: "center",
@@ -421,364 +560,160 @@ function Ge(u) {
421
560
  right: e.pin === "RIGHT" ? void 0 : 0,
422
561
  left: e.pin !== "RIGHT" ? void 0 : 0,
423
562
  py: 3,
424
- children: /* @__PURE__ */ r(
425
- g,
563
+ children: /* @__PURE__ */ s(
564
+ m,
426
565
  {
427
566
  cursor: "col-resize",
428
567
  px: 0.75,
429
568
  className: "resizer",
430
569
  height: "fit",
431
570
  props: { onMouseDown: e.resizeColumn, onTouchStart: e.resizeColumn },
432
- children: /* @__PURE__ */ r(g, { width: 0.5, height: "fit", bgColor: "gray-400", hoverGroup: { resizer: { bgColor: "gray-600" } } })
571
+ children: /* @__PURE__ */ s(m, { component: "datagrid.header.cell.resizer" })
433
572
  }
434
573
  )
435
574
  }
436
575
  );
437
576
  }
438
- function Ee(u) {
439
- const { column: e } = u, [t, i, o] = Y({ hideOnScroll: !0, event: "mousedown" }), [s, n] = z({ top: 0, left: 0 }), h = E(() => s.left > window.innerWidth / 2, [s.left]), l = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "DESC"), m = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "ASC"), d = e.isLeaf && e.grid.sortColumn === e.key, w = e.pin !== "LEFT", y = e.pin !== "RIGHT", k = !!e.pin, x = e.isLeaf && e.key !== f, v = e.isLeaf && e.key === f, L = l || m || d, _ = w || y || k;
440
- return /* @__PURE__ */ r(C, { position: "absolute", right: e.pin === "RIGHT" ? 2.5 : 4, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ c(
441
- p,
577
+ ae.displayName = "DataGridHeaderCellResizer";
578
+ function de(a) {
579
+ const { column: e } = a, { key: t, pin: i, left: o, right: n, isEdge: r, isLeaf: c, leafs: l, grid: d, header: u, gridRows: p, widthVarName: C, leftVarName: x, rightVarName: k, inlineWidth: y } = e, G = t === T, b = t === f, R = t === v, B = t === _, S = i === "LEFT", E = i === "RIGHT", H = S || i === "RIGHT", z = S && o === 0, A = S && r, ge = E && r, fe = E && n === 0, X = c && !G && !R && !B, we = c ? 1 : l.length, Ce = !R && !B, q = !R && !B, Y = P(() => {
580
+ d.toggleSelectAllRows();
581
+ }, []), ye = I(() => {
582
+ if (R) return null;
583
+ if (B) {
584
+ const N = d.selectedRows.size === d.props.data.length, $ = !N && d.selectedRows.size > 0;
585
+ return /* @__PURE__ */ s(V, { variant: "datagrid", m: 1, indeterminate: $, checked: N, onChange: Y });
586
+ }
587
+ if (b) {
588
+ if (d.groupColumns.size === 1) {
589
+ const N = d.columns.value.leafs.findOrThrow(($) => $.key === d.groupColumns.values().next().value);
590
+ return N.header ?? N.key;
591
+ }
592
+ return "Group";
593
+ }
594
+ return u ?? t;
595
+ }, [d.groupColumns, d.selectedRows, Y]);
596
+ return /* @__PURE__ */ s(
597
+ w,
442
598
  {
443
- clean: !0,
444
- onClick: () => i(!t),
445
- width: 6,
446
- height: 6,
447
- cursor: "pointer",
448
- userSelect: "none",
449
- borderRadius: 1,
450
- borderColor: "gray-200",
451
- display: "flex",
452
- jc: "center",
453
- ai: "center",
454
- transition: "none",
455
- bgColor: "gray-200",
456
- hover: { bgColor: "gray-300" },
457
- children: [
458
- /* @__PURE__ */ r(fe, { fill: "violet-950" }),
459
- t && /* @__PURE__ */ c(
460
- J,
599
+ component: "datagrid.header.cell",
600
+ variant: { isRowNumber: R, isPinned: H, isFirstLeftPinned: z, isLastLeftPinned: A, isFirstRightPinned: ge, isLastRightPinned: fe, isSortable: X },
601
+ gridRow: p,
602
+ gridColumn: we,
603
+ style: {
604
+ width: `var(${C})`,
605
+ left: S ? `var(${x})` : void 0,
606
+ right: E ? `var(${k})` : void 0
607
+ },
608
+ children: !G && /* @__PURE__ */ h(Re, { children: [
609
+ /* @__PURE__ */ s(w, { width: "fit", height: "fit", jc: e.align, props: { onClick: X ? () => e.sortColumn() : void 0 }, children: /* @__PURE__ */ h(
610
+ w,
461
611
  {
462
- bgColor: "white",
463
- width: 56,
464
- b: 1,
465
- borderColor: "gray-300",
466
- borderRadius: 1,
467
- display: "flex",
468
- d: "column",
469
- mt: 4,
470
- py: 2,
471
612
  overflow: "hidden",
472
- translateX: h ? -55 : -5,
473
- onPositionChange: n,
474
- ref: o,
475
- shadow: "medium-shadow",
613
+ position: c ? void 0 : "sticky",
614
+ ai: "center",
615
+ transition: "none",
616
+ pl: e.align ? void 0 : 4,
617
+ style: {
618
+ left: i ? void 0 : `var(${d.leftEdgeVarName})`
619
+ },
476
620
  children: [
477
- l && /* @__PURE__ */ c(
478
- p,
479
- {
480
- clean: !0,
481
- display: "flex",
482
- gap: 2,
483
- p: 3,
484
- cursor: "pointer",
485
- hover: { bgColor: "gray-200" },
486
- onClick: () => e.sortColumn("ASC"),
487
- children: [
488
- /* @__PURE__ */ r($, { width: "1rem", fill: "violet-950" }),
489
- "Sort Ascending"
490
- ]
491
- }
492
- ),
493
- m && /* @__PURE__ */ c(
494
- p,
495
- {
496
- clean: !0,
497
- display: "flex",
498
- gap: 2,
499
- p: 3,
500
- cursor: "pointer",
501
- hover: { bgColor: "gray-200" },
502
- onClick: () => e.sortColumn("DESC"),
503
- children: [
504
- /* @__PURE__ */ r($, { width: "1rem", fill: "violet-950", rotate: 180 }),
505
- "Sort Descending"
506
- ]
507
- }
508
- ),
509
- d && /* @__PURE__ */ c(
510
- p,
511
- {
512
- clean: !0,
513
- display: "flex",
514
- gap: 2,
515
- p: 3,
516
- cursor: "pointer",
517
- hover: { bgColor: "gray-200" },
518
- onClick: () => e.sortColumn(void 0),
519
- children: [
520
- /* @__PURE__ */ r(g, { width: 4 }),
521
- "Clear Sort"
522
- ]
523
- }
524
- ),
525
- L && (_ || x || v) && /* @__PURE__ */ r(g, { bb: 1, my: 2, borderColor: "gray-300" }),
526
- w && /* @__PURE__ */ c(
527
- p,
528
- {
529
- clean: !0,
530
- display: "flex",
531
- gap: 2,
532
- p: 3,
533
- cursor: "pointer",
534
- hover: { bgColor: "gray-200" },
535
- onClick: () => e.pinColumn("LEFT"),
536
- children: [
537
- /* @__PURE__ */ r(K, { width: "1rem", fill: "violet-950" }),
538
- "Pin Left"
539
- ]
540
- }
541
- ),
542
- y && /* @__PURE__ */ c(
543
- p,
544
- {
545
- clean: !0,
546
- display: "flex",
547
- gap: 2,
548
- p: 3,
549
- cursor: "pointer",
550
- hover: { bgColor: "gray-200" },
551
- onClick: () => e.pinColumn("RIGHT"),
552
- children: [
553
- /* @__PURE__ */ r(K, { width: "1rem", fill: "violet-950", rotate: -90 }),
554
- "Pin Right"
555
- ]
556
- }
557
- ),
558
- k && /* @__PURE__ */ c(
559
- p,
560
- {
561
- clean: !0,
562
- display: "flex",
563
- gap: 2,
564
- p: 3,
565
- cursor: "pointer",
566
- hover: { bgColor: "gray-200" },
567
- onClick: () => e.pinColumn(),
568
- children: [
569
- /* @__PURE__ */ r(g, { width: 4 }),
570
- "Unpin"
571
- ]
572
- }
573
- ),
574
- L && _ && (x || v) && /* @__PURE__ */ r(g, { bb: 1, my: 2, borderColor: "gray-300" }),
575
- x && /* @__PURE__ */ c(
576
- p,
577
- {
578
- clean: !0,
579
- display: "flex",
580
- ai: "center",
581
- gap: 2,
582
- p: 3,
583
- cursor: "pointer",
584
- hover: { bgColor: "gray-200" },
585
- onClick: e.toggleGrouping,
586
- children: [
587
- /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(H, { width: "1rem", fill: "violet-950" }) }),
588
- /* @__PURE__ */ c(g, { textWrap: "nowrap", children: [
589
- " Group by ",
590
- e.header ?? e.key
591
- ] })
592
- ]
593
- }
594
- ),
595
- v && /* @__PURE__ */ c(p, { clean: !0, display: "flex", gap: 2, p: 3, cursor: "pointer", hover: { bgColor: "gray-200" }, onClick: e.grid.unGroupAll, children: [
596
- /* @__PURE__ */ r(g, { children: /* @__PURE__ */ r(H, { width: "1rem", fill: "violet-950" }) }),
597
- /* @__PURE__ */ r(g, { textWrap: "nowrap", children: " Un-Group All" })
598
- ] })
621
+ /* @__PURE__ */ s(m, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: ye }),
622
+ t === d.sortColumn && /* @__PURE__ */ s(m, { pl: (y ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ s(O, { width: "16px", rotate: d.sortDirection === "ASC" ? 0 : 180, fill: "currentColor" }) }),
623
+ q && /* @__PURE__ */ s(m, { minWidth: 10 })
599
624
  ]
600
625
  }
601
- )
602
- ]
603
- }
604
- ) });
605
- }
606
- function N(u) {
607
- const { children: e, column: t, style: i, ...o } = u, { key: s, pin: n, left: h, right: l, isEdge: m, align: d, widthVarName: w, leftVarName: y, rightVarName: k } = t, x = s === P, v = s === b, L = s === T, _ = n === "LEFT", R = n === "RIGHT", W = _ || R, I = _ && h === 0, B = _ && m, S = R && m, M = R && l === 0, O = !L && !x;
608
- return /* @__PURE__ */ c(
609
- C,
610
- {
611
- component: "datagrid.cell",
612
- props: { role: "cell" },
613
- variant: { isPinned: W, isFirstLeftPinned: I, isLastLeftPinned: B, isFirstRightPinned: S, isLastRightPinned: M, isRowNumber: v, isRowSelection: L },
614
- jc: d,
615
- style: {
616
- width: `var(${w})`,
617
- left: _ ? `var(${y})` : void 0,
618
- right: R ? `var(${k})` : void 0,
619
- ...i
620
- },
621
- ...o,
622
- children: [
623
- O && /* @__PURE__ */ r(g, { px: 4, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: e }),
624
- L && e
625
- ]
626
+ ) }),
627
+ Ce && /* @__PURE__ */ s(ae, { column: e }),
628
+ q && /* @__PURE__ */ s(le, { column: e })
629
+ ] })
626
630
  }
627
631
  );
628
632
  }
629
- function Pe(u) {
630
- const { row: e } = u;
631
- return /* @__PURE__ */ r(C, { className: "grid-row", display: "contents", props: { role: "rowgroup" }, children: e.cells.map((t) => {
632
- const { key: i, pin: o, groupColumnWidthVarName: s } = t.column, n = o === "RIGHT";
633
- if (i === f)
634
- return /* @__PURE__ */ r(
635
- N,
636
- {
637
- column: t.column,
638
- style: {
639
- width: `var(${s})`,
640
- right: n ? "0" : void 0
641
- },
642
- br: e.groupingColumn.pin === "LEFT" ? 1 : void 0,
643
- gridColumn: e.groupingColumnGridColumn,
644
- pl: 4 * e.depth,
645
- children: /* @__PURE__ */ r(p, { display: "contents", clean: !0, onClick: () => e.toggleRow(), cursor: "pointer", children: t.value })
646
- },
647
- i
648
- );
649
- if (i === T)
650
- return /* @__PURE__ */ r(N, { column: t.column, children: /* @__PURE__ */ r(V, { m: 1 }) }, i);
651
- if (o !== e.groupingColumn.pin || i === P || i === b)
652
- return /* @__PURE__ */ r(N, { column: t.column, children: t.value }, i);
653
- }) });
633
+ de.displayName = "DataGridHeaderCell";
634
+ function he(a) {
635
+ const { grid: e } = a, { isResizeMode: t } = e;
636
+ return /* @__PURE__ */ s(te, { component: "datagrid.header", variant: { isResizeMode: t }, style: { gridTemplateColumns: e.gridTemplateColumns.value }, children: e.headerRows.value.map((i) => i.map((o) => /* @__PURE__ */ s(de, { column: o }, o.uniqueKey))) });
654
637
  }
655
- function We(u) {
656
- const { row: e } = u;
657
- return /* @__PURE__ */ r(C, { className: "grid-row", display: "contents", props: { role: "row" }, children: e.cells.map((t) => /* @__PURE__ */ r(N, { column: t.column, children: t.column.key === T ? /* @__PURE__ */ r(V, {}) : t.value }, t.column.key)) });
638
+ he.displayName = "DataGridHeader";
639
+ function ce(a) {
640
+ const { grid: e } = a, [t, i] = U(0), o = P(
641
+ Q.throttle((n) => {
642
+ i(n.target.scrollTop);
643
+ }, 100),
644
+ []
645
+ );
646
+ return /* @__PURE__ */ h(m, { overflowX: "scroll", props: { onScroll: o }, children: [
647
+ /* @__PURE__ */ s(he, { grid: e }),
648
+ /* @__PURE__ */ s(re, { grid: e, scrollTop: t })
649
+ ] });
658
650
  }
659
- function Ie(u) {
660
- const { grid: e } = u, t = E(() => e.groupColumns.length === 0 ? null : e.groupColumns.map((i, o) => {
661
- const s = e.columns.value.leafs.findOrThrow((n) => n.key === i);
662
- return /* @__PURE__ */ c(de.Fragment, { children: [
663
- ">",
664
- /* @__PURE__ */ c(C, { component: "datagrid.columnGroups.item", children: [
665
- s.header ?? s.key,
666
- /* @__PURE__ */ r(p, { component: "datagrid.columnGroups.item.icon", onClick: () => e.toggleGrouping(s.key), children: /* @__PURE__ */ r(Ce, { fill: "currentColor", width: "100%" }) })
667
- ] })
668
- ] }, i);
669
- }), [e.groupColumns]);
670
- return /* @__PURE__ */ c(C, { component: "datagrid.columnGroups", position: "relative", children: [
671
- /* @__PURE__ */ r(De, { grid: e }),
672
- t && /* @__PURE__ */ r(H, { width: "1rem", fill: "violet-950" }),
673
- t,
674
- /* @__PURE__ */ c(C, { position: "absolute", justifySelf: "flex-end", right: 2, top: 2, className: "parent", children: [
675
- /* @__PURE__ */ r(C, { position: "absolute", width: 8, height: 8, right: 0, jc: "center", children: /* @__PURE__ */ r(we, { fill: "violet-950", width: "1rem" }) }),
676
- /* @__PURE__ */ r(Re, { placeholder: "Search...", height: 8, width: 50, zIndex: 1, bgColor: "transparent" })
677
- ] })
651
+ ce.displayName = "DataGridContent";
652
+ function ue(a) {
653
+ const { grid: e } = a;
654
+ return e.groupColumns.size === 0 ? null : /* @__PURE__ */ h(w, { component: "datagrid.topBar.columnGroups", children: [
655
+ /* @__PURE__ */ s(L, { component: "datagrid.topBar.columnGroups.icon", children: /* @__PURE__ */ s(F, { width: "100%", fill: "currentColor" }) }),
656
+ Array.from(e.groupColumns, (t) => {
657
+ const i = e.columns.value.leafs.findOrThrow((o) => o.key === t);
658
+ return /* @__PURE__ */ h(ve.Fragment, { children: [
659
+ /* @__PURE__ */ s(Z, { fill: "currentColor", width: "14px", height: "14px", rotate: -90 }),
660
+ /* @__PURE__ */ h(w, { component: "datagrid.topBar.columnGroups.item", children: [
661
+ i.header ?? i.key,
662
+ /* @__PURE__ */ s(g, { component: "datagrid.topBar.columnGroups.item.icon", onClick: () => e.toggleGrouping(i.key), children: /* @__PURE__ */ s(Ge, { fill: "currentColor", width: "100%" }) })
663
+ ] })
664
+ ] }, t);
665
+ })
678
666
  ] });
679
667
  }
680
- function De(u) {
681
- const { grid: e } = u, [t, i, o] = Y({ event: "mousedown" }), s = E(
668
+ ue.displayName = "DataGridColumnGroups";
669
+ function me(a) {
670
+ const { grid: e } = a, [t, i, o] = ee({ event: "mousedown" }), n = I(
682
671
  () => e.columns.value.leafs.filter(
683
- (n) => ![P, b, T, f].includes(n.key)
672
+ (r) => ![T, v, _, f].includes(r.key)
684
673
  ),
685
674
  [e.columns.value.leafs]
686
675
  );
687
- return /* @__PURE__ */ c(p, { clean: !0, cursor: "pointer", p: 1, hover: { bgColor: "gray-200", borderRadius: 1 }, onClick: () => i(!t), children: [
688
- /* @__PURE__ */ r(ve, { viewBox: "0 0 24 24", width: "20", fill: "currentColor", ...u, children: /* @__PURE__ */ r("path", { d: "M5 6h14M5 12h14M5 18h14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }),
689
- t && /* @__PURE__ */ r(
690
- J,
676
+ return /* @__PURE__ */ h(g, { component: "datagrid.topBar.contextMenu", onClick: () => i(!t), children: [
677
+ /* @__PURE__ */ s(be, { viewBox: "0 0 24 24", width: "20", fill: "currentColor", ...a, children: /* @__PURE__ */ s("path", { d: "M5 6h14M5 12h14M5 18h14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }),
678
+ t && /* @__PURE__ */ s(ie, { component: "datagrid.topBar.contextMenu.tooltip", ref: o, children: n.map((r) => /* @__PURE__ */ h(
679
+ g,
691
680
  {
692
- bgColor: "white",
693
- width: 56,
694
- b: 1,
695
- borderColor: "gray-300",
696
- borderRadius: 1,
697
- display: "flex",
698
- d: "column",
699
- mt: 4,
700
- py: 2,
701
- translateX: -1,
702
- shadow: "medium-shadow",
703
- ref: o,
704
- overflow: "auto",
705
- maxHeight: 100,
706
- children: s.map((n) => /* @__PURE__ */ c(
707
- p,
708
- {
709
- clean: !0,
710
- display: "flex",
711
- gap: 2,
712
- p: 3,
713
- cursor: "pointer",
714
- hover: { bgColor: "gray-200" },
715
- onClick: (h) => {
716
- h.stopPropagation(), n.toggleVisibility();
717
- },
718
- children: [
719
- /* @__PURE__ */ r(V, { checked: n.isVisible, onChange: () => {
720
- }, focus: { outline: 0 } }),
721
- n.header ?? n.key
722
- ]
723
- },
724
- n.key
725
- ))
726
- }
727
- )
681
+ component: "datagrid.topBar.contextMenu.tooltip.item",
682
+ onClick: (c) => {
683
+ c.stopPropagation(), r.toggleVisibility();
684
+ },
685
+ children: [
686
+ /* @__PURE__ */ s(V, { variant: "datagrid", checked: r.isVisible, onChange: () => {
687
+ }, focus: { outline: 0 } }),
688
+ r.header ?? r.key
689
+ ]
690
+ },
691
+ r.key
692
+ )) })
728
693
  ] });
729
694
  }
730
- function Be(u) {
731
- const e = _e(u), { isResizeMode: t } = e, i = E(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render headers"), e.headerRows.value.map((n) => n.map((h) => /* @__PURE__ */ r(Te, { column: h }, h.uniqueKey)))), [e.headerRows.value]), o = me(null), s = ge(
732
- q.throttle((n) => {
733
- var h;
734
- (h = o.current) == null || h.setScrollTop(n.target.scrollTop);
735
- }, 100),
736
- [o.current]
737
- );
738
- return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render"), /* @__PURE__ */ c(g, { component: "datagrid", style: e.sizes.value, props: { role: "presentation" }, children: [
739
- /* @__PURE__ */ r(Ie, { grid: e }),
740
- /* @__PURE__ */ c(g, { overflowX: "scroll", props: { onScroll: s }, children: [
741
- /* @__PURE__ */ r(j, { component: "datagrid.header", variant: { isResizeMode: t }, style: { gridTemplateColumns: e.gridTemplateColumns.value }, children: i }),
742
- /* @__PURE__ */ r(te, { ref: o, grid: e })
743
- ] }),
744
- /* @__PURE__ */ c(g, { p: 3, bgColor: "gray-200", bt: 1, borderColor: "gray-400", children: [
745
- "Rows: ",
746
- u.data.length
747
- ] })
695
+ me.displayName = "DataGridTopBarContextMenu";
696
+ function pe(a) {
697
+ const { grid: e } = a;
698
+ return /* @__PURE__ */ h(w, { component: "datagrid.topBar", position: "relative", children: [
699
+ /* @__PURE__ */ s(me, { grid: e }),
700
+ /* @__PURE__ */ s(ue, { grid: e })
748
701
  ] });
749
702
  }
750
- Be.displayName = "DataGrid";
751
- const Z = 10, ee = 25, Ne = Z + ee * 2;
752
- function Ve(u, e) {
753
- const { grid: t } = u, i = ye * t.ROW_HEIGHT, [o, s] = z(0), n = Math.max(0, Math.floor(o / i) - ee), h = E(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render rows"), t.flatRows.value.take(Ne, n).map((d) => d instanceof Q ? /* @__PURE__ */ r(Pe, { row: d }, d.rowKey) : /* @__PURE__ */ r(We, { row: d }, d.rowKey))), [t.flatRows.value, n]);
754
- pe(e, () => ({
755
- setScrollTop: s
756
- }));
757
- const l = t.flatRows.value.length;
758
- return /* @__PURE__ */ r(g, { height: t.ROW_HEIGHT * Z + 4, children: /* @__PURE__ */ r(
759
- g,
760
- {
761
- style: {
762
- height: `${l * i}px`
763
- },
764
- children: /* @__PURE__ */ r(
765
- j,
766
- {
767
- width: "max-content",
768
- minWidth: "fit",
769
- transition: "none",
770
- style: {
771
- transform: `translateY(${n * i}px)`,
772
- gridTemplateColumns: t.gridTemplateColumns.value
773
- },
774
- children: h
775
- }
776
- )
777
- }
778
- ) });
703
+ pe.displayName = "DataGridTopBar";
704
+ function Me(a) {
705
+ const [e, t] = U(0), i = xe();
706
+ return i.current || (i.current = new Be(a, () => t((o) => o + 1))), i.current;
707
+ }
708
+ function Ee(a) {
709
+ const e = Me(a);
710
+ return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render"), /* @__PURE__ */ h(m, { component: "datagrid", style: e.sizes.value, props: { role: "presentation" }, children: [
711
+ /* @__PURE__ */ s(pe, { grid: e }),
712
+ /* @__PURE__ */ s(ce, { grid: e }),
713
+ /* @__PURE__ */ s(_e, { grid: e })
714
+ ] });
779
715
  }
780
- const te = ce(Ve);
781
- te.displayName = "Rows";
716
+ Ee.displayName = "DataGrid";
782
717
  export {
783
- Be as default
718
+ Ee as default
784
719
  };