@@ -152,84 +152,82 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
152152 . (br_ mempty : )
153153 )
154154 (optsLabel opts)
155- ( ( if typ == FieldTypeImage
156- then do
157- src <-
158- maybeToList
159- $ st
160- ^? cloneTraversal optic
161- . # fieldInput
162- . # uniqueValue
163- if null src
155+ ( [ input_
156+ $ ( catMaybes
157+ [ Just . type_ $ htmlFieldType typ,
158+ fmap required_
159+ $ st
160+ ^? cloneTraversal optic
161+ . # fieldRequired,
162+ fmap
163+ (textProp " defaultValue" )
164+ ( st
165+ ^? cloneTraversal
166+ optic
167+ . # fieldInput
168+ . # uniqueValue
169+ ),
170+ Just
171+ $ onInput onInputAction,
172+ Just
173+ . disabled_
174+ $ opts
175+ ^. # optsDisabled,
176+ fmap placeholder_
177+ $ if null placeholder
178+ then optsLabel opts
179+ else Just placeholder,
180+ Just
181+ . id_
182+ . either impureThrow id
183+ . decodeUtf8Strict
184+ . unTagged
185+ $ htmlUid uid,
186+ Just
187+ . onKeyDown
188+ $ action
189+ . optsOnKeyDownAction opts uid,
190+ Just
191+ $ onBlur onBlurAction
192+ ]
193+ )
194+ <> ( opts ^. # optsExtraAttributes
195+ )
196+ ]
197+ <> ( if typ /= FieldTypeImage
164198 then mempty
165- else
199+ else do
200+ src <-
201+ maybeToList
202+ $ st
203+ ^? cloneTraversal optic
204+ . # fieldInput
205+ . # uniqueValue
166206 [ input_
167207 $ catMaybes
168208 [ Just $ type_ " file" ,
169209 Just $ accept_ " image/*" ,
170210 Just $ onInput onInputFileAction,
171211 Just
172212 . id_
173- . either impureThrow id
213+ . either impureThrow ( " file- " <> )
174214 . decodeUtf8Strict
175215 . unTagged
176- $ htmlUid uid,
177- fmap required_
178- $ st
179- ^? cloneTraversal optic
180- . # fieldRequired
181- ],
182- img_
183- ( loading_ " lazy"
184- : src_ src
185- : optsExtraAttributes opts
186- ),
187- br_ mempty
188- ]
189- else
190- singleton
191- . input_
192- $ ( catMaybes
193- [ Just . type_ $ htmlFieldType typ,
194- fmap required_
195- $ st
196- ^? cloneTraversal optic
197- . # fieldRequired,
198- fmap
199- (textProp " defaultValue" )
200- ( st
201- ^? cloneTraversal
202- optic
203- . # fieldInput
204- . # uniqueValue
205- ),
206- Just
207- $ onInput onInputAction,
208- Just
209- . disabled_
210- $ opts
211- ^. # optsDisabled,
212- fmap placeholder_
213- $ if null placeholder
214- then optsLabel opts
215- else Just placeholder,
216- Just
217- . id_
218- . either impureThrow id
219- . decodeUtf8Strict
220- . unTagged
221- $ htmlUid uid,
222- Just
223- . onKeyDown
224- $ action
225- . optsOnKeyDownAction opts uid,
226- Just
227- $ onBlur onBlurAction
228- ]
229- )
230- <> ( opts ^. # optsExtraAttributes
231- )
232- )
216+ $ htmlUid uid
217+ ]
218+ ]
219+ <> ( if null src
220+ then mempty
221+ else
222+ [ img_
223+ ( loading_ " lazy"
224+ : src_ src
225+ : optsExtraAttributes opts
226+ ),
227+ br_ mempty
228+ ]
229+ )
230+ )
233231 --
234232 -- TODO : with new semantic layout separate leading/trailing
235233 -- widgets do not make a lot of sense, should be a single option
@@ -310,7 +308,7 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
310308 const . fromMaybe action (optsOnInputAction opts) . ImpureUpdate $ do
311309 el <-
312310 getElementById
313- . either impureThrow id
311+ . either impureThrow ( " file- " <> )
314312 . decodeUtf8Strict
315313 . unTagged
316314 $ htmlUid uid
0 commit comments