"use strict";

exports.__esModule = true;
exports.default = void 0;
var _uniqueId2 = _interopRequireDefault(require("lodash/fp/uniqueId"));
var _identity2 = _interopRequireDefault(require("lodash/fp/identity"));
var _pipe2 = _interopRequireDefault(require("lodash/fp/pipe"));
var _get2 = _interopRequireDefault(require("lodash/fp/get"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _provider = _interopRequireDefault(require("../provider"));
var _item = _interopRequireDefault(require("./item.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const getTargetValueAndCall = fun => (0, _pipe2.default)((0, _get2.default)('target.value'), fun);
const themeStyle = {
  setup: _item.default.setup,
  coorpmanager: _item.default.coorpmanager
};
const Item = (props, context) => {
  const idRadioButton = (0, _uniqueId2.default)('inputRadioButton');
  const {
    skin
  } = context;
  const {
    color,
    name,
    value,
    checked,
    label,
    onChange = _identity2.default,
    theme
  } = props;
  const defaultColor = color || (0, _get2.default)('common.primary', skin);
  const mainClass = themeStyle[theme];
  return /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(_item.default.normal, mainClass),
    style: {
      backgroundColor: checked && defaultColor,
      borderRightColor: defaultColor,
      color: !checked && defaultColor
    }
  }, /*#__PURE__*/_react.default.createElement("input", {
    type: "radio",
    id: idRadioButton,
    className: _item.default.radio,
    name: name,
    value: value,
    checked: checked,
    onChange: getTargetValueAndCall(onChange)
  }), /*#__PURE__*/_react.default.createElement("label", {
    className: (0, _classnames.default)(_item.default.label, checked && _item.default.selected),
    style: {
      color: !checked && defaultColor
    },
    htmlFor: idRadioButton
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: _item.default.labelSpan,
    "data-name": `radio-${value}`,
    title: label
  }, label)));
};
Item.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
Item.propTypes = process.env.NODE_ENV !== "production" ? {
  color: _propTypes.default.string,
  value: _propTypes.default.string.isRequired,
  name: _propTypes.default.string,
  theme: _propTypes.default.string,
  checked: _propTypes.default.bool,
  label: _propTypes.default.string,
  onChange: _propTypes.default.func
} : {};
var _default = exports.default = Item;
//# sourceMappingURL=item.js.map