StatifierBlocks.Editor.MapRegions (StatifierBlocks v0.39.0)

Copy Markdown View Source

The two function components a host mounts to show the Map beside its own list: map_region/1, where the StatifierBlocksMap hook draws the document, and description_region/1, which says in words what the selected block is, or what the document is when nothing is selected.

They live in the StatifierBlocks.Editor.* namespace because they name Phoenix, and that namespace is where ADR-0005 decision 1's compile guard lives. They are not part of the editor: neither reads or renders anything StatifierBlocks.Editor holds, and the editor draws no map (ADR-0018).

What the host brings

The components keep no state. A host passes four things, and each stays the host's:

The host'sWhat it is
view modelStatifierBlocks.ViewModel.build/3 of the document, which both regions read; the description region also takes the document and the palette it was built from
selectionthe block id its list has selected, or nil; the map marks that block's box and the description region describes it
event namesthe names its list already sends to select a block and to open an insert; a gesture on the map is sent under those names, with the payload the list sends for the same gesture
listthe list itself, which stays the keyboard and screen-reader path to every step

The map region

map_region/1 renders the element the hook is attached to, inside a region hidden from assistive technology (aria-hidden="true"): a reader of the host's list would otherwise meet every step twice. The element scrolls, and a browser makes a scroll box with nothing focusable in it a Tab stop of its own, so it carries tabindex="-1"; nothing else in the region takes focus.

The element carries what the hook reads, in the attributes it reads them from: the graph StatifierBlocks.Map.graph/2 answers as JSON in data-graph, with the selection marked in it; whether the page can edit in data-editable; the list's event names in data-select-event and data-insert-event; the element to scroll into view after an insert armed from the map in data-insert-reveal, when the host names one; and the description region's id and its store's in data-info-region and data-info-store, when the host names the region, which is what gives the map its hover. The drawing goes into a child marked data-map-canvas, which LiveView leaves alone (phx-update="ignore").

The description region

description_region/1 renders the region with aria-live="polite", so a selection made in the list is read out, under the id the host's list rows name with aria-describedby. Its content is rendered on the server: the selected block's StatifierBlocks.Map.Info description, or StatifierBlocks.Map.Info.idle/4 when nothing is selected. A block's author-written note leads, above the built-in text (ADR-0001's Amendment of 2026-09-28, clause 2g). It shows values and never controls.

Beside the region, and hidden, it renders the store the hook's hover reads: one child per element the map draws, data-describes naming the element's map id, holding the same markup the region shows for it. The store's id is the region's with -store after it, which is the id map_region/1 stamps when it is handed the region's.

Summary

Functions

The Map's description region and its hidden store; see the moduledoc.

The region the StatifierBlocksMap hook draws the Map into; see the moduledoc.

Functions

description_region(assigns)

@spec description_region(map()) :: Phoenix.LiveView.Rendered.t()

The Map's description region and its hidden store; see the moduledoc.

Attributes

  • id (:string) (required) - the region's id, which the host's list rows name with aria-describedby.
  • document (StatifierBlocks.Document) (required) - the document the view model was built from.
  • view_model (StatifierBlocks.ViewModel) (required)
  • palette (StatifierBlocks.Palette) (required) - the palette the view model was built with.
  • selected (:string) - the block id the host's list has selected. Defaults to nil.
  • phrase (:any) - the host's words for event names, the function map_region/1 takes. Defaults to nil.
  • class (:string) - a class of the host's, added to the region's own. Defaults to nil.

map_region(assigns)

@spec map_region(map()) :: Phoenix.LiveView.Rendered.t()

The region the StatifierBlocksMap hook draws the Map into; see the moduledoc.

Attributes

  • id (:string) (required) - the id of the element the hook is attached to.
  • view_model (StatifierBlocks.ViewModel) (required)
  • selected (:string) - the block id the host's list has selected. Defaults to nil.
  • select_event (:string) - the event the host's list sends to select a block. Defaults to nil.
  • insert_event (:string) - the event the host's list sends to open an insert. Defaults to nil.
  • editable (:boolean) - whether the map's gaps and markers arm inserts. Defaults to false.
  • phrase (:any) - the host's words for event names, as StatifierBlocks.Map.graph/2 takes them. Defaults to nil.
  • description (:string) - the id of the host's description_region/1, which gives the map its hover. Defaults to nil.
  • insert_reveal (:string) - a selector for what to scroll into view after an insert armed from the map. Defaults to nil.
  • class (:string) - a class of the host's, added to the region's own. Defaults to nil.