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.d.mts CHANGED
@@ -29,9 +29,11 @@ export { default as Select, SelectContent, SelectItem, SelectTrigger, SelectValu
29
29
  export { default as Menu, MenuContent, MenuItem, MenuOverflow } from './Menu/index.mjs';
30
30
  export { CardActivitiesResults, CardPerformance, CardProgress, CardQuestions, CardResults, CardSimulado, CardStatus, CardTest, CardTopic } from './Card/index.mjs';
31
31
  export { Skeleton, SkeletonCard, SkeletonCircle, SkeletonList, SkeletonRectangle, SkeletonRounded, SkeletonTable, SkeletonText } from './Skeleton/index.mjs';
32
+ export { default as NotFound } from './NotFound/index.mjs';
32
33
  export { AuthProvider, ProtectedRoute, PublicRoute, getRootDomain, useAuth, useAuthGuard, useRouteAuth, withAuth } from './Auth/index.mjs';
33
34
  export { createZustandAuthAdapter } from './Auth/zustandAuthAdapter/index.mjs';
34
35
  export { useUrlAuthentication } from './Auth/useUrlAuthentication/index.mjs';
36
+ export { useApiConfig } from './Auth/useApiConfig/index.mjs';
35
37
  import 'react/jsx-runtime';
36
38
  import 'react';
37
39
  import 'zustand';
package/dist/index.d.ts CHANGED
@@ -29,9 +29,11 @@ export { default as Select, SelectContent, SelectItem, SelectTrigger, SelectValu
29
29
  export { default as Menu, MenuContent, MenuItem, MenuOverflow } from './Menu/index.js';
30
30
  export { CardActivitiesResults, CardPerformance, CardProgress, CardQuestions, CardResults, CardSimulado, CardStatus, CardTest, CardTopic } from './Card/index.js';
31
31
  export { Skeleton, SkeletonCard, SkeletonCircle, SkeletonList, SkeletonRectangle, SkeletonRounded, SkeletonTable, SkeletonText } from './Skeleton/index.js';
32
+ export { default as NotFound } from './NotFound/index.js';
32
33
  export { AuthProvider, ProtectedRoute, PublicRoute, getRootDomain, useAuth, useAuthGuard, useRouteAuth, withAuth } from './Auth/index.js';
33
34
  export { createZustandAuthAdapter } from './Auth/zustandAuthAdapter/index.js';
34
35
  export { useUrlAuthentication } from './Auth/useUrlAuthentication/index.js';
36
+ export { useApiConfig } from './Auth/useApiConfig/index.js';
35
37
  import 'react/jsx-runtime';
36
38
  import 'react';
37
39
  import 'zustand';
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ __export(src_exports, {
55
55
  MenuOverflow: () => MenuOverflow,
56
56
  Modal: () => Modal_default,
57
57
  NavButton: () => NavButton_default,
58
+ NotFound: () => NotFound_default,
58
59
  ProfileMenuFooter: () => ProfileMenuFooter,
59
60
  ProfileMenuHeader: () => ProfileMenuHeader,
60
61
  ProfileMenuSection: () => ProfileMenuSection,
@@ -88,6 +89,7 @@ __export(src_exports, {
88
89
  Toaster: () => Toaster_default,
89
90
  createZustandAuthAdapter: () => createZustandAuthAdapter,
90
91
  getRootDomain: () => getRootDomain,
92
+ useApiConfig: () => useApiConfig,
91
93
  useAuth: () => useAuth,
92
94
  useAuthGuard: () => useAuthGuard,
93
95
  useRouteAuth: () => useRouteAuth,
@@ -5775,10 +5777,108 @@ var SkeletonTable = (0, import_react18.forwardRef)(
5775
5777
  }
5776
5778
  );
5777
5779
 
5780
+ // src/components/NotFound/NotFound.tsx
5781
+ var import_jsx_runtime31 = require("react/jsx-runtime");
5782
+ var NotFound = ({
5783
+ title,
5784
+ description,
5785
+ buttonText = "Voltar",
5786
+ onButtonClick,
5787
+ className = "",
5788
+ errorType = "404",
5789
+ customErrorCode
5790
+ }) => {
5791
+ const getErrorCode = () => {
5792
+ if (errorType === "custom") {
5793
+ return customErrorCode?.trim() || "ERROR";
5794
+ }
5795
+ return errorType;
5796
+ };
5797
+ const getDefaultTitle = () => {
5798
+ switch (errorType) {
5799
+ case "404":
5800
+ return "P\xE1gina n\xE3o encontrada";
5801
+ case "500":
5802
+ return "Erro interno do servidor";
5803
+ default:
5804
+ return "Erro";
5805
+ }
5806
+ };
5807
+ const getDefaultDescription = () => {
5808
+ switch (errorType) {
5809
+ case "404":
5810
+ return "Oops! A p\xE1gina que voc\xEA est\xE1 procurando n\xE3o existe ou foi removida.";
5811
+ case "500":
5812
+ return "Algo deu errado em nossos servidores. Tente novamente mais tarde.";
5813
+ default:
5814
+ return "Ocorreu um erro inesperado.";
5815
+ }
5816
+ };
5817
+ const handleButtonClick = (event) => {
5818
+ event.preventDefault();
5819
+ onButtonClick?.();
5820
+ };
5821
+ const errorTitle = title || getDefaultTitle();
5822
+ const errorDescription = description || getDefaultDescription();
5823
+ const errorCode = getErrorCode();
5824
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5825
+ "div",
5826
+ {
5827
+ className: `flex flex-col w-full h-screen items-center justify-center bg-background-50 px-4 ${className}`,
5828
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5829
+ "main",
5830
+ {
5831
+ role: "main",
5832
+ "aria-labelledby": "error-title",
5833
+ "aria-describedby": "error-description",
5834
+ className: "flex flex-col items-center text-center max-w-md space-y-6",
5835
+ children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("section", { "aria-label": `Erro ${errorCode}`, children: [
5836
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5837
+ "div",
5838
+ {
5839
+ className: "text-8xl font-bold text-primary-300 select-none",
5840
+ "aria-label": `C\xF3digo de erro: ${errorCode}`,
5841
+ children: errorCode
5842
+ }
5843
+ ),
5844
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("header", { className: "space-y-2", children: [
5845
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5846
+ Text_default,
5847
+ {
5848
+ size: "xl",
5849
+ weight: "bold",
5850
+ className: "text-text-950",
5851
+ id: "error-title",
5852
+ "aria-level": 1,
5853
+ children: errorTitle
5854
+ }
5855
+ ),
5856
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Text_default, { size: "md", className: "text-text-600", id: "error-description", children: errorDescription })
5857
+ ] }),
5858
+ onButtonClick && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("nav", { "aria-label": "Navega\xE7\xE3o de erro", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
5859
+ Button_default,
5860
+ {
5861
+ onClick: handleButtonClick,
5862
+ variant: "solid",
5863
+ size: "medium",
5864
+ className: "mt-8",
5865
+ "aria-describedby": "error-description",
5866
+ "aria-label": `${buttonText}. ${errorDescription}`,
5867
+ children: buttonText
5868
+ }
5869
+ ) })
5870
+ ] })
5871
+ }
5872
+ )
5873
+ }
5874
+ );
5875
+ };
5876
+ var NotFound_default = NotFound;
5877
+
5778
5878
  // src/components/Auth/Auth.tsx
