import { _ as __rest } from '../_verture/tslib.es6-55ed4bd2.js';
import { jsx, jsxs } from 'react/jsx-runtime';
import React__default from 'react';
import { Button } from '../Button/index.js';
import { Tooltip } from '../Tooltip/index.js';
import clsx from 'clsx';
import Forbid from '@iam-com/icons/Forbid';
import { $ as $prefixCls } from '../_verture/constant-66aa48a1.js';
import { s as styleInject } from '../_verture/style-inject.es-300983ab.js';
import '../_verture/typeof-498dd2b1.js';
import '../_verture/slicedToArray-76060636.js';
import '../_verture/unsupportedIterableToArray-cb478f24.js';
import '@iam-com/icons/LoadingF';
import '@iam-com/icons/Down';
import '../_verture/index-fac03ce3.js';
import 'rc-dropdown';
import '../_verture/usePopupContainer-87febeb9.js';
import 'dayjs';
import '@iam-com/lib';
import '../_verture/useFormatMessage-703f8b20.js';
import '@para-ui/core/GlobalContext';
import 'rc-tooltip';
import 'rc-tooltip/lib/placements';

var css_248z = "@charset \"UTF-8\";\n/**\n* @author Hanz\n* @date 2021/10/26 下午2:39\n* @description\n*/\n/**\n* @author Hanz\n* @date 2021/10/20 下午2:08\n* @description color\n*/\n.paraui-v3-button-group {\n  display: inline-flex;\n  align-items: center;\n}\n.paraui-v3-button-group-iconSplit .paraui-v3-icon-button:not(:last-child) {\n  margin-right: 8px;\n}\n.paraui-v3-button-group-iconSplit.paraui-v3-button-group-tooltip > span:not(:last-child) {\n  margin-right: 8px;\n}\n.paraui-v3-button-group-icon {\n  border: 1px solid rgba(171, 176, 185, 0.4);\n  border-radius: 4px;\n}\n.paraui-v3-button-group-icon .paraui-v3-icon-button {\n  border: none;\n  border-radius: 0;\n}\n.paraui-v3-button-group-icon .paraui-v3-icon-button:not(:last-child) {\n  border-right: 1px solid rgba(171, 176, 185, 0.4);\n}\n.paraui-v3-button-group-icon .paraui-v3-icon-button:first-child {\n  border-radius: 4px 0 0 4px;\n}\n.paraui-v3-button-group-icon .paraui-v3-icon-button:last-child {\n  border-radius: 0 4px 4px 0;\n}\n.paraui-v3-button-group-icon.paraui-v3-button-group-tooltip > span .paraui-v3-icon-button {\n  border: none;\n  border-radius: 0;\n}\n.paraui-v3-button-group-icon.paraui-v3-button-group-tooltip > span:not(:last-child) .paraui-v3-icon-button {\n  border-right: 1px solid rgba(171, 176, 185, 0.4);\n}\n.paraui-v3-button-group-icon.paraui-v3-button-group-tooltip > span:first-child .paraui-v3-icon-button {\n  border-radius: 4px 0 0 4px;\n}\n.paraui-v3-button-group-icon.paraui-v3-button-group-tooltip > span:last-child .paraui-v3-icon-button {\n  border-radius: 0 4px 4px 0;\n}\n.paraui-v3-button-group-text .paraui-v3-button {\n  border: none;\n  border-radius: 0;\n}\n.paraui-v3-button-group-text .paraui-v3-button:not(:last-child) {\n  border-right: 1px solid rgba(171, 176, 185, 0.4);\n}";
styleInject(css_248z);

//按钮组
var ButtonGroup = function ButtonGroup(props) {
  var _props$mode = props.mode,
    mode = _props$mode === void 0 ? 'icon' : _props$mode,
    _props$data = props.data,
    data = _props$data === void 0 ? [] : _props$data,
    className = props.className,
    _props$showToolTip = props.showToolTip,
    showToolTip = _props$showToolTip === void 0 ? false : _props$showToolTip,
    onClick = props.onClick,
    _props$disabled = props.disabled,
    disabled = _props$disabled === void 0 ? false : _props$disabled,
    style = props.style;
  //tooltip title
  var generateTooltipTitle = function generateTooltipTitle(disabled, title) {
    if (disabled && title) {
      var svgObj = {
        marginRight: '4px',
        fontSize: '11px',
        color: 'inherit'
      };
      return jsxs("span", {
        children: [jsx(Forbid, {
          style: svgObj
        }), title]
      });
    }
    return title;
  };
  //渲染按钮组
  var renderButtonGroup = function renderButtonGroup() {
    if (!data || !data.length) return null;
    return data.map(function (item, index) {
      var text = item.text,
        _disabled = item.disabled;
      if (typeof _disabled === 'undefined') {
        _disabled = disabled;
        item.disabled = disabled;
      }
      if (showToolTip && ['icon', 'iconSplit'].includes(mode)) return jsx(Tooltip, Object.assign({
        title: generateTooltipTitle(_disabled, text)
      }, {
        children: jsx("span", {
          children: generateButton(item)
        })
      }), index);
      return jsx(React__default.Fragment, {
        children: generateButton(item)
      }, index);
    });
  };
  //按钮组点击
  var handleClickBubble = function handleClickBubble(data) {
    return function (evt) {
      onClick === null || onClick === void 0 ? void 0 : onClick(data, evt);
    };
  };
  //生成按钮
  var generateButton = function generateButton(data) {
    var _a = data !== null && data !== void 0 ? data : {},
      text = _a.text,
      icon = _a.icon,
      rest = __rest(_a, ["text", "icon"]);
    switch (mode) {
      case 'text':
        return jsx(Button, Object.assign({
          onClick: handleClickBubble(data),
          variant: 'outlined',
          size: 'small'
        }, rest, {
          children: text
        }));
      case 'icon':
        return jsx(Button.IconButton, Object.assign({
          onClick: handleClickBubble(data),
          variant: 'outlined'
        }, rest, {
          children: icon
        }));
      case 'iconSplit':
        return jsx(Button.IconButton, Object.assign({
          onClick: handleClickBubble(data),
          variant: 'outlined'
        }, rest, {
          children: icon
        }));
    }
  };
  return jsx("div", Object.assign({
    className: clsx("".concat($prefixCls, "-button-group"), "".concat($prefixCls, "-button-group-").concat(mode), className, showToolTip && "".concat($prefixCls, "-button-group-tooltip")),
    style: style
  }, {
    children: renderButtonGroup()
  }));
};

export { ButtonGroup, ButtonGroup as default };
