@symbo.ls/router 2.12.60 → 2.12.61
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 +24 -18
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -3,8 +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
|
-
|
|
7
|
-
const { location } = window
|
|
6
|
+
import { deepMerge } from '@domql/utils'
|
|
8
7
|
|
|
9
8
|
export const getActiveRoute = (level = 0, route = window.location.pathname) => {
|
|
10
9
|
const routeArray = route.split('/')
|
|
@@ -31,6 +30,12 @@ const defaultOptions = {
|
|
|
31
30
|
useFragment: false,
|
|
32
31
|
authCheck: true,
|
|
33
32
|
updateState: true,
|
|
33
|
+
updateStateOptions: {
|
|
34
|
+
preventUpdateTriggerStateUpdate: true,
|
|
35
|
+
preventContentUpdate: true,
|
|
36
|
+
preventUpdate: ['Modal', 'MainHeaderCaptions', 'HeaderSubAside']
|
|
37
|
+
},
|
|
38
|
+
setOptions: {},
|
|
34
39
|
scrollToOffset: 120,
|
|
35
40
|
scrollToOptions: { behavior: 'smooth' }
|
|
36
41
|
}
|
|
@@ -41,7 +46,7 @@ export const router = (
|
|
|
41
46
|
state = {},
|
|
42
47
|
passedOptions = {}
|
|
43
48
|
) => {
|
|
44
|
-
const options =
|
|
49
|
+
const options = deepMerge(passedOptions, defaultOptions)
|
|
45
50
|
lastLevel = options.level
|
|
46
51
|
|
|
47
52
|
const [pathname, hash] = path.split('#')
|
|
@@ -59,11 +64,11 @@ export const router = (
|
|
|
59
64
|
const route = routeArray.join('/').replace('//', '/')
|
|
60
65
|
const routeInContent = `/${routeArray[lastLevel + 1] || ''}`
|
|
61
66
|
|
|
62
|
-
const isPreview = location.pathname.includes('/
|
|
67
|
+
// const isPreview = location.pathname.includes('/editor')
|
|
63
68
|
|
|
64
69
|
const content = element.routes[routeInContent] || element.routes['/*']
|
|
65
70
|
|
|
66
|
-
const wasModal = isModalRoute(location.pathname.split('#')[0], element)
|
|
71
|
+
const wasModal = isModalRoute(window.location.pathname.split('#')[0], element)
|
|
67
72
|
const isInitial = options.initialRender
|
|
68
73
|
const hashChanged = hash && hash !== window.location.hash.slice(1)
|
|
69
74
|
const pathChanged = pathname !== lastPathname
|
|
@@ -84,27 +89,28 @@ export const router = (
|
|
|
84
89
|
// || (!rootRouteHasChanged && { preventUpdateTriggerStateUpdate: true, preventContentUpdate: true })
|
|
85
90
|
|
|
86
91
|
if (options.updateState) {
|
|
87
|
-
element.state.update({
|
|
88
|
-
route, hash, routeInContent
|
|
89
|
-
}, {
|
|
90
|
-
preventUpdateTriggerStateUpdate: true,
|
|
91
|
-
preventContentUpdate: true,
|
|
92
|
-
preventUpdate: ['Modal', 'MainHeaderCaptions', 'HeaderSubAside']
|
|
93
|
-
})
|
|
92
|
+
element.state.update({ route, hash, routeInContent }, options.updateStateOptions)
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
if (!isModal && element.Modal) {
|
|
97
96
|
element.Modal.removeContent()
|
|
97
|
+
} else if (isModal && element.content?.Tabs) {
|
|
98
|
+
element.content.Tabs.update()
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
if (hasSet) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (options.forceContentUpdate || (!isInitial && wasModal)) {
|
|
103
|
+
element.content.update()
|
|
104
|
+
} else {
|
|
105
|
+
element.set({
|
|
106
|
+
tag: options.useFragment && 'fragment',
|
|
107
|
+
extend: content
|
|
108
|
+
}, {
|
|
105
109
|
// ...(!isInitial && wasModal && !options.forceContentUpdate && { preventContentUpdate: true }),
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
preventUpdate: ['MainHeaderCaptions', 'HeaderSubAside'],
|
|
111
|
+
...options.setOptions
|
|
112
|
+
})
|
|
113
|
+
}
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/router",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.61",
|
|
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": "5d82942254ae88d047def5720cfc95b165cd3031",
|
|
15
15
|
"source": "index.js"
|
|
16
16
|
}
|