primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 3.93 kB
JavaScript
import o from"primevue/button";import i from"primevue/confirmationeventbus";import t from"primevue/dialog";import{resolveComponent as e,openBlock as n,createBlock as c,withCtx as s,createVNode as a,normalizeClass as r,renderSlot as l,createElementVNode as m,createElementBlock as f,Fragment as u,resolveDynamicComponent as p,createCommentVNode as h,toDisplayString as b}from"vue";var d={name:"ConfirmDialog",props:{group:String,breakpoints:{type:Object,default:null},draggable:{type:Boolean,default:!0}},confirmListener:null,closeListener:null,data:()=>({visible:!1,confirmation:null}),mounted(){this.confirmListener=o=>{o&&o.group===this.group&&(this.confirmation=o,this.confirmation.onShow&&this.confirmation.onShow(),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},onHide(){this.confirmation.onHide&&this.confirmation.onHide(),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]},autoFocusAccept(){return void 0===this.confirmation.defaultFocus||"accept"===this.confirmation.defaultFocus},autoFocusReject(){return"reject"===this.confirmation.defaultFocus},closeOnEscape(){return!this.confirmation||this.confirmation.closeOnEscape}},components:{CDialog:t,CDButton:o}};const g={class:"p-confirm-dialog-message"};d.render=function(o,i,t,d,v,j){const k=e("CDButton"),C=e("CDialog");return n(),c(C,{visible:v.visible,"onUpdate:visible":[i[2]||(i[2]=o=>v.visible=o),j.onHide],role:"alertdialog",class:"p-confirm-dialog",modal:!0,header:j.header,blockScroll:j.blockScroll,position:j.position,breakpoints:t.breakpoints,closeOnEscape:j.closeOnEscape,draggable:t.draggable},{footer:s((()=>[a(k,{label:j.rejectLabel,class:r(j.rejectClass),iconPos:"left",onClick:i[0]||(i[0]=o=>j.reject()),autofocus:j.autoFocusReject},{icon:s((i=>[l(o.$slots,"rejecticon",{},(()=>[m("span",{class:r([j.rejectIcon,i.class])},null,2)]))])),_:3},8,["label","class","autofocus"]),a(k,{label:j.acceptLabel,class:r(j.acceptClass),iconPos:"left",onClick:i[1]||(i[1]=o=>j.accept()),autofocus:j.autoFocusAccept},{icon:s((i=>[l(o.$slots,"accepticon",{},(()=>[m("span",{class:r([j.acceptIcon,i.class])},null,2)]))])),_:3},8,["label","class","autofocus"])])),default:s((()=>[o.$slots.message?(n(),c(p(o.$slots.message),{key:1,message:v.confirmation},null,8,["message"])):(n(),f(u,{key:0},[l(o.$slots,"icon",{class:"p-confirm-dialog-icon"},(()=>[o.$slots.icon?(n(),c(p(o.$slots.icon),{key:0,class:"p-confirm-dialog-icon"})):v.confirmation.icon?(n(),f("span",{key:1,class:r(j.iconClass)},null,2)):h("",!0)])),m("span",g,b(j.message),1)],64))])),_:3},8,["visible","header","blockScroll","position","breakpoints","closeOnEscape","draggable","onUpdate:visible"])};export{d as default};