"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StyleVisualItem = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
/// <reference path="../../typings/.d.ts" />
const EnumExtensions_1 = require("../../Utilities/Extensions/EnumExtensions");
const Enums_1 = require("../../AdaptableState/Common/Enums");
const StringExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/StringExtensions"));
class StyleVisualItem extends React.Component {
    render() {
        if (!this.props.Style) {
            return null;
        }
        let styleText = StringExtensions_1.default.IsNotNullOrEmpty(this.props.Text)
            ? this.props.Text
            : 'Style';
        let styleVisualisation;
        if (this.props.Style.ClassName) {
            styleVisualisation = React.createElement("div", null, 'CSS Class: ' + this.props.Style.ClassName);
        }
        else {
            let backColorForStyle = this.props.Style.BackColor != undefined ? this.props.Style.BackColor : null;
            let foreColorForStyle = this.props.Style.ForeColor != undefined ? this.props.Style.ForeColor : 'black';
            let borderColorForStyle = this.props.Style.BorderColor != undefined ? this.props.Style.BorderColor : null;
            let fontWeightForStyle = this.props.Style.FontWeight == Enums_1.FontWeight.Bold ? 'bold' : 'normal';
            let fontStyleForStyle = this.props.Style.FontStyle == Enums_1.FontStyle.Italic ? 'italic' : 'normal';
            let fontSizeForStyle = EnumExtensions_1.EnumExtensions.getCssFontSizeFromFontSizeEnum(this.props.Style.FontSize);
            styleVisualisation = (React.createElement("div", { className: this.props.Style.BackColor != undefined ? '' : 'ab_white_grey_stripes', style: {
                    textAlign: 'center',
                    margin: '2px',
                    padding: '3px',
                    background: backColorForStyle,
                    color: foreColorForStyle,
                    borderColor: borderColorForStyle,
                    borderStyle: borderColorForStyle ? 'solid' : 'none',
                    fontWeight: fontWeightForStyle,
                    fontStyle: fontStyleForStyle,
                    fontSize: fontSizeForStyle,
                } }, styleText));
        }
        return styleVisualisation;
    }
}
exports.StyleVisualItem = StyleVisualItem;
