import{r as t,c as i,h as e,H as s}from"./p-5a5e7c99.js";const a=class{constructor(e){t(this,e),this.timepicker=!0,this.timepickerStep=15,this.timepickerFormat="24h",this.input=i(this,"input",7)}async isValid(){return await this.materialsTextFieldEl.isValid()}async forceValidation(){this.materialsTextFieldEl.forceValidation()}componentWillLoad(){this.outlined&&this.fullwidth&&console.warn("[materials-date-field] You should not use fullwidth and outlined together")}updateValue(){this.materialsTextFieldEl&&(this.materialsTextFieldEl.value=this.value)}renderTimePicker(){if(this.timepicker)return e("materials-menu",{maxHeight:200,noPadding:!0,ref:t=>this.materialsMenuTimepickerEl=t},e("materials-timepicker",{timeSelected:this.value,clock24:"24h"===this.timepickerFormat,step:this.timepickerStep,onTimeSelectedChange:t=>{this.value=t.detail,this.input.emit(),this.materialsMenuTimepickerEl&&this.materialsMenuTimepickerEl.close()},onClick:t=>t.stopPropagation()}))}async openPicker(t){if(!this.disabled&&this.timepicker&&(t.stopPropagation(),t.preventDefault(),this.materialsMenuTimepickerEl)){await this.materialsMenuTimepickerEl.open();const t=this.materialsMenuTimepickerEl.querySelector("materials-timepicker"),i=this.materialsMenuTimepickerEl.shadowRoot.querySelector(".mdc-menu"),e=t.shadowRoot.querySelector("materials-list-item[selected]");t&&i&&e&&(i.scrollTop=e.offsetTop-60)}}render(){return e(s,{class:{"materials-time-field--dense":this.dense}},e("materials-text-field",{class:"timepicker-with-value",type:"time",value:this.value,label:this.label,fullwidth:this.fullwidth,dense:this.dense,outlined:this.outlined,focused:this.focused,disabled:this.disabled,leadingIcon:this.leadingIcon,required:this.required,width:this.width,helperText:this.helperText,persistent:this.persistent,hideNativeClear:!0,customValidation:this.customValidation,ref:t=>this.materialsTextFieldEl=t,onInput:t=>{t.stopPropagation(),this.input.emit(t.detail)},onClick:t=>this.openPicker(t)}),this.renderTimePicker())}static get watchers(){return{value:["updateValue"]}}static get style(){return":host{display:-ms-flexbox;display:flex;}.date-picker{padding:16px;}"}};export{a as materials_time_field};