@generouted/solid-router
Version:
Generated file-based routes for Solid Router and Vite
55 lines (49 loc) • 2.46 kB
TypeScript
import * as solid_js from 'solid-js';
import { Accessor } from 'solid-js';
import { AnchorProps as AnchorProps$1, NavigateProps as NavigateProps$1, NavigateOptions as NavigateOptions$1 } from '@solidjs/router';
import { MatchFilters } from '@solidjs/router/dist/types';
type ComponentProps<Path extends string, Params extends Record<string, any>> = Path extends keyof Params ? {
href: Path;
params: Params[Path];
} : {
href: Path;
params?: never;
};
type AnchorProps<Path extends string, Params extends Record<string, any>> = Omit<AnchorProps$1, 'href'> & ComponentProps<Path, Params>;
type NavigateProps<Path extends string, Params extends Record<string, any>> = Omit<NavigateProps$1, 'href'> & ComponentProps<Path, Params>;
type NavigateOptions<Path extends string, Params extends Record<string, any>> = Path extends keyof Params ? [Partial<NavigateOptions$1> & {
params: Params[Path];
}] : [Partial<NavigateOptions$1> & {
params?: never;
}] | [];
declare const components: <Path extends string, Params extends Record<string, any>>() => {
A: <P extends Path>(props: AnchorProps<P, Params>) => solid_js.JSX.Element;
Navigate: <P extends Path>(props: NavigateProps<P, Params>) => solid_js.JSX.Element;
};
declare const hooks: <Path extends string, Params extends Record<string, any>, ModalPath extends string>() => {
useParams: <P extends keyof Params>(path: P) => Params[P];
useNavigate: () => <P extends Path>(href: P, ...[options]: NavigateOptions<P, Params>) => void;
useMatch: <P extends Path>(path: () => P, matchFilters?: MatchFilters<P>) => Accessor<{
path: P;
params: Params[P];
} | undefined>;
useModals: () => {
current: any;
open: <P extends Path>(path: ModalPath, options?: Partial<NavigateOptions$1<any>> & (P extends keyof Params ? {
at?: P | undefined;
params: Params[P];
} : {
at?: P | undefined;
params?: never;
})) => void;
close: <P extends Path>(options?: Partial<NavigateOptions$1<any>> & (P extends keyof Params ? {
at?: P | undefined;
params: Params[P];
} : {
at?: P | undefined;
params?: never;
})) => void;
};
};
declare const generatePath: (path: string, params: Record<string, string>) => string;
export { type AnchorProps, type NavigateOptions, type NavigateProps, components, generatePath, hooks };