summaryrefslogtreecommitdiff
path: root/preact-router/src/index.d.ts
diff options
context:
space:
mode:
authorSebastian <sebasjm@gmail.com>2021-08-23 16:46:06 -0300
committerSebastian <sebasjm@gmail.com>2021-08-23 16:48:30 -0300
commit38acabfa6089ab8ac469c12b5f55022fb96935e5 (patch)
tree453dbf70000cc5e338b06201af1eaca8343f8f73 /preact-router/src/index.d.ts
parentf26125e039143b92dc0d84e7775f508ab0cdcaa8 (diff)
downloadnode-vendor-master.tar.gz
node-vendor-master.tar.bz2
node-vendor-master.zip
added web vendorsHEADmaster
Diffstat (limited to 'preact-router/src/index.d.ts')
-rw-r--r--preact-router/src/index.d.ts71
1 files changed, 71 insertions, 0 deletions
diff --git a/preact-router/src/index.d.ts b/preact-router/src/index.d.ts
new file mode 100644
index 0000000..fed2cf6
--- /dev/null
+++ b/preact-router/src/index.d.ts
@@ -0,0 +1,71 @@
+import * as preact from 'preact';
+
+export function route(url: string, replace?: boolean): boolean;
+export function route(options: { url: string; replace?: boolean }): boolean;
+
+export function getCurrentUrl(): string;
+
+export interface Location {
+ pathname: string;
+ search: string;
+}
+
+export interface CustomHistory {
+ listen(callback: (location: Location) => void): () => void;
+ location: Location;
+ push(path: string): void;
+ replace(path: string): void;
+}
+
+export interface RoutableProps {
+ path?: string;
+ default?: boolean;
+}
+
+export interface RouterOnChangeArgs {
+ router: Router;
+ url: string;
+ previous?: string;
+ active: preact.VNode[];
+ current: preact.VNode;
+}
+
+export interface RouterProps extends RoutableProps {
+ history?: CustomHistory;
+ static?: boolean;
+ url?: string;
+ onChange?: (args: RouterOnChangeArgs) => void;
+}
+
+export class Router extends preact.Component<RouterProps, {}> {
+ canRoute(url: string): boolean;
+ getMatchingChildren(
+ children: preact.VNode[],
+ url: string,
+ invoke: boolean
+ ): preact.VNode[];
+ routeTo(url: string): boolean;
+ render(props: RouterProps, {}): preact.VNode;
+}
+
+export const subscribers: Array<(url: string) => void>
+
+type AnyComponent<Props> =
+ | preact.FunctionalComponent<Props>
+ | preact.ComponentConstructor<Props, any>;
+
+export interface RouteProps<Props> extends RoutableProps {
+ component: AnyComponent<Props>;
+}
+
+export function Route<Props>(
+ props: RouteProps<Props> & Partial<Props>
+): preact.VNode;
+
+export function Link(props: {activeClassName?: string} & preact.JSX.HTMLAttributes): preact.VNode;
+
+declare module 'preact' {
+ export interface Attributes extends RoutableProps {}
+}
+
+export default Router;