@krosoft/react 0.0.294 → 0.0.296

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 (63) hide show
  1. package/README.md +3 -0
  2. package/dist/{AppActions-CpbkO_3O.js → AppActions-BMh044Sc.js} +2 -2
  3. package/dist/{AppSubTitle-BOVTZlUB.js → AppSubTitle-BfZTloah.js} +1 -1
  4. package/dist/ErrorAlert-0L-Dwqu8.js +37 -0
  5. package/dist/GenericForm-BV8n9y1n.js +311 -0
  6. package/dist/{ImageInput-BPNEywyf.js → ImageInput-BdOxyamZ.js} +2 -2
  7. package/dist/{MultiSelect-CZ4hye2w.js → MultiSelect-Dmt1iWgB.js} +45 -44
  8. package/dist/{SearchInput-nr0CrMLK.js → SearchInput-81oecSco.js} +42 -38
  9. package/dist/{cards-BBgGXmYa.js → cards-BFa9EQc6.js} +1 -1
  10. package/dist/components/core/cards/index.js +1 -1
  11. package/dist/components/core/dialogs/AppDialog.d.ts +38 -7
  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 +13 -3
  24. package/dist/components/core/inputs/MultiSelect.d.ts.map +1 -1
  25. package/dist/components/core/inputs/SingleSelect.d.ts +10 -2
  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 +2 -2
  41. package/dist/components/ui/button.d.ts.map +1 -1
  42. package/dist/components/ui/command.d.ts +7 -7
  43. package/dist/components/ui/index.js +4 -4
  44. package/dist/components/ui/input-otp.d.ts +2 -2
  45. package/dist/dialogs-CUKX7EFT.js +217 -0
  46. package/dist/{inputs-BMCt-VqZ.js → inputs-V2h_AcMW.js} +3 -3
  47. package/dist/{language-DOGOdjzx.js → language-9nbLYpqG.js} +2 -2
  48. package/dist/{navbar-CCHGdEzE.js → navbar-BLdw6QDi.js} +2 -2
  49. package/dist/{select-DmLScQKX.js → select-CfhuieLs.js} +1 -1
  50. package/dist/{sheet-DQTOen4V.js → sheet-DRzg-JWH.js} +1 -1
  51. package/dist/{states-BQK9jqS4.js → states-C4MdmAbW.js} +1 -1
  52. package/dist/tailwind/index.d.ts +5 -0
  53. package/dist/tailwind/index.d.ts.map +1 -1
  54. package/dist/tailwind/index.js +5 -0
  55. package/dist/{theme-q2uzluEd.js → theme-2eQs7CHF.js} +2 -2
  56. package/dist/{tooltip-BmZ9Bfou.js → tooltip-Bu3wNhtW.js} +1 -1
  57. package/dist/types/ButtonVariantType.d.ts +9 -1
  58. package/dist/types/ButtonVariantType.d.ts.map +1 -1
  59. package/dist/{ui-D8Pg34YW.js → ui-DVtB9U8H.js} +3 -3
  60. package/package.json +1 -1
  61. package/dist/ErrorAlert-L2s8Dd1_.js +0 -27
  62. package/dist/GenericForm-D7ni-5-4.js +0 -309
  63. 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` et le bouton `variant="brand"`. 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. C'est la surface la plus identitaire du package : chaque thème embarqué le redéclare avec ses propres teintes (violet par défaut, jaune sur Temporal, cyan sur Ocean). `--k-brand-foreground` porte le texte et les icônes posés dessus, et n'est donc pas toujours blanc : un dégradé clair demande un texte sombre. Story `Design Tokens/Marque` pour comparer les thèmes côte à côte.
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-DVtB9U8H.js";
4
+ import { s } from "./tooltip-Bu3wNhtW.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-BMh044Sc.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-DVtB9U8H.js";
5
+ import { s as p } from "./tooltip-Bu3wNhtW.js";
6
+ import { g as m } from "./sheet-DRzg-JWH.js";
7
+ import { i as h, l as g, n as ee, t as _, u as v } from "./select-CfhuieLs.js";
8
+ import { n as y } from "./useToast-UeDRLovh.js";
9
+ import { t as b } from "./ImageInput-BdOxyamZ.js";
10
+ import { t as x } from "./AppSubTitle-BfZTloah.js";
11
+ import { t as S } from "./MultiSelect-Dmt1iWgB.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-DVtB9U8H.js";
4
+ import { s as n } from "./tooltip-Bu3wNhtW.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,63 +1,63 @@
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-DVtB9U8H.js";
4
+ import { a as r, o as i } from "./tooltip-Bu3wNhtW.js";
5
+ import { h as a, m as o, p as s } from "./sheet-DRzg-JWH.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
- 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) => {
13
- N(e), e || j("");
14
- }, V = () => {
15
- y === void 0 ? b === void 0 ? _.forEach((e) => {
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, ...k }) => {
12
+ let { t: A } = t(), [j, M] = l(""), [N, P] = l(!1), F = x === "pill", I = c(() => j === "" ? g : g.filter((e) => e.label.toLowerCase().includes(j.toLowerCase())), [g, j]), L = c(() => I.filter((e) => e.disabled !== !0).map((e) => e.value), [I]), R = c(() => _.filter((e) => g.find((t) => t.value === e)?.disabled === !0), [g, _]), z = c(() => L.length !== 0 && L.every((e) => _.includes(e)), [L, _]), B = c(() => _.map((e) => g.find((t) => t.value === e)?.label ?? e), [g, _]), V = D !== void 0 && D > 0 ? B.slice(0, D) : B, H = B.length - V.length, U = (e) => {
13
+ P(e), e || M("");
14
+ }, W = () => {
15
+ R.length > 0 ? b === void 0 ? _.filter((e) => !R.includes(e)).forEach((e) => {
16
+ v(e);
17
+ }) : b(R) : 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
+ }, G = () => {
21
+ if (z) b === void 0 ? y !== void 0 && _.every((e) => L.includes(e)) ? y() : L.forEach((e) => {
22
+ v(e);
23
+ }) : b(_.filter((e) => !L.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
+ L.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 L.forEach((e) => {
30
+ _.includes(e) || v(e);
33
31
  });
34
- }, U = P ? /* @__PURE__ */ d("button", {
32
+ }, K = F ? /* @__PURE__ */ d("button", {
33
+ ...k,
35
34
  type: "button",
36
35
  disabled: E,
37
36
  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]"),
38
37
  children: [/* @__PURE__ */ u("span", {
39
38
  className: "truncate",
40
- children: C === void 0 ? S ?? k("select.placeholder") : k(C)
39
+ children: C === void 0 ? S ?? A("select.placeholder") : A(C)
41
40
  }), /* @__PURE__ */ d("div", {
42
41
  className: "flex shrink-0 items-center gap-1.5",
43
42
  children: [_.length > 0 && /* @__PURE__ */ u("span", {
44
43
  className: "flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground",
45
44
  children: _.length
46
- }), /* @__PURE__ */ u(f, { className: e("size-3.5 opacity-60 transition-transform", M && "rotate-180") })]
45
+ }), /* @__PURE__ */ u(f, { className: e("size-3.5 opacity-60 transition-transform", N && "rotate-180") })]
47
46
  })]
48
47
  }) : /* @__PURE__ */ d("button", {
48
+ ...k,
49
49
  type: "button",
50
50
  disabled: E,
51
- className: e(i, "w-full", M && "ring-2 ring-ring ring-offset-2", _.length === 0 && "text-muted-foreground", O),
51
+ className: e(i, "w-full", N && "ring-2 ring-ring ring-offset-2", _.length === 0 && "text-muted-foreground", O),
52
52
  children: [/* @__PURE__ */ u("span", {
53
53
  className: "truncate",
54
- children: _.length === 0 ? S ?? k("select.placeholder") : R.join(", ")
54
+ children: _.length === 0 ? S ?? A("select.placeholder") : V.join(", ")
55
55
  }), /* @__PURE__ */ d("div", {
56
56
  className: "flex shrink-0 items-center gap-1",
57
57
  children: [
58
- z > 0 && /* @__PURE__ */ d("span", {
58
+ H > 0 && /* @__PURE__ */ d("span", {
59
59
  className: "rounded-control bg-muted px-1.5 py-0.5 text-xs font-medium text-foreground",
60
- children: ["+", z]
60
+ children: ["+", H]
61
61
  }),
62
62
  _.length > 0 && !E && /* @__PURE__ */ u("span", {
63
63
  role: "button",
@@ -66,23 +66,23 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
66
66
  e.stopPropagation();
67
67
  },
68
68
  onPointerDown: (e) => {
69
- e.preventDefault(), e.stopPropagation(), V();
69
+ e.preventDefault(), e.stopPropagation(), W();
70
70
  },
71
71
  className: "text-muted-foreground hover:text-foreground",
72
72
  children: /* @__PURE__ */ u(m, { className: "size-4" })
73
73
  }),
74
- /* @__PURE__ */ u(f, { className: e("size-4 opacity-50 shrink-0 transition-transform", M && "rotate-180") })
74
+ /* @__PURE__ */ u(f, { className: e("size-4 opacity-50 shrink-0 transition-transform", N && "rotate-180") })
75
75
  ]
76
76
  })]
77
77
  });
78
78
  return /* @__PURE__ */ d(s, {
79
- open: M,
80
- onOpenChange: B,
79
+ open: N,
80
+ onOpenChange: U,
81
81
  children: [/* @__PURE__ */ u(a, {
82
82
  asChild: !0,
83
- children: U
83
+ children: K
84
84
  }), /* @__PURE__ */ d(o, {
85
- className: e("p-0", P ? "w-72 max-w-[var(--radix-popover-content-available-width)]" : "w-[var(--radix-popover-trigger-width)]"),
85
+ className: e("p-0", F ? "w-72 max-w-[var(--radix-popover-content-available-width)]" : "w-[var(--radix-popover-trigger-width)]"),
86
86
  align: "start",
87
87
  children: [/* @__PURE__ */ d(h, {
88
88
  shouldFilter: !1,
@@ -92,9 +92,9 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
92
92
  children: /* @__PURE__ */ d("div", {
93
93
  className: "relative",
94
94
  children: [/* @__PURE__ */ u(p, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }), /* @__PURE__ */ u(h.Input, {
95
- value: A,
96
- onValueChange: j,
97
- placeholder: T ?? k("search.placeholder"),
95
+ value: j,
96
+ onValueChange: M,
97
+ placeholder: T ?? A("search.placeholder"),
98
98
  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",
99
99
  autoFocus: !0
100
100
  })]
@@ -105,15 +105,16 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
105
105
  className: "sr-only"
106
106
  }), /* @__PURE__ */ d(h.List, {
107
107
  className: "flex flex-col gap-0.5 max-h-56 overflow-y-auto overflow-x-hidden 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",
108
- children: [F.length === 0 && /* @__PURE__ */ u("p", {
108
+ children: [I.length === 0 && /* @__PURE__ */ u("p", {
109
109
  className: "px-2 py-3 text-center text-xs text-muted-foreground",
110
- children: k("states.noResult")
111
- }), F.map((e) => /* @__PURE__ */ d(h.Item, {
110
+ children: A("states.noResult")
111
+ }), I.map((e) => /* @__PURE__ */ d(h.Item, {
112
112
  value: e.value,
113
+ disabled: e.disabled,
113
114
  onSelect: () => {
114
115
  v(e.value);
115
116
  },
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",
117
+ 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
118
  children: [
118
119
  /* @__PURE__ */ u("span", {
119
120
  className: "pointer-events-none shrink-0",
@@ -131,13 +132,13 @@ var g = ({ options: g, selected: _, onToggle: v, onClear: y, onSelectAll: b, var
131
132
  ]
132
133
  }, e.value))]
133
134
  })]
134
- }), F.length > 0 && /* @__PURE__ */ u("div", {
135
+ }), L.length > 0 && /* @__PURE__ */ u("div", {
135
136
  className: "border-t border-border p-1.5",
136
137
  children: /* @__PURE__ */ u("button", {
137
138
  type: "button",
138
- onClick: H,
139
+ onClick: G,
139
140
  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")
141
+ children: A(z ? "filters.deselectAll" : "filters.selectAll")
141
142
  })
142
143
  })]
143
144
  })]