{"version":3,"file":"EmailFormElement.CE49bFMM.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/ZziuMzbE78qikaVWtdOo/VMdRVZhOA0cjJtxoaGLN/EmailFormElement.js"],"sourcesContent":["/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicHeight 53\n */import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// Constants\nconst INVALID_STATE={valid:false,required:\"required\",value:\"value\"};function isEmailAddress(string){return/^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,64}$/.test(string);}export default function EmailField(props){const{// Functional props\nformId,name,required,emailPlaceholder,emailFilters={businessEmailsOnly:true},// Style props\nborderColor,borderColorFocus,borderColorError,borderWidth,borderRadius,placeholderColor,textColor,errorColor,warningColor,width,height,fontSize,padding,fontFamily,fontWeight,style}=props;const[formState,setFormState]=useState({});const[invalid,setInvalid]=useState(false);const[personalEmail,setPersonalEmail]=useState(false);const ref=useRef(null);function updateField(key,value){setFormState(prev=>({...prev,[formId]:{...prev[formId]||{},[name]:{...prev[formId]?.[name]||{},[key]:value}}}));}function invalidate(newState){setInvalid(newState);}function revalidate(){setInvalid(false);setPersonalEmail(false);}async function validateEmail(value){let valid=true;if(required&&(!value||value.length===0)){invalidate(INVALID_STATE.required);return false;}if(value&&value.length>0){if(!isEmailAddress(value)){valid=false;invalidate(INVALID_STATE.value);return false;}const domain=value.split(\"@\")[1];if(valid&&emailFilters&&emailFilters.businessEmailsOnly){try{const response=await fetch(\"https://f.hubspotusercontent40.net/hubfs/2832391/Marketing/Lead-Capture/free-domains-2.csv\");if(!response.ok)throw new Error(\"Network response was not ok\");const data=await response.text();const isPersonalEmail=data.split(\"\\r\\n\").includes(domain);if(isPersonalEmail){setPersonalEmail(true);}// We're still returning valid=true since we don't want to mark the field as invalid\nreturn true;}catch(error){console.error(\"Error fetching email domains list:\",error);}}}return valid;}function handleChange(event){const value=event.target.value;updateField(\"value\",value);}function handleBlur(event){validateEmail(event.target.value);}useEffect(()=>{setFormState(prev=>({...prev,[formId]:{...prev[formId]||{},[name]:{ref,class:\"formField\",value:\"\",name,required,validateEmail,type:\"email\"}}}));},[formId,name,required]);return /*#__PURE__*/_jsxs(\"div\",{style:{width,...style},children:[/*#__PURE__*/_jsx(\"input\",{ref:ref,type:\"email\",name:name,required:required,placeholder:emailPlaceholder,value:formState[formId]?.[name]?.value||\"\",onChange:handleChange,onBlur:handleBlur,onFocus:revalidate,style:{width:\"100%\",height:\"53px\",padding,fontSize,color:textColor,borderRadius,borderWidth:`${borderWidth}px`,borderStyle:\"solid\",borderColor:invalid?borderColorError:borderColor,outline:\"none\",boxSizing:\"border-box\",transition:\"border-color 0.2s ease-in-out\",fontFamily,fontWeight}}),/*#__PURE__*/_jsx(\"style\",{jsx:true,children:`\n                input::placeholder {\n                    color: ${placeholderColor};\n                }\n                input:focus {\n                    border-color: ${borderColorFocus} !important;\n                }\n            `}),invalid&&/*#__PURE__*/_jsx(\"p\",{style:{color:errorColor,fontSize:`calc(${fontSize} * 0.90)`,margin:\"4px 0 0 0\",fontFamily,fontWeight},children:invalid===INVALID_STATE.required?\"This field is required.\":\"Invalid email address.\"}),personalEmail&&!invalid&&/*#__PURE__*/_jsx(\"p\",{style:{color:warningColor,fontSize:`calc(${fontSize} * 0.90)`,margin:\"4px 0 0 0\",fontFamily,fontWeight},children:\"Personal email addresses require manual review, which may take a few days.\"})]});}// Default props\nEmailField.defaultProps={formId:\"0\",name:\"email\",required:true,emailPlaceholder:\"email@example.com\",borderColor:\"#E3EBF6\",borderColorFocus:\"#0066FF\",borderColorError:\"#FF0000\",borderWidth:1,borderRadius:\"8px\",placeholderColor:\"#999999\",textColor:\"#333333\",errorColor:\"#FF0000\",warningColor:\"#FF9900\",width:\"100%\",height:\"53px\",fontSize:\"16px\",padding:\"8px 12px\",fontFamily:\"Open Sans\",fontWeight:400};// Property controls\naddPropertyControls(EmailField,{formId:{type:ControlType.String,title:\"Form ID\",defaultValue:\"0\"},name:{type:ControlType.String,title:\"Name\",defaultValue:\"email\"},required:{type:ControlType.Boolean,title:\"Required\",defaultValue:true},emailPlaceholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"email@example.com\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#E3EBF6\"},borderColorFocus:{type:ControlType.Color,title:\"Focus colour\",defaultValue:\"#0066FF\"},borderColorError:{type:ControlType.Color,title:\"Error colour\",defaultValue:\"#FF0000\"},borderWidth:{type:ControlType.Number,title:\"Border width\",defaultValue:1,min:0,max:10,step:1},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"8px\"},placeholderColor:{type:ControlType.Color,title:\"Placeholder\",defaultValue:\"#999999\"},textColor:{type:ControlType.Color,title:\"Text colour\",defaultValue:\"#333333\"},errorColor:{type:ControlType.Color,title:\"Error text\",defaultValue:\"#FF0000\"},warningColor:{type:ControlType.Color,title:\"Warning text\",defaultValue:\"#FF9900\"},width:{type:ControlType.String,title:\"Width\",defaultValue:\"100%\"},height:{type:ControlType.String,title:\"Height\",defaultValue:\"53px\"},fontSize:{type:ControlType.String,title:\"Font size\",defaultValue:\"16px\"},padding:{type:ControlType.String,title:\"Padding\",defaultValue:\"8px 12px\"},fontFamily:{type:ControlType.String,title:\"Font Family\",defaultValue:\"Open Sans\"},fontWeight:{type:ControlType.Number,title:\"Font Weight\",defaultValue:400,min:100,max:900,step:100}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EmailField\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EmailFormElement.map"],"mappings":"yRAKoE,SAAS,EAAe,EAAO,CAAC,MAAM,oDAAoD,KAAK,EAAO,CAAE,SAAwB,EAAW,EAAM,CAAC,GAAK,CA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