---
import type { SelectField } from '../../resource-types';

interface Props {
  field: SelectField;
  value: unknown;
}

const { field, value } = Astro.props;
const current = value == null ? '' : String(value);
---

<select
  id={`f-${field.key}`}
  name={field.key}
  class="bs-input bs-select"
  required={field.required}
  disabled={field.readOnly}
>
  {!field.required && <option value="">—</option>}
  {field.options.map(opt => (
    <option value={String(opt.value)} selected={String(opt.value) === current}>{opt.label}</option>
  ))}
</select>
