{"version":3,"file":"ImageTextSlider.BEYAnpsF.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/I4VndHmWoF8NfiH6E5kt/N8sFqlX6sibuRWc23fWu/ImageTextSlider.js"],"sourcesContent":["// Slider avec slides personnalisables, navigation par flèches, drag, et preview de la slide suivante\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useState,useCallback,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{motion,useMotionValue,animate}from\"framer-motion\";/**\n * Card Slider avec preview de la slide suivante\n *\n * @framerIntrinsicWidth 1200\n * @framerIntrinsicHeight 600\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function ImageTextSlider(props){const{slides=[],slideWidth=800,slideHeight=600,gap=20,arrowColor=\"#000000\",arrowSize=40,arrowPosition=20,previewAmount=150,transition={type:\"spring\",stiffness:300,damping:30},mobileBreakpoint=768,arrowRightPadding=100}=props;const[currentIndex,setCurrentIndex]=useState(0);const x=useMotionValue(0);const containerRef=useRef(null);const[isDragging,setIsDragging]=useState(false);const dragStartX=useRef(0);const dragStartPos=useRef(0);const[isMobile,setIsMobile]=useState(false);const hasDragged=useRef(false);const totalSlides=slides.length;const maxIndex=Math.max(0,totalSlides-1);// Calculer la position x pour chaque index\nconst getXForIndex=useCallback(index=>{return-index*(slideWidth+gap);},[slideWidth,gap]);// Navigation\nconst goToSlide=useCallback(index=>{const clampedIndex=Math.max(0,Math.min(maxIndex,index));startTransition(()=>setCurrentIndex(clampedIndex));animate(x,getXForIndex(clampedIndex),transition);},[maxIndex,x,getXForIndex,transition]);const goToNext=useCallback(()=>{if(currentIndex<maxIndex){goToSlide(currentIndex+1);}},[currentIndex,maxIndex,goToSlide]);const goToPrev=useCallback(()=>{if(currentIndex>0){goToSlide(currentIndex-1);}},[currentIndex,goToSlide]);// Gestion du drag personnalisé\nconst handleMouseDown=useCallback(e=>{setIsDragging(true);hasDragged.current=false;dragStartX.current=e.clientX;dragStartPos.current=x.get();},[x]);const handleMouseMove=useCallback(e=>{if(!isDragging)return;const deltaX=e.clientX-dragStartX.current;if(Math.abs(deltaX)>5){hasDragged.current=true;}x.set(dragStartPos.current+deltaX);},[isDragging,x]);const handleMouseUp=useCallback(e=>{if(!isDragging)return;setIsDragging(false);const deltaX=e.clientX-dragStartX.current;const threshold=50// Seuil minimum pour changer de slide\n;if(deltaX>threshold&&currentIndex>0){// Drag vers la droite = slide précédente\ngoToSlide(currentIndex-1);}else if(deltaX<-threshold&&currentIndex<maxIndex){// Drag vers la gauche = slide suivante\ngoToSlide(currentIndex+1);}else{// Revenir à la position actuelle\ngoToSlide(currentIndex);}},[isDragging,currentIndex,maxIndex,goToSlide]);// Gestion du drag tactile (mobile)\nconst handleTouchStart=useCallback(e=>{setIsDragging(true);hasDragged.current=false;dragStartX.current=e.touches[0].clientX;dragStartPos.current=x.get();},[x]);const handleTouchMove=useCallback(e=>{if(!isDragging)return;const deltaX=e.touches[0].clientX-dragStartX.current;if(Math.abs(deltaX)>5){hasDragged.current=true;}x.set(dragStartPos.current+deltaX);},[isDragging,x]);const handleTouchEnd=useCallback(e=>{if(!isDragging)return;setIsDragging(false);const deltaX=e.changedTouches[0].clientX-dragStartX.current;const threshold=50// Seuil minimum pour changer de slide\n;if(deltaX>threshold&&currentIndex>0){// Drag vers la droite = slide précédente\ngoToSlide(currentIndex-1);}else if(deltaX<-threshold&&currentIndex<maxIndex){// Drag vers la gauche = slide suivante\ngoToSlide(currentIndex+1);}else{// Revenir à la position actuelle\ngoToSlide(currentIndex);}},[isDragging,currentIndex,maxIndex,goToSlide]);// Ajouter les event listeners\nuseEffect(()=>{if(isDragging){window.addEventListener(\"mousemove\",handleMouseMove);window.addEventListener(\"mouseup\",handleMouseUp);window.addEventListener(\"touchmove\",handleTouchMove);window.addEventListener(\"touchend\",handleTouchEnd);return()=>{window.removeEventListener(\"mousemove\",handleMouseMove);window.removeEventListener(\"mouseup\",handleMouseUp);window.removeEventListener(\"touchmove\",handleTouchMove);window.removeEventListener(\"touchend\",handleTouchEnd);};}},[isDragging,handleMouseMove,handleMouseUp,handleTouchMove,handleTouchEnd]);// Empêcher les clics si on a dragué\nconst handleClick=useCallback(e=>{if(hasDragged.current){e.preventDefault();e.stopPropagation();}},[]);// Initialiser la position\nuseEffect(()=>{x.set(getXForIndex(currentIndex));},[]);// Détecter si on est en mode mobile\nuseEffect(()=>{const checkMobile=()=>{if(typeof window!==\"undefined\"){startTransition(()=>setIsMobile(window.innerWidth<=mobileBreakpoint));}};checkMobile();if(typeof window!==\"undefined\"){window.addEventListener(\"resize\",checkMobile);return()=>window.removeEventListener(\"resize\",checkMobile);}},[mobileBreakpoint]);const containerWidth=props.style?.width===\"100%\"?\"100%\":slideWidth+previewAmount;// Mode mobile : affichage vertical\nif(isMobile){return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",width:\"100%\",display:\"flex\",flexDirection:\"column\",gap:`${gap}px`,overflow:\"visible\"},children:slides.map((slide,index)=>/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"auto\",position:\"relative\"},children:slide},index))});}return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{position:\"relative\",width:containerWidth,height:slideHeight+arrowSize+24,overflow:\"visible\",display:\"flex\",flexDirection:\"column\",gap:\"24px\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:`${arrowSize}px`,display:\"flex\",gap:\"24px\",justifyContent:\"flex-end\",zIndex:10,paddingRight:`${arrowRightPadding}px`},children:[/*#__PURE__*/_jsx(\"button\",{onClick:goToPrev,disabled:currentIndex===0,style:{width:`${arrowSize}px`,height:`${arrowSize}px`,background:\"transparent\",border:\"none\",cursor:currentIndex===0?\"default\":\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:0,opacity:currentIndex===0?.3:1,transform:\"rotate(180deg)\"},\"aria-label\":\"Previous slide\",children:/*#__PURE__*/_jsxs(\"svg\",{width:arrowSize,height:arrowSize,viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:[/*#__PURE__*/_jsx(\"title\",{children:\"Previous\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M3 12H21M21 12L14 5M21 12L14 19\",stroke:arrowColor,strokeWidth:\"1.5\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})]})}),/*#__PURE__*/_jsx(\"button\",{onClick:goToNext,disabled:currentIndex>=maxIndex,style:{width:`${arrowSize}px`,height:`${arrowSize}px`,background:\"transparent\",border:\"none\",cursor:currentIndex>=maxIndex?\"default\":\"pointer\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",padding:0,opacity:currentIndex>=maxIndex?.3:1},\"aria-label\":\"Next slide\",children:/*#__PURE__*/_jsxs(\"svg\",{width:arrowSize,height:arrowSize,viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",children:[/*#__PURE__*/_jsx(\"title\",{children:\"Next\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M3 12H21M21 12L14 5M21 12L14 19\",stroke:arrowColor,strokeWidth:\"1.5\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})]})})]}),/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:slideHeight,overflow:\"visible\",position:\"relative\"},children:/*#__PURE__*/_jsx(motion.div,{onMouseDown:handleMouseDown,onTouchStart:handleTouchStart,onClick:handleClick,style:{display:\"flex\",gap:`${gap}px`,x,cursor:isDragging?\"grabbing\":\"grab\",height:slideHeight},children:slides.map((slide,index)=>/*#__PURE__*/_jsx(\"div\",{onClick:handleClick,style:{minWidth:`${slideWidth}px`,width:`${slideWidth}px`,height:`${slideHeight}px`,position:\"relative\",userSelect:\"none\",pointerEvents:isDragging?\"none\":\"auto\"},children:slide},index))})})]});}addPropertyControls(ImageTextSlider,{slides:{type:ControlType.Array,title:\"Slides\",control:{type:ControlType.ComponentInstance},maxCount:10},slideWidth:{type:ControlType.Number,title:\"Slide Width\",defaultValue:800,min:200,max:2e3,step:10,unit:\"px\"},slideHeight:{type:ControlType.Number,title:\"Slide Height\",defaultValue:600,min:200,max:1200,step:10,unit:\"px\"},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:20,min:0,max:100,step:5,unit:\"px\"},previewAmount:{type:ControlType.Number,title:\"Preview Amount\",defaultValue:150,min:0,max:500,step:10,unit:\"px\"},arrowColor:{type:ControlType.Color,title:\"Arrow Color\",defaultValue:\"#000000\"},arrowSize:{type:ControlType.Number,title:\"Arrow Size\",defaultValue:40,min:20,max:80,step:5,unit:\"px\"},arrowPosition:{type:ControlType.Number,title:\"Arrow Position\",defaultValue:20,min:0,max:100,step:5,unit:\"px\"},transition:{type:ControlType.Transition,title:\"Transition\"},arrowRightPadding:{type:ControlType.Number,title:\"Arrow Right Padding\",defaultValue:100,min:0,max:300,step:10,unit:\"px\"},mobileBreakpoint:{type:ControlType.Number,title:\"Mobile Breakpoint\",defaultValue:768,min:320,max:1024,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ImageTextSlider\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"600\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"1200\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ImageTextSlider.map"],"mappings":"0RASG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,SAAO,EAAE,CAAC,aAAW,IAAI,cAAY,IAAI,MAAI,GAAG,aAAW,UAAU,YAAU,GAAG,gBAAc,GAAG,gBAAc,IAAI,aAAW,CAAC,KAAK,SAAS,UAAU,IAAI,QAAQ,GAAG,CAAC,mBAAiB,IAAI,oBAAkB,KAAK,EAAW,CAAC,EAAa,GAAiBA,EAAS,EAAE,CAAO,EAAE,EAAe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