var _a;
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 { INPUT_STYLE_NAME, INTEGERFIELD_NAME, VALIDATION_MESSAGE_NAME } from '../component-names';
import { MInputMask } from '../input-mask/input-mask';
import { MInputStyle } from '../input-style/input-style';
import { MValidationMessage } from '../validation-message/validation-message';
import WithRender from './integerfield.html?style=./integerfield.scss';
var MIntegerfield = /** @class */ (function (_super) {
    __extends(MIntegerfield, _super);
    function MIntegerfield() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.id = "mIntegerfield-" + uuid.generate();
        return _this;
    }
    Object.defineProperty(MIntegerfield.prototype, "hasDecimalfieldError", {
        get: function () {
            return this.as().hasError;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MIntegerfield.prototype, "isDecimalfieldValid", {
        get: function () {
            return this.as().isValid;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MIntegerfield.prototype, "inputMaskOptions", {
        get: function () {
            return {
                numeral: true,
                numeralThousandsGroupStyle: 'none',
                numeralIntegerScale: this.maxLength,
                numeralDecimalScale: 0,
                numeralDecimalMark: '',
                numeralPositiveOnly: true,
                stripLeadingZeroes: true,
                delimiter: ''
            };
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MIntegerfield.prototype, "currentLocale", {
        get: function () {
            return this.$i18n.currentLocale;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MIntegerfield.prototype, "model", {
        get: function () {
            return (!this.value && this.value !== 0 ? '' : this.value).toString();
        },
        set: function (value) {
            var valueAsNumber = Number.parseFloat(value);
            this.emitNewValue(valueAsNumber);
        },
        enumerable: true,
        configurable: true
    });
    MIntegerfield.prototype.emitNewValue = function (_newValue) { };
    __decorate([
        Prop()
    ], MIntegerfield.prototype, "value", void 0);
    __decorate([
        Prop({
            default: 16,
            validator: function (value) {
                if (!(typeof value === 'number')) {
                    return false;
                }
                if (!isNaN(value) && value <= 16) {
                    return true;
                }
                return false;
            }
        })
    ], MIntegerfield.prototype, "maxLength", void 0);
    __decorate([
        Emit('input')
    ], MIntegerfield.prototype, "emitNewValue", null);
    MIntegerfield = __decorate([
        WithRender,
        Component({
            mixins: [
                InputState,
                InputWidth,
                InputLabel,
                InputManagement
            ],
            components: (_a = {
                    MInputMask: MInputMask
                },
                _a[INPUT_STYLE_NAME] = MInputStyle,
                _a[VALIDATION_MESSAGE_NAME] = MValidationMessage,
                _a)
        })
    ], MIntegerfield);
    return MIntegerfield;
}(ModulVue));
export { MIntegerfield };
var IntegerfieldPlugin = {
    install: function (v) {
        v.component(INTEGERFIELD_NAME, MIntegerfield);
    }
};
export default IntegerfieldPlugin;
//# sourceMappingURL=integerfield.js.map