@exmg/exm-navigation 1.1.36 → 1.1.37-alpha.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.
Files changed (96) hide show
  1. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-base.d.ts +141 -0
  2. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-base.js +506 -0
  3. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-base.d.ts +14 -0
  4. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-base.js +65 -0
  5. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-menu-base.d.ts +12 -0
  6. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-menu-base.js +45 -0
  7. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-menu.d.ts +9 -0
  8. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-menu.js +12 -0
  9. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-nav-item-base.d.ts +14 -0
  10. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-nav-item-base.js +49 -0
  11. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-nav-item.d.ts +8 -0
  12. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer-nav-item.js +10 -0
  13. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer.d.ts +8 -0
  14. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-drawer.js +10 -0
  15. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon-base.d.ts +7 -0
  16. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon-base.js +20 -0
  17. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon-button-base.d.ts +9 -0
  18. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon-button-base.js +36 -0
  19. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon-button.d.ts +8 -0
  20. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon-button.js +10 -0
  21. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon.d.ts +8 -0
  22. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-icon.js +10 -0
  23. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail-base.d.ts +12 -0
  24. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail-base.js +62 -0
  25. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail-nav-item-base.d.ts +12 -0
  26. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail-nav-item-base.js +37 -0
  27. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail-nav-item.d.ts +8 -0
  28. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail-nav-item.js +10 -0
  29. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail.d.ts +8 -0
  30. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-rail.js +10 -0
  31. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-sub-menu-base.d.ts +28 -0
  32. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-sub-menu-base.js +153 -0
  33. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-sub-menu.d.ts +8 -0
  34. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-sub-menu.js +10 -0
  35. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-topbar-base.d.ts +10 -0
  36. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-topbar-base.js +33 -0
  37. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-topbar.d.ts +8 -0
  38. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation-topbar.js +10 -0
  39. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation.d.ts +8 -0
  40. package/.rollup.cache/root/repo/packages/exm-navigation/dist/exm-navigation.js +10 -0
  41. package/.rollup.cache/root/repo/packages/exm-navigation/dist/index.d.ts +12 -0
  42. package/.rollup.cache/root/repo/packages/exm-navigation/dist/index.js +13 -0
  43. package/.rollup.cache/root/repo/packages/exm-navigation/dist/mixins/media-queries.d.ts +8 -0
  44. package/.rollup.cache/root/repo/packages/exm-navigation/dist/mixins/media-queries.js +57 -0
  45. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-css.d.ts +1 -0
  46. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-css.js +75 -0
  47. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-drawer-css.d.ts +1 -0
  48. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-drawer-css.js +32 -0
  49. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-drawer-nav-item-css.d.ts +1 -0
  50. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-drawer-nav-item-css.js +84 -0
  51. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-icon-button-css.d.ts +1 -0
  52. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-icon-button-css.js +29 -0
  53. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-icon-css.d.ts +1 -0
  54. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-icon-css.js +22 -0
  55. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-rail-css.d.ts +1 -0
  56. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-rail-css.js +59 -0
  57. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-rail-nav-item-css.d.ts +1 -0
  58. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-rail-nav-item-css.js +94 -0
  59. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-sub-menu-css.d.ts +1 -0
  60. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-sub-menu-css.js +24 -0
  61. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-topbar-css.d.ts +1 -0
  62. package/.rollup.cache/root/repo/packages/exm-navigation/dist/styles/exm-navigation-topbar-css.js +30 -0
  63. package/.rollup.cache/root/repo/packages/exm-navigation/dist/types.d.ts +10 -0
  64. package/dist/exm-navigation-base.js +7 -6
  65. package/dist/exm-navigation-drawer-base.js +6 -3
  66. package/dist/exm-navigation-drawer-menu-base.js +6 -3
  67. package/dist/exm-navigation-drawer-menu.js +4 -2
  68. package/dist/exm-navigation-drawer-nav-item-base.js +7 -4
  69. package/dist/exm-navigation-drawer-nav-item.js +4 -2
  70. package/dist/exm-navigation-drawer.js +4 -2
  71. package/dist/exm-navigation-icon-base.js +6 -4
  72. package/dist/exm-navigation-icon-button-base.js +7 -4
  73. package/dist/exm-navigation-icon-button.js +4 -2
  74. package/dist/exm-navigation-icon.js +4 -2
  75. package/dist/exm-navigation-rail-base.js +6 -3
  76. package/dist/exm-navigation-rail-nav-item-base.js +6 -3
  77. package/dist/exm-navigation-rail-nav-item.js +4 -2
  78. package/dist/exm-navigation-rail.js +4 -2
  79. package/dist/exm-navigation-sub-menu-base.js +8 -5
  80. package/dist/exm-navigation-sub-menu.js +4 -2
  81. package/dist/exm-navigation-topbar-base.js +6 -3
  82. package/dist/exm-navigation-topbar.js +4 -2
  83. package/dist/exm-navigation.js +4 -2
  84. package/dist/index.js +1 -1
  85. package/dist/mixins/media-queries.js +6 -3
  86. package/dist/styles/exm-navigation-css.js +5 -2
  87. package/dist/styles/exm-navigation-drawer-css.js +5 -2
  88. package/dist/styles/exm-navigation-drawer-nav-item-css.js +5 -2
  89. package/dist/styles/exm-navigation-icon-button-css.js +5 -2
  90. package/dist/styles/exm-navigation-icon-css.js +5 -2
  91. package/dist/styles/exm-navigation-rail-css.js +5 -2
  92. package/dist/styles/exm-navigation-rail-nav-item-css.js +5 -2
  93. package/dist/styles/exm-navigation-sub-menu-css.js +5 -2
  94. package/dist/styles/exm-navigation-topbar-css.js +5 -2
  95. package/package.json +2 -2
  96. /package/{dist → .rollup.cache/root/repo/packages/exm-navigation/dist}/types.js +0 -0