5779
5879
  var import_react19 = require("react");
5780
5880
  var import_react_router_dom = require("react-router-dom");
5781
- var import_jsx_runtime31 = require("react/jsx-runtime");
5881
+ var import_jsx_runtime32 = require("react/jsx-runtime");
5782
5882
  var AuthContext = (0, import_react19.createContext)(void 0);
5783
5883
  var AuthProvider = ({
5784
5884
  children,
@@ -5848,7 +5948,7 @@ var AuthProvider = ({
5848
5948
  }),
5849
5949
  [authState, checkAuth, signOut]
5850
5950
  );
5851
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(AuthContext.Provider, { value: contextValue, children });
5951
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(AuthContext.Provider, { value: contextValue, children });
5852
5952
  };
5853
5953
  var useAuth = () => {
5854
5954
  const context = (0, import_react19.useContext)(AuthContext);
@@ -5864,9 +5964,9 @@ var ProtectedRoute = ({
5864
5964
  additionalCheck
5865
5965
  }) => {
5866
5966
  const { isAuthenticated, isLoading, ...authState } = useAuth();
5867
- const defaultLoadingComponent = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5967
+ const defaultLoadingComponent = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5868
5968
  if (isLoading) {
5869
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: loadingComponent || defaultLoadingComponent });
5969
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: loadingComponent || defaultLoadingComponent });
5870
5970
  }
