@symbo.ls/router 2.12.64 → 2.12.66
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/index.js +18 -17
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { setCookie } from '@domql/cookie'
|
|
4
4
|
import { redirectBasedOnAuth } from '@symbo.ls/auth-redirect'
|
|
5
5
|
import { isModalRoute } from '@symbo.ls/platform-utils'
|
|
6
|
-
import {
|
|
6
|
+
import { merge } from '@domql/utils'
|
|
7
7
|
|
|
8
8
|
export const getLocationPath = (index = 0, route = window.location.pathname) => {
|
|
9
9
|
const routeArray = route.split('/')
|
|
@@ -11,9 +11,9 @@ export const getLocationPath = (index = 0, route = window.location.pathname) =>
|
|
|
11
11
|
if (activeRoute) return `/${activeRoute}`
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const getLastLocationPath = (route = window.location.pathname) => {
|
|
14
|
+
export const getLastLocationPath = (level = 0, route = window.location.pathname) => {
|
|
15
15
|
const routeArray = route.split('/')
|
|
16
|
-
const activeRoute = routeArray[routeArray.length - 1]
|
|
16
|
+
const activeRoute = routeArray[routeArray.length - level - 1]
|
|
17
17
|
if (activeRoute) return `/${activeRoute}`
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -21,6 +21,7 @@ export let lastPathname
|
|
|
21
21
|
export let lastLevel = 0
|
|
22
22
|
|
|
23
23
|
const defaultOptions = {
|
|
24
|
+
window,
|
|
24
25
|
level: lastLevel,
|
|
25
26
|
initialRender: false,
|
|
26
27
|
pushState: true,
|
|
@@ -32,8 +33,8 @@ const defaultOptions = {
|
|
|
32
33
|
updateState: true,
|
|
33
34
|
updateStateOptions: {
|
|
34
35
|
preventUpdateTriggerStateUpdate: true,
|
|
35
|
-
preventContentUpdate: true,
|
|
36
|
-
preventUpdate: ['
|
|
36
|
+
// preventContentUpdate: true,
|
|
37
|
+
preventUpdate: ['MainHeaderCaptions', 'HeaderSubAside']
|
|
37
38
|
},
|
|
38
39
|
preventUpdate: ['MainHeaderCaptions', 'HeaderSubAside'],
|
|
39
40
|
setOptions: {},
|
|
@@ -47,7 +48,7 @@ export const router = (
|
|
|
47
48
|
state = {},
|
|
48
49
|
passedOptions = {}
|
|
49
50
|
) => {
|
|
50
|
-
const options =
|
|
51
|
+
const options = merge(passedOptions, defaultOptions)
|
|
51
52
|
lastLevel = options.level
|
|
52
53
|
|
|
53
54
|
const [pathname, hash] = path.split('#')
|
|
@@ -69,23 +70,22 @@ export const router = (
|
|
|
69
70
|
|
|
70
71
|
const content = element.routes[routeInContent] || element.routes['/*']
|
|
71
72
|
|
|
72
|
-
const wasModal = isModalRoute(window.location.pathname.split('#')[0], element)
|
|
73
|
+
const wasModal = isModalRoute(options.window.location.pathname.split('#')[0], element)
|
|
73
74
|
const isInitial = options.initialRender
|
|
74
|
-
const hashChanged = hash && hash !== window.location.hash.slice(1)
|
|
75
|
+
const hashChanged = hash && hash !== options.window.location.hash.slice(1)
|
|
75
76
|
const pathChanged = pathname !== lastPathname
|
|
76
77
|
lastPathname = pathname
|
|
77
78
|
|
|
78
79
|
if (!content) return
|
|
79
80
|
if (options.pushState) {
|
|
80
|
-
window.history.pushState({
|
|
81
|
-
prevUrl: window.location.href, ...state
|
|
81
|
+
options.window.history.pushState({
|
|
82
|
+
prevUrl: options.window.location.href, ...state
|
|
82
83
|
}, null, route + (hash ? `#${hash}` : ''))
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
const isModal = isModalRoute(pathname, element)
|
|
86
87
|
|
|
87
88
|
if (pathChanged || !hashChanged) {
|
|
88
|
-
const hasSet = isInitial || (!isInitial && !isModal)
|
|
89
89
|
// const rootRouteHasChanged = rootRoute !== element.state.rootRoute
|
|
90
90
|
// || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
|
|
91
91
|
|
|
@@ -96,12 +96,7 @@ export const router = (
|
|
|
96
96
|
})
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
element.Modal.removeContent()
|
|
101
|
-
} else if (isModal && element.content?.Tabs) {
|
|
102
|
-
element.content.Tabs.update()
|
|
103
|
-
}
|
|
104
|
-
|
|
99
|
+
const hasSet = isInitial || (!isInitial && !isModal)
|
|
105
100
|
if (hasSet) {
|
|
106
101
|
if (options.forceContentUpdate || (!isInitial && wasModal)) {
|
|
107
102
|
element.content.update()
|
|
@@ -116,6 +111,12 @@ export const router = (
|
|
|
116
111
|
})
|
|
117
112
|
}
|
|
118
113
|
}
|
|
114
|
+
|
|
115
|
+
if (!isModal && element.Modal?.content) {
|
|
116
|
+
element.Modal.removeContent()
|
|
117
|
+
} else if (isModal && element.content?.Tabs) {
|
|
118
|
+
element.content.Tabs.update()
|
|
119
|
+
}
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
const rootNode = element.node
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/router",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.66",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"@domql/utils": "latest",
|
|
12
12
|
"@symbo.ls/auth-redirect": "latest"
|
|
13
13
|
},
|
|
14
|
-
"gitHead": "
|
|
14
|
+
"gitHead": "7df1ed1d116dbd34daebaf7dbcb54ae7fa92d487",
|
|
15
15
|
"source": "index.js"
|
|
16
16
|
}
|