UNPKG

select-previsao-ondas

Version:

Componente que busca a previsão de ondas por praias

55 lines (54 loc) 2.02 kB
import { Component, State, Event, h } from "@stencil/core"; import PrevisaoOndasService from "../../services/previsao-ondas"; export class SelectPrevisaoOndasComponent { constructor() { this.estados = []; this.cidades = []; this.previsoes = []; this.previsaoOndasService = new PrevisaoOndasService(); } async componentWillLoad() { this.estados = await this.previsaoOndasService.getEstados(); } async handleSelectEstado(event) { this.cidades = await this.previsaoOndasService.getCidades(event.target.value); } async handleSelectCidade(event) { this.previsoes = await this.previsaoOndasService.getPrevisoes(event.target.value); this.change.emit(this.previsoes); } render() { return (h("div", null, h("select", { onInput: event => this.handleSelectEstado(event) }, this.estados.map(item => (h("option", { value: item.abreviatura }, item.abreviatura)))), this.cidades.length ? (h("select", { onInput: event => this.handleSelectCidade(event) }, this.cidades.map(item => (h("option", { value: item.id }, item.cidade))))) : null)); } static get is() { return "select-previsao-ondas"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["select-previsao-ondas.css"] }; } static get styleUrls() { return { "$": ["select-previsao-ondas.css"] }; } static get states() { return { "estados": {}, "cidades": {}, "previsoes": {} }; } static get events() { return [{ "method": "change", "name": "change", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }]; } }