@krosoft/react 0.0.217 → 0.0.219
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 +31 -0
- package/dist/{AppActions-BCXERyyB.js → AppActions-BFmagl91.js} +1 -1
- package/dist/{AppSubTitle-H8ElNObI.js → AppSubTitle-BMQMoehZ.js} +1 -1
- package/dist/AppVerticalTabs-0DrrDO3S.js +101 -0
- package/dist/{ConfirmationDialog-BmxaMEYz.js → ConfirmationDialog-CFsh-Eui.js} +62 -61
- package/dist/DataTable-Cpbp6yse.js +551 -0
- package/dist/ErrorAlert-D_203tKa.js +21 -0
- package/dist/ErrorState-DfJ009uc.js +12 -0
- package/dist/GenericForm-q9dvYl_h.js +342 -0
- package/dist/ImageInput-BYXz8wM1.js +68 -0
- package/dist/{KpiCardsLayout-XZTxB8FV.js → KpiCardsLayout-B-lMaUMA.js} +4 -4
- package/dist/{MultiSelect-Cj8vgAXJ.js → MultiSelect-Dkz1dgXo.js} +52 -51
- package/dist/{PieChart-D6y5EQnh.js → PieChart-bDy_V9Xt.js} +82 -81
- package/dist/SearchInput-CJ2YZpmB.js +244 -0
- package/dist/{SkeletonCards-CYo_lvKx.js → SkeletonCards-Bg2ygjwy.js} +1 -1
- package/dist/{TableFilter-DbnGaGKL.js → TableFilter-u6F06nMx.js} +133 -130
- package/dist/ThemeSelector-BRpEgvX8.js +49 -0
- package/dist/Topbar-bIyAunNd.js +318 -0
- package/dist/components/core/cards/index.js +1 -1
- package/dist/components/core/charts/ChartCard.d.ts.map +1 -1
- package/dist/components/core/charts/index.js +1 -1
- package/dist/components/core/dialogs/FormDialog.d.ts.map +1 -1
- package/dist/components/core/dialogs/index.js +2 -2
- package/dist/components/core/filters/ActiveFilters.d.ts.map +1 -1
- package/dist/components/core/filters/AdvancedFilters.d.ts.map +1 -1
- package/dist/components/core/filters/FilterField.d.ts.map +1 -1
- package/dist/components/core/filters/SearchableFilterPill.d.ts.map +1 -1
- package/dist/components/core/filters/TableFilter.d.ts.map +1 -1
- package/dist/components/core/filters/index.js +1 -1
- 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 +18 -18
- package/dist/components/core/inputs/DateRangePicker.d.ts.map +1 -1
- package/dist/components/core/inputs/ImageInput.d.ts.map +1 -1
- package/dist/components/core/inputs/MultiSelect.d.ts.map +1 -1
- package/dist/components/core/inputs/SearchInput.d.ts +1 -1
- package/dist/components/core/inputs/SearchInput.d.ts.map +1 -1
- package/dist/components/core/inputs/SearchableSelect.d.ts.map +1 -1
- package/dist/components/core/inputs/index.js +3 -3
- package/dist/components/core/layouts/index.js +3 -3
- package/dist/components/core/navbar/GlobalSearch.d.ts.map +1 -1
- package/dist/components/core/navbar/Sidebar.d.ts.map +1 -1
- package/dist/components/core/navbar/index.js +1 -1
- package/dist/components/core/states/ErrorAlert.d.ts.map +1 -1
- package/dist/components/core/states/ErrorState.d.ts.map +1 -1
- package/dist/components/core/states/index.js +2 -2
- package/dist/components/core/table/DataTable.d.ts.map +1 -1
- package/dist/components/core/table/TableBody.d.ts +1 -1
- package/dist/components/core/table/TableBody.d.ts.map +1 -1
- package/dist/components/core/table/TablePagination.d.ts.map +1 -1
- package/dist/components/core/table/index.js +1 -1
- package/dist/components/core/tabs/AppVerticalTabs.d.ts.map +1 -1
- package/dist/components/core/tabs/index.js +1 -1
- package/dist/components/core/theme/ThemeSelector.d.ts.map +1 -1
- package/dist/components/core/theme/index.js +1 -1
- package/dist/components/index.js +18 -18
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/index.js +1 -1
- package/dist/hooks/behavior/index.js +1 -1
- package/dist/hooks/behavior/useConfirmDeleteDialog.d.ts +1 -1
- package/dist/hooks/behavior/useConfirmDeleteDialog.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/ui/index.js +1 -1
- package/dist/hooks/ui/useTheme.d.ts.map +1 -1
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +7 -0
- package/dist/i18n/krosoftLocales.d.ts +175 -0
- package/dist/i18n/krosoftLocales.d.ts.map +1 -0
- package/dist/i18n/useKrosoftTranslation.d.ts +15 -0
- package/dist/i18n/useKrosoftTranslation.d.ts.map +1 -0
- package/dist/providers/index.js +1 -1
- package/dist/{sheet-BQmtrGf2.js → sheet-CDqLa-FP.js} +105 -108
- package/dist/useKrosoftTranslation-DdcylBY2.js +43 -0
- package/dist/usePage-Bhb81ffo.js +82 -0
- package/dist/useTheme-Cmw14Zxi.js +25 -0
- package/package.json +1 -1
- package/dist/AppVerticalTabs-aJmAVu6F.js +0 -100
- package/dist/DataTable-0-lae9KY.js +0 -550
- package/dist/ErrorAlert-SrIcU1mM.js +0 -17
- package/dist/ErrorState-CmaxuJyW.js +0 -8
- package/dist/GenericForm-DJR7PD-i.js +0 -341
- package/dist/ImageInput-DYe2XPNZ.js +0 -67
- package/dist/SearchInput-oeq0NBIc.js +0 -251
- package/dist/ThemeSelector-BFC37dSl.js +0 -48
- package/dist/Topbar-DUq-UeR0.js +0 -306
- package/dist/usePage-BFE9lxI1.js +0 -84
- package/dist/useTheme-CSr_h5xJ.js +0 -24
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { jsx as r, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { u as q } from "./useKrosoftTranslation-DdcylBY2.js";
|
|
3
|
+
import { I as D } from "./ImageInput-BYXz8wM1.js";
|
|
4
|
+
import { A as V } from "./AppSubTitle-BMQMoehZ.js";
|
|
5
|
+
import { M as J } from "./MultiSelect-Dkz1dgXo.js";
|
|
6
|
+
import { ai as L, al as Q, am as X, an as Y, aj as j, ao as $, bm as F, E as ee } from "./toggle-group-DLLrEwv2.js";
|
|
7
|
+
import "./alert-B9F1N9Qk.js";
|
|
8
|
+
import "@radix-ui/react-aspect-ratio";
|
|
9
|
+
import { B as P } from "./tooltip-DVeqVwqV.js";
|
|
10
|
+
import { C as te, d as ae, a as re } from "./chart-DntJZGxB.js";
|
|
11
|
+
import "@radix-ui/react-collapsible";
|
|
12
|
+
import { I as C } from "./sheet-CDqLa-FP.js";
|
|
13
|
+
import "lucide-react";
|
|
14
|
+
import "react-resizable-panels";
|
|
15
|
+
import { c as i } from "./tailwind.helper-B6yFEsav.js";
|
|
16
|
+
import { S as se, h as ne, i as le, a as oe, c as ce } from "./select-BpjFWqAY.js";
|
|
17
|
+
import "next-themes";
|
|
18
|
+
import "sonner";
|
|
19
|
+
import { u as ie } from "./useToast-BFTk4lWz.js";
|
|
20
|
+
import { zodResolver as ue } from "@hookform/resolvers/zod";
|
|
21
|
+
import { useState as f } from "react";
|
|
22
|
+
import { useForm as me } from "react-hook-form";
|
|
23
|
+
import { useTranslation as de } from "react-i18next";
|
|
24
|
+
import { z as y } from "zod";
|
|
25
|
+
const Ze = ({
|
|
26
|
+
schema: v,
|
|
27
|
+
isLoading: S,
|
|
28
|
+
error: N,
|
|
29
|
+
onSubmit: z,
|
|
30
|
+
onCancel: x,
|
|
31
|
+
initialData: g,
|
|
32
|
+
disabled: K = !1,
|
|
33
|
+
renderActions: A = !0,
|
|
34
|
+
onRegisterSubmit: w,
|
|
35
|
+
defaultCols: B = 4
|
|
36
|
+
}) => {
|
|
37
|
+
const { t: p } = de(), { t: h } = q(), { toast: E } = ie(), [k, T] = f(!1), [pe, I] = f({});
|
|
38
|
+
if (!v) return null;
|
|
39
|
+
const O = (e) => {
|
|
40
|
+
switch (e) {
|
|
41
|
+
case 1:
|
|
42
|
+
return "md:col-span-1 col-span-4";
|
|
43
|
+
case 2:
|
|
44
|
+
return "md:col-span-2 col-span-4";
|
|
45
|
+
case 3:
|
|
46
|
+
return "md:col-span-3 col-span-4";
|
|
47
|
+
case 4:
|
|
48
|
+
default:
|
|
49
|
+
return "md:col-span-4 col-span-4";
|
|
50
|
+
}
|
|
51
|
+
}, R = (() => {
|
|
52
|
+
const e = {};
|
|
53
|
+
return v.sections.forEach((t) => {
|
|
54
|
+
t.fields.forEach((a) => {
|
|
55
|
+
if (a.rules)
|
|
56
|
+
e[a.key] = a.rules(y);
|
|
57
|
+
else
|
|
58
|
+
switch (a.type) {
|
|
59
|
+
case "checkbox":
|
|
60
|
+
e[a.key] = y.boolean().nullable().optional();
|
|
61
|
+
break;
|
|
62
|
+
case "html":
|
|
63
|
+
break;
|
|
64
|
+
case "text":
|
|
65
|
+
case "textarea":
|
|
66
|
+
case "number":
|
|
67
|
+
case "date":
|
|
68
|
+
case "time":
|
|
69
|
+
case "select":
|
|
70
|
+
case "multiSelect":
|
|
71
|
+
case "color":
|
|
72
|
+
case "image":
|
|
73
|
+
e[a.key] = y.string().nullable().optional();
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}), y.object(e);
|
|
78
|
+
})(), m = me({
|
|
79
|
+
resolver: ue(R),
|
|
80
|
+
defaultValues: g || Object.fromEntries(v.sections.flatMap((e) => e.fields.map((t) => [t.key, t.defaultValue ?? null])))
|
|
81
|
+
});
|
|
82
|
+
f(() => {
|
|
83
|
+
w && w(() => void m.handleSubmit(M)());
|
|
84
|
+
}), f(() => {
|
|
85
|
+
if (g) {
|
|
86
|
+
const e = {};
|
|
87
|
+
v.sections.forEach((t) => {
|
|
88
|
+
t.fields.forEach((a) => {
|
|
89
|
+
a.type === "image" && g[a.key] && (e[a.key] = g[a.key]);
|
|
90
|
+
});
|
|
91
|
+
}), I(e);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const M = async (e) => {
|
|
95
|
+
if (k) return;
|
|
96
|
+
if (Object.keys(m.formState.errors).length > 0) {
|
|
97
|
+
E({
|
|
98
|
+
title: h("form.validationTitle"),
|
|
99
|
+
description: h("form.validationMessage"),
|
|
100
|
+
variant: "destructive"
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
T(!0);
|
|
105
|
+
try {
|
|
106
|
+
await Promise.resolve(z(e));
|
|
107
|
+
} catch (a) {
|
|
108
|
+
console.error("Error during form submission:", a), E({
|
|
109
|
+
title: h("states.errorTitle"),
|
|
110
|
+
description: h("form.submitError"),
|
|
111
|
+
variant: "destructive"
|
|
112
|
+
});
|
|
113
|
+
} finally {
|
|
114
|
+
T(!1);
|
|
115
|
+
}
|
|
116
|
+
}, Z = (e, t) => {
|
|
117
|
+
t && I((a) => ({ ...a, [e]: t }));
|
|
118
|
+
}, _ = (e) => {
|
|
119
|
+
if (!e) return !1;
|
|
120
|
+
const t = (a) => {
|
|
121
|
+
if (!a || !a._def) return !1;
|
|
122
|
+
const s = a._def;
|
|
123
|
+
return s.typeName === "ZodNullable" ? !0 : s.innerType ? t(s.innerType) : s.type ? t(s.type) : !1;
|
|
124
|
+
};
|
|
125
|
+
try {
|
|
126
|
+
const a = e(y);
|
|
127
|
+
return t(a);
|
|
128
|
+
} catch {
|
|
129
|
+
return !1;
|
|
130
|
+
}
|
|
131
|
+
}, G = (e) => {
|
|
132
|
+
var s;
|
|
133
|
+
if (!e) return !1;
|
|
134
|
+
const t = e(y);
|
|
135
|
+
return t.safeParse(void 0).success ? !1 : ((s = t._def.checks) == null ? void 0 : s.some((n) => n.kind === "min")) ?? !1;
|
|
136
|
+
}, H = (e, t) => {
|
|
137
|
+
const a = !!m.formState.errors[e.key], s = K;
|
|
138
|
+
switch (e.type) {
|
|
139
|
+
case "text":
|
|
140
|
+
case "color":
|
|
141
|
+
return /* @__PURE__ */ r(
|
|
142
|
+
C,
|
|
143
|
+
{
|
|
144
|
+
type: e.type,
|
|
145
|
+
...t,
|
|
146
|
+
placeholder: e.placeholderKey ? p(e.placeholderKey) : "",
|
|
147
|
+
className: i(a && "border-destructive"),
|
|
148
|
+
disabled: s,
|
|
149
|
+
value: t.value ?? ""
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
case "image": {
|
|
153
|
+
const n = e, o = n.value !== void 0 ? n.value : t.value;
|
|
154
|
+
return /* @__PURE__ */ r(
|
|
155
|
+
D,
|
|
156
|
+
{
|
|
157
|
+
value: o ?? "",
|
|
158
|
+
onChange: (l) => {
|
|
159
|
+
if (n.onChange && n.onChange(l), t.onChange(l), l) {
|
|
160
|
+
const d = new FileReader();
|
|
161
|
+
d.onloadend = () => {
|
|
162
|
+
Z(e.key, d.result);
|
|
163
|
+
}, d.readAsDataURL(l);
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
accept: n.accept,
|
|
167
|
+
maxSizeMB: n.maxSizeMB,
|
|
168
|
+
hint: n.hint,
|
|
169
|
+
disabled: s,
|
|
170
|
+
className: i(a && "border-destructive")
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
case "date":
|
|
175
|
+
return /* @__PURE__ */ r(
|
|
176
|
+
C,
|
|
177
|
+
{
|
|
178
|
+
type: "date",
|
|
179
|
+
...t,
|
|
180
|
+
className: i(a && "border-destructive"),
|
|
181
|
+
disabled: s,
|
|
182
|
+
value: t.value ?? ""
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
case "time":
|
|
186
|
+
return /* @__PURE__ */ r(
|
|
187
|
+
C,
|
|
188
|
+
{
|
|
189
|
+
type: "time",
|
|
190
|
+
...t,
|
|
191
|
+
className: i(a && "border-destructive"),
|
|
192
|
+
disabled: s,
|
|
193
|
+
value: t.value ?? ""
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
case "checkbox":
|
|
197
|
+
return /* @__PURE__ */ c("div", { className: "flex items-center space-x-2", children: [
|
|
198
|
+
/* @__PURE__ */ r(
|
|
199
|
+
ee,
|
|
200
|
+
{
|
|
201
|
+
id: e.key,
|
|
202
|
+
checked: t.value === !0,
|
|
203
|
+
onCheckedChange: (n) => {
|
|
204
|
+
t.onChange(n);
|
|
205
|
+
},
|
|
206
|
+
disabled: s,
|
|
207
|
+
className: i(a && "border-destructive")
|
|
208
|
+
}
|
|
209
|
+
),
|
|
210
|
+
/* @__PURE__ */ r("label", { htmlFor: e.key, className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: p(e.labelKey) })
|
|
211
|
+
] }, e.key);
|
|
212
|
+
case "textarea":
|
|
213
|
+
return /* @__PURE__ */ r(
|
|
214
|
+
F,
|
|
215
|
+
{
|
|
216
|
+
...t,
|
|
217
|
+
placeholder: e.placeholderKey ? p(e.placeholderKey) : "",
|
|
218
|
+
className: i(a && "border-destructive", "min-h-[100px]"),
|
|
219
|
+
disabled: s,
|
|
220
|
+
value: t.value ?? ""
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
case "number": {
|
|
224
|
+
const n = e;
|
|
225
|
+
return /* @__PURE__ */ r(
|
|
226
|
+
C,
|
|
227
|
+
{
|
|
228
|
+
type: "number",
|
|
229
|
+
...t,
|
|
230
|
+
step: n.step,
|
|
231
|
+
min: n.min,
|
|
232
|
+
placeholder: e.placeholderKey ? p(e.placeholderKey) : "",
|
|
233
|
+
className: i(a && "border-destructive"),
|
|
234
|
+
disabled: s,
|
|
235
|
+
value: t.value ?? "",
|
|
236
|
+
onChange: (o) => {
|
|
237
|
+
const l = o.target.value === "" ? "" : Number(o.target.value);
|
|
238
|
+
t.onChange(l);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
case "select": {
|
|
244
|
+
const n = e, o = _(e.rules), l = t.value === null || t.value === void 0 ? "" : t.value, d = n.options, b = d.find((u) => u.value === l);
|
|
245
|
+
return /* @__PURE__ */ c(se, { value: l, onValueChange: t.onChange, disabled: s, children: [
|
|
246
|
+
/* @__PURE__ */ r(j, { children: /* @__PURE__ */ r(
|
|
247
|
+
ne,
|
|
248
|
+
{
|
|
249
|
+
className: i(a && "border-destructive"),
|
|
250
|
+
onClear: o && l ? (u) => {
|
|
251
|
+
u.preventDefault(), u.stopPropagation(), t.onChange(null);
|
|
252
|
+
} : void 0,
|
|
253
|
+
children: /* @__PURE__ */ r(le, { placeholder: e.placeholderKey ? p(e.placeholderKey) : "", children: b ? /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
|
|
254
|
+
b.color && /* @__PURE__ */ r("div", { className: "w-4 h-4 rounded-full", style: { backgroundColor: b.color } }),
|
|
255
|
+
b.label
|
|
256
|
+
] }) : void 0 })
|
|
257
|
+
}
|
|
258
|
+
) }),
|
|
259
|
+
/* @__PURE__ */ r(oe, { children: d.map((u, W) => /* @__PURE__ */ r(ce, { value: u.value, children: /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
|
|
260
|
+
u.color && /* @__PURE__ */ r("div", { className: "w-4 h-4 rounded-full", style: { backgroundColor: u.color } }),
|
|
261
|
+
u.label
|
|
262
|
+
] }) }, W)) })
|
|
263
|
+
] });
|
|
264
|
+
}
|
|
265
|
+
case "multiSelect": {
|
|
266
|
+
const n = e, o = t.value ?? [];
|
|
267
|
+
return /* @__PURE__ */ r(
|
|
268
|
+
J,
|
|
269
|
+
{
|
|
270
|
+
options: n.options,
|
|
271
|
+
selected: o,
|
|
272
|
+
onToggle: (l) => {
|
|
273
|
+
const d = o.includes(l) ? o.filter((b) => b !== l) : [...o, l];
|
|
274
|
+
t.onChange(d);
|
|
275
|
+
},
|
|
276
|
+
onClear: () => {
|
|
277
|
+
t.onChange([]);
|
|
278
|
+
},
|
|
279
|
+
onSelectAll: (l) => {
|
|
280
|
+
t.onChange(l);
|
|
281
|
+
},
|
|
282
|
+
placeholder: e.placeholderKey ? p(e.placeholderKey) : "",
|
|
283
|
+
disabled: s
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
case "html":
|
|
288
|
+
return e.render(m.getValues(), e);
|
|
289
|
+
default:
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
}, U = (e, t) => {
|
|
293
|
+
const a = /* @__PURE__ */ r("div", { className: i("grid grid-cols-4 gap-4"), children: e.fields.map((s) => /* @__PURE__ */ r(
|
|
294
|
+
Q,
|
|
295
|
+
{
|
|
296
|
+
control: m.control,
|
|
297
|
+
name: s.key,
|
|
298
|
+
render: ({ field: n }) => {
|
|
299
|
+
var o;
|
|
300
|
+
return /* @__PURE__ */ c(X, { className: i(O(((o = s.layout) == null ? void 0 : o.cols) ?? B)), children: [
|
|
301
|
+
s.type !== "checkbox" && s.type !== "html" && /* @__PURE__ */ c(Y, { children: [
|
|
302
|
+
p(s.labelKey),
|
|
303
|
+
G(s.rules) && /* @__PURE__ */ r("span", { className: "text-destructive ml-1", children: "*" })
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ r(j, { children: H(s, n) }),
|
|
306
|
+
/* @__PURE__ */ r($, {})
|
|
307
|
+
] });
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
s.key
|
|
311
|
+
)) });
|
|
312
|
+
return v.useCards === !1 ? /* @__PURE__ */ c("div", { className: "space-y-4 mb-6", children: [
|
|
313
|
+
e.titleKey && /* @__PURE__ */ r(V, { titleKey: e.titleKey }),
|
|
314
|
+
a
|
|
315
|
+
] }, t) : /* @__PURE__ */ c(te, { className: "mb-6", children: [
|
|
316
|
+
e.titleKey && /* @__PURE__ */ r(ae, { children: /* @__PURE__ */ r(V, { titleKey: e.titleKey }) }),
|
|
317
|
+
/* @__PURE__ */ r(re, { children: a })
|
|
318
|
+
] }, t);
|
|
319
|
+
};
|
|
320
|
+
return /* @__PURE__ */ r(L, { ...m, children: /* @__PURE__ */ c(
|
|
321
|
+
"form",
|
|
322
|
+
{
|
|
323
|
+
onSubmit: (e) => {
|
|
324
|
+
m.handleSubmit(M)(e);
|
|
325
|
+
},
|
|
326
|
+
className: "space-y-4 px-0 w-full",
|
|
327
|
+
children: [
|
|
328
|
+
/* @__PURE__ */ c("div", { className: "space-y-4", children: [
|
|
329
|
+
v.sections.map((e, t) => U(e, t)),
|
|
330
|
+
N && /* @__PURE__ */ r("div", { className: "text-sm font-medium text-destructive", children: N.message })
|
|
331
|
+
] }),
|
|
332
|
+
!K && A && /* @__PURE__ */ c("div", { className: "flex justify-end gap-3 mt-6 border-t pt-4", children: [
|
|
333
|
+
x && /* @__PURE__ */ r(P, { type: "button", variant: "outline", onClick: x, disabled: k || S, children: h("actions.cancel") }),
|
|
334
|
+
/* @__PURE__ */ r(P, { variant: "default", type: "submit", disabled: k || (S ?? !1) || m.formState.isSubmitting, children: h(k || S ? "actions.saving" : "actions.save") })
|
|
335
|
+
] })
|
|
336
|
+
]
|
|
337
|
+
}
|
|
338
|
+
) });
|
|
339
|
+
};
|
|
340
|
+
export {
|
|
341
|
+
Ze as G
|
|
342
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { u as x } from "./useKrosoftTranslation-DdcylBY2.js";
|
|
3
|
+
import "./toggle-group-DLLrEwv2.js";
|
|
4
|
+
import "./alert-B9F1N9Qk.js";
|
|
5
|
+
import "@radix-ui/react-aspect-ratio";
|
|
6
|
+
import { B as N } from "./tooltip-DVeqVwqV.js";
|
|
7
|
+
import "./chart-DntJZGxB.js";
|
|
8
|
+
import "@radix-ui/react-collapsible";
|
|
9
|
+
import "./sheet-CDqLa-FP.js";
|
|
10
|
+
import { XIcon as w, ImageIcon as y, UploadIcon as I } from "lucide-react";
|
|
11
|
+
import "react-resizable-panels";
|
|
12
|
+
import { c as p } from "./tailwind.helper-B6yFEsav.js";
|
|
13
|
+
import "./select-BpjFWqAY.js";
|
|
14
|
+
import "next-themes";
|
|
15
|
+
import "sonner";
|
|
16
|
+
import { forwardRef as j, useRef as T } from "react";
|
|
17
|
+
import { u as R } from "./useNotifications-zbUhCvF_.js";
|
|
18
|
+
const P = j(
|
|
19
|
+
({ value: a, onChange: n, accept: m = "image/jpeg,image/png,image/webp", maxSizeMB: i = 2, disabled: l = !1, className: f = "", hint: c = "JPG, PNG, WEBP" }, h) => {
|
|
20
|
+
const { t } = x(), { showError: d } = R(), r = T(null), g = (b) => {
|
|
21
|
+
var u;
|
|
22
|
+
const o = (u = b.target.files) == null ? void 0 : u[0];
|
|
23
|
+
if (!o) return;
|
|
24
|
+
if (!m.split(",").map((v) => v.trim()).includes(o.type)) {
|
|
25
|
+
d(t("states.errorTitle"), t("image.invalidType", { types: c })), r.current && (r.current.value = "");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (o.size > i * 1024 * 1024) {
|
|
29
|
+
d(t("states.errorTitle"), t("image.tooLarge", { size: i })), r.current && (r.current.value = "");
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
n(o), r.current && (r.current.value = "");
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ e("div", { ref: h, className: f, children: a ? /* @__PURE__ */ s("div", { className: "relative w-32 h-32 rounded-surface overflow-hidden border-2 border-border", children: [
|
|
35
|
+
/* @__PURE__ */ e("img", { src: a, alt: "Preview", className: "w-full h-full object-cover" }),
|
|
36
|
+
!l && /* @__PURE__ */ e(N, { type: "button", variant: "destructive", size: "sm", className: "absolute top-1 right-1 h-6 w-6 p-0", onClick: () => {
|
|
37
|
+
n(null);
|
|
38
|
+
}, children: /* @__PURE__ */ e(w, { className: "h-4 w-4" }) })
|
|
39
|
+
] }) : l ? /* @__PURE__ */ s("div", { className: p("flex flex-col items-center justify-center w-full h-32", "border-2 border-dashed border-border rounded-surface", "bg-muted/30"), children: [
|
|
40
|
+
/* @__PURE__ */ e(y, { className: "h-8 w-8 text-muted-foreground/50 mb-2" }),
|
|
41
|
+
/* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground/50", children: t("image.empty") })
|
|
42
|
+
] }) : /* @__PURE__ */ s(
|
|
43
|
+
"label",
|
|
44
|
+
{
|
|
45
|
+
className: p(
|
|
46
|
+
"flex flex-col items-center justify-center w-full h-32",
|
|
47
|
+
"border-2 border-dashed border-border rounded-surface",
|
|
48
|
+
"cursor-pointer hover:bg-muted/50 transition-colors"
|
|
49
|
+
),
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ e(I, { className: "h-8 w-8 text-muted-foreground mb-2" }),
|
|
52
|
+
/* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground", children: t("image.upload") }),
|
|
53
|
+
/* @__PURE__ */ s("span", { className: "text-xs text-muted-foreground mt-1", children: [
|
|
54
|
+
c,
|
|
55
|
+
" (max ",
|
|
56
|
+
i,
|
|
57
|
+
"MB)"
|
|
58
|
+
] }),
|
|
59
|
+
/* @__PURE__ */ e("input", { ref: r, type: "file", className: "hidden", accept: m, onChange: g })
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
) });
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
P.displayName = "ImageInput";
|
|
66
|
+
export {
|
|
67
|
+
P as I
|
|
68
|
+
};
|
|
@@ -5,7 +5,7 @@ import "@radix-ui/react-aspect-ratio";
|
|
|
5
5
|
import { B as c } from "./tooltip-DVeqVwqV.js";
|
|
6
6
|
import "./chart-DntJZGxB.js";
|
|
7
7
|
import "@radix-ui/react-collapsible";
|
|
8
|
-
import "./sheet-
|
|
8
|
+
import "./sheet-CDqLa-FP.js";
|
|
9
9
|
import { ArrowLeftIcon as l } from "lucide-react";
|
|
10
10
|
import "react-resizable-panels";
|
|
11
11
|
import "clsx";
|
|
@@ -14,13 +14,13 @@ import "./select-BpjFWqAY.js";
|
|
|
14
14
|
import "next-themes";
|
|
15
15
|
import "sonner";
|
|
16
16
|
import "react";
|
|
17
|
-
import { A as f } from "./AppActions-
|
|
17
|
+
import { A as f } from "./AppActions-BFmagl91.js";
|
|
18
18
|
import { A as d } from "./AppTitle-D15YXeMx.js";
|
|
19
19
|
import { u } from "./useDocumentTitle-WNwdPz-I.js";
|
|
20
20
|
import { useTranslation as g } from "react-i18next";
|
|
21
21
|
import "@krosoft/core/helpers";
|
|
22
|
-
import { b as h, a as x } from "./SkeletonCards-
|
|
23
|
-
import { E as A } from "./ErrorState-
|
|
22
|
+
import { b as h, a as x } from "./SkeletonCards-Bg2ygjwy.js";
|
|
23
|
+
import { E as A } from "./ErrorState-DfJ009uc.js";
|
|
24
24
|
function O({
|
|
25
25
|
icon: t,
|
|
26
26
|
titleKey: e,
|
|
@@ -1,77 +1,78 @@
|
|
|
1
1
|
import { jsxs as l, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { u as O } from "./useKrosoftTranslation-DdcylBY2.js";
|
|
3
|
+
import { useState as L, useRef as T, useMemo as x, useEffect as z } from "react";
|
|
4
|
+
import { E as I } from "./toggle-group-DLLrEwv2.js";
|
|
4
5
|
import "./alert-B9F1N9Qk.js";
|
|
5
6
|
import "@radix-ui/react-aspect-ratio";
|
|
6
|
-
import { f as
|
|
7
|
+
import { f as P } from "./tooltip-DVeqVwqV.js";
|
|
7
8
|
import "./chart-DntJZGxB.js";
|
|
8
9
|
import "@radix-ui/react-collapsible";
|
|
9
|
-
import "./sheet-
|
|
10
|
-
import { XIcon as
|
|
10
|
+
import "./sheet-CDqLa-FP.js";
|
|
11
|
+
import { XIcon as q, ChevronDownIcon as S, SearchIcon as F } from "lucide-react";
|
|
11
12
|
import "react-resizable-panels";
|
|
12
|
-
import { c as
|
|
13
|
+
import { c as R } from "./tailwind.helper-B6yFEsav.js";
|
|
13
14
|
import "./select-BpjFWqAY.js";
|
|
14
15
|
import "next-themes";
|
|
15
16
|
import "sonner";
|
|
16
|
-
const
|
|
17
|
-
options:
|
|
17
|
+
const te = ({
|
|
18
|
+
options: a,
|
|
18
19
|
selected: t,
|
|
19
|
-
onToggle:
|
|
20
|
+
onToggle: N,
|
|
20
21
|
onClear: d,
|
|
21
22
|
onSelectAll: u,
|
|
22
|
-
placeholder:
|
|
23
|
+
placeholder: j,
|
|
23
24
|
searchable: m = !1,
|
|
24
|
-
searchPlaceholder:
|
|
25
|
+
searchPlaceholder: D,
|
|
25
26
|
disabled: f = !1,
|
|
26
|
-
maxCount:
|
|
27
|
+
maxCount: p
|
|
27
28
|
}) => {
|
|
28
|
-
const [c,
|
|
29
|
-
var
|
|
30
|
-
return ((
|
|
31
|
-
}), [
|
|
29
|
+
const { t: h } = O(), [c, g] = L(""), [s, k] = L(!1), b = T(null), w = T(null), n = x(() => c === "" ? a : a.filter((e) => e.label.toLowerCase().includes(c.toLowerCase())), [a, c]), y = x(() => n.length === 0 ? !1 : n.every((e) => t.includes(e.value)), [n, t]), v = x(() => t.map((e) => {
|
|
30
|
+
var o;
|
|
31
|
+
return ((o = a.find((i) => i.value === e)) == null ? void 0 : o.label) ?? e;
|
|
32
|
+
}), [a, t]), C = p !== void 0 && p > 0 ? v.slice(0, p) : v, E = v.length - C.length;
|
|
32
33
|
z(() => {
|
|
33
|
-
|
|
34
|
+
s && m && requestAnimationFrame(() => {
|
|
34
35
|
var e;
|
|
35
|
-
(e =
|
|
36
|
+
(e = w.current) == null || e.focus();
|
|
36
37
|
});
|
|
37
|
-
}, [
|
|
38
|
-
if (!
|
|
39
|
-
const e = (
|
|
40
|
-
|
|
38
|
+
}, [s, m]), z(() => {
|
|
39
|
+
if (!s) return;
|
|
40
|
+
const e = (o) => {
|
|
41
|
+
b.current !== null && !b.current.contains(o.target) && (k(!1), g(""));
|
|
41
42
|
};
|
|
42
43
|
return document.addEventListener("mousedown", e), () => {
|
|
43
44
|
document.removeEventListener("mousedown", e);
|
|
44
45
|
};
|
|
45
|
-
}, [
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
const e =
|
|
49
|
-
u !== void 0 ? u(
|
|
46
|
+
}, [s]);
|
|
47
|
+
const M = () => {
|
|
48
|
+
if (y) {
|
|
49
|
+
const e = n.map((i) => i.value), o = t.filter((i) => !e.includes(i));
|
|
50
|
+
u !== void 0 ? u(o) : d();
|
|
50
51
|
} else {
|
|
51
52
|
const e = [...t];
|
|
52
|
-
|
|
53
|
-
e.includes(
|
|
54
|
-
}), u !== void 0 ? u(e) :
|
|
55
|
-
t.includes(
|
|
53
|
+
n.forEach((o) => {
|
|
54
|
+
e.includes(o.value) || e.push(o.value);
|
|
55
|
+
}), u !== void 0 ? u(e) : n.forEach((o) => {
|
|
56
|
+
t.includes(o.value) || N(o.value);
|
|
56
57
|
});
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
|
-
return /* @__PURE__ */ l("div", { ref:
|
|
60
|
+
return /* @__PURE__ */ l("div", { ref: b, className: "relative w-full", children: [
|
|
60
61
|
/* @__PURE__ */ l(
|
|
61
62
|
"button",
|
|
62
63
|
{
|
|
63
64
|
type: "button",
|
|
64
65
|
disabled: f,
|
|
65
66
|
onClick: () => {
|
|
66
|
-
f ||
|
|
67
|
+
f || k((e) => (e && g(""), !e));
|
|
67
68
|
},
|
|
68
|
-
className:
|
|
69
|
+
className: R(P, "w-full", s && "ring-2 ring-ring ring-offset-2", t.length === 0 && "text-muted-foreground"),
|
|
69
70
|
children: [
|
|
70
|
-
/* @__PURE__ */ r("span", { className: "truncate", children: t.length === 0 ?
|
|
71
|
+
/* @__PURE__ */ r("span", { className: "truncate", children: t.length === 0 ? j ?? h("select.placeholder") : C.join(", ") }),
|
|
71
72
|
/* @__PURE__ */ l("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
72
|
-
|
|
73
|
+
E > 0 && /* @__PURE__ */ l("span", { className: "rounded-control bg-muted px-1.5 py-0.5 text-xs font-medium text-foreground", children: [
|
|
73
74
|
"+",
|
|
74
|
-
|
|
75
|
+
E
|
|
75
76
|
] }),
|
|
76
77
|
t.length > 0 && !f && /* @__PURE__ */ r(
|
|
77
78
|
"span",
|
|
@@ -85,43 +86,43 @@ const $ = ({
|
|
|
85
86
|
e.preventDefault(), e.stopPropagation(), d();
|
|
86
87
|
},
|
|
87
88
|
className: "text-muted-foreground hover:text-foreground",
|
|
88
|
-
children: /* @__PURE__ */ r(
|
|
89
|
+
children: /* @__PURE__ */ r(q, { className: "size-4" })
|
|
89
90
|
}
|
|
90
91
|
),
|
|
91
|
-
/* @__PURE__ */ r(
|
|
92
|
+
/* @__PURE__ */ r(S, { className: R("size-4 opacity-50 shrink-0 transition-transform", s && "rotate-180") })
|
|
92
93
|
] })
|
|
93
94
|
]
|
|
94
95
|
}
|
|
95
96
|
),
|
|
96
|
-
|
|
97
|
+
s ? /* @__PURE__ */ l("div", { className: "absolute left-0 right-0 top-[calc(100%+4px)] z-[100] rounded-surface border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 slide-in-from-top-2", children: [
|
|
97
98
|
m ? /* @__PURE__ */ r("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
98
|
-
/* @__PURE__ */ r(
|
|
99
|
+
/* @__PURE__ */ r(F, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
99
100
|
/* @__PURE__ */ r(
|
|
100
101
|
"input",
|
|
101
102
|
{
|
|
102
|
-
ref:
|
|
103
|
+
ref: w,
|
|
103
104
|
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",
|
|
104
|
-
placeholder:
|
|
105
|
+
placeholder: D ?? h("search.placeholder"),
|
|
105
106
|
value: c,
|
|
106
107
|
onChange: (e) => {
|
|
107
|
-
|
|
108
|
+
g(e.target.value);
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
)
|
|
111
112
|
] }) }) : null,
|
|
112
113
|
/* @__PURE__ */ l("div", { className: "flex flex-col gap-0.5 max-h-56 overflow-y-auto p-1.5 scrollbar-thin scrollbar-thumb-rounded scrollbar-thumb-muted-foreground/20 scrollbar-track-transparent [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-muted-foreground/20 [&::-webkit-scrollbar-track]:bg-transparent", children: [
|
|
113
|
-
|
|
114
|
-
/* @__PURE__ */ r(
|
|
114
|
+
n.length > 0 && /* @__PURE__ */ l("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
|
|
115
|
+
/* @__PURE__ */ r(I, { checked: y, onCheckedChange: M }),
|
|
115
116
|
"Tout sélectionner"
|
|
116
117
|
] }),
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
n.length === 0 && /* @__PURE__ */ r("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: h("states.noResult") }),
|
|
119
|
+
n.map((e) => /* @__PURE__ */ l("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
|
|
119
120
|
/* @__PURE__ */ r(
|
|
120
|
-
|
|
121
|
+
I,
|
|
121
122
|
{
|
|
122
123
|
checked: t.includes(e.value),
|
|
123
124
|
onCheckedChange: () => {
|
|
124
|
-
|
|
125
|
+
N(e.value);
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
),
|
|
@@ -142,5 +143,5 @@ const $ = ({
|
|
|
142
143
|
] });
|
|
143
144
|
};
|
|
144
145
|
export {
|
|
145
|
-
|
|
146
|
+
te as M
|
|
146
147
|
};
|