-----------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
-----------------------------------------------------------------------------
-- |
-- Module      :  Miso.Native.X.Element.Overlay.Event
-- Copyright   :  (C) 2016-2026 David M. Johnson
-- License     :  BSD3-style (see the file LICENSE)
-- Maintainer  :  David M. Johnson <code@dmj.io>
-- Stability   :  experimental
-- Portability :  non-portable
----------------------------------------------------------------------------
module Miso.Native.X.Element.Overlay.Event
  ( -- *** Events
    onDismissOverlay
  , onDismissOverlayWith
  , onDismissOverlayMain
  , onDismissOverlayMainWith
  , onError
  , onErrorWith
  , onErrorMain
  , onErrorMainWith
  , onOverlayTouch
  , onOverlayTouchWith
  , onOverlayTouchMain
  , onOverlayTouchMainWith
  , onRequestClose
  , onRequestCloseWith
  , onRequestCloseMain
  , onRequestCloseMainWith
  , onShowOverlay
  , onShowOverlayWith
  , onShowOverlayMain
  , onShowOverlayMainWith
    -- *** Types
  , OverlayErrorEvent (..)
  , OverlayTouchEvent (..)
    -- *** Decoders
  , overlayErrorDecoder
  , overlayTouchDecoder
    -- *** Event Map
  , overlayEvents
  ) where
-----------------------------------------------------------------------------
import qualified Data.Map as M
-----------------------------------------------------------------------------
import           Miso.Event
import           Miso.JSON
import           Miso.String (MisoString)
import           Miso.Types (Attribute, EventHandler, DOMRef)
-----------------------------------------------------------------------------
overlayEvents :: Events
overlayEvents :: Events
overlayEvents
  = [(MisoString, Phase)] -> Events
forall k a. Ord k => [(k, a)] -> Map k a
M.fromList
  [ (MisoString
"dismissoverlay", Phase
BUBBLE)
  , (MisoString
"error", Phase
BUBBLE)
  , (MisoString
"overlaytouch", Phase
BUBBLE)
  , (MisoString
"requestclose", Phase
BUBBLE)
  , (MisoString
"showoverlay", Phase
BUBBLE)
  ]
-----------------------------------------------------------------------------
-- | Payload of the @binderror@ event.
data OverlayErrorEvent
  = OverlayErrorEvent
  { OverlayErrorEvent -> MisoString
errorCode :: MisoString
    -- ^ The error code
  , OverlayErrorEvent -> MisoString
errorMsg :: MisoString
    -- ^ The error message
  } deriving (Int -> OverlayErrorEvent -> ShowS
[OverlayErrorEvent] -> ShowS
OverlayErrorEvent -> String
(Int -> OverlayErrorEvent -> ShowS)
-> (OverlayErrorEvent -> String)
-> ([OverlayErrorEvent] -> ShowS)
-> Show OverlayErrorEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OverlayErrorEvent -> ShowS
showsPrec :: Int -> OverlayErrorEvent -> ShowS
$cshow :: OverlayErrorEvent -> String
show :: OverlayErrorEvent -> String
$cshowList :: [OverlayErrorEvent] -> ShowS
showList :: [OverlayErrorEvent] -> ShowS
Show, OverlayErrorEvent -> OverlayErrorEvent -> Bool
(OverlayErrorEvent -> OverlayErrorEvent -> Bool)
-> (OverlayErrorEvent -> OverlayErrorEvent -> Bool)
-> Eq OverlayErrorEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OverlayErrorEvent -> OverlayErrorEvent -> Bool
== :: OverlayErrorEvent -> OverlayErrorEvent -> Bool
$c/= :: OverlayErrorEvent -> OverlayErrorEvent -> Bool
/= :: OverlayErrorEvent -> OverlayErrorEvent -> Bool
Eq)
-----------------------------------------------------------------------------
-- | Payload of the @bindoverlaytouch@ event.
data OverlayTouchEvent
  = OverlayTouchEvent
  { OverlayTouchEvent -> MisoString
touchState :: MisoString
    -- ^ The @OverlayTouchState@
  , OverlayTouchEvent -> Double
touchX :: Double
    -- ^ The horizontal position of the touch
  , OverlayTouchEvent -> Double
touchY :: Double
    -- ^ The vertical position of the touch
  } deriving (Int -> OverlayTouchEvent -> ShowS
[OverlayTouchEvent] -> ShowS
OverlayTouchEvent -> String
(Int -> OverlayTouchEvent -> ShowS)
-> (OverlayTouchEvent -> String)
-> ([OverlayTouchEvent] -> ShowS)
-> Show OverlayTouchEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OverlayTouchEvent -> ShowS
showsPrec :: Int -> OverlayTouchEvent -> ShowS
$cshow :: OverlayTouchEvent -> String
show :: OverlayTouchEvent -> String
$cshowList :: [OverlayTouchEvent] -> ShowS
showList :: [OverlayTouchEvent] -> ShowS
Show, OverlayTouchEvent -> OverlayTouchEvent -> Bool
(OverlayTouchEvent -> OverlayTouchEvent -> Bool)
-> (OverlayTouchEvent -> OverlayTouchEvent -> Bool)
-> Eq OverlayTouchEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OverlayTouchEvent -> OverlayTouchEvent -> Bool
== :: OverlayTouchEvent -> OverlayTouchEvent -> Bool
$c/= :: OverlayTouchEvent -> OverlayTouchEvent -> Bool
/= :: OverlayTouchEvent -> OverlayTouchEvent -> Bool
Eq)
-----------------------------------------------------------------------------
overlayErrorDecoder :: Decoder OverlayErrorEvent
overlayErrorDecoder :: Decoder OverlayErrorEvent
overlayErrorDecoder = [MisoString
"detail"] [MisoString]
-> (Value -> Parser OverlayErrorEvent) -> Decoder OverlayErrorEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser OverlayErrorEvent
details
  where
    details :: Value -> Parser OverlayErrorEvent
