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) [![Actions CI](https://github.com/primefaces/primevue/wo

2 lines (1 loc) 3.59 kB
"use strict";var e=require("primevue/button"),o=require("primevue/confirmationeventbus"),i=require("primevue/dialog"),t=require("vue");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=n(e),s=n(o),r={name:"ConfirmDialog",props:{group:String,breakpoints:{type:Object,default:null}},confirmListener:null,closeListener:null,data:()=>({visible:!1,confirmation:null}),mounted(){this.confirmListener=e=>{e&&e.group===this.group&&(this.confirmation=e,this.visible=!0)},this.closeListener=()=>{this.visible=!1,this.confirmation=null},s.default.on("confirm",this.confirmListener),s.default.on("close",this.closeListener)},beforeUnmount(){s.default.off("confirm",this.confirmListener),s.default.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:n(i).default,CDButton:c.default}};const a={class:"p-confirm-dialog-message"};r.render=function(e,o,i,n,c,s){const r=t.resolveComponent("CDButton"),l=t.resolveComponent("CDialog");return t.openBlock(),t.createBlock(l,{visible:c.visible,"onUpdate:visible":[o[2]||(o[2]=e=>c.visible=e),s.onHide],modal:!0,header:s.header,blockScroll:s.blockScroll,position:s.position,class:"p-confirm-dialog",breakpoints:i.breakpoints,closeOnEscape:s.closeOnEscape},{footer:t.withCtx((()=>[t.createVNode(r,{label:s.rejectLabel,icon:s.rejectIcon,class:t.normalizeClass(s.rejectClass),onClick:o[0]||(o[0]=e=>s.reject()),autofocus:s.autoFocusReject},null,8,["label","icon","class","autofocus"]),t.createVNode(r,{label:s.acceptLabel,icon:s.acceptIcon,class:t.normalizeClass(s.acceptClass),onClick:o[1]||(o[1]=e=>s.accept()),autofocus:s.autoFocusAccept},null,8,["label","icon","class","autofocus"])])),default:t.withCtx((()=>[e.$slots.message?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.$slots.message),{key:1,message:c.confirmation},null,8,["message"])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("i",{class:t.normalizeClass(s.iconClass)},null,2),t.createElementVNode("span",a,t.toDisplayString(s.message),1)],64))])),_:1},8,["visible","header","blockScroll","position","breakpoints","closeOnEscape","onUpdate:visible"])},module.exports=r;