"use strict";

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

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

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

var _reduxForm = require("redux-form");

var _index = require("../index");

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 TestWrap = function TestWrap(_ref) {
  var children = _ref.children;
  return _react.default.createElement("form", null, children);
};

var RFWrap = (0, _reduxForm.reduxForm)({
  form: 'rf-wrap2'
})(TestWrap);

var props = function props() {
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
      _ref2$isHidden = _ref2.isHidden,
      isHidden = _ref2$isHidden === void 0 ? undefined : _ref2$isHidden,
      _ref2$isDisabled = _ref2.isDisabled,
      isDisabled = _ref2$isDisabled === void 0 ? undefined : _ref2$isDisabled,
      _ref2$isUnstyledPlace = _ref2.isUnstyledPlaceholder,
      isUnstyledPlaceholder = _ref2$isUnstyledPlace === void 0 ? undefined : _ref2$isUnstyledPlace,
      _ref2$isInCombo = _ref2.isInCombo,
      isInCombo = _ref2$isInCombo === void 0 ? undefined : _ref2$isInCombo,
      _ref2$type = _ref2.type,
      type = _ref2$type === void 0 ? undefined : _ref2$type,
      _ref2$placeholder = _ref2.placeholder,
      placeholder = _ref2$placeholder === void 0 ? 'placeholder' : _ref2$placeholder,
      _ref2$afterText = _ref2.afterText,
      afterText = _ref2$afterText === void 0 ? undefined : _ref2$afterText,
      _ref2$id = _ref2.id,
      id = _ref2$id === void 0 ? 'something' : _ref2$id;

  return {
    isHidden: (0, _addonKnobs.boolean)('isHidden', isHidden),
    isDisabled: (0, _addonKnobs.boolean)('isDisabled', isDisabled),
    isUnstyledPlaceholder: (0, _addonKnobs.boolean)('isUnstyledPlaceholder', isUnstyledPlaceholder),
    isInCombo: (0, _addonKnobs.boolean)('isInCombo', isInCombo),
    type: (0, _addonKnobs.text)('type', type),
    placeholder: (0, _addonKnobs.text)('placeholder', placeholder),
    afterText: (0, _addonKnobs.text)('afterText', afterText),
    id: (0, _addonKnobs.text)('id', id)
  };
};

(0, _react2.storiesOf)('Web|form/TextField').add('Default', function () {
  return _react.default.createElement(RFWrap, null, _react.default.createElement(_reduxForm.Field, _extends({
    component: _index.TextField
  }, props())));
}).add('Error', function () {
  return _react.default.createElement(RFWrap, null, _react.default.createElement(_reduxForm.Field, _extends({
    component: _index.TextField
  }, props(), {
    meta: {
      touched: true,
      error: 'error message'
    }
  })));
}, {
  info: 'redux-form lib, reduxForm() parent'
});