primait / pyxis-components / Prima.Pyxis.Form.Autocomplete

Configuration


type Autocomplete model

Represent the opaque Autocomplete configuration.


type State

The State of the Autocomplete


type Msg
    = OnKeyPress (Maybe Prima.Pyxis.Form.Commons.KeyboardEvents.KeyCode)
    | OnFilter
    | OnSelect String
    | OnReset
    | OnInput String
    | Debounce (Debouncer.Basic.Msg Msg)
    | OpenMenu
    | CloseMenu

Represents the Msg of the Autocomplete.


type alias AutocompleteChoice =
{ value : String
, label : String 
}

Represent the AutocompleteChoice configuration.

Configuration Methods

autocomplete : Autocomplete model

Creates an autocomplete.

init : State

Initializes the Autocomplete's State.

initWithDefault : String -> String -> State

Initializes the Autocomplete's State with a default selected value.

update : Msg -> State -> ( State, Platform.Cmd.Cmd Msg, Maybe String )

Updates the Autocomplete's State.

autocompleteChoice : String -> String -> AutocompleteChoice

Create the AutocompleteChoice configuration.

updateChoices : List AutocompleteChoice -> State -> State

Update the AutocompleteChoice

Rendering

render : model -> State -> Autocomplete model -> List (Html Msg)

Renders the Autocomplete.

Methods

selectedValue : State -> Maybe String

Returns the current AutocompleteChoice.value selected by the user.

filterValue : State -> Maybe String

Returns the current filter inserted by the user.

subscription : State -> Platform.Sub.Sub Msg

Needed to wire keyboard events to the Autocomplete.

open : State -> State

Show the available options for the autocomplete.

close : State -> State

Hide the available options for the autocomplete.

isOpen : State -> Basics.Bool

Returns whether the menu is open or not.

toggle : State -> State

Toggle the menu openness.

reset : State -> State

Reset selected value.

Options

withAttribute : Html.Attribute Msg -> Autocomplete model -> Autocomplete model

Adds a generic Html.Attribute to the Autocomplete.

withClass : String -> Autocomplete model -> Autocomplete model

Adds a class to the Autocomplete.

withDebouncer : Basics.Float -> State -> State

Set the seconds for the debounce.

withDefaultValue : Maybe String -> Autocomplete model -> Autocomplete model

Adds a default value to the Input. Useful to teach the component about it's pristine/touched state.

withDisabled : Basics.Bool -> Autocomplete model -> Autocomplete model

Adds a disabled Html.Attribute to the Autocomplete.

withId : String -> Autocomplete model -> Autocomplete model

Adds an id Html.Attribute to the Autocomplete.

withLargeSize : Autocomplete model -> Autocomplete model

Adds a size of Large to the Autocomplete.

withMediumSize : Autocomplete model -> Autocomplete model

Adds a size of Medium to the Autocomplete.

withName : String -> Autocomplete model -> Autocomplete model

Adds a name Html.Attribute to the Autocomplete.

withOverridingClass : String -> Autocomplete model -> Autocomplete model

Adds a class to the Autocomplete which overrides all the previous.

withPlaceholder : String -> Autocomplete model -> Autocomplete model

Adds a placeholder Html.Attribute to the Autocomplete.

withSmallSize : Autocomplete model -> Autocomplete model

Adds a size of Small to the Autocomplete.

withThreshold : Basics.Int -> State -> State

Set the threshold for the filter application.

withIsSubmitted : (model -> Basics.Bool) -> Autocomplete model -> Autocomplete model

Adds an isSubmitted predicate to the Autocomplete.

Event Options

withOnBlur : Msg -> Autocomplete model -> Autocomplete model

Attaches the onBlur event to the Autocomplete.

withOnFocus : Msg -> Autocomplete model -> Autocomplete model

Attaches the onFocus event to the Autocomplete.

Validation

withValidation : (model -> Maybe Prima.Pyxis.Form.Validation.Type) -> Autocomplete model -> Autocomplete model

Adds a Validation rule to the Autocomplete.