{"version":3,"file":"TextRotation.CmDtzvec.mjs","names":["React.useState","__esmMin","init_npm_react_18_3_1","te","ce","init_jsx_runtime","c","p","_e","motion","AnimatePresence","init_framer_motion_DhsWWWsN","addPropertyControls","init_framer_D6uXRwWs","ControlType","TextRotation","props","safePhrases","phrases","index","setIndex","paused","setPaused","loop","id","i","interval","text","units","animationMode","arr","w","motionVariants","createFontStyle","fontProp","staticFontStyle","staticFont","font","rotatingFontStyle","rotatingFont","pauseOnHover","staticText","staticColor","animationStyle","unit","init_TextRotation"],"sources":["https:/framerusercontent.com/modules/S0yDUDI3mcecaCVK1qri/lf1LkojssYRWAbCHQrUZ/TextRotation.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{motion,AnimatePresence}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function TextRotation(props){const{staticText,phrases,interval,animationMode,animationStyle,loop,pauseOnHover,font,staticFont,rotatingFont,staticColor,color}=props;const safePhrases=phrases.length>0?phrases:[\"Text\"];const[index,setIndex]=React.useState(0);const[paused,setPaused]=React.useState(false);React.useEffect(()=>{if(paused)return;if(!loop&&index===safePhrases.length-1)return;const id=setTimeout(()=>{React.startTransition(()=>{setIndex(i=>(i+1)%safePhrases.length);});},interval);return()=>clearTimeout(id);},[index,interval,loop,paused,safePhrases.length]);const text=safePhrases[index];const units=animationMode===\"character\"?Array.from(text):animationMode===\"word\"?text.split(\" \").map((w,i,arr)=>i<arr.length-1?w+\" \":w):[text];const motionVariants={slideUp:{initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-16}},slideDown:{initial:{opacity:0,y:-16},animate:{opacity:1,y:0},exit:{opacity:0,y:16}},fade:{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}}};const createFontStyle=fontProp=>({...fontProp,fontFeatureSettings:fontProp?.fontFeatureSettings,fontVariationSettings:fontProp?.fontVariationSettings,fontOpticalSizing:fontProp?.fontOpticalSizing});const staticFontStyle=createFontStyle(staticFont??font);const rotatingFontStyle=createFontStyle(rotatingFont??font);const handleMouseEnter=()=>{if(!pauseOnHover)return;React.startTransition(()=>{setPaused(true);});};const handleMouseLeave=()=>{React.startTransition(()=>{setPaused(false);});};return /*#__PURE__*/_jsxs(\"div\",{\"aria-live\":\"polite\",onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,style:{display:\"inline-flex\",alignItems:\"baseline\"},children:[staticText&&/*#__PURE__*/_jsx(\"span\",{style:{...staticFontStyle,marginRight:6,color:staticColor,whiteSpace:\"pre\"},children:staticText}),/*#__PURE__*/_jsx(\"span\",{style:{position:\"relative\",display:\"inline-block\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(AnimatePresence,{mode:\"wait\",children:/*#__PURE__*/_jsx(motion.span,{...motionVariants[animationStyle],transition:{duration:.4,ease:\"easeOut\"},style:{...rotatingFontStyle,display:\"inline-block\",whiteSpace:\"nowrap\",color},children:units.map((unit,i)=>/*#__PURE__*/_jsx(motion.span,{initial:animationMode===\"phrase\"?false:{opacity:0,y:8},animate:animationMode===\"phrase\"?{}:{opacity:1,y:0},transition:{delay:animationMode===\"phrase\"?0:i*.04},style:{...rotatingFontStyle,display:\"inline-block\",whiteSpace:\"pre\"},children:unit},i))},text+index)})})]});}TextRotation.defaultProps={staticText:\"I like\",phrases:[\"apples\",\"mangoes\",\"oranges\"],interval:2e3,animationMode:\"phrase\",animationStyle:\"slideUp\",loop:true,pauseOnHover:false,staticColor:\"#666\",color:\"#000\"};addPropertyControls(TextRotation,{staticText:{type:ControlType.String,title:\"Static Text\"},phrases:{type:ControlType.Array,title:\"Rotating Text\",control:{type:ControlType.String}},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\"},staticFont:{type:ControlType.Font,title:\"Static Font\",controls:\"extended\"},rotatingFont:{type:ControlType.Font,title:\"Rotating Font\",controls:\"extended\"},interval:{type:ControlType.Number,title:\"Interval\",min:500,max:8e3,unit:\"ms\"},animationMode:{type:ControlType.Enum,title:\"Animate By\",options:[\"phrase\",\"word\",\"character\"]},animationStyle:{type:ControlType.Enum,title:\"Style\",options:[\"slideUp\",\"slideDown\",\"fade\"]},loop:{type:ControlType.Boolean,title:\"Loop\"},pauseOnHover:{type:ControlType.Boolean,title:\"Pause on Hover\"},staticColor:{type:ControlType.Color,title:\"Static Color\"},color:{type:ControlType.Color,title:\"Rotate Color\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextRotation\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextRotation.map"],"mappings":"A,wPAGG,SAAwBe,EAAa,EAAM,CAAC,GAAK,CAAC,aAAW,UAAQ,WAAS,gBAAc,iBAAe,OAAK,eAAa,OAAK,aAAW,eAAa,cAAY,SAAOC,EAAYC,EAAYC,EAAQ,OAAO,EAAEA,EAAQ,CAAC,MAAM,EAAO,CAACC,EAAMC,GAAUpB,EAAe,CAAC,EAAO,CAACqB,EAAOC,GAAWtB,EAAe,EAAK,EAAEI,MAAoB,CAAkB,GAAdiB,GAAiB,CAACE,GAAMJ,IAAQF,EAAY,OAAO,EAAE,OAAO,IAAMO,EAAG,eAAe,CAACrB,MAA0B,CAACiB,EAAS,IAAIK,EAAE,GAAGR,EAAY,MAAM,CAAE,CAAC,CAAE,EAAES,CAAQ,EAAE,UAAU,aAAaF,CAAE,CAAE,EAAE,CAACL,EAAMO,EAASH,EAAKF,EAAOJ,EAAY,MAAM,CAAC,EAAE,IAAMU,EAAKV,EAAYE,GAAaS,EAAMC,IAAgB,YAAY,MAAM,KAAKF,CAAI,EAAEE,IAAgB,OAAOF,EAAK,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,IAAMF,EAA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