1 |
- import{dI as I,dJ as H,dK as G,s as $,f as i,ai as D,aN as de,w as me,E as K,G as Q,L as M,aH as he,dL as ve,dM as Y,y as h,ad as F,ae as ye,z as c,P as v,Q as o,T as ge,D as fe,a3 as P,ao as we,cY as Ee,H as xe}from"./index-DT8qTvyx.js";var N,Ce=(N={},N[I]="in",N[H]="in",N[G]="out",N),Se={component:function(u){var n,e,r=u.data||{},t=u.thumbMode,a=u.classnames;return i.createElement(i.Fragment,null,r.hasOwnProperty("image")?i.createElement(Ee,{src:r.image,title:r.title,href:r.href,blank:r.blank,htmlTarget:r.htmlTarget,caption:r.description,thumbMode:(e=(n=r.thumbMode)!==null&&n!==void 0?n:t)!==null&&e!==void 0?e:"contain",imageMode:"original",className:a("Carousel-image")}):r.hasOwnProperty("html")?i.createElement(xe,{html:r.html,filterHtml:u.env.filterHtml}):r.hasOwnProperty("item")?i.createElement("span",null,r.item):i.createElement("p",null))}},Te=function(u){$(n,u);function n(){var e=u!==null&&u.apply(this,arguments)||this;return e.wrapperRef=i.createRef(),e.state={current:0,options:e.props.options||D(e.props)||[],nextAnimation:""},e.loading=!1,e}return n.prototype.componentDidMount=function(){this.prepareAutoSlide()},n.prototype.componentDidUpdate=function(e){var r=this.props,t=r.options||D(r)||[],a=e.options||D(e)||[];de(a,t)&&this.setState({options:t})},n.prototype.componentWillUnmount=function(){this.clearAutoTimeout()},n.prototype.doAction=function(e,r,t,a){var s=e==null?void 0:e.actionType;~["next","prev"].indexOf(s)?this.autoSlide(s):s==="goto-image"&&this.changeSlide((a==null?void 0:a.activeIndex)-1)},n.prototype.prepareAutoSlide=function(){if(!(this.state.options.length<2)&&(this.clearAutoTimeout(),this.props.auto)){var e=this.props.interval;this.intervalTimeout=setTimeout(this.autoSlide,typeof e=="string"?me(e,this.props.data)||5e3:e)}},n.prototype.autoSlide=function(e){this.clearAutoTimeout();var r=this.props.animation,t=this.state.nextAnimation;switch(e){case"prev":r==="slide"?t="slideRight":t="",this.transitFramesTowards("right",t);break;case"next":default:t="",this.transitFramesTowards("left",t);break}this.durationTimeout=setTimeout(this.prepareAutoSlide,this.props.duration)},n.prototype.transitFramesTowards=function(e,r){return K(this,void 0,void 0,function(){var t,a,s,y,l,d;return Q(this,function(x){switch(x.label){case 0:switch(t=this.state.current,a=t,e){case"left":t=this.getFrameId("next");break;case"right":t=this.getFrameId("prev");break}return s=this.props,y=s.dispatchEvent,l=s.data,[4,y("change",P(l,{activeIndex:t+1,prevIndex:a}))];case 1:return d=x.sent(),d!=null&&d.prevented?[2]:(this.setState({current:t,nextAnimation:r}),[2])}})})},n.prototype.getFrameId=function(e){var r=this.state,t=r.options,a=r.current,s=t.length;switch(e){case"prev":return(a-1+s)%s;case"next":return(a+1)%s;default:return a}},n.prototype.next=function(){var e=this.props.multiple;this.loading&&e&&e.count>1||this.autoSlide("next")},n.prototype.prev=function(){var e=this.props.multiple;this.loading&&e&&e.count>1||this.autoSlide("prev")},n.prototype.clearAutoTimeout=function(){clearTimeout(this.intervalTimeout),clearTimeout(this.durationTimeout)},n.prototype.changeSlide=function(e){return K(this,void 0,void 0,function(){var r,t,a,s,y,l;return Q(this,function(d){switch(d.label){case 0:return r=this.state.current,t=this.props,a=t.dispatchEvent,s=t.data,y=t.multiple,this.loading&&y&&y.count>1?[2]:[4,a("change",P(s,{activeIndex:e,prevIndex:r}))];case 1:return l=d.sent(),l!=null&&l.prevented?[2]:(this.setState({current:e}),[2])}})})},n.prototype.renderDots=function(){var e=this,r=this.props.classnames,t=this.state,a=t.current,s=t.options;return i.createElement("div",{className:r("Carousel-dotsControl"),onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave},Array.from({length:s.length}).map(function(y,l){return i.createElement("span",{key:l,onClick:function(){return e.changeSlide(l)},className:r("Carousel-dot",a===l?"is-active":"")})}))},n.prototype.renderArrows=function(){var e=this.props.classnames;return i.createElement("div",{className:e("Carousel-arrowsControl"),onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave},i.createElement("div",{className:e("Carousel-leftArrow"),onClick:this.prev},i.createElement(M,{icon:"left-arrow",className:"icon"})),i.createElement("div",{className:e("Carousel-rightArrow"),onClick:this.next},i.createElement(M,{icon:"right-arrow",className:"icon"})))},n.prototype.handleMouseEnter=function(){var e=this.props.multiple;e&&e.count>1||this.clearAutoTimeout()},n.prototype.handleMouseLeave=function(){var e=this.props.multiple;e&&e.count>1||this.prepareAutoSlide()},n.prototype.getNewOptions=function(e,r){r===void 0&&(r=1);var t=e;if(Array.isArray(e)&&e.length){t=new Array(e.length);for(var a=0;a<e.length;a++){t[a]=new Array(r);for(var s=0;s<r;s++)t[a][s]=e[(a+s)%e.length]}}return t},n.prototype.render=function(){var e,r=this,t=this.props,a=t.render,s=t.className,y=t.style,l=t.classnames,d=t.itemSchema,x=t.animation,U=t.width,V=t.height,W=t.controls,q=t.controlsTheme,Z=t.placeholder,ee=t.data,te=t.name,C=t.duration,S=t.multiple,re=t.alwaysShowArrow,m=t.icons,T=t.id,X=t.wrapperCustomStyle,ne=t.env,b=t.themeCss,O=this.state,w=O.options,B=O.current,ae=O.nextAnimation,_=null,R=y||{};U&&(R.width=U+"px"),V&&(R.height=V+"px");var j=he([W.indexOf("dots")>-1,W.indexOf("arrows")>-1],2),oe=j[0],z=j[1],k=ae||x;if(Array.isArray(w)&&w.length){var p=1;S&&typeof S.count=="number"&&S.count>=2&&(p=Math.floor(S.count)<w.length?Math.floor(S.count):w.length);var ie=this.getNewOptions(w,p),se=p>1&&typeof C=="number"?"".concat(C,"ms"):C||"500ms",le=p>1&&typeof C=="number"?C:500;_=i.createElement("div",{ref:this.wrapperRef,className:l("Carousel-container"),onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave},w.map(function(pe,L){return i.createElement(ve,{mountOnEnter:!0,unmountOnExit:!0,in:L===B,timeout:le,key:L},function(f){var E;f===I&&r.wrapperRef.current&&r.wrapperRef.current.childNodes.forEach(function(g){return g.offsetHeight}),p>1&&((f===I||f===G)&&!r.loading?r.loading=!0:(f===H||f===Y)&&r.loading&&(r.loading=!1));var ue=(E={},E[I]=0,E[H]=0,E[G]=k==="slideRight"?100/p:-100/p,E[Y]=k==="slideRight"?-100/p:100/p,E),ce=p>1?h({transitionTimingFunction:"linear",transitionDuration:se},x==="slide"?{transform:"translateX(".concat(ue[f],"%)")}:{}):{},J=function(g){var A;return a("".concat(B,"/body"),d||Se,{thumbMode:r.props.thumbMode,data:P(ee,we(g)?g:(A={item:g},A[te]=g,A))})};return i.createElement("div",{className:l("Carousel-item",k,Ce[f]),style:ce},p===1?J(pe):null,p>1?ie[L].map(function(g,A){return i.createElement("div",{key:A,style:{width:100/p+"%",height:"100%",float:"left"}},J(g))}):null)})}))}return i.createElement("div",{className:l("Carousel Carousel--".concat(q),(e={},e["Carousel-arrow--always"]=!!re,e),s,F(h(h({},this.props),{name:"baseControlClassName",id:T,themeCss:b})),F(h(h({},this.props),{name:"wrapperCustomStyle",id:T,themeCss:X}))),style:R},_||Z,oe?this.renderDots():null,z?i.createElement("div",{className:l("Carousel-leftArrow",F(h(h({},this.props),{name:"galleryControlClassName",id:T,themeCss:b}))),onClick:this.prev},m&&m.prev?i.isValidElement(m.prev)?m.prev:a("arrow-prev",m.prev):i.createElement(M,{icon:"left-arrow",className:"icon",iconContent:"ImageGallery-prevBtn"})):null,z?i.createElement("div",{className:l("Carousel-rightArrow",F(h(h({},this.props),{name:"galleryControlClassName",id:T,themeCss:b}))),onClick:this.next},m&&m.next?i.isValidElement(m.next)?m.next:a("arrow-next",m.next):i.createElement(M,{icon:"right-arrow",className:"icon",iconContent:"ImageGallery-nextBtn"})):null,i.createElement(ye,h({},this.props,{config:{wrapperCustomStyle:X,id:T,themeCss:b,classNames:[{key:"baseControlClassName"},{key:"galleryControlClassName",weights:{default:{suf:" svg",important:!0}}}]},env:ne})))},n.defaultProps={auto:!0,interval:5e3,duration:500,controlsTheme:"light",animation:"fade",controls:["dots","arrows"],placeholder:"-",multiple:{count:1},alwaysShowArrow:!1},c([v,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],n.prototype,"prepareAutoSlide",null),c([v,o("design:type",Function),o("design:paramtypes",[String]),o("design:returntype",void 0)],n.prototype,"autoSlide",null),c([v,o("design:type",Function),o("design:paramtypes",[String,String]),o("design:returntype",Promise)],n.prototype,"transitFramesTowards",null),c([v,o("design:type",Function),o("design:paramtypes",[String]),o("design:returntype",void 0)],n.prototype,"getFrameId",null),c([v,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],n.prototype,"next",null),c([v,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],n.prototype,"prev",null),c([v,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],n.prototype,"clearAutoTimeout",null),c([v,o("design:type",Function),o("design:paramtypes",[Number]),o("design:returntype",Promise)],n.prototype,"changeSlide",null),c([v,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],n.prototype,"handleMouseEnter",null),c([v,o("design:type",Function),o("design:paramtypes",[]),o("design:returntype",void 0)],n.prototype,"handleMouseLeave",null),n}(i.Component),Ne=function(u){$(n,u);function n(e,r){var t=u.call(this,e)||this,a=r;return a.registerComponent(t),t}return n.prototype.componentWillUnmount=function(){var e;(e=u.prototype.componentWillUnmount)===null||e===void 0||e.call(this);var r=this.context;r.unRegisterComponent(this)},n.contextType=ge,n=c([fe({type:"carousel"}),o("design:paramtypes",[Object,Object])],n),n}(Te);export{Te as Carousel,Ne as CarouselRenderer};
|