2019-02-13 14:03:45 +00:00
|
|
|
<template>
|
2020-09-21 12:47:24 +00:00
|
|
|
<div :class="containerClass" :style="style">
|
2020-11-25 08:34:02 +00:00
|
|
|
<PVSButton type="button" class="p-splitbutton-defaultbutton" v-bind="$attrs" :icon="icon" :label="label" @click="onDefaultButtonClick" />
|
2020-09-21 12:47:24 +00:00
|
|
|
<PVSButton type="button" class="p-splitbutton-menubutton" icon="pi pi-chevron-down" @click="onDropdownButtonClick" :disabled="$attrs.disabled"
|
2020-01-30 09:10:38 +00:00
|
|
|
aria-haspopup="true" :aria-controls="ariaId + '_overlay'"/>
|
2020-03-04 11:58:01 +00:00
|
|
|
<PVSMenu :id="ariaId + '_overlay'" ref="menu" :model="model" :popup="true" :autoZIndex="autoZIndex"
|
2020-04-23 06:28:51 +00:00
|
|
|
:baseZIndex="baseZIndex" :appendTo="appendTo" />
|
2019-02-13 14:03:45 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Button from '../button/Button';
|
2020-01-30 09:10:38 +00:00
|
|
|
import Menu from '../menu/Menu';
|
2019-12-26 11:24:53 +00:00
|
|
|
import UniqueComponentId from '../utils/UniqueComponentId';
|
2019-02-13 14:03:45 +00:00
|
|
|
|
|
|
|
export default {
|
2020-09-21 12:47:24 +00:00
|
|
|
inheritAttrs: false,
|
2019-02-13 14:03:45 +00:00
|
|
|
props: {
|
2019-05-21 11:51:08 +00:00
|
|
|
label: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
model: {
|
|
|
|
type: Array,
|
|
|
|
default: null
|
|
|
|
},
|
|
|
|
autoZIndex: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
|
|
|
},
|
|
|
|
baseZIndex: {
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
2020-03-04 11:47:12 +00:00
|
|
|
},
|
|
|
|
appendTo: {
|
|
|
|
type: String,
|
|
|
|
default: null
|
2020-09-21 12:47:24 +00:00
|
|
|
},
|
|
|
|
class: null,
|
|
|
|
style: null
|
2019-02-13 14:03:45 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
onDropdownButtonClick() {
|
2020-04-23 06:28:51 +00:00
|
|
|
this.$refs.menu.toggle({currentTarget: this.$el, relativeAlign: this.appendTo == null});
|
2020-11-25 08:34:02 +00:00
|
|
|
},
|
|
|
|
onDefaultButtonClick() {
|
|
|
|
this.$refs.menu.hide();
|
2020-01-30 09:10:38 +00:00
|
|
|
}
|
2019-12-26 11:24:53 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
ariaId() {
|
|
|
|
return UniqueComponentId();
|
2020-09-21 12:47:24 +00:00
|
|
|
},
|
|
|
|
containerClass() {
|
|
|
|
return ['p-splitbutton p-component', this.class];
|
2019-02-13 14:03:45 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2020-01-30 09:10:38 +00:00
|
|
|
'PVSButton': Button,
|
|
|
|
'PVSMenu': Menu
|
2019-02-13 14:03:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2020-01-30 10:16:39 +00:00
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.p-splitbutton {
|
2020-04-24 10:43:27 +00:00
|
|
|
display: inline-flex;
|
2020-01-30 10:16:39 +00:00
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
2020-05-13 13:30:02 +00:00
|
|
|
.p-splitbutton .p-splitbutton-defaultbutton {
|
2020-04-24 10:43:27 +00:00
|
|
|
flex: 1 1 auto;
|
2020-05-13 13:30:02 +00:00
|
|
|
border-top-right-radius: 0;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-right: 0 none;
|
2020-01-30 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 10:43:27 +00:00
|
|
|
.p-splitbutton-menubutton {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2020-05-13 13:30:02 +00:00
|
|
|
border-top-left-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
2020-04-28 09:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
.p-splitbutton .p-menu {
|
|
|
|
min-width: 100%;
|
2020-01-30 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 10:43:27 +00:00
|
|
|
.p-fluid .p-splitbutton {
|
|
|
|
display: flex;
|
2020-01-30 10:16:39 +00:00
|
|
|
}
|
|
|
|
</style>
|