analytica-frontend-lib 1.0.72 → 1.0.74

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.
Files changed (81) hide show
  1. package/dist/Accordation/index.js +119 -0
  2. package/dist/Accordation/index.js.map +1 -1
  3. package/dist/Accordation/index.mjs +119 -0
  4. package/dist/Accordation/index.mjs.map +1 -1
  5. package/dist/Auth/AuthProvider/index.d.mts +3 -0
  6. package/dist/Auth/AuthProvider/index.d.ts +3 -0
  7. package/dist/Auth/AuthProvider/index.js +211 -0
  8. package/dist/Auth/AuthProvider/index.js.map +1 -0
  9. package/dist/Auth/AuthProvider/index.mjs +187 -0
  10. package/dist/Auth/AuthProvider/index.mjs.map +1 -0
  11. package/dist/Auth/ProtectedRoute/index.d.mts +3 -0
  12. package/dist/Auth/ProtectedRoute/index.d.ts +3 -0
  13. package/dist/Auth/ProtectedRoute/index.js +211 -0
  14. package/dist/Auth/ProtectedRoute/index.js.map +1 -0
  15. package/dist/Auth/ProtectedRoute/index.mjs +187 -0
  16. package/dist/Auth/ProtectedRoute/index.mjs.map +1 -0
  17. package/dist/Auth/PublicRoute/index.d.mts +3 -0
  18. package/dist/Auth/PublicRoute/index.d.ts +3 -0
  19. package/dist/Auth/PublicRoute/index.js +211 -0
  20. package/dist/Auth/PublicRoute/index.js.map +1 -0
  21. package/dist/Auth/PublicRoute/index.mjs +187 -0
  22. package/dist/Auth/PublicRoute/index.mjs.map +1 -0
  23. package/dist/Auth/index.d.mts +106 -19
  24. package/dist/Auth/index.d.ts +106 -19
  25. package/dist/Auth/index.js +21 -0
  26. package/dist/Auth/index.js.map +1 -1
  27. package/dist/Auth/index.mjs +21 -0
  28. package/dist/Auth/index.mjs.map +1 -1
  29. package/dist/Auth/useAuth/index.d.mts +3 -0
  30. package/dist/Auth/useAuth/index.d.ts +3 -0
  31. package/dist/Auth/useAuth/index.js +211 -0
  32. package/dist/Auth/useAuth/index.js.map +1 -0
  33. package/dist/Auth/useAuth/index.mjs +187 -0
  34. package/dist/Auth/useAuth/index.mjs.map +1 -0
  35. package/dist/Auth/useAuthGuard/index.d.mts +3 -0
  36. package/dist/Auth/useAuthGuard/index.d.ts +3 -0
  37. package/dist/Auth/useAuthGuard/index.js +211 -0
  38. package/dist/Auth/useAuthGuard/index.js.map +1 -0
  39. package/dist/Auth/useAuthGuard/index.mjs +187 -0
  40. package/dist/Auth/useAuthGuard/index.mjs.map +1 -0
  41. package/dist/Auth/useRouteAuth/index.d.mts +3 -0
  42. package/dist/Auth/useRouteAuth/index.d.ts +3 -0
  43. package/dist/Auth/useRouteAuth/index.js +211 -0
  44. package/dist/Auth/useRouteAuth/index.js.map +1 -0
  45. package/dist/Auth/useRouteAuth/index.mjs +187 -0
  46. package/dist/Auth/useRouteAuth/index.mjs.map +1 -0
  47. package/dist/Auth/useUrlAuthentication/index.d.mts +58 -0
  48. package/dist/Auth/useUrlAuthentication/index.d.ts +58 -0
  49. package/dist/Auth/useUrlAuthentication/index.js +94 -0
  50. package/dist/Auth/useUrlAuthentication/index.js.map +1 -0
  51. package/dist/Auth/useUrlAuthentication/index.mjs +69 -0
  52. package/dist/Auth/useUrlAuthentication/index.mjs.map +1 -0
  53. package/dist/Auth/withAuth/index.d.mts +3 -0
  54. package/dist/Auth/withAuth/index.d.ts +3 -0
  55. package/dist/Auth/withAuth/index.js +211 -0
  56. package/dist/Auth/withAuth/index.js.map +1 -0
  57. package/dist/Auth/withAuth/index.mjs +187 -0
  58. package/dist/Auth/withAuth/index.mjs.map +1 -0
  59. package/dist/Auth/zustandAuthAdapter/index.d.mts +75 -0
  60. package/dist/Auth/zustandAuthAdapter/index.d.ts +75 -0
  61. package/dist/Auth/zustandAuthAdapter/index.js +70 -0
  62. package/dist/Auth/zustandAuthAdapter/index.js.map +1 -0
  63. package/dist/Auth/zustandAuthAdapter/index.mjs +45 -0
  64. package/dist/Auth/zustandAuthAdapter/index.mjs.map +1 -0
  65. package/dist/Card/index.d.mts +10 -1
  66. package/dist/Card/index.d.ts +10 -1
  67. package/dist/Card/index.js +121 -0
  68. package/dist/Card/index.js.map +1 -1
  69. package/dist/Card/index.mjs +120 -0
  70. package/dist/Card/index.mjs.map +1 -1
  71. package/dist/index.css +48 -0
  72. package/dist/index.css.map +1 -1
  73. package/dist/index.d.mts +2 -0
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.js +252 -0
  76. package/dist/index.js.map +1 -1
  77. package/dist/index.mjs +250 -0
  78. package/dist/index.mjs.map +1 -1
  79. package/dist/styles.css +48 -0
  80. package/dist/styles.css.map +1 -1
  81. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -4038,6 +4038,125 @@ var CardSimulado = forwardRef9(
4038
4038
  );
