@tanstack/react-router 0.0.1-beta.6 → 0.0.1-beta.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -16,34 +16,16 @@ function _extends() {
16
16
  _extends = Object.assign ? Object.assign.bind() : function (target) {
17
17
  for (var i = 1; i < arguments.length; i++) {
18
18
  var source = arguments[i];
19
-
20
19
  for (var key in source) {
21
20
  if (Object.prototype.hasOwnProperty.call(source, key)) {
22
21
  target[key] = source[key];
23
22
  }
24
23
  }
25
24
  }
26
-
27
25
  return target;
28
26
  };
29
27
  return _extends.apply(this, arguments);
30
28
  }
31
29
 
32
- function _objectWithoutPropertiesLoose(source, excluded) {
33
- if (source == null) return {};
34
- var target = {};
35
- var sourceKeys = Object.keys(source);
36
- var key, i;
37
-
38
- for (i = 0; i < sourceKeys.length; i++) {
39
- key = sourceKeys[i];
40
- if (excluded.indexOf(key) >= 0) continue;
41
- target[key] = source[key];
42
- }
43
-
44
- return target;
45
- }
46
-
47
30
  exports["extends"] = _extends;
48
- exports.objectWithoutPropertiesLoose = _objectWithoutPropertiesLoose;
49
31
  //# sourceMappingURL=_rollupPluginBabelHelpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,442 @@
