{"version":3,"file":"SubmitButton_2.C4uwlPnB.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/jWniMHU1OJuf1LuXtEIG/La6pxYp3pjxncfXgnd57/SubmitButton_2.js"],"sourcesContent":["// Form Submit Button fully compatible with Framer Forms, collects form data, exposes full customizability, shows loader for at least 2s\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * SubmitButton\n *\n * - Submits parent Framer form and collects all fields (uses FormData)\n * - Loader appears for at least 2 seconds\n * - Disables while loading\n * - Shows success state, customizable\n * - Allows full font, border, color, radius, text controls\n * @framerIntrinsicWidth 160\n * @framerIntrinsicHeight 45\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */function SubmitButton(props){const{label,successLabel,loadingLabel,font,fontSize,textColor,backgroundColor,hoverBackground,borderColor,borderWidth,borderRadius,successBackground,successTextColor,loaderColor,loaderSize,onSubmit,style}=props;const[isLoading,setIsLoading]=useState(false);const[isSuccess,setIsSuccess]=useState(false);const[isHover,setIsHover]=useState(false);const loaderTimeout=useRef(null);const isStatic=useIsStaticRenderer();useEffect(()=>{return()=>{if(loaderTimeout.current)clearTimeout(loaderTimeout.current);};},[]);function submitForm(e){// Only works in browser\nif(typeof window===\"undefined\")return;const btn=e.target instanceof Element?e.target:null;const form=btn?btn.closest(\"form[data-framer-component-type='Form']\"):null;if(form&&form instanceof HTMLFormElement){// Collect Framer fields by letting Framer's Form handler handle it: We dispatch a submit event so Framer handles data\nconst event=new Event(\"submit\",{bubbles:true,cancelable:true});form.dispatchEvent(event);// Also requestSubmit in case browser supports\nif(!event.defaultPrevented)form.requestSubmit?form.requestSubmit():form.submit();return true;}return false;}function handleClick(e){if(isLoading)return;// Try to submit Framer form first\nconst didSubmit=submitForm(e);if(didSubmit)return;// If not inside a Framer form, run custom user callback and loader\nstartTransition(()=>{setIsLoading(true);setIsSuccess(false);});if(typeof onSubmit===\"function\"){const res=onSubmit(e);if(res&&typeof res.then===\"function\"){Promise.all([Promise.resolve(res),new Promise(resolve=>{loaderTimeout.current=setTimeout(resolve,2e3);})]).then(()=>{startTransition(()=>{setIsLoading(false);setIsSuccess(true);});});}else{loaderTimeout.current=setTimeout(()=>{startTransition(()=>{setIsLoading(false);setIsSuccess(true);});},2e3);}}else{loaderTimeout.current=setTimeout(()=>{startTransition(()=>{setIsLoading(false);setIsSuccess(true);});},2e3);}}function handleMouseEnter(){startTransition(()=>setIsHover(true));}function handleMouseLeave(){startTransition(()=>setIsHover(false));}let displayLabel=label;let displayBg=backgroundColor;let displayColor=textColor;if(isSuccess){displayLabel=successLabel;displayBg=successBackground;displayColor=successTextColor;}else if(isLoading){displayLabel=loadingLabel;}else if(isHover){displayBg=hoverBackground;}// Button min width to avoid layout shift\nconst minW=Math.max(displayLabel?.length||0,label?.length||0,successLabel?.length||0,loadingLabel?.length||0)*(fontSize||16)*.6+loaderSize+32;const buttonStyles={display:\"flex\",alignItems:\"center\",justifyContent:\"center\",gap:10,width:\"100%\",minHeight:40,minWidth:minW,fontSize,color:displayColor,background:displayBg,border:`${borderWidth}px solid ${borderColor}`,borderRadius,padding:\"8px 24px\",cursor:isLoading?\"not-allowed\":\"pointer\",outline:\"none\",opacity:isLoading?.8:1,fontWeight:font.variant?.includes(\"Bold\")?700:500,fontFamily:font.fontFamily,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,transition:\"background 0.16s, color 0.16s, opacity 0.2s\",userSelect:\"none\",...font};const rootStyles={...style,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",width:style?.width||\"100%\",height:style?.height||\"fit-content\",position:\"relative\"};return /*#__PURE__*/_jsx(\"div\",{style:rootStyles,children:/*#__PURE__*/_jsxs(\"button\",{type:\"submit\",style:buttonStyles,disabled:isLoading,\"aria-disabled\":isLoading,onClick:isLoading||isSuccess?undefined:handleClick,onMouseEnter:handleMouseEnter,onMouseLeave:handleMouseLeave,children:[isLoading&&/*#__PURE__*/_jsxs(\"span\",{style:{display:\"inline-block\",width:loaderSize,height:loaderSize,marginRight:8,verticalAlign:\"middle\"},\"aria-label\":\"Loading\",children:[/*#__PURE__*/_jsxs(\"svg\",{width:loaderSize,height:loaderSize,viewBox:\"0 0 32 32\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",style:{display:\"block\",animation:isStatic?undefined:\"spin 0.8s linear infinite\"},children:[/*#__PURE__*/_jsx(\"circle\",{cx:\"16\",cy:\"16\",r:\"14\",stroke:loaderColor,strokeWidth:\"3\",opacity:\"0.15\"}),/*#__PURE__*/_jsx(\"path\",{d:\"M30 16a14 14 0 10-14 14\",stroke:loaderColor,strokeWidth:\"3\",strokeLinecap:\"round\"})]}),/*#__PURE__*/_jsx(\"style\",{children:`\n                          @keyframes spin { from { transform: rotate(0deg);} to {transform: rotate(360deg);} }\n                        `})]}),/*#__PURE__*/_jsx(\"span\",{style:{minWidth:40},children:displayLabel})]})});}addPropertyControls(SubmitButton,{label:{type:ControlType.String,title:\"Button Text\",defaultValue:\"Submit\"},successLabel:{type:ControlType.String,title:\"Success Text\",defaultValue:\"Submitted\"},loadingLabel:{type:ControlType.String,title:\"Loading Text\",defaultValue:\"Submitting...\"},font:{type:ControlType.Font,title:\"Font Style\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:17,variant:\"Bold\",lineHeight:\"1.15em\",letterSpacing:\"-0.01em\"}},fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:17,min:10,max:36,step:1,unit:\"px\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#111111\"},hoverBackground:{type:ControlType.Color,title:\"Hover Bg\",defaultValue:\"#222222\"},borderColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#111111\"},borderWidth:{type:ControlType.Number,title:\"Border Width\",defaultValue:1,min:0,max:10},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:32},successBackground:{type:ControlType.Color,title:\"Success Bg\",defaultValue:\"#43E887\"},successTextColor:{type:ControlType.Color,title:\"Success Text\",defaultValue:\"#ffffff\"},loaderColor:{type:ControlType.Color,title:\"Loader Color\",defaultValue:\"#FFF\"},loaderSize:{type:ControlType.Number,title:\"Loader Size\",defaultValue:18,min:10,max:32,step:1,unit:\"px\"},onSubmit:{type:ControlType.EventHandler,title:\"On Submit\"}});export default SubmitButton;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SubmitButton\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"160\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"45\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SubmitButton_2.map"],"mappings":"uNAaG,SAAS,EAAa,EAAM,CAAC,GAAK,CAAC,QAAM,eAAa,eAAa,OAAK,WAAS,YAAU,kBAAgB,kBAAgB,cAAY,cAAY,eAAa,oBAAkB,mBAAiB,cAAY,aAAW,WAAS,SAAO,EAAW,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAO,EAAcC,EAAO,KAAK,CAAO,EAAS,GAAqB,CAAC,UAAyB,CAAI,EAAc,SAAQ,aAAa,EAAc,QAAQ,EAAK,EAAE,CAAC,CAAC,SAAS,EAAW,EAAE,CACpjB,GAAU,IAAS,OAAY,OAAO,IAAM,EAAI,EAAE,kBAAkB,QAAQ,EAAE,OAAO,KAAW,EAAK,EAAI,EAAI,QAAQ,0CAA0C,CAAC,KAAK,GAAG,GAAM,aAAgB,gBAAgB,CAC9M,IAAM,EAAM,IAAI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