UNPKG

@tanstack/solid-router

Version:

Modern and scalable routing for Solid applications

1 lines 2.98 kB
{"version":3,"file":"RouterProvider.cjs","names":["routerContext","SafeFragment","Matches","AnyRouter","RegisteredRouter","RouterOptions","Solid","RouterContextProvider","Record","router","children","rest","RouterProps","TRouter","TDehydrated","JSX","Element","update","options","context","OptionalWrapper","Wrap","_$createComponent","Provider","value","RouterProvider","_$mergeProps","Omit","NonNullable","Partial"],"sources":["../../src/RouterProvider.tsx"],"sourcesContent":["import { routerContext } from './routerContext'\nimport { SafeFragment } from './SafeFragment'\nimport { Matches } from './Matches'\nimport type {\n AnyRouter,\n RegisteredRouter,\n RouterOptions,\n} from '@tanstack/router-core'\nimport type * as Solid from 'solid-js'\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 })\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"],"mappings":";;;;;AAUA,SAAgBO,sBAGd,EACAE,QACAC,UACA,GAAGC,QAGF;CAEDF,OAAOQ,OAAO;EACZ,GAAGR,OAAOS;EACV,GAAGP;EACHQ,SAAS;GACP,GAAGV,OAAOS,QAAQC;GAClB,GAAGR,KAAKQ;EACV;CACF,CAAC;CAID,QAAA,GAAA,aAAA,iBAFwBV,OAAOS,QAAQG,QAAQpB,qBAAAA,cAG7B,EAAA,IAAAS,WAAA;EAAA,QAAA,GAAA,aAAA,iBACbV,sBAAAA,cAAcuB,UAAQ;GAACC,OAAOf;GAAmB,IAAAC,WAAA;IAAA,OAC/CA,SAAS;GAAC;EAAA,CAAA;CAAA,EAAA,CAAA;AAInB;AAEA,SAAgBe,eAGd,EAAEhB,QAAQ,GAAGE,QAA2C;CACxD,QAAA,GAAA,aAAA,iBACGJ,wBAAAA,GAAAA,aAAAA,YAAqB,EAASE,OAAM,GAAME,MAAI,EAAAD,iBAAAA,GAAAA,aAAAA,iBACrCR,gBAAAA,SAAO,CAAA,CAAA,EAAG,CAAA,CAAA;AAGxB"}