@@ -0,0 +1,141 @@
1
+ import { PropertyValues } from 'lit';
2
+ import { ExmgElement } from '@exmg/lit-base/index.js';
3
+ import { MenuItem } from './types.js';
4
+ import { ExmNavigationDrawer } from './exm-navigation-drawer.js';
5
+ import '@material/web/icon/icon.js';
6
+ import '@material/web/iconbutton/icon-button.js';
7
+ import './exm-navigation-icon-button.js';
8
+ import './exm-navigation-topbar.js';
9
+ import './exm-navigation-rail.js';
10
+ import './exm-navigation-sub-menu.js';
11
+ import './exm-navigation-drawer-menu.js';
12
+ import './exm-navigation-drawer.js';
13
+ import '@material/web/icon/icon.js';
14
+ import '@material/web/iconbutton/icon-button.js';
15
+ declare const ExmNavigationBase_base: (new (...args: any[]) => {
16
+ media: "mobile" | "tablet" | "desktop";
17
+ touch: boolean;
18
+ }) & typeof ExmgElement;
19
+ export declare class ExmNavigationBase extends ExmNavigationBase_base {
20
+ items: MenuItem[];
21
+ path: string[];
22
+ drawerWidth: number;
23
+ disableNavigate: boolean;
24
+ hoverDisabled: boolean;
25
+ collapseOnDesktop: boolean;
26
+ drawer?: ExmNavigationDrawer;
27
+ navContent?: HTMLDivElement;
28
+ /**
29
+ * The menu item triggered by hovering and entering submenu's
30
+ * Once an item with endpoint is clicked, this value should be written to activeItem
31
+ */
32
+ selectedItem: string[];
33
+ /**
34
+ * The currently active menu item
35
+ */
36
+ activeItem: string[];
37
+ /**
38
+ * Wether or not the rail should be visible yes or no
39
+ */
40
+ railOpen: boolean;
41
+ /**
42
+ * Wether or not the drawer should be visible yes or no
43
+ */
44
+ drawerOpen: boolean;
45
+ /**
46
+ * Object with menuitem and a bool for having that path sub items yes or no
47
+ */
48
+ navigationHasSubmenu: Record<string, boolean>;
49
+ static styles: import("lit").CSSResult[];
50
+ constructor();
51
+ /**
52
+ * Get the menu items and the current path and set the correct startPath for the navigation
53
+ */
54
+ private setPath;
55
+ protected updated(changedProperties: PropertyValues): void;
56
+ protected firstUpdated(changedProperties: PropertyValues): void;
57
+ connectedCallback(): void;
58
+ /**
59
+ * Set the correct values when the media changes.
60
+ */
61
+ private handleMediaTypeChange;
62
+ private getPathEndpoint;
63
+ private loadPage;
64
+ /**
65
+ * Handles the drawer state. If it should be open yes or no.
66
+ * @param param0
67
+ */
68
+ handleDrawerOpen({ mobileForce, tabletForce, desktopForce }?: Record<string, boolean>): void;
69
+ /**
70
+ * Handle Rail item click or Drawer sub menu click.
71
+ * If the selected menu item has children, we add the first item to the list (as per Google implementation).
72
+ * 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
73
+ */
74
+ private handleRailItemClick;
75
+ /**
76
+ * Handle the mouse enter of the rail item.
77
+ */
78
+ private handleRailItemMouseEnter;
79
+ /**
80
+ * Handle the mouse leave of the rail item.
81
+ * If the item has no submenu and the current selected item has no submenu, it is safe to close the drawer
82
+ */
83
+ private handleRailItemMouseLeave;
84
+ /**
85
+ * Handle drawer mouse leave. Should close the drawer
86
+ */
87
+ private handleDrawerMouseLeave;
88
+ /**
89
+ * Handle the click on a sub menu item
90
+ * @param param Contains detail. This has the new path to go to.
91
+ * If the rail is hidden and the selected item has no children, we close the drawer
92
+ */
93
+ private handleSubMenuClick;
94
+ /**
95
+ * Handle the topbar menu click.
96
+ * Clicking the menu button in the topbar wil toggle the drawer
97
+ */
98
+ private handleTopbarMenuClick;
99
+ /**
100
+ * Handle the drawer back button click.
101
+ * This should reset the active item, so the root-level menu gets triggered
102
+ */
103
+ private handleDrawerBackClick;
104
+ private handleContentPointerDown;
105
+ /**
106
+ * Check if the passed paths last item has children yes or no
107
+ * @param path Path array
108
+ * @returns True if the given path has children
109
+ */
110
+ private currentSelectedHasChildren;
111
+ /**
112
+ * When the rail is not open, show the menu button on top of the drawer to close it
113
+ */
114
+ private renderDrawerMenuButton;
115
+ /**
116
+ * When no menu item selected, ot only toplevel without children, show the start menu (same as in the rail)
117
+ * If more levels deep, show the back button
118
+ */
119
+ private renderStartMenu;
120
+ /**
121
+ * return the sub menus. More then 1 level deep
122
+ */
123
+ private renderDrawerSubMenu;
124
+ /**
125
+ * Return the Rail
126
+ */
127
+ private renderRail;
128
+ /**
129
+ * Render the topbar. This is displayed on mobile and contains the menu button and a slot for the title
130
+ */
131
+ private renderTopbar;
132
+ /**
133
+ * If there is an active item, and that item has children, the width of the drawer should be set for desktop.
134
+ * This will push the content to the right.
135
+ *
136
+ * @returns the width of the drawer area
137
+ */
138
+ private getDrawerWidth;
139
+ render(): import("lit-html").TemplateResult<1>;
140
+ }
141
+ export {};
@@ -0,0 +1,506 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, nothing } from 'lit';
3
+ import { ExmgElement } from '@exmg/lit-base/index.js';
4
+ import { property, query, state } from 'lit/decorators.js';
5
+ import { styleMap } from 'lit/directives/style-map.js';
6
+ import { MediaQueries } from './mixins/media-queries.js';
7
+ import { classMap } from 'lit/directives/class-map.js';
8
+ import { style } from './styles/exm-navigation-css.js';
9
+ import '@material/web/icon/icon.js';
10
+ import '@material/web/iconbutton/icon-button.js';
11
+ import './exm-navigation-icon-button.js';
12
+ import './exm-navigation-topbar.js';
13
+ import './exm-navigation-rail.js';
14
+ import './exm-navigation-sub-menu.js';
15
+ import './exm-navigation-drawer-menu.js';
16
+ import './exm-navigation-drawer.js';
17
+ import '@material/web/icon/icon.js';
18
+ import '@material/web/iconbutton/icon-button.js';
19
+ // eslint-disable-next-line new-cap
20
+ export class ExmNavigationBase extends MediaQueries(ExmgElement) {
21
+ constructor() {
22
+ super();
23
+ this.items = [];
24
+ this.path = ['chat'];
25
+ this.drawerWidth = 275;
26
+ this.disableNavigate = false;
27
+ this.hoverDisabled = false;
28
+ this.collapseOnDesktop = false;
29
+ /**
30
+ * The menu item triggered by hovering and entering submenu's
31
+ * Once an item with endpoint is clicked, this value should be written to activeItem
32
+ */
33
+ this.selectedItem = [];
34
+ /**
35
+ * The currently active menu item
36
+ */
37
+ this.activeItem = [];
38
+ /**
39
+ * Wether or not the rail should be visible yes or no
40
+ */
41
+ this.railOpen = true;
42
+ /**
43
+ * Wether or not the drawer should be visible yes or no
44
+ */
45
+ this.drawerOpen = false;
46
+ /**
47
+ * Object with menuitem and a bool for having that path sub items yes or no
48
+ */
49
+ this.navigationHasSubmenu = {};
50
+ /**
51
+ * Listen to popState changes.
52
+ */
53
+ window.addEventListener('popstate', () => {
54
+ this.setPath();
55
+ });
56
+ }
57
+ /**
58
+ * Get the menu items and the current path and set the correct startPath for the navigation
59
+ */
60
+ setPath() {
61
+ let path = [];
62
+ /**
63
+ * Set to true if we found the path. This is needed because for breaking out of a recursive function
64
+ */
65
+ let finished = false;
66
+ /**
67
+ * Loop through the items with a give depth. For every depth level the id of the route is set to that index
68
+ * If there is a matching path, we set finished to true, so all levels wil break out of their for-loop
69
+ * Every call done with depth 0 will reset the path, so no artifacts of the previous route will remain
70
+ *
71
+ * @param items The items to loop through
72
+ * @param depth The navigation depth
73
+ */
74
+ function checkItems(items, depth = 0) {
75
+ for (const item of items) {
76
+ if (finished) {
77
+ break;
78
+ }
79
+ if (depth === 0) {
80
+ path = [];
81
+ }
82
+ path[depth] = item.id;
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)) {
88
+ finished = true;
89
+ break;
90
+ }
91
+ if (item.items && (item.items || []).length > 0) {
92
+ checkItems(item.items, depth + 1);
93
+ }
94
+ }
95
+ }
96
+ checkItems(this.items);
97
+ this.path = path;
98
+ this.selectedItem = path;
99
+ this.activeItem = path;
100
+ this.handleDrawerOpen();
101
+ }
102
+ updated(changedProperties) {
103
+ if (changedProperties.has('media')) {
104
+ this.handleMediaTypeChange.bind(this)();
105
+ }
106
+ if (changedProperties.has('items')) {
107
+ for (const item of this.items) {
108
+ this.navigationHasSubmenu[item.id] = (item.items || []).length > 0;
109
+ }
110
+ if (this.navigationHasSubmenu[this.path[0]] && this.media === 'desktop') {
111
+ this.drawerOpen = true;
112
+ }
113
+ }
114
+ }
115
+ firstUpdated(changedProperties) {
116
+ if (changedProperties.has('media')) {
117
+ this.handleMediaTypeChange.bind(this)();
118
+ }
119
+ document.documentElement.style.setProperty('--exm-navigation-submenu-width', `${this.drawerWidth}px`);
120
+ /**
121
+ * Set the start path
122
+ */
123
+ this.setPath();
124
+ }
125
+ connectedCallback() {
126
+ super.connectedCallback();
127
+ this.selectedItem = [...this.path];
128
+ this.activeItem = [...this.path];
129
+ }
130
+ /**
131
+ * Set the correct values when the media changes.
132
+ */
133
+ handleMediaTypeChange() {
134
+ this.drawerOpen = this.media === 'desktop' && this.navigationHasSubmenu[this.activeItem[0]];
135
+ this.railOpen = this.media !== 'mobile';
136
+ }
137
+ getPathEndpoint() {
138
+ let items = this.items;
139
+ let result;
140
+ const checkItems = (path, last) => {
141
+ const item = items.find((item) => item.id === path);
142
+ if (last) {
143
+ return item === null || item === void 0 ? void 0 : item.path;
144
+ }
145
+ items = (item === null || item === void 0 ? void 0 : item.items) || [];
146
+ return;
147
+ };
148
+ for (let i = 0; i < this.selectedItem.length; i++) {
149
+ result = checkItems(this.selectedItem[i], i === this.selectedItem.length - 1);
150
+ }
151
+ return result;
152
+ }
153
+ loadPage(path) {
154
+ this.path = path;
155
+ this.activeItem = path;
156
+ const endPoint = this.getPathEndpoint();
157
+ // If the route does not have a path, skip navigating
158
+ if (!endPoint) {
159
+ return;
160
+ }
161
+ this.fire('navigation-change', path);
162
+ if (!this.disableNavigate) {
163
+ window.history.pushState({}, '', this.getPathEndpoint());
164
+ window.dispatchEvent(new PopStateEvent('popstate'));
165
+ }
166
+ }
167
+ /**
168
+ * Handles the drawer state. If it should be open yes or no.
169
+ * @param param0
170
+ */
171
+ handleDrawerOpen({ mobileForce, tabletForce, desktopForce } = {}) {
172
+ const hasActiveSubmenu = this.navigationHasSubmenu[this.activeItem[0]];
173
+ const hasSelectedSubmenu = this.navigationHasSubmenu[this.selectedItem[0]];
174
+ if (this.media === 'mobile' || this.touch) {
175
+ // Only triggerable by button
176
+ if (mobileForce || !hasActiveSubmenu) {
177
+ this.drawerOpen = false;
178
+ }
179
+ }
180
+ if (this.media === 'tablet') {
181
+ if (tabletForce) {
182
+ this.drawerOpen = false;
183
+ }
184
+ else {
185
+ this.drawerOpen = hasSelectedSubmenu;
186
+ }
187
+ }
188
+ if (this.media === 'desktop') {
189
+ if (desktopForce) {
190
+ this.drawerOpen = false;
191
+ return;
192
+ }
193
+ if (this.navigationHasSubmenu[this.activeItem[0]]) {
194
+ this.drawerOpen = true;
195
+ }
196
+ else {
197
+ this.drawerOpen = hasSelectedSubmenu;
198
+ }
199
+ }
200
+ }
201
+ /**
202
+ * Handle Rail item click or Drawer sub menu click.
203
+ * If the selected menu item has children, we add the first item to the list (as per Google implementation).
204
+ * 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
205
+ */
206
+ handleRailItemClick({ detail }) {
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
+ }
220
+ const item = this.items.find((item) => item.id === this.activeItem[0]);
221
+ /**
222
+ * If this is the current item, skip it.
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
224
+ */
225
+ if (!isSameItem || (this.activeItem[0] === detail && (item === null || item === void 0 ? void 0 : item.additionalPath)) || this.media !== 'desktop') {
226
+ const items = ((_a = this.items.find((item) => item.id === detail)) === null || _a === void 0 ? void 0 : _a.items) || [];
227
+ if (items.length && !this.touch) {
228
+ this.selectedItem = [detail, items[0].id];
229
+ }
230
+ else {
231
+ this.selectedItem = [detail];
232
+ }
233
+ this.loadPage(this.selectedItem);
234
+ this.handleDrawerOpen();
235
+ }
236
+ }
237
+ /**
238
+ * Handle the mouse enter of the rail item.
239
+ */
240
+ handleRailItemMouseEnter({ detail }) {
241
+ if (this.touch || this.hoverDisabled) {
242
+ return;
243
+ }
244
+ this.selectedItem = [detail];
245
+ this.handleDrawerOpen();
246
+ }
247
+ /**
248
+ * Handle the mouse leave of the rail item.
249
+ * If the item has no submenu and the current selected item has no submenu, it is safe to close the drawer
250
+ */
251
+ handleRailItemMouseLeave() { }
252
+ /**
253
+ * Handle drawer mouse leave. Should close the drawer
254
+ */
255
+ handleDrawerMouseLeave() {
256
+ /**
257
+ * On mouse leave the drawer we want to set the active item to the selected item.
258
+ * If not, it will show the active item on every hover and will make navigating in the selected item impossible
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
+ }
268
+ this.selectedItem = this.activeItem;
269
+ this.handleDrawerOpen({ tabletForce: true });
270
+ }
271
+ /**
272
+ * Handle the click on a sub menu item
273
+ * @param param Contains detail. This has the new path to go to.
274
+ * If the rail is hidden and the selected item has no children, we close the drawer
275
+ */
276
+ handleSubMenuClick({ detail }) {
277
+ this.selectedItem = detail;
278
+ const endPoint = this.getPathEndpoint();
279
+ let mobileForce = false;
280
+ let desktopForce = false;
281
+ if (endPoint) {
282
+ this.loadPage(this.selectedItem);
283
+ mobileForce = true;
284
+ if (this.collapseOnDesktop) {
285
+ desktopForce = true;
286
+ }
287
+ }
288
+ this.handleDrawerOpen({ mobileForce, tabletForce: this.touch && !!endPoint, desktopForce });
289
+ }
290
+ /**
291
+ * Handle the topbar menu click.
292
+ * Clicking the menu button in the topbar wil toggle the drawer
293
+ */
294
+ handleTopbarMenuClick() {
295
+ this.drawerOpen = !this.drawerOpen;
296
+ }
297
+ /**
298
+ * Handle the drawer back button click.
299
+ * This should reset the active item, so the root-level menu gets triggered
300
+ */
301
+ handleDrawerBackClick() {
302
+ this.selectedItem = [];
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
+ }
311
+ /**
312
+ * Check if the passed paths last item has children yes or no
313
+ * @param path Path array
314
+ * @returns True if the given path has children
315
+ */
316
+ currentSelectedHasChildren(path) {
317
+ let currentItems = this.items;
318
+ return path.reduce((_, pathSection) => {
319
+ const item = currentItems.find((currentItem) => currentItem.id === pathSection);
320
+ currentItems = (item === null || item === void 0 ? void 0 : item.items) || [];
321
+ return ((item === null || item === void 0 ? void 0 : item.items) || []).length > 0;
322
+ }, false);
323
+ }
324
+ /**
325
+ * When the rail is not open, show the menu button on top of the drawer to close it
326
+ */
327
+ renderDrawerMenuButton() {
328
+ return !this.railOpen
329
+ ? html `
330
+ <section class="drawer-menu-button">
331
+ <md-icon-button @click=${this.handleTopbarMenuClick}>
332
+ <md-icon>${this.drawerOpen ? 'menu_open' : 'menu'}</md-icon>
333
+ </md-icon-button>
334
+ </section>
335
+ `
336
+ : nothing;
337
+ }
338
+ /**
339
+ * When no menu item selected, ot only toplevel without children, show the start menu (same as in the rail)
340
+ * If more levels deep, show the back button
341
+ */
342
+ renderStartMenu() {
343
+ if (this.railOpen) {
344
+ return nothing;
345
+ }
346
+ return this.selectedItem.length === 0 ||
347
+ (this.selectedItem.length === 1 && !this.currentSelectedHasChildren(this.selectedItem))
348
+ ? html `<exm-navigation-drawer-menu
349
+ .items=${this.items}
350
+ .path=${this.activeItem}
351
+ @drawer-menu-item-click=${this.handleRailItemClick}
352
+ ></exm-navigation-drawer-menu>`
353
+ : html `
354
+ <section class="drawer-back-button">
355
+ <exm-navigation-icon-button
356
+ icon="arrow_back"
357
+ label="Main menu"
358
+ @navigation-icon-button-click=${this.handleDrawerBackClick}
359
+ ></exm-navigation-icon-button>
360
+ </section>
361
+ `;
362
+ }
363
+ /**
364
+ * return the sub menus. More then 1 level deep
365
+ */
366
+ renderDrawerSubMenu() {
367
+ /**
368
+ * When the selected item is empty we do not display the submenu on mobile
369
+ */
370
+ if (this.selectedItem.length === 0 && this.media === 'mobile') {
371
+ return nothing;
372
+ }
373
+ /**
374
+ * Do we have all items of the selectedItem available in the active Item
375
+ */
376
+ const selectedInActive = this.selectedItem.reduce((_, item, index) => {
377
+ if (item === this.activeItem[index]) {
378
+ return true;
379
+ }
380
+ return false;
381
+ }, false);
382
+ /**
383
+ * Determine the data to use for the submenu. This is needed to show the correct selected items in the submenu of the drawer
384
+ * If all selected Items ar in the active item, show the active item
385
+ * If the selected item haas no children, but the drawer is open, show the active item
386
+ * In all the other cases we use the selected item
387
+ */
388
+ const selected = selectedInActive || (!this.navigationHasSubmenu[this.selectedItem[0]] && this.drawerOpen)
389
+ ? this.activeItem
390
+ : this.selectedItem;
391
+ return html `
392
+ <exm-navigation-sub-menu
393
+ .items=${this.items}
394
+ .path=${selected}
395
+ ?has-back-button=${!this.railOpen &&
396
+ (selected.length > 1 || (selected.length > 0 && this.currentSelectedHasChildren(selected)))}
397
+ @sub-menu-item-click=${this.handleSubMenuClick}
398
+ ></exm-navigation-sub-menu>
399
+ `;
400
+ }
401
+ /**
402
+ * Return the Rail
403
+ */
404
+ renderRail() {
405
+ return html `<exm-navigation-rail
406
+ .items=${this.items}
407
+ .selected=${this.activeItem}
408
+ @rail-item-click=${this.handleRailItemClick}
409
+ @rail-item-mouseenter=${this.handleRailItemMouseEnter}
410
+ @rail-item-mouseleave=${this.handleRailItemMouseLeave}
411
+ >
412
+ <slot name="rail-top" slot="rail-top"></slot>
413
+ <slot name="rail-bottom" slot="rail-bottom"></slot>
414
+ </exm-navigation-rail>`;
415
+ }
416
+ /**
417
+ * Render the topbar. This is displayed on mobile and contains the menu button and a slot for the title
418
+ */
419
+ renderTopbar() {
420
+ return html `<exm-navigation-topbar ?drawer-open=${this.drawerOpen} @topbar-menu-click=${this.handleTopbarMenuClick}>
421
+ <slot name="topbar-title" slot="topbar-title"></slot>
422
+ <slot name="topbar-actions" slot="topbar-actions"></slot>
423
+ </exm-navigation-topbar>`;
424
+ }
425
+ /**
426
+ * If there is an active item, and that item has children, the width of the drawer should be set for desktop.
427
+ * This will push the content to the right.
428
+ *
429
+ * @returns the width of the drawer area
430
+ */
431
+ getDrawerWidth() {
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) {
440
+ return this.drawerWidth;
441
+ }
442
+ return 0;
443
+ }
444
+ render() {
445
+ const containerStyle = {
446
+ '--exm-navigation-submenu-column-width': `${this.getDrawerWidth()}px`,
447
+ };
448
+ const containerClass = { 'show-topbar': !this.railOpen };
449
+ return html `
450
+ <section
451
+ class="navigation-container ${classMap(containerClass)}"
452
+ id="navigation-container"
453
+ style=${styleMap(containerStyle)}
454
+ >
455
+ ${this.railOpen ? this.renderRail() : this.renderTopbar()}
456
+ <exm-navigation-drawer ?open=${this.drawerOpen} @drawer-mouseleave=${this.handleDrawerMouseLeave}>
457
+ ${[this.renderDrawerMenuButton(), this.renderStartMenu(), this.renderDrawerSubMenu()]}
458
+ </exm-navigation-drawer>
459
+ <section class="content" @pointerdown=${this.handleContentPointerDown}>
460
+ <slot></slot>
461
+ </section>
462
+ </section>
463
+ `;
464
+ }
465
+ }
466
+ ExmNavigationBase.styles = [style];
467
+ __decorate([
468
+ property({ type: Array })
469
+ ], ExmNavigationBase.prototype, "items", void 0);
470
+ __decorate([
471
+ property({ type: Array })
472
+ ], ExmNavigationBase.prototype, "path", void 0);
473
+ __decorate([
474
+ property({ type: Number, attribute: 'drawer-width' })
475
+ ], ExmNavigationBase.prototype, "drawerWidth", void 0);
476
+ __decorate([
477
+ property({ type: Boolean, attribute: 'disable-navigation' })
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);
485
+ __decorate([
486
+ query('exm-navigation-drawer')
487
+ ], ExmNavigationBase.prototype, "drawer", void 0);
488
+ __decorate([
489
+ query('#navigation-container')
490
+ ], ExmNavigationBase.prototype, "navContent", void 0);
491
+ __decorate([
492
+ state()
493
+ ], ExmNavigationBase.prototype, "selectedItem", void 0);
494
+ __decorate([
495
+ state()
496
+ ], ExmNavigationBase.prototype, "activeItem", void 0);
497
+ __decorate([
498
+ state()
499
+ ], ExmNavigationBase.prototype, "railOpen", void 0);
500
+ __decorate([
501
+ state()
502
+ ], ExmNavigationBase.prototype, "drawerOpen", void 0);
503
+ __decorate([
504
+ state()
505
+ ], ExmNavigationBase.prototype, "navigationHasSubmenu", void 0);
506
+ //# sourceMappingURL=exm-navigation-base.js.map
@@ -0,0 +1,14 @@
1
+ import { ExmgElement } from '@exmg/lit-base';
2
+ export declare class ExmNavigationDrawerBase extends ExmgElement {
3
+ open: boolean;
4
+ persistent: boolean;
5
+ drawer?: HTMLDivElement;
6
+ static styles: import("lit").CSSResult[];
7
+ connectedCallback(): void;
8
+ disconnectedCallback(): void;
9
+ private handleWindowMouseOut;
10
+ private handleMouseEnter;
11
+ private handleMouseLeave;
12
+ protected firstUpdated(): Promise<void>;
13
+ render(): import("lit-html").TemplateResult<1>;
14
+ }