"use strict";

exports.__esModule = true;
exports.EmailInput = exports.TextInput = exports.getEventUpdater = exports.FormInput = void 0;

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

var _styledComponents = _interopRequireDefault(require("styled-components"));

var _Input = _interopRequireDefault(require("../../Input"));

var _utils = require("../../../utils");

var _excluded = ["update", "value"],
    _excluded2 = ["update", "value"];

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

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

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

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var FormInput = (0, _styledComponents.default)(_Input.default).withConfig({
  displayName: "Text__FormInput",
  componentId: "sc-6hq9ty-0"
})(["box-sizing:border-box;flex:0 0 auto;border-radius:4px;min-width:40px;width:100%;&:active,&:focus{z-index:1;}&:invalid{border-color:", ";box-shadow:0 0 4px ", ";}", " &[type=\"date\"],&[type=\"number\"],&[type=\"time\"]{-webkit-appearance:none;-moz-appearance:textfield;}&::-webkit-clear-button,&::-webkit-calendar-picker-indicator{display:none;}&::-webkit-outer-spin-button,&::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}"], (0, _utils.getThemeProp)(["colors", "error"], "#ce4844"), (0, _utils.getThemeProp)(["colors", "error"], "#ce4844"), ""
/* These are hacks, work only in Chrome, best not used */
);
exports.FormInput = FormInput;
var getEventUpdater = (0, _utils.memoize)(function (update) {
  return function (e) {
    return update(e.target.value);
  };
});
exports.getEventUpdater = getEventUpdater;

var TextInput = function TextInput(_ref) {
  var update = _ref.update,
      _ref$value = _ref.value,
      value = _ref$value === void 0 ? "" : _ref$value,
      props = _objectWithoutProperties(_ref, _excluded);

  return /*#__PURE__*/_react.default.createElement(FormInput, _extends({
    type: "text",
    onChange: getEventUpdater(update)
  }, props, {
    value: value
  }));
};

exports.TextInput = TextInput;

var EmailInput = function EmailInput(_ref2) {
  var update = _ref2.update,
      _ref2$value = _ref2.value,
      value = _ref2$value === void 0 ? "" : _ref2$value,
      props = _objectWithoutProperties(_ref2, _excluded2);

  return /*#__PURE__*/_react.default.createElement(FormInput, _extends({
    type: "email",
    onChange: getEventUpdater(update)
  }, props, {
    value: value
  }));
};

exports.EmailInput = EmailInput;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(FormInput, "FormInput", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
  reactHotLoader.register(getEventUpdater, "getEventUpdater", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
  reactHotLoader.register(TextInput, "TextInput", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
  reactHotLoader.register(EmailInput, "EmailInput", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(FormInput, "FormInput", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
  reactHotLoader.register(getEventUpdater, "getEventUpdater", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
  reactHotLoader.register(TextInput, "TextInput", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
  reactHotLoader.register(EmailInput, "EmailInput", "/home/vsts/work/1/s/src/components/Form/Inputs/Text.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();