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) 2.03 kB
import*as r from"react";import{useEventListener as t,useMountEffect as e}from"primereact/hooks";import{ObjectUtils as n}from"primereact/utils";function o(){return o=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r},o.apply(this,arguments)}function i(r){if(Array.isArray(r))return r}function a(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,i=[],a=!0,u=!1;try{for(e=e.call(r);!(a=(n=e.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(r){u=!0,o=r}finally{try{a||null==e.return||e.return()}finally{if(u)throw o}}return i}}function u(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e<t;e++)n[e]=r[e];return n}function l(r,t){if(r){if("string"==typeof r)return u(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);return"Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(r,t):void 0}}function c(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(r,t){return i(r)||a(r,t)||l(r,t)||c()}var s=r.forwardRef((function(i,a){var u=f(r.useState(!1),2),l=u[0],c=u[1],p=r.useRef(null),d=f(t({target:"window",type:"scroll",listener:function(){v()&&(h(),y())}}),2),m=d[0],y=d[1],v=function(){if(l)return!1;var r=p.current.getBoundingClientRect();return document.documentElement.clientHeight>=r.top},h=function(r){c(!0),i.onLoad&&i.onLoad(r)};r.useImperativeHandle(a,(function(){return{props:i,getElement:function(){return p.current}}})),e((function(){l||(v()?h():m())}));var g=n.findDiffKeys(i,s.defaultProps);return r.createElement("div",o({ref:p},g),l&&i.children)}));s.displayName="DeferredContent",s.defaultProps={__TYPE:"DeferredContent",onload:null};export{s as DeferredContent};