react-router-dom 0.0.0-experimental-bcda00aaf → 0.0.0-experimental-3278f3ca6

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