/** * @license Copyright © HatioLab Inc. All rights reserved. */ import { css, html, LitElement } from 'lit' import { customElement, property, query } from 'lit/decorators.js' /** http body editor element Example: */ @customElement('things-editor-http-body') export default class ThingsEditorHttpBody extends LitElement { static styles = [ css` :host { display: flex; flex-direction: column; align-content: center; width: 100%; overflow: hidden; border: 1px solid #ccc; margin: 5px 0; } div { display: flex; flex-flow: row nowrap; align-items: center; } div[kind] { border-bottom: 1px solid #aaa; background-color: #ddd; } div[accessor] { background-color: #eee; } label { margin: 0 12px 0 3px; } #accessor { flex: 1; min-height: 20px; margin: 2px; } select, ox-select, input:not([type='checkbox']) { border: 1px solid rgba(0, 0, 0, 0.2); border-radius: 4px; } ` ] @property({ type: Object }) value: { [key: string]: string } = {} firstUpdated() { this.renderRoot.addEventListener('change', this._onChange.bind(this)) } render() { var { kind = 'none', accessor = '', contentType } = this.value || {} return html`
${kind !== 'none' ? html` ${kind == 'raw' ? this.renderContentType(contentType) : html``}
` : html``} ` } renderContentType(contentType) { return html`
` } _onChange(e) { var input = e.target this.value = { ...this.value, [input.name]: input.value } this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true })) } }