'use strict';

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

var _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; };

exports.default = PasswordInput;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _pathHelpers = require('../helpers/pathHelpers');

var _LineInput = require('../../styles/cspace-input/LineInput.css');

var _LineInput2 = _interopRequireDefault(_LineInput);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var propTypes = {
  name: _react.PropTypes.string,
  parentPath: _pathHelpers.pathPropType,
  subpath: _pathHelpers.pathPropType,
  value: _react.PropTypes.string
};

var defaultProps = {
  value: ''
};

function PasswordInput(props) {
  var name = props.name,
      value = props.value,
      remainingProps = _objectWithoutProperties(props, ['name', 'value']);

  var normalizedValue = value === null || typeof value === 'undefined' ? '' : value;
  var readOnly = !remainingProps.onChange;

  return _react2.default.createElement('input', _extends({}, remainingProps, {
    className: _LineInput2.default.normal,
    name: name,
    readOnly: readOnly,
    type: 'password',
    value: normalizedValue
  }));
}

PasswordInput.propTypes = propTypes;
PasswordInput.defaultProps = defaultProps;