{"version":3,"file":"ResponsiveCardCarousel.CFtmTWRv.mjs","names":["React.useRef","React.useState","React.useMemo","React.useCallback"],"sources":["https:/framerusercontent.com/modules/cLFUh6OnKfX0G9m9GdFc/Vq6M5v8KF25AdNH3I7JN/ResponsiveCardCarousel.js"],"sourcesContent":["// Build a Framer Code Component: Responsive Card Carousel\n// Never use ControlType.Array with nested ControlType.ComponentInstance — it breaks. Use a single repeated slot pattern instead.\n// Card slots: Use ControlType.Array with ControlType.ComponentInstance.\n// Desktop (≥768px): grid columns = numCards, stretch heights, no fixed heights, no slider.\n// Mobile (<768px): horizontal swipe slider using Framer Motion useAnimation and onDragEnd-style snapping (no drag=\"x\"), dots (mobile only).\n// Layout detection via ResizeObserver + forceLayout override.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,useAnimation,useMotionValue}from\"framer-motion\";function clamp(n,min,max){return Math.max(min,Math.min(max,n));}function fillNode(node){if(!/*#__PURE__*/React.isValidElement(node))return node;const existingStyle=node.props?.style||{};return /*#__PURE__*/React.cloneElement(node,{style:{...existingStyle,width:\"100%\",height:\"100%\"}});}/**\n * Responsive Card Carousel\n *\n * @framerIntrinsicWidth 800\n * @framerIntrinsicHeight 320\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function ResponsiveCardCarousel(props){const{cards,forceLayout,showDots,dotSize,dotColor,dotActiveColor,cardGap,dotsPadding,style}=props;const isStatic=useIsStaticRenderer();const containerRef=React.useRef(null);const[containerWidth,setContainerWidth]=React.useState(0);const[activeIndex,setActiveIndex]=React.useState(0);const controls=useAnimation();const x=useMotionValue(0);const[isDragging,setIsDragging]=React.useState(false);const dragStartXRef=React.useRef(0);const startOffsetXRef=React.useRef(0);const count=Math.max(0,cards?.length??0);React.useEffect(()=>{if(typeof window===\"undefined\")return;if(!containerRef.current)return;const el=containerRef.current;const ro=new ResizeObserver(entries=>{const entry=entries[0];const w=entry?.contentRect?.width;if(typeof w===\"number\"&&Number.isFinite(w)){React.startTransition(()=>setContainerWidth(w));}});ro.observe(el);return()=>ro.disconnect();},[]);const layout=React.useMemo(()=>{if(forceLayout===\"desktop\"||forceLayout===\"mobile\")return forceLayout;return containerWidth>=768?\"desktop\":\"mobile\";},[forceLayout,containerWidth]);const mobileStep=React.useMemo(()=>{// Card is 90vw, based on container width.\nconst w=containerWidth>0?containerWidth*.9:0;return w+cardGap;},[containerWidth,cardGap]);const snapToIndex=React.useCallback(async(nextIndex,animated)=>{const clamped=clamp(nextIndex,0,Math.max(0,count-1));React.startTransition(()=>setActiveIndex(clamped));if(layout!==\"mobile\")return;if(mobileStep<=0)return;const targetX=-clamped*mobileStep;if(!animated||isStatic){x.set(targetX);return;}await controls.start({x:targetX,transition:{type:\"spring\",stiffness:320,damping:34,mass:.8}});},[controls,count,isStatic,layout,mobileStep,x]);// Keep x in sync if width changes or cards count changes.\nReact.useEffect(()=>{if(layout!==\"mobile\")return;if(count<=0){x.set(0);return;}const clamped=clamp(activeIndex,0,count-1);if(clamped!==activeIndex){React.startTransition(()=>setActiveIndex(clamped));}if(mobileStep>0){x.set(-clamped*mobileStep);}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[layout,count,mobileStep]);const onPointerDown=React.useCallback(e=>{if(isStatic)return;if(layout!==\"mobile\")return;if(count<=1)return;e.currentTarget.setPointerCapture?.(e.pointerId);controls.stop();dragStartXRef.current=e.clientX;startOffsetXRef.current=x.get();React.startTransition(()=>setIsDragging(true));},[controls,count,isStatic,layout,x]);const onPointerMove=React.useCallback(e=>{if(!isDragging)return;if(layout!==\"mobile\")return;if(count<=1)return;if(mobileStep<=0)return;const delta=e.clientX-dragStartXRef.current;const raw=startOffsetXRef.current+delta;// Rubber-band-ish clamp.\nconst minX=-(count-1)*mobileStep;const maxX=0;const clamped=clamp(raw,minX-mobileStep*.25,maxX+mobileStep*.25);x.set(clamped);},[count,isDragging,layout,mobileStep,x]);const onPointerUp=React.useCallback(async e=>{if(!isDragging)return;React.startTransition(()=>setIsDragging(false));if(isStatic)return;if(layout!==\"mobile\")return;if(count<=1)return;if(mobileStep<=0)return;const delta=e.clientX-dragStartXRef.current;const threshold=mobileStep*.18;let next=activeIndex;if(Math.abs(delta)>threshold){next=delta<0?activeIndex+1:activeIndex-1;}else{// If it's a small drag, snap to closest based on current x.\nconst currentX=x.get();next=Math.round(-currentX/mobileStep);}await snapToIndex(next,true);},[activeIndex,count,isDragging,isStatic,layout,mobileStep,snapToIndex,x]);const dots=React.useMemo(()=>{if(!showDots)return null;if(layout!==\"mobile\")return null;if(count<=1)return null;return /*#__PURE__*/_jsx(\"div\",{style:{marginTop:dotsPadding,width:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",gap:Math.max(6,Math.round(dotSize*.9))},\"aria-label\":\"Carousel pagination\",role:\"tablist\",children:new Array(count).fill(0).map((_,i)=>{const isActive=i===activeIndex;return /*#__PURE__*/_jsx(\"div\",{role:\"tab\",\"aria-selected\":isActive,style:{width:dotSize,height:dotSize,borderRadius:\"50%\",background:isActive?dotActiveColor:dotColor,opacity:isActive?1:.7,transition:\"opacity 150ms ease\"}},i);})});},[activeIndex,count,dotActiveColor,dotColor,dotSize,dotsPadding,layout,showDots]);if(count===0){return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",color:\"rgba(0,0,0,0.5)\",background:\"rgba(0,0,0,0.04)\",borderRadius:8,padding:16,boxSizing:\"border-box\"},\"aria-label\":\"Card carousel empty state\",children:\"Connect at least one card instance.\"});}if(layout===\"desktop\"){return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",display:\"grid\",gridTemplateColumns:`repeat(${count}, 1fr)`,alignItems:\"start\",gap:cardGap,boxSizing:\"border-box\"},\"aria-label\":\"Card carousel grid\",children:cards.map((node,i)=>/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"column\",height:\"100%\",width:\"100%\",minWidth:0,minHeight:0,alignSelf:\"flex-start\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",flex:1,minHeight:0,minWidth:0},children:fillNode(node)})},i))});}// Mobile\nconst cardWidth=containerWidth>0?containerWidth*.9:\"90%\";return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{...style,position:\"relative\",width:\"100%\",height:\"100%\",boxSizing:\"border-box\"},\"aria-label\":\"Card carousel\",children:[/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",overflow:\"visible\",boxSizing:\"border-box\",touchAction:\"pan-y\"},children:/*#__PURE__*/_jsx(motion.div,{style:{display:\"flex\",alignItems:\"stretch\",gap:cardGap,height:\"100%\",x,willChange:isDragging?\"transform\":undefined,cursor:isDragging?\"grabbing\":\"grab\",userSelect:\"none\"},animate:controls,onPointerDown:onPointerDown,onPointerMove:onPointerMove,onPointerUp:onPointerUp,onPointerCancel:onPointerUp,role:\"group\",\"aria-roledescription\":\"carousel\",\"aria-live\":\"polite\",children:cards.map((node,i)=>/*#__PURE__*/_jsx(\"div\",{style:{width:cardWidth,flexShrink:0,display:\"flex\",flexDirection:\"column\",minHeight:0,minWidth:0},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\",flex:1,minHeight:0,minWidth:0},children:fillNode(node)})},i))})}),dots]});}addPropertyControls(ResponsiveCardCarousel,{cards:{type:ControlType.Array,title:\"Cards\",control:{type:ControlType.ComponentInstance,title:\"Card\"},defaultValue:[undefined],maxCount:50},forceLayout:{type:ControlType.Enum,title:\"Preview Layout\",options:[\"auto\",\"desktop\",\"mobile\"],defaultValue:\"auto\",displaySegmentedControl:true,optionTitles:[\"Auto\",\"Desktop\",\"Mobile\"]},showDots:{type:ControlType.Boolean,title:\"Show Dots\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},dotSize:{type:ControlType.Number,title:\"Dot Size\",defaultValue:8,min:4,max:24,step:1,unit:\"px\"},dotColor:{type:ControlType.Color,title:\"Dot Color\",defaultValue:\"rgba(255,255,255,0.3)\"},dotActiveColor:{type:ControlType.Color,title:\"Dot Active Color\",defaultValue:\"rgba(255,255,255,1)\"},cardGap:{type:ControlType.Number,title:\"Card Gap\",defaultValue:16,min:0,max:80,step:1,unit:\"px\"},dotsPadding:{type:ControlType.Number,title:\"Dots Padding Top\",defaultValue:24,min:0,max:120,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ResponsiveCardCarousel\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"800\",\"framerIntrinsicHeight\":\"320\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ResponsiveCardCarousel.map"],"mappings":"mTAM2N,SAAS,EAAM,EAAE,EAAI,EAAI,CAAC,OAAO,KAAK,IAAI,EAAI,KAAK,IAAI,EAAI,CAAC,CAAC,CAAE,CAAC,SAAS,EAAS,EAAK,CAAmG,OAAjF,EAAqB,CAAI,EAA4E,EAAmB,EAAK,CAAC,MAAM,CAAC,GAA1E,EAAK,OAAO,OAAO,CAAC,EAAuE,MAAM,OAAO,OAAO,MAAM,CAAC,CAAC,EAAhJ,CAAkJ,CAQrf,SAAwB,EAAuB,EAAM,CAAC,GAAK,CAAC,QAAM,cAAY,WAAS,UAAQ,WAAS,iBAAe,UAAQ,cAAY,SAAO,EAAY,EAAS,EAAoB,EAAQ,EAAaA,EAAa,IAAI,EAAO,CAAC,EAAe,GAAmBC,EAAe,CAAC,EAAO,CAAC,EAAY,GAAgBA,EAAe,CAAC,EAAQ,EAAS,EAAa,EAAQ,EA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