primevue
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primevue) [ • 5.49 kB
JavaScript
"use strict";var e=require("primevue/button"),t=require("primevue/confirmationeventbus"),n=require("primevue/dialog"),o=require("primevue/basecomponent"),c=require("vue");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=i(e),a=i(t),s=i(n),l={name:"ConfirmDialog",extends:{name:"BaseConfirmDialog",extends:i(o).default,props:{group:String,breakpoints:{type:Object,default:null},draggable:{type:Boolean,default:!0}},css:{classes:{root:"p-confirm-dialog",icon:function(e){var t=e.instance;return["p-confirm-dialog-icon",t.confirmation?t.confirmation.icon:null]},message:"p-confirm-dialog-message",rejectButton:function(e){var t=e.instance;return["p-confirm-dialog-reject",t.confirmation?t.confirmation.rejectClass||"p-button-text":null]},acceptButton:function(e){var t=e.instance;return["p-confirm-dialog-accept",t.confirmation?t.confirmation.acceptClass:null]}}},provide:function(){return{$parentInstance:this}}},confirmListener:null,closeListener:null,data:function(){return{visible:!1,confirmation:null}},mounted:function(){var e=this;this.confirmListener=function(t){t&&t.group===e.group&&(e.confirmation=t,e.confirmation.onShow&&e.confirmation.onShow(),e.visible=!0)},this.closeListener=function(){e.visible=!1,e.confirmation=null},a.default.on("confirm",this.confirmListener),a.default.on("close",this.closeListener)},beforeUnmount:function(){a.default.off("confirm",this.confirmListener),a.default.off("close",this.closeListener)},methods:{accept:function(){this.confirmation.accept&&this.confirmation.accept(),this.visible=!1},reject:function(){this.confirmation.reject&&this.confirmation.reject(),this.visible=!1},onHide:function(){this.confirmation.onHide&&this.confirmation.onHide(),this.visible=!1},getCXOptions:function(e,t){return{contenxt:{icon:e,iconClass:t.class}}}},computed:{header:function(){return this.confirmation?this.confirmation.header:null},message:function(){return this.confirmation?this.confirmation.message:null},blockScroll:function(){return!this.confirmation||this.confirmation.blockScroll},position:function(){return this.confirmation?this.confirmation.position:null},acceptLabel:function(){return this.confirmation?this.confirmation.acceptLabel||this.$primevue.config.locale.accept:null},rejectLabel:function(){return this.confirmation?this.confirmation.rejectLabel||this.$primevue.config.locale.reject:null},acceptIcon:function(){return this.confirmation?this.confirmation.acceptIcon:null},rejectIcon:function(){return this.confirmation?this.confirmation.rejectIcon:null},autoFocusAccept:function(){return void 0===this.confirmation.defaultFocus||"accept"===this.confirmation.defaultFocus},autoFocusReject:function(){return"reject"===this.confirmation.defaultFocus},closeOnEscape:function(){return!this.confirmation||this.confirmation.closeOnEscape}},components:{CDialog:s.default,CDButton:r.default}};l.render=function(e,t,n,o,i,r){var a=c.resolveComponent("CDButton"),s=c.resolveComponent("CDialog");return c.openBlock(),c.createBlock(s,{visible:i.visible,"onUpdate:visible":[t[2]||(t[2]=function(e){return i.visible=e}),r.onHide],role:"alertdialog",class:c.normalizeClass(e.cx("root")),modal:!0,header:r.header,blockScroll:r.blockScroll,position:r.position,breakpoints:e.breakpoints,closeOnEscape:r.closeOnEscape,draggable:e.draggable,pt:e.pt,unstyled:e.unstyled},{footer:c.withCtx((function(){return[c.createVNode(a,{label:r.rejectLabel,class:c.normalizeClass(e.cx("rejectButton")),onClick:t[0]||(t[0]=function(e){return r.reject()}),autofocus:r.autoFocusReject,unstyled:e.unstyled,pt:e.ptm("rejectButton"),"data-pc-name":"rejectbutton"},c.createSlots({_:2},[r.rejectIcon||e.$slots.rejecticon?{name:"icon",fn:c.withCtx((function(t){return[c.renderSlot(e.$slots,"rejecticon",{},(function(){return[c.createElementVNode("span",c.mergeProps({class:[r.rejectIcon,t.class]},e.ptm("rejectButton").icon,{"data-pc-name":"rejectbuttonicon"}),null,16)]}))]})),key:"0"}:void 0]),1032,["label","class","autofocus","unstyled","pt"]),c.createVNode(a,{label:r.acceptLabel,class:c.normalizeClass(e.cx("acceptButton")),onClick:t[1]||(t[1]=function(e){return r.accept()}),autofocus:r.autoFocusAccept,unstyled:e.unstyled,pt:e.ptm("acceptButton"),"data-pc-name":"acceptbutton"},c.createSlots({_:2},[r.acceptIcon||e.$slots.accepticon?{name:"icon",fn:c.withCtx((function(t){return[c.renderSlot(e.$slots,"accepticon",{},(function(){return[c.createElementVNode("span",c.mergeProps({class:[r.acceptIcon,t.class]},e.ptm("acceptButton").icon,{"data-pc-name":"acceptbuttonicon"}),null,16)]}))]})),key:"0"}:void 0]),1032,["label","class","autofocus","unstyled","pt"])]})),default:c.withCtx((function(){return[e.$slots.message?(c.openBlock(),c.createBlock(c.resolveDynamicComponent(e.$slots.message),{key:1,message:i.confirmation},null,8,["message"])):(c.openBlock(),c.createElementBlock(c.Fragment,{key:0},[c.renderSlot(e.$slots,"icon",{},(function(){return[e.$slots.icon?(c.openBlock(),c.createBlock(c.resolveDynamicComponent(e.$slots.icon),{key:0,class:c.normalizeClass(e.cx("icon"))},null,8,["class"])):i.confirmation.icon?(c.openBlock(),c.createElementBlock("span",c.mergeProps({key:1,class:e.cx("icon")},e.ptm("icon")),null,16)):c.createCommentVNode("",!0)]})),c.createElementVNode("span",c.mergeProps({class:e.cx("message")},e.ptm("message")),c.toDisplayString(r.message),17)],64))]})),_:3},8,["visible","class","header","blockScroll","position","breakpoints","closeOnEscape","draggable","onUpdate:visible","pt","unstyled"])},module.exports=l;