defmodule <%= @module_name %>.Components.UI.Table do @moduledoc """ Composable Table component for dense data grids in dashboards. Ejected from PhiaUI — owns this copy of the source. Customise freely. > #### LiveView Streams compatibility {: .tip} > > Use table_body/1 as the stream container: > > <.table_body id="users" phx-update="stream"> > <.table_row :for={{dom_id, user} <- @streams.users} id={dom_id}> > <.table_cell><%%= user.name %> > > ## Example <.table> <.table_caption>Users <.table_header> <.table_row> <.table_head>Name <.table_head>Email <.table_body> <.table_row> <.table_cell>Alice <.table_cell>alice@example.com """ use Phoenix.Component import <%= @module_name %>.ClassMerger, only: [cn: 1] attr :class, :string, default: nil, doc: "Additional CSS classes for outer wrapper" attr :rest, :global, doc: "HTML attributes forwarded to the outer div" slot :inner_block, required: true def table(assigns) do ~H"""
<%%= render_slot(@inner_block) %>
""" end attr :class, :string, default: nil, doc: "Additional CSS classes" attr :rest, :global slot :inner_block, required: true def table_header(assigns) do ~H""" <%%= render_slot(@inner_block) %> """ end attr :class, :string, default: nil, doc: "Additional CSS classes" attr :rest, :global, doc: "Supports phx-update for LiveView Streams" slot :inner_block, required: true def table_body(assigns) do ~H""" <%%= render_slot(@inner_block) %> """ end attr :class, :string, default: nil, doc: "Additional CSS classes" attr :rest, :global slot :inner_block, required: true def table_footer(assigns) do ~H""" <%%= render_slot(@inner_block) %> """ end attr :class, :string, default: nil, doc: "Additional CSS classes" attr :selected, :boolean, default: false, doc: "Marks row as selected" attr :rest, :global slot :inner_block, required: true def table_row(assigns) do ~H""" <%%= render_slot(@inner_block) %> """ end attr :class, :string, default: nil, doc: "Additional CSS classes" attr :rest, :global slot :inner_block, required: true def table_head(assigns) do ~H""" <%%= render_slot(@inner_block) %> """ end attr :class, :string, default: nil, doc: "Additional CSS classes" attr :rest, :global slot :inner_block, required: true def table_cell(assigns) do ~H""" <%%= render_slot(@inner_block) %> """ end attr :class, :string, default: nil, doc: "Additional CSS classes" attr :rest, :global slot :inner_block, required: true def table_caption(assigns) do ~H""" <%%= render_slot(@inner_block) %> """ end end