@jingoz/react-virtual-list
Version:
32 lines (29 loc) • 12.4 kB
JavaScript
(function(m,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],E):(m=typeof globalThis<"u"?globalThis:m||self,E(m["react-virtual-list"]={},m.require$$0))})(this,function(m,E){"use strict";var I={exports:{}},C={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var Q;function Re(){if(Q)return C;Q=1;var u=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function v(c,s,l){var g=null;if(l!==void 0&&(g=""+l),s.key!==void 0&&(g=""+s.key),"key"in s){l={};for(var x in s)x!=="key"&&(l[x]=s[x])}else l=s;return s=l.ref,{$$typeof:u,type:c,key:g,ref:s!==void 0?s:null,props:l}}return C.Fragment=b,C.jsx=v,C.jsxs=v,C}var O={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ee;function ye(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Me?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case L:return"Fragment";case Ne:return"Portal";case le:return"Profiler";case ae:return"StrictMode";case J:return"Suspense";case X:return"SuspenseList"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case se:return(e.displayName||"Context")+".Provider";case ue:return(e._context.displayName||"Context")+".Consumer";case z:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case B:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case $:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function b(e){return""+e}function v(e){try{b(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),b(e)}}function c(){}function s(){if(Y===0){fe=console.log,de=console.info,Ee=console.warn,ve=console.error,me=console.group,be=console.groupCollapsed,ge=console.groupEnd;var e={configurable:!0,enumerable:!0,value:c,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}function l(){if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:y({},e,{value:fe}),info:y({},e,{value:de}),warn:y({},e,{value:Ee}),error:y({},e,{value:ve}),group:y({},e,{value:me}),groupCollapsed:y({},e,{value:be}),groupEnd:y({},e,{value:ge})})}0>Y&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function g(e){if(D===void 0)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);D=r&&r[1]||"",Te=-1<t.stack.indexOf(`
at`)?" (<anonymous>)":-1<t.stack.indexOf("@")?"@unknown:0:0":""}return`
`+D+e+Te}function x(e,r){if(!e||Z)return"";var t=K.get(e);if(t!==void 0)return t;Z=!0,t=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var n=null;n=R.H,R.H=null,s();try{var i={DetermineComponentFrameRoot:function(){try{if(r){var p=function(){throw Error()};if(Object.defineProperty(p.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(p,[])}catch(h){var G=h}Reflect.construct(e,[],p)}else{try{p.call()}catch(h){G=h}e.call(p.prototype)}}else{try{throw Error()}catch(h){G=h}(p=e())&&typeof p.catch=="function"&&p.catch(function(){})}}catch(h){if(h&&G&&typeof h.stack=="string")return[h.stack,G.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var a=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");a&&a.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=i.DetermineComponentFrameRoot(),_=o[0],w=o[1];if(_&&w){var d=_.split(`
`),S=w.split(`
`);for(o=a=0;a<d.length&&!d[a].includes("DetermineComponentFrameRoot");)a++;for(;o<S.length&&!S[o].includes("DetermineComponentFrameRoot");)o++;if(a===d.length||o===S.length)for(a=d.length-1,o=S.length-1;1<=a&&0<=o&&d[a]!==S[o];)o--;for(;1<=a&&0<=o;a--,o--)if(d[a]!==S[o]){if(a!==1||o!==1)do if(a--,o--,0>o||d[a]!==S[o]){var W=`
`+d[a].replace(" at new "," at ");return e.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",e.displayName)),typeof e=="function"&&K.set(e,W),W}while(1<=a&&0<=o);break}}}finally{Z=!1,R.H=n,l(),Error.prepareStackTrace=t}return d=(d=e?e.displayName||e.name:"")?g(d):"",typeof e=="function"&&K.set(e,d),d}function T(e){if(e==null)return"";if(typeof e=="function"){var r=e.prototype;return x(e,!(!r||!r.isReactComponent))}if(typeof e=="string")return g(e);switch(e){case J:return g("Suspense");case X:return g("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case z:return e=x(e.render,!1),e;case B:return T(e.type);case $:r=e._payload,e=e._init;try{return T(e(r))}catch{}}return""}function N(){var e=R.A;return e===null?null:e.getOwner()}function V(e){if(ce.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function F(e,r){function t(){_e||(_e=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function j(){var e=u(this.type);return he[e]||(he[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function P(e,r,t,n,i,a){return t=a.ref,e={$$typeof:H,type:e,key:r,props:a,_owner:i},(t!==void 0?t:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:j}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function M(e,r,t,n,i,a){if(typeof e=="string"||typeof e=="function"||e===L||e===le||e===ae||e===J||e===X||e===Pe||typeof e=="object"&&e!==null&&(e.$$typeof===$||e.$$typeof===B||e.$$typeof===se||e.$$typeof===ue||e.$$typeof===z||e.$$typeof===Ye||e.getModuleId!==void 0)){var o=r.children;if(o!==void 0)if(n)if(q(o)){for(n=0;n<o.length;n++)U(o[n],e);Object.freeze&&Object.freeze(o)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else U(o,e)}else o="",(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(o+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),e===null?n="null":q(e)?n="array":e!==void 0&&e.$$typeof===H?(n="<"+(u(e.type)||"Unknown")+" />",o=" Did you accidentally export a JSX literal instead of a component?"):n=typeof e,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",n,o);if(ce.call(r,"key")){o=u(e);var _=Object.keys(r).filter(function(d){return d!=="key"});n=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",xe[o+n]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,n,o,_,o),xe[o+n]=!0)}if(o=null,t!==void 0&&(v(t),o=""+t),V(r)&&(v(r.key),o=""+r.key),"key"in r){t={};for(var w in r)w!=="key"&&(t[w]=r[w])}else t=r;return o&&F(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),P(e,o,a,i,N(),t)}function U(e,r){if(typeof e=="object"&&e&&e.$$typeof!==We){if(q(e))for(var t=0;t<e.length;t++){var n=e[t];f(n)&&A(n,r)}else if(f(e))e._store&&(e._store.validated=1);else if(e===null||typeof e!="object"?t=null:(t=ie&&e[ie]||e["@@iterator"],t=typeof t=="function"?t:null),typeof t=="function"&&t!==e.entries&&(t=t.call(e),t!==e))for(;!(e=t.next()).done;)f(e.value)&&A(e.value,r)}}function f(e){return typeof e=="object"&&e!==null&&e.$$typeof===H}function A(e,r){if(e._store&&!e._store.validated&&e.key==null&&(e._store.validated=1,r=Oe(r),!pe[r])){pe[r]=!0;var t="";e&&e._owner!=null&&e._owner!==N()&&(t=null,typeof e._owner.tag=="number"?t=u(e._owner.type):typeof e._owner.name=="string"&&(t=e._owner.name),t=" It was passed a child from "+t+".");var n=R.getCurrentStack;R.getCurrentStack=function(){var i=T(e.type);return n&&(i+=n()||""),i},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',r,t),R.getCurrentStack=n}}function Oe(e){var r="",t=N();return t&&(t=u(t.type))&&(r=`
Check the render method of \``+t+"`."),r||(e=u(e))&&(r=`
Check the top-level render call using <`+e+">."),r}var ke=E,H=Symbol.for("react.transitional.element"),Ne=Symbol.for("react.portal"),L=Symbol.for("react.fragment"),ae=Symbol.for("react.strict_mode"),le=Symbol.for("react.profiler"),ue=Symbol.for("react.consumer"),se=Symbol.for("react.context"),z=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),Pe=Symbol.for("react.offscreen"),ie=Symbol.iterator,Me=Symbol.for("react.client.reference"),R=ke.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ce=Object.prototype.hasOwnProperty,y=Object.assign,Ye=Symbol.for("react.client.reference"),q=Array.isArray,Y=0,fe,de,Ee,ve,me,be,ge;c.__reactDisabledLog=!0;var D,Te,Z=!1,K=new(typeof WeakMap=="function"?WeakMap:Map),We=Symbol.for("react.client.reference"),_e,he={},xe={},pe={};O.Fragment=L,O.jsx=function(e,r,t,n,i){return M(e,r,t,!1,n,i)},O.jsxs=function(e,r,t,n,i){return M(e,r,t,!0,n,i)}}()),O}var re;function Se(){return re||(re=1,process.env.NODE_ENV==="production"?I.exports=Re():I.exports=ye()),I.exports}var k=Se();function je({children:u}){const[b,v]=E.useState({width:0,height:0}),c=E.useRef(null);return E.useLayoutEffect(()=>{if(!c.current)return;const{width:s,height:l}=c.current.getBoundingClientRect();v({width:s,height:l})},[]),k.jsx("div",{ref:c,style:{width:"100%",height:"100%"},children:u(b)})}function Ae({index:u,offset:b,rowHeight:v,children:c}){return k.jsx("div",{style:{position:"absolute",width:"100%",height:v,top:b},children:c?c(u):null})}const we="react-virtual-list-fixed-height-item",Ce=E.forwardRef(function({className:u="",style:b={},total:v=0,viewHeight:c=te,padding:s=ne,rowHeight:l=oe,children:g},x){const T=E.useRef(null),[N,V]=E.useState(0),F=Math.max(v*l,c);let j=Math.floor(N/l),P=Math.ceil(c/l)+j;j=Math.max(j-s,0),P=Math.min(P+s,v-1);const M=[];for(let f=j;f<P;f++)M.push(k.jsx(Ae,{index:f,offset:f*l,rowHeight:l,children:g},`${we}-${f}`));const U=f=>{const A=f.currentTarget.scrollTop;requestAnimationFrame(()=>{V(A)})};return E.useImperativeHandle(x,()=>({scrollToViaIndex:f=>{const A=f*l;T.current&&T.current.scrollTo({top:A})},scrollToViaScrollTop:f=>{T.current&&T.current.scrollTo({top:f})}})),k.jsx("div",{ref:T,className:`virtual-list-viewer ${u}`,style:{...b,height:c,overflowY:"auto"},onScroll:U,children:k.jsx("div",{className:"virtual-list-container",style:{position:"relative",height:F},children:M})})}),te=300,oe=40,ne=3;m.AutoSizer=je,m.DEFAULT_PADDING=ne,m.DEFAULT_ROW_HEIGHT=oe,m.DEFAULT_VIEW_HEIGHT=te,m.FixedHeightVirtualList=Ce,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})});