159 lines
3.5 KiB
Vue
159 lines
3.5 KiB
Vue
<script>
|
|
import BaseComponent from 'primevue/basecomponent';
|
|
import { useStyle } from 'primevue/usestyle';
|
|
|
|
const styles = `
|
|
.p-menubar {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.p-menubar ul {
|
|
margin: 0;
|
|
padding: 0;
|
|
list-style: none;
|
|
}
|
|
|
|
.p-menubar .p-menuitem-link {
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
text-decoration: none;
|
|
overflow: hidden;
|
|
position: relative;
|
|
}
|
|
|
|
.p-menubar .p-menuitem-text {
|
|
line-height: 1;
|
|
}
|
|
|
|
.p-menubar .p-menuitem {
|
|
position: relative;
|
|
}
|
|
|
|
.p-menubar-root-list {
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.p-menubar-root-list > li ul {
|
|
display: none;
|
|
z-index: 1;
|
|
}
|
|
|
|
.p-menubar-root-list > .p-menuitem-active > .p-submenu-list {
|
|
display: block;
|
|
}
|
|
|
|
.p-menubar .p-submenu-list {
|
|
display: none;
|
|
position: absolute;
|
|
z-index: 1;
|
|
}
|
|
|
|
.p-menubar .p-submenu-list > .p-menuitem-active > .p-submenu-list {
|
|
display: block;
|
|
left: 100%;
|
|
top: 0;
|
|
}
|
|
|
|
.p-menubar .p-submenu-list .p-menuitem .p-menuitem-content .p-menuitem-link .p-submenu-icon {
|
|
margin-left: auto;
|
|
}
|
|
|
|
.p-menubar .p-menubar-end {
|
|
margin-left: auto;
|
|
align-self: center;
|
|
}
|
|
|
|
.p-menubar-button {
|
|
display: none;
|
|
cursor: pointer;
|
|
align-items: center;
|
|
justify-content: center;
|
|
text-decoration: none;
|
|
}
|
|
`;
|
|
|
|
const inlineStyles = {
|
|
submenu: ({ context, processedItem }) => ({ display: context.isItemActive(processedItem) ? 'block' : 'none' })
|
|
};
|
|
|
|
const classes = {
|
|
root: ({ instance }) => [
|
|
'p-menubar p-component',
|
|
{
|
|
'p-menubar-mobile-active': instance.mobileActive
|
|
}
|
|
],
|
|
start: 'p-menubar-start',
|
|
button: 'p-menubar-button',
|
|
menu: 'p-menubar-root-list',
|
|
menuitem: ({ context, processedItem }) => [
|
|
'p-menuitem',
|
|
context.getItemProp(processedItem, 'class'),
|
|
{
|
|
'p-menuitem-active p-highlight': context.isItemActive(processedItem),
|
|
'p-focus': context.isItemFocused(processedItem),
|
|
'p-disabled': context.isItemDisabled(processedItem)
|
|
}
|
|
],
|
|
content: 'p-menuitem-content',
|
|
action: ({ context, isActive, isExactActive }) => [
|
|
'p-menuitem-link',
|
|
{
|
|
'router-link-active': isActive,
|
|
'router-link-active-exact': context.exact && isExactActive
|
|
}
|
|
],
|
|
icon: ({ context, processedItem }) => ['p-menuitem-icon', context.getItemProp(processedItem, 'icon')],
|
|
label: 'p-menuitem-text',
|
|
submenuIcon: 'p-submenu-icon',
|
|
submenu: 'p-submenu-list',
|
|
separator: ({ context, processedItem }) => ['p-menuitem-separator', context.getItemProp(processedItem, 'class')],
|
|
end: 'p-menubar-end'
|
|
};
|
|
|
|
const { load: loadStyle, unload: unloadStyle } = useStyle(styles, { id: 'primevue_menubar_style', manual: true });
|
|
|
|
export default {
|
|
name: 'BaseMenubar',
|
|
extends: BaseComponent,
|
|
props: {
|
|
model: {
|
|
type: Array,
|
|
default: null
|
|
},
|
|
exact: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
buttonProps: {
|
|
type: null,
|
|
default: null
|
|
},
|
|
'aria-labelledby': {
|
|
type: String,
|
|
default: null
|
|
},
|
|
'aria-label': {
|
|
type: String,
|
|
default: null
|
|
}
|
|
},
|
|
css: {
|
|
classes,
|
|
inlineStyles
|
|
},
|
|
watch: {
|
|
isUnstyled: {
|
|
immediate: true,
|
|
handler(newValue) {
|
|
!newValue && loadStyle();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|