@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"}
@@ -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"}
@@ -1,49 +1,80 @@
1
- import { u as E } from "../useMobile-DN1_OMDB.js";
2
- import { u as j } from "../useNotifications-zbUhCvF_.js";
3
- import { t as w, u as y } from "../useToast-BFTk4lWz.js";
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 r } from "react";
7
- function k(s, c = "nom", t = {}) {
8
- const [i, n] = a(t.initialPage ?? 1), [u, l] = a(t.initialPageSize ?? 10), [h, S] = a(c), [g, m] = a(t.initialSortDirection ?? "asc"), [o, C] = a(t.initialSearchText ?? ""), [d, x] = a(t.initialSearchText ?? ""), [T, f] = a(s);
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 e = setTimeout(() => {
11
- x(o);
12
- }, t.debounceMs ?? 300);
10
+ const t = setTimeout(() => {
11
+ f(i);
12
+ }, e.debounceMs ?? 300);
13
13
  return () => {
14
- clearTimeout(e);
14
+ clearTimeout(t);
15
15
  };
16
- }, [o, t.debounceMs]);
17
- const b = r((e) => {
18
- C(e), n(1);
19
- }, []), P = r((e) => {
20
- f(e), n(1);
21
- }, []), p = r((e, D) => {
22
- S(e), m(D);
23
- }, []), z = r((e) => {
24
- l(e), n(1);
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: i,
27
+ currentPage: g,
28
28
  onPageChange: n,
29
- pageSize: u,
30
- onPageSizeChange: z,
31
- sortColumn: h,
32
- sortDirection: g,
33
- onSortChange: p,
34
- searchText: o,
29
+ pageSize: r,
30
+ onPageSizeChange: P,
31
+ sortColumn: m,
32
+ sortDirection: S,
33
+ onSortChange: b,
34
+ searchText: i,
35
35
  debouncedSearchText: d,
36
- onSearchChange: b,
37
- appliedFilters: T,
38
- onFiltersChange: P
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
- w as toast,
72
+ j as toast,
73
+ E as useConfirmDeleteDialog,
43
74
  I as useDataTable,
44
- E as useMobile,
45
- j as useNotifications,
46
- k as useServerTable,
75
+ v as useMobile,
76
+ A as useNotifications,
77
+ y as useServerTable,
47
78
  G as useTheme,
48
- y as useToast
79
+ q as useToast
49
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krosoft/react",
3
- "version": "0.0.106",
3
+ "version": "0.0.107",
4
4
  "description": "Krosoft shared React package",
5
5
  "type": "module",
6
6
  "scripts": {