@tanstack/react-router 1.7.1 → 1.8.1

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.
Files changed (209) hide show
  1. package/dist/cjs/CatchBoundary.cjs +106 -0
  2. package/dist/cjs/CatchBoundary.cjs.map +1 -0
  3. package/dist/cjs/Matches.cjs +278 -0
  4. package/dist/cjs/Matches.cjs.map +1 -0
  5. package/dist/cjs/Matches.d.cts +71 -0
  6. package/{build/cjs/RouterProvider.js → dist/cjs/RouterProvider.cjs} +55 -58
  7. package/dist/cjs/RouterProvider.cjs.map +1 -0
  8. package/dist/cjs/RouterProvider.d.cts +29 -0
  9. package/dist/cjs/awaited.cjs +51 -0
  10. package/dist/cjs/awaited.cjs.map +1 -0
  11. package/dist/cjs/defer.cjs +30 -0
  12. package/dist/cjs/defer.cjs.map +1 -0
  13. package/dist/cjs/fileRoute.cjs +19 -0
  14. package/dist/cjs/fileRoute.cjs.map +1 -0
  15. package/dist/cjs/history.d.cts +7 -0
  16. package/{build/cjs/index.js → dist/cjs/index.cjs} +39 -51
  17. package/dist/cjs/index.cjs.map +1 -0
  18. package/dist/cjs/lazyRouteComponent.cjs +40 -0
  19. package/dist/cjs/lazyRouteComponent.cjs.map +1 -0
  20. package/dist/cjs/link.cjs +196 -0
  21. package/dist/cjs/link.cjs.map +1 -0
  22. package/dist/cjs/link.d.cts +85 -0
  23. package/{build/cjs/path.js → dist/cjs/path.cjs} +87 -95
  24. package/dist/cjs/path.cjs.map +1 -0
  25. package/dist/cjs/path.d.cts +24 -0
  26. package/dist/cjs/qss.cjs +45 -0
  27. package/dist/cjs/qss.cjs.map +1 -0
  28. package/dist/cjs/redirects.cjs +15 -0
  29. package/dist/cjs/redirects.cjs.map +1 -0
  30. package/dist/cjs/route.cjs +143 -0
  31. package/dist/cjs/route.cjs.map +1 -0
  32. package/dist/cjs/router.cjs +1089 -0
  33. package/dist/cjs/router.cjs.map +1 -0
  34. package/dist/cjs/routerContext.cjs +29 -0
  35. package/dist/cjs/routerContext.cjs.map +1 -0
  36. package/{build/cjs/scroll-restoration.js → dist/cjs/scroll-restoration.cjs} +58 -75
  37. package/dist/cjs/scroll-restoration.cjs.map +1 -0
  38. package/{build/cjs/searchParams.js → dist/cjs/searchParams.cjs} +18 -36
  39. package/dist/cjs/searchParams.cjs.map +1 -0
  40. package/dist/cjs/useBlocker.cjs +36 -0
  41. package/dist/cjs/useBlocker.cjs.map +1 -0
  42. package/dist/cjs/useNavigate.cjs +55 -0
  43. package/dist/cjs/useNavigate.cjs.map +1 -0
  44. package/dist/cjs/useParams.cjs +16 -0
  45. package/dist/cjs/useParams.cjs.map +1 -0
  46. package/dist/cjs/useRouteContext.cjs +11 -0
  47. package/dist/cjs/useRouteContext.cjs.map +1 -0
  48. package/dist/cjs/useRouter.cjs +33 -0
  49. package/dist/cjs/useRouter.cjs.map +1 -0
  50. package/dist/cjs/useRouterState.cjs +12 -0
  51. package/dist/cjs/useRouterState.cjs.map +1 -0
  52. package/dist/cjs/useSearch.cjs +13 -0
  53. package/dist/cjs/useSearch.cjs.map +1 -0
  54. package/{build/cjs/utils.js → dist/cjs/utils.cjs} +25 -116
  55. package/dist/cjs/utils.cjs.map +1 -0
  56. package/dist/cjs/utils.d.cts +50 -0
  57. package/dist/esm/CatchBoundary.d.ts +36 -0
  58. package/dist/esm/CatchBoundary.js +89 -0
  59. package/dist/esm/CatchBoundary.js.map +1 -0
  60. package/{build/types → dist/esm}/Matches.d.ts +3 -3
  61. package/dist/esm/Matches.js +261 -0
  62. package/dist/esm/Matches.js.map +1 -0
  63. package/{build/types → dist/esm}/RouterProvider.d.ts +3 -1
  64. package/dist/esm/RouterProvider.js +136 -0
  65. package/dist/esm/RouterProvider.js.map +1 -0
  66. package/dist/esm/awaited.d.ts +9 -0
  67. package/dist/esm/awaited.js +51 -0
  68. package/dist/esm/awaited.js.map +1 -0
  69. package/dist/esm/defer.d.ts +22 -0
  70. package/dist/esm/defer.js +30 -0
  71. package/{build/cjs → dist/esm}/defer.js.map +1 -1
  72. package/dist/esm/fileRoute.d.ts +21 -0
  73. package/dist/esm/fileRoute.js +19 -0
  74. package/dist/esm/fileRoute.js.map +1 -0
  75. package/{build/types → dist/esm}/history.d.ts +1 -1
  76. package/dist/esm/index.d.ts +30 -0
  77. package/dist/esm/index.js +118 -0
  78. package/dist/esm/index.js.map +1 -0
  79. package/dist/esm/lazyRouteComponent.d.ts +2 -0
  80. package/dist/esm/lazyRouteComponent.js +23 -0
  81. package/{build/cjs → dist/esm}/lazyRouteComponent.js.map +1 -1
  82. package/{build/types → dist/esm}/link.d.ts +3 -1
  83. package/dist/esm/link.js +179 -0
  84. package/dist/esm/link.js.map +1 -0
  85. package/dist/esm/location.d.ts +12 -0
  86. package/{build/types → dist/esm}/path.d.ts +8 -1
  87. package/dist/esm/path.js +209 -0
  88. package/dist/esm/path.js.map +1 -0
  89. package/dist/esm/qss.d.ts +2 -0
  90. package/dist/esm/qss.js +45 -0
  91. package/dist/esm/qss.js.map +1 -0
  92. package/dist/esm/redirects.d.ts +11 -0
  93. package/dist/esm/redirects.js +15 -0
  94. package/{build/cjs → dist/esm}/redirects.js.map +1 -1
  95. package/dist/esm/route.d.ts +300 -0
  96. package/dist/esm/route.js +143 -0
  97. package/dist/esm/route.js.map +1 -0
  98. package/dist/esm/routeInfo.d.ts +31 -0
  99. package/dist/esm/router.d.ts +201 -0
  100. package/dist/esm/router.js +1089 -0
  101. package/dist/esm/router.js.map +1 -0
  102. package/dist/esm/routerContext.d.ts +3 -0
  103. package/dist/esm/routerContext.js +13 -0
  104. package/{build/cjs → dist/esm}/routerContext.js.map +1 -1
  105. package/dist/esm/scroll-restoration.d.ts +18 -0
  106. package/dist/esm/scroll-restoration.js +168 -0
  107. package/dist/esm/scroll-restoration.js.map +1 -0
  108. package/dist/esm/searchParams.d.ts +7 -0
  109. package/dist/esm/searchParams.js +63 -0
  110. package/{build/cjs → dist/esm}/searchParams.js.map +1 -1
  111. package/dist/esm/useBlocker.d.ts +9 -0
  112. package/dist/esm/useBlocker.js +19 -0
  113. package/{build/cjs → dist/esm}/useBlocker.js.map +1 -1
  114. package/dist/esm/useNavigate.d.ts +20 -0
  115. package/dist/esm/useNavigate.js +38 -0
  116. package/{build/cjs → dist/esm}/useNavigate.js.map +1 -1
  117. package/dist/esm/useParams.d.ts +7 -0
  118. package/dist/esm/useParams.js +16 -0
  119. package/{build/cjs → dist/esm}/useParams.js.map +1 -1
  120. package/dist/esm/useRouteContext.d.ts +7 -0
  121. package/dist/esm/useRouteContext.js +11 -0
  122. package/{build/cjs → dist/esm}/useRouteContext.js.map +1 -1
  123. package/dist/esm/useRouter.d.ts +5 -0
  124. package/dist/esm/useRouter.js +16 -0
  125. package/{build/cjs → dist/esm}/useRouter.js.map +1 -1
  126. package/dist/esm/useRouterState.d.ts +6 -0
  127. package/dist/esm/useRouterState.js +12 -0
  128. package/{build/cjs → dist/esm}/useRouterState.js.map +1 -1
  129. package/dist/esm/useSearch.d.ts +7 -0
  130. package/dist/esm/useSearch.js +13 -0
  131. package/dist/esm/useSearch.js.map +1 -0
  132. package/{build/types → dist/esm}/utils.d.ts +4 -0
  133. package/dist/esm/utils.js +137 -0
  134. package/dist/esm/utils.js.map +1 -0
  135. package/package.json +43 -22
  136. package/src/Matches.tsx +10 -6
  137. package/src/RouterProvider.tsx +3 -1
  138. package/src/fileRoute.ts +4 -5
  139. package/src/link.tsx +5 -4
  140. package/src/path.ts +16 -5
  141. package/src/route.ts +5 -6
  142. package/src/router.ts +25 -8
  143. package/src/useSearch.tsx +5 -2
  144. package/src/utils.ts +9 -0
  145. package/build/cjs/CatchBoundary.js +0 -128
  146. package/build/cjs/CatchBoundary.js.map +0 -1
  147. package/build/cjs/Matches.js +0 -260
  148. package/build/cjs/Matches.js.map +0 -1
  149. package/build/cjs/RouterProvider.js.map +0 -1
  150. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -29
  151. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  152. package/build/cjs/awaited.js +0 -60
  153. package/build/cjs/awaited.js.map +0 -1
  154. package/build/cjs/defer.js +0 -42
  155. package/build/cjs/fileRoute.js +0 -31
  156. package/build/cjs/fileRoute.js.map +0 -1
  157. package/build/cjs/index.js.map +0 -1
  158. package/build/cjs/lazyRouteComponent.js +0 -54
  159. package/build/cjs/link.js +0 -224
  160. package/build/cjs/link.js.map +0 -1
  161. package/build/cjs/path.js.map +0 -1
  162. package/build/cjs/qss.js +0 -63
  163. package/build/cjs/qss.js.map +0 -1
  164. package/build/cjs/redirects.js +0 -28
  165. package/build/cjs/route.js +0 -292
  166. package/build/cjs/route.js.map +0 -1
  167. package/build/cjs/router.js +0 -1116
  168. package/build/cjs/router.js.map +0 -1
  169. package/build/cjs/routerContext.js +0 -42
  170. package/build/cjs/scroll-restoration.js.map +0 -1
  171. package/build/cjs/useBlocker.js +0 -55
  172. package/build/cjs/useNavigate.js +0 -88
  173. package/build/cjs/useParams.js +0 -27
  174. package/build/cjs/useRouteContext.js +0 -23
  175. package/build/cjs/useRouter.js +0 -44
  176. package/build/cjs/useRouterState.js +0 -24
  177. package/build/cjs/useSearch.js +0 -25
  178. package/build/cjs/useSearch.js.map +0 -1
  179. package/build/cjs/utils.js.map +0 -1
  180. package/build/esm/index.js +0 -2874
  181. package/build/esm/index.js.map +0 -1
  182. package/build/stats-html.html +0 -4838
  183. package/build/stats-react.json +0 -1471
  184. package/build/umd/index.development.js +0 -3573
  185. package/build/umd/index.development.js.map +0 -1
  186. package/build/umd/index.production.js +0 -22
  187. package/build/umd/index.production.js.map +0 -1
  188. /package/{build/types/CatchBoundary.d.ts → dist/cjs/CatchBoundary.d.cts} +0 -0
  189. /package/{build/types/awaited.d.ts → dist/cjs/awaited.d.cts} +0 -0
  190. /package/{build/types/defer.d.ts → dist/cjs/defer.d.cts} +0 -0
  191. /package/{build/types/fileRoute.d.ts → dist/cjs/fileRoute.d.cts} +0 -0
  192. /package/{build/types/index.d.ts → dist/cjs/index.d.cts} +0 -0
  193. /package/{build/types/lazyRouteComponent.d.ts → dist/cjs/lazyRouteComponent.d.cts} +0 -0
  194. /package/{build/types/location.d.ts → dist/cjs/location.d.cts} +0 -0
  195. /package/{build/types/qss.d.ts → dist/cjs/qss.d.cts} +0 -0
  196. /package/{build/types/redirects.d.ts → dist/cjs/redirects.d.cts} +0 -0
  197. /package/{build/types/route.d.ts → dist/cjs/route.d.cts} +0 -0
  198. /package/{build/types/routeInfo.d.ts → dist/cjs/routeInfo.d.cts} +0 -0
  199. /package/{build/types/router.d.ts → dist/cjs/router.d.cts} +0 -0
  200. /package/{build/types/routerContext.d.ts → dist/cjs/routerContext.d.cts} +0 -0
  201. /package/{build/types/scroll-restoration.d.ts → dist/cjs/scroll-restoration.d.cts} +0 -0
  202. /package/{build/types/searchParams.d.ts → dist/cjs/searchParams.d.cts} +0 -0
  203. /package/{build/types/useBlocker.d.ts → dist/cjs/useBlocker.d.cts} +0 -0
  204. /package/{build/types/useNavigate.d.ts → dist/cjs/useNavigate.d.cts} +0 -0
  205. /package/{build/types/useParams.d.ts → dist/cjs/useParams.d.cts} +0 -0
  206. /package/{build/types/useRouteContext.d.ts → dist/cjs/useRouteContext.d.cts} +0 -0
  207. /package/{build/types/useRouter.d.ts → dist/cjs/useRouter.d.cts} +0 -0
  208. /package/{build/types/useRouterState.d.ts → dist/cjs/useRouterState.d.cts} +0 -0
  209. /package/{build/types/useSearch.d.ts → dist/cjs/useSearch.d.cts} +0 -0
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const Matches = require("./Matches.cjs");
6
+ const useRouterState = require("./useRouterState.cjs");
7
+ const useRouter = require("./useRouter.cjs");
8
+ const utils = require("./utils.cjs");
9
+ function _interopNamespaceDefault(e) {
10
+ const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
11
+ if (e) {
12
+ for (const k in e) {
13
+ if (k !== "default") {
14
+ const d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: () => e[k]
18
+ });
19
+ }
20
+ }
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+ const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
26
+ const preloadWarning = "Error preloading route! ☝️";
27
+ function useLinkProps(options) {
28
+ const router = useRouter.useRouter();
29
+ const matchPathname = Matches.useMatch({
30
+ strict: false,
31
+ select: (s) => s.pathname
32
+ });
33
+ const {
34
+ // custom props
35
+ children,
36
+ target,
37
+ activeProps = () => ({ className: "active" }),
38
+ inactiveProps = () => ({}),
39
+ activeOptions,
40
+ disabled,
41
+ hash,
42
+ search,
43
+ params,
44
+ to,
45
+ state,
46
+ mask,
47
+ preload: userPreload,
48
+ preloadDelay: userPreloadDelay,
49
+ replace,
50
+ startTransition,
51
+ resetScroll,
52
+ // element props
53
+ style,
54
+ className,
55
+ onClick,
56
+ onFocus,
57
+ onMouseEnter,
58
+ onMouseLeave,
59
+ onTouchStart,
60
+ ...rest
61
+ } = options;
62
+ const dest = {
63
+ from: options.to ? matchPathname : void 0,
64
+ ...options
65
+ };
66
+ let type = "internal";
67
+ try {
68
+ new URL(`${to}`);
69
+ type = "external";
70
+ } catch {
71
+ }
72
+ if (type === "external") {
73
+ return {
74
+ href: to
75
+ };
76
+ }
77
+ const next = router.buildLocation(dest);
78
+ const preload = userPreload ?? router.options.defaultPreload;
79
+ const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
80
+ const isActive = useRouterState.useRouterState({
81
+ select: (s) => {
82
+ const currentPathSplit = s.location.pathname.split("/");
83
+ const nextPathSplit = next.pathname.split("/");
84
+ const pathIsFuzzyEqual = nextPathSplit.every(
85
+ (d, i) => d === currentPathSplit[i]
86
+ );
87
+ const pathTest = (activeOptions == null ? void 0 : activeOptions.exact) ? s.location.pathname === next.pathname : pathIsFuzzyEqual;
88
+ const hashTest = (activeOptions == null ? void 0 : activeOptions.includeHash) ? s.location.hash === next.hash : true;
89
+ const searchTest = (activeOptions == null ? void 0 : activeOptions.includeSearch) ?? true ? utils.deepEqual(s.location.search, next.search, !(activeOptions == null ? void 0 : activeOptions.exact)) : true;
90
+ return pathTest && hashTest && searchTest;
91
+ }
92
+ });
93
+ const handleClick = (e) => {
94
+ if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!target || target === "_self") && e.button === 0) {
95
+ e.preventDefault();
96
+ router.commitLocation({ ...next, replace, resetScroll, startTransition });
97
+ }
98
+ };
99
+ const handleFocus = (e) => {
100
+ if (preload) {
101
+ router.preloadRoute(dest).catch((err) => {
102
+ console.warn(err);
103
+ console.warn(preloadWarning);
104
+ });
105
+ }
106
+ };
107
+ const handleTouchStart = (e) => {
108
+ if (preload) {
109
+ router.preloadRoute(dest).catch((err) => {
110
+ console.warn(err);
111
+ console.warn(preloadWarning);
112
+ });
113
+ }
114
+ };
115
+ const handleEnter = (e) => {
116
+ const target2 = e.target || {};
117
+ if (preload) {
118
+ if (target2.preloadTimeout) {
119
+ return;
120
+ }
121
+ target2.preloadTimeout = setTimeout(() => {
122
+ target2.preloadTimeout = null;
123
+ router.preloadRoute(dest).catch((err) => {
124
+ console.warn(err);
125
+ console.warn(preloadWarning);
126
+ });
127
+ }, preloadDelay);
128
+ }
129
+ };
130
+ const handleLeave = (e) => {
131
+ const target2 = e.target || {};
132
+ if (target2.preloadTimeout) {
133
+ clearTimeout(target2.preloadTimeout);
134
+ target2.preloadTimeout = null;
135
+ }
136
+ };
137
+ const composeHandlers = (handlers) => (e) => {
138
+ if (e.persist)
139
+ e.persist();
140
+ handlers.filter(Boolean).forEach((handler) => {
141
+ if (e.defaultPrevented)
142
+ return;
143
+ handler(e);
144
+ });
145
+ };
146
+ const resolvedActiveProps = isActive ? utils.functionalUpdate(activeProps, {}) ?? {} : {};
147
+ const resolvedInactiveProps = isActive ? {} : utils.functionalUpdate(inactiveProps, {}) ?? {};
148
+ return {
149
+ ...resolvedActiveProps,
150
+ ...resolvedInactiveProps,
151
+ ...rest,
152
+ href: disabled ? void 0 : next.maskedLocation ? next.maskedLocation.href : next.href,
153
+ onClick: composeHandlers([onClick, handleClick]),
154
+ onFocus: composeHandlers([onFocus, handleFocus]),
155
+ onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
156
+ onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
157
+ onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
158
+ target,
159
+ style: {
160
+ ...style,
161
+ ...resolvedActiveProps.style,
162
+ ...resolvedInactiveProps.style
163
+ },
164
+ className: [
165
+ className,
166
+ resolvedActiveProps.className,
167
+ resolvedInactiveProps.className
168
+ ].filter(Boolean).join(" ") || void 0,
169
+ ...disabled ? {
170
+ role: "link",
171
+ "aria-disabled": true
172
+ } : void 0,
173
+ ["data-status"]: isActive ? "active" : void 0
174
+ };
175
+ }
176
+ const Link = React__namespace.forwardRef((props, ref) => {
177
+ const linkProps = useLinkProps(props);
178
+ return /* @__PURE__ */ jsxRuntime.jsx(
179
+ "a",
180
+ {
181
+ ...{
182
+ ref,
183
+ ...linkProps,
184
+ children: typeof props.children === "function" ? props.children({
185
+ isActive: linkProps["data-status"] === "active"
186
+ }) : props.children
187
+ }
188
+ }
189
+ );
190
+ });
191
+ function isCtrlEvent(e) {
192
+ return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
193
+ }
194
+ exports.Link = Link;
195
+ exports.useLinkProps = useLinkProps;
196
+ //# sourceMappingURL=link.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link.cjs","sources":["../../src/link.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMatch } from './Matches'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Trim } from './fileRoute'\nimport { AnyRoute, ReactNode, RootSearchSchema } from './route'\nimport { RouteByPath, RouteIds, RoutePaths } from './routeInfo'\nimport { RegisteredRouter } from './router'\nimport { LinkProps, UseLinkPropsOptions } from './useNavigate'\nimport {\n Expand,\n NoInfer,\n NonNullableUpdater,\n PickRequired,\n StringLiteral,\n Updater,\n WithoutEmpty,\n deepEqual,\n functionalUpdate,\n} from './utils'\nimport { HistoryState } from '@tanstack/history'\n\nexport type CleanPath<T extends string> = T extends `${infer L}//${infer R}`\n ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`>\n : T extends `${infer L}//`\n ? `${CleanPath<L>}/`\n : T extends `//${infer L}`\n ? `/${CleanPath<L>}`\n : T\n\nexport type Split<S, TIncludeTrailingSlash = true> = S extends unknown\n ? string extends S\n ? string[]\n : S extends string\n ? CleanPath<S> extends ''\n ? []\n : TIncludeTrailingSlash extends true\n ? CleanPath<S> extends `${infer T}/`\n ? [...Split<T>, '/']\n : CleanPath<S> extends `/${infer U}`\n ? Split<U>\n : CleanPath<S> extends `${infer T}/${infer U}`\n ? [...Split<T>, ...Split<U>]\n : [S]\n : CleanPath<S> extends `${infer T}/${infer U}`\n ? [...Split<T>, ...Split<U>]\n : S extends string\n ? [S]\n : never\n : never\n : never\n\nexport type ParsePathParams<T extends string> = keyof {\n [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}`\n ? L extends ''\n ? '_splat'\n : L\n : never]: K\n}\n\nexport type Join<T, Delimiter extends string = '/'> = T extends []\n ? ''\n : T extends [infer L extends string]\n ? L\n : T extends [infer L extends string, ...infer Tail extends [...string[]]]\n ? CleanPath<`${L}${Delimiter}${Join<Tail>}`>\n : never\n\nexport type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never\n\nexport type RelativeToPathAutoComplete<\n AllPaths extends string,\n TFrom extends string,\n TTo extends string,\n SplitPaths extends string[] = Split<AllPaths, false>,\n> = TTo extends `..${infer _}`\n ? SplitPaths extends [\n ...Split<ResolveRelativePath<TFrom, TTo>, false>,\n ...infer TToRest,\n ]\n ? `${CleanPath<\n Join<\n [\n ...Split<TTo, false>,\n ...(\n | TToRest\n | (Split<\n ResolveRelativePath<TFrom, TTo>,\n false\n >['length'] extends 1\n ? never\n : ['../'])\n ),\n ]\n >\n >}`\n : never\n : TTo extends `./${infer RestTTo}`\n ? SplitPaths extends [\n ...Split<TFrom, false>,\n ...Split<RestTTo, false>,\n ...infer RestPath,\n ]\n ? `${TTo}${Join<RestPath>}`\n : never\n :\n | (TFrom extends `/`\n ? never\n : SplitPaths extends [...Split<TFrom, false>, ...infer RestPath]\n ? Join<RestPath> extends { length: 0 }\n ? never\n : './'\n : never)\n | (TFrom extends `/` ? never : '../')\n | AllPaths\n\nexport type NavigateOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.\n replace?: boolean\n resetScroll?: boolean\n // If set to `true`, the link's underlying navigate() call will be wrapped in a `React.startTransition` call. Defaults to `true`.\n startTransition?: boolean\n}\n\nexport type ToOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptions<TRouteTree, TFrom, TTo> & {\n mask?: ToMaskOptions<TRouteTree, TMaskFrom, TMaskTo>\n}\n\nexport type ToMaskOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TMaskFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>,\n TMaskTo extends string = '',\n> = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {\n unmaskOnReload?: boolean\n}\n\nexport type ToSubOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>,\n TTo extends string = '',\n TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n> = {\n to?: ToPathOption<TRouteTree, TFrom, TTo>\n // The new has string or a function to update it\n hash?: true | Updater<string>\n // State to pass to the history stack\n state?: true | NonNullableUpdater<HistoryState>\n // The source route path. This is automatically set when using route-level APIs, but for type-safe relative routing on the router itself, this is required\n from?: StringLiteral<TFrom>\n // // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path\n} & CheckPath<TRouteTree, NoInfer<TResolved>, {}> &\n SearchParamOptions<TRouteTree, TFrom, TTo, TResolved> &\n PathParamOptions<TRouteTree, TFrom, TTo, TResolved>\n\ntype ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo)\n\ntype ParamVariant = 'PATH' | 'SEARCH'\ntype ExcludeRootSearchSchema<T, Excluded = Exclude<T, RootSearchSchema>> = [\n Excluded,\n] extends [never]\n ? {}\n : Excluded\n\ntype PostProcessParams<\n T,\n TParamVariant extends ParamVariant,\n> = TParamVariant extends 'SEARCH' ? ExcludeRootSearchSchema<T> : T\n\nexport type ParamOptions<\n TRouteTree extends AnyRoute,\n TFrom,\n TTo extends string,\n TResolved,\n TParamVariant extends ParamVariant,\n TFromRouteType extends\n | 'allParams'\n | 'fullSearchSchema' = TParamVariant extends 'PATH'\n ? 'allParams'\n : 'fullSearchSchema',\n TToRouteType extends\n | 'allParams'\n | 'fullSearchSchemaInput' = TParamVariant extends 'PATH'\n ? 'allParams'\n : 'fullSearchSchemaInput',\n TFromParams = PostProcessParams<\n RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType],\n TParamVariant\n >,\n TToIndex = TTo extends ''\n ? ''\n : RouteByPath<TRouteTree, `${TTo}/`> extends never\n ? TTo\n : `${TTo}/`,\n TToParams = TToIndex extends ''\n ? TFromParams\n : never extends TResolved\n ? PostProcessParams<\n RouteByPath<TRouteTree, TToIndex>['types'][TToRouteType],\n TParamVariant\n >\n : PostProcessParams<\n RouteByPath<TRouteTree, TResolved>['types'][TToRouteType],\n TParamVariant\n >,\n TReducer = ParamsReducer<TFromParams, TToParams>,\n> = Expand<WithoutEmpty<PickRequired<TToParams>>> extends never\n ? Partial<MakeParamOption<TParamVariant, true | TReducer>>\n : TFromParams extends Expand<WithoutEmpty<PickRequired<TToParams>>>\n ? MakeParamOption<TParamVariant, true | TReducer>\n : MakeParamOption<TParamVariant, TReducer>\n\ntype MakeParamOption<\n TParamVariant extends ParamVariant,\n T,\n> = TParamVariant extends 'PATH'\n ? MakePathParamOptions<T>\n : MakeSearchParamOptions<T>\ntype MakeSearchParamOptions<T> = { search: T }\ntype MakePathParamOptions<T> = { params: T }\n\nexport type SearchParamOptions<\n TRouteTree extends AnyRoute,\n TFrom,\n TTo extends string,\n TResolved,\n> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'SEARCH'>\n\nexport type PathParamOptions<\n TRouteTree extends AnyRoute,\n TFrom,\n TTo extends string,\n TResolved,\n> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'PATH'>\n\nexport type ToPathOption<\n TRouteTree extends AnyRoute = AnyRoute,\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string = '',\n> =\n | TTo\n | RelativeToPathAutoComplete<\n RoutePaths<TRouteTree>,\n NoInfer<TFrom> extends string ? NoInfer<TFrom> : '',\n NoInfer<TTo> & string\n >\n\nexport interface ActiveOptions {\n exact?: boolean\n includeHash?: boolean\n includeSearch?: boolean\n}\n\nexport type LinkOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n> = NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // The standard anchor tag target attribute\n target?: HTMLAnchorElement['target']\n // Defaults to `{ exact: false, includeHash: false }`\n activeOptions?: ActiveOptions\n // If set, will preload the linked route on hover and cache it for this many milliseconds in hopes that the user will eventually navigate there.\n preload?: false | 'intent'\n // Delay intent preloading by this many milliseconds. If the intent exits before this delay, the preload will be cancelled.\n preloadDelay?: number\n // If true, will render the link without the href attribute\n disabled?: boolean\n}\n\nexport type CheckPath<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<\n TPath,\n RoutePaths<TRouteTree>\n> extends never\n ? TPass\n : CheckPathError<TRouteTree, Exclude<TPath, RoutePaths<TRouteTree>>>\n\nexport type CheckPathError<TRouteTree extends AnyRoute, TInvalids> = {\n to: RoutePaths<TRouteTree>\n}\n\nexport type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string\n ? TTo extends string\n ? TTo extends '.'\n ? TFrom\n : TTo extends `./`\n ? Join<[TFrom, '/']>\n : TTo extends `./${infer TRest}`\n ? ResolveRelativePath<TFrom, TRest>\n : TTo extends `/${infer TRest}`\n ? TTo\n : Split<TTo> extends ['..', ...infer ToRest]\n ? Split<TFrom> extends [...infer FromRest, infer FromTail]\n ? ToRest extends ['/']\n ? Join<[...FromRest, '/']>\n : ResolveRelativePath<Join<FromRest>, Join<ToRest>>\n : never\n : Split<TTo> extends ['.', ...infer ToRest]\n ? ToRest extends ['/']\n ? Join<[TFrom, '/']>\n : ResolveRelativePath<TFrom, Join<ToRest>>\n : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>>\n : never\n : never\n\ntype LinkCurrentTargetElement = {\n preloadTimeout?: null | ReturnType<typeof setTimeout>\n}\n\nconst preloadWarning = 'Error preloading route! ☝️'\n\nexport function useLinkProps<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n): React.AnchorHTMLAttributes<HTMLAnchorElement> {\n const router = useRouter()\n const matchPathname = useMatch({\n strict: false,\n select: (s) => s.pathname,\n })\n\n const {\n // custom props\n children,\n target,\n activeProps = () => ({ className: 'active' }),\n inactiveProps = () => ({}),\n activeOptions,\n disabled,\n hash,\n search,\n params,\n to,\n state,\n mask,\n preload: userPreload,\n preloadDelay: userPreloadDelay,\n replace,\n startTransition,\n resetScroll,\n // element props\n style,\n className,\n onClick,\n onFocus,\n onMouseEnter,\n onMouseLeave,\n onTouchStart,\n ...rest\n } = options\n\n // If this link simply reloads the current route,\n // make sure it has a new key so it will trigger a data refresh\n\n // If this `to` is a valid external URL, return\n // null for LinkUtils\n\n const dest = {\n from: options.to ? matchPathname : undefined,\n ...options,\n }\n\n let type: 'internal' | 'external' = 'internal'\n\n try {\n new URL(`${to}`)\n type = 'external'\n } catch {}\n\n if (type === 'external') {\n return {\n href: to,\n }\n }\n\n const next = router.buildLocation(dest as any)\n const preload = userPreload ?? router.options.defaultPreload\n const preloadDelay =\n userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = useRouterState({\n select: (s) => {\n // Compare path/hash for matches\n const currentPathSplit = s.location.pathname.split('/')\n const nextPathSplit = next.pathname.split('/')\n const pathIsFuzzyEqual = nextPathSplit.every(\n (d, i) => d === currentPathSplit[i],\n )\n // Combine the matches based on user router.options\n const pathTest = activeOptions?.exact\n ? s.location.pathname === next.pathname\n : pathIsFuzzyEqual\n const hashTest = activeOptions?.includeHash\n ? s.location.hash === next.hash\n : true\n const searchTest =\n activeOptions?.includeSearch ?? true\n ? deepEqual(s.location.search, next.search, !activeOptions?.exact)\n : true\n\n // The final \"active\" test\n return pathTest && hashTest && searchTest\n },\n })\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n if (\n !disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!target || target === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n // All is well? Navigate!\n router.commitLocation({ ...next, replace, resetScroll, startTransition })\n }\n }\n\n // The click handler\n const handleFocus = (e: MouseEvent) => {\n if (preload) {\n router.preloadRoute(dest as any).catch((err) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n }\n }\n\n const handleTouchStart = (e: TouchEvent) => {\n if (preload) {\n router.preloadRoute(dest as any).catch((err) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n }\n }\n\n const handleEnter = (e: MouseEvent) => {\n const target = (e.target || {}) as LinkCurrentTargetElement\n\n if (preload) {\n if (target.preloadTimeout) {\n return\n }\n\n target.preloadTimeout = setTimeout(() => {\n target.preloadTimeout = null\n router.preloadRoute(dest as any).catch((err) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n }, preloadDelay)\n }\n }\n\n const handleLeave = (e: MouseEvent) => {\n const target = (e.target || {}) as LinkCurrentTargetElement\n\n if (target.preloadTimeout) {\n clearTimeout(target.preloadTimeout)\n target.preloadTimeout = null\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\n ? undefined\n : next.maskedLocation\n ? next.maskedLocation.href\n : next.href,\n onClick: composeHandlers([onClick, handleClick]),\n onFocus: composeHandlers([onFocus, handleFocus]),\n onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),\n onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),\n onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),\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 LinkComponent<TProps extends Record<string, any> = {}> {\n <\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n TMaskTo extends string = '',\n >(\n props: LinkProps<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n TProps &\n React.RefAttributes<HTMLAnchorElement>,\n ): ReactNode\n}\n\nexport const Link: LinkComponent = 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\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n"],"names":["useRouter","useMatch","useRouterState","deepEqual","target","functionalUpdate","React","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkUA,MAAM,iBAAiB;AAEhB,SAAS,aAOd,SAC+C;AAC/C,QAAM,SAASA,UAAAA;AACf,QAAM,gBAAgBC,QAAAA,SAAS;AAAA,IAC7B,QAAQ;AAAA,IACR,QAAQ,CAAC,MAAM,EAAE;AAAA,EAAA,CAClB;AAEK,QAAA;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,IACA,cAAc,OAAO,EAAE,WAAW;IAClC,gBAAgB,OAAO,CAAA;AAAA,IACvB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,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SAAS,YAAY,GAAe;AAC3B,SAAA,CAAC,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE;AACpD;;;"}
@@ -0,0 +1,85 @@
1
+ import * as React from 'react';
2
+ import { Trim } from './fileRoute';
3
+ import { AnyRoute, ReactNode, RootSearchSchema } from './route';
4
+ import { RouteByPath, RoutePaths } from './routeInfo';
5
+ import { RegisteredRouter } from './router';
6
+ import { LinkProps, UseLinkPropsOptions } from './useNavigate';
7
+ import { Expand, NoInfer, NonNullableUpdater, PickRequired, StringLiteral, Updater, WithoutEmpty } from './utils';
8
+ import { HistoryState } from '@tanstack/history';
9
+ export type CleanPath<T extends string> = T extends `${infer L}//${infer R}` ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`> : T extends `${infer L}//` ? `${CleanPath<L>}/` : T extends `//${infer L}` ? `/${CleanPath<L>}` : T;
10
+ export type Split<S, TIncludeTrailingSlash = true> = S extends unknown ? string extends S ? string[] : S extends string ? CleanPath<S> extends '' ? [] : TIncludeTrailingSlash extends true ? CleanPath<S> extends `${infer T}/` ? [...Split<T>, '/'] : CleanPath<S> extends `/${infer U}` ? Split<U> : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : [S] : CleanPath<S> extends `${infer T}/${infer U}` ? [...Split<T>, ...Split<U>] : S extends string ? [S] : never : never : never;
11
+ export type ParsePathParams<T extends string> = keyof {
12
+ [K in Trim<Split<T>[number], '_'> as K extends `$${infer L}` ? L extends '' ? '_splat' : L : never]: K;
13
+ };
14
+ export type Join<T, Delimiter extends string = '/'> = T extends [] ? '' : T extends [infer L extends string] ? L : T extends [infer L extends string, ...infer Tail extends [...string[]]] ? CleanPath<`${L}${Delimiter}${Join<Tail>}`> : never;
15
+ export type Last<T extends any[]> = T extends [...infer _, infer L] ? L : never;
16
+ export type RelativeToPathAutoComplete<AllPaths extends string, TFrom extends string, TTo extends string, SplitPaths extends string[] = Split<AllPaths, false>> = TTo extends `..${infer _}` ? SplitPaths extends [
17
+ ...Split<ResolveRelativePath<TFrom, TTo>, false>,
18
+ ...infer TToRest
19
+ ] ? `${CleanPath<Join<[
20
+ ...Split<TTo, false>,
21
+ ...(TToRest | (Split<ResolveRelativePath<TFrom, TTo>, false>['length'] extends 1 ? never : ['../']))
22
+ ]>>}` : never : TTo extends `./${infer RestTTo}` ? SplitPaths extends [
23
+ ...Split<TFrom, false>,
24
+ ...Split<RestTTo, false>,
25
+ ...infer RestPath
26
+ ] ? `${TTo}${Join<RestPath>}` : never : (TFrom extends `/` ? never : SplitPaths extends [...Split<TFrom, false>, ...infer RestPath] ? Join<RestPath> extends {
27
+ length: 0;
28
+ } ? never : './' : never) | (TFrom extends `/` ? never : '../') | AllPaths;
29
+ export type NavigateOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ToOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
30
+ replace?: boolean;
31
+ resetScroll?: boolean;
32
+ startTransition?: boolean;
33
+ };
34
+ export type ToOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TFrom, TTo> & {
35
+ mask?: ToMaskOptions<TRouteTree, TMaskFrom, TMaskTo>;
36
+ };
37
+ export type ToMaskOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TMaskFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>, TMaskTo extends string = ''> = ToSubOptions<TRouteTree, TMaskFrom, TMaskTo> & {
38
+ unmaskOnReload?: boolean;
39
+ };
40
+ export type ToSubOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = RoutePaths<TRouteTree>, TTo extends string = '', TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>> = {
41
+ to?: ToPathOption<TRouteTree, TFrom, TTo>;
42
+ hash?: true | Updater<string>;
43
+ state?: true | NonNullableUpdater<HistoryState>;
44
+ from?: StringLiteral<TFrom>;
45
+ } & CheckPath<TRouteTree, NoInfer<TResolved>, {}> & SearchParamOptions<TRouteTree, TFrom, TTo, TResolved> & PathParamOptions<TRouteTree, TFrom, TTo, TResolved>;
46
+ type ParamsReducer<TFrom, TTo> = TTo | ((current: TFrom) => TTo);
47
+ type ParamVariant = 'PATH' | 'SEARCH';
48
+ type ExcludeRootSearchSchema<T, Excluded = Exclude<T, RootSearchSchema>> = [
49
+ Excluded
50
+ ] extends [never] ? {} : Excluded;
51
+ type PostProcessParams<T, TParamVariant extends ParamVariant> = TParamVariant extends 'SEARCH' ? ExcludeRootSearchSchema<T> : T;
52
+ export type ParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string, TResolved, TParamVariant extends ParamVariant, TFromRouteType extends 'allParams' | 'fullSearchSchema' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchema', TToRouteType extends 'allParams' | 'fullSearchSchemaInput' = TParamVariant extends 'PATH' ? 'allParams' : 'fullSearchSchemaInput', TFromParams = PostProcessParams<RouteByPath<TRouteTree, TFrom>['types'][TFromRouteType], TParamVariant>, TToIndex = TTo extends '' ? '' : RouteByPath<TRouteTree, `${TTo}/`> extends never ? TTo : `${TTo}/`, TToParams = TToIndex extends '' ? TFromParams : never extends TResolved ? PostProcessParams<RouteByPath<TRouteTree, TToIndex>['types'][TToRouteType], TParamVariant> : PostProcessParams<RouteByPath<TRouteTree, TResolved>['types'][TToRouteType], TParamVariant>, TReducer = ParamsReducer<TFromParams, TToParams>> = Expand<WithoutEmpty<PickRequired<TToParams>>> extends never ? Partial<MakeParamOption<TParamVariant, true | TReducer>> : TFromParams extends Expand<WithoutEmpty<PickRequired<TToParams>>> ? MakeParamOption<TParamVariant, true | TReducer> : MakeParamOption<TParamVariant, TReducer>;
53
+ type MakeParamOption<TParamVariant extends ParamVariant, T> = TParamVariant extends 'PATH' ? MakePathParamOptions<T> : MakeSearchParamOptions<T>;
54
+ type MakeSearchParamOptions<T> = {
55
+ search: T;
56
+ };
57
+ type MakePathParamOptions<T> = {
58
+ params: T;
59
+ };
60
+ export type SearchParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string, TResolved> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'SEARCH'>;
61
+ export type PathParamOptions<TRouteTree extends AnyRoute, TFrom, TTo extends string, TResolved> = ParamOptions<TRouteTree, TFrom, TTo, TResolved, 'PATH'>;
62
+ export type ToPathOption<TRouteTree extends AnyRoute = AnyRoute, TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = ''> = TTo | RelativeToPathAutoComplete<RoutePaths<TRouteTree>, NoInfer<TFrom> extends string ? NoInfer<TFrom> : '', NoInfer<TTo> & string>;
63
+ export interface ActiveOptions {
64
+ exact?: boolean;
65
+ includeHash?: boolean;
66
+ includeSearch?: boolean;
67
+ }
68
+ export type LinkOptions<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''> = NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {
69
+ target?: HTMLAnchorElement['target'];
70
+ activeOptions?: ActiveOptions;
71
+ preload?: false | 'intent';
72
+ preloadDelay?: number;
73
+ disabled?: boolean;
74
+ };
75
+ export type CheckPath<TRouteTree extends AnyRoute, TPath, TPass> = Exclude<TPath, RoutePaths<TRouteTree>> extends never ? TPass : CheckPathError<TRouteTree, Exclude<TPath, RoutePaths<TRouteTree>>>;
76
+ export type CheckPathError<TRouteTree extends AnyRoute, TInvalids> = {
77
+ to: RoutePaths<TRouteTree>;
78
+ };
79
+ export type ResolveRelativePath<TFrom, TTo = '.'> = TFrom extends string ? TTo extends string ? TTo extends '.' ? TFrom : TTo extends `./` ? Join<[TFrom, '/']> : TTo extends `./${infer TRest}` ? ResolveRelativePath<TFrom, TRest> : TTo extends `/${infer TRest}` ? TTo : Split<TTo> extends ['..', ...infer ToRest] ? Split<TFrom> extends [...infer FromRest, infer FromTail] ? ToRest extends ['/'] ? Join<[...FromRest, '/']> : ResolveRelativePath<Join<FromRest>, Join<ToRest>> : never : Split<TTo> extends ['.', ...infer ToRest] ? ToRest extends ['/'] ? Join<[TFrom, '/']> : ResolveRelativePath<TFrom, Join<ToRest>> : CleanPath<Join<['/', ...Split<TFrom>, ...Split<TTo>]>> : never : never;
80
+ export declare function useLinkProps<TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(options: UseLinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): React.AnchorHTMLAttributes<HTMLAnchorElement>;
81
+ export interface LinkComponent<TProps extends Record<string, any> = {}> {
82
+ <TRouteTree extends AnyRoute = RegisteredRouter['routeTree'], TFrom extends RoutePaths<TRouteTree> | string = string, TTo extends string = '', TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom, TMaskTo extends string = ''>(props: LinkProps<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & TProps & React.RefAttributes<HTMLAnchorElement>): ReactNode;
83
+ }
84
+ export declare const Link: LinkComponent;
85
+ export {};
@@ -1,60 +1,47 @@
1
- /**
2
- * @tanstack/react-router/src/index.tsx
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
- var utils = require('./utils.js');
14
-
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const utils = require("./utils.cjs");
15
4
  function joinPaths(paths) {
16
- return cleanPath(paths.filter(Boolean).join('/'));
5
+ return cleanPath(paths.filter(Boolean).join("/"));
17
6
  }
18
7
  function cleanPath(path) {
19
- // remove double slashes
20
- return path.replace(/\/{2,}/g, '/');
8
+ return path.replace(/\/{2,}/g, "/");
21
9
  }
22
10
  function trimPathLeft(path) {
23
- return path === '/' ? path : path.replace(/^\/{1,}/, '');
11
+ return path === "/" ? path : path.replace(/^\/{1,}/, "");
24
12
  }
25
13
  function trimPathRight(path) {
26
- return path === '/' ? path : path.replace(/\/{1,}$/, '');
14
+ return path === "/" ? path : path.replace(/\/{1,}$/, "");
27
15
  }
28
16
  function trimPath(path) {
29
17
  return trimPathRight(trimPathLeft(path));
30
18
  }
31
19
  function resolvePath(basepath, base, to) {
32
- base = base.replace(new RegExp(`^${basepath}`), '/');
33
- to = to.replace(new RegExp(`^${basepath}`), '/');
20
+ base = base.replace(new RegExp(`^${basepath}`), "/");
21
+ to = to.replace(new RegExp(`^${basepath}`), "/");
34
22
  let baseSegments = parsePathname(base);
35
23
  const toSegments = parsePathname(to);
36
24
  toSegments.forEach((toSegment, index) => {
37
- if (toSegment.value === '/') {
25
+ var _a;
26
+ if (toSegment.value === "/") {
38
27
  if (!index) {
39
- // Leading slash
40
28
  baseSegments = [toSegment];
41
29
  } else if (index === toSegments.length - 1) {
42
- // Trailing Slash
43
30
  baseSegments.push(toSegment);
44
- } else ;
45
- } else if (toSegment.value === '..') {
46
- // Extra trailing slash? pop it off
47
- if (baseSegments.length > 1 && utils.last(baseSegments)?.value === '/') {
31
+ } else
32
+ ;
33
+ } else if (toSegment.value === "..") {
34
+ if (baseSegments.length > 1 && ((_a = utils.last(baseSegments)) == null ? void 0 : _a.value) === "/") {
48
35
  baseSegments.pop();
49
36
  }
50
37
  baseSegments.pop();
51
- } else if (toSegment.value === '.') {
38
+ } else if (toSegment.value === ".") {
52
39
  return;
53
40
  } else {
54
41
  baseSegments.push(toSegment);
55
42
  }
56
43
  });
57
- const joined = joinPaths([basepath, ...baseSegments.map(d => d.value)]);
44
+ const joined = joinPaths([basepath, ...baseSegments.map((d) => d.value)]);
58
45
  return cleanPath(joined);
59
46
  }
60
47
  function parsePathname(pathname) {
@@ -63,90 +50,97 @@ function parsePathname(pathname) {
63
50
  }
64
51
  pathname = cleanPath(pathname);
65
52
  const segments = [];
66
- if (pathname.slice(0, 1) === '/') {
53
+ if (pathname.slice(0, 1) === "/") {
67
54
  pathname = pathname.substring(1);
68
55
  segments.push({
69
- type: 'pathname',
70
- value: '/'
56
+ type: "pathname",
57
+ value: "/"
71
58
  });
72
59
  }
73
60
  if (!pathname) {
74
61
  return segments;
75
62
  }
76
-
77
- // Remove empty segments and '.' segments
78
- const split = pathname.split('/').filter(Boolean);
79
- segments.push(...split.map(part => {
80
- if (part === '$' || part === '*') {
81
- return {
82
- type: 'wildcard',
83
- value: part
84
- };
85
- }
86
- if (part.charAt(0) === '$') {
63
+ const split = pathname.split("/").filter(Boolean);
64
+ segments.push(
65
+ ...split.map((part) => {
66
+ if (part === "$" || part === "*") {
67
+ return {
68
+ type: "wildcard",
69
+ value: part
70
+ };
71
+ }
72
+ if (part.charAt(0) === "$") {
73
+ return {
74
+ type: "param",
75
+ value: part
76
+ };
77
+ }
87
78
  return {
88
- type: 'param',
79
+ type: "pathname",
89
80
  value: part
90
81
  };
91
- }
92
- return {
93
- type: 'pathname',
94
- value: part
95
- };
96
- }));
97
- if (pathname.slice(-1) === '/') {
82
+ })
83
+ );
84
+ if (pathname.slice(-1) === "/") {
98
85
  pathname = pathname.substring(1);
99
86
  segments.push({
100
- type: 'pathname',
101
- value: '/'
87
+ type: "pathname",
88
+ value: "/"
102
89
  });
103
90
  }
104
91
  return segments;
105
92
  }
106
- function interpolatePath(path, params, leaveWildcards = false) {
93
+ function interpolatePath({
94
+ path,
95
+ params,
96
+ leaveWildcards,
97
+ leaveParams
98
+ }) {
107
99
  const interpolatedPathSegments = parsePathname(path);
108
- return joinPaths(interpolatedPathSegments.map(segment => {
109
- if (segment.type === 'wildcard') {
110
- const value = params[segment.value];
111
- if (leaveWildcards) return `${segment.value}${value ?? ''}`;
112
- return value;
113
- }
114
- if (segment.type === 'param') {
115
- return params[segment.value.substring(1)] ?? 'undefined';
116
- }
117
- return segment.value;
118
- }));
100
+ return joinPaths(
101
+ interpolatedPathSegments.map((segment) => {
102
+ if (segment.type === "wildcard") {
103
+ const value = params[segment.value];
104
+ if (leaveWildcards)
105
+ return `${segment.value}${value ?? ""}`;
106
+ return value;
107
+ }
108
+ if (segment.type === "param") {
109
+ if (leaveParams) {
110
+ const value = params[segment.value];
111
+ return `${segment.value}${value ?? ""}`;
112
+ }
113
+ return params[segment.value.substring(1)] ?? "undefined";
114
+ }
115
+ return segment.value;
116
+ })
117
+ );
119
118
  }
120
119
  function matchPathname(basepath, currentPathname, matchLocation) {
121
120
  const pathParams = matchByPath(basepath, currentPathname, matchLocation);
122
- // const searchMatched = matchBySearch(location.search, matchLocation)
123
-
124
121
  if (matchLocation.to && !pathParams) {
125
122
  return;
126
123
  }
127
124
  return pathParams ?? {};
128
125
  }
129
126
  function removeBasepath(basepath, pathname) {
130
- return basepath != '/' ? pathname.substring(basepath.length) : pathname;
127
+ return basepath != "/" ? pathname.substring(basepath.length) : pathname;
131
128
  }
132
129
  function matchByPath(basepath, from, matchLocation) {
133
- // Remove the base path from the pathname
134
130
  from = removeBasepath(basepath, from);
135
- // Default to to $ (wildcard)
136
- const to = `${matchLocation.to ?? '$'}`;
137
- // Parse the from and to
131
+ const to = `${matchLocation.to ?? "$"}`;
138
132
  const baseSegments = parsePathname(from);
139
133
  const routeSegments = parsePathname(to);
140
- if (!from.startsWith('/')) {
134
+ if (!from.startsWith("/")) {
141
135
  baseSegments.unshift({
142
- type: 'pathname',
143
- value: '/'
136
+ type: "pathname",
137
+ value: "/"
144
138
  });
145
139
  }
146
- if (!to.startsWith('/')) {
140
+ if (!to.startsWith("/")) {
147
141
  routeSegments.unshift({
148
- type: 'pathname',
149
- value: '/'
142
+ type: "pathname",
143
+ value: "/"
150
144
  });
151
145
  }
152
146
  const params = {};
@@ -157,18 +151,17 @@ function matchByPath(basepath, from, matchLocation) {
157
151
  const isLastBaseSegment = i >= baseSegments.length - 1;
158
152
  const isLastRouteSegment = i >= routeSegments.length - 1;
159
153
  if (routeSegment) {
160
- if (routeSegment.type === 'wildcard') {
161
- if (baseSegment?.value) {
162
- const _splat = joinPaths(baseSegments.slice(i).map(d => d.value));
163
- // TODO: Deprecate *
164
- params['*'] = _splat;
165
- params['_splat'] = _splat;
154
+ if (routeSegment.type === "wildcard") {
155
+ if (baseSegment == null ? void 0 : baseSegment.value) {
156
+ const _splat = joinPaths(baseSegments.slice(i).map((d) => d.value));
157
+ params["*"] = _splat;
158
+ params["_splat"] = _splat;
166
159
  return true;
167
160
  }
168
161
  return false;
169
162
  }
170
- if (routeSegment.type === 'pathname') {
171
- if (routeSegment.value === '/' && !baseSegment?.value) {
163
+ if (routeSegment.type === "pathname") {
164
+ if (routeSegment.value === "/" && !(baseSegment == null ? void 0 : baseSegment.value)) {
172
165
  return true;
173
166
  }
174
167
  if (baseSegment) {
@@ -184,25 +177,24 @@ function matchByPath(basepath, from, matchLocation) {
184
177
  if (!baseSegment) {
185
178
  return false;
186
179
  }
187
- if (routeSegment.type === 'param') {
188
- if (baseSegment?.value === '/') {
180
+ if (routeSegment.type === "param") {
181
+ if ((baseSegment == null ? void 0 : baseSegment.value) === "/") {
189
182
  return false;
190
183
  }
191
- if (baseSegment.value.charAt(0) !== '$') {
184
+ if (baseSegment.value.charAt(0) !== "$") {
192
185
  params[routeSegment.value.substring(1)] = baseSegment.value;
193
186
  }
194
187
  }
195
188
  }
196
189
  if (!isLastBaseSegment && isLastRouteSegment) {
197
- params['**'] = joinPaths(baseSegments.slice(i + 1).map(d => d.value));
198
- return !!matchLocation.fuzzy && routeSegment?.value !== '/';
190
+ params["**"] = joinPaths(baseSegments.slice(i + 1).map((d) => d.value));
191
+ return !!matchLocation.fuzzy && (routeSegment == null ? void 0 : routeSegment.value) !== "/";
199
192
  }
200
193
  }
201
194
  return true;
202
195
  })();
203
- return isMatch ? params : undefined;
196
+ return isMatch ? params : void 0;
204
197
  }
205
-
206
198
  exports.cleanPath = cleanPath;
207
199
  exports.interpolatePath = interpolatePath;
208
200
  exports.joinPaths = joinPaths;
@@ -214,4 +206,4 @@ exports.resolvePath = resolvePath;
214
206
  exports.trimPath = trimPath;
215
207
  exports.trimPathLeft = trimPathLeft;
216
208
  exports.trimPathRight = trimPathRight;
217
- //# sourceMappingURL=path.js.map
209
+ //# sourceMappingURL=path.cjs.map