'use strict';

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

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

"use strict";
const _hoisted_1 = {
  key: 0,
  style: { "padding": "0 5px 5px 5px" }
};
const __default__ = vue.defineComponent({
  name: "me-input-select"
});
var script = /* @__PURE__ */ vue.defineComponent({
  ...__default__,
  props: /* @__PURE__ */ vue.mergeModels({
    options: { type: Array, required: true },
    selectLabel: { type: String, required: false, default: "\u8BF7\u9009\u62E9" },
    search: { type: Boolean, required: false, default: false }
  }, {
    "modelValue": { type: [String, Number] },
    "modelModifiers": {}
  }),
  emits: /* @__PURE__ */ vue.mergeModels(["searchEmit", "clickOutSideEmit"], ["update:modelValue"]),
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const model = vue.useModel(__props, "modelValue");
    const isEdit = vue.ref(false);
    const searchValue = vue.ref("");
    const divRef = vue.ref();
    const handleClick = () => {
      const onClick = (e) => {
        const clickInner = divRef.value?.contains(e.target);
      };
      window.addEventListener("click", onClick);
    };
    const handleSearch = () => {
      emit("searchEmit", searchValue.value);
    };
    const handleInputBlur = () => {
      isEdit.value = false;
      emit("clickOutSideEmit", isEdit.value);
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock(
        "div",
        {
          class: "me-input-select",
          ref_key: "divRef",
          ref: divRef,
          onClick: handleClick
        },
        [
          vue.createVNode(vue.unref(elementPlus.ElInput), vue.mergeProps({
            modelValue: model.value,
            "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => model.value = $event),
            style: { "max-width": "600px" },
            placeholder: "Please input",
            class: "input-with-select",
            onBlur: handleInputBlur
          }, _ctx.$attrs), {
            append: vue.withCtx(() => [
              vue.createVNode(
                vue.unref(elementPlus.ElDropdown),
                vue.mergeProps({
                  style: { "width": "80px" },
                  class: "flex-center",
                  "max-height": "400",
                  trigger: "click"
                }, _ctx.$attrs),
                {
                  dropdown: vue.withCtx(() => [
                    vue.createVNode(vue.unref(elementPlus.ElDropdownMenu), { style: { "width": "100%" } }, {
                      default: vue.withCtx(() => [
                        __props.search ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
                          vue.createVNode(vue.unref(elementPlus.ElInput), {
                            modelValue: searchValue.value,
                            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => searchValue.value = $event),
                            onKeyup: vue.withKeys(handleSearch, ["enter"]),
                            placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u641C\u7D22",
                            maxlength: "15"
                          }, {
                            append: vue.withCtx(() => [
                              vue.createElementVNode("span", {
                                style: { "cursor": "pointer" },
                                onClick: handleSearch
                              }, [
                                vue.createVNode(vue.unref(index.MeSvgIcon), { name: "ri-search-line" })
                              ])
                            ]),
                            _: 1
                            /* STABLE */
                          }, 8, ["modelValue"])
                        ])) : vue.createCommentVNode("v-if", true),
                        vue.createVNode(vue.unref(elementPlus.ElScrollbar), {
                          height: "260px",
                          style: { "overflow-y": "auto" }
                        }, {
                          default: vue.withCtx(() => [
                            (vue.openBlock(true), vue.createElementBlock(
                              vue.Fragment,
                              null,
                              vue.renderList(props.options, (item, index) => {
                                return vue.openBlock(), vue.createBlock(vue.unref(elementPlus.ElDropdownItem), { command: item }, {
                                  default: vue.withCtx(() => [
                                    vue.renderSlot(_ctx.$slots, "item", {
                                      data: item,
                                      index
                                    }, () => [
                                      vue.createTextVNode(
                                        vue.toDisplayString(item?.label),
                                        1
                                        /* TEXT */
                                      )
                                    ])
                                  ]),
                                  _: 2
                                  /* DYNAMIC */
                                }, 1032, ["command"]);
                              }),
                              256
                              /* UNKEYED_FRAGMENT */
                            ))
                          ]),
                          _: 3
                          /* FORWARDED */
                        })
                      ]),
                      _: 3
                      /* FORWARDED */
                    })
                  ]),
                  default: vue.withCtx(() => [
                    vue.createVNode(vue.unref(elementPlus.ElButton), {
                      type: "primary",
                      onClick: _cache[0] || (_cache[0] = () => {
                      })
                    }, {
                      default: vue.withCtx(() => [
                        vue.createTextVNode(
                          vue.toDisplayString(props.selectLabel),
                          1
                          /* TEXT */
                        )
                      ]),
                      _: 1
                      /* STABLE */
                    })
                  ]),
                  _: 3
                  /* FORWARDED */
                },
                16
                /* FULL_PROPS */
              )
            ]),
            _: 3
            /* FORWARDED */
          }, 16, ["modelValue"])
        ],
        512
        /* NEED_PATCH */
      );
    };
  }
});

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