details = MisoString
-> (Object -> Parser OverlayErrorEvent)
-> Value
-> Parser OverlayErrorEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser OverlayErrorEvent)
 -> Value -> Parser OverlayErrorEvent)
-> (Object -> Parser OverlayErrorEvent)
-> Value
-> Parser OverlayErrorEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
      MisoString -> MisoString -> OverlayErrorEvent
OverlayErrorEvent
        (MisoString -> MisoString -> OverlayErrorEvent)
-> Parser MisoString -> Parser (MisoString -> OverlayErrorEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"errorCode"
        Parser (MisoString -> OverlayErrorEvent)
-> Parser MisoString -> Parser OverlayErrorEvent
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"errorMsg"
-----------------------------------------------------------------------------
overlayTouchDecoder :: Decoder OverlayTouchEvent
overlayTouchDecoder :: Decoder OverlayTouchEvent
overlayTouchDecoder = [MisoString
"detail"] [MisoString]
-> (Value -> Parser OverlayTouchEvent) -> Decoder OverlayTouchEvent
forall a. [MisoString] -> (Value -> Parser a) -> Decoder a
`at` Value -> Parser OverlayTouchEvent
details
  where
    details :: Value -> Parser OverlayTouchEvent
details = MisoString
-> (Object -> Parser OverlayTouchEvent)
-> Value
-> Parser OverlayTouchEvent
forall a. MisoString -> (Object -> Parser a) -> Value -> Parser a
withObject MisoString
"detail" ((Object -> Parser OverlayTouchEvent)
 -> Value -> Parser OverlayTouchEvent)
-> (Object -> Parser OverlayTouchEvent)
-> Value
-> Parser OverlayTouchEvent
forall a b. (a -> b) -> a -> b
$ \Object
o ->
      MisoString -> Double -> Double -> OverlayTouchEvent
OverlayTouchEvent
        (MisoString -> Double -> Double -> OverlayTouchEvent)
-> Parser MisoString
-> Parser (Double -> Double -> OverlayTouchEvent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> MisoString -> Parser MisoString
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"state"
        Parser (Double -> Double -> OverlayTouchEvent)
-> Parser Double -> Parser (Double -> OverlayTouchEvent)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"x"
        Parser (Double -> OverlayTouchEvent)
-> Parser Double -> Parser OverlayTouchEvent
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> MisoString -> Parser Double
forall a. FromJSON a => Object -> MisoString -> Parser a
.: MisoString
"y"
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/overlay.html#binddismissoverlay
--
-- Triggered when the overlay is hidden.
--
onDismissOverlay :: action -> Attribute model action
onDismissOverlay :: forall action model. action -> Attribute model action
onDismissOverlay action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"dismissoverlay" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onDismissOverlay', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = Dismissed
--
-- view_ [ event (static (onDismissOverlayMain Dismissed)) ] [ "some view" ]
-- @
--
onDismissOverlayMain :: action -> EventHandler model action
onDismissOverlayMain :: forall action model. action -> EventHandler model action
onDismissOverlayMain action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"dismissoverlay" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onDismissOverlayMain', but the handler also receives read-only access
-- to the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = Dismissed Model DOMRef
--
-- view_ [ event (static (onDismissOverlayMainWith Dismissed)) ] [ "some view" ]
-- @
--
onDismissOverlayMainWith :: (model -> DOMRef -> action) -> EventHandler model action
onDismissOverlayMainWith :: forall model action.
(model -> DOMRef -> action) -> EventHandler model action
onDismissOverlayMainWith model -> DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"dismissoverlay" Decoder ()
emptyDecoder (\() model
m DOMRef
ref -> model -> DOMRef -> action
action model
m DOMRef
ref)
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/overlay.html#binderror
--
-- *Android 2.18+*. Triggered on an overlay error.
--
onError :: (OverlayErrorEvent -> action) -> Attribute model action
onError :: forall action model.
(OverlayErrorEvent -> action) -> Attribute model action
onError OverlayErrorEvent -> action
action = MisoString
-> Decoder OverlayErrorEvent
-> (OverlayErrorEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"error" Decoder OverlayErrorEvent
overlayErrorDecoder (\OverlayErrorEvent
e model
_ DOMRef
_ -> OverlayErrorEvent -> action
action OverlayErrorEvent
e)
-----------------------------------------------------------------------------
-- | Like 'onError', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = Errored OverlayErrorEvent
--
-- view_ [ event (static (onErrorMain Errored)) ] [ "some view" ]
-- @
--
onErrorMain :: (OverlayErrorEvent -> action) -> EventHandler model action
onErrorMain :: forall action model.
(OverlayErrorEvent -> action) -> EventHandler model action
onErrorMain OverlayErrorEvent -> action
action = MisoString
-> Decoder OverlayErrorEvent
-> (OverlayErrorEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"error" Decoder OverlayErrorEvent
overlayErrorDecoder (\OverlayErrorEvent
e model
_ DOMRef
_ -> OverlayErrorEvent -> action
action OverlayErrorEvent
e)
-----------------------------------------------------------------------------
-- | Like 'onErrorMain', but the handler also receives read-only access to the
-- @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = Errored OverlayErrorEvent Model DOMRef
--
-- view_ [ event (static (onErrorMainWith Errored)) ] [ "some view" ]
-- @
--
onErrorMainWith :: (OverlayErrorEvent -> model -> DOMRef -> action) -> EventHandler model action
onErrorMainWith :: forall model action.
(OverlayErrorEvent -> model -> DOMRef -> action)
-> EventHandler model action
onErrorMainWith OverlayErrorEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder OverlayErrorEvent
-> (OverlayErrorEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"error" Decoder OverlayErrorEvent
overlayErrorDecoder OverlayErrorEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/overlay.html#bindoverlaytouch
--
-- Triggered when the overlay is touched.
--
onOverlayTouch :: (OverlayTouchEvent -> action) -> Attribute model action
onOverlayTouch :: forall action model.
(OverlayTouchEvent -> action) -> Attribute model action
onOverlayTouch OverlayTouchEvent -> action
action = MisoString
-> Decoder OverlayTouchEvent
-> (OverlayTouchEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"overlaytouch" Decoder OverlayTouchEvent
overlayTouchDecoder (\OverlayTouchEvent
e model
_ DOMRef
_ -> OverlayTouchEvent -> action
action OverlayTouchEvent
e)
-----------------------------------------------------------------------------
-- | Like 'onOverlayTouch', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = Touched OverlayTouchEvent
--
-- view_ [ event (static (onOverlayTouchMain Touched)) ] [ "some view" ]
-- @
--
onOverlayTouchMain :: (OverlayTouchEvent -> action) -> EventHandler model action
onOverlayTouchMain :: forall action model.
(OverlayTouchEvent -> action) -> EventHandler model action
onOverlayTouchMain OverlayTouchEvent -> action
action = MisoString
-> Decoder OverlayTouchEvent
-> (OverlayTouchEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"overlaytouch" Decoder OverlayTouchEvent
overlayTouchDecoder (\OverlayTouchEvent
e model
_ DOMRef
_ -> OverlayTouchEvent -> action
action OverlayTouchEvent
e)
-----------------------------------------------------------------------------
-- | Like 'onOverlayTouchMain', but the handler also receives read-only access to
-- the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = Touched OverlayTouchEvent Model DOMRef
--
-- view_ [ event (static (onOverlayTouchMainWith Touched)) ] [ "some view" ]
-- @
--
onOverlayTouchMainWith :: (OverlayTouchEvent -> model -> DOMRef -> action) -> EventHandler model action
onOverlayTouchMainWith :: forall model action.
(OverlayTouchEvent -> model -> DOMRef -> action)
-> EventHandler model action
onOverlayTouchMainWith OverlayTouchEvent -> model -> DOMRef -> action
action = MisoString
-> Decoder OverlayTouchEvent
-> (OverlayTouchEvent -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"overlaytouch" Decoder OverlayTouchEvent
overlayTouchDecoder OverlayTouchEvent -> model -> DOMRef -> action
action
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/overlay.html#bindrequestclose
--
-- Triggered when the back button is clicked.
--
onRequestClose :: action -> Attribute model action
onRequestClose :: forall action model. action -> Attribute model action
onRequestClose action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"requestclose" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onRequestClose', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = RequestedClose
--
-- view_ [ event (static (onRequestCloseMain RequestedClose)) ] [ "some view" ]
-- @
--
onRequestCloseMain :: action -> EventHandler model action
onRequestCloseMain :: forall action model. action -> EventHandler model action
onRequestCloseMain action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"requestclose" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onRequestCloseMain', but the handler also receives read-only access to
-- the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = RequestedClose Model DOMRef
--
-- view_ [ event (static (onRequestCloseMainWith RequestedClose)) ] [ "some view" ]
-- @
--
onRequestCloseMainWith :: (model -> DOMRef -> action) -> EventHandler model action
onRequestCloseMainWith :: forall model action.
(model -> DOMRef -> action) -> EventHandler model action
onRequestCloseMainWith model -> DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"requestclose" Decoder ()
emptyDecoder (\() model
m DOMRef
ref -> model -> DOMRef -> action
action model
m DOMRef
ref)
-----------------------------------------------------------------------------
-- | https://lynxjs.org/api/elements/built-in/overlay.html#bindshowoverlay
--
-- Triggered when the overlay is displayed.
--
onShowOverlay :: action -> Attribute model action
onShowOverlay :: forall action model. action -> Attribute model action
onShowOverlay action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"showoverlay" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onShowOverlay', but dispatched on the Lynx __main thread__ ('MTS').
--
-- Runs imperatively on the MTS (no VDOM diff). Meant to be used with
-- @-XStaticPointers@.
--
-- @
-- data Action = Shown
--
-- view_ [ event (static (onShowOverlayMain Shown)) ] [ "some view" ]
-- @
--
onShowOverlayMain :: action -> EventHandler model action
onShowOverlayMain :: forall action model. action -> EventHandler model action
onShowOverlayMain action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"showoverlay" Decoder ()
emptyDecoder (\() model
_ DOMRef
_ -> action
action)
-----------------------------------------------------------------------------
-- | Like 'onShowOverlayMain', but the handler also receives read-only access to
-- the @model@ and the target element's 'DOMRef' (for imperative MTS mutation).
--
-- @
-- data Action = Shown Model DOMRef
--
-- view_ [ event (static (onShowOverlayMainWith Shown)) ] [ "some view" ]
-- @
--
onShowOverlayMainWith :: (model -> DOMRef -> action) -> EventHandler model action
onShowOverlayMainWith :: forall model action.
(model -> DOMRef -> action) -> EventHandler model action
onShowOverlayMainWith model -> DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> EventHandler model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> EventHandler model action
onMain MisoString
"showoverlay" Decoder ()
emptyDecoder (\() model
m DOMRef
ref -> model -> DOMRef -> action
action model
m DOMRef
ref)
-----------------------------------------------------------------------------
-- | Like 'onDismissOverlay', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onDismissOverlayWith :: (DOMRef -> action) -> Attribute model action
onDismissOverlayWith :: forall action model. (DOMRef -> action) -> Attribute model action
onDismissOverlayWith DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"dismissoverlay" Decoder ()
emptyDecoder (\() model
_ DOMRef
ref -> DOMRef -> action
action DOMRef
ref)
-----------------------------------------------------------------------------
-- | Like 'onError', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onErrorWith :: (OverlayErrorEvent -> DOMRef -> action) -> Attribute model action
onErrorWith :: forall action model.
(OverlayErrorEvent -> DOMRef -> action) -> Attribute model action
onErrorWith OverlayErrorEvent -> DOMRef -> action
action = MisoString
-> Decoder OverlayErrorEvent
-> (OverlayErrorEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"error" Decoder OverlayErrorEvent
overlayErrorDecoder ((OverlayErrorEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (OverlayErrorEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \OverlayErrorEvent
v model
_ DOMRef
domRef -> OverlayErrorEvent -> DOMRef -> action
action OverlayErrorEvent
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onOverlayTouch', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onOverlayTouchWith :: (OverlayTouchEvent -> DOMRef -> action) -> Attribute model action
onOverlayTouchWith :: forall action model.
(OverlayTouchEvent -> DOMRef -> action) -> Attribute model action
onOverlayTouchWith OverlayTouchEvent -> DOMRef -> action
action = MisoString
-> Decoder OverlayTouchEvent
-> (OverlayTouchEvent -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"overlaytouch" Decoder OverlayTouchEvent
overlayTouchDecoder ((OverlayTouchEvent -> model -> DOMRef -> action)
 -> Attribute model action)
-> (OverlayTouchEvent -> model -> DOMRef -> action)
-> Attribute model action
forall a b. (a -> b) -> a -> b
$ \OverlayTouchEvent
v model
_ DOMRef
domRef -> OverlayTouchEvent -> DOMRef -> action
action OverlayTouchEvent
v DOMRef
domRef
-----------------------------------------------------------------------------
-- | Like 'onRequestClose', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onRequestCloseWith :: (DOMRef -> action) -> Attribute model action
onRequestCloseWith :: forall action model. (DOMRef -> action) -> Attribute model action
onRequestCloseWith DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"requestclose" Decoder ()
emptyDecoder (\() model
_ DOMRef
ref -> DOMRef -> action
action DOMRef
ref)
-----------------------------------------------------------------------------
-- | Like 'onShowOverlay', but the handler also receives the target element's 'DOMRef'.
-- Use for main-thread ('MTS') handlers that imperatively mutate the element.
onShowOverlayWith :: (DOMRef -> action) -> Attribute model action
onShowOverlayWith :: forall action model. (DOMRef -> action) -> Attribute model action
onShowOverlayWith DOMRef -> action
action = MisoString
-> Decoder ()
-> (() -> model -> DOMRef -> action)
-> Attribute model action
forall result model action.
MisoString
-> Decoder result
-> (result -> model -> DOMRef -> action)
-> Attribute model action
on MisoString
"showoverlay" Decoder ()
emptyDecoder (\() model
_ DOMRef
ref -> DOMRef -> action
action DOMRef
ref)
-----------------------------------------------------------------------------