@cronocode/react-box 3.0.15 → 3.0.16
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/{dataGridCell.d.ts → components/dataGridCell.d.ts} +2 -2
- package/components/dataGrid/components/dataGridColumnGroups.d.ts +6 -0
- package/components/dataGrid/{dataGridGroupRow.d.ts → components/dataGridGroupRow.d.ts} +1 -1
- package/components/dataGrid/{dataGridHeaderCell.d.ts → components/dataGridHeaderCell.d.ts} +1 -1
- package/components/dataGrid/{dataGridPagination.d.ts → components/dataGridPagination.d.ts} +1 -1
- package/components/dataGrid/{dataGridRow.d.ts → components/dataGridRow.d.ts} +1 -1
- package/components/dataGrid/contracts/dataGridContract.d.ts +0 -1
- package/components/dataGrid/models/columnModel.d.ts +3 -0
- package/components/dataGrid/models/gridModel.d.ts +9 -4
- package/components/dataGrid.cjs +1 -1
- package/components/dataGrid.mjs +439 -315
- package/components/dropdown.cjs +1 -1
- package/components/dropdown.d.ts +3 -3
- package/components/dropdown.mjs +81 -61
- package/components/semantics.d.ts +25 -25
- package/core/extends/boxComponents.d.ts +36 -4
- package/core.cjs +3 -3
- package/core.mjs +190 -158
- package/icons/searchIcon.d.ts +2 -0
- package/package.json +1 -1
- package/ssg.mjs +1 -1
package/components/dataGrid.mjs
CHANGED
|
@@ -1,50 +1,58 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { useMemo as
|
|
8
|
-
import { F as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
var le = Object.defineProperty;
|
|
2
|
+
var ae = (u, e, t) => e in u ? le(u, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : u[e] = t;
|
|
3
|
+
var a = (u, e, t) => ae(u, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { jsx as r, jsxs as d, Fragment as ue } from "react/jsx-runtime";
|
|
5
|
+
import m from "../box.mjs";
|
|
6
|
+
import j from "./grid.mjs";
|
|
7
|
+
import he, { useMemo as E, useState as z, forwardRef as ce, useRef as de, useCallback as ge, useImperativeHandle as me } from "react";
|
|
8
|
+
import { F as q, m as V, A as $, b as Y, D as pe, P as K, G as H, C as fe, S as Ce, d as we } from "../core.mjs";
|
|
9
|
+
import p from "./button.mjs";
|
|
10
|
+
import S from "./checkbox.mjs";
|
|
11
|
+
import C from "./flex.mjs";
|
|
12
|
+
import J from "./tooltip.mjs";
|
|
13
|
+
import ye from "./baseSvg.mjs";
|
|
14
|
+
import ve from "./textbox.mjs";
|
|
15
|
+
const Re = "NO_PIN";
|
|
16
|
+
class G {
|
|
17
|
+
constructor(e, t, i) {
|
|
18
|
+
a(this, "columns", []);
|
|
19
|
+
a(this, "_pin");
|
|
20
|
+
a(this, "_inlineWidth");
|
|
21
|
+
a(this, "resizeColumn", (e) => {
|
|
20
22
|
this.grid.isResizeMode = !0;
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
this.leafs.forEach((
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
}), this.grid.headerRows.clear(), this.grid.sizes.clear(),
|
|
27
|
-
}, 20),
|
|
28
|
-
|
|
23
|
+
const t = e.pageX, { MIN_COLUMN_WIDTH_PX: i, update: o } = this.grid, s = this.leafs.sumBy((c) => c.inlineWidth) - this.leafs.length * i, n = this.leafs.toRecord((c) => [c.key, c.inlineWidth]), h = q.throttle((c) => {
|
|
24
|
+
const w = (c.pageX - t) * (this.pin === "RIGHT" ? -1 : 1);
|
|
25
|
+
this.leafs.forEach((y) => {
|
|
26
|
+
const k = n[y.key], L = s > 0 ? (k - i) / s * w : w / this.leafs.length, v = Math.round(k + L);
|
|
27
|
+
y.setWidth(v < i ? i : v);
|
|
28
|
+
}), this.grid.headerRows.clear(), this.grid.sizes.clear(), o();
|
|
29
|
+
}, 20), l = new AbortController(), g = (c) => {
|
|
30
|
+
l.abort(), this.grid.isResizeMode = !1, o();
|
|
29
31
|
};
|
|
30
|
-
window.addEventListener("mousemove",
|
|
32
|
+
window.addEventListener("mousemove", h, l), window.addEventListener("mouseup", g, l);
|
|
31
33
|
});
|
|
32
|
-
|
|
33
|
-
this.isLeaf ? this._pin =
|
|
34
|
+
a(this, "pinColumn", (e) => {
|
|
35
|
+
this.isLeaf ? this._pin = e : this.columns.forEach((t) => t.pinColumn(e)), this.grid.pinColumn(this.uniqueKey, e);
|
|
34
36
|
});
|
|
35
|
-
|
|
37
|
+
a(this, "toggleGrouping", () => {
|
|
36
38
|
this.grid.toggleGrouping(this.key);
|
|
37
39
|
});
|
|
38
|
-
|
|
39
|
-
this.grid.setSortColumn(this.key, ...
|
|
40
|
+
a(this, "sortColumn", (...e) => {
|
|
41
|
+
this.grid.setSortColumn(this.key, ...e);
|
|
40
42
|
});
|
|
41
|
-
|
|
43
|
+
a(this, "setWidth", (e) => {
|
|
42
44
|
if (!this.isLeaf)
|
|
43
45
|
throw new Error("Cannot set width for a parent column.");
|
|
44
|
-
this._inlineWidth !==
|
|
46
|
+
this._inlineWidth !== e && (this._inlineWidth = e, this.grid.setWidth(this.key, e));
|
|
45
47
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
a(this, "toggleVisibility", () => {
|
|
49
|
+
this.grid.toggleColumnVisibility(this.key);
|
|
50
|
+
});
|
|
51
|
+
var o;
|
|
52
|
+
this.def = e, this.grid = t, this.parent = i, this.columns = ((o = e.columns) == null ? void 0 : o.map((s) => new G(e.pin ? { ...s, pin: e.pin } : s, t, this))) ?? [], this.isLeaf && (this._inlineWidth = this.key == P ? void 0 : this.def.width ?? this.grid.DEFAULT_COLUMN_WIDTH_PX, this._pin = e.pin);
|
|
53
|
+
}
|
|
54
|
+
get visibleColumns() {
|
|
55
|
+
return this.columns.filter((e) => e.isVisible);
|
|
48
56
|
}
|
|
49
57
|
get key() {
|
|
50
58
|
return this.def.key;
|
|
@@ -60,66 +68,74 @@ class T {
|
|
|
60
68
|
}
|
|
61
69
|
get pin() {
|
|
62
70
|
if (this.isLeaf) return this._pin;
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
71
|
+
const e = [...new Set(this.columns.flatMap((t) => t.pin))];
|
|
72
|
+
if (e.length === 1) return e[0];
|
|
65
73
|
}
|
|
66
74
|
get uniqueKey() {
|
|
67
75
|
return `${this.key}${this.pin ?? ""}`;
|
|
68
76
|
}
|
|
69
|
-
getPinnedColumn(
|
|
70
|
-
if (this.hasPin(
|
|
77
|
+
getPinnedColumn(e) {
|
|
78
|
+
if (this.hasPin(e)) {
|
|
71
79
|
if (this.isLeaf) return this;
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
const
|
|
75
|
-
return
|
|
76
|
-
}).filter((i) => !!i),
|
|
80
|
+
const t = new G({ ...this.def, pin: e }, this.grid, this.parent);
|
|
81
|
+
return t.columns = this.columns.filter((i) => i.hasPin(e)).map((i) => {
|
|
82
|
+
const o = i.getPinnedColumn(e);
|
|
83
|
+
return o.parent = t, o;
|
|
84
|
+
}).filter((i) => !!i), t;
|
|
77
85
|
}
|
|
78
86
|
}
|
|
79
|
-
hasPin(
|
|
80
|
-
return this.isLeaf ? this._pin ===
|
|
87
|
+
hasPin(e) {
|
|
88
|
+
return this.isLeaf ? this._pin === e : this.columns.some((t) => t.hasPin(e));
|
|
81
89
|
}
|
|
82
90
|
get death() {
|
|
83
91
|
return this.parent ? this.parent.death + 1 : 0;
|
|
84
92
|
}
|
|
85
93
|
get flatColumns() {
|
|
86
|
-
const
|
|
87
|
-
return
|
|
94
|
+
const e = [this];
|
|
95
|
+
return e.push(...this.columns.flatMap((t) => t.flatColumns)), e;
|
|
88
96
|
}
|
|
89
97
|
get inlineWidth() {
|
|
90
98
|
if (this.isLeaf) return this._inlineWidth;
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
return
|
|
99
|
+
const e = this.visibleColumns.map((t) => t.inlineWidth).filter((t) => typeof t == "number");
|
|
100
|
+
if (e.length !== 0)
|
|
101
|
+
return e.sumBy((t) => t);
|
|
94
102
|
}
|
|
95
103
|
get left() {
|
|
96
|
-
let
|
|
104
|
+
let e = 0;
|
|
97
105
|
if (this.parent) {
|
|
98
|
-
const
|
|
99
|
-
|
|
106
|
+
const { visibleColumns: t, left: i } = this.parent, o = t.findIndex((s) => s === this);
|
|
107
|
+
e += t.sumBy((s, n) => n < o ? s.inlineWidth ?? 0 : 0), e += i;
|
|
100
108
|
} else {
|
|
101
|
-
const
|
|
102
|
-
|
|
109
|
+
const t = this.grid.columns.value.left.filter((o) => o.isVisible), i = t.findIndex((o) => o === this);
|
|
110
|
+
e += t.sumBy((o, s) => s < i ? o.inlineWidth ?? 0 : 0);
|
|
103
111
|
}
|
|
104
|
-
return
|
|
112
|
+
return e;
|
|
105
113
|
}
|
|
106
114
|
get right() {
|
|
107
|
-
let
|
|
115
|
+
let e = 0;
|
|
108
116
|
if (this.parent) {
|
|
109
|
-
const
|
|
110
|
-
|
|
117
|
+
const { visibleColumns: t } = this.parent, i = t.reverse(), o = i.findIndex((s) => s === this);
|
|
118
|
+
e += i.sumBy((s, n) => n < o ? s.inlineWidth ?? 0 : 0), e += this.parent.right;
|
|
111
119
|
} else {
|
|
112
|
-
const
|
|
113
|
-
|
|
120
|
+
const i = this.grid.columns.value.right.filter((s) => s.isVisible).reverse(), o = i.findIndex((s) => s === this);
|
|
121
|
+
e += i.sumBy((s, n) => n < o ? s.inlineWidth ?? 0 : 0);
|
|
114
122
|
}
|
|
115
|
-
return
|
|
123
|
+
return e;
|
|
116
124
|
}
|
|
117
125
|
get isEdge() {
|
|
118
|
-
|
|
126
|
+
if (!this.pin) return !1;
|
|
127
|
+
if (this.parent) {
|
|
128
|
+
const { visibleColumns: t } = this.parent;
|
|
129
|
+
return (this.pin === "LEFT" ? t.at(-1) : t.at(0)) === this && this.parent.isEdge;
|
|
130
|
+
}
|
|
131
|
+
return (this.pin === "LEFT" ? this.grid.columns.value.left.filter((t) => t.isVisible).at(-1) : this.grid.columns.value.right.filter((t) => t.isVisible).at(0)) === this;
|
|
132
|
+
}
|
|
133
|
+
get isVisible() {
|
|
134
|
+
return this.isLeaf ? !this.grid.hiddenColumns.includes(this.key) : this.leafs.some((e) => e.isVisible);
|
|
119
135
|
}
|
|
120
136
|
// Approved
|
|
121
137
|
get leafs() {
|
|
122
|
-
return this.isLeaf ? [this] : this.
|
|
138
|
+
return this.isLeaf ? [this] : this.visibleColumns.flatMap((e) => e.leafs);
|
|
123
139
|
}
|
|
124
140
|
get groupColumnWidthVarName() {
|
|
125
141
|
return `--${this.uniqueKey}-group-width`;
|
|
@@ -134,28 +150,28 @@ class T {
|
|
|
134
150
|
return `--${this.uniqueKey}-right`;
|
|
135
151
|
}
|
|
136
152
|
get gridRows() {
|
|
137
|
-
return this.isLeaf ? this.grid.
|
|
153
|
+
return this.isLeaf ? this.grid.columns.value.maxDeath - this.death : 1;
|
|
138
154
|
}
|
|
139
155
|
}
|
|
140
|
-
class
|
|
141
|
-
constructor(
|
|
142
|
-
this.grid =
|
|
156
|
+
class be {
|
|
157
|
+
constructor(e, t, i) {
|
|
158
|
+
this.grid = e, this.row = t, this.column = i;
|
|
143
159
|
}
|
|
144
160
|
get value() {
|
|
145
|
-
return this.column.key ===
|
|
161
|
+
return this.column.key === b ? this.row.rowIndex + 1 : this.column.key === f ? `> ${this.row.groupValue} (${this.row.count})` : null;
|
|
146
162
|
}
|
|
147
163
|
}
|
|
148
|
-
class
|
|
149
|
-
constructor(
|
|
150
|
-
|
|
151
|
-
this.grid =
|
|
164
|
+
class Q {
|
|
165
|
+
constructor(e, t, i, o, s) {
|
|
166
|
+
a(this, "parentRow");
|
|
167
|
+
this.grid = e, this.groupColumn = t, this.rows = i, this.rowIndex = o, this.groupValue = s, i.forEach((n) => n.parentRow = this);
|
|
152
168
|
}
|
|
153
169
|
get rowKey() {
|
|
154
|
-
var
|
|
155
|
-
return `${((
|
|
170
|
+
var e;
|
|
171
|
+
return `${((e = this.parentRow) == null ? void 0 : e.rowKey) ?? ""}${this.groupColumn.key}${this.groupValue}`;
|
|
156
172
|
}
|
|
157
173
|
get cells() {
|
|
158
|
-
return this.grid.columns.value.
|
|
174
|
+
return this.grid.columns.value.visibleLeafs.map((e) => new be(this.grid, this, e));
|
|
159
175
|
}
|
|
160
176
|
get expanded() {
|
|
161
177
|
return this.grid.expandedGroupRow[this.rowKey];
|
|
@@ -164,42 +180,42 @@ class q {
|
|
|
164
180
|
return this.parentRow ? this.parentRow.depth + 1 : 0;
|
|
165
181
|
}
|
|
166
182
|
get count() {
|
|
167
|
-
return this.rows.sumBy((
|
|
183
|
+
return this.rows.sumBy((e) => e.count, 0);
|
|
168
184
|
}
|
|
169
185
|
get flatRows() {
|
|
170
|
-
return this.expanded ? [this, ...this.rows.flatMap((
|
|
186
|
+
return this.expanded ? [this, ...this.rows.flatMap((e) => e.flatRows)] : [this];
|
|
171
187
|
}
|
|
172
188
|
get groupingColumn() {
|
|
173
|
-
return this.grid.columns.value.leafs.findOrThrow((
|
|
189
|
+
return this.grid.columns.value.leafs.findOrThrow((e) => e.key === f);
|
|
174
190
|
}
|
|
175
191
|
get groupingColumnGridColumn() {
|
|
176
|
-
const {
|
|
177
|
-
return
|
|
178
|
-
(
|
|
192
|
+
const { visibleLeafs: e } = this.grid.columns.value, { groupingColumn: t } = this;
|
|
193
|
+
return e.sumBy(
|
|
194
|
+
(o) => o.pin === t.pin && o.key !== P && o.key !== T && o.key !== b ? 1 : 0
|
|
179
195
|
);
|
|
180
196
|
}
|
|
181
197
|
toggleRow() {
|
|
182
198
|
this.grid.toggleGroupRow(this.rowKey);
|
|
183
199
|
}
|
|
184
200
|
}
|
|
185
|
-
class
|
|
186
|
-
constructor(
|
|
187
|
-
this.grid =
|
|
201
|
+
class ke {
|
|
202
|
+
constructor(e, t, i) {
|
|
203
|
+
this.grid = e, this.row = t, this.column = i;
|
|
188
204
|
}
|
|
189
205
|
get value() {
|
|
190
|
-
return this.column.key ===
|
|
206
|
+
return this.column.key === P ? null : this.column.key === b ? this.row.rowIndex + 1 : this.row.row[this.column.key];
|
|
191
207
|
}
|
|
192
208
|
}
|
|
193
|
-
class
|
|
194
|
-
constructor(
|
|
195
|
-
|
|
196
|
-
this.grid =
|
|
209
|
+
class X {
|
|
210
|
+
constructor(e, t, i) {
|
|
211
|
+
a(this, "parentRow");
|
|
212
|
+
this.grid = e, this.row = t, this.rowIndex = i, this.grid = e, this.row = t;
|
|
197
213
|
}
|
|
198
214
|
get rowKey() {
|
|
199
215
|
return this.getRowKey();
|
|
200
216
|
}
|
|
201
217
|
get cells() {
|
|
202
|
-
return this.grid.columns.value.
|
|
218
|
+
return this.grid.columns.value.visibleLeafs.map((e) => new ke(this.grid, this, e));
|
|
203
219
|
}
|
|
204
220
|
get count() {
|
|
205
221
|
return 1;
|
|
@@ -209,111 +225,129 @@ class U {
|
|
|
209
225
|
}
|
|
210
226
|
getRowKey() {
|
|
211
227
|
var i;
|
|
212
|
-
const { rowKey:
|
|
213
|
-
return `${((i = this.parentRow) == null ? void 0 : i.rowKey) ?? ""}${
|
|
228
|
+
const { rowKey: e } = this.grid.props.def, t = e ? typeof e == "function" ? e(this.row) : this.row[e] : this.rowIndex;
|
|
229
|
+
return `${((i = this.parentRow) == null ? void 0 : i.rowKey) ?? ""}${t}`;
|
|
214
230
|
}
|
|
215
231
|
}
|
|
216
|
-
const
|
|
217
|
-
class
|
|
218
|
-
constructor(
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const
|
|
232
|
+
const P = "empty-cell", b = "row-number-cell", T = "row-selection-cell", f = "grouping-cell";
|
|
233
|
+
class Le {
|
|
234
|
+
constructor(e, t) {
|
|
235
|
+
a(this, "_sourceColumns", []);
|
|
236
|
+
a(this, "columns", V(() => {
|
|
237
|
+
const e = this._sourceColumns.map((l) => l.getPinnedColumn("LEFT")).filter((l) => !!l), t = this._sourceColumns.map((l) => l.getPinnedColumn()).filter((l) => !!l), i = this._sourceColumns.map((l) => l.getPinnedColumn("RIGHT")).filter((l) => !!l), o = [...e, ...t, ...i].flatMap((l) => l.flatColumns), s = o.filter((l) => l.isLeaf), n = o.filter((l) => l.isLeaf && l.isVisible), h = o.maxBy((l) => l.death) + 1;
|
|
222
238
|
return {
|
|
223
|
-
left:
|
|
224
|
-
middle:
|
|
239
|
+
left: e,
|
|
240
|
+
middle: t,
|
|
225
241
|
right: i,
|
|
226
|
-
flat:
|
|
227
|
-
leafs:
|
|
242
|
+
flat: o,
|
|
243
|
+
leafs: s,
|
|
244
|
+
visibleLeafs: n,
|
|
245
|
+
maxDeath: h
|
|
228
246
|
};
|
|
229
247
|
}));
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
248
|
+
a(this, "headerRows", V(() => this.columns.value.flat.groupBy((t) => t.death).sortBy((t) => t.key).map((t) => {
|
|
249
|
+
var o, s, n;
|
|
250
|
+
const i = t.values.groupBy((h) => h.pin ?? Re).toRecord((h) => [h.key, h.values]);
|
|
251
|
+
return [
|
|
252
|
+
...((o = i.LEFT) == null ? void 0 : o.filter((h) => h.isVisible)) ?? [],
|
|
253
|
+
...((s = i.NO_PIN) == null ? void 0 : s.filter((h) => h.isVisible)) ?? [],
|
|
254
|
+
...((n = i.RIGHT) == null ? void 0 : n.filter((h) => h.isVisible)) ?? []
|
|
255
|
+
];
|
|
233
256
|
})));
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
return `${
|
|
257
|
+
a(this, "gridTemplateColumns", V(() => {
|
|
258
|
+
const { visibleLeafs: e } = this.columns.value, t = e.sumBy((n) => n.pin === "RIGHT" ? 1 : 0), i = e.length - t - 1, o = i > 0 ? `repeat(${i}, max-content)` : "", s = t > 0 ? `repeat(${t}, max-content)` : "";
|
|
259
|
+
return `${o} auto ${s}`;
|
|
237
260
|
}));
|
|
238
|
-
|
|
239
|
-
let
|
|
240
|
-
if (this._sortColumn && (
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
return this._sortColumn ===
|
|
246
|
-
let
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
return
|
|
261
|
+
a(this, "rows", V(() => {
|
|
262
|
+
let e = this.props.data;
|
|
263
|
+
if (this._sortColumn && (e = e.sortBy((t) => t[this._sortColumn], this._sortDirection)), this.groupColumns.length > 0) {
|
|
264
|
+
const t = (i, o, s) => {
|
|
265
|
+
const n = o[0];
|
|
266
|
+
o = o.removeBy((l) => l === n);
|
|
267
|
+
const h = this.columns.value.leafs.findOrThrow((l) => l.key === n);
|
|
268
|
+
return this._sortColumn === f && (i = i.sortBy((l) => l[n], this._sortDirection)), i.groupBy((l) => l[n]).map((l) => {
|
|
269
|
+
let g;
|
|
270
|
+
o.length > 0 ? g = t(l.values, o, s + 1) : g = l.values.map((w, y) => new X(this, w, s + 1 + y));
|
|
271
|
+
const c = new Q(this, h, g, s, l.key);
|
|
272
|
+
return s += 1, c.expanded && (s += g.length), c;
|
|
250
273
|
});
|
|
251
274
|
};
|
|
252
|
-
return e
|
|
275
|
+
return t(e, this.groupColumns, 0);
|
|
253
276
|
}
|
|
254
|
-
return
|
|
277
|
+
return e.map((t, i) => new X(this, t, i));
|
|
255
278
|
}));
|
|
256
|
-
|
|
257
|
-
|
|
279
|
+
a(this, "flatRows", V(() => this.rows.value.flatMap((e) => e.flatRows)));
|
|
280
|
+
a(this, "sizes", V(() => {
|
|
258
281
|
console.log("sizes");
|
|
259
|
-
const
|
|
260
|
-
const { inlineWidth:
|
|
261
|
-
return typeof
|
|
282
|
+
const e = this.columns.value.flat.reduce((o, s) => {
|
|
283
|
+
const { inlineWidth: n } = s;
|
|
284
|
+
return typeof n == "number" && (o[s.widthVarName] = `${s.inlineWidth}px`), s.pin === "LEFT" && (o[s.leftVarName] = `${s.left}px`), s.pin === "RIGHT" && (o[s.rightVarName] = `${s.right}px`), o;
|
|
262
285
|
}, {});
|
|
263
|
-
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
}
|
|
286
|
+
e[this.leftEdgeVarName] = `${this.leftEdge}px`;
|
|
287
|
+
const { visibleLeafs: t } = this.columns.value, i = t.find((o) => o.key === f);
|
|
288
|
+
if (i) {
|
|
289
|
+
const o = t.sumBy((s) => s.pin === i.pin && s.key !== b && s.key !== T ? s.inlineWidth ?? 0 : 0);
|
|
290
|
+
e[i.groupColumnWidthVarName] = `${o}px`;
|
|
291
|
+
}
|
|
292
|
+
return this.groupColumns.forEach((o) => {
|
|
293
|
+
const s = this.columns.value.leafs.findOrThrow((n) => n.key === o);
|
|
294
|
+
e[s.groupColumnWidthVarName] = `${t.sumBy((n) => n.pin === s.pin ? n.inlineWidth ?? 0 : 0)}px`;
|
|
295
|
+
}), e;
|
|
269
296
|
}));
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
[this._sortDirection] =
|
|
297
|
+
a(this, "ROW_HEIGHT", 12);
|
|
298
|
+
a(this, "MIN_COLUMN_WIDTH_PX", 48);
|
|
299
|
+
a(this, "DEFAULT_COLUMN_WIDTH_PX", 200);
|
|
300
|
+
a(this, "isResizeMode", !1);
|
|
301
|
+
a(this, "expandedGroupRow", {});
|
|
302
|
+
a(this, "leftEdgeVarName", "--left-edge");
|
|
303
|
+
a(this, "setSortColumn", (e, ...t) => {
|
|
304
|
+
if (t.length > 0)
|
|
305
|
+
[this._sortDirection] = t, this._sortColumn = this._sortDirection ? e : void 0;
|
|
279
306
|
else {
|
|
280
|
-
const { _sortColumn: i, _sortDirection:
|
|
281
|
-
this._sortColumn = i ===
|
|
307
|
+
const { _sortColumn: i, _sortDirection: o } = this;
|
|
308
|
+
this._sortColumn = i === e && o === "DESC" ? void 0 : e, this._sortDirection = i === e && o === "ASC" ? "DESC" : "ASC";
|
|
282
309
|
}
|
|
283
310
|
this.headerRows.clear(), this.rows.clear(), this.flatRows.clear(), this.update();
|
|
284
311
|
});
|
|
285
|
-
|
|
286
|
-
const i = this.columns.value.flat.findOrThrow((
|
|
287
|
-
i.pin !==
|
|
312
|
+
a(this, "pinColumn", (e, t) => {
|
|
313
|
+
const i = this.columns.value.flat.findOrThrow((o) => o.uniqueKey === e);
|
|
314
|
+
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();
|
|
288
315
|
});
|
|
289
|
-
|
|
290
|
-
this.groupColumns.includes(
|
|
291
|
-
const
|
|
292
|
-
if (this.groupColumns.length > 0 && !
|
|
293
|
-
const i = this._sourceColumns.sumBy((
|
|
294
|
-
this._sourceColumns.splice(i, 0, new
|
|
295
|
-
} else this.groupColumns.length === 0 &&
|
|
316
|
+
a(this, "toggleGrouping", (e) => {
|
|
317
|
+
this.groupColumns.includes(e) ? (this.groupColumns = this.groupColumns.removeBy((i) => i === e), this.hiddenColumns = this.hiddenColumns.removeBy((i) => i === e)) : (this.groupColumns = this.groupColumns.add(e), this.hiddenColumns = this.hiddenColumns.add(e));
|
|
318
|
+
const t = this._sourceColumns.find((i) => i.key === f);
|
|
319
|
+
if (this.groupColumns.length > 0 && !t) {
|
|
320
|
+
const i = this._sourceColumns.sumBy((o) => o.key === b || o.key === T ? 1 : 0);
|
|
321
|
+
this._sourceColumns.splice(i, 0, new G({ key: f }, this));
|
|
322
|
+
} else this.groupColumns.length === 0 && t && (this._sourceColumns = this._sourceColumns.removeBy((i) => i.key === f));
|
|
296
323
|
this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
|
|
297
324
|
});
|
|
298
|
-
|
|
299
|
-
|
|
325
|
+
a(this, "unGroupAll", () => {
|
|
326
|
+
this.groupColumns = [], this._sourceColumns = this._sourceColumns.removeBy((e) => e.key === f), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
|
|
327
|
+
});
|
|
328
|
+
a(this, "toggleGroupRow", (e) => {
|
|
329
|
+
e in this.expandedGroupRow ? delete this.expandedGroupRow[e] : this.expandedGroupRow[e] = !0, this.rows.clear(), this.flatRows.clear(), this.update();
|
|
300
330
|
});
|
|
301
|
-
|
|
302
|
-
|
|
331
|
+
a(this, "toggleColumnVisibility", (e) => {
|
|
332
|
+
this.hiddenColumns.includes(e) ? this.hiddenColumns = this.hiddenColumns.removeBy((t) => t === e) : this.hiddenColumns = this.hiddenColumns.add(e), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
|
|
333
|
+
});
|
|
334
|
+
a(this, "setWidth", (e, t) => {
|
|
335
|
+
const i = this.columns.value.leafs.find((s) => s.key === e);
|
|
303
336
|
if (!i)
|
|
304
337
|
throw new Error("Leaf column not found.");
|
|
305
|
-
i.setWidth(
|
|
338
|
+
i.setWidth(t), this._sourceColumns.flatMap((s) => s.flatColumns).findOrThrow((s) => s.key === e).setWidth(t);
|
|
306
339
|
});
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
340
|
+
a(this, "groupColumns", []);
|
|
341
|
+
a(this, "hiddenColumns", []);
|
|
342
|
+
a(this, "_sortColumn");
|
|
343
|
+
a(this, "_sortDirection", "ASC");
|
|
344
|
+
this.props = e, this.update = t, this._sourceColumns = e.def.columns.map((i) => new G(i, this)), this._sourceColumns.push(new G({ key: P }, this)), this._sourceColumns.unshift(new G({ key: T, width: 50, align: "center" }, this)), this._sourceColumns.unshift(new G({ key: b, pin: "LEFT", width: 70, align: "right" }, this));
|
|
311
345
|
}
|
|
312
346
|
get leftEdge() {
|
|
313
|
-
return this.columns.value.left.sumBy((
|
|
347
|
+
return this.columns.value.left.sumBy((e) => e.inlineWidth ?? 0);
|
|
314
348
|
}
|
|
315
349
|
get rightEdge() {
|
|
316
|
-
return this.columns.value.right.sumBy((
|
|
350
|
+
return this.columns.value.right.sumBy((e) => e.inlineWidth ?? 0);
|
|
317
351
|
}
|
|
318
352
|
get sortColumn() {
|
|
319
353
|
return this._sortColumn;
|
|
@@ -322,92 +356,92 @@ class yt {
|
|
|
322
356
|
return this._sortDirection;
|
|
323
357
|
}
|
|
324
358
|
}
|
|
325
|
-
function
|
|
326
|
-
const
|
|
327
|
-
return
|
|
359
|
+
function _e(u) {
|
|
360
|
+
const e = E(() => new Le(u, () => i((s) => s + 1)), [u]), [t, i] = z(0);
|
|
361
|
+
return E(() => Object.create(Object.getPrototypeOf(e), Object.getOwnPropertyDescriptors(e)), [e, t]);
|
|
328
362
|
}
|
|
329
|
-
function
|
|
330
|
-
const { column:
|
|
331
|
-
if (
|
|
332
|
-
if (
|
|
333
|
-
if (
|
|
334
|
-
if (
|
|
335
|
-
const
|
|
336
|
-
return
|
|
363
|
+
function xe(u) {
|
|
364
|
+
const { column: e } = u, { key: t, pin: i, left: o, right: s, isEdge: n, isLeaf: h, leafs: l, grid: g, header: c, gridRows: w, widthVarName: y, leftVarName: k, rightVarName: L, inlineWidth: v } = e, _ = t === P, x = t === f, R = t === b, W = t === T, I = i === "LEFT", D = i === "RIGHT", B = I || i === "RIGHT", M = I && o === 0, O = I && n, te = D && n, ie = D && s === 0, A = h && !_ && !R && !W, se = h ? 1 : l.length, oe = !R && !W, F = !R && !W, re = E(() => {
|
|
365
|
+
if (R) return null;
|
|
366
|
+
if (W) return /* @__PURE__ */ r(S, { m: 1 });
|
|
367
|
+
if (x) {
|
|
368
|
+
if (g.groupColumns.length === 1) {
|
|
369
|
+
const U = g.columns.value.leafs.findOrThrow((ne) => ne.key === g.groupColumns[0]);
|
|
370
|
+
return U.header ?? U.key;
|
|
337
371
|
}
|
|
338
372
|
return "Group";
|
|
339
373
|
}
|
|
340
|
-
return
|
|
341
|
-
}, [
|
|
342
|
-
return /* @__PURE__ */
|
|
343
|
-
|
|
374
|
+
return c ?? t;
|
|
375
|
+
}, [g.groupColumns]);
|
|
376
|
+
return /* @__PURE__ */ r(
|
|
377
|
+
C,
|
|
344
378
|
{
|
|
345
379
|
component: "datagrid.header.cell",
|
|
346
|
-
variant: { isRowNumber:
|
|
347
|
-
gridRow:
|
|
348
|
-
gridColumn:
|
|
380
|
+
variant: { isRowNumber: R, isPinned: B, isFirstLeftPinned: M, isLastLeftPinned: O, isFirstRightPinned: te, isLastRightPinned: ie, isSortable: A },
|
|
381
|
+
gridRow: w,
|
|
382
|
+
gridColumn: se,
|
|
349
383
|
style: {
|
|
350
|
-
width: `var(${
|
|
351
|
-
left:
|
|
352
|
-
right: D ? `var(${
|
|
384
|
+
width: `var(${y})`,
|
|
385
|
+
left: I ? `var(${k})` : void 0,
|
|
386
|
+
right: D ? `var(${L})` : void 0
|
|
353
387
|
},
|
|
354
|
-
children: !
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
|
|
388
|
+
children: !_ && /* @__PURE__ */ d(ue, { children: [
|
|
389
|
+
/* @__PURE__ */ r(C, { width: "fit", height: "fit", jc: e.align, props: { onClick: A ? () => e.sortColumn() : void 0 }, children: /* @__PURE__ */ d(
|
|
390
|
+
C,
|
|
357
391
|
{
|
|
358
392
|
overflow: "hidden",
|
|
359
|
-
position:
|
|
393
|
+
position: h ? void 0 : "sticky",
|
|
360
394
|
ai: "center",
|
|
361
395
|
transition: "none",
|
|
362
|
-
pl:
|
|
396
|
+
pl: e.align ? void 0 : 4,
|
|
363
397
|
style: {
|
|
364
|
-
left: i ? void 0 : `var(${
|
|
398
|
+
left: i ? void 0 : `var(${g.leftEdgeVarName})`
|
|
365
399
|
},
|
|
366
400
|
children: [
|
|
367
|
-
/* @__PURE__ */
|
|
368
|
-
|
|
369
|
-
|
|
401
|
+
/* @__PURE__ */ r(m, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: re }),
|
|
402
|
+
t === g.sortColumn && /* @__PURE__ */ r(m, { pl: (v ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ r($, { width: "16px", rotate: g.sortDirection === "ASC" ? 0 : 180, fill: "violet-950" }) }),
|
|
403
|
+
F && /* @__PURE__ */ r(m, { minWidth: 10 })
|
|
370
404
|
]
|
|
371
405
|
}
|
|
372
406
|
) }),
|
|
373
|
-
|
|
374
|
-
|
|
407
|
+
oe && /* @__PURE__ */ r(Te, { column: e }),
|
|
408
|
+
F && /* @__PURE__ */ r(Ge, { column: e })
|
|
375
409
|
] })
|
|
376
410
|
}
|
|
377
411
|
);
|
|
378
412
|
}
|
|
379
|
-
function
|
|
380
|
-
const { column:
|
|
381
|
-
return /* @__PURE__ */
|
|
382
|
-
|
|
413
|
+
function Te(u) {
|
|
414
|
+
const { column: e } = u;
|
|
415
|
+
return /* @__PURE__ */ r(
|
|
416
|
+
C,
|
|
383
417
|
{
|
|
384
418
|
height: "fit",
|
|
385
419
|
ai: "center",
|
|
386
420
|
position: "absolute",
|
|
387
|
-
right:
|
|
388
|
-
left:
|
|
421
|
+
right: e.pin === "RIGHT" ? void 0 : 0,
|
|
422
|
+
left: e.pin !== "RIGHT" ? void 0 : 0,
|
|
389
423
|
py: 3,
|
|
390
|
-
children: /* @__PURE__ */
|
|
391
|
-
|
|
424
|
+
children: /* @__PURE__ */ r(
|
|
425
|
+
m,
|
|
392
426
|
{
|
|
393
427
|
cursor: "col-resize",
|
|
394
428
|
px: 0.75,
|
|
395
429
|
className: "resizer",
|
|
396
430
|
height: "fit",
|
|
397
|
-
props: { onMouseDown:
|
|
398
|
-
children: /* @__PURE__ */
|
|
431
|
+
props: { onMouseDown: e.resizeColumn, onTouchStart: e.resizeColumn },
|
|
432
|
+
children: /* @__PURE__ */ r(m, { width: 0.5, height: "fit", bgColor: "gray-400", hoverGroup: { resizer: { bgColor: "gray-600" } } })
|
|
399
433
|
}
|
|
400
434
|
)
|
|
401
435
|
}
|
|
402
436
|
);
|
|
403
437
|
}
|
|
404
|
-
function
|
|
405
|
-
const { column:
|
|
406
|
-
return /* @__PURE__ */
|
|
407
|
-
|
|
438
|
+
function Ge(u) {
|
|
439
|
+
const { column: e } = u, [t, i, o] = Y({ hideOnScroll: !0, event: "mousedown" }), [s, n] = z({ top: 0, left: 0 }), h = E(() => s.left > window.innerWidth / 2, [s.left]), l = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "DESC"), g = e.isLeaf && (e.grid.sortColumn !== e.key || e.grid.sortDirection === "ASC"), c = e.isLeaf && e.grid.sortColumn === e.key, w = e.pin !== "LEFT", y = e.pin !== "RIGHT", k = !!e.pin, L = e.isLeaf && e.key !== f, v = e.isLeaf && e.key === f, _ = l || g || c, x = w || y || k;
|
|
440
|
+
return /* @__PURE__ */ r(C, { position: "absolute", right: e.pin === "RIGHT" ? 2.5 : 4, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ d(
|
|
441
|
+
p,
|
|
408
442
|
{
|
|
409
443
|
clean: !0,
|
|
410
|
-
onClick: () => i(!
|
|
444
|
+
onClick: () => i(!t),
|
|
411
445
|
width: 6,
|
|
412
446
|
height: 6,
|
|
413
447
|
cursor: "pointer",
|
|
@@ -421,9 +455,9 @@ function _t(u) {
|
|
|
421
455
|
bgColor: "gray-200",
|
|
422
456
|
hover: { bgColor: "gray-300" },
|
|
423
457
|
children: [
|
|
424
|
-
/* @__PURE__ */
|
|
425
|
-
|
|
426
|
-
|
|
458
|
+
/* @__PURE__ */ r(pe, { fill: "violet-950" }),
|
|
459
|
+
t && /* @__PURE__ */ d(
|
|
460
|
+
J,
|
|
427
461
|
{
|
|
428
462
|
bgColor: "white",
|
|
429
463
|
width: 56,
|
|
@@ -435,13 +469,13 @@ function _t(u) {
|
|
|
435
469
|
mt: 4,
|
|
436
470
|
py: 2,
|
|
437
471
|
overflow: "hidden",
|
|
438
|
-
translateX:
|
|
439
|
-
onPositionChange:
|
|
440
|
-
ref:
|
|
472
|
+
translateX: h ? -55 : -5,
|
|
473
|
+
onPositionChange: n,
|
|
474
|
+
ref: o,
|
|
441
475
|
shadow: "medium-shadow",
|
|
442
476
|
children: [
|
|
443
|
-
|
|
444
|
-
|
|
477
|
+
l && /* @__PURE__ */ d(
|
|
478
|
+
p,
|
|
445
479
|
{
|
|
446
480
|
clean: !0,
|
|
447
481
|
display: "flex",
|
|
@@ -449,15 +483,15 @@ function _t(u) {
|
|
|
449
483
|
p: 3,
|
|
450
484
|
cursor: "pointer",
|
|
451
485
|
hover: { bgColor: "gray-200" },
|
|
452
|
-
onClick: () =>
|
|
486
|
+
onClick: () => e.sortColumn("ASC"),
|
|
453
487
|
children: [
|
|
454
|
-
/* @__PURE__ */
|
|
488
|
+
/* @__PURE__ */ r($, { width: "1rem", fill: "violet-950" }),
|
|
455
489
|
"Sort Ascending"
|
|
456
490
|
]
|
|
457
491
|
}
|
|
458
492
|
),
|
|
459
|
-
|
|
460
|
-
|
|
493
|
+
g && /* @__PURE__ */ d(
|
|
494
|
+
p,
|
|
461
495
|
{
|
|
462
496
|
clean: !0,
|
|
463
497
|
display: "flex",
|
|
@@ -465,15 +499,15 @@ function _t(u) {
|
|
|
465
499
|
p: 3,
|
|
466
500
|
cursor: "pointer",
|
|
467
501
|
hover: { bgColor: "gray-200" },
|
|
468
|
-
onClick: () =>
|
|
502
|
+
onClick: () => e.sortColumn("DESC"),
|
|
469
503
|
children: [
|
|
470
|
-
/* @__PURE__ */
|
|
504
|
+
/* @__PURE__ */ r($, { width: "1rem", fill: "violet-950", rotate: 180 }),
|
|
471
505
|
"Sort Descending"
|
|
472
506
|
]
|
|
473
507
|
}
|
|
474
508
|
),
|
|
475
|
-
|
|
476
|
-
|
|
509
|
+
c && /* @__PURE__ */ d(
|
|
510
|
+
p,
|
|
477
511
|
{
|
|
478
512
|
clean: !0,
|
|
479
513
|
display: "flex",
|
|
@@ -481,16 +515,16 @@ function _t(u) {
|
|
|
481
515
|
p: 3,
|
|
482
516
|
cursor: "pointer",
|
|
483
517
|
hover: { bgColor: "gray-200" },
|
|
484
|
-
onClick: () =>
|
|
518
|
+
onClick: () => e.sortColumn(void 0),
|
|
485
519
|
children: [
|
|
486
|
-
/* @__PURE__ */
|
|
520
|
+
/* @__PURE__ */ r(m, { width: 4 }),
|
|
487
521
|
"Clear Sort"
|
|
488
522
|
]
|
|
489
523
|
}
|
|
490
524
|
),
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
525
|
+
_ && (x || L || v) && /* @__PURE__ */ r(m, { bb: 1, my: 2, borderColor: "gray-300" }),
|
|
526
|
+
w && /* @__PURE__ */ d(
|
|
527
|
+
p,
|
|
494
528
|
{
|
|
495
529
|
clean: !0,
|
|
496
530
|
display: "flex",
|
|
@@ -498,15 +532,15 @@ function _t(u) {
|
|
|
498
532
|
p: 3,
|
|
499
533
|
cursor: "pointer",
|
|
500
534
|
hover: { bgColor: "gray-200" },
|
|
501
|
-
onClick: () =>
|
|
535
|
+
onClick: () => e.pinColumn("LEFT"),
|
|
502
536
|
children: [
|
|
503
|
-
/* @__PURE__ */
|
|
537
|
+
/* @__PURE__ */ r(K, { width: "1rem", fill: "violet-950" }),
|
|
504
538
|
"Pin Left"
|
|
505
539
|
]
|
|
506
540
|
}
|
|
507
541
|
),
|
|
508
|
-
|
|
509
|
-
|
|
542
|
+
y && /* @__PURE__ */ d(
|
|
543
|
+
p,
|
|
510
544
|
{
|
|
511
545
|
clean: !0,
|
|
512
546
|
display: "flex",
|
|
@@ -514,15 +548,15 @@ function _t(u) {
|
|
|
514
548
|
p: 3,
|
|
515
549
|
cursor: "pointer",
|
|
516
550
|
hover: { bgColor: "gray-200" },
|
|
517
|
-
onClick: () =>
|
|
551
|
+
onClick: () => e.pinColumn("RIGHT"),
|
|
518
552
|
children: [
|
|
519
|
-
/* @__PURE__ */
|
|
553
|
+
/* @__PURE__ */ r(K, { width: "1rem", fill: "violet-950", rotate: -90 }),
|
|
520
554
|
"Pin Right"
|
|
521
555
|
]
|
|
522
556
|
}
|
|
523
557
|
),
|
|
524
|
-
|
|
525
|
-
|
|
558
|
+
k && /* @__PURE__ */ d(
|
|
559
|
+
p,
|
|
526
560
|
{
|
|
527
561
|
clean: !0,
|
|
528
562
|
display: "flex",
|
|
@@ -530,20 +564,37 @@ function _t(u) {
|
|
|
530
564
|
p: 3,
|
|
531
565
|
cursor: "pointer",
|
|
532
566
|
hover: { bgColor: "gray-200" },
|
|
533
|
-
onClick: () =>
|
|
567
|
+
onClick: () => e.pinColumn(),
|
|
534
568
|
children: [
|
|
535
|
-
/* @__PURE__ */
|
|
569
|
+
/* @__PURE__ */ r(m, { width: 4 }),
|
|
536
570
|
"Unpin"
|
|
537
571
|
]
|
|
538
572
|
}
|
|
539
573
|
),
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
574
|
+
_ && x && (L || v) && /* @__PURE__ */ r(m, { bb: 1, my: 2, borderColor: "gray-300" }),
|
|
575
|
+
L && /* @__PURE__ */ d(
|
|
576
|
+
p,
|
|
577
|
+
{
|
|
578
|
+
clean: !0,
|
|
579
|
+
display: "flex",
|
|
580
|
+
ai: "center",
|
|
581
|
+
gap: 2,
|
|
582
|
+
p: 3,
|
|
583
|
+
cursor: "pointer",
|
|
584
|
+
hover: { bgColor: "gray-200" },
|
|
585
|
+
onClick: e.toggleGrouping,
|
|
586
|
+
children: [
|
|
587
|
+
/* @__PURE__ */ r(m, { children: /* @__PURE__ */ r(H, { width: "1rem", fill: "violet-950" }) }),
|
|
588
|
+
/* @__PURE__ */ d(m, { textWrap: "nowrap", children: [
|
|
589
|
+
" Group by ",
|
|
590
|
+
e.header ?? e.key
|
|
591
|
+
] })
|
|
592
|
+
]
|
|
593
|
+
}
|
|
594
|
+
),
|
|
595
|
+
v && /* @__PURE__ */ d(p, { clean: !0, display: "flex", gap: 2, p: 3, cursor: "pointer", hover: { bgColor: "gray-200" }, onClick: e.grid.unGroupAll, children: [
|
|
596
|
+
/* @__PURE__ */ r(m, { children: /* @__PURE__ */ r(H, { width: "1rem", fill: "violet-950" }) }),
|
|
597
|
+
/* @__PURE__ */ r(m, { textWrap: "nowrap", children: " Un-Group All" })
|
|
547
598
|
] })
|
|
548
599
|
]
|
|
549
600
|
}
|
|
@@ -552,108 +603,181 @@ function _t(u) {
|
|
|
552
603
|
}
|
|
553
604
|
) });
|
|
554
605
|
}
|
|
555
|
-
function
|
|
556
|
-
const { children:
|
|
557
|
-
return /* @__PURE__ */
|
|
558
|
-
|
|
606
|
+
function N(u) {
|
|
607
|
+
const { children: e, column: t, style: i, ...o } = u, { key: s, pin: n, left: h, right: l, isEdge: g, align: c, widthVarName: w, leftVarName: y, rightVarName: k } = t, L = s === P, v = s === b, _ = s === T, x = n === "LEFT", R = n === "RIGHT", W = x || R, I = x && h === 0, D = x && g, B = R && g, M = R && l === 0, O = !_ && !L;
|
|
608
|
+
return /* @__PURE__ */ d(
|
|
609
|
+
C,
|
|
559
610
|
{
|
|
560
611
|
component: "datagrid.cell",
|
|
561
612
|
props: { role: "cell" },
|
|
562
|
-
variant: {
|
|
563
|
-
jc:
|
|
613
|
+
variant: { isPinned: W, isFirstLeftPinned: I, isLastLeftPinned: D, isFirstRightPinned: B, isLastRightPinned: M, isRowNumber: v, isRowSelection: _ },
|
|
614
|
+
jc: c,
|
|
564
615
|
style: {
|
|
565
|
-
width: `var(${
|
|
566
|
-
left:
|
|
567
|
-
right:
|
|
616
|
+
width: `var(${w})`,
|
|
617
|
+
left: x ? `var(${y})` : void 0,
|
|
618
|
+
right: R ? `var(${k})` : void 0,
|
|
568
619
|
...i
|
|
569
620
|
},
|
|
570
|
-
...
|
|
621
|
+
...o,
|
|
571
622
|
children: [
|
|
572
|
-
O && /* @__PURE__ */
|
|
573
|
-
|
|
623
|
+
O && /* @__PURE__ */ r(m, { px: 4, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: e }),
|
|
624
|
+
_ && e
|
|
574
625
|
]
|
|
575
626
|
}
|
|
576
627
|
);
|
|
577
628
|
}
|
|
578
|
-
function
|
|
579
|
-
const { row:
|
|
580
|
-
return /* @__PURE__ */
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
629
|
+
function Ee(u) {
|
|
630
|
+
const { row: e } = u;
|
|
631
|
+
return /* @__PURE__ */ r(C, { className: "grid-row", display: "contents", props: { role: "rowgroup" }, children: e.cells.map((t) => {
|
|
632
|
+
const { key: i, pin: o, groupColumnWidthVarName: s } = t.column, n = o === "RIGHT";
|
|
633
|
+
if (i === f)
|
|
634
|
+
return /* @__PURE__ */ r(
|
|
635
|
+
N,
|
|
584
636
|
{
|
|
585
|
-
column:
|
|
637
|
+
column: t.column,
|
|
586
638
|
style: {
|
|
587
|
-
width: `var(${
|
|
639
|
+
width: `var(${s})`,
|
|
640
|
+
right: n ? "0" : void 0
|
|
588
641
|
},
|
|
589
|
-
br:
|
|
590
|
-
gridColumn:
|
|
591
|
-
pl: 4 *
|
|
592
|
-
children: /* @__PURE__ */
|
|
642
|
+
br: e.groupingColumn.pin === "LEFT" ? 1 : void 0,
|
|
643
|
+
gridColumn: e.groupingColumnGridColumn,
|
|
644
|
+
pl: 4 * e.depth,
|
|
645
|
+
children: /* @__PURE__ */ r(p, { display: "contents", clean: !0, onClick: () => e.toggleRow(), cursor: "pointer", children: t.value })
|
|
593
646
|
},
|
|
594
|
-
|
|
647
|
+
i
|
|
595
648
|
);
|
|
596
|
-
if (
|
|
597
|
-
return /* @__PURE__ */
|
|
598
|
-
if (
|
|
599
|
-
return /* @__PURE__ */
|
|
649
|
+
if (i === T)
|
|
650
|
+
return /* @__PURE__ */ r(N, { column: t.column, children: /* @__PURE__ */ r(S, { m: 1 }) }, i);
|
|
651
|
+
if (o !== e.groupingColumn.pin || i === P || i === b)
|
|
652
|
+
return /* @__PURE__ */ r(N, { column: t.column, children: t.value }, i);
|
|
600
653
|
}) });
|
|
601
654
|
}
|
|
602
|
-
function
|
|
603
|
-
const { row:
|
|
604
|
-
return /* @__PURE__ */
|
|
655
|
+
function Pe(u) {
|
|
656
|
+
const { row: e } = u;
|
|
657
|
+
return /* @__PURE__ */ r(C, { className: "grid-row", display: "contents", props: { role: "row" }, children: e.cells.map((t) => /* @__PURE__ */ r(N, { column: t.column, children: t.column.key === T ? /* @__PURE__ */ r(S, {}) : t.value }, t.column.key)) });
|
|
605
658
|
}
|
|
606
|
-
function
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
659
|
+
function We(u) {
|
|
660
|
+
const { grid: e } = u, t = E(() => e.groupColumns.length === 0 ? null : e.groupColumns.map((i, o) => {
|
|
661
|
+
const s = e.columns.value.leafs.findOrThrow((n) => n.key === i);
|
|
662
|
+
return /* @__PURE__ */ d(he.Fragment, { children: [
|
|
663
|
+
">",
|
|
664
|
+
/* @__PURE__ */ d(C, { component: "datagrid.columnGroups.item", children: [
|
|
665
|
+
s.header ?? s.key,
|
|
666
|
+
/* @__PURE__ */ r(p, { component: "datagrid.columnGroups.item.icon", onClick: () => e.toggleGrouping(s.key), children: /* @__PURE__ */ r(fe, { fill: "currentColor", width: "100%" }) })
|
|
667
|
+
] })
|
|
668
|
+
] }, i);
|
|
669
|
+
}), [e.groupColumns]);
|
|
670
|
+
return /* @__PURE__ */ d(C, { component: "datagrid.columnGroups", position: "relative", children: [
|
|
671
|
+
/* @__PURE__ */ r(Ie, { grid: e }),
|
|
672
|
+
t && /* @__PURE__ */ r(H, { width: "1rem", fill: "violet-950" }),
|
|
673
|
+
t,
|
|
674
|
+
/* @__PURE__ */ d(C, { position: "absolute", justifySelf: "flex-end", right: 2, top: 2, className: "parent", children: [
|
|
675
|
+
/* @__PURE__ */ r(C, { position: "absolute", width: 8, height: 8, right: 0, jc: "center", children: /* @__PURE__ */ r(Ce, { fill: "violet-950", width: "1rem" }) }),
|
|
676
|
+
/* @__PURE__ */ r(ve, { placeholder: "Search...", height: 8, width: 50, zIndex: 1, bgColor: "transparent" })
|
|
677
|
+
] })
|
|
678
|
+
] });
|
|
679
|
+
}
|
|
680
|
+
function Ie(u) {
|
|
681
|
+
const { grid: e } = u, [t, i, o] = Y({ event: "mousedown" }), s = E(
|
|
682
|
+
() => e.columns.value.leafs.filter(
|
|
683
|
+
(n) => ![P, b, T, f].includes(n.key)
|
|
684
|
+
),
|
|
685
|
+
[e.columns.value.leafs]
|
|
686
|
+
);
|
|
687
|
+
return /* @__PURE__ */ d(p, { clean: !0, cursor: "pointer", p: 1, hover: { bgColor: "gray-200", borderRadius: 1 }, onClick: () => i(!t), children: [
|
|
688
|
+
/* @__PURE__ */ r(ye, { viewBox: "0 0 24 24", width: "20", fill: "currentColor", ...u, children: /* @__PURE__ */ r("path", { d: "M5 6h14M5 12h14M5 18h14", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }),
|
|
689
|
+
t && /* @__PURE__ */ r(
|
|
690
|
+
J,
|
|
691
|
+
{
|
|
692
|
+
bgColor: "white",
|
|
693
|
+
width: 56,
|
|
694
|
+
b: 1,
|
|
695
|
+
borderColor: "gray-300",
|
|
696
|
+
borderRadius: 1,
|
|
697
|
+
display: "flex",
|
|
698
|
+
d: "column",
|
|
699
|
+
mt: 4,
|
|
700
|
+
py: 2,
|
|
701
|
+
translateX: -1,
|
|
702
|
+
shadow: "medium-shadow",
|
|
703
|
+
ref: o,
|
|
704
|
+
overflow: "auto",
|
|
705
|
+
maxHeight: 100,
|
|
706
|
+
children: s.map((n) => /* @__PURE__ */ d(
|
|
707
|
+
p,
|
|
708
|
+
{
|
|
709
|
+
clean: !0,
|
|
710
|
+
display: "flex",
|
|
711
|
+
gap: 2,
|
|
712
|
+
p: 3,
|
|
713
|
+
cursor: "pointer",
|
|
714
|
+
hover: { bgColor: "gray-200" },
|
|
715
|
+
onClick: (h) => {
|
|
716
|
+
h.stopPropagation(), n.toggleVisibility();
|
|
717
|
+
},
|
|
718
|
+
children: [
|
|
719
|
+
/* @__PURE__ */ r(S, { checked: n.isVisible, onChange: () => {
|
|
720
|
+
}, focus: { outline: 0 } }),
|
|
721
|
+
n.header ?? n.key
|
|
722
|
+
]
|
|
723
|
+
},
|
|
724
|
+
n.key
|
|
725
|
+
))
|
|
726
|
+
}
|
|
727
|
+
)
|
|
728
|
+
] });
|
|
729
|
+
}
|
|
730
|
+
function je(u) {
|
|
731
|
+
const e = _e(u), { isResizeMode: t } = e, i = E(() => (console.log("render - headers"), e.headerRows.value.map((n) => n.map((h) => /* @__PURE__ */ r(xe, { column: h }, h.uniqueKey)))), [e.headerRows.value]), o = de(null), s = ge(
|
|
732
|
+
q.throttle((n) => {
|
|
733
|
+
var h;
|
|
734
|
+
(h = o.current) == null || h.setScrollTop(n.target.scrollTop);
|
|
611
735
|
}, 100),
|
|
612
|
-
[
|
|
736
|
+
[o.current]
|
|
613
737
|
);
|
|
614
|
-
return console.log("render - data grid"), /* @__PURE__ */
|
|
615
|
-
/* @__PURE__ */
|
|
616
|
-
/* @__PURE__ */
|
|
617
|
-
/* @__PURE__ */
|
|
618
|
-
/* @__PURE__ */
|
|
738
|
+
return console.log("render - data grid"), /* @__PURE__ */ d(m, { component: "datagrid", style: e.sizes.value, props: { role: "presentation" }, children: [
|
|
739
|
+
/* @__PURE__ */ r(We, { grid: e }),
|
|
740
|
+
/* @__PURE__ */ d(m, { overflowX: "scroll", props: { onScroll: s }, children: [
|
|
741
|
+
/* @__PURE__ */ r(j, { component: "datagrid.header", variant: { isResizeMode: t }, style: { gridTemplateColumns: e.gridTemplateColumns.value }, children: i }),
|
|
742
|
+
/* @__PURE__ */ r(Ne, { ref: o, grid: e })
|
|
619
743
|
] }),
|
|
620
|
-
/* @__PURE__ */
|
|
744
|
+
/* @__PURE__ */ d(m, { p: 3, bgColor: "gray-200", bt: 1, borderColor: "gray-400", children: [
|
|
621
745
|
"Rows: ",
|
|
622
|
-
|
|
746
|
+
u.data.length
|
|
623
747
|
] })
|
|
624
748
|
] });
|
|
625
749
|
}
|
|
626
|
-
const
|
|
627
|
-
function
|
|
628
|
-
const { grid:
|
|
629
|
-
|
|
630
|
-
setScrollTop:
|
|
750
|
+
const Z = 10, ee = 25, Ve = Z + ee * 2;
|
|
751
|
+
function De(u, e) {
|
|
752
|
+
const { grid: t } = u, i = we * t.ROW_HEIGHT, [o, s] = z(0), n = Math.max(0, Math.floor(o / i) - ee), h = E(() => (console.log("render - rows"), t.flatRows.value.take(Ve, n).map((c) => c instanceof Q ? /* @__PURE__ */ r(Ee, { row: c }, c.rowKey) : /* @__PURE__ */ r(Pe, { row: c }, c.rowKey))), [t.flatRows.value, n]);
|
|
753
|
+
me(e, () => ({
|
|
754
|
+
setScrollTop: s
|
|
631
755
|
}));
|
|
632
|
-
const
|
|
633
|
-
return /* @__PURE__ */
|
|
634
|
-
|
|
756
|
+
const l = t.flatRows.value.length;
|
|
757
|
+
return /* @__PURE__ */ r(m, { height: t.ROW_HEIGHT * Z + 4, children: /* @__PURE__ */ r(
|
|
758
|
+
m,
|
|
635
759
|
{
|
|
636
760
|
style: {
|
|
637
|
-
height: `${
|
|
761
|
+
height: `${l * i}px`
|
|
638
762
|
},
|
|
639
|
-
children: /* @__PURE__ */
|
|
640
|
-
|
|
763
|
+
children: /* @__PURE__ */ r(
|
|
764
|
+
j,
|
|
641
765
|
{
|
|
642
766
|
props: { role: "presentation" },
|
|
643
767
|
width: "max-content",
|
|
644
768
|
minWidth: "fit",
|
|
645
769
|
transition: "none",
|
|
646
770
|
style: {
|
|
647
|
-
transform: `translateY(${
|
|
648
|
-
gridTemplateColumns:
|
|
771
|
+
transform: `translateY(${n * i}px)`,
|
|
772
|
+
gridTemplateColumns: t.gridTemplateColumns.value
|
|
649
773
|
},
|
|
650
|
-
children:
|
|
774
|
+
children: h
|
|
651
775
|
}
|
|
652
776
|
)
|
|
653
777
|
}
|
|
654
778
|
) });
|
|
655
779
|
}
|
|
656
|
-
const
|
|
780
|
+
const Ne = ce(De);
|
|
657
781
|
export {
|
|
658
|
-
|
|
782
|
+
je as default
|
|
659
783
|
};
|