@argon-router/react 0.8.0 → 0.8.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/dist/index.cjs CHANGED
@@ -28,4 +28,4 @@ React keys must be passed directly to JSX without using spread:
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 he=y,Y=Symbol.for("react.transitional.element"),Te=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),Z=Symbol.for("react.consumer"),Q=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"),D=Symbol.iterator,pe=Symbol.for("react.client.reference"),_=he.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,h=Object.assign,Ce=Symbol.for("react.client.reference"),z=Array.isArray,p=0,re,te,oe,ne,ae,ue,se;b.__reactDisabledLog=!0;var J,le,L=!1,G=new(typeof WeakMap=="function"?WeakMap:Map),Se=Symbol.for("react.client.reference"),ie,ce={},fe={},de={};O.Fragment=M,O.jsx=function(e,r,t,n,c){return H(e,r,t,!1,n,c)},O.jsxs=function(e,r,t,n,c){return H(e,r,t,!0,n,c)}}()),O}var be;function Ne(){return be||(be=1,process.env.NODE_ENV==="production"?N.exports=Oe():N.exports=Ae()),N.exports}var d=Ne();const me=y.createContext(null),Pe=a=>d.jsx(me.Provider,{value:a.router,children:a.children});function F(){const a=y.useContext(me);if(!a)throw new Error("[useRouter] Router not found. Add RouterProvider in app root");return a}function Re(){return ge.useUnit(F())}const Ye=y.forwardRef((a,v)=>{const{to:s,params:b,onClick:l,...i}=a,{mappedRoutes:E}=F(),m=E.find(({route:g})=>g===s),{onOpen:j}=ge.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;exports.useRouterContext=F;
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"),K=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),Z=Symbol.for("react.consumer"),Q=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"),D=Symbol.iterator,pe=Symbol.for("react.client.reference"),_=he.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=Object.prototype.hasOwnProperty,h=Object.assign,Ce=Symbol.for("react.client.reference"),z=Array.isArray,p=0,re,te,oe,ne,ae,ue,se;b.__reactDisabledLog=!0;var J,le,L=!1,G=new(typeof WeakMap=="function"?WeakMap:Map),Se=Symbol.for("react.client.reference"),ie,ce={},fe={},de={};O.Fragment=M,O.jsx=function(e,r,t,n,c){return H(e,r,t,!1,n,c)},O.jsxs=function(e,r,t,n,c){return H(e,r,t,!0,n,c)}}()),O}var be;function Ne(){return be||(be=1,process.env.NODE_ENV==="production"?N.exports=Oe():N.exports=Ae()),N.exports}var d=Ne();const me=y.createContext(null),Pe=a=>d.jsx(me.Provider,{value:a.router,children:a.children});function F(){const a=y.useContext(me);if(!a)throw new Error("[useRouter] Router not found. Add RouterProvider in app root");return a}function Re(){return ge.useUnit(F())}const Ye=y.forwardRef((a,v)=>{const{to:s,params:b,onClick:l,...i}=a,{mappedRoutes:E}=F(),m=E.find(({route:g})=>g===s),{onOpen:j}=ge.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||{}})))}})});function Me(a){return{route:a.route,view:()=>{const{view:v,layout:s}=a;return s?d.jsx(s,{children:d.jsx(v,{})}):d.jsx(v,{})}}}const $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}};function 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;exports.useRouterContext=F;
package/dist/index.d.ts CHANGED
@@ -16,8 +16,8 @@ declare type BaseLinkProps<Params> = {
16
16
  children?: ReactNode;
17
17
  } & AnchorProps;
18
18
 
