mirror of
https://github.com/nunntom/elm-ui-select.git
synced 2024-11-23 05:22:34 +03:00
Add isMenuPlacementAbove
This commit is contained in:
parent
d41d32094f
commit
6819870bb8
@ -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
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user