UNPKG

react-antd-admin-panel

Version:

Modern TypeScript-first React admin panel builder with Ant Design 6

106 lines 2.58 kB
import type { MainConfig, RouteConfig, MainInstance } from './types'; import { GlobalStore } from './Store'; import { UserState } from './UserState'; /** * Main - Central Application Orchestrator * Manages configuration, routing, and global state * * @example * const app = new Main({ * config: { * pathToApi: 'https://api.example.com', * defaultRoute: '/dashboard', * boot: async (main) => { * const user = await fetchUser(); * main.User().set(user); * }, * }, * sections: { * '/dashboard': { * component: DashboardPage, * icon: <DashboardOutlined />, * title: 'Dashboard', * }, * '/users': { * component: UsersPage, * icon: <UserOutlined />, * title: 'Users', * requiredRole: 'admin', * }, * }, * }); */ export declare class Main { private _config; private _store; private _userState; private _navigate?; constructor(config: MainConfig); /** * Get the configuration */ getConfig(): MainConfig; /** * Get route sections */ getSections(): Record<string, RouteConfig>; /** * Get a specific section/route config */ getSection(path: string): RouteConfig | undefined; /** * Get the global store */ Store(): GlobalStore; /** * Get the user state manager */ User(): UserState; /** * Set the navigation function (called by MainProvider) */ setNavigate(fn: (path: string) => void): void; /** * Navigate to a route */ navigate(path: string): void; /** * Check if the current user can access a route */ canAccess(route: RouteConfig): boolean; /** * Get all accessible routes for the current user */ getAccessibleRoutes(): Record<string, RouteConfig>; /** * Get routes for sidebar (non-hidden, accessible) */ getSidebarRoutes(): Array<{ path: string; route: RouteConfig; }>; /** * Create a MainInstance for use in context */ createInstance(navigate: (path: string) => void): MainInstance; /** * Get the default route */ getDefaultRoute(): string; /** * Get the auth route (for unauthenticated users) */ getAuthRoute(): string; /** * Check if user is authenticated */ isAuthenticated(): boolean; /** * Flatten nested routes for routing */ getFlatRoutes(): Array<{ path: string; route: RouteConfig; }>; } //# sourceMappingURL=Main.d.ts.map