@cronocode/react-box 3.1.6 → 3.1.8

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,46 +1,57 @@
1
- import { jsxs as d, jsx as r, Fragment as _e } from "react/jsx-runtime";
1
+ import { jsxs as d, jsx as n, Fragment as Be } from "react/jsx-runtime";
2
+ import Ee, { useCallback as k, useMemo as X, useState as M, useRef as O, useEffect as z, useLayoutEffect as Pe } from "react";
2
3
  import g from "../box.mjs";
3
4
  import m from "./flex.mjs";
4
- import Be, { useCallback as k, useMemo as Y, useState as W, useRef as O, useEffect as A } from "react";
5
- import he from "./grid.mjs";
6
- import { F as Ve, m as H, f as se, E as pe, b as me, D as Ee, S as ne, P as le, G as re, d as Me } from "../core.mjs";
7
- import Z from "./checkbox.mjs";
8
- import T from "./button.mjs";
9
- import D from "./dropdown.mjs";
5
+ import me from "./grid.mjs";
6
+ import { F as Ie, m as P, f as ae, E as ge, b as Me, D as He, S as oe, P as ce, G as se, d as ze } from "../core.mjs";
7
+ import le from "./checkbox.mjs";
8
+ import D from "./button.mjs";
9
+ import fe from "./baseSvg.mjs";
10
+ import b from "./dropdown.mjs";
10
11
  import j from "./textbox.mjs";
