"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = (0, tslib_1.__importStar)(require("react"));
require("./index.css");
var PropTypes = (0, tslib_1.__importStar)(require("prop-types"));
var classnames_1 = (0, tslib_1.__importDefault)(require("../../utils/classnames"));
function Text(_a) {
    var text = _a.text, _b = _a.maxLines, maxLines = _b === void 0 ? 2 : _b, space = _a.space, _c = _a.userSelect, userSelect = _c === void 0 ? true : _c, _d = _a.style, style = _d === void 0 ? {} : _d, className = _a.className, events = _a.events, id = _a.id, props = (0, tslib_1.__rest)(_a, ["text", "maxLines", "space", "userSelect", "style", "className", "events", "id"]);
    var textStyle = {
        WebkitLineClamp: maxLines,
        whiteSpace: space ? 'pre-wrap' : 'pre-line',
    };
    if (!userSelect) {
        textStyle.userSelect = 'none';
    }
    var contenteditable = props.contenteditable, onInput = props.onInput, onBlur = props.onBlur;
    return (React.createElement("p", { contentEditable: contenteditable, onInput: onInput, onBlur: onBlur, style: (0, tslib_1.__assign)((0, tslib_1.__assign)({}, textStyle), style), className: (0, classnames_1.default)('weda-text', 'weda-ui', className), id: id, onClick: function (e) { return events.tap({}, { originEvent: e }); } }, text));
}
exports.default = Text;
Text.propTypes = {
    /**
     * 文本内容
     */
    text: PropTypes.string,
    /**
     * 最大显示行数。0 表示无限制
     */
    maxLines: PropTypes.number,
    /**
     * 是否显示连续空格
     */
    space: PropTypes.bool,
    userSelect: PropTypes.bool,
    events: PropTypes.objectOf(PropTypes.func),
    style: PropTypes.object,
    className: PropTypes.string,
    id: PropTypes.string,
    contenteditable: PropTypes.oneOf([PropTypes.string, PropTypes.bool]),
    onInput: PropTypes.func,
    onBlur: PropTypes.func,
};
Text.defaultProps = {
    maxLines: 2,
    text: '文本内容',
    space: false,
    userSelect: true,
};
//# sourceMappingURL=index.js.map