academe-kit 0.10.3 → 0.11.2
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.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.js +14 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/types/components/ProtectedApp/index.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,13 @@ type ProtectedAppProps = {
|
|
|
22
22
|
requiredClientRoles?: RequiredClientRoles;
|
|
23
23
|
requiredRealmRoles?: string[];
|
|
24
24
|
theme?: Theme;
|
|
25
|
+
/**
|
|
26
|
+
* Indica que o app ainda está carregando dados pós-autenticação (ex.: a lista
|
|
27
|
+
* de instituições do usuário). Quando `true`, o ProtectedApp continua exibindo
|
|
28
|
+
* a MESMA tela de loading do boot do Keycloak, evitando um segundo spinner em
|
|
29
|
+
* sequência. Default `false` — comportamento idêntico ao anterior.
|
|
30
|
+
*/
|
|
31
|
+
pending?: boolean;
|
|
25
32
|
};
|
|
26
33
|
type TextColorClasses = {
|
|
27
34
|
textPrimary: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -9823,15 +9823,21 @@ const useProtectedAppColors = () => {
|
|
|
9823
9823
|
const context = useContext(ProtectedAppContext);
|
|
9824
9824
|
return context || themes.dark.textColors;
|
|
9825
9825
|
};
|
|
9826
|
-
const ProtectedApp = ({ children, requiredClientRoles, requiredRealmRoles, theme = "dark", }) => {
|
|
9826
|
+
const ProtectedApp = ({ children, requiredClientRoles, requiredRealmRoles, theme = "dark", pending = false, }) => {
|
|
9827
9827
|
const { isInitialized, goToLogin, hasClientRole, hasRealmRole, isAuthenticated, signOut, } = useAcademeAuth();
|
|
9828
9828
|
const themeConfig = themes[theme];
|
|
9829
9829
|
const { backgroundColor, textColors } = themeConfig;
|
|
9830
9830
|
const handleContactSupport = () => {
|
|
9831
9831
|
window.open("https://wa.me/558540428133", "_blank");
|
|
9832
9832
|
};
|
|
9833
|
+
// Tela de loading de tela cheia reutilizada em duas fases do boot:
|
|
9834
|
+
// (1) enquanto o Keycloak inicializa (`!isInitialized`) e (2) enquanto o app
|
|
9835
|
+
// ainda carrega dados pós-auth (`pending`). Por ser o MESMO elemento na mesma
|
|
9836
|
+
// posição da árvore, o React reconcilia entre as fases sem remontar o Spinner
|
|
9837
|
+
// — a animação fica contínua (um loading só, sem "piscar").
|
|
9838
|
+
const loadingScreen = (jsx("div", { className: `!flex !w-screen !h-screen !items-center !justify-center ${backgroundColor}`, children: jsx(Spinner, { className: "!size-10", style: { color: "#892CDD" } }) }));
|
|
9833
9839
|
if (!isInitialized) {
|
|
9834
|
-
return
|
|
9840
|
+
return loadingScreen;
|
|
9835
9841
|
}
|
|
9836
9842
|
if (!isAuthenticated()) {
|
|
9837
9843
|
goToLogin();
|
|
@@ -9845,6 +9851,12 @@ const ProtectedApp = ({ children, requiredClientRoles, requiredRealmRoles, theme
|
|
|
9845
9851
|
!requiredRealmRoles?.some((role) => hasRealmRole(role))) {
|
|
9846
9852
|
return (jsxs("div", { className: `flex flex-col w-screen h-screen items-center justify-center ${backgroundColor}`, children: [jsx(CircleAlert, { className: `size-10 ${textColors.iconColor}` }), jsx("h1", { className: `text-2xl font-bold mt-4 text-center ${textColors.textPrimary}`, children: "Oops, voc\u00EA n\u00E3o tem permiss\u00E3o para acessar aqui." }), jsx("span", { className: `text-center ${textColors.textSecondary}`, children: "Se voc\u00EA acredita que isso \u00E9 um erro, entre em contato com o suporte." }), jsxs("div", { className: "flex gap-3 mt-4", children: [jsx(Button, { variant: "primary", size: "md", onClick: handleContactSupport, children: "Falar com o suporte" }), jsx(Button, { variant: "outline", size: "md", onClick: signOut, children: "Sair da conta" })] })] }));
|
|
9847
9853
|
}
|
|
9854
|
+
// Auth e roles OK, mas o app ainda carrega dados pós-auth (ex.: a lista de
|
|
9855
|
+
// instituições do dash). Mantém o MESMO `loadingScreen` do passo `!isInitialized`,
|
|
9856
|
+
// então o spinner não remonta entre as fases — continua sendo um loading só.
|
|
9857
|
+
if (pending) {
|
|
9858
|
+
return loadingScreen;
|
|
9859
|
+
}
|
|
9848
9860
|
return (jsx(ProtectedAppContext.Provider, { value: textColors, children: children }));
|
|
9849
9861
|
};
|
|
9850
9862
|
|