{"version":3,"file":"GridTextCursorTrail.C4RSCHI7.mjs","names":["useRef","useState","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/4tqRvmQqJOZcjvPGLsrs/NUiedzpemntR6Muilxhb/GridTextCursorTrail.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useCallback,useMemo,useRef}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,AnimatePresence}from\"framer-motion\";/**\n * @framerIntrinsicWidth 800\n * @framerIntrinsicHeight 600\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerDisableUnlink\n */export default function GridCursorTrail(props){const{text,gridSize,trailLength,colorMode,backgroundColor,customColors,cornerRadius,font,textColor,trailDuration,scope,hideCursor,style}=props;const containerRef=useRef(null);const[trail,setTrail]=useState([]);const lastPos=useRef({x:-1,y:-1});const globalIndex=useRef(0);// Process text for sequential display (Best Practice: Multi-line support)\nconst chars=useMemo(()=>{if(!text)return[\" \"];const processed=text.replace(/\\\\n/g,\"\\n\");return processed.split(\"\");},[text]);const handleMouseMove=useCallback(e=>{let clientX=e.clientX;let clientY=e.clientY;if((scope===\"local\"||scope===\"document\")&&containerRef.current){const rect=containerRef.current.getBoundingClientRect();clientX=e.clientX-rect.left;clientY=e.clientY-rect.top;if(scope===\"local\"){if(e.clientX<rect.left||e.clientX>rect.right||e.clientY<rect.top||e.clientY>rect.bottom){return;}}}const x=Math.floor(clientX/gridSize);const y=Math.floor(clientY/gridSize);if(x!==lastPos.current.x||y!==lastPos.current.y){lastPos.current={x,y};const id=globalIndex.current++;const charIndex=id%chars.length;const colorIndex=colorMode===\"custom\"&&customColors?.length>0?id%customColors.length:0;setTrail(prev=>{const newTrail=[...prev,{x,y,id,charIndex,colorIndex,createdAt:Date.now()}];if(newTrail.length>trailLength){return newTrail.slice(newTrail.length-trailLength);}return newTrail;});}},[gridSize,trailLength,scope,chars,colorMode,customColors]);// Lifetime System: Automatically remove items after their lifetime\nuseEffect(()=>{if(RenderTarget.current()===RenderTarget.canvas)return;const interval=setInterval(()=>{const now=Date.now();setTrail(prev=>{const filtered=prev.filter(item=>now-item.createdAt<trailDuration*1e3);if(filtered.length!==prev.length)return filtered;return prev;});},50);return()=>clearInterval(interval);},[trailDuration]);// Global Cursor Hide System for Viewport/Document scopes\nuseEffect(()=>{if(!hideCursor||RenderTarget.current()===RenderTarget.canvas)return;if(scope===\"local\")return;const styleId=`framer-hide-cursor-${globalIndex.current}`;let styleTag=document.getElementById(styleId);if(!styleTag){styleTag=document.createElement(\"style\");styleTag.id=styleId;styleTag.innerHTML=`body, a, button, [role=\"button\"] { cursor: none !important; }`;document.head.appendChild(styleTag);}return()=>{const tag=document.getElementById(styleId);if(tag)tag.remove();};},[hideCursor,scope]);// Event listener management\nuseEffect(()=>{const target=scope===\"viewport\"||scope===\"document\"?window:containerRef.current;if(!target)return;if(RenderTarget.current()!==RenderTarget.canvas){target.addEventListener(\"mousemove\",handleMouseMove);}return()=>{target.removeEventListener(\"mousemove\",handleMouseMove);};},[handleMouseMove,scope]);// Preview mode for Framer Canvas\nconst displayTrail=useMemo(()=>{if(RenderTarget.current()===RenderTarget.canvas&&trail.length===0){return[{x:1,y:1,id:-1,charIndex:0,colorIndex:0,createdAt:0},{x:2,y:2,id:-2,charIndex:1%chars.length,colorIndex:1%(customColors?.length||1),createdAt:0},{x:3,y:3,id:-3,charIndex:2%chars.length,colorIndex:2%(customColors?.length||1),createdAt:0}];}return trail;},[trail,chars,customColors]);const containerStyle={...style,width:\"100%\",height:\"100%\",padding:0,margin:0,overflow:scope===\"viewport\"||scope===\"document\"?\"visible\":\"hidden\",position:scope===\"viewport\"?\"fixed\":scope===\"document\"?\"absolute\":\"relative\",top:scope===\"viewport\"||scope===\"document\"?0:undefined,left:scope===\"viewport\"||scope===\"document\"?0:undefined,pointerEvents:scope===\"viewport\"||scope===\"document\"?\"none\":\"auto\",zIndex:scope===\"viewport\"||scope===\"document\"?9999:undefined,cursor:hideCursor&&scope===\"local\"?\"none\":\"auto\"};const isOnCanvas=RenderTarget.current()===RenderTarget.canvas;return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:containerStyle,children:[isOnCanvas&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:0,right:0,bottom:0,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",pointerEvents:\"none\",zIndex:10},children:/*#__PURE__*/_jsx(\"div\",{style:{padding:\"6px 14px\",borderRadius:\"12px\",backgroundColor:\"rgba(0, 0, 0, 0.4)\",color:\"white\",fontSize:\"12px\",fontWeight:500,backdropFilter:\"blur(4px)\",border:\"1px solid rgba(255, 255, 255, 0.1)\",letterSpacing:\"-0.01em\",textAlign:\"center\"},children:\"Please check in Preview\"})}),/*#__PURE__*/_jsx(AnimatePresence,{children:displayTrail.map((item,index)=>{// Opacity calculation based on trail order\nconst opacity=(index+1)/(displayTrail.length||1);const char=chars[item.charIndex];const bgColor=colorMode===\"custom\"&&customColors?.length>0?customColors[item.colorIndex]:backgroundColor;return /*#__PURE__*/_jsx(motion.div,{initial:{opacity:0,scale:.8},animate:{opacity,scale:1},exit:{opacity:0,scale:.5},transition:{duration:.3,ease:\"easeOut\"},style:{position:\"absolute\",left:item.x*gridSize,top:item.y*gridSize,width:gridSize,height:gridSize,backgroundColor:bgColor,borderRadius:cornerRadius,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",pointerEvents:\"none\",// Best Practice: Font extended correctly (Removed incorrect ...style)\n...font,color:textColor,// Additional centering reinforcement\nlineHeight:1},children:/*#__PURE__*/_jsx(\"span\",{style:{display:\"block\",whiteSpace:\"pre-wrap\",textAlign:font?.textAlign||\"center\",// Using transform for perfect optical centering if needed,\n// but flex + lineHeight 1 is usually enough.\nlineHeight:\"1em\"},children:char===\"\\n\"?/*#__PURE__*/_jsx(\"br\",{}):char})},item.id);})})]});}GridCursorTrail.defaultProps={text:\"Grid Cursor \",gridSize:50,trailLength:10,colorMode:\"custom\",backgroundColor:\"rgba(0, 153, 255, 0.2)\",customColors:[\"#FFC09F\",\"#FFEE93\",\"#FCF5C7\",\"#A0CED9\",\"#ADF7B6\"],cornerRadius:100,trailDuration:.5,scope:\"local\",hideCursor:false,textColor:\"#ffffff\",font:{fontSize:40}};addPropertyControls(GridCursorTrail,{// --- Content Section ---\ntext:{type:ControlType.String,defaultValue:\"Grid Cursor \",title:\"Text\"},font:{type:ControlType.Font,controls:\"extended\",defaultValue:{fontSize:40,textAlign:\"center\",variant:\"Semibold\"}},textColor:{type:ControlType.Color,defaultValue:\"#ffffff\",title:\"Font Color\"},// --- Trail Mechanics ---\ngridSize:{type:ControlType.Number,min:10,max:200,defaultValue:50,unit:\"px\",title:\"Grid Size\"},cornerRadius:{type:ControlType.Number,min:0,max:100,defaultValue:100,unit:\"px\",title:\"Corner Radius\"},trailLength:{type:ControlType.Number,min:1,max:500,defaultValue:10,unit:\"pcs\",title:\"Max Length\"},trailDuration:{type:ControlType.Number,min:.1,max:10,step:.1,defaultValue:.5,unit:\"s\",title:\"Lifetime\"},// --- Visual Styling ---\ncolorMode:{type:ControlType.Enum,options:[\"single\",\"custom\"],optionTitles:[\"Single Color\",\"Multi Color\"],defaultValue:\"custom\",title:\"Color Mode\"},backgroundColor:{type:ControlType.Color,defaultValue:\"rgba(0, 153, 255, 0.2)\",title:\"Color\",hidden:props=>props.colorMode!==\"single\"},customColors:{type:ControlType.Array,control:{type:ControlType.Color},defaultValue:[\"#FFC09F\",\"#FFEE93\",\"#FCF5C7\",\"#A0CED9\",\"#ADF7B6\"],title:\"Colors\",hidden:props=>props.colorMode!==\"custom\"},// --- Interaction Settings ---\nscope:{type:ControlType.Enum,options:[\"local\",\"document\"],optionTitles:[\"Local (Within Componet)\",\"Global (Entire Page)\"],defaultValue:\"local\",title:\"Tracking Scope\",description:\"Explore more components at [THE DESIGN FUTURIST](https://thedesignfuturist.zip)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GridCursorTrail\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"800\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"600\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GridTextCursorTrail.map"],"mappings":"qRAMG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,cAAY,YAAU,kBAAgB,eAAa,eAAa,OAAK,YAAU,gBAAc,QAAM,aAAW,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAM,GAAUC,EAAS,EAAE,CAAC,CAAO,EAAQD,EAAO,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAO,EAAYA,EAAO,EAAE,CAC3T,EAAME,MAAiB,EAAiC,EAAK,QAAQ,OAAO;EAAK,CAAkB,MAAM,GAAG,CAA1E,CAAC,IAAI,CAAwE,CAAC,EAAK,CAAC,CAAO,EAAgBC,EAAY,GAAG,CAAC,IAAI,EAAQ,EAAE,QAAY,EAAQ,EAAE,QAAQ,IAAI,IAAQ,SAAS,IAAQ,aAAa,EAAa,QAAQ,CAAC,IAAM,EAAK,EAAa,QAAQ,uBAAuB,CAAwD,GAAvD,EAAQ,EAAE,QAAQ,EAAK,KAAK,EAAQ,EAAE,QAAQ,EAAK,IAAO,IAAQ,UAAY,EAAE,QAAQ,EAAK,MAAM,EAAE,QAAQ,EAAK,OAAO,EAAE,QAAQ,EAAK,KAAK,EAAE,QAAQ,EAAK,QAAQ,OAAU,IAAM,EAAE,KAAK,MAAM,EAAQ,EAAS,CAAO,EAAE,KAAK,MAAM,EAAQ,EAAS,CAAC,GAAG,IAAI,EAAQ,QAAQ,GAAG,IAAI,EAAQ,QAAQ,EAAE,CAAC,EAAQ,QAAQ,CAAC,IAAE,IAAE,CAAC,IAAM,EAAG,EA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