import React, { useContext } from "react";
import classnames from "classnames";
import useMergedState from "../hooks/use-merged-state";
import RadioContext from "./RadioContext";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
const RadioGroup = (props) => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("radio-group", prefixCls);
  const [checked, setChecked] = useMergedState({
    value: props.value,
    defaultValue: props.defaultValue
  });
  const toggle = (name) => {
    var _a;
    setChecked(name);
    (_a = props.onChange) == null ? void 0 : _a.call(props, name);
  };
  return /* @__PURE__ */ React.createElement(RadioContext.Provider, {
    value: {
      parent: {
        props
      },
      toggle,
      checked
    }
  }, /* @__PURE__ */ React.createElement("div", {
    className: classnames(props.className, bem([props.direction])),
    style: props.style,
    role: "radiogroup"
  }, props.children));
};
var stdin_default = RadioGroup;
export {
  stdin_default as default
};
