'use strict';

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

var __chunk_1 = require('./chunk-cc325129.js');
var __chunk_2 = require('./chunk-d8f887e2.js');
var __chunk_5 = require('./chunk-22e9253e.js');
var __chunk_7 = require('./chunk-29761f59.js');

//
var inputId = 1;
var script = {
  name: 'VFileDropArea',
  data: function data() {
    return {
      // eslint-disable-next-line no-plusplus
      inputId: "v-file-drop-area-idx-".concat(inputId++)
    };
  },
  methods: {
    onChange: function onChange(e) {
      this.$emit('change', e.target.files);
    },
    preventDrop: function preventDrop(e) {
      e.preventDefault();
      e.stopPropagation();
      return false;
    },
    handleDrop: function handleDrop(e) {
      if (this.isDisabled) {
        return this.preventDrop(e);
      }

      var files = this.getTransferFiles(e);
      this.$emit('change', files);
      return this.preventDrop(e);
    },
    getTransferFiles: function getTransferFiles(e) {
      var fileList = [];

      if (e.dataTransfer) {
        var dataTransfer = e.dataTransfer;

        if (dataTransfer.files && dataTransfer.files.length) {
          fileList = dataTransfer.files;
        } else if (dataTransfer.items && dataTransfer.items.length) {
          // During the drag even the dataTransfer.files is null
          // but Chrome implements some drag store, which is accessible via dataTransfer.items
          fileList = dataTransfer.items;
        }
      } else if (e.target && e.target.files) {
        fileList = e.target.files;
      }

      return fileList;
    }
  },
  beforeMount: function beforeMount() {
    window.addEventListener('dragenter', this.preventDrop, false);
    window.addEventListener('dragleave', this.preventDrop, false);
    window.addEventListener('dragover', this.preventDrop, false);
    window.addEventListener('drop', this.handleDrop, false);
  },
  beforeDestroy: function beforeDestroy() {
    window.removeEventListener('dragenter', this.preventDrop, false);
    window.removeEventListener('dragleave', this.preventDrop, false);
    window.removeEventListener('dragover', this.preventDrop, false);
    window.removeEventListener('drop', this.handleDrop, false);
  },
  mixins: [__chunk_2.ThemeMixin, __chunk_5.IsDisabledMixin],
  components: {
    FieldAtom: __chunk_7.FieldAtom
  }
};

/* script */
const __vue_script__ = script;

/* template */
var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('field-atom',{staticClass:"v-file-drop-area",class:_vm.themeCssClass},[_c('button',{staticClass:"v-file-drop-area-button",attrs:{"type":"button"}},[_c('label',{staticClass:"v-file-drop-area-label",attrs:{"for":_vm.inputId}},[_c('div',[_vm._t("default")],2),_vm._v(" "),_c('input',_vm._b({staticClass:"file-drop-area-input",attrs:{"id":_vm.inputId,"type":"file"},on:{"change":_vm.onChange}},'input',_vm.$attrs,false))])])])};
var __vue_staticRenderFns__ = [];

  /* 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__ = false;
  /* style inject */
  
  /* style inject SSR */
  

  
  var VFileDropArea = __chunk_1.__vue_normalize__(
    { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
    __vue_inject_styles__,
    __vue_script__,
    __vue_scope_id__,
    __vue_is_functional_template__,
    __vue_module_identifier__,
    undefined,
    undefined
  );

exports.default = VFileDropArea;
