react-router-dom 6.26.2 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # `react-router-dom`
2
2
 
3
+ ## 6.27.0-pre.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Stabilize `unstable_patchRoutesOnNavigation` ([#11973](https://github.com/remix-run/react-router/pull/11973))
8
+ - Stabilize `unstable_dataStrategy` ([#11974](https://github.com/remix-run/react-router/pull/11974))
9
+ - Stabilize the `unstable_flushSync` option for navigations and fetchers ([#11989](https://github.com/remix-run/react-router/pull/11989))
10
+ - Stabilize the `unstable_viewTransition` option for navigations and the corresponding `unstable_useViewTransitionState` hook ([#11989](https://github.com/remix-run/react-router/pull/11989))
11
+
12
+ ### Patch Changes
13
+
14
+ - - Fix bug when submitting to the current contextual route (parent route with an index child) when an `?index` param already exists from a prior submission ([#12003](https://github.com/remix-run/react-router/pull/12003))
15
+ - Fix `useFormAction` bug - when removing `?index` param it would not keep other non-Remix `index` params
16
+ - - Fix types for `RouteObject` within `PatchRoutesOnNavigationFunction`'s `patch` method so it doesn't expect agnostic route objects passed to `patch` ([#11967](https://github.com/remix-run/react-router/pull/11967))
17
+ - Add new `PatchRoutesOnNavigationFunctionArgs` type for convenience
18
+ - Updated dependencies:
19
+ - `react-router@6.27.0-pre.0`
20
+ - `@remix-run/router@1.20.0-pre.0`
21
+
3
22
  ## 6.26.2
4
23
 
5
24
  ### Patch Changes
package/dist/dom.d.ts CHANGED
@@ -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;
package/dist/index.d.ts CHANGED
@@ -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 };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v6.26.2
2
+ * React Router DOM v6.27.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -208,9 +208,9 @@ function getFormSubmissionInfo(target, basename) {
208
208
  };
209
209
  }
210
210
 
211
- const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "unstable_viewTransition"],
212
- _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "unstable_viewTransition", "children"],
213
- _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "unstable_viewTransition"];
211
+ const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"],
212
+ _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"],
213
+ _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
214
214
  // HEY YOU! DON'T TOUCH THIS VARIABLE!
215
215
  //
216
216
  // It is replaced with the proper version at build time via a babel plugin in
@@ -238,8 +238,8 @@ function createBrowserRouter(routes, opts) {
238
238
  hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
239
239
  routes,
240
240
  mapRouteProperties: UNSAFE_mapRouteProperties,
241
- unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
242
- unstable_patchRoutesOnNavigation: opts == null ? void 0 : opts.unstable_patchRoutesOnNavigation,
241
+ dataStrategy: opts == null ? void 0 : opts.dataStrategy,
242
+ patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
243
243
  window: opts == null ? void 0 : opts.window
244
244
  }).initialize();
245
245
  }
@@ -255,8 +255,8 @@ function createHashRouter(routes, opts) {
255
255
  hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
256
256
  routes,
257
257
  mapRouteProperties: UNSAFE_mapRouteProperties,
258
- unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
259
- unstable_patchRoutesOnNavigation: opts == null ? void 0 : opts.unstable_patchRoutesOnNavigation,
258
+ dataStrategy: opts == null ? void 0 : opts.dataStrategy,
259
+ patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
260
260
  window: opts == null ? void 0 : opts.window
261
261
  }).initialize();
262
262
  }
@@ -414,8 +414,8 @@ function RouterProvider(_ref) {
414
414
  let setState = React.useCallback((newState, _ref2) => {
415
415
  let {
416
416
  deletedFetchers,
417
- unstable_flushSync: flushSync,
418
- unstable_viewTransitionOpts: viewTransitionOpts
417
+ flushSync: flushSync,
418
+ viewTransitionOpts: viewTransitionOpts
419
419
  } = _ref2;
420
420
  deletedFetchers.forEach(key => fetcherData.current.delete(key));
421
421
  newState.fetchers.forEach((fetcher, key) => {
@@ -738,7 +738,7 @@ const Link = /*#__PURE__*/React.forwardRef(function LinkWithRef(_ref7, ref) {
738
738
  target,
739
739
  to,
740
740
  preventScrollReset,
741
- unstable_viewTransition
741
+ viewTransition
742
742
  } = _ref7,
743
743
  rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
744
744
  let {
@@ -778,7 +778,7 @@ const Link = /*#__PURE__*/React.forwardRef(function LinkWithRef(_ref7, ref) {
778
778
  target,
779
779
  preventScrollReset,
780
780
  relative,
781
- unstable_viewTransition
781
+ viewTransition
782
782
  });
783
783
  function handleClick(event) {
784
784
  if (onClick) onClick(event);
@@ -811,7 +811,7 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref
811
811
  end = false,
812
812
  style: styleProp,
813
813
  to,
814
- unstable_viewTransition,
814
+ viewTransition,
815
815
  children
816
816
  } = _ref8,
817
817
  rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
@@ -827,7 +827,7 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref
827
827
  let isTransitioning = routerState != null &&
828
828
  // Conditional usage is OK here because the usage of a data router is static
829
829
  // eslint-disable-next-line react-hooks/rules-of-hooks
830
- useViewTransitionState(path) && unstable_viewTransition === true;
830
+ useViewTransitionState(path) && viewTransition === true;
831
831
  let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
832
832
  let locationPathname = location.pathname;
833
833
  let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
@@ -871,7 +871,7 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref
871
871
  ref: ref,
872
872
  style: style,
873
873
  to: to,
874
- unstable_viewTransition: unstable_viewTransition
874
+ viewTransition: viewTransition
875
875
  }), typeof children === "function" ? children(renderProps) : children);
876
876
  });
877
877
  if (process.env.NODE_ENV !== "production") {
@@ -895,7 +895,7 @@ const Form = /*#__PURE__*/React.forwardRef((_ref9, forwardedRef) => {
895
895
  onSubmit,
896
896
  relative,
897
897
  preventScrollReset,
898
- unstable_viewTransition
898
+ viewTransition
899
899
  } = _ref9,
900
900
  props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
901
901
  let submit = useSubmit();
@@ -917,7 +917,7 @@ const Form = /*#__PURE__*/React.forwardRef((_ref9, forwardedRef) => {
917
917
  state,
918
918
  relative,
919
919
  preventScrollReset,
920
- unstable_viewTransition
920
+ viewTransition
921
921
  });
922
922
  };
923
923
  return /*#__PURE__*/React.createElement("form", _extends({
@@ -993,7 +993,7 @@ function useLinkClickHandler(to, _temp) {
993
993
  state,
994
994
  preventScrollReset,
995
995
  relative,
996
- unstable_viewTransition
996
+ viewTransition
997
997
  } = _temp === void 0 ? {} : _temp;
998
998
  let navigate = useNavigate();
999
999
  let location = useLocation();
@@ -1011,10 +1011,10 @@ function useLinkClickHandler(to, _temp) {
1011
1011
  state,
1012
1012
  preventScrollReset,
1013
1013
  relative,
1014
- unstable_viewTransition
1014
+ viewTransition
1015
1015
  });
1016
1016
  }
1017
- }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, unstable_viewTransition]);
1017
+ }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
1018
1018
  }
