import { LitElement, html } from "lit"; import { customElement, property } from "lit/decorators.js"; type SelectOption = { value: number | string; label: string; }; @customElement("setting-select") export class SettingSelect extends LitElement { @property() label = "Setting"; @property() description = ""; @property({ type: Array }) options: SelectOption[] = []; @property({ type: String }) value = ""; createRenderRoot() { return this; } private handleChange(e: Event) { const input = e.target as HTMLSelectElement; const selected = this.options.find( (option) => String(option.value) === input.value, ); const selectedValue = selected?.value ?? input.value; this.value = String(selectedValue); this.dispatchEvent( new CustomEvent("change", { detail: { value: selectedValue }, bubbles: true, composed: true, }), ); } render() { return html`