@cronocode/react-box 3.1.3 → 3.1.6

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,38 +1,41 @@
1
- import { jsxs as h, jsx as s, Fragment as ke } from "react/jsx-runtime";
2
- import p from "../box.mjs";
3
- import g from "./flex.mjs";
4
- import Te, { useCallback as X, useMemo as j, useState as te, useRef as De, useEffect as Q } from "react";
5
- import { F as le, m as P, E as ae, b as de, D as Se, S as Z, P as ne, G as ee, C as _e } from "../core.mjs";
6
- import ce from "./grid.mjs";
7
- import q from "./checkbox.mjs";
8
- import w from "./button.mjs";
9
- import { Span as D } from "./semantics.mjs";
10
- import he from "./tooltip.mjs";
11
- import Be from "./baseSvg.mjs";
12
- function Pe(l) {
13
- const { grid: e } = l;
14
- return /* @__PURE__ */ h(g, { component: "datagrid.bottomBar", children: [
15
- /* @__PURE__ */ h(p, { children: [
1
+ import { jsxs as d, jsx as r, Fragment as _e } from "react/jsx-runtime";
2
+ import g from "../box.mjs";
3
+ 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";
10
+ 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;
16
+ return /* @__PURE__ */ d(m, { component: "datagrid.bottomBar", children: [
17
+ /* @__PURE__ */ d(g, { children: [
16
18
  "Rows: ",
17
- e.props.data.length
19
+ n ? `${t} / ${i}` : i
18
20
  ] }),
19
- e.props.def.rowSelection && /* @__PURE__ */ h(p, { children: [
21
+ e.props.def.rowSelection && /* @__PURE__ */ d(g, { children: [
20
22
  "Selected: ",
21
23
  e.selectedRows.size
22
- ] })
24
+ ] }),
25
+ n && /* @__PURE__ */ r(g, { color: "blue-600", cursor: "pointer", hover: { textDecoration: "underline" }, props: { onClick: e.clearAllFilters }, children: "Clear filters" })
23
26
  ] });
24
27
  }
25
- function ue(l) {
26
- const { cell: e } = l, t = X(() => {
28
+ function fe(s) {
29
+ const { cell: e } = s, t = k(() => {
27
30
  e.grid.toggleRowSelection(e.row.key);
28
31
  }, [e.grid, e.row.key]);
29
- return /* @__PURE__ */ s(q, { variant: "datagrid", checked: e.row.selected, onChange: t });
32
+ return /* @__PURE__ */ r(Z, { variant: "datagrid", checked: e.row.selected, onChange: t });
30
33
  }
31
- ue.displayName = "DataGridCellRowSelection";
32
- const Ee = "NO_PIN";
33
- class S {
34
+ fe.displayName = "DataGridCellRowSelection";
35
+ const He = "NO_PIN";
36
+ class M {
34
37
  constructor(e, t, i) {
35
- this.def = e, this.grid = t, this.parent = i, this.columns = e.columns?.map((n) => new S(e.pin ? { ...n, pin: e.pin } : n, t, this)) ?? [], this.isLeaf && (this._inlineWidth = this.key == E ? void 0 : this.def.width ?? this.grid.DEFAULT_COLUMN_WIDTH_PX, this._pin = e.pin);
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);
36
39
  }
37
40
  columns = [];
38
41
  get visibleColumns() {
@@ -53,6 +56,9 @@ class S {
53
56
  get Cell() {
54
57
  return this.def.Cell;
55
58
  }
59
+ get filterable() {
60
+ return this.def.filterable;
61
+ }
56
62
  _pin;
57
63
  get pin() {
58
64
  if (this.isLeaf) return this._pin;
@@ -65,7 +71,7 @@ class S {
65
71
  getPinnedColumn(e) {
66
72
  if (this.hasPin(e)) {
67
73
  if (this.isLeaf) return this;
68
- const t = new S({ ...this.def, pin: e }, this.grid, this.parent);
74
+ const t = new M({ ...this.def, pin: e }, this.grid, this.parent);
69
75
  return t.columns = this.columns.filter((i) => i.hasPin(e)).map((i) => {
70
76
  const n = i.getPinnedColumn(e);
71
77
  return n.parent = t, n;
@@ -93,7 +99,7 @@ class S {
93
99
  let e = 0;
94
100
  if (this.parent) {
95
101
  const { visibleColumns: t, left: i } = this.parent, n = t.findIndex((o) => o === this);
96
- e += t.sumBy((o, r) => r < n ? o.inlineWidth ?? 0 : 0), e += i;
102
+ e += t.sumBy((o, l) => l < n ? o.inlineWidth ?? 0 : 0), e += i;
97
103
  } else {
98
104
  const t = this.grid.columns.value.left.filter((n) => n.isVisible), i = t.findIndex((n) => n === this);
99
105
  e += t.sumBy((n, o) => o < i ? n.inlineWidth ?? 0 : 0);
@@ -104,10 +110,10 @@ class S {
104
110
  let e = 0;
105
111
  if (this.parent) {
106
112
  const { visibleColumns: t } = this.parent, i = t.reverse(), n = i.findIndex((o) => o === this);
107
- e += i.sumBy((o, r) => r < n ? o.inlineWidth ?? 0 : 0), e += this.parent.right;
113
+ e += i.sumBy((o, l) => l < n ? o.inlineWidth ?? 0 : 0), e += this.parent.right;
108
114
  } else {
109
115
  const i = this.grid.columns.value.right.filter((o) => o.isVisible).reverse(), n = i.findIndex((o) => o === this);
110
- e += i.sumBy((o, r) => r < n ? o.inlineWidth ?? 0 : 0);
116
+ e += i.sumBy((o, l) => l < n ? o.inlineWidth ?? 0 : 0);
111
117
  }
112
118
  return e;
113
119
  }
@@ -143,16 +149,16 @@ class S {
143
149
  }
144
150
  resizeColumn = (e) => {
145
151
  this.grid.isResizeMode = !0;
146
- const t = e.pageX, { MIN_COLUMN_WIDTH_PX: i, update: n } = this.grid, o = this.leafs.sumBy((d) => d.inlineWidth) - this.leafs.length * i, r = this.leafs.toRecord((d) => [d.key, d.inlineWidth]), u = le.throttle((d) => {
147
- const m = (d.pageX - t) * (this.pin === "RIGHT" ? -1 : 1);
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) => {
153
+ const p = (c.pageX - t) * (this.pin === "RIGHT" ? -1 : 1);
148
154
  this.leafs.forEach((f) => {
149
- const R = r[f.key], y = o > 0 ? (R - i) / o * m : m / this.leafs.length, k = Math.round(R + y);
150
- f.setWidth(k < i ? i : k);
155
+ const v = l[f.key], y = o > 0 ? (v - i) / o * p : p / this.leafs.length, R = Math.round(v + y);
156
+ f.setWidth(R < i ? i : R);
151
157
  }), this.grid.sizes.clear(), n();
152
- }, 40), a = new AbortController(), c = (d) => {
158
+ }, 40), a = new AbortController(), h = (c) => {
153
159
  a.abort(), this.grid.isResizeMode = !1, n();
154
160
  };
155
- window.addEventListener("mousemove", u, a), window.addEventListener("mouseup", c, a);
161
+ window.addEventListener("mousemove", u, a), window.addEventListener("mouseup", h, a);
156
162
  };
157
163
  pinColumn = (e) => {
158
164
  this.isLeaf ? this._pin = e : this.columns.forEach((t) => t.pinColumn(e)), this.grid.pinColumn(this.uniqueKey, e);
@@ -172,15 +178,15 @@ class S {
172
178
  this.grid.toggleColumnVisibility(this.key);
173
179
  };
174
180
  }
175
- class Me {
181
+ class Ae {
176
182
  constructor(e, t, i) {
177
183
  this.grid = e, this.row = t, this.column = i;
178
184
  }
179
185
  get value() {
180
- return this.column.key === C ? this.row.rowIndex + 1 : this.row.data[this.column.key];
186
+ return this.column.key === L ? this.row.rowIndex + 1 : this.row.data[this.column.key];
181
187
  }
182
188
  }
183
- class oe {
189
+ class ae {
184
190
  constructor(e, t, i) {
185
191
  this.grid = e, this.data = t, this.rowIndex = i, this.grid = e, this.data = t, this.key = this.grid.getRowKey(t);
186
192
  }
@@ -188,7 +194,7 @@ class oe {
188
194
  parentRow;
189
195
  count = 1;
190
196
  get cells() {
191
- return this.grid.columns.value.visibleLeafs.map((e) => new Me(this.grid, this, e));
197
+ return this.grid.columns.value.visibleLeafs.map((e) => new Ae(this.grid, this, e));
192
198
  }
193
199
  get selected() {
194
200
  return this.grid.selectedRows.has(this.key);
@@ -200,89 +206,217 @@ class oe {
200
206
  return this;
201
207
  }
202
208
  }
203
- const E = "empty-cell", C = "row-number-cell", se = 70, _ = "row-selection-cell", x = "grouping-cell";
204
- class Ne {
209
+ const B = "empty-cell", L = "row-number-cell", ce = 70, P = "row-selection-cell", N = "grouping-cell";
210
+ class ze {
205
211
  constructor(e, t) {
206
212
  this.props = e, this.update = t, console.debug("\x1B[32m%s\x1B[0m", "[react-box]: DataGrid GridModel ctor");
207
213
  }
208
- sourceColumns = P(() => {
214
+ sourceColumns = H(() => {
209
215
  const { def: e } = this.props, t = [];
210
- if (this.groupColumns.size > 0 && t.push(new S({ key: x }, this)), t.push(...e.columns.map((i) => new S(i, this))), t.push(new S({ key: E, Cell: () => null }, this)), e.rowSelection) {
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) {
211
217
  const i = typeof e.rowSelection == "object" && e.rowSelection.pinned ? "LEFT" : void 0;
212
218
  t.unshift(
213
- new S({ key: _, pin: i, width: 50, align: "center", Cell: ue }, this)
219
+ new M({ key: P, pin: i, width: 50, align: "center", Cell: fe }, this)
214
220
  );
215
221
  }
216
222
  if (e.showRowNumber) {
217
- let i, n = se;
218
- typeof e.showRowNumber == "object" && (e.showRowNumber.pinned && (i = "LEFT"), n = e.showRowNumber.width ?? se), t.unshift(new S({ key: C, pin: i, width: n, align: "right" }, this));
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));
219
225
  }
220
226
  return t;
221
227
  });
222
- columns = P(() => {
228
+ columns = H(() => {
223
229
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid columns memo");
224
- 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), r = n.filter((a) => a.isLeaf && a.isVisible), u = n.maxBy((a) => a.death) + 1;
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;
225
231
  return {
226
232
  left: e,
227
233
  middle: t,
228
234
  right: i,
229
235
  flat: n,
230
236
  leafs: o,
231
- visibleLeafs: r,
237
+ visibleLeafs: l,
232
238
  maxDeath: u
233
239
  };
234
240
  });
235
- 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) => {
236
- const i = t.values.groupBy((n) => n.pin ?? Ee).toRecord((n) => [n.key, n.values]);
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]);
237
243
  return [
238
244
  ...i.LEFT?.filter((n) => n.isVisible) ?? [],
239
245
  ...i.NO_PIN?.filter((n) => n.isVisible) ?? [],
240
246
  ...i.RIGHT?.filter((n) => n.isVisible) ?? []
241
247
  ];
242
248
  })));
243
- gridTemplateColumns = P(() => {
249
+ gridTemplateColumns = H(() => {
244
250
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid gridTemplateColumns memo");
245
- const { visibleLeafs: e } = this.columns.value, t = e.sumBy((r) => r.pin === "RIGHT" ? 1 : 0), i = e.length - t - 1, n = i > 0 ? `repeat(${i}, max-content)` : "", o = t > 0 ? `repeat(${t}, max-content)` : "";
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)` : "";
246
252
  return `${n} auto ${o}`;
247
253
  });
248
- rows = P(() => {
249
- console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid rows memo");
254
+ // ========== Filtering ==========
255
+ _globalFilterValue = "";
256
+ get globalFilterValue() {
257
+ return this.props.globalFilterValue ?? this._globalFilterValue;
258
+ }
259
+ _columnFilters = {};
260
+ get columnFilters() {
261
+ return this.props.columnFilters ?? this._columnFilters;
262
+ }
263
+ /**
264
+ * Apply global filter (fuzzy search across all or specified columns)
265
+ */
266
+ applyGlobalFilter(e) {
267
+ const t = this.globalFilterValue.trim();
268
+ 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
271
+ ).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));
275
+ }));
276
+ }
277
+ /**
278
+ * Apply column-level filters
279
+ */
280
+ applyColumnFilters(e) {
281
+ 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);
287
+ }));
288
+ }
289
+ /**
290
+ * Check if a cell value matches a filter
291
+ */
292
+ matchesFilter(e, t) {
293
+ switch (t.type) {
294
+ case "text":
295
+ return t.value.trim() ? e == null ? !1 : se(t.value, String(e)) : !0;
296
+ case "number": {
297
+ if (e == null) return !1;
298
+ const i = typeof e == "number" ? e : parseFloat(String(e));
299
+ if (isNaN(i)) return !1;
300
+ switch (t.operator) {
301
+ case "eq":
302
+ return i === t.value;
303
+ case "ne":
304
+ return i !== t.value;
305
+ case "gt":
306
+ return i > t.value;
307
+ case "gte":
308
+ return i >= t.value;
309
+ case "lt":
310
+ return i < t.value;
311
+ case "lte":
312
+ return i <= t.value;
313
+ case "between":
314
+ return t.valueTo !== void 0 ? i >= t.value && i <= t.valueTo : i >= t.value;
315
+ default:
316
+ return !0;
317
+ }
318
+ }
319
+ case "multiselect":
320
+ return t.values.length === 0 ? !0 : t.values.includes(e);
321
+ default:
322
+ return !0;
323
+ }
324
+ }
325
+ /**
326
+ * Get filtered data (applies global filter then column filters)
327
+ */
328
+ get filteredData() {
250
329
  let e = this.props.data;
330
+ return this.props.def.globalFilter && (e = this.applyGlobalFilter(e)), e = this.applyColumnFilters(e), e;
331
+ }
332
+ /**
333
+ * Set global filter value
334
+ */
335
+ setGlobalFilter = (e) => {
336
+ this.props.onGlobalFilterChange ? this.props.onGlobalFilterChange(e) : this._globalFilterValue = e, this.rows.clear(), this.flatRows.clear(), this.update();
337
+ };
338
+ /**
339
+ * Set a single column filter
340
+ */
341
+ setColumnFilter = (e, t) => {
342
+ const i = { ...this.columnFilters };
343
+ t === void 0 ? delete i[e] : i[e] = t, this.props.onColumnFiltersChange ? this.props.onColumnFiltersChange(i) : this._columnFilters = i, this.rows.clear(), this.flatRows.clear(), this.update();
344
+ };
345
+ /**
346
+ * Clear all column filters
347
+ */
348
+ clearColumnFilters = () => {
349
+ this.props.onColumnFiltersChange ? this.props.onColumnFiltersChange({}) : this._columnFilters = {}, this.rows.clear(), this.flatRows.clear(), this.update();
350
+ };
351
+ /**
352
+ * Clear all filters (global + column)
353
+ */
354
+ clearAllFilters = () => {
355
+ this.setGlobalFilter(""), this.clearColumnFilters();
356
+ };
357
+ /**
358
+ * Get unique values for a column (used for multiselect filter options)
359
+ */
360
+ getColumnUniqueValues = (e) => {
361
+ const t = /* @__PURE__ */ new Set();
362
+ 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)));
366
+ };
367
+ /**
368
+ * Check if any filter is active
369
+ */
370
+ get hasActiveFilters() {
371
+ return this.globalFilterValue.trim() !== "" || Object.keys(this.columnFilters).length > 0;
372
+ }
373
+ /**
374
+ * Get count of filtered rows vs total rows
375
+ */
376
+ get filterStats() {
377
+ return {
378
+ filtered: this.filteredData.length,
379
+ total: this.props.data.length
380
+ };
381
+ }
382
+ rows = H(() => {
383
+ console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid rows memo");
384
+ let e = this.filteredData;
251
385
  if (this._sortColumn && (e = e.sortBy((t) => t[this._sortColumn], this._sortDirection)), this.groupColumns.size > 0) {
252
386
  const t = (i, n, o) => {
253
- const r = n.values().next().value;
254
- n.delete(r);
255
- const u = this.columns.value.leafs.findOrThrow((a) => a.key === r);
256
- return this._sortColumn === x && (i = i.sortBy((a) => a[r], this._sortDirection)), i.groupBy((a) => a[r]).map((a) => {
257
- let c;
258
- n.size > 0 ? c = t(a.values, new Set(n), o + 1) : c = a.values.map((m, f) => new oe(this, m, o + 1 + f));
259
- const d = new me(this, u, c, o, a.key);
260
- return o += 1, d.expanded && (o += c.length), d;
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;
261
395
  });
262
396
  };
263
397
  return t(e, new Set(this.groupColumns), 0);
264
398
  }
265
- return e.map((t, i) => new oe(this, t, i));
399
+ return e.map((t, i) => new ae(this, t, i));
266
400
  });
267
- flatRows = P(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid flatRows memo"), this.rows.value.flatMap((e) => e.flatRows)));
401
+ flatRows = H(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid flatRows memo"), this.rows.value.flatMap((e) => e.flatRows)));
268
402
  get rowHeight() {
269
403
  return this.props.def.rowHeight ?? this.DEFAULT_ROW_HEIGHT_PX;
270
404
  }
271
- sizes = P(() => {
405
+ sizes = H(() => {
272
406
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid sizes memo");
273
407
  const e = this.columns.value.flat.reduce((n, o) => {
274
- const { inlineWidth: r } = o;
275
- return typeof r == "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;
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;
276
410
  }, {});
277
411
  e[this.rowHeightVarName] = `${this.rowHeight}px`, e[this.leftEdgeVarName] = `${this.leftEdge}px`;
278
- const { visibleLeafs: t } = this.columns.value, i = t.find((n) => n.key === x);
412
+ const { visibleLeafs: t } = this.columns.value, i = t.find((n) => n.key === N);
279
413
  if (i) {
280
- const n = t.sumBy((o) => o.pin === i.pin && o.key !== C && o.key !== _ ? o.inlineWidth ?? 0 : 0);
414
+ const n = t.sumBy((o) => o.pin === i.pin && o.key !== L && o.key !== P ? o.inlineWidth ?? 0 : 0);
281
415
  e[i.groupColumnWidthVarName] = `${n}px`;
282
416
  }
283
417
  return this.groupColumns.forEach((n) => {
284
- const o = this.columns.value.leafs.findOrThrow((r) => r.key === n);
285
- e[o.groupColumnWidthVarName] = `${t.sumBy((r) => r.pin === o.pin ? r.inlineWidth ?? 0 : 0)}px`;
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`;
286
420
  }), e;
287
421
  });
288
422
  DEFAULT_ROW_HEIGHT_PX = 48;
@@ -321,7 +455,8 @@ class Ne {
321
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();
322
456
  };
323
457
  unGroupAll = () => {
324
- this.groupColumns = /* @__PURE__ */ new Set(), this.sourceColumns.clear(), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
458
+ 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();
325
460
  };
326
461
  toggleGroupRow = (e) => {
327
462
  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();
@@ -362,24 +497,24 @@ class Ne {
362
497
  return this._sortDirection;
363
498
  }
364
499
  }
365
- class We {
500
+ class Oe {
366
501
  constructor(e, t, i) {
367
502
  this.grid = e, this.row = t, this.column = i;
368
503
  }
369
504
  get value() {
370
- return this.column.key === C ? this.row.rowIndex + 1 : this.column.key === x ? `${this.row.groupValue} (${this.row.count})` : null;
505
+ return this.column.key === L ? this.row.rowIndex + 1 : this.column.key === N ? `${this.row.groupValue} (${this.row.count})` : null;
371
506
  }
372
507
  }
373
- class me {
508
+ class we {
374
509
  constructor(e, t, i, n, o) {
375
- this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = n, this.groupValue = o, i.forEach((r) => r.parentRow = this);
510
+ this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = n, this.groupValue = o, i.forEach((l) => l.parentRow = this);
376
511
  }
377
512
  get key() {
378
513
  return `${this.parentRow?.key ?? ""}${this.groupColumn.key}${this.groupValue}`;
379
514
  }
380
515
  parentRow;
381
516
  get cells() {
382
- return this.grid.columns.value.visibleLeafs.map((e) => new We(this.grid, this, e));
517
+ return this.grid.columns.value.visibleLeafs.map((e) => new Oe(this.grid, this, e));
383
518
  }
384
519
  get selected() {
385
520
  return this.allRows.every((e) => e.selected);
@@ -403,41 +538,41 @@ class me {
403
538
  return this.rows.flatMap((e) => e.allRows);
404
539
  }
405
540
  get groupingColumn() {
406
- return this.grid.columns.value.leafs.findOrThrow((e) => e.key === x);
541
+ return this.grid.columns.value.leafs.findOrThrow((e) => e.key === N);
407
542
  }
408
543
  get groupingColumnGridColumn() {
409
544
  const { visibleLeafs: e } = this.grid.columns.value, { groupingColumn: t } = this;
410
545
  return e.sumBy(
411
- (n) => n.pin === t.pin && n.key !== E && n.key !== _ && n.key !== C ? 1 : 0
546
+ (n) => n.pin === t.pin && n.key !== B && n.key !== P && n.key !== L ? 1 : 0
412
547
  );
413
548
  }
414
549
  toggleRow() {
415
550
  this.grid.toggleGroupRow(this.key);
416
551
  }
417
552
  }
418
- function A(l) {
419
- const { children: e, column: t, style: i, ...n } = l, { key: o, pin: r, left: u, right: a, isEdge: c, align: d, widthVarName: m, leftVarName: f, rightVarName: R } = t;
420
- "align" in t.def && (n.jc = d);
421
- const y = o === C, k = o === _, G = r === "LEFT", b = r === "RIGHT";
422
- return /* @__PURE__ */ s(
423
- g,
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(
558
+ m,
424
559
  {
425
560
  component: "datagrid.body.cell",
426
561
  props: { role: "cell" },
427
562
  variant: {
428
- isPinned: G || b,
429
- isFirstLeftPinned: G && u === 0,
430
- isLastLeftPinned: G && c,
431
- isFirstRightPinned: b && c,
563
+ isPinned: F || b,
564
+ isFirstLeftPinned: F && u === 0,
565
+ isLastLeftPinned: F && h,
566
+ isFirstRightPinned: b && h,
432
567
  isLastRightPinned: b && a === 0,
433
- isRowSelection: k,
568
+ isRowSelection: R,
434
569
  isRowNumber: y
435
570
  },
436
571
  style: {
437
- width: `var(${m})`,
572
+ width: `var(${p})`,
438
573
  height: `var(${t.grid.rowHeightVarName})`,
439
- left: G ? `var(${f})` : void 0,
440
- right: b ? `var(${R})` : void 0,
574
+ left: F ? `var(${f})` : void 0,
575
+ right: b ? `var(${v})` : void 0,
441
576
  ...i
442
577
  },
443
578
  ...n,
@@ -445,73 +580,74 @@ function A(l) {
445
580
  }
446
581
  );
447
582
  }
448
- A.displayName = "DataGridCell";
449
- function pe(l) {
450
- const { row: e } = l, { selected: t, indeterminate: i, cells: n, groupingColumn: o, groupingColumnGridColumn: r, depth: u, expanded: a } = e, c = X(() => {
451
- e.grid.toggleRowsSelection(e.allRows.map((d) => d.key));
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(() => {
586
+ e.grid.toggleRowsSelection(e.allRows.map((c) => c.key));
452
587
  }, []);
453
- return /* @__PURE__ */ s(g, { className: "grid-row", selected: t, display: "contents", props: { role: "rowgroup" }, children: n.map((d) => {
454
- const { key: m, pin: f, groupColumnWidthVarName: R } = d.column, y = f === "RIGHT";
455
- if (m === x)
456
- return /* @__PURE__ */ s(
457
- A,
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,
458
593
  {
459
- column: d.column,
594
+ column: c.column,
460
595
  style: {
461
- width: `var(${R})`,
596
+ width: `var(${v})`,
462
597
  right: y ? "0" : void 0
463
598
  },
464
599
  br: o.pin === "LEFT" ? 1 : void 0,
465
- gridColumn: r,
600
+ gridColumn: l,
466
601
  pl: 4 * u,
467
602
  overflow: "auto",
468
- children: /* @__PURE__ */ s(p, { textWrap: "nowrap", px: 3, children: /* @__PURE__ */ h(w, { clean: !0, onClick: () => e.toggleRow(), cursor: "pointer", display: "flex", gap: 1, ai: "center", children: [
469
- /* @__PURE__ */ s(ae, { fill: "currentColor", width: "14px", height: "14px", rotate: a ? 0 : -90 }),
470
- d.value
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 }),
605
+ c.value
471
606
  ] }) })
472
607
  },
473
- m
608
+ p
474
609
  );
475
- if (m === _)
476
- return /* @__PURE__ */ s(A, { column: d.column, children: /* @__PURE__ */ s(q, { variant: "datagrid", m: 1, checked: t, indeterminate: i, onChange: c }) }, m);
477
- if (f !== o.pin || m === C || m === E)
478
- return /* @__PURE__ */ s(A, { column: d.column, px: m === C ? 3 : void 0, children: d.value }, m);
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);
479
614
  }) });
480
615
  }
481
- pe.displayName = "DataGridGroupRow";
482
- function ge(l) {
483
- const { cell: e } = l;
484
- return /* @__PURE__ */ s(g, { height: "fit", width: "fit", overflow: "auto", ai: "center", jc: e.column.align, children: /* @__PURE__ */ s(p, { px: 3, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: e.value }) });
616
+ Ce.displayName = "DataGridGroupRow";
617
+ function ve(s) {
618
+ 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 }) });
485
620
  }
486
- ge.displayName = "DataGridCellText";
487
- function fe(l) {
488
- const { row: e } = l, { selected: t } = e;
489
- return /* @__PURE__ */ s(g, { className: "grid-row", selected: t, display: "contents", props: { role: "row" }, children: e.cells.map((i) => /* @__PURE__ */ s(A, { column: i.column, children: i.column.Cell ? /* @__PURE__ */ s(i.column.Cell, { cell: i }) : /* @__PURE__ */ s(ge, { cell: i }) }, i.column.key)) });
621
+ ve.displayName = "DataGridCellText";
622
+ function ye(s) {
623
+ 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)) });
490
625
  }
491
- fe.displayName = "DataGridRow";
492
- const He = 10, re = 20;
493
- function we(l) {
494
- const { grid: e, scrollTop: t } = l, i = e.flatRows.value.length, n = Math.max(0, Math.floor(t / e.rowHeight) - re), o = e.props.def.visibleRowsCount ?? He, r = e.rowHeight * o + e.rowHeight / 5, u = j(() => {
626
+ ye.displayName = "DataGridRow";
627
+ const $e = 10, ue = 20;
628
+ 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(() => {
495
630
  if (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render rows"), e.props.data.length === 0)
496
- return /* @__PURE__ */ s(g, { jc: "center", ai: "center", gridColumn: "full-row", style: { height: r }, children: e.props.loading ? "loading..." : "empty" });
497
- const a = o + re * 2;
498
- return e.flatRows.value.take(a, n).map((d) => d instanceof me ? /* @__PURE__ */ s(pe, { row: d }, d.key) : /* @__PURE__ */ s(fe, { row: d }, d.key));
499
- }, [e.flatRows.value, e.props.data.length, e.props.loading, n, r, o]);
500
- return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render DataGridBody"), /* @__PURE__ */ s(p, { style: { height: r }, children: /* @__PURE__ */ s(
501
- p,
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(
636
+ g,
502
637
  {
503
638
  style: {
504
639
  height: `${i * e.rowHeight}px`
505
640
  },
506
- children: /* @__PURE__ */ s(
507
- ce,
641
+ children: /* @__PURE__ */ r(
642
+ he,
508
643
  {
509
644
  component: "datagrid.body",
510
645
  width: "max-content",
511
646
  minWidth: "fit",
512
647
  transition: "none",
513
648
  style: {
514
- transform: `translateY(${n * e.rowHeight}px)`,
649
+ transform: `translate3d(0, ${n * e.rowHeight}px, 0)`,
650
+ willChange: "transform",
515
651
  gridTemplateColumns: e.gridTemplateColumns.value
516
652
  },
517
653
  children: u
@@ -520,61 +656,264 @@ function we(l) {
520
656
  }
521
657
  ) });
522
658
  }
523
- we.displayName = "DataGridBody";
524
- function Ce(l) {
525
- const { column: e } = l, { key: t, pin: i, left: n, right: o, isEdge: r, isLeaf: u, align: a, header: c, grid: d } = e, [m, f, R] = de({ hideOnScroll: !0, event: "mousedown" }), [y, k] = te({ top: 0, left: 0 }), G = j(() => y.left > window.innerWidth / 2, [y.left]), b = u && (d.sortColumn !== t || d.sortDirection === "DESC"), L = u && (d.sortColumn !== t || d.sortDirection === "ASC"), v = u && d.sortColumn === t, T = i !== "LEFT", B = i !== "RIGHT", N = !!i, W = u && t !== x, H = u && t === x, F = b || L || v, O = T || B || N, $ = a === "right" ? 2 : void 0, Y = a === "right" ? void 0 : i === "RIGHT" ? 2.5 : 4, K = t === E, I = t === C, J = t === _, V = i === "LEFT", z = i === "RIGHT";
526
- return /* @__PURE__ */ s(g, { position: "absolute", left: $, right: Y, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ h(
527
- w,
659
+ 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);
664
+ }, []);
665
+ const u = k(
666
+ (c) => {
667
+ 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;
670
+ }, 300);
671
+ },
672
+ [e, s.key]
673
+ ), a = k(() => {
674
+ o(""), e.setColumnFilter(s.key, void 0);
675
+ }, [e, s.key]), h = typeof s.def.filterable == "object" ? s.def.filterable : {};
676
+ 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: "✕" }) })
679
+ ] });
680
+ }
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);
685
+ }, []);
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 === "") {
690
+ e.setColumnFilter(s.key, void 0);
691
+ return;
692
+ }
693
+ const V = {
694
+ type: "number",
695
+ operator: w,
696
+ value: _
697
+ };
698
+ if (w === "between" && S !== void 0 && S !== "") {
699
+ const I = typeof S == "number" ? S : parseFloat(String(S));
700
+ isNaN(I) || (V.valueTo = I);
701
+ }
702
+ e.setColumnFilter(s.key, V);
703
+ },
704
+ [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;
710
+ }, 300);
711
+ },
712
+ [a, c, R]
713
+ ), b = k(
714
+ (w) => {
715
+ h(w), R(w, l, c);
716
+ },
717
+ [l, c, R]
718
+ ), 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;
723
+ }, 300);
724
+ },
725
+ [a, l, R]
726
+ ), G = k(() => {
727
+ u(""), p(""), h("eq"), e.setColumnFilter(s.key, void 0);
728
+ }, [e, s.key]);
729
+ return /* @__PURE__ */ d(m, { ai: a === "between" ? "start" : "center", gap: 1, width: "fit", children: [
730
+ /* @__PURE__ */ d(
731
+ D,
732
+ {
733
+ value: a,
734
+ variant: "compact",
735
+ onChange: (w) => w && b(w),
736
+ minWidth: 6,
737
+ hideIcon: !0,
738
+ 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: "↔" })
746
+ ]
747
+ }
748
+ ),
749
+ a === "between" ? /* @__PURE__ */ d(m, { d: "column", gap: 1, flex1: !0, children: [
750
+ /* @__PURE__ */ d(m, { ai: "center", position: "relative", flex1: !0, children: [
751
+ /* @__PURE__ */ r(
752
+ j,
753
+ {
754
+ type: "number",
755
+ variant: "compact",
756
+ placeholder: y.placeholder ?? "From",
757
+ value: l,
758
+ onChange: F,
759
+ width: "fit",
760
+ step: y.step
761
+ }
762
+ ),
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: "✕" }) })
764
+ ] }),
765
+ /* @__PURE__ */ r(m, { ai: "center", flex1: !0, children: /* @__PURE__ */ r(
766
+ j,
767
+ {
768
+ type: "number",
769
+ variant: "compact",
770
+ placeholder: "To",
771
+ value: c,
772
+ onChange: x,
773
+ width: "fit",
774
+ step: y.step
775
+ }
776
+ ) })
777
+ ] }) : /* @__PURE__ */ d(m, { ai: "center", position: "relative", flex1: !0, children: [
778
+ /* @__PURE__ */ r(
779
+ j,
780
+ {
781
+ type: "number",
782
+ variant: "compact",
783
+ placeholder: y.placeholder ?? "Value",
784
+ value: l,
785
+ onChange: F,
786
+ width: "fit",
787
+ step: y.step
788
+ }
789
+ ),
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: "✕" }) })
791
+ ] })
792
+ ] });
793
+ }
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 });
801
+ },
802
+ [e, s.key]
803
+ );
804
+ return /* @__PURE__ */ d(
805
+ D,
806
+ {
807
+ multiple: !0,
808
+ showCheckbox: !0,
809
+ isSearchable: !0,
810
+ searchPlaceholder: "Search...",
811
+ value: i,
812
+ width: "fit",
813
+ minWidth: 0,
814
+ onChange: l,
815
+ variant: "compact",
816
+ 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)))
820
+ ]
821
+ }
822
+ );
823
+ }
824
+ function be(s) {
825
+ const { column: e, grid: t } = s, { filterable: i } = e.def;
826
+ if (!i) return null;
827
+ switch ((typeof i == "object" ? i : { type: "text" }).type) {
828
+ case "text":
829
+ return /* @__PURE__ */ r(de, { column: e, grid: t });
830
+ case "number":
831
+ return /* @__PURE__ */ r(Ue, { column: e, grid: t });
832
+ case "multiselect":
833
+ return /* @__PURE__ */ r(qe, { column: e, grid: t });
834
+ default:
835
+ return /* @__PURE__ */ r(de, { column: e, grid: t });
836
+ }
837
+ }
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(
842
+ m,
843
+ {
844
+ component: "datagrid.filter.cell",
845
+ variant: { isPinned: b || x, isFirstLeftPinned: b && o === 0, isLastLeftPinned: b && u, isFirstRightPinned: x && u, isLastRightPinned: x && l === 0 },
846
+ px: f ? 0 : 2,
847
+ style: {
848
+ width: `var(${a})`,
849
+ left: b ? `var(${h})` : void 0,
850
+ right: x ? `var(${c})` : void 0
851
+ },
852
+ children: !F && p && /* @__PURE__ */ r(be, { column: e, grid: t })
853
+ }
854
+ );
855
+ }
856
+ xe.displayName = "DataGridFilterCell";
857
+ function Fe(s) {
858
+ 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;
860
+ }
861
+ Fe.displayName = "DataGridFilterRow";
862
+ 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,
528
866
  {
529
867
  component: "datagrid.header.cell.contextMenu",
530
- onClick: () => f(!m),
531
- variant: { isPinned: V || i === "RIGHT", isFirstLeftPinned: V && n === 0, isLastLeftPinned: V && r, isFirstRightPinned: z && r, isLastRightPinned: z && o === 0, isSortable: u && !K && !I && !J, isRowNumber: I },
868
+ 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: $ },
532
870
  children: [
533
- /* @__PURE__ */ s(D, { component: "datagrid.header.cell.contextMenu.icon", children: /* @__PURE__ */ s(Se, { fill: "currentColor" }) }),
534
- m && /* @__PURE__ */ h(
535
- he,
871
+ /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.icon", children: /* @__PURE__ */ r(Ee, { fill: "currentColor" }) }),
872
+ p && /* @__PURE__ */ d(
873
+ ge,
536
874
  {
537
875
  component: "datagrid.header.cell.contextMenu.tooltip",
538
- variant: { openLeft: G },
539
- onPositionChange: k,
540
- ref: R,
876
+ onPositionChange: R,
877
+ ref: v,
878
+ adjustTranslateX: F ? "-100%" : "-21px",
879
+ adjustTranslateY: "16px",
541
880
  children: [
542
- b && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("ASC"), children: [
543
- /* @__PURE__ */ s(D, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(Z, { width: "100%", fill: "currentColor" }) }),
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" }) }),
544
883
  "Sort Ascending"
545
884
  ] }),
546
- L && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("DESC"), children: [
547
- /* @__PURE__ */ s(D, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(Z, { width: "100%", fill: "currentColor", rotate: 180 }) }),
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 }) }),
548
887
  "Sort Descending"
