@krosoft/react 0.0.252 → 0.0.254

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.
Files changed (55) hide show
  1. package/dist/{AppActions-C_0YI75w.js → AppActions-BMq9aQrB.js} +1 -1
  2. package/dist/{AppSubTitle-tqqV9nuT.js → AppSubTitle-DIQetGjl.js} +1 -1
  3. package/dist/{ErrorAlert-BDqDHUUc.js → ErrorAlert-DClCk3Ey.js} +1 -1
  4. package/dist/{GenericForm-CWXT5wiv.js → GenericForm-D1TP41Gp.js} +6 -6
  5. package/dist/{ImageInput-CN2ozjpc.js → ImageInput-DnoBhP4X.js} +2 -2
  6. package/dist/{MultiSelect-BF0zL0B0.js → MultiSelect-O9AljNco.js} +2 -2
  7. package/dist/{SearchInput-BQyRXzCv.js → SearchInput-BEqCjP6R.js} +3 -3
  8. package/dist/{behavior-D3JNfIVJ.js → behavior-DDtrNBAq.js} +1 -1
  9. package/dist/{cards-Bkwz7WQM.js → cards-3sbUuHR0.js} +1 -1
  10. package/dist/{charts-CXhVUqLH.js → charts-CwT9AFWj.js} +1 -1
  11. package/dist/components/core/cards/index.js +1 -1
  12. package/dist/components/core/charts/index.js +1 -1
  13. package/dist/components/core/dialogs/index.js +3 -3
  14. package/dist/components/core/filters/index.js +5 -5
  15. package/dist/components/core/forms/index.js +1 -1
  16. package/dist/components/core/index.js +19 -19
  17. package/dist/components/core/inputs/index.js +3 -3
  18. package/dist/components/core/language/index.js +1 -1
  19. package/dist/components/core/layouts/index.js +5 -5
  20. package/dist/components/core/navbar/index.js +1 -1
  21. package/dist/components/core/states/index.js +2 -2
  22. package/dist/components/core/table/JsonTableOutput.d.ts +8 -0
  23. package/dist/components/core/table/JsonTableOutput.d.ts.map +1 -0
  24. package/dist/components/core/table/TableBody.d.ts +1 -1
  25. package/dist/components/core/table/TableBody.d.ts.map +1 -1
  26. package/dist/components/core/table/TableHeader.d.ts.map +1 -1
  27. package/dist/components/core/table/index.d.ts +1 -0
  28. package/dist/components/core/table/index.d.ts.map +1 -1
  29. package/dist/components/core/table/index.js +2 -2
  30. package/dist/components/core/tabs/index.js +4 -4
  31. package/dist/components/core/theme/index.js +1 -1
  32. package/dist/components/index.js +19 -19
  33. package/dist/components/ui/index.js +2 -2
  34. package/dist/{dialogs-BGHSClsq.js → dialogs-CVA3y-o4.js} +5 -5
  35. package/dist/hooks/behavior/index.js +1 -1
  36. package/dist/hooks/index.js +4 -4
  37. package/dist/hooks/ui/index.js +3 -3
  38. package/dist/hooks/ui/useLanguage.d.ts.map +1 -1
  39. package/dist/i18n/index.js +1 -1
  40. package/dist/i18n/krosoftLocales.d.ts +4 -0
  41. package/dist/i18n/krosoftLocales.d.ts.map +1 -1
  42. package/dist/{i18n-Dw99bRmg.js → i18n-DW5zKBEK.js} +6 -2
  43. package/dist/{language-BQpuOau0.js → language-Cn7U026J.js} +2 -2
  44. package/dist/{navbar-G9FexEW-.js → navbar-DLxNVUU9.js} +3 -3
  45. package/dist/{sheet-CRrYTZrl.js → sheet-B8mCfCPe.js} +1 -1
  46. package/dist/{states-N8-LjFng.js → states-BusGNKku.js} +2 -2
  47. package/dist/table-C4tXdSu3.js +644 -0
  48. package/dist/{theme-BGakUJ9c.js → theme-Ck_D5xtg.js} +2 -2
  49. package/dist/{ui-CmUIUFnk.js → ui-Dg7lq9J8.js} +2 -2
  50. package/dist/{ui-CiX0E_bn.js → ui-hvA1osvS.js} +1 -1
  51. package/dist/useLanguage-B1dusDJk.js +23 -0
  52. package/dist/{useTheme-DVfcJ-Qd.js → useTheme-D1APOG9I.js} +1 -1
  53. package/package.json +1 -1
  54. package/dist/table-D7PJi2IO.js +0 -582
  55. package/dist/useLanguage-DN3CuBv5.js +0 -19
