"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useRadioGroup = exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _stack = _interopRequireDefault(require("../../atoms/stack/stack"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
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); }
const radioGroupContext = /*#__PURE__*/(0, _react.createContext)({});

/**
 * Hook to get access to the state of a Radio group
 */
const useRadioGroup = () => (0, _react.useContext)(radioGroupContext);
exports.useRadioGroup = useRadioGroup;
/**
 * RadioGroup is a component that groups together multiple Radio components.
 */
const RadioGroup = /*#__PURE__*/_react.default.memo( /*#__PURE__*/_react.default.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.default.createElement(radioGroupContext.Provider, {
    value: {
      size: size,
      variant: variant,
      isDisabled: isDisabled,
      colorScheme: colorScheme,
      radioGroupValue: currentValue,
      setRadioGroupValue: setRadioGroupValue
    }
  }, /*#__PURE__*/_react.default.createElement(_stack.default, _extends({
    direction: "vertical",
    spacing: spacing
  }, rest, {
    accessibilityRole: "radiogroup",
    ref: ref
  }), children));
}));
RadioGroup.displayName = "RadioGroup";
var _default = exports.default = RadioGroup;
//# sourceMappingURL=radio-group.js.map