react-router-dom 6.17.0-pre.1 → 6.17.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,17 +1,10 @@
1
1
  # `react-router-dom`
2
2
 
3
- ## 6.17.0-pre.1
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies:
8
- - `react-router@6.17.0-pre.1`
9
-
10
- ## 6.17.0-pre.0
3
+ ## 6.17.0
11
4
 
12
5
  ### Minor Changes
13
6
 
14
- - Add support for the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition) via `document.startViewTransition` to enable CSS animated transitions on SPA navigations in your application. ([#10916](https://github.com/remix-run/react-router/pull/10916))
7
+ - Add experimental support for the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition) via `document.startViewTransition` to enable CSS animated transitions on SPA navigations in your application. ([#10916](https://github.com/remix-run/react-router/pull/10916))
15
8
 
16
9
  The simplest approach to enabling a View Transition in your React Router app is via the new `<Link unstable_viewTransition>` prop. This will cause the navigation DOM update to be wrapped in `document.startViewTransition` which will enable transitions for the DOM update. Without any additional CSS styles, you'll get a basic cross-fade animation for your page.
17
10
 
@@ -52,12 +45,14 @@
52
45
 
53
46
  For more information on using the View Transitions API, please refer to the [Smooth and simple transitions with the View Transitions API](https://developer.chrome.com/docs/web-platform/view-transitions/) guide from the Google Chrome team.
54
47
 
48
+ Please note, that because the `ViewTransition` API is a DOM API, we now export a specific `RouterProvider` from `react-router-dom` with this functionality. If you are importing `RouterProvider` from `react-router`, then it will not support view transitions. ([#10928](https://github.com/remix-run/react-router/pull/10928)
49
+
55
50
  ### Patch Changes
56
51
 
57
52
  - Log a warning and fail gracefully in `ScrollRestoration` when `sessionStorage` is unavailable ([#10848](https://github.com/remix-run/react-router/pull/10848))
58
53
  - Updated dependencies:
59
- - `@remix-run/router@1.10.0-pre.0`
60
- - `react-router@6.17.0-pre.0`
54
+ - `@remix-run/router@1.10.0`
55
+ - `react-router@6.17.0`
61
56
 
62
57
  ## 6.16.0
63
58
 
package/dist/index.d.ts CHANGED
@@ -3,18 +3,21 @@
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, NavigateOptions, RelativeRoutingType, RouteObject, To } from "react-router";
6
+ import type { FutureConfig, Location, NavigateOptions, RelativeRoutingType, RouteObject, RouterProviderProps, To } from "react-router";
7
7
  import type { Fetcher, FormEncType, FormMethod, FutureConfig as RouterFutureConfig, GetScrollRestorationKeyFunction, History, HTMLFormMethod, HydrationState, Router as RemixRouter, V7_FormMethod } from "@remix-run/router";
8
8
  import type { SubmitOptions, ParamKeyValuePair, URLSearchParamsInit, SubmitTarget } from "./dom";
9
9
  import { createSearchParams } from "./dom";
10
10
  export type { FormEncType, FormMethod, GetScrollRestorationKeyFunction, ParamKeyValuePair, SubmitOptions, URLSearchParamsInit, V7_FormMethod, };
11
11
  export { createSearchParams };
12
12
  export type { ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, ErrorResponse, Fetcher, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LazyRouteFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, ShouldRevalidateFunctionArgs, To, UIMatch, } from "react-router";
13
- export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, unstable_useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, } from "react-router";
13
+ export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, useActionData, useAsyncError, useAsyncValue, unstable_useBlocker, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, } from "react-router";
14
14
  /** @internal */
15
- export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_ViewTransitionContext, UNSAFE_useRouteId, } from "react-router";
15
+ export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, } from "react-router";
16
16
  declare global {
17
17
  var __staticRouterHydrationData: HydrationState | undefined;
18
+ interface Document {
19
+ startViewTransition(cb: () => Promise<void> | void): ViewTransition;
20
+ }
18
21
  }
19
22
  interface DOMRouterOpts {
20
23
  basename?: string;
@@ -24,6 +27,25 @@ interface DOMRouterOpts {
24
27
  }
25
28
  export declare function createBrowserRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
26
29
  export declare function createHashRouter(routes: RouteObject[], opts?: DOMRouterOpts): RemixRouter;
30
+ type ViewTransitionContextObject = {
31
+ isTransitioning: false;
32
+ } | {
33
+ isTransitioning: true;
34
+ currentLocation: Location;
35
+ nextLocation: Location;
36
+ };
37
+ declare const ViewTransitionContext: React.Context<ViewTransitionContextObject>;
38
+ export { ViewTransitionContext as UNSAFE_ViewTransitionContext };
39
+ interface ViewTransition {
40
+ finished: Promise<void>;
41
+ ready: Promise<void>;
42
+ updateCallbackDone: Promise<void>;
43
+ skipTransition(): void;
44
+ }
45
+ /**
46
+ * Given a Remix Router instance, render the appropriate UI
47
+ */
48
+ export declare function RouterProvider({ fallbackElement, router, future, }: RouterProviderProps): React.ReactElement;
27
49
  export interface BrowserRouterProps {
28
50
  basename?: string;
29
51
  children?: React.ReactNode;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v6.17.0-pre.1
2
+ * React Router DOM v6.17.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -9,8 +9,8 @@
9
9
  * @license MIT
10
10
  */
11
11
  import * as React from 'react';
12
- import { UNSAFE_mapRouteProperties, Router, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, useNavigate, createPath, UNSAFE_useRouteId, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_ViewTransitionContext, UNSAFE_DataRouterContext } from 'react-router';
13
- export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_ViewTransitionContext, UNSAFE_useRouteId, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router';
12
+ import { UNSAFE_mapRouteProperties, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, Router, UNSAFE_useRoutesImpl, UNSAFE_NavigationContext, useHref, useResolvedPath, useLocation, useNavigate, createPath, UNSAFE_useRouteId, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker } from 'react-router';
13
+ export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_useRouteId, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, redirectDocument, renderMatches, resolvePath, unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes } from 'react-router';
14
14
  import { stripBasename, UNSAFE_warning, createRouter, createBrowserHistory, createHashHistory, UNSAFE_ErrorResponseImpl, UNSAFE_invariant, joinPaths, matchPath } from '@remix-run/router';
15
15
 
16
16
  function _extends() {
@@ -288,6 +288,12 @@ function deserializeErrors(errors) {
288
288
  }
289
289
  return serialized;
290
290
  }
291
+ const ViewTransitionContext = /*#__PURE__*/React.createContext({
292
+ isTransitioning: false
293
+ });
294
+ if (process.env.NODE_ENV !== "production") {
295
+ ViewTransitionContext.displayName = "ViewTransition";
296
+ }
291
297
  //#endregion
292
298
  ////////////////////////////////////////////////////////////////////////////////
293
299
  //#region Components
@@ -315,16 +321,200 @@ function deserializeErrors(errors) {
315
321
  */
316
322
  const START_TRANSITION = "startTransition";
317
323
  const startTransitionImpl = React[START_TRANSITION];
324
+ function startTransitionSafe(cb) {
325
+ if (startTransitionImpl) {
326
+ startTransitionImpl(cb);
327
+ } else {
328
+ cb();
329
+ }
330
+ }
331
+ class Deferred {
332
+ constructor() {
333
+ this.status = "pending";
334
+ this.promise = new Promise((resolve, reject) => {
335
+ this.resolve = value => {
336
+ if (this.status === "pending") {
337
+ this.status = "resolved";
338
+ resolve(value);
339
+ }
340
+ };
341
+ this.reject = reason => {
342
+ if (this.status === "pending") {
343
+ this.status = "rejected";
344
+ reject(reason);
345
+ }
346
+ };
347
+ });
348
+ }
349
+ }
350
+ /**
351
+ * Given a Remix Router instance, render the appropriate UI
352
+ */
353
+ function RouterProvider(_ref) {
354
+ let {
355
+ fallbackElement,
356
+ router,
357
+ future
358
+ } = _ref;
359
+ let [state, setStateImpl] = React.useState(router.state);
360
+ let [pendingState, setPendingState] = React.useState();
361
+ let [vtContext, setVtContext] = React.useState({
362
+ isTransitioning: false
363
+ });
364
+ let [renderDfd, setRenderDfd] = React.useState();
365
+ let [transition, setTransition] = React.useState();
366
+ let [interruption, setInterruption] = React.useState();
367
+ let {
368
+ v7_startTransition
369
+ } = future || {};
370
+ let optInStartTransition = React.useCallback(cb => {
371
+ if (v7_startTransition) {
372
+ startTransitionSafe(cb);
373
+ } else {
374
+ cb();
375
+ }
376
+ }, [v7_startTransition]);
377
+ let setState = React.useCallback((newState, _ref2) => {
378
+ let {
379
+ unstable_viewTransitionOpts: viewTransitionOpts
380
+ } = _ref2;
381
+ if (!viewTransitionOpts || router.window == null || typeof router.window.document.startViewTransition !== "function") {
382
+ // Mid-navigation state update, or startViewTransition isn't available
383
+ optInStartTransition(() => setStateImpl(newState));
384
+ } else if (transition && renderDfd) {
385
+ // Interrupting an in-progress transition, cancel and let everything flush
386
+ // out, and then kick off a new transition from the interruption state
387
+ renderDfd.resolve();
388
+ transition.skipTransition();
389
+ setInterruption({
390
+ state: newState,
391
+ currentLocation: viewTransitionOpts.currentLocation,
392
+ nextLocation: viewTransitionOpts.nextLocation
393
+ });
394
+ } else {
395
+ // Completed navigation update with opted-in view transitions, let 'er rip
396
+ setPendingState(newState);
397
+ setVtContext({
398
+ isTransitioning: true,
399
+ currentLocation: viewTransitionOpts.currentLocation,
400
+ nextLocation: viewTransitionOpts.nextLocation
401
+ });
402
+ }
403
+ }, [optInStartTransition, transition, renderDfd, router.window]);
404
+ // Need to use a layout effect here so we are subscribed early enough to
405
+ // pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
406
+ React.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
407
+ // When we start a view transition, create a Deferred we can use for the
408
+ // eventual "completed" render
409
+ React.useEffect(() => {
410
+ if (vtContext.isTransitioning) {
411
+ setRenderDfd(new Deferred());
412
+ }
413
+ }, [vtContext.isTransitioning]);
414
+ // Once the deferred is created, kick off startViewTransition() to update the
415
+ // DOM and then wait on the Deferred to resolve (indicating the DOM update has
416
+ // happened)
417
+ React.useEffect(() => {
418
+ if (renderDfd && pendingState && router.window) {
419
+ let newState = pendingState;
420
+ let renderPromise = renderDfd.promise;
421
+ let transition = router.window.document.startViewTransition(async () => {
422
+ optInStartTransition(() => setStateImpl(newState));
423
+ await renderPromise;
424
+ });
425
+ transition.finished.finally(() => {
426
+ setRenderDfd(undefined);
427
+ setTransition(undefined);
428
+ setPendingState(undefined);
429
+ setVtContext({
430
+ isTransitioning: false
431
+ });
432
+ });
433
+ setTransition(transition);
434
+ }
435
+ }, [optInStartTransition, pendingState, renderDfd, router.window]);
436
+ // When the new location finally renders and is committed to the DOM, this
437
+ // effect will run to resolve the transition
438
+ React.useEffect(() => {
439
+ if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
440
+ renderDfd.resolve();
441
+ }
442
+ }, [renderDfd, transition, state.location, pendingState]);
443
+ // If we get interrupted with a new navigation during a transition, we skip
444
+ // the active transition, let it cleanup, then kick it off again here
445
+ React.useEffect(() => {
446
+ if (!vtContext.isTransitioning && interruption) {
447
+ setPendingState(interruption.state);
448
+ setVtContext({
449
+ isTransitioning: true,
450
+ currentLocation: interruption.currentLocation,
451
+ nextLocation: interruption.nextLocation
452
+ });
453
+ setInterruption(undefined);
454
+ }
455
+ }, [vtContext.isTransitioning, interruption]);
456
+ let navigator = React.useMemo(() => {
457
+ return {
458
+ createHref: router.createHref,
459
+ encodeLocation: router.encodeLocation,
460
+ go: n => router.navigate(n),
461
+ push: (to, state, opts) => router.navigate(to, {
462
+ state,
463
+ preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
464
+ }),
465
+ replace: (to, state, opts) => router.navigate(to, {
466
+ replace: true,
467
+ state,
468
+ preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
469
+ })
470
+ };
471
+ }, [router]);
472
+ let basename = router.basename || "/";
473
+ let dataRouterContext = React.useMemo(() => ({
474
+ router,
475
+ navigator,
476
+ static: false,
477
+ basename
478
+ }), [router, navigator, basename]);
479
+ // The fragment and {null} here are important! We need them to keep React 18's
480
+ // useId happy when we are server-rendering since we may have a <script> here
481
+ // containing the hydrated server-side staticContext (from StaticRouterProvider).
482
+ // useId relies on the component tree structure to generate deterministic id's
483
+ // so we need to ensure it remains the same on the client even though
484
+ // we don't need the <script> tag
485
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(UNSAFE_DataRouterContext.Provider, {
486
+ value: dataRouterContext
487
+ }, /*#__PURE__*/React.createElement(UNSAFE_DataRouterStateContext.Provider, {
488
+ value: state
489
+ }, /*#__PURE__*/React.createElement(ViewTransitionContext.Provider, {
490
+ value: vtContext
491
+ }, /*#__PURE__*/React.createElement(Router, {
492
+ basename: basename,
493
+ location: state.location,
494
+ navigationType: state.historyAction,
495
+ navigator: navigator
496
+ }, state.initialized ? /*#__PURE__*/React.createElement(DataRoutes, {
497
+ routes: router.routes,
498
+ state: state
499
+ }) : fallbackElement)))), null);
500
+ }
501
+ function DataRoutes(_ref3) {
502
+ let {
503
+ routes,
504
+ state
505
+ } = _ref3;
506
+ return UNSAFE_useRoutesImpl(routes, undefined, state);
507
+ }
318
508
  /**
319
509
  * A `<Router>` for use in web browsers. Provides the cleanest URLs.
320
510
  */
321
- function BrowserRouter(_ref) {
511
+ function BrowserRouter(_ref4) {
322
512
  let {
323
513
  basename,
324
514
  children,
325
515
  future,
326
516
  window
327
- } = _ref;
517
+ } = _ref4;
328
518
  let historyRef = React.useRef();
329
519
  if (historyRef.current == null) {
330
520
  historyRef.current = createBrowserHistory({
@@ -356,13 +546,13 @@ function BrowserRouter(_ref) {
356
546
  * A `<Router>` for use in web browsers. Stores the location in the hash
357
547
  * portion of the URL so it is not sent to the server.
358
548
  */
359
- function HashRouter(_ref2) {
549
+ function HashRouter(_ref5) {
360
550
  let {
361
551
  basename,
362
552
  children,
363
553
  future,
364
554
  window
365
- } = _ref2;
555
+ } = _ref5;
366
556
  let historyRef = React.useRef();
367
557
  if (historyRef.current == null) {
368
558
  historyRef.current = createHashHistory({
@@ -396,13 +586,13 @@ function HashRouter(_ref2) {
396
586
  * two versions of the history library to your bundles unless you use the same
397
587
  * version of the history library that React Router uses internally.
398
588
  */
399
- function HistoryRouter(_ref3) {
589
+ function HistoryRouter(_ref6) {
400
590
  let {
401
591
  basename,
402
592
  children,
403
593
  future,
404
594
  history
405
- } = _ref3;
595
+ } = _ref6;
406
596
  let [state, setStateImpl] = React.useState({
407
597
  action: history.action,
408
598
  location: history.location
@@ -430,7 +620,7 @@ const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
430
620
  /**
431
621
  * The public API for rendering a history-aware `<a>`.
432
622
  */
433
- const Link = /*#__PURE__*/React.forwardRef(function LinkWithRef(_ref4, ref) {
623
+ const Link = /*#__PURE__*/React.forwardRef(function LinkWithRef(_ref7, ref) {
434
624
  let {
435
625
  onClick,
436
626
  relative,
@@ -441,8 +631,8 @@ const Link = /*#__PURE__*/React.forwardRef(function LinkWithRef(_ref4, ref) {
441
631
  to,
442
632
  preventScrollReset,
443
633
  unstable_viewTransition
444
- } = _ref4,
445
- rest = _objectWithoutPropertiesLoose(_ref4, _excluded);
634
+ } = _ref7,
635
+ rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
446
636
  let {
447
637
  basename
448
638
  } = React.useContext(UNSAFE_NavigationContext);
@@ -505,7 +695,7 @@ if (process.env.NODE_ENV !== "production") {
505
695
  /**
506
696
  * A `<Link>` wrapper that knows if it's "active" or not.
507
697
  */
508
- const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref5, ref) {
698
+ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref8, ref) {
509
699
  let {
510
700
  "aria-current": ariaCurrentProp = "page",
511
701
  caseSensitive = false,
@@ -515,8 +705,8 @@ const NavLink = /*#__PURE__*/React.forwardRef(function NavLinkWithRef(_ref5, ref
515
705
  to,
516
706
  unstable_viewTransition,
517
707
  children
518
- } = _ref5,
519
- rest = _objectWithoutPropertiesLoose(_ref5, _excluded2);
708
+ } = _ref8,
709
+ rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
520
710
  let path = useResolvedPath(to, {
521
711
  relative: rest.relative
522
712
  });
@@ -585,7 +775,7 @@ const Form = /*#__PURE__*/React.forwardRef((props, ref) => {
585
775
  if (process.env.NODE_ENV !== "production") {
586
776
  Form.displayName = "Form";
587
777
  }
588
- const FormImpl = /*#__PURE__*/React.forwardRef((_ref6, forwardedRef) => {
778
+ const FormImpl = /*#__PURE__*/React.forwardRef((_ref9, forwardedRef) => {
589
779
  let {
590
780
  reloadDocument,
591
781
  replace,
@@ -597,8 +787,8 @@ const FormImpl = /*#__PURE__*/React.forwardRef((_ref6, forwardedRef) => {
597
787
  relative,
598
788
  preventScrollReset,
599
789
  unstable_viewTransition
600
- } = _ref6,
601
- props = _objectWithoutPropertiesLoose(_ref6, _excluded3);
790
+ } = _ref9,
791
+ props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
602
792
  let formMethod = method.toLowerCase() === "get" ? "get" : "post";
603
793
  let formAction = useFormAction(action, {
604
794
  relative
@@ -632,11 +822,11 @@ if (process.env.NODE_ENV !== "production") {
632
822
  * This component will emulate the browser's scroll restoration on location
633
823
  * changes.
634
824
  */
635
- function ScrollRestoration(_ref7) {
825
+ function ScrollRestoration(_ref10) {
636
826
  let {
637
827
  getKey,
638
828
  storageKey
639
- } = _ref7;
829
+ } = _ref10;
640
830
  useScrollRestoration({
641
831
  getKey,
642
832
  storageKey
@@ -656,7 +846,6 @@ var DataRouterHook;
656
846
  DataRouterHook["UseSubmit"] = "useSubmit";
657
847
  DataRouterHook["UseSubmitFetcher"] = "useSubmitFetcher";
658
848
  DataRouterHook["UseFetcher"] = "useFetcher";
659
- DataRouterHook["useViewTransitionStates"] = "useViewTransitionStates";
660
849
  DataRouterHook["useViewTransitionState"] = "useViewTransitionState";
661
850
  })(DataRouterHook || (DataRouterHook = {}));
662
851
  var DataRouterStateHook;
@@ -1070,11 +1259,11 @@ function usePageHide(callback, options) {
1070
1259
  * very incorrectly in some cases) across browsers if user click addition
1071
1260
  * back/forward navigations while the confirm is open. Use at your own risk.
1072
1261
  */
1073
- function usePrompt(_ref8) {
1262
+ function usePrompt(_ref11) {
1074
1263
  let {
1075
1264
  when,
1076
1265
  message
1077
- } = _ref8;
1266
+ } = _ref11;
1078
1267
  let blocker = unstable_useBlocker(when);
1079
1268
  React.useEffect(() => {
1080
1269
  if (blocker.state === "blocked") {
@@ -1107,34 +1296,35 @@ function useViewTransitionState(to, opts) {
1107
1296
  if (opts === void 0) {
1108
1297
  opts = {};
1109
1298
  }
1110
- let vtContext = React.useContext(UNSAFE_ViewTransitionContext);
1299
+ let vtContext = React.useContext(ViewTransitionContext);
1300
+ !(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;
1111
1301
  let {
1112
1302
  basename
1113
1303
  } = useDataRouterContext(DataRouterHook.useViewTransitionState);
1114
1304
  let path = useResolvedPath(to, {
1115
1305
  relative: opts.relative
1116
1306
  });
1117
- if (vtContext.isTransitioning) {
1118
- let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
1119
- let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
1120
- // Transition is active if we're going to or coming from the indicated
1121
- // destination. This ensures that other PUSH navigations that reverse
1122
- // an indicated transition apply. I.e., on the list view you have:
1123
- //
1124
- // <NavLink to="/details/1" unstable_viewTransition>
1125
- //
1126
- // If you click the breadcrumb back to the list view:
1127
- //
1128
- // <NavLink to="/list" unstable_viewTransition>
1129
- //
1130
- // We should apply the transition because it's indicated as active going
1131
- // from /list -> /details/1 and therefore should be active on the reverse
1132
- // (even though this isn't strictly a POP reverse)
1133
- return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
1307
+ if (!vtContext.isTransitioning) {
1308
+ return false;
1134
1309
  }
1135
- return false;
1310
+ let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
1311
+ let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
1312
+ // Transition is active if we're going to or coming from the indicated
1313
+ // destination. This ensures that other PUSH navigations that reverse
1314
+ // an indicated transition apply. I.e., on the list view you have:
1315
+ //
1316
+ // <NavLink to="/details/1" unstable_viewTransition>
1317
+ //
1318
+ // If you click the breadcrumb back to the list view:
1319
+ //
1320
+ // <NavLink to="/list" unstable_viewTransition>
1321
+ //
1322
+ // We should apply the transition because it's indicated as active going
1323
+ // from /list -> /details/1 and therefore should be active on the reverse
1324
+ // (even though this isn't strictly a POP reverse)
1325
+ return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
1136
1326
  }
1137
1327
  //#endregion
1138
1328
 
1139
- export { BrowserRouter, Form, HashRouter, Link, NavLink, ScrollRestoration, 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 };
1329
+ export { BrowserRouter, Form, HashRouter, Link, NavLink, RouterProvider, ScrollRestoration, 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 };
1140
1330
  //# sourceMappingURL=index.js.map