@krosoft/react 0.0.238 → 0.0.240

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 (109) hide show
  1. package/dist/AppActions-C_0YI75w.js +60 -0
  2. package/dist/AppSubTitle-tqqV9nuT.js +19 -0
  3. package/dist/AppTitle-BR4JFZfp.js +19 -0
  4. package/dist/ErrorAlert-BDqDHUUc.js +27 -0
  5. package/dist/GenericForm-CWXT5wiv.js +310 -0
  6. package/dist/ImageInput-CN2ozjpc.js +80 -0
  7. package/dist/MultiSelect-BF0zL0B0.js +134 -0
  8. package/dist/SearchInput-BJPT0SbB.js +255 -0
  9. package/dist/alert-REQGK9bR.js +32 -0
  10. package/dist/behavior-BR_V9Rpe.js +76 -0
  11. package/dist/cards-Cta6x49J.js +126 -0
  12. package/dist/chart-Dq3AIrue.js +166 -0
  13. package/dist/charts-CXhVUqLH.js +328 -0
  14. package/dist/components/core/cards/index.js +2 -10
  15. package/dist/components/core/charts/index.js +2 -11
  16. package/dist/components/core/dialogs/index.js +4 -19
  17. package/dist/components/core/filters/index.js +426 -7
  18. package/dist/components/core/forms/index.js +2 -4
  19. package/dist/components/core/index.js +24 -97
  20. package/dist/components/core/inputs/index.js +4 -11
  21. package/dist/components/core/language/index.js +2 -4
  22. package/dist/components/core/layouts/index.js +50 -11
  23. package/dist/components/core/navbar/index.js +2 -9
  24. package/dist/components/core/states/index.js +3 -8
  25. package/dist/components/core/table/index.js +2 -15
  26. package/dist/components/core/tabs/index.js +188 -6
  27. package/dist/components/core/theme/index.js +2 -4
  28. package/dist/components/index.js +28 -322
  29. package/dist/components/ui/index.js +8 -240
  30. package/dist/contexts/index.js +2 -5
  31. package/dist/dialogs-BGHSClsq.js +208 -0
  32. package/dist/helpers/index.js +39 -46
  33. package/dist/hooks/behavior/index.js +2 -10
  34. package/dist/hooks/index.js +11 -30
  35. package/dist/hooks/ui/index.js +10 -22
  36. package/dist/i18n/index.js +2 -10
  37. package/dist/i18n-Dw99bRmg.js +190 -0
  38. package/dist/language-DxHhlpgN.js +58 -0
  39. package/dist/navbar-Bc5OQWRI.js +385 -0
  40. package/dist/providers/index.js +42 -49
  41. package/dist/pwa/index.js +32 -34
  42. package/dist/select-ULiTPOr5.js +81 -0
  43. package/dist/sheet-CRrYTZrl.js +226 -0
  44. package/dist/sidebar.context-BahtU6hE.js +5 -0
  45. package/dist/skeleton-D6Ga4BLw.js +11 -0
  46. package/dist/states-N8-LjFng.js +26 -0
  47. package/dist/table-muUyiaK6.js +571 -0
  48. package/dist/tailwind/index.js +126 -156
  49. package/dist/tailwind.helper-CJaRYBmL.js +8 -0
  50. package/dist/theme-B_n0F6R4.js +57 -0
  51. package/dist/tokens/index.js +37 -46
  52. package/dist/tooltip-B2dzyfs9.js +50 -0
  53. package/dist/types/forms/index.js +0 -1
  54. package/dist/types/index.js +1 -1
  55. package/dist/ui-CiX0E_bn.js +1165 -0
  56. package/dist/ui-DSVBO3iM.js +46 -0
  57. package/dist/useDocumentTitle-D7MywIeB.js +19 -0
  58. package/dist/useFixedColumns-DfAX30tT.js +147 -0
  59. package/dist/useLanguage-DN3CuBv5.js +19 -0
  60. package/dist/useMobile-pTQ8lWvt.js +16 -0
  61. package/dist/useNotifications-CyhTruIG.js +20 -0
  62. package/dist/useScrollFade-D9kqJBDh.js +27 -0
  63. package/dist/useTheme-DVfcJ-Qd.js +25 -0
  64. package/dist/useToast-UeDRLovh.js +103 -0
  65. package/package.json +3 -3
  66. package/dist/AppActions-BFwztl-1.js +0 -76
  67. package/dist/AppSubTitle-BTN0YAc7.js +0 -13
  68. package/dist/AppTitle-D15YXeMx.js +0 -13
  69. package/dist/AppVerticalTabs-B7XXtAVj.js +0 -103
  70. package/dist/ConfirmationDialog-Dj4WdnHg.js +0 -188
  71. package/dist/DataTable-CjrR27Di.js +0 -638
  72. package/dist/ErrorAlert-B99Xb_Hg.js +0 -23
  73. package/dist/ErrorState-CkeS_IBT.js +0 -14
  74. package/dist/GenericForm-CydibLHU.js +0 -343
  75. package/dist/ImageInput-DoOOvvth.js +0 -70
  76. package/dist/KpiCardsLayout-Bq4xQ3i8.js +0 -43
  77. package/dist/LanguageSelector-C7E51rCQ.js +0 -47
  78. package/dist/LoadingState-BN0YaPSs.js +0 -9
  79. package/dist/MetricCard-B0xnFyim.js +0 -53
  80. package/dist/MultiSelect-DbH7LrsD.js +0 -149
  81. package/dist/PieChart-uozNJtEx.js +0 -295
  82. package/dist/SearchInput-DIZ5Yt6L.js +0 -246
  83. package/dist/SkeletonCards-B9C4cNMr.js +0 -75
  84. package/dist/TableFilter-CmEVF5Bo.js +0 -422
  85. package/dist/ThemeSelector-CLi4_epH.js +0 -52
  86. package/dist/Topbar-Clby5_uj.js +0 -431
  87. package/dist/alert-B9F1N9Qk.js +0 -30
  88. package/dist/chart-DntJZGxB.js +0 -181
  89. package/dist/select-BpjFWqAY.js +0 -96
  90. package/dist/sheet-XYI-ezvY.js +0 -292
  91. package/dist/sidebar.context-D5nywlmP.js +0 -6
  92. package/dist/skeleton-BX4RcsiK.js +0 -8
  93. package/dist/tailwind.helper-B6yFEsav.js +0 -8
  94. package/dist/toaster-CyzB1m5z.js +0 -75
  95. package/dist/toggle-group-iZqnrTj7.js +0 -1276
  96. package/dist/tooltip-DVeqVwqV.js +0 -61
  97. package/dist/useDateFnsLocale-D6VExZ8U.js +0 -11
  98. package/dist/useDocumentTitle-WNwdPz-I.js +0 -14
  99. package/dist/useFixedColumns-CKZyu4PD.js +0 -161
  100. package/dist/useKrosoftTranslation-BTp46G94.js +0 -47
  101. package/dist/useLanguage-C9jI2nwn.js +0 -19
  102. package/dist/useMobile-DN1_OMDB.js +0 -16
  103. package/dist/useNotifications-zbUhCvF_.js +0 -12
  104. package/dist/usePage-BQm6tdJD.js +0 -84
  105. package/dist/useScrollFade-BA4KqJYp.js +0 -23
  106. package/dist/useServerTable-UvTY6L1N.js +0 -38
  107. package/dist/useSidebar-BJuALHqQ.js +0 -11
  108. package/dist/useTheme-DS6ZjdzM.js +0 -27
  109. package/dist/useToast-BFTk4lWz.js +0 -100
