@argon-router/react 0.5.1 → 0.6.1
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/README.md +2 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +99 -0
- package/dist/index.js +70 -74
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Router without a headache
|
|
4
4
|
|
|
5
5
|
> [!WARNING]
|
|
6
|
-
> argon-router is
|
|
6
|
+
> argon-router is not production ready yet and still may have bugs and unstable API. If you found bug — please report it on GitHub.
|
|
7
7
|
|
|
8
8
|
## Documentation
|
|
9
9
|
|
|
@@ -13,6 +13,7 @@ For additional information, guides and api reference visit [documentation site](
|
|
|
13
13
|
|
|
14
14
|
- [@argon-router/core](https://www.npmjs.com/package/@argon-router/core)
|
|
15
15
|
- [@argon-router/react](https://www.npmjs.com/package/@argon-router/react)
|
|
16
|
+
- [@argon-router/paths](https://www.npmjs.com/package/@argon-router/paths)
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var de;function Oe(){if(de)return S;de=1;var a=Symbol.for("react.transitional.element"),
|
|
9
|
+
*/var de;function Oe(){if(de)return S;de=1;var a=Symbol.for("react.transitional.element"),v=Symbol.for("react.fragment");function s(b,l,i){var E=null;if(i!==void 0&&(E=""+i),l.key!==void 0&&(E=""+l.key),"key"in l){i={};for(var m in l)m!=="key"&&(i[m]=l[m])}else i=l;return l=i.ref,{$$typeof:a,type:b,key:E,ref:l!==void 0?l:null,props:i}}return S.Fragment=v,S.jsx=s,S.jsxs=s,S}var O={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ve;function Ae(){return ve||(ve=1,process.env.NODE_ENV!=="production"&&function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case M:return"Fragment";case Te:return"Portal";case K:return"Profiler";case B:return"StrictMode";case V:return"Suspense";case W:return"SuspenseList"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Z:return(e.displayName||"Context")+".Provider";case I:return(e._context.displayName||"Context")+".Consumer";case $:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return r=e.displayName||null,r!==null?r:a(e.type)||"Memo";case q:r=e._payload,e=e._init;try{return a(e(r))}catch{}}return null}function
|
|
17
|
+
*/var ve;function Ae(){return ve||(ve=1,process.env.NODE_ENV!=="production"&&function(){function a(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===pe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case M:return"Fragment";case Te:return"Portal";case K:return"Profiler";case B:return"StrictMode";case V:return"Suspense";case W:return"SuspenseList"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case Z:return(e.displayName||"Context")+".Provider";case I:return(e._context.displayName||"Context")+".Consumer";case $:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case U:return r=e.displayName||null,r!==null?r:a(e.type)||"Memo";case q:r=e._payload,e=e._init;try{return a(e(r))}catch{}}return null}function v(e){return""+e}function s(e){try{v(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),v(e)}}function b(){}function l(){if(p===0){ee=console.log,re=console.info,te=console.warn,oe=console.error,ne=console.group,ae=console.groupCollapsed,ue=console.groupEnd;var e={configurable:!0,enumerable:!0,value:b,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}p++}function i(){if(p--,p===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:h({},e,{value:ee}),info:h({},e,{value:re}),warn:h({},e,{value:te}),error:h({},e,{value:oe}),group:h({},e,{value:ne}),groupCollapsed:h({},e,{value:ae}),groupEnd:h({},e,{value:ue})})}0>p&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function E(e){if(J===void 0)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);J=r&&r[1]||"",se=-1<t.stack.indexOf(`
|
|
18
18
|
at`)?" (<anonymous>)":-1<t.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
19
|
-
`+J+e+se}function m(e,r){if(!e||L)return"";var t=G.get(e);if(t!==void 0)return t;L=!0,t=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var n=null;n=
|
|
19
|
+
`+J+e+se}function m(e,r){if(!e||L)return"";var t=G.get(e);if(t!==void 0)return t;L=!0,t=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var n=null;n=_.H,_.H=null,l();try{var c={DetermineComponentFrameRoot:function(){try{if(r){var x=function(){throw Error()};if(Object.defineProperty(x.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(x,[])}catch(w){var A=w}Reflect.construct(e,[],x)}else{try{x.call()}catch(w){A=w}e.call(x.prototype)}}else{try{throw Error()}catch(w){A=w}(x=e())&&typeof x.catch=="function"&&x.catch(function(){})}}catch(w){if(w&&A&&typeof w.stack=="string")return[w.stack,A.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=c.DetermineComponentFrameRoot(),R=o[0],k=o[1];if(R&&k){var f=R.split(`
|
|
20
20
|
`),T=k.split(`
|
|
21
|
-
`);for(o=u=0;u<
|
|
22
|
-
`+
|
|
21
|
+
`);for(o=u=0;u<f.length&&!f[u].includes("DetermineComponentFrameRoot");)u++;for(;o<T.length&&!T[o].includes("DetermineComponentFrameRoot");)o++;if(u===f.length||o===T.length)for(u=f.length-1,o=T.length-1;1<=u&&0<=o&&f[u]!==T[o];)o--;for(;1<=u&&0<=o;u--,o--)if(f[u]!==T[o]){if(u!==1||o!==1)do if(u--,o--,0>o||f[u]!==T[o]){var C=`
|
|
22
|
+
`+f[u].replace(" at new "," at ");return e.displayName&&C.includes("<anonymous>")&&(C=C.replace("<anonymous>",e.displayName)),typeof e=="function"&&G.set(e,C),C}while(1<=u&&0<=o);break}}}finally{L=!1,_.H=n,i(),Error.prepareStackTrace=t}return f=(f=e?e.displayName||e.name:"")?E(f):"",typeof e=="function"&&G.set(e,f),f}function j(e){if(e==null)return"";if(typeof e=="function"){var r=e.prototype;return m(e,!(!r||!r.isReactComponent))}if(typeof e=="string")return E(e);switch(e){case V:return E("Suspense");case W:return E("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case $:return e=m(e.render,!1),e;case U:return j(e.type);case q:r=e._payload,e=e._init;try{return j(e(r))}catch{}}return""}function g(){var e=_.A;return e===null?null:e.getOwner()}function we(e){if(D.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function xe(e,r){function t(){le||(le=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function ye(){var e=a(this.type);return ie[e]||(ie[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function je(e,r,t,n,c,u){return t=u.ref,e={$$typeof:Y,type:e,key:r,props:u,_owner:c},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:ye}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function F(e,r,t,n,c,u){if(typeof e=="string"||typeof e=="function"||e===M||e===K||e===B||e===V||e===W||e===ke||typeof e=="object"&&e!==null&&(e.$$typeof===q||e.$$typeof===U||e.$$typeof===Z||e.$$typeof===I||e.$$typeof===$||e.$$typeof===Ce||e.getModuleId!==void 0)){var o=r.children;if(o!==void 0)if(n)if(z(o)){for(n=0;n<o.length;n++)H(o[n],e);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else H(o,e)}else o="",(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(o+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),e===null?n="null":z(e)?n="array":e!==void 0&&e.$$typeof===Y?(n="<"+(a(e.type)||"Unknown")+" />",o=" Did you accidentally export a JSX literal instead of a component?"):n=typeof e,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",n,o);if(D.call(r,"key")){o=a(e);var R=Object.keys(r).filter(function(f){return f!=="key"});n=0<R.length?"{key: someKey, "+R.join(": ..., ")+": ...}":"{key: someKey}",ce[o+n]||(R=0<R.length?"{"+R.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
23
23
|
let props = %s;
|
|
24
24
|
<%s {...props} />
|
|
25
25
|
React keys must be passed directly to JSX without using spread:
|
|
26
26
|
let props = %s;
|
|
27
|
-
<%s key={someKey} {...props} />`,n,o,R,o),ce[o+n]=!0)}if(o=null,t!==void 0&&(s(t),o=""+t),we(r)&&(s(r.key),o=""+r.key),"key"in r){t={};for(var k in r)k!=="key"&&(t[k]=r[k])}else t=r;return o&&xe(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),je(e,o,u,c,
|
|
27
|
+
<%s key={someKey} {...props} />`,n,o,R,o),ce[o+n]=!0)}if(o=null,t!==void 0&&(s(t),o=""+t),we(r)&&(s(r.key),o=""+r.key),"key"in r){t={};for(var k in r)k!=="key"&&(t[k]=r[k])}else t=r;return o&&xe(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),je(e,o,u,c,g(),t)}function H(e,r){if(typeof e=="object"&&e&&e.$$typeof!==Se){if(z(e))for(var t=0;t<e.length;t++){var n=e[t];P(n)&&X(n,r)}else if(P(e))e._store&&(e._store.validated=1);else if(e===null||typeof e!="object"?t=null:(t=Q&&e[Q]||e["@@iterator"],t=typeof t=="function"?t:null),typeof t=="function"&&t!==e.entries&&(t=t.call(e),t!==e))for(;!(e=t.next()).done;)P(e.value)&&X(e.value,r)}}function P(e){return typeof e=="object"&&e!==null&&e.$$typeof===Y}function X(e,r){if(e._store&&!e._store.validated&&e.key==null&&(e._store.validated=1,r=_e(r),!fe[r])){fe[r]=!0;var t="";e&&e._owner!=null&&e._owner!==g()&&(t=null,typeof e._owner.tag=="number"?t=a(e._owner.type):typeof e._owner.name=="string"&&(t=e._owner.name),t=" It was passed a child from "+t+".");var n=_.getCurrentStack;_.getCurrentStack=function(){var c=j(e.type);return n&&(c+=n()||""),c},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',r,t),_.getCurrentStack=n}}function _e(e){var r="",t=g();return t&&(t=a(t.type))&&(r=`
|
|
28
28
|
|
|
29
29
|
Check the render method of \``+t+"`."),r||(e=a(e))&&(r=`
|
|
30
30
|
|
|
31
|
-
Check the top-level render call using <`+e+">."),r}var
|
|
31
|
+
Check the top-level render call using <`+e+">."),r}var he=y,Y=Symbol.for("react.transitional.element"),Te=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),B=Symbol.for("react.strict_mode"),K=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),V=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),U=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),ke=Symbol.for("react.offscreen"),Q=Symbol.iterator,pe=Symbol.for("react.client.reference"),_=he.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,h=Object.assign,Ce=Symbol.for("react.client.reference"),z=Array.isArray,p=0,ee,re,te,oe,ne,ae,ue;b.__reactDisabledLog=!0;var J,se,L=!1,G=new(typeof WeakMap=="function"?WeakMap:Map),Se=Symbol.for("react.client.reference"),le,ie={},ce={},fe={};O.Fragment=M,O.jsx=function(e,r,t,n,c){return F(e,r,t,!1,n,c)},O.jsxs=function(e,r,t,n,c){return F(e,r,t,!0,n,c)}}()),O}var Ee;function Ne(){return Ee||(Ee=1,process.env.NODE_ENV==="production"?N.exports=Oe():N.exports=Ae()),N.exports}var d=Ne();const ge=y.createContext(null),Pe=a=>d.jsx(ge.Provider,{value:a.router,children:a.children});function me(){const a=y.useContext(ge);if(!a)throw new Error("[useRouter] Router not found. Add RouterProvider in app root");return a}function Re(){return be.useUnit(me())}const Ye=y.forwardRef((a,v)=>{const{to:s,params:b,onClick:l,...i}=a,{mappedRoutes:E}=me(),m=E.find(({route:g})=>g===s),{onOpen:j}=be.useUnit(s);if(!m)throw new Error(`[Link] Route with path "${s.path}" not found. Maybe it is not passed into createRouter?`);return d.jsx("a",{...i,ref:v,href:m.build(b??void 0),onClick:g=>{l==null||l(g),!g.defaultPrevented&&(i.target&&i.target!=="_self"||g.metaKey||g.altKey||g.ctrlKey||g.shiftKey||(g.preventDefault(),j({params:b||{}})))}})}),Me=a=>({route:a.route,view:()=>{const{view:v,layout:s}=a;return s?d.jsx(s,{children:d.jsx(v,{})}):d.jsx(v,{})}}),$e=a=>{const{routes:v,otherwise:s}=a;return()=>{const{activeRoutes:b}=Re(),l=b.reduce((E,m)=>E.filter(j=>j!==m.parent),b),i=v.find(E=>E.route===l.at(-1));return i?y.createElement(i.view):s?d.jsx(s,{}):null}},Ve=a=>{a.route.internal.setAsyncImport(a.view);const v=y.lazy(a.view);return{route:a.route,view:()=>{const{layout:s,fallback:b=()=>d.jsx(d.Fragment,{})}=a;return s?d.jsx(s,{children:d.jsx(y.Suspense,{fallback:d.jsx(b,{}),children:d.jsx(v,{})})}):d.jsx(y.Suspense,{fallback:d.jsx(b,{}),children:d.jsx(v,{})})}}};exports.Link=Ye;exports.RouterProvider=Pe;exports.createLazyRouteView=Ve;exports.createRouteView=Me;exports.createRoutesView=$e;exports.useRouter=Re;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,30 @@ declare interface CreateBaseRouteViewProps {
|
|
|
23
23
|
}>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @description Creates Lazy route view with async bundle load
|
|
28
|
+
* @link https://movpushmov.dev/argon-router/react/create-lazy-route-view.html
|
|
29
|
+
* @param props Lazy route view props
|
|
30
|
+
* @returns RouteView
|
|
31
|
+
* @example ```ts
|
|
32
|
+
* // profile.tsx
|
|
33
|
+
* export default function () {
|
|
34
|
+
* return <>...</>;
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* // index.ts
|
|
38
|
+
* import { createLazyRouteView } from '@argon-router/react';
|
|
39
|
+
* import { routes } from '@shared/routing';
|
|
40
|
+
* import { MainLayout } from '@layouts';
|
|
41
|
+
*
|
|
42
|
+
* export const ProfileScreen = createLazyRouteView({
|
|
43
|
+
* route: routes.profile,
|
|
44
|
+
* view: () => import('./profile'),
|
|
45
|
+
* fallback: () => ':(',
|
|
46
|
+
* layout: MainLayout,
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
26
50
|
export declare const createLazyRouteView: (props: CreateLazyRouteViewProps) => RouteView;
|
|
27
51
|
|
|
28
52
|
export declare interface CreateLazyRouteViewProps extends CreateBaseRouteViewProps {
|
|
@@ -32,6 +56,29 @@ export declare interface CreateLazyRouteViewProps extends CreateBaseRouteViewPro
|
|
|
32
56
|
fallback?: ComponentType;
|
|
33
57
|
}
|
|
34
58
|
|
|
59
|
+
/**
|
|
60
|
+
* @description Create routes view which renders current opened route. `Don't forget add <RouterProvider>`!
|
|
61
|
+
* @param props Routes view config
|
|
62
|
+
* @link https://movpushmov.dev/argon-router/react/create-routes-view.html
|
|
63
|
+
* @returns RoutesView
|
|
64
|
+
* @example ```tsx
|
|
65
|
+
* import { createRoutesView } from '@argon-router/react';
|
|
66
|
+
* import { router } from './router';
|
|
67
|
+
* // feed screen & profile screen must be created with createRouteView!
|
|
68
|
+
* import { FeedScreen, ProfileScreen } from './screens';
|
|
69
|
+
*
|
|
70
|
+
* const RoutesView = createRoutesView({ routes: [FeedScreen, ProfileScreen] });
|
|
71
|
+
*
|
|
72
|
+
* // then you can use it like react component:
|
|
73
|
+
* function App() {
|
|
74
|
+
* return (
|
|
75
|
+
* <RouterProvider router={router}>
|
|
76
|
+
* <RoutesView />
|
|
77
|
+
* </RouterProvider>
|
|
78
|
+
* );
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
35
82
|
export declare const createRoutesView: (props: CreateRoutesViewProps) => () => JSX.Element | null;
|
|
36
83
|
|
|
37
84
|
declare interface CreateRoutesViewProps {
|
|
@@ -39,6 +86,27 @@ declare interface CreateRoutesViewProps {
|
|
|
39
86
|
otherwise?: ComponentType;
|
|
40
87
|
}
|
|
41
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @description Creates Route view without async bundle load
|
|
91
|
+
* @link https://movpushmov.dev/argon-router/react/create-route-view.html
|
|
92
|
+
* @param props Route view props
|
|
93
|
+
* @returns RouteView
|
|
94
|
+
* @example ```ts
|
|
95
|
+
* import { createRouteView } from '@argon-router/react';
|
|
96
|
+
* import { routes } from '@shared/routing';
|
|
97
|
+
* import { MainLayout } from '@layouts';
|
|
98
|
+
*
|
|
99
|
+
* function Profile() {
|
|
100
|
+
* return <>...</>;
|
|
101
|
+
* }
|
|
102
|
+
*
|
|
103
|
+
* export const ProfileScreen = createRouteView({
|
|
104
|
+
* route: routes.profile,
|
|
105
|
+
* view: Profile,
|
|
106
|
+
* layout: MainLayout,
|
|
107
|
+
* });
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
42
110
|
export declare const createRouteView: (props: CreateRouteViewProps) => RouteView;
|
|
43
111
|
|
|
44
112
|
export declare interface CreateRouteViewProps extends CreateBaseRouteViewProps {
|
|
@@ -49,6 +117,28 @@ declare type ForwardedLink = <Params = void>(props: LinkProps<Params> & {
|
|
|
49
117
|
ref?: ForwardedRef<HTMLAnchorElement>;
|
|
50
118
|
}) => ReactNode;
|
|
51
119
|
|
|
120
|
+
/**
|
|
121
|
+
* @description Navigates user to provided route on click
|
|
122
|
+
* @link https://movpushmov.dev/argon-router/react/link.html
|
|
123
|
+
* @example ```tsx
|
|
124
|
+
* import { Link } from '@argon-router/react';
|
|
125
|
+
* import { routes } from '@shared/routing';
|
|
126
|
+
*
|
|
127
|
+
* function Profile({ user }) {
|
|
128
|
+
* return (
|
|
129
|
+
* <>
|
|
130
|
+
* <Link to={routes.settings}>Settings</Link>
|
|
131
|
+
*
|
|
132
|
+
* {user.posts.map((post) => (
|
|
133
|
+
* <Link to={routes.editPost} params={{ id: post.id }}>
|
|
134
|
+
* Edit post
|
|
135
|
+
* </Link>
|
|
136
|
+
* ))}
|
|
137
|
+
* </>
|
|
138
|
+
* );
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
52
142
|
export declare const Link: ForwardedLink;
|
|
53
143
|
|
|
54
144
|
export declare type LinkProps<Params> = Params extends Record<string, never> | void | undefined ? BaseLinkProps<Params> & {
|
|
@@ -57,6 +147,10 @@ export declare type LinkProps<Params> = Params extends Record<string, never> | v
|
|
|
57
147
|
params: Params;
|
|
58
148
|
};
|
|
59
149
|
|
|
150
|
+
/**
|
|
151
|
+
* @description Provides router in React tree
|
|
152
|
+
* @param props Router provider config
|
|
153
|
+
*/
|
|
60
154
|
export declare const RouterProvider: (props: RouterProviderProps) => JSX.Element;
|
|
61
155
|
|
|
62
156
|
declare interface RouterProviderProps {
|
|
@@ -69,6 +163,11 @@ export declare interface RouteView {
|
|
|
69
163
|
view: FC;
|
|
70
164
|
}
|
|
71
165
|
|
|
166
|
+
/**
|
|
167
|
+
* @description Use router from provider
|
|
168
|
+
* @returns Router
|
|
169
|
+
* @link https://movpushmov.dev/argon-router/react/use-router.html
|
|
170
|
+
*/
|
|
72
171
|
export declare function useRouter(): {
|
|
73
172
|
query: Query;
|
|
74
173
|
path: string;
|
package/dist/index.js
CHANGED
|
@@ -14,23 +14,23 @@ var de;
|
|
|
14
14
|
function Me() {
|
|
15
15
|
if (de) return C;
|
|
16
16
|
de = 1;
|
|
17
|
-
var a = Symbol.for("react.transitional.element"),
|
|
18
|
-
function s(
|
|
19
|
-
var
|
|
20
|
-
if (i !== void 0 && (
|
|
17
|
+
var a = Symbol.for("react.transitional.element"), v = Symbol.for("react.fragment");
|
|
18
|
+
function s(b, l, i) {
|
|
19
|
+
var E = null;
|
|
20
|
+
if (i !== void 0 && (E = "" + i), l.key !== void 0 && (E = "" + l.key), "key" in l) {
|
|
21
21
|
i = {};
|
|
22
22
|
for (var g in l)
|
|
23
23
|
g !== "key" && (i[g] = l[g]);
|
|
24
24
|
} else i = l;
|
|
25
25
|
return l = i.ref, {
|
|
26
26
|
$$typeof: a,
|
|
27
|
-
type:
|
|
28
|
-
key:
|
|
27
|
+
type: b,
|
|
28
|
+
key: E,
|
|
29
29
|
ref: l !== void 0 ? l : null,
|
|
30
30
|
props: i
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
return C.Fragment =
|
|
33
|
+
return C.Fragment = v, C.jsx = s, C.jsxs = s, C;
|
|
34
34
|
}
|
|
35
35
|
var A = {};
|
|
36
36
|
/**
|
|
@@ -53,7 +53,7 @@ function $e() {
|
|
|
53
53
|
switch (e) {
|
|
54
54
|
case Y:
|
|
55
55
|
return "Fragment";
|
|
56
|
-
case
|
|
56
|
+
case he:
|
|
57
57
|
return "Portal";
|
|
58
58
|
case B:
|
|
59
59
|
return "Profiler";
|
|
@@ -86,12 +86,12 @@ function $e() {
|
|
|
86
86
|
}
|
|
87
87
|
return null;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function v(e) {
|
|
90
90
|
return "" + e;
|
|
91
91
|
}
|
|
92
92
|
function s(e) {
|
|
93
93
|
try {
|
|
94
|
-
|
|
94
|
+
v(e);
|
|
95
95
|
var r = !1;
|
|
96
96
|
} catch {
|
|
97
97
|
r = !0;
|
|
@@ -103,10 +103,10 @@ function $e() {
|
|
|
103
103
|
r,
|
|
104
104
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
105
105
|
n
|
|
106
|
-
),
|
|
106
|
+
), v(e);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function b() {
|
|
110
110
|
}
|
|
111
111
|
function l() {
|
|
112
112
|
if (p === 0) {
|
|
@@ -114,7 +114,7 @@ function $e() {
|
|
|
114
114
|
var e = {
|
|
115
115
|
configurable: !0,
|
|
116
116
|
enumerable: !0,
|
|
117
|
-
value:
|
|
117
|
+
value: b,
|
|
118
118
|
writable: !0
|
|
119
119
|
};
|
|
120
120
|
Object.defineProperties(console, {
|
|
@@ -133,20 +133,20 @@ function $e() {
|
|
|
133
133
|
if (p--, p === 0) {
|
|
134
134
|
var e = { configurable: !0, enumerable: !0, writable: !0 };
|
|
135
135
|
Object.defineProperties(console, {
|
|
136
|
-
log:
|
|
137
|
-
info:
|
|
138
|
-
warn:
|
|
139
|
-
error:
|
|
140
|
-
group:
|
|
141
|
-
groupCollapsed:
|
|
142
|
-
groupEnd:
|
|
136
|
+
log: _({}, e, { value: D }),
|
|
137
|
+
info: _({}, e, { value: ee }),
|
|
138
|
+
warn: _({}, e, { value: re }),
|
|
139
|
+
error: _({}, e, { value: te }),
|
|
140
|
+
group: _({}, e, { value: oe }),
|
|
141
|
+
groupCollapsed: _({}, e, { value: ne }),
|
|
142
|
+
groupEnd: _({}, e, { value: ae })
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
0 > p && console.error(
|
|
146
146
|
"disabledDepth fell below zero. This is a bug in React. Please file an issue."
|
|
147
147
|
);
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function E(e) {
|
|
150
150
|
if (q === void 0)
|
|
151
151
|
try {
|
|
152
152
|
throw Error();
|
|
@@ -164,7 +164,7 @@ function $e() {
|
|
|
164
164
|
if (t !== void 0) return t;
|
|
165
165
|
J = !0, t = Error.prepareStackTrace, Error.prepareStackTrace = void 0;
|
|
166
166
|
var n = null;
|
|
167
|
-
n =
|
|
167
|
+
n = j.H, j.H = null, l();
|
|
168
168
|
try {
|
|
169
169
|
var c = {
|
|
170
170
|
DetermineComponentFrameRoot: function() {
|
|
@@ -220,27 +220,27 @@ function $e() {
|
|
|
220
220
|
);
|
|
221
221
|
var o = c.DetermineComponentFrameRoot(), x = o[0], T = o[1];
|
|
222
222
|
if (x && T) {
|
|
223
|
-
var
|
|
224
|
-
`),
|
|
223
|
+
var f = x.split(`
|
|
224
|
+
`), h = T.split(`
|
|
225
225
|
`);
|
|
226
|
-
for (o = u = 0; u <
|
|
226
|
+
for (o = u = 0; u < f.length && !f[u].includes(
|
|
227
227
|
"DetermineComponentFrameRoot"
|
|
228
228
|
); )
|
|
229
229
|
u++;
|
|
230
|
-
for (; o <
|
|
230
|
+
for (; o < h.length && !h[o].includes(
|
|
231
231
|
"DetermineComponentFrameRoot"
|
|
232
232
|
); )
|
|
233
233
|
o++;
|
|
234
|
-
if (u ===
|
|
235
|
-
for (u =
|
|
234
|
+
if (u === f.length || o === h.length)
|
|
235
|
+
for (u = f.length - 1, o = h.length - 1; 1 <= u && 0 <= o && f[u] !== h[o]; )
|
|
236
236
|
o--;
|
|
237
237
|
for (; 1 <= u && 0 <= o; u--, o--)
|
|
238
|
-
if (
|
|
238
|
+
if (f[u] !== h[o]) {
|
|
239
239
|
if (u !== 1 || o !== 1)
|
|
240
240
|
do
|
|
241
|
-
if (u--, o--, 0 > o ||
|
|
241
|
+
if (u--, o--, 0 > o || f[u] !== h[o]) {
|
|
242
242
|
var k = `
|
|
243
|
-
` +
|
|
243
|
+
` + f[u].replace(
|
|
244
244
|
" at new ",
|
|
245
245
|
" at "
|
|
246
246
|
);
|
|
@@ -251,9 +251,9 @@ function $e() {
|
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
253
|
} finally {
|
|
254
|
-
J = !1,
|
|
254
|
+
J = !1, j.H = n, i(), Error.prepareStackTrace = t;
|
|
255
255
|
}
|
|
256
|
-
return
|
|
256
|
+
return f = (f = e ? e.displayName || e.name : "") ? E(f) : "", typeof e == "function" && G.set(e, f), f;
|
|
257
257
|
}
|
|
258
258
|
function y(e) {
|
|
259
259
|
if (e == null) return "";
|
|
@@ -264,12 +264,12 @@ function $e() {
|
|
|
264
264
|
!(!r || !r.isReactComponent)
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
if (typeof e == "string") return
|
|
267
|
+
if (typeof e == "string") return E(e);
|
|
268
268
|
switch (e) {
|
|
269
269
|
case $:
|
|
270
|
-
return
|
|
270
|
+
return E("Suspense");
|
|
271
271
|
case W:
|
|
272
|
-
return
|
|
272
|
+
return E("SuspenseList");
|
|
273
273
|
}
|
|
274
274
|
if (typeof e == "object")
|
|
275
275
|
switch (e.$$typeof) {
|
|
@@ -286,8 +286,8 @@ function $e() {
|
|
|
286
286
|
}
|
|
287
287
|
return "";
|
|
288
288
|
}
|
|
289
|
-
function
|
|
290
|
-
var e =
|
|
289
|
+
function m() {
|
|
290
|
+
var e = j.A;
|
|
291
291
|
return e === null ? null : e.getOwner();
|
|
292
292
|
}
|
|
293
293
|
function xe(e) {
|
|
@@ -359,8 +359,8 @@ function $e() {
|
|
|
359
359
|
);
|
|
360
360
|
if (Q.call(r, "key")) {
|
|
361
361
|
o = a(e);
|
|
362
|
-
var x = Object.keys(r).filter(function(
|
|
363
|
-
return
|
|
362
|
+
var x = Object.keys(r).filter(function(f) {
|
|
363
|
+
return f !== "key";
|
|
364
364
|
});
|
|
365
365
|
n = 0 < x.length ? "{key: someKey, " + x.join(": ..., ") + ": ...}" : "{key: someKey}", ie[o + n] || (x = 0 < x.length ? "{" + x.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
366
366
|
`A props object containing a "key" prop is being spread into JSX:
|
|
@@ -383,7 +383,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
383
383
|
return o && we(
|
|
384
384
|
t,
|
|
385
385
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
386
|
-
), ye(e, o, u, c,
|
|
386
|
+
), ye(e, o, u, c, m(), t);
|
|
387
387
|
}
|
|
388
388
|
function F(e, r) {
|
|
389
389
|
if (typeof e == "object" && e && e.$$typeof !== Ce) {
|
|
@@ -403,31 +403,31 @@ React keys must be passed directly to JSX without using spread:
|
|
|
403
403
|
return typeof e == "object" && e !== null && e.$$typeof === P;
|
|
404
404
|
}
|
|
405
405
|
function H(e, r) {
|
|
406
|
-
if (e._store && !e._store.validated && e.key == null && (e._store.validated = 1, r =
|
|
406
|
+
if (e._store && !e._store.validated && e.key == null && (e._store.validated = 1, r = je(r), !ce[r])) {
|
|
407
407
|
ce[r] = !0;
|
|
408
408
|
var t = "";
|
|
409
|
-
e && e._owner != null && e._owner !==
|
|
410
|
-
var n =
|
|
411
|
-
|
|
409
|
+
e && e._owner != null && e._owner !== m() && (t = null, typeof e._owner.tag == "number" ? t = a(e._owner.type) : typeof e._owner.name == "string" && (t = e._owner.name), t = " It was passed a child from " + t + ".");
|
|
410
|
+
var n = j.getCurrentStack;
|
|
411
|
+
j.getCurrentStack = function() {
|
|
412
412
|
var c = y(e.type);
|
|
413
413
|
return n && (c += n() || ""), c;
|
|
414
414
|
}, console.error(
|
|
415
415
|
'Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',
|
|
416
416
|
r,
|
|
417
417
|
t
|
|
418
|
-
),
|
|
418
|
+
), j.getCurrentStack = n;
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
|
-
function
|
|
422
|
-
var r = "", t =
|
|
421
|
+
function je(e) {
|
|
422
|
+
var r = "", t = m();
|
|
423
423
|
return t && (t = a(t.type)) && (r = `
|
|
424
424
|
|
|
425
425
|
Check the render method of \`` + t + "`."), r || (e = a(e)) && (r = `
|
|
426
426
|
|
|
427
427
|
Check the top-level render call using <` + e + ">."), r;
|
|
428
428
|
}
|
|
429
|
-
var
|
|
430
|
-
|
|
429
|
+
var _e = Ae, P = Symbol.for("react.transitional.element"), he = Symbol.for("react.portal"), Y = Symbol.for("react.fragment"), X = Symbol.for("react.strict_mode"), B = Symbol.for("react.profiler"), K = Symbol.for("react.consumer"), I = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), $ = Symbol.for("react.suspense"), W = Symbol.for("react.suspense_list"), U = Symbol.for("react.memo"), V = Symbol.for("react.lazy"), Te = Symbol.for("react.offscreen"), Z = Symbol.iterator, pe = Symbol.for("react.client.reference"), j = _e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Q = Object.prototype.hasOwnProperty, _ = Object.assign, ke = Symbol.for("react.client.reference"), z = Array.isArray, p = 0, D, ee, re, te, oe, ne, ae;
|
|
430
|
+
b.__reactDisabledLog = !0;
|
|
431
431
|
var q, ue, J = !1, G = new (typeof WeakMap == "function" ? WeakMap : Map)(), Ce = Symbol.for("react.client.reference"), se, le = {}, ie = {}, ce = {};
|
|
432
432
|
A.Fragment = Y, A.jsx = function(e, r, t, n, c) {
|
|
433
433
|
return L(e, r, t, !1, n, c);
|
|
@@ -440,8 +440,8 @@ var Ee;
|
|
|
440
440
|
function We() {
|
|
441
441
|
return Ee || (Ee = 1, process.env.NODE_ENV === "production" ? S.exports = Me() : S.exports = $e()), S.exports;
|
|
442
442
|
}
|
|
443
|
-
var
|
|
444
|
-
const me = Oe(null), qe = (a) => /* @__PURE__ */
|
|
443
|
+
var d = We();
|
|
444
|
+
const me = Oe(null), qe = (a) => /* @__PURE__ */ d.jsx(me.Provider, { value: a.router, children: a.children });
|
|
445
445
|
function ge() {
|
|
446
446
|
const a = Se(me);
|
|
447
447
|
if (!a)
|
|
@@ -453,49 +453,45 @@ function ge() {
|
|
|
453
453
|
function Ue() {
|
|
454
454
|
return be(ge());
|
|
455
455
|
}
|
|
456
|
-
const Je = Ne((a,
|
|
457
|
-
const { to: s, params:
|
|
458
|
-
if (!g)
|
|
459
|
-
const { internal: f } = s;
|
|
456
|
+
const Je = Ne((a, v) => {
|
|
457
|
+
const { to: s, params: b, onClick: l, ...i } = a, { mappedRoutes: E } = ge(), g = E.find(({ route: m }) => m === s), { onOpen: y } = be(s);
|
|
458
|
+
if (!g)
|
|
460
459
|
throw new Error(
|
|
461
|
-
`[Link] Route with path "${
|
|
460
|
+
`[Link] Route with path "${s.path}" not found. Maybe it is not passed into createRouter?`
|
|
462
461
|
);
|
|
463
|
-
|
|
464
|
-
return /* @__PURE__ */ v.jsx(
|
|
462
|
+
return /* @__PURE__ */ d.jsx(
|
|
465
463
|
"a",
|
|
466
464
|
{
|
|
467
465
|
...i,
|
|
468
|
-
ref:
|
|
469
|
-
href: g.
|
|
470
|
-
onClick: (
|
|
471
|
-
l == null || l(
|
|
466
|
+
ref: v,
|
|
467
|
+
href: g.build(b ?? void 0),
|
|
468
|
+
onClick: (m) => {
|
|
469
|
+
l == null || l(m), !m.defaultPrevented && (i.target && i.target !== "_self" || m.metaKey || m.altKey || m.ctrlKey || m.shiftKey || (m.preventDefault(), y({ params: b || {} })));
|
|
472
470
|
}
|
|
473
471
|
}
|
|
474
472
|
);
|
|
475
473
|
}), Ge = (a) => ({
|
|
476
474
|
route: a.route,
|
|
477
475
|
view: () => {
|
|
478
|
-
const { view:
|
|
479
|
-
return s ? /* @__PURE__ */
|
|
476
|
+
const { view: v, layout: s } = a;
|
|
477
|
+
return s ? /* @__PURE__ */ d.jsx(s, { children: /* @__PURE__ */ d.jsx(v, {}) }) : /* @__PURE__ */ d.jsx(v, {});
|
|
480
478
|
}
|
|
481
479
|
}), Le = (a) => {
|
|
482
|
-
const { routes:
|
|
480
|
+
const { routes: v, otherwise: s } = a;
|
|
483
481
|
return () => {
|
|
484
|
-
const { activeRoutes:
|
|
485
|
-
(
|
|
486
|
-
), m), i = E.find(
|
|
487
|
-
(b) => b.route === l.at(-1)
|
|
482
|
+
const { activeRoutes: b } = Ue(), l = b.reduce((E, g) => E.filter((y) => y !== g.parent), b), i = v.find(
|
|
483
|
+
(E) => E.route === l.at(-1)
|
|
488
484
|
);
|
|
489
|
-
return i ? Pe(i.view) : s ? /* @__PURE__ */
|
|
485
|
+
return i ? Pe(i.view) : s ? /* @__PURE__ */ d.jsx(s, {}) : null;
|
|
490
486
|
};
|
|
491
487
|
}, Fe = (a) => {
|
|
492
488
|
a.route.internal.setAsyncImport(a.view);
|
|
493
|
-
const
|
|
489
|
+
const v = Ye(a.view);
|
|
494
490
|
return {
|
|
495
491
|
route: a.route,
|
|
496
492
|
view: () => {
|
|
497
|
-
const { layout: s, fallback:
|
|
498
|
-
return s ? /* @__PURE__ */
|
|
493
|
+
const { layout: s, fallback: b = () => /* @__PURE__ */ d.jsx(d.Fragment, {}) } = a;
|
|
494
|
+
return s ? /* @__PURE__ */ d.jsx(s, { children: /* @__PURE__ */ d.jsx(fe, { fallback: /* @__PURE__ */ d.jsx(b, {}), children: /* @__PURE__ */ d.jsx(v, {}) }) }) : /* @__PURE__ */ d.jsx(fe, { fallback: /* @__PURE__ */ d.jsx(b, {}), children: /* @__PURE__ */ d.jsx(v, {}) });
|
|
499
495
|
}
|
|
500
496
|
};
|
|
501
497
|
};
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"registry": "https://registry.npmjs.org/"
|
|
6
6
|
},
|
|
7
7
|
"private": false,
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.6.1",
|
|
9
9
|
"description": "React bindings for argon router",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"effector",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"url": "https://github.com/movpushmov/argon-router/issues"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@argon-router/core": "^0.
|
|
47
|
+
"@argon-router/core": "^0.6.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@babel/preset-react": "^7.26.3",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"effector-react": ">=23",
|
|
60
60
|
"react": "18 || 19"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "7f4fbed2048af77d3087cc608fb2fe30c9991d9b"
|
|
63
63
|
}
|