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