@sigtes/ui 0.0.18 → 0.0.19

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.
@@ -3,3 +3,4 @@ export { useFormState } from './useFormState';
3
3
  export { type FormStateProps } from './useFormState';
4
4
  export { useForm } from 'react-hook-form';
5
5
  export { useAuthorization } from './useAuthorization';
6
+ export { type QueryHookProps, type QueryHookType } from './useQuery';
@@ -0,0 +1 @@
1
+ export * from './useQuery';
@@ -0,0 +1,13 @@
1
+ import { UseMutationResult, UseQueryResult } from '@tanstack/react-query';
2
+ export interface QueryHookType<SchemaType, CreateType, UpdateType> {
3
+ updateMutation: UseMutationResult<SchemaType, Error, UpdateType>;
4
+ deleteMutation: UseMutationResult<SchemaType, Error, {
5
+ id: string;
6
+ }>;
7
+ createMutation: UseMutationResult<SchemaType, Error, CreateType>;
8
+ getById: UseQueryResult<SchemaType>;
9
+ getAll: UseQueryResult<SchemaType[]>;
10
+ }
11
+ export type QueryHookProps<T = object> = {
12
+ id?: string;
13
+ } & T;
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"),l=require("react-hook-form"),m=require("./UserProvider-Sov75KqP.cjs");function p(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 g(e){e instanceof Error?n.toast.error("Falha na solicitação.",{description:`${e.name} | ${e.message}`}):n.toast.error("Erro desconhecido.")}const E={handleApiReponse:p,handleApiError:g};function h(e){const[s,t]=i.useState(!1),[o,r]=i.useState(!1),[u,c]=i.useState(e||{});function a(d){const f={create:()=>{t(!0),r(!1)},edit:()=>{t(!0),r(!0)}}[d];f()}return{open:a,setDataToUpdate:c,currentState:{dataToUpdate:u,isEditMode:o,initialData:e||{},isVisible:s,setIsVisible:t},controls:{onCreate:()=>a("create"),onUpdate:()=>a("edit"),setDataToUpdate:c}}}const S="/forbidden";function b(e,s,t=""){const{user:o,isLoading:r}=m.useUser();i.useEffect(()=>{s&&o.id===""&&!r&&s.push("/login"),s&&o.id!==""&&!r&&(o.features.includes(e)?s.push(t):s.push(S))},[s,o,r,e,t])}Object.defineProperty(exports,"useForm",{enumerable:!0,get:()=>l.useForm});exports.useAuthorization=b;exports.useErrors=E;exports.useFormState=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),n=require("sonner"),l=require("react-hook-form"),m=require("./UserProvider-Sov75KqP.cjs");require("@tanstack/react-query");function p(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 g(e){e instanceof Error?n.toast.error("Falha na solicitação.",{description:`${e.name} | ${e.message}`}):n.toast.error("Erro desconhecido.")}const E={handleApiReponse:p,handleApiError:g};function h(e){const[s,t]=i.useState(!1),[o,r]=i.useState(!1),[c,u]=i.useState(e||{});function a(d){const f={create:()=>{t(!0),r(!1)},edit:()=>{t(!0),r(!0)}}[d];f()}return{open:a,setDataToUpdate:u,currentState:{dataToUpdate:c,isEditMode:o,initialData:e||{},isVisible:s,setIsVisible:t},controls:{onCreate:()=>a("create"),onUpdate:()=>a("edit"),setDataToUpdate:u}}}const S="/forbidden";function b(e,s,t=""){const{user:o,isLoading:r}=m.useUser();i.useEffect(()=>{s&&o.id===""&&!r&&s.push("/login"),s&&o.id!==""&&!r&&(o.features.includes(e)?s.push(t):s.push(S))},[s,o,r,e,t])}Object.defineProperty(exports,"useForm",{enumerable:!0,get:()=>l.useForm});exports.useAuthorization=b;exports.useErrors=E;exports.useFormState=h;
package/dist/hooks.es.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { useState as c, useEffect as l } from "react";
2
2
  import { toast as r } from "sonner";
3
- import { useForm as R } from "react-hook-form";
3
+ import { useForm as x } from "react-hook-form";
4
4
  import { u as p } from "./UserProvider-ultyW1kJ.js";
5
+ import "@tanstack/react-query";
5
6
  function m(e, s) {
6
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);
7
8
  }
@@ -10,11 +11,11 @@ function E(e) {
10
11
  description: `${e.name} | ${e.message}`
11
12
  }) : r.error("Erro desconhecido.");
12
13
  }
13
- const S = {
14
+ const A = {
14
15
  handleApiReponse: m,
15
16
  handleApiError: E
16
17
  };
17
- function A(e) {
18
+ function D(e) {
18
19
  const [s, t] = c(!1), [o, n] = c(!1), [u, a] = c(
19
20
  e || {}
20
21
  );
@@ -47,15 +48,15 @@ function A(e) {
47
48
  };
48
49
  }
49
50
  const h = "/forbidden";
50
- function D(e, s, t = "") {
51
+ function I(e, s, t = "") {
51
52
  const { user: o, isLoading: n } = p();
52
53
  l(() => {
53
54
  s && o.id === "" && !n && s.push("/login"), s && o.id !== "" && !n && (o.features.includes(e) ? s.push(t) : s.push(h));
54
55
  }, [s, o, n, e, t]);
55
56
  }
56
57
  export {
57
- D as useAuthorization,
58
- S as useErrors,
59
- R as useForm,
60
- A as useFormState
58
+ I as useAuthorization,
59
+ A as useErrors,
60
+ x as useForm,
61
+ D as useFormState
61
62
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigtes/ui",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -66,7 +66,9 @@
66
66
  "react-hook-form": "^7.63.0",
67
67
  "recharts": "^2.15.4",
68
68
  "sonner": "^2.0.7",
69
- "tailwind-merge": "^3.3.1"
69
+ "tailwind-merge": "^3.3.1",
70
+ "@radix-ui/react-dialog": "^1.1.15",
71
+ "@tanstack/react-query": "^5.90.2"
70
72
  },
71
73
  "devDependencies": {
72
74
  "@chromatic-com/storybook": "^4.1.1",
@@ -96,8 +98,5 @@
96
98
  "vite": "^7.1.7",
97
99
  "vite-plugin-dts": "^4.5.4",
98
100
  "vitest": "^3.2.4"
99
- },
100
- "dependencies": {
101
- "@radix-ui/react-dialog": "^1.1.15"
102
101
  }
103
102
  }