PtahUi.Components.Table (PtahUI v0.1.0)

Copy Markdown View Source

Data table with sortable columns, row click, actions, and pagination.

Pagination and sorting work with any meta map that has the fields produced by Flop.Meta, but Flop is not a hard dependency — pass any compatible struct/map.

Example

<.table id="users" items={@users} meta={@meta} params={@params}>
  <:col :let={user} label="Nome" field={:name} sortable>
    {user.name}
  </:col>
  <:col :let={user} label="Email">{user.email}</:col>
  <:action :let={user}>
    <.link patch={~p"/users/#{user}/edit"}>Editar</.link>
  </:action>
</.table>

Summary

Functions

Renders a pagination bar.

Functions

pagination(assigns)

Renders a pagination bar.

Attributes

  • meta (:any) (required)
  • params (:map) (required)
  • active_page_class (:string) - Classes for the current page button. Defaults to "bg-indigo-600 text-white border-indigo-600".
  • inactive_page_class (:string) - Classes for other page buttons. Defaults to "bg-white text-gray-600 border-gray-200 hover:bg-gray-50".

table(assigns)

Attributes

  • id (:string) (required)
  • items (:any) (required) - List or LiveStream of rows.
  • meta (:any) (required) - Pagination/sorting metadata (e.g. Flop.Meta).
  • params (:map) (required) - Current query params map.
  • row_id (:any) - Defaults to nil.
  • row_click (:any) - Defaults to nil.
  • sortable (:boolean) - Defaults to false.
  • wrapper_class (:string) - Classes for the table wrapper div. Defaults to "bg-white border border-gray-200".
  • header_class (:string) - Classes for the thead row. Defaults to "text-gray-500 border-b border-gray-200 bg-gray-50".
  • row_class (:string) - Classes for each tbody row. Defaults to "border-b border-gray-100 last:border-0".
  • row_hover_class (:string) - Hover classes added to rows when row_click is set. Defaults to "hover:bg-gray-50".

Slots

  • col - Accepts attributes:
    • label (:string)
    • sortable (:boolean)
    • field (:atom)
    • class (:string)
  • action - Accepts attributes:
    • label (:string)