@krosoft/react 0.0.218 → 0.0.220

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 (88) hide show
  1. package/README.md +31 -0
  2. package/dist/{AppActions-BCXERyyB.js → AppActions-BFmagl91.js} +1 -1
  3. package/dist/{AppSubTitle-H8ElNObI.js → AppSubTitle-BMQMoehZ.js} +1 -1
  4. package/dist/AppVerticalTabs-0DrrDO3S.js +101 -0
  5. package/dist/{ConfirmationDialog-BmxaMEYz.js → ConfirmationDialog-CFsh-Eui.js} +62 -61
  6. package/dist/DataTable-Cpbp6yse.js +551 -0
  7. package/dist/ErrorAlert-D_203tKa.js +21 -0
  8. package/dist/ErrorState-DfJ009uc.js +12 -0
  9. package/dist/GenericForm-q9dvYl_h.js +342 -0
  10. package/dist/ImageInput-BYXz8wM1.js +68 -0
  11. package/dist/{KpiCardsLayout-XZTxB8FV.js → KpiCardsLayout-B-lMaUMA.js} +4 -4
  12. package/dist/{MultiSelect-Cj8vgAXJ.js → MultiSelect-Dkz1dgXo.js} +52 -51
  13. package/dist/{PieChart-D6y5EQnh.js → PieChart-bDy_V9Xt.js} +82 -81
  14. package/dist/SearchInput-CJ2YZpmB.js +244 -0
  15. package/dist/{SkeletonCards-CYo_lvKx.js → SkeletonCards-Bg2ygjwy.js} +1 -1
  16. package/dist/{TableFilter-DbnGaGKL.js → TableFilter-u6F06nMx.js} +133 -130
  17. package/dist/ThemeSelector-BRpEgvX8.js +49 -0
  18. package/dist/Topbar-bIyAunNd.js +318 -0
  19. package/dist/components/core/cards/index.js +1 -1
  20. package/dist/components/core/charts/ChartCard.d.ts.map +1 -1
  21. package/dist/components/core/charts/index.js +1 -1
  22. package/dist/components/core/dialogs/FormDialog.d.ts.map +1 -1
  23. package/dist/components/core/dialogs/index.js +2 -2
  24. package/dist/components/core/filters/ActiveFilters.d.ts.map +1 -1
  25. package/dist/components/core/filters/AdvancedFilters.d.ts.map +1 -1
  26. package/dist/components/core/filters/FilterField.d.ts.map +1 -1
  27. package/dist/components/core/filters/SearchableFilterPill.d.ts.map +1 -1
  28. package/dist/components/core/filters/TableFilter.d.ts.map +1 -1
  29. package/dist/components/core/filters/index.js +1 -1
  30. package/dist/components/core/forms/GenericForm.d.ts.map +1 -1
  31. package/dist/components/core/forms/index.js +1 -1
  32. package/dist/components/core/index.js +18 -18
  33. package/dist/components/core/inputs/DateRangePicker.d.ts.map +1 -1
  34. package/dist/components/core/inputs/ImageInput.d.ts.map +1 -1
  35. package/dist/components/core/inputs/MultiSelect.d.ts.map +1 -1
  36. package/dist/components/core/inputs/SearchInput.d.ts +1 -1
  37. package/dist/components/core/inputs/SearchInput.d.ts.map +1 -1
  38. package/dist/components/core/inputs/SearchableSelect.d.ts.map +1 -1
  39. package/dist/components/core/inputs/index.js +3 -3
  40. package/dist/components/core/layouts/index.js +3 -3
  41. package/dist/components/core/navbar/GlobalSearch.d.ts.map +1 -1
  42. package/dist/components/core/navbar/Sidebar.d.ts.map +1 -1
  43. package/dist/components/core/navbar/index.js +1 -1
  44. package/dist/components/core/states/ErrorAlert.d.ts.map +1 -1
  45. package/dist/components/core/states/ErrorState.d.ts.map +1 -1
  46. package/dist/components/core/states/index.js +2 -2
  47. package/dist/components/core/table/DataTable.d.ts.map +1 -1
  48. package/dist/components/core/table/TableBody.d.ts +1 -1
  49. package/dist/components/core/table/TableBody.d.ts.map +1 -1
  50. package/dist/components/core/table/TablePagination.d.ts.map +1 -1
  51. package/dist/components/core/table/index.js +1 -1
  52. package/dist/components/core/tabs/AppVerticalTabs.d.ts.map +1 -1
  53. package/dist/components/core/tabs/index.js +1 -1
  54. package/dist/components/core/theme/ThemeSelector.d.ts.map +1 -1
  55. package/dist/components/core/theme/index.js +1 -1
  56. package/dist/components/index.js +18 -18
  57. package/dist/components/ui/command.d.ts.map +1 -1
  58. package/dist/components/ui/index.js +1 -1
  59. package/dist/hooks/behavior/index.js +1 -1
  60. package/dist/hooks/behavior/useConfirmDeleteDialog.d.ts +1 -1
  61. package/dist/hooks/behavior/useConfirmDeleteDialog.d.ts.map +1 -1
  62. package/dist/hooks/index.js +2 -2
  63. package/dist/hooks/ui/index.js +1 -1
  64. package/dist/hooks/ui/useTheme.d.ts.map +1 -1
  65. package/dist/i18n/index.d.ts +3 -0
  66. package/dist/i18n/index.d.ts.map +1 -0
  67. package/dist/i18n/index.js +7 -0
  68. package/dist/i18n/krosoftLocales.d.ts +175 -0
  69. package/dist/i18n/krosoftLocales.d.ts.map +1 -0
  70. package/dist/i18n/useKrosoftTranslation.d.ts +15 -0
  71. package/dist/i18n/useKrosoftTranslation.d.ts.map +1 -0
  72. package/dist/providers/index.js +1 -1
  73. package/dist/{sheet-BQmtrGf2.js → sheet-CDqLa-FP.js} +105 -108
  74. package/dist/useKrosoftTranslation-DdcylBY2.js +43 -0
  75. package/dist/usePage-Bhb81ffo.js +82 -0
  76. package/dist/useTheme-Cmw14Zxi.js +25 -0
  77. package/package.json +1 -1
  78. package/dist/AppVerticalTabs-aJmAVu6F.js +0 -100
  79. package/dist/DataTable-0-lae9KY.js +0 -550
  80. package/dist/ErrorAlert-SrIcU1mM.js +0 -17
  81. package/dist/ErrorState-CmaxuJyW.js +0 -8
  82. package/dist/GenericForm-DJR7PD-i.js +0 -341
  83. package/dist/ImageInput-DYe2XPNZ.js +0 -67
  84. package/dist/SearchInput-oeq0NBIc.js +0 -251
  85. package/dist/ThemeSelector-BFC37dSl.js +0 -48
  86. package/dist/Topbar-DUq-UeR0.js +0 -306
  87. package/dist/usePage-BFE9lxI1.js +0 -84
  88. package/dist/useTheme-CSr_h5xJ.js +0 -24
