kdu-router 3.4.0-beta.0 → 3.6.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.
Files changed (49) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +11 -9
  3. package/dist/composables.js +253 -0
  4. package/dist/composables.mjs +244 -0
  5. package/dist/kdu-router.common.js +2682 -2572
  6. package/dist/kdu-router.esm.browser.js +2677 -2563
  7. package/dist/kdu-router.esm.browser.min.js +5 -5
  8. package/dist/kdu-router.esm.js +2685 -2572
  9. package/dist/kdu-router.js +2682 -2573
  10. package/dist/kdu-router.min.js +5 -5
  11. package/ketur/attributes.json +38 -38
  12. package/ketur/tags.json +20 -20
  13. package/package.json +115 -111
  14. package/src/components/link.js +224 -197
  15. package/src/components/view.js +155 -149
  16. package/src/composables/globals.js +34 -0
  17. package/src/composables/guards.js +68 -0
  18. package/src/composables/index.js +3 -0
  19. package/src/composables/useLink.js +113 -0
  20. package/src/composables/utils.js +11 -0
  21. package/src/create-matcher.js +226 -200
  22. package/src/create-route-map.js +220 -205
  23. package/src/entries/cjs.js +3 -0
  24. package/src/entries/esm.js +12 -0
  25. package/src/history/abstract.js +72 -68
  26. package/src/history/base.js +379 -400
  27. package/src/history/hash.js +152 -163
  28. package/src/history/html5.js +99 -94
  29. package/src/index.js +3 -277
  30. package/src/install.js +52 -52
  31. package/src/router.js +293 -0
  32. package/src/util/async.js +18 -18
  33. package/src/util/dom.js +3 -3
  34. package/src/util/errors.js +86 -85
  35. package/src/util/location.js +69 -69
  36. package/src/util/misc.js +6 -6
  37. package/src/util/params.js +37 -37
  38. package/src/util/path.js +74 -74
  39. package/src/util/push-state.js +46 -46
  40. package/src/util/query.js +113 -96
  41. package/src/util/resolve-components.js +109 -109
  42. package/src/util/route.js +151 -132
  43. package/src/util/scroll.js +175 -165
  44. package/src/util/state-key.js +22 -22
  45. package/src/util/warn.js +14 -14
  46. package/types/composables.d.ts +53 -0
  47. package/types/index.d.ts +25 -17
  48. package/types/kdu.d.ts +22 -22
  49. package/types/router.d.ts +564 -170
