MishkaGervaz.Table.Entities.Notice (MishkaGervaz v0.0.1-alpha.3)

Copy Markdown View Source

Entity struct for static table notices (alerts/banners).

Mirrors MishkaGervaz.Form.Entities.Notice but with table-specific positions and bind_to atoms.

Positions

Atoms:

  • :table_top - above everything in the table region
  • :before_header / :after_header - around the table header
  • :before_filters / :after_filters - around the filters bar
  • :before_bulk_actions / :after_bulk_actions - around the bulk action bar
  • :before_table / :after_table - around the <table> element itself
  • :before_pagination / :after_pagination - around the pagination row
  • :table_bottom - last possible slot inside the table region
  • :empty_state - rendered only when the stream is empty

Tuples:

  • {:before_column, :col_name} / {:after_column, :col_name} - decorate a specific column header cell

Bind to (dynamic activation)

  • :no_results - active when the stream is empty after a load
  • :has_filters - active when any filter has a non-empty value
  • :has_selection - active when any row is selected
  • :loading - active when the table is in :loading state
  • :error - active when the load returned an error
  • :archived_view - active when viewing archived records
  • nil - no auto-binding; controlled solely by visible/show_when

Example

layout do
  notice :archived_warning do
    position :before_table
    type :warning
    icon "hero-archive-box"
    title "Viewing archived records"
    bind_to :archived_view
  end

  notice :no_match do
    position :empty_state
    type :info
    title "No records match your filters"
    bind_to :no_results
  end
end

See MishkaGervaz.Table.Dsl.Layout, MishkaGervaz.Table.Entities.Notice.Ui, MishkaGervaz.Table.Entities.Header / MishkaGervaz.Table.Entities.Footer (sibling chrome), and the form-side counterpart MishkaGervaz.Form.Entities.Notice.

Summary

Functions

Validate a position value. Returns :ok or {:error, reason}.

Types

position()

@type position() ::
  :table_top
  | :before_header
  | :after_header
  | :before_filters
  | :after_filters
  | :before_bulk_actions
  | :after_bulk_actions
  | :before_table
  | :after_table
  | :before_pagination
  | :after_pagination
  | :table_bottom
  | :empty_state
  | {:before_column, atom()}
  | {:after_column, atom()}

t()

@type t() :: %MishkaGervaz.Table.Entities.Notice{
  __identifier__: atom() | nil,
  __spark_metadata__: map() | nil,
  bind_to:
    :no_results
    | :has_filters
    | :has_selection
    | :loading
    | :error
    | :archived_view
    | nil,
  content: String.t() | (-> String.t()) | (map() -> String.t()) | nil,
  dismissible: boolean(),
  icon: String.t() | nil,
  name: atom(),
  position: position(),
  render:
    (map() -> Phoenix.LiveView.Rendered.t())
    | (map(), map() -> Phoenix.LiveView.Rendered.t())
    | nil,
  restricted: boolean() | (map() -> boolean()),
  show_when: (map() -> boolean()) | nil,
  title: String.t() | (-> String.t()) | (map() -> String.t()) | nil,
  type: :info | :warning | :error | :success | :neutral,
  ui: MishkaGervaz.Table.Entities.Notice.Ui.t() | nil,
  visible: boolean() | (map() -> boolean())
}

Functions

transform(notice)

validate_position(pos)

Validate a position value. Returns :ok or {:error, reason}.