Module

Halogen.Widgets.Select

Package
purescript-halogen-widgets
Repository
afcondon/purescript-halogen-widgets

A controlled single-select dropdown, optionally typeahead-filtered, with three presentations of the same option data:

  • flat (defaultInput) — one un-headed list.
  • grouped (groupedInput) — named groups inline, non-selectable headers over indented leaves.
  • cascade (cascadingInput, cascade = true) — the same groups as a macOS-style fly-out menu: top-level family rows, each hovering/keying open a submenu to the side. Hover-intent, click/touch open, full keyboard navigation, and viewport-edge flip are all handled inside the widget.

Two kinds of state, deliberately split (see CONTRACT.md):

  • selected is CONTROLLED — it is app-meaningful, so the parent owns it and Selected requests a change.
  • open, query, and the cascade interaction state (hovered, leafFocus, flipLeft) are EPHEMERAL — the widget owns them and never surfaces them.

#Option Source

type Option = { label :: String, value :: String }

#OptionGroup Source

type OptionGroup = { label :: String, options :: Array Option }

A named group of options. The same data drives all three grouped presentations (see cascade): inline headers, or fly-out submenus.

#Input Source

type Input = { cascade :: Boolean, disabled :: Boolean, groups :: Array OptionGroup, options :: Array Option, placeholder :: String, searchable :: Boolean, selected :: Maybe String }

Two ways to supply options, and they coexist:

  • options — a flat, un-headed list (the original surface).
  • groups — named sections. When groups is non-empty the dropdown renders grouped; otherwise it falls back to the flat options. selected is still a single controlled value resolved across both sources.

cascade chooses the grouped presentation: false (default) is the inline grouped list; true is the fly-out submenu menu. No effect without groups.

#Output Source

data Output

Constructors

#Query Source

data Query a

Constructors

#component Source

#defaultInput Source

defaultInput :: Array Option -> Input

The flat on-ramp, unchanged: groups defaults to [], so every existing caller compiles and behaves exactly as before.

#groupedInput Source

groupedInput :: Array OptionGroup -> Input

The grouped on-ramp (inline list): named groups, headers over their leaves.

#cascadingInput Source

cascadingInput :: Array OptionGroup -> Input

The cascade on-ramp (fly-out submenus): named groups, each revealed as a side popup on hover/click/keyboard. Same controlled selected and Selected output as every other shape — only the panel interaction differs.