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.67 kB
JavaScript
this.primereact=this.primereact||{},this.primereact.deferredcontent=function(e,t,r,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var u=o(t);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i.apply(this,arguments)}function a(e){if(Array.isArray(e))return e}function c(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,u,i,a=[],c=!0,l=!1;try{if(u=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=u.call(r)).done)&&(a.push(n.value),a.length!==t);c=!0);}catch(e){l=!0,o=e}finally{try{if(!c&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return a}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t){if(e){if("string"==typeof e)return l(e,t);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)?l(e,t):void 0}}function s(){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 d(e,t){return a(e)||c(e,t)||f(e,t)||s()}var p={defaultProps:{__TYPE:"DeferredContent",onload:null,children:void 0},getProps:function(e){return n.ObjectUtils.getMergedProps(e,p.defaultProps)},getOtherProps:function(e){return n.ObjectUtils.getDiffProps(e,p.defaultProps)}},y=u.forwardRef((function(e,t){var n=p.getProps(e),o=d(u.useState(!1),2),a=o[0],c=o[1],l=u.useRef(null),f=d(r.useEventListener({target:"window",type:"scroll",listener:function(){b()&&(g(),y())}}),2),s=f[0],y=f[1],b=function(){if(a)return!1;var e=l.current.getBoundingClientRect();return document.documentElement.clientHeight>=e.top},g=function(e){c(!0),n.onLoad&&n.onLoad(e)};u.useImperativeHandle(t,(function(){return{props:n,getElement:function(){return l.current}}})),r.useMountEffect((function(){a||(b()?g():s())}));var m=p.getOtherProps(n);return u.createElement("div",i({ref:l},m),a&&n.children)}));return y.displayName="DeferredContent",e.DeferredContent=y,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.hooks,primereact.utils);