"use strict";
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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const classnames_1 = __importDefault(require("classnames"));
const React = __importStar(require("react"));
const react_jss_1 = __importDefault(require("react-jss"));
const Button_1 = require("../Button");
const styles = (theme) => ({
    button: {
        transition: 'background-color .6s',
        overflow: 'hidden',
        '&.sent': {
            backgroundColor: '#64bf6f !important',
        },
        '& > *': {
            display: 'block',
            overflow: 'hidden',
            height: 'inherit',
        },
        '& > *:not(.sentSpan)': Object.assign({}, theme.mixins.flexbox.containerCenter, { transition: 'transform .6s', transform: 'translateY(-100%)' }),
        '&.sent > *:not(.sentSpan)': {
            transform: 'translateY(0)',
        },
        '& .sentSpan': Object.assign({}, theme.mixins.flexbox.containerCenter, { transition: 'transform .6s, color .6s', transform: 'translateY(-100%)', color: 'white' }),
        '&.sent .sentSpan': {
            transform: 'translateY(0)',
        },
    },
});
class ButtonFeedbackImpl extends React.PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            sent: false,
        };
        this.onClick = this.onClick.bind(this);
    }
    onClick(e) {
        if (this.props.onClick) {
            this.props.onClick(e);
        }
        clearTimeout(this.feedbackTimeout);
        this.setState({ sent: true });
        this.feedbackTimeout = setTimeout(() => {
            this.setState({ sent: false });
        }, 2500);
    }
    render() {
        const _a = this.props, { children, className, classes } = _a, buttonProps = __rest(_a, ["children", "className", "classes"]);
        const { sent } = this.state;
        const child = (typeof children === 'string') ?
            React.createElement("span", null, children) : React.Children.only(children);
        return (React.createElement(Button_1.Button, Object.assign({ className: classnames_1.default(className, classes.button, { sent }), onClick: this.onClick }, buttonProps),
            React.createElement("span", { className: "sentSpan" }, "Sent"),
            child));
    }
}
exports.ButtonFeedback = react_jss_1.default(styles)(ButtonFeedbackImpl);
//# sourceMappingURL=index.js.map