react-router-dom-v5-compat 6.26.2-pre.0 → 6.27.0-pre.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/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v5 Compat v6.26.2-pre.0
2
+ * React Router DOM v5 Compat v6.27.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -73,7 +73,7 @@ interface SharedSubmitOptions {
73
73
  /**
74
74
  * Enable flushSync for this submission's state updates
75
75
  */
76
- unstable_flushSync?: boolean;
76
+ flushSync?: boolean;
77
77
  }
78
78
  /**
79
79
  * Submit options available to fetchers
@@ -105,7 +105,7 @@ export interface SubmitOptions extends FetcherSubmitOptions {
105
105
  /**
106
106
  * Enable view transitions on this submission navigation
107
107
  */
108
- unstable_viewTransition?: boolean;
108
+ viewTransition?: boolean;
109
109
  }
110
110
  export declare function getFormSubmissionInfo(target: SubmitTarget, basename: string): {
111
111
  action: string | null;
@@ -3,14 +3,14 @@
3
3
  * you'll need to update the rollup config for react-router-dom-v5-compat.
4
4
  */
5
5
  import * as React from "react";
6
- import type { FutureConfig, Location, NavigateOptions, RelativeRoutingType, RouteObject, RouterProviderProps, To, unstable_DataStrategyFunction, unstable_PatchRoutesOnNavigationFunction } from "react-router";
6
+ import type { FutureConfig, Location, NavigateOptions, RelativeRoutingType, RouteObject, RouterProviderProps, To, DataStrategyFunction, PatchRoutesOnNavigationFunction } from "react-router";
7
7
  import type { Fetcher, FormEncType, FormMethod, FutureConfig as RouterFutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, V7_FormMethod, BlockerFunction } from "@remix-run/router";
8
8
  import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@remix-run/router";
9
9
  import type { SubmitOptions, ParamKeyValuePair, URLSearchParamsInit, SubmitTarget, FetcherSubmitOptions } from "./dom";
10
10
  import { createSearchParams } from "./dom";
11
11
  export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
12
12
  export { createSearchParams, ErrorResponseImpl as UNSAFE_ErrorResponseImpl };
13
- export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker, BlockerFunction, DataRouteMatch, DataRouteObject, unstable_DataStrategyFunction, unstable_DataStrategyFunctionArgs, unstable_DataStrategyMatch, unstable_DataStrategyResult, ErrorResponse, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathParam, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, unstable_PatchRoutesOnNavigationFunction, } from "react-router";
13
+ export type { ActionFunction, ActionFunctionArgs, AwaitProps, Blocker, BlockerFunction, DataRouteMatch, DataRouteObject, DataStrategyFunction, DataStrategyFunctionArgs, DataStrategyMatch, DataStrategyResult, ErrorResponse, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, PatchRoutesOnNavigationFunction, PatchRoutesOnNavigationFunctionArgs, Path, PathMatch, Pathname, PathParam, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, } from "react-router";
14
14
  export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, replace, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, } from "react-router";
15
15
  /** @internal */
16
16
  export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, } from "react-router";
@@ -25,8 +25,8 @@ interface DOMRouterOpts {
25
25
  basename?: string;
26
26
  future?: Partial<Omit<RouterFutureConfig, "v7_prependBasename">>;
27
27
  hydrationData?: HydrationState;
28
- unstable_dataStrategy?: unstable_DataStrategyFunction;
29
- unstable_patchRoutesOnNavigation?: unstable_PatchRoutesOnNavigationFunction;
28
+ dataStrategy?: DataStrategyFunction;
29
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
30
30
  window?: Window;
31
31
  }
32
32
  export declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
@@ -99,7 +99,7 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
99
99
  preventScrollReset?: boolean;
100
100
  relative?: RelativeRoutingType;
101
101
  to: To;
102
- unstable_viewTransition?: boolean;
102
+ viewTransition?: boolean;
103
103
  }
104
104
  /**
105
105
  * The public API for rendering a history-aware `<a>`.
@@ -190,7 +190,7 @@ export interface FormProps extends SharedFormProps {
190
190
  /**
191
191
  * Enable view transitions on this Form navigation
192
192
  */
193
- unstable_viewTransition?: boolean;
193
+ viewTransition?: boolean;
194
194
  }
195
195
  /**
196
196
  * A `@remix-run/router`-aware `<form>`. It behaves like a normal form except
@@ -216,13 +216,13 @@ export declare namespace ScrollRestoration {
216
216
  * you need to create custom `<Link>` components with the same click behavior we
217
217
  * use in our exported `<Link>`.
218
218
  */
