{"version":3,"file":"FileUploadInput.V0f1Oa8D.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/zcu9MdQqUM9WEzB8sZkS/Zc91DEDLcz2epEQrMwOo/FileUploadInput.js"],"sourcesContent":["// FileUploadInput: Framer file upload input that binds with Framer Form. Uploads to Cloudinary and validates file size (max 5MB).\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * FileUploadInput\n *\n * Framer file upload input that binds with Framer Form. Supports multiple files.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function FileUploadInput(props){const{acceptedTypes,maxSizeMB,errorMessage,buttonText,backgroundColor,textColor,buttonColor,buttonTextColor,borderRadius,borderWidth,borderColor,required,multiple,fieldName,style}=props;const fileInputRef=useRef(null);const[selectedFiles,setSelectedFiles]=useState([]);const[error,setError]=useState(\"\");const handleFileChange=e=>{const files=Array.from(e.target.files||[]);if(!files.length){startTransition(()=>{setSelectedFiles([]);setError(\"\");});return;}const maxSizeBytes=maxSizeMB*1024*1024;const oversized=files.find(f=>f.size>maxSizeBytes);if(oversized){startTransition(()=>{setSelectedFiles([]);setError(errorMessage||`File size must be less than ${maxSizeMB}MB`);});if(fileInputRef.current){fileInputRef.current.value=\"\";}return;}startTransition(()=>{setSelectedFiles(files);setError(\"\");});};const handleButtonClick=()=>{fileInputRef.current?.click();};if(RenderTarget.current()===RenderTarget.thumbnail)return null;const name=multiple?`${fieldName}[]`:fieldName;return /*#__PURE__*/_jsxs(\"div\",{style:{width:\"100%\",display:\"flex\",flexDirection:\"column\",...style},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:12,padding:\"10px 12px\",backgroundColor,borderRadius,border:`${borderWidth}px solid ${error?\"#c00\":borderColor}`,minHeight:44},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:handleButtonClick,style:{padding:\"8px 16px\",backgroundColor:buttonColor,color:buttonTextColor,border:\"none\",borderRadius:borderRadius-2,fontSize:14,fontWeight:500,cursor:\"pointer\",whiteSpace:\"nowrap\"},children:buttonText}),/*#__PURE__*/_jsx(\"span\",{style:{fontSize:14,color:selectedFiles.length>0?textColor:\"#999\",overflow:\"hidden\",textOverflow:\"ellipsis\",whiteSpace:\"nowrap\"},children:selectedFiles.length>0?selectedFiles.length===1?selectedFiles[0].name:`${selectedFiles.length} files selected`:\"No file chosen\"}),/*#__PURE__*/_jsx(\"input\",{ref:fileInputRef,type:\"file\",name:name,multiple:multiple,accept:acceptedTypes,onChange:handleFileChange,required:required,style:{position:\"absolute\",width:1,height:1,padding:0,margin:-1,overflow:\"hidden\",clip:\"rect(0, 0, 0, 0)\",whiteSpace:\"nowrap\",border:0}})]}),error&&/*#__PURE__*/_jsx(\"span\",{style:{color:\"#c00\",fontSize:13},children:error})]});}addPropertyControls(FileUploadInput,{fieldName:{type:ControlType.String,title:\"Field Name\",defaultValue:\"files\",placeholder:\"e.g., files\"},multiple:{type:ControlType.Boolean,title:\"Multiple\",defaultValue:false},required:{type:ControlType.Boolean,title:\"Required\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},acceptedTypes:{type:ControlType.String,title:\"Accepted Types\",defaultValue:\"image/*,.pdf,.doc,.docx\",placeholder:\"e.g., image/*,.pdf\"},maxSizeMB:{type:ControlType.Number,title:\"Max Size (MB)\",defaultValue:5,min:1,max:50,step:1},errorMessage:{type:ControlType.String,title:\"Error Message\",defaultValue:\"File size must be less than 5MB\"},buttonText:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Choose File\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},buttonColor:{type:ControlType.Color,title:\"Button Color\",defaultValue:\"#0099FF\"},buttonTextColor:{type:ControlType.Color,title:\"Button Text\",defaultValue:\"#FFFFFF\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#DDDDDD\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:32,step:1},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:1,min:0,max:10,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FileUploadInput\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FileUploadInput.map"],"mappings":"uMAQG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,gBAAc,YAAU,eAAa,aAAW,kBAAgB,YAAU,cAAY,kBAAgB,eAAa,cAAY,cAAY,WAAS,WAAS,YAAU,SAAO,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAc,GAAkBC,EAAS,EAAE,CAAC,CAAM,CAAC,EAAM,GAAUA,EAAS,GAAG,CAAO,EAAiB,GAAG,CAAC,IAAM,EAAM,MAAM,KAAK,EAAE,OAAO,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,EAAM,OAAO,CAAC,MAAoB,CAAC,EAAiB,EAAE,CAAC,CAAC,EAAS,GAAG,EAAG,CAAC,OAAQ,IAAM,EAAa,EAAU,KAAK,KAAwD,GAAnC,EAAM,KAAK,GAAG,EAAE,KAAK,EAAa,CAAc,CAAC,MAAoB,CAAC,EAAiB,EAAE,CAAC,CAAC,EAAS,GAAc,+BAA+B,EAAU,IAAI,EAAG,CAAI,EAAa,UAAS,EAAa,QAAQ,MAAM,IAAI,OAAQ,MAAoB,CAAC,EAAiB,EAAM,CAAC,EAAS,GAAG,EAAG,EAAS,MAAsB,CAAC,EAAa,SAAS,OAAO,EAAG,GAAG,EAAa,SAAS,GAAG,EAAa,UAAU,OAAO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