import "core-js/modules/es.array.iterator.js";
import "core-js/modules/web.dom-collections.iterator.js";
import React, { useState } from 'react';
import Form from '../form';
import Popover from '../popover';
import './style';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const InlineErrorFormItem = props => {
  const [visible, setVisible] = useState(false);
  return /*#__PURE__*/_jsx(Form.Item, {
    style: {
      margin: '-5px 0'
    },
    preserve: false
    // @ts-ignore
    ,
    _internalItemRender: {
      mark: 'pro_table_render',
      render: (inputProps, {
        input,
        errorList,
        extra
      }) => {
        const {
          errors
        } = inputProps;
        return /*#__PURE__*/_jsx(Popover, {
          trigger: props.trigger,
          placement: "topLeft",
          visible: errors.length > 0 && visible,
          content: /*#__PURE__*/_jsx("div", {
            children: errorList
          }),
          onVisibleChange: v => {
            return errors.length > 0 && setVisible(v);
          },
          children: /*#__PURE__*/_jsxs("div", {
            children: [input, extra]
          })
        });
      }
    },
    ...props,
    children: props.children
  });
};
export default InlineErrorFormItem;