19
- declare interface CreateBaseRouteViewProps {
20
- route: Route<any>;
19
+ declare interface CreateBaseRouteViewProps<T> {
20
+ route: Route<T>;
21
21
  layout?: ComponentType<{
22
22
  children: ReactNode;
23
23
  }>;
@@ -47,9 +47,9 @@ declare interface CreateBaseRouteViewProps {
47
47
  * });
48
48
  * ```
49
49
  */
50
- export declare const createLazyRouteView: (props: CreateLazyRouteViewProps) => RouteView;
50
+ export declare function createLazyRouteView<T>(props: CreateLazyRouteViewProps<T>): RouteView;
51
51
 
52
- export declare interface CreateLazyRouteViewProps extends CreateBaseRouteViewProps {
52
+ export declare interface CreateLazyRouteViewProps<T> extends CreateBaseRouteViewProps<T> {
53
53
  view: () => Promise<{
54
54
  default: ComponentType;
55
55
  }>;
@@ -107,9 +107,9 @@ declare interface CreateRoutesViewProps {
107
107
  * });
108
108
  * ```
109
109
  */
110
- export declare const createRouteView: (props: CreateRouteViewProps) => RouteView;
110
+ export declare function createRouteView<T>(props: CreateRouteViewProps<T>): RouteView;
111
111
 
112
- export declare interface CreateRouteViewProps extends CreateBaseRouteViewProps {
112
+ export declare interface CreateRouteViewProps<T> extends CreateBaseRouteViewProps<T> {
113
113
  view: ComponentType;
114
114
  }
115
115
 
package/dist/index.js CHANGED
@@ -15,22 +15,22 @@ function Me() {
15
15
  if (de) return C;
16
16
  de = 1;
17
17
  var a = Symbol.for("react.transitional.element"), v = Symbol.for("react.fragment");
18
- function s(b, l, i) {
18
+ function l(b, s, i) {
19
19
  var E = null;
20
- if (i !== void 0 && (E = "" + i), l.key !== void 0 && (E = "" + l.key), "key" in l) {
20
+ if (i !== void 0 && (E = "" + i), s.key !== void 0 && (E = "" + s.key), "key" in s) {
21
21
  i = {};
22
- for (var g in l)
23
- g !== "key" && (i[g] = l[g]);
24
- } else i = l;
25
- return l = i.ref, {
22
+ for (var g in s)
23
+ g !== "key" && (i[g] = s[g]);
24
+ } else i = s;
25
+ return s = i.ref, {
26
26
  $$typeof: a,
27
27
  type: b,
28
28
  key: E,
29
- ref: l !== void 0 ? l : null,
29
+ ref: s !== void 0 ? s : null,
30
30
  props: i
31
31
  };
32
32
  }
33
- return C.Fragment = v, C.jsx = s, C.jsxs = s, C;
33
+ return C.Fragment = v, C.jsx = l, C.jsxs = l, C;
34
34
  }
35
35
  var A = {};
36
36
  /**
@@ -89,7 +89,7 @@ function $e() {
89
89
  function v(e) {
90
90
  return "" + e;
91
91
  }
92
- function s(e) {
92
+ function l(e) {
93
93
  try {
94
94
  v(e);
95
95
  var r = !1;
@@ -108,7 +108,7 @@ function $e() {
108
108
  }
109
109
  function b() {
110
110
  }
111
- function l() {
111
+ function s() {
112
112
  if (p === 0) {
113
113
  D = console.log, ee = console.info, re = console.warn, te = console.error, oe = console.group, ne = console.groupCollapsed, ae = console.groupEnd;
114
114
  var e = {
@@ -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 = j.H, j.H = null, l();
167
+ n = j.H, j.H = null, s();
168
168
  try {
169
169
  var c = {
170
170
  DetermineComponentFrameRoot: function() {
@@ -299,7 +299,7 @@ function $e() {
299
299
  }
300
300
  function we(e, r) {
301
301
  function t() {
302
- se || (se = !0, console.error(
302
+ le || (le = !0, console.error(
303
303
  "%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)",
304
304
  r
305
305
  ));
@@ -311,7 +311,7 @@ function $e() {
311
311
  }
312
312
  function Re() {
313
313
  var e = a(this.type);
314
- return le[e] || (le[e] = !0, console.error(
314
+ return se[e] || (se[e] = !0, console.error(
315
315
  "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."
316
316
  )), e = this.props.ref, e !== void 0 ? e : null;
317
317
  }
@@ -375,7 +375,7 @@ React keys must be passed directly to JSX without using spread:
375
375
  o
376
376
  ), ie[o + n] = !0);
377
377
  }
378
- if (o = null, t !== void 0 && (s(t), o = "" + t), xe(r) && (s(r.key), o = "" + r.key), "key" in r) {
378
+ if (o = null, t !== void 0 && (l(t), o = "" + t), xe(r) && (l(r.key), o = "" + r.key), "key" in r) {
379
379
  t = {};
380
380
  for (var T in r)
381
381
  T !== "key" && (t[T] = r[T]);
@@ -428,7 +428,7 @@ Check the top-level render call using <` + e + ">."), r;
428
428
  }
429
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
430
  b.__reactDisabledLog = !0;
431
- var q, ue, J = !1, G = new (typeof WeakMap == "function" ? WeakMap : Map)(), Ce = Symbol.for("react.client.reference"), se, le = {}, ie = {}, ce = {};
431
+ var q, ue, J = !1, G = new (typeof WeakMap == "function" ? WeakMap : Map)(), Ce = Symbol.for("react.client.reference"), le, se = {}, 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);
434
434
  }, A.jsxs = function(e, r, t, n, c) {
@@ -454,10 +454,10 @@ function Ue() {
454
454
  return be(ge());
455
455
  }
456
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);
457
+ const { to: l, params: b, onClick: s, ...i } = a, { mappedRoutes: E } = ge(), g = E.find(({ route: m }) => m === l), { onOpen: y } = be(l);
458
458
  if (!g)
459
459
  throw new Error(
460
- `[Link] Route with path "${s.path}" not found. Maybe it is not passed into createRouter?`
460
+ `[Link] Route with path "${l.path}" not found. Maybe it is not passed into createRouter?`
461
461
  );
462
462
  return /* @__PURE__ */ d.jsx(
463
463
  "a",
@@ -466,35 +466,40 @@ const Je = Ne((a, v) => {
466
466
  ref: v,
467
467
  href: g.build(b ?? void 0),
468
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 || {} })));
469
+ s == null || s(m), !m.defaultPrevented && (i.target && i.target !== "_self" || m.metaKey || m.altKey || m.ctrlKey || m.shiftKey || (m.preventDefault(), y({ params: b || {} })));
470
470
  }
471
471
  }
472
472
  );