1019
1019
  /**
1020
1020
  * A convenient wrapper for reading and writing search parameters via the
@@ -1077,7 +1077,7 @@ function useSubmit() {
1077
1077
  body,
1078
1078
  formMethod: options.method || method,
1079
1079
  formEncType: options.encType || encType,
1080
- unstable_flushSync: options.unstable_flushSync
1080
+ flushSync: options.flushSync
1081
1081
  });
1082
1082
  } else {
1083
1083
  router.navigate(options.action || action, {
@@ -1089,8 +1089,8 @@ function useSubmit() {
1089
1089
  replace: options.replace,
1090
1090
  state: options.state,
1091
1091
  fromRouteId: currentRouteId,
1092
- unstable_flushSync: options.unstable_flushSync,
1093
- unstable_viewTransition: options.unstable_viewTransition
1092
+ flushSync: options.flushSync,
1093
+ viewTransition: options.viewTransition
1094
1094
  });
1095
1095
  }
1096
1096
  }, [router, basename, currentRouteId]);
@@ -1124,9 +1124,13 @@ function useFormAction(action, _temp2) {
1124
1124
  // since it might not apply to our contextual route. We add it back based
1125
1125
  // on match.route.index below
1126
1126
  let params = new URLSearchParams(path.search);
1127
- if (params.has("index") && params.get("index") === "") {
1127
+ let indexValues = params.getAll("index");
1128
+ let hasNakedIndexParam = indexValues.some(v => v === "");
1129
+ if (hasNakedIndexParam) {
1128
1130
  params.delete("index");
1129
- path.search = params.toString() ? "?" + params.toString() : "";
1131
+ indexValues.filter(v => v).forEach(v => params.append("index", v));
1132
+ let qs = params.toString();
1133
+ path.search = qs ? "?" + qs : "";
1130
1134
  }
1131
1135
  }
1132
1136
  if ((!action || action === ".") && match.route.index) {
@@ -1417,7 +1421,7 @@ function useViewTransitionState(to, opts) {
1417
1421
  opts = {};
1418
1422
  }
1419
1423
  let vtContext = React.useContext(ViewTransitionContext);
1420
- !(vtContext != null) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "`unstable_useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. " + "Did you accidentally import `RouterProvider` from `react-router`?") : UNSAFE_invariant(false) : void 0;
1424
+ !(vtContext != null) ? process.env.NODE_ENV !== "production" ? UNSAFE_invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. " + "Did you accidentally import `RouterProvider` from `react-router`?") : UNSAFE_invariant(false) : void 0;
1421
1425
  let {
1422
1426
  basename
1423
1427
  } = useDataRouterContext(DataRouterHook.useViewTransitionState);
@@ -1433,11 +1437,11 @@ function useViewTransitionState(to, opts) {
1433
1437
  // destination. This ensures that other PUSH navigations that reverse
1434
1438
  // an indicated transition apply. I.e., on the list view you have:
1435
1439
  //
1436
- // <NavLink to="/details/1" unstable_viewTransition>
1440
+ // <NavLink to="/details/1" viewTransition>
1437
1441
  //
1438
1442
  // If you click the breadcrumb back to the list view:
1439
1443
  //
1440
- // <NavLink to="/list" unstable_viewTransition>
1444
+ // <NavLink to="/list" viewTransition>
1441
1445
  //
1442
1446
  // We should apply the transition because it's indicated as active going
1443
1447
  // from /list -> /details/1 and therefore should be active on the reverse
@@ -1446,5 +1450,5 @@ function useViewTransitionState(to, opts) {
1446
1450
  }
1447
1451
  //#endregion
1448
1452
 
1449
- export { BrowserRouter, Form, HashRouter, Link, NavLink, RouterProvider, ScrollRestoration, FetchersContext as UNSAFE_FetchersContext, ViewTransitionContext as UNSAFE_ViewTransitionContext, useScrollRestoration as UNSAFE_useScrollRestoration, createBrowserRouter, createHashRouter, createSearchParams, HistoryRouter as unstable_HistoryRouter, usePrompt as unstable_usePrompt, useViewTransitionState as unstable_useViewTransitionState, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLinkClickHandler, useSearchParams, useSubmit };
1453
+ export { BrowserRouter, Form, HashRouter, Link, NavLink, RouterProvider, ScrollRestoration, FetchersContext as UNSAFE_FetchersContext, ViewTransitionContext as UNSAFE_ViewTransitionContext, useScrollRestoration as UNSAFE_useScrollRestoration, createBrowserRouter, createHashRouter, createSearchParams, HistoryRouter as unstable_HistoryRouter, usePrompt as unstable_usePrompt, useBeforeUnload, useFetcher, useFetchers, useFormAction, useLinkClickHandler, useSearchParams, useSubmit, useViewTransitionState };
1450
1454
  //# sourceMappingURL=index.js.map