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) • 2.27 kB
JavaScript
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 u(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=e){var n,o,i,u,a=[],l=!0,c=!1;try{if(i=(e=e.call(r)).next,0===t){if(Object(e)!==e)return;l=!1}else for(;!(l=(n=i.call(e)).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(r){c=!0,o=r}finally{try{if(!l&&null!=e.return&&(u=e.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}function a(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 a(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)?a(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)||u(r,t)||l(r,t)||c()}var s={defaultProps:{__TYPE:"DeferredContent",onload:null,children:void 0},getProps:function(r){return n.getMergedProps(r,s.defaultProps)},getOtherProps:function(r){return n.getDiffProps(r,s.defaultProps)}},p=r.forwardRef((function(n,i){var u=s.getProps(n),a=f(r.useState(!1),2),l=a[0],c=a[1],p=r.useRef(null),d=f(t({target:"window",type:"scroll",listener:function(){g()&&(h(),y())}}),2),m=d[0],y=d[1],g=function(){if(l)return!1;var r=p.current.getBoundingClientRect();return document.documentElement.clientHeight>=r.top},h=function(r){c(!0),u.onLoad&&u.onLoad(r)};r.useImperativeHandle(i,(function(){return{props:u,getElement:function(){return p.current}}})),e((function(){l||(g()?h():m())}));var v=s.getOtherProps(u);return r.createElement("div",o({ref:p},v),l&&u.children)}));p.displayName="DeferredContent";export{p as DeferredContent};