virtuallist-react
Version:
This is a virtual list component based on react
1 lines • 8.84 kB
JavaScript
(()=>{"use strict";var e={268:function(e,t,r){function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t){return a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},a(e,t)}function c(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},u(e)}var l=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),s=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),f=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&l(t,e,r);return s(t,e),t};Object.defineProperty(t,"__esModule",{value:!0});var p=f(r(689)),d=r(62);r(726);var v=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&a(e,t)}(f,e);var t,r,n,l,s=(n=f,l=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=u(n);if(l){var r=u(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return c(this,e)});function f(){var e;return o(this,f),(e=s.apply(this,arguments)).state={start:0},e.scrollBox=null,e.handleScroll=function(){var t=e.props.options,r=t.itemHeight,n=t.bothAppend,o=t.dom,i=(o?o.current:e.scrollBox).scrollTop,a=Math.floor(i/r)-(n||0);e.setState({start:a})},e}return t=f,(r=[{key:"handleToScroll",value:function(e,t){this.scrollBox&&this.scrollBox.scrollTo({top:e*t,left:0,behavior:"smooth"})}},{key:"render",value:function(){var e=this,t=this.props.options,r=t.width,n=t.height,o=t.count,i=t.itemHeight,a=t.renderItem,c=t.itemWidth,u=t.loading,l=t.appendNum,s=t.delay,f=t.bothAppend,v=t.dom,h=window.innerHeight;n="string"==typeof n?h*(parseInt(n)/100):n;var y=this.state.start,m=y+Math.ceil(n/i)+(l||0)+(f?2*f:0);m=m>o?o:m;var b=new Array(m-y).fill(0).map((function(e,t){return{index:y+t}})),g={position:"absolute",left:0,width:c,height:i};return p.default.createElement("div",{className:"virtualList-container",style:{height:n,width:r},ref:function(t){e.scrollBox=t,v.current=t},onScroll:(0,d.debounce)(this.handleScroll,s)},p.default.createElement("div",{className:"virtualList-container-inner",style:{height:"".concat(o*i,"px")}},b.map((function(e){var t=e.index;return a({index:t,style:Object.assign(Object.assign({},g),{top:i*t})})})),p.default.createElement("div",{className:"virtualList-loading",style:{top:i*m}},u&&u)))}}])&&i(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),f}(p.Component);t.default=v},804:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var o=n(r(268));t.default=o.default},62:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0,t.debounce=function(e,t){var r;return function(){clearInterval(r),r=setTimeout((function(){e()}),t)}}},90:(e,t,r)=>{r.d(t,{Z:()=>c});var n=r(589),o=r.n(n),i=r(910),a=r.n(i)()(o());a.push([e.id,".virtualList-container {\r\n overflow: auto;\r\n will-change: transform;\r\n}\r\n.virtualList-container-inner {\r\n position: relative;\r\n width: 100%;\r\n min-height: 500px;\r\n}\r\n.virtualList-loading {\r\n position: absolute;\r\n left: 0;\r\n width: 100%;\r\n height: 100px;\r\n}\r\n",""]);const c=a},910:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r})).join("")},t.i=function(e,r,n,o,i){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(n)for(var c=0;c<this.length;c++){var u=this[c][0];null!=u&&(a[u]=!0)}for(var l=0;l<e.length;l++){var s=[].concat(e[l]);n&&a[s[0]]||(void 0!==i&&(void 0===s[5]||(s[1]="@layer".concat(s[5].length>0?" ".concat(s[5]):""," {").concat(s[1],"}")),s[5]=i),r&&(s[2]?(s[1]="@media ".concat(s[2]," {").concat(s[1],"}"),s[2]=r):s[2]=r),o&&(s[4]?(s[1]="@supports (".concat(s[4],") {").concat(s[1],"}"),s[4]=o):s[4]="".concat(o)),t.push(s))}},t}},589:e=>{e.exports=function(e){return e[1]}},726:(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var n=r(906),o=r.n(n),i=r(814),a=r.n(i),c=r(486),u=r.n(c),l=r(918),s=r.n(l),f=r(102),p=r.n(f),d=r(653),v=r.n(d),h=r(90),y={};y.styleTagTransform=v(),y.setAttributes=s(),y.insert=u().bind(null,"head"),y.domAPI=a(),y.insertStyleElement=p(),o()(h.Z,y);const m=h.Z&&h.Z.locals?h.Z.locals:void 0},906:e=>{var t=[];function r(e){for(var r=-1,n=0;n<t.length;n++)if(t[n].identifier===e){r=n;break}return r}function n(e,n){for(var i={},a=[],c=0;c<e.length;c++){var u=e[c],l=n.base?u[0]+n.base:u[0],s=i[l]||0,f="".concat(l," ").concat(s);i[l]=s+1;var p=r(f),d={css:u[1],media:u[2],sourceMap:u[3],supports:u[4],layer:u[5]};if(-1!==p)t[p].references++,t[p].updater(d);else{var v=o(d,n);n.byIndex=c,t.splice(c,0,{identifier:f,updater:v,references:1})}a.push(f)}return a}function o(e,t){var r=t.domAPI(t);return r.update(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap&&t.supports===e.supports&&t.layer===e.layer)return;r.update(e=t)}else r.remove()}}e.exports=function(e,o){var i=n(e=e||[],o=o||{});return function(e){e=e||[];for(var a=0;a<i.length;a++){var c=r(i[a]);t[c].references--}for(var u=n(e,o),l=0;l<i.length;l++){var s=r(i[l]);0===t[s].references&&(t[s].updater(),t.splice(s,1))}i=u}}},486:e=>{var t={};e.exports=function(e,r){var n=function(e){if(void 0===t[e]){var r=document.querySelector(e);if(window.HTMLIFrameElement&&r instanceof window.HTMLIFrameElement)try{r=r.contentDocument.head}catch(e){r=null}t[e]=r}return t[e]}(e);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");n.appendChild(r)}},102:e=>{e.exports=function(e){var t=document.createElement("style");return e.setAttributes(t,e.attributes),e.insert(t,e.options),t}},918:(e,t,r)=>{e.exports=function(e){var t=r.nc;t&&e.setAttribute("nonce",t)}},814:e=>{e.exports=function(e){var t=e.insertStyleElement(e);return{update:function(r){!function(e,t,r){var n="";r.supports&&(n+="@supports (".concat(r.supports,") {")),r.media&&(n+="@media ".concat(r.media," {"));var o=void 0!==r.layer;o&&(n+="@layer".concat(r.layer.length>0?" ".concat(r.layer):""," {")),n+=r.css,o&&(n+="}"),r.media&&(n+="}"),r.supports&&(n+="}");var i=r.sourceMap;i&&"undefined"!=typeof btoa&&(n+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(i))))," */")),t.styleTagTransform(n,e,t.options)}(t,e,r)},remove:function(){!function(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e)}(t)}}}},653:e=>{e.exports=function(e,t){if(t.styleSheet)t.styleSheet.cssText=e;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(e))}}},689:e=>{e.exports=require("react")}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n=r(804);module.exports=n})();