git.iko.soy/rowtype-yoga/ry-blocks
on e95bf02 help sign in
8 files changed+111−59
since splitsnapshots
unifiedsplit
packages.dhall−20 spago.dhall−1 src/React/Aria/Interactions.js+4 src/React/Aria/Interactions.purs+56 src/React/Aria/Utils.js+7 src/React/Aria/Utils.purs+19 src/Yoga/Block.purs−7 src/Yoga/Block/Atom/Select/View.purs+25−31
packages.dhall−20
@@ -172,23 +172,3 @@ in upstream
172172 [ "heterogeneous", "lists", "prelude", "record", "typelevel-prelude" ]
173173 }
174174 with react-basic-storybook = ../purescript-react-basic-storybook/spago.dhall as Location
175− with react-aria =
176− { repo = "https://github.com/rowtype-yoga/purescript-react-aria"
177− , version = "v0.2.0"
178− , dependencies =
179− [ "aff"
180− , "effect"
181− , "foreign"
182− , "foreign-object"
183− , "nullable"
184− , "ordered-collections"
185− , "prelude"
186− , "react-basic"
187− , "react-basic-dom"
188− , "react-basic-hooks"
189− , "unsafe-coerce"
190− , "untagged-union"
191− , "web-dom"
192− , "web-html"
193− ]
194− }
spago.dhall−1
@@ -36,7 +36,6 @@ You can edit this file as you like.
3636 , "prelude"
3737 , "profunctor-lenses"
3838 , "random"
39− , "react-aria"
4039 , "react-basic"
4140 , "react-basic-dom"
4241 , "react-basic-emotion"
src/React/Aria/Interactions.jsnew file+4
@@ -0,0 +1,4 @@
1+import { useFocusWithin, useFocus } from "@react-aria/interactions"
2+
3+export const useFocusWithinImpl = useFocusWithin
4+export const useFocusImpl = useFocus
src/React/Aria/Interactions.pursnew file+56
@@ -0,0 +1,56 @@
1+module React.Aria.Interactions where
2+
3+import Prelude
4+
5+import Effect.Uncurried (EffectFn1, runEffectFn1)
6+import Prim.Row (class Union)
7+import React.Basic.Events (EventHandler)
8+import React.Basic.Hooks (Hook, unsafeHook)
9+
10+-- UseFocusWithin
11+
12+type FocusWithinProps =
13+ ( isDisabled ∷ Boolean
14+ , onFocusWithin ∷ EventHandler
15+ , onBlurWithin ∷ EventHandler
16+ , onFocusWithinChange ∷ EffectFn1 Boolean Unit
17+ )
18+
19+type FocusWithinResult =
20+ { focusWithinProps ∷
21+ { onBlur ∷ EventHandler, onFocus ∷ EventHandler }
22+ }
23+
24+foreign import useFocusWithinImpl ∷ ∀ props. EffectFn1 props FocusWithinResult
25+
26+newtype UseFocusWithin a = UseFocusWithin a
27+
28+useFocusWithin
29+ ∷ ∀ props props_
30+ . Union props props_ FocusWithinProps
31+ ⇒ { | props }
32+ → Hook UseFocusWithin FocusWithinResult
33+useFocusWithin = unsafeHook <<< runEffectFn1 useFocusWithinImpl
34+
35+-- UseFocus
36+
37+type FocusProps =
38+ ( isDisabled ∷ Boolean
39+ , onFocus ∷ EventHandler
40+ , onBlur ∷ EventHandler
41+ , onFocusChange ∷ EffectFn1 Boolean Unit
42+ )
43+
44+type FocusResult =
45+ { focusProps ∷ { onBlur ∷ EventHandler, onFocus ∷ EventHandler } }
46+
47+foreign import useFocusImpl ∷ ∀ props. EffectFn1 props FocusResult
48+
49+newtype UseFocus a = UseFocus a
50+
51+useFocus
52+ ∷ ∀ props props_
53+ . Union props props_ FocusProps
54+ ⇒ { | props }
55+ → Hook UseFocus FocusResult
56+useFocus = unsafeHook <<< runEffectFn1 useFocusImpl
src/React/Aria/Utils.jsnew file+7
@@ -0,0 +1,7 @@
1+import { mergeProps, useId } from "@react-aria/utils"
2+
3+export function mergePropsImpl(args) {
4+ return mergeProps(...args)
5+}
6+
7+export const useIdImpl = useId
src/React/Aria/Utils.pursnew file+19
@@ -0,0 +1,19 @@
1+module React.Aria.Utils where
2+
3+import Foreign (Foreign, unsafeFromForeign, unsafeToForeign)
4+import Prim.Row (class Union)
5+import React.Basic.Hooks (Hook, unsafeHook)
6+import Effect (Effect)
7+
8+foreign import useIdImpl ∷ Effect String
9+
10+newtype UseId a = UseId a
11+
12+useId ∷ Hook UseId String
13+useId = unsafeHook useIdImpl
14+
15+foreign import mergePropsImpl ∷ Array Foreign → Foreign
16+
17+mergeProps ∷ ∀ r1 r2 r3. Union r1 r2 r3 ⇒ { | r1 } → { | r2 } → { | r3 }
18+mergeProps r1 r2 = unsafeFromForeign
19+ (mergePropsImpl [ unsafeToForeign r1, unsafeToForeign r2 ])
src/Yoga/Block.purs−7
@@ -10,7 +10,6 @@ import Yoga.Block.Atom.Icon as Icon
1010import Yoga.Block.Atom.Image as Image
1111import Yoga.Block.Atom.Input as Input
1212import Yoga.Block.Atom.Range as Range
13−import Yoga.Block.Atom.Select as Select
1413import Yoga.Block.Atom.Segmented as Segmented
1514import Yoga.Block.Atom.Toggle as Toggle
1615import Yoga.Block.Container as Container
@@ -153,12 +152,6 @@ layer = React.element layer'
153152range ∷ ∀ p q. Union p q Range.Props ⇒ ReactComponent { | p }
154153range = Range.component
155154
156−select' ∷ ∀ a. ReactComponent (Select.Props a)
157−select' = Select.component
158−
159−select ∷ ∀ a. (Select.Props a) → JSX
160−select = React.element select'
161−
162155segmented' ∷ ReactComponent Segmented.Props
163156segmented' = Segmented.component
164157
src/Yoga/Block/Atom/Select/View.purs+25−31
@@ -2,39 +2,33 @@ module Yoga.Block.Atom.Select.View where
22
33import Yoga.Prelude.View
44
5−import Data.Array as Array
65import Effect.Unsafe (unsafePerformEffect)
6+import Yoga.Block.Atom.Select.Style as Style
77import React.Basic.DOM as R
88import React.Basic.Hooks as React
9−import Yoga.Block.Atom.Select.Style as Style
109
11−type Props a =
12− { choice ∷ a
13− , choices ∷ Array a
14− , onChange ∷ a → Effect Unit
15− , toString ∷ a → String
16− , toValue ∷ a → String
17− }
18−
19−component ∷ ∀ a. ReactComponent (Props a)
10+component ∷
11+ ∀ a.
12+ ReactComponent
13+ ( { choice ∷ a
14+ , choices ∷ Array a
15+ , onChange ∷ Array a → Effect Unit
16+ , toString ∷ a → String
17+ , toValue ∷ a → String
18+ }
19+ )
2020component = unsafePerformEffect do
21− React.reactComponent "Select" \{ toString, toValue, choices, onChange } →
22− React.do
23− pure $
24− div "input-container" Style.container
25− [ R.select'
26− </*
27− { className: "select"
28− , role: "listbox"
29− , css: Style.select
30− , onChange: handler targetValue
31− \maybeVal → traverse_ onChange do
32− val ← maybeVal
33− choices # Array.find (toString >>> (_ == val))
34−
35− }
36− />
37− ( choices <#> \c → R.option' </ { value: toValue c } />
38− [ R.text $ toString c ]
39− )
40− ]
21+ React.reactComponent "Select" \{ toString, toValue, choices } → React.do
22+ pure $
23+ div "input-container" Style.container
24+ [ R.select'
25+ </*
26+ { className: "select"
27+ , role: "listbox"
28+ , css: Style.select
29+ }
30+ />
31+ ( choices <#> \c → R.option' </ { value: toValue c } />
32+ [ R.text $ toString c ]
33+ )
34+ ]