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

Configuration


type TextArea model msg

Represent the opaque TextArea configuration.

Configuration Methods

textArea : (model -> Maybe String) -> (String -> msg) -> TextArea model msg

Create an textarea.

Rendering

render : model -> TextArea model msg -> List (Html msg)

Renders the TextArea.

import Html
import Prima.Pyxis.Form.TextArea as TextArea
import Prima.Pyxis.Form.Validation as Validation

...

type Msg =
    OnInput String

type alias Model =
    { note: Maybe String }

...

view : Html Msg
view =
    Html.div
        []
        (TextArea.textArea .note OnInput
            |> Input.withClass "my-custom-class"
            |> Input.withValidation (Maybe.andThen validate << .note)
        )

validate : String -> Validation.Type
validate str =
    if String.isEmpty str then
        Just <| Validation.ErrorWithMessage "Note is empty".
    else
        Nothing

Options

withAttribute : Html.Attribute msg -> TextArea model msg -> TextArea model msg

Adds a generic Html.Attribute to the TextArea.

withClass : String -> TextArea model msg -> TextArea model msg

Adds a class to the TextArea.

withDefaultValue : Maybe String -> TextArea model msg -> TextArea model msg

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

withDisabled : Basics.Bool -> TextArea model msg -> TextArea model msg

Adds a disabled Html.Attribute to the TextArea.

withId : String -> TextArea model msg -> TextArea model msg

Adds an id Html.Attribute to the TextArea.

withMediumSize : TextArea model msg -> TextArea model msg

Adds a size of Medium to the TextArea.

withSmallSize : TextArea model msg -> TextArea model msg

Sets a size of Small to the TextArea.

withLargeSize : TextArea model msg -> TextArea model msg

Adds a size of Large to the TextArea.

withName : String -> TextArea model msg -> TextArea model msg

Adds a name Html.Attribute to the TextArea.

withPlaceholder : String -> TextArea model msg -> TextArea model msg

Adds a placeholder Html.Attribute to the TextArea.

withIsSubmitted : (model -> Basics.Bool) -> TextArea model msg -> TextArea model msg

Adds an isSubmitted predicate to the TextArea.

Event Options

withOnBlur : msg -> TextArea model msg -> TextArea model msg

Attaches the onBlur event to the TextArea.

withOnFocus : msg -> TextArea model msg -> TextArea model msg

Attaches the onFocus event to the TextArea.

Validation

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

Adds a Validation rule to the TextArea.