primait/pyxis-components/9.0.1

NOTE: the latest version is 9.0.3

Prima.Pyxis.Form.Autocomplete

Configuration

type Autocomplete model

Represent the opaque Autocomplete configuration.

type State

The State of the Autocomplete

type Msg
= OnKeyPress (Maybe KeyCode)
| OnFilter
| OnSelect String
| OnReset
| OnInput String
| Debounce (Msg Msg)
| OpenMenu
| CloseMenu

Represents the Msg of the Autocomplete.

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

Represent the AutocompleteChoice configuration.

Configuration Methods

Creates an autocomplete.

Initializes the Autocomplete's State.

initWithDefault : String -> String -> State

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

update : Msg -> State -> ( State, 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.

Needed to wire keyboard events to the Autocomplete.

Show the available options for the autocomplete.

Hide the available options for the autocomplete.

isOpen : State -> Bool

Returns whether the menu is open or not.

Toggle the menu openness.

Reset selected value.

Options

withAttribute : 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 : 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 : 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.

Adds a size of Large to the Autocomplete.

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.

Adds a size of Small to the Autocomplete.

Set the threshold for the filter application.

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

Adds an isSubmitted predicate to the Autocomplete.

Event Options

Attaches the onBlur event to the Autocomplete.

Attaches the onFocus event to the Autocomplete.

Validation

withValidation : (model -> Maybe Type) -> Autocomplete model -> Autocomplete model

Adds a Validation rule to the Autocomplete.