@cronocode/react-box 3.1.2 → 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.
Files changed (34) hide show
  1. package/components/dataGrid/components/dataGridCell.d.ts +1 -1
  2. package/components/dataGrid/components/dataGridColumnFilter.d.ts +11 -0
  3. package/components/dataGrid/components/dataGridFilterCell.d.ts +8 -0
  4. package/components/dataGrid/components/dataGridFilterRow.d.ts +6 -0
  5. package/components/dataGrid/components/dataGridGlobalFilter.d.ts +6 -0
  6. package/components/dataGrid/contracts/dataGridContract.d.ts +57 -0
  7. package/components/dataGrid/models/columnModel.d.ts +1 -0
  8. package/components/dataGrid/models/gridModel.d.ts +53 -1
  9. package/components/dataGrid/models/groupRowModel.d.ts +2 -0
  10. package/components/dataGrid.cjs +1 -1
  11. package/components/dataGrid.mjs +694 -284
  12. package/components/dropdown.cjs +1 -1
  13. package/components/dropdown.d.ts +4 -1
  14. package/components/dropdown.mjs +158 -149
  15. package/components/form.mjs +1 -1
  16. package/components/semantics.d.ts +25 -25
  17. package/components/semantics.mjs +5 -5
  18. package/components/textbox.cjs +1 -1
  19. package/components/textbox.d.ts +2 -2
  20. package/components/textbox.mjs +5 -4
  21. package/components/tooltip.cjs +1 -1
  22. package/components/tooltip.d.ts +4 -0
  23. package/components/tooltip.mjs +45 -41
  24. package/core/boxStyles.d.ts +66 -31
  25. package/core/extends/boxComponents.d.ts +812 -153
  26. package/core/variables.d.ts +25 -1
  27. package/core.cjs +3 -7
  28. package/core.mjs +1542 -681
  29. package/hooks/useVirtualization.d.ts +43 -0
  30. package/package.json +7 -5
  31. package/ssg.cjs +1 -1
  32. package/ssg.mjs +28 -20
  33. package/types.d.ts +6 -5
  34. package/utils/string/fuzzySearch.d.ts +27 -0
