{"version":3,"file":"CustomPhoneInput.CFaKpDDB.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/0CiZN2KlgCLQzlLS039A/fqDQwsBIJJEv5AGVL3Mr/CustomPhoneInput.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";// --- Framer Store (Copied for local use, but it's the SAME store as the overrides) ---\nconst useValidationStore=createStore({isValid:true,errors:{},submitted:false});/**\n * A custom phone number input component with built-in validation and customizable error messages.\n * This component integrates with the global form validation store.\n */export function CustomPhoneInput({name=\"phone\",placeholder=\"Enter phone number\",required=false,showErrorsImmediately=false,fontFamily=\"Arial\",fontSize=16,fontWeight=\"normal\",color=\"#333\",backgroundColor=\"#F5F5F5\",borderRadius=8,padding=12,width=\"100%\",height=48,borderColor=\"#E0E0E0\",borderWidth=1,customEmptyPhoneMessage,customInvalidPhoneMessage,onChange}){const[value,setValue]=useState(\"\");const[store,setStore]=useValidationStore();const[isTouched,setIsTouched]=useState(false);const phoneRegex=/^\\d{9,10}$/;const validate=inputValue=>{let currentErrorMessage=\"\";const isEmpty=inputValue.trim()===\"\";if(required&&isEmpty){currentErrorMessage=customEmptyPhoneMessage||\"מספר הטלפון אינו יכול להיות ריק.\";}else if(!isEmpty&&!phoneRegex.test(inputValue)){currentErrorMessage=customInvalidPhoneMessage||\"מספר הטלפון חייב להיות בן 9 או 10 ספרות (מספרים בלבד).\";}// --- Debugging ---\n// console.log(`[${name}] Validating: \"${inputValue}\" -> Error: \"${currentErrorMessage}\"`);\n// --- End Debugging ---\nsetStore(prev=>({...prev,errors:{...prev.errors,[name]:currentErrorMessage}}));return currentErrorMessage===\"\";};// Initial validation when component mounts or required prop changes\n// This ensures the store is populated with initial validity before any user interaction\nuseEffect(()=>{validate(value);},[required]);const handleChange=e=>{const newValue=e.target.value;setValue(newValue);// --- CRITICAL FIX: Always validate on change to keep store updated ---\nvalidate(newValue);// --- End CRITICAL FIX ---\nif(onChange){onChange(newValue);}};const handleBlur=()=>{setIsTouched(true);validate(value)// Validate on blur to ensure the final state is captured\n;};// Determine if visual error should be shown\nconst showVisualError=showErrorsImmediately&&isTouched&&store.errors[name]||// Show immediately if toggled, touched, and error exists\nstore.submitted&&store.errors[name]// OR show if form submitted and error exists\n;// Dynamic border style\nconst effectiveBorderStyle=showVisualError?`1px solid red`:`${borderWidth}px solid ${borderColor}`;return /*#__PURE__*/_jsxs(\"div\",{style:{width:width,height:height,position:\"relative\",marginBottom:showVisualError?20:0},children:[/*#__PURE__*/_jsx(\"input\",{type:\"tel\",name:name,placeholder:placeholder,value:value,onChange:handleChange,onBlur:handleBlur,onFocus:()=>setIsTouched(true),style:{width:\"100%\",height:\"100%\",fontSize:fontSize,color:color,backgroundColor:backgroundColor,borderRadius:borderRadius,padding:`${padding}px`,border:effectiveBorderStyle,outline:\"none\",boxSizing:\"border-box\",textAlign:\"right\",direction:\"rtl\",fontFamily:fontFamily,fontWeight:fontWeight}}),showVisualError&&/*#__PURE__*/_jsx(\"div\",{style:{color:\"red\",fontSize:\"12px\",marginTop:\"4px\",textAlign:\"right\",direction:\"rtl\",position:\"absolute\",width:\"100%\",bottom:\"-16px\",left:0},children:store.errors[name]})]});}// --- Property Controls for Framer UI ---\naddPropertyControls(CustomPhoneInput,{name:{type:ControlType.String,title:\"Name\",defaultValue:\"phone\",placeholder:\"e.g., phone\",tooltip:\"Unique identifier for this input in the form validation store.\"},placeholder:{type:ControlType.String,title:\"Placeholder\",defaultValue:\"Enter phone number\",placeholder:\"e.g., 0501234567\"},required:{type:ControlType.Boolean,title:\"Required\",defaultValue:false,tooltip:\"Check if this field is mandatory for form submission.\"},showErrorsImmediately:{type:ControlType.Boolean,title:\"Show Errors Immediately\",defaultValue:false,tooltip:\"If checked, errors will appear as you type or on blur, not just on submit.\"},fontFamily:{type:ControlType.String,title:\"Font Family\",defaultValue:\"Arial\",placeholder:\"e.g., Assistant, Inter\",tooltip:\"Enter the exact name of a font available in Framer.\"},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:16,min:8,max:64,step:1},fontWeight:{type:ControlType.Enum,title:\"Font Weight\",defaultValue:\"normal\",options:[\"normal\",\"bold\",\"100\",\"200\",\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],optionTitles:[\"Normal\",\"Bold\",\"100 Thin\",\"200 Extra Light\",\"300 Light\",\"400 Regular\",\"500 Medium\",\"600 Semi Bold\",\"700 Bold\",\"800 Extra Bold\",\"900 Black\"],tooltip:\"Select a font weight. Available weights depend on the font family.\"},color:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#333\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#F5F5F5\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:8,min:0,step:1},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:12,min:0,step:1},width:{type:ControlType.String,title:\"Width\",defaultValue:\"100%\",placeholder:\"e.g., 200px, 100%\"},height:{type:ControlType.Number,title:\"Height\",defaultValue:48,min:20,step:1},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#E0E0E0\"},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:1,min:0,max:5,step:.5},customEmptyPhoneMessage:{type:ControlType.String,title:\"Empty Message\",defaultValue:\"מספר הטלפון אינו יכול להיות ריק.\",placeholder:\"e.g., Phone cannot be empty.\",tooltip:\"Custom message when the field is empty.\"},customInvalidPhoneMessage:{type:ControlType.String,title:\"Invalid Message\",defaultValue:\"מספר הטלפון חייב להיות בן 9 או 10 ספרות (מספרים בלבד).\",placeholder:\"e.g., Phone must be 9 or 10 digits.\",tooltip:\"Custom message when the phone number format is invalid.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"CustomPhoneInput\":{\"type\":\"reactComponent\",\"name\":\"CustomPhoneInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\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