{"version":3,"file":"TextRotation.dRe87G46.mjs","names":["React.useState"],"sources":["https:/framerusercontent.com/modules/HabBqLGVvnHvZUUHKBz0/ee2QoOEydvvkaF0j3f9p/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\";export default function TextRotation(props){const{staticText,phrases,interval,animationMode,animationStyle,loop,pauseOnHover,font,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(()=>{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}}};return /*#__PURE__*/_jsxs(\"div\",{\"aria-live\":\"polite\",onMouseEnter:()=>pauseOnHover&&setPaused(true),onMouseLeave:()=>pauseOnHover&&setPaused(false),style:{...font,display:\"inline-flex\",alignItems:\"center\"},children:[staticText&&/*#__PURE__*/_jsx(\"span\",{style:{marginRight:6,color:staticColor,whiteSpace:\"pre\"},children:staticText}),/*#__PURE__*/_jsx(\"span\",{style:{position:\"relative\",display:\"inline-block\",overflow:\"hidden\",lineHeight:1.25},children:/*#__PURE__*/_jsx(AnimatePresence,{mode:\"wait\",children:/*#__PURE__*/_jsx(motion.span,{...motionVariants[animationStyle],transition:{duration:.4,ease:\"easeOut\"},style:{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:{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\"},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\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextRotation.map"],"mappings":"iPAA2L,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,aAAW,UAAQ,WAAS,gBAAc,iBAAe,OAAK,eAAa,OAAK,cAAY,SAAO,EAAY,EAAY,EAAQ,OAAO,EAAE,EAAQ,CAAC,OAAO,CAAM,CAAC,EAAM,GAAUA,EAAe,EAAE,CAAM,CAAC,EAAO,GAAWA,EAAe,GAAM,CAAC,MAAoB,CAAkB,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