@@ -1,38 +1,41 @@
1
- import { jsxs as u, jsx as r, Fragment as Ge } from "react/jsx-runtime";
2
- import h from "../box.mjs";
3
- import g from "./flex.mjs";
4
- import be, { useCallback as W, useMemo as H, useState as O, useRef as ke, useEffect as z } from "react";
5
- import { F as J, m as S, E as Q, b as Z, D as Le, S as A, P as q, G as $, C as De } from "../core.mjs";
6
- import ee from "./grid.mjs";
7
- import I from "./checkbox.mjs";
8
- import f from "./button.mjs";
9
- import { Span as L } from "./semantics.mjs";
10
- import te from "./tooltip.mjs";
11
- import Te from "./baseSvg.mjs";
12
- function Se(a) {
13
- const { grid: e } = a;
14
- return /* @__PURE__ */ u(g, { component: "datagrid.bottomBar", children: [
15
- /* @__PURE__ */ u(h, { 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__ */ u(h, { 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 ie(a) {
26
- const { cell: e } = a, t = W(() => {
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__ */ r(I, { variant: "datagrid", checked: e.row.selected, onChange: t });
32
+ return /* @__PURE__ */ r(Z, { variant: "datagrid", checked: e.row.selected, onChange: t });
30
33
  }
31
- ie.displayName = "DataGridCellRowSelection";
32
- const Be = "NO_PIN";
33
- class D {
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 D(e.pin ? { ...n, pin: e.pin } : n, t, this)) ?? [], this.isLeaf && (this._inlineWidth = this.key == _ ? 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 D {
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 D {
65
71
  getPinnedColumn(e) {
66
72
  if (this.hasPin(e)) {
67
73
  if (this.isLeaf) return this;
68
- const t = new D({ ...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 D {
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, s) => s < 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 D {
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, s) => s < 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, s) => s < 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 D {
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((c) => c.inlineWidth) - this.leafs.length * i, s = this.leafs.toRecord((c) => [c.key, c.inlineWidth]), m = J.throttle((c) => {
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) => {
147
153
  const p = (c.pageX - t) * (this.pin === "RIGHT" ? -1 : 1);
148
- this.leafs.forEach((w) => {
149
- const v = s[w.key], x = o > 0 ? (v - i) / o * p : p / this.leafs.length, C = Math.round(v + x);
150
- w.setWidth(C < i ? i : C);
154
+ 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);
156
+ f.setWidth(R < i ? i : R);
151
157
  }), this.grid.sizes.clear(), n();
152
- }, 40), l = new AbortController(), d = (c) => {
153
- l.abort(), this.grid.isResizeMode = !1, n();
158
+ }, 40), a = new AbortController(), h = (c) => {
159
+ a.abort(), this.grid.isResizeMode = !1, n();
154
160
  };
155
- window.addEventListener("mousemove", m, l), window.addEventListener("mouseup", d, l);
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 D {
172
178
  this.grid.toggleColumnVisibility(this.key);
173
179
  };
174
180
  }
175
- class _e {
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 === b ? 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 Y {
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 Y {
188
194
  parentRow;
189
195
  count = 1;
190
196
  get cells() {
191
- return this.grid.columns.value.visibleLeafs.map((e) => new _e(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 Y {
200
206
  return this;
201
207
  }
202
208
  }
203
- const _ = "empty-cell", b = "row-number-cell", B = "row-selection-cell", y = "grouping-cell";
204
- class Me {
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 = S(() => {
214
+ sourceColumns = H(() => {
209
215
  const { def: e } = this.props, t = [];
210
- if (this.groupColumns.size > 0 && t.push(new D({ key: y }, this)), t.push(...e.columns.map((i) => new D(i, this))), t.push(new D({ key: _, 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 D({ key: B, pin: i, width: 50, align: "center", Cell: ie }, 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
- const i = typeof e.showRowNumber == "object" && e.showRowNumber.pinned ? "LEFT" : void 0;
218
- t.unshift(new D({ key: b, pin: i, width: 70, 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 = S(() => {
228
+ columns = H(() => {
223
229
  console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid columns memo");
224
- 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), n = [...e, ...t, ...i].flatMap((l) => l.flatColumns), o = n.filter((l) => l.isLeaf), s = n.filter((l) => l.isLeaf && l.isVisible), m = n.maxBy((l) => l.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: s,
232
- maxDeath: m
237
+ visibleLeafs: l,
238
+ maxDeath: u
233
239
  };
234
240
  });
235
- headerRows = S(() => (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 ?? Be).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 = S(() => {
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((s) => s.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 = S(() => {
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 s = n.values().next().value;
254
- n.delete(s);
255
- const m = this.columns.value.leafs.findOrThrow((l) => l.key === s);
256
- return this._sortColumn === y && (i = i.sortBy((l) => l[s], this._sortDirection)), i.groupBy((l) => l[s]).map((l) => {
257
- let d;
258
- n.size > 0 ? d = t(l.values, new Set(n), o + 1) : d = l.values.map((p, w) => new Y(this, p, o + 1 + w));
259
- const c = new ne(this, m, d, o, l.key);
260
- return o += 1, c.expanded && (o += d.length), c;
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 Y(this, t, i));
399
+ return e.map((t, i) => new ae(this, t, i));
266
400
  });
267
- flatRows = S(() => (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 = S(() => {
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: s } = o;
275
- return typeof s == "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 === y);
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 !== b && o.key !== B ? 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((s) => s.key === n);
285
- e[o.groupColumnWidthVarName] = `${t.sumBy((s) => s.pin === o.pin ? s.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 Me {
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,30 @@ class Me {
362
497
  return this._sortDirection;
363
498
  }
364
499
  }
365
- class Ne {
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 === b ? this.row.rowIndex + 1 : this.column.key === y ? `${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 ne {
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((s) => s.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 Ne(this.grid, this, e));
517
+ return this.grid.columns.value.visibleLeafs.map((e) => new Oe(this.grid, this, e));
518
+ }
519
+ get selected() {
520
+ return this.allRows.every((e) => e.selected);
521
+ }
522
+ get indeterminate() {
523
+ return !this.selected && this.allRows.some((e) => e.selected);
383
524
  }
384
525
  get expanded() {
385
526
  return this.grid.expandedGroupRow.has(this.key);
@@ -397,33 +538,41 @@ class ne {
397
538
  return this.rows.flatMap((e) => e.allRows);
398
539
  }
399
540
  get groupingColumn() {
400
- return this.grid.columns.value.leafs.findOrThrow((e) => e.key === y);
541
+ return this.grid.columns.value.leafs.findOrThrow((e) => e.key === N);
401
542
  }
402
543
  get groupingColumnGridColumn() {
403
544
  const { visibleLeafs: e } = this.grid.columns.value, { groupingColumn: t } = this;
404
545
  return e.sumBy(
405
- (n) => n.pin === t.pin && n.key !== _ && n.key !== B && n.key !== b ? 1 : 0
546
+ (n) => n.pin === t.pin && n.key !== B && n.key !== P && n.key !== L ? 1 : 0
406
547
  );
407
548
  }
408
549
  toggleRow() {
409
550
  this.grid.toggleGroupRow(this.key);
410
551
  }
411
552
  }
412
- function E(a) {
413
- const { children: e, column: t, style: i, ...n } = a, { key: o, pin: s, left: m, right: l, isEdge: d, align: c, widthVarName: p, leftVarName: w, rightVarName: v } = t;
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;
414
555
  "align" in t.def && (n.jc = c);
415
- const x = o === b, C = o === B, R = s === "LEFT", G = s === "RIGHT";
556
+ const y = o === L, R = o === P, F = l === "LEFT", b = l === "RIGHT";
416
557
  return /* @__PURE__ */ r(
417
- g,
558
+ m,
418
559
  {
419
- component: "datagrid.cell",
560
+ component: "datagrid.body.cell",
420
561
  props: { role: "cell" },
421
- variant: { isPinned: R || G, isFirstLeftPinned: R && m === 0, isLastLeftPinned: R && d, isFirstRightPinned: G && d, isLastRightPinned: G && l === 0, isRowNumber: x, isRowSelection: C },
562
+ 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
570
+ },
422
571
  style: {
423
572
  width: `var(${p})`,
424
573
  height: `var(${t.grid.rowHeightVarName})`,
425
- left: R ? `var(${w})` : void 0,
426
- right: G ? `var(${v})` : void 0,
574
+ left: F ? `var(${f})` : void 0,
575
+ right: b ? `var(${v})` : void 0,
427
576
  ...i
428
577
  },
429
578
  ...n,
@@ -431,143 +580,353 @@ function E(a) {
431
580
  }
432
581
  );
433
582
  }
434
- E.displayName = "DataGridCell";
435
- function oe(a) {
436
- const { row: e } = a, t = W(() => {
437
- e.grid.toggleRowsSelection(e.allRows.map((i) => i.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));
438
587
  }, []);
439
- return /* @__PURE__ */ r(g, { className: "grid-row", display: "contents", props: { role: "rowgroup" }, children: e.cells.map((i) => {
440
- const { key: n, pin: o, groupColumnWidthVarName: s } = i.column, m = o === "RIGHT";
441
- if (n === y)
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)
442
591
  return /* @__PURE__ */ r(
443
- E,
592
+ X,
444
593
  {
445
- column: i.column,
594
+ column: c.column,
446
595
  style: {
447
- width: `var(${s})`,
448
- right: m ? "0" : void 0
596
+ width: `var(${v})`,
597
+ right: y ? "0" : void 0
449
598
  },
450
- br: e.groupingColumn.pin === "LEFT" ? 1 : void 0,
451
- gridColumn: e.groupingColumnGridColumn,
452
- pl: 4 * e.depth,
599
+ br: o.pin === "LEFT" ? 1 : void 0,
600
+ gridColumn: l,
601
+ pl: 4 * u,
453
602
  overflow: "auto",
454
- children: /* @__PURE__ */ r(h, { textWrap: "nowrap", px: 4, children: /* @__PURE__ */ u(f, { clean: !0, onClick: () => e.toggleRow(), cursor: "pointer", display: "flex", gap: 1, ai: "center", children: [
455
- /* @__PURE__ */ r(Q, { fill: "currentColor", width: "14px", height: "14px", rotate: e.expanded ? 0 : -90 }),
456
- i.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
457
606
  ] }) })
458
607
  },
459
- n
608
+ p
460
609
  );
461
- if (n === B) {
462
- const l = e.allRows, d = l.every((p) => p.selected), c = !d && l.some((p) => p.selected);
463
- return /* @__PURE__ */ r(E, { column: i.column, children: /* @__PURE__ */ r(I, { variant: "datagrid", m: 1, checked: d, indeterminate: c, onChange: t }) }, n);
464
- }
465
- if (n === _) return /* @__PURE__ */ r(h, {}, n);
466
- if (o !== e.groupingColumn.pin || n === b)
467
- return /* @__PURE__ */ r(E, { column: i.column, px: 4, children: i.value }, n);
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);
468
614
  }) });
469
615
  }
470
- oe.displayName = "DataGridGroupRow";
471
- function re(a) {
472
- const { cell: e } = a;
473
- return /* @__PURE__ */ r(g, { height: "fit", width: "fit", overflow: "auto", ai: "center", jc: e.column.align, children: /* @__PURE__ */ r(h, { px: 4, 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 }) });
474
620
  }
475
- re.displayName = "DataGridCellText";
476
- function se(a) {
477
- const { row: e } = a;
478
- return /* @__PURE__ */ r(g, { className: "grid-row", display: "contents", props: { role: "row" }, children: e.cells.map((t) => /* @__PURE__ */ r(E, { column: t.column, children: t.column.Cell ? /* @__PURE__ */ r(t.column.Cell, { cell: t }) : /* @__PURE__ */ r(re, { cell: t }) }, t.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)) });
479
625
  }
480
- se.displayName = "DataGridRow";
481
- const Ee = 10, K = 20;
482
- function le(a) {
483
- const { grid: e, scrollTop: t } = a, i = e.flatRows.value.length, n = Math.max(0, Math.floor(t / e.rowHeight) - K), o = e.props.def.visibleRowsCount ?? Ee, s = e.rowHeight * o + e.rowHeight / 5, m = H(() => {
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(() => {
484
630
  if (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render rows"), e.props.data.length === 0)
485
- return /* @__PURE__ */ r(g, { jc: "center", ai: "center", gridColumn: "full-row", style: { height: s }, children: e.props.loading ? "loading..." : "empty" });
486
- const l = o + K * 2;
487
- return e.flatRows.value.take(l, n).map((c) => c instanceof ne ? /* @__PURE__ */ r(oe, { row: c }, c.key) : /* @__PURE__ */ r(se, { row: c }, c.key));
488
- }, [e.flatRows.value, e.props.data.length, e.props.loading, n, s, o]);
489
- return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render DataGridBody"), /* @__PURE__ */ r(h, { style: { height: s }, children: /* @__PURE__ */ r(
490
- h,
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,
491
637
  {
492
638
  style: {
493
639
  height: `${i * e.rowHeight}px`
494
640
  },
495
641
  children: /* @__PURE__ */ r(
496
- ee,
642
+ he,
497
643
  {
644
+ component: "datagrid.body",
498
645
  width: "max-content",
499
646
  minWidth: "fit",
500
647
  transition: "none",
501
648
  style: {
502
- transform: `translateY(${n * e.rowHeight}px)`,
649
+ transform: `translate3d(0, ${n * e.rowHeight}px, 0)`,
650
+ willChange: "transform",
503
651
  gridTemplateColumns: e.gridTemplateColumns.value
504
652
  },
505
- children: m
653
+ children: u
506
654
  }
507
655
  )
508
656
  }
509
657
  ) });
510
658
  }
511
- le.displayName = "DataGridBody";
512
- function ae(a) {
513
- const { column: e } = a, [t, i, n] = Z({ hideOnScroll: !0, event: "mousedown" }), [o, s] = O({ top: 0, left: 0 }), m = H(() => o.left > window.innerWidth / 2, [o.left]), l = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "DESC"), d = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "ASC"), c = e.isLeaf && e.grid.sortColumn === e.key, p = e.pin !== "LEFT", w = e.pin !== "RIGHT", v = !!e.pin, x = e.isLeaf && e.key !== y, C = e.isLeaf && e.key === y, R = l || d || c, G = p || w || v, k = e.align === "right" ? 2 : void 0, T = e.align === "right" ? void 0 : e.pin === "RIGHT" ? 2.5 : 4;
514
- return /* @__PURE__ */ r(g, { position: "absolute", left: k, right: T, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu", onClick: () => i(!t), children: [
515
- /* @__PURE__ */ r(L, { component: "datagrid.header.cell.contextMenu.icon", children: /* @__PURE__ */ r(Le, { fill: "currentColor" }) }),
516
- t && /* @__PURE__ */ u(
517
- te,
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,
518
732
  {
519
- component: "datagrid.header.cell.contextMenu.tooltip",
520
- variant: { openLeft: m },
521
- onPositionChange: s,
522
- ref: n,
733
+ value: a,
734
+ variant: "compact",
735
+ onChange: (w) => w && b(w),
736
+ minWidth: 6,
737
+ hideIcon: !0,
523
738
  children: [
524
- l && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("ASC"), children: [
525
- /* @__PURE__ */ r(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(A, { width: "100%", fill: "currentColor" }) }),
526
- "Sort Ascending"
527
- ] }),
528
- d && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn("DESC"), children: [
529
- /* @__PURE__ */ r(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(A, { width: "100%", fill: "currentColor", rotate: 180 }) }),
530
- "Sort Descending"
531
- ] }),
532
- c && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
533
- /* @__PURE__ */ r(h, { width: 4 }),
534
- "Clear Sort"
535
- ] }),
536
- R && (G || x || C) && /* @__PURE__ */ r(h, { bb: 1, my: 2, borderColor: "gray-300" }),
537
- p && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("LEFT"), children: [
538
- /* @__PURE__ */ r(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(q, { width: "100%", fill: "currentColor" }) }),
539
- "Pin Left"
540
- ] }),
541
- w && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn("RIGHT"), children: [
542
- /* @__PURE__ */ r(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r(q, { width: "100%", fill: "currentColor", rotate: -90 }) }),
543
- "Pin Right"
544
- ] }),
545
- v && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
546
- /* @__PURE__ */ r(h, { width: 4 }),
547
- "Unpin"
548
- ] }),
549
- R && G && (x || C) && /* @__PURE__ */ r(h, { bb: 1, my: 2, borderColor: "gray-300" }),
550
- x && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: e.toggleGrouping, children: [
551
- /* @__PURE__ */ r(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r($, { width: "100%", fill: "currentColor" }) }),
552
- /* @__PURE__ */ u(h, { textWrap: "nowrap", children: [
553
- "Group by ",
554
- e.header ?? e.key
555
- ] })
556
- ] }),
557
- C && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: e.grid.unGroupAll, children: [
558
- /* @__PURE__ */ r(L, { component: "datagrid.header.cell.contextMenu.tooltip.item.icon", children: /* @__PURE__ */ r($, { width: "100%", fill: "currentColor" }) }),
559
- /* @__PURE__ */ r(h, { textWrap: "nowrap", children: "Un-Group All" })
560
- ] })
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: "↔" })
561
746
  ]
562
747
  }
563
- )
564
- ] }) });
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
+ ] });
565
793
  }
566
- ae.displayName = "DataGridHeaderCellContextMenu";
567
- function de(a) {
568
- const { column: e } = a;
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";
569
841
  return /* @__PURE__ */ r(
570
- g,
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,
866
+ {
867
+ component: "datagrid.header.cell.contextMenu",
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: $ },
870
+ children: [
871
+ /* @__PURE__ */ r(E, { component: "datagrid.header.cell.contextMenu.icon", children: /* @__PURE__ */ r(Ee, { fill: "currentColor" }) }),
872
+ p && /* @__PURE__ */ d(
873
+ ge,
874
+ {
875
+ component: "datagrid.header.cell.contextMenu.tooltip",
876
+ onPositionChange: R,
877
+ ref: v,
878
+ adjustTranslateX: F ? "-100%" : "-21px",
879
+ adjustTranslateY: "16px",
880
+ 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" }) }),
883
+ "Sort Ascending"
884
+ ] }),
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 }) }),
887
+ "Sort Descending"
888
+ ] }),
889
+ G && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
890
+ /* @__PURE__ */ r(g, { width: 4 }),
891
+ "Clear Sort"
892
+ ] }),
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" }) }),
896
+ "Pin Left"
897
+ ] }),
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 }) }),
900
+ "Pin Right"
901
+ ] }),
902
+ S && /* @__PURE__ */ d(T, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
903
+ /* @__PURE__ */ r(g, { width: 4 }),
904
+ "Unpin"
905
+ ] }),
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: [
910
+ "Group by ",
911
+ h ?? t
912
+ ] })
913
+ ] }),
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" })
917
+ ] })
918
+ ]
919
+ }
920
+ )
921
+ ]
922
+ }
923
+ ) });
924
+ }
925
+ Ge.displayName = "DataGridHeaderCellContextMenu";
926
+ function ke(s) {
927
+ const { column: e } = s;
928
+ return /* @__PURE__ */ r(
929
+ m,
571
930
  {
572
931
  height: "fit",
573
932
  ai: "center",
@@ -576,165 +935,216 @@ function de(a) {
576
935
  left: e.pin !== "RIGHT" ? void 0 : 0,
577
936
  py: 3,
578
937
  children: /* @__PURE__ */ r(
579
- h,
938
+ g,
580
939
  {
581
940
  cursor: "col-resize",
582
941
  px: 0.75,
942
+ mt: -6,
583
943
  className: "resizer",
584
944
  height: "fit",
585
945
  props: { onMouseDown: e.resizeColumn, onTouchStart: e.resizeColumn },
586
- children: /* @__PURE__ */ r(h, { component: "datagrid.header.cell.resizer" })
946
+ children: /* @__PURE__ */ r(g, { component: "datagrid.header.cell.resizer" })
587
947
  }
588
948
  )
589
949
  }
590
950
  );
591
951
  }
592
- de.displayName = "DataGridHeaderCellResizer";
593
- function ce(a) {
594
- const { column: e } = a, { key: t, pin: i, left: n, right: o, isEdge: s, isLeaf: m, leafs: l, grid: d, header: c, gridRows: p, widthVarName: w, leftVarName: v, rightVarName: x, inlineWidth: C } = e, R = t === _, G = t === y, k = t === b, T = t === B, M = i === "LEFT", P = i === "RIGHT", F = M || i === "RIGHT", fe = M && n === 0, we = M && s, Ce = P && s, Re = P && o === 0, U = m && !R && !k && !T, ye = m ? 1 : l.length, ve = !k && !T, X = !k && !T, j = W(() => {
595
- d.toggleSelectAllRows();
596
- }, []), xe = H(() => {
597
- if (k) return null;
598
- if (T) {
599
- const N = d.selectedRows.size === d.props.data.length, V = !N && d.selectedRows.size > 0;
600
- return /* @__PURE__ */ r(I, { variant: "datagrid", m: 1, indeterminate: V, checked: N, onChange: j });
601
- }
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;
602
958
  if (G) {
603
- if (d.groupColumns.size === 1) {
604
- const N = d.columns.value.leafs.findOrThrow((V) => V.key === d.groupColumns.values().next().value);
605
- return N.header ?? N.key;
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 });
961
+ }
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;
606
966
  }
607
967
  return "Group";
608
968
  }
609
969
  return c ?? t;
610
- }, [d.groupColumns, d.selectedRows, j]);
970
+ }, [h.groupColumns, h.selectedRows, q]);
611
971
  return /* @__PURE__ */ r(
612
- g,
972
+ m,
613
973
  {
974
+ props: { role: "columnheader" },
614
975
  component: "datagrid.header.cell",
615
- variant: { isRowNumber: k, isPinned: F, isFirstLeftPinned: fe, isLastLeftPinned: we, isFirstRightPinned: Ce, isLastRightPinned: Re, isSortable: U },
976
+ variant: { isPinned: S, isFirstLeftPinned: _, isLastLeftPinned: V, isFirstRightPinned: I, isLastRightPinned: K, isSortable: J, isRowNumber: x },
616
977
  gridRow: p,
617
- gridColumn: ye,
978
+ gridColumn: ee,
618
979
  style: {
619
- width: `var(${w})`,
620
- left: M ? `var(${v})` : void 0,
621
- right: P ? `var(${x})` : void 0
980
+ width: `var(${f})`,
981
+ left: w ? `var(${v})` : void 0,
982
+ right: C ? `var(${y})` : void 0
622
983
  },
623
- children: !R && /* @__PURE__ */ u(Ge, { children: [
624
- /* @__PURE__ */ r(g, { width: "fit", height: "fit", jc: e.align, props: { onClick: U ? () => e.sortColumn() : void 0 }, children: /* @__PURE__ */ u(
625
- 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,
626
987
  {
627
988
  overflow: "hidden",
628
- position: m ? void 0 : "sticky",
989
+ position: u ? void 0 : "sticky",
629
990
  ai: "center",
630
991
  transition: "none",
631
- pl: e.align === "right" ? 10 : 4,
992
+ pl: ie,
993
+ pr: U,
632
994
  style: {
633
- left: i ? void 0 : `var(${d.leftEdgeVarName})`
995
+ left: i ? void 0 : `var(${h.leftEdgeVarName})`
634
996
  },
635
997
  children: [
636
- /* @__PURE__ */ r(h, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: xe }),
637
- t === d.sortColumn && /* @__PURE__ */ r(h, { pl: (C ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ r(A, { width: "16px", rotate: d.sortDirection === "ASC" ? 0 : 180, fill: "currentColor" }) }),
638
- X && /* @__PURE__ */ r(h, { 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 })
639
1001
  ]
640
1002
  }
641
1003
  ) }),
642
- ve && /* @__PURE__ */ r(de, { column: e }),
643
- X && /* @__PURE__ */ r(ae, { column: e })
1004
+ te && /* @__PURE__ */ r(ke, { column: e }),
1005
+ $ && /* @__PURE__ */ r(Ge, { column: e })
644
1006
  ] })
645
1007
  }
646
1008
  );
