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) 4.51 kB
"use strict";var e=require("primevue/basecomponent"),o=require("primevue/button"),t=require("primevue/confirmationeventbus"),i=require("primevue/dialog"),n=require("vue");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=c(e),r=c(o),a=c(t),l=c(i),m={name:"ConfirmDialog",extends:s.default,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=e=>{e&&e.group===this.group&&(this.confirmation=e,this.confirmation.onShow&&this.confirmation.onShow(),this.visible=!0)},this.closeListener=()=>{this.visible=!1,this.confirmation=null},a.default.on("confirm",this.confirmListener),a.default.on("close",this.closeListener)},beforeUnmount(){a.default.off("confirm",this.confirmListener),a.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:l.default,CDButton:r.default}};m.render=function(e,o,t,i,c,s){const r=n.resolveComponent("CDButton"),a=n.resolveComponent("CDialog");return n.openBlock(),n.createBlock(a,{visible:c.visible,"onUpdate:visible":[o[2]||(o[2]=e=>c.visible=e),s.onHide],role:"alertdialog",class:"p-confirm-dialog",modal:!0,header:s.header,blockScroll:s.blockScroll,position:s.position,breakpoints:t.breakpoints,closeOnEscape:s.closeOnEscape,draggable:t.draggable,pt:e.pt},{footer:n.withCtx((()=>[n.createVNode(r,{label:s.rejectLabel,class:n.normalizeClass(s.rejectClass),iconPos:"left",onClick:o[0]||(o[0]=e=>s.reject()),autofocus:s.autoFocusReject,pt:e.ptm("rejectButton")},{icon:n.withCtx((o=>[n.renderSlot(e.$slots,"rejecticon",{},(()=>[n.createElementVNode("span",n.mergeProps({class:[s.rejectIcon,o.class]},e.ptm("rejectButton").icon),null,16)]))])),_:3},8,["label","class","autofocus","pt"]),n.createVNode(r,{label:s.acceptLabel,class:n.normalizeClass(s.acceptClass),iconPos:"left",onClick:o[1]||(o[1]=e=>s.accept()),autofocus:s.autoFocusAccept,pt:e.ptm("acceptButton")},{icon:n.withCtx((o=>[n.renderSlot(e.$slots,"accepticon",{},(()=>[n.createElementVNode("span",n.mergeProps({class:[s.acceptIcon,o.class]},e.ptm("acceptButton").icon),null,16)]))])),_:3},8,["label","class","autofocus","pt"])])),default:n.withCtx((()=>[e.$slots.message?(n.openBlock(),n.createBlock(n.resolveDynamicComponent(e.$slots.message),{key:1,message:c.confirmation},null,8,["message"])):(n.openBlock(),n.createElementBlock(n.Fragment,{key:0},[n.renderSlot(e.$slots,"icon",{class:"p-confirm-dialog-icon"},(()=>[e.$slots.icon?(n.openBlock(),n.createBlock(n.resolveDynamicComponent(e.$slots.icon),{key:0,class:"p-confirm-dialog-icon"})):c.confirmation.icon?(n.openBlock(),n.createElementBlock("span",n.mergeProps({key:1,class:s.iconClass},e.ptm("icon")),null,16)):n.createCommentVNode("",!0)])),n.createElementVNode("span",n.mergeProps({class:"p-confirm-dialog-message"},e.ptm("message")),n.toDisplayString(s.message),17)],64))])),_:3},8,["visible","header","blockScroll","position","breakpoints","closeOnEscape","draggable","onUpdate:visible","pt"])},module.exports=m;