Skip to content
docsv0.1.0

AutocompleteComponent

Live autocomplete primitive: a search box backed by an injectable {@see DataSourceRegistryInterface}, with `search`/`select`/`remove`/`clear` actions and optional single- or multi-select state. Render-target-agnostic like every component here — this class only owns {@see contract()}, {@see mount()}, and {@see handle()}; turning its state into markup/TUI is a {@see \Milpa\Live\Contracts\Rendering\ComponentRendererInterface}'s job.

AutocompleteComponent::__construct()

public function __construct(Milpa\Live\Contracts\Data\DataSourceRegistryInterface $dataSources, ?Milpa\Interfaces\Event\MilpaEventDispatcherInterface $dispatcher = null):

Parameters

Parameters of __construct()
NameTypeDescription
$dataSourcesMilpa\Live\Contracts\Data\DataSourceRegistryInterface
$dispatcher?Milpa\Interfaces\Event\MilpaEventDispatcherInterface

AutocompleteComponent::contract()

public static function contract(): Milpa\Live\ValueObjects\ComponentContract

The autocomplete's runtime contract: props/state schema plus its four declared actions (`search`, `select`, `remove`, `clear`).

AutocompleteComponent::mount()

public function mount(array $props, Milpa\Live\ValueObjects\ComponentContext $context): Milpa\Live\ValueObjects\StateSnapshot

Builds the initial state from `source`/`query`/`selected`/`limit`/ `multiple` props; requires a non-empty `source` prop.

Parameters

Parameters of mount()
NameTypeDescription
$propsarray
$contextMilpa\Live\ValueObjects\ComponentContext

Throws

\InvalidArgumentException If `source` is missing or empty.

AutocompleteComponent::handle()

public function handle(Milpa\Live\ValueObjects\InteractionRequest $request): Milpa\Live\ValueObjects\InteractionResult

Dispatches to `search`/`select`/`remove`/`clear`; an unrecognized action is reported via {@see InteractionResult::$errors} rather than thrown, per {@see ComponentDefinitionInterface::handle()}'s contract.

Parameters

Parameters of handle()
NameTypeDescription
$requestMilpa\Live\ValueObjects\InteractionRequest