Module

React.Keybind.Types

Package
purescript-react-keybind
Repository
EpicOrange/purescript-react-keybind

This module contains Purescript versions of types in the original react-keybind library.

Although all types are exported, ShortcutSpec and WithShortcutProps are likely the only two types you'll need from here.

Component WithShortcutProps is the type you pass into withShortcut:

import React.Basic.Hooks (Component)
import React.Basic.Hooks as React
myComponent :: Component WithShortcutProps
myComponent = React.component "MyComponent" \{ shortcut } -> ...

myShortcutComponent :: Component {}
myShortcutComponent = withShortcut "MyShortcutComponent" myComponent

ShortcutSpec is the type you pass into registerShortcut and registerSequenceShortcut:

let myShortcut :: ShortcutSpec
    myShortcut = { method: handler_ doSomething, keys: ["ctrl+h", "cmd+h"], ... }
_ <- registerShortcut myShortcut

#ShortcutSpecRow Source

type ShortcutSpecRow = (description :: String, holdDuration :: Maybe Number, keys :: Array String, method :: EventHandler, title :: String)

#WithShortcutPropsRow Source

#ProviderPropsRow Source

type ProviderPropsRow = (children :: Array JSX, ignoreKeys :: Array String, ignoreTagNames :: Array String, preventDefault :: Boolean)

#IShortcut Source

type IShortcut = { description :: String, hold :: Number, holdDuration :: String, id :: String, keys :: Array String, method :: EventHandler, sequence :: Boolean, title :: String }

#ProviderRenderPropsRow Source

type ProviderRenderPropsRow = (registerSequenceShortcut :: ShortcutSpec -> Effect Unit, registerShortcut :: ShortcutSpec -> Effect Unit, shortcuts :: Array IShortcut, triggerShortcut :: String -> Effect Unit, unregisterShortcut :: Array String -> Effect Unit)