@tinkoff/router 0.2.18 → 0.3.0
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/lib/history/client.browser.js +16 -1
- package/lib/history/client.es.js +16 -1
- package/lib/history/client.js +16 -1
- package/package.json +3 -3
|
@@ -10,16 +10,31 @@ const generateKey = (navigation) => {
|
|
|
10
10
|
return `${to.name}_${to.path}`;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
const generatePreviousNavigateState = (navigation) => {
|
|
14
|
+
const state = {};
|
|
15
|
+
if (navigation.from) {
|
|
16
|
+
state.previousRoute = navigation.from;
|
|
17
|
+
}
|
|
18
|
+
if (navigation.fromUrl) {
|
|
19
|
+
state.previousUrl = navigation.fromUrl;
|
|
20
|
+
}
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
13
23
|
const generateState = (navigation, currentState) => {
|
|
14
24
|
const key = generateKey(navigation);
|
|
25
|
+
const previousNavigateState = generatePreviousNavigateState(navigation);
|
|
15
26
|
let { type } = navigation;
|
|
16
27
|
if (navigation.replace && currentState) {
|
|
17
28
|
type = currentState.type === type ? type : 'navigate';
|
|
18
29
|
}
|
|
30
|
+
const navigateState = {
|
|
31
|
+
...previousNavigateState,
|
|
32
|
+
...navigation.navigateState,
|
|
33
|
+
};
|
|
19
34
|
return {
|
|
20
35
|
key,
|
|
21
36
|
type,
|
|
22
|
-
navigateState
|
|
37
|
+
navigateState,
|
|
23
38
|
};
|
|
24
39
|
};
|
|
25
40
|
class ClientHistory extends History {
|
package/lib/history/client.es.js
CHANGED
|
@@ -10,16 +10,31 @@ const generateKey = (navigation) => {
|
|
|
10
10
|
return `${to.name}_${to.path}`;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
+
const generatePreviousNavigateState = (navigation) => {
|
|
14
|
+
const state = {};
|
|
15
|
+
if (navigation.from) {
|
|
16
|
+
state.previousRoute = navigation.from;
|
|
17
|
+
}
|
|
18
|
+
if (navigation.fromUrl) {
|
|
19
|
+
state.previousUrl = navigation.fromUrl;
|
|
20
|
+
}
|
|
21
|
+
return state;
|
|
22
|
+
};
|
|
13
23
|
const generateState = (navigation, currentState) => {
|
|
14
24
|
const key = generateKey(navigation);
|
|
25
|
+
const previousNavigateState = generatePreviousNavigateState(navigation);
|
|
15
26
|
let { type } = navigation;
|
|
16
27
|
if (navigation.replace && currentState) {
|
|
17
28
|
type = currentState.type === type ? type : 'navigate';
|
|
18
29
|
}
|
|
30
|
+
const navigateState = {
|
|
31
|
+
...previousNavigateState,
|
|
32
|
+
...navigation.navigateState,
|
|
33
|
+
};
|
|
19
34
|
return {
|
|
20
35
|
key,
|
|
21
36
|
type,
|
|
22
|
-
navigateState
|
|
37
|
+
navigateState,
|
|
23
38
|
};
|
|
24
39
|
};
|
|
25
40
|
class ClientHistory extends History {
|
package/lib/history/client.js
CHANGED
|
@@ -14,16 +14,31 @@ const generateKey = (navigation) => {
|
|
|
14
14
|
return `${to.name}_${to.path}`;
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
+
const generatePreviousNavigateState = (navigation) => {
|
|
18
|
+
const state = {};
|
|
19
|
+
if (navigation.from) {
|
|
20
|
+
state.previousRoute = navigation.from;
|
|
21
|
+
}
|
|
22
|
+
if (navigation.fromUrl) {
|
|
23
|
+
state.previousUrl = navigation.fromUrl;
|
|
24
|
+
}
|
|
25
|
+
return state;
|
|
26
|
+
};
|
|
17
27
|
const generateState = (navigation, currentState) => {
|
|
18
28
|
const key = generateKey(navigation);
|
|
29
|
+
const previousNavigateState = generatePreviousNavigateState(navigation);
|
|
19
30
|
let { type } = navigation;
|
|
20
31
|
if (navigation.replace && currentState) {
|
|
21
32
|
type = currentState.type === type ? type : 'navigate';
|
|
22
33
|
}
|
|
34
|
+
const navigateState = {
|
|
35
|
+
...previousNavigateState,
|
|
36
|
+
...navigation.navigateState,
|
|
37
|
+
};
|
|
23
38
|
return {
|
|
24
39
|
key,
|
|
25
40
|
type,
|
|
26
|
-
navigateState
|
|
41
|
+
navigateState,
|
|
27
42
|
};
|
|
28
43
|
};
|
|
29
44
|
class ClientHistory extends base.History {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkoff/router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "router",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"watch": "tsc -w"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@tinkoff/react-hooks": "0.
|
|
25
|
-
"@tinkoff/url": "0.
|
|
24
|
+
"@tinkoff/react-hooks": "0.2.0",
|
|
25
|
+
"@tinkoff/url": "0.9.0",
|
|
26
26
|
"@tinkoff/utils": "^2.1.2",
|
|
27
27
|
"use-sync-external-store": "^1.2.0"
|
|
28
28
|
},
|