Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"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 };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const exotic_1 = require("exotic");
const deps_1 = require("./deps");
const renderProps_1 = require("./renderProps");
class Overlay extends react_1.default.PureComponent {
    constructor() {
        super(...arguments);
        this.handleKeyDown = (event) => {
            if (event.key === 'Esc' || event.key === 'Escape') {
                this.handleEvent(event);
            }
        };
        // @todo for perf remove this?
        this.handleEvent = (event) => {
            console.debug('[Overlay] onEvent - click or esc');
            if (this.props.onClick) {
                this.props.onClick(event);
            }
        };
    }
    componentDidMount() {
        if (deps_1.IS_BROWSER) {
            window.addEventListener('keydown', this.handleKeyDown);
        }
    }
    componentWillUnmount() {
        if (deps_1.IS_BROWSER) {
            window.removeEventListener('keydown', this.handleKeyDown);
        }
    }
    render() {
        const _a = this.props, { isVisible, onClick, renderTint } = _a, remainingProps = __rest(_a, ["isVisible", "onClick", "renderTint"]);
        const attributes = Object.assign({}, remainingProps, { isVisible, onClick: this.handleEvent });
        return renderTint(attributes);
        // return <Transition {...attributes} />
    }
}
Overlay.defaultProps = {
    onClick: exotic_1.NO_OP,
    isVisible: false,
    renderTint: renderProps_1.renderTint,
};
exports.Overlay = Overlay;
exports.default = Overlay;
//# sourceMappingURL=Overlay.js.map