@real-router/angular 0.2.2 → 0.4.0
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/README.md +27 -1
- package/dist/README.md +27 -1
- package/dist/fesm2022/real-router-angular.mjs +392 -203
- package/dist/fesm2022/real-router-angular.mjs.map +1 -1
- package/dist/types/real-router-angular.d.ts +20 -3
- package/dist/types/real-router-angular.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/RouteView.ts +14 -0
- package/src/directives/RouteSelf.ts +6 -0
- package/src/dom-utils/index.ts +7 -0
- package/src/dom-utils/scroll-restore.ts +217 -0
- package/src/index.ts +2 -0
- package/src/providers.ts +31 -3
package/README.md
CHANGED
|
@@ -337,6 +337,32 @@ export class AppComponent {}
|
|
|
337
337
|
|
|
338
338
|
The announcer creates a visually hidden `aria-live` region and announces each navigation to screen readers. See the [Accessibility guide](https://github.com/greydragon888/real-router/wiki/Accessibility) for details.
|
|
339
339
|
|
|
340
|
+
## Scroll Restoration
|
|
341
|
+
|
|
342
|
+
Opt-in via the `provideRealRouter` options bag:
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { provideRealRouter } from "@real-router/angular";
|
|
346
|
+
|
|
347
|
+
bootstrapApplication(AppComponent, {
|
|
348
|
+
providers: [
|
|
349
|
+
provideRealRouter(router, {
|
|
350
|
+
scrollRestoration: { mode: "restore" },
|
|
351
|
+
}),
|
|
352
|
+
],
|
|
353
|
+
});
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
`RealRouterOptions` shape:
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
interface RealRouterOptions {
|
|
360
|
+
scrollRestoration?: ScrollRestorationOptions; // { mode?, anchorScrolling?, scrollContainer? }
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Restores scroll on back/forward, scrolls to top (or `#hash`) on push. Three modes: `"restore"` (default), `"top"`, `"manual"`. Custom containers via `scrollContainer: () => HTMLElement | null`. The utility is created by `provideEnvironmentInitializer` and torn down via `inject(DestroyRef)`. Options are a snapshot at bootstrap — not reactive to runtime changes. See [Scroll Restoration guide](https://github.com/greydragon888/real-router/wiki/Scroll-Restoration) for details.
|
|
365
|
+
|
|
340
366
|
## Angular-Specific Patterns
|
|
341
367
|
|
|
342
368
|
### Signals, Not Observables
|
|
@@ -433,7 +459,7 @@ const transitionSignal = sourceToSignal(createTransitionSource(router));
|
|
|
433
459
|
|
|
434
460
|
Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
435
461
|
|
|
436
|
-
- [RouterProvider](https://github.com/greydragon888/real-router/wiki/RouterProvider) · [RouteView](https://github.com/greydragon888/real-router/wiki/RouteView) · [RouterErrorBoundary](https://github.com/greydragon888/real-router/wiki/RouterErrorBoundary)
|
|
462
|
+
- [RouterProvider](https://github.com/greydragon888/real-router/wiki/RouterProvider) · [RouteView](https://github.com/greydragon888/real-router/wiki/RouteView) · [RouterErrorBoundary](https://github.com/greydragon888/real-router/wiki/RouterErrorBoundary) · [Scroll Restoration](https://github.com/greydragon888/real-router/wiki/Scroll-Restoration)
|
|
437
463
|
- [injectRouter](https://github.com/greydragon888/real-router/wiki/injectRouter) · [injectRoute](https://github.com/greydragon888/real-router/wiki/injectRoute) · [injectRouteNode](https://github.com/greydragon888/real-router/wiki/injectRouteNode) · [injectNavigator](https://github.com/greydragon888/real-router/wiki/injectNavigator) · [injectRouteUtils](https://github.com/greydragon888/real-router/wiki/injectRouteUtils) · [injectRouterTransition](https://github.com/greydragon888/real-router/wiki/injectRouterTransition)
|
|
438
464
|
|
|
439
465
|
## Related Packages
|
package/dist/README.md
CHANGED
|
@@ -337,6 +337,32 @@ export class AppComponent {}
|
|
|
337
337
|
|
|
338
338
|
The announcer creates a visually hidden `aria-live` region and announces each navigation to screen readers. See the [Accessibility guide](https://github.com/greydragon888/real-router/wiki/Accessibility) for details.
|
|
339
339
|
|
|
340
|
+
## Scroll Restoration
|
|
341
|
+
|
|
342
|
+
Opt-in via the `provideRealRouter` options bag:
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
import { provideRealRouter } from "@real-router/angular";
|
|
346
|
+
|
|
347
|
+
bootstrapApplication(AppComponent, {
|
|
348
|
+
providers: [
|
|
349
|
+
provideRealRouter(router, {
|
|
350
|
+
scrollRestoration: { mode: "restore" },
|
|
351
|
+
}),
|
|
352
|
+
],
|
|
353
|
+
});
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
`RealRouterOptions` shape:
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
interface RealRouterOptions {
|
|
360
|
+
scrollRestoration?: ScrollRestorationOptions; // { mode?, anchorScrolling?, scrollContainer? }
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Restores scroll on back/forward, scrolls to top (or `#hash`) on push. Three modes: `"restore"` (default), `"top"`, `"manual"`. Custom containers via `scrollContainer: () => HTMLElement | null`. The utility is created by `provideEnvironmentInitializer` and torn down via `inject(DestroyRef)`. Options are a snapshot at bootstrap — not reactive to runtime changes. See [Scroll Restoration guide](https://github.com/greydragon888/real-router/wiki/Scroll-Restoration) for details.
|
|
365
|
+
|
|
340
366
|
## Angular-Specific Patterns
|
|
341
367
|
|
|
342
368
|
### Signals, Not Observables
|
|
@@ -433,7 +459,7 @@ const transitionSignal = sourceToSignal(createTransitionSource(router));
|
|
|
433
459
|
|
|
434
460
|
Full documentation: [Wiki](https://github.com/greydragon888/real-router/wiki)
|
|
435
461
|
|
|
436
|
-
- [RouterProvider](https://github.com/greydragon888/real-router/wiki/RouterProvider) · [RouteView](https://github.com/greydragon888/real-router/wiki/RouteView) · [RouterErrorBoundary](https://github.com/greydragon888/real-router/wiki/RouterErrorBoundary)
|
|
462
|
+
- [RouterProvider](https://github.com/greydragon888/real-router/wiki/RouterProvider) · [RouteView](https://github.com/greydragon888/real-router/wiki/RouteView) · [RouterErrorBoundary](https://github.com/greydragon888/real-router/wiki/RouterErrorBoundary) · [Scroll Restoration](https://github.com/greydragon888/real-router/wiki/Scroll-Restoration)
|
|
437
463
|
- [injectRouter](https://github.com/greydragon888/real-router/wiki/injectRouter) · [injectRoute](https://github.com/greydragon888/real-router/wiki/injectRoute) · [injectRouteNode](https://github.com/greydragon888/real-router/wiki/injectRouteNode) · [injectNavigator](https://github.com/greydragon888/real-router/wiki/injectNavigator) · [injectRouteUtils](https://github.com/greydragon888/real-router/wiki/injectRouteUtils) · [injectRouterTransition](https://github.com/greydragon888/real-router/wiki/injectRouterTransition)
|
|
438
464
|
|
|
439
465
|
## Related Packages
|