549
888
  ] }),
550
- v && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
551
- /* @__PURE__ */ s(p, { width: 4 }),
889
+ G && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
890
+ /* @__PURE__ */ r(g, { width: 4 }),
552
891
  "Clear Sort"
553
892
  ] }),
554
- F && (O || W || H) && /* @__PURE__ */ s(p, { bb: 1, my: 2, borderColor: "gray-300" }),
555
- T && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("LEFT"), children: [
556
- /* @__PURE__ */ s(D, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(ne, { width: "100%", fill: "currentColor" }) }),
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" }) }),
557
896
  "Pin Left"
558
897
  ] }),
559
- B && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("RIGHT"), children: [
560
- /* @__PURE__ */ s(D, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(ne, { width: "100%", fill: "currentColor", rotate: -90 }) }),
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 }) }),
561
900
  "Pin Right"
562
901
  ] }),
563
- N && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
564
- /* @__PURE__ */ s(p, { width: 4 }),
902
+ S && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
903
+ /* @__PURE__ */ r(g, { width: 4 }),
565
904
  "Unpin"
566
905
  ] }),
567
- F && O && (W || H) && /* @__PURE__ */ s(p, { bb: 1, my: 2, borderColor: "gray-300" }),
568
- W && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: e.toggleGrouping, children: [
569
- /* @__PURE__ */ s(D, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(ee, { width: "100%", fill: "currentColor" }) }),
570
- /* @__PURE__ */ h(p, { textWrap: "nowrap", children: [
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" }) }),
909
+ /* @__PURE__ */ d(g, { textWrap: "nowrap", children: [
571
910
  "Group by ",
572
- c ?? t
911
+ h ?? t
573
912
  ] })
574
913
  ] }),
