{"version":3,"file":"FormValidation.DAxcpSA0.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/COnFG27uHHxU0EWvg927/uUkzphDyYlwGnqA5nmjn/FormValidation.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState}from\"react\";const MOBILE_PHONE_REGEX=/^01[016789]-[0-9]{3,4}-[0-9]{4}$/;const formatMobilePhone=raw=>{let n=raw.replace(/[^0-9]/g,\"\");if(n.length>0&&!n.startsWith(\"0\")){n=\"0\"+n;}if(n.length>=2&&n[1]!==\"1\"){n=n.slice(0,1);}if(n.length>=3&&!\"016789\".includes(n[2])){n=n.slice(0,2);}n=n.slice(0,11);if(!n)return\"\";if(n.length<=3)return n;if(n.length<=7)return`${n.slice(0,3)}-${n.slice(3)}`;if(n.length===11){return`${n.slice(0,3)}-${n.slice(3,7)}-${n.slice(7,11)}`;}return`${n.slice(0,3)}-${n.slice(3,6)}-${n.slice(6,10)}`;};// 유효성 검사: 숫자 11자리 완성 + 형식 일치\nconst isValidMobile=formatted=>{const digits=formatted.replace(/[^0-9]/g,\"\");return digits.length===11&&MOBILE_PHONE_REGEX.test(formatted);};const ALLOWED_KEYS=[\"Backspace\",\"Delete\",\"Tab\",\"Escape\",\"Enter\",\"Home\",\"End\",\"ArrowLeft\",\"ArrowRight\",\"ArrowUp\",\"ArrowDown\"];export function withKoreanPhoneValidation(Component){return props=>{const[value,setValue]=useState(props.value??\"\");const[isValid,setIsValid]=useState(true);const[touched,setTouched]=useState(false);const handleKeyDown=event=>{if(event.ctrlKey||event.metaKey)return;if(ALLOWED_KEYS.includes(event.key))return;if(!/^[0-9]$/.test(event.key)){event.preventDefault();return;}const target=event.target;const currentDigits=target.value.replace(/[^0-9]/g,\"\");const hasSelection=target.selectionStart!==target.selectionEnd;if(currentDigits.length>=11&&!hasSelection){event.preventDefault();}};const handleInput=event=>{const target=event.target;const filtered=target.value.replace(/[^0-9]/g,\"\");if(target.value!==filtered){target.value=filtered;}};const handleCompositionEnd=event=>{const target=event.target;const formatted=formatMobilePhone(target.value);target.value=formatted;setValue(formatted);setIsValid(formatted.length===0||isValidMobile(formatted));if(props.onChange){props.onChange({target,currentTarget:target});}};const handlePaste=event=>{event.preventDefault();const pasted=event.clipboardData.getData(\"text\");const formatted=formatMobilePhone(pasted);setValue(formatted);setIsValid(formatted.length===0||isValidMobile(formatted));if(props.onChange){const synthetic={target:{value:formatted},currentTarget:{value:formatted}};props.onChange(synthetic);}};const handleChange=event=>{const raw=typeof event===\"string\"?event:event?.target?.value??\"\";const formatted=formatMobilePhone(raw);setValue(formatted);// 입력 중에는 11자리 미만이어도 에러 표시 안 함 (빈 값 제외)\nsetIsValid(formatted.length===0||isValidMobile(formatted));if(props.onChange){if(event?.target){event.target.value=formatted;props.onChange(event);}else{props.onChange(formatted);}}};// 포커스 벗어날 때(blur) 비로소 \"11자 완성 여부\"로 최종 판정\nconst handleBlur=event=>{setTouched(true);setIsValid(value.length===0||isValidMobile(value));if(props.onBlur){props.onBlur(event);}};// touched 이후에는 실시간으로도 11자 미완성이면 에러 표시\nconst showError=touched&&value.length>0&&!isValidMobile(value);return /*#__PURE__*/_jsx(Component,{...props,value:value,onChange:handleChange,onKeyDown:handleKeyDown,onInput:handleInput,onCompositionEnd:handleCompositionEnd,onPaste:handlePaste,onBlur:handleBlur,inputMode:\"numeric\",type:\"tel\",maxLength:13,placeholder:props.placeholder??\"010-1234-5678\",style:{...props.style,imeMode:\"disabled\",border:showError?\"1px solid #FF0000\":props.style?.border,boxShadow:showError?\"0 0 0 1px #FF0000\":props.style?.boxShadow}});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withKoreanPhoneValidation\":{\"type\":\"reactHoc\",\"name\":\"withKoreanPhoneValidation\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FormValidation.map"],"mappings":"kHAC0Q,SAAgB,EAA0B,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,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