@@ -1,341 +0,0 @@
1
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
2
- import { I as W } from "./ImageInput-DYe2XPNZ.js";
3
- import { A as T } from "./AppSubTitle-H8ElNObI.js";
4
- import { M as q } from "./MultiSelect-Cj8vgAXJ.js";
5
- import { ai as D, al as J, am as L, an as Q, aj as j, ao as X, bm as Y, E as $ } from "./toggle-group-DLLrEwv2.js";
6
- import "./alert-B9F1N9Qk.js";
7
- import "@radix-ui/react-aspect-ratio";
8
- import { B as A } from "./tooltip-DVeqVwqV.js";
9
- import { C as F, d as ee, a as te } from "./chart-DntJZGxB.js";
10
- import "@radix-ui/react-collapsible";
11
- import { I as k } from "./sheet-BQmtrGf2.js";
12
- import "lucide-react";
13
- import "react-resizable-panels";
14
- import { c as i } from "./tailwind.helper-B6yFEsav.js";
15
- import { S as re, h as ae, i as se, a as ne, c as le } from "./select-BpjFWqAY.js";
16
- import "next-themes";
17
- import "sonner";
18
- import { u as ce } from "./useToast-BFTk4lWz.js";
19
- import { zodResolver as oe } from "@hookform/resolvers/zod";
20
- import { useState as C } from "react";
21
- import { useForm as ue } from "react-hook-form";
22
- import { useTranslation as ie } from "react-i18next";
23
- import { z as b } from "zod";
24
- const Be = ({
25
- schema: h,
26
- isLoading: S,
27
- error: N,
28
- onSubmit: M,
29
- onCancel: f,
30
- initialData: y,
31
- disabled: x = !1,
32
- renderActions: P = !0,
33
- onRegisterSubmit: K,
34
- defaultCols: z = 4
35
- }) => {
36
- const { t: u } = ie(), { toast: E } = ce(), [g, w] = C(!1), [me, I] = C({});
37
- if (!h) return null;
38
- const B = (e) => {
39
- switch (e) {
40
- case 1:
41
- return "md:col-span-1 col-span-4";
42
- case 2:
43
- return "md:col-span-2 col-span-4";
44
- case 3:
45
- return "md:col-span-3 col-span-4";
46
- case 4:
47
- default:
48
- return "md:col-span-4 col-span-4";
49
- }
50
- }, O = (() => {
51
- const e = {};
52
- return h.sections.forEach((t) => {
53
- t.fields.forEach((r) => {
54
- if (r.rules)
55
- e[r.key] = r.rules(b);
56
- else
57
- switch (r.type) {
58
- case "checkbox":
59
- e[r.key] = b.boolean().nullable().optional();
60
- break;
61
- case "html":
62
- break;
63
- case "text":
64
- case "textarea":
65
- case "number":
66
- case "date":
67
- case "time":
68
- case "select":
69
- case "multiSelect":
70
- case "color":
71
- case "image":
72
- e[r.key] = b.string().nullable().optional();
73
- break;
74
- }
75
- });
76
- }), b.object(e);
77
- })(), d = ue({
78
- resolver: oe(O),
79
- defaultValues: y || Object.fromEntries(h.sections.flatMap((e) => e.fields.map((t) => [t.key, t.defaultValue ?? null])))
80
- });
81
- C(() => {
82
- K && K(() => void d.handleSubmit(V)());
83
- }), C(() => {
84
- if (y) {
85
- const e = {};
86
- h.sections.forEach((t) => {
87
- t.fields.forEach((r) => {
88
- r.type === "image" && y[r.key] && (e[r.key] = y[r.key]);
89
- });
90
- }), I(e);
91
- }
92
- });
93
- const V = async (e) => {
94
- if (g) return;
95
- if (Object.keys(d.formState.errors).length > 0) {
96
- E({
97
- title: "Erreur de validation",
98
- description: "Veuillez vérifier les champs du formulaire",
99
- variant: "destructive"
100
- });
101
- return;
102
- }
103
- w(!0);
104
- try {
105
- await Promise.resolve(M(e));
106
- } catch (r) {
107
- console.error("Error during form submission:", r), E({
108
- title: "Erreur",
109
- description: "Une erreur est survenue lors de l'enregistrement",
110
- variant: "destructive"
111
- });
112
- } finally {
113
- w(!1);
114
- }
115
- }, R = (e, t) => {
116
- t && I((r) => ({ ...r, [e]: t }));
117
- }, Z = (e) => {
118
- if (!e) return !1;
119
- const t = (r) => {
120
- if (!r || !r._def) return !1;
121
- const s = r._def;
122
- return s.typeName === "ZodNullable" ? !0 : s.innerType ? t(s.innerType) : s.type ? t(s.type) : !1;
123
- };
124
- try {
125
- const r = e(b);
126
- return t(r);
127
- } catch {
128
- return !1;
129
- }
130
- }, _ = (e) => {
131
- var s;
132
- if (!e) return !1;
133
- const t = e(b);
134
- return t.safeParse(void 0).success ? !1 : ((s = t._def.checks) == null ? void 0 : s.some((n) => n.kind === "min")) ?? !1;
135
- }, G = (e, t) => {
136
- const r = !!d.formState.errors[e.key], s = x;
137
- switch (e.type) {
138
- case "text":
139
- case "color":
140
- return /* @__PURE__ */ a(
141
- k,
142
- {
143
- type: e.type,
144
- ...t,
145
- placeholder: e.placeholderKey ? u(e.placeholderKey) : "",
146
- className: i(r && "border-destructive"),
147
- disabled: s,
148
- value: t.value ?? ""
149
- }
150
- );
151
- case "image": {
152
- const n = e, c = n.value !== void 0 ? n.value : t.value;
153
- return /* @__PURE__ */ a(
154
- W,
155
- {
156
- value: c ?? "",
157
- onChange: (l) => {
158
- if (n.onChange && n.onChange(l), t.onChange(l), l) {
159
- const p = new FileReader();
160
- p.onloadend = () => {
161
- R(e.key, p.result);
162
- }, p.readAsDataURL(l);
163
- }
164
- },
165
- accept: n.accept,
166
- maxSizeMB: n.maxSizeMB,
167
- hint: n.hint,
168
- disabled: s,
169
- className: i(r && "border-destructive")
170
- }
171
- );
172
- }
173
- case "date":
174
- return /* @__PURE__ */ a(
175
- k,
176
- {
177
- type: "date",
178
- ...t,
179
- className: i(r && "border-destructive"),
180
- disabled: s,
181
- value: t.value ?? ""
182
- }
183
- );
184
- case "time":
185
- return /* @__PURE__ */ a(
186
- k,
187
- {
188
- type: "time",
189
- ...t,
190
- className: i(r && "border-destructive"),
191
- disabled: s,
192
- value: t.value ?? ""
193
- }
194
- );
195
- case "checkbox":
196
- return /* @__PURE__ */ o("div", { className: "flex items-center space-x-2", children: [
197
- /* @__PURE__ */ a(
198
- $,
199
- {
200
- id: e.key,
201
- checked: t.value === !0,
202
- onCheckedChange: (n) => {
203
- t.onChange(n);
204
- },
205
- disabled: s,
206
- className: i(r && "border-destructive")
207
- }
208
- ),
209
- /* @__PURE__ */ a("label", { htmlFor: e.key, className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: u(e.labelKey) })
210
- ] }, e.key);
211
- case "textarea":
212
- return /* @__PURE__ */ a(
213
- Y,
214
- {
215
- ...t,
216
- placeholder: e.placeholderKey ? u(e.placeholderKey) : "",
217
- className: i(r && "border-destructive", "min-h-[100px]"),
218
- disabled: s,
219
- value: t.value ?? ""
220
- }
221
- );
222
- case "number": {
223
- const n = e;
224
- return /* @__PURE__ */ a(
225
- k,
226
- {
227
- type: "number",
228
- ...t,
229
- step: n.step,
230
- min: n.min,
231
- placeholder: e.placeholderKey ? u(e.placeholderKey) : "",
232
- className: i(r && "border-destructive"),
233
- disabled: s,
234
- value: t.value ?? "",
235
- onChange: (c) => {
236
- const l = c.target.value === "" ? "" : Number(c.target.value);
237
- t.onChange(l);
238
- }
239
- }
240
- );
241
- }
242
- case "select": {
243
- const n = e, c = Z(e.rules), l = t.value === null || t.value === void 0 ? "" : t.value, p = n.options, v = p.find((m) => m.value === l);
244
- return /* @__PURE__ */ o(re, { value: l, onValueChange: t.onChange, disabled: s, children: [
245
- /* @__PURE__ */ a(j, { children: /* @__PURE__ */ a(
246
- ae,
247
- {
248
- className: i(r && "border-destructive"),
249
- onClear: c && l ? (m) => {
250
- m.preventDefault(), m.stopPropagation(), t.onChange(null);
251
- } : void 0,
252
- children: /* @__PURE__ */ a(se, { placeholder: e.placeholderKey ? u(e.placeholderKey) : "", children: v ? /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
253
- v.color && /* @__PURE__ */ a("div", { className: "w-4 h-4 rounded-full", style: { backgroundColor: v.color } }),
254
- v.label
255
- ] }) : void 0 })
256
- }
257
- ) }),
258
- /* @__PURE__ */ a(ne, { children: p.map((m, H) => /* @__PURE__ */ a(le, { value: m.value, children: /* @__PURE__ */ o("div", { className: "flex items-center gap-2", children: [
259
- m.color && /* @__PURE__ */ a("div", { className: "w-4 h-4 rounded-full", style: { backgroundColor: m.color } }),
260
- m.label
261
- ] }) }, H)) })
262
- ] });
263
- }
264
- case "multiSelect": {
265
- const n = e, c = t.value ?? [];
266
- return /* @__PURE__ */ a(
267
- q,
268
- {
269
- options: n.options,
270
- selected: c,
271
- onToggle: (l) => {
272
- const p = c.includes(l) ? c.filter((v) => v !== l) : [...c, l];
273
- t.onChange(p);
274
- },
275
- onClear: () => {
276
- t.onChange([]);
277
- },
278
- onSelectAll: (l) => {
279
- t.onChange(l);
280
- },
281
- placeholder: e.placeholderKey ? u(e.placeholderKey) : "",
282
- disabled: s
283
- }
284
- );
285
- }
286
- case "html":
287
- return e.render(d.getValues(), e);
288
- default:
289
- return null;
290
- }
291
- }, U = (e, t) => {
292
- const r = /* @__PURE__ */ a("div", { className: i("grid grid-cols-4 gap-4"), children: e.fields.map((s) => /* @__PURE__ */ a(
293
- J,
294
- {
295
- control: d.control,
296
- name: s.key,
297
- render: ({ field: n }) => {
298
- var c;
299
- return /* @__PURE__ */ o(L, { className: i(B(((c = s.layout) == null ? void 0 : c.cols) ?? z)), children: [
300
- s.type !== "checkbox" && s.type !== "html" && /* @__PURE__ */ o(Q, { children: [
301
- u(s.labelKey),
302
- _(s.rules) && /* @__PURE__ */ a("span", { className: "text-destructive ml-1", children: "*" })
303
- ] }),
304
- /* @__PURE__ */ a(j, { children: G(s, n) }),
305
- /* @__PURE__ */ a(X, {})
306
- ] });
307
- }
308
- },
309
- s.key
310
- )) });
311
- return h.useCards === !1 ? /* @__PURE__ */ o("div", { className: "space-y-4 mb-6", children: [
312
- e.titleKey && /* @__PURE__ */ a(T, { titleKey: e.titleKey }),
313
- r
314
- ] }, t) : /* @__PURE__ */ o(F, { className: "mb-6", children: [
315
- e.titleKey && /* @__PURE__ */ a(ee, { children: /* @__PURE__ */ a(T, { titleKey: e.titleKey }) }),
316
- /* @__PURE__ */ a(te, { children: r })
317
- ] }, t);
318
- };
319
- return /* @__PURE__ */ a(D, { ...d, children: /* @__PURE__ */ o(
320
- "form",
321
- {
322
- onSubmit: (e) => {
323
- d.handleSubmit(V)(e);
324
- },
325
- className: "space-y-4 px-0 w-full",
326
- children: [
327
- /* @__PURE__ */ o("div", { className: "space-y-4", children: [
328
- h.sections.map((e, t) => U(e, t)),
329
- N && /* @__PURE__ */ a("div", { className: "text-sm font-medium text-destructive", children: N.message })
330
- ] }),
331
- !x && P && /* @__PURE__ */ o("div", { className: "flex justify-end gap-3 mt-6 border-t pt-4", children: [
332
- f && /* @__PURE__ */ a(A, { type: "button", variant: "outline", onClick: f, disabled: g || S, children: u("Annuler", "Annuler") }),
333
- /* @__PURE__ */ a(A, { variant: "default", type: "submit", disabled: g || (S ?? !1) || d.formState.isSubmitting, children: g || S ? u("Enregistrement...", "Enregistrement...") : u("Enregistrer", "Enregistrer") })
334
- ] })
335
- ]
336
- }
337
- ) });
338
- };
339
- export {
340
- Be as G
341
- };
@@ -1,67 +0,0 @@
1
- import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
- import "./toggle-group-DLLrEwv2.js";
3
- import "./alert-B9F1N9Qk.js";
4
- import "@radix-ui/react-aspect-ratio";
5
- import { B as x } from "./tooltip-DVeqVwqV.js";
6
- import "./chart-DntJZGxB.js";
7
- import "@radix-ui/react-collapsible";
8
- import "./sheet-BQmtrGf2.js";
9
- import { XIcon as N, ImageIcon as v, UploadIcon as w } from "lucide-react";
10
- import "react-resizable-panels";
11
- import { c as u } from "./tailwind.helper-B6yFEsav.js";
12
- import "./select-BpjFWqAY.js";
13
- import "next-themes";
14
- import "sonner";
15
- import { forwardRef as I, useRef as y } from "react";
16
- import { u as j } from "./useNotifications-zbUhCvF_.js";
17
- const R = I(
18
- ({ value: i, onChange: n, accept: a = "image/jpeg,image/png,image/webp", maxSizeMB: s = 2, disabled: c = !1, className: p = "", hint: l = "JPG, PNG, WEBP" }, f) => {
19
- const { showError: m } = j(), r = y(null), h = (b) => {
20
- var d;
21
- const t = (d = b.target.files) == null ? void 0 : d[0];
22
- if (!t) return;
23
- if (!a.split(",").map((g) => g.trim()).includes(t.type)) {
24
- m("Erreur", `Seuls les fichiers ${l} sont acceptés`), r.current && (r.current.value = "");
25
- return;
26
- }
27
- if (t.size > s * 1024 * 1024) {
28
- m("Erreur", `Le fichier ne doit pas dépasser ${s}MB`), r.current && (r.current.value = "");
29
- return;
30
- }
31
- n(t), r.current && (r.current.value = "");
32
- };
33
- return /* @__PURE__ */ e("div", { ref: f, className: p, children: i ? /* @__PURE__ */ o("div", { className: "relative w-32 h-32 rounded-surface overflow-hidden border-2 border-border", children: [
34
- /* @__PURE__ */ e("img", { src: i, alt: "Preview", className: "w-full h-full object-cover" }),
35
- !c && /* @__PURE__ */ e(x, { type: "button", variant: "destructive", size: "sm", className: "absolute top-1 right-1 h-6 w-6 p-0", onClick: () => {
36
- n(null);
37
- }, children: /* @__PURE__ */ e(N, { className: "h-4 w-4" }) })
38
- ] }) : c ? /* @__PURE__ */ o("div", { className: u("flex flex-col items-center justify-center w-full h-32", "border-2 border-dashed border-border rounded-surface", "bg-muted/30"), children: [
39
- /* @__PURE__ */ e(v, { className: "h-8 w-8 text-muted-foreground/50 mb-2" }),
40
- /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground/50", children: "Aucune image" })
41
- ] }) : /* @__PURE__ */ o(
42
- "label",
43
- {
44
- className: u(
45
- "flex flex-col items-center justify-center w-full h-32",
46
- "border-2 border-dashed border-border rounded-surface",
47
- "cursor-pointer hover:bg-muted/50 transition-colors"
48
- ),
49
- children: [
50
- /* @__PURE__ */ e(w, { className: "h-8 w-8 text-muted-foreground mb-2" }),
51
- /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: "Cliquer pour uploader" }),
52
- /* @__PURE__ */ o("span", { className: "text-xs text-muted-foreground mt-1", children: [
53
- l,
54
- " (max ",
55
- s,
56
- "MB)"
57
- ] }),
58
- /* @__PURE__ */ e("input", { ref: r, type: "file", className: "hidden", accept: a, onChange: h })
59
- ]
60
- }
61
- ) });
62
- }
63
- );
64
- R.displayName = "ImageInput";
65
- export {
66
- R as I
67
- };
@@ -1,251 +0,0 @@
1
- import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
- import * as S from "react";
3
- import { useState as z, useRef as q, useEffect as G, useMemo as K } from "react";
4
- import { C as L, b0 as R, b2 as j, b1 as T } from "./toggle-group-DLLrEwv2.js";
5
- import "./alert-B9F1N9Qk.js";
6
- import "@radix-ui/react-aspect-ratio";
7
- import { B as y, f as X } from "./tooltip-DVeqVwqV.js";
8
- import "./chart-DntJZGxB.js";
9
- import "@radix-ui/react-collapsible";
10
- import { C as F, m as H, o as J, k as Q, l as U, n as E, I as W } from "./sheet-BQmtrGf2.js";
11
- import { CalendarIcon as _, XIcon as M, ChevronDownIcon as Y, CheckIcon as Z, PlusIcon as ee, SearchIcon as te } from "lucide-react";
12
- import "react-resizable-panels";
13
- import { c as g } from "./tailwind.helper-B6yFEsav.js";
14
- import "./select-BpjFWqAY.js";
15
- import "next-themes";
16
- import "sonner";
17
- import { format as N } from "date-fns";
18
- import { fr as b } from "date-fns/locale";
19
- const Ne = ({ date: r, onDateChange: o, placeholder: h }) => {
20
- const [c, a] = z(!1), s = q(null);
21
- G(() => {
22
- if (!c) return;
23
- const i = (f) => {
24
- s.current !== null && !s.current.contains(f.target) && a(!1);
25
- };
26
- return document.addEventListener("mousedown", i), () => {
27
- document.removeEventListener("mousedown", i);
28
- };
29
- }, [c]);
30
- const d = () => {
31
- a((i) => !i);
32
- }, m = (i) => {
33
- o(i), a(!1);
34
- };
35
- return /* @__PURE__ */ n("div", { ref: s, className: "relative w-full", children: [
36
- /* @__PURE__ */ n(
37
- y,
38
- {
39
- variant: "outline",
40
- type: "button",
41
- onClick: d,
42
- className: g(
43
- "w-full justify-start text-left font-normal focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
44
- c && "ring-2 ring-ring ring-offset-2",
45
- r === void 0 && "text-muted-foreground"
46
- ),
47
- children: [
48
- /* @__PURE__ */ e(_, { className: "mr-2 size-4 shrink-0" }),
49
- r !== void 0 ? N(r, "dd/MM/yyyy", { locale: b }) : /* @__PURE__ */ e("span", { children: h })
50
- ]
51
- }
52
- ),
53
- c ? /* @__PURE__ */ e("div", { className: "absolute left-0 top-[calc(100%+4px)] z-[100] rounded-surface border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 slide-in-from-top-2", children: /* @__PURE__ */ e(L, { mode: "single", selected: r, onSelect: m }) }) : null
54
- ] });
55
- }, be = ({ value: r, onChange: o, placeholder: h = "Selectionner une periode", className: c }) => {
56
- const [a, s] = S.useState(!1), [d, m] = S.useState(r);
57
- S.useEffect(() => {
58
- a && m(r);
59
- }, [a, r]);
60
- const i = (l) => {
61
- l.stopPropagation(), o(void 0), s(!1);
62
- }, f = () => {
63
- o(d), s(!1);
64
- }, x = () => {
65
- m(r), s(!1);
66
- }, k = () => {
67
- m(void 0);
68
- }, p = (l) => l != null && l.from ? !l.to || l.from.getTime() === l.to.getTime() ? N(l.from, "dd MMM yyyy", { locale: b }) : `${N(l.from, "dd MMM yyyy", { locale: b })} - ${N(l.to, "dd MMM yyyy", { locale: b })}` : h;
69
- return /* @__PURE__ */ e("div", { className: g("grid gap-2", c), children: /* @__PURE__ */ n(R, { open: a, onOpenChange: s, children: [
70
- /* @__PURE__ */ e(j, { asChild: !0, children: /* @__PURE__ */ n(y, { id: "date", variant: "outline", className: g("w-[300px] justify-start text-left font-normal", !(r != null && r.from) && "text-muted-foreground"), children: [
71
- /* @__PURE__ */ e(_, { className: "mr-2 size-4" }),
72
- p(r),
73
- (r == null ? void 0 : r.from) && /* @__PURE__ */ e(
74
- y,
75
- {
76
- type: "button",
77
- variant: "ghost",
78
- size: "icon",
79
- "aria-label": "Effacer la periode selectionnee",
80
- className: "ml-auto h-5 w-5 opacity-50 hover:opacity-100",
81
- onClick: i,
82
- children: /* @__PURE__ */ e(M, { className: "size-4" })
83
- }
84
- )
85
- ] }) }),
86
- /* @__PURE__ */ n(T, { className: "w-auto p-0", align: "start", side: "bottom", sideOffset: 4, children: [
87
- /* @__PURE__ */ e(
88
- L,
89
- {
90
- mode: "range",
91
- defaultMonth: d == null ? void 0 : d.from,
92
- selected: d,
93
- onSelect: m,
94
- numberOfMonths: 2,
95
- weekStartsOn: 1,
96
- className: "pointer-events-auto p-3"
97
- }
98
- ),
99
- /* @__PURE__ */ n("div", { className: "flex items-center justify-between border-t border-border px-3 py-2", children: [
100
- /* @__PURE__ */ e(y, { variant: "ghost", size: "sm", onClick: k, children: "Effacer" }),
101
- /* @__PURE__ */ n("div", { className: "flex gap-2", children: [
102
- /* @__PURE__ */ e(y, { variant: "ghost", size: "sm", onClick: x, children: "Annuler" }),
103
- /* @__PURE__ */ e(y, { size: "sm", onClick: f, children: "Appliquer" })
104
- ] })
105
- ] })
106
- ] })
107
- ] }) });
108
- }, xe = ({
109
- options: r = [],
110
- value: o,
111
- onChange: h,
112
- onClear: c,
113
- onCreate: a,
114
- placeholder: s = "Sélectionner...",
115
- searchPlaceholder: d = "Rechercher...",
116
- emptyLabel: m = "Aucun résultat",
117
- createLabel: i = (p) => `Créer « ${p} »`,
118
- disabled: f = !1,
119
- modal: x = !0,
120
- className: k
121
- }) => {
122
- const [p, l] = z(!1), [I, P] = z(""), v = o !== void 0 && o !== "", u = K(() => v ? r.find((t) => t.value === o) : void 0, [v, r, o]), A = v ? (u == null ? void 0 : u.label) ?? o : void 0, C = I.trim(), D = a !== void 0 && C !== "" && !r.some((t) => t.label.toLowerCase() === C.toLowerCase()), w = (t) => {
123
- l(t), t || P("");
124
- }, O = (t) => {
125
- h(t), w(!1);
126
- }, V = () => {
127
- a == null || a(C), w(!1);
128
- };
129
- return /* @__PURE__ */ n(R, { open: p, onOpenChange: w, modal: x, children: [
130
- /* @__PURE__ */ e(j, { asChild: !0, children: /* @__PURE__ */ n(
131
- "button",
132
- {
133
- type: "button",
134
- role: "combobox",
135
- "aria-expanded": p,
136
- disabled: f,
137
- className: g(
138
- X,
139
- "w-full",
140
- "data-[state=open]:ring-2 data-[state=open]:ring-ring data-[state=open]:ring-offset-2",
141
- !v && "text-muted-foreground",
142
- k
143
- ),
144
- children: [
145
- /* @__PURE__ */ n("span", { className: "flex items-center truncate", children: [
146
- (u == null ? void 0 : u.color) && /* @__PURE__ */ e("span", { className: "mr-2 size-2.5 shrink-0 rounded-full", style: { backgroundColor: u.color } }),
147
- /* @__PURE__ */ e("span", { className: "truncate", children: A ?? s }),
148
- (u == null ? void 0 : u.description) !== void 0 && /* @__PURE__ */ n("span", { className: "ml-1 truncate text-muted-foreground", children: [
149
- "(",
150
- u.description,
151
- ")"
152
- ] })
153
- ] }),
154
- /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
155
- c && v && !f && /* @__PURE__ */ e(
156
- "span",
157
- {
158
- role: "button",
159
- tabIndex: -1,
160
- onClick: (t) => {
161
- t.stopPropagation();
162
- },
163
- onPointerDown: (t) => {
164
- t.preventDefault(), t.stopPropagation(), c();
165
- },
166
- className: "text-muted-foreground hover:text-foreground",
167
- children: /* @__PURE__ */ e(M, { className: "size-4" })
168
- }
169
- ),
170
- /* @__PURE__ */ e(Y, { className: g("size-4 shrink-0 opacity-50 transition-transform", p && "rotate-180") })
171
- ] })
172
- ]
173
- }
174
- ) }),
175
- /* @__PURE__ */ e(T, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ n(
176
- F,
177
- {
178
- filter: (t, $, B) => (B ?? []).join(" ").toLowerCase().includes($.trim().toLowerCase()) ? 1 : 0,
179
- children: [
180
- /* @__PURE__ */ e(H, { placeholder: d, value: I, onValueChange: P }),
181
- /* @__PURE__ */ n(J, { children: [
182
- !D && /* @__PURE__ */ e(Q, { children: m }),
183
- /* @__PURE__ */ n(U, { children: [
184
- r.map((t) => /* @__PURE__ */ n(
185
- E,
186
- {
187
- value: t.value,
188
- keywords: [t.label, t.description ?? ""],
189
- onSelect: () => {
190
- O(t.value);
191
- },
192
- children: [
193
- /* @__PURE__ */ e(Z, { className: g("mr-2 size-4 shrink-0", o === t.value ? "opacity-100" : "opacity-0") }),
194
- t.color !== void 0 && /* @__PURE__ */ e("span", { className: "mr-2 size-2.5 shrink-0 rounded-full", style: { backgroundColor: t.color } }),
195
- /* @__PURE__ */ e("span", { className: "truncate", children: t.label }),
196
- t.description !== void 0 && /* @__PURE__ */ n("span", { className: "ml-1 truncate text-muted-foreground", children: [
197
- "(",
198
- t.description,
199
- ")"
200
- ] })
201
- ]
202
- },
203
- t.value
204
- )),
205
- D && /* @__PURE__ */ n(E, { forceMount: !0, value: "__create__", onSelect: V, children: [
206
- /* @__PURE__ */ e(ee, { className: "mr-2 size-4 shrink-0" }),
207
- /* @__PURE__ */ e("span", { className: "truncate", children: i(C) })
208
- ] })
209
- ] })
210
- ] })
211
- ]
212
- }
213
- ) })
214
- ] });
215
- }, ke = ({
216
- searchQuery: r,
217
- search: o,
218
- placeholder: h = "Rechercher...",
219
- onSearch: c,
220
- onSubmit: a,
221
- onClear: s,
222
- className: d
223
- }) => {
224
- const m = r ?? o ?? "", i = () => {
225
- c(""), s !== void 0 && s();
226
- };
227
- return /* @__PURE__ */ n("div", { className: g("relative h-fit w-full md:w-64", d), children: [
228
- /* @__PURE__ */ e(te, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4" }),
229
- /* @__PURE__ */ e(
230
- W,
231
- {
232
- placeholder: h,
233
- value: m,
234
- onChange: (f) => {
235
- c(f.target.value);
236
- },
237
- className: "pl-8",
238
- onKeyDown: (f) => {
239
- f.key === "Enter" && a !== void 0 && (f.preventDefault(), a());
240
- }
241
- }
242
- ),
243
- m !== "" ? /* @__PURE__ */ e("button", { onClick: i, className: "absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 hover:text-gray-700", type: "button", children: /* @__PURE__ */ e(M, { className: "size-4" }) }) : null
244
- ] });
245
- };
246
- export {
247
- Ne as D,
248
- ke as S,
249
- be as a,
250
- xe as b
251
- };