{"version":3,"file":"CorporateEmailInput.CETUmLAL.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/c9thtvgf6U68oJ0ekF0t/RQaPtsCsl79tIGwUw5Ht/CorporateEmailInput.js"],"sourcesContent":["// Input component that only allows emails from corporate domains via regex\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,startTransition,useEffect,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";export default function CorporateEmailInput(props){const{label,placeholder,placeholderColor,errorMsg,excludedDomains,textColor,background,inputBackground,font,borderRadius,style,borderColor,focusBorderColor,focusBorderWidth,errorBorderColor,errorBorderWidth,errorTextColor,errorBackgroundColor,errorFont,successMsg,successTextColor,successBackgroundColor,successBorderColor,successBorderWidth,successPadding,successFont}=props;const[value,setValue]=useState(\"\");const[touched,setTouched]=useState(false);const[submitted,setSubmitted]=useState(false);const inputRef=useRef(null);// Regex: match email and force @allowedDomain only\n// Supporting exclusion: allow any domain EXCEPT excludedDomains (comma separated regex or plain domain)\nconst excludedArr=(excludedDomains||\"\").split(\",\").map(d=>d.trim()).filter(Boolean);const excludedPattern=excludedArr.length?new RegExp(`@(${excludedArr.map(d=>d.replace(/^@?/,\"\").replace(/[-/\\\\^$*+?.()|[\\]{}]/g,\"\\\\$&\")).join(\"|\")})$`,\"i\"):null;const anyEmail=/^[a-zA-Z0-9._%+-]+@([a-zA-Z0-9.-]+\\.[a-zA-Z]{2,})$/;const isValid=anyEmail.test(value)&&!(excludedPattern&&excludedPattern.test(value));function onChange(e){const input=e.target;// The value of a controlled input has to update urgently. Inside\n// startTransition React can re-render the input with the previous\n// value, which rewrites the DOM value and puts the caret back at the\n// end — making it impossible to fix a typo mid-address.\nsetValue(input.value);// Update custom validity\nif(input){const testValue=e.target.value;const testValid=anyEmail.test(testValue)&&!(excludedPattern&&excludedPattern.test(testValue));if(testValue&&!testValid){input.setCustomValidity(errorMsg);}else{input.setCustomValidity(\"\");}}}function onBlur(){setTouched(true);}// Listen for parent form submission\nuseEffect(()=>{const input=inputRef.current;if(!input)return;const form=input.closest(\"form\");if(!form)return;const handleSubmit=e=>{// Check if this input has a valid email\nif(isValid&&value){startTransition(()=>{setSubmitted(true);setTouched(false);});// Reset success message after 5 seconds\nsetTimeout(()=>{startTransition(()=>setSubmitted(false));},5e3);}};form.addEventListener(\"submit\",handleSubmit);return()=>form.removeEventListener(\"submit\",handleSubmit);},[isValid,value]);const showError=touched&&value.length>0&&!isValid;return /*#__PURE__*/_jsxs(\"div\",{style:{...style,width:\"100%\",display:\"flex\",flexDirection:\"column\",gap:6,background,borderRadius,...font},children:[/*#__PURE__*/_jsx(\"label\",{htmlFor:\"email\",style:{color:textColor,fontWeight:500,marginBottom:4,display:\"none\"},children:label}),/*#__PURE__*/_jsx(\"input\",{ref:inputRef,id:\"email\",type:\"email\",value:value,placeholder:placeholder,style:{padding:\"14px 12px\",borderRadius,border:showError?`${errorBorderWidth}px solid ${errorBorderColor}`:submitted?`${props.successBorderWidth}px solid ${props.successBorderColor}`:`1px solid ${borderColor}`,outline:\"none\",fontSize:font?.fontSize,...font,background:inputBackground,width:\"100%\",// @ts-ignore\n\"--placeholder-color\":placeholderColor,\"--focus-border-color\":focusBorderColor,\"--focus-border-width\":`${focusBorderWidth}px`},onChange:onChange,onBlur:onBlur,required:true,\"aria-invalid\":showError?\"true\":undefined,name:\"email\",autoComplete:\"email\"}),/*#__PURE__*/_jsx(\"style\",{children:`\n                #email::placeholder {\n                    color: var(--placeholder-color);\n                    opacity: 1;\n                }\n                #email:focus {\n                    border: var(--focus-border-width) solid var(--focus-border-color) !important;\n                }\n            `}),showError&&/*#__PURE__*/_jsx(\"div\",{style:{color:errorTextColor,marginTop:4,padding:props.errorPadding,textAlign:\"center\",background:errorBackgroundColor,borderRadius:borderRadius/2,...errorFont},children:errorMsg}),submitted&&!showError&&/*#__PURE__*/_jsx(\"div\",{style:{color:props.successTextColor,marginTop:4,padding:props.successPadding,textAlign:\"center\",background:props.successBackgroundColor,borderRadius:borderRadius/2,...props.successFont},children:props.successMsg})]});}addPropertyControls(CorporateEmailInput,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Work Email\"},placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"john@company.com\"},placeholderColor:{type:ControlType.Color,title:\"Placeholder Color\",defaultValue:\"#CCCCCC\"},errorMsg:{type:ControlType.String,title:\"Error Message\",defaultValue:\"Please provide your corporate email address.\"},excludedDomains:{type:ControlType.String,title:\"Excluded Domains\",defaultValue:\"\",placeholder:\"comma, separated, domains.com\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},inputBackground:{type:ControlType.Color,title:\"Input Background\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,max:24},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#EEEEEE\"},errorPadding:{type:ControlType.Padding,title:\"Error Padding\",defaultValue:\"4px 8px 4px 8px\"},focusBorderColor:{type:ControlType.Color,title:\"Focus Border Color\",defaultValue:\"#0099FF\"},focusBorderWidth:{type:ControlType.Number,title:\"Focus Border Width\",defaultValue:2,min:1,max:5,step:1,unit:\"px\"},errorBorderColor:{type:ControlType.Color,title:\"Error Border Color\",defaultValue:\"#FF5588\"},errorBorderWidth:{type:ControlType.Number,title:\"Error Border Width\",defaultValue:2,min:1,max:5,step:1,unit:\"px\"},errorTextColor:{type:ControlType.Color,title:\"Error Text Color\",defaultValue:\"#FF5588\"},errorBackgroundColor:{type:ControlType.Color,title:\"Error Background\",defaultValue:\"transparent\"},errorFont:{type:ControlType.Font,title:\"Error Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"13px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},successMsg:{type:ControlType.String,title:\"Success Message\",defaultValue:\"Thank you! We'll be in touch soon.\"},successTextColor:{type:ControlType.Color,title:\"Success Text Color\",defaultValue:\"#22CC66\"},successBackgroundColor:{type:ControlType.Color,title:\"Success Background\",defaultValue:\"transparent\"},successBorderColor:{type:ControlType.Color,title:\"Success Border Color\",defaultValue:\"#22CC66\"},successBorderWidth:{type:ControlType.Number,title:\"Success Border Width\",defaultValue:2,min:1,max:5,step:1,unit:\"px\"},successPadding:{type:ControlType.Padding,title:\"Success Padding\",defaultValue:\"4px 8px 4px 8px\"},successFont:{type:ControlType.Font,title:\"Success Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"13px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CorporateEmailInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CorporateEmailInput.map"],"mappings":"uMAC0K,SAAwB,EAAoB,EAAM,CAAC,GAAK,CAAC,QAAM,cAAY,mBAAiB,WAAS,kBAAgB,YAAU,aAAW,kBAAgB,OAAK,eAAa,QAAM,cAAY,mBAAiB,mBAAiB,mBAAiB,mBAAiB,iBAAe,uBAAqB,YAAU,aAAW,mBAAiB,yBAAuB,qBAAmB,qBAAmB,iBAAe,eAAa,EAAW,CAAC,EAAM,GAAUA,EAAS,EAAE,EAAO,CAAC,EAAQ,GAAYA,EAAS,EAAK,EAAO,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAQ,EAASC,EAAO,IAAI,EAEpuB,GAAa,GAAiB,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,OAAO,EAAQ,EAAg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