{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Miso.Event.Types where
import qualified Data.Map as M
import GHC.Generics
import GHCJS.Marshal (ToJSVal)
import Miso.String
import Data.Aeson (FromJSON)
data KeyInfo
= KeyInfo
{ keyCode :: !KeyCode
, shiftKey, metaKey, ctrlKey, altKey :: !Bool
} deriving (Show, Eq)
newtype KeyCode = KeyCode Int
deriving (Show, Eq, Ord, FromJSON)
newtype Checked = Checked Bool
deriving (Show, Eq, Ord, FromJSON)
data Options = Options {
preventDefault :: Bool
, stopPropagation :: Bool
} deriving (Show, Eq, Generic)
instance ToJSVal Options
defaultOptions :: Options
defaultOptions = Options False False
newtype AllowDrop = AllowDrop Bool
deriving (Show, Eq, FromJSON)
defaultEvents :: M.Map MisoString Bool
defaultEvents = M.fromList [
("blur", True)
, ("change", False)
, ("click", False)
, ("dblclick", False)
, ("focus", False)
, ("input", False)
, ("keydown", False)
, ("keypress", False)
, ("keyup", False)
, ("mouseup", False)
, ("mousedown", False)
, ("mouseenter", True)
, ("mouseleave", False)
, ("mouseover", False)
, ("mouseout", False)
, ("dragstart", False)
, ("dragover", False)
, ("dragend", False)
, ("dragenter", False)
, ("dragleave", False)
, ("drag", False)
, ("drop", False)
, ("submit", False)
]