analytica-frontend-lib 1.0.77 → 1.0.78

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/index.mjs CHANGED
@@ -5750,6 +5750,104 @@ var SkeletonTable = forwardRef16(
5750
5750
  }
5751
5751
  );
5752
5752
 
5753
+ // src/components/NotFound/NotFound.tsx
5754
+ import { jsx as jsx31, jsxs as jsxs26 } from "react/jsx-runtime";
5755
+ var NotFound = ({
5756
+ title,
5757
+ description,
5758
+ buttonText = "Voltar",
5759
+ onButtonClick,
5760
+ className = "",
5761
+ errorType = "404",
5762
+ customErrorCode
5763
+ }) => {
5764
+ const getErrorCode = () => {
5765
+ if (errorType === "custom") {
5766
+ return customErrorCode?.trim() || "ERROR";
5767
+ }
5768
+ return errorType;
5769
+ };
5770
+ const getDefaultTitle = () => {
5771
+ switch (errorType) {
5772
+ case "404":
5773
+ return "P\xE1gina n\xE3o encontrada";
5774
+ case "500":
5775
+ return "Erro interno do servidor";
5776
+ default:
5777
+ return "Erro";
5778
+ }
5779
+ };
5780
+ const getDefaultDescription = () => {
5781
+ switch (errorType) {
5782
+ case "404":
5783
+ return "Oops! A p\xE1gina que voc\xEA est\xE1 procurando n\xE3o existe ou foi removida.";
5784
+ case "500":
5785
+ return "Algo deu errado em nossos servidores. Tente novamente mais tarde.";
5786
+ default:
5787
+ return "Ocorreu um erro inesperado.";
5788
+ }
5789
+ };
5790
+ const handleButtonClick = (event) => {
5791
+ event.preventDefault();
5792
+ onButtonClick?.();
5793
+ };
5794
+ const errorTitle = title || getDefaultTitle();
5795
+ const errorDescription = description || getDefaultDescription();
5796
+ const errorCode = getErrorCode();
5797
+ return /* @__PURE__ */ jsx31(
5798
+ "div",
5799
+ {
5800
+ className: `flex flex-col w-full h-screen items-center justify-center bg-background-50 px-4 ${className}`,
5801
+ children: /* @__PURE__ */ jsx31(
5802
+ "main",
5803
+ {
5804
+ role: "main",
5805
+ "aria-labelledby": "error-title",
5806
+ "aria-describedby": "error-description",
5807
+ className: "flex flex-col items-center text-center max-w-md space-y-6",
5808
+ children: /* @__PURE__ */ jsxs26("section", { "aria-label": `Erro ${errorCode}`, children: [
5809
+ /* @__PURE__ */ jsx31(
5810
+ "div",
5811
+ {
5812
+ className: "text-8xl font-bold text-primary-300 select-none",
5813
+ "aria-label": `C\xF3digo de erro: ${errorCode}`,
5814
+ children: errorCode
5815
+ }
5816
+ ),
5817
+ /* @__PURE__ */ jsxs26("header", { className: "space-y-2", children: [
5818
+ /* @__PURE__ */ jsx31(
5819
+ Text_default,
5820
+ {
5821
+ size: "xl",
5822
+ weight: "bold",
5823
+ className: "text-text-950",
5824
+ id: "error-title",
5825
+ "aria-level": 1,
5826
+ children: errorTitle
5827
+ }
5828
+ ),
5829
+ /* @__PURE__ */ jsx31(Text_default, { size: "md", className: "text-text-600", id: "error-description", children: errorDescription })
5830
+ ] }),
5831
+ onButtonClick && /* @__PURE__ */ jsx31("nav", { "aria-label": "Navega\xE7\xE3o de erro", children: /* @__PURE__ */ jsx31(
5832
+ Button_default,
5833
+ {
5834
+ onClick: handleButtonClick,
5835
+ variant: "solid",
5836
+ size: "medium",
5837
+ className: "mt-8",
5838
+ "aria-describedby": "error-description",
5839
+ "aria-label": `${buttonText}. ${errorDescription}`,
5840
+ children: buttonText
5841
+ }
5842
+ ) })
5843
+ ] })
5844
+ }
5845
+ )
5846
+ }
5847
+ );
5848
+ };
5849
+ var NotFound_default = NotFound;
5850
+
5753
5851
  // src/components/Auth/Auth.tsx
