@modelmenu/navigation 3.2.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.
@@ -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.items)"
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 && item.items?.length && !menuBar.opened,
51
+ tooltip &&
52
+ tooltipItemId === item.id &&
53
+ item.items?.length &&
54
+ !menuBar.opened,
49
55
  },
50
56
  ]"
51
- v-if="tooltip && item.items?.length && !menuBar.opened"
52
- @mouseleave="hideTooltipItems($event)"
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"
@@ -170,7 +182,8 @@ export default defineComponent({
170
182
  topMenuItems: [] as TopMenuItems[],
171
183
  leftMenuItems: [] as LeftMenuItems[],
172
184
  tooltip: false,
173
- tooltipItems: [] as any[],
185
+ tooltipItemId: null as number | null,
186
+ tooltipTimeout: null as ReturnType<typeof setTimeout> | null,
174
187
  topItems: this.topItems,
175
188
  leftItems: this.leftItems,
176
189
  floor: 20,
@@ -225,19 +238,29 @@ export default defineComponent({
225
238
  openSubMenu(item: any) {
226
239
  item.opened = !item.opened;
227
240
  },
228
- showTooltipItems(event: any, items: any[]) {
241
+ showTooltipItems(event: any, item: any) {
229
242
  if (!this.menuBar.opened) {
230
- if (items?.length) {
231
- this.tooltip = true;
232
- this.tooltipItems = items;
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);
233
251
  }
252
+ this.tooltipTimeout = setTimeout(() => {
253
+ this.setTooltipItem(null);
254
+ }, 150);
234
255
  }
235
256
  },
236
- hideTooltipItems(event: any) {
237
- if (!this.menuBar.opened) {
238
- this.tooltip = false;
239
- this.tooltipItems = [];
257
+ setTooltipItem(itemId: number | null) {
258
+ if (this.tooltipTimeout) {
259
+ clearTimeout(this.tooltipTimeout);
260
+ this.tooltipTimeout = null;
240
261
  }
262
+ this.tooltipItemId = itemId;
263
+ this.tooltip = itemId !== null;
241
264
  },
242
265
  handleOpenMenu(item: any) {
243
266
  for (const subItem of this.leftMenuItems || []) {
@@ -9,8 +9,8 @@
9
9
  :key="subIndex"
10
10
  class="item"
11
11
  :class="{ 'menu-item-opened': menuBar.opened }"
12
- @mouseenter="showTooltipItems($event)"
13
- @mouseleave="hideTooltipItems($event)"
12
+ @mouseenter="showTooltipItems($event, subItem)"
13
+ @mouseleave="hideTooltipItems($event, subItem)"
14
14
  >
15
15
  <MenuItem
16
16
  :item="subItem"
@@ -21,19 +21,27 @@
21
21
  <SubMenuItems
22
22
  v-if="subItem.items?.length"
23
23
  @changeMenuItem="handleMenuItem($event)"
24
+ @tooltip="handleTooltip($event)"
24
25
  v-show="menuBar.opened"
25
26
  :item="subItem"
26
27
  :menuBar="menuBar"
28
+ :active-tooltip-item-id="activeTooltipItemId"
27
29
  ></SubMenuItems>
28
- <div class="active-tooltip" v-if="tooltip && subItem.items?.length">
30
+ <div
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
+ "
38
+ >
29
39
  <div
30
40
  v-for="value in subItem.items"
31
41
  :key="value.name"
32
42
  class="tooltip-item"
33
43
  @click="tooltipItemClick($event, subItem, value)"
34
44
  v-if="!menuBar.opened"
35
- @mouseenter="showTooltipItems($event)"
36
- @mouseleave="hideTooltipItems($event)"
37
45
  >
38
46
  {{ value.name }}
39
47
  </div>
@@ -65,16 +73,19 @@ export default {
65
73
  type: Array,
66
74
  default: () => [],
67
75
  },
76
+ activeTooltipItemId: {
77
+ type: Number,
78
+ default: null,
79
+ },
68
80
  },
69
81
  data() {
70
82
  return {
71
83
  item: this.item,
72
- tooltip: false,
73
84
  menuBar: this.menuBar,
74
85
  leftMenuItems: this.leftMenuItems as any[],
75
86
  };
76
87
  },
77
- emits: ["openmenu", "changeMenuItem"],
88
+ emits: ["openmenu", "changeMenuItem", "tooltip"],
78
89
  watch: {
79
90
  menuBar(newVal: any) {
80
91
  this.menuBar = newVal;
@@ -84,19 +95,26 @@ export default {
84
95
  },
85
96
  },
86
97
  methods: {
87
- showTooltipItems(event: any) {
98
+ showTooltipItems(event: any, subItem: any) {
88
99
  if (!this.menuBar.opened) {
89
- if (this.item.items?.length) {
90
- this.tooltip = true;
91
- }
100
+ this.$emit(
101
+ "tooltip",
102
+ subItem.items?.length ? subItem.id : null
103
+ );
92
104
  }
93
105
  },
106
+ handleTooltip(itemId: number | null) {
107
+ this.$emit("tooltip", itemId);
108
+ },
94
109
  handleMenuItem(event: any) {
95
110
  this.$emit("changeMenuItem", event);
96
111
  },
97
- hideTooltipItems(event: any) {
98
- if (!this.menuBar.opened) {
99
- this.tooltip = false;
112
+ hideTooltipItems(event: any, subItem: any) {
113
+ if (
114
+ !this.menuBar.opened &&
115
+ this.activeTooltipItemId === subItem.id
116
+ ) {
117
+ this.$emit("tooltip", null);
100
118
  }
101
119
  },
102
120
  tooltipItemClick(event: any, subItem: any, value: any) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelmenu/navigation",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "",
5
5
  "main": "./menu/index.d.ts",
6
6
  "type": "module",