@cronocode/react-box 3.1.1 → 3.1.2
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/components/dataGrid/components/dataGridCellRowSelection.d.ts +6 -0
- package/components/dataGrid/components/dataGridCellText.d.ts +6 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +6 -1
- package/components/dataGrid/models/cellModel.d.ts +1 -1
- package/components/dataGrid/models/columnModel.d.ts +6 -3
- package/components/dataGrid/models/gridModel.d.ts +3 -3
- package/components/dataGrid/models/groupRowModel.d.ts +1 -1
- package/components/dataGrid/models/rowModel.d.ts +1 -1
- package/components/dataGrid.cjs +1 -1
- package/components/dataGrid.mjs +330 -309
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.mjs +10 -10
- package/core/extends/boxComponents.d.ts +2 -1
- package/core/extends/useComponents.d.ts +1 -1
- package/core.cjs +2 -2
- package/core.mjs +11 -11
- package/package.json +3 -1
package/components/dataGrid.mjs
CHANGED
|
@@ -1,30 +1,38 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { F as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
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
9
|
import { Span as L } from "./semantics.mjs";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
function
|
|
10
|
+
import te from "./tooltip.mjs";
|
|
11
|
+
import Te from "./baseSvg.mjs";
|
|
12
|
+
function Se(a) {
|
|
13
13
|
const { grid: e } = a;
|
|
14
|
-
return /* @__PURE__ */
|
|
15
|
-
/* @__PURE__ */ h
|
|
14
|
+
return /* @__PURE__ */ u(g, { component: "datagrid.bottomBar", children: [
|
|
15
|
+
/* @__PURE__ */ u(h, { children: [
|
|
16
16
|
"Rows: ",
|
|
17
17
|
e.props.data.length
|
|
18
18
|
] }),
|
|
19
|
-
e.props.def.rowSelection && /* @__PURE__ */ h
|
|
19
|
+
e.props.def.rowSelection && /* @__PURE__ */ u(h, { children: [
|
|
20
20
|
"Selected: ",
|
|
21
21
|
e.selectedRows.size
|
|
22
22
|
] })
|
|
23
23
|
] });
|
|
24
24
|
}
|
|
25
|
+
function ie(a) {
|
|
26
|
+
const { cell: e } = a, t = W(() => {
|
|
27
|
+
e.grid.toggleRowSelection(e.row.key);
|
|
28
|
+
}, [e.grid, e.row.key]);
|
|
29
|
+
return /* @__PURE__ */ r(I, { variant: "datagrid", checked: e.row.selected, onChange: t });
|
|
30
|
+
}
|
|
31
|
+
ie.displayName = "DataGridCellRowSelection";
|
|
32
|
+
const Be = "NO_PIN";
|
|
25
33
|
class D {
|
|
26
34
|
constructor(e, t, i) {
|
|
27
|
-
this.def = e, this.grid = t, this.parent = i, this.columns = e.columns?.map((
|
|
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);
|
|
28
36
|
}
|
|
29
37
|
columns = [];
|
|
30
38
|
get visibleColumns() {
|
|
@@ -42,6 +50,9 @@ class D {
|
|
|
42
50
|
get isLeaf() {
|
|
43
51
|
return this.columns.length === 0;
|
|
44
52
|
}
|
|
53
|
+
get Cell() {
|
|
54
|
+
return this.def.Cell;
|
|
55
|
+
}
|
|
45
56
|
_pin;
|
|
46
57
|
get pin() {
|
|
47
58
|
if (this.isLeaf) return this._pin;
|
|
@@ -56,8 +67,8 @@ class D {
|
|
|
56
67
|
if (this.isLeaf) return this;
|
|
57
68
|
const t = new D({ ...this.def, pin: e }, this.grid, this.parent);
|
|
58
69
|
return t.columns = this.columns.filter((i) => i.hasPin(e)).map((i) => {
|
|
59
|
-
const
|
|
60
|
-
return
|
|
70
|
+
const n = i.getPinnedColumn(e);
|
|
71
|
+
return n.parent = t, n;
|
|
61
72
|
}).filter((i) => !!i), t;
|
|
62
73
|
}
|
|
63
74
|
}
|
|
@@ -81,22 +92,22 @@ class D {
|
|
|
81
92
|
get left() {
|
|
82
93
|
let e = 0;
|
|
83
94
|
if (this.parent) {
|
|
84
|
-
const { visibleColumns: t, left: i } = this.parent,
|
|
85
|
-
e += t.sumBy((
|
|
95
|
+
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;
|
|
86
97
|
} else {
|
|
87
|
-
const t = this.grid.columns.value.left.filter((
|
|
88
|
-
e += t.sumBy((
|
|
98
|
+
const t = this.grid.columns.value.left.filter((n) => n.isVisible), i = t.findIndex((n) => n === this);
|
|
99
|
+
e += t.sumBy((n, o) => o < i ? n.inlineWidth ?? 0 : 0);
|
|
89
100
|
}
|
|
90
101
|
return e;
|
|
91
102
|
}
|
|
92
103
|
get right() {
|
|
93
104
|
let e = 0;
|
|
94
105
|
if (this.parent) {
|
|
95
|
-
const { visibleColumns: t } = this.parent, i = t.reverse(),
|
|
96
|
-
e += i.sumBy((
|
|
106
|
+
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;
|
|
97
108
|
} else {
|
|
98
|
-
const i = this.grid.columns.value.right.filter((
|
|
99
|
-
e += i.sumBy((
|
|
109
|
+
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);
|
|
100
111
|
}
|
|
101
112
|
return e;
|
|
102
113
|
}
|
|
@@ -132,16 +143,16 @@ class D {
|
|
|
132
143
|
}
|
|
133
144
|
resizeColumn = (e) => {
|
|
134
145
|
this.grid.isResizeMode = !0;
|
|
135
|
-
const t = e.pageX, { MIN_COLUMN_WIDTH_PX: i, update:
|
|
136
|
-
const p = (
|
|
137
|
-
this.leafs.forEach((
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
}), this.grid.sizes.clear(),
|
|
141
|
-
}, 40), l = new AbortController(), d = (
|
|
142
|
-
l.abort(), this.grid.isResizeMode = !1,
|
|
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) => {
|
|
147
|
+
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);
|
|
151
|
+
}), this.grid.sizes.clear(), n();
|
|
152
|
+
}, 40), l = new AbortController(), d = (c) => {
|
|
153
|
+
l.abort(), this.grid.isResizeMode = !1, n();
|
|
143
154
|
};
|
|
144
|
-
window.addEventListener("mousemove",
|
|
155
|
+
window.addEventListener("mousemove", m, l), window.addEventListener("mouseup", d, l);
|
|
145
156
|
};
|
|
146
157
|
pinColumn = (e) => {
|
|
147
158
|
this.isLeaf ? this._pin = e : this.columns.forEach((t) => t.pinColumn(e)), this.grid.pinColumn(this.uniqueKey, e);
|
|
@@ -161,62 +172,15 @@ class D {
|
|
|
161
172
|
this.grid.toggleColumnVisibility(this.key);
|
|
162
173
|
};
|
|
163
174
|
}
|
|
164
|
-
class
|
|
165
|
-
constructor(e, t, i) {
|
|
166
|
-
this.grid = e, this.row = t, this.column = i;
|
|
167
|
-
}
|
|
168
|
-
get value() {
|
|
169
|
-
return this.column.key === v ? this.row.rowIndex + 1 : this.column.key === f ? `${this.row.groupValue} (${this.row.count})` : null;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
class oe {
|
|
173
|
-
constructor(e, t, i, o, n) {
|
|
174
|
-
this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = o, this.groupValue = n, i.forEach((r) => r.parentRow = this);
|
|
175
|
-
}
|
|
176
|
-
get key() {
|
|
177
|
-
return `${this.parentRow?.key ?? ""}${this.groupColumn.key}${this.groupValue}`;
|
|
178
|
-
}
|
|
179
|
-
parentRow;
|
|
180
|
-
get cells() {
|
|
181
|
-
return this.grid.columns.value.visibleLeafs.map((e) => new Le(this.grid, this, e));
|
|
182
|
-
}
|
|
183
|
-
get expanded() {
|
|
184
|
-
return this.grid.expandedGroupRow.has(this.key);
|
|
185
|
-
}
|
|
186
|
-
get depth() {
|
|
187
|
-
return this.parentRow ? this.parentRow.depth + 1 : 0;
|
|
188
|
-
}
|
|
189
|
-
get count() {
|
|
190
|
-
return this.rows.sumBy((e) => e.count, 0);
|
|
191
|
-
}
|
|
192
|
-
get flatRows() {
|
|
193
|
-
return this.expanded ? [this, ...this.rows.flatMap((e) => e.flatRows)] : [this];
|
|
194
|
-
}
|
|
195
|
-
get allRows() {
|
|
196
|
-
return this.rows.flatMap((e) => e.allRows);
|
|
197
|
-
}
|
|
198
|
-
get groupingColumn() {
|
|
199
|
-
return this.grid.columns.value.leafs.findOrThrow((e) => e.key === f);
|
|
200
|
-
}
|
|
201
|
-
get groupingColumnGridColumn() {
|
|
202
|
-
const { visibleLeafs: e } = this.grid.columns.value, { groupingColumn: t } = this;
|
|
203
|
-
return e.sumBy(
|
|
204
|
-
(o) => o.pin === t.pin && o.key !== T && o.key !== _ && o.key !== v ? 1 : 0
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
toggleRow() {
|
|
208
|
-
this.grid.toggleGroupRow(this.key);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
class De {
|
|
175
|
+
class _e {
|
|
212
176
|
constructor(e, t, i) {
|
|
213
177
|
this.grid = e, this.row = t, this.column = i;
|
|
214
178
|
}
|
|
215
179
|
get value() {
|
|
216
|
-
return this.column.key ===
|
|
180
|
+
return this.column.key === b ? this.row.rowIndex + 1 : this.row.data[this.column.key];
|
|
217
181
|
}
|
|
218
182
|
}
|
|
219
|
-
class
|
|
183
|
+
class Y {
|
|
220
184
|
constructor(e, t, i) {
|
|
221
185
|
this.grid = e, this.data = t, this.rowIndex = i, this.grid = e, this.data = t, this.key = this.grid.getRowKey(t);
|
|
222
186
|
}
|
|
@@ -224,7 +188,7 @@ class K {
|
|
|
224
188
|
parentRow;
|
|
225
189
|
count = 1;
|
|
226
190
|
get cells() {
|
|
227
|
-
return this.grid.columns.value.visibleLeafs.map((e) => new
|
|
191
|
+
return this.grid.columns.value.visibleLeafs.map((e) => new _e(this.grid, this, e));
|
|
228
192
|
}
|
|
229
193
|
get selected() {
|
|
230
194
|
return this.grid.selectedRows.has(this.key);
|
|
@@ -236,83 +200,89 @@ class K {
|
|
|
236
200
|
return this;
|
|
237
201
|
}
|
|
238
202
|
}
|
|
239
|
-
const
|
|
240
|
-
class
|
|
203
|
+
const _ = "empty-cell", b = "row-number-cell", B = "row-selection-cell", y = "grouping-cell";
|
|
204
|
+
class Me {
|
|
241
205
|
constructor(e, t) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
206
|
+
this.props = e, this.update = t, console.debug("\x1B[32m%s\x1B[0m", "[react-box]: DataGrid GridModel ctor");
|
|
207
|
+
}
|
|
208
|
+
sourceColumns = S(() => {
|
|
209
|
+
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) {
|
|
211
|
+
const i = typeof e.rowSelection == "object" && e.rowSelection.pinned ? "LEFT" : void 0;
|
|
212
|
+
t.unshift(
|
|
213
|
+
new D({ key: B, pin: i, width: 50, align: "center", Cell: ie }, this)
|
|
214
|
+
);
|
|
245
215
|
}
|
|
246
|
-
if (e.
|
|
247
|
-
const i = typeof e.
|
|
248
|
-
|
|
216
|
+
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));
|
|
249
219
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
columns =
|
|
220
|
+
return t;
|
|
221
|
+
});
|
|
222
|
+
columns = S(() => {
|
|
253
223
|
console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid columns memo");
|
|
254
|
-
const e = this.
|
|
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;
|
|
255
225
|
return {
|
|
256
226
|
left: e,
|
|
257
227
|
middle: t,
|
|
258
228
|
right: i,
|
|
259
|
-
flat:
|
|
260
|
-
leafs:
|
|
261
|
-
visibleLeafs:
|
|
262
|
-
maxDeath:
|
|
229
|
+
flat: n,
|
|
230
|
+
leafs: o,
|
|
231
|
+
visibleLeafs: s,
|
|
232
|
+
maxDeath: m
|
|
263
233
|
};
|
|
264
234
|
});
|
|
265
|
-
headerRows =
|
|
266
|
-
const i = t.values.groupBy((
|
|
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]);
|
|
267
237
|
return [
|
|
268
|
-
...i.LEFT?.filter((
|
|
269
|
-
...i.NO_PIN?.filter((
|
|
270
|
-
...i.RIGHT?.filter((
|
|
238
|
+
...i.LEFT?.filter((n) => n.isVisible) ?? [],
|
|
239
|
+
...i.NO_PIN?.filter((n) => n.isVisible) ?? [],
|
|
240
|
+
...i.RIGHT?.filter((n) => n.isVisible) ?? []
|
|
271
241
|
];
|
|
272
242
|
})));
|
|
273
|
-
gridTemplateColumns =
|
|
243
|
+
gridTemplateColumns = S(() => {
|
|
274
244
|
console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid gridTemplateColumns memo");
|
|
275
|
-
const { visibleLeafs: e } = this.columns.value, t = e.sumBy((
|
|
276
|
-
return `${
|
|
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)` : "";
|
|
246
|
+
return `${n} auto ${o}`;
|
|
277
247
|
});
|
|
278
|
-
rows =
|
|
248
|
+
rows = S(() => {
|
|
279
249
|
console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid rows memo");
|
|
280
250
|
let e = this.props.data;
|
|
281
251
|
if (this._sortColumn && (e = e.sortBy((t) => t[this._sortColumn], this._sortDirection)), this.groupColumns.size > 0) {
|
|
282
|
-
const t = (i,
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
const
|
|
286
|
-
return this._sortColumn ===
|
|
252
|
+
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) => {
|
|
287
257
|
let d;
|
|
288
|
-
|
|
289
|
-
const
|
|
290
|
-
return
|
|
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;
|
|
291
261
|
});
|
|
292
262
|
};
|
|
293
263
|
return t(e, new Set(this.groupColumns), 0);
|
|
294
264
|
}
|
|
295
|
-
return e.map((t, i) => new
|
|
265
|
+
return e.map((t, i) => new Y(this, t, i));
|
|
296
266
|
});
|
|
297
|
-
flatRows =
|
|
267
|
+
flatRows = S(() => (console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid flatRows memo"), this.rows.value.flatMap((e) => e.flatRows)));
|
|
298
268
|
get rowHeight() {
|
|
299
269
|
return this.props.def.rowHeight ?? this.DEFAULT_ROW_HEIGHT_PX;
|
|
300
270
|
}
|
|
301
|
-
sizes =
|
|
271
|
+
sizes = S(() => {
|
|
302
272
|
console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid sizes memo");
|
|
303
|
-
const e = this.columns.value.flat.reduce((
|
|
304
|
-
const { inlineWidth:
|
|
305
|
-
return typeof
|
|
273
|
+
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;
|
|
306
276
|
}, {});
|
|
307
277
|
e[this.rowHeightVarName] = `${this.rowHeight}px`, e[this.leftEdgeVarName] = `${this.leftEdge}px`;
|
|
308
|
-
const { visibleLeafs: t } = this.columns.value, i = t.find((
|
|
278
|
+
const { visibleLeafs: t } = this.columns.value, i = t.find((n) => n.key === y);
|
|
309
279
|
if (i) {
|
|
310
|
-
const
|
|
311
|
-
e[i.groupColumnWidthVarName] = `${
|
|
280
|
+
const n = t.sumBy((o) => o.pin === i.pin && o.key !== b && o.key !== B ? o.inlineWidth ?? 0 : 0);
|
|
281
|
+
e[i.groupColumnWidthVarName] = `${n}px`;
|
|
312
282
|
}
|
|
313
|
-
return this.groupColumns.forEach((
|
|
314
|
-
const
|
|
315
|
-
e[
|
|
283
|
+
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`;
|
|
316
286
|
}), e;
|
|
317
287
|
});
|
|
318
288
|
DEFAULT_ROW_HEIGHT_PX = 48;
|
|
@@ -338,26 +308,20 @@ class Be {
|
|
|
338
308
|
if (t.length > 0)
|
|
339
309
|
[this._sortDirection] = t, this._sortColumn = this._sortDirection ? e : void 0;
|
|
340
310
|
else {
|
|
341
|
-
const { _sortColumn: i, _sortDirection:
|
|
342
|
-
this._sortColumn = i === e &&
|
|
311
|
+
const { _sortColumn: i, _sortDirection: n } = this;
|
|
312
|
+
this._sortColumn = i === e && n === "DESC" ? void 0 : e, this._sortDirection = i === e && n === "ASC" ? "DESC" : "ASC";
|
|
343
313
|
}
|
|
344
314
|
this.headerRows.clear(), this.rows.clear(), this.flatRows.clear(), this.update();
|
|
345
315
|
};
|
|
346
316
|
pinColumn = (e, t) => {
|
|
347
|
-
const i = this.columns.value.flat.findOrThrow((
|
|
317
|
+
const i = this.columns.value.flat.findOrThrow((n) => n.uniqueKey === e);
|
|
348
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();
|
|
349
319
|
};
|
|
350
320
|
toggleGrouping = (e) => {
|
|
351
|
-
this.groupColumns = new Set(this.groupColumns), this.hiddenColumns = new Set(this.hiddenColumns), this.groupColumns.has(e) ? (this.groupColumns.delete(e), this.hiddenColumns.delete(e)) : (this.groupColumns.add(e), this.hiddenColumns.add(e));
|
|
352
|
-
const t = this._sourceColumns.find((i) => i.key === f);
|
|
353
|
-
if (this.groupColumns.size > 0 && !t) {
|
|
354
|
-
const i = this._sourceColumns.sumBy((o) => o.key === v || o.key === _ ? 1 : 0);
|
|
355
|
-
this._sourceColumns.splice(i, 0, new D({ key: f }, this));
|
|
356
|
-
} else this.groupColumns.size === 0 && t && (this._sourceColumns = this._sourceColumns.removeBy((i) => i.key === f));
|
|
357
|
-
this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
|
|
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();
|
|
358
322
|
};
|
|
359
323
|
unGroupAll = () => {
|
|
360
|
-
this.groupColumns = /* @__PURE__ */ new Set(), this.
|
|
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();
|
|
361
325
|
};
|
|
362
326
|
toggleGroupRow = (e) => {
|
|
363
327
|
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();
|
|
@@ -382,10 +346,10 @@ class Be {
|
|
|
382
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();
|
|
383
347
|
};
|
|
384
348
|
setWidth = (e, t) => {
|
|
385
|
-
const i = this.columns.value.leafs.find((
|
|
349
|
+
const i = this.columns.value.leafs.find((o) => o.key === e);
|
|
386
350
|
if (!i)
|
|
387
351
|
throw new Error("Leaf column not found.");
|
|
388
|
-
i.setWidth(t), this.
|
|
352
|
+
i.setWidth(t), this.sourceColumns.value.flatMap((o) => o.flatColumns).findOrThrow((o) => o.key === e).setWidth(t);
|
|
389
353
|
};
|
|
390
354
|
groupColumns = /* @__PURE__ */ new Set();
|
|
391
355
|
hiddenColumns = /* @__PURE__ */ new Set();
|
|
@@ -398,161 +362,212 @@ class Be {
|
|
|
398
362
|
return this._sortDirection;
|
|
399
363
|
}
|
|
400
364
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
365
|
+
class Ne {
|
|
366
|
+
constructor(e, t, i) {
|
|
367
|
+
this.grid = e, this.row = t, this.column = i;
|
|
368
|
+
}
|
|
369
|
+
get value() {
|
|
370
|
+
return this.column.key === b ? this.row.rowIndex + 1 : this.column.key === y ? `${this.row.groupValue} (${this.row.count})` : null;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
class ne {
|
|
374
|
+
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);
|
|
376
|
+
}
|
|
377
|
+
get key() {
|
|
378
|
+
return `${this.parentRow?.key ?? ""}${this.groupColumn.key}${this.groupValue}`;
|
|
379
|
+
}
|
|
380
|
+
parentRow;
|
|
381
|
+
get cells() {
|
|
382
|
+
return this.grid.columns.value.visibleLeafs.map((e) => new Ne(this.grid, this, e));
|
|
383
|
+
}
|
|
384
|
+
get expanded() {
|
|
385
|
+
return this.grid.expandedGroupRow.has(this.key);
|
|
386
|
+
}
|
|
387
|
+
get depth() {
|
|
388
|
+
return this.parentRow ? this.parentRow.depth + 1 : 0;
|
|
389
|
+
}
|
|
390
|
+
get count() {
|
|
391
|
+
return this.rows.sumBy((e) => e.count, 0);
|
|
392
|
+
}
|
|
393
|
+
get flatRows() {
|
|
394
|
+
return this.expanded ? [this, ...this.rows.flatMap((e) => e.flatRows)] : [this];
|
|
395
|
+
}
|
|
396
|
+
get allRows() {
|
|
397
|
+
return this.rows.flatMap((e) => e.allRows);
|
|
398
|
+
}
|
|
399
|
+
get groupingColumn() {
|
|
400
|
+
return this.grid.columns.value.leafs.findOrThrow((e) => e.key === y);
|
|
401
|
+
}
|
|
402
|
+
get groupingColumnGridColumn() {
|
|
403
|
+
const { visibleLeafs: e } = this.grid.columns.value, { groupingColumn: t } = this;
|
|
404
|
+
return e.sumBy(
|
|
405
|
+
(n) => n.pin === t.pin && n.key !== _ && n.key !== B && n.key !== b ? 1 : 0
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
toggleRow() {
|
|
409
|
+
this.grid.toggleGroupRow(this.key);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
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;
|
|
414
|
+
"align" in t.def && (n.jc = c);
|
|
415
|
+
const x = o === b, C = o === B, R = s === "LEFT", G = s === "RIGHT";
|
|
416
|
+
return /* @__PURE__ */ r(
|
|
417
|
+
g,
|
|
405
418
|
{
|
|
406
419
|
component: "datagrid.cell",
|
|
407
420
|
props: { role: "cell" },
|
|
408
|
-
variant: { isPinned:
|
|
409
|
-
jc: u,
|
|
421
|
+
variant: { isPinned: R || G, isFirstLeftPinned: R && m === 0, isLastLeftPinned: R && d, isFirstRightPinned: G && d, isLastRightPinned: G && l === 0, isRowNumber: x, isRowSelection: C },
|
|
410
422
|
style: {
|
|
411
423
|
width: `var(${p})`,
|
|
412
424
|
height: `var(${t.grid.rowHeightVarName})`,
|
|
413
|
-
left:
|
|
414
|
-
right:
|
|
425
|
+
left: R ? `var(${w})` : void 0,
|
|
426
|
+
right: G ? `var(${v})` : void 0,
|
|
415
427
|
...i
|
|
416
428
|
},
|
|
417
|
-
...
|
|
418
|
-
children:
|
|
419
|
-
A && /* @__PURE__ */ s(m, { px: 4, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: e }),
|
|
420
|
-
G && e
|
|
421
|
-
]
|
|
429
|
+
...n,
|
|
430
|
+
children: e
|
|
422
431
|
}
|
|
423
432
|
);
|
|
424
433
|
}
|
|
425
|
-
|
|
426
|
-
function
|
|
427
|
-
const { row: e } = a, t =
|
|
434
|
+
E.displayName = "DataGridCell";
|
|
435
|
+
function oe(a) {
|
|
436
|
+
const { row: e } = a, t = W(() => {
|
|
428
437
|
e.grid.toggleRowsSelection(e.allRows.map((i) => i.key));
|
|
429
438
|
}, []);
|
|
430
|
-
return /* @__PURE__ */
|
|
431
|
-
const { key:
|
|
432
|
-
if (
|
|
433
|
-
return /* @__PURE__ */
|
|
434
|
-
|
|
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)
|
|
442
|
+
return /* @__PURE__ */ r(
|
|
443
|
+
E,
|
|
435
444
|
{
|
|
436
445
|
column: i.column,
|
|
437
446
|
style: {
|
|
438
|
-
width: `var(${
|
|
439
|
-
right:
|
|
447
|
+
width: `var(${s})`,
|
|
448
|
+
right: m ? "0" : void 0
|
|
440
449
|
},
|
|
441
450
|
br: e.groupingColumn.pin === "LEFT" ? 1 : void 0,
|
|
442
451
|
gridColumn: e.groupingColumnGridColumn,
|
|
443
452
|
pl: 4 * e.depth,
|
|
444
|
-
|
|
445
|
-
|
|
453
|
+
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 }),
|
|
446
456
|
i.value
|
|
447
|
-
] })
|
|
457
|
+
] }) })
|
|
448
458
|
},
|
|
449
|
-
|
|
459
|
+
n
|
|
450
460
|
);
|
|
451
|
-
if (
|
|
452
|
-
const l = e.allRows, d = l.every((p) => p.selected),
|
|
453
|
-
return /* @__PURE__ */
|
|
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);
|
|
454
464
|
}
|
|
455
|
-
if (n
|
|
456
|
-
|
|
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);
|
|
457
468
|
}) });
|
|
458
469
|
}
|
|
459
|
-
|
|
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 }) });
|
|
474
|
+
}
|
|
475
|
+
re.displayName = "DataGridCellText";
|
|
460
476
|
function se(a) {
|
|
461
|
-
const { row: e } = a
|
|
462
|
-
|
|
463
|
-
}, []);
|
|
464
|
-
return /* @__PURE__ */ s(w, { className: "grid-row", display: "contents", props: { role: "row" }, children: e.cells.map((i) => /* @__PURE__ */ s(W, { column: i.column, children: i.column.key === _ ? /* @__PURE__ */ s(V, { variant: "datagrid", checked: e.selected, onChange: t }) : i.value }, i.column.key)) });
|
|
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)) });
|
|
465
479
|
}
|
|
466
480
|
se.displayName = "DataGridRow";
|
|
467
|
-
const
|
|
468
|
-
function
|
|
469
|
-
const { grid: e, scrollTop: t } = a, i = e.flatRows.value.length,
|
|
470
|
-
console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render rows")
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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(() => {
|
|
484
|
+
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,
|
|
476
491
|
{
|
|
477
492
|
style: {
|
|
478
493
|
height: `${i * e.rowHeight}px`
|
|
479
494
|
},
|
|
480
|
-
children: /* @__PURE__ */
|
|
481
|
-
|
|
495
|
+
children: /* @__PURE__ */ r(
|
|
496
|
+
ee,
|
|
482
497
|
{
|
|
483
498
|
width: "max-content",
|
|
484
499
|
minWidth: "fit",
|
|
485
500
|
transition: "none",
|
|
486
501
|
style: {
|
|
487
|
-
transform: `translateY(${
|
|
502
|
+
transform: `translateY(${n * e.rowHeight}px)`,
|
|
488
503
|
gridTemplateColumns: e.gridTemplateColumns.value
|
|
489
504
|
},
|
|
490
|
-
children:
|
|
505
|
+
children: m
|
|
491
506
|
}
|
|
492
507
|
)
|
|
493
508
|
}
|
|
494
509
|
) });
|
|
495
510
|
}
|
|
496
|
-
|
|
497
|
-
function
|
|
498
|
-
const { column: e } = a, [t, i,
|
|
499
|
-
return /* @__PURE__ */
|
|
500
|
-
/* @__PURE__ */
|
|
501
|
-
t && /* @__PURE__ */
|
|
502
|
-
|
|
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,
|
|
503
518
|
{
|
|
504
519
|
component: "datagrid.header.cell.contextMenu.tooltip",
|
|
505
|
-
variant: { openLeft:
|
|
506
|
-
onPositionChange:
|
|
507
|
-
ref:
|
|
520
|
+
variant: { openLeft: m },
|
|
521
|
+
onPositionChange: s,
|
|
522
|
+
ref: n,
|
|
508
523
|
children: [
|
|
509
|
-
l && /* @__PURE__ */
|
|
510
|
-
/* @__PURE__ */
|
|
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" }) }),
|
|
511
526
|
"Sort Ascending"
|
|
512
527
|
] }),
|
|
513
|
-
d && /* @__PURE__ */
|
|
514
|
-
/* @__PURE__ */
|
|
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 }) }),
|
|
515
530
|
"Sort Descending"
|
|
516
531
|
] }),
|
|
517
|
-
|
|
518
|
-
/* @__PURE__ */
|
|
532
|
+
c && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.sortColumn(void 0), children: [
|
|
533
|
+
/* @__PURE__ */ r(h, { width: 4 }),
|
|
519
534
|
"Clear Sort"
|
|
520
535
|
] }),
|
|
521
|
-
|
|
522
|
-
p && /* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
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" }) }),
|
|
524
539
|
"Pin Left"
|
|
525
540
|
] }),
|
|
526
|
-
|
|
527
|
-
/* @__PURE__ */
|
|
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 }) }),
|
|
528
543
|
"Pin Right"
|
|
529
544
|
] }),
|
|
530
|
-
|
|
531
|
-
/* @__PURE__ */
|
|
545
|
+
v && /* @__PURE__ */ u(f, { component: "datagrid.header.cell.contextMenu.tooltip.item", onClick: () => e.pinColumn(), children: [
|
|
546
|
+
/* @__PURE__ */ r(h, { width: 4 }),
|
|
532
547
|
"Unpin"
|
|
533
548
|
] }),
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
/* @__PURE__ */
|
|
537
|
-
/* @__PURE__ */ h
|
|
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: [
|
|
538
553
|
"Group by ",
|
|
539
554
|
e.header ?? e.key
|
|
540
555
|
] })
|
|
541
556
|
] }),
|
|
542
|
-
|
|
543
|
-
/* @__PURE__ */
|
|
544
|
-
/* @__PURE__ */
|
|
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" })
|
|
545
560
|
] })
|
|
546
561
|
]
|
|
547
562
|
}
|
|
548
563
|
)
|
|
549
564
|
] }) });
|
|
550
565
|
}
|
|
551
|
-
|
|
552
|
-
function
|
|
566
|
+
ae.displayName = "DataGridHeaderCellContextMenu";
|
|
567
|
+
function de(a) {
|
|
553
568
|
const { column: e } = a;
|
|
554
|
-
return /* @__PURE__ */
|
|
555
|
-
|
|
569
|
+
return /* @__PURE__ */ r(
|
|
570
|
+
g,
|
|
556
571
|
{
|
|
557
572
|
height: "fit",
|
|
558
573
|
ai: "center",
|
|
@@ -560,160 +575,166 @@ function ae(a) {
|
|
|
560
575
|
right: e.pin === "RIGHT" ? void 0 : 0,
|
|
561
576
|
left: e.pin !== "RIGHT" ? void 0 : 0,
|
|
562
577
|
py: 3,
|
|
563
|
-
children: /* @__PURE__ */
|
|
564
|
-
|
|
578
|
+
children: /* @__PURE__ */ r(
|
|
579
|
+
h,
|
|
565
580
|
{
|
|
566
581
|
cursor: "col-resize",
|
|
567
582
|
px: 0.75,
|
|
568
583
|
className: "resizer",
|
|
569
584
|
height: "fit",
|
|
570
585
|
props: { onMouseDown: e.resizeColumn, onTouchStart: e.resizeColumn },
|
|
571
|
-
children: /* @__PURE__ */
|
|
586
|
+
children: /* @__PURE__ */ r(h, { component: "datagrid.header.cell.resizer" })
|
|
572
587
|
}
|
|
573
588
|
)
|
|
574
589
|
}
|
|
575
590
|
);
|
|
576
591
|
}
|
|
577
|
-
|
|
578
|
-
function
|
|
579
|
-
const { column: e } = a, { key: t, pin: i, left:
|
|
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(() => {
|
|
580
595
|
d.toggleSelectAllRows();
|
|
581
|
-
}, []),
|
|
582
|
-
if (
|
|
583
|
-
if (
|
|
584
|
-
const N = d.selectedRows.size === d.props.data.length,
|
|
585
|
-
return /* @__PURE__ */
|
|
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 });
|
|
586
601
|
}
|
|
587
|
-
if (
|
|
602
|
+
if (G) {
|
|
588
603
|
if (d.groupColumns.size === 1) {
|
|
589
|
-
const N = d.columns.value.leafs.findOrThrow((
|
|
604
|
+
const N = d.columns.value.leafs.findOrThrow((V) => V.key === d.groupColumns.values().next().value);
|
|
590
605
|
return N.header ?? N.key;
|
|
591
606
|
}
|
|
592
607
|
return "Group";
|
|
593
608
|
}
|
|
594
|
-
return
|
|
595
|
-
}, [d.groupColumns, d.selectedRows,
|
|
596
|
-
return /* @__PURE__ */
|
|
597
|
-
|
|
609
|
+
return c ?? t;
|
|
610
|
+
}, [d.groupColumns, d.selectedRows, j]);
|
|
611
|
+
return /* @__PURE__ */ r(
|
|
612
|
+
g,
|
|
598
613
|
{
|
|
599
614
|
component: "datagrid.header.cell",
|
|
600
|
-
variant: { isRowNumber:
|
|
615
|
+
variant: { isRowNumber: k, isPinned: F, isFirstLeftPinned: fe, isLastLeftPinned: we, isFirstRightPinned: Ce, isLastRightPinned: Re, isSortable: U },
|
|
601
616
|
gridRow: p,
|
|
602
|
-
gridColumn:
|
|
617
|
+
gridColumn: ye,
|
|
603
618
|
style: {
|
|
604
|
-
width: `var(${
|
|
605
|
-
left:
|
|
606
|
-
right:
|
|
619
|
+
width: `var(${w})`,
|
|
620
|
+
left: M ? `var(${v})` : void 0,
|
|
621
|
+
right: P ? `var(${x})` : void 0
|
|
607
622
|
},
|
|
608
|
-
children: !
|
|
609
|
-
/* @__PURE__ */
|
|
610
|
-
|
|
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,
|
|
611
626
|
{
|
|
612
627
|
overflow: "hidden",
|
|
613
|
-
position:
|
|
628
|
+
position: m ? void 0 : "sticky",
|
|
614
629
|
ai: "center",
|
|
615
630
|
transition: "none",
|
|
616
|
-
pl: e.align ?
|
|
631
|
+
pl: e.align === "right" ? 10 : 4,
|
|
617
632
|
style: {
|
|
618
633
|
left: i ? void 0 : `var(${d.leftEdgeVarName})`
|
|
619
634
|
},
|
|
620
635
|
children: [
|
|
621
|
-
/* @__PURE__ */
|
|
622
|
-
t === d.sortColumn && /* @__PURE__ */
|
|
623
|
-
|
|
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 })
|
|
624
639
|
]
|
|
625
640
|
}
|
|
626
641
|
) }),
|
|
627
|
-
|
|
628
|
-
|
|
642
|
+
ve && /* @__PURE__ */ r(de, { column: e }),
|
|
643
|
+
X && /* @__PURE__ */ r(ae, { column: e })
|
|
629
644
|
] })
|
|
630
645
|
}
|
|
631
646
|
);
|
|
632
647
|
}
|
|
633
|
-
|
|
634
|
-
function
|
|
648
|
+
ce.displayName = "DataGridHeaderCell";
|
|
649
|
+
function ue(a) {
|
|
635
650
|
const { grid: e } = a, { isResizeMode: t } = e;
|
|
636
|
-
return /* @__PURE__ */
|
|
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))) });
|
|
637
652
|
}
|
|
638
|
-
|
|
639
|
-
function
|
|
640
|
-
const { grid: e } = a, [t, i] =
|
|
641
|
-
|
|
642
|
-
i(
|
|
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);
|
|
643
658
|
}, 100),
|
|
644
659
|
[]
|
|
645
660
|
);
|
|
646
|
-
return /* @__PURE__ */ h
|
|
647
|
-
/* @__PURE__ */
|
|
648
|
-
/* @__PURE__ */
|
|
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 })
|
|
649
664
|
] });
|
|
650
665
|
}
|
|
651
|
-
|
|
652
|
-
function
|
|
666
|
+
he.displayName = "DataGridContent";
|
|
667
|
+
function me(a) {
|
|
653
668
|
const { grid: e } = a;
|
|
654
|
-
return e.groupColumns.size === 0 ? null : /* @__PURE__ */
|
|
655
|
-
/* @__PURE__ */
|
|
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" }) }),
|
|
656
671
|
Array.from(e.groupColumns, (t) => {
|
|
657
|
-
const i = e.columns.value.leafs.findOrThrow((
|
|
658
|
-
return /* @__PURE__ */
|
|
659
|
-
/* @__PURE__ */
|
|
660
|
-
/* @__PURE__ */
|
|
672
|
+
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: [
|
|
661
676
|
i.header ?? i.key,
|
|
662
|
-
/* @__PURE__ */
|
|
677
|
+
/* @__PURE__ */ r(f, { component: "datagrid.topBar.columnGroups.item.icon", onClick: () => e.toggleGrouping(i.key), children: /* @__PURE__ */ r(De, { fill: "currentColor", width: "100%" }) })
|
|
663
678
|
] })
|
|
664
679
|
] }, t);
|
|
665
680
|
})
|
|
666
681
|
] });
|
|
667
682
|
}
|
|
668
|
-
|
|
669
|
-
function
|
|
670
|
-
const { grid: e } = a, [t, i,
|
|
683
|
+
me.displayName = "DataGridColumnGroups";
|
|
684
|
+
function pe(a) {
|
|
685
|
+
const { grid: e } = a, [t, i, n] = Z({ event: "mousedown" }), o = H(
|
|
671
686
|
() => e.columns.value.leafs.filter(
|
|
672
|
-
(
|
|
687
|
+
(s) => ![_, b, B, y].includes(s.key)
|
|
673
688
|
),
|
|
674
689
|
[e.columns.value.leafs]
|
|
675
690
|
);
|
|
676
|
-
return /* @__PURE__ */
|
|
677
|
-
/* @__PURE__ */
|
|
678
|
-
t && /* @__PURE__ */
|
|
679
|
-
|
|
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,
|
|
680
695
|
{
|
|
681
696
|
component: "datagrid.topBar.contextMenu.tooltip.item",
|
|
682
|
-
onClick: (
|
|
683
|
-
|
|
697
|
+
onClick: (m) => {
|
|
698
|
+
m.stopPropagation(), s.toggleVisibility();
|
|
684
699
|
},
|
|
685
700
|
children: [
|
|
686
|
-
/* @__PURE__ */
|
|
701
|
+
/* @__PURE__ */ r(I, { variant: "datagrid", checked: s.isVisible, onChange: () => {
|
|
687
702
|
}, focus: { outline: 0 } }),
|
|
688
|
-
|
|
703
|
+
s.header ?? s.key
|
|
689
704
|
]
|
|
690
705
|
},
|
|
691
|
-
|
|
706
|
+
s.key
|
|
692
707
|
)) })
|
|
693
708
|
] });
|
|
694
709
|
}
|
|
695
|
-
|
|
696
|
-
function
|
|
710
|
+
pe.displayName = "DataGridTopBarContextMenu";
|
|
711
|
+
function ge(a) {
|
|
697
712
|
const { grid: e } = a;
|
|
698
|
-
return /* @__PURE__ */
|
|
699
|
-
/* @__PURE__ */
|
|
700
|
-
/* @__PURE__ */
|
|
713
|
+
return /* @__PURE__ */ u(g, { component: "datagrid.topBar", position: "relative", children: [
|
|
714
|
+
/* @__PURE__ */ r(pe, { grid: e }),
|
|
715
|
+
/* @__PURE__ */ r(me, { grid: e })
|
|
701
716
|
] });
|
|
702
717
|
}
|
|
703
|
-
|
|
704
|
-
function
|
|
705
|
-
const [e, t] =
|
|
706
|
-
return i.current || (i.current = new
|
|
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;
|
|
707
728
|
}
|
|
708
|
-
function
|
|
709
|
-
const e =
|
|
710
|
-
return console.debug("\x1B[36m%s\x1B[0m", "[react-box]: DataGrid render"), /* @__PURE__ */ h
|
|
711
|
-
/* @__PURE__ */
|
|
712
|
-
/* @__PURE__ */
|
|
713
|
-
/* @__PURE__ */
|
|
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 })
|
|
714
735
|
] });
|
|
715
736
|
}
|
|
716
|
-
|
|
737
|
+
We.displayName = "DataGrid";
|
|
717
738
|
export {
|
|
718
|
-
|
|
739
|
+
We as default
|
|
719
740
|
};
|