{"version":3,"file":"NumberCounter.DUDFNvSS.mjs","names":["useState","useRef","decimals"],"sources":["https:/framerusercontent.com/modules/k9DzzXa8Oye3M8DbVJgc/uwW73hCzjH0fh45RuMCd/NumberCounter.js"],"sourcesContent":["// Number counter with 3 special character options eg $40M+\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView,useMotionValue,useSpring}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NumberCounter(props){const{targetNumber=40,prefix=\"$\",suffix=\"M+\",duration=2,decimals=0,separator=true,textColor=\"#000000\",useGradient=false,gradientText=\"linear-gradient(90deg, #FF0080, #7928CA, #0070F3)\",font}=props;const[displayValue,setDisplayValue]=useState(\"0\");const ref=useRef(null);const inView=useInView(ref,{once:true});const motionValue=useMotionValue(0);const springValue=useSpring(motionValue,{duration:duration*1e3,bounce:0});const isStatic=useIsStaticRenderer();useEffect(()=>{if(isStatic){setDisplayValue(formatNumber(targetNumber,decimals,separator));return;}if(inView){motionValue.set(targetNumber);}},[inView,targetNumber,motionValue,isStatic,decimals,separator]);useEffect(()=>{if(isStatic)return;const unsubscribe=springValue.on(\"change\",latest=>{startTransition(()=>{setDisplayValue(formatNumber(latest,decimals,separator));});});return()=>unsubscribe();},[springValue,decimals,separator,isStatic]);function formatNumber(value,decimals,useSeparator){const fixed=value.toFixed(decimals);if(!useSeparator)return fixed;const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\".\");}return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...props.style,position:\"relative\",width:\"max-content\",minWidth:\"max-content\"},children:/*#__PURE__*/_jsxs(\"span\",{style:{...useGradient?{background:gradientText,WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundClip:\"text\"}:{color:textColor},...font,whiteSpace:\"nowrap\"},children:[prefix,displayValue,suffix]})});}addPropertyControls(NumberCounter,{targetNumber:{type:ControlType.Number,title:\"Target Number\",defaultValue:40,min:0,step:.1},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"$\",placeholder:\"e.g. $, €, \\xa3\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"M+\",placeholder:\"e.g. M+, K, %\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1,displayStepper:true},separator:{type:ControlType.Boolean,title:\"Separator\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},useGradient:{type:ControlType.Boolean,title:\"Use Gradient\",defaultValue:false,enabledTitle:\"Gradient\",disabledTitle:\"Solid\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\",hidden:({useGradient})=>useGradient},gradientText:{type:ControlType.String,title:\"Gradient\",defaultValue:\"linear-gradient(90deg, #FF0080, #7928CA, #0070F3)\",placeholder:\"e.g. linear-gradient(90deg, #FF0080, #0070F3)\",displayTextArea:true,hidden:({useGradient})=>!useGradient},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"+QAIG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,eAAa,GAAG,SAAO,IAAI,SAAO,KAAK,WAAS,EAAE,WAAS,EAAE,YAAU,GAA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