@exmg/exm-navigation 1.1.6-alpha.9 → 1.1.8
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.
|
@@ -43,6 +43,11 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
43
43
|
*/
|
|
44
44
|
navigationHasSubmenu: Record<string, boolean>;
|
|
45
45
|
static styles: import("lit").CSSResult[];
|
|
46
|
+
constructor();
|
|
47
|
+
/**
|
|
48
|
+
* Get the menu items and the current path and set the correct startPath for the navigation
|
|
49
|
+
*/
|
|
50
|
+
private setPath;
|
|
46
51
|
protected updated(changedProperties: PropertyValues): void;
|
|
47
52
|
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
48
53
|
connectedCallback(): void;
|
|
@@ -17,10 +17,10 @@ import './exm-navigation-drawer.js';
|
|
|
17
17
|
// eslint-disable-next-line new-cap
|
|
18
18
|
export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
19
19
|
constructor() {
|
|
20
|
-
super(
|
|
20
|
+
super();
|
|
21
21
|
this.items = [];
|
|
22
22
|
this.path = ['chat'];
|
|
23
|
-
this.drawerWidth =
|
|
23
|
+
this.drawerWidth = 275;
|
|
24
24
|
this.disableNavigate = false;
|
|
25
25
|
/**
|
|
26
26
|
* The menu item triggered by hovering and entering submenu's
|
|
@@ -43,6 +43,55 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
43
43
|
* Object with menuitem and a bool for having that path sub items yes or no
|
|
44
44
|
*/
|
|
45
45
|
this.navigationHasSubmenu = {};
|
|
46
|
+
/**
|
|
47
|
+
* Listen to popState changes. When the event has a state, the browser navigation buttons have been used and we have to update the path
|
|
48
|
+
*/
|
|
49
|
+
window.addEventListener('popstate', (event) => {
|
|
50
|
+
if (event.state) {
|
|
51
|
+
this.setPath();
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the menu items and the current path and set the correct startPath for the navigation
|
|
57
|
+
*/
|
|
58
|
+
setPath() {
|
|
59
|
+
let path = [];
|
|
60
|
+
/**
|
|
61
|
+
* Set to true if we found the path. This is needed because for breaking out of a recursive function
|
|
62
|
+
*/
|
|
63
|
+
let finished = false;
|
|
64
|
+
/**
|
|
65
|
+
* Loop through the items with a give depth. For every depth level the id of the route is set to that index
|
|
66
|
+
* If there is a matching path, we set finished to true, so all levels wil break out of their for-loop
|
|
67
|
+
* Every call done with depth 0 will reset the path, so no artifacts of the previous route will remain
|
|
68
|
+
*
|
|
69
|
+
* @param items The items to loop through
|
|
70
|
+
* @param depth The navigation depth
|
|
71
|
+
*/
|
|
72
|
+
function checkItems(items, depth = 0) {
|
|
73
|
+
for (const item of items) {
|
|
74
|
+
if (finished) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (depth === 0) {
|
|
78
|
+
path = [];
|
|
79
|
+
}
|
|
80
|
+
path[depth] = item.id;
|
|
81
|
+
if (item.path === window.location.pathname) {
|
|
82
|
+
finished = true;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
if ((item.items || []).length > 0) {
|
|
86
|
+
checkItems(item.items, depth + 1);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
checkItems(this.items);
|
|
91
|
+
this.path = path;
|
|
92
|
+
this.selectedItem = path;
|
|
93
|
+
this.activeItem = path;
|
|
94
|
+
this.handleDrawerOpen();
|
|
46
95
|
}
|
|
47
96
|
updated(changedProperties) {
|
|
48
97
|
if (changedProperties.has('media')) {
|
|
@@ -61,6 +110,10 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
61
110
|
if (changedProperties.has('media')) {
|
|
62
111
|
this.handleMediaTypeChange.bind(this)();
|
|
63
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Set the start path
|
|
115
|
+
*/
|
|
116
|
+
this.setPath();
|
|
64
117
|
}
|
|
65
118
|
connectedCallback() {
|
|
66
119
|
super.connectedCallback();
|
|
@@ -7,8 +7,8 @@ export const MediaQueries = (superClass) => {
|
|
|
7
7
|
this.media = 'desktop';
|
|
8
8
|
this.touch = false;
|
|
9
9
|
this.mobileMedia = window.matchMedia('(max-width: 960px)');
|
|
10
|
-
this.tabletMedia = window.matchMedia('(min-width: 961px) and (max-width:
|
|
11
|
-
this.desktopMedia = window.matchMedia('(min-width:
|
|
10
|
+
this.tabletMedia = window.matchMedia('(min-width: 961px) and (max-width: 1600px)');
|
|
11
|
+
this.desktopMedia = window.matchMedia('(min-width: 1601px)');
|
|
12
12
|
this.hoverMedia = window.matchMedia('(hover: hover)');
|
|
13
13
|
}
|
|
14
14
|
updateMedia(media) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exmg/exm-navigation",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"module": "dist/index.js",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": "./dist/index.js",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"publishConfig": {
|
|
50
51
|
"access": "public"
|
|
51
52
|
},
|
|
52
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "e9c6e6e7b81658423344b640be549700e95be7c0"
|
|
53
54
|
}
|