Sha256: fa86d3334b52d6f2e598e18d7828e26e0948888944b8a743cbdf7a42a4f46fce
Contents?: true
Size: 845 Bytes
Versions: 7
Compression:
Stored size: 845 Bytes
Contents
import { htmlAttributes } from "../html/html-attributes"; type SelectOption = { value: string; text: string; }; export class Select { attributes: Record<string, any>; children: any[]; options: SelectOption[]; state: any; attribute: string; constructor(options: SelectOption[] = [], state: any, attribute: string, attributes: Record<string, any> = {}) { this.children = []; this.options = options; this.state = state; this.attribute = attribute; this.attributes = attributes; } get renderWrapper(): string { return `<select ${htmlAttributes(this.attributes)}>${this.options.map(option => `<option value='${option.value}'${option.value === this.state[this.attribute] ? " selected" : ""}>${option.text}</option>`).join("")}${this.children.map(child => child.renderWrapper).join("")}</select>`; } }
Version data entries
7 entries across 7 versions & 1 rubygems