"use strict";(self.webpackChunkdotcms_ui=self.webpackChunkdotcms_ui||[]).push([[4776],{64776:(_,l,i)=>{i.r(l),i.d(l,{dot_radio:()=>n});var r=i(15861),s=i(55956),e=i(26184),u=i(47628),o=i(50394);const n=class{constructor(t){(0,s.r)(this,t),this.dotValueChange=(0,s.c)(this,"dotValueChange",7),this.dotStatusChange=(0,s.c)(this,"dotStatusChange",7),this.value="",this.name="",this.label="",this.hint="",this.required=!1,this.disabled=!1,this.requiredMessage="",this.options="",this._options=void 0,this.status=void 0}reset(){var t=this;return(0,r.Z)(function*(){t.value="",t.status=(0,e.g)(t.isValid()),t.emitStatusChange(),t.emitValueChange()})()}componentWillLoad(){this.value=this.value||"",this.validateProps(),this.status=(0,e.g)(this.isValid()),this.emitStatusChange()}componentDidLoad(){const t=["dottype"],a=this.el.querySelectorAll('input[type="radio"]');setTimeout(()=>{const h=(0,o.g)(Array.from(this.el.attributes),t);a.forEach(c=>{(0,o.s)(c,h)})},0)}optionsWatch(){const t=(0,u.c)(this,"options");this._options=(0,e.f)(t)}valueWatch(){this.value=this.value||""}render(){const t=(0,e.a)(this.status,this.isValid(),this.required);return(0,s.h)(s.H,{class:Object.assign({},t)},(0,s.h)("dot-label",{label:this.label,required:this.required,name:this.name},(0,s.h)("div",{class:"dot-radio__items","aria-describedby":(0,e.h)(this.hint),tabIndex:this.hint?0:null,role:"radiogroup"},this._options.map(a=>(a.value=a.value.trim(),(0,s.h)("label",null,(0,s.h)("input",{checked:this.value.indexOf(a.value)>=0||null,class:(0,e.j)(this.isValid()),name:(0,e.k)(this.name),disabled:this.disabled||null,onInput:h=>this.setValue(h),type:"radio",value:a.value}),a.label))))),(0,e.c)(this.hint),(0,e.b)(this.showErrorMessage(),this.getErrorMessage()))}validateProps(){this.optionsWatch()}isValid(){return!this.required||!!this.value}showErrorMessage(){return this.getErrorMessage()&&!this.status.dotPristine}getErrorMessage(){return this.isValid()?"":this.requiredMessage}setValue(t){this.value=t.target.value.trim(),this.status=(0,e.u)(this.status,{dotTouched:!0,dotPristine:!1,dotValid:this.isValid()}),this.emitValueChange(),this.emitStatusChange()}emitStatusChange(){this.dotStatusChange.emit({name:this.name,status:this.status})}emitValueChange(){this.dotValueChange.emit({name:this.name,value:this.value})}get el(){return(0,s.g)(this)}static get watchers(){return{options:["optionsWatch"],value:["valueWatch"]}}};n.style=".dot-radio__items{display:flex;flex-direction:column}.dot-radio__items label{align-items:center;display:flex}.dot-radio__items input{margin:0 0.25rem 0 0}"}}]);