import { settings } from "../settings.js"; const styles = ["purple", "gray", "red", "green", "yellow", "blue"]; class DevToolbarSelect extends HTMLElement { shadowRoot; element; _selectStyle = "gray"; get selectStyle() { return this._selectStyle; } set selectStyle(value) { if (!styles.includes(value)) { settings.logger.error(`Invalid style: ${value}, expected one of ${styles.join(", ")}.`); return; } this._selectStyle = value; this.updateStyle(); } static observedAttributes = ["select-style"]; constructor() { super(); this.shadowRoot = this.attachShadow({ mode: "open" }); this.shadowRoot.innerHTML = ` `; this.element = document.createElement("select"); this.shadowRoot.addEventListener("slotchange", (event) => { if (event.target instanceof HTMLSlotElement) { this.element.append(...event.target.assignedNodes()); } }); } connectedCallback() { this.shadowRoot.append(this.element); this.updateStyle(); } attributeChangedCallback() { if (this.hasAttribute("select-style")) { this.selectStyle = this.getAttribute("select-style"); } } updateStyle() { const style = this.shadowRoot.querySelector("#selected-style"); if (style) { style.innerHTML = ` :host { --text-color: var(--${this.selectStyle}-text); --border-color: var(--${this.selectStyle}-border); } `; } } } export { DevToolbarSelect };