/*
 * Copyright (C) 2016-2020 Kano Computing Ltd.
 * License: http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 */
import { EventEmitter, subscribeTimeout } from '@kano/common/index.js';
import { PartEditorField } from '../field.js';
export class EventPartEditorField extends PartEditorField {
    constructor(component, key) {
        super(component, key);
        this._el = document.createElement('div');
        this._label = document.createElement('label');
        this._label.innerText = this.getFullKeyName();
        this._flash = document.createElement('span');
        this._flash.style.display = 'inline-block';
        this._flash.style.width = '20px';
        this._flash.style.height = '20px';
        this._flash.style.border = '1px solid black';
        this._el.appendChild(this._label);
        this._el.appendChild(this._flash);
        const emitter = this.getValue();
        emitter.event(this._onEvent, this);
    }
    static get propertyType() {
        return EventEmitter;
    }
    _onEvent() {
        this._flash.style.transition = 'none';
        this._flash.style.backgroundColor = 'yellow';
        this._flash.getBoundingClientRect();
        if (this._timer) {
            this._timer.dispose();
        }
        this._timer = subscribeTimeout(() => {
            this._flash.style.transition = 'all linear .1s';
            this._flash.style.backgroundColor = 'white';
        }, 100);
    }
}
//# sourceMappingURL=event.js.map