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 @@
"ffi-simple"
],
"repo"
:
"https://github.com/irresponsible/purescript-reactix"
,
"version"
:
"v0.
3.1
"
"version"
:
"v0.
4.0
"
},
"read"
:
{
"dependencies"
:
[
...
...
packages.dhall
View file @
9661e284
...
...
@@ -194,7 +194,7 @@ let additions =
, "ffi-simple"
]
"https://github.com/irresponsible/purescript-reactix"
"v0.
3.1
"
"v0.
4.0
"
, uint =
mkPackage
[ "maybe", "math", "generics-rep" ]
...
...
psc-package.json
View file @
9661e284
...
...
@@ -21,6 +21,7 @@
"random"
,
"reactix"
,
"routing"
,
"sequences"
,
"spec-discovery"
,
"spec-quickcheck"
,
"string-parsers"
,
...
...
src/Gargantext/Components/Annotation/AnnotatedField.purs
View file @
9661e284
...
...
@@ -49,7 +49,7 @@ annotatedFieldComponent :: R.Component Props
annotatedFieldComponent = R.hooksComponent "AnnotatedField" cpt
where
cpt {ngrams,setTermList,text} _ = do
menu /\ setMenu <- R.useState $
\_ -> pure
Nothing
menu /\ setMenu <- R.useState $
const
Nothing
let wrapperProps =
{ className: "annotated-field-wrapper" }
...
...
@@ -59,8 +59,8 @@ annotatedFieldComponent = R.hooksComponent "AnnotatedField" cpt
y = E.clientY event
setList t = do
setTermList (S.toLower text') (Just list) t
setMenu
Nothing
setMenu
$ Just {x, y, list: Just list, menuType: SetTermListItem, setList}
setMenu
(const Nothing)
setMenu
(const $ Just {x, y, list: Just list, menuType: SetTermListItem, setList} )
mapCompile (Tuple t l) = {text: t, list: l, onSelect}
compiled = map mapCompile $ compile ngrams text
...
...
@@ -82,13 +82,13 @@ maybeShowMenu setMenu setTermList ngrams event = do
list = findNgram ngrams sel'
setList t = do
setTermList sel' list t
setMenu
Nothing
setMenu
(const Nothing)
E.preventDefault event
setMenu
$ Just { x, y, list, menuType: NewNgram, setList }
setMenu
(const $ Just { x, y, list, menuType: NewNgram, setList })
Nothing -> pure unit
maybeAddMenu
:: (
Maybe AnnotationMenu
-> Effect Unit)
:: (
(Maybe AnnotationMenu -> Maybe AnnotationMenu)
-> Effect Unit)
-> R.Element
-> Maybe AnnotationMenu
-> R.Element
...
...
src/Gargantext/Components/Annotation/Menu.purs
View file @
9661e284
...
...
@@ -2,7 +2,7 @@
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.Maybe ( Maybe(..), maybe' )
import Effect ( Effect )
...
...
@@ -22,14 +22,14 @@ data MenuType = NewNgram | SetTermListItem
type Props =
( list :: Maybe TermList
, menuType :: MenuType
, setList :: TermList -> Effect Unit
, setList :: TermList -> Effect Unit
-- not a state hook setter
)
type AnnotationMenu = { x :: Number, y :: Number | Props }
-- | An Annotation Menu is parameterised by a Maybe Termlist of the
-- | 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 } =
CM.contextMenu { x,y,setMenu } [
R.createElement annotationMenuCpt {list,menuType,setList} []
...
...
src/Gargantext/Components/ContextMenu/ContextMenu.purs
View file @
9661e284
...
...
@@ -26,7 +26,7 @@ import Reactix.SyntheticEvent as E
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.unsafeHooksEffect $ delay unit $ \_ -> pure $ document ... "getElementById" $ ["menu-portal"]
...
...
@@ -40,12 +40,12 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
cpt menu children = do
host <- getPortalHost
root <- R.useRef null
rect /\ setRect <- R.useState $ \_ ->
pure
Nothing
R.useLayoutEffect1 (R.readRef root) $
\_ ->
do
rect /\ setRect <- R.useState $ \_ -> Nothing
R.useLayoutEffect1 (R.readRef root) $ do
traverse_
(\r -> setRect
$ Just (Element.boundingRect r
))
(\r -> setRect
(\_ -> Just (Element.boundingRect r)
))
(toMaybe $ R.readRef root)
pure $
\_ ->
pure unit
pure $ pure unit
R.useLayoutEffect2 root rect (contextMenuEffect menu.setMenu root)
let cs = [
HTML.div { className: "popover-content" }
...
...
@@ -61,31 +61,31 @@ contextMenuCpt = R.hooksComponent "ContextMenu" cpt
contextMenuEffect
:: forall t
. (
Maybe t
-> Effect Unit)
. (
(Maybe t -> Maybe t)
-> Effect Unit)
-> R.Ref (Nullable DOM.Element)
->
Unit -> Effect (Unit ->
Effect Unit)
contextMenuEffect setMenu rootRef
_
=
->
Effect (
Effect Unit)
contextMenuEffect setMenu rootRef =
case R.readNullableRef rootRef of
Just root -> do
let onClick = documentClickHandler setMenu root
let onScroll = documentScrollHandler setMenu
DOM.addEventListener document "click" onClick
DOM.addEventListener document "scroll" onScroll
pure $
\_ ->
do
pure $ do
DOM.removeEventListener document "click" onClick
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 =
R2.named "hideMenuOnClickOutside" $ callback $ \e ->
if Element.contains menu (DE.target e)
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 =
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 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
import Prelude
import Data.Nullable (Nullable)
import Data.Sequence (Seq)
import Data.Sequence as Seq
import Effect (Effect)
import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn1)
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
where
cpt props _ = do
let search = maybe defaultSearch identity (fst props.search)
term <- R.useState $ \_ ->
pure
search.term
db <- R.useState $ \_ ->
pure
Nothing
term <- R.useState $ \_ -> search.term
db <- R.useState $ \_ -> Nothing
pure $
div { className: "search-field input-group" }
[ databaseInput db props.databases
...
...
@@ -68,7 +68,7 @@ databaseInput (db /\ setDB) dbs =
liItem db = li { onClick }
[ a {href: "#"} [text (show db) ] ]
where
onClick = mkEffectFn1 $ \_ -> setDB
$ Just db
onClick = mkEffectFn1 $ \_ -> setDB
(const $ Just db)
dropdownBtnProps = { id: "search-dropdown"
, className: "btn btn-default dropdown-toggle"
, type: "button"} .= "data-toggle" $ "dropdown"
...
...
@@ -82,7 +82,7 @@ searchInput (term /\ setTerm) =
, type: "text"
, onChange
, 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
...
...
@@ -91,5 +91,5 @@ submitButton (database /\ _) (term /\ _) (_ /\ setSearch) =
where
click = mkEffectFn1 $ \_ -> do
case term of
"" -> setSearch
Nothing
_ -> setSearch
$ Just { database, term }
"" -> setSearch
(const Nothing)
_ -> 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
import Gargantext.Pages.Layout.Specs.SearchBar as SB
import Gargantext.Pages.Layout.States (AppState, _addCorpusState, _graphExplorerState, _loginState, _searchState)
import Gargantext.Router (Routes(..))
import Gargantext.Utils.Reactix
as R'
import Gargantext.Utils.Reactix
(scuff)
layoutSpec :: Spec AppState {} Action
layoutSpec =
...
...
@@ -180,7 +180,7 @@ searchBar = simpleSpec defaultPerformAction render
, div [ className "collapse navbar-collapse"
]
$ [ divDropdownLeft ]
<> [
R'.
scuff (SB.searchBar SB.defaultProps) ]
<> [ scuff (SB.searchBar SB.defaultProps) ]
<> [ divDropdownRight d s ]
]
]
...
...
src/Gargantext/Pages/Layout/Specs/SearchBar.purs
View file @
9661e284
...
...
@@ -15,7 +15,6 @@ import Thermite (Spec, defaultPerformAction, simpleSpec)
import Reactix as R
import DOM.Simple.Console
import Effect.Aff (launchAff)
import Gargantext.Utils.Reactix as R'
import Reactix.DOM.HTML as H
import Gargantext.Components.Search.Types
import Gargantext.Components.Search.Ajax as Ajax
...
...
@@ -35,8 +34,8 @@ searchBarComponent :: R.Component Props
searchBarComponent = R.hooksComponent "SearchBar" cpt
where
cpt props _ = do
open <- R.useState $
\_ -> pure $
props.open
search <- R.useState $
\_ -> pure
Nothing
open <- R.useState $
const
props.open
search <- R.useState $
const
Nothing
onSearchChange search
pure $ H.div { className: "search-bar-container" }
[ toggleButton open
...
...
@@ -50,7 +49,7 @@ searchFieldContainer (open /\ _) databases search =
onSearchChange :: R.State (Maybe Search) -> R.Hooks Unit
onSearchChange (search /\ setSearch) =
R
'.useLayoutEffect1' search $ \_ ->
traverse_ triggerSearch search
R
.useLayoutEffect1' search $
traverse_ triggerSearch search
where
triggerSearch q = do
launchAff $ do
...
...
@@ -68,4 +67,4 @@ toggleButton open =
[ H.text "control_point" ] ]
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_)
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Uncurried (mkEffectFn1)
import Effect.Uncurried (
EffectFn1,
mkEffectFn1)
import FFI.Simple ((...), defineProperty)
import React (ReactElement)
import Reactix as R
...
...
@@ -38,15 +38,11 @@ named :: forall o. String -> o -> o
named = flip $ defineProperty "name"
overState :: forall t. (t -> t) -> R.State t -> Effect Unit
overState f (state /\ setState) = setState $ f state
useLayoutEffect1' :: forall a. a -> (Unit -> Effect Unit) -> R.Hooks Unit
useLayoutEffect1' a f = R.useLayoutEffect1 a $ \_ ->
do f unit
pure $ \_ -> pure unit
overState f (_state /\ setState) = setState f
select :: ElemFactory
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