@namespace Lumeo

<div class="@CssClass" role="button" aria-expanded="@Context.IsOpen" @onclick="Toggle" @attributes="AdditionalAttributes">
    @ChildContent
</div>

@code {
    [CascadingParameter] public Popover.PopoverContext Context { get; set; } = default!;
    [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 => $"inline-flex {Class}".Trim();

    private async Task Toggle() => await Context.SetOpen.InvokeAsync(!Context.IsOpen);
}
