'use strict';
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 __());
    };
})();
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
            t[p[i]] = s[p[i]];
    return t;
};
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
export var KEY_ENTER = 13;
export var KEY_SPACE = 32;
var Block = /** @class */ (function (_super) {
    __extends(Block, _super);
    function Block() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.onKeyDown = function (e) {
            var _a = _this.props, onClick = _a.onClick, onKeyDown = _a.onKeyDown, preventDefaultKeyDown = _a.preventDefaultKeyDown;
            if (onKeyDown) {
                onKeyDown(e);
            }
            if (e.keyCode === KEY_ENTER || e.keyCode === KEY_SPACE) {
                onClick && onClick(e);
                if (preventDefaultKeyDown) {
                    e.preventDefault();
                }
            }
        };
        _this.onMouseDown = function (e) {
            var onMouseDown = _this.props.onMouseDown;
            if (onMouseDown) {
                onMouseDown(e);
            }
        };
        return _this;
    }
    Block.prototype.render = function () {
        var _a = this.props, noOffset = _a.noOffset, addTopOffset = _a.addTopOffset, addLeftOffset = _a.addLeftOffset, addRightOffset = _a.addRightOffset, addHorizontalOffset = _a.addHorizontalOffset, cancelTopOffset = _a.cancelTopOffset, cancelBottomOffset = _a.cancelBottomOffset, cancelHorizontalOffset = _a.cancelHorizontalOffset, verticalAlign = _a.verticalAlign, accent = _a.accent, condensed = _a.condensed, halfCondensed = _a.halfCondensed, inline = _a.inline, className = _a.className, testAutomationId = _a.testAutomationId, children = _a.children, handleKeyDown = _a.handleKeyDown, preventDefaultKeyDown = _a.preventDefaultKeyDown, noOverflow = _a.noOverflow, props = __rest(_a, ["noOffset", "addTopOffset", "addLeftOffset", "addRightOffset", "addHorizontalOffset", "cancelTopOffset", "cancelBottomOffset", "cancelHorizontalOffset", "verticalAlign", "accent", "condensed", "halfCondensed", "inline", "className", "testAutomationId", "children", "handleKeyDown", "preventDefaultKeyDown", "noOverflow"]);
        var classNames = classnames(className, {
            'rc-block': !cancelBottomOffset && !noOffset && !inline,
            'rc-block-inline': inline,
            'rc-block-addTopOffset': addTopOffset,
            'rc-block-addLeftOffset': addLeftOffset,
            'rc-block-addRightOffset': addRightOffset,
            'rc-block-addHorizontalOffset': addHorizontalOffset,
            'rc-block-cancelTopOffset': cancelTopOffset,
            'rc-block-cancelBottomOffset': cancelBottomOffset,
            'rc-block-cancelHorizontalOffset': cancelHorizontalOffset,
            'rc-block-accent': accent,
            'rc-block-condensed': condensed,
            'rc-block-half-condensed': halfCondensed,
            'rc-block-vertical-center': verticalAlign === 'center' || verticalAlign === true,
            'rc-block-vertical-bottom': verticalAlign === 'bottom',
            'rc-block-noOverflow': noOverflow
        });
        if (handleKeyDown) {
            props = __assign({}, props, { onMouseDown: this.onMouseDown, onKeyDown: this.onKeyDown });
        }
        return (React.createElement("div", __assign({ className: classNames, "data-test-automation-id": testAutomationId }, props), children));
    };
    Block.propTypes = {
        noOffset: PropTypes.bool,
        addTopOffset: PropTypes.bool,
        addLeftOffset: PropTypes.bool,
        addRightOffset: PropTypes.bool,
        addHorizontalOffset: PropTypes.bool,
        cancelTopOffset: PropTypes.bool,
        cancelBottomOffset: PropTypes.bool,
        cancelHorizontalOffset: PropTypes.bool,
        accent: PropTypes.bool,
        condensed: PropTypes.bool,
        halfCondensed: PropTypes.bool,
        inline: PropTypes.bool,
        verticalAlign: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
        children: PropTypes.node,
        className: PropTypes.string,
        testAutomationId: PropTypes.string,
        onClick: PropTypes.func,
        onKeyDown: PropTypes.func,
        onMouseDown: PropTypes.func,
        handleKeyDown: PropTypes.bool,
        preventDefaultKeyDown: PropTypes.bool,
        noOverflow: PropTypes.bool
    };
    Block.defaultProps = {
        noOffset: false,
        addTopOffset: false,
        addLeftOffset: false,
        addRightOffset: false,
        addHorizontalOffset: false,
        cancelTopOffset: false,
        cancelBottomOffset: false,
        cancelHorizontalOffset: false,
        accent: false,
        condensed: false,
        halfCondensed: false,
        inline: false,
        verticalAlign: false,
        children: null,
        className: null,
        testAutomationId: null,
        onClick: function (e) { return e; },
        onKeyDown: null,
        onMouseDown: null,
        handleKeyDown: false,
        preventDefaultKeyDown: true,
        noOverflow: false
    };
    return Block;
}(React.Component));
export { Block };
//# sourceMappingURL=Block.js.map