@krosoft/react 0.0.294 → 0.0.295

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 (58) hide show
  1. package/README.md +3 -0
  2. package/dist/{AppActions-CpbkO_3O.js → AppActions-NdUYh2ii.js} +2 -2
  3. package/dist/{AppSubTitle-BOVTZlUB.js → AppSubTitle-CunCNtvJ.js} +1 -1
  4. package/dist/ErrorAlert-0L-Dwqu8.js +37 -0
  5. package/dist/GenericForm-CLgO9HuL.js +311 -0
  6. package/dist/{ImageInput-BPNEywyf.js → ImageInput-DYGqUTBi.js} +2 -2
  7. package/dist/{MultiSelect-CZ4hye2w.js → MultiSelect-CXnF_D0R.js} +29 -30
  8. package/dist/{SearchInput-nr0CrMLK.js → SearchInput-DDcL_q7h.js} +7 -5
  9. package/dist/{cards-BBgGXmYa.js → cards-BB6V8VWw.js} +1 -1
  10. package/dist/components/core/cards/index.js +1 -1
  11. package/dist/components/core/dialogs/AppDialog.d.ts +40 -6
  12. package/dist/components/core/dialogs/AppDialog.d.ts.map +1 -1
  13. package/dist/components/core/dialogs/FormDialog.d.ts +8 -1
  14. package/dist/components/core/dialogs/FormDialog.d.ts.map +1 -1
  15. package/dist/components/core/dialogs/index.d.ts +1 -1
  16. package/dist/components/core/dialogs/index.d.ts.map +1 -1
  17. package/dist/components/core/dialogs/index.js +3 -3
  18. package/dist/components/core/filters/index.js +5 -5
  19. package/dist/components/core/forms/GenericForm.d.ts +4 -3
  20. package/dist/components/core/forms/GenericForm.d.ts.map +1 -1
  21. package/dist/components/core/forms/index.js +1 -1
  22. package/dist/components/core/index.js +17 -17
  23. package/dist/components/core/inputs/MultiSelect.d.ts +5 -1
  24. package/dist/components/core/inputs/MultiSelect.d.ts.map +1 -1
  25. package/dist/components/core/inputs/SingleSelect.d.ts +2 -0
  26. package/dist/components/core/inputs/SingleSelect.d.ts.map +1 -1
  27. package/dist/components/core/inputs/index.d.ts +1 -0
  28. package/dist/components/core/inputs/index.d.ts.map +1 -1
  29. package/dist/components/core/inputs/index.js +4 -4
  30. package/dist/components/core/language/index.js +1 -1
  31. package/dist/components/core/layouts/index.js +6 -6
  32. package/dist/components/core/navbar/index.js +1 -1
  33. package/dist/components/core/states/ErrorAlert.d.ts +5 -2
  34. package/dist/components/core/states/ErrorAlert.d.ts.map +1 -1
  35. package/dist/components/core/states/index.js +2 -2
  36. package/dist/components/core/table/index.js +3 -3
  37. package/dist/components/core/tabs/index.js +4 -4
  38. package/dist/components/core/theme/index.js +1 -1
  39. package/dist/components/index.js +19 -19
  40. package/dist/components/ui/button.d.ts.map +1 -1
  41. package/dist/components/ui/index.js +4 -4
  42. package/dist/dialogs-DVHdqXlO.js +217 -0
  43. package/dist/{inputs-BMCt-VqZ.js → inputs-DG8o5DMW.js} +3 -3
  44. package/dist/{language-DOGOdjzx.js → language-BvPG7v7d.js} +2 -2
  45. package/dist/{navbar-CCHGdEzE.js → navbar-CU6zaS92.js} +2 -2
  46. package/dist/{select-DmLScQKX.js → select-CsXmG_sJ.js} +1 -1
  47. package/dist/{sheet-DQTOen4V.js → sheet-4VOGdoiW.js} +1 -1
  48. package/dist/{states-BQK9jqS4.js → states-C4MdmAbW.js} +1 -1
  49. package/dist/tailwind/index.d.ts +5 -0
  50. package/dist/tailwind/index.d.ts.map +1 -1
  51. package/dist/tailwind/index.js +5 -0
  52. package/dist/{theme-q2uzluEd.js → theme-uTxCKUip.js} +2 -2
  53. package/dist/{tooltip-BmZ9Bfou.js → tooltip-CWdde1-y.js} +1 -1
  54. package/dist/{ui-D8Pg34YW.js → ui-rJqnHWNK.js} +3 -3
  55. package/package.json +1 -1
  56. package/dist/ErrorAlert-L2s8Dd1_.js +0 -27
  57. package/dist/GenericForm-D7ni-5-4.js +0 -309
  58. package/dist/dialogs-BjqvZvax.js +0 -207
