UNPKG

react-infinite-any-height

Version:

Wrapper component for react-infinite which auto calculates element heights.

2 lines 32.8 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("prop-types"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","prop-types","react-dom"],e):"object"==typeof exports?exports.InfiniteAnyHeight=e(require("react"),require("prop-types"),require("react-dom")):t.InfiniteAnyHeight=e(t.react,t["prop-types"],t["react-dom"])}(window,function(t,e,n){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=20)}([function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(e,n){e.exports=t},function(t,n){t.exports=e},function(t,e,n){(function(e){var n=e.isFinite;t.exports=function(t){return"number"==typeof t&&n(t)}}).call(this,n(0))},function(t,e,n){"use strict";var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var o=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.heightData=e,this.numberOfChildren=n}return r(t,[{key:"getTotalScrollableHeight",value:function(){0}},{key:"getDisplayIndexStart",value:function(t){0}},{key:"getDisplayIndexEnd",value:function(t){0}},{key:"getTopSpacerHeight",value:function(t){0}},{key:"getBottomSpacerHeight",value:function(t){0}}]),t}();t.exports=o},function(t,e,n){"use strict";t.exports={CONTAINER_HEIGHT_SCALE_FACTOR:"containerHeightScaleFactor"}},function(t,e,n){"use strict";(function(e){var n;n="undefined"!=typeof window?window:void 0!==e?e:"undefined"!=typeof self?self:{},t.exports=n}).call(this,n(0))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=i(n(1)),o=i(n(2));function i(t){return t&&t.__esModule?t:{default:t}}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}var l={display:"block",clear:"both"},c=function(t){function e(){var t,n,o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,c=Array(i),s=0;s<i;s++)c[s]=arguments[s];return n=o=a(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(c))),o.state={height:void 0},o.componentDidMount=function(){o.setHeight()},o.setHeight=function(){var t=o.node.getBoundingClientRect().height;o.props.addHeight(t),o.setState({height:t})},o.render=function(){return r.default.createElement("span",{ref:function(t){o.node=t},style:l},o.props.children)},a(o,n)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,r.default.Component),e}();c.propTypes={addHeight:o.default.func,children:o.default.node},e.default=c},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,n){(function(t,n){var r=200,o="__lodash_hash_undefined__",i=1,a=2,l=9007199254740991,c="[object Arguments]",s="[object Array]",u="[object AsyncFunction]",f="[object Boolean]",p="[object Date]",h="[object Error]",d="[object Function]",y="[object GeneratorFunction]",g="[object Map]",b="[object Number]",v="[object Null]",m="[object Object]",S="[object Proxy]",_="[object RegExp]",O="[object Set]",w="[object String]",j="[object Symbol]",T="[object Undefined]",H="[object ArrayBuffer]",A="[object DataView]",E=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,P={};P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P[c]=P[s]=P[H]=P[f]=P[A]=P[p]=P[h]=P[d]=P[g]=P[b]=P[m]=P[_]=P[O]=P[w]=P["[object WeakMap]"]=!1;var C="object"==typeof t&&t&&t.Object===Object&&t,x="object"==typeof self&&self&&self.Object===Object&&self,L=C||x||Function("return this")(),k="object"==typeof e&&e&&!e.nodeType&&e,B=k&&"object"==typeof n&&n&&!n.nodeType&&n,R=B&&B.exports===k,F=R&&C.process,D=function(){try{return F&&F.binding&&F.binding("util")}catch(t){}}(),z=D&&D.isTypedArray;function U(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function M(t){var e=-1,n=Array(t.size);return t.forEach(function(t,r){n[++e]=[r,t]}),n}function W(t){var e=-1,n=Array(t.size);return t.forEach(function(t){n[++e]=t}),n}var N,q,$,G=Array.prototype,V=Function.prototype,Y=Object.prototype,X=L["__core-js_shared__"],J=V.toString,K=Y.hasOwnProperty,Q=(N=/[^.]+$/.exec(X&&X.keys&&X.keys.IE_PROTO||""))?"Symbol(src)_1."+N:"",Z=Y.toString,tt=RegExp("^"+J.call(K).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),et=R?L.Buffer:void 0,nt=L.Symbol,rt=L.Uint8Array,ot=Y.propertyIsEnumerable,it=G.splice,at=nt?nt.toStringTag:void 0,lt=Object.getOwnPropertySymbols,ct=et?et.isBuffer:void 0,st=(q=Object.keys,$=Object,function(t){return q($(t))}),ut=Dt(L,"DataView"),ft=Dt(L,"Map"),pt=Dt(L,"Promise"),ht=Dt(L,"Set"),dt=Dt(L,"WeakMap"),yt=Dt(Object,"create"),gt=Wt(ut),bt=Wt(ft),vt=Wt(pt),mt=Wt(ht),St=Wt(dt),_t=nt?nt.prototype:void 0,Ot=_t?_t.valueOf:void 0;function wt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function jt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Tt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Ht(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Tt;++e<n;)this.add(t[e])}function At(t){var e=this.__data__=new jt(t);this.size=e.size}function Et(t,e){var n=$t(t),r=!n&&qt(t),o=!n&&!r&&Gt(t),i=!n&&!r&&!o&&Kt(t),a=n||r||o||i,l=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],c=l.length;for(var s in t)!e&&!K.call(t,s)||a&&("length"==s||o&&("offset"==s||"parent"==s)||i&&("buffer"==s||"byteLength"==s||"byteOffset"==s)||Mt(s,c))||l.push(s);return l}function It(t,e){for(var n=t.length;n--;)if(Nt(t[n][0],e))return n;return-1}function Pt(t){return null==t?void 0===t?T:v:at&&at in Object(t)?function(t){var e=K.call(t,at),n=t[at];try{t[at]=void 0;var r=!0}catch(t){}var o=Z.call(t);r&&(e?t[at]=n:delete t[at]);return o}(t):function(t){return Z.call(t)}(t)}function Ct(t){return Jt(t)&&Pt(t)==c}function xt(t,e,n,r,o){return t===e||(null==t||null==e||!Jt(t)&&!Jt(e)?t!=t&&e!=e:function(t,e,n,r,o,l){var u=$t(t),d=$t(e),y=u?s:Ut(t),v=d?s:Ut(e),S=(y=y==c?m:y)==m,T=(v=v==c?m:v)==m,E=y==v;if(E&&Gt(t)){if(!Gt(e))return!1;u=!0,S=!1}if(E&&!S)return l||(l=new At),u||Kt(t)?Bt(t,e,n,r,o,l):function(t,e,n,r,o,l,c){switch(n){case A:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case H:return!(t.byteLength!=e.byteLength||!l(new rt(t),new rt(e)));case f:case p:case b:return Nt(+t,+e);case h:return t.name==e.name&&t.message==e.message;case _:case w:return t==e+"";case g:var s=M;case O:var u=r&i;if(s||(s=W),t.size!=e.size&&!u)return!1;var d=c.get(t);if(d)return d==e;r|=a,c.set(t,e);var y=Bt(s(t),s(e),r,o,l,c);return c.delete(t),y;case j:if(Ot)return Ot.call(t)==Ot.call(e)}return!1}(t,e,y,n,r,o,l);if(!(n&i)){var I=S&&K.call(t,"__wrapped__"),P=T&&K.call(e,"__wrapped__");if(I||P){var C=I?t.value():t,x=P?e.value():e;return l||(l=new At),o(C,x,n,r,l)}}if(!E)return!1;return l||(l=new At),function(t,e,n,r,o,a){var l=n&i,c=Rt(t),s=c.length,u=Rt(e).length;if(s!=u&&!l)return!1;for(var f=s;f--;){var p=c[f];if(!(l?p in e:K.call(e,p)))return!1}var h=a.get(t);if(h&&a.get(e))return h==e;var d=!0;a.set(t,e),a.set(e,t);for(var y=l;++f<s;){p=c[f];var g=t[p],b=e[p];if(r)var v=l?r(b,g,p,e,t,a):r(g,b,p,t,e,a);if(!(void 0===v?g===b||o(g,b,n,r,a):v)){d=!1;break}y||(y="constructor"==p)}if(d&&!y){var m=t.constructor,S=e.constructor;m!=S&&"constructor"in t&&"constructor"in e&&!("function"==typeof m&&m instanceof m&&"function"==typeof S&&S instanceof S)&&(d=!1)}return a.delete(t),a.delete(e),d}(t,e,n,r,o,l)}(t,e,n,r,xt,o))}function Lt(t){return!(!Xt(t)||Q&&Q in t)&&(Vt(t)?tt:E).test(Wt(t))}function kt(t){if(n=(e=t)&&e.constructor,r="function"==typeof n&&n.prototype||Y,e!==r)return st(t);var e,n,r,o=[];for(var i in Object(t))K.call(t,i)&&"constructor"!=i&&o.push(i);return o}function Bt(t,e,n,r,o,l){var c=n&i,s=t.length,u=e.length;if(s!=u&&!(c&&u>s))return!1;var f=l.get(t);if(f&&l.get(e))return f==e;var p=-1,h=!0,d=n&a?new Ht:void 0;for(l.set(t,e),l.set(e,t);++p<s;){var y=t[p],g=e[p];if(r)var b=c?r(g,y,p,e,t,l):r(y,g,p,t,e,l);if(void 0!==b){if(b)continue;h=!1;break}if(d){if(!U(e,function(t,e){if(i=e,!d.has(i)&&(y===t||o(y,t,n,r,l)))return d.push(e);var i})){h=!1;break}}else if(y!==g&&!o(y,g,n,r,l)){h=!1;break}}return l.delete(t),l.delete(e),h}function Rt(t){return function(t,e,n){var r=e(t);return $t(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Qt,zt)}function Ft(t,e){var n,r,o=t.__data__;return("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function Dt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return Lt(n)?n:void 0}wt.prototype.clear=function(){this.__data__=yt?yt(null):{},this.size=0},wt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},wt.prototype.get=function(t){var e=this.__data__;if(yt){var n=e[t];return n===o?void 0:n}return K.call(e,t)?e[t]:void 0},wt.prototype.has=function(t){var e=this.__data__;return yt?void 0!==e[t]:K.call(e,t)},wt.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=yt&&void 0===e?o:e,this},jt.prototype.clear=function(){this.__data__=[],this.size=0},jt.prototype.delete=function(t){var e=this.__data__,n=It(e,t);return!(n<0||(n==e.length-1?e.pop():it.call(e,n,1),--this.size,0))},jt.prototype.get=function(t){var e=this.__data__,n=It(e,t);return n<0?void 0:e[n][1]},jt.prototype.has=function(t){return It(this.__data__,t)>-1},jt.prototype.set=function(t,e){var n=this.__data__,r=It(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},Tt.prototype.clear=function(){this.size=0,this.__data__={hash:new wt,map:new(ft||jt),string:new wt}},Tt.prototype.delete=function(t){var e=Ft(this,t).delete(t);return this.size-=e?1:0,e},Tt.prototype.get=function(t){return Ft(this,t).get(t)},Tt.prototype.has=function(t){return Ft(this,t).has(t)},Tt.prototype.set=function(t,e){var n=Ft(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},Ht.prototype.add=Ht.prototype.push=function(t){return this.__data__.set(t,o),this},Ht.prototype.has=function(t){return this.__data__.has(t)},At.prototype.clear=function(){this.__data__=new jt,this.size=0},At.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},At.prototype.get=function(t){return this.__data__.get(t)},At.prototype.has=function(t){return this.__data__.has(t)},At.prototype.set=function(t,e){var n=this.__data__;if(n instanceof jt){var o=n.__data__;if(!ft||o.length<r-1)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new Tt(o)}return n.set(t,e),this.size=n.size,this};var zt=lt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var a=t[n];e(a,n,t)&&(i[o++]=a)}return i}(lt(t),function(e){return ot.call(t,e)}))}:function(){return[]},Ut=Pt;function Mt(t,e){return!!(e=null==e?l:e)&&("number"==typeof t||I.test(t))&&t>-1&&t%1==0&&t<e}function Wt(t){if(null!=t){try{return J.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Nt(t,e){return t===e||t!=t&&e!=e}(ut&&Ut(new ut(new ArrayBuffer(1)))!=A||ft&&Ut(new ft)!=g||pt&&"[object Promise]"!=Ut(pt.resolve())||ht&&Ut(new ht)!=O||dt&&"[object WeakMap]"!=Ut(new dt))&&(Ut=function(t){var e=Pt(t),n=e==m?t.constructor:void 0,r=n?Wt(n):"";if(r)switch(r){case gt:return A;case bt:return g;case vt:return"[object Promise]";case mt:return O;case St:return"[object WeakMap]"}return e});var qt=Ct(function(){return arguments}())?Ct:function(t){return Jt(t)&&K.call(t,"callee")&&!ot.call(t,"callee")},$t=Array.isArray;var Gt=ct||function(){return!1};function Vt(t){if(!Xt(t))return!1;var e=Pt(t);return e==d||e==y||e==u||e==S}function Yt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=l}function Xt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Jt(t){return null!=t&&"object"==typeof t}var Kt=z?function(t){return function(e){return t(e)}}(z):function(t){return Jt(t)&&Yt(t.length)&&!!P[Pt(t)]};function Qt(t){return null!=(e=t)&&Yt(e.length)&&!Vt(e)?Et(t):kt(t);var e}n.exports=function(t,e){return xt(t,e)}}).call(this,n(0),n(8)(t))},function(t,e,n){"use strict";(function(e){var r=e.React||n(1),o=n(3);t.exports=function(t){var e="Invariant Violation: ";if(!t.containerHeight&&!t.useWindowAsScrollContainer)throw new Error(e+"Either containerHeight or useWindowAsScrollContainer must be provided.");if(!o(t.elementHeight)&&!Array.isArray(t.elementHeight))throw new Error(e+"You must provide either a number or an array of numbers as the elementHeight.");if(Array.isArray(t.elementHeight)&&r.Children.count(t.children)!==t.elementHeight.length)throw new Error(e+"There must be as many values provided in the elementHeight prop as there are children.")}}).call(this,n(0))},function(t,e,n){"use strict";var r={CLOSEST_LOWER:1,CLOSEST_HIGHER:2};t.exports={binaryIndexSearch:function(t,e,n){for(var o,i,a,l=t.length-1,c=0;c<=l;){if((a=t[i=c+Math.floor((l-c)/2)])===e)return i;a<e?c=i+1:a>e&&(l=i-1)}return n===r.CLOSEST_LOWER&&c>0?o=c-1:n===r.CLOSEST_HIGHER&&l<t.length-1&&(o=l+1),o},opts:r}},function(t,e,n){"use strict";var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var o=n(4),i=n(11),a=function(t){function e(t,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var r=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));return r.prefixHeightData=r.heightData.reduce(function(t,e){return 0===t.length?[e]:(t.push(t[t.length-1]+e),t)},[]),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,o),r(e,[{key:"maybeIndexToIndex",value:function(t){return void 0===t||null===t?this.prefixHeightData.length-1:t}},{key:"getTotalScrollableHeight",value:function(){var t=this.prefixHeightData.length;return 0===t?0:this.prefixHeightData[t-1]}},{key:"getDisplayIndexStart",value:function(t){var e=i.binaryIndexSearch(this.prefixHeightData,t,i.opts.CLOSEST_HIGHER);return this.maybeIndexToIndex(e)}},{key:"getDisplayIndexEnd",value:function(t){var e=i.binaryIndexSearch(this.prefixHeightData,t,i.opts.CLOSEST_HIGHER);return this.maybeIndexToIndex(e)}},{key:"getTopSpacerHeight",value:function(t){var e=t-1;return e<0?0:this.prefixHeightData[e]}},{key:"getBottomSpacerHeight",value:function(t){return-1===t?0:this.getTotalScrollableHeight()-this.prefixHeightData[t]}}]),e}();t.exports=a},function(t,e,n){"use strict";var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var o=n(4),i=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,o),r(e,[{key:"getTotalScrollableHeight",value:function(){return this.heightData*this.numberOfChildren}},{key:"getDisplayIndexStart",value:function(t){return Math.floor(t/this.heightData)}},{key:"getDisplayIndexEnd",value:function(t){var e=Math.ceil(t/this.heightData);return e>0?e-1:e}},{key:"getTopSpacerHeight",value:function(t){return t*this.heightData}},{key:"getBottomSpacerHeight",value:function(t){var e=t+1;return Math.max(0,(this.numberOfChildren-e)*this.heightData)}}]),e}();t.exports=i},function(t,e,n){"use strict";(function(e){var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};var o=n(13),i=n(12),a=n(5),l=e.React||n(1),c=n(6);t.exports={createInfiniteComputer:function(t,e){var n=l.Children.count(e);return Array.isArray(t)?new i(t,n):new o(t,n)},recomputeApertureStateFromOptionsAndScrollTop:function(t,e){var n=t.preloadBatchSize,r=t.preloadAdditionalHeight,o=t.infiniteComputer,i=n*(0===n?0:Math.floor(e/n)),a=i+n,l=Math.max(0,i-r),c=Math.min(o.getTotalScrollableHeight(),a+r);return{displayIndexStart:o.getDisplayIndexStart(l),displayIndexEnd:o.getDisplayIndexEnd(c)}},generateComputedProps:function(t){var e=t.containerHeight,n=t.preloadBatchSize,o=t.preloadAdditionalHeight,i=t.handleScroll,l=t.onInfiniteLoad,s=function(t,e){var n={};for(var r in t)e.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n}(t,["containerHeight","preloadBatchSize","preloadAdditionalHeight","handleScroll","onInfiniteLoad"]),u={};e="number"==typeof e?e:0,u.containerHeight=t.useWindowAsScrollContainer?c.innerHeight:e,u.handleScroll=i||function(){},u.onInfiniteLoad=l||function(){};var f={type:a.CONTAINER_HEIGHT_SCALE_FACTOR,amount:.5},p=n&&n.type?n:f;"number"==typeof n?u.preloadBatchSize=n:"object"===(void 0===p?"undefined":r(p))&&p.type===a.CONTAINER_HEIGHT_SCALE_FACTOR?u.preloadBatchSize=u.containerHeight*p.amount:u.preloadBatchSize=0;var h={type:a.CONTAINER_HEIGHT_SCALE_FACTOR,amount:1},d=o&&o.type?o:h;return"number"==typeof o?u.preloadAdditionalHeight=o:"object"===(void 0===d?"undefined":r(d))&&d.type===a.CONTAINER_HEIGHT_SCALE_FACTOR?u.preloadAdditionalHeight=u.containerHeight*d.amount:u.preloadAdditionalHeight=0,Object.assign(s,u)},buildHeightStyle:function(t){return{width:"100%",height:Math.ceil(t)}}}}).call(this,n(0))},function(t,e){var n="[object Function]",r=/^\[object .+?Constructor\]$/;function o(t){return!!t&&"object"==typeof t}var i,a,l=Object.prototype,c=Function.prototype.toString,s=l.hasOwnProperty,u=l.toString,f=RegExp("^"+c.call(s).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),p=9007199254740991;var h=(i=Array,function(t){return null!=t&&(function(t){return function(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}(t)&&u.call(t)==n}(t)?f.test(c.call(t)):o(t)&&r.test(t))}(a=null==i?void 0:i["isArray"])?a:void 0)||function(t){return o(t)&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=p}(t.length)&&"[object Array]"==u.call(t)};t.exports=h},function(t,e,n){"use strict";var r=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(t,e){for(var n,i,a=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),l=1;l<arguments.length;l++){for(var c in n=Object(arguments[l]))r.call(n,c)&&(a[c]=n[c]);if(Object.getOwnPropertySymbols){i=Object.getOwnPropertySymbols(n);for(var s=0;s<i.length;s++)o.call(n,i[s])&&(a[i[s]]=n[i[s]])}}return a}},function(t,e,n){"use strict";Object.assign||(Object.assign=n(16)),Array.isArray||(Array.isArray=n(15))},function(t,e,n){"use strict";(function(e){var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var o=e.React||n(1),i=e.PropTypes||n(2),a=n(6);n(17);var l=n(5),c=n(14),s=n(3),u=n(10),f=function(t){function e(t){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var n=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));p.call(n);var r=n.recomputeInternalStateFromProps(t);n.computedProps=r.computedProps,n.utils=r.utils,n.shouldAttachToBottom=t.displayBottomUpwards;var o=r.newState;return o.scrollTimeout=void 0,o.isScrolling=!1,n.state=o,n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,o.Component),r(e,null,[{key:"containerHeightScaleFactor",value:function(t){if(!s(t))throw new Error("The scale factor must be a number.");return{type:l.CONTAINER_HEIGHT_SCALE_FACTOR,amount:t}}}]),r(e,[{key:"componentWillReceiveProps",value:function(t){var e=this.recomputeInternalStateFromProps(t);this.computedProps=e.computedProps,this.utils=e.utils,this.setState(e.newState)}},{key:"componentWillUpdate",value:function(){this.props.displayBottomUpwards&&(this.preservedScrollState=this.utils.getScrollTop()-this.loadingSpinnerHeight)}},{key:"componentDidUpdate",value:function(t,e){if(this.loadingSpinnerHeight=this.utils.getLoadingSpinnerHeight(),!t.useWindowAsScrollContainer&&this.props.useWindowAsScrollContainer&&this.utils.subscribeToScrollListener(),this.props.displayBottomUpwards){var n=this.getLowestPossibleScrollTop();this.shouldAttachToBottom&&this.utils.getScrollTop()<n?this.utils.setScrollTop(n):t.isInfiniteLoading&&!this.props.isInfiniteLoading&&this.utils.setScrollTop(this.state.infiniteComputer.getTotalScrollableHeight()-e.infiniteComputer.getTotalScrollableHeight()+this.preservedScrollState)}var r=this.state.numberOfChildren!==e.numberOfChildren;if(r){var o=c.recomputeApertureStateFromOptionsAndScrollTop(this.state,this.utils.getScrollTop());this.setState(o)}r&&!this.hasAllVisibleItems()&&!this.state.isInfiniteLoading&&this.onInfiniteLoad()}},{key:"componentDidMount",value:function(){if(this.utils.subscribeToScrollListener(),this.hasAllVisibleItems()||this.onInfiniteLoad(),this.props.displayBottomUpwards){var t=this.getLowestPossibleScrollTop();this.shouldAttachToBottom&&this.utils.getScrollTop()<t&&this.utils.setScrollTop(t)}}},{key:"componentWillUnmount",value:function(){this.utils.unsubscribeFromScrollListener()}},{key:"render",value:function(){var t,e=this;t=this.state.numberOfChildren>1?this.computedProps.children.slice(this.state.displayIndexStart,this.state.displayIndexEnd+1):this.computedProps.children;var n={};this.state.isScrolling&&(n.pointerEvents="none");var r=this.state.infiniteComputer.getTopSpacerHeight(this.state.displayIndexStart),i=this.state.infiniteComputer.getBottomSpacerHeight(this.state.displayIndexEnd);if(this.computedProps.displayBottomUpwards){var a=this.computedProps.containerHeight-this.state.infiniteComputer.getTotalScrollableHeight();a>0&&(r=a-this.loadingSpinnerHeight)}var l=void 0===this.computedProps.infiniteLoadBeginEdgeOffset?null:o.createElement("div",{ref:function(t){e.loadingSpinner=t}},this.state.isInfiniteLoading?this.computedProps.loadingSpinnerDelegate:null);return o.createElement("div",{className:this.computedProps.className,ref:function(t){e.scrollable=t},style:this.utils.buildScrollableStyle(),onScroll:this.utils.nodeScrollListener},o.createElement("div",{ref:function(t){e.smoothScrollingWrapper=t},style:n},o.createElement("div",{ref:function(t){e.topSpacer=t},style:c.buildHeightStyle(r)}),this.computedProps.displayBottomUpwards&&l,t,!this.computedProps.displayBottomUpwards&&l,o.createElement("div",{ref:function(t){e.bottomSpacer=t},style:c.buildHeightStyle(i)})))}}]),e}();f.propTypes={children:i.any,handleScroll:i.func,preloadBatchSize:i.oneOfType([i.number,i.shape({type:i.oneOf(["containerHeightScaleFactor"]).isRequired,amount:i.number.isRequired})]),preloadAdditionalHeight:i.oneOfType([i.number,i.shape({type:i.oneOf(["containerHeightScaleFactor"]).isRequired,amount:i.number.isRequired})]),elementHeight:i.oneOfType([i.number,i.arrayOf(i.number)]).isRequired,containerHeight:i.number,useWindowAsScrollContainer:i.bool,displayBottomUpwards:i.bool.isRequired,infiniteLoadBeginEdgeOffset:i.number,onInfiniteLoad:i.func,loadingSpinnerDelegate:i.node,isInfiniteLoading:i.bool,timeScrollStateLastsForAfterUserScrolls:i.number,className:i.string,styles:i.shape({scrollableStyle:i.object}).isRequired},f.defaultProps={handleScroll:function(){},useWindowAsScrollContainer:!1,onInfiniteLoad:function(){},loadingSpinnerDelegate:o.createElement("div",null),displayBottomUpwards:!1,isInfiniteLoading:!1,timeScrollStateLastsForAfterUserScrolls:150,className:"",styles:{}};var p=function(){var t=this;this.shouldAttachToBottom=!1,this.preservedScrollState=0,this.loadingSpinnerHeight=0,this.generateComputedUtilityFunctions=function(e){var n={getLoadingSpinnerHeight:function(){var e=0;return t.loadingSpinner&&(e=t.loadingSpinner.offsetHeight||0),e}};return e.useWindowAsScrollContainer?(n.subscribeToScrollListener=function(){a.addEventListener("scroll",t.infiniteHandleScroll)},n.unsubscribeFromScrollListener=function(){a.removeEventListener("scroll",t.infiniteHandleScroll)},n.nodeScrollListener=function(){},n.getScrollTop=function(){return a.pageYOffset},n.setScrollTop=function(t){a.scroll(a.pageXOffset,t)},n.scrollShouldBeIgnored=function(){return!1},n.buildScrollableStyle=function(){return{}}):(n.subscribeToScrollListener=function(){},n.unsubscribeFromScrollListener=function(){},n.nodeScrollListener=t.infiniteHandleScroll,n.getScrollTop=function(){return t.scrollable?t.scrollable.scrollTop:0},n.setScrollTop=function(e){t.scrollable&&(t.scrollable.scrollTop=e)},n.scrollShouldBeIgnored=function(e){return e.target!==t.scrollable},n.buildScrollableStyle=function(){return Object.assign({},{height:t.computedProps.containerHeight,overflowX:"hidden",overflowY:"scroll",WebkitOverflowScrolling:"touch"},t.computedProps.styles.scrollableStyle||{})}),n},this.recomputeInternalStateFromProps=function(e){u(e);var n=c.generateComputedProps(e),r=t.generateComputedUtilityFunctions(e),i={};return i.numberOfChildren=o.Children.count(n.children),i.infiniteComputer=c.createInfiniteComputer(n.elementHeight,n.children),void 0!==n.isInfiniteLoading&&(i.isInfiniteLoading=n.isInfiniteLoading),i.preloadBatchSize=n.preloadBatchSize,i.preloadAdditionalHeight=n.preloadAdditionalHeight,{computedProps:n,utils:r,newState:i=Object.assign(i,c.recomputeApertureStateFromOptionsAndScrollTop(i,r.getScrollTop()))}},this.infiniteHandleScroll=function(e){t.utils.scrollShouldBeIgnored(e)||(t.computedProps.handleScroll(t.scrollable),t.handleScroll(t.utils.getScrollTop()))},this.manageScrollTimeouts=function(){t.state.scrollTimeout&&clearTimeout(t.state.scrollTimeout);var e=t,n=setTimeout(function(){e.setState({isScrolling:!1,scrollTimeout:void 0})},t.computedProps.timeScrollStateLastsForAfterUserScrolls);t.setState({isScrolling:!0,scrollTimeout:n})},this.getLowestPossibleScrollTop=function(){return t.state.infiniteComputer.getTotalScrollableHeight()-t.computedProps.containerHeight},this.hasAllVisibleItems=function(){return!(s(t.computedProps.infiniteLoadBeginEdgeOffset)&&t.state.infiniteComputer.getTotalScrollableHeight()<t.computedProps.containerHeight)},this.passedEdgeForInfiniteScroll=function(e){var n=t.computedProps.infiniteLoadBeginEdgeOffset;return"number"==typeof n&&(t.computedProps.displayBottomUpwards?!t.shouldAttachToBottom&&e<n:e>t.state.infiniteComputer.getTotalScrollableHeight()-t.computedProps.containerHeight-n)},this.onInfiniteLoad=function(){t.setState({isInfiniteLoading:!0}),t.computedProps.onInfiniteLoad()},this.handleScroll=function(e){t.shouldAttachToBottom=t.computedProps.displayBottomUpwards&&e>=t.getLowestPossibleScrollTop(),t.manageScrollTimeouts();var n=c.recomputeApertureStateFromOptionsAndScrollTop(t.state,e);t.passedEdgeForInfiniteScroll(e)&&!t.state.isInfiniteLoading?(t.setState(Object.assign({},n)),t.onInfiniteLoad()):t.setState(n)}};t.exports=f,e.Infinite=f}).call(this,n(0))},function(t,e){t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},o=n(1),i=f(o),a=f(n(2)),l=f(n(19)),c=f(n(18)),s=f(n(9)),u=f(n(7));function f(t){return t&&t.__esModule?t:{default:t}}function p(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}var h=function(t){function e(){var t,n,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var o=arguments.length,i=Array(o),a=0;a<o;a++)i[a]=arguments[a];return n=r=p(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(i))),d.call(r),p(r,n)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,o.Component),e}();h.displayName="InfiniteAnyHeight",h.propTypes={heights:a.default.array,heightsUpdateCallback:a.default.func,list:a.default.node,scrollContainer:a.default.object,useWindowAsScrollContainer:a.default.bool},h.defaultProps={heightsUpdateCallback:function(){},heights:[]};var d=function(){var t=this;this.state={heights:[],list:[]},this.lastScrollTop=0,this.scrollTopDelta=0,this.componentDidMount=function(){t.setList(t.props.list)},this.componentWillReceiveProps=function(e){(0,s.default)(e.list,t.props.list)||t.setList(e.list)},this.getScrollContainer=function(){return t.props.useWindowAsScrollContainer?document.body:l.default.findDOMNode(t)},this.addHeight=function(e,n){var r=t.state.heights,o=n-r[e];o&&t.scrollTopDelta<0&&(t.getScrollContainer().scrollTop+=o),r[e]=n,t.props.heightsUpdateCallback(r),t.setState({heights:r})},this.setList=function(e){var n=[],r=e.map(function(e,r){return n[r]=t.state.heights[r]||t.props.heights[r]||200,i.default.createElement(u.default,{addHeight:function(e){return t.addHeight(r,e)},key:r},e)});t.setState({heights:n,list:r})},this.handleScroll=function(){var e,n=t.getScrollContainer().scrollTop;(t.scrollTopDelta=n-t.lastScrollTop,t.lastScrollTop=n,"function"==typeof t.props.handleScroll)&&(e=t.props).handleScroll.apply(e,arguments)},this.render=function(){return i.default.createElement(c.default,r({elementHeight:t.state.heights,handleScroll:t.handleScroll},t.props),t.state.list)}};e.default=h}])}); //# sourceMappingURL=main.js.map