import { defineComponent, useModel, inject, resolveComponent, createBlock, openBlock, withCtx, createVNode, mergeProps, toHandlers, unref, withKeys, mergeModels } from 'vue';
import '../../../../../../utils/index.mjs';
import '../../../../base/input/index.mjs';
import { useWatchModelChange } from '../../composables/useWatchModelChange.mjs';
import { searchFormHandleQueryKey } from '../../constants.mjs';
import { searchFormInputEmits, searchFormInputProps, SearchFormInputName } from './searchFormInput.mjs';
import { getGmEvent } from '../../../../../../utils/src/elementPlus/event.mjs';
import { inputEmits } from '../../../../base/input/input.mjs';

var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{
    name: SearchFormInputName
  },
  __name: "SearchFormInput",
  props: /* @__PURE__ */ mergeModels(searchFormInputProps, {
    "modelValue": {},
    "modelModifiers": {}
  }),
  emits: /* @__PURE__ */ mergeModels(searchFormInputEmits, ["update:modelValue"]),
  setup(__props, { emit: __emit }) {
    const props = __props;
    const modelValue = useModel(__props, "modelValue");
    useWatchModelChange(modelValue, { prop: props.prop, noDefaultSync: props.noDefaultSync });
    const emit = __emit;
    const inputEvents = getGmEvent(inputEmits, emit);
    const handleQuery = inject(searchFormHandleQueryKey);
    const onKeyupEnter = (value) => {
      handleQuery?.();
      emit("keyupEnter", value);
    };
    return (_ctx, _cache) => {
      const _component_gm_input = resolveComponent("gm-input");
      const _component_gm_form_item = resolveComponent("gm-form-item");
      return openBlock(), createBlock(_component_gm_form_item, { prop: _ctx.prop }, {
        default: withCtx(() => [
          createVNode(_component_gm_input, mergeProps({
            modelValue: modelValue.value,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => modelValue.value = $event),
            placeholder: _ctx.label,
            disabled: _ctx.disabled,
            clearable: "",
            class: "gm-w-full"
          }, toHandlers(unref(inputEvents)), {
            onKeyup: withKeys(onKeyupEnter, ["enter"])
          }), null, 16, ["modelValue", "placeholder", "disabled"])
        ]),
        _: 1
        /* STABLE */
      }, 8, ["prop"]);
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=SearchFormInput.vue2.mjs.map
