@simonbackx/vue-app-navigation 2.1.1 → 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.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './src/PopOptions';
11
11
  export { default as Popup } from './src/Popup.vue';
12
12
  export * from './src/PushOptions';
13
13
  export { default as SplitViewController } from './src/SplitViewController.vue';
14
+ export { useSplitViewController } from './src/SplitViewController.vue';
14
15
  export { default as StackComponent } from './src/StackComponent.vue';
15
16
  export * from './src/utils/injectHooks';
16
17
  export * from './src/utils/navigationHooks';
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();
@@ -1843,7 +1847,7 @@ function defineRoutes(routes) {
1843
1847
  }
1844
1848
  }
1845
1849
  try {
1846
- if (await defaultHandler({ allowDetail: true })) {
1850
+ if (await defaultHandler({ allowDetail: false })) {
1847
1851
  return true;
1848
1852
  }
1849
1853
  } catch (e) {
@@ -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,
@@ -2918,5 +2932,6 @@ export {
2918
2932
  usePresent,
2919
2933
  useShow,
2920
2934
  useShowDetail,
2935
+ useSplitViewController,
2921
2936
  useUrl
2922
2937
  };
@@ -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;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@simonbackx/vue-app-navigation",
3
3
  "main": "./dist/index.js",
4
4
  "types": "./dist/index.d.ts",
5
- "version": "2.1.1",
5
+ "version": "2.3.0",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./dist/index.js",