import "./index.css";
/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
import { componentMixin, createComponentName } from '../_utils/component';
import Textarea from './Textarea';
let id = 0;
const __vue_script__ = {
  Textarea,
  name: createComponentName('input'),
  mixins: [componentMixin],
  model: {
    name: 'value',
    event: 'input'
  },
  props: {
    value: {
      type: String,
      default: ''
    },
    type: {
      type: String,
      default: 'text'
    },
    id: {
      type: String
    },
    autocomplete: {
      type: String,
      default: 'off'
    },
    placeholder: {
      type: String,
      default: ''
    },
    label: {
      type: String,
      default: ''
    }
  },

  data() {
    return {
      privateValue: this.$hasProp('value') ? this.value : this.$hasProp('defaultValue') ? this.defaultValue : '',
      textareaCalcStyle: {},
      prefixOffset: null,
      suffixOffset: null,
      hovering: false,
      focused: false,
      isError: false
    };
  },

  watch: {
    value(v) {
      this.privateValue = v;
    }

  },

  created() {
    if (!this.$hasProp('id')) {
      this.__id = 'gd-input-id-' + id++;
    }
  },

  methods: {
    handleInput(event) {
      const value = event.target.value;
      this.privateValue = value;
      this.$emit('input', value, event);
    },

    handleBlur(event) {
      this.focused = false;
      this.$emit('blur', event);
    },

    handleFocus(event) {
      this.focused = true;
      this.$emit('focus', event);
    },

    handleChange(event) {
      const value = event.target.value;
      this.privateValue = value;
      this.$emit('change', value, event);
    },

    handleEnter(event) {
      this.handleInput(event);
      this.handleChange(event);
      this.$emit('enter', event);
    }

  }
};
/* template */

var __vue_render__ = function () {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c("div", {
    class: _vm.bem({
      focus: _vm.focused
    })
  }, [_vm.label ? _c("label", {
    class: _vm.bem("label"),
    attrs: {
      for: _vm.id || _vm.__id
    }
  }, [_vm._v(_vm._s(_vm.label))]) : _vm._e(), _vm._v(" "), _vm._t("prepend"), _vm._v(" "), _c("input", _vm._g(_vm._b({
    class: _vm.bem("inner"),
    attrs: {
      id: _vm.id || _vm.__id,
      placeholder: _vm.placeholder,
      type: _vm.type,
      autocomplete: _vm.autocomplete
    },
    domProps: {
      value: _vm.privateValue
    },
    on: {
      input: _vm.handleInput,
      change: _vm.handleChange,
      focus: _vm.handleFocus,
      blur: _vm.handleBlur,
      keypress: function ($event) {
        if (!("button" in $event) && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) {
          return null;
        }

        return _vm.handleEnter($event);
      }
    }
  }, "input", _vm.$$attrs, false), _vm.ignoreListeners(["input", "change", "focus", "blur"]))), _vm._v(" "), _vm._t("append")], 2);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* 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;
/* component normalizer */

import __vue_normalize__ from '../_utils/vue-normalize-component.js';
/* style inject */

/* style inject SSR */

export default __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);