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