@modelmenu/navigation 3.1.0 → 3.3.0
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/dist/index.es.js +588 -558
- package/dist/index.umd.js +12 -12
- package/menu/MenuPlate.vue +42 -22
- package/menu/components/menu-item.vue +2 -3
- package/menu/components/sub-menu-items.vue +88 -40
- package/menu/components/top-menu-items/top-menu-item.vue +16 -15
- package/menu/components/top-menu-items/top-sub-menu-items.vue +13 -3
- package/package.json +1 -1
package/menu/MenuPlate.vue
CHANGED
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
v-for="(item, index) in leftMenuItems"
|
|
25
25
|
:key="index"
|
|
26
26
|
:class="['menu-item-heading', { 'item-active': item.active }]"
|
|
27
|
-
@mouseenter="showTooltipItems($event, item
|
|
27
|
+
@mouseenter="showTooltipItems($event, item)"
|
|
28
|
+
@mouseleave="hideTooltipItems($event, item)"
|
|
28
29
|
>
|
|
29
30
|
<div class="item" :class="{ 'menu-item-opened': menuBar.opened }">
|
|
30
31
|
<MenuItem
|
|
@@ -35,21 +36,32 @@
|
|
|
35
36
|
<SubMenuItems
|
|
36
37
|
@openmenu="handleOpenMenu($event)"
|
|
37
38
|
@changeMenuItem="handleMenuItem($event)"
|
|
39
|
+
@tooltip="setTooltipItem($event)"
|
|
38
40
|
v-show="menuBar.opened"
|
|
39
41
|
:left-menu-items="leftMenuItems"
|
|
40
42
|
:item="item"
|
|
41
43
|
:menuBar="menuBar"
|
|
44
|
+
:active-tooltip-item-id="tooltipItemId"
|
|
42
45
|
></SubMenuItems>
|
|
43
46
|
<div
|
|
44
47
|
:class="[
|
|
45
48
|
'active-tooltip',
|
|
46
49
|
{
|
|
47
50
|
'tooltip-opened':
|
|
48
|
-
tooltip &&
|
|
51
|
+
tooltip &&
|
|
52
|
+
tooltipItemId === item.id &&
|
|
53
|
+
item.items?.length &&
|
|
54
|
+
!menuBar.opened,
|
|
49
55
|
},
|
|
50
56
|
]"
|
|
51
|
-
v-if="
|
|
52
|
-
|
|
57
|
+
v-if="
|
|
58
|
+
tooltip &&
|
|
59
|
+
tooltipItemId === item.id &&
|
|
60
|
+
item.items?.length &&
|
|
61
|
+
!menuBar.opened
|
|
62
|
+
"
|
|
63
|
+
@mouseenter="setTooltipItem(item.id)"
|
|
64
|
+
@mouseleave="hideTooltipItems($event, item)"
|
|
53
65
|
>
|
|
54
66
|
<div
|
|
55
67
|
v-for="value in item.items"
|
|
@@ -89,11 +101,8 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
|
|
89
101
|
import {
|
|
90
102
|
faAlignJustify,
|
|
91
103
|
faChevronDown,
|
|
92
|
-
faChevronLeft,
|
|
93
|
-
faChevronRight,
|
|
94
104
|
faChevronUp,
|
|
95
105
|
faClose,
|
|
96
|
-
faHamburger,
|
|
97
106
|
} from "@fortawesome/free-solid-svg-icons";
|
|
98
107
|
import MenuItem from "./components/menu-item.vue";
|
|
99
108
|
import SubMenuItems from "./components/sub-menu-items.vue";
|
|
@@ -132,8 +141,8 @@ export default defineComponent({
|
|
|
132
141
|
},
|
|
133
142
|
loader: {
|
|
134
143
|
type: Boolean,
|
|
135
|
-
default: () => false
|
|
136
|
-
}
|
|
144
|
+
default: () => false,
|
|
145
|
+
},
|
|
137
146
|
},
|
|
138
147
|
emits: ["changeTheme"],
|
|
139
148
|
watch: {
|
|
@@ -173,7 +182,8 @@ export default defineComponent({
|
|
|
173
182
|
topMenuItems: [] as TopMenuItems[],
|
|
174
183
|
leftMenuItems: [] as LeftMenuItems[],
|
|
175
184
|
tooltip: false,
|
|
176
|
-
|
|
185
|
+
tooltipItemId: null as number | null,
|
|
186
|
+
tooltipTimeout: null as ReturnType<typeof setTimeout> | null,
|
|
177
187
|
topItems: this.topItems,
|
|
178
188
|
leftItems: this.leftItems,
|
|
179
189
|
floor: 20,
|
|
@@ -228,19 +238,29 @@ export default defineComponent({
|
|
|
228
238
|
openSubMenu(item: any) {
|
|
229
239
|
item.opened = !item.opened;
|
|
230
240
|
},
|
|
231
|
-
showTooltipItems(event: any,
|
|
241
|
+
showTooltipItems(event: any, item: any) {
|
|
232
242
|
if (!this.menuBar.opened) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
243
|
+
this.tooltip = !!item.items?.length;
|
|
244
|
+
this.tooltipItemId = this.tooltip ? item.id : null;
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
hideTooltipItems(event: any, item: any) {
|
|
248
|
+
if (!this.menuBar.opened && this.tooltipItemId === item.id) {
|
|
249
|
+
if (this.tooltipTimeout) {
|
|
250
|
+
clearTimeout(this.tooltipTimeout);
|
|
236
251
|
}
|
|
252
|
+
this.tooltipTimeout = setTimeout(() => {
|
|
253
|
+
this.setTooltipItem(null);
|
|
254
|
+
}, 150);
|
|
237
255
|
}
|
|
238
256
|
},
|
|
239
|
-
|
|
240
|
-
if (
|
|
241
|
-
this.
|
|
242
|
-
this.
|
|
257
|
+
setTooltipItem(itemId: number | null) {
|
|
258
|
+
if (this.tooltipTimeout) {
|
|
259
|
+
clearTimeout(this.tooltipTimeout);
|
|
260
|
+
this.tooltipTimeout = null;
|
|
243
261
|
}
|
|
262
|
+
this.tooltipItemId = itemId;
|
|
263
|
+
this.tooltip = itemId !== null;
|
|
244
264
|
},
|
|
245
265
|
handleOpenMenu(item: any) {
|
|
246
266
|
for (const subItem of this.leftMenuItems || []) {
|
|
@@ -410,7 +430,7 @@ export default defineComponent({
|
|
|
410
430
|
left: 0;
|
|
411
431
|
z-index: 200;
|
|
412
432
|
width: 70px;
|
|
413
|
-
animation: closeMenu 0.
|
|
433
|
+
animation: closeMenu 0.4s ease-out forwards;
|
|
414
434
|
height: 100dvh;
|
|
415
435
|
background-color: white;
|
|
416
436
|
border-right: 2px solid rgba(70, 70, 70, 0.4);
|
|
@@ -449,7 +469,7 @@ export default defineComponent({
|
|
|
449
469
|
|
|
450
470
|
.vertical-menu.vertical-menu-opened {
|
|
451
471
|
width: 200px;
|
|
452
|
-
animation: openMenu 0.
|
|
472
|
+
animation: openMenu 0.4s ease-in forwards;
|
|
453
473
|
}
|
|
454
474
|
|
|
455
475
|
.menu-button {
|
|
@@ -512,11 +532,11 @@ export default defineComponent({
|
|
|
512
532
|
}
|
|
513
533
|
|
|
514
534
|
.menu-icon.opened.rotate svg {
|
|
515
|
-
animation: rotateAnimation 0.
|
|
535
|
+
animation: rotateAnimation 0.4s forwards;
|
|
516
536
|
}
|
|
517
537
|
|
|
518
538
|
.menu-icon.opened.hover svg {
|
|
519
|
-
animation: hoverAnimation 0.
|
|
539
|
+
animation: hoverAnimation 0.4s forwards;
|
|
520
540
|
}
|
|
521
541
|
|
|
522
542
|
.none {
|
|
@@ -211,9 +211,8 @@ export default {
|
|
|
211
211
|
animation: closeMenuText 0.2s ease-out forwards;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
.menu-text-closed .sub-menu-button{
|
|
214
|
+
.menu-text-closed .sub-menu-button {
|
|
215
215
|
display: none;
|
|
216
|
-
|
|
217
216
|
}
|
|
218
217
|
|
|
219
218
|
.item-active {
|
|
@@ -252,6 +251,6 @@ export default {
|
|
|
252
251
|
}
|
|
253
252
|
|
|
254
253
|
.icon-opened {
|
|
255
|
-
animation: openMenu 0.
|
|
254
|
+
animation: openMenu 0.4s ease forwards;
|
|
256
255
|
}
|
|
257
256
|
</style>
|
|
@@ -1,37 +1,50 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="sub-menu-items"
|
|
4
|
+
:class="{ itemsOpened: item.opened, itemsClosed: !item.opened }"
|
|
5
|
+
>
|
|
6
|
+
<div class="sub-menu-content">
|
|
7
|
+
<div
|
|
8
|
+
v-for="(subItem, subIndex) in item.items"
|
|
9
|
+
:key="subIndex"
|
|
10
|
+
class="item"
|
|
11
|
+
:class="{ 'menu-item-opened': menuBar.opened }"
|
|
12
|
+
@mouseenter="showTooltipItems($event, subItem)"
|
|
13
|
+
@mouseleave="hideTooltipItems($event, subItem)"
|
|
14
|
+
>
|
|
15
|
+
<MenuItem
|
|
16
|
+
:item="subItem"
|
|
17
|
+
:leftItems="leftMenuItems"
|
|
18
|
+
@changeMenuItem="handleMenuItem($event)"
|
|
19
|
+
:menuBar="menuBar"
|
|
20
|
+
></MenuItem>
|
|
21
|
+
<SubMenuItems
|
|
22
|
+
v-if="subItem.items?.length"
|
|
23
|
+
@changeMenuItem="handleMenuItem($event)"
|
|
24
|
+
@tooltip="handleTooltip($event)"
|
|
25
|
+
v-show="menuBar.opened"
|
|
26
|
+
:item="subItem"
|
|
27
|
+
:menuBar="menuBar"
|
|
28
|
+
:active-tooltip-item-id="activeTooltipItemId"
|
|
29
|
+
></SubMenuItems>
|
|
25
30
|
<div
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
class="active-tooltip"
|
|
32
|
+
@mouseenter="$emit('tooltip', subItem.id)"
|
|
33
|
+
v-if="
|
|
34
|
+
activeTooltipItemId === subItem.id &&
|
|
35
|
+
subItem.items?.length &&
|
|
36
|
+
!menuBar.opened
|
|
37
|
+
"
|
|
33
38
|
>
|
|
34
|
-
|
|
39
|
+
<div
|
|
40
|
+
v-for="value in subItem.items"
|
|
41
|
+
:key="value.name"
|
|
42
|
+
class="tooltip-item"
|
|
43
|
+
@click="tooltipItemClick($event, subItem, value)"
|
|
44
|
+
v-if="!menuBar.opened"
|
|
45
|
+
>
|
|
46
|
+
{{ value.name }}
|
|
47
|
+
</div>
|
|
35
48
|
</div>
|
|
36
49
|
</div>
|
|
37
50
|
</div>
|
|
@@ -60,16 +73,19 @@ export default {
|
|
|
60
73
|
type: Array,
|
|
61
74
|
default: () => [],
|
|
62
75
|
},
|
|
76
|
+
activeTooltipItemId: {
|
|
77
|
+
type: Number,
|
|
78
|
+
default: null,
|
|
79
|
+
},
|
|
63
80
|
},
|
|
64
81
|
data() {
|
|
65
82
|
return {
|
|
66
83
|
item: this.item,
|
|
67
|
-
tooltip: false,
|
|
68
84
|
menuBar: this.menuBar,
|
|
69
85
|
leftMenuItems: this.leftMenuItems as any[],
|
|
70
86
|
};
|
|
71
87
|
},
|
|
72
|
-
emits: ["openmenu", "changeMenuItem"],
|
|
88
|
+
emits: ["openmenu", "changeMenuItem", "tooltip"],
|
|
73
89
|
watch: {
|
|
74
90
|
menuBar(newVal: any) {
|
|
75
91
|
this.menuBar = newVal;
|
|
@@ -79,19 +95,26 @@ export default {
|
|
|
79
95
|
},
|
|
80
96
|
},
|
|
81
97
|
methods: {
|
|
82
|
-
showTooltipItems(event: any) {
|
|
98
|
+
showTooltipItems(event: any, subItem: any) {
|
|
83
99
|
if (!this.menuBar.opened) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
this.$emit(
|
|
101
|
+
"tooltip",
|
|
102
|
+
subItem.items?.length ? subItem.id : null
|
|
103
|
+
);
|
|
87
104
|
}
|
|
88
105
|
},
|
|
106
|
+
handleTooltip(itemId: number | null) {
|
|
107
|
+
this.$emit("tooltip", itemId);
|
|
108
|
+
},
|
|
89
109
|
handleMenuItem(event: any) {
|
|
90
110
|
this.$emit("changeMenuItem", event);
|
|
91
111
|
},
|
|
92
|
-
hideTooltipItems(event: any) {
|
|
93
|
-
if (
|
|
94
|
-
this.
|
|
112
|
+
hideTooltipItems(event: any, subItem: any) {
|
|
113
|
+
if (
|
|
114
|
+
!this.menuBar.opened &&
|
|
115
|
+
this.activeTooltipItemId === subItem.id
|
|
116
|
+
) {
|
|
117
|
+
this.$emit("tooltip", null);
|
|
95
118
|
}
|
|
96
119
|
},
|
|
97
120
|
tooltipItemClick(event: any, subItem: any, value: any) {
|
|
@@ -143,4 +166,29 @@ export default {
|
|
|
143
166
|
font-size: 16px;
|
|
144
167
|
padding: 4px;
|
|
145
168
|
}
|
|
169
|
+
|
|
170
|
+
.sub-menu-items {
|
|
171
|
+
display: grid;
|
|
172
|
+
grid-template-rows: 0fr;
|
|
173
|
+
opacity: 0;
|
|
174
|
+
pointer-events: none;
|
|
175
|
+
transition:
|
|
176
|
+
grid-template-rows 0.35s ease,
|
|
177
|
+
opacity 0.25s ease;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.sub-menu-items.itemsOpened {
|
|
181
|
+
grid-template-rows: 1fr;
|
|
182
|
+
opacity: 1;
|
|
183
|
+
pointer-events: auto;
|
|
184
|
+
}
|
|
185
|
+
.sub-menu-items.itemsClosed {
|
|
186
|
+
grid-template-rows: 0fr;
|
|
187
|
+
opacity: 0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.sub-menu-content {
|
|
191
|
+
min-height: 0;
|
|
192
|
+
overflow: hidden;
|
|
193
|
+
}
|
|
146
194
|
</style>
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
class="horizontal-top-menu-item"
|
|
7
7
|
:class="{ 'menu-hover': item.opened, active: item.opened }"
|
|
8
8
|
@mouseenter="hoverOpenTopMenuItem($event, item)"
|
|
9
|
+
@mouseleave="closeTopMenuItem($event, item)"
|
|
9
10
|
>
|
|
10
11
|
<div
|
|
11
12
|
class="top-menu-item-heading"
|
|
@@ -23,7 +24,6 @@
|
|
|
23
24
|
</div>
|
|
24
25
|
|
|
25
26
|
<TopSubMenuItems
|
|
26
|
-
@mouseleave="closeTopMenuItem($event, item)"
|
|
27
27
|
v-if="item.items?.length"
|
|
28
28
|
:item="item"
|
|
29
29
|
:topMenuItems="topMenuItems"
|
|
@@ -85,6 +85,10 @@ export default {
|
|
|
85
85
|
if (this.menuTimeout) {
|
|
86
86
|
clearTimeout(this.menuTimeout);
|
|
87
87
|
}
|
|
88
|
+
if (item.opened) {
|
|
89
|
+
this.menuTimeout = null;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
88
92
|
document
|
|
89
93
|
.querySelector<Element>(`.horizontal-top-menu-item-${item.id}`)
|
|
90
94
|
?.classList.add("menu-hover");
|
|
@@ -96,14 +100,14 @@ export default {
|
|
|
96
100
|
|
|
97
101
|
this.menuTimeout = setTimeout(() => {
|
|
98
102
|
item.opened = true;
|
|
99
|
-
this.closeSubItems(item);
|
|
100
103
|
this.menuTimeout = null;
|
|
101
104
|
}, 200);
|
|
102
105
|
},
|
|
103
106
|
closeTopMenuItem(event: MouseEvent, item: any) {
|
|
104
|
-
document
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
const dataItem = document.querySelector<Element>(
|
|
108
|
+
`.horizontal-top-menu-item-${item.id}`
|
|
109
|
+
);
|
|
110
|
+
dataItem?.classList.remove("menu-hover");
|
|
107
111
|
|
|
108
112
|
if (this.menuTimeout) {
|
|
109
113
|
clearTimeout(this.menuTimeout);
|
|
@@ -120,7 +124,6 @@ export default {
|
|
|
120
124
|
item.opened = false;
|
|
121
125
|
item.openIcon = faChevronDown;
|
|
122
126
|
}
|
|
123
|
-
this.closeSubItems(item);
|
|
124
127
|
},
|
|
125
128
|
openMenuItem(event: MouseEvent, item: any) {
|
|
126
129
|
item.openIcon = faChevronUp;
|
|
@@ -133,16 +136,14 @@ export default {
|
|
|
133
136
|
for (const item of items) {
|
|
134
137
|
item.opened = false;
|
|
135
138
|
item.openIcon = faChevronDown;
|
|
139
|
+
this.closeSubItems(item);
|
|
136
140
|
}
|
|
137
141
|
},
|
|
138
142
|
closeSubItems(item: any) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
this.closeSubItems(subItem);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
143
|
+
for (const subItem of item.items ?? []) {
|
|
144
|
+
subItem.opened = false;
|
|
145
|
+
subItem.openIcon = faChevronDown;
|
|
146
|
+
this.closeSubItems(subItem);
|
|
146
147
|
}
|
|
147
148
|
},
|
|
148
149
|
},
|
|
@@ -215,10 +216,10 @@ export default {
|
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
.icon-opened {
|
|
218
|
-
animation: openMenu 0.
|
|
219
|
+
animation: openMenu 0.4s ease forwards;
|
|
219
220
|
}
|
|
220
221
|
|
|
221
222
|
.icon-closed {
|
|
222
|
-
animation: closeMenu 0.
|
|
223
|
+
animation: closeMenu 0.4s ease forwards;
|
|
223
224
|
}
|
|
224
225
|
</style>
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
v-for="(subSubItem, index) in item.items"
|
|
9
9
|
:key="subSubItem.id"
|
|
10
10
|
class="item"
|
|
11
|
+
@mouseleave="closeTopMenuItem($event, subSubItem)"
|
|
11
12
|
>
|
|
12
13
|
<div
|
|
13
14
|
class="top-menu-item"
|
|
@@ -18,13 +19,12 @@
|
|
|
18
19
|
<div v-if="subSubItem.items?.length">
|
|
19
20
|
<FontAwesomeIcon
|
|
20
21
|
:size="'sm'"
|
|
21
|
-
:class="{ 'icon-opened':
|
|
22
|
+
:class="{ 'icon-opened': subSubItem.opened }"
|
|
22
23
|
:icon="subSubItem.openIcon"
|
|
23
24
|
></FontAwesomeIcon>
|
|
24
25
|
</div>
|
|
25
26
|
</div>
|
|
26
27
|
<TopSubMenuItems
|
|
27
|
-
@mouseleave="closeTopMenuItem($event, subSubItem)"
|
|
28
28
|
:style="{ top: `${Number(index) * 70}px`, right: `${2 * 10 + 40}px` }"
|
|
29
29
|
v-if="subSubItem.items?.length"
|
|
30
30
|
:key="subSubItem.id"
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
<script lang="ts">
|
|
41
41
|
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
|
42
|
+
import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
|
|
42
43
|
import { toTop } from "../../routing/routing";
|
|
43
44
|
import { TopMenuItems } from "../../models/menu-models";
|
|
44
45
|
|
|
@@ -84,6 +85,15 @@ export default {
|
|
|
84
85
|
},
|
|
85
86
|
closeTopMenuItem(event: MouseEvent, item: any) {
|
|
86
87
|
item.opened = false;
|
|
88
|
+
item.openIcon = faChevronDown;
|
|
89
|
+
this.closeSubItems(item);
|
|
90
|
+
},
|
|
91
|
+
closeSubItems(item: any) {
|
|
92
|
+
for (const subItem of item.items ?? []) {
|
|
93
|
+
subItem.opened = false;
|
|
94
|
+
subItem.openIcon = faChevronDown;
|
|
95
|
+
this.closeSubItems(subItem);
|
|
96
|
+
}
|
|
87
97
|
},
|
|
88
98
|
openTopMenuItem(event: MouseEvent, item: any) {
|
|
89
99
|
if (!item.items?.length) {
|
|
@@ -98,7 +108,7 @@ export default {
|
|
|
98
108
|
<style>
|
|
99
109
|
.top-sub-menu-items {
|
|
100
110
|
position: absolute;
|
|
101
|
-
top:
|
|
111
|
+
top: 42px;
|
|
102
112
|
right: 0px;
|
|
103
113
|
padding: 8px 0px;
|
|
104
114
|
margin-top: 1px;
|