UNPKG

react-windowed-list

Version:

A fast, versatile virtual-render list component for React

2 lines (1 loc) 24.3 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("remeasure")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","remeasure"],t):t(e.WindowedList={},e.React,e.ReactDOM,e.Remeasure)}(this,function(e,t,r,n){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var o=["forceUpdate","setState"],i={getInitialState:!0,getInitialValues:!0,isPure:!0,onConstruct:!0,state:!0},a={displayName:!0},u=function(e){return o.map(function(t){return Object.prototype.hasOwnProperty.call(e[t],"prototype")?e[t]=e[t].bind(e):e[t]})},c=function(e){return!!e&&e instanceof t.Component},f=function(e){return console.error("The instance provided for use with the "+e+" is not a valid React component instance.")};function s(){return(s=Object.assign||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}).apply(this,arguments)}var l,p=(l=function(e){return e},function(e,t){return c(e)?function(r){return e[t]=l(r)}:f("ref")}),d=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];if(!c(e))return f("method");u(e);var i=t.memoizer;delete t.memoizer;var a=function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return t.call(e,e,o,n)};return i?i(a):a},m=function(e,t){return c(e)?u(e)&&function(){for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return t.call(e,e.props,e,n)}:f("render")},v=function(e,t){return c(e)?u(e)&&function(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),i=1;i<n;i++)o[i-1]=arguments[i];return t.call(e,r,e,o)}:f("render props")},y=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];return c(e)?u(e)&&t.call(e,e,n):f("value")},h=function e(r,n){if("function"!=typeof r){var o=r||{};return function(t,r){return"function"==typeof t?e(t,s({},o,r||{})):e(s({},o,t||{}))}}var u=n||{},c=u.getInitialState,f=u.getInitialValues,l=u.isPure,p=u.onConstruct,h=u.state,g=l?t.PureComponent:t.Component;function b(e){for(var t in g.call(this,e),this.state="function"==typeof c?y(this,c):h||null,u)i[t]||(this[t]="function"==typeof u[t]?u[t].isRender?m(this,u[t]):u[t].isRenderProps?v(this,u[t]):d(this,u[t]):u[t]);var n="function"==typeof f?y(this,f):null;if(n&&"object"==typeof n)for(var o in n)this[o]=n[o];return this.render=m(this,r),"function"==typeof p&&p(this),this}return b.prototype=Object.create(g.prototype),b.displayName=r.displayName||r.name||"ParmComponent",Object.keys(r).forEach(function(e){return!a[e]&&(b[e]=r[e])}),b},g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function b(e,t){return e(t={exports:{}},t.exports),t.exports}var w=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var P=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,n,o=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),i=1;i<arguments.length;i++){for(var a in r=Object(arguments[i]))O.call(r,a)&&(o[a]=r[a]);if(w){n=w(r);for(var u=0;u<n.length;u++)S.call(r,n[u])&&(o[n[u]]=r[n[u]])}}return o},R="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",x=function(){};if("production"!==process.env.NODE_ENV){var I=R,E={};x=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}var T=function(e,t,r,n,o){if("production"!==process.env.NODE_ENV)for(var i in e)if(e.hasOwnProperty(i)){var a;try{if("function"!=typeof e[i]){var u=Error((n||"React class")+": "+r+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.");throw u.name="Invariant Violation",u}a=e[i](t,i,n,r,null,I)}catch(e){a=e}if(!a||a instanceof Error||x((n||"React class")+": type specification of "+r+" `"+i+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof a+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),a instanceof Error&&!(a.message in E)){E[a.message]=!0;var c=o?o():"";x("Failed "+r+" type: "+a.message+(null!=c?c:""))}}},j=function(){};function z(){return null}"production"!==process.env.NODE_ENV&&(j=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}});var A=function(e,t){var r="function"==typeof Symbol&&Symbol.iterator,n="@@iterator";var o="<<anonymous>>",i={array:f("array"),bool:f("boolean"),func:f("function"),number:f("number"),object:f("object"),string:f("string"),symbol:f("symbol"),any:c(z),arrayOf:function(e){return c(function(t,r,n,o,i){if("function"!=typeof e)return new u("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside arrayOf.");var a=t[r];if(!Array.isArray(a)){var c=l(a);return new u("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected an array.")}for(var f=0;f<a.length;f++){var s=e(a,f,n,o,i+"["+f+"]",R);if(s instanceof Error)return s}return null})},element:function(){return c(function(t,r,n,o,i){var a=t[r];if(!e(a)){var c=l(a);return new u("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected a single ReactElement.")}return null})}(),instanceOf:function(e){return c(function(t,r,n,i,a){if(!(t[r]instanceof e)){var c=e.name||o,f=function(e){if(!e.constructor||!e.constructor.name)return o;return e.constructor.name}(t[r]);return new u("Invalid "+i+" `"+a+"` of type `"+f+"` supplied to `"+n+"`, expected instance of `"+c+"`.")}return null})},node:function(){return c(function(e,t,r,n,o){if(!s(e[t]))return new u("Invalid "+n+" `"+o+"` supplied to `"+r+"`, expected a ReactNode.");return null})}(),objectOf:function(e){return c(function(t,r,n,o,i){if("function"!=typeof e)return new u("Property `"+i+"` of component `"+n+"` has invalid PropType notation inside objectOf.");var a=t[r],c=l(a);if("object"!==c)return new u("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected an object.");for(var f in a)if(a.hasOwnProperty(f)){var s=e(a,f,n,o,i+"."+f,R);if(s instanceof Error)return s}return null})},oneOf:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&j("Invalid argument supplied to oneOf, expected an instance of array."),z;return c(function(t,r,n,o,i){for(var c=t[r],f=0;f<e.length;f++)if(a(c,e[f]))return null;var s=JSON.stringify(e);return new u("Invalid "+o+" `"+i+"` of value `"+c+"` supplied to `"+n+"`, expected one of "+s+".")})},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&j("Invalid argument supplied to oneOfType, expected an instance of array."),z;for(var t=0;t<e.length;t++){var r=e[t];if("function"!=typeof r)return j("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+d(r)+" at index "+t+"."),z}return c(function(t,r,n,o,i){for(var a=0;a<e.length;a++){var c=e[a];if(null==c(t,r,n,o,i,R))return null}return new u("Invalid "+o+" `"+i+"` supplied to `"+n+"`.")})},shape:function(e){return c(function(t,r,n,o,i){var a=t[r],c=l(a);if("object"!==c)return new u("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");for(var f in e){var s=e[f];if(s){var p=s(a,f,n,o,i+"."+f,R);if(p)return p}}return null})},exact:function(e){return c(function(t,r,n,o,i){var a=t[r],c=l(a);if("object"!==c)return new u("Invalid "+o+" `"+i+"` of type `"+c+"` supplied to `"+n+"`, expected `object`.");var f=P({},t[r],e);for(var s in f){var p=e[s];if(!p)return new u("Invalid "+o+" `"+i+"` key `"+s+"` supplied to `"+n+"`.\nBad object: "+JSON.stringify(t[r],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var d=p(a,s,n,o,i+"."+s,R);if(d)return d}return null})}};function a(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function u(e){this.message=e,this.stack=""}function c(e){if("production"!==process.env.NODE_ENV)var r={},n=0;function i(i,a,c,f,s,l,p){if(f=f||o,l=l||c,p!==R){if(t){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var m=f+":"+c;!r[m]&&n<3&&(j("You are manually calling a React.PropTypes validation function for the `"+l+"` prop on `"+f+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),r[m]=!0,n++)}}return null==a[c]?i?null===a[c]?new u("The "+s+" `"+l+"` is marked as required in `"+f+"`, but its value is `null`."):new u("The "+s+" `"+l+"` is marked as required in `"+f+"`, but its value is `undefined`."):null:e(a,c,f,s,l)}var a=i.bind(null,!1);return a.isRequired=i.bind(null,!0),a}function f(e){return c(function(t,r,n,o,i,a){var c=t[r];return l(c)!==e?new u("Invalid "+o+" `"+i+"` of type `"+p(c)+"` supplied to `"+n+"`, expected `"+e+"`."):null})}function s(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(s);if(null===t||e(t))return!0;var o=function(e){var t=e&&(r&&e[r]||e[n]);if("function"==typeof t)return t}(t);if(!o)return!1;var i,a=o.call(t);if(o!==t.entries){for(;!(i=a.next()).done;)if(!s(i.value))return!1}else for(;!(i=a.next()).done;){var u=i.value;if(u&&!s(u[1]))return!1}return!0;default:return!1}}function l(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||"Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol}(t,e)?"symbol":t}function p(e){if(void 0===e||null===e)return""+e;var t=l(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function d(e){var t=p(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return u.prototype=Error.prototype,i.checkPropTypes=T,i.PropTypes=i,i};function C(){}var M=b(function(e){if("production"!==process.env.NODE_ENV){var t="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103;e.exports=A(function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},!0)}else e.exports=function(){function e(e,t,r,n,o,i){if(i!==R){var a=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw a.name="Invariant Violation",a}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return r.checkPropTypes=C,r.PropTypes=r,r}()}),N=!!function(){if("undefined"==typeof window)return!1;var e=!1;try{document.createElement("div").addEventListener("test",function(){},{get passive(){return e=!0,!1}})}catch(e){}return e}()&&{passive:!0},k={x:"clientWidth",y:"clientHeight"},L={x:"clientTop",y:"clientLeft"},q={x:"innerWidth",y:"innerHeight"},F={x:"offsetWidth",y:"offsetHeight"},D={x:"offsetLeft",y:"offsetTop"},V={x:"overflowX",y:"overflowY"},_=["auto","scroll","overlay"],U={x:"scrollWidth",y:"scrollHeight"},W={x:"scrollLeft",y:"scrollTop"},B={x:"width",y:"height"},H={X:"x",Y:"y"},Y=Object.keys(H).map(function(e){return H[e]}),X={SIMPLE:"simple",UNIFORM:"uniform",VARIABLE:"variable"},J=Object.keys(X).map(function(e){return X[e]}),$={height:"100%",maxHeight:"inherit",width:"100%"},G={position:"relative"},K=+t.version.split(".").slice(0,2).join(".")>=16.3;function Q(e,t,r){var n,o,i,a,u;function c(){var f=Date.now()-a;f<t&&f>=0?n=setTimeout(c,t-f):(n=null,r||(u=e.apply(i,o),i=o=null))}null==t&&(t=100);var f=function(){i=this,o=arguments,a=Date.now();var f=r&&!n;return n||(n=setTimeout(c,t)),f&&(u=e.apply(i,o),i=o=null),u};return f.clear=function(){n&&(clearTimeout(n),n=null)},f.flush=function(){n&&(u=e.apply(i,o),i=o=null,clearTimeout(n),n=null)},f}Q.debounce=Q;for(var Z=Q,ee=b(function(e){(function(){var t,r,n,o,i,a;"undefined"!=typeof performance&&null!==performance&&performance.now?e.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(e.exports=function(){return(t()-i)/1e6},r=process.hrtime,o=(t=function(){var e;return 1e9*(e=r())[0]+e[1]})(),a=1e9*process.uptime(),i=o-a):Date.now?(e.exports=function(){return Date.now()-n},n=Date.now()):(e.exports=function(){return(new Date).getTime()-n},n=(new Date).getTime())}).call(g)}),te="undefined"==typeof window?g:window,re=["moz","webkit"],ne="AnimationFrame",oe=te["request"+ne],ie=te["cancel"+ne]||te["cancelRequest"+ne],ae=0;!oe&&ae<re.length;ae++)oe=te[re[ae]+"Request"+ne],ie=te[re[ae]+"Cancel"+ne]||te[re[ae]+"CancelRequest"+ne];if(!oe||!ie){var ue=0,ce=0,fe=[];oe=function(e){if(0===fe.length){var t=ee(),r=Math.max(0,1e3/60-(t-ue));ue=r+t,setTimeout(function(){var e=fe.slice(0);fe.length=0;for(var t=0;t<e.length;t++)if(!e[t].cancelled)try{e[t].callback(ue)}catch(e){setTimeout(function(){throw e},0)}},Math.round(r))}return fe.push({handle:++ce,callback:e,cancelled:!1}),ce},ie=function(e){for(var t=0;t<fe.length;t++)fe[t].handle===e&&(fe[t].cancelled=!0)}}var se=function(e){return oe.call(te,e)};se.cancel=function(){ie.apply(te,arguments)},se.polyfill=function(e){e||(e=te),e.requestAnimationFrame=oe,e.cancelAnimationFrame=ie};var le=Object.assign||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},pe=function(e){return"function"==typeof e},de=function(e){return"number"==typeof e},me=function(){},ve=function(e){return e||0},ye=function(e,t){for(var r=D[t],n=ve(e[L[t]])+ve(e[r]);e=e.offsetParent;)n+=ve(e[r]);return n},he=function(e,t,r,n){var o=n.isLazy,i=n.length,a=n.minSize,u=n.pageSize,c=n.type,f=Math.max(a,o&&c===X.UNIFORM?1:u),s=Math.max(t,f),l=s%r;l&&(s+=r-l),s>i&&(s=i);var p=e&&c!==X.SIMPLE?Math.max(Math.min(e,i-s),0):0;return(l=p%r)&&(p-=l,s+=l),{from:p,size:s}},ge=function(e,t){return e?e===window?window[q[t]]:e[k[t]]:0},be=Object.assign||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},we=Object.assign||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},Oe=Object.assign||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},Se={state:{from:0,itemsPerRow:0,size:0},onConstruct:function(e){var t=e.props,r=e.setReconcileFrameAfterUpdate,n=e.state;r(),e.state=we({},n,he(t.initialIndex,0,1,t),{itemsPerRow:1})},componentDidMount:function(e){e.outerContainer=r.findDOMNode(e),e.props.isHidden||se(function(){return e.updateFrame(e.scrollTo)})},componentDidUpdate:function(e){if(e.unstableTimeoutId||++e.updateCounter>100)return clearTimeout(e.unstableTimeoutId),e.unstableTimeoutId||console.error("WindowedList failed to reach a stable state."),void(e.unstableTimeoutId=setTimeout(function(){e.unstableTimeoutId=null,e.updateCounter=0},250));e.updateCounterTimeoutId||(e.updateCounterTimeoutId=se(function(){e.updateCounter=0,e.updateCounterTimeoutId=null})),e.props.isHidden||e.reconcileFrameAfterUpdate(e.updateFrame)},componentWillUnmount:function(e){e.scrollParent&&(e.scrollParent.removeEventListener("scroll",e.updateFrame,N),e.scrollParent.removeEventListener("mousewheel",me,N)),e.outerContainer=null},cache:{},outerContainer:null,reconcileFrameAfterUpdate:null,unstableTimeoutId:null,updateCounter:0,updateCounterTimeoutId:null,getItemSizeAndItemsPerRow:function(e){var t=e.items,r=e.props,n=r.axis,o=r.useStaticSize,i=e.state,a=i.itemSize,u=i.itemsPerRow;if(o&&a&&u)return{itemSize:a,itemsPerRow:u};var c=t?t.children:[];return c.length?function(e,t,r){var n,o=e[0],i=o[F[t]],a=Math.abs(i-r),u=(n=a)!=n||a>0?i:r;if(!u)return{};for(var c=D[t],f=o[c],s=1,l=e[s];l&&l[c]===f;)l=e[++s];return{itemSize:u,itemsPerRow:s}}(c,n,a):{}},getScrollOffset:function(e){var t=e.outerContainer,r=e.props.axis,n=e.scrollParent;if(!t||!n)return 0;var o=W[r],i=n===window?document.body[o]||document.documentElement[o]:n[o],a=function(e,t){return e===window?Math.max(document.body[U[t]],document.documentElement[U[t]]):e[U[t]]}(n,r)-ge(n,r),u=Math.max(0,Math.min(i,a));return ye(n,r)+u-ye(t,r)},getScrollParent:function(e){var t=e.outerContainer,r=e.props,n=r.axis,o=r.getScrollParent;if(pe(o))return o();if(!t)return null;for(var i=V[n],a=t;a=a.parentElement;)if(~_.indexOf(window.getComputedStyle(a)[i]))return a;return window},getSizeOfListItem:function(e,t){var r=e.cache,n=e.items,o=e.props,i=o.axis,a=o.getEstimatedItemSize,u=o.getItemSize,c=o.type,f=e.state,s=f.from,l=f.itemSize,p=f.size,d=t[0];if(l)return l;if(pe(u))return u(d);if(de(r[d]))return r[d];if(n){var m=n.children;if(m.length&&c===X.SIMPLE&&d>=s&&d<s+p){var v=m[d-s];if(v)return v[F[i]]}}return pe(a)?a(d,r):void 0},getSpaceBefore:function(e,t){var r=e.getSizeOfListItem,n=e.state,o=n.itemSize,i=n.itemsPerRow,a=t[0],u=t[1],c=void 0===u?{}:u;return de(c[a])?c[a]:(c[a]=o?Math.floor(a/i)*o:function(e,t,r){for(var n=t;n>0&&!de(e[n]);)--n;for(var o=ve(e[n]),i=void 0,a=n;a<t&&(e[a]=o,i=r(a),de(i));a++)o+=i;return o}(c,a,r),c[a])},getStartAndEnd:function(e,t){var r=e.getScrollOffset,n=e.getSpaceBefore,o=e.props,i=o.axis,a=o.getItemSize,u=o.length,c=o.threshold,f=o.type,s=e.scrollParent,l=t[0],p=void 0===l?c:l,d=r(),m=d+ge(s,i)+p;return{end:function(e,t){return e===X.UNIFORM||pe(t)}(f,a)?Math.min(m,n(u)):m,start:Math.max(0,d-p)}},getVisibleRange:function(e){for(var t=e.getSizeOfListItem,r=e.getSpaceBefore,n=e.getStartAndEnd,o=e.state,i=o.from,a=o.size,u=n(0),c=u.end,f=u.start,s={},l=i+a,p=void 0,d=void 0,m=void 0,v=void 0,y=i;y<l;y++)v=(m=r(y,s))+t(y),de(p)?m<c&&(d=y):v>f&&(p=y);return[p,d]},renderItems:function(e){for(var t=e.props,n=t.itemRenderer,o=t.containerRenderer,i=e.state,a=i.from,u=i.size,c=new Array(u),f=0;f<u;f++)c[f]=n(a+f,f);return o(c,function(t){return e.items=r.findDOMNode(t)})},scrollAround:function(e,t){var r=e.getScrollOffset,n=e.getSizeOfListItem,o=e.getSpaceBefore,i=e.getViewportSize,a=e.setScroll,u=t[0],c=o(u),f=c-i()+n(u),s=Math.min(f,c),l=r();if(l<=s)return a(s);var p=Math.max(f,c);return l>p?a(p):void 0},scrollTo:function(e,t){var r=e.getSpaceBefore,n=e.props.initialIndex,o=e.setScroll,i=t[0],a=de(i)?i:n;de(a)&&o(r(a))},setReconcileFrameAfterUpdate:function(e){var t=e.props.debounceReconciler;e.reconcileFrameAfterUpdate=de(t)?Z(function(e){e()},t):se},setScroll:function(e,t){var r=e.outerContainer,n=e.props.axis,o=e.scrollParent,i=t[0];if(o&&r){var a=i+ye(r,n);if(o===window)return window.scrollTo(0,a);o[W[n]]=a-ye(o,n)}},setStateIfAppropriate:function(e,t){var r=e.setState,n=e.state,o=t[0],i=t[1];return function(e,t){for(var r in t)if(e[r]!==t[r])return!1;return!0}(n,o)?i():r(o,i)},updateFrame:function(e,t){var r=e.props.type,n=e.updateScrollParent,o=e.updateSimpleFrame,i=e.updateUniformFrame,a=e.updateVariableFrame,u=t[0];n();var c=pe(u)?u:me;return r===X.UNIFORM?i(c):r===X.VARIABLE?a(c):o(c)},updateScrollParent:function(e){var t=e.getScrollParent,r=e.scrollParent,n=e.updateFrame,o=t();o!==r&&(r&&(r.removeEventListener("scroll",n),r.removeEventListener("mousewheel",me)),e.scrollParent=o,o&&(o.addEventListener("scroll",n,N),o.addEventListener("mousewheel",me,N)))},updateSimpleFrame:function(e,t){var r=e.getStartAndEnd,n=e.items,o=e.props,i=e.setStateIfAppropriate,a=e.state.size,u=t[0];return n&&function(e,t){var r=t.axis;if(!e.length)return 0;var n=e[0],o=e[e.length-1];return ye(o,r)+o[F[r]]-ye(n,r)}(n.children,o)<=r().end?i({size:Math.min(a+o.pageSize,o.length)},u):u()},updateUniformFrame:function(e,t){var r=e.getItemSizeAndItemsPerRow,n=e.getStartAndEnd,o=e.props,i=e.setStateIfAppropriate,a=t[0],u=r(),c=u.itemSize,f=u.itemsPerRow;if(!c||!f)return a();var s=n(),l=s.start,p=s.end,d=Math.floor(l/c)*f,m=(Math.ceil((p-l)/c)+1)*f,v=he(d,m,f,o);return i(be({},v,{itemSize:c,itemsPerRow:f}),a)},updateVariableFrame:function(e,t){var r=e.cache,n=e.items,o=e.getSizeOfListItem,i=e.getStartAndEnd,a=e.props,u=e.setStateIfAppropriate,c=e.state,f=c.from,s=c.size,l=t[0];n&&(a.getItemSize||function(e,t,r,n){for(var o=t.children,i=F[r],a=0;a<o.length;a++)n[e+a]=o[a][i]}(f,n,a.axis,r),u(function(e,t,r,n){for(var o=e.end,i=e.start,a=t.length,u=t.pageSize,c=a-1,f=0,s=0,l=-1,p=void 0;s<c;s++){if(p=r(s),!de(p)||f+p>i){1===s&&(s=0);break}f+=p}for(var d=a-s;++l<d&&f<o;){if(p=r(s+l),!de(p)){l=Math.min(l+u,d);break}f+=p}return f?{from:s,size:l}:n}(i(),a,o,{from:f,size:s}),l))}},Pe=h(function(e,r){var n=e.axis,o=e.length,i=e.type,a=e.usePosition,u=e.useTranslate3d,c=r.getSpaceBefore,f=r.renderItems,s=r.state,l=s.from,p=s.itemsPerRow;return i===X.SIMPLE?f():t.createElement("div",{style:$},t.createElement("div",{style:function(e,t,r,n){var o,i,a=n(Math.ceil(t/r)*r,{});if(!a)return G;var u=B[e];return le({},G,e!==H.X?((o={})[u]=a,o):((i={})[u]=a,i.overflowX="hidden",i))}(n,o,p,c)},t.createElement("div",{style:function(e,t,r,n,o){var i=o(n,{}),a=e===H.X?i:0,u=e===H.Y?i:0;if(t)return{left:a,position:"relative",top:u};var c=r?"translate3d("+a+"px, "+u+"px, 0)":"translate("+a+"px, "+u+"px)";return{msTransform:c,WebkitTransform:c,transform:c}}(n,a,u,l,c)},f())))},Oe({},Se,K?{getSnapshotBeforeUpdate:function(e,t){var r=e.props.debounceReconciler,n=e.setReconcileFrameAfterUpdate;return r!==t[0].debounceReconciler&&n()}}:{componentWillReceiveProps:function(e,t){var r=e.props.debounceReconciler,n=e.setReconcileFrameAfterUpdate,o=e.setStateIfAppropriate,i=e.state,a=i.from,u=i.itemsPerRow,c=i.size,f=t[0];r!==f.debounceReconciler&&n(),o(he(a,c,u,f),me)}}));Pe.displayName="WindowedListRenderer",Pe.propTypes={axis:M.oneOf(Y).isRequired,containerRenderer:M.func.isRequired,debounceReconciler:M.number,getEstimatedItemSize:M.func,getItemSize:M.func,getScrollParent:M.func,initialIndex:M.number.isRequired,isHidden:M.bool.isRequired,isLazy:M.bool.isRequired,itemRenderer:M.func.isRequired,length:M.number.isRequired,pageSize:M.number.isRequired,threshold:M.number.isRequired,type:M.oneOf(J).isRequired,usePosition:M.bool.isRequired,useStaticSize:M.bool.isRequired,useTranslate3d:M.bool.isRequired},Pe.defaultProps={axis:H.Y,containerRenderer:function(e,r){return t.createElement("div",{ref:r},e)},initialIndex:0,isHidden:!1,isLazy:!1,itemRenderer:function(e,r){return t.createElement("div",{key:r},e)},length:0,minSize:1,pageSize:10,threshold:100,type:X.SIMPLE,usePosition:!1,useStaticSize:!1,useTranslate3d:!1},K&&(Pe.getDerivedStateFromProps=function(e,t){var r=t.from,n=t.itemsPerRow,o=t.size,i=he(r,o,n,e);return i.from===r&&i.size===o?null:i});var Re=n.measure(["height","width"],{namespace:"__windowedListMeasurements"})(Pe),xe=Object.assign||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},Ie=function(e,r){return t.createElement(Re,xe({},e,{ref:p(r,"ref")}))};Ie.displayName="WindowedList";var Ee=h(Ie,{ref:null,getVisibleRange:function(e){var t=e.ref;return t&&t.originalComponent?t.originalComponent.getVisibleRange():[0,0]},scrollAround:function(e,t){var r=e.ref,n=t[0];return r&&r.originalComponent?r.originalComponent.scrollAround(n):null},scrollTo:function(e,t){var r=e.ref,n=t[0];return r&&r.originalComponent?r.originalComponent.scrollTo(n):null}});e.default=Ee,Object.defineProperty(e,"__esModule",{value:!0})});