@exmg/exm-navigation 1.1.2 → 1.1.4-alpha.2

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.
Files changed (90) hide show
  1. package/{src → dist}/exm-navigation-base.d.ts +34 -10
  2. package/{src → dist}/exm-navigation-base.js +132 -87
  3. package/{src → dist}/exm-navigation-drawer-base.d.ts +1 -4
  4. package/{src → dist}/exm-navigation-drawer-base.js +9 -8
  5. package/{src → dist}/exm-navigation-drawer-nav-item-base.js +12 -8
  6. package/{src → dist}/exm-navigation-icon-button-base.js +2 -0
  7. package/{src → dist}/exm-navigation-sub-menu-base.d.ts +10 -0
  8. package/{src → dist}/exm-navigation-sub-menu-base.js +71 -12
  9. package/{src → dist}/exm-navigation-topbar-base.js +3 -4
  10. package/dist/index.d.ts +12 -0
  11. package/dist/index.js +13 -0
  12. package/{src → dist}/mixins/media-queries.d.ts +1 -0
  13. package/{src → dist}/mixins/media-queries.js +14 -1
  14. package/{src → dist}/styles/exm-navigation-css.js +8 -2
  15. package/dist/styles/exm-navigation-drawer-css.js +35 -0
  16. package/dist/styles/exm-navigation-drawer-nav-item-css.js +84 -0
  17. package/{src → dist}/styles/exm-navigation-icon-button-css.js +6 -2
  18. package/{src → dist}/styles/exm-navigation-rail-css.js +1 -0
  19. package/dist/styles/exm-navigation-sub-menu-css.js +21 -0
  20. package/{src → dist}/styles/exm-navigation-topbar-css.js +1 -1
  21. package/package.json +20 -21
  22. package/index.d.ts +0 -12
  23. package/index.js +0 -13
  24. package/src/exm-navigation-drawer-nav.d.ts +0 -9
  25. package/src/exm-navigation-drawer-nav.js +0 -47
  26. package/src/exm-navigation-rail-nav-base.d.ts +0 -4
  27. package/src/exm-navigation-rail-nav-base.js +0 -9
  28. package/src/exm-navigation-rail-nav.d.ts +0 -9
  29. package/src/exm-navigation-rail-nav.js +0 -12
  30. package/src/exm-navigation-signals.d.ts +0 -11
  31. package/src/exm-navigation-signals.js +0 -11
  32. package/src/exm-navigation-toolbar-base.d.ts +0 -8
  33. package/src/exm-navigation-toolbar-base.js +0 -33
  34. package/src/exm-navigation-toolbar.d.ts +0 -9
  35. package/src/exm-navigation-toolbar.js +0 -12
  36. package/src/styles/exm-navigate-drawer-nav-item-css.d.ts +0 -1
  37. package/src/styles/exm-navigate-drawer-nav-item-css.js +0 -40
  38. package/src/styles/exm-navigation-drawer-css.js +0 -24
  39. package/src/styles/exm-navigation-drawer-nav-item-css.js +0 -40
  40. package/src/styles/exm-navigation-rail-nav-css.d.ts +0 -2
  41. package/src/styles/exm-navigation-rail-nav-css.js +0 -4
  42. package/src/styles/exm-navigation-styles-css.d.ts +0 -2
  43. package/src/styles/exm-navigation-styles-css.js +0 -4
  44. package/src/styles/exm-navigation-sub-menu-css.js +0 -46
  45. package/src/styles/exm-navigation-toolbar-css.d.ts +0 -2
  46. package/src/styles/exm-navigation-toolbar-css.js +0 -4
  47. /package/{src → dist}/exm-navigation-drawer-menu-base.d.ts +0 -0
  48. /package/{src → dist}/exm-navigation-drawer-menu-base.js +0 -0
  49. /package/{src → dist}/exm-navigation-drawer-menu.d.ts +0 -0
  50. /package/{src → dist}/exm-navigation-drawer-menu.js +0 -0
  51. /package/{src → dist}/exm-navigation-drawer-nav-item-base.d.ts +0 -0
  52. /package/{src → dist}/exm-navigation-drawer-nav-item.d.ts +0 -0
  53. /package/{src → dist}/exm-navigation-drawer-nav-item.js +0 -0
  54. /package/{src → dist}/exm-navigation-drawer.d.ts +0 -0
  55. /package/{src → dist}/exm-navigation-drawer.js +0 -0
  56. /package/{src → dist}/exm-navigation-icon-base.d.ts +0 -0
  57. /package/{src → dist}/exm-navigation-icon-base.js +0 -0
  58. /package/{src → dist}/exm-navigation-icon-button-base.d.ts +0 -0
  59. /package/{src → dist}/exm-navigation-icon-button.d.ts +0 -0
  60. /package/{src → dist}/exm-navigation-icon-button.js +0 -0
  61. /package/{src → dist}/exm-navigation-icon.d.ts +0 -0
  62. /package/{src → dist}/exm-navigation-icon.js +0 -0
  63. /package/{src → dist}/exm-navigation-rail-base.d.ts +0 -0
  64. /package/{src → dist}/exm-navigation-rail-base.js +0 -0
  65. /package/{src → dist}/exm-navigation-rail-nav-item-base.d.ts +0 -0
  66. /package/{src → dist}/exm-navigation-rail-nav-item-base.js +0 -0
  67. /package/{src → dist}/exm-navigation-rail-nav-item.d.ts +0 -0
  68. /package/{src → dist}/exm-navigation-rail-nav-item.js +0 -0
  69. /package/{src → dist}/exm-navigation-rail.d.ts +0 -0
  70. /package/{src → dist}/exm-navigation-rail.js +0 -0
  71. /package/{src → dist}/exm-navigation-sub-menu.d.ts +0 -0
  72. /package/{src → dist}/exm-navigation-sub-menu.js +0 -0
  73. /package/{src → dist}/exm-navigation-topbar-base.d.ts +0 -0
  74. /package/{src → dist}/exm-navigation-topbar.d.ts +0 -0
  75. /package/{src → dist}/exm-navigation-topbar.js +0 -0
  76. /package/{src → dist}/exm-navigation.d.ts +0 -0
  77. /package/{src → dist}/exm-navigation.js +0 -0
  78. /package/{src → dist}/styles/exm-navigation-css.d.ts +0 -0
  79. /package/{src → dist}/styles/exm-navigation-drawer-css.d.ts +0 -0
  80. /package/{src → dist}/styles/exm-navigation-drawer-nav-item-css.d.ts +0 -0
  81. /package/{src → dist}/styles/exm-navigation-icon-button-css.d.ts +0 -0
  82. /package/{src → dist}/styles/exm-navigation-icon-css.d.ts +0 -0
  83. /package/{src → dist}/styles/exm-navigation-icon-css.js +0 -0
  84. /package/{src → dist}/styles/exm-navigation-rail-css.d.ts +0 -0
  85. /package/{src → dist}/styles/exm-navigation-rail-nav-item-css.d.ts +0 -0
  86. /package/{src → dist}/styles/exm-navigation-rail-nav-item-css.js +0 -0
  87. /package/{src → dist}/styles/exm-navigation-sub-menu-css.d.ts +0 -0
  88. /package/{src → dist}/styles/exm-navigation-topbar-css.d.ts +0 -0
  89. /package/{src → dist}/types.d.ts +0 -0
  90. /package/{src → dist}/types.js +0 -0
