Add isMenuPlacementAbove

This commit is contained in:
Tom Nunn 2022-07-01 15:44:28 +02:00
parent d41d32094f
commit 6819870bb8
2 changed files with 35 additions and 26 deletions

View File

@ -161,30 +161,6 @@ toOptionState (Model { highlighted, selected }) ( idx, a ) =
Idle
-- CHECKS
isOpen : Model a -> Bool
isOpen (Model { menuOpen }) =
menuOpen
isFocused : Model a -> Bool
isFocused (Model { focused }) =
focused
isLoading : Model a -> Bool
isLoading (Model { requestState }) =
requestState == Just Loading
isRequestFailed : Model a -> Bool
isRequestFailed (Model { requestState }) =
requestState == Just Failed
toMenuPlacement : Maybe Placement -> Model a -> Placement
toMenuPlacement forcedPlacement (Model model) =
Maybe.map2 (calculateMenuDimensionsAndPlacement forcedPlacement) model.containerElement model.menuElement
@ -210,6 +186,30 @@ toContainerElement (Model { containerElement }) =
-- CHECKS
isOpen : Model a -> Bool
isOpen (Model { menuOpen }) =
menuOpen
isFocused : Model a -> Bool
isFocused (Model { focused }) =
focused
isLoading : Model a -> Bool
isLoading (Model { requestState }) =
requestState == Just Loading
isRequestFailed : Model a -> Bool
isRequestFailed (Model { requestState }) =
requestState == Just Failed
-- UPDATE

View File

@ -2,7 +2,7 @@ module Select exposing
( Select, init
, setItems, setSelected, setInputValue, closeMenu
, toValue, toInputValue
, isMenuOpen, isLoading, isRequestFailed
, isMenuOpen, isLoading, isRequestFailed, isMenuPlacementAbove
, Msg, update, updateWithRequest, Request, request, gotRequestResponse
, ViewConfig, view, withMenuAttributes, withMenuMaxHeight, withMenuMaxWidth, withNoMatchElement, OptionState, withOptionElement, ClearButton, withClearButton, clearButton, withFilter, withMenuAlwaysAbove, withMenuAlwaysBelow, withMenuPositionFixed
, toElement
@ -29,7 +29,7 @@ module Select exposing
# Check
@docs isMenuOpen, isLoading, isRequestFailed
@docs isMenuOpen, isLoading, isRequestFailed, isMenuPlacementAbove
# Update and Requests
@ -154,6 +154,15 @@ isRequestFailed =
Model.isRequestFailed
{-| Will the menu appear above the input as opposed to below?
Note: This does not take into account overriding placement with
[Select.withMenuAlwaysAbove](#withMenuAlwaysAbove) or [Select.withMenuAlwaysBelow](#withMenuAlwaysAbove).
-}
isMenuPlacementAbove : Select a -> Bool
isMenuPlacementAbove =
Model.toMenuPlacement Nothing >> (==) Above
-- UPDATE