comins-table 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,48 +1,468 @@
1
- import { addCominsRows as e, applyCominsColumnLayout as t, clearCominsCellRange as n, clearCominsSelection as r, clearCominsSortState as i, copyCominsCell as a, copyCominsCellRange as o, copyCominsRow as s, createCominsTableState as c, deleteCominsRows as l, exportCominsRowsToCsv as u, exportCominsRowsToJson as d, fillCominsCellRange as f, formatCominsCellValue as p, getCominsCellClassName as m, getCominsCellStyle as h, getCominsCellValue as g, getCominsHeaderRows as _, getCominsPageRows as v, getCominsSelectedCellRange as y, getCominsSortedRowIndexes as b, getCominsVirtualRows as x, getCominsVisibleColumns as ee, isCominsCellDisabled as S, isCominsCellInSelectedRange as C, isCominsCellSelected as w, isCominsRowSelected as te, moveCominsColumn as ne, moveCominsColumnGroup as re, moveCominsRow as ie, pasteCominsCell as ae, pasteCominsCellRange as T, pasteCominsRow as oe, queryCominsRows as se, replaceCominsRows as ce, selectCell as le, selectCellRange as ue, selectRow as E, selectRows as de, serializeCominsColumnLayout as fe, setCominsColumnGroupHidden as pe, setCominsColumnGroupWidth as me, setCominsColumnHidden as he, setCominsColumnWidth as D, setCominsHeaderVisible as ge, setCominsPagination as _e, setCominsSortModel as ve, setCominsSortState as ye, setCominsTableTheme as be, sortCominsRows as xe, updateCominsRows as Se } from "./core.js";
2
- import { Fragment as Ce, createElement as we, forwardRef as Te, useEffect as O, useId as Ee, useImperativeHandle as De, useLayoutEffect as Oe, useMemo as k, useRef as A, useState as j } from "react";
3
- import { jsx as M, jsxs as N } from "react/jsx-runtime";
4
- function ke({ clientX: e, clientY: t, startX: n, startY: r }) {
1
+ import { addCominsRows as e, applyCominsColumnLayout as t, clearCominsCellRange as n, clearCominsSelection as r, clearCominsSortState as i, copyCominsCell as a, copyCominsCellRange as o, copyCominsRow as s, createCominsTableState as c, deleteCominsRows as l, exportCominsRowsToCsv as u, exportCominsRowsToJson as d, fillCominsCellRange as f, formatCominsCellValue as p, getCominsCellClassName as m, getCominsCellStyle as h, getCominsCellValue as g, getCominsHeaderRows as _, getCominsPageRows as v, getCominsSelectedCellRange as y, getCominsSortedRowIndexes as b, getCominsVirtualRows as x, getCominsVisibleColumns as ee, isCominsCellDisabled as te, isCominsCellInSelectedRange as ne, isCominsCellSelected as re, isCominsRowSelected as S, moveCominsColumn as ie, moveCominsColumnGroup as C, moveCominsRow as ae, moveCominsRowToGroup as oe, pasteCominsCell as w, pasteCominsCellRange as se, pasteCominsRow as ce, queryCominsRows as T, replaceCominsRows as le, selectCell as ue, selectCellRange as de, selectRow as fe, selectRows as pe, serializeCominsColumnLayout as me, setCominsColumnGroupHidden as he, setCominsColumnGroupWidth as ge, setCominsColumnHidden as _e, setCominsColumnWidth as ve, setCominsHeaderVisible as ye, setCominsPagination as be, setCominsSortModel as xe, setCominsSortState as Se, setCominsTableTheme as Ce, sortCominsRows as we, updateCominsRows as Te } from "./core.js";
2
+ import * as Ee from "react";
3
+ import { Fragment as De, createElement as Oe, forwardRef as ke, isValidElement as Ae, useEffect as E, useId as je, useImperativeHandle as Me, useLayoutEffect as Ne, useMemo as D, useRef as O, useState as k } from "react";
4
+ import { CaretSortIcon as Pe, ChevronRightIcon as Fe, DragHandleDots2Icon as Ie, MagnifyingGlassIcon as Le, ThickArrowDownIcon as Re, ThickArrowUpIcon as ze } from "@radix-ui/react-icons";
5
+ import { Fragment as Be, jsx as A, jsxs as j } from "react/jsx-runtime";
6
+ function Ve({ clientX: e, clientY: t, startX: n, startY: r }) {
5
7
  let i = Math.abs(e - n), a = Math.abs(t - r);
6
8
  return i >= 6 && i > a ? "activate" : a >= 6 && a >= i ? "cancel" : "pending";
7
9
  }
8
10
  //#endregion
11
+ //#region src/filtering.ts
12
+ var He = {
13
+ boolean: /* @__PURE__ */ new Set([
14
+ "equals",
15
+ "isEmpty",
16
+ "isNotEmpty",
17
+ "notEquals"
18
+ ]),
19
+ date: /* @__PURE__ */ new Set([
20
+ "between",
21
+ "equals",
22
+ "greaterThan",
23
+ "greaterThanOrEqual",
24
+ "isEmpty",
25
+ "isNotEmpty",
26
+ "lessThan",
27
+ "lessThanOrEqual",
28
+ "notEquals"
29
+ ]),
30
+ number: /* @__PURE__ */ new Set([
31
+ "between",
32
+ "equals",
33
+ "greaterThan",
34
+ "greaterThanOrEqual",
35
+ "isEmpty",
36
+ "isNotEmpty",
37
+ "lessThan",
38
+ "lessThanOrEqual",
39
+ "notEquals"
40
+ ]),
41
+ text: /* @__PURE__ */ new Set([
42
+ "contains",
43
+ "endsWith",
44
+ "equals",
45
+ "isEmpty",
46
+ "isNotEmpty",
47
+ "notContains",
48
+ "notEquals",
49
+ "startsWith"
50
+ ])
51
+ };
52
+ function Ue(e) {
53
+ return [...He[e]];
54
+ }
55
+ function We(e, t) {
56
+ return t.split(".").reduce((e, t) => {
57
+ if (!(typeof e != "object" || !e)) return e[t];
58
+ }, e);
59
+ }
60
+ function Ge(e) {
61
+ return e == null || e === "";
62
+ }
63
+ function Ke(e) {
64
+ if (typeof e == "string" && /^\d{4}-\d{2}-\d{2}$/u.test(e)) {
65
+ let [t, n, r] = e.split("-").map(Number), i = Date.UTC(t, n - 1, r), a = new Date(i);
66
+ return a.getUTCFullYear() === t && a.getUTCMonth() === n - 1 && a.getUTCDate() === r ? i : null;
67
+ }
68
+ let t = e instanceof Date ? e : typeof e == "number" || typeof e == "string" ? new Date(e) : null;
69
+ return !t || !Number.isFinite(t.getTime()) ? null : Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate());
70
+ }
71
+ function qe(e, t) {
72
+ switch (e) {
73
+ case "boolean": return typeof t == "boolean" ? t : null;
74
+ case "date": return Ke(t);
75
+ case "number": return typeof t == "number" && Number.isFinite(t) ? t : null;
76
+ case "text": {
77
+ if (t == null) return null;
78
+ let e = String(t);
79
+ return e.length > 0 ? e : null;
80
+ }
81
+ }
82
+ }
83
+ function Je(e) {
84
+ return e === "boolean" || e === "date" || e === "number" || e === "text";
85
+ }
86
+ function Ye(e) {
87
+ return typeof e == "string" && Object.values(He).some((t) => t.has(e));
88
+ }
89
+ function Xe({ columns: e, model: t }) {
90
+ if (!Array.isArray(t)) return [];
91
+ let n = new Map(e.map((e) => [e.id, e])), r = /* @__PURE__ */ new Set(), i = [];
92
+ for (let e of t) {
93
+ if (!e || typeof e != "object") continue;
94
+ let t = e, a = typeof t.columnId == "string" ? n.get(t.columnId) : void 0, o = a?.filter;
95
+ if (!a || !o || !Je(o.kind) || !Ye(t.operator) || !He[o.kind].has(t.operator) || r.has(a.id)) continue;
96
+ if (t.operator === "isEmpty" || t.operator === "isNotEmpty") {
97
+ r.add(a.id), i.push({
98
+ column: a,
99
+ config: o,
100
+ operator: t.operator
101
+ });
102
+ continue;
103
+ }
104
+ let s = qe(o.kind, t.value);
105
+ if (s !== null) {
106
+ if (t.operator === "between") {
107
+ let e = qe(o.kind, t.valueTo);
108
+ if (typeof s != "number" || typeof e != "number") continue;
109
+ r.add(a.id), i.push({
110
+ column: a,
111
+ config: o,
112
+ operator: t.operator,
113
+ value: Math.min(s, e),
114
+ valueTo: Math.max(s, e)
115
+ });
116
+ continue;
117
+ }
118
+ r.add(a.id), i.push({
119
+ column: a,
120
+ config: o,
121
+ operator: t.operator,
122
+ value: s
123
+ });
124
+ }
125
+ }
126
+ return i;
127
+ }
128
+ function Ze(e, t, n, r) {
129
+ switch (t) {
130
+ case "between": return typeof e == "number" && typeof n == "number" && r !== void 0 && e >= n && e <= r;
131
+ case "equals": return e === n;
132
+ case "greaterThan": return e > n;
133
+ case "greaterThanOrEqual": return e >= n;
134
+ case "lessThan": return e < n;
135
+ case "lessThanOrEqual": return e <= n;
136
+ case "notEquals": return e !== n;
137
+ default: return !1;
138
+ }
139
+ }
140
+ function M(e, t) {
141
+ let n = We(e.data, t.column.field), r = t.config.getValue ? t.config.getValue({
142
+ column: t.column,
143
+ row: e.data,
144
+ rowId: e.id,
145
+ value: n
146
+ }) : n;
147
+ if (t.operator === "isEmpty") return Ge(r);
148
+ if (t.operator === "isNotEmpty") return !Ge(r);
149
+ if (Ge(r) || t.value === void 0) return !1;
150
+ switch (t.config.kind) {
151
+ case "boolean": return typeof r == "boolean" && typeof t.value == "boolean" ? t.operator === "equals" ? r === t.value : r !== t.value : !1;
152
+ case "date": {
153
+ let e = Ke(r);
154
+ return e !== null && typeof t.value == "number" && Ze(e, t.operator, t.value, t.valueTo);
155
+ }
156
+ case "number": return typeof r == "number" && Number.isFinite(r) && typeof t.value == "number" ? Ze(r, t.operator, t.value, t.valueTo) : !1;
157
+ case "text": {
158
+ let e = String(r), n = String(t.value), i = t.config.caseSensitive ? e : e.toLocaleLowerCase(), a = t.config.caseSensitive ? n : n.toLocaleLowerCase();
159
+ switch (t.operator) {
160
+ case "contains": return i.includes(a);
161
+ case "endsWith": return i.endsWith(a);
162
+ case "equals": return i === a;
163
+ case "notContains": return !i.includes(a);
164
+ case "notEquals": return i !== a;
165
+ case "startsWith": return i.startsWith(a);
166
+ default: return !1;
167
+ }
168
+ }
169
+ }
170
+ }
171
+ function Qe({ columns: e, model: t, rows: n }) {
172
+ let r = Xe({
173
+ columns: e,
174
+ model: t
175
+ });
176
+ return r.length === 0 ? n.map((e) => e.dataIndex) : n.flatMap((e) => r.every((t) => M(e, t)) ? [e.dataIndex] : []);
177
+ }
178
+ //#endregion
179
+ //#region src/table-icons.tsx
180
+ var N = {
181
+ columnMove: Ie,
182
+ disclosureCollapsed: Fe,
183
+ disclosureExpanded: Fe,
184
+ filter: Le,
185
+ sortAscending: ze,
186
+ sortDescending: Re,
187
+ sortUnsorted: Pe
188
+ };
189
+ function $e({ className: e, name: t }) {
190
+ let n = N[t];
191
+ return /* @__PURE__ */ A(n, {
192
+ "aria-hidden": "true",
193
+ className: ["comins-table-icon", e].filter(Boolean).join(" "),
194
+ "data-comins-icon": t,
195
+ focusable: "false"
196
+ });
197
+ }
198
+ var et = Ee.forwardRef(function({ className: e, icon: t, type: n = "button", ...r }, i) {
199
+ return /* @__PURE__ */ A("button", {
200
+ className: ["comins-table-icon-button", e].filter(Boolean).join(" "),
201
+ ref: i,
202
+ type: n,
203
+ ...r,
204
+ children: /* @__PURE__ */ A($e, { name: t })
205
+ });
206
+ }), tt = {
207
+ between: "Between",
208
+ contains: "Contains",
209
+ endsWith: "Ends with",
210
+ equals: "Equals",
211
+ greaterThan: "Greater than",
212
+ greaterThanOrEqual: "Greater than or equal",
213
+ isEmpty: "Is empty",
214
+ isNotEmpty: "Is not empty",
215
+ lessThan: "Less than",
216
+ lessThanOrEqual: "Less than or equal",
217
+ notContains: "Does not contain",
218
+ notEquals: "Does not equal",
219
+ startsWith: "Starts with"
220
+ };
221
+ function nt(e) {
222
+ return e === "text" ? "contains" : "equals";
223
+ }
224
+ function rt(e, t) {
225
+ let n = e?.value;
226
+ return n === void 0 ? t === "boolean" ? "true" : "" : t === "date" && typeof n == "number" ? new Date(n).toISOString().slice(0, 10) : String(n);
227
+ }
228
+ function it(e, t) {
229
+ let n = e?.valueTo;
230
+ return n === void 0 ? "" : t === "date" ? new Date(n).toISOString().slice(0, 10) : String(n);
231
+ }
232
+ function at(e) {
233
+ if (!/^\d{4}-\d{2}-\d{2}$/u.test(e)) return !1;
234
+ let [t, n, r] = e.split("-").map(Number), i = new Date(Date.UTC(t, n - 1, r));
235
+ return i.getUTCFullYear() === t && i.getUTCMonth() === n - 1 && i.getUTCDate() === r;
236
+ }
237
+ function ot({ columnId: e, columnLabel: t, kind: n, onChangeRule: r, onOpenChange: i, open: a, rule: o }) {
238
+ let s = O(null), c = O(i), l = O(null), u = je(), [d, f] = k(o?.operator ?? nt(n)), [p, m] = k(() => rt(o, n)), [h, g] = k(() => it(o, n)), [_, v] = k({
239
+ left: 0,
240
+ top: 0
241
+ }), y = o !== void 0, b = typeof r != "function", x = d !== "isEmpty" && d !== "isNotEmpty";
242
+ Ne(() => {
243
+ c.current = i;
244
+ }, [i]), E(() => {
245
+ a && (f(o?.operator ?? nt(n)), m(rt(o, n)), g(it(o, n)));
246
+ }, [
247
+ n,
248
+ a,
249
+ o?.operator,
250
+ o?.value,
251
+ o?.valueTo
252
+ ]), Ne(() => {
253
+ if (!a) return;
254
+ let e = () => {
255
+ let e = s.current, t = l.current;
256
+ if (!e) return;
257
+ let n = e.getBoundingClientRect(), r = t?.offsetWidth || 260, i = t?.offsetHeight || 220, a = Math.min(Math.max(8, n.left), Math.max(8, window.innerWidth - r - 8)), o = n.bottom + 6, c = o + i <= window.innerHeight - 8 ? o : Math.max(8, n.top - i - 6);
258
+ v({
259
+ left: a,
260
+ top: c
261
+ });
262
+ }, t = (e) => {
263
+ let t = e.target;
264
+ t instanceof Node && (s.current?.contains(t) || l.current?.contains(t)) || c.current?.(null);
265
+ }, n = (e) => {
266
+ e.key === "Escape" && (e.preventDefault(), c.current?.(null), s.current?.focus());
267
+ };
268
+ return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), window.addEventListener("pointerdown", t, !0), window.addEventListener("keydown", n), () => {
269
+ window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0), window.removeEventListener("pointerdown", t, !0), window.removeEventListener("keydown", n);
270
+ };
271
+ }, [a]);
272
+ let ee = (t, i, a) => {
273
+ if (!r) return;
274
+ if (t === "isEmpty" || t === "isNotEmpty") {
275
+ r({
276
+ columnId: e,
277
+ operator: t
278
+ });
279
+ return;
280
+ }
281
+ if (n === "text") {
282
+ r(i.length > 0 ? {
283
+ columnId: e,
284
+ operator: t,
285
+ value: i
286
+ } : null);
287
+ return;
288
+ }
289
+ if (n === "boolean") {
290
+ r(i === "true" || i === "false" ? {
291
+ columnId: e,
292
+ operator: t,
293
+ value: i === "true"
294
+ } : null);
295
+ return;
296
+ }
297
+ let o = n === "date" ? at(i) ? i : null : i !== "" && Number.isFinite(Number(i)) ? Number(i) : null;
298
+ if (o === null) {
299
+ if (t === "between") return;
300
+ r(null);
301
+ return;
302
+ }
303
+ if (t === "between") {
304
+ let i = n === "date" ? at(a) ? a : null : a !== "" && Number.isFinite(Number(a)) ? Number(a) : null;
305
+ if (i === null) return;
306
+ r({
307
+ columnId: e,
308
+ operator: t,
309
+ value: o,
310
+ valueTo: i
311
+ });
312
+ return;
313
+ }
314
+ r({
315
+ columnId: e,
316
+ operator: t,
317
+ value: o
318
+ });
319
+ };
320
+ return /* @__PURE__ */ j("span", {
321
+ className: "comins-column-filter",
322
+ "data-active": y ? "true" : void 0,
323
+ onClick: (e) => e.stopPropagation(),
324
+ onDoubleClick: (e) => e.stopPropagation(),
325
+ onKeyDown: (e) => {
326
+ e.stopPropagation(), e.key === "Escape" && (e.preventDefault(), i?.(null), s.current?.focus());
327
+ },
328
+ onPointerDown: (e) => e.stopPropagation(),
329
+ children: [/* @__PURE__ */ A(et, {
330
+ "aria-controls": a ? u : void 0,
331
+ "aria-expanded": a,
332
+ "aria-label": `Filter ${t}`,
333
+ className: "comins-column-filter__trigger",
334
+ "data-active": y ? "true" : void 0,
335
+ "data-testid": `column-filter-trigger-${e}`,
336
+ disabled: !i,
337
+ icon: "filter",
338
+ onClick: () => i?.(a ? null : e),
339
+ ref: s
340
+ }), a ? /* @__PURE__ */ j("span", {
341
+ "aria-label": `Filter ${t}`,
342
+ className: "comins-column-filter__popover",
343
+ "data-testid": `column-filter-popover-${e}`,
344
+ id: u,
345
+ ref: l,
346
+ role: "dialog",
347
+ style: _,
348
+ children: [
349
+ /* @__PURE__ */ A("strong", {
350
+ className: "comins-column-filter__title",
351
+ children: t
352
+ }),
353
+ /* @__PURE__ */ j("label", {
354
+ className: "comins-column-filter__field",
355
+ children: [/* @__PURE__ */ A("span", { children: "Operator" }), /* @__PURE__ */ A("select", {
356
+ "data-testid": `column-filter-operator-${e}`,
357
+ disabled: b,
358
+ onChange: (e) => {
359
+ let t = e.currentTarget.value;
360
+ f(t), ee(t, p, h);
361
+ },
362
+ value: d,
363
+ children: Ue(n).map((e) => /* @__PURE__ */ A("option", {
364
+ value: e,
365
+ children: tt[e]
366
+ }, e))
367
+ })]
368
+ }),
369
+ x && n === "boolean" ? /* @__PURE__ */ j("label", {
370
+ className: "comins-column-filter__field",
371
+ children: [/* @__PURE__ */ A("span", { children: "Value" }), /* @__PURE__ */ j("select", {
372
+ "data-testid": `column-filter-value-${e}`,
373
+ disabled: b,
374
+ onChange: (e) => {
375
+ let t = e.currentTarget.value;
376
+ m(t), ee(d, t, h);
377
+ },
378
+ value: p,
379
+ children: [/* @__PURE__ */ A("option", {
380
+ value: "true",
381
+ children: "True"
382
+ }), /* @__PURE__ */ A("option", {
383
+ value: "false",
384
+ children: "False"
385
+ })]
386
+ })]
387
+ }) : null,
388
+ x && n !== "boolean" ? /* @__PURE__ */ j("label", {
389
+ className: "comins-column-filter__field",
390
+ children: [/* @__PURE__ */ A("span", { children: d === "between" ? "From" : "Value" }), /* @__PURE__ */ A("input", {
391
+ "data-testid": `column-filter-value-${e}`,
392
+ disabled: b,
393
+ onChange: (e) => {
394
+ let t = e.currentTarget.value;
395
+ m(t), ee(d, t, h);
396
+ },
397
+ type: n === "date" ? "date" : n === "number" ? "number" : "text",
398
+ value: p
399
+ })]
400
+ }) : null,
401
+ x && d === "between" ? /* @__PURE__ */ j("label", {
402
+ className: "comins-column-filter__field",
403
+ children: [/* @__PURE__ */ A("span", { children: "To" }), /* @__PURE__ */ A("input", {
404
+ "data-testid": `column-filter-value-to-${e}`,
405
+ disabled: b,
406
+ onChange: (e) => {
407
+ let t = e.currentTarget.value;
408
+ g(t), ee(d, p, t);
409
+ },
410
+ type: n === "date" ? "date" : "number",
411
+ value: h
412
+ })]
413
+ }) : null,
414
+ /* @__PURE__ */ A("button", {
415
+ className: "comins-column-filter__clear",
416
+ "data-testid": `column-filter-clear-${e}`,
417
+ disabled: b || !y,
418
+ onClick: () => {
419
+ f(nt(n)), m(n === "boolean" ? "true" : ""), g(""), r?.(null);
420
+ },
421
+ type: "button",
422
+ children: "Clear"
423
+ })
424
+ ]
425
+ }) : null]
426
+ });
427
+ }
428
+ //#endregion
9
429
  //#region src/component-renderer.tsx
