@cronocode/react-box 3.0.15 → 3.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +1,58 @@
1
- var ot = Object.defineProperty;
2
- var st = (u, t, e) => t in u ? ot(u, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[t] = e;
3
- var l = (u, t, e) => st(u, typeof t != "symbol" ? t + "" : t, e);
4
- import { jsx as s, jsxs as g, Fragment as rt } from "react/jsx-runtime";
5
- import p from "../box.mjs";
6
- import X from "./grid.mjs";
7
- import { useMemo as N, useState as H, forwardRef as lt, useRef as ut, useCallback as at, useImperativeHandle as ht } from "react";
8
- import { F as j, m as I, A as B, b as ct, D as dt, P as K, G as pt, d as gt } from "../core.mjs";
9
- import _ from "./button.mjs";
10
- import b from "./flex.mjs";
11
- import mt from "./tooltip.mjs";
12
- import V from "./checkbox.mjs";
13
- const ft = "NO_PIN";
14
- class T {
15
- constructor(t, e, i) {
16
- l(this, "columns", []);
17
- l(this, "_pin");
18
- l(this, "_inlineWidth");
19
- l(this, "resizeColumn", (t) => {
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 e = t.pageX, { MIN_COLUMN_WIDTH_PX: i, update: n } = this.grid, o = this.leafs.sumBy((h) => h.inlineWidth) - this.leafs.length * i, r = this.leafs.toRecord((h) => [h.key, h.inlineWidth]), d = j.throttle((h) => {
22
- const m = (h.pageX - e) * (this.pin === "RIGHT" ? -1 : 1);
23
- this.leafs.forEach((f) => {
24
- const y = r[f.key], v = o > 0 ? (y - i) / o * m : m / this.leafs.length, R = Math.round(y + v);
25
- f.setWidth(R < i ? i : R);
26
- }), this.grid.headerRows.clear(), this.grid.sizes.clear(), n();
27
- }, 20), a = new AbortController(), c = (h) => {
28
- a.abort(), this.grid.isResizeMode = !1, n();
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", d, a), window.addEventListener("mouseup", c, a);
32
+ window.addEventListener("mousemove", h, l), window.addEventListener("mouseup", g, l);
31
33
  });
32
- l(this, "pinColumn", (t) => {
33
- this.isLeaf ? this._pin = t : this.columns.forEach((e) => e.pinColumn(t)), this.grid.pinColumn(this.uniqueKey, t);
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
- l(this, "toggleGrouping", () => {
37
+ a(this, "toggleGrouping", () => {
36
38
  this.grid.toggleGrouping(this.key);
37
39
  });
38
- l(this, "sortColumn", (...t) => {
39
- this.grid.setSortColumn(this.key, ...t);
40
+ a(this, "sortColumn", (...e) => {
41
+ this.grid.setSortColumn(this.key, ...e);
40
42
  });
41
- l(this, "setWidth", (t) => {
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 !== t && (this._inlineWidth = t, this.grid.setWidth(this.key, t));
46
+ this._inlineWidth !== e && (this._inlineWidth = e, this.grid.setWidth(this.key, e));
45
47
  });
46
- var n;
47
- this.def = t, this.grid = e, this.parent = i, this.columns = ((n = t.columns) == null ? void 0 : n.map((o) => new T(t.pin ? { ...o, pin: t.pin } : o, e, this))) ?? [], this.isLeaf && (this._inlineWidth = this.key == E ? void 0 : this.def.width ?? this.grid.DEFAULT_COLUMN_WIDTH_PX, this._pin = t.pin);
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 t = [...new Set(this.columns.flatMap((e) => e.pin))];
64
- if (t.length === 1) return t[0];
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(t) {
70
- if (this.hasPin(t)) {
77
+ getPinnedColumn(e) {
78
+ if (this.hasPin(e)) {
71
79
  if (this.isLeaf) return this;
72
- const e = new T({ ...this.def, pin: t }, this.grid, this.parent);
73
- return e.columns = this.columns.filter((i) => i.hasPin(t)).map((i) => {
74
- const n = i.getPinnedColumn(t);
75
- return n.parent = e, n;
76
- }).filter((i) => !!i), e;
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(t) {
80
- return this.isLeaf ? this._pin === t : this.columns.some((e) => e.hasPin(t));
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 t = [this];
87
- return t.push(...this.columns.flatMap((e) => e.flatColumns)), t;
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 t = this.columns.map((e) => e.inlineWidth).filter((e) => typeof e == "number");
92
- if (t.length !== 0)
93
- return t.sumBy((e) => e);
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 t = 0;
104
+ let e = 0;
97
105
  if (this.parent) {
98
- const e = this.parent.columns.findIndex((i) => i === this);
99
- t += this.parent.columns.sumBy((i, n) => n < e ? i.inlineWidth ?? 0 : 0), t += this.parent.left;
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 e = this.grid.columns.value.left.findIndex((i) => i === this);
102
- t += this.grid.columns.value.left.sumBy((i, n) => n < e ? i.inlineWidth ?? 0 : 0);
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 t;
112
+ return e;
105
113
  }
106
114
  get right() {
107
- let t = 0;
115
+ let e = 0;
108
116
  if (this.parent) {
109
- const e = [...this.parent.columns].reverse(), i = e.findIndex((n) => n === this);
110
- t += e.sumBy((n, o) => o < i ? n.inlineWidth ?? 0 : 0), t += this.parent.right;
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 e = [...this.grid.columns.value.right].reverse(), i = e.findIndex((n) => n === this);
113
- t += e.sumBy((n, o) => o < i ? n.inlineWidth ?? 0 : 0);
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 t;
123
+ return e;
116
124
  }
117
125
  get isEdge() {
118
- return this.pin ? this.parent ? (this.pin === "LEFT" ? this.parent.columns.at(-1) : this.parent.columns.at(0)) === this && this.parent.isEdge : (this.pin === "LEFT" ? this.grid.columns.value.left.at(-1) : this.grid.columns.value.right.at(0)) === this : !1;
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.columns.flatMap((t) => t.leafs);
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.headerRows.value.length - this.death : 1;
153
+ return this.isLeaf ? this.grid.columns.value.maxDeath - this.death : 1;
138
154
  }
139
155
  }
140
- class wt {
141
- constructor(t, e, i) {
142
- this.grid = t, this.row = e, this.column = i;
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 === L ? this.row.rowIndex + 1 : this.column.key === C ? `> ${this.row.groupValue} (${this.row.count})` : null;
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 q {
149
- constructor(t, e, i, n, o) {
150
- l(this, "parentRow");
151
- this.grid = t, this.groupColumn = e, this.rows = i, this.rowIndex = n, this.groupValue = o, i.forEach((r) => r.parentRow = this);
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 t;
155
- return `${((t = this.parentRow) == null ? void 0 : t.rowKey) ?? ""}${this.groupColumn.key}${this.groupValue}`;
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.leafs.map((t) => new wt(this.grid, this, t));
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((t) => t.count, 0);
183
+ return this.rows.sumBy((e) => e.count, 0);
168
184
  }
169
185
  get flatRows() {
170
- return this.expanded ? [this, ...this.rows.flatMap((t) => t.flatRows)] : [this];
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((t) => t.key === C);
189
+ return this.grid.columns.value.leafs.findOrThrow((e) => e.key === f);
174
190
  }
175
191
  get groupingColumnGridColumn() {
176
- const { leafs: t } = this.grid.columns.value, { groupingColumn: e } = this;
177
- return t.sumBy(
178
- (n) => n.pin === e.pin && n.key !== E && n.key !== x && n.key !== L ? 1 : 0
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 Ct {
186
- constructor(t, e, i) {
187
- this.grid = t, this.row = e, this.column = i;
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 === E ? null : this.column.key === L ? this.row.rowIndex + 1 : this.row.row[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 U {
194
- constructor(t, e, i) {
195
- l(this, "parentRow");
196
- this.grid = t, this.row = e, this.rowIndex = i, this.grid = t, this.row = e;
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.leafs.map((t) => new Ct(this.grid, this, t));
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: t } = this.grid.props.def, e = t ? typeof t == "function" ? t(this.row) : this.row[t] : this.rowIndex;
213
- return `${((i = this.parentRow) == null ? void 0 : i.rowKey) ?? ""}${e}`;
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 E = "empty-cell", L = "row-number-cell", x = "row-selection-cell", C = "grouping-cell";
217
- class yt {
218
- constructor(t, e) {
219
- l(this, "_sourceColumns", []);
220
- l(this, "columns", I(() => {
221
- const t = this._sourceColumns.map((r) => r.getPinnedColumn("LEFT")).filter((r) => !!r), e = this._sourceColumns.map((r) => r.getPinnedColumn()).filter((r) => !!r), i = this._sourceColumns.map((r) => r.getPinnedColumn("RIGHT")).filter((r) => !!r), n = [...t, ...e, ...i].flatMap((r) => r.flatColumns), o = n.filter((r) => r.isLeaf);
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: t,
224
- middle: e,
239
+ left: e,
240
+ middle: t,
225
241
  right: i,
226
- flat: n,
227
- leafs: o
242
+ flat: o,
243
+ leafs: s,
244
+ visibleLeafs: n,
245
+ maxDeath: h
228
246
  };
229
247
  }));
230
- l(this, "headerRows", I(() => this.columns.value.flat.groupBy((e) => e.death).sortBy((e) => e.key).map((e) => {
231
- const i = e.values.groupBy((n) => n.pin ?? ft).toRecord((n) => [n.key, n.values]);
232
- return [...i.LEFT ?? [], ...i.NO_PIN ?? [], ...i.RIGHT ?? []];
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
- l(this, "gridTemplateColumns", I(() => {
235
- const t = this.columns.value.leafs.sumBy((o) => o.pin === "RIGHT" ? 1 : 0), e = this.columns.value.leafs.length - t - 1, i = e > 0 ? `repeat(${e}, max-content)` : "", n = t > 0 ? `repeat(${t}, max-content)` : "";
236
- return `${i} auto ${n}`;
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
- l(this, "rows", I(() => {
239
- let t = this.props.data;
240
- if (this._sortColumn && (t = t.sortBy((e) => e[this._sortColumn], this._sortDirection)), this.groupColumns.length > 0) {
241
- const e = (i, n, o) => {
242
- const r = n[0];
243
- n = n.removeBy((a) => a === r);
244
- const d = this.columns.value.leafs.findOrThrow((a) => a.key === r);
245
- return this._sortColumn === C && (i = i.sortBy((a) => a[r], this._sortDirection)), i.groupBy((a) => a[r]).map((a) => {
246
- let c;
247
- n.length > 0 ? c = e(a.values, n, o + 1) : c = a.values.map((m, f) => new U(this, m, o + 1 + f));
248
- const h = new q(this, d, c, o, a.key);
249
- return o += 1, h.expanded && (o += c.length), h;
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(t, this.groupColumns, 0);
275
+ return t(e, this.groupColumns, 0);
253
276
  }
254
- return t.map((e, i) => new U(this, e, i));
277
+ return e.map((t, i) => new X(this, t, i));
255
278
  }));
256
- l(this, "flatRows", I(() => this.rows.value.flatMap((t) => t.flatRows)));
257
- l(this, "sizes", I(() => {
279
+ a(this, "flatRows", V(() => this.rows.value.flatMap((e) => e.flatRows)));
280
+ a(this, "sizes", V(() => {
258
281
  console.log("sizes");
259
- const t = this.columns.value.flat.reduce((i, n) => {
260
- const { inlineWidth: o } = n;
261
- return typeof o == "number" && (i[n.widthVarName] = `${n.inlineWidth}px`), n.pin === "LEFT" && (i[n.leftVarName] = `${n.left}px`), n.pin === "RIGHT" && (i[n.rightVarName] = `${n.right}px`), i;
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
- t[this.leftEdgeVarName] = `${this.leftEdge}px`;
264
- const e = this.columns.value.leafs.find((i) => i.key === C);
265
- return e && (t[e.groupColumnWidthVarName] = `${this.columns.value.leafs.sumBy((i) => i.pin === e.pin && i.key !== L && i.key !== x ? i.inlineWidth ?? 0 : 0)}px`), this.groupColumns.forEach((i) => {
266
- const n = this.columns.value.leafs.findOrThrow((o) => o.key === i);
267
- t[n.groupColumnWidthVarName] = `${this.columns.value.leafs.sumBy((o) => o.pin === n.pin ? o.inlineWidth ?? 0 : 0)}px`;
268
- }), t;
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
- l(this, "ROW_HEIGHT", 12);
271
- l(this, "MIN_COLUMN_WIDTH_PX", 48);
272
- l(this, "DEFAULT_COLUMN_WIDTH_PX", 200);
273
- l(this, "isResizeMode", !1);
274
- l(this, "expandedGroupRow", {});
275
- l(this, "leftEdgeVarName", "--left-edge");
276
- l(this, "setSortColumn", (t, ...e) => {
277
- if (e.length > 0)
278
- [this._sortDirection] = e, this._sortColumn = this._sortDirection ? t : void 0;
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: n } = this;
281
- this._sortColumn = i === t && n === "DESC" ? void 0 : t, this._sortDirection = i === t && n === "ASC" ? "DESC" : "ASC";
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
- l(this, "pinColumn", (t, e) => {
286
- const i = this.columns.value.flat.findOrThrow((n) => n.uniqueKey === t);
287
- i.pin !== e && i.pinColumn(e), this.columns.clear(), this.headerRows.clear(), this.gridTemplateColumns.clear(), this.rows.clear(), this.flatRows.clear(), this.sizes.clear(), this.update();
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
- l(this, "toggleGrouping", (t) => {
290
- this.groupColumns.includes(t) ? this.groupColumns = this.groupColumns.removeBy((i) => i === t) : this.groupColumns = this.groupColumns.add(t);
291
- const e = this._sourceColumns.find((i) => i.key === C);
292
- if (this.groupColumns.length > 0 && !e) {
293
- const i = this._sourceColumns.sumBy((n) => n.key === L || n.key === x ? 1 : 0);
294
- this._sourceColumns.splice(i, 0, new T({ key: C }, this));
295
- } else this.groupColumns.length === 0 && e && (this._sourceColumns = this._sourceColumns.removeBy((i) => i.key === C));
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
- l(this, "toggleGroupRow", (t) => {
299
- t in this.expandedGroupRow ? delete this.expandedGroupRow[t] : this.expandedGroupRow[t] = !0, this.rows.clear(), this.flatRows.clear(), this.update();
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
- l(this, "setWidth", (t, e) => {
302
- const i = this.columns.value.leafs.find((o) => o.key === t);
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(e), this._sourceColumns.flatMap((o) => o.flatColumns).findOrThrow((o) => o.key === t).setWidth(e);
338
+ i.setWidth(t), this._sourceColumns.flatMap((s) => s.flatColumns).findOrThrow((s) => s.key === e).setWidth(t);
306
339
  });
307
- l(this, "groupColumns", []);
308
- l(this, "_sortColumn");
309
- l(this, "_sortDirection", "ASC");
310
- this.props = t, this.update = e, this._sourceColumns = t.def.columns.map((i) => new T(i, this)), this._sourceColumns.push(new T({ key: E }, this)), this._sourceColumns.unshift(new T({ key: x, width: 50, align: "center" }, this)), this._sourceColumns.unshift(new T({ key: L, pin: "LEFT", width: 70, align: "right" }, this));
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((t) => t.inlineWidth ?? 0);
347
+ return this.columns.value.left.sumBy((e) => e.inlineWidth ?? 0);
314
348
  }
315
349
  get rightEdge() {
316
- return this.columns.value.right.sumBy((t) => t.inlineWidth ?? 0);
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 vt(u) {
326
- const t = N(() => new yt(u, () => i((o) => o + 1)), [u]), [e, i] = H(0);
327
- return N(() => Object.create(Object.getPrototypeOf(t), Object.getOwnPropertyDescriptors(t)), [t, e]);
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 Rt(u) {
330
- const { column: t } = u, { key: e, pin: i, left: n, right: o, isEdge: r, isLeaf: d, leafs: a, grid: c, header: h, gridRows: m, widthVarName: f, leftVarName: y, rightVarName: v, inlineWidth: R } = t, k = e === E, G = e === C, w = e === L, P = e === x, W = i === "LEFT", D = i === "RIGHT", M = W || i === "RIGHT", S = W && n === 0, O = W && r, Q = D && r, Z = D && o === 0, z = d && !k && !w && !P, tt = d ? 1 : a.length, et = !w && !P, A = !w && !P, it = N(() => {
331
- if (w) return null;
332
- if (P) return /* @__PURE__ */ s(V, { m: 1 });
333
- if (G) {
334
- if (c.groupColumns.length === 1) {
335
- const F = c.columns.value.leafs.findOrThrow((nt) => nt.key === c.groupColumns[0]);
336
- return F.header ?? F.key;
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 h ?? e;
341
- }, [c.groupColumns]);
342
- return /* @__PURE__ */ s(
343
- b,
374
+ return c ?? t;
375
+ }, [g.groupColumns]);
376
+ return /* @__PURE__ */ r(
377
+ C,
344
378
  {
345
379
  component: "datagrid.header.cell",
346
- variant: { isRowNumber: w, isPinned: M, isFirstLeftPinned: S, isLastLeftPinned: O, isFirstRightPinned: Q, isLastRightPinned: Z, isSortable: z },
347
- gridRow: m,
348
- gridColumn: tt,
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(${f})`,
351
- left: W ? `var(${y})` : void 0,
352
- right: D ? `var(${v})` : void 0
384
+ width: `var(${y})`,
385
+ left: I ? `var(${k})` : void 0,
386
+ right: D ? `var(${L})` : void 0
353
387
  },
354
- children: !k && /* @__PURE__ */ g(rt, { children: [
355
- /* @__PURE__ */ s(b, { width: "fit", height: "fit", jc: t.align, props: { onClick: z ? () => t.sortColumn() : void 0 }, children: /* @__PURE__ */ g(
356
- b,
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: d ? void 0 : "sticky",
393
+ position: h ? void 0 : "sticky",
360
394
  ai: "center",
361
395
  transition: "none",
362
- pl: t.align ? void 0 : 4,
396
+ pl: e.align ? void 0 : 4,
363
397
  style: {
364
- left: i ? void 0 : `var(${c.leftEdgeVarName})`
398
+ left: i ? void 0 : `var(${g.leftEdgeVarName})`
365
399
  },
366
400
  children: [
367
- /* @__PURE__ */ s(p, { overflow: "hidden", textOverflow: "ellipsis", textWrap: "nowrap", children: it }),
368
- e === c.sortColumn && /* @__PURE__ */ s(p, { pl: (R ?? 0) < 58 ? 0 : 2, children: /* @__PURE__ */ s(B, { width: "16px", rotate: c.sortDirection === "ASC" ? 0 : 180, fill: "violet-950" }) }),
369
- A && /* @__PURE__ */ s(p, { minWidth: 12 })
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
- et && /* @__PURE__ */ s(kt, { column: t }),
374
- A && /* @__PURE__ */ s(_t, { column: t })
407
+ oe && /* @__PURE__ */ r(Te, { column: e }),
408
+ F && /* @__PURE__ */ r(Ge, { column: e })
375
409
  ] })
376
410
  }
377
411
  );
378
412
  }
379
- function kt(u) {
380
- const { column: t } = u;
381
- return /* @__PURE__ */ s(
382
- b,
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: t.pin === "RIGHT" ? void 0 : 0,
388
- left: t.pin !== "RIGHT" ? void 0 : 0,
421
+ right: e.pin === "RIGHT" ? void 0 : 0,
422
+ left: e.pin !== "RIGHT" ? void 0 : 0,
389
423
  py: 3,
390
- children: /* @__PURE__ */ s(
391
- p,
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: t.resizeColumn, onTouchStart: t.resizeColumn },
398
- children: /* @__PURE__ */ s(p, { width: 0.5, height: "fit", bgColor: "gray-400", hoverGroup: { resizer: { bgColor: "gray-600" } } })
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 _t(u) {
405
- const { column: t } = u, [e, i, n] = ct({ hideOnScroll: !0, event: "mousedown" }), [o, r] = H({ top: 0, left: 0 }), d = N(() => o.left > window.innerWidth / 2, [o.left]), a = t.isLeaf && (t.grid.sortColumn !== t.key || t.grid.sortDirection === "DESC"), c = t.isLeaf && (t.grid.sortColumn !== t.key || t.grid.sortDirection === "ASC"), h = t.isLeaf && t.grid.sortColumn === t.key, m = t.pin !== "LEFT", f = t.pin !== "RIGHT", y = !!t.pin, v = t.isLeaf && t.key !== C, R = a || c || h, k = m || f || y;
406
- return /* @__PURE__ */ s(b, { position: "absolute", right: t.pin === "RIGHT" ? 2.5 : 4, top: "1/2", translateY: -3, ai: "center", children: /* @__PURE__ */ g(
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(!e),
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__ */ s(dt, { fill: "violet-950" }),
425
- e && /* @__PURE__ */ g(
426
- mt,
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: d ? -55 : -5,
439
- onPositionChange: r,
440
- ref: n,
472
+ translateX: h ? -55 : -5,
473
+ onPositionChange: n,
474
+ ref: o,
441
475
  shadow: "medium-shadow",
442
476
  children: [
443
- a && /* @__PURE__ */ g(
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: () => t.sortColumn("ASC"),
486
+ onClick: () => e.sortColumn("ASC"),
453
487
  children: [
454
- /* @__PURE__ */ s(B, { width: "1rem", fill: "violet-950" }),
488
+ /* @__PURE__ */ r($, { width: "1rem", fill: "violet-950" }),
455
489
  "Sort Ascending"
456
490
  ]
457
491
  }
458
492
  ),
459
- c && /* @__PURE__ */ g(
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: () => t.sortColumn("DESC"),
502
+ onClick: () => e.sortColumn("DESC"),
469
503
  children: [
470
- /* @__PURE__ */ s(B, { width: "1rem", fill: "violet-950", rotate: 180 }),
504
+ /* @__PURE__ */ r($, { width: "1rem", fill: "violet-950", rotate: 180 }),
471
505
  "Sort Descending"
472
506
  ]
473
507
  }
474
508
  ),
475
- h && /* @__PURE__ */ g(
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: () => t.sortColumn(void 0),
518
+ onClick: () => e.sortColumn(void 0),
485
519
  children: [
486
- /* @__PURE__ */ s(p, { width: 4 }),
520
+ /* @__PURE__ */ r(m, { width: 4 }),
487
521
  "Clear Sort"
488
522
  ]
489
523
  }
490
524
  ),
491
- R && (k || v) && /* @__PURE__ */ s(p, { bb: 1, my: 2, borderColor: "gray-300" }),
492
- m && /* @__PURE__ */ g(
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: () => t.pinColumn("LEFT"),
535
+ onClick: () => e.pinColumn("LEFT"),
502
536
  children: [
503
- /* @__PURE__ */ s(K, { width: "1rem", fill: "violet-950" }),
537
+ /* @__PURE__ */ r(K, { width: "1rem", fill: "violet-950" }),
504
538
  "Pin Left"
505
539
  ]
506
540
  }
507
541
  ),
508
- f && /* @__PURE__ */ g(
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: () => t.pinColumn("RIGHT"),
551
+ onClick: () => e.pinColumn("RIGHT"),
518
552
  children: [
519
- /* @__PURE__ */ s(K, { width: "1rem", fill: "violet-950", rotate: -90 }),
553
+ /* @__PURE__ */ r(K, { width: "1rem", fill: "violet-950", rotate: -90 }),
520
554
  "Pin Right"
521
555
  ]
522
556
  }
523
557
  ),
524
- y && /* @__PURE__ */ g(
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: () => t.pinColumn(),
567
+ onClick: () => e.pinColumn(),
534
568
  children: [
535
- /* @__PURE__ */ s(p, { width: 4 }),
569
+ /* @__PURE__ */ r(m, { width: 4 }),
536
570
  "Unpin"
537
571
  ]
538
572
  }
539
573
  ),
540
- R && k && v && /* @__PURE__ */ s(p, { bb: 1, my: 2, borderColor: "gray-300" }),
541
- v && /* @__PURE__ */ g(_, { clean: !0, display: "flex", gap: 2, p: 3, cursor: "pointer", hover: { bgColor: "gray-200" }, onClick: t.toggleGrouping, children: [
542
- /* @__PURE__ */ s(p, { children: /* @__PURE__ */ s(pt, { width: "1rem", fill: "violet-950" }) }),
543
- /* @__PURE__ */ g(p, { textWrap: "nowrap", children: [
544
- " Group by ",
545
- t.header ?? t.key
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 $(u) {
556
- const { children: t, column: e, style: i, ...n } = u, { key: o, pin: r, left: d, right: a, isEdge: c, align: h, widthVarName: m, leftVarName: f, rightVarName: y } = e, v = o === E, R = o === L, k = o === x, G = r === "LEFT", w = r === "RIGHT", P = G || w, W = G && d === 0, D = G && c, M = w && c, S = w && a === 0, O = !k && !v;
557
- return /* @__PURE__ */ g(
558
- b,
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: { isRowNumber: R, isRowSelection: k, isPinned: P, isFirstLeftPinned: W, isLastLeftPinned: D, isFirstRightPinned: M, isLastRightPinned: S },
563
- jc: h,
613
+ variant: { isPinned: W, isFirstLeftPinned: I, isLastLeftPinned: D, isFirstRightPinned: B, isLastRightPinned: M, isRowNumber: v, isRowSelection: _ },
614
+ jc: c,
564
615
  style: {
565
- width: `var(${m})`,
566
- left: G ? `var(${f})` : void 0,
567
- right: w ? `var(${y})` : void 0,
616
+ width: `var(${w})`,
617
+ left: x ? `var(${y})` : void 0,
618
+ right: R ? `var(${k})` : void 0,
568
619
  ...i
569
620
  },
570
- ...n,
621
+ ...o,
571
622
  children: [
572
- O && /* @__PURE__ */ s(p, { px: 4, textOverflow: "ellipsis", overflow: "hidden", textWrap: "nowrap", children: t }),
573
- k && t
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 Lt(u) {
579
- const { row: t } = u;
580
- return /* @__PURE__ */ s(b, { className: "grid-row", display: "contents", props: { role: "rowgroup" }, children: t.cells.map((e) => {
581
- if (e.column.key === C)
582
- return /* @__PURE__ */ s(
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: e.column,
637
+ column: t.column,
586
638
  style: {
587
- width: `var(${e.column.groupColumnWidthVarName})`
639
+ width: `var(${s})`,
640
+ right: n ? "0" : void 0
588
641
  },
589
- br: t.groupingColumn.pin === "LEFT" ? 1 : void 0,
590
- gridColumn: t.groupingColumnGridColumn,
591
- pl: 4 * t.depth,
592
- children: /* @__PURE__ */ s(_, { display: "contents", clean: !0, onClick: () => t.toggleRow(), cursor: "pointer", children: e.value })
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
- e.column.key
647
+ i
595
648
  );
596
- if (e.column.key === x)
597
- return /* @__PURE__ */ s($, { column: e.column, children: /* @__PURE__ */ s(V, { m: 1 }) }, e.column.key);
598
- if (e.column.pin !== t.groupingColumn.pin || e.column.key === E || e.column.key === L)
599
- return /* @__PURE__ */ s($, { column: e.column, children: e.value }, e.column.key);
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 Tt(u) {
603
- const { row: t } = u;
604
- return /* @__PURE__ */ s(b, { className: "grid-row", display: "contents", props: { role: "row" }, children: t.cells.map((e) => /* @__PURE__ */ s($, { column: e.column, children: e.column.key === x ? /* @__PURE__ */ s(V, {}) : e.value }, e.column.key)) });
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 Bt(u) {
607
- const t = vt(u), { isResizeMode: e } = t, i = N(() => (console.log("render - headers"), t.headerRows.value.map((r) => r.map((d) => /* @__PURE__ */ s(Rt, { column: d }, d.uniqueKey)))), [t.headerRows.value]), n = ut(null), o = at(
608
- j.throttle((r) => {
609
- var d;
610
- (d = n.current) == null || d.setScrollTop(r.target.scrollTop);
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
- [n.current]
736
+ [o.current]
613
737
  );
614
- return console.log("render - data grid"), /* @__PURE__ */ g(p, { component: "datagrid", style: t.sizes.value, props: { role: "presentation" }, children: [
615
- /* @__PURE__ */ s(p, { p: 3, bb: 1, borderColor: "gray-400", children: t.groupColumns.length > 0 ? t.groupColumns.join(" > ") : "No grouping" }),
616
- /* @__PURE__ */ g(p, { overflowX: "scroll", props: { onScroll: o }, children: [
617
- /* @__PURE__ */ s(X, { component: "datagrid.header", variant: { isResizeMode: e }, style: { gridTemplateColumns: t.gridTemplateColumns.value }, children: i }),
618
- /* @__PURE__ */ s(Et, { ref: n, grid: t })
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__ */ g(p, { p: 3, bgColor: "gray-200", children: [
744
+ /* @__PURE__ */ d(m, { p: 3, bgColor: "gray-200", bt: 1, borderColor: "gray-400", children: [
621
745
  "Rows: ",
622
- t.rows.value.length
746
+ u.data.length
623
747
  ] })
624
748
  ] });
625
749
  }
626
- const Y = 10, J = 25, bt = Y + J * 2;
627
- function xt(u, t) {
628
- const { grid: e } = u, i = gt * e.ROW_HEIGHT, [n, o] = H(0), r = Math.max(0, Math.floor(n / i) - J), d = N(() => (console.log("render - rows"), e.flatRows.value.take(bt, r).map((h) => h instanceof q ? /* @__PURE__ */ s(Lt, { row: h }, h.rowKey) : /* @__PURE__ */ s(Tt, { row: h }, h.rowKey))), [e.flatRows.value, r]);
629
- ht(t, () => ({
630
- setScrollTop: o
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 a = e.flatRows.value.length;
633
- return /* @__PURE__ */ s(p, { height: e.ROW_HEIGHT * Y, children: /* @__PURE__ */ s(
634
- p,
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: `${a * i}px`
761
+ height: `${l * i}px`
638
762
  },
639
- children: /* @__PURE__ */ s(
640
- X,
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(${r * i}px)`,
648
- gridTemplateColumns: e.gridTemplateColumns.value
771
+ transform: `translateY(${n * i}px)`,
772
+ gridTemplateColumns: t.gridTemplateColumns.value
649
773
  },
650
- children: d
774
+ children: h
651
775
  }
652
776
  )
653
777
  }
654
778
  ) });
655
779
  }
656
- const Et = lt(xt);
780
+ const Ne = ce(De);
657
781
  export {
658
- Bt as default
782
+ je as default
659
783
  };