@krosoft/react 0.0.293 → 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.
- package/README.md +3 -0
- package/dist/{AppActions-CpbkO_3O.js → AppActions-NdUYh2ii.js} +2 -2
- package/dist/{AppSubTitle-BOVTZlUB.js → AppSubTitle-CunCNtvJ.js} +1 -1
- package/dist/ErrorAlert-0L-Dwqu8.js +37 -0
- package/dist/GenericForm-CLgO9HuL.js +311 -0
- package/dist/{ImageInput-BPNEywyf.js → ImageInput-DYGqUTBi.js} +2 -2
- package/dist/MultiSelect-CXnF_D0R.js +146 -0
- package/dist/SearchInput-DDcL_q7h.js +318 -0
- package/dist/{cards-BBgGXmYa.js → cards-BB6V8VWw.js} +1 -1
- package/dist/components/core/cards/index.js +1 -1
- package/dist/components/core/dialogs/AppDialog.d.ts +40 -6
- package/dist/components/core/dialogs/AppDialog.d.ts.map +1 -1
- package/dist/components/core/dialogs/FormDialog.d.ts +8 -1
- package/dist/components/core/dialogs/FormDialog.d.ts.map +1 -1
- package/dist/components/core/dialogs/index.d.ts +1 -1
- package/dist/components/core/dialogs/index.d.ts.map +1 -1
- package/dist/components/core/dialogs/index.js +3 -3
- package/dist/components/core/filters/FilterField.d.ts.map +1 -1
- package/dist/components/core/filters/FilterPills.d.ts +1 -1
- package/dist/components/core/filters/TableFilter.d.ts.map +1 -1
- package/dist/components/core/filters/index.d.ts +0 -1
- package/dist/components/core/filters/index.d.ts.map +1 -1
- package/dist/components/core/filters/index.js +138 -255
- package/dist/components/core/forms/GenericForm.d.ts +4 -3
- package/dist/components/core/forms/GenericForm.d.ts.map +1 -1
- package/dist/components/core/forms/index.js +1 -1
- package/dist/components/core/index.js +22 -22
- package/dist/components/core/inputs/MultiSelect.d.ts +20 -8
- package/dist/components/core/inputs/MultiSelect.d.ts.map +1 -1
- package/dist/components/core/inputs/SingleSelect.d.ts +32 -0
- package/dist/components/core/inputs/SingleSelect.d.ts.map +1 -0
- package/dist/components/core/inputs/index.d.ts +3 -2
- package/dist/components/core/inputs/index.d.ts.map +1 -1
- package/dist/components/core/inputs/index.js +5 -5
- package/dist/components/core/language/index.js +1 -1
- package/dist/components/core/layouts/index.js +6 -6
- package/dist/components/core/navbar/index.js +1 -1
- package/dist/components/core/states/ErrorAlert.d.ts +5 -2
- package/dist/components/core/states/ErrorAlert.d.ts.map +1 -1
- package/dist/components/core/states/index.js +2 -2
- package/dist/components/core/table/index.js +3 -3
- package/dist/components/core/tabs/index.js +4 -4
- package/dist/components/core/theme/index.js +1 -1
- package/dist/components/index.js +24 -24
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/index.js +4 -4
- package/dist/dialogs-DVHdqXlO.js +217 -0
- package/dist/{inputs-CUNf48Vk.js → inputs-DG8o5DMW.js} +3 -3
- package/dist/{language-DOGOdjzx.js → language-BvPG7v7d.js} +2 -2
- package/dist/{navbar-CCHGdEzE.js → navbar-CU6zaS92.js} +2 -2
- package/dist/{select-DmLScQKX.js → select-CsXmG_sJ.js} +1 -1
- package/dist/{sheet-DQTOen4V.js → sheet-4VOGdoiW.js} +1 -1
- package/dist/{states-BQK9jqS4.js → states-C4MdmAbW.js} +1 -1
- package/dist/tailwind/index.d.ts +5 -0
- package/dist/tailwind/index.d.ts.map +1 -1
- package/dist/tailwind/index.js +5 -0
- package/dist/{theme-q2uzluEd.js → theme-uTxCKUip.js} +2 -2
- package/dist/{tooltip-BmZ9Bfou.js → tooltip-CWdde1-y.js} +1 -1
- package/dist/{ui-D8Pg34YW.js → ui-rJqnHWNK.js} +3 -3
- package/package.json +1 -1
- package/dist/ErrorAlert-L2s8Dd1_.js +0 -27
- package/dist/GenericForm-BdKwapAz.js +0 -309
- package/dist/MultiSelect-O4JP5fRO.js +0 -129
- package/dist/SearchInput-BSIjKB_9.js +0 -259
- package/dist/components/core/filters/SearchableFilterPill.d.ts +0 -17
- package/dist/components/core/filters/SearchableFilterPill.d.ts.map +0 -1
- package/dist/components/core/inputs/SearchableSelect.d.ts +0 -28
- package/dist/components/core/inputs/SearchableSelect.d.ts.map +0 -1
- package/dist/dialogs-BxyPBIc6.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-
|
|
4
|
-
import { s } from "./tooltip-
|
|
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-
|
|
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-
|
|
4
|
-
import { s as n } from "./tooltip-
|
|
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";
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { t as e } from "./tailwind.helper-CJaRYBmL.js";
|
|
2
|
+
import { t } from "./i18n-d2p0RJo9.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
|
+
import { useMemo as c, useState as l } from "react";
|
|
7
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
|
+
import { ChevronDownIcon as f, SearchIcon as p, XIcon as m } from "lucide-react";
|
|
9
|
+
import { Command as h } from "cmdk";
|
|
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.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
|
+
N(e), e || j("");
|
|
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) => {
|
|
18
|
+
v(e);
|
|
19
|
+
}) : b([]) : y();
|
|
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) {
|
|
25
|
+
let e = [..._];
|
|
26
|
+
I.forEach((t) => {
|
|
27
|
+
e.includes(t) || e.push(t);
|
|
28
|
+
}), b(e);
|
|
29
|
+
} else I.forEach((e) => {
|
|
30
|
+
_.includes(e) || v(e);
|
|
31
|
+
});
|
|
32
|
+
}, G = P ? /* @__PURE__ */ d("button", {
|
|
33
|
+
type: "button",
|
|
34
|
+
disabled: E,
|
|
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]"),
|
|
36
|
+
children: [/* @__PURE__ */ u("span", {
|
|
37
|
+
className: "truncate",
|
|
38
|
+
children: C === void 0 ? S ?? k("select.placeholder") : k(C)
|
|
39
|
+
}), /* @__PURE__ */ d("div", {
|
|
40
|
+
className: "flex shrink-0 items-center gap-1.5",
|
|
41
|
+
children: [_.length > 0 && /* @__PURE__ */ u("span", {
|
|
42
|
+
className: "flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground",
|
|
43
|
+
children: _.length
|
|
44
|
+
}), /* @__PURE__ */ u(f, { className: e("size-3.5 opacity-60 transition-transform", M && "rotate-180") })]
|
|
45
|
+
})]
|
|
46
|
+
}) : /* @__PURE__ */ d("button", {
|
|
47
|
+
type: "button",
|
|
48
|
+
disabled: E,
|
|
49
|
+
className: e(i, "w-full", M && "ring-2 ring-ring ring-offset-2", _.length === 0 && "text-muted-foreground", O),
|
|
50
|
+
children: [/* @__PURE__ */ u("span", {
|
|
51
|
+
className: "truncate",
|
|
52
|
+
children: _.length === 0 ? S ?? k("select.placeholder") : B.join(", ")
|
|
53
|
+
}), /* @__PURE__ */ d("div", {
|
|
54
|
+
className: "flex shrink-0 items-center gap-1",
|
|
55
|
+
children: [
|
|
56
|
+
V > 0 && /* @__PURE__ */ d("span", {
|
|
57
|
+
className: "rounded-control bg-muted px-1.5 py-0.5 text-xs font-medium text-foreground",
|
|
58
|
+
children: ["+", V]
|
|
59
|
+
}),
|
|
60
|
+
_.length > 0 && !E && /* @__PURE__ */ u("span", {
|
|
61
|
+
role: "button",
|
|
62
|
+
tabIndex: -1,
|
|
63
|
+
onClick: (e) => {
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
},
|
|
66
|
+
onPointerDown: (e) => {
|
|
67
|
+
e.preventDefault(), e.stopPropagation(), U();
|
|
68
|
+
},
|
|
69
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
70
|
+
children: /* @__PURE__ */ u(m, { className: "size-4" })
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ u(f, { className: e("size-4 opacity-50 shrink-0 transition-transform", M && "rotate-180") })
|
|
73
|
+
]
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
return /* @__PURE__ */ d(s, {
|
|
77
|
+
open: M,
|
|
78
|
+
onOpenChange: H,
|
|
79
|
+
children: [/* @__PURE__ */ u(a, {
|
|
80
|
+
asChild: !0,
|
|
81
|
+
children: G
|
|
82
|
+
}), /* @__PURE__ */ d(o, {
|
|
83
|
+
className: e("p-0", P ? "w-72 max-w-[var(--radix-popover-content-available-width)]" : "w-[var(--radix-popover-trigger-width)]"),
|
|
84
|
+
align: "start",
|
|
85
|
+
children: [/* @__PURE__ */ d(h, {
|
|
86
|
+
shouldFilter: !1,
|
|
87
|
+
className: "flex flex-col",
|
|
88
|
+
children: [w ? /* @__PURE__ */ u("div", {
|
|
89
|
+
className: "border-b border-border p-2",
|
|
90
|
+
children: /* @__PURE__ */ d("div", {
|
|
91
|
+
className: "relative",
|
|
92
|
+
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, {
|
|
93
|
+
value: A,
|
|
94
|
+
onValueChange: j,
|
|
95
|
+
placeholder: T ?? k("search.placeholder"),
|
|
96
|
+
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",
|
|
97
|
+
autoFocus: !0
|
|
98
|
+
})]
|
|
99
|
+
})
|
|
100
|
+
}) : /* @__PURE__ */ u(h.Input, {
|
|
101
|
+
autoFocus: !0,
|
|
102
|
+
tabIndex: -1,
|
|
103
|
+
className: "sr-only"
|
|
104
|
+
}), /* @__PURE__ */ d(h.List, {
|
|
105
|
+
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",
|
|
106
|
+
children: [F.length === 0 && /* @__PURE__ */ u("p", {
|
|
107
|
+
className: "px-2 py-3 text-center text-xs text-muted-foreground",
|
|
108
|
+
children: k("states.noResult")
|
|
109
|
+
}), F.map((e) => /* @__PURE__ */ d(h.Item, {
|
|
110
|
+
value: e.value,
|
|
111
|
+
disabled: e.disabled,
|
|
112
|
+
onSelect: () => {
|
|
113
|
+
v(e.value);
|
|
114
|
+
},
|
|
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",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ u("span", {
|
|
118
|
+
className: "pointer-events-none shrink-0",
|
|
119
|
+
children: /* @__PURE__ */ u(n, { checked: _.includes(e.value) })
|
|
120
|
+
}),
|
|
121
|
+
e.color && /* @__PURE__ */ u("span", {
|
|
122
|
+
className: "size-2.5 shrink-0 rounded-full",
|
|
123
|
+
style: { backgroundColor: e.color }
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ u("span", {
|
|
126
|
+
className: "min-w-0 flex-1 truncate",
|
|
127
|
+
title: e.label,
|
|
128
|
+
children: e.label
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
}, e.value))]
|
|
132
|
+
})]
|
|
133
|
+
}), I.length > 0 && /* @__PURE__ */ u("div", {
|
|
134
|
+
className: "border-t border-border p-1.5",
|
|
135
|
+
children: /* @__PURE__ */ u("button", {
|
|
136
|
+
type: "button",
|
|
137
|
+
onClick: W,
|
|
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",
|
|
139
|
+
children: k(R ? "filters.deselectAll" : "filters.selectAll")
|
|
140
|
+
})
|
|
141
|
+
})]
|
|
142
|
+
})]
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
//#endregion
|
|
146
|
+
export { g as t };
|