@tanstack/vue-router 1.167.0 → 1.167.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Asset.js +107 -151
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/Body.js +15 -24
- package/dist/esm/Body.js.map +1 -1
- package/dist/esm/CatchBoundary.js +112 -130
- package/dist/esm/CatchBoundary.js.map +1 -1
- package/dist/esm/ClientOnly.js +59 -29
- package/dist/esm/ClientOnly.js.map +1 -1
- package/dist/esm/HeadContent.dev.js +29 -23
- package/dist/esm/HeadContent.dev.js.map +1 -1
- package/dist/esm/HeadContent.js +21 -16
- package/dist/esm/HeadContent.js.map +1 -1
- package/dist/esm/Html.js +42 -61
- package/dist/esm/Html.js.map +1 -1
- package/dist/esm/Match.js +238 -319
- package/dist/esm/Match.js.map +1 -1
- package/dist/esm/Matches.js +127 -170
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +50 -65
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.js +31 -36
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/Scripts.js +79 -101
- package/dist/esm/Scripts.js.map +1 -1
- package/dist/esm/ScrollRestoration.js +25 -29
- package/dist/esm/ScrollRestoration.js.map +1 -1
- package/dist/esm/Transitioner.js +146 -164
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/esm/awaited.js +27 -34
- package/dist/esm/awaited.js.map +1 -1
- package/dist/esm/fileRoute.js +90 -92
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/headContentUtils.js +92 -123
- package/dist/esm/headContentUtils.js.map +1 -1
- package/dist/esm/index.dev.js +16 -118
- package/dist/esm/index.js +18 -119
- package/dist/esm/lazyRouteComponent.js +69 -82
- package/dist/esm/lazyRouteComponent.js.map +1 -1
- package/dist/esm/link.js +364 -385
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/matchContext.js +16 -11
- package/dist/esm/matchContext.js.map +1 -1
- package/dist/esm/not-found.js +30 -40
- package/dist/esm/not-found.js.map +1 -1
- package/dist/esm/renderRouteNotFound.js +20 -15
- package/dist/esm/renderRouteNotFound.js.map +1 -1
- package/dist/esm/route.js +196 -174
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/router.js +11 -11
- package/dist/esm/router.js.map +1 -1
- package/dist/esm/routerContext.js +10 -7
- package/dist/esm/routerContext.js.map +1 -1
- package/dist/esm/scroll-restoration.js +39 -50
- package/dist/esm/scroll-restoration.js.map +1 -1
- package/dist/esm/ssr/RouterClient.js +29 -43
- package/dist/esm/ssr/RouterClient.js.map +1 -1
- package/dist/esm/ssr/RouterServer.js +29 -32
- package/dist/esm/ssr/RouterServer.js.map +1 -1
- package/dist/esm/ssr/client.js +1 -4
- package/dist/esm/ssr/defaultRenderHandler.js +11 -13
- package/dist/esm/ssr/defaultRenderHandler.js.map +1 -1
- package/dist/esm/ssr/defaultStreamHandler.js +12 -15
- package/dist/esm/ssr/defaultStreamHandler.js.map +1 -1
- package/dist/esm/ssr/renderRouterToStream.js +47 -65
- package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +24 -32
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/ssr/server.js +3 -10
- package/dist/esm/useBlocker.js +243 -287
- package/dist/esm/useBlocker.js.map +1 -1
- package/dist/esm/useCanGoBack.js +6 -5
- package/dist/esm/useCanGoBack.js.map +1 -1
- package/dist/esm/useLoaderData.js +12 -11
- package/dist/esm/useLoaderData.js.map +1 -1
- package/dist/esm/useLoaderDeps.js +12 -14
- package/dist/esm/useLoaderDeps.js.map +1 -1
- package/dist/esm/useLocation.js +6 -7
- package/dist/esm/useLocation.js.map +1 -1
- package/dist/esm/useMatch.js +27 -35
- package/dist/esm/useMatch.js.map +1 -1
- package/dist/esm/useNavigate.js +18 -24
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js +13 -12
- package/dist/esm/useParams.js.map +1 -1
- package/dist/esm/useRouteContext.js +9 -8
- package/dist/esm/useRouteContext.js.map +1 -1
- package/dist/esm/useRouter.js +9 -8
- package/dist/esm/useRouter.js.map +1 -1
- package/dist/esm/useRouterState.js +18 -22
- package/dist/esm/useRouterState.js.map +1 -1
- package/dist/esm/useSearch.js +13 -12
- package/dist/esm/useSearch.js.map +1 -1
- package/dist/esm/utils.js +59 -38
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/dist/esm/index.dev.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/ssr/client.js.map +0 -1
- package/dist/esm/ssr/server.js.map +0 -1
package/dist/esm/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../src/link.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n deepEqual,\n exactPathTest,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { useIntersectionObserver } from './utils'\nimport { useMatches } from './Matches'\n\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type { AnchorHTMLAttributes, ReservedProps } from '@vue/runtime-dom'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\ntype EventHandler<TEvent = Event> = (e: TEvent) => void\n\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\ntype DataAttributes = {\n [K in `data-${string}`]?: unknown\n}\n\ntype LinkHTMLAttributes = AnchorHTMLAttributes &\n ReservedProps &\n DataAttributes & {\n // Vue's runtime-dom types use lowercase event names.\n // Also accept camelCase versions for external API compatibility.\n onMouseEnter?: EventHandler<MouseEvent>\n onMouseLeave?: EventHandler<MouseEvent>\n onMouseOver?: EventHandler<MouseEvent>\n onMouseOut?: EventHandler<MouseEvent>\n onTouchStart?: EventHandler<TouchEvent>\n\n // `disabled` is not a valid <a> attribute, but is useful when using `asChild`.\n disabled?: boolean\n }\n\ninterface StyledProps {\n class?: LinkHTMLAttributes['class']\n style?: LinkHTMLAttributes['style']\n [key: string]: unknown\n}\n\ntype PropsOfComponent<TComp> =\n // Functional components\n TComp extends (props: infer P, ...args: Array<unknown>) => any\n ? P\n : // Vue components (defineComponent, class components, etc)\n TComp extends Vue.Component<infer P>\n ? P\n : Record<string, unknown>\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): LinkHTMLAttributes {\n const router = useRouter()\n const isTransitioning = Vue.ref(false)\n let hasRenderFetched = false\n\n // Ensure router is defined before proceeding\n if (!router) {\n console.warn('useRouter must be used inside a <RouterProvider> component!')\n return Vue.computed(() => ({})) as unknown as LinkHTMLAttributes\n }\n\n // Determine if the link is external or internal\n const type = Vue.computed(() => {\n try {\n new URL(`${options.to}`)\n return 'external'\n } catch {\n return 'internal'\n }\n })\n\n const buildLocationKey = useRouterState({\n select: (s) => {\n const leaf = s.matches[s.matches.length - 1]\n return {\n search: leaf?.search,\n hash: s.location.hash,\n path: leaf?.pathname, // path + params\n }\n },\n })\n\n // when `from` is not supplied, use the leaf route of the current matches as the `from` location\n const from = useMatches({\n select: (matches) => options.from ?? matches[matches.length - 1]?.fullPath,\n })\n\n const _options = Vue.computed(() => ({\n ...options,\n from: from.value,\n }))\n\n const next = Vue.computed(() => {\n // Depend on search to rebuild when search changes\n buildLocationKey.value\n return router.buildLocation(_options.value as any)\n })\n\n const preload = Vue.computed(() => {\n if (_options.value.reloadDocument) {\n return false\n }\n return options.preload ?? router.options.defaultPreload\n })\n\n const preloadDelay = Vue.computed(\n () => options.preloadDelay ?? router.options.defaultPreloadDelay ?? 0,\n )\n\n const isActive = useRouterState({\n select: (s) => {\n const activeOptions = options.activeOptions\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next.value.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPathSplit = removeTrailingSlash(\n s.location.pathname,\n router.basepath,\n ).split('/')\n const nextPathSplit = removeTrailingSlash(\n next.value?.pathname,\n router.basepath,\n )?.split('/')\n\n const pathIsFuzzyEqual = nextPathSplit?.every(\n (d, i) => d === currentPathSplit[i],\n )\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next.value.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n return s.location.hash === next.value.hash\n }\n return true\n },\n })\n\n const doPreload = () =>\n router.preloadRoute(_options.value as any).catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const ref = Vue.ref<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: () => !!options.disabled || !(preload.value === 'viewport') },\n )\n\n Vue.effect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!options.disabled && preload.value === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n // Create safe props that can be spread\n const getPropsSafeToSpread = () => {\n const result: Record<string, any> = {}\n const optionRecord = options as unknown as Record<string, unknown>\n for (const key in options) {\n if (\n ![\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'children',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n '_asChild',\n 'from',\n 'additionalProps',\n ].includes(key)\n ) {\n result[key] = optionRecord[key]\n }\n }\n return result\n }\n\n if (type.value === 'external') {\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(options.to as string, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${options.to}`)\n }\n // Return props without href to prevent navigation\n const safeProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n ref,\n // No href attribute - blocks the dangerous protocol\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseEnter: options.onMouseEnter,\n onMouseLeave: options.onMouseLeave,\n onMouseOver: options.onMouseOver,\n onMouseOut: options.onMouseOut,\n onTouchStart: options.onTouchStart,\n }\n\n // Remove undefined values\n Object.keys(safeProps).forEach((key) => {\n if (safeProps[key] === undefined) {\n delete safeProps[key]\n }\n })\n\n return Vue.computed(\n () => safeProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // External links just have simple props\n const externalProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n ref,\n href: options.to,\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseEnter: options.onMouseEnter,\n onMouseLeave: options.onMouseLeave,\n onMouseOver: options.onMouseOver,\n onMouseOut: options.onMouseOut,\n onTouchStart: options.onTouchStart,\n }\n\n // Remove undefined values\n Object.keys(externalProps).forEach((key) => {\n if (externalProps[key] === undefined) {\n delete externalProps[key]\n }\n })\n\n return Vue.computed(\n () => externalProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // The click handler\n const handleClick = (e: PointerEvent): void => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n )?.getAttribute('target')\n const effectiveTarget =\n options.target !== undefined ? options.target : elementTarget\n\n if (\n !options.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n // Don't prevent default or handle navigation if reloadDocument is true\n if (_options.value.reloadDocument) {\n return\n }\n\n e.preventDefault()\n\n isTransitioning.value = true\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n isTransitioning.value = false\n })\n\n // All is well? Navigate!\n router.navigate({\n ..._options.value,\n replace: options.replace,\n resetScroll: options.resetScroll,\n hashScrollIntoView: options.hashScrollIntoView,\n startTransition: options.startTransition,\n viewTransition: options.viewTransition,\n ignoreBlocker: options.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n\n if (!preloadDelay.value) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay.value),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (options.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n // Helper to compose event handlers - with explicit return type and better type handling\n function composeEventHandlers<T extends Event>(\n handlers: Array<EventHandler<T> | undefined>,\n ): (e: T) => void {\n return (event: T) => {\n for (const handler of handlers) {\n if (handler) {\n handler(event)\n }\n }\n }\n }\n\n // Get the active and inactive props\n const resolvedActiveProps = Vue.computed<StyledProps>(() => {\n const activeProps = options.activeProps || (() => ({ class: 'active' }))\n const props = isActive.value\n ? typeof activeProps === 'function'\n ? activeProps()\n : activeProps\n : {}\n\n return props || { class: undefined, style: undefined }\n })\n\n const resolvedInactiveProps = Vue.computed<StyledProps>(() => {\n const inactiveProps = options.inactiveProps || (() => ({}))\n const props = isActive.value\n ? {}\n : typeof inactiveProps === 'function'\n ? inactiveProps()\n : inactiveProps\n\n return props || { class: undefined, style: undefined }\n })\n\n const resolvedClassName = Vue.computed(() => {\n const classes = [\n options.class,\n resolvedActiveProps.value?.class,\n resolvedInactiveProps.value?.class,\n ].filter(Boolean)\n return classes.length ? classes.join(' ') : undefined\n })\n\n const resolvedStyle = Vue.computed(() => {\n const result: Record<string, string | number> = {}\n\n // Merge styles from all sources\n if (options.style) {\n Object.assign(result, options.style)\n }\n\n if (resolvedActiveProps.value?.style) {\n Object.assign(result, resolvedActiveProps.value.style)\n }\n\n if (resolvedInactiveProps.value?.style) {\n Object.assign(result, resolvedInactiveProps.value.style)\n }\n\n return Object.keys(result).length > 0 ? result : undefined\n })\n\n const href = Vue.computed(() => {\n if (options.disabled) {\n return undefined\n }\n const nextLocation = next.value\n const location = nextLocation?.maskedLocation ?? nextLocation\n\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const publicHref = location?.publicHref\n if (!publicHref) return undefined\n\n const external = location?.external\n if (external) return publicHref\n\n return router.history.createHref(publicHref) || '/'\n })\n\n // Create static event handlers that don't change between renders\n const staticEventHandlers = {\n onClick: composeEventHandlers<PointerEvent>([\n options.onClick,\n handleClick,\n ]) as any,\n onBlur: composeEventHandlers<FocusEvent>([\n options.onBlur,\n handleLeave,\n ]) as any,\n onFocus: composeEventHandlers<FocusEvent>([\n options.onFocus,\n enqueueIntentPreload,\n ]) as any,\n onMouseenter: composeEventHandlers<MouseEvent>([\n options.onMouseEnter,\n enqueueIntentPreload,\n ]) as any,\n onMouseover: composeEventHandlers<MouseEvent>([\n options.onMouseOver,\n enqueueIntentPreload,\n ]) as any,\n onMouseleave: composeEventHandlers<MouseEvent>([\n options.onMouseLeave,\n handleLeave,\n ]) as any,\n onMouseout: composeEventHandlers<MouseEvent>([\n options.onMouseOut,\n handleLeave,\n ]) as any,\n onTouchstart: composeEventHandlers<TouchEvent>([\n options.onTouchStart,\n handleTouchStart,\n ]) as any,\n }\n\n // Compute all props synchronously to avoid hydration mismatches\n // Using Vue.computed ensures props are calculated at render time, not after\n const computedProps = Vue.computed<LinkHTMLAttributes>(() => {\n const result: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n href: href.value,\n ref,\n ...staticEventHandlers,\n disabled: !!options.disabled,\n target: options.target,\n }\n\n // Add style if present\n if (resolvedStyle.value) {\n result.style = resolvedStyle.value\n }\n\n // Add class if present\n if (resolvedClassName.value) {\n result.class = resolvedClassName.value\n }\n\n // Add disabled props\n if (options.disabled) {\n result.role = 'link'\n result['aria-disabled'] = true\n }\n\n // Add active status\n if (isActive.value) {\n result['data-status'] = 'active'\n result['aria-current'] = 'page'\n }\n\n // Add transitioning status\n if (isTransitioning.value) {\n result['data-transitioning'] = 'transitioning'\n }\n\n // Merge active/inactive props (excluding class and style which are handled above)\n const activeP = resolvedActiveProps.value\n const inactiveP = resolvedInactiveProps.value\n\n for (const key of Object.keys(activeP)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = (activeP as any)[key]\n }\n }\n for (const key of Object.keys(inactiveP)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = (inactiveP as any)[key]\n }\n }\n\n return result\n })\n\n // Return the computed ref itself - callers should access .value\n return computedProps as unknown as LinkHTMLAttributes\n}\n\n// Type definitions\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkHTMLAttributes\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n (TComp extends keyof HTMLElementTagNameMap\n ? LinkHTMLAttributes\n : PropsOfComponent<TComp>) & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\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 | Vue.VNodeChild\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Vue.VNodeChild)\n}\n\ntype LinkComponentVueProps<TComp> = TComp extends keyof HTMLElementTagNameMap\n ? Omit<LinkHTMLAttributes, keyof CreateLinkProps>\n : Omit<PropsOfComponent<TComp>, keyof CreateLinkProps>\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentVueProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Vue.VNode\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Vue.VNode\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Vue.VNode>,\n): LinkComponent<TComp> {\n return Vue.defineComponent({\n name: 'CreatedLink',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => Vue.h(LinkImpl as any, { ...attrs, _asChild: Comp }, slots)\n },\n }) as any\n}\n\nconst LinkImpl = Vue.defineComponent({\n name: 'Link',\n inheritAttrs: false,\n props: [\n '_asChild',\n 'to',\n 'preload',\n 'preloadDelay',\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'from',\n 'search',\n 'params',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'disabled',\n 'additionalProps',\n 'viewTransition',\n 'resetScroll',\n 'startTransition',\n 'hashScrollIntoView',\n 'replace',\n 'ignoreBlocker',\n 'target',\n ],\n setup(props, { attrs, slots }) {\n // Call useLinkProps ONCE during setup with combined props and attrs\n // The returned object is a computed ref that updates reactively\n const allProps = { ...props, ...attrs }\n const linkPropsComputed = useLinkProps(\n allProps as any,\n ) as unknown as Vue.ComputedRef<LinkHTMLAttributes>\n\n return () => {\n const Component = props._asChild || 'a'\n\n // Access the computed value to get fresh props each render\n const linkProps = linkPropsComputed.value\n\n const isActive = linkProps['data-status'] === 'active'\n const isTransitioning =\n linkProps['data-transitioning'] === 'transitioning'\n\n // Create the slot content or empty array if no default slot\n const slotContent = slots.default\n ? slots.default({\n isActive,\n isTransitioning,\n })\n : []\n\n // Special handling for SVG links - wrap an <a> inside the SVG\n if (Component === 'svg') {\n // Create props without class for svg link\n const svgLinkProps = { ...linkProps }\n delete svgLinkProps.class\n return Vue.h('svg', {}, [Vue.h('a', svgLinkProps, slotContent)])\n }\n\n // For custom functional components (non-string), pass children as a prop\n // since they may expect children as a prop like in Solid\n if (typeof Component !== 'string') {\n return Vue.h(\n Component,\n { ...linkProps, children: slotContent },\n slotContent,\n )\n }\n\n // Return the component with props and children\n return Vue.h(Component, linkProps, slotContent)\n }\n },\n})\n\n/**\n * Link component with proper TypeScript generics support\n */\nexport const Link = LinkImpl as unknown as Vue.Component<unknown> &\n Vue.Component<CreateLinkProps> &\n LinkComponent<'a'>\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"names":["timeoutMap","WeakMap","useLinkProps","options","router","useRouter","isTransitioning","Vue","ref","hasRenderFetched","console","warn","computed","type","URL","to","buildLocationKey","useRouterState","select","s","leaf","matches","length","search","hash","location","path","pathname","from","useMatches","fullPath","_options","value","next","buildLocation","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","exactPathTest","basepath","currentPathSplit","removeTrailingSlash","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","deepEqual","partial","ignoreUndefined","explicitUndefined","includeHash","doPreload","preloadRoute","catch","err","preloadWarning","preloadViewportIoCallback","entry","isIntersecting","useIntersectionObserver","rootMargin","disabled","effect","getPropsSafeToSpread","result","optionRecord","key","includes","isDangerousProtocol","protocolAllowlist","process","env","NODE_ENV","safeProps","target","style","class","onClick","onBlur","onFocus","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","onTouchStart","Object","keys","forEach","undefined","externalProps","href","handleClick","e","elementTarget","currentTarget","getAttribute","effectiveTarget","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","eventTarget","has","set","setTimeout","delete","handleTouchStart","_","handleLeave","id","get","clearTimeout","composeEventHandlers","handlers","event","handler","resolvedActiveProps","activeProps","props","resolvedInactiveProps","inactiveProps","resolvedClassName","classes","filter","Boolean","join","resolvedStyle","assign","nextLocation","maskedLocation","publicHref","external","history","createHref","staticEventHandlers","onMouseenter","onMouseover","onMouseleave","onMouseout","onTouchstart","computedProps","role","activeP","inactiveP","createLink","Comp","defineComponent","name","inheritAttrs","setup","attrs","slots","h","LinkImpl","_asChild","allProps","linkPropsComputed","Component","linkProps","slotContent","default","svgLinkPro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AAWI,UAAUH;AAAAA,WAC1BA,WACF;AAAA,MACF;AAGA,aAAO5K,IAAIqK,EAAEK,WAAWC,WAAWC,WAAW;AAAA,IAChD;AAAA,EACF;AACF,CAAC;AAKM,MAAMI,OAAOV;AAIpB,SAASlE,YAAYL,GAAe;AAClC,SAAO,CAAC,EAAEA,EAAEkF,WAAWlF,EAAEmF,UAAUnF,EAAEoF,WAAWpF,EAAEqF;AACpD;AAkBO,MAAMC,cAAmCzL,aAAY;AAC1D,SAAOA;AACT;"}
|
|
1
|
+
{"version":3,"file":"link.js","names":["Vue","deepEqual","exactPathTest","isDangerousProtocol","preloadWarning","removeTrailingSlash","useRouterState","useRouter","useIntersectionObserver","useMatches","timeoutMap","WeakMap","useLinkProps","options","router","isTransitioning","ref","hasRenderFetched","console","warn","computed","type","URL","to","buildLocationKey","select","s","leaf","matches","length","search","hash","location","path","pathname","from","fullPath","_options","value","next","buildLocation","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","basepath","currentPathSplit","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","partial","ignoreUndefined","explicitUndefined","includeHash","doPreload","preloadRoute","catch","err","preloadViewportIoCallback","entry","isIntersecting","rootMargin","disabled","effect","getPropsSafeToSpread","result","optionRecord","key","includes","protocolAllowlist","process","env","NODE_ENV","safeProps","target","style","class","onClick","onBlur","onFocus","onMouseEnter","onMouseLeave","onMouseOver","onMouseOut","onTouchStart","Object","keys","forEach","undefined","externalProps","href","handleClick","e","elementTarget","currentTarget","getAttribute","effectiveTarget","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","enqueueIntentPreload","eventTarget","has","set","setTimeout","delete","handleTouchStart","_","handleLeave","id","get","clearTimeout","composeEventHandlers","handlers","event","handler","resolvedActiveProps","activeProps","props","resolvedInactiveProps","inactiveProps","resolvedClassName","classes","filter","Boolean","join","resolvedStyle","assign","nextLocation","maskedLocation","publicHref","external","history","createHref","staticEventHandlers","onMouseenter","onMouseover","onMouseleave","onMouseout","onTouchstart","computedProps","role","activeP","inactiveP","createLink","Comp","defineComponent","name","inheritAttrs","setup","attrs","slots","h","LinkImpl","_asChild","allProps","linkPropsComputed","Component","linkProps","slotContent","default","svgLinkProps","children","Link","metaKey","altKey","ctrlKey","shiftKey","linkOptions"],"sources":["../../src/link.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport {\n deepEqual,\n exactPathTest,\n isDangerousProtocol,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\n\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { useIntersectionObserver } from './utils'\nimport { useMatches } from './Matches'\n\nimport type {\n AnyRouter,\n Constrain,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type { AnchorHTMLAttributes, ReservedProps } from '@vue/runtime-dom'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\n\ntype EventHandler<TEvent = Event> = (e: TEvent) => void\n\nconst timeoutMap = new WeakMap<EventTarget, ReturnType<typeof setTimeout>>()\n\ntype DataAttributes = {\n [K in `data-${string}`]?: unknown\n}\n\ntype LinkHTMLAttributes = AnchorHTMLAttributes &\n ReservedProps &\n DataAttributes & {\n // Vue's runtime-dom types use lowercase event names.\n // Also accept camelCase versions for external API compatibility.\n onMouseEnter?: EventHandler<MouseEvent>\n onMouseLeave?: EventHandler<MouseEvent>\n onMouseOver?: EventHandler<MouseEvent>\n onMouseOut?: EventHandler<MouseEvent>\n onTouchStart?: EventHandler<TouchEvent>\n\n // `disabled` is not a valid <a> attribute, but is useful when using `asChild`.\n disabled?: boolean\n }\n\ninterface StyledProps {\n class?: LinkHTMLAttributes['class']\n style?: LinkHTMLAttributes['style']\n [key: string]: unknown\n}\n\ntype PropsOfComponent<TComp> =\n // Functional components\n TComp extends (props: infer P, ...args: Array<unknown>) => any\n ? P\n : // Vue components (defineComponent, class components, etc)\n TComp extends Vue.Component<infer P>\n ? P\n : Record<string, unknown>\n\nexport function useLinkProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '',\n>(\n options: UseLinkPropsOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): LinkHTMLAttributes {\n const router = useRouter()\n const isTransitioning = Vue.ref(false)\n let hasRenderFetched = false\n\n // Ensure router is defined before proceeding\n if (!router) {\n console.warn('useRouter must be used inside a <RouterProvider> component!')\n return Vue.computed(() => ({})) as unknown as LinkHTMLAttributes\n }\n\n // Determine if the link is external or internal\n const type = Vue.computed(() => {\n try {\n new URL(`${options.to}`)\n return 'external'\n } catch {\n return 'internal'\n }\n })\n\n const buildLocationKey = useRouterState({\n select: (s) => {\n const leaf = s.matches[s.matches.length - 1]\n return {\n search: leaf?.search,\n hash: s.location.hash,\n path: leaf?.pathname, // path + params\n }\n },\n })\n\n // when `from` is not supplied, use the leaf route of the current matches as the `from` location\n const from = useMatches({\n select: (matches) => options.from ?? matches[matches.length - 1]?.fullPath,\n })\n\n const _options = Vue.computed(() => ({\n ...options,\n from: from.value,\n }))\n\n const next = Vue.computed(() => {\n // Depend on search to rebuild when search changes\n buildLocationKey.value\n return router.buildLocation(_options.value as any)\n })\n\n const preload = Vue.computed(() => {\n if (_options.value.reloadDocument) {\n return false\n }\n return options.preload ?? router.options.defaultPreload\n })\n\n const preloadDelay = Vue.computed(\n () => options.preloadDelay ?? router.options.defaultPreloadDelay ?? 0,\n )\n\n const isActive = useRouterState({\n select: (s) => {\n const activeOptions = options.activeOptions\n if (activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next.value.pathname,\n router.basepath,\n )\n if (!testExact) {\n return false\n }\n } else {\n const currentPathSplit = removeTrailingSlash(\n s.location.pathname,\n router.basepath,\n ).split('/')\n const nextPathSplit = removeTrailingSlash(\n next.value?.pathname,\n router.basepath,\n )?.split('/')\n\n const pathIsFuzzyEqual = nextPathSplit?.every(\n (d, i) => d === currentPathSplit[i],\n )\n if (!pathIsFuzzyEqual) {\n return false\n }\n }\n\n if (activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next.value.search, {\n partial: !activeOptions?.exact,\n ignoreUndefined: !activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (activeOptions?.includeHash) {\n return s.location.hash === next.value.hash\n }\n return true\n },\n })\n\n const doPreload = () =>\n router.preloadRoute(_options.value as any).catch((err: any) => {\n console.warn(err)\n console.warn(preloadWarning)\n })\n\n const preloadViewportIoCallback = (\n entry: IntersectionObserverEntry | undefined,\n ) => {\n if (entry?.isIntersecting) {\n doPreload()\n }\n }\n\n const ref = Vue.ref<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: () => !!options.disabled || !(preload.value === 'viewport') },\n )\n\n Vue.effect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!options.disabled && preload.value === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n // Create safe props that can be spread\n const getPropsSafeToSpread = () => {\n const result: Record<string, any> = {}\n const optionRecord = options as unknown as Record<string, unknown>\n for (const key in options) {\n if (\n ![\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'children',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onBlur',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n '_asChild',\n 'from',\n 'additionalProps',\n ].includes(key)\n ) {\n result[key] = optionRecord[key]\n }\n }\n return result\n }\n\n if (type.value === 'external') {\n // Block dangerous protocols like javascript:, blob:, data:\n if (isDangerousProtocol(options.to as string, router.protocolAllowlist)) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(`Blocked Link with dangerous protocol: ${options.to}`)\n }\n // Return props without href to prevent navigation\n const safeProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n ref,\n // No href attribute - blocks the dangerous protocol\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseEnter: options.onMouseEnter,\n onMouseLeave: options.onMouseLeave,\n onMouseOver: options.onMouseOver,\n onMouseOut: options.onMouseOut,\n onTouchStart: options.onTouchStart,\n }\n\n // Remove undefined values\n Object.keys(safeProps).forEach((key) => {\n if (safeProps[key] === undefined) {\n delete safeProps[key]\n }\n })\n\n return Vue.computed(\n () => safeProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // External links just have simple props\n const externalProps: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n ref,\n href: options.to,\n target: options.target,\n disabled: options.disabled,\n style: options.style,\n class: options.class,\n onClick: options.onClick,\n onBlur: options.onBlur,\n onFocus: options.onFocus,\n onMouseEnter: options.onMouseEnter,\n onMouseLeave: options.onMouseLeave,\n onMouseOver: options.onMouseOver,\n onMouseOut: options.onMouseOut,\n onTouchStart: options.onTouchStart,\n }\n\n // Remove undefined values\n Object.keys(externalProps).forEach((key) => {\n if (externalProps[key] === undefined) {\n delete externalProps[key]\n }\n })\n\n return Vue.computed(\n () => externalProps as LinkHTMLAttributes,\n ) as unknown as LinkHTMLAttributes\n }\n\n // The click handler\n const handleClick = (e: PointerEvent): void => {\n // Check actual element's target attribute as fallback\n const elementTarget = (\n e.currentTarget as HTMLAnchorElement | SVGAElement\n )?.getAttribute('target')\n const effectiveTarget =\n options.target !== undefined ? options.target : elementTarget\n\n if (\n !options.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n // Don't prevent default or handle navigation if reloadDocument is true\n if (_options.value.reloadDocument) {\n return\n }\n\n e.preventDefault()\n\n isTransitioning.value = true\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n isTransitioning.value = false\n })\n\n // All is well? Navigate!\n router.navigate({\n ..._options.value,\n replace: options.replace,\n resetScroll: options.resetScroll,\n hashScrollIntoView: options.hashScrollIntoView,\n startTransition: options.startTransition,\n viewTransition: options.viewTransition,\n ignoreBlocker: options.ignoreBlocker,\n })\n }\n }\n\n const enqueueIntentPreload = (e: MouseEvent | FocusEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n\n if (!preloadDelay.value) {\n doPreload()\n return\n }\n\n const eventTarget = e.currentTarget || e.target\n\n if (!eventTarget || timeoutMap.has(eventTarget)) return\n\n timeoutMap.set(\n eventTarget,\n setTimeout(() => {\n timeoutMap.delete(eventTarget)\n doPreload()\n }, preloadDelay.value),\n )\n }\n\n const handleTouchStart = (_: TouchEvent) => {\n if (options.disabled || preload.value !== 'intent') return\n doPreload()\n }\n\n const handleLeave = (e: MouseEvent | FocusEvent) => {\n if (options.disabled) return\n const eventTarget = e.currentTarget || e.target\n\n if (eventTarget) {\n const id = timeoutMap.get(eventTarget)\n clearTimeout(id)\n timeoutMap.delete(eventTarget)\n }\n }\n\n // Helper to compose event handlers - with explicit return type and better type handling\n function composeEventHandlers<T extends Event>(\n handlers: Array<EventHandler<T> | undefined>,\n ): (e: T) => void {\n return (event: T) => {\n for (const handler of handlers) {\n if (handler) {\n handler(event)\n }\n }\n }\n }\n\n // Get the active and inactive props\n const resolvedActiveProps = Vue.computed<StyledProps>(() => {\n const activeProps = options.activeProps || (() => ({ class: 'active' }))\n const props = isActive.value\n ? typeof activeProps === 'function'\n ? activeProps()\n : activeProps\n : {}\n\n return props || { class: undefined, style: undefined }\n })\n\n const resolvedInactiveProps = Vue.computed<StyledProps>(() => {\n const inactiveProps = options.inactiveProps || (() => ({}))\n const props = isActive.value\n ? {}\n : typeof inactiveProps === 'function'\n ? inactiveProps()\n : inactiveProps\n\n return props || { class: undefined, style: undefined }\n })\n\n const resolvedClassName = Vue.computed(() => {\n const classes = [\n options.class,\n resolvedActiveProps.value?.class,\n resolvedInactiveProps.value?.class,\n ].filter(Boolean)\n return classes.length ? classes.join(' ') : undefined\n })\n\n const resolvedStyle = Vue.computed(() => {\n const result: Record<string, string | number> = {}\n\n // Merge styles from all sources\n if (options.style) {\n Object.assign(result, options.style)\n }\n\n if (resolvedActiveProps.value?.style) {\n Object.assign(result, resolvedActiveProps.value.style)\n }\n\n if (resolvedInactiveProps.value?.style) {\n Object.assign(result, resolvedInactiveProps.value.style)\n }\n\n return Object.keys(result).length > 0 ? result : undefined\n })\n\n const href = Vue.computed(() => {\n if (options.disabled) {\n return undefined\n }\n const nextLocation = next.value\n const location = nextLocation?.maskedLocation ?? nextLocation\n\n // Use publicHref - it contains the correct href for display\n // When a rewrite changes the origin, publicHref is the full URL\n // Otherwise it's the origin-stripped path\n // This avoids constructing URL objects in the hot path\n const publicHref = location?.publicHref\n if (!publicHref) return undefined\n\n const external = location?.external\n if (external) return publicHref\n\n return router.history.createHref(publicHref) || '/'\n })\n\n // Create static event handlers that don't change between renders\n const staticEventHandlers = {\n onClick: composeEventHandlers<PointerEvent>([\n options.onClick,\n handleClick,\n ]) as any,\n onBlur: composeEventHandlers<FocusEvent>([\n options.onBlur,\n handleLeave,\n ]) as any,\n onFocus: composeEventHandlers<FocusEvent>([\n options.onFocus,\n enqueueIntentPreload,\n ]) as any,\n onMouseenter: composeEventHandlers<MouseEvent>([\n options.onMouseEnter,\n enqueueIntentPreload,\n ]) as any,\n onMouseover: composeEventHandlers<MouseEvent>([\n options.onMouseOver,\n enqueueIntentPreload,\n ]) as any,\n onMouseleave: composeEventHandlers<MouseEvent>([\n options.onMouseLeave,\n handleLeave,\n ]) as any,\n onMouseout: composeEventHandlers<MouseEvent>([\n options.onMouseOut,\n handleLeave,\n ]) as any,\n onTouchstart: composeEventHandlers<TouchEvent>([\n options.onTouchStart,\n handleTouchStart,\n ]) as any,\n }\n\n // Compute all props synchronously to avoid hydration mismatches\n // Using Vue.computed ensures props are calculated at render time, not after\n const computedProps = Vue.computed<LinkHTMLAttributes>(() => {\n const result: Record<string, unknown> = {\n ...getPropsSafeToSpread(),\n href: href.value,\n ref,\n ...staticEventHandlers,\n disabled: !!options.disabled,\n target: options.target,\n }\n\n // Add style if present\n if (resolvedStyle.value) {\n result.style = resolvedStyle.value\n }\n\n // Add class if present\n if (resolvedClassName.value) {\n result.class = resolvedClassName.value\n }\n\n // Add disabled props\n if (options.disabled) {\n result.role = 'link'\n result['aria-disabled'] = true\n }\n\n // Add active status\n if (isActive.value) {\n result['data-status'] = 'active'\n result['aria-current'] = 'page'\n }\n\n // Add transitioning status\n if (isTransitioning.value) {\n result['data-transitioning'] = 'transitioning'\n }\n\n // Merge active/inactive props (excluding class and style which are handled above)\n const activeP = resolvedActiveProps.value\n const inactiveP = resolvedInactiveProps.value\n\n for (const key of Object.keys(activeP)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = (activeP as any)[key]\n }\n }\n for (const key of Object.keys(inactiveP)) {\n if (key !== 'class' && key !== 'style') {\n result[key] = (inactiveP as any)[key]\n }\n }\n\n return result\n })\n\n // Return the computed ref itself - callers should access .value\n return computedProps as unknown as LinkHTMLAttributes\n}\n\n// Type definitions\nexport type UseLinkPropsOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends RoutePaths<TRouter['routeTree']> | string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends RoutePaths<TRouter['routeTree']> | string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkHTMLAttributes\n\nexport type ActiveLinkOptions<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n ActiveLinkOptionProps<TComp>\n\ntype ActiveLinkProps<TComp> = Partial<\n (TComp extends keyof HTMLElementTagNameMap\n ? LinkHTMLAttributes\n : PropsOfComponent<TComp>) & {\n [key: `data-${string}`]: unknown\n }\n>\n\nexport interface ActiveLinkOptionProps<TComp = 'a'> {\n /**\n * A function that returns additional props for the `active` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n activeProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n /**\n * A function that returns additional props for the `inactive` state of this link.\n * These props override other props passed to the link (`style`'s are merged, `class`'s are concatenated)\n */\n inactiveProps?: ActiveLinkProps<TComp> | (() => ActiveLinkProps<TComp>)\n}\n\nexport type LinkProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = ActiveLinkOptions<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo> &\n LinkPropsChildren\n\nexport interface LinkPropsChildren {\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 | Vue.VNodeChild\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Vue.VNodeChild)\n}\n\ntype LinkComponentVueProps<TComp> = TComp extends keyof HTMLElementTagNameMap\n ? Omit<LinkHTMLAttributes, keyof CreateLinkProps>\n : Omit<PropsOfComponent<TComp>, keyof CreateLinkProps>\n\nexport type LinkComponentProps<\n TComp = 'a',\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = '.',\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '.',\n> = LinkComponentVueProps<TComp> &\n LinkProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>\n\nexport type CreateLinkProps = LinkProps<\n any,\n any,\n string,\n string,\n string,\n string\n>\n\nexport type LinkComponent<\n in out TComp,\n in out TDefaultFrom extends string = string,\n> = <\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = TDefaultFrom,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(\n props: LinkComponentProps<TComp, TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => Vue.VNode\n\nexport interface LinkComponentRoute<\n in out TDefaultFrom extends string = string,\n> {\n defaultFrom: TDefaultFrom;\n <\n TRouter extends AnyRouter = RegisteredRouter,\n const TTo extends string | undefined = undefined,\n const TMaskTo extends string = '',\n >(\n props: LinkComponentProps<\n 'a',\n TRouter,\n this['defaultFrom'],\n TTo,\n this['defaultFrom'],\n TMaskTo\n >,\n ): Vue.VNode\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Vue.VNode>,\n): LinkComponent<TComp> {\n return Vue.defineComponent({\n name: 'CreatedLink',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => Vue.h(LinkImpl as any, { ...attrs, _asChild: Comp }, slots)\n },\n }) as any\n}\n\nconst LinkImpl = Vue.defineComponent({\n name: 'Link',\n inheritAttrs: false,\n props: [\n '_asChild',\n 'to',\n 'preload',\n 'preloadDelay',\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'from',\n 'search',\n 'params',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'disabled',\n 'additionalProps',\n 'viewTransition',\n 'resetScroll',\n 'startTransition',\n 'hashScrollIntoView',\n 'replace',\n 'ignoreBlocker',\n 'target',\n ],\n setup(props, { attrs, slots }) {\n // Call useLinkProps ONCE during setup with combined props and attrs\n // The returned object is a computed ref that updates reactively\n const allProps = { ...props, ...attrs }\n const linkPropsComputed = useLinkProps(\n allProps as any,\n ) as unknown as Vue.ComputedRef<LinkHTMLAttributes>\n\n return () => {\n const Component = props._asChild || 'a'\n\n // Access the computed value to get fresh props each render\n const linkProps = linkPropsComputed.value\n\n const isActive = linkProps['data-status'] === 'active'\n const isTransitioning =\n linkProps['data-transitioning'] === 'transitioning'\n\n // Create the slot content or empty array if no default slot\n const slotContent = slots.default\n ? slots.default({\n isActive,\n isTransitioning,\n })\n : []\n\n // Special handling for SVG links - wrap an <a> inside the SVG\n if (Component === 'svg') {\n // Create props without class for svg link\n const svgLinkProps = { ...linkProps }\n delete svgLinkProps.class\n return Vue.h('svg', {}, [Vue.h('a', svgLinkProps, slotContent)])\n }\n\n // For custom functional components (non-string), pass children as a prop\n // since they may expect children as a prop like in Solid\n if (typeof Component !== 'string') {\n return Vue.h(\n Component,\n { ...linkProps, children: slotContent },\n slotContent,\n )\n }\n\n // Return the component with props and children\n return Vue.h(Component, linkProps, slotContent)\n }\n },\n})\n\n/**\n * Link component with proper TypeScript generics support\n */\nexport const Link = LinkImpl as unknown as Vue.Component<unknown> &\n Vue.Component<CreateLinkProps> &\n LinkComponent<'a'>\n\nfunction isCtrlEvent(e: MouseEvent) {\n return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)\n}\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TComp,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<any>\n ? ValidateLinkOptionsArray<TRouter, TOptions, string, TComp>\n : ValidateLinkOptions<TRouter, TOptions, string, TComp>\n\nexport type LinkOptionsFn<TComp> = <\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(\n options: LinkOptionsFnOptions<TOptions, TComp, TRouter>,\n) => TOptions\n\nexport const linkOptions: LinkOptionsFn<'a'> = (options) => {\n return options as any\n}\n"],"mappings":";;;;;;;AA6BA,IAAMU,6BAAa,IAAIC,SAAqD;AAoC5E,SAAgBC,aAOdC,SACoB;CACpB,MAAMC,SAASP,WAAW;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BAAmB;GAC9C,MAAMnK,kBACJmK,UAAU,0BAA0B;GAGtC,MAAMC,cAAcR,MAAMS,UACtBT,MAAMS,QAAQ;IACZtI;IACA/B;IACD,CAAC,GACF,EAAE;AAGN,OAAIkK,cAAc,OAAO;IAEvB,MAAMI,eAAe,EAAE,GAAGH,WAAW;AACrC,WAAOG,aAAa/F;AACpB,WAAOtF,IAAI4K,EAAE,OAAO,EAAE,EAAE,CAAC5K,IAAI4K,EAAE,KAAKS,cAAcF,YAAY,CAAC,CAAC;;AAKlE,OAAI,OAAOF,cAAc,SACvB,QAAOjL,IAAI4K,EACTK,WACA;IAAE,GAAGC;IAAWI,UAAUH;IAAa,EACvCA,YACD;AAIH,UAAOnL,IAAI4K,EAAEK,WAAWC,WAAWC,YAAY;;;CAGpD,CAAC;;;;AAKF,IAAaI,OAAOV;AAIpB,SAASlE,YAAYL,GAAe;AAClC,QAAO,CAAC,EAAEA,EAAEkF,WAAWlF,EAAEmF,UAAUnF,EAAEoF,WAAWpF,EAAEqF;;AAmBpD,IAAaC,eAAmC/K,YAAY;AAC1D,QAAOA"}
|
package/dist/esm/matchContext.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import * as Vue from "vue";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
//#region src/matchContext.tsx
|
|
3
|
+
var matchContext = Symbol("TanStackRouterMatch");
|
|
4
|
+
var dummyMatchContext = Symbol("TanStackRouterDummyMatch");
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves the match ID from the component tree
|
|
7
|
+
*/
|
|
4
8
|
function injectMatch() {
|
|
5
|
-
|
|
9
|
+
return Vue.inject(matchContext, Vue.ref(void 0));
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves the dummy match ID from the component tree
|
|
13
|
+
* This only exists so we can conditionally inject a value when we are not interested in the nearest match
|
|
14
|
+
*/
|
|
7
15
|
function injectDummyMatch() {
|
|
8
|
-
|
|
16
|
+
return Vue.inject(dummyMatchContext, Vue.ref(void 0));
|
|
9
17
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
matchContext
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=matchContext.js.map
|
|
18
|
+
//#endregion
|
|
19
|
+
export { injectDummyMatch, injectMatch, matchContext };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=matchContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchContext.js","sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as Vue from 'vue'\n\n// Create a typed injection key with support for undefined values\n// This is the primary match context used throughout the router\nexport const matchContext = Symbol('TanStackRouterMatch') as Vue.InjectionKey<\n Vue.Ref<string | undefined>\n>\n\n// Dummy match context for when we want to look up by explicit 'from' route\nexport const dummyMatchContext = Symbol(\n 'TanStackRouterDummyMatch',\n) as Vue.InjectionKey<Vue.Ref<string | undefined>>\n\n/**\n * Provides a match ID to child components\n */\nexport function provideMatch(matchId: string | undefined) {\n Vue.provide(matchContext, Vue.ref(matchId))\n}\n\n/**\n * Retrieves the match ID from the component tree\n */\nexport function injectMatch(): Vue.Ref<string | undefined> {\n return Vue.inject(matchContext, Vue.ref(undefined))\n}\n\n/**\n * Provides a dummy match ID to child components\n */\nexport function provideDummyMatch(matchId: string | undefined) {\n Vue.provide(dummyMatchContext, Vue.ref(matchId))\n}\n\n/**\n * Retrieves the dummy match ID from the component tree\n * This only exists so we can conditionally inject a value when we are not interested in the nearest match\n */\nexport function injectDummyMatch(): Vue.Ref<string | undefined> {\n return Vue.inject(dummyMatchContext, Vue.ref(undefined))\n}\n"],"
|
|
1
|
+
{"version":3,"file":"matchContext.js","names":["Vue","matchContext","Symbol","dummyMatchContext","provideMatch","matchId","provide","ref","injectMatch","inject","undefined","provideDummyMatch","injectDummyMatch"],"sources":["../../src/matchContext.tsx"],"sourcesContent":["import * as Vue from 'vue'\n\n// Create a typed injection key with support for undefined values\n// This is the primary match context used throughout the router\nexport const matchContext = Symbol('TanStackRouterMatch') as Vue.InjectionKey<\n Vue.Ref<string | undefined>\n>\n\n// Dummy match context for when we want to look up by explicit 'from' route\nexport const dummyMatchContext = Symbol(\n 'TanStackRouterDummyMatch',\n) as Vue.InjectionKey<Vue.Ref<string | undefined>>\n\n/**\n * Provides a match ID to child components\n */\nexport function provideMatch(matchId: string | undefined) {\n Vue.provide(matchContext, Vue.ref(matchId))\n}\n\n/**\n * Retrieves the match ID from the component tree\n */\nexport function injectMatch(): Vue.Ref<string | undefined> {\n return Vue.inject(matchContext, Vue.ref(undefined))\n}\n\n/**\n * Provides a dummy match ID to child components\n */\nexport function provideDummyMatch(matchId: string | undefined) {\n Vue.provide(dummyMatchContext, Vue.ref(matchId))\n}\n\n/**\n * Retrieves the dummy match ID from the component tree\n * This only exists so we can conditionally inject a value when we are not interested in the nearest match\n */\nexport function injectDummyMatch(): Vue.Ref<string | undefined> {\n return Vue.inject(dummyMatchContext, Vue.ref(undefined))\n}\n"],"mappings":";;AAIA,IAAaC,eAAeC,OAAO,sBAElC;AAGD,IAAaC,oBAAoBD,OAC/B,2BACgD;;;;AAYlD,SAAgBM,cAA2C;AACzD,QAAOR,IAAIS,OAAOR,cAAcD,IAAIO,IAAIG,KAAAA,EAAU,CAAC;;;;;;AAcrD,SAAgBE,mBAAgD;AAC9D,QAAOZ,IAAIS,OAAON,mBAAmBH,IAAIO,IAAIG,KAAAA,EAAU,CAAC"}
|
package/dist/esm/not-found.js
CHANGED
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
import * as Vue from "vue";
|
|
2
|
-
import { isNotFound } from "@tanstack/router-core";
|
|
3
1
|
import { CatchBoundary } from "./CatchBoundary.js";
|
|
4
2
|
import { useRouterState } from "./useRouterState.js";
|
|
3
|
+
import { isNotFound } from "@tanstack/router-core";
|
|
4
|
+
import * as Vue from "vue";
|
|
5
|
+
//#region src/not-found.tsx
|
|
5
6
|
function CatchNotFound(props) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (props.onCatch) {
|
|
25
|
-
props.onCatch(error);
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
errorComponent: errorComponentFn,
|
|
32
|
-
children: props.children
|
|
33
|
-
});
|
|
7
|
+
const resetKey = useRouterState({ select: (s) => `not-found-${s.location.pathname}-${s.status}` });
|
|
8
|
+
const errorComponentFn = (componentProps) => {
|
|
9
|
+
const error = componentProps.error;
|
|
10
|
+
if (isNotFound(error)) {
|
|
11
|
+
if (props.fallback) return props.fallback(error);
|
|
12
|
+
return Vue.h("p", null, "Not Found");
|
|
13
|
+
} else throw error;
|
|
14
|
+
};
|
|
15
|
+
return Vue.h(CatchBoundary, {
|
|
16
|
+
getResetKey: () => resetKey.value,
|
|
17
|
+
onCatch: (error) => {
|
|
18
|
+
if (isNotFound(error)) {
|
|
19
|
+
if (props.onCatch) props.onCatch(error);
|
|
20
|
+
} else throw error;
|
|
21
|
+
},
|
|
22
|
+
errorComponent: errorComponentFn,
|
|
23
|
+
children: props.children
|
|
24
|
+
});
|
|
34
25
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
var DefaultGlobalNotFound = Vue.defineComponent({
|
|
27
|
+
name: "DefaultGlobalNotFound",
|
|
28
|
+
setup() {
|
|
29
|
+
return () => Vue.h("p", null, "Not Found");
|
|
30
|
+
}
|
|
40
31
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=not-found.js.map
|
|
32
|
+
//#endregion
|
|
33
|
+
export { CatchNotFound, DefaultGlobalNotFound };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=not-found.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found.js","sources":["../../src/not-found.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { isNotFound } from '@tanstack/router-core'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type { ErrorComponentProps, NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Vue.VNode\n onCatch?: (error: Error) => void\n children: Vue.VNode\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n // Create a function that returns a VNode to match the SyncRouteComponent signature\n const errorComponentFn = (componentProps: ErrorComponentProps) => {\n const error = componentProps.error\n\n if (isNotFound(error)) {\n // If a fallback is provided, use it\n if (props.fallback) {\n return props.fallback(error)\n }\n // Otherwise return a default not found message\n return Vue.h('p', null, 'Not Found')\n } else {\n // Re-throw non-NotFound errors\n throw error\n }\n }\n\n return Vue.h(CatchBoundary, {\n getResetKey: () => resetKey.value,\n onCatch: (error: Error) => {\n if (isNotFound(error)) {\n if (props.onCatch) {\n props.onCatch(error)\n }\n } else {\n throw error\n }\n },\n errorComponent: errorComponentFn,\n children: props.children,\n })\n}\n\nexport const DefaultGlobalNotFound = Vue.defineComponent({\n name: 'DefaultGlobalNotFound',\n setup() {\n return () => Vue.h('p', null, 'Not Found')\n },\n})\n"],"
|
|
1
|
+
{"version":3,"file":"not-found.js","names":["Vue","isNotFound","CatchBoundary","useRouterState","CatchNotFound","props","resetKey","select","s","location","pathname","status","errorComponentFn","componentProps","error","fallback","h","getResetKey","value","onCatch","errorComponent","children","DefaultGlobalNotFound","defineComponent","name","setup"],"sources":["../../src/not-found.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport { isNotFound } from '@tanstack/router-core'\nimport { CatchBoundary } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport type { ErrorComponentProps, NotFoundError } from '@tanstack/router-core'\n\nexport function CatchNotFound(props: {\n fallback?: (error: NotFoundError) => Vue.VNode\n onCatch?: (error: Error) => void\n children: Vue.VNode\n}) {\n // TODO: Some way for the user to programmatically reset the not-found boundary?\n const resetKey = useRouterState({\n select: (s) => `not-found-${s.location.pathname}-${s.status}`,\n })\n\n // Create a function that returns a VNode to match the SyncRouteComponent signature\n const errorComponentFn = (componentProps: ErrorComponentProps) => {\n const error = componentProps.error\n\n if (isNotFound(error)) {\n // If a fallback is provided, use it\n if (props.fallback) {\n return props.fallback(error)\n }\n // Otherwise return a default not found message\n return Vue.h('p', null, 'Not Found')\n } else {\n // Re-throw non-NotFound errors\n throw error\n }\n }\n\n return Vue.h(CatchBoundary, {\n getResetKey: () => resetKey.value,\n onCatch: (error: Error) => {\n if (isNotFound(error)) {\n if (props.onCatch) {\n props.onCatch(error)\n }\n } else {\n throw error\n }\n },\n errorComponent: errorComponentFn,\n children: props.children,\n })\n}\n\nexport const DefaultGlobalNotFound = Vue.defineComponent({\n name: 'DefaultGlobalNotFound',\n setup() {\n return () => Vue.h('p', null, 'Not Found')\n },\n})\n"],"mappings":";;;;;AAMA,SAAgBI,cAAcC,OAI3B;CAED,MAAMC,WAAWH,eAAe,EAC9BI,SAASC,MAAM,aAAaA,EAAEC,SAASC,SAAQ,GAAIF,EAAEG,UACtD,CAAC;CAGF,MAAMC,oBAAoBC,mBAAwC;EAChE,MAAMC,QAAQD,eAAeC;AAE7B,MAAIb,WAAWa,MAAM,EAAE;AAErB,OAAIT,MAAMU,SACR,QAAOV,MAAMU,SAASD,MAAM;AAG9B,UAAOd,IAAIgB,EAAE,KAAK,MAAM,YAAY;QAGpC,OAAMF;;AAIV,QAAOd,IAAIgB,EAAEd,eAAe;EAC1Be,mBAAmBX,SAASY;EAC5BC,UAAUL,UAAiB;AACzB,OAAIb,WAAWa,MAAM;QACfT,MAAMc,QACRd,OAAMc,QAAQL,MAAM;SAGtB,OAAMA;;EAGVM,gBAAgBR;EAChBS,UAAUhB,MAAMgB;EACjB,CAAC;;AAGJ,IAAaC,wBAAwBtB,IAAIuB,gBAAgB;CACvDC,MAAM;CACNC,QAAQ;AACN,eAAazB,IAAIgB,EAAE,KAAK,MAAM,YAAY;;CAE7C,CAAC"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
import { DefaultGlobalNotFound } from "./not-found.js";
|
|
1
2
|
import * as Vue from "vue";
|
|
2
3
|
import warning from "tiny-warning";
|
|
3
|
-
|
|
4
|
+
//#region src/renderRouteNotFound.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Renders a not found component for a route when no matching route is found.
|
|
7
|
+
*
|
|
8
|
+
* @param router - The router instance containing the route configuration
|
|
9
|
+
* @param route - The route that triggered the not found state
|
|
10
|
+
* @param data - Additional data to pass to the not found component
|
|
11
|
+
* @returns The rendered not found component or a default fallback component
|
|
12
|
+
*/
|
|
4
13
|
function renderRouteNotFound(router, route, data) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
return Vue.h(DefaultGlobalNotFound);
|
|
13
|
-
}
|
|
14
|
-
return Vue.h(route.options.notFoundComponent, data);
|
|
14
|
+
if (!route.options.notFoundComponent) {
|
|
15
|
+
if (router.options.defaultNotFoundComponent) return Vue.h(router.options.defaultNotFoundComponent, data);
|
|
16
|
+
if (process.env.NODE_ENV === "development") warning(route.options.notFoundComponent, `A notFoundError was encountered on the route with ID "${route.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`);
|
|
17
|
+
return Vue.h(DefaultGlobalNotFound);
|
|
18
|
+
}
|
|
19
|
+
return Vue.h(route.options.notFoundComponent, data);
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=renderRouteNotFound.js.map
|
|
21
|
+
//#endregion
|
|
22
|
+
export { renderRouteNotFound };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=renderRouteNotFound.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRouteNotFound.js","sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\n/**\n * Renders a not found component for a route when no matching route is found.\n *\n * @param router - The router instance containing the route configuration\n * @param route - The route that triggered the not found state\n * @param data - Additional data to pass to the not found component\n * @returns The rendered not found component or a default fallback component\n */\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n): Vue.VNode {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return Vue.h(router.options.defaultNotFoundComponent as any, data)\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`,\n )\n }\n\n return Vue.h(DefaultGlobalNotFound)\n }\n\n return Vue.h(route.options.notFoundComponent as any, data)\n}\n"],"
|
|
1
|
+
{"version":3,"file":"renderRouteNotFound.js","names":["Vue","warning","DefaultGlobalNotFound","renderRouteNotFound","router","route","data","options","notFoundComponent","defaultNotFoundComponent","h","process","env","NODE_ENV","id"],"sources":["../../src/renderRouteNotFound.tsx"],"sourcesContent":["import * as Vue from 'vue'\nimport warning from 'tiny-warning'\nimport { DefaultGlobalNotFound } from './not-found'\nimport type { AnyRoute, AnyRouter } from '@tanstack/router-core'\n\n/**\n * Renders a not found component for a route when no matching route is found.\n *\n * @param router - The router instance containing the route configuration\n * @param route - The route that triggered the not found state\n * @param data - Additional data to pass to the not found component\n * @returns The rendered not found component or a default fallback component\n */\nexport function renderRouteNotFound(\n router: AnyRouter,\n route: AnyRoute,\n data: any,\n): Vue.VNode {\n if (!route.options.notFoundComponent) {\n if (router.options.defaultNotFoundComponent) {\n return Vue.h(router.options.defaultNotFoundComponent as any, data)\n }\n\n if (process.env.NODE_ENV === 'development') {\n warning(\n route.options.notFoundComponent,\n `A notFoundError was encountered on the route with ID \"${route.id}\", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Not Found</p>)`,\n )\n }\n\n return Vue.h(DefaultGlobalNotFound)\n }\n\n return Vue.h(route.options.notFoundComponent as any, data)\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgBG,oBACdC,QACAC,OACAC,MACW;AACX,KAAI,CAACD,MAAME,QAAQC,mBAAmB;AACpC,MAAIJ,OAAOG,QAAQE,yBACjB,QAAOT,IAAIU,EAAEN,OAAOG,QAAQE,0BAAiCH,KAAK;AAGpE,MAAA,QAAA,IAAA,aAA6B,cAC3BL,SACEI,MAAME,QAAQC,mBACd,yDAAyDH,MAAMS,GAAE,oPAClE;AAGH,SAAOd,IAAIU,EAAER,sBAAsB;;AAGrC,QAAOF,IAAIU,EAAEL,MAAME,QAAQC,mBAA0BF,KAAK"}
|