@krosoft/react 0.0.165 → 0.0.166

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.
@@ -0,0 +1,543 @@
1
+ import { jsxs as i, jsx as e, Fragment as ne } from "react/jsx-runtime";
2
+ import { u as le } from "./useDataTable-CxcA5S-s.js";
3
+ import { ay as B, aM as L, aA as V, aC as de, $ as O, az as ce } from "./toggle-group-DY9wl0HW.js";
4
+ import "./alert-B78CiTYe.js";
5
+ import "@radix-ui/react-aspect-ratio";
6
+ import { B as v } from "./tooltip-BWyFpIxo.js";
7
+ import "@radix-ui/react-collapsible";
8
+ import "./sheet-Gop1cIaU.js";
9
+ import { MoreVerticalIcon as oe, Loader2Icon as he, AlertTriangleIcon as me, GripVerticalIcon as ge, ArrowUpIcon as ue, ArrowDownIcon as fe, ArrowUpDownIcon as pe, ChevronLeftIcon as xe, ChevronRightIcon as ye, SettingsIcon as ve } from "lucide-react";
10
+ import "react-resizable-panels";
11
+ import "clsx";
12
+ import "tailwind-merge";
13
+ import { S as be, h as Ne, i as ke, a as Se, c as we } from "./select-MWzbMBAS.js";
14
+ import "next-themes";
15
+ import "sonner";
16
+ import "react";
17
+ const H = [5, 10, 30, 50, 100], Ce = H[1];
18
+ function ze({ actions: n, row: t }) {
19
+ const a = n.filter((r) => r.visible === void 0 || r.visible(t));
20
+ if (a.length === 0)
21
+ return null;
22
+ const d = a.filter((r) => r.overflow !== !0), g = a.filter((r) => r.overflow === !0);
23
+ return /* @__PURE__ */ i("div", { className: "flex items-center justify-center gap-1", children: [
24
+ d.map((r, c) => {
25
+ var o;
26
+ const m = r.icon;
27
+ return /* @__PURE__ */ i(
28
+ v,
29
+ {
30
+ variant: r.variant ?? "ghost",
31
+ size: "sm",
32
+ disabled: ((o = r.disabled) == null ? void 0 : o.call(r, t)) ?? !1,
33
+ className: `h-7 px-2 text-muted-foreground hover:text-foreground ${r.className ?? ""}`,
34
+ onClick: (x) => {
35
+ x.stopPropagation(), r.onClick(t);
36
+ },
37
+ children: [
38
+ m !== void 0 && /* @__PURE__ */ e(m, { className: "size-3.5" }),
39
+ r.label
40
+ ]
41
+ },
42
+ c
43
+ );
44
+ }),
45
+ g.length > 0 && /* @__PURE__ */ i(B, { children: [
46
+ /* @__PURE__ */ e(L, { asChild: !0, children: /* @__PURE__ */ e(v, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ e(oe, { className: "size-3.5" }) }) }),
47
+ /* @__PURE__ */ e(
48
+ V,
49
+ {
50
+ align: "end",
51
+ onClick: (r) => {
52
+ r.stopPropagation();
53
+ },
54
+ children: g.map((r, c) => {
55
+ var o;
56
+ const m = r.icon;
57
+ return /* @__PURE__ */ i(
58
+ de,
59
+ {
60
+ disabled: ((o = r.disabled) == null ? void 0 : o.call(r, t)) ?? !1,
61
+ onClick: () => {
62
+ r.onClick(t);
63
+ },
64
+ className: r.className,
65
+ children: [
66
+ m !== void 0 && /* @__PURE__ */ e("span", { className: "mr-2 size-4 flex items-center justify-center", children: /* @__PURE__ */ e(m, { className: "size-4" }) }),
67
+ r.label
68
+ ]
69
+ },
70
+ c
71
+ );
72
+ })
73
+ }
74
+ )
75
+ ] })
76
+ ] });
77
+ }
78
+ function De({
79
+ isLoading: n,
80
+ error: t,
81
+ colSpanCount: a,
82
+ noDataMessage: d,
83
+ paginatedData: g,
84
+ getRowId: r,
85
+ onRowClick: c,
86
+ hasBulkActions: m,
87
+ selectedRows: o,
88
+ toggleRowSelection: x,
89
+ visibleColumnsArray: l,
90
+ columnWidths: y,
91
+ hasActions: C,
92
+ actions: b,
93
+ columns: z,
94
+ bordered: k = !1,
95
+ resizableColumns: S = !1
96
+ }) {
97
+ const D = (u, p) => {
98
+ const h = z.find((N) => N.key === p);
99
+ if ((h == null ? void 0 : h.renderCell) !== void 0)
100
+ return h.renderCell(u);
101
+ const s = u[p];
102
+ return /* @__PURE__ */ e("span", { className: "text-sm truncate", children: s != null ? String(s) : "-" });
103
+ };
104
+ return n ? /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-200 dark:divide-gray-800", children: /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: a, className: "py-8 text-center", children: /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center gap-2 text-muted-foreground", children: [
105
+ /* @__PURE__ */ e(he, { className: "h-6 w-6 animate-spin text-primary" }),
106
+ /* @__PURE__ */ e("span", { className: "text-sm", children: "Chargement..." })
107
+ ] }) }) }) }) : t ? /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-200 dark:divide-gray-800", children: /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: a, className: "py-8 text-center", children: /* @__PURE__ */ i("div", { className: "flex flex-col items-center justify-center gap-2 text-destructive", children: [
108
+ /* @__PURE__ */ e(me, { className: "h-6 w-6" }),
109
+ /* @__PURE__ */ e("span", { className: "text-sm", children: t })
110
+ ] }) }) }) }) : g.length === 0 ? /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-200 dark:divide-gray-800", children: /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: a, className: "py-8 text-center text-sm text-muted-foreground", children: d }) }) }) : /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-200 dark:divide-gray-800", children: g.map((u) => {
111
+ const p = r(u);
112
+ return /* @__PURE__ */ i(
113
+ "tr",
114
+ {
115
+ className: `group hover:bg-muted/50 dark:hover:bg-gray-900/50 transition-colors ${c !== void 0 ? "cursor-pointer" : ""}`,
116
+ onClick: (h) => c == null ? void 0 : c(u, h),
117
+ children: [
118
+ m ? /* @__PURE__ */ e(
119
+ "td",
120
+ {
121
+ className: "p-1 text-center align-middle",
122
+ style: { width: "32px", minWidth: "32px", maxWidth: "32px" },
123
+ onClick: (h) => {
124
+ h.stopPropagation();
125
+ },
126
+ children: /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e(
127
+ O,
128
+ {
129
+ checked: o.includes(p),
130
+ onCheckedChange: () => {
131
+ x(p);
132
+ }
133
+ }
134
+ ) })
135
+ }
136
+ ) : null,
137
+ l.map((h, s) => {
138
+ const N = s === l.length - 1;
139
+ return /* @__PURE__ */ e(
140
+ "td",
141
+ {
142
+ className: `px-2 py-2 relative ${k && !N ? "border-r border-gray-100 dark:border-gray-800" : ""} ${h.className ?? ""}`,
143
+ style: S ? { width: y[h.key] } : { minWidth: y[h.key] },
144
+ children: /* @__PURE__ */ e("div", { className: "w-full h-full", children: D(u, h.key) })
145
+ },
146
+ h.key
147
+ );
148
+ }),
149
+ C ? /* @__PURE__ */ e(
150
+ "td",
151
+ {
152
+ className: "p-1 text-center align-middle whitespace-nowrap",
153
+ style: { minWidth: "32px" },
154
+ onClick: (h) => {
155
+ h.stopPropagation();
156
+ },
157
+ children: b !== void 0 && b.length > 0 ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e(ze, { actions: b, row: u }) }) : null
158
+ }
159
+ ) : null
160
+ ]
161
+ },
162
+ p
163
+ );
164
+ }) });
165
+ }
166
+ function Ie({ selectedRows: n, setSelectedRows: t, bulkActions: a }) {
167
+ return /* @__PURE__ */ i("div", { className: "bg-muted/60 dark:bg-gray-900/60 border border-border px-3 py-1.5 flex items-center justify-between rounded-lg", children: [
168
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-4", children: [
169
+ /* @__PURE__ */ i("span", { className: "text-sm font-medium text-primary ml-1", children: [
170
+ n.length,
171
+ " sélectionné(s)"
172
+ ] }),
173
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: a.map((d, g) => {
174
+ const r = d.icon;
175
+ return /* @__PURE__ */ i(
176
+ v,
177
+ {
178
+ variant: "outline",
179
+ size: "sm",
180
+ onClick: () => {
181
+ d.onClick(n, () => {
182
+ t([]);
183
+ });
184
+ },
185
+ className: `h-7 bg-background shadow-sm text-xs px-2.5 ${d.variant === "destructive" ? "text-destructive border-destructive/30 hover:bg-destructive/10 hover:text-destructive" : "text-foreground"}`,
186
+ children: [
187
+ r !== void 0 && /* @__PURE__ */ e("span", { className: "mr-1.5 flex items-center justify-center", children: /* @__PURE__ */ e(r, { className: "h-3.5 w-3.5" }) }),
188
+ d.label
189
+ ]
190
+ },
191
+ g
192
+ );
193
+ }) })
194
+ ] }),
195
+ /* @__PURE__ */ e(
196
+ v,
197
+ {
198
+ variant: "ghost",
199
+ size: "sm",
200
+ onClick: () => {
201
+ t([]);
202
+ },
203
+ className: "text-xs text-muted-foreground hover:text-foreground h-7 px-2",
204
+ children: "Désélectionner"
205
+ }
206
+ )
207
+ ] });
208
+ }
209
+ function je({
210
+ hasBulkActions: n,
211
+ selectedRows: t,
212
+ totalItems: a,
213
+ toggleSelectAll: d,
214
+ visibleColumnsArray: g,
215
+ draggableColumns: r,
216
+ resizableColumns: c,
217
+ columnWidths: m,
218
+ sortColumn: o,
219
+ sortDirection: x,
220
+ handleSort: l,
221
+ handleDragStart: y,
222
+ handleDragOver: C,
223
+ handleDrop: b,
224
+ handleMouseDown: z,
225
+ hasActions: k,
226
+ settingsNode: S,
227
+ bordered: D = !1
228
+ }) {
229
+ let u = !1;
230
+ t.length === a && a > 0 ? u = !0 : t.length > 0 && (u = "indeterminate");
231
+ const p = (s) => s.sortable !== !0 ? null : o === s.key ? x === "asc" ? /* @__PURE__ */ e(ue, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ e(fe, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ e(pe, { className: "size-3.5 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors" }), h = (s, N) => {
232
+ const I = N !== !1, A = s.sortable === !0;
233
+ return /* @__PURE__ */ i(
234
+ "th",
235
+ {
236
+ className: [
237
+ "px-2 py-2 text-left text-sm font-medium text-gray-900 dark:text-gray-100 relative group",
238
+ D ? "border-r border-gray-200 dark:border-gray-800" : "",
239
+ A ? "cursor-pointer select-none" : "",
240
+ s.className ?? ""
241
+ ].filter(Boolean).join(" "),
242
+ style: c ? { width: m[s.key] } : { minWidth: m[s.key] },
243
+ draggable: I,
244
+ onClick: () => {
245
+ l(s.key);
246
+ },
247
+ onDragStart: (f) => {
248
+ I ? y(f, s.key) : f.preventDefault();
249
+ },
250
+ onDragOver: (f) => {
251
+ C(f, s.key);
252
+ },
253
+ onDrop: (f) => {
254
+ b(f, s.key);
255
+ },
256
+ children: [
257
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between pr-2", children: [
258
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
259
+ I ? /* @__PURE__ */ e(ge, { className: "size-4 text-gray-400 cursor-grab dark:text-gray-300 shrink-0" }) : null,
260
+ /* @__PURE__ */ e("span", { className: "truncate", children: s.label })
261
+ ] }),
262
+ /* @__PURE__ */ e("div", { className: "ml-1 shrink-0", children: p(s) })
263
+ ] }),
264
+ c ? /* @__PURE__ */ e(
265
+ "div",
266
+ {
267
+ className: "absolute right-0 top-0 bottom-0 w-2 cursor-col-resize hover:bg-blue-500 opacity-0 group-hover:opacity-50 transition-opacity",
268
+ onMouseDown: (f) => {
269
+ z(f, s.key);
270
+ }
271
+ }
272
+ ) : null
273
+ ]
274
+ },
275
+ s.key
276
+ );
277
+ };
278
+ return /* @__PURE__ */ e("thead", { className: "bg-muted/50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-800", children: /* @__PURE__ */ i("tr", { children: [
279
+ n ? /* @__PURE__ */ e("th", { className: "p-1 flex-shrink-0 text-center align-middle", style: { width: "32px", minWidth: "32px", maxWidth: "32px" }, children: /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e(O, { checked: u, onCheckedChange: d }) }) }) : null,
280
+ g.map((s) => h(s, r)),
281
+ k || S !== void 0 ? /* @__PURE__ */ e("th", { className: "p-1 text-center align-middle", style: { minWidth: "32px" }, children: S }) : null
282
+ ] }) });
283
+ }
284
+ const w = "…";
285
+ function j(n, t) {
286
+ return Array.from({ length: t - n + 1 }, (a, d) => n + d);
287
+ }
288
+ function Ae(n, t, a = 1) {
289
+ if (a * 2 + 5 >= t)
290
+ return j(1, t);
291
+ const g = Math.max(n - a, 1), r = Math.min(n + a, t), c = g > 2, m = r < t - 1;
292
+ if (!c && m)
293
+ return [...j(1, a + 2), w, t];
294
+ if (c && !m) {
295
+ const o = j(t - (a + 2) + 1, t);
296
+ return [1, w, ...o];
297
+ }
298
+ return [1, w, ...j(g, r), w, t];
299
+ }
300
+ function Me({
301
+ totalItems: n,
302
+ startIndex: t,
303
+ endIndex: a,
304
+ pageSize: d,
305
+ setPageSize: g,
306
+ currentPage: r,
307
+ setCurrentPage: c,
308
+ pageSizeOptions: m,
309
+ totalPages: o
310
+ }) {
311
+ const x = Ae(r, o);
312
+ return /* @__PURE__ */ i("div", { className: "px-4 py-2 border-t border-gray-200 dark:border-gray-800 flex flex-col sm:grid sm:grid-cols-3 items-center gap-2 bg-muted/50 dark:bg-gray-900/50", children: [
313
+ /* @__PURE__ */ i("div", { className: "text-sm text-muted-foreground justify-self-start", children: [
314
+ n === 0 ? "0" : `${String(t + 1)} - ${String(a)}`,
315
+ " sur ",
316
+ n
317
+ ] }),
318
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-center gap-1", children: o > 1 && /* @__PURE__ */ i(ne, { children: [
319
+ /* @__PURE__ */ e(
320
+ v,
321
+ {
322
+ variant: "ghost",
323
+ size: "icon",
324
+ className: "h-8 w-8 rounded-full",
325
+ onClick: () => {
326
+ c((l) => Math.max(1, l - 1));
327
+ },
328
+ disabled: r === 1,
329
+ "aria-label": "Page précédente",
330
+ children: /* @__PURE__ */ e(xe, { className: "size-4" })
331
+ }
332
+ ),
333
+ x.map(
334
+ (l, y) => l === w ? /* @__PURE__ */ e("span", { className: "flex h-8 w-8 items-center justify-center text-sm text-muted-foreground", children: w }, `dots-${String(y)}`) : /* @__PURE__ */ e(
335
+ v,
336
+ {
337
+ variant: l === r ? "default" : "ghost",
338
+ size: "icon",
339
+ className: "h-8 w-8 rounded-full text-sm",
340
+ onClick: () => {
341
+ c(l);
342
+ },
343
+ "aria-current": l === r ? "page" : void 0,
344
+ children: l
345
+ },
346
+ l
347
+ )
348
+ ),
349
+ /* @__PURE__ */ e(
350
+ v,
351
+ {
352
+ variant: "ghost",
353
+ size: "icon",
354
+ className: "h-8 w-8 rounded-full",
355
+ onClick: () => {
356
+ c((l) => Math.min(o, l + 1));
357
+ },
358
+ disabled: r === o,
359
+ "aria-label": "Page suivante",
360
+ children: /* @__PURE__ */ e(ye, { className: "size-4" })
361
+ }
362
+ )
363
+ ] }) }),
364
+ /* @__PURE__ */ e("div", { className: "justify-self-end", children: /* @__PURE__ */ i(
365
+ be,
366
+ {
367
+ value: String(d),
368
+ onValueChange: (l) => {
369
+ g(Number(l)), c(1);
370
+ },
371
+ children: [
372
+ /* @__PURE__ */ e(Ne, { className: "h-8 w-[110px] text-sm", children: /* @__PURE__ */ e(ke, {}) }),
373
+ /* @__PURE__ */ e(Se, { children: m.map((l) => /* @__PURE__ */ i(we, { value: String(l), children: [
374
+ l,
375
+ " / page"
376
+ ] }, l)) })
377
+ ]
378
+ }
379
+ ) })
380
+ ] });
381
+ }
382
+ function Te({ columns: n, visibleColumns: t, toggleColumnVisibility: a }) {
383
+ return /* @__PURE__ */ i(B, { children: [
384
+ /* @__PURE__ */ e(L, { asChild: !0, children: /* @__PURE__ */ e(v, { variant: "outline", size: "sm", className: "size-7 p-0 bg-white hover:bg-gray-100 dark:bg-gray-900 shadow-sm border-gray-200 dark:border-gray-800", children: /* @__PURE__ */ e(ve, { className: "size-3.5 text-gray-600 dark:text-gray-300" }) }) }),
385
+ /* @__PURE__ */ e(V, { align: "end", className: "w-56", children: n.map((d) => /* @__PURE__ */ e(
386
+ ce,
387
+ {
388
+ checked: t.has(d.key),
389
+ onCheckedChange: () => {
390
+ a(d.key);
391
+ },
392
+ children: d.label
393
+ },
394
+ d.key
395
+ )) })
396
+ ] });
397
+ }
398
+ function Qe({
399
+ data: n,
400
+ columns: t,
401
+ getRowId: a,
402
+ onRowClick: d,
403
+ actions: g,
404
+ bulkActions: r,
405
+ draggableColumns: c = !1,
406
+ resizableColumns: m = !1,
407
+ columnVisibility: o = !1,
408
+ isLoading: x = !1,
409
+ error: l = null,
410
+ bordered: y = !1,
411
+ noDataMessage: C = "Aucun résultat",
412
+ defaultPageSize: b = Ce,
413
+ pageSizeOptions: z = H,
414
+ totalRows: k,
415
+ currentPage: S,
416
+ pageSize: D,
417
+ onPageChange: u,
418
+ onPageSizeChange: p,
419
+ sortColumn: h,
420
+ sortDirection: s,
421
+ onSortChange: N
422
+ }) {
423
+ const {
424
+ sortColumn: I,
425
+ sortDirection: A,
426
+ selectedRows: f,
427
+ setSelectedRows: U,
428
+ visibleColumns: F,
429
+ columnWidths: M,
430
+ safeCurrentPage: G,
431
+ totalPages: R,
432
+ startIndex: _,
433
+ endIndex: q,
434
+ tableRef: E,
435
+ hasActions: T,
436
+ hasBulkActions: $,
437
+ visibleColumnsArray: W,
438
+ colSpanCount: J,
439
+ paginatedData: P,
440
+ handleSort: Q,
441
+ handleMouseDown: X,
442
+ handleDragStart: Y,
443
+ handleDragOver: Z,
444
+ handleDrop: K,
445
+ toggleColumnVisibility: ee,
446
+ toggleRowSelection: re,
447
+ toggleSelectAll: te,
448
+ pageSize: ae,
449
+ setPageSize: se,
450
+ setCurrentPage: ie
451
+ } = le({
452
+ data: n,
453
+ columns: t,
454
+ getRowId: a,
455
+ defaultPageSize: b,
456
+ actions: g,
457
+ bulkActions: r,
458
+ columnVisibility: o,
459
+ totalRows: k,
460
+ currentPage: S,
461
+ pageSize: D,
462
+ onPageChange: u,
463
+ onPageSizeChange: p,
464
+ sortColumn: h,
465
+ sortDirection: s,
466
+ onSortChange: N
467
+ });
468
+ return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
469
+ f.length > 0 && r !== void 0 && r.length > 0 && /* @__PURE__ */ e(Ie, { selectedRows: f, setSelectedRows: U, bulkActions: r }),
470
+ /* @__PURE__ */ i("div", { className: "w-full bg-card dark:bg-gray-950 rounded-md border border-gray-200 dark:border-gray-800 overflow-hidden", children: [
471
+ /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ i("table", { ref: E, className: "w-full", children: [
472
+ /* @__PURE__ */ e(
473
+ je,
474
+ {
475
+ hasBulkActions: $,
476
+ selectedRows: f,
477
+ totalItems: n.length,
478
+ toggleSelectAll: te,
479
+ visibleColumnsArray: W,
480
+ draggableColumns: c,
481
+ resizableColumns: m,
482
+ columnWidths: M,
483
+ sortColumn: I,
484
+ sortDirection: A,
485
+ handleSort: Q,
486
+ handleDragStart: Y,
487
+ handleDragOver: Z,
488
+ handleDrop: K,
489
+ handleMouseDown: X,
490
+ hasActions: T,
491
+ bordered: y,
492
+ settingsNode: o ? /* @__PURE__ */ e(Te, { columns: t, visibleColumns: F, toggleColumnVisibility: ee }) : void 0
493
+ }
494
+ ),
495
+ /* @__PURE__ */ e(
496
+ De,
497
+ {
498
+ bordered: y,
499
+ isLoading: x,
500
+ error: l,
501
+ colSpanCount: J,
502
+ noDataMessage: C,
503
+ paginatedData: P,
504
+ getRowId: a,
505
+ onRowClick: d,
506
+ hasBulkActions: $,
507
+ selectedRows: f,
508
+ toggleRowSelection: re,
509
+ visibleColumnsArray: W,
510
+ columnWidths: M,
511
+ hasActions: T || o,
512
+ actions: g,
513
+ columns: t,
514
+ resizableColumns: m
515
+ }
516
+ )
517
+ ] }) }),
518
+ /* @__PURE__ */ e(
519
+ Me,
520
+ {
521
+ totalItems: k ?? n.length,
522
+ startIndex: _,
523
+ endIndex: q,
524
+ pageSize: ae,
525
+ setPageSize: se,
526
+ currentPage: G,
527
+ setCurrentPage: ie,
528
+ pageSizeOptions: z,
529
+ totalPages: R
530
+ }
531
+ )
532
+ ] })
533
+ ] });
534
+ }
535
+ export {
536
+ Qe as D,
537
+ ze as T,
538
+ De as a,
539
+ Ie as b,
540
+ je as c,
541
+ Me as d,
542
+ Te as e
543
+ };
@@ -15,7 +15,7 @@ import { S as _, a as $, b as aa, T as ea } from "../../Topbar-DMyjbOTI.js";
15
15
  import { E as oa } from "../../ErrorAlert-DH1onuyt.js";
