flexi-datagrid 1.2.8 → 1.2.9

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.
Files changed (39) hide show
  1. package/dist/DataTable/DataTable.d.ts +2 -0
  2. package/dist/DataTable/components/FilterDropdown.d.ts +4 -0
  3. package/dist/DataTable/components/GroupZone.d.ts +1 -0
  4. package/dist/DataTable/components/HeaderCell.d.ts +8 -0
  5. package/dist/DataTable/components/Pagination.d.ts +1 -0
  6. package/dist/DataTable/components/PinnedBottomBody.d.ts +1 -0
  7. package/dist/DataTable/components/SettingsMenu.d.ts +4 -0
  8. package/dist/DataTable/components/TableBody.d.ts +1 -0
  9. package/dist/DataTable/components/TableColGroup.d.ts +1 -0
  10. package/dist/DataTable/components/TableHeader.d.ts +1 -0
  11. package/dist/DataTable/components/rows.d.ts +18 -0
  12. package/dist/DataTable/constants.d.ts +11 -0
  13. package/dist/DataTable/context/DataTableContext.d.ts +8 -0
  14. package/dist/DataTable/hooks/index.d.ts +12 -0
  15. package/dist/DataTable/hooks/useAnchoredPosition.d.ts +13 -0
  16. package/dist/DataTable/hooks/useClickOutside.d.ts +5 -0
  17. package/dist/DataTable/hooks/useColumnFilters.d.ts +25 -0
  18. package/dist/DataTable/hooks/useColumnReorder.d.ts +15 -0
  19. package/dist/DataTable/hooks/useColumnResize.d.ts +7 -0
  20. package/dist/DataTable/hooks/useColumnVisibility.d.ts +13 -0
  21. package/dist/DataTable/hooks/useDataTableState.d.ts +87 -0
  22. package/dist/DataTable/hooks/usePagination.d.ts +18 -0
  23. package/dist/DataTable/hooks/usePinnedColumns.d.ts +5 -0
  24. package/dist/DataTable/hooks/useRowGrouping.d.ts +7 -0
  25. package/dist/DataTable/hooks/useSettingsMenu.d.ts +11 -0
  26. package/dist/DataTable/hooks/useSorting.d.ts +6 -0
  27. package/dist/DataTable/hooks/useVirtualRows.d.ts +15 -0
  28. package/dist/DataTable/index.d.ts +2 -0
  29. package/dist/{Datatable.d.ts → DataTable/types.d.ts} +36 -7
  30. package/dist/DataTable/utils/classNames.d.ts +1 -0
  31. package/dist/DataTable/utils/columns.d.ts +12 -0
  32. package/dist/DataTable/utils/grouping.d.ts +5 -0
  33. package/dist/DataTable/utils/pinning.d.ts +12 -0
  34. package/dist/DataTable/utils/records.d.ts +10 -0
  35. package/dist/DataTable/utils/rowSpan.d.ts +7 -0
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.es.js +1165 -865
  38. package/dist/index.umd.js +1 -1
  39. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -1,17 +1,152 @@
