UNPKG

primevue

Version:

PrimeVue is an open source UI library for Vue featuring a rich set of 80+ components, a theme designer, various theme alternatives such as Material, Bootstrap, Tailwind, premium templates and professional support. In addition, it integrates with PrimeBloc

2 lines (1 loc) 10 kB
this.primevue=this.primevue||{},this.primevue.confirmpopup=function(e,t,n,o,i,r,c,s,l){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=a(e),f=a(t),p=a(n),m=a(o),d=a(i),h={name:"ConfirmPopup",extends:{name:"BaseConfirmPopup",extends:a(c).default,props:{group:String},style:a(s).default,provide:function(){return{$parentInstance:this}}},inheritAttrs:!1,data:function(){return{visible:!1,confirmation:null,autoFocusAccept:null,autoFocusReject:null}},target:null,outsideClickListener:null,scrollHandler:null,resizeListener:null,container:null,confirmListener:null,closeListener:null,mounted:function(){var e=this;this.confirmListener=function(t){t&&t.group===e.group&&(e.confirmation=t,e.target=t.target,e.confirmation.onShow&&e.confirmation.onShow(),e.visible=!0)},this.closeListener=function(){e.visible=!1,e.confirmation=null},f.default.on("confirm",this.confirmListener),f.default.on("close",this.closeListener)},beforeUnmount:function(){f.default.off("confirm",this.confirmListener),f.default.off("close",this.closeListener),this.unbindOutsideClickListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.unbindResizeListener(),this.container&&(r.ZIndexUtils.clear(this.container),this.container=null),this.target=null,this.confirmation=null},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},onAcceptKeydown:function(e){"Space"!==e.code&&"Enter"!==e.code&&"NumpadEnter"!==e.code||(this.accept(),r.DomHandler.focus(this.target),e.preventDefault())},onRejectKeydown:function(e){"Space"!==e.code&&"Enter"!==e.code&&"NumpadEnter"!==e.code||(this.reject(),r.DomHandler.focus(this.target),e.preventDefault())},onEnter:function(e){this.autoFocusAccept=void 0===this.confirmation.defaultFocus||"accept"===this.confirmation.defaultFocus,this.autoFocusReject="reject"===this.confirmation.defaultFocus,this.bindOutsideClickListener(),this.bindScrollListener(),this.bindResizeListener(),r.ZIndexUtils.set("overlay",e,this.$primevue.config.zIndex.overlay)},onAfterEnter:function(){this.focus()},onLeave:function(){this.autoFocusAccept=null,this.autoFocusReject=null,this.unbindOutsideClickListener(),this.unbindScrollListener(),this.unbindResizeListener()},onAfterLeave:function(e){r.ZIndexUtils.clear(e)},alignOverlay:function(){r.DomHandler.absolutePosition(this.container,this.target);var e=r.DomHandler.getOffset(this.container),t=r.DomHandler.getOffset(this.target),n=0;e.left<t.left&&(n=t.left-e.left),this.container.style.setProperty("--overlayArrowLeft","".concat(n,"px")),e.top<t.top&&(this.container.setAttribute("data-p-confirm-popup-flipped","true"),!this.isUnstyled&&r.DomHandler.addClass(this.container,"p-confirm-popup-flipped"))},bindOutsideClickListener:function(){var e=this;this.outsideClickListener||(this.outsideClickListener=function(t){e.visible&&e.container&&!e.container.contains(t.target)&&!e.isTargetClicked(t)?(e.confirmation.onHide&&e.confirmation.onHide(),e.visible=!1):e.alignOverlay()},document.addEventListener("click",this.outsideClickListener))},unbindOutsideClickListener:function(){this.outsideClickListener&&(document.removeEventListener("click",this.outsideClickListener),this.outsideClickListener=null)},bindScrollListener:function(){var e=this;this.scrollHandler||(this.scrollHandler=new r.ConnectedOverlayScrollHandler(this.target,(function(){e.visible&&(e.visible=!1)}))),this.scrollHandler.bindScrollListener()},unbindScrollListener:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()},bindResizeListener:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.visible&&!r.DomHandler.isTouchDevice()&&(e.visible=!1)},window.addEventListener("resize",this.resizeListener))},unbindResizeListener:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)},focus:function(){var e=this.container.querySelector("[autofocus]");e&&e.focus({preventScroll:!0})},isTargetClicked:function(e){return this.target&&(this.target===e.target||this.target.contains(e.target))},containerRef:function(e){this.container=e},onOverlayClick:function(e){m.default.emit("overlay-click",{originalEvent:e,target:this.target})},onOverlayKeydown:function(e){"Escape"===e.code&&(f.default.emit("close",this.closeListener),r.DomHandler.focus(this.target))},getCXOptions:function(e,t){return{contenxt:{icon:e,iconClass:t.class}}}},computed:{message:function(){return this.confirmation?this.confirmation.message: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}},components:{CPButton:u.default,Portal:d.default},directives:{focustrap:p.default}};function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function b(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function y(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?b(Object(n),!0).forEach((function(t){g(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):b(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function g(e,t,n){var o;return(t="symbol"==v(o=L(t,"string"))?o:String(o))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function L(e,t){if("object"!=v(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=v(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var k=["aria-modal"];return h.render=function(e,t,n,o,i,r){var c=l.resolveComponent("CPButton"),s=l.resolveComponent("Portal"),a=l.resolveDirective("focustrap");return l.openBlock(),l.createBlock(s,null,{default:l.withCtx((function(){return[l.createVNode(l.Transition,l.mergeProps({name:"p-confirm-popup",onEnter:r.onEnter,onAfterEnter:r.onAfterEnter,onLeave:r.onLeave,onAfterLeave:r.onAfterLeave},e.ptm("transition")),{default:l.withCtx((function(){return[i.visible?l.withDirectives((l.openBlock(),l.createElementBlock("div",l.mergeProps({key:0,ref:r.containerRef,role:"alertdialog",class:e.cx("root"),"aria-modal":i.visible,onClick:t[2]||(t[2]=function(){return r.onOverlayClick&&r.onOverlayClick.apply(r,arguments)}),onKeydown:t[3]||(t[3]=function(){return r.onOverlayKeydown&&r.onOverlayKeydown.apply(r,arguments)})},y(y({},e.$attrs),e.ptm("root"))),[e.$slots.container?l.renderSlot(e.$slots,"container",{key:0,message:i.confirmation,onAccept:r.accept,onReject:r.reject,acceptCallback:r.accept,rejectCallback:r.reject}):(l.openBlock(),l.createElementBlock(l.Fragment,{key:1},[e.$slots.message?(l.openBlock(),l.createBlock(l.resolveDynamicComponent(e.$slots.message),{key:1,message:i.confirmation},null,8,["message"])):(l.openBlock(),l.createElementBlock("div",l.mergeProps({key:0,class:e.cx("content")},e.ptm("content")),[l.renderSlot(e.$slots,"icon",{},(function(){return[e.$slots.icon?(l.openBlock(),l.createBlock(l.resolveDynamicComponent(e.$slots.icon),{key:0,class:l.normalizeClass(e.cx("icon"))},null,8,["class"])):i.confirmation.icon?(l.openBlock(),l.createElementBlock("span",l.mergeProps({key:1,class:e.cx("icon")},e.ptm("icon")),null,16)):l.createCommentVNode("",!0)]})),l.createElementVNode("span",l.mergeProps({class:e.cx("message")},e.ptm("message")),l.toDisplayString(i.confirmation.message),17)],16)),l.createElementVNode("div",l.mergeProps({class:e.cx("footer")},e.ptm("footer")),[l.createVNode(c,{label:r.rejectLabel,onClick:t[0]||(t[0]=function(e){return r.reject()}),onKeydown:r.onRejectKeydown,autofocus:i.autoFocusReject,class:l.normalizeClass([e.cx("rejectButton"),i.confirmation.rejectClass]),unstyled:e.unstyled,pt:e.ptm("rejectButton"),"data-pc-name":"rejectbutton"},l.createSlots({_:2},[r.rejectIcon||e.$slots.rejecticon?{name:"icon",fn:l.withCtx((function(t){return[l.renderSlot(e.$slots,"rejecticon",{},(function(){return[l.createElementVNode("span",l.mergeProps({class:[r.rejectIcon,t.class]},e.ptm("rejectButton").icon,{"data-pc-name":"rejectbuttonicon"}),null,16)]}))]})),key:"0"}:void 0]),1032,["label","onKeydown","autofocus","class","unstyled","pt"]),l.createVNode(c,{label:r.acceptLabel,onClick:t[1]||(t[1]=function(e){return r.accept()}),onKeydown:r.onAcceptKeydown,autofocus:i.autoFocusAccept,class:l.normalizeClass([e.cx("acceptButton"),i.confirmation.acceptClass]),unstyled:e.unstyled,pt:e.ptm("acceptButton"),"data-pc-name":"acceptbutton"},l.createSlots({_:2},[r.acceptIcon||e.$slots.accepticon?{name:"icon",fn:l.withCtx((function(t){return[l.renderSlot(e.$slots,"accepticon",{},(function(){return[l.createElementVNode("span",l.mergeProps({class:[r.acceptIcon,t.class]},e.ptm("acceptButton").icon,{"data-pc-name":"acceptbuttonicon"}),null,16)]}))]})),key:"0"}:void 0]),1032,["label","onKeydown","autofocus","class","unstyled","pt"])],16)],64))],16,k)),[[a]]):l.createCommentVNode("",!0)]})),_:3},16,["onEnter","onAfterEnter","onLeave","onAfterLeave"])]})),_:3})},h}(primevue.button,primevue.confirmationeventbus,primevue.focustrap,primevue.overlayeventbus,primevue.portal,primevue.utils,primevue.basecomponent,primevue.confirmpopup.style,Vue);