react-router-dom.development.js 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829
  1. /**
  2. * React Router DOM v6.30.1
  3. *
  4. * Copyright (c) Remix Software Inc.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE.md file in the root directory of this source tree.
  8. *
  9. * @license MIT
  10. */
  11. (function (global, factory) {
  12. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('react-router'), require('@remix-run/router')) :
  13. typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', 'react-router', '@remix-run/router'], factory) :
  14. (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactRouterDOM = {}, global.React, global.ReactDOM, global.ReactRouter, global.RemixRouter));
  15. })(this, (function (exports, React, ReactDOM, reactRouter, router) { 'use strict';
  16. function _interopNamespace(e) {
  17. if (e && e.__esModule) return e;
  18. var n = Object.create(null);
  19. if (e) {
  20. Object.keys(e).forEach(function (k) {
  21. if (k !== 'default') {
  22. var d = Object.getOwnPropertyDescriptor(e, k);
  23. Object.defineProperty(n, k, d.get ? d : {
  24. enumerable: true,
  25. get: function () { return e[k]; }
  26. });
  27. }
  28. });
  29. }
  30. n["default"] = e;
  31. return Object.freeze(n);
  32. }
  33. var React__namespace = /*#__PURE__*/_interopNamespace(React);
  34. var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
  35. function _extends() {
  36. _extends = Object.assign ? Object.assign.bind() : function (target) {
  37. for (var i = 1; i < arguments.length; i++) {
  38. var source = arguments[i];
  39. for (var key in source) {
  40. if (Object.prototype.hasOwnProperty.call(source, key)) {
  41. target[key] = source[key];
  42. }
  43. }
  44. }
  45. return target;
  46. };
  47. return _extends.apply(this, arguments);
  48. }
  49. function _objectWithoutPropertiesLoose(source, excluded) {
  50. if (source == null) return {};
  51. var target = {};
  52. var sourceKeys = Object.keys(source);
  53. var key, i;
  54. for (i = 0; i < sourceKeys.length; i++) {
  55. key = sourceKeys[i];
  56. if (excluded.indexOf(key) >= 0) continue;
  57. target[key] = source[key];
  58. }
  59. return target;
  60. }
  61. const defaultMethod = "get";
  62. const defaultEncType = "application/x-www-form-urlencoded";
  63. function isHtmlElement(object) {
  64. return object != null && typeof object.tagName === "string";
  65. }
  66. function isButtonElement(object) {
  67. return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
  68. }
  69. function isFormElement(object) {
  70. return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
  71. }
  72. function isInputElement(object) {
  73. return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
  74. }
  75. function isModifiedEvent(event) {
  76. return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
  77. }
  78. function shouldProcessLinkClick(event, target) {
  79. return event.button === 0 && (
  80. // Ignore everything but left clicks
  81. !target || target === "_self") &&
  82. // Let browser handle "target=_blank" etc.
  83. !isModifiedEvent(event) // Ignore clicks with modifier keys
  84. ;
  85. }
  86. /**
  87. * Creates a URLSearchParams object using the given initializer.
  88. *
  89. * This is identical to `new URLSearchParams(init)` except it also
  90. * supports arrays as values in the object form of the initializer
  91. * instead of just strings. This is convenient when you need multiple
  92. * values for a given key, but don't want to use an array initializer.
  93. *
  94. * For example, instead of:
  95. *
  96. * let searchParams = new URLSearchParams([
  97. * ['sort', 'name'],
  98. * ['sort', 'price']
  99. * ]);
  100. *
  101. * you can do:
  102. *
  103. * let searchParams = createSearchParams({
  104. * sort: ['name', 'price']
  105. * });
  106. */
  107. function createSearchParams(init) {
  108. if (init === void 0) {
  109. init = "";
  110. }
  111. return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
  112. let value = init[key];
  113. return memo.concat(Array.isArray(value) ? value.map(v => [key, v]) : [[key, value]]);
  114. }, []));
  115. }
  116. function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
  117. let searchParams = createSearchParams(locationSearch);
  118. if (defaultSearchParams) {
  119. // Use `defaultSearchParams.forEach(...)` here instead of iterating of
  120. // `defaultSearchParams.keys()` to work-around a bug in Firefox related to
  121. // web extensions. Relevant Bugzilla tickets:
  122. // https://bugzilla.mozilla.org/show_bug.cgi?id=1414602
  123. // https://bugzilla.mozilla.org/show_bug.cgi?id=1023984
  124. defaultSearchParams.forEach((_, key) => {
  125. if (!searchParams.has(key)) {
  126. defaultSearchParams.getAll(key).forEach(value => {
  127. searchParams.append(key, value);
  128. });
  129. }
  130. });
  131. }
  132. return searchParams;
  133. }
  134. // Thanks https://github.com/sindresorhus/type-fest!
  135. // One-time check for submitter support
  136. let _formDataSupportsSubmitter = null;
  137. function isFormDataSubmitterSupported() {
  138. if (_formDataSupportsSubmitter === null) {
  139. try {
  140. new FormData(document.createElement("form"),
  141. // @ts-expect-error if FormData supports the submitter parameter, this will throw
  142. 0);
  143. _formDataSupportsSubmitter = false;
  144. } catch (e) {
  145. _formDataSupportsSubmitter = true;
  146. }
  147. }
  148. return _formDataSupportsSubmitter;
  149. }
  150. /**
  151. * Submit options shared by both navigations and fetchers
  152. */
  153. /**
  154. * Submit options available to fetchers
  155. */
  156. /**
  157. * Submit options available to navigations
  158. */
  159. const supportedFormEncTypes = new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
  160. function getFormEncType(encType) {
  161. if (encType != null && !supportedFormEncTypes.has(encType)) {
  162. router.UNSAFE_warning(false, "\"" + encType + "\" is not a valid `encType` for `<Form>`/`<fetcher.Form>` " + ("and will default to \"" + defaultEncType + "\"")) ;
  163. return null;
  164. }
  165. return encType;
  166. }
  167. function getFormSubmissionInfo(target, basename) {
  168. let method;
  169. let action;
  170. let encType;
  171. let formData;
  172. let body;
  173. if (isFormElement(target)) {
  174. // When grabbing the action from the element, it will have had the basename
  175. // prefixed to ensure non-JS scenarios work, so strip it since we'll
  176. // re-prefix in the router
  177. let attr = target.getAttribute("action");
  178. action = attr ? router.stripBasename(attr, basename) : null;
  179. method = target.getAttribute("method") || defaultMethod;
  180. encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
  181. formData = new FormData(target);
  182. } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
  183. let form = target.form;
  184. if (form == null) {
  185. throw new Error("Cannot submit a <button> or <input type=\"submit\"> without a <form>");
  186. }
  187. // <button>/<input type="submit"> may override attributes of <form>
  188. // When grabbing the action from the element, it will have had the basename
  189. // prefixed to ensure non-JS scenarios work, so strip it since we'll
  190. // re-prefix in the router
  191. let attr = target.getAttribute("formaction") || form.getAttribute("action");
  192. action = attr ? router.stripBasename(attr, basename) : null;
  193. method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
  194. encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
  195. // Build a FormData object populated from a form and submitter
  196. formData = new FormData(form, target);
  197. // If this browser doesn't support the `FormData(el, submitter)` format,
  198. // then tack on the submitter value at the end. This is a lightweight
  199. // solution that is not 100% spec compliant. For complete support in older
  200. // browsers, consider using the `formdata-submitter-polyfill` package
  201. if (!isFormDataSubmitterSupported()) {
  202. let {
  203. name,
  204. type,
  205. value
  206. } = target;
  207. if (type === "image") {
  208. let prefix = name ? name + "." : "";
  209. formData.append(prefix + "x", "0");
  210. formData.append(prefix + "y", "0");
  211. } else if (name) {
  212. formData.append(name, value);
  213. }
  214. }
  215. } else if (isHtmlElement(target)) {
  216. throw new Error("Cannot submit element that is not <form>, <button>, or " + "<input type=\"submit|image\">");
  217. } else {
  218. method = defaultMethod;
  219. action = null;
  220. encType = defaultEncType;
  221. body = target;
  222. }
  223. // Send body for <Form encType="text/plain" so we encode it into text
  224. if (formData && encType === "text/plain") {
  225. body = formData;
  226. formData = undefined;
  227. }
  228. return {
  229. action,
  230. method: method.toLowerCase(),
  231. encType,
  232. formData,
  233. body
  234. };
  235. }
  236. const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"],
  237. _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"],
  238. _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
  239. //#endregion
  240. // HEY YOU! DON'T TOUCH THIS VARIABLE!
  241. //
  242. // It is replaced with the proper version at build time via a babel plugin in
  243. // the rollup config.
  244. //
  245. // Export a global property onto the window for React Router detection by the
  246. // Core Web Vitals Technology Report. This way they can configure the `wappalyzer`
  247. // to detect and properly classify live websites as being built with React Router:
  248. // https://github.com/HTTPArchive/wappalyzer/blob/main/src/technologies/r.json
  249. const REACT_ROUTER_VERSION = "6";
  250. try {
  251. window.__reactRouterVersion = REACT_ROUTER_VERSION;
  252. } catch (e) {
  253. // no-op
  254. }
  255. ////////////////////////////////////////////////////////////////////////////////
  256. //#region Routers
  257. ////////////////////////////////////////////////////////////////////////////////
  258. function createBrowserRouter(routes, opts) {
  259. return router.createRouter({
  260. basename: opts == null ? void 0 : opts.basename,
  261. future: _extends({}, opts == null ? void 0 : opts.future, {
  262. v7_prependBasename: true
  263. }),
  264. history: router.createBrowserHistory({
  265. window: opts == null ? void 0 : opts.window
  266. }),
  267. hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
  268. routes,
  269. mapRouteProperties: reactRouter.UNSAFE_mapRouteProperties,
  270. dataStrategy: opts == null ? void 0 : opts.dataStrategy,
  271. patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
  272. window: opts == null ? void 0 : opts.window
  273. }).initialize();
  274. }
  275. function createHashRouter(routes, opts) {
  276. return router.createRouter({
  277. basename: opts == null ? void 0 : opts.basename,
  278. future: _extends({}, opts == null ? void 0 : opts.future, {
  279. v7_prependBasename: true
  280. }),
  281. history: router.createHashHistory({
  282. window: opts == null ? void 0 : opts.window
  283. }),
  284. hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
  285. routes,
  286. mapRouteProperties: reactRouter.UNSAFE_mapRouteProperties,
  287. dataStrategy: opts == null ? void 0 : opts.dataStrategy,
  288. patchRoutesOnNavigation: opts == null ? void 0 : opts.patchRoutesOnNavigation,
  289. window: opts == null ? void 0 : opts.window
  290. }).initialize();
  291. }
  292. function parseHydrationData() {
  293. var _window;
  294. let state = (_window = window) == null ? void 0 : _window.__staticRouterHydrationData;
  295. if (state && state.errors) {
  296. state = _extends({}, state, {
  297. errors: deserializeErrors(state.errors)
  298. });
  299. }
  300. return state;
  301. }
  302. function deserializeErrors(errors) {
  303. if (!errors) return null;
  304. let entries = Object.entries(errors);
  305. let serialized = {};
  306. for (let [key, val] of entries) {
  307. // Hey you! If you change this, please change the corresponding logic in
  308. // serializeErrors in react-router-dom/server.tsx :)
  309. if (val && val.__type === "RouteErrorResponse") {
  310. serialized[key] = new router.UNSAFE_ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
  311. } else if (val && val.__type === "Error") {
  312. // Attempt to reconstruct the right type of Error (i.e., ReferenceError)
  313. if (val.__subType) {
  314. let ErrorConstructor = window[val.__subType];
  315. if (typeof ErrorConstructor === "function") {
  316. try {
  317. // @ts-expect-error
  318. let error = new ErrorConstructor(val.message);
  319. // Wipe away the client-side stack trace. Nothing to fill it in with
  320. // because we don't serialize SSR stack traces for security reasons
  321. error.stack = "";
  322. serialized[key] = error;
  323. } catch (e) {
  324. // no-op - fall through and create a normal Error
  325. }
  326. }
  327. }
  328. if (serialized[key] == null) {
  329. let error = new Error(val.message);
  330. // Wipe away the client-side stack trace. Nothing to fill it in with
  331. // because we don't serialize SSR stack traces for security reasons
  332. error.stack = "";
  333. serialized[key] = error;
  334. }
  335. } else {
  336. serialized[key] = val;
  337. }
  338. }
  339. return serialized;
  340. }
  341. //#endregion
  342. ////////////////////////////////////////////////////////////////////////////////
  343. //#region Contexts
  344. ////////////////////////////////////////////////////////////////////////////////
  345. const ViewTransitionContext = /*#__PURE__*/React__namespace.createContext({
  346. isTransitioning: false
  347. });
  348. {
  349. ViewTransitionContext.displayName = "ViewTransition";
  350. }
  351. // TODO: (v7) Change the useFetcher data from `any` to `unknown`
  352. const FetchersContext = /*#__PURE__*/React__namespace.createContext(new Map());
  353. {
  354. FetchersContext.displayName = "Fetchers";
  355. }
  356. //#endregion
  357. ////////////////////////////////////////////////////////////////////////////////
  358. //#region Components
  359. ////////////////////////////////////////////////////////////////////////////////
  360. /**
  361. Webpack + React 17 fails to compile on any of the following because webpack
  362. complains that `startTransition` doesn't exist in `React`:
  363. * import { startTransition } from "react"
  364. * import * as React from from "react";
  365. "startTransition" in React ? React.startTransition(() => setState()) : setState()
  366. * import * as React from from "react";
  367. "startTransition" in React ? React["startTransition"](() => setState()) : setState()
  368. Moving it to a constant such as the following solves the Webpack/React 17 issue:
  369. * import * as React from from "react";
  370. const START_TRANSITION = "startTransition";
  371. START_TRANSITION in React ? React[START_TRANSITION](() => setState()) : setState()
  372. However, that introduces webpack/terser minification issues in production builds
  373. in React 18 where minification/obfuscation ends up removing the call of
  374. React.startTransition entirely from the first half of the ternary. Grabbing
  375. this exported reference once up front resolves that issue.
  376. See https://github.com/remix-run/react-router/issues/10579
  377. */
  378. const START_TRANSITION = "startTransition";
  379. const startTransitionImpl = React__namespace[START_TRANSITION];
  380. const FLUSH_SYNC = "flushSync";
  381. const flushSyncImpl = ReactDOM__namespace[FLUSH_SYNC];
  382. const USE_ID = "useId";
  383. const useIdImpl = React__namespace[USE_ID];
  384. function startTransitionSafe(cb) {
  385. if (startTransitionImpl) {
  386. startTransitionImpl(cb);
  387. } else {
  388. cb();
  389. }
  390. }
  391. function flushSyncSafe(cb) {
  392. if (flushSyncImpl) {
  393. flushSyncImpl(cb);
  394. } else {
  395. cb();
  396. }
  397. }
  398. class Deferred {
  399. // @ts-expect-error - no initializer
  400. // @ts-expect-error - no initializer
  401. constructor() {
  402. this.status = "pending";
  403. this.promise = new Promise((resolve, reject) => {
  404. this.resolve = value => {
  405. if (this.status === "pending") {
  406. this.status = "resolved";
  407. resolve(value);
  408. }
  409. };
  410. this.reject = reason => {
  411. if (this.status === "pending") {
  412. this.status = "rejected";
  413. reject(reason);
  414. }
  415. };
  416. });
  417. }
  418. }
  419. /**
  420. * Given a Remix Router instance, render the appropriate UI
  421. */
  422. function RouterProvider(_ref) {
  423. let {
  424. fallbackElement,
  425. router: router$1,
  426. future
  427. } = _ref;
  428. let [state, setStateImpl] = React__namespace.useState(router$1.state);
  429. let [pendingState, setPendingState] = React__namespace.useState();
  430. let [vtContext, setVtContext] = React__namespace.useState({
  431. isTransitioning: false
  432. });
  433. let [renderDfd, setRenderDfd] = React__namespace.useState();
  434. let [transition, setTransition] = React__namespace.useState();
  435. let [interruption, setInterruption] = React__namespace.useState();
  436. let fetcherData = React__namespace.useRef(new Map());
  437. let {
  438. v7_startTransition
  439. } = future || {};
  440. let optInStartTransition = React__namespace.useCallback(cb => {
  441. if (v7_startTransition) {
  442. startTransitionSafe(cb);
  443. } else {
  444. cb();
  445. }
  446. }, [v7_startTransition]);
  447. let setState = React__namespace.useCallback((newState, _ref2) => {
  448. let {
  449. deletedFetchers,
  450. flushSync: flushSync,
  451. viewTransitionOpts: viewTransitionOpts
  452. } = _ref2;
  453. newState.fetchers.forEach((fetcher, key) => {
  454. if (fetcher.data !== undefined) {
  455. fetcherData.current.set(key, fetcher.data);
  456. }
  457. });
  458. deletedFetchers.forEach(key => fetcherData.current.delete(key));
  459. let isViewTransitionUnavailable = router$1.window == null || router$1.window.document == null || typeof router$1.window.document.startViewTransition !== "function";
  460. // If this isn't a view transition or it's not available in this browser,
  461. // just update and be done with it
  462. if (!viewTransitionOpts || isViewTransitionUnavailable) {
  463. if (flushSync) {
  464. flushSyncSafe(() => setStateImpl(newState));
  465. } else {
  466. optInStartTransition(() => setStateImpl(newState));
  467. }
  468. return;
  469. }
  470. // flushSync + startViewTransition
  471. if (flushSync) {
  472. // Flush through the context to mark DOM elements as transition=ing
  473. flushSyncSafe(() => {
  474. // Cancel any pending transitions
  475. if (transition) {
  476. renderDfd && renderDfd.resolve();
  477. transition.skipTransition();
  478. }
  479. setVtContext({
  480. isTransitioning: true,
  481. flushSync: true,
  482. currentLocation: viewTransitionOpts.currentLocation,
  483. nextLocation: viewTransitionOpts.nextLocation
  484. });
  485. });
  486. // Update the DOM
  487. let t = router$1.window.document.startViewTransition(() => {
  488. flushSyncSafe(() => setStateImpl(newState));
  489. });
  490. // Clean up after the animation completes
  491. t.finished.finally(() => {
  492. flushSyncSafe(() => {
  493. setRenderDfd(undefined);
  494. setTransition(undefined);
  495. setPendingState(undefined);
  496. setVtContext({
  497. isTransitioning: false
  498. });
  499. });
  500. });
  501. flushSyncSafe(() => setTransition(t));
  502. return;
  503. }
  504. // startTransition + startViewTransition
  505. if (transition) {
  506. // Interrupting an in-progress transition, cancel and let everything flush
  507. // out, and then kick off a new transition from the interruption state
  508. renderDfd && renderDfd.resolve();
  509. transition.skipTransition();
  510. setInterruption({
  511. state: newState,
  512. currentLocation: viewTransitionOpts.currentLocation,
  513. nextLocation: viewTransitionOpts.nextLocation
  514. });
  515. } else {
  516. // Completed navigation update with opted-in view transitions, let 'er rip
  517. setPendingState(newState);
  518. setVtContext({
  519. isTransitioning: true,
  520. flushSync: false,
  521. currentLocation: viewTransitionOpts.currentLocation,
  522. nextLocation: viewTransitionOpts.nextLocation
  523. });
  524. }
  525. }, [router$1.window, transition, renderDfd, fetcherData, optInStartTransition]);
  526. // Need to use a layout effect here so we are subscribed early enough to
  527. // pick up on any render-driven redirects/navigations (useEffect/<Navigate>)
  528. React__namespace.useLayoutEffect(() => router$1.subscribe(setState), [router$1, setState]);
  529. // When we start a view transition, create a Deferred we can use for the
  530. // eventual "completed" render
  531. React__namespace.useEffect(() => {
  532. if (vtContext.isTransitioning && !vtContext.flushSync) {
  533. setRenderDfd(new Deferred());
  534. }
  535. }, [vtContext]);
  536. // Once the deferred is created, kick off startViewTransition() to update the
  537. // DOM and then wait on the Deferred to resolve (indicating the DOM update has
  538. // happened)
  539. React__namespace.useEffect(() => {
  540. if (renderDfd && pendingState && router$1.window) {
  541. let newState = pendingState;
  542. let renderPromise = renderDfd.promise;
  543. let transition = router$1.window.document.startViewTransition(async () => {
  544. optInStartTransition(() => setStateImpl(newState));
  545. await renderPromise;
  546. });
  547. transition.finished.finally(() => {
  548. setRenderDfd(undefined);
  549. setTransition(undefined);
  550. setPendingState(undefined);
  551. setVtContext({
  552. isTransitioning: false
  553. });
  554. });
  555. setTransition(transition);
  556. }
  557. }, [optInStartTransition, pendingState, renderDfd, router$1.window]);
  558. // When the new location finally renders and is committed to the DOM, this
  559. // effect will run to resolve the transition
  560. React__namespace.useEffect(() => {
  561. if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
  562. renderDfd.resolve();
  563. }
  564. }, [renderDfd, transition, state.location, pendingState]);
  565. // If we get interrupted with a new navigation during a transition, we skip
  566. // the active transition, let it cleanup, then kick it off again here
  567. React__namespace.useEffect(() => {
  568. if (!vtContext.isTransitioning && interruption) {
  569. setPendingState(interruption.state);
  570. setVtContext({
  571. isTransitioning: true,
  572. flushSync: false,
  573. currentLocation: interruption.currentLocation,
  574. nextLocation: interruption.nextLocation
  575. });
  576. setInterruption(undefined);
  577. }
  578. }, [vtContext.isTransitioning, interruption]);
  579. React__namespace.useEffect(() => {
  580. router.UNSAFE_warning(fallbackElement == null || !router$1.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using " + "`v7_partialHydration`, use a `HydrateFallback` component instead") ;
  581. // Only log this once on initial mount
  582. // eslint-disable-next-line react-hooks/exhaustive-deps
  583. }, []);
  584. let navigator = React__namespace.useMemo(() => {
  585. return {
  586. createHref: router$1.createHref,
  587. encodeLocation: router$1.encodeLocation,
  588. go: n => router$1.navigate(n),
  589. push: (to, state, opts) => router$1.navigate(to, {
  590. state,
  591. preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
  592. }),
  593. replace: (to, state, opts) => router$1.navigate(to, {
  594. replace: true,
  595. state,
  596. preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
  597. })
  598. };
  599. }, [router$1]);
  600. let basename = router$1.basename || "/";
  601. let dataRouterContext = React__namespace.useMemo(() => ({
  602. router: router$1,
  603. navigator,
  604. static: false,
  605. basename
  606. }), [router$1, navigator, basename]);
  607. let routerFuture = React__namespace.useMemo(() => ({
  608. v7_relativeSplatPath: router$1.future.v7_relativeSplatPath
  609. }), [router$1.future.v7_relativeSplatPath]);
  610. React__namespace.useEffect(() => reactRouter.UNSAFE_logV6DeprecationWarnings(future, router$1.future), [future, router$1.future]);
  611. // The fragment and {null} here are important! We need them to keep React 18's
  612. // useId happy when we are server-rendering since we may have a <script> here
  613. // containing the hydrated server-side staticContext (from StaticRouterProvider).
  614. // useId relies on the component tree structure to generate deterministic id's
  615. // so we need to ensure it remains the same on the client even though
  616. // we don't need the <script> tag
  617. return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(reactRouter.UNSAFE_DataRouterContext.Provider, {
  618. value: dataRouterContext
  619. }, /*#__PURE__*/React__namespace.createElement(reactRouter.UNSAFE_DataRouterStateContext.Provider, {
  620. value: state
  621. }, /*#__PURE__*/React__namespace.createElement(FetchersContext.Provider, {
  622. value: fetcherData.current
  623. }, /*#__PURE__*/React__namespace.createElement(ViewTransitionContext.Provider, {
  624. value: vtContext
  625. }, /*#__PURE__*/React__namespace.createElement(reactRouter.Router, {
  626. basename: basename,
  627. location: state.location,
  628. navigationType: state.historyAction,
  629. navigator: navigator,
  630. future: routerFuture
  631. }, state.initialized || router$1.future.v7_partialHydration ? /*#__PURE__*/React__namespace.createElement(MemoizedDataRoutes, {
  632. routes: router$1.routes,
  633. future: router$1.future,
  634. state: state
  635. }) : fallbackElement))))), null);
  636. }
  637. // Memoize to avoid re-renders when updating `ViewTransitionContext`
  638. const MemoizedDataRoutes = /*#__PURE__*/React__namespace.memo(DataRoutes);
  639. function DataRoutes(_ref3) {
  640. let {
  641. routes,
  642. future,
  643. state
  644. } = _ref3;
  645. return reactRouter.UNSAFE_useRoutesImpl(routes, undefined, state, future);
  646. }
  647. /**
  648. * A `<Router>` for use in web browsers. Provides the cleanest URLs.
  649. */
  650. function BrowserRouter(_ref4) {
  651. let {
  652. basename,
  653. children,
  654. future,
  655. window
  656. } = _ref4;
  657. let historyRef = React__namespace.useRef();
  658. if (historyRef.current == null) {
  659. historyRef.current = router.createBrowserHistory({
  660. window,
  661. v5Compat: true
  662. });
  663. }
  664. let history = historyRef.current;
  665. let [state, setStateImpl] = React__namespace.useState({
  666. action: history.action,
  667. location: history.location
  668. });
  669. let {
  670. v7_startTransition
  671. } = future || {};
  672. let setState = React__namespace.useCallback(newState => {
  673. v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
  674. }, [setStateImpl, v7_startTransition]);
  675. React__namespace.useLayoutEffect(() => history.listen(setState), [history, setState]);
  676. React__namespace.useEffect(() => reactRouter.UNSAFE_logV6DeprecationWarnings(future), [future]);
  677. return /*#__PURE__*/React__namespace.createElement(reactRouter.Router, {
  678. basename: basename,
  679. children: children,
  680. location: state.location,
  681. navigationType: state.action,
  682. navigator: history,
  683. future: future
  684. });
  685. }
  686. /**
  687. * A `<Router>` for use in web browsers. Stores the location in the hash
  688. * portion of the URL so it is not sent to the server.
  689. */
  690. function HashRouter(_ref5) {
  691. let {
  692. basename,
  693. children,
  694. future,
  695. window
  696. } = _ref5;
  697. let historyRef = React__namespace.useRef();
  698. if (historyRef.current == null) {
  699. historyRef.current = router.createHashHistory({
  700. window,
  701. v5Compat: true
  702. });
  703. }
  704. let history = historyRef.current;
  705. let [state, setStateImpl] = React__namespace.useState({
  706. action: history.action,
  707. location: history.location
  708. });
  709. let {
  710. v7_startTransition
  711. } = future || {};
  712. let setState = React__namespace.useCallback(newState => {
  713. v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
  714. }, [setStateImpl, v7_startTransition]);
  715. React__namespace.useLayoutEffect(() => history.listen(setState), [history, setState]);
  716. React__namespace.useEffect(() => reactRouter.UNSAFE_logV6DeprecationWarnings(future), [future]);
  717. return /*#__PURE__*/React__namespace.createElement(reactRouter.Router, {
  718. basename: basename,
  719. children: children,
  720. location: state.location,
  721. navigationType: state.action,
  722. navigator: history,
  723. future: future
  724. });
  725. }
  726. /**
  727. * A `<Router>` that accepts a pre-instantiated history object. It's important
  728. * to note that using your own history object is highly discouraged and may add
  729. * two versions of the history library to your bundles unless you use the same
  730. * version of the history library that React Router uses internally.
  731. */
  732. function HistoryRouter(_ref6) {
  733. let {
  734. basename,
  735. children,
  736. future,
  737. history
  738. } = _ref6;
  739. let [state, setStateImpl] = React__namespace.useState({
  740. action: history.action,
  741. location: history.location
  742. });
  743. let {
  744. v7_startTransition
  745. } = future || {};
  746. let setState = React__namespace.useCallback(newState => {
  747. v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
  748. }, [setStateImpl, v7_startTransition]);
  749. React__namespace.useLayoutEffect(() => history.listen(setState), [history, setState]);
  750. React__namespace.useEffect(() => reactRouter.UNSAFE_logV6DeprecationWarnings(future), [future]);
  751. return /*#__PURE__*/React__namespace.createElement(reactRouter.Router, {
  752. basename: basename,
  753. children: children,
  754. location: state.location,
  755. navigationType: state.action,
  756. navigator: history,
  757. future: future
  758. });
  759. }
  760. {
  761. HistoryRouter.displayName = "unstable_HistoryRouter";
  762. }
  763. const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
  764. const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
  765. /**
  766. * The public API for rendering a history-aware `<a>`.
  767. */
  768. const Link = /*#__PURE__*/React__namespace.forwardRef(function LinkWithRef(_ref7, ref) {
  769. let {
  770. onClick,
  771. relative,
  772. reloadDocument,
  773. replace,
  774. state,
  775. target,
  776. to,
  777. preventScrollReset,
  778. viewTransition
  779. } = _ref7,
  780. rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
  781. let {
  782. basename
  783. } = React__namespace.useContext(reactRouter.UNSAFE_NavigationContext);
  784. // Rendered into <a href> for absolute URLs
  785. let absoluteHref;
  786. let isExternal = false;
  787. if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) {
  788. // Render the absolute href server- and client-side
  789. absoluteHref = to;
  790. // Only check for external origins client-side
  791. if (isBrowser) {
  792. try {
  793. let currentUrl = new URL(window.location.href);
  794. let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
  795. let path = router.stripBasename(targetUrl.pathname, basename);
  796. if (targetUrl.origin === currentUrl.origin && path != null) {
  797. // Strip the protocol/origin/basename for same-origin absolute URLs
  798. to = path + targetUrl.search + targetUrl.hash;
  799. } else {
  800. isExternal = true;
  801. }
  802. } catch (e) {
  803. // We can't do external URL detection without a valid URL
  804. router.UNSAFE_warning(false, "<Link to=\"" + to + "\"> contains an invalid URL which will probably break " + "when clicked - please update to a valid URL path.") ;
  805. }
  806. }
  807. }
  808. // Rendered into <a href> for relative URLs
  809. let href = reactRouter.useHref(to, {
  810. relative
  811. });
  812. let internalOnClick = useLinkClickHandler(to, {
  813. replace,
  814. state,
  815. target,
  816. preventScrollReset,
  817. relative,
  818. viewTransition
  819. });
  820. function handleClick(event) {
  821. if (onClick) onClick(event);
  822. if (!event.defaultPrevented) {
  823. internalOnClick(event);
  824. }
  825. }
  826. return (
  827. /*#__PURE__*/
  828. // eslint-disable-next-line jsx-a11y/anchor-has-content
  829. React__namespace.createElement("a", _extends({}, rest, {
  830. href: absoluteHref || href,
  831. onClick: isExternal || reloadDocument ? onClick : handleClick,
  832. ref: ref,
  833. target: target
  834. }))
  835. );
  836. });
  837. {
  838. Link.displayName = "Link";
  839. }
  840. /**
  841. * A `<Link>` wrapper that knows if it's "active" or not.
  842. */
  843. const NavLink = /*#__PURE__*/React__namespace.forwardRef(function NavLinkWithRef(_ref8, ref) {
  844. let {
  845. "aria-current": ariaCurrentProp = "page",
  846. caseSensitive = false,
  847. className: classNameProp = "",
  848. end = false,
  849. style: styleProp,
  850. to,
  851. viewTransition,
  852. children
  853. } = _ref8,
  854. rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
  855. let path = reactRouter.useResolvedPath(to, {
  856. relative: rest.relative
  857. });
  858. let location = reactRouter.useLocation();
  859. let routerState = React__namespace.useContext(reactRouter.UNSAFE_DataRouterStateContext);
  860. let {
  861. navigator,
  862. basename
  863. } = React__namespace.useContext(reactRouter.UNSAFE_NavigationContext);
  864. let isTransitioning = routerState != null &&
  865. // Conditional usage is OK here because the usage of a data router is static
  866. // eslint-disable-next-line react-hooks/rules-of-hooks
  867. useViewTransitionState(path) && viewTransition === true;
  868. let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
  869. let locationPathname = location.pathname;
  870. let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
  871. if (!caseSensitive) {
  872. locationPathname = locationPathname.toLowerCase();
  873. nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
  874. toPathname = toPathname.toLowerCase();
  875. }
  876. if (nextLocationPathname && basename) {
  877. nextLocationPathname = router.stripBasename(nextLocationPathname, basename) || nextLocationPathname;
  878. }
  879. // If the `to` has a trailing slash, look at that exact spot. Otherwise,
  880. // we're looking for a slash _after_ what's in `to`. For example:
  881. //
  882. // <NavLink to="/users"> and <NavLink to="/users/">
  883. // both want to look for a / at index 6 to match URL `/users/matt`
  884. const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
  885. let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
  886. let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
  887. let renderProps = {
  888. isActive,
  889. isPending,
  890. isTransitioning
  891. };
  892. let ariaCurrent = isActive ? ariaCurrentProp : undefined;
  893. let className;
  894. if (typeof classNameProp === "function") {
  895. className = classNameProp(renderProps);
  896. } else {
  897. // If the className prop is not a function, we use a default `active`
  898. // class for <NavLink />s that are active. In v5 `active` was the default
  899. // value for `activeClassName`, but we are removing that API and can still
  900. // use the old default behavior for a cleaner upgrade path and keep the
  901. // simple styling rules working as they currently do.
  902. className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
  903. }
  904. let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
  905. return /*#__PURE__*/React__namespace.createElement(Link, _extends({}, rest, {
  906. "aria-current": ariaCurrent,
  907. className: className,
  908. ref: ref,
  909. style: style,
  910. to: to,
  911. viewTransition: viewTransition
  912. }), typeof children === "function" ? children(renderProps) : children);
  913. });
  914. {
  915. NavLink.displayName = "NavLink";
  916. }
  917. /**
  918. * Form props shared by navigations and fetchers
  919. */
  920. /**
  921. * Form props available to fetchers
  922. */
  923. /**
  924. * Form props available to navigations
  925. */
  926. /**
  927. * A `@remix-run/router`-aware `<form>`. It behaves like a normal form except
  928. * that the interaction with the server is with `fetch` instead of new document
  929. * requests, allowing components to add nicer UX to the page as the form is
  930. * submitted and returns with data.
  931. */
  932. const Form = /*#__PURE__*/React__namespace.forwardRef((_ref9, forwardedRef) => {
  933. let {
  934. fetcherKey,
  935. navigate,
  936. reloadDocument,
  937. replace,
  938. state,
  939. method = defaultMethod,
  940. action,
  941. onSubmit,
  942. relative,
  943. preventScrollReset,
  944. viewTransition
  945. } = _ref9,
  946. props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
  947. let submit = useSubmit();
  948. let formAction = useFormAction(action, {
  949. relative
  950. });
  951. let formMethod = method.toLowerCase() === "get" ? "get" : "post";
  952. let submitHandler = event => {
  953. onSubmit && onSubmit(event);
  954. if (event.defaultPrevented) return;
  955. event.preventDefault();
  956. let submitter = event.nativeEvent.submitter;
  957. let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
  958. submit(submitter || event.currentTarget, {
  959. fetcherKey,
  960. method: submitMethod,
  961. navigate,
  962. replace,
  963. state,
  964. relative,
  965. preventScrollReset,
  966. viewTransition
  967. });
  968. };
  969. return /*#__PURE__*/React__namespace.createElement("form", _extends({
  970. ref: forwardedRef,
  971. method: formMethod,
  972. action: formAction,
  973. onSubmit: reloadDocument ? onSubmit : submitHandler
  974. }, props));
  975. });
  976. {
  977. Form.displayName = "Form";
  978. }
  979. /**
  980. * This component will emulate the browser's scroll restoration on location
  981. * changes.
  982. */
  983. function ScrollRestoration(_ref10) {
  984. let {
  985. getKey,
  986. storageKey
  987. } = _ref10;
  988. useScrollRestoration({
  989. getKey,
  990. storageKey
  991. });
  992. return null;
  993. }
  994. {
  995. ScrollRestoration.displayName = "ScrollRestoration";
  996. }
  997. //#endregion
  998. ////////////////////////////////////////////////////////////////////////////////
  999. //#region Hooks
  1000. ////////////////////////////////////////////////////////////////////////////////
  1001. var DataRouterHook = /*#__PURE__*/function (DataRouterHook) {
  1002. DataRouterHook["UseScrollRestoration"] = "useScrollRestoration";
  1003. DataRouterHook["UseSubmit"] = "useSubmit";
  1004. DataRouterHook["UseSubmitFetcher"] = "useSubmitFetcher";
  1005. DataRouterHook["UseFetcher"] = "useFetcher";
  1006. DataRouterHook["useViewTransitionState"] = "useViewTransitionState";
  1007. return DataRouterHook;
  1008. }(DataRouterHook || {});
  1009. var DataRouterStateHook = /*#__PURE__*/function (DataRouterStateHook) {
  1010. DataRouterStateHook["UseFetcher"] = "useFetcher";
  1011. DataRouterStateHook["UseFetchers"] = "useFetchers";
  1012. DataRouterStateHook["UseScrollRestoration"] = "useScrollRestoration";
  1013. return DataRouterStateHook;
  1014. }(DataRouterStateHook || {}); // Internal hooks
  1015. function getDataRouterConsoleError(hookName) {
  1016. return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
  1017. }
  1018. function useDataRouterContext(hookName) {
  1019. let ctx = React__namespace.useContext(reactRouter.UNSAFE_DataRouterContext);
  1020. !ctx ? router.UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
  1021. return ctx;
  1022. }
  1023. function useDataRouterState(hookName) {
  1024. let state = React__namespace.useContext(reactRouter.UNSAFE_DataRouterStateContext);
  1025. !state ? router.UNSAFE_invariant(false, getDataRouterConsoleError(hookName)) : void 0;
  1026. return state;
  1027. }
  1028. // External hooks
  1029. /**
  1030. * Handles the click behavior for router `<Link>` components. This is useful if
  1031. * you need to create custom `<Link>` components with the same click behavior we
  1032. * use in our exported `<Link>`.
  1033. */
  1034. function useLinkClickHandler(to, _temp) {
  1035. let {
  1036. target,
  1037. replace: replaceProp,
  1038. state,
  1039. preventScrollReset,
  1040. relative,
  1041. viewTransition
  1042. } = _temp === void 0 ? {} : _temp;
  1043. let navigate = reactRouter.useNavigate();
  1044. let location = reactRouter.useLocation();
  1045. let path = reactRouter.useResolvedPath(to, {
  1046. relative
  1047. });
  1048. return React__namespace.useCallback(event => {
  1049. if (shouldProcessLinkClick(event, target)) {
  1050. event.preventDefault();
  1051. // If the URL hasn't changed, a regular <a> will do a replace instead of
  1052. // a push, so do the same here unless the replace prop is explicitly set
  1053. let replace = replaceProp !== undefined ? replaceProp : reactRouter.createPath(location) === reactRouter.createPath(path);
  1054. navigate(to, {
  1055. replace,
  1056. state,
  1057. preventScrollReset,
  1058. relative,
  1059. viewTransition
  1060. });
  1061. }
  1062. }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
  1063. }
  1064. /**
  1065. * A convenient wrapper for reading and writing search parameters via the
  1066. * URLSearchParams interface.
  1067. */
  1068. function useSearchParams(defaultInit) {
  1069. router.UNSAFE_warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not " + "support the URLSearchParams API. If you need to support Internet " + "Explorer 11, we recommend you load a polyfill such as " + "https://github.com/ungap/url-search-params.") ;
  1070. let defaultSearchParamsRef = React__namespace.useRef(createSearchParams(defaultInit));
  1071. let hasSetSearchParamsRef = React__namespace.useRef(false);
  1072. let location = reactRouter.useLocation();
  1073. let searchParams = React__namespace.useMemo(() =>
  1074. // Only merge in the defaults if we haven't yet called setSearchParams.
  1075. // Once we call that we want those to take precedence, otherwise you can't
  1076. // remove a param with setSearchParams({}) if it has an initial value
  1077. getSearchParamsForLocation(location.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current), [location.search]);
  1078. let navigate = reactRouter.useNavigate();
  1079. let setSearchParams = React__namespace.useCallback((nextInit, navigateOptions) => {
  1080. const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
  1081. hasSetSearchParamsRef.current = true;
  1082. navigate("?" + newSearchParams, navigateOptions);
  1083. }, [navigate, searchParams]);
  1084. return [searchParams, setSearchParams];
  1085. }
  1086. /**
  1087. * Submits a HTML `<form>` to the server without reloading the page.
  1088. */
  1089. /**
  1090. * Submits a fetcher `<form>` to the server without reloading the page.
  1091. */
  1092. function validateClientSideSubmission() {
  1093. if (typeof document === "undefined") {
  1094. throw new Error("You are calling submit during the server render. " + "Try calling submit within a `useEffect` or callback instead.");
  1095. }
  1096. }
  1097. let fetcherId = 0;
  1098. let getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
  1099. /**
  1100. * Returns a function that may be used to programmatically submit a form (or
  1101. * some arbitrary data) to the server.
  1102. */
  1103. function useSubmit() {
  1104. let {
  1105. router
  1106. } = useDataRouterContext(DataRouterHook.UseSubmit);
  1107. let {
  1108. basename
  1109. } = React__namespace.useContext(reactRouter.UNSAFE_NavigationContext);
  1110. let currentRouteId = reactRouter.UNSAFE_useRouteId();
  1111. return React__namespace.useCallback(function (target, options) {
  1112. if (options === void 0) {
  1113. options = {};
  1114. }
  1115. validateClientSideSubmission();
  1116. let {
  1117. action,
  1118. method,
  1119. encType,
  1120. formData,
  1121. body
  1122. } = getFormSubmissionInfo(target, basename);
  1123. if (options.navigate === false) {
  1124. let key = options.fetcherKey || getUniqueFetcherId();
  1125. router.fetch(key, currentRouteId, options.action || action, {
  1126. preventScrollReset: options.preventScrollReset,
  1127. formData,
  1128. body,
  1129. formMethod: options.method || method,
  1130. formEncType: options.encType || encType,
  1131. flushSync: options.flushSync
  1132. });
  1133. } else {
  1134. router.navigate(options.action || action, {
  1135. preventScrollReset: options.preventScrollReset,
  1136. formData,
  1137. body,
  1138. formMethod: options.method || method,
  1139. formEncType: options.encType || encType,
  1140. replace: options.replace,
  1141. state: options.state,
  1142. fromRouteId: currentRouteId,
  1143. flushSync: options.flushSync,
  1144. viewTransition: options.viewTransition
  1145. });
  1146. }
  1147. }, [router, basename, currentRouteId]);
  1148. }
  1149. // v7: Eventually we should deprecate this entirely in favor of using the
  1150. // router method directly?
  1151. function useFormAction(action, _temp2) {
  1152. let {
  1153. relative
  1154. } = _temp2 === void 0 ? {} : _temp2;
  1155. let {
  1156. basename
  1157. } = React__namespace.useContext(reactRouter.UNSAFE_NavigationContext);
  1158. let routeContext = React__namespace.useContext(reactRouter.UNSAFE_RouteContext);
  1159. !routeContext ? router.UNSAFE_invariant(false, "useFormAction must be used inside a RouteContext") : void 0;
  1160. let [match] = routeContext.matches.slice(-1);
  1161. // Shallow clone path so we can modify it below, otherwise we modify the
  1162. // object referenced by useMemo inside useResolvedPath
  1163. let path = _extends({}, reactRouter.useResolvedPath(action ? action : ".", {
  1164. relative
  1165. }));
  1166. // If no action was specified, browsers will persist current search params
  1167. // when determining the path, so match that behavior
  1168. // https://github.com/remix-run/remix/issues/927
  1169. let location = reactRouter.useLocation();
  1170. if (action == null) {
  1171. // Safe to write to this directly here since if action was undefined, we
  1172. // would have called useResolvedPath(".") which will never include a search
  1173. path.search = location.search;
  1174. // When grabbing search params from the URL, remove any included ?index param
  1175. // since it might not apply to our contextual route. We add it back based
  1176. // on match.route.index below
  1177. let params = new URLSearchParams(path.search);
  1178. let indexValues = params.getAll("index");
  1179. let hasNakedIndexParam = indexValues.some(v => v === "");
  1180. if (hasNakedIndexParam) {
  1181. params.delete("index");
  1182. indexValues.filter(v => v).forEach(v => params.append("index", v));
  1183. let qs = params.toString();
  1184. path.search = qs ? "?" + qs : "";
  1185. }
  1186. }
  1187. if ((!action || action === ".") && match.route.index) {
  1188. path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
  1189. }
  1190. // If we're operating within a basename, prepend it to the pathname prior
  1191. // to creating the form action. If this is a root navigation, then just use
  1192. // the raw basename which allows the basename to have full control over the
  1193. // presence of a trailing slash on root actions
  1194. if (basename !== "/") {
  1195. path.pathname = path.pathname === "/" ? basename : router.joinPaths([basename, path.pathname]);
  1196. }
  1197. return reactRouter.createPath(path);
  1198. }
  1199. // TODO: (v7) Change the useFetcher generic default from `any` to `unknown`
  1200. /**
  1201. * Interacts with route loaders and actions without causing a navigation. Great
  1202. * for any interaction that stays on the same page.
  1203. */
  1204. function useFetcher(_temp3) {
  1205. var _route$matches;
  1206. let {
  1207. key
  1208. } = _temp3 === void 0 ? {} : _temp3;
  1209. let {
  1210. router: router$1
  1211. } = useDataRouterContext(DataRouterHook.UseFetcher);
  1212. let state = useDataRouterState(DataRouterStateHook.UseFetcher);
  1213. let fetcherData = React__namespace.useContext(FetchersContext);
  1214. let route = React__namespace.useContext(reactRouter.UNSAFE_RouteContext);
  1215. let routeId = (_route$matches = route.matches[route.matches.length - 1]) == null ? void 0 : _route$matches.route.id;
  1216. !fetcherData ? router.UNSAFE_invariant(false, "useFetcher must be used inside a FetchersContext") : void 0;
  1217. !route ? router.UNSAFE_invariant(false, "useFetcher must be used inside a RouteContext") : void 0;
  1218. !(routeId != null) ? router.UNSAFE_invariant(false, "useFetcher can only be used on routes that contain a unique \"id\"") : void 0;
  1219. // Fetcher key handling
  1220. // OK to call conditionally to feature detect `useId`
  1221. // eslint-disable-next-line react-hooks/rules-of-hooks
  1222. let defaultKey = useIdImpl ? useIdImpl() : "";
  1223. let [fetcherKey, setFetcherKey] = React__namespace.useState(key || defaultKey);
  1224. if (key && key !== fetcherKey) {
  1225. setFetcherKey(key);
  1226. } else if (!fetcherKey) {
  1227. // We will only fall through here when `useId` is not available
  1228. setFetcherKey(getUniqueFetcherId());
  1229. }
  1230. // Registration/cleanup
  1231. React__namespace.useEffect(() => {
  1232. router$1.getFetcher(fetcherKey);
  1233. return () => {
  1234. // Tell the router we've unmounted - if v7_fetcherPersist is enabled this
  1235. // will not delete immediately but instead queue up a delete after the
  1236. // fetcher returns to an `idle` state
  1237. router$1.deleteFetcher(fetcherKey);
  1238. };
  1239. }, [router$1, fetcherKey]);
  1240. // Fetcher additions
  1241. let load = React__namespace.useCallback((href, opts) => {
  1242. !routeId ? router.UNSAFE_invariant(false, "No routeId available for fetcher.load()") : void 0;
  1243. router$1.fetch(fetcherKey, routeId, href, opts);
  1244. }, [fetcherKey, routeId, router$1]);
  1245. let submitImpl = useSubmit();
  1246. let submit = React__namespace.useCallback((target, opts) => {
  1247. submitImpl(target, _extends({}, opts, {
  1248. navigate: false,
  1249. fetcherKey
  1250. }));
  1251. }, [fetcherKey, submitImpl]);
  1252. let FetcherForm = React__namespace.useMemo(() => {
  1253. let FetcherForm = /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
  1254. return /*#__PURE__*/React__namespace.createElement(Form, _extends({}, props, {
  1255. navigate: false,
  1256. fetcherKey: fetcherKey,
  1257. ref: ref
  1258. }));
  1259. });
  1260. {
  1261. FetcherForm.displayName = "fetcher.Form";
  1262. }
  1263. return FetcherForm;
  1264. }, [fetcherKey]);
  1265. // Exposed FetcherWithComponents
  1266. let fetcher = state.fetchers.get(fetcherKey) || router.IDLE_FETCHER;
  1267. let data = fetcherData.get(fetcherKey);
  1268. let fetcherWithComponents = React__namespace.useMemo(() => _extends({
  1269. Form: FetcherForm,
  1270. submit,
  1271. load
  1272. }, fetcher, {
  1273. data
  1274. }), [FetcherForm, submit, load, fetcher, data]);
  1275. return fetcherWithComponents;
  1276. }
  1277. /**
  1278. * Provides all fetchers currently on the page. Useful for layouts and parent
  1279. * routes that need to provide pending/optimistic UI regarding the fetch.
  1280. */
  1281. function useFetchers() {
  1282. let state = useDataRouterState(DataRouterStateHook.UseFetchers);
  1283. return Array.from(state.fetchers.entries()).map(_ref11 => {
  1284. let [key, fetcher] = _ref11;
  1285. return _extends({}, fetcher, {
  1286. key
  1287. });
  1288. });
  1289. }
  1290. const SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
  1291. let savedScrollPositions = {};
  1292. /**
  1293. * When rendered inside a RouterProvider, will restore scroll positions on navigations
  1294. */
  1295. function useScrollRestoration(_temp4) {
  1296. let {
  1297. getKey,
  1298. storageKey
  1299. } = _temp4 === void 0 ? {} : _temp4;
  1300. let {
  1301. router: router$1
  1302. } = useDataRouterContext(DataRouterHook.UseScrollRestoration);
  1303. let {
  1304. restoreScrollPosition,
  1305. preventScrollReset
  1306. } = useDataRouterState(DataRouterStateHook.UseScrollRestoration);
  1307. let {
  1308. basename
  1309. } = React__namespace.useContext(reactRouter.UNSAFE_NavigationContext);
  1310. let location = reactRouter.useLocation();
  1311. let matches = reactRouter.useMatches();
  1312. let navigation = reactRouter.useNavigation();
  1313. // Trigger manual scroll restoration while we're active
  1314. React__namespace.useEffect(() => {
  1315. window.history.scrollRestoration = "manual";
  1316. return () => {
  1317. window.history.scrollRestoration = "auto";
  1318. };
  1319. }, []);
  1320. // Save positions on pagehide
  1321. usePageHide(React__namespace.useCallback(() => {
  1322. if (navigation.state === "idle") {
  1323. let key = (getKey ? getKey(location, matches) : null) || location.key;
  1324. savedScrollPositions[key] = window.scrollY;
  1325. }
  1326. try {
  1327. sessionStorage.setItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY, JSON.stringify(savedScrollPositions));
  1328. } catch (error) {
  1329. router.UNSAFE_warning(false, "Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (" + error + ").") ;
  1330. }
  1331. window.history.scrollRestoration = "auto";
  1332. }, [storageKey, getKey, navigation.state, location, matches]));
  1333. // Read in any saved scroll locations
  1334. if (typeof document !== "undefined") {
  1335. // eslint-disable-next-line react-hooks/rules-of-hooks
  1336. React__namespace.useLayoutEffect(() => {
  1337. try {
  1338. let sessionPositions = sessionStorage.getItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY);
  1339. if (sessionPositions) {
  1340. savedScrollPositions = JSON.parse(sessionPositions);
  1341. }
  1342. } catch (e) {
  1343. // no-op, use default empty object
  1344. }
  1345. }, [storageKey]);
  1346. // Enable scroll restoration in the router
  1347. // eslint-disable-next-line react-hooks/rules-of-hooks
  1348. React__namespace.useLayoutEffect(() => {
  1349. let getKeyWithoutBasename = getKey && basename !== "/" ? (location, matches) => getKey( // Strip the basename to match useLocation()
  1350. _extends({}, location, {
  1351. pathname: router.stripBasename(location.pathname, basename) || location.pathname
  1352. }), matches) : getKey;
  1353. let disableScrollRestoration = router$1 == null ? void 0 : router$1.enableScrollRestoration(savedScrollPositions, () => window.scrollY, getKeyWithoutBasename);
  1354. return () => disableScrollRestoration && disableScrollRestoration();
  1355. }, [router$1, basename, getKey]);
  1356. // Restore scrolling when state.restoreScrollPosition changes
  1357. // eslint-disable-next-line react-hooks/rules-of-hooks
  1358. React__namespace.useLayoutEffect(() => {
  1359. // Explicit false means don't do anything (used for submissions)
  1360. if (restoreScrollPosition === false) {
  1361. return;
  1362. }
  1363. // been here before, scroll to it
  1364. if (typeof restoreScrollPosition === "number") {
  1365. window.scrollTo(0, restoreScrollPosition);
  1366. return;
  1367. }
  1368. // try to scroll to the hash
  1369. if (location.hash) {
  1370. let el = document.getElementById(decodeURIComponent(location.hash.slice(1)));
  1371. if (el) {
  1372. el.scrollIntoView();
  1373. return;
  1374. }
  1375. }
  1376. // Don't reset if this navigation opted out
  1377. if (preventScrollReset === true) {
  1378. return;
  1379. }
  1380. // otherwise go to the top on new locations
  1381. window.scrollTo(0, 0);
  1382. }, [location, restoreScrollPosition, preventScrollReset]);
  1383. }
  1384. }
  1385. /**
  1386. * Setup a callback to be fired on the window's `beforeunload` event. This is
  1387. * useful for saving some data to `window.localStorage` just before the page
  1388. * refreshes.
  1389. *
  1390. * Note: The `callback` argument should be a function created with
  1391. * `React.useCallback()`.
  1392. */
  1393. function useBeforeUnload(callback, options) {
  1394. let {
  1395. capture
  1396. } = options || {};
  1397. React__namespace.useEffect(() => {
  1398. let opts = capture != null ? {
  1399. capture
  1400. } : undefined;
  1401. window.addEventListener("beforeunload", callback, opts);
  1402. return () => {
  1403. window.removeEventListener("beforeunload", callback, opts);
  1404. };
  1405. }, [callback, capture]);
  1406. }
  1407. /**
  1408. * Setup a callback to be fired on the window's `pagehide` event. This is
  1409. * useful for saving some data to `window.localStorage` just before the page
  1410. * refreshes. This event is better supported than beforeunload across browsers.
  1411. *
  1412. * Note: The `callback` argument should be a function created with
  1413. * `React.useCallback()`.
  1414. */
  1415. function usePageHide(callback, options) {
  1416. let {
  1417. capture
  1418. } = options || {};
  1419. React__namespace.useEffect(() => {
  1420. let opts = capture != null ? {
  1421. capture
  1422. } : undefined;
  1423. window.addEventListener("pagehide", callback, opts);
  1424. return () => {
  1425. window.removeEventListener("pagehide", callback, opts);
  1426. };
  1427. }, [callback, capture]);
  1428. }
  1429. /**
  1430. * Wrapper around useBlocker to show a window.confirm prompt to users instead
  1431. * of building a custom UI with useBlocker.
  1432. *
  1433. * Warning: This has *a lot of rough edges* and behaves very differently (and
  1434. * very incorrectly in some cases) across browsers if user click addition
  1435. * back/forward navigations while the confirm is open. Use at your own risk.
  1436. */
  1437. function usePrompt(_ref12) {
  1438. let {
  1439. when,
  1440. message
  1441. } = _ref12;
  1442. let blocker = reactRouter.useBlocker(when);
  1443. React__namespace.useEffect(() => {
  1444. if (blocker.state === "blocked") {
  1445. let proceed = window.confirm(message);
  1446. if (proceed) {
  1447. // This timeout is needed to avoid a weird "race" on POP navigations
  1448. // between the `window.history` revert navigation and the result of
  1449. // `window.confirm`
  1450. setTimeout(blocker.proceed, 0);
  1451. } else {
  1452. blocker.reset();
  1453. }
  1454. }
  1455. }, [blocker, message]);
  1456. React__namespace.useEffect(() => {
  1457. if (blocker.state === "blocked" && !when) {
  1458. blocker.reset();
  1459. }
  1460. }, [blocker, when]);
  1461. }
  1462. /**
  1463. * Return a boolean indicating if there is an active view transition to the
  1464. * given href. You can use this value to render CSS classes or viewTransitionName
  1465. * styles onto your elements
  1466. *
  1467. * @param href The destination href
  1468. * @param [opts.relative] Relative routing type ("route" | "path")
  1469. */
  1470. function useViewTransitionState(to, opts) {
  1471. if (opts === void 0) {
  1472. opts = {};
  1473. }
  1474. let vtContext = React__namespace.useContext(ViewTransitionContext);
  1475. !(vtContext != null) ? router.UNSAFE_invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. " + "Did you accidentally import `RouterProvider` from `react-router`?") : void 0;
  1476. let {
  1477. basename
  1478. } = useDataRouterContext(DataRouterHook.useViewTransitionState);
  1479. let path = reactRouter.useResolvedPath(to, {
  1480. relative: opts.relative
  1481. });
  1482. if (!vtContext.isTransitioning) {
  1483. return false;
  1484. }
  1485. let currentPath = router.stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
  1486. let nextPath = router.stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
  1487. // Transition is active if we're going to or coming from the indicated
  1488. // destination. This ensures that other PUSH navigations that reverse
  1489. // an indicated transition apply. I.e., on the list view you have:
  1490. //
  1491. // <NavLink to="/details/1" viewTransition>
  1492. //
  1493. // If you click the breadcrumb back to the list view:
  1494. //
  1495. // <NavLink to="/list" viewTransition>
  1496. //
  1497. // We should apply the transition because it's indicated as active going
  1498. // from /list -> /details/1 and therefore should be active on the reverse
  1499. // (even though this isn't strictly a POP reverse)
  1500. return router.matchPath(path.pathname, nextPath) != null || router.matchPath(path.pathname, currentPath) != null;
  1501. }
  1502. //#endregion
  1503. Object.defineProperty(exports, 'AbortedDeferredError', {
  1504. enumerable: true,
  1505. get: function () { return reactRouter.AbortedDeferredError; }
  1506. });
  1507. Object.defineProperty(exports, 'Await', {
  1508. enumerable: true,
  1509. get: function () { return reactRouter.Await; }
  1510. });
  1511. Object.defineProperty(exports, 'MemoryRouter', {
  1512. enumerable: true,
  1513. get: function () { return reactRouter.MemoryRouter; }
  1514. });
  1515. Object.defineProperty(exports, 'Navigate', {
  1516. enumerable: true,
  1517. get: function () { return reactRouter.Navigate; }
  1518. });
  1519. Object.defineProperty(exports, 'NavigationType', {
  1520. enumerable: true,
  1521. get: function () { return reactRouter.NavigationType; }
  1522. });
  1523. Object.defineProperty(exports, 'Outlet', {
  1524. enumerable: true,
  1525. get: function () { return reactRouter.Outlet; }
  1526. });
  1527. Object.defineProperty(exports, 'Route', {
  1528. enumerable: true,
  1529. get: function () { return reactRouter.Route; }
  1530. });
  1531. Object.defineProperty(exports, 'Router', {
  1532. enumerable: true,
  1533. get: function () { return reactRouter.Router; }
  1534. });
  1535. Object.defineProperty(exports, 'Routes', {
  1536. enumerable: true,
  1537. get: function () { return reactRouter.Routes; }
  1538. });
  1539. Object.defineProperty(exports, 'UNSAFE_DataRouterContext', {
  1540. enumerable: true,
  1541. get: function () { return reactRouter.UNSAFE_DataRouterContext; }
  1542. });
  1543. Object.defineProperty(exports, 'UNSAFE_DataRouterStateContext', {
  1544. enumerable: true,
  1545. get: function () { return reactRouter.UNSAFE_DataRouterStateContext; }
  1546. });
  1547. Object.defineProperty(exports, 'UNSAFE_LocationContext', {
  1548. enumerable: true,
  1549. get: function () { return reactRouter.UNSAFE_LocationContext; }
  1550. });
  1551. Object.defineProperty(exports, 'UNSAFE_NavigationContext', {
  1552. enumerable: true,
  1553. get: function () { return reactRouter.UNSAFE_NavigationContext; }
  1554. });
  1555. Object.defineProperty(exports, 'UNSAFE_RouteContext', {
  1556. enumerable: true,
  1557. get: function () { return reactRouter.UNSAFE_RouteContext; }
  1558. });
  1559. Object.defineProperty(exports, 'UNSAFE_useRouteId', {
  1560. enumerable: true,
  1561. get: function () { return reactRouter.UNSAFE_useRouteId; }
  1562. });
  1563. Object.defineProperty(exports, 'createMemoryRouter', {
  1564. enumerable: true,
  1565. get: function () { return reactRouter.createMemoryRouter; }
  1566. });
  1567. Object.defineProperty(exports, 'createPath', {
  1568. enumerable: true,
  1569. get: function () { return reactRouter.createPath; }
  1570. });
  1571. Object.defineProperty(exports, 'createRoutesFromChildren', {
  1572. enumerable: true,
  1573. get: function () { return reactRouter.createRoutesFromChildren; }
  1574. });
  1575. Object.defineProperty(exports, 'createRoutesFromElements', {
  1576. enumerable: true,
  1577. get: function () { return reactRouter.createRoutesFromElements; }
  1578. });
  1579. Object.defineProperty(exports, 'defer', {
  1580. enumerable: true,
  1581. get: function () { return reactRouter.defer; }
  1582. });
  1583. Object.defineProperty(exports, 'generatePath', {
  1584. enumerable: true,
  1585. get: function () { return reactRouter.generatePath; }
  1586. });
  1587. Object.defineProperty(exports, 'isRouteErrorResponse', {
  1588. enumerable: true,
  1589. get: function () { return reactRouter.isRouteErrorResponse; }
  1590. });
  1591. Object.defineProperty(exports, 'json', {
  1592. enumerable: true,
  1593. get: function () { return reactRouter.json; }
  1594. });
  1595. Object.defineProperty(exports, 'matchPath', {
  1596. enumerable: true,
  1597. get: function () { return reactRouter.matchPath; }
  1598. });
  1599. Object.defineProperty(exports, 'matchRoutes', {
  1600. enumerable: true,
  1601. get: function () { return reactRouter.matchRoutes; }
  1602. });
  1603. Object.defineProperty(exports, 'parsePath', {
  1604. enumerable: true,
  1605. get: function () { return reactRouter.parsePath; }
  1606. });
  1607. Object.defineProperty(exports, 'redirect', {
  1608. enumerable: true,
  1609. get: function () { return reactRouter.redirect; }
  1610. });
  1611. Object.defineProperty(exports, 'redirectDocument', {
  1612. enumerable: true,
  1613. get: function () { return reactRouter.redirectDocument; }
  1614. });
  1615. Object.defineProperty(exports, 'renderMatches', {
  1616. enumerable: true,
  1617. get: function () { return reactRouter.renderMatches; }
  1618. });
  1619. Object.defineProperty(exports, 'replace', {
  1620. enumerable: true,
  1621. get: function () { return reactRouter.replace; }
  1622. });
  1623. Object.defineProperty(exports, 'resolvePath', {
  1624. enumerable: true,
  1625. get: function () { return reactRouter.resolvePath; }
  1626. });
  1627. Object.defineProperty(exports, 'useActionData', {
  1628. enumerable: true,
  1629. get: function () { return reactRouter.useActionData; }
  1630. });
  1631. Object.defineProperty(exports, 'useAsyncError', {
  1632. enumerable: true,
  1633. get: function () { return reactRouter.useAsyncError; }
  1634. });
  1635. Object.defineProperty(exports, 'useAsyncValue', {
  1636. enumerable: true,
  1637. get: function () { return reactRouter.useAsyncValue; }
  1638. });
  1639. Object.defineProperty(exports, 'useBlocker', {
  1640. enumerable: true,
  1641. get: function () { return reactRouter.useBlocker; }
  1642. });
  1643. Object.defineProperty(exports, 'useHref', {
  1644. enumerable: true,
  1645. get: function () { return reactRouter.useHref; }
  1646. });
  1647. Object.defineProperty(exports, 'useInRouterContext', {
  1648. enumerable: true,
  1649. get: function () { return reactRouter.useInRouterContext; }
  1650. });
  1651. Object.defineProperty(exports, 'useLoaderData', {
  1652. enumerable: true,
  1653. get: function () { return reactRouter.useLoaderData; }
  1654. });
  1655. Object.defineProperty(exports, 'useLocation', {
  1656. enumerable: true,
  1657. get: function () { return reactRouter.useLocation; }
  1658. });
  1659. Object.defineProperty(exports, 'useMatch', {
  1660. enumerable: true,
  1661. get: function () { return reactRouter.useMatch; }
  1662. });
  1663. Object.defineProperty(exports, 'useMatches', {
  1664. enumerable: true,
  1665. get: function () { return reactRouter.useMatches; }
  1666. });
  1667. Object.defineProperty(exports, 'useNavigate', {
  1668. enumerable: true,
  1669. get: function () { return reactRouter.useNavigate; }
  1670. });
  1671. Object.defineProperty(exports, 'useNavigation', {
  1672. enumerable: true,
  1673. get: function () { return reactRouter.useNavigation; }
  1674. });
  1675. Object.defineProperty(exports, 'useNavigationType', {
  1676. enumerable: true,
  1677. get: function () { return reactRouter.useNavigationType; }
  1678. });
  1679. Object.defineProperty(exports, 'useOutlet', {
  1680. enumerable: true,
  1681. get: function () { return reactRouter.useOutlet; }
  1682. });
  1683. Object.defineProperty(exports, 'useOutletContext', {
  1684. enumerable: true,
  1685. get: function () { return reactRouter.useOutletContext; }
  1686. });
  1687. Object.defineProperty(exports, 'useParams', {
  1688. enumerable: true,
  1689. get: function () { return reactRouter.useParams; }
  1690. });
  1691. Object.defineProperty(exports, 'useResolvedPath', {
  1692. enumerable: true,
  1693. get: function () { return reactRouter.useResolvedPath; }
  1694. });
  1695. Object.defineProperty(exports, 'useRevalidator', {
  1696. enumerable: true,
  1697. get: function () { return reactRouter.useRevalidator; }
  1698. });
  1699. Object.defineProperty(exports, 'useRouteError', {
  1700. enumerable: true,
  1701. get: function () { return reactRouter.useRouteError; }
  1702. });
  1703. Object.defineProperty(exports, 'useRouteLoaderData', {
  1704. enumerable: true,
  1705. get: function () { return reactRouter.useRouteLoaderData; }
  1706. });
  1707. Object.defineProperty(exports, 'useRoutes', {
  1708. enumerable: true,
  1709. get: function () { return reactRouter.useRoutes; }
  1710. });
  1711. Object.defineProperty(exports, 'UNSAFE_ErrorResponseImpl', {
  1712. enumerable: true,
  1713. get: function () { return router.UNSAFE_ErrorResponseImpl; }
  1714. });
  1715. exports.BrowserRouter = BrowserRouter;
  1716. exports.Form = Form;
  1717. exports.HashRouter = HashRouter;
  1718. exports.Link = Link;
  1719. exports.NavLink = NavLink;
  1720. exports.RouterProvider = RouterProvider;
  1721. exports.ScrollRestoration = ScrollRestoration;
  1722. exports.UNSAFE_FetchersContext = FetchersContext;
  1723. exports.UNSAFE_ViewTransitionContext = ViewTransitionContext;
  1724. exports.UNSAFE_useScrollRestoration = useScrollRestoration;
  1725. exports.createBrowserRouter = createBrowserRouter;
  1726. exports.createHashRouter = createHashRouter;
  1727. exports.createSearchParams = createSearchParams;
  1728. exports.unstable_HistoryRouter = HistoryRouter;
  1729. exports.unstable_usePrompt = usePrompt;
  1730. exports.useBeforeUnload = useBeforeUnload;
  1731. exports.useFetcher = useFetcher;
  1732. exports.useFetchers = useFetchers;
  1733. exports.useFormAction = useFormAction;
  1734. exports.useLinkClickHandler = useLinkClickHandler;
  1735. exports.useSearchParams = useSearchParams;
  1736. exports.useSubmit = useSubmit;
  1737. exports.useViewTransitionState = useViewTransitionState;
  1738. Object.defineProperty(exports, '__esModule', { value: true });
  1739. }));
  1740. //# sourceMappingURL=react-router-dom.development.js.map