react-router-dom
Advanced tools
Comparing version 0.0.0-experimental-48058118 to 0.0.0-experimental-63b6834e
# `react-router-dom` | ||
## 6.8.1 | ||
### Patch Changes | ||
- Improved absolute url detection in `Link` component (now also supports `mailto:` urls) ([#9994](https://github.com/remix-run/react-router/pull/9994)) | ||
- Fix partial object (search or hash only) pathnames losing current path value ([#10029](https://github.com/remix-run/react-router/pull/10029)) | ||
- Updated dependencies: | ||
- `react-router@6.8.1` | ||
- `@remix-run/router@1.3.2` | ||
## 6.8.0 | ||
@@ -4,0 +14,0 @@ |
@@ -12,6 +12,6 @@ /** | ||
export { createSearchParams }; | ||
export type { ActionFunction, ActionFunctionArgs, ActionFunctionWithMiddleware, ActionFunctionArgsWithMiddleware, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, Fetcher, FutureConfig, Hash, IndexRouteObject, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, LoaderFunctionArgs, LoaderFunctionWithMiddleware, LoaderFunctionArgsWithMiddleware, Location, MemoryRouterProps, MiddlewareContext, MiddlewareFunction, MiddlewareFunctionArgs, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, NonIndexRouteObject, OutletProps, Params, ParamParseKey, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RelativeRoutingType, RouteMatch, RouteObject, RouteProps, RouterProps, RouterProviderProps, RoutesProps, Search, ShouldRevalidateFunction, To, } from "react-router"; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createMemoryRouter, createMiddlewareContext, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, 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"; | ||
export type { ActionFunction, ActionFunctionArgs, AwaitProps, unstable_Blocker, unstable_BlockerFunction, DataRouteMatch, DataRouteObject, 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, To, } from "react-router"; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, 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"; | ||
/** @internal */ | ||
export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_enhanceManualRouteObjects, } from "react-router"; | ||
export { UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, } from "react-router"; | ||
declare global { | ||
@@ -24,2 +24,5 @@ var __staticRouterHydrationData: HydrationState | undefined; | ||
window?: Window; | ||
onInitialize?: (args: { | ||
router: RemixRouter; | ||
}) => void; | ||
}): RemixRouter; | ||
@@ -30,2 +33,5 @@ export declare function createHashRouter(routes: RouteObject[], opts?: { | ||
window?: Window; | ||
onInitialize?: (args: { | ||
router: RemixRouter; | ||
}) => void; | ||
}): RemixRouter; | ||
@@ -32,0 +38,0 @@ export interface BrowserRouterProps { |
/** | ||
* React Router DOM v0.0.0-experimental-48058118 | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* | ||
@@ -12,4 +12,4 @@ * Copyright (c) Remix Software Inc. | ||
import * as React from 'react'; | ||
import { UNSAFE_enhanceManualRouteObjects, Router, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_enhanceManualRouteObjects, createMemoryRouter, createMiddlewareContext, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, 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'; | ||
import { Router, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, 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'; | ||
import { createRouter, createBrowserHistory, createHashHistory, ErrorResponse, invariant, joinPaths } from '@remix-run/router'; | ||
@@ -204,3 +204,5 @@ | ||
hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(), | ||
routes: UNSAFE_enhanceManualRouteObjects(routes) | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
}).initialize(); | ||
@@ -215,3 +217,5 @@ } | ||
hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(), | ||
routes: UNSAFE_enhanceManualRouteObjects(routes) | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
}).initialize(); | ||
@@ -218,0 +222,0 @@ } |
/** | ||
* React Router DOM v0.0.0-experimental-48058118 | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* React Router DOM v0.0.0-experimental-48058118 | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* | ||
@@ -12,4 +12,4 @@ * Copyright (c) Remix Software Inc. | ||
import * as React from 'react'; | ||
import { UNSAFE_enhanceManualRouteObjects, Router, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, UNSAFE_enhanceManualRouteObjects, createMemoryRouter, createMiddlewareContext, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, 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'; | ||
import { Router, useHref, useResolvedPath, useLocation, UNSAFE_DataRouterStateContext, UNSAFE_NavigationContext, useNavigate, createPath, UNSAFE_RouteContext, useMatches, useNavigation, unstable_useBlocker, UNSAFE_DataRouterContext } from 'react-router'; | ||
export { AbortedDeferredError, Await, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, RouterProvider, Routes, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, UNSAFE_LocationContext, UNSAFE_NavigationContext, UNSAFE_RouteContext, createMemoryRouter, createPath, createRoutesFromChildren, createRoutesFromElements, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, 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'; | ||
import { createRouter, createBrowserHistory, createHashHistory, ErrorResponse, invariant, joinPaths } from '@remix-run/router'; | ||
@@ -170,3 +170,5 @@ | ||
hydrationData: opts?.hydrationData || parseHydrationData(), | ||
routes: UNSAFE_enhanceManualRouteObjects(routes) | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts?.onInitialize | ||
}).initialize(); | ||
@@ -181,3 +183,5 @@ } | ||
hydrationData: opts?.hydrationData || parseHydrationData(), | ||
routes: UNSAFE_enhanceManualRouteObjects(routes) | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts?.onInitialize | ||
}).initialize(); | ||
@@ -184,0 +188,0 @@ } |
/** | ||
* React Router DOM v0.0.0-experimental-48058118 | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
import*as e from"react";import{UNSAFE_enhanceManualRouteObjects as t,Router as r,useHref as n,useResolvedPath as o,useLocation as a,UNSAFE_DataRouterStateContext as i,UNSAFE_NavigationContext as s,useNavigate as l,createPath as u,UNSAFE_RouteContext as c,useMatches as f,useNavigation as m,unstable_useBlocker as d,UNSAFE_DataRouterContext as h}from"react-router";export{AbortedDeferredError,Await,MemoryRouter,Navigate,NavigationType,Outlet,Route,Router,RouterProvider,Routes,UNSAFE_DataRouterContext,UNSAFE_DataRouterStateContext,UNSAFE_LocationContext,UNSAFE_NavigationContext,UNSAFE_RouteContext,UNSAFE_enhanceManualRouteObjects,createMemoryRouter,createMiddlewareContext,createPath,createRoutesFromChildren,createRoutesFromElements,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,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";import{createRouter as p,createBrowserHistory as w,createHashHistory as g,ErrorResponse as y,invariant as v,joinPaths as b}from"@remix-run/router";const R="application/x-www-form-urlencoded";function S(e){return null!=e&&"string"==typeof e.tagName}function E(e=""){return new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function C(e,t,r){let n,o,a,i;if(S(s=e)&&"form"===s.tagName.toLowerCase()){let s=r.submissionTrigger;n=r.method||e.getAttribute("method")||"get",o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||R,i=new FormData(e),s&&s.name&&i.append(s.name,s.value)}else if(function(e){return S(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return S(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let s=e.form;if(null==s)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||s.getAttribute("method")||"get",o=r.action||e.getAttribute("formaction")||s.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||s.getAttribute("enctype")||R,i=new FormData(s),e.name&&i.append(e.name,e.value)}else{if(S(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||"get",o=r.action||t,a=r.encType||R,e instanceof FormData)i=e;else if(i=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)i.append(t,r);else if(null!=e)for(let t of Object.keys(e))i.append(t,e[t])}var s;let{protocol:l,host:u}=window.location;return{url:new URL(o,`${l}//${u}`),method:n.toLowerCase(),encType:a,formData:i}}function A(e,r){return p({basename:r?.basename,history:w({window:r?.window}),hydrationData:r?.hydrationData||x(),routes:t(e)}).initialize()}function L(e,r){return p({basename:r?.basename,history:g({window:r?.window}),hydrationData:r?.hydrationData||x(),routes:t(e)}).initialize()}function x(){let e=window?.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:U(e.errors)}),e}function U(e){if(!e)return null;let t=Object.entries(e),r={};for(let[n,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[n]=new y(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let e=new Error(o.message);e.stack="",r[n]=e}else r[n]=o;return r}function F({basename:t,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=w({window:o,v5Compat:!0}));let i=a.current,[s,l]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(l)),[i]),e.createElement(r,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:i})}function D({basename:t,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=g({window:o,v5Compat:!0}));let i=a.current,[s,l]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(l)),[i]),e.createElement(r,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:i})}function N({basename:t,children:n,history:o}){const[a,i]=e.useState({action:o.action,location:o.location});return e.useLayoutEffect((()=>o.listen(i)),[o]),e.createElement(r,{basename:t,children:n,location:a.location,navigationType:a.action,navigator:o})}const P="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,T=e.forwardRef((function({onClick:t,relative:r,reloadDocument:o,replace:a,state:i,target:s,to:l,preventScrollReset:u,...c},f){let m,d=!1;if(P&&"string"==typeof l&&/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(l)){m=l;let e=new URL(window.location.href),t=l.startsWith("//")?new URL(e.protocol+l):new URL(l);t.origin===e.origin?l=t.pathname+t.search+t.hash:d=!0}let h=n(l,{relative:r}),p=B(l,{replace:a,state:i,target:s,preventScrollReset:u,relative:r});return e.createElement("a",Object.assign({},c,{href:m||h,onClick:d||o?t:function(e){t&&t(e),e.defaultPrevented||p(e)},ref:f,target:s}))})),_=e.forwardRef((function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:l=!1,style:u,to:c,children:f,...m},d){let h=o(c,{relative:m.relative}),p=a(),w=e.useContext(i),{navigator:g}=e.useContext(s),y=g.encodeLocation?g.encodeLocation(h).pathname:h.pathname,v=p.pathname,b=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;r||(v=v.toLowerCase(),b=b?b.toLowerCase():null,y=y.toLowerCase());let R,S=v===y||!l&&v.startsWith(y)&&"/"===v.charAt(y.length),E=null!=b&&(b===y||!l&&b.startsWith(y)&&"/"===b.charAt(y.length)),C=S?t:void 0;R="function"==typeof n?n({isActive:S,isPending:E}):[n,S?"active":null,E?"pending":null].filter(Boolean).join(" ");let A="function"==typeof u?u({isActive:S,isPending:E}):u;return e.createElement(T,Object.assign({},m,{"aria-current":C,className:R,ref:d,style:A,to:c}),"function"==typeof f?f({isActive:S,isPending:E}):f)})),k=e.forwardRef(((t,r)=>e.createElement(O,Object.assign({},t,{ref:r})))),O=e.forwardRef((({reloadDocument:t,replace:r,method:n="get",action:o,onSubmit:a,fetcherKey:i,routeId:s,relative:l,preventScrollReset:u,...c},f)=>{let m=Y(i,s),d="get"===n.toLowerCase()?"get":"post",h=$(o,{relative:l});return e.createElement("form",Object.assign({ref:f,method:d,action:h,onSubmit:t?a:e=>{if(a&&a(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,o=t?.getAttribute("formmethod")||n;m(t||e.currentTarget,{method:o,replace:r,relative:l,preventScrollReset:u})}},c))}));function K({getKey:e,storageKey:t}){return Q({getKey:e,storageKey:t}),null}var j,I;function M(t){let r=e.useContext(h);return r||v(!1),r}function z(t){let r=e.useContext(i);return r||v(!1),r}function B(t,{target:r,replace:n,state:i,preventScrollReset:s,relative:c}={}){let f=l(),m=a(),d=o(t,{relative:c});return e.useCallback((e=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(e,r)){e.preventDefault();let r=void 0!==n?n:u(m)===u(d);f(t,{replace:r,state:i,preventScrollReset:s,relative:c})}}),[m,f,d,n,i,r,t,s,c])}function H(t){let r=e.useRef(E(t)),n=e.useRef(!1),o=a(),i=e.useMemo((()=>function(e,t){let r=E(e);if(t)for(let n of t.keys())r.has(n)||t.getAll(n).forEach((e=>{r.append(n,e)}));return r}(o.search,n.current?null:r.current)),[o.search]),s=l(),u=e.useCallback(((e,t)=>{const r=E("function"==typeof e?e(i):e);n.current=!0,s("?"+r,t)}),[s,i]);return[i,u]}function W(){return Y()}function Y(t,r){let{router:n}=M(j.UseSubmitImpl),o=$();return e.useCallback(((e,a={})=>{if("undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:s,formData:l,url:u}=C(e,o,a),c=u.pathname+u.search,f={replace:a.replace,preventScrollReset:a.preventScrollReset,formData:l,formMethod:i,formEncType:s};t?(null==r&&v(!1),n.fetch(t,r,c,f)):n.navigate(c,f)}),[o,n,t,r])}function $(t,{relative:r}={}){let{basename:n}=e.useContext(s),i=e.useContext(c);i||v(!1);let[l]=i.matches.slice(-1),f={...o(t||".",{relative:r})},m=a();if(null==t&&(f.search=m.search,f.hash=m.hash,l.route.index)){let e=new URLSearchParams(f.search);e.delete("index"),f.search=e.toString()?`?${e.toString()}`:""}return t&&"."!==t||!l.route.index||(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),"/"!==n&&(f.pathname="/"===f.pathname?n:b([n,f.pathname])),u(f)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(j||(j={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(I||(I={}));let J=0;function V(){let{router:t}=M(j.UseFetcher),r=e.useContext(c);r||v(!1);let n=r.matches[r.matches.length-1]?.route.id;null==n&&v(!1);let[o]=e.useState((()=>String(++J))),[a]=e.useState((()=>(n||v(!1),function(t,r){return e.forwardRef(((n,o)=>e.createElement(O,Object.assign({},n,{ref:o,fetcherKey:t,routeId:r}))))}(o,n)))),[i]=e.useState((()=>e=>{t||v(!1),n||v(!1),t.fetch(o,n,e)})),s=Y(o,n),l=t.getFetcher(o),u=e.useMemo((()=>({Form:a,submit:s,load:i,...l})),[l,a,s,i]);return e.useEffect((()=>()=>{t?t.deleteFetcher(o):console.warn("No fetcher available to clean up from useFetcher()")}),[t,o]),u}function q(){return[...z(I.UseFetchers).fetchers.values()]}let G={};function Q({getKey:t,storageKey:r}={}){let{router:n}=M(j.UseScrollRestoration),{restoreScrollPosition:o,preventScrollReset:i}=z(I.UseScrollRestoration),s=a(),l=f(),u=m();e.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("pagehide",t,e),()=>{window.removeEventListener("pagehide",t,e)}}),[t,n])}(e.useCallback((()=>{if("idle"===u.state){let e=(t?t(s,l):null)||s.key;G[e]=window.scrollY}sessionStorage.setItem(r||"react-router-scroll-positions",JSON.stringify(G)),window.history.scrollRestoration="auto"}),[r,t,u.state,s,l])),"undefined"!=typeof document&&(e.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(r||"react-router-scroll-positions");e&&(G=JSON.parse(e))}catch(e){}}),[r]),e.useLayoutEffect((()=>{let e=n?.enableScrollRestoration(G,(()=>window.scrollY),t);return()=>e&&e()}),[n,t]),e.useLayoutEffect((()=>{if(!1!==o)if("number"!=typeof o){if(s.hash){let e=document.getElementById(s.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==i&&window.scrollTo(0,0)}else window.scrollTo(0,o)}),[s,o,i]))}function X(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("beforeunload",t,e),()=>{window.removeEventListener("beforeunload",t,e)}}),[t,n])}function Z({when:t,message:r}){let n=d(t);e.useEffect((()=>{"blocked"!==n.state||t||n.reset()}),[n,t]),e.useEffect((()=>{if("blocked"===n.state){window.confirm(r)?setTimeout(n.proceed,0):n.reset()}}),[n,r])}export{F as BrowserRouter,k as Form,D as HashRouter,T as Link,_ as NavLink,K as ScrollRestoration,Q as UNSAFE_useScrollRestoration,A as createBrowserRouter,L as createHashRouter,E as createSearchParams,N as unstable_HistoryRouter,Z as unstable_usePrompt,X as useBeforeUnload,V as useFetcher,q as useFetchers,$ as useFormAction,B as useLinkClickHandler,H as useSearchParams,W as useSubmit}; | ||
import*as e from"react";import{Router as t,useHref as r,useResolvedPath as n,useLocation as o,UNSAFE_DataRouterStateContext as a,UNSAFE_NavigationContext as i,useNavigate as s,createPath as l,UNSAFE_RouteContext as u,useMatches as c,useNavigation as f,unstable_useBlocker as m,UNSAFE_DataRouterContext as d}from"react-router";export{AbortedDeferredError,Await,MemoryRouter,Navigate,NavigationType,Outlet,Route,Router,RouterProvider,Routes,UNSAFE_DataRouterContext,UNSAFE_DataRouterStateContext,UNSAFE_LocationContext,UNSAFE_NavigationContext,UNSAFE_RouteContext,createMemoryRouter,createPath,createRoutesFromChildren,createRoutesFromElements,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,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";import{createRouter as h,createBrowserHistory as p,createHashHistory as w,ErrorResponse as g,invariant as y,joinPaths as v}from"@remix-run/router";const b="application/x-www-form-urlencoded";function R(e){return null!=e&&"string"==typeof e.tagName}function E(e=""){return new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function S(e,t,r){let n,o,a,i;if(R(s=e)&&"form"===s.tagName.toLowerCase()){let s=r.submissionTrigger;n=r.method||e.getAttribute("method")||"get",o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||b,i=new FormData(e),s&&s.name&&i.append(s.name,s.value)}else if(function(e){return R(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return R(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let s=e.form;if(null==s)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||s.getAttribute("method")||"get",o=r.action||e.getAttribute("formaction")||s.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||s.getAttribute("enctype")||b,i=new FormData(s),e.name&&i.append(e.name,e.value)}else{if(R(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||"get",o=r.action||t,a=r.encType||b,e instanceof FormData)i=e;else if(i=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)i.append(t,r);else if(null!=e)for(let t of Object.keys(e))i.append(t,e[t])}var s;let{protocol:l,host:u}=window.location;return{url:new URL(o,`${l}//${u}`),method:n.toLowerCase(),encType:a,formData:i}}function C(e,t){return h({basename:t?.basename,history:p({window:t?.window}),hydrationData:t?.hydrationData||A(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:t?.onInitialize}).initialize()}function L(e,t){return h({basename:t?.basename,history:w({window:t?.window}),hydrationData:t?.hydrationData||A(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:t?.onInitialize}).initialize()}function A(){let e=window?.__staticRouterHydrationData;return e&&e.errors&&(e={...e,errors:x(e.errors)}),e}function x(e){if(!e)return null;let t=Object.entries(e),r={};for(let[n,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[n]=new g(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let e=new Error(o.message);e.stack="",r[n]=e}else r[n]=o;return r}function U({basename:r,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=p({window:o,v5Compat:!0}));let i=a.current,[s,l]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(l)),[i]),e.createElement(t,{basename:r,children:n,location:s.location,navigationType:s.action,navigator:i})}function D({basename:r,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=w({window:o,v5Compat:!0}));let i=a.current,[s,l]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(l)),[i]),e.createElement(t,{basename:r,children:n,location:s.location,navigationType:s.action,navigator:i})}function F({basename:r,children:n,history:o}){const[a,i]=e.useState({action:o.action,location:o.location});return e.useLayoutEffect((()=>o.listen(i)),[o]),e.createElement(t,{basename:r,children:n,location:a.location,navigationType:a.action,navigator:o})}const N="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,P=e.forwardRef((function({onClick:t,relative:n,reloadDocument:o,replace:a,state:i,target:s,to:l,preventScrollReset:u,...c},f){let m,d=!1;if(N&&"string"==typeof l&&/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(l)){m=l;let e=new URL(window.location.href),t=l.startsWith("//")?new URL(e.protocol+l):new URL(l);t.origin===e.origin?l=t.pathname+t.search+t.hash:d=!0}let h=r(l,{relative:n}),p=M(l,{replace:a,state:i,target:s,preventScrollReset:u,relative:n});return e.createElement("a",Object.assign({},c,{href:m||h,onClick:d||o?t:function(e){t&&t(e),e.defaultPrevented||p(e)},ref:f,target:s}))})),T=e.forwardRef((function({"aria-current":t="page",caseSensitive:r=!1,className:s="",end:l=!1,style:u,to:c,children:f,...m},d){let h=n(c,{relative:m.relative}),p=o(),w=e.useContext(a),{navigator:g}=e.useContext(i),y=g.encodeLocation?g.encodeLocation(h).pathname:h.pathname,v=p.pathname,b=w&&w.navigation&&w.navigation.location?w.navigation.location.pathname:null;r||(v=v.toLowerCase(),b=b?b.toLowerCase():null,y=y.toLowerCase());let R,E=v===y||!l&&v.startsWith(y)&&"/"===v.charAt(y.length),S=null!=b&&(b===y||!l&&b.startsWith(y)&&"/"===b.charAt(y.length)),C=E?t:void 0;R="function"==typeof s?s({isActive:E,isPending:S}):[s,E?"active":null,S?"pending":null].filter(Boolean).join(" ");let L="function"==typeof u?u({isActive:E,isPending:S}):u;return e.createElement(P,Object.assign({},m,{"aria-current":C,className:R,ref:d,style:L,to:c}),"function"==typeof f?f({isActive:E,isPending:S}):f)})),_=e.forwardRef(((t,r)=>e.createElement(k,Object.assign({},t,{ref:r})))),k=e.forwardRef((({reloadDocument:t,replace:r,method:n="get",action:o,onSubmit:a,fetcherKey:i,routeId:s,relative:l,preventScrollReset:u,...c},f)=>{let m=W(i,s),d="get"===n.toLowerCase()?"get":"post",h=Y(o,{relative:l});return e.createElement("form",Object.assign({ref:f,method:d,action:h,onSubmit:t?a:e=>{if(a&&a(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,o=t?.getAttribute("formmethod")||n;m(t||e.currentTarget,{method:o,replace:r,relative:l,preventScrollReset:u})}},c))}));function I({getKey:e,storageKey:t}){return G({getKey:e,storageKey:t}),null}var O,K;function j(t){let r=e.useContext(d);return r||y(!1),r}function z(t){let r=e.useContext(a);return r||y(!1),r}function M(t,{target:r,replace:a,state:i,preventScrollReset:u,relative:c}={}){let f=s(),m=o(),d=n(t,{relative:c});return e.useCallback((e=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(e,r)){e.preventDefault();let r=void 0!==a?a:l(m)===l(d);f(t,{replace:r,state:i,preventScrollReset:u,relative:c})}}),[m,f,d,a,i,r,t,u,c])}function B(t){let r=e.useRef(E(t)),n=e.useRef(!1),a=o(),i=e.useMemo((()=>function(e,t){let r=E(e);if(t)for(let n of t.keys())r.has(n)||t.getAll(n).forEach((e=>{r.append(n,e)}));return r}(a.search,n.current?null:r.current)),[a.search]),l=s(),u=e.useCallback(((e,t)=>{const r=E("function"==typeof e?e(i):e);n.current=!0,l("?"+r,t)}),[l,i]);return[i,u]}function H(){return W()}function W(t,r){let{router:n}=j(O.UseSubmitImpl),o=Y();return e.useCallback(((e,a={})=>{if("undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:s,formData:l,url:u}=S(e,o,a),c=u.pathname+u.search,f={replace:a.replace,preventScrollReset:a.preventScrollReset,formData:l,formMethod:i,formEncType:s};t?(null==r&&y(!1),n.fetch(t,r,c,f)):n.navigate(c,f)}),[o,n,t,r])}function Y(t,{relative:r}={}){let{basename:a}=e.useContext(i),s=e.useContext(u);s||y(!1);let[c]=s.matches.slice(-1),f={...n(t||".",{relative:r})},m=o();if(null==t&&(f.search=m.search,f.hash=m.hash,c.route.index)){let e=new URLSearchParams(f.search);e.delete("index"),f.search=e.toString()?`?${e.toString()}`:""}return t&&"."!==t||!c.route.index||(f.search=f.search?f.search.replace(/^\?/,"?index&"):"?index"),"/"!==a&&(f.pathname="/"===f.pathname?a:v([a,f.pathname])),l(f)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(O||(O={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(K||(K={}));let $=0;function J(){let{router:t}=j(O.UseFetcher),r=e.useContext(u);r||y(!1);let n=r.matches[r.matches.length-1]?.route.id;null==n&&y(!1);let[o]=e.useState((()=>String(++$))),[a]=e.useState((()=>(n||y(!1),function(t,r){return e.forwardRef(((n,o)=>e.createElement(k,Object.assign({},n,{ref:o,fetcherKey:t,routeId:r}))))}(o,n)))),[i]=e.useState((()=>e=>{t||y(!1),n||y(!1),t.fetch(o,n,e)})),s=W(o,n),l=t.getFetcher(o),c=e.useMemo((()=>({Form:a,submit:s,load:i,...l})),[l,a,s,i]);return e.useEffect((()=>()=>{t?t.deleteFetcher(o):console.warn("No fetcher available to clean up from useFetcher()")}),[t,o]),c}function V(){return[...z(K.UseFetchers).fetchers.values()]}let q={};function G({getKey:t,storageKey:r}={}){let{router:n}=j(O.UseScrollRestoration),{restoreScrollPosition:a,preventScrollReset:i}=z(K.UseScrollRestoration),s=o(),l=c(),u=f();e.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("pagehide",t,e),()=>{window.removeEventListener("pagehide",t,e)}}),[t,n])}(e.useCallback((()=>{if("idle"===u.state){let e=(t?t(s,l):null)||s.key;q[e]=window.scrollY}sessionStorage.setItem(r||"react-router-scroll-positions",JSON.stringify(q)),window.history.scrollRestoration="auto"}),[r,t,u.state,s,l])),"undefined"!=typeof document&&(e.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(r||"react-router-scroll-positions");e&&(q=JSON.parse(e))}catch(e){}}),[r]),e.useLayoutEffect((()=>{let e=n?.enableScrollRestoration(q,(()=>window.scrollY),t);return()=>e&&e()}),[n,t]),e.useLayoutEffect((()=>{if(!1!==a)if("number"!=typeof a){if(s.hash){let e=document.getElementById(s.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==i&&window.scrollTo(0,0)}else window.scrollTo(0,a)}),[s,a,i]))}function Q(t,r){let{capture:n}=r||{};e.useEffect((()=>{let e=null!=n?{capture:n}:void 0;return window.addEventListener("beforeunload",t,e),()=>{window.removeEventListener("beforeunload",t,e)}}),[t,n])}function X({when:t,message:r}){let n=m(t);e.useEffect((()=>{"blocked"!==n.state||t||n.reset()}),[n,t]),e.useEffect((()=>{if("blocked"===n.state){window.confirm(r)?setTimeout(n.proceed,0):n.reset()}}),[n,r])}export{U as BrowserRouter,_ as Form,D as HashRouter,P as Link,T as NavLink,I as ScrollRestoration,G as UNSAFE_useScrollRestoration,C as createBrowserRouter,L as createHashRouter,E as createSearchParams,F as unstable_HistoryRouter,X as unstable_usePrompt,Q as useBeforeUnload,J as useFetcher,V as useFetchers,Y as useFormAction,M as useLinkClickHandler,B as useSearchParams,H as useSubmit}; | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
import * as React from "react"; | ||
import type { Router as RemixRouter, StaticHandlerContext } from "@remix-run/router"; | ||
import type { Router as RemixRouter, StaticHandlerContext, CreateStaticHandlerOptions as RouterCreateStaticHandlerOptions } from "@remix-run/router"; | ||
import type { Location, RouteObject } from "react-router-dom"; | ||
@@ -25,2 +25,5 @@ export interface StaticRouterProps { | ||
export declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): JSX.Element; | ||
declare type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "hasErrorBoundary">; | ||
export declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): import("@remix-run/router").StaticHandler; | ||
export declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext): RemixRouter; | ||
export {}; |
@@ -166,22 +166,14 @@ 'use strict'; | ||
}; | ||
} // Temporary manifest generation - we should optimize this by combining the | ||
// tree-walks between convertRoutesToDataRoutes, enhanceManualRouteObjects, | ||
// and generateManifest. | ||
// Also look into getting rid of `route as AgnosticDataRouteObject` down below? | ||
} | ||
let hasErrorBoundary = route => Boolean(route.errorElement); | ||
function generateManifest(routes, manifest = new Map()) { | ||
routes.forEach(route => { | ||
manifest.set(route.id, route); | ||
if (route.children) { | ||
generateManifest(route.children, manifest); | ||
} | ||
function createStaticHandler(routes, opts) { | ||
return router.createStaticHandler(routes, { ...opts, | ||
hasErrorBoundary | ||
}); | ||
return manifest; | ||
} | ||
function createStaticRouter(routes, context) { | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(reactRouterDom.UNSAFE_enhanceManualRouteObjects(routes)); | ||
let manifest = generateManifest(dataRoutes); // Because our context matches may be from a framework-agnostic set of | ||
let manifest = {}; | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(routes, hasErrorBoundary, undefined, manifest); // Because our context matches may be from a framework-agnostic set of | ||
// routes passed to createStaticHandler(), we update them here with our | ||
@@ -191,5 +183,5 @@ // newly created/enhanced data routes | ||
let matches = context.matches.map(match => { | ||
let route = manifest.get(match.route.id) || match.route; | ||
let route = manifest[match.route.id] || match.route; | ||
return { ...match, | ||
route: route | ||
route | ||
}; | ||
@@ -267,3 +259,3 @@ }); | ||
getBlocker() { | ||
throw msg("getBlocker"); | ||
return router.IDLE_BLOCKER; | ||
}, | ||
@@ -296,2 +288,3 @@ | ||
exports.StaticRouterProvider = StaticRouterProvider; | ||
exports.createStaticHandler = createStaticHandler; | ||
exports.createStaticRouter = createStaticRouter; |
/** | ||
* React Router DOM v0.0.0-experimental-48058118 | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* | ||
@@ -225,3 +225,5 @@ * Copyright (c) Remix Software Inc. | ||
hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(), | ||
routes: reactRouter.UNSAFE_enhanceManualRouteObjects(routes) | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
}).initialize(); | ||
@@ -236,3 +238,5 @@ } | ||
hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(), | ||
routes: reactRouter.UNSAFE_enhanceManualRouteObjects(routes) | ||
routes, | ||
hasErrorBoundary: route => Boolean(route.errorElement), | ||
onInitialize: opts == null ? void 0 : opts.onInitialize | ||
}).initialize(); | ||
@@ -1120,6 +1124,2 @@ } | ||
}); | ||
Object.defineProperty(exports, 'UNSAFE_enhanceManualRouteObjects', { | ||
enumerable: true, | ||
get: function () { return reactRouter.UNSAFE_enhanceManualRouteObjects; } | ||
}); | ||
Object.defineProperty(exports, 'createMemoryRouter', { | ||
@@ -1129,6 +1129,2 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, 'createMiddlewareContext', { | ||
enumerable: true, | ||
get: function () { return reactRouter.createMiddlewareContext; } | ||
}); | ||
Object.defineProperty(exports, 'createPath', { | ||
@@ -1135,0 +1131,0 @@ enumerable: true, |
/** | ||
* React Router DOM v0.0.0-experimental-48058118 | ||
* React Router DOM v0.0.0-experimental-63b6834e | ||
* | ||
@@ -11,3 +11,3 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-router"),require("@remix-run/router")):"function"==typeof define&&define.amd?define(["exports","react","react-router","@remix-run/router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDOM={},e.React,e.ReactRouter,e.RemixRouter)}(this,(function(e,t,r,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=o(t);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function i(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}const c="get",l="application/x-www-form-urlencoded";function s(e){return null!=e&&"string"==typeof e.tagName}function f(e){return void 0===e&&(e=""),new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function d(e,t,r){let n,o,a,u;if(s(i=e)&&"form"===i.tagName.toLowerCase()){let i=r.submissionTrigger;n=r.method||e.getAttribute("method")||c,o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||l,u=new FormData(e),i&&i.name&&u.append(i.name,i.value)}else if(function(e){return s(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return s(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||i.getAttribute("method")||c,o=r.action||e.getAttribute("formaction")||i.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||i.getAttribute("enctype")||l,u=new FormData(i),e.name&&u.append(e.name,e.value)}else{if(s(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||c,o=r.action||t,a=r.encType||l,e instanceof FormData)u=e;else if(u=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)u.append(t,r);else if(null!=e)for(let t of Object.keys(e))u.append(t,e[t])}var i;let{protocol:f,host:d}=window.location;return{url:new URL(o,f+"//"+d),method:n.toLowerCase(),encType:a,formData:u}}const m=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"],b=["aria-current","caseSensitive","className","end","style","to","children"],p=["reloadDocument","replace","method","action","onSubmit","fetcherKey","routeId","relative","preventScrollReset"];function h(){var e;let t=null==(e=window)?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=u({},t,{errors:y(t.errors)})),t}function y(e){if(!e)return null;let t=Object.entries(e),r={};for(let[e,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[e]=new n.ErrorResponse(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let t=new Error(o.message);t.stack="",r[e]=t}else r[e]=o;return r}const g="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,v=a.forwardRef((function(e,t){let n,{onClick:o,relative:c,reloadDocument:l,replace:s,state:f,target:d,to:b,preventScrollReset:p}=e,h=i(e,m),y=!1;if(g&&"string"==typeof b&&/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(b)){n=b;let e=new URL(window.location.href),t=b.startsWith("//")?new URL(e.protocol+b):new URL(b);t.origin===e.origin?b=t.pathname+t.search+t.hash:y=!0}let v=r.useHref(b,{relative:c}),R=A(b,{replace:s,state:f,target:d,preventScrollReset:p,relative:c});return a.createElement("a",u({},h,{href:n||v,onClick:y||l?o:function(e){o&&o(e),e.defaultPrevented||R(e)},ref:t,target:d}))})),R=a.forwardRef((function(e,t){let{"aria-current":n="page",caseSensitive:o=!1,className:c="",end:l=!1,style:s,to:f,children:d}=e,m=i(e,b),p=r.useResolvedPath(f,{relative:m.relative}),h=r.useLocation(),y=a.useContext(r.UNSAFE_DataRouterStateContext),{navigator:g}=a.useContext(r.UNSAFE_NavigationContext),R=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=h.pathname,P=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;o||(w=w.toLowerCase(),P=P?P.toLowerCase():null,R=R.toLowerCase());let O,S=w===R||!l&&w.startsWith(R)&&"/"===w.charAt(R.length),j=null!=P&&(P===R||!l&&P.startsWith(R)&&"/"===P.charAt(R.length)),E=S?n:void 0;O="function"==typeof c?c({isActive:S,isPending:j}):[c,S?"active":null,j?"pending":null].filter(Boolean).join(" ");let A="function"==typeof s?s({isActive:S,isPending:j}):s;return a.createElement(v,u({},m,{"aria-current":E,className:O,ref:t,style:A,to:f}),"function"==typeof d?d({isActive:S,isPending:j}):d)})),w=a.forwardRef(((e,t)=>a.createElement(P,u({},e,{ref:t})))),P=a.forwardRef(((e,t)=>{let{reloadDocument:r,replace:n,method:o=c,action:l,onSubmit:s,fetcherKey:f,routeId:d,relative:m,preventScrollReset:b}=e,h=i(e,p),y=C(f,d),g="get"===o.toLowerCase()?"get":"post",v=N(l,{relative:m});return a.createElement("form",u({ref:t,method:g,action:v,onSubmit:r?s:e=>{if(s&&s(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,r=(null==t?void 0:t.getAttribute("formmethod"))||o;y(t||e.currentTarget,{method:r,replace:n,relative:m,preventScrollReset:b})}},h))}));var O,S;function j(e){let t=a.useContext(r.UNSAFE_DataRouterContext);return t||n.invariant(!1),t}function E(e){let t=a.useContext(r.UNSAFE_DataRouterStateContext);return t||n.invariant(!1),t}function A(e,t){let{target:n,replace:o,state:u,preventScrollReset:i,relative:c}=void 0===t?{}:t,l=r.useNavigate(),s=r.useLocation(),f=r.useResolvedPath(e,{relative:c});return a.useCallback((t=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(t,n)){t.preventDefault();let n=void 0!==o?o:r.createPath(s)===r.createPath(f);l(e,{replace:n,state:u,preventScrollReset:i,relative:c})}}),[s,l,f,o,u,n,e,i,c])}function C(e,t){let{router:r}=j(O.UseSubmitImpl),o=N();return a.useCallback((function(a,u){if(void 0===u&&(u={}),"undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:c,formData:l,url:s}=d(a,o,u),f=s.pathname+s.search,m={replace:u.replace,preventScrollReset:u.preventScrollReset,formData:l,formMethod:i,formEncType:c};e?(null==t&&n.invariant(!1),r.fetch(e,t,f,m)):r.navigate(f,m)}),[o,r,e,t])}function N(e,t){let{relative:o}=void 0===t?{}:t,{basename:i}=a.useContext(r.UNSAFE_NavigationContext),c=a.useContext(r.UNSAFE_RouteContext);c||n.invariant(!1);let[l]=c.matches.slice(-1),s=u({},r.useResolvedPath(e||".",{relative:o})),f=r.useLocation();if(null==e&&(s.search=f.search,s.hash=f.hash,l.route.index)){let e=new URLSearchParams(s.search);e.delete("index"),s.search=e.toString()?"?"+e.toString():""}return e&&"."!==e||!l.route.index||(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),"/"!==i&&(s.pathname="/"===s.pathname?i:n.joinPaths([i,s.pathname])),r.createPath(s)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(O||(O={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(S||(S={}));let x=0;const F="react-router-scroll-positions";let L={};function U(e){let{getKey:t,storageKey:n}=void 0===e?{}:e,{router:o}=j(O.UseScrollRestoration),{restoreScrollPosition:u,preventScrollReset:i}=E(S.UseScrollRestoration),c=r.useLocation(),l=r.useMatches(),s=r.useNavigation();a.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("pagehide",e,t),()=>{window.removeEventListener("pagehide",e,t)}}),[e,r])}(a.useCallback((()=>{if("idle"===s.state){let e=(t?t(c,l):null)||c.key;L[e]=window.scrollY}sessionStorage.setItem(n||F,JSON.stringify(L)),window.history.scrollRestoration="auto"}),[n,t,s.state,c,l])),"undefined"!=typeof document&&(a.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(n||F);e&&(L=JSON.parse(e))}catch(e){}}),[n]),a.useLayoutEffect((()=>{let e=null==o?void 0:o.enableScrollRestoration(L,(()=>window.scrollY),t);return()=>e&&e()}),[o,t]),a.useLayoutEffect((()=>{if(!1!==u)if("number"!=typeof u){if(c.hash){let e=document.getElementById(c.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==i&&window.scrollTo(0,0)}else window.scrollTo(0,u)}),[c,u,i]))}Object.defineProperty(e,"AbortedDeferredError",{enumerable:!0,get:function(){return r.AbortedDeferredError}}),Object.defineProperty(e,"Await",{enumerable:!0,get:function(){return r.Await}}),Object.defineProperty(e,"MemoryRouter",{enumerable:!0,get:function(){return r.MemoryRouter}}),Object.defineProperty(e,"Navigate",{enumerable:!0,get:function(){return r.Navigate}}),Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return r.NavigationType}}),Object.defineProperty(e,"Outlet",{enumerable:!0,get:function(){return r.Outlet}}),Object.defineProperty(e,"Route",{enumerable:!0,get:function(){return r.Route}}),Object.defineProperty(e,"Router",{enumerable:!0,get:function(){return r.Router}}),Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return r.RouterProvider}}),Object.defineProperty(e,"Routes",{enumerable:!0,get:function(){return r.Routes}}),Object.defineProperty(e,"UNSAFE_DataRouterContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterContext}}),Object.defineProperty(e,"UNSAFE_DataRouterStateContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterStateContext}}),Object.defineProperty(e,"UNSAFE_LocationContext",{enumerable:!0,get:function(){return r.UNSAFE_LocationContext}}),Object.defineProperty(e,"UNSAFE_NavigationContext",{enumerable:!0,get:function(){return r.UNSAFE_NavigationContext}}),Object.defineProperty(e,"UNSAFE_RouteContext",{enumerable:!0,get:function(){return r.UNSAFE_RouteContext}}),Object.defineProperty(e,"UNSAFE_enhanceManualRouteObjects",{enumerable:!0,get:function(){return r.UNSAFE_enhanceManualRouteObjects}}),Object.defineProperty(e,"createMemoryRouter",{enumerable:!0,get:function(){return r.createMemoryRouter}}),Object.defineProperty(e,"createMiddlewareContext",{enumerable:!0,get:function(){return r.createMiddlewareContext}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return r.createPath}}),Object.defineProperty(e,"createRoutesFromChildren",{enumerable:!0,get:function(){return r.createRoutesFromChildren}}),Object.defineProperty(e,"createRoutesFromElements",{enumerable:!0,get:function(){return r.createRoutesFromElements}}),Object.defineProperty(e,"defer",{enumerable:!0,get:function(){return r.defer}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return r.generatePath}}),Object.defineProperty(e,"isRouteErrorResponse",{enumerable:!0,get:function(){return r.isRouteErrorResponse}}),Object.defineProperty(e,"json",{enumerable:!0,get:function(){return r.json}}),Object.defineProperty(e,"matchPath",{enumerable:!0,get:function(){return r.matchPath}}),Object.defineProperty(e,"matchRoutes",{enumerable:!0,get:function(){return r.matchRoutes}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return r.parsePath}}),Object.defineProperty(e,"redirect",{enumerable:!0,get:function(){return r.redirect}}),Object.defineProperty(e,"renderMatches",{enumerable:!0,get:function(){return r.renderMatches}}),Object.defineProperty(e,"resolvePath",{enumerable:!0,get:function(){return r.resolvePath}}),Object.defineProperty(e,"unstable_useBlocker",{enumerable:!0,get:function(){return r.unstable_useBlocker}}),Object.defineProperty(e,"useActionData",{enumerable:!0,get:function(){return r.useActionData}}),Object.defineProperty(e,"useAsyncError",{enumerable:!0,get:function(){return r.useAsyncError}}),Object.defineProperty(e,"useAsyncValue",{enumerable:!0,get:function(){return r.useAsyncValue}}),Object.defineProperty(e,"useHref",{enumerable:!0,get:function(){return r.useHref}}),Object.defineProperty(e,"useInRouterContext",{enumerable:!0,get:function(){return r.useInRouterContext}}),Object.defineProperty(e,"useLoaderData",{enumerable:!0,get:function(){return r.useLoaderData}}),Object.defineProperty(e,"useLocation",{enumerable:!0,get:function(){return r.useLocation}}),Object.defineProperty(e,"useMatch",{enumerable:!0,get:function(){return r.useMatch}}),Object.defineProperty(e,"useMatches",{enumerable:!0,get:function(){return r.useMatches}}),Object.defineProperty(e,"useNavigate",{enumerable:!0,get:function(){return r.useNavigate}}),Object.defineProperty(e,"useNavigation",{enumerable:!0,get:function(){return r.useNavigation}}),Object.defineProperty(e,"useNavigationType",{enumerable:!0,get:function(){return r.useNavigationType}}),Object.defineProperty(e,"useOutlet",{enumerable:!0,get:function(){return r.useOutlet}}),Object.defineProperty(e,"useOutletContext",{enumerable:!0,get:function(){return r.useOutletContext}}),Object.defineProperty(e,"useParams",{enumerable:!0,get:function(){return r.useParams}}),Object.defineProperty(e,"useResolvedPath",{enumerable:!0,get:function(){return r.useResolvedPath}}),Object.defineProperty(e,"useRevalidator",{enumerable:!0,get:function(){return r.useRevalidator}}),Object.defineProperty(e,"useRouteError",{enumerable:!0,get:function(){return r.useRouteError}}),Object.defineProperty(e,"useRouteLoaderData",{enumerable:!0,get:function(){return r.useRouteLoaderData}}),Object.defineProperty(e,"useRoutes",{enumerable:!0,get:function(){return r.useRoutes}}),e.BrowserRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createBrowserHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Form=w,e.HashRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createHashHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Link=v,e.NavLink=R,e.ScrollRestoration=function(e){let{getKey:t,storageKey:r}=e;return U({getKey:t,storageKey:r}),null},e.UNSAFE_useScrollRestoration=U,e.createBrowserRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createBrowserHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:r.UNSAFE_enhanceManualRouteObjects(e)}).initialize()},e.createHashRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createHashHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:r.UNSAFE_enhanceManualRouteObjects(e)}).initialize()},e.createSearchParams=f,e.unstable_HistoryRouter=function(e){let{basename:t,children:n,history:o}=e;const[u,i]=a.useState({action:o.action,location:o.location});return a.useLayoutEffect((()=>o.listen(i)),[o]),a.createElement(r.Router,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:o})},e.unstable_usePrompt=function(e){let{when:t,message:n}=e,o=r.unstable_useBlocker(t);a.useEffect((()=>{"blocked"!==o.state||t||o.reset()}),[o,t]),a.useEffect((()=>{if("blocked"===o.state){window.confirm(n)?setTimeout(o.proceed,0):o.reset()}}),[o,n])},e.useBeforeUnload=function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("beforeunload",e,t),()=>{window.removeEventListener("beforeunload",e,t)}}),[e,r])},e.useFetcher=function(){var e;let{router:t}=j(O.UseFetcher),o=a.useContext(r.UNSAFE_RouteContext);o||n.invariant(!1);let i=null==(e=o.matches[o.matches.length-1])?void 0:e.route.id;null==i&&n.invariant(!1);let[c]=a.useState((()=>String(++x))),[l]=a.useState((()=>(i||n.invariant(!1),function(e,t){return a.forwardRef(((r,n)=>a.createElement(P,u({},r,{ref:n,fetcherKey:e,routeId:t}))))}(c,i)))),[s]=a.useState((()=>e=>{t||n.invariant(!1),i||n.invariant(!1),t.fetch(c,i,e)})),f=C(c,i),d=t.getFetcher(c),m=a.useMemo((()=>u({Form:l,submit:f,load:s},d)),[d,l,f,s]);return a.useEffect((()=>()=>{t?t.deleteFetcher(c):console.warn("No fetcher available to clean up from useFetcher()")}),[t,c]),m},e.useFetchers=function(){return[...E(S.UseFetchers).fetchers.values()]},e.useFormAction=N,e.useLinkClickHandler=A,e.useSearchParams=function(e){let t=a.useRef(f(e)),n=a.useRef(!1),o=r.useLocation(),u=a.useMemo((()=>function(e,t){let r=f(e);if(t)for(let e of t.keys())r.has(e)||t.getAll(e).forEach((t=>{r.append(e,t)}));return r}(o.search,n.current?null:t.current)),[o.search]),i=r.useNavigate(),c=a.useCallback(((e,t)=>{const r=f("function"==typeof e?e(u):e);n.current=!0,i("?"+r,t)}),[i,u]);return[u,c]},e.useSubmit=function(){return C()},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-router"),require("@remix-run/router")):"function"==typeof define&&define.amd?define(["exports","react","react-router","@remix-run/router"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactRouterDOM={},e.React,e.ReactRouter,e.RemixRouter)}(this,(function(e,t,r,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var a=o(t);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},u.apply(this,arguments)}function i(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}const c="get",l="application/x-www-form-urlencoded";function s(e){return null!=e&&"string"==typeof e.tagName}function f(e){return void 0===e&&(e=""),new URLSearchParams("string"==typeof e||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce(((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map((e=>[r,e])):[[r,n]])}),[]))}function d(e,t,r){let n,o,a,u;if(s(i=e)&&"form"===i.tagName.toLowerCase()){let i=r.submissionTrigger;n=r.method||e.getAttribute("method")||c,o=r.action||e.getAttribute("action")||t,a=r.encType||e.getAttribute("enctype")||l,u=new FormData(e),i&&i.name&&u.append(i.name,i.value)}else if(function(e){return s(e)&&"button"===e.tagName.toLowerCase()}(e)||function(e){return s(e)&&"input"===e.tagName.toLowerCase()}(e)&&("submit"===e.type||"image"===e.type)){let i=e.form;if(null==i)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');n=r.method||e.getAttribute("formmethod")||i.getAttribute("method")||c,o=r.action||e.getAttribute("formaction")||i.getAttribute("action")||t,a=r.encType||e.getAttribute("formenctype")||i.getAttribute("enctype")||l,u=new FormData(i),e.name&&u.append(e.name,e.value)}else{if(s(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');if(n=r.method||c,o=r.action||t,a=r.encType||l,e instanceof FormData)u=e;else if(u=new FormData,e instanceof URLSearchParams)for(let[t,r]of e)u.append(t,r);else if(null!=e)for(let t of Object.keys(e))u.append(t,e[t])}var i;let{protocol:f,host:d}=window.location;return{url:new URL(o,f+"//"+d),method:n.toLowerCase(),encType:a,formData:u}}const m=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset"],b=["aria-current","caseSensitive","className","end","style","to","children"],p=["reloadDocument","replace","method","action","onSubmit","fetcherKey","routeId","relative","preventScrollReset"];function h(){var e;let t=null==(e=window)?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=u({},t,{errors:y(t.errors)})),t}function y(e){if(!e)return null;let t=Object.entries(e),r={};for(let[e,o]of t)if(o&&"RouteErrorResponse"===o.__type)r[e]=new n.ErrorResponse(o.status,o.statusText,o.data,!0===o.internal);else if(o&&"Error"===o.__type){let t=new Error(o.message);t.stack="",r[e]=t}else r[e]=o;return r}const g="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,v=a.forwardRef((function(e,t){let n,{onClick:o,relative:c,reloadDocument:l,replace:s,state:f,target:d,to:b,preventScrollReset:p}=e,h=i(e,m),y=!1;if(g&&"string"==typeof b&&/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(b)){n=b;let e=new URL(window.location.href),t=b.startsWith("//")?new URL(e.protocol+b):new URL(b);t.origin===e.origin?b=t.pathname+t.search+t.hash:y=!0}let v=r.useHref(b,{relative:c}),R=C(b,{replace:s,state:f,target:d,preventScrollReset:p,relative:c});return a.createElement("a",u({},h,{href:n||v,onClick:y||l?o:function(e){o&&o(e),e.defaultPrevented||R(e)},ref:t,target:d}))})),R=a.forwardRef((function(e,t){let{"aria-current":n="page",caseSensitive:o=!1,className:c="",end:l=!1,style:s,to:f,children:d}=e,m=i(e,b),p=r.useResolvedPath(f,{relative:m.relative}),h=r.useLocation(),y=a.useContext(r.UNSAFE_DataRouterStateContext),{navigator:g}=a.useContext(r.UNSAFE_NavigationContext),R=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,w=h.pathname,P=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;o||(w=w.toLowerCase(),P=P?P.toLowerCase():null,R=R.toLowerCase());let O,S=w===R||!l&&w.startsWith(R)&&"/"===w.charAt(R.length),E=null!=P&&(P===R||!l&&P.startsWith(R)&&"/"===P.charAt(R.length)),j=S?n:void 0;O="function"==typeof c?c({isActive:S,isPending:E}):[c,S?"active":null,E?"pending":null].filter(Boolean).join(" ");let C="function"==typeof s?s({isActive:S,isPending:E}):s;return a.createElement(v,u({},m,{"aria-current":j,className:O,ref:t,style:C,to:f}),"function"==typeof d?d({isActive:S,isPending:E}):d)})),w=a.forwardRef(((e,t)=>a.createElement(P,u({},e,{ref:t})))),P=a.forwardRef(((e,t)=>{let{reloadDocument:r,replace:n,method:o=c,action:l,onSubmit:s,fetcherKey:f,routeId:d,relative:m,preventScrollReset:b}=e,h=i(e,p),y=A(f,d),g="get"===o.toLowerCase()?"get":"post",v=N(l,{relative:m});return a.createElement("form",u({ref:t,method:g,action:v,onSubmit:r?s:e=>{if(s&&s(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter,r=(null==t?void 0:t.getAttribute("formmethod"))||o;y(t||e.currentTarget,{method:r,replace:n,relative:m,preventScrollReset:b})}},h))}));var O,S;function E(e){let t=a.useContext(r.UNSAFE_DataRouterContext);return t||n.invariant(!1),t}function j(e){let t=a.useContext(r.UNSAFE_DataRouterStateContext);return t||n.invariant(!1),t}function C(e,t){let{target:n,replace:o,state:u,preventScrollReset:i,relative:c}=void 0===t?{}:t,l=r.useNavigate(),s=r.useLocation(),f=r.useResolvedPath(e,{relative:c});return a.useCallback((t=>{if(function(e,t){return!(0!==e.button||t&&"_self"!==t||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e))}(t,n)){t.preventDefault();let n=void 0!==o?o:r.createPath(s)===r.createPath(f);l(e,{replace:n,state:u,preventScrollReset:i,relative:c})}}),[s,l,f,o,u,n,e,i,c])}function A(e,t){let{router:r}=E(O.UseSubmitImpl),o=N();return a.useCallback((function(a,u){if(void 0===u&&(u={}),"undefined"==typeof document)throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");let{method:i,encType:c,formData:l,url:s}=d(a,o,u),f=s.pathname+s.search,m={replace:u.replace,preventScrollReset:u.preventScrollReset,formData:l,formMethod:i,formEncType:c};e?(null==t&&n.invariant(!1),r.fetch(e,t,f,m)):r.navigate(f,m)}),[o,r,e,t])}function N(e,t){let{relative:o}=void 0===t?{}:t,{basename:i}=a.useContext(r.UNSAFE_NavigationContext),c=a.useContext(r.UNSAFE_RouteContext);c||n.invariant(!1);let[l]=c.matches.slice(-1),s=u({},r.useResolvedPath(e||".",{relative:o})),f=r.useLocation();if(null==e&&(s.search=f.search,s.hash=f.hash,l.route.index)){let e=new URLSearchParams(s.search);e.delete("index"),s.search=e.toString()?"?"+e.toString():""}return e&&"."!==e||!l.route.index||(s.search=s.search?s.search.replace(/^\?/,"?index&"):"?index"),"/"!==i&&(s.pathname="/"===s.pathname?i:n.joinPaths([i,s.pathname])),r.createPath(s)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(O||(O={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(S||(S={}));let L=0;const x="react-router-scroll-positions";let F={};function U(e){let{getKey:t,storageKey:n}=void 0===e?{}:e,{router:o}=E(O.UseScrollRestoration),{restoreScrollPosition:u,preventScrollReset:i}=j(S.UseScrollRestoration),c=r.useLocation(),l=r.useMatches(),s=r.useNavigation();a.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("pagehide",e,t),()=>{window.removeEventListener("pagehide",e,t)}}),[e,r])}(a.useCallback((()=>{if("idle"===s.state){let e=(t?t(c,l):null)||c.key;F[e]=window.scrollY}sessionStorage.setItem(n||x,JSON.stringify(F)),window.history.scrollRestoration="auto"}),[n,t,s.state,c,l])),"undefined"!=typeof document&&(a.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(n||x);e&&(F=JSON.parse(e))}catch(e){}}),[n]),a.useLayoutEffect((()=>{let e=null==o?void 0:o.enableScrollRestoration(F,(()=>window.scrollY),t);return()=>e&&e()}),[o,t]),a.useLayoutEffect((()=>{if(!1!==u)if("number"!=typeof u){if(c.hash){let e=document.getElementById(c.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==i&&window.scrollTo(0,0)}else window.scrollTo(0,u)}),[c,u,i]))}Object.defineProperty(e,"AbortedDeferredError",{enumerable:!0,get:function(){return r.AbortedDeferredError}}),Object.defineProperty(e,"Await",{enumerable:!0,get:function(){return r.Await}}),Object.defineProperty(e,"MemoryRouter",{enumerable:!0,get:function(){return r.MemoryRouter}}),Object.defineProperty(e,"Navigate",{enumerable:!0,get:function(){return r.Navigate}}),Object.defineProperty(e,"NavigationType",{enumerable:!0,get:function(){return r.NavigationType}}),Object.defineProperty(e,"Outlet",{enumerable:!0,get:function(){return r.Outlet}}),Object.defineProperty(e,"Route",{enumerable:!0,get:function(){return r.Route}}),Object.defineProperty(e,"Router",{enumerable:!0,get:function(){return r.Router}}),Object.defineProperty(e,"RouterProvider",{enumerable:!0,get:function(){return r.RouterProvider}}),Object.defineProperty(e,"Routes",{enumerable:!0,get:function(){return r.Routes}}),Object.defineProperty(e,"UNSAFE_DataRouterContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterContext}}),Object.defineProperty(e,"UNSAFE_DataRouterStateContext",{enumerable:!0,get:function(){return r.UNSAFE_DataRouterStateContext}}),Object.defineProperty(e,"UNSAFE_LocationContext",{enumerable:!0,get:function(){return r.UNSAFE_LocationContext}}),Object.defineProperty(e,"UNSAFE_NavigationContext",{enumerable:!0,get:function(){return r.UNSAFE_NavigationContext}}),Object.defineProperty(e,"UNSAFE_RouteContext",{enumerable:!0,get:function(){return r.UNSAFE_RouteContext}}),Object.defineProperty(e,"createMemoryRouter",{enumerable:!0,get:function(){return r.createMemoryRouter}}),Object.defineProperty(e,"createPath",{enumerable:!0,get:function(){return r.createPath}}),Object.defineProperty(e,"createRoutesFromChildren",{enumerable:!0,get:function(){return r.createRoutesFromChildren}}),Object.defineProperty(e,"createRoutesFromElements",{enumerable:!0,get:function(){return r.createRoutesFromElements}}),Object.defineProperty(e,"defer",{enumerable:!0,get:function(){return r.defer}}),Object.defineProperty(e,"generatePath",{enumerable:!0,get:function(){return r.generatePath}}),Object.defineProperty(e,"isRouteErrorResponse",{enumerable:!0,get:function(){return r.isRouteErrorResponse}}),Object.defineProperty(e,"json",{enumerable:!0,get:function(){return r.json}}),Object.defineProperty(e,"matchPath",{enumerable:!0,get:function(){return r.matchPath}}),Object.defineProperty(e,"matchRoutes",{enumerable:!0,get:function(){return r.matchRoutes}}),Object.defineProperty(e,"parsePath",{enumerable:!0,get:function(){return r.parsePath}}),Object.defineProperty(e,"redirect",{enumerable:!0,get:function(){return r.redirect}}),Object.defineProperty(e,"renderMatches",{enumerable:!0,get:function(){return r.renderMatches}}),Object.defineProperty(e,"resolvePath",{enumerable:!0,get:function(){return r.resolvePath}}),Object.defineProperty(e,"unstable_useBlocker",{enumerable:!0,get:function(){return r.unstable_useBlocker}}),Object.defineProperty(e,"useActionData",{enumerable:!0,get:function(){return r.useActionData}}),Object.defineProperty(e,"useAsyncError",{enumerable:!0,get:function(){return r.useAsyncError}}),Object.defineProperty(e,"useAsyncValue",{enumerable:!0,get:function(){return r.useAsyncValue}}),Object.defineProperty(e,"useHref",{enumerable:!0,get:function(){return r.useHref}}),Object.defineProperty(e,"useInRouterContext",{enumerable:!0,get:function(){return r.useInRouterContext}}),Object.defineProperty(e,"useLoaderData",{enumerable:!0,get:function(){return r.useLoaderData}}),Object.defineProperty(e,"useLocation",{enumerable:!0,get:function(){return r.useLocation}}),Object.defineProperty(e,"useMatch",{enumerable:!0,get:function(){return r.useMatch}}),Object.defineProperty(e,"useMatches",{enumerable:!0,get:function(){return r.useMatches}}),Object.defineProperty(e,"useNavigate",{enumerable:!0,get:function(){return r.useNavigate}}),Object.defineProperty(e,"useNavigation",{enumerable:!0,get:function(){return r.useNavigation}}),Object.defineProperty(e,"useNavigationType",{enumerable:!0,get:function(){return r.useNavigationType}}),Object.defineProperty(e,"useOutlet",{enumerable:!0,get:function(){return r.useOutlet}}),Object.defineProperty(e,"useOutletContext",{enumerable:!0,get:function(){return r.useOutletContext}}),Object.defineProperty(e,"useParams",{enumerable:!0,get:function(){return r.useParams}}),Object.defineProperty(e,"useResolvedPath",{enumerable:!0,get:function(){return r.useResolvedPath}}),Object.defineProperty(e,"useRevalidator",{enumerable:!0,get:function(){return r.useRevalidator}}),Object.defineProperty(e,"useRouteError",{enumerable:!0,get:function(){return r.useRouteError}}),Object.defineProperty(e,"useRouteLoaderData",{enumerable:!0,get:function(){return r.useRouteLoaderData}}),Object.defineProperty(e,"useRoutes",{enumerable:!0,get:function(){return r.useRoutes}}),e.BrowserRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createBrowserHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Form=w,e.HashRouter=function(e){let{basename:t,children:o,window:u}=e,i=a.useRef();null==i.current&&(i.current=n.createHashHistory({window:u,v5Compat:!0}));let c=i.current,[l,s]=a.useState({action:c.action,location:c.location});return a.useLayoutEffect((()=>c.listen(s)),[c]),a.createElement(r.Router,{basename:t,children:o,location:l.location,navigationType:l.action,navigator:c})},e.Link=v,e.NavLink=R,e.ScrollRestoration=function(e){let{getKey:t,storageKey:r}=e;return U({getKey:t,storageKey:r}),null},e.UNSAFE_useScrollRestoration=U,e.createBrowserRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createBrowserHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:null==t?void 0:t.onInitialize}).initialize()},e.createHashRouter=function(e,t){return n.createRouter({basename:null==t?void 0:t.basename,history:n.createHashHistory({window:null==t?void 0:t.window}),hydrationData:(null==t?void 0:t.hydrationData)||h(),routes:e,hasErrorBoundary:e=>Boolean(e.errorElement),onInitialize:null==t?void 0:t.onInitialize}).initialize()},e.createSearchParams=f,e.unstable_HistoryRouter=function(e){let{basename:t,children:n,history:o}=e;const[u,i]=a.useState({action:o.action,location:o.location});return a.useLayoutEffect((()=>o.listen(i)),[o]),a.createElement(r.Router,{basename:t,children:n,location:u.location,navigationType:u.action,navigator:o})},e.unstable_usePrompt=function(e){let{when:t,message:n}=e,o=r.unstable_useBlocker(t);a.useEffect((()=>{"blocked"!==o.state||t||o.reset()}),[o,t]),a.useEffect((()=>{if("blocked"===o.state){window.confirm(n)?setTimeout(o.proceed,0):o.reset()}}),[o,n])},e.useBeforeUnload=function(e,t){let{capture:r}=t||{};a.useEffect((()=>{let t=null!=r?{capture:r}:void 0;return window.addEventListener("beforeunload",e,t),()=>{window.removeEventListener("beforeunload",e,t)}}),[e,r])},e.useFetcher=function(){var e;let{router:t}=E(O.UseFetcher),o=a.useContext(r.UNSAFE_RouteContext);o||n.invariant(!1);let i=null==(e=o.matches[o.matches.length-1])?void 0:e.route.id;null==i&&n.invariant(!1);let[c]=a.useState((()=>String(++L))),[l]=a.useState((()=>(i||n.invariant(!1),function(e,t){return a.forwardRef(((r,n)=>a.createElement(P,u({},r,{ref:n,fetcherKey:e,routeId:t}))))}(c,i)))),[s]=a.useState((()=>e=>{t||n.invariant(!1),i||n.invariant(!1),t.fetch(c,i,e)})),f=A(c,i),d=t.getFetcher(c),m=a.useMemo((()=>u({Form:l,submit:f,load:s},d)),[d,l,f,s]);return a.useEffect((()=>()=>{t?t.deleteFetcher(c):console.warn("No fetcher available to clean up from useFetcher()")}),[t,c]),m},e.useFetchers=function(){return[...j(S.UseFetchers).fetchers.values()]},e.useFormAction=N,e.useLinkClickHandler=C,e.useSearchParams=function(e){let t=a.useRef(f(e)),n=a.useRef(!1),o=r.useLocation(),u=a.useMemo((()=>function(e,t){let r=f(e);if(t)for(let e of t.keys())r.has(e)||t.getAll(e).forEach((t=>{r.append(e,t)}));return r}(o.search,n.current?null:t.current)),[o.search]),i=r.useNavigate(),c=a.useCallback(((e,t)=>{const r=f("function"==typeof e?e(u):e);n.current=!0,i("?"+r,t)}),[i,u]);return[u,c]},e.useSubmit=function(){return A()},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-router-dom.production.min.js.map |
{ | ||
"name": "react-router-dom", | ||
"version": "0.0.0-experimental-48058118", | ||
"version": "0.0.0-experimental-63b6834e", | ||
"description": "Declarative routing for React web applications", | ||
@@ -26,4 +26,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@remix-run/router": "0.0.0-experimental-48058118", | ||
"react-router": "0.0.0-experimental-48058118" | ||
"@remix-run/router": "0.0.0-experimental-63b6834e", | ||
"react-router": "0.0.0-experimental-63b6834e" | ||
}, | ||
@@ -30,0 +30,0 @@ "devDependencies": { |
import * as React from "react"; | ||
import type { Router as RemixRouter, StaticHandlerContext } from "@remix-run/router"; | ||
import type { Router as RemixRouter, StaticHandlerContext, CreateStaticHandlerOptions as RouterCreateStaticHandlerOptions } from "@remix-run/router"; | ||
import type { Location, RouteObject } from "react-router-dom"; | ||
@@ -25,2 +25,5 @@ export interface StaticRouterProps { | ||
export declare function StaticRouterProvider({ context, router, hydrate, nonce, }: StaticRouterProviderProps): JSX.Element; | ||
declare type CreateStaticHandlerOptions = Omit<RouterCreateStaticHandlerOptions, "hasErrorBoundary">; | ||
export declare function createStaticHandler(routes: RouteObject[], opts?: CreateStaticHandlerOptions): import("@remix-run/router").StaticHandler; | ||
export declare function createStaticRouter(routes: RouteObject[], context: StaticHandlerContext): RemixRouter; | ||
export {}; |
@@ -166,22 +166,14 @@ 'use strict'; | ||
}; | ||
} // Temporary manifest generation - we should optimize this by combining the | ||
// tree-walks between convertRoutesToDataRoutes, enhanceManualRouteObjects, | ||
// and generateManifest. | ||
// Also look into getting rid of `route as AgnosticDataRouteObject` down below? | ||
} | ||
let hasErrorBoundary = route => Boolean(route.errorElement); | ||
function generateManifest(routes, manifest = new Map()) { | ||
routes.forEach(route => { | ||
manifest.set(route.id, route); | ||
if (route.children) { | ||
generateManifest(route.children, manifest); | ||
} | ||
function createStaticHandler(routes, opts) { | ||
return router.createStaticHandler(routes, { ...opts, | ||
hasErrorBoundary | ||
}); | ||
return manifest; | ||
} | ||
function createStaticRouter(routes, context) { | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(reactRouterDom.UNSAFE_enhanceManualRouteObjects(routes)); | ||
let manifest = generateManifest(dataRoutes); // Because our context matches may be from a framework-agnostic set of | ||
let manifest = {}; | ||
let dataRoutes = router.UNSAFE_convertRoutesToDataRoutes(routes, hasErrorBoundary, undefined, manifest); // Because our context matches may be from a framework-agnostic set of | ||
// routes passed to createStaticHandler(), we update them here with our | ||
@@ -191,5 +183,5 @@ // newly created/enhanced data routes | ||
let matches = context.matches.map(match => { | ||
let route = manifest.get(match.route.id) || match.route; | ||
let route = manifest[match.route.id] || match.route; | ||
return { ...match, | ||
route: route | ||
route | ||
}; | ||
@@ -267,3 +259,3 @@ }); | ||
getBlocker() { | ||
throw msg("getBlocker"); | ||
return router.IDLE_BLOCKER; | ||
}, | ||
@@ -296,2 +288,3 @@ | ||
exports.StaticRouterProvider = StaticRouterProvider; | ||
exports.createStaticHandler = createStaticHandler; | ||
exports.createStaticRouter = createStaticRouter; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
565929
0
4410
+ Added@remix-run/router@0.0.0-experimental-63b6834e(transitive)
+ Addedreact-router@0.0.0-experimental-63b6834e(transitive)
- Removed@remix-run/router@0.0.0-experimental-48058118(transitive)
- Removedreact-router@0.0.0-experimental-48058118(transitive)