"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const components_1 = require("@bluebase/components");
const Button_1 = tslib_1.__importDefault(require("@material-ui/core/Button"));
const react_1 = tslib_1.__importDefault(require("react"));
const component_mapper_1 = require("@bluebase/component-mapper");
const styles_1 = require("./styles");
const withPropsStyles_1 = require("../../withPropsStyles");
exports.Button = withPropsStyles_1.withPropsStyles(styles_1.styles)(component_mapper_1.componentMapper(Button_1.default, {
    children: ({ title, children, loading, icon }) => {
        const content = children ? children : title;
        let _icon;
        if (loading) {
            _icon = (react_1.default.createElement(components_1.ActivityIndicator, { color: "#fff", style: { marginRight: 8, width: 24, height: 24 } }));
        }
        else if (icon) {
            const size = icon.size || 24;
            const iconProps = Object.assign({ size, style: Object.assign({ lineHeight: size, marginRight: 8 }, icon.style) }, icon);
            _icon = react_1.default.createElement(components_1.DynamicIcon, Object.assign({}, iconProps));
        }
        return (react_1.default.createElement(react_1.default.Fragment, null,
            _icon,
            content));
    },
    onClick: 'onPress',
}, { rest: true, ignore: ['loading', 'color'] }));
exports.Button.defaultProps = components_1.ButtonDefaultProps;
