<template>
  <label
    class="Select input"
    :class="{ disabled, unstyled }"
  >
    <select
      :disabled="disabled"
      :value="modelValue"
      @change="$emit('update:modelValue', $event.target.value)"
    >
      <slot />
    </select>
    {{ ' ' }}
    <FAIcon
      class="select-down-icon"
      icon="chevron-down"
    />
  </label>
</template>

<script src="./select.js"> </script>

<style lang="scss">
@import '../../_variables.scss';

/* TODO fix order of styles */
label.Select {
  padding: 0;

  select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: transparent;
    border: none;
    color: $fallback--text;
    color: var(--inputText, --text, $fallback--text);
    margin: 0;
    padding-block: 0 0;
    padding-inline: .2em 2em;
    font-family: sans-serif;
    font-family: var(--inputFont, sans-serif);
    font-size: 1em;
    inline-size: 100%;
    z-index: 1;
    block-size: 2em;
    line-height: 16px;
  }

  .select-down-icon {
    position: absolute;
    inset-block-start: 0;
    inset-block-end: 0;
    inset-inline-end: 5px;
    block-size: 100%;
    inline-size: 0.875em;
    color: $fallback--text;
    color: var(--inputText, $fallback--text);
    line-height: 2;
    z-index: 0;
    pointer-events: none;
  }

}
</style>
