You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
12 KiB
1 line
12 KiB
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[73453],{73453:function(e,t,n){n.d(t,{Z:function(){return N}});var r=n(87462),o=n(4942),u=n(1413),i=n(97685),c=n(45987),a=n(67294),l=n(94184),s=n.n(l),f=n(48555),v=a.forwardRef((function(e,t){var n=e.height,i=e.offset,c=e.children,l=e.prefixCls,v=e.onInnerResize,h=e.innerProps,d={},p={display:"flex",flexDirection:"column"};return void 0!==i&&(d={height:n,position:"relative",overflow:"hidden"},p=(0,u.Z)((0,u.Z)({},p),{},{transform:"translateY(".concat(i,"px)"),position:"absolute",left:0,right:0,top:0})),a.createElement("div",{style:d},a.createElement(f.Z,{onResize:function(e){e.offsetHeight&&v&&v()}},a.createElement("div",(0,r.Z)({style:p,className:s()((0,o.Z)({},"".concat(l,"-holder-inner"),l)),ref:t},h),c)))}));v.displayName="Filler";var h=v,d=n(15671),p=n(43144),g=n(60136),m=n(51630),b=n(75164);function M(e){return"touches"in e?e.touches[0].pageY:e.pageY}var R=function(e){(0,g.Z)(n,e);var t=(0,m.Z)(n);function n(){var e;(0,d.Z)(this,n);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return(e=t.call.apply(t,[this].concat(o))).moveRaf=null,e.scrollbarRef=a.createRef(),e.thumbRef=a.createRef(),e.visibleTimeout=null,e.state={dragging:!1,pageY:null,startTop:null,visible:!1},e.delayHidden=function(){clearTimeout(e.visibleTimeout),e.setState({visible:!0}),e.visibleTimeout=setTimeout((function(){e.setState({visible:!1})}),2e3)},e.onScrollbarTouchStart=function(e){e.preventDefault()},e.onContainerMouseDown=function(e){e.stopPropagation(),e.preventDefault()},e.patchEvents=function(){window.addEventListener("mousemove",e.onMouseMove),window.addEventListener("mouseup",e.onMouseUp),e.thumbRef.current.addEventListener("touchmove",e.onMouseMove),e.thumbRef.current.addEventListener("touchend",e.onMouseUp)},e.removeEvents=function(){var t;window.removeEventListener("mousemove",e.onMouseMove),window.removeEventListener("mouseup",e.onMouseUp),null===(t=e.scrollbarRef.current)||void 0===t||t.removeEventListener("touchstart",e.onScrollbarTouchStart),e.thumbRef.current&&(e.thumbRef.current.removeEventListener("touchstart",e.onMouseDown),e.thumbRef.current.removeEventListener("touchmove",e.onMouseMove),e.thumbRef.current.removeEventListener("touchend",e.onMouseUp)),b.Z.cancel(e.moveRaf)},e.onMouseDown=function(t){var n=e.props.onStartMove;e.setState({dragging:!0,pageY:M(t),startTop:e.getTop()}),n(),e.patchEvents(),t.stopPropagation(),t.preventDefault()},e.onMouseMove=function(t){var n=e.state,r=n.dragging,o=n.pageY,u=n.startTop,i=e.props.onScroll;if(b.Z.cancel(e.moveRaf),r){var c=u+(M(t)-o),a=e.getEnableScrollRange(),l=e.getEnableHeightRange(),s=l?c/l:0,f=Math.ceil(s*a);e.moveRaf=(0,b.Z)((function(){i(f)}))}},e.onMouseUp=function(){var t=e.props.onStopMove;e.setState({dragging:!1}),t(),e.removeEvents()},e.getSpinHeight=function(){var t=e.props,n=t.height,r=n/t.count*10;return r=Math.max(r,20),r=Math.min(r,n/2),Math.floor(r)},e.getEnableScrollRange=function(){var t=e.props;return t.scrollHeight-t.height||0},e.getEnableHeightRange=function(){return e.props.height-e.getSpinHeight()||0},e.getTop=function(){var t=e.props.scrollTop,n=e.getEnableScrollRange(),r=e.getEnableHeightRange();return 0===t||0===n?0:t/n*r},e.showScroll=function(){var t=e.props,n=t.height;return t.scrollHeight>n},e}return(0,p.Z)(n,[{key:"componentDidMount",value:function(){this.scrollbarRef.current.addEventListener("touchstart",this.onScrollbarTouchStart),this.thumbRef.current.addEventListener("touchstart",this.onMouseDown)}},{key:"componentDidUpdate",value:function(e){e.scrollTop!==this.props.scrollTop&&this.delayHidden()}},{key:"componentWillUnmount",value:function(){this.removeEvents(),clearTimeout(this.visibleTimeout)}},{key:"render",value:function(){var e=this.state,t=e.dragging,n=e.visible,r=this.props.prefixCls,u=this.getSpinHeight(),i=this.getTop(),c=this.showScroll(),l=c&&n;return a.createElement("div",{ref:this.scrollbarRef,className:s()("".concat(r,"-scrollbar"),(0,o.Z)({},"".concat(r,"-scrollbar-show"),c)),style:{width:8,top:0,bottom:0,right:0,position:"absolute",display:l?null:"none"},onMouseDown:this.onContainerMouseDown,onMouseMove:this.delayHidden},a.createElement("div",{ref:this.thumbRef,className:s()("".concat(r,"-scrollbar-thumb"),(0,o.Z)({},"".concat(r,"-scrollbar-thumb-moving"),t)),style:{width:"100%",height:u,top:i,left:0,position:"absolute",background:"rgba(0, 0, 0, 0.5)",borderRadius:99,cursor:"pointer",userSelect:"none"},onMouseDown:this.onMouseDown}))}}]),n}(a.Component);function E(e){var t=e.children,n=e.setRef,r=a.useCallback((function(e){n(e)}),[]);return a.cloneElement(t,{ref:r})}var Z=n(34203),S=function(){function e(){(0,d.Z)(this,e),this.maps=void 0,this.maps=Object.create(null)}return(0,p.Z)(e,[{key:"set",value:function(e,t){this.maps[e]=t}},{key:"get",value:function(e){return this.maps[e]}}]),e}();var w=n(71002);function y(e,t,n){var r=a.useState(e),o=(0,i.Z)(r,2),u=o[0],c=o[1],l=a.useState(null),s=(0,i.Z)(l,2),f=s[0],v=s[1];return a.useEffect((function(){var r=function(e,t,n){var r,o,u=e.length,i=t.length;if(0===u&&0===i)return null;u<i?(r=e,o=t):(r=t,o=e);var c={__EMPTY_ITEM__:!0};function a(e){return void 0!==e?n(e):c}for(var l=null,s=1!==Math.abs(u-i),f=0;f<o.length;f+=1){var v=a(r[f]);if(v!==a(o[f])){l=f,s=s||v!==a(o[f+1]);break}}return null===l?null:{index:l,multiple:s}}(u||[],e||[],t);void 0!==(null==r?void 0:r.index)&&(null==n||n(r.index),v(e[r.index])),c(e)}),[e]),[f]}var T="object"===("undefined"==typeof navigator?"undefined":(0,w.Z)(navigator))&&/Firefox/i.test(navigator.userAgent),H=function(e,t){var n=(0,a.useRef)(!1),r=(0,a.useRef)(null);function o(){clearTimeout(r.current),n.current=!0,r.current=setTimeout((function(){n.current=!1}),50)}var u=(0,a.useRef)({top:e,bottom:t});return u.current.top=e,u.current.bottom=t,function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=e<0&&u.current.top||e>0&&u.current.bottom;return t&&i?(clearTimeout(r.current),n.current=!1):i&&!n.current||o(),!n.current&&i}};var L=n(8410);var x=["prefixCls","className","height","itemHeight","fullHeight","style","data","children","itemKey","virtual","component","onScroll","onVisibleChange","innerProps"],D=[],k={overflowY:"auto",overflowAnchor:"none"};function C(e,t){var n=e.prefixCls,l=void 0===n?"rc-virtual-list":n,f=e.className,v=e.height,d=e.itemHeight,p=e.fullHeight,g=void 0===p||p,m=e.style,M=e.data,C=e.children,Y=e.itemKey,N=e.virtual,P=e.component,I=void 0===P?"div":P,U=e.onScroll,z=e.onVisibleChange,_=e.innerProps,K=(0,c.Z)(e,x),j=!(!1===N||!v||!d),A=j&&M&&d*M.length>v,O=(0,a.useState)(0),F=(0,i.Z)(O,2),V=F[0],W=F[1],q=(0,a.useState)(!1),B=(0,i.Z)(q,2),G=B[0],J=B[1],Q=s()(l,f),X=M||D,$=(0,a.useRef)(),ee=(0,a.useRef)(),te=(0,a.useRef)(),ne=a.useCallback((function(e){return"function"==typeof Y?Y(e):null==e?void 0:e[Y]}),[Y]),re={getKey:ne};function oe(e){W((function(t){var n=function(e){var t=e;Number.isNaN(Ee.current)||(t=Math.min(t,Ee.current));return t=Math.max(t,0),t}("function"==typeof e?e(t):e);return $.current.scrollTop=n,n}))}var ue=(0,a.useRef)({start:0,end:X.length}),ie=(0,a.useRef)(),ce=y(X,ne),ae=(0,i.Z)(ce,1)[0];ie.current=ae;var le=function(e,t,n){var r=a.useState(0),o=(0,i.Z)(r,2),u=o[0],c=o[1],l=(0,a.useRef)(new Map),s=(0,a.useRef)(new S),f=(0,a.useRef)();function v(){b.Z.cancel(f.current)}function h(){v(),f.current=(0,b.Z)((function(){l.current.forEach((function(e,t){if(e&&e.offsetParent){var n=(0,Z.Z)(e),r=n.offsetHeight;s.current.get(t)!==r&&s.current.set(t,n.offsetHeight)}})),c((function(e){return e+1}))}))}return(0,a.useEffect)((function(){return v}),[]),[function(r,o){var u=e(r),i=l.current.get(u);o?(l.current.set(u,o),h()):l.current.delete(u),!i!=!o&&(o?null==t||t(r):null==n||n(r))},h,s.current,u]}(ne,null,null),se=(0,i.Z)(le,4),fe=se[0],ve=se[1],he=se[2],de=se[3],pe=a.useMemo((function(){if(!j)return{scrollHeight:void 0,start:0,end:X.length-1,offset:void 0};var e;if(!A)return{scrollHeight:(null===(e=ee.current)||void 0===e?void 0:e.offsetHeight)||0,start:0,end:X.length-1,offset:void 0};for(var t,n,r,o=0,u=X.length,i=0;i<u;i+=1){var c=X[i],a=ne(c),l=he.get(a),s=o+(void 0===l?d:l);s>=V&&void 0===t&&(t=i,n=o),s>V+v&&void 0===r&&(r=i),o=s}return void 0===t&&(t=0,n=0,r=Math.ceil(v/d)),void 0===r&&(r=X.length-1),{scrollHeight:o,start:t,end:r=Math.min(r+1,X.length),offset:n}}),[A,j,V,X,de,v]),ge=pe.scrollHeight,me=pe.start,be=pe.end,Me=pe.offset;ue.current.start=me,ue.current.end=be;var Re=ge-v,Ee=(0,a.useRef)(Re);Ee.current=Re;var Ze=V<=0,Se=V>=Re,we=H(Ze,Se);var ye=function(e,t,n,r){var o=(0,a.useRef)(0),u=(0,a.useRef)(null),i=(0,a.useRef)(null),c=(0,a.useRef)(!1),l=H(t,n);return[function(t){if(e){b.Z.cancel(u.current);var n=t.deltaY;o.current+=n,i.current=n,l(n)||(T||t.preventDefault(),u.current=(0,b.Z)((function(){var e=c.current?10:1;r(o.current*e),o.current=0})))}},function(t){e&&(c.current=t.detail===i.current)}]}(j,Ze,Se,(function(e){oe((function(t){return t+e}))})),Te=(0,i.Z)(ye,2),He=Te[0],Le=Te[1];!function(e,t,n){var r,o=(0,a.useRef)(!1),u=(0,a.useRef)(0),i=(0,a.useRef)(null),c=(0,a.useRef)(null),l=function(e){if(o.current){var t=Math.ceil(e.touches[0].pageY),r=u.current-t;u.current=t,n(r)&&e.preventDefault(),clearInterval(c.current),c.current=setInterval((function(){(!n(r*=.9333333333333333,!0)||Math.abs(r)<=.1)&&clearInterval(c.current)}),16)}},s=function(){o.current=!1,r()},f=function(e){r(),1!==e.touches.length||o.current||(o.current=!0,u.current=Math.ceil(e.touches[0].pageY),i.current=e.target,i.current.addEventListener("touchmove",l),i.current.addEventListener("touchend",s))};r=function(){i.current&&(i.current.removeEventListener("touchmove",l),i.current.removeEventListener("touchend",s))},(0,L.Z)((function(){return e&&t.current.addEventListener("touchstart",f),function(){var e;null===(e=t.current)||void 0===e||e.removeEventListener("touchstart",f),r(),clearInterval(c.current)}}),[e])}(j,$,(function(e,t){return!we(e,t)&&(He({preventDefault:function(){},deltaY:e}),!0)})),(0,L.Z)((function(){function e(e){j&&e.preventDefault()}return $.current.addEventListener("wheel",He),$.current.addEventListener("DOMMouseScroll",Le),$.current.addEventListener("MozMousePixelScroll",e),function(){$.current&&($.current.removeEventListener("wheel",He),$.current.removeEventListener("DOMMouseScroll",Le),$.current.removeEventListener("MozMousePixelScroll",e))}}),[j]);var xe=function(e,t,n,r,o,u,i,c){var l=a.useRef();return function(a){if(null!=a){if(b.Z.cancel(l.current),"number"==typeof a)i(a);else if(a&&"object"===(0,w.Z)(a)){var s,f=a.align;s="index"in a?a.index:t.findIndex((function(e){return o(e)===a.key}));var v=a.offset,h=void 0===v?0:v;!function c(a,v){if(!(a<0)&&e.current){var d=e.current.clientHeight,p=!1,g=v;if(d){for(var m=v||f,M=0,R=0,E=0,Z=Math.min(t.length,s),S=0;S<=Z;S+=1){var w=o(t[S]);R=M;var y=n.get(w);M=E=R+(void 0===y?r:y),S===s&&void 0===y&&(p=!0)}var T=null;switch(m){case"top":T=R-h;break;case"bottom":T=E-d+h;break;default:var H=e.current.scrollTop;R<H?g="top":E>H+d&&(g="bottom")}null!==T&&T!==e.current.scrollTop&&i(T)}l.current=(0,b.Z)((function(){p&&u(),c(a-1,g)}),2)}}(3)}}else c()}}($,X,he,d,ne,ve,oe,(function(){var e;null===(e=te.current)||void 0===e||e.delayHidden()}));a.useImperativeHandle(t,(function(){return{scrollTo:xe}})),(0,L.Z)((function(){if(z){var e=X.slice(me,be+1);z(e,X)}}),[me,be,X]);var De=function(e,t,n,r,o,u){var i=u.getKey;return e.slice(t,n+1).map((function(e,n){var u=o(e,t+n,{}),c=i(e);return a.createElement(E,{key:c,setRef:function(t){return r(e,t)}},u)}))}(X,me,be,fe,C,re),ke=null;return v&&(ke=(0,u.Z)((0,o.Z)({},g?"height":"maxHeight",v),k),j&&(ke.overflowY="hidden",G&&(ke.pointerEvents="none"))),a.createElement("div",(0,r.Z)({style:(0,u.Z)((0,u.Z)({},m),{},{position:"relative"}),className:Q},K),a.createElement(I,{className:"".concat(l,"-holder"),style:ke,ref:$,onScroll:function(e){var t=e.currentTarget.scrollTop;t!==V&&oe(t),null==U||U(e)}},a.createElement(h,{prefixCls:l,height:ge,offset:Me,onInnerResize:ve,ref:ee,innerProps:_},De)),j&&a.createElement(R,{ref:te,prefixCls:l,scrollTop:V,height:v,scrollHeight:ge,count:X.length,onScroll:function(e){oe(e)},onStartMove:function(){J(!0)},onStopMove:function(){J(!1)}}))}var Y=a.forwardRef(C);Y.displayName="List";var N=Y}}]); |