{"version":3,"file":"ReactForm.DLDcrrtp.mjs","names":[],"sources":["https:/framerusercontent.com/modules/34doSerXoKnbEWm7g4kK/wc9ArQRH4LudkeT76bMN/ReactForm.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMediaQuery}from\"react-responsive\";import{useEffect}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */function drawInput(input){if(input.type==\"hr\"){return /*#__PURE__*/_jsx(\"hr\",{});}if(input.type==\"h1\"){return /*#__PURE__*/_jsx(\"h1\",{children:input.value});}if(input.type==\"h2\"){return /*#__PURE__*/_jsx(\"h2\",{style:title,children:input.value});}if(input.type==\"h3\"){return /*#__PURE__*/_jsx(\"h3\",{style:subTitle,children:input.value});}if(input.type==\"select\"){return drawSelect(input);}if(input.type==\"textarea\"){return /*#__PURE__*/_jsx(\"textarea\",{id:input.id,name:input.name,placeholder:input.placeholder,required:input.required==true,style:textStyle});}if(input.type==\"file\"){return /*#__PURE__*/_jsx(\"div\",{className:\"file-upload-wrapper\",children:/*#__PURE__*/_jsx(\"input\",{type:\"hidden\",id:input.id,name:input.name,value:input.value,role:\"uploadcare-uploader\",\"data-public-key\":\"64f60db525c573e37ca6\"})});}if(input.type==\"hidden\"){return /*#__PURE__*/_jsx(\"input\",{type:\"hidden\",id:input.id,name:input.name,value:input.value});}return /*#__PURE__*/_jsx(\"input\",{type:input.type,id:input.id,name:input.name,placeholder:input.placeholder,required:input.required==true,style:textStyle});}function drawSelect(input){let options=input.options.map(option=>{return /*#__PURE__*/_jsxs(\"option\",{value:option.value,selected:option.selected,children:[option.label?option.label:option.value,\" \",option.selected]});});const selected=input.options.some(option=>option.selected);if(!selected&&input.placeholder){options=[/*#__PURE__*/_jsx(\"option\",{value:\"\",children:input.placeholder})].concat(options);}return /*#__PURE__*/_jsx(\"div\",{children:/*#__PURE__*/_jsx(\"select\",{id:input.id,name:input.name,style:selectStyle,required:input.required==true,children:options})});}const getBaseURL=()=>{return\"https://www.khipu.com\";};function getLabel(input){return input.label!=undefined&&input.label!=\"\"?/*#__PURE__*/_jsxs(\"label\",{style:labelStyle,children:[input.label,!input.required?\" (Opcional)\":\"\"]}):\"\";}function inputColumns(input,columns){return Math.max(0,Math.min(input.columns,columns));}export default function ReactForm(props){var _props_redirect;const isMobile=useMediaQuery({query:\"(max-width: 767px)\"});const columns=isMobile?1:props.columns?props.columns:1;const inputs=props.inputs.map(input=>{const spanColumns=inputColumns(input,columns);const fieldStyle={...fieldContainer,...{gridColumn:\"span \"+spanColumns}};return /*#__PURE__*/_jsx(\"div\",{style:fieldStyle,children:/*#__PURE__*/_jsxs(\"div\",{style:fieldContainerInput,children:[getLabel(input),drawInput(input)]})},input.name);});const combined={...containerStyle,...{gridTemplateColumns:\"repeat(\"+columns+\", 1fr)\"}};useEffect(()=>{const script=document.createElement(\"script\");script.src=\"https://www.google.com/recaptcha/api.js\";script.async=true;script.defer=true;document.body.appendChild(script);},[]);function handleSubmit(event){const token=document.querySelector('textarea[name=\"g-recaptcha-response\"]').value;if(!token){event.preventDefault();}}return /*#__PURE__*/_jsx(\"form\",{method:props.method,encType:\"application/x-www-form-urlencoded\",action:props.submitType==\"form-spark-id\"?\"https://submit-form.com/\"+props.action:props.action,onSubmit:handleSubmit,style:{width:\"100%\",alignItems:\"left\",fontFamily:\"Public-Sans, sans-serif\",borderRadius:\"8px\",boxShadow:\"0 0 8px 0 rgba(0, 0, 0, 0.0)\"},children:/*#__PURE__*/_jsxs(\"div\",{style:combined,children:[/*#__PURE__*/_jsx(\"input\",{type:\"hidden\",name:\"_redirect\",value:((_props_redirect=props.redirect)===null||_props_redirect===void 0?void 0:_props_redirect.startsWith(\"http\"))?props.redirect:getBaseURL()+props.redirect}),/*#__PURE__*/_jsx(\"input\",{type:\"hidden\",name:\"_append\",value:props.append}),inputs,/*#__PURE__*/_jsx(\"div\",{className:\"g-recaptcha\",\"data-sitekey\":\"6LfucCMqAAAAAFb6P4gyf9hnEwNSW94gf0Q_dxMC\",style:{display:\"flex\",justifyContent:\"center\"}}),/*#__PURE__*/_jsx(\"input\",{type:\"submit\",value:props.submitLabel,style:{...submitStyle,...{gridColumn:\"span \"+columns}}})]})});}ReactForm.defaultProps={append:false,submitType:\"form-spark-id\",action:\"a0JFeDWix\",method:\"POST\",redirect:\"/page/recibido\",submitLabel:\"Send\",columns:2,inputs:[{label:\"Your name\",type:\"text\",name:\"name\",columns:1},{label:\"Your email\",type:\"email\",name:\"email\",columns:1},{label:\"Message\",type:\"textarea\",name:\"message\",columns:2}]};addPropertyControls(ReactForm,{submitType:{type:ControlType.Enum,options:[\"absolute\",\"form-spark-id\"],title:\"Submit type\"},action:{type:ControlType.String,title:\"Form action\"},method:{type:ControlType.Enum,options:[\"POST\",\"GET\"]},redirect:{type:ControlType.String,title:\"Redirect\"},append:{type:ControlType.Boolean,title:\"Append\"},columns:{type:ControlType.Number,title:\"Columns\"},submitLabel:{type:ControlType.String,title:\"Submit button\"},inputs:{type:ControlType.Array,control:{type:ControlType.Object,controls:{type:{type:ControlType.Enum,options:[\"text\",\"password\",\"select\",\"textarea\",\"email\",\"hidden\",\"file\",\"hr\",\"h1\",\"h2\",\"h3\"]},label:{type:ControlType.String},name:{type:ControlType.String},value:{type:ControlType.String},placeholder:{type:ControlType.String},required:{type:ControlType.Boolean,title:\"Required\"},id:{type:ControlType.String},columns:{type:ControlType.Number,title:\"Columns span\",defaultValue:1},options:{type:ControlType.Array,control:{type:ControlType.Object,controls:{value:{type:ControlType.String},label:{type:ControlType.String},selected:{type:ControlType.Boolean,defaultValue:false}}}}}}}});// Styles are written in object syntax\n// Learn more: https://reactjs.org/docs/dom-elements.html#style\nconst containerStyle={height:\"100%\",display:\"grid\",gap:\"1rem\",justifyContent:\"center\",alignItems:\"center\",overflow:\"hidden\"};const submitStyle={fontFamily:\"Public Sans, sans-serif\",backgroundColor:\"#8347AD\",color:\"#fff\",fontSize:\"16px\",width:\"100%\",padding:\"16px\",fontWeight:\"bold\",border:\"none\",borderRadius:\"8px\",cursor:\"pointer\"};const textStyle={width:\"100%\",padding:\"20px\",marginBottom:\"24px\",border:\"1px solid #ccc\",borderRadius:\"8px\",height:\"auto\",outline:\"none\",fontSize:\"16px\"};const selectStyle={width:\"100%\",padding:\"20px\",marginBottom:\"24px\",border:\"1px solid #ccc\",borderRadius:\"8px\",height:\"auto\",outline:\"none\",fontSize:\"16px\"};const labelStyle={fontSize:\"16px\",marginBottom:\"0.375rem\",height:\"auto\",display:\"inline-block\"};const fieldContainer={gap:\"1rem\"};const fieldContainerInputMobile={backgroundColor:\"red\"};/* Ajustes opcionales para los campos individuales */const fieldContainerInput={};const title={margin:\"1rem 0 0.5rem\"};const subTitle={marginBottom:\"1rem\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ReactForm\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ReactForm.map"],"mappings":"0UAGG,SAAS,EAAU,EAAM,CAAg5B,OAA54B,EAAM,MAAM,KAA0B,EAAK,KAAK,EAAE,CAAC,CAAK,EAAM,MAAM,KAA0B,EAAK,KAAK,CAAC,SAAS,EAAM,MAAM,CAAC,CAAK,EAAM,MAAM,KAA0B,EAAK,KAAK,CAAC,MAAM,EAAM,SAAS,EAAM,MAAM,CAAC,CAAK,EAAM,MAAM,KAA0B,EAAK,KAAK,CAAC,MAAM,EAAS,SAAS,EAAM,MAAM,CAAC,CAAK,EAAM,MAAM,SAAiB,EAAW,EAAM,CAAK,EAAM,MAAM,WAAgC,EAAK,WAAW,CAAC,GAAG,EAAM,GAAG,KAAK,EAAM,KAAK,YAAY,EAAM,YAAY,SAAS,EAAM,UAAU,EAAK,MAAM,EAAU,CAAC,CAAK,EAAM,MAAM,OAA4B,EAAK,MAAM,CAAC,UAAU,sBAAsB,SAAsB,EAAK,QAAQ,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