import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { InputLabel } from '../../mixins/input-label/input-label';
import { InputManagement } from '../../mixins/input-management/input-management';
import { InputState } from '../../mixins/input-state/input-state';
import { InputWidth } from '../../mixins/input-width/input-width';
import uuid from '../../utils/uuid/uuid';
import { ModulVue } from '../../utils/vue/vue';
import { SEARCHFIELD_NAME } from '../component-names';
import { MIconButton } from '../icon-button/icon-button';
import { MIcon } from '../icon/icon';
import { MInputStyle } from '../input-style/input-style';
import { MValidationMessage } from '../validation-message/validation-message';
import WithRender from './searchfield.html';
import './searchfield.scss';
var MSearchfield = /** @class */ (function (_super) {
    __extends(MSearchfield, _super);
    function MSearchfield() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.validationMessageId = uuid.generate();
        _this.searchIconDescription = _this.$i18n.translate('m-textfield:search');
        return _this;
    }
    MSearchfield.prototype.onReset = function () {
        var _a, _b;
        this.as().model = '';
        (_b = (_a = this.$refs) === null || _a === void 0 ? void 0 : _a.input) === null || _b === void 0 ? void 0 : _b.focus();
    };
    MSearchfield.prototype.onSearch = function (event) {
        this.search(this.as().model);
    };
    MSearchfield.prototype.search = function (model) { };
    Object.defineProperty(MSearchfield.prototype, "hasSearchfieldError", {
        get: function () {
            return this.as().hasError;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MSearchfield.prototype, "isSearchfieldValid", {
        get: function () {
            return this.as().isValid;
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        Prop({ default: function () { return "mSearchfield-" + uuid.generate(); } })
    ], MSearchfield.prototype, "id", void 0);
    __decorate([
        Emit('empty-field')
    ], MSearchfield.prototype, "onReset", null);
    __decorate([
        Emit('search')
    ], MSearchfield.prototype, "search", null);
    MSearchfield = __decorate([
        WithRender,
        Component({
            components: {
                MInputStyle: MInputStyle,
                MIconButton: MIconButton,
                MIcon: MIcon,
                MValidationMessage: MValidationMessage
            },
            mixins: [
                InputState,
                InputWidth,
                InputLabel,
                InputManagement
            ],
            modul: {
                i18n: {
                    'fr': require('./searchfield.lang.fr.json'),
                    'en': require('./searchfield.lang.en.json')
                }
            }
        })
    ], MSearchfield);
    return MSearchfield;
}(ModulVue));
export { MSearchfield };
var SearchfieldPlugin = {
    install: function (v) {
        v.component(SEARCHFIELD_NAME, MSearchfield);
    }
};
export default SearchfieldPlugin;
//# sourceMappingURL=searchfield.js.map