'use strict';

var normalizeComponent = require('./normalize-component-6fa50395.js');

var script = {
  name: 'CloseByKeyAtom',
  props: {
    stopPropagationElements: {
      type: Array,
      default: function _default() {
        return [];
      }
    }
  },
  methods: {
    onKeyUp: function onKeyUp(e) {
      var isEscape = e.keyCode === 27 || e.key === 'Escape';
      if (!isEscape) return;
      var targetNodeName = e.target.nodeName.toLowerCase();

      if (this.stopPropagationElements.includes(targetNodeName)) {
        e.stopPropagation();
        return;
      }

      this.$emit('close', e);
    }
  },
  beforeMount: function beforeMount() {
    window.addEventListener('keyup', this.onKeyUp);
  },
  beforeDestroy: function beforeDestroy() {
    window.removeEventListener('keyup', this.onKeyUp);
  },
  render: function render(createElement) {
    return createElement('div', this.$slots.default);
  }
};

/* script */
const __vue_script__ = script;

/* template */

  /* style */
  const __vue_inject_styles__ = undefined;
  /* scoped */
  const __vue_scope_id__ = undefined;
  /* module identifier */
  const __vue_module_identifier__ = undefined;
  /* functional template */
  const __vue_is_functional_template__ = undefined;
  /* style inject */
  
  /* style inject SSR */
  

  
  var CloseByKeyAtom = normalizeComponent.__vue_normalize__(
    {},
    __vue_inject_styles__,
    __vue_script__,
    __vue_scope_id__,
    __vue_is_functional_template__,
    __vue_module_identifier__,
    undefined,
    undefined
  );

exports.CloseByKeyAtom = CloseByKeyAtom;
