StatifierBlocks.Editor.PaletteBrowser (StatifierBlocks v0.1.0)

Copy Markdown View Source

The grouped, searchable, filterable palette (ADR-0005 decisions 8, 10, 13).

Everything it renders comes from palette_entry/0 through StatifierBlocks.ViewModel, which already applied decision 10's defaults - label to the type name, group to "Other", description to "", icon to nil, keywords to [], order to 0. A block type that implements none of the callback still renders here, and ADR-0002 decision 5 promised it would.

Two filters compose, and they are different in kind:

  • Search is the author's, over label, description, type name and keywords. Purely presentational.
  • Acceptance is the slot's. When the palette was opened from a specific gap, allowed carries the type names that slot will take, computed by StatifierBlocks.Editor with the same predicate a drag uses - Edit.Targets.droppable_slots_for/3 against a probe block of each candidate type. Decision 8 is explicit that the filter uses the same predicate as decision 5, not a parallel implementation, and this component deliberately computes none of it: it is handed a set.

Picking an entry emits an :insert at exactly the position the "+" named, which is the identical command a successful drop would produce. That is what makes the whole insertion path exercisable in LiveViewTest without simulating a drag, and it is why decision 8 is not only an accessibility affordance - though it is that, drag-and-drop being unusable by keyboard and hostile on touch.

Summary

Functions

The groups a query and an acceptance set leave visible, with empty groups dropped. Pure, so the palette's filtering is asserted directly rather than through markup.

The palette: a search box, then a section per entry.group.

Functions

filter(groups, query, allowed)

The groups a query and an acceptance set leave visible, with empty groups dropped. Pure, so the palette's filtering is asserted directly rather than through markup.

palette_browser(assigns)

The palette: a search box, then a section per entry.group.

Attributes

  • groups (:list) (required)
  • query (:string) - Defaults to "".
  • allowed (:any) - MapSet of accepted type names, or nil for unfiltered. Defaults to nil.
  • target (:any) (required)
  • icon (:any) - Defaults to nil.
  • class (:string) - Defaults to nil.