<template>
  <div class="RDateInput">
    <span class="RDateInput-Label">{{ label }}</span>
    <div class="RDateInput-Content">
      <x-date-input
        label="От"
        :options="options"
        :value="from"
        hide-bottom-space
        class="RDateInput-Input"
        @input="inputHandler($event, 'from')"
      />
      <x-date-input
        label="До"
        :options="options"
        :value="to"
        hide-bottom-space
        class="RDateInput-Input"
        @input="inputHandler($event, 'to')"
      />
    </div>
</div>

</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';
import XDateInput from './x-date-input.vue';

@Component({
  components: { XDateInput },
})
export default class RDateInput extends Vue {
  @Prop() private from!: Date;
  @Prop() private to!: Date;
  @Prop() options: Date;
  @Prop() label: string;

  private inputHandler($event: any, field: string): void {
    this.$emit(`update:${field}`, $event);
    this.$emit('input', {
      from: this.from,
      to: this.to,
    });
  }
}
</script>

<style lang="scss" scoped>
.RDateInput {
  display: flex;
  flex-direction: column;
  &-Label {
    font-family: 'Golos Text', sans-serif;
    font-style: normal;
    font-weight: 600;
    font-size: 12px;
    line-height: 16px;
    color: rgba(2, 12, 18, 0.58);
    margin-bottom: 4px;
  }
  &-Content {
    display: flex;
    flex-wrap: nowrap;
  }
  &-Input {
    flex-basis: 100%;
    &:not(:last-child) {
      margin-right: 8px;
    }
  }
}
</style>