4039
4039
  }
4040
4040
  );
4041
+ var CardTest = forwardRef9(
4042
+ ({
4043
+ title,
4044
+ duration,
4045
+ questionsCount,
4046
+ additionalInfo,
4047
+ selected = false,
4048
+ onSelect,
4049
+ className = "",
4050
+ ...props
4051
+ }, ref) => {
4052
+ const handleClick = () => {
4053
+ if (onSelect) {
4054
+ onSelect(!selected);
4055
+ }
4056
+ };
4057
+ const handleKeyDown = (event) => {
4058
+ if ((event.key === "Enter" || event.key === " ") && onSelect) {
4059
+ event.preventDefault();
4060
+ onSelect(!selected);
4061
+ }
4062
+ };
4063
+ const isSelectable = !!onSelect;
4064
+ const getQuestionsText = (count) => {
4065
+ const singular = count === 1 ? "quest\xE3o" : "quest\xF5es";
4066
+ return `${count} ${singular}`;
4067
+ };
4068
+ const displayInfo = questionsCount ? getQuestionsText(questionsCount) : additionalInfo || "";
4069
+ const baseClasses = "flex flex-row items-center p-4 gap-2 w-full max-w-full bg-background shadow-soft-shadow-1 rounded-xl isolate border-0 text-left";
4070
+ const interactiveClasses = isSelectable ? "cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary-950 focus:ring-offset-2" : "";
4071
+ const selectedClasses = selected ? "ring-2 ring-primary-950 ring-offset-2" : "";
4072
+ if (isSelectable) {
4073
+ return /* @__PURE__ */ jsx23(
4074
+ "button",
4075
+ {
4076
+ ref,
4077
+ type: "button",
4078
+ className: `${baseClasses} ${interactiveClasses} ${selectedClasses} ${className}`.trim(),
4079
+ onClick: handleClick,
4080
+ onKeyDown: handleKeyDown,
4081
+ "aria-pressed": selected,
4082
+ ...props,
4083
+ children: /* @__PURE__ */ jsxs18("div", { className: "flex flex-col justify-between gap-[27px] flex-grow min-h-[67px] w-full min-w-0", children: [
4084
+ /* @__PURE__ */ jsx23(
4085
+ Text_default,
4086
+ {
4087
+ size: "md",
4088
+ weight: "bold",
4089
+ className: "text-text-950 tracking-[0.2px] leading-[19px] truncate",
4090
+ children: title
4091
+ }
4092
+ ),
4093
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-row justify-start items-end gap-4 w-full", children: [
4094
+ duration && /* @__PURE__ */ jsxs18("div", { className: "flex flex-row items-center gap-1 flex-shrink-0", children: [
4095
+ /* @__PURE__ */ jsx23(Clock, { size: 16, className: "text-text-700" }),
4096
+ /* @__PURE__ */ jsx23(
4097
+ Text_default,
4098
+ {
4099
+ size: "sm",
4100
+ className: "text-text-700 leading-[21px] whitespace-nowrap",
4101
+ children: duration
4102
+ }
4103
+ )
4104
+ ] }),
4105
+ /* @__PURE__ */ jsx23(
4106
+ Text_default,
4107
+ {
4108
+ size: "sm",
4109
+ className: "text-text-700 leading-[21px] flex-grow truncate",
4110
+ children: displayInfo
4111
+ }
4112
+ )
4113
+ ] })
4114
+ ] })
4115
+ }
4116
+ );
4117
+ }
4118
+ return /* @__PURE__ */ jsx23(
4119
+ "div",
4120
+ {
4121
+ ref,
4122
+ className: `${baseClasses} ${className}`.trim(),
4123
+ ...props,
4124
+ children: /* @__PURE__ */ jsxs18("div", { className: "flex flex-col justify-between gap-[27px] flex-grow min-h-[67px] w-full min-w-0", children: [
4125
+ /* @__PURE__ */ jsx23(
4126
+ Text_default,
4127
+ {
4128
+ size: "md",
4129
+ weight: "bold",
4130
+ className: "text-text-950 tracking-[0.2px] leading-[19px] truncate",
4131
+ children: title
4132
+ }
4133
+ ),
4134
+ /* @__PURE__ */ jsxs18("div", { className: "flex flex-row justify-start items-end gap-4 w-full", children: [
4135
+ duration && /* @__PURE__ */ jsxs18("div", { className: "flex flex-row items-center gap-1 flex-shrink-0", children: [
4136
+ /* @__PURE__ */ jsx23(Clock, { size: 16, className: "text-text-700" }),
4137
+ /* @__PURE__ */ jsx23(
4138
+ Text_default,
4139
+ {
4140
+ size: "sm",
4141
+ className: "text-text-700 leading-[21px] whitespace-nowrap",
4142
+ children: duration
4143
+ }
4144
+ )
4145
+ ] }),
4146
+ /* @__PURE__ */ jsx23(
4147
+ Text_default,
4148
+ {
4149
+ size: "sm",
4150
+ className: "text-text-700 leading-[21px] flex-grow truncate min-w-0",
4151
+ children: displayInfo
4152
+ }
4153
+ )
4154
+ ] })
4155
+ ] })
4156
+ }
4157
+ );
4158
+ }
4159
+ );
4041
4160
 
