UNPKG

react-stablelist

Version:

A simple listview component for ReactJS that implements the concept of virtualization for effieciently rendering a huge dataset.

14 lines 24.7 kB
module.exports=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,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},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,n){t.exports=n(12)()},function(t,e,n){"use strict";t.exports=n(14)},function(t,e){function n(){return t.exports=n=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},n.apply(this,arguments)}t.exports=n},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(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)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e,n){var r=n(9);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}},function(t,e,n){var r=n(10),o=n(11);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?o(t):e}},,function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,r)}t.exports=n},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e,n){"use strict";var r=n(13);function o(){}function i(){}i.resetWarningCache=o,t.exports=function(){function t(t,e,n,o,i,c){if(c!==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 e(){return t}t.isRequired=t;var n={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:e,element:t,elementType:t,instanceOf:e,node:t,objectOf:e,oneOf:e,oneOfType:e,shape:e,exact:e,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},function(t,e,n){"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,e,n){"use strict"; /** @license React v16.13.1 * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var r=n(15),o="function"==typeof Symbol&&Symbol.for,i=o?Symbol.for("react.element"):60103,c=o?Symbol.for("react.portal"):60106,a=o?Symbol.for("react.fragment"):60107,u=o?Symbol.for("react.strict_mode"):60108,s=o?Symbol.for("react.profiler"):60114,l=o?Symbol.for("react.provider"):60109,p=o?Symbol.for("react.context"):60110,f=o?Symbol.for("react.forward_ref"):60112,h=o?Symbol.for("react.suspense"):60113,d=o?Symbol.for("react.memo"):60115,m=o?Symbol.for("react.lazy"):60116,y="function"==typeof Symbol&&Symbol.iterator;function v(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var _={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b={};function g(t,e,n){this.props=t,this.context=e,this.refs=b,this.updater=n||_}function S(){}function C(t,e,n){this.props=t,this.context=e,this.refs=b,this.updater=n||_}g.prototype.isReactComponent={},g.prototype.setState=function(t,e){if("object"!=typeof t&&"function"!=typeof t&&null!=t)throw Error(v(85));this.updater.enqueueSetState(this,t,e,"setState")},g.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")},S.prototype=g.prototype;var x=C.prototype=new S;x.constructor=C,r(x,g.prototype),x.isPureReactComponent=!0;var O={current:null},w=Object.prototype.hasOwnProperty,j={key:!0,ref:!0,__self:!0,__source:!0};function R(t,e,n){var r,o={},c=null,a=null;if(null!=e)for(r in void 0!==e.ref&&(a=e.ref),void 0!==e.key&&(c=""+e.key),e)w.call(e,r)&&!j.hasOwnProperty(r)&&(o[r]=e[r]);var u=arguments.length-2;if(1===u)o.children=n;else if(1<u){for(var s=Array(u),l=0;l<u;l++)s[l]=arguments[l+2];o.children=s}if(t&&t.defaultProps)for(r in u=t.defaultProps)void 0===o[r]&&(o[r]=u[r]);return{$$typeof:i,type:t,key:c,ref:a,props:o,_owner:O.current}}function B(t){return"object"==typeof t&&null!==t&&t.$$typeof===i}var E=/\/+/g,T=[];function k(t,e,n,r){if(T.length){var o=T.pop();return o.result=t,o.keyPrefix=e,o.func=n,o.context=r,o.count=0,o}return{result:t,keyPrefix:e,func:n,context:r,count:0}}function I(t){t.result=null,t.keyPrefix=null,t.func=null,t.context=null,t.count=0,10>T.length&&T.push(t)}function P(t,e,n){return null==t?0:function t(e,n,r,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var u=!1;if(null===e)u=!0;else switch(a){case"string":case"number":u=!0;break;case"object":switch(e.$$typeof){case i:case c:u=!0}}if(u)return r(o,e,""===n?"."+U(e,0):n),1;if(u=0,n=""===n?".":n+":",Array.isArray(e))for(var s=0;s<e.length;s++){var l=n+U(a=e[s],s);u+=t(a,l,r,o)}else if(null===e||"object"!=typeof e?l=null:l="function"==typeof(l=y&&e[y]||e["@@iterator"])?l:null,"function"==typeof l)for(e=l.call(e),s=0;!(a=e.next()).done;)u+=t(a=a.value,l=n+U(a,s++),r,o);else if("object"===a)throw r=""+e,Error(v(31,"[object Object]"===r?"object with keys {"+Object.keys(e).join(", ")+"}":r,""));return u}(t,"",e,n)}function U(t,e){return"object"==typeof t&&null!==t&&null!=t.key?function(t){var e={"=":"=0",":":"=2"};return"$"+(""+t).replace(/[=:]/g,(function(t){return e[t]}))}(t.key):e.toString(36)}function $(t,e){t.func.call(t.context,e,t.count++)}function A(t,e,n){var r=t.result,o=t.keyPrefix;t=t.func.call(t.context,e,t.count++),Array.isArray(t)?M(t,r,n,(function(t){return t})):null!=t&&(B(t)&&(t=function(t,e){return{$$typeof:i,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}(t,o+(!t.key||e&&e.key===t.key?"":(""+t.key).replace(E,"$&/")+"/")+n)),r.push(t))}function M(t,e,n,r,o){var i="";null!=n&&(i=(""+n).replace(E,"$&/")+"/"),P(t,A,e=k(e,i,r,o)),I(e)}var N={current:null};function V(){var t=N.current;if(null===t)throw Error(v(321));return t}var q={ReactCurrentDispatcher:N,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:O,IsSomeRendererActing:{current:!1},assign:r};e.Children={map:function(t,e,n){if(null==t)return t;var r=[];return M(t,r,null,e,n),r},forEach:function(t,e,n){if(null==t)return t;P(t,$,e=k(null,null,e,n)),I(e)},count:function(t){return P(t,(function(){return null}),null)},toArray:function(t){var e=[];return M(t,e,null,(function(t){return t})),e},only:function(t){if(!B(t))throw Error(v(143));return t}},e.Component=g,e.Fragment=a,e.Profiler=s,e.PureComponent=C,e.StrictMode=u,e.Suspense=h,e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=q,e.cloneElement=function(t,e,n){if(null==t)throw Error(v(267,t));var o=r({},t.props),c=t.key,a=t.ref,u=t._owner;if(null!=e){if(void 0!==e.ref&&(a=e.ref,u=O.current),void 0!==e.key&&(c=""+e.key),t.type&&t.type.defaultProps)var s=t.type.defaultProps;for(l in e)w.call(e,l)&&!j.hasOwnProperty(l)&&(o[l]=void 0===e[l]&&void 0!==s?s[l]:e[l])}var l=arguments.length-2;if(1===l)o.children=n;else if(1<l){s=Array(l);for(var p=0;p<l;p++)s[p]=arguments[p+2];o.children=s}return{$$typeof:i,type:t.type,key:c,ref:a,props:o,_owner:u}},e.createContext=function(t,e){return void 0===e&&(e=null),(t={$$typeof:p,_calculateChangedBits:e,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:l,_context:t},t.Consumer=t},e.createElement=R,e.createFactory=function(t){var e=R.bind(null,t);return e.type=t,e},e.createRef=function(){return{current:null}},e.forwardRef=function(t){return{$$typeof:f,render:t}},e.isValidElement=B,e.lazy=function(t){return{$$typeof:m,_ctor:t,_status:-1,_result:null}},e.memo=function(t,e){return{$$typeof:d,type:t,compare:void 0===e?null:e}},e.useCallback=function(t,e){return V().useCallback(t,e)},e.useContext=function(t,e){return V().useContext(t,e)},e.useDebugValue=function(){},e.useEffect=function(t,e){return V().useEffect(t,e)},e.useImperativeHandle=function(t,e,n){return V().useImperativeHandle(t,e,n)},e.useLayoutEffect=function(t,e){return V().useLayoutEffect(t,e)},e.useMemo=function(t,e){return V().useMemo(t,e)},e.useReducer=function(t,e,n){return V().useReducer(t,e,n)},e.useRef=function(t){return V().useRef(t)},e.useState=function(t){return V().useState(t)},e.version="16.13.1"},function(t,e,n){"use strict"; /* object-assign (c) Sindre Sorhus @license MIT */var r=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;function c(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},n=0;n<10;n++)e["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(e).map((function(t){return e[t]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(t){r[t]=t})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(t){return!1}}()?Object.assign:function(t,e){for(var n,a,u=c(t),s=1;s<arguments.length;s++){for(var l in n=Object(arguments[s]))o.call(n,l)&&(u[l]=n[l]);if(r){a=r(n);for(var p=0;p<a.length;p++)i.call(n,a[p])&&(u[a[p]]=n[a[p]])}}return u}},function(t,e,n){var r=n(17),o=n(18);"string"==typeof(o=o.__esModule?o.default:o)&&(o=[[t.i,o,""]]);var i={insert:"head",singleton:!1};r(o,i);t.exports=o.locals||{}},function(t,e,n){"use strict";var r,o=function(){return void 0===r&&(r=Boolean(window&&document&&document.all&&!window.atob)),r},i=function(){var t={};return function(e){if(void 0===t[e]){var n=document.querySelector(e);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}t[e]=n}return t[e]}}(),c=[];function a(t){for(var e=-1,n=0;n<c.length;n++)if(c[n].identifier===t){e=n;break}return e}function u(t,e){for(var n={},r=[],o=0;o<t.length;o++){var i=t[o],u=e.base?i[0]+e.base:i[0],s=n[u]||0,l="".concat(u," ").concat(s);n[u]=s+1;var p=a(l),f={css:i[1],media:i[2],sourceMap:i[3]};-1!==p?(c[p].references++,c[p].updater(f)):c.push({identifier:l,updater:y(f,e),references:1}),r.push(l)}return r}function s(t){var e=document.createElement("style"),r=t.attributes||{};if(void 0===r.nonce){var o=n.nc;o&&(r.nonce=o)}if(Object.keys(r).forEach((function(t){e.setAttribute(t,r[t])})),"function"==typeof t.insert)t.insert(e);else{var c=i(t.insert||"head");if(!c)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");c.appendChild(e)}return e}var l,p=(l=[],function(t,e){return l[t]=e,l.filter(Boolean).join("\n")});function f(t,e,n,r){var o=n?"":r.media?"@media ".concat(r.media," {").concat(r.css,"}"):r.css;if(t.styleSheet)t.styleSheet.cssText=p(e,o);else{var i=document.createTextNode(o),c=t.childNodes;c[e]&&t.removeChild(c[e]),c.length?t.insertBefore(i,c[e]):t.appendChild(i)}}function h(t,e,n){var r=n.css,o=n.media,i=n.sourceMap;if(o?t.setAttribute("media",o):t.removeAttribute("media"),i&&btoa&&(r+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleSheet)t.styleSheet.cssText=r;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(r))}}var d=null,m=0;function y(t,e){var n,r,o;if(e.singleton){var i=m++;n=d||(d=s(e)),r=f.bind(null,n,i,!1),o=f.bind(null,n,i,!0)}else n=s(e),r=h.bind(null,n,e),o=function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(n)};return r(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap)return;r(t=e)}else o()}}t.exports=function(t,e){(e=e||{}).singleton||"boolean"==typeof e.singleton||(e.singleton=o());var n=u(t=t||[],e);return function(t){if(t=t||[],"[object Array]"===Object.prototype.toString.call(t)){for(var r=0;r<n.length;r++){var o=a(n[r]);c[o].references--}for(var i=u(t,e),s=0;s<n.length;s++){var l=a(n[s]);0===c[l].references&&(c[l].updater(),c.splice(l,1))}n=i}}}},function(t,e,n){(e=n(19)(!1)).push([t.i,".list-root{height:auto;max-height:100%;overflow:auto}.list-root>.scrolling-container{min-height:100%;scrollbar-width:0;scrollbar-width:none}.list-root.horizontal-scroll{display:flex}.list-root.horizontal-scroll>.scrolling-container{display:flex}.list-root.horizontal-scroll>.scrolling-container>*{flex:1 0 auto;margin:0 10px}\n",""]),t.exports=e},function(t,e,n){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n=function(t,e){var n=t[1]||"",r=t[3];if(!r)return n;if(e&&"function"==typeof btoa){var o=(c=r,a=btoa(unescape(encodeURIComponent(JSON.stringify(c)))),u="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(a),"/*# ".concat(u," */")),i=r.sources.map((function(t){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(t," */")}));return[n].concat(i).concat([o]).join("\n")}var c,a,u;return[n].join("\n")}(e,t);return e[2]?"@media ".concat(e[2]," {").concat(n,"}"):n})).join("")},e.i=function(t,n,r){"string"==typeof t&&(t=[[null,t,""]]);var o={};if(r)for(var i=0;i<this.length;i++){var c=this[i][0];null!=c&&(o[c]=!0)}for(var a=0;a<t.length;a++){var u=[].concat(t[a]);r&&o[u[0]]||(n&&(u[2]?u[2]="".concat(n," and ").concat(u[2]):u[2]=n),e.push(u))}},e}},function(t,e,n){"use strict";n.r(e);var r=n(2),o=n.n(r),i=n(3),c=n.n(i),a=n(4),u=n.n(a),s=n(6),l=n.n(s),p=n(7),f=n.n(p),h=n(5),d=n.n(h);function m(t){var e,n,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t))for(e=0;e<t.length;e++)t[e]&&(n=m(t[e]))&&(r&&(r+=" "),r+=n);else for(e in t)t[e]&&(r&&(r+=" "),r+=e);return r}var y=function(){for(var t,e,n=0,r="";n<arguments.length;)(t=arguments[n++])&&(e=m(t))&&(r&&(r+=" "),r+=e);return r},v=n(0),_=n.n(v),b="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),g=new Uint8Array(16);function S(){if(!b)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return b(g)}for(var C=[],x=0;x<256;++x)C.push((x+256).toString(16).substr(1));var O=function(t,e){var n=e||0,r=C;return(r[t[n+0]]+r[t[n+1]]+r[t[n+2]]+r[t[n+3]]+"-"+r[t[n+4]]+r[t[n+5]]+"-"+r[t[n+6]]+r[t[n+7]]+"-"+r[t[n+8]]+r[t[n+9]]+"-"+r[t[n+10]]+r[t[n+11]]+r[t[n+12]]+r[t[n+13]]+r[t[n+14]]+r[t[n+15]]).toLowerCase()};var w=function(t,e,n){"string"==typeof t&&(e="binary"===t?new Uint8Array(16):null,t=null);var r=(t=t||{}).random||(t.rng||S)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){for(var o=n||0,i=0;i<16;++i)e[o+i]=r[i];return e}return O(r)},j=n(1),R=n.n(j),B=(n(16),function(){function t(e,n){var r=this,i=e.component,a=e.propProvider,u=e.data;c()(this,t),this.computeBatches=function(t){var e=t.itemCount,n=t.threshold,r=void 0===n?20:n,o=[],i=0,c=e<r?e:r,a=Math.floor(e/r);if(0==a)return[{start:i,end:c}];for(var u=0;u<a;++u,i=c,c+=r)o.push({start:i,end:c});return o[a-1].end=e,o},this.makeComponent=function(t,e,n){return R.a.createElement(r.component,o()({className:"history-item component-".concat(r._id," history-item-").concat(t)},r.propProvider(w(),t,e,n,r._data[t])))},this.makeComponents=function(t,e){for(var n=[],o=t;o<e;++o)n.push(r.makeComponent(o,!0,!0));return n},this.makeComponentBatch=function(t,e){for(var n=[],o=t[e],i=o.start,c=o.end,a=i;a<c;++a)n.push(r.makeComponent(a));return n},this.addComponents=function(t,e,n){return n?e.concat(t):t.concat(e)},this.updateComponents=function(t,e,n,o,i,c){var a=t;return n&&a.splice(o,i),a=r.addComponents(a,e,c)},this.updateBatchOfIndex=function(t,e,n,o,i){for(var c=[].concat(o),a=t[e],u=a.start,s=a.end,l=r.getElementIndex(u),p=r.getElementIndex(s-1),f=r.makeComponentBatch(t,e),h=l,d=0,m=s-u;h<=p&&d<m;++h,++d)c[h]=f[d];return c},this.isScrolledToBottom=function(t,e){return t?e.scrollWidth-e.scrollLeft-e.clientWidth<=1:e.scrollHeight-e.scrollTop-e.clientHeight<1},this.isScrolledToTop=function(t,e){return t?e.scrollLeft<=1:e.scrollTop<=1},this.getElementIndex=function(t){for(var e=document.querySelectorAll(".history-item.component-".concat(r._id)),n=0,o=e.length;n<o;++n)if(e[n].classList.contains("history-item-".concat(t)))return n;return-1},this._data=u,this.component=i,this.propProvider=a,this._id=n}return u()(t,[{key:"data",set:function(t){this._data=t}}]),t}());function E(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=d()(t);if(e){var o=d()(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return f()(this,n)}}var T=function(t){l()(n,t);var e=E(n);function n(t){var r;return c()(this,n),(r=e.call(this,t))._reconstruct=function(){r._compQueue=[],r._batches=r.util.computeBatches(r.props),r.util.data=r.props.data,r._currBatch=r.props.direction==r.directions.top?0:r._batches.length-1,r._currDecBatch=0,r._decrementVal=Math.floor(r.props.maxItems/r.props.threshold),r._didScrollUp=!1,r.setState({components:r.util.makeComponentBatch(r._batches,r._currBatch)})},r.hanldeScrolledToTop=function(){r._currBatch>=r._decrementVal&&(r._currDecBatch=r._currBatch-r._decrementVal,r._didScrollUp=!0,--r._currBatch,r.setState((function(t){return{components:r.util.updateComponents(t.components,r.util.makeComponentBatch(r._batches,r._currDecBatch),r.state.components.length>=r.props.maxItems,r.props.maxItems-r.props.threshold,r.state.components.length%r.props.threshold!=0?r.props.threshold+r._itemRemainder:r.props.threshold,!0)}})))},r.hanldeScrolledToBottom=function(){r._currBatch+=1,r.setState((function(t){return{components:r.util.updateComponents(t.components,r.util.makeComponentBatch(r._batches,r._currBatch),r.state.components.length>=r.props.maxItems,0,r.props.threshold,!1)}}))},r.handleScroll=function(){var t=r.util.isScrolledToTop(r.props.horizontalScrolling,r._containerElem),e=r.util.isScrolledToBottom(r.props.horizontalScrolling,r._containerElem);t&&0!=r._currBatch?r.hanldeScrolledToTop():e&&r._currBatch+1<r._batches.length&&r.hanldeScrolledToBottom()},r.hanldeScrolledToTop_inv=function(){--r._currBatch,r._didScrollUp=!0,r.setState((function(t){return{components:r.util.updateComponents(t.components,r.util.makeComponentBatch(r._batches,r._currBatch),r.state.components.length>=r.props.maxItems,r.props.maxItems-r.props.threshold,r.state.components.length%r.props.threshold!=0?r.props.threshold+r._itemRemainder:r.props.threshold,!0)}}))},r.hanldeScrolledToBottom_inv=function(){r._currBatch+r._decrementVal<=r._batches.length-1&&(r._currDecBatch=r._currBatch+r._decrementVal,++r._currBatch,r.setState((function(t){return{components:r.util.updateComponents(t.components,r.util.makeComponentBatch(r._batches,r._currDecBatch),r.state.components.length>=r.props.maxItems,0,r.props.threshold,!1)}})))},r.handleScroll_inv=function(){var t=r.util.isScrolledToTop(r.props.horizontalScrolling,r._containerElem),e=r.util.isScrolledToBottom(r.props.horizontalScrolling,r._containerElem);t&&r._currBatch-1>=0?r.hanldeScrolledToTop_inv():e&&r.hanldeScrolledToBottom_inv()},r.handleItemCountChange=function(t){var e=r.props.direction==r.directions.top&&r._currBatch==r._batches.length-1,n=r.props.direction==r.directions.bottom&&r._currBatch>=r._batches.length-r._decrementVal,o=r.props.itemCount-t;r._compQueue=r.util.makeComponents(o,r.props.itemCount),r._itemRemainder=r.props.itemCount%r.props.threshold,(e||n)&&(r._addedItem=!0,r._batches=r.util.computeBatches(r.props),r._currBatch=r._batches.length-1,r.util.data=r.props.data,r.setState((function(e){return{components:r.util.updateComponents(e.components,r._compQueue,r.state.components.length>=r.props.maxItems,0,t,!1)}}),(function(){r._compQueue=[]})))},r.updateAtIndex=function(t){if(!(t<0)){var e=r.util.getElementIndex(t),n=[].concat(r.state.components);n[e]=r.util.makeComponent(t),r.setState({components:n})}},r.updateBatchOfIndex=function(t){if(!(t<0)){var e=r._batches.findIndex((function(e){return t>=e.start&&t<=e.end}));r.setState((function(t){return{components:r.util.updateBatchOfIndex(r._batches,e,r.props.threshold,t.components,r._currBatch)}}))}},r._id=w(),r.util=new B(r.props,r._id),r._currBatch=0,r._decrementVal=0,r._currDecBatch=0,r._itemRemainder=0,r._addedItem=!1,r._didScrollUp=!1,r._batches=[],r._compQueue=[],r._container=Object(j.createRef)(),r._scrollingContainer=Object(j.createRef)(),r.state={components:[]},r.directions={top:"top",bottom:"bottom"},r}return u()(n,[{key:"componentDidMount",value:function(){var t=this;this._batches=this.util.computeBatches(this.props),this._currBatch=this.props.direction==this.directions.top?0:this._batches.length-1,this._decrementVal=Math.floor(this.props.maxItems/this.props.threshold),this._itemRemainder=this.props.itemCount%this.props.threshold,this._containerElem=this._container.current,this._containerElem&&this._containerElem.addEventListener("scroll",this.props.direction==this.directions.top?this.directions.top&&this.handleScroll:this.directions.bottom&&this.handleScroll_inv),this._scrollingContainerElem=this._scrollingContainer.current,this.setState({components:this.util.makeComponentBatch(this._batches,this._currBatch)},(function(){t.props.direction==t.directions.bottom&&(t._containerElem.scrollTop=t._containerElem.scrollHeight)})),this.props.innerRef&&(this.props.innerRef.current={updateAtIndex:this.updateAtIndex,updateBatchOfIndex:this.updateBatchOfIndex})}},{key:"componentDidUpdate",value:function(t){t.dataKey!=this.props.dataKey?this._reconstruct():this.props.itemCount!=t.itemCount?this.handleItemCountChange(this.props.itemCount-t.itemCount):this._didScrollUp?(this._didScrollUp=!1,this._containerElem.scrollTop=.2*this._scrollingContainerElem.scrollHeight):this._addedItem&&this.props.followNewItems&&(this._addedItem=!1,this._containerElem.scrollTo(0,this._scrollingContainerElem.scrollHeight))}},{key:"render",value:function(){return R.a.createElement("div",{className:y(this.props.className,"list-root",{"horizontal-scroll":this.props.horizontalScrolling}),ref:this._container,style:this.props.style},R.a.createElement("div",{className:"scrolling-container",ref:this._scrollingContainer},this.state.components))}}]),n}(j.PureComponent);T.propTypes={ref:_.a.func,data:_.a.array.isRequired,style:_.a.oneOfType([_.a.object,_.a.array]),dataKey:_.a.any.isRequired,innerRef:_.a.shape({current:_.a.any}),maxItems:_.a.number.isRequired,className:_.a.string,itemCount:_.a.number.isRequired,threshold:_.a.number.isRequired,component:_.a.elementType.isRequired,propProvider:_.a.func.isRequired,followNewItems:_.a.bool,horizontalScrolling:_.a.bool,direction:_.a.oneOf(["top","bottom"])},T.defaultProps={direction:"top",threshold:20,maxItems:60};var k=R.a.forwardRef((function(t,e){return R.a.createElement(T,o()({},t,{innerRef:e}))}));e.default=k}]);