import { type ComponentType, type ReactNode } from 'react'; import { type DirectoryNode, type FileSystemNode } from '@hamak/shared-utils'; import type { IRouteRegistry, IViewResolverRegistry, RouteContribution, StoreFsNodeRef } from '../api/index.js'; /** Props of a component a view resolver returns. */ export interface ResolvedViewProps { node: StoreFsNodeRef; } export type ViewComponent = ComponentType>; export type RouteComponent = ComponentType; export interface ViewRoutingContextValue { routes?: IRouteRegistry; resolvers?: IViewResolverRegistry; } export declare const ViewRoutingContext: import("react").Context; export interface ViewRoutingProviderProps extends ViewRoutingContextValue { children?: ReactNode; } /** Makes the registries available to {@link ContentView} and the hooks below. */ export declare function ViewRoutingProvider({ routes, resolvers, children }: ViewRoutingProviderProps): import("react").FunctionComponentElement>; /** The contributed routes, re-read whenever the registry changes. */ export declare function useRouteContributions(registry?: IRouteRegistry): readonly RouteContribution[]; /** The part of a store-fs facade {@link ContentView} reads through. */ export interface StoreFsNodeSelectorFactory { createSelector(path: string | string[]): (state: any) => FileSystemNode | undefined; } /** What {@link ContentView} renders when no resolver claims a file: its content, as text. */ export declare function DefaultContentView({ node }: ResolvedViewProps): import("react").ReactElement<{ 'data-content-type': string; }, string | import("react").JSXElementConstructor>; export interface ContentViewProps { /** The store-fs path of the node to display. */ path: string | string[]; fs: StoreFsNodeSelectorFactory; /** Defaults to the registry of the enclosing {@link ViewRoutingProvider}. */ resolvers?: IViewResolverRegistry; /** Rendered for a file no resolver claims. Defaults to {@link DefaultContentView}. */ fallback?: ViewComponent; /** Rendered for a directory node. Defaults to nothing. */ directory?: ComponentType<{ path: string[]; node: DirectoryNode; }>; /** Rendered while the path names no node. Defaults to nothing. */ missing?: ReactNode; } /** * The generic content route: observes one store-fs node and renders the * component the view resolvers return for it. A path that runs past a file * (`a.json/nope`, `a.json/a.json`) names no node and renders `missing`. * * It reads the store and nothing else. A change to the node re-renders the view * with the new content, and loading the node is the host's business: this * component dispatches nothing. A resolver registered or removed later takes * effect on the next render; with every resolver passing, `fallback` renders. * * Resolvers should return a stable component (not one created per call), or * the view remounts on every change. */ export declare function ContentView({ path, fs, resolvers, fallback, directory, missing }: ContentViewProps): import("react").FunctionComponentElement<{ children?: ReactNode | undefined; }> | import("react").ReactElement<{ path: string[]; node: DirectoryNode; }, string | import("react").JSXElementConstructor> | import("react").ReactElement, string | import("react").JSXElementConstructor> | null; //# sourceMappingURL=view-routing.d.ts.map