import "../../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                             */
/* empty css                                                                     */
/* empty css                                                                 */
import { ref, watch, onMounted, createElementBlock, openBlock, createElementVNode, createVNode, unref, withCtx, Fragment, renderList, toDisplayString } from "vue";
import { Search as search_default } from "../../../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
/* empty css                   */
import _export_sfc from "../../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElInput } from "../../../../../node_modules/element-plus/es/components/input/index.mjs";
import { ElScrollbar } from "../../../../../node_modules/element-plus/es/components/scrollbar/index.mjs";
const _hoisted_1 = { class: "field-variable" };
const _hoisted_2 = { class: "field-search" };
const _hoisted_3 = ["onClick"];
const _hoisted_4 = ["field-type"];
const _sfc_main = {
  __name: "FieldVariable",
  props: {
    fieldList: {
      type: Array,
      default: () => []
    }
  },
  emits: ["fieldSelect"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const type = {
      text: "字符串",
      textarea: "字符串",
      select: "字符串",
      radio: "字符串",
      number: "数字",
      multipleSelection: "数组",
      checkbox: "数组",
      date: "日期",
      switch: "布尔值",
      hidden: "隐藏域"
    };
    const searchVariable = ref("");
    const filterFieldList = ref([]);
    watch(searchVariable, (val) => {
      filterFieldList.value = props.fieldList.filter(
        ({ label }) => label.includes(val)
      );
    });
    onMounted(() => {
      filterFieldList.value = props.fieldList;
    });
    return (_ctx, _cache) => {
      const _component_el_input = ElInput;
      const _component_el_scrollbar = ElScrollbar;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          createVNode(_component_el_input, {
            placeholder: "搜索变量",
            "prefix-icon": unref(search_default),
            modelValue: searchVariable.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchVariable.value = $event),
            clearable: ""
          }, null, 8, ["prefix-icon", "modelValue"])
        ]),
        createVNode(_component_el_scrollbar, null, {
          default: withCtx(() => [
            (openBlock(true), createElementBlock(Fragment, null, renderList(filterFieldList.value, (item) => {
              return openBlock(), createElementBlock("div", {
                class: "field-item",
                onClick: ($event) => _ctx.$emit("fieldSelect", item),
                key: item.fieldName
              }, [
                createElementVNode("span", null, toDisplayString(item.label), 1),
                createElementVNode("span", {
                  "field-type": item.fieldType,
                  class: "text-tag"
                }, toDisplayString(type[item.fieldType]), 9, _hoisted_4)
              ], 8, _hoisted_3);
            }), 128))
          ]),
          _: 1
        })
      ]);
    };
  }
};
const FieldVariable = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c2ceeb58"]]);
export {
  FieldVariable as default
};