10
- function P(...e) {
430
+ function st(...e) {
11
431
  return e.filter(Boolean).join(" ");
12
432
  }
13
- function F(e, t) {
433
+ function ct(e, t) {
14
434
  return typeof e == "function" ? e(t) : e ?? {};
15
435
  }
16
- function Ae(e, t) {
436
+ function P(e, t) {
17
437
  return typeof e == "function" ? e(t) : e;
18
438
  }
19
- function je(e, t) {
439
+ function lt(e, t) {
20
440
  return typeof e == "function" ? e(t) : e;
21
441
  }
22
- function Me(e, t) {
442
+ function F(e, t) {
23
443
  return typeof e == "function" ? e(t) : e;
24
444
  }
25
- function Ne(e) {
26
- return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? e.map(Ne).join(" ") : "";
445
+ function I(e) {
446
+ return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? e.map(I).join(" ") : "";
27
447
  }
28
- function Pe(e) {
448
+ function ut(e) {
29
449
  return e.type !== "divider" && e.type !== "label";
30
450
  }
31
- function Fe(e, t) {
451
+ function L(e, t) {
32
452
  return !!(e && t instanceof Node && e.contains(t));
33
453
  }
34
- function I(e) {
454
+ function R(e) {
35
455
  e.stopPropagation();
36
456
  }
37
- function Ie(e) {
457
+ function z(e) {
38
458
  e.preventDefault(), e.stopPropagation();
39
459
  }
40
- function L(e) {
460
+ function dt(e) {
41
461
  return e == null ? "" : String(e);
42
462
  }
43
- function Le({ component: e, payload: t }) {
44
- let n = F(e.props, t), { defaultValue: r, onBlur: i, onChange: a, onClick: o, onKeyDown: s, onMouseDown: c, onPointerDown: l, value: u, ...d } = n, f = L(u ?? r), [p, m] = j(f), h = A(f);
45
- O(() => {
463
+ function ft({ component: e, payload: t }) {
464
+ let n = ct(e.props, t), { defaultValue: r, onBlur: i, onChange: a, onClick: o, onKeyDown: s, onMouseDown: c, onPointerDown: l, value: u, ...d } = n, f = dt(u ?? r), [p, m] = k(f), h = O(f);
465
+ E(() => {
46
466
  m(f), h.current = f;
47
467
  }, [f]);
48
468
  let g = (n) => {
@@ -55,55 +475,55 @@ function Le({ component: e, payload: t }) {
55
475
  value: p
56
476
  }));
57
477
  };
58
- return /* @__PURE__ */ M("input", {
478
+ return /* @__PURE__ */ A("input", {
59
479
  ...d,
60
- className: P("comins-table__component", "comins-table__component-input", n.className),
480
+ className: st("comins-table__component", "comins-table__component-input", n.className),
61
481
  onBlur: (e) => {
62
- i?.(e), I(e), g(e);
482
+ i?.(e), R(e), g(e);
63
483
  },
64
484
  onChange: (e) => {
65
- I(e), m(e.currentTarget.value);
485
+ R(e), m(e.currentTarget.value);
66
486
  },
67
487
  onClick: (e) => {
68
- o?.(e), I(e);
488
+ o?.(e), R(e);
69
489
  },
70
490
  onKeyDown: (e) => {
71
- s?.(e), I(e), e.key === "Enter" && (e.preventDefault(), g(e), e.currentTarget.blur());
491
+ s?.(e), R(e), e.key === "Enter" && (e.preventDefault(), g(e), e.currentTarget.blur());
72
492
  },
73
493
  onMouseDown: (e) => {
74
- c?.(e), I(e);
494
+ c?.(e), R(e);
75
495
  },
76
496
  onPointerDown: (e) => {
77
- l?.(e), I(e);
497
+ l?.(e), R(e);
78
498
  },
79
499
  value: p
80
500
  });
81
501
  }
82
- function Re({ component: e, payload: t }) {
83
- let n = F(e.props, t), { checked: r, defaultChecked: i, onChange: a, onClick: o, onKeyDown: s, onMouseDown: c, onPointerDown: l, style: u, ...d } = n, [f, p] = j(!!(r ?? i));
84
- return O(() => {
502
+ function pt({ component: e, payload: t }) {
503
+ let n = ct(e.props, t), { checked: r, defaultChecked: i, onChange: a, onClick: o, onKeyDown: s, onMouseDown: c, onPointerDown: l, style: u, ...d } = n, [f, p] = k(!!(r ?? i));
504
+ return E(() => {
85
505
  r !== void 0 && p(!!r);
86
- }, [r]), /* @__PURE__ */ M("input", {
506
+ }, [r]), /* @__PURE__ */ A("input", {
87
507
  ...d,
88
508
  checked: f,
89
- className: P("comins-table__component", "comins-table__component-checkbox", n.className),
509
+ className: st("comins-table__component", "comins-table__component-checkbox", n.className),
90
510
  onClick: (e) => {
91
- o?.(e), I(e);
511
+ o?.(e), R(e);
92
512
  },
93
513
  onChange: (n) => {
94
- a?.(n), I(n), p(n.currentTarget.checked), e.onCheckedChange?.({
514
+ a?.(n), R(n), p(n.currentTarget.checked), e.onCheckedChange?.({
95
515
  ...t,
96
516
  checked: n.currentTarget.checked
97
517
  });
98
518
  },
99
519
  onKeyDown: (e) => {
100
- s?.(e), I(e);
520
+ s?.(e), R(e);
101
521
  },
102
522
  onMouseDown: (e) => {
103
- c?.(e), I(e);
523
+ c?.(e), R(e);
104
524
  },
105
525
  onPointerDown: (e) => {
106
- l?.(e), I(e);
526
+ l?.(e), R(e);
107
527
  },
108
528
  style: {
109
529
  height: 20,
@@ -113,18 +533,18 @@ function Re({ component: e, payload: t }) {
113
533
  type: "checkbox"
114
534
  });
115
535
  }
116
- function ze({ component: e, payload: t }) {
117
- let { checked: n, ...r } = F(e.props, t), { onClick: i, onKeyDown: a, onMouseDown: o, onPointerDown: s, ...c } = r, [l, u] = j(!!n);
118
- O(() => {
536
+ function mt({ component: e, payload: t }) {
537
+ let { checked: n, ...r } = ct(e.props, t), { onClick: i, onKeyDown: a, onMouseDown: o, onPointerDown: s, ...c } = r, [l, u] = k(!!n);
538
+ E(() => {
119
539
  n !== void 0 && u(!!n);
120
540
  }, [n]);
121
541
  let d = typeof r.children == "string" && (r.children === "ON" || r.children === "OFF") ? l ? "ON" : "OFF" : r.children;
122
- return /* @__PURE__ */ M("button", {
542
+ return /* @__PURE__ */ A("button", {
123
543
  ...c,
124
544
  "aria-pressed": l,
125
- className: P("comins-table__component", "comins-table__component-toggle", r.className),
545
+ className: st("comins-table__component", "comins-table__component-toggle", r.className),
126
546
  onClick: (n) => {
127
- i?.(n), I(n);
547
+ i?.(n), R(n);
128
548
  let r = !l;
129
549
  u(r), e.onCheckedChange?.({
130
550
  ...t,
@@ -132,24 +552,24 @@ function ze({ component: e, payload: t }) {
132
552
  });
133
553
  },
134
554
  onKeyDown: (e) => {
135
- a?.(e), I(e);
555
+ a?.(e), R(e);
136
556
  },
137
557
  onMouseDown: (e) => {
138
- o?.(e), I(e);
558
+ o?.(e), R(e);
139
559
  },
140
560
  onPointerDown: (e) => {
141
- s?.(e), I(e);
561
+ s?.(e), R(e);
142
562
  },
143
563
  type: r.type ?? "button",
144
564
  children: d
145
565
  });
146
566
  }
147
- function Be({ component: e, payload: t }) {
148
- let [n, r] = j(!1), i = Ee(), a = A(null), o = A(null), [s, c] = j({
567
+ function ht({ component: e, payload: t }) {
568
+ let [n, r] = k(!1), i = je(), a = O(null), o = O(null), [s, c] = k({
149
569
  left: 0,
150
570
  position: "fixed",
151
571
  top: 0
152
- }), l = F(e.props, t), u = k(() => je(e.items, t), [e.items, t]), d = () => {
572
+ }), l = ct(e.props, t), u = D(() => lt(e.items, t), [e.items, t]), d = () => {
153
573
  let e = a.current;
154
574
  if (!e || typeof window > "u") return;
155
575
  let t = e.getBoundingClientRect(), n = Math.max(o.current?.offsetWidth ?? 136, 136);
@@ -170,77 +590,77 @@ function Be({ component: e, payload: t }) {
170
590
  open: i
171
591
  }));
172
592
  };
173
- O(() => {
593
+ E(() => {
174
594
  if (!n) return;
175
595
  let e = (e) => {
176
- Fe(a.current, e.target) || Fe(o.current, e.target) || f(!1, e);
596
+ L(a.current, e.target) || L(o.current, e.target) || f(!1, e);
177
597
  }, t = (e) => {
178
598
  e.key === "Escape" && (f(!1, e), a.current?.focus());
179
599
  };
180
600
  return document.addEventListener("pointerdown", e), document.addEventListener("keydown", t), () => {
181
601
  document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", t);
182
602
  };
183
- }, [n]), Oe(() => {
603
+ }, [n]), Ne(() => {
184
604
  if (n && (d(), !(typeof window > "u"))) return window.addEventListener("resize", d), window.addEventListener("scroll", d, !0), () => {
185
605
  window.removeEventListener("resize", d), window.removeEventListener("scroll", d, !0);
186
606
  };
187
607
  }, [n]);
188
- let p = n ? /* @__PURE__ */ M("span", {
608
+ let p = n ? /* @__PURE__ */ A("span", {
189
609
  "aria-label": "Header menu",
190
610
  className: "comins-table__component-menu-popover",
191
611
  id: i,
192
612
  ref: o,
193
613
  role: "menu",
194
614
  style: s,
195
- children: u.map((n, r) => n.type === "divider" ? /* @__PURE__ */ M("span", {
615
+ children: u.map((n, r) => n.type === "divider" ? /* @__PURE__ */ A("span", {
196
616
  "aria-orientation": "horizontal",
197
617
  className: "comins-table__component-menu-divider",
198
618
  role: "separator"
199
- }, `divider-${r}`) : n.type === "label" ? /* @__PURE__ */ M("span", {
619
+ }, `divider-${r}`) : n.type === "label" ? /* @__PURE__ */ A("span", {
200
620
  className: "comins-table__component-menu-label",
201
621
  role: "presentation",
202
622
  children: n.label
203
- }, `label-${r}`) : /* @__PURE__ */ M("button", {
623
+ }, `label-${r}`) : /* @__PURE__ */ A("button", {
204
624
  className: "comins-table__component-menu-item",
205
625
  disabled: n.disabled,
206
626
  onClick: (r) => {
207
- Ie(r), !(n.disabled || !Pe(n)) && (f(!1, r), e.onSelect?.({
627
+ z(r), !(n.disabled || !ut(n)) && (f(!1, r), e.onSelect?.({
208
628
  ...t,
209
629
  event: r,
210
630
  item: n,
211
631
  value: n.value
212
632
  }));
213
633
  },
214
- onKeyDown: I,
215
- onMouseDown: I,
216
- onPointerDown: I,
634
+ onKeyDown: R,
635
+ onMouseDown: R,
636
+ onPointerDown: R,
217
637
  role: "menuitem",
218
638
  type: "button",
219
639
  children: n.label
220
640
  }, `${String(n.value)}-${r}`))
221
641
  }) : null;
222
- return /* @__PURE__ */ N("span", {
642
+ return /* @__PURE__ */ j("span", {
223
643
  className: "comins-table__component comins-table__component-menu",
224
- children: [/* @__PURE__ */ M("button", {
644
+ children: [/* @__PURE__ */ A("button", {
225
645
  ...l,
226
646
  "aria-controls": n ? i : void 0,
227
647
  "aria-expanded": n,
228
648
  "aria-haspopup": "menu",
229
649
  "aria-label": l["aria-label"] ?? "Header menu",
230
- className: P("comins-table__component-menu-trigger", l.className),
650
+ className: st("comins-table__component-menu-trigger", l.className),
231
651
  onClick: (e) => {
232
- Ie(e), f(!n, e);
652
+ z(e), f(!n, e);
233
653
  },
234
654
  onKeyDown: (e) => {
235
655
  if (l.onKeyDown?.(e), e.key === "Escape" && n) {
236
- Ie(e), f(!1, e);
656
+ z(e), f(!1, e);
237
657
  return;
238
658
  }
239
- I(e);
659
+ R(e);
240
660
  },
241
- onMouseDown: I,
661
+ onMouseDown: R,
242
662
  onPointerDown: (e) => {
243
- l.onPointerDown?.(e), I(e);
663
+ l.onPointerDown?.(e), R(e);
244
664
  },
245
665
  ref: a,
246
666
  type: l.type ?? "button",
@@ -248,47 +668,47 @@ function Be({ component: e, payload: t }) {
248
668
  }), p]
249
669
  });
250
670
  }
251
- function R({ component: e, interaction: t, payload: n }) {
252
- let { height: r, itemHeight: i, limit: a, more: o = !1, searchable: s = !1, style: c, ...l } = F(e.props, n), u = k(() => Me(e.items, n), [e.items, n]), d = Math.max(1, Number(a ?? 5)), f = Math.max(1, Number(i ?? 28)), p = f * 5, m = r !== void 0 || c?.height !== void 0, [h, g] = j(""), [_, v] = j(!1), [y, b] = j(0), [x, ee] = j(null), [S, C] = j(p), w = A(null), te = n.row.selected && n.selection.selectedRowCount === 1, ne = !!(s && te), re = ne ? h : "";
253
- O(() => {
671
+ function gt({ component: e, interaction: t, payload: n }) {
672
+ let { height: r, itemHeight: i, limit: a, more: o = !1, searchable: s = !1, style: c, ...l } = ct(e.props, n), u = D(() => F(e.items, n), [e.items, n]), d = Math.max(1, Number(a ?? 5)), f = Math.max(1, Number(i ?? 28)), p = f * 5, m = r !== void 0 || c?.height !== void 0, [h, g] = k(""), [_, v] = k(!1), [y, b] = k(0), [x, ee] = k(null), [te, ne] = k(p), re = O(null), S = n.row.selected && n.selection.selectedRowCount === 1, ie = !!(s && S), C = ie ? h : "";
673
+ E(() => {
254
674
  v(!1), b(0);
255
- }, [u.length, d]), Oe(() => {
256
- let e = w.current;
675
+ }, [u.length, d]), Ne(() => {
676
+ let e = re.current;
257
677
  if (!e) return;
258
678
  let t = e.clientHeight > 0 ? e.clientHeight : p;
259
- C(m ? t : Math.min(t, p));
679
+ ne(m ? t : Math.min(t, p));
260
680
  }, [
261
681
  p,
262
682
  _,
263
- re,
683
+ C,
264
684
  m
265
- ]), O(() => {
266
- let e = w.current;
685
+ ]), E(() => {
686
+ let e = re.current;
267
687
  e && (e.scrollTop = 0, b(0));
268
- }, [re]), O(() => {
269
- if (te) return;
270
- let e = w.current;
688
+ }, [C]), E(() => {
689
+ if (S) return;
690
+ let e = re.current;
271
691
  e && (e.scrollTop = 0), v(!1), g(""), b(0);
272
- }, [te]);
273
- let ie = k(() => {
274
- let t = re.trim().toLowerCase();
692
+ }, [S]);
693
+ let ae = D(() => {
694
+ let t = C.trim().toLowerCase();
275
695
  return u.map((e, t) => ({
276
696
  item: e,
277
697
  itemIndex: t
278
698
  })).filter(({ item: n, itemIndex: r }) => t ? e.searchFilter ? e.searchFilter({
279
699
  item: n,
280
700
  itemIndex: r,
281
- value: re
282
- }) : Ne(n.label).toLowerCase().includes(t) : !0);
701
+ value: C
702
+ }) : I(n.label).toLowerCase().includes(t) : !0);
283
703
  }, [
284
- re,
704
+ C,
285
705
  e,
286
706
  u
287
- ]), ae = ie.length > d, T = !!(te && (_ || re.trim().length > 0 || !o && ae)), oe = ae && !T, se = ne && !_ ? 0 : 2, ce = Math.max(f, m ? S || p : Math.min(S || p, p)), le = Math.max(0, Math.floor(Math.max(0, y) / f) - se), ue = Math.min(ie.length, Math.ceil((Math.max(0, y) + ce) / f) + se), E = T ? ie.slice(le, ue) : ie.slice(0, ae ? d : ie.length), de = T ? le * f : 0, fe = T ? Math.max(0, ie.length - ue) * f : 0, pe = `${String(n.row.id)}-${n.column.id}`, me = {
707
+ ]), oe = ae.length > d, w = !!(S && (_ || C.trim().length > 0 || !o && oe)), se = oe && !w, ce = ie && !_ ? 0 : 2, T = Math.max(f, m ? te || p : Math.min(te || p, p)), le = Math.max(0, Math.floor(Math.max(0, y) / f) - ce), ue = Math.min(ae.length, Math.ceil((Math.max(0, y) + T) / f) + ce), de = w ? ae.slice(le, ue) : ae.slice(0, oe ? d : ae.length), fe = w ? le * f : 0, pe = w ? Math.max(0, ae.length - ue) * f : 0, me = `${String(n.row.id)}-${n.column.id}`, he = {
288
708
  ...c,
289
709
  "--comins-table-virtual-list-item-height": `${f}px`,
290
710
  height: r ?? c?.height ?? p
291
- }, he = (r, i, a) => {
711
+ }, ge = (r, i, a) => {
292
712
  r.disabled || t?.requestRowSelection?.({
293
713
  event: a,
294
714
  mode: "row-click"
@@ -300,70 +720,70 @@ function R({ component: e, interaction: t, payload: n }) {
300
720
  value: r.value
301
721
  }));
302
722
  };
303
- return /* @__PURE__ */ N("div", {
723
+ return /* @__PURE__ */ j("div", {
304
724
  ...l,
305
725
  "aria-label": l["aria-label"] ?? "Virtual list",
306
- className: P("comins-table__component", "comins-table__component-virtual-list", l.className),
307
- "data-comins-virtual-list-expanded": T ? "true" : void 0,
308
- "data-comins-virtual-list-visible-count": E.length,
309
- "data-testid": `virtual-list-${pe}`,
726
+ className: st("comins-table__component", "comins-table__component-virtual-list", l.className),
727
+ "data-comins-virtual-list-expanded": w ? "true" : void 0,
728
+ "data-comins-virtual-list-visible-count": de.length,
729
+ "data-testid": `virtual-list-${me}`,
310
730
  onClick: (e) => {
311
- l.onClick?.(e), I(e);
731
+ l.onClick?.(e), R(e);
312
732
  },
313
- onKeyDown: I,
314
- onMouseDown: I,
315
- onContextMenu: I,
316
- onDoubleClick: I,
317
- onMouseUp: I,
318
- onPointerUp: I,
319
- onPointerMove: I,
320
- onPointerEnter: I,
321
- onMouseOver: I,
322
- onMouseOut: I,
323
- onPointerLeave: I,
324
- onBlur: I,
325
- onFocus: I,
326
- onInput: I,
327
- onChange: I,
328
- onMouseMove: I,
329
- onMouseEnter: I,
330
- onMouseLeave: I,
331
- onTouchStart: I,
332
- onTouchMove: I,
333
- onTouchEnd: I,
733
+ onKeyDown: R,
734
+ onMouseDown: R,
735
+ onContextMenu: R,
736
+ onDoubleClick: R,
737
+ onMouseUp: R,
738
+ onPointerUp: R,
739
+ onPointerMove: R,
740
+ onPointerEnter: R,
741
+ onMouseOver: R,
742
+ onMouseOut: R,
743
+ onPointerLeave: R,
744
+ onBlur: R,
745
+ onFocus: R,
746
+ onInput: R,
747
+ onChange: R,
748
+ onMouseMove: R,
749
+ onMouseEnter: R,
750
+ onMouseLeave: R,
751
+ onTouchStart: R,
752
+ onTouchMove: R,
753
+ onTouchEnd: R,
334
754
  onWheel: (e) => {
335
- l.onWheel?.(e), I(e);
755
+ l.onWheel?.(e), R(e);
336
756
  },
337
757
  onPointerDown: (e) => {
338
- l.onPointerDown?.(e), I(e);
758
+ l.onPointerDown?.(e), R(e);
339
759
  },
340
760
  role: "listbox",
341
- style: me,
342
- children: [/* @__PURE__ */ N("div", {
761
+ style: he,
762
+ children: [/* @__PURE__ */ j("div", {
343
763
  className: "comins-table__component-virtual-list-items",
344
764
  onScroll: (e) => {
345
- I(e), b(e.currentTarget.scrollTop);
765
+ R(e), b(e.currentTarget.scrollTop);
346
766
  let t = e.currentTarget.clientHeight > 0 ? e.currentTarget.clientHeight : p;
347
- C(m ? t : Math.min(t, p));
767
+ ne(m ? t : Math.min(t, p));
348
768
  },
349
- ref: w,
769
+ ref: re,
350
770
  role: "presentation",
351
771
  children: [
352
- de > 0 ? /* @__PURE__ */ M("span", {
772
+ fe > 0 ? /* @__PURE__ */ A("span", {
353
773
  "aria-hidden": "true",
354
774
  className: "comins-table__component-virtual-list-spacer",
355
- style: { height: de }
775
+ style: { height: fe }
356
776
  }) : null,
357
- E.map(({ item: t, itemIndex: r }) => /* @__PURE__ */ M("button", {
777
+ de.map(({ item: t, itemIndex: r }) => /* @__PURE__ */ A("button", {
358
778
  "aria-selected": x === t.value,
359
779
  className: "comins-table__component-virtual-list-item",
360
780
  "data-comins-virtual-list-item": "true",
361
781
  disabled: t.disabled,
362
782
  onClick: (e) => {
363
- Ie(e), he(t, r, e);
783
+ z(e), ge(t, r, e);
364
784
  },
365
785
  onContextMenu: (i) => {
366
- I(i), !t.disabled && e.onContextMenuItem?.({
786
+ R(i), !t.disabled && e.onContextMenuItem?.({
367
787
  ...n,
368
788
  event: i,
369
789
  item: t,
@@ -372,128 +792,128 @@ function R({ component: e, interaction: t, payload: n }) {
372
792
  });
373
793
  },
374
794
  onKeyDown: (e) => {
375
- I(e), (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), he(t, r, e));
795
+ R(e), (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), ge(t, r, e));
376
796
  },
377
- onMouseDown: I,
378
- onPointerDown: I,
797
+ onMouseDown: R,
798
+ onPointerDown: R,
379
799
  role: "option",
380
800
  type: "button",
381
- children: /* @__PURE__ */ M("span", {
801
+ children: /* @__PURE__ */ A("span", {
382
802
  className: "comins-table__component-virtual-list-item-label",
383
803
  children: t.label
384
804
  })
385
805
  }, `${String(t.value)}-${r}`)),
386
- fe > 0 ? /* @__PURE__ */ M("span", {
806
+ pe > 0 ? /* @__PURE__ */ A("span", {
387
807
  "aria-hidden": "true",
388
808
  className: "comins-table__component-virtual-list-spacer",
389
- style: { height: fe }
809
+ style: { height: pe }
390
810
  }) : null
391
811
  ]
392
- }), /* @__PURE__ */ N("div", {
812
+ }), /* @__PURE__ */ j("div", {
393
813
  className: "comins-table__component-virtual-list-controls",
394
- children: [o && ae ? /* @__PURE__ */ M("button", {
395
- "aria-expanded": T,
814
+ children: [o && oe ? /* @__PURE__ */ A("button", {
815
+ "aria-expanded": w,
396
816
  "aria-label": "전체 목록 보기",
397
817
  className: "comins-table__component-virtual-list-overflow comins-table__component-virtual-list-more",
398
- "data-testid": `virtual-list-overflow-${pe}`,
818
+ "data-testid": `virtual-list-overflow-${me}`,
399
819
  onClick: (e) => {
400
- Ie(e), t?.requestRowSelection?.({
820
+ z(e), t?.requestRowSelection?.({
401
821
  event: e,
402
822
  mode: "exclusive"
403
823
  }) !== !1 && v(!0);
404
824
  },
405
- onKeyDown: I,
406
- onMouseDown: I,
407
- onPointerDown: I,
825
+ onKeyDown: R,
826
+ onMouseDown: R,
827
+ onPointerDown: R,
408
828
  type: "button",
409
829
  children: "..."
410
- }) : oe ? /* @__PURE__ */ M("span", {
830
+ }) : se ? /* @__PURE__ */ A("span", {
411
831
  "aria-hidden": "true",
412
832
  className: "comins-table__component-virtual-list-overflow comins-table__component-virtual-list-more",
413
- "data-testid": `virtual-list-overflow-${pe}`,
833
+ "data-testid": `virtual-list-overflow-${me}`,
414
834
  children: "..."
415
- }) : null, ne ? /* @__PURE__ */ M("input", {
835
+ }) : null, ie ? /* @__PURE__ */ A("input", {
416
836
  "aria-label": `${l["aria-label"] ?? "Virtual list"} 검색`,
417
837
  className: "comins-table__component-virtual-list-search",
418
- "data-testid": `virtual-list-search-${pe}`,
838
+ "data-testid": `virtual-list-search-${me}`,
419
839
  onChange: (e) => {
420
- I(e), g(e.currentTarget.value);
840
+ R(e), g(e.currentTarget.value);
421
841
  },
422
- onClick: I,
423
- onKeyDown: I,
424
- onMouseDown: I,
425
- onPointerDown: I,
842
+ onClick: R,
843
+ onKeyDown: R,
844
+ onMouseDown: R,
845
+ onPointerDown: R,
426
846
  placeholder: "검색",
427
847
  value: h
428
848
  }) : null]
429
849
  })]
430
850
  });
431
851
  }
432
- function Ve(e, t, n) {
433
- if (e.type === "menu") return /* @__PURE__ */ M(Be, {
852
+ function _t(e, t, n) {
853
+ if (e.type === "menu") return /* @__PURE__ */ A(ht, {
434
854
  component: e,
435
855
  payload: t
436
856
  });
437
- if (e.type === "virtual-list") return /* @__PURE__ */ M(R, {
857
+ if (e.type === "virtual-list") return /* @__PURE__ */ A(gt, {
438
858
  component: e,
439
859
  interaction: n,
440
860
  payload: t
441
861
  });
442
862
  if (e.type === "button") {
443
- let n = F(e.props, t), { onClick: r, onKeyDown: i, onMouseDown: a, onPointerDown: o, ...s } = n;
444
- return /* @__PURE__ */ M("button", {
863
+ let n = ct(e.props, t), { onClick: r, onKeyDown: i, onMouseDown: a, onPointerDown: o, ...s } = n;
864
+ return /* @__PURE__ */ A("button", {
445
865
  ...s,
446
- className: P("comins-table__component", "comins-table__component-button", n.className),
866
+ className: st("comins-table__component", "comins-table__component-button", n.className),
447
867
  onClick: (n) => {
448
- r?.(n), I(n), e.onClick?.({
868
+ r?.(n), R(n), e.onClick?.({
449
869
  ...t,
450
870
  event: n
451
871
  });
452
872
  },
453
873
  onKeyDown: (e) => {
454
- i?.(e), I(e);
874
+ i?.(e), R(e);
455
875
  },
456
876
  onMouseDown: (e) => {
457
- a?.(e), I(e);
877
+ a?.(e), R(e);
458
878
  },
459
879
  onPointerDown: (e) => {
460
- o?.(e), I(e);
880
+ o?.(e), R(e);
461
881
  },
462
882
  type: n.type ?? "button"
463
883
  });
464
884
  }
465
- if (e.type === "input") return /* @__PURE__ */ M(Le, {
885
+ if (e.type === "input") return /* @__PURE__ */ A(ft, {
466
886
  component: e,
467
887
  payload: t
468
888
  });
469
- if (e.type === "checkbox") return /* @__PURE__ */ M(Re, {
889
+ if (e.type === "checkbox") return /* @__PURE__ */ A(pt, {
470
890
  component: e,
471
891
  payload: t
472
892
  });
473
893
  if (e.type === "select") {
474
- let n = F(e.props, t), r = Ae(e.options, t), { onChange: i, onClick: a, onKeyDown: o, onMouseDown: s, onPointerDown: c, ...l } = n;
475
- return /* @__PURE__ */ M("select", {
894
+ let n = ct(e.props, t), r = P(e.options, t), { onChange: i, onClick: a, onKeyDown: o, onMouseDown: s, onPointerDown: c, ...l } = n;
895
+ return /* @__PURE__ */ A("select", {
476
896
  ...l,
477
- className: P("comins-table__component", "comins-table__component-select", n.className),
897
+ className: st("comins-table__component", "comins-table__component-select", n.className),
478
898
  onClick: (e) => {
479
- a?.(e), I(e);
899
+ a?.(e), R(e);
480
900
  },
481
901
  onChange: (n) => {
482
- i?.(n), I(n), e.onValueChange?.({
902
+ i?.(n), R(n), e.onValueChange?.({
483
903
  ...t,
484
904
  value: n.currentTarget.value
485
905
  });
486
906
  },
487
907
  onKeyDown: (e) => {
488
- o?.(e), I(e);
908
+ o?.(e), R(e);
489
909
  },
490
910
  onMouseDown: (e) => {
491
- s?.(e), I(e);
911
+ s?.(e), R(e);
492
912
  },
493
913
  onPointerDown: (e) => {
494
- c?.(e), I(e);
914
+ c?.(e), R(e);
495
915
  },
496
- children: r.map((e) => /* @__PURE__ */ M("option", {
916
+ children: r.map((e) => /* @__PURE__ */ A("option", {
497
917
  disabled: e.disabled,
498
918
  value: String(e.value),
499
919
  children: e.label
@@ -501,40 +921,40 @@ function Ve(e, t, n) {
501
921
  });
502
922
  }
503
923
  if (e.type === "radio") {
504
- let n = F(e.props, t), r = Ae(e.options, t), i = n.value ?? ("value" in t ? t.value : void 0), a = "row" in t ? `${t.column.id}-${String(t.row.id)}-radio` : `${t.column.id}-header-radio`, { value: o, ...s } = n;
505
- return /* @__PURE__ */ M("div", {
924
+ let n = ct(e.props, t), r = P(e.options, t), i = n.value ?? ("value" in t ? t.value : void 0), a = "row" in t ? `${t.column.id}-${String(t.row.id)}-radio` : `${t.column.id}-header-radio`, { value: o, ...s } = n;
925
+ return /* @__PURE__ */ A("div", {
506
926
  ...s,
507
- className: P("comins-table__component", "comins-table__component-radio", s.className),
927
+ className: st("comins-table__component", "comins-table__component-radio", s.className),
508
928
  onClick: (e) => {
509
- s.onClick?.(e), I(e);
929
+ s.onClick?.(e), R(e);
510
930
  },
511
931
  onKeyDown: (e) => {
512
- s.onKeyDown?.(e), I(e);
932
+ s.onKeyDown?.(e), R(e);
513
933
  },
514
934
  onMouseDown: (e) => {
515
- s.onMouseDown?.(e), I(e);
935
+ s.onMouseDown?.(e), R(e);
516
936
  },
517
937
  onPointerDown: (e) => {
518
- s.onPointerDown?.(e), I(e);
938
+ s.onPointerDown?.(e), R(e);
519
939
  },
520
940
  role: "radiogroup",
521
- children: r.map((n) => /* @__PURE__ */ N("label", {
522
- onClick: I,
523
- onMouseDown: I,
524
- children: [/* @__PURE__ */ M("input", {
941
+ children: r.map((n) => /* @__PURE__ */ j("label", {
942
+ onClick: R,
943
+ onMouseDown: R,
944
+ children: [/* @__PURE__ */ A("input", {
525
945
  checked: i === void 0 ? void 0 : String(i) === String(n.value),
526
946
  disabled: n.disabled,
527
947
  name: a,
528
- onClick: I,
948
+ onClick: R,
529
949
  onChange: (r) => {
530
- I(r), r.currentTarget.checked && e.onValueChange?.({
950
+ R(r), r.currentTarget.checked && e.onValueChange?.({
531
951
  ...t,
532
952
  value: String(n.value)
533
953
  });
534
954
  },
535
- onKeyDown: I,
536
- onMouseDown: I,
537
- onPointerDown: I,
955
+ onKeyDown: R,
956
+ onMouseDown: R,
957
+ onPointerDown: R,
538
958
  style: {
539
959
  height: 20,
540
960
  width: 20
@@ -545,49 +965,282 @@ function Ve(e, t, n) {
545
965
  }, String(n.value)))
546
966
  });
547
967
  }
548
- if (e.type === "toggle") return /* @__PURE__ */ M(ze, {
968
+ if (e.type === "toggle") return /* @__PURE__ */ A(mt, {
549
969
  component: e,
550
970
  payload: t
551
971
  });
552
- let r = F(e.props, t), i = Number(r.value ?? 0), a = Math.max(1, Number(r.max ?? 100)), o = Math.max(0, Math.min(100, i / a * 100));
553
- return /* @__PURE__ */ M("div", {
972
+ let r = ct(e.props, t), i = Number(r.value ?? 0), a = Math.max(1, Number(r.max ?? 100)), o = Math.max(0, Math.min(100, i / a * 100));
973
+ return /* @__PURE__ */ A("div", {
554
974
  ...r,
555
975
  "aria-valuemax": a,
556
976
  "aria-valuemin": 0,
557
977
  "aria-valuenow": i,
558
- className: P("comins-table__component", "comins-table__component-progress", r.className),
559
- onClick: I,
560
- onKeyDown: I,
561
- onMouseDown: I,
562
- onPointerDown: I,
978
+ className: st("comins-table__component", "comins-table__component-progress", r.className),
979
+ onClick: R,
980
+ onKeyDown: R,
981
+ onMouseDown: R,
982
+ onPointerDown: R,
563
983
  role: "progressbar",
564
- children: /* @__PURE__ */ M("span", { style: { width: `${o}%` } })
984
+ children: /* @__PURE__ */ A("span", { style: { width: `${o}%` } })
565
985
  });
566
986
  }
567
987
  //#endregion
568
- //#region src/summary.ts
569
- function z(e, t) {
988
+ //#region src/row-detail.tsx
989
+ function vt(e) {
990
+ return /* @__PURE__ */ A(et, {
991
+ "aria-controls": e.expanded ? e.controlsId : void 0,
992
+ "aria-expanded": e.expanded,
993
+ "aria-label": e.label,
994
+ className: "comins-row-detail-expander",
995
+ "data-comins-row-leading-control": "disclosure",
996
+ "data-testid": e.testId,
997
+ disabled: e.disabled,
998
+ icon: e.expanded ? "disclosureExpanded" : "disclosureCollapsed",
999
+ id: e.id,
1000
+ onClick: (t) => {
1001
+ t.preventDefault(), t.stopPropagation(), e.onToggle();
1002
+ },
1003
+ onKeyDown: (e) => e.stopPropagation(),
1004
+ onMouseDown: (e) => e.stopPropagation(),
1005
+ onPointerDown: (e) => e.stopPropagation(),
1006
+ ref: e.onElement
1007
+ });
1008
+ }
1009
+ function yt(e) {
1010
+ let t = O(null), n = O(e.getToggleElement), r = O(e.onContentElement), i = e.fixedHeight === void 0;
1011
+ return n.current = e.getToggleElement, r.current = e.onContentElement, Ne(() => {
1012
+ let e = t.current;
1013
+ return r.current(e), () => r.current(null);
1014
+ }, [i]), Ne(() => {
1015
+ let e = t.current;
1016
+ return () => {
1017
+ if (e?.contains(document.activeElement)) {
1018
+ let e = () => {
1019
+ let e = n.current();
1020
+ e?.isConnected && e.focus();
1021
+ };
1022
+ e(), window.requestAnimationFrame(e);
1023
+ }
1024
+ };
1025
+ }, []), /* @__PURE__ */ A("tr", {
1026
+ className: "comins-table__detail-row",
1027
+ "data-detail-for": e.ownerId,
1028
+ children: /* @__PURE__ */ A("td", {
1029
+ className: "comins-table__detail-cell",
1030
+ colSpan: Math.max(1, e.colSpan),
1031
+ children: /* @__PURE__ */ A("div", {
1032
+ "aria-labelledby": e.labelId,
1033
+ className: "comins-table__detail-content",
1034
+ "data-testid": e.testId,
1035
+ id: e.contentId,
1036
+ ref: t,
1037
+ role: "region",
1038
+ style: e.fixedHeight === void 0 ? void 0 : { height: e.fixedHeight },
1039
+ children: e.children
1040
+ })
1041
+ })
1042
+ });
1043
+ }
1044
+ //#endregion
1045
+ //#region src/grouping.ts
1046
+ var bt = /* @__PURE__ */ new Set([
1047
+ "avg",
1048
+ "count",
1049
+ "max",
1050
+ "min",
1051
+ "sum"
1052
+ ]);
1053
+ function xt(e, t) {
570
1054
  return t.split(".").reduce((e, t) => {
571
1055
  if (!(typeof e != "object" || !e)) return e[t];
572
1056
  }, e);
573
1057
  }
1058
+ function St(e, t) {
1059
+ return xt(e, t.field);
1060
+ }
574
1061
  function B(e) {
1062
+ switch (e) {
1063
+ case "avg": return {
1064
+ count: 0,
1065
+ kind: "avg",
1066
+ sum: 0
1067
+ };
1068
+ case "count": return {
1069
+ count: 0,
1070
+ kind: "count"
1071
+ };
1072
+ case "max":
1073
+ case "min": return {
1074
+ hasValue: !1,
1075
+ kind: e,
1076
+ value: 0
1077
+ };
1078
+ case "sum": return {
1079
+ count: 0,
1080
+ kind: "sum",
1081
+ sum: 0
1082
+ };
1083
+ }
1084
+ }
1085
+ function Ct(e, t) {
1086
+ if (e.kind === "count") {
1087
+ e.count += 1;
1088
+ return;
1089
+ }
1090
+ if (!(typeof t != "number" || !Number.isFinite(t))) {
1091
+ if (e.kind === "avg" || e.kind === "sum") {
1092
+ e.count += 1, e.sum += t;
1093
+ return;
1094
+ }
1095
+ if (!e.hasValue) {
1096
+ e.hasValue = !0, e.value = t;
1097
+ return;
1098
+ }
1099
+ e.value = e.kind === "min" ? Math.min(e.value, t) : Math.max(e.value, t);
1100
+ }
1101
+ }
1102
+ function wt(e) {
1103
+ switch (e.kind) {
1104
+ case "avg": return e.count === 0 ? null : e.sum / e.count;
1105
+ case "count": return e.count;
1106
+ case "max":
1107
+ case "min": return e.hasValue ? e.value : null;
1108
+ case "sum": return e.count === 0 ? null : e.sum;
1109
+ }
1110
+ }
1111
+ function Tt(e) {
1112
+ return `group:${typeof e}:${encodeURIComponent(String(e))}`;
1113
+ }
1114
+ function Et(e) {
1115
+ let t = new Map(e.columns.map((e) => [e.id, e])), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
1116
+ for (let [i, a] of Object.entries(e.config.aggregations ?? {})) t.has(i) && typeof a == "string" && bt.has(a) && (n.set(i, a), r.set(i, t.get(i)));
1117
+ let i = [], a = /* @__PURE__ */ new Map(), o = Array.isArray(e.config.groups) ? e.config.groups : [];
1118
+ for (let t of o) {
1119
+ let n = e.config.getGroupId(t);
1120
+ if (a.has(n)) continue;
1121
+ let r = {
1122
+ group: t,
1123
+ groupId: n,
1124
+ groupIndex: i.length,
1125
+ label: e.config.getGroupLabel?.(t) ?? String(n)
1126
+ };
1127
+ i.push(n), a.set(n, r);
1128
+ }
1129
+ return {
1130
+ aggregationColumns: r,
1131
+ aggregations: n,
1132
+ groupIds: i,
1133
+ groupsById: a
1134
+ };
1135
+ }
1136
+ function Dt(e) {
1137
+ let t = /* @__PURE__ */ new Map();
1138
+ for (let n of e.groupIds) {
1139
+ let r = e.groupsById.get(n);
1140
+ if (!r) continue;
1141
+ let i = /* @__PURE__ */ new Map();
1142
+ for (let [t, n] of e.aggregations) i.set(t, B(n));
1143
+ t.set(n, {
1144
+ ...r,
1145
+ aggregationState: i,
1146
+ leafSourceIndexes: []
1147
+ });
1148
+ }
1149
+ for (let n of e.rows) {
1150
+ let r = e.getRowGroupId(n.data, n.dataIndex), i = t.get(r);
1151
+ if (i) {
1152
+ i.leafSourceIndexes.push(n.dataIndex);
1153
+ for (let [t, r] of i.aggregationState) {
1154
+ let i = e.aggregationColumns?.get(t);
1155
+ Ct(r, i ? St(n.data, i) : xt(n.data, t));
1156
+ }
1157
+ }
1158
+ }
1159
+ return {
1160
+ groupIds: [...e.groupIds],
1161
+ groupsById: t
1162
+ };
1163
+ }
1164
+ function Ot(e, t) {
1165
+ return typeof e == "number" && typeof t == "number" ? e - t : String(e ?? "").localeCompare(String(t ?? ""));
1166
+ }
1167
+ function kt(e) {
1168
+ let t = new Map(e.columns.map((e) => [e.id, e])), n = /* @__PURE__ */ new Map(), r = (n) => [...n].sort((n, r) => {
1169
+ let i = e.rows[n], a = e.rows[r];
1170
+ if (i === void 0 || a === void 0) return n - r;
1171
+ for (let n of e.sortModel) {
1172
+ let e = t.get(n.columnId);
1173
+ if (!e?.sort) continue;
1174
+ let r = St(i, e), o = St(a, e), s = typeof e.sort == "function" ? e.sort(r, o, i, a) : Ot(r, o);
1175
+ if (s !== 0) return n.direction === "desc" ? s * -1 : s;
1176
+ }
1177
+ return n - r;
1178
+ });
1179
+ for (let t of e.model.groupIds) {
1180
+ let i = e.model.groupsById.get(t);
1181
+ i && n.set(t, r(i.leafSourceIndexes));
1182
+ }
1183
+ return {
1184
+ ...e.model,
1185
+ groupIds: [...e.model.groupIds],
1186
+ orderedLeafSourceIndexesById: n
1187
+ };
1188
+ }
1189
+ function At(e) {
1190
+ let t = [], n = new Set(e.expandedGroupIds), r = [];
1191
+ for (let i of e.model.groupIds) if (e.model.groupsById.get(i) && (t.push({
1192
+ groupId: i,
1193
+ key: Tt(i),
1194
+ kind: "group"
1195
+ }), n.has(i))) for (let n of e.model.orderedLeafSourceIndexesById.get(i) ?? []) {
1196
+ let i = e.rowIds[n];
1197
+ if (i === void 0) continue;
1198
+ let a = r.length;
1199
+ r.push(i), t.push({
1200
+ dataIndex: n,
1201
+ key: `data:${typeof i}:${encodeURIComponent(String(i))}`,
1202
+ kind: "data",
1203
+ rowId: i,
1204
+ visibleLeafIndex: a
1205
+ });
1206
+ }
1207
+ return {
1208
+ entries: t,
1209
+ visibleLeafRowIds: r
1210
+ };
1211
+ }
1212
+ function jt(e) {
1213
+ let t = [...e.groups], n = t.findIndex((t) => e.getGroupId(t) === e.sourceGroupId);
1214
+ if (n < 0 || e.sourceGroupId === e.targetGroupId) return t;
1215
+ let [r] = t.splice(n, 1), i = t.findIndex((t) => e.getGroupId(t) === e.targetGroupId);
1216
+ if (r === void 0 || i < 0) return [...e.groups];
1217
+ let a = e.position === "after" ? i + 1 : i;
1218
+ return t.splice(a, 0, r), t;
1219
+ }
1220
+ //#endregion
1221
+ //#region src/summary.ts
1222
+ function Mt(e, t) {
1223
+ return t.split(".").reduce((e, t) => {
1224
+ if (!(typeof e != "object" || !e)) return e[t];
1225
+ }, e);
1226
+ }
1227
+ function Nt(e) {
575
1228
  return e.filter((e) => typeof e == "number" && Number.isFinite(e));
576
1229
  }
577
- function He(e, t) {
1230
+ function Pt(e, t) {
578
1231
  if (e === "count") return t.length;
579
- let n = B(t);
1232
+ let n = Nt(t);
580
1233
  return n.length === 0 ? null : e === "sum" ? n.reduce((e, t) => e + t, 0) : e === "avg" ? n.reduce((e, t) => e + t, 0) / n.length : e === "min" ? Math.min(...n) : Math.max(...n);
581
1234
  }
582
- function Ue(e, t, n) {
1235
+ function Ft(e, t, n) {
583
1236
  return Object.entries(n.columns).reduce((n, [r, i]) => {
584
1237
  let a = t.find((e) => e.id === r);
585
1238
  if (!a || !i) return n;
586
- let o = typeof i == "object" && i ? i : void 0, s = typeof i == "object" && i ? i.aggregate : i, c = e.map((e) => z(e, a.field)), l = typeof s == "function" ? s({
1239
+ let o = typeof i == "object" && i ? i : void 0, s = typeof i == "object" && i ? i.aggregate : i, c = e.map((e) => Mt(e, a.field)), l = typeof s == "function" ? s({
587
1240
  column: a,
588
1241
  rows: e,
589
1242
  values: c
590
- }) : He(s, c);
1243
+ }) : Pt(s, c);
591
1244
  return n[r] = o?.format ? o.format({
592
1245
  column: a,
593
1246
  rows: e,
@@ -598,15 +1251,15 @@ function Ue(e, t, n) {
598
1251
  }
599
1252
  //#endregion
600
1253
  //#region src/tree.ts
601
- function We(e) {
1254
+ function It(e) {
602
1255
  return e.join(".");
603
1256
  }
604
- function Ge(e, t) {
1257
+ function Lt(e, t) {
605
1258
  let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = 0, a = (e, o) => {
606
1259
  e.forEach((e, s) => {
607
1260
  let c = [...o, s], l = t(e.item, i);
608
1261
  if (i += 1, n.has(l)) throw Error(`Duplicate tree row id: ${String(l)}`);
609
- n.set(l, c), r.set(We(c), l), e.children?.length && a(e.children, c);
1262
+ n.set(l, c), r.set(It(c), l), e.children?.length && a(e.children, c);
610
1263
  });
611
1264
  };
612
1265
  return a(e, []), {
@@ -614,17 +1267,17 @@ function Ge(e, t) {
614
1267
  idByPath: r
615
1268
  };
616
1269
  }
617
- function V(e, t, n) {
1270
+ function Rt(e, t, n) {
618
1271
  let [r, ...i] = t;
619
1272
  return r === void 0 ? [...e] : e.map((e, t) => t === r ? i.length === 0 ? n(e) : e.children ? {
620
1273
  ...e,
621
- children: V(e.children, i, n)
1274
+ children: Rt(e.children, i, n)
622
1275
  } : e : e);
623
1276
  }
624
- function Ke(e, t, n = {}) {
625
- let r = Ge(e, t), i = [], a = (e, t, o) => {
1277
+ function zt(e, t, n = {}) {
1278
+ let r = Lt(e, t), i = [], a = (e, t, o) => {
626
1279
  e.forEach((e, s) => {
627
- let c = [...o, s], l = e.children ?? [], u = l.length > 0, d = e.expand ?? n.defaultExpandAll ?? !1, f = r.idByPath.get(We(c));
1280
+ let c = [...o, s], l = e.children ?? [], u = l.length > 0, d = e.expand ?? n.defaultExpandAll ?? !1, f = r.idByPath.get(It(c));
628
1281
  f !== void 0 && (i.push({
629
1282
  depth: t,
630
1283
  expanded: d,
@@ -637,65 +1290,223 @@ function Ke(e, t, n = {}) {
637
1290
  };
638
1291
  return a(e, 0, []), i;
639
1292
  }
640
- function H(e) {
641
- return e.flatMap((e) => e.children?.length ? H(e.children) : [e.item]);
1293
+ function V(e) {
1294
+ return e.flatMap((e) => e.children?.length ? V(e.children) : [e.item]);
642
1295
  }
643
- function qe(e, t, n, r = {}) {
644
- let i = Ge(e, n).byId.get(t);
645
- return i ? V(e, i, (e) => ({
1296
+ function Bt(e, t, n, r = {}) {
1297
+ let i = Lt(e, n).byId.get(t);
1298
+ return i ? Rt(e, i, (e) => ({
646
1299
  ...e,
647
1300
  expand: !(e.expand ?? r.defaultExpandAll ?? !1)
648
1301
  })) : [...e];
649
1302
  }
650
- function U(e, t, n, r) {
651
- let i = Ge(e, n).byId.get(t);
652
- return i ? V(e, i, (e) => ({
1303
+ function Vt(e, t, n, r) {
1304
+ let i = Lt(e, n).byId.get(t);
1305
+ return i ? Rt(e, i, (e) => ({
653
1306
  ...e,
654
1307
  item: r(e.item)
655
1308
  })) : [...e];
656
1309
  }
657
- function W(e, t) {
1310
+ function Ht(e, t) {
658
1311
  return [...e].sort((e, n) => t(e.item, n.item)).map((e) => ({
659
1312
  ...e,
660
- children: e.children ? W(e.children, t) : void 0
1313
+ children: e.children ? Ht(e.children, t) : void 0
661
1314
  }));
662
1315
  }
663
1316
  //#endregion
664
- //#region src/index.tsx
665
- var Je = 50;
666
- function Ye(e, t, n, r, i) {
667
- let a = Math.max(0, r), o = e?.length ?? t.length, s = Math.min(o, Math.max(a, i)), c = [];
668
- for (let r = a; r < s; r += 1) {
669
- let i = e?.[r] ?? r, a = t[i], o = n[i];
670
- a !== void 0 && o !== void 0 && c.push({
671
- dataIndex: i,
672
- row: a,
673
- rowId: o,
674
- visibleIndex: r
675
- });
1317
+ //#region src/virtual-layout.ts
1318
+ var Ut = 15e5;
1319
+ function Wt(e) {
1320
+ return `data:${typeof e}:${encodeURIComponent(String(e))}`;
1321
+ }
1322
+ function Gt(e) {
1323
+ return {
1324
+ dataIndex: e.dataIndex,
1325
+ ...e.detail ? { detail: e.detail } : {},
1326
+ key: Wt(e.rowId),
1327
+ kind: "data",
1328
+ row: e.row,
1329
+ rowId: e.rowId,
1330
+ visibleIndex: e.visibleIndex
1331
+ };
1332
+ }
1333
+ function Kt(e, t) {
1334
+ return typeof e == "number" && Number.isFinite(e) && e > 0 ? e : Math.max(1, t);
1335
+ }
1336
+ function qt(e) {
1337
+ return typeof e == "number" && Number.isFinite(e) && e > 0 ? {
1338
+ height: e,
1339
+ mode: "fixed"
1340
+ } : { mode: "auto" };
1341
+ }
1342
+ var Jt = class e {
1343
+ heights;
1344
+ tree;
1345
+ totalHeight;
1346
+ constructor(e) {
1347
+ this.heights = Float64Array.from(e, (e) => Math.max(0, e)), this.tree = new Float64Array(this.heights.length + 1), this.totalHeight = 0;
1348
+ for (let e = 0; e < this.heights.length; e += 1) {
1349
+ let t = e + 1, n = this.heights[e] ?? 0, r = t + (t & -t);
1350
+ this.tree[t] = (this.tree[t] ?? 0) + n, this.totalHeight += n, r < this.tree.length && (this.tree[r] = (this.tree[r] ?? 0) + (this.tree[t] ?? 0));
1351
+ }
1352
+ }
1353
+ static from(t) {
1354
+ return new e(t);
1355
+ }
1356
+ add(e, t) {
1357
+ for (let n = e + 1; n < this.tree.length; n += n & -n) this.tree[n] = (this.tree[n] ?? 0) + t;
1358
+ }
1359
+ getHeight(e) {
1360
+ return this.heights[e] ?? 0;
1361
+ }
1362
+ getPrefixHeight(e) {
1363
+ let t = 0;
1364
+ for (let n = Math.min(this.heights.length, Math.max(0, e)); n > 0; n -= n & -n) t += this.tree[n] ?? 0;
1365
+ return t;
676
1366
  }
677
- return c;
1367
+ getTotalHeight() {
1368
+ return this.totalHeight;
1369
+ }
1370
+ findIndexAtOffset(e) {
1371
+ if (this.heights.length === 0 || this.totalHeight <= 0) return 0;
1372
+ let t = Math.min(Math.max(0, e), Math.max(0, this.getTotalHeight() - 2 ** -52)), n = 0, r = 0, i = 1;
1373
+ for (; i * 2 < this.tree.length;) i *= 2;
1374
+ for (; i > 0; i = Math.floor(i / 2)) {
1375
+ let e = n + i, a = r + (this.tree[e] ?? 0);
1376
+ e < this.tree.length && a <= t && (n = e, r = a);
1377
+ }
1378
+ return Math.min(this.heights.length - 1, n);
1379
+ }
1380
+ updateHeight(e, t) {
1381
+ let n = Math.max(0, t), r = this.heights[e];
1382
+ if (r === void 0) return 0;
1383
+ let i = n - r;
1384
+ return this.heights[e] = n, this.totalHeight += i, this.add(e, i), i;
1385
+ }
1386
+ };
1387
+ function Yt(e, t) {
1388
+ return e.kind === "group" ? e.height : t + (e.detail?.height ?? 0);
678
1389
  }
679
- function Xe(e) {
1390
+ function Xt(e, t) {
1391
+ let n = Math.min(e, Ut), r = Math.max(0, e - t), i = Math.max(0, n - t);
1392
+ return {
1393
+ logicalScrollableHeight: r,
1394
+ physicalScrollableHeight: i,
1395
+ physicalScrollHeight: n,
1396
+ scrollScale: r > 0 && i > 0 ? r / i : 1
1397
+ };
1398
+ }
1399
+ function Zt(e) {
1400
+ let t = Xt(e.heightIndex.getTotalHeight(), e.viewportHeight), n = Math.min(t.physicalScrollableHeight, Math.max(0, e.physicalScrollTop)), r = Math.min(t.logicalScrollableHeight, n * t.scrollScale), i = e.heightIndex.findIndexAtOffset(r), a = e.heightIndex.findIndexAtOffset(r + Math.max(0, e.viewportHeight)), o = Math.max(0, i - Math.max(0, e.overscan)), s = Math.min(a + Math.max(0, e.overscan) + 1, e.heightIndex.findIndexAtOffset(Infinity) + 1), c = e.heightIndex.getPrefixHeight(o);
1401
+ return {
1402
+ endIndex: s,
1403
+ logicalScrollTop: r,
1404
+ logicalStartOffset: c,
1405
+ physicalScrollHeight: t.physicalScrollHeight,
1406
+ renderOffset: n - (r - c),
1407
+ scrollScale: t.scrollScale,
1408
+ startIndex: o
1409
+ };
1410
+ }
1411
+ function Qt(e, t, n, r) {
1412
+ let i = e.get(t);
1413
+ return i && i.width === Math.round(n) ? {
1414
+ estimated: !1,
1415
+ height: i.height
1416
+ } : {
1417
+ estimated: !0,
1418
+ height: r
1419
+ };
1420
+ }
1421
+ function $t(e, t) {
1422
+ for (let n of e.keys()) t.has(n) || e.delete(n);
1423
+ }
1424
+ function en(e) {
1425
+ if (e.keys.length === 0) return;
1426
+ let t = e.heightIndex.findIndexAtOffset(e.logicalScrollTop), n = e.keys[t];
1427
+ if (n === void 0) return;
1428
+ let r = e.heightIndex.getPrefixHeight(t);
1429
+ return {
1430
+ key: n,
1431
+ offsetWithinSlot: Math.max(0, e.logicalScrollTop - r),
1432
+ previousIndex: t
1433
+ };
1434
+ }
1435
+ function tn(e) {
1436
+ let t = e.nextKeys.indexOf(e.anchor.key);
1437
+ if (t === -1) for (let n = Math.min(e.anchor.previousIndex - 1, e.previousKeys.length - 1); n >= 0 && (t = e.nextKeys.indexOf(e.previousKeys[n] ?? ""), t === -1); --n);
1438
+ if (t === -1) for (let n = Math.max(0, e.anchor.previousIndex + 1); n < e.previousKeys.length && (t = e.nextKeys.indexOf(e.previousKeys[n] ?? ""), t === -1); n += 1);
1439
+ if (t !== -1) return {
1440
+ index: t,
1441
+ offsetWithinSlot: Math.min(Math.max(0, e.anchor.offsetWithinSlot), Math.max(0, e.getNextHeight(t)))
1442
+ };
1443
+ }
1444
+ function nn(e, t, n) {
1445
+ let r = Xt(t, n);
1446
+ return Math.min(r.physicalScrollableHeight, Math.max(0, e) / r.scrollScale);
1447
+ }
1448
+ //#endregion
1449
+ //#region src/index.tsx
1450
+ var rn = 88;
1451
+ function an(e, t, n) {
1452
+ return e.id === t.id && e.kind === t.kind ? "neutral" : e.depth !== t.depth || e.parentGroupId !== t.parentGroupId ? "invalid" : n ? "valid" : "invalid";
1453
+ }
1454
+ function on(e, t) {
1455
+ return e.selection.rowIds.includes(t) ? e : fe(e, t);
1456
+ }
1457
+ function sn(e) {
1458
+ return e.mixed, e.keys;
1459
+ }
1460
+ function cn(e) {
1461
+ let t = sn(e.projection), n = e.logicalScrollTop ?? (e.projection.mixed ? Zt({
1462
+ heightIndex: e.projection.heightIndex,
1463
+ overscan: 0,
1464
+ physicalScrollTop: e.physicalScrollTop,
1465
+ viewportHeight: e.viewportHeight
1466
+ }).logicalScrollTop : (() => {
1467
+ let t = Xt(e.projection.visibleRowCount * e.projection.rowHeight, e.viewportHeight);
1468
+ return Math.min(t.logicalScrollableHeight, Math.max(0, e.physicalScrollTop) * t.scrollScale);
1469
+ })()), r = e.projection.mixed ? en({
1470
+ heightIndex: e.projection.heightIndex,
1471
+ keys: t,
1472
+ logicalScrollTop: n
1473
+ }) : (() => {
1474
+ if (e.projection.visibleRowCount === 0) return;
1475
+ let r = Math.min(e.projection.visibleRowCount - 1, Math.floor(n / e.projection.rowHeight)), i = t[r];
1476
+ return i === void 0 ? void 0 : {
1477
+ key: i,
1478
+ offsetWithinSlot: n - r * e.projection.rowHeight,
1479
+ previousIndex: r
1480
+ };
1481
+ })();
1482
+ return r ? {
1483
+ anchor: r,
1484
+ previousKeys: t,
1485
+ previousLogicalScrollTop: n,
1486
+ previousPhysicalScrollTop: e.physicalScrollTop,
1487
+ previousViewportHeight: e.viewportHeight
1488
+ } : void 0;
1489
+ }
1490
+ function ln(e) {
680
1491
  return !e || typeof e == "string" ? e : Object.entries(e).filter(([, e]) => e).map(([e]) => e).join(" ");
681
1492
  }
682
- function G(e, t, n) {
1493
+ function un(e, t, n) {
683
1494
  return typeof e == "function" ? e(t, n) : e;
684
1495
  }
685
- function Ze(e, t, n) {
686
- let r = G(e?.disabled, t, n) === !0;
1496
+ function dn(e, t, n) {
1497
+ let r = un(e?.disabled, t, n) === !0;
687
1498
  return {
688
- className: Xe(G(e?.className, t, n)),
1499
+ className: ln(un(e?.className, t, n)),
689
1500
  disabled: r,
690
- draggable: !r && G(e?.draggable, t, n) !== !1,
691
- style: G(e?.style, t, n)
1501
+ draggable: !r && un(e?.draggable, t, n) !== !1,
1502
+ style: un(e?.style, t, n)
692
1503
  };
693
1504
  }
694
- function Qe(e) {
1505
+ function fn(e) {
695
1506
  let t = e?.background ?? e?.backgroundColor;
696
1507
  return typeof t == "string" || typeof t == "number" ? t : void 0;
697
1508
  }
698
- function $e(e, t, n) {
1509
+ function pn(e, t, n) {
699
1510
  let r = {
700
1511
  height: e,
701
1512
  ...t
@@ -705,7 +1516,7 @@ function $e(e, t, n) {
705
1516
  "--comins-table-row-custom-background": n
706
1517
  };
707
1518
  }
708
- function et(e) {
1519
+ function mn(e) {
709
1520
  return {
710
1521
  data: e.row,
711
1522
  dataIndex: e.dataIndex,
@@ -713,7 +1524,7 @@ function et(e) {
713
1524
  index: e.visibleIndex
714
1525
  };
715
1526
  }
716
- function tt(e, t) {
1527
+ function hn(e, t) {
717
1528
  return {
718
1529
  definition: e,
719
1530
  field: e.field,
@@ -722,23 +1533,23 @@ function tt(e, t) {
722
1533
  label: e.label
723
1534
  };
724
1535
  }
725
- function nt(e, t) {
1536
+ function gn(e, t) {
726
1537
  return {
727
1538
  event: e,
728
1539
  index: t.visibleIndex,
729
- row: et(t)
1540
+ row: mn(t)
730
1541
  };
731
1542
  }
732
- function rt(e, t, n, r, i) {
1543
+ function _n(e, t, n, r, i) {
733
1544
  return {
734
- column: tt(n, r),
1545
+ column: hn(n, r),
735
1546
  event: e,
736
1547
  index: t.visibleIndex,
737
- row: et(t),
1548
+ row: mn(t),
738
1549
  value: i
739
1550
  };
740
1551
  }
741
- function it(e, t) {
1552
+ function vn(e, t) {
742
1553
  return {
743
1554
  definition: e,
744
1555
  field: e.field,
@@ -747,9 +1558,9 @@ function it(e, t) {
747
1558
  label: e.label
748
1559
  };
749
1560
  }
750
- function at(e, t, n, r, i, a, o) {
1561
+ function yn(e, t, n, r, i, a, o) {
751
1562
  return {
752
- column: it(i, a),
1563
+ column: vn(i, a),
753
1564
  row: {
754
1565
  data: e.row,
755
1566
  dataIndex: e.dataIndex,
@@ -762,31 +1573,31 @@ function at(e, t, n, r, i, a, o) {
762
1573
  value: o
763
1574
  };
764
1575
  }
765
- function ot(e, t) {
1576
+ function bn(e, t) {
766
1577
  let n = e.cell?.props;
767
1578
  return typeof n == "function" ? n(t) : n;
768
1579
  }
769
- function st(e, t) {
1580
+ function xn(e, t) {
770
1581
  return e === void 0 ? !0 : typeof e == "boolean" ? e : e(t);
771
1582
  }
772
- function ct(e, t) {
773
- return e?.disabled !== void 0 && st(e.disabled, t) === !0;
1583
+ function Sn(e, t) {
1584
+ return e?.disabled !== void 0 && xn(e.disabled, t) === !0;
774
1585
  }
775
- function lt(e, t) {
1586
+ function Cn(e, t) {
776
1587
  let n = e?.className;
777
1588
  return typeof n == "function" ? n(t) : n;
778
1589
  }
779
- function ut(e, t) {
1590
+ function wn(e, t) {
780
1591
  let n = e?.style;
781
1592
  return typeof n == "function" ? n(t) : n;
782
1593
  }
783
- function dt(e, t, n) {
1594
+ function Tn(e, t, n) {
784
1595
  return e.cell?.format ? e.cell.format(n) : t == null ? "" : String(t);
785
1596
  }
786
- function ft(e, t, n) {
787
- let r = e.columnState[t.id], i = Tt(e.sortModel, t.id);
1597
+ function En(e, t, n) {
1598
+ let r = e.columnState[t.id], i = Wn(e.sortModel, t.id);
788
1599
  return {
789
- column: it(t, n),
1600
+ column: vn(t, n),
790
1601
  layout: {
791
1602
  hidden: r?.hidden === !0 || t.hidden === !0,
792
1603
  width: r?.width ?? t.width
@@ -799,102 +1610,152 @@ function ft(e, t, n) {
799
1610
  }
800
1611
  };
801
1612
  }
802
- function pt(e) {
1613
+ function H(e) {
803
1614
  return "row" in e && "selection" in e;
804
1615
  }
805
- function K(e, t) {
806
- return !pt(t) || e.type !== "input" && e.type !== "select" || t.selection.selectedRowCount === 1 && t.row.selected;
1616
+ function Dn(e, t) {
1617
+ return !H(t) || e.type !== "input" && e.type !== "select" || t.selection.selectedRowCount === 1 && t.row.selected;
807
1618
  }
808
- function mt(e, t) {
809
- return (e ?? []).filter((e) => K(e, t));
1619
+ function On(e, t) {
1620
+ return (e ?? []).filter((e) => Dn(e, t));
810
1621
  }
811
- function ht(e, t, n, r) {
812
- return mt(e, t).map((e, t) => ({
1622
+ function kn(e, t, n, r) {
1623
+ return On(e, t).map((e, t) => ({
813
1624
  component: e,
814
1625
  index: t
815
- })).filter(({ component: e }) => (e.direction ?? "left") === n).map(({ component: e, index: i }) => /* @__PURE__ */ M("span", {
1626
+ })).filter(({ component: e }) => (e.direction ?? "left") === n).map(({ component: e, index: i }) => /* @__PURE__ */ A("span", {
816
1627
  className: "comins-table__component-slot",
817
1628
  "data-comins-component-align": e.align ?? "center",
818
1629
  "data-comins-component-direction": n,
819
1630
  "data-comins-component-id": e.id ?? `${e.type}-${i}`,
820
- children: Ve(e, t, r)
1631
+ children: _t(e, t, r)
821
1632
  }, e.id ?? `${e.type}-${i}`));
822
1633
  }
823
- function gt(e, t, n, r = {}) {
1634
+ function U(e) {
1635
+ e.preventDefault(), e.stopPropagation();
1636
+ }
1637
+ function An(e) {
1638
+ e.stopPropagation(), e.target instanceof HTMLElement && e.target.blur();
1639
+ }
1640
+ var jn = /* @__PURE__ */ new WeakSet();
1641
+ function Mn(e) {
1642
+ if (!e || jn.has(e)) return;
1643
+ let t = (t) => {
1644
+ e.hasAttribute("inert") && e.getAttribute("aria-hidden") === "true" && (t.preventDefault(), t.stopPropagation());
1645
+ };
1646
+ e.addEventListener("change", t, !0), e.addEventListener("input", t, !0), jn.add(e);
1647
+ }
1648
+ var Nn = {
1649
+ onBeforeInputCapture: U,
1650
+ onBlurCapture: U,
1651
+ onChangeCapture: U,
1652
+ onClickCapture: U,
1653
+ onContextMenuCapture: U,
1654
+ onDoubleClickCapture: U,
1655
+ onFocusCapture: An,
1656
+ onInputCapture: U,
1657
+ onKeyDownCapture: U,
1658
+ onKeyPressCapture: U,
1659
+ onKeyUpCapture: U,
1660
+ onMouseDownCapture: U,
1661
+ onMouseMoveCapture: U,
1662
+ onMouseOutCapture: U,
1663
+ onMouseOverCapture: U,
1664
+ onMouseUpCapture: U,
1665
+ onPointerCancelCapture: U,
1666
+ onPointerDownCapture: U,
1667
+ onPointerMoveCapture: U,
1668
+ onPointerOutCapture: U,
1669
+ onPointerOverCapture: U,
1670
+ onPointerUpCapture: U,
1671
+ onResetCapture: U,
1672
+ onScrollCapture: U,
1673
+ onSubmitCapture: U,
1674
+ onTouchCancelCapture: U,
1675
+ onTouchEndCapture: U,
1676
+ onTouchMoveCapture: U,
1677
+ onTouchStartCapture: U,
1678
+ onWheelCapture: U
1679
+ };
1680
+ function Pn(e, t) {
1681
+ let n = (e) => typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(n).join("") : Ae(e) && typeof e.type == "string" ? n(e.props.children) : "";
1682
+ return n(e).trim() || t;
1683
+ }
1684
+ function Fn(e, t, n, r = {}) {
824
1685
  if (!t?.length) return e;
825
- let i = r.showContent ?? !0, a = mt(t, n);
1686
+ let i = r.showContent ?? !0, a = On(t, n);
826
1687
  if (!a.length) return e;
827
- let o = ht(a, n, "left", r.interaction), s = ht(a, n, "right", r.interaction);
828
- return i ? /* @__PURE__ */ N("span", {
1688
+ let o = kn(a, n, "left", r.interaction), s = kn(a, n, "right", r.interaction);
1689
+ return i ? /* @__PURE__ */ j("span", {
829
1690
  className: "comins-table__component-layout",
830
1691
  children: [
831
- /* @__PURE__ */ M("span", {
1692
+ /* @__PURE__ */ A("span", {
832
1693
  className: "comins-table__component-group",
833
1694
  "data-comins-component-direction": "left",
834
1695
  children: o
835
1696
  }),
836
- /* @__PURE__ */ M("span", {
1697
+ /* @__PURE__ */ A("span", {
837
1698
  className: "comins-table__component-content",
838
1699
  children: e
839
1700
  }),
840
- /* @__PURE__ */ M("span", {
1701
+ /* @__PURE__ */ A("span", {
841
1702
  className: "comins-table__component-group",
842
1703
  "data-comins-component-direction": "right",
843
1704
  children: s
844
1705
  })
845
1706
  ]
846
- }) : /* @__PURE__ */ M("span", {
1707
+ }) : /* @__PURE__ */ A("span", {
847
1708
  className: "comins-table__component-layout",
848
1709
  "data-comins-component-only": "true",
849
- children: /* @__PURE__ */ N("span", {
1710
+ children: /* @__PURE__ */ j("span", {
850
1711
  className: "comins-table__component-group",
851
1712
  "data-comins-component-direction": "all",
852
1713
  children: [o, s]
853
1714
  })
854
1715
  });
855
1716
  }
856
- function _t(e) {
857
- return Math.max(Je, e.minWidth ?? Je);
1717
+ function In(e) {
1718
+ return Math.max(rn, e.minWidth ?? rn);
858
1719
  }
859
- function vt(e) {
1720
+ function Ln(e) {
860
1721
  return e.maxWidth ?? Infinity;
861
1722
  }
862
- function yt(e, t) {
1723
+ function W(e, t) {
863
1724
  return e.columnState[t.id]?.width ?? t.width ?? 100;
864
1725
  }
865
- function q(e, t, n) {
1726
+ function Rn(e, t, n) {
866
1727
  return Math.min(n, Math.max(t, e));
867
1728
  }
868
- function bt(e, t, n) {
869
- let r = t.map((t) => q(yt(e, t), _t(t), vt(t))), i = new Set(t.map((e, t) => t)), a = t.map(_t), o = t.map(vt), s = q(n, a.reduce((e, t) => e + t, 0), o.reduce((e, t) => e + t, 0));
1729
+ function zn(e, t, n) {
1730
+ let r = t.map((t) => Rn(W(e, t), In(t), Ln(t))), i = new Set(t.map((e, t) => t)), a = t.map(In), o = t.map(Ln), s = Rn(n, a.reduce((e, t) => e + t, 0), o.reduce((e, t) => e + t, 0));
870
1731
  for (; i.size > 0;) {
871
1732
  let e = s - r.reduce((e, t) => e + t, 0);
872
1733
  if (Math.abs(e) < .001) break;
873
1734
  let t = [...i], n = t.reduce((e, t) => e + Math.max(r[t] ?? 0, 0), 0), c = !1;
874
1735
  for (let s of t) {
875
- let l = r[s] ?? 0, u = l + e * (n > 0 ? l / n : 1 / t.length), d = q(u, a[s] ?? 0, o[s] ?? Infinity);
1736
+ let l = r[s] ?? 0, u = l + e * (n > 0 ? l / n : 1 / t.length), d = Rn(u, a[s] ?? 0, o[s] ?? Infinity);
876
1737
  r[s] = d, Math.abs(d - u) > .001 && (i.delete(s), c = !0);
877
1738
  }
878
1739
  if (!c) break;
879
1740
  }
880
1741
  return r;
881
1742
  }
882
- function xt(e, t, n) {
1743
+ function Bn(e, t, n) {
883
1744
  let r = e.columnGroups.find((e) => e.children.includes(t));
884
- if (!r || e.columnGroupState[r.id]?.hidden === !0) return D(e, t, n);
1745
+ if (!r || e.columnGroupState[r.id]?.hidden === !0) return ve(e, t, n);
885
1746
  let i = r.children.map((t) => e.columns.find((e) => e.id === t)).filter((e) => !!e).filter((t) => e.columnState[t.id]?.hidden !== !0), a = i.find((e) => e.id === t);
886
- if (!a) return D(e, t, n);
1747
+ if (!a) return ve(e, t, n);
887
1748
  let o = i.filter((e) => e.id !== t);
888
1749
  if (o.length === 0) {
889
- let r = yt(e, a);
890
- return D(e, t, q(n, _t(a), Math.min(vt(a), r)));
1750
+ let r = W(e, a);
1751
+ return ve(e, t, Rn(n, In(a), Math.min(Ln(a), r)));
891
1752
  }
892
- let s = i.reduce((t, n) => t + yt(e, n), 0), c = o.reduce((e, t) => e + _t(t), 0), l = o.reduce((e, t) => e + vt(t), 0), u = Math.max(_t(a), s - l), d = q(n, u, Math.max(u, Math.min(vt(a), s - c))), f = bt(e, o, s - d), p = D(e, t, d);
1753
+ let s = i.reduce((t, n) => t + W(e, n), 0), c = o.reduce((e, t) => e + In(t), 0), l = o.reduce((e, t) => e + Ln(t), 0), u = Math.max(In(a), s - l), d = Rn(n, u, Math.max(u, Math.min(Ln(a), s - c))), f = zn(e, o, s - d), p = ve(e, t, d);
893
1754
  return o.forEach((e, t) => {
894
- p = D(p, e.id, f[t] ?? yt(p, e));
1755
+ p = ve(p, e.id, f[t] ?? W(p, e));
895
1756
  }), p;
896
1757
  }
897
- function St(e, t, n) {
1758
+ function Vn(e, t, n) {
898
1759
  if (!e || typeof e != "object") return e;
899
1760
  let r = t.split("."), [i] = r;
900
1761
  if (!i) return e;
@@ -908,7 +1769,7 @@ function St(e, t, n) {
908
1769
  o[e] = a, n && (o = a);
909
1770
  }), o[r.at(-1)] = n, a;
910
1771
  }
911
- function Ct(e, t) {
1772
+ function Hn(e, t) {
912
1773
  return e?.columnId === t ? e.direction === "asc" ? {
913
1774
  columnId: t,
914
1775
  direction: "desc"
@@ -917,60 +1778,60 @@ function Ct(e, t) {
917
1778
  direction: "asc"
918
1779
  };
919
1780
  }
920
- function wt(e, t, n) {
921
- let r = e.findIndex((e) => e.columnId === t), i = Ct(r < 0 ? null : e[r] ?? null, t);
1781
+ function Un(e, t, n) {
1782
+ let r = e.findIndex((e) => e.columnId === t), i = Hn(r < 0 ? null : e[r] ?? null, t);
922
1783
  return n ? i ? r < 0 ? [...e, i] : e.map((e, t) => t === r ? i : e) : e.filter((e) => e.columnId !== t) : i ? [i] : [];
923
1784
  }
924
- function Tt(e, t) {
1785
+ function Wn(e, t) {
925
1786
  let n = e.findIndex((e) => e.columnId === t);
926
1787
  return n < 0 ? null : {
927
1788
  priority: n + 1,
928
1789
  rule: e[n]
929
1790
  };
930
1791
  }
931
- function Et(e, t) {
932
- let n = Tt(e, t)?.rule;
1792
+ function Gn(e, t) {
1793
+ let n = Wn(e, t)?.rule;
933
1794
  return n ? n.direction : "none";
934
1795
  }
935
- function Dt(e, t) {
936
- let n = Tt(e, t);
1796
+ function Kn(e, t) {
1797
+ let n = Wn(e, t);
937
1798
  if (!n) return e.length > 1 ? void 0 : "none";
938
1799
  if (!(n.priority > 1)) return n.rule.direction === "asc" ? "ascending" : "descending";
939
1800
  }
940
- function Ot(e, t) {
1801
+ function qn(e, t) {
941
1802
  return !e || !t ? e === t : e.columnId === t.columnId && e.direction === t.direction;
942
1803
  }
943
- function kt(e, t) {
1804
+ function Jn(e, t) {
944
1805
  return e.length === t.length && e.every((e, n) => e.columnId === t[n]?.columnId && e.direction === t[n]?.direction);
945
1806
  }
946
- function At(e, t) {
1807
+ function Yn(e, t) {
947
1808
  return e.length === t.length && e.every((e, n) => e === t[n]);
948
1809
  }
949
- function jt(e, t) {
950
- if (!At(e.rowIds, t.rowIds)) return !1;
1810
+ function Xn(e, t) {
1811
+ if (!Yn(e.rowIds, t.rowIds)) return !1;
951
1812
  let n = new Set(t.columns.map((e) => e.id)), r = e.selection.cell, i = e.selection.range;
952
1813
  return !(r && !n.has(r.columnId) || i && (!n.has(i.anchor.columnId) || !n.has(i.focus.columnId)));
953
1814
  }
954
- function Mt(e, t) {
1815
+ function Zn(e, t) {
955
1816
  return t.split(".").reduce((e, t) => {
956
1817
  if (!(typeof e != "object" || !e)) return e[t];
957
1818
  }, e);
958
1819
  }
959
- function J(e, t) {
1820
+ function Qn(e, t) {
960
1821
  return typeof e == "number" && typeof t == "number" ? e - t : String(e ?? "").localeCompare(String(t ?? ""));
961
1822
  }
962
- function Nt(e, t, n) {
963
- return n.length === 0 ? e : W(e, (e, r) => {
1823
+ function $n(e, t, n) {
1824
+ return n.length === 0 ? e : Ht(e, (e, r) => {
964
1825
  for (let i of n) {
965
1826
  let n = t.find((e) => (e.id ?? e.field) === i.columnId);
966
1827
  if (!n?.sort) continue;
967
- let a = Mt(e, n.field), o = Mt(r, n.field), s = typeof n.sort == "function" ? n.sort(a, o, e, r) : J(a, o);
1828
+ let a = Zn(e, n.field), o = Zn(r, n.field), s = typeof n.sort == "function" ? n.sort(a, o, e, r) : Qn(a, o);
968
1829
  if (s !== 0) return i.direction === "desc" ? s * -1 : s;
969
1830
  }
970
1831
  return 0;
971
1832
  });
972
1833
  }
973
- function Pt(e, t, n, r, i) {
1834
+ function er(e, t, n, r, i) {
974
1835
  if (t?.length === 0) return e;
975
1836
  let a = [], o = /* @__PURE__ */ new Map(), s = 0, c = (e, t) => {
976
1837
  e.forEach((e) => {
@@ -1002,190 +1863,648 @@ function Pt(e, t, n, r, i) {
1002
1863
  };
1003
1864
  return m(e);
1004
1865
  }
1005
- function Ft({ "buffer-size": e, cellSelection: n = !0, className: r, columnGroups: l, columns: u, data: d, "data-testid": f, emptyComponent: p, getRowId: m, hasMoreRows: h = !1, infiniteScroll: v = !1, infiniteScrollThreshold: y = 160, lazyLoad: x = !1, lazyLoadBatchSize: S = 30, lazyLoadMode: w = "append", lazyLoadThreshold: te, loading: se = !1, loadingComponent: ce, loadingMore: pe = !1, multiSort: he = !1, onChangeColumnLayout: ge, onChangeData: _e, onChangeSelection: be, onChangeSort: xe, onChangeSortModel: Te, onClickCell: Ee, onClickRow: Oe, onContextMenuCell: P, onContextMenuRow: F, onDoubleClickCell: Ae, onDoubleClickRow: je, onKeyDownCell: Me, onKeyDownRow: Ne, onLazyLoad: Pe, onLoadMore: Fe, pagination: I, persistHeaderWhenEmpty: Ie = !0, rowHeight: L = 36, rowProps: Le, showHeader: Re = !0, skeletonRowCount: ze, style: Be, summary: R, theme: Ve, treeContext: z, virtualized: B = !1 }, He) {
1006
- let We = A(null), Ge = A(null), V = A(null), Ke = A(null), H = A(null), qe = A(null), U = A(null), W = A(null), Je = A(null), G = A(null), et = A(null), tt = A(0), it = A(d), st = A(void 0), pt = A(null), K = A(null), vt = A(null), yt = A(null), q = A(!1), bt = A(null), Ct = A(0), At = A(null), Mt = A(null), J = A(null), [Nt, Pt] = j(0), [Ft, It] = j(0), [Lt, Rt] = j(null), [zt, Bt] = j(null), [Vt, Ht] = j(null), [Ut, Wt] = j(null), [Gt, Kt] = j(null), [qt, Jt] = j(d), [Yt, Xt] = j(void 0), [Zt, Qt] = j(null), [$t, en] = j(null), [tn, nn] = j(0), rn = x ? qt : d, [Y, an] = j(() => c({
1007
- columnGroups: l,
1008
- columns: u,
1009
- getRowId: m,
1010
- pagination: I,
1011
- rows: rn,
1012
- showHeader: Re,
1013
- theme: Ve
1014
- })), X = A(Y), on = A({
1015
- columnGroups: l,
1016
- columns: u,
1017
- data: rn,
1018
- getRowId: m,
1019
- pagination: I,
1020
- showHeader: Re
1021
- }), sn = Math.max(0, Math.floor(Number.isFinite(e) ? Number(e) : 10)), cn = Math.max(1, Math.floor(S)), ln = Math.max(0, Math.floor(te ?? y)), un = () => {
1022
- let e = U.current;
1023
- U.current = null, e?.();
1024
- }, dn = (e) => {
1025
- un(), U.current = e;
1026
- }, fn = (e) => {
1027
- if (!x || w !== "append" || !Pe || et.current) return;
1028
- let t = X.current.rows.length;
1029
- if (e === "scroll" && st.current !== void 0 && t >= st.current) return;
1030
- let n = new AbortController(), r = tt.current + 1, i = e === "scroll" ? t : 0;
1031
- tt.current = r, G.current?.abort(), G.current = n, et.current = e, e !== "scroll" && (Ct.current = 0, nn(0), We.current && (We.current.scrollTop = 0)), Kt(e), Pe({
1032
- limit: cn,
1033
- offset: i,
1034
- reason: e,
1035
- signal: n.signal
1036
- }).then((t) => {
1037
- if (n.signal.aborted || tt.current !== r) return;
1038
- let i = e === "scroll" ? [...it.current, ...t.rows] : [...t.rows];
1039
- it.current = i, st.current = t.total, Jt(i), Xt(t.total);
1040
- }).catch(() => {}).finally(() => {
1041
- tt.current === r && (et.current = null, G.current = null, Kt(null));
1866
+ function tr({ "buffer-size": e, cellSelection: n = !0, className: r, columnFiltering: l, columnGroups: u, columns: d, data: f, "data-testid": p, emptyComponent: m, estimatedRowDetailHeight: h, expandedRowIds: v, getRowDetailHeight: y, getRowId: x, hasMoreRows: te = !1, infiniteScroll: re = !1, infiniteScrollThreshold: S = 160, lazyLoad: T = !1, lazyLoadBatchSize: le = 30, lazyLoadMode: he = "append", lazyLoadThreshold: _e, loading: ye = !1, loadingComponent: be, loadingMore: Ce = !1, multiSort: we = !1, onChangeColumnLayout: Ee, onChangeData: ke, onChangeSelection: Ae, onChangeSort: Pe, onChangeSortModel: Fe, onClickCell: Ie, onClickRow: Le, onContextMenuCell: Re, onContextMenuRow: ze, onChangeExpandedRowIds: He, onDoubleClickCell: Ue, onDoubleClickRow: We, onKeyDownCell: Ge, onKeyDownRow: Ke, onLazyLoad: qe, onLoadMore: Je, pagination: Ye, persistHeaderWhenEmpty: Ze = !0, rowHeight: M = 36, rowGrouping: N, rowProps: tt, isRowExpandable: nt, renderRowDetail: rt, showColumnMoveHandle: it = !0, showHeader: at = !0, skeletonRowCount: st, style: ct, summary: P, theme: lt, treeContext: F, virtualized: I = !1 }, ut) {
1867
+ let L = O(null), R = O(null), z = O(null), dt = O(null), ft = O(null), pt = O(null), mt = O(/* @__PURE__ */ new Map()), ht = O(/* @__PURE__ */ new Map()), gt = O(/* @__PURE__ */ new Set()), _t = O(null), bt = O(/* @__PURE__ */ new Set()), xt = O(null), St = O(/* @__PURE__ */ new Map()), B = O(null), Ct = O(null), Tt = O(null), Ot = O(null), Mt = O(/* @__PURE__ */ new Map()), Nt = O(null), Pt = O(null), It = O(null), Lt = O(qe), Rt = O(0), zt = O(null), V = O(null), Bt = O(null), Vt = O(null), Ht = O(!1), Ut = O(null), Xt = O(null), en = O(/* @__PURE__ */ new Map()), rn = O(null), un = O(null), hn = O(null), vn = O(0), xn = O(null), H = O(null), Dn = O(0), U = O(null), An = O(null), jn = O(null), W = O(null), [zn, Hn] = k(0), [Yn, Zn] = k(0), [Qn, $n] = k(0), [er, tr] = k(null), [nr, rr] = k(null), [ir, ar] = k(null), [or, sr] = k(null), [cr, lr] = k(null), [ur, dr] = k(null), [fr, pr] = k(null), [mr, hr] = k(null), [gr, _r] = k(0), vr = je(), yr = f, G = !F && typeof N == "object" && !!N && N !== void 0 && Array.isArray(N.groups) && typeof N.getGroupId == "function" && typeof N.getRowGroupId == "function", K = !F && typeof l == "object" && !!l && l !== void 0 && Array.isArray(l.model), br = D(() => G ? {
1868
+ pageIndex: 0,
1869
+ pageSize: Math.max(1, yr.length)
1870
+ } : Ye, [
1871
+ yr.length,
1872
+ G,
1873
+ Ye
1874
+ ]), xr = K ? {
1875
+ ...tt,
1876
+ draggable: !1
1877
+ } : tt, [q, Sr] = k(() => c({
1878
+ columnGroups: u,
1879
+ columns: d,
1880
+ getRowId: x,
1881
+ pagination: br,
1882
+ rows: yr,
1883
+ showHeader: at,
1884
+ theme: lt
1885
+ })), J = O(q), Cr = O({
1886
+ columnGroups: u,
1887
+ columns: d,
1888
+ data: yr,
1889
+ getRowId: x,
1890
+ pagination: br,
1891
+ showHeader: at
1892
+ }), wr = Math.max(0, Math.floor(Number.isFinite(e) ? Number(e) : 10)), Tr = Math.max(1, Math.floor(le)), Er = Math.max(0, Math.floor(_e ?? S)), Dr = typeof qe == "function", Or = typeof rt == "function" && !F, kr = D(() => {
1893
+ let e = /* @__PURE__ */ new Set();
1894
+ return (v ?? []).filter((t) => !e.has(t) && (e.add(t), !0));
1895
+ }, [v]), Ar = D(() => new Set(kr), [kr]), jr = (e, t) => {
1896
+ !Or || !t || !He || He(Ar.has(e) ? kr.filter((t) => t !== e) : [...kr, e]);
1897
+ }, Mr = () => {
1898
+ let e = B.current;
1899
+ B.current = null, e?.();
1900
+ }, Nr = (e) => {
1901
+ Mr(), B.current = e;
1902
+ };
1903
+ Ne(() => {
1904
+ Lt.current = qe;
1905
+ }, [qe]);
1906
+ let Pr = (e) => {
1907
+ let t = Lt.current;
1908
+ if (G || K || !T || he !== "append" || !t || It.current) return;
1909
+ let n = J.current.rows.length;
1910
+ if (e === "scroll" && (!te || ye || Ce)) return;
1911
+ let r = new AbortController(), i = Rt.current + 1, a = e === "scroll" ? n : 0;
1912
+ Rt.current = i, Pt.current?.abort(), Pt.current = r, It.current = e, e !== "scroll" && (Dn.current = 0, _r(0), L.current && (L.current.scrollTop = 0));
1913
+ let o;
1914
+ try {
1915
+ o = t({
1916
+ limit: Tr,
1917
+ offset: a,
1918
+ reason: e,
1919
+ signal: r.signal
1920
+ });
1921
+ } catch {
1922
+ It.current = null, Pt.current = null;
1923
+ return;
1924
+ }
1925
+ Promise.resolve(o).catch(() => {}).finally(() => {
1926
+ Rt.current === i && (It.current = null, Pt.current = null);
1042
1927
  });
1043
1928
  };
1044
- O(() => {
1045
- it.current = qt;
1046
- }, [qt]), O(() => {
1047
- st.current = Yt;
1048
- }, [Yt]), O(() => {
1049
- x || (it.current = d, Jt(d), st.current = void 0, Xt(void 0));
1050
- }, [d, x]), O(() => {
1051
- if (!(!x || !Pe)) return fn("initial"), () => {
1052
- tt.current += 1, et.current = null, G.current?.abort(), G.current = null;
1929
+ E(() => {
1930
+ if (!(G || K || !T || !Dr)) return Pr("initial"), () => {
1931
+ Rt.current += 1, It.current = null, Pt.current?.abort(), Pt.current = null;
1053
1932
  };
1054
1933
  }, [
1055
- x,
1056
- Pe,
1057
- cn
1058
- ]), O(() => {
1059
- let e = on.current;
1060
- if (e.columns === u && e.columnGroups === l && e.data === rn && e.getRowId === m && e.pagination === I && e.showHeader === Re) return;
1061
- on.current = {
1062
- columnGroups: l,
1063
- columns: u,
1064
- data: rn,
1065
- getRowId: m,
1066
- pagination: I,
1067
- showHeader: Re
1934
+ K,
1935
+ G,
1936
+ Dr,
1937
+ T,
1938
+ Tr
1939
+ ]), E(() => {
1940
+ let e = Cr.current;
1941
+ if (e.columns === d && e.columnGroups === u && e.data === yr && e.getRowId === x && e.pagination === br && e.showHeader === at) return;
1942
+ Cr.current = {
1943
+ columnGroups: u,
1944
+ columns: d,
1945
+ data: yr,
1946
+ getRowId: x,
1947
+ pagination: br,
1948
+ showHeader: at
1068
1949
  };
1069
- let t = X.current, n = c({
1070
- columnLayout: fe(t),
1071
- columnGroups: l,
1072
- columns: u,
1073
- getRowId: m,
1074
- pagination: I ?? t.pagination,
1075
- rows: rn,
1076
- showHeader: Re,
1950
+ let t = J.current, n = c({
1951
+ columnLayout: me(t),
1952
+ columnGroups: u,
1953
+ columns: d,
1954
+ getRowId: x,
1955
+ pagination: br ?? t.pagination,
1956
+ rows: yr,
1957
+ showHeader: at,
1077
1958
  sortModel: t.sortModel,
1078
1959
  theme: t.theme
1079
- }), r = jt(t, n) ? {
1960
+ }), r = Xn(t, n) ? {
1080
1961
  ...n,
1081
1962
  selection: t.selection
1082
1963
  } : n;
1083
- X.current = r, an(r), Ot(r.sort, t.sort) || xe?.(r.sort), kt(r.sortModel, t.sortModel) || Te?.(r.sortModel);
1964
+ if (e.getRowId !== x) {
1965
+ let e = new Map(t.rowIds.map((e, n) => [e, t.rows[n]]));
1966
+ r.rowIds.forEach((t, n) => {
1967
+ e.has(t) && e.get(t) !== r.rows[n] && mt.current.delete(t);
1968
+ });
1969
+ }
1970
+ J.current = r, Sr(r), qn(r.sort, t.sort) || Pe?.(r.sort), Jn(r.sortModel, t.sortModel) || Fe?.(r.sortModel);
1084
1971
  }, [
1085
- l,
1086
1972
  u,
1087
- rn,
1088
- m,
1089
- I,
1090
- Re
1091
- ]), O(() => {
1092
- X.current = Y;
1093
- }, [Y]), O(() => {
1094
- pt.current !== null && pt.current !== Y.rows.length && (pt.current = null);
1095
- }, [Y.rows.length]), O(() => () => {
1096
- un(), Mt.current !== null && window.cancelAnimationFrame(Mt.current), At.current !== null && window.clearTimeout(At.current);
1097
- }, []), O(() => {
1098
- let e = We.current;
1973
+ d,
1974
+ yr,
1975
+ br,
1976
+ x,
1977
+ at
1978
+ ]), E(() => {
1979
+ J.current = q;
1980
+ }, [q]), E(() => {
1981
+ zt.current !== null && zt.current !== q.rows.length && (zt.current = null);
1982
+ }, [q.rows.length]), E(() => () => {
1983
+ Mr(), jn.current !== null && window.cancelAnimationFrame(jn.current), An.current !== null && window.clearTimeout(An.current);
1984
+ }, []), E(() => {
1985
+ let e = L.current;
1099
1986
  if (!e || typeof ResizeObserver > "u") return;
1100
1987
  let t = new ResizeObserver(([e]) => {
1101
- e && (Pt(e.contentRect.height), It(e.contentRect.width));
1988
+ e && (Hn(e.contentRect.height), Zn(e.contentRect.width));
1102
1989
  });
1103
1990
  return t.observe(e), () => t.disconnect();
1991
+ }, []), E(() => {
1992
+ $t(mt.current, new Set(q.rowIds));
1993
+ }, [q.rowIds]);
1994
+ let Fr = (e, t, n, r) => {
1995
+ let i = e.projection;
1996
+ if (!i || r !== e.contentWidth) return !1;
1997
+ let a = i.slotIndexByRowId.get(t), o = a === void 0 ? void 0 : i.slots[a];
1998
+ if (a === void 0 || o?.kind !== "data" || o.detail?.mode !== "auto") return !1;
1999
+ let s = i.heightIndex.getHeight(a) - o.detail.height + n, c = i.heightIndex.updateHeight(a, s);
2000
+ return o.detail.estimated = !1, o.detail.height = n, c !== 0;
2001
+ }, Ir = (e) => {
2002
+ let t = xt.current;
2003
+ if (!t) return;
2004
+ let n = e.filter(({ height: e, rowId: t, width: n }) => {
2005
+ let r = mt.current.get(t);
2006
+ return !r || r.width !== n || Math.abs(r.height - e) >= .5;
2007
+ });
2008
+ if (n.length === 0) return;
2009
+ let r = t.projection, i = L.current, a = i?.clientHeight || t.viewportHeight, o = H.current, s = o?.status === "pending" ? o : !o && r && i ? cn({
2010
+ logicalScrollTop: xn.current && Math.abs(i.scrollTop - xn.current.actualPhysical) <= .5 ? xn.current.targetLogical : void 0,
2011
+ physicalScrollTop: i.scrollTop,
2012
+ projection: {
2013
+ heightIndex: r.heightIndex,
2014
+ keys: r.keys,
2015
+ mixed: !0
2016
+ },
2017
+ viewportHeight: a
2018
+ }) : void 0, c = !1;
2019
+ for (let e of n) mt.current.set(e.rowId, {
2020
+ height: e.height,
2021
+ width: e.width
2022
+ }), c = Fr(t, e.rowId, e.height, e.width) || c;
2023
+ if (s && c && o?.status !== "pending") {
2024
+ let e = vn.current + 1;
2025
+ vn.current = e, H.current = {
2026
+ ...s,
2027
+ revision: e,
2028
+ status: "pending"
2029
+ };
2030
+ }
2031
+ (c || !r) && $n((e) => e + 1);
2032
+ }, Lr = () => {
2033
+ if (typeof ResizeObserver > "u") return null;
2034
+ let e = new ResizeObserver((e) => {
2035
+ let t = [];
2036
+ for (let n of e) {
2037
+ let e = ht.current.get(n.target);
2038
+ if (!e) continue;
2039
+ let r = (Array.isArray(n.borderBoxSize) ? n.borderBoxSize[0] : n.borderBoxSize)?.blockSize ?? n.target.getBoundingClientRect().height, i = Math.round(n.target.getBoundingClientRect().width);
2040
+ Number.isFinite(r) && r > 0 && t.push({
2041
+ height: r,
2042
+ rowId: e.rowId,
2043
+ width: i
2044
+ });
2045
+ }
2046
+ Ir(t);
2047
+ });
2048
+ _t.current = e;
2049
+ for (let t of ht.current.values()) bt.current.add(t.element), e.observe(t.element);
2050
+ return e;
2051
+ };
2052
+ Ne(() => () => {
2053
+ _t.current?.disconnect(), _t.current = null, bt.current.clear(), ht.current.clear(), gt.current.clear(), xt.current = null;
1104
2054
  }, []);
1105
- let pn = (e, t, n = {}) => {
1106
- t.rows !== e.rows && _e?.(t.rows), t.selection !== e.selection && be?.(t.selection), n.columnLayoutChanged && ge?.(fe(t)), Ot(t.sort, e.sort) || xe?.(t.sort), kt(t.sortModel, e.sortModel) || Te?.(t.sortModel);
1107
- }, Z = (e, t = {}) => {
1108
- let n = X.current, r = typeof e == "function" ? e(n) : e;
1109
- X.current = r, an(r), pn(n, r, t);
1110
- }, Q = k(() => ee(Y), [Y]), mn = k(() => _(Y), [Y]), hn = k(() => R ? Ue(z?.summaryRows ?? Y.rows, Q, R) : null, [
1111
- Y.rows,
1112
- R,
1113
- z?.summaryRows,
1114
- Q
1115
- ]), gn = k(() => {
1116
- if (!R) return [];
2055
+ let Rr = () => {
2056
+ ht.current.size === 0 && (_t.current?.disconnect(), _t.current = null, bt.current.clear());
2057
+ }, zr = (e, t, n) => {
2058
+ for (let [t, r] of ht.current) r.rowId === e && t !== n && (_t.current?.unobserve(t), bt.current.delete(t), ht.current.delete(t), gt.current.delete(t));
2059
+ if (!n || t === "fixed") {
2060
+ Rr();
2061
+ return;
2062
+ }
2063
+ ht.current.set(n, {
2064
+ element: n,
2065
+ rowId: e
2066
+ });
2067
+ }, Br = (e, t, n = {}) => {
2068
+ t.rows !== e.rows && ke?.(t.rows), t.selection !== e.selection && Ae?.(t.selection), n.columnLayoutChanged && Ee?.(me(t)), qn(t.sort, e.sort) || Pe?.(t.sort), Jn(t.sortModel, e.sortModel) || Fe?.(t.sortModel);
2069
+ }, Y = (e, t = {}) => {
2070
+ let n = J.current, r = typeof e == "function" ? e(n) : e;
2071
+ J.current = r, Sr(r), Br(n, r, t);
2072
+ }, X = D(() => ee(q), [q]), Vr = /* @__PURE__ */ new Map();
2073
+ E(() => {
2074
+ Mt.current = Vr;
2075
+ });
2076
+ let Hr = D(() => {
2077
+ let e = X.length;
2078
+ if (e === 0) return [];
2079
+ let t = X.map((e) => q.columnState[e.id]?.width ?? e.width);
2080
+ if (Yn <= 0) {
2081
+ let n = `${100 / e}%`;
2082
+ return t.map((e, t) => {
2083
+ if (e === void 0) return n;
2084
+ let r = X[t];
2085
+ return Rn(e, In(r), Ln(r));
2086
+ });
2087
+ }
2088
+ let n = 0;
2089
+ for (let e of t) n += e ?? 0;
2090
+ let r = X.filter((e, n) => t[n] === void 0), i = r.length > 0 ? Math.max(0, (Yn - n) / r.length) : 0;
2091
+ return X.map((e, n) => {
2092
+ let r = t[n] ?? i, a = In(e), o = e.maxWidth ?? Infinity;
2093
+ return Math.min(o, Math.max(a, r));
2094
+ });
2095
+ }, [
2096
+ Yn,
2097
+ q.columnState,
2098
+ X
2099
+ ]), Ur = D(() => {
2100
+ let e = 0;
2101
+ for (let t of Hr) {
2102
+ if (typeof t != "number") return;
2103
+ e += t;
2104
+ }
2105
+ return e;
2106
+ }, [Hr]), Wr = D(() => {
2107
+ if (typeof Ur == "number") return Math.max(Yn, Ur);
2108
+ }, [Ur, Yn]), Gr = typeof Wr == "number" && Number.isFinite(Wr) ? Math.round(Wr) : 0, Kr = D(() => _(q), [q]), qr = D(() => K ? Xe({
2109
+ columns: q.columns,
2110
+ model: l?.model
2111
+ }) : [], [
2112
+ l?.model,
2113
+ K,
2114
+ q.columns
2115
+ ]), Jr = qr.length > 0, Yr = D(() => new Map(qr.map((e) => [e.column.id, e])), [qr]), Xr = D(() => K ? Qe({
2116
+ columns: q.columns,
2117
+ model: l?.model,
2118
+ rows: q.rows.map((e, t) => ({
2119
+ data: e,
2120
+ dataIndex: t,
2121
+ id: q.rowIds[t]
2122
+ }))
2123
+ }) : q.rows.map((e, t) => t), [
2124
+ l?.model,
2125
+ K,
2126
+ q.columns,
2127
+ q.rowIds,
2128
+ q.rows
2129
+ ]), Zr = D(() => Xr.flatMap((e) => {
2130
+ let t = q.rows[e];
2131
+ return t === void 0 ? [] : [t];
2132
+ }), [Xr, q.rows]), Qr = D(() => P ? Ft(F?.summaryRows ?? Zr, X, P) : null, [
2133
+ Zr,
2134
+ P,
2135
+ F?.summaryRows,
2136
+ X
2137
+ ]), $r = D(() => {
2138
+ if (!P) return [];
1117
2139
  let e = [], t = 0;
1118
- for (; t < Q.length;) {
1119
- let n = Q[t], r = R.columns[n.id], i = typeof r == "object" && r ? r : void 0, a = i?.colSpan, o = Math.min(typeof a == "number" && Number.isFinite(a) ? Math.max(1, Math.floor(a)) : 1, Q.length - t);
2140
+ for (; t < X.length;) {
2141
+ let n = X[t], r = P.columns[n.id], i = typeof r == "object" && r ? r : void 0, a = i?.colSpan, o = Math.min(typeof a == "number" && Number.isFinite(a) ? Math.max(1, Math.floor(a)) : 1, X.length - t);
1120
2142
  e.push({
1121
2143
  className: i?.className,
1122
2144
  colSpan: o,
1123
2145
  column: n,
1124
2146
  style: i?.style,
1125
- value: hn?.[n.id] ?? (e.length === 0 ? R.label : null)
2147
+ value: Qr?.[n.id] ?? (e.length === 0 ? P.label : null)
1126
2148
  }), t += o;
1127
2149
  }
1128
2150
  return e;
1129
2151
  }, [
1130
- R,
1131
- hn,
1132
- Q
1133
- ]), _n = k(() => z || Y.sortModel.length === 0 ? null : b(Y), [Y, z]), vn = _n?.length ?? Y.rows.length, yn = Math.max(0, Y.pagination.pageIndex) * Math.max(1, Y.pagination.pageSize), bn = k(() => {
1134
- if (B) {
1135
- let e = Math.max(1, L), t = Nt || L * 12, n = vn * e, r = Math.min(n, 15e5), i = Math.max(0, n - t), a = Math.max(0, r - t), o = i > 0 && a > 0 ? i / a : 1, s = Math.min(i, Math.max(0, tn) * o), c = Math.max(0, Math.floor(s / e) - sn), l = Math.min(vn, Math.ceil((s + Math.max(0, t)) / e) + sn), u = c * e, d = o > 0 ? u / o : u;
2152
+ P,
2153
+ Qr,
2154
+ X
2155
+ ]), ei = N?.aggregations, ti = N?.getGroupId, ni = N?.getGroupLabel, ri = N?.getRowGroupId, ii = N?.groups, ai = D(() => G && ti && ri && ii ? Et({
2156
+ columns: q.columns,
2157
+ config: {
2158
+ aggregations: ei,
2159
+ getGroupId: ti,
2160
+ getGroupLabel: ni,
2161
+ getRowGroupId: ri,
2162
+ groups: ii
2163
+ }
2164
+ }) : null, [
2165
+ ei,
2166
+ ti,
2167
+ ni,
2168
+ ri,
2169
+ ii,
2170
+ G,
2171
+ q.columns
2172
+ ]), oi = D(() => ai && ri ? Dt({
2173
+ ...ai,
2174
+ getRowGroupId: ri,
2175
+ rows: Xr.flatMap((e) => {
2176
+ let t = q.rows[e], n = q.rowIds[e];
2177
+ return t === void 0 || n === void 0 ? [] : [{
2178
+ data: t,
2179
+ dataIndex: e,
2180
+ id: n
2181
+ }];
2182
+ })
2183
+ }) : null, [
2184
+ Xr,
2185
+ ri,
2186
+ ai,
2187
+ q.rowIds,
2188
+ q.rows
2189
+ ]), Z = D(() => oi ? kt({
2190
+ columns: q.columns,
2191
+ model: oi,
2192
+ rows: q.rows,
2193
+ sortModel: q.sortModel
2194
+ }) : null, [
2195
+ oi,
2196
+ q.columns,
2197
+ q.rows,
2198
+ q.sortModel
2199
+ ]), si = D(() => {
2200
+ let e = /* @__PURE__ */ new Set();
2201
+ return (Array.isArray(N?.expandedGroupIds) ? N.expandedGroupIds : []).filter((t) => !Z?.groupsById.has(t) || e.has(t) ? !1 : (e.add(t), !0));
2202
+ }, [Z, N?.expandedGroupIds]), ci = D(() => new Set(si), [si]), li = (e) => {
2203
+ let t = N?.onChangeExpandedGroupIds;
2204
+ typeof t != "function" || !Z?.groupsById.has(e) || t(ci.has(e) ? si.filter((t) => t !== e) : [...si, e]);
2205
+ }, Q = D(() => Z ? At({
2206
+ expandedGroupIds: si,
2207
+ model: Z,
2208
+ rowIds: q.rowIds
2209
+ }) : null, [
2210
+ si,
2211
+ Z,
2212
+ q.rowIds
2213
+ ]), ui = Q !== null;
2214
+ Ne(() => {
2215
+ if (!Q || !Z) {
2216
+ hn.current = null, rn.current = null;
2217
+ return;
2218
+ }
2219
+ let e = rn.current;
2220
+ if (e !== null) {
2221
+ let t = en.current.get(e);
2222
+ t && (rn.current = null, un.current = null, t.focus());
2223
+ }
2224
+ let t = new Set(Q.entries.flatMap((e) => e.kind === "data" ? [e.dataIndex] : [])), n = hn.current, r = un.current;
2225
+ if (hn.current = t, r === null || !n?.has(r) || t.has(r)) return;
2226
+ let i = document.activeElement;
2227
+ if (!(i && (L.current?.contains(i) || i === document.body))) return;
2228
+ let a = [...Z.groupsById.values()].find((e) => e.leafSourceIndexes.includes(r))?.groupId;
2229
+ a !== void 0 && en.current.get(a)?.focus();
2230
+ }, [Q, Z]);
2231
+ let di = D(() => F || ui ? null : b(q, Xr), [
2232
+ Xr,
2233
+ ui,
2234
+ q,
2235
+ F
2236
+ ]), fi = D(() => Q ? Q.entries.flatMap((e) => e.kind === "data" ? [e.dataIndex] : []) : di ?? Xr, [
2237
+ Xr,
2238
+ Q,
2239
+ di
2240
+ ]), pi = fi.length, mi = Q?.entries.length ?? pi, hi = Math.max(1, q.pagination.pageSize), gi = Math.max(0, Math.ceil(pi / hi) - 1), _i = Math.min(Math.max(0, q.pagination.pageIndex), gi) * hi;
2241
+ E(() => {
2242
+ if (!Q && !K) return;
2243
+ let e = new Set(Q?.visibleLeafRowIds ?? fi.flatMap((e) => {
2244
+ let t = q.rowIds[e];
2245
+ return t === void 0 ? [] : [t];
2246
+ })), t = J.current, n = t.selection.cell !== null && !e.has(t.selection.cell.rowId), r = t.selection.range !== null && (!e.has(t.selection.range.anchor.rowId) || !e.has(t.selection.range.focus.rowId));
2247
+ !n && !r || (n && (Nt.current = null), Bt.current = null, Vt.current = null, Y({
2248
+ ...t,
2249
+ selection: {
2250
+ ...t.selection,
2251
+ cell: n ? null : t.selection.cell,
2252
+ range: r || n ? null : t.selection.range
2253
+ }
2254
+ }));
2255
+ }, [
2256
+ K,
2257
+ Q,
2258
+ fi,
2259
+ q.rowIds
2260
+ ]);
2261
+ let vi = D(() => {
2262
+ if (!Or) return /* @__PURE__ */ new Set();
2263
+ let e = /* @__PURE__ */ new Set(), t = I || ui ? 0 : _i, n = I || ui ? fi.length : Math.min(fi.length, _i + hi);
2264
+ for (let r = t; r < n; r += 1) {
2265
+ let t = fi[r];
2266
+ if (t === void 0) continue;
2267
+ let n = q.rows[t], i = q.rowIds[t];
2268
+ if (n === void 0 || i === void 0 || !Ar.has(i)) continue;
2269
+ let a = { row: mn({
2270
+ dataIndex: t,
2271
+ row: n,
2272
+ rowId: i,
2273
+ visibleIndex: r
2274
+ }) };
2275
+ nt?.(a) !== !1 && e.add(i);
2276
+ }
2277
+ return e;
2278
+ }, [
2279
+ Ar,
2280
+ ui,
2281
+ nt,
2282
+ hi,
2283
+ _i,
2284
+ fi,
2285
+ Or,
2286
+ q.rowIds,
2287
+ q.rows,
2288
+ I
2289
+ ]), yi = D(() => {
2290
+ let e = Math.max(1, M);
2291
+ return (Q?.entries ?? fi.map((e, t) => {
2292
+ let n = q.rowIds[e];
2293
+ return n === void 0 ? null : {
2294
+ dataIndex: e,
2295
+ key: Wt(n),
2296
+ kind: "data",
2297
+ rowId: n,
2298
+ visibleLeafIndex: t
2299
+ };
2300
+ }).filter((e) => e !== null)).flatMap((t) => {
2301
+ if (t.kind === "group") return [{
2302
+ groupId: t.groupId,
2303
+ height: e,
2304
+ key: t.key,
2305
+ kind: "group"
2306
+ }];
2307
+ let { dataIndex: n, rowId: r, visibleLeafIndex: i } = t, a = q.rows[n];
2308
+ if (a === void 0 || r === void 0) return [];
2309
+ let o = null;
2310
+ if (vi.has(r)) {
2311
+ let e = { row: mn({
2312
+ dataIndex: n,
2313
+ row: a,
2314
+ rowId: r,
2315
+ visibleIndex: i
2316
+ }) }, t = qt(y?.(e));
2317
+ o = t.mode === "auto" ? {
2318
+ ...Qt(mt.current, r, Gr, Kt(h, M)),
2319
+ mode: "auto"
2320
+ } : {
2321
+ estimated: !1,
2322
+ height: t.height,
2323
+ mode: "fixed"
2324
+ };
2325
+ }
2326
+ return [Gt({
2327
+ dataIndex: n,
2328
+ detail: o,
2329
+ row: a,
2330
+ rowHeight: e,
2331
+ rowId: r,
2332
+ visibleIndex: i
2333
+ })];
2334
+ });
2335
+ }, [
2336
+ Gr,
2337
+ I ? 0 : Qn,
2338
+ vi,
2339
+ h,
2340
+ y,
2341
+ Q,
2342
+ fi,
2343
+ M,
2344
+ q.rowIds,
2345
+ q.rows
2346
+ ]), bi = D(() => {
2347
+ if (!I || vi.size === 0) return null;
2348
+ let e = Math.max(1, M), t = yi, n = Jt.from(t.map((t) => Yt(t, e))), r = /* @__PURE__ */ new Map();
2349
+ for (let e = 0; e < t.length; e += 1) {
2350
+ let n = t[e], i = n?.kind === "data" ? n.rowId : void 0;
2351
+ i !== void 0 && !r.has(i) && r.set(i, e);
2352
+ }
2353
+ return {
2354
+ heightIndex: n,
2355
+ keys: t.map((e) => e.key),
2356
+ slotIndexByRowId: r,
2357
+ slots: t
2358
+ };
2359
+ }, [
2360
+ vi,
2361
+ yi,
2362
+ M,
2363
+ I
2364
+ ]), xi = D(() => ({
2365
+ contentWidth: Gr,
2366
+ projection: bi,
2367
+ viewportHeight: zn || Math.max(1, M) * 12
2368
+ }), [
2369
+ zn,
2370
+ Gr,
2371
+ bi,
2372
+ M
2373
+ ]);
2374
+ Ne(() => {
2375
+ if (xt.current = xi, ht.current.size === 0) {
2376
+ Rr();
2377
+ return;
2378
+ }
2379
+ if (typeof ResizeObserver < "u") {
2380
+ let e = _t.current, t = e ?? Lr();
2381
+ if (e) for (let e of ht.current.values()) bt.current.has(e.element) || (bt.current.add(e.element), t?.observe(e.element));
2382
+ return;
2383
+ }
2384
+ let e = [];
2385
+ for (let t of ht.current.values()) {
2386
+ if (gt.current.has(t.element)) continue;
2387
+ gt.current.add(t.element);
2388
+ let n = t.element.getBoundingClientRect();
2389
+ Number.isFinite(n.height) && n.height > 0 && e.push({
2390
+ height: n.height,
2391
+ rowId: t.rowId,
2392
+ width: Math.round(n.width)
2393
+ });
2394
+ }
2395
+ Ir(e);
2396
+ });
2397
+ let Si = D(() => {
2398
+ if (I) {
2399
+ let e = Math.max(1, M), t = zn || M * 12;
2400
+ if (bi) {
2401
+ let e = cr && Math.abs(gr - cr.actualPhysical) <= .5 ? cr : null, n = Zt({
2402
+ heightIndex: bi.heightIndex,
2403
+ overscan: wr,
2404
+ physicalScrollTop: e?.requestedPhysical ?? gr,
2405
+ viewportHeight: t
2406
+ });
2407
+ return {
2408
+ mixed: !0,
2409
+ renderOffset: e ? e.actualPhysical - (e.targetLogical - n.logicalStartOffset) : n.renderOffset,
2410
+ scrollHeight: n.physicalScrollHeight,
2411
+ slots: bi.slots.slice(n.startIndex, n.endIndex)
2412
+ };
2413
+ }
2414
+ let n = mi * e, r = Math.min(n, 15e5), i = Math.max(0, n - t), a = Math.max(0, r - t), o = i > 0 && a > 0 ? i / a : 1, s = Math.min(i, Math.max(0, gr) * o), c = Math.max(0, Math.floor(s / e) - wr), l = Math.min(mi, Math.ceil((s + Math.max(0, t)) / e) + wr), u = c * e;
1136
2415
  return {
1137
- entries: Ye(_n, Y.rows, Y.rowIds, c, l),
1138
- renderOffset: d,
1139
- scrollHeight: r
2416
+ mixed: !1,
2417
+ renderOffset: o > 0 ? u / o : u,
2418
+ scrollHeight: r,
2419
+ slots: yi.slice(c, l)
1140
2420
  };
1141
2421
  }
1142
2422
  return {
1143
- entries: Ye(_n, Y.rows, Y.rowIds, yn, yn + Math.max(1, Y.pagination.pageSize)),
2423
+ mixed: !1,
1144
2424
  renderOffset: 0,
1145
- scrollHeight: 0
2425
+ scrollHeight: 0,
2426
+ slots: ui ? yi : yi.slice(_i, _i + hi)
1146
2427
  };
1147
2428
  }, [
1148
- Nt,
1149
- yn,
1150
- L,
1151
- tn,
1152
- _n,
1153
- Y.pagination.pageSize,
1154
- Y.rowIds,
1155
- Y.rows,
1156
- sn,
1157
- B,
1158
- vn
1159
- ]), xn = Ve ?? Y.theme, Sn = xn.density === "compact" ? "text-[11px]" : xn.density === "spacious" ? "text-[13px]" : "text-[length:var(--comins-font-size-base,12px)]", Cn = k(() => new Set(Y.selection.rowIds), [Y.selection.rowIds]), wn = k(() => {
1160
- let e = Q.length;
1161
- if (e === 0) return [];
1162
- let t = Q.map((e) => Y.columnState[e.id]?.width ?? e.width);
1163
- if (Ft <= 0) {
1164
- let n = `${100 / e}%`;
1165
- return t.map((e) => e ?? n);
2429
+ zn,
2430
+ Qn,
2431
+ yi,
2432
+ ui,
2433
+ cr,
2434
+ bi,
2435
+ _i,
2436
+ M,
2437
+ gr,
2438
+ hi,
2439
+ wr,
2440
+ I,
2441
+ mi
2442
+ ]), $ = D(() => I ? bi ? {
2443
+ heightIndex: bi.heightIndex,
2444
+ keys: bi.keys,
2445
+ mixed: !0
2446
+ } : {
2447
+ keys: yi.map((e) => e.key),
2448
+ mixed: !1,
2449
+ rowHeight: Math.max(1, M),
2450
+ visibleRowCount: mi
2451
+ } : null, [
2452
+ bi,
2453
+ yi,
2454
+ M,
2455
+ I,
2456
+ mi
2457
+ ]), Ci = U.current, wi = H.current, Ti = !wi && $ && Ci && $ !== Ci && L.current ? cn({
2458
+ logicalScrollTop: cr && Math.abs(L.current.scrollTop - cr.actualPhysical) <= .5 ? cr.targetLogical : void 0,
2459
+ physicalScrollTop: L.current.scrollTop,
2460
+ projection: Ci,
2461
+ viewportHeight: L.current.clientHeight || zn || M * 12
2462
+ }) : void 0, Ei = wi?.status === "pending" ? wi : Ti;
2463
+ Ne(() => {
2464
+ if (!$) {
2465
+ U.current = null, H.current = null, xn.current = null, lr(null);
2466
+ return;
1166
2467
  }
1167
- let n = 0;
1168
- for (let e of t) n += e ?? 0;
1169
- let r = Q.filter((e, n) => t[n] === void 0), i = r.length > 0 ? Math.max(0, (Ft - n) / r.length) : 0;
1170
- return Q.map((e, n) => {
1171
- let r = t[n] ?? i, a = _t(e), o = e.maxWidth ?? Infinity;
1172
- return Math.min(o, Math.max(a, r));
1173
- });
1174
- }, [
1175
- Ft,
1176
- Y.columnState,
1177
- Q
1178
- ]), Tn = k(() => {
1179
- let e = 0;
1180
- for (let t of wn) {
1181
- if (typeof t != "number") return;
1182
- e += t;
2468
+ if (U.current = $, wi?.status === "cancelled") {
2469
+ let e = H.current;
2470
+ e?.revision === wi.revision && e.status === "cancelled" && (H.current = null);
2471
+ return;
1183
2472
  }
1184
- return e;
1185
- }, [wn]), En = k(() => {
1186
- if (typeof Tn == "number") return Math.max(Ft, Tn);
1187
- }, [Tn, Ft]), Dn = typeof Tn == "number" && Ft > 0 && Tn > Ft + 1, On = x ? x && (Yt === void 0 || vn < Yt) : h, kn = se || Gt === "initial" || Gt === "refresh", An = pe || Gt === "scroll", jn = vn === 0, Mn = kn && jn, Nn = !kn && jn, Pn = (v || x) && An && On && !jn, Fn = Math.max(1, Math.floor(ze ?? Math.min(Math.max(1, Y.pagination.pageSize), 5))), In = (Mn ? Fn : +!!Nn) + +!!Pn, Ln = (bn.entries.length + In) * L, Rn = B ? 0 : Math.max(0, Nt - Ln), zn = Y.showHeader && (Ie || !jn || kn), Bn = (e, t) => (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === t, Vn = (e) => bn.entries[e], Hn = (e, t, n) => {
1188
- let r = (z ? e.rows.map((e, t) => t) : b(e)).flatMap((t, n) => {
2473
+ let e = L.current;
2474
+ if (!e || !Ei) return;
2475
+ let t = sn($), n = tn({
2476
+ anchor: Ei.anchor,
2477
+ getNextHeight: (e) => $.mixed ? $.heightIndex.getHeight(e) : $.rowHeight,
2478
+ nextKeys: t,
2479
+ previousKeys: Ei.previousKeys
2480
+ }), r = n ? ($.mixed ? $.heightIndex.getPrefixHeight(n.index) : n.index * $.rowHeight) + n.offsetWithinSlot : 0, i = nn(r, $.mixed ? $.heightIndex.getTotalHeight() : $.visibleRowCount * $.rowHeight, e.clientHeight || Ei.previousViewportHeight);
2481
+ if (wi) {
2482
+ let e = H.current;
2483
+ if (e?.revision !== wi.revision || e.status !== "pending") return;
2484
+ }
2485
+ if (jn.current !== null && (window.cancelAnimationFrame(jn.current), jn.current = null), e.scrollTop = i, wi) {
2486
+ let e = H.current;
2487
+ if (e?.revision !== wi.revision || e.status !== "pending") return;
2488
+ }
2489
+ let a = e.scrollTop, o = wi?.revision ?? vn.current + 1, s = $.mixed ? {
2490
+ actualPhysical: a,
2491
+ requestedPhysical: i,
2492
+ revision: o,
2493
+ targetLogical: r
2494
+ } : null;
2495
+ vn.current = Math.max(vn.current, o), wi && (H.current = null), xn.current = s, Dn.current = a, lr(s), _r(a);
2496
+ }, [$, Ei]);
2497
+ let Di = lt ?? q.theme, Oi = Di.density === "compact" ? "text-[11px]" : Di.density === "spacious" ? "text-[13px]" : "text-[length:var(--comins-font-size-base,12px)]", ki = D(() => new Set(q.selection.rowIds), [q.selection.rowIds]), Ai = typeof Ur == "number" && Yn > 0 && Ur > Yn + 1, ji = G || K ? !1 : te, Mi = ye, Ni = G || K ? !1 : Ce, Pi = mi === 0, Fi = Mi && Pi, Ii = !Mi && Pi, Li = !G && !K && (re || T) && Ni && ji && !Pi, Ri = Math.max(1, Math.floor(st ?? Math.min(Math.max(1, q.pagination.pageSize), 5))), zi = (Fi ? Ri : +!!Ii) + +!!Li, Bi = Si.slots.reduce((e, t) => e + Yt(t, M), 0) + zi * M, Vi = I ? 0 : Math.max(0, zn - Bi), Hi = q.showHeader && (Ze || !Pi || Mi), Ui = (e, t) => (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === t, Wi = (e) => {
2498
+ let t = Si.slots[e];
2499
+ return t?.kind === "data" ? t : void 0;
2500
+ }, Gi = (e, t, n) => {
2501
+ if (Q) {
2502
+ let e = Q.visibleLeafRowIds.indexOf(t), r = Q.visibleLeafRowIds.indexOf(n);
2503
+ if (e < 0 || r < 0) return [n];
2504
+ let i = Math.min(e, r), a = Math.max(e, r);
2505
+ return Q.visibleLeafRowIds.slice(i, a + 1);
2506
+ }
2507
+ let r = (F ? e.rows.map((e, t) => t) : b(e)).flatMap((t, n) => {
1189
2508
  let r = e.rows[t], i = e.rowIds[t];
1190
2509
  return r === void 0 || i === void 0 ? [] : [{
1191
2510
  dataIndex: t,
@@ -1197,53 +2516,94 @@ function Ft({ "buffer-size": e, cellSelection: n = !0, className: r, columnGroup
1197
2516
  if (i < 0 || a < 0) return [n];
1198
2517
  let o = Math.min(i, a), s = Math.max(i, a);
1199
2518
  return r.slice(o, s + 1).map((e) => e.rowId);
1200
- }, Un = (e, t) => {
1201
- Z((n) => de(n, Hn(n, e, t)));
1202
- }, Wn = (e) => {
1203
- Z((t) => de(t, e.flatMap((e) => {
1204
- let t = Vn(e);
1205
- return t ? [t.rowId] : [];
1206
- })));
1207
- }, $ = () => {
1208
- let e = J.current;
1209
- e && (e.cleanup(), e.timer !== null && window.clearTimeout(e.timer), J.current = null);
1210
- }, Gn = (e) => {
1211
- J.current?.columnId !== e && ($(), J.current = {
2519
+ }, Ki = (e, t) => {
2520
+ Y((n) => pe(n, Gi(n, e, t)));
2521
+ }, qi = (e) => {
2522
+ Y((t) => {
2523
+ let n = e.flatMap((e) => {
2524
+ if (Q) {
2525
+ let t = Q.visibleLeafRowIds[e];
2526
+ return t === void 0 ? [] : [t];
2527
+ }
2528
+ let t = Wi(e);
2529
+ return t ? [t.rowId] : [];
2530
+ });
2531
+ return pe(t, n);
2532
+ });
2533
+ }, Ji = () => {
2534
+ let e = W.current;
2535
+ e && (e.cleanup(), e.timer !== null && window.clearTimeout(e.timer), W.current = null);
2536
+ }, Yi = (e) => {
2537
+ W.current?.columnId !== e && (Ji(), W.current = {
1212
2538
  cleanup: () => void 0,
1213
2539
  columnId: e,
1214
2540
  timer: null
1215
2541
  });
1216
- }, Kn = () => {
1217
- let e = J.current;
2542
+ }, Xi = () => {
2543
+ let e = W.current;
1218
2544
  e && (e.cleanup(), e.cleanup = () => void 0, e.timer = window.setTimeout(() => {
1219
- J.current === e && (J.current = null);
2545
+ W.current === e && (W.current = null);
1220
2546
  }, 0));
1221
- }, qn = () => {
1222
- let e = J.current;
2547
+ }, Zi = () => {
2548
+ let e = W.current;
1223
2549
  if (!e) return;
1224
- let t = () => Kn(), n = () => $(), r = () => $();
2550
+ let t = () => Xi(), n = () => Ji(), r = () => Ji();
1225
2551
  e.cleanup(), e.cleanup = () => {
1226
2552
  window.removeEventListener("pointerup", t), window.removeEventListener("pointercancel", n), window.removeEventListener("blur", r);
1227
2553
  }, window.addEventListener("pointerup", t, { once: !0 }), window.addEventListener("pointercancel", n, { once: !0 }), window.addEventListener("blur", r, { once: !0 });
1228
- }, Jn = (e) => J.current?.columnId === e ? ($(), !0) : !1, Yn = (e, t) => {
1229
- e.sort && Z((n) => ve(n, wt(n.sortModel, e.id, he && t)));
1230
- }, Xn = (e, t) => {
2554
+ }, Qi = (e) => W.current?.columnId === e && (Ji(), !0), $i = (e, t) => {
2555
+ e.sort && Y((n) => xe(n, Un(n.sortModel, e.id, we && t)));
2556
+ }, ea = (e, t) => {
1231
2557
  let n = document.elementFromPoint(e, t)?.closest("[data-comins-column-id], [data-comins-column-group-id]");
1232
2558
  if (!n) return null;
1233
- if (n.dataset.cominsColumnId) return n.dataset.cominsColumnId;
1234
- let r = n.dataset.cominsColumnGroupId;
1235
- return (r ? X.current.columnGroups.find((e) => e.id === r) : void 0)?.children.find((e) => Q.some((t) => t.id === e)) ?? null;
2559
+ let r = Number(n.dataset.cominsColumnDepth);
2560
+ if (r !== 0 && r !== 1) return null;
2561
+ if (n.dataset.cominsColumnId) return {
2562
+ depth: r,
2563
+ id: n.dataset.cominsColumnId,
2564
+ kind: "column",
2565
+ parentGroupId: n.dataset.cominsColumnParentGroupId
2566
+ };
2567
+ let i = n.dataset.cominsColumnGroupId;
2568
+ return i ? {
2569
+ depth: r,
2570
+ id: i,
2571
+ kind: "group"
2572
+ } : null;
2573
+ }, ta = (e) => {
2574
+ let t = e.kind === "column" ? e.id : J.current.columnGroups.find((t) => t.id === e.id)?.children.find((e) => X.some((t) => t.id === e));
2575
+ return t ? X.findIndex((e) => e.id === t) : -1;
1236
2576
  };
1237
- De(He, () => ({
1238
- clearSort: () => Z((e) => i(e)),
1239
- expand: (e) => z?.onExpand(e),
1240
- fold: (e) => z?.onFold(e),
1241
- getColumnLayout: () => fe(Y),
1242
- getSortModel: () => Y.sortModel,
1243
- getSortState: () => Y.sort,
1244
- setColumnLayout: (e) => Z((n) => t(n, e), { columnLayoutChanged: !0 }),
1245
- setMoveTargetRow: (e, t) => Z((n) => {
1246
- if (z) return n;
2577
+ Me(ut, () => ({
2578
+ clearSort: () => Y((e) => i(e)),
2579
+ expand: (e) => F?.onExpand(e),
2580
+ expandGroups: (e) => {
2581
+ let t = N?.onChangeExpandedGroupIds;
2582
+ if (!Z || typeof t != "function") return;
2583
+ let n = e === void 0 ? Z.groupIds : e.filter((e) => Z.groupsById.has(e));
2584
+ if (n.length === 0) return;
2585
+ let r = [...si], i = new Set(r);
2586
+ for (let e of n) i.has(e) || (i.add(e), r.push(e));
2587
+ r.length !== si.length && t(r);
2588
+ },
2589
+ fold: (e) => F?.onFold(e),
2590
+ foldGroups: (e) => {
2591
+ let t = N?.onChangeExpandedGroupIds;
2592
+ if (!Z || typeof t != "function") return;
2593
+ if (e === void 0) {
2594
+ si.length > 0 && t([]);
2595
+ return;
2596
+ }
2597
+ if (e.length === 0) return;
2598
+ let n = new Set(e.filter((e) => Z.groupsById.has(e))), r = si.filter((e) => !n.has(e));
2599
+ r.length !== si.length && t(r);
2600
+ },
2601
+ getColumnLayout: () => me(q),
2602
+ getSortModel: () => q.sortModel,
2603
+ getSortState: () => q.sort,
2604
+ setColumnLayout: (e) => Y((n) => t(n, e), { columnLayoutChanged: !0 }),
2605
+ setMoveTargetRow: (e, t) => Y((n) => {
2606
+ if (F || G || K) return n;
1247
2607
  let r = b(n).flatMap((e) => {
1248
2608
  let t = n.rowIds[e];
1249
2609
  return t === void 0 ? [] : [t];
@@ -1263,65 +2623,111 @@ function Ft({ "buffer-size": e, cellSelection: n = !0, className: r, columnGroup
1263
2623
  sortModel: []
1264
2624
  } : n;
1265
2625
  }),
1266
- setSelectedRow: (e) => Wn([e]),
1267
- setSelectedRows: (e) => Wn(e),
1268
- setSortModel: (e) => Z((t) => ve(t, e)),
1269
- setSortState: (e) => Z((t) => ye(t, e))
2626
+ setSelectedRow: (e) => qi([e]),
2627
+ setSelectedRows: (e) => qi(e),
2628
+ setSortModel: (e) => Y((t) => xe(t, e)),
2629
+ setSortState: (e) => Y((t) => Se(t, e))
1270
2630
  }), [
1271
- bn.entries,
1272
- Y,
1273
- z
2631
+ Q,
2632
+ G,
2633
+ K,
2634
+ si,
2635
+ Z,
2636
+ N,
2637
+ Si.slots,
2638
+ q,
2639
+ F
1274
2640
  ]);
1275
- let Zn = () => {
1276
- let e = W.current;
1277
- e && (e.cleanup(), e.timer !== null && window.clearTimeout(e.timer)), W.current = null, Rt(null), Bt(null), Ht(null), Wt(null);
2641
+ let na = () => {
2642
+ let e = Ct.current;
2643
+ e && (e.cleanup(), e.timer !== null && window.clearTimeout(e.timer)), Ct.current = null, tr(null), rr(null), ar(null), sr(null);
1278
2644
  };
1279
- O(() => () => {
1280
- Zn(), $();
2645
+ E(() => () => {
2646
+ na(), Ji(), Tt.current?.();
1281
2647
  }, []);
1282
- let Qn = (e) => {
2648
+ let ra = () => {
2649
+ if (Tt.current?.(), Tt.current = null, Ot.current = null, typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
2650
+ let e = [
2651
+ z.current,
2652
+ L.current,
2653
+ R.current
2654
+ ].flatMap((e) => e ? Array.from(e.querySelectorAll("[data-comins-column-id], [data-comins-cell-column-id], [data-comins-summary-column-id]")) : []), t = /* @__PURE__ */ new Map();
2655
+ for (let n of e) t.set(n, n.getBoundingClientRect().left);
2656
+ Ot.current = t;
2657
+ };
2658
+ Ne(() => {
2659
+ let e = Ot.current;
2660
+ if (Ot.current = null, !e) return;
2661
+ let t = [];
2662
+ for (let [n, r] of e) {
2663
+ if (!n.isConnected) continue;
2664
+ let e = r - n.getBoundingClientRect().left;
2665
+ Math.abs(e) < .5 || (n.dataset.columnMoveAnimating = "prepare", n.style.setProperty("--comins-column-move-offset", `${e}px`), t.push(n));
2666
+ }
2667
+ if (t.length === 0) return;
2668
+ t[0]?.getBoundingClientRect();
2669
+ let n = 0, r = 0, i = () => {
2670
+ window.cancelAnimationFrame(n), window.clearTimeout(r);
2671
+ for (let e of t) delete e.dataset.columnMoveAnimating, e.style.removeProperty("--comins-column-move-offset");
2672
+ Tt.current === i && (Tt.current = null);
2673
+ };
2674
+ return Tt.current = i, n = window.requestAnimationFrame(() => {
2675
+ for (let e of t) e.dataset.columnMoveAnimating = "true", e.style.setProperty("--comins-column-move-offset", "0px");
2676
+ }), r = window.setTimeout(i, 220), i;
2677
+ }, [q.columnOrder]);
2678
+ let ia = (e) => {
1283
2679
  if (e.event.button !== 0) return;
1284
2680
  let t = e.event.pointerType, n = t === "mouse" || t === "", r = () => {
1285
- e.sortColumnId && Gn(e.sortColumnId);
2681
+ e.sortColumnId && Yi(e.sortColumnId);
1286
2682
  }, i = (t, n) => {
1287
- let i = W.current;
1288
- !i || i !== u || i.active || i.blocked || (i.active = !0, i.cancelSort = !0, r(), e.activate(t, n));
1289
- }, a = (e) => {
1290
- let t = W.current;
1291
- if (!(!t || t !== u)) {
1292
- if (!t.active && !t.blocked && n) {
1293
- let n = ke({
1294
- clientX: e.clientX,
1295
- clientY: e.clientY,
1296
- startX: t.startX,
1297
- startY: t.startY
2683
+ let i = Ct.current;
2684
+ !i || i !== u || i.active || i.blocked || (i.active = !0, i.cancelSort = !0, r(), e.activate(t, n), sr({
2685
+ ...e.source,
2686
+ status: "neutral"
2687
+ }));
2688
+ }, a = (t) => {
2689
+ let a = Ct.current;
2690
+ if (!(!a || a !== u)) {
2691
+ if (!a.active && !a.blocked && n) {
2692
+ let e = Ve({
2693
+ clientX: t.clientX,
2694
+ clientY: t.clientY,
2695
+ startX: a.startX,
2696
+ startY: a.startY
2697
+ });
2698
+ e === "activate" ? i(t.clientX, t.clientY) : e === "cancel" && (a.blocked = !0, a.cancelSort = !0, r());
2699
+ }
2700
+ if (!a.active && !a.blocked && !n && Math.hypot(t.clientX - a.startX, t.clientY - a.startY) > 4 && (a.blocked = !0, a.cancelSort = !0, window.clearTimeout(a.timer ?? void 0), r()), a.active) {
2701
+ t.preventDefault(), ar({
2702
+ x: t.clientX,
2703
+ y: t.clientY
1298
2704
  });
1299
- n === "activate" ? i(e.clientX, e.clientY) : n === "cancel" && (t.blocked = !0, t.cancelSort = !0, r());
2705
+ let n = ea(t.clientX, t.clientY);
2706
+ sr(n ? {
2707
+ ...n,
2708
+ status: e.resolveTarget(n)
2709
+ } : null);
1300
2710
  }
1301
- !t.active && !t.blocked && !n && Math.hypot(e.clientX - t.startX, e.clientY - t.startY) > 4 && (t.blocked = !0, t.cancelSort = !0, window.clearTimeout(t.timer ?? void 0), r()), t.active && (e.preventDefault(), Ht({
1302
- x: e.clientX,
1303
- y: e.clientY
1304
- }), Wt(Xn(e.clientX, e.clientY)));
1305
2711
  }
1306
2712
  }, o = (t) => {
1307
- let n = W.current;
2713
+ let n = Ct.current;
1308
2714
  if (n === u && n.active) {
1309
- let n = Xn(t.clientX, t.clientY);
1310
- n && e.commitTarget(n);
2715
+ let n = ea(t.clientX, t.clientY);
2716
+ n && e.resolveTarget(n) === "valid" && e.commitTarget(n);
1311
2717
  }
1312
- n === u && n.cancelSort && Kn(), Zn();
2718
+ n === u && n.cancelSort && Xi(), na();
1313
2719
  }, s = () => {
1314
- $(), Zn();
2720
+ Ji(), na();
1315
2721
  }, c = (e) => {
1316
- e.key === "Escape" && (e.preventDefault(), W.current === u && u.cancelSort && qn(), Zn());
2722
+ e.key === "Escape" && (e.preventDefault(), Ct.current === u && u.cancelSort && Zi(), na());
1317
2723
  }, l = () => {
1318
- $(), Zn();
2724
+ Ji(), na();
1319
2725
  }, u = {
1320
2726
  active: !1,
1321
2727
  blocked: !1,
1322
2728
  cancelSort: !1,
1323
2729
  cleanup: () => {
1324
- window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", s), window.removeEventListener("keydown", c), window.removeEventListener("blur", l);
2730
+ window.removeEventListener("pointermove", a, !0), window.removeEventListener("pointerup", o, !0), window.removeEventListener("pointercancel", s, !0), window.removeEventListener("keydown", c), window.removeEventListener("blur", l);
1325
2731
  },
1326
2732
  id: e.id,
1327
2733
  kind: e.kind,
@@ -1330,662 +2736,990 @@ function Ft({ "buffer-size": e, cellSelection: n = !0, className: r, columnGroup
1330
2736
  startY: e.event.clientY,
1331
2737
  timer: null
1332
2738
  };
1333
- Zn(), $(), n || (u.timer = window.setTimeout(() => {
1334
- let e = W.current;
2739
+ na(), Ji(), n || (u.timer = window.setTimeout(() => {
2740
+ let e = Ct.current;
1335
2741
  e === u && !e.active && !e.blocked && i(e.startX, e.startY);
1336
- }, 1e3)), W.current = u, window.addEventListener("pointermove", a), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", s), window.addEventListener("keydown", c), window.addEventListener("blur", l);
1337
- }, $n = (e, t) => {
1338
- Qn({
1339
- activate: (e, n) => {
1340
- Ht({
2742
+ }, 1e3)), Ct.current = u, window.addEventListener("pointermove", a, !0), window.addEventListener("pointerup", o, !0), window.addEventListener("pointercancel", s, !0), window.addEventListener("keydown", c), window.addEventListener("blur", l), e.activateImmediately && i(u.startX, u.startY);
2743
+ }, aa = (e, t, n = !1) => {
2744
+ let r = t.column;
2745
+ if (r.lockPosition) return;
2746
+ let i = {
2747
+ depth: +!!t.groupId,
2748
+ id: r.id,
2749
+ kind: "column",
2750
+ parentGroupId: t.groupId
2751
+ };
2752
+ ia({
2753
+ activateImmediately: n,
2754
+ activate: (e, t) => {
2755
+ ar({
1341
2756
  x: e,
1342
- y: n
1343
- }), Wt(t.id), Bt(null), Rt(t.id);
2757
+ y: t
2758
+ }), rr(null), tr(r.id);
1344
2759
  },
1345
2760
  commitTarget: (e) => {
1346
- if (e === t.id) return;
1347
- let n = Q.findIndex((t) => t.id === e);
1348
- if (n >= 0) {
1349
- let e = X.current, r = ne(e, t.id, n);
1350
- r !== e && r.columnOrder.some((t, n) => t !== e.columnOrder[n]) && Z(r, { columnLayoutChanged: !0 });
2761
+ let t = ta(e);
2762
+ if (t >= 0) {
2763
+ let e = J.current, n = ie(e, r.id, t);
2764
+ n !== e && n.columnOrder.some((t, n) => t !== e.columnOrder[n]) && (ra(), Y(n, { columnLayoutChanged: !0 }));
1351
2765
  }
1352
2766
  },
1353
2767
  event: e,
1354
- id: t.id,
2768
+ id: r.id,
1355
2769
  kind: "column",
1356
- sortColumnId: t.id
2770
+ resolveTarget: (e) => {
2771
+ let t = ta(e);
2772
+ if (t < 0) return "invalid";
2773
+ let n = J.current, a = ie(n, r.id, t);
2774
+ return an(i, e, a.columnOrder.some((e, t) => e !== n.columnOrder[t]));
2775
+ },
2776
+ sortColumnId: r.id,
2777
+ source: i
1357
2778
  });
1358
- }, er = (e, t) => {
1359
- Qn({
2779
+ }, oa = (e, t, n = !1) => {
2780
+ if (t.lockPosition) return;
2781
+ let r = {
2782
+ depth: 0,
2783
+ id: t.id,
2784
+ kind: "group"
2785
+ };
2786
+ ia({
2787
+ activateImmediately: n,
1360
2788
  activate: (e, n) => {
1361
- Ht({
2789
+ ar({
1362
2790
  x: e,
1363
2791
  y: n
1364
- }), Wt(t.children[0] ?? null), Rt(null), Bt(t.id);
2792
+ }), tr(null), rr(t.id);
1365
2793
  },
1366
2794
  commitTarget: (e) => {
1367
- if (t.children.includes(e)) return;
1368
- let n = Q.findIndex((t) => t.id === e);
2795
+ let n = ta(e);
1369
2796
  if (n >= 0) {
1370
- let e = X.current, r = re(e, t.id, n);
1371
- r !== e && r.columnOrder.some((t, n) => t !== e.columnOrder[n]) && Z(r, { columnLayoutChanged: !0 });
2797
+ let e = J.current, r = C(e, t.id, n);
2798
+ r !== e && r.columnOrder.some((t, n) => t !== e.columnOrder[n]) && (ra(), Y(r, { columnLayoutChanged: !0 }));
1372
2799
  }
1373
2800
  },
1374
2801
  event: e,
1375
2802
  id: t.id,
1376
- kind: "group"
2803
+ kind: "group",
2804
+ resolveTarget: (e) => {
2805
+ let n = ta(e);
2806
+ if (n < 0) return "invalid";
2807
+ let i = J.current, a = C(i, t.id, n);
2808
+ return an(r, e, a.columnOrder.some((e, t) => e !== i.columnOrder[t]));
2809
+ },
2810
+ source: r
1377
2811
  });
1378
- }, tr = (e, t) => {
1379
- if (e.shiftKey && K.current !== null) {
1380
- Un(K.current, t.rowId), K.current = t.rowId;
2812
+ }, sa = (e, t) => {
2813
+ if (e.shiftKey && V.current !== null) {
2814
+ Ki(V.current, t.rowId), V.current = t.rowId;
1381
2815
  return;
1382
2816
  }
1383
- Z((n) => E(n, t.rowId, {
2817
+ Y((n) => fe(n, t.rowId, {
1384
2818
  multi: e.ctrlKey || e.metaKey,
1385
2819
  toggle: e.ctrlKey || e.metaKey
1386
- })), K.current = t.rowId;
1387
- }, nr = (e, t, n) => {
2820
+ })), V.current = t.rowId;
2821
+ }, ca = (e, t, n) => {
1388
2822
  if (n) {
1389
2823
  e.preventDefault();
1390
2824
  return;
1391
2825
  }
1392
- if (Ne?.(nt(e, t)), !(e.defaultPrevented || e.target !== e.currentTarget)) {
1393
- if (z && (Bn(e, "c") || Bn(e, "v"))) {
2826
+ if (Ke?.(gn(e, t)), !(e.defaultPrevented || e.target !== e.currentTarget)) {
2827
+ if (F && (Ui(e, "c") || Ui(e, "v"))) {
1394
2828
  e.preventDefault();
1395
2829
  return;
1396
2830
  }
1397
- if (Bn(e, "c")) {
1398
- e.preventDefault(), qe.current = s(Y, t.rowId);
2831
+ if (Ui(e, "c")) {
2832
+ e.preventDefault(), pt.current = s(q, t.rowId);
1399
2833
  return;
1400
2834
  }
1401
- Bn(e, "v") && qe.current && (e.preventDefault(), Z((e) => oe(e, qe.current, {
2835
+ Ui(e, "v") && pt.current && (e.preventDefault(), Y((e) => ce(e, pt.current, {
1402
2836
  mode: "insert-after",
1403
2837
  targetRowId: t.rowId
1404
2838
  })));
1405
2839
  }
1406
- }, rr = (e, t, n, r, i, s) => {
2840
+ }, la = (e, t, n, r, i, s) => {
1407
2841
  if (s) {
1408
2842
  e.preventDefault(), e.stopPropagation();
1409
2843
  return;
1410
2844
  }
1411
- if (Me?.(rt(e, t, n, r, g(Y, t.row, n.id))), !e.defaultPrevented) {
1412
- if (Bn(e, "c")) {
1413
- e.preventDefault(), e.stopPropagation(), H.current = Y.selection.range ? o(Y) : null, Ke.current = H.current ? null : a(Y, i);
2845
+ if (Ge?.(_n(e, t, n, r, g(q, t.row, n.id))), !e.defaultPrevented) {
2846
+ if (Ui(e, "c")) {
2847
+ e.preventDefault(), e.stopPropagation(), ft.current = q.selection.range ? o(q, q.selection.range, Q?.visibleLeafRowIds ?? q.rowIds) : null, dt.current = ft.current ? null : a(q, i);
1414
2848
  return;
1415
2849
  }
1416
- Bn(e, "v") && (H.current || Ke.current) && (e.preventDefault(), e.stopPropagation(), Z((e) => H.current ? T(e, i, H.current) : ae(e, i, Ke.current)));
2850
+ Ui(e, "v") && (ft.current || dt.current) && (e.preventDefault(), e.stopPropagation(), Y((e) => ft.current ? se(e, i, ft.current, Q?.visibleLeafRowIds ?? e.rowIds) : w(e, i, dt.current)));
1417
2851
  }
1418
- }, ir = (e, t, r) => {
1419
- n && (r || e.button !== 0 || e.shiftKey || (vt.current = t, yt.current = t, q.current = !1));
1420
- }, ar = (e, t) => {
1421
- let n = document.elementFromPoint(e, t)?.closest("[data-comins-cell-column-id][data-comins-data-index]"), r = n?.dataset.cominsCellColumnId, i = n?.dataset.cominsDataIndex === void 0 ? NaN : Number(n.dataset.cominsDataIndex), a = Number.isInteger(i) ? Y.rowIds[i] : void 0;
2852
+ }, ua = (e, t, r) => {
2853
+ n && (r || e.button !== 0 || e.shiftKey || (Bt.current = t, Vt.current = t, Ht.current = !1));
2854
+ }, da = (e, t) => {
2855
+ let n = document.elementFromPoint(e, t)?.closest("[data-comins-cell-column-id][data-comins-data-index]"), r = n?.dataset.cominsCellColumnId, i = n?.dataset.cominsDataIndex === void 0 ? NaN : Number(n.dataset.cominsDataIndex), a = Number.isInteger(i) ? q.rowIds[i] : void 0;
1422
2856
  return r && a !== void 0 ? {
1423
2857
  columnId: r,
1424
2858
  rowId: a
1425
2859
  } : null;
1426
- }, or = (e) => {
2860
+ }, fa = (e) => {
1427
2861
  if (!n) return;
1428
- let t = vt.current;
1429
- !t || t.rowId === e.rowId && t.columnId === e.columnId || (q.current = !0, yt.current = e, Je.current = t, Z((n) => ue(n, {
2862
+ let t = Bt.current;
2863
+ !t || t.rowId === e.rowId && t.columnId === e.columnId || (Ht.current = !0, Vt.current = e, Nt.current = t, Y((n) => de(n, {
1430
2864
  anchor: t,
1431
2865
  focus: e
1432
2866
  })));
1433
- }, sr = () => {
1434
- n && (vt.current = null, yt.current = null);
1435
- }, cr = (e, t, n) => {
1436
- if (ir(e, t, n), n || e.button !== 0 || e.shiftKey) return;
2867
+ }, pa = () => {
2868
+ n && (Bt.current = null, Vt.current = null);
2869
+ }, ma = (e, t, n) => {
2870
+ if (ua(e, t, n), n || e.button !== 0 || e.shiftKey) return;
1437
2871
  let r = (e) => {
1438
2872
  if (e.buttons !== 1) return;
1439
- let t = ar(e.clientX, e.clientY);
1440
- t && or(t);
2873
+ let t = da(e.clientX, e.clientY);
2874
+ t && fa(t);
1441
2875
  }, i = () => {
1442
- window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", a), window.removeEventListener("pointercancel", o), window.removeEventListener("blur", o), U.current === i && (U.current = null);
2876
+ window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", a), window.removeEventListener("pointercancel", o), window.removeEventListener("blur", o), B.current === i && (B.current = null);
1443
2877
  }, a = () => {
1444
- i(), sr();
2878
+ i(), pa();
1445
2879
  }, o = () => {
1446
- i(), sr();
2880
+ i(), pa();
1447
2881
  };
1448
- e.preventDefault(), dn(i), window.addEventListener("pointermove", r), window.addEventListener("pointerup", a), window.addEventListener("pointercancel", o), window.addEventListener("blur", o);
1449
- }, lr = (e, t, n, r) => {
2882
+ e.preventDefault(), Nr(i), window.addEventListener("pointermove", r), window.addEventListener("pointerup", a), window.addEventListener("pointercancel", o), window.addEventListener("blur", o);
2883
+ }, ha = (e, t, n, r) => {
1450
2884
  if (n || !r || e.button !== 0) return;
1451
2885
  e.preventDefault(), e.stopPropagation();
1452
2886
  let i = t.rowId, a = (e) => {
1453
- bt.current = e, en(e);
1454
- }, o = (e, t) => {
1455
- let n = document.elementFromPoint(e, t)?.closest("[data-comins-row-data-index]");
1456
- if (!n || n.dataset.cominsRowDataIndex === void 0) return;
1457
- let r = Number(n.dataset.cominsRowDataIndex);
1458
- Number.isInteger(r) && a({
1459
- sourceRowId: i,
1460
- targetDataIndex: r
1461
- });
2887
+ Ut.current = e, pr(e);
2888
+ }, o = (e, n) => {
2889
+ let r = document.elementFromPoint(e, n)?.closest("[data-comins-row-data-index], [data-comins-group-index]");
2890
+ if (!r) return;
2891
+ if (r.dataset.cominsRowDataIndex !== void 0) {
2892
+ let e = Number(r.dataset.cominsRowDataIndex);
2893
+ if (!Number.isInteger(e)) return;
2894
+ let n = J.current.rows[e], o = ui && N && n !== void 0 ? N.getRowGroupId(n, e) : void 0, s = ui && N ? N.getRowGroupId(t.row, t.dataIndex) : void 0, c = o === void 0 || s === o || typeof N?.setRowGroupId == "function" && typeof ke == "function";
2895
+ a({
2896
+ sourceRowId: i,
2897
+ targetDataIndex: e,
2898
+ targetGroupId: o,
2899
+ valid: c
2900
+ });
2901
+ return;
2902
+ }
2903
+ let o = Number(r.dataset.cominsGroupIndex), s = Number.isInteger(o) ? Z?.groupIds[o] : void 0;
2904
+ if (s !== void 0 && ui && N) {
2905
+ let e = N.getRowGroupId(t.row, t.dataIndex) === s || typeof N.setRowGroupId == "function" && typeof ke == "function";
2906
+ a({
2907
+ sourceRowId: i,
2908
+ targetGroupId: s,
2909
+ valid: e
2910
+ });
2911
+ }
1462
2912
  }, s = (e) => {
1463
2913
  e.buttons === 1 && o(e.clientX, e.clientY);
1464
2914
  }, c = () => {
1465
- window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", u), window.removeEventListener("blur", u), U.current === c && (U.current = null);
2915
+ window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", u), window.removeEventListener("blur", u), B.current === c && (B.current = null);
1466
2916
  }, l = (e) => {
1467
2917
  c(), o(e.clientX, e.clientY);
1468
- let t = bt.current?.targetDataIndex;
1469
- a(null), t !== void 0 && Z((e) => ie(e, i, t));
2918
+ let n = Ut.current;
2919
+ if (a(null), n?.valid) {
2920
+ if (ui && N && n.targetGroupId !== void 0) {
2921
+ N.getRowGroupId(t.row, t.dataIndex) !== n.targetGroupId && !ci.has(n.targetGroupId) && (rn.current = n.targetGroupId), Y((e) => oe(e, {
2922
+ getRowGroupId: N.getRowGroupId,
2923
+ setRowGroupId: N.setRowGroupId,
2924
+ sourceRowId: i,
2925
+ targetGroupId: n.targetGroupId,
2926
+ targetRowId: n.targetDataIndex === void 0 ? void 0 : e.rowIds[n.targetDataIndex]
2927
+ }));
2928
+ return;
2929
+ }
2930
+ n.targetDataIndex !== void 0 && Y((e) => ae(e, i, n.targetDataIndex));
2931
+ }
1470
2932
  }, u = () => {
1471
2933
  c(), a(null);
1472
2934
  };
1473
- o(e.clientX, e.clientY), dn(c), window.addEventListener("pointermove", s), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", u), window.addEventListener("blur", u);
1474
- }, ur = Lt ? Q.find((e) => e.id === Lt) : void 0, dr = zt ? Y.columnGroups.find((e) => e.id === zt) : void 0, fr = ur?.label ?? dr?.label, pr = (e, t) => {
1475
- if (e.kind === "group") return /* @__PURE__ */ N("th", {
1476
- className: ["comins-table__th comins-table__group-th px-3 py-2 text-left font-semibold", zt === e.groupId ? "comins-column-moving" : void 0].filter(Boolean).join(" "),
1477
- colSpan: e.colSpan,
1478
- "data-column-moving": zt === e.groupId ? "true" : void 0,
1479
- "data-column-placeholder": zt === e.groupId ? "true" : void 0,
1480
- "data-comins-column-group-id": e.groupId,
1481
- "data-testid": `header-group-${e.groupId}`,
1482
- onPointerDown: (t) => er(t, e.group),
1483
- rowSpan: e.rowSpan,
1484
- scope: "colgroup",
1485
- children: [
1486
- /* @__PURE__ */ M("span", {
1487
- "aria-hidden": "true",
1488
- className: "comins-column-drop-marker"
1489
- }),
1490
- /* @__PURE__ */ M("span", {
1491
- className: "comins-table__header-content",
1492
- "data-comins-header-body": "true",
1493
- children: /* @__PURE__ */ M("span", {
1494
- className: "comins-table__header-label",
1495
- children: e.group.label
2935
+ o(e.clientX, e.clientY), Nr(c), window.addEventListener("pointermove", s), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", u), window.addEventListener("blur", u);
2936
+ }, ga = (e, t) => {
2937
+ let n = N?.onChangeGroups;
2938
+ if (e.button !== 0 || !N?.groupDraggable || typeof n != "function" || !Z?.groupsById.has(t)) return;
2939
+ e.preventDefault(), e.stopPropagation();
2940
+ let r = (e) => {
2941
+ Xt.current = e, hr(e);
2942
+ }, i = (e, n) => {
2943
+ let i = document.elementFromPoint(e, n)?.closest("[data-comins-group-index]"), a = Number(i?.dataset.cominsGroupIndex), o = Number.isInteger(a) ? Z.groupIds[a] : void 0;
2944
+ if (!i || o === void 0) return;
2945
+ let s = i.getBoundingClientRect(), c = n >= s.top + s.height / 2 ? "after" : "before";
2946
+ r({
2947
+ position: c,
2948
+ sourceGroupId: t,
2949
+ targetGroupId: o
2950
+ });
2951
+ }, a = (e) => {
2952
+ e.buttons === 1 && i(e.clientX, e.clientY);
2953
+ }, o = () => {
2954
+ window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", c), window.removeEventListener("blur", c), B.current === o && (B.current = null);
2955
+ }, s = (e) => {
2956
+ o(), i(e.clientX, e.clientY);
2957
+ let t = Xt.current;
2958
+ if (r(null), !t || t.sourceGroupId === t.targetGroupId) return;
2959
+ let a = N.groups, s = a.findIndex((e) => N.getGroupId(e) === t.sourceGroupId), c = jt({
2960
+ getGroupId: N.getGroupId,
2961
+ groups: a,
2962
+ position: t.position,
2963
+ sourceGroupId: t.sourceGroupId,
2964
+ targetGroupId: t.targetGroupId
2965
+ }), l = c.findIndex((e) => N.getGroupId(e) === t.sourceGroupId);
2966
+ s >= 0 && l >= 0 && a.some((e, t) => e !== c[t]) && n(c, {
2967
+ fromIndex: s,
2968
+ groupId: t.sourceGroupId,
2969
+ reason: "move",
2970
+ targetGroupId: t.targetGroupId,
2971
+ toIndex: l
2972
+ });
2973
+ }, c = () => {
2974
+ o(), r(null);
2975
+ };
2976
+ r({
2977
+ position: "before",
2978
+ sourceGroupId: t,
2979
+ targetGroupId: t
2980
+ }), Nr(o), window.addEventListener("pointermove", a), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), window.addEventListener("blur", c);
2981
+ }, _a = er ? X.find((e) => e.id === er) : void 0, va = nr ? q.columnGroups.find((e) => e.id === nr) : void 0, ya = _a ? Pn(_a.label, _a.id) : va ? Pn(va.label, va.id) : void 0, ba = (e, t) => {
2982
+ let n = l, r = n?.onChangeModel;
2983
+ if (!n || typeof r != "function") return;
2984
+ let i = Array.isArray(n.model) ? n.model : [], a = i.findIndex((t) => t?.columnId === e), o = i.filter((t) => t?.columnId !== e);
2985
+ t && o.splice(a < 0 ? o.length : a, 0, t), r(o);
2986
+ }, xa = (e, t) => {
2987
+ if (e.kind === "group") {
2988
+ let t = or?.kind === "group" && or.id === e.groupId, n = nr === e.groupId, r = e.group.lockPosition === !0, i = Pn(e.group.label, e.groupId);
2989
+ return /* @__PURE__ */ j("th", {
2990
+ "aria-label": n ? i : void 0,
2991
+ className: ["comins-table__th comins-table__group-th px-3 py-2 text-left font-semibold", n ? "comins-column-moving" : void 0].filter(Boolean).join(" "),
2992
+ colSpan: e.colSpan,
2993
+ "data-column-drop-target": t ? "true" : void 0,
2994
+ "data-column-drop-valid": t && or.status !== "neutral" ? or.status === "valid" ? "true" : "false" : void 0,
2995
+ "data-column-moving": n ? "true" : void 0,
2996
+ "data-column-placeholder": n ? "true" : void 0,
2997
+ "data-column-position-locked": r ? "true" : void 0,
2998
+ "data-comins-column-depth": "0",
2999
+ "data-comins-column-group-id": e.groupId,
3000
+ "data-testid": `header-group-${e.groupId}`,
3001
+ onPointerDown: (t) => oa(t, e.group),
3002
+ rowSpan: e.rowSpan,
3003
+ scope: "colgroup",
3004
+ children: [
3005
+ /* @__PURE__ */ A("span", {
3006
+ "aria-hidden": "true",
3007
+ className: "comins-column-drop-marker"
3008
+ }),
3009
+ /* @__PURE__ */ j("span", {
3010
+ ...n ? Nn : {},
3011
+ "aria-hidden": n ? "true" : void 0,
3012
+ className: "comins-table__header-content",
3013
+ "data-comins-header-body": "true",
3014
+ inert: n ? !0 : void 0,
3015
+ ref: Mn,
3016
+ children: [it && !r ? /* @__PURE__ */ A("span", {
3017
+ "aria-hidden": "true",
3018
+ className: "comins-column-move-handle",
3019
+ "data-comins-column-move-handle": "true",
3020
+ "data-testid": `column-group-move-handle-${e.groupId}`,
3021
+ draggable: !1,
3022
+ onClick: (e) => e.stopPropagation(),
3023
+ onPointerDown: (t) => {
3024
+ t.preventDefault(), t.stopPropagation(), oa(t, e.group, !0);
3025
+ },
3026
+ children: /* @__PURE__ */ A($e, { name: "columnMove" })
3027
+ }) : null, /* @__PURE__ */ A("span", {
3028
+ className: "comins-table__header-label",
3029
+ children: n ? null : e.group.label
3030
+ })]
3031
+ }),
3032
+ n ? /* @__PURE__ */ A("span", {
3033
+ "aria-hidden": "true",
3034
+ className: "comins-column-placeholder-label",
3035
+ children: i
3036
+ }) : null,
3037
+ /* @__PURE__ */ A("span", {
3038
+ "aria-hidden": "true",
3039
+ className: "comins-table__resize",
3040
+ "data-resizing": ur === e.groupId ? "true" : void 0,
3041
+ "data-testid": `resize-group-${e.groupId}`,
3042
+ onClick: (e) => e.stopPropagation(),
3043
+ onPointerDown: (t) => {
3044
+ t.preventDefault(), t.stopPropagation();
3045
+ let n = t.clientX, r = t.currentTarget.closest("th")?.getBoundingClientRect().width, i = /* @__PURE__ */ new Map();
3046
+ for (let t of e.group.children) {
3047
+ let e = X.find((e) => e.id === t);
3048
+ if (!e) continue;
3049
+ let n = Array.from(z.current?.querySelectorAll("[data-comins-column-id]") ?? []).find((t) => t.dataset.cominsColumnId === e.id)?.getBoundingClientRect().width, r = J.current.columnState[e.id]?.width ?? e.width ?? 160;
3050
+ i.set(e.id, n && Number.isFinite(n) ? n : r);
3051
+ }
3052
+ let a = [...i.values()].reduce((e, t) => e + t, 0), o = r && Number.isFinite(r) ? r : Math.max(1, a);
3053
+ dr(e.groupId);
3054
+ let s = (t) => {
3055
+ Y((r) => {
3056
+ let a = r;
3057
+ for (let [e, t] of i) a = ve(a, e, t);
3058
+ return ge(a, e.groupId, o + t.clientX - n);
3059
+ }, { columnLayoutChanged: !0 });
3060
+ }, c = () => {
3061
+ window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", u), window.removeEventListener("blur", u), B.current === c && (B.current = null);
3062
+ }, l = () => {
3063
+ c(), dr(null);
3064
+ }, u = () => {
3065
+ c(), dr(null);
3066
+ };
3067
+ Nr(c), window.addEventListener("pointermove", s), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", u), window.addEventListener("blur", u);
3068
+ },
3069
+ children: /* @__PURE__ */ A("span", { className: "comins-table__resize-line" })
1496
3070
  })
1497
- }),
1498
- /* @__PURE__ */ M("span", {
1499
- "aria-hidden": "true",
1500
- className: "comins-table__resize",
1501
- "data-resizing": Zt === e.groupId ? "true" : void 0,
1502
- "data-testid": `resize-group-${e.groupId}`,
1503
- onClick: (e) => e.stopPropagation(),
1504
- onPointerDown: (t) => {
1505
- t.preventDefault(), t.stopPropagation();
1506
- let n = t.clientX, r = t.currentTarget.closest("th")?.getBoundingClientRect().width, i = /* @__PURE__ */ new Map();
1507
- for (let t of e.group.children) {
1508
- let e = Q.find((e) => e.id === t);
1509
- if (!e) continue;
1510
- let n = Array.from(V.current?.querySelectorAll("[data-comins-column-id]") ?? []).find((t) => t.dataset.cominsColumnId === e.id)?.getBoundingClientRect().width, r = X.current.columnState[e.id]?.width ?? e.width ?? 160;
1511
- i.set(e.id, n && Number.isFinite(n) ? n : r);
1512
- }
1513
- let a = [...i.values()].reduce((e, t) => e + t, 0), o = r && Number.isFinite(r) ? r : Math.max(1, a);
1514
- Qt(e.groupId);
1515
- let s = (t) => {
1516
- Z((r) => {
1517
- let a = r;
1518
- for (let [e, t] of i) a = D(a, e, t);
1519
- return me(a, e.groupId, o + t.clientX - n);
1520
- }, { columnLayoutChanged: !0 });
1521
- }, c = () => {
1522
- window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", u), window.removeEventListener("blur", u), U.current === c && (U.current = null);
1523
- }, l = () => {
1524
- c(), Qt(null);
1525
- }, u = () => {
1526
- c(), Qt(null);
1527
- };
1528
- dn(c), window.addEventListener("pointermove", s), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", u), window.addEventListener("blur", u);
1529
- },
1530
- children: /* @__PURE__ */ M("span", { className: "comins-table__resize-line" })
1531
- })
1532
- ]
1533
- }, `group-${e.groupId}`);
1534
- let n = e.column, r = Q.findIndex((e) => e.id === n.id), i = r >= 0 ? r : t, a = Y.columnState[n.id], o = n.header?.props ?? {}, s = Tt(Y.sortModel, n.id), c = Et(Y.sortModel, n.id), l = c === "asc" || c === "desc", u = s !== null && Y.sortModel.length > 1, d = !!dr?.children.includes(n.id), f = Lt === n.id || d, p = [
3071
+ ]
3072
+ }, `group-${e.groupId}`);
3073
+ }
3074
+ let n = e.column, r = X.findIndex((e) => e.id === n.id), i = r >= 0 ? r : t, a = q.columnState[n.id], o = n.header?.props ?? {}, s = Wn(q.sortModel, n.id), c = Gn(q.sortModel, n.id), u = c === "asc" || c === "desc", d = s !== null && q.sortModel.length > 1, f = !!va?.children.includes(n.id), p = er === n.id || f, m = Pn(n.label, n.id), h = [
1535
3075
  "comins-table__th px-3 py-2 text-left font-semibold",
1536
- Lt === n.id ? "comins-column-moving" : void 0,
3076
+ er === n.id ? "comins-column-moving" : void 0,
1537
3077
  o.className
1538
- ].filter(Boolean).join(" "), m = ft(Y, n, i), h = n.header?.renderer ? n.header.renderer(m) : null, g = n.header?.renderer ? [] : ht(n.header?.components, m, "left"), _ = n.header?.renderer ? [] : ht(n.header?.components, m, "right"), v = g.length > 0 || _.length > 0;
1539
- return /* @__PURE__ */ we("th", {
3078
+ ].filter(Boolean).join(" "), g = En(q, n, i), _ = n.header?.renderer, v = _ ? Mt.current.get(n.id) : void 0, y = !!_ && (!p || v?.renderer !== _), b = _ ? y ? _(g) : v?.body : null;
3079
+ _ && y ? Vr.set(n.id, {
3080
+ body: b,
3081
+ renderer: _
3082
+ }) : _ && v && Vr.set(n.id, v);
3083
+ let x = n.header?.renderer ? [] : kn(n.header?.components, g, "left"), ee = n.header?.renderer ? [] : kn(n.header?.components, g, "right"), te = x.length > 0 || ee.length > 0, ne = or?.kind === "column" && or.id === n.id, re = n.lockPosition === !0, S = n.filter?.kind, ie = K && (S === "boolean" || S === "date" || S === "number" || S === "text");
3084
+ return /* @__PURE__ */ Oe("th", {
1540
3085
  ...o,
1541
- className: p,
3086
+ "aria-label": p ? m : o["aria-label"],
3087
+ "aria-labelledby": p ? void 0 : o["aria-labelledby"],
3088
+ className: h,
1542
3089
  colSpan: e.colSpan,
1543
- "data-column-drop-target": Ut === n.id ? "true" : void 0,
1544
- "data-column-moving": Lt === n.id ? "true" : void 0,
1545
- "data-column-placeholder": f ? "true" : void 0,
3090
+ "data-column-drop-target": ne ? "true" : void 0,
3091
+ "data-column-drop-valid": ne && or.status !== "neutral" ? or.status === "valid" ? "true" : "false" : void 0,
3092
+ "data-column-moving": er === n.id ? "true" : void 0,
3093
+ "data-column-placeholder": p ? "true" : void 0,
3094
+ "data-column-position-locked": re ? "true" : void 0,
3095
+ "data-comins-column-depth": e.groupId ? "1" : "0",
1546
3096
  "data-comins-column-id": n.id,
1547
3097
  "data-comins-column-index": i,
1548
- "data-sort-count": s ? Y.sortModel.length : void 0,
3098
+ "data-comins-column-parent-group-id": e.groupId,
3099
+ "data-sort-count": s ? q.sortModel.length : void 0,
1549
3100
  "data-sort-direction": s?.rule.direction,
1550
3101
  "data-sort-priority": s?.priority,
1551
3102
  "data-sortable": n.sort ? "true" : "false",
3103
+ "data-filter-active": Yr.has(n.id) ? "true" : void 0,
1552
3104
  "data-testid": `header-${n.id}`,
1553
- "aria-sort": n.sort ? Dt(Y.sortModel, n.id) : void 0,
3105
+ "aria-sort": n.sort ? Kn(q.sortModel, n.id) : void 0,
1554
3106
  key: `column-${n.id}`,
1555
3107
  onClick: (e) => {
1556
- o.onClick?.(e), !(e.defaultPrevented || !n.sort) && (Jn(n.id) || Yn(n, e.shiftKey));
3108
+ if (p) {
3109
+ e.preventDefault();
3110
+ return;
3111
+ }
3112
+ o.onClick?.(e), !(e.defaultPrevented || !n.sort) && (Qi(n.id) || $i(n, e.shiftKey));
1557
3113
  },
1558
3114
  onKeyDown: (e) => {
1559
- o.onKeyDown?.(e), !(e.defaultPrevented || !n.sort) && (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), Yn(n, e.shiftKey));
3115
+ if (p) {
3116
+ e.preventDefault();
3117
+ return;
3118
+ }
3119
+ o.onKeyDown?.(e), !(e.defaultPrevented || !n.sort) && (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), $i(n, e.shiftKey));
1560
3120
  },
1561
- onPointerDown: (e) => $n(e, n),
3121
+ onPointerDown: (t) => aa(t, e),
1562
3122
  rowSpan: e.rowSpan,
1563
3123
  scope: "col",
1564
3124
  style: {
1565
3125
  width: a?.width ?? n.width,
1566
3126
  ...o.style
1567
3127
  },
1568
- tabIndex: n.sort ? 0 : void 0
1569
- }, /* @__PURE__ */ M("span", {
3128
+ tabIndex: n.sort && !p ? 0 : void 0
3129
+ }, /* @__PURE__ */ A("span", {
1570
3130
  "aria-hidden": "true",
1571
3131
  className: "comins-column-drop-marker"
1572
- }), /* @__PURE__ */ N("span", {
3132
+ }), /* @__PURE__ */ j("span", {
3133
+ ...p ? Nn : {},
3134
+ "aria-hidden": p ? "true" : void 0,
1573
3135
  className: "comins-table__header-content",
1574
3136
  "data-comins-header-body": "true",
1575
- "data-comins-header-components": v ? "true" : void 0,
1576
- "data-comins-sort-indicator-visible": l ? "true" : void 0,
3137
+ "data-comins-header-components": te ? "true" : void 0,
3138
+ "data-comins-sort-indicator-visible": u ? "true" : void 0,
3139
+ inert: p ? !0 : void 0,
3140
+ ref: Mn,
1577
3141
  children: [
1578
- /* @__PURE__ */ M("span", {
3142
+ /* @__PURE__ */ j("span", {
1579
3143
  className: "comins-table__header-slot",
1580
3144
  "data-comins-header-slot": "left",
1581
- children: g
3145
+ children: [it && !re ? /* @__PURE__ */ A("span", {
3146
+ "aria-hidden": "true",
3147
+ className: "comins-column-move-handle",
3148
+ "data-comins-column-move-handle": "true",
3149
+ "data-testid": `column-move-handle-${n.id}`,
3150
+ draggable: !1,
3151
+ onClick: (e) => e.stopPropagation(),
3152
+ onPointerDown: (t) => {
3153
+ t.preventDefault(), t.stopPropagation(), aa(t, e, !0);
3154
+ },
3155
+ children: /* @__PURE__ */ A($e, { name: "columnMove" })
3156
+ }) : null, x]
1582
3157
  }),
1583
- /* @__PURE__ */ M("span", {
3158
+ /* @__PURE__ */ A("span", {
1584
3159
  className: "comins-table__header-label",
1585
- children: n.header?.renderer ? h : n.label
3160
+ children: n.header?.renderer ? b : p ? null : n.label
1586
3161
  }),
1587
- /* @__PURE__ */ N("span", {
3162
+ /* @__PURE__ */ j("span", {
1588
3163
  className: "comins-sort-meta",
1589
- "data-sort-visible": l ? "true" : void 0,
1590
- children: [/* @__PURE__ */ M("span", {
3164
+ "data-sort-visible": u ? "true" : void 0,
3165
+ children: [/* @__PURE__ */ A("span", {
1591
3166
  "aria-hidden": "true",
1592
3167
  className: "comins-sort-indicator",
1593
3168
  "data-sort-state": c,
1594
- "data-sort-visible": l ? "true" : void 0,
3169
+ "data-sort-visible": u ? "true" : void 0,
1595
3170
  "data-testid": `sort-indicator-${n.id}`,
1596
- children: /* @__PURE__ */ M("span", { className: "comins-sort-icon" })
1597
- }), u ? /* @__PURE__ */ M("span", {
3171
+ children: /* @__PURE__ */ A($e, { name: c === "asc" ? "sortAscending" : c === "desc" ? "sortDescending" : "sortUnsorted" })
3172
+ }), d ? /* @__PURE__ */ A("span", {
1598
3173
  "aria-hidden": "true",
1599
3174
  className: "comins-sort-priority",
1600
3175
  "data-testid": `sort-priority-${n.id}`,
1601
3176
  children: s.priority
1602
3177
  }) : null]
1603
3178
  }),
1604
- u ? /* @__PURE__ */ M("span", {
3179
+ d ? /* @__PURE__ */ A("span", {
1605
3180
  className: "comins-table__sort-status",
1606
- children: `Sorted ${s.rule.direction === "asc" ? "ascending" : "descending"}, priority ${s.priority} of ${Y.sortModel.length}`
3181
+ children: `Sorted ${s.rule.direction === "asc" ? "ascending" : "descending"}, priority ${s.priority} of ${q.sortModel.length}`
1607
3182
  }) : null,
1608
- /* @__PURE__ */ M("span", {
3183
+ /* @__PURE__ */ j("span", {
1609
3184
  className: "comins-table__header-slot",
1610
3185
  "data-comins-header-slot": "right",
1611
- children: _
3186
+ children: [ie && !p ? /* @__PURE__ */ A(ot, {
3187
+ columnId: n.id,
3188
+ columnLabel: m,
3189
+ kind: S,
3190
+ onChangeRule: typeof l?.onChangeModel == "function" ? (e) => ba(n.id, e) : void 0,
3191
+ onOpenChange: typeof l?.onChangeOpenColumnId == "function" ? l.onChangeOpenColumnId : void 0,
3192
+ open: l?.openColumnId === n.id,
3193
+ rule: Yr.get(n.id)
3194
+ }) : null, ee]
1612
3195
  })
1613
3196
  ]
1614
- }), /* @__PURE__ */ M("span", {
3197
+ }), p ? /* @__PURE__ */ A("span", {
3198
+ "aria-hidden": "true",
3199
+ className: "comins-column-placeholder-label",
3200
+ children: m
3201
+ }) : null, /* @__PURE__ */ A("span", {
1615
3202
  "aria-hidden": "true",
1616
3203
  className: "comins-table__resize",
1617
- "data-resizing": Zt === n.id ? "true" : void 0,
3204
+ "data-resizing": ur === n.id ? "true" : void 0,
1618
3205
  "data-testid": `resize-${n.id}`,
1619
3206
  onClick: (e) => e.stopPropagation(),
1620
3207
  onPointerDown: (e) => {
1621
3208
  e.preventDefault(), e.stopPropagation();
1622
3209
  let t = e.clientX, r = e.currentTarget.closest("th")?.getBoundingClientRect().width, i = /* @__PURE__ */ new Map();
1623
- for (let e of Q) {
1624
- let t = Array.from(V.current?.querySelectorAll("[data-comins-column-id]") ?? []).find((t) => t.dataset.cominsColumnId === e.id)?.getBoundingClientRect().width, n = X.current.columnState[e.id]?.width ?? e.width ?? 160;
3210
+ for (let e of X) {
3211
+ let t = Array.from(z.current?.querySelectorAll("[data-comins-column-id]") ?? []).find((t) => t.dataset.cominsColumnId === e.id)?.getBoundingClientRect().width, n = J.current.columnState[e.id]?.width ?? e.width ?? 160;
1625
3212
  i.set(e.id, t && Number.isFinite(t) ? t : n);
1626
3213
  }
1627
3214
  let o = i.get(n.id) ?? (r && Number.isFinite(r) ? r : a?.width ?? n.width ?? 160);
1628
- Qt(n.id);
3215
+ dr(n.id);
1629
3216
  let s = (e) => {
1630
- Z((r) => {
3217
+ Y((r) => {
1631
3218
  let a = r;
1632
- for (let [e, t] of i) a = D(a, e, t);
1633
- return xt(a, n.id, Math.max(_t(n), o + e.clientX - t));
3219
+ for (let [e, t] of i) a = ve(a, e, t);
3220
+ return Bn(a, n.id, Math.max(In(n), o + e.clientX - t));
1634
3221
  }, { columnLayoutChanged: !0 });
1635
3222
  }, c = () => {
1636
- window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", u), window.removeEventListener("blur", u), U.current === c && (U.current = null);
3223
+ window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", l), window.removeEventListener("pointercancel", u), window.removeEventListener("blur", u), B.current === c && (B.current = null);
1637
3224
  }, l = () => {
1638
- c(), Qt(null);
3225
+ c(), dr(null);
1639
3226
  }, u = () => {
1640
- c(), Qt(null);
3227
+ c(), dr(null);
1641
3228
  };
1642
- dn(c), window.addEventListener("pointermove", s), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", u), window.addEventListener("blur", u);
3229
+ Nr(c), window.addEventListener("pointermove", s), window.addEventListener("pointerup", l), window.addEventListener("pointercancel", u), window.addEventListener("blur", u);
1643
3230
  },
1644
- children: /* @__PURE__ */ M("span", { className: "comins-table__resize-line" })
3231
+ children: /* @__PURE__ */ A("span", { className: "comins-table__resize-line" })
1645
3232
  }));
1646
- }, mr = () => /* @__PURE__ */ M("colgroup", { children: Q.map((e, t) => /* @__PURE__ */ M("col", { style: { width: wn[t] } }, e.id)) }), hr = () => {
1647
- nn((e) => {
1648
- let t = Ct.current;
3233
+ }, Sa = () => /* @__PURE__ */ A("colgroup", { children: X.map((e, t) => /* @__PURE__ */ A("col", { style: { width: Hr[t] } }, e.id)) }), Ca = () => {
3234
+ _r((e) => {
3235
+ let t = Dn.current;
1649
3236
  return Math.abs(e - t) > .5 ? t : e;
1650
3237
  });
1651
- }, gr = (e) => {
1652
- if (x) {
1653
- if (!Pe || et.current) return;
1654
- e.scrollHeight - e.scrollTop - e.clientHeight <= ln && fn("scroll");
3238
+ }, wa = (e) => {
3239
+ if (G || K) return;
3240
+ if (T) {
3241
+ if (!qe || It.current) return;
3242
+ e.scrollHeight - e.scrollTop - e.clientHeight <= Er && Pr("scroll");
1655
3243
  return;
1656
3244
  }
1657
- if (!v || !h || pe || !Fe) return;
1658
- let t = Math.max(0, y);
3245
+ if (!re || !te || Ce || !Je) return;
3246
+ let t = Math.max(0, S);
1659
3247
  if (e.scrollHeight - e.scrollTop - e.clientHeight > t) return;
1660
- let n = X.current.rows.length;
1661
- pt.current !== n && (pt.current = n, Fe());
1662
- }, _r = (e) => {
1663
- let t = e.currentTarget;
1664
- Ct.current = t.scrollTop, gr(t), At.current !== null && (window.clearTimeout(At.current), At.current = null), Mt.current === null && (Mt.current = window.requestAnimationFrame(() => {
1665
- Mt.current = null, hr();
3248
+ let n = J.current.rows.length;
3249
+ zt.current !== n && (zt.current = n, Je());
3250
+ }, Ta = (e) => {
3251
+ let t = e.currentTarget, n = xn.current, r = H.current;
3252
+ Dn.current = t.scrollTop, r?.status === "pending" && Math.abs(t.scrollTop - r.previousPhysicalScrollTop) > .5 && (H.current = {
3253
+ ...r,
3254
+ status: "cancelled"
3255
+ }), n && Math.abs(t.scrollTop - n.actualPhysical) > .5 && (xn.current = null, lr(null)), wa(t), An.current !== null && (window.clearTimeout(An.current), An.current = null), jn.current === null && (jn.current = window.requestAnimationFrame(() => {
3256
+ jn.current = null, Ca();
1666
3257
  }));
1667
- let n = Math.max(0, t.scrollLeft);
1668
- if (V.current) {
1669
- let e = Math.max(0, V.current.scrollWidth - V.current.clientWidth), r = Math.max(0, t.scrollWidth - t.clientWidth);
1670
- n = Math.min(Math.min(e, r), n), Math.abs(t.scrollLeft - n) > .5 && (t.scrollLeft = n), V.current.scrollLeft = n;
3258
+ let i = Math.max(0, t.scrollLeft);
3259
+ if (z.current) {
3260
+ let e = Math.max(0, z.current.scrollWidth - z.current.clientWidth), n = Math.max(0, t.scrollWidth - t.clientWidth);
3261
+ i = Math.min(Math.min(e, n), i), Math.abs(t.scrollLeft - i) > .5 && (t.scrollLeft = i), z.current.scrollLeft = i;
1671
3262
  }
1672
- Ge.current && (Ge.current.scrollLeft = n);
3263
+ R.current && (R.current.scrollLeft = i);
1673
3264
  };
1674
- return /* @__PURE__ */ N("div", {
3265
+ return /* @__PURE__ */ j("div", {
1675
3266
  className: [
1676
3267
  "comins-table comins-typography-base h-full w-full overflow-hidden",
1677
- Sn,
1678
- xn.className,
3268
+ Oi,
3269
+ Di.className,
1679
3270
  r
1680
3271
  ].filter(Boolean).join(" "),
1681
- "aria-busy": kn || An ? "true" : void 0,
1682
- "data-loading": kn || An ? "true" : void 0,
1683
- "data-show-header": zn ? "true" : void 0,
3272
+ "aria-busy": Mi || Ni ? "true" : void 0,
3273
+ "data-filter-active": Jr ? "true" : void 0,
3274
+ "data-loading": Mi || Ni ? "true" : void 0,
3275
+ "data-show-header": Hi ? "true" : void 0,
1684
3276
  style: {
1685
- ...xn.style,
1686
- ...Be
3277
+ ...Di.style,
3278
+ ...ct
1687
3279
  },
1688
3280
  children: [
1689
- zn ? /* @__PURE__ */ M("div", {
3281
+ Hi ? /* @__PURE__ */ A("div", {
1690
3282
  className: "comins-table__header",
1691
- ref: V,
1692
- children: /* @__PURE__ */ N("table", {
3283
+ ref: z,
3284
+ children: /* @__PURE__ */ j("table", {
1693
3285
  className: "comins-table__table comins-table__header-table min-w-full table-fixed",
1694
- style: { width: En },
1695
- children: [mr(), /* @__PURE__ */ M("thead", {
3286
+ style: { width: Wr },
3287
+ children: [Sa(), /* @__PURE__ */ A("thead", {
1696
3288
  className: "comins-table__thead",
1697
- children: mn.map((e, t) => /* @__PURE__ */ M("tr", { children: e.map((e, t) => pr(e, t)) }, `header-row-${t}`))
3289
+ children: Kr.map((e, t) => /* @__PURE__ */ A("tr", { children: e.map((e, t) => xa(e, t)) }, `header-row-${t}`))
1698
3290
  })]
1699
3291
  })
1700
3292
  }) : null,
1701
- /* @__PURE__ */ N("div", {
3293
+ /* @__PURE__ */ j("div", {
1702
3294
  className: "comins-table__body-viewport",
1703
- "data-horizontal-overflow": Dn ? "true" : void 0,
1704
- "data-virtualized": B ? "true" : void 0,
1705
- "data-testid": f,
1706
- onScroll: _r,
1707
- ref: We,
3295
+ "data-horizontal-overflow": Ai ? "true" : void 0,
3296
+ "data-virtualized": I ? "true" : void 0,
3297
+ "data-testid": p,
3298
+ onFocusCapture: (e) => {
3299
+ let t = e.target.closest("[data-comins-row-data-index]"), n = t ? Number(t.dataset.cominsRowDataIndex) : NaN;
3300
+ un.current = Number.isInteger(n) ? n : null;
3301
+ },
3302
+ onScroll: Ta,
3303
+ ref: L,
1708
3304
  children: [
1709
- /* @__PURE__ */ N("table", {
1710
- className: ["comins-table__table comins-table__body-table min-w-full table-fixed", B ? "comins-table__body-table--virtualized" : void 0].filter(Boolean).join(" "),
1711
- style: B ? {
1712
- transform: `translate3d(0, ${bn.renderOffset}px, 0)`,
1713
- width: En
1714
- } : { width: En },
1715
- children: [mr(), /* @__PURE__ */ N("tbody", { children: [
1716
- Mn ? Array.from({ length: Fn }).map((e, t) => /* @__PURE__ */ M("tr", {
3305
+ /* @__PURE__ */ j("table", {
3306
+ className: ["comins-table__table comins-table__body-table min-w-full table-fixed", I ? "comins-table__body-table--virtualized" : void 0].filter(Boolean).join(" "),
3307
+ style: I ? {
3308
+ transform: `translate3d(0, ${Si.renderOffset}px, 0)`,
3309
+ width: Wr
3310
+ } : { width: Wr },
3311
+ children: [Sa(), /* @__PURE__ */ j("tbody", { children: [
3312
+ Fi ? Array.from({ length: Ri }).map((e, t) => /* @__PURE__ */ A("tr", {
1717
3313
  "aria-hidden": "true",
1718
3314
  className: "comins-table__tr comins-table__skeleton-row",
1719
3315
  "data-comins-row-parity": t % 2 == 0 ? "even" : "odd",
1720
3316
  "data-testid": "loading-skeleton-row",
1721
- style: { height: L },
1722
- children: Q.length > 0 ? Q.map((e) => /* @__PURE__ */ M("td", {
3317
+ style: { height: M },
3318
+ children: X.length > 0 ? X.map((e) => /* @__PURE__ */ A("td", {
1723
3319
  className: "comins-table__td comins-table__skeleton-cell px-3 py-2",
1724
3320
  "data-testid": `loading-skeleton-cell-${t}-${e.id}`,
1725
- style: { height: L },
1726
- children: /* @__PURE__ */ M("span", { className: "comins-table__skeleton-block" })
1727
- }, e.id)) : /* @__PURE__ */ M("td", {
3321
+ style: { height: M },
3322
+ children: /* @__PURE__ */ A("span", { className: "comins-table__skeleton-block" })
3323
+ }, e.id)) : /* @__PURE__ */ A("td", {
1728
3324
  className: "comins-table__td comins-table__skeleton-cell px-3 py-2",
1729
- children: /* @__PURE__ */ M("span", { className: "comins-table__skeleton-block" })
3325
+ children: /* @__PURE__ */ A("span", { className: "comins-table__skeleton-block" })
1730
3326
  })
1731
3327
  }, `loading-skeleton-${t}`)) : null,
1732
- Nn ? /* @__PURE__ */ M("tr", {
3328
+ Ii ? /* @__PURE__ */ A("tr", {
1733
3329
  className: "comins-table__tr comins-table__empty-state-row",
1734
- style: { height: L },
1735
- children: /* @__PURE__ */ M("td", {
3330
+ style: { height: M },
3331
+ children: /* @__PURE__ */ A("td", {
1736
3332
  className: "comins-table__td comins-table__empty-state-cell",
1737
- colSpan: Math.max(1, Q.length),
1738
- children: /* @__PURE__ */ M("div", {
3333
+ colSpan: Math.max(1, X.length),
3334
+ children: /* @__PURE__ */ A("div", {
1739
3335
  "data-testid": "data-table-empty-state",
1740
3336
  className: "comins-table__empty-state",
1741
- children: p ?? "표시할 데이터가 없습니다."
3337
+ children: m ?? "표시할 데이터가 없습니다."
1742
3338
  })
1743
3339
  })
1744
3340
  }) : null,
1745
- bn.entries.map((e, t) => {
1746
- let r = Ze(Le, e.row, e.visibleIndex), i = Cn.has(e.rowId), a = Rn === 0 && t === bn.entries.length - 1, o = Qe(r.style), s = B ? `virtual-row-slot-${t}` : String(e.rowId);
1747
- return /* @__PURE__ */ N(Ce, { children: [$t?.targetDataIndex === e.dataIndex && $t.sourceRowId !== e.rowId ? /* @__PURE__ */ M("tr", {
1748
- "aria-hidden": "true",
1749
- className: "comins-row-move-placeholder",
1750
- children: /* @__PURE__ */ M("td", {
1751
- colSpan: Math.max(1, Q.length),
1752
- "data-testid": "row-move-placeholder",
1753
- children: "이 위치로 이동"
1754
- })
1755
- }) : null, /* @__PURE__ */ M("tr", {
1756
- "aria-disabled": r.disabled ? "true" : void 0,
1757
- "aria-selected": i,
1758
- className: [
1759
- "comins-table__tr",
1760
- a ? "comins-table__tr--viewport-end" : void 0,
1761
- i ? "comins-row-selected" : void 0,
1762
- r.className
1763
- ].filter(Boolean).join(" "),
1764
- "data-disabled": r.disabled ? "true" : void 0,
1765
- "data-comins-row-custom-background": o === void 0 ? void 0 : "true",
1766
- "data-comins-row-data-index": e.dataIndex,
1767
- "data-comins-row-parity": e.visibleIndex % 2 == 0 ? "even" : "odd",
1768
- "data-row-draggable": r.draggable ? "true" : "false",
1769
- "data-selected-row": i ? "true" : void 0,
1770
- "data-testid": `row-${String(e.rowId)}`,
1771
- draggable: !1,
1772
- onClick: (t) => {
1773
- if (r.disabled) {
1774
- t.preventDefault();
1775
- return;
1776
- }
1777
- t.__cominsCellSelectionHandled || tr(t, e), Oe?.(nt(t, e));
1778
- },
1779
- onContextMenu: (t) => {
1780
- if (r.disabled) {
1781
- t.preventDefault();
1782
- return;
1783
- }
1784
- Z((t) => E(t, e.rowId)), K.current = e.rowId, F?.(nt(t, e));
1785
- },
1786
- onDoubleClick: (t) => {
1787
- if (r.disabled) {
1788
- t.preventDefault();
1789
- return;
1790
- }
1791
- je?.(nt(t, e));
1792
- },
1793
- onKeyDown: (t) => nr(t, e, r.disabled),
1794
- style: $e(L, r.style, o),
1795
- tabIndex: r.disabled ? -1 : 0,
1796
- children: Q.map((t, a) => {
1797
- let o = g(Y, e.row, t.id), s = {
1798
- columnId: t.id,
1799
- rowId: e.rowId
1800
- }, c = n && C(Y, s), l = n && Y.selection.cell?.rowId === e.rowId && Y.selection.cell.columnId === t.id, u = at(e, r.disabled, i, Y.selection.rowIds.length, t, a, o), d = ot(t, u), f = r.disabled || ct(d, u), p = { requestRowSelection: ({ event: t, mode: n }) => f ? !1 : n === "exclusive" ? (Z((t) => E(t, e.rowId)), K.current = e.rowId, !0) : (tr(t, e), !0) }, m = Xe(lt(d, u)), h = ut(d, u), _ = !!t.cell?.components?.length, v = dt(t, o, u), y = t.cell?.components?.map((e) => {
1801
- if (e.type !== "input") return e;
1802
- let t = e.onValueChange;
1803
- return {
1804
- ...e,
1805
- onValueChange: (e) => {
1806
- Z((t) => Se(t, [{
1807
- id: e.row.id,
1808
- patch: (t) => St(t, e.column.field, e.value)
1809
- }])), t?.(e);
1810
- }
1811
- };
1812
- }), b = mt(y, u), x = t.cell?.renderer ? t.cell.renderer(u) : _ ? gt(v, y, u, {
1813
- interaction: p,
1814
- showContent: !1
1815
- }) : /* @__PURE__ */ M("span", {
1816
- className: "comins-table__cell-value",
1817
- children: v
1818
- }), ee = typeof t.cell?.tooltip == "function" ? t.cell.tooltip(u) : t.cell?.tooltip, S = a === 0 ? z?.entriesByRowId.get(e.rowId) : void 0, w = S ? /* @__PURE__ */ N("span", {
1819
- className: "comins-tree-cell-content",
1820
- style: { "--comins-tree-depth": S.depth },
1821
- children: [S.hasChildren ? /* @__PURE__ */ M("button", {
1822
- "aria-expanded": S.expanded,
1823
- "aria-label": `${S.expanded ? "Collapse" : "Expand"} ${String(e.rowId)}`,
1824
- className: "comins-tree-expander",
1825
- "data-testid": `tree-expander-${String(e.rowId)}`,
1826
- onClick: (t) => {
1827
- t.preventDefault(), t.stopPropagation(), z?.onToggle(e.rowId);
1828
- },
1829
- onMouseDown: (e) => e.stopPropagation(),
1830
- onPointerDown: (e) => e.stopPropagation(),
1831
- type: "button",
1832
- children: S.expanded ? "▾" : "▸"
1833
- }) : /* @__PURE__ */ M("span", {
1834
- "aria-hidden": "true",
1835
- className: "comins-tree-expander-spacer"
1836
- }), /* @__PURE__ */ M("span", {
1837
- className: "comins-tree-cell-value",
1838
- children: x
1839
- })]
1840
- }) : x;
1841
- return /* @__PURE__ */ N("td", {
1842
- "aria-disabled": f ? "true" : void 0,
1843
- className: [
1844
- "comins-table__td px-3 py-2",
1845
- a === 0 ? "comins-table__td--with-row-handle" : void 0,
1846
- c ? "comins-cell-range-selected" : void 0,
1847
- m
1848
- ].filter(Boolean).join(" "),
1849
- "data-disabled": f ? "true" : void 0,
1850
- "data-comins-cell-column-id": t.id,
1851
- "data-comins-component-cell": b.length > 0 ? "true" : void 0,
1852
- "data-comins-data-index": e.dataIndex,
1853
- "data-range-selected": c ? "true" : void 0,
1854
- "data-selected": l ? "true" : void 0,
1855
- "data-testid": `cell-${String(e.rowId)}-${t.id}`,
1856
- draggable: !1,
1857
- onClick: (r) => {
1858
- if (Ee && r.stopPropagation(), f) {
1859
- r.preventDefault(), r.stopPropagation();
1860
- return;
1861
- }
1862
- if (q.current) {
1863
- q.current = !1, r.__cominsCellSelectionHandled = !0;
1864
- return;
1865
- }
1866
- let i = n ? Y.selection.cell ?? Je.current : null;
1867
- if (r.shiftKey && i) {
1868
- r.__cominsCellSelectionHandled = !0, Je.current = i, Z((t) => ue(K.current === null ? E(t, e.rowId) : de(t, Hn(t, K.current, e.rowId)), {
1869
- anchor: i,
1870
- focus: s
1871
- })), K.current = e.rowId;
1872
- return;
1873
- }
1874
- n && (Je.current = s), Z((t) => {
1875
- let i = E(t, e.rowId, {
1876
- multi: r.ctrlKey || r.metaKey,
1877
- toggle: r.ctrlKey || r.metaKey
1878
- });
1879
- return n ? le(i, s) : i;
1880
- }), r.__cominsCellSelectionHandled = !0, K.current = e.rowId, Ee?.(rt(r, e, t, a, o));
1881
- },
1882
- onContextMenu: (r) => {
1883
- if (f) {
1884
- r.preventDefault(), r.stopPropagation();
1885
- return;
1886
- }
1887
- Z((t) => {
1888
- let r = E(t, e.rowId);
1889
- return n ? le(r, s) : r;
1890
- }), K.current = e.rowId, n && (Je.current = s), P && (r.stopPropagation(), P(rt(r, e, t, a, o)));
1891
- },
1892
- onDoubleClick: (n) => {
1893
- if (Ae && n.stopPropagation(), f) {
1894
- n.preventDefault(), n.stopPropagation();
1895
- return;
1896
- }
1897
- Ae?.(rt(n, e, t, a, o));
1898
- },
1899
- onKeyDown: (n) => rr(n, e, t, a, s, f),
1900
- onMouseDown: (e) => ir(e, s, f),
1901
- onMouseOver: (e) => {
1902
- e.buttons === 1 && !U.current && or(s);
1903
- },
1904
- onMouseUp: sr,
1905
- onPointerDown: (e) => cr(e, s, f),
1906
- onPointerEnter: (e) => {
1907
- e.buttons === 1 && or(s);
1908
- },
1909
- onPointerMove: (e) => {
1910
- e.buttons === 1 && or(s);
1911
- },
1912
- onPointerUp: sr,
1913
- style: {
1914
- height: L,
1915
- ...h
1916
- },
1917
- title: typeof ee == "string" ? ee : void 0,
1918
- tabIndex: f ? -1 : 0,
1919
- children: [a === 0 && r.draggable ? /* @__PURE__ */ M("span", {
1920
- "aria-hidden": "true",
1921
- className: "comins-row-drag-handle",
1922
- "data-testid": `row-drag-handle-${String(e.rowId)}`,
3341
+ Si.slots.map((e, t) => {
3342
+ if (e.kind === "group") {
3343
+ let n = Z?.groupsById.get(e.groupId);
3344
+ if (!n) return null;
3345
+ let r = ci.has(e.groupId), i = t === Si.slots.length - 1, a = yi.at(-1)?.key === e.key, o = Si.scrollHeight >= zn - 1, s = i && (I ? a && o : Vi === 0), c = Object.fromEntries([...n.aggregationState].map(([e, t]) => [e, wt(t)])), l = {
3346
+ aggregateValues: c,
3347
+ expanded: r,
3348
+ group: n.group,
3349
+ groupId: n.groupId,
3350
+ groupIndex: n.groupIndex,
3351
+ isEmpty: n.leafSourceIndexes.length === 0,
3352
+ rowCount: n.leafSourceIndexes.length
3353
+ }, u = N?.getGroupRowProps?.(l), d = N?.renderGroupContent?.(l), f = Object.entries(c).flatMap(([e, t]) => {
3354
+ if (t === null) return [];
3355
+ let n = q.columns.find((t) => t.id === e);
3356
+ return [/* @__PURE__ */ j("span", {
3357
+ className: "comins-row-group-aggregate",
3358
+ children: [
3359
+ String(n?.label ?? e),
3360
+ ": ",
3361
+ String(t)
3362
+ ]
3363
+ }, e)];
3364
+ }), p = N?.groupDraggable === !0 && typeof N.onChangeGroups == "function", m = mr?.targetGroupId === e.groupId && mr.sourceGroupId !== e.groupId ? mr.position : void 0, h = fr?.targetGroupId === e.groupId;
3365
+ return /* @__PURE__ */ A("tr", {
3366
+ className: [
3367
+ "comins-table__tr comins-table__group-row",
3368
+ u?.className,
3369
+ s ? "comins-table__tr--viewport-end" : void 0
3370
+ ].filter(Boolean).join(" "),
3371
+ "data-comins-group-id": String(e.groupId),
3372
+ "data-comins-group-index": n.groupIndex,
3373
+ "data-comins-group-row": "true",
3374
+ "data-comins-group-drag-source": mr?.sourceGroupId === e.groupId ? "true" : void 0,
3375
+ "data-comins-group-drop-position": m,
3376
+ "data-comins-row-drop-valid": h ? fr.valid ? "true" : "false" : void 0,
3377
+ "data-testid": `group-row-${encodeURIComponent(String(e.groupId))}`,
3378
+ style: {
3379
+ ...u?.style,
3380
+ height: M
3381
+ },
3382
+ children: /* @__PURE__ */ A("th", {
3383
+ className: "comins-table__td comins-table__group-cell px-3 py-2",
3384
+ colSpan: Math.max(1, X.length),
3385
+ scope: "rowgroup",
3386
+ style: { height: M },
3387
+ children: /* @__PURE__ */ j("span", {
3388
+ className: "comins-row-group-cell-content",
3389
+ children: [
3390
+ p ? /* @__PURE__ */ A(et, {
3391
+ "aria-label": `Move ${String(n.label)} group`,
3392
+ className: "comins-row-group-drag-handle",
3393
+ "data-testid": `group-drag-handle-${encodeURIComponent(String(e.groupId))}`,
3394
+ icon: "columnMove",
3395
+ onPointerDown: (t) => ga(t, e.groupId)
3396
+ }) : null,
3397
+ /* @__PURE__ */ A(et, {
3398
+ "aria-expanded": r,
3399
+ "aria-label": `${r ? "Collapse" : "Expand"} ${String(n.label)} group`,
3400
+ className: "comins-row-group-expander",
3401
+ "data-testid": `group-toggle-${encodeURIComponent(String(e.groupId))}`,
3402
+ disabled: typeof N?.onChangeExpandedGroupIds != "function",
3403
+ icon: r ? "disclosureExpanded" : "disclosureCollapsed",
3404
+ onClick: (t) => {
3405
+ t.preventDefault(), t.stopPropagation(), li(e.groupId);
3406
+ },
3407
+ ref: (t) => {
3408
+ t ? en.current.set(e.groupId, t) : en.current.delete(e.groupId);
3409
+ }
3410
+ }),
3411
+ /* @__PURE__ */ A("span", {
3412
+ className: "comins-row-group-content",
3413
+ children: typeof N?.renderGroupContent == "function" ? d : /* @__PURE__ */ j(Be, { children: [
3414
+ /* @__PURE__ */ A("span", {
3415
+ className: "comins-row-group-label",
3416
+ children: n.label
3417
+ }),
3418
+ /* @__PURE__ */ j("span", {
3419
+ className: "comins-row-group-count",
3420
+ children: [n.leafSourceIndexes.length, " Rows"]
3421
+ }),
3422
+ f
3423
+ ] })
3424
+ })
3425
+ ]
3426
+ })
3427
+ })
3428
+ }, e.key);
3429
+ }
3430
+ let r = e, i = dn(xr, r.row, r.visibleIndex), a = ki.has(r.rowId), o = t === Si.slots.length - 1, s = yi.at(-1)?.key === r.key, c = Si.scrollHeight >= zn - 1, l = o && (I ? s && c : Vi === 0), u = fn(i.style), d = I && Si.mixed ? r.key : I ? `virtual-row-slot-${t}` : String(r.rowId), f = { row: mn(r) }, p = Or && (nt?.(f) ?? !0), m = p && vi.has(r.rowId), h = m && r.detail?.mode === "fixed" ? r.detail.height : void 0, _ = r.detail?.mode ?? "fixed", v = `${typeof r.rowId}-${encodeURIComponent(String(r.rowId))}`, y = `comins-row-detail-${encodeURIComponent(vr)}-${v}`, b = `${y}-content`, x = `${y}-toggle`;
3431
+ return /* @__PURE__ */ j(De, { children: [
3432
+ fr?.targetDataIndex === r.dataIndex && fr.sourceRowId !== r.rowId ? /* @__PURE__ */ A("tr", {
3433
+ "aria-hidden": "true",
3434
+ className: "comins-row-move-placeholder",
3435
+ "data-comins-row-drop-valid": fr.valid ? "true" : "false",
3436
+ children: /* @__PURE__ */ A("td", {
3437
+ colSpan: Math.max(1, X.length),
3438
+ "data-testid": "row-move-placeholder",
3439
+ children: "이 위치로 이동"
3440
+ })
3441
+ }) : null,
3442
+ /* @__PURE__ */ A("tr", {
3443
+ "aria-disabled": i.disabled ? "true" : void 0,
3444
+ "aria-selected": a,
3445
+ className: [
3446
+ "comins-table__tr",
3447
+ l && !m ? "comins-table__tr--viewport-end" : void 0,
3448
+ a ? "comins-row-selected" : void 0,
3449
+ i.className
3450
+ ].filter(Boolean).join(" "),
3451
+ "data-disabled": i.disabled ? "true" : void 0,
3452
+ "data-comins-row-custom-background": u === void 0 ? void 0 : "true",
3453
+ "data-comins-row-data-index": r.dataIndex,
3454
+ "data-comins-row-parity": r.visibleIndex % 2 == 0 ? "even" : "odd",
3455
+ "data-row-draggable": i.draggable ? "true" : "false",
3456
+ "data-selected-row": a ? "true" : void 0,
3457
+ "data-testid": `row-${String(r.rowId)}`,
3458
+ draggable: !1,
3459
+ onClick: (e) => {
3460
+ if (i.disabled) {
3461
+ e.preventDefault();
3462
+ return;
3463
+ }
3464
+ e.__cominsCellSelectionHandled || sa(e, r), Le?.(gn(e, r));
3465
+ },
3466
+ onContextMenu: (e) => {
3467
+ if (i.disabled) {
3468
+ e.preventDefault();
3469
+ return;
3470
+ }
3471
+ Y((e) => on(e, r.rowId)), V.current = r.rowId, ze?.(gn(e, r));
3472
+ },
3473
+ onDoubleClick: (e) => {
3474
+ if (i.disabled) {
3475
+ e.preventDefault();
3476
+ return;
3477
+ }
3478
+ We?.(gn(e, r));
3479
+ },
3480
+ onKeyDown: (e) => ca(e, r, i.disabled),
3481
+ style: pn(M, i.style, u),
3482
+ tabIndex: i.disabled ? -1 : 0,
3483
+ children: X.map((e, t) => {
3484
+ let o = g(q, r.row, e.id), s = {
3485
+ columnId: e.id,
3486
+ rowId: r.rowId
3487
+ }, c = n && ne(q, s, Q?.visibleLeafRowIds ?? q.rowIds), l = n && q.selection.cell?.rowId === r.rowId && q.selection.cell.columnId === e.id, u = yn(r, i.disabled, a, q.selection.rowIds.length, e, t, o), d = bn(e, u), f = i.disabled || Sn(d, u), h = { requestRowSelection: ({ event: e, mode: t }) => f ? !1 : t === "exclusive" ? (Y((e) => fe(e, r.rowId)), V.current = r.rowId, !0) : (sa(e, r), !0) }, _ = ln(Cn(d, u)), v = wn(d, u), y = !!e.cell?.components?.length, ee = Tn(e, o, u), te = e.cell?.components?.map((e) => {
3488
+ if (e.type !== "input") return e;
3489
+ let t = e.onValueChange;
3490
+ return {
3491
+ ...e,
3492
+ onValueChange: (e) => {
3493
+ Y((t) => Te(t, [{
3494
+ id: e.row.id,
3495
+ patch: (t) => Vn(t, e.column.field, e.value)
3496
+ }])), t?.(e);
3497
+ }
3498
+ };
3499
+ }), re = On(te, u), S = e.cell?.renderer ? e.cell.renderer(u) : y ? Fn(ee, te, u, {
3500
+ interaction: h,
3501
+ showContent: !1
3502
+ }) : /* @__PURE__ */ A("span", {
3503
+ className: "comins-table__cell-value",
3504
+ children: ee
3505
+ }), ie = typeof e.cell?.tooltip == "function" ? e.cell.tooltip(u) : e.cell?.tooltip, C = e.id === F?.treeColumnId ? F.entriesByRowId.get(r.rowId) : void 0, ae = C ? /* @__PURE__ */ j("span", {
3506
+ className: "comins-tree-cell-content",
3507
+ style: { "--comins-tree-depth": C.depth },
3508
+ children: [C.hasChildren ? /* @__PURE__ */ A(et, {
3509
+ "aria-expanded": C.expanded,
3510
+ "aria-label": `${C.expanded ? "Collapse" : "Expand"} ${String(r.rowId)}`,
3511
+ className: "comins-tree-expander",
3512
+ "data-testid": `tree-expander-${String(r.rowId)}`,
3513
+ icon: C.expanded ? "disclosureExpanded" : "disclosureCollapsed",
3514
+ onClick: (e) => {
3515
+ e.preventDefault(), e.stopPropagation(), F?.onToggle(r.rowId);
3516
+ },
3517
+ onMouseDown: (e) => e.stopPropagation(),
3518
+ onPointerDown: (e) => e.stopPropagation()
3519
+ }) : /* @__PURE__ */ A("span", {
3520
+ "aria-hidden": "true",
3521
+ className: "comins-tree-expander-spacer"
3522
+ }), /* @__PURE__ */ A("span", {
3523
+ className: "comins-tree-cell-value",
3524
+ children: S
3525
+ })]
3526
+ }) : S;
3527
+ return /* @__PURE__ */ A("td", {
3528
+ "aria-disabled": f ? "true" : void 0,
3529
+ className: [
3530
+ "comins-table__td px-3 py-2",
3531
+ c ? "comins-cell-range-selected" : void 0,
3532
+ _
3533
+ ].filter(Boolean).join(" "),
3534
+ "data-disabled": f ? "true" : void 0,
3535
+ "data-comins-cell-column-id": e.id,
3536
+ "data-comins-component-cell": re.length > 0 ? "true" : void 0,
3537
+ "data-comins-data-index": r.dataIndex,
3538
+ "data-range-selected": c ? "true" : void 0,
3539
+ "data-selected": l ? "true" : void 0,
3540
+ "data-testid": `cell-${String(r.rowId)}-${e.id}`,
1923
3541
  draggable: !1,
1924
- onClick: (e) => e.stopPropagation(),
1925
- onMouseDown: (e) => e.stopPropagation(),
1926
- onPointerDown: (t) => lr(t, e, r.disabled, r.draggable)
1927
- }) : null, w]
1928
- }, t.id);
1929
- })
1930
- }, s)] }, s);
3542
+ onClick: (i) => {
3543
+ if (Ie && i.stopPropagation(), f) {
3544
+ i.preventDefault(), i.stopPropagation();
3545
+ return;
3546
+ }
3547
+ if (Ht.current) {
3548
+ Ht.current = !1, i.__cominsCellSelectionHandled = !0;
3549
+ return;
3550
+ }
3551
+ let a = n ? q.selection.cell ?? Nt.current : null;
3552
+ if (i.shiftKey && a) {
3553
+ i.__cominsCellSelectionHandled = !0, Nt.current = a, Y((e) => {
3554
+ let t = V.current === null ? fe(e, r.rowId) : pe(e, Gi(e, V.current, r.rowId));
3555
+ return de(t, {
3556
+ anchor: a,
3557
+ focus: s
3558
+ });
3559
+ }), V.current = r.rowId;
3560
+ return;
3561
+ }
3562
+ n && (Nt.current = s), Y((e) => {
3563
+ let t = fe(e, r.rowId, {
3564
+ multi: i.ctrlKey || i.metaKey,
3565
+ toggle: i.ctrlKey || i.metaKey
3566
+ });
3567
+ return n ? ue(t, s) : t;
3568
+ }), i.__cominsCellSelectionHandled = !0, V.current = r.rowId, Ie?.(_n(i, r, e, t, o));
3569
+ },
3570
+ onContextMenu: (i) => {
3571
+ if (i.target.closest(".comins-row-detail-expander")) {
3572
+ i.stopPropagation();
3573
+ return;
3574
+ }
3575
+ if (f) {
3576
+ i.preventDefault(), i.stopPropagation();
3577
+ return;
3578
+ }
3579
+ Y((e) => {
3580
+ let t = on(e, r.rowId);
3581
+ return n ? ue(t, s) : t;
3582
+ }), V.current = r.rowId, n && (Nt.current = s), Re && (i.stopPropagation(), Re(_n(i, r, e, t, o)));
3583
+ },
3584
+ onDoubleClick: (n) => {
3585
+ if (n.target.closest(".comins-row-detail-expander")) {
3586
+ n.stopPropagation();
3587
+ return;
3588
+ }
3589
+ if (Ue && n.stopPropagation(), f) {
3590
+ n.preventDefault(), n.stopPropagation();
3591
+ return;
3592
+ }
3593
+ Ue?.(_n(n, r, e, t, o));
3594
+ },
3595
+ onKeyDown: (n) => la(n, r, e, t, s, f),
3596
+ onMouseDown: (e) => ua(e, s, f),
3597
+ onMouseOver: (e) => {
3598
+ e.buttons === 1 && !B.current && fa(s);
3599
+ },
3600
+ onMouseUp: pa,
3601
+ onPointerDown: (e) => ma(e, s, f),
3602
+ onPointerEnter: (e) => {
3603
+ e.buttons === 1 && fa(s);
3604
+ },
3605
+ onPointerMove: (e) => {
3606
+ e.buttons === 1 && fa(s);
3607
+ },
3608
+ onPointerUp: pa,
3609
+ style: {
3610
+ height: M,
3611
+ ...v
3612
+ },
3613
+ title: typeof ie == "string" ? ie : void 0,
3614
+ tabIndex: f ? -1 : 0,
3615
+ children: t === 0 && (Or || i.draggable) ? /* @__PURE__ */ j("div", {
3616
+ className: "comins-row-cell-content",
3617
+ children: [/* @__PURE__ */ j("span", {
3618
+ className: "comins-row-leading-controls",
3619
+ children: [Or ? p ? /* @__PURE__ */ A(vt, {
3620
+ controlsId: b,
3621
+ disabled: !He,
3622
+ expanded: m,
3623
+ id: x,
3624
+ label: `${m ? "Collapse" : "Expand"} ${String(r.rowId)} details`,
3625
+ onElement: (e) => {
3626
+ e ? St.current.set(r.rowId, e) : St.current.delete(r.rowId);
3627
+ },
3628
+ onToggle: () => jr(r.rowId, p),
3629
+ testId: `row-detail-toggle-${String(r.rowId)}`
3630
+ }) : /* @__PURE__ */ A("span", {
3631
+ "aria-hidden": "true",
3632
+ className: "comins-row-detail-expander-spacer",
3633
+ "data-comins-row-leading-control": "disclosure"
3634
+ }) : null, i.draggable ? /* @__PURE__ */ A("span", {
3635
+ "aria-hidden": "true",
3636
+ className: "comins-row-drag-handle",
3637
+ "data-comins-row-leading-control": "drag",
3638
+ "data-testid": `row-drag-handle-${String(r.rowId)}`,
3639
+ draggable: !1,
3640
+ onClick: (e) => e.stopPropagation(),
3641
+ onMouseDown: (e) => e.stopPropagation(),
3642
+ onPointerDown: (e) => ha(e, r, i.disabled, i.draggable)
3643
+ }) : null]
3644
+ }), /* @__PURE__ */ A("div", {
3645
+ className: "comins-row-cell-content__value",
3646
+ children: ae
3647
+ })]
3648
+ }) : ae
3649
+ }, e.id);
3650
+ })
3651
+ }, d),
3652
+ m ? /* @__PURE__ */ A(yt, {
3653
+ colSpan: X.length,
3654
+ contentId: b,
3655
+ fixedHeight: h,
3656
+ labelId: x,
3657
+ onContentElement: (e) => zr(r.rowId, _, e),
3658
+ ownerId: String(r.rowId),
3659
+ testId: `row-detail-content-${String(r.rowId)}`,
3660
+ getToggleElement: () => St.current.get(r.rowId) ?? null,
3661
+ children: rt?.(f)
3662
+ }) : null
3663
+ ] }, d);
1931
3664
  }),
1932
- Pn ? /* @__PURE__ */ M("tr", {
3665
+ Li ? /* @__PURE__ */ A("tr", {
1933
3666
  className: "comins-table__tr comins-table__infinite-loading-row",
1934
- style: { height: L },
1935
- children: /* @__PURE__ */ N("td", {
3667
+ style: { height: M },
3668
+ children: /* @__PURE__ */ j("td", {
1936
3669
  className: "comins-table__td comins-table__infinite-loading-cell",
1937
- colSpan: Math.max(1, Q.length),
3670
+ colSpan: Math.max(1, X.length),
1938
3671
  "data-testid": "data-table-infinite-loading-row",
1939
- children: [/* @__PURE__ */ M("span", {
3672
+ children: [/* @__PURE__ */ A("span", {
1940
3673
  className: "comins-table__loading-spinner",
1941
3674
  "data-testid": "data-table-infinite-loading-spinner"
1942
- }), /* @__PURE__ */ M("span", { children: "데이터를 불러오는 중입니다." })]
3675
+ }), /* @__PURE__ */ A("span", { children: "데이터를 불러오는 중입니다." })]
1943
3676
  })
1944
3677
  }) : null,
1945
- Rn > 0 ? /* @__PURE__ */ M("tr", {
3678
+ Vi > 0 ? /* @__PURE__ */ A("tr", {
1946
3679
  "aria-hidden": "true",
1947
3680
  className: "comins-table-empty-filler",
1948
- children: /* @__PURE__ */ M("td", {
1949
- colSpan: Math.max(1, Q.length),
3681
+ children: /* @__PURE__ */ A("td", {
3682
+ colSpan: Math.max(1, X.length),
1950
3683
  "data-testid": "table-empty-filler",
1951
- style: { height: Rn }
3684
+ style: { height: Vi }
1952
3685
  })
1953
3686
  }) : null
1954
3687
  ] })]
1955
3688
  }),
1956
- B ? /* @__PURE__ */ M("div", {
3689
+ I ? /* @__PURE__ */ A("div", {
1957
3690
  "aria-hidden": "true",
1958
3691
  className: "comins-table__body-virtual-sizer",
1959
3692
  style: {
1960
- height: bn.scrollHeight,
1961
- width: En
3693
+ height: Si.scrollHeight,
3694
+ width: Wr
1962
3695
  }
1963
3696
  }) : null,
1964
- kn && !jn ? /* @__PURE__ */ N("div", {
3697
+ Mi && !Pi ? /* @__PURE__ */ j("div", {
1965
3698
  className: "comins-table__loading-overlay",
1966
3699
  "data-testid": "data-table-loading-overlay",
1967
3700
  role: "status",
1968
- style: tn > 0 ? { transform: `translateY(${tn}px)` } : void 0,
1969
- children: [/* @__PURE__ */ M("span", {
3701
+ style: gr > 0 ? { transform: `translateY(${gr}px)` } : void 0,
3702
+ children: [/* @__PURE__ */ A("span", {
1970
3703
  className: "comins-table__loading-spinner",
1971
3704
  "data-testid": "data-table-loading-spinner"
1972
- }), /* @__PURE__ */ M("span", { children: ce ?? "불러오는 중입니다." })]
3705
+ }), /* @__PURE__ */ A("span", { children: be ?? "불러오는 중입니다." })]
1973
3706
  }) : null
1974
3707
  ]
1975
3708
  }),
1976
- R ? /* @__PURE__ */ M("div", {
3709
+ P ? /* @__PURE__ */ A("div", {
1977
3710
  "aria-label": "Table summary",
1978
3711
  className: "comins-table__summary",
1979
- ref: Ge,
1980
- children: /* @__PURE__ */ N("table", {
3712
+ ref: R,
3713
+ children: /* @__PURE__ */ j("table", {
1981
3714
  className: "comins-table__table comins-table__summary-table min-w-full table-fixed",
1982
- style: { width: En },
1983
- children: [mr(), /* @__PURE__ */ M("tfoot", { children: /* @__PURE__ */ M("tr", {
1984
- className: ["comins-table__summary-row", R.className].filter(Boolean).join(" "),
1985
- style: R.style,
1986
- children: gn.map((e) => /* @__PURE__ */ M("td", {
3715
+ style: { width: Wr },
3716
+ children: [Sa(), /* @__PURE__ */ A("tfoot", { children: /* @__PURE__ */ A("tr", {
3717
+ className: ["comins-table__summary-row", P.className].filter(Boolean).join(" "),
3718
+ style: P.style,
3719
+ children: $r.map((e) => /* @__PURE__ */ A("td", {
1987
3720
  className: ["comins-table__summary-cell px-3 py-2", e.className].filter(Boolean).join(" "),
1988
3721
  colSpan: e.colSpan,
3722
+ "data-comins-summary-column-id": e.column.id,
1989
3723
  "data-testid": `summary-cell-${e.column.id}`,
1990
3724
  style: e.style,
1991
3725
  children: e.value
@@ -1993,57 +3727,65 @@ function Ft({ "buffer-size": e, cellSelection: n = !0, className: r, columnGroup
1993
3727
  }) })]
1994
3728
  })
1995
3729
  }) : null,
1996
- fr && Vt ? /* @__PURE__ */ M("div", {
3730
+ ya && ir ? /* @__PURE__ */ j("div", {
1997
3731
  "aria-hidden": "true",
1998
3732
  className: "comins-column-move-ghost",
1999
3733
  "data-testid": "column-move-ghost",
2000
3734
  style: {
2001
- left: Vt.x + 12,
2002
- top: Vt.y + 12
3735
+ left: ir.x + 12,
3736
+ top: ir.y + 12
2003
3737
  },
2004
- children: fr
3738
+ children: [/* @__PURE__ */ A($e, { name: "columnMove" }), /* @__PURE__ */ A("span", {
3739
+ className: "comins-column-move-ghost__label",
3740
+ children: ya
3741
+ })]
2005
3742
  }) : null
2006
3743
  ]
2007
3744
  });
2008
3745
  }
2009
- function It({ data: e, defaultExpandAll: t = !0, getRowId: n, hasMoreRows: r, infiniteScroll: i, infiniteScrollThreshold: a, lazyLoad: o, lazyLoadBatchSize: s, lazyLoadMode: c, lazyLoadThreshold: l, loadingMore: u, onChangeData: d, onChangeSort: f, onChangeSortModel: p, onLazyLoad: m, onLoadMore: h, rowProps: g, tree: _, ...v }, y) {
2010
- let b = A(t).current, [x, ee] = j([]), S = k(() => Nt(e, v.columns, x), [
3746
+ function nr({ data: e, columnFiltering: t, defaultExpandAll: n = !0, estimatedRowDetailHeight: r, expandedRowIds: i, getRowDetailHeight: a, getRowId: o, hasMoreRows: s, infiniteScroll: c, infiniteScrollThreshold: l, lazyLoad: u, lazyLoadBatchSize: d, lazyLoadMode: f, lazyLoadThreshold: p, loadingMore: m, onChangeData: h, onChangeExpandedRowIds: g, onChangeSort: _, onChangeSortModel: v, onLazyLoad: y, onLoadMore: b, rowGrouping: x, rowProps: ee, isRowExpandable: te, renderRowDetail: ne, tree: re, ...S }, ie) {
3747
+ let C = O(n).current, [ae, oe] = k([]), w = D(() => S.columns.map((e, t) => t === 0 ? {
3748
+ ...e,
3749
+ lockPosition: !0
3750
+ } : e), [S.columns]), se = w[0]?.id ?? w[0]?.field ?? null, ce = D(() => $n(e, w, ae), [
2011
3751
  e,
2012
- v.columns,
2013
- x
2014
- ]), C = k(() => Ke(S, n, { defaultExpandAll: b }), [
2015
- n,
2016
- b,
2017
- S
2018
- ]), w = k(() => new Map(C.map((e) => [e.rowId, e])), [C]), te = k(() => ({
2019
- entriesByRowId: w,
3752
+ w,
3753
+ ae
3754
+ ]), T = D(() => zt(ce, o, { defaultExpandAll: C }), [
3755
+ o,
3756
+ C,
3757
+ ce
3758
+ ]), le = D(() => new Map(T.map((e) => [e.rowId, e])), [T]), ue = D(() => ({
3759
+ entriesByRowId: le,
2020
3760
  onExpand: (t) => {
2021
- let r = Pt(e, t, !0, n, b);
2022
- r !== e && d?.([...r]);
3761
+ let n = er(e, t, !0, o, C);
3762
+ n !== e && h?.([...n]);
2023
3763
  },
2024
3764
  onFold: (t) => {
2025
- let r = Pt(e, t, !1, n, b);
2026
- r !== e && d?.([...r]);
3765
+ let n = er(e, t, !1, o, C);
3766
+ n !== e && h?.([...n]);
2027
3767
  },
2028
- onToggle: (t) => d?.(qe(e, t, n, { defaultExpandAll: b })),
2029
- summaryRows: H(e)
3768
+ onToggle: (t) => h?.(Bt(e, t, o, { defaultExpandAll: C })),
3769
+ summaryRows: V(e),
3770
+ treeColumnId: se
2030
3771
  }), [
2031
3772
  e,
2032
- w,
2033
- n,
2034
- b,
2035
- d
2036
- ]), ne = (t) => {
2037
- let r = e;
3773
+ le,
3774
+ o,
3775
+ C,
3776
+ h,
3777
+ se
3778
+ ]), de = (t) => {
3779
+ let n = e;
2038
3780
  t.forEach((e, t) => {
2039
- let i = C[t];
2040
- i && i.item !== e && (r = U(r, i.rowId, n, () => e));
2041
- }), r !== e && d?.([...r]);
2042
- };
2043
- return /* @__PURE__ */ M(Lt, {
2044
- ...v,
2045
- data: C.map((e) => e.item),
2046
- getRowId: n,
3781
+ let r = T[t];
3782
+ r && r.item !== e && (n = Vt(n, r.rowId, o, () => e));
3783
+ }), n !== e && h?.([...n]);
3784
+ }, fe = {
3785
+ ...S,
3786
+ columns: w,
3787
+ data: T.map((e) => e.item),
3788
+ getRowId: o,
2047
3789
  hasMoreRows: !1,
2048
3790
  infiniteScroll: !1,
2049
3791
  infiniteScrollThreshold: void 0,
@@ -2052,38 +3794,41 @@ function It({ data: e, defaultExpandAll: t = !0, getRowId: n, hasMoreRows: r, in
2052
3794
  lazyLoadMode: void 0,
2053
3795
  lazyLoadThreshold: void 0,
2054
3796
  loadingMore: !1,
2055
- onChangeData: ne,
2056
- onChangeSort: f,
3797
+ onChangeData: de,
3798
+ onChangeSort: _,
2057
3799
  onChangeSortModel: (e) => {
2058
- ee(e), p?.(e);
3800
+ oe(e), v?.(e);
2059
3801
  },
2060
3802
  onLazyLoad: void 0,
2061
3803
  onLoadMore: void 0,
2062
3804
  pagination: {
2063
3805
  pageIndex: 0,
2064
- pageSize: Math.max(1, C.length)
3806
+ pageSize: Math.max(1, T.length)
2065
3807
  },
2066
3808
  rowProps: {
2067
- ...g,
3809
+ ...ee,
2068
3810
  draggable: !1
2069
3811
  },
2070
- tree: !1,
2071
- ref: y,
2072
- treeContext: te
3812
+ tree: !1
3813
+ };
3814
+ return /* @__PURE__ */ A(rr, {
3815
+ ...fe,
3816
+ ref: ie,
3817
+ treeContext: ue
2073
3818
  });
2074
3819
  }
2075
- var Lt = Te(Ft), Rt = Te(It);
2076
- function zt(e, t) {
2077
- return e.tree ? /* @__PURE__ */ M(Rt, {
3820
+ var rr = ke(tr), ir = ke(nr);
3821
+ function ar(e, t) {
3822
+ return e.tree ? /* @__PURE__ */ A(ir, {
2078
3823
  ...e,
2079
3824
  ref: t
2080
- }) : /* @__PURE__ */ M(Lt, {
3825
+ }) : /* @__PURE__ */ A(rr, {
2081
3826
  ...e,
2082
3827
  ref: t
2083
3828
  });
2084
3829
  }
2085
- var Bt = Te(zt), Vt = "comins-table";
3830
+ var or = ke(ar), sr = "comins-table";
2086
3831
  //#endregion
2087
- export { Bt as CominsTable, e as addCominsRows, t as applyCominsColumnLayout, n as clearCominsCellRange, r as clearCominsSelection, i as clearCominsSortState, Vt as cominsTablePackage, a as copyCominsCell, o as copyCominsCellRange, s as copyCominsRow, c as createCominsTableState, l as deleteCominsRows, u as exportCominsRowsToCsv, d as exportCominsRowsToJson, f as fillCominsCellRange, Ke as flattenCominsTree, p as formatCominsCellValue, m as getCominsCellClassName, h as getCominsCellStyle, g as getCominsCellValue, _ as getCominsHeaderRows, v as getCominsPageRows, y as getCominsSelectedCellRange, b as getCominsSortedRowIndexes, Ue as getCominsSummaryValues, H as getCominsTreeLeafItems, x as getCominsVirtualRows, ee as getCominsVisibleColumns, S as isCominsCellDisabled, C as isCominsCellInSelectedRange, w as isCominsCellSelected, te as isCominsRowSelected, ne as moveCominsColumn, re as moveCominsColumnGroup, ie as moveCominsRow, ae as pasteCominsCell, T as pasteCominsCellRange, oe as pasteCominsRow, se as queryCominsRows, ce as replaceCominsRows, le as selectCell, ue as selectCellRange, E as selectRow, de as selectRows, fe as serializeCominsColumnLayout, pe as setCominsColumnGroupHidden, me as setCominsColumnGroupWidth, he as setCominsColumnHidden, D as setCominsColumnWidth, ge as setCominsHeaderVisible, _e as setCominsPagination, ve as setCominsSortModel, ye as setCominsSortState, be as setCominsTableTheme, xe as sortCominsRows, W as sortCominsTreeSiblings, qe as toggleCominsTreeNode, Se as updateCominsRows, U as updateCominsTreeItem };
3832
+ export { or as CominsTable, e as addCominsRows, t as applyCominsColumnLayout, n as clearCominsCellRange, r as clearCominsSelection, i as clearCominsSortState, sr as cominsTablePackage, a as copyCominsCell, o as copyCominsCellRange, s as copyCominsRow, c as createCominsTableState, l as deleteCominsRows, u as exportCominsRowsToCsv, d as exportCominsRowsToJson, f as fillCominsCellRange, zt as flattenCominsTree, p as formatCominsCellValue, m as getCominsCellClassName, h as getCominsCellStyle, g as getCominsCellValue, _ as getCominsHeaderRows, v as getCominsPageRows, y as getCominsSelectedCellRange, b as getCominsSortedRowIndexes, Ft as getCominsSummaryValues, V as getCominsTreeLeafItems, x as getCominsVirtualRows, ee as getCominsVisibleColumns, te as isCominsCellDisabled, ne as isCominsCellInSelectedRange, re as isCominsCellSelected, S as isCominsRowSelected, ie as moveCominsColumn, C as moveCominsColumnGroup, ae as moveCominsRow, jt as moveCominsRowGroup, oe as moveCominsRowToGroup, w as pasteCominsCell, se as pasteCominsCellRange, ce as pasteCominsRow, T as queryCominsRows, le as replaceCominsRows, ue as selectCell, de as selectCellRange, fe as selectRow, pe as selectRows, me as serializeCominsColumnLayout, he as setCominsColumnGroupHidden, ge as setCominsColumnGroupWidth, _e as setCominsColumnHidden, ve as setCominsColumnWidth, ye as setCominsHeaderVisible, be as setCominsPagination, xe as setCominsSortModel, Se as setCominsSortState, Ce as setCominsTableTheme, we as sortCominsRows, Ht as sortCominsTreeSiblings, Bt as toggleCominsTreeNode, Te as updateCominsRows, Vt as updateCominsTreeItem };
2088
3833
 
2089
3834
  //# sourceMappingURL=index.js.map