package/types/router.d.ts CHANGED
@@ -1,170 +1,564 @@
1
- import Kdu, { ComponentOptions, PluginFunction, AsyncComponent } from 'kdu'
2
-
3
- type Component = ComponentOptions<Kdu> | typeof Kdu | AsyncComponent
4
- type Dictionary<T> = { [key: string]: T }
5
- type ErrorHandler = (err: Error) => void
6
-
7
- export type RouterMode = 'hash' | 'history' | 'abstract'
8
- export type RawLocation = string | Location
9
- export type RedirectOption = RawLocation | ((to: Route) => RawLocation)
10
- export type NavigationGuardNext<V extends Kdu = Kdu> = (
11
- to?: RawLocation | false | ((vm: V) => any) | void
12
- ) => void
13
-
14
- export type NavigationGuard<V extends Kdu = Kdu> = (
15
- to: Route,
16
- from: Route,
17
- next: NavigationGuardNext<V>
18
- ) => any
19
-
20
- export declare class KduRouter {
21
- constructor(options?: RouterOptions)
22
-
23
- app: Kdu
24
- options: RouterOptions;
25
- mode: RouterMode
26
- currentRoute: Route
27
-
28
- beforeEach(guard: NavigationGuard): Function
29
- beforeResolve(guard: NavigationGuard): Function
30
- afterEach(hook: (to: Route, from: Route) => any): Function
31
- push(location: RawLocation): Promise<Route>
32
- replace(location: RawLocation): Promise<Route>
33
- push(
34
- location: RawLocation,
35
- onComplete?: Function,
36
- onAbort?: ErrorHandler
37
- ): void
38
- replace(
39
- location: RawLocation,
40
- onComplete?: Function,
41
- onAbort?: ErrorHandler
42
- ): void
43
- go(n: number): void
44
- back(): void
45
- forward(): void
46
- getMatchedComponents(to?: RawLocation | Route): Component[]
47
- onReady(cb: Function, errorCb?: ErrorHandler): void
48
- onError(cb: ErrorHandler): void
49
- addRoutes(routes: RouteConfig[]): void
50
- resolve(
51
- to: RawLocation,
52
- current?: Route,
53
- append?: boolean
54
- ): {
55
- location: Location
56
- route: Route
57
- href: string
58
- // backwards compat
59
- normalizedTo: Location
60
- resolved: Route
61
- }
62
-
63
- static install: PluginFunction<never>
64
- static version: string
65
-
66
- static isNavigationFailure: (error: any, type?: NavigationFailureTypeE) => error is Error
67
- static NavigationFailureType: NavigationFailureTypeE
68
- }
69
-
70
- export enum NavigationFailureTypeE {
71
- redirected = 1,
72
- aborted = 2,
73
- cancelled = 3,
74
- duplicated = 4
75
- }
76
-
77
- type Position = { x: number; y: number }
78
- type PositionResult = Position | { selector: string; offset?: Position } | void
79
-
80
- export interface RouterOptions {
81
- routes?: RouteConfig[]
82
- mode?: RouterMode
83
- fallback?: boolean
84
- base?: string
85
- linkActiveClass?: string
86
- linkExactActiveClass?: string
87
- parseQuery?: (query: string) => Object
88
- stringifyQuery?: (query: Object) => string
89
- scrollBehavior?: (
90
- to: Route,
91
- from: Route,
92
- savedPosition: Position | void
93
- ) => PositionResult | Promise<PositionResult> | undefined | null
94
- }
95
-
96
- type RoutePropsFunction = (route: Route) => Object
97
-
98
- export interface PathToRegexpOptions {
99
- sensitive?: boolean
100
- strict?: boolean
101
- end?: boolean
102
- }
103
-
104
- interface _RouteConfigBase {
105
- path: string
106
- name?: string
107
- children?: RouteConfig[]
108
- redirect?: RedirectOption
109
- alias?: string | string[]
110
- meta?: any
111
- beforeEnter?: NavigationGuard
112
- caseSensitive?: boolean
113
- pathToRegexpOptions?: PathToRegexpOptions
114
- }
115
-
116
- interface RouteConfigSingleView extends _RouteConfigBase {
117
- component?: Component
118
- props?: boolean | Object | RoutePropsFunction
119
- }
120
-
121
- interface RouteConfigMultipleViews extends _RouteConfigBase {
122
- components?: Dictionary<Component>
123
- props?: Dictionary<boolean | Object | RoutePropsFunction>
124
- }
125
-
126
- export type RouteConfig = RouteConfigSingleView | RouteConfigMultipleViews
127
-
128
- export interface RouteRecord {
129
- path: string
130
- regex: RegExp
131
- components: Dictionary<Component>
132
- instances: Dictionary<Kdu>
133
- name?: string
134
- parent?: RouteRecord
135
- redirect?: RedirectOption
136
- matchAs?: string
137
- meta: any
138
- beforeEnter?: (
139
- route: Route,
140
- redirect: (location: RawLocation) => void,
141
- next: () => void
142
- ) => any
143
- props:
144
- | boolean
145
- | Object
146
- | RoutePropsFunction
147
- | Dictionary<boolean | Object | RoutePropsFunction>
148
- }
149
-
150
- export interface Location {
151
- name?: string
152
- path?: string
153
- hash?: string
154
- query?: Dictionary<string | (string | null)[] | null | undefined>
155
- params?: Dictionary<string>
156
- append?: boolean
157
- replace?: boolean
158
- }
159
-
160
- export interface Route {
161
- path: string
162
- name?: string | null
163
- hash: string
164
- query: Dictionary<string | (string | null)[]>
165
- params: Dictionary<string>
166
- fullPath: string
167
- matched: RouteRecord[]
168
- redirectedFrom?: string
169
- meta?: any
170
- }
1
+ import Kdu, { ComponentOptions, PluginFunction, AsyncComponent, KNode } from 'kdu'
2
+
3
+ type Component = ComponentOptions<Kdu> | typeof Kdu | AsyncComponent
4
+ type Dictionary<T> = { [key: string]: T }
5
+ type ErrorHandler = (err: Error) => void
6
+
7
+ export type RouterMode = 'hash' | 'history' | 'abstract'
8
+ export type RawLocation = string | Location
9
+ export type RedirectOption = RawLocation | ((to: Route) => RawLocation)
10
+ export type NavigationGuardNext<V extends Kdu = Kdu> = (
11
+ to?: RawLocation | false | ((vm: V) => any) | void
12
+ ) => void
13
+
14
+ export type NavigationGuard<V extends Kdu = Kdu> = (
15
+ to: Route,
16
+ from: Route,
17
+ next: NavigationGuardNext<V>
18
+ ) => any
19
+
20
+ /**
21
+ * Router instance.
22
+ */
23
+ export declare class KduRouter {
24
+ constructor(options?: RouterOptions)
25
+
26
+ app: Kdu
27
+ /**
28
+ * Original options object passed to create the Router
29
+ */
30
+ options: RouterOptions
31
+ /**
32
+ * Configured mode when creating the Router instance.
33
+ */
34
+ mode: RouterMode
35
+ /**
36
+ * Current {@link Route}
37
+ */
38
+ currentRoute: Route
39
+
40
+ /**
41
+ * Add a navigation guard that executes before any navigation.
42
+ *
43
+ * @param guard - navigation guard to add
44
+ * @returns a function that removes the registered guard
45
+ *
46
+ * @example
47
+ * ```js
48
+ * router.beforeEach((to, from, next) => {
49
+ * // must call `next`
50
+ * })
51
+ * ```
52
+ */
53
+ beforeEach(guard: NavigationGuard): () => void
54
+ /**
55
+ * Add a navigation guard that executes before navigation is about to be resolved. At this state all component have
56
+ * been fetched and other navigation guards have been successful.
57
+ *
58
+ * @param guard - navigation guard to add
59
+ * @returns a function that removes the registered guard
60
+ *
61
+ * @example
62
+ * ```js
63
+ * router.beforeResolve((to, from, next) => {
64
+ * // must call `next`
65
+ * })
66
+ * ```
67
+ */
68
+ beforeResolve(guard: NavigationGuard): () => void
69
+ /**
70
+ * Add a navigation hook that is executed after every navigation. Returns a function that removes the registered hook.
71
+ *
72
+ * @param hook - navigation hook to add
73
+ * @returns a function that removes the registered guard
74
+ *
75
+ * @example
76
+ * ```js
77
+ * router.afterEach((to, from) => {
78
+ * console.log('after navigation')
79
+ * })
80
+ * ```
81
+ */
82
+ afterEach(hook: (to: Route, from: Route) => any): () => void
83
+ /**
84
+ * Programmatically navigate to a new URL by pushing an entry in the history stack.
85
+ *
86
+ * @param to Route location to navigate to
87
+ */
88
+ push(to: RawLocation): Promise<Route>
89
+ /**
90
+ * Programmatically navigate to a new URL by pushing an entry in the history stack.
91
+ *
92
+ * @param to Route location to navigate to
93
+ * @param onComplete Navigation success callback
94
+ * @param onAbort Navigation aborted callback
95
+ */
96
+ push(
97
+ to: RawLocation,
98
+ onComplete?: (route: Route) => void,
99
+ onAbort?: ErrorHandler
100
+ ): void
101
+ /**
102
+ * Programmatically navigate to a new URL by replacing the current entry in the history stack.
103
+ *
104
+ * @param to Route location to navigate to
105
+ */
106
+ replace(to: RawLocation): Promise<Route>
107
+ /**
108
+ * Programmatically navigate to a new URL by replacing the current entry in the history stack.
109
+ *
110
+ * @param to Route location to navigate to
111
+ * @param onComplete Navigation success callback
112
+ * @param onAbort Navigation aborted callback
113
+ */
114
+ replace(
115
+ to: RawLocation,
116
+ onComplete?: (route: Route) => void,
117
+ onAbort?: ErrorHandler
118
+ ): void
119
+ /**
120
+ * Allows you to move forward or backward through the history. Calls `history.go()`.
121
+ *
122
+ * @param delta The position in the history to which you want to move, relative to the current page
123
+ */
124
+ go(n: number): void
125
+ /**
126
+ * Go back in history if possible by calling `history.back()`. Equivalent to `router.go(-1)`.
127
+ */
128
+ back(): void
129
+ /**
130
+ * Go forward in history if possible by calling `history.forward()`. Equivalent to `router.go(1)`.
131
+ */
132
+ forward(): void
133
+ match (raw: RawLocation, current?: Route, redirectedFrom?: Location): Route
134
+ getMatchedComponents(to?: RawLocation | Route): Component[]
135
+ /**
136
+ * This method queues a callback to be called when the router has completed the initial navigation, which means it has
137
+ * resolved all async enter hooks and async components that are associated with the initial route.
138
+ *
139
+ * This is useful in server-side rendering to ensure consistent output on both the server and the client.
140
+ * @param cb onReady callback.
141
+ * @param errorCb errorCb will be called when the initial route resolution runs into an error (e.g. failed to resolve
142
+ * an async component).
143
+ */
144
+ onReady(cb: () => void, errorCb?: ErrorHandler): void
145
+ /**
146
+ * Adds an error handler that is called every time a non caught error happens during navigation. This includes errors
147
+ * thrown synchronously and asynchronously, errors returned or passed to `next` in any navigation guard, and errors
148
+ * occurred when trying to resolve an async component that is required to render a route.
149
+ *
150
+ * @param handler - error handler to register
151
+ */
152
+ onError(cb: ErrorHandler): void
153
+ /**
154
+ * @deprecated use {@link addRoute | router.addRoute()} instead
155
+ */
156
+ addRoutes(routes: RouteConfig[]): void
157
+ /**
158
+ * Add a new {@link RouteConfig | route record} as the child of an existing route. If the route has a `name` and there
159
+ * is already an existing one with the same one, it overwrites it.
160
+ *
161
+ * @param parentName - Parent Route Record where `route` should be appended at
162
+ * @param route - Route Record to add
163
+ */
164
+ addRoute(parentName: string, route: RouteConfig): void
165
+ /**
166
+ * Add a new {@link RouteConfig | route} to the router. If the route has a `name` and there is already an existing one
167
+ * with the same one, it overwrites it.
168
+ * @param route - Route Record to add
169
+ */
170
+ addRoute(route: RouteConfig): void
171
+ /**
172
+ * Get the list of all the active route records.
173
+ */
174
+ getRoutes(): RouteRecordPublic[]
175
+
176
+ /**
177
+ *
178
+ * @param to Route location
179
+ * @param current current is the current Route by default (most of the time you don't need to change this)
180
+ * @param append allows you to append the path to the `current` route (as with `router-link`)
181
+ */
182
+ resolve(
183
+ to: RawLocation,
184
+ current?: Route,
185
+ append?: boolean
186
+ ): {
187
+ location: Location
188
+ route: Route
189
+ href: string
190
+ /**
191
+ * backwards compat
192
+ */
193
+ normalizedTo: Location
194
+ /**
195
+ * backwards compat
196
+ */
197
+ resolved: Route
198
+ }
199
+ /**
200
+ * @internal
201
+ */
202
+ static install: PluginFunction<never>
203
+ static version: string
204
+
205
+ static isNavigationFailure: typeof isNavigationFailure
206
+ static NavigationFailureType: {
207
+ [k in keyof typeof NavigationFailureType]: NavigationFailureType
208
+ }
209
+
210
+ static START_LOCATION: Route
211
+ }
212
+
213
+ /**
214
+ * Enumeration with all possible types for navigation failures.
215
+ *
216
+ * Can be passed to {@link isNavigationFailure} to check for specific failures.
217
+ */
218
+ export enum NavigationFailureType {
219
+ /**
220
+ * @internal
221
+ */
222
+ redirected = 2,
223
+ /**
224
+ * An aborted navigation is a navigation that failed because a navigation guard returned `false` or called
225
+ * `next(false)`
226
+ */
227
+ aborted = 4,
228
+ /**
229
+ * A cancelled navigation is a navigation that failed because a more recent navigation finished started (not
230
+ * necessarily finished).
231
+ */
232
+ cancelled = 8,
233
+ /**
234
+ * A duplicated navigation is a navigation that failed because it was initiated while already being at the exact same
235
+ * location.
236
+ */
237
+ duplicated = 16
238
+ }
239
+
240
+ /**
241
+ * Extended Error that contains extra information regarding a failed navigation.
242
+ */
243
+ export interface NavigationFailure extends Error {
244
+ /**
245
+ * Route location we were navigating from
246
+ */
247
+ from: Route
248
+ /**
249
+ * Route location we were navigating to
250
+ */
251
+ to: Route
252
+ /**
253
+ * Type of the navigation. One of {@link NavigationFailureType}
254
+ */
255
+ type: NavigationFailureType.aborted | NavigationFailureType.cancelled | NavigationFailureType.duplicated
256
+ }
257
+
258
+ /**
259
+ * Check if an object is a {@link NavigationFailure}.
260
+ */
261
+ export declare function isNavigationFailure(error: any, type?: NavigationFailureType): error is NavigationFailure
262
+
263
+ type Position = { x: number; y: number }
264
+ type PositionResult = Position | { selector: string; offset?: Position, behavior?: ScrollBehavior } | void
265
+
266
+
267
+ /**
268
+ * Options to initialize a {@link KduRouter} instance.
269
+ */
270
+ export interface RouterOptions {
271
+ routes?: RouteConfig[]
272
+ /**
273
+ * Configure the router mode.
274
+ *
275
+ * default: `"hash"` (in browser) | `"abstract"` (in Node.js)
276
+ *
277
+ * available values: `"hash" | "history" | "abstract"`
278
+ * - `"hash"`: uses the URL hash for routing. Works in all Kdu-supported browsers, including those that do not support
279
+ * HTML5 History API.
280
+ * - `"history"`: requires HTML5 History API and server config. See HTML5 History Mode.
281
+ * - `"abstract"`: works in all JavaScript environments, e.g. server-side with Node.js. **The router will
282
+ * automatically be forced into this mode if no browser API is present.**
283
+ */
284
+ mode?: RouterMode
285
+ fallback?: boolean
286
+ base?: string
287
+ /**
288
+ * Default class applied to active {@link RouterLink}. If none is provided, `router-link-active` will be applied.
289
+ */
290
+ linkActiveClass?: string
291
+ /**
292
+ * Default class applied to active {@link RouterLink}. If none is provided, `router-link-exact-active` will be
293
+ * applied.
294
+ */
295
+ linkExactActiveClass?: string
296
+ /**
297
+ * Custom implementation to parse a query. See its counterpart, {@link stringifyQuery}.
298
+ */
299
+ parseQuery?: (query: string) => Object
300
+ /**
301
+ * Custom implementation to stringify a query object. Should not prepend a leading `?`. {@link parseQuery} counterpart
302
+ * to handle query parsing.
303
+ */
304
+ stringifyQuery?: (query: Object) => string
305
+ /**
306
+ * Function to control scrolling when navigating between pages. Can return a Promise to delay scrolling.
307
+ *
308
+ * For more details see {@link Scroll Behavior}.
309
+ */
310
+ scrollBehavior?: (
311
+ to: Route,
312
+ from: Route,
313
+ savedPosition: Position | void
314
+ ) => PositionResult | Promise<PositionResult> | undefined | null
315
+ }
316
+
317
+ type RoutePropsFunction = (route: Route) => Object
318
+
319
+ export interface PathToRegexpOptions {
320
+ sensitive?: boolean
321
+ strict?: boolean
322
+ end?: boolean
323
+ }
324
+
325
+ interface _RouteConfigBase {
326
+ path: string
327
+ name?: string
328
+ children?: RouteConfig[]
329
+ redirect?: RedirectOption
330
+ alias?: string | string[]
331
+ meta?: RouteMeta
332
+ beforeEnter?: NavigationGuard
333
+ caseSensitive?: boolean
334
+ pathToRegexpOptions?: PathToRegexpOptions
335
+ }
336
+
337
+ interface RouteConfigSingleView extends _RouteConfigBase {
338
+ component?: Component
339
+ props?: boolean | Object | RoutePropsFunction
340
+ }
341
+
342
+ interface RouteConfigMultipleViews extends _RouteConfigBase {
343
+ components?: Dictionary<Component>
344
+ props?: Dictionary<boolean | Object | RoutePropsFunction>
345
+ }
346
+
347
+ export type RouteConfig = RouteConfigSingleView | RouteConfigMultipleViews
348
+
349
+ export interface RouteRecord {
350
+ path: string
351
+ regex: RegExp
352
+ components: Dictionary<Component>
353
+ instances: Dictionary<Kdu>
354
+ name?: string
355
+ parent?: RouteRecord
356
+ redirect?: RedirectOption
357
+ matchAs?: string
358
+ meta: RouteMeta
359
+ beforeEnter?: (
360
+ route: Route,
361
+ redirect: (location: RawLocation) => void,
362
+ next: () => void
363
+ ) => any
364
+ props:
365
+ | boolean
366
+ | Object
367
+ | RoutePropsFunction
368
+ | Dictionary<boolean | Object | RoutePropsFunction>
369
+ }
370
+
371
+ export interface RouteRecordPublic {
372
+ path: string
373
+ components: Dictionary<Component>
374
+ instances: Dictionary<Kdu>
375
+ name?: string
376
+ redirect?: RedirectOption
377
+ meta: any
378
+ beforeEnter?: (
379
+ route: Route,
380
+ redirect: (location: RawLocation) => void,
381
+ next: () => void
382
+ ) => any
383
+ props:
384
+ | boolean
385
+ | Object
386
+ | RoutePropsFunction
387
+ | Dictionary<boolean | Object | RoutePropsFunction>
388
+ }
389
+
390
+
391
+ export interface Location {
392
+ name?: string
393
+ path?: string
394
+ hash?: string
395
+ query?: Dictionary<string | (string | null)[] | null | undefined>
396
+ params?: Dictionary<string>
397
+ append?: boolean
398
+ replace?: boolean
399
+ }
400
+
401
+ export interface Route {
402
+ path: string
403
+ name?: string | null
404
+ hash: string
405
+ query: Dictionary<string | (string | null)[]>
406
+ params: Dictionary<string>
407
+ fullPath: string
408
+ matched: RouteRecord[]
409
+ redirectedFrom?: string
410
+ meta?: RouteMeta
411
+ }
412
+
413
+ export interface RouteMeta extends Record<string | number | symbol, any> {}
414
+
415
+ export interface RouterLinkProps {
416
+ /**
417
+ * Denotes the target route of the link. When clicked, the value of the `to` prop will be passed to
418
+ * `router.push()` internally, so the value can be either a string or a location descriptor object.
419
+ */
420
+ to: string | Location
421
+ /**
422
+ * Setting `replace` prop will call `router.replace()` instead of `router.push()` when clicked, so the navigation will
423
+ * not create a new history record.
424
+ *
425
+ * @default false
426
+ */
427
+ replace?: boolean
428
+ /**
429
+ * Setting `append` prop always appends the relative path to the current path. For example, assuming we are navigating
430
+ * from `/a` to a relative link `b`, without `append` we will end up at `/b`, but with append we will end up at
431
+ * `/a/b`.
432
+ *
433
+ * @default false
434
+ */
435
+ append?: boolean
436
+ /**
437
+ * Sometimes we want <RouterLink> to render as another tag, e.g <li>. Then we can use tag prop to specify which tag to
438
+ * render to, and it will still listen to click events for navigation.
439
+ *
440
+ * @default "a"
441
+ */
442
+ tag?: string
443
+ /**
444
+ * Configure the active CSS class applied when the link is active. Note the default value can also be configured
445
+ * globally via the `linkActiveClass` router constructor option.
446
+ *
447
+ * @default "router-link-active"
448
+ */
449
+ activeClass?: string
450
+ /**
451
+ * The default active class matching behavior is **inclusive match**. For example, `<RouterLink to="/a">` will get
452
+ * this class applied as long as the current path starts with `/a/` or is `/a`.
453
+ *
454
+ * @default false
455
+ */
456
+ exact?: boolean
457
+ /**
458
+ * Allows matching only using the `path` section of the url, effectively ignoring the `query` and the `hash` sections.
459
+ *
460
+ * @default false
461
+ */
462
+ exactPath?: boolean
463
+ /**
464
+ * Configure the active CSS class applied when the link is active with exact path match. Note the default value can
465
+ * also be configured globally via the `linkExactPathActiveClass` router constructor option.
466
+ *
467
+ * @default "router-link-exact-path-active"
468
+ */
469
+ exactPathActiveClass?: string
470
+
471
+ /**
472
+ * Specify the event(s) that can trigger the link navigation.
473
+ *
474
+ * @default 'click'
475
+ */
476
+ event?: string | ReadonlyArray<string>
477
+ /**
478
+ * Configure the active CSS class applied when the link is active with exact match. Note the default value can also be
479
+ * configured globally via the `linkExactActiveClass` router constructor option.
480
+ *
481
+ * @default "router-link-exact-active"
482
+ */
483
+ exactActiveClass?: string
484
+ /**
485
+ * Configure the value of `aria-current` when the link is active with exact match. It must be one of the allowed
486
+ * values for [aria-current](https://www.w3.org/TR/wai-aria-1.2/#aria-current) in the ARIA spec. In most cases, the
487
+ * default of page should be the best fit.
488
+ *
489
+ * @default "page"
490
+ */
491
+ ariaCurrentValue?:
492
+ | 'page'
493
+ | 'step'
494
+ | 'location'
495
+ | 'date'
496
+ | 'time'
497
+ | 'true'
498
+ | 'false'
499
+ }
500
+
501
+ export interface RouterLinkSlotArgument {
502
+ /**
503
+ * resolved url. This would be the `href` attribute of an `a` element
504
+ */
505
+ href: string
506
+ /**
507
+ * resolved normalized location
508
+ */
509
+ route: Route
510
+ /**
511
+ * function to trigger the navigation. It will automatically prevent events when necessary, the same way `RouterLink`
512
+ * does
513
+ */
514
+ navigate: (e?: MouseEvent) => Promise<undefined | NavigationFailure>
515
+ /**
516
+ * `true` if the [active class](https://kdujs-router-v3.web.app/api/#active-class) should be applied. Allows to apply an
517
+ * arbitrary class
518
+ */
519
+ isActive: boolean
520
+ /**
521
+ * `true` if the [exact active class](https://kdujs-router-v3.web.app/api/#exact-active-class) should be applied. Allows
522
+ * to apply an arbitrary class
523
+ */
524
+ isExactActive: boolean
525
+ }
526
+
527
+ /**
528
+ * Component to render a link that triggers a navigation on click.
529
+ */
530
+ export declare const RouterLink: new () => {
531
+ $props: RouterLinkProps
532
+ $scopedSlots: {
533
+ default?: ({
534
+ href,
535
+ route,
536
+ navigate,
537
+ isActive,
538
+ isExactActive
539
+ }: RouterLinkSlotArgument) => KNode[] | undefined
540
+ }
541
+ }
542
+
543
+ export interface RouterViewProps {
544
+ /**
545
+ * When a {@link RouterView | `<RouterView />`} has a name, it will render the component with the corresponding name
546
+ * in the matched route record's components option. See [Named
547
+ * Views](https://kdujs-router-v3.web.app/guide/essentials/named-views.html) for an example.
548
+ *
549
+ * @default "default"
550
+ */
551
+ name?: string
552
+ }
553
+
554
+ /**
555
+ * Component to display the current route the user is at.
556
+ */
557
+ export declare const RouterView: new () => {
558
+ $props: RouterViewProps
559
+ }
560
+
561
+ /**
562
+ * Initial route location where the router is. Can be used in navigation guards to differentiate the initial navigation.
563
+ */
564
+ export declare const START_LOCATION: Route