@krosoft/react 0.0.119 → 0.0.121

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.
@@ -1 +1 @@
1
- {"version":3,"file":"FilterSection.d.ts","sourceRoot":"","sources":["../../src/types/FilterSection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,iBAAiB,EAAE,CAAC;CAC9B"}
1
+ {"version":3,"file":"FilterSection.d.ts","sourceRoot":"","sources":["../../src/types/FilterSection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACxF,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;CACjC"}
@@ -5,9 +5,9 @@ export * from "./ColumnDef";
5
5
  export * from "./ConfirmDialogConfig";
6
6
  export * from "./FilterFieldConfig";
7
7
  export * from "./FilterSection";
8
+ export * from "./forms";
8
9
  export * from "./RowAction";
9
10
  export * from "./TabConfig";
10
11
  export * from "./UseDataTableProps";
11
12
  export * from "./UseDataTableResult";
12
- export * from "./forms";
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.119",
3
+ "version": "0.0.121",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,409 +0,0 @@
1
- import { jsxs as m, jsx as r } from "react/jsx-runtime";
2
- import { useState as k, useEffect as M, useMemo as A } from "react";
3
- import { a as $, D as O, b as _, S as I } from "./SearchInput-DJ_F3emq.js";
4
- import { aW as C, bD as j, bM as z, bF as R, bI as B, bL as Q, a$ as V, bH as H, bv as W, bx as X, bw as G, ce as J, _ as P } from "./toggle-group-wIgXZYDq.js";
5
- import "./alert-B34E_4uH.js";
6
- import { B as w, C as K } from "./tooltip-YhBPXbcJ.js";
7
- import { X as E, S as U, h as Y, i as Z, a as q, c as ee } from "./select-DlQvLtI3.js";
8
- import "next-themes";
9
- import { B as L } from "./badge-CfWlt79h.js";
10
- import { c as re } from "./tailwind.helper-gWiv5-6R.js";
11
- import { M as te } from "./MultiSelect-BoisW4Kn.js";
12
- import { c as le } from "./createLucideIcon-MP_wDWjs.js";
13
- /**
14
- * @license lucide-react v1.17.0 - ISC
15
- *
16
- * This source code is licensed under the ISC license.
17
- * See the LICENSE file in the root directory of this source tree.
18
- */
19
- const ae = [
20
- [
21
- "path",
22
- {
23
- d: "M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",
24
- key: "sc7q7i"
25
- }
26
- ]
27
- ], se = le("funnel", ae), T = (s, l, a = {}) => {
28
- if (l instanceof Date)
29
- return l.toLocaleDateString("fr-FR");
30
- const o = String(l), i = a[`${s}_${o}`];
31
- return i !== void 0 ? i : s.includes("ok") || l === "true" || l === "false" ? l === "true" ? "Oui" : "Non" : o;
32
- };
33
- function ce({ filters: s, onRemoveFilter: l, onClearAll: a, filterLabels: o = {}, optionLabels: i = {} }) {
34
- const d = Object.entries(s).filter(([n, p]) => !(p == null || p === "" || Array.isArray(p) && p.length === 0));
35
- return d.length === 0 ? null : /* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-2 mb-4", children: [
36
- /* @__PURE__ */ r("span", { className: "text-sm text-gray-600 font-medium", children: "Filtres actifs :" }),
37
- d.flatMap(([n, p]) => {
38
- const f = o[n] ?? n;
39
- if (Array.isArray(p))
40
- return p.map((v) => {
41
- const b = T(n, v, i);
42
- return /* @__PURE__ */ m(
43
- L,
44
- {
45
- variant: "secondary",
46
- className: "flex items-center gap-1 px-3 py-1 bg-blue-50 text-blue-700 border border-blue-200 hover:bg-blue-100",
47
- children: [
48
- f,
49
- ": ",
50
- b,
51
- /* @__PURE__ */ r(
52
- "button",
53
- {
54
- onClick: () => {
55
- l(n, v);
56
- },
57
- className: "ml-1 hover:bg-blue-200 rounded-full p-0.5",
58
- children: /* @__PURE__ */ r(E, { className: "size-4" })
59
- }
60
- )
61
- ]
62
- },
63
- `${n}_${String(v)}`
64
- );
65
- });
66
- const x = T(n, p, i);
67
- return /* @__PURE__ */ m(L, { 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: [
68
- f,
69
- ": ",
70
- x,
71
- /* @__PURE__ */ r(
72
- "button",
73
- {
74
- onClick: () => {
75
- l(n);
76
- },
77
- className: "ml-1 hover:bg-blue-200 rounded-full p-0.5",
78
- children: /* @__PURE__ */ r(E, { className: "size-4" })
79
- }
80
- )
81
- ] }, n);
82
- }),
83
- d.length > 0 && /* @__PURE__ */ r("button", { onClick: a, className: "text-xs text-red-500 hover:text-red-600 transition-colors font-medium ml-2", children: "Effacer tout" })
84
- ] });
85
- }
86
- const ne = ({ field: s, value: l, onChange: a, onToggleMultiSelect: o }) => {
87
- var i;
88
- switch (s.type) {
89
- case "text":
90
- return /* @__PURE__ */ r(
91
- C,
92
- {
93
- placeholder: s.placeholder,
94
- value: l ?? "",
95
- onChange: (d) => {
96
- a(d.target.value);
97
- }
98
- }
99
- );
100
- case "number":
101
- return /* @__PURE__ */ r(
102
- C,
103
- {
104
- type: "number",
105
- placeholder: s.placeholder,
106
- value: l ?? "",
107
- onChange: (d) => {
108
- a(d.target.value);
109
- },
110
- min: s.min,
111
- max: s.max
112
- }
113
- );
114
- case "select":
115
- return s.searchable === !0 ? /* @__PURE__ */ r(
116
- _,
117
- {
118
- options: s.options ?? [],
119
- value: l,
120
- onChange: a,
121
- placeholder: s.placeholder,
122
- searchPlaceholder: s.searchPlaceholder
123
- }
124
- ) : /* @__PURE__ */ m(U, { value: l ?? "", onValueChange: a, children: [
125
- /* @__PURE__ */ r(Y, { className: re((l === void 0 || l === "") && "text-muted-foreground"), children: /* @__PURE__ */ r(Z, { placeholder: s.placeholder }) }),
126
- /* @__PURE__ */ r(q, { children: (i = s.options) == null ? void 0 : i.map((d) => /* @__PURE__ */ r(ee, { value: d.value, children: d.label }, d.value)) })
127
- ] });
128
- case "date":
129
- return /* @__PURE__ */ r(O, { date: l, onDateChange: a, placeholder: s.placeholder ?? "Sélectionner une date" });
130
- case "date-range":
131
- return /* @__PURE__ */ r($, { value: l, onChange: a, placeholder: s.placeholder });
132
- case "multi-select":
133
- return /* @__PURE__ */ r(
134
- te,
135
- {
136
- options: s.options ?? [],
137
- selected: l ?? [],
138
- onToggle: o,
139
- onClear: () => {
140
- a([]);
141
- },
142
- onSelectAll: a,
143
- placeholder: s.placeholder,
144
- searchable: s.searchable,
145
- searchPlaceholder: s.searchPlaceholder
146
- }
147
- );
148
- default:
149
- return null;
150
- }
151
- };
152
- function oe({
153
- sections: s,
154
- filters: l,
155
- onFiltersChange: a,
156
- buttonText: o = "Plus de filtres",
157
- sheetTitle: i = "Filtres avancés"
158
- }) {
159
- const [d, n] = k(!1), [p, f] = k(l);
160
- M(() => {
161
- f(l);
162
- }, [l, d]);
163
- const x = (g, t) => {
164
- f((h) => ({ ...h, [g]: t }));
165
- }, v = (g, t) => {
166
- const h = p[g], e = Array.isArray(h) ? h : [], u = e.includes(t) ? e.filter((c) => c !== t) : [...e, t];
167
- x(g, u);
168
- }, b = () => {
169
- a(p), n(!1);
170
- }, N = () => {
171
- f({}), a({}), n(!1);
172
- };
173
- return /* @__PURE__ */ m(j, { open: d, onOpenChange: n, children: [
174
- /* @__PURE__ */ r(z, { asChild: !0, children: /* @__PURE__ */ m(w, { variant: "outline", className: "gap-2", children: [
175
- /* @__PURE__ */ r(se, { className: "size-4 shrink-0" }),
176
- o
177
- ] }) }),
178
- /* @__PURE__ */ m(R, { side: "right", className: "w-[400px] sm:w-[500px] flex flex-col p-0", children: [
179
- /* @__PURE__ */ r(B, { className: "p-6 pb-0", children: /* @__PURE__ */ r(Q, { children: i }) }),
180
- /* @__PURE__ */ r("div", { className: "flex-1 overflow-y-auto p-6 pt-6", children: /* @__PURE__ */ r("div", { className: "space-y-6", children: s.map((g, t) => /* @__PURE__ */ m("div", { className: "space-y-4", children: [
181
- /* @__PURE__ */ r("h3", { className: "font-semibold text-sm text-gray-900 dark:text-gray-100 border-b pb-2", children: g.title }),
182
- g.filters.map((h) => /* @__PURE__ */ m("div", { className: "space-y-2", children: [
183
- /* @__PURE__ */ r(V, { htmlFor: h.key, children: h.label }),
184
- /* @__PURE__ */ r(
185
- ne,
186
- {
187
- field: h,
188
- value: p[h.key],
189
- onChange: (e) => {
190
- x(h.key, e);
191
- },
192
- onToggleMultiSelect: (e) => {
193
- v(h.key, e);
194
- }
195
- }
196
- )
197
- ] }, h.key))
198
- ] }, t)) }) }),
199
- /* @__PURE__ */ m(H, { className: "gap-2 p-6 border-t bg-white dark:bg-gray-950", children: [
200
- /* @__PURE__ */ r(w, { variant: "outline", className: "flex-1", onClick: N, children: "Effacer les filtres" }),
201
- /* @__PURE__ */ r(w, { className: "flex-1 bg-orange-500 hover:bg-orange-600 text-white", onClick: b, children: "Rechercher" })
202
- ] })
203
- ] })
204
- ] });
205
- }
206
- function ie({
207
- label: s,
208
- options: l,
209
- selected: a,
210
- onToggle: o,
211
- onClear: i,
212
- onSelectAll: d,
213
- searchable: n = !1,
214
- searchPlaceholder: p = "Rechercher..."
215
- }) {
216
- const [f, x] = k(""), v = a.length > 0, b = A(() => f === "" ? l : l.filter((t) => t.label.toLowerCase().includes(f.toLowerCase())), [l, f]), N = A(() => b.length === 0 ? !1 : b.every((t) => a.includes(t.value)), [b, a]), g = () => {
217
- if (N)
218
- if (d !== void 0) {
219
- const t = b.map((e) => e.value), h = a.filter((e) => !t.includes(e));
220
- d(h);
221
- } else i !== void 0 ? i() : a.forEach((t) => {
222
- o(t);
223
- });
224
- else if (d !== void 0) {
225
- const t = [...a];
226
- b.forEach((h) => {
227
- t.includes(h.value) || t.push(h.value);
228
- }), d(t);
229
- } else
230
- b.forEach((t) => {
231
- a.includes(t.value) || o(t.value);
232
- });
233
- };
234
- return /* @__PURE__ */ m(
235
- W,
236
- {
237
- onOpenChange: () => {
238
- x("");
239
- },
240
- children: [
241
- /* @__PURE__ */ r(X, { asChild: !0, children: /* @__PURE__ */ m(
242
- "button",
243
- {
244
- 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"}`,
245
- children: [
246
- s,
247
- a.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: a.length }),
248
- /* @__PURE__ */ r(K, { className: "size-3.5 opacity-60" })
249
- ]
250
- }
251
- ) }),
252
- /* @__PURE__ */ m(G, { className: "w-56 p-0", align: "start", children: [
253
- n ? /* @__PURE__ */ r("div", { className: "border-b border-border p-2", children: /* @__PURE__ */ m("div", { className: "relative", children: [
254
- /* @__PURE__ */ r(J, { className: "absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
255
- /* @__PURE__ */ r(
256
- "input",
257
- {
258
- 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",
259
- placeholder: p,
260
- value: f,
261
- onChange: (t) => {
262
- x(t.target.value);
263
- },
264
- autoFocus: !0
265
- }
266
- )
267
- ] }) }) : null,
268
- /* @__PURE__ */ m("div", { className: "flex flex-col gap-0.5 max-h-56 overflow-y-auto p-1.5", children: [
269
- b.length > 0 && /* @__PURE__ */ m("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
270
- /* @__PURE__ */ r(P, { checked: N, onCheckedChange: g }),
271
- "Tout sélectionner"
272
- ] }),
273
- b.length === 0 && /* @__PURE__ */ r("p", { className: "px-2 py-3 text-center text-xs text-muted-foreground", children: "Aucun résultat" }),
274
- b.map((t) => /* @__PURE__ */ m("label", { className: "flex items-center gap-2.5 rounded-md px-2 py-2 text-sm hover:bg-muted cursor-pointer transition-colors", children: [
275
- /* @__PURE__ */ r(
276
- P,
277
- {
278
- checked: a.includes(t.value),
279
- onCheckedChange: () => {
280
- o(t.value);
281
- }
282
- }
283
- ),
284
- t.label
285
- ] }, t.value))
286
- ] }),
287
- a.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border p-1.5", children: /* @__PURE__ */ r(
288
- "button",
289
- {
290
- onClick: () => {
291
- i !== void 0 ? i() : a.forEach((t) => {
292
- o(t);
293
- });
294
- },
295
- 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",
296
- children: "Tout désélectionner"
297
- }
298
- ) })
299
- ] })
300
- ]
301
- }
302
- );
303
- }
304
- function Ae({
305
- searchQuery: s,
306
- onSearchChange: l,
307
- searchPlaceholder: a = "Rechercher...",
308
- filters: o,
309
- onFiltersChange: i,
310
- filterLabels: d = {},
311
- sections: n,
312
- advancedButtonText: p = "Filtres",
313
- sheetTitle: f = "Filtres avancés"
314
- }) {
315
- const x = (e, u) => {
316
- const c = o[e], y = Array.isArray(c) ? c : [], S = y.includes(u) ? y.filter((D) => D !== u) : [...y, u], F = { ...o };
317
- S.length === 0 ? delete F[e] : F[e] = S, i(F);
318
- }, v = (e) => {
319
- const u = { ...o };
320
- delete u[e], i(u);
321
- }, b = () => {
322
- i({});
323
- }, N = (e, u) => {
324
- const c = { ...o }, y = c[e];
325
- Array.isArray(y) && u !== void 0 ? (c[e] = y.filter((S) => S !== u), Array.isArray(c[e]) && c[e].length === 0 && delete c[e]) : delete c[e], i(c);
326
- }, g = A(() => {
327
- const e = [];
328
- return n.forEach((u) => {
329
- u.filters.forEach((c) => {
330
- c.isQuickFilter === !0 && e.push({
331
- key: c.key,
332
- label: c.label,
333
- options: c.options ?? [],
334
- searchable: c.searchable,
335
- searchPlaceholder: c.searchPlaceholder
336
- });
337
- });
338
- }), e;
339
- }, [n]), t = A(() => {
340
- const e = { ...d };
341
- return n.forEach((u) => {
342
- u.filters.forEach((c) => {
343
- e[c.key] = c.label;
344
- });
345
- }), e;
346
- }, [n, d]), h = A(() => {
347
- const e = {};
348
- return n.forEach((u) => {
349
- u.filters.forEach((c) => {
350
- c.options !== void 0 && c.options.forEach((y) => {
351
- e[`${c.key}_${y.value}`] = y.label;
352
- });
353
- });
354
- }), e;
355
- }, [n]);
356
- return /* @__PURE__ */ m("div", { className: "space-y-4 w-full", children: [
357
- /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-3 justify-between", children: /* @__PURE__ */ m("div", { className: "flex flex-wrap items-center gap-3", children: [
358
- l !== void 0 ? /* @__PURE__ */ r(
359
- I,
360
- {
361
- searchQuery: s,
362
- onSearch: l,
363
- onClear: () => {
364
- l("");
365
- },
366
- placeholder: a
367
- }
368
- ) : null,
369
- g.map((e) => /* @__PURE__ */ r(
370
- ie,
371
- {
372
- label: e.label,
373
- options: e.options,
374
- selected: Array.isArray(o[e.key]) ? o[e.key] : [],
375
- onToggle: (u) => {
376
- x(e.key, u);
377
- },
378
- onClear: () => {
379
- v(e.key);
380
- },
381
- onSelectAll: (u) => {
382
- i({ ...o, [e.key]: u });
383
- },
384
- searchable: e.searchable,
385
- searchPlaceholder: e.searchPlaceholder
386
- },
387
- e.key
388
- )),
389
- n.length > 0 && /* @__PURE__ */ r(oe, { sections: n, filters: o, onFiltersChange: i, buttonText: p, sheetTitle: f })
390
- ] }) }),
391
- /* @__PURE__ */ r(
392
- ce,
393
- {
394
- filters: o,
395
- onRemoveFilter: N,
396
- onClearAll: b,
397
- filterLabels: t,
398
- optionLabels: h
399
- }
400
- )
401
- ] });
402
- }
403
- export {
404
- ce as A,
405
- ne as F,
406
- ie as S,
407
- Ae as T,
408
- oe as a
409
- };