{"version":3,"file":"TypewriterEffect.CLpJsFf6.mjs","names":["useState","useRef","useMemo"],"sources":["https:/framerusercontent.com/modules/aYjSps2C836ufARWFxNz/bD3lSr1BO9rrx2uL5FNM/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 any\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,enableResponsive,tabletBreakpoint,mobileBreakpoint,tabletFontScale,mobileFontScale,showCursorToggle,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[windowWidth,setWindowWidth]=useState(typeof window!==\"undefined\"?window.innerWidth:1200);const timeoutRef=useRef(null);const blinkRef=useRef(null);const currentWord=words.length>0?words[wordIndex%words.length].word:\"\";// Track window width for responsive behavior\nuseEffect(()=>{if(!enableResponsive||typeof window===\"undefined\")return;const handleResize=()=>{startTransition(()=>setWindowWidth(window.innerWidth));};window.addEventListener(\"resize\",handleResize);return()=>window.removeEventListener(\"resize\",handleResize);},[enableResponsive]);// 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);};},[]);// Calculate responsive font size\nconst responsiveFontSize=useMemo(()=>{if(!enableResponsive)return font?.fontSize||\"32px\";const baseFontSize=typeof font?.fontSize===\"string\"&&font.fontSize.endsWith(\"px\")?parseFloat(font.fontSize):typeof font?.fontSize===\"number\"?font.fontSize:32;let scale=1;if(windowWidth<=mobileBreakpoint){scale=mobileFontScale/100;}else if(windowWidth<=tabletBreakpoint){scale=tabletFontScale/100;}return`${baseFontSize*scale}px`;},[enableResponsive,font?.fontSize,windowWidth,tabletBreakpoint,mobileBreakpoint,tabletFontScale,mobileFontScale]);// Font size for cursor height calculation\nconst fontSize=useMemo(()=>{if(typeof responsiveFontSize===\"string\"&&responsiveFontSize.endsWith(\"px\")){return parseFloat(responsiveFontSize);}else if(typeof responsiveFontSize===\"number\"){return responsiveFontSize;}return 32;},[responsiveFontSize]);return /*#__PURE__*/_jsxs(\"span\",{style:{...style,...font,fontSize:responsiveFontSize,color:textColor,display:\"flex\",alignItems:\"center\",flexWrap:\"wrap\",minWidth:1,minHeight:1,width:\"100%\",height:\"auto\",whiteSpace:\"normal\",wordWrap:\"break-word\",overflowWrap:\"break-word\"},\"aria-live\":\"polite\",children:[displayed,showCursorToggle&&/*#__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,flexShrink:0}})]});}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},showCursorToggle:{type:ControlType.Boolean,title:\"Show Cursor\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},enableResponsive:{type:ControlType.Boolean,title:\"Responsive\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},tabletBreakpoint:{type:ControlType.Number,title:\"Tablet Width\",defaultValue:768,min:480,max:1024,unit:\"px\",step:1,hidden:({enableResponsive})=>!enableResponsive},mobileBreakpoint:{type:ControlType.Number,title:\"Mobile Width\",defaultValue:480,min:320,max:767,unit:\"px\",step:1,hidden:({enableResponsive})=>!enableResponsive},tabletFontScale:{type:ControlType.Number,title:\"Tablet Scale\",defaultValue:80,min:50,max:100,unit:\"%\",step:5,hidden:({enableResponsive})=>!enableResponsive},mobileFontScale:{type:ControlType.Number,title:\"Mobile Scale\",defaultValue:60,min:40,max:100,unit:\"%\",step:5,hidden:({enableResponsive})=>!enableResponsive},cursorColor:{type:ControlType.Color,title:\"Cursor Color\",defaultValue:\"#FFFFFF\",hidden:({showCursorToggle})=>!showCursorToggle},cursorWidth:{type:ControlType.Number,title:\"Cursor Width\",defaultValue:2,min:1,max:8,unit:\"px\",step:1,hidden:({showCursorToggle})=>!showCursorToggle},cursorHeight:{type:ControlType.Number,title:\"Cursor Height\",defaultValue:100,min:50,max:120,unit:\"%\",step:1,hidden:({showCursorToggle})=>!showCursorToggle},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\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TypewriterEffect.map"],"mappings":"2NAMG,SAAwB,EAAiB,EAAM,CAAC,GAAK,CAAC,QAAM,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,cAAY,gBAAc,gBAAc,cAAY,cAAY,eAAa,OAAK,YAAU,mBAAiB,mBAAiB,mBAAiB,kBAAgB,kBAAgB,mBAAiB,SAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAG,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAM,CAAC,EAAU,GAAcA,EAAS,EAAE,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAK,CAAM,CAAC,EAAY,GAAgBA,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