@@ -2,10 +2,101 @@
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+
23+-- The type of the HoverCard component props
24+type RootProps =
25+ { open :: Opt Boolean -- ^ Whether the HoverCard is open or not
26+ , onOpenChange ::
27+ Opt (Boolean -> Effect Unit) -- ^ A callback function that is called when the HoverCard open state changes
28+ , className :: Opt String -- ^ The CSS class name of the HoverCard
29+ , style :: Opt CSS -- ^ The CSS style of the HoverCard
30+ }
31+
32+-- The foreign component for the HoverCard
33+foreign import rootImpl :: forall a. ReactComponent { | a }
34+
35+-- A PureScript wrapper for the HoverCard component
36+root :: forall p. Coerce p RootProps => p -> Array JSX -> JSX
37+root props kids = React.element rootImpl
38+ $ (coerce props :: RootProps) # RB.build
39+ ( RB.modify (Proxy :: _ "onOpenChange") (pseudoMap mkEffectFn1)
40+ <<< RB.insert (Proxy :: _ "children") kids
41+ )
42+
43+type HoverCardContentProps =
44+ { className :: Opt String -- ^ The CSS class name of the HoverCard content
45+ , style :: Opt CSS -- ^ The CSS style of the HoverCard content
46+ }
47+
48+-- The foreign component for the HoverCardContent
49+foreign import contentImpl :: forall a. ReactComponent { | a }
50+
51+-- A PureScript wrapper for the HoverCardContent component
52+content :: forall p kids. IsJSX kids => Coerce p HoverCardContentProps => p -> kids -> JSX
53+content props kids = React.element contentImpl
54+ $ (coerce props :: HoverCardContentProps) # RB.build
55+ ( RB.insert (Proxy :: _ "children") kids
56+ )
57+
58+-- The type of the HoverCardTrigger component props
59+type HoverCardTriggerProps =
60+ { className :: Opt String -- ^ The CSS class name of the HoverCard trigger
61+ , style :: Opt CSS -- ^ The CSS style of the HoverCard trigger
62+ }
63+
64+-- The foreign component for the HoverCardTrigger
65+foreign import triggerImpl :: forall a. ReactComponent { | a }
66+
67+-- A PureScript wrapper for the HoverCardTrigger component
68+trigger ::
69+ forall p kids. Coerce p HoverCardTriggerProps => IsJSX kids => p -> kids -> JSX
70+trigger props kids = React.element triggerImpl
71+ $ (coerce props :: HoverCardTriggerProps) # RB.build
72+ ( RB.insert (Proxy :: _ "children") kids
73+ )
74+
75+-- The type of the arrow component props
76+type HoverCardArrowProps =
77+ { className :: Opt String -- ^ The CSS class name of the HoverCard arrow
78+ , style :: Opt CSS -- ^ The CSS style of the HoverCard arrow
79+ }
80+
81+-- The foreign component for the HoverCard arrow
82+foreign import arrowImpl :: forall a. ReactComponent { | a }
83+
84+-- A PureScript wrapper for the HoverCard arrow component
85+arrow ∷ ∀ p kids. IsJSX kids => Coerce p HoverCardArrowProps ⇒ p → kids -> JSX
86+arrow props kids = React.element arrowImpl
87+ $ (coerce props ∷ HoverCardArrowProps) # RB.build
88+ ( RB.insert (Proxy :: Proxy "children") kids)
89+
90+-- The type of the portal component props
91+type HoverCardPortalProps =
92+ {}
93+
94+-- The foreign component for the HoverCard portal
95+foreign import portalImpl :: forall a. ReactComponent { | a }
96+
97+-- A PureScript wrapper for the HoverCardPortal component
98+portal ::
99+ forall p kids. Coerce p HoverCardPortalProps => IsJSX kids => p -> kids -> JSX
100+portal props kids = React.element portalImpl
101+ $ (coerce props :: HoverCardPortalProps) #
102+ unsafeSet "children" kids