"use strict";

exports.__esModule = true;
exports.default = exports.RequiredNotice = exports.Label = exports.FieldBox = void 0;

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

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

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

var _Text = _interopRequireDefault(require("../Text"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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

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 FieldBox = _styledComponents.default.div.withConfig({
  displayName: "Field__FieldBox",
  componentId: "sc-oln5y9-0"
})(["flex:0 1 auto;display:flex;flex-direction:column;margin-top:20px;position:relative;"]);

exports.FieldBox = FieldBox;

var Label = _styledComponents.default.label.withConfig({
  displayName: "Field__Label",
  componentId: "sc-oln5y9-1"
})(["", " min-height:17px;", ";", ";", ""], (0, _utils.ifFlag)("invalid", (0, _styledComponents.css)(["color:", ";"], (0, _utils.getThemeProp)(["colors", "error"], "#ce4844")), (0, _styledComponents.css)(["color:", ";"], (0, _utils.getThemeProp)(["colors", "textMedium"], "#999999"))), (0, _utils.ifFlag)("center", (0, _styledComponents.css)(["text-align:center;"])), (0, _utils.ifFlag)("labelOnly", "", (0, _styledComponents.css)(["margin-bottom:10px;"])), (0, _utils.ifFlag)("required", (0, _styledComponents.css)(["&::after{content:\" *\";color:#666;}"])));

exports.Label = Label;

var RequiredNotice = _styledComponents.default.div.withConfig({
  displayName: "Field__RequiredNotice",
  componentId: "sc-oln5y9-2"
})(["position:absolute;bottom:-1.6em;right:0;color:", ";"], (0, _utils.getThemeProp)(["colors", "error"], "#ce4844"));

exports.RequiredNotice = RequiredNotice;

var Field = function Field(_ref) {
  var id = _ref.id,
      label = _ref.label,
      center = _ref.center,
      labelOnly = _ref.labelOnly,
      required = _ref.required,
      invalid = _ref.invalid,
      children = _ref.children;
  var reqFlag = {
    invalid: invalid
  };
  if (required) reqFlag.required = true;
  return /*#__PURE__*/_react.default.createElement(FieldBox, null, label !== undefined ? /*#__PURE__*/_react.default.createElement(Label, _extends({
    htmlFor: labelOnly ? undefined : id,
    labelOnly: labelOnly,
    id: id + "_label",
    center: center
  }, reqFlag), /*#__PURE__*/_react.default.createElement(_Text.default, {
    message: label
  })) : null, labelOnly ? null : children, !labelOnly && required && invalid ? /*#__PURE__*/_react.default.createElement(RequiredNotice, null, /*#__PURE__*/_react.default.createElement(_Text.default, {
    message: required
  })) : null);
};

var _default = Field;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

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

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(FieldBox, "FieldBox", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(Label, "Label", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(RequiredNotice, "RequiredNotice", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(Field, "Field", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/Form/Field.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(FieldBox, "FieldBox", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(Label, "Label", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(RequiredNotice, "RequiredNotice", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(Field, "Field", "/home/vsts/work/1/s/src/components/Form/Field.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/Form/Field.js");
})();

;

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