@simonbackx/vue-app-navigation 2.2.0 → 2.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/dist/index.d.ts +1 -0
- package/dist/index.js +15 -0
- package/dist/src/utils/navigationHooks.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as ComponentWithPropertiesInstance } from './src/ComponentWithP
|
|
|
3
3
|
export { default as FramedComponent } from './src/FramedComponent.vue';
|
|
4
4
|
export * from './src/HistoryManager';
|
|
5
5
|
export { default as ModalStackComponent } from './src/ModalStackComponent.vue';
|
|
6
|
+
export { useModalStackComponent } from './src/ModalStackComponent.vue';
|
|
6
7
|
export * from './src/ModalStackComponentFinderMixin';
|
|
7
8
|
export { default as NavigationController } from './src/NavigationController.vue';
|
|
8
9
|
export { useNavigationController } from './src/NavigationController.vue';
|
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,
|
|
@@ -2911,6 +2925,7 @@ export {
|
|
|
2911
2925
|
useCurrentHref,
|
|
2912
2926
|
useDismiss,
|
|
2913
2927
|
useFocused,
|
|
2928
|
+
useModalStackComponent,
|
|
2914
2929
|
useNavigate,
|
|
2915
2930
|
useNavigationController,
|
|
2916
2931
|
usePop,
|
|
@@ -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;
|