mobx-route 0.0.63 → 0.0.65

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.
@@ -1,4 +1,4 @@
1
- import { AnyRouteFromCollection, RoutesCollection } from './route-group.types.js';
1
+ import { AnyRouteEntity, RoutesCollection } from './route-group.types.js';
2
2
  /**
3
3
  * Class for grouping related routes and managing their state.
4
4
  *
@@ -7,7 +7,7 @@ import { AnyRouteFromCollection, RoutesCollection } from './route-group.types.js
7
7
  export declare class RouteGroup<TRoutesCollection extends RoutesCollection> {
8
8
  private _indexRoute?;
9
9
  routes: TRoutesCollection;
10
- constructor(routes: TRoutesCollection, _indexRoute?: AnyRouteFromCollection<TRoutesCollection> | undefined);
10
+ constructor(routes: TRoutesCollection, _indexRoute?: AnyRouteEntity | undefined);
11
11
  /**
12
12
  * Returns true if at least one route in the group is open.
13
13
  *
@@ -19,7 +19,7 @@ export declare class RouteGroup<TRoutesCollection extends RoutesCollection> {
19
19
  *
20
20
  * [**Documentation**](https://js2me.github.io/mobx-route/core/RouteGroup.html#indexroute-route-undefined)
21
21
  */