16
16
  import { E as ta } from "../../ErrorState-vU8d4CwD.js";
17
17
  import { L as la } from "../../LoadingState-BN0YaPSs.js";
18
- import { D as ba, T as ma, a as da, b as ga, c as fa, d as Aa, e as Da } from "../../DataTable-BtmAMrZg.js";
18
+ import { D as ba, T as ma, a as da, b as ga, c as fa, d as Aa, e as Da } from "../../DataTable-28eGRJvy.js";
19
19
  import { A as na, a as ca, b as xa, c as Sa } from "../../AppVerticalTabs-DujFNh9f.js";
20
20
  import { T as Fa } from "../../ThemeSelector-CQ3fSDJ2.js";
21
21
  export {
@@ -12,6 +12,7 @@ export interface DataTableProps<T> {
12
12
  resizableColumns?: boolean;
13
13
  columnVisibility?: boolean;
14
14
  isLoading?: boolean;
15
+ error?: string | null;
15
16
  noDataMessage?: string;
16
17
  bordered?: boolean;
17
18
  defaultPageSize?: number;
@@ -25,5 +26,5 @@ export interface DataTableProps<T> {
25
26
  sortDirection?: "asc" | "desc";
26
27
  onSortChange?: (column: string | null, direction: "asc" | "desc") => void;
27
28
  }
28
- export declare function DataTable<T>({ data, columns, getRowId, onRowClick, actions, bulkActions, draggableColumns, resizableColumns, columnVisibility, isLoading, bordered, noDataMessage, defaultPageSize, pageSizeOptions, totalRows, currentPage, pageSize: controlledPageSize, onPageChange, onPageSizeChange, sortColumn: controlledSortColumn, sortDirection: controlledSortDirection, onSortChange, }: DataTableProps<T>): React.JSX.Element;
29
+ export declare function DataTable<T>({ data, columns, getRowId, onRowClick, actions, bulkActions, draggableColumns, resizableColumns, columnVisibility, isLoading, error, bordered, noDataMessage, defaultPageSize, pageSizeOptions, totalRows, currentPage, pageSize: controlledPageSize, onPageChange, onPageSizeChange, sortColumn: controlledSortColumn, sortDirection: controlledSortDirection, onSortChange, }: DataTableProps<T>): React.JSX.Element;
29
30
  //# sourceMappingURL=DataTable.d.ts.map
@@ -1 +1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AE,kBAAkB,EAC5B,YAAY,EACZ,gBAAgB,EAChB,UAAU,EAAE,oBAAoB,EAChC,aAAa,EAAE,uBAAuB,EACtC,YAAY,GACb,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAoHvC"}
@@ -3,6 +3,7 @@ import { ColumnDef, RowAction } from "@/types";
3
3
  export type { BulkAction, ColumnDef, RowAction } from "../../../types";
4
4
  export interface TableBodyProps<T> {
5
5
  isLoading: boolean;
6
+ error?: string | null;
6
7
  colSpanCount: number;
7
8
  noDataMessage: string;
8
9
  paginatedData: T[];
@@ -19,5 +20,5 @@ export interface TableBodyProps<T> {
19
20
  bordered?: boolean;
20
21
  resizableColumns?: boolean;
21
22
  }
22
- export declare function TableBody<T>({ isLoading, colSpanCount, noDataMessage, paginatedData, getRowId, onRowClick, hasBulkActions, selectedRows, toggleRowSelection, visibleColumnsArray, columnWidths, hasActions, actions, columns, bordered, resizableColumns, }: TableBodyProps<T>): React.JSX.Element;
23
+ export declare function TableBody<T>({ isLoading, error, colSpanCount, noDataMessage, paginatedData, getRowId, onRowClick, hasBulkActions, selectedRows, toggleRowSelection, visibleColumnsArray, columnWidths, hasActions, actions, columns, bordered, resizableColumns, }: TableBodyProps<T>): React.JSX.Element;
23
24
  //# sourceMappingURL=TableBody.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableBody.d.ts","sourceRoot":"","sources":["../../../../src/components/core/table/TableBody.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;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 -1 +1 @@
1
- {"version":3,"file":"TablePagination.d.ts","sourceRoot":"","sources":["../../../../src/components/core/table/TablePagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,EACf,UAAU,GACX,EAAE,oBAAoB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAsD1C"}
1
+ {"version":3,"file":"TablePagination.d.ts","sourceRoot":"","sources":["../../../../src/components/core/table/TablePagination.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB;AAoCD,wBAAgB,eAAe,CAAC,EAC9B,UAAU,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,EACf,UAAU,GACX,EAAE,oBAAoB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAoF1C"}
@@ -1,4 +1,4 @@
1
- import { D as s, T as b, a as l, b as T, c as t, d as o, e as i } from "../../../DataTable-BtmAMrZg.js";
1
+ import { D as s, T as b, a as l, b as T, c as t, d as o, e as i } from "../../../DataTable-28eGRJvy.js";
2
2
  export {
3
3
  s as DataTable,
4
4
  b as TableActions,
@@ -15,7 +15,7 @@ import { S as gr, a as dr, b as mr, T as Cr } from "../Topbar-DMyjbOTI.js";
15
15
  import { E as Tr } from "../ErrorAlert-DH1onuyt.js";
16
16
  import { E as Dr } from "../ErrorState-vU8d4CwD.js";
17
17
  import { L as xr } from "../LoadingState-BN0YaPSs.js";
18
- import { D as Ir, T as Pr, a as hr, b as fr, c as wr, d as vr, e as Fr } from "../DataTable-BtmAMrZg.js";
18
+ import { D as Ir, T as Pr, a as hr, b as fr, c as wr, d as vr, e as Fr } from "../DataTable-28eGRJvy.js";
19
19
  import { A as Br, a as Gr, b as Hr, c as Rr } from "../AppVerticalTabs-DujFNh9f.js";
20
20
  import { T as Nr } from "../ThemeSelector-CQ3fSDJ2.js";
21
21
  import { A as Er, a as Or, b as Vr } from "../alert-B78CiTYe.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,508 +0,0 @@
1
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { u as ae } from "./useDataTable-CxcA5S-s.js";
3
- import { ay as P, aM as $, aA as W, aC as se, $ as B, az as ie } from "./toggle-group-DY9wl0HW.js";
4
- import "./alert-B78CiTYe.js";
5
- import "@radix-ui/react-aspect-ratio";
6
- import { B as b } from "./tooltip-BWyFpIxo.js";
7
- import "@radix-ui/react-collapsible";
8
- import "./sheet-Gop1cIaU.js";
9
- import { MoreVerticalIcon as ne, Loader2Icon as le, GripVerticalIcon as de, ArrowUpIcon as oe, ArrowDownIcon as ce, ArrowUpDownIcon as me, ChevronLeftIcon as he, ChevronRightIcon as ge, SettingsIcon as ue } from "lucide-react";
10
- import "react-resizable-panels";
11
- import "clsx";
12
- import "tailwind-merge";
13
- import "./select-MWzbMBAS.js";
14
- import "next-themes";
15
- import "sonner";
16
- import "react";
17
- const L = [5, 10, 30, 50, 100], pe = L[1];
18
- function fe({ actions: d, row: s }) {
19
- const o = d.filter((r) => r.visible === void 0 || r.visible(s));
20
- if (o.length === 0)
21
- return null;
22
- const i = o.filter((r) => r.overflow !== !0), g = o.filter((r) => r.overflow === !0);
23
- return /* @__PURE__ */ t("div", { className: "flex items-center justify-center gap-1", children: [
24
- i.map((r, h) => {
25
- var c;
26
- const m = r.icon;
27
- return /* @__PURE__ */ t(
28
- b,
29
- {
30
- variant: r.variant ?? "ghost",
31
- size: "sm",
32
- disabled: ((c = r.disabled) == null ? void 0 : c.call(r, s)) ?? !1,
33
- className: `h-7 px-2 text-muted-foreground hover:text-foreground ${r.className ?? ""}`,
34
- onClick: (l) => {
35
- l.stopPropagation(), r.onClick(s);
36
- },
37
- children: [
38
- m !== void 0 && /* @__PURE__ */ e(m, { className: "size-3.5" }),
39
- r.label
40
- ]
41
- },
42
- h
43
- );
44
- }),
45
- g.length > 0 && /* @__PURE__ */ t(P, { children: [
46
- /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(b, { variant: "ghost", size: "icon", className: "h-7 w-7 text-muted-foreground hover:text-foreground", children: /* @__PURE__ */ e(ne, { className: "size-3.5" }) }) }),
47
- /* @__PURE__ */ e(
48
- W,
49
- {
50
- align: "end",
51
- onClick: (r) => {
52
- r.stopPropagation();
53
- },
54
- children: g.map((r, h) => {
55
- var c;
56
- const m = r.icon;
57
- return /* @__PURE__ */ t(
58
- se,
59
- {
60
- disabled: ((c = r.disabled) == null ? void 0 : c.call(r, s)) ?? !1,
61
- onClick: () => {
62
- r.onClick(s);
63
- },
64
- className: r.className,
65
- children: [
66
- m !== void 0 && /* @__PURE__ */ e("span", { className: "mr-2 size-4 flex items-center justify-center", children: /* @__PURE__ */ e(m, { className: "size-4" }) }),
67
- r.label
68
- ]
69
- },
70
- h
71
- );
72
- })
73
- }
74
- )
75
- ] })
76
- ] });
77
- }
78
- function xe({
79
- isLoading: d,
80
- colSpanCount: s,
81
- noDataMessage: o,
82
- paginatedData: i,
83
- getRowId: g,
84
- onRowClick: r,
85
- hasBulkActions: h,
86
- selectedRows: m,
87
- toggleRowSelection: c,
88
- visibleColumnsArray: l,
89
- columnWidths: v,
90
- hasActions: z,
91
- actions: y,
92
- columns: w,
93
- bordered: N = !1,
94
- resizableColumns: D = !1
95
- }) {
96
- const k = (p, u) => {
97
- const n = w.find((a) => a.key === u);
98
- if ((n == null ? void 0 : n.renderCell) !== void 0)
99
- return n.renderCell(p);
100
- const x = p[u];
101
- return /* @__PURE__ */ e("span", { className: "text-sm truncate", children: x != null ? String(x) : "-" });
102
- };
103
- return d ? /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-200 dark:divide-gray-800", children: /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: s, className: "py-8 text-center", children: /* @__PURE__ */ t("div", { className: "flex flex-col items-center justify-center gap-2 text-muted-foreground", children: [
104
- /* @__PURE__ */ e(le, { className: "h-6 w-6 animate-spin text-primary" }),
105
- /* @__PURE__ */ e("span", { className: "text-sm", children: "Chargement..." })
106
- ] }) }) }) }) : i.length === 0 ? /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-200 dark:divide-gray-800", children: /* @__PURE__ */ e("tr", { children: /* @__PURE__ */ e("td", { colSpan: s, className: "py-8 text-center text-sm text-muted-foreground", children: o }) }) }) : /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-200 dark:divide-gray-800", children: i.map((p) => {
107
- const u = g(p);
108
- return /* @__PURE__ */ t(
109
- "tr",
110
- {
111
- className: `group hover:bg-muted/50 dark:hover:bg-gray-900/50 transition-colors ${r !== void 0 ? "cursor-pointer" : ""}`,
112
- onClick: (n) => r == null ? void 0 : r(p, n),
113
- children: [
114
- h ? /* @__PURE__ */ e(
115
- "td",
116
- {
117
- className: "p-1 text-center align-middle",
118
- style: { width: "32px", minWidth: "32px", maxWidth: "32px" },
119
- onClick: (n) => {
120
- n.stopPropagation();
121
- },
122
- children: /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e(
123
- B,
124
- {
125
- checked: m.includes(u),
126
- onCheckedChange: () => {
127
- c(u);
128
- }
129
- }
130
- ) })
131
- }
132
- ) : null,
133
- l.map((n, x) => {
134
- const a = x === l.length - 1;
135
- return /* @__PURE__ */ e(
136
- "td",
137
- {
138
- className: `px-2 py-2 relative ${N && !a ? "border-r border-gray-100 dark:border-gray-800" : ""} ${n.className ?? ""}`,
139
- style: D ? { width: v[n.key] } : { minWidth: v[n.key] },
140
- children: /* @__PURE__ */ e("div", { className: "w-full h-full", children: k(p, n.key) })
141
- },
142
- n.key
143
- );
144
- }),
145
- z ? /* @__PURE__ */ e(
146
- "td",
147
- {
148
- className: "p-1 text-center align-middle whitespace-nowrap",
149
- style: { minWidth: "32px" },
150
- onClick: (n) => {
151
- n.stopPropagation();
152
- },
153
- children: y !== void 0 && y.length > 0 ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e(fe, { actions: y, row: p }) }) : null
154
- }
155
- ) : null
156
- ]
157
- },
158
- u
159
- );
160
- }) });
161
- }
162
- function ve({ selectedRows: d, setSelectedRows: s, bulkActions: o }) {
163
- return /* @__PURE__ */ t("div", { className: "bg-muted/60 dark:bg-gray-900/60 border border-border px-3 py-1.5 flex items-center justify-between rounded-lg", children: [
164
- /* @__PURE__ */ t("div", { className: "flex items-center gap-4", children: [
165
- /* @__PURE__ */ t("span", { className: "text-sm font-medium text-primary ml-1", children: [
166
- d.length,
167
- " sélectionné(s)"
168
- ] }),
169
- /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: o.map((i, g) => {
170
- const r = i.icon;
171
- return /* @__PURE__ */ t(
172
- b,
173
- {
174
- variant: "outline",
175
- size: "sm",
176
- onClick: () => {
177
- i.onClick(d, () => {
178
- s([]);
179
- });
180
- },
181
- className: `h-7 bg-background shadow-sm text-xs px-2.5 ${i.variant === "destructive" ? "text-destructive border-destructive/30 hover:bg-destructive/10 hover:text-destructive" : "text-foreground"}`,
182
- children: [
183
- r !== void 0 && /* @__PURE__ */ e("span", { className: "mr-1.5 flex items-center justify-center", children: /* @__PURE__ */ e(r, { className: "h-3.5 w-3.5" }) }),
184
- i.label
185
- ]
186
- },
187
- g
188
- );
189
- }) })
190
- ] }),
191
- /* @__PURE__ */ e(
192
- b,
193
- {
194
- variant: "ghost",
195
- size: "sm",
196
- onClick: () => {
197
- s([]);
198
- },
199
- className: "text-xs text-muted-foreground hover:text-foreground h-7 px-2",
200
- children: "Désélectionner"
201
- }
202
- )
203
- ] });
204
- }
205
- function ye({
206
- hasBulkActions: d,
207
- selectedRows: s,
208
- totalItems: o,
209
- toggleSelectAll: i,
210
- visibleColumnsArray: g,
211
- draggableColumns: r,
212
- resizableColumns: h,
213
- columnWidths: m,
214
- sortColumn: c,
215
- sortDirection: l,
216
- handleSort: v,
217
- handleDragStart: z,
218
- handleDragOver: y,
219
- handleDrop: w,
220
- handleMouseDown: N,
221
- hasActions: D,
222
- settingsNode: k,
223
- bordered: p = !1
224
- }) {
225
- let u = !1;
226
- s.length === o && o > 0 ? u = !0 : s.length > 0 && (u = "indeterminate");
227
- const n = (a) => a.sortable !== !0 ? null : c === a.key ? l === "asc" ? /* @__PURE__ */ e(oe, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ e(ce, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ e(me, { className: "size-3.5 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors" }), x = (a, I) => {
228
- const S = I !== !1, C = a.sortable === !0;
229
- return /* @__PURE__ */ t(
230
- "th",
231
- {
232
- className: [
233
- "px-2 py-2 text-left text-sm font-medium text-gray-900 dark:text-gray-100 relative group",
234
- p ? "border-r border-gray-200 dark:border-gray-800" : "",
235
- C ? "cursor-pointer select-none" : "",
236
- a.className ?? ""
237
- ].filter(Boolean).join(" "),
238
- style: h ? { width: m[a.key] } : { minWidth: m[a.key] },
239
- draggable: S,
240
- onClick: () => {
241
- v(a.key);
242
- },
243
- onDragStart: (f) => {
244
- S ? z(f, a.key) : f.preventDefault();
245
- },
246
- onDragOver: (f) => {
247
- y(f, a.key);
248
- },
249
- onDrop: (f) => {
250
- w(f, a.key);
251
- },
252
- children: [
253
- /* @__PURE__ */ t("div", { className: "flex items-center justify-between pr-2", children: [
254
- /* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: [
255
- S ? /* @__PURE__ */ e(de, { className: "size-4 text-gray-400 cursor-grab dark:text-gray-300 shrink-0" }) : null,
256
- /* @__PURE__ */ e("span", { className: "truncate", children: a.label })
257
- ] }),
258
- /* @__PURE__ */ e("div", { className: "ml-1 shrink-0", children: n(a) })
259
- ] }),
260
- h ? /* @__PURE__ */ e(
261
- "div",
262
- {
263
- className: "absolute right-0 top-0 bottom-0 w-2 cursor-col-resize hover:bg-blue-500 opacity-0 group-hover:opacity-50 transition-opacity",
264
- onMouseDown: (f) => {
265
- N(f, a.key);
266
- }
267
- }
268
- ) : null
269
- ]
270
- },
271
- a.key
272
- );
273
- };
274
- return /* @__PURE__ */ e("thead", { className: "bg-muted/50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-800", children: /* @__PURE__ */ t("tr", { children: [
275
- d ? /* @__PURE__ */ e("th", { className: "p-1 flex-shrink-0 text-center align-middle", style: { width: "32px", minWidth: "32px", maxWidth: "32px" }, children: /* @__PURE__ */ e("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ e(B, { checked: u, onCheckedChange: i }) }) }) : null,
276
- g.map((a) => x(a, r)),
277
- D || k !== void 0 ? /* @__PURE__ */ e("th", { className: "p-1 text-center align-middle", style: { minWidth: "32px" }, children: k }) : null
278
- ] }) });
279
- }
280
- function be({
281
- totalItems: d,
282
- startIndex: s,
283
- endIndex: o,
284
- pageSize: i,
285
- setPageSize: g,
286
- currentPage: r,
287
- setCurrentPage: h,
288
- pageSizeOptions: m,
289
- totalPages: c
290
- }) {
291
- return /* @__PURE__ */ t("div", { className: "px-4 py-2 border-t border-gray-200 dark:border-gray-800 flex items-center justify-between bg-muted/50 dark:bg-gray-900/50 flex-wrap gap-2", children: [
292
- /* @__PURE__ */ t("div", { className: "text-sm text-muted-foreground", children: [
293
- d === 0 ? "0" : `${String(s + 1)} - ${String(o)}`,
294
- " sur ",
295
- d
296
- ] }),
297
- /* @__PURE__ */ t("div", { className: "flex items-center gap-4", children: [
298
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
299
- /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: "Lignes par page :" }),
300
- /* @__PURE__ */ e(
301
- "select",
302
- {
303
- value: i,
304
- onChange: (l) => {
305
- g(Number(l.target.value)), h(1);
306
- },
307
- className: "border border-input bg-background rounded px-2 py-1 text-sm text-foreground",
308
- children: m.map((l) => /* @__PURE__ */ e("option", { value: l, children: l }, l))
309
- }
310
- )
311
- ] }),
312
- /* @__PURE__ */ t("div", { className: "flex items-center gap-2", children: [
313
- /* @__PURE__ */ e(
314
- b,
315
- {
316
- variant: "outline",
317
- size: "sm",
318
- className: "h-8 w-8 p-0",
319
- onClick: () => {
320
- h((l) => Math.max(1, l - 1));
321
- },
322
- disabled: r === 1,
323
- children: /* @__PURE__ */ e(he, { className: "size-4" })
324
- }
325
- ),
326
- /* @__PURE__ */ t("span", { className: "text-sm text-muted-foreground", children: [
327
- "Page ",
328
- r,
329
- " sur ",
330
- c
331
- ] }),
332
- /* @__PURE__ */ e(
333
- b,
334
- {
335
- variant: "outline",
336
- size: "sm",
337
- className: "h-8 w-8 p-0",
338
- onClick: () => {
339
- h((l) => Math.min(c, l + 1));
340
- },
341
- disabled: r === c,
342
- children: /* @__PURE__ */ e(ge, { className: "size-4" })
343
- }
344
- )
345
- ] })
346
- ] })
347
- ] });
348
- }
349
- function Ne({ columns: d, visibleColumns: s, toggleColumnVisibility: o }) {
350
- return /* @__PURE__ */ t(P, { children: [
351
- /* @__PURE__ */ e($, { asChild: !0, children: /* @__PURE__ */ e(b, { variant: "outline", size: "sm", className: "size-7 p-0 bg-white hover:bg-gray-100 dark:bg-gray-900 shadow-sm border-gray-200 dark:border-gray-800", children: /* @__PURE__ */ e(ue, { className: "size-3.5 text-gray-600 dark:text-gray-300" }) }) }),
352
- /* @__PURE__ */ e(W, { align: "end", className: "w-56", children: d.map((i) => /* @__PURE__ */ e(
353
- ie,
354
- {
355
- checked: s.has(i.key),
356
- onCheckedChange: () => {
357
- o(i.key);
358
- },
359
- children: i.label
360
- },
361
- i.key
362
- )) })
363
- ] });
364
- }
365
- function He({
366
- data: d,
367
- columns: s,
368
- getRowId: o,
369
- onRowClick: i,
370
- actions: g,
371
- bulkActions: r,
372
- draggableColumns: h = !1,
373
- resizableColumns: m = !1,
374
- columnVisibility: c = !1,
375
- isLoading: l = !1,
376
- bordered: v = !1,
377
- noDataMessage: z = "Aucun résultat",
378
- defaultPageSize: y = pe,
379
- pageSizeOptions: w = L,
380
- totalRows: N,
381
- currentPage: D,
382
- pageSize: k,
383
- onPageChange: p,
384
- onPageSizeChange: u,
385
- sortColumn: n,
386
- sortDirection: x,
387
- onSortChange: a
388
- }) {
389
- const {
390
- sortColumn: I,
391
- sortDirection: S,
392
- selectedRows: C,
393
- setSelectedRows: f,
394
- visibleColumns: H,
395
- columnWidths: j,
396
- safeCurrentPage: O,
397
- totalPages: U,
398
- startIndex: V,
399
- endIndex: G,
400
- tableRef: q,
401
- hasActions: A,
402
- hasBulkActions: M,
403
- visibleColumnsArray: T,
404
- colSpanCount: E,
405
- paginatedData: F,
406
- handleSort: J,
407
- handleMouseDown: Q,
408
- handleDragStart: X,
409
- handleDragOver: Y,
410
- handleDrop: Z,
411
- toggleColumnVisibility: _,
412
- toggleRowSelection: K,
413
- toggleSelectAll: R,
414
- pageSize: ee,
415
- setPageSize: re,
416
- setCurrentPage: te
417
- } = ae({
418
- data: d,
419
- columns: s,
420
- getRowId: o,
421
- defaultPageSize: y,
422
- actions: g,
423
- bulkActions: r,
424
- columnVisibility: c,
425
- totalRows: N,
426
- currentPage: D,
427
- pageSize: k,
428
- onPageChange: p,
429
- onPageSizeChange: u,
430
- sortColumn: n,
431
- sortDirection: x,
432
- onSortChange: a
433
- });
434
- return /* @__PURE__ */ t("div", { className: "space-y-4", children: [
435
- C.length > 0 && r !== void 0 && r.length > 0 && /* @__PURE__ */ e(ve, { selectedRows: C, setSelectedRows: f, bulkActions: r }),
436
- /* @__PURE__ */ t("div", { className: "w-full bg-card dark:bg-gray-950 rounded-md border border-gray-200 dark:border-gray-800 overflow-hidden", children: [
437
- /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ t("table", { ref: q, className: "w-full", children: [
438
- /* @__PURE__ */ e(
439
- ye,
440
- {
441
- hasBulkActions: M,
442
- selectedRows: C,
443
- totalItems: d.length,
444
- toggleSelectAll: R,
445
- visibleColumnsArray: T,
446
- draggableColumns: h,
447
- resizableColumns: m,
448
- columnWidths: j,
449
- sortColumn: I,
450
- sortDirection: S,
451
- handleSort: J,
452
- handleDragStart: X,
453
- handleDragOver: Y,
454
- handleDrop: Z,
455
- handleMouseDown: Q,
456
- hasActions: A,
457
- bordered: v,
458
- settingsNode: c ? /* @__PURE__ */ e(Ne, { columns: s, visibleColumns: H, toggleColumnVisibility: _ }) : void 0
459
- }
460
- ),
461
- /* @__PURE__ */ e(
462
- xe,
463
- {
464
- bordered: v,
465
- isLoading: l,
466
- colSpanCount: E,
467
- noDataMessage: z,
468
- paginatedData: F,
469
- getRowId: o,
470
- onRowClick: i,
471
- hasBulkActions: M,
472
- selectedRows: C,
473
- toggleRowSelection: K,
474
- visibleColumnsArray: T,
475
- columnWidths: j,
476
- hasActions: A || c,
477
- actions: g,
478
- columns: s,
479
- resizableColumns: m
480
- }
481
- )
482
- ] }) }),
483
- /* @__PURE__ */ e(
484
- be,
485
- {
486
- totalItems: N ?? d.length,
487
- startIndex: V,
488
- endIndex: G,
489
- pageSize: ee,
490
- setPageSize: re,
491
- currentPage: O,
492
- setCurrentPage: te,
493
- pageSizeOptions: w,
494
- totalPages: U
495
- }
496
- )
497
- ] })
498
- ] });
499
- }
500
- export {
501
- He as D,
502
- fe as T,
503
- xe as a,
504
- ve as b,
505
- ye as c,
506
- be as d,
507
- Ne as e
508
- };