@archbase/admin 3.0.3 → 3.0.5

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.
@@ -17,6 +17,10 @@ export interface ArchbaseAdminLayoutContextValue {
17
17
  hidden?: boolean;
18
18
  setHidden?: (value: boolean) => void;
19
19
  onNavigationDataChange?: (navigationData: ArchbaseNavigationItem[]) => void;
20
+ /** Indica se as permissões de navegação estão sendo carregadas */
21
+ isLoadingPermissions?: boolean;
22
+ /** Mensagem de erro ao carregar permissões (null se não houver erro) */
23
+ permissionsError?: string | null;
20
24
  }
21
25
  export interface ArchbaseAdminLayoutContextProps {
22
26
  navigationData?: ArchbaseNavigationItem[];
@@ -35,5 +35,17 @@ export interface ArchbaseAdvancedSidebarProps {
35
35
  iconDarkColor?: string;
36
36
  iconLightColor?: string;
37
37
  collapsedSubmenuWidth?: string | number;
38
+ /** Indica se as permissões estão sendo carregadas (exibe skeleton na área do menu) */
39
+ isLoading?: boolean;
40
+ /** Mensagem de erro ao carregar permissões (exibe mensagem na área do menu) */
41
+ loadingError?: string | null;
42
+ /** Componente customizado para exibir durante o carregamento */
43
+ loadingComponent?: ReactNode;
44
+ /** Componente customizado para exibir quando ocorrer erro */
45
+ errorComponent?: ReactNode;
46
+ /** Número de itens no skeleton durante loading */
47
+ skeletonItemCount?: number;
48
+ /** Número de grupos no skeleton durante loading */
49
+ skeletonGroupCount?: number;
38
50
  }
39
51
  export declare function ArchbaseAdvancedSidebar({ navigationData, sidebarGroupWidth, sidebarWidth, sidebarHeight, sidebarCollapsedWidth, selectedGroupColor, groupColor, backgroundGroupColor, isHidden, sideBarFooterHeight, sideBarFooterContent, groupLabelDarkColor, groupLabelLightColor, collapsed, onMenuItemClick, onClickActionIcon, withBorder, showGroupLabels, theme, sidebarRef, defaultGroupIcon, selectedGroupName, sideBarHeaderContent, iconsWithBackground, menuItemHeight, highlightActiveMenuItem, backgroundDarkColor, backgroundLightColor, textDarkColor, textLightColor, iconDarkColor, iconLightColor, collapsedSubmenuWidth, }: ArchbaseAdvancedSidebarProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,71 @@
1
1
  import { default as React, ReactNode } from 'react';
2
2
  import { RouteProps, RoutesProps } from 'react-router';
3
+ import { Params } from 'react-router-dom';
4
+ interface KeepAliveVisibilityContextValue {
5
+ isVisible: boolean;
6
+ }
7
+ /**
8
+ * Hook para acessar o estado de visibilidade do componente keep-alive.
9
+ * Use este hook quando precisar reagir a mudanças de visibilidade da tab,
10
+ * por exemplo, para recalcular dimensões de grids ou gráficos.
11
+ *
12
+ * @example
13
+ * import { useKeepAliveVisibility } from '@archbase/admin';
14
+ *
15
+ * function MeuGrid() {
16
+ * const { isVisible } = useKeepAliveVisibility();
17
+ * const gridRef = useRef();
18
+ *
19
+ * useEffect(() => {
20
+ * if (isVisible && gridRef.current) {
21
+ * // Força recálculo de dimensões quando tab fica visível
22
+ * gridRef.current.api?.sizeColumnsToFit();
23
+ * }
24
+ * }, [isVisible]);
25
+ *
26
+ * return <DataGrid ref={gridRef} ... />;
27
+ * }
28
+ */
29
+ export declare const useKeepAliveVisibility: () => KeepAliveVisibilityContextValue;
30
+ /**
31
+ * Hook para acessar os parâmetros da rota atual.
32
+ * Este hook funciona tanto dentro quanto fora do contexto do React Router Routes,
33
+ * sendo essencial para componentes que usam keepAlive.
34
+ *
35
+ * @example
36
+ * // Dentro de um componente com keepAlive
37
+ * const { id } = useArchbaseRouteParams();
38
+ */
39
+ export declare const useArchbaseRouteParams: <T extends Params<string> = Params<string>>() => T;
40
+ /**
41
+ * Hook de compatibilidade que funciona tanto com React Router quanto com keep-alive.
42
+ *
43
+ * Este hook tenta obter os parâmetros do React Router primeiro. Se não encontrar
44
+ * parâmetros (objeto vazio ou todos os valores undefined), usa o contexto do keep-alive.
45
+ *
46
+ * Use este hook como substituto direto do useParams do React Router para garantir
47
+ * compatibilidade com componentes que podem ou não usar keepAlive.
48
+ *
49
+ * @example
50
+ * // Substitui useParams do react-router-dom
51
+ * import { useParams } from '@archbase/admin';
52
+ * const { id } = useParams<{ id: string }>();
53
+ *
54
+ * @example
55
+ * // Funciona tanto com keepAlive: true quanto keepAlive: false
56
+ * const { id, slug } = useParams<{ id: string; slug: string }>();
57
+ */
58
+ export declare const useParams: <T extends Params<string> = Params<string>>() => T;
59
+ interface CachedComponent {
60
+ element: ReactNode;
61
+ params: Params<string>;
62
+ }
3
63
  interface KeepAliveCacheContextValue {
4
- cache: Map<string, ReactNode>;
64
+ cache: Map<string, CachedComponent>;
5
65
  requestedUnregister: Set<string>;
6
- register: (path: string, component: ReactNode) => void;
7
- unregister: (path: string) => void;
66
+ register: (cacheKey: string, component: ReactNode, params: Params<string>) => void;
67
+ unregister: (cacheKey: string) => void;
68
+ updateParams: (cacheKey: string, params: Params<string>) => void;
8
69
  requestUnregister: (path: string) => void;
9
70
  }
10
71
  export declare const useKeepAliveCache: () => KeepAliveCacheContextValue;
@@ -0,0 +1,41 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SidebarMenuSkeletonProps {
3
+ /** Número de itens de menu a exibir no skeleton */
4
+ itemCount?: number;
5
+ /** Se a sidebar está colapsada */
6
+ collapsed?: boolean;
7
+ /** Cor de fundo */
8
+ backgroundColor?: string;
9
+ }
10
+ /**
11
+ * Skeleton padrão para a área de itens de menu da sidebar.
12
+ * Usa o estilo padrão do Mantine (cinza animado).
13
+ */
14
+ export declare function SidebarMenuSkeleton({ itemCount, collapsed, backgroundColor, }: SidebarMenuSkeletonProps): import("react/jsx-runtime").JSX.Element;
15
+ export interface SidebarGroupsSkeletonProps {
16
+ /** Número de grupos a exibir no skeleton */
17
+ groupCount?: number;
18
+ /** Largura da coluna de grupos */
19
+ width?: string | number;
20
+ /** Altura da sidebar */
21
+ height?: string | number;
22
+ /** Cor de fundo da área de grupos */
23
+ backgroundColor?: string;
24
+ }
25
+ /**
26
+ * Skeleton para a área de grupos da sidebar (coluna lateral com ícones).
27
+ * Usa o estilo padrão do Mantine (cinza animado).
28
+ */
29
+ export declare function SidebarGroupsSkeleton({ groupCount, width, height, backgroundColor, }: SidebarGroupsSkeletonProps): import("react/jsx-runtime").JSX.Element;
30
+ export interface SidebarErrorMessageProps {
31
+ /** Mensagem de erro a exibir */
32
+ message: string;
33
+ /** Cor de fundo */
34
+ backgroundColor?: string;
35
+ /** Componente customizado para exibir o erro */
36
+ children?: ReactNode;
37
+ }
38
+ /**
39
+ * Componente para exibir mensagem de erro na sidebar.
40
+ */
41
+ export declare function SidebarErrorMessage({ message, backgroundColor, children, }: SidebarErrorMessageProps): import("react/jsx-runtime").JSX.Element;
package/dist/index.d.ts CHANGED
@@ -16,11 +16,14 @@ export { ArchbaseNavigationContext, ArchbaseNavigationProvider, useArchbaseNavig
16
16
  export type { ArchbaseNavigationContextValues, ArchbaseNavigationListenerType } from './ArchbaseNavigation.context';
17
17
  export { navigationDataSample } from './navigationData';
18
18
  export type { ArchbaseNavigationItem, ArchbaseCommandColor, ArchbaseCommandMenu, ArchbaseOwner, ArchbaseCompany, ArchbaseTabItem, LocationDataItem, } from './types';
19
- export { ArchbaseKeepAliveRoute, ArchbaseAliveAbleRoutes } from './ArchbaseAliveAbleRoutes';
19
+ export { ArchbaseKeepAliveRoute, ArchbaseAliveAbleRoutes, useKeepAliveVisibility, useArchbaseRouteParams, useParams, useKeepAliveCache } from './ArchbaseAliveAbleRoutes';
20
+ export type { ArchbaseKeepAliveRouteProps } from './ArchbaseAliveAbleRoutes';
20
21
  export type { CommandPaletteButtonProps, ArchbaseSpotlightActionData } from './CommandPaletteButton';
21
22
  export { CommandPaletteButton } from './CommandPaletteButton';
22
23
  export type { ArchbaseAdvancedSidebarProps } from './ArchbaseAdvancedSidebar';
23
24
  export { ArchbaseAdvancedSidebar } from './ArchbaseAdvancedSidebar';
25
+ export type { SidebarMenuSkeletonProps, SidebarGroupsSkeletonProps, SidebarErrorMessageProps } from './SidebarMenuSkeleton';
26
+ export { SidebarMenuSkeleton, SidebarGroupsSkeleton, SidebarErrorMessage } from './SidebarMenuSkeleton';
24
27
  export { ArchbaseDrawerContent } from './drawer/DrawerContent';
25
28
  export type { ArchbaseDrawerContentProps } from './drawer/DrawerContent';
26
29
  export { ArchbaseDrawerTrigger } from './drawer/DrawerTrigger';