{"version":3,"file":"MinDigitsValidator.CeapuzI3.mjs","names":["useRef","__esmMin","init_npm_react_18_3_1","window","init_ssg_sandbox_shims","ce","init_jsx_runtime","c","p","de","ControlType","RenderTarget","init_framer_BL9pqxmF","addPropertyControls","MinDigitsValidator","props","isCanvas","mountRef","mount","scope","getEl","cssEscape","fieldName","validate","el","raw","m","codeLen","totalDigits","afterCode","minDigits","message","onInput","timers","t","cur","id","style","accent","str","init_MinDigitsValidator"],"sources":["https:/framerusercontent.com/modules/L0Dp8ullu4kZoTugwY9c/Gu27a41wdtScU327PmZz/MinDigitsValidator.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useRef}from\"react\";/**\n * Min Digits Validator\n * --------------------\n * Drop this INSIDE a form to require a field (e.g. a phone number) to contain a\n * minimum number of digits BEYOND its country code. Phone widgets often ship a\n * default dial code (e.g. \"+1\"), so the field is never truly empty and its\n * \"required\" always passes — this fixes that.\n *\n * It works via the browser's native validation: when the number is too short it\n * calls setCustomValidity() on the field, which blocks submission (native error\n * bubble shown) and also keeps any success popup from appearing (their gate uses\n * form.checkValidity()).\n *\n * Reusable on any page: just set Field Name to the field's submitted name.\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerIntrinsicWidth 240\n * @framerIntrinsicHeight 40\n * @framerDisableUnlink\n */export default function MinDigitsValidator(props){const{fieldName,minDigits,message,accent,style}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const mountRef=useRef(null);useEffect(()=>{if(isCanvas)return;const mount=mountRef.current;if(!mount)return;const scope=mount.closest(\"form\")||document;const getEl=()=>scope.querySelector(`[name=\"${cssEscape(fieldName)}\"]`);const validate=()=>{const el=getEl();if(!el||typeof el.setCustomValidity!==\"function\")return;const raw=String(el.value||\"\").trim();// Country code = the run of digits right after a leading \"+\".\nconst m=raw.match(/^\\+?(\\d+)/);const codeLen=m?m[1].length:0;const totalDigits=raw.replace(/\\D/g,\"\").length;const afterCode=Math.max(0,totalDigits-codeLen);el.setCustomValidity(afterCode>=minDigits?\"\":message);};// Run after the field's own handlers settle.\nconst onInput=()=>window.setTimeout(validate,0);validate();const el=getEl();el?.addEventListener(\"input\",onInput);el?.addEventListener(\"change\",onInput);el?.addEventListener(\"blur\",onInput);// Catch value changes that don't fire input events, and late mounts.\nconst timers=[200,600,1200,2500].map(t=>window.setTimeout(validate,t));return()=>{const cur=getEl();cur?.removeEventListener(\"input\",onInput);cur?.removeEventListener(\"change\",onInput);cur?.removeEventListener(\"blur\",onInput);cur?.setCustomValidity(\"\");timers.forEach(id=>window.clearTimeout(id));};},[isCanvas,fieldName,minDigits,message]);return /*#__PURE__*/_jsx(\"div\",{ref:mountRef,style:{display:isCanvas?\"block\":\"contents\",...style},children:isCanvas&&/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:\"8px\",padding:\"10px 12px\",border:`1.5px dashed ${accent}`,borderRadius:\"10px\",color:accent,fontSize:\"13px\",fontWeight:600,fontFamily:\"Inter, sans-serif\",width:\"fit-content\"},children:[\"✓ Validator — “\",fieldName,\"” needs \",minDigits,\"+ digits\"]})});}function cssEscape(str){return String(str).replace(/[\"\\\\]/g,\"\\\\$&\");}MinDigitsValidator.defaultProps={fieldName:\"Phone Number\",minDigits:6,message:\"Please enter a full phone number.\",accent:\"rgb(13, 89, 242)\"};addPropertyControls(MinDigitsValidator,{fieldName:{type:ControlType.String,title:\"Field Name\",defaultValue:\"Phone Number\",description:\"The submitted name of the field to validate.\"},minDigits:{type:ControlType.Number,title:\"Min Digits\",defaultValue:6,min:1,max:20,step:1,description:\"Minimum digits required beyond the country code.\"},message:{type:ControlType.String,title:\"Error Message\",defaultValue:\"Please enter a full phone number.\"},accent:{type:ControlType.Color,title:\"Accent\",defaultValue:\"rgb(13, 89, 242)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MinDigitsValidator\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"40\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any\",\"framerIntrinsicWidth\":\"240\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MinDigitsValidator.map"],"mappings":"A,+MAoBG,SAAwBc,EAAmB,EAAM,CAAC,GAAK,CAAC,YAAU,YAAU,UAAQ,SAAO,SAAOC,EAAYC,EAASL,EAAa,QAAQ,IAAIA,EAAa,OAAaM,EAASjB,EAAO,IAAI,EAGoJ,OAHlJK,MAAc,CAAC,GAAGW,EAAS,OAAO,IAAME,EAAMD,EAAS,QAAQ,GAAG,CAACC,EAAM,OAAO,IAAMC,EAAMD,EAAM,QAAQ,MAAM,GAAG,SAAeE,MAAUD,EAAM,cAAc,UAAUE,EAAUC,CAAS,EAAE,GAAG,EAAQC,MAAa,CAAC,IAAMC,EAAGJ,EAAM,EAAE,GAAG,CAACI,GAAI,OAAOA,EAAG,mBAAoB,WAAW,OAAO,IAAMC,EAAI,OAAOD,EAAG,OAAO,EAAE,CAAC,CAAC,KAAK,EAClgBE,EAAED,EAAI,MAAM,WAAW,EAAQE,EAAQD,EAAEA,EAAE,EAAE,CAAC,OAAO,EAAQE,EAAYH,EAAI,QAAQ,MAAM,EAAE,CAAC,CAAC,OAAaI,EAAU,KAAK,IAAI,EAAED,EAAYD,CAAO,EAAEH,EAAG,kBAAkBK,GAAWC,EAAU,GAAGC,CAAO,CAAE,EAC5MC,MAAY7B,EAAO,WAAWoB,EAAS,CAAC,EAAEA,EAAS,EAAE,IAAMC,EAAGJ,EAAM,EAAEI,GAAI,iBAAiB,QAAQQ,CAAO,EAAER,GAAI,iBAAiB,SAASQ,CAAO,EAAER,GAAI,iBAAiB,OAAOQ,CAAO,EAC5L,IAAMC,EAAO,CAAC,IAAI,IAAI,KAAK,IAAI,CAAC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