UNPKG

react-antd-admin-panel

Version:

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

42 lines 1.45 kB
import React from 'react'; import type { RouteConfig } from './types'; interface ProtectedRouteProps { route: RouteConfig; children: React.ReactNode; fallback?: React.ReactNode; } /** * ProtectedRoute - Wraps a route component with access control * Redirects to auth route or shows fallback if user doesn't have access */ export declare function ProtectedRoute({ route, children, fallback }: ProtectedRouteProps): React.ReactElement | null; interface ProtectedProps { /** Required role to view children */ role?: string; /** Required permission to view children */ permission?: string; /** Required permissions (all) to view children */ permissions?: string[]; /** Required permissions (any) to view children */ anyPermission?: string[]; /** Fallback content when access denied */ fallback?: React.ReactNode; children: React.ReactNode; } /** * Protected - Component-level access control * Shows children only if user has required role/permissions * * @example * <Protected role="admin"> * <Button onClick={deleteUser}>Delete</Button> * </Protected> * * @example * <Protected permission="users.edit" fallback={<span>No access</span>}> * <EditUserForm /> * </Protected> */ export declare function Protected({ role, permission, permissions, anyPermission, fallback, children, }: ProtectedProps): React.ReactElement | null; export {}; //# sourceMappingURL=ProtectedRoute.d.ts.map