@kitbag/router 0.13.4 → 0.14.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.
@@ -763,6 +763,10 @@ export declare type ResolvedRoute<TRoute extends Route = Route> = Readonly<{
763
763
  * Type for additional data intended to be stored in history state.
764
764
  */
765
765
  state: ExtractRouteStateParamsAsOptional<TRoute['state']>;
766
+ /**
767
+ * String value of the resolved URL.
768
+ */
769
+ href: Url;
766
770
  }>;
767
771
 
768
772
  declare type ResolvedRouteQuery = {
@@ -893,10 +897,6 @@ export declare type Router<TRoutes extends Routes = any, __TOptions extends Rout
893
897
  * Replaces the current entry in the history stack with a new one.
894
898
  */
895
899
  replace: RouterReplace<TRoutes>;
896
- /**
897
- * Finds a route object based on the provided lookup parameters.
898
- */
899
- find: RouterFind<TRoutes>;
900
900
  /**
901
901
  * Handles route rejection based on a specified rejection type.
902
902
  */
@@ -955,13 +955,6 @@ export declare type Router<TRoutes extends Routes = any, __TOptions extends Rout
955
955
  start: () => Promise<void>;
956
956
  };
957
957
 
958
- declare type RouterFind<TRoutes extends Routes> = {
959
- <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterFindArgs<TRoutes, TSource>): ResolvedRoute | undefined;
960
- (url: Url): ResolvedRoute | undefined;
961
- };
962
-
963
- declare type RouterFindArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams] : [params: TParams];
964
-
965
958
  declare type RouterHistoryMode = 'auto' | 'browser' | 'memory' | 'hash';
966
959
 
967
960
  /**
@@ -971,7 +964,7 @@ export declare const RouterLink: __VLS_WithTemplateSlots_2<DefineComponent< {
971
964
  /**
972
965
  * The url string to navigate to or a callback that returns a url string
973
966
  */
974
- to: Url | ((resolve: RegisteredRouter["resolve"]) => Url);
967
+ to: Url | ResolvedRoute | ToCallback;
975
968
  /**
976
969
  * Determines what assets are prefetched when router-link is rendered for this route. Overrides route level prefetch.
977
970
  */
@@ -980,7 +973,7 @@ prefetch?: PrefetchConfig;
980
973
  /**
981
974
  * The url string to navigate to or a callback that returns a url string
982
975
  */
983
- to: Url | ((resolve: RegisteredRouter["resolve"]) => Url);
976
+ to: Url | ResolvedRoute | ToCallback;
984
977
  /**
985
978
  * Determines what assets are prefetched when router-link is rendered for this route. Overrides route level prefetch.
986
979
  */
@@ -989,14 +982,14 @@ prefetch?: PrefetchConfig;
989
982
  prefetch: PrefetchConfig;
990
983
  }, {}, {}, {}, string, ComponentProvideOptions, false, {}>, Readonly<{
991
984
  default?: (props: {
992
- resolved: string;
985
+ route: ResolvedRoute | undefined;
993
986
  isMatch: boolean;
994
987
  isExactMatch: boolean;
995
988
  isExternal: boolean;
996
989
  }) => unknown;
997
990
  }> & {
998
991
  default?: (props: {
999
- resolved: string;
992
+ route: ResolvedRoute | undefined;
1000
993
  isMatch: boolean;
1001
994
  isExactMatch: boolean;
1002
995
  isExternal: boolean;
@@ -1068,7 +1061,7 @@ declare type RouterReplace<TRoutes extends Routes> = {
1068
1061
  (url: Url, options?: RouterReplaceOptions): Promise<void>;
1069
1062
  };
1070
1063
 
1071
- declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>] : [params: TParams, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>];
1064
+ declare type RouterReplaceArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterReplaceOptions<RouteStateByName<TRoutes, TSource>>];
1072
1065
 
1073
1066
  declare type RouterReplaceOptions<TState = unknown> = {
1074
1067
  query?: QuerySource;
@@ -1077,15 +1070,16 @@ declare type RouterReplaceOptions<TState = unknown> = {
1077
1070
  };
1078
1071
 
1079
1072
  declare type RouterResolve<TRoutes extends Routes> = {
1080
- <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterResolveArgs<TRoutes, TSource>): Url;
1081
- (url: Url, options?: RouterResolveOptions): Url;
1073
+ <TSource extends RoutesName<TRoutes>>(name: TSource, ...args: RouterResolveArgs<TRoutes, TSource>): ResolvedRoute | undefined;
1074
+ (url: Url, options?: RouterResolveOptions): ResolvedRoute | undefined;
1082
1075
  };
1083
1076
 
1084
- declare type RouterResolveArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>, TParams = RouteParamsByKey<TRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: TParams, options?: RouterResolveOptions] : [params: TParams, options?: RouterResolveOptions];
1077
+ declare type RouterResolveArgs<TRoutes extends Routes, TSource extends RoutesName<TRoutes>> = AllPropertiesAreOptional<RouteParamsByKey<TRoutes, TSource>> extends true ? [params?: RouteParamsByKey<TRoutes, TSource>, options?: RouterResolveOptions<RouteStateByName<TRoutes, TSource>>] : [params: RouteParamsByKey<TRoutes, TSource>, options?: RouterResolveOptions<RouteStateByName<TRoutes, TSource>>];
1085
1078
 
