@krosoft/react 0.0.106 → 0.0.107
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConfirmDialogConfig } from "@/types/ConfirmDialogConfig";
|
|
2
|
+
interface UseConfirmDeleteDialogProps {
|
|
3
|
+
titleKey: string;
|
|
4
|
+
descriptionKey: string;
|
|
5
|
+
confirmKey?: string;
|
|
6
|
+
onConfirm: (id: string) => Promise<any>;
|
|
7
|
+
onReset?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const useConfirmDeleteDialog: ({ titleKey, descriptionKey, confirmKey, onConfirm, onReset, }: UseConfirmDeleteDialogProps) => ConfirmDialogConfig;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=useConfirmDeleteDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConfirmDeleteDialog.d.ts","sourceRoot":"","sources":["../../../src/hooks/behavior/useConfirmDeleteDialog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE,UAAU,2BAA2B;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,eAAO,MAAM,sBAAsB,GAAI,+DAMpC,2BAA2B,KAAG,mBAsChC,CAAC"}
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export { useTheme } from "./ui/useTheme";
|
|
|
6
6
|
export type { ThemeOption } from "./ui/useTheme";
|
|
7
7
|
export { useDataTable } from "./ui/useDataTable";
|
|
8
8
|
export { useServerTable } from "./ui/useServerTable";
|
|
9
|
+
export { useConfirmDeleteDialog } from "./behavior/useConfirmDeleteDialog";
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,49 +1,80 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
import { u as
|
|
3
|
-
import { t as
|
|
1
|
+
import { u as v } from "../useMobile-DN1_OMDB.js";
|
|
2
|
+
import { u as A } from "../useNotifications-zbUhCvF_.js";
|
|
3
|
+
import { t as j, u as q } from "../useToast-BFTk4lWz.js";
|
|
4
4
|
import { u as G } from "../useTheme-B0Bxda3I.js";
|
|
5
5
|
import { u as I } from "../useDataTable-CxcA5S-s.js";
|
|
6
|
-
import { useState as a, useEffect as F, useCallback as
|
|
7
|
-
function
|
|
8
|
-
const [
|
|
6
|
+
import { useState as a, useEffect as F, useCallback as l } from "react";
|
|
7
|
+
function y(u, h = "nom", e = {}) {
|
|
8
|
+
const [g, n] = a(e.initialPage ?? 1), [r, s] = a(e.initialPageSize ?? 10), [m, c] = a(h), [S, o] = a(e.initialSortDirection ?? "asc"), [i, C] = a(e.initialSearchText ?? ""), [d, f] = a(e.initialSearchText ?? ""), [x, T] = a(u);
|
|
9
9
|
F(() => {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
},
|
|
10
|
+
const t = setTimeout(() => {
|
|
11
|
+
f(i);
|
|
12
|
+
}, e.debounceMs ?? 300);
|
|
13
13
|
return () => {
|
|
14
|
-
clearTimeout(
|
|
14
|
+
clearTimeout(t);
|
|
15
15
|
};
|
|
16
|
-
}, [
|
|
17
|
-
const
|
|
18
|
-
C(
|
|
19
|
-
}, []),
|
|
20
|
-
|
|
21
|
-
}, []),
|
|
22
|
-
|
|
23
|
-
}, []),
|
|
24
|
-
|
|
16
|
+
}, [i, e.debounceMs]);
|
|
17
|
+
const p = l((t) => {
|
|
18
|
+
C(t), n(1);
|
|
19
|
+
}, []), D = l((t) => {
|
|
20
|
+
T(t), n(1);
|
|
21
|
+
}, []), b = l((t, z) => {
|
|
22
|
+
c(t), o(z);
|
|
23
|
+
}, []), P = l((t) => {
|
|
24
|
+
s(t), n(1);
|
|
25
25
|
}, []);
|
|
26
26
|
return {
|
|
27
|
-
currentPage:
|
|
27
|
+
currentPage: g,
|
|
28
28
|
onPageChange: n,
|
|
29
|
-
pageSize:
|
|
30
|
-
onPageSizeChange:
|
|
31
|
-
sortColumn:
|
|
32
|
-
sortDirection:
|
|
33
|
-
onSortChange:
|
|
34
|
-
searchText:
|
|
29
|
+
pageSize: r,
|
|
30
|
+
onPageSizeChange: P,
|
|
31
|
+
sortColumn: m,
|
|
32
|
+
sortDirection: S,
|
|
33
|
+
onSortChange: b,
|
|
34
|
+
searchText: i,
|
|
35
35
|
debouncedSearchText: d,
|
|
36
|
-
onSearchChange:
|
|
37
|
-
appliedFilters:
|
|
38
|
-
onFiltersChange:
|
|
36
|
+
onSearchChange: p,
|
|
37
|
+
appliedFilters: x,
|
|
38
|
+
onFiltersChange: D
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
const E = ({
|
|
42
|
+
titleKey: u,
|
|
43
|
+
descriptionKey: h,
|
|
44
|
+
confirmKey: e = "Confirmer",
|
|
45
|
+
onConfirm: g,
|
|
46
|
+
onReset: n
|
|
47
|
+
}) => {
|
|
48
|
+
const [r, s] = a(null), m = (o, i) => {
|
|
49
|
+
n == null || n(), s({ id: o, name: i });
|
|
50
|
+
}, c = () => {
|
|
51
|
+
s(null);
|
|
52
|
+
}, S = async () => {
|
|
53
|
+
if (r)
|
|
54
|
+
try {
|
|
55
|
+
await g(r.id), c();
|
|
56
|
+
} catch (o) {
|
|
57
|
+
console.error("Error deleting item:", o);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
isOpen: !!r,
|
|
62
|
+
itemName: (r == null ? void 0 : r.name) ?? null,
|
|
63
|
+
title: u,
|
|
64
|
+
description: h,
|
|
65
|
+
confirmKey: e,
|
|
66
|
+
openDialog: m,
|
|
67
|
+
onClose: c,
|
|
68
|
+
onConfirm: S
|
|
69
|
+
};
|
|
70
|
+
};
|
|
41
71
|
export {
|
|
42
|
-
|
|
72
|
+
j as toast,
|
|
73
|
+
E as useConfirmDeleteDialog,
|
|
43
74
|
I as useDataTable,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
75
|
+
v as useMobile,
|
|
76
|
+
A as useNotifications,
|
|
77
|
+
y as useServerTable,
|
|
47
78
|
G as useTheme,
|
|
48
|
-
|
|
79
|
+
q as useToast
|
|
49
80
|
};
|