katoikia-app/web-ui/web-react/node_modules/primereact/confirmpopup/confirmpopup.min.js

2 lines
10 KiB
JavaScript

this.primereact=this.primereact||{},this.primereact.confirmpopup=function(e,t,n,i,r,o,s,c,l){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=a(t),p=a(n),f=a(s);function d(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},y(e,t)}function b(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function m(e){return m="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},m(e)}function k(e,t){if(t&&("object"===m(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return v(e)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function L(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function O(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function C(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?O(Object(n),!0).forEach((function(t){L(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):O(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var R=function(e){b(L,e);var t,n,a,p,y,m=(t=L,n=j(),function(){var e,i=E(t);if(n){var r=E(this).constructor;e=Reflect.construct(i,arguments,r)}else e=i.apply(this,arguments);return k(this,e)});function L(e){var t;return d(this,L),(t=m.call(this,e)).state={visible:!1},t.reject=t.reject.bind(v(t)),t.accept=t.accept.bind(v(t)),t.hide=t.hide.bind(v(t)),t.onCloseClick=t.onCloseClick.bind(v(t)),t.onPanelClick=t.onPanelClick.bind(v(t)),t.onEnter=t.onEnter.bind(v(t)),t.onEntered=t.onEntered.bind(v(t)),t.onExit=t.onExit.bind(v(t)),t.onExited=t.onExited.bind(v(t)),t.overlayRef=u.default.createRef(),t.acceptBtnRef=u.default.createRef(),t}return a=L,(p=[{key:"acceptLabel",value:function(){return this.props.acceptLabel||s.localeOption("accept")}},{key:"rejectLabel",value:function(){return this.props.rejectLabel||s.localeOption("reject")}},{key:"bindDocumentClickListener",value:function(){var e=this;!this.documentClickListener&&this.props.dismissable&&(this.documentClickListener=function(t){!e.isPanelClicked&&e.isOutsideClicked(t.target)&&e.hide(),e.isPanelClicked=!1},document.addEventListener("click",this.documentClickListener))}},{key:"unbindDocumentClickListener",value:function(){this.documentClickListener&&(document.removeEventListener("click",this.documentClickListener),this.documentClickListener=null)}},{key:"bindScrollListener",value:function(){var e=this;this.scrollHandler||(this.scrollHandler=new i.ConnectedOverlayScrollHandler(this.props.target,(function(){e.state.visible&&e.hide()}))),this.scrollHandler.bindScrollListener()}},{key:"unbindScrollListener",value:function(){this.scrollHandler&&this.scrollHandler.unbindScrollListener()}},{key:"bindResizeListener",value:function(){var e=this;this.resizeListener||(this.resizeListener=function(){e.state.visible&&!i.DomHandler.isTouchDevice()&&e.hide()},window.addEventListener("resize",this.resizeListener))}},{key:"unbindResizeListener",value:function(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null)}},{key:"isOutsideClicked",value:function(e){return this.overlayRef&&this.overlayRef.current&&!(this.overlayRef.current.isSameNode(e)||this.overlayRef.current.contains(e))}},{key:"onCloseClick",value:function(e){this.hide(),e.preventDefault()}},{key:"onPanelClick",value:function(e){this.isPanelClicked=!0,c.OverlayService.emit("overlay-click",{originalEvent:e,target:this.props.target})}},{key:"accept",value:function(){this.props.accept&&this.props.accept(),this.hide("accept")}},{key:"reject",value:function(){this.props.reject&&this.props.reject(),this.hide("reject")}},{key:"show",value:function(){var e=this;this.setState({visible:!0},(function(){e.overlayEventListener=function(t){e.isOutsideClicked(t.target)||(e.isPanelClicked=!0)},c.OverlayService.on("overlay-click",e.overlayEventListener)}))}},{key:"hide",value:function(e){var t=this;this.setState({visible:!1},(function(){c.OverlayService.off("overlay-click",t.overlayEventListener),t.overlayEventListener=null,t.props.onHide&&t.props.onHide(e)}))}},{key:"onEnter",value:function(){i.ZIndexUtils.set("overlay",this.overlayRef.current,f.default.autoZIndex,f.default.zIndex.overlay),this.align()}},{key:"onEntered",value:function(){this.bindDocumentClickListener(),this.bindScrollListener(),this.bindResizeListener(),this.acceptBtnRef&&this.acceptBtnRef.current&&this.acceptBtnRef.current.focus(),this.props.onShow&&this.props.onShow()}},{key:"onExit",value:function(){this.unbindDocumentClickListener(),this.unbindScrollListener(),this.unbindResizeListener()}},{key:"onExited",value:function(){i.ZIndexUtils.clear(this.overlayRef.current)}},{key:"align",value:function(){if(this.props.target){i.DomHandler.absolutePosition(this.overlayRef.current,this.props.target);var e=i.DomHandler.getOffset(this.overlayRef.current),t=i.DomHandler.getOffset(this.props.target),n=0;e.left<t.left&&(n=t.left-e.left),this.overlayRef.current.style.setProperty("--overlayArrowLeft","".concat(n,"px")),e.top<t.top&&i.DomHandler.addClass(this.overlayRef.current,"p-confirm-popup-flipped")}}},{key:"componentDidMount",value:function(){this.props.visible&&this.setState({visible:!0})}},{key:"componentDidUpdate",value:function(e){e.visible!==this.props.visible&&this.setState({visible:this.props.visible})}},{key:"componentWillUnmount",value:function(){this.unbindDocumentClickListener(),this.unbindResizeListener(),this.scrollHandler&&(this.scrollHandler.destroy(),this.scrollHandler=null),this.overlayEventListener&&(c.OverlayService.off("overlay-click",this.overlayEventListener),this.overlayEventListener=null),i.ZIndexUtils.clear(this.overlayRef.current)}},{key:"renderContent",value:function(){var e=i.ObjectUtils.getJSXElement(this.props.message,this.props);return u.default.createElement("div",{className:"p-confirm-popup-content"},i.IconUtils.getJSXIcon(this.props.icon,{className:"p-confirm-popup-icon"},{props:this.props}),u.default.createElement("span",{className:"p-confirm-popup-message"},e))}},{key:"renderFooter",value:function(){var e=i.classNames("p-confirm-popup-accept p-button-sm",this.props.acceptClassName),t=i.classNames("p-confirm-popup-reject p-button-sm",{"p-button-text":!this.props.rejectClassName},this.props.rejectClassName),n=u.default.createElement("div",{className:"p-confirm-popup-footer"},u.default.createElement(r.Button,{label:this.rejectLabel(),icon:this.props.rejectIcon,className:t,onClick:this.reject}),u.default.createElement(r.Button,{ref:this.acceptBtnRef,label:this.acceptLabel(),icon:this.props.acceptIcon,className:e,onClick:this.accept}));if(this.props.footer){var o={accept:this.accept,reject:this.reject,className:"p-confirm-popup-footer",acceptClassName:e,rejectClassName:t,acceptLabel:this.acceptLabel(),rejectLabel:this.rejectLabel(),element:n,props:this.props};return i.ObjectUtils.getJSXElement(this.props.footer,o)}return n}},{key:"renderElement",value:function(){var e=i.classNames("p-confirm-popup p-component",this.props.className),t=this.renderContent(),n=this.renderFooter();return u.default.createElement(o.CSSTransition,{nodeRef:this.overlayRef,classNames:"p-connected-overlay",in:this.state.visible,timeout:{enter:120,exit:100},options:this.props.transitionOptions,unmountOnExit:!0,onEnter:this.onEnter,onEntered:this.onEntered,onExit:this.onExit,onExited:this.onExited},u.default.createElement("div",{ref:this.overlayRef,id:this.props.id,className:e,style:this.props.style,onClick:this.onPanelClick},t,n))}},{key:"render",value:function(){var e=this.renderElement();return u.default.createElement(l.Portal,{element:e,appendTo:this.props.appendTo,visible:this.props.visible})}}])&&h(a.prototype,p),y&&h(a,y),Object.defineProperty(a,"prototype",{writable:!1}),L}(t.Component);return L(R,"defaultProps",{target:null,visible:!1,message:null,rejectLabel:null,acceptLabel:null,icon:null,rejectIcon:null,acceptIcon:null,rejectClassName:null,acceptClassName:null,className:null,style:null,appendTo:null,dismissable:!0,footer:null,onShow:null,onHide:null,accept:null,reject:null,transitionOptions:null}),e.ConfirmPopup=R,e.confirmPopup=function(e){var t=e.appendTo||document.body,n=document.createDocumentFragment();i.DomHandler.appendChild(n,t),e=C(C({},e),{visible:void 0===e.visible||e.visible});var r=u.default.createElement(R,e);p.default.render(r,n);var o=function(t){e=C(C({},e),t),p.default.render(u.default.cloneElement(r,e),n)};return{_destroy:function(){p.default.unmountComponentAtNode(n)},show:function(){o({visible:!0,onHide:function(){o({visible:!1})}})},hide:function(){o({visible:!1})},update:function(e){o(e)}}},Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,ReactDOM,primereact.utils,primereact.button,primereact.csstransition,primereact.api,primereact.overlayservice,primereact.portal);