@modelmenu/navigation 1.1.0 → 2.1.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.
@@ -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 @changeMenuItem="handleMenuItem($event)" :item="item" :menuBar="menuBar" :left-items="leftMenuItems"></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 }}
@@ -29,12 +29,13 @@
29
29
 
30
30
  <div class="main" :class="{'main-loading': menuBar.loading}">
31
31
  <slot name="handler"></slot>
32
- <div class="loader " v-if="menuBar.loading">
33
- <svg class="loader-icon" viewBox="0 0 64 64" aria-hidden="true">
34
- <circle class="loader-track" cx="32" cy="32" r="24"></circle>
35
- <circle class="loader-ring" cx="32" cy="32" r="24"></circle>
36
- </svg>
37
- </div>
32
+ </div>
33
+
34
+ <div class="loader " v-if="menuBar.loading">
35
+ <svg class="loader-icon" viewBox="0 0 64 64" aria-hidden="true">
36
+ <circle class="loader-track" cx="32" cy="32" r="24"></circle>
37
+ <circle class="loader-ring" cx="32" cy="32" r="24"></circle>
38
+ </svg>
38
39
  </div>
39
40
  </div>
40
41
 
@@ -92,16 +93,12 @@
92
93
  this.leftItems = newVal;
93
94
  const idCounter = { value: 0 };
94
95
  this.leftMenuItems = this.toLeftMenuItems(newVal, idCounter);
95
- this.setActiveByRoute();
96
96
  },
97
97
  topItems(newVal: any) {
98
98
  this.topItems = newVal;
99
99
  },
100
100
  },
101
101
  mounted() {
102
- watch(() => this.$route, () => {
103
- this.setActiveByRoute();
104
- });
105
102
  },
106
103
  created() {
107
104
  const idCounter = { value: 0 };
@@ -110,7 +107,6 @@
110
107
  router(this.Router);
111
108
  load(false);
112
109
  menubar(this.menuBar);
113
- this.setActiveByRoute();
114
110
  },
115
111
  initTheme(){
116
112
  let themeLink = themes.find(x=> x.type === this.theme.type);
@@ -122,7 +118,6 @@
122
118
  data() {
123
119
  return {
124
120
  menuBar: this.initialMenuBar,
125
- faChevronDown: faChevronDown,
126
121
  faChevronRight: faChevronRight,
127
122
  topMenuItems: [] as TopMenuItems[],
128
123
  leftMenuItems: [] as LeftMenuItems[],
@@ -181,31 +176,6 @@
181
176
  openSubMenu(item: any) {
182
177
  item.opened = !item.opened;
183
178
  },
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
179
  showTooltipItems(event: any, items: any[]) {
210
180
  if (!this.menuBar.opened) {
211
181
  if(items?.length){
@@ -224,30 +194,37 @@
224
194
  for(let subItem of this.leftMenuItems || []){
225
195
  if(subItem.items?.length){
226
196
  subItem.opened = true;
227
- subItem.openIcon = subItem.openIcon ? faChevronDown : faChevronRight;
197
+ subItem.openIcon = subItem.openIcon ? faChevronDown : faChevronUp;
228
198
  }
229
199
  }
230
200
  let item1 = this.leftMenuItems.find(x=> x.name === item.name);
231
201
  if(item1){
232
202
  item1.opened = !item1.opened;
233
- item1.openIcon = item1.opened ? faChevronDown : faChevronRight;
203
+ item1.openIcon = item1.opened ? faChevronDown : faChevronUp;
234
204
  }
235
205
  },
236
206
  openTooltipItem(event: any, item: any, parentItem: any) {
207
+ this.closeItems(this.leftMenuItems);
237
208
  if(item.items?.length){
238
209
  this.openVerticalMenu(event);
239
210
  let parent = this.leftMenuItems.find((x: any) => x.id === parentItem.id)!;
240
211
  parent.opened = true;
241
- parent.openIcon = faChevronUp;
242
212
 
243
213
  let currentItem = parent.items.find((x: any) => x.id === item.id)!;
244
214
  currentItem.opened = true;
245
- currentItem.openIcon = faChevronUp;
246
215
  return;
247
216
  }
248
217
  parentItem.active = true;
249
218
  toTop(item.route);
250
- }
219
+ },
220
+ closeItems(items: any[]) {
221
+ for(let item of items){
222
+ item.active = false;
223
+ if(item.items?.length){
224
+ this.closeItems(item.items);
225
+ }
226
+ }
227
+ },
251
228
  }
252
229
  });
253
230
  </script>
@@ -290,14 +267,15 @@
290
267
  .loader{
291
268
  width: 100%;
292
269
  display: flex;
293
- justify-content: center;
294
- align-items: center;
270
+ position: fixed;
271
+ top: 40%;
272
+ left: 50%;
295
273
  height: 36dvh;
296
274
  }
297
275
 
298
276
  .loader-icon{
299
- width: 80px;
300
- height: 80px;
277
+ width: 60px;
278
+ height: 60px;
301
279
  transform-origin: center;
302
280
  animation: rotateLoader 1s linear infinite;
303
281
  }
@@ -381,6 +359,7 @@
381
359
  width: 70px;
382
360
  animation: closeMenu 0.3s ease-out forwards;
383
361
  height: 100dvh;
362
+ background-color: white;
384
363
  border-right: 1px solid rgba(70, 70, 70, 0.5);
385
364
  }
386
365
 
@@ -517,7 +496,7 @@
517
496
  }
518
497
 
519
498
  .main-loading{
520
- opacity: 0.1;
499
+ opacity: 0;
521
500
  background-color: white;
522
501
  }
523
502
  </style>
@@ -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="{'menu-text-opened': menuBar.opened, 'menu-text-closed': !menuBar.opened }" :icon="item.openIcon"></FontAwesomeIcon>
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(-30px);
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(-30px);
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
- item.opened = true;
60
- item.openIcon = faChevronDown;
61
- this.closeSubItems(item);
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
- item.opened = false;
66
- item.openIcon = faChevronRight;
67
- this.closeSubItems(item);
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 = faChevronRight;
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-left: 16px;
140
- padding-right: 10px;
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, faChevronUp } from '@fortawesome/free-solid-svg-icons';
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
- faChevronDown: faChevronDown,
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 = faChevronRight;
41
+ openIcon: any = faChevronUp;
42
42
  items: TopMenuItems[] = [] as TopMenuItems[];
43
43
  }
44
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelmenu/navigation",
3
- "version": "1.1.0",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "main": "./menu/index.d.ts",
6
6
  "type": "module",