UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 2.97 kB
import i from"primevue/confirmationeventbus";import o from"primevue/dialog";import t from"primevue/button";import{resolveComponent as e,openBlock as n,createBlock as c,withCtx as r,createVNode as s,normalizeClass as a,createElementVNode as l,toDisplayString as u}from"vue";var m={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]},autoFocusAccept(){return void 0===this.confirmation.defaultFocus||"accept"===this.confirmation.defaultFocus},autoFocusReject(){return"reject"===this.confirmation.defaultFocus}},components:{CDialog:o,CDButton:t}};const f={class:"p-confirm-dialog-message"};m.render=function(i,o,t,m,p,h){const b=e("CDButton"),d=e("CDialog");return n(),c(d,{visible:p.visible,"onUpdate:visible":o[2]||(o[2]=i=>p.visible=i),modal:!0,header:h.header,blockScroll:h.blockScroll,position:h.position,class:"p-confirm-dialog",breakpoints:t.breakpoints},{footer:r((()=>[s(b,{label:h.rejectLabel,icon:h.rejectIcon,class:a(h.rejectClass),onClick:o[0]||(o[0]=i=>h.reject()),autofocus:h.autoFocusReject},null,8,["label","icon","class","autofocus"]),s(b,{label:h.acceptLabel,icon:h.acceptIcon,class:a(h.acceptClass),onClick:o[1]||(o[1]=i=>h.accept()),autofocus:h.autoFocusAccept},null,8,["label","icon","class","autofocus"])])),default:r((()=>[l("i",{class:a(h.iconClass)},null,2),l("span",f,u(h.message),1)])),_:1},8,["visible","header","blockScroll","position","breakpoints"])};export{m as default};