-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.d.ts
More file actions
151 lines (147 loc) · 3.96 KB
/
Copy pathindex.d.ts
File metadata and controls
151 lines (147 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Generated by dts-bundle-generator v9.5.1
import React$1 from "react";
import { ReactElement, ReactNode } from "react";
export interface RouterProps {
scrollUp?: boolean;
url?: string;
children?: React$1.ReactNode;
}
declare const _default: ({
scrollUp,
url: baseUrl,
children,
}: RouterProps) => import("react/jsx-runtime").JSX.Element;
export type ParseParamType<T extends string> =
T extends `${infer Name}<${infer Type}>`
? Type extends "number"
? {
[K in Name]: number;
}
: Type extends "string"
? {
[K in Name]: string;
}
: Type extends "date"
? {
[K in Name]: Date;
}
: Type extends "boolean"
? {
[K in Name]: boolean;
}
: {
[K in Name]: string;
}
: {
[K in T]: string;
};
export type ExtractParams<T extends string> =
T extends `${infer _Prefix}/:${infer Param}/${infer Rest}`
? ParseParamType<Param> & ExtractParams<`/${Rest}`>
: T extends `${infer _Prefix}/:${infer Param}`
? ParseParamType<Param>
: {};
export type InferParamsFromPath<T extends string> =
T extends `${string}/:${string}` ? ExtractParams<T> : {};
export interface RoutePropsBase {
path?: string;
scrollUp?: boolean;
children?: React$1.ReactNode;
}
export type RouteProps<
T extends Record<string, string | number | boolean | Date> = {},
> = RoutePropsBase &
(
| {
component: React$1.FunctionComponent<T>;
render?: never;
}
| {
render: (params: T) => React$1.ReactNode;
component?: never;
}
| {
component?: never;
render?: never;
}
);
export type RouteType = <P extends string = string>(
props: RouteProps<InferParamsFromPath<P>> & {
path?: P;
},
) => React$1.ReactNode;
declare const _default$1: RouteType;
export type Query = Record<string, string | string[]>;
export type Url = {
path: string;
query: Query;
hash?: string;
params?: Params;
};
export type UrlSet = {
path?: string;
query?: Query;
hash?: string;
};
export type Params = Record<string, string | number | boolean | Date>;
export type SetUrlOptions = {
mode?: "push" | "replace";
};
export type NewUrlValue = Url | UrlSet | string;
export type SetUrl = (
newUrl: NewUrlValue | ((prev: Url) => NewUrlValue),
opts?: SetUrlOptions,
) => void;
export interface SwitchProps {
redirect?:
| string
| {
path: string;
}
| ((url: Url) => string);
children?: React$1.ReactNode;
}
declare const _default$2: ({
redirect,
children,
}: SwitchProps) => React$1.ReactElement | null;
declare const _default$3: import("react").Context<[Url, SetUrl] | undefined>;
declare const _default$4: () => [Url, SetUrl];
export type PathUpdater = (path: string) => string;
export type SetPath = (
path: string | PathUpdater,
opts?: SetUrlOptions,
) => void;
declare const _default$5: () => [string, SetPath];
export type QueryValue = string | string[] | undefined;
export type SetQueryProp = (
value: string | ((prev: QueryValue) => string),
opts?: SetUrlOptions,
) => void;
export type QueryUpdater = (query: Query) => Query | string;
export type SetQuery = (
newQuery: Query | string | QueryUpdater,
opts?: SetUrlOptions,
) => void;
export declare function useQuery(key: string): [QueryValue, SetQueryProp];
export declare function useQuery(): [Query, SetQuery];
export type HashUpdater = (hash: string | undefined) => string;
export type SetHash = (
hash: string | HashUpdater,
opts?: SetUrlOptions,
) => void;
declare const _default$6: () => [string | undefined, SetHash];
export declare function useParams(): Params;
export declare function useParams<T = string | number | boolean | Date>(
key: string,
): T;
export {
_default as default,
_default$1 as Route,
_default$2 as Switch,
_default$3 as Context,
_default$4 as useUrl,
_default$5 as usePath,
_default$6 as useHash,
};
export {};