@krosoft/react 0.0.150 → 0.0.152
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/TableFilter-DUGalkoi.js +411 -0
- package/dist/components/core/filters/AdvancedFilters.d.ts.map +1 -1
- package/dist/components/core/filters/index.js +1 -1
- package/dist/components/core/index.js +1 -1
- package/dist/components/index.js +1 -1
- package/package.json +2 -2
- package/dist/TableFilter-rjiss-d9.js +0 -405
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { jsxs as u, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as F, useEffect as $, useMemo as A } from "react";
|
|
3
|
+
import { a as D, D as O, b as j, S as M } from "./SearchInput-T9TeORNA.js";
|
|
4
|
+
import { B as k, a$ as I, bv as R, bx as z, bw as B, $ as C } from "./toggle-group-BASGy2mQ.js";
|
|
5
|
+
import "./alert-B78CiTYe.js";
|
|
6
|
+
import "@radix-ui/react-aspect-ratio";
|
|
7
|
+
import { B as w } from "./tooltip-BWyFpIxo.js";
|
|
8
|
+
import "@radix-ui/react-collapsible";
|
|
9
|
+
import { I as P, S as Q, i as V, b as _, e as H, h as X, d as G } from "./sheet-Gop1cIaU.js";
|
|
10
|
+
import { XIcon as E, Filter as J, ChevronDown as K, Search as U } from "lucide-react";
|
|
11
|
+
import "react-resizable-panels";
|
|
12
|
+
import "clsx";
|
|
13
|
+
import "tailwind-merge";
|
|
14
|
+
import { S as W, h as Y, i as Z, a as q, c as ee } from "./select-MWzbMBAS.js";
|
|
15
|
+
import "next-themes";
|
|
16
|
+
import "sonner";
|
|
17
|
+
import { c as re } from "./tailwind.helper-B6yFEsav.js";
|
|
18
|
+
import { M as te } from "./MultiSelect-DblSHEsg.js";
|
|
19
|
+
const L = (l, n, c = {}) => {
|
|
20
|
+
if (n instanceof Date)
|
|
21
|
+
return n.toLocaleDateString("fr-FR");
|
|
22
|
+
const i = String(n), d = c[`${l}_${i}`];
|
|
23
|
+
return d !== void 0 ? d : l.includes("ok") || n === "true" || n === "false" ? n === "true" ? "Oui" : "Non" : i;
|
|
24
|
+
};
|
|
25
|
+
function le({ filters: l, onRemoveFilter: n, onClearAll: c, filterLabels: i = {}, optionLabels: d = {} }) {
|
|
26
|
+
const o = Object.entries(l).filter(([h, m]) => !(m == null || m === "" || Array.isArray(m) && m.length === 0));
|
|
27
|
+
return o.length === 0 ? null : /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-2 mb-4", children: [
|
|
28
|
+
/* @__PURE__ */ r("span", { className: "text-sm text-gray-600 font-medium", children: "Filtres actifs :" }),
|
|
29
|
+
o.flatMap(([h, m]) => {
|
|
30
|
+
const b = i[h] ?? h;
|
|
31
|
+
if (Array.isArray(m))
|
|
32
|
+
return m.map((x) => {
|
|
33
|
+
const p = L(h, x, d);
|
|
34
|
+
return /* @__PURE__ */ u(
|
|
35
|
+
k,
|
|
36
|
+
{
|
|
37
|
+
variant: "secondary",
|
|
38
|
+
className: "flex items-center gap-1 px-3 py-1 bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100",
|
|
39
|
+
children: [
|
|
40
|
+
b,
|
|
41
|
+
": ",
|
|
42
|
+
p,
|
|
43
|
+
/* @__PURE__ */ r(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
onClick: () => {
|
|
47
|
+
n(h, x);
|
|
48
|
+
},
|
|
49
|
+
className: "ml-1 hover:bg-blue-200 rounded-full p-0.5",
|
|
50
|
+
children: /* @__PURE__ */ r(E, { className: "size-4" })
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
`${h}_${String(x)}`
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
const g = L(h, m, d);
|
|
59
|
+
return /* @__PURE__ */ u(k, { variant: "secondary", className: "flex items-center gap-1 px-3 py-1 bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100", children: [
|
|
60
|
+
b,
|
|
61
|
+
": ",
|
|
62
|
+
g,
|
|
63
|
+
/* @__PURE__ */ r(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
onClick: () => {
|
|
67
|
+
n(h);
|
|
68
|
+
},
|
|
69
|
+
className: "ml-1 hover:bg-blue-200 rounded-full p-0.5",
|
|
70
|
+
children: /* @__PURE__ */ r(E, { className: "size-4" })
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
] }, h);
|
|
74
|
+
}),
|
|
75
|
+
o.length > 0 && /* @__PURE__ */ r("button", { onClick: c, className: "text-xs text-red-500 hover:text-red-600 transition-colors font-medium ml-auto", children: "Effacer tout" })
|
|
76
|
+
] });
|
|
77
|
+
}
|
|
78
|
+
const ae = ({
|
|
79
|
+
field: l,
|
|
80
|
+
value: n,
|
|
81
|
+
onChange: c,
|
|
82
|
+
onToggleMultiSelect: i
|
|
83
|
+
}) => {
|
|
84
|
+
var d;
|
|
85
|
+
switch (l.type) {
|
|
86
|
+
case "text":
|
|
87
|
+
return /* @__PURE__ */ r(
|
|
88
|
+
P,
|
|
89
|
+
{
|
|
90
|
+
placeholder: l.placeholder,
|
|
91
|
+
value: n ?? "",
|
|
92
|
+
onChange: (o) => {
|
|
93
|
+
c(o.target.value);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
case "number":
|
|
98
|
+
return /* @__PURE__ */ r(
|
|
99
|
+
P,
|
|
100
|
+
{
|
|
101
|
+
type: "number",
|
|
102
|
+
placeholder: l.placeholder,
|
|
103
|
+
value: n ?? "",
|
|
104
|
+
onChange: (o) => {
|
|
105
|
+
c(o.target.value);
|
|
106
|
+
},
|
|
107
|
+
min: l.min,
|
|
108
|
+
max: l.max
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
case "select":
|
|
112
|
+
return l.searchable === !0 ? /* @__PURE__ */ r(
|
|
113
|
+
j,
|
|
114
|
+
{
|
|
115
|
+
options: l.options ?? [],
|
|
116
|
+
value: n,
|
|
117
|
+
onChange: c,
|
|
118
|
+
placeholder: l.placeholder,
|
|
119
|
+
searchPlaceholder: l.searchPlaceholder
|
|
120
|
+
}
|
|
121
|
+
) : /* @__PURE__ */ u(W, { value: n ?? "", onValueChange: c, children: [
|
|
122
|
+
/* @__PURE__ */ r(Y, { className: re((n === void 0 || n === "") && "text-muted-foreground"), children: /* @__PURE__ */ r(Z, { placeholder: l.placeholder }) }),
|
|
123
|
+
/* @__PURE__ */ r(q, { children: (d = l.options) == null ? void 0 : d.map((o) => /* @__PURE__ */ r(ee, { value: o.value, children: o.label }, o.value)) })
|
|
124
|
+
] });
|
|
125
|
+
case "date":
|
|
126
|
+
return /* @__PURE__ */ r(O, { date: n, onDateChange: c, placeholder: l.placeholder ?? "Sélectionner une date" });
|
|
127
|
+
case "date-range":
|
|
128
|
+
return /* @__PURE__ */ r(D, { value: n, onChange: c, placeholder: l.placeholder });
|
|
129
|
+
case "multi-select":
|
|
130
|
+
return /* @__PURE__ */ r(
|
|
131
|
+
te,
|
|
132
|
+
{
|
|
133
|
+
options: l.options ?? [],
|
|
134
|
+
selected: n ?? [],
|
|
135
|
+
onToggle: i,
|
|
136
|
+
onClear: () => {
|
|
137
|
+
c([]);
|
|
138
|
+
},
|
|
139
|
+
onSelectAll: c,
|
|
140
|
+
placeholder: l.placeholder,
|
|
141
|
+
searchable: l.searchable,
|
|
142
|
+
searchPlaceholder: l.searchPlaceholder
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
default:
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
}, se = (l) => !(l == null || l === "" || Array.isArray(l) && l.length === 0);
|
|
149
|
+
function ne({
|
|
150
|
+
sections: l,
|
|
151
|
+
filters: n,
|
|
152
|
+
onFiltersChange: c,
|
|
153
|
+
buttonText: i = "Plus de filtres",
|
|
154
|
+
sheetTitle: d = "Filtres avancés"
|
|
155
|
+
}) {
|
|
156
|
+
const [o, h] = F(!1), [m, b] = F(n);
|
|
157
|
+
$(() => {
|
|
158
|
+
b(n);
|
|
159
|
+
}, [n, o]);
|
|
160
|
+
const g = (a, e) => {
|
|
161
|
+
b((t) => ({ ...t, [a]: e }));
|
|
162
|
+
}, x = (a, e) => {
|
|
163
|
+
const t = m[a], s = Array.isArray(t) ? t : [], f = s.includes(e) ? s.filter((N) => N !== e) : [...s, e];
|
|
164
|
+
g(a, f);
|
|
165
|
+
}, p = () => {
|
|
166
|
+
c(m), h(!1);
|
|
167
|
+
}, y = () => {
|
|
168
|
+
b({}), c({}), h(!1);
|
|
169
|
+
}, v = A(() => {
|
|
170
|
+
const a = new Set(l.flatMap((e) => e.filters.map((t) => t.key)));
|
|
171
|
+
return Object.entries(n).filter(([e, t]) => a.has(e) && se(t)).length;
|
|
172
|
+
}, [l, n]);
|
|
173
|
+
return /* @__PURE__ */ u(Q, { open: o, onOpenChange: h, children: [
|
|
174
|
+
/* @__PURE__ */ r(V, { asChild: !0, children: /* @__PURE__ */ u(w, { variant: "outline", className: "gap-2", children: [
|
|
175
|
+
/* @__PURE__ */ r(J, { className: "size-4 shrink-0" }),
|
|
176
|
+
i,
|
|
177
|
+
v > 0 && /* @__PURE__ */ r("span", { className: "ml-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground", children: v })
|
|
178
|
+
] }) }),
|
|
179
|
+
/* @__PURE__ */ u(_, { side: "right", className: "w-[400px] sm:w-[500px] flex flex-col p-0", children: [
|
|
180
|
+
/* @__PURE__ */ r(H, { className: "p-6 pb-0", children: /* @__PURE__ */ r(X, { children: d }) }),
|
|
181
|
+
/* @__PURE__ */ r("div", { className: "flex-1 overflow-y-auto p-6 pt-6", children: /* @__PURE__ */ r("div", { className: "space-y-6", children: l.map((a, e) => /* @__PURE__ */ u("div", { className: "space-y-4", children: [
|
|
182
|
+
/* @__PURE__ */ r("h3", { className: "font-semibold text-sm text-gray-900 dark:text-gray-100 border-b pb-2", children: a.title }),
|
|
183
|
+
a.filters.map((t) => /* @__PURE__ */ u("div", { className: "space-y-2", children: [
|
|
184
|
+
/* @__PURE__ */ r(I, { htmlFor: t.key, children: t.label }),
|
|
185
|
+
/* @__PURE__ */ r(
|
|
186
|
+
ae,
|
|
187
|
+
{
|
|
188
|
+
field: t,
|
|
189
|
+
value: m[t.key],
|
|
190
|
+
onChange: (s) => {
|
|
191
|
+
g(t.key, s);
|
|
192
|
+
},
|
|
193
|
+
onToggleMultiSelect: (s) => {
|
|
194
|
+
x(t.key, s);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
] }, t.key))
|
|
199
|
+
] }, e)) }) }),
|
|
200
|
+
/* @__PURE__ */ u(G, { className: "gap-2 p-6 border-t bg-white dark:bg-gray-950", children: [
|
|
201
|
+
/* @__PURE__ */ r(w, { variant: "outline", className: "flex-1", onClick: y, children: "Effacer les filtres" }),
|
|
202
|
+
/* @__PURE__ */ r(w, { className: "flex-1 bg-orange-500 hover:bg-orange-600 text-white", onClick: p, children: "Rechercher" })
|
|
203
|
+
] })
|
|
204
|
+
] })
|
|
205
|
+
] });
|
|
206
|
+
}
|
|
207
|
+
function ce({
|
|
208
|
+
label: l,
|
|
209
|
+
options: n,
|
|
210
|
+
selected: c,
|
|
211
|
+
onToggle: i,
|
|
212
|
+
onClear: d,
|
|
213
|
+
onSelectAll: o,
|
|
214
|
+
searchable: h = !1,
|
|
215
|
+
searchPlaceholder: m = "Rechercher..."
|
|
216
|
+
}) {
|
|
217
|
+
const [b, g] = F(""), x = c.length > 0, p = A(() => b === "" ? n : n.filter((a) => a.label.toLowerCase().includes(b.toLowerCase())), [n, b]), y = A(() => p.length === 0 ? !1 : p.every((a) => c.includes(a.value)), [p, c]), v = () => {
|
|
218
|
+
if (y)
|
|
219
|
+
if (o !== void 0) {
|
|
220
|
+
const a = p.map((t) => t.value), e = c.filter((t) => !a.includes(t));
|
|
221
|
+
o(e);
|
|
222
|
+
} else d !== void 0 ? d() : c.forEach((a) => {
|
|
223
|
+
i(a);
|
|
224
|
+
});
|
|
225
|
+
else if (o !== void 0) {
|
|
226
|
+
const a = [...c];
|
|
227
|
+
p.forEach((e) => {
|
|
228
|
+
a.includes(e.value) || a.push(e.value);
|
|
229
|
+
}), o(a);
|
|
230
|
+
} else
|
|
231
|
+
p.forEach((a) => {
|
|
232
|
+
c.includes(a.value) || i(a.value);
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
return /* @__PURE__ */ u(
|
|
236
|
+
R,
|
|
237
|
+
{
|
|
238
|
+
onOpenChange: () => {
|
|
239
|
+
g("");
|
|
240
|
+
},
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ r(z, { asChild: !0, children: /* @__PURE__ */ u(
|
|
243
|
+
"button",
|
|
244
|
+
{
|
|
245
|
+
className: `inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm transition-colors whitespace-nowrap ${x ? "border-primary bg-primary/10 text-primary font-medium" : "border-border bg-card text-card-foreground hover:bg-muted"}`,
|
|
246
|
+
children: [
|
|
247
|
+
l,
|
|
248
|
+
c.length > 0 && /* @__PURE__ */ r("span", { className: "flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground", children: c.length }),
|
|
249
|
+
/* @__PURE__ */ r(K, { className: "size-3.5 opacity-60" })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
) }),
|
|
253
|
+
/* @__PURE__ */ u(B, { className: "w-56 p-0", align: "start", children: [
|
|
254
|
+
h ? /* @__PURE__ */ r("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ u("div", { className: "relative", children: [
|
|
255
|
+
/* @__PURE__ */ r(U, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
256
|
+
/* @__PURE__ */ r(
|
|
257
|
+
"input",
|
|
258
|
+
{
|
|
259
|
+
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",
|
|
260
|
+
placeholder: m,
|
|
261
|
+
value: b,
|
|
262
|
+
onChange: (a) => {
|
|
263
|
+
g(a.target.value);
|
|
264
|
+
},
|
|
265
|
+
autoFocus: !0
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
] }) }) : null,
|
|
269
|
+
/* @__PURE__ */ u("div", { className: "flex flex-col gap-0.5 max-h-56 overflow-y-auto p-1.5", children: [
|
|
270
|
+
p.length > 0 && /* @__PURE__ */ u("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
|
|
271
|
+
/* @__PURE__ */ r(C, { checked: y, onCheckedChange: v }),
|
|
272
|
+
"Tout sélectionner"
|
|
273
|
+
] }),
|
|
274
|
+
p.length === 0 && /* @__PURE__ */ r("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: "Aucun résultat" }),
|
|
275
|
+
p.map((a) => /* @__PURE__ */ u("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
|
|
276
|
+
/* @__PURE__ */ r(
|
|
277
|
+
C,
|
|
278
|
+
{
|
|
279
|
+
checked: c.includes(a.value),
|
|
280
|
+
onCheckedChange: () => {
|
|
281
|
+
i(a.value);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
a.label
|
|
286
|
+
] }, a.value))
|
|
287
|
+
] }),
|
|
288
|
+
c.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border p-1.5", children: /* @__PURE__ */ r(
|
|
289
|
+
"button",
|
|
290
|
+
{
|
|
291
|
+
onClick: () => {
|
|
292
|
+
d !== void 0 ? d() : c.forEach((a) => {
|
|
293
|
+
i(a);
|
|
294
|
+
});
|
|
295
|
+
},
|
|
296
|
+
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",
|
|
297
|
+
children: "Tout désélectionner"
|
|
298
|
+
}
|
|
299
|
+
) })
|
|
300
|
+
] })
|
|
301
|
+
]
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
function ke({
|
|
306
|
+
searchQuery: l,
|
|
307
|
+
onSearchChange: n,
|
|
308
|
+
searchPlaceholder: c = "Rechercher...",
|
|
309
|
+
filters: i,
|
|
310
|
+
onFiltersChange: d,
|
|
311
|
+
sections: o,
|
|
312
|
+
advancedButtonText: h = "Filtres",
|
|
313
|
+
sheetTitle: m = "Filtres avancés"
|
|
314
|
+
}) {
|
|
315
|
+
const b = (e, t) => {
|
|
316
|
+
const s = i[e], f = Array.isArray(s) ? s : [], N = f.includes(t) ? f.filter((T) => T !== t) : [...f, t], S = { ...i };
|
|
317
|
+
N.length === 0 ? delete S[e] : S[e] = N, d(S);
|
|
318
|
+
}, g = (e) => {
|
|
319
|
+
const t = { ...i };
|
|
320
|
+
delete t[e], d(t);
|
|
321
|
+
}, x = () => {
|
|
322
|
+
d({});
|
|
323
|
+
}, p = (e, t) => {
|
|
324
|
+
const s = { ...i }, f = s[e];
|
|
325
|
+
Array.isArray(f) && t !== void 0 ? (s[e] = f.filter((N) => N !== t), Array.isArray(s[e]) && s[e].length === 0 && delete s[e]) : delete s[e], d(s);
|
|
326
|
+
}, y = A(() => {
|
|
327
|
+
const e = [];
|
|
328
|
+
return o.forEach((t) => {
|
|
329
|
+
t.filters.forEach((s) => {
|
|
330
|
+
s.isQuickFilter === !0 && e.push({
|
|
331
|
+
key: s.key,
|
|
332
|
+
label: s.label,
|
|
333
|
+
options: s.options ?? [],
|
|
334
|
+
searchable: s.searchable,
|
|
335
|
+
searchPlaceholder: s.searchPlaceholder
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
}), e;
|
|
339
|
+
}, [o]), v = A(() => {
|
|
340
|
+
const e = {};
|
|
341
|
+
return o.forEach((t) => {
|
|
342
|
+
t.filters.forEach((s) => {
|
|
343
|
+
e[s.key] = s.badgeLabel ?? s.label;
|
|
344
|
+
});
|
|
345
|
+
}), e;
|
|
346
|
+
}, [o]), a = A(() => {
|
|
347
|
+
const e = {};
|
|
348
|
+
return o.forEach((t) => {
|
|
349
|
+
t.filters.forEach((s) => {
|
|
350
|
+
s.options !== void 0 && s.options.forEach((f) => {
|
|
351
|
+
e[`${s.key}_${f.value}`] = f.label;
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
}), e;
|
|
355
|
+
}, [o]);
|
|
356
|
+
return /* @__PURE__ */ u("div", { className: "space-y-4 w-full", children: [
|
|
357
|
+
/* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-3 justify-between", children: [
|
|
358
|
+
/* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
359
|
+
n !== void 0 ? /* @__PURE__ */ r(
|
|
360
|
+
M,
|
|
361
|
+
{
|
|
362
|
+
searchQuery: l,
|
|
363
|
+
onSearch: n,
|
|
364
|
+
onClear: () => {
|
|
365
|
+
n("");
|
|
366
|
+
},
|
|
367
|
+
placeholder: c
|
|
368
|
+
}
|
|
369
|
+
) : null,
|
|
370
|
+
y.map((e) => /* @__PURE__ */ r(
|
|
371
|
+
ce,
|
|
372
|
+
{
|
|
373
|
+
label: e.label,
|
|
374
|
+
options: e.options,
|
|
375
|
+
selected: Array.isArray(i[e.key]) ? i[e.key] : [],
|
|
376
|
+
onToggle: (t) => {
|
|
377
|
+
b(e.key, t);
|
|
378
|
+
},
|
|
379
|
+
onClear: () => {
|
|
380
|
+
g(e.key);
|
|
381
|
+
},
|
|
382
|
+
onSelectAll: (t) => {
|
|
383
|
+
d({ ...i, [e.key]: t });
|
|
384
|
+
},
|
|
385
|
+
searchable: e.searchable,
|
|
386
|
+
searchPlaceholder: e.searchPlaceholder
|
|
387
|
+
},
|
|
388
|
+
e.key
|
|
389
|
+
))
|
|
390
|
+
] }),
|
|
391
|
+
o.length > 0 && /* @__PURE__ */ r(ne, { sections: o, filters: i, onFiltersChange: d, buttonText: h, sheetTitle: m })
|
|
392
|
+
] }),
|
|
393
|
+
/* @__PURE__ */ r(
|
|
394
|
+
le,
|
|
395
|
+
{
|
|
396
|
+
filters: i,
|
|
397
|
+
onRemoveFilter: p,
|
|
398
|
+
onClearAll: x,
|
|
399
|
+
filterLabels: v,
|
|
400
|
+
optionLabels: a
|
|
401
|
+
}
|
|
402
|
+
)
|
|
403
|
+
] });
|
|
404
|
+
}
|
|
405
|
+
export {
|
|
406
|
+
le as A,
|
|
407
|
+
ae as F,
|
|
408
|
+
ce as S,
|
|
409
|
+
ke as T,
|
|
410
|
+
ne as a
|
|
411
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdvancedFilters.d.ts","sourceRoot":"","sources":["../../../../src/components/core/filters/AdvancedFilters.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"AdvancedFilters.d.ts","sourceRoot":"","sources":["../../../../src/components/core/filters/AdvancedFilters.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAStD,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/F,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7B,OAAO,EAAE,CAAC,CAAC;IACX,eAAe,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC3F,QAAQ,EACR,OAAO,EACP,eAAe,EACf,UAA8B,EAC9B,UAA8B,GAC/B,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,CA4F9C"}
|
|
@@ -2,7 +2,7 @@ import { D as r, M as o } from "../../MetricCard-D-qPl6zh.js";
|
|
|
2
2
|
import { K as t, a as i, S as l, b as p } from "../../SkeletonCards-qHukR79N.js";
|
|
3
3
|
import { A as m, C as d, F as g } from "../../ConfirmationDialog-wGKgYkmd.js";
|
|
4
4
|
import { D as A, a as D, b as T, c as n, d as c, e as x, f as S, g as C, h as F, i as P, P as h } from "../../toggle-group-BASGy2mQ.js";
|
|
5
|
-
import { A as k, a as H, F as I, S as K, T as v } from "../../TableFilter-
|
|
5
|
+
import { A as k, a as H, F as I, S as K, T as v } from "../../TableFilter-DUGalkoi.js";
|
|
6
6
|
import { G as M } from "../../GenericForm-Cy5ntJxi.js";
|
|
7
7
|
import { I as L } from "../../ImageInput-CJ419eqw.js";
|
|
8
8
|
import { D as G, a as N, S as O, b as R } from "../../SearchInput-T9TeORNA.js";
|
package/dist/components/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { D as o, M as r } from "../MetricCard-D-qPl6zh.js";
|
|
|
2
2
|
import { K as t, a as n, S as i, b as l } from "../SkeletonCards-qHukR79N.js";
|
|
3
3
|
import { A as p, C as u, F as g } from "../ConfirmationDialog-wGKgYkmd.js";
|
|
4
4
|
import { A as m, j as C, k as S, l as T, m as c, n as D, o as M, p as x, q as A, r as I, s as P, t as h, u as f, v as w, w as v, x as F, B as L, y as B, z as G, C as H, E as R, F as k, G as N, H as y, I as E, J as O, K as V, L as K, M as z, N as U, O as j, Q as q, R as J, S as Q, T as W, U as X, V as Y, W as Z, X as _, Y as $, Z as aa, _ as ea, $ as oa, a0 as ra, a1 as sa, a2 as ta, a3 as na, a4 as ia, a5 as la, a6 as ba, a7 as pa, a8 as ua, a9 as ga, aa as da, ab as ma, ac as Ca, ad as Sa, ae as Ta, af as ca, ag as Da, ah as Ma, ai as xa, aj as Aa, ak as Ia, al as Pa, am as ha, an as fa, D as wa, a as va, b as Fa, c as La, d as Ba, e as Ga, f as Ha, g as Ra, h as ka, i as Na, ao as ya, ap as Ea, aq as Oa, ar as Va, as as Ka, at as za, au as Ua, av as ja, aw as qa, ax as Ja, ay as Qa, az as Wa, aA as Xa, aB as Ya, aC as Za, aD as _a, aE as $a, aF as ae, aG as ee, aH as oe, aI as re, aJ as se, aK as te, aL as ne, aM as ie, aN as le, aO as be, aP as pe, aQ as ue, aR as ge, aS as de, aT as me, aU as Ce, aV as Se, aW as Te, aX as ce, aY as De, aZ as Me, a_ as xe, a$ as Ae, b0 as Ie, b1 as Pe, b2 as he, b3 as fe, b4 as we, b5 as ve, b6 as Fe, b7 as Le, b8 as Be, b9 as Ge, ba as He, bb as Re, bc as ke, bd as Ne, be as ye, bf as Ee, bg as Oe, bh as Ve, bi as Ke, bj as ze, bk as Ue, bl as je, bm as qe, bn as Je, bo as Qe, bp as We, bq as Xe, br as Ye, bs as Ze, bt as _e, bu as $e, bv as ao, bw as eo, bx as oo, P as ro, by as so, bz as to, bA as no, bB as io, bC as lo, bD as bo, bE as po, bF as uo, bG as go, bH as mo, bI as Co, bJ as So, bK as To, bL as co, bM as Do, bN as Mo, bO as xo, bP as Ao, bQ as Io, bR as Po, bS as ho, bT as fo, bU as wo, bV as vo, bW as Fo, bX as Lo, bY as Bo, bZ as Go, b_ as Ho, b$ as Ro, c0 as ko, c1 as No, c2 as yo, c3 as Eo } from "../toggle-group-BASGy2mQ.js";
|
|
5
|
-
import { A as Vo, a as Ko, F as zo, S as Uo, T as jo } from "../TableFilter-
|
|
5
|
+
import { A as Vo, a as Ko, F as zo, S as Uo, T as jo } from "../TableFilter-DUGalkoi.js";
|
|
6
6
|
import { G as Jo } from "../GenericForm-Cy5ntJxi.js";
|
|
7
7
|
import { I as Wo } from "../ImageInput-CJ419eqw.js";
|
|
8
8
|
import { D as Yo, a as Zo, S as _o, b as $o } from "../SearchInput-T9TeORNA.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krosoft/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.152",
|
|
4
4
|
"description": "Krosoft shared React package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -115,6 +115,6 @@
|
|
|
115
115
|
"tailwindcss": "^3.4.19",
|
|
116
116
|
"typescript": "^5.9.3",
|
|
117
117
|
"vite": "^6.4.3",
|
|
118
|
-
"vitest": "^4.1.
|
|
118
|
+
"vitest": "^4.1.10"
|
|
119
119
|
}
|
|
120
120
|
}
|
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
import { jsxs as u, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useState as w, useEffect as $, useMemo as N } from "react";
|
|
3
|
-
import { a as D, D as O, b as I, S as M } from "./SearchInput-T9TeORNA.js";
|
|
4
|
-
import { B as k, a$ as j, bv as R, bx as z, bw as B, $ as C } from "./toggle-group-BASGy2mQ.js";
|
|
5
|
-
import "./alert-B78CiTYe.js";
|
|
6
|
-
import "@radix-ui/react-aspect-ratio";
|
|
7
|
-
import { B as F } from "./tooltip-BWyFpIxo.js";
|
|
8
|
-
import "@radix-ui/react-collapsible";
|
|
9
|
-
import { I as P, S as Q, i as V, b as _, e as H, h as X, d as G } from "./sheet-Gop1cIaU.js";
|
|
10
|
-
import { XIcon as E, Filter as J, ChevronDown as K, Search as U } from "lucide-react";
|
|
11
|
-
import "react-resizable-panels";
|
|
12
|
-
import "clsx";
|
|
13
|
-
import "tailwind-merge";
|
|
14
|
-
import { S as W, h as Y, i as Z, a as q, c as ee } from "./select-MWzbMBAS.js";
|
|
15
|
-
import "next-themes";
|
|
16
|
-
import "sonner";
|
|
17
|
-
import { c as re } from "./tailwind.helper-B6yFEsav.js";
|
|
18
|
-
import { M as te } from "./MultiSelect-DblSHEsg.js";
|
|
19
|
-
const L = (n, l, s = {}) => {
|
|
20
|
-
if (l instanceof Date)
|
|
21
|
-
return l.toLocaleDateString("fr-FR");
|
|
22
|
-
const i = String(l), d = s[`${n}_${i}`];
|
|
23
|
-
return d !== void 0 ? d : n.includes("ok") || l === "true" || l === "false" ? l === "true" ? "Oui" : "Non" : i;
|
|
24
|
-
};
|
|
25
|
-
function le({ filters: n, onRemoveFilter: l, onClearAll: s, filterLabels: i = {}, optionLabels: d = {} }) {
|
|
26
|
-
const c = Object.entries(n).filter(([h, m]) => !(m == null || m === "" || Array.isArray(m) && m.length === 0));
|
|
27
|
-
return c.length === 0 ? null : /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-2 mb-4", children: [
|
|
28
|
-
/* @__PURE__ */ r("span", { className: "text-sm text-gray-600 font-medium", children: "Filtres actifs :" }),
|
|
29
|
-
c.flatMap(([h, m]) => {
|
|
30
|
-
const b = i[h] ?? h;
|
|
31
|
-
if (Array.isArray(m))
|
|
32
|
-
return m.map((v) => {
|
|
33
|
-
const p = L(h, v, d);
|
|
34
|
-
return /* @__PURE__ */ u(
|
|
35
|
-
k,
|
|
36
|
-
{
|
|
37
|
-
variant: "secondary",
|
|
38
|
-
className: "flex items-center gap-1 px-3 py-1 bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100",
|
|
39
|
-
children: [
|
|
40
|
-
b,
|
|
41
|
-
": ",
|
|
42
|
-
p,
|
|
43
|
-
/* @__PURE__ */ r(
|
|
44
|
-
"button",
|
|
45
|
-
{
|
|
46
|
-
onClick: () => {
|
|
47
|
-
l(h, v);
|
|
48
|
-
},
|
|
49
|
-
className: "ml-1 hover:bg-blue-200 rounded-full p-0.5",
|
|
50
|
-
children: /* @__PURE__ */ r(E, { className: "size-4" })
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
]
|
|
54
|
-
},
|
|
55
|
-
`${h}_${String(v)}`
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
const x = L(h, m, d);
|
|
59
|
-
return /* @__PURE__ */ u(k, { variant: "secondary", className: "flex items-center gap-1 px-3 py-1 bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100", children: [
|
|
60
|
-
b,
|
|
61
|
-
": ",
|
|
62
|
-
x,
|
|
63
|
-
/* @__PURE__ */ r(
|
|
64
|
-
"button",
|
|
65
|
-
{
|
|
66
|
-
onClick: () => {
|
|
67
|
-
l(h);
|
|
68
|
-
},
|
|
69
|
-
className: "ml-1 hover:bg-blue-200 rounded-full p-0.5",
|
|
70
|
-
children: /* @__PURE__ */ r(E, { className: "size-4" })
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
] }, h);
|
|
74
|
-
}),
|
|
75
|
-
c.length > 0 && /* @__PURE__ */ r("button", { onClick: s, className: "text-xs text-red-500 hover:text-red-600 transition-colors font-medium ml-2", children: "Effacer tout" })
|
|
76
|
-
] });
|
|
77
|
-
}
|
|
78
|
-
const ae = ({
|
|
79
|
-
field: n,
|
|
80
|
-
value: l,
|
|
81
|
-
onChange: s,
|
|
82
|
-
onToggleMultiSelect: i
|
|
83
|
-
}) => {
|
|
84
|
-
var d;
|
|
85
|
-
switch (n.type) {
|
|
86
|
-
case "text":
|
|
87
|
-
return /* @__PURE__ */ r(
|
|
88
|
-
P,
|
|
89
|
-
{
|
|
90
|
-
placeholder: n.placeholder,
|
|
91
|
-
value: l ?? "",
|
|
92
|
-
onChange: (c) => {
|
|
93
|
-
s(c.target.value);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
case "number":
|
|
98
|
-
return /* @__PURE__ */ r(
|
|
99
|
-
P,
|
|
100
|
-
{
|
|
101
|
-
type: "number",
|
|
102
|
-
placeholder: n.placeholder,
|
|
103
|
-
value: l ?? "",
|
|
104
|
-
onChange: (c) => {
|
|
105
|
-
s(c.target.value);
|
|
106
|
-
},
|
|
107
|
-
min: n.min,
|
|
108
|
-
max: n.max
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
case "select":
|
|
112
|
-
return n.searchable === !0 ? /* @__PURE__ */ r(
|
|
113
|
-
I,
|
|
114
|
-
{
|
|
115
|
-
options: n.options ?? [],
|
|
116
|
-
value: l,
|
|
117
|
-
onChange: s,
|
|
118
|
-
placeholder: n.placeholder,
|
|
119
|
-
searchPlaceholder: n.searchPlaceholder
|
|
120
|
-
}
|
|
121
|
-
) : /* @__PURE__ */ u(W, { value: l ?? "", onValueChange: s, children: [
|
|
122
|
-
/* @__PURE__ */ r(Y, { className: re((l === void 0 || l === "") && "text-muted-foreground"), children: /* @__PURE__ */ r(Z, { placeholder: n.placeholder }) }),
|
|
123
|
-
/* @__PURE__ */ r(q, { children: (d = n.options) == null ? void 0 : d.map((c) => /* @__PURE__ */ r(ee, { value: c.value, children: c.label }, c.value)) })
|
|
124
|
-
] });
|
|
125
|
-
case "date":
|
|
126
|
-
return /* @__PURE__ */ r(O, { date: l, onDateChange: s, placeholder: n.placeholder ?? "Sélectionner une date" });
|
|
127
|
-
case "date-range":
|
|
128
|
-
return /* @__PURE__ */ r(D, { value: l, onChange: s, placeholder: n.placeholder });
|
|
129
|
-
case "multi-select":
|
|
130
|
-
return /* @__PURE__ */ r(
|
|
131
|
-
te,
|
|
132
|
-
{
|
|
133
|
-
options: n.options ?? [],
|
|
134
|
-
selected: l ?? [],
|
|
135
|
-
onToggle: i,
|
|
136
|
-
onClear: () => {
|
|
137
|
-
s([]);
|
|
138
|
-
},
|
|
139
|
-
onSelectAll: s,
|
|
140
|
-
placeholder: n.placeholder,
|
|
141
|
-
searchable: n.searchable,
|
|
142
|
-
searchPlaceholder: n.searchPlaceholder
|
|
143
|
-
}
|
|
144
|
-
);
|
|
145
|
-
default:
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
function se({
|
|
150
|
-
sections: n,
|
|
151
|
-
filters: l,
|
|
152
|
-
onFiltersChange: s,
|
|
153
|
-
buttonText: i = "Plus de filtres",
|
|
154
|
-
sheetTitle: d = "Filtres avancés"
|
|
155
|
-
}) {
|
|
156
|
-
const [c, h] = w(!1), [m, b] = w(l);
|
|
157
|
-
$(() => {
|
|
158
|
-
b(l);
|
|
159
|
-
}, [l, c]);
|
|
160
|
-
const x = (f, t) => {
|
|
161
|
-
b((e) => ({ ...e, [f]: t }));
|
|
162
|
-
}, v = (f, t) => {
|
|
163
|
-
const e = m[f], a = Array.isArray(e) ? e : [], o = a.includes(t) ? a.filter((g) => g !== t) : [...a, t];
|
|
164
|
-
x(f, o);
|
|
165
|
-
}, p = () => {
|
|
166
|
-
s(m), h(!1);
|
|
167
|
-
}, y = () => {
|
|
168
|
-
b({}), s({}), h(!1);
|
|
169
|
-
};
|
|
170
|
-
return /* @__PURE__ */ u(Q, { open: c, onOpenChange: h, children: [
|
|
171
|
-
/* @__PURE__ */ r(V, { asChild: !0, children: /* @__PURE__ */ u(F, { variant: "outline", className: "gap-2", children: [
|
|
172
|
-
/* @__PURE__ */ r(J, { className: "size-4 shrink-0" }),
|
|
173
|
-
i
|
|
174
|
-
] }) }),
|
|
175
|
-
/* @__PURE__ */ u(_, { side: "right", className: "w-[400px] sm:w-[500px] flex flex-col p-0", children: [
|
|
176
|
-
/* @__PURE__ */ r(H, { className: "p-6 pb-0", children: /* @__PURE__ */ r(X, { children: d }) }),
|
|
177
|
-
/* @__PURE__ */ r("div", { className: "flex-1 overflow-y-auto p-6 pt-6", children: /* @__PURE__ */ r("div", { className: "space-y-6", children: n.map((f, t) => /* @__PURE__ */ u("div", { className: "space-y-4", children: [
|
|
178
|
-
/* @__PURE__ */ r("h3", { className: "font-semibold text-sm text-gray-900 dark:text-gray-100 border-b pb-2", children: f.title }),
|
|
179
|
-
f.filters.map((e) => /* @__PURE__ */ u("div", { className: "space-y-2", children: [
|
|
180
|
-
/* @__PURE__ */ r(j, { htmlFor: e.key, children: e.label }),
|
|
181
|
-
/* @__PURE__ */ r(
|
|
182
|
-
ae,
|
|
183
|
-
{
|
|
184
|
-
field: e,
|
|
185
|
-
value: m[e.key],
|
|
186
|
-
onChange: (a) => {
|
|
187
|
-
x(e.key, a);
|
|
188
|
-
},
|
|
189
|
-
onToggleMultiSelect: (a) => {
|
|
190
|
-
v(e.key, a);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
)
|
|
194
|
-
] }, e.key))
|
|
195
|
-
] }, t)) }) }),
|
|
196
|
-
/* @__PURE__ */ u(G, { className: "gap-2 p-6 border-t bg-white dark:bg-gray-950", children: [
|
|
197
|
-
/* @__PURE__ */ r(F, { variant: "outline", className: "flex-1", onClick: y, children: "Effacer les filtres" }),
|
|
198
|
-
/* @__PURE__ */ r(F, { className: "flex-1 bg-orange-500 hover:bg-orange-600 text-white", onClick: p, children: "Rechercher" })
|
|
199
|
-
] })
|
|
200
|
-
] })
|
|
201
|
-
] });
|
|
202
|
-
}
|
|
203
|
-
function ne({
|
|
204
|
-
label: n,
|
|
205
|
-
options: l,
|
|
206
|
-
selected: s,
|
|
207
|
-
onToggle: i,
|
|
208
|
-
onClear: d,
|
|
209
|
-
onSelectAll: c,
|
|
210
|
-
searchable: h = !1,
|
|
211
|
-
searchPlaceholder: m = "Rechercher..."
|
|
212
|
-
}) {
|
|
213
|
-
const [b, x] = w(""), v = s.length > 0, p = N(() => b === "" ? l : l.filter((t) => t.label.toLowerCase().includes(b.toLowerCase())), [l, b]), y = N(() => p.length === 0 ? !1 : p.every((t) => s.includes(t.value)), [p, s]), f = () => {
|
|
214
|
-
if (y)
|
|
215
|
-
if (c !== void 0) {
|
|
216
|
-
const t = p.map((a) => a.value), e = s.filter((a) => !t.includes(a));
|
|
217
|
-
c(e);
|
|
218
|
-
} else d !== void 0 ? d() : s.forEach((t) => {
|
|
219
|
-
i(t);
|
|
220
|
-
});
|
|
221
|
-
else if (c !== void 0) {
|
|
222
|
-
const t = [...s];
|
|
223
|
-
p.forEach((e) => {
|
|
224
|
-
t.includes(e.value) || t.push(e.value);
|
|
225
|
-
}), c(t);
|
|
226
|
-
} else
|
|
227
|
-
p.forEach((t) => {
|
|
228
|
-
s.includes(t.value) || i(t.value);
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
return /* @__PURE__ */ u(
|
|
232
|
-
R,
|
|
233
|
-
{
|
|
234
|
-
onOpenChange: () => {
|
|
235
|
-
x("");
|
|
236
|
-
},
|
|
237
|
-
children: [
|
|
238
|
-
/* @__PURE__ */ r(z, { asChild: !0, children: /* @__PURE__ */ u(
|
|
239
|
-
"button",
|
|
240
|
-
{
|
|
241
|
-
className: `inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-sm transition-colors whitespace-nowrap ${v ? "border-primary bg-primary/10 text-primary font-medium" : "border-border bg-card text-card-foreground hover:bg-muted"}`,
|
|
242
|
-
children: [
|
|
243
|
-
n,
|
|
244
|
-
s.length > 0 && /* @__PURE__ */ r("span", { className: "flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-primary-foreground", children: s.length }),
|
|
245
|
-
/* @__PURE__ */ r(K, { className: "size-3.5 opacity-60" })
|
|
246
|
-
]
|
|
247
|
-
}
|
|
248
|
-
) }),
|
|
249
|
-
/* @__PURE__ */ u(B, { className: "w-56 p-0", align: "start", children: [
|
|
250
|
-
h ? /* @__PURE__ */ r("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ u("div", { className: "relative", children: [
|
|
251
|
-
/* @__PURE__ */ r(U, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
252
|
-
/* @__PURE__ */ r(
|
|
253
|
-
"input",
|
|
254
|
-
{
|
|
255
|
-
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",
|
|
256
|
-
placeholder: m,
|
|
257
|
-
value: b,
|
|
258
|
-
onChange: (t) => {
|
|
259
|
-
x(t.target.value);
|
|
260
|
-
},
|
|
261
|
-
autoFocus: !0
|
|
262
|
-
}
|
|
263
|
-
)
|
|
264
|
-
] }) }) : null,
|
|
265
|
-
/* @__PURE__ */ u("div", { className: "flex flex-col gap-0.5 max-h-56 overflow-y-auto p-1.5", children: [
|
|
266
|
-
p.length > 0 && /* @__PURE__ */ u("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
|
|
267
|
-
/* @__PURE__ */ r(C, { checked: y, onCheckedChange: f }),
|
|
268
|
-
"Tout sélectionner"
|
|
269
|
-
] }),
|
|
270
|
-
p.length === 0 && /* @__PURE__ */ r("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: "Aucun résultat" }),
|
|
271
|
-
p.map((t) => /* @__PURE__ */ u("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
|
|
272
|
-
/* @__PURE__ */ r(
|
|
273
|
-
C,
|
|
274
|
-
{
|
|
275
|
-
checked: s.includes(t.value),
|
|
276
|
-
onCheckedChange: () => {
|
|
277
|
-
i(t.value);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
),
|
|
281
|
-
t.label
|
|
282
|
-
] }, t.value))
|
|
283
|
-
] }),
|
|
284
|
-
s.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border p-1.5", children: /* @__PURE__ */ r(
|
|
285
|
-
"button",
|
|
286
|
-
{
|
|
287
|
-
onClick: () => {
|
|
288
|
-
d !== void 0 ? d() : s.forEach((t) => {
|
|
289
|
-
i(t);
|
|
290
|
-
});
|
|
291
|
-
},
|
|
292
|
-
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",
|
|
293
|
-
children: "Tout désélectionner"
|
|
294
|
-
}
|
|
295
|
-
) })
|
|
296
|
-
] })
|
|
297
|
-
]
|
|
298
|
-
}
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
function we({
|
|
302
|
-
searchQuery: n,
|
|
303
|
-
onSearchChange: l,
|
|
304
|
-
searchPlaceholder: s = "Rechercher...",
|
|
305
|
-
filters: i,
|
|
306
|
-
onFiltersChange: d,
|
|
307
|
-
sections: c,
|
|
308
|
-
advancedButtonText: h = "Filtres",
|
|
309
|
-
sheetTitle: m = "Filtres avancés"
|
|
310
|
-
}) {
|
|
311
|
-
const b = (e, a) => {
|
|
312
|
-
const o = i[e], g = Array.isArray(o) ? o : [], S = g.includes(a) ? g.filter((T) => T !== a) : [...g, a], A = { ...i };
|
|
313
|
-
S.length === 0 ? delete A[e] : A[e] = S, d(A);
|
|
314
|
-
}, x = (e) => {
|
|
315
|
-
const a = { ...i };
|
|
316
|
-
delete a[e], d(a);
|
|
317
|
-
}, v = () => {
|
|
318
|
-
d({});
|
|
319
|
-
}, p = (e, a) => {
|
|
320
|
-
const o = { ...i }, g = o[e];
|
|
321
|
-
Array.isArray(g) && a !== void 0 ? (o[e] = g.filter((S) => S !== a), Array.isArray(o[e]) && o[e].length === 0 && delete o[e]) : delete o[e], d(o);
|
|
322
|
-
}, y = N(() => {
|
|
323
|
-
const e = [];
|
|
324
|
-
return c.forEach((a) => {
|
|
325
|
-
a.filters.forEach((o) => {
|
|
326
|
-
o.isQuickFilter === !0 && e.push({
|
|
327
|
-
key: o.key,
|
|
328
|
-
label: o.label,
|
|
329
|
-
options: o.options ?? [],
|
|
330
|
-
searchable: o.searchable,
|
|
331
|
-
searchPlaceholder: o.searchPlaceholder
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
}), e;
|
|
335
|
-
}, [c]), f = N(() => {
|
|
336
|
-
const e = {};
|
|
337
|
-
return c.forEach((a) => {
|
|
338
|
-
a.filters.forEach((o) => {
|
|
339
|
-
e[o.key] = o.badgeLabel ?? o.label;
|
|
340
|
-
});
|
|
341
|
-
}), e;
|
|
342
|
-
}, [c]), t = N(() => {
|
|
343
|
-
const e = {};
|
|
344
|
-
return c.forEach((a) => {
|
|
345
|
-
a.filters.forEach((o) => {
|
|
346
|
-
o.options !== void 0 && o.options.forEach((g) => {
|
|
347
|
-
e[`${o.key}_${g.value}`] = g.label;
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
}), e;
|
|
351
|
-
}, [c]);
|
|
352
|
-
return /* @__PURE__ */ u("div", { className: "space-y-4 w-full", children: [
|
|
353
|
-
/* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-3 justify-between", children: /* @__PURE__ */ u("div", { className: "flex flex-wrap items-center gap-3", children: [
|
|
354
|
-
l !== void 0 ? /* @__PURE__ */ r(
|
|
355
|
-
M,
|
|
356
|
-
{
|
|
357
|
-
searchQuery: n,
|
|
358
|
-
onSearch: l,
|
|
359
|
-
onClear: () => {
|
|
360
|
-
l("");
|
|
361
|
-
},
|
|
362
|
-
placeholder: s
|
|
363
|
-
}
|
|
364
|
-
) : null,
|
|
365
|
-
y.map((e) => /* @__PURE__ */ r(
|
|
366
|
-
ne,
|
|
367
|
-
{
|
|
368
|
-
label: e.label,
|
|
369
|
-
options: e.options,
|
|
370
|
-
selected: Array.isArray(i[e.key]) ? i[e.key] : [],
|
|
371
|
-
onToggle: (a) => {
|
|
372
|
-
b(e.key, a);
|
|
373
|
-
},
|
|
374
|
-
onClear: () => {
|
|
375
|
-
x(e.key);
|
|
376
|
-
},
|
|
377
|
-
onSelectAll: (a) => {
|
|
378
|
-
d({ ...i, [e.key]: a });
|
|
379
|
-
},
|
|
380
|
-
searchable: e.searchable,
|
|
381
|
-
searchPlaceholder: e.searchPlaceholder
|
|
382
|
-
},
|
|
383
|
-
e.key
|
|
384
|
-
)),
|
|
385
|
-
c.length > 0 && /* @__PURE__ */ r(se, { sections: c, filters: i, onFiltersChange: d, buttonText: h, sheetTitle: m })
|
|
386
|
-
] }) }),
|
|
387
|
-
/* @__PURE__ */ r(
|
|
388
|
-
le,
|
|
389
|
-
{
|
|
390
|
-
filters: i,
|
|
391
|
-
onRemoveFilter: p,
|
|
392
|
-
onClearAll: v,
|
|
393
|
-
filterLabels: f,
|
|
394
|
-
optionLabels: t
|
|
395
|
-
}
|
|
396
|
-
)
|
|
397
|
-
] });
|
|
398
|
-
}
|
|
399
|
-
export {
|
|
400
|
-
le as A,
|
|
401
|
-
ae as F,
|
|
402
|
-
ne as S,
|
|
403
|
-
we as T,
|
|
404
|
-
se as a
|
|
405
|
-
};
|