1086
- declare type RouterResolveOptions = {
1079
+ declare type RouterResolveOptions<TState = unknown> = {
1087
1080
  query?: QuerySource;
1088
1081
  hash?: string;
1082
+ state?: Partial<TState>;
1089
1083
  };
1090
1084
 
1091
1085
  declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
@@ -1095,6 +1089,7 @@ declare type RouterRoute<TRoute extends ResolvedRoute = ResolvedRoute> = {
1095
1089
  readonly matches: TRoute['matches'];
1096
1090
  readonly hash: TRoute['hash'];
1097
1091
  readonly update: RouteUpdate<TRoute>;
1092
+ readonly href: TRoute['href'];
1098
1093
  params: TRoute['params'];
1099
1094
  state: TRoute['state'];
1100
1095
  get query(): ResolvedRouteQuery;
@@ -1154,6 +1149,8 @@ declare type RouteWithMatch<TRoute extends RouterRoute, TRouteName extends TRout
1154
1149
 
1155
1150
  declare type StringHasValue<T> = string extends T ? true : '' extends T ? false : T extends string ? true : false;
1156
1151
 
1152
+ declare type ToCallback = (resolve: RegisteredRouter['resolve']) => ResolvedRoute | Url | undefined;
1153
+
1157
1154
  declare type ToHash<T extends string | Hash | undefined> = T extends string ? Hash<T> : T extends undefined ? Hash<''> : unknown extends T ? Hash<''> : T;
1158
1155
 
1159
1156
  declare type ToHost<T extends string | Host | undefined> = T extends string ? Host<T, {}> : T extends undefined ? Host<'', {}> : unknown extends T ? Host<'', {}> : T;
@@ -1187,7 +1184,7 @@ export declare type UseLink = {
1187
1184
  /**
1188
1185
  * Resolved URL with params interpolated and query applied. Same value as `router.resolve`.
1189
1186
  */
1190
- href: ComputedRef<string>;
1187
+ href: ComputedRef<Url | undefined>;
1191
1188
  /**
1192
1189
  * True if route matches current URL or is ancestor of route that matches current URL
1193
1190
  */
@@ -1225,6 +1222,10 @@ export declare function useLink<TRouteKey extends RegisteredRoutesName>(name: Ma
1225
1222
 
1226
1223
  export declare function useLink(url: MaybeRefOrGetter<Url>, options?: MaybeRefOrGetter<UseLinkOptions>): UseLink;
1227
1224
 
1225
+ export declare function useLink(resolvedRoute: MaybeRefOrGetter<ResolvedRoute | undefined>, options?: MaybeRefOrGetter<UseLinkOptions>): UseLink;
1226
+
1227
+ export declare function useLink(source: MaybeRefOrGetter<string | ResolvedRoute | undefined>, paramsOrOptions?: MaybeRefOrGetter<Record<PropertyKey, unknown> | UseLinkOptions>, maybeOptions?: MaybeRefOrGetter<UseLinkOptions>): UseLink;
1228
+
1228
1229
  declare type UseLinkArgs<TSource extends RegisteredRoutesName, TParams = RouteParamsByKey<RegisteredRoutes, TSource>> = AllPropertiesAreOptional<TParams> extends true ? [params?: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<UseLinkOptions>] : [params: MaybeRefOrGetter<TParams>, options?: MaybeRefOrGetter<UseLinkOptions>];
1229
1230
 
1230
1231
  export declare type UseLinkOptions = RouterResolveOptions & {