react-flexi-datatable 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1052 @@
1
+ import { useEffect as e, useMemo as t, useRef as n, useState as r } from "react";
2
+ import { Check as i, ChevronDown as a, ChevronLeft as o, ChevronRight as s, ChevronUp as c, ChevronsLeft as l, ChevronsRight as u, ChevronsUpDown as d, Columns3 as f, Download as p, Edit3 as m, Eye as h, EyeOff as ee, GripVertical as g, Pencil as te, RotateCcw as ne, Search as re, SlidersHorizontal as ie, Trash2 as ae, X as _ } from "lucide-react";
3
+ //#region \0rolldown/runtime.js
4
+ var v = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), y = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
5
+ if (typeof require < "u") return require.apply(this, arguments);
6
+ throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
7
+ }), b = /* @__PURE__ */ v(((e) => {
8
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
9
+ function r(e, n, r) {
10
+ var i = null;
11
+ if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
12
+ else r = n;
13
+ return n = r.ref, {
14
+ $$typeof: t,
15
+ type: e,
16
+ key: i,
17
+ ref: n === void 0 ? null : n,
18
+ props: r
19
+ };
20
+ }
21
+ e.Fragment = n, e.jsx = r, e.jsxs = r;
22
+ })), x = /* @__PURE__ */ v(((e) => {
23
+ process.env.NODE_ENV !== "production" && (function() {
24
+ function t(e) {
25
+ if (e == null) return null;
26
+ if (typeof e == "function") return e.$$typeof === oe ? null : e.displayName || e.name || null;
27
+ if (typeof e == "string") return e;
28
+ switch (e) {
29
+ case g: return "Fragment";
30
+ case ne: return "Profiler";
31
+ case te: return "StrictMode";
32
+ case _: return "Suspense";
33
+ case v: return "SuspenseList";
34
+ case S: return "Activity";
35
+ }
36
+ if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
37
+ case ee: return "Portal";
38
+ case ie: return e.displayName || "Context";
39
+ case re: return (e._context.displayName || "Context") + ".Consumer";
40
+ case ae:
41
+ var n = e.render;
42
+ return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
43
+ case b: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
44
+ case x:
45
+ n = e._payload, e = e._init;
46
+ try {
47
+ return t(e(n));
48
+ } catch {}
49
+ }
50
+ return null;
51
+ }
52
+ function n(e) {
53
+ return "" + e;
54
+ }
55
+ function r(e) {
56
+ try {
57
+ n(e);
58
+ var t = !1;
59
+ } catch {
60
+ t = !0;
61
+ }
62
+ if (t) {
63
+ t = console;
64
+ var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
65
+ return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
66
+ }
67
+ }
68
+ function i(e) {
69
+ if (e === g) return "<>";
70
+ if (typeof e == "object" && e && e.$$typeof === x) return "<...>";
71
+ try {
72
+ var n = t(e);
73
+ return n ? "<" + n + ">" : "<...>";
74
+ } catch {
75
+ return "<...>";
76
+ }
77
+ }
78
+ function a() {
79
+ var e = se.A;
80
+ return e === null ? null : e.getOwner();
81
+ }
82
+ function o() {
83
+ return Error("react-stack-top-frame");
84
+ }
85
+ function s(e) {
86
+ if (C.call(e, "key")) {
87
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
88
+ if (t && t.isReactWarning) return !1;
89
+ }
90
+ return e.key !== void 0;
91
+ }
92
+ function c(e, t) {
93
+ function n() {
94
+ T || (T = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
95
+ }
96
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
97
+ get: n,
98
+ configurable: !0
99
+ });
100
+ }
101
+ function l() {
102
+ var e = t(this.type);
103
+ return E[e] || (E[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
104
+ }
105
+ function u(e, t, n, r, i, a) {
106
+ var o = n.ref;
107
+ return e = {
108
+ $$typeof: h,
109
+ type: e,
110
+ key: t,
111
+ props: n,
112
+ _owner: r
113
+ }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
114
+ enumerable: !1,
115
+ value: null
116
+ }) : Object.defineProperty(e, "ref", {
117
+ enumerable: !1,
118
+ get: l
119
+ }), e._store = {}, Object.defineProperty(e._store, "validated", {
120
+ configurable: !1,
121
+ enumerable: !1,
122
+ writable: !0,
123
+ value: 0
124
+ }), Object.defineProperty(e, "_debugInfo", {
125
+ configurable: !1,
126
+ enumerable: !1,
127
+ writable: !0,
128
+ value: null
129
+ }), Object.defineProperty(e, "_debugStack", {
130
+ configurable: !1,
131
+ enumerable: !1,
132
+ writable: !0,
133
+ value: i
134
+ }), Object.defineProperty(e, "_debugTask", {
135
+ configurable: !1,
136
+ enumerable: !1,
137
+ writable: !0,
138
+ value: a
139
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
140
+ }
141
+ function d(e, n, i, o, l, d) {
142
+ var p = n.children;
143
+ if (p !== void 0) {
144
+ if (o) {
145
+ if (ce(p)) {
146
+ for (o = 0; o < p.length; o++) f(p[o]);
147
+ Object.freeze && Object.freeze(p);
148
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
149
+ } else f(p);
150
+ }
151
+ if (C.call(n, "key")) {
152
+ p = t(e);
153
+ var m = Object.keys(n).filter(function(e) {
154
+ return e !== "key";
155
+ });
156
+ o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", O[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), O[p + o] = !0);
157
+ }
158
+ if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
159
+ else i = n;
160
+ return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
161
+ }
162
+ function f(e) {
163
+ p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === x && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
164
+ }
165
+ function p(e) {
166
+ return typeof e == "object" && !!e && e.$$typeof === h;
167
+ }
168
+ var m = y("react"), h = Symbol.for("react.transitional.element"), ee = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), te = Symbol.for("react.strict_mode"), ne = Symbol.for("react.profiler"), re = Symbol.for("react.consumer"), ie = Symbol.for("react.context"), ae = Symbol.for("react.forward_ref"), _ = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), b = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), S = Symbol.for("react.activity"), oe = Symbol.for("react.client.reference"), se = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, ce = Array.isArray, w = console.createTask ? console.createTask : function() {
169
+ return null;
170
+ };
171
+ m = { react_stack_bottom_frame: function(e) {
172
+ return e();
173
+ } };
174
+ var T, E = {}, D = m.react_stack_bottom_frame.bind(m, o)(), le = w(i(o)), O = {};
175
+ e.Fragment = g, e.jsx = function(e, t, n) {
176
+ var r = 1e4 > se.recentlyCreatedOwnerStacks++;
177
+ return d(e, t, n, !1, r ? Error("react-stack-top-frame") : D, r ? w(i(e)) : le);
178
+ }, e.jsxs = function(e, t, n) {
179
+ var r = 1e4 > se.recentlyCreatedOwnerStacks++;
180
+ return d(e, t, n, !0, r ? Error("react-stack-top-frame") : D, r ? w(i(e)) : le);
181
+ };
182
+ })();
183
+ })), S = (/* @__PURE__ */ v(((e, t) => {
184
+ t.exports = process.env.NODE_ENV === "production" ? b() : x();
185
+ })))(), oe = "border border-slate-200 rounded-lg bg-white", se = {
186
+ Active: "bg-emerald-50 text-emerald-700",
187
+ Inactive: "bg-slate-100 text-slate-600",
188
+ Pending: "bg-amber-50 text-amber-700"
189
+ };
190
+ function C({ config: v, data: y = [], onView: b, onEdit: x, onDelete: C, onBulkEdit: ce }) {
191
+ let w = `table_cols_${v.id || v.title || "default"}`, [T, E] = r(y), [D, le] = r(""), [O, ue] = r({}), [k, de] = r({
192
+ key: null,
193
+ dir: null
194
+ }), [fe, A] = r(1), [j, pe] = r(v.pageSize || 10), [M, me] = r(() => {
195
+ try {
196
+ let e = localStorage.getItem(`${w}_visible`);
197
+ if (e) return JSON.parse(e);
198
+ } catch {}
199
+ return Object.fromEntries(v.columns.map((e) => [e.key, e.visible !== !1]));
200
+ }), [N, he] = r(() => {
201
+ try {
202
+ let e = localStorage.getItem(`${w}_order`);
203
+ if (e) return JSON.parse(e);
204
+ } catch {}
205
+ return v.columns.map((e) => e.key);
206
+ }), [P, ge] = r(() => {
207
+ try {
208
+ let e = localStorage.getItem(`${w}_widths`);
209
+ if (e) return JSON.parse(e);
210
+ } catch {}
211
+ return Object.fromEntries(v.columns.map((e) => [e.key, e.width || 160]));
212
+ }), [_e, ve] = r(null), [F, ye] = r(null), [be, I] = r(null), [L, xe] = r([]), [R, z] = r(null), [Se, Ce] = r(!1), [we, Te] = r(!1), [B, V] = r({
213
+ row: 0,
214
+ col: 0
215
+ }), [Ee, De] = r(null), [H, U] = r({}), [Oe, ke] = r(!1), [Ae, je] = r([]), [Me, W] = r({}), [G, K] = r(1), Ne = n(null), Pe = n(null), Fe = n(null), q = n(null);
216
+ e(() => {
217
+ v.searchable && q.current && q.current.focus();
218
+ }, [v.searchable]), e(() => {
219
+ let e = (e) => {
220
+ Pe.current && !Pe.current.contains(e.target) && Te(!1), Fe.current && !Fe.current.contains(e.target) && Ce(!1);
221
+ };
222
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
223
+ }, []), e(() => E(y), [y]), e(() => A(1), [
224
+ D,
225
+ O,
226
+ j
227
+ ]), e(() => {
228
+ try {
229
+ localStorage.setItem(`${w}_order`, JSON.stringify(N));
230
+ } catch {}
231
+ }, [N, w]), e(() => {
232
+ try {
233
+ localStorage.setItem(`${w}_visible`, JSON.stringify(M));
234
+ } catch {}
235
+ }, [M, w]), e(() => {
236
+ try {
237
+ localStorage.setItem(`${w}_widths`, JSON.stringify(P));
238
+ } catch {}
239
+ }, [P, w]);
240
+ let Ie = () => {
241
+ let e = v.columns.map((e) => e.key), t = Object.fromEntries(v.columns.map((e) => [e.key, e.visible !== !1])), n = Object.fromEntries(v.columns.map((e) => [e.key, e.width || 160]));
242
+ he(e), me(t), ge(n);
243
+ try {
244
+ localStorage.removeItem(`${w}_order`), localStorage.removeItem(`${w}_visible`), localStorage.removeItem(`${w}_widths`);
245
+ } catch {}
246
+ }, Le = (e, t) => {
247
+ e.preventDefault(), e.stopPropagation();
248
+ let n = e.clientX, r = P[t] || 160, i = (e) => {
249
+ let i = e.clientX - n, a = Math.max(70, r + i);
250
+ ge((e) => ({
251
+ ...e,
252
+ [t]: a
253
+ }));
254
+ }, a = () => {
255
+ document.removeEventListener("mousemove", i), document.removeEventListener("mouseup", a), ve(null);
256
+ };
257
+ ve(t), document.addEventListener("mousemove", i), document.addEventListener("mouseup", a);
258
+ }, J = t(() => {
259
+ let e = Object.fromEntries(v.columns.map((e) => [e.key, e]));
260
+ return N.map((t) => e[t]).filter((e) => e && M[e.key]);
261
+ }, [
262
+ v.columns,
263
+ N,
264
+ M
265
+ ]), Re = t(() => v.columns.filter((e) => e.editable !== !1), [v.columns]), ze = (e) => {
266
+ if (e.options) return e.options;
267
+ let t = v.filters?.find((t) => t.key === e.key);
268
+ return t?.options ? t.options.filter((e) => e.value !== "all").map((e) => e.value) : null;
269
+ }, Y = v.columnordering !== !1 && v.columnOrdering !== !1, Be = Y && v.dropcolumn !== !1 && v.dropColumn !== !1, Ve = (e, t) => {
270
+ Y && (ye(t), e.dataTransfer.setData("text/plain", t), e.dataTransfer.effectAllowed = "move");
271
+ }, He = (e, t) => {
272
+ e.preventDefault(), Be && (e.dataTransfer.dropEffect = "move", be !== t && I(t));
273
+ }, Ue = (e, t) => {
274
+ e.preventDefault(), e.stopPropagation();
275
+ let n = e.dataTransfer.getData("text/plain") || F;
276
+ n && n !== t && he((e) => {
277
+ let r = [...e], i = r.indexOf(n), a = r.indexOf(t);
278
+ return i !== -1 && a !== -1 && (r.splice(i, 1), r.splice(a, 0, n)), r;
279
+ }), ye(null), I(null);
280
+ }, We = (e) => {
281
+ e && (me((t) => Object.values(t).filter(Boolean).length <= 1 ? t : {
282
+ ...t,
283
+ [e]: !1
284
+ }), ye(null), I(null));
285
+ }, X = t(() => {
286
+ let e = [...T];
287
+ if (D.trim()) {
288
+ let t = D.toLowerCase(), n = v.columns.filter((e) => e.searchable !== !1).map((e) => e.key);
289
+ e = e.filter((e) => n.some((n) => String(e[n] ?? "").toLowerCase().includes(t)));
290
+ }
291
+ return Object.entries(O).forEach(([t, n]) => {
292
+ n && n !== "all" && (e = e.filter((e) => String(e[t]) === String(n)));
293
+ }), k.key && e.sort((e, t) => {
294
+ let n = String(e[k.key] ?? "").toLowerCase(), r = String(t[k.key] ?? "").toLowerCase(), i = n.localeCompare(r, void 0, { numeric: !0 });
295
+ return k.dir === "asc" ? i : -i;
296
+ }), e;
297
+ }, [
298
+ T,
299
+ D,
300
+ O,
301
+ k,
302
+ v.columns
303
+ ]), Z = Math.max(1, Math.ceil(X.length / j)), Q = Math.min(fe, Z), $ = X.slice((Q - 1) * j, Q * j), Ge = t(() => L.length > 0 ? L : $.map((e) => e.id), [L, $]), Ke = (e) => {
304
+ if (k.key !== e) return de({
305
+ key: e,
306
+ dir: "asc"
307
+ });
308
+ if (k.dir === "asc") return de({
309
+ key: e,
310
+ dir: "desc"
311
+ });
312
+ de({
313
+ key: null,
314
+ dir: null
315
+ });
316
+ }, qe = (e) => xe(e ? $.map((e) => e.id) : []), Je = (e) => xe((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]), Ye = (e) => {
317
+ De(e.id), U({ ...e });
318
+ }, Xe = () => {
319
+ De(null), U({});
320
+ }, Ze = () => {
321
+ E((e) => e.map((e) => e.id === Ee ? H : e)), x?.(H), De(null), U({});
322
+ }, Qe = () => {
323
+ let e = {}, t = L.length > 0 ? L : $.map((e) => e.id);
324
+ T.forEach((n) => {
325
+ t.includes(n.id) && (e[n.id] = { ...n });
326
+ }), W(e), je(Re.map((e) => e.key)), ke(!0);
327
+ }, $e = () => {
328
+ ke(!1), W({}), je([]);
329
+ }, et = () => {
330
+ let e = L.length > 0 ? L : $.map((e) => e.id);
331
+ E((t) => t.map((t) => e.includes(t.id) && Me[t.id] || t)), ce?.(e, Me), ke(!1), W({}), je([]);
332
+ };
333
+ return e(() => {
334
+ let e = (e) => {
335
+ if (!v.keyboardNavigation || !$.length) return;
336
+ let t = document.activeElement;
337
+ if (t && (["TEXTAREA"].includes(t.tagName) || t.tagName === "INPUT" && t.type !== "checkbox" || t.tagName === "SELECT")) return;
338
+ let n = !!(v.actions?.view || v.actions?.edit || v.actions?.delete), r = J.length + +!!v.selectable, i = J.length + +!!v.selectable + +!!n, a = t?.closest("[data-cell]"), o = B.row, s = B.col;
339
+ if (a) {
340
+ let e = a.getAttribute("data-cell");
341
+ if (e) {
342
+ let t = e.split("-").map(Number);
343
+ t.length === 2 && !isNaN(t[0]) && !isNaN(t[1]) && (o = t[0], s = t[1]);
344
+ }
345
+ }
346
+ if (e.key === "ArrowDown") {
347
+ e.preventDefault();
348
+ let t = Math.min($.length - 1, o + 1);
349
+ V({
350
+ row: t,
351
+ col: s
352
+ });
353
+ } else if (e.key === "ArrowUp") {
354
+ e.preventDefault();
355
+ let t = Math.max(-1, o - 1);
356
+ V({
357
+ row: t,
358
+ col: s
359
+ });
360
+ } else if (e.key === "ArrowRight") {
361
+ if (e.preventDefault(), n && s === r) {
362
+ let e = Ne.current?.querySelector(`[data-cell="${o}-${s}"]`), t = e ? Array.from(e.querySelectorAll("button")) : [];
363
+ if (G < t.length - 1) {
364
+ K((e) => e + 1);
365
+ return;
366
+ }
367
+ }
368
+ let t = Math.min(i - 1, s + 1);
369
+ V({
370
+ row: o,
371
+ col: t
372
+ });
373
+ } else if (e.key === "ArrowLeft") {
374
+ if (e.preventDefault(), n && s === r && G > 0) {
375
+ K((e) => e - 1);
376
+ return;
377
+ }
378
+ let t = Math.max(0, s - 1);
379
+ V({
380
+ row: o,
381
+ col: t
382
+ });
383
+ } else if (e.key === "Enter" || e.key === " ") {
384
+ if (o === -1) {
385
+ if (v.selectable && s === 0) e.preventDefault(), qe($.length > 0 && !$.every((e) => L.includes(e.id)));
386
+ else {
387
+ let t = v.selectable ? s - 1 : s, n = J[t];
388
+ n && n.sortable && (e.preventDefault(), Ke(n.key));
389
+ }
390
+ } else {
391
+ let i = $[o];
392
+ t && (t.type === "checkbox" || t.tagName === "BUTTON") ? (e.key === "Enter" || e.key === " ") && (e.preventDefault(), t.click()) : i && (v.selectable && s === 0 ? (e.preventDefault(), Je(i.id)) : n && s === r ? (e.preventDefault(), Ye(i)) : e.key === "Enter" && (e.preventDefault(), b?.(i)));
393
+ }
394
+ }
395
+ };
396
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
397
+ }, [
398
+ v.keyboardNavigation,
399
+ $,
400
+ J,
401
+ B,
402
+ G,
403
+ Je,
404
+ qe,
405
+ Ke,
406
+ b,
407
+ v.selectable,
408
+ L
409
+ ]), e(() => {
410
+ if (!v.keyboardNavigation || !Ne.current || document.activeElement === q.current) return;
411
+ let e = Ne.current.querySelector(`[data-cell="${B.row}-${B.col}"]`);
412
+ if (e) {
413
+ let t = Array.from(e.querySelectorAll("input, button, select"));
414
+ t.length > 0 ? (t[Math.min(G, t.length - 1)] || t[0]).focus() : e.focus();
415
+ }
416
+ }, [
417
+ B,
418
+ G,
419
+ v.keyboardNavigation,
420
+ $
421
+ ]), /* @__PURE__ */ (0, S.jsxs)("div", {
422
+ className: "space-y-3",
423
+ children: [
424
+ /* @__PURE__ */ (0, S.jsx)("div", {
425
+ className: `${oe} p-4`,
426
+ children: /* @__PURE__ */ (0, S.jsxs)("div", {
427
+ className: "flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",
428
+ children: [/* @__PURE__ */ (0, S.jsxs)("div", { children: [/* @__PURE__ */ (0, S.jsx)("h2", {
429
+ className: "text-lg font-semibold",
430
+ children: v.title
431
+ }), /* @__PURE__ */ (0, S.jsxs)("p", {
432
+ className: "text-sm text-slate-500",
433
+ children: [X.length, " records"]
434
+ })] }), /* @__PURE__ */ (0, S.jsxs)("div", {
435
+ className: "flex flex-wrap gap-2",
436
+ children: [
437
+ v.searchable && /* @__PURE__ */ (0, S.jsxs)("div", {
438
+ className: "relative",
439
+ children: [
440
+ /* @__PURE__ */ (0, S.jsx)(re, {
441
+ size: 16,
442
+ className: "absolute left-3 top-1/2 -translate-y-1/2 text-slate-400"
443
+ }),
444
+ /* @__PURE__ */ (0, S.jsx)("input", {
445
+ ref: q,
446
+ autoFocus: !0,
447
+ value: D,
448
+ onChange: (e) => le(e.target.value),
449
+ placeholder: "Search...",
450
+ className: "w-56 rounded-lg border border-slate-200 py-2 pl-9 pr-8 text-sm outline-none focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500/20"
451
+ }),
452
+ D && /* @__PURE__ */ (0, S.jsx)("button", {
453
+ onClick: () => {
454
+ le(""), q.current?.focus();
455
+ },
456
+ className: "absolute right-2 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600",
457
+ children: /* @__PURE__ */ (0, S.jsx)(_, { size: 15 })
458
+ })
459
+ ]
460
+ }),
461
+ v.filterable && /* @__PURE__ */ (0, S.jsxs)("div", {
462
+ ref: Pe,
463
+ className: "relative",
464
+ children: [/* @__PURE__ */ (0, S.jsxs)("button", {
465
+ onClick: () => Te((e) => !e),
466
+ className: "flex items-center gap-2 rounded-lg border border-slate-200 px-3 py-2 text-sm",
467
+ children: [/* @__PURE__ */ (0, S.jsx)(ie, { size: 16 }), "Filter"]
468
+ }), we && /* @__PURE__ */ (0, S.jsxs)("div", {
469
+ className: "absolute right-0 z-30 mt-2 w-64 rounded-xl border bg-white p-4 shadow-xl",
470
+ children: [v.filters?.map((e) => /* @__PURE__ */ (0, S.jsxs)("label", {
471
+ className: "mb-3 block text-sm",
472
+ children: [/* @__PURE__ */ (0, S.jsx)("span", {
473
+ className: "mb-1 block font-medium",
474
+ children: e.label
475
+ }), /* @__PURE__ */ (0, S.jsx)("select", {
476
+ value: O[e.key] || "all",
477
+ onChange: (t) => ue((n) => ({
478
+ ...n,
479
+ [e.key]: t.target.value
480
+ })),
481
+ className: "w-full rounded-lg border p-2",
482
+ children: e.options.map((e) => /* @__PURE__ */ (0, S.jsx)("option", {
483
+ value: e.value,
484
+ children: e.label
485
+ }, e.value))
486
+ })]
487
+ }, e.key)), /* @__PURE__ */ (0, S.jsx)("button", {
488
+ onClick: () => ue({}),
489
+ className: "text-sm font-medium text-slate-600",
490
+ children: "Clear filters"
491
+ })]
492
+ })]
493
+ }),
494
+ v.columnVisibility && /* @__PURE__ */ (0, S.jsxs)("div", {
495
+ ref: Fe,
496
+ className: "relative",
497
+ children: [/* @__PURE__ */ (0, S.jsxs)("button", {
498
+ onClick: () => Ce((e) => !e),
499
+ className: "flex items-center gap-2 rounded-lg border border-slate-200 px-3 py-2 text-sm",
500
+ children: [/* @__PURE__ */ (0, S.jsx)(f, { size: 16 }), "Columns"]
501
+ }), Se && /* @__PURE__ */ (0, S.jsxs)("div", {
502
+ className: "absolute right-0 z-30 mt-2 w-64 rounded-xl border bg-white p-3.5 shadow-xl",
503
+ children: [
504
+ /* @__PURE__ */ (0, S.jsxs)("div", {
505
+ className: "flex items-center justify-between pb-2 mb-2 border-b",
506
+ children: [/* @__PURE__ */ (0, S.jsx)("span", {
507
+ className: "text-xs font-semibold uppercase tracking-wider text-slate-500",
508
+ children: "Columns & Layout"
509
+ }), /* @__PURE__ */ (0, S.jsxs)("button", {
510
+ onClick: Ie,
511
+ className: "flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-800 font-medium",
512
+ title: "Reset default layout",
513
+ children: [/* @__PURE__ */ (0, S.jsx)(ne, { size: 12 }), "Reset"]
514
+ })]
515
+ }),
516
+ /* @__PURE__ */ (0, S.jsx)("div", {
517
+ className: "space-y-1 max-h-64 overflow-y-auto",
518
+ children: N.map((e) => {
519
+ let t = v.columns.find((t) => t.key === e);
520
+ if (!t) return null;
521
+ let n = M[e] !== !1;
522
+ return /* @__PURE__ */ (0, S.jsxs)("div", {
523
+ draggable: !0,
524
+ onDragStart: (e) => Ve(e, t.key),
525
+ onDragOver: (e) => He(e, t.key),
526
+ onDrop: (e) => Ue(e, t.key),
527
+ className: `flex items-center justify-between p-2 text-sm rounded-lg hover:bg-slate-50 cursor-grab active:cursor-grabbing transition-colors ${F === t.key ? "opacity-30 bg-slate-100" : ""} ${be === t.key && F !== t.key ? "border-l-4 border-l-indigo-600 bg-indigo-50/60" : ""}`,
528
+ children: [/* @__PURE__ */ (0, S.jsxs)("div", {
529
+ className: "flex items-center gap-2",
530
+ children: [/* @__PURE__ */ (0, S.jsx)("span", {
531
+ title: "Drag to reorder",
532
+ className: "text-slate-300 hover:text-slate-500 cursor-grab",
533
+ children: /* @__PURE__ */ (0, S.jsx)(g, { size: 14 })
534
+ }), /* @__PURE__ */ (0, S.jsxs)("label", {
535
+ className: "flex items-center gap-2 cursor-pointer select-none",
536
+ children: [/* @__PURE__ */ (0, S.jsx)("input", {
537
+ type: "checkbox",
538
+ checked: n,
539
+ onChange: () => me((e) => {
540
+ let n = Object.values(e).filter(Boolean).length;
541
+ return e[t.key] && n === 1 ? e : {
542
+ ...e,
543
+ [t.key]: !e[t.key]
544
+ };
545
+ }),
546
+ className: "rounded text-indigo-600 focus:ring-indigo-500"
547
+ }), /* @__PURE__ */ (0, S.jsx)("span", {
548
+ className: n ? "font-medium text-slate-800" : "text-slate-400 line-through",
549
+ children: t.label
550
+ })]
551
+ })]
552
+ }), /* @__PURE__ */ (0, S.jsxs)("span", {
553
+ className: "text-xs text-slate-400 font-mono",
554
+ children: [P[t.key] || 160, "px"]
555
+ })]
556
+ }, t.key);
557
+ })
558
+ }),
559
+ /* @__PURE__ */ (0, S.jsx)("p", {
560
+ className: "mt-2.5 pt-2 border-t text-[11px] text-slate-400 text-center",
561
+ children: "Drag handles to reorder | Drag column edge to resize"
562
+ })
563
+ ]
564
+ })]
565
+ }),
566
+ v.bulkEditable !== !1 && Re.length > 0 && /* @__PURE__ */ (0, S.jsxs)("button", {
567
+ onClick: Qe,
568
+ className: `flex items-center gap-2 rounded-lg border px-3 py-2 text-sm font-medium transition-colors ${Oe ? "border-indigo-500 bg-indigo-600 text-white" : L.length > 0 ? "border-indigo-300 bg-indigo-50 text-indigo-700 hover:bg-indigo-100" : "border-slate-200 bg-white text-slate-700 hover:bg-slate-50"}`,
569
+ children: [
570
+ /* @__PURE__ */ (0, S.jsx)(m, { size: 16 }),
571
+ "Bulk Edit",
572
+ L.length > 0 ? ` (${L.length})` : ""
573
+ ]
574
+ }),
575
+ v.exportable && /* @__PURE__ */ (0, S.jsxs)("button", {
576
+ onClick: () => {
577
+ let e = J.map((e) => e.label).join(","), t = X.map((e) => J.map((t) => `"${String(e[t.key] ?? "").replaceAll("\"", "\"\"")}"`).join(",")).join("\n"), n = new Blob([e + "\n" + t], { type: "text/csv" }), r = document.createElement("a");
578
+ r.href = URL.createObjectURL(n), r.download = "table-export.csv", r.click(), URL.revokeObjectURL(r.href);
579
+ },
580
+ className: "flex items-center gap-2 rounded-lg border border-slate-200 px-3 py-2 text-sm",
581
+ children: [/* @__PURE__ */ (0, S.jsx)(p, { size: 16 }), "Export"]
582
+ })
583
+ ]
584
+ })]
585
+ })
586
+ }),
587
+ Be && /* @__PURE__ */ (0, S.jsx)("div", {
588
+ onDragOver: (e) => {
589
+ e.preventDefault(), e.dataTransfer.dropEffect = "move";
590
+ },
591
+ onDrop: (e) => {
592
+ e.preventDefault();
593
+ let t = e.dataTransfer.getData("text/plain") || F;
594
+ t && We(t);
595
+ },
596
+ className: `transition-all duration-200 overflow-hidden ${F ? "max-h-24 opacity-100 my-2" : "max-h-0 opacity-0 my-0 pointer-events-none"}`,
597
+ children: /* @__PURE__ */ (0, S.jsxs)("div", {
598
+ className: "flex items-center justify-center gap-2 rounded-xl border-2 border-dashed border-rose-400 bg-rose-50 p-3 text-sm font-semibold text-rose-700 shadow-sm",
599
+ children: [/* @__PURE__ */ (0, S.jsx)(ae, {
600
+ size: 20,
601
+ className: "text-rose-600 animate-bounce"
602
+ }), /* @__PURE__ */ (0, S.jsxs)("span", { children: ["Drop column header here to hide column ", /* @__PURE__ */ (0, S.jsx)("b", { children: v.columns.find((e) => e.key === F)?.label })] })]
603
+ })
604
+ }),
605
+ Oe && /* @__PURE__ */ (0, S.jsxs)("div", {
606
+ className: "flex flex-wrap items-center justify-between gap-3 rounded-xl border border-indigo-200 bg-indigo-50/80 p-3.5 shadow-sm",
607
+ children: [/* @__PURE__ */ (0, S.jsxs)("div", {
608
+ className: "flex flex-wrap items-center gap-3",
609
+ children: [/* @__PURE__ */ (0, S.jsxs)("div", {
610
+ className: "flex items-center gap-2",
611
+ children: [/* @__PURE__ */ (0, S.jsx)(m, {
612
+ size: 18,
613
+ className: "text-indigo-600"
614
+ }), /* @__PURE__ */ (0, S.jsxs)("span", {
615
+ className: "font-semibold text-slate-900 text-sm",
616
+ children: [
617
+ "Bulk Edit Mode (",
618
+ Ge.length,
619
+ " records):"
620
+ ]
621
+ })]
622
+ }), /* @__PURE__ */ (0, S.jsxs)("div", {
623
+ className: "flex flex-wrap items-center gap-2",
624
+ children: [/* @__PURE__ */ (0, S.jsx)("span", {
625
+ className: "text-xs font-medium text-slate-600",
626
+ children: "Select columns to edit:"
627
+ }), Re.map((e) => {
628
+ let t = Ae.includes(e.key);
629
+ return /* @__PURE__ */ (0, S.jsxs)("button", {
630
+ type: "button",
631
+ onClick: () => {
632
+ je(t ? (t) => t.filter((t) => t !== e.key) : (t) => [...t, e.key]);
633
+ },
634
+ className: `flex items-center gap-1.5 rounded-lg px-2.5 py-1 text-xs font-medium border transition-all ${t ? "border-indigo-500 bg-indigo-600 text-white shadow-xs" : "border-slate-200 bg-white text-slate-700 hover:border-slate-300 hover:bg-slate-50"}`,
635
+ children: [/* @__PURE__ */ (0, S.jsx)("span", {
636
+ className: `flex h-3.5 w-3.5 items-center justify-center rounded border ${t ? "border-white bg-white text-indigo-600" : "border-slate-300 bg-white"}`,
637
+ children: t && /* @__PURE__ */ (0, S.jsx)(i, {
638
+ size: 10,
639
+ strokeWidth: 3
640
+ })
641
+ }), /* @__PURE__ */ (0, S.jsx)("span", { children: e.label })]
642
+ }, e.key);
643
+ })]
644
+ })]
645
+ }), /* @__PURE__ */ (0, S.jsxs)("div", {
646
+ className: "flex items-center gap-2",
647
+ children: [/* @__PURE__ */ (0, S.jsxs)("button", {
648
+ onClick: $e,
649
+ className: "flex items-center gap-1.5 rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs font-medium text-slate-700 hover:bg-slate-50 transition-colors",
650
+ children: [/* @__PURE__ */ (0, S.jsx)(_, {
651
+ size: 14,
652
+ className: "text-rose-500"
653
+ }), "Cancel"]
654
+ }), /* @__PURE__ */ (0, S.jsxs)("button", {
655
+ onClick: et,
656
+ className: "flex items-center gap-1.5 rounded-lg bg-emerald-600 px-3.5 py-1.5 text-xs font-medium text-white hover:bg-emerald-700 shadow-sm transition-colors",
657
+ children: [/* @__PURE__ */ (0, S.jsx)(i, { size: 14 }), "Save"]
658
+ })]
659
+ })]
660
+ }),
661
+ /* @__PURE__ */ (0, S.jsxs)("div", {
662
+ className: `${oe} overflow-hidden`,
663
+ children: [/* @__PURE__ */ (0, S.jsx)("div", {
664
+ className: "overflow-x-auto",
665
+ children: /* @__PURE__ */ (0, S.jsxs)("table", {
666
+ ref: Ne,
667
+ className: "min-w-full text-sm table-fixed",
668
+ children: [/* @__PURE__ */ (0, S.jsx)("thead", {
669
+ className: "border-b bg-slate-50",
670
+ children: /* @__PURE__ */ (0, S.jsxs)("tr", { children: [
671
+ v.selectable && /* @__PURE__ */ (0, S.jsx)("th", {
672
+ "data-cell": "-1-0",
673
+ className: "w-12 px-4 py-3",
674
+ children: /* @__PURE__ */ (0, S.jsx)("input", {
675
+ type: "checkbox",
676
+ checked: $.length > 0 && $.every((e) => L.includes(e.id)),
677
+ onChange: (e) => qe(e.target.checked),
678
+ onFocus: () => V({
679
+ row: -1,
680
+ col: 0
681
+ })
682
+ })
683
+ }),
684
+ J.map((e, t) => {
685
+ let n = v.selectable ? t + 1 : t, r = F === e.key, i = be === e.key && F !== e.key, o = P[e.key] || e.width || 160;
686
+ return /* @__PURE__ */ (0, S.jsxs)("th", {
687
+ "data-cell": `-1-${n}`,
688
+ style: {
689
+ width: `${o}px`,
690
+ minWidth: `${o}px`
691
+ },
692
+ draggable: Y,
693
+ onDragStart: (t) => Ve(t, e.key),
694
+ onDragOver: (t) => He(t, e.key),
695
+ onDragLeave: () => I(null),
696
+ onDrop: (t) => Ue(t, e.key),
697
+ onDragEnd: () => {
698
+ ye(null), I(null);
699
+ },
700
+ "aria-sort": k.key === e.key ? k.dir : "none",
701
+ className: `group relative whitespace-nowrap px-4 py-3 text-left font-semibold text-slate-600 ${Y ? "cursor-grab active:cursor-grabbing" : ""} transition-colors select-none ${r ? "opacity-30 bg-slate-100" : ""} ${i ? "border-l-4 border-l-indigo-600 bg-indigo-50/60" : ""}`,
702
+ children: [/* @__PURE__ */ (0, S.jsxs)("div", {
703
+ className: "flex items-center justify-between gap-1.5 pr-2",
704
+ children: [/* @__PURE__ */ (0, S.jsxs)("div", {
705
+ className: "flex items-center gap-1.5 overflow-hidden",
706
+ children: [Y && /* @__PURE__ */ (0, S.jsx)("span", {
707
+ title: "Drag header to reorder",
708
+ className: "text-slate-300 group-hover:text-slate-500 cursor-grab shrink-0",
709
+ children: /* @__PURE__ */ (0, S.jsx)(g, { size: 14 })
710
+ }), /* @__PURE__ */ (0, S.jsxs)("button", {
711
+ disabled: !e.sortable,
712
+ onClick: () => e.sortable && Ke(e.key),
713
+ className: `flex items-center gap-1 truncate ${e.sortable ? "hover:text-slate-900" : ""}`,
714
+ children: [/* @__PURE__ */ (0, S.jsx)("span", {
715
+ className: "truncate",
716
+ children: e.label
717
+ }), e.sortable && (k.key === e.key ? k.dir === "asc" ? /* @__PURE__ */ (0, S.jsx)(c, {
718
+ size: 15,
719
+ className: "shrink-0"
720
+ }) : /* @__PURE__ */ (0, S.jsx)(a, {
721
+ size: 15,
722
+ className: "shrink-0"
723
+ }) : /* @__PURE__ */ (0, S.jsx)(d, {
724
+ size: 15,
725
+ className: "text-slate-400 shrink-0"
726
+ }))]
727
+ })]
728
+ }), /* @__PURE__ */ (0, S.jsx)("button", {
729
+ type: "button",
730
+ title: "Hide column",
731
+ onClick: (t) => {
732
+ t.stopPropagation(), We(e.key);
733
+ },
734
+ className: "opacity-0 group-hover:opacity-100 transition-opacity p-0.5 text-slate-400 hover:text-rose-600 rounded shrink-0",
735
+ children: /* @__PURE__ */ (0, S.jsx)(ee, { size: 13 })
736
+ })]
737
+ }), /* @__PURE__ */ (0, S.jsx)("div", {
738
+ draggable: !1,
739
+ onMouseDown: (t) => Le(t, e.key),
740
+ onDoubleClick: (t) => {
741
+ t.stopPropagation(), ge((t) => ({
742
+ ...t,
743
+ [e.key]: e.width || 160
744
+ }));
745
+ },
746
+ title: "Drag to resize column width",
747
+ className: `absolute right-0 top-0 bottom-0 w-2.5 cursor-col-resize group-hover:bg-indigo-300/50 hover:!bg-indigo-500 transition-colors z-10 ${_e === e.key ? "bg-indigo-600 w-1" : ""}`
748
+ })]
749
+ }, e.key);
750
+ }),
751
+ (v.actions?.view || v.actions?.edit || v.actions?.delete) && /* @__PURE__ */ (0, S.jsx)("th", {
752
+ className: "sticky right-0 bg-slate-50 px-4 py-3 text-right font-semibold text-slate-600 w-32",
753
+ children: "Actions"
754
+ })
755
+ ] })
756
+ }), /* @__PURE__ */ (0, S.jsxs)("tbody", { children: [$.map((e, t) => {
757
+ let n = Ee === e.id, r = Oe && Ge.includes(e.id);
758
+ return /* @__PURE__ */ (0, S.jsxs)("tr", {
759
+ className: `border-b last:border-0 ${n || r ? "bg-indigo-50/20" : "hover:bg-slate-50"}`,
760
+ children: [
761
+ v.selectable && /* @__PURE__ */ (0, S.jsx)("td", {
762
+ "data-cell": `${t}-0`,
763
+ className: "px-4 py-3",
764
+ children: /* @__PURE__ */ (0, S.jsx)("input", {
765
+ type: "checkbox",
766
+ checked: L.includes(e.id),
767
+ onChange: () => Je(e.id),
768
+ onFocus: () => V({
769
+ row: t,
770
+ col: 0
771
+ })
772
+ })
773
+ }),
774
+ J.map((i, a) => {
775
+ let o = v.selectable ? a + 1 : a, s = r && Ae.includes(i.key) && i.editable !== !1, c = ze(i), l = P[i.key] || i.width || 160, u = e[i.key], d = u == null ? "" : String(u), f = d.length > 25;
776
+ return /* @__PURE__ */ (0, S.jsx)("td", {
777
+ "data-cell": `${t}-${o}`,
778
+ style: {
779
+ width: `${l}px`,
780
+ minWidth: `${l}px`
781
+ },
782
+ className: "px-4 py-3 truncate",
783
+ tabIndex: -1,
784
+ title: f ? d : void 0,
785
+ children: n && i.editable !== !1 ? c ? /* @__PURE__ */ (0, S.jsx)("select", {
786
+ value: H[i.key] ?? "",
787
+ onChange: (e) => U({
788
+ ...H,
789
+ [i.key]: e.target.value
790
+ }),
791
+ onKeyDown: (e) => {
792
+ e.key === "Enter" && Ze(), e.key === "Escape" && Xe();
793
+ },
794
+ className: "w-full rounded-md border border-indigo-300 bg-white px-2 py-1 text-sm outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500",
795
+ children: c.map((e) => {
796
+ let t = typeof e == "object" ? e.value : e, n = typeof e == "object" ? e.label : e;
797
+ return /* @__PURE__ */ (0, S.jsx)("option", {
798
+ value: t,
799
+ children: n
800
+ }, t);
801
+ })
802
+ }) : /* @__PURE__ */ (0, S.jsx)("input", {
803
+ type: "text",
804
+ value: H[i.key] ?? "",
805
+ onChange: (e) => U({
806
+ ...H,
807
+ [i.key]: e.target.value
808
+ }),
809
+ onKeyDown: (e) => {
810
+ e.key === "Enter" && Ze(), e.key === "Escape" && Xe();
811
+ },
812
+ className: "w-full rounded-md border border-indigo-300 bg-white px-2 py-1 text-sm outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500"
813
+ }) : s ? c ? /* @__PURE__ */ (0, S.jsx)("select", {
814
+ value: Me[e.id]?.[i.key] ?? e[i.key] ?? "",
815
+ onChange: (t) => W((n) => ({
816
+ ...n,
817
+ [e.id]: {
818
+ ...n[e.id] || e,
819
+ [i.key]: t.target.value
820
+ }
821
+ })),
822
+ onKeyDown: (e) => {
823
+ e.key === "Enter" && et(), e.key === "Escape" && $e();
824
+ },
825
+ className: "w-full rounded-md border border-indigo-400 bg-white px-2 py-1 text-sm outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500",
826
+ children: c.map((e) => {
827
+ let t = typeof e == "object" ? e.value : e, n = typeof e == "object" ? e.label : e;
828
+ return /* @__PURE__ */ (0, S.jsx)("option", {
829
+ value: t,
830
+ children: n
831
+ }, t);
832
+ })
833
+ }) : /* @__PURE__ */ (0, S.jsx)("input", {
834
+ type: "text",
835
+ value: Me[e.id]?.[i.key] ?? e[i.key] ?? "",
836
+ onChange: (t) => W((n) => ({
837
+ ...n,
838
+ [e.id]: {
839
+ ...n[e.id] || e,
840
+ [i.key]: t.target.value
841
+ }
842
+ })),
843
+ onKeyDown: (e) => {
844
+ e.key === "Enter" && et(), e.key === "Escape" && $e();
845
+ },
846
+ className: "w-full rounded-md border border-indigo-400 bg-white px-2 py-1 text-sm outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500"
847
+ }) : i.render ? i.render(u, e, t) : i.key === "status" ? /* @__PURE__ */ (0, S.jsx)("span", {
848
+ className: `rounded-full px-2.5 py-1 text-xs font-medium ${se[u] || "bg-slate-100 text-slate-600"}`,
849
+ children: u
850
+ }) : f ? /* @__PURE__ */ (0, S.jsxs)("span", {
851
+ title: d,
852
+ children: [d.slice(0, 25), "..."]
853
+ }) : d
854
+ }, i.key);
855
+ }),
856
+ (v.actions?.view || v.actions?.edit || v.actions?.delete) && /* @__PURE__ */ (0, S.jsx)("td", {
857
+ "data-cell": `${t}-${J.length + +!!v.selectable}`,
858
+ className: "sticky right-0 bg-white px-4 py-3 w-32",
859
+ children: n ? /* @__PURE__ */ (0, S.jsxs)("div", {
860
+ className: "flex justify-end gap-1",
861
+ children: [/* @__PURE__ */ (0, S.jsx)("button", {
862
+ title: "Save",
863
+ onClick: Ze,
864
+ className: "rounded-md bg-emerald-100 p-2 text-emerald-700 hover:bg-emerald-200",
865
+ children: /* @__PURE__ */ (0, S.jsx)(i, { size: 16 })
866
+ }), /* @__PURE__ */ (0, S.jsx)("button", {
867
+ title: "Cancel",
868
+ onClick: Xe,
869
+ className: "rounded-md bg-rose-100 p-2 text-rose-700 hover:bg-rose-200",
870
+ children: /* @__PURE__ */ (0, S.jsx)(_, { size: 16 })
871
+ })]
872
+ }) : /* @__PURE__ */ (0, S.jsxs)("div", {
873
+ className: "flex justify-end gap-1",
874
+ children: [
875
+ v.actions.view && /* @__PURE__ */ (0, S.jsx)("button", {
876
+ title: "View",
877
+ onClick: () => b?.(e),
878
+ onFocus: () => {
879
+ V({
880
+ row: t,
881
+ col: J.length + +!!v.selectable
882
+ }), K(0);
883
+ },
884
+ className: "rounded-md p-2 hover:bg-slate-100 focus:outline-none focus:ring-2 focus:ring-slate-400",
885
+ children: /* @__PURE__ */ (0, S.jsx)(h, { size: 16 })
886
+ }),
887
+ v.actions.edit && /* @__PURE__ */ (0, S.jsx)("button", {
888
+ title: "Edit",
889
+ onClick: () => Ye(e),
890
+ onFocus: () => {
891
+ V({
892
+ row: t,
893
+ col: J.length + +!!v.selectable
894
+ }), K(1);
895
+ },
896
+ className: "rounded-md p-2 hover:bg-slate-100 focus:outline-none focus:ring-2 focus:ring-slate-400",
897
+ children: /* @__PURE__ */ (0, S.jsx)(te, { size: 16 })
898
+ }),
899
+ v.actions.delete && /* @__PURE__ */ (0, S.jsx)("button", {
900
+ title: "Delete",
901
+ onClick: () => z(e),
902
+ onFocus: () => {
903
+ V({
904
+ row: t,
905
+ col: J.length + +!!v.selectable
906
+ }), K(2);
907
+ },
908
+ className: "rounded-md p-2 text-red-600 hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-red-400",
909
+ children: /* @__PURE__ */ (0, S.jsx)(ae, { size: 16 })
910
+ })
911
+ ]
912
+ })
913
+ })
914
+ ]
915
+ }, e.id);
916
+ }), !$.length && /* @__PURE__ */ (0, S.jsx)("tr", { children: /* @__PURE__ */ (0, S.jsxs)("td", {
917
+ colSpan: J.length + +!!v.selectable + 1,
918
+ className: "px-6 py-16 text-center",
919
+ children: [/* @__PURE__ */ (0, S.jsx)("div", {
920
+ className: "font-medium",
921
+ children: "No records found"
922
+ }), /* @__PURE__ */ (0, S.jsx)("div", {
923
+ className: "mt-1 text-sm text-slate-500",
924
+ children: "Try changing your search or filters."
925
+ })]
926
+ }) })] })]
927
+ })
928
+ }), /* @__PURE__ */ (0, S.jsxs)("div", {
929
+ className: "flex flex-col gap-3 border-t bg-white px-4 py-3 sm:flex-row sm:items-center sm:justify-between",
930
+ children: [/* @__PURE__ */ (0, S.jsxs)("div", {
931
+ className: "text-sm text-slate-500",
932
+ children: [
933
+ "Showing ",
934
+ X.length ? (Q - 1) * j + 1 : 0,
935
+ "–",
936
+ Math.min(Q * j, X.length),
937
+ " of ",
938
+ X.length
939
+ ]
940
+ }), /* @__PURE__ */ (0, S.jsxs)("div", {
941
+ className: "flex items-center gap-2",
942
+ children: [
943
+ /* @__PURE__ */ (0, S.jsx)("select", {
944
+ value: j,
945
+ onChange: (e) => pe(Number(e.target.value)),
946
+ className: "rounded-lg border border-slate-200 px-2 py-1.5 text-sm",
947
+ children: v.pageSizeOptions.map((e) => /* @__PURE__ */ (0, S.jsxs)("option", {
948
+ value: e,
949
+ children: [e, "/page"]
950
+ }, e))
951
+ }),
952
+ /* @__PURE__ */ (0, S.jsx)("button", {
953
+ disabled: Q === 1,
954
+ onClick: () => A(1),
955
+ className: "rounded-md border p-1.5 disabled:opacity-40",
956
+ children: /* @__PURE__ */ (0, S.jsx)(l, { size: 16 })
957
+ }),
958
+ /* @__PURE__ */ (0, S.jsx)("button", {
959
+ disabled: Q === 1,
960
+ onClick: () => A((e) => e - 1),
961
+ className: "rounded-md border p-1.5 disabled:opacity-40",
962
+ children: /* @__PURE__ */ (0, S.jsx)(o, { size: 16 })
963
+ }),
964
+ /* @__PURE__ */ (0, S.jsxs)("span", {
965
+ className: "px-2 text-sm",
966
+ children: [
967
+ "Page ",
968
+ Q,
969
+ " of ",
970
+ Z
971
+ ]
972
+ }),
973
+ /* @__PURE__ */ (0, S.jsx)("button", {
974
+ disabled: Q === Z,
975
+ onClick: () => A((e) => e + 1),
976
+ className: "rounded-md border p-1.5 disabled:opacity-40",
977
+ children: /* @__PURE__ */ (0, S.jsx)(s, { size: 16 })
978
+ }),
979
+ /* @__PURE__ */ (0, S.jsx)("button", {
980
+ disabled: Q === Z,
981
+ onClick: () => A(Z),
982
+ className: "rounded-md border p-1.5 disabled:opacity-40",
983
+ children: /* @__PURE__ */ (0, S.jsx)(u, { size: 16 })
984
+ })
985
+ ]
986
+ })]
987
+ })]
988
+ }),
989
+ L.length > 0 && !Oe && /* @__PURE__ */ (0, S.jsxs)("div", {
990
+ className: "fixed bottom-5 left-1/2 z-40 flex -translate-x-1/2 items-center gap-3 rounded-xl bg-slate-900 px-4 py-2.5 text-sm text-white shadow-xl",
991
+ children: [
992
+ /* @__PURE__ */ (0, S.jsxs)("span", {
993
+ className: "font-medium pl-1",
994
+ children: [L.length, " selected"]
995
+ }),
996
+ v.bulkEditable !== !1 && Re.length > 0 && /* @__PURE__ */ (0, S.jsxs)("button", {
997
+ onClick: Qe,
998
+ className: "flex items-center gap-1.5 rounded-lg bg-indigo-600 px-3 py-1.5 text-xs font-semibold text-white hover:bg-indigo-500 transition-colors shadow-sm",
999
+ children: [/* @__PURE__ */ (0, S.jsx)(m, { size: 14 }), "Bulk Edit"]
1000
+ }),
1001
+ /* @__PURE__ */ (0, S.jsx)("button", {
1002
+ onClick: () => xe([]),
1003
+ className: "text-xs text-slate-400 hover:text-white underline pr-1",
1004
+ children: "Clear"
1005
+ })
1006
+ ]
1007
+ }),
1008
+ R && /* @__PURE__ */ (0, S.jsx)("div", {
1009
+ onClick: (e) => {
1010
+ e.target === e.currentTarget && z(null);
1011
+ },
1012
+ className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",
1013
+ children: /* @__PURE__ */ (0, S.jsxs)("div", {
1014
+ className: "w-full max-w-sm rounded-2xl bg-white p-6 shadow-2xl",
1015
+ children: [
1016
+ /* @__PURE__ */ (0, S.jsx)("h3", {
1017
+ className: "text-lg font-semibold",
1018
+ children: "Delete record?"
1019
+ }),
1020
+ /* @__PURE__ */ (0, S.jsxs)("p", {
1021
+ className: "mt-2 text-sm text-slate-500",
1022
+ children: [
1023
+ "Are you sure you want to delete ",
1024
+ /* @__PURE__ */ (0, S.jsx)("b", { children: R.name }),
1025
+ "? This action cannot be undone."
1026
+ ]
1027
+ }),
1028
+ /* @__PURE__ */ (0, S.jsxs)("div", {
1029
+ className: "mt-6 flex justify-end gap-2",
1030
+ children: [/* @__PURE__ */ (0, S.jsx)("button", {
1031
+ onClick: () => z(null),
1032
+ className: "rounded-lg border px-4 py-2 text-sm",
1033
+ children: "Cancel"
1034
+ }), /* @__PURE__ */ (0, S.jsx)("button", {
1035
+ onClick: () => {
1036
+ E((e) => e.filter((e) => e.id !== R.id)), xe((e) => e.filter((e) => e !== R.id)), z(null), C?.(R);
1037
+ },
1038
+ className: "rounded-lg bg-red-600 px-4 py-2 text-sm font-medium text-white",
1039
+ children: "Delete"
1040
+ })]
1041
+ })
1042
+ ]
1043
+ })
1044
+ })
1045
+ ]
1046
+ });
1047
+ }
1048
+ //#endregion
1049
+ //#region src/index.js
1050
+ var ce = C;
1051
+ //#endregion
1052
+ export { C as DataTable, ce as default };