import { TypeDefault as BaseTypeDefault, CellRenderContext, ColumnEditorContext } from '@toolbox-web/grid'; import { FilterPanelParams } from '@toolbox-web/grid/plugins/filtering'; import { FC, ReactNode } from 'react'; /** * Type default configuration for React applications. * * Defines default renderer, editor, and editorParams for a data type * using React function components. * * @example * ```tsx * import type { TypeDefault } from '@toolbox-web/grid-react'; * * const countryDefault: TypeDefault = { * renderer: (ctx) => , * editor: (ctx) => ( * * ), * }; * ``` */ export interface TypeDefault { /** React component/function for rendering cells of this type */ renderer?: (ctx: CellRenderContext) => ReactNode; /** React component/function for editing cells of this type */ editor?: (ctx: ColumnEditorContext) => ReactNode; /** Default editorParams for this type */ editorParams?: Record; /** * Custom filter panel renderer for this type. Requires FilteringPlugin. * * Returns JSX to render as the custom filter panel content. * The rendered content is mounted into the filter panel container. * * @example * ```tsx * filterPanelRenderer: (params) => ( * params.applySetFilter(values)} * onClear={params.clearFilter} * /> * ) * ``` */ filterPanelRenderer?: (params: FilterPanelParams) => ReactNode; } /** * Type defaults registry - a map of type names to their defaults. */ export type TypeDefaultsMap = Record; /** * Props for the GridTypeProvider component. */ export interface GridTypeProviderProps { /** * Type defaults to provide to all descendant grids. * * @example * ```tsx * const typeDefaults = { * country: { * renderer: (ctx) => , * editor: (ctx) => * }, * status: { * renderer: (ctx) => * } * }; * * * * * ``` */ defaults: TypeDefaultsMap; children: ReactNode; } /** * Provides application-wide type defaults for all descendant grids. * * Wrap your application (or part of it) with this provider to make * type-level renderers and editors available to all DataGrid components. * * @example * ```tsx * // App.tsx or main.tsx * import { GridTypeProvider, type TypeDefaultsMap } from '@toolbox-web/grid-react'; * * const typeDefaults: TypeDefaultsMap = { * country: { * renderer: (ctx) => , * editor: (ctx) => ( * ctx.commit(v)} * /> * ) * }, * date: { * renderer: (ctx) => formatDate(ctx.value), * editor: (ctx) => * } * }; * * function App() { * return ( * * * * ); * } * ``` * * Any DataGrid with columns using `type: 'country'` will automatically * use the registered renderer/editor. */ export declare const GridTypeProvider: FC; /** * Hook to access the type defaults from context. * * @returns The type defaults map, or null if not within a GridTypeProvider */ export declare function useGridTypeDefaults(): TypeDefaultsMap | null; /** * Hook to get type defaults for a specific type. * * @param type - The type name to look up * @returns The type defaults, or undefined if not found * * @example * ```tsx * function MyComponent() { * const countryDefaults = useTypeDefault('country'); * // countryDefaults?.renderer, countryDefaults?.editor * } * ``` */ export declare function useTypeDefault(type: string): TypeDefault | undefined; /** * Creates a BaseTypeDefault that the grid can use from a React type default. * * This converts React render functions into grid-compatible renderer/editor functions. * Used internally by ReactGridAdapter. * * @internal */ export declare function typeDefaultToBaseTypeDefault(typeDefault: TypeDefault, renderReactNode: (node: ReactNode) => HTMLElement): BaseTypeDefault; /** * Wraps a React filter panel renderer into a vanilla FilterPanelRenderer. * * Mounts react content into the filter panel container element. * Automatically unmounts the previous root when a new panel opens. * * @internal */ export declare function wrapReactFilterPanelRenderer(reactFn: (params: FilterPanelParams) => ReactNode, renderReactNode: (node: ReactNode) => HTMLElement): (container: HTMLElement, params: FilterPanelParams) => void; /** * Internal context for passing the type defaults to the adapter. * Used by DataGrid to communicate with ReactGridAdapter. * @internal */ export declare const GridTypeContextInternal: import('react').Context; //# sourceMappingURL=grid-type-registry.d.ts.map