@@ -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,6 +12,7 @@ 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[];
@@ -18,32 +21,46 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
18
21
  disableNavigate: boolean;
19
22
  drawer?: ExmNavigationDrawer;
20
23
  navContent?: HTMLDivElement;
21
- persistent: boolean;
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
+ */
22
28
  selectedItem: string[];
29
+ /**
30
+ * The currently active menu item
31
+ */
23
32
  activeItem: string[];
33
+ /**
34
+ * Wether or not the rail should be visible yes or no
35
+ */
24
36
  railOpen: boolean;
37
+ /**
38
+ * Wether or not the drawer should be visible yes or no
39
+ */
25
40
  drawerOpen: boolean;
26
- drawerHover: boolean;
41
+ /**
42
+ * Object with menuitem and a bool for having that path sub items yes or no
43
+ */
27
44
  navigationHasSubmenu: Record<string, boolean>;
28
45
  static styles: import("lit").CSSResult[];
29
- menu: MenuItem[];
30
- expandedItems: {
31
- [k: string]: boolean;
32
- };
33
- unSubscribeSelected: () => void;
34
46
  protected updated(changedProperties: PropertyValues): void;
35
47
  protected firstUpdated(changedProperties: PropertyValues): void;
36
48
  connectedCallback(): void;
37
49
  /**
38
50
  * Set the correct values when the media changes.
39
51
  */
