analytica-frontend-lib 1.0.77 → 1.0.79

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,
@@ -3601,7 +3603,7 @@ var CardResults = (0, import_react11.forwardRef)(
3601
3603
  layout: "horizontal",
3602
3604
  padding: "none",
3603
3605
  minHeight: "medium",
3604
- className: `items-center pr-4 ${className}`,
3606
+ className: `items-center cursor-pointer pr-4 ${className}`,
3605
3607
  ...props,
3606
3608
  children: [
3607
3609
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
@@ -3631,7 +3633,7 @@ var CardResults = (0, import_react11.forwardRef)(
3631
3633
  {
3632
3634
  action: "success",
3633
3635
  variant: "solid",
3634
- size: "medium",
3636
+ size: "large",
3635
3637
  iconLeft: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_phosphor_react10.CheckCircle, {}),
3636
3638
  children: [
3637
3639
  correct_answers,
@@ -3644,7 +3646,7 @@ var CardResults = (0, import_react11.forwardRef)(
3644
3646
  {
3645
3647
  action: "error",
3646
3648
  variant: "solid",
3647
- size: "medium",
3649
+ size: "large",
3648
3650
  iconLeft: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_phosphor_react10.XCircle, {}),
3649
3651
  children: [
3650
3652
  incorrect_answers,
@@ -3656,14 +3658,14 @@ var CardResults = (0, import_react11.forwardRef)(
3656
3658
  ]
3657
3659
  }
3658
3660
  ),
3659
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_phosphor_react10.CaretRight, { className: "min-w-6 min-h-6 text-text-800 cursor-pointer" })
3661
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_phosphor_react10.CaretRight, { className: "min-w-6 min-h-6 text-text-800" })
3660
3662
  ]
3661
3663
  }
3662
3664
  );
3663
3665
  }
3664
3666
  );
3665
3667
  var CardStatus = (0, import_react11.forwardRef)(
3666
- ({ header, className, status, ...props }, ref) => {
3668
+ ({ header, className, status, label, ...props }, ref) => {
3667
3669
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
3668
3670
  CardBase,
3669
3671
  {
@@ -3671,7 +3673,7 @@ var CardStatus = (0, import_react11.forwardRef)(
3671
3673
  layout: "horizontal",
3672
3674
  padding: "medium",
3673
3675
  minHeight: "medium",
3674
- className: `items-center ${className}`,
3676
+ className: `items-center cursor-pointer ${className}`,
3675
3677
  ...props,
3676
3678
  children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "flex justify-between w-full h-full flex-row items-center gap-2", children: [
3677
3679
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-sm font-bold text-text-950 truncate flex-1 min-w-0", children: header }),
@@ -3686,7 +3688,7 @@ var CardStatus = (0, import_react11.forwardRef)(
3686
3688
  children: status == "correct" ? "Correta" : "Incorreta"
3687
3689
  }
3688
3690
  ),
3689
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-sm text-text-800", children: "Respondida" })
3691
+ label && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "text-sm text-text-800", children: label })
3690
3692
  ] }),
3691
3693
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_phosphor_react10.CaretRight, { className: "min-w-6 min-h-6 text-text-800 cursor-pointer flex-shrink-0 ml-2" })
3692
3694
  ] })
@@ -4365,7 +4367,7 @@ var AlternativesList = ({
4365
4367
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4366
4368
  "p",
4367
4369
  {
4368
- className: `block font-medium ${selectedValue === alternative.value || statusBadge ? "text-primary-950" : "text-text-600"}`,
4370
+ className: `block font-medium ${selectedValue === alternative.value || statusBadge ? "text-text-950" : "text-text-600"}`,
4369
4371
  children: alternative.label
4370
4372
  }
4371
4373
  ),
@@ -4388,7 +4390,7 @@ var AlternativesList = ({
4388
4390
  /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4389
4391
  "span",
4390
4392
  {
4391
- className: `flex-1 ${selectedValue === alternative.value || statusBadge ? "text-primary-950" : "text-text-600"}`,
4393
+ className: `flex-1 ${selectedValue === alternative.value || statusBadge ? "text-text-950" : "text-text-600"}`,
4392
4394
  children: alternative.label
4393
4395
  }
4394
4396
  )
@@ -4448,7 +4450,7 @@ var AlternativesList = ({
4448
4450
  {
4449
4451
  htmlFor: alternativeId,
4450
4452
  className: `block font-medium
4451
- ${actualValue === alternative.value ? "text-primary-950" : "text-text-600"}
4453
+ ${actualValue === alternative.value ? "text-text-950" : "text-text-600"}
4452
4454
  ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4453
4455
  children: alternative.label
4454
4456
  }
@@ -4481,7 +4483,7 @@ var AlternativesList = ({
4481
4483
  {
4482
4484
  htmlFor: alternativeId,
4483
4485
  className: `flex-1
4484
- ${actualValue === alternative.value ? "text-primary-950" : "text-text-600"}
4486
+ ${actualValue === alternative.value ? "text-text-950" : "text-text-600"}
4485
4487
  ${alternative.disabled ? "cursor-not-allowed" : "cursor-pointer"}`,
4486
4488
  children: alternative.label
4487
4489
  }
@@ -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,