"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const getComponent_1 = require("../../getComponent");
const Context_1 = require("../../Context");
const react_1 = tslib_1.__importDefault(require("react"));
/**
 * # ⏳ LoadingState
 *
 * A component that is used to show a loading state. Shows a spinner by
 * default. If 'timedOut' flag is set then it shows a timeout version.
 *
 * ## Usage
 * ```jsx
 * <LoadingState timedOut={false} retry={retryFunction}/>
 * ```
 *
 * TODO: Add a prop to allow custom text for retry button.
 */
class LoadingState extends react_1.default.Component {
    render() {
        const { timedOut, retry } = this.props;
        const props = {
            image: react_1.default.createElement(getComponent_1.ActivityIndicator, null)
        };
        if (timedOut === true) {
            props.description = 'This is taking longer than usual';
            if (retry) {
                props.actionTitle = 'Retry';
                props.actionOnPress = retry;
            }
        }
        return react_1.default.createElement(getComponent_1.ComponentState, Object.assign({}, props));
    }
}
LoadingState.contextType = Context_1.BlueBaseContext;
exports.LoadingState = LoadingState;
