@exmg/exm-navigation 1.1.1 → 1.1.3
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/package.json +2 -2
- package/src/exm-navigation-base.d.ts +2 -0
- package/src/exm-navigation-base.js +30 -3
- package/src/exm-navigation-drawer-base.js +3 -1
- package/src/exm-navigation-sub-menu-base.d.ts +1 -0
- package/src/exm-navigation-sub-menu-base.js +7 -1
- package/src/mixins/media-queries.js +2 -2
- package/src/styles/exm-navigation-css.js +10 -0
- package/src/styles/exm-navigation-icon-button-css.js +5 -3
- package/src/styles/exm-navigation-sub-menu-css.js +8 -0
- package/src/styles/exm-navigation-topbar-css.js +3 -2
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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exmg/exm-navigation",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "b00599f5b5bfb37b7bd248e612d461db1f2cdb63"
|
|
55
55
|
}
|
|
@@ -15,6 +15,7 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
15
15
|
items: MenuItem[];
|
|
16
16
|
path: string[];
|
|
17
17
|
drawerWidth: number;
|
|
18
|
+
disableNavigate: boolean;
|
|
18
19
|
drawer?: ExmNavigationDrawer;
|
|
19
20
|
navContent?: HTMLDivElement;
|
|
20
21
|
persistent: boolean;
|
|
@@ -37,6 +38,7 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
|
|
|
37
38
|
* Set the correct values when the media changes.
|
|
38
39
|
*/
|
|
39
40
|
handleMediaTypeChange(): void;
|
|
41
|
+
private getPathEndpoint;
|
|
40
42
|
loadPage(path: string[]): void;
|
|
41
43
|
/**
|
|
42
44
|
* Handle Rail item click or Drawer sub menu click.
|
|
@@ -19,6 +19,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
19
19
|
this.items = [];
|
|
20
20
|
this.path = ['chat'];
|
|
21
21
|
this.drawerWidth = 319;
|
|
22
|
+
this.disableNavigate = false;
|
|
22
23
|
this.persistent = true;
|
|
23
24
|
this.selectedItem = [];
|
|
24
25
|
this.activeItem = [];
|
|
@@ -61,10 +62,30 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
61
62
|
this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.selectedItem[0]];
|
|
62
63
|
this.railOpen = this.media !== 'mobile';
|
|
63
64
|
}
|
|
65
|
+
getPathEndpoint() {
|
|
66
|
+
let items = this.items;
|
|
67
|
+
let result;
|
|
68
|
+
const checkItems = (path, last) => {
|
|
69
|
+
const item = items.find((item) => item.id === path);
|
|
70
|
+
if (last) {
|
|
71
|
+
return (item === null || item === void 0 ? void 0 : item.path) || '/';
|
|
72
|
+
}
|
|
73
|
+
items = (item === null || item === void 0 ? void 0 : item.items) || [];
|
|
74
|
+
return;
|
|
75
|
+
};
|
|
76
|
+
for (let i = 0; i < this.selectedItem.length; i++) {
|
|
77
|
+
result = checkItems(this.selectedItem[i], i === this.selectedItem.length - 1);
|
|
78
|
+
}
|
|
79
|
+
return result || window.location.href;
|
|
80
|
+
}
|
|
64
81
|
loadPage(path) {
|
|
65
82
|
this.path = path;
|
|
66
83
|
this.selectedItem = path;
|
|
67
84
|
this.fire('navigation-change', path);
|
|
85
|
+
if (!this.disableNavigate) {
|
|
86
|
+
window.history.pushState({}, '', this.getPathEndpoint());
|
|
87
|
+
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
88
|
+
}
|
|
68
89
|
}
|
|
69
90
|
/**
|
|
70
91
|
* Handle Rail item click or Drawer sub menu click.
|
|
@@ -152,6 +173,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
152
173
|
if ((!this.railOpen || !this.persistent) && !this.currentSelectedHasChildren(detail)) {
|
|
153
174
|
this.drawerOpen = false;
|
|
154
175
|
}
|
|
176
|
+
this.loadPage(this.selectedItem);
|
|
155
177
|
}
|
|
156
178
|
/**
|
|
157
179
|
* Handle the topbar menu click.
|
|
@@ -186,7 +208,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
186
208
|
renderDrawerMenuButton() {
|
|
187
209
|
return !this.railOpen
|
|
188
210
|
? html `
|
|
189
|
-
<section>
|
|
211
|
+
<section class="drawer-menu-button">
|
|
190
212
|
<exm-navigation-icon-button
|
|
191
213
|
icon=${this.drawerOpen ? 'menu_open' : 'menu'}
|
|
192
214
|
@navigation-icon-button-click=${this.handleTopbarMenuClick}
|
|
@@ -210,7 +232,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
210
232
|
></exm-navigation-drawer-menu>`
|
|
211
233
|
: !this.railOpen
|
|
212
234
|
? html `
|
|
213
|
-
<section>
|
|
235
|
+
<section class="drawer-back-button">
|
|
214
236
|
<exm-navigation-icon-button
|
|
215
237
|
icon="arrow_back"
|
|
216
238
|
label="Main menu"
|
|
@@ -228,6 +250,9 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
228
250
|
<exm-navigation-sub-menu
|
|
229
251
|
.items=${this.items}
|
|
230
252
|
.path=${this.activeItem}
|
|
253
|
+
?has-back-button=${!this.railOpen &&
|
|
254
|
+
(this.activeItem.length > 1 ||
|
|
255
|
+
(this.activeItem.length > 0 && this.currentSelectedHasChildren(this.activeItem)))}
|
|
231
256
|
@sub-menu-item-click=${this.handleSubMenuClick}
|
|
232
257
|
></exm-navigation-sub-menu>
|
|
233
258
|
`;
|
|
@@ -276,7 +301,6 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
|
|
|
276
301
|
<slot></slot>
|
|
277
302
|
</section>
|
|
278
303
|
</section>
|
|
279
|
-
<slot></slot>
|
|
280
304
|
`;
|
|
281
305
|
}
|
|
282
306
|
}
|
|
@@ -290,6 +314,9 @@ __decorate([
|
|
|
290
314
|
__decorate([
|
|
291
315
|
property({ type: Number, attribute: 'drawer-width' })
|
|
292
316
|
], ExmNavigationBase.prototype, "drawerWidth", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
property({ type: Boolean, attribute: 'disable-navigation' })
|
|
319
|
+
], ExmNavigationBase.prototype, "disableNavigate", void 0);
|
|
293
320
|
__decorate([
|
|
294
321
|
query('exm-navigation-drawer')
|
|
295
322
|
], ExmNavigationBase.prototype, "drawer", 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];
|
|
@@ -8,6 +8,7 @@ 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'];
|
|
12
13
|
static styles: import("lit").CSSResult[];
|
|
13
14
|
protected updated(changedProperties: PropertyValues): void;
|
|
@@ -8,11 +8,13 @@ import './exm-navigation-rail-nav-item.js';
|
|
|
8
8
|
import './exm-navigation-drawer-nav-item.js';
|
|
9
9
|
import '@material/web/list/list.js';
|
|
10
10
|
import '@exmg/exm-collapsed/exm-collapsed.js';
|
|
11
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
11
12
|
export class ExmNavigationSubMenuBase extends ExmgElement {
|
|
12
13
|
constructor() {
|
|
13
14
|
super(...arguments);
|
|
14
15
|
this.items = [];
|
|
15
16
|
this.path = [];
|
|
17
|
+
this.hasBackButton = false;
|
|
16
18
|
}
|
|
17
19
|
updated(changedProperties) {
|
|
18
20
|
var _a;
|
|
@@ -56,8 +58,9 @@ export class ExmNavigationSubMenuBase extends ExmgElement {
|
|
|
56
58
|
`;
|
|
57
59
|
}
|
|
58
60
|
render() {
|
|
61
|
+
const navClass = { nav: true, 'has-back-button': this.hasBackButton };
|
|
59
62
|
return html `<div class="top"><slot name="top"></slot></div>
|
|
60
|
-
<nav class
|
|
63
|
+
<nav class=${classMap(navClass)}>
|
|
61
64
|
<md-list>
|
|
62
65
|
${repeat(this.currentItem || [], ({ id }) => id, (item) => (item.items || []).length === 0
|
|
63
66
|
? html `
|
|
@@ -82,6 +85,9 @@ __decorate([
|
|
|
82
85
|
__decorate([
|
|
83
86
|
property({ type: Array })
|
|
84
87
|
], ExmNavigationSubMenuBase.prototype, "path", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
property({ type: Boolean, attribute: 'has-back-button' })
|
|
90
|
+
], ExmNavigationSubMenuBase.prototype, "hasBackButton", void 0);
|
|
85
91
|
__decorate([
|
|
86
92
|
state()
|
|
87
93
|
], ExmNavigationSubMenuBase.prototype, "currentItem", void 0);
|
|
@@ -5,8 +5,8 @@ export const MediaQueries = (superClass) => {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
super(...arguments);
|
|
7
7
|
this.media = 'desktop';
|
|
8
|
-
this.mobileMedia = window.matchMedia('(max-width:
|
|
9
|
-
this.tabletMedia = window.matchMedia('(min-width:
|
|
8
|
+
this.mobileMedia = window.matchMedia('(max-width: 960px)');
|
|
9
|
+
this.tabletMedia = window.matchMedia('(min-width: 961px) and (max-width: 1200px)');
|
|
10
10
|
this.desktopMedia = window.matchMedia('(min-width: 1201px)');
|
|
11
11
|
}
|
|
12
12
|
updateMedia(media) {
|
|
@@ -6,6 +6,7 @@ export const style = css `
|
|
|
6
6
|
grid-template-rows: 1fr;
|
|
7
7
|
width: 100%;
|
|
8
8
|
transition: grid-template-columns 0.3s ease;
|
|
9
|
+
max-height: 100vh;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
.navigation-container.show-topbar {
|
|
@@ -37,6 +38,7 @@ export const style = css `
|
|
|
37
38
|
.content {
|
|
38
39
|
grid-area: 1/3/2/4;
|
|
39
40
|
z-index: 1;
|
|
41
|
+
overflow: scroll;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
exm-navigation-drawer {
|
|
@@ -52,5 +54,13 @@ export const style = css `
|
|
|
52
54
|
.left-margin {
|
|
53
55
|
margin-left: 2.5rem;
|
|
54
56
|
}
|
|
57
|
+
|
|
58
|
+
.drawer-menu-button {
|
|
59
|
+
padding: 8px 12px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.drawer-back-button {
|
|
63
|
+
padding: 8px 12px 0;
|
|
64
|
+
}
|
|
55
65
|
`;
|
|
56
66
|
//# sourceMappingURL=exm-navigation-css.js.map
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
2
|
export const style = css `
|
|
3
3
|
.icon-button {
|
|
4
|
+
display: inline-grid;
|
|
5
|
+
grid-template-columns: 48px;
|
|
4
6
|
border: none;
|
|
5
7
|
background-color: rgba(0, 0, 0, 0);
|
|
6
8
|
color: #fff;
|
|
7
|
-
width: 48px;
|
|
8
9
|
height: 48px;
|
|
9
|
-
display: flex;
|
|
10
10
|
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
padding: 0;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
.icon-button.has-label {
|
|
14
|
-
|
|
16
|
+
grid-template-columns: 48px auto;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
.icon-button .label {
|
|
@@ -8,6 +8,10 @@ export const style = css `
|
|
|
8
8
|
--_exm-navigation-item-color-selected: var(--exm-navigation-item-color-selected, var(--md-sys-color-on-secondary));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
md-list {
|
|
12
|
+
padding-top: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
11
15
|
md-list-item {
|
|
12
16
|
margin-right: 8px;
|
|
13
17
|
margin-left: 8px;
|
|
@@ -31,6 +35,10 @@ export const style = css `
|
|
|
31
35
|
color: var(--md-sys-color-primary);
|
|
32
36
|
}
|
|
33
37
|
|
|
38
|
+
.has-back-button {
|
|
39
|
+
padding-left: 44px;
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
.sub-menu {
|
|
35
43
|
margin-left: 1rem;
|
|
36
44
|
}
|
|
@@ -9,11 +9,12 @@ export const style = css `
|
|
|
9
9
|
background: var(--_exm-navigation-rail-background-color);
|
|
10
10
|
box-sizing: border-box;
|
|
11
11
|
display: grid;
|
|
12
|
-
grid-template-columns:
|
|
12
|
+
grid-template-columns: auto 1fr auto;
|
|
13
13
|
height: var(--_exm-navigation-top-bar-height);
|
|
14
|
-
gap:
|
|
14
|
+
gap: 16px;
|
|
15
15
|
justify-content: space-between;
|
|
16
16
|
width: 100%;
|
|
17
|
+
padding: 8px 12px;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
exm-navigation-icon-button {
|