This module provides a component that combines a Select for country dialing codes
with an Input for entering a phone number.
It uses the builder pattern:
new to create a base input.withPlaceholder or withIsRequired.view to render it.Initialize the PhoneSelectInput model.
init : DashboardModel
init =
{ phoneSelectInputModel = AvardaUi.PhoneSelectInput.init "phone" }Msg type for the PhoneSelectInput component. Use this for the wrap msg in your own Msg type.
type DashboardMsg
= HandlePhoneSelectInput AvardaUi.PhoneSelectInput.Msg
| NoUpdateUpdate function for the PhoneSelectInput component. Call this in your update function to handle Select's internal messages
update : Model -> Msg -> ( Model, Cmd Msg )
update model msg =
case msg of
HandlePhoneSelectInput phoneSelectInputMsg ->
let
( updatedPhoneSelectInputModel, phoneSelectInputCmd ) =
AvardaUi.PhoneSelectInput.update
HandlePhoneSelectInput
phoneSelectInputMsg
model.phoneSelectInputModel
in
( { model | phoneSelectInputModel = updatedPhoneSelectInputModel }, phoneSelectInputCmd )Create a new PhoneSelectInput component.
AvardaUi.PhoneSelectInput.new
{ inputLabel = "Phone"
, selectAriaLabel = "Country code"
, phoneSelectInputModel = model.phoneSelectInputModel
}Render the PhoneSelectInput as HTML .
Always call this after you've built up the input with new and chained settings.
AvardaUi.PhoneSelectInput.new "phone" {...}
|> AvardaUi.PhoneSelectInput.withIsRequired True
|> AvardaUi.PhoneSelectInput.viewYou can pass extra options / callbacks to this component using updateWith
UpdateOption type
update : Model -> Msg -> ( Model, Cmd Msg )
update model msg =
case msg of
HandlePhoneSelectInput phoneSelectInputMsg ->
let
( updatedPhoneSelectInputModel, phoneSelectInputCmd ) =
AvardaUi.PhoneSelectInput.updateWith
[ AvardaUi.PhoneSelectInput.onSelect OnSelect
, AvardaUi.PhoneSelectInput.onInput OnInput
]
HandlePhoneSelectInput
phoneSelectInputMsg
model.phoneSelectInputModel
in
( { model | phoneSelectInputModel = updatedPhoneSelectInputModel }, selectCmd )Used for triggering a message when an CountryCode is selected.
Used for triggering a message when the phone input is typed into.
Used for triggering a message when Tab is pressed in the input.
Used to fix issue with scrolling option into view when used in ShadowDOM. elm/browser cannot find the element ID when this component is used by an app which uses ShadowDOM
type alias ScrollOptionIntoViewCmd msg =
String -> Cmd msgAdjust the border radius of the PhoneSelectInput.
Add a hint text below the PhoneSelectInput.
Limit the maximum number of characters.
Add a placeholder to the input.
Disable the PhoneSelectInput
Mark the PhoneSelectInput as required.
Show an error message and mark the PhoneSelectInput as invalid. Replaces any active hint text.
Set a maximum height for the dropdown menu.
Sets the background color of the floating input label.
This is useful when the color of the background behind the input is something else then #FFFFFF.
Set the available CountryCodes for country select. These country codes have to come from AvardaUi.Util.CountryCode.
Set the selected CountryCode. It has to come from AvardaUi.Util.CountryCode.
Set the phone input value.
Get the currently selected CountryCode.
If none is selected, returns Nothing.
Get the current value of the phone input.
Model type for the Select component. Use this in your own model.