Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ReactClass props state insig exsig ctx
- data ClassConfig props state insig exsig ctx = ClassConfig {
- renderFn :: props -> state -> ReactNode insig
- initialState :: state
- name :: JSString
- transition :: (state, insig) -> (state, Maybe exsig)
- startupSignals :: [insig]
- childContext :: Maybe (HashMap Text ctx)
- smartClass :: ClassConfig props state insig exsig JSString
- dumbClass :: ClassConfig props () sig sig JSString
- render :: ReactNode Void -> Element -> IO ()
- debugRender :: Show sig => ReactNode sig -> Element -> IO ()
- data ReactNode sig
- data EventProperties e = EventProperties {
- bubbles :: !Bool
- cancelable :: !Bool
- currentTarget :: !e
- defaultPrevented :: !Bool
- eventPhase :: !Int
- isTrusted :: !Bool
- evtTarget :: !e
- eventType :: !JSString
- data Target = Target {}
- data ModifierKeys = ModifierKeys {}
- data MouseEvent = MouseEvent {}
- data KeyboardEvent = KeyboardEvent {}
- data ChangeEvent = ChangeEvent {}
- data FocusEvent = FocusEvent
- data BlurEvent = BlurEvent
- onBlur :: (BlurEvent -> Maybe s) -> AttrOrHandler s
- onFocus :: (FocusEvent -> Maybe s) -> AttrOrHandler s
- onChange :: (ChangeEvent -> Maybe s) -> AttrOrHandler s
- onKeyDown :: (KeyboardEvent -> Maybe s) -> AttrOrHandler s
- onKeyPress :: (KeyboardEvent -> Maybe s) -> AttrOrHandler s
- onKeyUp :: (KeyboardEvent -> Maybe s) -> AttrOrHandler s
- onMouseEnter :: (MouseEvent -> Maybe s) -> AttrOrHandler s
- onMouseLeave :: (MouseEvent -> Maybe s) -> AttrOrHandler s
- onDoubleClick :: (MouseEvent -> Maybe s) -> AttrOrHandler s
- onClick :: (MouseEvent -> Maybe s) -> AttrOrHandler s
- onEnter :: s -> AttrOrHandler s
- class GeneralizeSignal sigloc siggen where
- generalizeSignal :: sigloc -> siggen
- locally :: GeneralizeSignal sigloc siggen => ReactNode sigloc -> ReactNode siggen
- data AttrOrHandler signal
- newtype NoProps = NoProps ()
- noProps :: NoProps
- mkStaticAttr :: ToJSON a => Text -> a -> AttrOrHandler sig
- key_ :: Text -> AttrOrHandler sig
- class_ :: Text -> AttrOrHandler sig
- href_ :: Text -> AttrOrHandler sig
- id_ :: Text -> AttrOrHandler sig
- src_ :: Text -> AttrOrHandler sig
- value_ :: Text -> AttrOrHandler sig
- placeholder_ :: Text -> AttrOrHandler sig
- for_ :: Text -> AttrOrHandler sig
- type_ :: Text -> AttrOrHandler sig
- checked_ :: Bool -> AttrOrHandler sig
- autofocus_ :: Bool -> AttrOrHandler sig
- width_ :: Double -> AttrOrHandler sig
- height_ :: Double -> AttrOrHandler sig
- cx_ :: Double -> AttrOrHandler sig
- cy_ :: Double -> AttrOrHandler sig
- d_ :: Double -> AttrOrHandler sig
- dx_ :: Double -> AttrOrHandler sig
- dy_ :: Double -> AttrOrHandler sig
- x_ :: Double -> AttrOrHandler sig
- y_ :: Double -> AttrOrHandler sig
- r_ :: Double -> AttrOrHandler sig
- fill_ :: Text -> AttrOrHandler sig
- viewBox_ :: Text -> AttrOrHandler sig
- points_ :: Text -> AttrOrHandler sig
- transform_ :: Text -> AttrOrHandler sig
- classParent :: ClassCtx ctx => ClassConfig props state insig exsig ctx -> ReactNode insig -> props -> ReactNode exsig
- classLeaf :: ClassCtx ctx => ClassConfig props state insig exsig ctx -> props -> ReactNode exsig
- exportClassLeaf :: ClassCtx ctx => ClassConfig props state insig exsig ctx -> ExportedClass
- importLeafClass :: ToJSRef props => ImportedClass props sig -> props -> ReactNode sig
- importParentClass :: ToJSRef props => ImportedClass props sig -> props -> ReactNode sig -> ReactNode sig
- data ExportedNode sig
- type ExportedClass = JSRef ExportedClass_
- type ImportedClass props sig = JSRef (ImportedClass_ props sig)
Classes
data ReactClass props state insig exsig ctx Source
A ReactClass
is a standalone component of a user interface which
contains the state necessary to render itself. Classes are a tool for
scoping.
Use createClass
to construct.
data ClassConfig props state insig exsig ctx Source
ClassConfig | |
|
smartClass :: ClassConfig props state insig exsig JSString Source
dumbClass :: ClassConfig props () sig sig JSString Source
Rendering
React Nodes
Events
data EventProperties e Source
Low level properties common to all events
EventProperties | |
|
NFData e => NFData (EventProperties e) |
data ModifierKeys Source
data FocusEvent Source
Native Events
onBlur :: (BlurEvent -> Maybe s) -> AttrOrHandler s Source
onFocus :: (FocusEvent -> Maybe s) -> AttrOrHandler s Source
onChange :: (ChangeEvent -> Maybe s) -> AttrOrHandler s Source
onKeyDown :: (KeyboardEvent -> Maybe s) -> AttrOrHandler s Source
onKeyPress :: (KeyboardEvent -> Maybe s) -> AttrOrHandler s Source
onKeyUp :: (KeyboardEvent -> Maybe s) -> AttrOrHandler s Source
onMouseEnter :: (MouseEvent -> Maybe s) -> AttrOrHandler s Source
onMouseLeave :: (MouseEvent -> Maybe s) -> AttrOrHandler s Source
onDoubleClick :: (MouseEvent -> Maybe s) -> AttrOrHandler s Source
onClick :: (MouseEvent -> Maybe s) -> AttrOrHandler s Source
Synthetic Events
onEnter :: s -> AttrOrHandler s Source
Local
class GeneralizeSignal sigloc siggen where Source
Implement when a local signal can be generalized to a higher level one. Used
by locally
generalizeSignal :: sigloc -> siggen Source
locally :: GeneralizeSignal sigloc siggen => ReactNode sigloc -> ReactNode siggen Source
locally
exists to make it simple to embed classes with local concerns. An
example will be helpful:
We have some page which can respond to many different events.
data Transition = UserTyping JSString | Toggle ... globalPage_ :: [AttrOrHandler Transition] -> ReactNode Transition
And we want to be able to embed some components that don't care about all
that. inputBox_
can only output JSString
and pageHeader_
can't send
any signals at all.
inputBox_ :: ReactNode JSString pageHeader_ :: ReactNode Void
With locally we can easily embed them in globalPage_
:
instance GeneralizeSignal JSString Transition where generalizeSignal = UserTyping -- (globalPage_) renderFn = props state -> div_ [ class_ "global-page" ] $ do locally pageHeader_ ... locally inputBox_ ...
data AttrOrHandler signal Source
Attributes
When importing a foreign class you must specify the props it takes. In the
common case where it takes no props, only handles layout, it's convenient to
specify the type of props as NoProps
.
Example:
pageLayout_ :: ReactNode () -> ReactNode () pageLayout_ = importParentClass pageLayout noProps
NoProps () |
mkStaticAttr :: ToJSON a => Text -> a -> AttrOrHandler sig Source
key_ :: Text -> AttrOrHandler sig Source
class_ :: Text -> AttrOrHandler sig Source
href_ :: Text -> AttrOrHandler sig Source
id_ :: Text -> AttrOrHandler sig Source
src_ :: Text -> AttrOrHandler sig Source
value_ :: Text -> AttrOrHandler sig Source
placeholder_ :: Text -> AttrOrHandler sig Source
for_ :: Text -> AttrOrHandler sig Source
type_ :: Text -> AttrOrHandler sig Source
checked_ :: Bool -> AttrOrHandler sig Source
autofocus_ :: Bool -> AttrOrHandler sig Source
width_ :: Double -> AttrOrHandler sig Source
height_ :: Double -> AttrOrHandler sig Source
cx_ :: Double -> AttrOrHandler sig Source
cy_ :: Double -> AttrOrHandler sig Source
d_ :: Double -> AttrOrHandler sig Source
dx_ :: Double -> AttrOrHandler sig Source
dy_ :: Double -> AttrOrHandler sig Source
x_ :: Double -> AttrOrHandler sig Source
y_ :: Double -> AttrOrHandler sig Source
r_ :: Double -> AttrOrHandler sig Source
fill_ :: Text -> AttrOrHandler sig Source
viewBox_ :: Text -> AttrOrHandler sig Source
points_ :: Text -> AttrOrHandler sig Source
transform_ :: Text -> AttrOrHandler sig Source
Creating Elements
Class creation
classParent :: ClassCtx ctx => ClassConfig props state insig exsig ctx -> ReactNode insig -> props -> ReactNode exsig Source
classLeaf :: ClassCtx ctx => ClassConfig props state insig exsig ctx -> props -> ReactNode exsig Source
JS Interop
exportClassLeaf :: ClassCtx ctx => ClassConfig props state insig exsig ctx -> ExportedClass Source
importLeafClass :: ToJSRef props => ImportedClass props sig -> props -> ReactNode sig Source
importParentClass :: ToJSRef props => ImportedClass props sig -> props -> ReactNode sig -> ReactNode sig Source
data ExportedNode sig Source
ToJSRef (ExportedNode sig) |
type ExportedClass = JSRef ExportedClass_ Source
JS Interop
type ImportedClass props sig = JSRef (ImportedClass_ props sig) Source