@tanstack/react-router 0.0.1-beta.262 → 0.0.1-beta.264
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/Matches.js.map +1 -1
- package/build/cjs/RouterProvider.js +1 -1
- package/build/cjs/RouterProvider.js.map +1 -1
- package/build/cjs/index.js +1 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/route.js +39 -0
- package/build/cjs/route.js.map +1 -1
- package/build/esm/index.js +40 -2
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +355 -355
- package/build/types/Matches.d.ts +1 -1
- package/build/types/route.d.ts +23 -2
- package/build/umd/index.development.js +40 -1
- 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/Matches.tsx +1 -1
- package/src/RouterProvider.tsx +1 -4
- package/src/route.ts +58 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.264",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://tanstack.com/router",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@tanstack/store": "^0.1.3",
|
|
45
45
|
"tiny-invariant": "^1.3.1",
|
|
46
46
|
"tiny-warning": "^1.0.3",
|
|
47
|
-
"@tanstack/history": "0.0.1-beta.
|
|
47
|
+
"@tanstack/history": "0.0.1-beta.264"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rollup --config rollup.config.js"
|
package/src/Matches.tsx
CHANGED
package/src/RouterProvider.tsx
CHANGED
|
@@ -178,10 +178,7 @@ function Transitioner() {
|
|
|
178
178
|
routerState.location!.href !== routerState.resolvedLocation?.href,
|
|
179
179
|
})
|
|
180
180
|
|
|
181
|
-
if (
|
|
182
|
-
routerState.location.hash !== routerState.resolvedLocation?.hash &&
|
|
183
|
-
(document as any).querySelector
|
|
184
|
-
) {
|
|
181
|
+
if ((document as any).querySelector) {
|
|
185
182
|
console.log('hello', routerState.location.hash)
|
|
186
183
|
const el = document.getElementById(
|
|
187
184
|
routerState.location.hash,
|
package/src/route.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { AnyRouteMatch } from './Matches'
|
|
|
6
6
|
import { NavigateOptions, ParsePathParams, ToSubOptions } from './link'
|
|
7
7
|
import { ParsedLocation } from './location'
|
|
8
8
|
import { joinPaths, trimPath } from './path'
|
|
9
|
-
import { RoutePaths } from './routeInfo'
|
|
10
|
-
import { AnyRouter } from './router'
|
|
9
|
+
import { RouteById, RouteIds, RoutePaths } from './routeInfo'
|
|
10
|
+
import { AnyRouter, RegisteredRouter } from './router'
|
|
11
11
|
import { useParams } from './useParams'
|
|
12
12
|
import { useSearch } from './useSearch'
|
|
13
13
|
import {
|
|
@@ -371,6 +371,58 @@ export type RouteConstraints = {
|
|
|
371
371
|
TRouteTree: AnyRoute
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
+
export class RouteApi<
|
|
375
|
+
TId extends RouteIds<RegisteredRouter['routeTree']>,
|
|
376
|
+
TRoute extends AnyRoute = RouteById<RegisteredRouter['routeTree'], TId>,
|
|
377
|
+
TFullSearchSchema extends Record<
|
|
378
|
+
string,
|
|
379
|
+
any
|
|
380
|
+
> = TRoute['types']['fullSearchSchema'],
|
|
381
|
+
TAllParams extends AnyPathParams = TRoute['types']['allParams'],
|
|
382
|
+
TAllContext extends Record<string, any> = TRoute['types']['allContext'],
|
|
383
|
+
TLoaderData extends any = TRoute['types']['loaderData'],
|
|
384
|
+
> {
|
|
385
|
+
id: TId
|
|
386
|
+
|
|
387
|
+
constructor({ id }: { id: TId }) {
|
|
388
|
+
this.id = id as any
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
useMatch = <TSelected = TAllContext>(opts?: {
|
|
392
|
+
select?: (search: TAllContext) => TSelected
|
|
393
|
+
}): TSelected => {
|
|
394
|
+
return useMatch({ ...opts, from: this.id }) as any
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
useRouteContext = <TSelected = TAllContext>(opts?: {
|
|
398
|
+
select?: (search: TAllContext) => TSelected
|
|
399
|
+
}): TSelected => {
|
|
400
|
+
return useMatch({
|
|
401
|
+
...opts,
|
|
402
|
+
from: this.id,
|
|
403
|
+
select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),
|
|
404
|
+
} as any)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
useSearch = <TSelected = TFullSearchSchema>(opts?: {
|
|
408
|
+
select?: (search: TFullSearchSchema) => TSelected
|
|
409
|
+
}): TSelected => {
|
|
410
|
+
return useSearch({ ...opts, from: this.id } as any)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
useParams = <TSelected = TAllParams>(opts?: {
|
|
414
|
+
select?: (search: TAllParams) => TSelected
|
|
415
|
+
}): TSelected => {
|
|
416
|
+
return useParams({ ...opts, from: this.id } as any)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
useLoaderData = <TSelected = TLoaderData>(opts?: {
|
|
420
|
+
select?: (search: TLoaderData) => TSelected
|
|
421
|
+
}): TSelected => {
|
|
422
|
+
return useLoaderData({ ...opts, from: this.id } as any) as any
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
374
426
|
export class Route<
|
|
375
427
|
TParentRoute extends RouteConstraints['TParentRoute'] = AnyRoute,
|
|
376
428
|
TPath extends RouteConstraints['TPath'] = '/',
|
|
@@ -590,6 +642,7 @@ export class Route<
|
|
|
590
642
|
}): TSelected => {
|
|
591
643
|
return useMatch({ ...opts, from: this.id }) as any
|
|
592
644
|
}
|
|
645
|
+
|
|
593
646
|
useRouteContext = <TSelected = TAllContext>(opts?: {
|
|
594
647
|
select?: (search: TAllContext) => TSelected
|
|
595
648
|
}): TSelected => {
|
|
@@ -599,16 +652,19 @@ export class Route<
|
|
|
599
652
|
select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),
|
|
600
653
|
} as any)
|
|
601
654
|
}
|
|
655
|
+
|
|
602
656
|
useSearch = <TSelected = TFullSearchSchema>(opts?: {
|
|
603
657
|
select?: (search: TFullSearchSchema) => TSelected
|
|
604
658
|
}): TSelected => {
|
|
605
659
|
return useSearch({ ...opts, from: this.id } as any)
|
|
606
660
|
}
|
|
661
|
+
|
|
607
662
|
useParams = <TSelected = TAllParams>(opts?: {
|
|
608
663
|
select?: (search: TAllParams) => TSelected
|
|
609
664
|
}): TSelected => {
|
|
610
665
|
return useParams({ ...opts, from: this.id } as any)
|
|
611
666
|
}
|
|
667
|
+
|
|
612
668
|
useLoaderData = <TSelected = TLoaderData>(opts?: {
|
|
613
669
|
select?: (search: TLoaderData) => TSelected
|
|
614
670
|
}): TSelected => {
|