@exmg/exm-navigation 1.1.1 → 1.1.2-alpha.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/README.md +5 -4
- package/{src → dist}/exm-navigation-base.d.ts +36 -10
- package/{src → dist}/exm-navigation-base.js +155 -84
- package/{src → dist}/exm-navigation-drawer-base.js +3 -1
- 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 +11 -0
- package/dist/exm-navigation-sub-menu-base.js +153 -0
- 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 +16 -3
- package/{src → dist}/styles/exm-navigation-css.js +16 -0
- package/dist/styles/exm-navigation-drawer-nav-item-css.js +84 -0
- package/dist/styles/exm-navigation-icon-button-css.js +29 -0
- package/dist/styles/exm-navigation-sub-menu-css.js +21 -0
- package/{src → dist}/styles/exm-navigation-topbar-css.js +4 -3
- package/package.json +19 -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-sub-menu-base.js +0 -88
- 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-nav-item-css.js +0 -40
- package/src/styles/exm-navigation-icon-button-css.js +0 -23
- 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 -38
- 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-base.d.ts +0 -0
- /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-css.js +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-css.js +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
package/README.md
CHANGED
|
@@ -47,10 +47,11 @@ Some of the components used in the navigation c an be used separately. Please ch
|
|
|
47
47
|
|
|
48
48
|
### Properties/Attributes
|
|
49
49
|
|
|
50
|
-
| Name
|
|
51
|
-
|
|
|
52
|
-
| `items`
|
|
53
|
-
| `path`
|
|
50
|
+
| Name | Type | Default | Description |
|
|
51
|
+
| -------------------- | ------------ | ------- | ------------------------------------------------------------------------------------------ |
|
|
52
|
+
| `items` | `MenuItem[]` | _[]_ | The list of menuitems to display in the navigation component |
|
|
53
|
+
| `path` | `string[]` | _[]_ | The current/initial path for the navigation |
|
|
54
|
+
| `disable-navigation` | `boolean` | _false_ | Disable navigation managed by the component. In that case you can use the event to trigger |
|
|
54
55
|
|
|
55
56
|
#### MenuItem
|
|
56
57
|
|
|
@@ -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,38 +12,55 @@ 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[];
|
|
16
19
|
path: string[];
|
|
17
20
|
drawerWidth: number;
|
|
21
|
+
disableNavigate: boolean;
|
|
18
22
|
drawer?: ExmNavigationDrawer;
|
|
19
23
|
navContent?: HTMLDivElement;
|
|
20
|
-
|
|
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
|
+
*/
|
|
21
28
|
selectedItem: string[];
|
|
29
|
+
/**
|
|
30
|
+
* The currently active menu item
|
|
31
|
+
*/
|
|
22
32
|
activeItem: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Wether or not the rail should be visible yes or no
|
|
35
|
+
*/
|
|
23
36
|
railOpen: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Wether or not the drawer should be visible yes or no
|
|
39
|
+
*/
|
|
24
40
|
drawerOpen: boolean;
|
|
25
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Object with menuitem and a bool for having that path sub items yes or no
|
|
43
|
+
*/
|
|
26
44
|
navigationHasSubmenu: Record<string, boolean>;
|
|
27
45
|
static styles: import("lit").CSSResult[];
|
|
28
|
-
menu: MenuItem[];
|
|
29
|
-
expandedItems: {
|
|
30
|
-
[k: string]: boolean;
|
|
31
|
-
};
|
|
32
|
-
unSubscribeSelected: () => void;
|
|
33
46
|
protected updated(changedProperties: PropertyValues): void;
|
|
34
47
|
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
35
48
|
connectedCallback(): void;
|
|
36
49
|
/**
|
|
37
50
|
* Set the correct values when the media changes.
|
|
38
51
|
*/
|
|
39
|
-
handleMediaTypeChange
|
|
40
|
-
|
|
52
|
+
private handleMediaTypeChange;
|
|
53
|
+
private getPathEndpoint;
|
|
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;
|
|
41
60
|
/**
|
|
42
61
|
* Handle Rail item click or Drawer sub menu click.
|
|
43
62
|
* If the selected menu item has children, we add the first item to the list (as per Google implementation).
|
|
44
|
-
* 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
|
|
45
64
|
*/
|
|
46
65
|
private handleRailItemClick;
|
|
47
66
|
/**
|
|
@@ -100,6 +119,13 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
100
119
|
* Render the topbar. This is displayed on mobile and contains the menu button and a slot for the title
|
|
101
120
|
*/
|
|
102
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;
|
|
103
129
|
render(): import("lit-html").TemplateResult<1>;
|
|
104
130
|
}
|
|
105
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';
|
|
@@ -19,16 +21,28 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
19
21
|
this.items = [];
|
|
20
22
|
this.path = ['chat'];
|
|
21
23
|
this.drawerWidth = 319;
|
|
22
|
-
this.
|
|
24
|
+
this.disableNavigate = false;
|
|
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
|
+
*/
|
|
23
29
|
this.selectedItem = [];
|
|
30
|
+
/**
|
|
31
|
+
* The currently active menu item
|
|
32
|
+
*/
|
|
24
33
|
this.activeItem = [];
|
|
34
|
+
/**
|
|
35
|
+
* Wether or not the rail should be visible yes or no
|
|
36
|
+
*/
|
|
25
37
|
this.railOpen = true;
|
|
38
|
+
/**
|
|
39
|
+
* Wether or not the drawer should be visible yes or no
|
|
40
|
+
*/
|
|
26
41
|
this.drawerOpen = false;
|
|
27
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Object with menuitem and a bool for having that path sub items yes or no
|
|
44
|
+
*/
|
|
28
45
|
this.navigationHasSubmenu = {};
|
|
29
|
-
this.menu = [];
|
|
30
|
-
this.expandedItems = {};
|
|
31
|
-
this.unSubscribeSelected = () => { };
|
|
32
46
|
}
|
|
33
47
|
updated(changedProperties) {
|
|
34
48
|
if (changedProperties.has('media')) {
|
|
@@ -38,7 +52,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
38
52
|
for (const item of this.items) {
|
|
39
53
|
this.navigationHasSubmenu[item.id] = (item.items || []).length > 0;
|
|
40
54
|
}
|
|
41
|
-
if (this.navigationHasSubmenu[this.path[0]] && this.
|
|
55
|
+
if (this.navigationHasSubmenu[this.path[0]] && this.media === 'desktop') {
|
|
42
56
|
this.drawerOpen = true;
|
|
43
57
|
}
|
|
44
58
|
}
|
|
@@ -57,89 +71,111 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
57
71
|
* Set the correct values when the media changes.
|
|
58
72
|
*/
|
|
59
73
|
handleMediaTypeChange() {
|
|
60
|
-
this.
|
|
61
|
-
this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.selectedItem[0]];
|
|
74
|
+
this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.activeItem[0]];
|
|
62
75
|
this.railOpen = this.media !== 'mobile';
|
|
63
76
|
}
|
|
77
|
+
getPathEndpoint() {
|
|
78
|
+
let items = this.items;
|
|
79
|
+
let result;
|
|
80
|
+
const checkItems = (path, last) => {
|
|
81
|
+
const item = items.find((item) => item.id === path);
|
|
82
|
+
if (last) {
|
|
83
|
+
return item === null || item === void 0 ? void 0 : item.path;
|
|
84
|
+
}
|
|
85
|
+
items = (item === null || item === void 0 ? void 0 : item.items) || [];
|
|
86
|
+
return;
|
|
87
|
+
};
|
|
88
|
+
for (let i = 0; i < this.selectedItem.length; i++) {
|
|
89
|
+
result = checkItems(this.selectedItem[i], i === this.selectedItem.length - 1);
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
64
93
|
loadPage(path) {
|
|
65
94
|
this.path = path;
|
|
66
|
-
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
|
+
}
|
|
67
101
|
this.fire('navigation-change', path);
|
|
102
|
+
if (!this.disableNavigate) {
|
|
103
|
+
window.history.pushState({}, '', this.getPathEndpoint());
|
|
104
|
+
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
105
|
+
}
|
|
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
|
+
}
|
|
68
134
|
}
|
|
69
135
|
/**
|
|
70
136
|
* Handle Rail item click or Drawer sub menu click.
|
|
71
137
|
* If the selected menu item has children, we add the first item to the list (as per Google implementation).
|
|
72
|
-
* 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
|
|
73
139
|
*/
|
|
74
140
|
handleRailItemClick({ detail }) {
|
|
75
141
|
var _a;
|
|
76
|
-
if (this.
|
|
142
|
+
if (this.activeItem[0] !== detail || this.media === 'mobile') {
|
|
77
143
|
const items = ((_a = this.items.find((item) => item.id === detail)) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
78
|
-
if (items.length) {
|
|
144
|
+
if (items.length && !this.touch) {
|
|
79
145
|
this.selectedItem = [detail, items[0].id];
|
|
80
146
|
}
|
|
81
147
|
else {
|
|
82
148
|
this.selectedItem = [detail];
|
|
83
149
|
}
|
|
84
|
-
// copy the selected item to the active item
|
|
85
|
-
this.activeItem = this.selectedItem;
|
|
86
|
-
/**
|
|
87
|
-
* If persistent menu close the drawer when a item is clicked and does not has children items
|
|
88
|
-
*/
|
|
89
|
-
if (this.persistent) {
|
|
90
|
-
this.drawerOpen = items.length > 0 || this.navigationHasSubmenu[detail];
|
|
91
|
-
}
|
|
92
|
-
else if (items.length === 0) {
|
|
93
|
-
this.drawerOpen = false;
|
|
94
|
-
}
|
|
95
150
|
this.loadPage(this.selectedItem);
|
|
151
|
+
this.handleDrawerOpen();
|
|
96
152
|
}
|
|
97
153
|
}
|
|
98
154
|
/**
|
|
99
155
|
* Handle the mouse enter of the rail item.
|
|
100
156
|
*/
|
|
101
157
|
handleRailItemMouseEnter({ detail }) {
|
|
102
|
-
if (this.
|
|
103
|
-
|
|
104
|
-
if (detail !== this.selectedItem[0]) {
|
|
105
|
-
this.activeItem = [detail];
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
else if (this.navigationHasSubmenu[this.selectedItem[0]] && this.persistent) {
|
|
110
|
-
this.activeItem = this.selectedItem;
|
|
111
|
-
this.drawerOpen = true;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
this.activeItem = this.selectedItem;
|
|
115
|
-
this.drawerOpen = false;
|
|
158
|
+
if (this.touch) {
|
|
159
|
+
return;
|
|
116
160
|
}
|
|
117
|
-
this.
|
|
161
|
+
this.selectedItem = [detail];
|
|
162
|
+
this.handleDrawerOpen();
|
|
118
163
|
}
|
|
119
164
|
/**
|
|
120
165
|
* Handle the mouse leave of the rail item.
|
|
121
166
|
* If the item has no submenu and the current selected item has no submenu, it is safe to close the drawer
|
|
122
167
|
*/
|
|
123
|
-
handleRailItemMouseLeave({
|
|
124
|
-
if (!this.navigationHasSubmenu[detail] && !this.navigationHasSubmenu[this.selectedItem[0]]) {
|
|
125
|
-
this.drawerOpen = false;
|
|
126
|
-
}
|
|
127
|
-
if (!this.persistent && !this.navigationHasSubmenu[detail]) {
|
|
128
|
-
this.drawerOpen = false;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
168
|
+
handleRailItemMouseLeave() { }
|
|
131
169
|
/**
|
|
132
170
|
* Handle drawer mouse leave. Should close the drawer
|
|
133
171
|
*/
|
|
134
172
|
handleDrawerMouseLeave() {
|
|
135
|
-
if (!this.navigationHasSubmenu[this.selectedItem[0]] || !this.persistent) {
|
|
136
|
-
this.drawerOpen = false;
|
|
137
|
-
}
|
|
138
173
|
/**
|
|
139
174
|
* On mouse leave the drawer we want to set the active item to the selected item.
|
|
140
175
|
* If not, it will show the active item on every hover and will make navigating in the selected item impossible
|
|
141
176
|
*/
|
|
142
|
-
this.
|
|
177
|
+
this.selectedItem = this.activeItem;
|
|
178
|
+
this.handleDrawerOpen({ tabletForce: true });
|
|
143
179
|
}
|
|
144
180
|
/**
|
|
145
181
|
* Handle the click on a sub menu item
|
|
@@ -148,10 +184,13 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
148
184
|
*/
|
|
149
185
|
handleSubMenuClick({ detail }) {
|
|
150
186
|
this.selectedItem = detail;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
187
|
+
const endPoint = this.getPathEndpoint();
|
|
188
|
+
let mobileForce = false;
|
|
189
|
+
if (endPoint) {
|
|
190
|
+
this.loadPage(this.selectedItem);
|
|
191
|
+
mobileForce = true;
|
|
154
192
|
}
|
|
193
|
+
this.handleDrawerOpen({ mobileForce, tabletForce: this.touch && !!endPoint });
|
|
155
194
|
}
|
|
156
195
|
/**
|
|
157
196
|
* Handle the topbar menu click.
|
|
@@ -165,7 +204,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
165
204
|
* This should reset the active item, so the root-level menu gets triggered
|
|
166
205
|
*/
|
|
167
206
|
handleDrawerBackClick() {
|
|
168
|
-
this.
|
|
207
|
+
this.selectedItem = [];
|
|
169
208
|
}
|
|
170
209
|
/**
|
|
171
210
|
* Check if the passed paths last item has children yes or no
|
|
@@ -186,11 +225,10 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
186
225
|
renderDrawerMenuButton() {
|
|
187
226
|
return !this.railOpen
|
|
188
227
|
? html `
|
|
189
|
-
<section>
|
|
190
|
-
<
|
|
191
|
-
icon
|
|
192
|
-
|
|
193
|
-
></exm-navigation-icon-button>
|
|
228
|
+
<section class="drawer-menu-button">
|
|
229
|
+
<md-icon-button @click=${this.handleTopbarMenuClick}>
|
|
230
|
+
<md-icon>${this.drawerOpen ? 'menu_open' : 'menu'}</md-icon>
|
|
231
|
+
</md-icon-button>
|
|
194
232
|
</section>
|
|
195
233
|
`
|
|
196
234
|
: nothing;
|
|
@@ -200,34 +238,60 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
200
238
|
* If more levels deep, show the back button
|
|
201
239
|
*/
|
|
202
240
|
renderStartMenu() {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
241
|
+
if (this.railOpen) {
|
|
242
|
+
return nothing;
|
|
243
|
+
}
|
|
244
|
+
return this.selectedItem.length === 0 ||
|
|
245
|
+
(this.selectedItem.length === 1 && !this.currentSelectedHasChildren(this.selectedItem))
|
|
206
246
|
? html `<exm-navigation-drawer-menu
|
|
207
247
|
.items=${this.items}
|
|
208
248
|
.path=${this.activeItem}
|
|
209
249
|
@drawer-menu-item-click=${this.handleRailItemClick}
|
|
210
250
|
></exm-navigation-drawer-menu>`
|
|
211
|
-
:
|
|
212
|
-
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
`
|
|
221
|
-
: 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
|
+
`;
|
|
222
260
|
}
|
|
223
261
|
/**
|
|
224
262
|
* return the sub menus. More then 1 level deep
|
|
225
263
|
*/
|
|
226
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;
|
|
227
289
|
return html `
|
|
228
290
|
<exm-navigation-sub-menu
|
|
229
291
|
.items=${this.items}
|
|
230
|
-
.path=${
|
|
292
|
+
.path=${selected}
|
|
293
|
+
?has-back-button=${!this.railOpen &&
|
|
294
|
+
(selected.length > 1 || (selected.length > 0 && this.currentSelectedHasChildren(selected)))}
|
|
231
295
|
@sub-menu-item-click=${this.handleSubMenuClick}
|
|
232
296
|
></exm-navigation-sub-menu>
|
|
233
297
|
`;
|
|
@@ -238,7 +302,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
238
302
|
renderRail() {
|
|
239
303
|
return html `<exm-navigation-rail
|
|
240
304
|
.items=${this.items}
|
|
241
|
-
.selected=${this.
|
|
305
|
+
.selected=${this.activeItem}
|
|
242
306
|
@rail-item-click=${this.handleRailItemClick}
|
|
243
307
|
@rail-item-mouseenter=${this.handleRailItemMouseEnter}
|
|
244
308
|
@rail-item-mouseleave=${this.handleRailItemMouseLeave}
|
|
@@ -256,10 +320,21 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
256
320
|
<slot name="topbar-actions" slot="topbar-actions"></slot>
|
|
257
321
|
</exm-navigation-topbar>`;
|
|
258
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
|
+
}
|
|
259
335
|
render() {
|
|
260
|
-
var _a;
|
|
261
336
|
const containerStyle = {
|
|
262
|
-
'--exm-drawer-width': `${
|
|
337
|
+
'--exm-drawer-width': `${this.getDrawerWidth()}px`,
|
|
263
338
|
};
|
|
264
339
|
const containerClass = { 'show-topbar': !this.railOpen };
|
|
265
340
|
return html `
|
|
@@ -276,7 +351,6 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
276
351
|
<slot></slot>
|
|
277
352
|
</section>
|
|
278
353
|
</section>
|
|
279
|
-
<slot></slot>
|
|
280
354
|
`;
|
|
281
355
|
}
|
|
282
356
|
}
|
|
@@ -290,15 +364,15 @@ __decorate([
|
|
|
290
364
|
__decorate([
|
|
291
365
|
property({ type: Number, attribute: 'drawer-width' })
|
|
292
366
|
], ExmNavigationBase.prototype, "drawerWidth", void 0);
|
|
367
|
+
__decorate([
|
|
368
|
+
property({ type: Boolean, attribute: 'disable-navigation' })
|
|
369
|
+
], ExmNavigationBase.prototype, "disableNavigate", void 0);
|
|
293
370
|
__decorate([
|
|
294
371
|
query('exm-navigation-drawer')
|
|
295
372
|
], ExmNavigationBase.prototype, "drawer", void 0);
|
|
296
373
|
__decorate([
|
|
297
374
|
query('#navigation-container')
|
|
298
375
|
], ExmNavigationBase.prototype, "navContent", void 0);
|
|
299
|
-
__decorate([
|
|
300
|
-
state()
|
|
301
|
-
], ExmNavigationBase.prototype, "persistent", void 0);
|
|
302
376
|
__decorate([
|
|
303
377
|
state()
|
|
304
378
|
], ExmNavigationBase.prototype, "selectedItem", void 0);
|
|
@@ -311,9 +385,6 @@ __decorate([
|
|
|
311
385
|
__decorate([
|
|
312
386
|
state()
|
|
313
387
|
], ExmNavigationBase.prototype, "drawerOpen", void 0);
|
|
314
|
-
__decorate([
|
|
315
|
-
state()
|
|
316
|
-
], ExmNavigationBase.prototype, "drawerHover", void 0);
|
|
317
388
|
__decorate([
|
|
318
389
|
state()
|
|
319
390
|
], ExmNavigationBase.prototype, "navigationHasSubmenu", void 0);
|
|
@@ -33,7 +33,9 @@ export class ExmNavigationDrawerBase extends ExmgElement {
|
|
|
33
33
|
this.addEventListener('drawer-close', this.handleDrawerClose.bind(this));
|
|
34
34
|
}
|
|
35
35
|
render() {
|
|
36
|
-
return html `<mwc-drawer type="dismissible" ?open=${this.open}
|
|
36
|
+
return html `<mwc-drawer type="dismissible" ?open=${this.open}>
|
|
37
|
+
<slot></slot>
|
|
38
|
+
</mwc-drawer>`;
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
ExmNavigationDrawerBase.styles = [style];
|
|
@@ -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
|
}
|
|
@@ -8,10 +8,21 @@ import '@exmg/exm-collapsed/exm-collapsed.js';
|
|
|
8
8
|
export declare class ExmNavigationSubMenuBase extends ExmgElement {
|
|
9
9
|
items: MenuItem[];
|
|
10
10
|
path: (string | null)[];
|
|
11
|
+
hasBackButton: boolean;
|
|
11
12
|
currentItem?: MenuItem['items'];
|
|
13
|
+
static itemIndex: number;
|
|
14
|
+
navigationElement?: HTMLElement;
|
|
12
15
|
static styles: import("lit").CSSResult[];
|
|
13
16
|
protected updated(changedProperties: PropertyValues): void;
|
|
17
|
+
connectedCallback(): void;
|
|
18
|
+
disconnectedCallback(): void;
|
|
14
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;
|
|
15
26
|
private renderSubMenu;
|
|
16
27
|
render(): import("lit-html").TemplateResult<1>;
|
|
17
28
|
}
|