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