219
- export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, unstable_viewTransition, }?: {
219
+ export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, preventScrollReset, relative, viewTransition, }?: {
220
220
  target?: React.HTMLAttributeAnchorTarget;
221
221
  replace?: boolean;
222
222
  state?: any;
223
223
  preventScrollReset?: boolean;
224
224
  relative?: RelativeRoutingType;
225
- unstable_viewTransition?: boolean;
225
+ viewTransition?: boolean;
226
226
  }): (event: React.MouseEvent<E, MouseEvent>) => void;
227
227
  /**
228
228
  * A convenient wrapper for reading and writing search parameters via the
@@ -268,7 +268,7 @@ export type FetcherWithComponents<TData> = Fetcher<TData> & {
268
268
  Form: React.ForwardRefExoticComponent<FetcherFormProps & React.RefAttributes<HTMLFormElement>>;
269
269
  submit: FetcherSubmitFunction;
270
270
  load: (href: string, opts?: {
271
- unstable_flushSync?: boolean;
271
+ flushSync?: boolean;
272
272
  }) => void;
273
273
  };
274
274
  /**
@@ -328,4 +328,4 @@ export { usePrompt as unstable_usePrompt };
328
328
  declare function useViewTransitionState(to: To, opts?: {
329
329
  relative?: RelativeRoutingType;
330
330
  }): boolean;
331
- export { useViewTransitionState as unstable_useViewTransitionState };
331
+ export { useViewTransitionState as useViewTransitionState };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v5 Compat v6.26.2-pre.0
2
+ * React Router DOM v5 Compat v6.27.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -250,9 +250,9 @@
250
250
  };
251
251
  }
252
252
 
253
- const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "unstable_viewTransition"],
254
- _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "unstable_viewTransition", "children"],
255
- _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "unstable_viewTransition"];
253
+ const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"],
254
+ _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"],
255
+ _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
256
256
  //#endregion
257
257
  // HEY YOU! DON'T TOUCH THIS VARIABLE!
258
258
  //
@@ -285,8 +285,8 @@
285
285
  hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
286
286
  routes,
287
287
  mapRouteProperties: reactRouter.UNSAFE_mapRouteProperties,
288
- unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
289
- unstable_patchRoutesOnNavigation: opts == null ? void 0 : opts.unstable_patchRoutesOnNavigation,
288
+ dataStrategy: opts == null ? void 0 : opts.dataStrategy,
289
+ patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
290
290
  window: opts == null ? void 0 : opts.window
291
291
  }).initialize();
292
292
  }
@@ -302,8 +302,8 @@
302
302
  hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
303
303
  routes,
304
304
  mapRouteProperties: reactRouter.UNSAFE_mapRouteProperties,
305
- unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
306
- unstable_patchRoutesOnNavigation: opts == null ? void 0 : opts.unstable_patchRoutesOnNavigation,
305
+ dataStrategy: opts == null ? void 0 : opts.dataStrategy,
306
+ patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
307
307
  window: opts == null ? void 0 : opts.window
308
308
  }).initialize();
309
309
  }
@@ -478,8 +478,8 @@
478
478
  let setState = React__namespace.useCallback((newState, _ref2) => {
479
479
  let {
480
480
  deletedFetchers,
481
- unstable_flushSync: flushSync,
482
- unstable_viewTransitionOpts: viewTransitionOpts
481
+ flushSync: flushSync,
482
+ viewTransitionOpts: viewTransitionOpts
483
483
  } = _ref2;
484
484
  deletedFetchers.forEach(key => fetcherData.current.delete(key));
485
485
  newState.fetchers.forEach((fetcher, key) => {
@@ -815,7 +815,7 @@
815
815
  target,
816
816
  to,
817
817
  preventScrollReset,
818
- unstable_viewTransition
818
+ viewTransition
819
819
  } = _ref7,
820
820
  rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
821
821
  let {
@@ -858,7 +858,7 @@
858
858
  target,
859
859
  preventScrollReset,
860
860
  relative,
861
- unstable_viewTransition
861
+ viewTransition
862
862
  });
863
863
  function handleClick(event) {
864
864
  if (onClick) onClick(event);
@@ -891,7 +891,7 @@
891
891
  end = false,
892
892
  style: styleProp,
893
893
  to,
894
- unstable_viewTransition,
894
+ viewTransition,
895
895
  children
896
896
  } = _ref8,
897
897
  rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
@@ -907,7 +907,7 @@
907
907
  let isTransitioning = routerState != null &&
908
908
  // Conditional usage is OK here because the usage of a data router is static
909
909
  // eslint-disable-next-line react-hooks/rules-of-hooks
910
- useViewTransitionState(path) && unstable_viewTransition === true;
910
+ useViewTransitionState(path) && viewTransition === true;
911
911
  let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
912
912
  let locationPathname = location.pathname;
913
913
  let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
@@ -952,7 +952,7 @@
952
952
  ref: ref,
953
953
  style: style,
954
954
  to: to,
955
- unstable_viewTransition: unstable_viewTransition
955
+ viewTransition: viewTransition
956
956
  }), typeof children === "function" ? children(renderProps) : children);
957
957
  });
958
958
  {
@@ -989,7 +989,7 @@
989
989
  onSubmit,
990
990
  relative,
991
991
  preventScrollReset,
992
- unstable_viewTransition
992
+ viewTransition
993
993
  } = _ref9,
994
994
  props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
995
995
  let submit = useSubmit();
@@ -1011,7 +1011,7 @@
1011
1011
  state,
1012
1012
  relative,
1013
1013
  preventScrollReset,
1014
- unstable_viewTransition
1014
+ viewTransition
1015
1015
  });
1016
1016
  };
1017
1017
  return /*#__PURE__*/React__namespace.createElement("form", _extends({
@@ -1089,7 +1089,7 @@
1089
1089
  state,
1090
1090
  preventScrollReset,
1091
1091
  relative,
1092
- unstable_viewTransition
1092
+ viewTransition
1093
1093
  } = _temp === void 0 ? {} : _temp;
1094
1094
  let navigate = reactRouter.useNavigate();
1095
1095
  let location = reactRouter.useLocation();
@@ -1108,10 +1108,10 @@
1108
1108
  state,
1109
1109
  preventScrollReset,
1110
1110
  relative,
1111
- unstable_viewTransition
1111
+ viewTransition
1112
1112
  });
