You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Scripted/website/node_modules/react-router-dom/dist/react-router-dom.production...

13 lines
9.9 KiB

/**
* React Router DOM v6.4.2
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
import*as e from"react";import{UNSAFE_enhanceManualRouteObjects as t,Router as r,useHref as n,createPath as o,useResolvedPath as a,useMatch as i,UNSAFE_DataRouterStateContext as s,useNavigate as u,useLocation as c,UNSAFE_NavigationContext as l,UNSAFE_RouteContext as f,useMatches as m,useNavigation 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_DataStaticRouterContext,UNSAFE_LocationContext,UNSAFE_NavigationContext,UNSAFE_RouteContext,UNSAFE_enhanceManualRouteObjects,createMemoryRouter,createPath,createRoutesFromChildren,createRoutesFromElements,defer,generatePath,isRouteErrorResponse,json,matchPath,matchRoutes,parsePath,redirect,renderMatches,resolvePath,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 g,createHashHistory as y,matchPath as w,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 A(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:u,host:c}=window.location;return{url:new URL(o,`${u}//${c}`),method:n,encType:a,formData:i}}function C(e,r){return p({basename:r?.basename,history:g({window:r?.window}),hydrationData:r?.hydrationData||window?.__staticRouterHydrationData,routes:t(e)}).initialize()}function D(e,r){return p({basename:r?.basename,history:y({window:r?.window}),hydrationData:r?.hydrationData||window?.__staticRouterHydrationData,routes:t(e)}).initialize()}function x({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,u]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(u)),[i]),e.createElement(r,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:i})}function F({basename:t,children:n,window:o}){let a=e.useRef();null==a.current&&(a.current=y({window:o,v5Compat:!0}));let i=a.current,[s,u]=e.useState({action:i.action,location:i.location});return e.useLayoutEffect((()=>i.listen(u)),[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 U=e.forwardRef((function({onClick:t,relative:r,reloadDocument:o,replace:a,state:i,target:s,to:u,preventScrollReset:c,...l},f){let m=n(u,{relative:r}),d=I(u,{replace:a,state:i,target:s,preventScrollReset:c,relative:r});return e.createElement("a",Object.assign({},l,{href:m,onClick:o?t:function(e){t&&t(e),e.defaultPrevented||d(e)},ref:f,target:s}))})),L=e.forwardRef((function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:o=!1,style:u,to:c,children:l,...f},m){let d,h=a(c),p=i({path:h.pathname,end:o,caseSensitive:r}),g=e.useContext(s)?.navigation.location,y=a(g||""),v=null!=e.useMemo((()=>g?w({path:h.pathname,end:o,caseSensitive:r},y.pathname):null),[g,h.pathname,r,o,y.pathname]),b=null!=p,R=b?t:void 0;d="function"==typeof n?n({isActive:b,isPending:v}):[n,b?"active":null,v?"pending":null].filter(Boolean).join(" ");let S="function"==typeof u?u({isActive:b,isPending:v}):u;return e.createElement(U,Object.assign({},f,{"aria-current":R,className:d,ref:m,style:S,to:c}),"function"==typeof l?l({isActive:b,isPending:v}):l)})),P=e.forwardRef(((t,r)=>e.createElement(T,Object.assign({},t,{ref:r})))),T=e.forwardRef((({reloadDocument:t,replace:r,method:n="get",action:o,onSubmit:a,fetcherKey:i,routeId:s,relative:u,...c},l)=>{let f=Y(i,s),m="get"===n.toLowerCase()?"get":"post",d=$(o,{relative:u});return e.createElement("form",Object.assign({ref:l,method:m,action:d,onSubmit:t?a:e=>{if(a&&a(e),e.defaultPrevented)return;e.preventDefault();let t=e.nativeEvent.submitter;f(t||e.currentTarget,{method:n,replace:r,relative:u})}},c))}));function O({getKey:t,storageKey:r}){return function({getKey:t,storageKey:r}={}){let{router:n}=k(_.UseScrollRestoration),{restoreScrollPosition:o,preventScrollReset:a}=j(K.UseScrollRestoration),i=c(),s=m(),u=d();e.useEffect((()=>(window.history.scrollRestoration="manual",()=>{window.history.scrollRestoration="auto"})),[]),l=e.useCallback((()=>{if("idle"===u.state){let e=(t?t(i,s):null)||i.key;V[e]=window.scrollY}sessionStorage.setItem(r||"react-router-scroll-positions",JSON.stringify(V)),window.history.scrollRestoration="auto"}),[r,t,u.state,i,s]),e.useEffect((()=>(window.addEventListener("beforeunload",l),()=>{window.removeEventListener("beforeunload",l)})),[l]),e.useLayoutEffect((()=>{try{let e=sessionStorage.getItem(r||"react-router-scroll-positions");e&&(V=JSON.parse(e))}catch(e){}}),[r]),e.useLayoutEffect((()=>{let e=n?.enableScrollRestoration(V,(()=>window.scrollY),t);return()=>e&&e()}),[n,t]),e.useLayoutEffect((()=>{if(!1!==o)if("number"!=typeof o){if(i.hash){let e=document.getElementById(i.hash.slice(1));if(e)return void e.scrollIntoView()}!0!==a&&window.scrollTo(0,0)}else window.scrollTo(0,o)}),[i,o,a]);var l}({getKey:t,storageKey:r}),null}var _,K;function k(t){let r=e.useContext(h);return r||v(!1),r}function j(t){let r=e.useContext(s);return r||v(!1),r}function I(t,{target:r,replace:n,state:i,preventScrollReset:s,relative:l}={}){let f=u(),m=c(),d=a(t,{relative:l});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:o(m)===o(d);f(t,{replace:r,state:i,preventScrollReset:s,relative:l})}}),[m,f,d,n,i,r,t,s,l])}function M(t){let r=e.useRef(E(t)),n=c(),o=e.useMemo((()=>function(e,t){let r=E(e);for(let n of t.keys())r.has(n)||t.getAll(n).forEach((e=>{r.append(n,e)}));return r}(n.search,r.current)),[n.search]),a=u(),i=e.useCallback(((e,t)=>{const r=E("function"==typeof e?e(o):e);a("?"+r,t)}),[a,o]);return[o,i]}function H(){return Y()}function Y(t,r){let{router:n}=k(_.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:u,url:c}=A(e,o,a),l=c.pathname+c.search,f={replace:a.replace,formData:u,formMethod:i,formEncType:s};t?(null==r&&v(!1),n.fetch(t,r,l,f)):n.navigate(l,f)}),[o,n,t,r])}function $(t,{relative:r}={}){let{basename:n}=e.useContext(l),i=e.useContext(f);i||v(!1);let[s]=i.matches.slice(-1),u={...a(t??".",{relative:r})},m=c();if(null==t&&(u.search=m.search,u.hash=m.hash,s.route.index)){let e=new URLSearchParams(u.search);e.delete("index"),u.search=e.toString()?`?${e.toString()}`:""}return t&&"."!==t||!s.route.index||(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),"/"!==n&&(u.pathname="/"===u.pathname?n:b([n,u.pathname])),o(u)}!function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmitImpl="useSubmitImpl",e.UseFetcher="useFetcher"}(_||(_={})),function(e){e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"}(K||(K={}));let z=0;function B(){let{router:t}=k(_.UseFetcher),r=e.useContext(f);r||v(!1);let n=r.matches[r.matches.length-1]?.route.id;null==n&&v(!1);let[o]=e.useState((()=>String(++z))),[a]=e.useState((()=>(n||v(!1),function(t,r){return e.forwardRef(((n,o)=>e.createElement(T,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),u=t.getFetcher(o),c=e.useMemo((()=>({Form:a,submit:s,load:i,...u})),[u,a,s,i]);return e.useEffect((()=>()=>{t?t.deleteFetcher(o):console.warn("No fetcher available to clean up from useFetcher()")}),[t,o]),c}function J(){return[...j(K.UseFetchers).fetchers.values()]}let V={};export{x as BrowserRouter,P as Form,F as HashRouter,U as Link,L as NavLink,O as ScrollRestoration,C as createBrowserRouter,D as createHashRouter,E as createSearchParams,N as unstable_HistoryRouter,B as useFetcher,J as useFetchers,$ as useFormAction,I as useLinkClickHandler,M as useSearchParams,H as useSubmit};
//# sourceMappingURL=react-router-dom.production.min.js.map