@props([
'label' => null,
'name' => null,
])
@php
$wireModelKey = collect($attributes->getAttributes())->keys()->first(fn ($key) => str_starts_with((string) $key, 'wire:model'));
$wireModelValue = $wireModelKey ? $attributes->get($wireModelKey) : null;
$fieldName = $name ?? $wireModelValue;
$hasError = $fieldName && $errors->has($fieldName);
$inputId = 'field-'.str_replace(['.', '[', ']'], '-', $name ?? $wireModelValue ?? uniqid());
@endphp
@if ($label)
@endif
@if ($hasError)
{{ $errors->first($fieldName) }}
@endif