comins-table 0.1.1
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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +219 -0
- package/dist/clipboard.d.ts +3 -0
- package/dist/clipboard.d.ts.map +1 -0
- package/dist/clipboard.js +2 -0
- package/dist/component-renderer.d.ts +5 -0
- package/dist/component-renderer.d.ts.map +1 -0
- package/dist/core.d.ts +680 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +691 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1959 -0
- package/dist/index.js.map +1 -0
- package/dist/selection.d.ts +3 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +2 -0
- package/dist/summary.d.ts +14 -0
- package/dist/summary.d.ts.map +1 -0
- package/dist/tree.d.ts +20 -0
- package/dist/tree.d.ts.map +1 -0
- package/package.json +75 -0
- package/styles.css +1059 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1959 @@
|
|
|
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 S, isCominsCellDisabled as ee, isCominsCellInSelectedRange as C, isCominsCellSelected as te, isCominsRowSelected as ne, moveCominsColumn as re, moveCominsColumnGroup as w, moveCominsRow as T, pasteCominsCell as ie, pasteCominsCellRange as ae, 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, setCominsSortState as ve, setCominsTableTheme as ye, sortCominsRows as be, updateCominsRows as xe } from "./core.js";
|
|
2
|
+
import { Fragment as Se, createContext as Ce, createElement as we, forwardRef as O, useContext as Te, useEffect as k, useId as Ee, useImperativeHandle as De, useLayoutEffect as Oe, useMemo as A, useRef as j, useState as M } from "react";
|
|
3
|
+
import { jsx as N, jsxs as P } from "react/jsx-runtime";
|
|
4
|
+
//#region node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
|
|
5
|
+
var ke = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), Ae = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), je = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), Me = (e) => {
|
|
6
|
+
let t = je(e);
|
|
7
|
+
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
8
|
+
}, F = {
|
|
9
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
10
|
+
width: 24,
|
|
11
|
+
height: 24,
|
|
12
|
+
viewBox: "0 0 24 24",
|
|
13
|
+
fill: "none",
|
|
14
|
+
stroke: "currentColor",
|
|
15
|
+
strokeWidth: 2,
|
|
16
|
+
strokeLinecap: "round",
|
|
17
|
+
strokeLinejoin: "round"
|
|
18
|
+
}, Ne = (e) => {
|
|
19
|
+
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
20
|
+
return !1;
|
|
21
|
+
}, I = Ce({}), Pe = () => Te(I), Fe = O(({ color: e, size: t, strokeWidth: n, absoluteStrokeWidth: r, className: i = "", children: a, iconNode: o, ...s }, c) => {
|
|
22
|
+
let { size: l = 24, strokeWidth: u = 2, absoluteStrokeWidth: d = !1, color: f = "currentColor", className: p = "" } = Pe() ?? {}, m = r ?? d ? Number(n ?? u) * 24 / Number(t ?? l) : n ?? u;
|
|
23
|
+
return we("svg", {
|
|
24
|
+
ref: c,
|
|
25
|
+
...F,
|
|
26
|
+
width: t ?? l ?? F.width,
|
|
27
|
+
height: t ?? l ?? F.height,
|
|
28
|
+
stroke: e ?? f,
|
|
29
|
+
strokeWidth: m,
|
|
30
|
+
className: ke("lucide", p, i),
|
|
31
|
+
...!a && !Ne(s) && { "aria-hidden": "true" },
|
|
32
|
+
...s
|
|
33
|
+
}, [...o.map(([e, t]) => we(e, t)), ...Array.isArray(a) ? a : [a]]);
|
|
34
|
+
}), Ie = ((e, t) => {
|
|
35
|
+
let n = O(({ className: n, ...r }, i) => we(Fe, {
|
|
36
|
+
ref: i,
|
|
37
|
+
iconNode: t,
|
|
38
|
+
className: ke(`lucide-${Ae(Me(e))}`, `lucide-${e}`, n),
|
|
39
|
+
...r
|
|
40
|
+
}));
|
|
41
|
+
return n.displayName = Me(e), n;
|
|
42
|
+
})("arrow-up", [["path", {
|
|
43
|
+
d: "m5 12 7-7 7 7",
|
|
44
|
+
key: "hav0vg"
|
|
45
|
+
}], ["path", {
|
|
46
|
+
d: "M12 19V5",
|
|
47
|
+
key: "x0mq9r"
|
|
48
|
+
}]]);
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/component-renderer.tsx
|
|
51
|
+
function L(...e) {
|
|
52
|
+
return e.filter(Boolean).join(" ");
|
|
53
|
+
}
|
|
54
|
+
function R(e, t) {
|
|
55
|
+
return typeof e == "function" ? e(t) : e ?? {};
|
|
56
|
+
}
|
|
57
|
+
function Le(e, t) {
|
|
58
|
+
return typeof e == "function" ? e(t) : e;
|
|
59
|
+
}
|
|
60
|
+
function Re(e, t) {
|
|
61
|
+
return typeof e == "function" ? e(t) : e;
|
|
62
|
+
}
|
|
63
|
+
function z(e, t) {
|
|
64
|
+
return typeof e == "function" ? e(t) : e;
|
|
65
|
+
}
|
|
66
|
+
function B(e) {
|
|
67
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? e.map(B).join(" ") : "";
|
|
68
|
+
}
|
|
69
|
+
function ze(e) {
|
|
70
|
+
return e.type !== "divider" && e.type !== "label";
|
|
71
|
+
}
|
|
72
|
+
function Be(e, t) {
|
|
73
|
+
return !!(e && t instanceof Node && e.contains(t));
|
|
74
|
+
}
|
|
75
|
+
function V(e) {
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
}
|
|
78
|
+
function H(e) {
|
|
79
|
+
e.preventDefault(), e.stopPropagation();
|
|
80
|
+
}
|
|
81
|
+
function Ve(e) {
|
|
82
|
+
return e == null ? "" : String(e);
|
|
83
|
+
}
|
|
84
|
+
function He({ component: e, payload: t }) {
|
|
85
|
+
let n = R(e.props, t), { defaultValue: r, onBlur: i, onChange: a, onClick: o, onKeyDown: s, onMouseDown: c, onPointerDown: l, value: u, ...d } = n, f = Ve(u ?? r), [p, m] = M(f), h = j(f);
|
|
86
|
+
k(() => {
|
|
87
|
+
m(f), h.current = f;
|
|
88
|
+
}, [f]);
|
|
89
|
+
let g = (n) => {
|
|
90
|
+
p !== h.current && (h.current = p, e.onChange?.({
|
|
91
|
+
...t,
|
|
92
|
+
event: n,
|
|
93
|
+
value: p
|
|
94
|
+
}), e.onValueChange?.({
|
|
95
|
+
...t,
|
|
96
|
+
value: p
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
return /* @__PURE__ */ N("input", {
|
|
100
|
+
...d,
|
|
101
|
+
className: L("comins-table__component", "comins-table__component-input", n.className),
|
|
102
|
+
onBlur: (e) => {
|
|
103
|
+
i?.(e), V(e), g(e);
|
|
104
|
+
},
|
|
105
|
+
onChange: (e) => {
|
|
106
|
+
V(e), m(e.currentTarget.value);
|
|
107
|
+
},
|
|
108
|
+
onClick: (e) => {
|
|
109
|
+
o?.(e), V(e);
|
|
110
|
+
},
|
|
111
|
+
onKeyDown: (e) => {
|
|
112
|
+
s?.(e), V(e), e.key === "Enter" && (e.preventDefault(), g(e), e.currentTarget.blur());
|
|
113
|
+
},
|
|
114
|
+
onMouseDown: (e) => {
|
|
115
|
+
c?.(e), V(e);
|
|
116
|
+
},
|
|
117
|
+
onPointerDown: (e) => {
|
|
118
|
+
l?.(e), V(e);
|
|
119
|
+
},
|
|
120
|
+
value: p
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function Ue({ component: e, payload: t }) {
|
|
124
|
+
let n = R(e.props, t), { checked: r, defaultChecked: i, onChange: a, onClick: o, onKeyDown: s, onMouseDown: c, onPointerDown: l, style: u, ...d } = n, [f, p] = M(!!(r ?? i));
|
|
125
|
+
return k(() => {
|
|
126
|
+
r !== void 0 && p(!!r);
|
|
127
|
+
}, [r]), /* @__PURE__ */ N("input", {
|
|
128
|
+
...d,
|
|
129
|
+
checked: f,
|
|
130
|
+
className: L("comins-table__component", "comins-table__component-checkbox", n.className),
|
|
131
|
+
onClick: (e) => {
|
|
132
|
+
o?.(e), V(e);
|
|
133
|
+
},
|
|
134
|
+
onChange: (n) => {
|
|
135
|
+
a?.(n), V(n), p(n.currentTarget.checked), e.onCheckedChange?.({
|
|
136
|
+
...t,
|
|
137
|
+
checked: n.currentTarget.checked
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
onKeyDown: (e) => {
|
|
141
|
+
s?.(e), V(e);
|
|
142
|
+
},
|
|
143
|
+
onMouseDown: (e) => {
|
|
144
|
+
c?.(e), V(e);
|
|
145
|
+
},
|
|
146
|
+
onPointerDown: (e) => {
|
|
147
|
+
l?.(e), V(e);
|
|
148
|
+
},
|
|
149
|
+
style: {
|
|
150
|
+
height: 20,
|
|
151
|
+
width: 20,
|
|
152
|
+
...u
|
|
153
|
+
},
|
|
154
|
+
type: "checkbox"
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function U({ component: e, payload: t }) {
|
|
158
|
+
let { checked: n, ...r } = R(e.props, t), { onClick: i, onKeyDown: a, onMouseDown: o, onPointerDown: s, ...c } = r, [l, u] = M(!!n);
|
|
159
|
+
k(() => {
|
|
160
|
+
n !== void 0 && u(!!n);
|
|
161
|
+
}, [n]);
|
|
162
|
+
let d = typeof r.children == "string" && (r.children === "ON" || r.children === "OFF") ? l ? "ON" : "OFF" : r.children;
|
|
163
|
+
return /* @__PURE__ */ N("button", {
|
|
164
|
+
...c,
|
|
165
|
+
"aria-pressed": l,
|
|
166
|
+
className: L("comins-table__component", "comins-table__component-toggle", r.className),
|
|
167
|
+
onClick: (n) => {
|
|
168
|
+
i?.(n), V(n);
|
|
169
|
+
let r = !l;
|
|
170
|
+
u(r), e.onCheckedChange?.({
|
|
171
|
+
...t,
|
|
172
|
+
checked: r
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
onKeyDown: (e) => {
|
|
176
|
+
a?.(e), V(e);
|
|
177
|
+
},
|
|
178
|
+
onMouseDown: (e) => {
|
|
179
|
+
o?.(e), V(e);
|
|
180
|
+
},
|
|
181
|
+
onPointerDown: (e) => {
|
|
182
|
+
s?.(e), V(e);
|
|
183
|
+
},
|
|
184
|
+
type: r.type ?? "button",
|
|
185
|
+
children: d
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
function We({ component: e, payload: t }) {
|
|
189
|
+
let [n, r] = M(!1), i = Ee(), a = j(null), o = j(null), [s, c] = M({
|
|
190
|
+
left: 0,
|
|
191
|
+
position: "fixed",
|
|
192
|
+
top: 0
|
|
193
|
+
}), l = R(e.props, t), u = A(() => Re(e.items, t), [e.items, t]), d = () => {
|
|
194
|
+
let e = a.current;
|
|
195
|
+
if (!e || typeof window > "u") return;
|
|
196
|
+
let t = e.getBoundingClientRect(), n = Math.max(o.current?.offsetWidth ?? 136, 136);
|
|
197
|
+
c({
|
|
198
|
+
left: Math.max(8, Math.min(t.left, window.innerWidth - n - 8)),
|
|
199
|
+
position: "fixed",
|
|
200
|
+
top: Math.min(t.bottom + 4, window.innerHeight - 8),
|
|
201
|
+
zIndex: 9999
|
|
202
|
+
});
|
|
203
|
+
}, f = (i, a) => {
|
|
204
|
+
i !== n && e.onBeforeChange?.({
|
|
205
|
+
...t,
|
|
206
|
+
event: a,
|
|
207
|
+
open: i
|
|
208
|
+
}) !== !1 && (r(i), e.onOpenChange?.({
|
|
209
|
+
...t,
|
|
210
|
+
event: a,
|
|
211
|
+
open: i
|
|
212
|
+
}));
|
|
213
|
+
};
|
|
214
|
+
k(() => {
|
|
215
|
+
if (!n) return;
|
|
216
|
+
let e = (e) => {
|
|
217
|
+
Be(a.current, e.target) || Be(o.current, e.target) || f(!1, e);
|
|
218
|
+
}, t = (e) => {
|
|
219
|
+
e.key === "Escape" && (f(!1, e), a.current?.focus());
|
|
220
|
+
};
|
|
221
|
+
return document.addEventListener("pointerdown", e), document.addEventListener("keydown", t), () => {
|
|
222
|
+
document.removeEventListener("pointerdown", e), document.removeEventListener("keydown", t);
|
|
223
|
+
};
|
|
224
|
+
}, [n]), Oe(() => {
|
|
225
|
+
if (n && (d(), !(typeof window > "u"))) return window.addEventListener("resize", d), window.addEventListener("scroll", d, !0), () => {
|
|
226
|
+
window.removeEventListener("resize", d), window.removeEventListener("scroll", d, !0);
|
|
227
|
+
};
|
|
228
|
+
}, [n]);
|
|
229
|
+
let p = n ? /* @__PURE__ */ N("span", {
|
|
230
|
+
"aria-label": "Header menu",
|
|
231
|
+
className: "comins-table__component-menu-popover",
|
|
232
|
+
id: i,
|
|
233
|
+
ref: o,
|
|
234
|
+
role: "menu",
|
|
235
|
+
style: s,
|
|
236
|
+
children: u.map((n, r) => n.type === "divider" ? /* @__PURE__ */ N("span", {
|
|
237
|
+
"aria-orientation": "horizontal",
|
|
238
|
+
className: "comins-table__component-menu-divider",
|
|
239
|
+
role: "separator"
|
|
240
|
+
}, `divider-${r}`) : n.type === "label" ? /* @__PURE__ */ N("span", {
|
|
241
|
+
className: "comins-table__component-menu-label",
|
|
242
|
+
role: "presentation",
|
|
243
|
+
children: n.label
|
|
244
|
+
}, `label-${r}`) : /* @__PURE__ */ N("button", {
|
|
245
|
+
className: "comins-table__component-menu-item",
|
|
246
|
+
disabled: n.disabled,
|
|
247
|
+
onClick: (r) => {
|
|
248
|
+
H(r), !(n.disabled || !ze(n)) && (f(!1, r), e.onSelect?.({
|
|
249
|
+
...t,
|
|
250
|
+
event: r,
|
|
251
|
+
item: n,
|
|
252
|
+
value: n.value
|
|
253
|
+
}));
|
|
254
|
+
},
|
|
255
|
+
onKeyDown: V,
|
|
256
|
+
onMouseDown: V,
|
|
257
|
+
onPointerDown: V,
|
|
258
|
+
role: "menuitem",
|
|
259
|
+
type: "button",
|
|
260
|
+
children: n.label
|
|
261
|
+
}, `${String(n.value)}-${r}`))
|
|
262
|
+
}) : null;
|
|
263
|
+
return /* @__PURE__ */ P("span", {
|
|
264
|
+
className: "comins-table__component comins-table__component-menu",
|
|
265
|
+
children: [/* @__PURE__ */ N("button", {
|
|
266
|
+
...l,
|
|
267
|
+
"aria-controls": n ? i : void 0,
|
|
268
|
+
"aria-expanded": n,
|
|
269
|
+
"aria-haspopup": "menu",
|
|
270
|
+
"aria-label": l["aria-label"] ?? "Header menu",
|
|
271
|
+
className: L("comins-table__component-menu-trigger", l.className),
|
|
272
|
+
onClick: (e) => {
|
|
273
|
+
H(e), f(!n, e);
|
|
274
|
+
},
|
|
275
|
+
onKeyDown: (e) => {
|
|
276
|
+
if (l.onKeyDown?.(e), e.key === "Escape" && n) {
|
|
277
|
+
H(e), f(!1, e);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
V(e);
|
|
281
|
+
},
|
|
282
|
+
onMouseDown: V,
|
|
283
|
+
onPointerDown: (e) => {
|
|
284
|
+
l.onPointerDown?.(e), V(e);
|
|
285
|
+
},
|
|
286
|
+
ref: a,
|
|
287
|
+
type: l.type ?? "button",
|
|
288
|
+
children: l.children ?? "메뉴"
|
|
289
|
+
}), p]
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function Ge({ component: e, payload: t }) {
|
|
293
|
+
let { height: n, itemHeight: r, limit: i, more: a = !1, searchable: o = !1, style: s, ...c } = R(e.props, t), l = A(() => z(e.items, t), [e.items, t]), u = Math.max(1, Number(i ?? 5)), d = Math.max(1, Number(r ?? 28)), f = d * 5, p = n !== void 0 || s?.height !== void 0, [m, h] = M(""), [g, _] = M(!1), [v, y] = M(0), [b, x] = M(null), [S, ee] = M(f), C = j(null), te = t.row.selected && t.selection.selectedRowCount === 1, ne = !!(o && te), re = !!(a && te), w = ne ? m : "";
|
|
294
|
+
k(() => {
|
|
295
|
+
_(!1), y(0);
|
|
296
|
+
}, [l.length, u]), Oe(() => {
|
|
297
|
+
let e = C.current;
|
|
298
|
+
if (!e) return;
|
|
299
|
+
let t = e.clientHeight > 0 ? e.clientHeight : f;
|
|
300
|
+
ee(p ? t : Math.min(t, f));
|
|
301
|
+
}, [
|
|
302
|
+
f,
|
|
303
|
+
g,
|
|
304
|
+
w,
|
|
305
|
+
p
|
|
306
|
+
]), k(() => {
|
|
307
|
+
let e = C.current;
|
|
308
|
+
e && (e.scrollTop = 0, y(0));
|
|
309
|
+
}, [w]), k(() => {
|
|
310
|
+
if (te) return;
|
|
311
|
+
let e = C.current;
|
|
312
|
+
e && (e.scrollTop = 0), _(!1), h(""), y(0);
|
|
313
|
+
}, [te]);
|
|
314
|
+
let T = A(() => {
|
|
315
|
+
let t = w.trim().toLowerCase();
|
|
316
|
+
return l.map((e, t) => ({
|
|
317
|
+
item: e,
|
|
318
|
+
itemIndex: t
|
|
319
|
+
})).filter(({ item: n, itemIndex: r }) => t ? e.searchFilter ? e.searchFilter({
|
|
320
|
+
item: n,
|
|
321
|
+
itemIndex: r,
|
|
322
|
+
value: w
|
|
323
|
+
}) : B(n.label).toLowerCase().includes(t) : !0);
|
|
324
|
+
}, [
|
|
325
|
+
w,
|
|
326
|
+
e,
|
|
327
|
+
l
|
|
328
|
+
]), ie = T.length > u, ae = !!(te && (g || w.trim().length > 0 || !a && ie)), oe = ie && !ae, se = ne && !g ? 0 : 2, ce = Math.max(d, p ? S || f : Math.min(S || f, f)), le = Math.max(0, Math.floor(Math.max(0, v) / d) - se), ue = Math.min(T.length, Math.ceil((Math.max(0, v) + ce) / d) + se), E = ae ? T.slice(le, ue) : T.slice(0, ie ? u : T.length), de = ae ? le * d : 0, fe = ae ? Math.max(0, T.length - ue) * d : 0, pe = `${String(t.row.id)}-${t.column.id}`, me = {
|
|
329
|
+
...s,
|
|
330
|
+
"--comins-table-virtual-list-item-height": `${d}px`,
|
|
331
|
+
height: n ?? s?.height ?? f
|
|
332
|
+
}, he = (n, r, i) => {
|
|
333
|
+
n.disabled || (x(n.value), e.onClickItem?.({
|
|
334
|
+
...t,
|
|
335
|
+
event: i,
|
|
336
|
+
item: n,
|
|
337
|
+
itemIndex: r,
|
|
338
|
+
value: n.value
|
|
339
|
+
}));
|
|
340
|
+
};
|
|
341
|
+
return /* @__PURE__ */ P("div", {
|
|
342
|
+
...c,
|
|
343
|
+
"aria-label": c["aria-label"] ?? "Virtual list",
|
|
344
|
+
className: L("comins-table__component", "comins-table__component-virtual-list", c.className),
|
|
345
|
+
"data-comins-virtual-list-expanded": ae ? "true" : void 0,
|
|
346
|
+
"data-comins-virtual-list-visible-count": E.length,
|
|
347
|
+
"data-testid": `virtual-list-${pe}`,
|
|
348
|
+
onClick: (e) => {
|
|
349
|
+
c.onClick?.(e), V(e);
|
|
350
|
+
},
|
|
351
|
+
onKeyDown: V,
|
|
352
|
+
onMouseDown: V,
|
|
353
|
+
onContextMenu: V,
|
|
354
|
+
onDoubleClick: V,
|
|
355
|
+
onMouseUp: V,
|
|
356
|
+
onPointerUp: V,
|
|
357
|
+
onPointerMove: V,
|
|
358
|
+
onPointerEnter: V,
|
|
359
|
+
onMouseOver: V,
|
|
360
|
+
onMouseOut: V,
|
|
361
|
+
onPointerLeave: V,
|
|
362
|
+
onBlur: V,
|
|
363
|
+
onFocus: V,
|
|
364
|
+
onInput: V,
|
|
365
|
+
onChange: V,
|
|
366
|
+
onMouseMove: V,
|
|
367
|
+
onMouseEnter: V,
|
|
368
|
+
onMouseLeave: V,
|
|
369
|
+
onTouchStart: V,
|
|
370
|
+
onTouchMove: V,
|
|
371
|
+
onTouchEnd: V,
|
|
372
|
+
onWheel: (e) => {
|
|
373
|
+
c.onWheel?.(e), V(e);
|
|
374
|
+
},
|
|
375
|
+
onPointerDown: (e) => {
|
|
376
|
+
c.onPointerDown?.(e), V(e);
|
|
377
|
+
},
|
|
378
|
+
role: "listbox",
|
|
379
|
+
style: me,
|
|
380
|
+
children: [/* @__PURE__ */ P("div", {
|
|
381
|
+
className: "comins-table__component-virtual-list-items",
|
|
382
|
+
onScroll: (e) => {
|
|
383
|
+
V(e), y(e.currentTarget.scrollTop);
|
|
384
|
+
let t = e.currentTarget.clientHeight > 0 ? e.currentTarget.clientHeight : f;
|
|
385
|
+
ee(p ? t : Math.min(t, f));
|
|
386
|
+
},
|
|
387
|
+
ref: C,
|
|
388
|
+
role: "presentation",
|
|
389
|
+
children: [
|
|
390
|
+
de > 0 ? /* @__PURE__ */ N("span", {
|
|
391
|
+
"aria-hidden": "true",
|
|
392
|
+
className: "comins-table__component-virtual-list-spacer",
|
|
393
|
+
style: { height: de }
|
|
394
|
+
}) : null,
|
|
395
|
+
E.map(({ item: n, itemIndex: r }) => /* @__PURE__ */ N("button", {
|
|
396
|
+
"aria-selected": b === n.value,
|
|
397
|
+
className: "comins-table__component-virtual-list-item",
|
|
398
|
+
"data-comins-virtual-list-item": "true",
|
|
399
|
+
disabled: n.disabled,
|
|
400
|
+
onClick: (e) => {
|
|
401
|
+
H(e), he(n, r, e);
|
|
402
|
+
},
|
|
403
|
+
onContextMenu: (i) => {
|
|
404
|
+
V(i), !n.disabled && e.onContextMenuItem?.({
|
|
405
|
+
...t,
|
|
406
|
+
event: i,
|
|
407
|
+
item: n,
|
|
408
|
+
itemIndex: r,
|
|
409
|
+
value: n.value
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
onKeyDown: (e) => {
|
|
413
|
+
V(e), (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), he(n, r, e));
|
|
414
|
+
},
|
|
415
|
+
onMouseDown: V,
|
|
416
|
+
onPointerDown: V,
|
|
417
|
+
role: "option",
|
|
418
|
+
type: "button",
|
|
419
|
+
children: /* @__PURE__ */ N("span", {
|
|
420
|
+
className: "comins-table__component-virtual-list-item-label",
|
|
421
|
+
children: n.label
|
|
422
|
+
})
|
|
423
|
+
}, `${String(n.value)}-${r}`)),
|
|
424
|
+
fe > 0 ? /* @__PURE__ */ N("span", {
|
|
425
|
+
"aria-hidden": "true",
|
|
426
|
+
className: "comins-table__component-virtual-list-spacer",
|
|
427
|
+
style: { height: fe }
|
|
428
|
+
}) : null
|
|
429
|
+
]
|
|
430
|
+
}), /* @__PURE__ */ P("div", {
|
|
431
|
+
className: "comins-table__component-virtual-list-controls",
|
|
432
|
+
children: [oe ? re ? /* @__PURE__ */ N("button", {
|
|
433
|
+
"aria-label": "전체 목록 보기",
|
|
434
|
+
className: "comins-table__component-virtual-list-overflow comins-table__component-virtual-list-more",
|
|
435
|
+
"data-testid": `virtual-list-overflow-${pe}`,
|
|
436
|
+
onClick: (e) => {
|
|
437
|
+
H(e), _(!0);
|
|
438
|
+
},
|
|
439
|
+
onKeyDown: V,
|
|
440
|
+
onMouseDown: V,
|
|
441
|
+
onPointerDown: V,
|
|
442
|
+
type: "button",
|
|
443
|
+
children: "..."
|
|
444
|
+
}) : /* @__PURE__ */ N("span", {
|
|
445
|
+
"aria-hidden": "true",
|
|
446
|
+
className: "comins-table__component-virtual-list-overflow comins-table__component-virtual-list-more",
|
|
447
|
+
"data-testid": `virtual-list-overflow-${pe}`,
|
|
448
|
+
children: "..."
|
|
449
|
+
}) : null, ne ? /* @__PURE__ */ N("input", {
|
|
450
|
+
"aria-label": `${c["aria-label"] ?? "Virtual list"} 검색`,
|
|
451
|
+
className: "comins-table__component-virtual-list-search",
|
|
452
|
+
"data-testid": `virtual-list-search-${pe}`,
|
|
453
|
+
onChange: (e) => {
|
|
454
|
+
V(e), h(e.currentTarget.value);
|
|
455
|
+
},
|
|
456
|
+
onClick: V,
|
|
457
|
+
onKeyDown: V,
|
|
458
|
+
onMouseDown: V,
|
|
459
|
+
onPointerDown: V,
|
|
460
|
+
placeholder: "검색",
|
|
461
|
+
value: m
|
|
462
|
+
}) : null]
|
|
463
|
+
})]
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
function Ke(e, t) {
|
|
467
|
+
if (e.type === "menu") return /* @__PURE__ */ N(We, {
|
|
468
|
+
component: e,
|
|
469
|
+
payload: t
|
|
470
|
+
});
|
|
471
|
+
if (e.type === "virtual-list") return /* @__PURE__ */ N(Ge, {
|
|
472
|
+
component: e,
|
|
473
|
+
payload: t
|
|
474
|
+
});
|
|
475
|
+
if (e.type === "button") {
|
|
476
|
+
let n = R(e.props, t), { onClick: r, onKeyDown: i, onMouseDown: a, onPointerDown: o, ...s } = n;
|
|
477
|
+
return /* @__PURE__ */ N("button", {
|
|
478
|
+
...s,
|
|
479
|
+
className: L("comins-table__component", "comins-table__component-button", n.className),
|
|
480
|
+
onClick: (n) => {
|
|
481
|
+
r?.(n), V(n), e.onClick?.({
|
|
482
|
+
...t,
|
|
483
|
+
event: n
|
|
484
|
+
});
|
|
485
|
+
},
|
|
486
|
+
onKeyDown: (e) => {
|
|
487
|
+
i?.(e), V(e);
|
|
488
|
+
},
|
|
489
|
+
onMouseDown: (e) => {
|
|
490
|
+
a?.(e), V(e);
|
|
491
|
+
},
|
|
492
|
+
onPointerDown: (e) => {
|
|
493
|
+
o?.(e), V(e);
|
|
494
|
+
},
|
|
495
|
+
type: n.type ?? "button"
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
if (e.type === "input") return /* @__PURE__ */ N(He, {
|
|
499
|
+
component: e,
|
|
500
|
+
payload: t
|
|
501
|
+
});
|
|
502
|
+
if (e.type === "checkbox") return /* @__PURE__ */ N(Ue, {
|
|
503
|
+
component: e,
|
|
504
|
+
payload: t
|
|
505
|
+
});
|
|
506
|
+
if (e.type === "select") {
|
|
507
|
+
let n = R(e.props, t), r = Le(e.options, t), { onChange: i, onClick: a, onKeyDown: o, onMouseDown: s, onPointerDown: c, ...l } = n;
|
|
508
|
+
return /* @__PURE__ */ N("select", {
|
|
509
|
+
...l,
|
|
510
|
+
className: L("comins-table__component", "comins-table__component-select", n.className),
|
|
511
|
+
onClick: (e) => {
|
|
512
|
+
a?.(e), V(e);
|
|
513
|
+
},
|
|
514
|
+
onChange: (n) => {
|
|
515
|
+
i?.(n), V(n), e.onValueChange?.({
|
|
516
|
+
...t,
|
|
517
|
+
value: n.currentTarget.value
|
|
518
|
+
});
|
|
519
|
+
},
|
|
520
|
+
onKeyDown: (e) => {
|
|
521
|
+
o?.(e), V(e);
|
|
522
|
+
},
|
|
523
|
+
onMouseDown: (e) => {
|
|
524
|
+
s?.(e), V(e);
|
|
525
|
+
},
|
|
526
|
+
onPointerDown: (e) => {
|
|
527
|
+
c?.(e), V(e);
|
|
528
|
+
},
|
|
529
|
+
children: r.map((e) => /* @__PURE__ */ N("option", {
|
|
530
|
+
disabled: e.disabled,
|
|
531
|
+
value: String(e.value),
|
|
532
|
+
children: e.label
|
|
533
|
+
}, String(e.value)))
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
if (e.type === "radio") {
|
|
537
|
+
let n = R(e.props, t), r = Le(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;
|
|
538
|
+
return /* @__PURE__ */ N("div", {
|
|
539
|
+
...s,
|
|
540
|
+
className: L("comins-table__component", "comins-table__component-radio", s.className),
|
|
541
|
+
onClick: (e) => {
|
|
542
|
+
s.onClick?.(e), V(e);
|
|
543
|
+
},
|
|
544
|
+
onKeyDown: (e) => {
|
|
545
|
+
s.onKeyDown?.(e), V(e);
|
|
546
|
+
},
|
|
547
|
+
onMouseDown: (e) => {
|
|
548
|
+
s.onMouseDown?.(e), V(e);
|
|
549
|
+
},
|
|
550
|
+
onPointerDown: (e) => {
|
|
551
|
+
s.onPointerDown?.(e), V(e);
|
|
552
|
+
},
|
|
553
|
+
role: "radiogroup",
|
|
554
|
+
children: r.map((n) => /* @__PURE__ */ P("label", {
|
|
555
|
+
onClick: V,
|
|
556
|
+
onMouseDown: V,
|
|
557
|
+
children: [/* @__PURE__ */ N("input", {
|
|
558
|
+
checked: i === void 0 ? void 0 : String(i) === String(n.value),
|
|
559
|
+
disabled: n.disabled,
|
|
560
|
+
name: a,
|
|
561
|
+
onClick: V,
|
|
562
|
+
onChange: (r) => {
|
|
563
|
+
V(r), r.currentTarget.checked && e.onValueChange?.({
|
|
564
|
+
...t,
|
|
565
|
+
value: String(n.value)
|
|
566
|
+
});
|
|
567
|
+
},
|
|
568
|
+
onKeyDown: V,
|
|
569
|
+
onMouseDown: V,
|
|
570
|
+
onPointerDown: V,
|
|
571
|
+
style: {
|
|
572
|
+
height: 20,
|
|
573
|
+
width: 20
|
|
574
|
+
},
|
|
575
|
+
type: "radio",
|
|
576
|
+
value: String(n.value)
|
|
577
|
+
}), n.label]
|
|
578
|
+
}, String(n.value)))
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
if (e.type === "toggle") return /* @__PURE__ */ N(U, {
|
|
582
|
+
component: e,
|
|
583
|
+
payload: t
|
|
584
|
+
});
|
|
585
|
+
let n = R(e.props, t), r = Number(n.value ?? 0), i = Math.max(1, Number(n.max ?? 100)), a = Math.max(0, Math.min(100, r / i * 100));
|
|
586
|
+
return /* @__PURE__ */ N("div", {
|
|
587
|
+
...n,
|
|
588
|
+
"aria-valuemax": i,
|
|
589
|
+
"aria-valuemin": 0,
|
|
590
|
+
"aria-valuenow": r,
|
|
591
|
+
className: L("comins-table__component", "comins-table__component-progress", n.className),
|
|
592
|
+
onClick: V,
|
|
593
|
+
onKeyDown: V,
|
|
594
|
+
onMouseDown: V,
|
|
595
|
+
onPointerDown: V,
|
|
596
|
+
role: "progressbar",
|
|
597
|
+
children: /* @__PURE__ */ N("span", { style: { width: `${a}%` } })
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/summary.ts
|
|
602
|
+
function qe(e, t) {
|
|
603
|
+
return t.split(".").reduce((e, t) => {
|
|
604
|
+
if (!(typeof e != "object" || !e)) return e[t];
|
|
605
|
+
}, e);
|
|
606
|
+
}
|
|
607
|
+
function Je(e) {
|
|
608
|
+
return e.filter((e) => typeof e == "number" && Number.isFinite(e));
|
|
609
|
+
}
|
|
610
|
+
function Ye(e, t) {
|
|
611
|
+
if (e === "count") return t.length;
|
|
612
|
+
let n = Je(t);
|
|
613
|
+
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);
|
|
614
|
+
}
|
|
615
|
+
function Xe(e, t, n) {
|
|
616
|
+
return Object.entries(n.columns).reduce((n, [r, i]) => {
|
|
617
|
+
let a = t.find((e) => e.id === r);
|
|
618
|
+
if (!a || !i) return n;
|
|
619
|
+
let o = e.map((e) => qe(e, a.field));
|
|
620
|
+
return n[r] = typeof i == "function" ? i({
|
|
621
|
+
column: a,
|
|
622
|
+
rows: e,
|
|
623
|
+
values: o
|
|
624
|
+
}) : Ye(i, o), n;
|
|
625
|
+
}, {});
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region src/tree.ts
|
|
629
|
+
function Ze(e) {
|
|
630
|
+
return e.join(".");
|
|
631
|
+
}
|
|
632
|
+
function W(e, t) {
|
|
633
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = 0, a = (e, o) => {
|
|
634
|
+
e.forEach((e, s) => {
|
|
635
|
+
let c = [...o, s], l = t(e.item, i);
|
|
636
|
+
if (i += 1, n.has(l)) throw Error(`Duplicate tree row id: ${String(l)}`);
|
|
637
|
+
n.set(l, c), r.set(Ze(c), l), e.children?.length && a(e.children, c);
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
return a(e, []), {
|
|
641
|
+
byId: n,
|
|
642
|
+
idByPath: r
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function Qe(e, t, n) {
|
|
646
|
+
let [r, ...i] = t;
|
|
647
|
+
return r === void 0 ? [...e] : e.map((e, t) => t === r ? i.length === 0 ? n(e) : e.children ? {
|
|
648
|
+
...e,
|
|
649
|
+
children: Qe(e.children, i, n)
|
|
650
|
+
} : e : e);
|
|
651
|
+
}
|
|
652
|
+
function $e(e, t) {
|
|
653
|
+
let n = W(e, t), r = [], i = (e, t, a) => {
|
|
654
|
+
e.forEach((e, o) => {
|
|
655
|
+
let s = [...a, o], c = e.children ?? [], l = c.length > 0, u = e.expand === !0, d = n.idByPath.get(Ze(s));
|
|
656
|
+
d !== void 0 && (r.push({
|
|
657
|
+
depth: t,
|
|
658
|
+
expanded: u,
|
|
659
|
+
hasChildren: l,
|
|
660
|
+
item: e.item,
|
|
661
|
+
path: s,
|
|
662
|
+
rowId: d
|
|
663
|
+
}), l && u && i(c, t + 1, s));
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
return i(e, 0, []), r;
|
|
667
|
+
}
|
|
668
|
+
function et(e) {
|
|
669
|
+
return e.flatMap((e) => e.children?.length ? et(e.children) : [e.item]);
|
|
670
|
+
}
|
|
671
|
+
function tt(e, t, n) {
|
|
672
|
+
let r = W(e, n).byId.get(t);
|
|
673
|
+
return r ? Qe(e, r, (e) => ({
|
|
674
|
+
...e,
|
|
675
|
+
expand: e.expand !== !0
|
|
676
|
+
})) : [...e];
|
|
677
|
+
}
|
|
678
|
+
function nt(e, t, n, r) {
|
|
679
|
+
let i = W(e, n).byId.get(t);
|
|
680
|
+
return i ? Qe(e, i, (e) => ({
|
|
681
|
+
...e,
|
|
682
|
+
item: r(e.item)
|
|
683
|
+
})) : [...e];
|
|
684
|
+
}
|
|
685
|
+
function G(e, t) {
|
|
686
|
+
return [...e].sort((e, n) => t(e.item, n.item)).map((e) => ({
|
|
687
|
+
...e,
|
|
688
|
+
children: e.children ? G(e.children, t) : void 0
|
|
689
|
+
}));
|
|
690
|
+
}
|
|
691
|
+
//#endregion
|
|
692
|
+
//#region src/index.tsx
|
|
693
|
+
var rt = 50;
|
|
694
|
+
function it(e, t, n, r, i) {
|
|
695
|
+
let a = Math.max(0, r), o = e?.length ?? t.length, s = Math.min(o, Math.max(a, i)), c = [];
|
|
696
|
+
for (let r = a; r < s; r += 1) {
|
|
697
|
+
let i = e?.[r] ?? r, a = t[i], o = n[i];
|
|
698
|
+
a !== void 0 && o !== void 0 && c.push({
|
|
699
|
+
dataIndex: i,
|
|
700
|
+
row: a,
|
|
701
|
+
rowId: o,
|
|
702
|
+
visibleIndex: r
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
return c;
|
|
706
|
+
}
|
|
707
|
+
function at(e) {
|
|
708
|
+
return !e || typeof e == "string" ? e : Object.entries(e).filter(([, e]) => e).map(([e]) => e).join(" ");
|
|
709
|
+
}
|
|
710
|
+
function K(e, t, n) {
|
|
711
|
+
return typeof e == "function" ? e(t, n) : e;
|
|
712
|
+
}
|
|
713
|
+
function ot(e, t, n) {
|
|
714
|
+
let r = K(e?.disabled, t, n) === !0;
|
|
715
|
+
return {
|
|
716
|
+
className: at(K(e?.className, t, n)),
|
|
717
|
+
disabled: r,
|
|
718
|
+
draggable: !r && K(e?.draggable, t, n) !== !1,
|
|
719
|
+
style: K(e?.style, t, n)
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
function st(e) {
|
|
723
|
+
let t = e?.background ?? e?.backgroundColor;
|
|
724
|
+
return typeof t == "string" || typeof t == "number" ? t : void 0;
|
|
725
|
+
}
|
|
726
|
+
function ct(e, t, n) {
|
|
727
|
+
let r = {
|
|
728
|
+
height: e,
|
|
729
|
+
...t
|
|
730
|
+
};
|
|
731
|
+
return n === void 0 ? r : {
|
|
732
|
+
...r,
|
|
733
|
+
"--comins-table-row-custom-background": n
|
|
734
|
+
};
|
|
735
|
+
}
|
|
736
|
+
function lt(e) {
|
|
737
|
+
return {
|
|
738
|
+
data: e.row,
|
|
739
|
+
dataIndex: e.dataIndex,
|
|
740
|
+
id: e.rowId,
|
|
741
|
+
index: e.visibleIndex
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
function ut(e, t) {
|
|
745
|
+
return {
|
|
746
|
+
definition: e,
|
|
747
|
+
field: e.field,
|
|
748
|
+
id: e.id,
|
|
749
|
+
index: t,
|
|
750
|
+
label: e.label
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
function dt(e, t) {
|
|
754
|
+
return {
|
|
755
|
+
event: e,
|
|
756
|
+
index: t.visibleIndex,
|
|
757
|
+
row: lt(t)
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
function ft(e, t, n, r, i) {
|
|
761
|
+
return {
|
|
762
|
+
column: ut(n, r),
|
|
763
|
+
event: e,
|
|
764
|
+
index: t.visibleIndex,
|
|
765
|
+
row: lt(t),
|
|
766
|
+
value: i
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function q(e, t) {
|
|
770
|
+
return {
|
|
771
|
+
definition: e,
|
|
772
|
+
field: e.field,
|
|
773
|
+
id: e.id,
|
|
774
|
+
index: t,
|
|
775
|
+
label: e.label
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function pt(e, t, n, r, i, a, o) {
|
|
779
|
+
return {
|
|
780
|
+
column: q(i, a),
|
|
781
|
+
row: {
|
|
782
|
+
data: e.row,
|
|
783
|
+
dataIndex: e.dataIndex,
|
|
784
|
+
disabled: t,
|
|
785
|
+
id: e.rowId,
|
|
786
|
+
index: e.visibleIndex,
|
|
787
|
+
selected: n
|
|
788
|
+
},
|
|
789
|
+
selection: { selectedRowCount: r },
|
|
790
|
+
value: o
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function mt(e, t) {
|
|
794
|
+
let n = e.cell?.props;
|
|
795
|
+
return typeof n == "function" ? n(t) : n;
|
|
796
|
+
}
|
|
797
|
+
function ht(e, t) {
|
|
798
|
+
return e === void 0 ? !0 : typeof e == "boolean" ? e : e(t);
|
|
799
|
+
}
|
|
800
|
+
function gt(e, t) {
|
|
801
|
+
return e?.disabled !== void 0 && ht(e.disabled, t) === !0;
|
|
802
|
+
}
|
|
803
|
+
function _t(e, t) {
|
|
804
|
+
let n = e?.className;
|
|
805
|
+
return typeof n == "function" ? n(t) : n;
|
|
806
|
+
}
|
|
807
|
+
function vt(e, t) {
|
|
808
|
+
let n = e?.style;
|
|
809
|
+
return typeof n == "function" ? n(t) : n;
|
|
810
|
+
}
|
|
811
|
+
function yt(e, t, n) {
|
|
812
|
+
return e.cell?.format ? e.cell.format(n) : t == null ? "" : String(t);
|
|
813
|
+
}
|
|
814
|
+
function bt(e, t, n) {
|
|
815
|
+
let r = e.columnState[t.id];
|
|
816
|
+
return {
|
|
817
|
+
column: q(t, n),
|
|
818
|
+
layout: {
|
|
819
|
+
hidden: r?.hidden === !0 || t.hidden === !0,
|
|
820
|
+
width: r?.width ?? t.width
|
|
821
|
+
},
|
|
822
|
+
sort: {
|
|
823
|
+
direction: e.sort?.columnId === t.id ? e.sort.direction : null,
|
|
824
|
+
enabled: !!t.sort
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
function xt(e) {
|
|
829
|
+
return "row" in e && "selection" in e;
|
|
830
|
+
}
|
|
831
|
+
function St(e, t) {
|
|
832
|
+
return !xt(t) || e.type !== "input" && e.type !== "select" || t.selection.selectedRowCount === 1 && t.row.selected;
|
|
833
|
+
}
|
|
834
|
+
function Ct(e, t) {
|
|
835
|
+
return (e ?? []).filter((e) => St(e, t));
|
|
836
|
+
}
|
|
837
|
+
function wt(e, t, n) {
|
|
838
|
+
return Ct(e, t).map((e, t) => ({
|
|
839
|
+
component: e,
|
|
840
|
+
index: t
|
|
841
|
+
})).filter(({ component: e }) => (e.direction ?? "left") === n).map(({ component: e, index: r }) => /* @__PURE__ */ N("span", {
|
|
842
|
+
className: "comins-table__component-slot",
|
|
843
|
+
"data-comins-component-align": e.align ?? "center",
|
|
844
|
+
"data-comins-component-direction": n,
|
|
845
|
+
"data-comins-component-id": e.id ?? `${e.type}-${r}`,
|
|
846
|
+
children: Ke(e, t)
|
|
847
|
+
}, e.id ?? `${e.type}-${r}`));
|
|
848
|
+
}
|
|
849
|
+
function Tt(e, t, n, r = {}) {
|
|
850
|
+
if (!t?.length) return e;
|
|
851
|
+
let i = r.showContent ?? !0, a = Ct(t, n);
|
|
852
|
+
if (!a.length) return e;
|
|
853
|
+
let o = wt(a, n, "left"), s = wt(a, n, "right");
|
|
854
|
+
return i ? /* @__PURE__ */ P("span", {
|
|
855
|
+
className: "comins-table__component-layout",
|
|
856
|
+
children: [
|
|
857
|
+
/* @__PURE__ */ N("span", {
|
|
858
|
+
className: "comins-table__component-group",
|
|
859
|
+
"data-comins-component-direction": "left",
|
|
860
|
+
children: o
|
|
861
|
+
}),
|
|
862
|
+
/* @__PURE__ */ N("span", {
|
|
863
|
+
className: "comins-table__component-content",
|
|
864
|
+
children: e
|
|
865
|
+
}),
|
|
866
|
+
/* @__PURE__ */ N("span", {
|
|
867
|
+
className: "comins-table__component-group",
|
|
868
|
+
"data-comins-component-direction": "right",
|
|
869
|
+
children: s
|
|
870
|
+
})
|
|
871
|
+
]
|
|
872
|
+
}) : /* @__PURE__ */ N("span", {
|
|
873
|
+
className: "comins-table__component-layout",
|
|
874
|
+
"data-comins-component-only": "true",
|
|
875
|
+
children: /* @__PURE__ */ P("span", {
|
|
876
|
+
className: "comins-table__component-group",
|
|
877
|
+
"data-comins-component-direction": "all",
|
|
878
|
+
children: [o, s]
|
|
879
|
+
})
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
function Et(e) {
|
|
883
|
+
return Math.max(rt, e.minWidth ?? rt);
|
|
884
|
+
}
|
|
885
|
+
function J(e) {
|
|
886
|
+
return e.maxWidth ?? Infinity;
|
|
887
|
+
}
|
|
888
|
+
function Dt(e, t) {
|
|
889
|
+
return e.columnState[t.id]?.width ?? t.width ?? 100;
|
|
890
|
+
}
|
|
891
|
+
function Y(e, t, n) {
|
|
892
|
+
return Math.min(n, Math.max(t, e));
|
|
893
|
+
}
|
|
894
|
+
function Ot(e, t, n) {
|
|
895
|
+
let r = t.map((t) => Y(Dt(e, t), Et(t), J(t))), i = new Set(t.map((e, t) => t)), a = t.map(Et), o = t.map(J), s = Y(n, a.reduce((e, t) => e + t, 0), o.reduce((e, t) => e + t, 0));
|
|
896
|
+
for (; i.size > 0;) {
|
|
897
|
+
let e = s - r.reduce((e, t) => e + t, 0);
|
|
898
|
+
if (Math.abs(e) < .001) break;
|
|
899
|
+
let t = [...i], n = t.reduce((e, t) => e + Math.max(r[t] ?? 0, 0), 0), c = !1;
|
|
900
|
+
for (let s of t) {
|
|
901
|
+
let l = r[s] ?? 0, u = l + e * (n > 0 ? l / n : 1 / t.length), d = Y(u, a[s] ?? 0, o[s] ?? Infinity);
|
|
902
|
+
r[s] = d, Math.abs(d - u) > .001 && (i.delete(s), c = !0);
|
|
903
|
+
}
|
|
904
|
+
if (!c) break;
|
|
905
|
+
}
|
|
906
|
+
return r;
|
|
907
|
+
}
|
|
908
|
+
function kt(e, t, n) {
|
|
909
|
+
let r = e.columnGroups.find((e) => e.children.includes(t));
|
|
910
|
+
if (!r || e.columnGroupState[r.id]?.hidden === !0) return D(e, t, n);
|
|
911
|
+
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);
|
|
912
|
+
if (!a) return D(e, t, n);
|
|
913
|
+
let o = i.filter((e) => e.id !== t);
|
|
914
|
+
if (o.length === 0) {
|
|
915
|
+
let r = Dt(e, a);
|
|
916
|
+
return D(e, t, Y(n, Et(a), Math.min(J(a), r)));
|
|
917
|
+
}
|
|
918
|
+
let s = i.reduce((t, n) => t + Dt(e, n), 0), c = o.reduce((e, t) => e + Et(t), 0), l = o.reduce((e, t) => e + J(t), 0), u = Math.max(Et(a), s - l), d = Y(n, u, Math.max(u, Math.min(J(a), s - c))), f = Ot(e, o, s - d), p = D(e, t, d);
|
|
919
|
+
return o.forEach((e, t) => {
|
|
920
|
+
p = D(p, e.id, f[t] ?? Dt(p, e));
|
|
921
|
+
}), p;
|
|
922
|
+
}
|
|
923
|
+
function At(e, t, n) {
|
|
924
|
+
if (!e || typeof e != "object") return e;
|
|
925
|
+
let r = t.split("."), [i] = r;
|
|
926
|
+
if (!i) return e;
|
|
927
|
+
if (r.length === 1) return {
|
|
928
|
+
...e,
|
|
929
|
+
[i]: n
|
|
930
|
+
};
|
|
931
|
+
let a = { ...e }, o = a;
|
|
932
|
+
return r.slice(0, -1).forEach((e, t) => {
|
|
933
|
+
let n = r[t + 1], i = o[e], a = i && typeof i == "object" && !Array.isArray(i) ? { ...i } : {};
|
|
934
|
+
o[e] = a, n && (o = a);
|
|
935
|
+
}), o[r.at(-1)] = n, a;
|
|
936
|
+
}
|
|
937
|
+
function jt(e, t) {
|
|
938
|
+
return e?.columnId === t ? e.direction === "asc" ? {
|
|
939
|
+
columnId: t,
|
|
940
|
+
direction: "desc"
|
|
941
|
+
} : null : {
|
|
942
|
+
columnId: t,
|
|
943
|
+
direction: "asc"
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
function Mt(e, t) {
|
|
947
|
+
return e?.columnId === t ? e.direction : "none";
|
|
948
|
+
}
|
|
949
|
+
function Nt(e, t) {
|
|
950
|
+
return e?.columnId === t ? e.direction === "asc" ? "ascending" : "descending" : "none";
|
|
951
|
+
}
|
|
952
|
+
function Pt(e, t) {
|
|
953
|
+
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
954
|
+
}
|
|
955
|
+
function Ft(e, t) {
|
|
956
|
+
if (!Pt(e.rowIds, t.rowIds)) return !1;
|
|
957
|
+
let n = new Set(t.columns.map((e) => e.id)), r = e.selection.cell, i = e.selection.range;
|
|
958
|
+
return !(r && !n.has(r.columnId) || i && (!n.has(i.anchor.columnId) || !n.has(i.focus.columnId)));
|
|
959
|
+
}
|
|
960
|
+
function It(e, t) {
|
|
961
|
+
return t.split(".").reduce((e, t) => {
|
|
962
|
+
if (!(typeof e != "object" || !e)) return e[t];
|
|
963
|
+
}, e);
|
|
964
|
+
}
|
|
965
|
+
function Lt(e, t) {
|
|
966
|
+
return typeof e == "number" && typeof t == "number" ? e - t : String(e ?? "").localeCompare(String(t ?? ""));
|
|
967
|
+
}
|
|
968
|
+
function Rt(e, t, n) {
|
|
969
|
+
if (!n) return e;
|
|
970
|
+
let r = t.find((e) => (e.id ?? e.field) === n.columnId);
|
|
971
|
+
return r?.sort ? G(e, (e, t) => {
|
|
972
|
+
let i = It(e, r.field), a = It(t, r.field), o = typeof r.sort == "function" ? r.sort(i, a, e, t) : Lt(i, a);
|
|
973
|
+
return n.direction === "desc" ? o * -1 : o;
|
|
974
|
+
}) : e;
|
|
975
|
+
}
|
|
976
|
+
function zt({ "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: ee = 30, lazyLoadMode: te = "append", lazyLoadThreshold: ne, loading: se = !1, loadingComponent: ce, loadingMore: pe = !1, onChangeColumnLayout: he, onChangeData: ge, onChangeSelection: _e, onChangeSort: ye, onClickCell: be, onClickRow: Ce, onContextMenuCell: O, onContextMenuRow: Te, onDoubleClickCell: Ee, onDoubleClickRow: Oe, onKeyDownCell: ke, onKeyDownRow: Ae, onLazyLoad: je, onLoadMore: Me, pagination: F, persistHeaderWhenEmpty: Ne = !0, rowHeight: I = 36, rowProps: Pe, showHeader: Fe = !0, skeletonRowCount: L, style: R, summary: Le, theme: Re, treeContext: z, virtualized: B = !1 }, ze) {
|
|
977
|
+
let Be = j(null), V = j(null), H = j(null), Ve = j(null), He = j(null), Ue = j(null), U = j(null), We = j(null), Ge = j(null), Ke = j(null), qe = j(0), Je = j(d), Ye = j(void 0), Ze = j(null), W = j(null), Qe = j(null), $e = j(null), et = j(!1), tt = j(null), nt = j(0), G = j(null), rt = j(null), K = j(null), [lt, ut] = M(0), [q, ht] = M(0), [xt, St] = M(null), [J, Dt] = M(null), [Y, Ot] = M(null), [Pt, It] = M(null), [Lt, Rt] = M(null), [zt, Bt] = M(d), [Vt, Ht] = M(void 0), [Ut, Wt] = M(null), [Gt, Kt] = M(null), [qt, Jt] = M(0), Yt = x ? zt : d, [X, Xt] = M(() => c({
|
|
978
|
+
columnGroups: l,
|
|
979
|
+
columns: u,
|
|
980
|
+
getRowId: m,
|
|
981
|
+
pagination: F,
|
|
982
|
+
rows: Yt,
|
|
983
|
+
showHeader: Fe,
|
|
984
|
+
theme: Re
|
|
985
|
+
})), Z = j(X), Zt = j({
|
|
986
|
+
columnGroups: l,
|
|
987
|
+
columns: u,
|
|
988
|
+
data: Yt,
|
|
989
|
+
getRowId: m,
|
|
990
|
+
pagination: F,
|
|
991
|
+
showHeader: Fe
|
|
992
|
+
}), Qt = Math.max(0, Math.floor(Number.isFinite(e) ? Number(e) : 10)), $t = Math.max(1, Math.floor(ee)), en = Math.max(0, Math.floor(ne ?? y)), tn = (e) => {
|
|
993
|
+
if (!x || te !== "append" || !je || Ke.current) return;
|
|
994
|
+
let t = Z.current.rows.length;
|
|
995
|
+
if (e === "scroll" && Ye.current !== void 0 && t >= Ye.current) return;
|
|
996
|
+
let n = new AbortController(), r = qe.current + 1, i = e === "scroll" ? t : 0;
|
|
997
|
+
qe.current = r, Ge.current?.abort(), Ge.current = n, Ke.current = e, e !== "scroll" && (nt.current = 0, Jt(0), Be.current && (Be.current.scrollTop = 0)), Rt(e), je({
|
|
998
|
+
limit: $t,
|
|
999
|
+
offset: i,
|
|
1000
|
+
reason: e,
|
|
1001
|
+
signal: n.signal
|
|
1002
|
+
}).then((t) => {
|
|
1003
|
+
if (n.signal.aborted || qe.current !== r) return;
|
|
1004
|
+
let i = e === "scroll" ? [...Je.current, ...t.rows] : [...t.rows];
|
|
1005
|
+
Je.current = i, Ye.current = t.total, Bt(i), Ht(t.total);
|
|
1006
|
+
}).catch(() => {}).finally(() => {
|
|
1007
|
+
qe.current === r && (Ke.current = null, Ge.current = null, Rt(null));
|
|
1008
|
+
});
|
|
1009
|
+
};
|
|
1010
|
+
k(() => {
|
|
1011
|
+
Je.current = zt;
|
|
1012
|
+
}, [zt]), k(() => {
|
|
1013
|
+
Ye.current = Vt;
|
|
1014
|
+
}, [Vt]), k(() => {
|
|
1015
|
+
x || (Je.current = d, Bt(d), Ye.current = void 0, Ht(void 0));
|
|
1016
|
+
}, [d, x]), k(() => {
|
|
1017
|
+
if (!(!x || !je)) return tn("initial"), () => {
|
|
1018
|
+
qe.current += 1, Ke.current = null, Ge.current?.abort(), Ge.current = null;
|
|
1019
|
+
};
|
|
1020
|
+
}, [
|
|
1021
|
+
x,
|
|
1022
|
+
je,
|
|
1023
|
+
$t
|
|
1024
|
+
]), k(() => {
|
|
1025
|
+
let e = Zt.current;
|
|
1026
|
+
e.columns === u && e.columnGroups === l && e.data === Yt && e.getRowId === m && e.pagination === F && e.showHeader === Fe || (Zt.current = {
|
|
1027
|
+
columnGroups: l,
|
|
1028
|
+
columns: u,
|
|
1029
|
+
data: Yt,
|
|
1030
|
+
getRowId: m,
|
|
1031
|
+
pagination: F,
|
|
1032
|
+
showHeader: Fe
|
|
1033
|
+
}, Xt((e) => {
|
|
1034
|
+
let t = c({
|
|
1035
|
+
columnLayout: fe(e),
|
|
1036
|
+
columnGroups: l,
|
|
1037
|
+
columns: u,
|
|
1038
|
+
getRowId: m,
|
|
1039
|
+
pagination: F ?? e.pagination,
|
|
1040
|
+
rows: Yt,
|
|
1041
|
+
showHeader: Fe,
|
|
1042
|
+
sort: e.sort,
|
|
1043
|
+
theme: e.theme
|
|
1044
|
+
});
|
|
1045
|
+
return Ft(e, t) ? {
|
|
1046
|
+
...t,
|
|
1047
|
+
selection: e.selection
|
|
1048
|
+
} : t;
|
|
1049
|
+
}));
|
|
1050
|
+
}, [
|
|
1051
|
+
l,
|
|
1052
|
+
u,
|
|
1053
|
+
Yt,
|
|
1054
|
+
m,
|
|
1055
|
+
F,
|
|
1056
|
+
Fe
|
|
1057
|
+
]), k(() => {
|
|
1058
|
+
Z.current = X;
|
|
1059
|
+
}, [X]), k(() => {
|
|
1060
|
+
Ze.current !== null && Ze.current !== X.rows.length && (Ze.current = null);
|
|
1061
|
+
}, [X.rows.length]), k(() => () => {
|
|
1062
|
+
rt.current !== null && window.cancelAnimationFrame(rt.current), G.current !== null && window.clearTimeout(G.current);
|
|
1063
|
+
}, []), k(() => {
|
|
1064
|
+
let e = Be.current;
|
|
1065
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
1066
|
+
let t = new ResizeObserver(([e]) => {
|
|
1067
|
+
e && (ut(e.contentRect.height), ht(e.contentRect.width));
|
|
1068
|
+
});
|
|
1069
|
+
return t.observe(e), () => t.disconnect();
|
|
1070
|
+
}, []);
|
|
1071
|
+
let nn = (e, t, n = {}) => {
|
|
1072
|
+
t.rows !== e.rows && ge?.(t.rows), t.selection !== e.selection && _e?.(t.selection), n.columnLayoutChanged && he?.(fe(t)), (n.sortChanged || t.sort !== e.sort) && ye?.(t.sort);
|
|
1073
|
+
}, Q = (e, t = {}) => {
|
|
1074
|
+
let n = Z.current, r = typeof e == "function" ? e(n) : e;
|
|
1075
|
+
Z.current = r, Xt(r), nn(n, r, t);
|
|
1076
|
+
}, $ = A(() => S(X), [X]), rn = A(() => _(X), [X]), an = A(() => Le ? Xe(z?.summaryRows ?? X.rows, $, Le) : null, [
|
|
1077
|
+
X.rows,
|
|
1078
|
+
Le,
|
|
1079
|
+
z?.summaryRows,
|
|
1080
|
+
$
|
|
1081
|
+
]), on = A(() => z || !X.sort ? null : b(X), [X, z]), sn = on?.length ?? X.rows.length, cn = Math.max(0, X.pagination.pageIndex) * Math.max(1, X.pagination.pageSize), ln = A(() => {
|
|
1082
|
+
if (B) {
|
|
1083
|
+
let e = Math.max(1, I), t = lt || I * 12, n = sn * 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, qt) * o), c = Math.max(0, Math.floor(s / e) - Qt), l = Math.min(sn, Math.ceil((s + Math.max(0, t)) / e) + Qt), u = c * e, d = o > 0 ? u / o : u;
|
|
1084
|
+
return {
|
|
1085
|
+
entries: it(on, X.rows, X.rowIds, c, l),
|
|
1086
|
+
renderOffset: d,
|
|
1087
|
+
scrollHeight: r
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
return {
|
|
1091
|
+
entries: it(on, X.rows, X.rowIds, cn, cn + Math.max(1, X.pagination.pageSize)),
|
|
1092
|
+
renderOffset: 0,
|
|
1093
|
+
scrollHeight: 0
|
|
1094
|
+
};
|
|
1095
|
+
}, [
|
|
1096
|
+
lt,
|
|
1097
|
+
cn,
|
|
1098
|
+
I,
|
|
1099
|
+
qt,
|
|
1100
|
+
on,
|
|
1101
|
+
X.pagination.pageSize,
|
|
1102
|
+
X.rowIds,
|
|
1103
|
+
X.rows,
|
|
1104
|
+
Qt,
|
|
1105
|
+
B,
|
|
1106
|
+
sn
|
|
1107
|
+
]), un = Re ?? X.theme, dn = un.density === "compact" ? "text-[11px]" : un.density === "spacious" ? "text-[13px]" : "text-[length:var(--comins-font-size-base,12px)]", fn = A(() => new Set(X.selection.rowIds), [X.selection.rowIds]), pn = A(() => {
|
|
1108
|
+
let e = $.length;
|
|
1109
|
+
if (e === 0) return [];
|
|
1110
|
+
let t = $.map((e) => X.columnState[e.id]?.width ?? e.width);
|
|
1111
|
+
if (q <= 0) {
|
|
1112
|
+
let n = `${100 / e}%`;
|
|
1113
|
+
return t.map((e) => e ?? n);
|
|
1114
|
+
}
|
|
1115
|
+
let n = 0;
|
|
1116
|
+
for (let e of t) n += e ?? 0;
|
|
1117
|
+
let r = $.filter((e, n) => t[n] === void 0), i = r.length > 0 ? Math.max(0, (q - n) / r.length) : 0;
|
|
1118
|
+
return $.map((e, n) => {
|
|
1119
|
+
let r = t[n] ?? i, a = Et(e), o = e.maxWidth ?? Infinity;
|
|
1120
|
+
return Math.min(o, Math.max(a, r));
|
|
1121
|
+
});
|
|
1122
|
+
}, [
|
|
1123
|
+
q,
|
|
1124
|
+
X.columnState,
|
|
1125
|
+
$
|
|
1126
|
+
]), mn = A(() => {
|
|
1127
|
+
let e = 0;
|
|
1128
|
+
for (let t of pn) {
|
|
1129
|
+
if (typeof t != "number") return;
|
|
1130
|
+
e += t;
|
|
1131
|
+
}
|
|
1132
|
+
return e;
|
|
1133
|
+
}, [pn]), hn = A(() => {
|
|
1134
|
+
if (typeof mn == "number") return Math.max(q, mn);
|
|
1135
|
+
}, [mn, q]), gn = typeof mn == "number" && q > 0 && mn > q + 1, _n = x ? x && (Vt === void 0 || sn < Vt) : h, vn = se || Lt === "initial" || Lt === "refresh", yn = pe || Lt === "scroll", bn = sn === 0, xn = vn && bn, Sn = !vn && bn, Cn = (v || x) && yn && _n && !bn, wn = Math.max(1, Math.floor(L ?? Math.min(Math.max(1, X.pagination.pageSize), 5))), Tn = (xn ? wn : +!!Sn) + +!!Cn, En = (ln.entries.length + Tn) * I, Dn = B ? 0 : Math.max(0, lt - En), On = X.showHeader && (Ne || !bn || vn), kn = (e, t) => (e.ctrlKey || e.metaKey) && e.key.toLowerCase() === t, An = (e) => ln.entries[e], jn = (e, t, n) => {
|
|
1136
|
+
let r = (z ? e.rows.map((e, t) => t) : b(e)).flatMap((t, n) => {
|
|
1137
|
+
let r = e.rows[t], i = e.rowIds[t];
|
|
1138
|
+
return r === void 0 || i === void 0 ? [] : [{
|
|
1139
|
+
dataIndex: t,
|
|
1140
|
+
row: r,
|
|
1141
|
+
rowId: i,
|
|
1142
|
+
visibleIndex: n
|
|
1143
|
+
}];
|
|
1144
|
+
}), i = r.findIndex((e) => e.rowId === t), a = r.findIndex((e) => e.rowId === n);
|
|
1145
|
+
if (i < 0 || a < 0) return [n];
|
|
1146
|
+
let o = Math.min(i, a), s = Math.max(i, a);
|
|
1147
|
+
return r.slice(o, s + 1).map((e) => e.rowId);
|
|
1148
|
+
}, Mn = (e, t) => {
|
|
1149
|
+
Q((n) => de(n, jn(n, e, t)));
|
|
1150
|
+
}, Nn = (e) => {
|
|
1151
|
+
Q((t) => de(t, e.flatMap((e) => {
|
|
1152
|
+
let t = An(e);
|
|
1153
|
+
return t ? [t.rowId] : [];
|
|
1154
|
+
})));
|
|
1155
|
+
}, Pn = (e) => {
|
|
1156
|
+
if (K.current === e.id) {
|
|
1157
|
+
K.current = null;
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
e.sort && Q((t) => ve(t, jt(t.sort, e.id)), { sortChanged: !0 });
|
|
1161
|
+
}, Fn = (e, t) => {
|
|
1162
|
+
let n = document.elementFromPoint(e, t)?.closest("[data-comins-column-id], [data-comins-column-group-id]");
|
|
1163
|
+
if (!n) return null;
|
|
1164
|
+
if (n.dataset.cominsColumnId) return n.dataset.cominsColumnId;
|
|
1165
|
+
let r = n.dataset.cominsColumnGroupId;
|
|
1166
|
+
return (r ? Z.current.columnGroups.find((e) => e.id === r) : void 0)?.children.find((e) => $.some((t) => t.id === e)) ?? null;
|
|
1167
|
+
};
|
|
1168
|
+
De(ze, () => ({
|
|
1169
|
+
clearSort: () => Q((e) => i(e), { sortChanged: !0 }),
|
|
1170
|
+
getColumnLayout: () => fe(X),
|
|
1171
|
+
getSortState: () => X.sort,
|
|
1172
|
+
setColumnLayout: (e) => Q((n) => t(n, e), { columnLayoutChanged: !0 }),
|
|
1173
|
+
setMoveTargetRow: (e, t) => Q((n) => {
|
|
1174
|
+
if (z) return n;
|
|
1175
|
+
let r = b(n).flatMap((e) => {
|
|
1176
|
+
let t = n.rowIds[e];
|
|
1177
|
+
return t === void 0 ? [] : [t];
|
|
1178
|
+
}), i = r[t];
|
|
1179
|
+
if (i === void 0 || e < 0 || t < 0) return n;
|
|
1180
|
+
let a = r.filter((e) => e !== i), o = Math.min(a.length, e);
|
|
1181
|
+
a.splice(o, 0, i);
|
|
1182
|
+
let s = new Map(n.rowIds.map((e, t) => [e, n.rows[t]])), c = a.flatMap((e) => {
|
|
1183
|
+
let t = s.get(e);
|
|
1184
|
+
return t === void 0 ? [] : [t];
|
|
1185
|
+
});
|
|
1186
|
+
return c.length === n.rows.length ? {
|
|
1187
|
+
...n,
|
|
1188
|
+
rowIds: a,
|
|
1189
|
+
rows: c,
|
|
1190
|
+
sort: null
|
|
1191
|
+
} : n;
|
|
1192
|
+
}, { sortChanged: !0 }),
|
|
1193
|
+
setSelectedRow: (e) => Nn([e]),
|
|
1194
|
+
setSelectedRows: (e) => Nn(e),
|
|
1195
|
+
setSortState: (e) => Q((t) => ve(t, e), { sortChanged: !0 })
|
|
1196
|
+
}), [
|
|
1197
|
+
ln.entries,
|
|
1198
|
+
X,
|
|
1199
|
+
z
|
|
1200
|
+
]);
|
|
1201
|
+
let In = () => {
|
|
1202
|
+
let e = U.current;
|
|
1203
|
+
e && window.clearTimeout(e.timer), U.current = null, St(null), Dt(null), Ot(null), It(null);
|
|
1204
|
+
}, Ln = (e, t) => {
|
|
1205
|
+
if (e.button !== 0) return;
|
|
1206
|
+
let n = (e, n, r) => {
|
|
1207
|
+
e.active = !0, e.cancelSort = !0, K.current = t.id, Ot({
|
|
1208
|
+
x: n,
|
|
1209
|
+
y: r
|
|
1210
|
+
}), It(t.id), Dt(null), St(t.id);
|
|
1211
|
+
}, r = {
|
|
1212
|
+
active: !1,
|
|
1213
|
+
cancelSort: !1,
|
|
1214
|
+
id: t.id,
|
|
1215
|
+
kind: "column",
|
|
1216
|
+
movedBeforeLongPress: !1,
|
|
1217
|
+
startedAt: performance.now(),
|
|
1218
|
+
startX: e.clientX,
|
|
1219
|
+
startY: e.clientY,
|
|
1220
|
+
timer: window.setTimeout(() => {
|
|
1221
|
+
let e = U.current;
|
|
1222
|
+
!e || e.id !== t.id || e.kind !== "column" || e.movedBeforeLongPress || n(e, e.startX, e.startY);
|
|
1223
|
+
}, 1e3)
|
|
1224
|
+
}, i = (e) => {
|
|
1225
|
+
let r = U.current;
|
|
1226
|
+
if (!r || r.id !== t.id || r.kind !== "column") return;
|
|
1227
|
+
let i = Math.hypot(e.clientX - r.startX, e.clientY - r.startY);
|
|
1228
|
+
if (!r.active && performance.now() - r.startedAt >= 1e3 && !r.movedBeforeLongPress && n(r, e.clientX, e.clientY), !r.active && i > 4) {
|
|
1229
|
+
r.movedBeforeLongPress = !0, r.cancelSort = !0, K.current = t.id, window.clearTimeout(r.timer);
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
r.active && (e.preventDefault(), Ot({
|
|
1233
|
+
x: e.clientX,
|
|
1234
|
+
y: e.clientY
|
|
1235
|
+
}), It(Fn(e.clientX, e.clientY)));
|
|
1236
|
+
}, a = (e) => {
|
|
1237
|
+
let n = U.current;
|
|
1238
|
+
if (window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", a), !n || n.id !== t.id || n.kind !== "column") {
|
|
1239
|
+
In();
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
if (window.clearTimeout(n.timer), n.active) {
|
|
1243
|
+
let n = Fn(e.clientX, e.clientY);
|
|
1244
|
+
if (n) {
|
|
1245
|
+
let e = $.findIndex((e) => e.id === n);
|
|
1246
|
+
e >= 0 && Q((n) => re(n, t.id, e), { columnLayoutChanged: !0 });
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
(n.cancelSort || n.active) && (K.current = t.id), In();
|
|
1250
|
+
};
|
|
1251
|
+
In(), U.current = r, window.addEventListener("pointermove", i), window.addEventListener("pointerup", a);
|
|
1252
|
+
}, Rn = (e, t) => {
|
|
1253
|
+
if (e.button !== 0) return;
|
|
1254
|
+
let n = (e, n, r) => {
|
|
1255
|
+
e.active = !0, e.cancelSort = !0, Ot({
|
|
1256
|
+
x: n,
|
|
1257
|
+
y: r
|
|
1258
|
+
}), It(t.children[0] ?? null), St(null), Dt(t.id);
|
|
1259
|
+
}, r = {
|
|
1260
|
+
active: !1,
|
|
1261
|
+
cancelSort: !1,
|
|
1262
|
+
id: t.id,
|
|
1263
|
+
kind: "group",
|
|
1264
|
+
movedBeforeLongPress: !1,
|
|
1265
|
+
startedAt: performance.now(),
|
|
1266
|
+
startX: e.clientX,
|
|
1267
|
+
startY: e.clientY,
|
|
1268
|
+
timer: window.setTimeout(() => {
|
|
1269
|
+
let e = U.current;
|
|
1270
|
+
!e || e.id !== t.id || e.kind !== "group" || e.movedBeforeLongPress || n(e, e.startX, e.startY);
|
|
1271
|
+
}, 1e3)
|
|
1272
|
+
}, i = (e) => {
|
|
1273
|
+
let r = U.current;
|
|
1274
|
+
if (!r || r.id !== t.id || r.kind !== "group") return;
|
|
1275
|
+
let i = Math.hypot(e.clientX - r.startX, e.clientY - r.startY);
|
|
1276
|
+
if (!r.active && performance.now() - r.startedAt >= 1e3 && !r.movedBeforeLongPress && n(r, e.clientX, e.clientY), !r.active && i > 4) {
|
|
1277
|
+
r.movedBeforeLongPress = !0, r.cancelSort = !0, window.clearTimeout(r.timer);
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
r.active && (e.preventDefault(), Ot({
|
|
1281
|
+
x: e.clientX,
|
|
1282
|
+
y: e.clientY
|
|
1283
|
+
}), It(Fn(e.clientX, e.clientY)));
|
|
1284
|
+
}, a = (e) => {
|
|
1285
|
+
let n = U.current;
|
|
1286
|
+
if (window.removeEventListener("pointermove", i), window.removeEventListener("pointerup", a), !n || n.id !== t.id || n.kind !== "group") {
|
|
1287
|
+
In();
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (window.clearTimeout(n.timer), n.active) {
|
|
1291
|
+
let n = Fn(e.clientX, e.clientY);
|
|
1292
|
+
if (n) {
|
|
1293
|
+
let e = $.findIndex((e) => e.id === n);
|
|
1294
|
+
e >= 0 && Q((n) => w(n, t.id, e), { columnLayoutChanged: !0 });
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
In();
|
|
1298
|
+
};
|
|
1299
|
+
In(), U.current = r, window.addEventListener("pointermove", i), window.addEventListener("pointerup", a);
|
|
1300
|
+
}, zn = (e, t) => {
|
|
1301
|
+
if (e.shiftKey && W.current !== null) {
|
|
1302
|
+
Mn(W.current, t.rowId), W.current = t.rowId;
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
Q((n) => E(n, t.rowId, {
|
|
1306
|
+
multi: e.ctrlKey || e.metaKey,
|
|
1307
|
+
toggle: e.ctrlKey || e.metaKey
|
|
1308
|
+
})), W.current = t.rowId;
|
|
1309
|
+
}, Bn = (e, t, n) => {
|
|
1310
|
+
if (n) {
|
|
1311
|
+
e.preventDefault();
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
if (Ae?.(dt(e, t)), !(e.defaultPrevented || e.target !== e.currentTarget)) {
|
|
1315
|
+
if (z && (kn(e, "c") || kn(e, "v"))) {
|
|
1316
|
+
e.preventDefault();
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
if (kn(e, "c")) {
|
|
1320
|
+
e.preventDefault(), Ue.current = s(X, t.rowId);
|
|
1321
|
+
return;
|
|
1322
|
+
}
|
|
1323
|
+
kn(e, "v") && Ue.current && (e.preventDefault(), Q((e) => oe(e, Ue.current, {
|
|
1324
|
+
mode: "insert-after",
|
|
1325
|
+
targetRowId: t.rowId
|
|
1326
|
+
})));
|
|
1327
|
+
}
|
|
1328
|
+
}, Vn = (e, t, n, r, i, s) => {
|
|
1329
|
+
if (s) {
|
|
1330
|
+
e.preventDefault(), e.stopPropagation();
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
if (ke?.(ft(e, t, n, r, g(X, t.row, n.id))), !e.defaultPrevented) {
|
|
1334
|
+
if (kn(e, "c")) {
|
|
1335
|
+
e.preventDefault(), e.stopPropagation(), He.current = X.selection.range ? o(X) : null, Ve.current = He.current ? null : a(X, i);
|
|
1336
|
+
return;
|
|
1337
|
+
}
|
|
1338
|
+
kn(e, "v") && (He.current || Ve.current) && (e.preventDefault(), e.stopPropagation(), Q((e) => He.current ? ae(e, i, He.current) : ie(e, i, Ve.current)));
|
|
1339
|
+
}
|
|
1340
|
+
}, Hn = (e, t, r) => {
|
|
1341
|
+
n && (r || e.button !== 0 || e.shiftKey || (Qe.current = t, $e.current = t, et.current = !1));
|
|
1342
|
+
}, Un = (e, t) => {
|
|
1343
|
+
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) ? X.rowIds[i] : void 0;
|
|
1344
|
+
return r && a !== void 0 ? {
|
|
1345
|
+
columnId: r,
|
|
1346
|
+
rowId: a
|
|
1347
|
+
} : null;
|
|
1348
|
+
}, Wn = (e) => {
|
|
1349
|
+
if (!n) return;
|
|
1350
|
+
let t = Qe.current;
|
|
1351
|
+
!t || t.rowId === e.rowId && t.columnId === e.columnId || (et.current = !0, $e.current = e, We.current = t, Q((n) => ue(n, {
|
|
1352
|
+
anchor: t,
|
|
1353
|
+
focus: e
|
|
1354
|
+
})));
|
|
1355
|
+
}, Gn = () => {
|
|
1356
|
+
n && (Qe.current = null, $e.current = null);
|
|
1357
|
+
}, Kn = (e, t, n) => {
|
|
1358
|
+
if (Hn(e, t, n), n || e.button !== 0 || e.shiftKey) return;
|
|
1359
|
+
let r = (e) => {
|
|
1360
|
+
if (e.buttons !== 1) return;
|
|
1361
|
+
let t = Un(e.clientX, e.clientY);
|
|
1362
|
+
t && Wn(t);
|
|
1363
|
+
}, i = () => {
|
|
1364
|
+
Gn(), window.removeEventListener("pointermove", r), window.removeEventListener("pointerup", i);
|
|
1365
|
+
};
|
|
1366
|
+
e.preventDefault(), window.addEventListener("pointermove", r), window.addEventListener("pointerup", i);
|
|
1367
|
+
}, qn = (e, t, n, r) => {
|
|
1368
|
+
if (n || !r || e.button !== 0) return;
|
|
1369
|
+
e.preventDefault(), e.stopPropagation();
|
|
1370
|
+
let i = t.rowId, a = (e) => {
|
|
1371
|
+
tt.current = e, Kt(e);
|
|
1372
|
+
}, o = (e, t) => {
|
|
1373
|
+
let n = document.elementFromPoint(e, t)?.closest("[data-comins-row-data-index]");
|
|
1374
|
+
if (!n || n.dataset.cominsRowDataIndex === void 0) return;
|
|
1375
|
+
let r = Number(n.dataset.cominsRowDataIndex);
|
|
1376
|
+
Number.isInteger(r) && a({
|
|
1377
|
+
sourceRowId: i,
|
|
1378
|
+
targetDataIndex: r
|
|
1379
|
+
});
|
|
1380
|
+
}, s = (e) => {
|
|
1381
|
+
e.buttons === 1 && o(e.clientX, e.clientY);
|
|
1382
|
+
}, c = (e) => {
|
|
1383
|
+
window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", c), o(e.clientX, e.clientY);
|
|
1384
|
+
let t = tt.current?.targetDataIndex;
|
|
1385
|
+
a(null), t !== void 0 && Q((e) => T(e, i, t));
|
|
1386
|
+
};
|
|
1387
|
+
o(e.clientX, e.clientY), window.addEventListener("pointermove", s), window.addEventListener("pointerup", c);
|
|
1388
|
+
}, Jn = xt ? $.find((e) => e.id === xt) : void 0, Yn = J ? X.columnGroups.find((e) => e.id === J) : void 0, Xn = Jn?.label ?? Yn?.label, Zn = (e, t) => {
|
|
1389
|
+
if (e.kind === "group") return /* @__PURE__ */ P("th", {
|
|
1390
|
+
className: ["comins-table__th comins-table__group-th px-3 py-2 text-left font-semibold", J === e.groupId ? "comins-column-moving" : void 0].filter(Boolean).join(" "),
|
|
1391
|
+
colSpan: e.colSpan,
|
|
1392
|
+
"data-column-moving": J === e.groupId ? "true" : void 0,
|
|
1393
|
+
"data-comins-column-group-id": e.groupId,
|
|
1394
|
+
"data-testid": `header-group-${e.groupId}`,
|
|
1395
|
+
onPointerDown: (t) => Rn(t, e.group),
|
|
1396
|
+
rowSpan: e.rowSpan,
|
|
1397
|
+
scope: "colgroup",
|
|
1398
|
+
children: [
|
|
1399
|
+
/* @__PURE__ */ N("span", {
|
|
1400
|
+
"aria-hidden": "true",
|
|
1401
|
+
className: "comins-column-drop-marker"
|
|
1402
|
+
}),
|
|
1403
|
+
/* @__PURE__ */ N("span", {
|
|
1404
|
+
className: "comins-table__header-content",
|
|
1405
|
+
"data-comins-header-body": "true",
|
|
1406
|
+
children: /* @__PURE__ */ N("span", {
|
|
1407
|
+
className: "comins-table__header-label",
|
|
1408
|
+
children: e.group.label
|
|
1409
|
+
})
|
|
1410
|
+
}),
|
|
1411
|
+
/* @__PURE__ */ N("span", {
|
|
1412
|
+
"aria-hidden": "true",
|
|
1413
|
+
className: "comins-table__resize",
|
|
1414
|
+
"data-resizing": Ut === e.groupId ? "true" : void 0,
|
|
1415
|
+
"data-testid": `resize-group-${e.groupId}`,
|
|
1416
|
+
onClick: (e) => e.stopPropagation(),
|
|
1417
|
+
onPointerDown: (t) => {
|
|
1418
|
+
t.preventDefault(), t.stopPropagation();
|
|
1419
|
+
let n = t.clientX, r = t.currentTarget.closest("th")?.getBoundingClientRect().width, i = /* @__PURE__ */ new Map();
|
|
1420
|
+
for (let t of e.group.children) {
|
|
1421
|
+
let e = $.find((e) => e.id === t);
|
|
1422
|
+
if (!e) continue;
|
|
1423
|
+
let n = Array.from(H.current?.querySelectorAll("[data-comins-column-id]") ?? []).find((t) => t.dataset.cominsColumnId === e.id)?.getBoundingClientRect().width, r = Z.current.columnState[e.id]?.width ?? e.width ?? 160;
|
|
1424
|
+
i.set(e.id, n && Number.isFinite(n) ? n : r);
|
|
1425
|
+
}
|
|
1426
|
+
let a = [...i.values()].reduce((e, t) => e + t, 0), o = r && Number.isFinite(r) ? r : Math.max(1, a);
|
|
1427
|
+
Wt(e.groupId);
|
|
1428
|
+
let s = (t) => {
|
|
1429
|
+
Q((r) => {
|
|
1430
|
+
let a = r;
|
|
1431
|
+
for (let [e, t] of i) a = D(a, e, t);
|
|
1432
|
+
return me(a, e.groupId, o + t.clientX - n);
|
|
1433
|
+
}, { columnLayoutChanged: !0 });
|
|
1434
|
+
}, c = () => {
|
|
1435
|
+
Wt(null), window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", c);
|
|
1436
|
+
};
|
|
1437
|
+
window.addEventListener("pointermove", s), window.addEventListener("pointerup", c);
|
|
1438
|
+
},
|
|
1439
|
+
children: /* @__PURE__ */ N("span", { className: "comins-table__resize-line" })
|
|
1440
|
+
})
|
|
1441
|
+
]
|
|
1442
|
+
}, `group-${e.groupId}`);
|
|
1443
|
+
let n = e.column, r = $.findIndex((e) => e.id === n.id), i = r >= 0 ? r : t, a = X.columnState[n.id], o = n.header?.props ?? {}, s = Mt(X.sort, n.id), c = s === "asc" || s === "desc", l = [
|
|
1444
|
+
"comins-table__th px-3 py-2 text-left font-semibold",
|
|
1445
|
+
xt === n.id ? "comins-column-moving" : void 0,
|
|
1446
|
+
o.className
|
|
1447
|
+
].filter(Boolean).join(" "), u = bt(X, n, i), d = n.header?.renderer ? n.header.renderer(u) : null, f = n.header?.renderer ? [] : wt(n.header?.components, u, "left"), p = n.header?.renderer ? [] : wt(n.header?.components, u, "right"), m = f.length > 0 || p.length > 0;
|
|
1448
|
+
return /* @__PURE__ */ we("th", {
|
|
1449
|
+
...o,
|
|
1450
|
+
className: l,
|
|
1451
|
+
colSpan: e.colSpan,
|
|
1452
|
+
"data-column-drop-target": Pt === n.id ? "true" : void 0,
|
|
1453
|
+
"data-column-moving": xt === n.id ? "true" : void 0,
|
|
1454
|
+
"data-comins-column-id": n.id,
|
|
1455
|
+
"data-comins-column-index": i,
|
|
1456
|
+
"data-sort-direction": X.sort?.columnId === n.id ? X.sort.direction : void 0,
|
|
1457
|
+
"data-sortable": n.sort ? "true" : "false",
|
|
1458
|
+
"data-testid": `header-${n.id}`,
|
|
1459
|
+
"aria-sort": n.sort ? Nt(X.sort, n.id) : void 0,
|
|
1460
|
+
key: `column-${n.id}`,
|
|
1461
|
+
onClick: (e) => {
|
|
1462
|
+
o.onClick?.(e), !(e.defaultPrevented || !n.sort) && Pn(n);
|
|
1463
|
+
},
|
|
1464
|
+
onKeyDown: (e) => {
|
|
1465
|
+
o.onKeyDown?.(e), !(e.defaultPrevented || !n.sort) && (e.key === "Enter" || e.key === " " || e.key === "Spacebar") && (e.preventDefault(), Pn(n));
|
|
1466
|
+
},
|
|
1467
|
+
onPointerDown: (e) => Ln(e, n),
|
|
1468
|
+
rowSpan: e.rowSpan,
|
|
1469
|
+
scope: "col",
|
|
1470
|
+
style: {
|
|
1471
|
+
width: a?.width ?? n.width,
|
|
1472
|
+
...o.style
|
|
1473
|
+
},
|
|
1474
|
+
tabIndex: n.sort ? 0 : void 0
|
|
1475
|
+
}, /* @__PURE__ */ N("span", {
|
|
1476
|
+
"aria-hidden": "true",
|
|
1477
|
+
className: "comins-column-drop-marker"
|
|
1478
|
+
}), /* @__PURE__ */ P("span", {
|
|
1479
|
+
className: "comins-table__header-content",
|
|
1480
|
+
"data-comins-header-body": "true",
|
|
1481
|
+
"data-comins-header-components": m ? "true" : void 0,
|
|
1482
|
+
"data-comins-sort-indicator-visible": c ? "true" : void 0,
|
|
1483
|
+
children: [
|
|
1484
|
+
/* @__PURE__ */ N("span", {
|
|
1485
|
+
className: "comins-table__header-slot",
|
|
1486
|
+
"data-comins-header-slot": "left",
|
|
1487
|
+
children: f
|
|
1488
|
+
}),
|
|
1489
|
+
/* @__PURE__ */ N("span", {
|
|
1490
|
+
className: "comins-table__header-label",
|
|
1491
|
+
children: n.header?.renderer ? d : n.label
|
|
1492
|
+
}),
|
|
1493
|
+
/* @__PURE__ */ N("span", {
|
|
1494
|
+
"aria-hidden": "true",
|
|
1495
|
+
className: "comins-sort-indicator",
|
|
1496
|
+
"data-sort-state": s,
|
|
1497
|
+
"data-sort-visible": c ? "true" : void 0,
|
|
1498
|
+
"data-testid": `sort-indicator-${n.id}`,
|
|
1499
|
+
children: /* @__PURE__ */ N(Ie, {
|
|
1500
|
+
className: "comins-sort-icon",
|
|
1501
|
+
focusable: "false",
|
|
1502
|
+
size: 14,
|
|
1503
|
+
strokeWidth: 2.25
|
|
1504
|
+
})
|
|
1505
|
+
}),
|
|
1506
|
+
/* @__PURE__ */ N("span", {
|
|
1507
|
+
className: "comins-table__header-slot",
|
|
1508
|
+
"data-comins-header-slot": "right",
|
|
1509
|
+
children: p
|
|
1510
|
+
})
|
|
1511
|
+
]
|
|
1512
|
+
}), /* @__PURE__ */ N("span", {
|
|
1513
|
+
"aria-hidden": "true",
|
|
1514
|
+
className: "comins-table__resize",
|
|
1515
|
+
"data-resizing": Ut === n.id ? "true" : void 0,
|
|
1516
|
+
"data-testid": `resize-${n.id}`,
|
|
1517
|
+
onClick: (e) => e.stopPropagation(),
|
|
1518
|
+
onPointerDown: (e) => {
|
|
1519
|
+
e.preventDefault(), e.stopPropagation();
|
|
1520
|
+
let t = e.clientX, r = e.currentTarget.closest("th")?.getBoundingClientRect().width, i = /* @__PURE__ */ new Map();
|
|
1521
|
+
for (let e of $) {
|
|
1522
|
+
let t = Array.from(H.current?.querySelectorAll("[data-comins-column-id]") ?? []).find((t) => t.dataset.cominsColumnId === e.id)?.getBoundingClientRect().width, n = Z.current.columnState[e.id]?.width ?? e.width ?? 160;
|
|
1523
|
+
i.set(e.id, t && Number.isFinite(t) ? t : n);
|
|
1524
|
+
}
|
|
1525
|
+
let o = i.get(n.id) ?? (r && Number.isFinite(r) ? r : a?.width ?? n.width ?? 160);
|
|
1526
|
+
Wt(n.id);
|
|
1527
|
+
let s = (e) => {
|
|
1528
|
+
Q((r) => {
|
|
1529
|
+
let a = r;
|
|
1530
|
+
for (let [e, t] of i) a = D(a, e, t);
|
|
1531
|
+
return kt(a, n.id, Math.max(Et(n), o + e.clientX - t));
|
|
1532
|
+
}, { columnLayoutChanged: !0 });
|
|
1533
|
+
}, c = () => {
|
|
1534
|
+
Wt(null), window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", c);
|
|
1535
|
+
};
|
|
1536
|
+
window.addEventListener("pointermove", s), window.addEventListener("pointerup", c);
|
|
1537
|
+
},
|
|
1538
|
+
children: /* @__PURE__ */ N("span", { className: "comins-table__resize-line" })
|
|
1539
|
+
}));
|
|
1540
|
+
}, Qn = () => /* @__PURE__ */ N("colgroup", { children: $.map((e, t) => /* @__PURE__ */ N("col", { style: { width: pn[t] } }, e.id)) }), $n = () => {
|
|
1541
|
+
Jt((e) => {
|
|
1542
|
+
let t = nt.current;
|
|
1543
|
+
return Math.abs(e - t) > .5 ? t : e;
|
|
1544
|
+
});
|
|
1545
|
+
}, er = (e) => {
|
|
1546
|
+
if (x) {
|
|
1547
|
+
if (!je || Ke.current) return;
|
|
1548
|
+
e.scrollHeight - e.scrollTop - e.clientHeight <= en && tn("scroll");
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
if (!v || !h || pe || !Me) return;
|
|
1552
|
+
let t = Math.max(0, y);
|
|
1553
|
+
if (e.scrollHeight - e.scrollTop - e.clientHeight > t) return;
|
|
1554
|
+
let n = Z.current.rows.length;
|
|
1555
|
+
Ze.current !== n && (Ze.current = n, Me());
|
|
1556
|
+
}, tr = (e) => {
|
|
1557
|
+
let t = e.currentTarget;
|
|
1558
|
+
nt.current = t.scrollTop, er(t), G.current !== null && (window.clearTimeout(G.current), G.current = null), rt.current === null && (rt.current = window.requestAnimationFrame(() => {
|
|
1559
|
+
rt.current = null, $n();
|
|
1560
|
+
}));
|
|
1561
|
+
let n = Math.max(0, t.scrollLeft);
|
|
1562
|
+
if (H.current) {
|
|
1563
|
+
let e = Math.max(0, H.current.scrollWidth - H.current.clientWidth), r = Math.max(0, t.scrollWidth - t.clientWidth);
|
|
1564
|
+
n = Math.min(Math.min(e, r), n), Math.abs(t.scrollLeft - n) > .5 && (t.scrollLeft = n), H.current.scrollLeft = n;
|
|
1565
|
+
}
|
|
1566
|
+
V.current && (V.current.scrollLeft = n);
|
|
1567
|
+
};
|
|
1568
|
+
return /* @__PURE__ */ P("div", {
|
|
1569
|
+
className: [
|
|
1570
|
+
"comins-table comins-typography-base h-full w-full overflow-hidden",
|
|
1571
|
+
dn,
|
|
1572
|
+
un.className,
|
|
1573
|
+
r
|
|
1574
|
+
].filter(Boolean).join(" "),
|
|
1575
|
+
"aria-busy": vn || yn ? "true" : void 0,
|
|
1576
|
+
"data-loading": vn || yn ? "true" : void 0,
|
|
1577
|
+
"data-show-header": On ? "true" : void 0,
|
|
1578
|
+
style: {
|
|
1579
|
+
...un.style,
|
|
1580
|
+
...R
|
|
1581
|
+
},
|
|
1582
|
+
children: [
|
|
1583
|
+
On ? /* @__PURE__ */ N("div", {
|
|
1584
|
+
className: "comins-table__header",
|
|
1585
|
+
ref: H,
|
|
1586
|
+
children: /* @__PURE__ */ P("table", {
|
|
1587
|
+
className: "comins-table__table comins-table__header-table min-w-full table-fixed",
|
|
1588
|
+
style: { width: hn },
|
|
1589
|
+
children: [Qn(), /* @__PURE__ */ N("thead", {
|
|
1590
|
+
className: "comins-table__thead",
|
|
1591
|
+
children: rn.map((e, t) => /* @__PURE__ */ N("tr", { children: e.map((e, t) => Zn(e, t)) }, `header-row-${t}`))
|
|
1592
|
+
})]
|
|
1593
|
+
})
|
|
1594
|
+
}) : null,
|
|
1595
|
+
/* @__PURE__ */ P("div", {
|
|
1596
|
+
className: "comins-table__body-viewport",
|
|
1597
|
+
"data-horizontal-overflow": gn ? "true" : void 0,
|
|
1598
|
+
"data-virtualized": B ? "true" : void 0,
|
|
1599
|
+
"data-testid": f,
|
|
1600
|
+
onScroll: tr,
|
|
1601
|
+
ref: Be,
|
|
1602
|
+
children: [
|
|
1603
|
+
/* @__PURE__ */ P("table", {
|
|
1604
|
+
className: ["comins-table__table comins-table__body-table min-w-full table-fixed", B ? "comins-table__body-table--virtualized" : void 0].filter(Boolean).join(" "),
|
|
1605
|
+
style: B ? {
|
|
1606
|
+
transform: `translate3d(0, ${ln.renderOffset}px, 0)`,
|
|
1607
|
+
width: hn
|
|
1608
|
+
} : { width: hn },
|
|
1609
|
+
children: [Qn(), /* @__PURE__ */ P("tbody", { children: [
|
|
1610
|
+
xn ? Array.from({ length: wn }).map((e, t) => /* @__PURE__ */ N("tr", {
|
|
1611
|
+
"aria-hidden": "true",
|
|
1612
|
+
className: "comins-table__tr comins-table__skeleton-row",
|
|
1613
|
+
"data-comins-row-parity": t % 2 == 0 ? "even" : "odd",
|
|
1614
|
+
"data-testid": "loading-skeleton-row",
|
|
1615
|
+
style: { height: I },
|
|
1616
|
+
children: $.length > 0 ? $.map((e) => /* @__PURE__ */ N("td", {
|
|
1617
|
+
className: "comins-table__td comins-table__skeleton-cell px-3 py-2",
|
|
1618
|
+
"data-testid": `loading-skeleton-cell-${t}-${e.id}`,
|
|
1619
|
+
style: { height: I },
|
|
1620
|
+
children: /* @__PURE__ */ N("span", { className: "comins-table__skeleton-block" })
|
|
1621
|
+
}, e.id)) : /* @__PURE__ */ N("td", {
|
|
1622
|
+
className: "comins-table__td comins-table__skeleton-cell px-3 py-2",
|
|
1623
|
+
children: /* @__PURE__ */ N("span", { className: "comins-table__skeleton-block" })
|
|
1624
|
+
})
|
|
1625
|
+
}, `loading-skeleton-${t}`)) : null,
|
|
1626
|
+
Sn ? /* @__PURE__ */ N("tr", {
|
|
1627
|
+
className: "comins-table__tr comins-table__empty-state-row",
|
|
1628
|
+
style: { height: I },
|
|
1629
|
+
children: /* @__PURE__ */ N("td", {
|
|
1630
|
+
className: "comins-table__td comins-table__empty-state-cell",
|
|
1631
|
+
colSpan: Math.max(1, $.length),
|
|
1632
|
+
children: /* @__PURE__ */ N("div", {
|
|
1633
|
+
"data-testid": "data-table-empty-state",
|
|
1634
|
+
className: "comins-table__empty-state",
|
|
1635
|
+
children: p ?? "표시할 데이터가 없습니다."
|
|
1636
|
+
})
|
|
1637
|
+
})
|
|
1638
|
+
}) : null,
|
|
1639
|
+
ln.entries.map((e, t) => {
|
|
1640
|
+
let r = ot(Pe, e.row, e.visibleIndex), i = fn.has(e.rowId), a = Dn === 0 && t === ln.entries.length - 1, o = st(r.style), s = B ? `virtual-row-slot-${t}` : String(e.rowId);
|
|
1641
|
+
return /* @__PURE__ */ P(Se, { children: [Gt?.targetDataIndex === e.dataIndex && Gt.sourceRowId !== e.rowId ? /* @__PURE__ */ N("tr", {
|
|
1642
|
+
"aria-hidden": "true",
|
|
1643
|
+
className: "comins-row-move-placeholder",
|
|
1644
|
+
children: /* @__PURE__ */ N("td", {
|
|
1645
|
+
colSpan: Math.max(1, $.length),
|
|
1646
|
+
"data-testid": "row-move-placeholder",
|
|
1647
|
+
children: "이 위치로 이동"
|
|
1648
|
+
})
|
|
1649
|
+
}) : null, /* @__PURE__ */ N("tr", {
|
|
1650
|
+
"aria-disabled": r.disabled ? "true" : void 0,
|
|
1651
|
+
"aria-selected": i,
|
|
1652
|
+
className: [
|
|
1653
|
+
"comins-table__tr",
|
|
1654
|
+
a ? "comins-table__tr--viewport-end" : void 0,
|
|
1655
|
+
i ? "comins-row-selected" : void 0,
|
|
1656
|
+
r.className
|
|
1657
|
+
].filter(Boolean).join(" "),
|
|
1658
|
+
"data-disabled": r.disabled ? "true" : void 0,
|
|
1659
|
+
"data-comins-row-custom-background": o === void 0 ? void 0 : "true",
|
|
1660
|
+
"data-comins-row-data-index": e.dataIndex,
|
|
1661
|
+
"data-comins-row-parity": e.visibleIndex % 2 == 0 ? "even" : "odd",
|
|
1662
|
+
"data-row-draggable": r.draggable ? "true" : "false",
|
|
1663
|
+
"data-selected-row": i ? "true" : void 0,
|
|
1664
|
+
"data-testid": `row-${String(e.rowId)}`,
|
|
1665
|
+
draggable: !1,
|
|
1666
|
+
onClick: (t) => {
|
|
1667
|
+
if (r.disabled) {
|
|
1668
|
+
t.preventDefault();
|
|
1669
|
+
return;
|
|
1670
|
+
}
|
|
1671
|
+
t.__cominsCellSelectionHandled || zn(t, e), Ce?.(dt(t, e));
|
|
1672
|
+
},
|
|
1673
|
+
onContextMenu: (t) => {
|
|
1674
|
+
if (r.disabled) {
|
|
1675
|
+
t.preventDefault();
|
|
1676
|
+
return;
|
|
1677
|
+
}
|
|
1678
|
+
Q((t) => E(t, e.rowId)), W.current = e.rowId, Te?.(dt(t, e));
|
|
1679
|
+
},
|
|
1680
|
+
onDoubleClick: (t) => {
|
|
1681
|
+
if (r.disabled) {
|
|
1682
|
+
t.preventDefault();
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
Oe?.(dt(t, e));
|
|
1686
|
+
},
|
|
1687
|
+
onKeyDown: (t) => Bn(t, e, r.disabled),
|
|
1688
|
+
style: ct(I, r.style, o),
|
|
1689
|
+
tabIndex: r.disabled ? -1 : 0,
|
|
1690
|
+
children: $.map((t, a) => {
|
|
1691
|
+
let o = g(X, e.row, t.id), s = {
|
|
1692
|
+
columnId: t.id,
|
|
1693
|
+
rowId: e.rowId
|
|
1694
|
+
}, c = n && C(X, s), l = n && X.selection.cell?.rowId === e.rowId && X.selection.cell.columnId === t.id, u = pt(e, r.disabled, i, X.selection.rowIds.length, t, a, o), d = mt(t, u), f = r.disabled || gt(d, u), p = at(_t(d, u)), m = vt(d, u), h = !!t.cell?.components?.length, _ = yt(t, o, u), v = t.cell?.components?.map((e) => {
|
|
1695
|
+
if (e.type !== "input") return e;
|
|
1696
|
+
let t = e.onValueChange;
|
|
1697
|
+
return {
|
|
1698
|
+
...e,
|
|
1699
|
+
onValueChange: (e) => {
|
|
1700
|
+
Q((t) => xe(t, [{
|
|
1701
|
+
id: e.row.id,
|
|
1702
|
+
patch: (t) => At(t, e.column.field, e.value)
|
|
1703
|
+
}])), t?.(e);
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
}), y = Ct(v, u), b = t.cell?.renderer ? t.cell.renderer(u) : h ? Tt(_, v, u, { showContent: !1 }) : /* @__PURE__ */ N("span", {
|
|
1707
|
+
className: "comins-table__cell-value",
|
|
1708
|
+
children: _
|
|
1709
|
+
}), x = typeof t.cell?.tooltip == "function" ? t.cell.tooltip(u) : t.cell?.tooltip, S = a === 0 ? z?.entriesByRowId.get(e.rowId) : void 0, ee = S ? /* @__PURE__ */ P("span", {
|
|
1710
|
+
className: "comins-tree-cell-content",
|
|
1711
|
+
style: { "--comins-tree-depth": S.depth },
|
|
1712
|
+
children: [S.hasChildren ? /* @__PURE__ */ N("button", {
|
|
1713
|
+
"aria-expanded": S.expanded,
|
|
1714
|
+
"aria-label": `${S.expanded ? "Collapse" : "Expand"} ${String(e.rowId)}`,
|
|
1715
|
+
className: "comins-tree-expander",
|
|
1716
|
+
"data-testid": `tree-expander-${String(e.rowId)}`,
|
|
1717
|
+
onClick: (t) => {
|
|
1718
|
+
t.preventDefault(), t.stopPropagation(), z?.onToggle(e.rowId);
|
|
1719
|
+
},
|
|
1720
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
1721
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
1722
|
+
type: "button",
|
|
1723
|
+
children: S.expanded ? "▾" : "▸"
|
|
1724
|
+
}) : /* @__PURE__ */ N("span", {
|
|
1725
|
+
"aria-hidden": "true",
|
|
1726
|
+
className: "comins-tree-expander-spacer"
|
|
1727
|
+
}), /* @__PURE__ */ N("span", {
|
|
1728
|
+
className: "comins-tree-cell-value",
|
|
1729
|
+
children: b
|
|
1730
|
+
})]
|
|
1731
|
+
}) : b;
|
|
1732
|
+
return /* @__PURE__ */ P("td", {
|
|
1733
|
+
"aria-disabled": f ? "true" : void 0,
|
|
1734
|
+
className: [
|
|
1735
|
+
"comins-table__td px-3 py-2",
|
|
1736
|
+
a === 0 ? "comins-table__td--with-row-handle" : void 0,
|
|
1737
|
+
c ? "comins-cell-range-selected" : void 0,
|
|
1738
|
+
p
|
|
1739
|
+
].filter(Boolean).join(" "),
|
|
1740
|
+
"data-disabled": f ? "true" : void 0,
|
|
1741
|
+
"data-comins-cell-column-id": t.id,
|
|
1742
|
+
"data-comins-component-cell": y.length > 0 ? "true" : void 0,
|
|
1743
|
+
"data-comins-data-index": e.dataIndex,
|
|
1744
|
+
"data-range-selected": c ? "true" : void 0,
|
|
1745
|
+
"data-selected": l ? "true" : void 0,
|
|
1746
|
+
"data-testid": `cell-${String(e.rowId)}-${t.id}`,
|
|
1747
|
+
draggable: !1,
|
|
1748
|
+
onClick: (r) => {
|
|
1749
|
+
if (be && r.stopPropagation(), f) {
|
|
1750
|
+
r.preventDefault(), r.stopPropagation();
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
if (et.current) {
|
|
1754
|
+
et.current = !1, r.__cominsCellSelectionHandled = !0;
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
let i = n ? X.selection.cell ?? We.current : null;
|
|
1758
|
+
if (r.shiftKey && i) {
|
|
1759
|
+
r.__cominsCellSelectionHandled = !0, We.current = i, Q((t) => ue(W.current === null ? E(t, e.rowId) : de(t, jn(t, W.current, e.rowId)), {
|
|
1760
|
+
anchor: i,
|
|
1761
|
+
focus: s
|
|
1762
|
+
})), W.current = e.rowId;
|
|
1763
|
+
return;
|
|
1764
|
+
}
|
|
1765
|
+
n && (We.current = s), Q((t) => {
|
|
1766
|
+
let i = E(t, e.rowId, {
|
|
1767
|
+
multi: r.ctrlKey || r.metaKey,
|
|
1768
|
+
toggle: r.ctrlKey || r.metaKey
|
|
1769
|
+
});
|
|
1770
|
+
return n ? le(i, s) : i;
|
|
1771
|
+
}), r.__cominsCellSelectionHandled = !0, W.current = e.rowId, be?.(ft(r, e, t, a, o));
|
|
1772
|
+
},
|
|
1773
|
+
onContextMenu: (r) => {
|
|
1774
|
+
if (f) {
|
|
1775
|
+
r.preventDefault(), r.stopPropagation();
|
|
1776
|
+
return;
|
|
1777
|
+
}
|
|
1778
|
+
Q((t) => {
|
|
1779
|
+
let r = E(t, e.rowId);
|
|
1780
|
+
return n ? le(r, s) : r;
|
|
1781
|
+
}), W.current = e.rowId, n && (We.current = s), O && (r.stopPropagation(), O(ft(r, e, t, a, o)));
|
|
1782
|
+
},
|
|
1783
|
+
onDoubleClick: (n) => {
|
|
1784
|
+
if (Ee && n.stopPropagation(), f) {
|
|
1785
|
+
n.preventDefault(), n.stopPropagation();
|
|
1786
|
+
return;
|
|
1787
|
+
}
|
|
1788
|
+
Ee?.(ft(n, e, t, a, o));
|
|
1789
|
+
},
|
|
1790
|
+
onKeyDown: (n) => Vn(n, e, t, a, s, f),
|
|
1791
|
+
onMouseDown: (e) => Hn(e, s, f),
|
|
1792
|
+
onMouseOver: () => Wn(s),
|
|
1793
|
+
onMouseUp: Gn,
|
|
1794
|
+
onPointerDown: (e) => Kn(e, s, f),
|
|
1795
|
+
onPointerEnter: () => Wn(s),
|
|
1796
|
+
onPointerMove: (e) => {
|
|
1797
|
+
e.buttons === 1 && Wn(s);
|
|
1798
|
+
},
|
|
1799
|
+
onPointerUp: Gn,
|
|
1800
|
+
style: {
|
|
1801
|
+
height: I,
|
|
1802
|
+
...m
|
|
1803
|
+
},
|
|
1804
|
+
title: typeof x == "string" ? x : void 0,
|
|
1805
|
+
tabIndex: f ? -1 : 0,
|
|
1806
|
+
children: [a === 0 && r.draggable ? /* @__PURE__ */ N("span", {
|
|
1807
|
+
"aria-hidden": "true",
|
|
1808
|
+
className: "comins-row-drag-handle",
|
|
1809
|
+
"data-testid": `row-drag-handle-${String(e.rowId)}`,
|
|
1810
|
+
draggable: !1,
|
|
1811
|
+
onClick: (e) => e.stopPropagation(),
|
|
1812
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
1813
|
+
onPointerDown: (t) => qn(t, e, r.disabled, r.draggable)
|
|
1814
|
+
}) : null, ee]
|
|
1815
|
+
}, t.id);
|
|
1816
|
+
})
|
|
1817
|
+
}, s)] }, s);
|
|
1818
|
+
}),
|
|
1819
|
+
Cn ? /* @__PURE__ */ N("tr", {
|
|
1820
|
+
className: "comins-table__tr comins-table__infinite-loading-row",
|
|
1821
|
+
style: { height: I },
|
|
1822
|
+
children: /* @__PURE__ */ P("td", {
|
|
1823
|
+
className: "comins-table__td comins-table__infinite-loading-cell",
|
|
1824
|
+
colSpan: Math.max(1, $.length),
|
|
1825
|
+
"data-testid": "data-table-infinite-loading-row",
|
|
1826
|
+
children: [/* @__PURE__ */ N("span", {
|
|
1827
|
+
className: "comins-table__loading-spinner",
|
|
1828
|
+
"data-testid": "data-table-infinite-loading-spinner"
|
|
1829
|
+
}), /* @__PURE__ */ N("span", { children: "데이터를 불러오는 중입니다." })]
|
|
1830
|
+
})
|
|
1831
|
+
}) : null,
|
|
1832
|
+
Dn > 0 ? /* @__PURE__ */ N("tr", {
|
|
1833
|
+
"aria-hidden": "true",
|
|
1834
|
+
className: "comins-table-empty-filler",
|
|
1835
|
+
children: /* @__PURE__ */ N("td", {
|
|
1836
|
+
colSpan: Math.max(1, $.length),
|
|
1837
|
+
"data-testid": "table-empty-filler",
|
|
1838
|
+
style: { height: Dn }
|
|
1839
|
+
})
|
|
1840
|
+
}) : null
|
|
1841
|
+
] })]
|
|
1842
|
+
}),
|
|
1843
|
+
B ? /* @__PURE__ */ N("div", {
|
|
1844
|
+
"aria-hidden": "true",
|
|
1845
|
+
className: "comins-table__body-virtual-sizer",
|
|
1846
|
+
style: {
|
|
1847
|
+
height: ln.scrollHeight,
|
|
1848
|
+
width: hn
|
|
1849
|
+
}
|
|
1850
|
+
}) : null,
|
|
1851
|
+
vn && !bn ? /* @__PURE__ */ P("div", {
|
|
1852
|
+
className: "comins-table__loading-overlay",
|
|
1853
|
+
"data-testid": "data-table-loading-overlay",
|
|
1854
|
+
role: "status",
|
|
1855
|
+
style: qt > 0 ? { transform: `translateY(${qt}px)` } : void 0,
|
|
1856
|
+
children: [/* @__PURE__ */ N("span", {
|
|
1857
|
+
className: "comins-table__loading-spinner",
|
|
1858
|
+
"data-testid": "data-table-loading-spinner"
|
|
1859
|
+
}), /* @__PURE__ */ N("span", { children: ce ?? "불러오는 중입니다." })]
|
|
1860
|
+
}) : null
|
|
1861
|
+
]
|
|
1862
|
+
}),
|
|
1863
|
+
Le ? /* @__PURE__ */ N("div", {
|
|
1864
|
+
"aria-label": "Table summary",
|
|
1865
|
+
className: "comins-table__summary",
|
|
1866
|
+
ref: V,
|
|
1867
|
+
children: /* @__PURE__ */ P("table", {
|
|
1868
|
+
className: "comins-table__table comins-table__summary-table min-w-full table-fixed",
|
|
1869
|
+
style: { width: hn },
|
|
1870
|
+
children: [Qn(), /* @__PURE__ */ N("tfoot", { children: /* @__PURE__ */ N("tr", {
|
|
1871
|
+
className: "comins-table__summary-row",
|
|
1872
|
+
children: $.map((e, t) => /* @__PURE__ */ N("td", {
|
|
1873
|
+
className: "comins-table__summary-cell px-3 py-2",
|
|
1874
|
+
"data-testid": `summary-cell-${e.id}`,
|
|
1875
|
+
children: an?.[e.id] ?? (t === 0 ? Le.label : null)
|
|
1876
|
+
}, e.id))
|
|
1877
|
+
}) })]
|
|
1878
|
+
})
|
|
1879
|
+
}) : null,
|
|
1880
|
+
Xn && Y ? /* @__PURE__ */ N("div", {
|
|
1881
|
+
"aria-hidden": "true",
|
|
1882
|
+
className: "comins-column-move-ghost",
|
|
1883
|
+
"data-testid": "column-move-ghost",
|
|
1884
|
+
style: {
|
|
1885
|
+
left: Y.x + 12,
|
|
1886
|
+
top: Y.y + 12
|
|
1887
|
+
},
|
|
1888
|
+
children: Xn
|
|
1889
|
+
}) : null
|
|
1890
|
+
]
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
function Bt({ data: e, getRowId: t, hasMoreRows: n, infiniteScroll: r, infiniteScrollThreshold: i, lazyLoad: a, lazyLoadBatchSize: o, lazyLoadMode: s, lazyLoadThreshold: c, loadingMore: l, onChangeData: u, onChangeSort: d, onLazyLoad: f, onLoadMore: p, rowProps: m, tree: h, ...g }, _) {
|
|
1894
|
+
let [v, y] = M(null), b = A(() => Rt(e, g.columns, v), [
|
|
1895
|
+
e,
|
|
1896
|
+
g.columns,
|
|
1897
|
+
v
|
|
1898
|
+
]), x = A(() => $e(b, t), [t, b]), S = A(() => new Map(x.map((e) => [e.rowId, e])), [x]), ee = A(() => ({
|
|
1899
|
+
entriesByRowId: S,
|
|
1900
|
+
onToggle: (n) => u?.(tt(e, n, t)),
|
|
1901
|
+
summaryRows: et(e)
|
|
1902
|
+
}), [
|
|
1903
|
+
e,
|
|
1904
|
+
S,
|
|
1905
|
+
t,
|
|
1906
|
+
u
|
|
1907
|
+
]), C = (n) => {
|
|
1908
|
+
let r = e;
|
|
1909
|
+
n.forEach((e, n) => {
|
|
1910
|
+
let i = x[n];
|
|
1911
|
+
i && i.item !== e && (r = nt(r, i.rowId, t, () => e));
|
|
1912
|
+
}), r !== e && u?.([...r]);
|
|
1913
|
+
};
|
|
1914
|
+
return /* @__PURE__ */ N(Vt, {
|
|
1915
|
+
...g,
|
|
1916
|
+
data: x.map((e) => e.item),
|
|
1917
|
+
getRowId: t,
|
|
1918
|
+
hasMoreRows: !1,
|
|
1919
|
+
infiniteScroll: !1,
|
|
1920
|
+
infiniteScrollThreshold: void 0,
|
|
1921
|
+
lazyLoad: !1,
|
|
1922
|
+
lazyLoadBatchSize: void 0,
|
|
1923
|
+
lazyLoadMode: void 0,
|
|
1924
|
+
lazyLoadThreshold: void 0,
|
|
1925
|
+
loadingMore: !1,
|
|
1926
|
+
onChangeData: C,
|
|
1927
|
+
onChangeSort: (e) => {
|
|
1928
|
+
y(e), d?.(e);
|
|
1929
|
+
},
|
|
1930
|
+
onLazyLoad: void 0,
|
|
1931
|
+
onLoadMore: void 0,
|
|
1932
|
+
pagination: {
|
|
1933
|
+
pageIndex: 0,
|
|
1934
|
+
pageSize: Math.max(1, x.length)
|
|
1935
|
+
},
|
|
1936
|
+
rowProps: {
|
|
1937
|
+
...m,
|
|
1938
|
+
draggable: !1
|
|
1939
|
+
},
|
|
1940
|
+
tree: !1,
|
|
1941
|
+
ref: _,
|
|
1942
|
+
treeContext: ee
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
var Vt = O(zt), Ht = O(Bt);
|
|
1946
|
+
function Ut(e, t) {
|
|
1947
|
+
return e.tree ? /* @__PURE__ */ N(Ht, {
|
|
1948
|
+
...e,
|
|
1949
|
+
ref: t
|
|
1950
|
+
}) : /* @__PURE__ */ N(Vt, {
|
|
1951
|
+
...e,
|
|
1952
|
+
ref: t
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
var Wt = O(Ut), Gt = "comins-table";
|
|
1956
|
+
//#endregion
|
|
1957
|
+
export { Wt as CominsTable, e as addCominsRows, t as applyCominsColumnLayout, n as clearCominsCellRange, r as clearCominsSelection, i as clearCominsSortState, Gt 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, $e 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, Xe as getCominsSummaryValues, et as getCominsTreeLeafItems, x as getCominsVirtualRows, S as getCominsVisibleColumns, ee as isCominsCellDisabled, C as isCominsCellInSelectedRange, te as isCominsCellSelected, ne as isCominsRowSelected, re as moveCominsColumn, w as moveCominsColumnGroup, T as moveCominsRow, ie as pasteCominsCell, ae 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 setCominsSortState, ye as setCominsTableTheme, be as sortCominsRows, G as sortCominsTreeSiblings, tt as toggleCominsTreeNode, xe as updateCominsRows, nt as updateCominsTreeItem };
|
|
1958
|
+
|
|
1959
|
+
//# sourceMappingURL=index.js.map
|