{"version":3,"file":"PhoneValidation.3PtfjfSb.mjs","names":["useRef","__esmMin","c","J","init_jsx_runtime","ce","init_npm_react_18_3_1","de","withPhoneValidation","localRef","el","input","PHONE_PATTERN","PHONE_MESSAGE","check","Component","props","node","ref","init_PhoneValidation"],"sources":["https:/framerusercontent.com/modules/FKv78dbEB8i6t9WD9SKc/aGSXq2E2IXUWeW3fdvL6/PhoneValidation.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{forwardRef,useEffect,useRef}from\"react\";// Phone validation for a native Framer form field.\n// Apply this override to the label frame that contains the \"phone\" input.\n// Requires the international prefix: a leading \"+\" and the country code (e.g. +39), 8 to 15 digits in total;\n// spaces, dots, dashes and brackets are allowed between digits. Any country prefix is accepted.\n// No visual changes: it only sets standard HTML validation attributes on the existing input.\nconst PHONE_PATTERN=\"\\\\+[1-9](?:[\\\\s\\\\(\\\\)\\\\.\\\\-]*\\\\d){7,14}[\\\\s\\\\(\\\\)\\\\.\\\\-]*\";const PHONE_MESSAGE=\"Inserisci il numero con il prefisso internazionale, ad esempio +393331234567\";export function withPhoneValidation(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const localRef=useRef(null);useEffect(()=>{const el=localRef.current;if(!el)return;const input=el.querySelector(\"input\");if(!input)return;input.setAttribute(\"pattern\",PHONE_PATTERN);input.setAttribute(\"inputmode\",\"tel\");input.setAttribute(\"autocomplete\",\"tel\");input.setAttribute(\"maxlength\",\"24\");input.setAttribute(\"title\",PHONE_MESSAGE);const check=()=>{input.setCustomValidity(\"\");if(input.value&&input.validity.patternMismatch)input.setCustomValidity(PHONE_MESSAGE);};check();input.addEventListener(\"input\",check);return()=>input.removeEventListener(\"input\",check);},[]);return /*#__PURE__*/_jsx(Component,{...props,ref:node=>{localRef.current=node;if(typeof ref===\"function\")ref(node);else if(ref)ref.current=node;}});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withPhoneValidation\":{\"type\":\"reactHoc\",\"name\":\"withPhoneValidation\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./PhoneValidation.map"],"mappings":"A,gIAKmL,SAAgBQ,EAAoB,EAAU,CAAC,MAAoB,iBAAY,EAAM,IAAM,CAAC,IAAMC,EAAST,EAAO,IAAI,EAAsiB,OAApiBK,MAAc,CAAC,IAAMK,EAAGD,EAAS,QAAQ,GAAG,CAACC,EAAG,OAAO,IAAMC,EAAMD,EAAG,cAAc,OAAO,EAAE,GAAG,CAACC,EAAM,OAAOA,EAAM,aAAa,UAAUC,CAAa,EAAED,EAAM,aAAa,YAAY,KAAK,EAAEA,EAAM,aAAa,eAAe,KAAK,EAAEA,EAAM,aAAa,YAAY,IAAI,EAAEA,EAAM,aAAa,QAAQE,CAAa,EAAE,IAAMC,MAAU,CAACH,EAAM,kBAAkB,EAAE,EAAKA,EAAM,OAAOA,EAAM,SAAS,iBAAgBA,EAAM,kBAAkBE,CAAa,CAAE,EAAgD,OAA9CC,EAAM,EAAEH,EAAM,iBAAiB,QAAQG,CAAK,MAAYH,EAAM,oBAAoB,QAAQG,CAAK,CAAE,EAAE,CAAC,CAAC,EAAsB,gBAAKC,EAAU,CAAC,GAAGC,EAAM,IAAI,GAAM,CAAC,EAAS,QAAQC,EAAQ,OAAOC,GAAM,WAAWA,EAAID,CAAI,EAAUC,IAAI,EAAI,QAAQD,EAAK,CAAC,CAAC,CAAE,CAAC,CAAE,C,8CAAh+B,EAAc,4DAAkE,EAAc,8E"}