primevue-mirror/components/lib/menu/BaseMenu.vue

115 lines
2.5 KiB
Vue
Raw Normal View History

2023-05-29 09:09:48 +00:00
<script>
import BaseComponent from 'primevue/basecomponent';
import { useStyle } from 'primevue/usestyle';
const styles = `
2023-09-25 19:11:55 +00:00
@layer primevue {
.p-menu ul {
margin: 0;
padding: 0;
list-style: none;
}
.p-menu .p-menuitem-link {
cursor: pointer;
display: flex;
align-items: center;
text-decoration: none;
overflow: hidden;
position: relative;
}
.p-menu .p-menuitem-text {
line-height: 1;
}
2023-05-29 09:09:48 +00:00
}
`;
const classes = {
root: ({ instance, props }) => [
'p-menu p-component',
{
'p-menu-overlay': props.popup,
'p-input-filled': instance.$primevue.config.inputStyle === 'filled',
'p-ripple-disabled': instance.$primevue.config.ripple === false
}
],
start: 'p-menu-start',
menu: 'p-menu-list p-reset',
submenuHeader: 'p-submenu-header',
separator: 'p-menuitem-separator',
2023-05-29 09:09:48 +00:00
end: 'p-menu-end',
menuitem: ({ instance }) => [
2023-05-29 09:09:48 +00:00
'p-menuitem',
{
'p-focus': instance.id === instance.focusedOptionId,
'p-disabled': instance.disabled()
2023-05-29 09:09:48 +00:00
}
],
content: 'p-menuitem-content',
2023-05-30 12:02:59 +00:00
action: ({ props, isActive, isExactActive }) => [
2023-05-29 09:09:48 +00:00
'p-menuitem-link',
{
2023-05-29 11:13:36 +00:00
'router-link-active': isActive,
2023-05-30 12:02:59 +00:00
'router-link-active-exact': props.exact && isExactActive
2023-05-29 09:09:48 +00:00
}
],
icon: 'p-menuitem-icon',
2023-05-29 09:09:48 +00:00
label: 'p-menuitem-text'
};
const { load: loadStyle } = useStyle(styles, { name: 'menu', manual: true });
2023-05-29 09:09:48 +00:00
export default {
name: 'BaseMenu',
extends: BaseComponent,
props: {
popup: {
type: Boolean,
default: false
},
model: {
type: Array,
default: null
},
appendTo: {
type: String,
default: 'body'
},
autoZIndex: {
type: Boolean,
default: true
},
baseZIndex: {
type: Number,
default: 0
},
exact: {
type: Boolean,
default: true
},
tabindex: {
type: Number,
default: 0
},
'aria-label': {
type: String,
default: null
},
'aria-labelledby': {
type: String,
default: null
}
},
css: {
classes,
loadStyle
2023-05-29 09:09:48 +00:00
},
provide() {
return {
$parentInstance: this
};
2023-05-29 09:09:48 +00:00
}
};
</script>