@exmg/exm-navigation 1.1.3 → 1.1.4-alpha.2
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/{src → dist}/exm-navigation-base.d.ts +34 -10
- package/{src → dist}/exm-navigation-base.js +131 -87
- package/{src → dist}/exm-navigation-drawer-base.d.ts +1 -4
- package/{src → dist}/exm-navigation-drawer-base.js +9 -8
- package/{src → dist}/exm-navigation-drawer-nav-item-base.js +12 -8
- package/{src → dist}/exm-navigation-icon-button-base.js +2 -0
- package/{src → dist}/exm-navigation-sub-menu-base.d.ts +10 -0
- package/{src → dist}/exm-navigation-sub-menu-base.js +71 -12
- package/{src → dist}/exm-navigation-topbar-base.js +3 -4
- package/dist/index.d.ts +12 -0
- package/dist/index.js +13 -0
- package/{src → dist}/mixins/media-queries.d.ts +1 -0
- package/{src → dist}/mixins/media-queries.js +14 -1
- package/{src → dist}/styles/exm-navigation-css.js +8 -2
- package/dist/styles/exm-navigation-drawer-css.js +35 -0
- package/dist/styles/exm-navigation-drawer-nav-item-css.js +84 -0
- package/{src → dist}/styles/exm-navigation-icon-button-css.js +6 -2
- package/{src → dist}/styles/exm-navigation-rail-css.js +1 -0
- package/dist/styles/exm-navigation-sub-menu-css.js +21 -0
- package/{src → dist}/styles/exm-navigation-topbar-css.js +1 -1
- package/package.json +20 -21
- package/index.d.ts +0 -12
- package/index.js +0 -13
- package/src/exm-navigation-drawer-nav.d.ts +0 -9
- package/src/exm-navigation-drawer-nav.js +0 -47
- package/src/exm-navigation-rail-nav-base.d.ts +0 -4
- package/src/exm-navigation-rail-nav-base.js +0 -9
- package/src/exm-navigation-rail-nav.d.ts +0 -9
- package/src/exm-navigation-rail-nav.js +0 -12
- package/src/exm-navigation-signals.d.ts +0 -11
- package/src/exm-navigation-signals.js +0 -11
- package/src/exm-navigation-toolbar-base.d.ts +0 -8
- package/src/exm-navigation-toolbar-base.js +0 -33
- package/src/exm-navigation-toolbar.d.ts +0 -9
- package/src/exm-navigation-toolbar.js +0 -12
- package/src/styles/exm-navigate-drawer-nav-item-css.d.ts +0 -1
- package/src/styles/exm-navigate-drawer-nav-item-css.js +0 -40
- package/src/styles/exm-navigation-drawer-css.js +0 -24
- package/src/styles/exm-navigation-drawer-nav-item-css.js +0 -40
- package/src/styles/exm-navigation-rail-nav-css.d.ts +0 -2
- package/src/styles/exm-navigation-rail-nav-css.js +0 -4
- package/src/styles/exm-navigation-styles-css.d.ts +0 -2
- package/src/styles/exm-navigation-styles-css.js +0 -4
- package/src/styles/exm-navigation-sub-menu-css.js +0 -46
- package/src/styles/exm-navigation-toolbar-css.d.ts +0 -2
- package/src/styles/exm-navigation-toolbar-css.js +0 -4
- /package/{src → dist}/exm-navigation-drawer-menu-base.d.ts +0 -0
- /package/{src → dist}/exm-navigation-drawer-menu-base.js +0 -0
- /package/{src → dist}/exm-navigation-drawer-menu.d.ts +0 -0
- /package/{src → dist}/exm-navigation-drawer-menu.js +0 -0
- /package/{src → dist}/exm-navigation-drawer-nav-item-base.d.ts +0 -0
- /package/{src → dist}/exm-navigation-drawer-nav-item.d.ts +0 -0
- /package/{src → dist}/exm-navigation-drawer-nav-item.js +0 -0
- /package/{src → dist}/exm-navigation-drawer.d.ts +0 -0
- /package/{src → dist}/exm-navigation-drawer.js +0 -0
- /package/{src → dist}/exm-navigation-icon-base.d.ts +0 -0
- /package/{src → dist}/exm-navigation-icon-base.js +0 -0
- /package/{src → dist}/exm-navigation-icon-button-base.d.ts +0 -0
- /package/{src → dist}/exm-navigation-icon-button.d.ts +0 -0
- /package/{src → dist}/exm-navigation-icon-button.js +0 -0
- /package/{src → dist}/exm-navigation-icon.d.ts +0 -0
- /package/{src → dist}/exm-navigation-icon.js +0 -0
- /package/{src → dist}/exm-navigation-rail-base.d.ts +0 -0
- /package/{src → dist}/exm-navigation-rail-base.js +0 -0
- /package/{src → dist}/exm-navigation-rail-nav-item-base.d.ts +0 -0
- /package/{src → dist}/exm-navigation-rail-nav-item-base.js +0 -0
- /package/{src → dist}/exm-navigation-rail-nav-item.d.ts +0 -0
- /package/{src → dist}/exm-navigation-rail-nav-item.js +0 -0
- /package/{src → dist}/exm-navigation-rail.d.ts +0 -0
- /package/{src → dist}/exm-navigation-rail.js +0 -0
- /package/{src → dist}/exm-navigation-sub-menu.d.ts +0 -0
- /package/{src → dist}/exm-navigation-sub-menu.js +0 -0
- /package/{src → dist}/exm-navigation-topbar-base.d.ts +0 -0
- /package/{src → dist}/exm-navigation-topbar.d.ts +0 -0
- /package/{src → dist}/exm-navigation-topbar.js +0 -0
- /package/{src → dist}/exm-navigation.d.ts +0 -0
- /package/{src → dist}/exm-navigation.js +0 -0
- /package/{src → dist}/styles/exm-navigation-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-drawer-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-drawer-nav-item-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-icon-button-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-icon-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-icon-css.js +0 -0
- /package/{src → dist}/styles/exm-navigation-rail-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-rail-nav-item-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-rail-nav-item-css.js +0 -0
- /package/{src → dist}/styles/exm-navigation-sub-menu-css.d.ts +0 -0
- /package/{src → dist}/styles/exm-navigation-topbar-css.d.ts +0 -0
- /package/{src → dist}/types.d.ts +0 -0
- /package/{src → dist}/types.js +0 -0
|
@@ -2,6 +2,8 @@ import { PropertyValues } from 'lit';
|
|
|
2
2
|
import { ExmgElement } from '@exmg/lit-base/index.js';
|
|
3
3
|
import { MenuItem } from './types.js';
|
|
4
4
|
import { ExmNavigationDrawer } from './exm-navigation-drawer.js';
|
|
5
|
+
import '@material/web/icon/icon.js';
|
|
6
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
5
7
|
import './exm-navigation-icon-button.js';
|
|
6
8
|
import './exm-navigation-topbar.js';
|
|
7
9
|
import './exm-navigation-rail.js';
|
|
@@ -10,6 +12,7 @@ import './exm-navigation-drawer-menu.js';
|
|
|
10
12
|
import './exm-navigation-drawer.js';
|
|
11
13
|
declare const ExmNavigationBase_base: (new (...args: any[]) => {
|
|
12
14
|
media: "mobile" | "tablet" | "desktop";
|
|
15
|
+
touch: boolean;
|
|
13
16
|
}) & typeof ExmgElement;
|
|
14
17
|
export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
15
18
|
items: MenuItem[];
|
|
@@ -18,32 +21,46 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
18
21
|
disableNavigate: boolean;
|
|
19
22
|
drawer?: ExmNavigationDrawer;
|
|
20
23
|
navContent?: HTMLDivElement;
|
|
21
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The menu item triggered by hovering and entering submenu's
|
|
26
|
+
* Once an item with endpoint is clicked, this value should be written to activeItem
|
|
27
|
+
*/
|
|
22
28
|
selectedItem: string[];
|
|
29
|
+
/**
|
|
30
|
+
* The currently active menu item
|
|
31
|
+
*/
|
|
23
32
|
activeItem: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Wether or not the rail should be visible yes or no
|
|
35
|
+
*/
|
|
24
36
|
railOpen: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Wether or not the drawer should be visible yes or no
|
|
39
|
+
*/
|
|
25
40
|
drawerOpen: boolean;
|
|
26
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Object with menuitem and a bool for having that path sub items yes or no
|
|
43
|
+
*/
|
|
27
44
|
navigationHasSubmenu: Record<string, boolean>;
|
|
28
45
|
static styles: import("lit").CSSResult[];
|
|
29
|
-
menu: MenuItem[];
|
|
30
|
-
expandedItems: {
|
|
31
|
-
[k: string]: boolean;
|
|
32
|
-
};
|
|
33
|
-
unSubscribeSelected: () => void;
|
|
34
46
|
protected updated(changedProperties: PropertyValues): void;
|
|
35
47
|
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
36
48
|
connectedCallback(): void;
|
|
37
49
|
/**
|
|
38
50
|
* Set the correct values when the media changes.
|
|
39
51
|
*/
|
|
40
|
-
handleMediaTypeChange
|
|
52
|
+
private handleMediaTypeChange;
|
|
41
53
|
private getPathEndpoint;
|
|
42
|
-
loadPage
|
|
54
|
+
private loadPage;
|
|
55
|
+
/**
|
|
56
|
+
* Handles the drawer state. If it should be open yes or no.
|
|
57
|
+
* @param param0
|
|
58
|
+
*/
|
|
59
|
+
handleDrawerOpen({ mobileForce, tabletForce }?: Record<string, boolean>): void;
|
|
43
60
|
/**
|
|
44
61
|
* Handle Rail item click or Drawer sub menu click.
|
|
45
62
|
* If the selected menu item has children, we add the first item to the list (as per Google implementation).
|
|
46
|
-
* In this case we also do not close the drawer in non
|
|
63
|
+
* In this case we also do not close the drawer in non desktop mode, so the user is able to select a next level in the menu
|
|
47
64
|
*/
|
|
48
65
|
private handleRailItemClick;
|
|
49
66
|
/**
|
|
@@ -102,6 +119,13 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
102
119
|
* Render the topbar. This is displayed on mobile and contains the menu button and a slot for the title
|
|
103
120
|
*/
|
|
104
121
|
private renderTopbar;
|
|
122
|
+
/**
|
|
123
|
+
* If there is an active item, and that item has children, the width of the drawer should be set for desktop.
|
|
124
|
+
* This will push the content to the right.
|
|
125
|
+
*
|
|
126
|
+
* @returns the width of the drawer area
|
|
127
|
+
*/
|
|
128
|
+
private getDrawerWidth;
|
|
105
129
|
render(): import("lit-html").TemplateResult<1>;
|
|
106
130
|
}
|
|
107
131
|
export {};
|
|
@@ -6,6 +6,8 @@ import { styleMap } from 'lit/directives/style-map.js';
|
|
|
6
6
|
import { MediaQueries } from './mixins/media-queries.js';
|
|
7
7
|
import { classMap } from 'lit/directives/class-map.js';
|
|
8
8
|
import { style } from './styles/exm-navigation-css.js';
|
|
9
|
+
import '@material/web/icon/icon.js';
|
|
10
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
9
11
|
import './exm-navigation-icon-button.js';
|
|
10
12
|
import './exm-navigation-topbar.js';
|
|
11
13
|
import './exm-navigation-rail.js';
|
|
@@ -20,16 +22,27 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
20
22
|
this.path = ['chat'];
|
|
21
23
|
this.drawerWidth = 319;
|
|
22
24
|
this.disableNavigate = false;
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* The menu item triggered by hovering and entering submenu's
|
|
27
|
+
* Once an item with endpoint is clicked, this value should be written to activeItem
|
|
28
|
+
*/
|
|
24
29
|
this.selectedItem = [];
|
|
30
|
+
/**
|
|
31
|
+
* The currently active menu item
|
|
32
|
+
*/
|
|
25
33
|
this.activeItem = [];
|
|
34
|
+
/**
|
|
35
|
+
* Wether or not the rail should be visible yes or no
|
|
36
|
+
*/
|
|
26
37
|
this.railOpen = true;
|
|
38
|
+
/**
|
|
39
|
+
* Wether or not the drawer should be visible yes or no
|
|
40
|
+
*/
|
|
27
41
|
this.drawerOpen = false;
|
|
28
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Object with menuitem and a bool for having that path sub items yes or no
|
|
44
|
+
*/
|
|
29
45
|
this.navigationHasSubmenu = {};
|
|
30
|
-
this.menu = [];
|
|
31
|
-
this.expandedItems = {};
|
|
32
|
-
this.unSubscribeSelected = () => { };
|
|
33
46
|
}
|
|
34
47
|
updated(changedProperties) {
|
|
35
48
|
if (changedProperties.has('media')) {
|
|
@@ -39,7 +52,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
39
52
|
for (const item of this.items) {
|
|
40
53
|
this.navigationHasSubmenu[item.id] = (item.items || []).length > 0;
|
|
41
54
|
}
|
|
42
|
-
if (this.navigationHasSubmenu[this.path[0]] && this.
|
|
55
|
+
if (this.navigationHasSubmenu[this.path[0]] && this.media === 'desktop') {
|
|
43
56
|
this.drawerOpen = true;
|
|
44
57
|
}
|
|
45
58
|
}
|
|
@@ -58,8 +71,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
58
71
|
* Set the correct values when the media changes.
|
|
59
72
|
*/
|
|
60
73
|
handleMediaTypeChange() {
|
|
61
|
-
this.
|
|
62
|
-
this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.selectedItem[0]];
|
|
74
|
+
this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.activeItem[0]];
|
|
63
75
|
this.railOpen = this.media !== 'mobile';
|
|
64
76
|
}
|
|
65
77
|
getPathEndpoint() {
|
|
@@ -68,7 +80,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
68
80
|
const checkItems = (path, last) => {
|
|
69
81
|
const item = items.find((item) => item.id === path);
|
|
70
82
|
if (last) {
|
|
71
|
-
return
|
|
83
|
+
return item === null || item === void 0 ? void 0 : item.path;
|
|
72
84
|
}
|
|
73
85
|
items = (item === null || item === void 0 ? void 0 : item.items) || [];
|
|
74
86
|
return;
|
|
@@ -76,91 +88,94 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
76
88
|
for (let i = 0; i < this.selectedItem.length; i++) {
|
|
77
89
|
result = checkItems(this.selectedItem[i], i === this.selectedItem.length - 1);
|
|
78
90
|
}
|
|
79
|
-
return result
|
|
91
|
+
return result;
|
|
80
92
|
}
|
|
81
93
|
loadPage(path) {
|
|
82
94
|
this.path = path;
|
|
83
|
-
this.
|
|
95
|
+
this.activeItem = path;
|
|
96
|
+
const endPoint = this.getPathEndpoint();
|
|
97
|
+
// If the route does not have a path, skip navigating
|
|
98
|
+
if (!endPoint) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
84
101
|
this.fire('navigation-change', path);
|
|
85
102
|
if (!this.disableNavigate) {
|
|
86
103
|
window.history.pushState({}, '', this.getPathEndpoint());
|
|
87
104
|
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
88
105
|
}
|
|
89
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Handles the drawer state. If it should be open yes or no.
|
|
109
|
+
* @param param0
|
|
110
|
+
*/
|
|
111
|
+
handleDrawerOpen({ mobileForce, tabletForce } = {}) {
|
|
112
|
+
if (this.media === 'mobile' || this.touch) {
|
|
113
|
+
// Only triggerable by button
|
|
114
|
+
if (mobileForce || !this.navigationHasSubmenu[this.activeItem[0]]) {
|
|
115
|
+
this.drawerOpen = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (this.media === 'tablet') {
|
|
119
|
+
if (tabletForce) {
|
|
120
|
+
this.drawerOpen = false;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
this.drawerOpen = this.navigationHasSubmenu[this.selectedItem[0]];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (this.media === 'desktop') {
|
|
127
|
+
if (this.navigationHasSubmenu[this.activeItem[0]]) {
|
|
128
|
+
this.drawerOpen = true;
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this.drawerOpen = this.navigationHasSubmenu[this.selectedItem[0]];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
90
135
|
/**
|
|
91
136
|
* Handle Rail item click or Drawer sub menu click.
|
|
92
137
|
* If the selected menu item has children, we add the first item to the list (as per Google implementation).
|
|
93
|
-
* In this case we also do not close the drawer in non
|
|
138
|
+
* In this case we also do not close the drawer in non desktop mode, so the user is able to select a next level in the menu
|
|
94
139
|
*/
|
|
95
140
|
handleRailItemClick({ detail }) {
|
|
96
141
|
var _a;
|
|
97
|
-
if (this.
|
|
142
|
+
if (this.activeItem[0] !== detail || this.media !== 'desktop') {
|
|
98
143
|
const items = ((_a = this.items.find((item) => item.id === detail)) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
99
|
-
if (items.length) {
|
|
144
|
+
if (items.length && !this.touch) {
|
|
100
145
|
this.selectedItem = [detail, items[0].id];
|
|
101
146
|
}
|
|
102
147
|
else {
|
|
103
148
|
this.selectedItem = [detail];
|
|
104
149
|
}
|
|
105
|
-
// copy the selected item to the active item
|
|
106
|
-
this.activeItem = this.selectedItem;
|
|
107
|
-
/**
|
|
108
|
-
* If persistent menu close the drawer when a item is clicked and does not has children items
|
|
109
|
-
*/
|
|
110
|
-
if (this.persistent) {
|
|
111
|
-
this.drawerOpen = items.length > 0 || this.navigationHasSubmenu[detail];
|
|
112
|
-
}
|
|
113
|
-
else if (items.length === 0) {
|
|
114
|
-
this.drawerOpen = false;
|
|
115
|
-
}
|
|
116
150
|
this.loadPage(this.selectedItem);
|
|
151
|
+
this.handleDrawerOpen();
|
|
117
152
|
}
|
|
118
153
|
}
|
|
119
154
|
/**
|
|
120
155
|
* Handle the mouse enter of the rail item.
|
|
121
156
|
*/
|
|
122
157
|
handleRailItemMouseEnter({ detail }) {
|
|
123
|
-
if (this.
|
|
124
|
-
|
|
125
|
-
if (detail !== this.selectedItem[0]) {
|
|
126
|
-
this.activeItem = [detail];
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else if (this.navigationHasSubmenu[this.selectedItem[0]] && this.persistent) {
|
|
131
|
-
this.activeItem = this.selectedItem;
|
|
132
|
-
this.drawerOpen = true;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.activeItem = this.selectedItem;
|
|
136
|
-
this.drawerOpen = false;
|
|
158
|
+
if (this.touch) {
|
|
159
|
+
return;
|
|
137
160
|
}
|
|
138
|
-
this.
|
|
161
|
+
this.selectedItem = [detail];
|
|
162
|
+
this.handleDrawerOpen();
|
|
139
163
|
}
|
|
140
164
|
/**
|
|
141
165
|
* Handle the mouse leave of the rail item.
|
|
142
166
|
* If the item has no submenu and the current selected item has no submenu, it is safe to close the drawer
|
|
143
167
|
*/
|
|
144
|
-
handleRailItemMouseLeave({
|
|
145
|
-
if (!this.navigationHasSubmenu[detail] && !this.navigationHasSubmenu[this.selectedItem[0]]) {
|
|
146
|
-
this.drawerOpen = false;
|
|
147
|
-
}
|
|
148
|
-
if (!this.persistent && !this.navigationHasSubmenu[detail]) {
|
|
149
|
-
this.drawerOpen = false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
168
|
+
handleRailItemMouseLeave() { }
|
|
152
169
|
/**
|
|
153
170
|
* Handle drawer mouse leave. Should close the drawer
|
|
154
171
|
*/
|
|
155
172
|
handleDrawerMouseLeave() {
|
|
156
|
-
if (!this.navigationHasSubmenu[this.selectedItem[0]] || !this.persistent) {
|
|
157
|
-
this.drawerOpen = false;
|
|
158
|
-
}
|
|
159
173
|
/**
|
|
160
174
|
* On mouse leave the drawer we want to set the active item to the selected item.
|
|
161
175
|
* If not, it will show the active item on every hover and will make navigating in the selected item impossible
|
|
162
176
|
*/
|
|
163
|
-
this.
|
|
177
|
+
this.selectedItem = this.activeItem;
|
|
178
|
+
this.handleDrawerOpen({ tabletForce: true });
|
|
164
179
|
}
|
|
165
180
|
/**
|
|
166
181
|
* Handle the click on a sub menu item
|
|
@@ -169,11 +184,13 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
169
184
|
*/
|
|
170
185
|
handleSubMenuClick({ detail }) {
|
|
171
186
|
this.selectedItem = detail;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
187
|
+
const endPoint = this.getPathEndpoint();
|
|
188
|
+
let mobileForce = false;
|
|
189
|
+
if (endPoint) {
|
|
190
|
+
this.loadPage(this.selectedItem);
|
|
191
|
+
mobileForce = true;
|
|
175
192
|
}
|
|
176
|
-
this.
|
|
193
|
+
this.handleDrawerOpen({ mobileForce, tabletForce: this.touch && !!endPoint });
|
|
177
194
|
}
|
|
178
195
|
/**
|
|
179
196
|
* Handle the topbar menu click.
|
|
@@ -187,7 +204,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
187
204
|
* This should reset the active item, so the root-level menu gets triggered
|
|
188
205
|
*/
|
|
189
206
|
handleDrawerBackClick() {
|
|
190
|
-
this.
|
|
207
|
+
this.selectedItem = [];
|
|
191
208
|
}
|
|
192
209
|
/**
|
|
193
210
|
* Check if the passed paths last item has children yes or no
|
|
@@ -209,10 +226,9 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
209
226
|
return !this.railOpen
|
|
210
227
|
? html `
|
|
211
228
|
<section class="drawer-menu-button">
|
|
212
|
-
<
|
|
213
|
-
icon
|
|
214
|
-
|
|
215
|
-
></exm-navigation-icon-button>
|
|
229
|
+
<md-icon-button @click=${this.handleTopbarMenuClick}>
|
|
230
|
+
<md-icon>${this.drawerOpen ? 'menu_open' : 'menu'}</md-icon>
|
|
231
|
+
</md-icon-button>
|
|
216
232
|
</section>
|
|
217
233
|
`
|
|
218
234
|
: nothing;
|
|
@@ -222,37 +238,60 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
222
238
|
* If more levels deep, show the back button
|
|
223
239
|
*/
|
|
224
240
|
renderStartMenu() {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
241
|
+
if (this.railOpen) {
|
|
242
|
+
return nothing;
|
|
243
|
+
}
|
|
244
|
+
return this.selectedItem.length === 0 ||
|
|
245
|
+
(this.selectedItem.length === 1 && !this.currentSelectedHasChildren(this.selectedItem))
|
|
228
246
|
? html `<exm-navigation-drawer-menu
|
|
229
247
|
.items=${this.items}
|
|
230
248
|
.path=${this.activeItem}
|
|
231
249
|
@drawer-menu-item-click=${this.handleRailItemClick}
|
|
232
250
|
></exm-navigation-drawer-menu>`
|
|
233
|
-
:
|
|
234
|
-
|
|
235
|
-
<
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
`
|
|
243
|
-
: nothing;
|
|
251
|
+
: html `
|
|
252
|
+
<section class="drawer-back-button">
|
|
253
|
+
<exm-navigation-icon-button
|
|
254
|
+
icon="arrow_back"
|
|
255
|
+
label="Main menu"
|
|
256
|
+
@navigation-icon-button-click=${this.handleDrawerBackClick}
|
|
257
|
+
></exm-navigation-icon-button>
|
|
258
|
+
</section>
|
|
259
|
+
`;
|
|
244
260
|
}
|
|
245
261
|
/**
|
|
246
262
|
* return the sub menus. More then 1 level deep
|
|
247
263
|
*/
|
|
248
264
|
renderDrawerSubMenu() {
|
|
265
|
+
/**
|
|
266
|
+
* When the selected item is empty we do not display the submenu on mobile
|
|
267
|
+
*/
|
|
268
|
+
if (this.selectedItem.length === 0 && this.media === 'mobile') {
|
|
269
|
+
return nothing;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Do we have all items of the selectedItem available in the active Item
|
|
273
|
+
*/
|
|
274
|
+
const selectedInActive = this.selectedItem.reduce((_, item, index) => {
|
|
275
|
+
if (item === this.activeItem[index]) {
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
return false;
|
|
279
|
+
}, false);
|
|
280
|
+
/**
|
|
281
|
+
* Determine the data to use for the submenu. This is needed to show the correct selected items in the submenu of the drawer
|
|
282
|
+
* If all selected Items ar in the active item, show the active item
|
|
283
|
+
* If the selected item haas no children, but the drawer is open, show the active item
|
|
284
|
+
* In all the other cases we use the selected item
|
|
285
|
+
*/
|
|
286
|
+
const selected = selectedInActive || (!this.navigationHasSubmenu[this.selectedItem[0]] && this.drawerOpen)
|
|
287
|
+
? this.activeItem
|
|
288
|
+
: this.selectedItem;
|
|
249
289
|
return html `
|
|
250
290
|
<exm-navigation-sub-menu
|
|
251
291
|
.items=${this.items}
|
|
252
|
-
.path=${
|
|
292
|
+
.path=${selected}
|
|
253
293
|
?has-back-button=${!this.railOpen &&
|
|
254
|
-
(
|
|
255
|
-
(this.activeItem.length > 0 && this.currentSelectedHasChildren(this.activeItem)))}
|
|
294
|
+
(selected.length > 1 || (selected.length > 0 && this.currentSelectedHasChildren(selected)))}
|
|
256
295
|
@sub-menu-item-click=${this.handleSubMenuClick}
|
|
257
296
|
></exm-navigation-sub-menu>
|
|
258
297
|
`;
|
|
@@ -263,7 +302,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
263
302
|
renderRail() {
|
|
264
303
|
return html `<exm-navigation-rail
|
|
265
304
|
.items=${this.items}
|
|
266
|
-
.selected=${this.
|
|
305
|
+
.selected=${this.activeItem}
|
|
267
306
|
@rail-item-click=${this.handleRailItemClick}
|
|
268
307
|
@rail-item-mouseenter=${this.handleRailItemMouseEnter}
|
|
269
308
|
@rail-item-mouseleave=${this.handleRailItemMouseLeave}
|
|
@@ -281,10 +320,21 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
281
320
|
<slot name="topbar-actions" slot="topbar-actions"></slot>
|
|
282
321
|
</exm-navigation-topbar>`;
|
|
283
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* If there is an active item, and that item has children, the width of the drawer should be set for desktop.
|
|
325
|
+
* This will push the content to the right.
|
|
326
|
+
*
|
|
327
|
+
* @returns the width of the drawer area
|
|
328
|
+
*/
|
|
329
|
+
getDrawerWidth() {
|
|
330
|
+
if (this.media === 'desktop' && this.activeItem.length > 0 && this.navigationHasSubmenu[this.activeItem[0]]) {
|
|
331
|
+
return this.drawerWidth;
|
|
332
|
+
}
|
|
333
|
+
return 0;
|
|
334
|
+
}
|
|
284
335
|
render() {
|
|
285
|
-
var _a;
|
|
286
336
|
const containerStyle = {
|
|
287
|
-
'--exm-drawer-width': `${
|
|
337
|
+
'--exm-drawer-width': `${this.getDrawerWidth()}px`,
|
|
288
338
|
};
|
|
289
339
|
const containerClass = { 'show-topbar': !this.railOpen };
|
|
290
340
|
return html `
|
|
@@ -323,9 +373,6 @@ __decorate([
|
|
|
323
373
|
__decorate([
|
|
324
374
|
query('#navigation-container')
|
|
325
375
|
], ExmNavigationBase.prototype, "navContent", void 0);
|
|
326
|
-
__decorate([
|
|
327
|
-
state()
|
|
328
|
-
], ExmNavigationBase.prototype, "persistent", void 0);
|
|
329
376
|
__decorate([
|
|
330
377
|
state()
|
|
331
378
|
], ExmNavigationBase.prototype, "selectedItem", void 0);
|
|
@@ -338,9 +385,6 @@ __decorate([
|
|
|
338
385
|
__decorate([
|
|
339
386
|
state()
|
|
340
387
|
], ExmNavigationBase.prototype, "drawerOpen", void 0);
|
|
341
|
-
__decorate([
|
|
342
|
-
state()
|
|
343
|
-
], ExmNavigationBase.prototype, "drawerHover", void 0);
|
|
344
388
|
__decorate([
|
|
345
389
|
state()
|
|
346
390
|
], ExmNavigationBase.prototype, "navigationHasSubmenu", void 0);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { Drawer } from '@material/mwc-drawer';
|
|
2
1
|
import { ExmgElement } from '@exmg/lit-base';
|
|
3
|
-
import '@material/mwc-drawer';
|
|
4
2
|
export declare class ExmNavigationDrawerBase extends ExmgElement {
|
|
5
3
|
open: boolean;
|
|
6
4
|
persistent: boolean;
|
|
7
|
-
drawer?:
|
|
5
|
+
drawer?: HTMLDivElement;
|
|
8
6
|
static styles: import("lit").CSSResult[];
|
|
9
7
|
private handleMouseEnter;
|
|
10
8
|
private handleMouseLeave;
|
|
11
|
-
private handleDrawerClose;
|
|
12
9
|
protected firstUpdated(): Promise<void>;
|
|
13
10
|
render(): import("lit-html").TemplateResult<1>;
|
|
14
11
|
}
|
|
@@ -3,7 +3,7 @@ import { html } from 'lit';
|
|
|
3
3
|
import { property, query } from 'lit/decorators.js';
|
|
4
4
|
import { ExmgElement } from '@exmg/lit-base';
|
|
5
5
|
import { style } from './styles/exm-navigation-drawer-css.js';
|
|
6
|
-
import '
|
|
6
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
7
7
|
export class ExmNavigationDrawerBase extends ExmgElement {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
@@ -16,9 +16,6 @@ export class ExmNavigationDrawerBase extends ExmgElement {
|
|
|
16
16
|
handleMouseLeave() {
|
|
17
17
|
this.fire('drawer-mouseleave');
|
|
18
18
|
}
|
|
19
|
-
handleDrawerClose() {
|
|
20
|
-
this.fire('drawer-mouseleave');
|
|
21
|
-
}
|
|
22
19
|
async firstUpdated() {
|
|
23
20
|
var _a;
|
|
24
21
|
await this.updateComplete;
|
|
@@ -30,12 +27,16 @@ export class ExmNavigationDrawerBase extends ExmgElement {
|
|
|
30
27
|
asideElement.addEventListener('mouseleave', this.handleMouseLeave.bind(this));
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
|
-
this.addEventListener('drawer-close', this.handleDrawerClose.bind(this));
|
|
34
30
|
}
|
|
35
31
|
render() {
|
|
36
|
-
|
|
32
|
+
const classNames = { open: this.open };
|
|
33
|
+
return html `<aside
|
|
34
|
+
class="${classMap(classNames)}"
|
|
35
|
+
@mouseenter=${this.handleMouseEnter}
|
|
36
|
+
@mouseleave=${this.handleMouseLeave}
|
|
37
|
+
>
|
|
37
38
|
<slot></slot>
|
|
38
|
-
</
|
|
39
|
+
</aside> `;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
ExmNavigationDrawerBase.styles = [style];
|
|
@@ -46,6 +47,6 @@ __decorate([
|
|
|
46
47
|
property({ type: Boolean })
|
|
47
48
|
], ExmNavigationDrawerBase.prototype, "persistent", void 0);
|
|
48
49
|
__decorate([
|
|
49
|
-
query('
|
|
50
|
+
query('aside')
|
|
50
51
|
], ExmNavigationDrawerBase.prototype, "drawer", void 0);
|
|
51
52
|
//# sourceMappingURL=exm-navigation-drawer-base.js.map
|
|
@@ -6,6 +6,7 @@ import '@material/web/focus/md-focus-ring.js';
|
|
|
6
6
|
import './exm-navigation-icon.js';
|
|
7
7
|
import '@material/web/list/list.js';
|
|
8
8
|
import '@material/web/list/list-item.js';
|
|
9
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
9
10
|
export class ExmNavigationDrawerNavItemBase extends LitElement {
|
|
10
11
|
constructor() {
|
|
11
12
|
super(...arguments);
|
|
@@ -15,15 +16,18 @@ export class ExmNavigationDrawerNavItemBase extends LitElement {
|
|
|
15
16
|
this.submenuIcon = 'arrow_forward';
|
|
16
17
|
}
|
|
17
18
|
render() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const classList = { selected: this.selected, 'has-sub-menu': this.hasSubmenu, 'has-icon': !!this.icon };
|
|
20
|
+
return html `
|
|
21
|
+
<button class="${classMap(classList)}">
|
|
22
|
+
${this.icon ? html `<exm-navigation-icon class="item-icon" icon=${this.icon}></exm-navigation-icon>` : nothing}
|
|
23
|
+
<span class="label"><slot></slot></span>
|
|
24
|
+
${this.hasSubmenu
|
|
25
|
+
? html `<exm-navigation-icon class="has-submenu" icon=${this.submenuIcon}></exm-navigation-icon>`
|
|
21
26
|
: nothing}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
</md-list-item>`;
|
|
27
|
+
<md-ripple part="ripple"></md-ripple>
|
|
28
|
+
<md-focus-ring part="focus-ring" inward></md-focus-ring>
|
|
29
|
+
</button>
|
|
30
|
+
`;
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
ExmNavigationDrawerNavItemBase.styles = [style];
|
|
@@ -20,6 +20,8 @@ export class ExmNavigationIconButtonBase extends ExmgElement {
|
|
|
20
20
|
<button class="icon-button ${classMap(buttonClass)}" @click=${this.handleMenuButtonClick}>
|
|
21
21
|
<exm-navigation-icon icon=${this.icon}></exm-navigation-icon>
|
|
22
22
|
${this.label ? html ` <span class="label">${this.label}</span>` : nothing}
|
|
23
|
+
<md-ripple part="ripple"></md-ripple>
|
|
24
|
+
<md-focus-ring part="focus-ring" inward></md-focus-ring>
|
|
23
25
|
</button>
|
|
24
26
|
`;
|
|
25
27
|
}
|
|
@@ -10,9 +10,19 @@ export declare class ExmNavigationSubMenuBase extends ExmgElement {
|
|
|
10
10
|
path: (string | null)[];
|
|
11
11
|
hasBackButton: boolean;
|
|
12
12
|
currentItem?: MenuItem['items'];
|
|
13
|
+
static itemIndex: number;
|
|
14
|
+
navigationElement?: HTMLElement;
|
|
13
15
|
static styles: import("lit").CSSResult[];
|
|
14
16
|
protected updated(changedProperties: PropertyValues): void;
|
|
17
|
+
connectedCallback(): void;
|
|
18
|
+
disconnectedCallback(): void;
|
|
15
19
|
private handleSubMenuItemClick;
|
|
20
|
+
/**
|
|
21
|
+
* If a collapsable menuitem is not selected we can just pass the path.
|
|
22
|
+
* If it is selected, we remove the item from the path to collapse the menu again
|
|
23
|
+
*/
|
|
24
|
+
private handleCollapsableSubMenuItemClick;
|
|
25
|
+
private getItemStyle;
|
|
16
26
|
private renderSubMenu;
|
|
17
27
|
render(): import("lit-html").TemplateResult<1>;
|
|
18
28
|
}
|