@ydant/router 0.1.0 → 0.1.1
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 +14 -11
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,16 +11,16 @@ pnpm add @ydant/router
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { RouterView, RouterLink,
|
|
14
|
+
import { mount, type Component } from "@ydant/core";
|
|
15
|
+
import { createBasePlugin, div, nav, text } from "@ydant/base";
|
|
16
|
+
import { RouterView, RouterLink, getRoute, navigate } from "@ydant/router";
|
|
17
17
|
|
|
18
18
|
// Define pages
|
|
19
19
|
const HomePage: Component = () => div(() => [text("Home Page")]);
|
|
20
20
|
|
|
21
21
|
const UserPage: Component = () =>
|
|
22
22
|
div(function* () {
|
|
23
|
-
const route =
|
|
23
|
+
const route = getRoute();
|
|
24
24
|
yield* text(`User ID: ${route.params.id}`);
|
|
25
25
|
});
|
|
26
26
|
|
|
@@ -45,7 +45,9 @@ const App: Component = () =>
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
mount(App, document.getElementById("app")
|
|
48
|
+
mount(App, document.getElementById("app")!, {
|
|
49
|
+
plugins: [createBasePlugin()],
|
|
50
|
+
});
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
## API
|
|
@@ -53,7 +55,7 @@ mount(App, document.getElementById("app")!);
|
|
|
53
55
|
### RouterView
|
|
54
56
|
|
|
55
57
|
```typescript
|
|
56
|
-
function RouterView(props: RouterViewProps):
|
|
58
|
+
function RouterView(props: RouterViewProps): Render;
|
|
57
59
|
|
|
58
60
|
interface RouterViewProps {
|
|
59
61
|
routes: RouteDefinition[];
|
|
@@ -98,21 +100,21 @@ When a guard returns or resolves to `false`, the route is blocked and an empty v
|
|
|
98
100
|
### RouterLink
|
|
99
101
|
|
|
100
102
|
```typescript
|
|
101
|
-
function RouterLink(props: RouterLinkProps):
|
|
103
|
+
function RouterLink(props: RouterLinkProps): Render;
|
|
102
104
|
|
|
103
105
|
interface RouterLinkProps {
|
|
104
106
|
href: string;
|
|
105
|
-
children: () =>
|
|
107
|
+
children: () => Instruction;
|
|
106
108
|
activeClass?: string;
|
|
107
109
|
}
|
|
108
110
|
```
|
|
109
111
|
|
|
110
112
|
Creates a navigation link that updates the URL without page reload.
|
|
111
113
|
|
|
112
|
-
###
|
|
114
|
+
### getRoute
|
|
113
115
|
|
|
114
116
|
```typescript
|
|
115
|
-
function
|
|
117
|
+
function getRoute(): RouteInfo;
|
|
116
118
|
|
|
117
119
|
interface RouteInfo {
|
|
118
120
|
path: string;
|
|
@@ -154,4 +156,5 @@ Navigate through browser history.
|
|
|
154
156
|
- `matching.ts` - Path matching utilities
|
|
155
157
|
- `state.ts` - Route state management
|
|
156
158
|
- `navigation.ts` - Navigation functions
|
|
157
|
-
- `
|
|
159
|
+
- `RouterView.ts` - RouterView component
|
|
160
|
+
- `RouterLink.ts` - RouterLink component
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ydant/router",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Router for Ydant SPA applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"navigation",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@ydant/base": "0.1.
|
|
43
|
-
"@ydant/core": "0.1.
|
|
42
|
+
"@ydant/base": "0.1.2",
|
|
43
|
+
"@ydant/core": "0.1.1"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "vite build",
|