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