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