@@ -2,10 +2,10 @@ import "./useScrollFade-D9kqJBDh.js";
2
2
  import "./useToast-UeDRLovh.js";
3
3
  import "./useMobile-pTQ8lWvt.js";
4
4
  import "./useNotifications-CyhTruIG.js";
5
- import "./useLanguage-DN3CuBv5.js";
5
+ import "./useLanguage-B1dusDJk.js";
6
6
  import "./useDocumentTitle-D7MywIeB.js";
7
7
  import "./useFixedColumns-DnzqhbfT.js";
8
- import "./useTheme-DVfcJ-Qd.js";
8
+ import "./useTheme-D1APOG9I.js";
9
9
  import { useCallback as e, useEffect as t, useState as n } from "react";
10
10
  //#region src/hooks/ui/useServerTable.ts
11
11
  function r(r, i = "nom", a = {}) {
@@ -3,7 +3,7 @@ import "./helpers/index.js";
3
3
  import "./chart-Dq3AIrue.js";
4
4
  import "./alert-REQGK9bR.js";
5
5
  import { c as t, s as n } from "./tooltip-B2dzyfs9.js";
6
- import "./sheet-CRrYTZrl.js";
6
+ import "./sheet-B8mCfCPe.js";
7
7
  import "./select-ULiTPOr5.js";
8
8
  import "./skeleton-D6Ga4BLw.js";
9
9
  import { t as r } from "./useScrollFade-D9kqJBDh.js";
@@ -0,0 +1,23 @@
1
+ import { t as e } from "./i18n-DW5zKBEK.js";
2
+ import { t } from "./useNotifications-CyhTruIG.js";
3
+ import { useTranslation as n } from "react-i18next";
4
+ //#region src/hooks/ui/useLanguage.ts
5
+ function r(r) {
6
+ let { i18n: i } = n(), { t: a } = e(), { showSuccess: o } = t(), s = i.language ?? "", c = s.split("-")[0], l = r.find((e) => e.value === s) ?? r.find((e) => e.value === c) ?? r[0], u = r.findIndex((e) => e.value === l?.value), d = r.length > 0 ? r[(u + 1) % r.length] : void 0, f = (e) => {
7
+ i.changeLanguage(e);
8
+ let t = e.split("-")[0], n = r.find((t) => t.value === e) ?? r.find((e) => e.value === t);
9
+ o(a("language.updatedTitle"), a("language.updatedMessage", { language: n?.label ?? e }));
10
+ };
11
+ return {
12
+ language: s,
13
+ languageOptions: r,
14
+ currentLanguageOption: l,
15
+ nextLanguageOption: d,
16
+ changeLanguage: f,
17
+ cycleLanguage: () => {
18
+ d && f(d.value);
19
+ }
20
+ };
21
+ }
22
+ //#endregion
23
+ export { r as t };
@@ -1,4 +1,4 @@
1
- import { t as e } from "./i18n-Dw99bRmg.js";
1
+ import { t as e } from "./i18n-DW5zKBEK.js";
2
2
  import { t } from "./useNotifications-CyhTruIG.js";
3
3
  import { useTheme as n } from "next-themes";
4
4
  //#region src/hooks/ui/useTheme.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.252",
3
+ "version": "0.0.254",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,582 +0,0 @@
1
- import { Ft as e, Gt as t, Mt as n, Nt as r, bn as i, jt as a } from "./ui-CiX0E_bn.js";
2
- import { s as o } from "./tooltip-B2dzyfs9.js";
3
- import { t as s } from "./i18n-Dw99bRmg.js";
4
- import { i as c, l, n as u, t as d, u as f } from "./select-ULiTPOr5.js";
5
- import { n as p, t as m } from "./useFixedColumns-DnzqhbfT.js";
6
- import "react";
7
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
8
- import { AlertTriangleIcon as v, ArrowDownIcon as y, ArrowUpDownIcon as b, ArrowUpIcon as x, ChevronLeftIcon as S, ChevronRightIcon as C, GripVerticalIcon as w, Loader2Icon as T, MoreVerticalIcon as E, SettingsIcon as D } from "lucide-react";
9
- import { useNavigate as O } from "react-router-dom";
10
- //#region src/constants/datatable.ts
11
- var k = [
12
- 5,
13
- 10,
14
- 30,
15
- 50,
16
- 100
17
- ], A = k[1];
18
- //#endregion
19
- //#region src/components/core/table/TableActions.tsx
20
- function j({ actions: n, row: i }) {
21
- let s = n.filter((e) => e.visible === void 0 || e.visible(i));
22
- if (s.length === 0) return null;
23
- let c = s.filter((e) => e.overflow !== !0), l = s.filter((e) => e.overflow === !0);
24
- return /* @__PURE__ */ _("div", {
25
- className: "flex items-center justify-end gap-1",
26
- children: [c.map((e, t) => {
27
- let n = e.icon;
28
- return /* @__PURE__ */ _(o, {
29
- variant: e.variant ?? "ghost",
30
- size: "sm",
31
- disabled: e.disabled?.(i) ?? !1,
32
- className: `h-7 px-2 text-muted-foreground hover:text-foreground ${e.className ?? ""}`,
33
- onClick: (t) => {
34
- t.stopPropagation(), e.onClick(i);
35
- },
36
- children: [n !== void 0 && /* @__PURE__ */ g(n, { className: "size-3.5" }), e.label]
37
- }, t);
38
- }), l.length > 0 && /* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(t, {
39
- asChild: !0,
40
- children: /* @__PURE__ */ g(o, {
41
- variant: "ghost",
42
- size: "icon",
43
- className: "h-7 w-7 text-muted-foreground hover:text-foreground",
44
- children: /* @__PURE__ */ g(E, { className: "size-3.5" })
45
- })
46
- }), /* @__PURE__ */ g(r, {
47
- align: "end",
48
- onClick: (e) => {
49
- e.stopPropagation();
50
- },
51
- children: l.map((t, n) => {
52
- let r = t.icon;
53
- return /* @__PURE__ */ _(e, {
54
- disabled: t.disabled?.(i) ?? !1,
55
- onClick: () => {
56
- t.onClick(i);
57
- },
58
- className: t.className,
59
- children: [r !== void 0 && /* @__PURE__ */ g("span", {
60
- className: "mr-2 size-4 flex items-center justify-center",
61
- children: /* @__PURE__ */ g(r, { className: "size-4" })
62
- }), t.label]
63
- }, n);
64
- })
65
- })] })]
66
- });
67
- }
68
- //#endregion
69
- //#region src/components/core/table/columnAlignment.ts
70
- var M = {
71
- left: "text-left",
72
- center: "text-center",
73
- right: "text-right"
74
- };
75
- function N(e) {
76
- if (e.align !== void 0) return e.align;
77
- let t = (e.className ?? "").split(/\s+/);
78
- return t.includes("text-right") ? "right" : t.includes("text-center") ? "center" : "left";
79
- }
80
- function P(e) {
81
- return M[e];
82
- }
83
- //#endregion
84
- //#region src/components/core/table/fixedColumns.ts
85
- var F = "__selection__", I = "__actions__", L = {
86
- left: "border-r border-gray-200 dark:border-gray-800",
87
- right: "border-l border-gray-200 dark:border-gray-800"
88
- };
89
- function R(e, t) {
90
- if (e === void 0) return {
91
- className: "relative",
92
- style: {}
93
- };
94
- let n = t === "header";
95
- return {
96
- className: [
97
- "sticky bg-card dark:bg-gray-950",
98
- n ? "z-20" : "z-10",
99
- "before:absolute before:inset-0 before:-z-10 before:pointer-events-none",
100
- n ? "before:bg-muted/50 dark:before:bg-gray-900/50" : "group-hover:before:bg-muted/50 dark:group-hover:before:bg-gray-900/50",
101
- e.isEdge ? L[e.side] : ""
102
- ].filter(Boolean).join(" "),
103
- style: e.side === "left" ? { left: e.offset } : { right: e.offset }
104
- };
105
- }
106
- //#endregion
107
- //#region src/components/core/table/TableBody.tsx
108
- function z({ isLoading: e, error: t, colSpanCount: n, noDataMessage: r, paginatedData: a, getRowId: o, onRowClick: c, onRowNavigate: l, hasBulkActions: u, selectedRows: d, toggleRowSelection: f, visibleColumnsArray: p, columnWidths: m, hasActions: h, actions: y, columns: b, bordered: x = !1, dense: S = !1, resizableColumns: C = !1, fixedColumns: w = {} }) {
109
- let { t: E } = s(), D = O(), k = (e, t) => {
110
- let n = b.find((e) => e.key === t);
111
- if (n?.renderCell !== void 0) return n.renderCell(e);
112
- let r = e[t];
113
- return /* @__PURE__ */ g("span", {
114
- className: "text-sm truncate",
115
- children: r == null ? "-" : String(r)
116
- });
117
- };
118
- if (e) return /* @__PURE__ */ g("tbody", {
119
- className: "divide-y divide-gray-200 dark:divide-gray-800",
120
- children: /* @__PURE__ */ g("tr", { children: /* @__PURE__ */ g("td", {
121
- colSpan: n,
122
- className: "py-8 text-center",
123
- children: /* @__PURE__ */ _("div", {
124
- className: "flex flex-col items-center justify-center gap-2 text-muted-foreground",
125
- children: [/* @__PURE__ */ g(T, { className: "h-6 w-6 animate-spin text-primary" }), /* @__PURE__ */ g("span", {
126
- className: "text-sm",
127
- children: E("states.loading")
128
- })]
129
- })
130
- }) })
131
- });
132
- if (t) return /* @__PURE__ */ g("tbody", {
133
- className: "divide-y divide-gray-200 dark:divide-gray-800",
134
- children: /* @__PURE__ */ g("tr", { children: /* @__PURE__ */ g("td", {
135
- colSpan: n,
136
- className: "py-8 text-center",
137
- children: /* @__PURE__ */ _("div", {
138
- className: "flex flex-col items-center justify-center gap-2 text-destructive",
139
- children: [/* @__PURE__ */ g(v, { className: "h-6 w-6" }), /* @__PURE__ */ g("span", {
140
- className: "text-sm",
141
- children: t
142
- })]
143
- })
144
- }) })
145
- });
146
- if (a.length === 0) return /* @__PURE__ */ g("tbody", {
147
- className: "divide-y divide-gray-200 dark:divide-gray-800",
148
- children: /* @__PURE__ */ g("tr", { children: /* @__PURE__ */ g("td", {
149
- colSpan: n,
150
- className: "py-8 text-center text-sm text-muted-foreground",
151
- children: r ?? E("states.noResult")
152
- }) })
153
- });
154
- let A = R(w[F], "body"), M = R(w[I], "body"), L = l !== void 0 || c !== void 0, z = (e, t) => {
155
- if (l !== void 0) {
156
- let n = l(e);
157
- t.ctrlKey || t.metaKey ? window.open(n, "_blank") : D(n);
158
- } else c?.(e, t);
159
- };
160
- return /* @__PURE__ */ g("tbody", {
161
- className: "divide-y divide-gray-200 dark:divide-gray-800",
162
- children: a.map((e) => {
163
- let t = o(e);
164
- return /* @__PURE__ */ _("tr", {
165
- className: `group hover:bg-muted/50 dark:hover:bg-gray-900/50 transition-colors ${L ? "cursor-pointer" : ""}`,
166
- onClick: (t) => {
167
- z(e, t);
168
- },
169
- children: [
170
- u ? /* @__PURE__ */ g("td", {
171
- className: `p-1 text-center align-middle ${A.className}`,
172
- style: {
173
- width: "48px",
174
- minWidth: "48px",
175
- maxWidth: "48px",
176
- ...A.style
177
- },
178
- onClick: (e) => {
179
- e.stopPropagation();
180
- },
181
- children: /* @__PURE__ */ g("div", {
182
- className: "flex items-center justify-center",
183
- children: /* @__PURE__ */ g(i, {
184
- checked: d.includes(t),
185
- onCheckedChange: () => {
186
- f(t);
187
- }
188
- })
189
- })
190
- }) : null,
191
- p.map((t, n) => {
192
- let r = n === p.length - 1, i = R(w[t.key], "body");
193
- return /* @__PURE__ */ g("td", {
194
- className: `px-2 ${S ? "py-2" : "py-4"} ${P(N(t))} ${i.className} ${x && !r ? "border-r border-gray-100 dark:border-gray-800" : ""} ${t.className ?? ""}`,
195
- style: {
196
- ...C ? { width: m[t.key] } : { minWidth: m[t.key] },
197
- ...i.style
198
- },
199
- children: /* @__PURE__ */ g("div", {
200
- className: "w-full h-full",
201
- children: k(e, t.key)
202
- })
203
- }, t.key);
204
- }),
205
- h ? /* @__PURE__ */ g("td", {
206
- className: `p-1 text-right align-middle whitespace-nowrap ${M.className}`,
207
- style: {
208
- minWidth: "32px",
209
- ...M.style
210
- },
211
- onClick: (e) => {
212
- e.stopPropagation();
213
- },
214
- children: y !== void 0 && y.length > 0 ? /* @__PURE__ */ g("div", {
215
- className: "flex items-center justify-end",
216
- children: /* @__PURE__ */ g(j, {
217
- actions: y,
218
- row: e
219
- })
220
- }) : null
221
- }) : null
222
- ]
223
- }, t);
224
- })
225
- });
226
- }
227
- //#endregion
228
- //#region src/components/core/table/TableBulkActions.tsx
229
- function B({ selectedRows: e, setSelectedRows: t, bulkActions: n }) {
230
- return /* @__PURE__ */ _("div", {
231
- className: "bg-muted/60 dark:bg-gray-900/60 border border-border px-3 py-1.5 flex items-center justify-between rounded-surface",
232
- children: [/* @__PURE__ */ _("div", {
233
- className: "flex items-center gap-4",
234
- children: [/* @__PURE__ */ _("span", {
235
- className: "text-sm font-medium text-primary ml-1",
236
- children: [e.length, " sélectionné(s)"]
237
- }), /* @__PURE__ */ g("div", {
238
- className: "flex items-center gap-2",
239
- children: n.map((n, r) => {
240
- let i = n.icon;
241
- return /* @__PURE__ */ _(o, {
242
- variant: "outline",
243
- size: "sm",
244
- onClick: () => {
245
- n.onClick(e, () => {
246
- t([]);
247
- });
248
- },
249
- 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"}`,
250
- children: [i !== void 0 && /* @__PURE__ */ g("span", {
251
- className: "mr-1.5 flex items-center justify-center",
252
- children: /* @__PURE__ */ g(i, { className: "h-3.5 w-3.5" })
253
- }), n.label]
254
- }, r);
255
- })
256
- })]
257
- }), /* @__PURE__ */ g(o, {
258
- variant: "ghost",
259
- size: "sm",
260
- onClick: () => {
261
- t([]);
262
- },
263
- className: "text-xs text-muted-foreground hover:text-foreground h-7 px-2",
264
- children: "Désélectionner"
265
- })]
266
- });
267
- }
268
- //#endregion
269
- //#region src/components/core/table/TableHeader.tsx
270
- var V = {
271
- left: "justify-start",
272
- center: "justify-center",
273
- right: "justify-end"
274
- };
275
- function H({ hasBulkActions: e, selectedRows: t, totalItems: n, toggleSelectAll: r, visibleColumnsArray: a, draggableColumns: o, resizableColumns: s, columnWidths: c, sortColumn: l, sortDirection: u, handleSort: d, handleDragStart: f, handleDragOver: p, handleDrop: m, handleMouseDown: h, hasActions: v, settingsNode: S, bordered: C = !1, dense: T = !1, fixedColumns: E = {}, fixedSelection: D = !1, fixedActions: O = !1 }) {
276
- let k = !1;
277
- t.length === n && n > 0 ? k = !0 : t.length > 0 && (k = "indeterminate");
278
- let A = (e) => e.sortable === !0 ? l === e.key ? g(u === "asc" ? x : y, { className: "size-3.5 text-foreground" }) : /* @__PURE__ */ g(b, { className: "size-3.5 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors" }) : null, j = (e, t) => {
279
- let n = t !== !1 && e.fixed === void 0, r = e.sortable === !0, i = R(E[e.key], "header"), a = N(e), o = A(e);
280
- return /* @__PURE__ */ _("th", {
281
- "data-column-key": e.key,
282
- "data-fixed-side": e.fixed,
283
- className: [
284
- `px-2 ${T ? "py-2" : "py-4"} text-sm font-medium text-gray-900 dark:text-gray-100 group`,
285
- P(a),
286
- i.className,
287
- C ? "border-r border-gray-200 dark:border-gray-800" : "",
288
- r ? "cursor-pointer select-none" : "",
289
- e.className ?? ""
290
- ].filter(Boolean).join(" "),
291
- style: {
292
- ...s ? { width: c[e.key] } : { minWidth: c[e.key] },
293
- ...i.style
294
- },
295
- draggable: n,
296
- onClick: () => {
297
- d(e.key);
298
- },
299
- onDragStart: (t) => {
300
- n ? f(t, e.key) : t.preventDefault();
301
- },
302
- onDragOver: (t) => {
303
- p(t, e.key);
304
- },
305
- onDrop: (t) => {
306
- m(t, e.key);
307
- },
308
- children: [/* @__PURE__ */ _("div", {
309
- className: `flex items-center gap-1 ${V[a]} ${s ? "pr-2" : ""}`,
310
- children: [
311
- n ? /* @__PURE__ */ g(w, { className: "size-4 text-gray-400 cursor-grab dark:text-gray-300 shrink-0" }) : null,
312
- /* @__PURE__ */ g("span", {
313
- className: "truncate",
314
- children: e.label
315
- }),
316
- o === null ? null : /* @__PURE__ */ g("span", {
317
- className: "ml-1 shrink-0",
318
- children: o
319
- })
320
- ]
321
- }), s ? /* @__PURE__ */ g("div", {
322
- 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",
323
- onMouseDown: (t) => {
324
- h(t, e.key);
325
- }
326
- }) : null]
327
- }, e.key);
328
- }, M = R(E[F], "header"), L = R(E[I], "header");
329
- return /* @__PURE__ */ g("thead", {
330
- className: "bg-muted/50 dark:bg-gray-900/50 border-b border-gray-200 dark:border-gray-800",
331
- children: /* @__PURE__ */ _("tr", { children: [
332
- e ? /* @__PURE__ */ g("th", {
333
- "data-column-key": F,
334
- "data-fixed-side": D ? "left" : void 0,
335
- className: `p-1 text-center align-middle ${M.className}`,
336
- style: {
337
- width: "48px",
338
- minWidth: "48px",
339
- maxWidth: "48px",
340
- ...M.style
341
- },
342
- children: /* @__PURE__ */ g("div", {
343
- className: "flex items-center justify-center",
344
- children: /* @__PURE__ */ g(i, {
345
- checked: k,
346
- onCheckedChange: r
347
- })
348
- })
349
- }) : null,
350
- a.map((e) => j(e, o)),
351
- v || S !== void 0 ? /* @__PURE__ */ g("th", {
352
- "data-column-key": I,
353
- "data-fixed-side": O ? "right" : void 0,
354
- className: `p-1 text-right align-middle ${L.className}`,
355
- style: {
356
- minWidth: "32px",
357
- ...L.style
358
- },
359
- children: S
360
- }) : null
361
- ] })
362
- });
363
- }
364
- //#endregion
365
- //#region src/components/core/table/TablePagination.tsx
366
- var U = "…";
367
- function W(e, t) {
368
- return Array.from({ length: t - e + 1 }, (t, n) => e + n);
369
- }
370
- function G(e, t, n = 1) {
371
- if (n * 2 + 5 >= t) return W(1, t);
372
- let r = Math.max(e - n, 1), i = Math.min(e + n, t), a = r > 2, o = i < t - 1;
373
- return !a && o ? [
374
- ...W(1, n + 2),
375
- U,
376
- t
377
- ] : a && !o ? [
378
- 1,
379
- U,
380
- ...W(t - (n + 2) + 1, t)
381
- ] : [
382
- 1,
383
- U,
384
- ...W(r, i),
385
- U,
386
- t
387
- ];
388
- }
389
- function K({ totalItems: e, startIndex: t, endIndex: n, pageSize: r, setPageSize: i, currentPage: a, setCurrentPage: p, pageSizeOptions: m, totalPages: v }) {
390
- let { t: y } = s(), b = G(a, v);
391
- return /* @__PURE__ */ _("div", {
392
- 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",
393
- children: [
394
- /* @__PURE__ */ _("div", {
395
- className: "text-sm text-muted-foreground justify-self-start",
396
- children: [
397
- e === 0 ? "0" : `${String(t + 1)} - ${String(n)}`,
398
- " sur ",
399
- e
400
- ]
401
- }),
402
- /* @__PURE__ */ g("div", {
403
- className: "flex items-center justify-center gap-1",
404
- children: v > 1 && /* @__PURE__ */ _(h, { children: [
405
- /* @__PURE__ */ g(o, {
406
- variant: "ghost",
407
- size: "icon",
408
- className: "h-8 w-8 rounded-control",
409
- onClick: () => {
410
- p((e) => Math.max(1, e - 1));
411
- },
412
- disabled: a === 1,
413
- "aria-label": y("table.previousPage"),
414
- children: /* @__PURE__ */ g(S, { className: "size-4" })
415
- }),
416
- b.map((e, t) => e === U ? /* @__PURE__ */ g("span", {
417
- className: "flex h-8 w-8 items-center justify-center text-sm text-muted-foreground",
418
- children: U
419
- }, `dots-${String(t)}`) : /* @__PURE__ */ g(o, {
420
- variant: e === a ? "default" : "ghost",
421
- size: "icon",
422
- className: "h-8 w-8 rounded-control text-sm",
423
- onClick: () => {
424
- p(e);
425
- },
426
- "aria-current": e === a ? "page" : void 0,
427
- children: e
428
- }, e)),
429
- /* @__PURE__ */ g(o, {
430
- variant: "ghost",
431
- size: "icon",
432
- className: "h-8 w-8 rounded-control",
433
- onClick: () => {
434
- p((e) => Math.min(v, e + 1));
435
- },
436
- disabled: a === v,
437
- "aria-label": y("table.nextPage"),
438
- children: /* @__PURE__ */ g(C, { className: "size-4" })
439
- })
440
- ] })
441
- }),
442
- /* @__PURE__ */ g("div", {
443
- className: "justify-self-end",
444
- children: /* @__PURE__ */ _(d, {
445
- value: String(r),
446
- onValueChange: (e) => {
447
- i(Number(e)), p(1);
448
- },
449
- children: [/* @__PURE__ */ g(l, {
450
- className: "h-8 w-[110px] text-sm",
451
- children: /* @__PURE__ */ g(f, {})
452
- }), /* @__PURE__ */ g(u, { children: m.map((e) => /* @__PURE__ */ _(c, {
453
- value: String(e),
454
- children: [e, " / page"]
455
- }, e)) })]
456
- })
457
- })
458
- ]
459
- });
460
- }
461
- //#endregion
462
- //#region src/components/core/table/TableSettings.tsx
463
- function q({ columns: e, visibleColumns: i, toggleColumnVisibility: s }) {
464
- return /* @__PURE__ */ _(a, { children: [/* @__PURE__ */ g(t, {
465
- asChild: !0,
466
- children: /* @__PURE__ */ g(o, {
467
- variant: "outline",
468
- size: "sm",
469
- className: "size-7 p-0 bg-white hover:bg-gray-100 dark:bg-gray-900 shadow-sm border-gray-200 dark:border-gray-800",
470
- children: /* @__PURE__ */ g(D, { className: "size-3.5 text-gray-600 dark:text-gray-300" })
471
- })
472
- }), /* @__PURE__ */ g(r, {
473
- align: "end",
474
- className: "w-56",
475
- children: e.map((e) => /* @__PURE__ */ g(n, {
476
- checked: i.has(e.key),
477
- onCheckedChange: () => {
478
- s(e.key);
479
- },
480
- children: e.label
481
- }, e.key))
482
- })] });
483
- }
484
- //#endregion
485
- //#region src/components/core/table/DataTable.tsx
486
- function J({ 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: h = !1, fixedActions: v = !1, noDataMessage: y, defaultPageSize: b = A, pageSizeOptions: x = k, totalRows: S, currentPage: C, pageSize: w, onPageChange: T, onPageSizeChange: E, sortColumn: D, sortDirection: O, onSortChange: j }) {
487
- let { sortColumn: M, sortDirection: N, selectedRows: P, setSelectedRows: F, visibleColumns: I, columnWidths: L, safeCurrentPage: R, totalPages: V, startIndex: U, endIndex: W, tableRef: G, hasActions: J, hasBulkActions: Y, visibleColumnsArray: X, colSpanCount: Z, paginatedData: Q, handleSort: ee, handleMouseDown: te, handleDragStart: ne, handleDragOver: re, handleDrop: ie, toggleColumnVisibility: ae, toggleRowSelection: oe, toggleSelectAll: se, pageSize: ce, setPageSize: le, setCurrentPage: ue } = p({
488
- data: e,
489
- columns: t,
490
- getRowId: n,
491
- defaultPageSize: b,
492
- actions: a,
493
- bulkActions: o,
494
- columnVisibility: l,
495
- totalRows: S,
496
- currentPage: C,
497
- pageSize: w,
498
- onPageChange: T,
499
- onPageSizeChange: E,
500
- sortColumn: D,
501
- sortDirection: O,
502
- onSortChange: j
503
- }), de = Y && X.some((e) => e.fixed === "left"), $ = m(G);
504
- return /* @__PURE__ */ _("div", {
505
- className: "space-y-4 [--k-radius-control:var(--k-radius-control-dense,0.5rem)] [--k-radius-surface:var(--k-radius-surface-dense,0.75rem)]",
506
- children: [P.length > 0 && o !== void 0 && o.length > 0 && /* @__PURE__ */ g(B, {
507
- selectedRows: P,
508
- setSelectedRows: F,
509
- bulkActions: o
510
- }), /* @__PURE__ */ _("div", {
511
- className: "w-full bg-card dark:bg-gray-950 rounded-surface border border-gray-200 dark:border-gray-800 overflow-hidden",
512
- children: [/* @__PURE__ */ g("div", {
513
- className: "overflow-x-auto",
514
- children: /* @__PURE__ */ _("table", {
515
- ref: G,
516
- className: "w-full",
517
- children: [/* @__PURE__ */ g(H, {
518
- hasBulkActions: Y,
519
- selectedRows: P,
520
- totalItems: e.length,
521
- toggleSelectAll: se,
522
- visibleColumnsArray: X,
523
- draggableColumns: s,
524
- resizableColumns: c,
525
- columnWidths: L,
526
- sortColumn: M,
527
- sortDirection: N,
528
- handleSort: ee,
529
- handleDragStart: ne,
530
- handleDragOver: re,
531
- handleDrop: ie,
532
- handleMouseDown: te,
533
- hasActions: J,
534
- bordered: f,
535
- dense: h,
536
- fixedColumns: $,
537
- fixedSelection: de,
538
- fixedActions: v,
539
- settingsNode: l ? /* @__PURE__ */ g(q, {
540
- columns: t,
541
- visibleColumns: I,
542
- toggleColumnVisibility: ae
543
- }) : void 0
544
- }), /* @__PURE__ */ g(z, {
545
- bordered: f,
546
- dense: h,
547
- isLoading: u,
548
- error: d,
549
- colSpanCount: Z,
550
- noDataMessage: y,
551
- paginatedData: Q,
552
- getRowId: n,
553
- onRowClick: r,
554
- onRowNavigate: i,
555
- hasBulkActions: Y,
556
- selectedRows: P,
557
- toggleRowSelection: oe,
558
- visibleColumnsArray: X,
559
- columnWidths: L,
560
- hasActions: J || l,
561
- actions: a,
562
- columns: t,
563
- resizableColumns: c,
564
- fixedColumns: $
565
- })]
566
- })
567
- }), /* @__PURE__ */ g(K, {
568
- totalItems: S ?? e.length,
569
- startIndex: U,
570
- endIndex: W,
571
- pageSize: ce,
572
- setPageSize: le,
573
- currentPage: R,
574
- setCurrentPage: ue,
575
- pageSizeOptions: x,
576
- totalPages: V
577
- })]
578
- })]
579
- });
580
- }
581
- //#endregion
582
- export { B as a, F as c, N as d, j as f, H as i, R as l, q as n, z as o, K as r, I as s, J as t, P as u };
@@ -1,19 +0,0 @@
1
- import { useTranslation as e } from "react-i18next";
2
- //#region src/hooks/ui/useLanguage.ts
3
- function t(t) {
4
- let { i18n: n } = e(), r = n.language ?? "", i = r.split("-")[0], a = t.find((e) => e.value === r) ?? t.find((e) => e.value === i) ?? t[0], o = t.findIndex((e) => e.value === a?.value), s = t.length > 0 ? t[(o + 1) % t.length] : void 0, c = (e) => {
5
- n.changeLanguage(e);
6
- };
7
- return {
8
- language: r,
9
- languageOptions: t,
10
- currentLanguageOption: a,
11
- nextLanguageOption: s,
12
- changeLanguage: c,
13
- cycleLanguage: () => {
14
- s && c(s.value);
15
- }
16
- };
17
- }
18
- //#endregion
19
- export { t };