Skip to content

Commit ce39ac9

Browse files
committed
loosen renderSearchDropdown from Maybe to any Foldable
We need a multi-select version of `renderToolbarSearchDropdown` which returns `Array` instead of `Maybe`. `renderToolbarSearchDropdown` depends on `renderSearchDropdown` so we start from here.
1 parent 1b24b28 commit ce39ac9

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/Typeahead.purs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ import Data.Foldable as Data.Foldable
6868
import Data.Fuzzy as Data.Fuzzy
6969
import Data.Maybe (Maybe(..))
7070
import Data.Maybe as Data.Maybe
71-
import Data.Newtype as Data.Newtype
7271
import Data.Rational ((%))
7372
import Data.String as Data.String
7473
import Data.Time.Duration as Data.Time.Duration
@@ -914,12 +913,13 @@ renderMultiInput input renderContainer st =
914913
]
915914

916915
renderSearchDropdown
917-
:: action item m
916+
:: action f item m
918917
. Eq item
918+
=> Data.Foldable.Foldable f
919919
=> String
920920
-> Halogen.HTML.PlainHTML
921921
-> (Data.Fuzzy.Fuzzy item -> Halogen.HTML.PlainHTML)
922-
-> CompositeComponentRender action Maybe item m
922+
-> CompositeComponentRender action f item m
923923
renderSearchDropdown resetLabel label renderFuzzy st =
924924
Halogen.HTML.label
925925
[ Ocelot.HTML.Properties.css "relative" ]
@@ -934,12 +934,14 @@ renderSearchDropdown resetLabel label renderFuzzy st =
934934
[ Ocelot.Block.ItemContainer.dropdownContainer
935935
[ renderInput, renderReset ]
936936
renderFuzzy
937-
((==) st.selected <<< Just <<< _.original <<< Data.Newtype.unwrap)
937+
isSelected
938938
st.fuzzyItems
939939
st.highlightedIndex
940940
]
941941
]
942942
where
943+
isSelected :: Data.Fuzzy.Fuzzy item -> Boolean
944+
isSelected (Data.Fuzzy.Fuzzy { original }) = Data.Foldable.elem original st.selected
943945
renderInput =
944946
Halogen.HTML.div
945947
[ Ocelot.HTML.Properties.css "m-4 border-b-2 border-blue-88 pb-2 flex" ]
@@ -954,7 +956,7 @@ renderSearchDropdown resetLabel label renderFuzzy st =
954956
[ Halogen.HTML.Events.onClick \_ -> Select.Action $ RemoveAll
955957
]
956958
[ Halogen.HTML.text resetLabel ]
957-
( Data.Maybe.isNothing st.selected )
959+
( Data.Foldable.null st.selected )
958960
false
959961

960962
renderSingle

0 commit comments

Comments
 (0)