import { ColumnConfig, DataGridElement, GridConfig } from '@toolbox-web/grid'; import { DataGridRef } from './data-grid'; /** * Return type for useGrid hook. * @since 0.0.1 */ export interface UseGridReturn { /** Ref to attach to the DataGrid component (returns DataGridRef handle) */ ref: React.RefObject | null>; /** Direct access to the typed grid element (convenience for ref.current?.element) */ element: DataGridElement | null; /** Whether the grid is ready */ isReady: boolean; /** Current grid configuration */ config: GridConfig | null; /** Get the effective configuration */ getConfig: () => Promise | null>; /** Force a layout recalculation */ forceLayout: () => Promise; /** Toggle a group row */ toggleGroup: (key: string) => Promise; /** Get a plugin by its class */ getPlugin: (pluginClass: new (...args: unknown[]) => T) => T | undefined; /** * Get a plugin by its registered name (preferred). * Uses the type-safe PluginNameMap for auto-completion and return type narrowing. */ getPluginByName: DataGridElement['getPluginByName']; /** Register custom styles */ registerStyles: (id: string, css: string) => void; /** Unregister custom styles */ unregisterStyles: (id: string) => void; /** Get current visible columns */ getVisibleColumns: () => ColumnConfig[]; } /** * Hook for programmatic access to a grid instance. * * ## Usage * * ```tsx * import { DataGrid, useGrid } from '@toolbox-web/grid-react'; * * function MyComponent() { * const { ref, isReady, getConfig, forceLayout } = useGrid(); * * const handleResize = async () => { * await forceLayout(); * }; * * const handleExport = async () => { * const config = await getConfig(); * console.log('Exporting with columns:', config?.columns); * }; * * return ( * <> * * * * * ); * } * ``` * * @param selector - Optional CSS selector to target a specific grid element via * DOM query instead of using `ref`. Use when the component contains multiple * grids, e.g. `'tbw-grid.primary'` or `'#my-grid'`. * @since 0.0.1 */ export declare function useGrid(selector?: string): UseGridReturn; //# sourceMappingURL=use-grid.d.ts.map