import React, { useContext } from 'react';
import { InfoCircleOutlined } from '@wii/icons';
import ConfigProvider from '../config-provider';
import Tooltip from '../tooltip';
import classNames from 'classnames';
import './style';

/**
 * 在 form 的 label 后面增加一个 tips 来展示一些说明文案
 *
 * @param props
 */
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const LabelIconTip = props => {
  const {
    label,
    tooltip,
    ellipsis,
    subTitle
  } = props;
  const {
    getPrefixCls
  } = useContext(ConfigProvider.ConfigContext);
  if (!tooltip && !subTitle) {
    return /*#__PURE__*/_jsx(_Fragment, {
      children: label
    });
  }
  const className = getPrefixCls('pro-core-label-tip');
  const tooltipProps = typeof tooltip === 'string' || /*#__PURE__*/React.isValidElement(tooltip) ? {
    title: tooltip
  } : tooltip;
  const icon = (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.icon) || /*#__PURE__*/_jsx(InfoCircleOutlined, {});
  return /*#__PURE__*/_jsxs("div", {
    className: className,
    onMouseDown: e => e.stopPropagation(),
    onMouseLeave: e => e.stopPropagation(),
    onMouseMove: e => e.stopPropagation(),
    children: [/*#__PURE__*/_jsx("div", {
      className: classNames(`${className}-title`, {
        [`${className}-title-ellipsis`]: ellipsis
      }),
      children: label
    }), subTitle && /*#__PURE__*/_jsx("div", {
      className: `${className}-subtitle`,
      children: subTitle
    }), tooltip && /*#__PURE__*/_jsx(Tooltip, {
      ...tooltipProps,
      children: /*#__PURE__*/_jsx("span", {
        className: `${className}-icon`,
        children: icon
      })
    })]
  });
};
export default /*#__PURE__*/React.memo(LabelIconTip);