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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _theme = require('../const/theme');

var _styles = require('../helpers/styles');

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

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

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

/**
 * Normal text component
 */
var Text = function Text(props) {
    var numberOfLines = props.numberOfLines,
        styles = props.styles,
        rest = _objectWithoutProperties(props, ['numberOfLines', 'styles']);

    return _react2.default.createElement(
        'span',
        _extends({}, rest, {
            className: _styles.css.apply(undefined, [STYLES.text, numberOfLines == 1 && STYLES.singleLine].concat(_toConsumableArray(styles || [])))
        }),
        props.text || props.children
    );
};

var STYLES = _styles.StyleSheet.create({
    text: {
        display: 'inline-block',
        fontFamily: _theme.FONT.FAMILY,
        fontSize: _theme.FONT.SIZE_TEXT,
        fontWeight: 400,
        lineHeight: _theme.FONT.BASE_LINE_HEIGHT,
        color: _theme.COLOR.TEXT
    },
    singleLine: {
        overflow: 'hidden',
        textOverflow: 'ellipsis',
        whiteSpace: 'nowrap'
    },
    sub: {
        fontSize: _theme.FONT.SIZE_SUB_TEXT,
        color: _theme.COLOR.SUB_TEXT
    }
});

exports.default = Text;