flexi-datagrid 1.2.7 → 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 (40) 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/flexi-datagrid.css +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.es.js +1165 -868
  39. package/dist/index.umd.js +1 -1
  40. 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 c } from "lucide-react";
2
- import { useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
3
- import { createPortal as ae } from "react-dom";
4
- import { Fragment as oe, jsx as p, jsxs as m } from "react/jsx-runtime";
5
- //#region src/Datatable.tsx
6
- var h = (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(...h(e.children)) : t.push(e);
138
+ e.children && e.children.length > 0 ? t.push(...M(e.children)) : t.push(e);
10
139
  }), t;
11
- }, g = (...e) => e.filter(Boolean).join(" "), se = (e) => {
140
+ }, N = (e) => {
12
141
  if (e === !0) return "left";
13
142
  if (e === "left" || e === "right") return e;
14
- }, ce = (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,925 +161,1087 @@ var h = (e) => {
26
161
  children: i(e.children)
27
162
  } : e);
28
163
  return i(e);
29
- }, le = 48, ue = 150, de = 60;
30
- function _({ columns: _, data: v, rowKey: fe, actions: y, isLoading: pe, groupBy: b = !1, defaultGroupBy: me = [], onPinChange: he, onGroupChange: x, containerStyle: ge, tableStyle: _e, bordered: ve = !1, pinnedBottomRowData: S = [], pinnedRowClassName: ye, rowHeight: C = le, overscan: be = 8, onColumnResize: xe, onColumnReorder: Se, rowClassRules: Ce, onRowClick: we, rowSpanColumns: w, controlPanel: Te = !1, defaultDisplayPinnedIcon: Ee = !0, defaultHiddenColumns: De = [], onColumnVisibilityChange: T, pagination: E = !1, defaultPageSize: Oe = 10, pageSizeOptions: ke = [
31
- 10,
32
- 25,
33
- 50,
34
- 100
35
- ], onPageChange: D }) {
36
- let [O, Ae] = f(null), [k, je] = f({}), [A, Me] = f(""), [Ne, Pe] = f(null), [Fe, Ie] = f(null), j = d(/* @__PURE__ */ new Map()), [M, Le] = f(me), [Re, ze] = f({}), [Be, Ve] = f(!1), [N, He] = f({
37
- key: null,
38
- direction: null
39
- }), [Ue, We] = f({}), [Ge, Ke] = f({}), [qe, Je] = f(Ee), [P, Ye] = f(De), [F, Xe] = f(!1), Ze = d(null), I = d(null), [L, R] = f(1), [z, Qe] = f(Oe), $e = d(null), et = d(!1), B = d(null), V = u(() => h(_), [_]), [H, tt] = f(() => {
40
- let e = {};
41
- return V.forEach((t) => {
42
- let n = se(t.pinned);
43
- n && (e[t.key] = n);
44
- }), e;
45
- }), U = u(() => ce(_, H, Ge), [
46
- _,
47
- H,
48
- Ge
49
- ]), W = u(() => {
50
- let e = h(U), t = b ? M : [];
51
- return e.filter((e) => !t.includes(e.key) && !P.includes(e.key));
52
- }, [
53
- U,
54
- M,
55
- b,
56
- P
57
- ]), G = d(null), nt = d(null);
58
- l(() => {
59
- function e(e) {
60
- let t = e.target, n = O ? j.current.get(O) : null;
61
- nt.current && !nt.current.contains(t) && !(n && n.contains(t)) && (Ae(null), Me(""));
62
- }
63
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
64
- }, [O]), l(() => {
65
- if (!F) return;
66
- function e(e) {
67
- let t = e.target;
68
- Ze.current && !Ze.current.contains(t) && !(I.current && I.current.contains(t)) && Xe(!1);
69
- }
70
- return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
71
- }, [F]), l(() => {
72
- if (!F) return;
73
- let e = () => {
74
- let e = I.current, t = G.current;
75
- if (!e || !t) return;
76
- let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
77
- Ie({
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
- }, [F]), l(() => {
86
- if (!O) return;
87
- let e = () => {
88
- let e = j.current.get(O), t = G.current;
89
- if (!e || !t) return;
90
- let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
91
- Pe({
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
- }, [O]);
100
- let rt = (e) => typeof fe == "function" ? fe(e) : String(e[fe]), it = (e, t) => {
101
- if (!Ce) return;
102
- let n;
103
- for (let r in Ce) Ce[r](e, t) && (n = n ? `${n} ${r}` : r);
104
- return n;
105
- }, at = (e) => {
106
- tt((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], he && he(e, !!r, r), i;
109
- });
110
- }, ot = (e) => {
111
- Ye((t) => {
112
- let n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
113
- return T && T(n), n;
114
- });
115
- }, st = () => {
116
- Je(Ee), Ye(De), T && T(De);
117
- }, ct = (e) => {
118
- let t = "asc";
119
- N.key === e && (t = N.direction === "asc" ? "desc" : N.direction === "desc" ? null : "asc"), He({
120
- key: t ? e : null,
121
- direction: t
122
- });
123
- }, lt = (e, t, n) => {
124
- if (et.current) {
125
- e.preventDefault();
126
- return;
127
- }
128
- $e.current = t, n && e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move";
129
- }, ut = (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 = ut(r.children, t, n);
134
- if (e) return e;
135
- }
136
- return null;
137
- }, dt = (e, t) => {
138
- e.preventDefault(), e.stopPropagation();
139
- let n = $e.current;
140
- if ($e.current = null, !n || n === t) return;
141
- let r = ut(U, 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 = { ...Ge };
146
- i.forEach((e, t) => {
147
- s[e] = t;
148
- }), Ke(s), Se && Se(h(ce(_, H, s)).map((e) => e.key));
149
- }, ft = (e, t) => {
150
- e.preventDefault(), e.stopPropagation(), et.current = !0, B.current = {
151
- key: t.key,
152
- startX: e.clientX,
153
- startWidth: K(t)
154
- };
155
- let n = t.minWidth ?? de, r = t.maxWidth, i = (e) => {
156
- let t = B.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)), We((e) => e[t.key] === i ? e : {
160
- ...e,
161
- [t.key]: i
162
- });
163
- }, a = () => {
164
- let e = B.current;
165
- B.current = null, window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a), requestAnimationFrame(() => {
166
- et.current = !1;
167
- }), e && xe && We((t) => (t[e.key] !== void 0 && xe(e.key, t[e.key]), t));
168
- };
169
- window.addEventListener("mousemove", i), window.addEventListener("mouseup", a);
170
- }, pt = (e) => {
171
- e.preventDefault(), Ve(!1);
172
- let t = e.dataTransfer.getData("text/plain");
173
- if (t && !M.includes(t)) {
174
- let e = [...M, t];
175
- Le(e), x && x(e);
176
- }
177
- }, mt = (e) => {
178
- let t = M.filter((t) => t !== e);
179
- Le(t), ze({}), x && x(t);
180
- }, ht = u(() => {
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(U), n = Array.from({ length: t }, () => []), r = (e) => !e.children || e.children.length === 0 ? b && M.includes(e.key) || P.includes(e.key) ? 0 : 1 : e.children.reduce((e, t) => e + r(t), 0), i = b ? M : [], 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(U, 0), n.filter((e) => e.length > 0);
202
- }, [
203
- U,
204
- M,
205
- b,
206
- P
207
- ]), K = (e) => {
208
- if (Ue[e.key] !== void 0) return Ue[e.key];
209
- let t = e.style?.width || e.headerStyle?.width || `${ue}px`;
210
- return typeof t == "number" ? t : parseInt(String(t), 10) || ue;
211
- }, gt = u(() => {
212
- let e = {}, t = 0;
213
- b && M.length > 0 && (t += 48), W.forEach((n) => {
214
- H[n.key] === "left" && (e[n.key] = {
215
- side: "left",
216
- offset: t
217
- }, t += K(n));
218
- });
219
- let n = y ? 100 : 0;
220
- for (let t = W.length - 1; t >= 0; t--) {
221
- let r = W[t];
222
- H[r.key] === "right" && (e[r.key] = {
223
- side: "right",
224
- offset: n
225
- }, n += K(r));
226
- }
227
- return e;
228
- }, [
229
- W,
230
- H,
231
- M,
232
- b,
233
- y,
234
- Ue
235
- ]), _t = (e, t) => {
236
- je((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
- }, vt = (e) => {
244
- je((t) => {
245
- let n = { ...t };
246
- return delete n[e], n;
247
- });
248
- }, q = u(() => {
249
- let e = /* @__PURE__ */ new Map();
250
- return V.forEach((t) => e.set(t.key, t)), e;
251
- }, [V]), yt = u(() => {
252
- if (!O) return [];
253
- let e = q.get(O), t = v.map((t) => e?.getValue ? e.getValue(t) : t[O]);
254
- return Array.from(new Set(t)).filter((e) => e != null);
255
- }, [
256
- v,
257
- O,
258
- q
259
- ]), bt = u(() => {
260
- if (!A.trim()) return yt;
261
- let e = A.toLowerCase();
262
- return yt.filter((t) => String(t).toLowerCase().includes(e));
263
- }, [yt, A]), J = u(() => {
264
- let e = Object.entries(k).filter(([, e]) => e && e.length > 0), t = e.length === 0 ? v : v.filter((t) => e.every(([e, n]) => {
265
- let r = q.get(e), i = r?.getValue ? r.getValue(t) : t[e];
266
- return n.includes(i);
267
- }));
268
- if (N.key && N.direction) {
269
- let { key: e, direction: n } = N, r = q.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
- v,
285
- k,
286
- N,
287
- q
288
- ]), Y = J.length, X = E ? Math.max(1, Math.ceil(Y / z)) : 1;
289
- l(() => {
290
- R(1);
291
- }, [
292
- k,
293
- N,
294
- z,
295
- E
296
- ]), l(() => {
297
- L > X && R(X);
298
- }, [L, X]);
299
- let xt = u(() => {
300
- if (!E) return J;
301
- let e = (L - 1) * z;
302
- return J.slice(e, e + z);
303
- }, [
304
- J,
305
- E,
306
- L,
307
- z
308
- ]), St = (e) => {
309
- let t = Math.min(Math.max(1, e), X);
310
- R(t), D && D(t, z);
311
- }, Ct = (e) => {
312
- Qe(e), R(1), D && D(1, e);
313
- }, wt = u(() => {
314
- if (!b || M.length === 0) return xt;
315
- let e = (t, n, r = "") => {
316
- if (n >= M.length) return t;
317
- let i = M[n], a = q.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(xt, 0);
338
- }, [
339
- xt,
340
- M,
341
- b,
342
- q
343
- ]), Tt = (e) => {
344
- ze((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
- }, Et = u(() => {
352
- if (!b || M.length === 0) return wt;
353
- let e = [], t = (n) => {
354
- n.forEach((n) => {
355
- n.isGroupRow ? (e.push(n), Re[n.path] !== !1 && t(n.children)) : e.push(n);
356
- });
357
- };
358
- return t(wt), e;
359
- }, [
360
- wt,
361
- Re,
362
- M,
363
- b
364
- ]), Dt = d(null), [Ot, kt] = f(0), [At, jt] = f(0);
365
- l(() => {
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 = Et.length, { startIndex: Q, endIndex: Mt, topSpacerHeight: Nt, bottomSpacerHeight: Pt } = u(() => {
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 / C)), n = Math.ceil(At / C) + 1, r = Math.max(0, t - be), i = Math.min(Z, t + n + be);
383
- return {
384
- startIndex: r,
385
- endIndex: i,
386
- topSpacerHeight: r * C,
387
- bottomSpacerHeight: (Z - i) * C
388
- };
389
- }, [
390
- Ot,
391
- At,
392
- Z,
393
- C,
394
- be
395
- ]), Ft = u(() => Et.slice(Q, Mt), [
396
- Et,
397
- Q,
398
- Mt
399
- ]), It = u(() => {
400
- let e = /* @__PURE__ */ new Map();
401
- if (!w || w.length === 0) return e;
402
- let t = (e, t) => {
403
- let n = q.get(t);
404
- return n?.getValue ? n.getValue(e) : e[t];
405
- }, n = Ft, r = n.map(() => w.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 < w.length; n++) {
415
- let i = w[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 w.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
- w,
444
- q,
445
- Q
446
- ]), Lt = (e, t = !1, n) => {
447
- let r = gt[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 = u(() => S.map((e, t) => (S.length - 1 - t) * 48), [S]), $ = W.length + +!!y + (b && M.length > 0 ? 1 : 0), zt = /* @__PURE__ */ p("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: I,
462
- onClick: (e) => {
463
- e.stopPropagation(), Xe((e) => !e);
364
+ ref: e.buttonRef,
365
+ onClick: (t) => {
366
+ t.stopPropagation(), e.toggle();
464
367
  },
465
- className: g("flexi-icon-btn", "flexi-settings-btn", F && "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__ */ p(ie, { className: "flexi-icon-sm" })
468
- }), Bt = F && Fe && G.current && ae(/* @__PURE__ */ m("div", {
469
- ref: Ze,
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: Fe.top,
473
- right: Fe.right,
379
+ top: t.position.top,
380
+ right: t.position.right,
474
381
  zIndex: 9999
475
382
  },
476
383
  children: [
477
- /* @__PURE__ */ m("div", {
384
+ /* @__PURE__ */ S("div", {
478
385
  className: "flexi-settings-section",
479
- children: [/* @__PURE__ */ p("span", {
386
+ children: [/* @__PURE__ */ x("span", {
480
387
  className: "flexi-settings-heading",
481
388
  children: "Action Icons"
482
- }), /* @__PURE__ */ m("label", {
389
+ }), /* @__PURE__ */ S("label", {
483
390
  className: "flexi-filter-option",
484
- children: [/* @__PURE__ */ p("input", {
391
+ children: [/* @__PURE__ */ x("input", {
485
392
  type: "checkbox",
486
393
  className: "flexi-checkbox",
487
- checked: qe,
488
- onChange: () => Je((e) => !e)
489
- }), /* @__PURE__ */ p("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__ */ p("div", { className: "flexi-settings-divider" }),
496
- /* @__PURE__ */ m("div", {
402
+ /* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
403
+ /* @__PURE__ */ S("div", {
497
404
  className: "flexi-settings-section",
498
- children: [/* @__PURE__ */ p("span", {
405
+ children: [/* @__PURE__ */ x("span", {
499
406
  className: "flexi-settings-heading",
500
407
  children: "Columns"
501
- }), V.map((e) => /* @__PURE__ */ m("label", {
408
+ }), i.map((e) => /* @__PURE__ */ S("label", {
502
409
  className: "flexi-filter-option",
503
- children: [/* @__PURE__ */ p("input", {
410
+ children: [/* @__PURE__ */ x("input", {
504
411
  type: "checkbox",
505
412
  className: "flexi-checkbox",
506
- checked: !P.includes(e.key),
507
- onChange: () => ot(e.key)
508
- }), /* @__PURE__ */ p("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__ */ p("div", { className: "flexi-settings-divider" }),
515
- /* @__PURE__ */ m("button", {
421
+ /* @__PURE__ */ x("div", { className: "flexi-settings-divider" }),
422
+ /* @__PURE__ */ S("button", {
516
423
  type: "button",
517
- onClick: st,
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__ */ p(re, { className: "flexi-icon-sm" }), /* @__PURE__ */ p("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
- }), G.current);
524
- return /* @__PURE__ */ m("div", {
525
- ref: G,
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
- b && /* @__PURE__ */ p("div", {
529
- onDragOver: (e) => {
530
- e.preventDefault(), Ve(!0);
531
- },
532
- onDragLeave: () => Ve(!1),
533
- onDrop: pt,
534
- className: g("flexi-groupzone", Be && "flexi-groupzone--dragover"),
535
- children: M.length === 0 ? /* @__PURE__ */ p("span", {
536
- className: "flexi-groupzone-hint",
537
- children: "Drag a column header here to group your records by that field"
538
- }) : /* @__PURE__ */ m("div", {
539
- className: "flexi-groupzone-chips",
540
- children: [/* @__PURE__ */ p("span", {
541
- className: "flexi-groupzone-label",
542
- children: "Grouped By:"
543
- }), M.map((e) => /* @__PURE__ */ m("div", {
544
- className: "flexi-chip",
545
- children: [/* @__PURE__ */ p("span", { children: V.find((t) => t.key === e)?.header || e }), /* @__PURE__ */ p("button", {
546
- type: "button",
547
- onClick: () => mt(e),
548
- className: "flexi-icon-btn flexi-chip-remove",
549
- children: /* @__PURE__ */ p(c, { 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__ */ p("div", {
555
- ref: Dt,
556
- className: "flexi-table-wrap",
557
- style: ge,
558
- children: /* @__PURE__ */ m("table", {
559
- className: g("flexi-table", ve && "flexi-table--bordered"),
560
- style: _e,
561
- children: [
562
- /* @__PURE__ */ m("colgroup", { children: [
563
- b && M.length > 0 && /* @__PURE__ */ p("col", { style: { width: "48px" } }),
564
- W.map((e) => /* @__PURE__ */ p("col", { style: {
565
- ...e.style,
566
- width: K(e)
567
- } }, e.key)),
568
- y && /* @__PURE__ */ p("col", { style: { width: "100px" } })
569
- ] }),
570
- /* @__PURE__ */ p("thead", {
571
- className: "flexi-thead",
572
- children: ht.map((r, i) => /* @__PURE__ */ m("tr", {
573
- className: "flexi-header-row",
574
- children: [
575
- i === 0 && b && M.length > 0 && /* @__PURE__ */ p("th", {
576
- rowSpan: ht.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 = (k[a.key]?.length || 0) > 0, c = !!H[a.key], l = Lt(a.key, !0, a.headerStyle), u = !a.children || a.children.length === 0, d = N.key === a.key, f = !!(b && u), oe = u && a.resizable !== !1, h = i === 0 && re === r.length - 1;
588
- return /* @__PURE__ */ m("th", {
589
- rowSpan: o,
590
- colSpan: s,
591
- draggable: !0,
592
- onDragStart: (e) => lt(e, a.key, u),
593
- onDragOver: (e) => e.preventDefault(),
594
- onDrop: (e) => dt(e, a.key),
595
- className: g("flexi-th", "flexi-th--draggable", f && "flexi-th--group-draggable", c && "flexi-th--pinned", a.className, a.headerClassName),
596
- style: l,
597
- children: [/* @__PURE__ */ m("div", {
598
- className: "flexi-th-inner",
599
- children: [
600
- /* @__PURE__ */ m("div", {
601
- className: g("flexi-th-label", a.sortable && u && "flexi-th-label--sortable"),
602
- onClick: () => a.sortable && u && ct(a.key),
603
- children: [/* @__PURE__ */ p("span", {
604
- className: "flexi-th-text",
605
- children: a.header
606
- }), u && a.sortable && /* @__PURE__ */ p("span", {
607
- className: g("flexi-sort-icon", d && "flexi-sort-icon--active"),
608
- children: d && N.direction === "asc" ? /* @__PURE__ */ p(t, { className: "flexi-icon-sm" }) : d && N.direction === "desc" ? /* @__PURE__ */ p(e, { className: "flexi-icon-sm" }) : /* @__PURE__ */ p(n, { className: "flexi-icon-sm" })
609
- })]
610
- }),
611
- /* @__PURE__ */ m("div", {
612
- className: "flexi-th-actions",
613
- children: [
614
- u && a.filterable && /* @__PURE__ */ p("button", {
615
- type: "button",
616
- ref: (e) => {
617
- e ? j.current.set(a.key, e) : j.current.delete(a.key);
618
- },
619
- onClick: (e) => {
620
- e.stopPropagation(), Me(""), Ae(O === a.key ? null : a.key);
621
- },
622
- className: g("flexi-icon-btn", "flexi-filter-btn", ie && "flexi-filter-btn--active"),
623
- children: /* @__PURE__ */ p(ee, { className: "flexi-icon-sm" })
624
- }),
625
- u && qe && /* @__PURE__ */ p("button", {
626
- type: "button",
627
- onClick: (e) => {
628
- e.stopPropagation(), at(a.key);
629
- },
630
- className: g("flexi-icon-btn", "flexi-pin-btn", c && "flexi-pin-btn--pinned"),
631
- title: H[a.key] === "left" ? "Pinned left (click to pin right)" : H[a.key] === "right" ? "Pinned right (click to unpin)" : "Pin column left",
632
- children: p(c ? ne : te, { className: "flexi-icon-sm" })
633
- }),
634
- Te && h && zt
635
- ]
636
- }),
637
- O === a.key && u && Ne && G.current && ae(/* @__PURE__ */ m("div", {
638
- ref: nt,
639
- className: "flexi-filter-dropdown",
640
- style: {
641
- top: Ne.top,
642
- left: Ne.left,
643
- zIndex: 9999
644
- },
645
- children: [
646
- /* @__PURE__ */ p("div", {
647
- className: "flexi-filter-search",
648
- children: /* @__PURE__ */ p("input", {
649
- type: "text",
650
- placeholder: "Search values...",
651
- value: A,
652
- onChange: (e) => Me(e.target.value),
653
- className: "flexi-input",
654
- onClick: (e) => e.stopPropagation()
655
- })
656
- }),
657
- /* @__PURE__ */ p("div", {
658
- className: "flexi-filter-list",
659
- children: bt.length === 0 ? /* @__PURE__ */ p("div", {
660
- className: "flexi-filter-empty",
661
- children: "No results found"
662
- }) : bt.map((e, t) => /* @__PURE__ */ m("label", {
663
- className: "flexi-filter-option",
664
- children: [/* @__PURE__ */ p("input", {
665
- type: "checkbox",
666
- className: "flexi-checkbox",
667
- checked: k[a.key]?.includes(e) || !1,
668
- onChange: () => _t(a.key, e)
669
- }), /* @__PURE__ */ p("span", {
670
- className: "flexi-filter-option-text",
671
- children: String(e)
672
- })]
673
- }, t))
674
- }),
675
- ie && /* @__PURE__ */ p("div", {
676
- className: "flexi-filter-footer",
677
- children: /* @__PURE__ */ p("button", {
678
- type: "button",
679
- onClick: () => vt(a.key),
680
- className: "flexi-filter-clear",
681
- children: "Clear Filter"
682
- })
683
- })
684
- ]
685
- }), G.current)
686
- ]
687
- }), oe && /* @__PURE__ */ p("div", {
688
- className: "flexi-th-resizer",
689
- onMouseDown: (e) => ft(e, a),
690
- onClick: (e) => e.stopPropagation(),
691
- onDragStart: (e) => e.preventDefault()
692
- })]
693
- }, a.key);
694
- }),
695
- i === 0 && y && /* @__PURE__ */ p("th", {
696
- rowSpan: ht.length,
697
- className: "flexi-actions-th",
698
- style: {
699
- position: "sticky",
700
- top: 0,
701
- right: 0,
702
- zIndex: 35,
703
- backgroundColor: "rgb(248, 250, 252)"
704
- },
705
- children: Te && zt
706
- })
707
- ]
708
- }, `header-row-${i}`))
709
- }),
710
- /* @__PURE__ */ p("tbody", {
711
- className: "flexi-tbody",
712
- children: pe ? /* @__PURE__ */ p("tr", { children: /* @__PURE__ */ p("td", {
713
- colSpan: $,
714
- className: "flexi-empty-cell",
715
- children: "Loading records..."
716
- }) }) : Et.length === 0 ? /* @__PURE__ */ p("tr", { children: /* @__PURE__ */ p("td", {
717
- colSpan: $,
718
- className: "flexi-empty-cell",
719
- children: "No records found matching criteria."
720
- }) }) : /* @__PURE__ */ m(oe, { children: [
721
- Nt > 0 && /* @__PURE__ */ p("tr", {
722
- "aria-hidden": "true",
723
- style: { height: Nt },
724
- children: /* @__PURE__ */ p("td", {
725
- colSpan: $,
726
- style: {
727
- padding: 0,
728
- border: "none",
729
- height: Nt
730
- }
731
- })
732
- }),
733
- Ft.map((e, t) => Vt(e, Q + t)),
734
- Pt > 0 && /* @__PURE__ */ p("tr", {
735
- "aria-hidden": "true",
736
- style: { height: Pt },
737
- children: /* @__PURE__ */ p("td", {
738
- colSpan: $,
739
- style: {
740
- padding: 0,
741
- border: "none",
742
- height: Pt
743
- }
744
- })
745
- })
746
- ] })
747
- }),
748
- S.length > 0 && /* @__PURE__ */ p("tbody", {
749
- className: "flexi-tbody flexi-tbody--pinned-bottom",
750
- children: S.map((e, t) => Ht(e, t))
751
- })
752
- ]
753
- })
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}`);
754
494
  }),
755
- Bt,
756
- E && /* @__PURE__ */ m("div", {
757
- className: "flexi-pagination",
758
- children: [
759
- /* @__PURE__ */ m("div", {
760
- className: "flexi-pagination-size",
761
- children: [/* @__PURE__ */ p("span", { children: "Rows per page" }), /* @__PURE__ */ p("select", {
762
- value: z,
763
- onChange: (e) => Ct(Number(e.target.value)),
764
- className: "flexi-pagination-select",
765
- children: ke.map((e) => /* @__PURE__ */ p("option", {
766
- value: e,
767
- children: e
768
- }, e))
769
- })]
770
- }),
771
- /* @__PURE__ */ p("div", {
772
- className: "flexi-pagination-info",
773
- children: Y === 0 ? "0 of 0" : `${(L - 1) * z + 1}–${Math.min(L * z, Y)} of ${Y}`
774
- }),
775
- /* @__PURE__ */ m("div", {
776
- className: "flexi-pagination-controls",
777
- children: [
778
- /* @__PURE__ */ p("button", {
779
- type: "button",
780
- onClick: () => St(1),
781
- disabled: L === 1,
782
- className: "flexi-icon-btn",
783
- title: "First page",
784
- children: /* @__PURE__ */ p(o, { className: "flexi-icon-sm" })
785
- }),
786
- /* @__PURE__ */ p("button", {
787
- type: "button",
788
- onClick: () => St(L - 1),
789
- disabled: L === 1,
790
- className: "flexi-icon-btn",
791
- title: "Previous page",
792
- children: /* @__PURE__ */ p(i, { className: "flexi-icon-sm" })
793
- }),
794
- /* @__PURE__ */ m("span", {
795
- className: "flexi-pagination-page",
796
- children: [
797
- "Page ",
798
- L,
799
- " of ",
800
- X
801
- ]
802
- }),
803
- /* @__PURE__ */ p("button", {
804
- type: "button",
805
- onClick: () => St(L + 1),
806
- disabled: L === X,
807
- className: "flexi-icon-btn",
808
- title: "Next page",
809
- children: /* @__PURE__ */ p(a, { className: "flexi-icon-sm" })
810
- }),
811
- /* @__PURE__ */ p("button", {
812
- type: "button",
813
- onClick: () => St(X),
814
- disabled: L === X,
815
- className: "flexi-icon-btn",
816
- title: "Last page",
817
- children: /* @__PURE__ */ p(s, { className: "flexi-icon-sm" })
818
- })
819
- ]
820
- })
821
- ]
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
+ })
822
506
  })
823
507
  ]
824
508
  });
825
- function Vt(e, t) {
826
- if (e.isGroupRow) {
827
- let n = Re[e.path] !== !1;
828
- return /* @__PURE__ */ m("tr", {
829
- className: "flexi-group-row",
830
- style: { height: C },
831
- children: [/* @__PURE__ */ p("td", {
832
- className: "flexi-group-cell",
833
- style: {
834
- position: "sticky",
835
- left: 0,
836
- zIndex: 20,
837
- backgroundColor: "rgba(248, 250, 252, 0.9)",
838
- paddingLeft: `${e.depth * 12 + 16}px`
839
- },
840
- children: /* @__PURE__ */ m("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", {
841
610
  type: "button",
842
- onClick: () => Tt(e.path),
843
- className: "flexi-group-toggle",
844
- children: [
845
- p(n ? r : a, { className: "flexi-icon-md flexi-icon-muted" }),
846
- /* @__PURE__ */ p("span", {
847
- className: "flexi-group-value",
848
- children: e.groupValue
849
- }),
850
- /* @__PURE__ */ p("span", {
851
- className: "flexi-group-count",
852
- children: e.totalItemsCount
853
- })
854
- ]
855
- })
856
- }), /* @__PURE__ */ p("td", {
857
- colSpan: $ - 1,
858
- className: "flexi-group-filler"
859
- })]
860
- }, `group-header-${e.path}-${t}`);
861
- }
862
- let n = rt(e);
863
- return /* @__PURE__ */ m("tr", {
864
- className: g("flexi-row", we && "flexi-row--clickable", it(e, t)),
865
- style: { height: C },
866
- onClick: we ? (n) => we(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",
867
645
  children: [
868
- b && M?.length > 0 && /* @__PURE__ */ p("td", {
869
- className: "flexi-row-indent-cell",
646
+ i === 0 && t && /* @__PURE__ */ x("th", {
647
+ rowSpan: r.length,
648
+ className: "flexi-group-spacer-th",
870
649
  style: {
871
650
  position: "sticky",
651
+ top: 0,
872
652
  left: 0,
873
- zIndex: 10
653
+ zIndex: 35,
654
+ backgroundColor: "rgb(248, 250, 252)"
874
655
  }
875
656
  }),
876
- W?.map((n) => {
877
- let r = w?.includes(n.key) ? It.get(t)?.[n.key] : void 0;
878
- if (r === "skip") return null;
879
- let i = e[n.key], a = Lt(n.key, !1, n.style), o = !!H[n.key];
880
- return /* @__PURE__ */ p("td", {
881
- rowSpan: typeof r == "number" ? r : void 0,
882
- className: g("flexi-cell", o && "flexi-cell--pinned", n.className),
883
- style: a,
884
- children: n.render ? n.render(i, e) : /* @__PURE__ */ p("span", {
885
- className: "flexi-cell-text",
886
- children: i
887
- })
888
- }, n.key);
889
- }),
890
- y && /* @__PURE__ */ p("td", {
891
- 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 ",
892
664
  style: {
893
- position: "sticky",
894
- right: 0
665
+ right: 0,
666
+ zIndex: 55,
667
+ display: "flex",
668
+ justifyContent: "center",
669
+ alignItems: "center"
895
670
  },
896
- children: /* @__PURE__ */ p("div", {
897
- className: "flexi-actions-inner",
898
- children: y(e)
899
- })
671
+ children: /* @__PURE__ */ x(B, {})
900
672
  })
901
673
  ]
902
- }, 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;
903
729
  }
904
- function Ht(e, t) {
905
- let n = typeof ye == "function" ? ye(e, t) : ye, r = {
906
- position: "sticky",
907
- bottom: `${Rt[t]}px`,
908
- background: "#",
909
- 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()));
910
763
  };
911
- return /* @__PURE__ */ m("tr", {
912
- className: g("flexi-row", "flexi-row--pinned-bottom", n),
913
- style: r,
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());
782
+ };
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",
914
1223
  children: [
915
- b && M?.length > 0 && /* @__PURE__ */ p("td", {
916
- className: "flexi-row-indent-cell",
917
- style: {
918
- position: "sticky",
919
- left: 0,
920
- zIndex: 10
921
- }
922
- }),
923
- W?.map((t) => {
924
- let n = e[t.key], r = Lt(t.key, !1, t.style), i = !!H[t.key], a = t.pinnedRender ?? t.render;
925
- return /* @__PURE__ */ p("td", {
926
- className: g("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"),
927
1231
  style: r,
928
- children: a ? a(n, e) : /* @__PURE__ */ p("span", {
929
- className: "flexi-cell-text",
930
- children: n
931
- })
932
- }, t.key);
933
- }),
934
- y && /* @__PURE__ */ p("td", {
935
- className: "flexi-actions-cell",
936
- style: {
937
- position: "sticky",
938
- right: 0
939
- },
940
- children: /* @__PURE__ */ p("div", {
941
- className: "flexi-actions-inner",
942
- children: y(e)
1232
+ children: [
1233
+ /* @__PURE__ */ x(de, {}),
1234
+ /* @__PURE__ */ x(fe, {}),
1235
+ /* @__PURE__ */ x(ue, {}),
1236
+ /* @__PURE__ */ x(z, {})
1237
+ ]
943
1238
  })
944
- })
1239
+ }),
1240
+ /* @__PURE__ */ x(V, {}),
1241
+ t.paginationEnabled && /* @__PURE__ */ x(k, {})
945
1242
  ]
946
- }, `pinned-bottom-row-${t}`);
947
- }
1243
+ })
1244
+ });
948
1245
  }
949
1246
  //#endregion
950
- export { _ as DataTable };
1247
+ export { Ee as DataTable };