@krosoft/react 0.0.101 → 0.0.103

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 (66) hide show
  1. package/dist/{AppSubTitle-DBxJVB46.js → AppSubTitle-Cr3zbmee.js} +1 -1
  2. package/dist/{AppTitle-DDQoaHBb.js → AppTitle-eazxzYGa.js} +1 -1
  3. package/dist/{AppVerticalTabs-CYx0jMXp.js → AppVerticalTabs-ujb4jtNi.js} +2 -2
  4. package/dist/ConfirmationDialog-B41OAAmc.js +257 -0
  5. package/dist/{DataTable-locK3Z44.js → DataTable-jrFyuw67.js} +222 -224
  6. package/dist/GenericForm-D3Gxh9kf.js +11365 -0
  7. package/dist/ImageInput-BcGHoduc.js +82 -0
  8. package/dist/{MetricCard-CFwSSiQY.js → MetricCard-CXDB0msa.js} +1 -1
  9. package/dist/MultiSelect-Bc0Re1XN.js +137 -0
  10. package/dist/SearchInput-DFrIqONH.js +586 -0
  11. package/dist/{TableFilter-DGFQNbZ_.js → TableFilter-CK8NyawM.js} +27 -26
  12. package/dist/{ThemeSelector-Cl2EWB-n.js → ThemeSelector-BMvfc21-.js} +1 -1
  13. package/dist/components/core/cards/index.js +1 -1
  14. package/dist/components/core/dialogs/FormDialog.d.ts +6 -18
  15. package/dist/components/core/dialogs/FormDialog.d.ts.map +1 -1
  16. package/dist/components/core/dialogs/index.d.ts +1 -1
  17. package/dist/components/core/dialogs/index.d.ts.map +1 -1
  18. package/dist/components/core/dialogs/index.js +2 -2
  19. package/dist/components/core/filters/index.js +1 -1
  20. package/dist/components/core/forms/GenericForm.d.ts +57 -0
  21. package/dist/components/core/forms/GenericForm.d.ts.map +1 -0
  22. package/dist/components/core/forms/index.d.ts +2 -0
  23. package/dist/components/core/forms/index.d.ts.map +1 -0
  24. package/dist/components/core/forms/index.js +4 -0
  25. package/dist/components/core/index.d.ts +1 -0
  26. package/dist/components/core/index.d.ts.map +1 -1
  27. package/dist/components/core/index.js +57 -52
  28. package/dist/components/core/inputs/ImageInput.d.ts +12 -0
  29. package/dist/components/core/inputs/ImageInput.d.ts.map +1 -0
  30. package/dist/components/core/inputs/MultiSelect.d.ts +2 -1
  31. package/dist/components/core/inputs/MultiSelect.d.ts.map +1 -1
  32. package/dist/components/core/inputs/index.d.ts +1 -0
  33. package/dist/components/core/inputs/index.d.ts.map +1 -1
  34. package/dist/components/core/inputs/index.js +8 -5
  35. package/dist/components/core/layouts/index.js +2 -2
  36. package/dist/components/core/table/TableBody.d.ts.map +1 -1
  37. package/dist/components/core/table/TableHeader.d.ts.map +1 -1
  38. package/dist/components/core/table/index.js +1 -1
  39. package/dist/components/core/tabs/index.js +1 -1
  40. package/dist/components/core/theme/index.js +1 -1
  41. package/dist/components/index.js +116 -111
  42. package/dist/components/ui/index.js +2 -2
  43. package/dist/hooks/index.js +17 -16
  44. package/dist/{toaster-BTQcWjuV.js → toaster-CtADevTu.js} +1 -1
  45. package/dist/{toggle-group-6CH5BRLO.js → toggle-group-Cnfwf4uy.js} +8376 -7317
  46. package/dist/types/AppAction.d.ts +1 -1
  47. package/dist/types/AppAction.d.ts.map +1 -1
  48. package/dist/types/forms/FieldType.d.ts +2 -0
  49. package/dist/types/forms/FieldType.d.ts.map +1 -0
  50. package/dist/types/forms/FormField.d.ts +40 -0
  51. package/dist/types/forms/FormField.d.ts.map +1 -0
  52. package/dist/types/forms/FormSchema.d.ts +6 -0
  53. package/dist/types/forms/FormSchema.d.ts.map +1 -0
  54. package/dist/types/forms/FormSection.d.ts +12 -0
  55. package/dist/types/forms/FormSection.d.ts.map +1 -0
  56. package/dist/types/forms/index.d.ts +5 -0
  57. package/dist/types/forms/index.d.ts.map +1 -0
  58. package/dist/types/forms/index.js +1 -0
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/useNotifications-zbUhCvF_.js +12 -0
  62. package/dist/useTheme-B0Bxda3I.js +22 -0
  63. package/package.json +7 -5
  64. package/dist/ConfirmationDialog-bBFPpP2z.js +0 -322
  65. package/dist/SearchInput-CsZcpaxL.js +0 -710
  66. package/dist/useTheme-BtR4Ahrp.js +0 -31
