@@ -0,0 +1,326 @@
1+module RadixUI.DropdownMenu where
2+
3+import Prelude
4+
5+import Data.Undefined.NoProblem (Opt, pseudoMap)
6+import Data.Undefined.NoProblem.Closed (class Coerce, coerce)
7+import Effect (Effect)
8+import Effect.Uncurried (EffectFn1, mkEffectFn1)
9+import Prim.Row (class Union)
10+import React.Basic (JSX, ReactComponent)
11+import React.Basic (element) as React
12+import React.Basic.Events (SyntheticEvent)
13+import Record.Builder (build, insert, modify) as RB
14+import Record.Unsafe (unsafeSet)
15+import Record.Unsafe.Union (unsafeUnion)
16+import Type.Proxy (Proxy(Proxy))
17+import Data.Tuple.Nested ((/\))
18+import Control.Monad.Identity.Trans (runIdentityT)
19+import Beta.DOM.Internal (CSS)
20+import Beta.DOM (class IsJSX)
21+
22+
23+-- | The type of the DropdownMenu component props
24+type RootProps =
25+ { open :: Opt Boolean -- ^ Whether the menu is open or not
26+ , onOpenChange ::
27+ Opt (Boolean -> Effect Unit) -- ^ A callback function that is called when the menu open state changes
28+ , className :: Opt String -- ^ The CSS class name of the menu
29+ , style :: Opt CSS -- ^ The CSS style of the menu
30+ }
31+
32+-- | The foreign component for the DropdownMenu
33+foreign import rootImpl :: forall a. ReactComponent { | a }
34+
35+-- | A PureScript wrapper for the DropdownMenu 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+-- | The type of the DropdownMenuContent component props
44+type DropdownMenuContentProps =
45+ { side ::
46+ Opt String -- ^ The preferred side of the menu content relative to the trigger
47+ , sideOffset ::
48+ Opt Number -- ^ The offset in pixels from the trigger to the menu content on the side axis
49+ , align ::
50+ Opt String -- ^ The preferred alignment of the menu content relative to the trigger on the side axis
51+ , alignOffset ::
52+ Opt Number -- ^ The offset in pixels from the trigger to the menu content on the align axis
53+ , disableOutsidePointerEvents ::
54+ Opt Boolean -- ^ Whether to disable pointer events outside of the menu content
55+ , onEscapeKeyDown ::
56+ Opt (Effect Unit) -- ^ A callback function that is called when the escape key is pressed while the menu content is focused
57+ , onPointerDownOutside ::
58+ Opt (Effect Unit) -- ^ A callback function that is called when a pointer event occurs outside of the menu content
59+ , onFocusOutside ::
60+ Opt (Effect Unit) -- ^ A callback function that is called when a focus event occurs outside of the menu content
61+ , onInteractOutside ::
62+ Opt (Effect Unit) -- ^ A callback function that is called when an interaction event occurs outside of the menu content
63+ , forceMount ::
64+ Opt Boolean -- ^ Whether to force mount the menu content in the DOM even when it is not open
65+ , className :: Opt String -- ^ The CSS class name of the menu content
66+ , style :: Opt CSS -- ^ The CSS style of the menu content
67+ }
68+
69+-- | The foreign component for the DropdownMenuContent
70+foreign import contentImpl :: forall a. ReactComponent { | a }
71+
72+-- | A PureScript wrapper for the DropdownMenuContent component
73+content :: forall p. Coerce p DropdownMenuContentProps => p -> Array JSX -> JSX
74+content props kids = React.element contentImpl
75+ $ (coerce props :: DropdownMenuContentProps) # RB.build
76+ (
77+ -- RB.modify (Proxy ∷ _ "onEscapeKeyDown") (pseudoMap mkEffectFn1)
78+ -- <<< RB.modify (Proxy ∷ _ "onPointerDownOutside") (pseudoMap mkEffectFn1)
79+ -- <<< RB.modify (Proxy ∷ _ "onFocusOutside") (pseudoMap mkEffectFn1)
80+ -- <<< RB.modify (Proxy ∷ _ "onInteractOutside") (pseudoMap mkEffectFn1)
81+ -- <<<
82+ RB.insert (Proxy :: _ "children") kids
83+ )
84+
85+-- | The type of the DropdownMenuItem component props
86+type DropdownMenuItemProps =
87+ { disabled :: Opt Boolean -- ^ Whether the menu item is disabled or not
88+ , onSelect ::
89+ Opt (SyntheticEvent -> Effect Unit) -- ^ A callback function that is called when the menu item is selected by a pointer or keyboard event
90+ , className :: Opt String -- ^ The CSS class name of the menu item
91+ , style :: Opt CSS -- ^ The CSS style of the menu item
92+ }
93+
94+-- | The foreign component for the DropdownMenuItem
95+foreign import itemImpl :: forall a. ReactComponent { | a }
96+
97+-- | A PureScript wrapper for the DropdownMenuItem component
98+item :: forall p kids. Coerce p DropdownMenuItemProps => IsJSX kids => p -> kids -> JSX
99+item props kids = React.element itemImpl
100+ $ (coerce props :: DropdownMenuItemProps) # RB.build
101+ ( RB.modify (Proxy :: _ "onSelect") (pseudoMap mkEffectFn1)
102+ <<< RB.insert (Proxy :: _ "children") kids
103+ )
104+
105+-- | The type of the DropdownMenuItemIndicator component props
106+type DropdownMenuItemIndicatorProps =
107+ { className :: Opt String -- ^ The CSS class name of the menu item indicator
108+ , style :: Opt CSS -- ^ The CSS style of the menu item indicator
109+ }
110+
111+-- | The foreign component for the DropdownMenuItemIndicator
112+foreign import itemIndicatorImpl :: forall a. ReactComponent { | a }
113+
114+-- | A PureScript wrapper for the DropdownMenuItemIndicator component
115+itemIndicator ::
116+ forall p kids.
117+ Coerce p DropdownMenuItemIndicatorProps =>
118+ IsJSX kids =>
119+ p ->
120+ kids ->
121+ JSX
122+itemIndicator props kids = React.element itemIndicatorImpl
123+ $ (coerce props :: DropdownMenuItemIndicatorProps) # RB.build
124+ ( RB.insert (Proxy :: _ "children") kids
125+ )
126+
127+-- | The type of the DropdownMenuTrigger component props
128+type DropdownMenuTriggerProps =
129+ { className :: Opt String -- ^ The CSS class name of the menu trigger
130+ , style :: Opt CSS -- ^ The CSS style of the menu trigger
131+ , asChild ::
132+ Opt Boolean -- ^ Whether to render the menu trigger as a child of the menu content
133+ }
134+
135+-- | The foreign component for the DropdownMenuTrigger
136+foreign import triggerImpl :: forall a. ReactComponent { | a }
137+
138+-- | A PureScript wrapper for the DropdownMenuTrigger component
139+trigger ::
140+ forall p kids. Coerce p DropdownMenuTriggerProps => IsJSX kids => p -> kids -> JSX
141+trigger props kids = React.element triggerImpl
142+ $ (coerce props :: DropdownMenuTriggerProps) # RB.build
143+ ( RB.insert (Proxy :: _ "children") kids
144+ )
145+
146+-- | The type of the DropdownMenuGroup component props
147+type DropdownMenuGroupProps = {}
148+
149+-- | The foreign component for the DropdownMenuGroup
150+foreign import groupImpl :: forall a. ReactComponent { | a }
151+
152+-- | A PureScript wrapper for the DropdownMenuGroup component
153+group :: forall p. Coerce p DropdownMenuGroupProps => p -> Array JSX -> JSX
154+group props kids = React.element groupImpl
155+ $ (coerce props :: DropdownMenuGroupProps) # RB.build
156+ ( RB.insert (Proxy :: _ "children") kids
157+ )
158+
159+-- | The type of the DropdownMenuLabel component props
160+type DropdownMenuLabelProps =
161+ { className :: Opt String -- ^ The CSS class name of the menu label
162+ , style :: Opt CSS -- ^ The CSS style of the menu label
163+ }
164+
165+-- | The foreign component for the DropdownMenuLabel
166+foreign import labelImpl :: forall a. ReactComponent { | a }
167+
168+-- | A PureScript wrapper for the DropdownMenuLabel component
169+label :: forall p kids. Coerce p DropdownMenuLabelProps => IsJSX kids => p -> kids -> JSX
170+label props kids = React.element labelImpl
171+ $ (coerce props :: DropdownMenuLabelProps) # RB.build
172+ ( RB.insert (Proxy :: _ "children") kids
173+ )
174+
175+-- | The type of the DropdownMenuCheckboxItem component props
176+type DropdownMenuCheckboxItemProps =
177+ { checked :: Opt Boolean -- ^ Whether the menu checkbox item is checked or not
178+ , onCheckedChange ::
179+ Opt (Boolean -> Effect Unit) -- ^ A callback function that is called when the menu checkbox item checked state changes
180+ , className :: Opt String -- ^ The CSS class name of the menu checkbox item
181+ , style :: Opt CSS -- ^ The CSS style of the menu checkbox item
182+ }
183+
184+-- | The foreign component for the DropdownMenuCheckboxItem
185+foreign import checkboxItemImpl :: forall a. ReactComponent { | a }
186+
187+-- | A PureScript wrapper for the DropdownMenuCheckboxItem component
188+checkboxItem :: forall p. Coerce p DropdownMenuCheckboxItemProps => p -> Array JSX -> JSX
189+checkboxItem props kids = React.element checkboxItemImpl
190+ $ (coerce props :: DropdownMenuCheckboxItemProps) # RB.build
191+ ( RB.modify (Proxy :: _ "onCheckedChange") (pseudoMap mkEffectFn1)
192+ <<< RB.insert (Proxy :: _ "children") kids
193+ )
194+
195+-- | The type of the DropdownMenuRadioGroup component props
196+type DropdownMenuRadioGroupProps =
197+ { value ::
198+ Opt String -- ^ The value of the selected menu radio item in the group
199+ , onValueChange ::
200+ Opt (String -> Effect Unit) -- ^ A callback function that is called when the value of the selected menu radio item in the group changes
201+ }
202+
203+-- | The foreign component for the DropdownMenuRadioGroup
204+foreign import radioGroupImpl :: forall a. ReactComponent { | a }
205+
206+-- | A PureScript wrapper for the DropdownMenuRadioGroup component
207+radioGroup :: forall p. Coerce p DropdownMenuRadioGroupProps => p -> Array JSX -> JSX
208+radioGroup props' kids = do
209+ let props = coerce props' :: DropdownMenuRadioGroupProps
210+ React.element radioGroupImpl
211+ $ props # unsafeUnion
212+ { onValueChange: pseudoMap mkEffectFn1 props.onValueChange
213+ , children: kids
214+ }
215+
216+-- | The type of the DropdownMenuRadioItem component props
217+type DropdownMenuRadioItemProps =
218+ { value :: String -- ^ The value of the menu radio item
219+ , className :: Opt String -- ^ The CSS class name of the menu radio item
220+ , style :: Opt CSS -- ^ The CSS style of the menu radio item
221+ }
222+
223+-- | The foreign component for the DropdownMenuRadioItem
224+foreign import radioItemImpl :: forall a. ReactComponent { | a }
225+
226+-- | A PureScript wrapper for the DropdownMenuRadioItem component
227+radioItem :: forall p. Coerce p DropdownMenuRadioItemProps => p -> Array JSX -> JSX
228+radioItem props kids = React.element radioItemImpl
229+ $ (coerce props :: DropdownMenuRadioItemProps) #
230+ unsafeSet "children" kids
231+
232+-- | The type of the DropdownMenuSeparator component props
233+type DropdownMenuSeparatorProps =
234+ { className :: Opt String -- ^ The CSS class name of the menu separator
235+ , style :: Opt CSS -- ^ The CSS style of the menu separator
236+ }
237+
238+-- | The foreign component for the DropdownMenuSeparator
239+foreign import separatorImpl :: forall a. ReactComponent { | a }
240+
241+-- | A PureScript wrapper for the DropdownMenuSeparator component
242+separator :: forall p. Coerce p DropdownMenuSeparatorProps => p -> JSX
243+separator props = React.element separatorImpl
244+ $ (coerce props :: DropdownMenuSeparatorProps)
245+
246+-- | The type of the DropdownMenuArrow component props
247+type DropdownMenuArrowProps =
248+ { className :: Opt String -- ^ The CSS class name of the menu arrow
249+ , style :: Opt CSS -- ^ The CSS style of the menu arrow
250+ }
251+
252+-- | The foreign component for the DropdownMenuArrow
253+foreign import arrowImpl :: forall a. ReactComponent { | a }
254+
255+-- | A PureScript wrapper for the DropdownMenuArrow component
256+arrow :: forall p. Coerce p DropdownMenuArrowProps => p -> JSX
257+arrow props = React.element arrowImpl
258+ $ (coerce props :: DropdownMenuArrowProps)
259+
260+-- | The type of the DropdownMenuSub component props
261+type DropdownMenuSubProps =
262+ { className :: Opt String }
263+
264+-- | The foreign component for the DropdownMenuSub
265+foreign import subImpl :: forall a. ReactComponent { | a }
266+
267+-- | A PureScript wrapper for the DropdownMenuSub component
268+sub :: forall p. Coerce p DropdownMenuSubProps => p -> Array JSX -> JSX
269+sub props kids = React.element subImpl
270+ $ (coerce props :: DropdownMenuSubProps) #
271+ unsafeSet "children" kids
272+
273+-- | The type of the DropdownMenuSubTrigger component props
274+type DropdownMenuSubTriggerProps =
275+ { className :: Opt String -- ^ The CSS class name of the menu sub trigger
276+ , style :: Opt CSS -- ^ The CSS style of the menu sub trigger
277+ }
278+
279+-- | The foreign component for the DropdownMenuSubTrigger
280+foreign import subTriggerImpl :: forall a. ReactComponent { | a }
281+
282+-- | A PureScript wrapper for the DropdownMenuSubTrigger component
283+subTrigger ::
284+ forall p kids. Coerce p DropdownMenuSubTriggerProps => IsJSX kids => p -> kids -> JSX
285+subTrigger props kids = React.element subTriggerImpl
286+ $ (coerce props :: DropdownMenuSubTriggerProps) #
287+ unsafeSet "children" kids
288+
289+-- | The type of the DropdownMenuSubContent component props
290+type DropdownMenuSubContentProps =
291+ { side ::
292+ Opt String -- ^ The preferred side of the menu sub content relative to the trigger
293+ , sideOffset ::
294+ Opt Number -- ^ The offset in pixels from the trigger to the menu sub content on the side axis
295+ , align ::
296+ Opt String -- ^ The preferred alignment of the menu sub content relative to the trigger on the side axis
297+ , alignOffset ::
298+ Opt Number -- ^ The offset in pixels from the trigger to the menu sub content on the align axis
299+ , className :: Opt String -- ^ The CSS class name of the menu sub content
300+ , style :: Opt CSS -- ^ The CSS style of the menu sub content
301+ }
302+
303+-- | The foreign component for the DropdownMenuSubContent
304+foreign import subContentImpl :: forall a. ReactComponent { | a }
305+
306+-- | A PureScript wrapper for the DropdownMenuSubContent component
307+subContent ::
308+ forall p kids. Coerce p DropdownMenuSubContentProps => IsJSX kids => p -> kids -> JSX
309+subContent props children = React.element subContentImpl
310+ $ (coerce props :: DropdownMenuSubContentProps) #
311+ unsafeUnion { children }
312+
313+-- | The type of the DropdownMenuPortal component props
314+type DropdownMenuPortalProps =
315+ {
316+ }
317+
318+-- | The foreign component for the DropdownMenuPortal
319+foreign import portalImpl :: forall a. ReactComponent { | a }
320+
321+-- | A PureScript wrapper for the DropdownMenuPortal component
322+portal ::
323+ forall p kids. Coerce p DropdownMenuPortalProps => IsJSX kids => p -> kids -> JSX
324+portal props kids = React.element portalImpl
325+ $ (coerce props :: DropdownMenuPortalProps) #
326+ unsafeSet "children" kids