refactor: #7090 for TieredMenu
parent
6498320863
commit
f36d6c0285
|
@ -1,13 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<Portal :appendTo="appendTo" :disabled="!popup">
|
<Portal :appendTo="appendTo" :disabled="!popup">
|
||||||
<transition name="p-connected-overlay" @enter="onEnter" @after-enter="onAfterEnter" @leave="onLeave" @after-leave="onAfterLeave" v-bind="ptm('transition')">
|
<transition name="p-connected-overlay" @enter="onEnter" @after-enter="onAfterEnter" @leave="onLeave" @after-leave="onAfterLeave" v-bind="ptm('transition')">
|
||||||
<div v-if="visible" :ref="containerRef" :id="id" :class="cx('root')" @click="onOverlayClick" v-bind="ptmi('root')">
|
<div v-if="visible" :ref="containerRef" :id="$id" :class="cx('root')" @click="onOverlayClick" v-bind="ptmi('root')">
|
||||||
<div v-if="$slots.start" :class="cx('start')" v-bind="ptm('start')">
|
<div v-if="$slots.start" :class="cx('start')" v-bind="ptm('start')">
|
||||||
<slot name="start"></slot>
|
<slot name="start"></slot>
|
||||||
</div>
|
</div>
|
||||||
<TieredMenuSub
|
<TieredMenuSub
|
||||||
:ref="menubarRef"
|
:ref="menubarRef"
|
||||||
:id="id + '_list'"
|
:id="$id + '_list'"
|
||||||
:class="cx('rootList')"
|
:class="cx('rootList')"
|
||||||
:tabindex="!disabled ? tabindex : -1"
|
:tabindex="!disabled ? tabindex : -1"
|
||||||
role="menubar"
|
role="menubar"
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
:aria-disabled="disabled || undefined"
|
:aria-disabled="disabled || undefined"
|
||||||
aria-orientation="vertical"
|
aria-orientation="vertical"
|
||||||
:aria-activedescendant="focused ? focusedItemId : undefined"
|
:aria-activedescendant="focused ? focusedItemId : undefined"
|
||||||
:menuId="id"
|
:menuId="$id"
|
||||||
:focusedItemId="focused ? focusedItemId : undefined"
|
:focusedItemId="focused ? focusedItemId : undefined"
|
||||||
:items="processedItems"
|
:items="processedItems"
|
||||||
:templates="$slots"
|
:templates="$slots"
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
import { absolutePosition, addStyle, findSingle, focus, getOuterWidth, isTouchDevice } from '@primeuix/utils/dom';
|
import { absolutePosition, addStyle, findSingle, focus, getOuterWidth, isTouchDevice } from '@primeuix/utils/dom';
|
||||||
import { findLastIndex, isEmpty, isNotEmpty, isPrintableCharacter, resolve } from '@primeuix/utils/object';
|
import { findLastIndex, isEmpty, isNotEmpty, isPrintableCharacter, resolve } from '@primeuix/utils/object';
|
||||||
import { ZIndex } from '@primeuix/utils/zindex';
|
import { ZIndex } from '@primeuix/utils/zindex';
|
||||||
import { ConnectedOverlayScrollHandler, UniqueComponentId } from '@primevue/core/utils';
|
import { ConnectedOverlayScrollHandler } from '@primevue/core/utils';
|
||||||
import OverlayEventBus from 'primevue/overlayeventbus';
|
import OverlayEventBus from 'primevue/overlayeventbus';
|
||||||
import Portal from 'primevue/portal';
|
import Portal from 'primevue/portal';
|
||||||
import BaseTieredMenu from './BaseTieredMenu.vue';
|
import BaseTieredMenu from './BaseTieredMenu.vue';
|
||||||
|
@ -67,7 +67,6 @@ export default {
|
||||||
searchValue: null,
|
searchValue: null,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
id: this.$attrs.id,
|
|
||||||
focused: false,
|
focused: false,
|
||||||
focusedItemInfo: { index: -1, level: 0, parentKey: '' },
|
focusedItemInfo: { index: -1, level: 0, parentKey: '' },
|
||||||
activeItemPath: [],
|
activeItemPath: [],
|
||||||
|
@ -79,9 +78,6 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'$attrs.id': function (newValue) {
|
|
||||||
this.id = newValue || UniqueComponentId();
|
|
||||||
},
|
|
||||||
activeItemPath(newPath) {
|
activeItemPath(newPath) {
|
||||||
if (!this.popup) {
|
if (!this.popup) {
|
||||||
if (isNotEmpty(newPath)) {
|
if (isNotEmpty(newPath)) {
|
||||||
|
@ -95,7 +91,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.id = this.id || UniqueComponentId();
|
|
||||||
this.bindMatchMediaListener();
|
this.bindMatchMediaListener();
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
|
@ -612,7 +607,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scrollInView(index = -1) {
|
scrollInView(index = -1) {
|
||||||
const id = index !== -1 ? `${this.id}_${index}` : this.focusedItemId;
|
const id = index !== -1 ? `${this.$id}_${index}` : this.focusedItemId;
|
||||||
const element = findSingle(this.menubar, `li[id="${id}"]`);
|
const element = findSingle(this.menubar, `li[id="${id}"]`);
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
|
@ -657,7 +652,7 @@ export default {
|
||||||
return processedItem ? processedItem.items : this.processedItems;
|
return processedItem ? processedItem.items : this.processedItems;
|
||||||
},
|
},
|
||||||
focusedItemId() {
|
focusedItemId() {
|
||||||
return this.focusedItemInfo.index !== -1 ? `${this.id}${isNotEmpty(this.focusedItemInfo.parentKey) ? '_' + this.focusedItemInfo.parentKey : ''}_${this.focusedItemInfo.index}` : null;
|
return this.focusedItemInfo.index !== -1 ? `${this.$id}${isNotEmpty(this.focusedItemInfo.parentKey) ? '_' + this.focusedItemInfo.parentKey : ''}_${this.focusedItemInfo.index}` : null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
Loading…
Reference in New Issue