flexi-datagrid 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,17 +1,17 @@
1
- import { ArrowDown as e, ArrowUp as t, ArrowUpDown as n, ChevronDown as r, ChevronRight as i, Filter as a, Pin as o, PinOff as s, X as ee } from "lucide-react";
2
- import { useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
3
- import { createPortal as te } from "react-dom";
4
- import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
5
- //#region src/DataTable.tsx
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
6
  var h = (e) => {
7
7
  let t = [];
8
8
  return e.forEach((e) => {
9
9
  e.children && e.children.length > 0 ? t.push(...h(e.children)) : t.push(e);
10
10
  }), t;
11
- }, g = (...e) => e.filter(Boolean).join(" "), ne = (e) => {
11
+ }, g = (...e) => e.filter(Boolean).join(" "), se = (e) => {
12
12
  if (e === !0) return "left";
13
13
  if (e === "left" || e === "right") return e;
14
- }, re = (e, t, n) => {
14
+ }, ce = (e, t, n) => {
15
15
  let r = (e) => {
16
16
  let n = t[e];
17
17
  return n === "left" ? 0 : n === "right" ? 2 : 1;
@@ -26,42 +26,69 @@ var h = (e) => {
26
26
  children: i(e.children)
27
27
  } : e);
28
28
  return i(e);
29
- }, ie = 48, ae = 150, oe = 60;
30
- function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy: x = !1, defaultGroupBy: ce = [], onPinChange: le, onGroupChange: S, containerStyle: ue, tableStyle: de, bordered: fe = !1, pinnedBottomRowData: C = [], pinnedRowClassName: pe, rowHeight: w = ie, overscan: me = 8, onColumnResize: he, onColumnReorder: ge, rowClassRules: _e, onRowClick: T }) {
31
- let [E, ve] = d(null), [D, ye] = d({}), [O, k] = d(""), [A, be] = d(null), j = u(/* @__PURE__ */ new Map()), [M, xe] = d(ce), [N, Se] = d({}), [Ce, P] = d(!1), [F, we] = d({
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({
32
37
  key: null,
33
38
  direction: null
34
- }), [I, Te] = d({}), [L, Ee] = d({}), R = u(null), z = u(!1), B = u(null), V = l(() => h(_), [_]), [H, De] = d(() => {
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(() => {
35
40
  let e = {};
36
41
  return V.forEach((t) => {
37
- let n = ne(t.pinned);
42
+ let n = se(t.pinned);
38
43
  n && (e[t.key] = n);
39
44
  }), e;
40
- }), U = l(() => re(_, H, L), [
45
+ }), U = u(() => ce(_, H, Ge), [
41
46
  _,
42
47
  H,
43
- L
44
- ]), W = l(() => {
45
- let e = h(U), t = x ? M : [];
46
- return e.filter((e) => !t.includes(e.key));
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));
47
52
  }, [
48
53
  U,
49
54
  M,
50
- x
51
- ]), G = u(null), K = u(null);
52
- c(() => {
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;
53
66
  function e(e) {
54
- let t = e.target, n = E ? j.current.get(E) : null;
55
- K.current && !K.current.contains(t) && !(n && n.contains(t)) && (ve(null), k(""));
67
+ let t = e.target;
68
+ Ze.current && !Ze.current.contains(t) && !(I.current && I.current.contains(t)) && Xe(!1);
56
69
  }
57
70
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
58
- }, [E]), c(() => {
59
- if (!E) return;
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;
60
87
  let e = () => {
61
- let e = j.current.get(E), t = G.current;
88
+ let e = j.current.get(O), t = G.current;
62
89
  if (!e || !t) return;
63
90
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
64
- be({
91
+ Pe({
65
92
  top: n.bottom - r.top + 4,
66
93
  left: n.left - r.left
67
94
  });
@@ -69,87 +96,94 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
69
96
  return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
70
97
  window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
71
98
  };
72
- }, [E]);
73
- let Oe = (e) => typeof y == "function" ? y(e) : String(e[y]), ke = (e, t) => {
74
- if (!_e) return;
99
+ }, [O]);
100
+ let rt = (e) => typeof fe == "function" ? fe(e) : String(e[fe]), it = (e, t) => {
101
+ if (!Ce) return;
75
102
  let n;
76
- for (let r in _e) _e[r](e, t) && (n = n ? `${n} ${r}` : r);
103
+ for (let r in Ce) Ce[r](e, t) && (n = n ? `${n} ${r}` : r);
77
104
  return n;
78
- }, Ae = (e) => {
79
- De((t) => {
105
+ }, at = (e) => {
106
+ tt((t) => {
80
107
  let n = t[e], r = n ? n === "left" ? "right" : void 0 : "left", i = { ...t };
81
- return r ? i[e] = r : delete i[e], le && le(e, !!r, r), i;
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;
82
114
  });
83
- }, je = (e) => {
115
+ }, st = () => {
116
+ Je(Ee), Ye(De), T && T(De);
117
+ }, ct = (e) => {
84
118
  let t = "asc";
85
- F.key === e && (t = F.direction === "asc" ? "desc" : F.direction === "desc" ? null : "asc"), we({
119
+ N.key === e && (t = N.direction === "asc" ? "desc" : N.direction === "desc" ? null : "asc"), He({
86
120
  key: t ? e : null,
87
121
  direction: t
88
122
  });
89
- }, Me = (e, t, n) => {
90
- if (z.current) {
123
+ }, lt = (e, t, n) => {
124
+ if (et.current) {
91
125
  e.preventDefault();
92
126
  return;
93
127
  }
94
- R.current = t, n && e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move";
95
- }, Ne = (e, t, n) => {
128
+ $e.current = t, n && e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move";
129
+ }, ut = (e, t, n) => {
96
130
  let r = e.map((e) => e.key);
97
131
  if (r.includes(t) && r.includes(n)) return e;
98
132
  for (let r of e) if (r.children && r.children.length > 0) {
99
- let e = Ne(r.children, t, n);
133
+ let e = ut(r.children, t, n);
100
134
  if (e) return e;
101
135
  }
102
136
  return null;
103
- }, Pe = (e, t) => {
137
+ }, dt = (e, t) => {
104
138
  e.preventDefault(), e.stopPropagation();
105
- let n = R.current;
106
- if (R.current = null, !n || n === t) return;
107
- let r = Ne(U, n, t);
139
+ let n = $e.current;
140
+ if ($e.current = null, !n || n === t) return;
141
+ let r = ut(U, n, t);
108
142
  if (!r) return;
109
143
  let i = r.map((e) => e.key), a = i.indexOf(n), o = i.indexOf(t);
110
144
  i.splice(o, 0, i.splice(a, 1)[0]);
111
- let s = { ...L };
145
+ let s = { ...Ge };
112
146
  i.forEach((e, t) => {
113
147
  s[e] = t;
114
- }), Ee(s), ge && ge(h(re(_, H, s)).map((e) => e.key));
115
- }, Fe = (e, t) => {
116
- e.preventDefault(), e.stopPropagation(), z.current = !0, B.current = {
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 = {
117
151
  key: t.key,
118
152
  startX: e.clientX,
119
- startWidth: J(t)
153
+ startWidth: K(t)
120
154
  };
121
- let n = t.minWidth ?? oe, r = t.maxWidth, i = (e) => {
155
+ let n = t.minWidth ?? de, r = t.maxWidth, i = (e) => {
122
156
  let t = B.current;
123
157
  if (!t) return;
124
158
  let i = t.startWidth + (e.clientX - t.startX);
125
- i = Math.max(n, i), r && (i = Math.min(r, i)), Te((e) => e[t.key] === i ? e : {
159
+ i = Math.max(n, i), r && (i = Math.min(r, i)), We((e) => e[t.key] === i ? e : {
126
160
  ...e,
127
161
  [t.key]: i
128
162
  });
129
163
  }, a = () => {
130
164
  let e = B.current;
131
165
  B.current = null, window.removeEventListener("mousemove", i), window.removeEventListener("mouseup", a), requestAnimationFrame(() => {
132
- z.current = !1;
133
- }), e && he && Te((t) => (t[e.key] !== void 0 && he(e.key, t[e.key]), t));
166
+ et.current = !1;
167
+ }), e && xe && We((t) => (t[e.key] !== void 0 && xe(e.key, t[e.key]), t));
134
168
  };
135
169
  window.addEventListener("mousemove", i), window.addEventListener("mouseup", a);
136
- }, Ie = (e) => {
137
- e.preventDefault(), P(!1);
170
+ }, pt = (e) => {
171
+ e.preventDefault(), Ve(!1);
138
172
  let t = e.dataTransfer.getData("text/plain");
139
173
  if (t && !M.includes(t)) {
140
174
  let e = [...M, t];
141
- xe(e), S && S(e);
175
+ Le(e), x && x(e);
142
176
  }
143
- }, Le = (e) => {
177
+ }, mt = (e) => {
144
178
  let t = M.filter((t) => t !== e);
145
- xe(t), Se({}), S && S(t);
146
- }, q = l(() => {
179
+ Le(t), ze({}), x && x(t);
180
+ }, ht = u(() => {
147
181
  let e = (t) => {
148
182
  let n = 0;
149
183
  return t.forEach((t) => {
150
184
  n = t.children && t.children.length > 0 ? Math.max(n, 1 + e(t.children)) : Math.max(n, 1);
151
185
  }), n;
152
- }, t = e(U), n = Array.from({ length: t }, () => []), r = (e) => !e.children || e.children.length === 0 ? M.includes(e.key) && x ? 0 : 1 : e.children.reduce((e, t) => e + r(t), 0), i = x ? M : [], a = (e, o) => {
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) => {
153
187
  e.forEach((e) => {
154
188
  if (i.includes(e.key)) return;
155
189
  let s = r(e);
@@ -168,70 +202,71 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
168
202
  }, [
169
203
  U,
170
204
  M,
171
- x
172
- ]), J = (e) => {
173
- if (I[e.key] !== void 0) return I[e.key];
174
- let t = e.style?.width || e.headerStyle?.width || `${ae}px`;
175
- return typeof t == "number" ? t : parseInt(String(t), 10) || ae;
176
- }, Re = l(() => {
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(() => {
177
212
  let e = {}, t = 0;
178
- x && M.length > 0 && (t += 48), W.forEach((n) => {
213
+ b && M.length > 0 && (t += 48), W.forEach((n) => {
179
214
  H[n.key] === "left" && (e[n.key] = {
180
215
  side: "left",
181
216
  offset: t
182
- }, t += J(n));
217
+ }, t += K(n));
183
218
  });
184
- let n = b ? 100 : 0;
219
+ let n = y ? 100 : 0;
185
220
  for (let t = W.length - 1; t >= 0; t--) {
186
221
  let r = W[t];
187
222
  H[r.key] === "right" && (e[r.key] = {
188
223
  side: "right",
189
224
  offset: n
190
- }, n += J(r));
225
+ }, n += K(r));
191
226
  }
192
227
  return e;
193
228
  }, [
194
229
  W,
195
230
  H,
196
231
  M,
197
- x,
198
232
  b,
199
- I
200
- ]), ze = (e, t) => {
201
- ye((n) => {
233
+ y,
234
+ Ue
235
+ ]), _t = (e, t) => {
236
+ je((n) => {
202
237
  let r = n[e] || [], i = r.includes(t) ? r.filter((e) => e !== t) : [...r, t], a = {
203
238
  ...n,
204
239
  [e]: i
205
240
  };
206
241
  return a[e].length === 0 && delete a[e], a;
207
242
  });
208
- }, Be = (e) => {
209
- ye((t) => {
243
+ }, vt = (e) => {
244
+ je((t) => {
210
245
  let n = { ...t };
211
246
  return delete n[e], n;
212
247
  });
213
- }, Y = l(() => {
248
+ }, q = u(() => {
214
249
  let e = /* @__PURE__ */ new Map();
215
250
  return V.forEach((t) => e.set(t.key, t)), e;
216
- }, [V]), Ve = l(() => {
217
- if (!E) return [];
218
- let e = Y.get(E), t = v.map((t) => e?.getValue ? e.getValue(t) : 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]);
219
254
  return Array.from(new Set(t)).filter((e) => e != null);
220
255
  }, [
221
256
  v,
222
- E,
223
- Y
224
- ]), He = l(() => {
225
- if (!O.trim()) return Ve;
226
- let e = O.toLowerCase();
227
- return Ve.filter((t) => String(t).toLowerCase().includes(e));
228
- }, [Ve, O]), Ue = l(() => {
229
- let e = Object.entries(D).filter(([, e]) => e && e.length > 0), t = e.length === 0 ? v : v.filter((t) => e.every(([e, n]) => {
230
- let r = Y.get(e), i = r?.getValue ? r.getValue(t) : t[e];
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];
231
266
  return n.includes(i);
232
267
  }));
233
- if (F.key && F.direction) {
234
- let { key: e, direction: n } = F, r = Y.get(e);
268
+ if (N.key && N.direction) {
269
+ let { key: e, direction: n } = N, r = q.get(e);
235
270
  t = [...t].sort((t, i) => {
236
271
  let a = r?.getValue ? r.getValue(t) : t[e], o = r?.getValue ? r.getValue(i) : i[e];
237
272
  if (a === o) return 0;
@@ -247,18 +282,46 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
247
282
  return t;
248
283
  }, [
249
284
  v,
250
- D,
251
- F,
252
- Y
253
- ]), We = l(() => {
254
- if (!x || M.length === 0) return Ue;
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;
255
315
  let e = (t, n, r = "") => {
256
316
  if (n >= M.length) return t;
257
- let i = M[n], a = Y.get(i), o = {};
317
+ let i = M[n], a = q.get(i), o = {};
258
318
  return t.forEach((e) => {
259
319
  let t = a?.getValue ? a.getValue(e) : e[i], n = String(t ?? "N/A");
260
320
  o[n] || (o[n] = []), o[n].push(e);
261
- }), Object.entries(o).map(([t, a]) => {
321
+ }), Object.entries(o).sort(([e], [t]) => e.localeCompare(t, void 0, {
322
+ numeric: !0,
323
+ sensitivity: "base"
324
+ })).map(([t, a]) => {
262
325
  let o = r ? `${r}➔${t}` : t;
263
326
  return {
264
327
  isGroupRow: !0,
@@ -271,70 +334,117 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
271
334
  };
272
335
  });
273
336
  };
274
- return e(Ue, 0);
337
+ return e(xt, 0);
275
338
  }, [
276
- Ue,
339
+ xt,
277
340
  M,
278
- x,
279
- Y
280
- ]), Ge = (e) => {
281
- Se((t) => {
341
+ b,
342
+ q
343
+ ]), Tt = (e) => {
344
+ ze((t) => {
282
345
  let n = t[e] !== !1;
283
346
  return {
284
347
  ...t,
285
348
  [e]: !n
286
349
  };
287
350
  });
288
- }, X = l(() => {
289
- if (!x || M.length === 0) return We;
351
+ }, Et = u(() => {
352
+ if (!b || M.length === 0) return wt;
290
353
  let e = [], t = (n) => {
291
354
  n.forEach((n) => {
292
- n.isGroupRow ? (e.push(n), N[n.path] !== !1 && t(n.children)) : e.push(n);
355
+ n.isGroupRow ? (e.push(n), Re[n.path] !== !1 && t(n.children)) : e.push(n);
293
356
  });
294
357
  };
295
- return t(We), e;
358
+ return t(wt), e;
296
359
  }, [
297
- We,
298
- N,
360
+ wt,
361
+ Re,
299
362
  M,
300
- x
301
- ]), Ke = u(null), [qe, Je] = d(0), [Ye, Xe] = d(0);
302
- c(() => {
303
- let e = Ke.current;
363
+ b
364
+ ]), Dt = d(null), [Ot, kt] = f(0), [At, jt] = f(0);
365
+ l(() => {
366
+ let e = Dt.current;
304
367
  if (!e) return;
305
- let t = () => Je(e.scrollTop);
306
- Xe(e.clientHeight), Je(e.scrollTop), e.addEventListener("scroll", t, { passive: !0 });
368
+ let t = () => kt(e.scrollTop);
369
+ jt(e.clientHeight), kt(e.scrollTop), e.addEventListener("scroll", t, { passive: !0 });
307
370
  let n;
308
- return typeof ResizeObserver < "u" && (n = new ResizeObserver(() => Xe(e.clientHeight)), n.observe(e)), () => {
371
+ return typeof ResizeObserver < "u" && (n = new ResizeObserver(() => jt(e.clientHeight)), n.observe(e)), () => {
309
372
  e.removeEventListener("scroll", t), n?.disconnect();
310
373
  };
311
374
  }, []);
312
- let Z = X.length, { startIndex: Ze, endIndex: Qe, topSpacerHeight: Q, bottomSpacerHeight: $e } = l(() => {
313
- if (Ye === 0) return {
375
+ let Z = Et.length, { startIndex: Q, endIndex: Mt, topSpacerHeight: Nt, bottomSpacerHeight: Pt } = u(() => {
376
+ if (At === 0) return {
314
377
  startIndex: 0,
315
378
  endIndex: Z,
316
379
  topSpacerHeight: 0,
317
380
  bottomSpacerHeight: 0
318
381
  };
319
- let e = Math.floor(qe / w), t = Math.ceil(Ye / w), n = Math.max(0, e - me), r = Math.min(Z, e + t + me);
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);
320
383
  return {
321
- startIndex: n,
322
- endIndex: r,
323
- topSpacerHeight: n * w,
324
- bottomSpacerHeight: (Z - r) * w
384
+ startIndex: r,
385
+ endIndex: i,
386
+ topSpacerHeight: r * C,
387
+ bottomSpacerHeight: (Z - i) * C
325
388
  };
326
389
  }, [
327
- qe,
328
- Ye,
390
+ Ot,
391
+ At,
329
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,
330
443
  w,
331
- me
332
- ]), et = l(() => X.slice(Ze, Qe), [
333
- X,
334
- Ze,
335
- Qe
336
- ]), tt = (e, t = !1, n) => {
337
- let r = Re[e];
444
+ q,
445
+ Q
446
+ ]), Lt = (e, t = !1, n) => {
447
+ let r = gt[e];
338
448
  if (!r) return n || {};
339
449
  let i = r.side === "right";
340
450
  return {
@@ -346,237 +456,378 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
346
456
  boxShadow: i ? "-2px 0 5px -2px rgba(0,0,0,0.1)" : "2px 0 5px -2px rgba(0,0,0,0.1)",
347
457
  ...n
348
458
  };
349
- }, nt = l(() => C.map((e, t) => (C.length - 1 - t) * 48), [C]), $ = W.length + +!!b + (x && M.length > 0 ? 1 : 0);
350
- return /* @__PURE__ */ m("div", {
351
- ref: G,
352
- className: "flexi-root",
353
- children: [x && /* @__PURE__ */ p("div", {
354
- onDragOver: (e) => {
355
- e.preventDefault(), P(!0);
356
- },
357
- onDragLeave: () => P(!1),
358
- onDrop: Ie,
359
- className: g("flexi-groupzone", Ce && "flexi-groupzone--dragover"),
360
- children: M.length === 0 ? /* @__PURE__ */ p("span", {
361
- className: "flexi-groupzone-hint",
362
- children: "Drag a column header here to group your records by that field"
363
- }) : /* @__PURE__ */ m("div", {
364
- className: "flexi-groupzone-chips",
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", {
460
+ type: "button",
461
+ ref: I,
462
+ onClick: (e) => {
463
+ e.stopPropagation(), Xe((e) => !e);
464
+ },
465
+ className: g("flexi-icon-btn", "flexi-settings-btn", F && "flexi-settings-btn--active"),
466
+ 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,
470
+ className: "flexi-settings-menu",
471
+ style: {
472
+ top: Fe.top,
473
+ right: Fe.right,
474
+ zIndex: 9999
475
+ },
476
+ children: [
477
+ /* @__PURE__ */ m("div", {
478
+ className: "flexi-settings-section",
365
479
  children: [/* @__PURE__ */ p("span", {
366
- className: "flexi-groupzone-label",
367
- children: "Grouped By:"
368
- }), M.map((e) => /* @__PURE__ */ m("div", {
369
- className: "flexi-chip",
370
- children: [/* @__PURE__ */ p("span", { children: V.find((t) => t.key === e)?.header || e }), /* @__PURE__ */ p("button", {
371
- type: "button",
372
- onClick: () => Le(e),
373
- className: "flexi-icon-btn flexi-chip-remove",
374
- children: /* @__PURE__ */ p(ee, { className: "flexi-icon-xs" })
480
+ className: "flexi-settings-heading",
481
+ children: "Action Icons"
482
+ }), /* @__PURE__ */ m("label", {
483
+ className: "flexi-filter-option",
484
+ children: [/* @__PURE__ */ p("input", {
485
+ type: "checkbox",
486
+ className: "flexi-checkbox",
487
+ checked: qe,
488
+ onChange: () => Je((e) => !e)
489
+ }), /* @__PURE__ */ p("span", {
490
+ className: "flexi-filter-option-text",
491
+ children: "Show pin icon on hover"
375
492
  })]
376
- }, e))]
493
+ })]
494
+ }),
495
+ /* @__PURE__ */ p("div", { className: "flexi-settings-divider" }),
496
+ /* @__PURE__ */ m("div", {
497
+ className: "flexi-settings-section",
498
+ children: [/* @__PURE__ */ p("span", {
499
+ className: "flexi-settings-heading",
500
+ children: "Columns"
501
+ }), V.map((e) => /* @__PURE__ */ m("label", {
502
+ className: "flexi-filter-option",
503
+ children: [/* @__PURE__ */ p("input", {
504
+ type: "checkbox",
505
+ className: "flexi-checkbox",
506
+ checked: !P.includes(e.key),
507
+ onChange: () => ot(e.key)
508
+ }), /* @__PURE__ */ p("span", {
509
+ className: "flexi-filter-option-text",
510
+ children: e.header
511
+ })]
512
+ }, e.key))]
513
+ }),
514
+ /* @__PURE__ */ p("div", { className: "flexi-settings-divider" }),
515
+ /* @__PURE__ */ m("button", {
516
+ type: "button",
517
+ onClick: st,
518
+ className: "flexi-settings-reset",
519
+ 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" })]
377
521
  })
378
- }), /* @__PURE__ */ p("div", {
379
- ref: Ke,
380
- className: "flexi-table-wrap",
381
- style: ue,
382
- children: /* @__PURE__ */ m("table", {
383
- className: g("flexi-table", fe && "flexi-table--bordered"),
384
- style: de,
385
- children: [
386
- /* @__PURE__ */ m("colgroup", { children: [
387
- x && M.length > 0 && /* @__PURE__ */ p("col", { style: { width: "48px" } }),
388
- W.map((e) => /* @__PURE__ */ p("col", { style: {
389
- ...e.style,
390
- width: J(e)
391
- } }, e.key)),
392
- b && /* @__PURE__ */ p("col", { style: { width: "100px" } })
393
- ] }),
394
- /* @__PURE__ */ p("thead", {
395
- className: "flexi-thead",
396
- children: q.map((r, i) => /* @__PURE__ */ m("tr", {
397
- className: "flexi-header-row",
398
- children: [
399
- i === 0 && x && M.length > 0 && /* @__PURE__ */ p("th", {
400
- rowSpan: q.length,
401
- className: "flexi-group-spacer-th",
402
- style: {
403
- position: "sticky",
404
- top: 0,
405
- left: 0,
406
- zIndex: 35,
407
- backgroundColor: "rgb(248, 250, 252)"
408
- }
409
- }),
410
- r.map(({ col: r, rowSpan: i, colSpan: ee }) => {
411
- let c = (D[r.key]?.length || 0) > 0, l = !!H[r.key], u = tt(r.key, !0, r.headerStyle), d = !r.children || r.children.length === 0, f = F.key === r.key, h = !!(x && d), ne = d && r.resizable !== !1;
412
- return /* @__PURE__ */ m("th", {
413
- rowSpan: i,
414
- colSpan: ee,
415
- draggable: !0,
416
- onDragStart: (e) => Me(e, r.key, d),
417
- onDragOver: (e) => e.preventDefault(),
418
- onDrop: (e) => Pe(e, r.key),
419
- className: g("flexi-th", "flexi-th--draggable", h && "flexi-th--group-draggable", l && "flexi-th--pinned", r.className, r.headerClassName),
420
- style: u,
421
- children: [/* @__PURE__ */ m("div", {
422
- className: "flexi-th-inner",
423
- children: [
424
- /* @__PURE__ */ m("div", {
425
- className: g("flexi-th-label", r.sortable && d && "flexi-th-label--sortable"),
426
- onClick: () => r.sortable && d && je(r.key),
427
- children: [/* @__PURE__ */ p("span", {
428
- className: "flexi-th-text",
429
- children: r.header
430
- }), d && r.sortable && /* @__PURE__ */ p("span", {
431
- className: g("flexi-sort-icon", f && "flexi-sort-icon--active"),
432
- children: f && F.direction === "asc" ? /* @__PURE__ */ p(t, { className: "flexi-icon-sm" }) : f && F.direction === "desc" ? /* @__PURE__ */ p(e, { className: "flexi-icon-sm" }) : /* @__PURE__ */ p(n, { className: "flexi-icon-sm" })
433
- })]
434
- }),
435
- /* @__PURE__ */ m("div", {
436
- className: "flexi-th-actions",
437
- children: [d && r.filterable && /* @__PURE__ */ p("button", {
438
- type: "button",
439
- ref: (e) => {
440
- e ? j.current.set(r.key, e) : j.current.delete(r.key);
441
- },
442
- onClick: (e) => {
443
- e.stopPropagation(), k(""), ve(E === r.key ? null : r.key);
444
- },
445
- className: g("flexi-icon-btn", "flexi-filter-btn", c && "flexi-filter-btn--active"),
446
- children: /* @__PURE__ */ p(a, { className: "flexi-icon-sm" })
447
- }), d && /* @__PURE__ */ p("button", {
448
- type: "button",
449
- onClick: (e) => {
450
- e.stopPropagation(), Ae(r.key);
451
- },
452
- className: g("flexi-icon-btn", "flexi-pin-btn", l && "flexi-pin-btn--pinned"),
453
- title: H[r.key] === "left" ? "Pinned left (click to pin right)" : H[r.key] === "right" ? "Pinned right (click to unpin)" : "Pin column left",
454
- children: p(l ? s : o, { className: "flexi-icon-sm" })
455
- })]
456
- }),
457
- E === r.key && d && A && G.current && te(/* @__PURE__ */ m("div", {
458
- ref: K,
459
- className: "flexi-filter-dropdown",
460
- style: {
461
- top: A.top,
462
- left: A.left,
463
- zIndex: 9999
464
- },
465
- children: [
466
- /* @__PURE__ */ p("div", {
467
- className: "flexi-filter-search",
468
- children: /* @__PURE__ */ p("input", {
469
- type: "text",
470
- placeholder: "Search values...",
471
- value: O,
472
- onChange: (e) => k(e.target.value),
473
- className: "flexi-input",
474
- onClick: (e) => e.stopPropagation()
475
- })
476
- }),
477
- /* @__PURE__ */ p("div", {
478
- className: "flexi-filter-list",
479
- children: He.length === 0 ? /* @__PURE__ */ p("div", {
480
- className: "flexi-filter-empty",
481
- children: "No results found"
482
- }) : He.map((e, t) => /* @__PURE__ */ m("label", {
483
- className: "flexi-filter-option",
484
- children: [/* @__PURE__ */ p("input", {
485
- type: "checkbox",
486
- className: "flexi-checkbox",
487
- checked: D[r.key]?.includes(e) || !1,
488
- onChange: () => ze(r.key, e)
489
- }), /* @__PURE__ */ p("span", {
490
- className: "flexi-filter-option-text",
491
- children: String(e)
492
- })]
493
- }, t))
494
- }),
495
- c && /* @__PURE__ */ p("div", {
496
- className: "flexi-filter-footer",
497
- children: /* @__PURE__ */ p("button", {
522
+ ]
523
+ }), G.current);
524
+ return /* @__PURE__ */ m("div", {
525
+ ref: G,
526
+ className: "flexi-root",
527
+ 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))]
552
+ })
553
+ }),
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", {
498
626
  type: "button",
499
- onClick: () => Be(r.key),
500
- className: "flexi-filter-clear",
501
- children: "Clear Filter"
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
+ })
502
683
  })
503
- })
504
- ]
505
- }), G.current)
506
- ]
507
- }), ne && /* @__PURE__ */ p("div", {
508
- className: "flexi-th-resizer",
509
- onMouseDown: (e) => Fe(e, r),
510
- onClick: (e) => e.stopPropagation(),
511
- onDragStart: (e) => e.preventDefault()
512
- })]
513
- }, r.key);
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
+ })
514
732
  }),
515
- i === 0 && b && /* @__PURE__ */ p("th", {
516
- rowSpan: q.length,
517
- className: "flexi-actions-th",
518
- style: {
519
- position: "sticky",
520
- top: 0,
521
- right: 0,
522
- zIndex: 35,
523
- backgroundColor: "rgb(248, 250, 252)"
524
- }
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
+ })
525
745
  })
526
- ]
527
- }, `header-row-${i}`))
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
+ })
754
+ }),
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
+ })]
528
770
  }),
529
- /* @__PURE__ */ p("tbody", {
530
- className: "flexi-tbody",
531
- children: se ? /* @__PURE__ */ p("tr", { children: /* @__PURE__ */ p("td", {
532
- colSpan: $,
533
- className: "flexi-empty-cell",
534
- children: "Loading records..."
535
- }) }) : X.length === 0 ? /* @__PURE__ */ p("tr", { children: /* @__PURE__ */ p("td", {
536
- colSpan: $,
537
- className: "flexi-empty-cell",
538
- children: "No records found matching criteria."
539
- }) }) : /* @__PURE__ */ m(f, { children: [
540
- Q > 0 && /* @__PURE__ */ p("tr", {
541
- "aria-hidden": "true",
542
- style: { height: Q },
543
- children: /* @__PURE__ */ p("td", {
544
- colSpan: $,
545
- style: {
546
- padding: 0,
547
- border: "none",
548
- height: Q
549
- }
550
- })
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" })
551
785
  }),
552
- et.map((e, t) => rt(e, Ze + t)),
553
- $e > 0 && /* @__PURE__ */ p("tr", {
554
- "aria-hidden": "true",
555
- style: { height: $e },
556
- children: /* @__PURE__ */ p("td", {
557
- colSpan: $,
558
- style: {
559
- padding: 0,
560
- border: "none",
561
- height: $e
562
- }
563
- })
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" })
564
818
  })
565
- ] })
566
- }),
567
- C.length > 0 && /* @__PURE__ */ p("tbody", {
568
- className: "flexi-tbody flexi-tbody--pinned-bottom",
569
- children: C.map((e, t) => it(e, t))
819
+ ]
570
820
  })
571
821
  ]
572
822
  })
573
- })]
823
+ ]
574
824
  });
575
- function rt(e, t) {
825
+ function Vt(e, t) {
576
826
  if (e.isGroupRow) {
577
- let n = N[e.path] !== !1;
827
+ let n = Re[e.path] !== !1;
578
828
  return /* @__PURE__ */ m("tr", {
579
829
  className: "flexi-group-row",
830
+ style: { height: C },
580
831
  children: [/* @__PURE__ */ p("td", {
581
832
  className: "flexi-group-cell",
582
833
  style: {
@@ -588,10 +839,10 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
588
839
  },
589
840
  children: /* @__PURE__ */ m("button", {
590
841
  type: "button",
591
- onClick: () => Ge(e.path),
842
+ onClick: () => Tt(e.path),
592
843
  className: "flexi-group-toggle",
593
844
  children: [
594
- p(n ? r : i, { className: "flexi-icon-md flexi-icon-muted" }),
845
+ p(n ? r : a, { className: "flexi-icon-md flexi-icon-muted" }),
595
846
  /* @__PURE__ */ p("span", {
596
847
  className: "flexi-group-value",
597
848
  children: e.groupValue
@@ -608,12 +859,13 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
608
859
  })]
609
860
  }, `group-header-${e.path}-${t}`);
610
861
  }
611
- let n = Oe(e);
862
+ let n = rt(e);
612
863
  return /* @__PURE__ */ m("tr", {
613
- className: g("flexi-row", T && "flexi-row--clickable", ke(e, t)),
614
- onClick: T ? (n) => T(e, t, n) : void 0,
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,
615
867
  children: [
616
- x && M?.length > 0 && /* @__PURE__ */ p("td", {
868
+ b && M?.length > 0 && /* @__PURE__ */ p("td", {
617
869
  className: "flexi-row-indent-cell",
618
870
  style: {
619
871
  position: "sticky",
@@ -621,18 +873,21 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
621
873
  zIndex: 10
622
874
  }
623
875
  }),
624
- W?.map((t) => {
625
- let n = e[t.key], r = tt(t.key, !1, t.style);
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];
626
880
  return /* @__PURE__ */ p("td", {
627
- className: g("flexi-cell", !!H[t.key] && "flexi-cell--pinned", t.className),
628
- style: r,
629
- children: t.render ? t.render(n, e) : /* @__PURE__ */ p("span", {
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", {
630
885
  className: "flexi-cell-text",
631
- children: n
886
+ children: i
632
887
  })
633
- }, t.key);
888
+ }, n.key);
634
889
  }),
635
- b && /* @__PURE__ */ p("td", {
890
+ y && /* @__PURE__ */ p("td", {
636
891
  className: "flexi-actions-cell",
637
892
  style: {
638
893
  position: "sticky",
@@ -640,16 +895,16 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
640
895
  },
641
896
  children: /* @__PURE__ */ p("div", {
642
897
  className: "flexi-actions-inner",
643
- children: b(e)
898
+ children: y(e)
644
899
  })
645
900
  })
646
901
  ]
647
902
  }, n ?? `row-${t}`);
648
903
  }
649
- function it(e, t) {
650
- let n = typeof pe == "function" ? pe(e, t) : pe, r = {
904
+ function Ht(e, t) {
905
+ let n = typeof ye == "function" ? ye(e, t) : ye, r = {
651
906
  position: "sticky",
652
- bottom: `${nt[t]}px`,
907
+ bottom: `${Rt[t]}px`,
653
908
  background: "#",
654
909
  zIndex: 45
655
910
  };
@@ -657,7 +912,7 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
657
912
  className: g("flexi-row", "flexi-row--pinned-bottom", n),
658
913
  style: r,
659
914
  children: [
660
- x && M?.length > 0 && /* @__PURE__ */ p("td", {
915
+ b && M?.length > 0 && /* @__PURE__ */ p("td", {
661
916
  className: "flexi-row-indent-cell",
662
917
  style: {
663
918
  position: "sticky",
@@ -666,7 +921,7 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
666
921
  }
667
922
  }),
668
923
  W?.map((t) => {
669
- let n = e[t.key], r = tt(t.key, !1, t.style), i = !!H[t.key], a = t.pinnedRender ?? t.render;
924
+ let n = e[t.key], r = Lt(t.key, !1, t.style), i = !!H[t.key], a = t.pinnedRender ?? t.render;
670
925
  return /* @__PURE__ */ p("td", {
671
926
  className: g("flexi-cell", i && "flexi-cell--pinned", t.className),
672
927
  style: r,
@@ -676,7 +931,7 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
676
931
  })
677
932
  }, t.key);
678
933
  }),
679
- b && /* @__PURE__ */ p("td", {
934
+ y && /* @__PURE__ */ p("td", {
680
935
  className: "flexi-actions-cell",
681
936
  style: {
682
937
  position: "sticky",
@@ -684,7 +939,7 @@ function _({ columns: _, data: v, rowKey: y, actions: b, isLoading: se, groupBy:
684
939
  },
685
940
  children: /* @__PURE__ */ p("div", {
686
941
  className: "flexi-actions-inner",
687
- children: b(e)
942
+ children: y(e)
688
943
  })
689
944
  })
690
945
  ]