@tanstack/solid-router 1.132.0-alpha.8 → 1.132.0
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/cjs/Asset.cjs +30 -1
- package/dist/cjs/Asset.cjs.map +1 -1
- package/dist/cjs/Matches.cjs +22 -18
- package/dist/cjs/Matches.cjs.map +1 -1
- package/dist/cjs/RouterProvider.cjs +9 -9
- package/dist/cjs/RouterProvider.cjs.map +1 -1
- package/dist/cjs/ScriptOnce.cjs +12 -2
- package/dist/cjs/ScriptOnce.cjs.map +1 -1
- package/dist/cjs/fileRoute.cjs.map +1 -1
- package/dist/cjs/fileRoute.d.cts +2 -2
- package/dist/cjs/index.cjs +8 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +4 -2
- package/dist/cjs/link.cjs +46 -31
- package/dist/cjs/link.cjs.map +1 -1
- package/dist/cjs/route.cjs.map +1 -1
- package/dist/cjs/route.d.cts +9 -9
- package/dist/cjs/ssr/renderRouterToString.cjs +1 -0
- package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
- package/dist/cjs/useNavigate.cjs +1 -8
- package/dist/cjs/useNavigate.cjs.map +1 -1
- package/dist/cjs/useParams.cjs +3 -2
- package/dist/cjs/useParams.cjs.map +1 -1
- package/dist/esm/Asset.js +30 -1
- package/dist/esm/Asset.js.map +1 -1
- package/dist/esm/Matches.js +16 -12
- package/dist/esm/Matches.js.map +1 -1
- package/dist/esm/RouterProvider.js +9 -9
- package/dist/esm/RouterProvider.js.map +1 -1
- package/dist/esm/ScriptOnce.js +13 -3
- package/dist/esm/ScriptOnce.js.map +1 -1
- package/dist/esm/fileRoute.d.ts +2 -2
- package/dist/esm/fileRoute.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +3 -2
- package/dist/esm/link.js +46 -31
- package/dist/esm/link.js.map +1 -1
- package/dist/esm/route.d.ts +9 -9
- package/dist/esm/route.js.map +1 -1
- package/dist/esm/ssr/renderRouterToString.js +1 -0
- package/dist/esm/ssr/renderRouterToString.js.map +1 -1
- package/dist/esm/useNavigate.js +1 -8
- package/dist/esm/useNavigate.js.map +1 -1
- package/dist/esm/useParams.js +3 -2
- package/dist/esm/useParams.js.map +1 -1
- package/dist/source/Asset.jsx +33 -1
- package/dist/source/Asset.jsx.map +1 -1
- package/dist/source/Matches.jsx +11 -7
- package/dist/source/Matches.jsx.map +1 -1
- package/dist/source/RouterProvider.jsx +7 -7
- package/dist/source/RouterProvider.jsx.map +1 -1
- package/dist/source/ScriptOnce.jsx +4 -2
- package/dist/source/ScriptOnce.jsx.map +1 -1
- package/dist/source/fileRoute.d.ts +2 -2
- package/dist/source/fileRoute.js.map +1 -1
- package/dist/source/index.d.ts +4 -2
- package/dist/source/index.jsx +2 -1
- package/dist/source/index.jsx.map +1 -1
- package/dist/source/link.jsx +47 -36
- package/dist/source/link.jsx.map +1 -1
- package/dist/source/route.d.ts +9 -9
- package/dist/source/route.jsx.map +1 -1
- package/dist/source/ssr/renderRouterToString.jsx +1 -0
- package/dist/source/ssr/renderRouterToString.jsx.map +1 -1
- package/dist/source/useNavigate.jsx +1 -5
- package/dist/source/useNavigate.jsx.map +1 -1
- package/dist/source/useParams.jsx +3 -2
- package/dist/source/useParams.jsx.map +1 -1
- package/package.json +3 -3
- package/src/Asset.tsx +47 -1
- package/src/Matches.tsx +18 -16
- package/src/RouterProvider.tsx +9 -10
- package/src/ScriptOnce.tsx +5 -2
- package/src/fileRoute.ts +10 -3
- package/src/index.tsx +5 -2
- package/src/link.tsx +47 -41
- package/src/route.tsx +48 -22
- package/src/ssr/renderRouterToString.tsx +1 -0
- package/src/useNavigate.tsx +1 -9
- package/src/useParams.tsx +6 -4
- package/dist/cjs/useActiveLocation.cjs +0 -40
- package/dist/cjs/useActiveLocation.cjs.map +0 -1
- package/dist/cjs/useActiveLocation.d.cts +0 -8
- package/dist/esm/useActiveLocation.d.ts +0 -8
- package/dist/esm/useActiveLocation.js +0 -40
- package/dist/esm/useActiveLocation.js.map +0 -1
- package/dist/source/useActiveLocation.d.ts +0 -8
- package/dist/source/useActiveLocation.js +0 -33
- package/dist/source/useActiveLocation.js.map +0 -1
- package/src/useActiveLocation.ts +0 -61
package/dist/esm/Matches.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport { SafeFragment } from './SafeFragment'\nimport type {\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n RouterState,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n const pendingElement = router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n\n // Do not render a root Suspense during SSR or hydrating from SSR\n const ResolvedSuspense =\n router.isServer || (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Suspense\n\n const inner = (\n <ResolvedSuspense fallback={pendingElement}>\n {!router.isServer && <Transitioner />}\n <MatchesInner />\n </ResolvedSuspense>\n )\n\n return router.options.InnerWrap ? (\n <router.options.InnerWrap>{inner}</router.options.InnerWrap>\n ) : (\n inner\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const matchComponent = () =>\n matchId() ? <Match matchId={matchId()!} /> : null\n\n return (\n <matchContext.Provider value={matchId}>\n {router.options.disableGlobalCatchBoundary ? (\n matchComponent()\n ) : (\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={(error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }}\n >\n {matchComponent()}\n </CatchBoundary>\n )}\n </matchContext.Provider>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n const status = useRouterState({\n select: (s) => s.status,\n })\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n const matchRoute = Solid.createMemo(() => {\n status()\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n\n return matchRoute\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\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 | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const status = useRouterState({\n select: (s) => s.status,\n })\n\n return (\n <Solid.Show when={status()} keyed>\n {(_) => {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)() as boolean\n const child = props.children\n if (typeof child === 'function') {\n return (child as any)(params)\n }\n\n return params ? child : null\n }}\n </Solid.Show>\n )\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n return useRouterState({\n select: (state: RouterState<TRouter['routeTree']>) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<MakeRouteMatchUnion<TRouter>>)\n : matches\n },\n } as any) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"names":["Matches","router","useRouter","pendingElement","options","defaultPendingComponent","_$createComponent","ResolvedSuspense","isServer","document","ssr","SafeFragment","Solid","Suspense","inner","fallback","children","_$memo","Transitioner","MatchesInner","InnerWrap","matchId","useRouterState","select","s","matches","id","resetKey","loadedAt","matchComponent","Match","matchContext","Provider","value","disableGlobalCatchBoundary","CatchBoundary","getResetKey","errorComponent","ErrorComponent","onCatch","error","warning","message","toString","useMatchRoute","status","opts","pending","caseSensitive","fuzzy","includeSearch","rest","matchRoute","createMemo","MatchRoute","props","Show","when","keyed","_","params","child","useMatches","state","useParentMatches","contextMatchId","useContext","slice","findIndex","d","useChildMatches"],"mappings":";;;;;;;;;;AAqCO,SAASA,UAAU;AACxB,QAAMC,SAASC,UAAAA;AAEf,QAAMC,iBAAiBF,OAAOG,QAAQC,0BAAuBC,gBAC1DL,OAAOG,QAAQC,+BACd;A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vB,SACTuB,KAAKvB,OAAOE,OAA8C,IAC1DA;AAAAA,IACN;AAAA,EAAA,CACM;AACV;AAEO,SAASuC,iBAIdlB,MACsD;AACtD,QAAMmB,iBAAiBrD,MAAMsD,WAAWnC,YAAY;AAEpD,SAAO+B,WAAW;AAAA,IAChBvC,QAAQA,CAACE,YAAiD;AACxDA,gBAAUA,QAAQ0C,MAChB,GACA1C,QAAQ2C,UAAWC,OAAMA,EAAE3C,OAAOuC,eAAAA,CAAgB,CACpD;AACA,aAAOnB,MAAMvB,SAASuB,KAAKvB,OAAOE,OAAO,IAAIA;AAAAA,IAC/C;AAAA,EAAA,CACM;AACV;AAEO,SAAS6C,gBAIdxB,MACsD;AACtD,QAAMmB,iBAAiBrD,MAAMsD,WAAWnC,YAAY;AAEpD,SAAO+B,WAAW;AAAA,IAChBvC,QAAQA,CAACE,YAAiD;AACxDA,gBAAUA,QAAQ0C,MAChB1C,QAAQ2C,UAAWC,CAAAA,MAAMA,EAAE3C,OAAOuC,eAAAA,CAAgB,IAAI,CACxD;AACA,aAAOnB,MAAMvB,SAASuB,KAAKvB,OAAOE,OAAO,IAAIA;AAAAA,IAC/C;AAAA,EAAA,CACM;AACV;"}
|
|
1
|
+
{"version":3,"file":"Matches.js","sources":["../../src/Matches.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport warning from 'tiny-warning'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\nimport { Transitioner } from './Transitioner'\nimport { matchContext } from './matchContext'\nimport { Match } from './Match'\nimport { SafeFragment } from './SafeFragment'\nimport type {\n AnyRouter,\n DeepPartial,\n Expand,\n MakeOptionalPathParams,\n MakeOptionalSearchParams,\n MakeRouteMatchUnion,\n MaskOptions,\n MatchRouteOptions,\n NoInfer,\n RegisteredRouter,\n ResolveRelativePath,\n ResolveRoute,\n RouteByPath,\n RouterState,\n ToSubOptionsProps,\n} from '@tanstack/router-core'\n\ndeclare module '@tanstack/router-core' {\n export interface RouteMatchExtensions {\n meta?: Array<Solid.JSX.IntrinsicElements['meta'] | undefined>\n links?: Array<Solid.JSX.IntrinsicElements['link'] | undefined>\n scripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n styles?: Array<Solid.JSX.IntrinsicElements['style'] | undefined>\n headScripts?: Array<Solid.JSX.IntrinsicElements['script'] | undefined>\n }\n}\n\nexport function Matches() {\n const router = useRouter()\n\n // Do not render a root Suspense during SSR or hydrating from SSR\n const ResolvedSuspense =\n router.isServer || (typeof document !== 'undefined' && router.ssr)\n ? SafeFragment\n : Solid.Suspense\n\n const OptionalWrapper = router.options.InnerWrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <ResolvedSuspense\n fallback={\n router.options.defaultPendingComponent ? (\n <router.options.defaultPendingComponent />\n ) : null\n }\n >\n {!router.isServer && <Transitioner />}\n <MatchesInner />\n </ResolvedSuspense>\n </OptionalWrapper>\n )\n}\n\nfunction MatchesInner() {\n const router = useRouter()\n const matchId = useRouterState({\n select: (s) => {\n return s.matches[0]?.id\n },\n })\n\n const resetKey = useRouterState({\n select: (s) => s.loadedAt,\n })\n\n const matchComponent = () => {\n const id = matchId()\n return id ? <Match matchId={id} /> : null\n }\n\n return (\n <matchContext.Provider value={matchId}>\n {router.options.disableGlobalCatchBoundary ? (\n matchComponent()\n ) : (\n <CatchBoundary\n getResetKey={() => resetKey()}\n errorComponent={ErrorComponent}\n onCatch={(error) => {\n warning(\n false,\n `The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!`,\n )\n warning(false, error.message || error.toString())\n }}\n >\n {matchComponent()}\n </CatchBoundary>\n )}\n </matchContext.Provider>\n )\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions\n\nexport function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {\n const router = useRouter()\n\n const status = useRouterState({\n select: (s) => s.status,\n })\n\n return <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n >(\n opts: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n ): Solid.Accessor<\n false | Expand<ResolveRoute<TRouter, TFrom, TTo>['types']['allParams']>\n > => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...rest } = opts\n\n const matchRoute = Solid.createMemo(() => {\n status()\n return router.matchRoute(rest as any, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n })\n })\n\n return matchRoute\n }\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = '',\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\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 | ((\n params?: RouteByPath<\n TRouter['routeTree'],\n ResolveRelativePath<TFrom, NoInfer<TTo>>\n >['types']['allParams'],\n ) => Solid.JSX.Element)\n | Solid.JSX.Element\n}\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = '',\n>(props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): any {\n const status = useRouterState({\n select: (s) => s.status,\n })\n\n return (\n <Solid.Show when={status()} keyed>\n {(_) => {\n const matchRoute = useMatchRoute()\n const params = matchRoute(props as any)() as boolean\n const child = props.children\n if (typeof child === 'function') {\n return (child as any)(params)\n }\n\n return params ? child : null\n }}\n </Solid.Show>\n )\n}\n\nexport interface UseMatchesBaseOptions<TRouter extends AnyRouter, TSelected> {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected\n}\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n return useRouterState({\n select: (state: RouterState<TRouter['routeTree']>) => {\n const matches = state.matches\n return opts?.select\n ? opts.select(matches as Array<MakeRouteMatchUnion<TRouter>>)\n : matches\n },\n } as any) as Solid.Accessor<UseMatchesResult<TRouter, TSelected>>\n}\n\nexport function useParentMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n 0,\n matches.findIndex((d) => d.id === contextMatchId()),\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n\nexport function useChildMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n opts?: UseMatchesBaseOptions<TRouter, TSelected>,\n): Solid.Accessor<UseMatchesResult<TRouter, TSelected>> {\n const contextMatchId = Solid.useContext(matchContext)\n\n return useMatches({\n select: (matches: Array<MakeRouteMatchUnion<TRouter>>) => {\n matches = matches.slice(\n matches.findIndex((d) => d.id === contextMatchId()) + 1,\n )\n return opts?.select ? opts.select(matches) : matches\n },\n } as any)\n}\n"],"names":["Matches","router","useRouter","ResolvedSuspense","isServer","document","ssr","SafeFragment","Solid","Suspense","OptionalWrapper","options","InnerWrap","_$createComponent","children","fallback","_$memo","defaultPendingComponent","Transitioner","MatchesInner","matchId","useRouterState","select","s","matches","id","resetKey","loadedAt","matchComponent","Match","matchContext","Provider","value","disableGlobalCatchBoundary","CatchBoundary","getResetKey","errorComponent","ErrorComponent","onCatch","error","warning","message","toString","useMatchRoute","status","opts","pending","caseSensitive","fuzzy","includeSearch","rest","matchRoute","createMemo","MatchRoute","props","Show","when","keyed","_","params","child","useMatches","state","useParentMatches","contextMatchId","useContext","slice","findIndex","d","useChildMatches"],"mappings":";;;;;;;;;;AAqCO,SAASA,UAAU;AACxB,QAAMC,SAASC,UAAAA;AAGf,QAAMC,mBACJF,OAAOG,YAAa,OAAOC,aAAa,eAAeJ,OAAOK,MAC1DC,eACAC,MAAMC;AAEZ,QAAMC,kBAAkBT,OAAOU,QAAQC,aAAaL;AAEpD,SAAAM,gBACGH,iBAAe;AAAA,IAAA,IAAAI,WAAA;AAAA,aAAAD,gBACbV,kBAAgB;AAAA,QAAA,IACfY,WAAQ;AAAA,iBACNC,KAAA,MAAA,CAAA,CAAAf,OAAOU,QAAQM,uBAAuB,MAAAJ,gBACnCZ,OAAOU,QAAQM,+BACd;AAAA,QAAI;AAAA,QAAA,IAAAH,WAAA;AAAA,iBAAA,CAAAE,KAAA,MAGTA,KAAA,MAAA,CAAA,CAAA,CAACf,OAAOG,QAAQ,EAAA,KAAAS,gBAAKK,cAAY,EAAA,CAAG,GAAAL,gBACpCM,cAAY,CAAA,CAAA,CAAA;AAAA,QAAA;AAAA,MAAA,CAAA;AAAA,IAAA;AAAA,EAAA,CAAA;AAIrB;AAEA,SAASA,eAAe;AACtB,QAAMlB,SAASC,UAAAA;AACf,QAAMkB,UAAUC,eAAe;AAAA,IAC7BC,QAASC,CAAAA,MAAM;AACb,aAAOA,EAAEC,QAAQ,CAAC,GAAGC;AAAAA,IACvB;AAAA,EAAA,CACD;AAED,QAAM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OnB,MAAMvB,SAASuB,KAAKvB,OAAOE,OAAO,IAAIA;AAAAA,IAC/C;AAAA,EAAA,CACM;AACV;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createComponent, mergeProps } from "solid-js/web";
|
|
2
2
|
import { Matches } from "./Matches.js";
|
|
3
3
|
import { getRouterContext } from "./routerContext.js";
|
|
4
|
+
import { SafeFragment } from "./SafeFragment.js";
|
|
4
5
|
function RouterContextProvider({
|
|
5
6
|
router,
|
|
6
7
|
children,
|
|
@@ -15,18 +16,17 @@ function RouterContextProvider({
|
|
|
15
16
|
}
|
|
16
17
|
});
|
|
17
18
|
const routerContext = getRouterContext();
|
|
18
|
-
const
|
|
19
|
-
|
|
19
|
+
const OptionalWrapper = router.options.Wrap || SafeFragment;
|
|
20
|
+
return createComponent(OptionalWrapper, {
|
|
20
21
|
get children() {
|
|
21
|
-
return
|
|
22
|
+
return createComponent(routerContext.Provider, {
|
|
23
|
+
value: router,
|
|
24
|
+
get children() {
|
|
25
|
+
return children();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
22
28
|
}
|
|
23
29
|
});
|
|
24
|
-
if (router.options.Wrap) {
|
|
25
|
-
return createComponent(router.options.Wrap, {
|
|
26
|
-
children: provider
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return provider;
|
|
30
30
|
}
|
|
31
31
|
function RouterProvider({
|
|
32
32
|
router,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport type * as Solid from 'solid-js'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: () => Solid.JSX.Element\n}) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n } as any)\n\n const routerContext = getRouterContext()\n\n const
|
|
1
|
+
{"version":3,"file":"RouterProvider.js","sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import { Matches } from './Matches'\nimport { getRouterContext } from './routerContext'\nimport { SafeFragment } from './SafeFragment'\nimport type * as Solid from 'solid-js'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\n\nexport function RouterContextProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({\n router,\n children,\n ...rest\n}: RouterProps<TRouter, TDehydrated> & {\n children: () => Solid.JSX.Element\n}) {\n // Allow the router to update options on the router instance\n router.update({\n ...router.options,\n ...rest,\n context: {\n ...router.options.context,\n ...rest.context,\n },\n } as any)\n\n const routerContext = getRouterContext()\n\n const OptionalWrapper = router.options.Wrap || SafeFragment\n\n return (\n <OptionalWrapper>\n <routerContext.Provider value={router as AnyRouter}>\n {children()}\n </routerContext.Provider>\n </OptionalWrapper>\n )\n}\n\nexport function RouterProvider<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n>({ router, ...rest }: RouterProps<TRouter, TDehydrated>) {\n return (\n <RouterContextProvider router={router} {...rest}>\n {() => <Matches />}\n </RouterContextProvider>\n )\n}\n\nexport type RouterProps<\n TRouter extends AnyRouter = RegisteredRouter,\n TDehydrated extends Record<string, any> = Record<string, any>,\n> = Omit<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >,\n 'context'\n> & {\n router: TRouter\n context?: Partial<\n RouterOptions<\n TRouter['routeTree'],\n NonNullable<TRouter['options']['trailingSlash']>,\n false,\n TRouter['history'],\n TDehydrated\n >['context']\n >\n}\n"],"names":["RouterContextProvider","router","children","rest","update","options","context","routerContext","getRouterContext","OptionalWrapper","Wrap","SafeFragment","_$createComponent","Provider","value","RouterProvider","_$mergeProps","Matches"],"mappings":";;;;AAUO,SAASA,sBAGd;AAAA,EACAC;AAAAA,EACAC;AAAAA,EACA,GAAGC;AAGL,GAAG;AAEDF,SAAOG,OAAO;AAAA,IACZ,GAAGH,OAAOI;AAAAA,IACV,GAAGF;AAAAA,IACHG,SAAS;AAAA,MACP,GAAGL,OAAOI,QAAQC;AAAAA,MAClB,GAAGH,KAAKG;AAAAA,IAAAA;AAAAA,EACV,CACM;AAER,QAAMC,gBAAgBC,iBAAAA;AAEtB,QAAMC,kBAAkBR,OAAOI,QAAQK,QAAQC;AAE/C,SAAAC,gBACGH,iBAAe;AAAA,IAAA,IAAAP,WAAA;AAAA,aAAAU,gBACbL,cAAcM,UAAQ;AAAA,QAACC,OAAOb;AAAAA,QAAmB,IAAAC,WAAA;AAAA,iBAC/CA,SAAAA;AAAAA,QAAU;AAAA,MAAA,CAAA;AAAA,IAAA;AAAA,EAAA,CAAA;AAInB;AAEO,SAASa,eAGd;AAAA,EAAEd;AAAAA,EAAQ,GAAGE;AAAwC,GAAG;AACxD,SAAAS,gBACGZ,uBAAqBgB,WAAA;AAAA,IAACf;AAAAA,EAAAA,GAAoBE,MAAI;AAAA,IAAAD,UAC5CA,MAAAU,gBAAOK,SAAO,CAAA,CAAA;AAAA,EAAA,CAAG,CAAA;AAGxB;"}
|
package/dist/esm/ScriptOnce.js
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import { template, effect } from "solid-js/web";
|
|
1
|
+
import { template, effect, setAttribute } from "solid-js/web";
|
|
2
|
+
import { useRouter } from "./useRouter.js";
|
|
2
3
|
var _tmpl$ = /* @__PURE__ */ template(`<script class=$tsr>`);
|
|
3
4
|
function ScriptOnce({
|
|
4
5
|
children
|
|
5
6
|
}) {
|
|
6
|
-
|
|
7
|
+
const router = useRouter();
|
|
8
|
+
if (!router.isServer) {
|
|
7
9
|
return null;
|
|
8
10
|
}
|
|
9
11
|
return (() => {
|
|
10
12
|
var _el$ = _tmpl$();
|
|
11
|
-
effect(() =>
|
|
13
|
+
effect((_p$) => {
|
|
14
|
+
var _v$ = router.options.ssr?.nonce, _v$2 = [children].filter(Boolean).join("\n") + ";$_TSR.c()";
|
|
15
|
+
_v$ !== _p$.e && setAttribute(_el$, "nonce", _p$.e = _v$);
|
|
16
|
+
_v$2 !== _p$.t && (_el$.innerHTML = _p$.t = _v$2);
|
|
17
|
+
return _p$;
|
|
18
|
+
}, {
|
|
19
|
+
e: void 0,
|
|
20
|
+
t: void 0
|
|
21
|
+
});
|
|
12
22
|
return _el$;
|
|
13
23
|
})();
|
|
14
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ScriptOnce.js","sources":["../../src/ScriptOnce.tsx"],"sourcesContent":["import { useRouter } from './useRouter'\n\nexport function ScriptOnce({\n children,\n}: {\n children: string\n log?: boolean\n sync?: boolean\n}) {\n const router = useRouter()\n if (!router.isServer) {\n return null\n }\n return (\n <script\n nonce={router.options.ssr?.nonce}\n class=\"$tsr\"\n innerHTML={[children].filter(Boolean).join('\\n') + ';$_TSR.c()'}\n />\n )\n}\n"],"names":["ScriptOnce","children","router","useRouter","isServer","_el$","_tmpl$","_$effect","_p$","_v$","options","ssr","nonce","_v$2","filter","Boolean","join","e","_$setAttribute","t","innerHTML","undefined"],"mappings":";;;AAEO,SAASA,WAAW;AAAA,EACzBC;AAKF,GAAG;AACD,QAAMC,SAASC,UAAAA;AACf,MAAI,CAACD,OAAOE,UAAU;AACpB,WAAO;AAAA,EACT;AACA,UAAA,MAAA;AAAA,QAAAC,OAAAC,OAAAA;AAAAC,WAAAC,CAAAA,QAAA;AAAA,UAAAC,MAEWP,OAAOQ,QAAQC,KAAKC,OAAKC,OAErB,CAACZ,QAAQ,EAAEa,OAAOC,OAAO,EAAEC,KAAK,IAAI,IAAI;AAAYP,cAAAD,IAAAS,KAAAC,aAAAb,MAAA,SAAAG,IAAAS,IAAAR,GAAA;AAAAI,eAAAL,IAAAW,MAAAd,KAAAe,YAAAZ,IAAAW,IAAAN;AAAA,aAAAL;AAAAA,IAAA,GAAA;AAAA,MAAAS,GAAAI;AAAAA,MAAAF,GAAAE;AAAAA,IAAAA,CAAA;AAAA,WAAAhB;AAAAA,EAAA,GAAA;AAGrE;"}
|
package/dist/esm/fileRoute.d.ts
CHANGED
|
@@ -16,14 +16,14 @@ export declare class FileRoute<TFilePath extends keyof FileRoutesByPath, TParent
|
|
|
16
16
|
constructor(path?: TFilePath | undefined, _opts?: {
|
|
17
17
|
silent: boolean;
|
|
18
18
|
});
|
|
19
|
-
createRoute: <TRegister
|
|
19
|
+
createRoute: <TRegister = Register, TSearchValidator = undefined, TParams = ResolveParams<TPath>, TRouteContextFn = AnyContext, TBeforeLoadFn = AnyContext, TLoaderDeps extends Record<string, any> = {}, TLoaderFn = undefined, TChildren = unknown, TSSR = unknown, TMiddlewares = unknown, THandlers = undefined>(options?: FileBaseRouteOptions<TRegister, TParentRoute, TId, TPath, TSearchValidator, TParams, TLoaderDeps, TLoaderFn, AnyContext, TRouteContextFn, TBeforeLoadFn, AnyContext, TSSR, TMiddlewares, THandlers> & UpdatableRouteOptions<TParentRoute, TId, TFullPath, TParams, TSearchValidator, TLoaderFn, TLoaderDeps, AnyContext, TRouteContextFn, TBeforeLoadFn>) => Route<TRegister, TParentRoute, TPath, TFullPath, TFilePath, TId, TSearchValidator, TParams, AnyContext, TRouteContextFn, TBeforeLoadFn, TLoaderDeps, TLoaderFn, TChildren, unknown, TSSR, TMiddlewares, THandlers>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
@deprecated It's recommended not to split loaders into separate files.
|
|
23
23
|
Instead, place the loader function in the the main route file, inside the
|
|
24
24
|
`createFileRoute('/path/to/file)(options)` options.
|
|
25
25
|
*/
|
|
26
|
-
export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <TLoaderFn>(loaderFn: Constrain<TLoaderFn, RouteLoaderFn<TRoute['parentRoute'], TRoute['types']['id'], TRoute['types']['params'], TRoute['types']['loaderDeps'], TRoute['types']['routerContext'], TRoute['types']['routeContextFn'], TRoute['types']['beforeLoadFn']>>) => TLoaderFn;
|
|
26
|
+
export declare function FileRouteLoader<TFilePath extends keyof FileRoutesByPath, TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute']>(_path: TFilePath): <TLoaderFn>(loaderFn: Constrain<TLoaderFn, RouteLoaderFn<Register, TRoute['parentRoute'], TRoute['types']['id'], TRoute['types']['params'], TRoute['types']['loaderDeps'], TRoute['types']['routerContext'], TRoute['types']['routeContextFn'], TRoute['types']['beforeLoadFn']>>) => TLoaderFn;
|
|
27
27
|
declare module '@tanstack/router-core' {
|
|
28
28
|
interface LazyRoute<in out TRoute extends AnyRoute> {
|
|
29
29
|
useMatch: UseMatchRoute<TRoute['id']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderFn,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister
|
|
1
|
+
{"version":3,"file":"fileRoute.js","sources":["../../src/fileRoute.ts"],"sourcesContent":["import warning from 'tiny-warning'\nimport { createRoute } from './route'\n\nimport { useMatch } from './useMatch'\nimport { useLoaderDeps } from './useLoaderDeps'\nimport { useLoaderData } from './useLoaderData'\nimport { useSearch } from './useSearch'\nimport { useParams } from './useParams'\nimport { useNavigate } from './useNavigate'\nimport { useRouter } from './useRouter'\nimport type { UseParamsRoute } from './useParams'\nimport type { UseMatchRoute } from './useMatch'\nimport type { UseSearchRoute } from './useSearch'\nimport type {\n AnyContext,\n AnyRoute,\n AnyRouter,\n Constrain,\n ConstrainLiteral,\n FileBaseRouteOptions,\n FileRoutesByPath,\n LazyRouteOptions,\n Register,\n RegisteredRouter,\n ResolveParams,\n Route,\n RouteById,\n RouteConstraints,\n RouteIds,\n RouteLoaderFn,\n UpdatableRouteOptions,\n UseNavigateResult,\n} from '@tanstack/router-core'\nimport type { UseLoaderDepsRoute } from './useLoaderDeps'\nimport type { UseLoaderDataRoute } from './useLoaderData'\nimport type { UseRouteContextRoute } from './useRouteContext'\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n>(\n path?: TFilePath,\n): FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>['createRoute'] {\n if (typeof path === 'object') {\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute(path) as any\n }\n return new FileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>(path, {\n silent: true,\n }).createRoute\n}\n\n/** \n @deprecated It's no longer recommended to use the `FileRoute` class directly.\n Instead, use `createFileRoute('/path/to/file')(options)` to create a file route.\n*/\nexport class FileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath]['parentRoute'],\n TId extends RouteConstraints['TId'] = FileRoutesByPath[TFilePath]['id'],\n TPath extends RouteConstraints['TPath'] = FileRoutesByPath[TFilePath]['path'],\n TFullPath extends\n RouteConstraints['TFullPath'] = FileRoutesByPath[TFilePath]['fullPath'],\n> {\n silent?: boolean\n\n constructor(\n public path?: TFilePath,\n _opts?: { silent: boolean },\n ) {\n this.silent = _opts?.silent\n }\n\n createRoute = <\n TRegister = Register,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, any> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n TMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: FileBaseRouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n AnyContext,\n TSSR,\n TMiddlewares,\n THandlers\n > &\n UpdatableRouteOptions<\n TParentRoute,\n TId,\n TFullPath,\n TParams,\n TSearchValidator,\n TLoaderFn,\n TLoaderDeps,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn\n >,\n ): Route<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TFilePath,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TMiddlewares,\n THandlers\n > => {\n warning(\n this.silent,\n 'FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead.',\n )\n const route = createRoute(options as any)\n ;(route as any).isRoot = false\n return route as any\n }\n}\n\n/** \n @deprecated It's recommended not to split loaders into separate files.\n Instead, place the loader function in the the main route file, inside the\n `createFileRoute('/path/to/file)(options)` options.\n*/\nexport function FileRouteLoader<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(\n _path: TFilePath,\n): <TLoaderFn>(\n loaderFn: Constrain<\n TLoaderFn,\n RouteLoaderFn<\n Register,\n TRoute['parentRoute'],\n TRoute['types']['id'],\n TRoute['types']['params'],\n TRoute['types']['loaderDeps'],\n TRoute['types']['routerContext'],\n TRoute['types']['routeContextFn'],\n TRoute['types']['beforeLoadFn']\n >\n >,\n) => TLoaderFn {\n warning(\n false,\n `FileRouteLoader is deprecated and will be removed in the next major version. Please place the loader function in the the main route file, inside the \\`createFileRoute('/path/to/file')(options)\\` options`,\n )\n return (loaderFn) => loaderFn as any\n}\n\ndeclare module '@tanstack/router-core' {\n export interface LazyRoute<in out TRoute extends AnyRoute> {\n useMatch: UseMatchRoute<TRoute['id']>\n useRouteContext: UseRouteContextRoute<TRoute['id']>\n useSearch: UseSearchRoute<TRoute['id']>\n useParams: UseParamsRoute<TRoute['id']>\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']>\n useLoaderData: UseLoaderDataRoute<TRoute['id']>\n useNavigate: () => UseNavigateResult<TRoute['fullPath']>\n }\n}\n\nexport class LazyRoute<TRoute extends AnyRoute> {\n options: {\n id: string\n } & LazyRouteOptions\n\n constructor(\n opts: {\n id: string\n } & LazyRouteOptions,\n ) {\n this.options = opts\n }\n\n useMatch: UseMatchRoute<TRoute['id']> = (opts) => {\n return useMatch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useRouteContext: UseRouteContextRoute<TRoute['id']> = (opts) => {\n return useMatch({\n from: this.options.id,\n select: (d: any) => (opts?.select ? opts.select(d.context) : d.context),\n }) as any\n }\n\n useSearch: UseSearchRoute<TRoute['id']> = (opts) => {\n return useSearch({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useParams: UseParamsRoute<TRoute['id']> = (opts) => {\n return useParams({\n select: opts?.select,\n from: this.options.id,\n } as any) as any\n }\n\n useLoaderDeps: UseLoaderDepsRoute<TRoute['id']> = (opts) => {\n return useLoaderDeps({ ...opts, from: this.options.id } as any)\n }\n\n useLoaderData: UseLoaderDataRoute<TRoute['id']> = (opts) => {\n return useLoaderData({ ...opts, from: this.options.id } as any)\n }\n\n useNavigate = (): UseNavigateResult<TRoute['fullPath']> => {\n const router = useRouter()\n return useNavigate({ from: router.routesById[this.options.id].fullPath })\n }\n}\n\nexport function createLazyRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n TId extends string = string,\n TRoute extends AnyRoute = RouteById<TRouter['routeTree'], TId>,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter['routeTree']>>) {\n return (opts: LazyRouteOptions) => {\n return new LazyRoute<TRoute>({\n id: id,\n ...opts,\n })\n }\n}\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath]['preLoaderRoute'],\n>(id: TFilePath): (opts: LazyRouteOptions) => LazyRoute<TRoute> {\n if (typeof id === 'object') {\n return new LazyRoute<TRoute>(id) as any\n }\n\n return (opts: LazyRouteOptions) => new LazyRoute<TRoute>({ id, ...opts })\n}\n"],"names":["opts"],"mappings":";;;;;;;;;AAqCO,SAAS,gBAQd,MAC0E;AAC1E,MAAI,OAAO,SAAS,UAAU;AAC5B,WAAO,IAAI,UAA0D,MAAM;AAAA,MACzE,QAAQ;AAAA,IAAA,CACT,EAAE,YAAY,IAAI;AAAA,EACrB;AACA,SAAO,IAAI,UAA0D,MAAM;AAAA,IACzE,QAAQ;AAAA,EAAA,CACT,EAAE;AACL;AAMO,MAAM,UAOX;AAAA,EAGA,YACS,MACP,OACA;AAFO,SAAA,OAAA;AAMT,SAAA,cAAc,CAaZ,YAgDG;AACH;AAAA,QACE,KAAK;AAAA,QACL;AAAA,MAAA;AAEF,YAAM,QAAQ,YAAY,OAAc;AACtC,YAAc,SAAS;AACzB,aAAO;AAAA,IACT;AAxEE,SAAK,SAAS,OAAO;AAAA,EACvB;AAwEF;AAOO,SAAS,gBAId,OAea;AACb;AAAA,IACE;AAAA,IACA;AAAA,EAAA;AAEF,SAAO,CAAC,aAAa;AACvB;AAcO,MAAM,UAAmC;AAAA,EAK9C,YAC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AAO,CAAC,SAA2B,IAAI,UAAkB,EAAE,IAAI,GAAG,MAAM;AAC1E;"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname,
|
|
2
|
-
export type { DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, Segment, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, NavigateFn, BuildLocationFn, InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, Register, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, AnyRouterWithContext, ParseRoute, RoutesById, RouteById, RouteIds, RoutesByPath, RouteByPath, RoutePaths, FullSearchSchema, AllParams, AllLoaderData, FullSearchSchemaInput, AllContext, CommitLocationOptions, MatchLocation, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllParamsFromParent, RouteContextParameter, BeforeLoadContextParameter, ResolveAllContext, FullSearchSchemaOption, MakeRemountDepsOptionsUnion, RemountDepsOptions, FileRouteTypes, FileRoutesByPath, UseNavigateResult, AnyRedirect, Redirect, RedirectOptions, ResolvedRedirect, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, MakeRouteMatch, MakeRouteMatchUnion, RouteMatch, AnyRouteMatch, RouteContextFn, RouteContextOptions,
|
|
1
|
+
export { defer, TSR_DEFERRED_PROMISE, isMatch, joinPaths, cleanPath, trimPathLeft, trimPathRight, trimPath, resolvePath, parsePathname, interpolatePath, matchPathname, matchByPath, rootRouteId, defaultSerializeError, defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith, functionalUpdate, replaceEqualDeep, isPlainObject, isPlainArray, deepEqual, createControlledPromise, retainSearchParams, stripSearchParams, createSerializationAdapter, } from '@tanstack/router-core';
|
|
2
|
+
export type { DeferredPromiseState, DeferredPromise, ParsedLocation, RemoveTrailingSlashes, RemoveLeadingSlashes, ActiveOptions, Segment, ResolveRelativePath, RootRouteId, AnyPathParams, ResolveParams, ResolveOptionalParams, ResolveRequiredParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, UpdatableStaticRouteOption, MetaDescriptor, RouteLinkEntry, ParseParamsFn, SearchFilter, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, TrimPath, TrimPathLeft, TrimPathRight, StringifyParamsFn, ParamsOptions, InferAllParams, InferAllContext, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveLoaderData, ResolveRouteContext, SearchSerializer, SearchParser, TrailingSlashOption, Manifest, RouterManagedTag, ControlledPromise, Constrain, Expand, MergeAll, Assign, IntersectAssign, ResolveValidatorInput, ResolveValidatorOutput, AnyValidator, DefaultValidator, ValidatorFn, AnySchema, AnyValidatorAdapter, AnyValidatorFn, AnyValidatorObj, ResolveValidatorInputFn, ResolveValidatorOutputFn, ResolveSearchValidatorInput, ResolveSearchValidatorInputFn, Validator, ValidatorAdapter, ValidatorObj, NavigateFn, BuildLocationFn, InferDescendantToPaths, RelativeToPath, RelativeToParentPath, RelativeToCurrentPath, Register, AbsoluteToPath, RelativeToPathAutoComplete, NavigateOptions, ToOptions, ToMaskOptions, ToSubOptions, ResolveRoute, SearchParamOptions, PathParamOptions, ToPathOption, LinkOptions, MakeOptionalPathParams, AnyRouterWithContext, ParseRoute, RoutesById, RouteById, RouteIds, RoutesByPath, RouteByPath, RoutePaths, FullSearchSchema, AllParams, AllLoaderData, FullSearchSchemaInput, AllContext, CommitLocationOptions, MatchLocation, ResolveFullSearchSchema, ResolveFullSearchSchemaInput, ResolveAllParamsFromParent, RouteContextParameter, BeforeLoadContextParameter, ResolveAllContext, FullSearchSchemaOption, MakeRemountDepsOptionsUnion, RemountDepsOptions, FileRouteTypes, FileRoutesByPath, UseNavigateResult, AnyRedirect, Redirect, RedirectOptions, ResolvedRedirect, RouteOptions, FileBaseRouteOptions, BaseRouteOptions, UpdatableRouteOptions, RouteLoaderFn, LoaderFnContext, MakeRouteMatch, MakeRouteMatchUnion, RouteMatch, AnyRouteMatch, RouteContextFn, RouteContextOptions, BeforeLoadContextOptions, ContextOptions, RootRouteOptions, AnyRouteWithContext, LazyRouteOptions, AnyRoute, ResolveFullPath, RouteConstraints, RouterState, ListenerFn, BuildNextOptions, AnyRouter, RegisteredRouter, RouterEvents, RouterEvent, RouterListener, MatchRouteOptions, RouteMask, RouterContextOptions, RouterOptions, RouterConstructorOptions, ControllablePromise, InjectedHtmlEntry, CreateFileRoute, CreateLazyFileRoute, AnySerializationAdapter, SerializationAdapter, } from '@tanstack/router-core';
|
|
3
3
|
export { createHistory, createBrowserHistory, createHashHistory, createMemoryHistory, } from '@tanstack/history';
|
|
4
4
|
export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryState, } from '@tanstack/history';
|
|
5
5
|
export { useAwaited, Await } from './awaited.js';
|
|
@@ -47,3 +47,5 @@ export { ScriptOnce } from './ScriptOnce.js';
|
|
|
47
47
|
export { Asset } from './Asset.js';
|
|
48
48
|
export { HeadContent, useTags } from './HeadContent.js';
|
|
49
49
|
export { Scripts } from './Scripts.js';
|
|
50
|
+
export { rewriteBasepath, composeRewrites } from '@tanstack/router-core';
|
|
51
|
+
export type { LocationRewrite, LocationRewriteFunction, } from '@tanstack/router-core';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PathParamError, SearchParamError, TSR_DEFERRED_PROMISE, cleanPath, componentTypes, createControlledPromise, createSerializationAdapter, deepEqual, defaultParseSearch, defaultSerializeError, defaultStringifySearch, defer, functionalUpdate, getInitialRouterState, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, matchByPath, matchPathname, notFound, parsePathname, parseSearchWith, redirect,
|
|
1
|
+
import { PathParamError, SearchParamError, TSR_DEFERRED_PROMISE, cleanPath, componentTypes, composeRewrites, createControlledPromise, createSerializationAdapter, deepEqual, defaultParseSearch, defaultSerializeError, defaultStringifySearch, defer, functionalUpdate, getInitialRouterState, interpolatePath, isMatch, isNotFound, isPlainArray, isPlainObject, isRedirect, joinPaths, lazyFn, matchByPath, matchPathname, notFound, parsePathname, parseSearchWith, redirect, replaceEqualDeep, resolvePath, retainSearchParams, rewriteBasepath, rootRouteId, stringifySearchWith, stripSearchParams, trimPath, trimPathLeft, trimPathRight } from "@tanstack/router-core";
|
|
2
2
|
import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
|
|
3
3
|
import { Await, useAwaited } from "./awaited.js";
|
|
4
4
|
import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
|
|
@@ -66,6 +66,7 @@ export {
|
|
|
66
66
|
TSR_DEFERRED_PROMISE,
|
|
67
67
|
cleanPath,
|
|
68
68
|
componentTypes,
|
|
69
|
+
composeRewrites,
|
|
69
70
|
createBrowserHistory,
|
|
70
71
|
createControlledPromise,
|
|
71
72
|
createFileRoute,
|
|
@@ -107,10 +108,10 @@ export {
|
|
|
107
108
|
parsePathname,
|
|
108
109
|
parseSearchWith,
|
|
109
110
|
redirect,
|
|
110
|
-
removeBasepath,
|
|
111
111
|
replaceEqualDeep,
|
|
112
112
|
resolvePath,
|
|
113
113
|
retainSearchParams,
|
|
114
|
+
rewriteBasepath,
|
|
114
115
|
rootRouteId,
|
|
115
116
|
rootRouteWithContext,
|
|
116
117
|
stringifySearchWith,
|
package/dist/esm/link.js
CHANGED
|
@@ -5,7 +5,6 @@ import { functionalUpdate, preloadWarning, exactPathTest, removeTrailingSlash, d
|
|
|
5
5
|
import { useRouterState } from "./useRouterState.js";
|
|
6
6
|
import { useRouter } from "./useRouter.js";
|
|
7
7
|
import { useIntersectionObserver } from "./utils.js";
|
|
8
|
-
import { useActiveLocation } from "./useActiveLocation.js";
|
|
9
8
|
function useLinkProps(options) {
|
|
10
9
|
const router = useRouter();
|
|
11
10
|
const [isTransitioning, setIsTransitioning] = Solid.createSignal(false);
|
|
@@ -17,35 +16,58 @@ function useLinkProps(options) {
|
|
|
17
16
|
inactiveProps: () => ({})
|
|
18
17
|
}, options), ["activeProps", "inactiveProps", "activeOptions", "to", "preload", "preloadDelay", "hashScrollIntoView", "replace", "startTransition", "resetScroll", "viewTransition", "target", "disabled", "style", "class", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "onMouseOver", "onMouseOut", "onTouchStart", "ignoreBlocker"]);
|
|
19
18
|
const [_, propsSafeToSpread] = Solid.splitProps(rest, ["params", "search", "hash", "state", "mask", "reloadDocument", "unsafeRelative"]);
|
|
20
|
-
const type = () => {
|
|
21
|
-
try {
|
|
22
|
-
new URL(`${local.to}`);
|
|
23
|
-
return "external";
|
|
24
|
-
} catch {
|
|
25
|
-
}
|
|
26
|
-
return "internal";
|
|
27
|
-
};
|
|
28
19
|
const currentSearch = useRouterState({
|
|
29
20
|
select: (s) => s.location.searchStr
|
|
30
21
|
});
|
|
31
|
-
const
|
|
32
|
-
getFromPath,
|
|
33
|
-
activeLocation
|
|
34
|
-
} = useActiveLocation();
|
|
35
|
-
const from = getFromPath(options.from);
|
|
22
|
+
const from = options.from;
|
|
36
23
|
const _options = () => {
|
|
37
24
|
return {
|
|
38
25
|
...options,
|
|
39
|
-
from
|
|
26
|
+
from
|
|
40
27
|
};
|
|
41
28
|
};
|
|
42
29
|
const next = Solid.createMemo(() => {
|
|
43
30
|
currentSearch();
|
|
44
|
-
activeLocation();
|
|
45
31
|
return router.buildLocation(_options());
|
|
46
32
|
});
|
|
33
|
+
const hrefOption = Solid.createMemo(() => {
|
|
34
|
+
if (_options().disabled) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
let href;
|
|
38
|
+
const maskedLocation = next().maskedLocation;
|
|
39
|
+
if (maskedLocation) {
|
|
40
|
+
href = maskedLocation.url;
|
|
41
|
+
} else {
|
|
42
|
+
href = next().url;
|
|
43
|
+
}
|
|
44
|
+
let external = false;
|
|
45
|
+
if (router.origin) {
|
|
46
|
+
if (href.startsWith(router.origin)) {
|
|
47
|
+
href = href.replace(router.origin, "");
|
|
48
|
+
} else {
|
|
49
|
+
external = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
href,
|
|
54
|
+
external
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
const externalLink = Solid.createMemo(() => {
|
|
58
|
+
const _href = hrefOption();
|
|
59
|
+
if (_href?.external) {
|
|
60
|
+
return _href.href;
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
new URL(_options().to);
|
|
64
|
+
return _options().to;
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
return void 0;
|
|
68
|
+
});
|
|
47
69
|
const preload = Solid.createMemo(() => {
|
|
48
|
-
if (_options().reloadDocument) {
|
|
70
|
+
if (_options().reloadDocument || externalLink()) {
|
|
49
71
|
return false;
|
|
50
72
|
}
|
|
51
73
|
return local.preload ?? router.options.defaultPreload;
|
|
@@ -53,6 +75,7 @@ function useLinkProps(options) {
|
|
|
53
75
|
const preloadDelay = () => local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
54
76
|
const isActive = useRouterState({
|
|
55
77
|
select: (s) => {
|
|
78
|
+
if (externalLink()) return false;
|
|
56
79
|
if (local.activeOptions?.exact) {
|
|
57
80
|
const testExact = exactPathTest(s.location.pathname, next().pathname, router.basepath);
|
|
58
81
|
if (!testExact) {
|
|
@@ -105,19 +128,16 @@ function useLinkProps(options) {
|
|
|
105
128
|
hasRenderFetched = true;
|
|
106
129
|
}
|
|
107
130
|
});
|
|
108
|
-
if (
|
|
131
|
+
if (externalLink()) {
|
|
109
132
|
return Solid.mergeProps(propsSafeToSpread, {
|
|
110
133
|
ref,
|
|
111
|
-
|
|
112
|
-
return type();
|
|
113
|
-
},
|
|
114
|
-
get href() {
|
|
115
|
-
return local.to;
|
|
116
|
-
}
|
|
134
|
+
href: externalLink
|
|
117
135
|
}, Solid.splitProps(local, ["target", "disabled", "style", "class", "onClick", "onFocus", "onMouseEnter", "onMouseLeave", "onMouseOut", "onMouseOver", "onTouchStart"])[0]);
|
|
118
136
|
}
|
|
119
137
|
const handleClick = (e) => {
|
|
120
|
-
|
|
138
|
+
const elementTarget = e.currentTarget.target;
|
|
139
|
+
const effectiveTarget = local.target !== void 0 ? local.target : elementTarget;
|
|
140
|
+
if (!local.disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
|
|
121
141
|
e.preventDefault();
|
|
122
142
|
setIsTransitioning(true);
|
|
123
143
|
const unsub = router.subscribe("onResolved", () => {
|
|
@@ -188,14 +208,9 @@ function useLinkProps(options) {
|
|
|
188
208
|
...resolvedActiveProps().style,
|
|
189
209
|
...resolvedInactiveProps().style
|
|
190
210
|
});
|
|
191
|
-
const href = Solid.createMemo(() => {
|
|
192
|
-
const nextLocation = next();
|
|
193
|
-
const maskedLocation = nextLocation?.maskedLocation;
|
|
194
|
-
return _options().disabled ? void 0 : maskedLocation ? router.history.createHref(maskedLocation.href) : router.history.createHref(nextLocation?.href);
|
|
195
|
-
});
|
|
196
211
|
return Solid.mergeProps(propsSafeToSpread, resolvedActiveProps, resolvedInactiveProps, () => {
|
|
197
212
|
return {
|
|
198
|
-
href:
|
|
213
|
+
href: hrefOption()?.href,
|
|
199
214
|
ref: mergeRefs(setRef, _options().ref),
|
|
200
215
|
onClick: composeEventHandlers([local.onClick, handleClick]),
|
|
201
216
|
onFocus: composeEventHandlers([local.onFocus, handleFocus]),
|
package/dist/esm/link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport { mergeRefs } from '@solid-primitives/refs'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\nimport { Dynamic } from 'solid-js/web'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport { useActiveLocation } from './useActiveLocation'\nimport type {\n AnyRouter,\n Constrain,\n LinkCurrentTargetElement,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\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): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n let hasRenderFetched = false\n\n const [local, rest] = Solid.splitProps(\n Solid.mergeProps(\n {\n activeProps: () => ({ class: 'active' }),\n inactiveProps: () => ({}),\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n // const {\n // // custom props\n // activeProps = () => ({ class: 'active' }),\n // inactiveProps = () => ({}),\n // activeOptions,\n // to,\n // preload: userPreload,\n // preloadDelay: userPreloadDelay,\n // hashScrollIntoView,\n // replace,\n // startTransition,\n // resetScroll,\n // viewTransition,\n // // element props\n // children,\n // target,\n // disabled,\n // style,\n // class,\n // onClick,\n // onFocus,\n // onMouseEnter,\n // onMouseLeave,\n // onTouchStart,\n // ignoreBlocker,\n // ...rest\n // } = options\n\n const [_, propsSafeToSpread] = Solid.splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n ])\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 type: Solid.Accessor<'internal' | 'external'> = () => {\n try {\n new URL(`${local.to}`)\n return 'external'\n } catch {}\n return 'internal'\n }\n\n const currentSearch = useRouterState({\n select: (s) => s.location.searchStr,\n })\n\n const { getFromPath, activeLocation } = useActiveLocation()\n\n const from = getFromPath(options.from)\n\n const _options = () => {\n return {\n ...options,\n from: from(),\n }\n }\n\n const next = Solid.createMemo(() => {\n currentSearch()\n activeLocation()\n return router.buildLocation(_options() as any)\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = useRouterState({\n select: (s) => {\n if (local.activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next().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()?.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 (local.activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next().search, {\n partial: !local.activeOptions?.exact,\n ignoreUndefined: !local.activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (local.activeOptions?.includeHash) {\n return s.location.hash === next().hash\n }\n return true\n },\n })\n\n const doPreload = () =>\n router.preloadRoute(_options() 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, setRef] = Solid.createSignal<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(preload() === 'viewport') },\n )\n\n Solid.createEffect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preload() === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n if (type() === 'external') {\n return Solid.mergeProps(\n propsSafeToSpread,\n {\n ref,\n get type() {\n return type()\n },\n get href() {\n return local.to\n },\n },\n Solid.splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!local.target || local.target === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n setIsTransitioning(true)\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n // The click handler\n const handleFocus = (_: MouseEvent) => {\n if (local.disabled) return\n if (preload()) {\n doPreload()\n }\n }\n\n const handleTouchStart = handleFocus\n\n const handleEnter = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (preload()) {\n if (eventTarget.preloadTimeout) {\n return\n }\n\n eventTarget.preloadTimeout = setTimeout(() => {\n eventTarget.preloadTimeout = null\n doPreload()\n }, preloadDelay())\n }\n }\n\n const handleLeave = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (eventTarget.preloadTimeout) {\n clearTimeout(eventTarget.preloadTimeout)\n eventTarget.preloadTimeout = null\n }\n }\n\n /** Call a JSX.EventHandlerUnion with the event. */\n function callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n ) {\n if (handler) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n }\n\n return event.defaultPrevented\n }\n\n function composeEventHandlers<T>(\n handlers: Array<Solid.JSX.EventHandlerUnion<T, any> | undefined>,\n ) {\n return (event: any) => {\n for (const handler of handlers) {\n callHandler(event, handler)\n }\n }\n }\n\n // Get the active props\n const resolvedActiveProps: () => Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n } = () =>\n isActive() ? (functionalUpdate(local.activeProps as any, {}) ?? {}) : {}\n\n // Get the inactive props\n const resolvedInactiveProps: () => Omit<\n Solid.ComponentProps<'a'>,\n 'style'\n > & { style?: Solid.JSX.CSSProperties } = () =>\n isActive() ? {} : functionalUpdate(local.inactiveProps, {})\n\n const resolvedClassName = () =>\n [local.class, resolvedActiveProps().class, resolvedInactiveProps().class]\n .filter(Boolean)\n .join(' ')\n\n const resolvedStyle = () => ({\n ...local.style,\n ...resolvedActiveProps().style,\n ...resolvedInactiveProps().style,\n })\n\n const href = Solid.createMemo(() => {\n const nextLocation = next()\n const maskedLocation = nextLocation?.maskedLocation\n\n return _options().disabled\n ? undefined\n : maskedLocation\n ? router.history.createHref(maskedLocation.href)\n : router.history.createHref(nextLocation?.href)\n })\n\n return Solid.mergeProps(\n propsSafeToSpread,\n resolvedActiveProps,\n resolvedInactiveProps,\n () => {\n return {\n href: href(),\n ref: mergeRefs(setRef, _options().ref),\n onClick: composeEventHandlers([local.onClick, handleClick]),\n onFocus: composeEventHandlers([local.onFocus, handleFocus]),\n onMouseEnter: composeEventHandlers([local.onMouseEnter, handleEnter]),\n onMouseOver: composeEventHandlers([local.onMouseOver, handleEnter]),\n onMouseLeave: composeEventHandlers([local.onMouseLeave, handleLeave]),\n onMouseOut: composeEventHandlers([local.onMouseOut, handleLeave]),\n onTouchStart: composeEventHandlers([\n local.onTouchStart,\n handleTouchStart,\n ]),\n disabled: !!local.disabled,\n target: local.target,\n ...(Object.keys(resolvedStyle).length && { style: resolvedStyle }),\n ...(resolvedClassName() && { class: resolvedClassName() }),\n ...(local.disabled && {\n role: 'link',\n 'aria-disabled': true,\n }),\n ...(isActive() && { 'data-status': 'active', 'aria-current': 'page' }),\n ...(isTransitioning() && { 'data-transitioning': 'transitioning' }),\n }\n },\n ) as any\n}\n\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 Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\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 LinkComponentSolidProps<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 | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\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> = LinkComponentSolidProps<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) => Solid.JSX.Element\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 ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = Solid.splitProps(\n props as typeof props & { _asChild: any },\n ['_asChild', 'children'],\n )\n\n const [_, linkProps] = Solid.splitProps(\n useLinkProps(rest as unknown as any),\n ['type'],\n )\n\n const children = Solid.createMemo(() => {\n const ch = local.children\n if (typeof ch === 'function') {\n return ch({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n isTransitioning: false,\n })\n }\n\n return ch satisfies Solid.JSX.Element\n })\n\n return (\n <Dynamic component={local._asChild ? local._asChild : 'a'} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\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":["useLinkProps","options","router","useRouter","isTransitioning","setIsTransitioning","Solid","createSignal","hasRenderFetched","local","rest","splitProps","mergeProps","activeProps","class","inactiveProps","_","propsSafeToSpread","type","URL","to","currentSearch","useRouterState","select","s","location","searchStr","getFromPath","activeLocation","useActiveLocation","from","_options","next","createMemo","buildLocation","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","exactPathTest","pathname","basepath","currentPathSplit","removeTrailingSlash","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","deepEqual","search","partial","ignoreUndefined","explicitUndefined","includeHash","hash","doPreload","preloadRoute","catch","err","console","warn","preloadWarning","preloadViewportIoCallback","entry","isIntersecting","ref","setRef","useIntersectionObserver","rootMargin","disabled","createEffect","href","handleClick","e","isCtrlEvent","defaultPrevented","target","button","preventDefault","unsub","subscribe","navigate","replace","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","handleFocus","handleTouchStart","handleEnter","eventTarget","preloadTimeout","setTimeout","handleLeave","clearTimeout","callHandler","event","handler","composeEventHandlers","handlers","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","resolvedClassName","filter","Boolean","join","resolvedStyle","style","nextLocation","maskedLocation","undefined","history","createHref","mergeRefs","onClick","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","Object","keys","length","role","createLink","Comp","props","_$createComponent","Link","_$mergeProps","_asChild","linkProps","children","ch","Dynamic","component","metaKey","altKey","ctrlKey","shiftKey","linkOptions"],"mappings":";;;;;;;;AA+BO,SAASA,aAOdC,SAC2B;AAC3B,QAAMC,SAASC,UAAAA;AACf,QAAM,CAACC,iBAAiBC,kBAAkB,IAAIC,MAAMC,aAAa,KAAK;AACtE,MAAIC,mBAAmB;AAEvB,QAAM,CAACC,OAAOC,IAAI,IAAIJ,MAAMK,WAC1BL,MAAMM,WACJ;AAAA,IACEC,aAAaA,OAAO;AAAA,MAAEC,OAAO;AAAA,IAAA;AAAA,IAC7BC,eAAeA,OAAO,CAAA;AAAA,EAAC,GAEzBd,OACF,GACA,CACE,eACA,iBACA,iBACA,MACA,WACA,gBACA,sBACA,WACA,mBACA,eACA,kBACA,UACA,YACA,SACA,SACA,WACA,WACA,gBACA,gBACA,eACA,cACA,gBACA,eAAe,CAEnB;AA8BA,QAAM,CAACe,GAAGC,iBAAiB,IAAIX,MAAMK,WAAWD,MAAM,CACpD,UACA,UACA,QACA,SACA,QACA,kBACA,gBAAgB,CACjB;AAQD,QAAMQ,OAAgDA,MAAM;AAC1D,QAAI;AACF,UAAIC,IAAI,GAAGV,MAAMW,EAAE,EAAE;AACrB,aAAO;AAAA,IACT,QAAQ;AAAA,IAAC;AACT,WAAO;AAAA,EACT;AAEA,QAAMC,gBA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KC,gBAAMC,MAAIC,WAAKH,OAAK;AAAA,IAAEI,UAAUL;AAAAA,EAAAA,CAAI,CAAA;AACnD;AAEO,MAAMG,OAA4BF,CAAAA,UAAU;AACjD,QAAM,CAACjI,OAAOC,IAAI,IAAIJ,MAAMK,WAC1B+H,OACA,CAAC,YAAY,UAAU,CACzB;AAEA,QAAM,CAAC1H,GAAG+H,SAAS,IAAIzI,MAAMK,WAC3BX,aAAaU,IAAsB,GACnC,CAAC,MAAM,CACT;AAEA,QAAMsI,WAAW1I,MAAM2B,WAAW,MAAM;AACtC,UAAMgH,KAAKxI,MAAMuI;AACjB,QAAI,OAAOC,OAAO,YAAY;AAC5B,aAAOA,GAAG;AAAA,QACR,IAAIzG,WAAW;AACb,iBAAQuG,UAAkB,aAAa,MAAM;AAAA,QAC/C;AAAA,QACA3I,iBAAiB;AAAA,MAAA,CAClB;AAAA,IACH;AAEA,WAAO6I;AAAAA,EACT,CAAC;AAED,SAAAN,gBACGO,SAAOL,WAAA;AAAA,IAAA,IAACM,YAAS;AAAA,aAAE1I,MAAMqI,WAAWrI,MAAMqI,WAAW;AAAA,IAAG;AAAA,EAAA,GAAMC,WAAS;AAAA,IAAA,IAAAC,WAAA;AAAA,aACrEA,SAAAA;AAAAA,IAAU;AAAA,EAAA,CAAA,CAAA;AAGjB;AAEA,SAAS7D,YAAYD,GAAe;AAClC,SAAO,CAAC,EAAEA,EAAEkE,WAAWlE,EAAEmE,UAAUnE,EAAEoE,WAAWpE,EAAEqE;AACpD;AAkBO,MAAMC,cAAmCvJ,CAAAA,YAAY;AAC1D,SAAOA;AACT;"}
|
|
1
|
+
{"version":3,"file":"link.js","sources":["../../src/link.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\n\nimport { mergeRefs } from '@solid-primitives/refs'\n\nimport {\n deepEqual,\n exactPathTest,\n functionalUpdate,\n preloadWarning,\n removeTrailingSlash,\n} from '@tanstack/router-core'\nimport { Dynamic } from 'solid-js/web'\nimport { useRouterState } from './useRouterState'\nimport { useRouter } from './useRouter'\n\nimport { useIntersectionObserver } from './utils'\n\nimport type {\n AnyRouter,\n Constrain,\n LinkCurrentTargetElement,\n LinkOptions,\n RegisteredRouter,\n RoutePaths,\n} from '@tanstack/router-core'\nimport type {\n ValidateLinkOptions,\n ValidateLinkOptionsArray,\n} from './typePrimitives'\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): Solid.ComponentProps<'a'> {\n const router = useRouter()\n const [isTransitioning, setIsTransitioning] = Solid.createSignal(false)\n let hasRenderFetched = false\n\n const [local, rest] = Solid.splitProps(\n Solid.mergeProps(\n {\n activeProps: () => ({ class: 'active' }),\n inactiveProps: () => ({}),\n },\n options,\n ),\n [\n 'activeProps',\n 'inactiveProps',\n 'activeOptions',\n 'to',\n 'preload',\n 'preloadDelay',\n 'hashScrollIntoView',\n 'replace',\n 'startTransition',\n 'resetScroll',\n 'viewTransition',\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOver',\n 'onMouseOut',\n 'onTouchStart',\n 'ignoreBlocker',\n ],\n )\n\n // const {\n // // custom props\n // activeProps = () => ({ class: 'active' }),\n // inactiveProps = () => ({}),\n // activeOptions,\n // to,\n // preload: userPreload,\n // preloadDelay: userPreloadDelay,\n // hashScrollIntoView,\n // replace,\n // startTransition,\n // resetScroll,\n // viewTransition,\n // // element props\n // children,\n // target,\n // disabled,\n // style,\n // class,\n // onClick,\n // onFocus,\n // onMouseEnter,\n // onMouseLeave,\n // onTouchStart,\n // ignoreBlocker,\n // ...rest\n // } = options\n\n const [_, propsSafeToSpread] = Solid.splitProps(rest, [\n 'params',\n 'search',\n 'hash',\n 'state',\n 'mask',\n 'reloadDocument',\n 'unsafeRelative',\n ])\n\n const currentSearch = useRouterState({\n select: (s) => s.location.searchStr,\n })\n\n const from = options.from\n\n const _options = () => {\n return {\n ...options,\n from,\n }\n }\n\n const next = Solid.createMemo(() => {\n currentSearch()\n return router.buildLocation(_options() as any)\n })\n\n const hrefOption = Solid.createMemo(() => {\n if (_options().disabled) {\n return undefined\n }\n let href\n const maskedLocation = next().maskedLocation\n if (maskedLocation) {\n href = maskedLocation.url\n } else {\n href = next().url\n }\n let external = false\n if (router.origin) {\n if (href.startsWith(router.origin)) {\n href = href.replace(router.origin, '')\n } else {\n external = true\n }\n }\n return { href, external }\n })\n\n const externalLink = Solid.createMemo(() => {\n const _href = hrefOption()\n if (_href?.external) {\n return _href.href\n }\n try {\n new URL(_options().to as any)\n return _options().to\n } catch {}\n return undefined\n })\n\n const preload = Solid.createMemo(() => {\n if (_options().reloadDocument || externalLink()) {\n return false\n }\n return local.preload ?? router.options.defaultPreload\n })\n const preloadDelay = () =>\n local.preloadDelay ?? router.options.defaultPreloadDelay ?? 0\n\n const isActive = useRouterState({\n select: (s) => {\n if (externalLink()) return false\n if (local.activeOptions?.exact) {\n const testExact = exactPathTest(\n s.location.pathname,\n next().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()?.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 (local.activeOptions?.includeSearch ?? true) {\n const searchTest = deepEqual(s.location.search, next().search, {\n partial: !local.activeOptions?.exact,\n ignoreUndefined: !local.activeOptions?.explicitUndefined,\n })\n if (!searchTest) {\n return false\n }\n }\n\n if (local.activeOptions?.includeHash) {\n return s.location.hash === next().hash\n }\n return true\n },\n })\n\n const doPreload = () =>\n router.preloadRoute(_options() 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, setRef] = Solid.createSignal<Element | null>(null)\n\n useIntersectionObserver(\n ref,\n preloadViewportIoCallback,\n { rootMargin: '100px' },\n { disabled: !!local.disabled || !(preload() === 'viewport') },\n )\n\n Solid.createEffect(() => {\n if (hasRenderFetched) {\n return\n }\n if (!local.disabled && preload() === 'render') {\n doPreload()\n hasRenderFetched = true\n }\n })\n\n if (externalLink()) {\n return Solid.mergeProps(\n propsSafeToSpread,\n {\n ref,\n href: externalLink,\n },\n Solid.splitProps(local, [\n 'target',\n 'disabled',\n 'style',\n 'class',\n 'onClick',\n 'onFocus',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onMouseOut',\n 'onMouseOver',\n 'onTouchStart',\n ])[0],\n ) as any\n }\n\n // The click handler\n const handleClick = (e: MouseEvent) => {\n // Check actual element's target attribute as fallback\n const elementTarget = (e.currentTarget as HTMLAnchorElement).target\n const effectiveTarget =\n local.target !== undefined ? local.target : elementTarget\n\n if (\n !local.disabled &&\n !isCtrlEvent(e) &&\n !e.defaultPrevented &&\n (!effectiveTarget || effectiveTarget === '_self') &&\n e.button === 0\n ) {\n e.preventDefault()\n\n setIsTransitioning(true)\n\n const unsub = router.subscribe('onResolved', () => {\n unsub()\n setIsTransitioning(false)\n })\n\n // All is well? Navigate!\n // N.B. we don't call `router.commitLocation(next) here because we want to run `validateSearch` before committing\n router.navigate({\n ..._options(),\n replace: local.replace,\n resetScroll: local.resetScroll,\n hashScrollIntoView: local.hashScrollIntoView,\n startTransition: local.startTransition,\n viewTransition: local.viewTransition,\n ignoreBlocker: local.ignoreBlocker,\n })\n }\n }\n\n // The click handler\n const handleFocus = (_: MouseEvent) => {\n if (local.disabled) return\n if (preload()) {\n doPreload()\n }\n }\n\n const handleTouchStart = handleFocus\n\n const handleEnter = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (preload()) {\n if (eventTarget.preloadTimeout) {\n return\n }\n\n eventTarget.preloadTimeout = setTimeout(() => {\n eventTarget.preloadTimeout = null\n doPreload()\n }, preloadDelay())\n }\n }\n\n const handleLeave = (e: MouseEvent) => {\n if (local.disabled) return\n const eventTarget = (e.target || {}) as LinkCurrentTargetElement\n\n if (eventTarget.preloadTimeout) {\n clearTimeout(eventTarget.preloadTimeout)\n eventTarget.preloadTimeout = null\n }\n }\n\n /** Call a JSX.EventHandlerUnion with the event. */\n function callHandler<T, TEvent extends Event>(\n event: TEvent & { currentTarget: T; target: Element },\n handler: Solid.JSX.EventHandlerUnion<T, TEvent> | undefined,\n ) {\n if (handler) {\n if (typeof handler === 'function') {\n handler(event)\n } else {\n handler[0](handler[1], event)\n }\n }\n\n return event.defaultPrevented\n }\n\n function composeEventHandlers<T>(\n handlers: Array<Solid.JSX.EventHandlerUnion<T, any> | undefined>,\n ) {\n return (event: any) => {\n for (const handler of handlers) {\n callHandler(event, handler)\n }\n }\n }\n\n // Get the active props\n const resolvedActiveProps: () => Omit<Solid.ComponentProps<'a'>, 'style'> & {\n style?: Solid.JSX.CSSProperties\n } = () =>\n isActive() ? (functionalUpdate(local.activeProps as any, {}) ?? {}) : {}\n\n // Get the inactive props\n const resolvedInactiveProps: () => Omit<\n Solid.ComponentProps<'a'>,\n 'style'\n > & { style?: Solid.JSX.CSSProperties } = () =>\n isActive() ? {} : functionalUpdate(local.inactiveProps, {})\n\n const resolvedClassName = () =>\n [local.class, resolvedActiveProps().class, resolvedInactiveProps().class]\n .filter(Boolean)\n .join(' ')\n\n const resolvedStyle = () => ({\n ...local.style,\n ...resolvedActiveProps().style,\n ...resolvedInactiveProps().style,\n })\n\n return Solid.mergeProps(\n propsSafeToSpread,\n resolvedActiveProps,\n resolvedInactiveProps,\n () => {\n return {\n href: hrefOption()?.href,\n ref: mergeRefs(setRef, _options().ref),\n onClick: composeEventHandlers([local.onClick, handleClick]),\n onFocus: composeEventHandlers([local.onFocus, handleFocus]),\n onMouseEnter: composeEventHandlers([local.onMouseEnter, handleEnter]),\n onMouseOver: composeEventHandlers([local.onMouseOver, handleEnter]),\n onMouseLeave: composeEventHandlers([local.onMouseLeave, handleLeave]),\n onMouseOut: composeEventHandlers([local.onMouseOut, handleLeave]),\n onTouchStart: composeEventHandlers([\n local.onTouchStart,\n handleTouchStart,\n ]),\n disabled: !!local.disabled,\n target: local.target,\n ...(Object.keys(resolvedStyle).length && { style: resolvedStyle }),\n ...(resolvedClassName() && { class: resolvedClassName() }),\n ...(local.disabled && {\n role: 'link',\n 'aria-disabled': true,\n }),\n ...(isActive() && { 'data-status': 'active', 'aria-current': 'page' }),\n ...(isTransitioning() && { 'data-transitioning': 'transitioning' }),\n }\n },\n ) as any\n}\n\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 Omit<Solid.ComponentProps<'a'>, 'style'> & { style?: Solid.JSX.CSSProperties }\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 LinkComponentSolidProps<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 | Solid.JSX.Element\n | ((state: {\n isActive: boolean\n isTransitioning: boolean\n }) => Solid.JSX.Element)\n}\n\ntype LinkComponentSolidProps<TComp> = TComp extends Solid.ValidComponent\n ? Omit<Solid.ComponentProps<TComp>, keyof CreateLinkProps>\n : never\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> = LinkComponentSolidProps<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) => Solid.JSX.Element\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 ): Solid.JSX.Element\n}\n\nexport function createLink<const TComp>(\n Comp: Constrain<TComp, any, (props: CreateLinkProps) => Solid.JSX.Element>,\n): LinkComponent<TComp> {\n return (props) => <Link {...props} _asChild={Comp} />\n}\n\nexport const Link: LinkComponent<'a'> = (props) => {\n const [local, rest] = Solid.splitProps(\n props as typeof props & { _asChild: any },\n ['_asChild', 'children'],\n )\n\n const [_, linkProps] = Solid.splitProps(\n useLinkProps(rest as unknown as any),\n ['type'],\n )\n\n const children = Solid.createMemo(() => {\n const ch = local.children\n if (typeof ch === 'function') {\n return ch({\n get isActive() {\n return (linkProps as any)['data-status'] === 'active'\n },\n isTransitioning: false,\n })\n }\n\n return ch satisfies Solid.JSX.Element\n })\n\n return (\n <Dynamic component={local._asChild ? local._asChild : 'a'} {...linkProps}>\n {children()}\n </Dynamic>\n )\n}\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":["useLinkProps","options","router","useRouter","isTransitioning","setIsTransitioning","Solid","createSignal","hasRenderFetched","local","rest","splitProps","mergeProps","activeProps","class","inactiveProps","_","propsSafeToSpread","currentSearch","useRouterState","select","s","location","searchStr","from","_options","next","createMemo","buildLocation","hrefOption","disabled","undefined","href","maskedLocation","url","external","origin","startsWith","replace","externalLink","_href","URL","to","preload","reloadDocument","defaultPreload","preloadDelay","defaultPreloadDelay","isActive","activeOptions","exact","testExact","exactPathTest","pathname","basepath","currentPathSplit","removeTrailingSlash","split","nextPathSplit","pathIsFuzzyEqual","every","d","i","includeSearch","searchTest","deepEqual","search","partial","ignoreUndefined","explicitUndefined","includeHash","hash","doPreload","preloadRoute","catch","err","console","warn","preloadWarning","preloadViewportIoCallback","entry","isIntersecting","ref","setRef","useIntersectionObserver","rootMargin","createEffect","handleClick","e","elementTarget","currentTarget","target","effectiveTarget","isCtrlEvent","defaultPrevented","button","preventDefault","unsub","subscribe","navigate","resetScroll","hashScrollIntoView","startTransition","viewTransition","ignoreBlocker","handleFocus","handleTouchStart","handleEnter","eventTarget","preloadTimeout","setTimeout","handleLeave","clearTimeout","callHandler","event","handler","composeEventHandlers","handlers","resolvedActiveProps","functionalUpdate","resolvedInactiveProps","resolvedClassName","filter","Boolean","join","resolvedStyle","style","mergeRefs","onClick","onFocus","onMouseEnter","onMouseOver","onMouseLeave","onMouseOut","onTouchStart","Object","keys","length","role","createLink","Comp","props","_$createComponent","Link","_$mergeProps","_asChild","linkProps","children","ch","Dynamic","component","metaKey","altKey","ctrlKey","shiftKey","linkOptions"],"mappings":";;;;;;;AA8BO,SAASA,aAOdC,SAC2B;AAC3B,QAAMC,SAASC,UAAAA;AACf,QAAM,CAACC,iBAAiBC,kBAAkB,IAAIC,MAAMC,aAAa,KAAK;AACtE,MAAIC,mBAAmB;AAEvB,QAAM,CAACC,OAAOC,IAAI,IAAIJ,MAAMK,WAC1BL,MAAMM,WACJ;AAAA,IACEC,aAAaA,OAAO;AAAA,MAAEC,OAAO;AAAA,IAAA;AAAA,IAC7BC,eAAeA,OAAO,CAAA;AAAA,EAAC,GAEzBd,OACF,GACA,CACE,eACA,iBACA,iBACA,MACA,WACA,gBACA,s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