import { defineComponent, useModel, ref, computed, onMounted, openBlock, createBlock, unref, mergeProps, mergeModels } from 'vue';
import { isNumber } from './input-number.mjs';
import { ElInputNumber } from 'element-plus';

"use strict";
const __default__ = defineComponent({
  name: "me-input-number"
});
var script = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: /* @__PURE__ */ mergeModels({
    suffix: { type: String, required: false, default: "" },
    width: { type: [Number, String], required: false, default: 150 },
    showControl: { type: Boolean, required: false, default: true },
    min: { type: Number, required: false, default: 0 }
  }, {
    "modelValue": { type: Number },
    "modelModifiers": {}
  }),
  emits: ["update:modelValue"],
  setup(__props) {
    const props = __props;
    const model = useModel(__props, "modelValue");
    const refInputNumber = ref();
    const getSize = (val) => {
      let res = isNumber(val) ? val + "px" : val;
      return res;
    };
    const inputNumberStyle = computed(() => {
      return {
        width: getSize(props.width)
      };
    });
    onMounted(() => {
      const el = refInputNumber.value.$el;
      el.querySelector(".el-input__wrapper").setAttribute("suffix", props.suffix);
    });
    const onBlur = (e) => {
      const value = e.target.value;
      if (!value) {
        model.value = 0;
      }
    };
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(ElInputNumber), mergeProps({
        ref_key: "refInputNumber",
        ref: refInputNumber,
        modelValue: model.value,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => model.value = $event),
        class: "me-input-number"
      }, _ctx.$attrs, {
        controls: true,
        "controls-position": "right",
        style: inputNumberStyle.value,
        min: __props.min,
        onBlur
      }), null, 16, ["modelValue", "style", "min"]);
    };
  }
});

export { script as default };
//# sourceMappingURL=input-number.vue2.mjs.map
