Repository URL to install this package:
|
Version:
3.0.6-working.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const exotic_1 = require("exotic");
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() {
window.addEventListener('keydown', this.handleKeyDown);
}
componentWillUnmount() {
window.removeEventListener('keydown', this.handleKeyDown);
}
render() {
const _a = this.props,
{
isVisible,
onClick,
renderTint
} = _a,
remainingProps = tslib_1.__rest(_a, ["isVisible", "onClick", "renderTint"]);
const attributes = Object.assign({}, remainingProps, {
isVisible,
onClick: this.handleEvent
});
return renderTint(attributes);
}
}
Overlay.defaultProps = {
onClick: exotic_1.NO_OP,
isVisible: false,
renderTint: renderProps_1.renderTint
};
exports.Overlay = Overlay;
exports.default = Overlay; //# sourceMappingURL=Overlay.js.map