{"version":3,"file":"WorkEmailInput.CTtCRruZ.mjs","names":["useState","useRef","useCallback"],"sources":["https:/framerusercontent.com/modules/W0djc99aIfhxIAz0aHuL/FrDfoAB1I2ZQmhUq94im/WorkEmailInput.js"],"sourcesContent":["// Custom input field that validates work email addresses, excluding free providers\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useCallback,startTransition,useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Work Email Input Field\n * \n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function WorkEmailInput(props){const{name,placeholder,label,showLabel,required,backgroundColor,borderColor,focusBorderColor,errorBorderColor,textColor,errorTextColor,font,borderRadius,padding,errorMessage,successMessage,showValidationMessage,onValueChange}=props;const[value,setValue]=useState(\"\");const[isFocused,setIsFocused]=useState(false);const[validationState,setValidationState]=useState(\"none\");const inputRef=useRef(null);// List of common free email providers to exclude\nconst freeProviders=[\"gmail.com\",\"yahoo.com\",\"hotmail.com\",\"outlook.com\",\"aol.com\",\"icloud.com\",\"mail.com\",\"protonmail.com\",\"yandex.com\",\"zoho.com\",\"live.com\",\"msn.com\",\"yahoo.co.uk\",\"googlemail.com\",\"me.com\",\"mac.com\",\"rocketmail.com\",\"ymail.com\",\"aim.com\",\"fastmail.com\"];const validateEmail=useCallback(email=>{// Basic email regex\nconst emailRegex=/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;if(!emailRegex.test(email)){return false;}// Extract domain\nconst domain=email.split(\"@\")[1]?.toLowerCase();if(!domain){return false;}// Check if it's a free provider\nreturn!freeProviders.includes(domain);},[]);const handleChange=useCallback(e=>{const newValue=e.target.value;setValue(newValue);let newValidationState;let isValid=false;if(newValue.trim()===\"\"){newValidationState=\"none\";isValid=!required// If not required, empty is valid\n;}else{isValid=validateEmail(newValue);newValidationState=isValid?\"valid\":\"invalid\";}startTransition(()=>setValidationState(newValidationState));// Use HTML5 validation API to control form submission\nif(inputRef.current){if(newValue.trim()===\"\"&&!required){inputRef.current.setCustomValidity(\"\");}else if(newValue.trim()===\"\"&&required){inputRef.current.setCustomValidity(\"This field is required\");}else if(!isValid){inputRef.current.setCustomValidity(\"Please enter a valid work email address\");}else{inputRef.current.setCustomValidity(\"\");}}// Notify parent component (Framer form) of value and validation state\nif(onValueChange){onValueChange(newValue,isValid);}},[validateEmail,required,onValueChange]);// Notify parent of initial state and set initial validation\nuseEffect(()=>{if(onValueChange){const isValid=value.trim()===\"\"?!required:validateEmail(value);onValueChange(value,isValid);}// Set initial validation state\nif(inputRef.current){if(value.trim()===\"\"&&required){inputRef.current.setCustomValidity(\"This field is required\");}else if(value.trim()!==\"\"&&!validateEmail(value)){inputRef.current.setCustomValidity(\"Please enter a valid work email address\");}else{inputRef.current.setCustomValidity(\"\");}}},[]);const handleFocus=useCallback(()=>{startTransition(()=>setIsFocused(true));},[]);const handleBlur=useCallback(()=>{startTransition(()=>setIsFocused(false));},[]);const getBorderColor=()=>{if(validationState===\"invalid\")return errorBorderColor;if(isFocused)return focusBorderColor;return borderColor;};const getValidationMessage=()=>{if(!showValidationMessage||validationState===\"none\")return null;if(validationState===\"invalid\"){return /*#__PURE__*/_jsx(\"div\",{style:{...font,fontSize:\"12px\",color:errorTextColor,marginTop:\"4px\"},children:errorMessage});}if(validationState===\"valid\"){return /*#__PURE__*/_jsx(\"div\",{style:{...font,fontSize:\"12px\",color:textColor,marginTop:\"4px\"},children:successMessage});}return null;};return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,width:\"100%\",display:\"flex\",flexDirection:\"column\"},children:[showLabel&&/*#__PURE__*/_jsxs(\"label\",{htmlFor:name,style:{...font,color:textColor,marginBottom:\"8px\",fontSize:\"14px\"},children:[label,required&&\" *\"]}),/*#__PURE__*/_jsx(\"input\",{id:name,name:name,type:\"email\",value:value,onChange:handleChange,onFocus:handleFocus,onBlur:handleBlur,placeholder:placeholder,required:required,\"data-framer-form-field\":name,\"data-valid\":validationState===\"valid\"||validationState===\"none\"&&!required,style:{...font,width:\"100%\",padding:`${padding}px`,backgroundColor,border:`2px solid ${getBorderColor()}`,borderRadius:`${borderRadius}px`,color:textColor,fontSize:\"16px\",outline:\"none\",transition:\"border-color 0.2s ease\",boxSizing:\"border-box\"},\"aria-invalid\":validationState===\"invalid\",\"aria-describedby\":showValidationMessage?\"validation-message\":undefined,\"aria-required\":required,ref:inputRef}),/*#__PURE__*/_jsx(\"input\",{type:\"hidden\",name:`${name}_validation`,value:validationState===\"valid\"||validationState===\"none\"&&!required?\"valid\":\"\",required:true,\"data-framer-form-field\":`${name}_validation`}),/*#__PURE__*/_jsx(\"div\",{id:\"validation-message\",children:getValidationMessage()})]});}addPropertyControls(WorkEmailInput,{name:{type:ControlType.String,title:\"Field Name\",defaultValue:\"workEmail\"},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Work Email\"},showLabel:{type:ControlType.Boolean,title:\"Show Label\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},required:{type:ControlType.Boolean,title:\"Required\",defaultValue:true,enabledTitle:\"Required\",disabledTitle:\"Optional\"},placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Enter your work email address\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#EEEEEE\"},focusBorderColor:{type:ControlType.Color,title:\"Focus Border\",defaultValue:\"#000000\"},errorBorderColor:{type:ControlType.Color,title:\"Error Border\",defaultValue:\"#FF5588\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},errorTextColor:{type:ControlType.Color,title:\"Error Text\",defaultValue:\"#FF5588\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"16px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:32,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:12,min:4,max:24,unit:\"px\"},showValidationMessage:{type:ControlType.Boolean,title:\"Show Validation\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},errorMessage:{type:ControlType.String,title:\"Error Message\",defaultValue:\"Please enter a valid work email address\",hidden:({showValidationMessage})=>!showValidationMessage},successMessage:{type:ControlType.String,title:\"Success Message\",defaultValue:\"Valid work email address\",hidden:({showValidationMessage})=>!showValidationMessage}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"WorkEmailInput\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./WorkEmailInput.map"],"mappings":"wMAMG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,OAAK,cAAY,QAAM,YAAU,WAAS,kBAAgB,cAAY,mBAAiB,mBAAiB,YAAU,iBAAe,OAAK,eAAa,UAAQ,eAAa,iBAAe,wBAAsB,iBAAe,EAAW,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAgB,GAAoBA,EAAS,OAAO,CAAO,EAASC,EAAO,KAAK,CAC1b,EAAc,CAAC,YAAY,YAAY,cAAc,cAAc,UAAU,aAAa,WAAW,iBAAiB,aAAa,WAAW,WAAW,UAAU,cAAc,iBAAiB,SAAS,UAAU,iBAAiB,YAAY,UAAU,eAAe,CAAO,EAAcC,EAAY,GAAO,CAC3Q,GAAG,CAAhC,6BAA4C,KAAK,EAAM,CAAE,MAAO,GACjF,IAAM,EAAO,EAAM,MAAM,IAAI,CAAC,IAAI,aAAa,CAC/C,OADoD,EAC9C,CAAC,EAAc,SAAS,EAAO,CAD8B,IAC3B,EAAE,CAAC,CAAO,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