@page "/dev/context-menu-demo"
@* Dev-only host page to live-verify the reusable ContextMenu component. *@
@attribute [Authorize(Policy = AdminUiPolicies.AuthenticatedRead)]
@rendermode InteractiveServer

<PageTitle>ContextMenu demo</PageTitle>

<h1>ContextMenu demo</h1>
<p>Right-click the card below, or use the <strong>⋯</strong> button.</p>

<div style="display:flex; align-items:center; gap:1rem; margin:1rem 0;">
    <ContextMenu Items="_items" ShowEllipsis="false">
        <div style="padding:2rem 3rem; border:1px dashed var(--bs-border-color); border-radius:.5rem; user-select:none;">
            Right-click me
        </div>
    </ContextMenu>

    <ContextMenu Items="_items" ShowEllipsis="true" />
</div>

<p>Last action: <strong>@_lastAction</strong></p>

@code {
    private string _lastAction = "(none)";

    private IReadOnlyList<ContextMenuItem> _items => new List<ContextMenuItem>
    {
        new() { Label = "Edit", Icon = "✏️", OnClick = () => Set("Edit") },
        new() { Label = "Duplicate", Icon = "📄", OnClick = () => Set("Duplicate") },
        ContextMenuItem.Separator(),
        new() { Label = "Delete", Icon = "🗑️", Disabled = true, OnClick = () => Set("Delete") },
    };

    private Task Set(string action)
    {
        _lastAction = action;
        return Task.CompletedTask;
    }
}
