mobx-route 0.7.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/README.md +4 -0
- package/core/config/config.d.ts +1 -1
- package/core/config/config.d.ts.map +1 -1
- package/core/config/config.js +14 -5
- package/core/config/config.types.d.ts +1 -1
- package/core/config/config.types.d.ts.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +1 -1
- package/core/route/index.d.ts +1 -1
- package/core/route/index.d.ts.map +1 -1
- package/core/route/index.js +1 -1
- package/core/route/route.d.ts +4 -4
- package/core/route/route.d.ts.map +1 -1
- package/core/route/route.js +8 -9
- package/core/route/route.test.d.ts +1 -1
- package/core/route/route.test.d.ts.map +1 -1
- package/core/route/route.test.js +1 -5
- package/core/route/route.types.d.ts +6 -6
- package/core/route/route.types.d.ts.map +1 -1
- package/core/route-group/route-group.d.ts +1 -1
- package/core/route-group/route-group.d.ts.map +1 -1
- package/core/route-group/route-group.types.d.ts +1 -1
- package/core/route-group/route-group.types.d.ts.map +1 -1
- package/core/router/index.d.ts +1 -1
- package/core/router/index.d.ts.map +1 -1
- package/core/router/index.js +1 -1
- package/core/router/router.d.ts +3 -3
- package/core/router/router.d.ts.map +1 -1
- package/core/router/router.types.d.ts +4 -4
- package/core/router/router.types.d.ts.map +1 -1
- package/core/utils/is-route-entity.d.ts +1 -1
- package/core/utils/is-route-entity.d.ts.map +1 -1
- package/core/virtual-route/virtual-route.d.ts +3 -3
- package/core/virtual-route/virtual-route.d.ts.map +1 -1
- package/core/virtual-route/virtual-route.types.d.ts +2 -2
- package/core/virtual-route/virtual-route.types.d.ts.map +1 -1
- package/package.json +14 -21
- package/react/components/index.d.ts +0 -1
- package/react/components/index.d.ts.map +1 -1
- package/react/components/index.js +0 -1
- package/react/components/link.d.ts +4 -4
- package/react/components/link.d.ts.map +1 -1
- package/react/components/link.js +6 -5
- package/react/components/route-view-group.d.ts +9 -11
- package/react/components/route-view-group.d.ts.map +1 -1
- package/react/components/route-view-group.js +2 -5
- package/react/components/route-view-group.test.js +2 -21
- package/react/components/route-view.d.ts +9 -12
- package/react/components/route-view.d.ts.map +1 -1
- package/view-model/route-view-model.d.ts +4 -4
- package/view-model/route-view-model.d.ts.map +1 -1
- package/view-model/route-view-model.js +1 -1
- package/react/components/route-switch.d.ts +0 -25
- package/react/components/route-switch.d.ts.map +0 -1
- package/react/components/route-switch.js +0 -109
- package/react/components/route-switch.test.d.ts +0 -2
- package/react/components/route-switch.test.d.ts.map +0 -1
- package/react/components/route-switch.test.js +0 -146
package/README.md
CHANGED
package/core/config/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RouteGlobalConfig } from './config.types.js';
|
|
1
|
+
import type { RouteGlobalConfig } from './config.types.js';
|
|
2
2
|
export declare const routeConfig: {
|
|
3
3
|
get: () => RouteGlobalConfig;
|
|
4
4
|
set: (value: RouteGlobalConfig | null | undefined) => RouteGlobalConfig | null | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/config/config.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/config/config.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAK3D,eAAO,MAAM,WAAW;;;;CAuCvB,CAAC"}
|
package/core/config/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createBrowserHistory, isObservableHistory, QueryParams, } from 'mobx-location-history';
|
|
2
2
|
import { createGlobalDynamicConfig } from 'yummies/complex';
|
|
3
3
|
let localHistory;
|
|
4
4
|
let localQueryParams;
|
|
@@ -6,7 +6,13 @@ export const routeConfig = createGlobalDynamicConfig((update) => {
|
|
|
6
6
|
if (localHistory && update?.history && isObservableHistory(localHistory)) {
|
|
7
7
|
localHistory.destroy();
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
let history;
|
|
10
|
+
if (update?.history) {
|
|
11
|
+
history = update.history;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
history = localHistory = createBrowserHistory();
|
|
15
|
+
}
|
|
10
16
|
let queryParams;
|
|
11
17
|
if (update?.history && !update.queryParams) {
|
|
12
18
|
if (localQueryParams) {
|
|
@@ -18,9 +24,12 @@ export const routeConfig = createGlobalDynamicConfig((update) => {
|
|
|
18
24
|
if (localQueryParams && update?.queryParams) {
|
|
19
25
|
localQueryParams.destroy();
|
|
20
26
|
}
|
|
21
|
-
queryParams
|
|
22
|
-
update
|
|
23
|
-
|
|
27
|
+
if (update?.queryParams) {
|
|
28
|
+
queryParams = update.queryParams;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
queryParams = localQueryParams = new QueryParams({ history });
|
|
32
|
+
}
|
|
24
33
|
}
|
|
25
34
|
return {
|
|
26
35
|
...update,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../src/core/config/config.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../src/core/config/config.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,YAAY,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
package/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './config/index.js';
|
|
2
2
|
export * from './route/index.js';
|
|
3
3
|
export * from './route-group/index.js';
|
|
4
|
-
export * from './virtual-route/index.js';
|
|
5
4
|
export * from './router/index.js';
|
|
5
|
+
export * from './virtual-route/index.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC"}
|
package/core/index.js
CHANGED
package/core/route/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/route/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/route/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC"}
|
package/core/route/index.js
CHANGED
package/core/route/route.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { History, IQueryParams } from 'mobx-location-history';
|
|
2
|
-
import { ParamData, TokenData } from 'path-to-regexp';
|
|
3
|
-
import {
|
|
4
|
-
import { AnyRoute, BeforeOpenFeedback,
|
|
1
|
+
import { type History, type IQueryParams } from 'mobx-location-history';
|
|
2
|
+
import { type ParamData, type TokenData } from 'path-to-regexp';
|
|
3
|
+
import type { AnyObject, IsPartial, Maybe, MaybePromise } from 'yummies/utils/types';
|
|
4
|
+
import type { AnyRoute, BeforeOpenFeedback, InputPathParams, IRoute, ParsedPathData, ParsedPathParams, PreparedNavigationData, RouteConfiguration, RouteNavigateParams } from './route.types.js';
|
|
5
5
|
/**
|
|
6
6
|
* Class for creating path based route.
|
|
7
7
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/core/route/route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/core/route/route.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAGL,KAAK,SAAS,EAEd,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,YAAY,EACb,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AACH,qBAAa,KAAK,CAChB,KAAK,SAAS,MAAM,EACpB,YAAY,SAAS,eAAe,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,EACpE,aAAa,SAAS,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,EACzD,YAAY,SAAS,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAC5D,YAAW,MAAM,CAAC,KAAK,EAAE,YAAY,EAAE,aAAa,CAAC;IAgC5C,IAAI,EAAE,KAAK;IAClB,SAAS,CAAC,MAAM,EAAE,kBAAkB,CAClC,KAAK,EACL,YAAY,EACZ,aAAa,EACb,YAAY,CACb;IApCH,SAAS,CAAC,eAAe,EAAE,eA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AAC,IAAI,CAAC;IACtE,IAAI,CACF,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,mBAAmB,CAAC,SAAS,CAAC,EACxC,KAAK,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC;IAwDhB,SAAS,CAAC,UAAU,CAClB,QAAQ,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAC7C,YAAY,CAAC,kBAAkB,CAAC;IAQnC,SAAS,CAAC,UAAU;IAQpB,SAAS,KAAK,SAAS,cAKtB;IAED,OAAO,CAAC,qBAAqB,CAAQ;IACrC,OAAO,CAAC,kBAAkB,CAcxB;IAEF,OAAO;CAGR;AAED,eAAO,MAAM,WAAW,GACtB,KAAK,SAAS,MAAM,EACpB,YAAY,SAAS,eAAe,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,EACpE,aAAa,SAAS,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,EACzD,YAAY,SAAS,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,EAE5D,MAAM,KAAK,EACX,SAAS,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,4DACD,CAAC"}
|
package/core/route/route.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/* eslint-disable prefer-const */
|
|
2
1
|
import { LinkedAbortController } from 'linked-abort-controller';
|
|
3
2
|
import { action, computed, makeObservable, observable, onBecomeObserved, onBecomeUnobserved, reaction, } from 'mobx';
|
|
4
3
|
import { buildSearchString, } from 'mobx-location-history';
|
|
5
|
-
import { compile, match, parse } from 'path-to-regexp';
|
|
4
|
+
import { compile, match, parse, } from 'path-to-regexp';
|
|
6
5
|
import { routeConfig } from '../config/config.js';
|
|
7
6
|
/**
|
|
8
7
|
* Class for creating path based route.
|
|
@@ -91,8 +90,8 @@ export class Route {
|
|
|
91
90
|
(pathnameToCheck === '/' || pathnameToCheck === '')) {
|
|
92
91
|
return { params: {}, path: pathnameToCheck };
|
|
93
92
|
}
|
|
94
|
-
|
|
95
|
-
const parsed =
|
|
93
|
+
this._matcher ??= match(this.tokenData);
|
|
94
|
+
const parsed = this._matcher(pathnameToCheck);
|
|
96
95
|
if (parsed === false) {
|
|
97
96
|
return null;
|
|
98
97
|
}
|
|
@@ -144,7 +143,7 @@ export class Route {
|
|
|
144
143
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#extend-path-config-route)
|
|
145
144
|
*/
|
|
146
145
|
extend(path, config) {
|
|
147
|
-
//
|
|
146
|
+
// biome-ignore lint/correctness/noUnusedVariables: this is need to extract unused fields
|
|
148
147
|
const { index, params, ...configFromCurrentRoute } = this.config;
|
|
149
148
|
const extendedChild = new Route(`${this.path}${path}`, {
|
|
150
149
|
...configFromCurrentRoute,
|
|
@@ -179,8 +178,8 @@ export class Route {
|
|
|
179
178
|
createUrl(...args) {
|
|
180
179
|
const pathParams = args[0];
|
|
181
180
|
const queryParams = args[1];
|
|
182
|
-
|
|
183
|
-
const path =
|
|
181
|
+
this._compiler ??= compile(this.tokenData);
|
|
182
|
+
const path = this._compiler(this.processParams(pathParams));
|
|
184
183
|
return [
|
|
185
184
|
this.baseUrl,
|
|
186
185
|
this.isHash ? '#' : '',
|
|
@@ -194,7 +193,7 @@ export class Route {
|
|
|
194
193
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#open-args)
|
|
195
194
|
*/
|
|
196
195
|
async open(...args) {
|
|
197
|
-
|
|
196
|
+
const { replace, state: rawState, query, } = typeof args[1] === 'boolean' || args.length > 2
|
|
198
197
|
? { replace: args[1], query: args[2] }
|
|
199
198
|
: (args[1] ?? {});
|
|
200
199
|
let url;
|
|
@@ -206,7 +205,7 @@ export class Route {
|
|
|
206
205
|
params = args[0];
|
|
207
206
|
url = this.createUrl(args[0], query);
|
|
208
207
|
}
|
|
209
|
-
|
|
208
|
+
const state = rawState ?? null;
|
|
210
209
|
const navigationData = {
|
|
211
210
|
url,
|
|
212
211
|
params: params,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { History } from 'mobx-location-history';
|
|
1
|
+
import { type History } from 'mobx-location-history';
|
|
2
2
|
export declare const mockHistory: (history: History) => {
|
|
3
3
|
spies: {
|
|
4
4
|
push: import("vitest").MockInstance<(to: import("mobx-location-history").To, state?: any) => void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.test.d.ts","sourceRoot":"","sources":["../../../src/core/route/route.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route.test.d.ts","sourceRoot":"","sources":["../../../src/core/route/route.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAS3E,eAAO,MAAM,WAAW,GAAI,SAAS,OAAO;;;;;;;;;;;;;;;;CAgB3C,CAAC"}
|
package/core/route/route.test.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
-
/* eslint-disable sonarjs/no-dead-store */
|
|
3
|
-
/* eslint-disable sonarjs/sonar-no-unused-vars */
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
1
|
import { createBrowserHistory } from 'mobx-location-history';
|
|
6
2
|
import { beforeEach, describe, expect, expectTypeOf, it, vi } from 'vitest';
|
|
7
3
|
import { routeConfig } from '../config/config.js';
|
|
@@ -193,7 +189,7 @@ describe('route', () => {
|
|
|
193
189
|
});
|
|
194
190
|
it('test param typings (with options)', () => {
|
|
195
191
|
const foo = new Route('/foo/:bar/:baz', {
|
|
196
|
-
params: (
|
|
192
|
+
params: (_params) => {
|
|
197
193
|
return {
|
|
198
194
|
bad: 1,
|
|
199
195
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ParseOptions } from 'path-to-regexp';
|
|
2
|
-
import {
|
|
3
|
-
import { RouteGlobalConfig } from '../config/config.types.js';
|
|
4
|
-
import { AnyAbstractRouteEntity } from '../route-group/route-group.types.js';
|
|
5
|
-
import { VirtualRoute } from '../virtual-route/virtual-route.js';
|
|
6
|
-
import { Route } from './route.js';
|
|
1
|
+
import type { ParseOptions } from 'path-to-regexp';
|
|
2
|
+
import type { AnyObject, IsPartial, Maybe, MaybePromise } from 'yummies/utils/types';
|
|
3
|
+
import type { RouteGlobalConfig } from '../config/config.types.js';
|
|
4
|
+
import type { AnyAbstractRouteEntity } from '../route-group/route-group.types.js';
|
|
5
|
+
import type { VirtualRoute } from '../virtual-route/virtual-route.js';
|
|
6
|
+
import type { Route } from './route.js';
|
|
7
7
|
export type PreparedNavigationData<TParams extends AnyObject = AnyObject> = {
|
|
8
8
|
state?: any;
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.types.d.ts","sourceRoot":"","sources":["../../../src/core/route/route.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"route.types.d.ts","sourceRoot":"","sources":["../../../src/core/route/route.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,YAAY,EACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,MAAM,sBAAsB,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,IAAI;IAC1E,KAAK,CAAC,EAAE,GAAG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S,MAAM,IAAI,YAAY,CAC7D,IAAI,EACJ,cAAc,CACf,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,cAAc,CAAC,KAAK,SAAS,MAAM;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,QAAQ,IAAI,CAAC,SAAS,MAAM,CAC1D,MAAM,KAAK,EACX,GAAG,EACH,GAAG,CACJ,GACG,KAAK,GACL,KAAK,CAAC;AAEV,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,QAAQ,IAAI,CAAC,SAAS,YAAY,CACvE,MAAM,OAAO,CACd,GACG,OAAO,GACP,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,MAAM,YAAY,EAAE,GAAG,CAAC,GAC5C,YAAY,GACZ,KAAK,CAAC;AAEZ,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,QAAQ,IAAI,CAAC,SAAS,YAAY,CAClE,MAAM,OAAO,CACd,GACG,OAAO,GACP,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC,GACvC,OAAO,GACP,KAAK,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-group.d.ts","sourceRoot":"","sources":["../../../src/core/route-group/route-group.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"route-group.d.ts","sourceRoot":"","sources":["../../../src/core/route-group/route-group.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EACjB,MAAM,wBAAwB,CAAC;AAIhC;;;;GAIG;AACH,qBAAa,UAAU,CAAC,iBAAiB,SAAS,gBAAgB,CAChE,YAAW,kBAAkB,CAAC,iBAAiB,CAAC;IAM9C,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,CAK3C;IAED;;;;OAIG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;CAuBpB;AAED,eAAO,MAAM,gBAAgB,GAAI,iBAAiB,SAAS,gBAAgB,EACzE,QAAQ,iBAAiB,EACzB,aAAa,cAAc,kCAC6B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyRoute } from '../route/index.js';
|
|
2
|
-
import { AbstractVirtualRoute, AnyVirtualRoute } from '../virtual-route/index.js';
|
|
2
|
+
import type { AbstractVirtualRoute, AnyVirtualRoute } from '../virtual-route/index.js';
|
|
3
3
|
import type { RouteGroup } from './route-group.js';
|
|
4
4
|
export type AnyRouteGroup = RouteGroup<RoutesCollection>;
|
|
5
5
|
export type AnyRouteEntity = AnyRoute | AnyRouteGroup | AnyVirtualRoute;
|
|
@@ -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,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,
|
|
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,KAAK,EACV,oBAAoB,EACpB,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAEnC,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,WAAW,kBAAkB,CACjC,iBAAiB,SAAS,gBAAgB,GAAG,gBAAgB;IAE7D,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAEpE,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC;AAE3E,MAAM,MAAM,qBAAqB,GAAG,sBAAsB,EAAE,CAAC;AAE7D,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;AAE5E,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,sBAAsB,CAAC"}
|
package/core/router/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/router/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/router/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
package/core/router/index.js
CHANGED
package/core/router/router.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { History, IQueryParams } from 'mobx-location-history';
|
|
2
|
-
import { RoutesCollection } from '../route-group/index.js';
|
|
3
|
-
import { RouterConfiguration, RouterNavigateOptions } from './router.types.js';
|
|
1
|
+
import { type History, type IQueryParams } from 'mobx-location-history';
|
|
2
|
+
import type { RoutesCollection } from '../route-group/index.js';
|
|
3
|
+
import type { RouterConfiguration, RouterNavigateOptions } from './router.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Class for centralized routing management.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,qBAAa,MAAM,CAAC,iBAAiB,SAAS,gBAAgB;IAC5D,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,YAAY,CAAC;gBAER,MAAM,EAAE,mBAAmB,CAAC,iBAAiB,CAAC;IAU1D,IAAI,QAAQ,6CAEX;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;CAWtD;AAED,eAAO,MAAM,YAAY,GAAI,iBAAiB,SAAS,gBAAgB,EACrE,QAAQ,mBAAmB,CAAC,iBAAiB,CAAC,8BACzB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { History, IQueryParams } from 'mobx-location-history';
|
|
2
|
-
import { AnyObject } from 'yummies/utils/types';
|
|
3
|
-
import { RoutesCollection } from '../route-group/index.js';
|
|
4
|
-
import { Router } from './router.js';
|
|
1
|
+
import type { History, IQueryParams } from 'mobx-location-history';
|
|
2
|
+
import type { AnyObject } from 'yummies/utils/types';
|
|
3
|
+
import type { RoutesCollection } from '../route-group/index.js';
|
|
4
|
+
import type { Router } from './router.js';
|
|
5
5
|
export interface RouterConfiguration<TRoutesStruct extends RoutesCollection> {
|
|
6
6
|
routes: TRoutesStruct;
|
|
7
7
|
history?: History;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.types.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"router.types.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,mBAAmB,CAAC,aAAa,SAAS,gBAAgB;IACzE,MAAM,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-route-entity.d.ts","sourceRoot":"","sources":["../../../src/core/utils/is-route-entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"is-route-entity.d.ts","sourceRoot":"","sources":["../../../src/core/utils/is-route-entity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE1E,eAAO,MAAM,aAAa,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,cACtB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IQueryParams } from 'mobx-location-history';
|
|
2
|
-
import {
|
|
3
|
-
import { AbstractVirtualRoute, VirtualOpenExtraParams, VirtualRouteConfiguration } from './virtual-route.types.js';
|
|
1
|
+
import type { IQueryParams } from 'mobx-location-history';
|
|
2
|
+
import type { AnyObject, EmptyObject, IsPartial, Maybe } from 'yummies/utils/types';
|
|
3
|
+
import type { AbstractVirtualRoute, VirtualOpenExtraParams, VirtualRouteConfiguration } from './virtual-route.types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Class for creating routes with custom activation logic
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-route.d.ts","sourceRoot":"","sources":["../../../src/core/virtual-route/virtual-route.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"virtual-route.d.ts","sourceRoot":"","sources":["../../../src/core/virtual-route/virtual-route.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,KAAK,EACN,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAElC;;;;GAIG;AACH,qBAAa,YAAY,CAAC,OAAO,SAAS,SAAS,GAAG,WAAW,GAAG,WAAW,CAC7E,YAAW,oBAAoB,CAAC,OAAO,CAAC;IAW5B,SAAS,CAAC,MAAM,EAAE,yBAAyB,CAAC,OAAO,CAAC;IAThE,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAC3C,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvB,OAAO,CAAC,aAAa,CAAU;IAE/B,OAAO,CAAC,WAAW,CAA2D;IAC9E,OAAO,CAAC,gBAAgB,CAAsB;gBAExB,MAAM,GAAE,yBAAyB,CAAC,OAAO,CAAM;IAoCrE;;OAEG;IACH,IAAI,QAAQ,YAGX;IAED;;OAEG;IACH,cAAc,CACZ,WAAW,EAAE,KAAK,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC;IAKvE;;OAEG;IACH,IAAI,CACF,GAAG,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,IAAI,GACpC,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,sBAAsB,CAAC,GAC/D,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,sBAAsB,CAAC,GAC1D,OAAO,CAAC,IAAI,CAAC;IAyChB;;OAEG;IACH,KAAK;IAYL,OAAO,CAAC,qBAAqB,CAAQ;IACrC,OAAO,CAAC,kBAAkB,CAcxB;IAEF,OAAO;CAGR;AAED,eAAO,MAAM,kBAAkB,GAC7B,OAAO,SAAS,SAAS,GAAG,WAAW,GAAG,WAAW,EAErD,SAAS,yBAAyB,CAAC,OAAO,CAAC,0BACP,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IQueryParams } from 'mobx-location-history';
|
|
2
|
-
import {
|
|
1
|
+
import type { IQueryParams } from 'mobx-location-history';
|
|
2
|
+
import type { AnyObject, EmptyObject, IsPartial, Maybe, MaybeFn, MaybePromise } from 'yummies/utils/types';
|
|
3
3
|
import type { VirtualRoute } from './virtual-route.js';
|
|
4
4
|
export type AnyVirtualRoute = VirtualRoute<any>;
|
|
5
5
|
export interface VirtualOpenExtraParams {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-route.types.d.ts","sourceRoot":"","sources":["../../../src/core/virtual-route/virtual-route.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"virtual-route.types.d.ts","sourceRoot":"","sources":["../../../src/core/virtual-route/virtual-route.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,KAAK,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,KAAK,EACL,OAAO,EACP,YAAY,EACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB,CACnC,OAAO,SAAS,SAAS,GAAG,WAAW,GAAG,WAAW;IAErD,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB,CACxC,OAAO,SAAS,SAAS,GAAG,WAAW,GAAG,WAAW;IAErD;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B,WAAW,CAAC,EAAE,YAAY,CAAC;IAE3B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CACrB,KAAK,CAAC,OAAO,CAAC,EACd;QAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KAAC,CACxC,CAAC;IAEF;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB;;;;OAIG;IACH,IAAI,CAAC,EAAE,CACL,GAAG,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,IAAI,GACpC,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,GACtD,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,KAChD,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAElC;;;;OAIG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,OAAO,GAAG,IAAI,CAAC;IAEzD;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC;IAExD;;OAEG;IACH,UAAU,CAAC,EAAE,CACX,GAAG,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,IAAI,GACpC,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,GACtD,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,KAChD,YAAY,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC;IAElC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IAExB;;OAEG;IACH,SAAS,CAAC,EAAE,CACV,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EACxB,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAClC,IAAI,CAAC;CACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-route",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"mobx",
|
|
6
6
|
"react",
|
|
@@ -46,16 +46,17 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
+
"@changesets/changelog-github": "^0.5.1",
|
|
50
|
+
"@changesets/cli": "^2.29.5",
|
|
51
|
+
"@biomejs/biome": "2.1.4",
|
|
49
52
|
"@types/react": "^18.0.0 || ^19.0.0",
|
|
50
53
|
"@testing-library/react": "^16.3.0",
|
|
51
54
|
"@types/lodash-es": "^4.17.12",
|
|
52
55
|
"@types/node": "^20.17.30",
|
|
53
56
|
"@vitejs/plugin-react-swc": "^3.9.0",
|
|
54
57
|
"@vitest/coverage-istanbul": "^3.1.2",
|
|
55
|
-
"commitfmt": "^1.0.
|
|
56
|
-
"
|
|
57
|
-
"js2me-eslint-config": "^1.0.7",
|
|
58
|
-
"js2me-exports-post-build-script": "^3.0.2",
|
|
58
|
+
"commitfmt": "^1.0.4",
|
|
59
|
+
"js2me-exports-post-build-script": "^5.0.1",
|
|
59
60
|
"jsdom": "^26.1.0",
|
|
60
61
|
"lefthook": "^1.11.13",
|
|
61
62
|
"nodemon": "^3.1.9",
|
|
@@ -144,16 +145,6 @@
|
|
|
144
145
|
"default": "./react/components/link.js",
|
|
145
146
|
"types": "./react/components/link.d.ts"
|
|
146
147
|
},
|
|
147
|
-
"./react/components/route-switch.test": {
|
|
148
|
-
"import": "./react/components/route-switch.test.js",
|
|
149
|
-
"default": "./react/components/route-switch.test.js",
|
|
150
|
-
"types": "./react/components/route-switch.test.d.ts"
|
|
151
|
-
},
|
|
152
|
-
"./react/components/route-switch": {
|
|
153
|
-
"import": "./react/components/route-switch.js",
|
|
154
|
-
"default": "./react/components/route-switch.js",
|
|
155
|
-
"types": "./react/components/route-switch.d.ts"
|
|
156
|
-
},
|
|
157
148
|
"./react/components/route-view-group.test": {
|
|
158
149
|
"import": "./react/components/route-view-group.test.js",
|
|
159
150
|
"default": "./react/components/route-view-group.test.js",
|
|
@@ -193,21 +184,23 @@
|
|
|
193
184
|
"typings": "./index.d.ts",
|
|
194
185
|
"scripts": {
|
|
195
186
|
"clean": "rimraf dist",
|
|
196
|
-
"lint:check": "
|
|
187
|
+
"lint:check": "pnpm exec biome check --write --no-errors-on-unmatched --files-ignore-unknown=true",
|
|
197
188
|
"ts:check": "tsc --noEmit",
|
|
198
189
|
"check": "npm run lint:check && npm run ts:check",
|
|
199
190
|
"prebuild": "npm run clean && npm run check",
|
|
200
|
-
"build:watch": "npm run build && nodemon --
|
|
191
|
+
"build:watch": "npm run build && nodemon --watch src --ext ts --exec \"tsc && node ./post-build.mjs\"",
|
|
201
192
|
"build": "tsc && node ./post-build.mjs",
|
|
202
193
|
"pub": "PUBLISH=true pnpm run build",
|
|
194
|
+
"pub-ci": "PUBLISH=true CI=true pnpm run build",
|
|
203
195
|
"pub:patch": "PUBLISH=true PUBLISH_VERSION=patch pnpm run build",
|
|
204
196
|
"pub:minor": "PUBLISH=true PUBLISH_VERSION=minor pnpm run build",
|
|
205
197
|
"pub:major": "PUBLISH=true PUBLISH_VERSION=major pnpm run build",
|
|
206
|
-
"test": "vitest run",
|
|
207
|
-
"test:watch": "vitest watch",
|
|
208
|
-
"test:coverage": "vitest run --coverage",
|
|
198
|
+
"test": "vitest run --config vitest.config.ts",
|
|
199
|
+
"test:watch": "vitest watch --config vitest.config.ts",
|
|
200
|
+
"test:coverage": "vitest run --config vitest.config.ts --coverage",
|
|
209
201
|
"docs": "pnpm build && cd docs && pnpm dev",
|
|
210
|
-
"docs:
|
|
202
|
+
"docs:install": "cd docs && pnpm i",
|
|
203
|
+
"docs:build": "cd docs && pnpm build",
|
|
211
204
|
"docs:serve": "cd docs && pnpm preview",
|
|
212
205
|
"dev": "pnpm test:watch",
|
|
213
206
|
"dev:install-hooks": "if [ -z \"$CI\" ]; then lefthook install; fi"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAGhC,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnchorHTMLAttributes
|
|
2
|
-
import { IsPartial } from 'yummies/utils/types';
|
|
3
|
-
import { AnyRoute, InputPathParams, RouteNavigateParams } from '../../core/index.js';
|
|
1
|
+
import { type AnchorHTMLAttributes } from 'react';
|
|
2
|
+
import type { IsPartial } from 'yummies/utils/types';
|
|
3
|
+
import { type AnyRoute, type InputPathParams, type RouteNavigateParams } from '../../core/index.js';
|
|
4
4
|
interface LinkAnchorProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
|
|
5
5
|
asChild?: boolean;
|
|
6
6
|
}
|
|
@@ -17,7 +17,7 @@ type LinkSimpleRouteProps = {
|
|
|
17
17
|
href: string;
|
|
18
18
|
};
|
|
19
19
|
export type LinkProps<TRoute extends AnyRoute> = LinkAnchorProps & RouteNavigateParams & (LinkPathRouteProps<TRoute> | LinkSimpleRouteProps);
|
|
20
|
-
type LinkComponentType = <TRoute extends AnyRoute>(props: LinkProps<TRoute>) => ReactNode;
|
|
20
|
+
type LinkComponentType = <TRoute extends AnyRoute>(props: LinkProps<TRoute>) => React.ReactNode;
|
|
21
21
|
export declare const Link: LinkComponentType;
|
|
22
22
|
export {};
|
|
23
23
|
//# sourceMappingURL=link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/react/components/link.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/react/components/link.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EAK1B,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAa,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAEzB,MAAM,qBAAqB,CAAC;AAE7B,UAAU,eACR,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,KAAK,kBAAkB,CAAC,MAAM,SAAS,QAAQ,IAAI;IACjD,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,CAAC,SAAS,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IAAI,GACxD;IACE,MAAM,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;CAC7D,GACD;IAAE,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC;AAEjD,KAAK,oBAAoB,GACrB;IACE,EAAE,EAAE,MAAM,CAAC;CACZ,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEN,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,QAAQ,IAAI,eAAe,GAC9D,mBAAmB,GACnB,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC;AAEtD,KAAK,iBAAiB,GAAG,CAAC,MAAM,SAAS,QAAQ,EAC/C,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,KACrB,KAAK,CAAC,SAAS,CAAC;AAErB,eAAO,MAAM,IAAI,EAsED,iBAAiB,CAAC"}
|
package/react/components/link.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
2
|
import { buildSearchString } from 'mobx-location-history';
|
|
4
3
|
import { observer } from 'mobx-react-lite';
|
|
5
4
|
import { cloneElement, forwardRef, isValidElement, } from 'react';
|
|
@@ -7,12 +6,15 @@ import { routeConfig, } from '../../core/index.js';
|
|
|
7
6
|
export const Link = observer(forwardRef(({ to, href: outerHref, asChild, children, params,
|
|
8
7
|
// route navigate params
|
|
9
8
|
query, replace, state, ...outerAnchorProps }, ref) => {
|
|
9
|
+
const isExternalNavigation = outerAnchorProps.target === '_blank' ||
|
|
10
|
+
outerAnchorProps.target === 'blank';
|
|
10
11
|
const href = outerHref ??
|
|
11
12
|
(typeof to === 'string'
|
|
12
13
|
? `${to}${buildSearchString(query || {})}`
|
|
13
14
|
: to.createUrl(params, query));
|
|
14
15
|
const handleClick = (event) => {
|
|
15
|
-
if (
|
|
16
|
+
if (isExternalNavigation ||
|
|
17
|
+
event.ctrlKey ||
|
|
16
18
|
event.metaKey ||
|
|
17
19
|
event.altKey ||
|
|
18
20
|
event.shiftKey ||
|
|
@@ -33,9 +35,8 @@ query, replace, state, ...outerAnchorProps }, ref) => {
|
|
|
33
35
|
...outerAnchorProps,
|
|
34
36
|
href,
|
|
35
37
|
onClick: handleClick,
|
|
36
|
-
rel: outerAnchorProps.
|
|
37
|
-
? 'noopener noreferrer'
|
|
38
|
-
: outerAnchorProps.rel,
|
|
38
|
+
rel: outerAnchorProps.rel ??
|
|
39
|
+
(isExternalNavigation ? 'noopener noreferrer' : undefined),
|
|
39
40
|
};
|
|
40
41
|
return asChild && isValidElement(children) ? (
|
|
41
42
|
// @ts-ignore
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
children: ReactNode;
|
|
1
|
+
import type { IsPartial, Maybe } from 'yummies/utils/types';
|
|
2
|
+
import { type AnyRouteEntity, type RouteNavigateParams, type RouteParams } from '../../core/index.js';
|
|
3
|
+
type LayoutComponent = React.ComponentType<{
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}> | React.ComponentType<{
|
|
6
|
+
children: React.ReactNode;
|
|
8
7
|
}>;
|
|
9
8
|
interface BaseProps extends RouteNavigateParams {
|
|
10
|
-
children: ReactNode;
|
|
9
|
+
children: React.ReactNode;
|
|
11
10
|
layout?: LayoutComponent;
|
|
12
11
|
}
|
|
13
12
|
type PropsWithDefaultRoute<TRoute extends AnyRouteEntity> = BaseProps & {
|
|
@@ -21,8 +20,7 @@ type PropsWithDefaultUrl = BaseProps & {
|
|
|
21
20
|
otherwise?: string;
|
|
22
21
|
};
|
|
23
22
|
export type RouteViewGroupProps<TRoute extends AnyRouteEntity> = PropsWithDefaultRoute<TRoute> | PropsWithDefaultUrl;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
23
|
+
type RouteViewGroupComponent = <TRoute extends AnyRouteEntity>(props: RouteViewGroupProps<TRoute>) => React.ReactNode;
|
|
24
|
+
export declare const RouteViewGroup: RouteViewGroupComponent;
|
|
27
25
|
export {};
|
|
28
26
|
//# sourceMappingURL=route-view-group.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-view-group.d.ts","sourceRoot":"","sources":["../../../src/react/components/route-view-group.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route-view-group.d.ts","sourceRoot":"","sources":["../../../src/react/components/route-view-group.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAEjB,MAAM,qBAAqB,CAAC;AAG7B,KAAK,eAAe,GAChB,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,GACnD,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CAAC,CAAC;AAEvD,UAAU,SAAU,SAAQ,mBAAmB;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAED,KAAK,qBAAqB,CAAC,MAAM,SAAS,cAAc,IAAI,SAAS,GAAG;IACtE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,IAAI,GAC1C;IACE,MAAM,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;CACrC,GACD;IACE,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC,CAAC;AAET,KAAK,mBAAmB,GAAG,SAAS,GAAG;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,MAAM,SAAS,cAAc,IACzD,qBAAqB,CAAC,MAAM,CAAC,GAC7B,mBAAmB,CAAC;AAExB,KAAK,uBAAuB,GAAG,CAAC,MAAM,SAAS,cAAc,EAC3D,KAAK,EAAE,mBAAmB,CAAC,MAAM,CAAC,KAC/B,KAAK,CAAC,SAAS,CAAC;AAErB,eAAO,MAAM,cAAc,EA8DX,uBAAuB,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable sonarjs/no-nested-conditional */
|
|
3
|
-
/* eslint-disable unicorn/no-nested-ternary */
|
|
4
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
5
2
|
import { buildSearchString } from 'mobx-location-history';
|
|
6
3
|
import { observer } from 'mobx-react-lite';
|
|
7
4
|
import { isValidElement, useEffect } from 'react';
|
|
8
5
|
import { routeConfig, } from '../../core/index.js';
|
|
9
6
|
import { isRouteEntity } from '../../core/utils/is-route-entity.js';
|
|
10
|
-
export const RouteViewGroup = observer(
|
|
7
|
+
export const RouteViewGroup = observer(({ children, layout: Layout, otherwise: otherwiseNavigation,
|
|
11
8
|
// @ts-ignore
|
|
12
|
-
params, ...navigateParams }) {
|
|
9
|
+
params, ...navigateParams }) => {
|
|
13
10
|
let activeChildNode = null;
|
|
14
11
|
let lastInactiveChildNode = null;
|
|
15
12
|
const childNodes = Array.isArray(children)
|
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
/* eslint-disable sonarjs/no-unstable-nested-components */
|
|
3
2
|
import { act, render } from '@testing-library/react';
|
|
4
3
|
import { createBrowserHistory } from 'mobx-location-history';
|
|
5
|
-
import {
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
6
5
|
import { Route, routeConfig } from '../../core/index.js';
|
|
7
6
|
import { mockHistory } from '../../core/route/route.test.js';
|
|
8
|
-
import { RouteViewGroup } from './route-view-group.js';
|
|
9
7
|
import { RouteView } from './route-view.js';
|
|
8
|
+
import { RouteViewGroup } from './route-view-group.js';
|
|
10
9
|
describe('<RouteViewGroup />', () => {
|
|
11
10
|
it('Should render nothing when no one route is opened', async () => {
|
|
12
11
|
const history = mockHistory(createBrowserHistory());
|
|
13
12
|
routeConfig.update({
|
|
14
13
|
history,
|
|
15
14
|
});
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
history.clearMocks();
|
|
18
|
-
});
|
|
19
15
|
const route1 = new Route('/test1');
|
|
20
16
|
const route2 = new Route('/test2');
|
|
21
17
|
const route3 = new Route('/test3');
|
|
@@ -30,9 +26,6 @@ describe('<RouteViewGroup />', () => {
|
|
|
30
26
|
routeConfig.update({
|
|
31
27
|
history,
|
|
32
28
|
});
|
|
33
|
-
beforeEach(() => {
|
|
34
|
-
history.clearMocks();
|
|
35
|
-
});
|
|
36
29
|
const route1 = new Route('/test1');
|
|
37
30
|
const route2 = new Route('/test2');
|
|
38
31
|
const route3 = new Route('/test3');
|
|
@@ -47,9 +40,6 @@ describe('<RouteViewGroup />', () => {
|
|
|
47
40
|
routeConfig.update({
|
|
48
41
|
history,
|
|
49
42
|
});
|
|
50
|
-
beforeEach(() => {
|
|
51
|
-
history.clearMocks();
|
|
52
|
-
});
|
|
53
43
|
const route1 = new Route('/test1');
|
|
54
44
|
const route2 = new Route('/test2');
|
|
55
45
|
const route3 = new Route('/test3');
|
|
@@ -65,9 +55,6 @@ describe('<RouteViewGroup />', () => {
|
|
|
65
55
|
routeConfig.update({
|
|
66
56
|
history,
|
|
67
57
|
});
|
|
68
|
-
beforeEach(() => {
|
|
69
|
-
history.clearMocks();
|
|
70
|
-
});
|
|
71
58
|
const route1 = new Route('/test1');
|
|
72
59
|
const route2 = new Route('/test2');
|
|
73
60
|
const route3 = new Route('/test3');
|
|
@@ -83,9 +70,6 @@ describe('<RouteViewGroup />', () => {
|
|
|
83
70
|
routeConfig.update({
|
|
84
71
|
history,
|
|
85
72
|
});
|
|
86
|
-
beforeEach(() => {
|
|
87
|
-
history.clearMocks();
|
|
88
|
-
});
|
|
89
73
|
const route1 = new Route('/test1');
|
|
90
74
|
const route2 = new Route('/test2');
|
|
91
75
|
const route3 = new Route('/test3');
|
|
@@ -101,9 +85,6 @@ describe('<RouteViewGroup />', () => {
|
|
|
101
85
|
routeConfig.update({
|
|
102
86
|
history,
|
|
103
87
|
});
|
|
104
|
-
beforeEach(() => {
|
|
105
|
-
history.clearMocks();
|
|
106
|
-
});
|
|
107
88
|
const route1 = new Route('/test');
|
|
108
89
|
const route2 = new Route('/test');
|
|
109
90
|
const route3 = new Route('/test');
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export type RouteViewComponent<TRoute extends AnyAbstractRouteEntity> = ComponentType<RouteViewProps<TRoute>>;
|
|
1
|
+
import { type LoadableConfig } from 'react-simple-loadable';
|
|
2
|
+
import type { AnyAbstractRouteEntity, AnyRoute, AnyVirtualRoute } from '../../core/index.js';
|
|
3
|
+
export type RouteViewComponent<TRoute extends AnyAbstractRouteEntity> = React.ComponentType<RouteViewProps<TRoute>>;
|
|
5
4
|
interface RouteViewConfigWithoutRoute {
|
|
6
|
-
children?: ReactNode | (() => ReactNode);
|
|
5
|
+
children?: React.ReactNode | (() => React.ReactNode);
|
|
7
6
|
}
|
|
8
7
|
export interface RouteViewConfigWithRoute<TRoute extends AnyAbstractRouteEntity> extends Pick<LoadableConfig, 'loading' | 'preload' | 'throwOnError'> {
|
|
9
8
|
route: TRoute;
|
|
@@ -12,17 +11,15 @@ export interface RouteViewConfigWithRoute<TRoute extends AnyAbstractRouteEntity>
|
|
|
12
11
|
/**
|
|
13
12
|
* Case when route is not opened
|
|
14
13
|
*/
|
|
15
|
-
fallback?: ReactNode;
|
|
16
|
-
children?: ReactNode | ((params: RouteViewProps<TRoute>['params'], route: TRoute) => ReactNode);
|
|
14
|
+
fallback?: React.ReactNode;
|
|
15
|
+
children?: React.ReactNode | ((params: RouteViewProps<TRoute>['params'], route: TRoute) => React.ReactNode);
|
|
17
16
|
}
|
|
18
17
|
export type RouteViewConfig<TRoute extends AnyAbstractRouteEntity> = RouteViewConfigWithRoute<TRoute> | RouteViewConfigWithoutRoute;
|
|
19
18
|
export type RouteViewProps<TRoute extends AnyAbstractRouteEntity> = {
|
|
20
|
-
children?: ReactNode;
|
|
19
|
+
children?: React.ReactNode;
|
|
21
20
|
params: TRoute extends AnyRoute ? Exclude<TRoute['params'], null | undefined> : TRoute extends AnyVirtualRoute ? TRoute['params'] : never;
|
|
22
21
|
};
|
|
23
|
-
|
|
24
|
-
export declare const RouteView:
|
|
25
|
-
displayName: string;
|
|
26
|
-
};
|
|
22
|
+
type RouteViewBaseComponent = <TRoute extends AnyAbstractRouteEntity>(props: RouteViewConfig<TRoute>) => React.ReactNode;
|
|
23
|
+
export declare const RouteView: RouteViewBaseComponent;
|
|
27
24
|
export {};
|
|
28
25
|
//# sourceMappingURL=route-view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-view.d.ts","sourceRoot":"","sources":["../../../src/react/components/route-view.tsx"],"names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C,SAAS,CAAC;IAC3B,MAAM,EAAE,MAAM,SAAS,QAAQ,GAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,GAC3C,MAAM,SAAS,eAAe,GAC5B,MAAM,CAAC,QAAQ,CAAC,GAChB,KAAK,CAAC;CACb,CAAC;AAEF,KAAK,sBAAsB,GAAG,CAAC,MAAM,SAAS,sBAAsB,EAClE,KAAK,EAAE,eAAe,CAAC,MAAM,CAAC,KAC3B,KAAK,CAAC,SAAS,CAAC;AA+CrB,eAAO,MAAM,SAAS,EAA8B,sBAAsB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IQueryParams } from 'mobx-location-history';
|
|
2
|
-
import { ViewModelBase, ViewModelParams } from 'mobx-view-model';
|
|
3
|
-
import { EmptyObject } from 'yummies/utils/types';
|
|
4
|
-
import { AnyAbstractRouteEntity, RouteParams } from '../core/index.js';
|
|
1
|
+
import type { IQueryParams } from 'mobx-location-history';
|
|
2
|
+
import { ViewModelBase, type ViewModelParams } from 'mobx-view-model';
|
|
3
|
+
import type { EmptyObject } from 'yummies/utils/types';
|
|
4
|
+
import { type AnyAbstractRouteEntity, type RouteParams } from '../core/index.js';
|
|
5
5
|
export declare abstract class RouteViewModel<TRoute extends AnyAbstractRouteEntity = AnyAbstractRouteEntity> extends ViewModelBase<EmptyObject> {
|
|
6
6
|
abstract readonly route: TRoute;
|
|
7
7
|
constructor(params: ViewModelParams<EmptyObject, any>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-view-model.d.ts","sourceRoot":"","sources":["../../src/view-model/route-view-model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"route-view-model.d.ts","sourceRoot":"","sources":["../../src/view-model/route-view-model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAEL,aAAa,EACb,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EACL,KAAK,sBAAsB,EAE3B,KAAK,WAAW,EAGjB,MAAM,kBAAkB,CAAC;AAE1B,8BAAsB,cAAc,CAClC,MAAM,SAAS,sBAAsB,GAAG,sBAAsB,CAC9D,SAAQ,aAAa,CAAC,WAAW,CAAC;IAClC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEpB,MAAM,EAAE,eAAe,CAAC,WAAW,EAAE,GAAG,CAAC;IAarD,IAAa,OAAO,IAAI,WAAW,CAAC,MAAM,CAAC,CAU1C;IAED,IAAI,KAAK,IAAI,YAAY,CAMxB;IAED,IAAI,UAAU,wBAEb;IAED,IAAI,SAAS,YAEZ;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed } from 'mobx';
|
|
2
2
|
import { applyObservable, ViewModelBase, } from 'mobx-view-model';
|
|
3
|
-
import {
|
|
3
|
+
import { Route, routeConfig, VirtualRoute, } from '../core/index.js';
|
|
4
4
|
export class RouteViewModel extends ViewModelBase {
|
|
5
5
|
constructor(params) {
|
|
6
6
|
super(params);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { IsPartial, Maybe } from 'yummies/utils/types';
|
|
3
|
-
import { AnyRouteEntity, RouteNavigateParams, RouteParams } from '../../core/index.js';
|
|
4
|
-
interface BaseProps extends RouteNavigateParams {
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
type PropsWithDefaultRoute<TRoute extends AnyRouteEntity> = BaseProps & {
|
|
8
|
-
default?: TRoute;
|
|
9
|
-
} & (IsPartial<RouteParams<TRoute>> extends true ? {
|
|
10
|
-
params?: Maybe<RouteParams<TRoute>>;
|
|
11
|
-
} : {
|
|
12
|
-
params: RouteParams<TRoute>;
|
|
13
|
-
});
|
|
14
|
-
type PropsWithDefaultUrl = BaseProps & {
|
|
15
|
-
default?: string;
|
|
16
|
-
};
|
|
17
|
-
export type SwitchProps<TRoute extends AnyRouteEntity> = PropsWithDefaultRoute<TRoute> | PropsWithDefaultUrl;
|
|
18
|
-
/**
|
|
19
|
-
* WIP
|
|
20
|
-
*/
|
|
21
|
-
export declare const Switch: (<TRoute extends AnyRouteEntity>({ children, default: defaultNavigation, params, ...navigateParams }: SwitchProps<TRoute>) => string | number | bigint | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null) & {
|
|
22
|
-
displayName: string;
|
|
23
|
-
};
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=route-switch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-switch.d.ts","sourceRoot":"","sources":["../../../src/react/components/route-switch.tsx"],"names":[],"mappings":"AAKA,OAAO,EAA4B,SAAS,EAAa,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EACL,cAAc,EAEd,mBAAmB,EACnB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAG7B,UAAU,SAAU,SAAQ,mBAAmB;IAC7C,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,KAAK,qBAAqB,CAAC,MAAM,SAAS,cAAc,IAAI,SAAS,GAAG;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,IAAI,GAC1C;IACE,MAAM,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;CACrC,GACD;IACE,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC,CAAC;AAET,KAAK,mBAAmB,GAAG,SAAS,GAAG;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,CAAC,MAAM,SAAS,cAAc,IACjD,qBAAqB,CAAC,MAAM,CAAC,GAC7B,mBAAmB,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,MAAM,IAAsB,MAAM,SAAS,cAAc,uEAMnE,WAAW,CAAC,MAAM,CAAC;;CA2GpB,CAAC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/* eslint-disable sonarjs/no-nested-conditional */
|
|
2
|
-
/* eslint-disable unicorn/no-nested-ternary */
|
|
3
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
4
|
-
import { buildSearchString } from 'mobx-location-history';
|
|
5
|
-
import { observer } from 'mobx-react-lite';
|
|
6
|
-
import { Fragment, isValidElement, useEffect } from 'react';
|
|
7
|
-
import { routeConfig, } from '../../core/index.js';
|
|
8
|
-
import { isRouteEntity } from '../../core/utils/is-route-entity.js';
|
|
9
|
-
/**
|
|
10
|
-
* WIP
|
|
11
|
-
*/
|
|
12
|
-
export const Switch = observer(function ({ children, default: defaultNavigation,
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
params, ...navigateParams }) {
|
|
15
|
-
let activeElement = null;
|
|
16
|
-
let lastInactiveElement = null;
|
|
17
|
-
let foundActive = false;
|
|
18
|
-
const stack = Array.isArray(children)
|
|
19
|
-
? [...children].reverse()
|
|
20
|
-
: children
|
|
21
|
-
? [children]
|
|
22
|
-
: [];
|
|
23
|
-
while (stack.length > 0) {
|
|
24
|
-
const node = stack.pop();
|
|
25
|
-
if (node == null || typeof node === 'boolean') {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (Array.isArray(node)) {
|
|
29
|
-
for (let i = node.length - 1; i >= 0; i--) {
|
|
30
|
-
stack.push(node[i]);
|
|
31
|
-
}
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
if (isValidElement(node) && node.type === Fragment) {
|
|
35
|
-
// @ts-expect-error redundand checks better to wrap in this directive
|
|
36
|
-
const fragmentChildren = node.props?.children;
|
|
37
|
-
if (fragmentChildren) {
|
|
38
|
-
if (Array.isArray(fragmentChildren)) {
|
|
39
|
-
for (let i = fragmentChildren.length - 1; i >= 0; i--) {
|
|
40
|
-
stack.push(fragmentChildren[i]);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
stack.push(fragmentChildren);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
let isActive = false;
|
|
50
|
-
const checkStack = [node];
|
|
51
|
-
while (checkStack.length > 0) {
|
|
52
|
-
const checkNode = checkStack.pop();
|
|
53
|
-
if (checkNode == null || typeof checkNode === 'boolean') {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
if (Array.isArray(checkNode)) {
|
|
57
|
-
for (const element of checkNode) {
|
|
58
|
-
checkStack.push(element);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
else if (isValidElement(checkNode)) {
|
|
62
|
-
if (
|
|
63
|
-
// @ts-expect-error redundand checks better to wrap in this directive
|
|
64
|
-
isRouteEntity(checkNode.props?.route) &&
|
|
65
|
-
// @ts-expect-error redundand checks better to wrap in this directive
|
|
66
|
-
checkNode.props.route.isOpened) {
|
|
67
|
-
isActive = true;
|
|
68
|
-
break;
|
|
69
|
-
}
|
|
70
|
-
// @ts-expect-error redundand checks better to wrap in this directive
|
|
71
|
-
if (checkNode.props.children) {
|
|
72
|
-
// @ts-expect-error redundand checks better to wrap in this directive
|
|
73
|
-
checkStack.push(checkNode.props.children);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (isActive) {
|
|
78
|
-
activeElement = node;
|
|
79
|
-
foundActive = true;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
lastInactiveElement = node;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
if (!foundActive && defaultNavigation) {
|
|
87
|
-
if (typeof defaultNavigation === 'string') {
|
|
88
|
-
const history = routeConfig.get().history;
|
|
89
|
-
const url = `${defaultNavigation}${buildSearchString(navigateParams.query || {})}`;
|
|
90
|
-
if (navigateParams.replace) {
|
|
91
|
-
history.replace(url, navigateParams.state);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
history.push(url, navigateParams.state);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else if (!defaultNavigation.isOpened) {
|
|
98
|
-
defaultNavigation.open(params, navigateParams);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}, [foundActive, defaultNavigation]);
|
|
102
|
-
if (foundActive) {
|
|
103
|
-
return activeElement;
|
|
104
|
-
}
|
|
105
|
-
if (defaultNavigation) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
return lastInactiveElement ?? null;
|
|
109
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"route-switch.test.d.ts","sourceRoot":"","sources":["../../../src/react/components/route-switch.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { act, render } from '@testing-library/react';
|
|
3
|
-
import { createBrowserHistory } from 'mobx-location-history';
|
|
4
|
-
import { beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
-
import { Route, routeConfig } from '../../core/index.js';
|
|
6
|
-
import { mockHistory } from '../../core/route/route.test.js';
|
|
7
|
-
import { Switch } from './route-switch.js';
|
|
8
|
-
import { RouteView } from './route-view.js';
|
|
9
|
-
describe('<RouteSwitch/>', () => {
|
|
10
|
-
it('Should render nothing when no one route is opened', async () => {
|
|
11
|
-
const history = mockHistory(createBrowserHistory());
|
|
12
|
-
routeConfig.update({
|
|
13
|
-
history,
|
|
14
|
-
});
|
|
15
|
-
beforeEach(() => {
|
|
16
|
-
history.clearMocks();
|
|
17
|
-
});
|
|
18
|
-
const route1 = new Route('/test1');
|
|
19
|
-
const route2 = new Route('/test2');
|
|
20
|
-
const route3 = new Route('/test3');
|
|
21
|
-
const App = () => {
|
|
22
|
-
return (_jsxs(Switch, { children: [_jsx(RouteView, { route: route1, view: () => _jsx("div", { children: "route1" }) }), _jsx(RouteView, { route: route2, view: () => _jsx("div", { children: "route2" }) }), _jsx(RouteView, { route: route3, view: () => _jsx("div", { children: "route3" }) })] }));
|
|
23
|
-
};
|
|
24
|
-
const { container } = await act(async () => render(_jsx(App, {})));
|
|
25
|
-
expect(container.firstChild).toBeNull();
|
|
26
|
-
});
|
|
27
|
-
it('Should render last non active element when no one route is opened', async () => {
|
|
28
|
-
const history = mockHistory(createBrowserHistory());
|
|
29
|
-
routeConfig.update({
|
|
30
|
-
history,
|
|
31
|
-
});
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
history.clearMocks();
|
|
34
|
-
});
|
|
35
|
-
const route1 = new Route('/test1');
|
|
36
|
-
const route2 = new Route('/test2');
|
|
37
|
-
const route3 = new Route('/test3');
|
|
38
|
-
const App1 = () => {
|
|
39
|
-
return (_jsxs(Switch, { children: [_jsx(RouteView, { route: route1, view: () => _jsx("div", { children: "route1" }) }), _jsx(RouteView, { route: route2, view: () => _jsx("div", { children: "route2" }) }), _jsx(RouteView, { route: route3, view: () => _jsx("div", { children: "route3" }) }), _jsx("div", { children: "not_found1" })] }));
|
|
40
|
-
};
|
|
41
|
-
const screen1 = await act(async () => render(_jsx(App1, {})));
|
|
42
|
-
expect(screen1.getByText('not_found1')).toBeDefined();
|
|
43
|
-
});
|
|
44
|
-
it('Should render active element when 1-order route is opened', async () => {
|
|
45
|
-
const history = mockHistory(createBrowserHistory());
|
|
46
|
-
routeConfig.update({
|
|
47
|
-
history,
|
|
48
|
-
});
|
|
49
|
-
beforeEach(() => {
|
|
50
|
-
history.clearMocks();
|
|
51
|
-
});
|
|
52
|
-
const route1 = new Route('/test1');
|
|
53
|
-
const route2 = new Route('/test2');
|
|
54
|
-
const route3 = new Route('/test3');
|
|
55
|
-
const App1 = () => {
|
|
56
|
-
return (_jsxs(Switch, { children: [_jsx(RouteView, { route: route1, view: () => _jsx("div", { children: "route1" }) }), _jsx(RouteView, { route: route2, view: () => _jsx("div", { children: "route2" }) }), _jsx(RouteView, { route: route3, view: () => _jsx("div", { children: "route3" }) }), _jsx("div", { children: "not_found1" })] }));
|
|
57
|
-
};
|
|
58
|
-
await route1.open();
|
|
59
|
-
const screen1 = await act(async () => render(_jsx(App1, {})));
|
|
60
|
-
expect(screen1.getByText('route1')).toBeDefined();
|
|
61
|
-
});
|
|
62
|
-
it('Should render active element when 2-order route is opened', async () => {
|
|
63
|
-
const history = mockHistory(createBrowserHistory());
|
|
64
|
-
routeConfig.update({
|
|
65
|
-
history,
|
|
66
|
-
});
|
|
67
|
-
beforeEach(() => {
|
|
68
|
-
history.clearMocks();
|
|
69
|
-
});
|
|
70
|
-
const route1 = new Route('/test1');
|
|
71
|
-
const route2 = new Route('/test2');
|
|
72
|
-
const route3 = new Route('/test3');
|
|
73
|
-
const App1 = () => {
|
|
74
|
-
return (_jsxs(Switch, { children: [_jsx(RouteView, { route: route1, view: () => _jsx("div", { children: "route1" }) }), _jsx(RouteView, { route: route2, view: () => _jsx("div", { children: "route2" }) }), _jsx(RouteView, { route: route3, view: () => _jsx("div", { children: "route3" }) }), _jsx("div", { children: "not_found1" })] }));
|
|
75
|
-
};
|
|
76
|
-
await route2.open();
|
|
77
|
-
const screen1 = await act(async () => render(_jsx(App1, {})));
|
|
78
|
-
expect(screen1.getByText('route2')).toBeDefined();
|
|
79
|
-
});
|
|
80
|
-
it('Should render active element when 3-order route is opened', async () => {
|
|
81
|
-
const history = mockHistory(createBrowserHistory());
|
|
82
|
-
routeConfig.update({
|
|
83
|
-
history,
|
|
84
|
-
});
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
history.clearMocks();
|
|
87
|
-
});
|
|
88
|
-
const route1 = new Route('/test1');
|
|
89
|
-
const route2 = new Route('/test2');
|
|
90
|
-
const route3 = new Route('/test3');
|
|
91
|
-
const App1 = () => {
|
|
92
|
-
return (_jsxs(Switch, { children: [_jsx(RouteView, { route: route1, view: () => _jsx("div", { children: "route1" }) }), _jsx(RouteView, { route: route2, view: () => _jsx("div", { children: "route2" }) }), _jsx(RouteView, { route: route3, view: () => _jsx("div", { children: "route3" }) }), _jsx("div", { children: "not_found1" })] }));
|
|
93
|
-
};
|
|
94
|
-
await route3.open();
|
|
95
|
-
const screen1 = await act(async () => render(_jsx(App1, {})));
|
|
96
|
-
expect(screen1.getByText('route3')).toBeDefined();
|
|
97
|
-
});
|
|
98
|
-
it('Should render element of LAST OPENED route', async () => {
|
|
99
|
-
const history = mockHistory(createBrowserHistory());
|
|
100
|
-
routeConfig.update({
|
|
101
|
-
history,
|
|
102
|
-
});
|
|
103
|
-
beforeEach(() => {
|
|
104
|
-
history.clearMocks();
|
|
105
|
-
});
|
|
106
|
-
const route1 = new Route('/test');
|
|
107
|
-
const route2 = new Route('/test');
|
|
108
|
-
const route3 = new Route('/test');
|
|
109
|
-
const App1 = () => {
|
|
110
|
-
return (_jsxs(Switch, { children: [_jsx(RouteView, { route: route1, view: () => _jsx("div", { children: "route1" }) }), _jsx(RouteView, { route: route2, view: () => _jsx("div", { children: "route2" }) }), _jsx(RouteView, { route: route3, view: () => _jsx("div", { children: "route3" }) }), _jsx("div", { children: "not_found1" })] }));
|
|
111
|
-
};
|
|
112
|
-
await route3.open();
|
|
113
|
-
const screen1 = await act(async () => render(_jsx(App1, {})));
|
|
114
|
-
expect(screen1.getByText('route3')).toBeDefined();
|
|
115
|
-
expect(() => screen1.getByText('route2')).toThrowError();
|
|
116
|
-
expect(() => screen1.getByText('route1')).toThrowError();
|
|
117
|
-
expect(() => screen1.getByText('not_found1')).toThrowError();
|
|
118
|
-
});
|
|
119
|
-
it('Should render element with wrapper component if it is opened', async () => {
|
|
120
|
-
const history = mockHistory(createBrowserHistory());
|
|
121
|
-
routeConfig.update({
|
|
122
|
-
history,
|
|
123
|
-
});
|
|
124
|
-
beforeEach(() => {
|
|
125
|
-
history.clearMocks();
|
|
126
|
-
});
|
|
127
|
-
const route1 = new Route('/route-1-test');
|
|
128
|
-
const route2 = new Route('/route-2-test');
|
|
129
|
-
const route3 = new Route('/route-3-test');
|
|
130
|
-
const Wrapper = ({ children, text, }) => {
|
|
131
|
-
return (_jsxs("div", { className: "wrapper", children: [_jsx("label", { children: text }), children] }));
|
|
132
|
-
};
|
|
133
|
-
const App1 = () => {
|
|
134
|
-
return (_jsxs(Switch, { children: [_jsx(Wrapper, { text: "wrapper1", children: _jsx(RouteView, { route: route1, view: () => _jsx("div", { children: "route1" }) }) }), _jsx(Wrapper, { text: "wrapper2", children: _jsx(RouteView, { route: route2, view: () => _jsx("div", { children: "route2" }) }) }), _jsx(Wrapper, { text: "wrapper3", children: _jsx(RouteView, { route: route3, view: () => _jsx("div", { children: "route3" }) }) }), _jsx("div", { children: "not_found1" })] }));
|
|
135
|
-
};
|
|
136
|
-
await route2.open();
|
|
137
|
-
const screen1 = await act(async () => render(_jsx(App1, {})));
|
|
138
|
-
expect(screen1.getByText('route2')).toBeDefined();
|
|
139
|
-
expect(screen1.getByText('wrapper2')).toBeDefined();
|
|
140
|
-
expect(() => screen1.getByText('route1')).toThrowError();
|
|
141
|
-
expect(() => screen1.getByText('wrapper1')).toThrowError();
|
|
142
|
-
expect(() => screen1.getByText('route3')).toThrowError();
|
|
143
|
-
expect(() => screen1.getByText('wrapper3')).toThrowError();
|
|
144
|
-
expect(() => screen1.getByText('not_found1')).toThrowError();
|
|
145
|
-
});
|
|
146
|
-
});
|