5754
5852
  import {
5755
5853
  createContext,
@@ -5760,7 +5858,7 @@ import {
5760
5858
  useMemo as useMemo3
5761
5859
  } from "react";
5762
5860
  import { useLocation, Navigate } from "react-router-dom";
5763
- import { Fragment as Fragment7, jsx as jsx31 } from "react/jsx-runtime";
5861
+ import { Fragment as Fragment7, jsx as jsx32 } from "react/jsx-runtime";
5764
5862
  var AuthContext = createContext(void 0);
5765
5863
  var AuthProvider = ({
5766
5864
  children,
@@ -5830,7 +5928,7 @@ var AuthProvider = ({
5830
5928
  }),
5831
5929
  [authState, checkAuth, signOut]
5832
5930
  );
5833
- return /* @__PURE__ */ jsx31(AuthContext.Provider, { value: contextValue, children });
5931
+ return /* @__PURE__ */ jsx32(AuthContext.Provider, { value: contextValue, children });
5834
5932
  };
5835
5933
  var useAuth = () => {
5836
5934
  const context = useContext(AuthContext);
@@ -5846,9 +5944,9 @@ var ProtectedRoute = ({
5846
5944
  additionalCheck
5847
5945
  }) => {
5848
5946
  const { isAuthenticated, isLoading, ...authState } = useAuth();
5849
- const defaultLoadingComponent = /* @__PURE__ */ jsx31("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsx31("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5947
+ const defaultLoadingComponent = /* @__PURE__ */ jsx32("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsx32("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5850
5948
  if (isLoading) {
5851
- return /* @__PURE__ */ jsx31(Fragment7, { children: loadingComponent || defaultLoadingComponent });
5949
+ return /* @__PURE__ */ jsx32(Fragment7, { children: loadingComponent || defaultLoadingComponent });
5852
5950
  }
5853
5951
  if (!isAuthenticated) {
5854
5952
  if (typeof window !== "undefined") {
@@ -5859,12 +5957,12 @@ var ProtectedRoute = ({
5859
5957
  return null;
5860
5958
  }
5861
5959
  }
5862
- return /* @__PURE__ */ jsx31(Navigate, { to: redirectTo, replace: true });
5960
+ return /* @__PURE__ */ jsx32(Navigate, { to: redirectTo, replace: true });
5863
5961
  }
5864
5962
  if (additionalCheck && !additionalCheck({ isAuthenticated, isLoading, ...authState })) {
5865
- return /* @__PURE__ */ jsx31(Navigate, { to: redirectTo, replace: true });
5963
+ return /* @__PURE__ */ jsx32(Navigate, { to: redirectTo, replace: true });
5866
5964
  }
5867
- return /* @__PURE__ */ jsx31(Fragment7, { children });
5965
+ return /* @__PURE__ */ jsx32(Fragment7, { children });
5868
5966
  };
5869
5967
  var PublicRoute = ({
5870
5968
  children,
@@ -5874,15 +5972,15 @@ var PublicRoute = ({
5874
5972
  }) => {
5875
5973
  const { isAuthenticated, isLoading } = useAuth();
5876
5974
  if (checkAuthBeforeRender && isLoading) {
5877
- return /* @__PURE__ */ jsx31("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsx31("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5975
+ return /* @__PURE__ */ jsx32("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsx32("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5878
5976
  }
5879
5977
  if (isAuthenticated && redirectIfAuthenticated) {
5880
- return /* @__PURE__ */ jsx31(Navigate, { to: redirectTo, replace: true });
5978
+ return /* @__PURE__ */ jsx32(Navigate, { to: redirectTo, replace: true });
5881
5979
  }
5882
- return /* @__PURE__ */ jsx31(Fragment7, { children });
5980
+ return /* @__PURE__ */ jsx32(Fragment7, { children });
5883
5981
  };
5884
5982
  var withAuth = (Component, options = {}) => {
5885
- return (props) => /* @__PURE__ */ jsx31(ProtectedRoute, { ...options, children: /* @__PURE__ */ jsx31(Component, { ...props }) });
5983
+ return (props) => /* @__PURE__ */ jsx32(ProtectedRoute, { ...options, children: /* @__PURE__ */ jsx32(Component, { ...props }) });
5886
5984
  };
5887
5985
  var useAuthGuard = (options = {}) => {
5888
5986
  const authState = useAuth();
@@ -5897,7 +5995,7 @@ var useAuthGuard = (options = {}) => {
5897
5995
  var useRouteAuth = (fallbackPath = "/") => {
5898
5996
  const { isAuthenticated, isLoading } = useAuth();
5899
5997
  const location = useLocation();
5900
- const redirectToLogin = () => /* @__PURE__ */ jsx31(Navigate, { to: fallbackPath, state: { from: location }, replace: true });
5998
+ const redirectToLogin = () => /* @__PURE__ */ jsx32(Navigate, { to: fallbackPath, state: { from: location }, replace: true });
5901
5999
  return {
5902
6000
  isAuthenticated,
5903
6001
  isLoading,
@@ -6025,6 +6123,17 @@ function useUrlAuthentication(options) {
6025
6123
  options.clearParamsFromURL
6026
6124
  ]);
6027
6125
  }
6126
+
6127
+ // src/components/Auth/useApiConfig.ts
6128
+ import { useMemo as useMemo4 } from "react";
6129
+ function useApiConfig(api) {
6130
+ return useMemo4(
6131
+ () => ({
6132
+ get: (endpoint, config) => api.get(endpoint, config)
6133
+ }),
6134
+ [api]
6135
+ );
6136
+ }
6028
6137
  export {
6029
6138
  Alert_default as Alert,
6030
6139
  AlertDialog,
@@ -6061,6 +6170,7 @@ export {
6061
6170
  MenuOverflow,
6062
6171
  Modal_default as Modal,
6063
6172
  NavButton_default as NavButton,
6173
+ NotFound_default as NotFound,
6064
6174
  ProfileMenuFooter,
6065
6175
  ProfileMenuHeader,
6066
6176
  ProfileMenuSection,
@@ -6094,6 +6204,7 @@ export {
6094
6204
  Toaster_default as Toaster,
6095
6205
  createZustandAuthAdapter,
6096
6206
  getRootDomain,
6207
+ useApiConfig,
6097
6208
  useAuth,
6098
6209
  useAuthGuard,
6099
6210
  useRouteAuth,