@ionic/react-router 9.0.7-dev.11790792026.1963eab3 → 9.0.7-dev.11790799266.10a460f2

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 });
@@ -621,16 +622,14 @@ const getFallbackParamsFromViewItems = (allViewItems, currentOutletId, currentPa
621
622
  return params;
622
623
  };
623
624
  /**
624
- * Builds the matches array for RouteContext. The leaf `pathname` uses the absolute base,
625
- * because the raw match is relative for a route without a leading slash, which breaks
626
- * relative links, and includes a splat's tail, which loops an index `<Navigate>`.
625
+ * Builds the matches array for RouteContext.
627
626
  */
628
- const buildContextMatches = (parentMatches, combinedParams, absolutePathnameBase, viewItem, routeElement, componentElement) => {
627
+ const buildContextMatches = (parentMatches, combinedParams, routeMatch, routeInfoPathname, absolutePathnameBase, viewItem, routeElement, componentElement) => {
629
628
  return [
630
629
  ...parentMatches,
631
630
  {
632
631
  params: combinedParams,
633
- pathname: absolutePathnameBase,
632
+ pathname: routeMatch?.pathname || routeInfoPathname,
634
633
  pathnameBase: absolutePathnameBase,
635
634
  route: {
636
635
  id: viewItem.id,
@@ -983,7 +982,7 @@ class ReactRouterViewStack extends ViewStacks {
983
982
  const combinedParams = { ...accumulatedParentParams, ...(routeMatch?.params ?? {}) };
984
983
  const parentPathnameBase = parentMatches.length > 0 ? parentMatches[parentMatches.length - 1].pathnameBase : '/';
985
984
  const absolutePathnameBase = computeAbsolutePathnameBase(routeElement, routeMatch, parentPathnameBase, routeInfo.pathname);
986
- const contextMatches = buildContextMatches(parentMatches, combinedParams, absolutePathnameBase, viewItem, routeElement, componentElement);
985
+ const contextMatches = buildContextMatches(parentMatches, combinedParams, routeMatch, routeInfo.pathname, absolutePathnameBase, viewItem, routeElement, componentElement);
987
986
  const routeContextValue = parentContext
988
987
  ? { ...parentContext, matches: contextMatches }
989
988
  : { outlet: null, matches: contextMatches, isDataRoute: false };
@@ -3709,18 +3708,6 @@ const IonRouter = ({ children, registerHistoryListener }) => {
3709
3708
  };
3710
3709
  IonRouter.displayName = 'IonRouter';
3711
3710
 
3712
- /**
3713
- * Defaults React Router 7's `useTransitions` to `false`, since a transition can defer the
3714
- * commit past Ionic's page-visible signal. React Router 6 ignores the prop.
3715
- *
3716
- * Uses `??` instead of spreading a default first, because an explicit
3717
- * `useTransitions={undefined}` would override it and React Router reads that as on.
3718
- */
3719
- const withTransitionDefaults = (props) => {
3720
- const { useTransitions } = props;
3721
- return { ...props, useTransitions: useTransitions ?? false };
3722
- };
3723
-
3724
3711
  /**
3725
3712
  * `IonReactRouter` facilitates the integration of Ionic's specific
3726
3713
  * navigation and UI management with the standard React Router mechanisms,
@@ -3765,7 +3752,7 @@ const RouterContent$2 = ({ children }) => {
3765
3752
  return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
3766
3753
  };
3767
3754
  const IonReactRouter = ({ children, ...browserRouterProps }) => {
3768
- return (React.createElement(BrowserRouter, { ...withTransitionDefaults(browserRouterProps) },
3755
+ return (React.createElement(BrowserRouter, { ...browserRouterProps },
3769
3756
  React.createElement(RouterContent$2, null, children)));
3770
3757
  };
3771
3758
 
@@ -3775,8 +3762,8 @@ const IonReactRouter = ({ children, ...browserRouterProps }) => {
3775
3762
  * isn't available or desirable.
3776
3763
  */
3777
3764
  const RouterContent$1 = ({ children }) => {
3778
- const location = useLocation();
3779
- const navigationType = useNavigationType();
3765
+ const location = useLocation$1();
3766
+ const navigationType = useNavigationType$1();
3780
3767
  const historyListenHandler = useRef();
3781
3768
  const registerHistoryListener = useCallback((cb) => {
3782
3769
  historyListenHandler.current = cb;
@@ -3804,7 +3791,7 @@ const RouterContent$1 = ({ children }) => {
3804
3791
  return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
3805
3792
  };
3806
3793
  const IonReactMemoryRouter = ({ children, ...routerProps }) => {
3807
- return (React.createElement(MemoryRouter, { ...withTransitionDefaults(routerProps) },
3794
+ return (React.createElement(MemoryRouter, { ...routerProps },
3808
3795
  React.createElement(RouterContent$1, null, children)));
3809
3796
  };
3810
3797
 
@@ -3842,7 +3829,7 @@ const RouterContent = ({ children }) => {
3842
3829
  return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
3843
3830
  };
3844
3831
  const IonReactHashRouter = ({ children, ...routerProps }) => {
3845
- return (React.createElement(HashRouter, { ...withTransitionDefaults(routerProps) },
3832
+ return (React.createElement(HashRouter, { ...routerProps },
3846
3833
  React.createElement(RouterContent, null, children)));
3847
3834
  };
3848
3835