"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const classnames_1 = require("../../../../../client/classnames");
const element_1 = require("../../../../../client/element");
const parentElement_1 = require("../../../../../client/platform/web/parentElement");
const theme_1 = require("../../../../../client/theme");
const Component_1 = require("../../value/TextField/Component");
const HEIGHT = 39;
const DEFAULT_STYLE = {
    height: `${HEIGHT}px`,
    width: '100%',
    color: 'currentColor',
    borderTopWidth: '0',
    borderTopStyle: 'solid',
    borderTopColor: 'currentColor',
    backgroundColor: theme_1.COLOR_NONE,
    borderRadius: '3px 3px 0 0',
    fontSize: '16px',
    textAlign: 'center',
};
class SearchInput extends element_1.Element {
    constructor($props, $system) {
        super($props, $system);
        const { className, style, disabled } = this.$props;
        const input = new Component_1.default({
            className: (0, classnames_1.default)('search-input', className),
            style: Object.assign(Object.assign({}, DEFAULT_STYLE), style),
            maxLength: 30,
            disabled,
            tabIndex: -1,
        }, this.$system);
        this._input = input;
        const $element = (0, parentElement_1.default)($system);
        this.$element = $element;
        this.$slot = {
            default: input,
        };
        this.registerRoot(input);
    }
    onPropChanged(prop, current) {
        if (prop === 'style') {
            this._input.setProp('style', Object.assign(Object.assign({}, DEFAULT_STYLE), current));
        }
        else if (prop === 'disabled') {
            this._input.setProp('disabled', current);
        }
        else if (prop === 'tabIndex') {
            this._input.setProp('tabIndex', current);
        }
        else if (prop === 'value') {
            this._input.setProp('value', current);
        }
    }
    setSelectionRange(start, end, direction) {
        this._input.setSelectionRange(start, end, direction);
    }
}
exports.default = SearchInput;
//# sourceMappingURL=Component.js.map