UNPKG

mui-toolpad-extended-tuni

Version:
118 lines (117 loc) 4.08 kB
import { ComponentType } from 'react'; /** * Toolbar Registry System * * @version 3.1.0 * * A flexible system for registering and managing toolbar actions based on routes. * Supports dynamic registration, unregistration, and automatic re-rendering. * Now with support for passing props to registered components. * * @example * ```tsx * // Register a toolbar action * registerToolbarAction('/my-route', MyActionComponent); * * // Register with props * registerToolbarAction('/my-route', MyActionComponent, { some: 'props' }); * * // Clean up when component unmounts * useEffect(() => { * registerToolbarAction('/my-route', MyActionComponent); * return () => unregisterToolbarAction('/my-route', MyActionComponent); * }, []); * ``` */ /** * Toolbar entry containing both the component and optional props */ export interface ToolbarEntry { Component: ComponentType<any>; props?: Record<string, any>; } /** * Register a new page toolbar action for a specific route. * * @param path - The route path where this action should appear. * @param Component - The React component to render in the page toolbar. * @param props - Optional props to pass to the component. * * @example * registerPageToolbarAction('/my-route', MyPageAction); * registerPageToolbarAction('/my-route', MyPageAction, { color: 'primary' }); */ export declare function registerPageToolbarAction(path: string, Component: ComponentType<any>, props?: Record<string, any>): void; /** * Unregister a page toolbar action from a specific route. * * @param path - The route path to remove the action from. * @param Component - The React component to remove. * * @example * unregisterPageToolbarAction('/my-route', MyPageAction); */ export declare function unregisterPageToolbarAction(path: string, Component: ComponentType<any>): void; /** * Get all registered page toolbar actions for a specific route. * * @param path - The route path to get the actions for. * @returns An array of registered page toolbar action entries. * * @example * const actions = getPageToolbarActions('/my-route'); */ export declare function getPageToolbarActions(path: string): ToolbarEntry[]; /** * Clear all registered page toolbar actions for a specific route. * * @param path - The route path to clear the actions for. * * @example * clearPageToolbarActions('/my-route'); */ export declare function clearPageToolbarActions(path: string): void; /** * Register a new app toolbar action for a specific route or global key. * * @param path - The key or route where this action should appear. * @param Component - The React component to render in the app toolbar. * @param props - Optional props to pass to the component. * * @example * registerAppToolbarAction('global', MyAppAction); * registerAppToolbarAction('global', MyAppAction, { variant: 'outlined' }); */ export declare function registerAppToolbarAction(path: string, Component: ComponentType<any>, props?: Record<string, any>): void; /** * Unregister an app toolbar action from a specific route or global key. * * @param path - The key or route to remove the action from. * @param Component - The React component to remove. * * @example * unregisterAppToolbarAction('global', MyAppAction); */ export declare function unregisterAppToolbarAction(path: string, Component: ComponentType<any>): void; /** * Get all registered app toolbar actions for a specific route or global key. * * @param path - The key or route to get the actions for. * @returns An array of registered app toolbar action entries. * * @example * const actions = getAppToolbarActions('global'); */ export declare function getAppToolbarActions(path: string): ToolbarEntry[]; /** * Clear all registered app toolbar actions for a specific route or global key. * * @param path - The key or route to clear the actions for. * * @example * clearAppToolbarActions('global'); */ export declare function clearAppToolbarActions(path: string): void; export declare const useToolbarRegistryStore: () => { version: number; };