var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { property } from '../../decorators.js';
import { PartComponent } from '../../component.js';
import { EventEmitter } from '@kano/common/index.js';
export class TextInputComponent extends PartComponent {
    constructor() {
        super(...arguments);
        this.value = '';
        this.placeholder = '';
        this.change = new EventEmitter();
    }
    render(ctx, el) {
        const inputEl = el;
        const halfHeight = inputEl.clientHeight / 2;
        ctx.fillStyle = '#FFFFFF';
        ctx.strokeStyle = '#8c8c8c';
        ctx.strokeRect(0, 0, inputEl.clientWidth, inputEl.clientHeight);
        ctx.fillRect(0, 0, inputEl.clientWidth, inputEl.clientHeight + 5);
        const valuePresent = inputEl.value && inputEl.value.length > 0;
        // if placeholder, set text color to grey
        ctx.fillStyle = valuePresent ? '#000000' : '#8c8c8c';
        ctx.font = "16px Bariol";
        ctx.fillText(inputEl.value || inputEl.placeholder || '', halfHeight - 2, 6 + (halfHeight));
    }
}
__decorate([
    property({ type: String, value: '' })
], TextInputComponent.prototype, "value", void 0);
__decorate([
    property({ type: String, value: '' })
], TextInputComponent.prototype, "placeholder", void 0);
__decorate([
    property({ type: EventEmitter, value: new EventEmitter(), noReset: true })
], TextInputComponent.prototype, "change", void 0);
//# sourceMappingURL=text-input-component.js.map