UNPKG

primereact

Version:

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

2 lines (1 loc) 3.44 kB
import*as e from"react";import n from"primereact/api";import{useMountEffect as r,useUpdateEffect as t,useUnmountEffect as o}from"primereact/hooks";import{Portal as l}from"primereact/portal";import{ObjectUtils as a,DomHandler as c,ZIndexUtils as u,classNames as i}from"primereact/utils";function f(){return f=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},f.apply(this,arguments)}function d(e){if(Array.isArray(e))return e}function s(e,n){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var t,o,l,a,c=[],u=!0,i=!1;try{if(l=(r=r.call(e)).next,0===n){if(Object(r)!==r)return;u=!1}else for(;!(u=(t=l.call(r)).done)&&(c.push(t.value),c.length!==n);u=!0);}catch(e){i=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(i)throw o}}return c}}function p(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function m(e,n){if(e){if("string"==typeof e)return p(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(e,n):void 0}}function y(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var b={defaultProps:{__TYPE:"BlockUI",autoZIndex:!0,baseZIndex:0,blocked:!1,className:null,containerClassName:null,containerStyle:null,fullScreen:!1,id:null,onBlocked:null,onUnblocked:null,style:null,template:null,children:void 0},getProps:function(e){return a.getMergedProps(e,b.defaultProps)},getOtherProps:function(e){return a.getDiffProps(e,b.defaultProps)}},v=e.forwardRef((function(p,v){var h,g,k=b.getProps(p),S=e.useState(k.blocked),I=(g=2,d(h=S)||s(h,g)||m(h,g)||y()),P=I[0],O=I[1],w=e.useRef(null),E=e.useRef(null),j=function(){O(!0)},x=function(){var e=function(){O(!1),k.fullScreen&&c.removeClass(document.body,"p-overflow-hidden"),k.onUnblocked&&k.onUnblocked()};E.current?(c.addClass(E.current,"p-component-overlay-leave"),E.current.addEventListener("animationend",(function(){u.clear(E.current),e()}))):e()},C=function(){if(k.fullScreen&&(c.addClass(document.body,"p-overflow-hidden"),document.activeElement.blur()),k.autoZIndex){var e=k.fullScreen?"modal":"overlay";u.set(e,E.current,n.autoZIndex,k.baseZIndex||n.zIndex[e])}k.onBlocked&&k.onBlocked()};r((function(){P&&j()})),t((function(){k.blocked?j():x()}),[k.blocked]),o((function(){k.fullScreen&&c.removeClass(document.body,"p-overflow-hidden"),u.clear(E.current)})),e.useImperativeHandle(v,(function(){return{props:k,block:j,unblock:x,getElement:function(){return w.current}}}));var N=b.getOtherProps(k),A=function(){if(P){var n=k.fullScreen?document.body:"self",r=i("p-blockui p-component-overlay p-component-overlay-enter",{"p-blockui-document":k.fullScreen},k.className),t=k.template?a.getJSXElement(k.template,k):null;return e.createElement(l,{element:e.createElement("div",{ref:E,className:r,style:k.style},t),appendTo:n,onMounted:C})}return null}(),U=i("p-blockui-container",k.containerClassName);return e.createElement("div",f({id:k.id,ref:w,className:U,style:k.containerStyle},N),k.children,A)}));v.displayName="BlockUI";export{v as BlockUI};