22
- get indexRoute(): AnyRouteFromCollection<TRoutesCollection> | undefined;
22
+ get indexRoute(): AnyRouteEntity | undefined;
23
23
  /**
24
24
  * Main navigation method for the group.
25
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"route-group.d.ts","sourceRoot":"","sources":["../../../src/core/route-group/route-group.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAIhC;;;;GAIG;AACH,qBAAa,UAAU,CAAC,iBAAiB,SAAS,gBAAgB;IAK9D,OAAO,CAAC,WAAW,CAAC;IAJtB,MAAM,EAAE,iBAAiB,CAAC;gBAGxB,MAAM,EAAE,iBAAiB,EACjB,WAAW,CAAC,EAAE,sBAAsB,CAAC,iBAAiB,CAAC,YAAA;IAUjE;;;;OAIG;IACH,IAAI,QAAQ,IAAI,OAAO,CAOtB;IAED;;;;OAIG;IACH,IAAI,UAAU,IAAI,sBAAsB,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAOtE;IAED;;;;OAIG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAwBpB"}
1
+ {"version":3,"file":"route-group.d.ts","sourceRoot":"","sources":["../../../src/core/route-group/route-group.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1E;;;;GAIG;AACH,qBAAa,UAAU,CAAC,iBAAiB,SAAS,gBAAgB;IAK9D,OAAO,CAAC,WAAW,CAAC;IAJtB,MAAM,EAAE,iBAAiB,CAAC;gBAGxB,MAAM,EAAE,iBAAiB,EACjB,WAAW,CAAC,EAAE,cAAc,YAAA;IAUtC;;;;OAIG;IACH,IAAI,QAAQ,IAAI,OAAO,CAOtB;IAED;;;;OAIG;IACH,IAAI,UAAU,IAAI,cAAc,GAAG,SAAS,CAO3C;IAED;;;;OAIG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAuBpB"}
@@ -42,7 +42,6 @@ export class RouteGroup {
42
42
  open(...args) {
43
43
  let lastGroupRoute;
44
44
  if (this.indexRoute) {
45
- // @ts-expect-error no way to handle this ts error
46
45
  this.indexRoute.open(...args);
47
46
  return;
48
47
  }
@@ -1,4 +1,3 @@
1
- import { EmptyObject, ValueOf } from 'yummies/utils/types';
2
1
  import type { AnyRoute } from '../route/index.js';
3
2
  import { AnyVirtualRoute } from '../virtual-route/index.js';
4
3
  import type { RouteGroup } from './route-group.js';
@@ -7,9 +6,4 @@ export type AnyRouteEntity = AnyRoute | AnyRouteGroup | AnyVirtualRoute;
7
6
  export type RoutesArrayCollection = AnyRouteEntity[];
8
7
  export type RoutesObjectCollection = Record<string, AnyRouteEntity>;
9
8
  export type RoutesCollection = RoutesArrayCollection | RoutesObjectCollection;
10
- export type AnyRouteFromCollection<TRoutes extends RoutesCollection> = ValueOf<TRoutes extends RoutesArrayCollection ? {
11
- [K in keyof TRoutes]: TRoutes[K] extends AnyRouteEntity ? TRoutes[K] : never;
12
- } : TRoutes extends RoutesObjectCollection ? {
13
- [K in keyof TRoutes]: TRoutes[K] extends AnyRouteEntity ? TRoutes[K] : never;
14
- } : EmptyObject>;
15
9
  //# sourceMappingURL=route-group.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route-group.types.d.ts","sourceRoot":"","sources":["../../../src/core/route-group/route-group.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,aAAa,GAAG,eAAe,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC;AAE9E,MAAM,MAAM,sBAAsB,CAAC,OAAO,SAAS,gBAAgB,IAAI,OAAO,CAC5E,OAAO,SAAS,qBAAqB,GACjC;KACG,CAAC,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,cAAc,GACnD,OAAO,CAAC,CAAC,CAAC,GACV,KAAK;CACV,GACD,OAAO,SAAS,sBAAsB,GACpC;KACG,CAAC,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,cAAc,GACnD,OAAO,CAAC,CAAC,CAAC,GACV,KAAK;CACV,GACD,WAAW,CAClB,CAAC"}
1
+ {"version":3,"file":"route-group.types.d.ts","sourceRoot":"","sources":["../../../src/core/route-group/route-group.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,aAAa,GAAG,eAAe,CAAC;AAExE,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-route",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "keywords": [
5
5
  "mobx",
6
6
  "react",
@@ -11,6 +11,8 @@ export type LinkProps<TRoute extends AnyRoute> = Omit<AnchorHTMLAttributes<HTMLA
11
11
  params: ExtractPathParams<TRoute['path']>;
12
12
  })) | {
13
13
  to: string;
14
+ } | {
15
+ href: string;
14
16
  });
15
17
  type LinkComponentType = <TRoute extends AnyRoute>(props: LinkProps<TRoute>) => ReactNode;
16
18
  export declare const Link: LinkComponentType;
@@ -1 +1 @@
1
- {"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/react/components/link.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EAKpB,SAAS,EACV,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,qBAAqB,EAAa,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EACL,QAAQ,EACR,iBAAiB,EACj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ACC,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IAAI,GACtE;IAEE,MAAM,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CAC/D,GACD;IAAE,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC,GACnD;IACE,EAAE,EAAE,MAAM,CAAC;CACZ,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CACJ,CAAC;AAEJ,KAAK,iBAAiB,GAAG,CAAC,MAAM,SAAS,QAAQ,EAC/C,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,KACrB,SAAS,CAAC;AAEf,eAAO,MAAM,IAAI,EA0DD,iBAAiB,CAAC"}
@@ -2,8 +2,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  /* eslint-disable @typescript-eslint/ban-ts-comment */
3
3
  import { observer } from 'mobx-react-lite';
4
4
  import { cloneElement, forwardRef, isValidElement, } from 'react';
5
- export const Link = observer(forwardRef(({ to, asChild, query, replace, children, params, ...anchorProps }, ref) => {
6
- const href = typeof to === 'string' ? to : to.createUrl(params, query);
5
+ export const Link = observer(forwardRef(({ to, href: outerHref, asChild, query, replace, children, params, ...anchorProps }, ref) => {
6
+ const href = outerHref ??
7
+ (typeof to === 'string'
8
+ ? to
9
+ : to.createUrl(params, query));
7
10
  const handleClick = (event) => {
8
11
  if (event.ctrlKey ||
9
12
  event.metaKey ||