473
- }), Ge = (a) => ({
474
- route: a.route,
475
- view: () => {
476
- const { view: v, layout: s } = a;
477
- return s ? /* @__PURE__ */ d.jsx(s, { children: /* @__PURE__ */ d.jsx(v, {}) }) : /* @__PURE__ */ d.jsx(v, {});
478
- }
479
- }), Le = (a) => {
480
- const { routes: v, otherwise: s } = a;
473
+ });
474
+ function Ge(a) {
475
+ return {
476
+ route: a.route,
477
+ view: () => {
478
+ const { view: v, layout: l } = a;
479
+ return l ? /* @__PURE__ */ d.jsx(l, { children: /* @__PURE__ */ d.jsx(v, {}) }) : /* @__PURE__ */ d.jsx(v, {});
480
+ }
481
+ };
482
+ }
483
+ const Le = (a) => {
484
+ const { routes: v, otherwise: l } = a;
481
485
  return () => {
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)
486
+ const { activeRoutes: b } = Ue(), s = b.reduce((E, g) => E.filter((y) => y !== g.parent), b), i = v.find(
487
+ (E) => E.route === s.at(-1)
484
488
  );
485
- return i ? Pe(i.view) : s ? /* @__PURE__ */ d.jsx(s, {}) : null;
489
+ return i ? Pe(i.view) : l ? /* @__PURE__ */ d.jsx(l, {}) : null;
486
490
  };
487
- }, Fe = (a) => {
491
+ };
492
+ function Fe(a) {
488
493
  a.route.internal.setAsyncImport(a.view);
489
494
  const v = Ye(a.view);
490
495
  return {
491
496
  route: a.route,
492
497
  view: () => {
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, {}) });
498
+ const { layout: l, fallback: b = () => /* @__PURE__ */ d.jsx(d.Fragment, {}) } = a;
499
+ return l ? /* @__PURE__ */ d.jsx(l, { 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, {}) });
495
500
  }
496
501
  };
497
- };
502
+ }
498
503
  export {
499
504
  Je as Link,
500
505
  qe as RouterProvider,
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.0",
8
+ "version": "0.8.1",
9
9
  "description": "React bindings for argon router",
10
10
  "keywords": [
11
11
  "effector",
@@ -59,5 +59,5 @@
59
59
  "effector-react": ">=23",
60
60
  "react": "18 || 19"
61
61
  },
62
- "gitHead": "1865adb15d9a326bc13d7b4f4a25ef63d14c63ee"
62
+ "gitHead": "027a8258dd08c6fe7394b9512f98f833a15b68bf"
63
63
  }