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.
NewEduCoderBuild/17004.async.js

1 line
23 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

(self.webpackChunk=self.webpackChunk||[]).push([[17004],{73457:function(e,t,n){"use strict";n.d(t,{Z:function(){return Z}});var r=n(17061),s=n.n(r),o=n(17156),i=n.n(o),l=n(42122),a=n.n(l),c=n(27424),u=n.n(c),d=n(70215),p=n.n(d),h=n(67294),f=n(2453),m=n(92421),v=n(71230),x=n(59758),y=n(4340),g=n(82749),j="tip___bHEXo",b=n(85893),w=["ButtonText","ButtonOptions","uploadProps","showTip","showText"],Z=function(e){var t,n,r,o=e.ButtonText,l=e.ButtonOptions,c=e.uploadProps,d=e.showTip,Z=e.showText,_=p()(e,w),k=(0,h.useState)(null),C=u()(k,2),L=C[0],S=C[1],P=a()(a()({maxCount:1,accept:"image/*",withCredentials:!0,beforeUpload:function(e){if(!("image/jpeg"===e.type||"image/png"===e.type||"image/jpg"===e.type))return f.ZP.error("您上传的不是JPEG/PNG/JPG类型文件"),m.Z.LIST_IGNORE;var t=e.size/1024/1024;return 0==t?(f.ZP.error("".concat(e.name," 图片无法上传。").concat(0==t?"文件内容不能为空":"超过图片大小限制(2MB)")),m.Z.LIST_IGNORE):!(t>2)||(f.ZP.error("".concat(e.name," 图片无法上传。超过图片大小限制(2MB)")),m.Z.LIST_IGNORE)},onChange:function(e){var t,n;(["uploading","done","removed"].includes(e.file.status)&&S(e.file),"done"==e.file.status)&&(null==_||_.onChange(null===(t=e.file)||void 0===t||null===(n=t.response)||void 0===n?void 0:n.id))},action:"".concat(x.Z.API_SERVER,"/api/attachments.json")},c||{}),{},{onRemove:(n=i()(s()().mark((function e(t){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:O(),(null==c?void 0:c.onRemove)&&(null==c||c.onRemove(t));case 2:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}),O=function(){S(null),null==_||_.onChange()};return(0,h.useEffect)((function(){(null==_?void 0:_.value)&&S({response:{id:null==_?void 0:_.value}})}),[null==_?void 0:_.value]),(0,b.jsx)("div",{id:(null==_?void 0:_.scrollId)||"",children:null!=L&&null!==(t=L.response)&&void 0!==t&&t.id?(0,b.jsxs)(v.Z,{align:"middle",justify:"center",style:{position:"relative",width:400,backgroundColor:"#f4f3f4"},children:[(0,b.jsx)("img",{src:x.Z.API_SERVER+"/api/attachments/"+(null==L||null===(r=L.response)||void 0===r?void 0:r.id),alt:"avatar",style:{width:"100%"}}),(0,b.jsx)("div",{style:{position:"absolute",right:"-6px",top:"-6px",cursor:"pointer",width:16,height:16,borderRadius:"50%",backgroundColor:"#fff"},children:(0,b.jsx)(y.Z,{onClick:i()(s()().mark((function e(){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:O();case 1:case"end":return e.stop()}}),e)}))),style:{fontSize:"16px",color:"red"}})})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(m.Z,a()(a()({},P),{},{children:(0,b.jsx)(g.op,a()(a()({style:a()({borderRadius:"2px"},null==l?void 0:l.style)},l),{},{children:o}))})),d&&(0,b.jsx)("span",{className:j,children:"建议上传尺寸为472*266的图片"}),Z&&(0,b.jsx)("span",{className:j,style:{width:"4rem"},children:"需上传尺寸为200*268的图片大小不超过2MB"})]})})}},17004:function(e,t,n){"use strict";n.d(t,{Z:function(){return q}});var r=n(42122),s=n.n(r),o=n(17061),i=n.n(o),l=n(17156),a=n.n(l),c=n(70215),u=n.n(c),d=n(67294),p=n(14446),h=n(2453),f=n(91773),m=n(11486),v=n(71230),x=n(15746),y=n(76661),g=n(73457),j=n(861),b=n.n(j),w=n(27424),Z=n.n(w),_=n(84567),k=n(83062),C=n(96101),L=n(49288),S=n(71577),P=n(246),O=n.n(P),I=n(27484),T=n.n(I),E=n(73290),N=n(81728),M=n(84519),R=n(88275),F=n(85893),D=(0,R.connect)((function(e){return{classroomList:e.classroomList,loading:e.loading}}))((function(e){var t,n,r=e.classroomList,o=(e.loading,e.dispatch),l=(0,R.useParams)(),c=r.actionTabs,u=(0,d.useState)([]),v=Z()(u,2),x=v[0],g=v[1],j=(0,d.useState)(!0),w=Z()(j,2),P=w[0],I=w[1],D=(0,d.useState)(!1),H=Z()(D,2),B=H[0],q=H[1],W=f.Z.useForm(),z=Z()(W,1)[0],V=(0,d.useState)([]),Y=Z()(V,2),A=Y[0],G=Y[1],U=(0,d.useState)(0),$=Z()(U,2),J=$[0],X=$[1],Q=(0,d.useState)([]),K=Z()(Q,2),ee=K[0],te=K[1],ne=(0,d.useState)(!0),re=Z()(ne,2),se=re[0],oe=re[1];(0,d.useRef)();(0,d.useEffect)((function(){"添加成员"===r.actionTabs.key&&(oe(!0),ie())}),[r.actionTabs.key]);var ie=function(){var e=a()(i()().mark((function e(){var t;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,o({type:"classroomList/getSchoolList",payload:{}});case 2:t=e.sent,g(t.map((function(e){return{value:e}})));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),le=function(){var e=a()(i()().mark((function e(){var t,n,r,o,a=arguments;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t=a.length>0&&void 0!==a[0]&&a[0])&&!P||B){e.next=11;break}return r=z.getFieldValue(),q(!0),X(t?1:J+1),e.next=7,(0,E.nQ)(s()({page:t?1:J+1,container_id:l.coursesId,container_type:1,school_name:null==r?void 0:r.school_name,keyword:null==r?void 0:r.keyword},r));case 7:o=e.sent,G(t?b()(o.users):[].concat(b()(A),b()(o.users))),q(!1),(null===(n=o.users)||void 0===n?void 0:n.length)<10&&I(!1);case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ae=function(){var e=a()(i()().mark((function e(){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!=ee){e.next=4;break}h.ZP.error("请选择人数"),e.next=9;break;case 4:return console.log(l),e.next=7,(0,M.ZP)("/api/core_subjects/".concat(l.coreId,"/add_members.json"),{method:"post",body:{user_ids:ee.map((function(e){return e}))}});case 7:0===e.sent.status&&(h.ZP.success("添加成功"),o({type:"classroomList/setActionTabs",payload:{}}),o({type:"coreCurriculum/getCoreSubjectDetail",payload:{id:l.coreId}}));case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ce=[{title:"",dataIndex:"added",width:40,ellipsis:!0,render:function(e,t){return(0,F.jsx)(_.Z,{value:t.numid,checked:ee.includes(String(t.numid)),disabled:!!e})}},{title:"姓名",width:100,ellipsis:!0,dataIndex:"username",render:function(e,t){return(0,F.jsx)(k.Z,{placement:"bottom",title:e,children:(0,F.jsx)(R.Link,{className:"bold c-black",to:"/users/".concat(t.login),target:"_blank",children:e||"--"})})}},{title:"手机",width:100,dataIndex:"phone",ellipsis:!0,render:function(e){return(0,F.jsx)(k.Z,{placement:"bottom",title:e,children:(0,F.jsx)("span",{children:e||"--"})})}},{title:"邮箱",dataIndex:"email",width:100,ellipsis:!0,render:function(e){return(0,F.jsx)(k.Z,{placement:"bottom",title:e,children:(0,F.jsx)("span",{children:e||"--"})})}},{title:"学号/工号",width:100,dataIndex:"student_number",ellipsis:!0,render:function(e){return(0,F.jsx)(k.Z,{placement:"bottom",title:e,children:(0,F.jsx)("span",{children:e||"--"})})}},{title:"学校/单位",width:150,dataIndex:"school_name",ellipsis:!0,render:function(e){return(0,F.jsx)(k.Z,{placement:"bottom",title:e,children:(0,F.jsx)("span",{children:e||"--"})})}},{title:"最后登录时间",dataIndex:"last_login_on",width:140,ellipsis:!0,render:function(e){return(0,F.jsx)(k.Z,{placement:"bottom",title:e,children:(0,F.jsx)("span",{children:T()(e).format("YYYY-MM-DD HH:mm")})})}},{title:"状态",dataIndex:"added",width:80,render:function(e){if(1===e)return(0,F.jsx)("span",{className:"c-green",children:"已添加"})}}];return(0,F.jsxs)(p.Z,{centered:!0,title:"添加成员",open:"添加成员"===r.actionTabs.key,okText:"确定",cancelText:"取消",width:1100,zIndex:1e3,bodyStyle:{minHeight:200},onOk:a()(i()().mark((function e(){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:ae();case 1:case"end":return e.stop()}}),e)}))),onCancel:function(){te([]),o({type:"classroomList/setActionTabs",payload:{}})},children:[(0,F.jsxs)(f.Z,{layout:"inline",form:z,initialValues:{school_name:"",keyword:"",search_type:"1"},className:"mt10",children:[(0,F.jsx)(f.Z.Item,{name:"search_type",label:"搜索类型",children:(0,F.jsxs)(C.Z,{style:{width:90},children:[(0,F.jsx)(C.Z.Option,{value:"1",children:"姓名"}),(0,F.jsx)(C.Z.Option,{value:"2",children:"手机号"}),(0,F.jsx)(C.Z.Option,{value:"3",children:"邮箱"})]})}),(0,F.jsx)(f.Z.Item,{name:"keyword",label:"搜索内容:",children:(0,F.jsx)(m.Z,{allowClear:!0,style:{width:250},size:"middle",defaultValue:(null===(t=c.selectArrs)||void 0===t?void 0:t.category_name)||(null===(n=c.selectArrs)||void 0===n?void 0:n.name)})}),(0,F.jsx)(f.Z.Item,{name:"school_name",label:"单位:",children:(0,F.jsx)(L.Z,{options:x,style:{width:390},size:"middle",placeholder:"请输入单位名称",filterOption:function(e,t){return-1!==t.value.toUpperCase().indexOf(e.toUpperCase())}})}),(0,F.jsx)(f.Z.Item,{children:(0,F.jsx)(S.ZP,{htmlType:"submit",type:"primary",size:"middle",onClick:function(){return function(){var e;if(""===(null===(e=z.getFieldValue())||void 0===e?void 0:e.keyword))return G([]),void h.ZP.error("请输入搜索内容");oe(!1),I(!0),q(!1),te([]),setTimeout((function(){le(!0)}),200)}()},children:"搜索"})})]}),se&&(0,F.jsxs)("div",{className:"tc font16 c-light-black mt40 pb30",children:[(0,F.jsx)("img",{src:N.RL,width:"100",alt:""}),(0,F.jsx)("br",{}),(0,F.jsx)("p",{className:"mt20",children:"请搜索要添加的人员"})]}),!se&&""==A&&!B&&(0,F.jsxs)("div",{className:"tc font16 c-light-black mt40 pb30",children:[(0,F.jsx)("img",{src:N.z3,width:"100",alt:""}),(0,F.jsx)("br",{}),(0,F.jsx)("p",{className:"mt20",children:"暂时还没有相关数据哦!"})]}),(!se&&""!=A||B)&&(0,F.jsxs)("section",{children:[(0,F.jsx)("div",{className:"flexd-table-header mt20",children:(0,F.jsx)(y.Z,{pagination:!1,dataSource:[],columns:ce})}),(0,F.jsx)("div",{style:{maxHeight:260,overflow:"auto"},children:(0,F.jsx)(O(),{initialLoad:!1,pageStart:1,threshold:20,loadMore:function(e){le()},hasMore:P,useWindow:!1,children:(0,F.jsx)(y.Z,{loading:B,showHeader:!1,pagination:!1,dataSource:A,columns:ce,onRow:function(e){return{onClick:function(e){e.currentTarget.querySelector("input").disabled||function(e){e=String(e);var t=ee.indexOf(e);t<0?ee.push(e):ee.splice(t,1),te(b()(ee))}(e.currentTarget.querySelector("input").value)}}}})})})]})]})})),H=n(7),B=["handleFinish","form","dispatch","user","coreCurriculum"],q=(0,R.connect)((function(e){return{dispatch:e.dispatch,coreCurriculum:e.coreCurriculum,user:e.user}}))((function(e){var t,n=e.handleFinish,r=e.form,o=e.dispatch,l=(e.user,e.coreCurriculum),c=u()(e,B),d=l.CoreDetail,j=(0,R.useParams)(),b=[{title:"姓名",dataIndex:"user_name",key:"user_name"},{title:"学校",dataIndex:"school_name",key:"school_name"},{title:"身份",dataIndex:"role",key:"role",width:80,render:function(e,t){return(0,F.jsx)("span",{children:"1"==e?"管理员":"成员"})}},{title:"操作",render:function(e,t){return(0,F.jsx)(F.Fragment,{children:!(null!=t&&t.is_current_user)&&(0,F.jsxs)(F.Fragment,{children:["1"==(null==t?void 0:t.role)&&((null==d?void 0:d.is_core_subject_admin)||(0,H.Ny)())&&(0,F.jsx)("span",{style:{marginLeft:10,cursor:"pointer",color:"blue"},onClick:a()(i()().mark((function e(){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:p.Z.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"撤销管理员",content:"是否确认将成员撤销管理员?",onOk:function(){var e=a()(i()().mark((function e(){var n;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,M.ZP)("/api/core_subjects/".concat(j.coreId,"/set_admin.json"),{method:"post",body:{user_id:null==t?void 0:t.user_id,operation:"revoke"}});case 2:0==(null==(n=e.sent)?void 0:n.status)&&(h.ZP.success("成功撤销管理员"),o({type:"coreCurriculum/getCoreSubjectDetail",payload:{id:j.coreId}}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()});case 1:case"end":return e.stop()}}),e)}))),children:"撤销管理员"}),"2"==(null==t?void 0:t.role)&&((null==d?void 0:d.is_core_subject_admin)||(0,H.Ny)())&&(0,F.jsx)("span",{style:{marginLeft:10,cursor:"pointer",color:"blue"},onClick:a()(i()().mark((function e(){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:p.Z.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"设为管理员",content:"是否确认将成员设为管理员?",onOk:function(){var e=a()(i()().mark((function e(){var n;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,M.ZP)("/api/core_subjects/".concat(j.coreId,"/set_admin.json"),{method:"post",body:{user_id:null==t?void 0:t.user_id,operation:"set"}});case 2:0==(null==(n=e.sent)?void 0:n.status)&&(h.ZP.success("成功设为管理员"),o({type:"coreCurriculum/getCoreSubjectDetail",payload:{id:j.coreId}}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()});case 1:case"end":return e.stop()}}),e)}))),children:"设为管理员"}),((null==d?void 0:d.is_core_subject_admin)||(0,H.Ny)())&&(0,F.jsx)("span",{style:{marginLeft:10,cursor:"pointer",color:"blue"},onClick:a()(i()().mark((function e(){return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:p.Z.confirm({centered:!0,okText:"确定",cancelText:"取消",title:"移除成员",content:"是否确认将成员移除?",onOk:function(){var e=a()(i()().mark((function e(){var n;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,M.ZP)("/api/core_subjects/".concat(j.coreId,"/remove_members.json"),{method:"post",body:{user_id:null==t?void 0:t.user_id}});case 2:0==(null==(n=e.sent)?void 0:n.status)&&(h.ZP.success("移除成功"),o({type:"coreCurriculum/getCoreSubjectDetail",payload:{id:j.coreId}}));case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}()});case 1:case"end":return e.stop()}}),e)}))),children:"移除成员"})]})})}}];return(0,F.jsxs)(p.Z,s()(s()({},c),{},{destroyOnClose:!0,centered:!0,width:1200,children:[(0,F.jsxs)(f.Z,{form:r,size:"large",initialValues:{},layout:"vertical",style:{maxHeight:"calc(100vh - 200px)"},onValuesChange:function(e){},onFinish:n,children:[(0,F.jsx)(f.Z.Item,{htmlFor:null,name:"name",label:"课程名称",rules:[{required:!0,message:"请输入课程名称"}],children:(0,F.jsx)(m.Z,{placeholder:"请输入课程名称",maxLength:50,showCount:!0})}),(0,F.jsx)(f.Z.Item,{htmlFor:null,name:"name_en",label:"课程英文名称",rules:[{required:!0,message:"请输入课程英文名称"}],children:(0,F.jsx)(m.Z,{placeholder:"请输入课程英文名称",maxLength:50,showCount:!0})}),(0,F.jsxs)(v.Z,{gutter:20,children:[(0,F.jsx)(x.Z,{flex:1,children:(0,F.jsx)(f.Z.Item,{htmlFor:null,name:"adminer",label:"负责人(中文)",rules:[{required:!0,message:"请输入负责人"}],children:(0,F.jsx)(m.Z,{placeholder:"请输入负责人",maxLength:10,showCount:!0})})}),(0,F.jsx)(x.Z,{flex:1,children:(0,F.jsx)(f.Z.Item,{htmlFor:null,name:"adminer_en",label:"负责人(英文)",rules:[{required:!0,message:"请输入负责人"}],children:(0,F.jsx)(m.Z,{placeholder:"请输入负责人",maxLength:100,showCount:!0})})})]}),(0,F.jsxs)(v.Z,{gutter:20,children:[(0,F.jsx)(x.Z,{flex:1,children:(0,F.jsx)(f.Z.Item,{htmlFor:null,name:"leading_unit",label:"牵头单位(中文)",rules:[{required:!0,message:"请输入牵头单位"}],children:(0,F.jsx)(m.Z,{placeholder:"请输入牵头单位",maxLength:20,showCount:!0})})}),(0,F.jsx)(x.Z,{flex:1,children:(0,F.jsx)(f.Z.Item,{htmlFor:null,name:"leading_unit_en",label:"牵头单位(英文)",rules:[{required:!0,message:"请输入牵头单位"}],children:(0,F.jsx)(m.Z,{placeholder:"请输入牵头单位",maxLength:500,showCount:!0})})})]}),(0,F.jsxs)(v.Z,{gutter:20,children:[(0,F.jsxs)(x.Z,{span:9,children:[(0,F.jsx)(f.Z.Item,{name:"cover_id",label:"列表封面图",rules:[{required:!0,message:"请上传列表封面图"}],children:(0,F.jsx)(g.Z,{ButtonText:"上传图片"})}),(0,F.jsx)(f.Z.Item,{name:"detail_pic_id",label:"课程详情图",children:(0,F.jsx)(g.Z,{ButtonText:"上传图片"})})]}),"新建核心课程"!=(null==c?void 0:c.title)&&(0,F.jsxs)(x.Z,{span:15,style:{position:"relative"},children:[(0,F.jsx)(f.Z.Item,{name:"users_id",label:"课程成员",children:(0,F.jsx)(y.Z,{columns:b,scroll:{y:200},dataSource:null==l||null===(t=l.CoreDetail)||void 0===t?void 0:t.members,bordered:!0,pagination:!1})}),((null==d?void 0:d.is_core_subject_admin)||(0,H.Ny)())&&(0,F.jsx)("div",{onClick:function(){o({type:"classroomList/setActionTabs",payload:{key:"添加成员"}})},style:{position:"absolute",right:"10px",top:"10px",cursor:"pointer",color:"blue"},children:"添加成员"})]})]})]}),(0,F.jsx)(D,{})]}))}))},49288:function(e,t,n){"use strict";var r=n(94184),s=n.n(r),o=n(37419),i=n(10366),l=n(67294),a=n(8745),c=n(96159),u=n(53124),d=n(96101);const{Option:p}=d.Z;function h(e){return e&&e.type&&(e.type.isSelectOption||e.type.isSelectOptGroup)}const f=(e,t)=>{const{prefixCls:n,className:r,popupClassName:a,dropdownClassName:f,children:m,dataSource:v}=e,x=(0,o.Z)(m);let y;1===x.length&&(0,c.l$)(x[0])&&!h(x[0])&&([y]=x);const g=y?()=>y:void 0;let j;j=x.length&&h(x[0])?m:v?v.map((e=>{if((0,c.l$)(e))return e;switch(typeof e){case"string":return l.createElement(p,{key:e,value:e},e);case"object":{const{value:t}=e;return l.createElement(p,{key:t,value:t},e.text)}default:return}})):[];const{getPrefixCls:b}=l.useContext(u.E_),w=b("select",n);return l.createElement(d.Z,Object.assign({ref:t,suffixIcon:null},(0,i.Z)(e,["dataSource","dropdownClassName"]),{prefixCls:w,popupClassName:a||f,className:s()(`${w}-auto-complete`,r),mode:d.Z.SECRET_COMBOBOX_MODE_DO_NOT_USE},{getInputElement:g}),j)},m=l.forwardRef(f),v=(0,a.Z)(m);m.Option=p,m._InternalPanelDoNotUseOrYouWillBeFired=v,t.Z=m},57761:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(67294),o=l(s),i=l(n(45697));function l(e){return e&&e.__esModule?e:{default:e}}var a=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.scrollListener=n.scrollListener.bind(n),n.eventListenerOptions=n.eventListenerOptions.bind(n),n.mousewheelListener=n.mousewheelListener.bind(n),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),r(t,[{key:"componentDidMount",value:function(){this.pageLoaded=this.props.pageStart,this.options=this.eventListenerOptions(),this.attachScrollListener()}},{key:"componentDidUpdate",value:function(){if(this.props.isReverse&&this.loadMore){var e=this.getParentElement(this.scrollComponent);e.scrollTop=e.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}},{key:"componentWillUnmount",value:function(){this.detachScrollListener(),this.detachMousewheelListener()}},{key:"isPassiveSupported",value:function(){var e=!1,t={get passive(){e=!0}};try{document.addEventListener("test",null,t),document.removeEventListener("test",null,t)}catch(e){}return e}},{key:"eventListenerOptions",value:function(){var e=this.props.useCapture;return this.isPassiveSupported()&&(e={useCapture:this.props.useCapture,passive:!0}),e}},{key:"setDefaultLoader",value:function(e){this.defaultLoader=e}},{key:"detachMousewheelListener",value:function(){var e=window;!1===this.props.useWindow&&(e=this.scrollComponent.parentNode),e.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}},{key:"detachScrollListener",value:function(){var e=window;!1===this.props.useWindow&&(e=this.getParentElement(this.scrollComponent)),e.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),e.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}},{key:"getParentElement",value:function(e){var t=this.props.getScrollParent&&this.props.getScrollParent();return null!=t?t:e&&e.parentNode}},{key:"filterProps",value:function(e){return e}},{key:"attachScrollListener",value:function(){var e=this.getParentElement(this.scrollComponent);if(this.props.hasMore&&e){var t=window;!1===this.props.useWindow&&(t=e),t.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),t.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),t.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}}},{key:"mousewheelListener",value:function(e){1!==e.deltaY||this.isPassiveSupported()||e.preventDefault()}},{key:"scrollListener",value:function(){var e=this.scrollComponent,t=window,n=this.getParentElement(e),r=void 0;if(this.props.useWindow){var s=document.documentElement||document.body.parentNode||document.body,o=void 0!==t.pageYOffset?t.pageYOffset:s.scrollTop;r=this.props.isReverse?o:this.calculateOffset(e,o)}else r=this.props.isReverse?n.scrollTop:e.scrollHeight-n.scrollTop-n.clientHeight;r<Number(this.props.threshold)&&e&&null!==e.offsetParent&&(this.detachScrollListener(),this.beforeScrollHeight=n.scrollHeight,this.beforeScrollTop=n.scrollTop,"function"==typeof this.props.loadMore&&(this.props.loadMore(this.pageLoaded+=1),this.loadMore=!0))}},{key:"calculateOffset",value:function(e,t){return e?this.calculateTopPosition(e)+(e.offsetHeight-t-window.innerHeight):0}},{key:"calculateTopPosition",value:function(e){return e?e.offsetTop+this.calculateTopPosition(e.offsetParent):0}},{key:"render",value:function(){var e=this,t=this.filterProps(this.props),n=t.children,r=t.element,s=t.hasMore,i=(t.initialLoad,t.isReverse),l=t.loader,a=(t.loadMore,t.pageStart,t.ref),c=(t.threshold,t.useCapture,t.useWindow,t.getScrollParent,function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(t,["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","ref","threshold","useCapture","useWindow","getScrollParent"]));c.ref=function(t){e.scrollComponent=t,a&&a(t)};var u=[n];return s&&(l?i?u.unshift(l):u.push(l):this.defaultLoader&&(i?u.unshift(this.defaultLoader):u.push(this.defaultLoader))),o.default.createElement(r,c,u)}}]),t}(s.Component);a.propTypes={children:i.default.node.isRequired,element:i.default.node,hasMore:i.default.bool,initialLoad:i.default.bool,isReverse:i.default.bool,loader:i.default.node,loadMore:i.default.func.isRequired,pageStart:i.default.number,ref:i.default.func,getScrollParent:i.default.func,threshold:i.default.number,useCapture:i.default.bool,useWindow:i.default.bool},a.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null},t.default=a,e.exports=t.default},246:function(e,t,n){e.exports=n(57761)}}]);