@sigtes/ui 0.1.0 → 0.2.0
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/components/table/DataTable.d.ts +1 -7
- package/dist/components.cjs.js +863 -800
- package/dist/components.es.js +36896 -35852
- package/dist/hooks/useFormState/useFormState.d.ts +6 -7
- package/dist/hooks.cjs.js +1 -1
- package/dist/hooks.es.js +18 -21
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
type OpenMode = "create" | "edit";
|
|
2
|
-
export interface FormStateProps<
|
|
3
|
-
|
|
4
|
-
initialData: Partial<T>;
|
|
2
|
+
export interface FormStateProps<TKeys, TData> {
|
|
3
|
+
data: TKeys & Partial<TData>;
|
|
5
4
|
isVisible: boolean;
|
|
6
5
|
isEditMode: boolean;
|
|
7
6
|
setIsVisible: (value: boolean) => void;
|
|
8
7
|
}
|
|
9
|
-
export declare function useFormState<
|
|
8
|
+
export declare function useFormState<TKeys, TData>(initialData: TKeys & Partial<TData>): {
|
|
10
9
|
open: (mode: OpenMode) => void;
|
|
11
|
-
|
|
12
|
-
currentState: FormStateProps<
|
|
10
|
+
setData: import('react').Dispatch<import('react').SetStateAction<TKeys & Partial<TData>>>;
|
|
11
|
+
currentState: FormStateProps<TKeys, TData>;
|
|
13
12
|
controls: {
|
|
14
13
|
onCreate: () => void;
|
|
15
14
|
onUpdate: () => void;
|
|
16
|
-
|
|
15
|
+
setData: import('react').Dispatch<import('react').SetStateAction<TKeys & Partial<TData>>>;
|
|
17
16
|
};
|
|
18
17
|
};
|
|
19
18
|
export {};
|
package/dist/hooks.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),n=require("sonner"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),n=require("sonner"),d=require("react-hook-form"),m=require("./UserProvider-Sov75KqP.cjs");require("@tanstack/react-query");function g(e,s){s instanceof Object?"statusCode"in s||s===!0?n.toast.error(e.errorMessage):n.toast.success(e.message):s===!0?n.toast.success(e.message):n.toast.error(e.errorMessage)}function E(e){e instanceof Error?n.toast.error("Falha na solicitação.",{description:`${e.name} | ${e.message}`}):n.toast.error("Erro desconhecido.")}const h={handleApiReponse:g,handleApiError:E};function p(e){const[s,t]=i.useState(!1),[r,o]=i.useState(!1),[a,c]=i.useState(e);function u(f){const l={create:()=>{t(!0),o(!1)},edit:()=>{t(!0),o(!0)}}[f];l()}return{open:u,setData:c,currentState:{data:a,isEditMode:r,isVisible:s,setIsVisible:t},controls:{onCreate:()=>u("create"),onUpdate:()=>u("edit"),setData:c}}}const S="/forbidden";function b(e,s,t=""){const{user:r,isLoading:o}=m.useUser();i.useEffect(()=>{s&&r.id===""&&!o&&s.push("/login"),s&&r.id!==""&&!o&&(r.features.includes(e)?s.push(t):s.push(S))},[s,r,o,e,t])}Object.defineProperty(exports,"useForm",{enumerable:!0,get:()=>d.useForm});exports.useAuthorization=b;exports.useErrors=h;exports.useFormState=p;
|
package/dist/hooks.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useState as c, useEffect as
|
|
1
|
+
import { useState as c, useEffect as d } from "react";
|
|
2
2
|
import { toast as r } from "sonner";
|
|
3
3
|
import { useForm as x } from "react-hook-form";
|
|
4
|
-
import { u as
|
|
4
|
+
import { u as m } from "./UserProvider-ultyW1kJ.js";
|
|
5
5
|
import "@tanstack/react-query";
|
|
6
|
-
function
|
|
6
|
+
function p(e, s) {
|
|
7
7
|
s instanceof Object ? "statusCode" in s || s === !0 ? r.error(e.errorMessage) : r.success(e.message) : s === !0 ? r.success(e.message) : r.error(e.errorMessage);
|
|
8
8
|
}
|
|
9
9
|
function E(e) {
|
|
@@ -11,16 +11,14 @@ function E(e) {
|
|
|
11
11
|
description: `${e.name} | ${e.message}`
|
|
12
12
|
}) : r.error("Erro desconhecido.");
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
handleApiReponse:
|
|
14
|
+
const D = {
|
|
15
|
+
handleApiReponse: p,
|
|
16
16
|
handleApiError: E
|
|
17
17
|
};
|
|
18
|
-
function
|
|
19
|
-
const [s, t] = c(!1), [o, n] = c(!1), [u, a] = c(
|
|
20
|
-
e || {}
|
|
21
|
-
);
|
|
18
|
+
function I(e) {
|
|
19
|
+
const [s, t] = c(!1), [o, n] = c(!1), [u, a] = c(e);
|
|
22
20
|
function i(f) {
|
|
23
|
-
const
|
|
21
|
+
const l = {
|
|
24
22
|
create: () => {
|
|
25
23
|
t(!0), n(!1);
|
|
26
24
|
},
|
|
@@ -28,35 +26,34 @@ function D(e) {
|
|
|
28
26
|
t(!0), n(!0);
|
|
29
27
|
}
|
|
30
28
|
}[f];
|
|
31
|
-
|
|
29
|
+
l();
|
|
32
30
|
}
|
|
33
31
|
return {
|
|
34
32
|
open: i,
|
|
35
|
-
|
|
33
|
+
setData: a,
|
|
36
34
|
currentState: {
|
|
37
|
-
|
|
35
|
+
data: u,
|
|
38
36
|
isEditMode: o,
|
|
39
|
-
initialData: e || {},
|
|
40
37
|
isVisible: s,
|
|
41
38
|
setIsVisible: t
|
|
42
39
|
},
|
|
43
40
|
controls: {
|
|
44
41
|
onCreate: () => i("create"),
|
|
45
42
|
onUpdate: () => i("edit"),
|
|
46
|
-
|
|
43
|
+
setData: a
|
|
47
44
|
}
|
|
48
45
|
};
|
|
49
46
|
}
|
|
50
47
|
const h = "/forbidden";
|
|
51
|
-
function
|
|
52
|
-
const { user: o, isLoading: n } =
|
|
53
|
-
|
|
48
|
+
function O(e, s, t = "") {
|
|
49
|
+
const { user: o, isLoading: n } = m();
|
|
50
|
+
d(() => {
|
|
54
51
|
s && o.id === "" && !n && s.push("/login"), s && o.id !== "" && !n && (o.features.includes(e) ? s.push(t) : s.push(h));
|
|
55
52
|
}, [s, o, n, e, t]);
|
|
56
53
|
}
|
|
57
54
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
O as useAuthorization,
|
|
56
|
+
D as useErrors,
|
|
60
57
|
x as useForm,
|
|
61
|
-
|
|
58
|
+
I as useFormState
|
|
62
59
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Button, buttonVariants } from './components/button';
|
|
2
|
-
export { Table, TableBody, TableCell, TableCaption, TableFooter, TableHead, TableHeader, TableRow, DataTable, DraggableRow, DragHandle, type
|
|
2
|
+
export { Table, TableBody, TableCell, TableCaption, TableFooter, TableHead, TableHeader, TableRow, DataTable, DraggableRow, DragHandle, type DataTableProps, } from './components/table';
|
|
3
3
|
export { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, DefaultDropdownMenuTrigger, } from './components/dropdown-menu';
|
|
4
4
|
export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, } from './components/select';
|
|
5
5
|
export { Input } from './components/input';
|