"use strict";(self.webpackChunkdotcms_ui=self.webpackChunkdotcms_ui||[]).push([[9455],{99455:(r,h,i)=>{i.r(h),i.d(h,{dot_select:()=>n});var u=i(15861),e=i(55956),s=i(26184),o=i(47628),l=i(50394);const n=class{constructor(t){(0,e.r)(this,t),this.dotValueChange=(0,e.c)(this,"dotValueChange",7),this.dotStatusChange=(0,e.c)(this,"dotStatusChange",7),this._dotTouched=!1,this._dotPristine=!0,this.value="",this.name="",this.label="",this.hint="",this.options="",this.required=!1,this.requiredMessage="This field is required",this.disabled=!1,this._options=void 0,this.status=void 0}componentWillLoad(){this.validateProps(),this.emitInitialValue(),this.status=(0,s.g)(this.isValid()),this.emitStatusChange()}optionsWatch(){const t=(0,o.c)(this,"options");this._options=(0,s.f)(t)}reset(){var t=this;return(0,u.Z)(function*(){t.value="",t.status=(0,s.g)(t.isValid()),t.emitInitialValue(),t.emitStatusChange()})()}componentDidLoad(){const t=this.el.querySelector("select");setTimeout(()=>{const a=(0,l.g)(Array.from(this.el.attributes),[]);(0,l.s)(t,a)},0)}render(){const t=(0,s.a)(this.status,this.isValid(),this.required);return(0,e.h)(e.H,{class:Object.assign({},t)},(0,e.h)("dot-label",{label:this.label,required:this.required,name:this.name},(0,e.h)("select",{"aria-describedby":(0,s.h)(this.hint),class:(0,s.j)(this.status.dotValid),id:(0,s.k)(this.name),disabled:this.shouldBeDisabled(),onChange:a=>this.setValue(a)},this._options.map(a=>(0,e.h)("option",{selected:this.value===a.value||null,value:a.value},a.label)))),(0,s.c)(this.hint),(0,s.b)(!this.isValid(),this.requiredMessage))}validateProps(){this.optionsWatch()}shouldBeDisabled(){return!!this.disabled||null}setValue(t){this.value=t.target.value,this.status=(0,s.u)(this.status,{dotTouched:!0,dotPristine:!1,dotValid:this.isValid()}),this.emitValueChange(),this.emitStatusChange()}emitInitialValue(){this.value||(this.value=this._options.length?this._options[0].value:"",this.emitValueChange())}emitStatusChange(){this.dotStatusChange.emit({name:this.name,status:this.status})}isValid(){return!this.required||!!this.value}emitValueChange(){this.dotValueChange.emit({name:this.name,value:this.value})}get el(){return(0,e.g)(this)}static get watchers(){return{options:["optionsWatch"]}}};n.style=""}}]);