var _excluded = ["type", "content", "offset", "size", "color", "style", "showZero"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';
import { Badge } from 'antd';
/**
 * BadgeWrapper 角标包装组件
 * 负责角标的渲染和定位，支持红点、数字、文本三种类型
 * 位置通过 offset 控制，大小通过 size 控制
 *
 * @example
 * ```tsx
 * // 红点角标
 * <BadgeWrapper badge={{ type: 'dot' }}>
 *   <TextCard text="Item" />
 * </BadgeWrapper>
 *
 * // 数字角标
 * <BadgeWrapper badge={{ type: 'number', content: 99 }}>
 *   <TextCard text="Item" />
 * </BadgeWrapper>
 *
 * // 文本角标
 * <BadgeWrapper badge={{ type: 'text', content: 'New' }}>
 *   <TextCard text="Item" />
 * </BadgeWrapper>
 * ```
 */
var BadgeWrapper = function BadgeWrapper(props) {
  var badge = props.badge,
    children = props.children;

  // 如果没有角标配置，直接返回子元素
  if (!badge) {
    return /*#__PURE__*/React.createElement(React.Fragment, null, children);
  }
  var _badge$type = badge.type,
    type = _badge$type === void 0 ? 'dot' : _badge$type,
    content = badge.content,
    offset = badge.offset,
    size = badge.size,
    color = badge.color,
    style = badge.style,
    _badge$showZero = badge.showZero,
    showZero = _badge$showZero === void 0 ? false : _badge$showZero,
    rest = _objectWithoutProperties(badge, _excluded);

  /**
   * 根据角标类型渲染不同的 Badge
   */
  var renderBadge = function renderBadge() {
    // 红点类型
    if (type === 'dot') {
      return /*#__PURE__*/React.createElement(Badge, _extends({
        dot: true,
        color: color,
        offset: offset,
        size: size,
        style: style
      }, rest), children);
    }

    // 数字或文本类型
    if (type === 'number' || type === 'text') {
      return /*#__PURE__*/React.createElement(Badge, _extends({
        count: content,
        color: color,
        offset: offset,
        size: size,
        style: style,
        showZero: showZero
      }, rest), children);
    }
    return /*#__PURE__*/React.createElement(React.Fragment, null, children);
  };
  return renderBadge();
};
export default BadgeWrapper;