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);
};
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import './InputCheckbox.scss';
import CheckboxSvg from '../Icons/CheckboxSvg';
var InputCheckbox = /** @class */ (function (_super) {
    __extends(InputCheckbox, _super);
    function InputCheckbox() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.handleChange = function (event) {
            return _this.props.onChange(event.target.checked);
        };
        _this.renderIcon = function () {
            if (_this.props.disableIcon) {
                return null;
            }
            if (_this.props.icon) {
                return React.createElement(_this.props.icon, __assign(__assign({}, _this.props.iconProps), { className: "input-checkbox__icon " + _this.props.iconProps.className }));
            }
            return (React.createElement(CheckboxSvg, { className: "input-checkbox__icon", hasBorder: true, hasCircle: false }));
        };
        return _this;
    }
    InputCheckbox.prototype.render = function () {
        return (React.createElement("label", { className: [
                'input-checkbox',
                'input-checkbox-label',
                'qa-input-checkbox_label',
                this.props.className,
            ]
                .filter(Boolean)
                .join(' ') },
            React.createElement("input", { checked: this.props.checked, className: "input-checkbox__input qa-input-checkbox_input", name: this.props.name, onChange: this.handleChange, tabIndex: this.props.tabIndex, type: "checkbox" }),
            React.createElement("div", { className: "input-checkbox__focus-indicator" }),
            this.renderIcon(),
            React.createElement("span", { className: "input-checkbox__text" }, this.props.label)));
    };
    InputCheckbox.propTypes = {
        checked: PropTypes.any.isRequired,
        className: PropTypes.string,
        disableIcon: PropTypes.bool,
        icon: PropTypes.func,
        iconProps: PropTypes.object,
        label: PropTypes.any.isRequired,
        name: PropTypes.string,
        onChange: PropTypes.func.isRequired,
        tabIndex: PropTypes.number,
    };
    InputCheckbox.defaultProps = {
        className: '',
        disableIcon: false,
        iconProps: {},
        tabIndex: 0,
    };
    return InputCheckbox;
}(PureComponent));
export default InputCheckbox;
//# sourceMappingURL=InputCheckbox.js.map