1
- import { ArrowDown as e, ArrowUp as t, ArrowUpDown as n, ChevronDown as r, ChevronLeft as i, ChevronRight as a, ChevronsLeft as o, ChevronsRight as s, Filter as ee, Pin as te, PinOff as ne, RotateCcw as re, Settings as ie, X as ae } from "lucide-react";
2
- import { useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
3
- import { createPortal as oe } from "react-dom";
4
- import { Fragment as se, jsx as f, jsxs as p } from "react/jsx-runtime";
5
- //#region src/Datatable.tsx
6
- var m = (e) => {
1
+ import { ArrowDown as e, ArrowUp as t, ArrowUpDown as n, ChevronDown as r, ChevronLeft as i, ChevronRight as a, ChevronsLeft as o, ChevronsRight as s, Filter as c, Pin as l, PinOff as u, RotateCcw as d, Settings as f, X as p } from "lucide-react";
2
+ import { createContext as m, useCallback as h, useContext as g, useEffect as _, useMemo as v, useRef as y, useState as b } from "react";
3
+ import { jsx as x, jsxs as S } from "react/jsx-runtime";
4
+ import { createPortal as C } from "react-dom";
5
+ //#region src/DataTable/context/DataTableContext.tsx
6
+ var w = m(null);
7
+ function T({ value: e, children: t }) {
8
+ return /* @__PURE__ */ x(w.Provider, {
9
+ value: e,
10
+ children: t
11
+ });
12
+ }
13
+ function E() {
14
+ let e = g(w);
15
+ if (!e) throw Error("DataTable components must be rendered inside <DataTable>.");
16
+ return e;
17
+ }
18
+ //#endregion
19
+ //#region src/DataTable/utils/classNames.ts
20
+ var D = (...e) => e.filter(Boolean).join(" ");
21
+ //#endregion
22
+ //#region src/DataTable/components/GroupZone.tsx
23
+ function O() {
24
+ let { groupedColumns: e, columnsByKey: t, addGroup: n, removeGroup: r } = E(), [i, a] = b(!1);
25
+ return /* @__PURE__ */ x("div", {
26
+ onDragOver: (e) => {
27
+ e.preventDefault(), a(!0);
28
+ },
29
+ onDragLeave: () => a(!1),
30
+ onDrop: (e) => {
31
+ e.preventDefault(), a(!1);
32
+ let r = e.dataTransfer.getData("text/plain");
33
+ r && t.has(r) && n(r);
34
+ },
35
+ className: D("flexi-groupzone", i && "flexi-groupzone--dragover"),
36
+ children: e.length === 0 ? /* @__PURE__ */ x("span", {
37
+ className: "flexi-groupzone-hint",
38
+ children: "Drag a column header here to group your records by that field"
39
+ }) : /* @__PURE__ */ S("div", {
40
+ className: "flexi-groupzone-chips",
41
+ children: [/* @__PURE__ */ x("span", {
42
+ className: "flexi-groupzone-label",
43
+ children: "Grouped By:"
44
+ }), e.map((e) => /* @__PURE__ */ S("div", {
45
+ className: "flexi-chip",
46
+ children: [/* @__PURE__ */ x("span", { children: t.get(e)?.header || e }), /* @__PURE__ */ x("button", {
47
+ type: "button",
48
+ onClick: () => r(e),
49
+ className: "flexi-icon-btn flexi-chip-remove",
50
+ children: /* @__PURE__ */ x(p, { className: "flexi-icon-xs" })
51
+ })]
52
+ }, e))]
53
+ })
54
+ });
55
+ }
56
+ //#endregion
57
+ //#region src/DataTable/components/Pagination.tsx
58
+ function k() {
59
+ let { currentPage: e, pageSize: t, totalPages: n, totalCount: r, pageSizeOptions: c, goToPage: l, changePageSize: u } = E();
60
+ return /* @__PURE__ */ S("div", {
61
+ className: "flexi-pagination",
62
+ children: [
63
+ /* @__PURE__ */ S("div", {
64
+ className: "flexi-pagination-size",
65
+ children: [/* @__PURE__ */ x("span", { children: "Rows per page" }), /* @__PURE__ */ x("select", {
66
+ value: t,
67
+ onChange: (e) => u(Number(e.target.value)),
68
+ className: "flexi-pagination-select",
69
+ children: c.map((e) => /* @__PURE__ */ x("option", {
70
+ value: e,
71
+ children: e
72
+ }, e))
73
+ })]
74
+ }),
75
+ /* @__PURE__ */ x("div", {
76
+ className: "flexi-pagination-info",
77
+ children: r === 0 ? "0 of 0" : `${(e - 1) * t + 1}–${Math.min(e * t, r)} of ${r}`
78
+ }),
79
+ /* @__PURE__ */ S("div", {
80
+ className: "flexi-pagination-controls",
81
+ children: [
82
+ /* @__PURE__ */ x("button", {
83
+ type: "button",
84
+ onClick: () => l(1),
85
+ disabled: e === 1,
86
+ className: "flexi-icon-btn",
87
+ title: "First page",
88
+ children: /* @__PURE__ */ x(o, { className: "flexi-icon-sm" })
89
+ }),
90
+ /* @__PURE__ */ x("button", {
91
+ type: "button",
92
+ onClick: () => l(e - 1),
93
+ disabled: e === 1,
94
+ className: "flexi-icon-btn",
95
+ title: "Previous page",
96
+ children: /* @__PURE__ */ x(i, { className: "flexi-icon-sm" })
97
+ }),
98
+ /* @__PURE__ */ S("span", {
99
+ className: "flexi-pagination-page",
100
+ children: [
101
+ "Page ",
102
+ e,
103
+ " of ",
104
+ n
105
+ ]
106
+ }),
107
+ /* @__PURE__ */ x("button", {
108
+ type: "button",
109
+ onClick: () => l(e + 1),
110
+ disabled: e === n,
111
+ className: "flexi-icon-btn",
112
+ title: "Next page",
113
+ children: /* @__PURE__ */ x(a, { className: "flexi-icon-sm" })
114
+ }),
115
+ /* @__PURE__ */ x("button", {
116
+ type: "button",
117
+ onClick: () => l(n),
118
+ disabled: e === n,
119
+ className: "flexi-icon-btn",
120
+ title: "Last page",
121
+ children: /* @__PURE__ */ x(s, { className: "flexi-icon-sm" })
122
+ })
123
+ ]
124
+ })
125
+ ]
126
+ });
127
+ }
128
+ //#endregion
129
+ //#region src/DataTable/constants.ts
130
+ var ee = [
131
+ 10,
132
+ 25,
133
+ 50,
134
+ 100
135
+ ], A = [], j = [], M = (e) => {
7
136
  let t = [];
8
137
  return e.forEach((e) => {
9
- e.children && e.children.length > 0 ? t.push(...m(e.children)) : t.push(e);
138
+ e.children && e.children.length > 0 ? t.push(...M(e.children)) : t.push(e);
10
139
  }), t;
11
- }, h = (...e) => e.filter(Boolean).join(" "), ce = (e) => {
140
+ }, N = (e) => {
12
141
  if (e === !0) return "left";
13
142
  if (e === "left" || e === "right") return e;
14
- }, le = (e, t, n) => {
143
+ }, P = (e) => {
144
+ let t = {};
145
+ return e.forEach((e) => {
146
+ let n = N(e.pinned);
147
+ n && (t[e.key] = n);
148
+ }), t;
149
+ }, F = (e, t, n) => {
15
150
  let r = (e) => {
16
151
  let n = t[e];
17
152
  return n === "left" ? 0 : n === "right" ? 2 : 1;
@@ -26,922 +161,1087 @@ var m = (e) => {
26
161
  children: i(e.children)
27
162
  } : e);
28
163
  return i(e);
29
- }, ue = 48, de = 150, fe = 60;
30
- function g({ columns: g, data: _, rowKey: pe, actions: v, isLoading: me, groupBy: y = !1, defaultGroupBy: he = [], onPinChange: ge, onGroupChange: b, containerStyle: _e, tableStyle: ve, bordered: ye = !1, pinnedBottomRowData: x = [], pinnedRowClassName: be, rowHeight: S = ue, overscan: xe = 8, onColumnResize: Se, onColumnReorder: Ce, rowClassRules: we, onRowClick: Te, rowSpanColumns: C, controlPanel: Ee = !1, defaultDisplayPinnedIcon: De = !0, defaultHiddenColumns: Oe = [], onColumnVisibilityChange: w, pagination: T = !1, defaultPageSize: ke = 10, pageSizeOptions: Ae = [
31
- 10,
32
- 25,
33
- 50,
34
- 100
35
- ], onPageChange: E }) {
36
- let [D, je] = d(null), [O, Me] = d({}), [k, Ne] = d(""), [Pe, Fe] = d(null), [Ie, Le] = d(null), Re = u(/* @__PURE__ */ new Map()), [A, ze] = d(he), [Be, Ve] = d({}), [He, Ue] = d(!1), [j, We] = d({
37
- key: null,
38
- direction: null
39
- }), [Ge, Ke] = d({}), [qe, Je] = d({}), [Ye, Xe] = d(De), [M, Ze] = d(Oe), [N, Qe] = d(!1), $e = u(null), P = u(null), [F, I] = d(1), [L, et] = d(ke), tt = u(null), nt = u(!1), R = u(null), z = l(() => m(g), [g]), [B, rt] = d(() => {
40
- let e = {};
41
- return z.forEach((t) => {
42
- let n = ce(t.pinned);
43
- n && (e[t.key] = n);
44
- }), e;
45
- }), V = l(() => le(g, B, qe), [
46
- g,
47
- B,
48
- qe
49
- ]), H = l(() => {
50
- let e = m(V), t = y ? A : [];
51
- return e.filter((e) => !t.includes(e.key) && !M.includes(e.key));
52
- }, [
53
- V,
54
- A,
55
- y,
56
- M
57
- ]), U = u(null), it = u(null);
58
- c(() => {
59
- function e(e) {
60
- let t = e.target, n = D ? Re.current.get(D) : null;
61
- it.current && !it.current.contains(t) && !(n && n.contains(t)) && (je(null), Ne(""));
62
- }
63
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
64
- }, [D]), c(() => {
65
- if (!N) return;
66
- function e(e) {
67
- let t = e.target;
68
- $e.current && !$e.current.contains(t) && !(P.current && P.current.contains(t)) && Qe(!1);
69
- }
70
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
71
- }, [N]), c(() => {
72
- if (!N) return;
73
- let e = () => {
74
- let e = P.current, t = U.current;
75
- if (!e || !t) return;
76
- let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
77
- Le({
78
- top: n.bottom - r.top + 4,
79
- right: r.right - n.right
80
- });
81
- };
82
- return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
83
- window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
84
- };
85
- }, [N]), c(() => {
86
- if (!D) return;
87
- let e = () => {
88
- let e = Re.current.get(D), t = U.current;
89
- if (!e || !t) return;
90
- let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
91
- Fe({
92
- top: n.bottom - r.top + 4,
93
- left: n.left - r.left
94
- });
95
- };
96
- return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
97
- window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
98
- };
99
- }, [D]);
100
- let at = (e) => typeof pe == "function" ? pe(e) : String(e[pe]), ot = (e, t) => {
101
- if (!we) return;
102
- let n;
103
- for (let r in we) we[r](e, t) && (n = n ? `${n} ${r}` : r);
104
- return n;
105
- }, st = (e) => {
106
- rt((t) => {
107
- let n = t[e], r = n ? n === "left" ? "right" : void 0 : "left", i = { ...t };
108
- return r ? i[e] = r : delete i[e], ge && ge(e, !!r, r), i;
109
- });
110
- }, ct = (e) => {
111
- Ze((t) => {
112
- let n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
113
- return w && w(n), n;
114
- });
115
- }, lt = () => {
116
- Xe(De), Ze(Oe), w && w(Oe);
117
- }, ut = (e) => {
118
- let t = "asc";
119
- j.key === e && (t = j.direction === "asc" ? "desc" : j.direction === "desc" ? null : "asc"), We({
120
- key: t ? e : null,
121
- direction: t
122
- });
123
- }, dt = (e, t, n) => {
124
- if (nt.current) {
125
- e.preventDefault();
126
- return;
127
- }
128
- tt.current = t, n && e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move";
129
- }, ft = (e, t, n) => {
130
- let r = e.map((e) => e.key);
131
- if (r.includes(t) && r.includes(n)) return e;
132
- for (let r of e) if (r.children && r.children.length > 0) {
133
- let e = ft(r.children, t, n);
134
- if (e) return e;
135
- }
136
- return null;
137
- }, pt = (e, t) => {
138
- e.preventDefault(), e.stopPropagation();
139
- let n = tt.current;
140
- if (tt.current = null, !n || n === t) return;
141
- let r = ft(V, n, t);
142
- if (!r) return;
143
- let i = r.map((e) => e.key), a = i.indexOf(n), o = i.indexOf(t);
144
- i.splice(o, 0, i.splice(a, 1)[0]);
145
- let s = { ...qe };
146
- i.forEach((e, t) => {
147
- s[e] = t;
148
- }), Je(s), Ce && Ce(m(le(g, B, s)).map((e) => e.key));
149
- }, mt = (e, t) => {
150
- e.preventDefault(), e.stopPropagation(), nt.current = !0, R.current = {
151
- key: t.key,
152
- startX: e.clientX,
153
- startWidth: W(t)
154
- };
155
- let n = t.minWidth ?? fe, r = t.maxWidth, i = (e) => {
156
- let t = R.current;
157
- if (!t) return;
158
- let i = t.startWidth + (e.clientX - t.startX);
159
- i = Math.max(n, i), r && (i = Math.min(r, i)), Ke((e) => e[t.key] === i ? e : {
160
- ...e,
161
- [t.key]: i
162
- });
163
- }, a = () => {
164
- let e = R.current;
165
- R.current = null, window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a), requestAnimationFrame(() => {
166
- nt.current = !1;
167
- }), e && Se && Ke((t) => (t[e.key] !== void 0 && Se(e.key, t[e.key]), t));
168
- };
169
- window.addEventListener("mousemove", i), window.addEventListener("mouseup", a);
170
- }, ht = (e) => {
171
- e.preventDefault(), Ue(!1);
172
- let t = e.dataTransfer.getData("text/plain");
173
- if (t && !A.includes(t)) {
174
- let e = [...A, t];
175
- ze(e), b && b(e);
176
- }
177
- }, gt = (e) => {
178
- let t = A.filter((t) => t !== e);
179
- ze(t), Ve({}), b && b(t);
180
- }, _t = l(() => {
181
- let e = (t) => {
182
- let n = 0;
183
- return t.forEach((t) => {
184
- n = t.children && t.children.length > 0 ? Math.max(n, 1 + e(t.children)) : Math.max(n, 1);
185
- }), n;
186
- }, t = e(V), n = Array.from({ length: t }, () => []), r = (e) => !e.children || e.children.length === 0 ? y && A.includes(e.key) || M.includes(e.key) ? 0 : 1 : e.children.reduce((e, t) => e + r(t), 0), i = y ? A : [], a = (e, o) => {
187
- e.forEach((e) => {
188
- if (i.includes(e.key)) return;
189
- let s = r(e);
190
- s !== 0 && (e.children && e.children.length > 0 ? (n[o].push({
191
- col: e,
192
- rowSpan: 1,
193
- colSpan: s
194
- }), a(e.children, o + 1)) : n[o].push({
195
- col: e,
196
- rowSpan: t - o,
197
- colSpan: 1
198
- }));
199
- });
200
- };
201
- return a(V, 0), n.filter((e) => e.length > 0);
202
- }, [
203
- V,
204
- A,
205
- y,
206
- M
207
- ]), W = (e) => {
208
- if (Ge[e.key] !== void 0) return Ge[e.key];
209
- let t = e.style?.width || e.headerStyle?.width || `${de}px`;
210
- return typeof t == "number" ? t : parseInt(String(t), 10) || de;
211
- }, vt = l(() => {
212
- let e = {}, t = 0;
213
- y && A.length > 0 && (t += 48), H.forEach((n) => {
214
- B[n.key] === "left" && (e[n.key] = {
215
- side: "left",
216
- offset: t
217
- }, t += W(n));
218
- });
219
- let n = v ? 100 : 0;
220
- for (let t = H.length - 1; t >= 0; t--) {
221
- let r = H[t];
222
- B[r.key] === "right" && (e[r.key] = {
223
- side: "right",
224
- offset: n
225
- }, n += W(r));
226
- }
227
- return e;
228
- }, [
229
- H,
230
- B,
231
- A,
232
- y,
233
- v,
234
- Ge
235
- ]), yt = (e, t) => {
236
- Me((n) => {
237
- let r = n[e] || [], i = r.includes(t) ? r.filter((e) => e !== t) : [...r, t], a = {
238
- ...n,
239
- [e]: i
240
- };
241
- return a[e].length === 0 && delete a[e], a;
242
- });
243
- }, bt = (e) => {
244
- Me((t) => {
245
- let n = { ...t };
246
- return delete n[e], n;
247
- });
248
- }, G = l(() => {
249
- let e = /* @__PURE__ */ new Map();
250
- return z.forEach((t) => e.set(t.key, t)), e;
251
- }, [z]), xt = l(() => {
252
- if (!D) return [];
253
- let e = G.get(D), t = _.map((t) => e?.getValue ? e.getValue(t) : t[D]);
254
- return Array.from(new Set(t)).filter((e) => e != null);
255
- }, [
256
- _,
257
- D,
258
- G
259
- ]), St = l(() => {
260
- if (!k.trim()) return xt;
261
- let e = k.toLowerCase();
262
- return xt.filter((t) => String(t).toLowerCase().includes(e));
263
- }, [xt, k]), K = l(() => {
264
- let e = Object.entries(O).filter(([, e]) => e && e.length > 0), t = e.length === 0 ? _ : _.filter((t) => e.every(([e, n]) => {
265
- let r = G.get(e), i = r?.getValue ? r.getValue(t) : t[e];
266
- return n.includes(i);
267
- }));
268
- if (j.key && j.direction) {
269
- let { key: e, direction: n } = j, r = G.get(e);
270
- t = [...t].sort((t, i) => {
271
- let a = r?.getValue ? r.getValue(t) : t[e], o = r?.getValue ? r.getValue(i) : i[e];
272
- if (a === o) return 0;
273
- if (a == null) return 1;
274
- if (o == null) return -1;
275
- let s = 0;
276
- return s = typeof a == "number" && typeof o == "number" ? a - o : String(a).localeCompare(String(o), void 0, {
277
- numeric: !0,
278
- sensitivity: "base"
279
- }), n === "asc" ? s : -s;
280
- });
281
- }
282
- return t;
283
- }, [
284
- _,
285
- O,
286
- j,
287
- G
288
- ]), q = K.length, J = T ? Math.max(1, Math.ceil(q / L)) : 1;
289
- c(() => {
290
- I(1);
291
- }, [
292
- O,
293
- j,
294
- L,
295
- T
296
- ]), c(() => {
297
- F > J && I(J);
298
- }, [F, J]);
299
- let Ct = l(() => {
300
- if (!T) return K;
301
- let e = (F - 1) * L;
302
- return K.slice(e, e + L);
303
- }, [
304
- K,
305
- T,
306
- F,
307
- L
308
- ]), Y = (e) => {
309
- let t = Math.min(Math.max(1, e), J);
310
- I(t), E && E(t, L);
311
- }, wt = (e) => {
312
- et(e), I(1), E && E(1, e);
313
- }, Tt = l(() => {
314
- if (!y || A.length === 0) return Ct;
315
- let e = (t, n, r = "") => {
316
- if (n >= A.length) return t;
317
- let i = A[n], a = G.get(i), o = {};
318
- return t.forEach((e) => {
319
- let t = a?.getValue ? a.getValue(e) : e[i], n = String(t ?? "N/A");
320
- o[n] || (o[n] = []), o[n].push(e);
321
- }), Object.entries(o).sort(([e], [t]) => e.localeCompare(t, void 0, {
322
- numeric: !0,
323
- sensitivity: "base"
324
- })).map(([t, a]) => {
325
- let o = r ? `${r}➔${t}` : t;
326
- return {
327
- isGroupRow: !0,
328
- groupKey: i,
329
- groupValue: t,
330
- path: o,
331
- depth: n,
332
- children: e(a, n + 1, o),
333
- totalItemsCount: a.length
334
- };
335
- });
336
- };
337
- return e(Ct, 0);
338
- }, [
339
- Ct,
340
- A,
341
- y,
342
- G
343
- ]), Et = (e) => {
344
- Ve((t) => {
345
- let n = t[e] !== !1;
346
- return {
347
- ...t,
348
- [e]: !n
349
- };
164
+ }, te = (e, t, n) => {
165
+ let r = e.map((e) => e.key);
166
+ if (r.includes(t) && r.includes(n)) return e;
167
+ for (let r of e) if (r.children && r.children.length > 0) {
168
+ let e = te(r.children, t, n);
169
+ if (e) return e;
170
+ }
171
+ return null;
172
+ }, I = (e, t) => {
173
+ let n = t[e.key];
174
+ if (n !== void 0) return n;
175
+ let r = e.style?.width || e.headerStyle?.width || "150px";
176
+ if (typeof r == "number") return r;
177
+ let i = String(r).trim();
178
+ return /^\d+(\.\d+)?(px)?$/i.test(i) && parseInt(i, 10) || 150;
179
+ }, ne = (e, t, n) => {
180
+ let r = (e) => {
181
+ let t = 0;
182
+ return e.forEach((e) => {
183
+ t = e.children && e.children.length > 0 ? Math.max(t, 1 + r(e.children)) : Math.max(t, 1);
184
+ }), t;
185
+ }, i = r(e), a = Array.from({ length: i }, () => []), o = (e) => !e.children || e.children.length === 0 ? t.includes(e.key) || n.includes(e.key) ? 0 : 1 : e.children.reduce((e, t) => e + o(t), 0), s = (e, n) => {
186
+ e.forEach((e) => {
187
+ if (t.includes(e.key)) return;
188
+ let r = o(e);
189
+ r !== 0 && (e.children && e.children.length > 0 ? (a[n].push({
190
+ col: e,
191
+ rowSpan: 1,
192
+ colSpan: r
193
+ }), s(e.children, n + 1)) : a[n].push({
194
+ col: e,
195
+ rowSpan: i - n,
196
+ colSpan: 1
197
+ }));
350
198
  });
351
- }, X = l(() => {
352
- if (!y || A.length === 0) return Tt;
353
- let e = [], t = (n) => {
354
- n.forEach((n) => {
355
- n.isGroupRow ? (e.push(n), Be[n.path] !== !1 && t(n.children)) : e.push(n);
356
- });
357
- };
358
- return t(Tt), e;
359
- }, [
360
- Tt,
361
- Be,
362
- A,
363
- y
364
- ]), Dt = u(null), [Ot, kt] = d(0), [At, jt] = d(0);
365
- c(() => {
366
- let e = Dt.current;
367
- if (!e) return;
368
- let t = () => kt(e.scrollTop);
369
- jt(e.clientHeight), kt(e.scrollTop), e.addEventListener("scroll", t, { passive: !0 });
370
- let n;
371
- return typeof ResizeObserver < "u" && (n = new ResizeObserver(() => jt(e.clientHeight)), n.observe(e)), () => {
372
- e.removeEventListener("scroll", t), n?.disconnect();
373
- };
374
- }, []);
375
- let Z = X.length, { startIndex: Q, endIndex: Mt, topSpacerHeight: Nt, bottomSpacerHeight: Pt } = l(() => {
376
- if (At === 0) return {
377
- startIndex: 0,
378
- endIndex: Z,
379
- topSpacerHeight: 0,
380
- bottomSpacerHeight: 0
381
- };
382
- let e = Math.max(0, Z - 1), t = Math.min(e, Math.floor(Ot / S)), n = Math.ceil(At / S) + 1, r = Math.max(0, t - xe), i = Math.min(Z, t + n + xe);
383
- return {
384
- startIndex: r,
385
- endIndex: i,
386
- topSpacerHeight: r * S,
387
- bottomSpacerHeight: (Z - i) * S
388
- };
389
- }, [
390
- Ot,
391
- At,
392
- Z,
393
- S,
394
- xe
395
- ]), Ft = l(() => X.slice(Q, Mt), [
396
- X,
397
- Q,
398
- Mt
399
- ]), It = l(() => {
400
- let e = /* @__PURE__ */ new Map();
401
- if (!C || C.length === 0) return e;
402
- let t = (e, t) => {
403
- let n = G.get(t);
404
- return n?.getValue ? n.getValue(e) : e[t];
405
- }, n = Ft, r = n.map(() => C.map(() => !0)), i = null;
406
- for (let e = 0; e < n.length; e++) {
407
- let a = n[e];
408
- if (a.isGroupRow) {
409
- i = null;
410
- continue;
411
- }
412
- if (i !== null) {
413
- let o = n[i], s = !0;
414
- for (let n = 0; n < C.length; n++) {
415
- let i = C[n];
416
- s && t(a, i) === t(o, i) ? r[e][n] = !1 : (s = !1, r[e][n] = !0);
417
- }
418
- }
419
- i = e;
420
- }
421
- return C.forEach((t, i) => {
422
- let a = 0;
423
- for (; a < n.length;) {
424
- if (n[a].isGroupRow || !r[a][i]) {
425
- a++;
426
- continue;
427
- }
428
- let o = a + 1;
429
- for (; o < n.length && !n[o].isGroupRow && !r[o][i];) o++;
430
- if (o - a > 1) {
431
- let n = e.get(Q + a) || {};
432
- n[t] = o - a, e.set(Q + a, n);
433
- for (let n = a + 1; n < o; n++) {
434
- let r = e.get(Q + n) || {};
435
- r[t] = "skip", e.set(Q + n, r);
436
- }
437
- }
438
- a = o;
439
- }
440
- }), e;
441
- }, [
442
- Ft,
443
- C,
444
- G,
445
- Q
446
- ]), Lt = (e, t = !1, n) => {
447
- let r = vt[e];
448
- if (!r) return n || {};
449
- let i = r.side === "right";
450
- return {
199
+ };
200
+ s(e, 0);
201
+ let c = a.filter((e) => e.length > 0);
202
+ return c.map((e, t) => e.map((e) => ({
203
+ ...e,
204
+ rowSpan: Math.min(e.rowSpan, c.length - t)
205
+ })));
206
+ }, re = ({ visibleLeafColumns: e, pinnedColumns: t, columnWidths: n, hasGroups: r, hasActions: i }) => {
207
+ let a = {}, o = r ? 48 : 0;
208
+ e.forEach((e) => {
209
+ t[e.key] === "left" && (a[e.key] = {
210
+ side: "left",
211
+ offset: o
212
+ }, o += I(e, n));
213
+ });
214
+ let s = i ? 100 : 0;
215
+ for (let r = e.length - 1; r >= 0; r--) {
216
+ let i = e[r];
217
+ t[i.key] === "right" && (a[i.key] = {
218
+ side: "right",
219
+ offset: s
220
+ }, s += I(i, n));
221
+ }
222
+ return a;
223
+ }, L = (e, t, n = !1, r) => {
224
+ let i = e[t];
225
+ if (!i) return r || {};
226
+ let a = i.side === "right";
227
+ return {
228
+ position: "sticky",
229
+ [a ? "right" : "left"]: `${i.offset}px`,
230
+ ...n ? { top: 0 } : {},
231
+ zIndex: n ? 30 : 20,
232
+ background: "#f8fafc",
233
+ boxShadow: a ? "-2px 0 5px -2px rgba(0,0,0,0.1)" : "2px 0 5px -2px rgba(0,0,0,0.1)",
234
+ ...r
235
+ };
236
+ }, ie = () => /* @__PURE__ */ x("td", {
237
+ className: "flexi-row-indent-cell",
238
+ style: {
239
+ position: "sticky",
240
+ left: 0,
241
+ zIndex: 10
242
+ }
243
+ });
244
+ function R({ children: e }) {
245
+ return /* @__PURE__ */ x("td", {
246
+ className: "flexi-actions-cell",
247
+ style: {
451
248
  position: "sticky",
452
- [i ? "right" : "left"]: `${r.offset}px`,
453
- ...t ? { top: 0 } : {},
454
- zIndex: t ? 30 : 20,
455
- background: "#f8fafc",
456
- boxShadow: i ? "-2px 0 5px -2px rgba(0,0,0,0.1)" : "2px 0 5px -2px rgba(0,0,0,0.1)",
457
- ...n
458
- };
459
- }, Rt = l(() => x.map((e, t) => (x.length - 1 - t) * 48), [x]), $ = H.length + +!!v + (y && A.length > 0 ? 1 : 0), zt = /* @__PURE__ */ f("button", {
249
+ right: 0
250
+ },
251
+ children: /* @__PURE__ */ x("div", {
252
+ className: "flexi-actions-inner",
253
+ children: e
254
+ })
255
+ });
256
+ }
257
+ function ae({ node: e }) {
258
+ let { rowHeight: t, expandedGroups: n, toggleGroupExpansion: i, totalColumnsCount: o } = E(), s = n[e.path] !== !1;
259
+ return /* @__PURE__ */ S("tr", {
260
+ className: "flexi-group-row",
261
+ style: { height: t },
262
+ children: [/* @__PURE__ */ x("td", {
263
+ className: "flexi-group-cell",
264
+ style: {
265
+ position: "sticky",
266
+ left: 0,
267
+ zIndex: 20,
268
+ backgroundColor: "rgba(248, 250, 252, 0.9)",
269
+ paddingLeft: `${e.depth * 12 + 16}px`
270
+ },
271
+ children: /* @__PURE__ */ S("button", {
272
+ type: "button",
273
+ onClick: () => i(e.path),
274
+ className: "flexi-group-toggle",
275
+ children: [
276
+ x(s ? r : a, { className: "flexi-icon-md flexi-icon-muted" }),
277
+ /* @__PURE__ */ x("span", {
278
+ className: "flexi-group-value",
279
+ children: e.groupValue
280
+ }),
281
+ /* @__PURE__ */ x("span", {
282
+ className: "flexi-group-count",
283
+ children: e.totalItemsCount
284
+ })
285
+ ]
286
+ })
287
+ }), /* @__PURE__ */ x("td", {
288
+ colSpan: Math.max(1, o - 1),
289
+ className: "flexi-group-filler"
290
+ })]
291
+ });
292
+ }
293
+ function oe({ record: e, rowIndex: t, className: n }) {
294
+ let { rowHeight: r, hasGroups: i, hasActions: a, actions: o, onRowClick: s, visibleLeafColumns: c, pinnedColumns: l, pinOffsets: u, rowSpanColumns: d, rowSpanInfo: f } = E(), p = f.get(t);
295
+ return /* @__PURE__ */ S("tr", {
296
+ className: D("flexi-row", s && "flexi-row--clickable", n),
297
+ style: { height: r },
298
+ onClick: s ? (n) => s(e, t, n) : void 0,
299
+ children: [
300
+ i && /* @__PURE__ */ x(ie, {}),
301
+ c.map((t) => {
302
+ let n = d?.includes(t.key) ? p?.[t.key] : void 0;
303
+ if (n === "skip") return null;
304
+ let r = e[t.key];
305
+ return /* @__PURE__ */ x("td", {
306
+ rowSpan: typeof n == "number" ? n : void 0,
307
+ className: D("flexi-cell", !!l[t.key] && "flexi-cell--pinned", t.className),
308
+ style: L(u, t.key, !1, t.style),
309
+ children: t.render ? t.render(r, e) : /* @__PURE__ */ x("span", {
310
+ className: "flexi-cell-text",
311
+ children: r
312
+ })
313
+ }, t.key);
314
+ }),
315
+ a && o && /* @__PURE__ */ x(R, { children: o(e) })
316
+ ]
317
+ });
318
+ }
319
+ function se({ record: e, index: t, className: n }) {
320
+ let { hasGroups: r, hasActions: i, actions: a, pinnedBottomRowData: o, visibleLeafColumns: s, pinnedColumns: c, pinOffsets: l } = E(), u = {
321
+ position: "sticky",
322
+ bottom: `${(o.length - 1 - t) * 48}px`,
323
+ zIndex: 45
324
+ };
325
+ return /* @__PURE__ */ S("tr", {
326
+ className: D("flexi-row", "flexi-row--pinned-bottom", n),
327
+ style: u,
328
+ children: [
329
+ r && /* @__PURE__ */ x(ie, {}),
330
+ s.map((t) => {
331
+ let n = e[t.key], r = t.pinnedRender ?? t.render;
332
+ return /* @__PURE__ */ x("td", {
333
+ className: D("flexi-cell", !!c[t.key] && "flexi-cell--pinned", t.className),
334
+ style: L(l, t.key, !1, t.style),
335
+ children: r ? r(n, e) : /* @__PURE__ */ x("span", {
336
+ className: "flexi-cell-text",
337
+ children: n
338
+ })
339
+ }, t.key);
340
+ }),
341
+ i && a && /* @__PURE__ */ x(R, { children: a(e) })
342
+ ]
343
+ });
344
+ }
345
+ //#endregion
346
+ //#region src/DataTable/components/PinnedBottomBody.tsx
347
+ function z() {
348
+ let { pinnedBottomRowData: e, pinnedRowClassName: t } = E();
349
+ return e.length === 0 ? null : /* @__PURE__ */ x("tbody", {
350
+ className: "flexi-tbody flexi-tbody--pinned-bottom",
351
+ children: e.map((e, n) => /* @__PURE__ */ x(se, {
352
+ record: e,
353
+ index: n,
354
+ className: typeof t == "function" ? t(e, n) : t
355
+ }, `pinned-bottom-row-${n}`))
356
+ });
357
+ }
358
+ //#endregion
359
+ //#region src/DataTable/components/SettingsMenu.tsx
360
+ function B() {
361
+ let { settingsMenu: e } = E();
362
+ return /* @__PURE__ */ x("button", {
460
363
  type: "button",
461
- ref: P,
462
- onClick: (e) => {
463
- e.stopPropagation(), Qe((e) => !e);
364
+ ref: e.buttonRef,
365
+ onClick: (t) => {
366
+ t.stopPropagation(), e.toggle();
464
367
  },
465
- className: h("flexi-icon-btn", N && "flexi-settings-btn--active"),
368
+ className: D("flexi-icon-btn", e.isOpen && "flexi-settings-btn--active"),
466
369
  title: "Grid display settings",
467
- children: /* @__PURE__ */ f(ie, { className: "flexi-icon-sm" })
468
- }), Bt = N && Ie && U.current && oe(/* @__PURE__ */ p("div", {
469
- ref: $e,
370
+ children: /* @__PURE__ */ x(f, { className: "flexi-icon-sm" })
371
+ });
372
+ }
373
+ function V() {
374
+ let { gridRootRef: e, settingsMenu: t, displayPinnedIcon: n, toggleDisplayPinnedIcon: r, initialLeafColumns: i, hiddenColumns: a, toggleColumnVisibility: o, resetControlPanelDefaults: s } = E(), c = e.current;
375
+ return !t.isOpen || !t.position || !c ? null : C(/* @__PURE__ */ S("div", {
376
+ ref: t.menuRef,
470
377
  className: "flexi-settings-menu",
471
378
  style: {
472
- top: Ie.top,
473
- right: Ie.right,
379
+ top: t.position.top,
380
+ right: t.position.right,
474
381
  zIndex: 9999
475
382
  },
476
383
  children: [
477
- /* @__PURE__ */ p("div", {
384
+ /* @__PURE__ */ S("div", {
478
385
  className: "flexi-settings-section",
479
- children: [/* @__PURE__ */ f("span", {
386
+ children: [/* @__PURE__ */ x("span", {
480
387
  className: "flexi-settings-heading",
481
388
  children: "Action Icons"
482
- }), /* @__PURE__ */ p("label", {
389
+ }), /* @__PURE__ */ S("label", {
483
390
  className: "flexi-filter-option",
484
- children: [/* @__PURE__ */ f("input", {
391
+ children: [/* @__PURE__ */ x("input", {
485
392
  type: "checkbox",
486
393
  className: "flexi-checkbox",
487
- checked: Ye,
488
- onChange: () => Xe((e) => !e)
489
- }), /* @__PURE__ */ f("span", {
394
+ checked: n,
395
+ onChange: r
396
+ }), /* @__PURE__ */ x("span", {
490
397
  className: "flexi-filter-option-text",
491
398
  children: "Show pin icon on hover"
492
399
  })]
493
400
  })]
494
401
  }),
495
- /* @__PURE__ */ f("div", { className: "flexi-settings-divider" }),
496
- /* @__PURE__ */ p("div", {
402
+ /* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
403
+ /* @__PURE__ */ S("div", {
497
404
  className: "flexi-settings-section",
498
- children: [/* @__PURE__ */ f("span", {
405
+ children: [/* @__PURE__ */ x("span", {
499
406
  className: "flexi-settings-heading",
500
407
  children: "Columns"
501
- }), z.map((e) => /* @__PURE__ */ p("label", {
408
+ }), i.map((e) => /* @__PURE__ */ S("label", {
502
409
  className: "flexi-filter-option",
503
- children: [/* @__PURE__ */ f("input", {
410
+ children: [/* @__PURE__ */ x("input", {
504
411
  type: "checkbox",
505
412
  className: "flexi-checkbox",
506
- checked: !M.includes(e.key),
507
- onChange: () => ct(e.key)
508
- }), /* @__PURE__ */ f("span", {
413
+ checked: !a.includes(e.key),
414
+ onChange: () => o(e.key)
415
+ }), /* @__PURE__ */ x("span", {
509
416
  className: "flexi-filter-option-text",
510
417
  children: e.header
511
418
  })]
512
419
  }, e.key))]
513
420
  }),
514
- /* @__PURE__ */ f("div", { className: "flexi-settings-divider" }),
515
- /* @__PURE__ */ p("button", {
421
+ /* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
422
+ /* @__PURE__ */ S("button", {
516
423
  type: "button",
517
- onClick: lt,
424
+ onClick: s,
518
425
  className: "flexi-settings-reset",
519
426
  title: "Reset pin icon visibility and hidden columns to their defaults",
520
- children: [/* @__PURE__ */ f(re, { className: "flexi-icon-sm" }), /* @__PURE__ */ f("span", { children: "Reset to defaults" })]
427
+ children: [/* @__PURE__ */ x(d, { className: "flexi-icon-sm" }), /* @__PURE__ */ x("span", { children: "Reset to defaults" })]
521
428
  })
522
429
  ]
523
- }), U.current);
524
- return /* @__PURE__ */ p("div", {
525
- ref: U,
526
- className: "flexi-root",
430
+ }), c);
431
+ }
432
+ //#endregion
433
+ //#region src/DataTable/utils/records.ts
434
+ var H = (e, t, n) => n?.getValue ? n.getValue(e) : e[t], U = (e, t) => {
435
+ let n = typeof t == "function" ? t(e) : e[t];
436
+ return n == null ? void 0 : String(n);
437
+ }, W = (e, t, n) => {
438
+ if (!n) return;
439
+ let r;
440
+ for (let i in n) n[i](e, t) && (r = r ? `${r} ${i}` : i);
441
+ return r;
442
+ }, G = (e, t, n) => {
443
+ let r = e.map((e) => H(e, t, n));
444
+ return Array.from(new Set(r)).filter((e) => e != null);
445
+ }, ce = (e, t, n) => {
446
+ let r = Object.entries(t).filter(([, e]) => e && e.length > 0);
447
+ return r.length === 0 ? e : e.filter((e) => r.every(([t, r]) => r.includes(H(e, t, n.get(t)))));
448
+ }, K = (e) => e == null || typeof e == "number" && Number.isNaN(e), q = (e, t) => typeof e == "number" && typeof t == "number" ? e - t : e instanceof Date && t instanceof Date ? e.getTime() - t.getTime() : String(e).localeCompare(String(t), void 0, {
449
+ numeric: !0,
450
+ sensitivity: "base"
451
+ }), le = (e, t, n, r) => [...e].sort((e, i) => {
452
+ let a = H(e, t, r), o = H(i, t, r);
453
+ if (a === o) return 0;
454
+ let s = K(a), c = K(o);
455
+ if (s && c) return 0;
456
+ if (s) return 1;
457
+ if (c) return -1;
458
+ let l = q(a, o);
459
+ return n === "asc" ? l : -l;
460
+ });
461
+ //#endregion
462
+ //#region src/DataTable/components/TableBody.tsx
463
+ function ue() {
464
+ let { isLoading: e, visibleRows: t, startIndex: n, totalRowCount: r, topSpacerHeight: i, bottomSpacerHeight: a, totalColumnsCount: o, rowKey: s, rowClassRules: c } = E(), l = Math.max(1, o);
465
+ return e || r === 0 ? /* @__PURE__ */ x("tbody", {
466
+ className: "flexi-tbody",
467
+ children: /* @__PURE__ */ x("tr", { children: /* @__PURE__ */ x("td", {
468
+ colSpan: l,
469
+ className: "flexi-empty-cell",
470
+ children: e ? "Loading records..." : "No records found matching criteria."
471
+ }) })
472
+ }) : /* @__PURE__ */ S("tbody", {
473
+ className: "flexi-tbody",
527
474
  children: [
528
- y && /* @__PURE__ */ f("div", {
529
- onDragOver: (e) => {
530
- e.preventDefault(), Ue(!0);
531
- },
532
- onDragLeave: () => Ue(!1),
533
- onDrop: ht,
534
- className: h("flexi-groupzone", He && "flexi-groupzone--dragover"),
535
- children: A.length === 0 ? /* @__PURE__ */ f("span", {
536
- className: "flexi-groupzone-hint",
537
- children: "Drag a column header here to group your records by that field"
538
- }) : /* @__PURE__ */ p("div", {
539
- className: "flexi-groupzone-chips",
540
- children: [/* @__PURE__ */ f("span", {
541
- className: "flexi-groupzone-label",
542
- children: "Grouped By:"
543
- }), A.map((e) => /* @__PURE__ */ p("div", {
544
- className: "flexi-chip",
545
- children: [/* @__PURE__ */ f("span", { children: z.find((t) => t.key === e)?.header || e }), /* @__PURE__ */ f("button", {
546
- type: "button",
547
- onClick: () => gt(e),
548
- className: "flexi-icon-btn flexi-chip-remove",
549
- children: /* @__PURE__ */ f(ae, { className: "flexi-icon-xs" })
550
- })]
551
- }, e))]
475
+ i > 0 && /* @__PURE__ */ x("tr", {
476
+ "aria-hidden": "true",
477
+ style: { height: i },
478
+ children: /* @__PURE__ */ x("td", {
479
+ colSpan: l,
480
+ style: {
481
+ padding: 0,
482
+ border: "none",
483
+ height: i
484
+ }
552
485
  })
553
486
  }),
554
- /* @__PURE__ */ f("div", {
555
- ref: Dt,
556
- className: "flexi-table-wrap",
557
- style: _e,
558
- children: /* @__PURE__ */ p("table", {
559
- className: h("flexi-table", ye && "flexi-table--bordered"),
560
- style: ve,
561
- children: [
562
- /* @__PURE__ */ p("colgroup", { children: [
563
- y && A.length > 0 && /* @__PURE__ */ f("col", { style: { width: "48px" } }),
564
- H.map((e) => /* @__PURE__ */ f("col", { style: {
565
- ...e.style,
566
- width: W(e)
567
- } }, e.key)),
568
- v && /* @__PURE__ */ f("col", { style: { width: "100px" } })
569
- ] }),
570
- /* @__PURE__ */ f("thead", {
571
- className: "flexi-thead",
572
- children: _t.map((r, i) => /* @__PURE__ */ p("tr", {
573
- className: "flexi-header-row",
574
- children: [
575
- i === 0 && y && A.length > 0 && /* @__PURE__ */ f("th", {
576
- rowSpan: _t.length,
577
- className: "flexi-group-spacer-th",
578
- style: {
579
- position: "sticky",
580
- top: 0,
581
- left: 0,
582
- zIndex: 35,
583
- backgroundColor: "rgb(248, 250, 252)"
584
- }
585
- }),
586
- r.map(({ col: a, rowSpan: o, colSpan: s }, re) => {
587
- let ie = (O[a.key]?.length || 0) > 0, ae = !!B[a.key], c = Lt(a.key, !0, a.headerStyle), l = !a.children || a.children.length === 0, u = j.key === a.key, d = !!(y && l), se = l && a.resizable !== !1;
588
- return i === 0 && r.length - 1, /* @__PURE__ */ p("th", {
589
- rowSpan: o,
590
- colSpan: s,
591
- draggable: !0,
592
- onDragStart: (e) => dt(e, a.key, l),
593
- onDragOver: (e) => e.preventDefault(),
594
- onDrop: (e) => pt(e, a.key),
595
- className: h("flexi-th", "flexi-th--draggable", d && "flexi-th--group-draggable", ae && "flexi-th--pinned", a.className, a.headerClassName),
596
- style: c,
597
- children: [/* @__PURE__ */ p("div", {
598
- className: "flexi-th-inner",
599
- children: [
600
- /* @__PURE__ */ p("div", {
601
- className: h("flexi-th-label", a.sortable && l && "flexi-th-label--sortable"),
602
- onClick: () => a.sortable && l && ut(a.key),
603
- children: [/* @__PURE__ */ f("span", {
604
- className: "flexi-th-text",
605
- children: a.header
606
- }), l && a.sortable && /* @__PURE__ */ f("span", {
607
- className: h("flexi-sort-icon", u && "flexi-sort-icon--active"),
608
- children: u && j.direction === "asc" ? /* @__PURE__ */ f(t, { className: "flexi-icon-sm" }) : u && j.direction === "desc" ? /* @__PURE__ */ f(e, { className: "flexi-icon-sm" }) : /* @__PURE__ */ f(n, { className: "flexi-icon-sm" })
609
- })]
610
- }),
611
- /* @__PURE__ */ p("div", {
612
- className: "flexi-th-actions",
613
- children: [l && a.filterable && /* @__PURE__ */ f("button", {
614
- type: "button",
615
- ref: (e) => {
616
- e ? Re.current.set(a.key, e) : Re.current.delete(a.key);
617
- },
618
- onClick: (e) => {
619
- e.stopPropagation(), Ne(""), je(D === a.key ? null : a.key);
620
- },
621
- className: h("flexi-icon-btn", "flexi-filter-btn", ie && "flexi-filter-btn--active"),
622
- children: /* @__PURE__ */ f(ee, { className: "flexi-icon-sm" })
623
- }), l && Ye && /* @__PURE__ */ f("button", {
624
- type: "button",
625
- onClick: (e) => {
626
- e.stopPropagation(), st(a.key);
627
- },
628
- className: h("flexi-icon-btn", "flexi-pin-btn", ae && "flexi-pin-btn--pinned"),
629
- title: B[a.key] === "left" ? "Pinned left (click to pin right)" : B[a.key] === "right" ? "Pinned right (click to unpin)" : "Pin column left",
630
- children: f(ae ? ne : te, { className: "flexi-icon-sm" })
631
- })]
632
- }),
633
- D === a.key && l && Pe && U.current && oe(/* @__PURE__ */ p("div", {
634
- ref: it,
635
- className: "flexi-filter-dropdown",
636
- style: {
637
- top: Pe.top,
638
- left: Pe.left,
639
- zIndex: 9999
640
- },
641
- children: [
642
- /* @__PURE__ */ f("div", {
643
- className: "flexi-filter-search",
644
- children: /* @__PURE__ */ f("input", {
645
- type: "text",
646
- placeholder: "Search values...",
647
- value: k,
648
- onChange: (e) => Ne(e.target.value),
649
- className: "flexi-input",
650
- onClick: (e) => e.stopPropagation()
651
- })
652
- }),
653
- /* @__PURE__ */ f("div", {
654
- className: "flexi-filter-list",
655
- children: St.length === 0 ? /* @__PURE__ */ f("div", {
656
- className: "flexi-filter-empty",
657
- children: "No results found"
658
- }) : St.map((e, t) => /* @__PURE__ */ p("label", {
659
- className: "flexi-filter-option",
660
- children: [/* @__PURE__ */ f("input", {
661
- type: "checkbox",
662
- className: "flexi-checkbox",
663
- checked: O[a.key]?.includes(e) || !1,
664
- onChange: () => yt(a.key, e)
665
- }), /* @__PURE__ */ f("span", {
666
- className: "flexi-filter-option-text",
667
- children: String(e)
668
- })]
669
- }, t))
670
- }),
671
- ie && /* @__PURE__ */ f("div", {
672
- className: "flexi-filter-footer",
673
- children: /* @__PURE__ */ f("button", {
674
- type: "button",
675
- onClick: () => bt(a.key),
676
- className: "flexi-filter-clear",
677
- children: "Clear Filter"
678
- })
679
- })
680
- ]
681
- }), U.current)
682
- ]
683
- }), se && /* @__PURE__ */ f("div", {
684
- className: "flexi-th-resizer",
685
- onMouseDown: (e) => mt(e, a),
686
- onClick: (e) => e.stopPropagation(),
687
- onDragStart: (e) => e.preventDefault()
688
- })]
689
- }, a.key);
690
- }),
691
- Ee && i === 0 && /* @__PURE__ */ f("div", {
692
- className: "flexi-actions-th flexi-th",
693
- style: {
694
- position: "sticky",
695
- top: 0,
696
- right: 0,
697
- zIndex: 55,
698
- display: "flex",
699
- justifyContent: "center",
700
- alignItems: "center"
701
- },
702
- children: Ee && zt
703
- })
704
- ]
705
- }, `header-row-${i}`))
706
- }),
707
- /* @__PURE__ */ f("tbody", {
708
- className: "flexi-tbody",
709
- children: me ? /* @__PURE__ */ f("tr", { children: /* @__PURE__ */ f("td", {
710
- colSpan: $,
711
- className: "flexi-empty-cell",
712
- children: "Loading records..."
713
- }) }) : X.length === 0 ? /* @__PURE__ */ f("tr", { children: /* @__PURE__ */ f("td", {
714
- colSpan: $,
715
- className: "flexi-empty-cell",
716
- children: "No records found matching criteria."
717
- }) }) : /* @__PURE__ */ p(se, { children: [
718
- Nt > 0 && /* @__PURE__ */ f("tr", {
719
- "aria-hidden": "true",
720
- style: { height: Nt },
721
- children: /* @__PURE__ */ f("td", {
722
- colSpan: $,
723
- style: {
724
- padding: 0,
725
- border: "none",
726
- height: Nt
727
- }
728
- })
729
- }),
730
- Ft.map((e, t) => Vt(e, Q + t)),
731
- Pt > 0 && /* @__PURE__ */ f("tr", {
732
- "aria-hidden": "true",
733
- style: { height: Pt },
734
- children: /* @__PURE__ */ f("td", {
735
- colSpan: $,
736
- style: {
737
- padding: 0,
738
- border: "none",
739
- height: Pt
740
- }
741
- })
742
- })
743
- ] })
744
- }),
745
- x.length > 0 && /* @__PURE__ */ f("tbody", {
746
- className: "flexi-tbody flexi-tbody--pinned-bottom",
747
- children: x.map((e, t) => Ht(e, t))
748
- })
749
- ]
750
- })
487
+ t.map((e, t) => {
488
+ let r = n + t;
489
+ return e.kind === "group" ? /* @__PURE__ */ x(ae, { node: e }, `group-header-${e.path}-${r}`) : /* @__PURE__ */ x(oe, {
490
+ record: e.record,
491
+ rowIndex: r,
492
+ className: W(e.record, r, c)
493
+ }, U(e.record, s) ?? `row-${r}`);
751
494
  }),
752
- Bt,
753
- T && /* @__PURE__ */ p("div", {
754
- className: "flexi-pagination",
755
- children: [
756
- /* @__PURE__ */ p("div", {
757
- className: "flexi-pagination-size",
758
- children: [/* @__PURE__ */ f("span", { children: "Rows per page" }), /* @__PURE__ */ f("select", {
759
- value: L,
760
- onChange: (e) => wt(Number(e.target.value)),
761
- className: "flexi-pagination-select",
762
- children: Ae.map((e) => /* @__PURE__ */ f("option", {
763
- value: e,
764
- children: e
765
- }, e))
766
- })]
767
- }),
768
- /* @__PURE__ */ f("div", {
769
- className: "flexi-pagination-info",
770
- children: q === 0 ? "0 of 0" : `${(F - 1) * L + 1}–${Math.min(F * L, q)} of ${q}`
771
- }),
772
- /* @__PURE__ */ p("div", {
773
- className: "flexi-pagination-controls",
774
- children: [
775
- /* @__PURE__ */ f("button", {
776
- type: "button",
777
- onClick: () => Y(1),
778
- disabled: F === 1,
779
- className: "flexi-icon-btn",
780
- title: "First page",
781
- children: /* @__PURE__ */ f(o, { className: "flexi-icon-sm" })
782
- }),
783
- /* @__PURE__ */ f("button", {
784
- type: "button",
785
- onClick: () => Y(F - 1),
786
- disabled: F === 1,
787
- className: "flexi-icon-btn",
788
- title: "Previous page",
789
- children: /* @__PURE__ */ f(i, { className: "flexi-icon-sm" })
790
- }),
791
- /* @__PURE__ */ p("span", {
792
- className: "flexi-pagination-page",
793
- children: [
794
- "Page ",
795
- F,
796
- " of ",
797
- J
798
- ]
799
- }),
800
- /* @__PURE__ */ f("button", {
801
- type: "button",
802
- onClick: () => Y(F + 1),
803
- disabled: F === J,
804
- className: "flexi-icon-btn",
805
- title: "Next page",
806
- children: /* @__PURE__ */ f(a, { className: "flexi-icon-sm" })
807
- }),
808
- /* @__PURE__ */ f("button", {
809
- type: "button",
810
- onClick: () => Y(J),
811
- disabled: F === J,
812
- className: "flexi-icon-btn",
813
- title: "Last page",
814
- children: /* @__PURE__ */ f(s, { className: "flexi-icon-sm" })
815
- })
816
- ]
817
- })
818
- ]
495
+ a > 0 && /* @__PURE__ */ x("tr", {
496
+ "aria-hidden": "true",
497
+ style: { height: a },
498
+ children: /* @__PURE__ */ x("td", {
499
+ colSpan: l,
500
+ style: {
501
+ padding: 0,
502
+ border: "none",
503
+ height: a
504
+ }
505
+ })
819
506
  })
820
507
  ]
821
508
  });
822
- function Vt(e, t) {
823
- if (e.isGroupRow) {
824
- let n = Be[e.path] !== !1;
825
- return /* @__PURE__ */ p("tr", {
826
- className: "flexi-group-row",
827
- style: { height: S },
828
- children: [/* @__PURE__ */ f("td", {
829
- className: "flexi-group-cell",
830
- style: {
831
- position: "sticky",
832
- left: 0,
833
- zIndex: 20,
834
- backgroundColor: "rgba(248, 250, 252, 0.9)",
835
- paddingLeft: `${e.depth * 12 + 16}px`
836
- },
837
- children: /* @__PURE__ */ p("button", {
509
+ }
510
+ //#endregion
511
+ //#region src/DataTable/components/TableColGroup.tsx
512
+ function de() {
513
+ let { hasGroups: e, hasActions: t, visibleLeafColumns: n, columnWidths: r } = E();
514
+ return /* @__PURE__ */ S("colgroup", { children: [
515
+ e && /* @__PURE__ */ x("col", { style: { width: "48px" } }),
516
+ n.map((e) => /* @__PURE__ */ x("col", { style: {
517
+ ...e.style,
518
+ width: I(e, r)
519
+ } }, e.key)),
520
+ t && /* @__PURE__ */ x("col", { style: { width: "100px" } })
521
+ ] });
522
+ }
523
+ //#endregion
524
+ //#region src/DataTable/components/FilterDropdown.tsx
525
+ function J({ columnKey: e }) {
526
+ let { gridRootRef: t, filters: n } = E(), r = t.current, { filterPosition: i } = n;
527
+ if (!r || !i) return null;
528
+ let a = n.selectedFilters[e], o = (a?.length || 0) > 0, s = n.filteredUniqueValues;
529
+ return C(/* @__PURE__ */ S("div", {
530
+ ref: n.dropdownRef,
531
+ className: "flexi-filter-dropdown",
532
+ style: {
533
+ top: i.top,
534
+ left: i.left,
535
+ zIndex: 9999
536
+ },
537
+ children: [
538
+ /* @__PURE__ */ x("div", {
539
+ className: "flexi-filter-search",
540
+ children: /* @__PURE__ */ x("input", {
541
+ type: "text",
542
+ placeholder: "Search values...",
543
+ value: n.filterSearchQuery,
544
+ onChange: (e) => n.setFilterSearchQuery(e.target.value),
545
+ className: "flexi-input",
546
+ onClick: (e) => e.stopPropagation()
547
+ })
548
+ }),
549
+ /* @__PURE__ */ x("div", {
550
+ className: "flexi-filter-list",
551
+ children: s.length === 0 ? /* @__PURE__ */ x("div", {
552
+ className: "flexi-filter-empty",
553
+ children: "No results found"
554
+ }) : s.map((t, r) => /* @__PURE__ */ S("label", {
555
+ className: "flexi-filter-option",
556
+ children: [/* @__PURE__ */ x("input", {
557
+ type: "checkbox",
558
+ className: "flexi-checkbox",
559
+ checked: a?.includes(t) || !1,
560
+ onChange: () => n.handleFilterChange(e, t)
561
+ }), /* @__PURE__ */ x("span", {
562
+ className: "flexi-filter-option-text",
563
+ children: String(t)
564
+ })]
565
+ }, r))
566
+ }),
567
+ o && /* @__PURE__ */ x("div", {
568
+ className: "flexi-filter-footer",
569
+ children: /* @__PURE__ */ x("button", {
570
+ type: "button",
571
+ onClick: () => n.clearFilter(e),
572
+ className: "flexi-filter-clear",
573
+ children: "Clear Filter"
574
+ })
575
+ })
576
+ ]
577
+ }), r);
578
+ }
579
+ //#endregion
580
+ //#region src/DataTable/components/HeaderCell.tsx
581
+ function Y({ col: r, rowSpan: i, colSpan: a }) {
582
+ let { groupBy: o, pinnedColumns: s, pinOffsets: d, displayPinnedIcon: f, togglePin: p, sortState: m, handleSort: h, filters: g, handleDragStart: _, handleDragEnd: v, handleDrop: y, startResize: b } = E(), C = s[r.key], w = !!C, T = (g.selectedFilters[r.key]?.length || 0) > 0, O = !r.children || r.children.length === 0, k = m.key === r.key, ee = o && O, A = O && r.resizable !== !1, j = !!r.sortable && O;
583
+ return /* @__PURE__ */ S("th", {
584
+ rowSpan: i,
585
+ colSpan: a,
586
+ draggable: !0,
587
+ onDragStart: (e) => _(e, r.key, O),
588
+ onDragEnd: v,
589
+ onDragOver: (e) => e.preventDefault(),
590
+ onDrop: (e) => y(e, r.key),
591
+ className: D("flexi-th", "flexi-th--draggable", ee && "flexi-th--group-draggable", w && "flexi-th--pinned", r.className, r.headerClassName),
592
+ style: L(d, r.key, !0, r.headerStyle),
593
+ children: [/* @__PURE__ */ S("div", {
594
+ className: "flexi-th-inner",
595
+ children: [
596
+ /* @__PURE__ */ S("div", {
597
+ className: D("flexi-th-label", j && "flexi-th-label--sortable"),
598
+ onClick: () => j && h(r.key),
599
+ children: [/* @__PURE__ */ x("span", {
600
+ className: "flexi-th-text",
601
+ children: r.header
602
+ }), j && /* @__PURE__ */ x("span", {
603
+ className: D("flexi-sort-icon", k && "flexi-sort-icon--active"),
604
+ children: k && m.direction === "asc" ? /* @__PURE__ */ x(t, { className: "flexi-icon-sm" }) : k && m.direction === "desc" ? /* @__PURE__ */ x(e, { className: "flexi-icon-sm" }) : /* @__PURE__ */ x(n, { className: "flexi-icon-sm" })
605
+ })]
606
+ }),
607
+ /* @__PURE__ */ S("div", {
608
+ className: "flexi-th-actions",
609
+ children: [O && r.filterable && /* @__PURE__ */ x("button", {
838
610
  type: "button",
839
- onClick: () => Et(e.path),
840
- className: "flexi-group-toggle",
841
- children: [
842
- f(n ? r : a, { className: "flexi-icon-md flexi-icon-muted" }),
843
- /* @__PURE__ */ f("span", {
844
- className: "flexi-group-value",
845
- children: e.groupValue
846
- }),
847
- /* @__PURE__ */ f("span", {
848
- className: "flexi-group-count",
849
- children: e.totalItemsCount
850
- })
851
- ]
852
- })
853
- }), /* @__PURE__ */ f("td", {
854
- colSpan: $ - 1,
855
- className: "flexi-group-filler"
856
- })]
857
- }, `group-header-${e.path}-${t}`);
858
- }
859
- let n = at(e);
860
- return /* @__PURE__ */ p("tr", {
861
- className: h("flexi-row", Te && "flexi-row--clickable", ot(e, t)),
862
- style: { height: S },
863
- onClick: Te ? (n) => Te(e, t, n) : void 0,
611
+ ref: (e) => g.registerFilterButton(r.key, e),
612
+ onClick: (e) => {
613
+ e.stopPropagation(), g.toggleFilterDropdown(r.key);
614
+ },
615
+ className: D("flexi-icon-btn", "flexi-filter-btn", T && "flexi-filter-btn--active"),
616
+ children: /* @__PURE__ */ x(c, { className: "flexi-icon-sm" })
617
+ }), O && f && /* @__PURE__ */ x("button", {
618
+ type: "button",
619
+ onClick: (e) => {
620
+ e.stopPropagation(), p(r.key);
621
+ },
622
+ className: D("flexi-icon-btn", "flexi-pin-btn", w && "flexi-pin-btn--pinned"),
623
+ title: C === "left" ? "Pinned left (click to pin right)" : C === "right" ? "Pinned right (click to unpin)" : "Pin column left",
624
+ children: x(w ? u : l, { className: "flexi-icon-sm" })
625
+ })]
626
+ }),
627
+ O && g.activeFilterKey === r.key && /* @__PURE__ */ x(J, { columnKey: r.key })
628
+ ]
629
+ }), A && /* @__PURE__ */ x("div", {
630
+ className: "flexi-th-resizer",
631
+ onMouseDown: (e) => b(e, r),
632
+ onClick: (e) => e.stopPropagation(),
633
+ onDragStart: (e) => e.preventDefault()
634
+ })]
635
+ });
636
+ }
637
+ //#endregion
638
+ //#region src/DataTable/components/TableHeader.tsx
639
+ function fe() {
640
+ let { headerRows: e, hasGroups: t, controlPanel: n } = E(), r = e.length === 0 && n ? [[]] : e;
641
+ return /* @__PURE__ */ x("thead", {
642
+ className: "flexi-thead",
643
+ children: r.map((e, i) => /* @__PURE__ */ S("tr", {
644
+ className: "flexi-header-row",
864
645
  children: [
865
- y && A?.length > 0 && /* @__PURE__ */ f("td", {
866
- className: "flexi-row-indent-cell",
646
+ i === 0 && t && /* @__PURE__ */ x("th", {
647
+ rowSpan: r.length,
648
+ className: "flexi-group-spacer-th",
867
649
  style: {
868
650
  position: "sticky",
651
+ top: 0,
869
652
  left: 0,
870
- zIndex: 10
653
+ zIndex: 35,
654
+ backgroundColor: "rgb(248, 250, 252)"
871
655
  }
872
656
  }),
873
- H?.map((n) => {
874
- let r = C?.includes(n.key) ? It.get(t)?.[n.key] : void 0;
875
- if (r === "skip") return null;
876
- let i = e[n.key], a = Lt(n.key, !1, n.style), o = !!B[n.key];
877
- return /* @__PURE__ */ f("td", {
878
- rowSpan: typeof r == "number" ? r : void 0,
879
- className: h("flexi-cell", o && "flexi-cell--pinned", n.className),
880
- style: a,
881
- children: n.render ? n.render(i, e) : /* @__PURE__ */ f("span", {
882
- className: "flexi-cell-text",
883
- children: i
884
- })
885
- }, n.key);
886
- }),
887
- v && /* @__PURE__ */ f("td", {
888
- className: "flexi-actions-cell",
657
+ e.map(({ col: e, rowSpan: t, colSpan: n }) => /* @__PURE__ */ x(Y, {
658
+ col: e,
659
+ rowSpan: t,
660
+ colSpan: n
661
+ }, e.key)),
662
+ n && i === 0 && /* @__PURE__ */ x("th", {
663
+ className: "flexi-actions-th flexi-th ",
889
664
  style: {
890
- position: "sticky",
891
- right: 0
665
+ right: 0,
666
+ zIndex: 55,
667
+ display: "flex",
668
+ justifyContent: "center",
669
+ alignItems: "center"
892
670
  },
893
- children: /* @__PURE__ */ f("div", {
894
- className: "flexi-actions-inner",
895
- children: v(e)
896
- })
671
+ children: /* @__PURE__ */ x(B, {})
897
672
  })
898
673
  ]
899
- }, n ?? `row-${t}`);
674
+ }, `header-row-${i}`))
675
+ });
676
+ }
677
+ //#endregion
678
+ //#region src/DataTable/utils/grouping.ts
679
+ var pe = (e, t, n, r = 0, i = "") => {
680
+ if (r >= t.length) return e.map((e) => ({
681
+ kind: "record",
682
+ record: e
683
+ }));
684
+ let a = t[r], o = n.get(a), s = /* @__PURE__ */ new Map();
685
+ return e.forEach((e) => {
686
+ let t = String(H(e, a, o) ?? "N/A"), n = s.get(t);
687
+ n ? n.push(e) : s.set(t, [e]);
688
+ }), Array.from(s.entries()).sort(([e], [t]) => e.localeCompare(t, void 0, {
689
+ numeric: !0,
690
+ sensitivity: "base"
691
+ })).map(([e, o]) => {
692
+ let s = i ? `${i}➔${e}` : e;
693
+ return {
694
+ kind: "group",
695
+ groupKey: a,
696
+ groupValue: e,
697
+ path: s,
698
+ depth: r,
699
+ children: pe(o, t, n, r + 1, s),
700
+ totalItemsCount: o.length
701
+ };
702
+ });
703
+ }, me = (e, t) => {
704
+ let n = [], r = (e) => {
705
+ e.forEach((e) => {
706
+ n.push(e), e.kind === "group" && t[e.path] !== !1 && r(e.children);
707
+ });
708
+ };
709
+ return r(e), n;
710
+ }, he = (e, t, n, r) => {
711
+ let i = /* @__PURE__ */ new Map();
712
+ if (!t || t.length === 0) return i;
713
+ let a = e.map(() => t.map(() => !0)), o = null;
714
+ for (let r = 0; r < e.length; r++) {
715
+ let i = e[r];
716
+ if (i.kind === "group") {
717
+ o = null;
718
+ continue;
719
+ }
720
+ let s = o === null ? null : e[o];
721
+ if (s && s.kind === "record") {
722
+ let e = !0;
723
+ for (let o = 0; o < t.length; o++) {
724
+ let c = t[o], l = n.get(c);
725
+ e && H(i.record, c, l) === H(s.record, c, l) ? a[r][o] = !1 : (e = !1, a[r][o] = !0);
726
+ }
727
+ }
728
+ o = r;
900
729
  }
901
- function Ht(e, t) {
902
- let n = typeof be == "function" ? be(e, t) : be, r = {
903
- position: "sticky",
904
- bottom: `${Rt[t]}px`,
905
- background: "#",
906
- zIndex: 45
730
+ return t.forEach((t, n) => {
731
+ let o = 0;
732
+ for (; o < e.length;) {
733
+ if (e[o].kind === "group" || !a[o][n]) {
734
+ o++;
735
+ continue;
736
+ }
737
+ let s = o + 1;
738
+ for (; s < e.length && e[s].kind !== "group" && !a[s][n];) s++;
739
+ if (s - o > 1) {
740
+ let e = i.get(r + o) || {};
741
+ e[t] = s - o, i.set(r + o, e);
742
+ for (let e = o + 1; e < s; e++) {
743
+ let n = i.get(r + e) || {};
744
+ n[t] = "skip", i.set(r + e, n);
745
+ }
746
+ }
747
+ o = s;
748
+ }
749
+ }), i;
750
+ };
751
+ //#endregion
752
+ //#region src/DataTable/hooks/useAnchoredPosition.ts
753
+ function X({ active: e, resetKey: t, rootRef: n, getAnchor: r, compute: i }) {
754
+ let [a, o] = b(null), s = y(r), c = y(i);
755
+ return s.current = r, c.current = i, _(() => {
756
+ if (!e) {
757
+ o(null);
758
+ return;
759
+ }
760
+ let t = () => {
761
+ let e = s.current(), t = n.current;
762
+ !e || !t || o(c.current(e.getBoundingClientRect(), t.getBoundingClientRect()));
763
+ };
764
+ return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
765
+ window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
766
+ };
767
+ }, [
768
+ e,
769
+ t,
770
+ n
771
+ ]), a;
772
+ }
773
+ //#endregion
774
+ //#region src/DataTable/hooks/useClickOutside.ts
775
+ function Z(e, t, n) {
776
+ let r = y(t), i = y(n);
777
+ r.current = t, i.current = n, _(() => {
778
+ if (!e) return;
779
+ let t = (e) => {
780
+ let t = e.target, [n, ...a] = r.current();
781
+ n && (n.contains(t) || a.some((e) => e?.contains(t)) || i.current());
907
782
  };
908
- return /* @__PURE__ */ p("tr", {
909
- className: h("flexi-row", "flexi-row--pinned-bottom", n),
910
- style: r,
783
+ return document.addEventListener("mousedown", t), () => document.removeEventListener("mousedown", t);
784
+ }, [e]);
785
+ }
786
+ //#endregion
787
+ //#region src/DataTable/hooks/useColumnFilters.ts
788
+ function ge({ data: e, columnsByKey: t, gridRootRef: n }) {
789
+ let [r, i] = b(null), [a, o] = b({}), [s, c] = b(""), l = y(/* @__PURE__ */ new Map()), u = y(null), d = h((e, t) => {
790
+ t ? l.current.set(e, t) : l.current.delete(e);
791
+ }, []), f = h(() => {
792
+ i(null), c("");
793
+ }, []), p = h((e) => {
794
+ c(""), i((t) => t === e ? null : e);
795
+ }, []);
796
+ Z(r !== null, () => [u.current, r ? l.current.get(r) : null], f);
797
+ let m = X({
798
+ active: r !== null,
799
+ resetKey: r,
800
+ rootRef: n,
801
+ getAnchor: () => r ? l.current.get(r) : null,
802
+ compute: (e, t) => ({
803
+ top: e.bottom - t.top + 4,
804
+ left: e.left - t.left
805
+ })
806
+ }), g = h((e, t) => {
807
+ o((n) => {
808
+ let r = n[e] || [], i = r.includes(t) ? r.filter((e) => e !== t) : [...r, t], a = {
809
+ ...n,
810
+ [e]: i
811
+ };
812
+ return i.length === 0 && delete a[e], a;
813
+ });
814
+ }, []), _ = h((e) => {
815
+ o((t) => {
816
+ let n = { ...t };
817
+ return delete n[e], n;
818
+ });
819
+ }, []), x = v(() => r ? G(e, r, t.get(r)) : [], [
820
+ e,
821
+ r,
822
+ t
823
+ ]);
824
+ return {
825
+ activeFilterKey: r,
826
+ selectedFilters: a,
827
+ filterSearchQuery: s,
828
+ setFilterSearchQuery: c,
829
+ filterPosition: m,
830
+ dropdownRef: u,
831
+ filteredUniqueValues: v(() => {
832
+ if (!s.trim()) return x;
833
+ let e = s.toLowerCase();
834
+ return x.filter((t) => String(t).toLowerCase().includes(e));
835
+ }, [x, s]),
836
+ registerFilterButton: d,
837
+ toggleFilterDropdown: p,
838
+ handleFilterChange: g,
839
+ clearFilter: _
840
+ };
841
+ }
842
+ //#endregion
843
+ //#region src/DataTable/hooks/useColumnReorder.ts
844
+ function _e({ columns: e, pinnedColumns: t, isResizingRef: n, onColumnReorder: r }) {
845
+ let [i, a] = b({}), o = y(null), s = v(() => F(e, t, i), [
846
+ e,
847
+ t,
848
+ i
849
+ ]);
850
+ return {
851
+ reorderedColumns: s,
852
+ handleDragStart: h((e, t, r) => {
853
+ if (n.current) {
854
+ e.preventDefault();
855
+ return;
856
+ }
857
+ o.current = t, r && e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move";
858
+ }, [n]),
859
+ handleDragEnd: h(() => {
860
+ o.current = null;
861
+ }, []),
862
+ handleDrop: h((n, c) => {
863
+ n.preventDefault(), n.stopPropagation();
864
+ let l = o.current;
865
+ if (o.current = null, !l || l === c) return;
866
+ let u = te(s, l, c);
867
+ if (!u) return;
868
+ let d = u.map((e) => e.key), f = d.indexOf(l), p = d.indexOf(c);
869
+ d.splice(p, 0, d.splice(f, 1)[0]);
870
+ let m = { ...i };
871
+ d.forEach((e, t) => {
872
+ m[e] = t;
873
+ }), a(m), r && r(M(F(e, t, m)).map((e) => e.key));
874
+ }, [
875
+ s,
876
+ i,
877
+ e,
878
+ t,
879
+ r
880
+ ])
881
+ };
882
+ }
883
+ //#endregion
884
+ //#region src/DataTable/hooks/useColumnResize.ts
885
+ function ve(e) {
886
+ let [t, n] = b({}), r = y(!1), i = y(null), a = y(e);
887
+ return a.current = e, _(() => () => i.current?.(), []), {
888
+ columnWidths: t,
889
+ isResizingRef: r,
890
+ startResize: h((e, o) => {
891
+ e.preventDefault(), e.stopPropagation(), i.current?.(), r.current = !0;
892
+ let s = e.clientX, c = I(o, t), l = o.minWidth ?? 60, u = o.maxWidth, d = t[o.key], f = (e) => {
893
+ let t = Math.max(l, c + (e.clientX - s));
894
+ u && (t = Math.min(u, t)), d = t, n((e) => e[o.key] === t ? e : {
895
+ ...e,
896
+ [o.key]: t
897
+ });
898
+ }, p = () => {
899
+ window.removeEventListener("mousemove", f), window.removeEventListener("mouseup", m), i.current = null;
900
+ }, m = () => {
901
+ p(), requestAnimationFrame(() => {
902
+ r.current = !1;
903
+ }), d !== void 0 && a.current?.(o.key, d);
904
+ };
905
+ window.addEventListener("mousemove", f), window.addEventListener("mouseup", m), i.current = () => {
906
+ p(), r.current = !1;
907
+ };
908
+ }, [t])
909
+ };
910
+ }
911
+ //#endregion
912
+ //#region src/DataTable/hooks/useColumnVisibility.ts
913
+ function ye({ defaultHiddenColumns: e, defaultDisplayPinnedIcon: t, onColumnVisibilityChange: n }) {
914
+ let [r, i] = b(e), [a, o] = b(t);
915
+ return {
916
+ hiddenColumns: r,
917
+ displayPinnedIcon: a,
918
+ toggleColumnVisibility: h((e) => {
919
+ let t = r.includes(e) ? r.filter((t) => t !== e) : [...r, e];
920
+ i(t), n?.(t);
921
+ }, [r, n]),
922
+ toggleDisplayPinnedIcon: h(() => o((e) => !e), []),
923
+ resetControlPanelDefaults: h(() => {
924
+ o(t), i(e), n?.(e);
925
+ }, [
926
+ t,
927
+ e,
928
+ n
929
+ ])
930
+ };
931
+ }
932
+ //#endregion
933
+ //#region src/DataTable/hooks/usePagination.ts
934
+ function be({ items: e, enabled: t, defaultPageSize: n, onPageChange: r, resetOn: i }) {
935
+ let [a, o] = b(1), [s, c] = b(Math.max(1, Math.floor(n) || 1)), l = e.length, u = t ? Math.max(1, Math.ceil(l / s)) : 1;
936
+ return _(() => {
937
+ o(1);
938
+ }, [
939
+ ...i,
940
+ s,
941
+ t
942
+ ]), _(() => {
943
+ a > u && o(u);
944
+ }, [a, u]), {
945
+ currentPage: a,
946
+ pageSize: s,
947
+ totalPages: u,
948
+ totalCount: l,
949
+ pagedItems: v(() => {
950
+ if (!t) return e;
951
+ let n = (a - 1) * s;
952
+ return e.slice(n, n + s);
953
+ }, [
954
+ e,
955
+ t,
956
+ a,
957
+ s
958
+ ]),
959
+ goToPage: h((e) => {
960
+ let t = Math.min(Math.max(1, e), u);
961
+ o(t), r?.(t, s);
962
+ }, [
963
+ u,
964
+ s,
965
+ r
966
+ ]),
967
+ changePageSize: h((e) => {
968
+ c(e), o(1), r?.(1, e);
969
+ }, [r])
970
+ };
971
+ }
972
+ //#endregion
973
+ //#region src/DataTable/hooks/usePinnedColumns.ts
974
+ function xe(e, t) {
975
+ let [n, r] = b(() => P(e));
976
+ return {
977
+ pinnedColumns: n,
978
+ togglePin: h((e) => {
979
+ let i = n[e], a = i ? i === "left" ? "right" : void 0 : "left", o = { ...n };
980
+ a ? o[e] = a : delete o[e], r(o), t?.(e, !!a, a);
981
+ }, [n, t])
982
+ };
983
+ }
984
+ //#endregion
985
+ //#region src/DataTable/hooks/useRowGrouping.ts
986
+ function Se(e, t) {
987
+ let [n, r] = b(e), [i, a] = b({});
988
+ return {
989
+ groupedColumns: n,
990
+ expandedGroups: i,
991
+ addGroup: h((e) => {
992
+ if (!e || n.includes(e)) return;
993
+ let i = [...n, e];
994
+ r(i), t?.(i);
995
+ }, [n, t]),
996
+ removeGroup: h((e) => {
997
+ let i = n.filter((t) => t !== e);
998
+ r(i), a({}), t?.(i);
999
+ }, [n, t]),
1000
+ toggleGroupExpansion: h((e) => {
1001
+ a((t) => ({
1002
+ ...t,
1003
+ [e]: t[e] === !1
1004
+ }));
1005
+ }, [])
1006
+ };
1007
+ }
1008
+ //#endregion
1009
+ //#region src/DataTable/hooks/useSettingsMenu.ts
1010
+ function Ce(e) {
1011
+ let [t, n] = b(!1), r = y(null), i = y(null), a = h(() => n((e) => !e), []);
1012
+ return Z(t, () => [r.current, i.current], h(() => n(!1), [])), {
1013
+ isOpen: t,
1014
+ position: X({
1015
+ active: t,
1016
+ rootRef: e,
1017
+ getAnchor: () => i.current,
1018
+ compute: (e, t) => ({
1019
+ top: e.bottom - t.top + 4,
1020
+ right: t.right - e.right
1021
+ })
1022
+ }),
1023
+ menuRef: r,
1024
+ buttonRef: i,
1025
+ toggle: a
1026
+ };
1027
+ }
1028
+ //#endregion
1029
+ //#region src/DataTable/hooks/useSorting.ts
1030
+ function we() {
1031
+ let [e, t] = b({
1032
+ key: null,
1033
+ direction: null
1034
+ });
1035
+ return {
1036
+ sortState: e,
1037
+ handleSort: h((e) => {
1038
+ t((t) => {
1039
+ let n = "asc";
1040
+ return t.key === e && (t.direction === "asc" ? n = "desc" : t.direction === "desc" && (n = null)), {
1041
+ key: n ? e : null,
1042
+ direction: n
1043
+ };
1044
+ });
1045
+ }, [])
1046
+ };
1047
+ }
1048
+ //#endregion
1049
+ //#region src/DataTable/hooks/useVirtualRows.ts
1050
+ function Te({ containerRef: e, totalRowCount: t, rowHeight: n, overscan: r }) {
1051
+ let [i, a] = b(0), [o, s] = b(0);
1052
+ return _(() => {
1053
+ let t = e.current;
1054
+ if (!t) return;
1055
+ let n = () => a(t.scrollTop);
1056
+ s(t.clientHeight), a(t.scrollTop), t.addEventListener("scroll", n, { passive: !0 });
1057
+ let r;
1058
+ return typeof ResizeObserver < "u" && (r = new ResizeObserver(() => s(t.clientHeight)), r.observe(t)), () => {
1059
+ t.removeEventListener("scroll", n), r?.disconnect();
1060
+ };
1061
+ }, [e]), v(() => {
1062
+ if (o === 0) return {
1063
+ startIndex: 0,
1064
+ endIndex: t,
1065
+ topSpacerHeight: 0,
1066
+ bottomSpacerHeight: 0
1067
+ };
1068
+ let e = n > 0 ? n : 1, a = Math.max(0, t - 1), s = Math.min(a, Math.floor(i / e)), c = Math.ceil(o / e) + 1, l = Math.max(0, s - r), u = Math.min(t, s + c + r);
1069
+ return {
1070
+ startIndex: l,
1071
+ endIndex: u,
1072
+ topSpacerHeight: l * e,
1073
+ bottomSpacerHeight: (t - u) * e
1074
+ };
1075
+ }, [
1076
+ i,
1077
+ o,
1078
+ t,
1079
+ n,
1080
+ r
1081
+ ]);
1082
+ }
1083
+ //#endregion
1084
+ //#region src/DataTable/hooks/useDataTableState.ts
1085
+ function Q({ columns: e, data: t, rowKey: n, actions: r, isLoading: i, groupBy: a = !1, defaultGroupBy: o = A, onPinChange: s, onGroupChange: c, pinnedBottomRowData: l = j, pinnedRowClassName: u, rowHeight: d = 48, overscan: f = 8, onColumnResize: p, onColumnReorder: m, rowClassRules: h, onRowClick: g, rowSpanColumns: _, controlPanel: b = !1, defaultDisplayPinnedIcon: x = !0, defaultHiddenColumns: S = A, onColumnVisibilityChange: C, pagination: w = !1, defaultPageSize: T = 10, pageSizeOptions: E = ee, onPageChange: D }) {
1086
+ let O = y(null), k = y(null), N = v(() => M(e), [e]), P = v(() => {
1087
+ let e = /* @__PURE__ */ new Map();
1088
+ return N.forEach((t) => e.set(t.key, t)), e;
1089
+ }, [N]), { pinnedColumns: F, togglePin: te } = xe(N, s), { columnWidths: I, isResizingRef: L, startResize: ie } = ve(p), { reorderedColumns: R, handleDragStart: ae, handleDragEnd: oe, handleDrop: se } = _e({
1090
+ columns: e,
1091
+ pinnedColumns: F,
1092
+ isResizingRef: L,
1093
+ onColumnReorder: m
1094
+ }), z = ye({
1095
+ defaultHiddenColumns: S,
1096
+ defaultDisplayPinnedIcon: x,
1097
+ onColumnVisibilityChange: C
1098
+ }), { hiddenColumns: B } = z, V = Se(o, c), { groupedColumns: H, expandedGroups: U } = V, W = a ? H : A, G = W.length > 0, K = !!r, q = v(() => M(R).filter((e) => !W.includes(e.key) && !B.includes(e.key)), [
1099
+ R,
1100
+ W,
1101
+ B
1102
+ ]), ue = v(() => ne(R, W, B), [
1103
+ R,
1104
+ W,
1105
+ B
1106
+ ]), de = v(() => re({
1107
+ visibleLeafColumns: q,
1108
+ pinnedColumns: F,
1109
+ columnWidths: I,
1110
+ hasGroups: G,
1111
+ hasActions: K
1112
+ }), [
1113
+ q,
1114
+ F,
1115
+ I,
1116
+ G,
1117
+ K
1118
+ ]), J = ge({
1119
+ data: t,
1120
+ columnsByKey: P,
1121
+ gridRootRef: O
1122
+ }), { sortState: Y, handleSort: fe } = we(), X = be({
1123
+ items: v(() => {
1124
+ let e = ce(t, J.selectedFilters, P);
1125
+ return !Y.key || !Y.direction ? e : le(e, Y.key, Y.direction, P.get(Y.key));
1126
+ }, [
1127
+ t,
1128
+ J.selectedFilters,
1129
+ Y,
1130
+ P
1131
+ ]),
1132
+ enabled: w,
1133
+ defaultPageSize: T,
1134
+ onPageChange: D,
1135
+ resetOn: [J.selectedFilters, Y]
1136
+ }), Z = v(() => pe(X.pagedItems, W, P), [
1137
+ X.pagedItems,
1138
+ W,
1139
+ P
1140
+ ]), Q = v(() => me(Z, U), [Z, U]), Ee = Q.length, { startIndex: $, endIndex: De, topSpacerHeight: Oe, bottomSpacerHeight: ke } = Te({
1141
+ containerRef: k,
1142
+ totalRowCount: Ee,
1143
+ rowHeight: d,
1144
+ overscan: f
1145
+ }), Ae = v(() => Q.slice($, De), [
1146
+ Q,
1147
+ $,
1148
+ De
1149
+ ]), je = v(() => he(Ae, _, P, $), [
1150
+ Ae,
1151
+ _,
1152
+ P,
1153
+ $
1154
+ ]), Me = Ce(O), Ne = q.length + +!!K + +!!G;
1155
+ return {
1156
+ gridRootRef: O,
1157
+ tableWrapRef: k,
1158
+ rowKey: n,
1159
+ actions: r,
1160
+ isLoading: !!i,
1161
+ groupBy: a,
1162
+ controlPanel: b,
1163
+ rowHeight: d,
1164
+ rowSpanColumns: _,
1165
+ rowClassRules: h,
1166
+ onRowClick: g,
1167
+ pinnedBottomRowData: l,
1168
+ pinnedRowClassName: u,
1169
+ pageSizeOptions: E,
1170
+ paginationEnabled: w,
1171
+ initialLeafColumns: N,
1172
+ columnsByKey: P,
1173
+ visibleLeafColumns: q,
1174
+ headerRows: ue,
1175
+ pinnedColumns: F,
1176
+ pinOffsets: de,
1177
+ columnWidths: I,
1178
+ togglePin: te,
1179
+ startResize: ie,
1180
+ handleDragStart: ae,
1181
+ handleDragEnd: oe,
1182
+ handleDrop: se,
1183
+ hiddenColumns: B,
1184
+ displayPinnedIcon: z.displayPinnedIcon,
1185
+ toggleColumnVisibility: z.toggleColumnVisibility,
1186
+ toggleDisplayPinnedIcon: z.toggleDisplayPinnedIcon,
1187
+ resetControlPanelDefaults: z.resetControlPanelDefaults,
1188
+ settingsMenu: Me,
1189
+ groupedColumns: H,
1190
+ expandedGroups: U,
1191
+ addGroup: V.addGroup,
1192
+ removeGroup: V.removeGroup,
1193
+ toggleGroupExpansion: V.toggleGroupExpansion,
1194
+ hasGroups: G,
1195
+ hasActions: K,
1196
+ sortState: Y,
1197
+ handleSort: fe,
1198
+ filters: J,
1199
+ currentPage: X.currentPage,
1200
+ pageSize: X.pageSize,
1201
+ totalPages: X.totalPages,
1202
+ totalCount: X.totalCount,
1203
+ goToPage: X.goToPage,
1204
+ changePageSize: X.changePageSize,
1205
+ visibleRows: Ae,
1206
+ startIndex: $,
1207
+ totalRowCount: Ee,
1208
+ topSpacerHeight: Oe,
1209
+ bottomSpacerHeight: ke,
1210
+ rowSpanInfo: je,
1211
+ totalColumnsCount: Ne
1212
+ };
1213
+ }
1214
+ //#endregion
1215
+ //#region src/DataTable/DataTable.tsx
1216
+ function Ee(e) {
1217
+ let t = Q(e), { containerStyle: n, tableStyle: r, bordered: i = !1 } = e;
1218
+ return /* @__PURE__ */ x(T, {
1219
+ value: t,
1220
+ children: /* @__PURE__ */ S("div", {
1221
+ ref: t.gridRootRef,
1222
+ className: "flexi-root",
911
1223
  children: [
912
- y && A?.length > 0 && /* @__PURE__ */ f("td", {
913
- className: "flexi-row-indent-cell",
914
- style: {
915
- position: "sticky",
916
- left: 0,
917
- zIndex: 10
918
- }
919
- }),
920
- H?.map((t) => {
921
- let n = e[t.key], r = Lt(t.key, !1, t.style), i = !!B[t.key], a = t.pinnedRender ?? t.render;
922
- return /* @__PURE__ */ f("td", {
923
- className: h("flexi-cell", i && "flexi-cell--pinned", t.className),
1224
+ t.groupBy && /* @__PURE__ */ x(O, {}),
1225
+ /* @__PURE__ */ x("div", {
1226
+ ref: t.tableWrapRef,
1227
+ className: "flexi-table-wrap",
1228
+ style: n,
1229
+ children: /* @__PURE__ */ S("table", {
1230
+ className: D("flexi-table", i && "flexi-table--bordered"),
924
1231
  style: r,
925
- children: a ? a(n, e) : /* @__PURE__ */ f("span", {
926
- className: "flexi-cell-text",
927
- children: n
928
- })
929
- }, t.key);
930
- }),
931
- v && /* @__PURE__ */ f("td", {
932
- className: "flexi-actions-cell",
933
- style: {
934
- position: "sticky",
935
- right: 0
936
- },
937
- children: /* @__PURE__ */ f("div", {
938
- className: "flexi-actions-inner",
939
- children: v(e)
1232
+ children: [
1233
+ /* @__PURE__ */ x(de, {}),
1234
+ /* @__PURE__ */ x(fe, {}),
1235
+ /* @__PURE__ */ x(ue, {}),
1236
+ /* @__PURE__ */ x(z, {})
1237
+ ]
940
1238
  })
941
- })
1239
+ }),
1240
+ /* @__PURE__ */ x(V, {}),
1241
+ t.paginationEnabled && /* @__PURE__ */ x(k, {})
942
1242
  ]
943
- }, `pinned-bottom-row-${t}`);
944
- }
1243
+ })
1244
+ });
945
1245
  }
946
1246
  //#endregion
947
- export { g as DataTable };
1247
+ export { Ee as DataTable };