@exmg/exm-navigation 1.1.9 → 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,6 +14,8 @@ 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() {
@@ -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) {
82
84
  finished = true;
83
85
  break;
84
86
  }
85
- if ((item.items || []).length > 0) {
87
+ if (item.additionalPath && item.additionalPath.test(window.location.pathname)) {
88
+ finished = true;
89
+ break;
90
+ }
91
+ if (item.items && (item.items || []).length > 0) {
86
92
  checkItems(item.items, depth + 1);
87
93
  }
88
94
  }
@@ -110,6 +116,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
110
116
  if (changedProperties.has('media')) {
111
117
  this.handleMediaTypeChange.bind(this)();
112
118
  }
119
+ document.documentElement.style.setProperty('--exm-navigation-submenu-width', `${this.drawerWidth}px`);
113
120
  /**
114
121
  * Set the start path
115
122
  */
@@ -192,7 +199,14 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
192
199
  */
193
200
  handleRailItemClick({ detail }) {
194
201
  var _a;
195
- 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') {
196
210
  const items = ((_a = this.items.find((item) => item.id === detail)) === null || _a === void 0 ? void 0 : _a.items) || [];
197
211
  if (items.length && !this.touch) {
198
212
  this.selectedItem = [detail, items[0].id];
@@ -387,7 +401,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
387
401
  }
388
402
  render() {
389
403
  const containerStyle = {
390
- '--exm-drawer-width': `${this.getDrawerWidth()}px`,
404
+ '--exm-navigation-submenu-column-width': `${this.getDrawerWidth()}px`,
391
405
  };
392
406
  const containerClass = { 'show-topbar': !this.railOpen };
393
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>
@@ -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
- --exm-drawer-max-width: 319px;
6
- }
7
-
8
3
  :host {
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",
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": "ac876ab3f3d6d83a43a3944c052c8e71de300832"
50
+ "gitHead": "20be399892ecc54f71f080f17a677a370d9f2b9c"
54
51
  }