@namespace Lumeo

@{
    var itemContext = new AccordionItemContext(Value, Disabled);
}

<CascadingValue Value="itemContext" IsFixed="false">
    <div class="@CssClass" @attributes="AdditionalAttributes">
        @ChildContent
    </div>
</CascadingValue>

@code {
    [Parameter] public RenderFragment? ChildContent { get; set; }
    [Parameter, EditorRequired] public string Value { get; set; } = "";
    [Parameter] public bool Disabled { get; set; }
    [Parameter] public string? Class { get; set; }
    [Parameter(CaptureUnmatchedValues = true)] public Dictionary<string, object>? AdditionalAttributes { get; set; }

    private string CssClass => string.Join(" ", new[] { "border-b border-border/40", Disabled ? "opacity-50" : null, Class }.Where(s => !string.IsNullOrWhiteSpace(s)));

    public record AccordionItemContext(string Value, bool Disabled);
}
