@@ -44,9 +44,10 @@ data Full model action t f = Full
44
44
}
45
45
deriving stock (Generic )
46
46
47
- data Opts model action = Opts
47
+ data Opts model action t f = Opts
48
48
{ optsIcon :: Icon. Icon -> View action ,
49
49
optsLabel :: Maybe Unicode ,
50
+ optsOnFocus :: Field t f -> Update model -> Update model ,
50
51
optsFullWidth :: Bool ,
51
52
optsPlaceholder :: Unicode ,
52
53
optsOnInputAction :: Maybe (Update model -> action ),
@@ -63,11 +64,12 @@ data Opts model action = Opts
63
64
}
64
65
deriving stock (Generic )
65
66
66
- defOpts :: Opts model action
67
+ defOpts :: Opts model action t f
67
68
defOpts =
68
69
Opts
69
70
{ optsIcon = Icon. icon @ Icon. Fa ,
70
71
optsLabel = Nothing ,
72
+ optsOnFocus = const id ,
71
73
optsFullWidth = False ,
72
74
optsPlaceholder = mempty ,
73
75
optsOnInputAction = Nothing ,
@@ -155,7 +157,7 @@ labeled label attrs =
155
157
156
158
field ::
157
159
Full model action t Unique ->
158
- Opts model action ->
160
+ Opts model action t Unique ->
159
161
[View action ]
160
162
field full@ Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts =
161
163
( do
@@ -318,6 +320,8 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
318
320
.~ Blurred
319
321
onFocusAction =
320
322
action
323
+ . ( maybe id (optsOnFocus opts) $ st ^? cloneTraversal optic
324
+ )
321
325
. PureUpdate
322
326
$ cloneTraversal optic
323
327
. # fieldFocusState
@@ -370,7 +374,7 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
370
374
371
375
ratioField ::
372
376
Args model action Rational Unique ->
373
- Opts model action ->
377
+ Opts model action Rational Unique ->
374
378
[View action ]
375
379
ratioField args =
376
380
field
@@ -382,7 +386,7 @@ ratioField args =
382
386
383
387
textField ::
384
388
Args model action Unicode Unique ->
385
- Opts model action ->
389
+ Opts model action Unicode Unique ->
386
390
[View action ]
387
391
textField args =
388
392
field
@@ -394,7 +398,7 @@ textField args =
394
398
395
399
dynamicField ::
396
400
Args model action DynamicField Unique ->
397
- Opts model action ->
401
+ Opts model action DynamicField Unique ->
398
402
[View action ]
399
403
dynamicField args =
400
404
field
@@ -406,7 +410,7 @@ dynamicField args =
406
410
407
411
passwordField ::
408
412
Args model action Unicode Unique ->
409
- Opts model action ->
413
+ Opts model action Unicode Unique ->
410
414
[View action ]
411
415
passwordField args opts =
412
416
textField
@@ -423,7 +427,7 @@ passwordField args opts =
423
427
424
428
fieldIcon ::
425
429
Full model action t Unique ->
426
- Opts model action ->
430
+ Opts model action t Unique ->
427
431
OptsWidget model action ->
428
432
View action
429
433
fieldIcon full opts = \ case
@@ -532,7 +536,7 @@ fieldIcon full opts = \case
532
536
. # uniqueUid
533
537
534
538
fieldIconSimple ::
535
- Opts model action ->
539
+ Opts model action t f ->
536
540
Icon. Icon ->
537
541
[Attribute action ] ->
538
542
action ->
@@ -673,7 +677,7 @@ selectTypeWidget args@Args {argsAction = action} optic =
673
677
fieldViewer ::
674
678
( Foldable1 f
675
679
) =>
676
- Opts model action ->
680
+ Opts model action t f ->
677
681
Args model action t f ->
678
682
[View action ]
679
683
fieldViewer opts args =
@@ -729,7 +733,7 @@ header txt =
729
733
genericFieldViewer ::
730
734
( Foldable1 f
731
735
) =>
732
- Opts model action ->
736
+ Opts model action t f ->
733
737
Args model action t f ->
734
738
(Unicode -> View action ) ->
735
739
[View action ]
@@ -828,7 +832,7 @@ genericFieldViewer opts0 args widget =
828
832
]
829
833
)
830
834
831
- fieldViewerIcon :: Opts model action -> Icon. Icon -> action -> View action
835
+ fieldViewerIcon :: Opts model action t f -> Icon. Icon -> action -> View action
832
836
fieldViewerIcon opts icon action =
833
837
button_
834
838
[onClick action]
0 commit comments