{"version":3,"file":"INeedHave.Cv4js5kk.mjs","names":["useState","useRef","startTransition"],"sources":["https:/framerusercontent.com/modules/sCxYqcLL8dEqZ9K9Qphh/AKgC6LXTL1TQuozaSqY5/INeedHave.js"],"sourcesContent":["// Customizable download button for PDF files with full styling control\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,startTransition,useRef}from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function INeedHave(props){const{label=\"Download PDF\",uploadedFile=\"https://framerusercontent.com/assets/sample.pdf\",fileName=\"document.pdf\",backgroundColor=\"#000000\",textColor=\"#FFFFFF\",hoverBackgroundColor=\"#333333\",hoverTextColor=\"#FFFFFF\",borderRadius=8,padding=\"12px 24px\",font,showIcon=true,iconPosition=\"left\",disabled=false,width=\"auto\",showUploadArea=false,uploadAreaText=\"Click to upload file or drag and drop\"}=props;const[isHovered,setIsHovered]=useState(false);const[isDownloading,setIsDownloading]=useState(false);const[isDragOver,setIsDragOver]=useState(false);const[currentFile,setCurrentFile]=useState(null);const fileInputRef=useRef(null);const handleDownload=async()=>{if(disabled||isDownloading)return;startTransition(()=>setIsDownloading(true));try{let fileUrl=uploadedFile;let downloadFileName=fileName;// If user uploaded a file through the upload area, use that instead\nif(currentFile){fileUrl=URL.createObjectURL(currentFile);downloadFileName=currentFile.name;}const response=await fetch(fileUrl);const blob=await response.blob();const url=window.URL.createObjectURL(blob);const link=document.createElement(\"a\");link.href=url;link.download=downloadFileName;document.body.appendChild(link);link.click();document.body.removeChild(link);window.URL.revokeObjectURL(url);}catch(error){console.error(\"Download failed:\",error);}finally{startTransition(()=>setIsDownloading(false));}};const handleFileUpload=file=>{startTransition(()=>setCurrentFile(file));};const handleFileInputChange=event=>{const file=event.target.files?.[0];if(file){handleFileUpload(file);}};const handleDragOver=event=>{event.preventDefault();startTransition(()=>setIsDragOver(true));};const handleDragLeave=event=>{event.preventDefault();startTransition(()=>setIsDragOver(false));};const handleDrop=event=>{event.preventDefault();startTransition(()=>setIsDragOver(false));const file=event.dataTransfer.files?.[0];if(file){handleFileUpload(file);}};const handleUploadAreaClick=()=>{fileInputRef.current?.click();};const currentBackgroundColor=isHovered&&!disabled?hoverBackgroundColor:backgroundColor;const currentTextColor=isHovered&&!disabled?hoverTextColor:textColor;const downloadIcon=/*#__PURE__*/_jsxs(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",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\"})]});const uploadIcon=/*#__PURE__*/_jsxs(\"svg\",{width:\"24\",height:\"24\",viewBox:\"0 0 24 24\",fill:\"none\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\",children:[/*#__PURE__*/_jsx(\"path\",{d:\"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4\"}),/*#__PURE__*/_jsx(\"polyline\",{points:\"17,8 12,3 7,8\"}),/*#__PURE__*/_jsx(\"line\",{x1:\"12\",y1:\"3\",x2:\"12\",y2:\"15\"})]});const isFixedWidth=props?.style&&props.style.width===\"100%\";if(showUploadArea){return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",display:\"flex\",flexDirection:\"column\",gap:\"12px\",...width===\"full\"||isFixedWidth?{width:\"100%\"}:{width:\"auto\",minWidth:\"max-content\"}},children:[/*#__PURE__*/_jsxs(\"div\",{onClick:handleUploadAreaClick,onDragOver:handleDragOver,onDragLeave:handleDragLeave,onDrop:handleDrop,style:{border:`2px dashed ${isDragOver?backgroundColor:\"#CCCCCC\"}`,borderRadius:borderRadius,padding:\"24px\",textAlign:\"center\",cursor:\"pointer\",backgroundColor:isDragOver?`${backgroundColor}10`:\"#F5F5F5\",transition:\"all 0.2s ease\",...font},children:[uploadIcon,/*#__PURE__*/_jsx(\"div\",{style:{marginTop:\"8px\",color:\"#666666\"},children:currentFile?`Selected: ${currentFile.name}`:uploadAreaText})]}),/*#__PURE__*/_jsx(\"input\",{ref:fileInputRef,type:\"file\",onChange:handleFileInputChange,style:{display:\"none\"},accept:\".pdf,.doc,.docx,.txt,.jpg,.jpeg,.png,.gif,.webp,.svg,.mp4,.webm,.mov,.mp3,.wav,.ogg\"}),/*#__PURE__*/_jsxs(\"button\",{onClick:handleDownload,disabled:disabled||isDownloading||!currentFile&&!uploadedFile,onMouseEnter:()=>startTransition(()=>setIsHovered(true)),onMouseLeave:()=>startTransition(()=>setIsHovered(false)),style:{position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",gap:showIcon?\"8px\":\"0\",backgroundColor:currentBackgroundColor,color:currentTextColor,border:\"none\",borderRadius:borderRadius,padding:padding,cursor:disabled||isDownloading||!currentFile&&!uploadedFile?\"not-allowed\":\"pointer\",opacity:disabled||!currentFile&&!uploadedFile?.6:1,transition:\"all 0.2s ease\",outline:\"none\",textDecoration:\"none\",width:\"100%\",...font},\"aria-label\":`Download ${currentFile?.name||fileName}`,role:\"button\",children:[showIcon&&iconPosition===\"left\"&&downloadIcon,/*#__PURE__*/_jsx(\"span\",{children:isDownloading?\"Downloading...\":label}),showIcon&&iconPosition===\"right\"&&downloadIcon]})]});}return /*#__PURE__*/_jsxs(\"button\",{onClick:handleDownload,disabled:disabled||isDownloading,onMouseEnter:()=>startTransition(()=>setIsHovered(true)),onMouseLeave:()=>startTransition(()=>setIsHovered(false)),style:{...props.style,position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",gap:showIcon?\"8px\":\"0\",backgroundColor:currentBackgroundColor,color:currentTextColor,border:\"none\",borderRadius:borderRadius,padding:padding,cursor:disabled||isDownloading?\"not-allowed\":\"pointer\",opacity:disabled?.6:1,transition:\"all 0.2s ease\",outline:\"none\",textDecoration:\"none\",...width===\"full\"||isFixedWidth?{width:\"100%\"}:{width:\"auto\",minWidth:\"max-content\"},...font},\"aria-label\":`Download ${fileName}`,role:\"button\",children:[showIcon&&iconPosition===\"left\"&&downloadIcon,/*#__PURE__*/_jsx(\"span\",{children:isDownloading?\"Downloading...\":label}),showIcon&&iconPosition===\"right\"&&downloadIcon]});}addPropertyControls(INeedHave,{showUploadArea:{type:ControlType.Boolean,title:\"Show Upload Area\",defaultValue:false,enabledTitle:\"Show\",disabledTitle:\"Hide\"},uploadAreaText:{type:ControlType.String,title:\"Upload Area Text\",defaultValue:\"Click to upload file or drag and drop\",hidden:({showUploadArea})=>!showUploadArea},label:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Download PDF\"},uploadedFile:{type:ControlType.File,title:\"Upload File\",allowedFileTypes:[\"pdf\",\"doc\",\"docx\",\"txt\",\"jpg\",\"jpeg\",\"png\",\"gif\",\"webp\",\"svg\",\"mp4\",\"webm\",\"mov\",\"mp3\",\"wav\",\"ogg\"]},fileName:{type:ControlType.String,title:\"File Name\",defaultValue:\"document.pdf\",placeholder:\"document.pdf\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},hoverBackgroundColor:{type:ControlType.Color,title:\"Hover Background\",defaultValue:\"#333333\"},hoverTextColor:{type:ControlType.Color,title:\"Hover Text\",defaultValue:\"#FFFFFF\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:50,unit:\"px\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"12px 24px\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},showIcon:{type:ControlType.Boolean,title:\"Show Icon\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},iconPosition:{type:ControlType.Enum,title:\"Icon Position\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true,hidden:({showIcon})=>!showIcon},disabled:{type:ControlType.Boolean,title:\"Disabled\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},width:{type:ControlType.Enum,title:\"Width\",options:[\"auto\",\"full\"],optionTitles:[\"Auto\",\"Full Width\"],defaultValue:\"auto\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"INeedHave\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./INeedHave.map"],"mappings":"6MAIG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,QAAM,eAAe,eAAa,kDAAkD,WAAS,eAAe,kBAAgB,UAAU,YAAU,UAAU,uBAAqB,UAAU,iBAAe,UAAU,eAAa,EAAE,UAAQ,YAAY,OAAK,WAAS,GAAK,eAAa,OAAO,WAAS,GAAM,QAAM,OAAO,iBAAe,GAAM,iBAAe,yCAAyC,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAc,GAAkBA,EAAS,GAAM,CAAM,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,EAAY,GAAgBA,EAAS,KAAK,CAAO,EAAaC,EAAO,KAAK,CAAO,EAAe,SAAS,CAAI,QAAU,GAAqB,OAAoB,EAAiB,GAAK,CAAC,CAAC,GAAG,CAAC,IAAI,EAAQ,EAAiB,EAAiB,EAC9zB,IAAa,EAAQ,IAAI,gBAAgB,EAAY,CAAC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