@tanstack/router-core 0.0.1-alpha.1 → 0.0.1-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js +30 -0
- package/build/cjs/node_modules/tiny-invariant/dist/esm/tiny-invariant.js.map +1 -0
- package/build/cjs/packages/router-core/src/index.js +35 -1421
- package/build/cjs/packages/router-core/src/index.js.map +1 -1
- package/build/cjs/packages/router-core/src/path.js +222 -0
- package/build/cjs/packages/router-core/src/path.js.map +1 -0
- package/build/cjs/packages/router-core/src/qss.js +1 -1
- package/build/cjs/packages/router-core/src/qss.js.map +1 -1
- package/build/cjs/packages/router-core/src/route.js +126 -0
- package/build/cjs/packages/router-core/src/route.js.map +1 -0
- package/build/cjs/packages/router-core/src/routeConfig.js +69 -0
- package/build/cjs/packages/router-core/src/routeConfig.js.map +1 -0
- package/build/cjs/packages/router-core/src/routeMatch.js +247 -0
- package/build/cjs/packages/router-core/src/routeMatch.js.map +1 -0
- package/build/cjs/packages/router-core/src/router.js +809 -0
- package/build/cjs/packages/router-core/src/router.js.map +1 -0
- package/build/cjs/packages/router-core/src/searchParams.js +70 -0
- package/build/cjs/packages/router-core/src/searchParams.js.map +1 -0
- package/build/cjs/packages/router-core/src/utils.js +118 -0
- package/build/cjs/packages/router-core/src/utils.js.map +1 -0
- package/build/esm/index.js +1350 -1231
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +388 -46
- package/build/types/index.d.ts +401 -343
- package/build/umd/index.development.js +1218 -1091
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/frameworks.ts +13 -0
- package/src/index.ts +15 -2969
- package/src/link.ts +291 -0
- package/src/path.ts +236 -0
- package/src/qss.ts +1 -1
- package/src/route.ts +181 -0
- package/src/routeConfig.ts +523 -0
- package/src/routeInfo.ts +228 -0
- package/src/routeMatch.ts +340 -0
- package/src/router.ts +1211 -0
- package/src/searchParams.ts +54 -0
- package/src/utils.ts +157 -0
- package/src/createRoutes.test.ts +0 -328
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { decode, encode } from './qss'
|
|
2
|
+
import { AnySearchSchema } from './routeConfig'
|
|
3
|
+
|
|
4
|
+
export const defaultParseSearch = parseSearchWith(JSON.parse)
|
|
5
|
+
export const defaultStringifySearch = stringifySearchWith(JSON.stringify)
|
|
6
|
+
|
|
7
|
+
export function parseSearchWith(parser: (str: string) => any) {
|
|
8
|
+
return (searchStr: string): AnySearchSchema => {
|
|
9
|
+
if (searchStr.substring(0, 1) === '?') {
|
|
10
|
+
searchStr = searchStr.substring(1)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let query: Record<string, unknown> = decode(searchStr)
|
|
14
|
+
|
|
15
|
+
// Try to parse any query params that might be json
|
|
16
|
+
for (let key in query) {
|
|
17
|
+
const value = query[key]
|
|
18
|
+
if (typeof value === 'string') {
|
|
19
|
+
try {
|
|
20
|
+
query[key] = parser(value)
|
|
21
|
+
} catch (err) {
|
|
22
|
+
//
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return query
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function stringifySearchWith(stringify: (search: any) => string) {
|
|
32
|
+
return (search: Record<string, any>) => {
|
|
33
|
+
search = { ...search }
|
|
34
|
+
|
|
35
|
+
if (search) {
|
|
36
|
+
Object.keys(search).forEach((key) => {
|
|
37
|
+
const val = search[key]
|
|
38
|
+
if (typeof val === 'undefined' || val === undefined) {
|
|
39
|
+
delete search[key]
|
|
40
|
+
} else if (val && typeof val === 'object' && val !== null) {
|
|
41
|
+
try {
|
|
42
|
+
search[key] = stringify(val)
|
|
43
|
+
} catch (err) {
|
|
44
|
+
// silent
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const searchStr = encode(search as Record<string, string>).toString()
|
|
51
|
+
|
|
52
|
+
return searchStr ? `?${searchStr}` : ''
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never]
|
|
2
|
+
export type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N
|
|
3
|
+
export type IsAnyBoolean<T> = 1 extends 0 & T ? true : false
|
|
4
|
+
export type IsKnown<T, Y, N> = unknown extends T ? N : Y
|
|
5
|
+
export type PickAsRequired<T, K extends keyof T> = Omit<T, K> &
|
|
6
|
+
Required<Pick<T, K>>
|
|
7
|
+
export type PickAsPartial<T, K extends keyof T> = Omit<T, K> &
|
|
8
|
+
Partial<Pick<T, K>>
|
|
9
|
+
export type PickUnsafe<T, K> = K extends keyof T ? Pick<T, K> : never
|
|
10
|
+
export type PickExtra<T, K> = Expand<{
|
|
11
|
+
[TKey in keyof K as string extends TKey
|
|
12
|
+
? never
|
|
13
|
+
: TKey extends keyof T
|
|
14
|
+
? never
|
|
15
|
+
: TKey]: K[TKey]
|
|
16
|
+
}>
|
|
17
|
+
export type PickRequired<T> = {
|
|
18
|
+
[K in keyof T as undefined extends T[K] ? never : K]: T[K]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Expand<T> = T extends object
|
|
22
|
+
? T extends infer O
|
|
23
|
+
? { [K in keyof O]: O[K] }
|
|
24
|
+
: never
|
|
25
|
+
: T
|
|
26
|
+
|
|
27
|
+
// type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
28
|
+
// k: infer I,
|
|
29
|
+
// ) => any
|
|
30
|
+
// ? I
|
|
31
|
+
// : never
|
|
32
|
+
|
|
33
|
+
export type Values<O> = O[ValueKeys<O>]
|
|
34
|
+
export type ValueKeys<O> = Extract<keyof O, PropertyKey>
|
|
35
|
+
|
|
36
|
+
export type DeepAwaited<T> = T extends Promise<infer A>
|
|
37
|
+
? DeepAwaited<A>
|
|
38
|
+
: T extends Record<infer A, Promise<infer B>>
|
|
39
|
+
? { [K in A]: DeepAwaited<B> }
|
|
40
|
+
: T
|
|
41
|
+
|
|
42
|
+
export type PathParamMask<TRoutePath extends string> =
|
|
43
|
+
TRoutePath extends `${infer L}/:${infer C}/${infer R}`
|
|
44
|
+
? PathParamMask<`${L}/${string}/${R}`>
|
|
45
|
+
: TRoutePath extends `${infer L}/:${infer C}`
|
|
46
|
+
? PathParamMask<`${L}/${string}`>
|
|
47
|
+
: TRoutePath
|
|
48
|
+
|
|
49
|
+
export type Timeout = ReturnType<typeof setTimeout>
|
|
50
|
+
|
|
51
|
+
export type Updater<TPrevious, TResult = TPrevious> =
|
|
52
|
+
| TResult
|
|
53
|
+
| ((prev?: TPrevious) => TResult)
|
|
54
|
+
|
|
55
|
+
export type PickExtract<T, U> = {
|
|
56
|
+
[K in keyof T as T[K] extends U ? K : never]: T[K]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type PickExclude<T, U> = {
|
|
60
|
+
[K in keyof T as T[K] extends U ? never : K]: T[K]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* This function returns `a` if `b` is deeply equal.
|
|
65
|
+
* If not, it will replace any deeply equal children of `b` with those of `a`.
|
|
66
|
+
* This can be used for structural sharing between JSON values for example.
|
|
67
|
+
*/
|
|
68
|
+
export function replaceEqualDeep(prev: any, next: any) {
|
|
69
|
+
if (prev === next) {
|
|
70
|
+
return prev
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const array = Array.isArray(prev) && Array.isArray(next)
|
|
74
|
+
|
|
75
|
+
if (array || (isPlainObject(prev) && isPlainObject(next))) {
|
|
76
|
+
const aSize = array ? prev.length : Object.keys(prev).length
|
|
77
|
+
const bItems = array ? next : Object.keys(next)
|
|
78
|
+
const bSize = bItems.length
|
|
79
|
+
const copy: any = array ? [] : {}
|
|
80
|
+
|
|
81
|
+
let equalItems = 0
|
|
82
|
+
|
|
83
|
+
for (let i = 0; i < bSize; i++) {
|
|
84
|
+
const key = array ? i : bItems[i]
|
|
85
|
+
copy[key] = replaceEqualDeep(prev[key], next[key])
|
|
86
|
+
if (copy[key] === prev[key]) {
|
|
87
|
+
equalItems++
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return aSize === bSize && equalItems === aSize ? prev : copy
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return next
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Copied from: https://github.com/jonschlinkert/is-plain-object
|
|
98
|
+
function isPlainObject(o: any) {
|
|
99
|
+
if (!hasObjectPrototype(o)) {
|
|
100
|
+
return false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// If has modified constructor
|
|
104
|
+
const ctor = o.constructor
|
|
105
|
+
if (typeof ctor === 'undefined') {
|
|
106
|
+
return true
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// If has modified prototype
|
|
110
|
+
const prot = ctor.prototype
|
|
111
|
+
if (!hasObjectPrototype(prot)) {
|
|
112
|
+
return false
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// If constructor does not have an Object-specific method
|
|
116
|
+
if (!prot.hasOwnProperty('isPrototypeOf')) {
|
|
117
|
+
return false
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Most likely a plain Object
|
|
121
|
+
return true
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function hasObjectPrototype(o: any) {
|
|
125
|
+
return Object.prototype.toString.call(o) === '[object Object]'
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function last<T>(arr: T[]) {
|
|
129
|
+
return arr[arr.length - 1]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function warning(cond: any, message: string): cond is true {
|
|
133
|
+
if (cond) {
|
|
134
|
+
if (typeof console !== 'undefined') console.warn(message)
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
throw new Error(message)
|
|
138
|
+
} catch {}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function isFunction(d: any): d is Function {
|
|
145
|
+
return typeof d === 'function'
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function functionalUpdate<TResult>(
|
|
149
|
+
updater: Updater<TResult>,
|
|
150
|
+
previous: TResult,
|
|
151
|
+
) {
|
|
152
|
+
if (isFunction(updater)) {
|
|
153
|
+
return updater(previous as TResult)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return updater
|
|
157
|
+
}
|
package/src/createRoutes.test.ts
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { Route } from '@tanstack/router-core'
|
|
2
|
-
import { z } from 'zod'
|
|
3
|
-
import {
|
|
4
|
-
createRouter,
|
|
5
|
-
AllRouteInfo,
|
|
6
|
-
createRouteConfig,
|
|
7
|
-
RelativeToPathAutoComplete,
|
|
8
|
-
} from '.'
|
|
9
|
-
|
|
10
|
-
// Write a test
|
|
11
|
-
describe('everything', () => {
|
|
12
|
-
it('should work', () => {
|
|
13
|
-
// Build our routes. We could do this in our component, too.
|
|
14
|
-
const routeConfig = createRouteConfig().addChildren((createRoute) => [
|
|
15
|
-
createRoute({
|
|
16
|
-
path: '/',
|
|
17
|
-
validateSearch: (search) =>
|
|
18
|
-
z
|
|
19
|
-
.object({
|
|
20
|
-
version: z.number(),
|
|
21
|
-
})
|
|
22
|
-
.parse(search),
|
|
23
|
-
}),
|
|
24
|
-
createRoute({
|
|
25
|
-
path: '/test',
|
|
26
|
-
validateSearch: (search) =>
|
|
27
|
-
z
|
|
28
|
-
.object({
|
|
29
|
-
version: z.number(),
|
|
30
|
-
isGood: z.boolean(),
|
|
31
|
-
})
|
|
32
|
-
.parse(search),
|
|
33
|
-
}),
|
|
34
|
-
createRoute({
|
|
35
|
-
path: 'dashboard',
|
|
36
|
-
loader: async () => {
|
|
37
|
-
console.log('Fetching all invoices...')
|
|
38
|
-
return {
|
|
39
|
-
invoices: 'await fetchInvoices()',
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
}).addChildren((createRoute) => [
|
|
43
|
-
createRoute({ path: '/' }),
|
|
44
|
-
createRoute({
|
|
45
|
-
path: 'invoices',
|
|
46
|
-
}).addChildren((createRoute) => [
|
|
47
|
-
createRoute({
|
|
48
|
-
path: '/',
|
|
49
|
-
action: async (partialInvoice: { amount: number }) => {
|
|
50
|
-
const invoice: { id: number; amount: number } = null!
|
|
51
|
-
// // Redirect to the new invoice
|
|
52
|
-
// ctx.router.navigate({
|
|
53
|
-
// to: invoice.id,
|
|
54
|
-
// // Use the current match for relative paths
|
|
55
|
-
// from: ctx.match.pathname,
|
|
56
|
-
// })
|
|
57
|
-
return invoice
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
60
|
-
createRoute({
|
|
61
|
-
path: ':invoiceId',
|
|
62
|
-
parseParams: ({ invoiceId }) => ({ invoiceId: Number(invoiceId) }),
|
|
63
|
-
stringifyParams: ({ invoiceId }) => ({
|
|
64
|
-
invoiceId: String(invoiceId),
|
|
65
|
-
}),
|
|
66
|
-
loader: async ({ params: { invoiceId } }) => {
|
|
67
|
-
console.log('Fetching invoice...')
|
|
68
|
-
return {
|
|
69
|
-
invoice: 'await fetchInvoiceById(invoiceId!)',
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
}),
|
|
73
|
-
]),
|
|
74
|
-
createRoute({
|
|
75
|
-
path: 'users',
|
|
76
|
-
loader: async () => {
|
|
77
|
-
return {
|
|
78
|
-
users: 'await fetchUsers()',
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
validateSearch: (search) =>
|
|
82
|
-
z
|
|
83
|
-
.object({
|
|
84
|
-
usersView: z
|
|
85
|
-
.object({
|
|
86
|
-
sortBy: z.enum(['name', 'id', 'email']).optional(),
|
|
87
|
-
filterBy: z.string().optional(),
|
|
88
|
-
})
|
|
89
|
-
.optional(),
|
|
90
|
-
})
|
|
91
|
-
.parse(search),
|
|
92
|
-
preSearchFilters: [
|
|
93
|
-
// Keep the usersView search param around
|
|
94
|
-
// while in this route (or it's children!)
|
|
95
|
-
(search) => ({
|
|
96
|
-
...search,
|
|
97
|
-
usersView: {
|
|
98
|
-
...search.usersView,
|
|
99
|
-
},
|
|
100
|
-
}),
|
|
101
|
-
],
|
|
102
|
-
}).addChildren((createRoute) => [
|
|
103
|
-
createRoute({
|
|
104
|
-
path: ':userId',
|
|
105
|
-
loader: async ({ params: { userId }, search }) => {
|
|
106
|
-
return {
|
|
107
|
-
user: 'await fetchUserById(userId!)',
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
action: async (partialUser: { amount: number }) => {
|
|
111
|
-
const invoice: { id: number; amount: number } = null!
|
|
112
|
-
// // Redirect to the new invoice
|
|
113
|
-
// ctx.router.navigate({
|
|
114
|
-
// to: invoice.id,
|
|
115
|
-
// // Use the current match for relative paths
|
|
116
|
-
// from: ctx.match.pathname,
|
|
117
|
-
// })
|
|
118
|
-
return invoice
|
|
119
|
-
},
|
|
120
|
-
}),
|
|
121
|
-
]),
|
|
122
|
-
]),
|
|
123
|
-
// Obviously, you can put routes in other files, too
|
|
124
|
-
// reallyExpensiveRoute,
|
|
125
|
-
createRoute({
|
|
126
|
-
path: 'authenticated/', // Trailing slash doesn't mean anything
|
|
127
|
-
}).addChildren((createRoute) => [
|
|
128
|
-
createRoute({
|
|
129
|
-
path: '/',
|
|
130
|
-
}),
|
|
131
|
-
]),
|
|
132
|
-
])
|
|
133
|
-
|
|
134
|
-
type MyRoutesInfo = AllRouteInfo<typeof routeConfig>
|
|
135
|
-
// ^?
|
|
136
|
-
type RouteInfo = MyRoutesInfo['routeInfo']
|
|
137
|
-
type RoutesById = MyRoutesInfo['routeInfoById']
|
|
138
|
-
type RoutesTest = Route<
|
|
139
|
-
MyRoutesInfo,
|
|
140
|
-
MyRoutesInfo['routeInfoByFullPath']['/']
|
|
141
|
-
>
|
|
142
|
-
// ^?
|
|
143
|
-
type RoutePaths = MyRoutesInfo['routeInfoByFullPath']
|
|
144
|
-
// ^?
|
|
145
|
-
type InvoiceRouteInfo = RoutesById['/dashboard/invoices/']
|
|
146
|
-
// ^?
|
|
147
|
-
type InvoiceLoaderData = InvoiceRouteInfo['loaderData']
|
|
148
|
-
// ^?//
|
|
149
|
-
type InvoiceAction = InvoiceRouteInfo['actionPayload']
|
|
150
|
-
// ^?
|
|
151
|
-
|
|
152
|
-
const router = createRouter({
|
|
153
|
-
routeConfig,
|
|
154
|
-
})
|
|
155
|
-
|
|
156
|
-
const loaderData = router.getRoute('/dashboard/users/:userId')
|
|
157
|
-
// ^?
|
|
158
|
-
const route = router.getRoute('/dashboard/users/:userId')
|
|
159
|
-
// ^?
|
|
160
|
-
const action = route.action
|
|
161
|
-
// ^?
|
|
162
|
-
const result = action.submit({ amount: 10000 })
|
|
163
|
-
// ^?
|
|
164
|
-
|
|
165
|
-
router.buildLink({
|
|
166
|
-
to: '/dashboard/users/:userId',
|
|
167
|
-
params: {
|
|
168
|
-
userId: '2',
|
|
169
|
-
},
|
|
170
|
-
search: (prev) => ({
|
|
171
|
-
usersView: {
|
|
172
|
-
sortBy: 'email',
|
|
173
|
-
},
|
|
174
|
-
}),
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
// @ts-expect-error
|
|
178
|
-
router.buildLink({
|
|
179
|
-
from: '/',
|
|
180
|
-
to: '/test',
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
router.buildLink({
|
|
184
|
-
from: '/',
|
|
185
|
-
to: '/test',
|
|
186
|
-
search: () => {
|
|
187
|
-
return {
|
|
188
|
-
version: 2,
|
|
189
|
-
isGood: true,
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
router.buildLink({
|
|
195
|
-
from: '/test',
|
|
196
|
-
to: '/',
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
route.buildLink({
|
|
200
|
-
to: '',
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
router.getRoute('/dashboard').buildLink({
|
|
204
|
-
to: '/dashboard/invoices',
|
|
205
|
-
params: {
|
|
206
|
-
// @ts-expect-error
|
|
207
|
-
invoiceId: 2,
|
|
208
|
-
},
|
|
209
|
-
})
|
|
210
|
-
|
|
211
|
-
router.getRoute('/dashboard').buildLink({
|
|
212
|
-
to: '/dashboard/invoices/:invoiceId',
|
|
213
|
-
params: {
|
|
214
|
-
// @ts-expect-error
|
|
215
|
-
invoiceId: '2',
|
|
216
|
-
},
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
router.getRoute('/').buildLink({
|
|
220
|
-
to: '/dashboard/invoices/:invoiceId',
|
|
221
|
-
params: {
|
|
222
|
-
invoiceId: 2,
|
|
223
|
-
},
|
|
224
|
-
})
|
|
225
|
-
|
|
226
|
-
router.getRoute('/').buildLink({
|
|
227
|
-
to: '/',
|
|
228
|
-
search: {
|
|
229
|
-
version: 2,
|
|
230
|
-
},
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
router.getRoute('/').buildLink({
|
|
234
|
-
to: '/dashboard/users/:userId',
|
|
235
|
-
params: (current) => ({
|
|
236
|
-
userId:
|
|
237
|
-
// @ts-expect-error
|
|
238
|
-
current?.invoiceId,
|
|
239
|
-
}),
|
|
240
|
-
search: (old) => ({
|
|
241
|
-
usersView: {
|
|
242
|
-
sortBy: 'email' as const,
|
|
243
|
-
filterBy: String(old.version),
|
|
244
|
-
},
|
|
245
|
-
}),
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
router.getRoute('/dashboard/invoices/:invoiceId').buildLink({
|
|
249
|
-
to: '/dashboard/users/:userId',
|
|
250
|
-
params: (current) => ({
|
|
251
|
-
userId: `${current?.invoiceId}`,
|
|
252
|
-
}),
|
|
253
|
-
search: (prev) => {
|
|
254
|
-
return {
|
|
255
|
-
usersView: {
|
|
256
|
-
sortBy: 'name' as const,
|
|
257
|
-
filterBy: 'tanner',
|
|
258
|
-
},
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
})
|
|
262
|
-
|
|
263
|
-
router.getRoute('/dashboard/users/:userId').buildLink({
|
|
264
|
-
to: '/',
|
|
265
|
-
search: (prev) => {
|
|
266
|
-
return {
|
|
267
|
-
version: 2,
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
})
|
|
271
|
-
|
|
272
|
-
router.buildLink({
|
|
273
|
-
from: '/',
|
|
274
|
-
to: '/dashboard/users/:userId',
|
|
275
|
-
params: {
|
|
276
|
-
userId: '2',
|
|
277
|
-
},
|
|
278
|
-
search: (prev) => ({
|
|
279
|
-
usersView: {
|
|
280
|
-
sortBy: 'id',
|
|
281
|
-
filterBy: `${prev.version}`,
|
|
282
|
-
},
|
|
283
|
-
}),
|
|
284
|
-
})
|
|
285
|
-
|
|
286
|
-
router.getRoute('/').navigate({
|
|
287
|
-
// to: '.',
|
|
288
|
-
// TODO: What the heck? Why is any required here?
|
|
289
|
-
search: (prev: any) => ({
|
|
290
|
-
version: prev.version,
|
|
291
|
-
}),
|
|
292
|
-
})
|
|
293
|
-
|
|
294
|
-
router.buildLink({
|
|
295
|
-
from: '/dashboard/invoices',
|
|
296
|
-
to: '/dashboard',
|
|
297
|
-
})
|
|
298
|
-
|
|
299
|
-
router.getRoute('/').buildLink({
|
|
300
|
-
to: '/dashboard/invoices/:invoiceId',
|
|
301
|
-
params: {
|
|
302
|
-
invoiceId: 2,
|
|
303
|
-
},
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
router.getRoute('/dashboard/invoices/:invoiceId').buildLink({
|
|
307
|
-
to: '.',
|
|
308
|
-
params: (d) => ({
|
|
309
|
-
invoiceId: d.invoiceId,
|
|
310
|
-
}),
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
type test = RelativeToPathAutoComplete<
|
|
314
|
-
// ^?
|
|
315
|
-
MyRoutesInfo['fullPath'],
|
|
316
|
-
'/dashboard/invoices',
|
|
317
|
-
'..'
|
|
318
|
-
>
|
|
319
|
-
|
|
320
|
-
router.getRoute('/dashboard/invoices/:invoiceId').buildLink({
|
|
321
|
-
to: '../test',
|
|
322
|
-
search: {
|
|
323
|
-
version: 2,
|
|
324
|
-
isGood: true,
|
|
325
|
-
},
|
|
326
|
-
})
|
|
327
|
-
})
|
|
328
|
-
})
|