MishkaGervaz.Table.Types.Column.Tags (MishkaGervaz v0.0.1-alpha.4)

Copy Markdown View Source

Renders a list value (e.g. {:array, :string}) as individual tag/badge chips.

Up to :max_items chips show inline (default 2); any extra collapse behind a +N chip that expands the rest in place and toggles back on a second click or a click outside. The chip/toggle markup lives in the UI adapter (MishkaGervaz.UIAdapters.Tailwind.cell_tags/1), so it is themeable and overridable per adapter — this type only prepares the data and delegates, exactly like MishkaGervaz.Table.Types.Column.Badge delegates to ui.badge/1.

The raw list is read straight from the record's source field, so it is unaffected by the table's display-string join of array values (get_cell_value/2) — that join would otherwise hand this type one space-joined string instead of a list, which is why the incoming value is ignored here.

Every element id is namespaced by both the column source field and the record id (gz-tags-<field>-<record_id>), so several :tags columns in the same row/table each toggle independently.

Options (via column.ui.extra)

  • :max_items — chips shown before collapsing into +N (default 2)
  • :badge_class — chip CSS class (defaults to the adapter's neutral pill)
  • :empty — text shown for an empty/nil list (default "—")

Usage

column :dependencies do
  ui do
    type :tags
  end
end

column :dependencies do
  ui do
    type :tags
    extra %{max_items: 3, badge_class: "rounded-full bg-blue-50 px-2 py-0.5 text-blue-700"}
  end
end

See MishkaGervaz.Table.Behaviours.ColumnType, MishkaGervaz.Table.Types.Column (the registry) and MishkaGervaz.UIAdapters.Tailwind (cell_tags/1).