import { __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useContext } from 'react';
import clsx from 'clsx';
import ConfigProviderContext from '../config-provider/ConfigProviderContext';
import ButtonContext from './ButtonContext';
import { SHADOW } from '../utils/constant';
export const ButtonGroup = _a => {
  var {
    className,
    style,
    children,
    onClick
  } = _a,
      props = __rest(_a, ["className", "style", "children", "onClick"]);

  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace('button-group', prefixCls);

  const internalClick = e => {
    if (props.disabled) return;
    onClick === null || onClick === void 0 ? void 0 : onClick(e);
  };

  return _jsx("div", Object.assign({
    onClick: internalClick,
    style: style,
    className: clsx(className, bem([props.type, {
      round: props.round,
      plain: props.plain,
      disabled: props.disabled
    }]), props.shadow && `${SHADOW}--${+props.shadow}`)
  }, {
    children: _jsx(ButtonContext.Provider, Object.assign({
      value: {
        parent: props
      }
    }, {
      children: children
    }))
  }));
};
export default ButtonGroup;