@ionic/react-router 9.0.10-dev.11793383958.19a7d413 → 9.0.10-dev.11794405764.178328c1

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
@@ -1,7 +1,8 @@
1
1
  import React, { useRef, useState, useEffect, useCallback } from 'react';
2
- import { Route, matchPath as matchPath$1, Routes, Navigate, UNSAFE_RouteContext, matchRoutes, useLocation, useNavigate, BrowserRouter, useNavigationType, MemoryRouter, HashRouter } from 'react-router-dom';
2
+ import { Route, matchPath as matchPath$1, Routes, Navigate, UNSAFE_RouteContext, matchRoutes, useLocation, useNavigate, BrowserRouter, useNavigationType, HashRouter } from 'react-router-dom';
3
3
  import { IonRoute, ViewStacks, generateId, ViewLifeCycleManager, createDebugLogger, StackContext, RouteManagerContext, getConfig, LocationHistory, NavManager } from '@ionic/react';
4
4
  import { LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_DID_ENTER } from '@ionic/core/components';
5
+ import { MemoryRouter, useLocation as useLocation$1, useNavigationType as useNavigationType$1 } from 'react-router';
5
6
 
6
7
  const IonRouteInner = ({ path, index, caseSensitive, element }) => {
7
8
  return React.createElement(Route, { path: path, index: index, caseSensitive: caseSensitive, element: element });
@@ -645,16 +646,14 @@ const getFallbackParamsFromViewItems = (allViewItems, currentOutletId, currentPa
645
646
  return params;
646
647
  };
647
648
  /**
648
- * Builds the matches array for RouteContext. The leaf `pathname` uses the absolute base,
649
- * because the raw match is relative for a route without a leading slash, which breaks
650
- * relative links, and includes a splat's tail, which loops an index `<Navigate>`.
649
+ * Builds the matches array for RouteContext.
651
650
  */
652
- const buildContextMatches = (parentMatches, combinedParams, absolutePathnameBase, viewItem, routeElement, componentElement) => {
651
+ const buildContextMatches = (parentMatches, combinedParams, routeMatch, routeInfoPathname, absolutePathnameBase, viewItem, routeElement, componentElement) => {
653
652
  return [
654
653
  ...parentMatches,
655
654
  {
656
655
  params: combinedParams,
657
- pathname: absolutePathnameBase,
656
+ pathname: routeMatch?.pathname || routeInfoPathname,
658
657
  pathnameBase: absolutePathnameBase,
659
658
  route: {
660
659
  id: viewItem.id,
@@ -1049,7 +1048,7 @@ class ReactRouterViewStack extends ViewStacks {
1049
1048
  const combinedParams = { ...accumulatedParentParams, ...(routeMatch?.params ?? {}) };
1050
1049
  const parentPathnameBase = parentMatches.length > 0 ? parentMatches[parentMatches.length - 1].pathnameBase : '/';
1051
1050
  const absolutePathnameBase = computeAbsolutePathnameBase(routeElement, routeMatch, parentPathnameBase, routeInfo.pathname);
1052
- const contextMatches = buildContextMatches(parentMatches, combinedParams, absolutePathnameBase, viewItem, routeElement, componentElement);
1051
+ const contextMatches = buildContextMatches(parentMatches, combinedParams, routeMatch, routeInfo.pathname, absolutePathnameBase, viewItem, routeElement, componentElement);
1053
1052
  const routeContextValue = parentContext
1054
1053
  ? { ...parentContext, matches: contextMatches }
1055
1054
  : { outlet: null, matches: contextMatches, isDataRoute: false };
@@ -3755,18 +3754,6 @@ const IonRouter = ({ children, registerHistoryListener }) => {
3755
3754
  };
3756
3755
  IonRouter.displayName = 'IonRouter';
3757
3756
 
3758
- /**
3759
- * Defaults React Router 7's `useTransitions` to `false`, since a transition can defer the
3760
- * commit past Ionic's page-visible signal. React Router 6 ignores the prop.
3761
- *
3762
- * Uses `??` instead of spreading a default first, because an explicit
3763
- * `useTransitions={undefined}` would override it and React Router reads that as on.
3764
- */
3765
- const withTransitionDefaults = (props) => {
3766
- const { useTransitions } = props;
3767
- return { ...props, useTransitions: useTransitions ?? false };
3768
- };
3769
-
3770
3757
  /**
3771
3758
  * `IonReactRouter` facilitates the integration of Ionic's specific
3772
3759
  * navigation and UI management with the standard React Router mechanisms,
@@ -3811,7 +3798,7 @@ const RouterContent$2 = ({ children }) => {
3811
3798
  return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
3812
3799
  };
3813
3800
  const IonReactRouter = ({ children, ...browserRouterProps }) => {
3814
- return (React.createElement(BrowserRouter, { ...withTransitionDefaults(browserRouterProps) },
3801
+ return (React.createElement(BrowserRouter, { ...browserRouterProps },
3815
3802
  React.createElement(RouterContent$2, null, children)));
3816
3803
  };
3817
3804
 
@@ -3821,8 +3808,8 @@ const IonReactRouter = ({ children, ...browserRouterProps }) => {
3821
3808
  * isn't available or desirable.
3822
3809
  */
3823
3810
  const RouterContent$1 = ({ children }) => {
3824
- const location = useLocation();
3825
- const navigationType = useNavigationType();
3811
+ const location = useLocation$1();
3812
+ const navigationType = useNavigationType$1();
3826
3813
  const historyListenHandler = useRef();
3827
3814
  const registerHistoryListener = useCallback((cb) => {
3828
3815
  historyListenHandler.current = cb;
@@ -3850,7 +3837,7 @@ const RouterContent$1 = ({ children }) => {
3850
3837
  return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
3851
3838
  };
3852
3839
  const IonReactMemoryRouter = ({ children, ...routerProps }) => {
3853
- return (React.createElement(MemoryRouter, { ...withTransitionDefaults(routerProps) },
3840
+ return (React.createElement(MemoryRouter, { ...routerProps },
3854
3841
  React.createElement(RouterContent$1, null, children)));
3855
3842
  };
3856
3843
 
@@ -3888,7 +3875,7 @@ const RouterContent = ({ children }) => {
3888
3875
  return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
3889
3876
  };
3890
3877
  const IonReactHashRouter = ({ children, ...routerProps }) => {
3891
- return (React.createElement(HashRouter, { ...withTransitionDefaults(routerProps) },
3878
+ return (React.createElement(HashRouter, { ...routerProps },
3892
3879
  React.createElement(RouterContent, null, children)));
3893
3880
  };
3894
3881