@ionic/react-router 9.0.12-dev.11794925657.15984d14 → 9.0.12-dev.11794938426.180bdfeb
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 +11 -24
- package/dist/index.js.map +1 -1
- package/dist/types/ReactRouter/IonReactMemoryRouter.d.ts +1 -1
- package/dist/types/ReactRouter/IonRouter.d.ts +2 -1
- package/dist/types/ReactRouter/utils/pathMatching.d.ts +1 -1
- package/package.json +9 -16
- package/dist/types/ReactRouter/utils/transitionDefaults.d.ts +0 -10
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,
|
|
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, StackContext, createDebugLogger, 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.
|
|
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:
|
|
656
|
+
pathname: routeMatch?.pathname || routeInfoPathname,
|
|
658
657
|
pathnameBase: absolutePathnameBase,
|
|
659
658
|
route: {
|
|
660
659
|
id: viewItem.id,
|
|
@@ -1062,7 +1061,7 @@ class ReactRouterViewStack extends ViewStacks {
|
|
|
1062
1061
|
const combinedParams = { ...accumulatedParentParams, ...(routeMatch?.params ?? {}) };
|
|
1063
1062
|
const parentPathnameBase = parentMatches.length > 0 ? parentMatches[parentMatches.length - 1].pathnameBase : '/';
|
|
1064
1063
|
const absolutePathnameBase = computeAbsolutePathnameBase(routeElement, routeMatch, parentPathnameBase, routeInfo.pathname);
|
|
1065
|
-
const contextMatches = buildContextMatches(parentMatches, combinedParams, absolutePathnameBase, viewItem, routeElement, componentElement);
|
|
1064
|
+
const contextMatches = buildContextMatches(parentMatches, combinedParams, routeMatch, routeInfo.pathname, absolutePathnameBase, viewItem, routeElement, componentElement);
|
|
1066
1065
|
const routeContextValue = parentContext
|
|
1067
1066
|
? { ...parentContext, matches: contextMatches }
|
|
1068
1067
|
: { outlet: null, matches: contextMatches, isDataRoute: false };
|
|
@@ -3775,18 +3774,6 @@ const IonRouter = ({ children, registerHistoryListener }) => {
|
|
|
3775
3774
|
};
|
|
3776
3775
|
IonRouter.displayName = 'IonRouter';
|
|
3777
3776
|
|
|
3778
|
-
/**
|
|
3779
|
-
* Defaults React Router 7's `useTransitions` to `false`, since a transition can defer the
|
|
3780
|
-
* commit past Ionic's page-visible signal. React Router 6 ignores the prop.
|
|
3781
|
-
*
|
|
3782
|
-
* Uses `??` instead of spreading a default first, because an explicit
|
|
3783
|
-
* `useTransitions={undefined}` would override it and React Router reads that as on.
|
|
3784
|
-
*/
|
|
3785
|
-
const withTransitionDefaults = (props) => {
|
|
3786
|
-
const { useTransitions } = props;
|
|
3787
|
-
return { ...props, useTransitions: useTransitions ?? false };
|
|
3788
|
-
};
|
|
3789
|
-
|
|
3790
3777
|
/**
|
|
3791
3778
|
* `IonReactRouter` facilitates the integration of Ionic's specific
|
|
3792
3779
|
* navigation and UI management with the standard React Router mechanisms,
|
|
@@ -3831,7 +3818,7 @@ const RouterContent$2 = ({ children }) => {
|
|
|
3831
3818
|
return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
|
|
3832
3819
|
};
|
|
3833
3820
|
const IonReactRouter = ({ children, ...browserRouterProps }) => {
|
|
3834
|
-
return (React.createElement(BrowserRouter, { ...
|
|
3821
|
+
return (React.createElement(BrowserRouter, { ...browserRouterProps },
|
|
3835
3822
|
React.createElement(RouterContent$2, null, children)));
|
|
3836
3823
|
};
|
|
3837
3824
|
|
|
@@ -3841,8 +3828,8 @@ const IonReactRouter = ({ children, ...browserRouterProps }) => {
|
|
|
3841
3828
|
* isn't available or desirable.
|
|
3842
3829
|
*/
|
|
3843
3830
|
const RouterContent$1 = ({ children }) => {
|
|
3844
|
-
const location = useLocation();
|
|
3845
|
-
const navigationType = useNavigationType();
|
|
3831
|
+
const location = useLocation$1();
|
|
3832
|
+
const navigationType = useNavigationType$1();
|
|
3846
3833
|
const historyListenHandler = useRef();
|
|
3847
3834
|
const registerHistoryListener = useCallback((cb) => {
|
|
3848
3835
|
historyListenHandler.current = cb;
|
|
@@ -3870,7 +3857,7 @@ const RouterContent$1 = ({ children }) => {
|
|
|
3870
3857
|
return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
|
|
3871
3858
|
};
|
|
3872
3859
|
const IonReactMemoryRouter = ({ children, ...routerProps }) => {
|
|
3873
|
-
return (React.createElement(MemoryRouter, { ...
|
|
3860
|
+
return (React.createElement(MemoryRouter, { ...routerProps },
|
|
3874
3861
|
React.createElement(RouterContent$1, null, children)));
|
|
3875
3862
|
};
|
|
3876
3863
|
|
|
@@ -3908,7 +3895,7 @@ const RouterContent = ({ children }) => {
|
|
|
3908
3895
|
return React.createElement(IonRouter, { registerHistoryListener: registerHistoryListener }, children);
|
|
3909
3896
|
};
|
|
3910
3897
|
const IonReactHashRouter = ({ children, ...routerProps }) => {
|
|
3911
|
-
return (React.createElement(HashRouter, { ...
|
|
3898
|
+
return (React.createElement(HashRouter, { ...routerProps },
|
|
3912
3899
|
React.createElement(RouterContent, null, children)));
|
|
3913
3900
|
};
|
|
3914
3901
|
|