{"version":3,"file":"CMSItemsTicker.1o08uvvq.mjs","names":["useState","useRef"],"sources":["https:/framer.com/m/Utlis-SwIN.js@U9vmYX0zDZtz999aDBu4","https:/framerusercontent.com/modules/MEwNH2Jtzb5hmutaeYr3/s0NAuQV3FXizgKMH3FKe/CMSItemsTicker.js"],"sourcesContent":["// new utils\nexport const findQueryInProps=obj=>{if(obj==null)return null;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return obj.query;// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){let result=findQueryInProps(obj[key]);if(result!==null)return result;}}// If `query` is not found\nreturn null;};export const updateQueryInProps=(obj,newQuery)=>{if(obj==null)return obj;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return{...obj,query:newQuery};// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){const updatedChild=updateQueryInProps(obj[key],newQuery);if(updatedChild!==obj[key]){return{...obj,[key]:updatedChild};}}}return obj;};export const findPropsBeforeQuery=obj=>{if(obj==null)return null;// Check if `query` exists in the current level\nif(obj.hasOwnProperty(\"query\"))return obj;// Iterate over the properties\nfor(let key in obj){if(obj.hasOwnProperty(key)&&typeof obj[key]===\"object\"){let result=findPropsBeforeQuery(obj[key]);if(result!==null)return result;}}// If `query` is not found\nreturn null;};\nexport const __FramerMetadata__ = {\"exports\":{\"findQueryInProps\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateQueryInProps\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"findPropsBeforeQuery\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Utlis.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{cloneElement,useEffect,useRef,useState}from\"react\";import{findPropsBeforeQuery}from\"https://framer.com/m/Utlis-SwIN.js@U9vmYX0zDZtz999aDBu4\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight any-prefer-auto\n */export default function CMSItemsTicker(props){const{collectionList,direction,speed,itemSpacing,itemWidth,fixedWidth,draggable}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const clProps=!isCanvas?findPropsBeforeQuery(collectionList?.[0]?.props):undefined;const data=clProps?.query?useQueryData(clProps.query):[];const[renderedItems,setRenderedItems]=useState([]);const tickerRef=useRef(null);const dragStartTime=useRef(0);const dragStartPos=useRef({x:0,y:0});const currentTranslate=useRef(0);const isDragging=useRef(false);const animationFrame=useRef(null);const lastDragPosition=useRef(0);const wrapItem=(item,index)=>{return /*#__PURE__*/_jsx(\"div\",{style:{marginRight:direction===\"left\"||direction===\"right\"?itemSpacing:0,marginBottom:direction===\"up\"||direction===\"down\"?itemSpacing:0,display:direction===\"up\"||direction===\"down\"?\"block\":\"inline-block\",width:itemWidth===\"fixed\"?`${fixedWidth}px`:\"auto\",position:\"relative\",flexShrink:0},onDragStart:e=>e.preventDefault(),children:/*#__PURE__*/cloneElement(item,{style:{...item.props.style,userSelect:\"none\",WebkitUserSelect:\"none\",pointerEvents:isDragging.current?\"none\":\"auto\",width:\"100%\",height:\"100%\"},draggable:false})},index);};useEffect(()=>{if(data&&clProps?.children){const childrenData=clProps.children(data);const items=childrenData?.props?.children||[];if(Array.isArray(items)){const styledItems=items.map(wrapItem);setRenderedItems(styledItems);}else{setRenderedItems([]);}}else{setRenderedItems([]);}},[collectionList,direction,itemSpacing,itemWidth,fixedWidth,data]);const handleMouseDown=e=>{if(!draggable)return;e.preventDefault();isDragging.current=false;dragStartTime.current=Date.now();dragStartPos.current={x:e.clientX,y:e.clientY};lastDragPosition.current=direction===\"left\"||direction===\"right\"?e.clientX:e.clientY;document.addEventListener(\"mousemove\",handleMouseMove);document.addEventListener(\"mouseup\",handleMouseUp);if(animationFrame.current){cancelAnimationFrame(animationFrame.current);}tickerRef.current.style.cursor=\"grabbing\";};const handleMouseMove=e=>{e.preventDefault();const currentPos=direction===\"left\"||direction===\"right\"?e.clientX:e.clientY;const dragDistance=Math.abs(currentPos-lastDragPosition.current);if(!isDragging.current&&dragDistance>5){isDragging.current=true;tickerRef.current.style.pointerEvents=\"none\";}if(isDragging.current){const delta=currentPos-lastDragPosition.current;currentTranslate.current+=delta;const transform=direction===\"left\"||direction===\"right\"?`translateX(${currentTranslate.current}px)`:`translateY(${currentTranslate.current}px)`;tickerRef.current.style.transform=transform;}lastDragPosition.current=currentPos;};const handleMouseUp=e=>{document.removeEventListener(\"mousemove\",handleMouseMove);document.removeEventListener(\"mouseup\",handleMouseUp);const timeDiff=Date.now()-dragStartTime.current;const clickThreshold=200// milliseconds\n;if(timeDiff<clickThreshold&&!isDragging.current){tickerRef.current.style.pointerEvents=\"auto\";}isDragging.current=false;tickerRef.current.style.cursor=\"grab\";tickerRef.current.style.pointerEvents=\"auto\";startAnimation();};const handleTouchStart=e=>{if(!draggable)return;e.preventDefault();isDragging.current=false;dragStartTime.current=Date.now();const touch=e.touches[0];dragStartPos.current={x:touch.clientX,y:touch.clientY};lastDragPosition.current=direction===\"left\"||direction===\"right\"?touch.clientX:touch.clientY;if(animationFrame.current){cancelAnimationFrame(animationFrame.current);}};const handleTouchMove=e=>{e.preventDefault();const touch=e.touches[0];const currentPos=direction===\"left\"||direction===\"right\"?touch.clientX:touch.clientY;const dragDistance=Math.abs(currentPos-lastDragPosition.current);if(!isDragging.current&&dragDistance>5){isDragging.current=true;tickerRef.current.style.pointerEvents=\"none\";}if(isDragging.current){const delta=currentPos-lastDragPosition.current;currentTranslate.current+=delta;const transform=direction===\"left\"||direction===\"right\"?`translateX(${currentTranslate.current}px)`:`translateY(${currentTranslate.current}px)`;tickerRef.current.style.transform=transform;}lastDragPosition.current=currentPos;};const handleTouchEnd=()=>{const timeDiff=Date.now()-dragStartTime.current;const clickThreshold=200;if(timeDiff<clickThreshold&&!isDragging.current){tickerRef.current.style.pointerEvents=\"auto\";}isDragging.current=false;tickerRef.current.style.pointerEvents=\"auto\";startAnimation();};const startAnimation=()=>{const animate=()=>{if(!isDragging.current&&tickerRef.current){const scrollSize=direction===\"left\"||direction===\"right\"?tickerRef.current.scrollWidth/2:tickerRef.current.scrollHeight/2;if(direction===\"left\"||direction===\"up\"){currentTranslate.current-=speed;if(Math.abs(currentTranslate.current)>=scrollSize){currentTranslate.current+=scrollSize;}}else{currentTranslate.current+=speed;if(currentTranslate.current>=0){currentTranslate.current-=scrollSize;}}const transform=direction===\"left\"||direction===\"right\"?`translateX(${currentTranslate.current}px)`:`translateY(${currentTranslate.current}px)`;tickerRef.current.style.transform=transform;}animationFrame.current=requestAnimationFrame(animate);};animate();};useEffect(()=>{if(renderedItems.length>0){startAnimation();}return()=>{if(animationFrame.current){cancelAnimationFrame(animationFrame.current);}};},[renderedItems.length,direction,speed]);const containerStyle={...props.style,overflow:\"hidden\",whiteSpace:direction===\"up\"||direction===\"down\"?\"normal\":\"nowrap\"};const tickerStyle={display:direction===\"up\"||direction===\"down\"?\"block\":\"inline-flex\",alignItems:\"center\",cursor:draggable?\"grab\":\"default\",userSelect:\"none\",WebkitUserSelect:\"none\",touchAction:\"none\",willChange:\"transform\",position:\"relative\"};if(isCanvas){containerStyle.padding=10;containerStyle.border=\"1px dashed #594FEE\";containerStyle.borderRadius=\"8px\";containerStyle.backgroundColor=\"#EEEDFD\";}return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:isCanvas?renderedItems.length>0?/*#__PURE__*/_jsx(\"div\",{style:tickerStyle,children:renderedItems}):/*#__PURE__*/_jsx(\"div\",{style:{color:\"#594FEE\",padding:\"20px\",textAlign:\"center\",fontFamily:\"Arial, sans-serif\"},children:\"CMS Ticker - Connect, configure and preview to see the component\"}):renderedItems.length>0?/*#__PURE__*/_jsxs(\"div\",{ref:tickerRef,style:tickerStyle,onMouseDown:handleMouseDown,onTouchStart:handleTouchStart,onTouchMove:handleTouchMove,onTouchEnd:handleTouchEnd,children:[renderedItems,renderedItems]}):/*#__PURE__*/_jsx(\"div\",{children:\"Segment\"})});}CMSItemsTicker.displayName=\"CMS Items Ticker\";addPropertyControls(CMSItemsTicker,{collectionList:{type:ControlType.ComponentInstance,description:\"Please ensure that the CMS item that you are connecting to is vertically stacked\"},direction:{type:ControlType.Enum,defaultValue:\"left\",options:[\"left\",\"right\",\"up\",\"down\"],displaySegmentedControl:true},speed:{type:ControlType.Number,defaultValue:1,min:0,max:10,displayStepper:true},itemSpacing:{type:ControlType.Number,defaultValue:20,min:0},itemWidth:{type:ControlType.Enum,defaultValue:\"auto\",options:[\"auto\",\"fixed\"],optionTitles:[\"Auto\",\"Fixed\"],displaySegmentedControl:true},fixedWidth:{type:ControlType.Number,defaultValue:200,min:1,max:1e3,displayStepper:true,hidden:({itemWidth})=>itemWidth!==\"fixed\"},draggable:{type:ControlType.Boolean,defaultValue:false,description:\"v2.1 \\n[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSItemsTicker\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"600\",\"framerSupportedLayoutHeight\":\"any-prefer-auto\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CMSItemsTicker.map"],"mappings":"oVAMgO,EAAqB,GAAK,CAAC,GAAG,GAAK,KAAK,OAAO,KAC/Q,GAAG,EAAI,eAAe,SAAS,OAAO,EACtC,IAAI,IAAI,KAAO,EAAK,GAAG,EAAI,eAAe,IAAM,OAAO,EAAI,IAAO,SAAS,CAAC,IAAI,EAAO,EAAqB,EAAI,IAAM,GAAG,IAAS,KAAK,OA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