2 lines
4.4 KiB
JavaScript
2 lines
4.4 KiB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("primereact/utils"),n=require("primereact/portal"),o=require("primereact/api");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=r(e),i=r(o);function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function p(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&&a(e,t)}function f(e){return f="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},f(e)}function d(e,t){if(t&&("object"===f(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return s(e)}function b(e){return b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},b(e)}function y(){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}}var m,h,v,k=function(o){p(k,e.Component);var r,a,f,m,h,v=(r=k,a=y(),function(){var e,t=b(r);if(a){var n=b(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return d(this,e)});function k(e){var t;return u(this,k),(t=v.call(this,e)).state={visible:e.blocked},t.block=t.block.bind(s(t)),t.unblock=t.unblock.bind(s(t)),t.onPortalMounted=t.onPortalMounted.bind(s(t)),t}return f=k,(m=[{key:"block",value:function(){this.setState({visible:!0})}},{key:"unblock",value:function(){var e=this,n=function(){e.setState({visible:!1},(function(){e.props.fullScreen&&t.DomHandler.removeClass(document.body,"p-overflow-hidden"),e.props.onUnblocked&&e.props.onUnblocked()}))};this.mask?(t.DomHandler.addClass(this.mask,"p-component-overlay-leave"),this.mask.addEventListener("animationend",(function(){t.ZIndexUtils.clear(e.mask),n()}))):n()}},{key:"onPortalMounted",value:function(){if(this.props.fullScreen&&(t.DomHandler.addClass(document.body,"p-overflow-hidden"),document.activeElement.blur()),this.props.autoZIndex){var e=this.props.fullScreen?"modal":"overlay";t.ZIndexUtils.set(e,this.mask,i.default.autoZIndex,this.props.baseZIndex||i.default.zIndex[e])}this.props.onBlocked&&this.props.onBlocked()}},{key:"renderMask",value:function(){var e=this;if(this.state.visible){var o=t.classNames("p-blockui p-component-overlay p-component-overlay-enter",{"p-blockui-document":this.props.fullScreen},this.props.className),r=this.props.template?t.ObjectUtils.getJSXElement(this.props.template,this.props):null;return l.default.createElement(n.Portal,{element:l.default.createElement("div",{ref:function(t){return e.mask=t},className:o,style:this.props.style},r),appendTo:this.props.fullScreen?document.body:"self",onMounted:this.onPortalMounted})}return null}},{key:"componentDidMount",value:function(){this.state.visible&&this.block()}},{key:"componentDidUpdate",value:function(e,t){e.blocked!==this.props.blocked&&(this.props.blocked?this.block():this.unblock())}},{key:"componentWillUnmount",value:function(){this.props.fullScreen&&t.DomHandler.removeClass(document.body,"p-overflow-hidden"),t.ZIndexUtils.clear(this.mask)}},{key:"render",value:function(){var e=this,t=this.renderMask();return l.default.createElement("div",{ref:function(t){return e.container=t},id:this.props.id,className:"p-blockui-container"},this.props.children,t)}}])&&c(f.prototype,m),h&&c(f,h),Object.defineProperty(f,"prototype",{writable:!1}),k}();v={id:null,blocked:!1,fullScreen:!1,baseZIndex:0,autoZIndex:!0,style:null,className:null,template:null,onBlocked:null,onUnblocked:null},(h="defaultProps")in(m=k)?Object.defineProperty(m,h,{value:v,enumerable:!0,configurable:!0,writable:!0}):m[h]=v,exports.BlockUI=k;
|