@modelmenu/navigation 1.0.0 → 2.0.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/README.MD +6 -0
- package/dist/index.es.js +566 -581
- package/dist/index.umd.js +10 -10
- package/menu/MenuPlate.vue +4 -35
- package/menu/components/menu-item.vue +19 -6
- package/menu/components/sub-menu-items.vue +8 -3
- package/menu/components/top-menu-items/top-menu-item.vue +37 -13
- package/menu/components/top-menu-items/top-sub-menu-items.vue +15 -16
- package/menu/models/menu-models.ts +2 -2
- package/package.json +1 -1
package/menu/MenuPlate.vue
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
<div class="vertical-menu" :class="{'vertical-menu-opened': menuBar.opened}">
|
|
13
13
|
<div v-for="(item, index) in leftMenuItems" :key="index" :class="['menu-item-heading', { 'item-active': item.active }]" @mouseenter="showTooltipItems($event, item.items)">
|
|
14
14
|
<div class="item" :class="{'menu-item-opened': menuBar.opened, }">
|
|
15
|
-
<MenuItem
|
|
16
|
-
<SubMenuItems @openmenu="handleOpenMenu($event)" v-show="menuBar.opened" :left-menu-items="leftMenuItems" :item="item" :menuBar="menuBar"></SubMenuItems>
|
|
15
|
+
<MenuItem :item="item" :menuBar="menuBar" :left-items="leftMenuItems"></MenuItem>
|
|
16
|
+
<SubMenuItems @openmenu="handleOpenMenu($event)" @changeMenuItem="handleMenuItem($event)" v-show="menuBar.opened" :left-menu-items="leftMenuItems" :item="item" :menuBar="menuBar"></SubMenuItems>
|
|
17
17
|
<div class="active-tooltip" v-if="tooltip && item.items?.length && !menuBar.opened" @mouseleave="hideTooltipItems($event)">
|
|
18
18
|
<div v-for="value in item.items" :key="value.name" class="tooltip-item" @click="openTooltipItem($event, value, item)">
|
|
19
19
|
{{ value.name }}
|
|
@@ -92,16 +92,12 @@
|
|
|
92
92
|
this.leftItems = newVal;
|
|
93
93
|
const idCounter = { value: 0 };
|
|
94
94
|
this.leftMenuItems = this.toLeftMenuItems(newVal, idCounter);
|
|
95
|
-
this.setActiveByRoute();
|
|
96
95
|
},
|
|
97
96
|
topItems(newVal: any) {
|
|
98
97
|
this.topItems = newVal;
|
|
99
98
|
},
|
|
100
99
|
},
|
|
101
100
|
mounted() {
|
|
102
|
-
watch(() => this.$route, () => {
|
|
103
|
-
this.setActiveByRoute();
|
|
104
|
-
});
|
|
105
101
|
},
|
|
106
102
|
created() {
|
|
107
103
|
const idCounter = { value: 0 };
|
|
@@ -110,7 +106,6 @@
|
|
|
110
106
|
router(this.Router);
|
|
111
107
|
load(false);
|
|
112
108
|
menubar(this.menuBar);
|
|
113
|
-
this.setActiveByRoute();
|
|
114
109
|
},
|
|
115
110
|
initTheme(){
|
|
116
111
|
let themeLink = themes.find(x=> x.type === this.theme.type);
|
|
@@ -122,7 +117,6 @@
|
|
|
122
117
|
data() {
|
|
123
118
|
return {
|
|
124
119
|
menuBar: this.initialMenuBar,
|
|
125
|
-
faChevronDown: faChevronDown,
|
|
126
120
|
faChevronRight: faChevronRight,
|
|
127
121
|
topMenuItems: [] as TopMenuItems[],
|
|
128
122
|
leftMenuItems: [] as LeftMenuItems[],
|
|
@@ -181,31 +175,6 @@
|
|
|
181
175
|
openSubMenu(item: any) {
|
|
182
176
|
item.opened = !item.opened;
|
|
183
177
|
},
|
|
184
|
-
setActiveByRoute() {
|
|
185
|
-
const path = this.$route?.path || '/';
|
|
186
|
-
this.clearActiveItems(this.leftMenuItems);
|
|
187
|
-
this.markActiveRoute(this.leftMenuItems, path);
|
|
188
|
-
},
|
|
189
|
-
clearActiveItems(items: any[]) {
|
|
190
|
-
for (const item of items) {
|
|
191
|
-
item.active = false;
|
|
192
|
-
if (item.items?.length) {
|
|
193
|
-
this.clearActiveItems(item.items);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
markActiveRoute(items: any[], path: string): boolean {
|
|
198
|
-
let found = false;
|
|
199
|
-
for (const item of items) {
|
|
200
|
-
const childActive = item.items?.length ? this.markActiveRoute(item.items, path) : false;
|
|
201
|
-
item.active = item.route === path || childActive;
|
|
202
|
-
item.opened = childActive;
|
|
203
|
-
if (item.active) {
|
|
204
|
-
found = true;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return found;
|
|
208
|
-
},
|
|
209
178
|
showTooltipItems(event: any, items: any[]) {
|
|
210
179
|
if (!this.menuBar.opened) {
|
|
211
180
|
if(items?.length){
|
|
@@ -224,13 +193,13 @@
|
|
|
224
193
|
for(let subItem of this.leftMenuItems || []){
|
|
225
194
|
if(subItem.items?.length){
|
|
226
195
|
subItem.opened = true;
|
|
227
|
-
subItem.openIcon = subItem.openIcon ? faChevronDown :
|
|
196
|
+
subItem.openIcon = subItem.openIcon ? faChevronDown : faChevronUp;
|
|
228
197
|
}
|
|
229
198
|
}
|
|
230
199
|
let item1 = this.leftMenuItems.find(x=> x.name === item.name);
|
|
231
200
|
if(item1){
|
|
232
201
|
item1.opened = !item1.opened;
|
|
233
|
-
item1.openIcon = item1.opened ? faChevronDown :
|
|
202
|
+
item1.openIcon = item1.opened ? faChevronDown : faChevronUp;
|
|
234
203
|
}
|
|
235
204
|
},
|
|
236
205
|
openTooltipItem(event: any, item: any, parentItem: any) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<FontAwesomeIcon class="menu-item-icon" v-if="item.icon" :size="'lg'" :icon="item.icon"></FontAwesomeIcon>
|
|
4
4
|
<p class="menu-item-text" :class="{'menu-text-opened': menuBar.opened, 'menu-text-closed': !menuBar.opened }"> {{ item.name }}</p>
|
|
5
5
|
<div class="sub-menu-button" v-if="item.items?.length">
|
|
6
|
-
<FontAwesomeIcon :class="{'
|
|
6
|
+
<FontAwesomeIcon :class="{'icon-opened': item.opened}" :icon="item.openIcon"></FontAwesomeIcon>
|
|
7
7
|
</div>
|
|
8
8
|
</div>
|
|
9
9
|
</template>
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
<script lang="ts">
|
|
12
12
|
import { ref } from 'vue';
|
|
13
13
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
14
|
-
import { faChevronDown, faChevronRight } from '@fortawesome/free-solid-svg-icons';
|
|
15
14
|
import { router, to } from '../routing/routing';
|
|
16
15
|
import { LeftMenuItems } from '../models/menu-models';
|
|
17
16
|
|
|
@@ -36,7 +35,6 @@
|
|
|
36
35
|
},
|
|
37
36
|
data() {
|
|
38
37
|
return {
|
|
39
|
-
faChevronDown: faChevronDown,
|
|
40
38
|
menuBar: this.menuBar,
|
|
41
39
|
tooltip: true,
|
|
42
40
|
item: this.item,
|
|
@@ -65,12 +63,12 @@
|
|
|
65
63
|
if(!item.items?.length){
|
|
66
64
|
to(item.route);
|
|
67
65
|
|
|
66
|
+
this.setUnActiveItems(this.leftItems);
|
|
68
67
|
let activeItem = this.findItem(this.leftItems, item, true);
|
|
69
68
|
this.$emit('changeMenuItem', this.leftItems);
|
|
70
69
|
return;
|
|
71
70
|
}
|
|
72
71
|
item.opened = !item.opened;
|
|
73
|
-
item.openIcon = item.opened ? faChevronDown : faChevronRight;
|
|
74
72
|
|
|
75
73
|
if(!this.menuBar.opened){
|
|
76
74
|
return;
|
|
@@ -80,12 +78,15 @@
|
|
|
80
78
|
for(const entry of items){
|
|
81
79
|
if(entry.id === item.id){
|
|
82
80
|
entry.active = setActive;
|
|
81
|
+
entry.opened = setActive;
|
|
83
82
|
return entry;
|
|
84
83
|
}
|
|
84
|
+
|
|
85
85
|
if(entry.items?.length){
|
|
86
86
|
const found = this.findItem(entry.items, item, setActive);
|
|
87
87
|
if(found){
|
|
88
88
|
entry.active = setActive;
|
|
89
|
+
entry.opened = setActive;
|
|
89
90
|
return found;
|
|
90
91
|
}
|
|
91
92
|
}
|
|
@@ -204,7 +205,7 @@
|
|
|
204
205
|
@keyframes openMenuText {
|
|
205
206
|
from {
|
|
206
207
|
opacity: 0;
|
|
207
|
-
transform: translateX(-
|
|
208
|
+
transform: translateX(-20px);
|
|
208
209
|
}
|
|
209
210
|
to {
|
|
210
211
|
opacity: 1;
|
|
@@ -219,8 +220,20 @@
|
|
|
219
220
|
}
|
|
220
221
|
to {
|
|
221
222
|
opacity: 0;
|
|
222
|
-
transform: translateX(-
|
|
223
|
+
transform: translateX(-20px);
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
226
|
|
|
227
|
+
@keyframes openMenu {
|
|
228
|
+
from {
|
|
229
|
+
transform: rotate(0deg);
|
|
230
|
+
}
|
|
231
|
+
to {
|
|
232
|
+
transform: rotate(90deg);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.icon-opened{
|
|
237
|
+
animation: openMenu 0.02s ease forwards;
|
|
238
|
+
}
|
|
226
239
|
</style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="sub-menu-items" v-if="item.opened">
|
|
3
3
|
<div v-for="(subItem, subIndex) in item.items" :key="subIndex" class="item" :class="{'menu-item-opened': menuBar.opened }" @mouseenter="showTooltipItems($event)" @mouseleave="hideTooltipItems($event)">
|
|
4
|
-
<MenuItem :item="subItem" :leftItems="leftMenuItems" :menuBar="menuBar" ></MenuItem>
|
|
5
|
-
<SubMenuItems v-if="subItem.items?.length" v-show="menuBar.opened" :item="subItem" :menuBar="menuBar"></SubMenuItems>
|
|
4
|
+
<MenuItem :item="subItem" :leftItems="leftMenuItems" @changeMenuItem="handleMenuItem($event)" :menuBar="menuBar" ></MenuItem>
|
|
5
|
+
<SubMenuItems v-if="subItem.items?.length" @changeMenuItem="handleMenuItem($event)" v-show="menuBar.opened" :item="subItem" :menuBar="menuBar"></SubMenuItems>
|
|
6
6
|
<div class="active-tooltip" v-if="tooltip && subItem.items?.length">
|
|
7
7
|
<div v-for="value in subItem.items" :key="value.name" class="tooltip-item" @click="tooltipItemClick($event, subItem, value)" v-if="!menuBar.opened" @mouseenter="showTooltipItems($event)" @mouseleave="hideTooltipItems($event)">
|
|
8
8
|
{{ value.name }}
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
emits: [
|
|
47
|
-
'openmenu'
|
|
47
|
+
'openmenu',
|
|
48
|
+
'changeMenuItem'
|
|
48
49
|
],
|
|
49
50
|
watch:{
|
|
50
51
|
menuBar(newVal: any) {
|
|
@@ -62,6 +63,9 @@
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
},
|
|
66
|
+
handleMenuItem(event: any){
|
|
67
|
+
this.$emit('changeMenuItem', event);
|
|
68
|
+
},
|
|
65
69
|
hideTooltipItems(event: any) {
|
|
66
70
|
if (!this.menuBar.opened) {
|
|
67
71
|
this.tooltip = false;
|
|
@@ -89,6 +93,7 @@
|
|
|
89
93
|
left: 74px;
|
|
90
94
|
width: 240px;
|
|
91
95
|
height: 80px;
|
|
96
|
+
border-radius: 4px;
|
|
92
97
|
border: 1px solid #424242;
|
|
93
98
|
background-color: white !important;
|
|
94
99
|
z-index: 999999999;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<div class="top-menu-item-heading" @click="openMenuItem($event, item)" @mouseleave="closeTopMenu($event, item)">
|
|
6
6
|
{{ item.name }}
|
|
7
|
-
<div v-if="item.items?.length"><FontAwesomeIcon :size="'sm'" :icon="item.openIcon"></FontAwesomeIcon></div>
|
|
7
|
+
<div v-if="item.items?.length"><FontAwesomeIcon :size="'sm'" :class="{'icon-opened': item.opened}" :icon="item.openIcon"></FontAwesomeIcon></div>
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<TopSubMenuItems @mouseleave="closeTopMenuItem($event, item)" v-if="item.items?.length" :item="item" :topMenuItems="topMenuItems" :menuBar="menuBar" @click.stop></TopSubMenuItems>
|
|
@@ -55,21 +55,27 @@ import { toTop } from '../../routing/routing';
|
|
|
55
55
|
|
|
56
56
|
},
|
|
57
57
|
hoverOpenTopMenuItem(event: MouseEvent, item: any) {
|
|
58
|
-
document.querySelector(`.horizontal-top-menu-item-${item.id}`)?.classList.add('menu-hover');
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
document.querySelector<Element>(`.horizontal-top-menu-item-${item.id}`)?.classList.add('menu-hover');
|
|
59
|
+
this.closeMenuTabs(this.topMenuItems);
|
|
60
|
+
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
item.opened = true;
|
|
63
|
+
this.closeSubItems(item);
|
|
64
|
+
}, 200)
|
|
62
65
|
},
|
|
63
66
|
closeTopMenuItem(event: MouseEvent, item: any) {
|
|
64
|
-
document.querySelector(`.horizontal-top-menu-item-${item.id}`)?.classList.remove('menu-hover');
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
document.querySelector<Element>(`.horizontal-top-menu-item-${item.id}`)?.classList.remove('menu-hover');
|
|
68
|
+
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
item.opened = false;
|
|
71
|
+
item.openIcon = faChevronUp;
|
|
72
|
+
this.closeSubItems(item);
|
|
73
|
+
}, 200)
|
|
68
74
|
},
|
|
69
75
|
closeTopMenu(event: MouseEvent, item: any) {
|
|
70
76
|
if(!item.items?.length){
|
|
71
77
|
item.opened = false;
|
|
72
|
-
item.openIcon =
|
|
78
|
+
item.openIcon = faChevronUp;
|
|
73
79
|
}
|
|
74
80
|
this.closeSubItems(item);
|
|
75
81
|
},
|
|
@@ -79,6 +85,12 @@ import { toTop } from '../../routing/routing';
|
|
|
79
85
|
return;
|
|
80
86
|
}
|
|
81
87
|
},
|
|
88
|
+
closeMenuTabs(items: any[]) {
|
|
89
|
+
for(let item of items){
|
|
90
|
+
item.opened = false;
|
|
91
|
+
item.openIcon = faChevronUp;
|
|
92
|
+
}
|
|
93
|
+
},
|
|
82
94
|
closeSubItems(item: any) {
|
|
83
95
|
if(!item.opened){
|
|
84
96
|
for(let subItem of item.items || []){
|
|
@@ -132,11 +144,23 @@ import { toTop } from '../../routing/routing';
|
|
|
132
144
|
.horizontal-top-menu-item{
|
|
133
145
|
display: flex;
|
|
134
146
|
align-items: center;
|
|
147
|
+
box-sizing: border-box;
|
|
135
148
|
cursor: pointer;
|
|
136
149
|
height: 48px;
|
|
137
|
-
width: 70px;
|
|
138
150
|
border-bottom: 2px solid transparent;
|
|
139
|
-
padding
|
|
140
|
-
|
|
151
|
+
padding: 4px 12px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@keyframes openMenu {
|
|
155
|
+
from {
|
|
156
|
+
transform: rotate(0deg);
|
|
157
|
+
}
|
|
158
|
+
to {
|
|
159
|
+
transform: rotate(180deg);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.icon-opened{
|
|
164
|
+
animation: openMenu 0.02s ease forwards;
|
|
141
165
|
}
|
|
142
166
|
</style>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="top-sub-menu-items" v-if="item.opened">
|
|
3
3
|
<div v-for="(subSubItem, index) in item.items" :key="subSubItem.id" class="item">
|
|
4
4
|
<div class="top-menu-item" @click.stop="openTopMenuItem($event, subSubItem)" @mouseenter="openHoverTopMenuItem($event, subSubItem)">
|
|
5
|
-
{{ subSubItem.name }} <div v-if="subSubItem.items?.length" style="margin-left: 8px;"><FontAwesomeIcon :size="'sm'" :icon="subSubItem.openIcon"></FontAwesomeIcon></div>
|
|
5
|
+
{{ subSubItem.name }} <div v-if="subSubItem.items?.length" style="margin-left: 8px;"><FontAwesomeIcon :size="'sm'" :class="{'icon-opened': item.opened}" :icon="subSubItem.openIcon"></FontAwesomeIcon></div>
|
|
6
6
|
</div>
|
|
7
7
|
<TopSubMenuItems @mouseleave="closeTopMenuItem($event, subSubItem)" :style="{top: `${(Number(index)) * 70}px`, right: `${2 * 10 + 40}px`}" v-if="subSubItem.items?.length" :key="subSubItem.id" :item="subSubItem" :topMenuItems="topMenuItems" :menuBar="menuBar"></TopSubMenuItems>
|
|
8
8
|
</div>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script lang="ts">
|
|
13
|
-
import { faChevronDown, faChevronRight
|
|
13
|
+
import { faChevronDown, faChevronRight } from '@fortawesome/free-solid-svg-icons';
|
|
14
14
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
|
15
15
|
import { toTop } from '../../routing/routing';
|
|
16
16
|
import { TopMenuItems } from '../../models/menu-models';
|
|
@@ -37,10 +37,9 @@ import { TopMenuItems } from '../../models/menu-models';
|
|
|
37
37
|
data() {
|
|
38
38
|
return {
|
|
39
39
|
tooltip: false,
|
|
40
|
-
|
|
40
|
+
topMenuItems: this.topMenuItems,
|
|
41
41
|
item: this.item,
|
|
42
42
|
menuBar: this.menuBar,
|
|
43
|
-
faChevronRight: faChevronRight,
|
|
44
43
|
toTop: toTop
|
|
45
44
|
}
|
|
46
45
|
},
|
|
@@ -55,11 +54,9 @@ import { TopMenuItems } from '../../models/menu-models';
|
|
|
55
54
|
methods: {
|
|
56
55
|
openHoverTopMenuItem(event: MouseEvent, item: any) {
|
|
57
56
|
item.opened = true;
|
|
58
|
-
item.openIcon = faChevronDown;
|
|
59
57
|
},
|
|
60
58
|
closeTopMenuItem(event: MouseEvent, item: any) {
|
|
61
59
|
item.opened = false;
|
|
62
|
-
item.openIcon = faChevronRight;
|
|
63
60
|
},
|
|
64
61
|
openTopMenuItem(event: MouseEvent, item: any) {
|
|
65
62
|
if(!item.items?.length){
|
|
@@ -67,16 +64,6 @@ import { TopMenuItems } from '../../models/menu-models';
|
|
|
67
64
|
return;
|
|
68
65
|
}
|
|
69
66
|
},
|
|
70
|
-
closeSubItems(item: any) {
|
|
71
|
-
if(!item.opened){
|
|
72
|
-
for(let subItem of item.items || []){
|
|
73
|
-
subItem.opened = false;
|
|
74
|
-
if(subItem.items?.length){
|
|
75
|
-
this.closeSubItems(subItem);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
67
|
}
|
|
81
68
|
};
|
|
82
69
|
</script>
|
|
@@ -110,4 +97,16 @@ import { TopMenuItems } from '../../models/menu-models';
|
|
|
110
97
|
padding: 3px 7px;
|
|
111
98
|
cursor: pointer;
|
|
112
99
|
}
|
|
100
|
+
@keyframes openMenu {
|
|
101
|
+
from {
|
|
102
|
+
transform: rotate(0deg);
|
|
103
|
+
}
|
|
104
|
+
to {
|
|
105
|
+
transform: rotate(180deg);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.icon-opened{
|
|
110
|
+
animation: openMenu 0.02s ease forwards;
|
|
111
|
+
}
|
|
113
112
|
</style>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { faChevronDown, faChevronLeft, faChevronRight } from "@fortawesome/free-solid-svg-icons";
|
|
1
|
+
import { faChevronDown, faChevronLeft, faChevronRight, faChevronUp } from "@fortawesome/free-solid-svg-icons";
|
|
2
2
|
|
|
3
3
|
export class LeftMenuModel{
|
|
4
4
|
name: string = '';
|
|
@@ -38,7 +38,7 @@ export class TopMenuItems{
|
|
|
38
38
|
route: string = '';
|
|
39
39
|
opened: boolean = false;
|
|
40
40
|
active: boolean = false;
|
|
41
|
-
openIcon: any =
|
|
41
|
+
openIcon: any = faChevronUp;
|
|
42
42
|
items: TopMenuItems[] = [] as TopMenuItems[];
|
|
43
43
|
}
|
|
44
44
|
|