1113
1113
  }
1114
- }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, unstable_viewTransition]);
1114
+ }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
1115
1115
  }
1116
1116
 
1117
1117
  /**
@@ -1185,7 +1185,7 @@
1185
1185
  body,
1186
1186
  formMethod: options.method || method,
1187
1187
  formEncType: options.encType || encType,
1188
- unstable_flushSync: options.unstable_flushSync
1188
+ flushSync: options.flushSync
1189
1189
  });
1190
1190
  } else {
1191
1191
  router.navigate(options.action || action, {
@@ -1197,8 +1197,8 @@
1197
1197
  replace: options.replace,
1198
1198
  state: options.state,
1199
1199
  fromRouteId: currentRouteId,
1200
- unstable_flushSync: options.unstable_flushSync,
1201
- unstable_viewTransition: options.unstable_viewTransition
1200
+ flushSync: options.flushSync,
1201
+ viewTransition: options.viewTransition
1202
1202
  });
1203
1203
  }
1204
1204
  }, [router, basename, currentRouteId]);
@@ -1235,9 +1235,13 @@
1235
1235
  // since it might not apply to our contextual route. We add it back based
1236
1236
  // on match.route.index below
1237
1237
  let params = new URLSearchParams(path.search);
1238
- if (params.has("index") && params.get("index") === "") {
1238
+ let indexValues = params.getAll("index");
1239
+ let hasNakedIndexParam = indexValues.some(v => v === "");
1240
+ if (hasNakedIndexParam) {
1239
1241
  params.delete("index");
1240
- path.search = params.toString() ? "?" + params.toString() : "";
1242
+ indexValues.filter(v => v).forEach(v => params.append("index", v));
1243
+ let qs = params.toString();
1244
+ path.search = qs ? "?" + qs : "";
1241
1245
  }
1242
1246
  }
1243
1247
  if ((!action || action === ".") && match.route.index) {
@@ -1548,7 +1552,7 @@
1548
1552
  opts = {};
1549
1553
  }
1550
1554
  let vtContext = React__namespace.useContext(ViewTransitionContext);
1551
- !(vtContext != null) ? router.UNSAFE_invariant(false, "`unstable_useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. " + "Did you accidentally import `RouterProvider` from `react-router`?") : void 0;
1555
+ !(vtContext != null) ? router.UNSAFE_invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. " + "Did you accidentally import `RouterProvider` from `react-router`?") : void 0;
1552
1556
  let {
1553
1557
  basename
1554
1558
  } = useDataRouterContext(DataRouterHook.useViewTransitionState);
@@ -1565,11 +1569,11 @@
1565
1569
  // destination. This ensures that other PUSH navigations that reverse
1566
1570
  // an indicated transition apply. I.e., on the list view you have:
1567
1571
  //
1568
- // <NavLink to="/details/1" unstable_viewTransition>
1572
+ // <NavLink to="/details/1" viewTransition>
1569
1573
  //
1570
1574
  // If you click the breadcrumb back to the list view:
1571
1575
  //
1572
- // <NavLink to="/list" unstable_viewTransition>
1576
+ // <NavLink to="/list" viewTransition>
1573
1577
  //
1574
1578
  // We should apply the transition because it's indicated as active going
1575
1579
  // from /list -> /details/1 and therefore should be active on the reverse