{"version":3,"file":"NumberRoller.B77jUIxN.mjs","names":["useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/D6xea0F3WDjb9MmqkWUn/we8tNThuJyIj3aO1t858/NumberRoller.js"],"sourcesContent":["// Animated number counter with customizable prefix/suffix and individual styling\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef,useMemo,startTransition}from\"react\";import{motion,useInView,useMotionValue,useTransform,animate}from\"framer-motion\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Animated Number Counter\n *\n * A component that animates numbers rolling from 0 to target value with customizable prefix/suffix\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NumberRoller(props){const{targetNumber=100,prefix=\"\",suffix=\"%\",duration=2,delay=0,easing=\"easeOut\",startOnView=true,numberFont,prefixFont,suffixFont,numberColor=\"#000000\",prefixColor=\"#000000\",suffixColor=\"#000000\",decimalPlaces=0}=props;const[hasStarted,setHasStarted]=useState(false);const isStatic=useIsStaticRenderer();const containerRef=useRef(null);const inView=useInView(containerRef,{once:true});const motionValue=useMotionValue(1);const rounded=useTransform(motionValue,latest=>{// For floating numbers, always show at least 1 decimal place if the target has decimals\nconst hasDecimals=targetNumber%1!==0;const places=hasDecimals&&decimalPlaces===0?1:decimalPlaces;return latest.toFixed(places);});const easingMap={linear:[0,0,1,1],easeIn:[.4,0,1,1],easeOut:[0,0,.2,1],easeInOut:[.4,0,.2,1],bounce:[.68,-.55,.265,1.55]};const shouldStart=useMemo(()=>{if(isStatic)return true;if(!startOnView)return true;return inView;},[isStatic,startOnView,inView]);useEffect(()=>{if(!shouldStart||hasStarted)return;const timer=setTimeout(()=>{startTransition(()=>setHasStarted(true));animate(motionValue,targetNumber,{duration:duration,ease:easingMap[easing]});},delay*1e3);return()=>clearTimeout(timer);},[shouldStart,delay,hasStarted,motionValue,targetNumber,duration,easing]);if(isStatic){return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"baseline\",width:\"max-content\",...props.style},children:[prefix&&/*#__PURE__*/_jsx(\"span\",{style:{color:prefixColor,...prefixFont},children:prefix}),/*#__PURE__*/_jsx(\"span\",{style:{color:numberColor,...numberFont},children:(()=>{// For floating numbers, always show at least 1 decimal place if the target has decimals\nconst hasDecimals=targetNumber%1!==0;const places=hasDecimals&&decimalPlaces===0?1:decimalPlaces;return targetNumber.toFixed(places);})()}),suffix&&/*#__PURE__*/_jsx(\"span\",{style:{color:suffixColor,...suffixFont},children:suffix})]});}return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{display:\"flex\",alignItems:\"baseline\",width:\"max-content\",...props.style},children:[prefix&&/*#__PURE__*/_jsx(\"span\",{style:{color:prefixColor,...prefixFont},children:prefix}),/*#__PURE__*/_jsx(motion.span,{style:{color:numberColor,...numberFont},initial:{opacity:0},animate:hasStarted?{opacity:1}:{opacity:0},transition:{duration:.3},children:rounded}),suffix&&/*#__PURE__*/_jsx(\"span\",{style:{color:suffixColor,...suffixFont},children:suffix})]});}addPropertyControls(NumberRoller,{targetNumber:{type:ControlType.Number,title:\"Target Number\",defaultValue:3.2,min:0,max:1e3,step:.1},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"e.g. $, +, x\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"%\",placeholder:\"e.g. %, K, M\"},decimalPlaces:{type:ControlType.Number,title:\"Decimal Places\",defaultValue:0,min:0,max:3,step:1,displayStepper:true},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:5,step:.1,unit:\"s\"},easing:{type:ControlType.Enum,title:\"Easing\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\",\"bounce\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\",\"Bounce\"],defaultValue:\"easeOut\",displaySegmentedControl:true},startOnView:{type:ControlType.Boolean,title:\"Start on View\",defaultValue:true,enabledTitle:\"On View\",disabledTitle:\"Immediate\"},numberFont:{type:ControlType.Font,title:\"Number Font\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.03em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},prefixFont:{type:ControlType.Font,title:\"Prefix Font\",defaultValue:{fontSize:\"22px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},suffixFont:{type:ControlType.Font,title:\"Suffix Font\",defaultValue:{fontSize:\"22px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},numberColor:{type:ControlType.Color,title:\"Number Color\",defaultValue:\"#000000\"},prefixColor:{type:ControlType.Color,title:\"Prefix Color\",defaultValue:\"#000000\"},suffixColor:{type:ControlType.Color,title:\"Suffix Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberRoller\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberRoller.map"],"mappings":"oSAQG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,eAAa,IAAI,SAAO,GAAG,SAAO,IAAI,WAAS,EAAE,QAAM,EAAE,SAAO,UAAU,cAAY,GAAK,aAAW,aAAW,aAAW,cAAY,UAAU,cAAY,UAAU,cAAY,UAAU,gBAAc,GAAG,EAAW,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAQ,EAAS,EAAoB,EAAQ,EAAaC,EAAO,IAAI,EAAQ,EAAO,EAAU,EAAa,CAAC,KAAK,EAAI,CAAC,EAAQ,EAAY,EAAe,CAAC,EAAQ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