import { defineComponent, computed, ref, watch, createVNode, Transition, withDirectives, TransitionGroup, vShow } from 'vue';
import '../../../vue-components/index.mjs';
import useStyle from '../style/index.mjs';
import { useInjectFormItemPrefix } from './context.mjs';
import { collapseMotion } from '../../../vue-components/transition/src/collapseMotion.mjs';
import { getTransitionGroupProps, getTransitionProps } from '../../../vue-components/transition/src/transition.mjs';

var ErrorList = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "ErrorList",
  inheritAttrs: false,
  props: ["errors", "help", "onErrorVisibleChanged", "helpStatus", "warnings"],
  setup(props, {
    attrs
  }) {
    const {
      prefixCls,
      status
    } = useInjectFormItemPrefix();
    const baseClassName = computed(() => `${prefixCls.value}-item-explain`);
    const visible = computed(() => !!(props.errors && props.errors.length));
    const innerStatus = ref(status.value);
    const [, hashId] = useStyle(prefixCls);
    watch([visible, status], () => {
      if (visible.value)
        innerStatus.value = status.value;
    });
    return () => {
      const colMItem = collapseMotion(`${prefixCls.value}-show-help-item`);
      const transitionGroupProps = getTransitionGroupProps(`${prefixCls.value}-show-help-item`, colMItem);
      transitionGroupProps.role = "alert";
      transitionGroupProps.class = [hashId.value, baseClassName.value, attrs.class, `${prefixCls.value}-show-help`];
      return createVNode(Transition, {
        ...getTransitionProps(`${prefixCls.value}-show-help`),
        "onAfterEnter": () => props.onErrorVisibleChanged(true),
        "onAfterLeave": () => props.onErrorVisibleChanged(false)
      }, {
        default: () => {
          var _a;
          return [withDirectives(createVNode(TransitionGroup, {
            ...transitionGroupProps,
            "tag": "div"
          }, {
            default: () => {
              var _a2;
              return [(_a2 = props.errors) == null ? void 0 : _a2.map((error, index) => {
                return createVNode("div", {
                  "key": index,
                  "class": innerStatus.value ? `${baseClassName.value}-${innerStatus.value}` : ""
                }, [error]);
              })];
            }
          }), [[vShow, !!((_a = props.errors) == null ? void 0 : _a.length)]])];
        }
      });
    };
  }
});

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