UNPKG

radh-ui

Version:

Stencil Component Starter

69 lines (68 loc) 2.03 kB
import { Component, Event, Prop, State, Watch, h } from '@stencil/core'; export class RadhLocaleSelect { parseLocale(newValue) { if (newValue) this.innerLocales = JSON.parse(this.locales); } componentWillLoad() { this.parseLocale(this.locales); } handleSelect(event) { this.sendLocale.emit(event.target.value); } render() { if (this.innerLocales) { return (h("div", null, h("select", { onChange: (ev) => this.handleSelect(ev) }, this.innerLocales.map(locale => h("option", { value: locale.value }, locale.name))))); } } static get is() { return "radh-locale-select"; } static get originalStyleUrls() { return { "$": ["radh-locale-select.css"] }; } static get styleUrls() { return { "$": ["radh-locale-select.css"] }; } static get properties() { return { "locales": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "locales", "reflect": false } }; } static get states() { return { "innerLocales": {} }; } static get events() { return [{ "method": "sendLocale", "name": "sendLocale", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }]; } static get watchers() { return [{ "propName": "locales", "methodName": "parseLocale" }]; } }