'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

var _themeGet = require('../../extensions/themeGet');

var _themeGet2 = _interopRequireDefault(_themeGet);

var _userTextSpacing = require('../../extensions/userTextSpacing');

var _userTextSpacing2 = _interopRequireDefault(_userTextSpacing);

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

var Label = _styledComponents2.default.label.withConfig({ displayName: 'Label' }).attrs({
  spacing: _userTextSpacing2.default
}).withConfig({
  displayName: 'Label'
})(['font-size:1em;letter-spacing:0.02em;font-weight:700;font-family:', ';color:', ';background:transparent;line-height:1.5;display:block;margin:', ';', ';', ';'], (0, _themeGet2.default)('fonts.brand'), (0, _themeGet2.default)('colors.text.default'), function (props) {
  return props.spacing;
}, function (_ref) {
  var disabled = _ref.disabled;
  return disabled && (0, _styledComponents.css)(['color:', ';'], (0, _themeGet2.default)('colors.text.disabled'));
}, function (_ref2) {
  var required = _ref2.required;
  return required ? (0, _styledComponents.css)(['&::after{content:\'*\';color:#e8562e;padding-left:0.3em;}']) : '';
});

Label.propTypes = {
  /**
   * Styles the label to indicate that the associated field is disabled.
   */
  disabled: _propTypes2.default.bool,
  /**
   * Adds a class name to the element.
   */
  className: _propTypes2.default.string,
  /**
   * Adds an id to the element.
   */
  id: _propTypes2.default.string,
  /**
   * Adds a red star at the end of the label.
   */
  required: _propTypes2.default.bool,
  /**
   * Specify a CSS value or an object { top, right, bottom, left } or { vertical, horizontal } to
   * control the spacing around the heading. Defaults to a large space below the element.
   */
  spacing: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object])
};

Label.defaultProps = {
  disabled: false,
  className: null,
  id: null,
  required: false
};

/**
 * @component
 */
exports.default = Label;