40
- handleMediaTypeChange(): void;
52
+ private handleMediaTypeChange;
41
53
  private getPathEndpoint;
42
- loadPage(path: string[]): void;
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;
43
60
  /**
44
61
  * Handle Rail item click or Drawer sub menu click.
45
62
  * If the selected menu item has children, we add the first item to the list (as per Google implementation).
46
- * In this case we also do not close the drawer in non persistent mode, so the user is able to select a next level in the menu
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
47
64
  */
48
65
  private handleRailItemClick;
49
66
  /**
@@ -102,6 +119,13 @@ export declare class ExmNavigationBase extends ExmNavigationBase_base {
102
119
  * Render the topbar. This is displayed on mobile and contains the menu button and a slot for the title
103
120
  */
104
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;
105
129
  render(): import("lit-html").TemplateResult<1>;
106
130
  }
107
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';
@@ -20,16 +22,27 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
20
22
  this.path = ['chat'];
21
23
  this.drawerWidth = 319;
22
24
  this.disableNavigate = false;
23
- this.persistent = true;
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
+ */
24
29
  this.selectedItem = [];
30
+ /**
31
+ * The currently active menu item
32
+ */
25
33
  this.activeItem = [];
34
+ /**
35
+ * Wether or not the rail should be visible yes or no
36
+ */
26
37
  this.railOpen = true;
38
+ /**
39
+ * Wether or not the drawer should be visible yes or no
40
+ */
27
41
  this.drawerOpen = false;
28
- this.drawerHover = false;
42
+ /**
43
+ * Object with menuitem and a bool for having that path sub items yes or no
44
+ */
29
45
  this.navigationHasSubmenu = {};
30
- this.menu = [];
31
- this.expandedItems = {};
32
- this.unSubscribeSelected = () => { };
33
46
  }
34
47
  updated(changedProperties) {
35
48
  if (changedProperties.has('media')) {
@@ -39,7 +52,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
39
52
  for (const item of this.items) {
40
53
  this.navigationHasSubmenu[item.id] = (item.items || []).length > 0;
41
54
  }
42
- if (this.navigationHasSubmenu[this.path[0]] && this.persistent) {
55
+ if (this.navigationHasSubmenu[this.path[0]] && this.media === 'desktop') {
43
56
  this.drawerOpen = true;
44
57
  }
45
58
  }
@@ -58,8 +71,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
58
71
  * Set the correct values when the media changes.
59
72
  */
60
73
  handleMediaTypeChange() {
61
- this.persistent = this.media === 'desktop';
62
- this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.selectedItem[0]];
74
+ this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.activeItem[0]];
63
75
  this.railOpen = this.media !== 'mobile';
64
76
  }
65
77
  getPathEndpoint() {
@@ -68,7 +80,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
68
80
  const checkItems = (path, last) => {
69
81
  const item = items.find((item) => item.id === path);
70
82
  if (last) {
71
- return (item === null || item === void 0 ? void 0 : item.path) || '/';
83
+ return item === null || item === void 0 ? void 0 : item.path;
72
84
  }
73
85
  items = (item === null || item === void 0 ? void 0 : item.items) || [];
74
86
  return;
@@ -76,90 +88,94 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
76
88
  for (let i = 0; i < this.selectedItem.length; i++) {
77
89
  result = checkItems(this.selectedItem[i], i === this.selectedItem.length - 1);
78
90
  }
79
- return result || window.location.href;
91
+ return result;
80
92
  }
81
93
  loadPage(path) {
82
94
  this.path = path;
83
- this.selectedItem = path;
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
+ }
84
101
  this.fire('navigation-change', path);
85
102
  if (!this.disableNavigate) {
86
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
+ }
87
133
  }
88
134
  }
89
135
  /**
90
136
  * Handle Rail item click or Drawer sub menu click.
91
137
  * If the selected menu item has children, we add the first item to the list (as per Google implementation).
92
- * In this case we also do not close the drawer in non persistent mode, so the user is able to select a next level in the menu
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
93
139
  */
