"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _core = require("@emotion/core");

var _propTypes = _interopRequireDefault(require("prop-types"));

var _shortid = _interopRequireDefault(require("shortid"));

var _core2 = require("@material-ui/core");

var _Radio = _interopRequireDefault(require("@material-ui/core/Radio"));

var _RadioGroup = _interopRequireDefault(require("@material-ui/core/RadioGroup"));

var _styles = require("@material-ui/styles");

var _uiThemes = require("@hackoregon/ui-themes");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var RadioButtonGroup = function RadioButtonGroup(_ref) {
  var labels = _ref.labels,
      onChange = _ref.onChange,
      disabled = _ref.disabled,
      value = _ref.value,
      grpLabel = _ref.grpLabel,
      labelPlacement = _ref.labelPlacement,
      row = _ref.row,
      formHelperText = _ref.formHelperText;
  return (0, _core.jsx)(_styles.ThemeProvider, {
    theme: _uiThemes.MaterialTheme
  }, (0, _core.jsx)(_core2.FormControl, {
    disabled: disabled
  }, (0, _core.jsx)(_core2.FormLabel, null, grpLabel), (0, _core.jsx)(_RadioGroup["default"], {
    "aria-label": grpLabel,
    name: grpLabel,
    onChange: onChange,
    value: value,
    row: row
  }, labels.map(function (label) {
    return (0, _core.jsx)(_core2.FormControlLabel, {
      key: _shortid["default"].generate(),
      value: label,
      control: (0, _core.jsx)(_Radio["default"], {
        inputProps: {
          "aria-label": {
            label: label
          }
        }
      }),
      label: label,
      labelPlacement: labelPlacement
    });
  })), formHelperText && (0, _core.jsx)(_core2.FormHelperText, null, formHelperText)));
};

RadioButtonGroup.displayName = "RadioButtonGroup";
RadioButtonGroup.propTypes = {
  labels: _propTypes["default"].arrayOf(_propTypes["default"].string),
  value: _propTypes["default"].string,
  grpLabel: _propTypes["default"].string,
  labelPlacement: _propTypes["default"].string,
  formHelperText: _propTypes["default"].string,
  row: _propTypes["default"].bool,
  disabled: _propTypes["default"].bool,
  onChange: _propTypes["default"].func
};
RadioButtonGroup.defaultProps = {
  labels: ["Label 1", "Label 2", "Label 3"],
  value: "Label 1",
  grpLabel: "GroupLabel",
  labelPlacement: "end",
  formHelperText: "",
  row: false,
  disabled: false
};
var _default = RadioButtonGroup;
exports["default"] = _default;