@namespace Lumeo

<label class="@CssClass" @attributes="AdditionalAttributes">
    @ChildContent
</label>

@code {
    [CascadingParameter] public FormField.FormFieldContext? FieldContext { get; set; }
    [Parameter] public RenderFragment? ChildContent { get; set; }
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private string CssClass => string.Join(" ", new[] { "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70", FieldContext?.HasError == true ? "text-destructive" : null, Class }.Where(s => !string.IsNullOrWhiteSpace(s)));
}
