@@ -35,6 +35,9 @@ view model schema isRequired isDisabled path =
3535 isPassword =
3636 uiSpec. widgetType == Just PasswordField
3737
38+ isMultiline =
39+ uiSpec. widgetType == Just MultilineTextField
40+
3841 ( disabled, hidden ) =
3942 applyRule model. value path uiSpec. rule
4043
@@ -54,23 +57,8 @@ view model schema isRequired isDisabled path =
5457
5558 else
5659 text " "
57- in
58- div
59- [ classList
60- [ ( " jf-textfield" , True )
61- , ( " jf-textfield--outlined" , model. config. textFieldStyle == Outlined )
62- , ( " jf-textfield--dense" , model. config. dense )
63- , ( " jf-textfield--focused" , model. focused |> Maybe . map ( (==) path) |> Maybe . withDefault False )
64- , ( " jf-textfield--empty" , editedValue == " " )
65- , ( " jf-textfield--invalid" , hasError )
66- , ( " jf-textfield--disabled" , actuallyDisabled )
67- , ( " jf-textfield--hidden" , hidden )
68- ]
6960
70- -- , onFocus <| FocusTextInput path
71- -- , Html.Attributes.tabindex -1
72- ]
73- [ input
61+ baseAttributes =
7462 [ class " jf-textfield__input"
7563 , onFocus <| FocusInput ( Just path)
7664 , onBlur <| FocusInput Nothing
@@ -80,16 +68,47 @@ view model schema isRequired isDisabled path =
8068 , Html . Attributes . name id
8169 , Html . Attributes . autocomplete False
8270 , Html . Attributes . disabled actuallyDisabled
83- , if isPassword && not model. showPassword then
84- type_ " password"
71+ ]
72+
73+ textInput =
74+ if isMultiline then
75+ textarea baseAttributes []
8576
86- else
87- type_ " text"
77+ else
78+ input
79+ ( baseAttributes
80+ ++ [ if isPassword && not model. showPassword then
81+ type_ " password"
82+
83+ else
84+ type_ " text"
85+ ]
86+ )
87+ []
88+ in
89+ div
90+ [ classList [ ( " jf-element" , True ) , ( " jf-element--hidden" , hidden ) ]
91+ ]
92+ [ div
93+ [ classList
94+ [ ( " jf-textfield" , True )
95+ , ( " jf-textfield--outlined" , model. config. textFieldStyle == Outlined )
96+ , ( " jf-textfield--dense" , model. config. dense )
97+ , ( " jf-textfield--focused" , model. focused |> Maybe . map ( (==) path) |> Maybe . withDefault False )
98+ , ( " jf-textfield--empty" , editedValue == " " )
99+ , ( " jf-textfield--invalid" , hasError )
100+ , ( " jf-textfield--disabled" , actuallyDisabled )
101+ , ( " jf-textfield--multiline" , isMultiline )
102+ ]
103+
104+ -- , onFocus <| FocusTextInput path
105+ -- , Html.Attributes.tabindex -1
106+ ]
107+ [ textInput
108+ , icon
109+ , label [ class " jf-textfield__label" ] [ schema |> getTitle isRequired |> text ]
88110 ]
89- []
90- , icon
91- , label [ class " jf-textfield__label" ] [ schema |> getTitle isRequired |> text ]
92- , div [ class " jf-textfield__helper-text" ] [ helperText ]
111+ , div [ class " jf-helper-text" ] [ helperText ]
93112 ]
94113
95114
@@ -128,29 +147,33 @@ viewNumeric model schema isRequired isDisabled path =
128147 isDisabled || disabled
129148 in
130149 div
131- [ classList
132- [ ( " jf-textfield" , True )
133- , ( " jf-textfield--outlined" , model. config. textFieldStyle == Outlined )
134- , ( " jf-textfield--dense" , model. config. dense )
135- , ( " jf-textfield--focused" , isFocused )
136- , ( " jf-textfield--empty" , editedValue == " " )
137- , ( " jf-textfield--invalid" , hasError )
138- , ( " jf-textfield--disabled" , actuallyDisabled )
139- , ( " jf-textfield--hidden" , hidden )
140- ]
150+ [ classList [ ( " jf-element" , True ) , ( " jf-element--hidden" , hidden ) ]
141151 ]
142- [ input
143- [ class " jf-textfield__input"
144- , onFocus <| FocusNumericInput ( Just path)
145- , onBlur <| FocusNumericInput Nothing
146- , onInput <| EditNumber
147- , Html . Attributes . id id
148- , Html . Attributes . name id
149- , value <| editedValue
150- , type_ " number"
151- , Html . Attributes . disabled actuallyDisabled
152+ [ div
153+ [ classList
154+ [ ( " jf-textfield" , True )
155+ , ( " jf-textfield--outlined" , model. config. textFieldStyle == Outlined )
156+ , ( " jf-textfield--dense" , model. config. dense )
157+ , ( " jf-textfield--focused" , isFocused )
158+ , ( " jf-textfield--empty" , editedValue == " " )
159+ , ( " jf-textfield--invalid" , hasError )
160+ , ( " jf-textfield--disabled" , actuallyDisabled )
161+ , ( " jf-textfield--hidden" , hidden )
162+ ]
163+ ]
164+ [ input
165+ [ class " jf-textfield__input"
166+ , onFocus <| FocusNumericInput ( Just path)
167+ , onBlur <| FocusNumericInput Nothing
168+ , onInput <| EditNumber
169+ , Html . Attributes . id id
170+ , Html . Attributes . name id
171+ , value <| editedValue
172+ , type_ " number"
173+ , Html . Attributes . disabled actuallyDisabled
174+ ]
175+ []
176+ , label [ class " jf-textfield__label" ] [ schema |> getTitle isRequired |> text ]
152177 ]
153- []
154- , label [ class " jf-textfield__label" ] [ schema |> getTitle isRequired |> text ]
155- , div [ class " jf-textfield__helper-text" ] [ helperText ]
178+ , div [ class " jf-helper-text" ] [ helperText ]
156179 ]
0 commit comments