575
- H && /* @__PURE__ */ h(w, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: d.unGroupAll, children: [
576
- /* @__PURE__ */ s(D, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ s(ee, { width: "100%", fill: "currentColor" }) }),
577
- /* @__PURE__ */ s(p, { textWrap: "nowrap", children: "Un-Group All" })
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" })
578
917
  ] })
579
918
  ]
580
919
  }
@@ -583,11 +922,11 @@ function Ce(l) {
583
922
  }
584
923
  ) });
585
924
  }
586
- Ce.displayName = "DataGridHeaderCellContextMenu";
587
- function Re(l) {
588
- const { column: e } = l;
589
- return /* @__PURE__ */ s(
590
- g,
925
+ Ge.displayName = "DataGridHeaderCellContextMenu";
926
+ function ke(s) {
927
+ const { column: e } = s;
928
+ return /* @__PURE__ */ r(
929
+ m,
591
930
  {
592
931
  height: "fit",
593
932
  ai: "center",
@@ -595,168 +934,217 @@ function Re(l) {
595
934
  right: e.pin === "RIGHT" ? void 0 : 0,
596
935
  left: e.pin !== "RIGHT" ? void 0 : 0,
597
936
  py: 3,
598
- children: /* @__PURE__ */ s(
599
- p,
937
+ children: /* @__PURE__ */ r(
938
+ g,
600
939
  {
601
940
  cursor: "col-resize",
602
941
  px: 0.75,
942
+ mt: -6,
603
943
  className: "resizer",
604
944
  height: "fit",
605
945
  props: { onMouseDown: e.resizeColumn, onTouchStart: e.resizeColumn },
606
- children: /* @__PURE__ */ s(p, { component: "datagrid.header.cell.resizer" })
946
+ children: /* @__PURE__ */ r(g, { component: "datagrid.header.cell.resizer" })
607
947
  }
608
948
  )
609
949
  }
610
950
  );
611
951
  }
612
- Re.displayName = "DataGridHeaderCellResizer";
613
- function ye(l) {
614
- const { column: e } = l, { key: t, pin: i, left: n, right: o, isEdge: r, isLeaf: u, leafs: a, grid: c, header: d, gridRows: m, widthVarName: f, leftVarName: R, rightVarName: y, inlineWidth: k } = e, G = t === E, b = t === x, L = t === C, v = t === _, T = i === "LEFT", B = i === "RIGHT", N = T || i === "RIGHT", W = T && n === 0, H = T && r, F = B && r, O = B && o === 0, $ = u && !G && !L && !v, Y = u ? 1 : a.length, K = !L && !v, I = !L && !v, J = v ? void 0 : e.align === "right" ? 10 : 3, V = v ? void 0 : e.align === "center" ? 3 : void 0, z = X(() => {
615
- c.toggleSelectAllRows();
616
- }, []), ie = j(() => {
617
- if (L) return null;
618
- if (v) {
619
- const M = c.selectedRows.size === c.props.data.length, U = !M && c.selectedRows.size > 0;
620
- return /* @__PURE__ */ s(q, { variant: "datagrid", m: 1, indeterminate: U, checked: M, onChange: z });
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 });
621
961
  }
622
962
  if (b) {
623
- if (c.groupColumns.size === 1) {
624
- const M = c.columns.value.leafs.findOrThrow((U) => U.key === c.groupColumns.values().next().value);
625
- return M.header ?? M.key;
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;
626
966
  }
627
967
  return "Group";
628
968
  }
629
- return d ?? t;
630
- }, [c.groupColumns, c.selectedRows, z]);
631
- return /* @__PURE__ */ s(
632
- g,
969
+ return c ?? t;
970
+ }, [h.groupColumns, h.selectedRows, q]);
971
+ return /* @__PURE__ */ r(
972
+ m,
633
973
  {
634
974
  props: { role: "columnheader" },
635
975
  component: "datagrid.header.cell",
636
- variant: { isPinned: N, isFirstLeftPinned: W, isLastLeftPinned: H, isFirstRightPinned: F, isLastRightPinned: O, isSortable: $, isRowNumber: L },
637
- gridRow: m,
638
- gridColumn: Y,
976
+ variant: { isPinned: S, isFirstLeftPinned: _, isLastLeftPinned: V, isFirstRightPinned: I, isLastRightPinned: K, isSortable: J, isRowNumber: x },
977
+ gridRow: p,
978
+ gridColumn: ee,
639
979
  style: {
640
980
  width: `var(${f})`,
641
- left: T ? `var(${R})` : void 0,
642
- right: B ? `var(${y})` : void 0
981
+ left: w ? `var(${v})` : void 0,
982
+ right: C ? `var(${y})` : void 0
643
983
  },
644
- children: !G && /* @__PURE__ */ h(ke, { children: [
645
- /* @__PURE__ */ s(g, { width: "fit", height: "fit", jc: e.align, props: { onClick: $ ? () => e.sortColumn() : void 0 }, children: /* @__PURE__ */ h(
646
- g,
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(
986
+ m,
647
987
  {
648
988
  overflow: "hidden",
649
989
  position: u ? void 0 : "sticky",
650
990
  ai: "center",
651
991
  transition: "none",
652
- pl: J,
653
- pr: V,
992
+ pl: ie,
993
+ pr: U,
654
994
  style: {
655
- left: i ? void 0 : `var(${c.leftEdgeVarName})`
995
+ left: i ? void 0 : `var(${h.leftEdgeVarName})`
656
996
  },
657
997
  children: [
658
- /* @__PURE__ */ s(p, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: ie }),
659
- t === c.sortColumn && /* @__PURE__ */ s(p, { pl: (k ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ s(Z, { width: "16px", rotate: c.sortDirection === "ASC" ? 0 : 180, fill: "currentColor" }) }),
660
- I && /* @__PURE__ */ s(p, { minWidth: e.align === "right" ? 4 : 10 })
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 })
661
1001
  ]
662
1002
  }
663
1003
  ) }),
664
- K && /* @__PURE__ */ s(Re, { column: e }),
665
- I && /* @__PURE__ */ s(Ce, { column: e })
1004
+ te && /* @__PURE__ */ r(ke, { column: e }),
1005
+ $ && /* @__PURE__ */ r(Ge, { column: e })
666
1006
  ] })
667
1007
  }
668
1008
  );
669
1009
  }
