'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var useKeyPress = require('@prom-ui/core/useKeyPress');

function _interopNamespaceCompat(e) {
    if (e && typeof e === 'object' && 'default' in e) return e;
    var n = Object.create(null);
    if (e) {
        Object.keys(e).forEach(function (k) {
            if (k !== 'default') {
                var d = Object.getOwnPropertyDescriptor(e, k);
                Object.defineProperty(n, k, d.get ? d : {
                    enumerable: true,
                    get: function () { return e[k]; }
                });
            }
        });
    }
    n.default = e;
    return Object.freeze(n);
}

var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);

var KeyPressApp = function KeyPressApp(_ref) {
  var code = _ref.code,
    onKeyDown = _ref.onKeyDown,
    onKeyUp = _ref.onKeyUp;
  useKeyPress.useKeyPress(code, onKeyDown, onKeyUp);
  return null;
};
var KeyPress = function KeyPress(_ref2) {
  var _ref2$isActive = _ref2.isActive,
    isActive = _ref2$isActive === void 0 ? true : _ref2$isActive,
    code = _ref2.code,
    _ref2$onKeyDown = _ref2.onKeyDown,
    onKeyDown = _ref2$onKeyDown === void 0 ? function () {} : _ref2$onKeyDown,
    _ref2$onKeyUp = _ref2.onKeyUp,
    onKeyUp = _ref2$onKeyUp === void 0 ? function () {} : _ref2$onKeyUp;
  if (isActive) {
    return /*#__PURE__*/React__namespace.createElement(KeyPressApp, {
      code: code,
      onKeyDown: onKeyDown,
      onKeyUp: onKeyUp
    });
  }
  return null;
};
KeyPress.displayName = 'KeyPress';

Object.defineProperty(exports, 'useKeyPress', {
    enumerable: true,
    get: function () { return useKeyPress.useKeyPress; }
});
exports.KeyPress = KeyPress;
