{"version":3,"file":"NumberCounter.DotyvIHV.mjs","names":[],"sources":["https:/framerusercontent.com/modules/dpKJGKNZgBXZvOh4V2KX/cxK4lKD7dMCH8ZOLwqDv/NumberCounter.js"],"sourcesContent":["// Animated Counter that counts up to a target number when in view, with customizable font, size, prefix/suffix, and extra text\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";/**\n * Animated Counter\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NumberCounter(props){const{target,duration,prefix,suffix,extraText,font:fontObj,style}=props;// Extract merged font/color controls\nconst numberFont=fontObj?.font||{};const numberColor=fontObj?.color||\"#000\";const extraFont=fontObj?.extraFont||{};const extraColor=fontObj?.extraColor||\"#222\";const ref=useRef(null);const numberRef=useRef(null);const measureRef=useRef(null);const[numberWidth,setNumberWidth]=useState(undefined);const isInView=useInView(ref,{once:true,margin:\"-20% 0px\"});const[count,setCount]=useState(0);const hasAnimated=useRef(false);const rafRef=useRef();// Measure the width of the final number (with prefix/suffix) before animating\nuseEffect(()=>{if(measureRef.current){setNumberWidth(measureRef.current.offsetWidth);}},[target,prefix,suffix,fontObj]);useEffect(()=>{if(isInView&&!hasAnimated.current){hasAnimated.current=true;const start=0;const end=target;const totalFrames=Math.max(1,Math.round(duration*60));let frame=0;function animate(){frame++;const progress=Math.min(frame/totalFrames,1);const value=Math.round(start+(end-start)*progress);startTransition(()=>setCount(value));if(progress<1){rafRef.current=requestAnimationFrame(animate);}}animate();}return()=>{if(rafRef.current)cancelAnimationFrame(rafRef.current);};},[isInView,target,duration]);return /*#__PURE__*/_jsxs(\"div\",{ref:ref,style:{display:\"inline-flex\",alignItems:\"baseline\",gap:8,...style},children:[/*#__PURE__*/_jsxs(\"span\",{ref:measureRef,style:{...numberFont,color:numberColor,position:\"absolute\",visibility:\"hidden\",pointerEvents:\"none\",whiteSpace:\"pre\",height:0,overflow:\"hidden\"},\"aria-hidden\":\"true\",children:[target,prefix,suffix]}),/*#__PURE__*/_jsxs(\"span\",{ref:numberRef,style:{...numberFont,color:numberColor,minWidth:numberWidth?numberWidth:undefined,maxWidth:numberWidth?numberWidth:undefined,display:\"inline-block\",textAlign:\"left\",whiteSpace:\"pre\",boxSizing:\"content-box\"},children:[count,prefix,suffix]}),extraText&&/*#__PURE__*/_jsx(\"span\",{style:{...extraFont,color:extraColor,marginLeft:4},children:extraText})]});}addPropertyControls(NumberCounter,{target:{type:ControlType.Number,title:\"Target\",defaultValue:100,min:0,max:1e6,step:1},duration:{type:ControlType.Number,title:\"Duration (s)\",defaultValue:1.2,min:.1,max:10,step:.05},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"+, $\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},extraText:{type:ControlType.String,title:\"Extra Text\",defaultValue:\"clients\",placeholder:\"clients, users, etc.\"},font:{type:ControlType.Object,title:\"Font & Color\",controls:{font:{type:ControlType.Font,title:\"Number Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:40,variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Number Color\",defaultValue:\"#000000\"},extraFont:{type:ControlType.Font,title:\"Extra Text Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:20,variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},extraColor:{type:ControlType.Color,title:\"Extra Text Color\",defaultValue:\"#222222\"}},defaultValue:{font:{fontSize:40,variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},color:\"#000000\",extraFont:{fontSize:20,variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},extraColor:\"#222222\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"mXAMG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,SAAO,WAAS,SAAO,SAAO,YAAU,KAAK,EAAQ,QAAM,CAAC,EAC5G,EAAW,GAAS,MAAM,CAAE,EAAO,EAAY,GAAS,OAAO,OAAa,EAAU,GAAS,WAAW,CAAE,EAAO,EAAW,GAAS,YAAY,OAAa,EAAI,EAAO,KAAK,CAAO,EAAU,EAAO,KAAK,CAAO,EAAW,EAAO,KAAK,CAAM,CAAC,EAAY,EAAe,CAAC,MAAA,GAAmB,CAAO,EAAS,EAAU,EAAI,CAAC,MAAK,EAAK,OAAO,UAAW,EAAC,CAAM,CAAC,EAAM,EAAS,CAAC,EAAS,EAAE,CAAO,EAAY,GAAO,EAAM,CAAO,EAAO,GAAQ,CACqL,MAAhnB,GAAU,IAAI,CAAC,AAAG,EAAW,SAAS,EAAe,EAAW,QAAQ,YAAY,AAAG,EAAC,CAAC,EAAO,EAAO,EAAO,CAAQ,EAAC,CAAC,EAAU,IAAI,CAAC,GAAG,IAAW,EAAY,QAAQ,CAAC,EAAY,SAAQ,EAAK,IAAM,EAAM,EAAQ,EAAI,EAAa,EAAY,KAAK,IAAI,EAAE,KAAK,MAAM,EAAS,GAAG,CAAC,CAAK,EAAM,EAAE,SAAS,GAAS,CAAC,IAAQ,IAAM,EAAS,KAAK,IAAI,EAAM,EAAY,EAAE,CAAO,EAAM,KAAK,MAAM,GAAO,EAAI,GAAO,EAAS,CAAsC,AAArC,EAAgB,IAAI,EAAS,EAAM,CAAC,CAAI,EAAS,IAAG,EAAO,QAAQ,sBAAsB,EAAQ,CAAG,IAAS,AAAE,OAAM,IAAI,CAAC,AAAG,EAAO,SAAQ,qBAAqB,EAAO,QAA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