@tanstack/react-router 0.0.1-beta.242 → 0.0.1-beta.243

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.
@@ -38,12 +38,13 @@ function useNavigate(defaultOpts) {
38
38
  const {
39
39
  navigate
40
40
  } = RouterProvider.useRouter();
41
- const match = Matches.useMatch({
42
- strict: false
41
+ const matchPathname = Matches.useMatch({
42
+ strict: false,
43
+ select: s => s.pathname
43
44
  });
44
45
  return React__namespace.useCallback(opts => {
45
46
  return navigate({
46
- from: opts?.to ? match.pathname : undefined,
47
+ from: opts?.to ? matchPathname : undefined,
47
48
  ...defaultOpts,
48
49
  ...opts
49
50
  });
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigate.js","sources":["../../src/useNavigate.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMatch } from './Matches'\nimport { useRouter } from './RouterProvider'\nimport { LinkOptions, NavigateOptions } from './link'\nimport { AnyRoute } from './route'\nimport { RoutePaths } from './routeInfo'\nimport { RegisteredRouter } from './router'\nimport { useLayoutEffect } from './utils'\n\nexport function useNavigate<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDefaultFrom extends RoutePaths<TRouteTree> = '/',\n>(defaultOpts?: { from?: TDefaultFrom }) {\n const { navigate } = useRouter()\n const match = useMatch({\n strict: false,\n })\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = TDefaultFrom,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n >(\n opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ) => {\n return navigate({\n from: opts?.to ? match.pathname : undefined,\n ...defaultOpts,\n ...(opts as any),\n })\n },\n [],\n )\n}\n\nexport function typedNavigate<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDefaultFrom extends RoutePaths<TRouteTree> = '/',\n>(navigate: (opts: NavigateOptions<any>) => Promise<void>) {\n return navigate as <\n TFrom extends RoutePaths<TRouteTree> = TDefaultFrom,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n >(\n opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ) => Promise<void>\n} //\n\nexport function Navigate<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n>(props: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): null {\n const { navigate } = useRouter()\n const match = useMatch({ strict: false })\n\n useLayoutEffect(() => {\n navigate({\n from: props.to ? match.pathname : undefined,\n ...props,\n } as any)\n }, [])\n\n return null\n}\n\nexport type MakeLinkPropsOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = LinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>\n\nexport type MakeLinkOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = LinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | React.ReactNode\n | ((state: { isActive: boolean }) => React.ReactNode)\n }\n\nexport type LinkPropsOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = LinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n activeProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n // A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n inactiveProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n}\n"],"names":["useNavigate","defaultOpts","navigate","useRouter","match","useMatch","strict","React","useCallback","opts","from","to","pathname","undefined","typedNavigate","Navigate","props","useLayoutEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,SAASA,WAAWA,CAGzBC,WAAqC,EAAE;EACvC,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,wBAAS,EAAE,CAAA;EAChC,MAAMC,KAAK,GAAGC,gBAAQ,CAAC;AACrBC,IAAAA,MAAM,EAAE,KAAA;AACV,GAAC,CAAC,CAAA;AACF,EAAA,OAAOC,gBAAK,CAACC,WAAW,CAOpBC,IAAkE,IAC/D;AACH,IAAA,OAAOP,QAAQ,CAAC;MACdQ,IAAI,EAAED,IAAI,EAAEE,EAAE,GAAGP,KAAK,CAACQ,QAAQ,GAAGC,SAAS;AAC3C,MAAA,GAAGZ,WAAW;MACd,GAAIQ,IAAAA;AACN,KAAC,CAAC,CAAA;GACH,EACD,EACF,CAAC,CAAA;AACH,CAAA;AAEO,SAASK,aAAaA,CAG3BZ,QAAuD,EAAE;AACzD,EAAA,OAAOA,QAAQ,CAAA;AAQjB,CAAC;;AAEM,SAASa,QAAQA,CAMtBC,KAAkE,EAAQ;EAC1E,MAAM;AAAEd,IAAAA,QAAAA;GAAU,GAAGC,wBAAS,EAAE,CAAA;EAChC,MAAMC,KAAK,GAAGC,gBAAQ,CAAC;AAAEC,IAAAA,MAAM,EAAE,KAAA;AAAM,GAAC,CAAC,CAAA;AAEzCW,EAAAA,qBAAe,CAAC,MAAM;AACpBf,IAAAA,QAAQ,CAAC;MACPQ,IAAI,EAAEM,KAAK,CAACL,EAAE,GAAGP,KAAK,CAACQ,QAAQ,GAAGC,SAAS;MAC3C,GAAGG,KAAAA;AACL,KAAQ,CAAC,CAAA;GACV,EAAE,EAAE,CAAC,CAAA;AAEN,EAAA,OAAO,IAAI,CAAA;AACb;;;;;;"}
1
+ {"version":3,"file":"useNavigate.js","sources":["../../src/useNavigate.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useMatch } from './Matches'\nimport { useRouter } from './RouterProvider'\nimport { LinkOptions, NavigateOptions } from './link'\nimport { AnyRoute } from './route'\nimport { RoutePaths } from './routeInfo'\nimport { RegisteredRouter } from './router'\nimport { useLayoutEffect } from './utils'\n\nexport function useNavigate<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDefaultFrom extends RoutePaths<TRouteTree> = '/',\n>(defaultOpts?: { from?: TDefaultFrom }) {\n const { navigate } = useRouter()\n const matchPathname = useMatch({\n strict: false,\n select: (s) => s.pathname,\n })\n return React.useCallback(\n <\n TFrom extends RoutePaths<TRouteTree> = TDefaultFrom,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n >(\n opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ) => {\n return navigate({\n from: opts?.to ? matchPathname : undefined,\n ...defaultOpts,\n ...(opts as any),\n })\n },\n [],\n )\n}\n\nexport function typedNavigate<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TDefaultFrom extends RoutePaths<TRouteTree> = '/',\n>(navigate: (opts: NavigateOptions<any>) => Promise<void>) {\n return navigate as <\n TFrom extends RoutePaths<TRouteTree> = TDefaultFrom,\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n >(\n opts?: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>,\n ) => Promise<void>\n} //\n\nexport function Navigate<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n>(props: NavigateOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo>): null {\n const { navigate } = useRouter()\n const match = useMatch({ strict: false })\n\n useLayoutEffect(() => {\n navigate({\n from: props.to ? match.pathname : undefined,\n ...props,\n } as any)\n }, [])\n\n return null\n}\n\nexport type MakeLinkPropsOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = LinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n React.AnchorHTMLAttributes<HTMLAnchorElement>\n\nexport type MakeLinkOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = LinkPropsOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> &\n Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'children'> & {\n // If a function is passed as a child, it will be given the `isActive` boolean to aid in further styling on the element it returns\n children?:\n | React.ReactNode\n | ((state: { isActive: boolean }) => React.ReactNode)\n }\n\nexport type LinkPropsOptions<\n TRouteTree extends AnyRoute = RegisteredRouter['routeTree'],\n TFrom extends RoutePaths<TRouteTree> = '/',\n TTo extends string = '',\n TMaskFrom extends RoutePaths<TRouteTree> = '/',\n TMaskTo extends string = '',\n> = LinkOptions<TRouteTree, TFrom, TTo, TMaskFrom, TMaskTo> & {\n // A function that returns additional props for the `active` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n activeProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n // A function that returns additional props for the `inactive` state of this link. These props override other props passed to the link (`style`'s are merged, `className`'s are concatenated)\n inactiveProps?:\n | React.AnchorHTMLAttributes<HTMLAnchorElement>\n | (() => React.AnchorHTMLAttributes<HTMLAnchorElement>)\n}\n"],"names":["useNavigate","defaultOpts","navigate","useRouter","matchPathname","useMatch","strict","select","s","pathname","React","useCallback","opts","from","to","undefined","typedNavigate","Navigate","props","match","useLayoutEffect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASO,SAASA,WAAWA,CAGzBC,WAAqC,EAAE;EACvC,MAAM;AAAEC,IAAAA,QAAAA;GAAU,GAAGC,wBAAS,EAAE,CAAA;EAChC,MAAMC,aAAa,GAAGC,gBAAQ,CAAC;AAC7BC,IAAAA,MAAM,EAAE,KAAK;AACbC,IAAAA,MAAM,EAAGC,CAAC,IAAKA,CAAC,CAACC,QAAAA;AACnB,GAAC,CAAC,CAAA;AACF,EAAA,OAAOC,gBAAK,CAACC,WAAW,CAOpBC,IAAkE,IAC/D;AACH,IAAA,OAAOV,QAAQ,CAAC;AACdW,MAAAA,IAAI,EAAED,IAAI,EAAEE,EAAE,GAAGV,aAAa,GAAGW,SAAS;AAC1C,MAAA,GAAGd,WAAW;MACd,GAAIW,IAAAA;AACN,KAAC,CAAC,CAAA;GACH,EACD,EACF,CAAC,CAAA;AACH,CAAA;AAEO,SAASI,aAAaA,CAG3Bd,QAAuD,EAAE;AACzD,EAAA,OAAOA,QAAQ,CAAA;AAQjB,CAAC;;AAEM,SAASe,QAAQA,CAMtBC,KAAkE,EAAQ;EAC1E,MAAM;AAAEhB,IAAAA,QAAAA;GAAU,GAAGC,wBAAS,EAAE,CAAA;EAChC,MAAMgB,KAAK,GAAGd,gBAAQ,CAAC;AAAEC,IAAAA,MAAM,EAAE,KAAA;AAAM,GAAC,CAAC,CAAA;AAEzCc,EAAAA,qBAAe,CAAC,MAAM;AACpBlB,IAAAA,QAAQ,CAAC;MACPW,IAAI,EAAEK,KAAK,CAACJ,EAAE,GAAGK,KAAK,CAACV,QAAQ,GAAGM,SAAS;MAC3C,GAAGG,KAAAA;AACL,KAAQ,CAAC,CAAA;GACV,EAAE,EAAE,CAAC,CAAA;AAEN,EAAA,OAAO,IAAI,CAAA;AACb;;;;;;"}
@@ -2520,12 +2520,13 @@ function useNavigate(defaultOpts) {
2520
2520
  const {
2521
2521
  navigate
2522
2522
  } = useRouter();
2523
- const match = useMatch({
2524
- strict: false
2523
+ const matchPathname = useMatch({
2524
+ strict: false,
2525
+ select: s => s.pathname
2525
2526
  });
2526
2527
  return React.useCallback(opts => {
2527
2528
  return navigate({
2528
- from: opts?.to ? match.pathname : undefined,
2529
+ from: opts?.to ? matchPathname : undefined,
2529
2530
  ...defaultOpts,
2530
2531
  ...opts
2531
2532
  });