"use strict";

var _react = _interopRequireDefault(require("react"));

var _react2 = require("@storybook/react");

var _addonKnobs = require("@storybook/addon-knobs");

var _configureStore2 = _interopRequireDefault(require("../../../../storybook/configureStore"));

var _other = require("../../../../storybook/reducers/other");

var _stories = require("../stories");

var _component = _interopRequireDefault(require("../component"));

var _component2 = _interopRequireDefault(require("./component"));

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

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); }

var _configureStore = (0, _configureStore2.default)(),
    getState = _configureStore.getState,
    dispatch = _configureStore.dispatch; // const RangeRF = reduxForm({
//   form: 'range',
// })(Range);


var props = function props() {
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
      _ref$isHidden = _ref.isHidden,
      isHidden = _ref$isHidden === void 0 ? undefined : _ref$isHidden,
      _ref$title = _ref.title,
      title = _ref$title === void 0 ? undefined : _ref$title;

  return {
    isHidden: (0, _addonKnobs.boolean)('isHidden', isHidden, 'group'),
    title: (0, _addonKnobs.text)('title', title, 'group')
  };
};

var _onClick = function onClick(sex) {
  dispatch((0, _other.updateRadioGroup)(sex));
  (0, _react2.forceReRender)();
};

(0, _react2.storiesOf)('Web|form/Radio').add('Group', function () {
  return _react.default.createElement(_component2.default, props({
    title: 'sex'
  }), _react.default.createElement(_component.default, _extends({}, (0, _stories.props)({
    checked: getState().other.formRadioGroup.male,
    name: 'sex',
    id: 'male',
    value: 'male',
    label: 'male'
  }, 'male'), {
    onClick: function onClick() {
      return _onClick('male');
    }
  })), _react.default.createElement(_component.default, _extends({}, (0, _stories.props)({
    checked: getState().other.formRadioGroup.female,
    name: 'sex',
    id: 'female',
    value: 'female',
    label: 'female'
  }, 'female'), {
    onClick: function onClick() {
      return _onClick('female');
    }
  })));
}); // .add('Example with redux form', () => (
//   <RadioGroupRF
//     {...props({ value: getState().other.formRadioGroup.value, isRFFWrap: true })}
//     onClick={onClick}
//   />
// ), { info: 'redux-form lib, reduxForm() parent' });