670
- ye.displayName = "DataGridHeaderCell";
671
- function ve(l) {
672
- const { grid: e } = l, { isResizeMode: t } = e;
673
- return /* @__PURE__ */ s(ce, { component: "datagrid.header", variant: { isResizeMode: t }, style: { gridTemplateColumns: e.gridTemplateColumns.value }, children: e.headerRows.value.map((i) => i.map((n) => /* @__PURE__ */ s(ye, { column: n }, n.uniqueKey))) });
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 })
1016
+ ] });
674
1017
  }
675
- ve.displayName = "DataGridHeader";
676
- function xe(l) {
677
- const { grid: e } = l, [t, i] = te(0), n = X(
678
- le.throttle((o) => {
679
- i(o.target.scrollTop);
680
- }, 100),
681
- []
682
- );
683
- return /* @__PURE__ */ h(p, { overflowX: "scroll", props: { onScroll: n }, children: [
684
- /* @__PURE__ */ s(ve, { grid: e }),
685
- /* @__PURE__ */ s(we, { grid: e, scrollTop: t })
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;
1023
+ });
1024
+ }, []);
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 })
686
1028
  ] });
687
1029
  }
688
- xe.displayName = "DataGridContent";
689
- function Ge(l) {
690
- const { grid: e } = l;
691
- return e.groupColumns.size === 0 ? null : /* @__PURE__ */ h(g, { component: "datagrid.topBar.columnGroups", children: [
692
- /* @__PURE__ */ s(D, { component: "datagrid.topBar.columnGroups.icon", children: /* @__PURE__ */ s(ee, { width: "100%", fill: "currentColor" }) }),
1030
+ Se.displayName = "DataGridContent";
1031
+ function De(s) {
1032
+ const { grid: e } = s;
1033
+ 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" }) }),
693
1035
  Array.from(e.groupColumns, (t) => {
694
1036
  const i = e.columns.value.leafs.findOrThrow((n) => n.key === t);
695
- return /* @__PURE__ */ h(Te.Fragment, { children: [
696
- /* @__PURE__ */ s(ae, { fill: "currentColor", width: "14px", height: "14px", rotate: -90 }),
697
- /* @__PURE__ */ h(g, { component: "datagrid.topBar.columnGroups.item", children: [
1037
+ return /* @__PURE__ */ d(Be.Fragment, { children: [
1038
+ /* @__PURE__ */ r(pe, { fill: "currentColor", width: "14px", height: "14px", rotate: -90 }),
1039
+ /* @__PURE__ */ d(m, { component: "datagrid.topBar.columnGroups.item", children: [
698
1040
  i.header ?? i.key,
699
- /* @__PURE__ */ s(w, { component: "datagrid.topBar.columnGroups.item.icon", onClick: () => e.toggleGrouping(i.key), children: /* @__PURE__ */ s(_e, { fill: "currentColor", width: "100%" }) })
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: "✕" }) })
700
1042
  ] })
701
1043
  ] }, t);
702
1044
  })
703
1045
  ] });
704
1046
  }
705
- Ge.displayName = "DataGridColumnGroups";
706
- function be(l) {
707
- const { grid: e } = l, [t, i, n] = de({ event: "mousedown" }), o = j(
1047
+ 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);
1052
+ }, []);
1053
+ const o = k(
1054
+ (c) => {
1055
+ const p = c.target.value;
1056
+ i(p), n.current && clearTimeout(n.current), n.current = setTimeout(() => {
1057
+ e.setGlobalFilter(p), n.current = null;
1058
+ }, 300);
1059
+ },
1060
+ [e]
1061
+ ), l = k(() => {
1062
+ i(""), e.setGlobalFilter("");
1063
+ }, [e]), { filtered: u, total: a } = e.filterStats, h = e.hasActiveFilters && u !== a;
1064
+ 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
1069
+ ] }),
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,
1074
+ {
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
1083
+ }
1084
+ ),
1085
+ t && /* @__PURE__ */ r(g, { component: "datagrid.topBar.globalFilter.inputWrapper.clear", props: { onClick: l }, children: "✕" })
1086
+ ] })
1087
+ ] });
1088
+ }
1089
+ function Ne(s) {
1090
+ const { grid: e } = s, [t, i, n] = me({ event: "mousedown" }), o = Y(
708
1091
  () => e.columns.value.leafs.filter(
709
- (r) => ![E, C, _, x].includes(r.key)
1092
+ (l) => ![B, L, P, N].includes(l.key)
710
1093
  ),
711
1094
  [e.columns.value.leafs]
712
1095
  );
713
- return /* @__PURE__ */ h(w, { component: "datagrid.topBar.contextMenu", onClick: () => i(!t), children: [
714
- /* @__PURE__ */ s(Be, { viewBox: "0 0 24 24", width: "20", fill: "currentColor", ...l, children: /* @__PURE__ */ s("path", { d: "M5 6h14M5 12h14M5 18h14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }),
715
- t && /* @__PURE__ */ s(he, { component: "datagrid.topBar.contextMenu.tooltip", ref: n, children: o.map((r) => /* @__PURE__ */ h(
716
- w,
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,
717
1100
  {
718
1101
  component: "datagrid.topBar.contextMenu.tooltip.item",
719
1102
  onClick: (u) => {
720
- u.stopPropagation(), r.toggleVisibility();
1103
+ u.stopPropagation(), l.toggleVisibility();
721
1104
  },
722
1105
  children: [
723
- /* @__PURE__ */ s(q, { variant: "datagrid", checked: r.isVisible, onChange: () => {
1106
+ /* @__PURE__ */ r(Z, { variant: "datagrid", checked: l.isVisible, onChange: () => {
724
1107
  }, focus: { outline: 0 } }),
725
- r.header ?? r.key
1108
+ l.header ?? l.key
726
1109
  ]
727
1110
  },
728
- r.key
1111
+ l.key
729
1112
  )) })
730
1113
  ] });
731
1114
  }
732
- be.displayName = "DataGridTopBarContextMenu";
733
- function Le(l) {
734
- const { grid: e } = l;
735
- return /* @__PURE__ */ h(g, { component: "datagrid.topBar", position: "relative", children: [
736
- /* @__PURE__ */ s(be, { grid: e }),
737
- /* @__PURE__ */ s(Ge, { grid: e })
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 })
1122
+ ] }),
1123
+ e.props.def.globalFilter && /* @__PURE__ */ r(m, { position: "relative", pr: 2, children: /* @__PURE__ */ r(je, { grid: e }) })
738
1124
  ] });
739
1125
  }
740
- Le.displayName = "DataGridTopBar";
741
- function Ie(l) {
742
- const [e, t] = te(0), i = De();
743
- return i.current || (i.current = new Ne(l, () => t((n) => n + 1))), Q(() => {
744
- i.current.props = l, i.current.rows.clear(), i.current.flatRows.clear(), i.current.update();
745
- }, [l.data]), Q(() => {
746
- i.current.props = l, 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();
747
- }, [l.def]), Q(() => {
748
- i.current.props = l, i.current.update();
749
- }, [l.loading]), i.current;
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(() => {
1130
+ i.current.props = s, i.current.rows.clear(), i.current.flatRows.clear(), i.current.update();
1131
+ }, [s.data]), A(() => {
1132
+ 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(() => {
1134
+ i.current.props = s, i.current.update();
1135
+ }, [s.loading]), A(() => {
1136
+ i.current.props = s, i.current.rows.clear(), i.current.flatRows.clear(), i.current.update();
1137
+ }, [s.globalFilterValue, s.columnFilters]), i.current;
750
1138
  }
751
- function Ve(l) {
752
- const e = Ie(l);
753
- return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render"), /* @__PURE__ */ h(p, { component: "datagrid", style: e.sizes.value, props: { role: "presentation" }, children: [
754
- e.props.def.topBar && /* @__PURE__ */ s(Le, { grid: e }),
755
- /* @__PURE__ */ s(xe, { grid: e }),
756
- e.props.def.bottomBar && /* @__PURE__ */ s(Pe, { grid: e })
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 })
757
1145
  ] });
758
1146
  }
759
- Ve.displayName = "DataGrid";
1147
+ Ye.displayName = "DataGrid";
760
1148
  export {
761
- Ve as default
1149
+ Ye as default
762
1150
  };