import _uniqueId from "lodash/fp/uniqueId";
import _identity from "lodash/fp/identity";
import _pipe from "lodash/fp/pipe";
import _get from "lodash/fp/get";
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Provider from '../provider';
import style from './item.css';
const getTargetValueAndCall = fun => _pipe(_get('target.value'), fun);
const themeStyle = {
  setup: style.setup,
  coorpmanager: style.coorpmanager
};
const Item = (props, context) => {
  const idRadioButton = _uniqueId('inputRadioButton');
  const {
    skin
  } = context;
  const {
    color,
    name,
    value,
    checked,
    label,
    onChange = _identity,
    theme
  } = props;
  const defaultColor = color || _get('common.primary', skin);
  const mainClass = themeStyle[theme];
  return /*#__PURE__*/React.createElement("div", {
    className: classNames(style.normal, mainClass),
    style: {
      backgroundColor: checked && defaultColor,
      borderRightColor: defaultColor,
      color: !checked && defaultColor
    }
  }, /*#__PURE__*/React.createElement("input", {
    type: "radio",
    id: idRadioButton,
    className: style.radio,
    name: name,
    value: value,
    checked: checked,
    onChange: getTargetValueAndCall(onChange)
  }), /*#__PURE__*/React.createElement("label", {
    className: classNames(style.label, checked && style.selected),
    style: {
      color: !checked && defaultColor
    },
    htmlFor: idRadioButton
  }, /*#__PURE__*/React.createElement("span", {
    className: style.labelSpan,
    "data-name": `radio-${value}`,
    title: label
  }, label)));
};
Item.contextTypes = {
  skin: Provider.childContextTypes.skin
};
Item.propTypes = process.env.NODE_ENV !== "production" ? {
  color: PropTypes.string,
  value: PropTypes.string.isRequired,
  name: PropTypes.string,
  theme: PropTypes.string,
  checked: PropTypes.bool,
  label: PropTypes.string,
  onChange: PropTypes.func
} : {};
export default Item;
//# sourceMappingURL=item.js.map