647
1009
  }
648
- ce.displayName = "DataGridHeaderCell";
649
- function ue(a) {
650
- const { grid: e } = a, { isResizeMode: t } = e;
651
- return /* @__PURE__ */ r(ee, { component: "datagrid.header", variant: { isResizeMode: t }, style: { gridTemplateColumns: e.gridTemplateColumns.value }, children: e.headerRows.value.map((i) => i.map((n) => /* @__PURE__ */ r(ce, { 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
+ ] });
652
1017
  }
653
- ue.displayName = "DataGridHeader";
654
- function he(a) {
655
- const { grid: e } = a, [t, i] = O(0), n = W(
656
- J.throttle((o) => {
657
- i(o.target.scrollTop);
658
- }, 100),
659
- []
660
- );
661
- return /* @__PURE__ */ u(h, { overflowX: "scroll", props: { onScroll: n }, children: [
662
- /* @__PURE__ */ r(ue, { grid: e }),
663
- /* @__PURE__ */ r(le, { 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 })
664
1028
  ] });
665
1029
  }
666
- he.displayName = "DataGridContent";
667
- function me(a) {
668
- const { grid: e } = a;
669
- return e.groupColumns.size === 0 ? null : /* @__PURE__ */ u(g, { component: "datagrid.topBar.columnGroups", children: [
670
- /* @__PURE__ */ r(L, { component: "datagrid.topBar.columnGroups.icon", children: /* @__PURE__ */ r($, { 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" }) }),
671
1035
  Array.from(e.groupColumns, (t) => {
672
1036
  const i = e.columns.value.leafs.findOrThrow((n) => n.key === t);
673
- return /* @__PURE__ */ u(be.Fragment, { children: [
674
- /* @__PURE__ */ r(Q, { fill: "currentColor", width: "14px", height: "14px", rotate: -90 }),
675
- /* @__PURE__ */ u(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: [
676
1040
  i.header ?? i.key,
677
- /* @__PURE__ */ r(f, { component: "datagrid.topBar.columnGroups.item.icon", onClick: () => e.toggleGrouping(i.key), children: /* @__PURE__ */ r(De, { 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: "✕" }) })
678
1042
  ] })
679
1043
  ] }, t);
680
1044
  })
681
1045
  ] });
682
1046
  }
683
- me.displayName = "DataGridColumnGroups";
684
- function pe(a) {
685
- const { grid: e } = a, [t, i, n] = Z({ event: "mousedown" }), o = H(
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(
686
1091
  () => e.columns.value.leafs.filter(
687
- (s) => ![_, b, B, y].includes(s.key)
1092
+ (l) => ![B, L, P, N].includes(l.key)
688
1093
  ),
689
1094
  [e.columns.value.leafs]
690
1095
  );
691
- return /* @__PURE__ */ u(f, { component: "datagrid.topBar.contextMenu", onClick: () => i(!t), children: [
692
- /* @__PURE__ */ r(Te, { viewBox: "0 0 24 24", width: "20", fill: "currentColor", ...a, children: /* @__PURE__ */ r("path", { d: "M5 6h14M5 12h14M5 18h14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }),
693
- t && /* @__PURE__ */ r(te, { component: "datagrid.topBar.contextMenu.tooltip", ref: n, children: o.map((s) => /* @__PURE__ */ u(
694
- f,
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,
695
1100
  {
696
1101
  component: "datagrid.topBar.contextMenu.tooltip.item",
697
- onClick: (m) => {
698
- m.stopPropagation(), s.toggleVisibility();
1102
+ onClick: (u) => {
1103
+ u.stopPropagation(), l.toggleVisibility();
699
1104
  },
700
1105
  children: [
701
- /* @__PURE__ */ r(I, { variant: "datagrid", checked: s.isVisible, onChange: () => {
1106
+ /* @__PURE__ */ r(Z, { variant: "datagrid", checked: l.isVisible, onChange: () => {
702
1107
  }, focus: { outline: 0 } }),
703
- s.header ?? s.key
1108
+ l.header ?? l.key
704
1109
  ]
705
1110
  },
706
- s.key
1111
+ l.key
707
1112
  )) })
708
1113
  ] });
709
1114
  }
710
- pe.displayName = "DataGridTopBarContextMenu";
711
- function ge(a) {
712
- const { grid: e } = a;
713
- return /* @__PURE__ */ u(g, { component: "datagrid.topBar", position: "relative", children: [
714
- /* @__PURE__ */ r(pe, { grid: e }),
715
- /* @__PURE__ */ r(me, { 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 }) })
716
1124
  ] });
717
1125
  }
718
- ge.displayName = "DataGridTopBar";
719
- function Pe(a) {
720
- const [e, t] = O(0), i = ke();
721
- return i.current || (i.current = new Me(a, () => t((n) => n + 1))), z(() => {
722
- i.current.props = a, i.current.rows.clear(), i.current.flatRows.clear(), i.current.update();
723
- }, [a.data]), z(() => {
724
- i.current.props = a, 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();
725
- }, [a.def]), z(() => {
726
- i.current.props = a, i.current.update();
727
- }, [a.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;
728
1138
  }
729
- function We(a) {
730
- const e = Pe(a);
731
- return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render"), /* @__PURE__ */ u(h, { component: "datagrid", style: e.sizes.value, props: { role: "presentation" }, children: [
732
- /* @__PURE__ */ r(ge, { grid: e }),
733
- /* @__PURE__ */ r(he, { grid: e }),
734
- /* @__PURE__ */ r(Se, { 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 })
735
1145
  ] });
736
1146
  }
737
- We.displayName = "DataGrid";
1147
+ Ye.displayName = "DataGrid";
738
1148
  export {
739
- We as default
1149
+ Ye as default
740
1150
  };