{"version":3,"file":"ScrollPagination.CyJ75bMb.mjs","names":["useRef","useState","padding"],"sources":["https:/framerusercontent.com/modules/2P6KdmeSURv32Ow7xNz6/GAkyYEqWwLqGqOyt3Avm/ScrollPagination.js"],"sourcesContent":["// X-Axis Scroll with Arrow Pagination and Adaptive Height\n// Horizontally scrollable area with left/right arrow buttons for pagination. Arrows are disabled at scroll edges. Content height adapts to children.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useState,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * X-Axis Scroll with Arrow Pagination (Adaptive Height)\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function ScrollPagination(props){const{children,background,arrowColor,arrowBg,arrowDisabledColor,arrowSize,gap,padding,style}=props;const scrollRef=useRef(null);const[canScrollLeft,setCanScrollLeft]=useState(false);const[canScrollRight,setCanScrollRight]=useState(false);const[itemCount,setItemCount]=useState(0);useEffect(()=>{// Count children for snapping\nif(Array.isArray(children))setItemCount(children.length);else if(children)setItemCount(1);else setItemCount(0);},[children]);// Update arrow enabled/disabled state\nconst updateScrollState=()=>{const el=scrollRef.current;if(!el)return;startTransition(()=>{setCanScrollLeft(el.scrollLeft>0);// Right arrow disables when scrolled to end (allowing for floating point error)\nconst epsilon=2;setCanScrollRight(el.scrollLeft+el.clientWidth<el.scrollWidth-epsilon);});};useEffect(()=>{updateScrollState();const el=scrollRef.current;if(!el)return;el.addEventListener(\"scroll\",updateScrollState);window.addEventListener(\"resize\",updateScrollState);return()=>{el.removeEventListener(\"scroll\",updateScrollState);window.removeEventListener(\"resize\",updateScrollState);};},[itemCount,gap]);// Snap to the next/previous item based on scroll position and item edges\n// Helper to parse left padding from CSS shorthand\nfunction getLeftPadding(padding){if(!padding)return 0;const parts=padding.trim().split(/\\s+/);if(parts.length===1)return parseInt(parts[0])||0;if(parts.length===2)return parseInt(parts[1])||0;if(parts.length===3)return parseInt(parts[1])||0;if(parts.length===4)return parseInt(parts[3])||0;return 0;}const scrollBy=dir=>{const el=scrollRef.current;if(!el)return;const container=el.querySelector(\"div\");if(!container)return;const items=Array.from(container.children);if(!items.length)return;const scrollLeft=el.scrollLeft;const leftPad=getLeftPadding(padding);if(dir===\"right\"){// If at the very start, always jump to the second item (if it exists)\nif(scrollLeft===0&&items.length>1){el.scrollTo({left:items[1].offsetLeft-leftPad,behavior:\"smooth\"});return;}// Find the first item whose left edge is greater than scrollLeft + 1\nfor(let i=0;i<items.length;i++){if(items[i].offsetLeft>scrollLeft+leftPad+1){el.scrollTo({left:items[i].offsetLeft-leftPad,behavior:\"smooth\"});return;}}// If none found, scroll to end\nel.scrollTo({left:el.scrollWidth-el.clientWidth,behavior:\"smooth\"});}else{// Find the last item whose left edge is less than scrollLeft - 1 (snap to previous item)\nlet prevIndex=-1;for(let i=0;i<items.length;i++){if(items[i].offsetLeft<scrollLeft+leftPad-1){prevIndex=i;}}if(prevIndex>=0){el.scrollTo({left:items[prevIndex].offsetLeft-leftPad,behavior:\"smooth\"});return;}// If none found, scroll to start\nel.scrollTo({left:0,behavior:\"smooth\"});}};const Pagination=/*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",display:\"flex\",justifyContent:\"flex-end\",gap:props.paginationArrowGap,marginTop:16,paddingRight:props.paginationPaddingRight,paddingLeft:props.paginationPaddingLeft,paddingTop:props.paginationPaddingTop,paddingBottom:props.paginationPaddingBottom},children:[/*#__PURE__*/_jsx(\"button\",{\"aria-label\":\"Scroll left\",disabled:!canScrollLeft,onClick:()=>scrollBy(\"left\"),style:{width:arrowSize,height:arrowSize,minWidth:arrowSize,minHeight:arrowSize,border:\"none\",borderRadius:\"50%\",background:arrowBg,color:arrowColor,opacity:canScrollLeft?1:.2,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",cursor:canScrollLeft?\"pointer\":\"not-allowed\",transition:\"background 0.2s, color 0.2s, opacity 0.2s\"},children:/*#__PURE__*/_jsx(\"svg\",{width:arrowSize*.6,height:arrowSize*.6,viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:/*#__PURE__*/_jsx(\"polyline\",{points:\"15 18 9 12 15 6\"})})}),/*#__PURE__*/_jsx(\"button\",{\"aria-label\":\"Scroll right\",disabled:!canScrollRight,onClick:()=>scrollBy(\"right\"),style:{width:arrowSize,height:arrowSize,minWidth:arrowSize,minHeight:arrowSize,border:\"none\",borderRadius:\"50%\",background:arrowBg,color:arrowColor,opacity:canScrollRight?1:.2,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",cursor:canScrollRight?\"pointer\":\"not-allowed\",transition:\"background 0.2s, color 0.2s, opacity 0.2s\"},children:/*#__PURE__*/_jsx(\"svg\",{width:arrowSize*.6,height:arrowSize*.6,viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:/*#__PURE__*/_jsx(\"polyline\",{points:\"9 18 15 12 9 6\"})})})]});return /*#__PURE__*/_jsxs(\"div\",{style:{...style,position:\"relative\",width:\"100%\",background,overflow:\"visible\",display:\"flex\",flexDirection:\"column\",alignItems:\"stretch\"},children:[props.paginationPosition===\"above\"&&Pagination,/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",display:\"flex\",flexDirection:\"row\",justifyContent:\"flex-start\"},children:/*#__PURE__*/_jsx(\"div\",{ref:scrollRef,style:{width:\"100%\",overflowX:\"auto\",overflowY:\"visible\",display:\"flex\",gap,padding,scrollBehavior:\"smooth\",scrollbarWidth:\"none\",msOverflowStyle:\"none\",alignItems:\"stretch\"},tabIndex:0,\"aria-label\":\"Horizontal scroll area\",children:/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",gap,scrollSnapType:\"x mandatory\",alignItems:\"stretch\"},children:Array.isArray(children)?children.map((child,i)=>/*#__PURE__*/_jsx(\"div\",{style:{width:\"max-content\",borderRadius:8,overflow:\"visible\",scrollSnapAlign:\"start\",flex:\"0 0 auto\",display:\"flex\",alignItems:\"stretch\",justifyContent:\"center\"},children:child},i)):children&&/*#__PURE__*/_jsx(\"div\",{style:{width:\"max-content\",borderRadius:8,overflow:\"visible\",scrollSnapAlign:\"start\",flex:\"0 0 auto\",display:\"flex\",alignItems:\"stretch\",justifyContent:\"center\"},children:children})})})}),props.paginationPosition===\"below\"&&Pagination]});}addPropertyControls(ScrollPagination,{background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},arrowColor:{type:ControlType.Color,title:\"Arrow Color\",defaultValue:\"#222222\"},arrowBg:{type:ControlType.Color,title:\"Arrow BG\",defaultValue:\"#F5F5F5\"},arrowDisabledColor:{type:ControlType.Color,title:\"Arrow Disabled\",defaultValue:\"#EEEEEE\"},arrowSize:{type:ControlType.Number,title:\"Arrow Size\",defaultValue:36,min:24,max:64,step:1,unit:\"px\"},gap:{type:ControlType.Number,title:\"Item Gap\",defaultValue:16,min:0,max:64,step:1,unit:\"px\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"20px 16px 16px 20px\"},paginationPaddingRight:{type:ControlType.Number,title:\"Pagination Right\",defaultValue:60,min:0,max:200,step:1,unit:\"px\"},paginationPaddingLeft:{type:ControlType.Number,title:\"Pagination Left\",defaultValue:0,min:0,max:200,step:1,unit:\"px\"},paginationPaddingTop:{type:ControlType.Number,title:\"Pagination Top\",defaultValue:0,min:0,max:200,step:1,unit:\"px\"},paginationPaddingBottom:{type:ControlType.Number,title:\"Pagination Bottom\",defaultValue:0,min:0,max:200,step:1,unit:\"px\"},paginationPosition:{type:ControlType.Enum,title:\"Pagination Position\",options:[\"below\",\"above\"],optionTitles:[\"Below\",\"Above\"],defaultValue:\"below\",displaySegmentedControl:true},paginationArrowGap:{type:ControlType.Number,title:\"Arrow Gap\",defaultValue:8,min:0,max:64,step:1,unit:\"px\"},children:{type:ControlType.Slot,title:\"Content\",maxCount:10}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ScrollPagination\",\"slots\":[\"children\"],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ScrollPagination.map"],"mappings":"oNAOG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,WAAS,aAAW,aAAW,UAAQ,qBAAmB,YAAU,MAAI,UAAQ,SAAO,EAAY,EAAUA,EAAO,KAAK,CAAM,CAAC,EAAc,GAAkBC,EAAS,GAAM,CAAM,CAAC,EAAe,GAAmBA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAC,MAAc,CAC9T,EAAxB,MAAM,QAAQ,EAAS,CAAc,EAAS,OAAgB,EAAsB,EAAqB,EAAE,EAAG,CAAC,EAAS,CAAC,CAC5H,IAAM,MAAsB,CAAC,IAAM,EAAG,EAAU,QAAY,GAAU,MAAoB,CAAC,EAAiB,EAAG,WAAW,EAAE,CAC5G,EAAkB,EAAG,WAAW,EAAG,YAAY,EAAG,YAApD,EAAwE,EAAG,EAAG,MAAc,CAAC,GAAmB,CAAC,IAAM,EAAG,EAAU,QAAY,KAA8G,OAApG,EAAG,iBAAiB,SAAS,EAAkB,CAAC,EAAO,iBAAiB,SAAS,EAAkB,KAAW,CAAC,EAAG,oBAAoB,SAAS,EAAkB,CAAC,EAAO,oBAAoB,SAAS,EAAkB,GAAK,CAAC,EAAU,EAAI,CAAC,CAErZ,SAAS,EAAe,EAAQ,CAAC,GAAG,CAACC,EAAQ,MAAO,GAAE,IAAM,EAAMA,EAAQ,MAAM,CAAC,MAAM,MAAM,CAAqM,OAAjM,EAAM,SAAS,EAAS,SAAS,EAAM,GAAG,EAAE,EAAK,EAAM,SAAS,GAAkC,EAAM,SAAS,EAAS,SAAS,EAAM,GAAG,EAAE,EAAK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