<template>
  <label
    v-if="label"
    class="block text-sm font-medium text-gray-700"
    :for="id"
    v-text="label"
  />
  <select
    :id="id"
    class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50"
    :class="$attrs.class"
    :value="modelValue"
    @input="$emit('update:modelValue', $event.target.value)"
  >
    <option
      v-for="item in items"
      :key="item.value"
      :value="item.value"
      v-text="item.label"
    />
  </select>
</template>

<script>
export default {
  props: {
    modelValue: {
      type: String,
      default: null,
    },
    label: {
      type: String,
      default: null,
      required: false,
    },
    items: {
      type: Array,
      required: true,
    },
    id: {
      type: String,
      required: true,
    },
  },
  emits: ['update:modelValue'],
}
</script>
