"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _comp = require("../../ui/src/comp");
var _xeUtils = _interopRequireDefault(require("xe-utils"));
var _ui = require("../../ui");
var _utils = require("../../ui/src/utils");
var _dom = require("../../ui/src/dom");
var _vn = require("../../ui/src/vn");
var _util = require("./util");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var handleNumberString = function handleNumberString(val) {
  if (_xeUtils.default.eqNull(val)) {
    return '';
  }
  return "".concat(val);
};
var _default2 = exports.default = /* define-vxe-component start */(0, _comp.defineVxeComponent)({
  name: 'VxeNumberInput',
  mixins: [_ui.globalMixins.sizeMixin],
  model: {
    prop: 'value',
    event: 'modelValue'
  },
  props: {
    value: [String, Number],
    immediate: {
      type: Boolean,
      default: true
    },
    name: String,
    type: {
      type: String,
      default: 'number'
    },
    clearable: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.clearable;
      }
    },
    readonly: {
      type: Boolean,
      default: null
    },
    disabled: {
      type: Boolean,
      default: null
    },
    placeholder: String,
    maxLength: {
      type: [String, Number],
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.maxLength;
      }
    },
    autoComplete: {
      type: String,
      default: 'off'
    },
    align: String,
    form: String,
    className: String,
    size: {
      type: String,
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.size || (0, _ui.getConfig)().size;
      }
    },
    min: {
      type: [String, Number],
      default: null
    },
    max: {
      type: [String, Number],
      default: null
    },
    step: [String, Number],
    exponential: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.exponential;
      }
    },
    showCurrency: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.showCurrency;
      }
    },
    currencySymbol: {
      type: String,
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.currencySymbol;
      }
    },
    controlConfig: Object,
    // number、float、amount
    roundingMode: {
      type: String,
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.roundingMode;
      }
    },
    // float、amount
    digits: {
      type: [String, Number],
      default: null
    },
    autoFill: {
      type: Boolean,
      default: function _default() {
        return (0, _ui.getConfig)().numberInput.autoFill;
      }
    },
    editable: {
      type: Boolean,
      default: true
    },
    plusIcon: String,
    minusIcon: String,
    prefixIcon: String,
    prefixConfig: Object,
    suffixIcon: String,
    suffixConfig: Object,
    // 已废弃
    controls: {
      type: Boolean,
      default: null
    },
    // 已废弃
    maxlength: [String, Number],
    // 已废弃
    autocomplete: String
  },
  inject: {
    $xeForm: {
      default: null
    },
    formItemInfo: {
      from: 'xeFormItemInfo',
      default: null
    }
  },
  data: function data() {
    var xID = _xeUtils.default.uniqueId();
    var reactData = {
      isFocus: false,
      isActivated: false,
      inputValue: ''
    };
    var internalData = {
      // dnTimeout: undefined,
      // ainTimeout: undefined,
      // isMouseDown: undefined,
      // isUM: undefined
    };
    return {
      xID: xID,
      reactData: reactData,
      internalData: internalData
    };
  },
  computed: Object.assign(Object.assign({}, {}), {
    computeFormReadonly: function computeFormReadonly() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var $xeForm = $xeNumberInput.$xeForm;
      var readonly = props.readonly;
      if (readonly === null) {
        if ($xeForm) {
          return $xeForm.readonly;
        }
        return false;
      }
      return readonly;
    },
    computeIsDisabled: function computeIsDisabled() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var $xeForm = $xeNumberInput.$xeForm;
      var disabled = props.disabled;
      if (disabled === null) {
        if ($xeForm) {
          return $xeForm.disabled;
        }
        return false;
      }
      return disabled;
    },
    computeDigitsValue: function computeDigitsValue() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var type = props.type,
        digits = props.digits;
      var defDigits = digits;
      if (defDigits === null) {
        defDigits = (0, _ui.getConfig)().numberInput.digits;
        if (defDigits === null) {
          if (type === 'amount') {
            defDigits = 2;
          }
        }
      }
      return _xeUtils.default.toInteger(defDigits) || 1;
    },
    computeControlOpts: function computeControlOpts() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      return Object.assign({}, (0, _ui.getConfig)().numberInput.controlConfig, props.controlConfig);
    },
    computePrefixOpts: function computePrefixOpts() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      return Object.assign({}, (0, _ui.getConfig)().numberInput.prefixConfig, props.prefixConfig);
    },
    computeSuffixOpts: function computeSuffixOpts() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      return Object.assign({}, (0, _ui.getConfig)().numberInput.suffixConfig, props.suffixConfig);
    },
    computeDecimalsType: function computeDecimalsType() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var type = props.type;
      return type === 'float' || type === 'amount';
    },
    computeStepValue: function computeStepValue() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var type = props.type;
      var digitsValue = $xeNumberInput.computeDigitsValue;
      var decimalsType = $xeNumberInput.computeDecimalsType;
      var step = props.step;
      if (type === 'integer') {
        return _xeUtils.default.toInteger(step) || 1;
      } else if (decimalsType) {
        return _xeUtils.default.toNumber(step) || 1 / Math.pow(10, digitsValue);
      }
      return _xeUtils.default.toNumber(step) || 1;
    },
    computeIsClearable: function computeIsClearable() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      return props.clearable;
    },
    computeInputReadonly: function computeInputReadonly() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var editable = props.editable;
      var formReadonly = $xeNumberInput.computeFormReadonly;
      return formReadonly || !editable;
    },
    computeInpPlaceholder: function computeInpPlaceholder() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var placeholder = props.placeholder;
      if (placeholder) {
        return (0, _utils.getFuncText)(placeholder);
      }
      var globalPlaceholder = (0, _ui.getConfig)().numberInput.placeholder;
      if (globalPlaceholder) {
        return (0, _utils.getFuncText)(globalPlaceholder);
      }
      return (0, _ui.getI18n)('vxe.base.pleaseInput');
    },
    computeInpMaxLength: function computeInpMaxLength() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var type = props.type,
        maxLength = props.maxLength,
        maxlength = props.maxlength,
        min = props.min,
        max = props.max;
      var digitsValue = $xeNumberInput.computeDigitsValue;
      // 数值最大长度默认限制 16 位，包含小数
      var maxDefLen = 16;
      if (!(0, _utils.eqEmptyValue)(min) && !(0, _utils.eqEmptyValue)(max)) {
        return "".concat(max).length + (type === 'integer' ? 0 : digitsValue + 1) + (_xeUtils.default.toNumber(min) >= 0 ? 0 : 1);
      }
      if (maxLength || maxlength) {
        return _xeUtils.default.toNumber(maxLength || maxlength);
      }
      return maxDefLen;
    },
    computeInpImmediate: function computeInpImmediate() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var immediate = props.immediate;
      return immediate;
    },
    computeNumValue: function computeNumValue() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var type = props.type;
      var inputValue = reactData.inputValue;
      return type === 'integer' ? _xeUtils.default.toInteger((0, _util.handleNumber)(inputValue)) : _xeUtils.default.toNumber((0, _util.handleNumber)(inputValue));
    },
    computeNumLabel: function computeNumLabel() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var type = props.type,
        roundingMode = props.roundingMode,
        showCurrency = props.showCurrency,
        currencySymbol = props.currencySymbol,
        autoFill = props.autoFill;
      var inputValue = reactData.inputValue;
      var digitsValue = $xeNumberInput.computeDigitsValue;
      if (type === 'amount') {
        var num = _xeUtils.default.toNumber(inputValue);
        var cfyOpts = {
          digits: digitsValue
        };
        if (roundingMode === 'floor') {
          cfyOpts.floor = true;
        } else if (roundingMode === 'ceil') {
          cfyOpts.ceil = true;
        } else {
          cfyOpts.round = true;
        }
        var amountLabel = _xeUtils.default.commafy(num, cfyOpts);
        if (!autoFill) {
          var _amountLabel$split = amountLabel.split('.'),
            _amountLabel$split2 = _slicedToArray(_amountLabel$split, 2),
            iStr = _amountLabel$split2[0],
            dStr = _amountLabel$split2[1];
          if (dStr) {
            var dRest = dStr.replace(/0+$/, '');
            amountLabel = dRest ? [iStr, '.', dRest].join('') : iStr;
          }
        }
        if (showCurrency) {
          return "".concat(currencySymbol || (0, _ui.getI18n)('vxe.numberInput.currencySymbol') || '').concat(amountLabel);
        }
        return amountLabel;
      }
      return _xeUtils.default.toString(inputValue);
    },
    computeIsDisabledSubtractNumber: function computeIsDisabledSubtractNumber() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var min = props.min;
      var inputValue = reactData.inputValue;
      var numValue = $xeNumberInput.computeNumValue;
      // 当有值时再进行判断
      if ((inputValue || inputValue === 0) && min !== null) {
        return numValue <= _xeUtils.default.toNumber(min);
      }
      return false;
    },
    computeIsDisabledAddNumber: function computeIsDisabledAddNumber() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var max = props.max;
      var inputValue = reactData.inputValue;
      var numValue = $xeNumberInput.computeNumValue;
      // 当有值时再进行判断
      if ((inputValue || inputValue === 0) && max !== null) {
        return numValue >= _xeUtils.default.toNumber(max);
      }
      return false;
    }
  }),
  methods: {
    //
    // Method
    //
    dispatchEvent: function dispatchEvent(type, params, evnt) {
      var $xeNumberInput = this;
      $xeNumberInput.$emit(type, (0, _ui.createEvent)(evnt, {
        $numberInput: $xeNumberInput
      }, params));
    },
    emitModel: function emitModel(value) {
      var $xeNumberInput = this;
      var _events = $xeNumberInput._events;
      if (_events && _events.modelValue) {
        $xeNumberInput.$emit('modelValue', value);
      } else {
        $xeNumberInput.$emit('model-value', value);
      }
    },
    focus: function focus() {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      if (!inputReadonly) {
        var inputElem = $xeNumberInput.$refs.refInputTarget;
        reactData.isActivated = true;
        inputElem.focus();
      }
      return $xeNumberInput.$nextTick();
    },
    blur: function blur() {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var inputElem = $xeNumberInput.$refs.refInputTarget;
      inputElem.blur();
      reactData.isActivated = false;
      return $xeNumberInput.$nextTick();
    },
    select: function select() {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var inputElem = $xeNumberInput.$refs.refInputTarget;
      inputElem.select();
      reactData.isActivated = false;
      return $xeNumberInput.$nextTick();
    },
    getNumberValue: function getNumberValue(val) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var type = props.type,
        exponential = props.exponential,
        roundingMode = props.roundingMode,
        autoFill = props.autoFill;
      var inpMaxLength = $xeNumberInput.computeInpMaxLength;
      var digitsValue = $xeNumberInput.computeDigitsValue;
      var decimalsType = $xeNumberInput.computeDecimalsType;
      var restVal = '';
      if (decimalsType) {
        restVal = (0, _util.toFloatValueFixed)(val, type, digitsValue, roundingMode);
        if (!autoFill) {
          restVal = handleNumberString(_xeUtils.default.toNumber(restVal));
        }
      } else {
        restVal = handleNumberString(val);
      }
      if (exponential && (val === restVal || handleNumberString(val).toLowerCase() === _xeUtils.default.toNumber(restVal).toExponential())) {
        return val;
      }
      return restVal.slice(0, inpMaxLength);
    },
    triggerEvent: function triggerEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var inputValue = reactData.inputValue;
      $xeNumberInput.dispatchEvent(evnt.type, {
        value: inputValue
      }, evnt);
    },
    handleChange: function handleChange(val, inputValue, evnt) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var internalData = $xeNumberInput.internalData;
      var $xeForm = $xeNumberInput.$xeForm;
      var formItemInfo = $xeNumberInput.formItemInfo;
      var value = (0, _utils.eqEmptyValue)(val) ? null : Number(val);
      var isChange = value !== props.value;
      if (isChange) {
        internalData.isUM = true;
        $xeNumberInput.emitModel(value);
      }
      if (reactData.inputValue !== inputValue) {
        $xeNumberInput.$nextTick(function () {
          reactData.inputValue = inputValue || '';
        });
      }
      $xeNumberInput.dispatchEvent('input', {
        value: value
      }, evnt);
      if (isChange) {
        $xeNumberInput.dispatchEvent('change', {
          value: value
        }, evnt);
        // 自动更新校验状态
        if ($xeForm && formItemInfo) {
          $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
        }
      }
    },
    emitInputEvent: function emitInputEvent(inputValue, evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var inpImmediate = $xeNumberInput.computeInpImmediate;
      var value = inputValue === (0, _utils.eqEmptyValue)(inputValue) ? null : _xeUtils.default.toNumber(inputValue);
      reactData.inputValue = inputValue;
      if (inpImmediate) {
        $xeNumberInput.handleChange(value, inputValue, evnt);
      } else {
        $xeNumberInput.dispatchEvent('input', {
          value: value
        }, evnt);
      }
    },
    inputEvent: function inputEvent(evnt) {
      var $xeNumberInput = this;
      var inputElem = evnt.target;
      var value = inputElem.value;
      $xeNumberInput.emitInputEvent(value, evnt);
    },
    changeEvent: function changeEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var inpImmediate = $xeNumberInput.computeInpImmediate;
      if (!inpImmediate) {
        $xeNumberInput.triggerEvent(evnt);
      }
      $xeNumberInput.dispatchEvent('lazy-change', {
        value: reactData.inputValue
      }, evnt);
    },
    focusEvent: function focusEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      if (!inputReadonly) {
        var inputValue = reactData.inputValue;
        reactData.inputValue = (0, _utils.eqEmptyValue)(inputValue) ? '' : "".concat(_xeUtils.default.toNumber(inputValue));
        reactData.isFocus = true;
        reactData.isActivated = true;
        $xeNumberInput.triggerEvent(evnt);
      }
    },
    clickPrefixEvent: function clickPrefixEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      if (!isDisabled) {
        var inputValue = reactData.inputValue;
        $xeNumberInput.dispatchEvent('prefix-click', {
          value: inputValue
        }, evnt);
      }
    },
    clearValueEvent: function clearValueEvent(evnt, value) {
      var $xeNumberInput = this;
      $xeNumberInput.focus();
      $xeNumberInput.handleChange(null, '', evnt);
      $xeNumberInput.dispatchEvent('clear', {
        value: value
      }, evnt);
      $xeNumberInput.dispatchEvent('lazy-change', {
        value: value
      }, evnt);
    },
    clickSuffixEvent: function clickSuffixEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      if (!isDisabled) {
        var inputValue = reactData.inputValue;
        $xeNumberInput.dispatchEvent('suffix-click', {
          value: inputValue
        }, evnt);
      }
    },
    updateModel: function updateModel(val) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var type = props.type,
        roundingMode = props.roundingMode,
        autoFill = props.autoFill;
      var inputValue = reactData.inputValue;
      var digitsValue = $xeNumberInput.computeDigitsValue;
      var decimalsType = $xeNumberInput.computeDecimalsType;
      if ((0, _utils.eqEmptyValue)(val)) {
        reactData.inputValue = '';
      } else {
        var textValue = '' + val;
        if (decimalsType) {
          textValue = (0, _util.toFloatValueFixed)(val, type, digitsValue, roundingMode);
          if (!autoFill) {
            textValue = '' + _xeUtils.default.toNumber(textValue);
          }
        }
        if (textValue !== inputValue) {
          reactData.inputValue = textValue;
        }
      }
    },
    /**
     * 检查初始值
     */
    initValue: function initValue() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var type = props.type,
        roundingMode = props.roundingMode,
        autoFill = props.autoFill;
      var inputValue = reactData.inputValue;
      var digitsValue = $xeNumberInput.computeDigitsValue;
      var decimalsType = $xeNumberInput.computeDecimalsType;
      if (decimalsType) {
        if (inputValue) {
          var textValue = '';
          var validValue = null;
          if (inputValue) {
            textValue = (0, _util.toFloatValueFixed)(inputValue, type, digitsValue, roundingMode);
            validValue = _xeUtils.default.toNumber(textValue);
            if (!autoFill) {
              textValue = "".concat(validValue);
            }
          }
          if (inputValue !== validValue) {
            $xeNumberInput.handleChange(validValue, textValue, {
              type: 'init'
            });
          } else {
            reactData.inputValue = textValue;
          }
        }
      }
    },
    validMaxNum: function validMaxNum(num) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      return props.max === null || props.max === '' || _xeUtils.default.toNumber(num) <= _xeUtils.default.toNumber(props.max);
    },
    validMinNum: function validMinNum(num) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      return props.min === null || props.min === '' || _xeUtils.default.toNumber(num) >= _xeUtils.default.toNumber(props.min);
    },
    afterCheckValue: function afterCheckValue() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var type = props.type,
        min = props.min,
        max = props.max,
        exponential = props.exponential;
      var inputValue = reactData.inputValue;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      if (!inputReadonly) {
        if ((0, _utils.eqEmptyValue)(inputValue)) {
          var inpNumVal = null;
          var inpValue = inputValue;
          if (min || min === 0) {
            inpNumVal = _xeUtils.default.toNumber(min);
            inpValue = "".concat(inpNumVal);
          }
          $xeNumberInput.handleChange(inpNumVal, "".concat(inpValue || ''), {
            type: 'check'
          });
          return;
        }
        if (inputValue || min || max) {
          var _inpNumVal = type === 'integer' ? _xeUtils.default.toInteger((0, _util.handleNumber)(inputValue)) : _xeUtils.default.toNumber((0, _util.handleNumber)(inputValue));
          if (!$xeNumberInput.validMinNum(_inpNumVal)) {
            _inpNumVal = min;
          } else if (!$xeNumberInput.validMaxNum(_inpNumVal)) {
            _inpNumVal = max;
          }
          if (exponential) {
            var inpStringVal = handleNumberString(inputValue).toLowerCase();
            if (inpStringVal === _xeUtils.default.toNumber(_inpNumVal).toExponential()) {
              _inpNumVal = inpStringVal;
            }
          }
          var _inpValue = $xeNumberInput.getNumberValue(_inpNumVal);
          $xeNumberInput.handleChange((0, _utils.eqEmptyValue)(_inpValue) ? null : Number(_inpValue), _inpValue, {
            type: 'check'
          });
        }
      }
    },
    blurEvent: function blurEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var $xeForm = $xeNumberInput.$xeForm;
      var formItemInfo = $xeNumberInput.formItemInfo;
      var inputValue = reactData.inputValue;
      var inpImmediate = $xeNumberInput.computeInpImmediate;
      var value = inputValue ? Number(inputValue) : null;
      if (!inpImmediate) {
        $xeNumberInput.handleChange(value, handleNumberString(inputValue), evnt);
      }
      $xeNumberInput.afterCheckValue();
      reactData.isFocus = false;
      reactData.isActivated = false;
      $xeNumberInput.dispatchEvent('blur', {
        value: value
      }, evnt);
      // 自动更新校验状态
      if ($xeForm && formItemInfo) {
        $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value);
      }
    },
    // 数值
    numberChange: function numberChange(isPlus, evnt) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var min = props.min,
        max = props.max,
        type = props.type;
      var inputValue = reactData.inputValue;
      var stepValue = $xeNumberInput.computeStepValue;
      var numValue = type === 'integer' ? _xeUtils.default.toInteger((0, _util.handleNumber)(inputValue)) : _xeUtils.default.toNumber((0, _util.handleNumber)(inputValue));
      var newValue = isPlus ? _xeUtils.default.add(numValue, stepValue) : _xeUtils.default.subtract(numValue, stepValue);
      var restNum;
      if (!$xeNumberInput.validMinNum(newValue)) {
        restNum = min;
      } else if (!$xeNumberInput.validMaxNum(newValue)) {
        restNum = max;
      } else {
        restNum = newValue;
      }
      $xeNumberInput.emitInputEvent($xeNumberInput.getNumberValue(restNum), evnt);
    },
    numberPlusEvent: function numberPlusEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      var formReadonly = $xeNumberInput.computeFormReadonly;
      var isDisabledAddNumber = $xeNumberInput.computeIsDisabledAddNumber;
      if (!isDisabled && !formReadonly && !isDisabledAddNumber) {
        $xeNumberInput.numberChange(true, evnt);
      }
      reactData.isActivated = true;
      $xeNumberInput.dispatchEvent('plus-number', {
        value: reactData.inputValue
      }, evnt);
      $xeNumberInput.dispatchEvent('lazy-change', {
        value: reactData.inputValue
      }, evnt);
      // 已废弃
      $xeNumberInput.dispatchEvent('next-number', {
        value: reactData.inputValue
      }, evnt);
    },
    numberMinusEvent: function numberMinusEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      var formReadonly = $xeNumberInput.computeFormReadonly;
      var isDisabledSubtractNumber = $xeNumberInput.computeIsDisabledSubtractNumber;
      if (!isDisabled && !formReadonly && !isDisabledSubtractNumber) {
        $xeNumberInput.numberChange(false, evnt);
      }
      reactData.isActivated = true;
      $xeNumberInput.dispatchEvent('minus-number', {
        value: reactData.inputValue
      }, evnt);
      $xeNumberInput.dispatchEvent('lazy-change', {
        value: reactData.inputValue
      }, evnt);
      // 已废弃
      $xeNumberInput.dispatchEvent('prev-number', {
        value: reactData.inputValue
      }, evnt);
    },
    numberKeydownEvent: function numberKeydownEvent(evnt) {
      var $xeNumberInput = this;
      var isUpArrow = _ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.ARROW_UP);
      var isDwArrow = _ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.ARROW_DOWN);
      if (isUpArrow || isDwArrow) {
        evnt.preventDefault();
        if (isUpArrow) {
          $xeNumberInput.numberPlusEvent(evnt);
        } else {
          $xeNumberInput.numberMinusEvent(evnt);
        }
      }
    },
    keydownEvent: function keydownEvent(evnt) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var type = props.type,
        exponential = props.exponential,
        controls = props.controls;
      var controlOpts = $xeNumberInput.computeControlOpts;
      var isArrow = controlOpts.isArrow;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      var isControlKey = (0, _dom.hasControlKey)(evnt);
      var isShiftKey = evnt.shiftKey;
      var isAltKey = evnt.altKey;
      var keyCode = evnt.keyCode;
      var isEsc = _ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.ESCAPE);
      var isUpArrow = _ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.ARROW_UP);
      var isDwArrow = _ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.ARROW_DOWN);
      if (!isControlKey && !isShiftKey && !isAltKey) {
        if (_ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.SPACEBAR) || type === 'integer' && keyCode === 110 || (!exponential || keyCode !== 69) && keyCode >= 65 && keyCode <= 90 || keyCode >= 186 && keyCode <= 188 || keyCode >= 191) {
          evnt.preventDefault();
        }
      }
      if (isEsc) {
        $xeNumberInput.afterCheckValue();
      } else if (isUpArrow || isDwArrow) {
        if ((0, _utils.isEnableConf)(controlOpts) && (controls === false ? controls : isArrow) && !inputReadonly) {
          $xeNumberInput.numberKeydownEvent(evnt);
        }
      }
      $xeNumberInput.triggerEvent(evnt);
    },
    keyupEvent: function keyupEvent(evnt) {
      var $xeNumberInput = this;
      $xeNumberInput.triggerEvent(evnt);
    },
    // 数值
    stopDown: function stopDown() {
      var $xeNumberInput = this;
      var internalData = $xeNumberInput.internalData;
      var dnTimeout = internalData.dnTimeout;
      if (dnTimeout) {
        clearTimeout(dnTimeout);
        internalData.dnTimeout = undefined;
      }
    },
    stopAutoIncrement: function stopAutoIncrement() {
      var $xeNumberInput = this;
      var internalData = $xeNumberInput.internalData;
      var ainTimeout = internalData.ainTimeout;
      if (ainTimeout) {
        clearTimeout(ainTimeout);
        internalData.ainTimeout = undefined;
      }
    },
    numberDownMinusEvent: function numberDownMinusEvent(evnt) {
      var $xeNumberInput = this;
      var internalData = $xeNumberInput.internalData;
      $xeNumberInput.numberStopAll();
      internalData.ainTimeout = setTimeout(function () {
        $xeNumberInput.numberMinusEvent(evnt);
        $xeNumberInput.numberDownMinusEvent(evnt);
      }, 60);
    },
    numberDownPlusEvent: function numberDownPlusEvent(evnt) {
      var $xeNumberInput = this;
      var internalData = $xeNumberInput.internalData;
      $xeNumberInput.numberStopAll();
      internalData.ainTimeout = setTimeout(function () {
        $xeNumberInput.numberPlusEvent(evnt);
        $xeNumberInput.numberDownPlusEvent(evnt);
      }, 60);
    },
    numberStopAll: function numberStopAll() {
      var $xeNumberInput = this;
      $xeNumberInput.stopDown();
      $xeNumberInput.stopAutoIncrement();
    },
    numberClickEvent: function numberClickEvent(evnt) {
      var $xeNumberInput = this;
      var internalData = $xeNumberInput.internalData;
      if (internalData.isMouseDown) {
        internalData.isMouseDown = false;
      } else {
        $xeNumberInput.numberStopAll();
        var isAddNumber = (0, _dom.hasClass)(evnt.currentTarget, 'is--plus');
        if (isAddNumber) {
          $xeNumberInput.numberPlusEvent(evnt);
        } else {
          $xeNumberInput.numberMinusEvent(evnt);
        }
      }
    },
    numberMousedownEvent: function numberMousedownEvent(evnt) {
      var $xeNumberInput = this;
      var internalData = $xeNumberInput.internalData;
      $xeNumberInput.numberStopAll();
      internalData.isMouseDown = true;
      if (evnt.button === 0) {
        var isAddNumber = (0, _dom.hasClass)(evnt.currentTarget, 'is--plus');
        if (isAddNumber) {
          $xeNumberInput.numberPlusEvent(evnt);
        } else {
          $xeNumberInput.numberMinusEvent(evnt);
        }
        internalData.dnTimeout = setTimeout(function () {
          if (isAddNumber) {
            $xeNumberInput.numberDownPlusEvent(evnt);
          } else {
            $xeNumberInput.numberDownMinusEvent(evnt);
          }
        }, 500);
      }
    },
    wheelEvent: function wheelEvent(evnt) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var controls = props.controls;
      var controlOpts = $xeNumberInput.computeControlOpts;
      var isWheel = controlOpts.isWheel;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      if ((0, _utils.isEnableConf)(controlOpts) && (controls === false ? controls : isWheel) && !inputReadonly) {
        if (reactData.isActivated) {
          evnt.stopPropagation();
          evnt.preventDefault();
          var delta = evnt.deltaY;
          if (delta > 0) {
            // 向下
            $xeNumberInput.numberMinusEvent(evnt);
          } else if (delta < 0) {
            // 向上
            $xeNumberInput.numberPlusEvent(evnt);
          }
        }
      }
      $xeNumberInput.triggerEvent(evnt);
    },
    clickEvent: function clickEvent(evnt) {
      var $xeNumberInput = this;
      $xeNumberInput.triggerEvent(evnt);
    },
    // 全局事件
    handleGlobalMousedownEvent: function handleGlobalMousedownEvent(evnt) {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var isActivated = reactData.isActivated;
      var el = $xeNumberInput.$refs.refElem;
      var panelElem = $xeNumberInput.$refs.refInputPanel;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      var inpImmediate = $xeNumberInput.computeInpImmediate;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      if (!isDisabled && !inputReadonly && isActivated) {
        reactData.isActivated = (0, _dom.getEventTargetNode)(evnt, el).flag || (0, _dom.getEventTargetNode)(evnt, panelElem).flag;
        if (!reactData.isActivated) {
          if (!inpImmediate) {
            var inputValue = reactData.inputValue;
            var value = inputValue ? Number(inputValue) : null;
            $xeNumberInput.handleChange(value, handleNumberString(inputValue), evnt);
          }
          $xeNumberInput.afterCheckValue();
        }
      }
    },
    handleGlobalKeydownEvent: function handleGlobalKeydownEvent(evnt) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var clearable = props.clearable;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      if (!isDisabled && !inputReadonly) {
        var isTab = _ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.TAB);
        var isDel = _ui.globalEvents.hasKey(evnt, _ui.GLOBAL_EVENT_KEYS.DELETE);
        var isActivated = reactData.isActivated;
        if (isTab) {
          if (isActivated) {
            $xeNumberInput.afterCheckValue();
          }
          isActivated = false;
          reactData.isActivated = isActivated;
        }
        if (isDel && clearable) {
          if (isActivated) {
            $xeNumberInput.clearValueEvent(evnt, null);
          }
        }
      }
    },
    handleGlobalBlurEvent: function handleGlobalBlurEvent() {
      var $xeNumberInput = this;
      var reactData = $xeNumberInput.reactData;
      var isActivated = reactData.isActivated;
      if (isActivated) {
        $xeNumberInput.afterCheckValue();
      }
    },
    //
    // Render
    //
    renderPrefixIcon: function renderPrefixIcon(h) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var slots = $xeNumberInput.$scopedSlots;
      var prefixIcon = props.prefixIcon;
      var prefixOpts = $xeNumberInput.computePrefixOpts;
      var prefixSlot = slots.prefix;
      var preIcon = prefixIcon || prefixOpts.icon;
      var sufContent = prefixOpts.content;
      return prefixSlot || preIcon || sufContent ? h('div', {
        class: 'vxe-number-input--prefix',
        on: {
          click: $xeNumberInput.clickPrefixEvent
        }
      }, [h('div', {
        class: 'vxe-number-input--prefix-icon'
      }, prefixSlot ? (0, _vn.getSlotVNs)(prefixSlot({})) : [preIcon ? h('i', {
        class: preIcon
      }) : (0, _ui.renderEmptyElement)($xeNumberInput), sufContent ? h('span', {
        class: 'vxe-prefix-input--suffix-text'
      }, "".concat(sufContent)) : (0, _ui.renderEmptyElement)($xeNumberInput)])]) : (0, _ui.renderEmptyElement)($xeNumberInput);
    },
    renderSuffixIcon: function renderSuffixIcon(h) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var slots = $xeNumberInput.$scopedSlots;
      var suffixIcon = props.suffixIcon;
      var inputValue = reactData.inputValue;
      var suffixSlot = slots.suffix;
      var suffixOpts = $xeNumberInput.computeSuffixOpts;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      var isClearable = $xeNumberInput.computeIsClearable;
      var sufIcon = suffixIcon || suffixOpts.icon;
      var sufContent = suffixOpts.content;
      return h('div', {
        class: ['vxe-number-input--suffix', {
          'is--clear': isClearable && !isDisabled && !(inputValue === '' || _xeUtils.default.eqNull(inputValue))
        }]
      }, [isClearable ? h('div', {
        class: 'vxe-number-input--clear-icon',
        on: {
          click: $xeNumberInput.clearValueEvent
        }
      }, [h('i', {
        class: (0, _ui.getIcon)().INPUT_CLEAR
      })]) : (0, _ui.renderEmptyElement)($xeNumberInput), suffixSlot || sufIcon || sufContent ? h('div', {
        class: 'vxe-number-input--suffix-icon',
        on: {
          click: $xeNumberInput.clickSuffixEvent
        }
      }, suffixSlot ? (0, _vn.getSlotVNs)(suffixSlot({})) : [sufIcon ? h('i', {
        class: sufIcon
      }) : (0, _ui.renderEmptyElement)($xeNumberInput), sufContent ? h('span', {
        class: 'vxe-number-input--suffix-text'
      }, "".concat(sufContent)) : (0, _ui.renderEmptyElement)($xeNumberInput)]) : (0, _ui.renderEmptyElement)($xeNumberInput)]);
    },
    renderInput: function renderInput(h) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var type = props.type,
        name = props.name,
        autocomplete = props.autocomplete,
        autoComplete = props.autoComplete;
      var inputValue = reactData.inputValue,
        isFocus = reactData.isFocus;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      var numLabel = $xeNumberInput.computeNumLabel;
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      var inpMaxLength = $xeNumberInput.computeInpMaxLength;
      var inpPlaceholder = $xeNumberInput.computeInpPlaceholder;
      return h('div', {
        key: 'ni',
        class: 'vxe-number-input--input-wrapper'
      }, [$xeNumberInput.renderPrefixIcon(h), h('div', {
        class: 'vxe-number-input--input-inner'
      }, [h('input', {
        ref: 'refInputTarget',
        class: 'vxe-number-input--input',
        domProps: {
          value: !isFocus && type === 'amount' ? numLabel : inputValue
        },
        attrs: {
          name: name,
          type: 'text',
          placeholder: inpPlaceholder,
          maxlength: inpMaxLength,
          readonly: inputReadonly,
          disabled: isDisabled,
          autocomplete: autoComplete || autocomplete
        },
        on: {
          keydown: $xeNumberInput.keydownEvent,
          keyup: $xeNumberInput.keyupEvent,
          click: $xeNumberInput.clickEvent,
          input: $xeNumberInput.inputEvent,
          change: $xeNumberInput.changeEvent,
          focus: $xeNumberInput.focusEvent,
          blur: $xeNumberInput.blurEvent
        }
      })]), $xeNumberInput.renderSuffixIcon(h)]);
    },
    renderMinusBtn: function renderMinusBtn(h) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var minusIcon = props.minusIcon;
      var isDisabledSubtractNumber = $xeNumberInput.computeIsDisabledSubtractNumber;
      return h('button', {
        key: 'prev',
        class: ['vxe-number-input--minus-btn is--minus', {
          'is--disabled': isDisabledSubtractNumber
        }],
        attrs: {
          type: 'button'
        },
        on: {
          click: $xeNumberInput.numberClickEvent,
          mousedown: $xeNumberInput.numberMousedownEvent,
          mouseup: $xeNumberInput.numberStopAll,
          mouseleave: $xeNumberInput.numberStopAll
        }
      }, [h('i', {
        class: minusIcon || (0, _ui.getIcon)().NUMBER_INPUT_MINUS_NUM
      })]);
    },
    renderPlusBtn: function renderPlusBtn(h) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var plusIcon = props.plusIcon;
      var isDisabledAddNumber = $xeNumberInput.computeIsDisabledAddNumber;
      return h('button', {
        key: 'next',
        class: ['vxe-number-input--plus-btn is--plus', {
          'is--disabled': isDisabledAddNumber
        }],
        attrs: {
          type: 'button'
        },
        on: {
          click: $xeNumberInput.numberClickEvent,
          mousedown: $xeNumberInput.numberMousedownEvent,
          mouseup: $xeNumberInput.numberStopAll,
          mouseleave: $xeNumberInput.numberStopAll
        }
      }, [h('i', {
        class: plusIcon || (0, _ui.getIcon)().NUMBER_INPUT_PLUS_NUM
      })]);
    },
    renderSideControl: function renderSideControl(h) {
      var $xeNumberInput = this;
      return h('div', {
        key: 'cplr',
        class: 'vxe-number-input--side-control'
      }, [$xeNumberInput.renderPlusBtn(h), $xeNumberInput.renderMinusBtn(h)]);
    },
    renderVN: function renderVN(h) {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      var slots = $xeNumberInput.$scopedSlots;
      var className = props.className,
        controls = props.controls,
        type = props.type,
        align = props.align,
        prefixIcon = props.prefixIcon,
        suffixIcon = props.suffixIcon;
      var inputValue = reactData.inputValue,
        isActivated = reactData.isActivated;
      var vSize = $xeNumberInput.computeSize;
      var controlOpts = $xeNumberInput.computeControlOpts;
      var layout = controlOpts.layout,
        showButton = controlOpts.showButton;
      var isDisabled = $xeNumberInput.computeIsDisabled;
      var formReadonly = $xeNumberInput.computeFormReadonly;
      var numLabel = $xeNumberInput.computeNumLabel;
      var prefixSlot = slots.prefix;
      var suffixSlot = slots.suffix;
      if (formReadonly) {
        return h('div', {
          ref: 'refElem',
          class: ['vxe-number-input--readonly', "type--".concat(type), className]
        }, numLabel);
      }
      var inputReadonly = $xeNumberInput.computeInputReadonly;
      var isClearable = $xeNumberInput.computeIsClearable;
      var isControls = (0, _utils.isEnableConf)(controlOpts) && (controls === false ? controls : showButton);
      return h('div', {
        ref: 'refElem',
        class: ['vxe-number-input', "type--".concat(type), "ctl--".concat(layout === 'right' || layout === 'left' ? layout : 'default'), className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "size--".concat(vSize), vSize), "is--".concat(align), align), 'is--controls', isControls && !inputReadonly), 'is--prefix', !!prefixSlot || prefixIcon), 'is--suffix', !!suffixSlot || suffixIcon), 'is--disabled', isDisabled), 'is--active', isActivated), 'show--clear', isClearable && !isDisabled && !(inputValue === '' || _xeUtils.default.eqNull(inputValue)))],
        attrs: {
          spellcheck: false
        }
      }, isControls ? layout === 'right' ? [$xeNumberInput.renderInput(h), $xeNumberInput.renderSideControl(h)] : layout === 'left' ? [$xeNumberInput.renderSideControl(h), $xeNumberInput.renderInput(h)] : [$xeNumberInput.renderMinusBtn(h), $xeNumberInput.renderInput(h), $xeNumberInput.renderPlusBtn(h)] : [$xeNumberInput.renderInput(h)]);
    }
  },
  watch: {
    value: function value(val) {
      var $xeNumberInput = this;
      var internalData = $xeNumberInput.internalData;
      if (!internalData.isUM) {
        this.updateModel(val);
      }
      internalData.isUM = false;
    },
    type: function type() {
      var $xeNumberInput = this;
      var props = $xeNumberInput;
      var reactData = $xeNumberInput.reactData;
      // 切换类型是重置内置变量
      Object.assign(reactData, {
        inputValue: props.value
      });
      $xeNumberInput.initValue();
    }
  },
  created: function created() {
    var $xeNumberInput = this;
    var props = $xeNumberInput;
    this.updateModel(props.value);
    $xeNumberInput.initValue();
  },
  mounted: function mounted() {
    var $xeNumberInput = this;
    var targetElem = $xeNumberInput.$refs.refInputTarget;
    if (targetElem) {
      targetElem.addEventListener('wheel', $xeNumberInput.wheelEvent, {
        passive: false
      });
    }
    _ui.globalEvents.on($xeNumberInput, 'mousedown', $xeNumberInput.handleGlobalMousedownEvent);
    _ui.globalEvents.on($xeNumberInput, 'keydown', $xeNumberInput.handleGlobalKeydownEvent);
    _ui.globalEvents.on($xeNumberInput, 'blur', $xeNumberInput.handleGlobalBlurEvent);
  },
  beforeDestroy: function beforeDestroy() {
    var $xeNumberInput = this;
    var reactData = $xeNumberInput.reactData;
    reactData.isFocus = false;
    $xeNumberInput.numberStopAll();
    $xeNumberInput.afterCheckValue();
    var targetElem = $xeNumberInput.$refs.refInputTarget;
    if (targetElem) {
      targetElem.removeEventListener('wheel', $xeNumberInput.wheelEvent);
    }
    _ui.globalEvents.off($xeNumberInput, 'mousedown');
    _ui.globalEvents.off($xeNumberInput, 'keydown');
    _ui.globalEvents.off($xeNumberInput, 'blur');
  },
  render: function render(h) {
    return this.renderVN(h);
  }
});
/* define-vxe-component end */