@krosoft/react 0.0.311 → 0.0.313
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/behavior-bxFMjAHE.js +201 -0
- package/dist/components/core/index.js +1 -1
- package/dist/components/core/navbar/index.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/hooks/behavior/index.d.ts +2 -0
- package/dist/hooks/behavior/index.d.ts.map +1 -1
- package/dist/hooks/behavior/index.js +2 -2
- package/dist/hooks/behavior/useDebounce.d.ts +7 -0
- package/dist/hooks/behavior/useDebounce.d.ts.map +1 -0
- package/dist/hooks/behavior/useTable.d.ts +31 -0
- package/dist/hooks/behavior/useTable.d.ts.map +1 -0
- package/dist/hooks/index.js +2 -2
- package/dist/{navbar-C4WWdADW.js → navbar-DD0va8YU.js} +1 -1
- package/package.json +11 -6
- package/dist/behavior-2kM6-wgK.js +0 -116
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { t as e } from "./i18n-ClZK4zll.js";
|
|
2
|
+
import { n as t } from "./datatable-COQcYUrk.js";
|
|
3
|
+
import "./constants/index.js";
|
|
4
|
+
import { n, t as r } from "./sidebar.context-BahtU6hE.js";
|
|
5
|
+
import * as i from "react";
|
|
6
|
+
import { useCallback as a, useContext as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
7
|
+
import { TrashIcon as d } from "lucide-react";
|
|
8
|
+
import { format as f, parse as p } from "date-fns";
|
|
9
|
+
import { useQuery as m } from "@tanstack/react-query";
|
|
10
|
+
import { useSearchParams as h } from "react-router-dom";
|
|
11
|
+
//#region src/hooks/behavior/useDialog.ts
|
|
12
|
+
var g = (e) => {
|
|
13
|
+
let [t, n] = u(null);
|
|
14
|
+
return {
|
|
15
|
+
id: t?.id ?? null,
|
|
16
|
+
name: t?.name ?? null,
|
|
17
|
+
isOpen: !!t,
|
|
18
|
+
openDialog: (t, r) => {
|
|
19
|
+
e?.onReset?.(), n({
|
|
20
|
+
id: t,
|
|
21
|
+
name: r
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
onClose: () => {
|
|
25
|
+
n(null);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}, _ = ({ titleKey: e, descriptionKey: t, confirmKey: n = "Confirmer", onConfirm: r, onReset: i }) => {
|
|
29
|
+
let a = g({ onReset: i });
|
|
30
|
+
return {
|
|
31
|
+
isOpen: a.isOpen,
|
|
32
|
+
itemName: a.name,
|
|
33
|
+
title: e,
|
|
34
|
+
description: t,
|
|
35
|
+
confirmKey: n,
|
|
36
|
+
openDialog: a.openDialog,
|
|
37
|
+
onClose: a.onClose,
|
|
38
|
+
onConfirm: async () => {
|
|
39
|
+
if (a.id) try {
|
|
40
|
+
await r(a.id), a.onClose();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error("Error confirming action:", e);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, v = ({ titleKey: t, descriptionKey: n, confirmKey: r, onConfirm: i, onReset: a }) => {
|
|
47
|
+
let { t: o } = e();
|
|
48
|
+
return {
|
|
49
|
+
..._({
|
|
50
|
+
titleKey: t,
|
|
51
|
+
descriptionKey: n,
|
|
52
|
+
confirmKey: r ?? o("actions.delete"),
|
|
53
|
+
onConfirm: i,
|
|
54
|
+
onReset: a
|
|
55
|
+
}),
|
|
56
|
+
loadingKey: "actions.deleting",
|
|
57
|
+
icon: d,
|
|
58
|
+
titleClassName: "flex items-center gap-2 text-destructive"
|
|
59
|
+
};
|
|
60
|
+
}, y = (e, t) => {
|
|
61
|
+
let [n, r] = u(e), i = l(void 0);
|
|
62
|
+
return s(() => (i.current = setTimeout(() => {
|
|
63
|
+
r(e);
|
|
64
|
+
}, t), () => {
|
|
65
|
+
clearTimeout(i.current);
|
|
66
|
+
}), [e, t]), [n, a((e) => {
|
|
67
|
+
clearTimeout(i.current), r(e);
|
|
68
|
+
}, [])];
|
|
69
|
+
}, b = (e, t = 250) => {
|
|
70
|
+
let [n, r] = i.useState(e);
|
|
71
|
+
return i.useEffect(() => {
|
|
72
|
+
let n = setTimeout(() => {
|
|
73
|
+
r(e);
|
|
74
|
+
}, t);
|
|
75
|
+
return () => {
|
|
76
|
+
clearTimeout(n);
|
|
77
|
+
};
|
|
78
|
+
}, [e, t]), n;
|
|
79
|
+
}, x = () => {
|
|
80
|
+
let e = o(n);
|
|
81
|
+
if (e === void 0) throw Error("usePage must be used within an PageProvider");
|
|
82
|
+
return e;
|
|
83
|
+
}, S = () => {
|
|
84
|
+
let e = o(r);
|
|
85
|
+
if (e === void 0) throw Error("useSidebar must be used within a SidebarProvider");
|
|
86
|
+
return e;
|
|
87
|
+
}, C = ({ queryKey: e, queryFn: n, defaultSortField: r = "", defaultSortDirection: i = "asc", additionalQueryParams: o = {}, resetUrlParams: d = [], onResetFilters: f = () => {}, enabled: p = !0 }) => {
|
|
88
|
+
let [g, _] = h(), v = parseInt(g.get("page") || "1", 10), b = g.get("search") || "", x = g.get("sortField") || r, S = g.get("sortDirection") || i, [C, w] = u(v), [T, E] = u(t), D = a((e) => {
|
|
89
|
+
E(e), w(1);
|
|
90
|
+
}, []), [O, k] = u(b), [A, j] = u(x), [M, N] = u(S), [P, F] = y(O, 300), I = l(P);
|
|
91
|
+
s(() => {
|
|
92
|
+
I.current !== P && C !== 1 && w(1), I.current = P;
|
|
93
|
+
}, [P, C]), s(() => {
|
|
94
|
+
_((e) => (C === 1 ? e.delete("page") : e.set("page", C.toString()), P.trim() ? e.set("search", P.trim()) : e.delete("search"), A && A !== r ? e.set("sortField", A) : e.delete("sortField"), M === i ? e.delete("sortDirection") : e.set("sortDirection", M), e), { replace: !0 });
|
|
95
|
+
}, [
|
|
96
|
+
C,
|
|
97
|
+
P,
|
|
98
|
+
A,
|
|
99
|
+
M,
|
|
100
|
+
r,
|
|
101
|
+
i,
|
|
102
|
+
_
|
|
103
|
+
]);
|
|
104
|
+
let L = c(() => ({
|
|
105
|
+
pageNumber: C,
|
|
106
|
+
pageSize: T,
|
|
107
|
+
text: P.trim() || void 0,
|
|
108
|
+
...o
|
|
109
|
+
}), [
|
|
110
|
+
C,
|
|
111
|
+
T,
|
|
112
|
+
P,
|
|
113
|
+
o
|
|
114
|
+
]), R = c(() => A ? [{
|
|
115
|
+
key: A,
|
|
116
|
+
order: M
|
|
117
|
+
}] : [], [A, M]), z = a((e) => {
|
|
118
|
+
e && (A === e ? N(M === "asc" ? "desc" : "asc") : (j(e), N("asc")));
|
|
119
|
+
}, [A, M]), B = a(() => {
|
|
120
|
+
k(""), F(""), w(1), j(r), N(i), _((e) => (e.delete("page"), e.delete("search"), e.delete("sortField"), e.delete("sortDirection"), d.forEach((t) => {
|
|
121
|
+
e.delete(t);
|
|
122
|
+
}), e), { replace: !0 }), f();
|
|
123
|
+
}, [
|
|
124
|
+
r,
|
|
125
|
+
i,
|
|
126
|
+
F,
|
|
127
|
+
_,
|
|
128
|
+
d,
|
|
129
|
+
f
|
|
130
|
+
]), V = c(() => [
|
|
131
|
+
...e,
|
|
132
|
+
L,
|
|
133
|
+
R
|
|
134
|
+
], [
|
|
135
|
+
e,
|
|
136
|
+
L,
|
|
137
|
+
R
|
|
138
|
+
]), { data: H, isLoading: U, error: W, refetch: G } = m({
|
|
139
|
+
queryKey: V,
|
|
140
|
+
queryFn: () => n(L, R),
|
|
141
|
+
enabled: p
|
|
142
|
+
});
|
|
143
|
+
return {
|
|
144
|
+
paginationResult: H,
|
|
145
|
+
isLoading: U,
|
|
146
|
+
error: W,
|
|
147
|
+
refetch: G,
|
|
148
|
+
pageNumber: C,
|
|
149
|
+
pageSize: T,
|
|
150
|
+
setPageNumber: w,
|
|
151
|
+
setPageSize: D,
|
|
152
|
+
search: O,
|
|
153
|
+
debouncedSearch: P,
|
|
154
|
+
setSearch: k,
|
|
155
|
+
sortField: A,
|
|
156
|
+
sortDirection: M,
|
|
157
|
+
handleSort: z,
|
|
158
|
+
resetFilters: B
|
|
159
|
+
};
|
|
160
|
+
}, w = "yyyy-MM-dd";
|
|
161
|
+
function T(e, t, n, r) {
|
|
162
|
+
let [i, o] = h(), s = i.get(e), c;
|
|
163
|
+
c = s === null ? t : n ? n(s) : s;
|
|
164
|
+
let l = a((n) => {
|
|
165
|
+
o((i) => {
|
|
166
|
+
let a = r ? r(n) : String(n);
|
|
167
|
+
return a === (r ? r(t) : String(t)) || a === "" || a === "undefined" ? i.delete(e) : i.set(e, a), i;
|
|
168
|
+
}, { replace: !0 });
|
|
169
|
+
}, [
|
|
170
|
+
e,
|
|
171
|
+
t,
|
|
172
|
+
r,
|
|
173
|
+
o
|
|
174
|
+
]);
|
|
175
|
+
return [c, l];
|
|
176
|
+
}
|
|
177
|
+
function E(e, t = []) {
|
|
178
|
+
return T(e, t, (e) => e ? e.split(",").filter(Boolean) : [], (e) => e.join(","));
|
|
179
|
+
}
|
|
180
|
+
function D(e, t) {
|
|
181
|
+
return T(e, t, (e) => parseInt(e, 10) || t, (e) => e.toString());
|
|
182
|
+
}
|
|
183
|
+
var O = (e) => {
|
|
184
|
+
if (!e) return;
|
|
185
|
+
let [t, n] = e.split("_"), r = t ? p(t, w, /* @__PURE__ */ new Date()) : void 0;
|
|
186
|
+
if (!r || isNaN(r.getTime())) return;
|
|
187
|
+
let i = n ? p(n, w, /* @__PURE__ */ new Date()) : void 0;
|
|
188
|
+
return {
|
|
189
|
+
from: r,
|
|
190
|
+
to: i && !isNaN(i.getTime()) ? i : void 0
|
|
191
|
+
};
|
|
192
|
+
}, k = (e) => {
|
|
193
|
+
if (!e?.from) return "";
|
|
194
|
+
let t = f(e.from, w), n = e.to ? f(e.to, w) : "";
|
|
195
|
+
return n ? `${t}_${n}` : t;
|
|
196
|
+
};
|
|
197
|
+
function A(e) {
|
|
198
|
+
return T(e, void 0, O, k);
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
export { A as a, C as c, b as d, y as f, g as h, E as i, S as l, _ as m, O as n, D as o, v as p, k as r, T as s, w as t, x as u };
|
|
@@ -18,7 +18,7 @@ import { t as Y } from "../../language-VKGAsAfF.js";
|
|
|
18
18
|
import { t as X } from "../../AppTitle-DIHE8uen.js";
|
|
19
19
|
import { n as Z, t as Q } from "../../states-C3v4BU7N.js";
|
|
20
20
|
import { AppPageHeader as $, KpiCardsLayout as ee } from "./layouts/index.js";
|
|
21
|
-
import { a as te, i as ne, n as re, o as ie, r as ae, t as oe } from "../../navbar-
|
|
21
|
+
import { a as te, i as ne, n as re, o as ie, r as ae, t as oe } from "../../navbar-DD0va8YU.js";
|
|
22
22
|
import { DataTable as se, JsonTableOutput as ce, TableActions as le, TableBody as ue, TableBulkActions as de, TableHeader as fe, TablePagination as pe, TableSettings as me } from "./table/index.js";
|
|
23
23
|
import { AppTabContainer as he, AppTabHeader as ge, AppTabs as _e, AppVerticalTabs as ve } from "./tabs/index.js";
|
|
24
24
|
import { t as ye } from "../../theme-Bkamu5J6.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, t as a } from "../../../navbar-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, t as a } from "../../../navbar-DD0va8YU.js";
|
|
2
2
|
export { r as GlobalSearch, e as NotificationsBell, i as Sidebar, n as SidebarHeader, t as SidebarNavItem, a as Topbar };
|
package/dist/components/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import { t as $r } from "../language-VKGAsAfF.js";
|
|
|
22
22
|
import { t as ei } from "../AppTitle-DIHE8uen.js";
|
|
23
23
|
import { n as ti, t as ni } from "../states-C3v4BU7N.js";
|
|
24
24
|
import { AppPageHeader as ri, KpiCardsLayout as ii } from "./core/layouts/index.js";
|
|
25
|
-
import { a as ai, i as oi, n as si, o as ci, r as li, t as ui } from "../navbar-
|
|
25
|
+
import { a as ai, i as oi, n as si, o as ci, r as li, t as ui } from "../navbar-DD0va8YU.js";
|
|
26
26
|
import { DataTable as di, JsonTableOutput as fi, TableActions as pi, TableBody as mi, TableBulkActions as hi, TableHeader as gi, TablePagination as _i, TableSettings as vi } from "./core/table/index.js";
|
|
27
27
|
import { AppTabContainer as yi, AppTabHeader as bi, AppTabs as xi, AppVerticalTabs as Si } from "./core/tabs/index.js";
|
|
28
28
|
import { t as Ci } from "../theme-Bkamu5J6.js";
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { useConfirmationDialog } from "./useConfirmationDialog";
|
|
2
2
|
export { useConfirmDeleteDialog } from "./useConfirmDeleteDialog";
|
|
3
|
+
export { useDebounce } from "./useDebounce";
|
|
3
4
|
export { useDebouncedValue } from "./useDebouncedValue";
|
|
4
5
|
export { useDialog } from "./useDialog";
|
|
5
6
|
export type { DialogState } from "./useDialog";
|
|
6
7
|
export { usePage } from "./usePage";
|
|
7
8
|
export { useSidebar } from "./useSidebar";
|
|
9
|
+
export { useTable } from "./useTable";
|
|
8
10
|
export { parseDateRange, serializeDateRange, URL_DATE_FORMAT, useUrlArrayState, useUrlDateRangeState, useUrlNumberState, useUrlState } from "./useUrlState";
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/behavior/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/behavior/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t, d as n, f as r, i,
|
|
2
|
-
export {
|
|
1
|
+
import { a as e, c as t, d as n, f as r, h as i, i as a, l as o, m as s, n as c, o as l, p as u, r as d, s as f, t as p, u as m } from "../../behavior-bxFMjAHE.js";
|
|
2
|
+
export { p as URL_DATE_FORMAT, c as parseDateRange, d as serializeDateRange, u as useConfirmDeleteDialog, s as useConfirmationDialog, r as useDebounce, n as useDebouncedValue, i as useDialog, m as usePage, o as useSidebar, t as useTable, a as useUrlArrayState, e as useUrlDateRangeState, l as useUrlNumberState, f as useUrlState };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retarde la propagation d'une valeur, et expose un `flush` pour l'appliquer immédiatement
|
|
3
|
+
* quand l'utilisateur déclenche une action explicite qui ne doit pas paraître en retard
|
|
4
|
+
* (réinitialisation d'un filtre, par exemple).
|
|
5
|
+
*/
|
|
6
|
+
export declare const useDebounce: <T>(value: T, delay: number) => readonly [T, (immediateValue: T) => void];
|
|
7
|
+
//# sourceMappingURL=useDebounce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDebounce.d.ts","sourceRoot":"","sources":["../../../src/hooks/behavior/useDebounce.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,mCAcT,CAAC,UAM7C,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PaginationQuery, PaginationResult, SortOption } from "@krosoft/core/types";
|
|
2
|
+
interface UseTableProps<TQueryParams, TResult> {
|
|
3
|
+
queryKey: string[];
|
|
4
|
+
queryFn: (queryParams: TQueryParams, sortOptions: SortOption[]) => Promise<PaginationResult<TResult>>;
|
|
5
|
+
defaultSortField?: string;
|
|
6
|
+
defaultSortDirection?: "asc" | "desc";
|
|
7
|
+
additionalQueryParams?: Partial<TQueryParams>;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
/** Paramètres d'URL propres à la table (filtres métier) à effacer lors d'une réinitialisation. */
|
|
10
|
+
resetUrlParams?: string[];
|
|
11
|
+
onResetFilters?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const useTable: <TQueryParams extends PaginationQuery, TResult>({ queryKey: baseQueryKey, queryFn, defaultSortField, defaultSortDirection, additionalQueryParams, resetUrlParams, onResetFilters, enabled, }: UseTableProps<TQueryParams, TResult>) => {
|
|
14
|
+
paginationResult: PaginationResult<TResult> | undefined;
|
|
15
|
+
isLoading: boolean;
|
|
16
|
+
error: Error | null;
|
|
17
|
+
refetch: (options?: import("@tanstack/query-core").RefetchOptions) => Promise<import("@tanstack/query-core").QueryObserverResult<PaginationResult<TResult>, Error>>;
|
|
18
|
+
pageNumber: number;
|
|
19
|
+
pageSize: number;
|
|
20
|
+
setPageNumber: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
21
|
+
setPageSize: (size: number) => void;
|
|
22
|
+
search: string;
|
|
23
|
+
debouncedSearch: string;
|
|
24
|
+
setSearch: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
25
|
+
sortField: string;
|
|
26
|
+
sortDirection: "asc" | "desc";
|
|
27
|
+
handleSort: (field: string | null) => void;
|
|
28
|
+
resetFilters: () => void;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=useTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTable.d.ts","sourceRoot":"","sources":["../../../src/hooks/behavior/useTable.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMzF,UAAU,aAAa,CAAC,YAAY,EAAE,OAAO;IAC3C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACtG,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACtC,qBAAqB,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kGAAkG;IAClG,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,eAAO,MAAM,QAAQ,GAAI,YAAY,SAAS,eAAe,EAAE,OAAO,EAAE,8IASrE,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC;;;;;;;;wBAcE,MAAM;;;;;;wBAgFnC,MAAM,GAAG,IAAI;;CA2ExB,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -7,5 +7,5 @@ import { t as s } from "../useDocumentTitle-Ces2VRou.js";
|
|
|
7
7
|
import { t as c } from "../useLanguage-c7lPQ7eh.js";
|
|
8
8
|
import { t as l } from "../ui-Bbn7hLKT.js";
|
|
9
9
|
import { t as u } from "../useTheme-CU6lGuO4.js";
|
|
10
|
-
import { a as d, c as f, d as p, f as m, i as
|
|
11
|
-
export {
|
|
10
|
+
import { a as d, c as f, d as p, f as m, h, i as g, l as _, m as v, n as y, o as b, p as x, r as S, s as C, t as w, u as T } from "../behavior-bxFMjAHE.js";
|
|
11
|
+
export { w as URL_DATE_FORMAT, y as parseDateRange, S as serializeDateRange, n as toast, x as useConfirmDeleteDialog, v as useConfirmationDialog, a as useDataTable, m as useDebounce, p as useDebouncedValue, h as useDialog, s as useDocumentTitle, o as useFixedColumns, c as useLanguage, r as useMobile, i as useNotifications, T as usePage, e as useScrollFade, l as useServerTable, _ as useSidebar, f as useTable, u as useTheme, t as useToast, g as useUrlArrayState, d as useUrlDateRangeState, b as useUrlNumberState, C as useUrlState };
|
|
@@ -3,7 +3,7 @@ import { t } from "./i18n-ClZK4zll.js";
|
|
|
3
3
|
import { c as n, i as r, n as i, r as a, t as o } from "./tooltip-_geGvbS7.js";
|
|
4
4
|
import { C as s, S as c, b as l, d as u, g as d, h as f, i as p, l as m, m as h, p as g, r as _, t as v, v as y, x as b, y as x } from "./sheet-BjlRzLnc.js";
|
|
5
5
|
import { t as S } from "./skeleton-D6Ga4BLw.js";
|
|
6
|
-
import {
|
|
6
|
+
import { l as C } from "./behavior-bxFMjAHE.js";
|
|
7
7
|
import "./hooks/index.js";
|
|
8
8
|
import * as w from "react";
|
|
9
9
|
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krosoft/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.313",
|
|
4
4
|
"description": "Krosoft shared React package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@krosoft/core": ">=0.0.1",
|
|
34
|
+
"@tanstack/react-query": ">=5",
|
|
34
35
|
"next-themes": ">=0.4.6",
|
|
35
36
|
"react": ">=19.2.8",
|
|
36
37
|
"react-i18next": ">=17.0.13",
|
|
@@ -38,6 +39,9 @@
|
|
|
38
39
|
"vite-plugin-pwa": ">=1.3.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependenciesMeta": {
|
|
42
|
+
"@tanstack/react-query": {
|
|
43
|
+
"optional": true
|
|
44
|
+
},
|
|
41
45
|
"next-themes": {
|
|
42
46
|
"optional": true
|
|
43
47
|
},
|
|
@@ -83,10 +87,10 @@
|
|
|
83
87
|
"date-fns": "^4.4.0",
|
|
84
88
|
"embla-carousel-react": "^8.6.0",
|
|
85
89
|
"input-otp": "^1.5.0",
|
|
86
|
-
"lucide-react": "^1.
|
|
90
|
+
"lucide-react": "^1.41.0",
|
|
87
91
|
"react-day-picker": "^10.0.1",
|
|
88
92
|
"react-hook-form": "^7.87.0",
|
|
89
|
-
"react-resizable-panels": "^4.12.
|
|
93
|
+
"react-resizable-panels": "^4.12.4",
|
|
90
94
|
"recharts": "^3.10.1",
|
|
91
95
|
"sonner": "^2.0.8",
|
|
92
96
|
"tailwind-merge": "^2.6.1",
|
|
@@ -103,14 +107,15 @@
|
|
|
103
107
|
"@storybook/addon-docs": "^10.6.0",
|
|
104
108
|
"@storybook/addon-themes": "^10.6.0",
|
|
105
109
|
"@storybook/react-vite": "^10.6.0",
|
|
110
|
+
"@tanstack/react-query": "^5.102.8",
|
|
106
111
|
"@testing-library/dom": "^10.4.1",
|
|
107
112
|
"@testing-library/react": "^16.3.3",
|
|
108
113
|
"@types/node": "^25.9.5",
|
|
109
114
|
"@types/react": "^19.2.18",
|
|
110
|
-
"@types/react-dom": "^19.2.
|
|
111
|
-
"autoprefixer": "^10.5.
|
|
115
|
+
"@types/react-dom": "^19.2.7",
|
|
116
|
+
"autoprefixer": "^10.5.5",
|
|
112
117
|
"eslint-plugin-storybook": "10.6.0",
|
|
113
|
-
"i18next": "^26.4.
|
|
118
|
+
"i18next": "^26.4.2",
|
|
114
119
|
"jsdom": "^30.0.1",
|
|
115
120
|
"next-themes": "^0.4.6",
|
|
116
121
|
"prettier": "^3.9.6",
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./i18n-ClZK4zll.js";
|
|
2
|
-
import { n as t, t as n } from "./sidebar.context-BahtU6hE.js";
|
|
3
|
-
import * as r from "react";
|
|
4
|
-
import { useCallback as i, useContext as a, useState as o } from "react";
|
|
5
|
-
import { TrashIcon as s } from "lucide-react";
|
|
6
|
-
import { format as c, parse as l } from "date-fns";
|
|
7
|
-
import { useSearchParams as u } from "react-router-dom";
|
|
8
|
-
//#region src/hooks/behavior/useDialog.ts
|
|
9
|
-
var d = (e) => {
|
|
10
|
-
let [t, n] = o(null);
|
|
11
|
-
return {
|
|
12
|
-
id: t?.id ?? null,
|
|
13
|
-
name: t?.name ?? null,
|
|
14
|
-
isOpen: !!t,
|
|
15
|
-
openDialog: (t, r) => {
|
|
16
|
-
e?.onReset?.(), n({
|
|
17
|
-
id: t,
|
|
18
|
-
name: r
|
|
19
|
-
});
|
|
20
|
-
},
|
|
21
|
-
onClose: () => {
|
|
22
|
-
n(null);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
}, f = ({ titleKey: e, descriptionKey: t, confirmKey: n = "Confirmer", onConfirm: r, onReset: i }) => {
|
|
26
|
-
let a = d({ onReset: i });
|
|
27
|
-
return {
|
|
28
|
-
isOpen: a.isOpen,
|
|
29
|
-
itemName: a.name,
|
|
30
|
-
title: e,
|
|
31
|
-
description: t,
|
|
32
|
-
confirmKey: n,
|
|
33
|
-
openDialog: a.openDialog,
|
|
34
|
-
onClose: a.onClose,
|
|
35
|
-
onConfirm: async () => {
|
|
36
|
-
if (a.id) try {
|
|
37
|
-
await r(a.id), a.onClose();
|
|
38
|
-
} catch (e) {
|
|
39
|
-
console.error("Error confirming action:", e);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}, p = ({ titleKey: t, descriptionKey: n, confirmKey: r, onConfirm: i, onReset: a }) => {
|
|
44
|
-
let { t: o } = e();
|
|
45
|
-
return {
|
|
46
|
-
...f({
|
|
47
|
-
titleKey: t,
|
|
48
|
-
descriptionKey: n,
|
|
49
|
-
confirmKey: r ?? o("actions.delete"),
|
|
50
|
-
onConfirm: i,
|
|
51
|
-
onReset: a
|
|
52
|
-
}),
|
|
53
|
-
loadingKey: "actions.deleting",
|
|
54
|
-
icon: s,
|
|
55
|
-
titleClassName: "flex items-center gap-2 text-destructive"
|
|
56
|
-
};
|
|
57
|
-
}, m = (e, t = 250) => {
|
|
58
|
-
let [n, i] = r.useState(e);
|
|
59
|
-
return r.useEffect(() => {
|
|
60
|
-
let n = setTimeout(() => {
|
|
61
|
-
i(e);
|
|
62
|
-
}, t);
|
|
63
|
-
return () => {
|
|
64
|
-
clearTimeout(n);
|
|
65
|
-
};
|
|
66
|
-
}, [e, t]), n;
|
|
67
|
-
}, h = () => {
|
|
68
|
-
let e = a(t);
|
|
69
|
-
if (e === void 0) throw Error("usePage must be used within an PageProvider");
|
|
70
|
-
return e;
|
|
71
|
-
}, g = () => {
|
|
72
|
-
let e = a(n);
|
|
73
|
-
if (e === void 0) throw Error("useSidebar must be used within a SidebarProvider");
|
|
74
|
-
return e;
|
|
75
|
-
}, _ = "yyyy-MM-dd";
|
|
76
|
-
function v(e, t, n, r) {
|
|
77
|
-
let [a, o] = u(), s = a.get(e), c;
|
|
78
|
-
c = s === null ? t : n ? n(s) : s;
|
|
79
|
-
let l = i((n) => {
|
|
80
|
-
o((i) => {
|
|
81
|
-
let a = r ? r(n) : String(n);
|
|
82
|
-
return a === (r ? r(t) : String(t)) || a === "" || a === "undefined" ? i.delete(e) : i.set(e, a), i;
|
|
83
|
-
}, { replace: !0 });
|
|
84
|
-
}, [
|
|
85
|
-
e,
|
|
86
|
-
t,
|
|
87
|
-
r,
|
|
88
|
-
o
|
|
89
|
-
]);
|
|
90
|
-
return [c, l];
|
|
91
|
-
}
|
|
92
|
-
function y(e, t = []) {
|
|
93
|
-
return v(e, t, (e) => e ? e.split(",").filter(Boolean) : [], (e) => e.join(","));
|
|
94
|
-
}
|
|
95
|
-
function b(e, t) {
|
|
96
|
-
return v(e, t, (e) => parseInt(e, 10) || t, (e) => e.toString());
|
|
97
|
-
}
|
|
98
|
-
var x = (e) => {
|
|
99
|
-
if (!e) return;
|
|
100
|
-
let [t, n] = e.split("_"), r = t ? l(t, _, /* @__PURE__ */ new Date()) : void 0;
|
|
101
|
-
if (!r || isNaN(r.getTime())) return;
|
|
102
|
-
let i = n ? l(n, _, /* @__PURE__ */ new Date()) : void 0;
|
|
103
|
-
return {
|
|
104
|
-
from: r,
|
|
105
|
-
to: i && !isNaN(i.getTime()) ? i : void 0
|
|
106
|
-
};
|
|
107
|
-
}, S = (e) => {
|
|
108
|
-
if (!e?.from) return "";
|
|
109
|
-
let t = c(e.from, _), n = e.to ? c(e.to, _) : "";
|
|
110
|
-
return n ? `${t}_${n}` : t;
|
|
111
|
-
};
|
|
112
|
-
function C(e) {
|
|
113
|
-
return v(e, void 0, x, S);
|
|
114
|
-
}
|
|
115
|
-
//#endregion
|
|
116
|
-
export { C as a, g as c, p as d, f, y as i, h as l, x as n, b as o, d as p, S as r, v as s, _ as t, m as u };
|