@simonbackx/vue-app-navigation 2.2.0 → 2.3.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/dist/index.js +14 -0
- package/dist/src/utils/navigationHooks.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1814,6 +1814,10 @@ function getCurrentRoutes() {
|
|
|
1814
1814
|
};
|
|
1815
1815
|
});
|
|
1816
1816
|
}
|
|
1817
|
+
function onCheckRoutes(handler) {
|
|
1818
|
+
const instance = getCurrentInstance();
|
|
1819
|
+
instance._navigationCheckRoutesHandlers = [...instance._navigationCheckRoutes, handler];
|
|
1820
|
+
}
|
|
1817
1821
|
function defineRoutes(routes) {
|
|
1818
1822
|
const component = useCurrentComponent();
|
|
1819
1823
|
const urlhelpers = useUrl();
|
|
@@ -1886,6 +1890,15 @@ function defineRoutes(routes) {
|
|
|
1886
1890
|
onMounted(async () => {
|
|
1887
1891
|
if (component && component.checkRoutes) {
|
|
1888
1892
|
component.checkRoutes = false;
|
|
1893
|
+
if ("_navigationCheckRoutesHandlers" in component && Array.isArray(component._navigationCheckRoutesHandlers)) {
|
|
1894
|
+
for (const handler of component._navigationCheckRoutesHandlers) {
|
|
1895
|
+
if (typeof handler === "function") {
|
|
1896
|
+
await handler();
|
|
1897
|
+
} else {
|
|
1898
|
+
console.error("Invalid checkRoutes handler", handler);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1889
1902
|
if (Array.isArray(routes)) {
|
|
1890
1903
|
if (await handleRoutes(routes)) {
|
|
1891
1904
|
setDefaultHandler();
|
|
@@ -2901,6 +2914,7 @@ export {
|
|
|
2901
2914
|
matchPath,
|
|
2902
2915
|
matchQuery,
|
|
2903
2916
|
normalizePushOptions,
|
|
2917
|
+
onCheckRoutes,
|
|
2904
2918
|
setTitle,
|
|
2905
2919
|
setTitleSuffix,
|
|
2906
2920
|
templateToUrl,
|
|
@@ -66,6 +66,8 @@ export type NavigationOptions<T> = {
|
|
|
66
66
|
export declare function usePop(): (options?: PopOptions) => Promise<void> | undefined;
|
|
67
67
|
export declare function useNavigate(): <Params extends Record<string, unknown>>(prop1: string | Route<Params, unknown>, prop2?: RouteNavigationOptions<Params>) => Promise<void>;
|
|
68
68
|
export type DefaultRouteHandler = () => Promise<boolean>;
|
|
69
|
+
export type OnCheckRoutesHandler = () => Promise<void> | void;
|
|
70
|
+
export declare function onCheckRoutes(handler: OnCheckRoutesHandler): void;
|
|
69
71
|
export declare function defineRoutes(routes: (Route<any, undefined>[]) | (() => Promise<boolean | (Route<any, undefined>[])>)): void;
|
|
70
72
|
export declare function useCurrentHref(): Ref<string>;
|
|
71
73
|
export declare function useCheckRoute(): <Params extends Record<string, unknown>>(prop1: string | Route<Params, unknown>, prop2?: RouteNavigationOptions<Params>) => boolean;
|