import{r as t,c as s,h as i,H as e,a as o}from"./p-9576a29b.js";const h=class{constructor(i){t(this,i),this.formEvent=s(this,"formEvent",7),this.formSubmit=s(this,"formSubmit",7),this.sendForm=s(this,"sendForm",7),this.formData={}}handleSubmit(t){if(t.detail.name==this.name){console.info("form submit");const t=Object.assign({},this.formData);this.submitHandler&&this.submitHandler(t),this.sendForm.emit(t)}}receivedFormEvent(t){if(t.detail.name==this.name){const s=Object.assign(Object.assign({},this.formData),{formId:this.name});console.log(s),s[t.detail.key]=t.detail,this.formData=s}}render(){return i(e,{as:"form"},i("form",{name:this.name},i("slot",null)))}},c=class{constructor(i){t(this,i),this.formEvent=s(this,"formEvent",7),this.type="text",this.autocomplete="off",this.required=!1,this.checked=!1,this.autofocus=!1,this.w=12,this.bg="gray-100",this.hoverBg="gray-300",this.focusBg="gray-300",this.bWidth=0,this.p=4,this.focusOutline="none",this.extraProps={}}async componentWillLoad(){await this.computeStyles()}async computeStyles(){const t=await(await import("./p-98f5bc2e.js").then((function(t){return t.s}))).calculateStyles(this);this.hash=t}onChange(t){const s=t.currentTarget;this.inputValue=s.value,"checkbox"==this.type&&(this.inputValue=!!s.checked),this.formEvent.emit({name:this.formId,key:this.name,type:this.type,value:this.inputValue})}componentWillRender(){"checkbox"==this.type&&(this.extraProps.checked=!!this.checked||null)}render(){const t={id:this._id,name:this.name,type:this.type,formId:this.formId,autocomplete:this.autocomplete,required:this.required,placeholder:this.placeholder,autofocus:this.autofocus},s=Object.keys(t).filter((s=>null!==t[s])).reduce(((s,i)=>(s[i]=t[i],s)),{});return i(e,{style:{display:"block",width:"100%"}},i("corejam-box",{flex:!0,direction:"col",w:12,mb:3},this.label&&i("corejam-box",{mb:4},i("label",{htmlFor:this.name},i("corejam-type",{size:"sm",color:"gray-500"},this.label))),i("input",Object.assign({},s,this.extraProps,{class:this.hash,"data-cy":this.formId+"-"+this.name,value:this.value,onInput:t=>this.onChange(t)}))))}get el(){return o(this)}},r=class{constructor(i){t(this,i),this.formSubmit=s(this,"formSubmit",7)}onClick(t){t.preventDefault(),this.formSubmit.emit({name:this.formId,type:"submit"})}render(){return i(e,{onClick:t=>this.onClick(t),"data-cy":`submit-${this.formId}`},i("slot",null))}},a=class{constructor(s){t(this,s),this.as="span",this.droppableElements=["corejam-box"]}async componentWillLoad(){await this.computeStyles()}async computeStyles(){const t=await(await import("./p-98f5bc2e.js").then((function(t){return t.s}))).calculateStyles(this);this.hash=t}render(){return i(this.as,{class:this.hash},i("slot",null))}static get watchers(){return{color:["computeStyles"],family:["computeStyles"],size:["computeStyles"],fontStyle:["computeStyles"],spacing:["computeStyles"],decoration:["computeStyles"],transform:["computeStyles"],align:["computeStyles"]}}};export{h as corejam_form_container,c as corejam_form_input,r as corejam_form_submit,a as corejam_type}