@@ -0,0 +1,60 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import { Bt as t, Ft as n, Gt as r, Nt as i, jt as a } from "./ui-CiX0E_bn.js";
3
+ import { s as o } from "./tooltip-B2dzyfs9.js";
4
+ import { t as s } from "./useMobile-pTQ8lWvt.js";
5
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
+ import { useTranslation as u } from "react-i18next";
7
+ import { MoreVerticalIcon as d } from "lucide-react";
8
+ //#region src/components/core/layouts/AppActions.tsx
9
+ function f({ actions: f, className: p }) {
10
+ let { t: m } = u(), h = s();
11
+ return !f || f.length === 0 ? null : h ? /* @__PURE__ */ l(a, { children: [/* @__PURE__ */ c(r, {
12
+ asChild: !0,
13
+ children: /* @__PURE__ */ c(o, {
14
+ variant: "outline",
15
+ size: "icon",
16
+ children: /* @__PURE__ */ c(d, { className: "size-4" })
17
+ })
18
+ }), /* @__PURE__ */ c(i, {
19
+ align: "end",
20
+ className: "min-w-48",
21
+ children: f.map((r, i) => r ? r.children && r.children.length > 0 ? /* @__PURE__ */ l("div", { children: [i > 0 && /* @__PURE__ */ c(t, {}), r.children.map((t, r) => t ? /* @__PURE__ */ l(n, {
22
+ onClick: () => void t.onClick(),
23
+ disabled: t.disabled,
24
+ className: e("gap-2", t.className),
25
+ children: [t.icon && /* @__PURE__ */ c(t.icon, { className: "size-4" }), t.labelKey && m(t.labelKey)]
26
+ }, r) : null)] }, i) : /* @__PURE__ */ l(n, {
27
+ onClick: () => void r.onClick(),
28
+ disabled: r.disabled,
29
+ className: e("gap-2", r.className),
30
+ children: [r.icon && /* @__PURE__ */ c(r.icon, { className: "size-4" }), r.labelKey && m(r.labelKey)]
31
+ }, i) : null)
32
+ })] }) : ((t) => /* @__PURE__ */ c("div", {
33
+ className: e("flex gap-2", p),
34
+ children: t.map((t, s) => t ? t.children && t.children.length > 0 ? /* @__PURE__ */ l(a, { children: [/* @__PURE__ */ c(r, {
35
+ asChild: !0,
36
+ children: /* @__PURE__ */ l(o, {
37
+ variant: t.variant,
38
+ disabled: t.disabled,
39
+ className: e("gap-2", t.className),
40
+ children: [t.icon && /* @__PURE__ */ c(t.icon, { className: "size-4" }), t.labelKey && m(t.labelKey)]
41
+ })
42
+ }), /* @__PURE__ */ c(i, {
43
+ align: "end",
44
+ children: t.children.map((t, r) => t ? /* @__PURE__ */ l(n, {
45
+ onClick: () => void t.onClick(),
46
+ disabled: t.disabled,
47
+ className: e("gap-2", t.className),
48
+ children: [t.icon && /* @__PURE__ */ c(t.icon, { className: "size-4" }), t.labelKey && m(t.labelKey)]
49
+ }, r) : null)
50
+ })] }, s) : /* @__PURE__ */ l(o, {
51
+ variant: t.variant,
52
+ onClick: () => void t.onClick(),
53
+ disabled: t.disabled,
54
+ className: e("gap-2", t.className),
55
+ children: [t.icon && /* @__PURE__ */ c(t.icon, { className: "size-4" }), t.labelKey && m(t.labelKey)]
56
+ }, s) : null)
57
+ }))(f);
58
+ }
59
+ //#endregion
60
+ export { f as t };
@@ -0,0 +1,19 @@
1
+ import { t as e } from "./AppActions-C_0YI75w.js";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ import { useTranslation as r } from "react-i18next";
4
+ //#region src/components/core/layouts/AppSubTitle.tsx
5
+ function i({ titleKey: i, actions: a, className: o }) {
6
+ let { t: s } = r();
7
+ return /* @__PURE__ */ n("div", {
8
+ className: "flex flex-col sm:flex-row sm:items-center justify-between gap-4",
9
+ children: [/* @__PURE__ */ t("h2", {
10
+ className: "text-lg font-semibold",
11
+ children: s(i)
12
+ }), /* @__PURE__ */ t(e, {
13
+ actions: a,
14
+ className: o
15
+ })]
16
+ });
17
+ }
18
+ //#endregion
19
+ export { i as t };
@@ -0,0 +1,19 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ import { useTranslation as r } from "react-i18next";
4
+ //#region src/components/core/layouts/AppTitle.tsx
5
+ function i({ titleKey: i, descriptionKey: a, isSubTitle: o }) {
6
+ let { t: s } = r();
7
+ return /* @__PURE__ */ n("div", {
8
+ className: "flex min-w-0 flex-col gap-1",
9
+ children: [/* @__PURE__ */ t("h1", {
10
+ className: o ? "text-xl md:text-2xl font-semibold" : "text-xl md:text-3xl font-bold",
11
+ children: s(i) ?? ""
12
+ }), a ? /* @__PURE__ */ t("p", {
13
+ className: e("hidden md:block text-muted-foreground", o && "text-sm"),
14
+ children: s(a)
15
+ }) : null]
16
+ });
17
+ }
18
+ //#endregion
19
+ export { i as t };
@@ -0,0 +1,27 @@
1
+ import { n as e, t } from "./alert-REQGK9bR.js";
2
+ import { t as n } from "./i18n-Dw99bRmg.js";
3
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
+ import { AlertTriangle as a } from "lucide-react";
5
+ //#region src/components/core/states/ErrorAlert.tsx
6
+ var o = ({ error: o }) => {
7
+ let { t: s } = n();
8
+ return o ? /* @__PURE__ */ i(t, {
9
+ variant: "destructive",
10
+ children: [/* @__PURE__ */ r(a, { className: "size-4" }), /* @__PURE__ */ i(e, { children: [/* @__PURE__ */ i("div", {
11
+ className: "flex items-center space-x-2",
12
+ children: [
13
+ /* @__PURE__ */ r("span", {
14
+ className: "font-semibold",
15
+ children: s("states.errorPrefix")
16
+ }),
17
+ /* @__PURE__ */ r("span", { children: o.code }),
18
+ /* @__PURE__ */ r("span", { children: o.message })
19
+ ]
20
+ }), o.errors && o.errors.length > 0 && /* @__PURE__ */ r("ul", {
21
+ className: "mt-2 list-disc list-inside",
22
+ children: o.errors.map((e, t) => /* @__PURE__ */ r("li", { children: e }, t))
23
+ })] })]
24
+ }) : null;
25
+ };
26
+ //#endregion
27
+ export { o as t };
@@ -0,0 +1,310 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import { c as t, d as n, s as r } from "./chart-Dq3AIrue.js";
3
+ import { Ct as i, Dt as a, Et as o, Ot as s, St as c, Tt as l, bn as u, p as d } from "./ui-CiX0E_bn.js";
4
+ import { s as f } from "./tooltip-B2dzyfs9.js";
5
+ import { t as p } from "./i18n-Dw99bRmg.js";
6
+ import { g as m } from "./sheet-CRrYTZrl.js";
7
+ import { i as h, l as g, n as _, t as v, u as y } from "./select-ULiTPOr5.js";
8
+ import { n as b } from "./useToast-UeDRLovh.js";
9
+ import { t as x } from "./ImageInput-CN2ozjpc.js";
10
+ import { t as S } from "./AppSubTitle-tqqV9nuT.js";
11
+ import { t as C } from "./MultiSelect-BF0zL0B0.js";
12
+ import { useState as w } from "react";
13
+ import { jsx as T, jsxs as E } from "react/jsx-runtime";
14
+ import { useTranslation as D } from "react-i18next";
15
+ import { useForm as O } from "react-hook-form";
16
+ import { zodResolver as k } from "@hookform/resolvers/zod";
17
+ import { z as A } from "zod";
18
+ //#region src/components/core/forms/GenericForm.tsx
19
+ var j = ({ schema: j, isLoading: M, error: N, onSubmit: P, onCancel: F, initialData: I, disabled: L = !1, renderActions: R = !0, onRegisterSubmit: z, defaultCols: B = 4 }) => {
20
+ let { t: V } = D(), { t: H } = p(), { toast: U } = b(), [W, G] = w(!1), [ee, K] = w({});
21
+ if (!j) return null;
22
+ let q = (e) => {
23
+ switch (e) {
24
+ case 1: return "md:col-span-1 col-span-4";
25
+ case 2: return "md:col-span-2 col-span-4";
26
+ case 3: return "md:col-span-3 col-span-4";
27
+ default: return "md:col-span-4 col-span-4";
28
+ }
29
+ }, J = (() => {
30
+ let e = {};
31
+ return j.sections.forEach((t) => {
32
+ t.fields.forEach((t) => {
33
+ if (t.rules) e[t.key] = t.rules(A);
34
+ else switch (t.type) {
35
+ case "checkbox":
36
+ e[t.key] = A.boolean().nullable().optional();
37
+ break;
38
+ case "html": break;
39
+ case "text":
40
+ case "textarea":
41
+ case "number":
42
+ case "date":
43
+ case "time":
44
+ case "select":
45
+ case "multiSelect":
46
+ case "color":
47
+ case "image": e[t.key] = A.string().nullable().optional();
48
+ }
49
+ });
50
+ }), A.object(e);
51
+ })(), Y = O({
52
+ resolver: k(J),
53
+ defaultValues: I || Object.fromEntries(j.sections.flatMap((e) => e.fields.map((e) => [e.key, e.defaultValue ?? null])))
54
+ });
55
+ w(() => {
56
+ z && z(() => void Y.handleSubmit(X)());
57
+ }), w(() => {
58
+ if (I) {
59
+ let e = {};
60
+ j.sections.forEach((t) => {
61
+ t.fields.forEach((t) => {
62
+ t.type === "image" && I[t.key] && (e[t.key] = I[t.key]);
63
+ });
64
+ }), K(e);
65
+ }
66
+ });
67
+ let X = async (e) => {
68
+ if (!W) {
69
+ if (Object.keys(Y.formState.errors).length > 0) {
70
+ U({
71
+ title: H("form.validationTitle"),
72
+ description: H("form.validationMessage"),
73
+ variant: "destructive"
74
+ });
75
+ return;
76
+ }
77
+ G(!0);
78
+ try {
79
+ await Promise.resolve(P(e));
80
+ } catch (e) {
81
+ console.error("Error during form submission:", e), U({
82
+ title: H("states.errorTitle"),
83
+ description: H("form.submitError"),
84
+ variant: "destructive"
85
+ });
86
+ } finally {
87
+ G(!1);
88
+ }
89
+ }
90
+ }, Z = (e, t) => {
91
+ t && K((n) => ({
92
+ ...n,
93
+ [e]: t
94
+ }));
95
+ }, Q = (e) => {
96
+ if (!e) return !1;
97
+ let t = (e) => {
98
+ if (!e || !e._def) return !1;
99
+ let n = e._def;
100
+ return n.typeName === "ZodNullable" ? !0 : n.innerType ? t(n.innerType) : n.type ? t(n.type) : !1;
101
+ };
102
+ try {
103
+ return t(e(A));
104
+ } catch {
105
+ return !1;
106
+ }
107
+ }, $ = (e) => {
108
+ if (!e) return !1;
109
+ let t = e(A);
110
+ return t.safeParse(void 0).success ? !1 : t._def.checks?.some((e) => e.kind === "min") ?? !1;
111
+ }, te = (t, n) => {
112
+ let r = !!Y.formState.errors[t.key], a = L;
113
+ switch (t.type) {
114
+ case "text":
115
+ case "color": return /* @__PURE__ */ T(m, {
116
+ type: t.type,
117
+ ...n,
118
+ placeholder: t.placeholderKey ? V(t.placeholderKey) : "",
119
+ className: e(r && "border-destructive"),
120
+ disabled: a,
121
+ value: n.value ?? ""
122
+ });
123
+ case "image": {
124
+ let i = t, o = i.value === void 0 ? n.value : i.value;
125
+ return /* @__PURE__ */ T(x, {
126
+ value: o ?? "",
127
+ onChange: (e) => {
128
+ if (i.onChange && i.onChange(e), n.onChange(e), e) {
129
+ let n = new FileReader();
130
+ n.onloadend = () => {
131
+ Z(t.key, n.result);
132
+ }, n.readAsDataURL(e);
133
+ }
134
+ },
135
+ accept: i.accept,
136
+ maxSizeMB: i.maxSizeMB,
137
+ hint: i.hint,
138
+ disabled: a,
139
+ className: e(r && "border-destructive")
140
+ });
141
+ }
142
+ case "date": return /* @__PURE__ */ T(m, {
143
+ type: "date",
144
+ ...n,
145
+ className: e(r && "border-destructive"),
146
+ disabled: a,
147
+ value: n.value ?? ""
148
+ });
149
+ case "time": return /* @__PURE__ */ T(m, {
150
+ type: "time",
151
+ ...n,
152
+ className: e(r && "border-destructive"),
153
+ disabled: a,
154
+ value: n.value ?? ""
155
+ });
156
+ case "checkbox": return /* @__PURE__ */ E("div", {
157
+ className: "flex items-center space-x-2",
158
+ children: [/* @__PURE__ */ T(u, {
159
+ id: t.key,
160
+ checked: n.value === !0,
161
+ onCheckedChange: (e) => {
162
+ n.onChange(e);
163
+ },
164
+ disabled: a,
165
+ className: e(r && "border-destructive")
166
+ }), /* @__PURE__ */ T("label", {
167
+ htmlFor: t.key,
168
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
169
+ children: V(t.labelKey)
170
+ })]
171
+ }, t.key);
172
+ case "textarea": return /* @__PURE__ */ T(d, {
173
+ ...n,
174
+ placeholder: t.placeholderKey ? V(t.placeholderKey) : "",
175
+ className: e(r && "border-destructive", "min-h-[100px]"),
176
+ disabled: a,
177
+ value: n.value ?? ""
178
+ });
179
+ case "number": {
180
+ let i = t;
181
+ return /* @__PURE__ */ T(m, {
182
+ type: "number",
183
+ ...n,
184
+ step: i.step,
185
+ min: i.min,
186
+ placeholder: t.placeholderKey ? V(t.placeholderKey) : "",
187
+ className: e(r && "border-destructive"),
188
+ disabled: a,
189
+ value: n.value ?? "",
190
+ onChange: (e) => {
191
+ let t = e.target.value === "" ? "" : Number(e.target.value);
192
+ n.onChange(t);
193
+ }
194
+ });
195
+ }
196
+ case "select": {
197
+ let o = t, s = Q(t.rules), c = n.value === null || n.value === void 0 ? "" : n.value, l = o.options, u = l.find((e) => e.value === c);
198
+ return /* @__PURE__ */ E(v, {
199
+ value: c,
200
+ onValueChange: n.onChange,
201
+ disabled: a,
202
+ children: [/* @__PURE__ */ T(i, { children: /* @__PURE__ */ T(g, {
203
+ className: e(r && "border-destructive"),
204
+ onClear: s && c ? (e) => {
205
+ e.preventDefault(), e.stopPropagation(), n.onChange(null);
206
+ } : void 0,
207
+ children: /* @__PURE__ */ T(y, {
208
+ placeholder: t.placeholderKey ? V(t.placeholderKey) : "",
209
+ children: u ? /* @__PURE__ */ E("div", {
210
+ className: "flex items-center gap-2",
211
+ children: [u.color && /* @__PURE__ */ T("div", {
212
+ className: "w-4 h-4 rounded-full",
213
+ style: { backgroundColor: u.color }
214
+ }), u.label]
215
+ }) : void 0
216
+ })
217
+ }) }), /* @__PURE__ */ T(_, { children: l.map((e, t) => /* @__PURE__ */ T(h, {
218
+ value: e.value,
219
+ children: /* @__PURE__ */ E("div", {
220
+ className: "flex items-center gap-2",
221
+ children: [e.color && /* @__PURE__ */ T("div", {
222
+ className: "w-4 h-4 rounded-full",
223
+ style: { backgroundColor: e.color }
224
+ }), e.label]
225
+ })
226
+ }, t)) })]
227
+ });
228
+ }
229
+ case "multiSelect": {
230
+ let e = t, r = n.value ?? [];
231
+ return /* @__PURE__ */ T(C, {
232
+ options: e.options,
233
+ selected: r,
234
+ onToggle: (e) => {
235
+ let t = r.includes(e) ? r.filter((t) => t !== e) : [...r, e];
236
+ n.onChange(t);
237
+ },
238
+ onClear: () => {
239
+ n.onChange([]);
240
+ },
241
+ onSelectAll: (e) => {
242
+ n.onChange(e);
243
+ },
244
+ placeholder: t.placeholderKey ? V(t.placeholderKey) : "",
245
+ disabled: a
246
+ });
247
+ }
248
+ case "html": return t.render(Y.getValues(), t);
249
+ default: return null;
250
+ }
251
+ }, ne = (c, u) => {
252
+ let d = /* @__PURE__ */ T("div", {
253
+ className: e("grid grid-cols-4 gap-4"),
254
+ children: c.fields.map((t) => /* @__PURE__ */ T(l, {
255
+ control: Y.control,
256
+ name: t.key,
257
+ render: ({ field: n }) => /* @__PURE__ */ E(o, {
258
+ className: e(q(t.layout?.cols ?? B)),
259
+ children: [
260
+ t.type !== "checkbox" && t.type !== "html" && /* @__PURE__ */ E(a, { children: [V(t.labelKey), $(t.rules) && /* @__PURE__ */ T("span", {
261
+ className: "text-destructive ml-1",
262
+ children: "*"
263
+ })] }),
264
+ /* @__PURE__ */ T(i, { children: te(t, n) }),
265
+ /* @__PURE__ */ T(s, {})
266
+ ]
267
+ })
268
+ }, t.key))
269
+ });
270
+ return j.useCards === !1 ? /* @__PURE__ */ E("div", {
271
+ className: "space-y-4 mb-6",
272
+ children: [c.titleKey && /* @__PURE__ */ T(S, { titleKey: c.titleKey }), d]
273
+ }, u) : /* @__PURE__ */ E(r, {
274
+ className: "mb-6",
275
+ children: [c.titleKey && /* @__PURE__ */ T(n, { children: /* @__PURE__ */ T(S, { titleKey: c.titleKey }) }), /* @__PURE__ */ T(t, { children: d })]
276
+ }, u);
277
+ };
278
+ return /* @__PURE__ */ T(c, {
279
+ ...Y,
280
+ children: /* @__PURE__ */ E("form", {
281
+ onSubmit: (e) => {
282
+ Y.handleSubmit(X)(e);
283
+ },
284
+ className: "space-y-4 px-0 w-full",
285
+ children: [/* @__PURE__ */ E("div", {
286
+ className: "space-y-4",
287
+ children: [j.sections.map((e, t) => ne(e, t)), N && /* @__PURE__ */ T("div", {
288
+ className: "text-sm font-medium text-destructive",
289
+ children: N.message
290
+ })]
291
+ }), !L && R && /* @__PURE__ */ E("div", {
292
+ className: "flex justify-end gap-3 mt-6 border-t pt-4",
293
+ children: [F && /* @__PURE__ */ T(f, {
294
+ type: "button",
295
+ variant: "outline",
296
+ onClick: F,
297
+ disabled: W || M,
298
+ children: H("actions.cancel")
299
+ }), /* @__PURE__ */ T(f, {
300
+ variant: "default",
301
+ type: "submit",
302
+ disabled: W || (M ?? !1) || Y.formState.isSubmitting,
303
+ children: H(W || M ? "actions.saving" : "actions.save")
304
+ })]
305
+ })]
306
+ })
307
+ });
308
+ };
309
+ //#endregion
310
+ export { j as t };
@@ -0,0 +1,80 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import "./ui-CiX0E_bn.js";
3
+ import { s as t } from "./tooltip-B2dzyfs9.js";
4
+ import { t as n } from "./i18n-Dw99bRmg.js";
5
+ import { t as r } from "./useNotifications-CyhTruIG.js";
6
+ import { forwardRef as i, useRef as a } from "react";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ import { ImageIcon as c, UploadIcon as l, XIcon as u } from "lucide-react";
9
+ //#region src/components/core/inputs/ImageInput.tsx
10
+ var d = i(({ value: i, onChange: d, accept: f = "image/jpeg,image/png,image/webp", maxSizeMB: p = 2, disabled: m = !1, className: h = "", hint: g = "JPG, PNG, WEBP" }, _) => {
11
+ let { t: v } = n(), { showError: y } = r(), b = a(null);
12
+ return /* @__PURE__ */ o("div", {
13
+ ref: _,
14
+ className: h,
15
+ children: i ? /* @__PURE__ */ s("div", {
16
+ className: "relative w-32 h-32 rounded-surface overflow-hidden border-2 border-border",
17
+ children: [/* @__PURE__ */ o("img", {
18
+ src: i,
19
+ alt: "Preview",
20
+ className: "w-full h-full object-cover"
21
+ }), !m && /* @__PURE__ */ o(t, {
22
+ type: "button",
23
+ variant: "destructive",
24
+ size: "sm",
25
+ className: "absolute top-1 right-1 h-6 w-6 p-0",
26
+ onClick: () => {
27
+ d(null);
28
+ },
29
+ children: /* @__PURE__ */ o(u, { className: "h-4 w-4" })
30
+ })]
31
+ }) : m ? /* @__PURE__ */ s("div", {
32
+ className: e("flex flex-col items-center justify-center w-full h-32", "border-2 border-dashed border-border rounded-surface", "bg-muted/30"),
33
+ children: [/* @__PURE__ */ o(c, { className: "h-8 w-8 text-muted-foreground/50 mb-2" }), /* @__PURE__ */ o("span", {
34
+ className: "text-sm text-muted-foreground/50",
35
+ children: v("image.empty")
36
+ })]
37
+ }) : /* @__PURE__ */ s("label", {
38
+ className: e("flex flex-col items-center justify-center w-full h-32", "border-2 border-dashed border-border rounded-surface", "cursor-pointer hover:bg-muted/50 transition-colors"),
39
+ children: [
40
+ /* @__PURE__ */ o(l, { className: "h-8 w-8 text-muted-foreground mb-2" }),
41
+ /* @__PURE__ */ o("span", {
42
+ className: "text-sm text-muted-foreground",
43
+ children: v("image.upload")
44
+ }),
45
+ /* @__PURE__ */ s("span", {
46
+ className: "text-xs text-muted-foreground mt-1",
47
+ children: [
48
+ g,
49
+ " (max ",
50
+ p,
51
+ "MB)"
52
+ ]
53
+ }),
54
+ /* @__PURE__ */ o("input", {
55
+ ref: b,
56
+ type: "file",
57
+ className: "hidden",
58
+ accept: f,
59
+ onChange: (e) => {
60
+ let t = e.target.files?.[0];
61
+ if (t) {
62
+ if (!f.split(",").map((e) => e.trim()).includes(t.type)) {
63
+ y(v("states.errorTitle"), v("image.invalidType", { types: g })), b.current && (b.current.value = "");
64
+ return;
65
+ }
66
+ if (t.size > p * 1024 * 1024) {
67
+ y(v("states.errorTitle"), v("image.tooLarge", { size: p })), b.current && (b.current.value = "");
68
+ return;
69
+ }
70
+ d(t), b.current && (b.current.value = "");
71
+ }
72
+ }
73
+ })
74
+ ]
75
+ })
76
+ });
77
+ });
78
+ d.displayName = "ImageInput";
79
+ //#endregion
80
+ export { d as t };
@@ -0,0 +1,134 @@
1
+ import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
+ import { bn as t } from "./ui-CiX0E_bn.js";
3
+ import { o as n } from "./tooltip-B2dzyfs9.js";
4
+ import { t as r } from "./i18n-Dw99bRmg.js";
5
+ import { useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
6
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
+ import { ChevronDownIcon as u, SearchIcon as d, XIcon as f } from "lucide-react";
8
+ //#region src/components/core/inputs/MultiSelect.tsx
9
+ var p = ({ options: p, selected: m, onToggle: h, onClear: g, onSelectAll: _, placeholder: v, searchable: y = !1, searchPlaceholder: b, disabled: x = !1, maxCount: S }) => {
10
+ let { t: C } = r(), [w, T] = s(""), [E, D] = s(!1), O = o(null), k = o(null), A = a(() => w === "" ? p : p.filter((e) => e.label.toLowerCase().includes(w.toLowerCase())), [p, w]), j = a(() => A.length !== 0 && A.every((e) => m.includes(e.value)), [A, m]), M = a(() => m.map((e) => p.find((t) => t.value === e)?.label ?? e), [p, m]), N = S !== void 0 && S > 0 ? M.slice(0, S) : M, P = M.length - N.length;
11
+ return i(() => {
12
+ E && y && requestAnimationFrame(() => {
13
+ k.current?.focus();
14
+ });
15
+ }, [E, y]), i(() => {
16
+ if (!E) return;
17
+ let e = (e) => {
18
+ O.current !== null && !O.current.contains(e.target) && (D(!1), T(""));
19
+ };
20
+ return document.addEventListener("mousedown", e), () => {
21
+ document.removeEventListener("mousedown", e);
22
+ };
23
+ }, [E]), /* @__PURE__ */ l("div", {
24
+ ref: O,
25
+ className: "relative w-full",
26
+ children: [/* @__PURE__ */ l("button", {
27
+ type: "button",
28
+ disabled: x,
29
+ onClick: () => {
30
+ x || D((e) => (e && T(""), !e));
31
+ },
32
+ className: e(n, "w-full", E && "ring-2 ring-ring ring-offset-2", m.length === 0 && "text-muted-foreground"),
33
+ children: [/* @__PURE__ */ c("span", {
34
+ className: "truncate",
35
+ children: m.length === 0 ? v ?? C("select.placeholder") : N.join(", ")
36
+ }), /* @__PURE__ */ l("div", {
37
+ className: "flex shrink-0 items-center gap-1",
38
+ children: [
39
+ P > 0 && /* @__PURE__ */ l("span", {
40
+ className: "rounded-control bg-muted px-1.5 py-0.5 text-xs font-medium text-foreground",
41
+ children: ["+", P]
42
+ }),
43
+ m.length > 0 && !x && /* @__PURE__ */ c("span", {
44
+ role: "button",
45
+ tabIndex: -1,
46
+ onClick: (e) => {
47
+ e.stopPropagation();
48
+ },
49
+ onPointerDown: (e) => {
50
+ e.preventDefault(), e.stopPropagation(), g();
51
+ },
52
+ className: "text-muted-foreground hover:text-foreground",
53
+ children: /* @__PURE__ */ c(f, { className: "size-4" })
54
+ }),
55
+ /* @__PURE__ */ c(u, { className: e("size-4 opacity-50 shrink-0 transition-transform", E && "rotate-180") })
56
+ ]
57
+ })]
58
+ }), E ? /* @__PURE__ */ l("div", {
59
+ className: "absolute left-0 right-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",
60
+ children: [
61
+ y ? /* @__PURE__ */ c("div", {
62
+ className: "border-b border-border p-2",
63
+ children: /* @__PURE__ */ l("div", {
64
+ className: "relative",
65
+ children: [/* @__PURE__ */ c(d, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }), /* @__PURE__ */ c("input", {
66
+ ref: k,
67
+ className: "w-full rounded-control 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",
68
+ placeholder: b ?? C("search.placeholder"),
69
+ value: w,
70
+ onChange: (e) => {
71
+ T(e.target.value);
72
+ }
73
+ })]
74
+ })
75
+ }) : null,
76
+ /* @__PURE__ */ l("div", {
77
+ 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",
78
+ children: [
79
+ A.length > 0 && /* @__PURE__ */ l("label", {
80
+ className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors",
81
+ children: [/* @__PURE__ */ c(t, {
82
+ checked: j,
83
+ onCheckedChange: () => {
84
+ if (j) {
85
+ let e = A.map((e) => e.value), t = m.filter((t) => !e.includes(t));
86
+ _ === void 0 ? g() : _(t);
87
+ } else {
88
+ let e = [...m];
89
+ A.forEach((t) => {
90
+ e.includes(t.value) || e.push(t.value);
91
+ }), _ === void 0 ? A.forEach((e) => {
92
+ m.includes(e.value) || h(e.value);
93
+ }) : _(e);
94
+ }
95
+ }
96
+ }), "Tout sélectionner"]
97
+ }),
98
+ A.length === 0 && /* @__PURE__ */ c("p", {
99
+ className: "px-2 py-3 text-center text-xs text-muted-foreground",
100
+ children: C("states.noResult")
101
+ }),
102
+ A.map((e) => /* @__PURE__ */ l("label", {
103
+ className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors",
104
+ children: [
105
+ /* @__PURE__ */ c(t, {
106
+ checked: m.includes(e.value),
107
+ onCheckedChange: () => {
108
+ h(e.value);
109
+ }
110
+ }),
111
+ e.color && /* @__PURE__ */ c("span", {
112
+ className: "size-2.5 shrink-0 rounded-full",
113
+ style: { backgroundColor: e.color }
114
+ }),
115
+ e.label
116
+ ]
117
+ }, e.value))
118
+ ]
119
+ }),
120
+ m.length > 0 && /* @__PURE__ */ c("div", {
121
+ className: "border-t border-border p-1.5",
122
+ children: /* @__PURE__ */ c("button", {
123
+ type: "button",
124
+ onClick: g,
125
+ 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",
126
+ children: "Tout désélectionner"
127
+ })
128
+ })
129
+ ]
130
+ }) : null]
131
+ });
132
+ };
133
+ //#endregion
134
+ export { p as t };