'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var elementPlus = require('element-plus');
var index = require('../../svg-icon/index.js');
var index$1 = require('../../input-number/index.js');

"use strict";
const _hoisted_1 = {
  key: 1,
  style: { "margin-left": "4px" }
};
const _hoisted_2 = { class: "me-input" };
const _hoisted_3 = {
  key: 3,
  class: "first-button"
};
const _hoisted_4 = {
  key: 1,
  style: { "margin-left": "4px" }
};
const __default__ = vue.defineComponent({
  name: "me-input"
});
var script = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: /* @__PURE__ */ vue.mergeModels({
    btnText: { type: String, required: false, default: "\u786E\u5B9A" },
    mode: { type: String, required: false, default: "number" },
    loading: { type: Boolean, required: false, default: false },
    buttonGroupAppend: { type: Array, required: false },
    buttonGroupPrepend: { type: Array, required: false },
    searchOptions: { type: Array, required: false },
    selectWidth: { type: String, required: false, default: "100px" },
    height: { type: String, required: false, default: "32px" },
    width: { type: String, required: false, default: "150px" },
    focusWidth: { type: String, required: false, default: "0px" },
    controls: { type: Boolean, required: false, default: false }
  }, {
    "modelValue": { type: null },
    "modelModifiers": {},
    "select": {},
    "selectModifiers": {}
  }),
  emits: /* @__PURE__ */ vue.mergeModels(["confirm", "selectChange"], ["update:modelValue", "update:select"]),
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const data = vue.useModel(__props, "modelValue");
    const searchData = vue.useModel(__props, "select");
    const slots = vue.useSlots();
    const isPrepend = vue.computed(() => {
      return props.buttonGroupPrepend || slots["button-group-prepend"];
    });
    const isAppend = vue.computed(() => {
      return props.buttonGroupAppend || slots["button-group-append"];
    });
    const showDefault = vue.computed(() => {
      return isPrepend.value || isAppend.value;
    });
    const inputWidth = vue.ref(props.width);
    const getStyle = vue.computed(() => {
      return {
        width: inputWidth.value,
        transition: "width .3s ease-in-out"
      };
    });
    const inputStyle = vue.computed(() => {
      return {
        "--me-border-b-r-radius": borderBottomRightRadius.value,
        "--me-border-t-r-radius": borderTopRightRadius.value,
        "--me-height": props.height,
        "--me-border-radius": meInputBorderStyle.value,
        "--me-select-width": props.selectWidth
      };
    });
    const meInputBorderStyle = vue.computed(() => {
      if (searchData.value) {
        return "0px";
      }
      if (slots["append"] || slots["prepend"]) {
        return;
      }
      if (!slots["button-group-prepend"]) {
        return "4px 0px 0px 4px";
      }
      if (!slots["button-group-append"]) {
        return "0px 4px 4px 0px";
      }
    });
    const borderBottomRightRadius = vue.computed(() => {
      if (slots["button-group"]) {
        return "0px";
      } else {
        return "4px";
      }
    });
    const borderTopRightRadius = vue.computed(() => {
      if (slots["button-group"]) {
        return "0px";
      } else {
        return "4px";
      }
    });
    const handleInputFocus = () => {
      inputWidth.value = `calc(${props.width} + ${props.focusWidth})`;
    };
    const handleInputBlur = () => {
      inputWidth.value = props.width;
    };
    const handleConfirm = () => {
      emit("confirm");
    };
    const searchChange = (value) => {
      emit("selectChange", value);
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock(
        "div",
        {
          class: "me-input",
          style: vue.normalizeStyle({ ...inputStyle.value })
        },
        [
          vue.createElementVNode(
            "div",
            {
              class: "tag-input input-group",
              style: vue.normalizeStyle({ height: props.height, width: props.width })
            },
            [
              searchData.value ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElSelect), {
                key: 0,
                onChange: searchChange,
                modelValue: searchData.value,
                "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchData.value = $event),
                class: "search-select",
                style: vue.normalizeStyle({ width: __props.selectWidth, height: props.height })
              }, {
                default: vue.withCtx(() => [
                  (vue.openBlock(true), vue.createElementBlock(
                    vue.Fragment,
                    null,
                    vue.renderList(__props.searchOptions, (item) => {
                      return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElOption), {
                        key: item.value,
                        label: item.label,
                        value: item.value
                      }, null, 8, ["label", "value"]);
                    }),
                    128
                    /* KEYED_FRAGMENT */
                  ))
                ]),
                _: 1
                /* STABLE */
              }, 8, ["modelValue", "style"])) : vue.createCommentVNode("v-if", true),
              vue.createCommentVNode(" buttonGroupPrepend \u524D\u7F6E\u6309\u94AE\u7EC4 "),
              __props.buttonGroupPrepend ? (vue.openBlock(), vue.createElementBlock(
                "div",
                {
                  key: 1,
                  class: vue.normalizeClass(["button-group", { prepend: isPrepend.value }])
                },
                [
                  (vue.openBlock(true), vue.createElementBlock(
                    vue.Fragment,
                    null,
                    vue.renderList(__props.buttonGroupPrepend, (item, index$1) => {
                      return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElButton), {
                        loading: item.loading,
                        onClick: item.handle,
                        style: vue.normalizeStyle({
                          borderTopRightRadius: index$1 == __props.buttonGroupPrepend.length - 1 ? "4px" : "0px",
                          borderBottomRightRadius: index$1 == __props.buttonGroupPrepend.length - 1 ? "4px" : "0px",
                          width: item.text ? "auto" : item.width || "34px"
                        })
                      }, {
                        default: vue.withCtx(() => [
                          item.icon ? (vue.openBlock(), vue.createBlock(vue.unref(index.MeSvgIcon), {
                            key: 0,
                            name: item.icon
                          }, null, 8, ["name"])) : vue.createCommentVNode("v-if", true),
                          item.text ? (vue.openBlock(), vue.createElementBlock(
                            "span",
                            _hoisted_1,
                            vue.toDisplayString(item.text),
                            1
                            /* TEXT */
                          )) : vue.createCommentVNode("v-if", true)
                        ]),
                        _: 2
                        /* DYNAMIC */
                      }, 1032, ["loading", "onClick", "style"]);
                    }),
                    256
                    /* UNKEYED_FRAGMENT */
                  ))
                ],
                2
                /* CLASS */
              )) : (vue.openBlock(), vue.createElementBlock(
                "div",
                {
                  key: 2,
                  class: vue.normalizeClass(["button-group", { prepend: isPrepend.value }])
                },
                [
                  vue.renderSlot(_ctx.$slots, "button-group-prepend")
                ],
                2
                /* CLASS */
              )),
              vue.createCommentVNode(" \u8F93\u5165\u6846 "),
              vue.createElementVNode("div", _hoisted_2, [
                vue.renderSlot(_ctx.$slots, "input", {}, () => [
                  __props.mode === "number" ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.MeInputNumber), vue.mergeProps({
                    key: 0,
                    onFocus: handleInputFocus,
                    onBlur: handleInputBlur,
                    style: getStyle.value,
                    modelValue: data.value,
                    "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => data.value = $event)
                  }, _ctx.$attrs, { controls: __props.controls }), null, 16, ["style", "modelValue", "controls"])) : vue.createCommentVNode("v-if", true),
                  __props.mode === "text" ? (vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElInput), vue.mergeProps({
                    key: 1,
                    onFocus: handleInputFocus,
                    onBlur: handleInputBlur,
                    style: getStyle.value,
                    clearable: ""
                  }, _ctx.$attrs, {
                    modelValue: data.value,
                    "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => data.value = $event)
                  }), vue.createSlots({
                    _: 2
                    /* DYNAMIC */
                  }, [
                    vue.renderList(_ctx.$slots, (item, key) => {
                      return {
                        name: key,
                        fn: vue.withCtx(() => [
                          vue.renderSlot(_ctx.$slots, key)
                        ])
                      };
                    })
                  ]), 1040, ["style", "modelValue"])) : vue.createCommentVNode("v-if", true)
                ])
              ]),
              vue.createCommentVNode(" \u9ED8\u8BA4 \u6309\u94AE\u7EC4 "),
              !showDefault.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3, [
                vue.renderSlot(_ctx.$slots, "default", {}, () => [
                  vue.createVNode(vue.unref(elementPlus.ElButton), {
                    style: {
                      borderTopLeftRadius: "0px",
                      borderBottomLeftRadius: "0px"
                    },
                    loading: __props.loading,
                    onClick: handleConfirm
                  }, {
                    default: vue.withCtx(() => [
                      vue.createTextVNode(
                        vue.toDisplayString(__props.btnText),
                        1
                        /* TEXT */
                      )
                    ]),
                    _: 1
                    /* STABLE */
                  }, 8, ["loading"])
                ])
              ])) : vue.createCommentVNode("v-if", true),
              vue.createCommentVNode(" buttonGroupAppend \u540E\u7F6E\u6309\u94AE\u7EC4"),
              __props.buttonGroupAppend ? (vue.openBlock(), vue.createElementBlock(
                "div",
                {
                  key: 4,
                  class: vue.normalizeClass(["button-group", { append: isAppend.value }])
                },
                [
                  (vue.openBlock(true), vue.createElementBlock(
                    vue.Fragment,
                    null,
                    vue.renderList(__props.buttonGroupAppend, (item, index$1) => {
                      return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElButton), {
                        loading: item.loading,
                        onClick: item.handle,
                        style: vue.normalizeStyle({
                          borderTopRightRadius: index$1 == __props.buttonGroupAppend.length - 1 ? "4px" : "0px",
                          borderBottomRightRadius: index$1 == __props.buttonGroupAppend.length - 1 ? "4px" : "0px",
                          width: item.text ? "auto" : item.width || "34px"
                        })
                      }, {
                        default: vue.withCtx(() => [
                          item.icon ? (vue.openBlock(), vue.createBlock(vue.unref(index.MeSvgIcon), {
                            key: 0,
                            name: item.icon
                          }, null, 8, ["name"])) : vue.createCommentVNode("v-if", true),
                          item.text ? (vue.openBlock(), vue.createElementBlock(
                            "span",
                            _hoisted_4,
                            vue.toDisplayString(item.text),
                            1
                            /* TEXT */
                          )) : vue.createCommentVNode("v-if", true)
                        ]),
                        _: 2
                        /* DYNAMIC */
                      }, 1032, ["loading", "onClick", "style"]);
                    }),
                    256
                    /* UNKEYED_FRAGMENT */
                  ))
                ],
                2
                /* CLASS */
              )) : (vue.openBlock(), vue.createElementBlock(
                "div",
                {
                  key: 5,
                  class: vue.normalizeClass(["button-group", { append: isAppend.value }])
                },
                [
                  vue.renderSlot(_ctx.$slots, "button-group-append")
                ],
                2
                /* CLASS */
              ))
            ],
            4
            /* STYLE */
          )
        ],
        4
        /* STYLE */
      );
    };
  }
});

exports.default = script;
//# sourceMappingURL=input.vue2.js.map
