@simonbackx/vue-app-navigation 2.19.0 → 2.19.1

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 CHANGED
@@ -1803,14 +1803,14 @@ function useNavigate() {
1803
1803
  const show = useShow();
1804
1804
  const showDetail = useShowDetail();
1805
1805
  const toRoute = async function(route, options) {
1806
- let componentProperties = (options == null ? void 0 : options.properties) ?? {};
1806
+ let componentProperties = (options == null ? void 0 : options.properties) ?? ("defaultProperties" in route && route.defaultProperties ? route.defaultProperties() : null) ?? {};
1807
1807
  let params = (options == null ? void 0 : options.params) ?? {};
1808
1808
  if (!(options == null ? void 0 : options.properties)) {
1809
1809
  if ("paramsToProps" in route) {
1810
1810
  componentProperties = route.paramsToProps((options == null ? void 0 : options.params) ?? {}, options == null ? void 0 : options.query);
1811
1811
  } else {
1812
1812
  if (options == null ? void 0 : options.params) {
1813
- throw new Error("Using route to a route that only has properties, no parameters. Use properties instead of params in navigate() for this route: " + route.url);
1813
+ console.error("Using route to a route that only has properties, no parameters. Use properties instead of params in navigate() for this route: " + route.url, route, options);
1814
1814
  }
1815
1815
  }
1816
1816
  }
@@ -1973,7 +1973,7 @@ function addCheckRoutesMountedHandler() {
1973
1973
  }
1974
1974
  });
1975
1975
  }
1976
- function defineRoutes(routes) {
1976
+ function defineRoutes(tmpRoutes) {
1977
1977
  const urlhelpers = useUrl();
1978
1978
  const navigate = useNavigate();
1979
1979
  const currentRoutes = getCurrentRoutes();
@@ -1981,19 +1981,19 @@ function defineRoutes(routes) {
1981
1981
  let hadRoutes = false;
1982
1982
  if (currentRoutes.value.length) {
1983
1983
  hadRoutes = true;
1984
- routes = [...currentRoutes.value, ...Array.isArray(routes) ? routes : []];
1984
+ tmpRoutes = [...currentRoutes.value, ...tmpRoutes];
1985
1985
  }
1986
- currentRoutes.value = Array.isArray(routes) ? routes : [];
1987
- if (hadRoutes) {
1986
+ currentRoutes.value = tmpRoutes;
1987
+ if (hadRoutes || tmpRoutes.length === 0) {
1988
1988
  return;
1989
1989
  }
1990
- async function handleRoutes(routes2) {
1991
- for (const route of routes2) {
1990
+ async function handleRoutes(routes) {
1991
+ for (const route of routes) {
1992
1992
  const result = urlhelpers.match(route.url, "params" in route ? route.params : {});
1993
1993
  if (result) {
1994
1994
  try {
1995
1995
  await navigate(route, {
1996
- params: result.params,
1996
+ params: "params" in route ? result.params : void 0,
1997
1997
  animated: false,
1998
1998
  adjustHistory: false,
1999
1999
  query: result.query,
@@ -2015,6 +2015,7 @@ function defineRoutes(routes) {
2015
2015
  return false;
2016
2016
  }
2017
2017
  const getDefaultRoute = ({ allowDetail } = { allowDetail: true }) => {
2018
+ const routes = currentRoutes.value;
2018
2019
  if (!Array.isArray(routes)) {
2019
2020
  return null;
2020
2021
  }
@@ -2046,12 +2047,10 @@ function defineRoutes(routes) {
2046
2047
  }
2047
2048
  };
2048
2049
  onCheckRoutes(async () => {
2049
- const routes2 = currentRoutes.value;
2050
- if (Array.isArray(routes2)) {
2051
- if (await handleRoutes(routes2)) {
2052
- setDefaultHandler();
2053
- return;
2054
- }
2050
+ const routes = currentRoutes.value;
2051
+ if (await handleRoutes(routes)) {
2052
+ setDefaultHandler();
2053
+ return;
2055
2054
  }
2056
2055
  setDefaultHandler();
2057
2056
  });
@@ -2585,7 +2584,6 @@ const navigationMethods = {
2585
2584
  };
2586
2585
  const NavigationMixin = {
2587
2586
  created() {
2588
- var _a;
2589
2587
  const definitions = {
2590
2588
  pop: usePop(),
2591
2589
  showDetail: useShowDetail(),
@@ -2605,10 +2603,6 @@ const NavigationMixin = {
2605
2603
  $url: useUrl(),
2606
2604
  $navigate: useNavigate()
2607
2605
  };
2608
- const navigationOptions = (_a = this.$options) == null ? void 0 : _a.navigation;
2609
- if (navigationOptions || this.customRoutes) {
2610
- defineRoutes((navigationOptions == null ? void 0 : navigationOptions.routes) ?? (this.customRoutes ? this.customRoutes.bind(this) : null) ?? []);
2611
- }
2612
2606
  injectHooks(this, definitions);
2613
2607
  },
2614
2608
  computed: {
@@ -1,10 +1,10 @@
1
1
  import { DefineComponent, Ref } from 'vue';
2
2
  import { default as NavigationController } from './NavigationController.vue';
3
3
  import { default as Popup } from './Popup.vue';
4
+ import { useNavigationController } from './useNavigationController';
4
5
  import { useSplitViewController } from './useSplitViewController';
5
6
  import { NavigationOptions, useCanDismiss, useCanPop, useDismiss, useFocused, useNavigate, usePop, usePresent, useShow, useShowDetail, useUrl } from './utils/navigationHooks';
6
7
  import { useModalStackComponent } from './utils/useModalStackComponent';
7
- import { useNavigationController } from './useNavigationController';
8
8
 
9
9
  /**
10
10
  * @returns To detect whether you are in a popup
@@ -63,7 +63,7 @@ export type NavigationOptions<T> = {
63
63
  routes?: Route<any>[];
64
64
  };
65
65
  export declare function usePop(): (options?: PopOptions) => Promise<void> | undefined;
66
- export declare function useNavigate(): <Props extends Record<string, unknown>, Params extends Record<string, unknown>>(prop1: string | Route<Props, Params>, prop2?: RouteNavigationOptions<Props, Params>) => Promise<void>;
66
+ export declare function useNavigate(): <Props, Params>(prop1: string | Route<Props, Params>, prop2?: RouteNavigationOptions<Props, Params>) => Promise<void>;
67
67
  export type DefaultRouteHandler = () => Promise<boolean>;
68
68
  /**
69
69
  * Return true when the route has been handled and other route checks should not be executed.
@@ -71,7 +71,7 @@ export type DefaultRouteHandler = () => Promise<boolean>;
71
71
  export type OnCheckRoutesHandler = () => Promise<void | boolean> | void | boolean;
72
72
  export declare function onCheckRoutes(handler: OnCheckRoutesHandler): void;
73
73
  export declare function onNotCheckRoutes(handler: OnCheckRoutesHandler): void;
74
- export declare function defineRoutes(routes: Route<any, any>[]): void;
74
+ export declare function defineRoutes(tmpRoutes: Route<any>[]): void;
75
75
  export declare function useCurrentHref(): Ref<string, string>;
76
76
  export declare function useCheckRoute(): <Params extends Record<string, unknown>>(prop1: string | Route<Params>, prop2?: RouteNavigationOptions<Params>) => boolean;
77
77
  export declare function normalizePushOptions(o: PushOptions | ComponentWithProperties, currentComponent: ComponentWithProperties | null, urlHelpers: ReturnType<typeof useUrl>): PushOptions;
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.19.0",
5
+ "version": "2.19.1",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./dist/index.js",