@krosoft/react 0.0.260 → 0.0.261

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,614 @@
1
+ import { ACTIONS_COLUMN_KEY as e, SELECTION_COLUMN_KEY as t, getAlignmentClass as n, getColumnAlignment as r, getFixedCellProps as i } from "./helpers/index.js";
2
+ import { At as a, C as o, D as s, Ft as c, Gt as l, Mt as u, Nt as d, O as f, S as p, T as m, bn as h, jt as g, k as _, v } from "./ui-hnbBp9RZ.js";
3
+ import { s as y } from "./tooltip-BmZ9Bfou.js";
4
+ import { t as b } from "./i18n-DW5zKBEK.js";
5
+ import { i as x, l as S, n as C, t as w, u as T } from "./select-DmLScQKX.js";
6
+ import { n as E, t as D } from "./useFixedColumns-DnzqhbfT.js";
7
+ import { useState as O } from "react";
8
+ import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
9
+ import { useTranslation as M } from "react-i18next";
10
+ import { formatJsonValue as N, isRecord as P, tryParseJson as F } from "@krosoft/core/helpers";
11
+ import { AlertTriangleIcon as ee, ArrowDownIcon as I, ArrowUpDownIcon as L, ArrowUpIcon as R, ChevronLeftIcon as z, ChevronRightIcon as B, GripVerticalIcon as V, Loader2Icon as H, MoreVerticalIcon as U, SettingsIcon as W } from "lucide-react";
12
+ import { useNavigate as G } from "react-router-dom";
13
+ //#region src/constants/datatable.ts
14
+ var K = [
15
+ 5,
16
+ 10,
17
+ 30,
18
+ 50,
19
+ 100
20
+ ], te = K[1];
21
+ //#endregion
22
+ //#region src/components/core/table/TableActions.tsx
23
+ function q({ actions: e, row: t }) {
24
+ let n = e.filter((e) => e.visible === void 0 || e.visible(t));
25
+ if (n.length === 0) return null;
26
+ let r = n.filter((e) => e.overflow !== !0), i = n.filter((e) => e.overflow === !0);
27
+ return /* @__PURE__ */ j("div", {
28
+ className: "flex items-center justify-end gap-1",
29
+ children: [r.map((e, n) => {
30
+ let r = e.icon;
31
+ return /* @__PURE__ */ j(y, {
32
+ variant: e.variant ?? "ghost",
33
+ size: "sm",
34
+ disabled: e.disabled?.(t) ?? !1,
35
+ className: `h-7 px-2 text-muted-foreground hover:text-foreground ${e.className ?? ""}`,
36
+ onClick: (n) => {
37
+ n.stopPropagation(), e.onClick(t);
38
+ },
39
+ children: [r !== void 0 && /* @__PURE__ */ A(r, { className: "size-3.5" }), e.label]
40
+ }, n);
41
+ }), i.length > 0 && /* @__PURE__ */ j(g, { children: [/* @__PURE__ */ A(l, {
42
+ asChild: !0,
43
+ children: /* @__PURE__ */ A(y, {
44
+ variant: "ghost",
45
+ size: "icon",
46
+ className: "h-7 w-7 text-muted-foreground hover:text-foreground",
47
+ children: /* @__PURE__ */ A(U, { className: "size-3.5" })
48
+ })
49
+ }), /* @__PURE__ */ A(d, {
50
+ align: "end",
51
+ onClick: (e) => {
52
+ e.stopPropagation();
53
+ },
54
+ children: i.map((e, n) => {
55
+ let r = e.icon;
56
+ return /* @__PURE__ */ j(c, {
57
+ disabled: e.disabled?.(t) ?? !1,
58
+ onClick: () => {
59
+ e.onClick(t);
60
+ },
61
+ className: e.className,
62
+ children: [r !== void 0 && /* @__PURE__ */ A("span", {
63
+ className: "mr-2 size-4 flex items-center justify-center",
64
+ children: /* @__PURE__ */ A(r, { className: "size-4" })
65
+ }), e.label]
66
+ }, n);
67
+ })
68
+ })] })]
69
+ });
70
+ }
71
+ //#endregion
72
+ //#region src/components/core/table/TableBody.tsx
73
+ function J({ isLoading: a, error: o, colSpanCount: s, messages: c, paginatedData: l, getRowId: u, onRowClick: d, onRowNavigate: f, hasBulkActions: p, selectedRows: m, toggleRowSelection: g, visibleColumnsArray: _, columnWidths: v, hasActions: y, actions: x, columns: S, bordered: C = !1, dense: w = !1, resizableColumns: T = !1, fixedColumns: E = {} }) {
74
+ let { t: D } = b(), { t: O } = M(), k = c?.loadingKey ? O(c.loadingKey) : D("states.loading"), N = c?.emptyKey ? O(c.emptyKey) : D("states.noResult"), P = G(), F = (e, t) => {
75
+ let n = S.find((e) => e.key === t);
76
+ if (n?.renderCell !== void 0) return n.renderCell(e);
77
+ let r = e[t];
78
+ return /* @__PURE__ */ A("span", {
79
+ className: "text-sm truncate",
80
+ children: r == null ? "-" : String(r)
81
+ });
82
+ };
83
+ if (a) return /* @__PURE__ */ A("tbody", {
84
+ className: "divide-y divide-border",
85
+ children: /* @__PURE__ */ A("tr", { children: /* @__PURE__ */ A("td", {
86
+ colSpan: s,
87
+ className: "py-8 text-center",
88
+ children: /* @__PURE__ */ j("div", {
89
+ className: "flex flex-col items-center justify-center gap-2 text-muted-foreground",
90
+ children: [/* @__PURE__ */ A(H, { className: "h-6 w-6 animate-spin text-primary" }), /* @__PURE__ */ A("span", {
91
+ className: "text-sm",
92
+ children: k
93
+ })]
94
+ })
95
+ }) })
96
+ });
97
+ if (o) return /* @__PURE__ */ A("tbody", {
98
+ className: "divide-y divide-border",
99
+ children: /* @__PURE__ */ A("tr", { children: /* @__PURE__ */ A("td", {
100
+ colSpan: s,
101
+ className: "py-8 text-center",
102
+ children: /* @__PURE__ */ j("div", {
103
+ className: "flex flex-col items-center justify-center gap-2 text-destructive",
104
+ children: [/* @__PURE__ */ A(ee, { className: "h-6 w-6" }), /* @__PURE__ */ A("span", {
105
+ className: "text-sm",
106
+ children: o
107
+ })]
108
+ })
109
+ }) })
110
+ });
111
+ if (l.length === 0) return /* @__PURE__ */ A("tbody", {
112
+ className: "divide-y divide-border",
113
+ children: /* @__PURE__ */ A("tr", { children: /* @__PURE__ */ A("td", {
114
+ colSpan: s,
115
+ className: "py-8 text-center text-sm text-muted-foreground",
116
+ children: N
117
+ }) })
118
+ });
119
+ let I = i(E[t], "body"), L = i(E[e], "body"), R = f !== void 0 || d !== void 0, z = (e, t) => {
120
+ if (f !== void 0) {
121
+ let n = f(e);
122
+ t.ctrlKey || t.metaKey ? window.open(n, "_blank") : P(n);
123
+ } else d?.(e, t);
124
+ };
125
+ return /* @__PURE__ */ A("tbody", {
126
+ className: "divide-y divide-border",
127
+ children: l.map((e) => {
128
+ let t = u(e);
129
+ return /* @__PURE__ */ j("tr", {
130
+ className: `group hover:bg-muted/50 transition-colors ${R ? "cursor-pointer" : ""}`,
131
+ onClick: (t) => {
132
+ z(e, t);
133
+ },
134
+ children: [
135
+ p ? /* @__PURE__ */ A("td", {
136
+ className: `p-1 text-center align-middle ${I.className}`,
137
+ style: {
138
+ width: "48px",
139
+ minWidth: "48px",
140
+ maxWidth: "48px",
141
+ ...I.style
142
+ },
143
+ onClick: (e) => {
144
+ e.stopPropagation();
145
+ },
146
+ children: /* @__PURE__ */ A("div", {
147
+ className: "flex items-center justify-center",
148
+ children: /* @__PURE__ */ A(h, {
149
+ checked: m.includes(t),
150
+ onCheckedChange: () => {
151
+ g(t);
152
+ }
153
+ })
154
+ })
155
+ }) : null,
156
+ _.map((t, a) => {
157
+ let o = a === _.length - 1, s = i(E[t.key], "body");
158
+ return /* @__PURE__ */ A("td", {
159
+ className: `${`${a === 0 && !p ? "pl-4" : "pl-2"} ${o && !y ? "pr-4" : "pr-2"}`} ${w ? "py-2" : "py-4"} text-sm ${n(r(t))} ${s.className} ${C && !o ? "border-r border-border" : ""} ${t.className ?? ""}`,
160
+ style: {
161
+ ...T ? { width: v[t.key] } : { minWidth: v[t.key] },
162
+ ...s.style
163
+ },
164
+ children: /* @__PURE__ */ A("div", {
165
+ className: "w-full h-full",
166
+ children: F(e, t.key)
167
+ })
168
+ }, t.key);
169
+ }),
170
+ y ? /* @__PURE__ */ A("td", {
171
+ className: `py-1 pl-1 pr-4 text-right align-middle whitespace-nowrap ${L.className}`,
172
+ style: {
173
+ minWidth: "32px",
174
+ ...L.style
175
+ },
176
+ onClick: (e) => {
177
+ e.stopPropagation();
178
+ },
179
+ children: x !== void 0 && x.length > 0 ? /* @__PURE__ */ A("div", {
180
+ className: "flex items-center justify-end",
181
+ children: /* @__PURE__ */ A(q, {
182
+ actions: x,
183
+ row: e
184
+ })
185
+ }) : null
186
+ }) : null
187
+ ]
188
+ }, t);
189
+ })
190
+ });
191
+ }
192
+ //#endregion
193
+ //#region src/components/core/table/TableBulkActions.tsx
194
+ function Y({ selectedRows: e, setSelectedRows: t, bulkActions: n }) {
195
+ return /* @__PURE__ */ j("div", {
196
+ className: "bg-muted/60 border border-border px-3 py-1.5 flex items-center justify-between rounded-surface",
197
+ children: [/* @__PURE__ */ j("div", {
198
+ className: "flex items-center gap-4",
199
+ children: [/* @__PURE__ */ j("span", {
200
+ className: "text-sm font-medium text-primary ml-1",
201
+ children: [e.length, " sélectionné(s)"]
202
+ }), /* @__PURE__ */ A("div", {
203
+ className: "flex items-center gap-2",
204
+ children: n.map((n, r) => {
205
+ let i = n.icon;
206
+ return /* @__PURE__ */ j(y, {
207
+ variant: "outline",
208
+ size: "sm",
209
+ onClick: () => {
210
+ n.onClick(e, () => {
211
+ t([]);
212
+ });
213
+ },
214
+ className: `h-7 bg-background shadow-sm text-xs px-2.5 ${n.variant === "destructive" ? "text-destructive border-destructive/30 hover:bg-destructive/10 hover:text-destructive" : "text-foreground"}`,
215
+ children: [i !== void 0 && /* @__PURE__ */ A("span", {
216
+ className: "mr-1.5 flex items-center justify-center",
217
+ children: /* @__PURE__ */ A(i, { className: "h-3.5 w-3.5" })
218
+ }), n.label]
219
+ }, r);
220
+ })
221
+ })]
222
+ }), /* @__PURE__ */ A(y, {
223
+ variant: "ghost",
224
+ size: "sm",
225
+ onClick: () => {
226
+ t([]);
227
+ },
228
+ className: "text-xs text-muted-foreground hover:text-foreground h-7 px-2",
229
+ children: "Désélectionner"
230
+ })]
231
+ });
232
+ }
233
+ //#endregion
234
+ //#region src/components/core/table/TableHeader.tsx
235
+ var X = {
236
+ left: "justify-start",
237
+ center: "justify-center",
238
+ right: "justify-end"
239
+ };
240
+ function Z({ hasBulkActions: a, selectedRows: o, totalItems: s, toggleSelectAll: c, visibleColumnsArray: l, draggableColumns: u, resizableColumns: d, columnWidths: f, sortColumn: p, sortDirection: m, handleSort: g, handleDragStart: _, handleDragOver: v, handleDrop: y, handleMouseDown: b, hasActions: x, settingsNode: S, bordered: C = !1, dense: w = !1, fixedColumns: T = {}, fixedSelection: E = !1, fixedActions: D = !1 }) {
241
+ let O = !1;
242
+ o.length === s && s > 0 ? O = !0 : o.length > 0 && (O = "indeterminate");
243
+ let k = (e) => e.sortable === !0 ? p === e.key ? A(m === "asc" ? R : I, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ A(L, { className: "size-3.5 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors" }) : null, M = (e, t, o) => {
244
+ let s = o !== !1 && e.fixed === void 0, c = e.sortable === !0, u = i(T[e.key], "header"), p = r(e), m = k(e), h = t === 0 && !a, E = t === l.length - 1 && !(x || S !== void 0), D = `${h ? "pl-4" : "pl-2"} ${E ? "pr-4" : "pr-2"}`;
245
+ return /* @__PURE__ */ j("th", {
246
+ "data-column-key": e.key,
247
+ "data-fixed-side": e.fixed,
248
+ className: [
249
+ `${D} ${w ? "py-2" : "py-4"} text-sm font-medium text-foreground group`,
250
+ n(p),
251
+ u.className,
252
+ C ? "border-r border-border" : "",
253
+ c ? "cursor-pointer select-none" : "",
254
+ e.className ?? ""
255
+ ].filter(Boolean).join(" "),
256
+ style: {
257
+ ...d ? { width: f[e.key] } : { minWidth: f[e.key] },
258
+ ...u.style
259
+ },
260
+ draggable: s,
261
+ onClick: () => {
262
+ g(e.key);
263
+ },
264
+ onDragStart: (t) => {
265
+ s ? _(t, e.key) : t.preventDefault();
266
+ },
267
+ onDragOver: (t) => {
268
+ v(t, e.key);
269
+ },
270
+ onDrop: (t) => {
271
+ y(t, e.key);
272
+ },
273
+ children: [/* @__PURE__ */ j("div", {
274
+ className: `flex items-center gap-1 ${X[p]} ${d ? "pr-2" : ""}`,
275
+ children: [
276
+ s ? /* @__PURE__ */ A(V, { className: "size-4 text-muted-foreground cursor-grab shrink-0" }) : null,
277
+ /* @__PURE__ */ A("span", {
278
+ className: "truncate",
279
+ children: e.label
280
+ }),
281
+ m === null ? null : /* @__PURE__ */ A("span", {
282
+ className: "ml-1 shrink-0",
283
+ children: m
284
+ })
285
+ ]
286
+ }), d ? /* @__PURE__ */ A("div", {
287
+ 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",
288
+ onMouseDown: (t) => {
289
+ b(t, e.key);
290
+ }
291
+ }) : null]
292
+ }, e.key);
293
+ }, N = i(T[t], "header"), P = i(T[e], "header");
294
+ return /* @__PURE__ */ A("thead", {
295
+ className: "bg-muted/50 border-b border-border",
296
+ children: /* @__PURE__ */ j("tr", { children: [
297
+ a ? /* @__PURE__ */ A("th", {
298
+ "data-column-key": t,
299
+ "data-fixed-side": E ? "left" : void 0,
300
+ className: `p-1 text-center align-middle ${N.className}`,
301
+ style: {
302
+ width: "48px",
303
+ minWidth: "48px",
304
+ maxWidth: "48px",
305
+ ...N.style
306
+ },
307
+ children: /* @__PURE__ */ A("div", {
308
+ className: "flex items-center justify-center",
309
+ children: /* @__PURE__ */ A(h, {
310
+ checked: O,
311
+ onCheckedChange: c
312
+ })
313
+ })
314
+ }) : null,
315
+ l.map((e, t) => M(e, t, u)),
316
+ x || S !== void 0 ? /* @__PURE__ */ A("th", {
317
+ "data-column-key": e,
318
+ "data-fixed-side": D ? "right" : void 0,
319
+ className: `py-1 pl-1 pr-4 text-right align-middle ${P.className}`,
320
+ style: {
321
+ minWidth: "32px",
322
+ ...P.style
323
+ },
324
+ children: S
325
+ }) : null
326
+ ] })
327
+ });
328
+ }
329
+ //#endregion
330
+ //#region src/components/core/table/TablePagination.tsx
331
+ var Q = "…";
332
+ function $(e, t) {
333
+ return Array.from({ length: t - e + 1 }, (t, n) => e + n);
334
+ }
335
+ function ne(e, t, n = 1) {
336
+ if (n * 2 + 5 >= t) return $(1, t);
337
+ let r = Math.max(e - n, 1), i = Math.min(e + n, t), a = r > 2, o = i < t - 1;
338
+ return !a && o ? [
339
+ ...$(1, n + 2),
340
+ Q,
341
+ t
342
+ ] : a && !o ? [
343
+ 1,
344
+ Q,
345
+ ...$(t - (n + 2) + 1, t)
346
+ ] : [
347
+ 1,
348
+ Q,
349
+ ...$(r, i),
350
+ Q,
351
+ t
352
+ ];
353
+ }
354
+ function re({ totalItems: e, startIndex: t, endIndex: n, pageSize: r, setPageSize: i, currentPage: a, setCurrentPage: o, pageSizeOptions: s, totalPages: c }) {
355
+ let { t: l } = b(), u = ne(a, c);
356
+ return /* @__PURE__ */ j("div", {
357
+ className: "px-4 py-2 border-t border-border flex flex-col sm:grid sm:grid-cols-3 items-center gap-2 bg-muted/50",
358
+ children: [
359
+ /* @__PURE__ */ j("div", {
360
+ className: "text-sm text-muted-foreground justify-self-start",
361
+ children: [
362
+ e === 0 ? "0" : `${String(t + 1)} - ${String(n)}`,
363
+ " sur ",
364
+ e
365
+ ]
366
+ }),
367
+ /* @__PURE__ */ A("div", {
368
+ className: "flex items-center justify-center gap-1",
369
+ children: c > 1 && /* @__PURE__ */ j(k, { children: [
370
+ /* @__PURE__ */ A(y, {
371
+ variant: "ghost",
372
+ size: "icon",
373
+ className: "h-8 w-8 rounded-control",
374
+ onClick: () => {
375
+ o((e) => Math.max(1, e - 1));
376
+ },
377
+ disabled: a === 1,
378
+ "aria-label": l("table.previousPage"),
379
+ children: /* @__PURE__ */ A(z, { className: "size-4" })
380
+ }),
381
+ u.map((e, t) => e === Q ? /* @__PURE__ */ A("span", {
382
+ className: "flex h-8 w-8 items-center justify-center text-sm text-muted-foreground",
383
+ children: Q
384
+ }, `dots-${String(t)}`) : /* @__PURE__ */ A(y, {
385
+ variant: e === a ? "default" : "ghost",
386
+ size: "icon",
387
+ className: "h-8 w-8 rounded-control text-sm",
388
+ onClick: () => {
389
+ o(e);
390
+ },
391
+ "aria-current": e === a ? "page" : void 0,
392
+ children: e
393
+ }, e)),
394
+ /* @__PURE__ */ A(y, {
395
+ variant: "ghost",
396
+ size: "icon",
397
+ className: "h-8 w-8 rounded-control",
398
+ onClick: () => {
399
+ o((e) => Math.min(c, e + 1));
400
+ },
401
+ disabled: a === c,
402
+ "aria-label": l("table.nextPage"),
403
+ children: /* @__PURE__ */ A(B, { className: "size-4" })
404
+ })
405
+ ] })
406
+ }),
407
+ /* @__PURE__ */ A("div", {
408
+ className: "justify-self-end",
409
+ children: /* @__PURE__ */ j(w, {
410
+ value: String(r),
411
+ onValueChange: (e) => {
412
+ i(Number(e)), o(1);
413
+ },
414
+ children: [/* @__PURE__ */ A(S, {
415
+ className: "h-8 w-[110px] text-sm",
416
+ children: /* @__PURE__ */ A(T, {})
417
+ }), /* @__PURE__ */ A(C, { children: s.map((e) => /* @__PURE__ */ j(x, {
418
+ value: String(e),
419
+ children: [e, " / page"]
420
+ }, e)) })]
421
+ })
422
+ })
423
+ ]
424
+ });
425
+ }
426
+ //#endregion
427
+ //#region src/components/core/table/TableSettings.tsx
428
+ function ie({ columns: e, visibleColumns: t, toggleColumnVisibility: n }) {
429
+ return /* @__PURE__ */ j(g, { children: [/* @__PURE__ */ A(l, {
430
+ asChild: !0,
431
+ children: /* @__PURE__ */ A(y, {
432
+ variant: "outline",
433
+ size: "sm",
434
+ className: "size-7 p-0 bg-background hover:bg-muted shadow-sm border-border",
435
+ children: /* @__PURE__ */ A(W, { className: "size-3.5 text-muted-foreground" })
436
+ })
437
+ }), /* @__PURE__ */ A(d, {
438
+ align: "end",
439
+ className: "w-56",
440
+ children: e.map((e) => /* @__PURE__ */ A(u, {
441
+ checked: t.has(e.key),
442
+ onCheckedChange: () => {
443
+ n(e.key);
444
+ },
445
+ children: e.label
446
+ }, e.key))
447
+ })] });
448
+ }
449
+ //#endregion
450
+ //#region src/components/core/table/DataTable.tsx
451
+ function ae({ data: e, columns: t, getRowId: n, onRowClick: r, onRowNavigate: i, actions: a, bulkActions: o, isLoading: s = !1, error: c = null, config: l, defaultPageSize: u = te, pageSizeOptions: d = K, totalRows: f, currentPage: p, pageSize: m, onPageChange: h, onPageSizeChange: g, sortColumn: _, sortDirection: v, onSortChange: y }) {
452
+ let b = l?.dense ?? !1, x = l?.bordered ?? !1, S = l?.draggableColumns ?? !1, C = l?.resizableColumns ?? !1, w = l?.columnVisibility ?? !1, T = l?.fixedActions ?? !1, { sortColumn: O, sortDirection: k, selectedRows: M, setSelectedRows: N, visibleColumns: P, columnWidths: F, safeCurrentPage: ee, totalPages: I, startIndex: L, endIndex: R, tableRef: z, hasActions: B, hasBulkActions: V, visibleColumnsArray: H, colSpanCount: U, paginatedData: W, handleSort: G, handleMouseDown: q, handleDragStart: X, handleDragOver: Q, handleDrop: $, toggleColumnVisibility: ne, toggleRowSelection: ae, toggleSelectAll: oe, pageSize: se, setPageSize: ce, setCurrentPage: le } = E({
453
+ data: e,
454
+ columns: t,
455
+ getRowId: n,
456
+ defaultPageSize: u,
457
+ actions: a,
458
+ bulkActions: o,
459
+ columnVisibility: w,
460
+ totalRows: f,
461
+ currentPage: p,
462
+ pageSize: m,
463
+ onPageChange: h,
464
+ onPageSizeChange: g,
465
+ sortColumn: _,
466
+ sortDirection: v,
467
+ onSortChange: y
468
+ }), ue = V && H.some((e) => e.fixed === "left"), de = D(z);
469
+ return /* @__PURE__ */ j("div", {
470
+ className: "space-y-4 [--k-radius-control:var(--k-radius-control-dense,0.5rem)] [--k-radius-surface:var(--k-radius-surface-dense,0.75rem)]",
471
+ children: [M.length > 0 && o !== void 0 && o.length > 0 && /* @__PURE__ */ A(Y, {
472
+ selectedRows: M,
473
+ setSelectedRows: N,
474
+ bulkActions: o
475
+ }), /* @__PURE__ */ j("div", {
476
+ className: "w-full bg-card rounded-surface border border-border overflow-hidden",
477
+ children: [/* @__PURE__ */ A("div", {
478
+ className: "overflow-x-auto",
479
+ children: /* @__PURE__ */ j("table", {
480
+ ref: z,
481
+ className: "w-full",
482
+ children: [/* @__PURE__ */ A(Z, {
483
+ hasBulkActions: V,
484
+ selectedRows: M,
485
+ totalItems: e.length,
486
+ toggleSelectAll: oe,
487
+ visibleColumnsArray: H,
488
+ draggableColumns: S,
489
+ resizableColumns: C,
490
+ columnWidths: F,
491
+ sortColumn: O,
492
+ sortDirection: k,
493
+ handleSort: G,
494
+ handleDragStart: X,
495
+ handleDragOver: Q,
496
+ handleDrop: $,
497
+ handleMouseDown: q,
498
+ hasActions: B,
499
+ bordered: x,
500
+ dense: b,
501
+ fixedColumns: de,
502
+ fixedSelection: ue,
503
+ fixedActions: T,
504
+ settingsNode: w ? /* @__PURE__ */ A(ie, {
505
+ columns: t,
506
+ visibleColumns: P,
507
+ toggleColumnVisibility: ne
508
+ }) : void 0
509
+ }), /* @__PURE__ */ A(J, {
510
+ bordered: x,
511
+ dense: b,
512
+ isLoading: s,
513
+ error: c,
514
+ colSpanCount: U,
515
+ messages: l?.messages,
516
+ paginatedData: W,
517
+ getRowId: n,
518
+ onRowClick: r,
519
+ onRowNavigate: i,
520
+ hasBulkActions: V,
521
+ selectedRows: M,
522
+ toggleRowSelection: ae,
523
+ visibleColumnsArray: H,
524
+ columnWidths: F,
525
+ hasActions: B || w,
526
+ actions: a,
527
+ columns: t,
528
+ resizableColumns: C,
529
+ fixedColumns: de
530
+ })]
531
+ })
532
+ }), /* @__PURE__ */ A(re, {
533
+ totalItems: f ?? e.length,
534
+ startIndex: L,
535
+ endIndex: R,
536
+ pageSize: se,
537
+ setPageSize: ce,
538
+ currentPage: ee,
539
+ setCurrentPage: le,
540
+ pageSizeOptions: d,
541
+ totalPages: I
542
+ })]
543
+ })]
544
+ });
545
+ }
546
+ //#endregion
547
+ //#region src/components/core/table/JsonTableOutput.tsx
548
+ var oe = ({ header: e, output: t }) => {
549
+ let [n, r] = O(!0), i = F(t), c = i !== null, l = () => /* @__PURE__ */ j("div", {
550
+ className: "flex items-center justify-between mb-2",
551
+ children: [/* @__PURE__ */ A("span", {
552
+ className: "font-medium text-sm",
553
+ children: e
554
+ }), /* @__PURE__ */ j("div", {
555
+ className: "flex items-center gap-2",
556
+ children: [/* @__PURE__ */ A(v, {
557
+ id: "table-mode",
558
+ checked: n,
559
+ onCheckedChange: r
560
+ }), /* @__PURE__ */ A(a, {
561
+ htmlFor: "table-mode",
562
+ className: "text-xs",
563
+ children: "Mode tableau"
564
+ })]
565
+ })]
566
+ }), u = ({ children: e }) => /* @__PURE__ */ A("div", {
567
+ className: "border rounded min-w-0 w-full",
568
+ children: /* @__PURE__ */ A(p, { children: e })
569
+ }), d = () => /* @__PURE__ */ A("pre", {
570
+ className: "text-xs bg-muted p-4 rounded overflow-x-auto whitespace-pre-wrap",
571
+ children: c && !n ? JSON.stringify(i, null, 2) : t
572
+ });
573
+ return t ? /* @__PURE__ */ j("div", {
574
+ className: "min-w-0 w-full",
575
+ children: [l(), (() => {
576
+ if (!c || !n) return /* @__PURE__ */ A(d, {});
577
+ if (Array.isArray(i) && i.length > 0 && P(i[0])) {
578
+ let e = i, t = Object.keys(e[0]);
579
+ return /* @__PURE__ */ j(u, { children: [/* @__PURE__ */ A(f, {
580
+ className: "bg-muted/50",
581
+ children: /* @__PURE__ */ A(_, { children: t.map((e) => /* @__PURE__ */ A(s, {
582
+ className: "font-medium",
583
+ children: e
584
+ }, e)) })
585
+ }), /* @__PURE__ */ A(o, { children: e.map((e, n) => /* @__PURE__ */ A(_, { children: t.map((t) => /* @__PURE__ */ A(m, {
586
+ className: "text-sm whitespace-pre-wrap",
587
+ children: N(e[t])
588
+ }, t)) }, n)) })] });
589
+ }
590
+ if (P(i)) {
591
+ let e = Object.entries(i);
592
+ return /* @__PURE__ */ j(u, { children: [/* @__PURE__ */ A(f, {
593
+ className: "bg-muted/50",
594
+ children: /* @__PURE__ */ j(_, { children: [/* @__PURE__ */ A(s, {
595
+ className: "font-medium",
596
+ children: "Propriété"
597
+ }), /* @__PURE__ */ A(s, {
598
+ className: "font-medium",
599
+ children: "Valeur"
600
+ })] })
601
+ }), /* @__PURE__ */ A(o, { children: e.map(([e, t]) => /* @__PURE__ */ j(_, { children: [/* @__PURE__ */ A(m, {
602
+ className: "font-medium text-sm",
603
+ children: e
604
+ }), /* @__PURE__ */ A(m, {
605
+ className: "text-sm whitespace-pre-wrap",
606
+ children: N(t)
607
+ })] }, e)) })] });
608
+ }
609
+ return /* @__PURE__ */ A(d, {});
610
+ })()]
611
+ }) : null;
612
+ };
613
+ //#endregion
614
+ export { Z as a, q as c, re as i, ae as n, Y as o, ie as r, J as s, oe as t };
@@ -0,0 +1,27 @@
1
+ import type { DataTableMessages } from "./DataTableMessages";
2
+ /**
3
+ * Options de comportement/présentation du `DataTable`, regroupées en un seul objet.
4
+ *
5
+ * Destinée à accueillir progressivement les réglages aujourd'hui passés à plat en props
6
+ * (bordered, colonnes figées…).
7
+ *
8
+ * Le paramètre générique `T` est conservé dès maintenant : les prochains réglages
9
+ * (rendu de ligne conditionnel, etc.) dépendront du type de la donnée.
10
+ */
11
+ export interface DataTableConfig<T> {
12
+ /** Réduit la hauteur des lignes pour un affichage compact. */
13
+ dense?: boolean;
14
+ /** Affiche les bordures entre colonnes. */
15
+ bordered?: boolean;
16
+ /** Active le glisser-déposer des colonnes. */
17
+ draggableColumns?: boolean;
18
+ /** Active le redimensionnement des colonnes. */
19
+ resizableColumns?: boolean;
20
+ /** Affiche le bouton de gestion de la visibilité des colonnes. */
21
+ columnVisibility?: boolean;
22
+ /** Fige la colonne des actions (et du réglage des colonnes) sur le bord droit. */
23
+ fixedActions?: boolean;
24
+ /** Clés i18n des messages d'état (vide, chargement). */
25
+ messages?: DataTableMessages;
26
+ }
27
+ //# sourceMappingURL=DataTableConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableConfig.d.ts","sourceRoot":"","sources":["../../src/types/DataTableConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Clés i18n des messages d'état du `DataTable`, résolues dans le namespace de
3
+ * l'application (comme `labelKey`/`titleKey`). Non fournies, le tableau retombe
4
+ * sur les libellés par défaut du package.
5
+ */
6
+ export interface DataTableMessages {
7
+ /** Clé i18n du message affiché quand le tableau ne contient aucune donnée. */
8
+ emptyKey?: string;
9
+ /** Clé i18n du message affiché pendant le chargement des données. */
10
+ loadingKey?: string;
11
+ }
12
+ //# sourceMappingURL=DataTableMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataTableMessages.d.ts","sourceRoot":"","sources":["../../src/types/DataTableMessages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -4,6 +4,8 @@ export * from "./ButtonVariantType";
4
4
  export * from "./ChartDatum";
5
5
  export * from "./ColumnDef";
6
6
  export * from "./ConfirmDialogConfig";
7
+ export * from "./DataTableConfig";
8
+ export * from "./DataTableMessages";
7
9
  export * from "./DateRangeValue";
8
10
  export * from "./FilterFieldConfig";
9
11
  export * from "./FilterSection";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.260",
3
+ "version": "0.0.261",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {