{{--
    File input.

        <x-form.file name="file" label="Spreadsheet" accept=".xlsx,.csv" required />

    The only input type this app takes a file for is a bulk import, so this
    stays a plain native file input rather than a drag-and-drop zone — a
    `<input type="file">` is already keyboard accessible and shows the chosen
    filename on its own, and a custom drop zone would need to reimplement
    both for no real gain here.
--}}
@props([
    'name',
    'label' => null,
    'help' => null,
    'required' => false,
    'accept' => null,
])

@php
    $id = $attributes->get('id', $name);
    $hasError = $errors->has($name);
@endphp

<div class="ams-field">
    @if ($label)
        <label for="{{ $id }}" class="form-label">
            {{ $label }}@if ($required)<span class="ams-required" aria-hidden="true">*</span>@endif
        </label>
    @endif

    <input type="file"
           name="{{ $name }}"
           id="{{ $id }}"
           @if ($accept) accept="{{ $accept }}" @endif
           @if ($required) required @endif
           @if ($help) aria-describedby="{{ $id }}-help" @endif
           {{ $attributes->except('id')->merge(['class' => 'form-control'.($hasError ? ' is-invalid' : '')]) }}>

    @if ($help)
        <div class="form-text" id="{{ $id }}-help">{{ $help }}</div>
    @endif

    @error($name)
        <div class="invalid-feedback">{{ $message }}</div>
    @enderror
</div>
