defmodule LiveViewContinuity.Menu do @moduledoc """ An unstyled, action-only menu with patch-safe client interaction state. See `MENU.md` for the observable interaction contract. """ use Phoenix.Component alias Phoenix.LiveView.JS attr(:id, :string, required: true) attr(:on_action, :string, required: true) attr(:class, :any, default: nil) attr(:rest, :global) slot :trigger, required: true do attr(:class, :any) end slot :item, required: true do attr(:id, :string, required: true) attr(:disabled, :boolean) attr(:class, :any) attr(:close_on_action, :boolean) attr(:typeahead_text, :string) end def menu(assigns) do assigns = case assigns.trigger do [trigger_entry] -> assign(assigns, :trigger_entry, trigger_entry) entries -> raise ArgumentError, "menu requires exactly one trigger slot, got: #{length(entries)}" end ~H"""
"-popup"} role="menu" popover="auto" aria-labelledby={@id <> "-trigger"} >
""" end end