{"version":3,"file":"FileLinkButton.DopeWmON.mjs","names":["useRef","useState","startTransition"],"sources":["https:/framerusercontent.com/modules/VxTEMy2d6JlrIQqYPXPL/MdkcylM6n6cShw8X2z7f/FileLinkButton.js"],"sourcesContent":["// Button component for enabling file uploads in Framer forms\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * File Upload Button for Framer Forms\n * \n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function FileLinkButton(props){const{label,acceptedTypes,multiple,backgroundColor,textColor,hoverColor,borderRadius,padding,font,disabled,maxFileSize,onFileSelect}=props;const fileInputRef=useRef(null);const[isHovered,setIsHovered]=useState(false);const[selectedFiles,setSelectedFiles]=useState([]);const handleButtonClick=()=>{if(!disabled&&fileInputRef.current){fileInputRef.current.click();}};const handleFileChange=event=>{const files=event.target.files;if(files){const fileNames=[];const validFiles=[];for(let i=0;i<files.length;i++){const file=files[i];if(file.size<=maxFileSize*1024*1024){fileNames.push(file.name);validFiles.push(file);}}startTransition(()=>{setSelectedFiles(fileNames);});if(onFileSelect){const fileList=new DataTransfer;validFiles.forEach(file=>fileList.items.add(file));onFileSelect(fileList.files);}}};const displayText=selectedFiles.length>0?`${selectedFiles.length} file${selectedFiles.length>1?\"s\":\"\"} selected`:label;return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"inline-block\",position:\"relative\"},children:[/*#__PURE__*/_jsx(\"input\",{ref:fileInputRef,type:\"file\",accept:acceptedTypes,multiple:multiple,onChange:handleFileChange,style:{position:\"absolute\",opacity:0,pointerEvents:\"none\",width:0,height:0},disabled:disabled}),/*#__PURE__*/_jsxs(\"button\",{type:\"button\",onClick:handleButtonClick,onMouseEnter:()=>startTransition(()=>setIsHovered(true)),onMouseLeave:()=>startTransition(()=>setIsHovered(false)),disabled:disabled,style:{backgroundColor:disabled?\"#CCCCCC\":isHovered?hoverColor:backgroundColor,color:disabled?\"#666666\":textColor,border:\"none\",borderRadius:`${borderRadius}px`,padding:`${padding}px ${padding*1.5}px`,cursor:disabled?\"not-allowed\":\"pointer\",transition:\"all 0.2s ease\",outline:\"none\",display:\"flex\",alignItems:\"center\",gap:\"8px\",...font,opacity:disabled?.6:1},\"aria-label\":`Upload file. ${selectedFiles.length>0?`${selectedFiles.length} files selected`:\"No files selected\"}`,children:[/*#__PURE__*/_jsxs(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"7,10 12,15 17,10\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"12\",y1:\"15\",x2:\"12\",y2:\"3\"})]}),displayText]}),selectedFiles.length>0&&/*#__PURE__*/_jsxs(\"div\",{style:{marginTop:\"8px\",fontSize:\"12px\",color:\"#666666\",...font},children:[selectedFiles.slice(0,3).map((fileName,index)=>/*#__PURE__*/_jsx(\"div\",{style:{marginBottom:\"2px\"},children:fileName},index)),selectedFiles.length>3&&/*#__PURE__*/_jsxs(\"div\",{style:{fontStyle:\"italic\"},children:[\"+\",selectedFiles.length-3,\" more files\"]})]})]});}addPropertyControls(FileLinkButton,{label:{type:ControlType.String,title:\"Button Label\",defaultValue:\"Choose File\"},acceptedTypes:{type:ControlType.String,title:\"Accepted File Types\",defaultValue:\".pdf,.doc,.docx,.jpg,.png\",placeholder:\".pdf,.doc,.jpg\"},multiple:{type:ControlType.Boolean,title:\"Multiple Files\",defaultValue:false,enabledTitle:\"Allow\",disabledTitle:\"Single\"},maxFileSize:{type:ControlType.Number,title:\"Max File Size (MB)\",defaultValue:10,min:1,max:100,step:1},backgroundColor:{type:ControlType.Color,title:\"Background Color\",defaultValue:\"#000000\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},hoverColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#333333\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:32,step:1,unit:\"px\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:12,min:4,max:32,step:1,unit:\"px\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},disabled:{type:ControlType.Boolean,title:\"Disabled\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FileLinkButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FileLinkButton.map"],"mappings":"wRAMG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,gBAAc,WAAS,kBAAgB,YAAU,aAAW,eAAa,UAAQ,OAAK,WAAS,cAAY,gBAAc,EAAY,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcC,EAAS,GAAM,CAAM,CAAC,EAAc,GAAkBA,EAAS,EAAE,CAAC,CAAO,MAAsB,CAAI,CAAC,GAAU,EAAa,SAAS,EAAa,QAAQ,OAAO,EAAU,EAAiB,GAAO,CAAC,IAAM,EAAM,EAAM,OAAO,MAAM,GAAG,EAAM,CAAC,IAAM,EAAU,EAAE,CAAO,EAAW,EAAE,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,EAAM,OAAO,IAAI,CAAC,IAAM,EAAK,EAAM,GAAM,EAAK,MAAM,EAAY,KAAK,OAAM,EAAU,KAAK,EAAK,KAAK,CAAC,EAAW,KAAK,EAAK,EAAuD,GAApD,MAAoB,CAAC,EAAi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