5871
5971
  if (!isAuthenticated) {
5872
5972
  if (typeof window !== "undefined") {
@@ -5877,12 +5977,12 @@ var ProtectedRoute = ({
5877
5977
  return null;
5878
5978
  }
5879
5979
  }
5880
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
5980
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
5881
5981
  }
5882
5982
  if (additionalCheck && !additionalCheck({ isAuthenticated, isLoading, ...authState })) {
5883
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
5983
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
5884
5984
  }
5885
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
5985
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
5886
5986
  };
5887
5987
  var PublicRoute = ({
5888
5988
  children,
@@ -5892,15 +5992,15 @@ var PublicRoute = ({
5892
5992
  }) => {
5893
5993
  const { isAuthenticated, isLoading } = useAuth();
5894
5994
  if (checkAuthBeforeRender && isLoading) {
5895
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5995
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "text-text-950 text-lg", children: "Carregando..." }) });
5896
5996
  }
5897
5997
  if (isAuthenticated && redirectIfAuthenticated) {
5898
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
5998
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
5899
5999
  }
5900
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children });
6000
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
5901
6001
  };
5902
6002
  var withAuth = (Component, options = {}) => {
5903
- return (props) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ProtectedRoute, { ...options, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Component, { ...props }) });
6003
+ return (props) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ProtectedRoute, { ...options, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Component, { ...props }) });
5904
6004
  };
5905
6005
  var useAuthGuard = (options = {}) => {
5906
6006
  const authState = useAuth();
@@ -5915,7 +6015,7 @@ var useAuthGuard = (options = {}) => {
5915
6015
  var useRouteAuth = (fallbackPath = "/") => {
5916
6016
  const { isAuthenticated, isLoading } = useAuth();
5917
6017
  const location = (0, import_react_router_dom.useLocation)();
5918
- const redirectToLogin = () => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_react_router_dom.Navigate, { to: fallbackPath, state: { from: location }, replace: true });
6018
+ const redirectToLogin = () => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: fallbackPath, state: { from: location }, replace: true });
5919
6019
  return {
5920
6020
  isAuthenticated,
5921
6021
  isLoading,
@@ -6043,6 +6143,17 @@ function useUrlAuthentication(options) {
6043
6143
  options.clearParamsFromURL
6044
6144
  ]);
6045
6145
  }
6146
+
6147
+ // src/components/Auth/useApiConfig.ts
6148
+ var import_react21 = require("react");
6149
+ function useApiConfig(api) {
6150
+ return (0, import_react21.useMemo)(
6151
+ () => ({
6152
+ get: (endpoint, config) => api.get(endpoint, config)
6153
+ }),
6154
+ [api]
6155
+ );
6156
+ }
6046
6157
  // Annotate the CommonJS export names for ESM import in node:
6047
6158
  0 && (module.exports = {
6048
6159
  Alert,
@@ -6080,6 +6191,7 @@ function useUrlAuthentication(options) {
6080
6191
  MenuOverflow,
6081
6192
  Modal,
6082
6193
  NavButton,
6194
+ NotFound,
6083
6195
  ProfileMenuFooter,
6084
6196
  ProfileMenuHeader,
6085
6197
  ProfileMenuSection,
@@ -6113,6 +6225,7 @@ function useUrlAuthentication(options) {
6113
6225
  Toaster,
6114
6226
  createZustandAuthAdapter,
6115
6227
  getRootDomain,
6228
+ useApiConfig,
6116
6229
  useAuth,
6117
6230
  useAuthGuard,
6118
6231
  useRouteAuth,