package/README.md CHANGED
@@ -91,10 +91,13 @@ Rien n'oblige à suivre un preset : n'importe quelle valeur convient (`--k-radiu
91
91
  | ---------------------------------------------------------- | ---------------------------------------------------------------- |
92
92
  | `--k-success`, `--k-warning`, `--k-info` (+ `-foreground`) | `bg-success`, `text-warning-foreground`, `border-info`… |
93
93
  | `--k-topbar-*` | `bg-topbar`, `text-topbar-foreground`, `bg-topbar-accent`… |
94
+ | `--k-brand-from`, `--k-brand-to`, `--k-brand-foreground` | `from-brand-from`, `to-brand-to`, `text-brand-foreground` |
94
95
  | `--k-sidebar-muted` | `text-sidebar-muted` |
95
96
  | `--k-radius-control`, `--k-radius-surface` (+ `-dense`) | `rounded-control`, `rounded-surface` |
96
97
  | `--k-font-heading`, `--k-font-body` | appliquées directement par `globals.css` sur `body` et `h1`–`h6` |
97
98
 
99
+ `--k-brand-*` est le dégradé de marque : il habille l'en-tête d'`AppDialog`. Deux bornes plutôt qu'une couleur pleine, parce que les surfaces qui le portent sont des dégradés — un thème qui n'en veut pas met la même valeur des deux côtés. Il est déclaré sur `:root` seulement, comme la palette des graphes : ces teintes portent du texte blanc et restent identiques en clair comme en sombre.
100
+
98
101
  Ces couleurs sont désormais mappées par le preset partagé : un projet consommateur qui les déclarait dans son propre `tailwind.config` peut supprimer ces lignes.
99
102
 
100
103
  Story `Démos/Radius` pour comparer les presets, sélecteur **Radius** dans la barre d'outils Storybook pour les appliquer à n'importe quelle story.
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
2
  import { t } from "./i18n-d2p0RJo9.js";
3
- import { Bt as n, Ft as r, Gt as i, Nt as a, jt as o } from "./ui-D8Pg34YW.js";
4
- import { s } from "./tooltip-BmZ9Bfou.js";
3
+ import { Bt as n, Ft as r, Gt as i, Nt as a, jt as o } from "./ui-rJqnHWNK.js";
4
+ import { s } from "./tooltip-CWdde1-y.js";
5
5
  import { t as c } from "./useMobile-pTQ8lWvt.js";
6
6
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
7
  import { MoreVerticalIcon as d } from "lucide-react";
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./i18n-d2p0RJo9.js";
2
- import { t } from "./AppActions-CpbkO_3O.js";
2
+ import { t } from "./AppActions-NdUYh2ii.js";
3
3
  import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
4
  //#region src/components/core/layouts/AppSubTitle.tsx
5
5
  function i({ titleKey: i, actions: a, className: o }) {
@@ -0,0 +1,37 @@
1
+ import { t as e } from "./i18n-d2p0RJo9.js";
2
+ import { n as t, t as n } from "./alert-REQGK9bR.js";
3
+ import "react";
4
+ import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
+ import { AlertTriangle as a } from "lucide-react";
6
+ //#region src/components/core/states/ErrorAlert.tsx
7
+ var o = (e) => e instanceof Error ? {} : {
8
+ code: e.code,
9
+ errors: e.errors ?? void 0
10
+ }, s = ({ error: s, className: c }) => {
11
+ let { t: l } = e();
12
+ if (!s) return null;
13
+ let { code: u, errors: d } = o(s);
14
+ return /* @__PURE__ */ i(n, {
15
+ variant: "destructive",
16
+ className: c,
17
+ children: [/* @__PURE__ */ r(a, { className: "size-4" }), /* @__PURE__ */ i(t, { children: [/* @__PURE__ */ i("div", {
18
+ className: "flex items-center space-x-2",
19
+ children: [
20
+ /* @__PURE__ */ r("span", {
21
+ className: "font-semibold",
22
+ children: l("states.errorPrefix")
23
+ }),
24
+ u !== void 0 && /* @__PURE__ */ r("span", { children: u }),
25
+ /* @__PURE__ */ r("span", {
26
+ className: "break-words [overflow-wrap:anywhere]",
27
+ children: s.message
28
+ })
29
+ ]
30
+ }), d && d.length > 0 && /* @__PURE__ */ r("ul", {
31
+ className: "mt-2 list-disc list-inside",
32
+ children: d.map((e, t) => /* @__PURE__ */ r("li", { children: e }, t))
33
+ })] })]
34
+ });
35
+ };
36
+ //#endregion
37
+ export { s as t };
@@ -0,0 +1,311 @@
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 { t as i } from "./i18n-d2p0RJo9.js";
4
+ import { Ct as a, Dt as o, Et as s, Ot as c, St as l, Tt as u, bn as d, p as f } from "./ui-rJqnHWNK.js";
5
+ import { s as p } from "./tooltip-CWdde1-y.js";
6
+ import { g as m } from "./sheet-4VOGdoiW.js";
7
+ import { i as h, l as g, n as ee, t as _, u as v } from "./select-CsXmG_sJ.js";
8
+ import { n as y } from "./useToast-UeDRLovh.js";
9
+ import { t as b } from "./ImageInput-DYGqUTBi.js";
10
+ import { t as x } from "./AppSubTitle-CunCNtvJ.js";
11
+ import { t as S } from "./MultiSelect-CXnF_D0R.js";
12
+ import { useEffect as C, useRef as w, useState as T } from "react";
13
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
14
+ import { useForm as O } from "react-hook-form";
15
+ import { zodResolver as k } from "@hookform/resolvers/zod";
16
+ import { z as A } from "zod";
17
+ //#region src/components/core/forms/GenericForm.tsx
18
+ var j = (e) => {
19
+ let t = {};
20
+ return (e?.sections ?? []).forEach((e) => {
21
+ e.fields.forEach((e) => {
22
+ if (e.rules) t[e.key] = e.rules(A);
23
+ else switch (e.type) {
24
+ case "checkbox":
25
+ t[e.key] = A.boolean().nullable().optional();
26
+ break;
27
+ case "html": break;
28
+ case "text":
29
+ case "textarea":
30
+ case "number":
31
+ case "date":
32
+ case "time":
33
+ case "select":
34
+ case "multiSelect":
35
+ case "color":
36
+ case "image": t[e.key] = A.string().nullable().optional();
37
+ }
38
+ });
39
+ }), A.object(t);
40
+ }, M = (e, t) => t || Object.fromEntries((e?.sections ?? []).flatMap((e) => e.fields.map((e) => [e.key, e.defaultValue ?? null]))), N = (e, t) => {
41
+ let n = {};
42
+ return t && (e?.sections ?? []).forEach((e) => {
43
+ e.fields.forEach((e) => {
44
+ let r = t[e.key];
45
+ e.type === "image" && typeof r == "string" && r && (n[e.key] = r);
46
+ });
47
+ }), n;
48
+ }, P = ({ schema: P, isLoading: F, error: I, onSubmit: L, onCancel: R, initialData: z, disabled: B = !1, renderActions: V = !0, id: H, defaultCols: U = 4 }) => {
49
+ let { t: W } = i(), { toast: G } = y(), [K, q] = T(!1), [J, Y] = T(() => N(P, z)), X = O({
50
+ resolver: k(j(P)),
51
+ defaultValues: M(P, z)
52
+ }), Z = w(!!P);
53
+ C(() => {
54
+ !P || Z.current || (Z.current = !0, X.reset(M(P, z)), Y(N(P, z)));
55
+ }, [
56
+ X,
57
+ P,
58
+ z
59
+ ]);
60
+ let Q = (e) => {
61
+ switch (e) {
62
+ case 1: return "md:col-span-1 col-span-4";
63
+ case 2: return "md:col-span-2 col-span-4";
64
+ case 3: return "md:col-span-3 col-span-4";
65
+ default: return "md:col-span-4 col-span-4";
66
+ }
67
+ }, te = async (e) => {
68
+ if (!K) {
69
+ if (Object.keys(X.formState.errors).length > 0) {
70
+ G({
71
+ title: W("form.validationTitle"),
72
+ description: W("form.validationMessage"),
73
+ variant: "destructive"
74
+ });
75
+ return;
76
+ }
77
+ q(!0);
78
+ try {
79
+ await Promise.resolve(L(e));
80
+ } catch (e) {
81
+ console.error("Error during form submission:", e), G({
82
+ title: W("states.errorTitle"),
83
+ description: W("form.submitError"),
84
+ variant: "destructive"
85
+ });
86
+ } finally {
87
+ q(!1);
88
+ }
89
+ }
90
+ }, $ = (e, t) => {
91
+ Y((n) => ({
92
+ ...n,
93
+ [e]: t
94
+ }));
95
+ }, ne = (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
+ }, re = (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
+ }, ie = (t, n) => {
112
+ let r = !!X.formState.errors[t.key], i = B;
113
+ switch (t.type) {
114
+ case "text":
115
+ case "color": return /* @__PURE__ */ E(m, {
116
+ type: t.type,
117
+ ...n,
118
+ placeholder: t.placeholderKey ? W(t.placeholderKey) : "",
119
+ className: e(r && "border-destructive"),
120
+ disabled: i,
121
+ value: n.value ?? ""
122
+ });
123
+ case "image": {
124
+ let a = t, o = t.key, s = typeof n.value == "string" ? n.value : void 0, c = a.value === void 0 ? s ?? J[o] : a.value;
125
+ return /* @__PURE__ */ E(b, {
126
+ value: c ?? "",
127
+ onChange: (e) => {
128
+ if (a.onChange && a.onChange(e), n.onChange(e), e) {
129
+ let t = new FileReader();
130
+ t.onloadend = () => {
131
+ $(o, t.result);
132
+ }, t.readAsDataURL(e);
133
+ } else $(o, "");
134
+ },
135
+ accept: a.accept,
136
+ maxSizeMB: a.maxSizeMB,
137
+ hint: a.hint,
138
+ disabled: i,
139
+ className: e(r && "border-destructive")
140
+ });
141
+ }
142
+ case "date": return /* @__PURE__ */ E(m, {
143
+ type: "date",
144
+ ...n,
145
+ className: e(r && "border-destructive"),
146
+ disabled: i,
147
+ value: n.value ?? ""
148
+ });
149
+ case "time": return /* @__PURE__ */ E(m, {
150
+ type: "time",
151
+ ...n,
152
+ className: e(r && "border-destructive"),
153
+ disabled: i,
154
+ value: n.value ?? ""
155
+ });
156
+ case "checkbox": return /* @__PURE__ */ D("div", {
157
+ className: "flex items-center space-x-2",
158
+ children: [/* @__PURE__ */ E(d, {
159
+ id: t.key,
160
+ checked: n.value === !0,
161
+ onCheckedChange: (e) => {
162
+ n.onChange(e);
163
+ },
164
+ disabled: i,
165
+ className: e(r && "border-destructive")
166
+ }), /* @__PURE__ */ E("label", {
167
+ htmlFor: t.key,
168
+ className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
169
+ children: W(t.labelKey)
170
+ })]
171
+ }, t.key);
172
+ case "textarea": return /* @__PURE__ */ E(f, {
173
+ ...n,
174
+ placeholder: t.placeholderKey ? W(t.placeholderKey) : "",
175
+ className: e(r && "border-destructive", "min-h-[100px]"),
176
+ disabled: i,
177
+ value: n.value ?? ""
178
+ });
179
+ case "number": {
180
+ let a = t;
181
+ return /* @__PURE__ */ E(m, {
182
+ type: "number",
183
+ ...n,
184
+ step: a.step,
185
+ min: a.min,
186
+ placeholder: t.placeholderKey ? W(t.placeholderKey) : "",
187
+ className: e(r && "border-destructive"),
188
+ disabled: i,
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 = ne(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__ */ D(_, {
199
+ value: c,
200
+ onValueChange: n.onChange,
201
+ disabled: i,
202
+ children: [/* @__PURE__ */ E(a, { children: /* @__PURE__ */ E(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__ */ E(v, {
208
+ placeholder: t.placeholderKey ? W(t.placeholderKey) : "",
209
+ children: u ? /* @__PURE__ */ D("div", {
210
+ className: "flex items-center gap-2",
211
+ children: [u.color && /* @__PURE__ */ E("div", {
212
+ className: "w-4 h-4 rounded-full",
213
+ style: { backgroundColor: u.color }
214
+ }), u.label]
215
+ }) : void 0
216
+ })
217
+ }) }), /* @__PURE__ */ E(ee, { children: l.map((e, t) => /* @__PURE__ */ E(h, {
218
+ value: e.value,
219
+ children: /* @__PURE__ */ D("div", {
220
+ className: "flex items-center gap-2",
221
+ children: [e.color && /* @__PURE__ */ E("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__ */ E(S, {
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 ? W(t.placeholderKey) : "",
245
+ disabled: i
246
+ });
247
+ }
248
+ case "html": return t.render(X.getValues(), t);
249
+ default: return null;
250
+ }
251
+ }, ae = (i, l) => {
252
+ let d = /* @__PURE__ */ E("div", {
253
+ className: e("grid grid-cols-4 gap-4"),
254
+ children: i.fields.map((t) => /* @__PURE__ */ E(u, {
255
+ control: X.control,
256
+ name: t.key,
257
+ render: ({ field: n }) => /* @__PURE__ */ D(s, {
258
+ className: e(Q(t.layout?.cols ?? U)),
259
+ children: [
260
+ t.type !== "checkbox" && t.type !== "html" && /* @__PURE__ */ D(o, { children: [W(t.labelKey), re(t.rules) && /* @__PURE__ */ E("span", {
261
+ className: "text-destructive ml-1",
262
+ children: "*"
263
+ })] }),
264
+ /* @__PURE__ */ E(a, { children: ie(t, n) }),
265
+ /* @__PURE__ */ E(c, {})
266
+ ]
267
+ })
268
+ }, t.key))
269
+ });
270
+ return P?.useCards === !1 ? /* @__PURE__ */ D("div", {
271
+ className: "space-y-4 mb-6",
272
+ children: [i.titleKey && /* @__PURE__ */ E(x, { titleKey: i.titleKey }), d]
273
+ }, l) : /* @__PURE__ */ D(r, {
274
+ className: "mb-6",
275
+ children: [i.titleKey && /* @__PURE__ */ E(n, { children: /* @__PURE__ */ E(x, { titleKey: i.titleKey }) }), /* @__PURE__ */ E(t, { children: d })]
276
+ }, l);
277
+ };
278
+ return P ? /* @__PURE__ */ E(l, {
279
+ ...X,
280
+ children: /* @__PURE__ */ D("form", {
281
+ id: H,
282
+ onSubmit: (e) => {
283
+ X.handleSubmit(te)(e);
284
+ },
285
+ className: "space-y-4 px-0 w-full",
286
+ children: [/* @__PURE__ */ D("div", {
287
+ className: "space-y-4",
288
+ children: [P.sections.map((e, t) => ae(e, t)), I && /* @__PURE__ */ E("div", {
289
+ className: "text-sm font-medium text-destructive",
290
+ children: I.message
291
+ })]
292
+ }), !B && V && /* @__PURE__ */ D("div", {
293
+ className: "flex justify-end gap-3 mt-6 border-t pt-4",
294
+ children: [R && /* @__PURE__ */ E(p, {
295
+ type: "button",
296
+ variant: "outline",
297
+ onClick: R,
298
+ disabled: K || F,
299
+ children: W("actions.cancel")
300
+ }), /* @__PURE__ */ E(p, {
301
+ variant: "default",
302
+ type: "submit",
303
+ disabled: K || (F ?? !1) || X.formState.isSubmitting,
304
+ children: W(K || F ? "actions.saving" : "actions.save")
305
+ })]
306
+ })]
307
+ })
308
+ }) : null;
309
+ };
310
+ //#endregion
311
+ export { P as t };
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
2
  import { t } from "./i18n-d2p0RJo9.js";
3
- import "./ui-D8Pg34YW.js";
4
- import { s as n } from "./tooltip-BmZ9Bfou.js";
3
+ import "./ui-rJqnHWNK.js";
4
+ import { s as n } from "./tooltip-CWdde1-y.js";
5
5
  import { t as r } from "./useNotifications-CyhTruIG.js";
6
6
  import { forwardRef as i, useRef as a } from "react";
7
7
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
@@ -1,37 +1,35 @@
1
1
  import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
2
  import { t } from "./i18n-d2p0RJo9.js";
3
- import { bn as n } from "./ui-D8Pg34YW.js";
4
- import { a as r, o as i } from "./tooltip-BmZ9Bfou.js";
5
- import { h as a, m as o, p as s } from "./sheet-DQTOen4V.js";
3
+ import { bn as n } from "./ui-rJqnHWNK.js";
4
+ import { a as r, o as i } from "./tooltip-CWdde1-y.js";
5
+ import { h as a, m as o, p as s } from "./sheet-4VOGdoiW.js";
6
6
  import { useMemo as c, useState as l } from "react";
7
7
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
8
8
  import { ChevronDownIcon as f, SearchIcon as p, XIcon as m } from "lucide-react";
9
9
  import { Command as h } from "cmdk";
10
10
  //#region src/components/core/inputs/MultiSelect.tsx
11
11
  var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, variant: x = "input", placeholder: S, labelKey: C, searchable: w = !1, searchPlaceholder: T, disabled: E = !1, maxCount: D, className: O }) => {
12
- let { t: k } = t(), [A, j] = l(""), [M, N] = l(!1), P = x === "pill", F = c(() => A === "" ? g : g.filter((e) => e.label.toLowerCase().includes(A.toLowerCase())), [g, A]), I = c(() => F.length !== 0 && F.every((e) => _.includes(e.value)), [F, _]), L = c(() => _.map((e) => g.find((t) => t.value === e)?.label ?? e), [g, _]), R = D !== void 0 && D > 0 ? L.slice(0, D) : L, z = L.length - R.length, B = (e) => {
12
+ let { t: k } = t(), [A, j] = l(""), [M, N] = l(!1), P = x === "pill", F = c(() => A === "" ? g : g.filter((e) => e.label.toLowerCase().includes(A.toLowerCase())), [g, A]), I = c(() => F.filter((e) => e.disabled !== !0).map((e) => e.value), [F]), L = c(() => _.filter((e) => g.find((t) => t.value === e)?.disabled === !0), [g, _]), R = c(() => I.length !== 0 && I.every((e) => _.includes(e)), [I, _]), z = c(() => _.map((e) => g.find((t) => t.value === e)?.label ?? e), [g, _]), B = D !== void 0 && D > 0 ? z.slice(0, D) : z, V = z.length - B.length, H = (e) => {
13
13
  N(e), e || j("");
14
- }, V = () => {
15
- y === void 0 ? b === void 0 ? _.forEach((e) => {
14
+ }, U = () => {
15
+ L.length > 0 ? b === void 0 ? _.filter((e) => !L.includes(e)).forEach((e) => {
16
+ v(e);
17
+ }) : b(L) : y === void 0 ? b === void 0 ? _.forEach((e) => {
16
18
  v(e);
17
19
  }) : b([]) : y();
18
- }, H = () => {
19
- if (I) {
20
- if (b !== void 0) {
21
- let e = F.map((e) => e.value);
22
- b(_.filter((t) => !e.includes(t)));
23
- } else y === void 0 ? _.forEach((e) => {
24
- v(e);
25
- }) : y();
26
- } else if (b !== void 0) {
20
+ }, W = () => {
21
+ if (R) b === void 0 ? y !== void 0 && _.every((e) => I.includes(e)) ? y() : I.forEach((e) => {
22
+ v(e);
23
+ }) : b(_.filter((e) => !I.includes(e)));
24
+ else if (b !== void 0) {
27
25
  let e = [..._];
28
- F.forEach((t) => {
29
- e.includes(t.value) || e.push(t.value);
26
+ I.forEach((t) => {
27
+ e.includes(t) || e.push(t);
30
28
  }), b(e);
31
- } else F.forEach((e) => {
32
- _.includes(e.value) || v(e.value);
29
+ } else I.forEach((e) => {
30
+ _.includes(e) || v(e);
33
31
  });
34
- }, U = P ? /* @__PURE__ */ d("button", {
32
+ }, G = P ? /* @__PURE__ */ d("button", {
35
33
  type: "button",
36
34
  disabled: E,
37
35
  className: e(r, "inline-flex items-center justify-between gap-1.5 whitespace-nowrap transition-colors", _.length > 0 ? "border-primary bg-primary/10 text-primary font-medium" : "hover:bg-muted", O ?? "w-full md:w-[180px]"),
@@ -51,13 +49,13 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
51
49
  className: e(i, "w-full", M && "ring-2 ring-ring ring-offset-2", _.length === 0 && "text-muted-foreground", O),
52
50
  children: [/* @__PURE__ */ u("span", {
53
51
  className: "truncate",
54
- children: _.length === 0 ? S ?? k("select.placeholder") : R.join(", ")
52
+ children: _.length === 0 ? S ?? k("select.placeholder") : B.join(", ")
55
53
  }), /* @__PURE__ */ d("div", {
56
54
  className: "flex shrink-0 items-center gap-1",
57
55
  children: [
58
- z > 0 && /* @__PURE__ */ d("span", {
56
+ V > 0 && /* @__PURE__ */ d("span", {
59
57
  className: "rounded-control bg-muted px-1.5 py-0.5 text-xs font-medium text-foreground",
60
- children: ["+", z]
58
+ children: ["+", V]
61
59
  }),
62
60
  _.length > 0 && !E && /* @__PURE__ */ u("span", {
63
61
  role: "button",
@@ -66,7 +64,7 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
66
64
  e.stopPropagation();
67
65
  },
68
66
  onPointerDown: (e) => {
69
- e.preventDefault(), e.stopPropagation(), V();
67
+ e.preventDefault(), e.stopPropagation(), U();
70
68
  },
71
69
  className: "text-muted-foreground hover:text-foreground",
72
70
  children: /* @__PURE__ */ u(m, { className: "size-4" })
@@ -77,10 +75,10 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
77
75
  });
78
76
  return /* @__PURE__ */ d(s, {
79
77
  open: M,
80
- onOpenChange: B,
78
+ onOpenChange: H,
81
79
  children: [/* @__PURE__ */ u(a, {
82
80
  asChild: !0,
83
- children: U
81
+ children: G
84
82
  }), /* @__PURE__ */ d(o, {
85
83
  className: e("p-0", P ? "w-72 max-w-[var(--radix-popover-content-available-width)]" : "w-[var(--radix-popover-trigger-width)]"),
86
84
  align: "start",
@@ -110,10 +108,11 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
110
108
  children: k("states.noResult")
111
109
  }), F.map((e) => /* @__PURE__ */ d(h.Item, {
112
110
  value: e.value,
111
+ disabled: e.disabled,
113
112
  onSelect: () => {
114
113
  v(e.value);
115
114
  },
116
- className: "flex min-w-0 items-center gap-2.5 rounded-md px-2 py-2 text-sm cursor-pointer transition-colors data-[selected=true]:bg-muted",
115
+ className: "flex min-w-0 items-center gap-2.5 rounded-md px-2 py-2 text-sm cursor-pointer transition-colors data-[selected=true]:bg-muted data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50",
117
116
  children: [
118
117
  /* @__PURE__ */ u("span", {
119
118
  className: "pointer-events-none shrink-0",
@@ -131,13 +130,13 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
131
130
  ]
132
131
  }, e.value))]
133
132
  })]
134
- }), F.length > 0 && /* @__PURE__ */ u("div", {
133
+ }), I.length > 0 && /* @__PURE__ */ u("div", {
135
134
  className: "border-t border-border p-1.5",
136
135
  children: /* @__PURE__ */ u("button", {
137
136
  type: "button",
138
- onClick: H,
137
+ onClick: W,
139
138
  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",
140
- children: k(I ? "filters.deselectAll" : "filters.selectAll")
139
+ children: k(R ? "filters.deselectAll" : "filters.selectAll")
141
140
  })
142
141
  })]
143
142
  })]
@@ -1,9 +1,9 @@
1
1
  import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
2
  import { r as t, t as n } from "./i18n-d2p0RJo9.js";
3
- import { En as r } from "./ui-D8Pg34YW.js";
4
- import { o as i, s as a } from "./tooltip-BmZ9Bfou.js";
5
- import { g as o, h as s, m as c, p as l } from "./sheet-DQTOen4V.js";
6
- import { i as u, l as d, n as f, t as p, u as m } from "./select-DmLScQKX.js";
3
+ import { En as r } from "./ui-rJqnHWNK.js";
4
+ import { o as i, s as a } from "./tooltip-CWdde1-y.js";
5
+ import { g as o, h as s, m as c, p as l } from "./sheet-4VOGdoiW.js";
6
+ import { i as u, l as d, n as f, t as p, u as m } from "./select-CsXmG_sJ.js";
7
7
  import * as h from "react";
8
8
  import { useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
9
9
  import { jsx as b, jsxs as x } from "react/jsx-runtime";
@@ -141,6 +141,7 @@ var A = ({ date: n, onDateChange: i, placeholder: o }) => {
141
141
  children: /* @__PURE__ */ b(m, { placeholder: v ?? P("select.placeholder") })
142
142
  }), /* @__PURE__ */ b(f, { children: t.map((e) => /* @__PURE__ */ b(u, {
143
143
  value: e.value,
144
+ disabled: e.disabled,
144
145
  children: /* @__PURE__ */ x("span", {
145
146
  className: "flex items-center",
146
147
  children: [
@@ -242,10 +243,11 @@ var A = ({ date: n, onDateChange: i, placeholder: o }) => {
242
243
  t.map((t) => /* @__PURE__ */ x(O.Item, {
243
244
  value: t.value,
244
245
  keywords: [t.label, t.description ?? ""],
246
+ disabled: t.disabled,
245
247
  onSelect: () => {
246
248
  G(t.value);
247
249
  },
248
- className: "flex min-w-0 items-center gap-2.5 rounded-md px-2 py-2 text-sm cursor-pointer transition-colors data-[selected=true]:bg-muted",
250
+ className: "flex min-w-0 items-center gap-2.5 rounded-md px-2 py-2 text-sm cursor-pointer transition-colors data-[selected=true]:bg-muted data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50",
249
251
  children: [
250
252
  /* @__PURE__ */ b(C, { className: e("size-4 shrink-0", r === t.value ? "opacity-100" : "opacity-0") }),
251
253
  t.color && /* @__PURE__ */ b("span", {
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./tailwind.helper-CJaRYBmL.js";
2
2
  import { c as t, d as n, f as r, s as i } from "./chart-Dq3AIrue.js";
3
3
  import { t as a } from "./i18n-d2p0RJo9.js";
4
- import "./ui-D8Pg34YW.js";
4
+ import "./ui-rJqnHWNK.js";
5
5
  import { t as o } from "./skeleton-D6Ga4BLw.js";
6
6
  import "react";
7
7
  import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
@@ -1,2 +1,2 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "../../../cards-BBgGXmYa.js";
1
+ import { a as e, i as t, n, o as r, r as i, t as a } from "../../../cards-BB6V8VWw.js";
2
2
  export { r as DashboardCard, e as KpiCard, t as KpiCards, i as MetricCard, n as SkeletonCard, a as SkeletonCards };
@@ -1,28 +1,62 @@
1
+ import { buttonVariants } from "../../../components/ui";
2
+ import { ErrorHttp } from "@krosoft/core/types";
3
+ import type { VariantProps } from "class-variance-authority";
1
4
  import React from "react";
2
- export type ButtonVariantType = "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | "styled";
5
+ /** Dérivé de `buttonVariants` : un variant ajouté au `Button` devient utilisable ici sans rien recopier. */
6
+ export type ButtonVariantType = NonNullable<VariantProps<typeof buttonVariants>["variant"]>;
7
+ export type AppDialogSize = "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "full";
3
8
  export interface DialogAction {
9
+ /** Clé de rendu. À défaut, le libellé sert de clé : à renseigner si deux actions partagent le même. */
10
+ id?: string;
11
+ /** Clé i18n, ou libellé déjà résolu — le repli i18next renvoie la chaîne telle quelle. */
4
12
  label: string;
5
- onClick: () => void;
13
+ onClick?: () => void;
6
14
  variant?: ButtonVariantType;
7
15
  disabled?: boolean;
8
16
  icon?: React.ElementType;
9
17
  className?: string;
18
+ /**
19
+ * `"submit"` combiné à `form` soumet un formulaire rendu dans `children` : c'est
20
+ * ce qui évite de remonter le `submit` du formulaire jusqu'au pied de la dialog.
21
+ */
22
+ type?: "button" | "submit";
23
+ /** `id` du `<form>` visé par une action `"submit"`. */
24
+ form?: string;
25
+ /**
26
+ * Désactivation automatique pendant `isLoading`. Passer `false` pour une action
27
+ * qui doit rester atteignable pendant le chargement (« Annuler » d'un envoi long).
28
+ */
29
+ disableOnLoading?: boolean;
10
30
  }
11
31
  export interface AppDialogConfig {
12
- title: string;
13
- description?: string;
32
+ /** Une chaîne est traitée comme une clé i18n ; passer un `ReactNode` pour un libellé métier à ne pas traduire. */
33
+ title: React.ReactNode;
34
+ description?: React.ReactNode;
14
35
  icon?: React.ElementType;
36
+ /** Largeur maximale à partir de `sm`. `xl` par défaut. */
37
+ size?: AppDialogSize;
38
+ /**
39
+ * Classe de largeur brute, breakpoint compris (`"sm:max-w-4xl"`).
40
+ * @deprecated Préférer `size`, qui n'oblige pas à connaître le gabarit interne.
41
+ */
15
42
  maxWidth?: string;
43
+ /** Ignoré si un `footer` est fourni au composant. */
16
44
  actions?: DialogAction[];
45
+ headerClassName?: string;
46
+ footerClassName?: string;
17
47
  }
18
48
  interface AppDialogProps {
19
49
  open: boolean;
20
50
  onOpenChange: (open: boolean) => void;
21
51
  config: AppDialogConfig;
52
+ /** Affiche une barre de progression, désactive les actions et verrouille la fermeture. */
22
53
  isLoading?: boolean;
23
- error?: Error | null;
54
+ error?: ErrorHttp | Error | null;
55
+ /** Pied de dialog libre, prioritaire sur `config.actions`. */
56
+ footer?: React.ReactNode;
57
+ className?: string;
24
58
  children: React.ReactNode;
25
59
  }
26
- export declare function AppDialog({ open, onOpenChange, config, isLoading, error, children }: AppDialogProps): React.ReactElement;
60
+ export declare function AppDialog({ open, onOpenChange, config, isLoading, error, footer, className, children }: AppDialogProps): React.ReactElement;
27
61
  export {};
28
62
  //# sourceMappingURL=AppDialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/core/dialogs/AppDialog.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;AAElH,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;CAC1B;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,CAoDxH"}
1
+ {"version":3,"file":"AppDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/core/dialogs/AppDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAU,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIzD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,4GAA4G;AAC5G,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,YAAY,CAAC,OAAO,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAE5F,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC;AAkBvF,MAAM,WAAW,YAAY;IAC3B,uGAAuG;IACvG,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,0FAA0F;IAC1F,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC3B,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,kHAAkH;IAClH,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACzB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,eAAe,CAAC;IACxB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,IAAI,CAAC;IACjC,8DAA8D;IAC9D,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,CA4F3I"}