"use strict";
/**
 * @file Checkbox
 * @author fex
 */
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var react_1 = tslib_1.__importDefault(require("react"));
var classnames_1 = tslib_1.__importDefault(require("classnames"));
var theme_1 = require("../theme");
var helper_1 = require("../utils/helper");
var sizeMap = {
    sm: 'i-checks-sm',
    lg: 'i-checks-lg',
    small: 'i-checks-sm',
    large: 'i-checks-lg',
};
var Checkbox = /** @class */ (function (_super) {
    tslib_1.__extends(Checkbox, _super);
    function Checkbox() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Checkbox.prototype.handleCheck = function (e) {
        var _a = this.props, trueValue = _a.trueValue, falseValue = _a.falseValue, onChange = _a.onChange;
        if (!onChange) {
            return;
        }
        onChange(e.currentTarget.checked ? trueValue : falseValue);
    };
    Checkbox.prototype.render = function () {
        var _a = this.props, size = _a.size, className = _a.className, ns = _a.classPrefix, value = _a.value, label = _a.label, partial = _a.partial, trueValue = _a.trueValue, children = _a.children, disabled = _a.disabled, readOnly = _a.readOnly, checked = _a.checked, type = _a.type, name = _a.name;
        className = (className ? className : '') + (size && sizeMap[size] ? " " + sizeMap[size] : '');
        return (react_1.default.createElement("label", { className: classnames_1.default(ns + "Checkbox " + ns + "Checkbox--" + type, (_b = {},
                _b[ns + "Checkbox--full"] = !partial,
                _b), className) },
            react_1.default.createElement("input", { type: type, checked: typeof checked !== 'undefined'
                    ? checked
                    : typeof value === 'undefined'
                        ? value
                        : value == trueValue, onChange: this.handleCheck, disabled: disabled, readOnly: readOnly, name: name }),
            react_1.default.createElement("i", null),
            react_1.default.createElement("span", null, children || label)));
        var _b;
    };
    Checkbox.defaultProps = {
        trueValue: true,
        falseValue: false,
        type: 'checkbox',
    };
    tslib_1.__decorate([
        helper_1.autobind,
        tslib_1.__metadata("design:type", Function),
        tslib_1.__metadata("design:paramtypes", [typeof (_a = (typeof react_1.default !== "undefined" && react_1.default).ChangeEvent) === "function" && _a || Object]),
        tslib_1.__metadata("design:returntype", void 0)
    ], Checkbox.prototype, "handleCheck", null);
    return Checkbox;
    var _a;
}(react_1.default.Component));
exports.Checkbox = Checkbox;
exports.default = theme_1.themeable(Checkbox);
//# sourceMappingURL=./components/Checkbox.js.map
