"use strict";
/**
 * @file Checkbox
 * @author fex
 */
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = require("react");
var cx = require("classnames");
var theme_1 = require("../theme");
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(props) {
        var _this = _super.call(this, props) || this;
        _this.hanldeCheck = _this.hanldeCheck.bind(_this);
        return _this;
    }
    Checkbox.prototype.hanldeCheck = 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.createElement("label", { className: cx(ns + "Checkbox " + ns + "Checkbox--" + type, (_b = {},
                _b[ns + "Checkbox--full"] = !partial,
                _b), className) },
            React.createElement("input", { type: type, checked: typeof checked !== 'undefined'
                    ? checked
                    : typeof value === 'undefined'
                        ? value
                        : value == trueValue, onChange: this.hanldeCheck, disabled: disabled, readOnly: readOnly, name: name }),
            React.createElement("i", null),
            React.createElement("span", null, children || label)));
        var _b;
    };
    Checkbox.defaultProps = {
        trueValue: true,
        falseValue: false,
        type: 'checkbox',
    };
    return Checkbox;
}(React.Component));
exports.Checkbox = Checkbox;
exports.default = theme_1.themeable(Checkbox);
//# sourceMappingURL=./components/Checkbox.js.map
