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); }
import React, { createContext, useContext } from "react";
import Stack from "../../atoms/stack/stack";
const radioGroupContext = /*#__PURE__*/createContext({});

/**
 * Hook to get access to the state of a Radio group
 */
export const useRadioGroup = () => useContext(radioGroupContext);
/**
 * RadioGroup is a component that groups together multiple Radio components.
 */
const RadioGroup = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(({
  children,
  isDisabled = false,
  value = undefined,
  defaultValue = undefined,
  spacing = "2",
  onChange = () => {},
  size = "m",
  variant = "filled",
  colorScheme = "primary",
  ...rest
}, ref) => {
  const currentValue = value ?? defaultValue;
  const setRadioGroupValue = value => {
    onChange(value);
  };
  return /*#__PURE__*/React.createElement(radioGroupContext.Provider, {
    value: {
      size: size,
      variant: variant,
      isDisabled: isDisabled,
      colorScheme: colorScheme,
      radioGroupValue: currentValue,
      setRadioGroupValue: setRadioGroupValue
    }
  }, /*#__PURE__*/React.createElement(Stack, _extends({
    direction: "vertical",
    spacing: spacing
  }, rest, {
    accessibilityRole: "radiogroup",
    ref: ref
  }), children));
}));
RadioGroup.displayName = "RadioGroup";
export default RadioGroup;
//# sourceMappingURL=radio-group.js.map