@@ -0,0 +1,82 @@
1
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
2
+ import "./toggle-group-Cnfwf4uy.js";
3
+ import "./alert-srKINZRG.js";
4
+ import { c as u } from "./tailwind.helper-gWiv5-6R.js";
5
+ import { B as v } from "./tooltip-mWS3Mix6.js";
6
+ import { X as y } from "./select-CDIMkakd.js";
7
+ import "next-themes";
8
+ import { forwardRef as N, useRef as w } from "react";
9
+ import { u as j } from "./useNotifications-zbUhCvF_.js";
10
+ import { c as p } from "./index-BSI9LuBZ.js";
11
+ /**
12
+ * @license lucide-react v1.16.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */
17
+ const k = [
18
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
19
+ ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
20
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
21
+ ], I = p("image", k);
22
+ /**
23
+ * @license lucide-react v1.16.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */
28
+ const R = [
29
+ ["path", { d: "M12 3v12", key: "1x0j5s" }],
30
+ ["path", { d: "m17 8-5-5-5 5", key: "7q97r8" }],
31
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }]
32
+ ], E = p("upload", R), P = N(
33
+ ({ value: a, onChange: n, accept: c = "image/jpeg,image/png,image/webp", maxSizeMB: s = 2, disabled: i = !1, className: f = "", hint: l = "JPG, PNG, WEBP" }, h) => {
34
+ const { showError: d } = j(), r = w(null), g = (x) => {
35
+ var m;
36
+ const t = (m = x.target.files) == null ? void 0 : m[0];
37
+ if (!t) return;
38
+ if (!c.split(",").map((b) => b.trim()).includes(t.type)) {
39
+ d("Erreur", `Seuls les fichiers ${l} sont acceptés`), r.current && (r.current.value = "");
40
+ return;
41
+ }
42
+ if (t.size > s * 1024 * 1024) {
43
+ d("Erreur", `Le fichier ne doit pas dépasser ${s}MB`), r.current && (r.current.value = "");
44
+ return;
45
+ }
46
+ n(t), r.current && (r.current.value = "");
47
+ };
48
+ return /* @__PURE__ */ e("div", { ref: h, className: f, children: a ? /* @__PURE__ */ o("div", { className: "relative w-32 h-32 rounded-lg overflow-hidden border-2 border-border", children: [
49
+ /* @__PURE__ */ e("img", { src: a, alt: "Preview", className: "w-full h-full object-cover" }),
50
+ !i && /* @__PURE__ */ e(v, { type: "button", variant: "destructive", size: "sm", className: "absolute top-1 right-1 h-6 w-6 p-0", onClick: () => {
51
+ n(null);
52
+ }, children: /* @__PURE__ */ e(y, { className: "h-4 w-4" }) })
53
+ ] }) : i ? /* @__PURE__ */ o("div", { className: u("flex flex-col items-center justify-center w-full h-32", "border-2 border-dashed border-border rounded-lg", "bg-muted/30"), children: [
54
+ /* @__PURE__ */ e(I, { className: "h-8 w-8 text-muted-foreground/50 mb-2" }),
55
+ /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground/50", children: "Aucune image" })
56
+ ] }) : /* @__PURE__ */ o(
57
+ "label",
58
+ {
59
+ className: u(
60
+ "flex flex-col items-center justify-center w-full h-32",
61
+ "border-2 border-dashed border-border rounded-lg",
62
+ "cursor-pointer hover:bg-muted/50 transition-colors"
63
+ ),
64
+ children: [
65
+ /* @__PURE__ */ e(E, { className: "h-8 w-8 text-muted-foreground mb-2" }),
66
+ /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: "Cliquer pour uploader" }),
67
+ /* @__PURE__ */ o("span", { className: "text-xs text-muted-foreground mt-1", children: [
68
+ l,
69
+ " (max ",
70
+ s,
71
+ "MB)"
72
+ ] }),
73
+ /* @__PURE__ */ e("input", { ref: r, type: "file", className: "hidden", accept: c, onChange: g })
74
+ ]
75
+ }
76
+ ) });
77
+ }
78
+ );
79
+ P.displayName = "ImageInput";
80
+ export {
81
+ P as I
82
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
- import { I as l, M as p, J as m, N as x } from "./toggle-group-6CH5BRLO.js";
2
+ import { I as l, M as p, J as m, N as x } from "./toggle-group-Cnfwf4uy.js";
3
3
  import { c } from "./tailwind.helper-gWiv5-6R.js";
4
4
  import { useTranslation as f } from "react-i18next";
5
5
  import { formatNumber as b } from "@krosoft/core/helpers";
@@ -0,0 +1,137 @@
1
+ import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
+ import { useState as w, useRef as k, useMemo as N, useEffect as y } from "react";
3
+ import { ce as R, _ as C } from "./toggle-group-Cnfwf4uy.js";
4
+ import "./alert-srKINZRG.js";
5
+ import { c as E } from "./tailwind.helper-gWiv5-6R.js";
6
+ import { C as T } from "./tooltip-mWS3Mix6.js";
7
+ import { X as D } from "./select-CDIMkakd.js";
8
+ import "next-themes";
9
+ const V = ({
10
+ options: i,
11
+ selected: n,
12
+ onToggle: h,
13
+ onClear: d,
14
+ onSelectAll: u,
15
+ placeholder: j = "Sélectionner...",
16
+ searchable: f = !1,
17
+ searchPlaceholder: z = "Rechercher...",
18
+ disabled: m = !1
19
+ }) => {
20
+ const [c, g] = w(""), [a, b] = w(!1), p = k(null), x = k(null), o = N(() => c === "" ? i : i.filter((e) => e.label.toLowerCase().includes(c.toLowerCase())), [i, c]), v = N(() => o.length === 0 ? !1 : o.every((e) => n.includes(e.value)), [o, n]);
21
+ y(() => {
22
+ a && f && requestAnimationFrame(() => {
23
+ var e;
24
+ (e = x.current) == null || e.focus();
25
+ });
26
+ }, [a, f]), y(() => {
27
+ if (!a) return;
28
+ const e = (r) => {
29
+ p.current !== null && !p.current.contains(r.target) && (b(!1), g(""));
30
+ };
31
+ return document.addEventListener("mousedown", e), () => {
32
+ document.removeEventListener("mousedown", e);
33
+ };
34
+ }, [a]);
35
+ const L = () => {
36
+ if (v) {
37
+ const e = o.map((s) => s.value), r = n.filter((s) => !e.includes(s));
38
+ u !== void 0 ? u(r) : d();
39
+ } else {
40
+ const e = [...n];
41
+ o.forEach((r) => {
42
+ e.includes(r.value) || e.push(r.value);
43
+ }), u !== void 0 ? u(e) : o.forEach((r) => {
44
+ n.includes(r.value) || h(r.value);
45
+ });
46
+ }
47
+ };
48
+ return /* @__PURE__ */ l("div", { ref: p, className: "relative w-full", children: [
49
+ /* @__PURE__ */ l(
50
+ "button",
51
+ {
52
+ type: "button",
53
+ disabled: m,
54
+ onClick: () => {
55
+ m || b((e) => (e && g(""), !e));
56
+ },
57
+ className: E(
58
+ "flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
59
+ a && "ring-2 ring-ring ring-offset-2",
60
+ n.length === 0 && "text-muted-foreground"
61
+ ),
62
+ children: [
63
+ /* @__PURE__ */ t("span", { className: "truncate", children: n.length === 0 ? j : n.map((e) => {
64
+ var r;
65
+ return ((r = i.find((s) => s.value === e)) == null ? void 0 : r.label) ?? e;
66
+ }).join(", ") }),
67
+ /* @__PURE__ */ l("div", { className: "flex shrink-0 items-center gap-1", children: [
68
+ n.length > 0 && !m && /* @__PURE__ */ t(
69
+ "span",
70
+ {
71
+ role: "button",
72
+ tabIndex: -1,
73
+ onClick: (e) => {
74
+ e.stopPropagation();
75
+ },
76
+ onPointerDown: (e) => {
77
+ e.preventDefault(), e.stopPropagation(), d();
78
+ },
79
+ className: "text-muted-foreground hover:text-foreground",
80
+ children: /* @__PURE__ */ t(D, { className: "size-4" })
81
+ }
82
+ ),
83
+ /* @__PURE__ */ t(T, { className: E("size-4 opacity-50 shrink-0 transition-transform", a && "rotate-180") })
84
+ ] })
85
+ ]
86
+ }
87
+ ),
88
+ a ? /* @__PURE__ */ l("div", { className: "absolute left-0 right-0 top-[calc(100%+4px)] z-[100] rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 slide-in-from-top-2", children: [
89
+ f ? /* @__PURE__ */ t("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
90
+ /* @__PURE__ */ t(R, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
91
+ /* @__PURE__ */ t(
92
+ "input",
93
+ {
94
+ ref: x,
95
+ className: "w-full rounded-md bg-muted/50 py-1.5 pl-7 pr-2 text-sm text-foreground placeholder:text-muted-foreground outline-none focus:ring-1 focus:ring-ring",
96
+ placeholder: z,
97
+ value: c,
98
+ onChange: (e) => {
99
+ g(e.target.value);
100
+ }
101
+ }
102
+ )
103
+ ] }) }) : null,
104
+ /* @__PURE__ */ l("div", { className: "flex flex-col gap-0.5 max-h-56 overflow-y-auto p-1.5 scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-muted-foreground/20 scrollbar-track-transparent [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 [&::-webkit-scrollbar-track]:bg-transparent", children: [
105
+ o.length > 0 && /* @__PURE__ */ l("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
106
+ /* @__PURE__ */ t(C, { checked: v, onCheckedChange: L }),
107
+ "Tout sélectionner"
108
+ ] }),
109
+ o.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: "Aucun résultat" }),
110
+ o.map((e) => /* @__PURE__ */ l("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
111
+ /* @__PURE__ */ t(
112
+ C,
113
+ {
114
+ checked: n.includes(e.value),
115
+ onCheckedChange: () => {
116
+ h(e.value);
117
+ }
118
+ }
119
+ ),
120
+ e.label
121
+ ] }, e.value))
122
+ ] }),
123
+ n.length > 0 && /* @__PURE__ */ t("div", { className: "border-t border-border p-1.5", children: /* @__PURE__ */ t(
124
+ "button",
125
+ {
126
+ type: "button",
127
+ onClick: d,
128
+ className: "w-full rounded-md px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted transition-colors text-center",
129
+ children: "Tout désélectionner"
130
+ }
131
+ ) })
132
+ ] }) : null
133
+ ] });
134
+ };
135
+ export {
136
+ V as M
137
+ };