'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../vue-components/index.cjs');
var index = require('../style/index.cjs');
var context = require('./context.cjs');
var collapseMotion = require('../../../vue-components/transition/src/collapseMotion.cjs');
var transition = require('../../../vue-components/transition/src/transition.cjs');

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

exports.default = ErrorList;
//# sourceMappingURL=ErrorList.cjs.map