94
140
  handleRailItemClick({ detail }) {
95
141
  var _a;
96
- if (this.selectedItem[0] !== detail) {
142
+ if (this.activeItem[0] !== detail || this.media !== 'desktop') {
97
143
  const items = ((_a = this.items.find((item) => item.id === detail)) === null || _a === void 0 ? void 0 : _a.items) || [];
98
- if (items.length) {
144
+ if (items.length && !this.touch) {
99
145
  this.selectedItem = [detail, items[0].id];
100
146
  }
101
147
  else {
102
148
  this.selectedItem = [detail];
103
149
  }
104
- // copy the selected item to the active item
105
- this.activeItem = this.selectedItem;
106
- /**
107
- * If persistent menu close the drawer when a item is clicked and does not has children items
108
- */
109
- if (this.persistent) {
110
- this.drawerOpen = items.length > 0 || this.navigationHasSubmenu[detail];
111
- }
112
- else if (items.length === 0) {
113
- this.drawerOpen = false;
114
- }
115
150
  this.loadPage(this.selectedItem);
151
+ this.handleDrawerOpen();
116
152
  }
117
153
  }
118
154
  /**
119
155
  * Handle the mouse enter of the rail item.
120
156
  */
121
157
  handleRailItemMouseEnter({ detail }) {
122
- if (this.navigationHasSubmenu[detail]) {
123
- this.drawerOpen = true;
124
- if (detail !== this.selectedItem[0]) {
125
- this.activeItem = [detail];
126
- return;
127
- }
128
- }
129
- else if (this.navigationHasSubmenu[this.selectedItem[0]] && this.persistent) {
130
- this.activeItem = this.selectedItem;
131
- this.drawerOpen = true;
132
- }
133
- else {
134
- this.activeItem = this.selectedItem;
135
- this.drawerOpen = false;
158
+ if (this.touch) {
159
+ return;
136
160
  }
137
- this.activeItem = this.selectedItem;
161
+ this.selectedItem = [detail];
162
+ this.handleDrawerOpen();
138
163
  }
139
164
  /**
140
165
  * Handle the mouse leave of the rail item.
141
166
  * If the item has no submenu and the current selected item has no submenu, it is safe to close the drawer
142
167
  */
143
- handleRailItemMouseLeave({ detail }) {
144
- if (!this.navigationHasSubmenu[detail] && !this.navigationHasSubmenu[this.selectedItem[0]]) {
145
- this.drawerOpen = false;
146
- }
147
- if (!this.persistent && !this.navigationHasSubmenu[detail]) {
148
- this.drawerOpen = false;
149
- }
150
- }
168
+ handleRailItemMouseLeave() { }
151
169
  /**
152
170
  * Handle drawer mouse leave. Should close the drawer
153
171
  */
154
172
  handleDrawerMouseLeave() {
155
- if (!this.navigationHasSubmenu[this.selectedItem[0]] || !this.persistent) {
156
- this.drawerOpen = false;
157
- }
158
173
  /**
159
174
  * On mouse leave the drawer we want to set the active item to the selected item.
160
175
  * If not, it will show the active item on every hover and will make navigating in the selected item impossible
161
176
  */
162
- this.activeItem = this.selectedItem;
177
+ this.selectedItem = this.activeItem;
178
+ this.handleDrawerOpen({ tabletForce: true });
163
179
  }
164
180
  /**
165
181
  * Handle the click on a sub menu item
@@ -168,11 +184,13 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
168
184
  */
169
185
  handleSubMenuClick({ detail }) {
170
186
  this.selectedItem = detail;
171
- this.activeItem = detail;
172
- if ((!this.railOpen || !this.persistent) && !this.currentSelectedHasChildren(detail)) {
173
- this.drawerOpen = false;
187
+ const endPoint = this.getPathEndpoint();
188
+ let mobileForce = false;
189
+ if (endPoint) {
190
+ this.loadPage(this.selectedItem);
191
+ mobileForce = true;
174
192
  }
175
- this.loadPage(this.selectedItem);
193
+ this.handleDrawerOpen({ mobileForce, tabletForce: this.touch && !!endPoint });
176
194
  }
177
195
  /**
178
196
  * Handle the topbar menu click.
@@ -186,7 +204,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
186
204
  * This should reset the active item, so the root-level menu gets triggered
187
205
  */
188
206
  handleDrawerBackClick() {
189
- this.activeItem = [];
207
+ this.selectedItem = [];
190
208
  }
191
209
  /**
192
210
  * Check if the passed paths last item has children yes or no
@@ -208,10 +226,9 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
208
226
  return !this.railOpen
209
227
  ? html `
210
228
  <section class="drawer-menu-button">
211
- <exm-navigation-icon-button
212
- icon=${this.drawerOpen ? 'menu_open' : 'menu'}
213
- @navigation-icon-button-click=${this.handleTopbarMenuClick}
214
- ></exm-navigation-icon-button>
229
+ <md-icon-button @click=${this.handleTopbarMenuClick}>
230
+ <md-icon>${this.drawerOpen ? 'menu_open' : 'menu'}</md-icon>
231
+ </md-icon-button>
215
232
  </section>
216
233
  `
217
234
  : nothing;
@@ -221,37 +238,60 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
221
238
  * If more levels deep, show the back button
222
239
  */
223
240
  renderStartMenu() {
224
- return !this.railOpen &&
225
- (this.activeItem.length === 0 ||
226
- (this.activeItem.length === 1 && !this.currentSelectedHasChildren(this.activeItem)))
241
+ if (this.railOpen) {
242
+ return nothing;
243
+ }
244
+ return this.selectedItem.length === 0 ||
245
+ (this.selectedItem.length === 1 && !this.currentSelectedHasChildren(this.selectedItem))
227
246
  ? html `<exm-navigation-drawer-menu
228
247
  .items=${this.items}
229
248
  .path=${this.activeItem}
230
249
  @drawer-menu-item-click=${this.handleRailItemClick}
231
250
  ></exm-navigation-drawer-menu>`
232
- : !this.railOpen
233
- ? html `
234
- <section class="drawer-back-button">
235
- <exm-navigation-icon-button
236
- icon="arrow_back"
237
- label="Main menu"
238
- @navigation-icon-button-click=${this.handleDrawerBackClick}
239
- ></exm-navigation-icon-button>
240
- </section>
241
- `
242
- : 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
+ `;
243
260
  }
244
261
  /**
245
262
  * return the sub menus. More then 1 level deep
246
263
  */
247
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;
248
289
  return html `
249
290
  <exm-navigation-sub-menu
250
291
  .items=${this.items}
251
- .path=${this.activeItem}
292
+ .path=${selected}
252
293
  ?has-back-button=${!this.railOpen &&
253
- (this.activeItem.length > 1 ||
254
- (this.activeItem.length > 0 && this.currentSelectedHasChildren(this.activeItem)))}
294
+ (selected.length > 1 || (selected.length > 0 && this.currentSelectedHasChildren(selected)))}
255
295
  @sub-menu-item-click=${this.handleSubMenuClick}
256
296
  ></exm-navigation-sub-menu>
257
297
  `;
@@ -262,7 +302,7 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
262
302
  renderRail() {
263
303
  return html `<exm-navigation-rail
264
304
  .items=${this.items}
265
- .selected=${this.selectedItem}
305
+ .selected=${this.activeItem}
266
306
  @rail-item-click=${this.handleRailItemClick}
267
307
  @rail-item-mouseenter=${this.handleRailItemMouseEnter}
268
308
  @rail-item-mouseleave=${this.handleRailItemMouseLeave}
@@ -280,10 +320,21 @@ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
280
320
  <slot name="topbar-actions" slot="topbar-actions"></slot>
281
321
  </exm-navigation-topbar>`;
282
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
+ }
283
335
  render() {
284
- var _a;
285
336
  const containerStyle = {
286
- '--exm-drawer-width': `${(((_a = this.items.find((item) => item.id === this.selectedItem[0])) === null || _a === void 0 ? void 0 : _a.items) || []).length > 0 && this.persistent ? this.drawerWidth : 0}px`,
337
+ '--exm-drawer-width': `${this.getDrawerWidth()}px`,
287
338
  };
288
339
  const containerClass = { 'show-topbar': !this.railOpen };
289
340
  return html `
@@ -322,9 +373,6 @@ __decorate([
322
373
  __decorate([
323
374
  query('#navigation-container')
324
375
  ], ExmNavigationBase.prototype, "navContent", void 0);
325
- __decorate([
326
- state()
327
- ], ExmNavigationBase.prototype, "persistent", void 0);
328
376
  __decorate([
329
377
  state()
330
378
  ], ExmNavigationBase.prototype, "selectedItem", void 0);
@@ -337,9 +385,6 @@ __decorate([
337
385
  __decorate([
338
386
  state()
339
387
  ], ExmNavigationBase.prototype, "drawerOpen", void 0);
340
- __decorate([
341
- state()
342
- ], ExmNavigationBase.prototype, "drawerHover", void 0);
343
388
  __decorate([
344
389
  state()
345
390
  ], ExmNavigationBase.prototype, "navigationHasSubmenu", void 0);
@@ -1,14 +1,11 @@
1
- import { Drawer } from '@material/mwc-drawer';
2
1
  import { ExmgElement } from '@exmg/lit-base';
3
- import '@material/mwc-drawer';
4
2
  export declare class ExmNavigationDrawerBase extends ExmgElement {
5
3
  open: boolean;
6
4
  persistent: boolean;
7
- drawer?: Drawer;
5
+ drawer?: HTMLDivElement;
8
6
  static styles: import("lit").CSSResult[];
9
7
  private handleMouseEnter;
10
8
  private handleMouseLeave;
11
- private handleDrawerClose;
12
9
  protected firstUpdated(): Promise<void>;
13
10
  render(): import("lit-html").TemplateResult<1>;
14
11
  }
@@ -3,7 +3,7 @@ import { html } from 'lit';
3
3
  import { property, query } from 'lit/decorators.js';
4
4
  import { ExmgElement } from '@exmg/lit-base';
5
5
  import { style } from './styles/exm-navigation-drawer-css.js';
6
- import '@material/mwc-drawer';
6
+ import { classMap } from 'lit/directives/class-map.js';
7
7
  export class ExmNavigationDrawerBase extends ExmgElement {
8
8
  constructor() {
9
9
  super(...arguments);
@@ -16,9 +16,6 @@ export class ExmNavigationDrawerBase extends ExmgElement {
16
16
  handleMouseLeave() {
17
17
  this.fire('drawer-mouseleave');
18
18
  }
19
- handleDrawerClose() {
20
- this.fire('drawer-mouseleave');
21
- }
22
19
  async firstUpdated() {
23
20
  var _a;
24
21
  await this.updateComplete;
@@ -30,12 +27,16 @@ export class ExmNavigationDrawerBase extends ExmgElement {
30
27
  asideElement.addEventListener('mouseleave', this.handleMouseLeave.bind(this));
31
28
  }
32
29
  }
33
- this.addEventListener('drawer-close', this.handleDrawerClose.bind(this));
34
30
  }
35
31
  render() {
36
- return html `<mwc-drawer type="dismissible" ?open=${this.open}>
32
+ const classNames = { open: this.open };
33
+ return html `<aside
34
+ class="${classMap(classNames)}"
35
+ @mouseenter=${this.handleMouseEnter}
36
+ @mouseleave=${this.handleMouseLeave}
37
+ >
37
38
  <slot></slot>
38
- </mwc-drawer>`;
39
+ </aside> `;
39
40
  }
40
41
  }
41
42
  ExmNavigationDrawerBase.styles = [style];
@@ -46,6 +47,6 @@ __decorate([
46
47
  property({ type: Boolean })
47
48
  ], ExmNavigationDrawerBase.prototype, "persistent", void 0);
48
49
  __decorate([
49
- query('mwc-drawer')
50
+ query('aside')
50
51
  ], ExmNavigationDrawerBase.prototype, "drawer", void 0);
51
52
  //# sourceMappingURL=exm-navigation-drawer-base.js.map
@@ -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
- return html `<md-list-item type="button" ?selected=${this.selected}>
19
- ${this.icon
20
- ? html `<exm-navigation-icon slot="start" class="item-icon" icon=${this.icon}></exm-navigation-icon>`
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
- <div class="label"><slot></slot></div>
23
- ${this.hasSubmenu
24
- ? html `<exm-navigation-icon slot="end" class="has-submenu" icon=${this.submenuIcon}></exm-navigation-icon>`
25
- : nothing}
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
  }
@@ -10,9 +10,19 @@ export declare class ExmNavigationSubMenuBase extends ExmgElement {
10
10
  path: (string | null)[];
11
11
  hasBackButton: boolean;
12
12
  currentItem?: MenuItem['items'];
13
+ static itemIndex: number;
14
+ navigationElement?: HTMLElement;
13
15
  static styles: import("lit").CSSResult[];
14
16
  protected updated(changedProperties: PropertyValues): void;
17
+ connectedCallback(): void;
18
+ disconnectedCallback(): void;
15
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;
16
26
  private renderSubMenu;
17
27
  render(): import("lit-html").TemplateResult<1>;
18
28
  }