Struct Autocomplete

Source
pub struct Autocomplete<A = ()> { /* private fields */ }
Expand description

Editable free-text field with a filtered suggestion popup.

Typing always updates the bound text signal. Activating an enabled suggestion replaces it with the suggestion label and invokes on_select; arbitrary text remains valid and need not match an item.

§Examples

use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::controls::Autocomplete;
let value = State::new(String::new());
let autocomplete: Autocomplete<()> = Autocomplete::new().bind(value).suggestion("Apple");
let _ = autocomplete;

Implementations§

Source§

impl<A: 'static> Autocomplete<A>

Source

pub fn new() -> Self

Creates an enabled, unbound autocomplete with no suggestions.

The placeholder is Type to search..., the popup starts closed, and an internal empty text signal is allocated when the component builds.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new();
let _ = autocomplete;
Source

pub fn bind(self, value: impl Into<Signal<String>>) -> Self

Binds the editable text to a writable signal.

Both free typing and suggestion activation update this signal.

§Examples
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().bind(State::new("ap".to_string()));
let _ = autocomplete;
Source

pub fn placeholder(self, placeholder: impl Into<Binding<String>>) -> Self

Replaces the static or reactive empty-text placeholder.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().placeholder("Find fruit...");
let _ = autocomplete;
Source

pub fn suggestion(self, label: impl Into<String>) -> Self

Appends an enabled, iconless suggestion.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().suggestion("Apple");
let _ = autocomplete;
Source

pub fn autocomplete_item(self, item: AutocompleteItem) -> Self

Appends a fully configured suggestion.

§Examples
use ailloli_ui_widgets::controls::{Autocomplete, AutocompleteItem};
let autocomplete: Autocomplete<()> = Autocomplete::new()
    .autocomplete_item(AutocompleteItem::new("Apple").disabled(true));
let _ = autocomplete;
Source

pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self

Sets the static or reactive whole-control disabled state.

Disabled autocomplete fields are not focusable, ignore events, and close an open popup during layout.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().disabled(true);
let _ = autocomplete;
Source

pub fn disabled_signal(self, disabled: Memo<bool>) -> Self

Uses a memo as the reactive whole-control disabled binding.

§Examples
use ailloli_ui_runtime::component::Memo;
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().disabled_signal(Memo::new(|| false));
let _ = autocomplete;
Source

pub fn default_open(self, open: bool) -> Self

Sets only the popup’s initial open state.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().default_open(true);
let _ = autocomplete;
Source

pub fn autocomplete_style(self, style: AutocompleteStyle) -> Self

Replaces the input and popup style without altering explicit layout values.

§Examples
use ailloli_ui_widgets::controls::{Autocomplete, AutocompleteStyle};
let autocomplete: Autocomplete<()> = Autocomplete::new()
    .autocomplete_style(AutocompleteStyle::default());
let _ = autocomplete;
Source

pub fn autocomplete_size(self, size: AutocompleteSize) -> Self

Re-derives the style from the default theme and requested density.

This overwrites every prior style customization.

§Examples
use ailloli_ui_widgets::controls::{Autocomplete, AutocompleteSize};
let autocomplete: Autocomplete<()> = Autocomplete::new()
    .autocomplete_size(AutocompleteSize::Compact);
let _ = autocomplete;
Source

pub fn on_select(self, f: impl Fn(String) -> A + 'static) -> Self

Dispatches the application action returned for an activated suggestion.

The exact label is written to the bound signal before this callback. Free typing does not invoke it.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<String> = Autocomplete::new().on_select(|label| label);
let _ = autocomplete;
Source

pub fn on_select_ctx( self, f: impl Fn(&mut EventCtx<A>, String) + 'static, ) -> Self

Handles an activated suggestion with direct event-context access.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new()
    .on_select_ctx(|_ctx, _label| {});
let _ = autocomplete;
Source

pub fn width(self, value: impl Into<Length>) -> Self

Sets the trigger layout width in logical pixels or another [Length].

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().width(260.0);
let _ = autocomplete;
Source

pub fn height(self, value: impl Into<Length>) -> Self

Sets the trigger layout height in logical pixels or another [Length].

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().height(40.0);
let _ = autocomplete;
Source

pub fn fill_width(self) -> Self

Makes the trigger fill its available horizontal layout space.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().fill_width();
let _ = autocomplete;
Source

pub fn flex_grow(self) -> Self

Sets the flex-grow factor to 1.0 without changing layout width.

§Examples
use ailloli_ui_widgets::controls::Autocomplete;
let autocomplete: Autocomplete<()> = Autocomplete::new().flex_grow();
let _ = autocomplete;

Trait Implementations§

Source§

impl<A: 'static> Default for Autocomplete<A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A: 'static> IntoView<A> for Autocomplete<A>

Source§

fn into_view(self) -> View<A>

Converts configuration into a sized reactive component view.

Source§

impl<A: 'static> LayoutExt for Autocomplete<A>

Source§

fn layout_mut(&mut self) -> &mut LayoutStyle

Returns the widget’s mutable declarative size/inset state. Read more

Auto Trait Implementations§

§

impl<A> Freeze for Autocomplete<A>

§

impl<A = ()> !RefUnwindSafe for Autocomplete<A>

§

impl<A = ()> !Send for Autocomplete<A>

§

impl<A = ()> !Sync for Autocomplete<A>

§

impl<A> Unpin for Autocomplete<A>

§

impl<A = ()> !UnwindSafe for Autocomplete<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, A> FlexItemExt<A> for T
where T: IntoView<A>,

Source§

fn flex_grow(self) -> View<A>

Sets flex-grow weight to one. Read more
Source§

fn flex_grow_by(self, value: f32) -> View<A>

Sets the dimensionless flex-grow weight. Read more
Source§

fn flex_shrink(self, value: f32) -> View<A>

Sets the dimensionless flex-shrink weight. Read more
Source§

fn flex_basis(self, value: impl Into<Length>) -> View<A>

Sets the preferred main-axis flex basis. Read more
Source§

fn align_self(self, value: AlignItems) -> View<A>

Overrides the parent cross-axis alignment for this view. Read more
Source§

fn fill_width(self) -> View<A>

Marks width as parent-fill in the view size hint. Read more
Source§

fn fill_height(self) -> View<A>

Marks height as parent-fill in the view size hint. Read more
Source§

fn fill(self) -> View<A>

Marks both axes as parent-fill in the view size hint. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, A> IntoViewKeyExt<A> for T
where T: IntoView<A>,

§

fn key(self, key: impl Into<String>) -> View<A>

Converts self, assigns the owned key, and returns the view. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,