@tanstack/react-router 0.0.1-beta.255 → 0.0.1-beta.256

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.
@@ -13,7 +13,6 @@
13
13
  var React = require('react');
14
14
  var Matches = require('./Matches.js');
15
15
  var RouterProvider = require('./RouterProvider.js');
16
- var utils = require('./utils.js');
17
16
 
18
17
  function _interopNamespaceDefault(e) {
19
18
  var n = Object.create(null);
@@ -61,7 +60,7 @@ function Navigate(props) {
61
60
  const match = Matches.useMatch({
62
61
  strict: false
63
62
  });
64
- utils.useLayoutEffect(() => {
63
+ React__namespace.useEffect(() => {
65
64
  navigate({
66
65
  from: props.to ? match.pathname : undefined,
67
66
  ...props
@@ -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 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;;;;;;"}
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 React.useEffect(() => {\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","useEffect"],"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;EAEzCI,gBAAK,CAACU,SAAS,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;;;;;;"}
@@ -2575,7 +2575,7 @@ function Navigate(props) {
2575
2575
  const match = useMatch({
2576
2576
  strict: false
2577
2577
  });
2578
- useLayoutEffect$1(() => {
2578
+ React.useEffect(() => {
2579
2579
  navigate({
2580
2580
  from: props.to ? match.pathname : undefined,
2581
2581
  ...props