react-router-dom-v5-compat 6.2.2 → 6.4.0-pre.2

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/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../packages/react-router-dom-v5-compat/react-router-dom/index.tsx","../../../packages/react-router-dom-v5-compat/lib/components.tsx"],"sourcesContent":["/**\n * NOTE: If you refactor this to split up the modules into separate files,\n * you'll need to update the rollup config for react-router-dom-v5-compat.\n */\nimport * as React from \"react\";\nimport type { BrowserHistory, HashHistory, History } from \"history\";\nimport { createBrowserHistory, createHashHistory } from \"history\";\nimport {\n MemoryRouter,\n Navigate,\n Outlet,\n Route,\n Router,\n Routes,\n createRoutesFromChildren,\n generatePath,\n matchRoutes,\n matchPath,\n createPath,\n parsePath,\n resolvePath,\n renderMatches,\n useHref,\n useInRouterContext,\n useLocation,\n useMatch,\n useNavigate,\n useNavigationType,\n useOutlet,\n useParams,\n useResolvedPath,\n useRoutes,\n useOutletContext,\n} from \"react-router\";\nimport type { To } from \"react-router\";\n\nfunction warning(cond: boolean, message: string): void {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging React Router!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// RE-EXPORTS\n////////////////////////////////////////////////////////////////////////////////\n\n// Note: Keep in sync with react-router exports!\nexport {\n MemoryRouter,\n Navigate,\n Outlet,\n Route,\n Router,\n Routes,\n createRoutesFromChildren,\n generatePath,\n matchRoutes,\n matchPath,\n createPath,\n parsePath,\n renderMatches,\n resolvePath,\n useHref,\n useInRouterContext,\n useLocation,\n useMatch,\n useNavigate,\n useNavigationType,\n useOutlet,\n useParams,\n useResolvedPath,\n useRoutes,\n useOutletContext,\n};\n\nexport { NavigationType } from \"react-router\";\nexport type {\n Hash,\n Location,\n Path,\n To,\n MemoryRouterProps,\n NavigateFunction,\n NavigateOptions,\n NavigateProps,\n Navigator,\n OutletProps,\n Params,\n PathMatch,\n RouteMatch,\n RouteObject,\n RouteProps,\n PathRouteProps,\n LayoutRouteProps,\n IndexRouteProps,\n RouterProps,\n Pathname,\n Search,\n RoutesProps,\n} from \"react-router\";\n\n///////////////////////////////////////////////////////////////////////////////\n// DANGER! PLEASE READ ME!\n// We provide these exports as an escape hatch in the event that you need any\n// routing data that we don't provide an explicit API for. With that said, we\n// want to cover your use case if we can, so if you feel the need to use these\n// we want to hear from you. Let us know what you're building and we'll do our\n// best to make sure we can support you!\n//\n// We consider these exports an implementation detail and do not guarantee\n// against any breaking changes, regardless of the semver release. Use with\n// extreme caution and only if you understand the consequences. Godspeed.\n///////////////////////////////////////////////////////////////////////////////\n\n/** @internal */\nexport {\n UNSAFE_NavigationContext,\n UNSAFE_LocationContext,\n UNSAFE_RouteContext,\n} from \"react-router\";\n\n////////////////////////////////////////////////////////////////////////////////\n// COMPONENTS\n////////////////////////////////////////////////////////////////////////////////\n\nexport interface BrowserRouterProps {\n basename?: string;\n children?: React.ReactNode;\n window?: Window;\n}\n\n/**\n * A `<Router>` for use in web browsers. Provides the cleanest URLs.\n */\nexport function BrowserRouter({\n basename,\n children,\n window,\n}: BrowserRouterProps) {\n let historyRef = React.useRef<BrowserHistory>();\n if (historyRef.current == null) {\n historyRef.current = createBrowserHistory({ window });\n }\n\n let history = historyRef.current;\n let [state, setState] = React.useState({\n action: history.action,\n location: history.location,\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nexport interface HashRouterProps {\n basename?: string;\n children?: React.ReactNode;\n window?: Window;\n}\n\n/**\n * A `<Router>` for use in web browsers. Stores the location in the hash\n * portion of the URL so it is not sent to the server.\n */\nexport function HashRouter({ basename, children, window }: HashRouterProps) {\n let historyRef = React.useRef<HashHistory>();\n if (historyRef.current == null) {\n historyRef.current = createHashHistory({ window });\n }\n\n let history = historyRef.current;\n let [state, setState] = React.useState({\n action: history.action,\n location: history.location,\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nexport interface HistoryRouterProps {\n basename?: string;\n children?: React.ReactNode;\n history: History;\n}\n\n/**\n * A `<Router>` that accepts a pre-instantiated history object. It's important\n * to note that using your own history object is highly discouraged and may add\n * two versions of the history library to your bundles unless you use the same\n * version of the history library that React Router uses internally.\n */\nfunction HistoryRouter({ basename, children, history }: HistoryRouterProps) {\n const [state, setState] = React.useState({\n action: history.action,\n location: history.location,\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nif (__DEV__) {\n HistoryRouter.displayName = \"unstable_HistoryRouter\";\n}\n\nexport { HistoryRouter as unstable_HistoryRouter };\n\nfunction isModifiedEvent(event: React.MouseEvent) {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);\n}\n\nexport interface LinkProps\n extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> {\n reloadDocument?: boolean;\n replace?: boolean;\n state?: any;\n to: To;\n}\n\n/**\n * The public API for rendering a history-aware <a>.\n */\nexport const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function LinkWithRef(\n { onClick, reloadDocument, replace = false, state, target, to, ...rest },\n ref\n ) {\n let href = useHref(to);\n let internalOnClick = useLinkClickHandler(to, { replace, state, target });\n function handleClick(\n event: React.MouseEvent<HTMLAnchorElement, MouseEvent>\n ) {\n if (onClick) onClick(event);\n if (!event.defaultPrevented && !reloadDocument) {\n internalOnClick(event);\n }\n }\n\n return (\n // eslint-disable-next-line jsx-a11y/anchor-has-content\n <a\n {...rest}\n href={href}\n onClick={handleClick}\n ref={ref}\n target={target}\n />\n );\n }\n);\n\nif (__DEV__) {\n Link.displayName = \"Link\";\n}\n\nexport interface NavLinkProps\n extends Omit<LinkProps, \"className\" | \"style\" | \"children\"> {\n children:\n | React.ReactNode\n | ((props: { isActive: boolean }) => React.ReactNode);\n caseSensitive?: boolean;\n className?: string | ((props: { isActive: boolean }) => string | undefined);\n end?: boolean;\n style?:\n | React.CSSProperties\n | ((props: { isActive: boolean }) => React.CSSProperties);\n}\n\n/**\n * A <Link> wrapper that knows if it's \"active\" or not.\n */\nexport const NavLink = React.forwardRef<HTMLAnchorElement, NavLinkProps>(\n function NavLinkWithRef(\n {\n \"aria-current\": ariaCurrentProp = \"page\",\n caseSensitive = false,\n className: classNameProp = \"\",\n end = false,\n style: styleProp,\n to,\n children,\n ...rest\n },\n ref\n ) {\n let location = useLocation();\n let path = useResolvedPath(to);\n\n let locationPathname = location.pathname;\n let toPathname = path.pathname;\n if (!caseSensitive) {\n locationPathname = locationPathname.toLowerCase();\n toPathname = toPathname.toLowerCase();\n }\n\n let isActive =\n locationPathname === toPathname ||\n (!end &&\n locationPathname.startsWith(toPathname) &&\n locationPathname.charAt(toPathname.length) === \"/\");\n\n let ariaCurrent = isActive ? ariaCurrentProp : undefined;\n\n let className: string | undefined;\n if (typeof classNameProp === \"function\") {\n className = classNameProp({ isActive });\n } else {\n // If the className prop is not a function, we use a default `active`\n // class for <NavLink />s that are active. In v5 `active` was the default\n // value for `activeClassName`, but we are removing that API and can still\n // use the old default behavior for a cleaner upgrade path and keep the\n // simple styling rules working as they currently do.\n className = [classNameProp, isActive ? \"active\" : null]\n .filter(Boolean)\n .join(\" \");\n }\n\n let style =\n typeof styleProp === \"function\" ? styleProp({ isActive }) : styleProp;\n\n return (\n <Link\n {...rest}\n aria-current={ariaCurrent}\n className={className}\n ref={ref}\n style={style}\n to={to}\n >\n {typeof children === \"function\" ? children({ isActive }) : children}\n </Link>\n );\n }\n);\n\nif (__DEV__) {\n NavLink.displayName = \"NavLink\";\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// HOOKS\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Handles the click behavior for router `<Link>` components. This is useful if\n * you need to create custom `<Link>` components with the same click behavior we\n * use in our exported `<Link>`.\n */\nexport function useLinkClickHandler<E extends Element = HTMLAnchorElement>(\n to: To,\n {\n target,\n replace: replaceProp,\n state,\n }: {\n target?: React.HTMLAttributeAnchorTarget;\n replace?: boolean;\n state?: any;\n } = {}\n): (event: React.MouseEvent<E, MouseEvent>) => void {\n let navigate = useNavigate();\n let location = useLocation();\n let path = useResolvedPath(to);\n\n return React.useCallback(\n (event: React.MouseEvent<E, MouseEvent>) => {\n if (\n event.button === 0 && // Ignore everything but left clicks\n (!target || target === \"_self\") && // Let browser handle \"target=_blank\" etc.\n !isModifiedEvent(event) // Ignore clicks with modifier keys\n ) {\n event.preventDefault();\n\n // If the URL hasn't changed, a regular <a> will do a replace instead of\n // a push, so do the same here.\n let replace =\n !!replaceProp || createPath(location) === createPath(path);\n\n navigate(to, { replace, state });\n }\n },\n [location, navigate, path, replaceProp, state, target, to]\n );\n}\n\n/**\n * A convenient wrapper for reading and writing search parameters via the\n * URLSearchParams interface.\n */\nexport function useSearchParams(defaultInit?: URLSearchParamsInit) {\n warning(\n typeof URLSearchParams !== \"undefined\",\n `You cannot use the \\`useSearchParams\\` hook in a browser that does not ` +\n `support the URLSearchParams API. If you need to support Internet ` +\n `Explorer 11, we recommend you load a polyfill such as ` +\n `https://github.com/ungap/url-search-params\\n\\n` +\n `If you're unsure how to load polyfills, we recommend you check out ` +\n `https://polyfill.io/v3/ which provides some recommendations about how ` +\n `to load polyfills only for users that need them, instead of for every ` +\n `user.`\n );\n\n let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));\n\n let location = useLocation();\n let searchParams = React.useMemo(() => {\n let searchParams = createSearchParams(location.search);\n\n for (let key of defaultSearchParamsRef.current.keys()) {\n if (!searchParams.has(key)) {\n defaultSearchParamsRef.current.getAll(key).forEach((value) => {\n searchParams.append(key, value);\n });\n }\n }\n\n return searchParams;\n }, [location.search]);\n\n let navigate = useNavigate();\n let setSearchParams = React.useCallback(\n (\n nextInit: URLSearchParamsInit,\n navigateOptions?: { replace?: boolean; state?: any }\n ) => {\n navigate(\"?\" + createSearchParams(nextInit), navigateOptions);\n },\n [navigate]\n );\n\n return [searchParams, setSearchParams] as const;\n}\n\nexport type ParamKeyValuePair = [string, string];\n\nexport type URLSearchParamsInit =\n | string\n | ParamKeyValuePair[]\n | Record<string, string | string[]>\n | URLSearchParams;\n\n/**\n * Creates a URLSearchParams object using the given initializer.\n *\n * This is identical to `new URLSearchParams(init)` except it also\n * supports arrays as values in the object form of the initializer\n * instead of just strings. This is convenient when you need multiple\n * values for a given key, but don't want to use an array initializer.\n *\n * For example, instead of:\n *\n * let searchParams = new URLSearchParams([\n * ['sort', 'name'],\n * ['sort', 'price']\n * ]);\n *\n * you can do:\n *\n * let searchParams = createSearchParams({\n * sort: ['name', 'price']\n * });\n */\nexport function createSearchParams(\n init: URLSearchParamsInit = \"\"\n): URLSearchParams {\n return new URLSearchParams(\n typeof init === \"string\" ||\n Array.isArray(init) ||\n init instanceof URLSearchParams\n ? init\n : Object.keys(init).reduce((memo, key) => {\n let value = init[key];\n return memo.concat(\n Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]\n );\n }, [] as ParamKeyValuePair[])\n );\n}\n","import * as React from \"react\";\nimport type { Location, To } from \"history\";\nimport { Action, createPath, parsePath } from \"history\";\n\n// Get useHistory from react-router-dom v5 (peer dep).\n// @ts-expect-error\nimport { useHistory } from \"react-router-dom\";\n\n// We are a wrapper around react-router-dom v6, so bring it in\n// and bundle it because an app can't have two versions of\n// react-router-dom in its package.json.\nimport { Router, Routes, Route } from \"../react-router-dom\";\n\nexport function CompatRouter({ children }: { children: React.ReactNode }) {\n let history = useHistory();\n let [state, setState] = React.useState(() => ({\n location: history.location,\n action: history.action,\n }));\n\n React.useEffect(() => {\n history.listen((location: Location, action: Action) =>\n setState({ location, action })\n );\n }, [history]);\n\n return (\n <Router\n navigationType={state.action}\n location={state.location}\n navigator={history}\n >\n <Routes>\n <Route path=\"*\" element={children} />\n </Routes>\n </Router>\n );\n}\n\nexport interface StaticRouterProps {\n basename?: string;\n children?: React.ReactNode;\n location: Partial<Location> | string;\n}\n\n/**\n * A <Router> that may not transition to any other location. This is useful\n * on the server where there is no stateful UI.\n */\nexport function StaticRouter({\n basename,\n children,\n location: locationProp = \"/\",\n}: StaticRouterProps) {\n if (typeof locationProp === \"string\") {\n locationProp = parsePath(locationProp);\n }\n\n let action = Action.Pop;\n let location: Location = {\n pathname: locationProp.pathname || \"/\",\n search: locationProp.search || \"\",\n hash: locationProp.hash || \"\",\n state: locationProp.state || null,\n key: locationProp.key || \"default\",\n };\n\n let staticNavigator = {\n createHref(to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n },\n push(to: To) {\n throw new Error(\n `You cannot use navigator.push() on the server because it is a stateless ` +\n `environment. This error was probably triggered when you did a ` +\n `\\`navigate(${JSON.stringify(to)})\\` somewhere in your app.`\n );\n },\n replace(to: To) {\n throw new Error(\n `You cannot use navigator.replace() on the server because it is a stateless ` +\n `environment. This error was probably triggered when you did a ` +\n `\\`navigate(${JSON.stringify(to)}, { replace: true })\\` somewhere ` +\n `in your app.`\n );\n },\n go(delta: number) {\n throw new Error(\n `You cannot use navigator.go() on the server because it is a stateless ` +\n `environment. This error was probably triggered when you did a ` +\n `\\`navigate(${delta})\\` somewhere in your app.`\n );\n },\n back() {\n throw new Error(\n `You cannot use navigator.back() on the server because it is a stateless ` +\n `environment.`\n );\n },\n forward() {\n throw new Error(\n `You cannot use navigator.forward() on the server because it is a stateless ` +\n `environment.`\n );\n },\n };\n\n return (\n <Router\n basename={basename}\n children={children}\n location={location}\n navigationType={action}\n navigator={staticNavigator}\n static={true}\n />\n );\n}\n"],"names":["warning","cond","message","console","warn","Error","e","BrowserRouter","basename","children","window","historyRef","React","current","createBrowserHistory","history","state","setState","action","location","listen","React.createElement","HashRouter","createHashHistory","HistoryRouter","displayName","isModifiedEvent","event","metaKey","altKey","ctrlKey","shiftKey","Link","LinkWithRef","ref","onClick","reloadDocument","replace","target","to","rest","href","useHref","internalOnClick","useLinkClickHandler","handleClick","defaultPrevented","NavLink","NavLinkWithRef","ariaCurrentProp","caseSensitive","className","classNameProp","end","style","styleProp","useLocation","path","useResolvedPath","locationPathname","pathname","toPathname","toLowerCase","isActive","startsWith","charAt","length","ariaCurrent","undefined","filter","Boolean","join","replaceProp","navigate","useNavigate","button","preventDefault","createPath","useSearchParams","defaultInit","URLSearchParams","defaultSearchParamsRef","createSearchParams","searchParams","search","key","keys","has","getAll","forEach","value","append","setSearchParams","nextInit","navigateOptions","init","Array","isArray","Object","reduce","memo","concat","map","v","CompatRouter","useHistory","StaticRouter","locationProp","parsePath","Action","Pop","hash","staticNavigator","createHref","push","JSON","stringify","go","delta","back","forward"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAASA,OAAT,CAAiBC,IAAjB,EAAgCC,OAAhC,EAAuD;AACrD,MAAI,CAACD,IAAL,EAAW;AACT;AACA,QAAI,OAAOE,OAAP,KAAmB,WAAvB,EAAoCA,OAAO,CAACC,IAAR,CAAaF,OAAb;;AAEpC,QAAI;AACF;AACA;AACA;AACA;AACA;AACA,YAAM,IAAIG,KAAJ,CAAUH,OAAV,CAAN,CANE;AAQH,KARD,CAQE,OAAOI,CAAP,EAAU;AACb;AACF;AAkFD;AACA;;AAQA;AACA;AACA;AACO,SAASC,aAAT,OAIgB;AAAA,MAJO;AAC5BC,IAAAA,QAD4B;AAE5BC,IAAAA,QAF4B;AAG5BC,IAAAA;AAH4B,GAIP;AACrB,MAAIC,UAAU,GAAGC,MAAA,EAAjB;;AACA,MAAID,UAA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IlH,KAAJ,CACJ,2FADI,CAAN;AAID,KA/BmB;;AAgCpBmH,IAAAA,OAAO,GAAG;AACR,YAAM,IAAInH,KAAJ,CACJ,8FADI,CAAN;AAID;;AArCmB,GAAtB;AAwCA,sBACEgB,cAAC,MAAD;AACE,IAAA,QAAQ,EAAEb,QADZ;AAEE,IAAA,QAAQ,EAAEC,QAFZ;AAGE,IAAA,QAAQ,EAAEU,QAHZ;AAIE,IAAA,cAAc,EAAED,MAJlB;AAKE,IAAA,SAAS,EAAE8F,eALb;AAME,IAAA,MAAM,EAAE;AANV,IADF;AAUD;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../packages/react-router-dom-v5-compat/react-router-dom/dom.ts","../../../packages/react-router-dom-v5-compat/react-router-dom/index.tsx","../../../packages/react-router-dom-v5-compat/lib/components.tsx"],"sourcesContent":["import type { FormEncType, FormMethod } from \"@remix-run/router\";\n\nexport const defaultMethod = \"get\";\nconst defaultEncType = \"application/x-www-form-urlencoded\";\n\nexport function isHtmlElement(object: any): object is HTMLElement {\n return object != null && typeof object.tagName === \"string\";\n}\n\nexport function isButtonElement(object: any): object is HTMLButtonElement {\n return isHtmlElement(object) && object.tagName.toLowerCase() === \"button\";\n}\n\nexport function isFormElement(object: any): object is HTMLFormElement {\n return isHtmlElement(object) && object.tagName.toLowerCase() === \"form\";\n}\n\nexport function isInputElement(object: any): object is HTMLInputElement {\n return isHtmlElement(object) && object.tagName.toLowerCase() === \"input\";\n}\n\ntype LimitedMouseEvent = Pick<\n MouseEvent,\n \"button\" | \"metaKey\" | \"altKey\" | \"ctrlKey\" | \"shiftKey\"\n>;\n\nfunction isModifiedEvent(event: LimitedMouseEvent) {\n return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);\n}\n\nexport function shouldProcessLinkClick(\n event: LimitedMouseEvent,\n target?: string\n) {\n return (\n event.button === 0 && // Ignore everything but left clicks\n (!target || target === \"_self\") && // Let browser handle \"target=_blank\" etc.\n !isModifiedEvent(event) // Ignore clicks with modifier keys\n );\n}\n\nexport type ParamKeyValuePair = [string, string];\n\nexport type URLSearchParamsInit =\n | string\n | ParamKeyValuePair[]\n | Record<string, string | string[]>\n | URLSearchParams;\n\n/**\n * Creates a URLSearchParams object using the given initializer.\n *\n * This is identical to `new URLSearchParams(init)` except it also\n * supports arrays as values in the object form of the initializer\n * instead of just strings. This is convenient when you need multiple\n * values for a given key, but don't want to use an array initializer.\n *\n * For example, instead of:\n *\n * let searchParams = new URLSearchParams([\n * ['sort', 'name'],\n * ['sort', 'price']\n * ]);\n *\n * you can do:\n *\n * let searchParams = createSearchParams({\n * sort: ['name', 'price']\n * });\n */\nexport function createSearchParams(\n init: URLSearchParamsInit = \"\"\n): URLSearchParams {\n return new URLSearchParams(\n typeof init === \"string\" ||\n Array.isArray(init) ||\n init instanceof URLSearchParams\n ? init\n : Object.keys(init).reduce((memo, key) => {\n let value = init[key];\n return memo.concat(\n Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]\n );\n }, [] as ParamKeyValuePair[])\n );\n}\n\nexport function getSearchParamsForLocation(\n locationSearch: string,\n defaultSearchParams: URLSearchParams\n) {\n let searchParams = createSearchParams(locationSearch);\n\n for (let key of defaultSearchParams.keys()) {\n if (!searchParams.has(key)) {\n defaultSearchParams.getAll(key).forEach((value) => {\n searchParams.append(key, value);\n });\n }\n }\n\n return searchParams;\n}\n\nexport interface SubmitOptions {\n /**\n * The HTTP method used to submit the form. Overrides `<form method>`.\n * Defaults to \"GET\".\n */\n method?: FormMethod;\n\n /**\n * The action URL path used to submit the form. Overrides `<form action>`.\n * Defaults to the path of the current route.\n *\n * Note: It is assumed the path is already resolved. If you need to resolve a\n * relative path, use `useFormAction`.\n */\n action?: string;\n\n /**\n * The action URL used to submit the form. Overrides `<form encType>`.\n * Defaults to \"application/x-www-form-urlencoded\".\n */\n encType?: FormEncType;\n\n /**\n * Set `true` to replace the current entry in the browser's history stack\n * instead of creating a new one (i.e. stay on \"the same page\"). Defaults\n * to `false`.\n */\n replace?: boolean;\n}\n\nexport function getFormSubmissionInfo(\n target:\n | HTMLFormElement\n | HTMLButtonElement\n | HTMLInputElement\n | FormData\n | URLSearchParams\n | { [name: string]: string }\n | null,\n defaultAction: string,\n options: SubmitOptions\n): {\n url: URL;\n method: string;\n encType: string;\n formData: FormData;\n} {\n let method: string;\n let action: string;\n let encType: string;\n let formData: FormData;\n\n if (isFormElement(target)) {\n let submissionTrigger: HTMLButtonElement | HTMLInputElement = (\n options as any\n ).submissionTrigger;\n\n method = options.method || target.getAttribute(\"method\") || defaultMethod;\n action = options.action || target.getAttribute(\"action\") || defaultAction;\n encType =\n options.encType || target.getAttribute(\"enctype\") || defaultEncType;\n\n formData = new FormData(target);\n\n if (submissionTrigger && submissionTrigger.name) {\n formData.append(submissionTrigger.name, submissionTrigger.value);\n }\n } else if (\n isButtonElement(target) ||\n (isInputElement(target) &&\n (target.type === \"submit\" || target.type === \"image\"))\n ) {\n let form = target.form;\n\n if (form == null) {\n throw new Error(\n `Cannot submit a <button> or <input type=\"submit\"> without a <form>`\n );\n }\n\n // <button>/<input type=\"submit\"> may override attributes of <form>\n\n method =\n options.method ||\n target.getAttribute(\"formmethod\") ||\n form.getAttribute(\"method\") ||\n defaultMethod;\n action =\n options.action ||\n target.getAttribute(\"formaction\") ||\n form.getAttribute(\"action\") ||\n defaultAction;\n encType =\n options.encType ||\n target.getAttribute(\"formenctype\") ||\n form.getAttribute(\"enctype\") ||\n defaultEncType;\n\n formData = new FormData(form);\n\n // Include name + value from a <button>\n if (target.name) {\n formData.set(target.name, target.value);\n }\n } else if (isHtmlElement(target)) {\n throw new Error(\n `Cannot submit element that is not <form>, <button>, or ` +\n `<input type=\"submit|image\">`\n );\n } else {\n method = options.method || defaultMethod;\n action = options.action || defaultAction;\n encType = options.encType || defaultEncType;\n\n if (target instanceof FormData) {\n formData = target;\n } else {\n formData = new FormData();\n\n if (target instanceof URLSearchParams) {\n for (let [name, value] of target) {\n formData.append(name, value);\n }\n } else if (target != null) {\n for (let name of Object.keys(target)) {\n formData.append(name, target[name]);\n }\n }\n }\n }\n\n let { protocol, host } = window.location;\n let url = new URL(action, `${protocol}//${host}`);\n\n if (method.toLowerCase() === \"get\") {\n for (let [name, value] of formData) {\n if (typeof value === \"string\") {\n url.searchParams.append(name, value);\n } else {\n throw new Error(`Cannot submit binary form data using GET`);\n }\n }\n }\n\n return { url, method, encType, formData };\n}\n","/**\n * NOTE: If you refactor this to split up the modules into separate files,\n * you'll need to update the rollup config for react-router-dom-v5-compat.\n */\nimport * as React from \"react\";\nimport {\n Router,\n createPath,\n useHref,\n useLocation,\n useMatch,\n useNavigate,\n useRenderDataRouter,\n useResolvedPath,\n UNSAFE_RouteContext,\n UNSAFE_DataRouterContext,\n UNSAFE_DataRouterStateContext,\n} from \"react-router\";\nimport type { To } from \"react-router\";\nimport type {\n BrowserHistory,\n Fetcher,\n FormEncType,\n FormMethod,\n HashHistory,\n History,\n HydrationState,\n GetScrollRestorationKeyFunction,\n RouteObject,\n} from \"@remix-run/router\";\nimport {\n createBrowserHistory,\n createHashHistory,\n createBrowserRouter,\n createHashRouter,\n invariant,\n matchPath,\n} from \"@remix-run/router\";\n\nimport type {\n SubmitOptions,\n ParamKeyValuePair,\n URLSearchParamsInit,\n} from \"./dom\";\nimport {\n createSearchParams,\n defaultMethod,\n getFormSubmissionInfo,\n getSearchParamsForLocation,\n shouldProcessLinkClick,\n} from \"./dom\";\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Re-exports\n////////////////////////////////////////////////////////////////////////////////\n\nexport type { ParamKeyValuePair, URLSearchParamsInit };\nexport { createSearchParams };\n\n// Note: Keep in sync with react-router exports!\nexport type {\n ActionFunction,\n DataMemoryRouterProps,\n DataRouteMatch,\n Fetcher,\n Hash,\n IndexRouteProps,\n JsonFunction,\n LayoutRouteProps,\n LoaderFunction,\n Location,\n MemoryRouterProps,\n NavigateFunction,\n NavigateOptions,\n NavigateProps,\n Navigation,\n Navigator,\n OutletProps,\n Params,\n Path,\n PathMatch,\n Pathname,\n PathPattern,\n PathRouteProps,\n RedirectFunction,\n RouteMatch,\n RouteObject,\n RouteProps,\n RouterProps,\n RoutesProps,\n Search,\n ShouldRevalidateFunction,\n To,\n} from \"react-router\";\nexport {\n DataMemoryRouter,\n MemoryRouter,\n Navigate,\n NavigationType,\n Outlet,\n Route,\n Router,\n Routes,\n createPath,\n createRoutesFromChildren,\n isRouteErrorResponse,\n generatePath,\n json,\n matchPath,\n matchRoutes,\n parsePath,\n redirect,\n renderMatches,\n resolvePath,\n useActionData,\n useHref,\n useInRouterContext,\n useLoaderData,\n useLocation,\n useMatch,\n useMatches,\n useNavigate,\n useNavigation,\n useNavigationType,\n useOutlet,\n useOutletContext,\n useParams,\n useResolvedPath,\n useRevalidator,\n useRouteError,\n useRouteLoaderData,\n useRoutes,\n} from \"react-router\";\n\n///////////////////////////////////////////////////////////////////////////////\n// DANGER! PLEASE READ ME!\n// We provide these exports as an escape hatch in the event that you need any\n// routing data that we don't provide an explicit API for. With that said, we\n// want to cover your use case if we can, so if you feel the need to use these\n// we want to hear from you. Let us know what you're building and we'll do our\n// best to make sure we can support you!\n//\n// We consider these exports an implementation detail and do not guarantee\n// against any breaking changes, regardless of the semver release. Use with\n// extreme caution and only if you understand the consequences. Godspeed.\n///////////////////////////////////////////////////////////////////////////////\n\n/** @internal */\nexport {\n UNSAFE_NavigationContext,\n UNSAFE_LocationContext,\n UNSAFE_RouteContext,\n UNSAFE_DataRouterContext,\n UNSAFE_DataRouterStateContext,\n useRenderDataRouter,\n} from \"react-router\";\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Components\n////////////////////////////////////////////////////////////////////////////////\n\nexport interface DataBrowserRouterProps {\n children?: React.ReactNode;\n hydrationData?: HydrationState;\n fallbackElement: React.ReactElement;\n routes?: RouteObject[];\n window?: Window;\n}\n\nexport function DataBrowserRouter({\n children,\n fallbackElement,\n hydrationData,\n routes,\n window,\n}: DataBrowserRouterProps): React.ReactElement {\n return useRenderDataRouter({\n children,\n fallbackElement,\n routes,\n createRouter: (routes) =>\n createBrowserRouter({\n routes,\n hydrationData,\n window,\n }),\n });\n}\n\nexport interface DataHashRouterProps {\n children?: React.ReactNode;\n hydrationData?: HydrationState;\n fallbackElement: React.ReactElement;\n routes?: RouteObject[];\n window?: Window;\n}\n\nexport function DataHashRouter({\n children,\n hydrationData,\n fallbackElement,\n routes,\n window,\n}: DataBrowserRouterProps): React.ReactElement {\n return useRenderDataRouter({\n children,\n fallbackElement,\n routes,\n createRouter: (routes) =>\n createHashRouter({\n routes,\n hydrationData,\n window,\n }),\n });\n}\n\nexport interface BrowserRouterProps {\n basename?: string;\n children?: React.ReactNode;\n window?: Window;\n}\n\n/**\n * A `<Router>` for use in web browsers. Provides the cleanest URLs.\n */\nexport function BrowserRouter({\n basename,\n children,\n window,\n}: BrowserRouterProps) {\n let historyRef = React.useRef<BrowserHistory>();\n if (historyRef.current == null) {\n historyRef.current = createBrowserHistory({ window, v5Compat: true });\n }\n\n let history = historyRef.current;\n let [state, setState] = React.useState({\n action: history.action,\n location: history.location,\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nexport interface HashRouterProps {\n basename?: string;\n children?: React.ReactNode;\n window?: Window;\n}\n\n/**\n * A `<Router>` for use in web browsers. Stores the location in the hash\n * portion of the URL so it is not sent to the server.\n */\nexport function HashRouter({ basename, children, window }: HashRouterProps) {\n let historyRef = React.useRef<HashHistory>();\n if (historyRef.current == null) {\n historyRef.current = createHashHistory({ window, v5Compat: true });\n }\n\n let history = historyRef.current;\n let [state, setState] = React.useState({\n action: history.action,\n location: history.location,\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nexport interface HistoryRouterProps {\n basename?: string;\n children?: React.ReactNode;\n history: History;\n}\n\n/**\n * A `<Router>` that accepts a pre-instantiated history object. It's important\n * to note that using your own history object is highly discouraged and may add\n * two versions of the history library to your bundles unless you use the same\n * version of the history library that React Router uses internally.\n */\nfunction HistoryRouter({ basename, children, history }: HistoryRouterProps) {\n const [state, setState] = React.useState({\n action: history.action,\n location: history.location,\n });\n\n React.useLayoutEffect(() => history.listen(setState), [history]);\n\n return (\n <Router\n basename={basename}\n children={children}\n location={state.location}\n navigationType={state.action}\n navigator={history}\n />\n );\n}\n\nif (__DEV__) {\n HistoryRouter.displayName = \"unstable_HistoryRouter\";\n}\n\nexport { HistoryRouter as unstable_HistoryRouter };\n\nexport interface LinkProps\n extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, \"href\"> {\n reloadDocument?: boolean;\n replace?: boolean;\n state?: any;\n resetScroll?: boolean;\n to: To;\n}\n\n/**\n * The public API for rendering a history-aware <a>.\n */\nexport const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function LinkWithRef(\n {\n onClick,\n reloadDocument,\n replace = false,\n state,\n target,\n to,\n resetScroll,\n ...rest\n },\n ref\n ) {\n let href = useHref(to);\n let internalOnClick = useLinkClickHandler(to, {\n replace,\n state,\n target,\n resetScroll,\n });\n function handleClick(\n event: React.MouseEvent<HTMLAnchorElement, MouseEvent>\n ) {\n if (onClick) onClick(event);\n if (!event.defaultPrevented && !reloadDocument) {\n internalOnClick(event);\n }\n }\n\n return (\n // eslint-disable-next-line jsx-a11y/anchor-has-content\n <a\n {...rest}\n href={href}\n onClick={handleClick}\n ref={ref}\n target={target}\n />\n );\n }\n);\n\nif (__DEV__) {\n Link.displayName = \"Link\";\n}\n\nexport interface NavLinkProps\n extends Omit<LinkProps, \"className\" | \"style\" | \"children\"> {\n children?:\n | React.ReactNode\n | ((props: { isActive: boolean; isPending: boolean }) => React.ReactNode);\n caseSensitive?: boolean;\n className?:\n | string\n | ((props: {\n isActive: boolean;\n isPending: boolean;\n }) => string | undefined);\n end?: boolean;\n style?:\n | React.CSSProperties\n | ((props: {\n isActive: boolean;\n isPending: boolean;\n }) => React.CSSProperties);\n}\n\n/**\n * A <Link> wrapper that knows if it's \"active\" or not.\n */\nexport const NavLink = React.forwardRef<HTMLAnchorElement, NavLinkProps>(\n function NavLinkWithRef(\n {\n \"aria-current\": ariaCurrentProp = \"page\",\n caseSensitive = false,\n className: classNameProp = \"\",\n end = false,\n style: styleProp,\n to,\n children,\n ...rest\n },\n ref\n ) {\n let path = useResolvedPath(to);\n let match = useMatch({ path: path.pathname, end, caseSensitive });\n\n let routerState = React.useContext(UNSAFE_DataRouterStateContext);\n let nextLocation = routerState?.navigation.location;\n let nextPath = useResolvedPath(nextLocation || \"\");\n let nextMatch = React.useMemo(\n () =>\n nextLocation\n ? matchPath(\n { path: path.pathname, end, caseSensitive },\n nextPath.pathname\n )\n : null,\n [nextLocation, path.pathname, caseSensitive, end, nextPath.pathname]\n );\n\n let isPending = nextMatch != null;\n let isActive = match != null;\n\n let ariaCurrent = isActive ? ariaCurrentProp : undefined;\n\n let className: string | undefined;\n if (typeof classNameProp === \"function\") {\n className = classNameProp({ isActive, isPending });\n } else {\n // If the className prop is not a function, we use a default `active`\n // class for <NavLink />s that are active. In v5 `active` was the default\n // value for `activeClassName`, but we are removing that API and can still\n // use the old default behavior for a cleaner upgrade path and keep the\n // simple styling rules working as they currently do.\n className = [\n classNameProp,\n isActive ? \"active\" : null,\n isPending ? \"pending\" : null,\n ]\n .filter(Boolean)\n .join(\" \");\n }\n\n let style =\n typeof styleProp === \"function\"\n ? styleProp({ isActive, isPending })\n : styleProp;\n\n return (\n <Link\n {...rest}\n aria-current={ariaCurrent}\n className={className}\n ref={ref}\n style={style}\n to={to}\n >\n {typeof children === \"function\"\n ? children({ isActive, isPending })\n : children}\n </Link>\n );\n }\n);\n\nif (__DEV__) {\n NavLink.displayName = \"NavLink\";\n}\n\nexport interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {\n /**\n * The HTTP verb to use when the form is submit. Supports \"get\", \"post\",\n * \"put\", \"delete\", \"patch\".\n */\n method?: FormMethod;\n\n /**\n * Normal `<form action>` but supports React Router's relative paths.\n */\n action?: string;\n\n /**\n * Replaces the current entry in the browser history stack when the form\n * navigates. Use this if you don't want the user to be able to click \"back\"\n * to the page with the form on it.\n */\n replace?: boolean;\n\n /**\n * A function to call when the form is submitted. If you call\n * `event.preventDefault()` then this form will not do anything.\n */\n onSubmit?: React.FormEventHandler<HTMLFormElement>;\n}\n\n/**\n * A `@remix-run/router`-aware `<form>`. It behaves like a normal form except\n * that the interaction with the server is with `fetch` instead of new document\n * requests, allowing components to add nicer UX to the page as the form is\n * submitted and returns with data.\n */\nexport const Form = React.forwardRef<HTMLFormElement, FormProps>(\n (props, ref) => {\n return <FormImpl {...props} ref={ref} />;\n }\n);\n\nif (__DEV__) {\n Form.displayName = \"Form\";\n}\n\ntype HTMLSubmitEvent = React.BaseSyntheticEvent<\n SubmitEvent,\n Event,\n HTMLFormElement\n>;\n\ntype HTMLFormSubmitter = HTMLButtonElement | HTMLInputElement;\n\ninterface FormImplProps extends FormProps {\n fetcherKey?: string;\n}\n\nconst FormImpl = React.forwardRef<HTMLFormElement, FormImplProps>(\n (\n {\n replace,\n method = defaultMethod,\n action = \".\",\n onSubmit,\n fetcherKey,\n ...props\n },\n forwardedRef\n ) => {\n let submit = useSubmitImpl(fetcherKey);\n let formMethod: FormMethod =\n method.toLowerCase() === \"get\" ? \"get\" : \"post\";\n let formAction = useFormAction(action);\n let submitHandler: React.FormEventHandler<HTMLFormElement> = (event) => {\n onSubmit && onSubmit(event);\n if (event.defaultPrevented) return;\n event.preventDefault();\n\n let submitter = (event as unknown as HTMLSubmitEvent).nativeEvent\n .submitter as HTMLFormSubmitter | null;\n\n submit(submitter || event.currentTarget, { method, replace });\n };\n\n return (\n <form\n ref={forwardedRef}\n method={formMethod}\n action={formAction}\n onSubmit={submitHandler}\n {...props}\n />\n );\n }\n);\n\nif (__DEV__) {\n Form.displayName = \"Form\";\n}\n\ninterface ScrollRestorationProps {\n getKey?: GetScrollRestorationKeyFunction;\n storageKey?: string;\n}\n\n/**\n * This component will emulate the browser's scroll restoration on location\n * changes.\n */\nexport function ScrollRestoration({\n getKey,\n storageKey,\n}: ScrollRestorationProps) {\n useScrollRestoration({ getKey, storageKey });\n return null;\n}\n\nif (__DEV__) {\n ScrollRestoration.displayName = \"ScrollRestoration\";\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Hooks\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Handles the click behavior for router `<Link>` components. This is useful if\n * you need to create custom `<Link>` components with the same click behavior we\n * use in our exported `<Link>`.\n */\nexport function useLinkClickHandler<E extends Element = HTMLAnchorElement>(\n to: To,\n {\n target,\n replace: replaceProp,\n state,\n resetScroll,\n }: {\n target?: React.HTMLAttributeAnchorTarget;\n replace?: boolean;\n state?: any;\n resetScroll?: boolean;\n } = {}\n): (event: React.MouseEvent<E, MouseEvent>) => void {\n let navigate = useNavigate();\n let location = useLocation();\n let path = useResolvedPath(to);\n\n return React.useCallback(\n (event: React.MouseEvent<E, MouseEvent>) => {\n if (shouldProcessLinkClick(event, target)) {\n event.preventDefault();\n\n // If the URL hasn't changed, a regular <a> will do a replace instead of\n // a push, so do the same here.\n let replace =\n !!replaceProp || createPath(location) === createPath(path);\n\n let newState = state;\n if (resetScroll === false) {\n newState = {\n ...state,\n __resetScrollPosition: false,\n };\n }\n\n navigate(to, { replace, state: newState });\n }\n },\n [location, navigate, path, replaceProp, state, target, to, resetScroll]\n );\n}\n\n/**\n * A convenient wrapper for reading and writing search parameters via the\n * URLSearchParams interface.\n */\nexport function useSearchParams(defaultInit?: URLSearchParamsInit) {\n warning(\n typeof URLSearchParams !== \"undefined\",\n `You cannot use the \\`useSearchParams\\` hook in a browser that does not ` +\n `support the URLSearchParams API. If you need to support Internet ` +\n `Explorer 11, we recommend you load a polyfill such as ` +\n `https://github.com/ungap/url-search-params\\n\\n` +\n `If you're unsure how to load polyfills, we recommend you check out ` +\n `https://polyfill.io/v3/ which provides some recommendations about how ` +\n `to load polyfills only for users that need them, instead of for every ` +\n `user.`\n );\n\n let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));\n\n let location = useLocation();\n let searchParams = React.useMemo(\n () =>\n getSearchParamsForLocation(\n location.search,\n defaultSearchParamsRef.current\n ),\n [location.search]\n );\n\n let navigate = useNavigate();\n let setSearchParams = React.useCallback(\n (\n nextInit: URLSearchParamsInit,\n navigateOptions?: { replace?: boolean; state?: any }\n ) => {\n navigate(\"?\" + createSearchParams(nextInit), navigateOptions);\n },\n [navigate]\n );\n\n return [searchParams, setSearchParams] as const;\n}\n\n/**\n * Submits a HTML `<form>` to the server without reloading the page.\n */\nexport interface SubmitFunction {\n (\n /**\n * Specifies the `<form>` to be submitted to the server, a specific\n * `<button>` or `<input type=\"submit\">` to use to submit the form, or some\n * arbitrary data to submit.\n *\n * Note: When using a `<button>` its `name` and `value` will also be\n * included in the form data that is submitted.\n */\n target:\n | HTMLFormElement\n | HTMLButtonElement\n | HTMLInputElement\n | FormData\n | URLSearchParams\n | { [name: string]: string }\n | null,\n\n /**\n * Options that override the `<form>`'s own attributes. Required when\n * submitting arbitrary data without a backing `<form>`.\n */\n options?: SubmitOptions\n ): void;\n}\n\n/**\n * Returns a function that may be used to programmatically submit a form (or\n * some arbitrary data) to the server.\n */\nexport function useSubmit(): SubmitFunction {\n return useSubmitImpl();\n}\n\nfunction useSubmitImpl(fetcherKey?: string): SubmitFunction {\n let router = React.useContext(UNSAFE_DataRouterContext);\n let defaultAction = useFormAction();\n\n return React.useCallback(\n (target, options = {}) => {\n invariant(\n router != null,\n \"useSubmit() must be used within a <DataRouter>\"\n );\n\n if (typeof document === \"undefined\") {\n throw new Error(\n \"You are calling submit during the server render. \" +\n \"Try calling submit within a `useEffect` or callback instead.\"\n );\n }\n\n let { method, encType, formData, url } = getFormSubmissionInfo(\n target,\n defaultAction,\n options\n );\n\n let href = url.pathname + url.search;\n let opts = {\n // If replace is not specified, we'll default to false for GET and\n // true otherwise\n replace:\n options.replace != null ? options.replace === true : method !== \"get\",\n formData,\n formMethod: method as FormMethod,\n formEncType: encType as FormEncType,\n };\n if (fetcherKey) {\n router.fetch(fetcherKey, href, opts);\n } else {\n router.navigate(href, opts);\n }\n },\n [defaultAction, router, fetcherKey]\n );\n}\n\nexport function useFormAction(action = \".\"): string {\n let routeContext = React.useContext(UNSAFE_RouteContext);\n invariant(routeContext, \"useLoaderData must be used inside a RouteContext\");\n\n let [match] = routeContext.matches.slice(-1);\n let { pathname, search } = useResolvedPath(action);\n\n if (action === \".\" && match.route.index) {\n search = search ? search.replace(/^\\?/, \"?index&\") : \"?index\";\n }\n\n return pathname + search;\n}\n\nfunction createFetcherForm(fetcherKey: string) {\n let FetcherForm = React.forwardRef<HTMLFormElement, FormProps>(\n (props, ref) => {\n return <FormImpl {...props} ref={ref} fetcherKey={fetcherKey} />;\n }\n );\n if (__DEV__) {\n FetcherForm.displayName = \"fetcher.Form\";\n }\n return FetcherForm;\n}\n\nlet fetcherId = 0;\n\ntype FetcherWithComponents<TData> = Fetcher<TData> & {\n Form: ReturnType<typeof createFetcherForm>;\n submit: ReturnType<typeof useSubmitImpl>;\n load: (href: string) => void;\n};\n\n/**\n * Interacts with route loaders and actions without causing a navigation. Great\n * for any interaction that stays on the same page.\n */\nexport function useFetcher<TData = any>(): FetcherWithComponents<TData> {\n let router = React.useContext(UNSAFE_DataRouterContext);\n invariant(router, `useFetcher must be used within a DataRouter`);\n\n let [fetcherKey] = React.useState(() => String(++fetcherId));\n let [Form] = React.useState(() => createFetcherForm(fetcherKey));\n let [load] = React.useState(() => (href: string) => {\n invariant(router, `No router available for fetcher.load()`);\n router.fetch(fetcherKey, href);\n });\n let submit = useSubmitImpl(fetcherKey);\n\n let fetcher = router.getFetcher<TData>(fetcherKey);\n\n let fetcherWithComponents = React.useMemo(\n () => ({\n Form,\n submit,\n load,\n ...fetcher,\n }),\n [fetcher, Form, submit, load]\n );\n\n React.useEffect(() => {\n // Is this busted when the React team gets real weird and calls effects\n // twice on mount? We really just need to garbage collect here when this\n // fetcher is no longer around.\n return () => {\n if (!router) {\n console.warn(\"No fetcher available to clean up from useFetcher()\");\n return;\n }\n router.deleteFetcher(fetcherKey);\n };\n }, [router, fetcherKey]);\n\n return fetcherWithComponents;\n}\n\n/**\n * Provides all fetchers currently on the page. Useful for layouts and parent\n * routes that need to provide pending/optimistic UI regarding the fetch.\n */\nexport function useFetchers(): Fetcher[] {\n let state = React.useContext(UNSAFE_DataRouterStateContext);\n invariant(state, `useFetchers must be used within a DataRouter`);\n return [...state.fetchers.values()];\n}\n\nconst SCROLL_RESTORATION_STORAGE_KEY = \"react-router-scroll-positions\";\nlet savedScrollPositions: Record<string, number> = {};\n\n/**\n * When rendered inside a DataRouter, will restore scroll positions on navigations\n */\nfunction useScrollRestoration({\n getKey,\n storageKey,\n}: {\n getKey?: GetScrollRestorationKeyFunction;\n storageKey?: string;\n} = {}) {\n let location = useLocation();\n let router = React.useContext(UNSAFE_DataRouterContext);\n let state = React.useContext(UNSAFE_DataRouterStateContext);\n\n invariant(\n router != null && state != null,\n \"useScrollRestoration must be used within a DataRouter\"\n );\n let { restoreScrollPosition, resetScrollPosition } = state;\n\n // Trigger manual scroll restoration while we're active\n React.useEffect(() => {\n window.history.scrollRestoration = \"manual\";\n return () => {\n window.history.scrollRestoration = \"auto\";\n };\n }, []);\n\n // Save positions on unload\n useBeforeUnload(\n React.useCallback(() => {\n if (state?.navigation.state === \"idle\") {\n let key =\n (getKey ? getKey(state.location, state.matches) : null) ||\n state.location.key;\n savedScrollPositions[key] = window.scrollY;\n }\n sessionStorage.setItem(\n storageKey || SCROLL_RESTORATION_STORAGE_KEY,\n JSON.stringify(savedScrollPositions)\n );\n window.history.scrollRestoration = \"auto\";\n }, [\n storageKey,\n getKey,\n state.navigation.state,\n state.location,\n state.matches,\n ])\n );\n\n // Read in any saved scroll locations\n React.useLayoutEffect(() => {\n try {\n let sessionPositions = sessionStorage.getItem(\n storageKey || SCROLL_RESTORATION_STORAGE_KEY\n );\n if (sessionPositions) {\n savedScrollPositions = JSON.parse(sessionPositions);\n }\n } catch (e) {\n // no-op, use default empty object\n }\n }, [storageKey]);\n\n // Enable scroll restoration in the router\n React.useLayoutEffect(() => {\n let disableScrollRestoration = router?.enableScrollRestoration(\n savedScrollPositions,\n () => window.scrollY,\n getKey\n );\n return () => disableScrollRestoration && disableScrollRestoration();\n }, [router, getKey]);\n\n // Restore scrolling when state.restoreScrollPosition changes\n React.useLayoutEffect(() => {\n // Explicit false means don't do anything (used for submissions)\n if (restoreScrollPosition === false) {\n return;\n }\n\n // been here before, scroll to it\n if (typeof restoreScrollPosition === \"number\") {\n window.scrollTo(0, restoreScrollPosition);\n return;\n }\n\n // try to scroll to the hash\n if (location.hash) {\n let el = document.getElementById(location.hash.slice(1));\n if (el) {\n el.scrollIntoView();\n return;\n }\n }\n\n // Opt out of scroll reset if this link requested it\n if (resetScrollPosition === false) {\n return;\n }\n\n // otherwise go to the top on new locations\n window.scrollTo(0, 0);\n }, [location, restoreScrollPosition, resetScrollPosition]);\n}\n\nfunction useBeforeUnload(callback: () => any): void {\n React.useEffect(() => {\n window.addEventListener(\"beforeunload\", callback);\n return () => {\n window.removeEventListener(\"beforeunload\", callback);\n };\n }, [callback]);\n}\n\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Utils\n////////////////////////////////////////////////////////////////////////////////\n\nfunction warning(cond: boolean, message: string): void {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging React Router!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n//#endregion\n","import * as React from \"react\";\nimport type { Location, To } from \"history\";\nimport { Action, createPath, parsePath } from \"history\";\n\n// Get useHistory from react-router-dom v5 (peer dep).\n// @ts-expect-error\nimport { useHistory, Route as RouteV5 } from \"react-router-dom\";\n\n// We are a wrapper around react-router-dom v6, so bring it in\n// and bundle it because an app can't have two versions of\n// react-router-dom in its package.json.\nimport { Router, Routes, Route } from \"../react-router-dom\";\n\n// v5 isn't in TypeScript, they'll also lose the @types/react-router with this\n// but not worried about that for now.\nexport function CompatRoute(props: any) {\n let { path } = props;\n if (!props.exact) path += \"/*\";\n return (\n <Routes>\n <Route path={path} element={<RouteV5 {...props} />} />\n </Routes>\n );\n}\n\nexport function CompatRouter({ children }: { children: React.ReactNode }) {\n let history = useHistory();\n let [state, setState] = React.useState(() => ({\n location: history.location,\n action: history.action,\n }));\n\n React.useLayoutEffect(() => {\n history.listen((location: Location, action: Action) =>\n setState({ location, action })\n );\n }, [history]);\n\n return (\n <Router\n navigationType={state.action}\n location={state.location}\n navigator={history}\n >\n <Routes>\n <Route path=\"*\" element={children} />\n </Routes>\n </Router>\n );\n}\n\nexport interface StaticRouterProps {\n basename?: string;\n children?: React.ReactNode;\n location: Partial<Location> | string;\n}\n\n/**\n * A <Router> that may not navigate to any other location. This is useful\n * on the server where there is no stateful UI.\n */\nexport function StaticRouter({\n basename,\n children,\n location: locationProp = \"/\",\n}: StaticRouterProps) {\n if (typeof locationProp === \"string\") {\n locationProp = parsePath(locationProp);\n }\n\n let action = Action.Pop;\n let location: Location = {\n pathname: locationProp.pathname || \"/\",\n search: locationProp.search || \"\",\n hash: locationProp.hash || \"\",\n state: locationProp.state || null,\n key: locationProp.key || \"default\",\n };\n\n let staticNavigator = {\n createHref(to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n },\n push(to: To) {\n throw new Error(\n `You cannot use navigator.push() on the server because it is a stateless ` +\n `environment. This error was probably triggered when you did a ` +\n `\\`navigate(${JSON.stringify(to)})\\` somewhere in your app.`\n );\n },\n replace(to: To) {\n throw new Error(\n `You cannot use navigator.replace() on the server because it is a stateless ` +\n `environment. This error was probably triggered when you did a ` +\n `\\`navigate(${JSON.stringify(to)}, { replace: true })\\` somewhere ` +\n `in your app.`\n );\n },\n go(delta: number) {\n throw new Error(\n `You cannot use navigator.go() on the server because it is a stateless ` +\n `environment. This error was probably triggered when you did a ` +\n `\\`navigate(${delta})\\` somewhere in your app.`\n );\n },\n back() {\n throw new Error(\n `You cannot use navigator.back() on the server because it is a stateless ` +\n `environment.`\n );\n },\n forward() {\n throw new Error(\n `You cannot use navigator.forward() on the server because it is a stateless ` +\n `environment.`\n );\n },\n };\n\n return (\n <Router\n basename={basename}\n children={children}\n location={location}\n navigationType={action}\n navigator={staticNavigator}\n static={true}\n />\n );\n}\n"],"names":["defaultMethod","defaultEncType","isHtmlElement","object","tagName","isButtonElement","toLowerCase","isFormElement","isInputElement","isModifiedEvent","event","metaKey","altKey","ctrlKey","shiftKey","shouldProcessLinkClick","target","button","createSearchParams","init","URLSearchParams","Array","isArray","Object","keys","reduce","memo","key","value","concat","map","v","getSearchParamsForLocation","locationSearch","defaultSearchParams","searchParams","has","getAll","forEach","append","getFormSubmissionInfo","defaultAction","options","method","action","encType","formData","submissionTrigger","getAttribute","FormData","name","type","form","Error","set","protocol","host","window","location","url","URL","BrowserRouter","basename","children","historyRef","React","current","createBrowserHistory","v5Compat","history","state","setState","listen","React.createElement","HashRouter","createHashHistory","HistoryRouter","displayName","Link","LinkWithRef","ref","onClick","reloadDocument","replace","to","resetScroll","rest","href","useHref","internalOnClick","useLinkClickHandler","handleClick","defaultPrevented","NavLink","NavLinkWithRef","ariaCurrentProp","caseSensitive","className","classNameProp","end","style","styleProp","path","useResolvedPath","match","useMatch","pathname","routerState","UNSAFE_DataRouterStateContext","nextLocation","navigation","nextPath","nextMatch","matchPath","isPending","isActive","ariaCurrent","undefined","filter","Boolean","join","Form","props","FormImpl","forwardedRef","onSubmit","fetcherKey","submit","useSubmitImpl","formMethod","formAction","useFormAction","submitHandler","preventDefault","submitter","nativeEvent","currentTarget","replaceProp","navigate","useNavigate","useLocation","createPath","newState","__resetScrollPosition","useSearchParams","defaultInit","warning","defaultSearchParamsRef","search","setSearchParams","nextInit","navigateOptions","router","UNSAFE_DataRouterContext","invariant","document","opts","formEncType","fetch","routeContext","UNSAFE_RouteContext","matches","slice","route","index","cond","message","console","warn","e","CompatRoute","exact","RouteV5","CompatRouter","useHistory","StaticRouter","locationProp","parsePath","Action","Pop","hash","staticNavigator","createHref","push","JSON","stringify","go","delta","back","forward"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,MAAMA,aAAa,GAAG,KAAtB;AACP,MAAMC,cAAc,GAAG,mCAAvB;AAEO,SAASC,aAAT,CAAuBC,MAAvB,EAA2D;AAChE,SAAOA,MAAM,IAAI,IAAV,IAAkB,OAAOA,MAAM,CAACC,OAAd,KAA0B,QAAnD;AACD;AAEM,SAASC,eAAT,CAAyBF,MAAzB,EAAmE;AACxE,SAAOD,aAAa,CAACC,MAAD,CAAb,IAAyBA,MAAM,CAACC,OAAP,CAAeE,WAAf,OAAiC,QAAjE;AACD;AAEM,SAASC,aAAT,CAAuBJ,MAAvB,EAA+D;AACpE,SAAOD,aAAa,CAACC,MAAD,CAAb,IAAyBA,MAAM,CAACC,OAAP,CAAeE,WAAf,OAAiC,MAAjE;AACD;AAEM,SAASE,cAAT,CAAwBL,MAAxB,EAAiE;AACtE,SAAOD,aAAa,CAACC,MAAD,CAAb,IAAyBA,MAAM,CAACC,OAAP,CAAeE,WAAf,OAAiC,OAAjE;AACD;;AAOD,SAASG,eAAT,CAAyBC,KAAzB,EAAmD;AACjD,SAAO,CAAC,EAAEA,KAAK,CAACC,OAAN,IAAiBD,KAAK,CAACE,MAAvB,IAAiCF,KAAK,CAACG,OAAvC,IAAkDH,KAAK,CAACI,QAA1D,CAAR;AACD;;AAEM,SAASC,sBAAT,CACLL,KADK,EAELM,MAFK,EAGL;AACA,SACEN,KAAK,CAACO,MAAN,KAAiB,CAAjB;AACC,GAACD,MAAD,IAAWA,MAAM,KAA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,eAAe,GAAG;AACpBC,IAAAA,UAAU,CAAClG,EAAD,EAAS;AACjB,aAAO,OAAOA,EAAP,KAAc,QAAd,GAAyBA,EAAzB,GAA8ByD,YAAU,CAACzD,EAAD,CAA/C;AACD,KAHmB;;AAIpBmG,IAAAA,IAAI,CAACnG,EAAD,EAAS;AACX,YAAM,IAAI/B,KAAJ,CACJ,gKAEgBmI,IAAI,CAACC,SAAL,CAAerG,EAAf,CAFhB,+BADI,CAAN;AAKD,KAVmB;;AAWpBD,IAAAA,OAAO,CAACC,EAAD,EAAS;AACd,YAAM,IAAI/B,KAAJ,CACJ,mKAEgBmI,IAAI,CAACC,SAAL,CAAerG,EAAf,CAFhB,uDADI,CAAN;AAMD,KAlBmB;;AAmBpBsG,IAAAA,EAAE,CAACC,KAAD,EAAgB;AAChB,YAAM,IAAItI,KAAJ,CACJ,8JAEgBsI,KAFhB,+BADI,CAAN;AAKD,KAzBmB;;AA0BpBC,IAAAA,IAAI,GAAG;AACL,YAAM,IAAIvI,KAAJ,CACJ,2FADI,CAAN;AAID,KA/BmB;;AAgCpBwI,IAAAA,OAAO,GAAG;AACR,YAAM,IAAIxI,KAAJ,CACJ,8FADI,CAAN;AAID;;AArCmB,GAAtB;AAwCA,sBACEoB,cAAC,MAAD;AACE,IAAA,QAAQ,EAAEX,QADZ;AAEE,IAAA,QAAQ,EAAEC,QAFZ;AAGE,IAAA,QAAQ,EAAEL,QAHZ;AAIE,IAAA,cAAc,EAAEd,MAJlB;AAKE,IAAA,SAAS,EAAEyI,eALb;AAME,IAAA,MAAM,EAAE;AANV,IADF;AAUD;;;;"}
@@ -1,5 +1,6 @@
1
1
  import * as React from "react";
2
2
  import type { Location } from "history";
3
+ export declare function CompatRoute(props: any): JSX.Element;
3
4
  export declare function CompatRouter({ children }: {
4
5
  children: React.ReactNode;
5
6
  }): JSX.Element;
@@ -9,7 +10,7 @@ export interface StaticRouterProps {
9
10
  location: Partial<Location> | string;
10
11
  }
11
12
  /**
12
- * A <Router> that may not transition to any other location. This is useful
13
+ * A <Router> that may not navigate to any other location. This is useful
13
14
  * on the server where there is no stateful UI.
14
15
  */
15
16
  export declare function StaticRouter({ basename, children, location: locationProp, }: StaticRouterProps): JSX.Element;
package/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router DOM v5 Compat v6.2.2
2
+ * React Router DOM v5 Compat v6.4.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router-dom-v5-compat",
3
- "version": "6.2.2",
3
+ "version": "6.4.0-pre.2",
4
4
  "author": "Remix Software <hello@remix.run>",
5
5
  "description": "Migration path to React Router v6 from v4/5",
6
6
  "repository": {
@@ -13,15 +13,15 @@
13
13
  "module": "./index.js",
14
14
  "types": "./index.d.ts",
15
15
  "unpkg": "./umd/react-router.production.min.js",
16
+ "dependencies": {
17
+ "history": "^5.3.0",
18
+ "react-router": "6.4.0-pre.2"
19
+ },
16
20
  "peerDependencies": {
17
21
  "react": ">=16.8",
18
22
  "react-dom": ">=16.8",
19
23
  "react-router-dom": "4 || 5"
20
24
  },
21
- "dependencies": {
22
- "history": "^5.3.0",
23
- "react-router": "6.2.2"
24
- },
25
25
  "sideEffects": false,
26
26
  "keywords": [
27
27
  "react",
@@ -0,0 +1,68 @@
1
+ import type { FormEncType, FormMethod } from "@remix-run/router";
2
+ export declare const defaultMethod = "get";
3
+ export declare function isHtmlElement(object: any): object is HTMLElement;
4
+ export declare function isButtonElement(object: any): object is HTMLButtonElement;
5
+ export declare function isFormElement(object: any): object is HTMLFormElement;
6
+ export declare function isInputElement(object: any): object is HTMLInputElement;
7
+ declare type LimitedMouseEvent = Pick<MouseEvent, "button" | "metaKey" | "altKey" | "ctrlKey" | "shiftKey">;
8
+ export declare function shouldProcessLinkClick(event: LimitedMouseEvent, target?: string): boolean;
9
+ export declare type ParamKeyValuePair = [string, string];
10
+ export declare type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
11
+ /**
12
+ * Creates a URLSearchParams object using the given initializer.
13
+ *
14
+ * This is identical to `new URLSearchParams(init)` except it also
15
+ * supports arrays as values in the object form of the initializer
16
+ * instead of just strings. This is convenient when you need multiple
17
+ * values for a given key, but don't want to use an array initializer.
18
+ *
19
+ * For example, instead of:
20
+ *
21
+ * let searchParams = new URLSearchParams([
22
+ * ['sort', 'name'],
23
+ * ['sort', 'price']
24
+ * ]);
25
+ *
26
+ * you can do:
27
+ *
28
+ * let searchParams = createSearchParams({
29
+ * sort: ['name', 'price']
30
+ * });
31
+ */
32
+ export declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
33
+ export declare function getSearchParamsForLocation(locationSearch: string, defaultSearchParams: URLSearchParams): URLSearchParams;
34
+ export interface SubmitOptions {
35
+ /**
36
+ * The HTTP method used to submit the form. Overrides `<form method>`.
37
+ * Defaults to "GET".
38
+ */
39
+ method?: FormMethod;
40
+ /**
41
+ * The action URL path used to submit the form. Overrides `<form action>`.
42
+ * Defaults to the path of the current route.
43
+ *
44
+ * Note: It is assumed the path is already resolved. If you need to resolve a
45
+ * relative path, use `useFormAction`.
46
+ */
47
+ action?: string;
48
+ /**
49
+ * The action URL used to submit the form. Overrides `<form encType>`.
50
+ * Defaults to "application/x-www-form-urlencoded".
51
+ */
52
+ encType?: FormEncType;
53
+ /**
54
+ * Set `true` to replace the current entry in the browser's history stack
55
+ * instead of creating a new one (i.e. stay on "the same page"). Defaults
56
+ * to `false`.
57
+ */
58
+ replace?: boolean;
59
+ }
60
+ export declare function getFormSubmissionInfo(target: HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | {
61
+ [name: string]: string;
62
+ } | null, defaultAction: string, options: SubmitOptions): {
63
+ url: URL;
64
+ method: string;
65
+ encType: string;
66
+ formData: FormData;
67
+ };
68
+ export {};
@@ -3,14 +3,32 @@
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 { History } from "history";
7
- import { MemoryRouter, Navigate, Outlet, Route, Router, Routes, createRoutesFromChildren, generatePath, matchRoutes, matchPath, createPath, parsePath, resolvePath, renderMatches, useHref, useInRouterContext, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useRoutes, useOutletContext } from "react-router";
8
6
  import type { To } from "react-router";
9
- export { MemoryRouter, Navigate, Outlet, Route, Router, Routes, createRoutesFromChildren, generatePath, matchRoutes, matchPath, createPath, parsePath, renderMatches, resolvePath, useHref, useInRouterContext, useLocation, useMatch, useNavigate, useNavigationType, useOutlet, useParams, useResolvedPath, useRoutes, useOutletContext, };
10
- export { NavigationType } from "react-router";
11
- export type { Hash, Location, Path, To, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigator, OutletProps, Params, PathMatch, RouteMatch, RouteObject, RouteProps, PathRouteProps, LayoutRouteProps, IndexRouteProps, RouterProps, Pathname, Search, RoutesProps, } from "react-router";
7
+ import type { Fetcher, FormMethod, History, HydrationState, GetScrollRestorationKeyFunction, RouteObject } from "@remix-run/router";
8
+ import type { SubmitOptions, ParamKeyValuePair, URLSearchParamsInit } from "./dom";
9
+ import { createSearchParams } from "./dom";
10
+ export type { ParamKeyValuePair, URLSearchParamsInit };
11
+ export { createSearchParams };
12
+ export type { ActionFunction, DataMemoryRouterProps, DataRouteMatch, Fetcher, Hash, IndexRouteProps, JsonFunction, LayoutRouteProps, LoaderFunction, Location, MemoryRouterProps, NavigateFunction, NavigateOptions, NavigateProps, Navigation, Navigator, OutletProps, Params, Path, PathMatch, Pathname, PathPattern, PathRouteProps, RedirectFunction, RouteMatch, RouteObject, RouteProps, RouterProps, RoutesProps, Search, ShouldRevalidateFunction, To, } from "react-router";
13
+ export { DataMemoryRouter, MemoryRouter, Navigate, NavigationType, Outlet, Route, Router, Routes, createPath, createRoutesFromChildren, isRouteErrorResponse, generatePath, json, matchPath, matchRoutes, parsePath, redirect, renderMatches, resolvePath, useActionData, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes, } from "react-router";
12
14
  /** @internal */
13
- export { UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, } from "react-router";
15
+ export { UNSAFE_NavigationContext, UNSAFE_LocationContext, UNSAFE_RouteContext, UNSAFE_DataRouterContext, UNSAFE_DataRouterStateContext, useRenderDataRouter, } from "react-router";
16
+ export interface DataBrowserRouterProps {
17
+ children?: React.ReactNode;
18
+ hydrationData?: HydrationState;
19
+ fallbackElement: React.ReactElement;
20
+ routes?: RouteObject[];
21
+ window?: Window;
22
+ }
23
+ export declare function DataBrowserRouter({ children, fallbackElement, hydrationData, routes, window, }: DataBrowserRouterProps): React.ReactElement;
24
+ export interface DataHashRouterProps {
25
+ children?: React.ReactNode;
26
+ hydrationData?: HydrationState;
27
+ fallbackElement: React.ReactElement;
28
+ routes?: RouteObject[];
29
+ window?: Window;
30
+ }
31
+ export declare function DataHashRouter({ children, hydrationData, fallbackElement, routes, window, }: DataBrowserRouterProps): React.ReactElement;
14
32
  export interface BrowserRouterProps {
15
33
  basename?: string;
16
34
  children?: React.ReactNode;
@@ -50,6 +68,7 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
50
68
  reloadDocument?: boolean;
51
69
  replace?: boolean;
52
70
  state?: any;
71
+ resetScroll?: boolean;
53
72
  to: To;
54
73
  }
55
74
  /**
@@ -57,31 +76,76 @@ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorEle
57
76
  */
58
77
  export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
59
78
  export interface NavLinkProps extends Omit<LinkProps, "className" | "style" | "children"> {
60
- children: React.ReactNode | ((props: {
79
+ children?: React.ReactNode | ((props: {
61
80
  isActive: boolean;
81
+ isPending: boolean;
62
82
  }) => React.ReactNode);
63
83
  caseSensitive?: boolean;
64
84
  className?: string | ((props: {
65
85
  isActive: boolean;
86
+ isPending: boolean;
66
87
  }) => string | undefined);
67
88
  end?: boolean;
68
89
  style?: React.CSSProperties | ((props: {
69
90
  isActive: boolean;
91
+ isPending: boolean;
70
92
  }) => React.CSSProperties);
71
93
  }
72
94
  /**
73
95
  * A <Link> wrapper that knows if it's "active" or not.
74
96
  */
75
97
  export declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
98
+ export interface FormProps extends React.FormHTMLAttributes<HTMLFormElement> {
99
+ /**
100
+ * The HTTP verb to use when the form is submit. Supports "get", "post",
101
+ * "put", "delete", "patch".
102
+ */
103
+ method?: FormMethod;
104
+ /**
105
+ * Normal `<form action>` but supports React Router's relative paths.
106
+ */
107
+ action?: string;
108
+ /**
109
+ * Replaces the current entry in the browser history stack when the form
110
+ * navigates. Use this if you don't want the user to be able to click "back"
111
+ * to the page with the form on it.
112
+ */
113
+ replace?: boolean;
114
+ /**
115
+ * A function to call when the form is submitted. If you call
116
+ * `event.preventDefault()` then this form will not do anything.
117
+ */
118
+ onSubmit?: React.FormEventHandler<HTMLFormElement>;
119
+ }
120
+ /**
121
+ * A `@remix-run/router`-aware `<form>`. It behaves like a normal form except
122
+ * that the interaction with the server is with `fetch` instead of new document
123
+ * requests, allowing components to add nicer UX to the page as the form is
124
+ * submitted and returns with data.
125
+ */
126
+ export declare const Form: React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
127
+ interface ScrollRestorationProps {
128
+ getKey?: GetScrollRestorationKeyFunction;
129
+ storageKey?: string;
130
+ }
131
+ /**
132
+ * This component will emulate the browser's scroll restoration on location
133
+ * changes.
134
+ */
135
+ export declare function ScrollRestoration({ getKey, storageKey, }: ScrollRestorationProps): null;
136
+ export declare namespace ScrollRestoration {
137
+ var displayName: string;
138
+ }
76
139
  /**
77
140
  * Handles the click behavior for router `<Link>` components. This is useful if
78
141
  * you need to create custom `<Link>` components with the same click behavior we
79
142
  * use in our exported `<Link>`.
80
143
  */
81
- export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, }?: {
144
+ export declare function useLinkClickHandler<E extends Element = HTMLAnchorElement>(to: To, { target, replace: replaceProp, state, resetScroll, }?: {
82
145
  target?: React.HTMLAttributeAnchorTarget;
83
146
  replace?: boolean;
84
147
  state?: any;
148
+ resetScroll?: boolean;
85
149
  }): (event: React.MouseEvent<E, MouseEvent>) => void;
86
150
  /**
87
151
  * A convenient wrapper for reading and writing search parameters via the
@@ -91,27 +155,48 @@ export declare function useSearchParams(defaultInit?: URLSearchParamsInit): read
91
155
  replace?: boolean | undefined;
92
156
  state?: any;
93
157
  } | undefined) => void];
94
- export declare type ParamKeyValuePair = [string, string];
95
- export declare type URLSearchParamsInit = string | ParamKeyValuePair[] | Record<string, string | string[]> | URLSearchParams;
96
158
  /**
97
- * Creates a URLSearchParams object using the given initializer.
98
- *
99
- * This is identical to `new URLSearchParams(init)` except it also
100
- * supports arrays as values in the object form of the initializer
101
- * instead of just strings. This is convenient when you need multiple
102
- * values for a given key, but don't want to use an array initializer.
103
- *
104
- * For example, instead of:
105
- *
106
- * let searchParams = new URLSearchParams([
107
- * ['sort', 'name'],
108
- * ['sort', 'price']
109
- * ]);
110
- *
111
- * you can do:
112
- *
113
- * let searchParams = createSearchParams({
114
- * sort: ['name', 'price']
115
- * });
159
+ * Submits a HTML `<form>` to the server without reloading the page.
160
+ */
161
+ export interface SubmitFunction {
162
+ (
163
+ /**
164
+ * Specifies the `<form>` to be submitted to the server, a specific
165
+ * `<button>` or `<input type="submit">` to use to submit the form, or some
166
+ * arbitrary data to submit.
167
+ *
168
+ * Note: When using a `<button>` its `name` and `value` will also be
169
+ * included in the form data that is submitted.
170
+ */
171
+ target: HTMLFormElement | HTMLButtonElement | HTMLInputElement | FormData | URLSearchParams | {
172
+ [name: string]: string;
173
+ } | null,
174
+ /**
175
+ * Options that override the `<form>`'s own attributes. Required when
176
+ * submitting arbitrary data without a backing `<form>`.
177
+ */
178
+ options?: SubmitOptions): void;
179
+ }
180
+ /**
181
+ * Returns a function that may be used to programmatically submit a form (or
182
+ * some arbitrary data) to the server.
183
+ */
184
+ export declare function useSubmit(): SubmitFunction;
185
+ declare function useSubmitImpl(fetcherKey?: string): SubmitFunction;
186
+ export declare function useFormAction(action?: string): string;
187
+ declare function createFetcherForm(fetcherKey: string): React.ForwardRefExoticComponent<FormProps & React.RefAttributes<HTMLFormElement>>;
188
+ declare type FetcherWithComponents<TData> = Fetcher<TData> & {
189
+ Form: ReturnType<typeof createFetcherForm>;
190
+ submit: ReturnType<typeof useSubmitImpl>;
191
+ load: (href: string) => void;
192
+ };
193
+ /**
194
+ * Interacts with route loaders and actions without causing a navigation. Great
195
+ * for any interaction that stays on the same page.
196
+ */
197
+ export declare function useFetcher<TData = any>(): FetcherWithComponents<TData>;
198
+ /**
199
+ * Provides all fetchers currently on the page. Useful for layouts and parent
200
+ * routes that need to provide pending/optimistic UI regarding the fetch.
116
201
  */
117
- export declare function createSearchParams(init?: URLSearchParamsInit): URLSearchParams;
202
+ export declare function useFetchers(): Fetcher[];