Merge pull request #1055 from NoRedInk/country-name-autocomplete

A11-1340 add `"country-name"` autocomplete to TextInput
This commit is contained in:
Charbel 2022-08-30 14:46:50 -03:00 committed by GitHub
commit f5cee17e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 2 deletions

View File

@ -1,6 +1,6 @@
module Nri.Ui.TextInput.V7 exposing
( view, generateId
, number, float, text, newPassword, currentPassword, email, search, addressLevel2, addressLine1, familyName, givenName, organization, organizationTitle, postalCode, sex, tel
, number, float, text, newPassword, currentPassword, email, search, addressLevel2, addressLine1, countryName, familyName, givenName, organization, organizationTitle, postalCode, sex, tel
, readOnlyText
, value, map
, onFocus, onBlur, onEnter
@ -27,7 +27,7 @@ module Nri.Ui.TextInput.V7 exposing
### Input types
@docs number, float, text, newPassword, currentPassword, email, search, addressLevel2, addressLine1, familyName, givenName, organization, organizationTitle, postalCode, sex, tel
@docs number, float, text, newPassword, currentPassword, email, search, addressLevel2, addressLine1, countryName, familyName, givenName, organization, organizationTitle, postalCode, sex, tel
@docs readOnlyText
@ -383,6 +383,25 @@ addressLevel2 onInput_ =
)
{-| An input that allows country-name entry
-}
countryName : (String -> msg) -> Attribute String msg
countryName onInput_ =
Attribute
{ emptyEventsAndValues
| toString = Just identity
, fromString = Just identity
, onInput = Just (identity >> onInput_)
}
(\config ->
{ config
| fieldType = Just "text"
, inputMode = Nothing
, autocomplete = Just "country-name"
}
)
{-| An input that allows postal-code entry
-}
postalCode : (String -> msg) -> Attribute String msg

View File

@ -282,6 +282,16 @@ customizableExamples state =
, onBlur = "Blurred!!!"
, onEnter = "Entered!!!"
}
, toExample
{ name = "countryName"
, toString = identity
, inputType = TextInput.countryName
, inputTypeCode = "TextInput.countryName"
, inputTypeValueCode = \value -> Code.string (Maybe.withDefault "" value)
, onFocus = "Focused!!!"
, onBlur = "Blurred!!!"
, onEnter = "Entered!!!"
}
, toExample
{ name = "postalCode"
, toString = identity