Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-reactix
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
purescript-reactix
Commits
693eea23
Commit
693eea23
authored
Oct 13, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added couple of new functions
These were used in Gargantext, it is ported for common functionality.
parent
ccfd0649
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
4 deletions
+23
-4
package.json
package.json
+1
-1
Reactix.purs
src/Reactix.purs
+1
-1
Hooks.purs
src/Reactix/Hooks.purs
+4
-1
React.purs
src/Reactix/React.purs
+10
-1
SyntheticEvent.purs
src/Reactix/SyntheticEvent.purs
+7
-0
No files found.
package.json
View file @
693eea23
{
"name"
:
"reactix"
,
"version"
:
"0.4.
5
"
,
"version"
:
"0.4.
6
"
,
"description"
:
""
,
"scripts"
:
{
"rebase-set"
:
"spago package-set-upgrade && spago psc-package-insdhall"
,
...
...
src/Reactix.purs
View file @
693eea23
...
...
@@ -3,5 +3,5 @@ module Reactix
) where
import Reactix.React (class IsComponent, Component, Consumer, Context, Element, Hooks, Memo, Provider, React, ReactDOM, Ref, consume, consumeContext, consumer, createContext, createDOMElement, createElement, rawCreateElement, createPortal, createRef, fragment, hooksComponent, isValid, memo, memo', provide, provideContext, provider, react, reactDOM, readNullableRef, readRef, render, runHooks, setRef, staticComponent, unsafeHooksEffect) as Exports
import Reactix.Hooks (Reducer, State, nothing, thenNothing, unsafeUseCallback, unsafeUseEffect, unsafeUseImperativeHandle, unsafeUseLayoutEffect, unsafeUseMemo, useCallback, useCallback1, useCallback2, useCallback3, useCallback4, useCallback5, useContext, useDebugValue, useDebugValue', useEffect, useEffect', useEffect1, useEffect1', useEffect2, useEffect2', useEffect3, useEffect3', useEffect4, useEffect4', useEffect5, useEffect5', useEffectFn1, useEffectFn1', useEffectFn2, useEffectFn2', useEffectFn3, useEffectFn3', useEffectFn4, useEffectFn4', useEffectFn5, useEffectFn5', useEffectOnce, useEffectOnce', useImperativeHandle, useImperativeHandle1, useImperativeHandle2, useImperativeHandle3, useImperativeHandle4, useImperativeHandle5, useLayoutEffect, useLayoutEffect', useLayoutEffect1, useLayoutEffect1', useLayoutEffect2, useLayoutEffect2', useLayoutEffect3, useLayoutEffect3', useLayoutEffect4, useLayoutEffect4', useLayoutEffect5, useLayoutEffect5', useLayoutEffectFn1, useLayoutEffectFn1', useLayoutEffectFn2, useLayoutEffectFn2', useLayoutEffectFn3, useLayoutEffectFn3', useLayoutEffectFn4, useLayoutEffectFn4', useLayoutEffectFn5, useLayoutEffectFn5', useMemo, useMemo1, useMemo2, useMemo3, useMemo4, useMemo5, useReducer, useReducer', useRef, useState, useState') as Exports
import Reactix.Hooks (Reducer, State,
Setter,
nothing, thenNothing, unsafeUseCallback, unsafeUseEffect, unsafeUseImperativeHandle, unsafeUseLayoutEffect, unsafeUseMemo, useCallback, useCallback1, useCallback2, useCallback3, useCallback4, useCallback5, useContext, useDebugValue, useDebugValue', useEffect, useEffect', useEffect1, useEffect1', useEffect2, useEffect2', useEffect3, useEffect3', useEffect4, useEffect4', useEffect5, useEffect5', useEffectFn1, useEffectFn1', useEffectFn2, useEffectFn2', useEffectFn3, useEffectFn3', useEffectFn4, useEffectFn4', useEffectFn5, useEffectFn5', useEffectOnce, useEffectOnce', useImperativeHandle, useImperativeHandle1, useImperativeHandle2, useImperativeHandle3, useImperativeHandle4, useImperativeHandle5, useLayoutEffect, useLayoutEffect', useLayoutEffect1, useLayoutEffect1', useLayoutEffect2, useLayoutEffect2', useLayoutEffect3, useLayoutEffect3', useLayoutEffect4, useLayoutEffect4', useLayoutEffect5, useLayoutEffect5', useLayoutEffectFn1, useLayoutEffectFn1', useLayoutEffectFn2, useLayoutEffectFn2', useLayoutEffectFn3, useLayoutEffectFn3', useLayoutEffectFn4, useLayoutEffectFn4', useLayoutEffectFn5, useLayoutEffectFn5', useMemo, useMemo1, useMemo2, useMemo3, useMemo4, useMemo5, useReducer, useReducer', useRef, useState, useState') as Exports
import Reactix.SyntheticEvent (SyntheticEvent) as Exports
src/Reactix/Hooks.purs
View file @
693eea23
module Reactix.Hooks
( State, useState, useState'
( State,
Setter,
useState, useState'
, Reducer, useReducer, useReducer'
, useContext
, useRef
...
...
@@ -49,6 +49,9 @@ delayEffect = delay
-- | A state hook is a tuple of value and setter
type State state = Tuple state ((state -> state) -> Effect Unit)
-- a setter function, for useState
type Setter t = (t -> t) -> Effect Unit
-- | Given an Effect function returning an initial value, returns a State
useState :: forall s. (Unit -> s) -> Hooks (State s)
useState s =
...
...
src/Reactix/React.purs
View file @
693eea23
...
...
@@ -12,7 +12,8 @@ module Reactix.React
, class IsComponent
, Component, createElement, createDOMElement
, rawCreateElement
, staticComponent, hooksComponent
, StaticComponent, staticComponent, staticComponentWithModule
, HooksComponent, hooksComponent, hooksComponentWithModule
, fragment
, Ref, createRef, readRef, readNullableRef, setRef
...
...
@@ -89,6 +90,8 @@ instance consumerIsComponent :: IsComponent (Consumer v) () (v -> Element) where
-- | The type of a function that can be turned into a component with
-- | `staticComponent`. Will not have access to the `Hooks` Monad.
type Module = String
type StaticComponent props = Record props -> Array Element -> Element
-- | Turns a `StaticComponent` function into a Component
...
...
@@ -98,6 +101,9 @@ staticComponent name c = Component $ named name $ mkEffectFn1 c'
c' :: Record props -> Effect Element
c' props = pure $ c props (children props)
staticComponentWithModule :: forall props. Module -> String -> StaticComponent props -> R.Component props
staticComponentWithModule module' name c = R.staticComponent (module' <> "." <> name) c
-- | The type of a function that can be turned into a component with
-- | `hooksComponent`. Will have access to the `Hooks` Monad.
type HooksComponent props = Record props -> Array Element -> Hooks Element
...
...
@@ -109,6 +115,9 @@ hooksComponent name c = Component $ named name $ mkEffectFn1 c'
c' :: Record props -> Effect Element
c' props = runHooks $ c props (children props)
hooksComponentWithModule :: forall props. Module -> String -> HooksComponent props -> R.Component props
hooksComponentWithModule module' name c = hooksComponent (module' <> "." <> name) c
rawCreateElement :: forall c p cs. c -> p -> Array cs -> Element
rawCreateElement c p cs = react ... "createElement" $ args
where args = PA.unshift c $ PA.unshift p cs
...
...
src/Reactix/SyntheticEvent.purs
View file @
693eea23
...
...
@@ -6,9 +6,16 @@ import DOM.Simple as DOM
import DOM.Simple.Event (class HasModifierKeys, class IsEvent, class IsMouseEvent, KeyboardEvent, MouseButtonEvent)
import Effect ( Effect )
import FFI.Simple ( (..), (...), delay )
import Unsafe.Coerce (unsafeCoerce)
foreign import data SyntheticEvent :: Type -> Type
unsafeEventValue :: forall event. event -> String
unsafeEventValue e = (unsafeCoerce e).target.value
unsafeEventTarget :: forall event. event -> DOM.Element
unsafeEventTarget e = (unsafeCoerce e).target
bubbles :: forall e. IsEvent e => SyntheticEvent e -> Boolean
bubbles e = e .. "bubbles"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment