multi_select(
name:,
label:,
options:, # values or { value:, label:, sub:, status:, color: }
selected: nil, # nil = all
icon: nil,
all_label: "Todos",
none_label: "Nenhum",
many_label: "%{count} selecionados",
searchable: nil, # nil = more than 8 options
search_placeholder: "Buscar",
align: :left
)
Options are values or hashes (value, label, optional sub, status or color). It submits name[] with the checked values; selected: nil means all. The summary on the trigger follows the choice: all, none, the one name, or many_label with %{count}. Search appears by itself above 8 options.
It dispatches componeer--multi-select:change with the chosen values, so a form can submit itself: data-action="componeer--multi-select:change->filters#submit".
<div style="min-height: 330px">
<%= multi_select name: :projects, label: "Projetos", icon: "folder",
all_label: "Todos os projetos", none_label: "Nenhum projeto", many_label: "%{count} projetos",
selected: %w[exemplo canal],
searchable: true, search_placeholder: "Buscar projeto",
options: [
{ value: "exemplo", label: "Empresa Exemplo", sub: "3 missões abertas", color: "#4f46e5" },
{ value: "canal", label: "Canal Exemplo", sub: "5 missões abertas", color: "#0d9488" },
{ value: "cliente", label: "Cliente Fictício", sub: "1 missão aberta", color: "#0284c7" },
{ value: "interno", label: "Projeto Interno", sub: "Nenhuma missão aberta", color: "#6b7280" }
] %>
</div>