@kareemelbalshe/any-table 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/LICENSE +21 -0
- package/README.md +998 -0
- package/dist/adapters/apiAdapter.d.ts +2 -0
- package/dist/adapters/index.d.ts +5 -0
- package/dist/adapters/objectUtils.d.ts +18 -0
- package/dist/adapters/paginationAdapter.d.ts +2 -0
- package/dist/adapters/searchAdapter.d.ts +4 -0
- package/dist/adapters/sortAdapter.d.ts +7 -0
- package/dist/columns/autoColumns.d.ts +5 -0
- package/dist/columns/columnResolver.d.ts +13 -0
- package/dist/columns/index.d.ts +3 -0
- package/dist/columns/typeDetector.d.ts +7 -0
- package/dist/components/AnyTable.d.ts +8 -0
- package/dist/components/TableBody.d.ts +17 -0
- package/dist/components/TableConfirmDialog.d.ts +13 -0
- package/dist/components/TableEmptyState.d.ts +8 -0
- package/dist/components/TableErrorState.d.ts +6 -0
- package/dist/components/TableHeader.d.ts +16 -0
- package/dist/components/TablePagination.d.ts +14 -0
- package/dist/components/TableSearch.d.ts +9 -0
- package/dist/components/TableSkeleton.d.ts +7 -0
- package/dist/components/index.d.ts +9 -0
- package/dist/favicon.svg +65 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/useAnyTableController.d.ts +18 -0
- package/dist/hooks/useAnyTableData.d.ts +22 -0
- package/dist/hooks/useAnyTablePagination.d.ts +24 -0
- package/dist/hooks/useAnyTableSearch.d.ts +14 -0
- package/dist/hooks/useAnyTableSorting.d.ts +15 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1930 -0
- package/dist/index.js.map +1 -0
- package/dist/logo.svg +65 -0
- package/dist/renderers/ActionRenderer.d.ts +8 -0
- package/dist/renderers/CellRenderer.d.ts +8 -0
- package/dist/renderers/DefaultRenderers.d.ts +52 -0
- package/dist/renderers/index.d.ts +3 -0
- package/dist/style.css +1 -0
- package/dist/theme/defaultTheme.d.ts +3 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/themeContext.d.ts +8 -0
- package/dist/types/action.types.d.ts +117 -0
- package/dist/types/api.types.d.ts +99 -0
- package/dist/types/column.types.d.ts +101 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/table.types.d.ts +252 -0
- package/dist/types/theme.types.d.ts +51 -0
- package/package.json +80 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1930 @@
|
|
|
1
|
+
import { jsx as s, jsxs as b, Fragment as Se } from "react/jsx-runtime";
|
|
2
|
+
import Nt, { useMemo as O, useState as v, useEffect as ye, useCallback as w, useRef as wt, useImperativeHandle as vt, createContext as At, useContext as Ct } from "react";
|
|
3
|
+
function S(e, t, n = void 0) {
|
|
4
|
+
if (e == null) return n;
|
|
5
|
+
if (!t || typeof t != "string") return e;
|
|
6
|
+
if (t in e && e[t] !== void 0)
|
|
7
|
+
return e[t];
|
|
8
|
+
const l = t.replace(/\[(\w+)\]/g, ".$1").split(".");
|
|
9
|
+
let a = e;
|
|
10
|
+
for (let i = 0; i < l.length; i++) {
|
|
11
|
+
const g = l[i];
|
|
12
|
+
if (a == null)
|
|
13
|
+
return n;
|
|
14
|
+
a = a[g];
|
|
15
|
+
}
|
|
16
|
+
return a !== void 0 ? a : n;
|
|
17
|
+
}
|
|
18
|
+
function St(e) {
|
|
19
|
+
return e !== null && typeof e == "object" && !Array.isArray(e);
|
|
20
|
+
}
|
|
21
|
+
function fe(e) {
|
|
22
|
+
if (!e || typeof e != "string") return "";
|
|
23
|
+
let t = e.replace(/[._\-]+/g, " ");
|
|
24
|
+
return t = t.replace(/([a-z])([A-Z])/g, "$1 $2"), t.split(" ").filter(Boolean).map((n) => {
|
|
25
|
+
const o = n.toLowerCase();
|
|
26
|
+
return n.length <= 3 && n === n.toUpperCase() ? n : o.charAt(0).toUpperCase() + o.slice(1);
|
|
27
|
+
}).join(" ");
|
|
28
|
+
}
|
|
29
|
+
const Tt = [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".avif"], Pt = ["image", "avatar", "photo", "logo", "picture", "thumbnail", "banner", "img", "icon"], Et = ["price", "spend", "cost", "amount", "total", "fee", "rate", "salary", "balance", "deposit", "commission", "charge"], $t = ["status", "state", "phase", "condition"];
|
|
30
|
+
function be(e, t) {
|
|
31
|
+
const n = e.toLowerCase();
|
|
32
|
+
if (Pt.some((a) => n.includes(a)))
|
|
33
|
+
return "image";
|
|
34
|
+
if (Et.some((a) => n.includes(a)))
|
|
35
|
+
return "currency";
|
|
36
|
+
if ($t.some((a) => n.includes(a)))
|
|
37
|
+
return "status";
|
|
38
|
+
const o = t.filter((a) => a != null && a !== "");
|
|
39
|
+
if (o.length === 0)
|
|
40
|
+
return "string";
|
|
41
|
+
const l = o[0];
|
|
42
|
+
if (typeof l == "boolean" || n.startsWith("is") || n.startsWith("has"))
|
|
43
|
+
return "boolean";
|
|
44
|
+
if (Array.isArray(l))
|
|
45
|
+
return "array";
|
|
46
|
+
if (typeof l == "object")
|
|
47
|
+
return l.url && typeof l.url == "string" && Re(l.url) ? "image" : "object";
|
|
48
|
+
if (typeof l == "number")
|
|
49
|
+
return "number";
|
|
50
|
+
if (typeof l == "string") {
|
|
51
|
+
const a = l.trim();
|
|
52
|
+
if (Re(a))
|
|
53
|
+
return "image";
|
|
54
|
+
if ((Dt(a) || n.includes("date") || n.includes("at") || n.includes("time")) && !isNaN(Date.parse(a)))
|
|
55
|
+
return a.includes("T") || a.includes(":") ? "datetime" : "date";
|
|
56
|
+
if (a.includes("@") && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a))
|
|
57
|
+
return "email";
|
|
58
|
+
if (a.startsWith("http://") || a.startsWith("https://"))
|
|
59
|
+
return "url";
|
|
60
|
+
if (n.includes("phone") || n.includes("mobile") || n.includes("tel"))
|
|
61
|
+
return "phone";
|
|
62
|
+
}
|
|
63
|
+
return "string";
|
|
64
|
+
}
|
|
65
|
+
function Re(e) {
|
|
66
|
+
if (!e || typeof e != "string") return !1;
|
|
67
|
+
if (e.startsWith("data:image/")) return !0;
|
|
68
|
+
const t = e.toLowerCase().split("?")[0];
|
|
69
|
+
return Tt.some((n) => t.endsWith(n));
|
|
70
|
+
}
|
|
71
|
+
function Dt(e) {
|
|
72
|
+
return !e || typeof e != "string" || e.length < 10 ? !1 : /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/.test(e);
|
|
73
|
+
}
|
|
74
|
+
const Mt = ["__v", "password", "token", "refreshToken", "secret", "hash", "salt"];
|
|
75
|
+
function _t(e, t = Mt, n = 2) {
|
|
76
|
+
if (!e || !e.length)
|
|
77
|
+
return [];
|
|
78
|
+
const o = /* @__PURE__ */ new Map(), l = e.slice(0, 10);
|
|
79
|
+
for (const a of l)
|
|
80
|
+
!a || typeof a != "object" || Ve(a, "", o, l, t, 0, n);
|
|
81
|
+
return Array.from(o.values());
|
|
82
|
+
}
|
|
83
|
+
function Ve(e, t, n, o, l, a, i) {
|
|
84
|
+
if (!(!e || typeof e != "object" || a > i))
|
|
85
|
+
for (const g of Object.keys(e)) {
|
|
86
|
+
if (l.includes(g)) continue;
|
|
87
|
+
const c = t ? `${t}.${g}` : g, d = e[g];
|
|
88
|
+
if (St(d) && !Bt(d) && a < i) {
|
|
89
|
+
Ve(d, c, n, o, l, a + 1, i);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (!n.has(c)) {
|
|
93
|
+
const r = o.map((u) => S(u, c)), m = be(c, r);
|
|
94
|
+
n.set(c, {
|
|
95
|
+
key: c,
|
|
96
|
+
title: fe(c),
|
|
97
|
+
type: m,
|
|
98
|
+
sortable: !0,
|
|
99
|
+
searchable: !0,
|
|
100
|
+
align: m === "number" || m === "currency" ? "right" : "left"
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function Bt(e, t) {
|
|
106
|
+
return "en" in e && "ar" in e && Object.keys(e).length <= 3 ? !1 : "url" in e && typeof e.url == "string" || "coordinates" in e || "lat" in e && "lng" in e;
|
|
107
|
+
}
|
|
108
|
+
function jt(e) {
|
|
109
|
+
const { data: t = [], columns: n, autoColumns: o = !0, thead: l, headerData: a } = e;
|
|
110
|
+
return a && Array.isArray(a) && a.length > 0 ? a.map((i, g) => {
|
|
111
|
+
const c = l && l[g] ? l[g] : fe(i), d = t.map((m) => m?.[i]), r = be(i, d);
|
|
112
|
+
return {
|
|
113
|
+
key: i,
|
|
114
|
+
title: c,
|
|
115
|
+
type: r,
|
|
116
|
+
sortable: !0,
|
|
117
|
+
searchable: !0,
|
|
118
|
+
align: r === "number" || r === "currency" ? "right" : "left"
|
|
119
|
+
};
|
|
120
|
+
}) : n && Array.isArray(n) && n.length > 0 ? n.map((i) => {
|
|
121
|
+
if (typeof i == "string") {
|
|
122
|
+
const r = t.map((u) => u?.[i]), m = be(i, r);
|
|
123
|
+
return {
|
|
124
|
+
key: i,
|
|
125
|
+
title: fe(i),
|
|
126
|
+
type: m,
|
|
127
|
+
sortable: !0,
|
|
128
|
+
searchable: !0,
|
|
129
|
+
align: m === "number" || m === "currency" ? "right" : "left"
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const g = String(i.key), c = i.title !== void 0 ? i.title : fe(g), d = i.type || be(g, t.map((r) => r?.[g]));
|
|
133
|
+
return {
|
|
134
|
+
...i,
|
|
135
|
+
title: c,
|
|
136
|
+
type: d,
|
|
137
|
+
sortable: i.sortable !== void 0 ? i.sortable : !0,
|
|
138
|
+
searchable: i.searchable !== void 0 ? i.searchable : !0,
|
|
139
|
+
align: i.align || (d === "number" || d === "currency" ? "right" : "left")
|
|
140
|
+
};
|
|
141
|
+
}) : o && t && t.length > 0 ? _t(t) : [];
|
|
142
|
+
}
|
|
143
|
+
function zt({
|
|
144
|
+
config: e,
|
|
145
|
+
onSearchChange: t
|
|
146
|
+
}) {
|
|
147
|
+
const n = O(() => typeof e == "object" && e !== null ? e : { enabled: !!e }, [e]), o = n.enabled !== !1 && !!e, l = n.debounce ?? 350, [a, i] = v(""), [g, c] = v(""), [d, r] = v(!1);
|
|
148
|
+
ye(() => {
|
|
149
|
+
if (!o) return;
|
|
150
|
+
if (a === "") {
|
|
151
|
+
c(""), r(!1), t?.("");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
r(!0);
|
|
155
|
+
const f = setTimeout(() => {
|
|
156
|
+
c(a), r(!1), t?.(a);
|
|
157
|
+
}, l);
|
|
158
|
+
return () => {
|
|
159
|
+
clearTimeout(f);
|
|
160
|
+
};
|
|
161
|
+
}, [a, l, o, t]);
|
|
162
|
+
const m = w((f) => {
|
|
163
|
+
i(f);
|
|
164
|
+
}, []), u = w(() => {
|
|
165
|
+
i(""), c(""), r(!1), t?.("");
|
|
166
|
+
}, [t]);
|
|
167
|
+
return {
|
|
168
|
+
enabled: o,
|
|
169
|
+
search: a,
|
|
170
|
+
debouncedSearch: g,
|
|
171
|
+
isDebouncing: d,
|
|
172
|
+
setSearch: m,
|
|
173
|
+
clearSearch: u,
|
|
174
|
+
searchConfig: n
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function Lt({
|
|
178
|
+
config: e,
|
|
179
|
+
onSortChange: t
|
|
180
|
+
}) {
|
|
181
|
+
const n = O(() => typeof e == "object" && e !== null ? e : { enabled: !!e }, [e]), o = n.enabled !== !1 && !!e, l = n.allowUnsort ?? !0, [a, i] = v(
|
|
182
|
+
n.defaultSortBy || null
|
|
183
|
+
), [g, c] = v(
|
|
184
|
+
n.defaultSortOrder || null
|
|
185
|
+
), d = w(
|
|
186
|
+
(u) => {
|
|
187
|
+
if (o) {
|
|
188
|
+
if (a !== u) {
|
|
189
|
+
i(u), c("asc"), t?.(u, "asc");
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
g === "asc" ? (c("desc"), t?.(u, "desc")) : g === "desc" && l ? (i(null), c(null), t?.(null, null)) : (c("asc"), t?.(u, "asc"));
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
[o, a, g, l, t]
|
|
196
|
+
), r = w(
|
|
197
|
+
(u, f) => {
|
|
198
|
+
i(u), c(f), t?.(u, f);
|
|
199
|
+
},
|
|
200
|
+
[t]
|
|
201
|
+
), m = w(() => {
|
|
202
|
+
i(null), c(null), t?.(null, null);
|
|
203
|
+
}, [t]);
|
|
204
|
+
return {
|
|
205
|
+
enabled: o,
|
|
206
|
+
sortBy: a,
|
|
207
|
+
sortOrder: g,
|
|
208
|
+
toggleSort: d,
|
|
209
|
+
setSorting: r,
|
|
210
|
+
resetSorting: m,
|
|
211
|
+
sortingConfig: n
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function Ot({
|
|
215
|
+
config: e,
|
|
216
|
+
totalRecords: t,
|
|
217
|
+
onPageChange: n
|
|
218
|
+
}) {
|
|
219
|
+
const o = O(() => typeof e == "object" && e !== null ? e : { enabled: !!e }, [e]), l = o.enabled !== !1 && !!e, a = o.defaultPage || 1, i = o.defaultPageSize || 10, g = o.pageSizeOptions || [5, 10, 20, 50, 100], [c, d] = v(a), [r, m] = v(i), u = Math.max(1, Math.ceil(t / Math.max(1, r))), f = w(
|
|
220
|
+
(N) => {
|
|
221
|
+
const A = Math.max(1, Math.min(N, u));
|
|
222
|
+
d(A), n?.(A, r);
|
|
223
|
+
},
|
|
224
|
+
[u, r, n]
|
|
225
|
+
), p = w(
|
|
226
|
+
(N) => {
|
|
227
|
+
m(N), d(1), n?.(1, N);
|
|
228
|
+
},
|
|
229
|
+
[n]
|
|
230
|
+
), k = w(() => {
|
|
231
|
+
c < u && f(c + 1);
|
|
232
|
+
}, [c, u, f]), E = w(() => {
|
|
233
|
+
c > 1 && f(c - 1);
|
|
234
|
+
}, [c, f]), h = w(() => {
|
|
235
|
+
d(1), m(i), n?.(1, i);
|
|
236
|
+
}, [i, n]), D = w(
|
|
237
|
+
(N = 5) => {
|
|
238
|
+
const A = Math.max(
|
|
239
|
+
1,
|
|
240
|
+
Math.min(c - Math.floor(N / 2), u - N + 1)
|
|
241
|
+
), j = Math.min(u, A + N - 1), H = [];
|
|
242
|
+
for (let W = A; W <= j; W++)
|
|
243
|
+
H.push(W);
|
|
244
|
+
return H;
|
|
245
|
+
},
|
|
246
|
+
[c, u]
|
|
247
|
+
), M = w(
|
|
248
|
+
(N) => {
|
|
249
|
+
if (!l) return N;
|
|
250
|
+
const A = (c - 1) * r;
|
|
251
|
+
return N.slice(A, A + r);
|
|
252
|
+
},
|
|
253
|
+
[l, c, r]
|
|
254
|
+
);
|
|
255
|
+
return {
|
|
256
|
+
enabled: l,
|
|
257
|
+
page: c,
|
|
258
|
+
pageSize: r,
|
|
259
|
+
totalRecords: t,
|
|
260
|
+
totalPages: u,
|
|
261
|
+
pageSizeOptions: g,
|
|
262
|
+
hasNextPage: c < u,
|
|
263
|
+
hasPrevPage: c > 1,
|
|
264
|
+
setPage: f,
|
|
265
|
+
setPageSize: p,
|
|
266
|
+
nextPage: k,
|
|
267
|
+
prevPage: E,
|
|
268
|
+
resetPagination: h,
|
|
269
|
+
getPageWindow: D,
|
|
270
|
+
sliceData: M,
|
|
271
|
+
paginationConfig: o
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const Wt = [
|
|
275
|
+
"total",
|
|
276
|
+
"totalCount",
|
|
277
|
+
"count",
|
|
278
|
+
"recordsTotal",
|
|
279
|
+
"totalRecords",
|
|
280
|
+
"totalItems",
|
|
281
|
+
"meta.total",
|
|
282
|
+
"meta.totalCount",
|
|
283
|
+
"meta.count",
|
|
284
|
+
"pagination.total",
|
|
285
|
+
"pagination.totalCount",
|
|
286
|
+
"pagination.count",
|
|
287
|
+
"pageInfo.total",
|
|
288
|
+
"pageInfo.totalCount",
|
|
289
|
+
"paging.total"
|
|
290
|
+
], It = [
|
|
291
|
+
"page",
|
|
292
|
+
"currentPage",
|
|
293
|
+
"pageNumber",
|
|
294
|
+
"current_page",
|
|
295
|
+
"meta.page",
|
|
296
|
+
"meta.currentPage",
|
|
297
|
+
"pagination.page",
|
|
298
|
+
"pagination.currentPage",
|
|
299
|
+
"pageInfo.page"
|
|
300
|
+
], Ft = [
|
|
301
|
+
"pageSize",
|
|
302
|
+
"limit",
|
|
303
|
+
"perPage",
|
|
304
|
+
"per_page",
|
|
305
|
+
"meta.pageSize",
|
|
306
|
+
"meta.limit",
|
|
307
|
+
"meta.perPage",
|
|
308
|
+
"pagination.pageSize",
|
|
309
|
+
"pagination.limit",
|
|
310
|
+
"pagination.perPage"
|
|
311
|
+
], Ht = [
|
|
312
|
+
"totalPages",
|
|
313
|
+
"pageCount",
|
|
314
|
+
"lastPage",
|
|
315
|
+
"last_page",
|
|
316
|
+
"total_pages",
|
|
317
|
+
"meta.totalPages",
|
|
318
|
+
"meta.lastPage",
|
|
319
|
+
"pagination.totalPages",
|
|
320
|
+
"pagination.lastPage"
|
|
321
|
+
];
|
|
322
|
+
function X(e, t, n = 1, o = 10, l) {
|
|
323
|
+
if (!e || typeof e != "object") {
|
|
324
|
+
const d = l !== void 0 ? l : 0;
|
|
325
|
+
return {
|
|
326
|
+
page: n,
|
|
327
|
+
pageSize: o,
|
|
328
|
+
total: d,
|
|
329
|
+
totalPages: Math.max(1, Math.ceil(d / Math.max(1, o))),
|
|
330
|
+
hasNextPage: !1,
|
|
331
|
+
hasPrevPage: !1
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
let a;
|
|
335
|
+
if (t?.totalPath) {
|
|
336
|
+
const d = S(e, t.totalPath);
|
|
337
|
+
typeof d == "number" ? a = d : typeof d == "string" && !isNaN(Number(d)) && (a = Number(d));
|
|
338
|
+
}
|
|
339
|
+
if (a === void 0)
|
|
340
|
+
for (const d of Wt) {
|
|
341
|
+
const r = S(e, d);
|
|
342
|
+
if (typeof r == "number" && !isNaN(r)) {
|
|
343
|
+
a = r;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
if (typeof r == "string" && r.trim() !== "" && !isNaN(Number(r))) {
|
|
347
|
+
a = Number(r);
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
a === void 0 && (a = l !== void 0 ? l : 0);
|
|
352
|
+
let i;
|
|
353
|
+
if (t?.pagePath) {
|
|
354
|
+
const d = S(e, t.pagePath);
|
|
355
|
+
typeof d == "number" ? i = d : typeof d == "string" && !isNaN(Number(d)) && (i = Number(d));
|
|
356
|
+
}
|
|
357
|
+
if (i === void 0)
|
|
358
|
+
for (const d of It) {
|
|
359
|
+
const r = S(e, d);
|
|
360
|
+
if (typeof r == "number" && !isNaN(r)) {
|
|
361
|
+
i = r;
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
if (typeof r == "string" && r.trim() !== "" && !isNaN(Number(r))) {
|
|
365
|
+
i = Number(r);
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
i === void 0 && (i = n);
|
|
370
|
+
let g;
|
|
371
|
+
if (t?.pageSizePath) {
|
|
372
|
+
const d = S(e, t.pageSizePath);
|
|
373
|
+
typeof d == "number" ? g = d : typeof d == "string" && !isNaN(Number(d)) && (g = Number(d));
|
|
374
|
+
}
|
|
375
|
+
if (g === void 0)
|
|
376
|
+
for (const d of Ft) {
|
|
377
|
+
const r = S(e, d);
|
|
378
|
+
if (typeof r == "number" && !isNaN(r)) {
|
|
379
|
+
g = r;
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
if (typeof r == "string" && r.trim() !== "" && !isNaN(Number(r))) {
|
|
383
|
+
g = Number(r);
|
|
384
|
+
break;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
g === void 0 && (g = o);
|
|
388
|
+
let c;
|
|
389
|
+
if (t?.totalPagesPath) {
|
|
390
|
+
const d = S(e, t.totalPagesPath);
|
|
391
|
+
typeof d == "number" ? c = d : typeof d == "string" && !isNaN(Number(d)) && (c = Number(d));
|
|
392
|
+
}
|
|
393
|
+
if (c === void 0)
|
|
394
|
+
for (const d of Ht) {
|
|
395
|
+
const r = S(e, d);
|
|
396
|
+
if (typeof r == "number" && !isNaN(r)) {
|
|
397
|
+
c = r;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return (c === void 0 || c <= 0) && (c = Math.max(1, Math.ceil(a / Math.max(1, g)))), {
|
|
402
|
+
total: a,
|
|
403
|
+
page: i,
|
|
404
|
+
pageSize: g,
|
|
405
|
+
totalPages: c,
|
|
406
|
+
hasNextPage: i < c,
|
|
407
|
+
hasPrevPage: i > 1
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
const Rt = [
|
|
411
|
+
"data",
|
|
412
|
+
"items",
|
|
413
|
+
"results",
|
|
414
|
+
"rows",
|
|
415
|
+
"records",
|
|
416
|
+
"list",
|
|
417
|
+
"payload",
|
|
418
|
+
"content",
|
|
419
|
+
"users",
|
|
420
|
+
"orders",
|
|
421
|
+
"products",
|
|
422
|
+
"drivers",
|
|
423
|
+
"merchants",
|
|
424
|
+
"reports",
|
|
425
|
+
"transactions",
|
|
426
|
+
"withdrawals",
|
|
427
|
+
"coupons",
|
|
428
|
+
"subscriptions",
|
|
429
|
+
"deadLetters.items"
|
|
430
|
+
];
|
|
431
|
+
function Ut(e, t, n) {
|
|
432
|
+
const o = n?.page || 1, l = n?.pageSize || 10;
|
|
433
|
+
if (t?.transformResponse && typeof t.transformResponse == "function") {
|
|
434
|
+
const a = t.transformResponse(e);
|
|
435
|
+
if (Array.isArray(a))
|
|
436
|
+
return {
|
|
437
|
+
data: a,
|
|
438
|
+
meta: X(e, t.response, o, l, a.length),
|
|
439
|
+
raw: e
|
|
440
|
+
};
|
|
441
|
+
if (a && typeof a == "object") {
|
|
442
|
+
const i = Array.isArray(a.data) ? a.data : [], g = a.meta ? {
|
|
443
|
+
total: a.meta.total !== void 0 ? a.meta.total : i.length,
|
|
444
|
+
page: a.meta.page !== void 0 ? a.meta.page : o,
|
|
445
|
+
pageSize: a.meta.pageSize !== void 0 ? a.meta.pageSize : l,
|
|
446
|
+
totalPages: a.meta.totalPages !== void 0 ? a.meta.totalPages : Math.max(1, Math.ceil((a.meta.total || i.length) / (a.meta.pageSize || l)))
|
|
447
|
+
} : X(e, t.response, o, l, i.length);
|
|
448
|
+
return { data: i, meta: g, raw: e };
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
if (Array.isArray(e))
|
|
452
|
+
return {
|
|
453
|
+
data: e,
|
|
454
|
+
meta: {
|
|
455
|
+
total: e.length,
|
|
456
|
+
page: o,
|
|
457
|
+
pageSize: l,
|
|
458
|
+
totalPages: Math.max(1, Math.ceil(e.length / l)),
|
|
459
|
+
hasNextPage: o * l < e.length,
|
|
460
|
+
hasPrevPage: o > 1
|
|
461
|
+
},
|
|
462
|
+
raw: e
|
|
463
|
+
};
|
|
464
|
+
if (t?.response?.dataPath) {
|
|
465
|
+
const a = S(e, t.response.dataPath), i = Array.isArray(a) ? a : [], g = X(e, t.response, o, l, i.length);
|
|
466
|
+
return { data: i, meta: g, raw: e };
|
|
467
|
+
}
|
|
468
|
+
if (e && typeof e == "object") {
|
|
469
|
+
for (const a of Rt) {
|
|
470
|
+
const i = S(e, a);
|
|
471
|
+
if (Array.isArray(i)) {
|
|
472
|
+
const g = X(e, t?.response, o, l, i.length);
|
|
473
|
+
return {
|
|
474
|
+
data: i,
|
|
475
|
+
meta: g,
|
|
476
|
+
raw: e
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
for (const a in e)
|
|
481
|
+
if (Array.isArray(e[a])) {
|
|
482
|
+
const i = X(e, t?.response, o, l, e[a].length);
|
|
483
|
+
return {
|
|
484
|
+
data: e[a],
|
|
485
|
+
meta: i,
|
|
486
|
+
raw: e
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
if (Object.keys(e).length > 0 && !Array.isArray(e)) {
|
|
490
|
+
const a = e.user || e.order || e.item || e.data || e;
|
|
491
|
+
if (a && typeof a == "object" && !Array.isArray(a))
|
|
492
|
+
return {
|
|
493
|
+
data: [a],
|
|
494
|
+
meta: {
|
|
495
|
+
total: 1,
|
|
496
|
+
page: 1,
|
|
497
|
+
pageSize: l,
|
|
498
|
+
totalPages: 1,
|
|
499
|
+
hasNextPage: !1,
|
|
500
|
+
hasPrevPage: !1
|
|
501
|
+
},
|
|
502
|
+
raw: e
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
return {
|
|
507
|
+
data: [],
|
|
508
|
+
meta: {
|
|
509
|
+
total: 0,
|
|
510
|
+
page: o,
|
|
511
|
+
pageSize: l,
|
|
512
|
+
totalPages: 1,
|
|
513
|
+
hasNextPage: !1,
|
|
514
|
+
hasPrevPage: !1
|
|
515
|
+
},
|
|
516
|
+
raw: e
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function Kt(e, t, n, o) {
|
|
520
|
+
if (!e || !e.length) return [];
|
|
521
|
+
if (!t || typeof t != "string" || !t.trim()) return e;
|
|
522
|
+
const l = t.trim().toLowerCase();
|
|
523
|
+
if (o && typeof o == "function")
|
|
524
|
+
return e.filter((i) => o(i, l));
|
|
525
|
+
const a = l.split(/\s+/).filter(Boolean);
|
|
526
|
+
return e.filter((i) => {
|
|
527
|
+
if (!i || typeof i != "object") return !1;
|
|
528
|
+
const g = [];
|
|
529
|
+
if (n && n.length > 0)
|
|
530
|
+
for (const d of n) {
|
|
531
|
+
const r = S(i, d);
|
|
532
|
+
r != null && (typeof r == "object" ? g.push(JSON.stringify(r).toLowerCase()) : g.push(String(r).toLowerCase()));
|
|
533
|
+
}
|
|
534
|
+
else
|
|
535
|
+
Te(i, g);
|
|
536
|
+
const c = g.join(" ");
|
|
537
|
+
return a.every((d) => c.includes(d));
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
function Te(e, t, n = 0) {
|
|
541
|
+
if (!(n > 4 || e === null || e === void 0)) {
|
|
542
|
+
if (typeof e != "object") {
|
|
543
|
+
t.push(String(e).toLowerCase());
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
if (Array.isArray(e)) {
|
|
547
|
+
for (const o of e)
|
|
548
|
+
Te(o, t, n + 1);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
for (const o in e)
|
|
552
|
+
if (Object.prototype.hasOwnProperty.call(e, o)) {
|
|
553
|
+
if (o.startsWith("__") || o.toLowerCase().includes("password")) continue;
|
|
554
|
+
Te(e[o], t, n + 1);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
function Gt(e, t, n, o) {
|
|
559
|
+
if (!e || !e.length || !t || !n)
|
|
560
|
+
return e;
|
|
561
|
+
const l = [...e];
|
|
562
|
+
return o && typeof o == "function" ? (l.sort((a, i) => {
|
|
563
|
+
const g = o(a, i);
|
|
564
|
+
return n === "desc" ? -g : g;
|
|
565
|
+
}), l) : (l.sort((a, i) => {
|
|
566
|
+
const g = S(a, t), c = S(i, t);
|
|
567
|
+
if (g == null)
|
|
568
|
+
return c == null ? 0 : 1;
|
|
569
|
+
if (c == null)
|
|
570
|
+
return -1;
|
|
571
|
+
let d = 0;
|
|
572
|
+
if (typeof g == "number" && typeof c == "number")
|
|
573
|
+
d = g - c;
|
|
574
|
+
else if (typeof g == "boolean" && typeof c == "boolean")
|
|
575
|
+
d = g === c ? 0 : g ? -1 : 1;
|
|
576
|
+
else if (g instanceof Date && c instanceof Date)
|
|
577
|
+
d = g.getTime() - c.getTime();
|
|
578
|
+
else if (typeof g == "string" && typeof c == "string" && Ue(g) && Ue(c))
|
|
579
|
+
d = new Date(g).getTime() - new Date(c).getTime();
|
|
580
|
+
else {
|
|
581
|
+
const r = String(g), m = String(c);
|
|
582
|
+
d = r.localeCompare(m, void 0, {
|
|
583
|
+
numeric: !0,
|
|
584
|
+
sensitivity: "base"
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return n === "desc" ? -d : d;
|
|
588
|
+
}), l);
|
|
589
|
+
}
|
|
590
|
+
function Ue(e) {
|
|
591
|
+
return e.length < 10 ? !1 : /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/.test(e);
|
|
592
|
+
}
|
|
593
|
+
function Yt({
|
|
594
|
+
data: e,
|
|
595
|
+
api: t,
|
|
596
|
+
columns: n,
|
|
597
|
+
searchQuery: o,
|
|
598
|
+
sortBy: l,
|
|
599
|
+
sortOrder: a,
|
|
600
|
+
page: i,
|
|
601
|
+
pageSize: g,
|
|
602
|
+
manualLoading: c
|
|
603
|
+
}) {
|
|
604
|
+
const d = !!(t && typeof t.fetcher == "function"), r = d && t?.mode !== "client", [m, u] = v([]), [f, p] = v(0), [k, E] = v(!1), [h, D] = v(null), [M, N] = v(0), A = wt(null), j = w(async () => {
|
|
605
|
+
if (!d || !t?.fetcher) return;
|
|
606
|
+
A.current && A.current.abort();
|
|
607
|
+
const B = new AbortController();
|
|
608
|
+
A.current = B, E(!0), D(null);
|
|
609
|
+
const z = t.paramNames || {}, R = z.pageParam || "page", re = z.pageSizeParam || "limit", G = z.searchParam || "q", Y = z.sortByParam || "sortBy", I = z.sortOrderParam || "sortOrder", U = {
|
|
610
|
+
[R]: i,
|
|
611
|
+
[re]: g,
|
|
612
|
+
page: i,
|
|
613
|
+
pageSize: g,
|
|
614
|
+
...o ? { [G]: o, search: o, q: o } : {},
|
|
615
|
+
...l ? { [Y]: l, sortBy: l } : {},
|
|
616
|
+
...a ? { [I]: a, sortOrder: a } : {},
|
|
617
|
+
...t.params || {}
|
|
618
|
+
};
|
|
619
|
+
try {
|
|
620
|
+
const T = await t.fetcher(U, B.signal);
|
|
621
|
+
if (B.signal.aborted) return;
|
|
622
|
+
const V = Ut(
|
|
623
|
+
T,
|
|
624
|
+
t,
|
|
625
|
+
U
|
|
626
|
+
);
|
|
627
|
+
u(V.data), p(V.meta.total), t.onSuccess?.(V);
|
|
628
|
+
} catch (T) {
|
|
629
|
+
if (T?.name === "AbortError" || T?.name === "CanceledError")
|
|
630
|
+
return;
|
|
631
|
+
D(T), t.onError?.(T);
|
|
632
|
+
} finally {
|
|
633
|
+
B.signal.aborted || E(!1);
|
|
634
|
+
}
|
|
635
|
+
}, [d, t, i, g, o, l, a]);
|
|
636
|
+
ye(() => {
|
|
637
|
+
d && j();
|
|
638
|
+
}, [j, M]), ye(() => () => {
|
|
639
|
+
A.current && A.current.abort();
|
|
640
|
+
}, []);
|
|
641
|
+
const H = w(async () => {
|
|
642
|
+
d && N((B) => B + 1);
|
|
643
|
+
}, [d]), { displayRows: W, finalTotal: te } = O(() => {
|
|
644
|
+
if (r)
|
|
645
|
+
return {
|
|
646
|
+
displayRows: m,
|
|
647
|
+
finalTotal: f
|
|
648
|
+
};
|
|
649
|
+
const B = d ? m : e || [], z = n.filter((T) => T.searchable !== !1).map((T) => T.key), R = Kt(B, o, z), G = n.find((T) => T.key === l)?.comparator, Y = Gt(R, l, a, G), I = (i - 1) * g;
|
|
650
|
+
return {
|
|
651
|
+
displayRows: Y.slice(I, I + g),
|
|
652
|
+
finalTotal: R.length
|
|
653
|
+
};
|
|
654
|
+
}, [
|
|
655
|
+
r,
|
|
656
|
+
d,
|
|
657
|
+
m,
|
|
658
|
+
e,
|
|
659
|
+
f,
|
|
660
|
+
n,
|
|
661
|
+
o,
|
|
662
|
+
l,
|
|
663
|
+
a,
|
|
664
|
+
i,
|
|
665
|
+
g
|
|
666
|
+
]);
|
|
667
|
+
return {
|
|
668
|
+
rows: W,
|
|
669
|
+
totalRecords: te,
|
|
670
|
+
loading: c !== void 0 ? c : k,
|
|
671
|
+
error: h,
|
|
672
|
+
refresh: H,
|
|
673
|
+
isServerMode: r,
|
|
674
|
+
rawRemoteData: m
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
function Vt({
|
|
678
|
+
tableRef: e,
|
|
679
|
+
refresh: t,
|
|
680
|
+
resetPagination: n,
|
|
681
|
+
resetSearch: o,
|
|
682
|
+
resetSorting: l,
|
|
683
|
+
setPage: a,
|
|
684
|
+
setPageSize: i,
|
|
685
|
+
setSearch: g,
|
|
686
|
+
setSorting: c,
|
|
687
|
+
selectedRows: d,
|
|
688
|
+
clearSelection: r,
|
|
689
|
+
getState: m
|
|
690
|
+
}) {
|
|
691
|
+
vt(
|
|
692
|
+
e,
|
|
693
|
+
() => ({
|
|
694
|
+
refresh: t,
|
|
695
|
+
reset: () => {
|
|
696
|
+
n(), o(), l(), r();
|
|
697
|
+
},
|
|
698
|
+
resetSearch: o,
|
|
699
|
+
resetSorting: l,
|
|
700
|
+
resetPagination: n,
|
|
701
|
+
setPage: a,
|
|
702
|
+
setPageSize: i,
|
|
703
|
+
setSearch: g,
|
|
704
|
+
setSorting: c,
|
|
705
|
+
getSelectedRows: () => d,
|
|
706
|
+
clearSelection: r,
|
|
707
|
+
getState: m
|
|
708
|
+
}),
|
|
709
|
+
[
|
|
710
|
+
t,
|
|
711
|
+
n,
|
|
712
|
+
o,
|
|
713
|
+
l,
|
|
714
|
+
a,
|
|
715
|
+
i,
|
|
716
|
+
g,
|
|
717
|
+
c,
|
|
718
|
+
d,
|
|
719
|
+
r,
|
|
720
|
+
m
|
|
721
|
+
]
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
const Jt = {
|
|
725
|
+
primary: "#2667EC",
|
|
726
|
+
primaryHover: "#1E54C6",
|
|
727
|
+
primaryLight: "#397FF6",
|
|
728
|
+
secondary: "#39E965",
|
|
729
|
+
success: "#10B981",
|
|
730
|
+
warning: "#F59E0B",
|
|
731
|
+
danger: "#EF4444",
|
|
732
|
+
info: "#0EA5E9",
|
|
733
|
+
scaffold: "#0F172A",
|
|
734
|
+
card: "#1E293B",
|
|
735
|
+
cardSecondary: "#334155",
|
|
736
|
+
border: "#334155",
|
|
737
|
+
textPrimary: "#F8FAFC",
|
|
738
|
+
textSecondary: "#94A3B8",
|
|
739
|
+
textMuted: "#64748B",
|
|
740
|
+
inputBg: "#1E293B",
|
|
741
|
+
rowHover: "rgba(38, 103, 236, 0.04)",
|
|
742
|
+
rowSelected: "rgba(38, 103, 236, 0.08)"
|
|
743
|
+
}, Q = {
|
|
744
|
+
mode: "auto",
|
|
745
|
+
colors: Jt,
|
|
746
|
+
borderRadius: "1rem",
|
|
747
|
+
fontFamily: "'Alexandria', system-ui, -apple-system, sans-serif",
|
|
748
|
+
density: "normal",
|
|
749
|
+
classes: {
|
|
750
|
+
container: "w-full flex flex-col gap-4 font-sans text-gray-900 dark:text-gray-100",
|
|
751
|
+
tableWrapper: "w-full overflow-x-auto rounded-2xl border border-gray-200 dark:border-gray-800 bg-white dark:bg-slate-900 shadow-sm transition-colors",
|
|
752
|
+
table: "w-full border-collapse text-left text-sm",
|
|
753
|
+
thead: "bg-gray-50/80 dark:bg-slate-800/80 backdrop-blur-md border-b border-gray-200 dark:border-gray-800 text-gray-700 dark:text-gray-300 font-bold uppercase tracking-wider text-xs",
|
|
754
|
+
th: "py-3.5 px-4 font-bold select-none whitespace-nowrap",
|
|
755
|
+
tbody: "divide-y divide-gray-100 dark:divide-gray-800/60 bg-white dark:bg-slate-900",
|
|
756
|
+
tr: "transition-colors duration-150 hover:bg-gray-50/60 dark:hover:bg-slate-800/40",
|
|
757
|
+
td: "py-3 px-4 text-sm text-gray-700 dark:text-gray-300 align-middle",
|
|
758
|
+
searchContainer: "w-full sm:max-w-md relative flex items-center",
|
|
759
|
+
searchInput: "w-full pl-10 pr-10 py-2.5 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-800 text-sm font-medium text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary transition-all",
|
|
760
|
+
paginationContainer: "w-full flex flex-wrap items-center justify-between gap-4 pt-2 text-sm text-gray-600 dark:text-gray-400",
|
|
761
|
+
paginationButton: "h-9 min-w-[36px] px-3 flex items-center justify-center rounded-xl font-bold text-sm transition-all duration-150 bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-slate-700 disabled:opacity-40 disabled:cursor-not-allowed",
|
|
762
|
+
paginationButtonActive: "bg-primary text-white hover:bg-primary-soft shadow-md shadow-primary/30",
|
|
763
|
+
paginationSelect: "h-9 px-3 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-800 text-sm font-medium text-gray-700 dark:text-gray-300 focus:outline-none focus:border-primary cursor-pointer"
|
|
764
|
+
}
|
|
765
|
+
}, Je = At(Q), Zt = ({
|
|
766
|
+
theme: e,
|
|
767
|
+
children: t
|
|
768
|
+
}) => {
|
|
769
|
+
const n = O(() => e ? {
|
|
770
|
+
...Q,
|
|
771
|
+
...e,
|
|
772
|
+
colors: {
|
|
773
|
+
...Q.colors,
|
|
774
|
+
...e.colors || {}
|
|
775
|
+
},
|
|
776
|
+
classes: {
|
|
777
|
+
...Q.classes,
|
|
778
|
+
...e.classes || {}
|
|
779
|
+
}
|
|
780
|
+
} : Q, [e]);
|
|
781
|
+
return /* @__PURE__ */ s(Je.Provider, { value: n, children: t });
|
|
782
|
+
};
|
|
783
|
+
function ee() {
|
|
784
|
+
return Ct(Je);
|
|
785
|
+
}
|
|
786
|
+
const qt = ({
|
|
787
|
+
value: e,
|
|
788
|
+
onChange: t,
|
|
789
|
+
onClear: n,
|
|
790
|
+
isDebouncing: o = !1,
|
|
791
|
+
placeholder: l = "Search records..."
|
|
792
|
+
}) => {
|
|
793
|
+
const a = ee();
|
|
794
|
+
return /* @__PURE__ */ b("div", { className: a.classes?.searchContainer || "w-full sm:max-w-md relative flex items-center", children: [
|
|
795
|
+
/* @__PURE__ */ s("span", { className: "absolute left-3.5 text-gray-400 dark:text-gray-500 pointer-events-none flex items-center", children: /* @__PURE__ */ s(
|
|
796
|
+
"svg",
|
|
797
|
+
{
|
|
798
|
+
className: "w-4 h-4",
|
|
799
|
+
fill: "none",
|
|
800
|
+
stroke: "currentColor",
|
|
801
|
+
viewBox: "0 0 24 24",
|
|
802
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
803
|
+
children: /* @__PURE__ */ s(
|
|
804
|
+
"path",
|
|
805
|
+
{
|
|
806
|
+
strokeLinecap: "round",
|
|
807
|
+
strokeLinejoin: "round",
|
|
808
|
+
strokeWidth: 2,
|
|
809
|
+
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
}
|
|
813
|
+
) }),
|
|
814
|
+
/* @__PURE__ */ s(
|
|
815
|
+
"input",
|
|
816
|
+
{
|
|
817
|
+
type: "text",
|
|
818
|
+
value: e,
|
|
819
|
+
onChange: (i) => t(i.target.value),
|
|
820
|
+
placeholder: l,
|
|
821
|
+
className: a.classes?.searchInput || "w-full pl-10 pr-10 py-2.5 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-800 text-sm font-medium text-gray-900 dark:text-white placeholder:text-gray-400 dark:placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-primary/40 focus:border-primary transition-all"
|
|
822
|
+
}
|
|
823
|
+
),
|
|
824
|
+
/* @__PURE__ */ b("div", { className: "absolute right-3 flex items-center gap-1.5", children: [
|
|
825
|
+
o && /* @__PURE__ */ s("span", { className: "w-3.5 h-3.5 border-2 border-primary border-t-transparent rounded-full animate-spin" }),
|
|
826
|
+
e && /* @__PURE__ */ s(
|
|
827
|
+
"button",
|
|
828
|
+
{
|
|
829
|
+
type: "button",
|
|
830
|
+
onClick: n,
|
|
831
|
+
className: "p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 rounded-full hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",
|
|
832
|
+
title: "Clear search",
|
|
833
|
+
children: /* @__PURE__ */ s(
|
|
834
|
+
"svg",
|
|
835
|
+
{
|
|
836
|
+
className: "w-3.5 h-3.5",
|
|
837
|
+
fill: "none",
|
|
838
|
+
stroke: "currentColor",
|
|
839
|
+
viewBox: "0 0 24 24",
|
|
840
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
841
|
+
children: /* @__PURE__ */ s("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" })
|
|
842
|
+
}
|
|
843
|
+
)
|
|
844
|
+
}
|
|
845
|
+
)
|
|
846
|
+
] })
|
|
847
|
+
] });
|
|
848
|
+
}, Xt = ({
|
|
849
|
+
columns: e,
|
|
850
|
+
hasActions: t,
|
|
851
|
+
actionsTitle: n = "Actions",
|
|
852
|
+
actionsWidth: o,
|
|
853
|
+
sortBy: l,
|
|
854
|
+
sortOrder: a,
|
|
855
|
+
onSort: i,
|
|
856
|
+
selectable: g,
|
|
857
|
+
allSelected: c,
|
|
858
|
+
isIndeterminate: d,
|
|
859
|
+
onToggleSelectAll: r
|
|
860
|
+
}) => {
|
|
861
|
+
const m = ee();
|
|
862
|
+
return /* @__PURE__ */ s("thead", { className: m.classes?.thead || "bg-gray-50/80 dark:bg-slate-800/80 border-b border-gray-200 dark:border-gray-800", children: /* @__PURE__ */ b("tr", { children: [
|
|
863
|
+
g && /* @__PURE__ */ s("th", { className: "w-10 px-4 py-3 text-center align-middle", children: /* @__PURE__ */ s(
|
|
864
|
+
"input",
|
|
865
|
+
{
|
|
866
|
+
type: "checkbox",
|
|
867
|
+
checked: c,
|
|
868
|
+
ref: (u) => {
|
|
869
|
+
u && (u.indeterminate = !!d);
|
|
870
|
+
},
|
|
871
|
+
onChange: r,
|
|
872
|
+
className: "w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-primary/30 cursor-pointer"
|
|
873
|
+
}
|
|
874
|
+
) }),
|
|
875
|
+
e.map((u) => {
|
|
876
|
+
const f = l === u.key, p = u.sortable !== !1 && !!i, k = u.align === "center" ? "text-center" : u.align === "right" ? "text-right" : "text-left";
|
|
877
|
+
return /* @__PURE__ */ s(
|
|
878
|
+
"th",
|
|
879
|
+
{
|
|
880
|
+
style: {
|
|
881
|
+
width: u.width,
|
|
882
|
+
minWidth: u.minWidth,
|
|
883
|
+
maxWidth: u.maxWidth
|
|
884
|
+
},
|
|
885
|
+
onClick: () => p && i?.(String(u.key)),
|
|
886
|
+
className: `${m.classes?.th || "py-3.5 px-4 font-bold select-none whitespace-nowrap text-xs uppercase tracking-wider"} ${k} ${u.headerClassName || ""} ${p ? "cursor-pointer hover:text-primary transition-colors group" : ""}`,
|
|
887
|
+
children: /* @__PURE__ */ b(
|
|
888
|
+
"div",
|
|
889
|
+
{
|
|
890
|
+
className: `inline-flex items-center gap-1.5 ${u.align === "center" ? "justify-center" : u.align === "right" ? "justify-end" : "justify-start"}`,
|
|
891
|
+
children: [
|
|
892
|
+
/* @__PURE__ */ s("span", { children: u.title }),
|
|
893
|
+
p && /* @__PURE__ */ s(
|
|
894
|
+
"span",
|
|
895
|
+
{
|
|
896
|
+
className: `inline-flex flex-col text-[10px] transition-transform ${f ? "text-primary scale-110" : "text-gray-400 opacity-40 group-hover:opacity-100"}`,
|
|
897
|
+
children: f ? a === "asc" ? "▲" : "▼" : /* @__PURE__ */ s("span", { className: "text-[9px] leading-none opacity-50", children: "▲▼" })
|
|
898
|
+
}
|
|
899
|
+
)
|
|
900
|
+
]
|
|
901
|
+
}
|
|
902
|
+
)
|
|
903
|
+
},
|
|
904
|
+
String(u.key)
|
|
905
|
+
);
|
|
906
|
+
}),
|
|
907
|
+
t && /* @__PURE__ */ s(
|
|
908
|
+
"th",
|
|
909
|
+
{
|
|
910
|
+
style: { width: o || "auto" },
|
|
911
|
+
className: `${m.classes?.th || "py-3.5 px-4 font-bold select-none whitespace-nowrap text-xs uppercase tracking-wider"} text-right pr-6`,
|
|
912
|
+
children: n
|
|
913
|
+
}
|
|
914
|
+
)
|
|
915
|
+
] }) });
|
|
916
|
+
}, _ = () => /* @__PURE__ */ s("span", { className: "text-gray-400 dark:text-gray-500 font-mono text-sm", children: "—" }), Ze = ({ value: e }) => {
|
|
917
|
+
if (e == null || e === "")
|
|
918
|
+
return /* @__PURE__ */ s(_, {});
|
|
919
|
+
const t = String(e);
|
|
920
|
+
return /* @__PURE__ */ s("span", { className: "truncate block max-w-xs font-normal text-sm", title: t, children: t });
|
|
921
|
+
}, Qt = ({ value: e }) => {
|
|
922
|
+
if (e == null || isNaN(Number(e)))
|
|
923
|
+
return /* @__PURE__ */ s(_, {});
|
|
924
|
+
const t = Number(e);
|
|
925
|
+
return /* @__PURE__ */ s("span", { className: "font-mono text-sm font-medium", children: t.toLocaleString() });
|
|
926
|
+
}, er = ({ value: e }) => {
|
|
927
|
+
if (e == null)
|
|
928
|
+
return /* @__PURE__ */ s(_, {});
|
|
929
|
+
const t = !!e;
|
|
930
|
+
return /* @__PURE__ */ b(
|
|
931
|
+
"span",
|
|
932
|
+
{
|
|
933
|
+
className: `inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-semibold tracking-wide ${t ? "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border border-emerald-500/20" : "bg-rose-500/10 text-rose-600 dark:text-rose-400 border border-rose-500/20"}`,
|
|
934
|
+
children: [
|
|
935
|
+
/* @__PURE__ */ s("span", { className: `w-1.5 h-1.5 rounded-full ${t ? "bg-emerald-500" : "bg-rose-500"}` }),
|
|
936
|
+
t ? "Yes" : "No"
|
|
937
|
+
]
|
|
938
|
+
}
|
|
939
|
+
);
|
|
940
|
+
}, Ke = ({
|
|
941
|
+
value: e,
|
|
942
|
+
isDateTime: t = !1
|
|
943
|
+
}) => {
|
|
944
|
+
if (!e) return /* @__PURE__ */ s(_, {});
|
|
945
|
+
const n = e instanceof Date ? e : new Date(e);
|
|
946
|
+
return isNaN(n.getTime()) ? /* @__PURE__ */ s(Ze, { value: e, column: { key: "" } }) : /* @__PURE__ */ b("span", { className: "whitespace-nowrap text-xs sm:text-sm font-medium text-gray-700 dark:text-gray-300", children: [
|
|
947
|
+
n.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" }),
|
|
948
|
+
t && /* @__PURE__ */ s("span", { className: "text-xs text-gray-400 dark:text-gray-500 ml-1.5", children: n.toLocaleTimeString(void 0, { hour: "2-digit", minute: "2-digit" }) })
|
|
949
|
+
] });
|
|
950
|
+
}, tr = ({ value: e, column: t }) => {
|
|
951
|
+
if (e == null || isNaN(Number(e)))
|
|
952
|
+
return /* @__PURE__ */ s(_, {});
|
|
953
|
+
const n = Number(e), o = t.currency || "EGP";
|
|
954
|
+
return /* @__PURE__ */ b("span", { className: "font-mono text-sm font-bold text-gray-900 dark:text-white", children: [
|
|
955
|
+
n.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 }),
|
|
956
|
+
" ",
|
|
957
|
+
/* @__PURE__ */ s("span", { className: "text-xs font-normal text-gray-500 dark:text-gray-400", children: o })
|
|
958
|
+
] });
|
|
959
|
+
}, Ge = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z'/%3E%3C/svg%3E", rr = ({ value: e }) => {
|
|
960
|
+
let t = "";
|
|
961
|
+
return typeof e == "string" ? t = e : Array.isArray(e) && e.length > 0 ? t = typeof e[0] == "string" ? e[0] : e[0]?.url || "" : e && typeof e == "object" && (t = e.url || ""), t || (t = Ge), /* @__PURE__ */ s("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ s(
|
|
962
|
+
"img",
|
|
963
|
+
{
|
|
964
|
+
src: t,
|
|
965
|
+
alt: "Thumbnail",
|
|
966
|
+
className: "w-10 h-10 rounded-full object-cover border border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-gray-800 shadow-sm",
|
|
967
|
+
loading: "lazy",
|
|
968
|
+
onError: (n) => {
|
|
969
|
+
n.target.src = Ge;
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
) });
|
|
973
|
+
}, ar = {
|
|
974
|
+
active: { bg: "bg-emerald-500/10 border-emerald-500/20", text: "text-emerald-600 dark:text-emerald-400", dot: "bg-emerald-500" },
|
|
975
|
+
delivered: { bg: "bg-emerald-500/10 border-emerald-500/20", text: "text-emerald-600 dark:text-emerald-400", dot: "bg-emerald-500" },
|
|
976
|
+
completed: { bg: "bg-emerald-500/10 border-emerald-500/20", text: "text-emerald-600 dark:text-emerald-400", dot: "bg-emerald-500" },
|
|
977
|
+
approved: { bg: "bg-emerald-500/10 border-emerald-500/20", text: "text-emerald-600 dark:text-emerald-400", dot: "bg-emerald-500" },
|
|
978
|
+
paid: { bg: "bg-emerald-500/10 border-emerald-500/20", text: "text-emerald-600 dark:text-emerald-400", dot: "bg-emerald-500" },
|
|
979
|
+
online: { bg: "bg-emerald-500/10 border-emerald-500/20", text: "text-emerald-600 dark:text-emerald-400", dot: "bg-emerald-500" },
|
|
980
|
+
open: { bg: "bg-blue-500/10 border-blue-500/20", text: "text-blue-600 dark:text-blue-400", dot: "bg-blue-500" },
|
|
981
|
+
investigating: { bg: "bg-blue-500/10 border-blue-500/20", text: "text-blue-600 dark:text-blue-400", dot: "bg-blue-500" },
|
|
982
|
+
pending: { bg: "bg-amber-500/10 border-amber-500/20", text: "text-amber-600 dark:text-amber-400", dot: "bg-amber-500" },
|
|
983
|
+
processing: { bg: "bg-amber-500/10 border-amber-500/20", text: "text-amber-600 dark:text-amber-400", dot: "bg-amber-500" },
|
|
984
|
+
banned: { bg: "bg-rose-500/10 border-rose-500/20", text: "text-rose-600 dark:text-rose-400", dot: "bg-rose-500" },
|
|
985
|
+
rejected: { bg: "bg-rose-500/10 border-rose-500/20", text: "text-rose-600 dark:text-rose-400", dot: "bg-rose-500" },
|
|
986
|
+
cancelled: { bg: "bg-rose-500/10 border-rose-500/20", text: "text-rose-600 dark:text-rose-400", dot: "bg-rose-500" },
|
|
987
|
+
offline: { bg: "bg-gray-500/10 border-gray-500/20", text: "text-gray-600 dark:text-gray-400", dot: "bg-gray-500" },
|
|
988
|
+
closed: { bg: "bg-gray-500/10 border-gray-500/20", text: "text-gray-600 dark:text-gray-400", dot: "bg-gray-500" }
|
|
989
|
+
}, nr = ({ value: e, column: t }) => {
|
|
990
|
+
if (e == null || e === "")
|
|
991
|
+
return /* @__PURE__ */ s(_, {});
|
|
992
|
+
const n = String(e), o = n.toLowerCase();
|
|
993
|
+
if (t.statusMap && t.statusMap[n]) {
|
|
994
|
+
const a = t.statusMap[n];
|
|
995
|
+
return /* @__PURE__ */ b(
|
|
996
|
+
"span",
|
|
997
|
+
{
|
|
998
|
+
className: "inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-bold uppercase tracking-wider border",
|
|
999
|
+
style: { color: a.color, backgroundColor: a.bg },
|
|
1000
|
+
children: [
|
|
1001
|
+
/* @__PURE__ */ s("span", { className: "w-1.5 h-1.5 rounded-full", style: { backgroundColor: a.color } }),
|
|
1002
|
+
a.label || n
|
|
1003
|
+
]
|
|
1004
|
+
}
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
const l = ar[o] || {
|
|
1008
|
+
bg: "bg-gray-500/10 border-gray-500/20",
|
|
1009
|
+
text: "text-gray-700 dark:text-gray-300",
|
|
1010
|
+
dot: "bg-gray-400"
|
|
1011
|
+
};
|
|
1012
|
+
return /* @__PURE__ */ b(
|
|
1013
|
+
"span",
|
|
1014
|
+
{
|
|
1015
|
+
className: `inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full text-xs font-bold uppercase tracking-wider border ${l.bg} ${l.text}`,
|
|
1016
|
+
children: [
|
|
1017
|
+
/* @__PURE__ */ s("span", { className: `w-1.5 h-1.5 rounded-full ${l.dot}` }),
|
|
1018
|
+
n
|
|
1019
|
+
]
|
|
1020
|
+
}
|
|
1021
|
+
);
|
|
1022
|
+
}, sr = ({ value: e }) => !Array.isArray(e) || e.length === 0 ? /* @__PURE__ */ s(_, {}) : /* @__PURE__ */ b("div", { className: "flex flex-wrap gap-1 items-center", children: [
|
|
1023
|
+
e.slice(0, 3).map((t, n) => /* @__PURE__ */ s(
|
|
1024
|
+
"span",
|
|
1025
|
+
{
|
|
1026
|
+
className: "inline-block px-2 py-0.5 text-xs rounded bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-gray-700",
|
|
1027
|
+
children: typeof t == "object" ? JSON.stringify(t) : String(t)
|
|
1028
|
+
},
|
|
1029
|
+
n
|
|
1030
|
+
)),
|
|
1031
|
+
e.length > 3 && /* @__PURE__ */ b("span", { className: "text-xs text-gray-400 font-medium", children: [
|
|
1032
|
+
"+",
|
|
1033
|
+
e.length - 3
|
|
1034
|
+
] })
|
|
1035
|
+
] }), or = ({ value: e }) => !e || typeof e != "object" ? /* @__PURE__ */ s(_, {}) : "en" in e || "ar" in e ? /* @__PURE__ */ s("span", { className: "font-medium text-sm", children: e.en || e.ar || "" }) : /* @__PURE__ */ s("span", { className: "font-mono text-xs text-gray-500 dark:text-gray-400 truncate block max-w-xs", title: JSON.stringify(e), children: JSON.stringify(e) }), ir = ({ value: e }) => {
|
|
1036
|
+
if (!e) return /* @__PURE__ */ s(_, {});
|
|
1037
|
+
const t = String(e);
|
|
1038
|
+
return /* @__PURE__ */ b(
|
|
1039
|
+
"a",
|
|
1040
|
+
{
|
|
1041
|
+
href: t,
|
|
1042
|
+
target: "_blank",
|
|
1043
|
+
rel: "noopener noreferrer",
|
|
1044
|
+
className: "text-primary hover:underline text-sm font-medium inline-flex items-center gap-1",
|
|
1045
|
+
children: [
|
|
1046
|
+
/* @__PURE__ */ s("span", { className: "truncate max-w-[150px]", children: t }),
|
|
1047
|
+
/* @__PURE__ */ s("span", { className: "text-xs", children: "↗" })
|
|
1048
|
+
]
|
|
1049
|
+
}
|
|
1050
|
+
);
|
|
1051
|
+
}, lr = ({ value: e }) => {
|
|
1052
|
+
if (!e) return /* @__PURE__ */ s(_, {});
|
|
1053
|
+
const t = String(e);
|
|
1054
|
+
return /* @__PURE__ */ s(
|
|
1055
|
+
"a",
|
|
1056
|
+
{
|
|
1057
|
+
href: `mailto:${t}`,
|
|
1058
|
+
className: "text-primary hover:underline text-sm font-medium truncate block max-w-xs",
|
|
1059
|
+
children: t
|
|
1060
|
+
}
|
|
1061
|
+
);
|
|
1062
|
+
}, dr = ({ value: e }) => {
|
|
1063
|
+
if (!e) return /* @__PURE__ */ s(_, {});
|
|
1064
|
+
const t = String(e);
|
|
1065
|
+
return /* @__PURE__ */ s(
|
|
1066
|
+
"a",
|
|
1067
|
+
{
|
|
1068
|
+
href: `tel:${t}`,
|
|
1069
|
+
className: "font-mono text-sm text-gray-800 dark:text-gray-200 hover:text-primary transition-colors",
|
|
1070
|
+
children: t
|
|
1071
|
+
}
|
|
1072
|
+
);
|
|
1073
|
+
}, cr = ({ row: e, column: t, rowIndex: n }) => {
|
|
1074
|
+
const o = S(e, t.key);
|
|
1075
|
+
if (t.render && typeof t.render == "function")
|
|
1076
|
+
return /* @__PURE__ */ s(Se, { children: t.render(o, e, n) });
|
|
1077
|
+
if (t.formatter && typeof t.formatter == "function")
|
|
1078
|
+
return /* @__PURE__ */ s(Se, { children: t.formatter(o, e, n) });
|
|
1079
|
+
switch (t.type) {
|
|
1080
|
+
case "boolean":
|
|
1081
|
+
return /* @__PURE__ */ s(er, { value: o, column: t });
|
|
1082
|
+
case "number":
|
|
1083
|
+
return /* @__PURE__ */ s(Qt, { value: o, column: t });
|
|
1084
|
+
case "currency":
|
|
1085
|
+
return /* @__PURE__ */ s(tr, { value: o, column: t });
|
|
1086
|
+
case "date":
|
|
1087
|
+
return /* @__PURE__ */ s(Ke, { value: o, column: t, isDateTime: !1 });
|
|
1088
|
+
case "datetime":
|
|
1089
|
+
return /* @__PURE__ */ s(Ke, { value: o, column: t, isDateTime: !0 });
|
|
1090
|
+
case "image":
|
|
1091
|
+
return /* @__PURE__ */ s(rr, { value: o, column: t });
|
|
1092
|
+
case "status":
|
|
1093
|
+
return /* @__PURE__ */ s(nr, { value: o, column: t });
|
|
1094
|
+
case "array":
|
|
1095
|
+
return /* @__PURE__ */ s(sr, { value: o, column: t });
|
|
1096
|
+
case "object":
|
|
1097
|
+
return /* @__PURE__ */ s(or, { value: o, column: t });
|
|
1098
|
+
case "url":
|
|
1099
|
+
return /* @__PURE__ */ s(ir, { value: o, column: t });
|
|
1100
|
+
case "email":
|
|
1101
|
+
return /* @__PURE__ */ s(lr, { value: o, column: t });
|
|
1102
|
+
case "phone":
|
|
1103
|
+
return /* @__PURE__ */ s(dr, { value: o, column: t });
|
|
1104
|
+
default:
|
|
1105
|
+
return /* @__PURE__ */ s(Ze, { value: o, column: t });
|
|
1106
|
+
}
|
|
1107
|
+
}, gr = ({
|
|
1108
|
+
isOpen: e,
|
|
1109
|
+
title: t,
|
|
1110
|
+
message: n,
|
|
1111
|
+
confirmText: o = "Confirm",
|
|
1112
|
+
cancelText: l = "Cancel",
|
|
1113
|
+
type: a = "danger",
|
|
1114
|
+
onClose: i,
|
|
1115
|
+
onConfirm: g,
|
|
1116
|
+
isLoading: c = !1
|
|
1117
|
+
}) => (ye(() => {
|
|
1118
|
+
const d = (r) => {
|
|
1119
|
+
r.key === "Escape" && i();
|
|
1120
|
+
};
|
|
1121
|
+
return e && window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
|
|
1122
|
+
}, [e, i]), e ? /* @__PURE__ */ s(
|
|
1123
|
+
"div",
|
|
1124
|
+
{
|
|
1125
|
+
className: "fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm any-table-fade-in",
|
|
1126
|
+
onClick: i,
|
|
1127
|
+
children: /* @__PURE__ */ b(
|
|
1128
|
+
"div",
|
|
1129
|
+
{
|
|
1130
|
+
className: "bg-white dark:bg-slate-900 border border-gray-200 dark:border-gray-800 w-full max-w-md rounded-2xl p-6 shadow-2xl transform transition-all text-center",
|
|
1131
|
+
onClick: (d) => d.stopPropagation(),
|
|
1132
|
+
role: "dialog",
|
|
1133
|
+
children: [
|
|
1134
|
+
/* @__PURE__ */ s(
|
|
1135
|
+
"div",
|
|
1136
|
+
{
|
|
1137
|
+
className: `mx-auto mb-4 w-14 h-14 rounded-full flex items-center justify-center text-2xl ${a === "danger" ? "bg-rose-500/10 text-rose-500" : a === "warning" ? "bg-amber-500/10 text-amber-500" : "bg-blue-500/10 text-blue-500"}`,
|
|
1138
|
+
children: a === "danger" ? "⚠️" : a === "warning" ? "⚡" : "ℹ️"
|
|
1139
|
+
}
|
|
1140
|
+
),
|
|
1141
|
+
/* @__PURE__ */ s("h3", { className: "text-xl font-black text-gray-900 dark:text-white mb-2", children: t }),
|
|
1142
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-gray-600 dark:text-gray-400 mb-6 leading-relaxed", children: n }),
|
|
1143
|
+
/* @__PURE__ */ b("div", { className: "flex items-center justify-center gap-3", children: [
|
|
1144
|
+
/* @__PURE__ */ s(
|
|
1145
|
+
"button",
|
|
1146
|
+
{
|
|
1147
|
+
type: "button",
|
|
1148
|
+
disabled: c,
|
|
1149
|
+
onClick: i,
|
|
1150
|
+
className: "w-full py-2.5 px-4 rounded-xl border border-gray-200 dark:border-gray-700 bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-gray-300 font-bold text-sm hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors disabled:opacity-50",
|
|
1151
|
+
children: l
|
|
1152
|
+
}
|
|
1153
|
+
),
|
|
1154
|
+
/* @__PURE__ */ s(
|
|
1155
|
+
"button",
|
|
1156
|
+
{
|
|
1157
|
+
type: "button",
|
|
1158
|
+
disabled: c,
|
|
1159
|
+
onClick: g,
|
|
1160
|
+
className: `w-full py-2.5 px-4 rounded-xl font-bold text-sm text-white transition-all shadow-md active:scale-95 disabled:opacity-50 ${a === "danger" ? "bg-rose-600 hover:bg-rose-700 shadow-rose-600/30" : "bg-primary hover:bg-primary-soft shadow-primary/30"}`,
|
|
1161
|
+
children: c ? "Processing..." : o
|
|
1162
|
+
}
|
|
1163
|
+
)
|
|
1164
|
+
] })
|
|
1165
|
+
]
|
|
1166
|
+
}
|
|
1167
|
+
)
|
|
1168
|
+
}
|
|
1169
|
+
) : null), Ye = {
|
|
1170
|
+
primary: "bg-primary text-white hover:bg-primary-soft shadow-sm shadow-primary/20",
|
|
1171
|
+
secondary: "bg-emerald-600 text-white hover:bg-emerald-700 shadow-sm shadow-emerald-600/20",
|
|
1172
|
+
success: "bg-emerald-500 text-white hover:bg-emerald-600 shadow-sm shadow-emerald-500/20",
|
|
1173
|
+
warning: "bg-amber-500 text-white hover:bg-amber-600 shadow-sm shadow-amber-500/20",
|
|
1174
|
+
danger: "bg-rose-500 text-white hover:bg-rose-600 shadow-sm shadow-rose-500/20",
|
|
1175
|
+
info: "bg-sky-500 text-white hover:bg-sky-600 shadow-sm shadow-sky-500/20",
|
|
1176
|
+
neutral: "bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-700 border border-gray-200 dark:border-gray-700",
|
|
1177
|
+
ghost: "bg-transparent text-gray-600 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-800 hover:text-gray-900 dark:hover:text-white"
|
|
1178
|
+
}, ur = ({ row: e, actions: t, context: n }) => {
|
|
1179
|
+
const [o, l] = v(null), [a, i] = v({});
|
|
1180
|
+
if (!t || !t.length)
|
|
1181
|
+
return null;
|
|
1182
|
+
const g = async (r) => {
|
|
1183
|
+
if (r.confirmation) {
|
|
1184
|
+
const m = typeof r.confirmation.title == "function" ? r.confirmation.title(e) : r.confirmation.title || "Confirm Action", u = typeof r.confirmation.message == "function" ? r.confirmation.message(e) : r.confirmation.message || "Are you sure you want to perform this action?";
|
|
1185
|
+
l({
|
|
1186
|
+
isOpen: !0,
|
|
1187
|
+
title: m,
|
|
1188
|
+
message: u,
|
|
1189
|
+
confirmText: r.confirmation.confirmText || "Confirm",
|
|
1190
|
+
cancelText: r.confirmation.cancelText || "Cancel",
|
|
1191
|
+
type: r.confirmation.type || "danger",
|
|
1192
|
+
onConfirm: async () => {
|
|
1193
|
+
l(null), await c(r);
|
|
1194
|
+
}
|
|
1195
|
+
});
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
await c(r);
|
|
1199
|
+
}, c = async (r) => {
|
|
1200
|
+
if (r.type === "button" || !r.type) {
|
|
1201
|
+
i((m) => ({ ...m, [r.id]: !0 }));
|
|
1202
|
+
try {
|
|
1203
|
+
await r.onClick(e, n);
|
|
1204
|
+
} finally {
|
|
1205
|
+
i((m) => ({ ...m, [r.id]: !1 }));
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
}, d = async (r, m) => {
|
|
1209
|
+
const u = !m;
|
|
1210
|
+
i((f) => ({ ...f, [r.id]: !0 }));
|
|
1211
|
+
try {
|
|
1212
|
+
await r.onChange(e, u, n);
|
|
1213
|
+
} finally {
|
|
1214
|
+
i((f) => ({ ...f, [r.id]: !1 }));
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
return /* @__PURE__ */ b(Se, { children: [
|
|
1218
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-end gap-2 pr-2", children: t.map((r) => {
|
|
1219
|
+
if (typeof r.hide == "function" && r.hide(e) || typeof r.show == "function" && !r.show(e)) return null;
|
|
1220
|
+
const m = typeof r.disabled == "function" ? r.disabled(e) : !!r.disabled, u = a[r.id] || (typeof r.loading == "function" ? r.loading(e) : !!r.loading), f = typeof r.label == "function" ? r.label(e) : r.label, p = typeof r.icon == "function" ? r.icon(e) : r.icon, k = typeof r.tooltip == "function" ? r.tooltip(e) : r.tooltip, E = typeof r.className == "function" ? r.className(e) : r.className || "";
|
|
1221
|
+
if (r.type === "custom" && r.render)
|
|
1222
|
+
return /* @__PURE__ */ s(Nt.Fragment, { children: r.render(e, n) }, r.id);
|
|
1223
|
+
if (r.type === "switch") {
|
|
1224
|
+
const M = r, N = M.checked(e);
|
|
1225
|
+
return /* @__PURE__ */ b(
|
|
1226
|
+
"div",
|
|
1227
|
+
{
|
|
1228
|
+
className: "flex items-center gap-2",
|
|
1229
|
+
title: k || f,
|
|
1230
|
+
children: [
|
|
1231
|
+
f && /* @__PURE__ */ b("span", { className: "text-xs font-semibold text-gray-500", children: [
|
|
1232
|
+
f,
|
|
1233
|
+
":"
|
|
1234
|
+
] }),
|
|
1235
|
+
/* @__PURE__ */ s(
|
|
1236
|
+
"button",
|
|
1237
|
+
{
|
|
1238
|
+
type: "button",
|
|
1239
|
+
role: "switch",
|
|
1240
|
+
"aria-checked": N,
|
|
1241
|
+
disabled: m || u,
|
|
1242
|
+
onClick: () => d(M, N),
|
|
1243
|
+
className: `relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${N ? "bg-emerald-500" : "bg-gray-300 dark:bg-gray-700"} ${E}`,
|
|
1244
|
+
children: /* @__PURE__ */ s(
|
|
1245
|
+
"span",
|
|
1246
|
+
{
|
|
1247
|
+
"aria-hidden": "true",
|
|
1248
|
+
className: `pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out flex items-center justify-center ${N ? "translate-x-5" : "translate-x-0"}`,
|
|
1249
|
+
children: u && /* @__PURE__ */ s("span", { className: "w-2.5 h-2.5 border-2 border-primary border-t-transparent rounded-full animate-spin" })
|
|
1250
|
+
}
|
|
1251
|
+
)
|
|
1252
|
+
}
|
|
1253
|
+
)
|
|
1254
|
+
]
|
|
1255
|
+
},
|
|
1256
|
+
r.id
|
|
1257
|
+
);
|
|
1258
|
+
}
|
|
1259
|
+
const h = typeof r.variant == "function" ? r.variant(e) : r.variant || "neutral", D = Ye[h] || Ye.neutral;
|
|
1260
|
+
return /* @__PURE__ */ b(
|
|
1261
|
+
"button",
|
|
1262
|
+
{
|
|
1263
|
+
type: "button",
|
|
1264
|
+
disabled: m || u,
|
|
1265
|
+
onClick: () => g(r),
|
|
1266
|
+
title: k,
|
|
1267
|
+
style: r.color ? { backgroundColor: r.color, color: "#ffffff" } : void 0,
|
|
1268
|
+
className: `inline-flex items-center justify-center gap-1.5 px-3 py-1.5 rounded-xl text-xs font-bold transition-all duration-200 active:scale-95 disabled:cursor-not-allowed disabled:opacity-50 disabled:active:scale-100 ${D} ${E}`,
|
|
1269
|
+
children: [
|
|
1270
|
+
u ? /* @__PURE__ */ s("span", { className: "w-3.5 h-3.5 border-2 border-current border-t-transparent rounded-full animate-spin" }) : p && /* @__PURE__ */ s("span", { className: "text-sm", children: p }),
|
|
1271
|
+
f && /* @__PURE__ */ s("span", { children: f })
|
|
1272
|
+
]
|
|
1273
|
+
},
|
|
1274
|
+
r.id
|
|
1275
|
+
);
|
|
1276
|
+
}) }),
|
|
1277
|
+
o && /* @__PURE__ */ s(
|
|
1278
|
+
gr,
|
|
1279
|
+
{
|
|
1280
|
+
isOpen: o.isOpen,
|
|
1281
|
+
title: o.title,
|
|
1282
|
+
message: o.message,
|
|
1283
|
+
confirmText: o.confirmText,
|
|
1284
|
+
cancelText: o.cancelText,
|
|
1285
|
+
type: o.type,
|
|
1286
|
+
onClose: () => l(null),
|
|
1287
|
+
onConfirm: o.onConfirm
|
|
1288
|
+
}
|
|
1289
|
+
)
|
|
1290
|
+
] });
|
|
1291
|
+
}, mr = ({
|
|
1292
|
+
rows: e,
|
|
1293
|
+
columns: t,
|
|
1294
|
+
actions: n,
|
|
1295
|
+
actionContext: o,
|
|
1296
|
+
rowKeyResolver: l,
|
|
1297
|
+
selectable: a,
|
|
1298
|
+
selectedKeys: i,
|
|
1299
|
+
onToggleSelectRow: g,
|
|
1300
|
+
onRowClick: c,
|
|
1301
|
+
striped: d = !1,
|
|
1302
|
+
hoverable: r = !0
|
|
1303
|
+
}) => {
|
|
1304
|
+
const m = ee(), u = !!(n && n.length > 0);
|
|
1305
|
+
return /* @__PURE__ */ s("tbody", { className: m.classes?.tbody || "divide-y divide-gray-100 dark:divide-gray-800/60 bg-white dark:bg-slate-900", children: e.map((f, p) => {
|
|
1306
|
+
const k = l(f, p), E = i?.has(k);
|
|
1307
|
+
return /* @__PURE__ */ b(
|
|
1308
|
+
"tr",
|
|
1309
|
+
{
|
|
1310
|
+
onClick: (h) => c?.(f, p, h),
|
|
1311
|
+
className: `${m.classes?.tr || "transition-colors duration-150"} ${d && p % 2 === 1 ? "bg-gray-50/40 dark:bg-slate-800/20" : ""} ${r ? "hover:bg-gray-50/70 dark:hover:bg-slate-800/50" : ""} ${E ? "bg-primary/5 dark:bg-primary/10" : ""} ${c ? "cursor-pointer" : ""}`,
|
|
1312
|
+
children: [
|
|
1313
|
+
a && /* @__PURE__ */ s(
|
|
1314
|
+
"td",
|
|
1315
|
+
{
|
|
1316
|
+
className: "w-10 px-4 py-3 text-center align-middle",
|
|
1317
|
+
onClick: (h) => h.stopPropagation(),
|
|
1318
|
+
children: /* @__PURE__ */ s(
|
|
1319
|
+
"input",
|
|
1320
|
+
{
|
|
1321
|
+
type: "checkbox",
|
|
1322
|
+
checked: E,
|
|
1323
|
+
onChange: () => g?.(k, f),
|
|
1324
|
+
className: "w-4 h-4 rounded border-gray-300 dark:border-gray-600 text-primary focus:ring-primary/30 cursor-pointer"
|
|
1325
|
+
}
|
|
1326
|
+
)
|
|
1327
|
+
}
|
|
1328
|
+
),
|
|
1329
|
+
t.map((h) => {
|
|
1330
|
+
const D = h.align === "center" ? "text-center" : h.align === "right" ? "text-right" : "text-left", M = typeof h.className == "function" ? h.className(f?.[h.key], f, p) : h.className || "";
|
|
1331
|
+
return /* @__PURE__ */ s(
|
|
1332
|
+
"td",
|
|
1333
|
+
{
|
|
1334
|
+
style: {
|
|
1335
|
+
width: h.width,
|
|
1336
|
+
minWidth: h.minWidth,
|
|
1337
|
+
maxWidth: h.maxWidth
|
|
1338
|
+
},
|
|
1339
|
+
className: `${m.classes?.td || "py-3 px-4 text-sm align-middle"} ${D} ${M}`,
|
|
1340
|
+
children: /* @__PURE__ */ s(cr, { row: f, column: h, rowIndex: p })
|
|
1341
|
+
},
|
|
1342
|
+
String(h.key)
|
|
1343
|
+
);
|
|
1344
|
+
}),
|
|
1345
|
+
u && /* @__PURE__ */ s(
|
|
1346
|
+
"td",
|
|
1347
|
+
{
|
|
1348
|
+
className: `${m.classes?.td || "py-3 px-4 text-sm align-middle"} text-right`,
|
|
1349
|
+
onClick: (h) => h.stopPropagation(),
|
|
1350
|
+
children: /* @__PURE__ */ s(
|
|
1351
|
+
ur,
|
|
1352
|
+
{
|
|
1353
|
+
row: f,
|
|
1354
|
+
actions: n || [],
|
|
1355
|
+
context: o
|
|
1356
|
+
}
|
|
1357
|
+
)
|
|
1358
|
+
}
|
|
1359
|
+
)
|
|
1360
|
+
]
|
|
1361
|
+
},
|
|
1362
|
+
String(k)
|
|
1363
|
+
);
|
|
1364
|
+
}) });
|
|
1365
|
+
}, fr = ({
|
|
1366
|
+
page: e,
|
|
1367
|
+
pageSize: t,
|
|
1368
|
+
totalRecords: n,
|
|
1369
|
+
totalPages: o,
|
|
1370
|
+
pageSizeOptions: l = [5, 10, 20, 50, 100],
|
|
1371
|
+
onPageChange: a,
|
|
1372
|
+
onPageSizeChange: i,
|
|
1373
|
+
showPageSizeSelector: g = !0,
|
|
1374
|
+
showTotalCount: c = !0,
|
|
1375
|
+
pageWindow: d
|
|
1376
|
+
}) => {
|
|
1377
|
+
const r = ee(), m = Math.min((e - 1) * t + 1, n), u = Math.min(e * t, n);
|
|
1378
|
+
return /* @__PURE__ */ b(
|
|
1379
|
+
"div",
|
|
1380
|
+
{
|
|
1381
|
+
className: r.classes?.paginationContainer || "w-full flex flex-wrap items-center justify-between gap-4 pt-4 text-sm text-gray-600 dark:text-gray-400",
|
|
1382
|
+
children: [
|
|
1383
|
+
/* @__PURE__ */ b("div", { className: "flex items-center gap-3", children: [
|
|
1384
|
+
c && n > 0 ? /* @__PURE__ */ b("span", { className: "text-xs sm:text-sm font-medium", children: [
|
|
1385
|
+
"Showing ",
|
|
1386
|
+
/* @__PURE__ */ s("strong", { className: "text-gray-900 dark:text-white font-bold", children: m }),
|
|
1387
|
+
" to",
|
|
1388
|
+
" ",
|
|
1389
|
+
/* @__PURE__ */ s("strong", { className: "text-gray-900 dark:text-white font-bold", children: u }),
|
|
1390
|
+
" of",
|
|
1391
|
+
" ",
|
|
1392
|
+
/* @__PURE__ */ s("strong", { className: "text-gray-900 dark:text-white font-bold", children: n.toLocaleString() }),
|
|
1393
|
+
" results"
|
|
1394
|
+
] }) : /* @__PURE__ */ b("span", { className: "text-xs sm:text-sm font-medium", children: [
|
|
1395
|
+
"Page ",
|
|
1396
|
+
e,
|
|
1397
|
+
" of ",
|
|
1398
|
+
o
|
|
1399
|
+
] }),
|
|
1400
|
+
g && /* @__PURE__ */ b("div", { className: "flex items-center gap-2 ml-2", children: [
|
|
1401
|
+
/* @__PURE__ */ s("span", { className: "text-xs text-gray-500 hidden sm:inline", children: "Rows:" }),
|
|
1402
|
+
/* @__PURE__ */ s(
|
|
1403
|
+
"select",
|
|
1404
|
+
{
|
|
1405
|
+
value: t,
|
|
1406
|
+
onChange: (f) => i(Number(f.target.value)),
|
|
1407
|
+
className: r.classes?.paginationSelect || "h-8 px-2.5 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-slate-800 text-xs font-semibold text-gray-800 dark:text-gray-200 focus:outline-none focus:border-primary cursor-pointer",
|
|
1408
|
+
children: l.map((f) => /* @__PURE__ */ b("option", { value: f, className: "bg-white dark:bg-slate-800 text-gray-900 dark:text-white", children: [
|
|
1409
|
+
f,
|
|
1410
|
+
" / page"
|
|
1411
|
+
] }, f))
|
|
1412
|
+
}
|
|
1413
|
+
)
|
|
1414
|
+
] })
|
|
1415
|
+
] }),
|
|
1416
|
+
/* @__PURE__ */ b("div", { className: "flex items-center gap-1.5 ml-auto", children: [
|
|
1417
|
+
/* @__PURE__ */ s(
|
|
1418
|
+
"button",
|
|
1419
|
+
{
|
|
1420
|
+
type: "button",
|
|
1421
|
+
disabled: e <= 1,
|
|
1422
|
+
onClick: () => a(e - 1),
|
|
1423
|
+
"aria-label": "Previous Page",
|
|
1424
|
+
className: `${r.classes?.paginationButton || "h-8 min-w-[32px] px-2.5 flex items-center justify-center rounded-xl font-bold text-xs bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-slate-700 disabled:opacity-40"}`,
|
|
1425
|
+
children: "‹"
|
|
1426
|
+
}
|
|
1427
|
+
),
|
|
1428
|
+
d.map((f) => {
|
|
1429
|
+
const p = f === e;
|
|
1430
|
+
return /* @__PURE__ */ s(
|
|
1431
|
+
"button",
|
|
1432
|
+
{
|
|
1433
|
+
type: "button",
|
|
1434
|
+
onClick: () => a(f),
|
|
1435
|
+
className: `${r.classes?.paginationButton || "h-8 min-w-[32px] px-2.5 flex items-center justify-center rounded-xl font-bold text-xs"} ${p ? r.classes?.paginationButtonActive || "bg-primary text-white shadow-sm shadow-primary/30" : "bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-slate-700"}`,
|
|
1436
|
+
children: f
|
|
1437
|
+
},
|
|
1438
|
+
f
|
|
1439
|
+
);
|
|
1440
|
+
}),
|
|
1441
|
+
/* @__PURE__ */ s(
|
|
1442
|
+
"button",
|
|
1443
|
+
{
|
|
1444
|
+
type: "button",
|
|
1445
|
+
disabled: e >= o,
|
|
1446
|
+
onClick: () => a(e + 1),
|
|
1447
|
+
"aria-label": "Next Page",
|
|
1448
|
+
className: `${r.classes?.paginationButton || "h-8 min-w-[32px] px-2.5 flex items-center justify-center rounded-xl font-bold text-xs bg-gray-100 dark:bg-slate-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-slate-700 disabled:opacity-40"}`,
|
|
1449
|
+
children: "›"
|
|
1450
|
+
}
|
|
1451
|
+
)
|
|
1452
|
+
] })
|
|
1453
|
+
]
|
|
1454
|
+
}
|
|
1455
|
+
);
|
|
1456
|
+
}, br = ({
|
|
1457
|
+
columnsCount: e = 5,
|
|
1458
|
+
rowsCount: t = 5,
|
|
1459
|
+
hasActions: n = !0
|
|
1460
|
+
}) => /* @__PURE__ */ s("tbody", { className: "divide-y divide-gray-100 dark:divide-gray-800/60 bg-white dark:bg-slate-900", children: Array.from({ length: t }).map((o, l) => /* @__PURE__ */ b("tr", { className: "any-table-pulse", children: [
|
|
1461
|
+
Array.from({ length: e }).map((a, i) => /* @__PURE__ */ s("td", { className: "py-4 px-4 align-middle", children: /* @__PURE__ */ s(
|
|
1462
|
+
"div",
|
|
1463
|
+
{
|
|
1464
|
+
className: "h-4 bg-gray-200 dark:bg-slate-700/60 rounded-md",
|
|
1465
|
+
style: {
|
|
1466
|
+
width: `${Math.floor(40 + (i * 19 + l * 13) % 45)}%`
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
) }, i)),
|
|
1470
|
+
n && /* @__PURE__ */ s("td", { className: "py-4 px-4 text-right align-middle pr-6", children: /* @__PURE__ */ b("div", { className: "inline-flex gap-2 justify-end", children: [
|
|
1471
|
+
/* @__PURE__ */ s("div", { className: "w-14 h-7 bg-gray-200 dark:bg-slate-700/60 rounded-xl" }),
|
|
1472
|
+
/* @__PURE__ */ s("div", { className: "w-14 h-7 bg-gray-200 dark:bg-slate-700/60 rounded-xl" })
|
|
1473
|
+
] }) })
|
|
1474
|
+
] }, l)) }), yr = ({
|
|
1475
|
+
title: e,
|
|
1476
|
+
description: t,
|
|
1477
|
+
isSearchActive: n = !1,
|
|
1478
|
+
onClearSearch: o
|
|
1479
|
+
}) => /* @__PURE__ */ b("div", { className: "w-full py-16 px-6 flex flex-col items-center justify-center text-center any-table-fade-in", children: [
|
|
1480
|
+
/* @__PURE__ */ s("div", { className: "w-16 h-16 mb-4 rounded-2xl bg-gray-100 dark:bg-slate-800 text-gray-400 dark:text-gray-500 flex items-center justify-center text-3xl shadow-inner", children: n ? "🔍" : "📂" }),
|
|
1481
|
+
/* @__PURE__ */ s("h3", { className: "text-lg font-bold text-gray-800 dark:text-gray-200 mb-1", children: e || (n ? "No matching records found" : "No data available") }),
|
|
1482
|
+
/* @__PURE__ */ s("p", { className: "text-sm text-gray-500 dark:text-gray-400 max-w-sm mb-5 leading-relaxed", children: t || (n ? "Try adjusting your search criteria or clear the search filter." : "There are currently no records to display.") }),
|
|
1483
|
+
n && o && /* @__PURE__ */ s(
|
|
1484
|
+
"button",
|
|
1485
|
+
{
|
|
1486
|
+
type: "button",
|
|
1487
|
+
onClick: o,
|
|
1488
|
+
className: "px-4 py-2 rounded-xl bg-primary text-white text-xs font-bold hover:bg-primary-soft transition-all shadow-sm shadow-primary/20 active:scale-95",
|
|
1489
|
+
children: "Clear Search Filter"
|
|
1490
|
+
}
|
|
1491
|
+
)
|
|
1492
|
+
] }), hr = ({ error: e, onRetry: t }) => {
|
|
1493
|
+
const n = typeof e == "string" ? e : e?.message || e?.response?.data?.message || "Failed to load table data.";
|
|
1494
|
+
return /* @__PURE__ */ b("div", { className: "w-full py-14 px-6 flex flex-col items-center justify-center text-center any-table-fade-in", children: [
|
|
1495
|
+
/* @__PURE__ */ s("div", { className: "w-14 h-14 mb-4 rounded-2xl bg-rose-500/10 text-rose-500 flex items-center justify-center text-2xl border border-rose-500/20", children: "⚠️" }),
|
|
1496
|
+
/* @__PURE__ */ s("h3", { className: "text-lg font-bold text-gray-800 dark:text-gray-200 mb-1", children: "Unable to load data" }),
|
|
1497
|
+
/* @__PURE__ */ s("p", { className: "text-xs sm:text-sm text-rose-600 dark:text-rose-400 font-medium max-w-md mb-5 leading-relaxed bg-rose-500/5 px-3 py-1.5 rounded-lg border border-rose-500/10", children: n }),
|
|
1498
|
+
t && /* @__PURE__ */ b(
|
|
1499
|
+
"button",
|
|
1500
|
+
{
|
|
1501
|
+
type: "button",
|
|
1502
|
+
onClick: t,
|
|
1503
|
+
className: "inline-flex items-center gap-2 px-4 py-2 rounded-xl bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-xs font-bold hover:bg-gray-800 dark:hover:bg-gray-100 transition-all shadow-md active:scale-95",
|
|
1504
|
+
children: [
|
|
1505
|
+
/* @__PURE__ */ s("span", { children: "🔄" }),
|
|
1506
|
+
/* @__PURE__ */ s("span", { children: "Retry Request" })
|
|
1507
|
+
]
|
|
1508
|
+
}
|
|
1509
|
+
)
|
|
1510
|
+
] });
|
|
1511
|
+
};
|
|
1512
|
+
function pr(e) {
|
|
1513
|
+
const {
|
|
1514
|
+
data: t,
|
|
1515
|
+
api: n,
|
|
1516
|
+
columns: o,
|
|
1517
|
+
autoColumns: l = !0,
|
|
1518
|
+
rowKey: a,
|
|
1519
|
+
title: i,
|
|
1520
|
+
subtitle: g,
|
|
1521
|
+
actions: c,
|
|
1522
|
+
actionsTitle: d = "Actions",
|
|
1523
|
+
actionsWidth: r,
|
|
1524
|
+
search: m = !0,
|
|
1525
|
+
sorting: u = !0,
|
|
1526
|
+
pagination: f = !0,
|
|
1527
|
+
selectable: p = !1,
|
|
1528
|
+
onSelectionChange: k,
|
|
1529
|
+
onRowClick: E,
|
|
1530
|
+
loading: h,
|
|
1531
|
+
loadingComponent: D,
|
|
1532
|
+
emptyComponent: M,
|
|
1533
|
+
emptyTitle: N,
|
|
1534
|
+
emptyDescription: A,
|
|
1535
|
+
errorComponent: j,
|
|
1536
|
+
className: H = "",
|
|
1537
|
+
tableClassName: W = "",
|
|
1538
|
+
headerActions: te,
|
|
1539
|
+
showHeader: B = !0,
|
|
1540
|
+
bordered: z = !0,
|
|
1541
|
+
striped: R = !1,
|
|
1542
|
+
hoverable: re = !0,
|
|
1543
|
+
stickyHeader: G = !1,
|
|
1544
|
+
tableRef: Y,
|
|
1545
|
+
// Legacy Wasel Props
|
|
1546
|
+
thead: I,
|
|
1547
|
+
headerData: U,
|
|
1548
|
+
tbodys: T,
|
|
1549
|
+
titleHeader: V,
|
|
1550
|
+
add: Pe,
|
|
1551
|
+
linkAdd: Ee,
|
|
1552
|
+
addHandler: $e,
|
|
1553
|
+
view: De,
|
|
1554
|
+
linkView: ae,
|
|
1555
|
+
viewHandler: ne,
|
|
1556
|
+
edit: Me,
|
|
1557
|
+
linkEdit: se,
|
|
1558
|
+
editHandler: oe,
|
|
1559
|
+
del: _e,
|
|
1560
|
+
handleDelete: he,
|
|
1561
|
+
block: Be,
|
|
1562
|
+
handleBlock: pe,
|
|
1563
|
+
buttons: ie
|
|
1564
|
+
} = e, xe = ee(), le = O(() => t || T || void 0, [t, T]), K = O(() => jt({
|
|
1565
|
+
data: le,
|
|
1566
|
+
columns: o,
|
|
1567
|
+
autoColumns: l,
|
|
1568
|
+
thead: I,
|
|
1569
|
+
headerData: U
|
|
1570
|
+
}).filter((y) => typeof y.hidden == "function" ? !y.hidden({ data: le || [] }) : !y.hidden), [le, o, l, I, U]), F = w(
|
|
1571
|
+
(x, y) => {
|
|
1572
|
+
if (typeof a == "function")
|
|
1573
|
+
return a(x, y);
|
|
1574
|
+
if (typeof a == "string") {
|
|
1575
|
+
const $ = S(x, a);
|
|
1576
|
+
if ($ != null) return $;
|
|
1577
|
+
}
|
|
1578
|
+
const P = x?._id ?? x?.id ?? x?.key;
|
|
1579
|
+
return P ?? y;
|
|
1580
|
+
},
|
|
1581
|
+
[a]
|
|
1582
|
+
), {
|
|
1583
|
+
enabled: je,
|
|
1584
|
+
search: ze,
|
|
1585
|
+
debouncedSearch: Le,
|
|
1586
|
+
isDebouncing: qe,
|
|
1587
|
+
setSearch: Oe,
|
|
1588
|
+
clearSearch: ke,
|
|
1589
|
+
searchConfig: Xe
|
|
1590
|
+
} = zt({ config: m }), {
|
|
1591
|
+
enabled: Qe,
|
|
1592
|
+
sortBy: Ne,
|
|
1593
|
+
sortOrder: we,
|
|
1594
|
+
toggleSort: et,
|
|
1595
|
+
setSorting: tt,
|
|
1596
|
+
resetSorting: rt
|
|
1597
|
+
} = Lt({ config: u }), We = O(() => {
|
|
1598
|
+
const x = [...c || []];
|
|
1599
|
+
return ie && Array.isArray(ie) && ie.forEach((y, P) => {
|
|
1600
|
+
x.push({
|
|
1601
|
+
id: `legacy-btn-${P}`,
|
|
1602
|
+
label: y.label,
|
|
1603
|
+
icon: y.icon,
|
|
1604
|
+
className: y.className,
|
|
1605
|
+
show: y.show,
|
|
1606
|
+
hide: y.hide,
|
|
1607
|
+
onClick: ($) => y.onClick($)
|
|
1608
|
+
});
|
|
1609
|
+
}), Be && pe && x.push({
|
|
1610
|
+
id: "legacy-block",
|
|
1611
|
+
label: (y) => y.isBanned || !y.isActive ? "Unblock" : "Block",
|
|
1612
|
+
variant: (y) => y.isBanned || !y.isActive ? "success" : "danger",
|
|
1613
|
+
onClick: (y) => pe(y?._id || y?.id)
|
|
1614
|
+
}), De && (ne || ae) && x.push({
|
|
1615
|
+
id: "legacy-view",
|
|
1616
|
+
label: "View",
|
|
1617
|
+
variant: "primary",
|
|
1618
|
+
onClick: (y) => {
|
|
1619
|
+
const P = y?._id || y?.id;
|
|
1620
|
+
ne ? ne(P) : ae && typeof window < "u" && (window.location.href = `${ae}/${P}`);
|
|
1621
|
+
}
|
|
1622
|
+
}), Me && (oe || se) && x.push({
|
|
1623
|
+
id: "legacy-edit",
|
|
1624
|
+
label: "Edit",
|
|
1625
|
+
variant: "info",
|
|
1626
|
+
onClick: (y) => {
|
|
1627
|
+
const P = y?._id || y?.id;
|
|
1628
|
+
oe ? oe(P) : se && typeof window < "u" && (window.location.href = `${se}/${P}`);
|
|
1629
|
+
}
|
|
1630
|
+
}), _e && he && x.push({
|
|
1631
|
+
id: "legacy-del",
|
|
1632
|
+
label: "Delete",
|
|
1633
|
+
variant: "danger",
|
|
1634
|
+
confirmation: {
|
|
1635
|
+
title: "Delete Item",
|
|
1636
|
+
message: "Are you sure you want to delete this record?"
|
|
1637
|
+
},
|
|
1638
|
+
onClick: (y) => he(y?._id || y?.id)
|
|
1639
|
+
}), x;
|
|
1640
|
+
}, [
|
|
1641
|
+
c,
|
|
1642
|
+
ie,
|
|
1643
|
+
Be,
|
|
1644
|
+
pe,
|
|
1645
|
+
De,
|
|
1646
|
+
ae,
|
|
1647
|
+
ne,
|
|
1648
|
+
Me,
|
|
1649
|
+
se,
|
|
1650
|
+
oe,
|
|
1651
|
+
_e,
|
|
1652
|
+
he
|
|
1653
|
+
]), [at, nt] = v(1), [st, ot] = v(10), {
|
|
1654
|
+
rows: C,
|
|
1655
|
+
totalRecords: ve,
|
|
1656
|
+
loading: de,
|
|
1657
|
+
error: J,
|
|
1658
|
+
refresh: Z,
|
|
1659
|
+
isServerMode: it
|
|
1660
|
+
} = Yt({
|
|
1661
|
+
data: le,
|
|
1662
|
+
api: n,
|
|
1663
|
+
columns: K,
|
|
1664
|
+
searchQuery: Le,
|
|
1665
|
+
sortBy: Ne,
|
|
1666
|
+
sortOrder: we,
|
|
1667
|
+
page: at,
|
|
1668
|
+
pageSize: st,
|
|
1669
|
+
manualLoading: h
|
|
1670
|
+
}), {
|
|
1671
|
+
enabled: lt,
|
|
1672
|
+
page: ce,
|
|
1673
|
+
pageSize: Ae,
|
|
1674
|
+
totalPages: Ie,
|
|
1675
|
+
pageSizeOptions: dt,
|
|
1676
|
+
setPage: ge,
|
|
1677
|
+
setPageSize: Fe,
|
|
1678
|
+
resetPagination: ct,
|
|
1679
|
+
getPageWindow: gt,
|
|
1680
|
+
paginationConfig: He
|
|
1681
|
+
} = Ot({
|
|
1682
|
+
config: f,
|
|
1683
|
+
totalRecords: ve,
|
|
1684
|
+
onPageChange: (x, y) => {
|
|
1685
|
+
nt(x), ot(y);
|
|
1686
|
+
}
|
|
1687
|
+
}), [L, ue] = v(/* @__PURE__ */ new Set()), ut = w(
|
|
1688
|
+
(x, y) => {
|
|
1689
|
+
ue((P) => {
|
|
1690
|
+
const $ = new Set(P);
|
|
1691
|
+
if ($.has(x) ? $.delete(x) : $.add(x), k) {
|
|
1692
|
+
const pt = C.filter((xt, kt) => $.has(F(xt, kt)));
|
|
1693
|
+
k(pt, Array.from($));
|
|
1694
|
+
}
|
|
1695
|
+
return $;
|
|
1696
|
+
});
|
|
1697
|
+
},
|
|
1698
|
+
[C, F, k]
|
|
1699
|
+
), mt = w(() => {
|
|
1700
|
+
if (L.size === C.length && C.length > 0)
|
|
1701
|
+
ue(/* @__PURE__ */ new Set()), k?.([], []);
|
|
1702
|
+
else {
|
|
1703
|
+
const x = new Set(C.map((y, P) => F(y, P)));
|
|
1704
|
+
ue(x), k?.(C, Array.from(x));
|
|
1705
|
+
}
|
|
1706
|
+
}, [C, L.size, F, k]), ft = w(() => {
|
|
1707
|
+
ue(/* @__PURE__ */ new Set()), k?.([], []);
|
|
1708
|
+
}, [k]), bt = C.length > 0 && L.size === C.length, yt = L.size > 0 && L.size < C.length, Ce = O(
|
|
1709
|
+
() => ({
|
|
1710
|
+
refresh: Z,
|
|
1711
|
+
loading: de,
|
|
1712
|
+
page: ce,
|
|
1713
|
+
selectedRows: C.filter((x, y) => L.has(F(x, y))),
|
|
1714
|
+
setPage: ge
|
|
1715
|
+
}),
|
|
1716
|
+
[Z, de, ce, C, L, F, ge]
|
|
1717
|
+
);
|
|
1718
|
+
Vt({
|
|
1719
|
+
tableRef: Y,
|
|
1720
|
+
refresh: Z,
|
|
1721
|
+
resetPagination: ct,
|
|
1722
|
+
resetSearch: ke,
|
|
1723
|
+
resetSorting: rt,
|
|
1724
|
+
setPage: ge,
|
|
1725
|
+
setPageSize: Fe,
|
|
1726
|
+
setSearch: Oe,
|
|
1727
|
+
setSorting: tt,
|
|
1728
|
+
selectedRows: Ce.selectedRows,
|
|
1729
|
+
clearSelection: ft,
|
|
1730
|
+
getState: () => ({
|
|
1731
|
+
data: C,
|
|
1732
|
+
loading: de,
|
|
1733
|
+
error: J,
|
|
1734
|
+
page: ce,
|
|
1735
|
+
pageSize: Ae,
|
|
1736
|
+
total: ve,
|
|
1737
|
+
totalPages: Ie,
|
|
1738
|
+
search: ze,
|
|
1739
|
+
sortBy: Ne,
|
|
1740
|
+
sortOrder: we,
|
|
1741
|
+
selectedRowKeys: Array.from(L),
|
|
1742
|
+
selectedRows: Ce.selectedRows,
|
|
1743
|
+
isServerMode: it
|
|
1744
|
+
})
|
|
1745
|
+
});
|
|
1746
|
+
const q = i || V, me = We.length > 0, ht = !!(q || g || je || te || Pe);
|
|
1747
|
+
return /* @__PURE__ */ b("div", { className: `any-table-wrapper ${xe.classes?.container || "w-full flex flex-col gap-4 font-sans"} ${H}`, children: [
|
|
1748
|
+
ht && /* @__PURE__ */ b("div", { className: "w-full flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-1", children: [
|
|
1749
|
+
(q || g) && /* @__PURE__ */ b("div", { className: "flex flex-col", children: [
|
|
1750
|
+
q && /* @__PURE__ */ b("h2", { className: "text-xl sm:text-2xl font-black text-gray-900 dark:text-white tracking-tight flex items-center gap-2.5", children: [
|
|
1751
|
+
/* @__PURE__ */ s("span", { className: "w-1.5 h-6 bg-primary rounded-full inline-block" }),
|
|
1752
|
+
q
|
|
1753
|
+
] }),
|
|
1754
|
+
g && /* @__PURE__ */ s("p", { className: "text-xs sm:text-sm text-gray-500 dark:text-gray-400 font-medium mt-0.5 pl-4", children: g })
|
|
1755
|
+
] }),
|
|
1756
|
+
/* @__PURE__ */ b("div", { className: "flex flex-wrap items-center gap-3 w-full sm:w-auto justify-start sm:justify-end ml-auto", children: [
|
|
1757
|
+
je && /* @__PURE__ */ s(
|
|
1758
|
+
qt,
|
|
1759
|
+
{
|
|
1760
|
+
value: ze,
|
|
1761
|
+
onChange: Oe,
|
|
1762
|
+
onClear: ke,
|
|
1763
|
+
isDebouncing: qe,
|
|
1764
|
+
placeholder: Xe.placeholder
|
|
1765
|
+
}
|
|
1766
|
+
),
|
|
1767
|
+
te,
|
|
1768
|
+
Pe && /* @__PURE__ */ b(
|
|
1769
|
+
"button",
|
|
1770
|
+
{
|
|
1771
|
+
type: "button",
|
|
1772
|
+
onClick: () => {
|
|
1773
|
+
$e ? $e() : Ee && typeof window < "u" && (window.location.href = Ee);
|
|
1774
|
+
},
|
|
1775
|
+
className: "inline-flex items-center gap-2 px-4 py-2.5 rounded-xl bg-primary text-white text-xs sm:text-sm font-bold hover:bg-primary-soft transition-all shadow-sm shadow-primary/20 active:scale-95 whitespace-nowrap",
|
|
1776
|
+
children: [
|
|
1777
|
+
/* @__PURE__ */ s("span", { children: "+" }),
|
|
1778
|
+
/* @__PURE__ */ b("span", { children: [
|
|
1779
|
+
"Add ",
|
|
1780
|
+
q || "Record"
|
|
1781
|
+
] })
|
|
1782
|
+
]
|
|
1783
|
+
}
|
|
1784
|
+
)
|
|
1785
|
+
] })
|
|
1786
|
+
] }),
|
|
1787
|
+
/* @__PURE__ */ s(
|
|
1788
|
+
"div",
|
|
1789
|
+
{
|
|
1790
|
+
className: `${xe.classes?.tableWrapper || "w-full overflow-x-auto rounded-2xl border bg-white dark:bg-slate-900"} ${z ? "border border-gray-200 dark:border-gray-800" : ""}`,
|
|
1791
|
+
children: J ? typeof j == "function" ? j(J, Z) : j || /* @__PURE__ */ s(hr, { error: J, onRetry: Z }) : /* @__PURE__ */ b(
|
|
1792
|
+
"table",
|
|
1793
|
+
{
|
|
1794
|
+
className: `${xe.classes?.table || "w-full border-collapse text-left text-sm"} ${G ? "relative" : ""} ${W}`,
|
|
1795
|
+
children: [
|
|
1796
|
+
B && /* @__PURE__ */ s(
|
|
1797
|
+
Xt,
|
|
1798
|
+
{
|
|
1799
|
+
columns: K,
|
|
1800
|
+
hasActions: me,
|
|
1801
|
+
actionsTitle: d,
|
|
1802
|
+
actionsWidth: r,
|
|
1803
|
+
sortBy: Ne,
|
|
1804
|
+
sortOrder: we,
|
|
1805
|
+
onSort: Qe ? et : void 0,
|
|
1806
|
+
selectable: p,
|
|
1807
|
+
allSelected: bt,
|
|
1808
|
+
isIndeterminate: yt,
|
|
1809
|
+
onToggleSelectAll: mt
|
|
1810
|
+
}
|
|
1811
|
+
),
|
|
1812
|
+
de && C.length === 0 ? D ? /* @__PURE__ */ s("tbody", { children: /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: K.length + (p ? 1 : 0) + (me ? 1 : 0), children: D }) }) }) : /* @__PURE__ */ s(
|
|
1813
|
+
br,
|
|
1814
|
+
{
|
|
1815
|
+
columnsCount: K.length + (p ? 1 : 0),
|
|
1816
|
+
rowsCount: Ae || 5,
|
|
1817
|
+
hasActions: me
|
|
1818
|
+
}
|
|
1819
|
+
) : C.length === 0 ? (
|
|
1820
|
+
/* Empty State */
|
|
1821
|
+
/* @__PURE__ */ s("tbody", { children: /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
|
|
1822
|
+
"td",
|
|
1823
|
+
{
|
|
1824
|
+
colSpan: K.length + (p ? 1 : 0) + (me ? 1 : 0),
|
|
1825
|
+
className: "p-0",
|
|
1826
|
+
children: M || /* @__PURE__ */ s(
|
|
1827
|
+
yr,
|
|
1828
|
+
{
|
|
1829
|
+
title: N,
|
|
1830
|
+
description: A,
|
|
1831
|
+
isSearchActive: !!Le,
|
|
1832
|
+
onClearSearch: ke
|
|
1833
|
+
}
|
|
1834
|
+
)
|
|
1835
|
+
}
|
|
1836
|
+
) }) })
|
|
1837
|
+
) : (
|
|
1838
|
+
/* Body Rows */
|
|
1839
|
+
/* @__PURE__ */ s(
|
|
1840
|
+
mr,
|
|
1841
|
+
{
|
|
1842
|
+
rows: C,
|
|
1843
|
+
columns: K,
|
|
1844
|
+
actions: We,
|
|
1845
|
+
actionContext: Ce,
|
|
1846
|
+
rowKeyResolver: F,
|
|
1847
|
+
selectable: p,
|
|
1848
|
+
selectedKeys: L,
|
|
1849
|
+
onToggleSelectRow: ut,
|
|
1850
|
+
onRowClick: E,
|
|
1851
|
+
striped: R,
|
|
1852
|
+
hoverable: re
|
|
1853
|
+
}
|
|
1854
|
+
)
|
|
1855
|
+
)
|
|
1856
|
+
]
|
|
1857
|
+
}
|
|
1858
|
+
)
|
|
1859
|
+
}
|
|
1860
|
+
),
|
|
1861
|
+
lt && !J && /* @__PURE__ */ s(
|
|
1862
|
+
fr,
|
|
1863
|
+
{
|
|
1864
|
+
page: ce,
|
|
1865
|
+
pageSize: Ae,
|
|
1866
|
+
totalRecords: ve,
|
|
1867
|
+
totalPages: Ie,
|
|
1868
|
+
pageSizeOptions: dt,
|
|
1869
|
+
onPageChange: ge,
|
|
1870
|
+
onPageSizeChange: Fe,
|
|
1871
|
+
showPageSizeSelector: He.showPageSizeSelector,
|
|
1872
|
+
showTotalCount: He.showTotalCount,
|
|
1873
|
+
pageWindow: gt(5)
|
|
1874
|
+
}
|
|
1875
|
+
)
|
|
1876
|
+
] });
|
|
1877
|
+
}
|
|
1878
|
+
function Nr(e) {
|
|
1879
|
+
return /* @__PURE__ */ s(Zt, { theme: e.theme, children: /* @__PURE__ */ s(pr, { ...e }) });
|
|
1880
|
+
}
|
|
1881
|
+
export {
|
|
1882
|
+
ur as ActionRenderer,
|
|
1883
|
+
Nr as AnyTable,
|
|
1884
|
+
pr as AnyTableInner,
|
|
1885
|
+
Zt as AnyTableThemeProvider,
|
|
1886
|
+
sr as ArrayRenderer,
|
|
1887
|
+
er as BooleanRenderer,
|
|
1888
|
+
cr as CellRenderer,
|
|
1889
|
+
gr as ConfirmModal,
|
|
1890
|
+
tr as CurrencyRenderer,
|
|
1891
|
+
Jt as DEFAULT_THEME_COLORS,
|
|
1892
|
+
Ke as DateRenderer,
|
|
1893
|
+
lr as EmailRenderer,
|
|
1894
|
+
_ as FallbackPlaceholder,
|
|
1895
|
+
rr as ImageRenderer,
|
|
1896
|
+
Qt as NumberRenderer,
|
|
1897
|
+
or as ObjectRenderer,
|
|
1898
|
+
dr as PhoneRenderer,
|
|
1899
|
+
nr as StatusRenderer,
|
|
1900
|
+
Ze as StringRenderer,
|
|
1901
|
+
mr as TableBody,
|
|
1902
|
+
yr as TableEmptyState,
|
|
1903
|
+
hr as TableErrorState,
|
|
1904
|
+
Xt as TableHeader,
|
|
1905
|
+
fr as TablePagination,
|
|
1906
|
+
qt as TableSearch,
|
|
1907
|
+
br as TableSkeleton,
|
|
1908
|
+
ir as UrlRenderer,
|
|
1909
|
+
Nr as default,
|
|
1910
|
+
Q as defaultAnyTableTheme,
|
|
1911
|
+
X as extractPaginationMeta,
|
|
1912
|
+
Kt as filterRowsBySearch,
|
|
1913
|
+
_t as generateAutoColumns,
|
|
1914
|
+
S as getNestedValue,
|
|
1915
|
+
be as inferColumnType,
|
|
1916
|
+
Re as isImageUrl,
|
|
1917
|
+
Dt as isIsoDate,
|
|
1918
|
+
St as isPlainObject,
|
|
1919
|
+
Ut as normalizeApiResponse,
|
|
1920
|
+
jt as resolveColumns,
|
|
1921
|
+
Gt as sortRows,
|
|
1922
|
+
fe as toTitleCase,
|
|
1923
|
+
Vt as useAnyTableController,
|
|
1924
|
+
Yt as useAnyTableData,
|
|
1925
|
+
Ot as useAnyTablePagination,
|
|
1926
|
+
zt as useAnyTableSearch,
|
|
1927
|
+
Lt as useAnyTableSorting,
|
|
1928
|
+
ee as useAnyTableTheme
|
|
1929
|
+
};
|
|
1930
|
+
//# sourceMappingURL=index.js.map
|