@krosoft/react 0.0.102 → 0.0.103
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/dist/{AppSubTitle-DBxJVB46.js → AppSubTitle-Cr3zbmee.js} +1 -1
- package/dist/{AppTitle-DDQoaHBb.js → AppTitle-eazxzYGa.js} +1 -1
- package/dist/{AppVerticalTabs-CYx0jMXp.js → AppVerticalTabs-ujb4jtNi.js} +2 -2
- package/dist/ConfirmationDialog-B41OAAmc.js +257 -0
- package/dist/{DataTable-CtzBzpP-.js → DataTable-jrFyuw67.js} +1 -1
- package/dist/GenericForm-D3Gxh9kf.js +11365 -0
- package/dist/{ImageInput-DVMsk_kn.js → ImageInput-BcGHoduc.js} +1 -1
- package/dist/{MetricCard-CFwSSiQY.js → MetricCard-CXDB0msa.js} +1 -1
- package/dist/MultiSelect-Bc0Re1XN.js +137 -0
- package/dist/SearchInput-DFrIqONH.js +586 -0
- package/dist/{TableFilter-DGFQNbZ_.js → TableFilter-CK8NyawM.js} +27 -26
- package/dist/components/core/cards/index.js +1 -1
- package/dist/components/core/dialogs/FormDialog.d.ts +6 -18
- 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 +2 -2
- package/dist/components/core/filters/index.js +1 -1
- package/dist/components/core/forms/GenericForm.d.ts +57 -0
- package/dist/components/core/forms/GenericForm.d.ts.map +1 -0
- package/dist/components/core/forms/index.d.ts +2 -0
- package/dist/components/core/forms/index.d.ts.map +1 -0
- package/dist/components/core/forms/index.js +4 -0
- package/dist/components/core/index.d.ts +1 -0
- package/dist/components/core/index.d.ts.map +1 -1
- package/dist/components/core/index.js +48 -45
- package/dist/components/core/inputs/MultiSelect.d.ts +2 -1
- package/dist/components/core/inputs/MultiSelect.d.ts.map +1 -1
- package/dist/components/core/inputs/index.js +8 -7
- package/dist/components/core/layouts/index.js +2 -2
- package/dist/components/core/table/index.js +1 -1
- package/dist/components/core/tabs/index.js +1 -1
- package/dist/components/index.js +100 -97
- package/dist/components/ui/index.js +2 -2
- package/dist/{toaster-BTQcWjuV.js → toaster-CtADevTu.js} +1 -1
- package/dist/{toggle-group-6CH5BRLO.js → toggle-group-Cnfwf4uy.js} +8376 -7317
- package/dist/types/forms/FieldType.d.ts +2 -0
- package/dist/types/forms/FieldType.d.ts.map +1 -0
- package/dist/types/forms/FormField.d.ts +40 -0
- package/dist/types/forms/FormField.d.ts.map +1 -0
- package/dist/types/forms/FormSchema.d.ts +6 -0
- package/dist/types/forms/FormSchema.d.ts.map +1 -0
- package/dist/types/forms/FormSection.d.ts +12 -0
- package/dist/types/forms/FormSection.d.ts.map +1 -0
- package/dist/types/forms/index.d.ts +5 -0
- package/dist/types/forms/index.d.ts.map +1 -0
- package/dist/types/forms/index.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +7 -5
- package/dist/ConfirmationDialog-bBFPpP2z.js +0 -322
- package/dist/SearchInput-CsZcpaxL.js +0 -710
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
2
|
-
import "./toggle-group-
|
|
2
|
+
import "./toggle-group-Cnfwf4uy.js";
|
|
3
3
|
import "./alert-srKINZRG.js";
|
|
4
4
|
import { c as u } from "./tailwind.helper-gWiv5-6R.js";
|
|
5
5
|
import { B as v } from "./tooltip-mWS3Mix6.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as s, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { I as l, M as p, J as m, N as x } from "./toggle-group-
|
|
2
|
+
import { I as l, M as p, J as m, N as x } from "./toggle-group-Cnfwf4uy.js";
|
|
3
3
|
import { c } from "./tailwind.helper-gWiv5-6R.js";
|
|
4
4
|
import { useTranslation as f } from "react-i18next";
|
|
5
5
|
import { formatNumber as b } from "@krosoft/core/helpers";
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsxs as l, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as k, useMemo as N, useEffect as y } from "react";
|
|
3
|
+
import { ce as R, _ as C } from "./toggle-group-Cnfwf4uy.js";
|
|
4
|
+
import "./alert-srKINZRG.js";
|
|
5
|
+
import { c as E } from "./tailwind.helper-gWiv5-6R.js";
|
|
6
|
+
import { C as T } from "./tooltip-mWS3Mix6.js";
|
|
7
|
+
import { X as D } from "./select-CDIMkakd.js";
|
|
8
|
+
import "next-themes";
|
|
9
|
+
const V = ({
|
|
10
|
+
options: i,
|
|
11
|
+
selected: n,
|
|
12
|
+
onToggle: h,
|
|
13
|
+
onClear: d,
|
|
14
|
+
onSelectAll: u,
|
|
15
|
+
placeholder: j = "Sélectionner...",
|
|
16
|
+
searchable: f = !1,
|
|
17
|
+
searchPlaceholder: z = "Rechercher...",
|
|
18
|
+
disabled: m = !1
|
|
19
|
+
}) => {
|
|
20
|
+
const [c, g] = w(""), [a, b] = w(!1), p = k(null), x = k(null), o = N(() => c === "" ? i : i.filter((e) => e.label.toLowerCase().includes(c.toLowerCase())), [i, c]), v = N(() => o.length === 0 ? !1 : o.every((e) => n.includes(e.value)), [o, n]);
|
|
21
|
+
y(() => {
|
|
22
|
+
a && f && requestAnimationFrame(() => {
|
|
23
|
+
var e;
|
|
24
|
+
(e = x.current) == null || e.focus();
|
|
25
|
+
});
|
|
26
|
+
}, [a, f]), y(() => {
|
|
27
|
+
if (!a) return;
|
|
28
|
+
const e = (r) => {
|
|
29
|
+
p.current !== null && !p.current.contains(r.target) && (b(!1), g(""));
|
|
30
|
+
};
|
|
31
|
+
return document.addEventListener("mousedown", e), () => {
|
|
32
|
+
document.removeEventListener("mousedown", e);
|
|
33
|
+
};
|
|
34
|
+
}, [a]);
|
|
35
|
+
const L = () => {
|
|
36
|
+
if (v) {
|
|
37
|
+
const e = o.map((s) => s.value), r = n.filter((s) => !e.includes(s));
|
|
38
|
+
u !== void 0 ? u(r) : d();
|
|
39
|
+
} else {
|
|
40
|
+
const e = [...n];
|
|
41
|
+
o.forEach((r) => {
|
|
42
|
+
e.includes(r.value) || e.push(r.value);
|
|
43
|
+
}), u !== void 0 ? u(e) : o.forEach((r) => {
|
|
44
|
+
n.includes(r.value) || h(r.value);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ l("div", { ref: p, className: "relative w-full", children: [
|
|
49
|
+
/* @__PURE__ */ l(
|
|
50
|
+
"button",
|
|
51
|
+
{
|
|
52
|
+
type: "button",
|
|
53
|
+
disabled: m,
|
|
54
|
+
onClick: () => {
|
|
55
|
+
m || b((e) => (e && g(""), !e));
|
|
56
|
+
},
|
|
57
|
+
className: E(
|
|
58
|
+
"flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
|
|
59
|
+
a && "ring-2 ring-ring ring-offset-2",
|
|
60
|
+
n.length === 0 && "text-muted-foreground"
|
|
61
|
+
),
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: n.length === 0 ? j : n.map((e) => {
|
|
64
|
+
var r;
|
|
65
|
+
return ((r = i.find((s) => s.value === e)) == null ? void 0 : r.label) ?? e;
|
|
66
|
+
}).join(", ") }),
|
|
67
|
+
/* @__PURE__ */ l("div", { className: "flex shrink-0 items-center gap-1", children: [
|
|
68
|
+
n.length > 0 && !m && /* @__PURE__ */ t(
|
|
69
|
+
"span",
|
|
70
|
+
{
|
|
71
|
+
role: "button",
|
|
72
|
+
tabIndex: -1,
|
|
73
|
+
onClick: (e) => {
|
|
74
|
+
e.stopPropagation();
|
|
75
|
+
},
|
|
76
|
+
onPointerDown: (e) => {
|
|
77
|
+
e.preventDefault(), e.stopPropagation(), d();
|
|
78
|
+
},
|
|
79
|
+
className: "text-muted-foreground hover:text-foreground",
|
|
80
|
+
children: /* @__PURE__ */ t(D, { className: "size-4" })
|
|
81
|
+
}
|
|
82
|
+
),
|
|
83
|
+
/* @__PURE__ */ t(T, { className: E("size-4 opacity-50 shrink-0 transition-transform", a && "rotate-180") })
|
|
84
|
+
] })
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
),
|
|
88
|
+
a ? /* @__PURE__ */ l("div", { className: "absolute left-0 right-0 top-[calc(100%+4px)] z-[100] rounded-md border bg-popover text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 slide-in-from-top-2", children: [
|
|
89
|
+
f ? /* @__PURE__ */ t("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
90
|
+
/* @__PURE__ */ t(R, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
91
|
+
/* @__PURE__ */ t(
|
|
92
|
+
"input",
|
|
93
|
+
{
|
|
94
|
+
ref: x,
|
|
95
|
+
className: "w-full rounded-md 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",
|
|
96
|
+
placeholder: z,
|
|
97
|
+
value: c,
|
|
98
|
+
onChange: (e) => {
|
|
99
|
+
g(e.target.value);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
] }) }) : null,
|
|
104
|
+
/* @__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: [
|
|
105
|
+
o.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: [
|
|
106
|
+
/* @__PURE__ */ t(C, { checked: v, onCheckedChange: L }),
|
|
107
|
+
"Tout sélectionner"
|
|
108
|
+
] }),
|
|
109
|
+
o.length === 0 && /* @__PURE__ */ t("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: "Aucun résultat" }),
|
|
110
|
+
o.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: [
|
|
111
|
+
/* @__PURE__ */ t(
|
|
112
|
+
C,
|
|
113
|
+
{
|
|
114
|
+
checked: n.includes(e.value),
|
|
115
|
+
onCheckedChange: () => {
|
|
116
|
+
h(e.value);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
e.label
|
|
121
|
+
] }, e.value))
|
|
122
|
+
] }),
|
|
123
|
+
n.length > 0 && /* @__PURE__ */ t("div", { className: "border-t border-border p-1.5", children: /* @__PURE__ */ t(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
type: "button",
|
|
127
|
+
onClick: d,
|
|
128
|
+
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",
|
|
129
|
+
children: "Tout désélectionner"
|
|
130
|
+
}
|
|
131
|
+
) })
|
|
132
|
+
] }) : null
|
|
133
|
+
] });
|
|
134
|
+
};
|
|
135
|
+
export {
|
|
136
|
+
V as M
|
|
137
|
+
};
|