{"version":3,"file":"TypewriterEffect.CfYUVCzU.mjs","names":["useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/IW0n3kExqX3zumAqsJzD/7PyEGZhmwZtYQ014tcGv/TypewriterEffect.js"],"sourcesContent":["// Dynamic Typing Animation Component with Customizable Cursor and Typography\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Dynamic Typing Animation\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function TypewriterEffect(props){const{words=[{word:\"Hello\"},{word:\"World\"},{word:\"Framer\"}],typingSpeed,deletingSpeed,pauseDuration,cursorColor,cursorWidth,cursorHeight,font,textColor,style}=props;const[displayed,setDisplayed]=useState(\"\");const[isDeleting,setIsDeleting]=useState(false);const[wordIndex,setWordIndex]=useState(0);const[charIndex,setCharIndex]=useState(0);const[pause,setPause]=useState(false);const[showCursor,setShowCursor]=useState(true);const timeoutRef=useRef(null);const blinkRef=useRef(null);const currentWord=words.length>0?words[wordIndex%words.length].word:\"\";// Typing/Deleting Effect\nuseEffect(()=>{if(pause)return;if(timeoutRef.current)clearTimeout(timeoutRef.current);let delay=typingSpeed;if(!isDeleting&&charIndex<currentWord.length){delay=typingSpeed;timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setDisplayed(currentWord.slice(0,charIndex+1));setCharIndex(charIndex+1);});},delay);}else if(!isDeleting&&charIndex===currentWord.length){// Pause at end of word\ntimeoutRef.current=window.setTimeout(()=>{startTransition(()=>setIsDeleting(true));},pauseDuration);}else if(isDeleting&&charIndex>0){delay=deletingSpeed;timeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setDisplayed(currentWord.slice(0,charIndex-1));setCharIndex(charIndex-1);});},delay);}else if(isDeleting&&charIndex===0){// Pause before next word\ntimeoutRef.current=window.setTimeout(()=>{startTransition(()=>{setIsDeleting(false);setWordIndex((wordIndex+1)%words.length);});},pauseDuration);}return()=>{if(timeoutRef.current)clearTimeout(timeoutRef.current);};},[charIndex,isDeleting,pause,wordIndex,currentWord,typingSpeed,deletingSpeed,pauseDuration,words.length]);// Reset charIndex when wordIndex changes\nuseEffect(()=>{if(!isDeleting){startTransition(()=>setCharIndex(0));}},[wordIndex,isDeleting]);// Blinking Cursor Effect\nuseEffect(()=>{if(blinkRef.current)clearInterval(blinkRef.current);blinkRef.current=window.setInterval(()=>{startTransition(()=>setShowCursor(v=>!v));},500);return()=>{if(blinkRef.current)clearInterval(blinkRef.current);};},[]);// Font size for cursor height calculation\nconst fontSize=useMemo(()=>{if(font&&font.fontSize){if(typeof font.fontSize===\"string\"&&font.fontSize.endsWith(\"px\")){return parseFloat(font.fontSize);}else if(typeof font.fontSize===\"number\"){return font.fontSize;}}return 32;},[font]);return /*#__PURE__*/_jsxs(\"span\",{style:{...style,...font,color:textColor,display:\"inline-flex\",alignItems:\"center\",minWidth:1,minHeight:1,maxWidth:\"100%\",width:\"100%\",whiteSpace:\"pre-wrap\",wordBreak:\"break-word\"},\"aria-live\":\"polite\",children:[displayed,/*#__PURE__*/_jsx(\"span\",{\"aria-hidden\":\"true\",style:{display:\"inline-block\",background:cursorColor,width:cursorWidth,height:fontSize*(cursorHeight/100),marginLeft:2,marginRight:2,verticalAlign:\"bottom\",opacity:showCursor?1:0,transition:\"opacity 0.1s\",borderRadius:2}})]});}addPropertyControls(TypewriterEffect,{words:{type:ControlType.Array,title:\"Words\",control:{type:ControlType.Object,controls:{word:{type:ControlType.String,defaultValue:\"Hello\"}}},defaultValue:[{word:\"Hello\"},{word:\"World\"},{word:\"Framer\"}],maxCount:10},typingSpeed:{type:ControlType.Number,title:\"Typing Speed\",defaultValue:100,min:20,max:500,unit:\"ms\",step:5},deletingSpeed:{type:ControlType.Number,title:\"Deleting Speed\",defaultValue:60,min:10,max:500,unit:\"ms\",step:5},pauseDuration:{type:ControlType.Number,title:\"Pause Duration\",defaultValue:1e3,min:200,max:3e3,unit:\"ms\",step:50},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#FFFFFF\"},cursorWidth:{type:ControlType.Number,title:\"Cursor Width\",defaultValue:2,min:1,max:8,unit:\"px\",step:1},cursorHeight:{type:ControlType.Number,title:\"Cursor Height\",defaultValue:100,min:50,max:120,unit:\"%\",step:1},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TypewriterEffect\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TypewriterEffect.map"],"mappings":"sNAMG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,KAAK,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,cAAY,gBAAc,gBAAc,cAAY,cAAY,eAAa,OAAK,YAAU,SAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,EAAE,EAAO,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAO,CAAC,EAAU,GAAcA,EAAS,CAAC,EAAO,CAAC,EAAU,GAAcA,EAAS,CAAC,EAAO,CAAC,EAAM,GAAUA,EAAS,EAAK,EAAO,CAAC,EAAW,GAAeA,EAAS,EAAI,EAAQ,EAAWC,EAAO,IAAI,EAAQ,EAASA,EAAO,IAAI,EAAQ,EAAY,EAAM,OAAO,EAAE,EAAM,EAAU,EAAM,OAAO,CAAC,KAAK,GAC1lB,MAAc,CAAC,GAAG,EAAM,OAAU,EAAW,SAAQ,aAA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