import { __assign, __rest } from "tslib";
import * as React from 'react';
import './index.css';
import * as PropTypes from 'prop-types';
import classNames from '../../utils/classnames';
export default 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 = __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: __assign(__assign({}, textStyle), style), className: classNames('weda-text', 'weda-ui', className), id: id, onClick: function (e) { return events.tap({}, { originEvent: e }); } }, 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