{"version":3,"file":"CopyEmail.DEV99xf4.mjs","names":["useState","useRef","useMemo","useCallback"],"sources":["https:/framerusercontent.com/modules/ATSRwClfxBr04PKVnSWt/kK9LEVmT8XxgCFb7RSb3/CopyEmail.js"],"sourcesContent":["// User instructions: make a copy email component; settings to change texts and their color; copy exact one; option to add icon png; not a button just text; hover changes text color (property); click changes text to \"copied\" for few seconds then goes back to original text \"Copy email\"\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{startTransition,useCallback,useEffect,useMemo,useRef,useState}from\"react\";/**\n * @framerIntrinsicWidth 210\n * @framerIntrinsicHeight 56\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CopyEmail(props){const{emailToCopy,text,copiedText,copiedDurationMs,textColor,hoverTextColor,backgroundColor,font,alignment,showIcon,icon,iconSize,gap,padding,borderRadius,style}=props;const isStatic=useIsStaticRenderer();const[hovered,setHovered]=useState(false);const[copied,setCopied]=useState(false);const timeoutRef=useRef(null);const longestLabel=useMemo(()=>{const a=text??\"\";const b=copiedText??\"\";return a.length>=b.length?a:b;},[text,copiedText]);const label=copied?copiedText:text;const currentColor=hovered?hoverTextColor:textColor;const clearTimer=useCallback(()=>{if(timeoutRef.current!==null&&typeof window!==\"undefined\"){window.clearTimeout(timeoutRef.current);timeoutRef.current=null;}},[]);useEffect(()=>{return()=>clearTimer();},[clearTimer]);const copyToClipboard=useCallback(async()=>{if(isStatic)return;if(typeof window===\"undefined\")return;const value=(emailToCopy??\"\").trim();if(!value)return;try{if(navigator?.clipboard?.writeText){await navigator.clipboard.writeText(value);}else{// Fallback\nconst ta=document.createElement(\"textarea\");ta.value=value;ta.style.position=\"fixed\";ta.style.opacity=\"0\";ta.style.left=\"-9999px\";ta.style.top=\"-9999px\";document.body.appendChild(ta);ta.focus();ta.select();document.execCommand(\"copy\");document.body.removeChild(ta);}clearTimer();startTransition(()=>setCopied(true));timeoutRef.current=window.setTimeout(()=>{startTransition(()=>setCopied(false));timeoutRef.current=null;},Math.max(250,copiedDurationMs||0));}catch{// Ignore (permissions, unsupported, etc.)\n}},[isStatic,emailToCopy,copiedDurationMs,clearTimer]);const onKeyDown=useCallback(e=>{if(isStatic)return;if(e.key===\"Enter\"||e.key===\" \"){e.preventDefault();copyToClipboard();}},[isStatic,copyToClipboard]);const isFullWidth=!!style?.width&&style.width===\"100%\";const isFullHeight=!!style?.height&&style.height===\"100%\";const containerStyle=useMemo(()=>({position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:alignment===\"right\"?\"flex-end\":alignment===\"center\"?\"center\":\"flex-start\",gap,padding,borderRadius,background:backgroundColor,color:currentColor,cursor:isStatic?\"default\":\"pointer\",userSelect:\"none\",WebkitUserSelect:\"none\",whiteSpace:\"nowrap\",...isFullWidth?{width:\"100%\"}:{width:\"max-content\"},...isFullHeight?{height:\"100%\"}:{},...style}),[alignment,gap,padding,borderRadius,backgroundColor,currentColor,isStatic,isFullWidth,isFullHeight,style]);const textStyle=useMemo(()=>({margin:0,padding:0,minWidth:\"max-content\",textAlign:\"left\",color:currentColor,...font}),[currentColor,font]);const iconNode=useMemo(()=>{if(!showIcon)return null;if(icon?.src){return /*#__PURE__*/_jsx(\"img\",{src:icon.src,srcSet:icon.srcSet,alt:icon.alt??\"\",style:{width:iconSize,height:iconSize,display:\"block\",objectFit:\"contain\",flex:\"0 0 auto\",pointerEvents:\"none\",opacity:hovered?.75:1,transition:\"opacity 150ms ease\"}});}// Built-in arrow (fallback)\nreturn /*#__PURE__*/_jsxs(\"svg\",{width:iconSize,height:iconSize,viewBox:\"0 0 24 24\",fill:\"none\",\"aria-hidden\":\"true\",style:{display:\"block\",flex:\"0 0 auto\",pointerEvents:\"none\"},children:[/*#__PURE__*/_jsx(\"path\",{d:\"M7 17L17 7\",stroke:currentColor,strokeWidth:\"2.5\",strokeLinecap:\"round\",strokeLinejoin:\"round\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M10 7H17V14\",stroke:currentColor,strokeWidth:\"2.5\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})]});},[showIcon,icon,iconSize,hovered,currentColor]);return /*#__PURE__*/_jsxs(\"span\",{style:containerStyle,role:\"button\",tabIndex:isStatic?-1:0,\"aria-label\":copied?copiedText:`Copy email: ${emailToCopy}`,onClick:isStatic?undefined:copyToClipboard,onKeyDown:onKeyDown,onPointerEnter:isStatic?undefined:()=>{startTransition(()=>setHovered(true));},onPointerLeave:isStatic?undefined:()=>{startTransition(()=>setHovered(false));},onFocus:isStatic?undefined:()=>{startTransition(()=>setHovered(true));},onBlur:isStatic?undefined:()=>{startTransition(()=>setHovered(false));},children:[/*#__PURE__*/_jsxs(\"span\",{style:{position:\"relative\",display:\"inline-block\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{...textStyle,visibility:\"hidden\"},children:longestLabel}),/*#__PURE__*/_jsx(\"span\",{style:{...textStyle,position:\"absolute\",inset:0},children:label})]}),!copied&&iconNode]});}addPropertyControls(CopyEmail,{emailToCopy:{type:ControlType.String,title:\"Email\",defaultValue:\"hello@example.com\",placeholder:\"email@domain.com\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"Copy email\"},copiedText:{type:ControlType.String,title:\"Copied Text\",defaultValue:\"Copied\"},copiedDurationMs:{type:ControlType.Number,title:\"Copied Time\",defaultValue:2e3,min:250,max:1e4,step:250,unit:\"ms\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#FFFFFF\"},hoverTextColor:{type:ControlType.Color,title:\"Hover Text\",defaultValue:\"#CCCCCC\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"32px\",variant:\"Medium\",letterSpacing:\"-0.02em\",lineHeight:\"1.1em\"}},alignment:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},showIcon:{type:ControlType.Boolean,title:\"Icon\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},icon:{type:ControlType.ResponsiveImage,title:\"Icon PNG\",hidden:p=>!p.showIcon},iconSize:{type:ControlType.Number,title:\"Icon Size\",defaultValue:26,min:10,max:64,step:1,unit:\"px\",hidden:p=>!p.showIcon},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:14,min:0,max:40,step:1,unit:\"px\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"10px 16px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:10,min:0,max:60,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CopyEmail\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"210\",\"framerIntrinsicHeight\":\"56\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CopyEmail.map"],"mappings":"4OAOG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,cAAY,OAAK,aAAW,mBAAiB,YAAU,iBAAe,kBAAgB,OAAK,YAAU,WAAS,OAAK,WAAS,MAAI,UAAQ,eAAa,SAAO,EAAY,EAAS,EAAoB,EAAO,CAAC,EAAQ,GAAYA,EAAS,EAAK,EAAO,CAAC,EAAO,GAAWA,EAAS,EAAK,EAAQ,EAAWC,EAAO,IAAI,EAAQ,EAAaC,MAAY,CAAC,IAAM,EAAE,GAAM,GAAS,EAAE,GAAY,GAAG,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAE,EAAE,CAAC,EAAK,CAAU,CAAC,EAAQ,EAAM,EAAO,EAAW,EAAW,EAAa,EAAQ,EAAe,EAA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