import { defineComponent, ref, computed, watch, watchEffect, openBlock, createElementBlock, createVNode, unref, mergeProps, toHandlers, withCtx, createElementVNode, normalizeClass } from "vue";
import { Field } from "vant";
import { _ as _sfc_main$1 } from "./index4.js";
import "./index5.js";
import "./index6.js";
import "@wltech/svg";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    value: { default: "" },
    item: { default: () => {
    } },
    hasBorder: { type: Boolean, default: false },
    placeholder: { default: "" }
  },
  emits: ["update:value", "onBlur"],
  setup(__props, { emit }) {
    const props = __props;
    const fieldValue = ref();
    const inputClass = computed(() => {
      return props.hasBorder ? `border-1 border-solid border-border-color uno-radius-6` : "";
    });
    const inputPlacehoder = computed(() => {
      var _a;
      return props.placeholder ? props.placeholder : `\u8BF7\u8F93\u5165${(_a = props == null ? void 0 : props.item) == null ? void 0 : _a.label}`;
    });
    watch(
      () => fieldValue.value,
      (val) => {
        emit("update:value", val);
      }
    );
    const onInputBlur = () => {
      emit("onBlur", fieldValue.value);
    };
    watchEffect(() => {
      fieldValue.value = props.value;
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", null, [
        createVNode(unref(Field), mergeProps({
          modelValue: fieldValue.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => fieldValue.value = $event),
          label: __props.item.label
        }, __props.item, toHandlers(__props.item.on || {})), {
          input: withCtx(() => [
            createElementVNode("div", {
              class: normalizeClass(`w-full uno-px-10 ${unref(inputClass)}`)
            }, [
              createVNode(_sfc_main$1, {
                modelValue: fieldValue.value,
                "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => fieldValue.value = $event),
                placeholder: unref(inputPlacehoder),
                onOnBlur: onInputBlur
              }, null, 8, ["modelValue", "placeholder"])
            ], 2)
          ]),
          _: 1
        }, 16, ["modelValue", "label"])
      ]);
    };
  }
});
export { _sfc_main as default };
