primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 2.67 kB
JavaScript
import i from"primevue/confirmationeventbus";import o from"primevue/dialog";import t from"primevue/button";import{resolveComponent as n,openBlock as e,createBlock as c,withCtx as r,createVNode as s,toDisplayString as l}from"vue";var a={name:"ConfirmDialog",props:{group:String,breakpoints:{type:Object,default:null}},confirmListener:null,closeListener:null,data:()=>({visible:!1,confirmation:null}),mounted(){this.confirmListener=i=>{i&&i.group===this.group&&(this.confirmation=i,this.visible=!0)},this.closeListener=()=>{this.visible=!1,this.confirmation=null},i.on("confirm",this.confirmListener),i.on("close",this.closeListener)},beforeUnmount(){i.off("confirm",this.confirmListener),i.off("close",this.closeListener)},methods:{accept(){this.confirmation.accept&&this.confirmation.accept(),this.visible=!1},reject(){this.confirmation.reject&&this.confirmation.reject(),this.visible=!1}},computed:{header(){return this.confirmation?this.confirmation.header:null},message(){return this.confirmation?this.confirmation.message:null},blockScroll(){return!this.confirmation||this.confirmation.blockScroll},position(){return this.confirmation?this.confirmation.position:null},iconClass(){return["p-confirm-dialog-icon",this.confirmation?this.confirmation.icon:null]},acceptLabel(){return this.confirmation?this.confirmation.acceptLabel||this.$primevue.config.locale.accept:null},rejectLabel(){return this.confirmation?this.confirmation.rejectLabel||this.$primevue.config.locale.reject:null},acceptIcon(){return this.confirmation?this.confirmation.acceptIcon:null},rejectIcon(){return this.confirmation?this.confirmation.rejectIcon:null},acceptClass(){return["p-confirm-dialog-accept",this.confirmation?this.confirmation.acceptClass:null]},rejectClass(){return["p-confirm-dialog-reject",this.confirmation?this.confirmation.rejectClass||"p-button-text":null]}},components:{CDialog:o,CDButton:t}};const m={class:"p-confirm-dialog-message"};a.render=function(i,o,t,a,f,u){const p=n("CDButton"),h=n("CDialog");return e(),c(h,{visible:f.visible,"onUpdate:visible":o[3]||(o[3]=i=>f.visible=i),modal:!0,header:u.header,blockScroll:u.blockScroll,position:u.position,class:"p-confirm-dialog",breakpoints:t.breakpoints},{footer:r((()=>[s(p,{label:u.rejectLabel,icon:u.rejectIcon,class:u.rejectClass,onClick:o[1]||(o[1]=i=>u.reject())},null,8,["label","icon","class"]),s(p,{label:u.acceptLabel,icon:u.acceptIcon,class:u.acceptClass,onClick:o[2]||(o[2]=i=>u.accept()),autofocus:""},null,8,["label","icon","class"])])),default:r((()=>[s("i",{class:u.iconClass},null,2),s("span",m,l(u.message),1)])),_:1},8,["visible","header","blockScroll","position","breakpoints"])};export default a;