var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import * as _ from "lodash";
import * as classnames from "classnames";
import * as React from "react";
import * as PropTypes from "prop-types";
import Tooltip from "../Tooltip";
import "./Label.less";
var Color = {
    // General:
    DEFAULT: "default",
    NEW_FEATURE: "new-feature",
    // Alerts:
    SUCCESS: "success",
    WARNING: "warning",
    ERROR: "error",
    // Accents:
    CATEGORY_1: "new-feature",
    CATEGORY_2: "category-2",
    TAG: "tag",
    // For backwards compatibility:
    BLUE: "new-feature",
    AQUA: "new-feature",
    PURPLE: "new-feature",
    PINK: "category-2",
    GRAY: "default",
};
// We are reducing the options from S/M/L to only S/L so
// here we map M -> s for backwards compatibility.
var Size = {
    S: "s",
    M: "s",
    L: "l",
};
var propTypes = {
    children: PropTypes.node.isRequired,
    className: PropTypes.string,
    color: PropTypes.oneOf(_.values(Color)),
    tooltip: PropTypes.node,
    tooltipPlacement: Tooltip.propTypes.placement,
    tooltipTextAlign: Tooltip.propTypes.textAlign,
    size: PropTypes.oneOf(_.values(Size)),
};
var defaultProps = {
    color: Color.DEFAULT,
    size: Size.S,
};
export var cssClass = {
    CONTAINER: "Label",
    WITH_TOOLTIP: "Label--withTooltip",
    color: function (c) { return "Label--" + c; },
    size: function (s) { return "Label--" + s; },
};
var Label = /** @class */ (function (_super) {
    __extends(Label, _super);
    function Label() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.label = React.createRef();
        return _this;
    }
    Label.prototype.focus = function () {
        this.label.current.focus();
    };
    Label.prototype.render = function () {
        var _a = this.props, children = _a.children, className = _a.className, color = _a.color, size = _a.size, tooltip = _a.tooltip, tooltipPlacement = _a.tooltipPlacement, tooltipTextAlign = _a.tooltipTextAlign;
        var label = (React.createElement("span", { className: classnames(cssClass.CONTAINER, color && cssClass.color(color), size && cssClass.size(size), tooltip && cssClass.WITH_TOOLTIP, className), ref: this.label, tabIndex: tooltip ? 0 : undefined }, children));
        if (!tooltip) {
            return label;
        }
        return (React.createElement(Tooltip, { content: tooltip, placement: tooltipPlacement, textAlign: tooltipTextAlign }, label));
    };
    Label.propTypes = propTypes;
    Label.defaultProps = defaultProps;
    Label.Color = Color;
    Label.Size = Size;
    return Label;
}(React.PureComponent));
export default Label;
