ketekny-ui-kit 1.0.110 → 1.0.112
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/package.json
CHANGED
|
@@ -234,6 +234,24 @@ export default {
|
|
|
234
234
|
},
|
|
235
235
|
},
|
|
236
236
|
methods: {
|
|
237
|
+
findMenuItemById(items, id) {
|
|
238
|
+
for (const item of items) {
|
|
239
|
+
if (item.id === id) return item
|
|
240
|
+
if (item?.children?.length) {
|
|
241
|
+
const found = this.findMenuItemById(item.children, id)
|
|
242
|
+
if (found) return found
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return null
|
|
246
|
+
},
|
|
247
|
+
collectDescendantIds(item, ids = []) {
|
|
248
|
+
if (!item?.children?.length) return ids
|
|
249
|
+
for (const child of item.children) {
|
|
250
|
+
ids.push(child.id)
|
|
251
|
+
this.collectDescendantIds(child, ids)
|
|
252
|
+
}
|
|
253
|
+
return ids
|
|
254
|
+
},
|
|
237
255
|
syncFavoritesFromMenu() {
|
|
238
256
|
const storedFavorites = this.readStoredFavorites()
|
|
239
257
|
const storedTab = this.readStoredActiveMenuTab()
|
|
@@ -293,10 +311,16 @@ export default {
|
|
|
293
311
|
},
|
|
294
312
|
toggle(id) {
|
|
295
313
|
if (this.openIds.has(id)) {
|
|
296
|
-
|
|
314
|
+
const target = this.findMenuItemById(this.mainMenu, id)
|
|
315
|
+
const next = new Set(this.openIds)
|
|
316
|
+
next.delete(id)
|
|
317
|
+
for (const childId of this.collectDescendantIds(target)) {
|
|
318
|
+
next.delete(childId)
|
|
319
|
+
}
|
|
320
|
+
this.openIds = next
|
|
297
321
|
return
|
|
298
322
|
}
|
|
299
|
-
this.openIds = new Set([id])
|
|
323
|
+
this.openIds = new Set([...this.openIds, id])
|
|
300
324
|
},
|
|
301
325
|
select(itemOrId) {
|
|
302
326
|
const id = typeof itemOrId === 'string' ? itemOrId : itemOrId?.id
|
|
@@ -19,6 +19,12 @@ export default {
|
|
|
19
19
|
theme: { type: String, default: 'dark' },
|
|
20
20
|
},
|
|
21
21
|
emits: ['select', 'toggle', 'toggle-favorite'],
|
|
22
|
+
data() {
|
|
23
|
+
return {
|
|
24
|
+
showLabelTooltip: false,
|
|
25
|
+
resizeObserver: null,
|
|
26
|
+
}
|
|
27
|
+
},
|
|
22
28
|
computed: {
|
|
23
29
|
hasChildren() {
|
|
24
30
|
return Array.isArray(this.item.children) && this.item.children.length > 0
|
|
@@ -54,12 +60,39 @@ export default {
|
|
|
54
60
|
}
|
|
55
61
|
},
|
|
56
62
|
},
|
|
63
|
+
mounted() {
|
|
64
|
+
this.$nextTick(() => {
|
|
65
|
+
this.updateLabelTooltip()
|
|
66
|
+
if (typeof ResizeObserver !== 'undefined' && this.$refs.labelText) {
|
|
67
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
68
|
+
this.updateLabelTooltip()
|
|
69
|
+
})
|
|
70
|
+
this.resizeObserver.observe(this.$refs.labelText)
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
},
|
|
74
|
+
updated() {
|
|
75
|
+
this.$nextTick(() => {
|
|
76
|
+
this.updateLabelTooltip()
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
beforeUnmount() {
|
|
80
|
+
this.resizeObserver?.disconnect?.()
|
|
81
|
+
},
|
|
57
82
|
methods: {
|
|
58
83
|
containsActive(node) {
|
|
59
84
|
if (node.id === this.activeId) return true
|
|
60
85
|
if (!node.children) return false
|
|
61
86
|
return node.children.some((child) => this.containsActive(child))
|
|
62
87
|
},
|
|
88
|
+
updateLabelTooltip() {
|
|
89
|
+
const labelEl = this.$refs.labelText
|
|
90
|
+
if (!labelEl || this.isCollapsedTop) {
|
|
91
|
+
this.showLabelTooltip = false
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
this.showLabelTooltip = labelEl.scrollWidth > labelEl.clientWidth
|
|
95
|
+
},
|
|
63
96
|
handleClick() {
|
|
64
97
|
if (this.hasChildren && !this.isCollapsedTop) {
|
|
65
98
|
this.$emit('toggle', this.item.id)
|
|
@@ -127,7 +160,11 @@ export default {
|
|
|
127
160
|
/>
|
|
128
161
|
|
|
129
162
|
<template v-if="!isCollapsedTop">
|
|
130
|
-
<span
|
|
163
|
+
<span
|
|
164
|
+
ref="labelText"
|
|
165
|
+
class="flex-1 truncate"
|
|
166
|
+
v-tooltip.right="showLabelTooltip ? item.label : null"
|
|
167
|
+
>{{ item.label }}</span>
|
|
131
168
|
|
|
132
169
|
<span
|
|
133
170
|
v-if="item.badge != null"
|