primevue-mirror/src/components/splitbutton/SplitButton.vue

114 lines
2.6 KiB
Vue
Raw Normal View History

2019-02-13 14:03:45 +00:00
<template>
2020-01-30 10:16:39 +00:00
<div class="p-splitbutton p-buttonset p-component">
2019-02-13 14:03:45 +00:00
<PVSButton type="button" :icon="icon" :label="label" @click="onClick" :disabled="disabled" :tabindex="tabindex" />
2019-12-26 11:28:53 +00:00
<PVSButton type="button" class="p-splitbutton-menubutton" icon="pi pi-caret-down" @click="onDropdownButtonClick" :disabled="disabled"
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';
import Menu from '../menu/Menu';
import UniqueComponentId from '../utils/UniqueComponentId';
2019-02-13 14:03:45 +00:00
export default {
props: {
2019-05-21 11:51:08 +00:00
label: {
type: String,
default: null
},
icon: {
type: String,
default: null
},
model: {
type: Array,
default: null
},
disabled: {
type: Boolean,
default: false
},
tabindex: {
type: String,
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
}
2019-02-13 14:03:45 +00:00
},
methods: {
onClick(event) {
this.$emit('click', event);
},
onDropdownButtonClick() {
2020-04-23 06:28:51 +00:00
this.$refs.menu.toggle({currentTarget: this.$el, relativeAlign: this.appendTo == null});
}
},
computed: {
ariaId() {
return UniqueComponentId();
2019-02-13 14:03:45 +00:00
}
},
components: {
'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 {
position: relative;
display: inline-block;
zoom: 1;
}
.p-splitbutton .p-button.p-splitbutton-menubutton {
width: 2em;
vertical-align: top;
}
.p-splitbutton .p-menu {
left: auto;
top: auto;
}
.p-splitbutton.p-disabled button {
cursor: default;
}
.p-fluid .p-splitbutton {
width: 100%;
box-sizing: border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing: border-box;
}
.p-fluid .p-splitbutton .p-button:first-child {
width: calc(100% - 2em);
}
.p-fluid .p-splitbutton .p-button.p-splitbutton-menubutton {
width: 2em;
box-sizing: border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing: border-box;
}
.p-splitbutton.p-button-secondary .p-button:first-child {
border-right: 0 none;
}
</style>