git.iko.soy/rowtype-yoga/purescript-radix-ui
on main help sign in
7 files changed+160−72
since splitsnapshots
unifiedsplit
.idea/misc.xml−1 src/RadixUI/Avatar.purs+23−13 src/RadixUI/Dialog.js−1 src/RadixUI/Dialog.purs+23−41 src/RadixUI/DropdownMenu.purs+7−5 src/RadixUI/HoverCard.js+5−5 src/RadixUI/HoverCard.purs+102−6
.idea/misc.xml−1
@@ -1,4 +1,3 @@
1−<?xml version="1.0" encoding="UTF-8"?>
21<project version="4">
32 <component name="ProjectRootManager">
43 <output url="file://$PROJECT_DIR$/out" />
src/RadixUI/Avatar.purs+23−13
@@ -1,18 +1,20 @@
11module RadixUI.Avatar where
22
33import Prelude
4−import React.Basic (JSX, ReactComponent)
4+
5+import Beta.DOM (class IsJSX)
6+import Beta.DOM (unsafeWithChildren)
7+import Beta.DOM.Internal (CSS)
8+import Beta.DOM.Internal (class IsJSX)
9+import Data.Time.Duration (Milliseconds)
510import Data.Undefined.NoProblem (Opt, pseudoMap)
611import Data.Undefined.NoProblem.Closed (class Coerce, coerce)
7−import React.Basic (element) as React
8−import Data.Time.Duration (Milliseconds)
912import Effect (Effect)
10−import Beta.DOM.Internal (CSS)
11−import Beta.DOM (class IsJSX)
12−import Effect.Uncurried (mkEffectFn1)
13+import Effect.Uncurried (EffectFn1, mkEffectFn1)
1314import Partial.Unsafe (unsafeCrashWith)
14−import Beta.DOM (unsafeWithChildren)
15−import Beta.DOM.Internal (class IsJSX)
15+import React.Basic (JSX, ReactComponent)
16+import React.Basic (element) as React
17+import Unsafe.Coerce (unsafeCoerce)
1618
1719foreign import rootImpl :: forall r. ReactComponent { | r }
1820foreign import imageImpl :: forall r. ReactComponent { | r }
@@ -20,6 +22,8 @@ foreign import fallbackImpl :: forall r. ReactComponent { | r }
2022
2123type RootProps =
2224 { asChild :: Opt Boolean
25+ , className :: Opt String
26+ , style :: Opt CSS
2327 }
2428
2529root :: forall p kids. Coerce p RootProps => IsJSX kids => p -> kids -> JSX
@@ -42,20 +46,26 @@ toImageLoadingStatus = case _ of
4246
4347type ImageProps =
4448 { asChild :: Opt Boolean
49+ , className :: Opt String
50+ , src :: Opt String
51+ , alt :: Opt String
52+ , style :: Opt CSS
4553 , onLoadingStatusChange :: Opt (ImageLoadingStatus -> Effect Unit)
4654 }
4755
48−image :: forall p kids. Coerce p ImageProps => IsJSX kids => p -> kids -> JSX
49−image props' kids = do
56+image :: forall p. Coerce p ImageProps => p -> JSX
57+image props' = do
5058 let props = coerce props' :: ImageProps
51− React.element imageImpl $ props
52− { onLoadingStatusChange = pseudoMap (mkEffectFn1 <<< (toImageLoadingStatus >>> _)) props.onLoadingStatusChange }
53− # unsafeWithChildren kids
59+ React.element imageImpl $ unsafeCoerce $ props
60+ { onLoadingStatusChange = pseudoMap (mkEffectFn1 <<< (toImageLoadingStatus >>> _)) props.onLoadingStatusChange :: Opt (EffectFn1 String Unit)
61+ }
5462
5563
5664type FallbackProps =
5765 { asChild :: Opt Boolean
5866 , delayMs :: Opt Milliseconds
67+ , className :: Opt String
68+ , style :: Opt CSS
5969 }
6070
6171fallback :: forall p kids. Coerce p FallbackProps => IsJSX kids => p -> kids -> JSX
src/RadixUI/Dialog.js−1
@@ -7,5 +7,4 @@ export const descriptionImpl = Dialog.Description;
77export const triggerImpl = Dialog.Trigger;
88export const closeImpl = Dialog.Close;
99export const rootImpl = Dialog.Root;
10−export const actionImpl = Dialog.Action;
1110export const portalImpl = Dialog.Portal;
src/RadixUI/Dialog.purs+23−41
@@ -25,16 +25,17 @@ type RootProps =
2525 }
2626
2727x = React.element
28+
2829-- | The foreign component for the Dialog
2930foreign import rootImpl ∷ ∀ a. ReactComponent { | a }
3031
3132-- | A PureScript wrapper for the Dialog component
32−root ∷
33− ∀ p.
34− Coerce p RootProps ⇒
35− p →
36− Array JSX →
37− JSX
33+root
34+ ∷ ∀ p
35+ . Coerce p RootProps
36+ ⇒ p
37+ → Array JSX
38+ → JSX
3839root props kids = React.element rootImpl $
3940 (coerce props ∷ RootProps) # RB.build
4041 ( RB.modify (Proxy ∷ _ "onOpenChange") (pseudoMap mkEffectFn1)
@@ -51,8 +52,8 @@ type DialogTriggerProps =
5152foreign import triggerImpl ∷ ∀ a. ReactComponent { | a }
5253
5354-- | A PureScript wrapper for the DialogTrigger component
54−trigger ∷
55− ∀ p kids. Coerce p DialogTriggerProps ⇒ IsJSX kids ⇒ p → kids → JSX
55+trigger
56+ ∷ ∀ p kids. Coerce p DialogTriggerProps ⇒ IsJSX kids ⇒ p → kids → JSX
5657trigger props kids = React.element triggerImpl $
5758 (coerce props ∷ DialogTriggerProps) # RB.build
5859 ( RB.insert (Proxy ∷ _ "children") kids
@@ -60,18 +61,16 @@ trigger props kids = React.element triggerImpl $
6061
6162-- | The type of the DialogPortal component props
6263type DialogPortalProps =
63− { forceMount ∷
64− Opt Boolean -- ^ Whether to force mount the alert dialog portal in the DOM even when it is not open
65− , container ∷
66− Opt HTMLElement -- ^ The container element to mount the alert dialog portal into
64+ { forceMount ∷ Opt Boolean -- ^ Whether to force mount the alert dialog portal in the DOM even when it is not open
65+ , container ∷ Opt HTMLElement -- ^ The container element to mount the alert dialog portal into
6766 }
6867
6968-- | The foreign component for the DialogPortal
7069foreign import portalImpl ∷ ∀ a. ReactComponent { | a }
7170
7271-- | A PureScript wrapper for the DialogPortal component
73−portal ∷
74− ∀ p kids. Coerce p DialogPortalProps ⇒ IsJSX kids ⇒ p → kids → JSX
72+portal
73+ ∷ ∀ p kids. Coerce p DialogPortalProps ⇒ IsJSX kids ⇒ p → kids → JSX
7574portal props kids = React.element portalImpl $
7675 (coerce props ∷ DialogPortalProps) # RB.build
7776 ( RB.insert (Proxy ∷ _ "children") kids
@@ -91,8 +90,8 @@ type DialogOverlayProps =
9190foreign import overlayImpl ∷ ∀ a. ReactComponent { | a }
9291
9392-- | A PureScript wrapper for the DialogOverlay component
94−overlay ∷
95− ∀ p kids. Coerce p DialogOverlayProps ⇒ IsJSX kids ⇒ p → kids → JSX
93+overlay
94+ ∷ ∀ p kids. Coerce p DialogOverlayProps ⇒ IsJSX kids ⇒ p → kids → JSX
9695overlay props kids = React.element overlayImpl $
9796 (coerce props ∷ DialogOverlayProps) # RB.build
9897 ( RB.insert (Proxy ∷ _ "children") kids
@@ -118,8 +117,8 @@ type DialogContentProps =
118117foreign import contentImpl ∷ ∀ a. ReactComponent { | a }
119118
120119-- | A PureScript wrapper for the DialogContent component
121−content ∷
122− ∀ p kids. Coerce p DialogContentProps ⇒ IsJSX kids ⇒ p → kids → JSX
120+content
121+ ∷ ∀ p kids. Coerce p DialogContentProps ⇒ IsJSX kids ⇒ p → kids → JSX
123122content props kids = React.element contentImpl $
124123 (coerce props ∷ DialogContentProps) # RB.build
125124 (
@@ -136,23 +135,6 @@ type DialogCancelProps =
136135 Opt Boolean -- ^ Whether to render the alert dialog cancel button as a child of the dialog content
137136 }
138137
139−-- | The type of the DialogAction component props
140−type DialogActionProps =
141− { asChild ∷
142− Opt Boolean -- ^ Whether to render the alert dialog action button as a child of the dialog content
143− }
144−
145−-- | The foreign component for the DialogAction
146−foreign import actionImpl ∷ ∀ a. ReactComponent { | a }
147−
148−-- | A PureScript wrapper for the DialogAction component
149−action ∷
150− ∀ p kids. Coerce p DialogActionProps ⇒ IsJSX kids ⇒ p → kids → JSX
151−action props kids = React.element actionImpl $
152− (coerce props ∷ DialogActionProps) # RB.build
153− ( RB.insert (Proxy ∷ _ "children") kids
154− )
155−
156138-- | The type of the DialogTitle component props
157139type DialogTitleProps =
158140 { asChild ∷
@@ -165,8 +147,8 @@ type DialogTitleProps =
165147foreign import titleImpl ∷ ∀ a. ReactComponent { | a }
166148
167149-- | A PureScript wrapper for the DialogTitle component
168−title ∷
169− ∀ p kids. Coerce p DialogTitleProps ⇒ IsJSX kids ⇒ p → kids → JSX
150+title
151+ ∷ ∀ p kids. Coerce p DialogTitleProps ⇒ IsJSX kids ⇒ p → kids → JSX
170152title props kids = React.element titleImpl $
171153 (coerce props ∷ DialogTitleProps) # RB.build
172154 ( RB.insert (Proxy ∷ _ "children") kids
@@ -185,8 +167,8 @@ type DialogDescriptionProps =
185167foreign import descriptionImpl ∷ ∀ a. ReactComponent { | a }
186168
187169-- | A PureScript wrapper for the DialogDescription component
188−description ∷
189− ∀ p kids. Coerce p DialogDescriptionProps ⇒ IsJSX kids ⇒ p → kids → JSX
170+description
171+ ∷ ∀ p kids. Coerce p DialogDescriptionProps ⇒ IsJSX kids ⇒ p → kids → JSX
190172description props kids = React.element descriptionImpl $
191173 (coerce props ∷ DialogDescriptionProps) # RB.build
192174 ( RB.insert (Proxy ∷ _ "children") kids
@@ -205,8 +187,8 @@ type DialogCloseProps =
205187foreign import closeImpl ∷ ∀ a. ReactComponent { | a }
206188
207189-- | A PureScript wrapper for the DialogClose component
208−close ∷
209− ∀ p kids. Coerce p DialogCloseProps ⇒ IsJSX kids ⇒ p → kids → JSX
190+close
191+ ∷ ∀ p kids. Coerce p DialogCloseProps ⇒ IsJSX kids ⇒ p → kids → JSX
210192close props kids = React.element closeImpl $
211193 (coerce props ∷ DialogCloseProps) # RB.build
212194 ( RB.insert (Proxy ∷ _ "children") kids
src/RadixUI/DropdownMenu.purs+7−5
@@ -9,7 +9,7 @@ import Effect.Uncurried (EffectFn1, mkEffectFn1)
99import Prim.Row (class Union)
1010import React.Basic (JSX, ReactComponent)
1111import React.Basic (element) as React
12−import React.Basic.Events (SyntheticEvent)
12+import React.Basic.Events (EventHandler, SyntheticEvent)
1313import Record.Builder (build, insert, modify) as RB
1414import Record.Unsafe (unsafeSet)
1515import Record.Unsafe.Union (unsafeUnion)
@@ -86,9 +86,10 @@ content props kids = React.element contentImpl
8686type DropdownMenuItemProps =
8787 { disabled :: Opt Boolean -- ^ Whether the menu item is disabled or not
8888 , onSelect ::
89− Opt (SyntheticEvent -> Effect Unit) -- ^ A callback function that is called when the menu item is selected by a pointer or keyboard event
89+ Opt EventHandler -- ^ A callback function that is called when the menu item is selected by a pointer or keyboard event
9090 , className :: Opt String -- ^ The CSS class name of the menu item
9191 , style :: Opt CSS -- ^ The CSS style of the menu item
92+ , asChild :: Opt Boolean
9293 }
9394
9495-- | The foreign component for the DropdownMenuItem
@@ -98,9 +99,9 @@ foreign import itemImpl :: forall a. ReactComponent { | a }
9899item :: forall p kids. Coerce p DropdownMenuItemProps => IsJSX kids => p -> kids -> JSX
99100item props kids = React.element itemImpl
100101 $ (coerce props :: DropdownMenuItemProps) # RB.build
101− ( RB.modify (Proxy :: _ "onSelect") (pseudoMap mkEffectFn1)
102− <<< RB.insert (Proxy :: _ "children") kids
103− )
102+-- ( RB.modify (Proxy :: _ "onSelect") (pseudoMap mkEffectFn1) <<<
103+ (RB.insert (Proxy :: _ "children") kids)
104+-- )
104105
105106-- | The type of the DropdownMenuItemIndicator component props
106107type DropdownMenuItemIndicatorProps =
@@ -247,6 +248,7 @@ separator props = React.element separatorImpl
247248type DropdownMenuArrowProps =
248249 { className :: Opt String -- ^ The CSS class name of the menu arrow
249250 , style :: Opt CSS -- ^ The CSS style of the menu arrow
251+ , asChild :: Opt Boolean -- ^ Whether to render the menu arrow as a child of the menu content
250252 }
251253
252254-- | The foreign component for the DropdownMenuArrow
src/RadixUI/HoverCard.js+5−5
@@ -1,7 +1,7 @@
11import * as HoverCard from '@radix-ui/react-hover-card';
22
3−export const hoverCardRoot = HoverCard.Root;
4−export const hoverCardTrigger = HoverCard.Trigger;
5−export const hoverCardContent = HoverCard.Content;
6−export const hoverCardArrow = HoverCard.Arrow;
7−export const hoverCardPortal = HoverCard.Portal;
3+export const contentImpl = HoverCard.Content;
4+export const arrowImpl = HoverCard.Arrow;
5+export const portalImpl = HoverCard.Portal;
6+export const triggerImpl = HoverCard.Trigger;
7+export const rootImpl = HoverCard.Root;
src/RadixUI/HoverCard.purs+102−6
@@ -2,10 +2,106 @@
22module RadixUI.HoverCard where
33
44import Prelude
5−import React.Basic (ReactComponent)
65
7−foreign import hoverCardRoot :: forall r. ReactComponent { | r }
8−foreign import hoverCardTrigger :: forall r. ReactComponent { | r }
9−foreign import hoverCardContent :: forall r. ReactComponent { | r }
10−foreign import hoverCardArrow :: forall r. ReactComponent { | r }
11−foreign import hoverCardPortal :: forall r. ReactComponent { | r }
6+import Data.Undefined.NoProblem (Opt, pseudoMap)
7+import Data.Undefined.NoProblem.Closed (class Coerce, coerce)
8+import Effect (Effect)
9+import Effect.Uncurried (EffectFn1, mkEffectFn1)
10+import Prim.Row (class Union)
11+import React.Basic (JSX, ReactComponent)
12+import React.Basic (element) as React
13+import React.Basic.Events (EventHandler, SyntheticEvent)
14+import Record.Builder (build, insert, modify) as RB
15+import Record.Unsafe (unsafeSet)
16+import Record.Unsafe.Union (unsafeUnion)
17+import Type.Proxy (Proxy(Proxy))
18+import Data.Tuple.Nested ((/\))
19+import Control.Monad.Identity.Trans (runIdentityT)
20+import Beta.DOM.Internal (CSS)
21+import Beta.DOM (class IsJSX)
22+import Data.Time.Duration (Milliseconds)
23+import Web.HTML.HTMLElement (HTMLElement)
24+
25+-- The type of the HoverCard component props
26+type RootProps =
27+ { open :: Opt Boolean -- ^ Whether the HoverCard is open or not
28+ , onOpenChange ::
29+ Opt (Boolean -> Effect Unit) -- ^ A callback function that is called when the HoverCard open state changes
30+ , className :: Opt String -- ^ The CSS class name of the HoverCard
31+ , openDelay :: Opt Milliseconds -- ^ The duration from when the mouse enters the trigger until the hover card opens
32+ , closeDelay :: Opt Milliseconds -- ^ The duration from when the mouse leaves the trigger until the hover card closes
33+ , style :: Opt CSS -- ^ The CSS style of the HoverCard
34+ }
35+
36+-- The foreign component for the HoverCard
37+foreign import rootImpl :: forall a. ReactComponent { | a }
38+
39+-- A PureScript wrapper for the HoverCard component
40+root :: forall p. Coerce p RootProps => p -> Array JSX -> JSX
41+root props kids = React.element rootImpl
42+ $ (coerce props :: RootProps) # RB.build
43+ ( RB.modify (Proxy :: _ "onOpenChange") (pseudoMap mkEffectFn1)
44+ <<< RB.insert (Proxy :: _ "children") kids
45+ )
46+
47+type HoverCardContentProps =
48+ { className :: Opt String -- ^ The CSS class name of the HoverCard content
49+ , style :: Opt CSS -- ^ The CSS style of the HoverCard content
50+ }
51+
52+-- The foreign component for the HoverCardContent
53+foreign import contentImpl :: forall a. ReactComponent { | a }
54+
55+-- A PureScript wrapper for the HoverCardContent component
56+content :: forall p kids. IsJSX kids => Coerce p HoverCardContentProps => p -> kids -> JSX
57+content props kids = React.element contentImpl
58+ $ (coerce props :: HoverCardContentProps) # RB.build
59+ ( RB.insert (Proxy :: _ "children") kids
60+ )
61+
62+-- The type of the HoverCardTrigger component props
63+type HoverCardTriggerProps =
64+ { className :: Opt String -- ^ The CSS class name of the HoverCard trigger
65+ , style :: Opt CSS -- ^ The CSS style of the HoverCard trigger
66+ }
67+
68+-- The foreign component for the HoverCardTrigger
69+foreign import triggerImpl :: forall a. ReactComponent { | a }
70+
71+-- A PureScript wrapper for the HoverCardTrigger component
72+trigger ::
73+ forall p kids. Coerce p HoverCardTriggerProps => IsJSX kids => p -> kids -> JSX
74+trigger props kids = React.element triggerImpl
75+ $ (coerce props :: HoverCardTriggerProps) # RB.build
76+ ( RB.insert (Proxy :: _ "children") kids
77+ )
78+
79+-- The type of the arrow component props
80+type HoverCardArrowProps =
81+ { className :: Opt String -- ^ The CSS class name of the HoverCard arrow
82+ , style :: Opt CSS -- ^ The CSS style of the HoverCard arrow
83+ }
84+
85+-- The foreign component for the HoverCard arrow
86+foreign import arrowImpl :: forall a. ReactComponent { | a }
87+
88+-- A PureScript wrapper for the HoverCard arrow component
89+arrow ∷ ∀ p kids. IsJSX kids => Coerce p HoverCardArrowProps ⇒ p → kids -> JSX
90+arrow props kids = React.element arrowImpl
91+ $ (coerce props ∷ HoverCardArrowProps) # RB.build
92+ ( RB.insert (Proxy :: Proxy "children") kids)
93+
94+-- The type of the portal component props
95+type HoverCardPortalProps =
96+ { container :: Opt HTMLElement -- ^ The DOM element to render the portal into
97+ }
98+
99+-- The foreign component for the HoverCard portal
100+foreign import portalImpl :: forall a. ReactComponent { | a }
101+
102+-- A PureScript wrapper for the HoverCardPortal component
103+portal ::
104+ forall p kids. Coerce p HoverCardPortalProps => IsJSX kids => p -> kids -> JSX
105+portal props kids = React.element portalImpl
106+ $ (coerce props :: HoverCardPortalProps) #
107+ unsafeSet "children" kids