@exmg/exm-navigation 1.1.9-alpha.0 → 1.1.10-alpha.19

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 CHANGED
@@ -59,7 +59,9 @@ Some of the components used in the navigation c an be used separately. Please ch
59
59
  interface MenuItem {
60
60
  id: string;
61
61
  label: string;
62
+ type?: 'separator' | 'default';
62
63
  path?: string;
64
+ additionalPath?: Regexp;
63
65
  url?: string;
64
66
  icon?: string;
65
67
  items?: MenuItem[];
@@ -10,6 +10,8 @@ import './exm-navigation-rail.js';
10
10
  import './exm-navigation-sub-menu.js';
11
11
  import './exm-navigation-drawer-menu.js';
12
12
  import './exm-navigation-drawer.js';
13
+ import '@material/web/icon/icon.js';
14
+ import '@material/web/iconbutton/icon-button.js';
13
15
  declare const ExmNavigationBase_base: (new (...args: any[]) => {
14
16
  media: "mobile" | "tablet" | "desktop";
15
17
  touch: boolean;
@@ -14,13 +14,15 @@ import './exm-navigation-rail.js';
14
14
  import './exm-navigation-sub-menu.js';
15
15
  import './exm-navigation-drawer-menu.js';
16
16
  import './exm-navigation-drawer.js';
17
+ import '@material/web/icon/icon.js';
18
+ import '@material/web/iconbutton/icon-button.js';
17
19
  // eslint-disable-next-line new-cap
18
20
  export class ExmNavigationBase extends MediaQueries(ExmgElement) {
19
21
  constructor() {
20
22
  super();
21
23
  this.items = [];
22
24
  this.path = ['chat'];
23
- this.drawerWidth = 319;
25
+ this.drawerWidth = 275;
24
26
  this.disableNavigate = false;
25
27
  /**
26
28
  * The menu item triggered by hovering and entering submenu's
@@ -78,11 +80,15 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
78
80
  path = [];
79
81
  }
80
82
  path[depth] = item.id;
81
- if (item.path === window.location.pathname) {
83
+ if (item.path === window.location.pathname || `${item.path}/` === window.location.pathname) {
84
+ finished = true;
85
+ break;
86
+ }
87
+ if (item.additionalPath && item.additionalPath.test(window.location.pathname)) {
82
88
  finished = true;
83
89
  break;
84
90
  }
85
- if ((item.items || []).length > 0) {
91
+ if (item.items && (item.items || []).length > 0) {
86
92
  checkItems(item.items, depth + 1);
87
93
  }
88
94
  }
@@ -91,6 +97,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
91
97
  this.path = path;
92
98
  this.selectedItem = path;
93
99
  this.activeItem = path;
100
+ this.handleDrawerOpen();
94
101
  }
95
102
  updated(changedProperties) {
96
103
  if (changedProperties.has('media')) {
@@ -109,6 +116,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
109
116
  if (changedProperties.has('media')) {
110
117
  this.handleMediaTypeChange.bind(this)();
111
118
  }
119
+ document.documentElement.style.setProperty('--exm-navigation-submenu-width', `${this.drawerWidth}px`);
112
120
  /**
113
121
  * Set the start path
114
122
  */
@@ -191,7 +199,14 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
191
199
  */
192
200
  handleRailItemClick({ detail }) {
193
201
  var _a;
194
- if (this.activeItem[0] !== detail || this.media !== 'desktop') {
202
+ const item = this.items.find((item) => item.id === this.activeItem[0]);
203
+ /**
204
+ * If this is the current item, skip it.
205
+ * 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
206
+ */
207
+ if (this.activeItem[0] !== detail ||
208
+ (this.activeItem[0] === detail && (item === null || item === void 0 ? void 0 : item.additionalPath)) ||
209
+ this.media !== 'desktop') {
195
210
  const items = ((_a = this.items.find((item) => item.id === detail)) === null || _a === void 0 ? void 0 : _a.items) || [];
196
211
  if (items.length && !this.touch) {
197
212
  this.selectedItem = [detail, items[0].id];
@@ -386,7 +401,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
386
401
  }
387
402
  render() {
388
403
  const containerStyle = {
389
- '--exm-drawer-width': `${this.getDrawerWidth()}px`,
404
+ '--exm-navigation-submenu-column-width': `${this.getDrawerWidth()}px`,
390
405
  };
391
406
  const containerClass = { 'show-topbar': !this.railOpen };
392
407
  return html `
@@ -5,6 +5,7 @@ import { property } from 'lit/decorators.js';
5
5
  import { repeat } from 'lit/directives/repeat.js';
6
6
  import { style } from './styles/exm-navigation-rail-css.js';
7
7
  import './exm-navigation-rail-nav-item.js';
8
+ import { classMap } from 'lit/directives/class-map.js';
8
9
  export class ExmNavigationRailBase extends ExmgElement {
9
10
  constructor() {
10
11
  super(...arguments);
@@ -25,20 +26,26 @@ export class ExmNavigationRailBase extends ExmgElement {
25
26
  <nav class="nav">
26
27
  <ul>
27
28
  ${repeat(this.items, (item) => {
28
- return html `
29
- <li>
30
- <exm-navigation-rail-nav-item
31
- @click=${() => this.handleRailClick(item.id)}
32
- @mouseenter=${() => this.handleRailMouseEnter(item.id)}
33
- @mouseleave=${() => this.handleRailMouseLeave(item.id)}
34
- label=${item.label}
35
- icon=${item.icon || ''}
36
- ?hasSubMenu=${(item.items || []).length > 0}
37
- itemId=${item.id}
38
- .selected=${this.selected[0] === item.id}
39
- ></exm-navigation-rail-nav-item>
40
- </li>
41
- `;
29
+ if (item.type === 'separator') {
30
+ return html ` <li class="rail-separator"></li> `;
31
+ }
32
+ else {
33
+ const classes = { hidden: item.type === 'hidden' };
34
+ return html `
35
+ <li class=${classMap(classes)}>
36
+ <exm-navigation-rail-nav-item
37
+ @click=${() => this.handleRailClick(item.id)}
38
+ @mouseenter=${() => this.handleRailMouseEnter(item.id)}
39
+ @mouseleave=${() => this.handleRailMouseLeave(item.id)}
40
+ label=${item.label}
41
+ icon=${item.icon || ''}
42
+ ?hasSubMenu=${(item.items || []).length > 0}
43
+ itemId=${item.id}
44
+ .selected=${this.selected[0] === item.id}
45
+ ></exm-navigation-rail-nav-item>
46
+ </li>
47
+ `;
48
+ }
42
49
  })}
43
50
  </ul>
44
51
  </nav>
@@ -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: 1200px)');
11
- this.desktopMedia = window.matchMedia('(min-width: 1201px)');
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) {
@@ -1,8 +1,12 @@
1
1
  import { css } from 'lit';
2
2
  export const style = css `
3
+ :host {
4
+ --_exm-navigation-drawer-shape: var(--exm-navigation-drawer-shape, 1rem);
5
+ }
6
+
3
7
  .navigation-container {
4
8
  display: grid;
5
- grid-template-columns: auto var(--exm-drawer-width, 500px) 1fr;
9
+ grid-template-columns: auto var(--exm-navigation-submenu-column-width, 500px) 1fr;
6
10
  grid-template-rows: 1fr;
7
11
  width: 100%;
8
12
  transition: grid-template-columns 0.3s ease;
@@ -48,7 +52,6 @@ export const style = css `
48
52
  --md-list-item-trailing-supporting-text-color: var(--md-sys-color-on-surface-variant);
49
53
  --md-list-item-container-shape: 24px;
50
54
  --mdc-theme-surface: var(--md-sys-color-surface-container-high);
51
- --mdc-shape-large: 1rem;
52
55
  }
53
56
 
54
57
  .left-margin {
@@ -1,13 +1,10 @@
1
1
  import { css } from 'lit';
2
2
  export const style = css `
3
- :root {
4
- --md-sys-color-background: var(--md-sys-color-surface-container-high);
5
- }
6
-
7
3
  :host {
8
- --exm-drawer-max-width: 319px;
4
+ --md-sys-color-background: var(--md-sys-color-surface-container-high);
5
+ --_exm-navigation-submenu-width: var(--exm-navigation-submenu-width);
9
6
  display: grid;
10
- grid-template-columns: var(--mdc-drawer-width, 300px) 1fr;
7
+ grid-template-columns: var(--_exm-navigation-submenu-width, 300px) 1fr;
11
8
  height: 100vh;
12
9
  width: 100%;
13
10
  box-sizing: border-box;
@@ -17,15 +14,15 @@ export const style = css `
17
14
 
18
15
  aside {
19
16
  position: absolute;
20
- left: calc(-1 * var(--exm-drawer-max-width, 300px) - 1px);
21
- width: var(--exm-drawer-max-width, 300px);
17
+ left: calc(-1 * var(--_exm-navigation-submenu-width, 300px) - 1px);
18
+ width: var(--_exm-navigation-submenu-width, 300px);
22
19
  height: 100%;
23
20
  transition: left 0.3s ease-out;
24
21
  z-index: 4;
25
22
  background-color: var(--exm-drawer-container-color, var(--md-sys-color-surface-container, #f3edf7));
26
- color: var(--exm-drawer-container-on-color, var(--md-sys-color-on-surface-container, #f3edf7));
27
- border-radius: 0 var(--mdc-shape-large, 0) var(--mdc-shape-large, 0) 0;
28
- border-left: 1px solid var(--md-sys-color-outline);
23
+ color: var(--exm-drawer-container-on-color, var(--md-sys-color-on-surface, #f3edf7));
24
+ border-radius: 0 var(--_exm-navigation-drawer-shape, 0) var(--_exm-navigation-drawer-shape, 0) 0;
25
+ border-left: 1px solid var(--md-sys-color-outline-variant);
29
26
 
30
27
  &.open {
31
28
  left: 0;
@@ -46,5 +46,14 @@ export const style = css `
46
46
  flex-grow: 1;
47
47
  justify-content: flex-end;
48
48
  }
49
+
50
+ .rail-separator {
51
+ border-bottom: 1px solid var(--md-sys-color-outline-variant);
52
+ margin: -2px 16px 14px;
53
+ }
54
+
55
+ .hidden {
56
+ display: none;
57
+ }
49
58
  `;
50
59
  //# sourceMappingURL=exm-navigation-rail-css.js.map
package/dist/types.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export interface MenuItem {
2
2
  id: string;
3
3
  label: string;
4
+ type?: 'separator' | 'default' | 'hidden';
4
5
  path?: string;
6
+ additionalPath?: RegExp;
5
7
  url?: string;
6
8
  icon?: string;
7
9
  items?: MenuItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exmg/exm-navigation",
3
- "version": "1.1.9-alpha.0",
3
+ "version": "1.1.10-alpha.19+20be399",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,20 +15,17 @@
15
15
  "./exm-navigation-icon-button.js": "./dist/exm-navigation-icon-button.js",
16
16
  "./exm-navigation-rail.js": "./dist/exm-navigation-rail.js",
17
17
  "./exm-navigation-rail-nav-item.js": "./dist/exm-navigation-rail-nav-item.js",
18
- "./exm-navigation-topbar.js": "./dist/exm-navigation-topbar.js",
19
- "./exm-navigation-base.js": "./dist/ExmNavigationBase.js"
18
+ "./exm-navigation-topbar.js": "./dist/exm-navigation-topbar.js"
20
19
  },
21
20
  "dependencies": {
22
- "@exmg/lit-base": "^3.0.0",
23
- "@lit-labs/motion": "^1.0.7",
24
- "@material/mwc-top-app-bar-fixed": "^0.27.0",
21
+ "@lit-labs/motion": "^1.0.7"
22
+ },
23
+ "peerDependencies": {
24
+ "@exmg/lit-base": "^3.0.3",
25
25
  "@material/web": "^2.2.0",
26
- "lit": "^3.0.0",
26
+ "lit": "^3.2.1",
27
27
  "tslib": "^2.6.2"
28
28
  },
29
- "devDependencies": {
30
- "@exmg/lit-cli": "1.1.13"
31
- },
32
29
  "keywords": [
33
30
  "web-components",
34
31
  "lit",
@@ -50,5 +47,5 @@
50
47
  "publishConfig": {
51
48
  "access": "public"
52
49
  },
53
- "gitHead": "1973df6ecaaf0a57b688f5eb8852516295bc04d6"
50
+ "gitHead": "20be399892ecc54f71f080f17a677a370d9f2b9c"
54
51
  }