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
| Name | Type | Description |
|---|---|---|
| $dataSources | Milpa\Live\Contracts\Data\DataSourceRegistryInterface | |
| $dispatcher | ?Milpa\Interfaces\Event\MilpaEventDispatcherInterface |
AutocompleteComponent::contract()
public static function contract(): Milpa\Live\ValueObjects\ComponentContractThe 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\StateSnapshotBuilds the initial state from `source`/`query`/`selected`/`limit`/ `multiple` props; requires a non-empty `source` prop.
Parameters
| Name | Type | Description |
|---|---|---|
| $props | array | |
| $context | Milpa\Live\ValueObjects\ComponentContext |
Throws
\InvalidArgumentException If `source` is missing or empty.
AutocompleteComponent::handle()
public function handle(Milpa\Live\ValueObjects\InteractionRequest $request): Milpa\Live\ValueObjects\InteractionResultDispatches to `search`/`select`/`remove`/`clear`; an unrecognized action is reported via {@see InteractionResult::$errors} rather than thrown, per {@see ComponentDefinitionInterface::handle()}'s contract.
Parameters
| Name | Type | Description |
|---|---|---|
| $request | Milpa\Live\ValueObjects\InteractionRequest |