/*
 * Copyright (C) 2016-2020 Kano Computing Ltd.
 * License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 */
import { html } from 'lit-element/lit-element.js';
import { classMap } from 'lit-html/directives/class-map.js';
import { KCIndexedPicker } from './kc-indexed-picker.js';
export class KCQuotePicker extends KCIndexedPicker {
    onItemClick(item) {
        this.value = item.label;
        this.id = item.id;
        this.dispatchEvent(new CustomEvent('value-changed', { composed: true, bubbles: true, detail: item }));
    }
    renderItem(item) {
        return html `
            <button class=${classMap({ item: true, selected: this.id === item.id })}
                id=${item.id} @click=${() => this.onItemClick(item)}>
                ${this.renderItemContent(item)}
            </button>
        `;
    }
    revealSelectedElement() {
        if (!this.renderRoot) {
            return;
        }
        const el = this.renderRoot.querySelector(`#${this.id}`);
        if (!el) {
            return;
        }
        el.scrollIntoView({ behavior: 'smooth' });
    }
}
customElements.define('kc-quote-picker', KCQuotePicker);
//# sourceMappingURL=kc-quote-picker.js.map