1
+ /**
2
+ * react-router
3
+ *
4
+ * Copyright (c) TanStack
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
+ 'use strict';
12
+
13
+ Object.defineProperty(exports, '__esModule', { value: true });
14
+
15
+ var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
16
+ var React = require('react');
17
+ var router = require('@tanstack/router');
18
+ var reactStore = require('@tanstack/react-store');
19
+
20
+ function _interopNamespace(e) {
21
+ if (e && e.__esModule) return e;
22
+ var n = Object.create(null);
23
+ if (e) {
24
+ Object.keys(e).forEach(function (k) {
25
+ if (k !== 'default') {
26
+ var d = Object.getOwnPropertyDescriptor(e, k);
27
+ Object.defineProperty(n, k, d.get ? d : {
28
+ enumerable: true,
29
+ get: function () { return e[k]; }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ n["default"] = e;
35
+ return Object.freeze(n);
36
+ }
37
+
38
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
39
+
40
+ //
41
+
42
+ function lazy(importer) {
43
+ const lazyComp = /*#__PURE__*/React__namespace.lazy(importer);
44
+ const finalComp = lazyComp;
45
+ finalComp.preload = async () => {
46
+ {
47
+ await importer();
48
+ }
49
+ };
50
+ return finalComp;
51
+ }
52
+ //
53
+
54
+ function useLinkProps(options) {
55
+ const router$1 = useRouter();
56
+ const {
57
+ // custom props
58
+ type,
59
+ children,
60
+ target,
61
+ activeProps = () => ({
62
+ className: 'active'
63
+ }),
64
+ inactiveProps = () => ({}),
65
+ activeOptions,
66
+ disabled,
67
+ // fromCurrent,
68
+ hash,
69
+ search,
70
+ params,
71
+ to = '.',
72
+ preload,
73
+ preloadDelay,
74
+ preloadMaxAge,
75
+ replace,
76
+ // element props
77
+ style,
78
+ className,
79
+ onClick,
80
+ onFocus,
81
+ onMouseEnter,
82
+ onMouseLeave,
83
+ onTouchStart,
84
+ onTouchEnd,
85
+ ...rest
86
+ } = options;
87
+ const linkInfo = router$1.buildLink(options);
88
+ if (linkInfo.type === 'external') {
89
+ const {
90
+ href
91
+ } = linkInfo;
92
+ return {
93
+ href
94
+ };
95
+ }
96
+ const {
97
+ handleClick,
98
+ handleFocus,
99
+ handleEnter,
100
+ handleLeave,
101
+ isActive,
102
+ next
103
+ } = linkInfo;
104
+ const reactHandleClick = e => {
105
+ if (React__namespace.startTransition) {
106
+ // This is a hack for react < 18
107
+ React__namespace.startTransition(() => {
108
+ handleClick(e);
109
+ });
110
+ } else {
111
+ handleClick(e);
112
+ }
113
+ };
114
+ const composeHandlers = handlers => e => {
115
+ if (e.persist) e.persist();
116
+ handlers.filter(Boolean).forEach(handler => {
117
+ if (e.defaultPrevented) return;
118
+ handler(e);
119
+ });
120
+ };
121
+
122
+ // Get the active props
123
+ const resolvedActiveProps = isActive ? router.functionalUpdate(activeProps, {}) ?? {} : {};
124
+
125
+ // Get the inactive props
126
+ const resolvedInactiveProps = isActive ? {} : router.functionalUpdate(inactiveProps, {}) ?? {};
127
+ return {
128
+ ...resolvedActiveProps,
129
+ ...resolvedInactiveProps,
130
+ ...rest,
131
+ href: disabled ? undefined : next.href,
132
+ onClick: composeHandlers([onClick, reactHandleClick]),
133
+ onFocus: composeHandlers([onFocus, handleFocus]),
134
+ onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
135
+ onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
136
+ target,
137
+ style: {
138
+ ...style,
139
+ ...resolvedActiveProps.style,
140
+ ...resolvedInactiveProps.style
141
+ },
142
+ className: [className, resolvedActiveProps.className, resolvedInactiveProps.className].filter(Boolean).join(' ') || undefined,
143
+ ...(disabled ? {
144
+ role: 'link',
145
+ 'aria-disabled': true
146
+ } : undefined),
147
+ ['data-status']: isActive ? 'active' : undefined
148
+ };
149
+ }
150
+ const Link = /*#__PURE__*/React__namespace.forwardRef((props, ref) => {
151
+ const linkProps = useLinkProps(props);
152
+ return /*#__PURE__*/React__namespace.createElement("a", _rollupPluginBabelHelpers["extends"]({
153
+ ref: ref
154
+ }, linkProps, {
155
+ children: typeof props.children === 'function' ? props.children({
156
+ isActive: linkProps['data-status'] === 'active'
157
+ }) : props.children
158
+ }));
159
+ });
160
+ const matchesContext = /*#__PURE__*/React__namespace.createContext(null);
161
+ const routerContext = /*#__PURE__*/React__namespace.createContext(null);
162
+ class ReactRouter extends router.Router {
163
+ constructor(opts) {
164
+ super({
165
+ ...opts,
166
+ loadComponent: async component => {
167
+ if (component.preload) {
168
+ await component.preload();
169
+ }
170
+ return component;
171
+ }
172
+ });
173
+ }
174
+ }
175
+ function RouterProvider({
176
+ router,
177
+ ...rest
178
+ }) {
179
+ router.update(rest);
180
+ const currentMatches = reactStore.useStore(router.store, s => s.currentMatches, undefined);
181
+ React__namespace.useEffect(router.mount, [router]);
182
+ return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
183
+ value: {
184
+ router: router
185
+ }
186
+ }, /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
187
+ value: [undefined, ...currentMatches]
188
+ }, /*#__PURE__*/React__namespace.createElement(Outlet, null))));
189
+ }
190
+ function useRouter() {
191
+ const value = React__namespace.useContext(routerContext);
192
+ router.warning(!value, 'useRouter must be used inside a <Router> component!');
193
+ return value.router;
194
+ }
195
+ function useRouterStore(selector, shallow) {
196
+ const router = useRouter();
197
+ return reactStore.useStore(router.store, selector, shallow);
198
+ }
199
+ function useMatches() {
200
+ return React__namespace.useContext(matchesContext);
201
+ }
202
+ function useMatch(opts) {
203
+ const router$1 = useRouter();
204
+ const nearestMatch = useMatches()[0];
205
+ const match = opts?.from ? router$1.store.state.currentMatches.find(d => d.route.id === opts?.from) : nearestMatch;
206
+ router.invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
207
+ if (opts?.strict ?? true) {
208
+ router.invariant(nearestMatch.route.id == match?.route.id, `useMatch("${match?.route.id}") is being called in a component that is meant to render the '${nearestMatch.route.id}' route. Did you mean to 'useMatch("${match?.route.id}", { strict: false })' or 'useRoute("${match?.route.id}")' instead?`);
209
+ }
210
+ reactStore.useStore(match.store, d => opts?.track?.(match) ?? match, opts?.shallow);
211
+ return match;
212
+ }
213
+ function useRoute(routeId) {
214
+ const router$1 = useRouter();
215
+ const resolvedRoute = router$1.getRoute(routeId);
216
+ router.invariant(resolvedRoute, `Could not find a route for route "${routeId}"! Did you forget to add it to your route config?`);
217
+ return resolvedRoute;
218
+ }
219
+ function useSearch(opts) {
220
+ const match = useMatch(opts);
221
+ reactStore.useStore(match.store, d => opts?.track?.(d.search) ?? d.search);
222
+ return match.store.state.search;
223
+ }
224
+ function useParams(opts) {
225
+ const router$1 = useRouter();
226
+ reactStore.useStore(router$1.store, d => {
227
+ const params = router.last(d.currentMatches)?.params;
228
+ return opts?.track?.(params) ?? params;
229
+ });
230
+ return router.last(router$1.store.state.currentMatches)?.params;
231
+ }
232
+ function useNavigate(defaultOpts) {
233
+ const router = useRouter();
234
+ return opts => {
235
+ return router.navigate({
236
+ ...defaultOpts,
237
+ ...opts
238
+ });
239
+ };
240
+ }
241
+ function useMatchRoute() {
242
+ const router = useRouter();
243
+ return opts => {
244
+ const {
245
+ pending,
246
+ caseSensitive,
247
+ ...rest
248
+ } = opts;
249
+ return router.matchRoute(rest, {
250
+ pending,
251
+ caseSensitive
252
+ });
253
+ };
254
+ }
255
+ function MatchRoute(props) {
256
+ const matchRoute = useMatchRoute();
257
+ const params = matchRoute(props);
258
+ if (!params) {
259
+ return null;
260
+ }
261
+ if (typeof props.children === 'function') {
262
+ return props.children(params);
263
+ }
264
+ return params ? props.children : null;
265
+ }
266
+ function Outlet() {
267
+ const matches = useMatches().slice(1);
268
+ const match = matches[0];
269
+ if (!match) {
270
+ return null;
271
+ }
272
+ return /*#__PURE__*/React__namespace.createElement(SubOutlet, {
273
+ matches: matches,
274
+ match: match
275
+ });
276
+ }
277
+ function SubOutlet({
278
+ matches,
279
+ match
280
+ }) {
281
+ const router$1 = useRouter();
282
+ reactStore.useStore(match.store);
283
+ const defaultPending = React__namespace.useCallback(() => null, []);
284
+ const Inner = React__namespace.useCallback(props => {
285
+ if (props.match.store.state.status === 'error') {
286
+ throw props.match.store.state.error;
287
+ }
288
+ if (props.match.store.state.status === 'success') {
289
+ return /*#__PURE__*/React__namespace.createElement(props.match.component ?? router$1.options.defaultComponent ?? Outlet);
290
+ }
291
+ if (props.match.store.state.status === 'pending') {
292
+ throw props.match.__loadPromise;
293
+ }
294
+ router.invariant(false, 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!');
295
+ }, []);
296
+ const PendingComponent = match.pendingComponent ?? router$1.options.defaultPendingComponent ?? defaultPending;
297
+ const errorComponent = match.errorComponent ?? router$1.options.defaultErrorComponent;
298
+ return /*#__PURE__*/React__namespace.createElement(matchesContext.Provider, {
299
+ value: matches
300
+ }, /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, {
301
+ fallback: /*#__PURE__*/React__namespace.createElement(PendingComponent, null)
302
+ }, /*#__PURE__*/React__namespace.createElement(CatchBoundary, {
303
+ key: match.route.id,
304
+ errorComponent: errorComponent,
305
+ match: match
306
+ }, /*#__PURE__*/React__namespace.createElement(Inner, {
307
+ match: match
308
+ }))));
309
+ }
310
+
311
+ // This is the messiest thing ever... I'm either seriously tired (likely) or
312
+ // there has to be a better way to reset error boundaries when the
313
+ // router's location key changes.
314
+
315
+ class CatchBoundary extends React__namespace.Component {
316
+ state = {
317
+ error: false,
318
+ info: undefined
319
+ };
320
+ componentDidCatch(error, info) {
321
+ console.error(`Error in route match: ${this.props.match.id}`);
322
+ console.error(error);
323
+ this.setState({
324
+ error,
325
+ info
326
+ });
327
+ }
328
+ render() {
329
+ return /*#__PURE__*/React__namespace.createElement(CatchBoundaryInner, _rollupPluginBabelHelpers["extends"]({}, this.props, {
330
+ errorState: this.state,
331
+ reset: () => this.setState({})
332
+ }));
333
+ }
334
+ }
335
+ function CatchBoundaryInner(props) {
336
+ const [activeErrorState, setActiveErrorState] = React__namespace.useState(props.errorState);
337
+ const router = useRouter();
338
+ const errorComponent = props.errorComponent ?? DefaultErrorBoundary;
339
+ const prevKeyRef = React__namespace.useRef('');
340
+ React__namespace.useEffect(() => {
341
+ if (activeErrorState) {
342
+ if (router.store.state.currentLocation.key !== prevKeyRef.current) {
343
+ setActiveErrorState({});
344
+ }
345
+ }
346
+ prevKeyRef.current = router.store.state.currentLocation.key;
347
+ }, [activeErrorState, router.store.state.currentLocation.key]);
348
+ React__namespace.useEffect(() => {
349
+ if (props.errorState.error) {
350
+ setActiveErrorState(props.errorState);
351
+ }
352
+ // props.reset()
353
+ }, [props.errorState.error]);
354
+ if (props.errorState.error && activeErrorState.error) {
355
+ return /*#__PURE__*/React__namespace.createElement(errorComponent, activeErrorState);
356
+ }
357
+ return props.children;
358
+ }
359
+ function DefaultErrorBoundary({
360
+ error
361
+ }) {
362
+ return /*#__PURE__*/React__namespace.createElement("div", {
363
+ style: {
364
+ padding: '.5rem',
365
+ maxWidth: '100%'
366
+ }
367
+ }, /*#__PURE__*/React__namespace.createElement("strong", {
368
+ style: {
369
+ fontSize: '1.2rem'
370
+ }
371
+ }, "Something went wrong!"), /*#__PURE__*/React__namespace.createElement("div", {
372
+ style: {
373
+ height: '.5rem'
374
+ }
375
+ }), /*#__PURE__*/React__namespace.createElement("div", null, /*#__PURE__*/React__namespace.createElement("pre", null, error.message ? /*#__PURE__*/React__namespace.createElement("code", {
376
+ style: {
377
+ fontSize: '.7em',
378
+ border: '1px solid red',
379
+ borderRadius: '.25rem',
380
+ padding: '.5rem',
381
+ color: 'red'
382
+ }
383
+ }, error.message) : null)));
384
+ }
385
+
386
+ // TODO: While we migrate away from the history package, these need to be disabled
387
+ // export function usePrompt(message: string, when: boolean | any): void {
388
+ // const router = useRouter()
389
+
390
+ // React.useEffect(() => {
391
+ // if (!when) return
392
+
393
+ // let unblock = router.getHistory().block((transition) => {
394
+ // if (window.confirm(message)) {
395
+ // unblock()
396
+ // transition.retry()
397
+ // } else {
398
+ // router.setStore((s) => {
399
+ // s.currentLocation.pathname = window.location.pathname
400
+ // })
401
+ // }
402
+ // })
403
+
404
+ // return unblock
405
+ // }, [when, message])
406
+ // }
407
+
408
+ // export function Prompt({ message, when, children }: PromptProps) {
409
+ // usePrompt(message, when ?? true)
410
+ // return (children ?? null) as ReactNode
411
+ // }
412
+
413
+ Object.defineProperty(exports, 'useStore', {
414
+ enumerable: true,
415
+ get: function () { return reactStore.useStore; }
416
+ });
417
+ exports.DefaultErrorBoundary = DefaultErrorBoundary;
418
+ exports.Link = Link;
419
+ exports.MatchRoute = MatchRoute;
420
+ exports.Outlet = Outlet;
421
+ exports.ReactRouter = ReactRouter;
422
+ exports.RouterProvider = RouterProvider;
423
+ exports.lazy = lazy;
424
+ exports.matchesContext = matchesContext;
425
+ exports.routerContext = routerContext;
426
+ exports.useLinkProps = useLinkProps;
427
+ exports.useMatch = useMatch;
428
+ exports.useMatchRoute = useMatchRoute;
429
+ exports.useMatches = useMatches;
430
+ exports.useNavigate = useNavigate;
431
+ exports.useParams = useParams;
432
+ exports.useRoute = useRoute;
433
+ exports.useRouter = useRouter;
434
+ exports.useRouterStore = useRouterStore;
435
+ exports.useSearch = useSearch;
436
+ Object.keys(router).forEach(function (k) {
437
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
438
+ enumerable: true,
439
+ get: function () { return router[k]; }
440
+ });
441
+ });
442
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\n\nimport {\n Route,\n RegisteredRoutesInfo,\n RegisteredRouter,\n RouterStore,\n last,\n warning,\n RouterOptions,\n RouteMatch,\n MatchRouteOptions,\n AnyRoute,\n AnyRoutesInfo,\n DefaultRoutesInfo,\n functionalUpdate,\n RoutesInfo,\n ValidFromPath,\n LinkOptions,\n RouteByPath,\n ResolveRelativePath,\n NoInfer,\n ToOptions,\n invariant,\n Router,\n Expand,\n} from '@tanstack/router'\nimport { useStore } from '@tanstack/react-store'\n\n//\n\nexport * from '@tanstack/router'\n\nexport { useStore }\n\n//\n\ntype ReactNode = any\n\nexport type SyncRouteComponent<TProps = {}> = (props: TProps) => ReactNode\n\nexport type RouteComponent<TProps = {}> = SyncRouteComponent<TProps> & {\n preload?: () => Promise<void>\n}\n\nexport function lazy(\n importer: () => Promise<{ default: SyncRouteComponent }>,\n): RouteComponent {\n const lazyComp = React.lazy(importer as any)\n let preloaded: Promise<SyncRouteComponent>\n\n const finalComp = lazyComp as unknown as RouteComponent\n\n finalComp.preload = async () => {\n if (!preloaded) {\n await importer()\n }\n }\n\n return finalComp\n}\n\nexport type LinkPropsOptions<\n TFrom extends RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkOptions<RegisteredRoutesInfo, TFrom, TTo> & {\n // A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n activeProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n // A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n inactiveProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n}\n\nexport type MakeUseMatchRouteOptions<\n TFrom extends RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> & MatchRouteOptions\n\nexport type MakeMatchRouteOptions<\n TFrom extends RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = ToOptions<RegisteredRoutesInfo, TFrom, TTo> &\n MatchRouteOptions & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | ReactNode\n | ((\n params: RouteByPath<\n RegisteredRoutesInfo,\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['__types']['allParams'],\n ) => ReactNode)\n }\n\nexport type MakeLinkPropsOptions<\n TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> & React.AnchorHTMLAttributes<HTMLAnchorElement>\n\nexport type MakeLinkOptions<\n TFrom extends RegisteredRoutesInfo['routePaths'] = '/',\n TTo extends string = '.',\n> = LinkPropsOptions<TFrom, TTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?: ReactNode | ((state: { isActive: boolean }) => ReactNode)\n }\n\ndeclare module '@tanstack/router' {\n interface FrameworkGenerics {\n Component: RouteComponent\n ErrorComponent: RouteComponent<{\n error: unknown\n info: { componentStack: string }\n }>\n }\n\n interface RouterOptions<TRouteTree, TRouterContext> {\n // ssrFooter?: () => JSX.Element | Node\n }\n}\n\nexport type PromptProps = {\n message: string\n when?: boolean | any\n children?: ReactNode\n}\n\n//\n\nexport function useLinkProps<\n TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/',\n TTo extends string = '.',\n>(\n options: MakeLinkPropsOptions<TFrom, TTo>,\n): React.AnchorHTMLAttributes<HTMLAnchorElement> {\n const router = useRouter()\n\n const {\n // custom props\n type,\n children,\n target,\n activeProps = () => ({ className: 'active' }),\n inactiveProps = () => ({}),\n activeOptions,\n disabled,\n // fromCurrent,\n hash,\n search,\n params,\n to = '.',\n preload,\n preloadDelay,\n preloadMaxAge,\n replace,\n // element props\n style,\n className,\n onClick,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchStart,\n onTouchEnd,\n ...rest\n } = options\n\n const linkInfo = router.buildLink(options as any)\n\n if (linkInfo.type === 'external') {\n const { href } = linkInfo\n return { href }\n }\n\n const { handleClick, handleFocus, handleEnter, handleLeave, isActive, next } =\n linkInfo\n\n const reactHandleClick = (e: Event) => {\n if (React.startTransition) {\n // This is a hack for react < 18\n React.startTransition(() => {\n handleClick(e)\n })\n } else {\n handleClick(e)\n }\n }\n\n const composeHandlers =\n (handlers: (undefined | ((e: any) => void))[]) =>\n (e: React.SyntheticEvent) => {\n if (e.persist) e.persist()\n handlers.filter(Boolean).forEach((handler) => {\n if (e.defaultPrevented) return\n handler!(e)\n })\n }\n\n // Get the active props\n const resolvedActiveProps: React.HTMLAttributes<HTMLAnchorElement> = isActive\n ? functionalUpdate(activeProps as any, {}) ?? {}\n : {}\n\n // Get the inactive props\n const resolvedInactiveProps: React.HTMLAttributes<HTMLAnchorElement> =\n isActive ? {} : functionalUpdate(inactiveProps, {}) ?? {}\n\n return {\n ...resolvedActiveProps,\n ...resolvedInactiveProps,\n ...rest,\n href: disabled ? undefined : next.href,\n onClick: composeHandlers([onClick, reactHandleClick]),\n onFocus: composeHandlers([onFocus, handleFocus]),\n onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),\n onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),\n target,\n style: {\n ...style,\n ...resolvedActiveProps.style,\n ...resolvedInactiveProps.style,\n },\n className:\n [\n className,\n resolvedActiveProps.className,\n resolvedInactiveProps.className,\n ]\n .filter(Boolean)\n .join(' ') || undefined,\n ...(disabled\n ? {\n role: 'link',\n 'aria-disabled': true,\n }\n : undefined),\n ['data-status']: isActive ? 'active' : undefined,\n }\n}\n\nexport interface LinkFn<\n TDefaultFrom extends RegisteredRoutesInfo['routePaths'] = '/',\n TDefaultTo extends string = '.',\n> {\n <\n TFrom extends RegisteredRoutesInfo['routePaths'] = TDefaultFrom,\n TTo extends string = TDefaultTo,\n >(\n props: MakeLinkOptions<TFrom, TTo> & React.RefAttributes<HTMLAnchorElement>,\n ): ReactNode\n}\n\nexport const Link: LinkFn = React.forwardRef((props: any, ref) => {\n const linkProps = useLinkProps(props)\n\n return (\n <a\n {...{\n ref: ref as any,\n ...linkProps,\n children:\n typeof props.children === 'function'\n ? props.children({\n isActive: (linkProps as any)['data-status'] === 'active',\n })\n : props.children,\n }}\n />\n )\n}) as any\n\ntype MatchesContextValue = RouteMatch[]\n\nexport const matchesContext = React.createContext<MatchesContextValue>(null!)\nexport const routerContext = React.createContext<{ router: RegisteredRouter }>(\n null!,\n)\n\nexport type MatchesProviderProps = {\n value: MatchesContextValue\n children: ReactNode\n}\n\nexport class ReactRouter<\n TRouteConfig extends AnyRoute = Route,\n TRoutesInfo extends AnyRoutesInfo = RoutesInfo<TRouteConfig>,\n TRouterContext = unknown,\n> extends Router<TRouteConfig, TRoutesInfo, TRouterContext> {\n constructor(opts: RouterOptions<TRouteConfig, TRouterContext>) {\n super({\n ...opts,\n loadComponent: async (component) => {\n if (component.preload) {\n await component.preload()\n }\n\n return component as any\n },\n })\n }\n}\n\nexport type RouterProps<\n TRouteConfig extends AnyRoute = Route,\n TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,\n TRouterContext = unknown,\n> = RouterOptions<TRouteConfig, TRouterContext> & {\n router: Router<TRouteConfig, TRoutesInfo, TRouterContext>\n}\n\nexport function RouterProvider<\n TRouteConfig extends AnyRoute = Route,\n TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo,\n TRouterContext = unknown,\n>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo, TRouterContext>) {\n router.update(rest)\n\n const currentMatches = useStore(\n router.store,\n (s) => s.currentMatches,\n undefined,\n )\n\n React.useEffect(router.mount, [router])\n\n return (\n <>\n <routerContext.Provider value={{ router: router as any }}>\n <matchesContext.Provider value={[undefined!, ...currentMatches]}>\n <Outlet />\n </matchesContext.Provider>\n </routerContext.Provider>\n </>\n )\n}\n\nexport function useRouter(): RegisteredRouter {\n const value = React.useContext(routerContext)\n warning(!value, 'useRouter must be used inside a <Router> component!')\n return value.router\n}\n\nexport function useRouterStore<T = RouterStore>(\n selector?: (state: Router['store']) => T,\n shallow?: boolean,\n): T {\n const router = useRouter()\n return useStore(router.store, selector as any, shallow)\n}\n\nexport function useMatches(): RouteMatch[] {\n return React.useContext(matchesContext)\n}\n\nexport function useMatch<\n TFrom extends keyof RegisteredRoutesInfo['routesById'],\n TStrict extends boolean = true,\n TRouteMatch = RouteMatch<\n RegisteredRoutesInfo,\n RegisteredRoutesInfo['routesById'][TFrom]\n >,\n>(opts?: {\n from: TFrom\n strict?: TStrict\n track?: (match: TRouteMatch) => any\n shallow?: boolean\n}): TStrict extends true ? TRouteMatch : TRouteMatch | undefined {\n const router = useRouter()\n const nearestMatch = useMatches()[0]!\n const match = opts?.from\n ? router.store.state.currentMatches.find((d) => d.route.id === opts?.from)\n : nearestMatch\n\n invariant(\n match,\n `Could not find ${\n opts?.from ? `an active match from \"${opts.from}\"` : 'a nearest match!'\n }`,\n )\n\n if (opts?.strict ?? true) {\n invariant(\n nearestMatch.route.id == match?.route.id,\n `useMatch(\"${\n match?.route.id as string\n }\") is being called in a component that is meant to render the '${\n nearestMatch.route.id\n }' route. Did you mean to 'useMatch(\"${\n match?.route.id as string\n }\", { strict: false })' or 'useRoute(\"${\n match?.route.id as string\n }\")' instead?`,\n )\n }\n\n useStore(\n match!.store,\n (d) => opts?.track?.(match as any) ?? match,\n opts?.shallow,\n )\n\n return match as any\n}\n\nexport function useRoute<\n TId extends keyof RegisteredRoutesInfo['routesById'] = '/',\n>(routeId: TId): RegisteredRoutesInfo['routesById'][TId] {\n const router = useRouter()\n const resolvedRoute = router.getRoute(routeId as any)\n\n invariant(\n resolvedRoute,\n `Could not find a route for route \"${\n routeId as string\n }\"! Did you forget to add it to your route config?`,\n )\n\n return resolvedRoute as any\n}\n\nexport function useSearch<\n TFrom extends keyof RegisteredRoutesInfo['routesById'],\n TStrict extends boolean = true,\n TSearch = RegisteredRoutesInfo['routesById'][TFrom]['__types']['fullSearchSchema'],\n TSelected = TSearch,\n>(opts?: {\n from: TFrom\n strict?: TStrict\n track?: (search: TSearch) => TSelected\n}): TStrict extends true ? TSelected : TSelected | undefined {\n const match = useMatch(opts)\n useStore(\n (match as any).store,\n (d: any) => opts?.track?.(d.search) ?? d.search,\n )\n\n return (match as unknown as RouteMatch).store.state.search as any\n}\n\nexport function useParams<\n TFrom extends keyof RegisteredRoutesInfo['routesById'] = '/',\n TDefaultSelected = Expand<\n RegisteredRoutesInfo['allParams'] &\n RegisteredRoutesInfo['routesById'][TFrom]['__types']['allParams']\n >,\n TSelected = TDefaultSelected,\n>(opts?: {\n from: TFrom\n track?: (search: TDefaultSelected) => TSelected\n}): TSelected {\n const router = useRouter()\n useStore(router.store, (d) => {\n const params = last(d.currentMatches)?.params as any\n return opts?.track?.(params) ?? params\n })\n\n return last(router.store.state.currentMatches)?.params as any\n}\n\nexport function useNavigate<\n TDefaultFrom extends keyof RegisteredRoutesInfo['routesById'] = '/',\n>(defaultOpts?: { from?: TDefaultFrom }) {\n const router = useRouter()\n return <\n TFrom extends keyof RegisteredRoutesInfo['routesById'] = TDefaultFrom,\n TTo extends string = '.',\n >(\n opts?: MakeLinkOptions<TFrom, TTo>,\n ) => {\n return router.navigate({ ...defaultOpts, ...(opts as any) })\n }\n}\n\nexport function useMatchRoute() {\n const router = useRouter()\n\n return <\n TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/',\n TTo extends string = '.',\n >(\n opts: MakeUseMatchRouteOptions<TFrom, TTo>,\n ) => {\n const { pending, caseSensitive, ...rest } = opts\n\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n })\n }\n}\n\nexport function MatchRoute<\n TFrom extends ValidFromPath<RegisteredRoutesInfo> = '/',\n TTo extends string = '.',\n>(props: MakeMatchRouteOptions<TFrom, TTo>): any {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props)\n\n if (!params) {\n return null\n }\n\n if (typeof props.children === 'function') {\n return (props.children as any)(params)\n }\n\n return params ? props.children : null\n}\n\nexport function Outlet() {\n const matches = useMatches().slice(1)\n const match = matches[0]\n\n if (!match) {\n return null\n }\n\n return <SubOutlet matches={matches} match={match} />\n}\n\nfunction SubOutlet({\n matches,\n match,\n}: {\n matches: RouteMatch[]\n match: RouteMatch\n}) {\n const router = useRouter()\n useStore(match!.store)\n\n const defaultPending = React.useCallback(() => null, [])\n\n const Inner = React.useCallback((props: { match: RouteMatch }): any => {\n if (props.match.store.state.status === 'error') {\n throw props.match.store.state.error\n }\n\n if (props.match.store.state.status === 'success') {\n return React.createElement(\n (props.match.component as any) ??\n router.options.defaultComponent ??\n Outlet,\n )\n }\n\n if (props.match.store.state.status === 'pending') {\n throw props.match.__loadPromise\n }\n\n invariant(\n false,\n 'Idle routeMatch status encountered during rendering! You should never see this. File an issue!',\n )\n }, [])\n\n const PendingComponent = (match.pendingComponent ??\n router.options.defaultPendingComponent ??\n defaultPending) as any\n\n const errorComponent =\n match.errorComponent ?? router.options.defaultErrorComponent\n\n return (\n <matchesContext.Provider value={matches}>\n <React.Suspense fallback={<PendingComponent />}>\n <CatchBoundary\n key={match.route.id}\n errorComponent={errorComponent}\n match={match as any}\n >\n <Inner match={match} />\n </CatchBoundary>\n </React.Suspense>\n {/* Provide a suffix suspense boundary to make sure the router is\n ready to be dehydrated on the server */}\n {/* {router.options.ssrFooter && match.id === rootRouteId ? (\n <React.Suspense fallback={null}>\n {(() => {\n if (router.store.pending) {\n throw router.navigationPromise\n }\n\n return router.options.ssrFooter()\n })()}\n </React.Suspense>\n ) : null} */}\n </matchesContext.Provider>\n )\n}\n\n// This is the messiest thing ever... I'm either seriously tired (likely) or\n// there has to be a better way to reset error boundaries when the\n// router's location key changes.\n\nclass CatchBoundary extends React.Component<{\n children: any\n errorComponent: any\n match: RouteMatch\n}> {\n state = {\n error: false,\n info: undefined,\n }\n componentDidCatch(error: any, info: any) {\n console.error(`Error in route match: ${this.props.match.id}`)\n console.error(error)\n this.setState({\n error,\n info,\n })\n }\n render() {\n return (\n <CatchBoundaryInner\n {...this.props}\n errorState={this.state}\n reset={() => this.setState({})}\n />\n )\n }\n}\n\nfunction CatchBoundaryInner(props: {\n children: any\n errorComponent: any\n errorState: { error: unknown; info: any }\n reset: () => void\n}) {\n const [activeErrorState, setActiveErrorState] = React.useState(\n props.errorState,\n )\n const router = useRouter()\n const errorComponent = props.errorComponent ?? DefaultErrorBoundary\n const prevKeyRef = React.useRef('' as any)\n\n React.useEffect(() => {\n if (activeErrorState) {\n if (router.store.state.currentLocation.key !== prevKeyRef.current) {\n setActiveErrorState({} as any)\n }\n }\n\n prevKeyRef.current = router.store.state.currentLocation.key\n }, [activeErrorState, router.store.state.currentLocation.key])\n\n React.useEffect(() => {\n if (props.errorState.error) {\n setActiveErrorState(props.errorState)\n }\n // props.reset()\n }, [props.errorState.error])\n\n if (props.errorState.error && activeErrorState.error) {\n return React.createElement(errorComponent, activeErrorState)\n }\n\n return props.children\n}\n\nexport function DefaultErrorBoundary({ error }: { error: any }) {\n return (\n <div style={{ padding: '.5rem', maxWidth: '100%' }}>\n <strong style={{ fontSize: '1.2rem' }}>Something went wrong!</strong>\n <div style={{ height: '.5rem' }} />\n <div>\n <pre>\n {error.message ? (\n <code\n style={{\n fontSize: '.7em',\n border: '1px solid red',\n borderRadius: '.25rem',\n padding: '.5rem',\n color: 'red',\n }}\n >\n {error.message}\n </code>\n ) : null}\n </pre>\n </div>\n </div>\n )\n}\n\n// TODO: While we migrate away from the history package, these need to be disabled\n// export function usePrompt(message: string, when: boolean | any): void {\n// const router = useRouter()\n\n// React.useEffect(() => {\n// if (!when) return\n\n// let unblock = router.getHistory().block((transition) => {\n// if (window.confirm(message)) {\n// unblock()\n// transition.retry()\n// } else {\n// router.setStore((s) => {\n// s.currentLocation.pathname = window.location.pathname\n// })\n// }\n// })\n\n// return unblock\n// }, [when, message])\n// }\n\n// export function Prompt({ message, when, children }: PromptProps) {\n// usePrompt(message, when ?? true)\n// return (children ?? null) as ReactNode\n// }\n"],"names":["lazy","importer","lazyComp","React","finalComp","preload","useLinkProps","options","router","useRouter","type","children","target","activeProps","className","inactiveProps","activeOptions","disabled","hash","search","params","to","preloadDelay","preloadMaxAge","replace","style","onClick","onFocus","onMouseEnter","onMouseLeave","onTouchStart","onTouchEnd","rest","linkInfo","buildLink","href","handleClick","handleFocus","handleEnter","handleLeave","isActive","next","reactHandleClick","e","startTransition","composeHandlers","handlers","persist","filter","Boolean","forEach","handler","defaultPrevented","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","undefined","join","role","Link","forwardRef","props","ref","linkProps","_extends","matchesContext","createContext","routerContext","ReactRouter","Router","constructor","opts","loadComponent","component","RouterProvider","update","currentMatches","useStore","store","s","useEffect","mount","value","useContext","warning","useRouterStore","selector","shallow","useMatches","useMatch","nearestMatch","match","from","state","find","d","route","id","invariant","strict","track","useRoute","routeId","resolvedRoute","getRoute","useSearch","useParams","last","useNavigate","defaultOpts","navigate","useMatchRoute","pending","caseSensitive","matchRoute","MatchRoute","Outlet","matches","slice","SubOutlet","defaultPending","useCallback","Inner","status","error","createElement","defaultComponent","__loadPromise","PendingComponent","pendingComponent","defaultPendingComponent","errorComponent","defaultErrorComponent","CatchBoundary","Component","info","componentDidCatch","console","setState","render","CatchBoundaryInner","activeErrorState","setActiveErrorState","useState","errorState","DefaultErrorBoundary","prevKeyRef","useRef","currentLocation","key","current","padding","maxWidth","fontSize","height","message","border","borderRadius","color"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA;;AAUO,SAASA,IAAI,CAClBC,QAAwD,EACxC;AAChB,EAAA,MAAMC,QAAQ,gBAAGC,gBAAK,CAACH,IAAI,CAACC,QAAQ,CAAQ,CAAA;EAG5C,MAAMG,SAAS,GAAGF,QAAqC,CAAA;EAEvDE,SAAS,CAACC,OAAO,GAAG,YAAY;IACd;AACd,MAAA,MAAMJ,QAAQ,EAAE,CAAA;AAClB,KAAA;GACD,CAAA;AAED,EAAA,OAAOG,SAAS,CAAA;AAClB,CAAA;AAwEA;;AAEO,SAASE,YAAY,CAI1BC,OAAyC,EACM;EAC/C,MAAMC,QAAM,GAAGC,SAAS,EAAE,CAAA;EAE1B,MAAM;AACJ;IACAC,IAAI;IACJC,QAAQ;IACRC,MAAM;AACNC,IAAAA,WAAW,GAAG,OAAO;AAAEC,MAAAA,SAAS,EAAE,QAAA;AAAS,KAAC,CAAC;AAC7CC,IAAAA,aAAa,GAAG,OAAO,EAAE,CAAC;IAC1BC,aAAa;IACbC,QAAQ;AACR;IACAC,IAAI;IACJC,MAAM;IACNC,MAAM;AACNC,IAAAA,EAAE,GAAG,GAAG;IACRhB,OAAO;IACPiB,YAAY;IACZC,aAAa;IACbC,OAAO;AACP;IACAC,KAAK;IACLX,SAAS;IACTY,OAAO;IACPC,OAAO;IACPC,YAAY;IACZC,YAAY;IACZC,YAAY;IACZC,UAAU;IACV,GAAGC,IAAAA;AACL,GAAC,GAAGzB,OAAO,CAAA;AAEX,EAAA,MAAM0B,QAAQ,GAAGzB,QAAM,CAAC0B,SAAS,CAAC3B,OAAO,CAAQ,CAAA;AAEjD,EAAA,IAAI0B,QAAQ,CAACvB,IAAI,KAAK,UAAU,EAAE;IAChC,MAAM;AAAEyB,MAAAA,IAAAA;AAAK,KAAC,GAAGF,QAAQ,CAAA;IACzB,OAAO;AA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