@sigtes/ui 0.2.2 → 0.2.4
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.cjs.js +771 -729
- package/dist/components.es.js +20326 -19630
- package/dist/hooks/useQuery/useQuery.d.ts +1 -1
- package/dist/hooks.cjs.js +1 -1
- package/dist/hooks.es.js +23 -23
- package/package.json +1 -1
|
@@ -6,4 +6,4 @@ export interface QueryHookType<SchemaType, CreateType, UpdateType, DeleteType> {
|
|
|
6
6
|
getById: UseQueryResult<SchemaType>;
|
|
7
7
|
getAll: UseQueryResult<SchemaType[]>;
|
|
8
8
|
}
|
|
9
|
-
export type QueryHookProps<T = object> = {} & T
|
|
9
|
+
export type QueryHookProps<T = object> = {} & Partial<T>;
|
package/dist/hooks.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),r=require("sonner"),m=require("react-hook-form"),p=require("./UserProvider-Sov75KqP.cjs");require("@tanstack/react-query");function c(t){if(typeof t!="object"||t===null)return!1;const e=t;return"name"in e&&typeof e.name=="string"&&"message"in e&&typeof e.message=="string"&&"action"in e&&typeof e.action=="string"&&"statusCode"in e&&typeof e.statusCode=="number"}function g(t,e){if(c(e)){r.toast.error(e.message);return}if(e){r.toast.success(t.message);return}r.toast.error(t.errorMessage)}function b(t){c(t)?r.toast.error("Falha na solicitação.",{description:`${t.name} | ${t.message}`}):r.toast.error("Erro desconhecido.")}const E={handleApiReponse:g,handleApiError:b};function h(t){const[e,s]=i.useState(!1),[o,n]=i.useState(!1),[f,a]=i.useState(t);function u(l){const d={create:()=>{s(!0),n(!1)},edit:()=>{s(!0),n(!0)}}[l];d()}return{open:u,setData:a,currentState:{data:f,isEditMode:o,isVisible:e,setIsVisible:s},controls:{onCreate:()=>u("create"),onUpdate:()=>u("edit"),setData:a}}}const y="/forbidden";function S(t,e,s=""){const{user:o,isLoading:n}=p.useUser();i.useEffect(()=>{e&&o.id===""&&!n&&e.push("/login"),e&&o.id!==""&&!n&&(o.features.includes(t)?e.push(s):e.push(y))},[e,o,n,t,s])}Object.defineProperty(exports,"useForm",{enumerable:!0,get:()=>m.useForm});exports.useAuthorization=S;exports.useErrors=E;exports.useFormState=h;
|
package/dist/hooks.es.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import { useState as c, useEffect as
|
|
2
|
-
import { toast as
|
|
1
|
+
import { useState as c, useEffect as l } from "react";
|
|
2
|
+
import { toast as i } from "sonner";
|
|
3
3
|
import { useForm as U } from "react-hook-form";
|
|
4
|
-
import { u as
|
|
4
|
+
import { u as d } from "./UserProvider-ultyW1kJ.js";
|
|
5
5
|
import "@tanstack/react-query";
|
|
6
|
-
function
|
|
6
|
+
function a(s) {
|
|
7
7
|
if (typeof s != "object" || s === null)
|
|
8
8
|
return !1;
|
|
9
9
|
const e = s;
|
|
10
|
-
return "name" in e && typeof e.name == "
|
|
10
|
+
return "name" in e && typeof e.name == "string" && "message" in e && typeof e.message == "string" && "action" in e && typeof e.action == "string" && "statusCode" in e && typeof e.statusCode == "number";
|
|
11
11
|
}
|
|
12
12
|
function g(s, e) {
|
|
13
|
-
if (
|
|
14
|
-
|
|
13
|
+
if (a(e)) {
|
|
14
|
+
i.error(e.message);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
if (e
|
|
18
|
-
|
|
17
|
+
if (e) {
|
|
18
|
+
i.success(s.message);
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
i.error(s.errorMessage);
|
|
22
22
|
}
|
|
23
23
|
function E(s) {
|
|
24
|
-
s
|
|
24
|
+
a(s) ? i.error("Falha na solicitação.", {
|
|
25
25
|
description: `${s.name} | ${s.message}`
|
|
26
|
-
}) :
|
|
26
|
+
}) : i.error("Erro desconhecido.");
|
|
27
27
|
}
|
|
28
28
|
const A = {
|
|
29
29
|
handleApiReponse: g,
|
|
30
30
|
handleApiError: E
|
|
31
31
|
};
|
|
32
32
|
function D(s) {
|
|
33
|
-
const [e, t] = c(!1), [n, o] = c(!1), [
|
|
34
|
-
function
|
|
35
|
-
const
|
|
33
|
+
const [e, t] = c(!1), [n, o] = c(!1), [f, u] = c(s);
|
|
34
|
+
function r(m) {
|
|
35
|
+
const p = {
|
|
36
36
|
create: () => {
|
|
37
37
|
t(!0), o(!1);
|
|
38
38
|
},
|
|
39
39
|
edit: () => {
|
|
40
40
|
t(!0), o(!0);
|
|
41
41
|
}
|
|
42
|
-
}[
|
|
43
|
-
|
|
42
|
+
}[m];
|
|
43
|
+
p();
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
46
|
-
open:
|
|
46
|
+
open: r,
|
|
47
47
|
setData: u,
|
|
48
48
|
currentState: {
|
|
49
|
-
data:
|
|
49
|
+
data: f,
|
|
50
50
|
isEditMode: n,
|
|
51
51
|
isVisible: e,
|
|
52
52
|
setIsVisible: t
|
|
53
53
|
},
|
|
54
54
|
controls: {
|
|
55
|
-
onCreate: () =>
|
|
56
|
-
onUpdate: () =>
|
|
55
|
+
onCreate: () => r("create"),
|
|
56
|
+
onUpdate: () => r("edit"),
|
|
57
57
|
setData: u
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
const h = "/forbidden";
|
|
62
62
|
function M(s, e, t = "") {
|
|
63
|
-
const { user: n, isLoading: o } =
|
|
64
|
-
|
|
63
|
+
const { user: n, isLoading: o } = d();
|
|
64
|
+
l(() => {
|
|
65
65
|
e && n.id === "" && !o && e.push("/login"), e && n.id !== "" && !o && (n.features.includes(s) ? e.push(t) : e.push(h));
|
|
66
66
|
}, [e, n, o, s, t]);
|
|
67
67
|
}
|