<template>
  <div
    class="fl-input-container"
    :class="{
    'error': isError,
    'disabled': disabled
    }"
    @click="focusInput"
  >
    <label class="fl-input-label">{{ label }}</label>
    <input
      ref="input"
      v-model="valueInput"
      v-bind="$attrs"
      class="fl-input"
      @keyup.enter="$emit('press', $event)"
    >
    <fl-icon
      v-if="$attrs.type === 'password'"
      name="eye"
      class="fl-input-password__icon"
    />
  </div>
</template>

<script>

import InputMixin from '../../mixins/inputMixin'
import FlIcon from '@/core-components/icon/FlIcon'

export default {
  name: 'FlInput',
  components: { FlIcon },
  mixins: [InputMixin],
  props: {
    isError: {
      type: Boolean,
      default: false
    },
    disabled: {
      type: Boolean,
      default: false
    }
  }
}
</script>

<style lang="scss" scoped>
  .fl-input-container {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: 56px;
    padding-top: 5px;
    padding-left: 10px;
    overflow: hidden;
    background: $light-02;
    border: 1px transparent solid;
    border-radius: $border-radius;
    transition: 0.2s;
  }

  .fl-input {
    width: 100%;
    height: 22px;
    margin-top: 0;
    margin-bottom: 0;
    background: transparent;
    transform: translateY(-2px);
  }

  .fl-input-label {
    display: inline-block;
    height: 16px;
    padding-top: 5px;
    color: $grey-01;
    font-size: 12px;
  }

  .fl-input-password__icon {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    fill: #9ba2ab;
  }

  .error {
    border: 1px $red solid;

    .fl-input {
      color: $red;
    }

    .fl-input-label {
      color: $red;
    }
  }

  .disabled {
    background: rgba($grey-01, 0.1);
    pointer-events: none;

    .fl-input {
      color: $grey-01;
    }
  }
</style>
