UNPKG

primereact

Version:

PrimeReact is an open source UI library for React 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 Prime

2 lines (1 loc) 3.11 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{DomHandler as a,ZIndexUtils as c,ObjectUtils as u,classNames as i}from"primereact/utils";function d(){return d=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},d.apply(this,arguments)}function f(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=!0,c=!1;try{for(r=r.call(e);!(a=(t=r.next()).done)&&(l.push(t.value),!n||l.length!==n);a=!0);}catch(e){c=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(c)throw o}}return l}}function m(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 p(e,n){if(e){if("string"==typeof e)return m(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)?m(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=e.forwardRef((function(m,v){var k,h,S=e.useState(m.blocked),I=(h=2,f(k=S)||s(k,h)||p(k,h)||y()),g=I[0],w=I[1],E=e.useRef(null),x=e.useRef(null),j=function(){w(!0)},A=function(){var e=function(){w(!1),m.fullScreen&&a.removeClass(document.body,"p-overflow-hidden"),m.onUnblocked&&m.onUnblocked()};x.current?(a.addClass(x.current,"p-component-overlay-leave"),x.current.addEventListener("animationend",(function(){c.clear(x.current),e()}))):e()},O=function(){if(m.fullScreen&&(a.addClass(document.body,"p-overflow-hidden"),document.activeElement.blur()),m.autoZIndex){var e=m.fullScreen?"modal":"overlay";c.set(e,x.current,n.autoZIndex,m.baseZIndex||n.zIndex[e])}m.onBlocked&&m.onBlocked()};r((function(){g&&j()})),t((function(){m.blocked?j():A()}),[m.blocked]),o((function(){m.fullScreen&&a.removeClass(document.body,"p-overflow-hidden"),c.clear(x.current)})),e.useImperativeHandle(v,(function(){return{props:m,block:j,unblock:A,getElement:function(){return E.current}}}));var U=u.findDiffKeys(m,b.defaultProps),B=function(){if(g){var n=m.fullScreen?document.body:"self",r=i("p-blockui p-component-overlay p-component-overlay-enter",{"p-blockui-document":m.fullScreen},m.className),t=m.template?u.getJSXElement(m.template,m):null;return e.createElement(l,{element:e.createElement("div",{ref:x,className:r,style:m.style},t),appendTo:n,onMounted:O})}return null}();return e.createElement("div",d({id:m.id,ref:E,className:"p-blockui-container"},U),m.children,B)}));b.displayName="BlockUI",b.defaultProps={__TYPE:"BlockUI",id:null,blocked:!1,fullScreen:!1,baseZIndex:0,autoZIndex:!0,style:null,className:null,template:null,onBlocked:null,onUnblocked:null};export{b as BlockUI};