function _extends() { _extends = Object.assign || 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 from 'react';
import { Box } from '../../primitives';
import { FormControlContext } from '../../composites/FormControl';
export const RadioContext = /*#__PURE__*/React.createContext({});

const RadioGroup = ({
  size,
  children,
  onChange,
  colorScheme,
  value,
  defaultValue,
  ...props
}) => {
  const formControlContext = React.useContext(FormControlContext);
  const [selected, setSelected] = React.useState(value || defaultValue || []);

  const onChangeHandler = radioValue => {
    setSelected(radioValue);
    onChange && onChange(radioValue);
  };

  return /*#__PURE__*/React.createElement(RadioContext.Provider, {
    value: { ...formControlContext,
      onChangeHandler,
      size,
      colorScheme,
      value: selected
    }
  }, /*#__PURE__*/React.createElement(Box, _extends({
    alignItems: "flex-start"
  }, props), children));
};

export default RadioGroup;
//# sourceMappingURL=RadioGroup.js.map