analytica-frontend-lib 1.0.76 → 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/Auth/useApiConfig/index.d.mts +43 -0
- package/dist/Auth/useApiConfig/index.d.ts +43 -0
- package/dist/Auth/useApiConfig/index.js +39 -0
- package/dist/Auth/useApiConfig/index.js.map +1 -0
- package/dist/Auth/useApiConfig/index.mjs +14 -0
- package/dist/Auth/useApiConfig/index.mjs.map +1 -0
- package/dist/NotFound/index.d.mts +58 -0
- package/dist/NotFound/index.d.ts +58 -0
- package/dist/NotFound/index.js +233 -0
- package/dist/NotFound/index.js.map +1 -0
- package/dist/NotFound/index.mjs +210 -0
- package/dist/NotFound/index.mjs.map +1 -0
- package/dist/index.css +39 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +127 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -12
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +39 -0
- package/dist/styles.css.map +1 -1
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -27,11 +27,13 @@ export { AlertDialog } from './AlertDialog/index.mjs';
|
|
|
27
27
|
export { default as DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, MenuLabel, ProfileMenuFooter, ProfileMenuHeader, ProfileMenuSection, ProfileMenuTrigger } from './DropdownMenu/index.mjs';
|
|
28
28
|
export { default as Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './Select/index.mjs';
|
|
29
29
|
export { default as Menu, MenuContent, MenuItem, MenuOverflow } from './Menu/index.mjs';
|
|
30
|
-
export { CardActivitiesResults, CardPerformance, CardProgress, CardQuestions, CardResults, CardSimulado, CardStatus, CardTopic } from './Card/index.mjs';
|
|
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
|
@@ -27,11 +27,13 @@ export { AlertDialog } from './AlertDialog/index.js';
|
|
|
27
27
|
export { default as DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, MenuLabel, ProfileMenuFooter, ProfileMenuHeader, ProfileMenuSection, ProfileMenuTrigger } from './DropdownMenu/index.js';
|
|
28
28
|
export { default as Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './Select/index.js';
|
|
29
29
|
export { default as Menu, MenuContent, MenuItem, MenuOverflow } from './Menu/index.js';
|
|
30
|
-
export { CardActivitiesResults, CardPerformance, CardProgress, CardQuestions, CardResults, CardSimulado, CardStatus, CardTopic } from './Card/index.js';
|
|
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
|
@@ -35,6 +35,7 @@ __export(src_exports, {
|
|
|
35
35
|
CardResults: () => CardResults,
|
|
36
36
|
CardSimulado: () => CardSimulado,
|
|
37
37
|
CardStatus: () => CardStatus,
|
|
38
|
+
CardTest: () => CardTest,
|
|
38
39
|
CardTopic: () => CardTopic,
|
|
39
40
|
CheckBox: () => CheckBox_default,
|
|
40
41
|
Chips: () => Chips_default,
|
|
@@ -54,6 +55,7 @@ __export(src_exports, {
|
|
|
54
55
|
MenuOverflow: () => MenuOverflow,
|
|
55
56
|
Modal: () => Modal_default,
|
|
56
57
|
NavButton: () => NavButton_default,
|
|
58
|
+
NotFound: () => NotFound_default,
|
|
57
59
|
ProfileMenuFooter: () => ProfileMenuFooter,
|
|
58
60
|
ProfileMenuHeader: () => ProfileMenuHeader,
|
|
59
61
|
ProfileMenuSection: () => ProfileMenuSection,
|
|
@@ -87,6 +89,7 @@ __export(src_exports, {
|
|
|
87
89
|
Toaster: () => Toaster_default,
|
|
88
90
|
createZustandAuthAdapter: () => createZustandAuthAdapter,
|
|
89
91
|
getRootDomain: () => getRootDomain,
|
|
92
|
+
useApiConfig: () => useApiConfig,
|
|
90
93
|
useAuth: () => useAuth,
|
|
91
94
|
useAuthGuard: () => useAuthGuard,
|
|
92
95
|
useRouteAuth: () => useRouteAuth,
|
|
@@ -5774,10 +5777,108 @@ var SkeletonTable = (0, import_react18.forwardRef)(
|
|
|
5774
5777
|
}
|
|
5775
5778
|
);
|
|
5776
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
|
+
|
|
5777
5878
|
// src/components/Auth/Auth.tsx
|
|
5778
5879
|
var import_react19 = require("react");
|
|
5779
5880
|
var import_react_router_dom = require("react-router-dom");
|
|
5780
|
-
var
|
|
5881
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
5781
5882
|
var AuthContext = (0, import_react19.createContext)(void 0);
|
|
5782
5883
|
var AuthProvider = ({
|
|
5783
5884
|
children,
|
|
@@ -5847,7 +5948,7 @@ var AuthProvider = ({
|
|
|
5847
5948
|
}),
|
|
5848
5949
|
[authState, checkAuth, signOut]
|
|
5849
5950
|
);
|
|
5850
|
-
return /* @__PURE__ */ (0,
|
|
5951
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(AuthContext.Provider, { value: contextValue, children });
|
|
5851
5952
|
};
|
|
5852
5953
|
var useAuth = () => {
|
|
5853
5954
|
const context = (0, import_react19.useContext)(AuthContext);
|
|
@@ -5863,9 +5964,9 @@ var ProtectedRoute = ({
|
|
|
5863
5964
|
additionalCheck
|
|
5864
5965
|
}) => {
|
|
5865
5966
|
const { isAuthenticated, isLoading, ...authState } = useAuth();
|
|
5866
|
-
const defaultLoadingComponent = /* @__PURE__ */ (0,
|
|
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..." }) });
|
|
5867
5968
|
if (isLoading) {
|
|
5868
|
-
return /* @__PURE__ */ (0,
|
|
5969
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children: loadingComponent || defaultLoadingComponent });
|
|
5869
5970
|
}
|
|
5870
5971
|
if (!isAuthenticated) {
|
|
5871
5972
|
if (typeof window !== "undefined") {
|
|
@@ -5876,12 +5977,12 @@ var ProtectedRoute = ({
|
|
|
5876
5977
|
return null;
|
|
5877
5978
|
}
|
|
5878
5979
|
}
|
|
5879
|
-
return /* @__PURE__ */ (0,
|
|
5980
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
|
|
5880
5981
|
}
|
|
5881
5982
|
if (additionalCheck && !additionalCheck({ isAuthenticated, isLoading, ...authState })) {
|
|
5882
|
-
return /* @__PURE__ */ (0,
|
|
5983
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
|
|
5883
5984
|
}
|
|
5884
|
-
return /* @__PURE__ */ (0,
|
|
5985
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
|
|
5885
5986
|
};
|
|
5886
5987
|
var PublicRoute = ({
|
|
5887
5988
|
children,
|
|
@@ -5891,15 +5992,15 @@ var PublicRoute = ({
|
|
|
5891
5992
|
}) => {
|
|
5892
5993
|
const { isAuthenticated, isLoading } = useAuth();
|
|
5893
5994
|
if (checkAuthBeforeRender && isLoading) {
|
|
5894
|
-
return /* @__PURE__ */ (0,
|
|
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..." }) });
|
|
5895
5996
|
}
|
|
5896
5997
|
if (isAuthenticated && redirectIfAuthenticated) {
|
|
5897
|
-
return /* @__PURE__ */ (0,
|
|
5998
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: redirectTo, replace: true });
|
|
5898
5999
|
}
|
|
5899
|
-
return /* @__PURE__ */ (0,
|
|
6000
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
|
|
5900
6001
|
};
|
|
5901
6002
|
var withAuth = (Component, options = {}) => {
|
|
5902
|
-
return (props) => /* @__PURE__ */ (0,
|
|
6003
|
+
return (props) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(ProtectedRoute, { ...options, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Component, { ...props }) });
|
|
5903
6004
|
};
|
|
5904
6005
|
var useAuthGuard = (options = {}) => {
|
|
5905
6006
|
const authState = useAuth();
|
|
@@ -5914,7 +6015,7 @@ var useAuthGuard = (options = {}) => {
|
|
|
5914
6015
|
var useRouteAuth = (fallbackPath = "/") => {
|
|
5915
6016
|
const { isAuthenticated, isLoading } = useAuth();
|
|
5916
6017
|
const location = (0, import_react_router_dom.useLocation)();
|
|
5917
|
-
const redirectToLogin = () => /* @__PURE__ */ (0,
|
|
6018
|
+
const redirectToLogin = () => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_react_router_dom.Navigate, { to: fallbackPath, state: { from: location }, replace: true });
|
|
5918
6019
|
return {
|
|
5919
6020
|
isAuthenticated,
|
|
5920
6021
|
isLoading,
|
|
@@ -6042,6 +6143,17 @@ function useUrlAuthentication(options) {
|
|
|
6042
6143
|
options.clearParamsFromURL
|
|
6043
6144
|
]);
|
|
6044
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
|
+
}
|
|
6045
6157
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6046
6158
|
0 && (module.exports = {
|
|
6047
6159
|
Alert,
|
|
@@ -6059,6 +6171,7 @@ function useUrlAuthentication(options) {
|
|
|
6059
6171
|
CardResults,
|
|
6060
6172
|
CardSimulado,
|
|
6061
6173
|
CardStatus,
|
|
6174
|
+
CardTest,
|
|
6062
6175
|
CardTopic,
|
|
6063
6176
|
CheckBox,
|
|
6064
6177
|
Chips,
|
|
@@ -6078,6 +6191,7 @@ function useUrlAuthentication(options) {
|
|
|
6078
6191
|
MenuOverflow,
|
|
6079
6192
|
Modal,
|
|
6080
6193
|
NavButton,
|
|
6194
|
+
NotFound,
|
|
6081
6195
|
ProfileMenuFooter,
|
|
6082
6196
|
ProfileMenuHeader,
|
|
6083
6197
|
ProfileMenuSection,
|
|
@@ -6111,6 +6225,7 @@ function useUrlAuthentication(options) {
|
|
|
6111
6225
|
Toaster,
|
|
6112
6226
|
createZustandAuthAdapter,
|
|
6113
6227
|
getRootDomain,
|
|
6228
|
+
useApiConfig,
|
|
6114
6229
|
useAuth,
|
|
6115
6230
|
useAuthGuard,
|
|
6116
6231
|
useRouteAuth,
|