@exmg/exm-navigation 1.1.29 → 1.1.31
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.
|
@@ -21,6 +21,8 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
21
21
|
path: string[];
|
|
22
22
|
drawerWidth: number;
|
|
23
23
|
disableNavigate: boolean;
|
|
24
|
+
hoverDisabled: boolean;
|
|
25
|
+
collapseOnDesktop: boolean;
|
|
24
26
|
drawer?: ExmNavigationDrawer;
|
|
25
27
|
navContent?: HTMLDivElement;
|
|
26
28
|
/**
|
|
@@ -63,7 +65,7 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
63
65
|
* Handles the drawer state. If it should be open yes or no.
|
|
64
66
|
* @param param0
|
|
65
67
|
*/
|
|
66
|
-
handleDrawerOpen({ mobileForce, tabletForce }?: Record<string, boolean>): void;
|
|
68
|
+
handleDrawerOpen({ mobileForce, tabletForce, desktopForce }?: Record<string, boolean>): void;
|
|
67
69
|
/**
|
|
68
70
|
* Handle Rail item click or Drawer sub menu click.
|
|
69
71
|
* If the selected menu item has children, we add the first item to the list (as per Google implementation).
|
|
@@ -99,6 +101,7 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
99
101
|
* This should reset the active item, so the root-level menu gets triggered
|
|
100
102
|
*/
|
|
101
103
|
private handleDrawerBackClick;
|
|
104
|
+
private handleContentPointerDown;
|
|
102
105
|
/**
|
|
103
106
|
* Check if the passed paths last item has children yes or no
|
|
104
107
|
* @param path Path array
|
|
@@ -24,6 +24,8 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
24
24
|
this.path = ['chat'];
|
|
25
25
|
this.drawerWidth = 275;
|
|
26
26
|
this.disableNavigate = false;
|
|
27
|
+
this.hoverDisabled = false;
|
|
28
|
+
this.collapseOnDesktop = false;
|
|
27
29
|
/**
|
|
28
30
|
* The menu item triggered by hovering and entering submenu's
|
|
29
31
|
* Once an item with endpoint is clicked, this value should be written to activeItem
|
|
@@ -166,10 +168,12 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
166
168
|
* Handles the drawer state. If it should be open yes or no.
|
|
167
169
|
* @param param0
|
|
168
170
|
*/
|
|
169
|
-
handleDrawerOpen({ mobileForce, tabletForce } = {}) {
|
|
171
|
+
handleDrawerOpen({ mobileForce, tabletForce, desktopForce } = {}) {
|
|
172
|
+
const hasActiveSubmenu = this.navigationHasSubmenu[this.activeItem[0]];
|
|
173
|
+
const hasSelectedSubmenu = this.navigationHasSubmenu[this.selectedItem[0]];
|
|
170
174
|
if (this.media === 'mobile' || this.touch) {
|
|
171
175
|
// Only triggerable by button
|
|
172
|
-
if (mobileForce || !
|
|
176
|
+
if (mobileForce || !hasActiveSubmenu) {
|
|
173
177
|
this.drawerOpen = false;
|
|
174
178
|
}
|
|
175
179
|
}
|
|
@@ -178,15 +182,19 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
178
182
|
this.drawerOpen = false;
|
|
179
183
|
}
|
|
180
184
|
else {
|
|
181
|
-
this.drawerOpen =
|
|
185
|
+
this.drawerOpen = hasSelectedSubmenu;
|
|
182
186
|
}
|
|
183
187
|
}
|
|
184
188
|
if (this.media === 'desktop') {
|
|
189
|
+
if (desktopForce) {
|
|
190
|
+
this.drawerOpen = false;
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
185
193
|
if (this.navigationHasSubmenu[this.activeItem[0]]) {
|
|
186
194
|
this.drawerOpen = true;
|
|
187
195
|
}
|
|
188
196
|
else {
|
|
189
|
-
this.drawerOpen =
|
|
197
|
+
this.drawerOpen = hasSelectedSubmenu;
|
|
190
198
|
}
|
|
191
199
|
}
|
|
192
200
|
}
|
|
@@ -197,14 +205,24 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
197
205
|
*/
|
|
198
206
|
handleRailItemClick({ detail }) {
|
|
199
207
|
var _a;
|
|
208
|
+
const isSameItem = this.activeItem[0] === detail;
|
|
209
|
+
if (this.hoverDisabled) {
|
|
210
|
+
if (isSameItem && this.drawerOpen && this.collapseOnDesktop) {
|
|
211
|
+
this.drawerOpen = false;
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
this.selectedItem = [detail];
|
|
215
|
+
this.loadPage(this.selectedItem);
|
|
216
|
+
this.handleDrawerOpen();
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
200
220
|
const item = this.items.find((item) => item.id === this.activeItem[0]);
|
|
201
221
|
/**
|
|
202
222
|
* If this is the current item, skip it.
|
|
203
223
|
* If it is the current one and we have an additional path, handle the click to be able to go to the path's destination
|
|
204
224
|
*/
|
|
205
|
-
if (this.activeItem[0]
|
|
206
|
-
(this.activeItem[0] === detail && (item === null || item === void 0 ? void 0 : item.additionalPath)) ||
|
|
207
|
-
this.media !== 'desktop') {
|
|
225
|
+
if (!isSameItem || (this.activeItem[0] === detail && (item === null || item === void 0 ? void 0 : item.additionalPath)) || this.media !== 'desktop') {
|
|
208
226
|
const items = ((_a = this.items.find((item) => item.id === detail)) === null || _a === void 0 ? void 0 : _a.items) || [];
|
|
209
227
|
if (items.length && !this.touch) {
|
|
210
228
|
this.selectedItem = [detail, items[0].id];
|
|
@@ -220,7 +238,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
220
238
|
* Handle the mouse enter of the rail item.
|
|
221
239
|
*/
|
|
222
240
|
handleRailItemMouseEnter({ detail }) {
|
|
223
|
-
if (this.touch) {
|
|
241
|
+
if (this.touch || this.hoverDisabled) {
|
|
224
242
|
return;
|
|
225
243
|
}
|
|
226
244
|
this.selectedItem = [detail];
|
|
@@ -239,6 +257,14 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
239
257
|
* On mouse leave the drawer we want to set the active item to the selected item.
|
|
240
258
|
* If not, it will show the active item on every hover and will make navigating in the selected item impossible
|
|
241
259
|
*/
|
|
260
|
+
if (this.hoverDisabled) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (this.media === 'desktop' && this.collapseOnDesktop) {
|
|
264
|
+
this.selectedItem = this.activeItem;
|
|
265
|
+
this.drawerOpen = false;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
242
268
|
this.selectedItem = this.activeItem;
|
|
243
269
|
this.handleDrawerOpen({ tabletForce: true });
|
|
244
270
|
}
|
|
@@ -251,11 +277,15 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
251
277
|
this.selectedItem = detail;
|
|
252
278
|
const endPoint = this.getPathEndpoint();
|
|
253
279
|
let mobileForce = false;
|
|
280
|
+
let desktopForce = false;
|
|
254
281
|
if (endPoint) {
|
|
255
282
|
this.loadPage(this.selectedItem);
|
|
256
283
|
mobileForce = true;
|
|
284
|
+
if (this.collapseOnDesktop) {
|
|
285
|
+
desktopForce = true;
|
|
286
|
+
}
|
|
257
287
|
}
|
|
258
|
-
this.handleDrawerOpen({ mobileForce, tabletForce: this.touch && !!endPoint });
|
|
288
|
+
this.handleDrawerOpen({ mobileForce, tabletForce: this.touch && !!endPoint, desktopForce });
|
|
259
289
|
}
|
|
260
290
|
/**
|
|
261
291
|
* Handle the topbar menu click.
|
|
@@ -271,6 +301,13 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
271
301
|
handleDrawerBackClick() {
|
|
272
302
|
this.selectedItem = [];
|
|
273
303
|
}
|
|
304
|
+
// Close the drawer whenever the content area is interacted with
|
|
305
|
+
handleContentPointerDown() {
|
|
306
|
+
if (!this.drawerOpen || (this.media === 'desktop' && !this.collapseOnDesktop))
|
|
307
|
+
return;
|
|
308
|
+
this.selectedItem = this.activeItem;
|
|
309
|
+
this.drawerOpen = false;
|
|
310
|
+
}
|
|
274
311
|
/**
|
|
275
312
|
* Check if the passed paths last item has children yes or no
|
|
276
313
|
* @param path Path array
|
|
@@ -392,7 +429,14 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
392
429
|
* @returns the width of the drawer area
|
|
393
430
|
*/
|
|
394
431
|
getDrawerWidth() {
|
|
395
|
-
if (this.media
|
|
432
|
+
if (this.media !== 'desktop' || !this.drawerOpen) {
|
|
433
|
+
return 0;
|
|
434
|
+
}
|
|
435
|
+
const activeItem = this.activeItem[0];
|
|
436
|
+
const selectedItem = this.selectedItem[0];
|
|
437
|
+
const activeHasChildren = !!activeItem && this.navigationHasSubmenu[activeItem];
|
|
438
|
+
const selectedHasChildren = !!selectedItem && this.navigationHasSubmenu[selectedItem];
|
|
439
|
+
if (activeHasChildren || selectedHasChildren) {
|
|
396
440
|
return this.drawerWidth;
|
|
397
441
|
}
|
|
398
442
|
return 0;
|
|
@@ -412,7 +456,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
412
456
|
<exm-navigation-drawer ?open=${this.drawerOpen} @drawer-mouseleave=${this.handleDrawerMouseLeave}>
|
|
413
457
|
${[this.renderDrawerMenuButton(), this.renderStartMenu(), this.renderDrawerSubMenu()]}
|
|
414
458
|
</exm-navigation-drawer>
|
|
415
|
-
<section class="content">
|
|
459
|
+
<section class="content" @pointerdown=${this.handleContentPointerDown}>
|
|
416
460
|
<slot></slot>
|
|
417
461
|
</section>
|
|
418
462
|
</section>
|
|
@@ -432,6 +476,12 @@ __decorate([
|
|
|
432
476
|
__decorate([
|
|
433
477
|
property({ type: Boolean, attribute: 'disable-navigation' })
|
|
434
478
|
], ExmNavigationBase.prototype, "disableNavigate", void 0);
|
|
479
|
+
__decorate([
|
|
480
|
+
property({ type: Boolean, attribute: 'hover-disabled' })
|
|
481
|
+
], ExmNavigationBase.prototype, "hoverDisabled", void 0);
|
|
482
|
+
__decorate([
|
|
483
|
+
property({ type: Boolean, attribute: 'collapse-on-desktop' })
|
|
484
|
+
], ExmNavigationBase.prototype, "collapseOnDesktop", void 0);
|
|
435
485
|
__decorate([
|
|
436
486
|
query('exm-navigation-drawer')
|
|
437
487
|
], ExmNavigationBase.prototype, "drawer", void 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exmg/exm-navigation",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "ce33f79e394b6a6635b74a6551032880aebfdf5e"
|
|
51
51
|
}
|