import { defineComponent, computed, createVNode, Fragment } from 'vue';
import '../../../utils/index.mjs';
import { Col } from '../../grid/index.mjs';
import ErrorList from './ErrorList.mjs';
import { useInjectForm, useProvideForm, useProvideFormItemPrefix } from './context.mjs';
import { filterEmpty } from '../../../utils/vue/props.mjs';
import { classNames } from '../../../utils/dom/class.mjs';

var FormItemInput = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "FormItemInput",
  slots: Object,
  inheritAttrs: false,
  props: ["prefixCls", "errors", "hasFeedback", "onDomErrorVisibleChange", "wrapperCol", "help", "extra", "status", "marginBottom", "onErrorVisibleChanged"],
  setup(props, {
    slots
  }) {
    const formContext = useInjectForm();
    const {
      wrapperCol: contextWrapperCol
    } = formContext;
    const subFormContext = {
      ...formContext
    };
    delete subFormContext.labelCol;
    delete subFormContext.wrapperCol;
    useProvideForm(subFormContext);
    useProvideFormItemPrefix({
      prefixCls: computed(() => props.prefixCls),
      status: computed(() => props.status)
    });
    return () => {
      var _a, _b, _c;
      const {
        prefixCls,
        wrapperCol,
        marginBottom,
        onErrorVisibleChanged,
        help = (_a = slots.help) == null ? void 0 : _a.call(slots),
        errors = filterEmpty((_b = slots.errors) == null ? void 0 : _b.call(slots)),
        // hasFeedback,
        // status,
        extra = (_c = slots.extra) == null ? void 0 : _c.call(slots)
      } = props;
      const baseClassName = `${prefixCls}-item`;
      const mergedWrapperCol = wrapperCol || (contextWrapperCol == null ? void 0 : contextWrapperCol.value) || {};
      const className = classNames(`${baseClassName}-control`, mergedWrapperCol.class);
      return createVNode(Col, {
        ...mergedWrapperCol,
        "class": className
      }, {
        default: () => {
          var _a2;
          return createVNode(Fragment, null, [createVNode("div", {
            "class": `${baseClassName}-control-input`
          }, [createVNode("div", {
            "class": `${baseClassName}-control-input-content`
          }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])]), marginBottom !== null || errors.length ? createVNode("div", {
            "style": {
              display: "flex",
              flexWrap: "nowrap"
            }
          }, [createVNode(ErrorList, {
            "errors": errors,
            "help": help,
            "class": `${baseClassName}-explain-connected`,
            "onErrorVisibleChanged": onErrorVisibleChanged
          }, null), !!marginBottom && createVNode("div", {
            "style": {
              width: 0,
              height: `${marginBottom}px`
            }
          }, null)]) : null, extra ? createVNode("div", {
            "class": `${baseClassName}-extra`
          }, [extra]) : null]);
        }
      });
    };
  }
});

export { FormItemInput as default };
//# sourceMappingURL=FormItemInput.mjs.map
