A filter button that opens a menu of filters: one row per group that opens a second panel to
its side with the group's options as checkboxes (or radios), plus flat sections (a sort order)
in the same menu. Behaviour lives in the LedgerUI.FilterMenu hook
(priv/static/ledger_ui/hooks/filter_menu.js): opening, submenus, keyboard (arrows, Enter,
Esc, ArrowRight into a submenu) and staging never leave the browser.
<.form for={@form} phx-submit="apply_filters">
<.filter_menu id="orders-filter" label="Filtrar" locale="pt_BR" variant="outline" size="sm"
groups={[
%{name: "filter[status]", label: "Status", icon: "checkmark-circle-02",
value: @filter["status"],
options: [{"Faturado", "invoiced", 3}, {"Aprovado", "approved", 2}]},
%{name: "filter[sort]", label: "Ordenar por", caption: "Ordenar por",
display: :section, type: :single, value: @filter["sort"],
options: [{"Mais recentes", "recent"}, {"Maior valor", "value"}]}
]} />
</.form>Every option is a real input (filter[status][] for a multiple group, filter[sort] for a
single one), so a form posts them. In mode="apply" (default) ticks only stage: the group's
row shows how many are staged, Apply shows how many records they leave (the options' count,
or results), Clear unticks the filter groups and closing the menu any other way takes the
staged values back; the trigger shows how many values are applied (the groups' value).
mode="live" has no Apply: every tick reaches the form's phx-change and on_change.
on_change, on_apply and on_clear push %{"id" => id, "values" => %{group_name => [..] | "x"}}
to target. A :single group takes custom: true (or the row's text): a last row that
opens two date fields; the value is then "custom:FROM..TO" (ISO days), parsed by
custom_range/1. A :group slot takes the same attributes as a group and your own content
(any checkbox/radio inputs with a name, and data-lu-count for what Apply counts).