4042
4161
  // src/components/Accordation/Accordation.tsx
4043
4162
  import { CaretRight as CaretRight2 } from "phosphor-react";
@@ -5736,6 +5855,14 @@ var ProtectedRoute = ({
5736
5855
  return /* @__PURE__ */ jsx31(Fragment7, { children: loadingComponent || defaultLoadingComponent });
5737
5856
  }
5738
5857
  if (!isAuthenticated) {
5858
+ if (typeof window !== "undefined") {
5859
+ const rootDomain = getRootDomain();
5860
+ const currentLocation = `${window.location.protocol}//${window.location.hostname}${window.location.port ? ":" + window.location.port : ""}`;
5861
+ if (rootDomain !== currentLocation) {
5862
+ window.location.href = rootDomain;
5863
+ return null;
5864
+ }
5865
+ }
5739
5866
  return /* @__PURE__ */ jsx31(Navigate, { to: redirectTo, replace: true });
5740
5867
  }
5741
5868
  if (additionalCheck && !additionalCheck({ isAuthenticated, isLoading, ...authState })) {
@@ -5781,6 +5908,127 @@ var useRouteAuth = (fallbackPath = "/") => {
5781
5908
  redirectToLogin
5782
5909
  };
5783
5910
  };
5911
+ var getRootDomain = () => {
5912
+ const { hostname, protocol, port } = window.location;
5913
+ const portStr = port ? ":" + port : "";
5914
+ if (hostname === "localhost") {
5915
+ return `${protocol}//${hostname}${portStr}`;
5916
+ }
5917
+ const parts = hostname.split(".");
5918
+ if (parts.length > 2) {
5919
+ const base = parts.slice(-2).join(".");
5920
+ return `${protocol}//${base}${portStr}`;
5921
+ }
5922
+ return `${protocol}//${hostname}${portStr}`;
5923
+ };
5924
+
5925
+ // src/components/Auth/zustandAuthAdapter.ts
5926
+ function createZustandAuthAdapter(useAuthStore) {
5927
+ return {
5928
+ /**
5929
+ * Check if the user is authenticated based on sessionInfo and tokens
5930
+ *
5931
+ * @returns {Promise<boolean>} Promise that resolves to authentication status
5932
+ */
5933
+ checkAuth: async () => {
5934
+ const { sessionInfo, tokens } = useAuthStore.getState();
5935
+ return Boolean(sessionInfo && tokens);
5936
+ },
5937
+ /**
5938
+ * Get the current user from the store
5939
+ *
5940
+ * @returns {unknown} Current user data from the store
5941
+ */
5942
+ getUser: () => useAuthStore.getState().user,
5943
+ /**
5944
+ * Get the current session information from the store
5945
+ *
5946
+ * @returns {unknown} Current session info from the store
5947
+ */
5948
+ getSessionInfo: () => useAuthStore.getState().sessionInfo,
5949
+ /**
5950
+ * Get the current authentication tokens from the store
5951
+ *
5952
+ * @returns {unknown} Current tokens from the store
5953
+ */
5954
+ getTokens: () => useAuthStore.getState().tokens,
5955
+ /**
5956
+ * Sign out the user by calling the store's signOut function if available
5957
+ *
5958
+ * @returns {void}
5959
+ */
5960
+ signOut: () => {
5961
+ const signOutFn = useAuthStore.getState().signOut;
5962
+ if (typeof signOutFn === "function") signOutFn();
5963
+ }
5964
+ };
5965
+ }
5966
+
5967
+ // src/components/Auth/useUrlAuthentication.ts
5968
+ import { useEffect as useEffect9 } from "react";
5969
+ import { useLocation as useLocation2 } from "react-router-dom";
5970
+ var getAuthParams = (location, extractParams) => {
5971
+ const searchParams = new URLSearchParams(location.search);
5972
+ return extractParams ? extractParams(searchParams) : {
5973
+ sessionId: searchParams.get("sessionId"),
5974
+ token: searchParams.get("token"),
5975
+ refreshToken: searchParams.get("refreshToken")
5976
+ };
5977
+ };
5978
+ var hasValidAuthParams = (authParams) => {
5979
+ return !!(authParams?.sessionId && authParams?.token && authParams?.refreshToken);
5980
+ };
5981
+ var hasValidProfileData = (data) => {
5982
+ return data !== null && typeof data === "object" && data !== void 0;
5983
+ };
5984
+ var handleProfileSelection = (responseData, setSelectedProfile) => {
5985
+ if (!setSelectedProfile) return;
5986
+ if (!hasValidProfileData(responseData)) return;
5987
+ const profileId = responseData.profileId;
5988
+ const isValidProfileId = profileId !== null && profileId !== void 0;
5989
+ if (isValidProfileId) {
5990
+ setSelectedProfile({
5991
+ id: profileId
5992
+ });
5993
+ }
5994
+ };
5995
+ function useUrlAuthentication(options) {
5996
+ const location = useLocation2();
5997
+ useEffect9(() => {
5998
+ const handleAuthentication = async () => {
5999
+ const authParams = getAuthParams(location, options.extractParams);
6000
+ if (!hasValidAuthParams(authParams)) {
6001
+ return;
6002
+ }
6003
+ try {
6004
+ options.setTokens({
6005
+ token: authParams.token,
6006
+ refreshToken: authParams.refreshToken
6007
+ });
6008
+ const response = await options.api.get(options.endpoint, {
6009
+ headers: {
6010
+ Authorization: `Bearer ${authParams.token}`
6011
+ }
6012
+ });
6013
+ options.setSessionInfo(response.data.data);
6014
+ handleProfileSelection(response.data.data, options.setSelectedProfile);
6015
+ options.clearParamsFromURL?.();
6016
+ } catch (error) {
6017
+ console.error("Erro ao obter informa\xE7\xF5es da sess\xE3o:", error);
6018
+ }
6019
+ };
6020
+ handleAuthentication();
6021
+ }, [
6022
+ location.search,
6023
+ options.setSessionInfo,
6024
+ options.setSelectedProfile,
6025
+ options.setTokens,
6026
+ options.api,
6027
+ options.endpoint,
6028
+ options.extractParams,
6029
+ options.clearParamsFromURL
6030
+ ]);
6031
+ }
5784
6032
  export {
5785
6033
  Alert_default as Alert,
5786
6034
  AlertDialog,
@@ -5847,10 +6095,12 @@ export {
5847
6095
  TextArea_default as TextArea,
5848
6096
  Toast_default as Toast,
5849
6097
  Toaster_default as Toaster,
6098
+ createZustandAuthAdapter,
5850
6099
  useAuth,
5851
6100
  useAuthGuard,
5852
6101
  useRouteAuth,
5853
6102
  ToastStore_default as useToastStore,
6103
+ useUrlAuthentication,
5854
6104
  withAuth
5855
6105
  };
5856
6106
  //# sourceMappingURL=index.mjs.map