Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
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
Grégoire Locqueville
purescript-gargantext
Commits
9661e284
Commit
9661e284
authored
Jul 03, 2019
by
James Laver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade Reactix to 0.4.0
parent
994d62b0
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
102 additions
and
93 deletions
+102
-93
packages.json
.psc-package/local/.set/packages.json
+1
-1
packages.dhall
packages.dhall
+1
-1
psc-package.json
psc-package.json
+1
-0
AnnotatedField.purs
src/Gargantext/Components/Annotation/AnnotatedField.purs
+6
-6
Menu.purs
src/Gargantext/Components/Annotation/Menu.purs
+3
-3
ContextMenu.purs
src/Gargantext/Components/ContextMenu/ContextMenu.purs
+14
-14
Sigmajs.purs
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
+2
-0
SearchField.purs
src/Gargantext/Components/Search/SearchField.purs
+6
-6
Tree.purs
src/Gargantext/Components/Tree.purs
+58
-47
Specs.purs
src/Gargantext/Pages/Layout/Specs.purs
+2
-2
SearchBar.purs
src/Gargantext/Pages/Layout/Specs/SearchBar.purs
+4
-5
Reactix.purs
src/Gargantext/Utils/Reactix.purs
+4
-8
No files found.
.psc-package/local/.set/packages.json
View file @
9661e284
...
@@ -2102,7 +2102,7 @@
...
@@ -2102,7 +2102,7 @@
"ffi-simple"
"ffi-simple"
],
],
"repo"
:
"https://github.com/irresponsible/purescript-reactix"
,
"repo"
:
"https://github.com/irresponsible/purescript-reactix"
,
"version"
:
"v0.
3.1
"
"version"
:
"v0.
4.0
"
},
},
"read"
:
{
"read"
:
{
"dependencies"
:
[
"dependencies"
:
[
...
...
packages.dhall
View file @
9661e284
...
@@ -194,7 +194,7 @@ let additions =
...
@@ -194,7 +194,7 @@ let additions =
, "ffi-simple"
, "ffi-simple"
]
]
"https://github.com/irresponsible/purescript-reactix"
"https://github.com/irresponsible/purescript-reactix"
"v0.
3.1
"
"v0.
4.0
"
, uint =
, uint =
mkPackage
mkPackage
[ "maybe", "math", "generics-rep" ]
[ "maybe", "math", "generics-rep" ]
...
...
psc-package.json
View file @
9661e284
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
"random"
,
"random"
,
"reactix"
,
"reactix"
,
"routing"
,
"routing"
,
"sequences"
,
"spec-discovery"
,
"spec-discovery"
,
"spec-quickcheck"
,
"spec-quickcheck"
,
"string-parsers"
,
"string-parsers"
,
...
...
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
9661e284
...
@@ -49,7 +49,7 @@ annotatedFieldComponent :: R.Component Props
...
@@ -49,7 +49,7 @@ annotatedFieldComponent :: R.Component Props
annotatedFieldComponent = R.hooksComponent "AnnotatedField" cpt
annotatedFieldComponent = R.hooksComponent "AnnotatedField" cpt
where
where
cpt {ngrams,setTermList,text} _ = do
cpt {ngrams,setTermList,text} _ = do
menu /\ setMenu <- R.useState $
\_ -> pure
Nothing
menu /\ setMenu <- R.useState $
const
Nothing
let wrapperProps =
let wrapperProps =
{ className: "annotated-field-wrapper" }
{ className: "annotated-field-wrapper" }
...
@@ -59,8 +59,8 @@ annotatedFieldComponent = R.hooksComponent "AnnotatedField" cpt
...
@@ -59,8 +59,8 @@ annotatedFieldComponent = R.hooksComponent "AnnotatedField" cpt
y = E.clientY event
y = E.clientY event
setList t = do
setList t = do
setTermList (S.toLower text') (Just list) t
setTermList (S.toLower text') (Just list) t
setMenu
Nothing
setMenu
(const Nothing)
setMenu
$ Just {x, y, list: Just list, menuType: SetTermListItem, setList}
setMenu
(const $ Just {x, y, list: Just list, menuType: SetTermListItem, setList} )
mapCompile (Tuple t l) = {text: t, list: l, onSelect}
mapCompile (Tuple t l) = {text: t, list: l, onSelect}
compiled = map mapCompile $ compile ngrams text
compiled = map mapCompile $ compile ngrams text
...
@@ -82,13 +82,13 @@ maybeShowMenu setMenu setTermList ngrams event = do
...
@@ -82,13 +82,13 @@ maybeShowMenu setMenu setTermList ngrams event = do
list = findNgram ngrams sel'
list = findNgram ngrams sel'
setList t = do
setList t = do
setTermList sel' list t
setTermList sel' list t
setMenu
Nothing
setMenu
(const Nothing)
E.preventDefault event
E.preventDefault event
setMenu
$ Just { x, y, list, menuType: NewNgram, setList }
setMenu
(const $ Just { x, y, list, menuType: NewNgram, setList })
Nothing -> pure unit
Nothing -> pure unit
maybeAddMenu
maybeAddMenu
:: (
Maybe AnnotationMenu
-> Effect Unit)
:: (
(Maybe AnnotationMenu -> Maybe AnnotationMenu)
-> Effect Unit)
-> R.Element
-> R.Element
-> Maybe AnnotationMenu
-> Maybe AnnotationMenu
-> R.Element
-> R.Element
...
...
src/Gargantext/Components/Annotation/Menu.purs
View file @
9661e284
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
module Gargantext.Components.Annotation.Menu where
module Gargantext.Components.Annotation.Menu where
import Prelude ( Unit, (==), ($), (<>), unit, pure, otherwise )
import Prelude ( Unit, (==), ($), (<>), unit, pure, otherwise
, const
)
import Data.Array as A
import Data.Array as A
import Data.Maybe ( Maybe(..), maybe' )
import Data.Maybe ( Maybe(..), maybe' )
import Effect ( Effect )
import Effect ( Effect )
...
@@ -22,14 +22,14 @@ data MenuType = NewNgram | SetTermListItem
...
@@ -22,14 +22,14 @@ data MenuType = NewNgram | SetTermListItem
type Props =
type Props =
( list :: Maybe TermList
( list :: Maybe TermList
, menuType :: MenuType
, menuType :: MenuType
, setList :: TermList -> Effect Unit
, setList :: TermList -> Effect Unit
-- not a state hook setter
)
)
type AnnotationMenu = { x :: Number, y :: Number | Props }
type AnnotationMenu = { x :: Number, y :: Number | Props }
-- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | TermList the currently selected text belongs to
-- | TermList the currently selected text belongs to
annotationMenu :: (
Maybe AnnotationMenu
-> Effect Unit) -> AnnotationMenu -> R.Element
annotationMenu :: (
(Maybe AnnotationMenu -> Maybe AnnotationMenu)
-> Effect Unit) -> AnnotationMenu -> R.Element
annotationMenu setMenu { x,y,list,menuType,setList } =
annotationMenu setMenu { x,y,list,menuType,setList } =
CM.contextMenu { x,y,setMenu } [
CM.contextMenu { x,y,setMenu } [
R.createElement annotationMenuCpt {list,menuType,setList} []
R.createElement annotationMenuCpt {list,menuType,setList} []
...
...
src/Gargantext/Components/ContextMenu/ContextMenu.purs
View file @
9661e284
...
@@ -26,7 +26,7 @@ import Reactix.SyntheticEvent as E
...
@@ -26,7 +26,7 @@ import Reactix.SyntheticEvent as E
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
type Props t = ( x :: Number, y :: Number, setMenu ::
Maybe t
-> Effect Unit)
type Props t = ( x :: Number, y :: Number, setMenu ::
(Maybe t -> Maybe t)
-> Effect Unit)
getPortalHost :: R.Hooks DOM.Element
getPortalHost :: R.Hooks DOM.Element
getPortalHost = R.unsafeHooksEffect $ delay unit $ \_ -> pure $ document ... "getElementById" $ ["menu-portal"]
getPortalHost = R.unsafeHooksEffect $ delay unit $ \_ -> pure $ document ... "getElementById" $ ["menu-portal"]
...
@@ -40,12 +40,12 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
...
@@ -40,12 +40,12 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
cpt menu children = do
cpt menu children = do
host <- getPortalHost
host <- getPortalHost
root <- R.useRef null
root <- R.useRef null
rect /\ setRect <- R.useState $ \_ ->
pure
Nothing
rect /\ setRect <- R.useState $ \_ -> Nothing
R.useLayoutEffect1 (R.readRef root) $
\_ ->
do
R.useLayoutEffect1 (R.readRef root) $ do
traverse_
traverse_
(\r -> setRect
$ Just (Element.boundingRect r
))
(\r -> setRect
(\_ -> Just (Element.boundingRect r)
))
(toMaybe $ R.readRef root)
(toMaybe $ R.readRef root)
pure $
\_ ->
pure unit
pure $ pure unit
R.useLayoutEffect2 root rect (contextMenuEffect menu.setMenu root)
R.useLayoutEffect2 root rect (contextMenuEffect menu.setMenu root)
let cs = [
let cs = [
HTML.div { className: "popover-content" }
HTML.div { className: "popover-content" }
...
@@ -61,31 +61,31 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
...
@@ -61,31 +61,31 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
contextMenuEffect
contextMenuEffect
:: forall t
:: forall t
. (
Maybe t
-> Effect Unit)
. (
(Maybe t -> Maybe t)
-> Effect Unit)
-> R.Ref (Nullable DOM.Element)
-> R.Ref (Nullable DOM.Element)
->
Unit -> Effect (Unit ->
Effect Unit)
->
Effect (
Effect Unit)
contextMenuEffect setMenu rootRef
_
=
contextMenuEffect setMenu rootRef =
case R.readNullableRef rootRef of
case R.readNullableRef rootRef of
Just root -> do
Just root -> do
let onClick = documentClickHandler setMenu root
let onClick = documentClickHandler setMenu root
let onScroll = documentScrollHandler setMenu
let onScroll = documentScrollHandler setMenu
DOM.addEventListener document "click" onClick
DOM.addEventListener document "click" onClick
DOM.addEventListener document "scroll" onScroll
DOM.addEventListener document "scroll" onScroll
pure $
\_ ->
do
pure $ do
DOM.removeEventListener document "click" onClick
DOM.removeEventListener document "click" onClick
DOM.removeEventListener document "scroll" onScroll
DOM.removeEventListener document "scroll" onScroll
Nothing -> pure
$ \_ -> pure unit
Nothing -> pure
R.nothing
documentClickHandler :: forall t. (
Maybe t
-> Effect Unit) -> DOM.Element -> Callback DE.MouseEvent
documentClickHandler :: forall t. (
(Maybe t -> Maybe t)
-> Effect Unit) -> DOM.Element -> Callback DE.MouseEvent
documentClickHandler hide menu =
documentClickHandler hide menu =
R2.named "hideMenuOnClickOutside" $ callback $ \e ->
R2.named "hideMenuOnClickOutside" $ callback $ \e ->
if Element.contains menu (DE.target e)
if Element.contains menu (DE.target e)
then pure unit
then pure unit
else hide
Nothing
else hide
(const Nothing)
documentScrollHandler :: forall t. (
Maybe t
-> Effect Unit) -> Callback DE.MouseEvent
documentScrollHandler :: forall t. (
(Maybe t -> Maybe t)
-> Effect Unit) -> Callback DE.MouseEvent
documentScrollHandler hide =
documentScrollHandler hide =
R2.named "hideMenuOnScroll" $ callback $ \e -> hide
Nothing
R2.named "hideMenuOnScroll" $ callback $ \e -> hide
(const Nothing)
position :: forall t. Record (Props t) -> DOMRect -> { left :: Number, top :: Number }
position :: forall t. Record (Props t) -> DOMRect -> { left :: Number, top :: Number }
position mouse {width: menuWidth, height: menuHeight} = {left, top}
position mouse {width: menuWidth, height: menuHeight} = {left, top}
...
...
src/Gargantext/Components/GraphExplorer/Sigmajs.purs
View file @
9661e284
...
@@ -3,6 +3,8 @@ module Gargantext.Components.GraphExplorer.Sigmajs where
...
@@ -3,6 +3,8 @@ module Gargantext.Components.GraphExplorer.Sigmajs where
import Prelude
import Prelude
import Data.Nullable (Nullable)
import Data.Nullable (Nullable)
import Data.Sequence (Seq)
import Data.Sequence as Seq
import Effect (Effect)
import Effect (Effect)
import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1)
import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
import React (Children, ReactClass, ReactElement, ReactRef, SyntheticEventHandler, createElement, unsafeCreateElement)
...
...
src/Gargantext/Components/Search/SearchField.purs
View file @
9661e284
...
@@ -46,8 +46,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
...
@@ -46,8 +46,8 @@ searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) hasChanged
where
where
cpt props _ = do
cpt props _ = do
let search = maybe defaultSearch identity (fst props.search)
let search = maybe defaultSearch identity (fst props.search)
term <- R.useState $ \_ ->
pure
search.term
term <- R.useState $ \_ -> search.term
db <- R.useState $ \_ ->
pure
Nothing
db <- R.useState $ \_ -> Nothing
pure $
pure $
div { className: "search-field input-group" }
div { className: "search-field input-group" }
[ databaseInput db props.databases
[ databaseInput db props.databases
...
@@ -68,7 +68,7 @@ databaseInput (db /\ setDB) dbs =
...
@@ -68,7 +68,7 @@ databaseInput (db /\ setDB) dbs =
liItem db = li { onClick }
liItem db = li { onClick }
[ a {href: "#"} [text (show db) ] ]
[ a {href: "#"} [text (show db) ] ]
where
where
onClick = mkEffectFn1 $ \_ -> setDB
$ Just db
onClick = mkEffectFn1 $ \_ -> setDB
(const $ Just db)
dropdownBtnProps = { id: "search-dropdown"
dropdownBtnProps = { id: "search-dropdown"
, className: "btn btn-default dropdown-toggle"
, className: "btn btn-default dropdown-toggle"
, type: "button"} .= "data-toggle" $ "dropdown"
, type: "button"} .= "data-toggle" $ "dropdown"
...
@@ -82,7 +82,7 @@ searchInput (term /\ setTerm) =
...
@@ -82,7 +82,7 @@ searchInput (term /\ setTerm) =
, type: "text"
, type: "text"
, onChange
, onChange
, placeholder }
, placeholder }
where onChange = mkEffectFn1 $ \e -> setTerm
$ e .. "target" .. "value"
where onChange = mkEffectFn1 $ \e -> setTerm
(const $ e .. "target" .. "value")
submitButton :: R.State (Maybe Database) -> R.State String -> R.State (Maybe Search) -> R.Element
submitButton :: R.State (Maybe Database) -> R.State String -> R.State (Maybe Search) -> R.Element
...
@@ -91,5 +91,5 @@ submitButton (database /\ _) (term /\ _) (_ /\ setSearch) =
...
@@ -91,5 +91,5 @@ submitButton (database /\ _) (term /\ _) (_ /\ setSearch) =
where
where
click = mkEffectFn1 $ \_ -> do
click = mkEffectFn1 $ \_ -> do
case term of
case term of
"" -> setSearch
Nothing
"" -> setSearch
(const Nothing)
_ -> setSearch
$ Just { database, term }
_ -> setSearch
(const $ Just { database, term })
src/Gargantext/Components/Tree.purs
View file @
9661e284
This diff is collapsed.
Click to expand it.
src/Gargantext/Pages/Layout/Specs.purs
View file @
9661e284
...
@@ -29,7 +29,7 @@ import Gargantext.Pages.Layout.Specs.Search as S
...
@@ -29,7 +29,7 @@ import Gargantext.Pages.Layout.Specs.Search as S
import Gargantext.Pages.Layout.Specs.SearchBar as SB
import Gargantext.Pages.Layout.Specs.SearchBar as SB
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _graphExplorerState, _loginState, _searchState)
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _graphExplorerState, _loginState, _searchState)
import Gargantext.Router (Routes(..))
import Gargantext.Router (Routes(..))
import Gargantext.Utils.Reactix
as R'
import Gargantext.Utils.Reactix
(scuff)
layoutSpec :: Spec AppState {} Action
layoutSpec :: Spec AppState {} Action
layoutSpec =
layoutSpec =
...
@@ -180,7 +180,7 @@ searchBar = simpleSpec defaultPerformAction render
...
@@ -180,7 +180,7 @@ searchBar = simpleSpec defaultPerformAction render
, div [ className "collapse navbar-collapse"
, div [ className "collapse navbar-collapse"
]
]
$ [ divDropdownLeft ]
$ [ divDropdownLeft ]
<> [
R'.
scuff (SB.searchBar SB.defaultProps) ]
<> [ scuff (SB.searchBar SB.defaultProps) ]
<> [ divDropdownRight d s ]
<> [ divDropdownRight d s ]
]
]
]
]
...
...
src/Gargantext/Pages/Layout/Specs/SearchBar.purs
View file @
9661e284
...
@@ -15,7 +15,6 @@ import Thermite (Spec, defaultPerformAction, simpleSpec)
...
@@ -15,7 +15,6 @@ import Thermite (Spec, defaultPerformAction, simpleSpec)
import Reactix as R
import Reactix as R
import DOM.Simple.Console
import DOM.Simple.Console
import Effect.Aff (launchAff)
import Effect.Aff (launchAff)
import Gargantext.Utils.Reactix as R'
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import Gargantext.Components.Search.Types
import Gargantext.Components.Search.Types
import Gargantext.Components.Search.Ajax as Ajax
import Gargantext.Components.Search.Ajax as Ajax
...
@@ -35,8 +34,8 @@ searchBarComponent :: R.Component Props
...
@@ -35,8 +34,8 @@ searchBarComponent :: R.Component Props
searchBarComponent = R.hooksComponent "SearchBar" cpt
searchBarComponent = R.hooksComponent "SearchBar" cpt
where
where
cpt props _ = do
cpt props _ = do
open <- R.useState $
\_ -> pure $
props.open
open <- R.useState $
const
props.open
search <- R.useState $
\_ -> pure
Nothing
search <- R.useState $
const
Nothing
onSearchChange search
onSearchChange search
pure $ H.div { className: "search-bar-container" }
pure $ H.div { className: "search-bar-container" }
[ toggleButton open
[ toggleButton open
...
@@ -50,7 +49,7 @@ searchFieldContainer (open /\ _) databases search =
...
@@ -50,7 +49,7 @@ searchFieldContainer (open /\ _) databases search =
onSearchChange :: R.State (Maybe Search) -> R.Hooks Unit
onSearchChange :: R.State (Maybe Search) -> R.Hooks Unit
onSearchChange (search /\ setSearch) =
onSearchChange (search /\ setSearch) =
R
'.useLayoutEffect1' search $ \_ ->
traverse_ triggerSearch search
R
.useLayoutEffect1' search $
traverse_ triggerSearch search
where
where
triggerSearch q = do
triggerSearch q = do
launchAff $ do
launchAff $ do
...
@@ -68,4 +67,4 @@ toggleButton open =
...
@@ -68,4 +67,4 @@ toggleButton open =
[ H.text "control_point" ] ]
[ H.text "control_point" ] ]
onToggleExpanded :: forall e. R.State Boolean -> EffectFn1 e Unit
onToggleExpanded :: forall e. R.State Boolean -> EffectFn1 e Unit
onToggleExpanded
open = mkEffectFn1 $ \_ -> R'.overState not open
onToggleExpanded
(_open /\ setOpen) = mkEffectFn1 $ \_ -> setOpen not
src/Gargantext/Utils/Reactix.purs
View file @
9661e284
...
@@ -10,7 +10,7 @@ import Data.Traversable (traverse_)
...
@@ -10,7 +10,7 @@ import Data.Traversable (traverse_)
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect (Effect)
import Effect.Uncurried (mkEffectFn1)
import Effect.Uncurried (
EffectFn1,
mkEffectFn1)
import FFI.Simple ((...), defineProperty)
import FFI.Simple ((...), defineProperty)
import React (ReactElement)
import React (ReactElement)
import Reactix as R
import Reactix as R
...
@@ -38,15 +38,11 @@ named :: forall o. String -> o -> o
...
@@ -38,15 +38,11 @@ named :: forall o. String -> o -> o
named = flip $ defineProperty "name"
named = flip $ defineProperty "name"
overState :: forall t. (t -> t) -> R.State t -> Effect Unit
overState :: forall t. (t -> t) -> R.State t -> Effect Unit
overState f (state /\ setState) = setState $ f state
overState f (_state /\ setState) = setState f
useLayoutEffect1' :: forall a. a -> (Unit -> Effect Unit) -> R.Hooks Unit
useLayoutEffect1' a f = R.useLayoutEffect1 a $ \_ ->
do f unit
pure $ \_ -> pure unit
select :: ElemFactory
select :: ElemFactory
select = createDOMElement "select"
select = createDOMElement "select"
effToggler (value /\ setValue) = mkEffectFn1 $ \_ -> setValue $ not value
effToggler :: forall e. R.State Boolean -> EffectFn1 e Unit
effToggler (_value /\ setValue) = mkEffectFn1 $ \e -> setValue not
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