11
- import { Span as E } from "./semantics.mjs";
12
- import ge from "./tooltip.mjs";
13
- import We from "./baseSvg.mjs";
14
- function Ie(s) {
15
- const { grid: e } = s, { filtered: t, total: i } = e.filterStats, n = e.hasActiveFilters;
12
+ import { Span as I } from "./semantics.mjs";
13
+ import Ae from "./tooltip.mjs";
14
+ function Oe(s) {
15
+ const { grid: e } = s, { filtered: t, total: i } = e.filterStats, r = e.hasActiveFilters;
16
16
  return /* @__PURE__ */ d(m, { component: "datagrid.bottomBar", children: [
17
17
  /* @__PURE__ */ d(g, { children: [
18
18
  "Rows: ",
19
- n ? `${t} / ${i}` : i
19
+ r ? `${t} / ${i}` : i
20
20
  ] }),
21
21
  e.props.def.rowSelection && /* @__PURE__ */ d(g, { children: [
22
22
  "Selected: ",
23
23
  e.selectedRows.size
24
24
  ] }),
25
- n && /* @__PURE__ */ r(g, { color: "blue-600", cursor: "pointer", hover: { textDecoration: "underline" }, props: { onClick: e.clearAllFilters }, children: "Clear filters" })
25
+ r && /* @__PURE__ */ n(g, { color: "blue-600", cursor: "pointer", hover: { textDecoration: "underline" }, props: { onClick: e.clearAllFilters }, children: "Clear filters" })
26
26
  ] });
27
27
  }
28
- function fe(s) {
28
+ function Ce(s) {
29
29
  const { cell: e } = s, t = k(() => {
30
30
  e.grid.toggleRowSelection(e.row.key);
31
31
  }, [e.grid, e.row.key]);
32
- return /* @__PURE__ */ r(Z, { variant: "datagrid", checked: e.row.selected, onChange: t });
32
+ return /* @__PURE__ */ n(le, { variant: "datagrid", checked: e.row.selected, onChange: t });
33
33
  }
34
- fe.displayName = "DataGridCellRowSelection";
35
- const He = "NO_PIN";
36
- class M {
34
+ Ce.displayName = "DataGridCellRowSelection";
35
+ const $e = "NO_PIN";
36
+ class A {
37
37
  constructor(e, t, i) {
38
- this.def = e, this.grid = t, this.parent = i, this.columns = e.columns?.map((n) => new M(e.pin ? { ...n, pin: e.pin } : n, t, this)) ?? [], this.isLeaf && (this._inlineWidth = this.key == B ? void 0 : this.def.width ?? this.grid.DEFAULT_COLUMN_WIDTH_PX, this._pin = e.pin);
38
+ if (this.def = e, this.grid = t, this.parent = i, this.columns = e.columns?.map((r) => new A(e.pin ? { ...r, pin: e.pin } : r, t, this)) ?? [], this.isLeaf) {
39
+ const r = this.grid.columnWidths.get(this.key);
40
+ this._inlineWidth = this.key == V ? void 0 : r ?? this.def.width ?? this.grid.DEFAULT_COLUMN_WIDTH_PX, this._pin = e.pin;
41
+ }
39
42
  }
40
43
  columns = [];
41
44
  get visibleColumns() {
42
45
  return this.columns.filter((e) => e.isVisible);
43
46
  }
47
+ get isFirstLeaf() {
48
+ const { leafs: e } = this;
49
+ return e.length > 0 && e.at(0) === this;
50
+ }
51
+ get isLastLeaf() {
52
+ const { leafs: e } = this;
53
+ return e.length > 0 && e.at(-1) === this;
54
+ }
44
55
  get key() {
45
56
  return this.def.key;
46
57
  }
@@ -59,6 +70,22 @@ class M {
59
70
  get filterable() {
60
71
  return this.def.filterable;
61
72
  }
73
+ /** Whether sorting is enabled for this column. Column-level setting takes priority over grid-level. */
74
+ get sortable() {
75
+ return this.def.sortable !== void 0 ? this.def.sortable : this.grid.props.def.sortable !== !1;
76
+ }
77
+ /** Whether resizing is enabled for this column. Column-level setting takes priority over grid-level. */
78
+ get resizable() {
79
+ return this.def.resizable !== void 0 ? this.def.resizable : this.grid.props.def.resizable !== !1;
80
+ }
81
+ /** Whether column participates in flex distribution. Default true unless explicitly false. */
82
+ get isFlexible() {
83
+ return this.def.flexible !== !1;
84
+ }
85
+ /** The base width before flex calculation (what user set or DEFAULT). */
86
+ get baseWidth() {
87
+ return this._inlineWidth ?? this.grid.DEFAULT_COLUMN_WIDTH_PX;
88
+ }
62
89
  _pin;
63
90
  get pin() {
64
91
  if (this.isLeaf) return this._pin;
@@ -71,10 +98,10 @@ class M {
71
98
  getPinnedColumn(e) {
72
99
  if (this.hasPin(e)) {
73
100
  if (this.isLeaf) return this;
74
- const t = new M({ ...this.def, pin: e }, this.grid, this.parent);
101
+ const t = new A({ ...this.def, pin: e }, this.grid, this.parent);
75
102
  return t.columns = this.columns.filter((i) => i.hasPin(e)).map((i) => {
76
- const n = i.getPinnedColumn(e);
77
- return n.parent = t, n;
103
+ const r = i.getPinnedColumn(e);
104
+ return r.parent = t, r;
78
105
  }).filter((i) => !!i), t;
79
106
  }
80
107
  }
@@ -90,7 +117,8 @@ class M {
90
117
  }
91
118
  _inlineWidth;
92
119
  get inlineWidth() {
93
- if (this.isLeaf) return this._inlineWidth;
120
+ if (this.isLeaf)
121
+ return this.grid.getFlexWidth(this.key) ?? this._inlineWidth;
94
122
  const e = this.visibleColumns.map((t) => t.inlineWidth).filter((t) => typeof t == "number");
95
123
  if (e.length !== 0)
96
124
  return e.sumBy((t) => t);
@@ -98,22 +126,22 @@ class M {
98
126
  get left() {
99
127
  let e = 0;
100
128
  if (this.parent) {
101
- const { visibleColumns: t, left: i } = this.parent, n = t.findIndex((o) => o === this);
102
- e += t.sumBy((o, l) => l < n ? o.inlineWidth ?? 0 : 0), e += i;
129
+ const { visibleColumns: t, left: i } = this.parent, r = t.findIndex((o) => o === this);
130
+ e += t.sumBy((o, a) => a < r ? o.inlineWidth ?? 0 : 0), e += i;
103
131
  } else {
104
- const t = this.grid.columns.value.left.filter((n) => n.isVisible), i = t.findIndex((n) => n === this);
105
- e += t.sumBy((n, o) => o < i ? n.inlineWidth ?? 0 : 0);
132
+ const t = this.grid.columns.value.left.filter((r) => r.isVisible), i = t.findIndex((r) => r === this);
133
+ e += t.sumBy((r, o) => o < i ? r.inlineWidth ?? 0 : 0);
106
134
  }
107
135
  return e;
108
136
  }
109
137
  get right() {
110
138
  let e = 0;
111
139
  if (this.parent) {
112
- const { visibleColumns: t } = this.parent, i = t.reverse(), n = i.findIndex((o) => o === this);
113
- e += i.sumBy((o, l) => l < n ? o.inlineWidth ?? 0 : 0), e += this.parent.right;
140
+ const { visibleColumns: t } = this.parent, i = t.reverse(), r = i.findIndex((o) => o === this);
141
+ e += i.sumBy((o, a) => a < r ? o.inlineWidth ?? 0 : 0), e += this.parent.right;
114
142
  } else {
115
- const i = this.grid.columns.value.right.filter((o) => o.isVisible).reverse(), n = i.findIndex((o) => o === this);
116
- e += i.sumBy((o, l) => l < n ? o.inlineWidth ?? 0 : 0);
143
+ const i = this.grid.columns.value.right.filter((o) => o.isVisible).reverse(), r = i.findIndex((o) => o === this);
144
+ e += i.sumBy((o, a) => a < r ? o.inlineWidth ?? 0 : 0);
117
145
  }
118
146
  return e;
119
147
  }
@@ -148,17 +176,16 @@ class M {
148
176
  return this.isLeaf ? this.grid.columns.value.maxDeath - this.death : 1;
149
177
  }
150
178
  resizeColumn = (e) => {
151
- this.grid.isResizeMode = !0;
152
- const t = e.pageX, { MIN_COLUMN_WIDTH_PX: i, update: n } = this.grid, o = this.leafs.sumBy((c) => c.inlineWidth) - this.leafs.length * i, l = this.leafs.toRecord((c) => [c.key, c.inlineWidth]), u = Ve.throttle((c) => {
179
+ const t = e.pageX, { MIN_COLUMN_WIDTH_PX: i, update: r } = this.grid, o = this.leafs.toRecord((c) => [c.key, c.inlineWidth ?? c.baseWidth]), a = this.leafs.sumBy((c) => o[c.key]) - this.leafs.length * i, h = Ie.throttle((c) => {
153
180
  const p = (c.pageX - t) * (this.pin === "RIGHT" ? -1 : 1);
154
181
  this.leafs.forEach((f) => {
155
- const v = l[f.key], y = o > 0 ? (v - i) / o * p : p / this.leafs.length, R = Math.round(v + y);
182
+ const y = o[f.key], v = a > 0 ? (y - i) / a * p : p / this.leafs.length, R = Math.round(y + v);
156
183
  f.setWidth(R < i ? i : R);
157
- }), this.grid.sizes.clear(), n();
158
- }, 40), a = new AbortController(), h = (c) => {
159
- a.abort(), this.grid.isResizeMode = !1, n();
184
+ }), this.grid.flexWidths.clear(), this.grid.sizes.clear(), r();
185
+ }, 40), u = new AbortController(), l = (c) => {
186
+ u.abort(), r();
160
187
  };
161
- window.addEventListener("mousemove", u, a), window.addEventListener("mouseup", h, a);
188
+ window.addEventListener("mousemove", h, u), window.addEventListener("mouseup", l, u);
162
189
  };
163
190
  pinColumn = (e) => {
164
191
  this.isLeaf ? this._pin = e : this.columns.forEach((t) => t.pinColumn(e)), this.grid.pinColumn(this.uniqueKey, e);
@@ -178,15 +205,15 @@ class M {
178
205
  this.grid.toggleColumnVisibility(this.key);
179
206
  };
180
207
  }
181
- class Ae {
208
+ class Ue {
182
209
  constructor(e, t, i) {
183
210
  this.grid = e, this.row = t, this.column = i;
184
211
  }
185
212
  get value() {
186
- return this.column.key === L ? this.row.rowIndex + 1 : this.row.data[this.column.key];
213
+ return this.column.key === G ? this.row.rowIndex + 1 : this.row.data[this.column.key];
187
214
  }
188
215
  }
189
- class ae {
216
+ class ue {
190
217
  constructor(e, t, i) {
191
218
  this.grid = e, this.data = t, this.rowIndex = i, this.grid = e, this.data = t, this.key = this.grid.getRowKey(t);
192
219
  }
@@ -194,7 +221,7 @@ class ae {
194
221
  parentRow;
195
222
  count = 1;
196
223
  get cells() {
197
- return this.grid.columns.value.visibleLeafs.map((e) => new Ae(this.grid, this, e));
224
+ return this.grid.columns.value.visibleLeafs.map((e) => new Ue(this.grid, this, e));
198
225
  }
199
226
  get selected() {
200
227
  return this.grid.selectedRows.has(this.key);
@@ -206,50 +233,53 @@ class ae {
206
233
  return this;
207
234
  }
208
235
  }
209
- const B = "empty-cell", L = "row-number-cell", ce = 70, P = "row-selection-cell", N = "grouping-cell";
210
- class ze {
236
+ const V = "empty-cell", G = "row-number-cell", he = 70, _ = "row-selection-cell", T = "grouping-cell";
237
+ class je {
211
238
  constructor(e, t) {
212
239
  this.props = e, this.update = t, console.debug("\x1B[32m%s\x1B[0m", "[react-box]: DataGrid GridModel ctor");
213
240
  }
214
- sourceColumns = H(() => {
241
+ sourceColumns = P(() => {
215
242
  const { def: e } = this.props, t = [];
216
- if (this.groupColumns.size > 0 && t.push(new M({ key: N }, this)), t.push(...e.columns.map((i) => new M(i, this))), t.push(new M({ key: B, Cell: () => null }, this)), e.rowSelection) {
243
+ if (this.groupColumns.size > 0 && t.push(new A({ key: T }, this)), t.push(...e.columns.map((i) => new A(i, this))), e.rowSelection) {
217
244
  const i = typeof e.rowSelection == "object" && e.rowSelection.pinned ? "LEFT" : void 0;
218
245
  t.unshift(
219
- new M({ key: P, pin: i, width: 50, align: "center", Cell: fe }, this)
246
+ new A({ key: _, pin: i, width: 50, align: "center", Cell: Ce }, this)
220
247
  );
221
248
  }
222
249
  if (e.showRowNumber) {
223
- let i, n = ce;
224
- typeof e.showRowNumber == "object" && (e.showRowNumber.pinned && (i = "LEFT"), n = e.showRowNumber.width ?? ce), t.unshift(new M({ key: L, pin: i, width: n, align: "right" }, this));
250
+ let i, r = he;
251
+ typeof e.showRowNumber == "object" && (e.showRowNumber.pinned && (i = "LEFT"), r = e.showRowNumber.width ?? he), t.unshift(new A({ key: G, pin: i, width: r, align: "right" }, this));
225
252
  }
226
253
  return t;
227
254
  });
228
- columns = H(() => {
255
+ columns = P(() => {
229
256
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid columns memo");
230
- const e = this.sourceColumns.value.map((a) => a.getPinnedColumn("LEFT")).filter((a) => !!a), t = this.sourceColumns.value.map((a) => a.getPinnedColumn()).filter((a) => !!a), i = this.sourceColumns.value.map((a) => a.getPinnedColumn("RIGHT")).filter((a) => !!a), n = [...e, ...t, ...i].flatMap((a) => a.flatColumns), o = n.filter((a) => a.isLeaf), l = n.filter((a) => a.isLeaf && a.isVisible), u = n.maxBy((a) => a.death) + 1;
257
+ const e = this.sourceColumns.value.map((l) => l.getPinnedColumn("LEFT")).filter((l) => !!l), t = this.sourceColumns.value.map((l) => l.getPinnedColumn()).filter((l) => !!l), i = this.sourceColumns.value.map((l) => l.getPinnedColumn("RIGHT")).filter((l) => !!l), r = [...e, ...t, ...i].flatMap((l) => l.flatColumns), o = r.filter((l) => l.isLeaf), a = r.filter((l) => l.isLeaf && l.isVisible), h = a.filter(
258
+ (l) => ![V, G, _, T].includes(l.key)
259
+ ), u = r.maxBy((l) => l.death) + 1;
231
260
  return {
232
261
  left: e,
233
262
  middle: t,
234
263
  right: i,
235
- flat: n,
264
+ flat: r,
236
265
  leafs: o,
237
- visibleLeafs: l,
266
+ visibleLeafs: a,
267
+ userVisibleLeafs: h,
238
268
  maxDeath: u
239
269
  };
240
270
  });
241
- headerRows = H(() => (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) => {
242
- const i = t.values.groupBy((n) => n.pin ?? He).toRecord((n) => [n.key, n.values]);
271
+ headerRows = P(() => (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) => {
272
+ const i = t.values.groupBy((r) => r.pin ?? $e).toRecord((r) => [r.key, r.values]);
243
273
  return [
244
- ...i.LEFT?.filter((n) => n.isVisible) ?? [],
245
- ...i.NO_PIN?.filter((n) => n.isVisible) ?? [],
246
- ...i.RIGHT?.filter((n) => n.isVisible) ?? []
274
+ ...i.LEFT?.filter((r) => r.isVisible) ?? [],
275
+ ...i.NO_PIN?.filter((r) => r.isVisible) ?? [],
276
+ ...i.RIGHT?.filter((r) => r.isVisible) ?? []
247
277
  ];
248
278
  })));
249
- gridTemplateColumns = H(() => {
279
+ gridTemplateColumns = P(() => {
250
280
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid gridTemplateColumns memo");
251
- const { visibleLeafs: e } = this.columns.value, t = e.sumBy((l) => l.pin === "RIGHT" ? 1 : 0), i = e.length - t - 1, n = i > 0 ? `repeat(${i}, max-content)` : "", o = t > 0 ? `repeat(${t}, max-content)` : "";
252
- return `${n} auto ${o}`;
281
+ const { visibleLeafs: e } = this.columns.value, t = e.sumBy((a) => a.pin === "RIGHT" ? 1 : 0), i = e.length - t, r = i > 0 ? `repeat(${i}, max-content)` : "", o = t > 0 ? `repeat(${t}, max-content)` : "";
282
+ return `${r} ${o}`.trim();
253
283
  });
254
284
  // ========== Filtering ==========
255
285
  _globalFilterValue = "";
@@ -266,12 +296,12 @@ class ze {
266
296
  applyGlobalFilter(e) {
267
297
  const t = this.globalFilterValue.trim();
268
298
  if (!t) return e;
269
- const { globalFilterKeys: i } = this.props.def, n = i ?? this.columns.value.leafs.filter(
270
- (o) => o.key !== B && o.key !== L && o.key !== P && o.key !== N
299
+ const { globalFilterKeys: i } = this.props.def, r = i ?? this.columns.value.leafs.filter(
300
+ (o) => o.key !== V && o.key !== G && o.key !== _ && o.key !== T
271
301
  ).map((o) => o.key);
272
- return e.filter((o) => n.some((l) => {
273
- const u = o[l];
274
- return u == null ? !1 : se(t, String(u));
302
+ return e.filter((o) => r.some((a) => {
303
+ const h = o[a];
304
+ return h == null ? !1 : ae(t, String(h));
275
305
  }));
276
306
  }
277
307
  /**
@@ -279,11 +309,11 @@ class ze {
279
309
  */
280
310
  applyColumnFilters(e) {
281
311
  const t = this.columnFilters, i = Object.keys(t);
282
- return i.length === 0 ? e : e.filter((n) => i.every((o) => {
283
- const l = t[o];
284
- if (!l) return !0;
285
- const u = n[o];
286
- return this.matchesFilter(u, l);
312
+ return i.length === 0 ? e : e.filter((r) => i.every((o) => {
313
+ const a = t[o];
314
+ if (!a) return !0;
315
+ const h = r[o];
316
+ return this.matchesFilter(h, a);
287
317
  }));
288
318
  }
289
319
  /**
@@ -292,7 +322,7 @@ class ze {
292
322
  matchesFilter(e, t) {
293
323
  switch (t.type) {
294
324
  case "text":
295
- return t.value.trim() ? e == null ? !1 : se(t.value, String(e)) : !0;
325
+ return t.value.trim() ? e == null ? !1 : ae(t.value, String(e)) : !0;
296
326
  case "number": {
297
327
  if (e == null) return !1;
298
328
  const i = typeof e == "number" ? e : parseFloat(String(e));
@@ -360,9 +390,9 @@ class ze {
360
390
  getColumnUniqueValues = (e) => {
361
391
  const t = /* @__PURE__ */ new Set();
362
392
  return this.props.data.forEach((i) => {
363
- const n = i[e];
364
- n !== void 0 && t.add(n);
365
- }), Array.from(t).sort((i, n) => i === null ? 1 : n === null ? -1 : typeof i == "string" && typeof n == "string" ? i.localeCompare(n) : typeof i == "number" && typeof n == "number" ? i - n : String(i).localeCompare(String(n)));
393
+ const r = i[e];
394
+ r !== void 0 && t.add(r);
395
+ }), Array.from(t).sort((i, r) => i === null ? 1 : r === null ? -1 : typeof i == "string" && typeof r == "string" ? i.localeCompare(r) : typeof i == "number" && typeof r == "number" ? i - r : String(i).localeCompare(String(r)));
366
396
  };
367
397
  /**
368
398
  * Check if any filter is active
@@ -379,50 +409,78 @@ class ze {
379
409
  total: this.props.data.length
380
410
  };
381
411
  }
382
- rows = H(() => {
412
+ rows = P(() => {
383
413
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid rows memo");
384
414
  let e = this.filteredData;
385
415
  if (this._sortColumn && (e = e.sortBy((t) => t[this._sortColumn], this._sortDirection)), this.groupColumns.size > 0) {
386
- const t = (i, n, o) => {
387
- const l = n.values().next().value;
388
- n.delete(l);
389
- const u = this.columns.value.leafs.findOrThrow((a) => a.key === l);
390
- return this._sortColumn === N && (i = i.sortBy((a) => a[l], this._sortDirection)), i.groupBy((a) => a[l]).map((a) => {
391
- let h;
392
- n.size > 0 ? h = t(a.values, new Set(n), o + 1) : h = a.values.map((p, f) => new ae(this, p, o + 1 + f));
393
- const c = new we(this, u, h, o, a.key);
394
- return o += 1, c.expanded && (o += h.length), c;
416
+ const t = (i, r, o) => {
417
+ const a = r.values().next().value;
418
+ r.delete(a);
419
+ const h = this.columns.value.leafs.findOrThrow((u) => u.key === a);
420
+ return this._sortColumn === T && (i = i.sortBy((u) => u[a], this._sortDirection)), i.groupBy((u) => u[a]).map((u) => {
421
+ let l;
422
+ r.size > 0 ? l = t(u.values, new Set(r), o + 1) : l = u.values.map((p, f) => new ue(this, p, o + 1 + f));
423
+ const c = new we(this, h, l, o, u.key);
424
+ return o += 1, c.expanded && (o += l.length), c;
395
425
  });
396
426
  };
397
427
  return t(e, new Set(this.groupColumns), 0);
398
428
  }
399
- return e.map((t, i) => new ae(this, t, i));
429
+ return e.map((t, i) => new ue(this, t, i));
400
430
  });
401
- flatRows = H(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid flatRows memo"), this.rows.value.flatMap((e) => e.flatRows)));
431
+ flatRows = P(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid flatRows memo"), this.rows.value.flatMap((e) => e.flatRows)));
402
432
  get rowHeight() {
403
433
  return this.props.def.rowHeight ?? this.DEFAULT_ROW_HEIGHT_PX;
404
434
  }
405
- sizes = H(() => {
435
+ sizes = P(() => {
406
436
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid sizes memo");
407
- const e = this.columns.value.flat.reduce((n, o) => {
408
- const { inlineWidth: l } = o;
409
- return typeof l == "number" && (n[o.widthVarName] = `${o.inlineWidth}px`), o.pin === "LEFT" && (n[o.leftVarName] = `${o.left}px`), o.pin === "RIGHT" && (n[o.rightVarName] = `${o.right}px`), n;
437
+ const e = this.columns.value.flat.reduce((r, o) => {
438
+ const { inlineWidth: a } = o;
439
+ return typeof a == "number" && (r[o.widthVarName] = `${o.inlineWidth}px`), o.pin === "LEFT" && (r[o.leftVarName] = `${o.left}px`), o.pin === "RIGHT" && (r[o.rightVarName] = `${o.right}px`), r;
410
440
  }, {});
411
441
  e[this.rowHeightVarName] = `${this.rowHeight}px`, e[this.leftEdgeVarName] = `${this.leftEdge}px`;
412
- const { visibleLeafs: t } = this.columns.value, i = t.find((n) => n.key === N);
442
+ const { visibleLeafs: t } = this.columns.value, i = t.find((r) => r.key === T);
413
443
  if (i) {
414
- const n = t.sumBy((o) => o.pin === i.pin && o.key !== L && o.key !== P ? o.inlineWidth ?? 0 : 0);
415
- e[i.groupColumnWidthVarName] = `${n}px`;
444
+ const r = t.sumBy((o) => o.pin === i.pin && o.key !== G && o.key !== _ ? o.inlineWidth ?? 0 : 0);
445
+ e[i.groupColumnWidthVarName] = `${r}px`;
416
446
  }
417
- return this.groupColumns.forEach((n) => {
418
- const o = this.columns.value.leafs.findOrThrow((l) => l.key === n);
419
- e[o.groupColumnWidthVarName] = `${t.sumBy((l) => l.pin === o.pin ? l.inlineWidth ?? 0 : 0)}px`;
447
+ return this.groupColumns.forEach((r) => {
448
+ const o = this.columns.value.leafs.findOrThrow((a) => a.key === r);
449
+ e[o.groupColumnWidthVarName] = `${t.sumBy((a) => a.pin === o.pin ? a.inlineWidth ?? 0 : 0)}px`;
420
450
  }), e;
421
451
  });
452
+ // ========== Flexible Column Sizing ==========
453
+ _containerWidth = 0;
454
+ get containerWidth() {
455
+ return this._containerWidth;
456
+ }
457
+ setContainerWidth = (e) => {
458
+ this._containerWidth !== e && (this._containerWidth = e, this.flexWidths.clear(), this.sizes.clear(), this.update());
459
+ };
460
+ flexWidths = P(() => {
461
+ console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid flexWidths memo");
462
+ const e = this._containerWidth;
463
+ if (e <= 0) return {};
464
+ const t = this.columns.value.visibleLeafs.filter((c) => c.key !== V), i = (c) => !c.isFlexible || this.columnWidths.has(c.key), r = t.filter(i).sumBy((c) => c.baseWidth), o = t.filter((c) => !i(c)), a = o.sumBy((c) => c.baseWidth), h = e - r;
465
+ if (h <= a)
466
+ return o.toRecord((c) => [c.key, c.baseWidth]);
467
+ const u = {};
468
+ let l = 0;
469
+ return o.forEach((c, p) => {
470
+ if (p === o.length - 1)
471
+ u[c.key] = h - l;
472
+ else {
473
+ const f = Math.floor(c.baseWidth / a * h);
474
+ u[c.key] = f, l += f;
475
+ }
476
+ }), u;
477
+ });
478
+ getFlexWidth(e) {
479
+ return this.flexWidths.value[e];
480
+ }
422
481
  DEFAULT_ROW_HEIGHT_PX = 48;
423
482
  MIN_COLUMN_WIDTH_PX = 48;
424
483
  DEFAULT_COLUMN_WIDTH_PX = 200;
425
- isResizeMode = !1;
426
484
  expandedGroupRow = /* @__PURE__ */ new Set();
427
485
  selectedRows = /* @__PURE__ */ new Set();
428
486
  get leftEdge() {
@@ -442,21 +500,21 @@ class ze {
442
500
  if (t.length > 0)
443
501
  [this._sortDirection] = t, this._sortColumn = this._sortDirection ? e : void 0;
444
502
  else {
445
- const { _sortColumn: i, _sortDirection: n } = this;
446
- this._sortColumn = i === e && n === "DESC" ? void 0 : e, this._sortDirection = i === e && n === "ASC" ? "DESC" : "ASC";
503
+ const { _sortColumn: i, _sortDirection: r } = this;
504
+ this._sortColumn = i === e && r === "DESC" ? void 0 : e, this._sortDirection = i === e && r === "ASC" ? "DESC" : "ASC";
447
505
  }
448
506
  this.headerRows.clear(), this.rows.clear(), this.flatRows.clear(), this.update();
449
507
  };
450
508
  pinColumn = (e, t) => {
451
- const i = this.columns.value.flat.findOrThrow((n) => n.uniqueKey === e);
452
- 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();
509
+ const i = this.columns.value.flat.findOrThrow((r) => r.uniqueKey === e);
510
+ i.pin !== t && i.pinColumn(t), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.flexWidths.clear(), this.sizes.clear(), this.update();
453
511
  };
454
512
  toggleGrouping = (e) => {
455
- 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)), this.sourceColumns.clear(), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
513
+ 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)), this.sourceColumns.clear(), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.flexWidths.clear(), this.sizes.clear(), this.update();
456
514
  };
457
515
  unGroupAll = () => {
458
516
  const e = new Set(this.groupColumns);
459
- this.groupColumns = /* @__PURE__ */ new Set(), this.hiddenColumns = new Set(Array.from(this.hiddenColumns).filter((t) => !e.has(t))), this.sourceColumns.clear(), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
517
+ this.groupColumns = /* @__PURE__ */ new Set(), this.hiddenColumns = new Set(Array.from(this.hiddenColumns).filter((t) => !e.has(t))), this.sourceColumns.clear(), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.flexWidths.clear(), this.sizes.clear(), this.update();
460
518
  };
461
519
  toggleGroupRow = (e) => {
462
520
  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();
@@ -478,16 +536,14 @@ class ze {
478
536
  this.toggleRowsSelection(this.props.data.map((e) => this.getRowKey(e)));
479
537
  };
480
538
  toggleColumnVisibility = (e) => {
481
- 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();
539
+ 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.flexWidths.clear(), this.sizes.clear(), this.update();
482
540
  };
483
541
  setWidth = (e, t) => {
484
- const i = this.columns.value.leafs.find((o) => o.key === e);
485
- if (!i)
486
- throw new Error("Leaf column not found.");
487
- i.setWidth(t), this.sourceColumns.value.flatMap((o) => o.flatColumns).findOrThrow((o) => o.key === e).setWidth(t);
542
+ this.columnWidths.set(e, t);
488
543
  };
489
544
  groupColumns = /* @__PURE__ */ new Set();
490
545
  hiddenColumns = /* @__PURE__ */ new Set();
546
+ columnWidths = /* @__PURE__ */ new Map();
491
547
  _sortColumn;
492
548
  get sortColumn() {
493
549
  return this._sortColumn;
@@ -497,24 +553,24 @@ class ze {
497
553
  return this._sortDirection;
498
554
  }
499
555
  }
500
- class Oe {
556
+ class qe {
501
557
  constructor(e, t, i) {
502
558
  this.grid = e, this.row = t, this.column = i;
503
559
  }
504
560
  get value() {
505
- return this.column.key === L ? this.row.rowIndex + 1 : this.column.key === N ? `${this.row.groupValue} (${this.row.count})` : null;
561
+ return this.column.key === G ? this.row.rowIndex + 1 : this.column.key === T ? `${this.row.groupValue} (${this.row.count})` : null;
506
562
  }
507
563
  }
508
564
  class we {
509
- constructor(e, t, i, n, o) {
510
- this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = n, this.groupValue = o, i.forEach((l) => l.parentRow = this);
565
+ constructor(e, t, i, r, o) {
566
+ this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = r, this.groupValue = o, i.forEach((a) => a.parentRow = this);
511
567
  }
512
568
  get key() {
513
569
  return `${this.parentRow?.key ?? ""}${this.groupColumn.key}${this.groupValue}`;
514
570
  }
515
571
  parentRow;
516
572
  get cells() {
517
- return this.grid.columns.value.visibleLeafs.map((e) => new Oe(this.grid, this, e));
573
+ return this.grid.columns.value.visibleLeafs.map((e) => new qe(this.grid, this, e));
518
574
  }
519
575
  get selected() {
520
576
  return this.allRows.every((e) => e.selected);
@@ -538,231 +594,277 @@ class we {
538
594
  return this.rows.flatMap((e) => e.allRows);
539
595
  }
540
596
  get groupingColumn() {
541
- return this.grid.columns.value.leafs.findOrThrow((e) => e.key === N);
597
+ return this.grid.columns.value.leafs.findOrThrow((e) => e.key === T);
542
598
  }
543
599
  get groupingColumnGridColumn() {
544
600
  const { visibleLeafs: e } = this.grid.columns.value, { groupingColumn: t } = this;
545
601
  return e.sumBy(
546
- (n) => n.pin === t.pin && n.key !== B && n.key !== P && n.key !== L ? 1 : 0
602
+ (r) => r.pin === t.pin && r.key !== V && r.key !== _ && r.key !== G ? 1 : 0
547
603
  );
548
604
  }
549
605
  toggleRow() {
550
606
  this.grid.toggleGroupRow(this.key);
551
607
  }
552
608
  }
553
- function X(s) {
554
- const { children: e, column: t, style: i, ...n } = s, { key: o, pin: l, left: u, right: a, isEdge: h, align: c, widthVarName: p, leftVarName: f, rightVarName: v } = t;
555
- "align" in t.def && (n.jc = c);
556
- const y = o === L, R = o === P, F = l === "LEFT", b = l === "RIGHT";
557
- return /* @__PURE__ */ r(
609
+ function q(s) {
610
+ const { children: e, column: t, style: i, ...r } = s, { key: o, pin: a, left: h, right: u, isEdge: l, align: c, widthVarName: p, leftVarName: f, rightVarName: y, isFirstLeaf: v, isLastLeaf: R } = t;
611
+ "align" in t.def && (r.jc = c);
612
+ const N = o === G, S = o === _, x = o === V, L = a === "LEFT", C = a === "RIGHT";
613
+ return /* @__PURE__ */ n(
558
614
  m,
559
615
  {
560
616
  component: "datagrid.body.cell",
561
617
  props: { role: "cell" },
562
618
  variant: {
563
- isPinned: F || b,
564
- isFirstLeftPinned: F && u === 0,
565
- isLastLeftPinned: F && h,
566
- isFirstRightPinned: b && h,
567
- isLastRightPinned: b && a === 0,
568
- isRowSelection: R,
569
- isRowNumber: y
619
+ isPinned: L || C,
620
+ isFirstLeftPinned: L && h === 0,
621
+ isLastLeftPinned: L && l,
622
+ isFirstRightPinned: C && l,
623
+ isLastRightPinned: C && u === 0,
624
+ isRowSelection: S,
625
+ isRowNumber: N,
626
+ isFirstLeaf: v,
627
+ isLastLeaf: R,
628
+ isEmptyCell: x
570
629
  },
571
630
  style: {
572
631
  width: `var(${p})`,
573
632
  height: `var(${t.grid.rowHeightVarName})`,
574
- left: F ? `var(${f})` : void 0,
575
- right: b ? `var(${v})` : void 0,
633
+ left: L ? `var(${f})` : void 0,
634
+ right: C ? `var(${y})` : void 0,
576
635
  ...i
577
636
  },
578
- ...n,
637
+ ...r,
579
638
  children: e
580
639
  }
581
640
  );
582
641
  }
583
- X.displayName = "DataGridCell";
584
- function Ce(s) {
585
- const { row: e } = s, { selected: t, indeterminate: i, cells: n, groupingColumn: o, groupingColumnGridColumn: l, depth: u, expanded: a } = e, h = k(() => {
642
+ q.displayName = "DataGridCell";
643
+ function ye(s) {
644
+ const { row: e } = s, { selected: t, indeterminate: i, cells: r, groupingColumn: o, groupingColumnGridColumn: a, depth: h, expanded: u } = e, l = k(() => {
586
645
  e.grid.toggleRowsSelection(e.allRows.map((c) => c.key));
587
646
  }, []);
588
- return /* @__PURE__ */ r(m, { className: "grid-row", selected: t, display: "contents", props: { role: "rowgroup" }, children: n.map((c) => {
589
- const { key: p, pin: f, groupColumnWidthVarName: v } = c.column, y = f === "RIGHT";
590
- if (p === N)
591
- return /* @__PURE__ */ r(
592
- X,
647
+ return /* @__PURE__ */ n(m, { className: "grid-row", selected: t, display: "contents", props: { role: "rowgroup" }, children: r.map((c) => {
648
+ const { key: p, pin: f, groupColumnWidthVarName: y } = c.column, v = f === "RIGHT";
649
+ if (p === T)
650
+ return /* @__PURE__ */ n(
651
+ q,
593
652
  {
594
653
  column: c.column,
595
654
  style: {
596
- width: `var(${v})`,
597
- right: y ? "0" : void 0
655
+ width: `var(${y})`,
656
+ right: v ? "0" : void 0
598
657
  },
599
658
  br: o.pin === "LEFT" ? 1 : void 0,
600
- gridColumn: l,
601
- pl: 4 * u,
659
+ gridColumn: a,
660
+ pl: 4 * h,
602
661
  overflow: "auto",
603
- children: /* @__PURE__ */ r(g, { textWrap: "nowrap", px: 3, children: /* @__PURE__ */ d(T, { clean: !0, onClick: () => e.toggleRow(), cursor: "pointer", display: "flex", gap: 1, ai: "center", children: [
604
- /* @__PURE__ */ r(pe, { fill: "currentColor", width: "14px", height: "14px", rotate: a ? 0 : -90 }),
662
+ children: /* @__PURE__ */ n(g, { textWrap: "nowrap", px: 3, children: /* @__PURE__ */ d(D, { clean: !0, onClick: () => e.toggleRow(), cursor: "pointer", display: "flex", gap: 1, ai: "center", children: [
663
+ /* @__PURE__ */ n(ge, { fill: "currentColor", width: "14px", height: "14px", rotate: u ? 0 : -90 }),
605
664
  c.value
606
665
  ] }) })
607
666
  },
608
667
  p
609
668
  );
610
- if (p === P)
611
- return /* @__PURE__ */ r(X, { column: c.column, children: /* @__PURE__ */ r(Z, { variant: "datagrid", m: 1, checked: t, indeterminate: i, onChange: h }) }, p);
612
- if (f !== o.pin || p === L || p === B)
613
- return /* @__PURE__ */ r(X, { column: c.column, px: p === L ? 3 : void 0, children: c.value }, p);
669
+ if (p === _)
670
+ return /* @__PURE__ */ n(q, { column: c.column, children: /* @__PURE__ */ n(le, { variant: "datagrid", m: 1, checked: t, indeterminate: i, onChange: l }) }, p);
671
+ if (f !== o.pin || p === G || p === V)
672
+ return /* @__PURE__ */ n(q, { column: c.column, px: p === G ? 3 : void 0, children: c.value }, p);
614
673
  }) });
615
674
  }
616
- Ce.displayName = "DataGridGroupRow";
675
+ ye.displayName = "DataGridGroupRow";
617
676
  function ve(s) {
618
677
  const { cell: e } = s;
619
- return /* @__PURE__ */ r(m, { height: "fit", width: "fit", overflow: "auto", ai: "center", jc: e.column.align, children: /* @__PURE__ */ r(g, { px: 3, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: e.value }) });
678
+ return /* @__PURE__ */ n(m, { height: "fit", width: "fit", overflow: "auto", ai: "center", jc: e.column.align, children: /* @__PURE__ */ n(g, { px: 3, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: e.value }) });
620
679
  }
621
680
  ve.displayName = "DataGridCellText";
622
- function ye(s) {
681
+ function be(s) {
623
682
  const { row: e } = s, { selected: t } = e;
624
- return /* @__PURE__ */ r(m, { className: "grid-row", selected: t, display: "contents", props: { role: "row" }, children: e.cells.map((i) => /* @__PURE__ */ r(X, { column: i.column, children: i.column.Cell ? /* @__PURE__ */ r(i.column.Cell, { cell: i }) : /* @__PURE__ */ r(ve, { cell: i }) }, i.column.key)) });
683
+ return /* @__PURE__ */ n(m, { className: "grid-row", selected: t, display: "contents", props: { role: "row" }, children: e.cells.map((i) => /* @__PURE__ */ n(q, { column: i.column, children: i.column.Cell ? /* @__PURE__ */ n(i.column.Cell, { cell: i }) : /* @__PURE__ */ n(ve, { cell: i }) }, i.column.key)) });
625
684
  }
626
- ye.displayName = "DataGridRow";
627
- const $e = 10, ue = 20;
685
+ be.displayName = "DataGridRow";
686
+ const Xe = 10, de = 20;
628
687
  function Re(s) {
629
- const { grid: e, scrollTop: t } = s, i = e.flatRows.value.length, n = Math.max(0, Math.floor(t / e.rowHeight) - ue), o = e.props.def.visibleRowsCount ?? $e, l = e.rowHeight * o + e.rowHeight / 5, u = Y(() => {
688
+ const { grid: e, scrollTop: t } = s, i = e.flatRows.value.length, r = Math.max(0, Math.floor(t / e.rowHeight) - de), o = e.props.def.visibleRowsCount ?? Xe, a = e.rowHeight * o + e.rowHeight / 5, h = X(() => {
630
689
  if (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render rows"), e.props.data.length === 0)
631
- return /* @__PURE__ */ r(m, { jc: "center", ai: "center", gridColumn: "full-row", style: { height: l }, children: e.props.loading ? "loading..." : "empty" });
632
- const a = o + ue * 2;
633
- return e.flatRows.value.take(a, n).map((c) => c instanceof we ? /* @__PURE__ */ r(Ce, { row: c }, c.key) : /* @__PURE__ */ r(ye, { row: c }, c.key));
634
- }, [e.flatRows.value, e.props.data.length, e.props.loading, n, l, o]);
635
- return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render DataGridBody"), /* @__PURE__ */ r(g, { style: { height: l }, children: /* @__PURE__ */ r(
690
+ return /* @__PURE__ */ n(m, { jc: "center", ai: "center", gridColumn: "full-row", style: { height: a }, children: e.props.loading ? "loading..." : "empty" });
691
+ const u = o + de * 2;
692
+ return e.flatRows.value.take(u, r).map((c) => c instanceof we ? /* @__PURE__ */ n(ye, { row: c }, c.key) : /* @__PURE__ */ n(be, { row: c }, c.key));
693
+ }, [e.flatRows.value, e.props.data.length, e.props.loading, r, a, o]);
694
+ return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render DataGridBody"), /* @__PURE__ */ n(g, { style: { height: a }, children: /* @__PURE__ */ n(
636
695
  g,
637
696
  {
638
697
  style: {
639
698
  height: `${i * e.rowHeight}px`
640
699
  },
641
- children: /* @__PURE__ */ r(
642
- he,
700
+ children: /* @__PURE__ */ n(
701
+ me,
643
702
  {
644
703
  component: "datagrid.body",
645
704
  width: "max-content",
646
705
  minWidth: "fit",
647
706
  transition: "none",
648
707
  style: {
649
- transform: `translate3d(0, ${n * e.rowHeight}px, 0)`,
708
+ transform: `translate3d(0, ${r * e.rowHeight}px, 0)`,
650
709
  willChange: "transform",
651
710
  gridTemplateColumns: e.gridTemplateColumns.value
652
711
  },
653
- children: u
712
+ children: h
654
713
  }
655
714
  )
656
715
  }
657
716
  ) });
658
717
  }
659
718
  Re.displayName = "DataGridBody";
660
- function de({ column: s, grid: e }) {
661
- const t = e.columnFilters[s.key], i = t?.type === "text" ? t.value : "", [n, o] = W(i), l = O(null);
662
- A(() => () => {
663
- l.current && clearTimeout(l.current);
719
+ function Ye() {
720
+ return /* @__PURE__ */ n(
721
+ m,
722
+ {
723
+ d: "column",
724
+ ai: "center",
725
+ jc: "center",
726
+ gap: 4,
727
+ py: 16,
728
+ px: 6,
729
+ bgColor: "gray-50",
730
+ borderRadius: 4,
731
+ theme: { dark: { bgColor: "gray-900" } },
732
+ children: /* @__PURE__ */ d(m, { d: "column", ai: "center", gap: 3, children: [
733
+ /* @__PURE__ */ n(
734
+ g,
735
+ {
736
+ width: 16,
737
+ height: 16,
738
+ borderRadius: 999,
739
+ bgColor: "gray-200",
740
+ theme: { dark: { bgColor: "gray-700" } },
741
+ display: "flex",
742
+ ai: "center",
743
+ jc: "center",
744
+ children: /* @__PURE__ */ n(fe, { viewBox: "0 0 24 24", width: "40", fill: "currentColor", color: "gray-400", theme: { dark: { color: "gray-500" } }, children: /* @__PURE__ */ n(
745
+ "path",
746
+ {
747
+ fillRule: "evenodd",
748
+ clipRule: "evenodd",
749
+ d: "M3 6a3 3 0 013-3h12a3 3 0 013 3v12a3 3 0 01-3 3H6a3 3 0 01-3-3V6zm3-1a1 1 0 00-1 1v12a1 1 0 001 1h12a1 1 0 001-1V6a1 1 0 00-1-1H6zm2 3a1 1 0 011-1h6a1 1 0 110 2H9a1 1 0 01-1-1zm0 4a1 1 0 011-1h6a1 1 0 110 2H9a1 1 0 01-1-1zm0 4a1 1 0 011-1h4a1 1 0 110 2H9a1 1 0 01-1-1z"
750
+ }
751
+ ) })
752
+ }
753
+ ),
754
+ /* @__PURE__ */ d(m, { d: "column", ai: "center", gap: 1, children: [
755
+ /* @__PURE__ */ n(g, { fontSize: 18, fontWeight: 600, color: "gray-900", theme: { dark: { color: "gray-50" } }, children: "No Columns Selected" }),
756
+ /* @__PURE__ */ n(g, { fontSize: 14, color: "gray-500", textAlign: "center", theme: { dark: { color: "gray-400" } }, children: "Select at least one column from the columns menu to display data" })
757
+ ] })
758
+ ] })
759
+ }
760
+ );
761
+ }
762
+ function pe({ column: s, grid: e }) {
763
+ const t = e.columnFilters[s.key], i = t?.type === "text" ? t.value : "", [r, o] = M(i), a = O(null);
764
+ z(() => () => {
765
+ a.current && clearTimeout(a.current);
664
766
  }, []);
665
- const u = k(
767
+ const h = k(
666
768
  (c) => {
667
769
  const p = c.target.value;
668
- o(p), l.current && clearTimeout(l.current), l.current = setTimeout(() => {
669
- p.trim() ? e.setColumnFilter(s.key, { type: "text", value: p }) : e.setColumnFilter(s.key, void 0), l.current = null;
770
+ o(p), a.current && clearTimeout(a.current), a.current = setTimeout(() => {
771
+ p.trim() ? e.setColumnFilter(s.key, { type: "text", value: p }) : e.setColumnFilter(s.key, void 0), a.current = null;
670
772
  }, 300);
671
773
  },
672
774
  [e, s.key]
673
- ), a = k(() => {
775
+ ), u = k(() => {
674
776
  o(""), e.setColumnFilter(s.key, void 0);
675
- }, [e, s.key]), h = typeof s.def.filterable == "object" ? s.def.filterable : {};
777
+ }, [e, s.key]), l = typeof s.def.filterable == "object" ? s.def.filterable : {};
676
778
  return /* @__PURE__ */ d(m, { ai: "center", position: "relative", width: "fit", children: [
677
- /* @__PURE__ */ r(j, { width: "fit", variant: "compact", placeholder: h.placeholder ?? "Filter...", value: n, onChange: u }),
678
- n && /* @__PURE__ */ r(m, { position: "absolute", right: 2, top: "1/2", translateY: "-1/2", cursor: "pointer", props: { onClick: a }, children: /* @__PURE__ */ r(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
779
+ /* @__PURE__ */ n(j, { width: "fit", variant: "compact", placeholder: l.placeholder ?? "Filter...", value: r, onChange: h }),
780
+ r && /* @__PURE__ */ n(m, { position: "absolute", right: 2, top: "1/2", translateY: "-1/2", cursor: "pointer", props: { onClick: u }, children: /* @__PURE__ */ n(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
679
781
  ] });
680
782
  }
681
- function Ue({ column: s, grid: e }) {
682
- const t = e.columnFilters[s.key], i = t?.type === "number" ? t.value : "", n = t?.type === "number" ? t.operator : "eq", o = t?.type === "number" ? t.valueTo : "", [l, u] = W(i), [a, h] = W(n), [c, p] = W(o ?? ""), f = O(null), v = O(null);
683
- A(() => () => {
684
- f.current && clearTimeout(f.current), v.current && clearTimeout(v.current);
783
+ function Ke({ column: s, grid: e }) {
784
+ const t = e.columnFilters[s.key], i = t?.type === "number" ? t.value : "", r = t?.type === "number" ? t.operator : "eq", o = t?.type === "number" ? t.valueTo : "", [a, h] = M(i), [u, l] = M(r), [c, p] = M(o ?? ""), f = O(null), y = O(null);
785
+ z(() => () => {
786
+ f.current && clearTimeout(f.current), y.current && clearTimeout(y.current);
685
787
  }, []);
686
- const y = typeof s.def.filterable == "object" ? s.def.filterable : {}, R = k(
687
- (w, C, S) => {
688
- const _ = typeof C == "number" ? C : parseFloat(C);
689
- if (isNaN(_) || C === "") {
788
+ const v = typeof s.def.filterable == "object" ? s.def.filterable : {}, R = k(
789
+ (C, w, F) => {
790
+ const W = typeof w == "number" ? w : parseFloat(w);
791
+ if (isNaN(W) || w === "") {
690
792
  e.setColumnFilter(s.key, void 0);
691
793
  return;
692
794
  }
693
- const V = {
795
+ const B = {
694
796
  type: "number",
695
- operator: w,
696
- value: _
797
+ operator: C,
798
+ value: W
697
799
  };
698
- if (w === "between" && S !== void 0 && S !== "") {
699
- const I = typeof S == "number" ? S : parseFloat(String(S));
700
- isNaN(I) || (V.valueTo = I);
800
+ if (C === "between" && F !== void 0 && F !== "") {
801
+ const E = typeof F == "number" ? F : parseFloat(String(F));
802
+ isNaN(E) || (B.valueTo = E);
701
803
  }
702
- e.setColumnFilter(s.key, V);
804
+ e.setColumnFilter(s.key, B);
703
805
  },
704
806
  [e, s.key]
705
- ), F = k(
706
- (w) => {
707
- const C = w.target.value;
708
- u(C), f.current && clearTimeout(f.current), f.current = setTimeout(() => {
709
- R(a, C, c), f.current = null;
807
+ ), N = k(
808
+ (C) => {
809
+ const w = C.target.value;
810
+ h(w), f.current && clearTimeout(f.current), f.current = setTimeout(() => {
811
+ R(u, w, c), f.current = null;
710
812
  }, 300);
711
813
  },
712
- [a, c, R]
713
- ), b = k(
714
- (w) => {
715
- h(w), R(w, l, c);
814
+ [u, c, R]
815
+ ), S = k(
816
+ (C) => {
817
+ l(C), R(C, a, c);
716
818
  },
717
- [l, c, R]
819
+ [a, c, R]
718
820
  ), x = k(
719
- (w) => {
720
- const C = w.target.value;
721
- p(C), v.current && clearTimeout(v.current), v.current = setTimeout(() => {
722
- R(a, l, C), v.current = null;
821
+ (C) => {
822
+ const w = C.target.value;
823
+ p(w), y.current && clearTimeout(y.current), y.current = setTimeout(() => {
824
+ R(u, a, w), y.current = null;
723
825
  }, 300);
724
826
  },
725
- [a, l, R]
726
- ), G = k(() => {
727
- u(""), p(""), h("eq"), e.setColumnFilter(s.key, void 0);
827
+ [u, a, R]
828
+ ), L = k(() => {
829
+ h(""), p(""), l("eq"), e.setColumnFilter(s.key, void 0);
728
830
  }, [e, s.key]);
729
- return /* @__PURE__ */ d(m, { ai: a === "between" ? "start" : "center", gap: 1, width: "fit", children: [
831
+ return /* @__PURE__ */ d(m, { ai: u === "between" ? "start" : "center", gap: 1, width: "fit", children: [
730
832
  /* @__PURE__ */ d(
731
- D,
833
+ b,
732
834
  {
733
- value: a,
835
+ value: u,
734
836
  variant: "compact",
735
- onChange: (w) => w && b(w),
837
+ onChange: (C) => C && S(C),
736
838
  minWidth: 6,
737
839
  hideIcon: !0,
738
840
  children: [
739
- /* @__PURE__ */ r(D.Item, { value: "eq", children: "=" }),
740
- /* @__PURE__ */ r(D.Item, { value: "ne", children: "≠" }),
741
- /* @__PURE__ */ r(D.Item, { value: "gt", children: ">" }),
742
- /* @__PURE__ */ r(D.Item, { value: "gte", children: "≥" }),
743
- /* @__PURE__ */ r(D.Item, { value: "lt", children: "<" }),
744
- /* @__PURE__ */ r(D.Item, { value: "lte", children: "≤" }),
745
- /* @__PURE__ */ r(D.Item, { value: "between", children: "↔" })
841
+ /* @__PURE__ */ n(b.Item, { value: "eq", children: "=" }),
842
+ /* @__PURE__ */ n(b.Item, { value: "ne", children: "≠" }),
843
+ /* @__PURE__ */ n(b.Item, { value: "gt", children: ">" }),
844
+ /* @__PURE__ */ n(b.Item, { value: "gte", children: "≥" }),
845
+ /* @__PURE__ */ n(b.Item, { value: "lt", children: "<" }),
846
+ /* @__PURE__ */ n(b.Item, { value: "lte", children: "≤" }),
847
+ /* @__PURE__ */ n(b.Item, { value: "between", children: "↔" })
746
848
  ]
747
849
  }
748
850
  ),
749
- a === "between" ? /* @__PURE__ */ d(m, { d: "column", gap: 1, flex1: !0, children: [
851
+ u === "between" ? /* @__PURE__ */ d(m, { d: "column", gap: 1, flex1: !0, children: [
750
852
  /* @__PURE__ */ d(m, { ai: "center", position: "relative", flex1: !0, children: [
751
- /* @__PURE__ */ r(
853
+ /* @__PURE__ */ n(
752
854
  j,
753
855
  {
754
856
  type: "number",
755
857
  variant: "compact",
756
- placeholder: y.placeholder ?? "From",
757
- value: l,
758
- onChange: F,
858
+ placeholder: v.placeholder ?? "From",
859
+ value: a,
860
+ onChange: N,
759
861
  width: "fit",
760
- step: y.step
862
+ step: v.step
761
863
  }
762
864
  ),
763
- (l !== "" || c !== "") && /* @__PURE__ */ r(m, { position: "absolute", right: 2, top: "1/2", translateY: "-1/2", cursor: "pointer", props: { onClick: G }, children: /* @__PURE__ */ r(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
865
+ (a !== "" || c !== "") && /* @__PURE__ */ n(m, { position: "absolute", right: 2, top: "1/2", translateY: "-1/2", cursor: "pointer", props: { onClick: L }, children: /* @__PURE__ */ n(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
764
866
  ] }),
765
- /* @__PURE__ */ r(m, { ai: "center", flex1: !0, children: /* @__PURE__ */ r(
867
+ /* @__PURE__ */ n(m, { ai: "center", flex1: !0, children: /* @__PURE__ */ n(
766
868
  j,
767
869
  {
768
870
  type: "number",
@@ -771,38 +873,38 @@ function Ue({ column: s, grid: e }) {
771
873
  value: c,
772
874
  onChange: x,
773
875
  width: "fit",
774
- step: y.step
876
+ step: v.step
775
877
  }
776
878
  ) })
777
879
  ] }) : /* @__PURE__ */ d(m, { ai: "center", position: "relative", flex1: !0, children: [
778
- /* @__PURE__ */ r(
880
+ /* @__PURE__ */ n(
779
881
  j,
780
882
  {
781
883
  type: "number",
782
884
  variant: "compact",
783
- placeholder: y.placeholder ?? "Value",
784
- value: l,
785
- onChange: F,
885
+ placeholder: v.placeholder ?? "Value",
886
+ value: a,
887
+ onChange: N,
786
888
  width: "fit",
787
- step: y.step
889
+ step: v.step
788
890
  }
789
891
  ),
790
- l !== "" && /* @__PURE__ */ r(m, { position: "absolute", right: 2, top: "1/2", translateY: "-1/2", cursor: "pointer", props: { onClick: G }, children: /* @__PURE__ */ r(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
892
+ a !== "" && /* @__PURE__ */ n(m, { position: "absolute", right: 2, top: "1/2", translateY: "-1/2", cursor: "pointer", props: { onClick: L }, children: /* @__PURE__ */ n(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
791
893
  ] })
792
894
  ] });
793
895
  }
794
- function qe({ column: s, grid: e }) {
795
- const t = e.columnFilters[s.key], i = t?.type === "multiselect" ? t.values : [], n = typeof s.def.filterable == "object" ? s.def.filterable : {}, o = Y(() => n.options ? n.options : e.getColumnUniqueValues(s.key).map((a) => ({
796
- label: a === null ? "(empty)" : String(a),
797
- value: a
798
- })), [n.options, e, s.key]), l = k(
799
- (u, a) => {
800
- a.length === 0 ? e.setColumnFilter(s.key, void 0) : e.setColumnFilter(s.key, { type: "multiselect", values: a });
896
+ function Je({ column: s, grid: e }) {
897
+ const t = e.columnFilters[s.key], i = t?.type === "multiselect" ? t.values : [], r = typeof s.def.filterable == "object" ? s.def.filterable : {}, o = X(() => r.options ? r.options : e.getColumnUniqueValues(s.key).map((u) => ({
898
+ label: u === null ? "(empty)" : String(u),
899
+ value: u
900
+ })), [r.options, e, s.key]), a = k(
901
+ (h, u) => {
902
+ u.length === 0 ? e.setColumnFilter(s.key, void 0) : e.setColumnFilter(s.key, { type: "multiselect", values: u });
801
903
  },
802
904
  [e, s.key]
803
905
  );
804
906
  return /* @__PURE__ */ d(
805
- D,
907
+ b,
806
908
  {
807
909
  multiple: !0,
808
910
  showCheckbox: !0,
@@ -811,109 +913,109 @@ function qe({ column: s, grid: e }) {
811
913
  value: i,
812
914
  width: "fit",
813
915
  minWidth: 0,
814
- onChange: l,
916
+ onChange: a,
815
917
  variant: "compact",
816
918
  children: [
817
- /* @__PURE__ */ r(D.Unselect, { children: "Clear" }),
818
- /* @__PURE__ */ r(D.SelectAll, { children: "Select All" }),
819
- o.map((u) => /* @__PURE__ */ r(D.Item, { value: u.value, ai: "center", gap: 2, children: u.label }, String(u.value)))
919
+ /* @__PURE__ */ n(b.Unselect, { children: "Clear" }),
920
+ /* @__PURE__ */ n(b.SelectAll, { children: "Select All" }),
921
+ o.map((h) => /* @__PURE__ */ n(b.Item, { value: h.value, ai: "center", gap: 2, children: h.label }, String(h.value)))
820
922
  ]
821
923
  }
822
924
  );
823
925
  }
824
- function be(s) {
926
+ function xe(s) {
825
927
  const { column: e, grid: t } = s, { filterable: i } = e.def;
826
928
  if (!i) return null;
827
929
  switch ((typeof i == "object" ? i : { type: "text" }).type) {
828
930
  case "text":
829
- return /* @__PURE__ */ r(de, { column: e, grid: t });
931
+ return /* @__PURE__ */ n(pe, { column: e, grid: t });
830
932
  case "number":
831
- return /* @__PURE__ */ r(Ue, { column: e, grid: t });
933
+ return /* @__PURE__ */ n(Ke, { column: e, grid: t });
832
934
  case "multiselect":
833
- return /* @__PURE__ */ r(qe, { column: e, grid: t });
935
+ return /* @__PURE__ */ n(Je, { column: e, grid: t });
834
936
  default:
835
- return /* @__PURE__ */ r(de, { column: e, grid: t });
937
+ return /* @__PURE__ */ n(pe, { column: e, grid: t });
836
938
  }
837
939
  }
838
- be.displayName = "DataGridColumnFilter";
839
- function xe(s) {
840
- const { column: e, grid: t } = s, { key: i, pin: n, left: o, right: l, isEdge: u, widthVarName: a, leftVarName: h, rightVarName: c, filterable: p } = e, f = i === B, F = f || i === N || i === L || i === P, b = n === "LEFT", x = n === "RIGHT";
841
- return /* @__PURE__ */ r(
940
+ xe.displayName = "DataGridColumnFilter";
941
+ function Fe(s) {
942
+ const { column: e, grid: t } = s, { key: i, pin: r, left: o, right: a, isEdge: h, widthVarName: u, leftVarName: l, rightVarName: c, filterable: p } = e, f = i === V, N = f || i === T || i === G || i === _, S = r === "LEFT", x = r === "RIGHT";
943
+ return /* @__PURE__ */ n(
842
944
  m,
843
945
  {
844
946
  component: "datagrid.filter.cell",
845
- variant: { isPinned: b || x, isFirstLeftPinned: b && o === 0, isLastLeftPinned: b && u, isFirstRightPinned: x && u, isLastRightPinned: x && l === 0 },
947
+ variant: { isPinned: S || x, isFirstLeftPinned: S && o === 0, isLastLeftPinned: S && h, isFirstRightPinned: x && h, isLastRightPinned: x && a === 0 },
846
948
  px: f ? 0 : 2,
847
949
  style: {
848
- width: `var(${a})`,
849
- left: b ? `var(${h})` : void 0,
950
+ width: `var(${u})`,
951
+ left: S ? `var(${l})` : void 0,
850
952
  right: x ? `var(${c})` : void 0
851
953
  },
852
- children: !F && p && /* @__PURE__ */ r(be, { column: e, grid: t })
954
+ children: !N && p && /* @__PURE__ */ n(xe, { column: e, grid: t })
853
955
  }
854
956
  );
855
957
  }
856
- xe.displayName = "DataGridFilterCell";
857
- function Fe(s) {
958
+ Fe.displayName = "DataGridFilterCell";
959
+ function ke(s) {
858
960
  const { grid: e } = s, { visibleLeafs: t } = e.columns.value;
859
- return t.some((n) => n.filterable) ? t.map((n) => /* @__PURE__ */ r(xe, { column: n, grid: e }, n.uniqueKey)) : null;
961
+ return t.some((r) => r.filterable) ? t.map((r) => /* @__PURE__ */ n(Fe, { column: r, grid: e }, r.uniqueKey)) : null;
860
962
  }
861
- Fe.displayName = "DataGridFilterRow";
963
+ ke.displayName = "DataGridFilterRow";
862
964
  function Ge(s) {
863
- const { column: e } = s, { key: t, pin: i, left: n, right: o, isEdge: l, isLeaf: u, align: a, header: h, grid: c } = e, [p, f, v] = me({ hideOnScroll: !0, event: "mousedown" }), [y, R] = W({ top: 0, left: 0 }), F = Y(() => y.left > window.innerWidth / 2, [y.left]), b = u && (c.sortColumn !== t || c.sortDirection === "DESC"), x = u && (c.sortColumn !== t || c.sortDirection === "ASC"), G = u && c.sortColumn === t, w = i !== "LEFT", C = i !== "RIGHT", S = !!i, _ = u && t !== N, V = u && t === N, I = b || x || G, K = w || C || S, J = a === "right" ? 2 : void 0, ee = a === "right" ? void 0 : i === "RIGHT" ? 2.5 : 4, te = t === B, $ = t === L, ie = t === P, U = i === "LEFT", q = i === "RIGHT";
864
- return /* @__PURE__ */ r(m, { position: "absolute", left: J, right: ee, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ d(
865
- T,
965
+ const { column: e } = s, { key: t, pin: i, left: r, right: o, isEdge: a, isLeaf: h, align: u, header: l, grid: c } = e, [p, f, y] = Me({ hideOnScroll: !0, event: "mousedown" }), [v, R] = M({ top: 0, left: 0 }), N = X(() => v.left > window.innerWidth / 2, [v.left]), S = h && e.sortable && (c.sortColumn !== t || c.sortDirection === "DESC"), x = h && e.sortable && (c.sortColumn !== t || c.sortDirection === "ASC"), L = h && e.sortable && c.sortColumn === t, C = i !== "LEFT", w = i !== "RIGHT", F = !!i, W = h && t !== T, B = h && t === T, E = S || x || L, Y = C || w || F, ee = u === "right" ? 2 : void 0, te = u === "right" ? void 0 : i === "RIGHT" ? 2.5 : 4, K = t === V, J = t === G, ie = t === _, $ = i === "LEFT", Q = i === "RIGHT", re = $ || i === "RIGHT", Z = $ && r === 0, ne = $ && a, H = Q && a, U = Q && o === 0, Ne = h && !K && !J && !ie && e.sortable;
966
+ return /* @__PURE__ */ n(m, { position: "absolute", left: ee, right: te, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ d(
967
+ D,
866
968
  {
867
969
  component: "datagrid.header.cell.contextMenu",
868
970
  onClick: () => f(!p),
869
- variant: { isPinned: U || i === "RIGHT", isFirstLeftPinned: U && n === 0, isLastLeftPinned: U && l, isFirstRightPinned: q && l, isLastRightPinned: q && o === 0, isSortable: u && !te && !$ && !ie, isRowNumber: $ },
971
+ variant: { isPinned: re, isFirstLeftPinned: Z, isLastLeftPinned: ne, isFirstRightPinned: H, isLastRightPinned: U, isSortable: Ne, isRowNumber: J },
870
972
  children: [
871
- /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.icon", children: /* @__PURE__ */ r(Ee, { fill: "currentColor" }) }),
973
+ /* @__PURE__ */ n(I, { component: "datagrid.header.cell.contextMenu.icon", children: /* @__PURE__ */ n(He, { fill: "currentColor" }) }),
872
974
  p && /* @__PURE__ */ d(
873
- ge,
975
+ Ae,
874
976
  {
875
977
  component: "datagrid.header.cell.contextMenu.tooltip",
876
978
  onPositionChange: R,
877
- ref: v,
878
- adjustTranslateX: F ? "-100%" : "-21px",
979
+ ref: y,
980
+ adjustTranslateX: N ? "-100%" : "-21px",
879
981
  adjustTranslateY: "16px",
880
982
  children: [
881
- b && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("ASC"), children: [
882
- /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(ne, { width: "100%", fill: "currentColor" }) }),
983
+ S && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("ASC"), children: [
984
+ /* @__PURE__ */ n(I, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ n(oe, { width: "100%", fill: "currentColor" }) }),
883
985
  "Sort Ascending"
884
986
  ] }),
885
- x && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("DESC"), children: [
886
- /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(ne, { width: "100%", fill: "currentColor", rotate: 180 }) }),
987
+ x && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("DESC"), children: [
988
+ /* @__PURE__ */ n(I, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ n(oe, { width: "100%", fill: "currentColor", rotate: 180 }) }),
887
989
  "Sort Descending"
888
990
  ] }),
889
- G && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
890
- /* @__PURE__ */ r(g, { width: 4 }),
991
+ L && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
992
+ /* @__PURE__ */ n(g, { width: 4 }),
891
993
  "Clear Sort"
892
994
  ] }),
893
- I && (K || _ || V) && /* @__PURE__ */ r(g, { bb: 1, my: 2, borderColor: "gray-300", component: "datagrid.header.cell.contextMenu.tooltip.item.separator" }),
894
- w && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("LEFT"), children: [
895
- /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(le, { width: "100%", fill: "currentColor" }) }),
995
+ E && (Y || W || B) && /* @__PURE__ */ n(g, { bb: 1, my: 2, borderColor: "gray-300", component: "datagrid.header.cell.contextMenu.tooltip.item.separator" }),
996
+ C && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("LEFT"), children: [
997
+ /* @__PURE__ */ n(I, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ n(ce, { width: "100%", fill: "currentColor" }) }),
896
998
  "Pin Left"
897
999
  ] }),
898
- C && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("RIGHT"), children: [
899
- /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(le, { width: "100%", fill: "currentColor", rotate: -90 }) }),
1000
+ w && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("RIGHT"), children: [
1001
+ /* @__PURE__ */ n(I, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ n(ce, { width: "100%", fill: "currentColor", rotate: -90 }) }),
900
1002
  "Pin Right"
901
1003
  ] }),
902
- S && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
903
- /* @__PURE__ */ r(g, { width: 4 }),
1004
+ F && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
1005
+ /* @__PURE__ */ n(g, { width: 4 }),
904
1006
  "Unpin"
905
1007
  ] }),
906
- I && K && (_ || V) && /* @__PURE__ */ r(g, { component: "datagrid.header.cell.contextMenu.tooltip.item.separator" }),
907
- _ && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: e.toggleGrouping, children: [
908
- /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(re, { width: "100%", fill: "currentColor" }) }),
1008
+ E && Y && (W || B) && /* @__PURE__ */ n(g, { component: "datagrid.header.cell.contextMenu.tooltip.item.separator" }),
1009
+ W && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: e.toggleGrouping, children: [
1010
+ /* @__PURE__ */ n(I, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ n(se, { width: "100%", fill: "currentColor" }) }),
909
1011
  /* @__PURE__ */ d(g, { textWrap: "nowrap", children: [
910
1012
  "Group by ",
911
- h ?? t
1013
+ l ?? t
912
1014
  ] })
913
1015
  ] }),
914
- V && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: c.unGroupAll, children: [
915
- /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(re, { width: "100%", fill: "currentColor" }) }),
916
- /* @__PURE__ */ r(g, { textWrap: "nowrap", children: "Un-Group All" })
1016
+ B && /* @__PURE__ */ d(D, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: c.unGroupAll, children: [
1017
+ /* @__PURE__ */ n(I, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ n(se, { width: "100%", fill: "currentColor" }) }),
1018
+ /* @__PURE__ */ n(g, { textWrap: "nowrap", children: "Un-Group All" })
917
1019
  ] })
918
1020
  ]
919
1021
  }
@@ -923,9 +1025,9 @@ function Ge(s) {
923
1025
  ) });
924
1026
  }
925
1027
  Ge.displayName = "DataGridHeaderCellContextMenu";
926
- function ke(s) {
1028
+ function Se(s) {
927
1029
  const { column: e } = s;
928
- return /* @__PURE__ */ r(
1030
+ return /* @__PURE__ */ n(
929
1031
  m,
930
1032
  {
931
1033
  height: "fit",
@@ -934,7 +1036,7 @@ function ke(s) {
934
1036
  right: e.pin === "RIGHT" ? void 0 : 0,
935
1037
  left: e.pin !== "RIGHT" ? void 0 : 0,
936
1038
  py: 3,
937
- children: /* @__PURE__ */ r(
1039
+ children: /* @__PURE__ */ n(
938
1040
  g,
939
1041
  {
940
1042
  cursor: "col-resize",
@@ -943,208 +1045,295 @@ function ke(s) {
943
1045
  className: "resizer",
944
1046
  height: "fit",
945
1047
  props: { onMouseDown: e.resizeColumn, onTouchStart: e.resizeColumn },
946
- children: /* @__PURE__ */ r(g, { component: "datagrid.header.cell.resizer" })
1048
+ children: /* @__PURE__ */ n(g, { component: "datagrid.header.cell.resizer" })
947
1049
  }
948
1050
  )
949
1051
  }
950
1052
  );
951
1053
  }
952
- ke.displayName = "DataGridHeaderCellResizer";
953
- function Te(s) {
954
- const { column: e } = s, { key: t, pin: i, left: n, right: o, isEdge: l, isLeaf: u, leafs: a, grid: h, header: c, gridRows: p, widthVarName: f, leftVarName: v, rightVarName: y, inlineWidth: R } = e, F = t === B, b = t === N, x = t === L, G = t === P, w = i === "LEFT", C = i === "RIGHT", S = w || i === "RIGHT", _ = w && n === 0, V = w && l, I = C && l, K = C && o === 0, J = u && !F && !x && !G, ee = u ? 1 : a.length, te = !x && !G, $ = !x && !G, ie = G ? void 0 : e.align === "right" ? 10 : 3, U = G ? void 0 : e.align === "center" ? 3 : void 0, q = k(() => {
955
- h.toggleSelectAllRows();
956
- }, []), oe = Y(() => {
957
- if (x) return null;
958
- if (G) {
959
- const z = h.selectedRows.size === h.props.data.length, Q = !z && h.selectedRows.size > 0;
960
- return /* @__PURE__ */ r(Z, { variant: "datagrid", m: 1, indeterminate: Q, checked: z, onChange: q });
1054
+ Se.displayName = "DataGridHeaderCellResizer";
1055
+ function Le(s) {
1056
+ const { column: e } = s, {
1057
+ key: t,
1058
+ pin: i,
1059
+ left: r,
1060
+ right: o,
1061
+ isEdge: a,
1062
+ isLeaf: h,
1063
+ leafs: u,
1064
+ grid: l,
1065
+ header: c,
1066
+ gridRows: p,
1067
+ widthVarName: f,
1068
+ leftVarName: y,
1069
+ rightVarName: v,
1070
+ inlineWidth: R,
1071
+ isFirstLeaf: N,
1072
+ isLastLeaf: S
1073
+ } = e, x = t === V, L = t === T, C = t === G, w = t === _, F = i === "LEFT", W = i === "RIGHT", B = F || i === "RIGHT", E = F && r === 0, Y = F && a, ee = W && a, te = W && o === 0, K = h && !x && !C && !w && e.sortable, J = h ? 1 : u.length, ie = !C && !w && e.resizable, $ = !C && !w, Q = w ? void 0 : e.align === "right" ? 10 : 3, re = w ? void 0 : e.align === "center" ? 3 : void 0, Z = k(() => {
1074
+ l.toggleSelectAllRows();
1075
+ }, []), ne = X(() => {
1076
+ if (C) return null;
1077
+ if (w) {
1078
+ const H = l.selectedRows.size === l.props.data.length, U = !H && l.selectedRows.size > 0;
1079
+ return /* @__PURE__ */ n(le, { variant: "datagrid", m: 1, indeterminate: U, checked: H, onChange: Z });
961
1080
  }
962
- if (b) {
963
- if (h.groupColumns.size === 1) {
964
- const z = h.columns.value.leafs.findOrThrow((Q) => Q.key === h.groupColumns.values().next().value);
965
- return z.header ?? z.key;
1081
+ if (L) {
1082
+ if (l.groupColumns.size === 1) {
1083
+ const H = l.columns.value.leafs.findOrThrow((U) => U.key === l.groupColumns.values().next().value);
1084
+ return H.header ?? H.key;
966
1085
  }
967
1086
  return "Group";
968
1087
  }
969
1088
  return c ?? t;
970
- }, [h.groupColumns, h.selectedRows, q]);
971
- return /* @__PURE__ */ r(
1089
+ }, [l.groupColumns, l.selectedRows, Z]);
1090
+ return /* @__PURE__ */ n(
972
1091
  m,
973
1092
  {
974
1093
  props: { role: "columnheader" },
975
1094
  component: "datagrid.header.cell",
976
- variant: { isPinned: S, isFirstLeftPinned: _, isLastLeftPinned: V, isFirstRightPinned: I, isLastRightPinned: K, isSortable: J, isRowNumber: x },
1095
+ variant: {
1096
+ isPinned: B,
1097
+ isFirstLeftPinned: E,
1098
+ isLastLeftPinned: Y,
1099
+ isFirstRightPinned: ee,
1100
+ isLastRightPinned: te,
1101
+ isSortable: K,
1102
+ isRowNumber: C,
1103
+ isFirstLeaf: N,
1104
+ isLastLeaf: S,
1105
+ isEmptyCell: x
1106
+ },
977
1107
  gridRow: p,
978
- gridColumn: ee,
1108
+ gridColumn: J,
979
1109
  style: {
980
1110
  width: `var(${f})`,
981
- left: w ? `var(${v})` : void 0,
982
- right: C ? `var(${y})` : void 0
1111
+ left: F ? `var(${y})` : void 0,
1112
+ right: W ? `var(${v})` : void 0
983
1113
  },
984
- children: !F && /* @__PURE__ */ d(_e, { children: [
985
- /* @__PURE__ */ r(m, { width: "fit", height: "fit", jc: e.align, props: { onClick: J ? () => e.sortColumn() : void 0 }, children: /* @__PURE__ */ d(
1114
+ children: !x && /* @__PURE__ */ d(Be, { children: [
1115
+ /* @__PURE__ */ n(m, { width: "fit", height: "fit", jc: e.align, props: { onClick: K ? () => e.sortColumn() : void 0 }, children: /* @__PURE__ */ d(
986
1116
  m,
987
1117
  {
988
1118
  overflow: "hidden",
989
- position: u ? void 0 : "sticky",
1119
+ position: h ? void 0 : "sticky",
990
1120
  ai: "center",
991
1121
  transition: "none",
992
- pl: ie,
993
- pr: U,
1122
+ pl: Q,
1123
+ pr: re,
994
1124
  style: {
995
- left: i ? void 0 : `var(${h.leftEdgeVarName})`
1125
+ left: i ? void 0 : `var(${l.leftEdgeVarName})`
996
1126
  },
997
1127
  children: [
998
- /* @__PURE__ */ r(g, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: oe }),
999
- t === h.sortColumn && /* @__PURE__ */ r(g, { pl: (R ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ r(ne, { width: "16px", rotate: h.sortDirection === "ASC" ? 0 : 180, fill: "currentColor" }) }),
1000
- $ && /* @__PURE__ */ r(g, { minWidth: e.align === "right" ? 4 : 10 })
1128
+ /* @__PURE__ */ n(g, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: ne }),
1129
+ t === l.sortColumn && /* @__PURE__ */ n(g, { pl: (R ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ n(oe, { width: "16px", rotate: l.sortDirection === "ASC" ? 0 : 180, fill: "currentColor" }) }),
1130
+ $ && /* @__PURE__ */ n(g, { minWidth: e.align === "right" ? 4 : 10 })
1001
1131
  ]
1002
1132
  }
1003
1133
  ) }),
1004
- te && /* @__PURE__ */ r(ke, { column: e }),
1005
- $ && /* @__PURE__ */ r(Ge, { column: e })
1134
+ ie && /* @__PURE__ */ n(Se, { column: e }),
1135
+ $ && /* @__PURE__ */ n(Ge, { column: e })
1006
1136
  ] })
1007
1137
  }
1008
1138
  );
1009
1139
  }
1010
- Te.displayName = "DataGridHeaderCell";
1011
- function Le(s) {
1012
- const { grid: e } = s, { isResizeMode: t } = e;
1013
- return /* @__PURE__ */ d(he, { component: "datagrid.header", variant: { isResizeMode: t }, style: { gridTemplateColumns: e.gridTemplateColumns.value }, children: [
1014
- e.headerRows.value.map((i) => i.map((n) => /* @__PURE__ */ r(Te, { column: n }, n.uniqueKey))),
1015
- /* @__PURE__ */ r(Fe, { grid: e })
1140
+ Le.displayName = "DataGridHeaderCell";
1141
+ function Te(s) {
1142
+ const { grid: e } = s;
1143
+ return /* @__PURE__ */ d(me, { component: "datagrid.header", style: { gridTemplateColumns: e.gridTemplateColumns.value }, children: [
1144
+ e.headerRows.value.map((t) => t.map((i) => /* @__PURE__ */ n(Le, { column: i }, i.uniqueKey))),
1145
+ /* @__PURE__ */ n(ke, { grid: e })
1016
1146
  ] });
1017
1147
  }
1018
- Le.displayName = "DataGridHeader";
1019
- function Se(s) {
1020
- const { grid: e } = s, [t, i] = W(0), n = O(null), o = k((l) => {
1021
- n.current !== null && cancelAnimationFrame(n.current), n.current = requestAnimationFrame(() => {
1022
- i(l.target.scrollTop), n.current = null;
1148
+ Te.displayName = "DataGridHeader";
1149
+ function We(s) {
1150
+ const { grid: e } = s, [t, i] = M(0), r = O(null), o = k((h) => {
1151
+ r.current !== null && cancelAnimationFrame(r.current), r.current = requestAnimationFrame(() => {
1152
+ i(h.target.scrollTop), r.current = null;
1023
1153
  });
1024
1154
  }, []);
1025
- return /* @__PURE__ */ d(g, { overflowX: "scroll", style: { willChange: "scroll-position" }, props: { onScroll: o }, children: [
1026
- /* @__PURE__ */ r(Le, { grid: e }),
1027
- /* @__PURE__ */ r(Re, { grid: e, scrollTop: t })
1028
- ] });
1155
+ return e.columns.value.userVisibleLeafs.length > 0 ? /* @__PURE__ */ d(g, { overflowX: "scroll", style: { willChange: "scroll-position" }, props: { onScroll: o }, children: [
1156
+ /* @__PURE__ */ n(Te, { grid: e }),
1157
+ /* @__PURE__ */ n(Re, { grid: e, scrollTop: t })
1158
+ ] }) : /* @__PURE__ */ n(Ye, {});
1029
1159
  }
1030
- Se.displayName = "DataGridContent";
1160
+ We.displayName = "DataGridContent";
1031
1161
  function De(s) {
1032
1162
  const { grid: e } = s;
1033
1163
  return e.groupColumns.size === 0 ? null : /* @__PURE__ */ d(m, { component: "datagrid.topBar.columnGroups", children: [
1034
- /* @__PURE__ */ r(E, { component: "datagrid.topBar.columnGroups.icon", children: /* @__PURE__ */ r(re, { width: "100%", fill: "currentColor" }) }),
1164
+ /* @__PURE__ */ n(I, { component: "datagrid.topBar.columnGroups.icon", children: /* @__PURE__ */ n(se, { width: "100%", fill: "currentColor" }) }),
1035
1165
  Array.from(e.groupColumns, (t) => {
1036
- const i = e.columns.value.leafs.findOrThrow((n) => n.key === t);
1037
- return /* @__PURE__ */ d(Be.Fragment, { children: [
1038
- /* @__PURE__ */ r(pe, { fill: "currentColor", width: "14px", height: "14px", rotate: -90 }),
1166
+ const i = e.columns.value.leafs.findOrThrow((r) => r.key === t);
1167
+ return /* @__PURE__ */ d(Ee.Fragment, { children: [
1168
+ /* @__PURE__ */ n(ge, { fill: "currentColor", width: "14px", height: "14px", rotate: -90 }),
1039
1169
  /* @__PURE__ */ d(m, { component: "datagrid.topBar.columnGroups.item", children: [
1040
1170
  i.header ?? i.key,
1041
- /* @__PURE__ */ r(T, { component: "datagrid.topBar.columnGroups.item.icon", onClick: () => e.toggleGrouping(i.key), children: /* @__PURE__ */ r(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
1171
+ /* @__PURE__ */ n(D, { component: "datagrid.topBar.columnGroups.item.icon", onClick: () => e.toggleGrouping(i.key), children: /* @__PURE__ */ n(g, { fontSize: 10, color: "gray-400", hover: { color: "gray-600" }, children: "✕" }) })
1042
1172
  ] })
1043
1173
  ] }, t);
1044
1174
  })
1045
1175
  ] });
1046
1176
  }
1047
1177
  De.displayName = "DataGridColumnGroups";
1048
- function je(s) {
1049
- const { grid: e } = s, [t, i] = W(e.globalFilterValue), n = O(null);
1050
- A(() => () => {
1051
- n.current && clearTimeout(n.current);
1178
+ function Qe(s) {
1179
+ const { grid: e } = s, [t, i] = M(e.globalFilterValue), r = O(null);
1180
+ z(() => () => {
1181
+ r.current && clearTimeout(r.current);
1052
1182
  }, []);
1053
1183
  const o = k(
1054
1184
  (c) => {
1055
1185
  const p = c.target.value;
1056
- i(p), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
1057
- e.setGlobalFilter(p), n.current = null;
1186
+ i(p), r.current && clearTimeout(r.current), r.current = setTimeout(() => {
1187
+ e.setGlobalFilter(p), r.current = null;
1058
1188
  }, 300);
1059
1189
  },
1060
1190
  [e]
1061
- ), l = k(() => {
1191
+ ), a = k(() => {
1062
1192
  i(""), e.setGlobalFilter("");
1063
- }, [e]), { filtered: u, total: a } = e.filterStats, h = e.hasActiveFilters && u !== a;
1193
+ }, [e]), { filtered: h, total: u } = e.filterStats, l = e.hasActiveFilters && h !== u;
1064
1194
  return /* @__PURE__ */ d(m, { component: "datagrid.topBar.globalFilter", children: [
1065
- h && /* @__PURE__ */ d(g, { component: "datagrid.topBar.globalFilter.stats", children: [
1066
- u,
1067
- " / ",
1068
- a
1195
+ l && /* @__PURE__ */ d(g, { component: "datagrid.topBar.globalFilter.stats", children: [
1196
+ h,
1197
+ "/",
1198
+ u
1069
1199
  ] }),
1070
- /* @__PURE__ */ d(m, { component: "datagrid.topBar.globalFilter.inputWrapper", children: [
1071
- /* @__PURE__ */ r(m, { component: "datagrid.topBar.globalFilter.inputWrapper.icon", children: /* @__PURE__ */ r(Me, { fill: "currentColor", width: "1rem" }) }),
1072
- /* @__PURE__ */ r(
1073
- j,
1200
+ /* @__PURE__ */ d(m, { position: "relative", ai: "center", children: [
1201
+ /* @__PURE__ */ n(m, { position: "absolute", left: 3, pointerEvents: "none", color: "gray-400", theme: { dark: { color: "gray-500" } }, children: /* @__PURE__ */ n(ze, { fill: "currentColor", width: "14px" }) }),
1202
+ /* @__PURE__ */ n(j, { placeholder: "Search...", variant: "compact", value: t, onChange: o, pl: 8, pr: t ? 8 : 3 }),
1203
+ t && /* @__PURE__ */ n(
1204
+ g,
1074
1205
  {
1075
- component: "datagrid.topBar.globalFilter.inputWrapper.input",
1076
- placeholder: "Search...",
1077
- value: t,
1078
- onChange: o,
1079
- pl: 8,
1080
- pr: t ? 8 : 3,
1081
- height: 8,
1082
- width: 50
1206
+ position: "absolute",
1207
+ right: 2,
1208
+ cursor: "pointer",
1209
+ p: 1,
1210
+ color: "gray-400",
1211
+ hover: { color: "gray-600" },
1212
+ theme: { dark: { color: "gray-500", hover: { color: "gray-300" } } },
1213
+ props: { onClick: a },
1214
+ children: /* @__PURE__ */ n(g, { fontSize: 12, fontWeight: 600, children: "✕" })
1083
1215
  }
1084
- ),
1085
- t && /* @__PURE__ */ r(g, { component: "datagrid.topBar.globalFilter.inputWrapper.clear", props: { onClick: l }, children: "✕" })
1216
+ )
1086
1217
  ] })
1087
1218
  ] });
1088
1219
  }
1089
- function Ne(s) {
1090
- const { grid: e } = s, [t, i, n] = me({ event: "mousedown" }), o = Y(
1220
+ function _e(s) {
1221
+ const { grid: e } = s, i = X(
1091
1222
  () => e.columns.value.leafs.filter(
1092
- (l) => ![B, L, P, N].includes(l.key)
1223
+ (l) => ![V, G, _, T].includes(l.key)
1093
1224
  ),
1094
1225
  [e.columns.value.leafs]
1095
- );
1096
- return /* @__PURE__ */ d(T, { component: "datagrid.topBar.contextMenu", onClick: () => i(!t), children: [
1097
- /* @__PURE__ */ r(We, { viewBox: "0 0 24 24", width: "20", fill: "currentColor", ...s, children: /* @__PURE__ */ r("path", { d: "M5 6h14M5 12h14M5 18h14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }),
1098
- t && /* @__PURE__ */ r(ge, { component: "datagrid.topBar.contextMenu.tooltip", ref: n, children: o.map((l) => /* @__PURE__ */ d(
1099
- T,
1100
- {
1101
- component: "datagrid.topBar.contextMenu.tooltip.item",
1102
- onClick: (u) => {
1103
- u.stopPropagation(), l.toggleVisibility();
1104
- },
1105
- children: [
1106
- /* @__PURE__ */ r(Z, { variant: "datagrid", checked: l.isVisible, onChange: () => {
1107
- }, focus: { outline: 0 } }),
1108
- l.header ?? l.key
1109
- ]
1226
+ ).map((l) => ({
1227
+ id: String(l.key),
1228
+ label: l.header ?? l.key,
1229
+ leaf: l
1230
+ })), r = i.filter((l) => l.leaf.isVisible).map((l) => l.id), o = i.length, h = o - r.length > 0;
1231
+ return /* @__PURE__ */ d(
1232
+ b,
1233
+ {
1234
+ multiple: !0,
1235
+ showCheckbox: !0,
1236
+ hideIcon: !0,
1237
+ variant: "compact",
1238
+ value: r,
1239
+ onChange: (l, c) => {
1240
+ const p = new Set(c);
1241
+ i.forEach((f) => {
1242
+ const y = p.has(f.id);
1243
+ f.leaf.isVisible !== y && f.leaf.toggleVisibility();
1244
+ });
1110
1245
  },
1111
- l.key
1112
- )) })
1113
- ] });
1246
+ isSearchable: i.length > 6,
1247
+ searchPlaceholder: "Search columns...",
1248
+ display: "inline-flex",
1249
+ children: [
1250
+ /* @__PURE__ */ n(b.Display, { children: (l) => {
1251
+ const c = l.length === 0;
1252
+ return /* @__PURE__ */ d(m, { ai: "center", gap: 2, children: [
1253
+ /* @__PURE__ */ d(fe, { viewBox: "0 0 20 20", width: "18", height: "18", children: [
1254
+ /* @__PURE__ */ n("rect", { x: "2", y: "3", width: "4", height: "14", rx: "1", fill: "currentColor", opacity: 0.9 }),
1255
+ /* @__PURE__ */ n("rect", { x: "8", y: "3", width: "4", height: "14", rx: "1", fill: "currentColor", opacity: 0.6 }),
1256
+ /* @__PURE__ */ n("rect", { x: "14", y: "3", width: "4", height: "14", rx: "1", fill: "currentColor", opacity: 0.3 })
1257
+ ] }),
1258
+ h && /* @__PURE__ */ d(
1259
+ g,
1260
+ {
1261
+ tag: "span",
1262
+ fontSize: 11,
1263
+ lineHeight: 16,
1264
+ fontWeight: 500,
1265
+ px: 2,
1266
+ py: 0.5,
1267
+ borderRadius: 1,
1268
+ bgColor: c ? "red-100" : "amber-100",
1269
+ color: c ? "red-700" : "amber-700",
1270
+ theme: {
1271
+ dark: {
1272
+ bgColor: c ? "red-900" : "amber-900",
1273
+ color: c ? "red-300" : "amber-300"
1274
+ }
1275
+ },
1276
+ children: [
1277
+ l.length,
1278
+ "/",
1279
+ o
1280
+ ]
1281
+ }
1282
+ )
1283
+ ] });
1284
+ } }),
1285
+ /* @__PURE__ */ n(b.SelectAll, { children: "Show All" }),
1286
+ /* @__PURE__ */ n(b.Unselect, { children: "Hide All" }),
1287
+ i.map((l) => /* @__PURE__ */ n(b.Item, { value: l.id, textWrap: "nowrap", children: l.label }, l.id))
1288
+ ]
1289
+ }
1290
+ );
1114
1291
  }
1115
- Ne.displayName = "DataGridTopBarContextMenu";
1116
- function Pe(s) {
1117
- const { grid: e } = s;
1118
- return /* @__PURE__ */ d(m, { component: "datagrid.topBar", position: "relative", ai: "center", jc: "space-between", children: [
1119
- /* @__PURE__ */ d(m, { ai: "center", gap: 2, children: [
1120
- /* @__PURE__ */ r(Ne, { grid: e }),
1121
- /* @__PURE__ */ r(De, { grid: e })
1292
+ _e.displayName = "DataGridTopBarContextMenu";
1293
+ function Ve(s) {
1294
+ const { grid: e } = s, { title: t, topBarContent: i, globalFilter: r } = e.props.def;
1295
+ return /* @__PURE__ */ d(m, { component: "datagrid.topBar", position: "relative", ai: "center", jc: "space-between", gap: 4, flexWrap: "wrap", children: [
1296
+ /* @__PURE__ */ d(m, { ai: "center", gap: 3, flexWrap: "wrap", minWidth: 0, children: [
1297
+ /* @__PURE__ */ n(_e, { grid: e }),
1298
+ t && /* @__PURE__ */ n(g, { fontWeight: 600, fontSize: 16, color: "gray-800", theme: { dark: { color: "gray-100" } }, children: t }),
1299
+ /* @__PURE__ */ n(De, { grid: e })
1122
1300
  ] }),
1123
- e.props.def.globalFilter && /* @__PURE__ */ r(m, { position: "relative", pr: 2, children: /* @__PURE__ */ r(je, { grid: e }) })
1301
+ /* @__PURE__ */ d(m, { ai: "center", gap: 3, flexWrap: "wrap", jc: "flex-end", minWidth: 0, children: [
1302
+ i && /* @__PURE__ */ n(g, { children: i }),
1303
+ r && /* @__PURE__ */ n(Qe, { grid: e })
1304
+ ] })
1124
1305
  ] });
1125
1306
  }
1126
- Pe.displayName = "DataGridTopBar";
1127
- function Xe(s) {
1128
- const [e, t] = W(0), i = O();
1129
- return i.current || (i.current = new ze(s, () => t((n) => n + 1))), A(() => {
1307
+ Ve.displayName = "DataGridTopBar";
1308
+ function Ze(s) {
1309
+ const [e, t] = M(0), i = O();
1310
+ return i.current || (i.current = new je(s, () => t((r) => r + 1))), z(() => {
1130
1311
  i.current.props = s, i.current.rows.clear(), i.current.flatRows.clear(), i.current.update();
1131
- }, [s.data]), A(() => {
1312
+ }, [s.data]), z(() => {
1132
1313
  i.current.props = s, i.current.sourceColumns.clear(), i.current.columns.clear(), i.current.headerRows.clear(), i.current.gridTemplateColumns.clear(), i.current.rows.clear(), i.current.flatRows.clear(), i.current.sizes.clear(), i.current.update();
1133
- }, [s.def]), A(() => {
1314
+ }, [s.def]), z(() => {
1134
1315
  i.current.props = s, i.current.update();
1135
- }, [s.loading]), A(() => {
1316
+ }, [s.loading]), z(() => {
1136
1317
  i.current.props = s, i.current.rows.clear(), i.current.flatRows.clear(), i.current.update();
1137
1318
  }, [s.globalFilterValue, s.columnFilters]), i.current;
1138
1319
  }
1139
- function Ye(s) {
1140
- const e = Xe(s);
1141
- return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render"), /* @__PURE__ */ d(g, { component: "datagrid", style: e.sizes.value, props: { role: "presentation" }, children: [
1142
- e.props.def.topBar && /* @__PURE__ */ r(Pe, { grid: e }),
1143
- /* @__PURE__ */ r(Se, { grid: e }),
1144
- e.props.def.bottomBar && /* @__PURE__ */ r(Ie, { grid: e })
1320
+ function et(s) {
1321
+ const e = Ze(s), t = O(null);
1322
+ return Pe(() => {
1323
+ const i = t.current;
1324
+ if (!i) return;
1325
+ const r = new ResizeObserver((o) => {
1326
+ const a = o[0]?.contentRect.width ?? 0;
1327
+ e.setContainerWidth(a);
1328
+ });
1329
+ return r.observe(i), () => r.disconnect();
1330
+ }, [e]), console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render"), /* @__PURE__ */ d(g, { ref: t, component: "datagrid", style: e.sizes.value, props: { role: "presentation" }, children: [
1331
+ e.props.def.topBar && /* @__PURE__ */ n(Ve, { grid: e }),
1332
+ /* @__PURE__ */ n(We, { grid: e }),
1333
+ e.props.def.bottomBar && /* @__PURE__ */ n(Oe, { grid: e })
1145
1334
  ] });
1146
1335
  }
1147
- Ye.displayName = "DataGrid";
1336
+ et.displayName = "DataGrid";
1148
1337
  export {
1149
- Ye as default
1338
+ et as default
1150
1339
  };