@@ -1,13 +1,195 @@
11module RadixUI.Dialog where
22
33import Prelude
4−import React.Basic (ReactComponent)
4+import React.Basic (JSX, ReactComponent)
5+import Effect.Uncurried (EffectFn1, mkEffectFn1)
6+import Prim.Row (class Union)
7+import React.Basic (element) as React
8+import Effect (Effect)
9+import Type.Proxy (Proxy(Proxy))
10+import Data.Undefined.NoProblem (Opt, pseudoMap)
11+import Data.Undefined.NoProblem.Closed (class Coerce, coerce)
12+import Record.Builder (build, insert, modify) as RB
13+import React.Basic.Events (SyntheticEvent)
14+import Web.HTML.HTMLElement (HTMLElement)
15+import Beta.DOM.Internal (CSS)
16+import Beta.DOM (class IsJSX)
517
6−foreign import dialogOverlay :: forall r. ReactComponent {|r}
7−foreign import dialogContent :: forall r. ReactComponent {|r}
8−foreign import dialogTitle :: forall r. ReactComponent {|r}
9−foreign import dialogDescription :: forall r. ReactComponent {|r}
10−foreign import dialogTrigger :: forall r. ReactComponent {|r}
11−foreign import dialogClose :: forall r. ReactComponent {|r}
12−foreign import dialogRoot :: forall r. ReactComponent {|r}
18+-- | The type of the Dialog component props
19+type RootProps =
20+ { open ∷ Opt Boolean -- ^ Whether the alert dialog is open or not
21+ , onOpenChange ∷
22+ Opt (Boolean → Effect Unit) -- ^ A callback function that is called when the alert dialog open state changes
23+ , className ∷ Opt String -- ^ The CSS class name of the alert dialog
24+ , style ∷ Opt CSS -- ^ The CSS style of the alert dialog
25+ }
1326
27+x = React.element
28+
29+-- | The foreign component for the Dialog
30+foreign import rootImpl ∷ ∀ a. ReactComponent { | a }
31+
32+-- | A PureScript wrapper for the Dialog component
33+root
34+ ∷ ∀ p
35+ . Coerce p RootProps
36+ ⇒ p
37+ → Array JSX
38+ → JSX
39+root props kids = React.element rootImpl $
40+ (coerce props ∷ RootProps) # RB.build
41+ ( RB.modify (Proxy ∷ _ "onOpenChange") (pseudoMap mkEffectFn1)
42+ <<< RB.insert (Proxy ∷ _ "children") kids
43+ )
44+
45+-- | The type of the DialogTrigger component props
46+type DialogTriggerProps =
47+ { asChild ∷
48+ Opt Boolean -- ^ Whether to render the alert dialog trigger as a child of the dialog content
49+ }
50+
51+-- | The foreign component for the DialogTrigger
52+foreign import triggerImpl ∷ ∀ a. ReactComponent { | a }
53+
54+-- | A PureScript wrapper for the DialogTrigger component
55+trigger
56+ ∷ ∀ p kids. Coerce p DialogTriggerProps ⇒ IsJSX kids ⇒ p → kids → JSX
57+trigger props kids = React.element triggerImpl $
58+ (coerce props ∷ DialogTriggerProps) # RB.build
59+ ( RB.insert (Proxy ∷ _ "children") kids
60+ )
61+
62+-- | The type of the DialogPortal component props
63+type DialogPortalProps =
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
66+ }
67+
68+-- | The foreign component for the DialogPortal
69+foreign import portalImpl ∷ ∀ a. ReactComponent { | a }
70+
71+-- | A PureScript wrapper for the DialogPortal component
72+portal
73+ ∷ ∀ p kids. Coerce p DialogPortalProps ⇒ IsJSX kids ⇒ p → kids → JSX
74+portal props kids = React.element portalImpl $
75+ (coerce props ∷ DialogPortalProps) # RB.build
76+ ( RB.insert (Proxy ∷ _ "children") kids
77+ )
78+
79+-- | The type of the DialogOverlay component props
80+type DialogOverlayProps =
81+ { asChild ∷
82+ Opt Boolean -- ^ Whether to render the alert dialog overlay as a child of the dialog content
83+ , forceMount ∷
84+ Opt Boolean -- ^ Whether to force mount the alert dialog overlay in the DOM even when it is not open
85+ , className ∷ Opt String -- ^ The CSS class name of the alert dialog overlay
86+ , style ∷ Opt CSS -- ^ The CSS style of the alert dialog overlay
87+ }
88+
89+-- | The foreign component for the DialogOverlay
90+foreign import overlayImpl ∷ ∀ a. ReactComponent { | a }
91+
92+-- | A PureScript wrapper for the DialogOverlay component
93+overlay
94+ ∷ ∀ p kids. Coerce p DialogOverlayProps ⇒ IsJSX kids ⇒ p → kids → JSX
95+overlay props kids = React.element overlayImpl $
96+ (coerce props ∷ DialogOverlayProps) # RB.build
97+ ( RB.insert (Proxy ∷ _ "children") kids
98+ )
99+
100+-- | The type of the DialogContent component props
101+type DialogContentProps =
102+ { asChild ∷
103+ Opt Boolean -- ^ Whether to render the alert dialog content as a child of the dialog root
104+ , forceMount ∷
105+ Opt Boolean -- ^ Whether to force mount the alert dialog content in the DOM even when it is not open
106+ , onOpenAutoFocus ∷
107+ Opt (Effect Unit) -- ^ A callback function that is called when the alert dialog content is opened and should receive focus
108+ , onCloseAutoFocus ∷
109+ Opt (Effect Unit) -- ^ A callback function that is called when the alert dialog content is closed and should receive focus
110+ , onEscapeKeyDown ∷
111+ Opt (Effect Unit) -- ^ A callback function that is called when the escape key is pressed while the alert dialog content is focused
112+ , className ∷ Opt String -- ^ The CSS class name of the alert dialog content
113+ , style ∷ Opt CSS -- ^ The CSS style of the alert dialog content
114+ }
115+
116+-- | The foreign component for the DialogContent
117+foreign import contentImpl ∷ ∀ a. ReactComponent { | a }
118+
119+-- | A PureScript wrapper for the DialogContent component
120+content
121+ ∷ ∀ p kids. Coerce p DialogContentProps ⇒ IsJSX kids ⇒ p → kids → JSX
122+content props kids = React.element contentImpl $
123+ (coerce props ∷ DialogContentProps) # RB.build
124+ (
125+ -- RB.modify (Proxy :: _ "onOpenAutoFocus") (pseudoMap mkEffectFn1)
126+ -- <<< RB.modify (Proxy :: _ "onCloseAutoFocus") (pseudoMap mkEffectFn1)
127+ -- <<< RB.modify (Proxy :: _ "onEscapeKeyDown") (pseudoMap mkEffectFn1)
128+ -- <<<
129+ RB.insert (Proxy ∷ _ "children") kids
130+ )
131+
132+-- | The type of the DialogCancel component props
133+type DialogCancelProps =
134+ { asChild ∷
135+ Opt Boolean -- ^ Whether to render the alert dialog cancel button as a child of the dialog content
136+ }
137+
138+-- | The type of the DialogTitle component props
139+type DialogTitleProps =
140+ { asChild ∷
141+ Opt Boolean -- ^ Whether to render the alert dialog title as a child of the dialog content
142+ , className ∷ Opt String -- ^ The CSS class name of the alert dialog title
143+ , style ∷ Opt CSS -- ^ The CSS style of the alert dialog title
144+ }
145+
146+-- | The foreign component for the DialogTitle
147+foreign import titleImpl ∷ ∀ a. ReactComponent { | a }
148+
149+-- | A PureScript wrapper for the DialogTitle component
150+title
151+ ∷ ∀ p kids. Coerce p DialogTitleProps ⇒ IsJSX kids ⇒ p → kids → JSX
152+title props kids = React.element titleImpl $
153+ (coerce props ∷ DialogTitleProps) # RB.build
154+ ( RB.insert (Proxy ∷ _ "children") kids
155+ )
156+
157+-- | The type of the DialogDescription component props
158+type DialogDescriptionProps =
159+ { asChild ∷
160+ Opt Boolean -- ^ Whether to render the alert dialog description as a child of the dialog content
161+ , className ∷
162+ Opt String -- ^ The CSS class name of the alert dialog description
163+ , style ∷ Opt CSS -- ^ The CSS style of the alert dialog description
164+ }
165+
166+-- | The foreign component for the DialogDescription
167+foreign import descriptionImpl ∷ ∀ a. ReactComponent { | a }
168+
169+-- | A PureScript wrapper for the DialogDescription component
170+description
171+ ∷ ∀ p kids. Coerce p DialogDescriptionProps ⇒ IsJSX kids ⇒ p → kids → JSX
172+description props kids = React.element descriptionImpl $
173+ (coerce props ∷ DialogDescriptionProps) # RB.build
174+ ( RB.insert (Proxy ∷ _ "children") kids
175+ )
176+
177+-- | The type of the DialogClose component props
178+type DialogCloseProps =
179+ { asChild ∷
180+ Opt Boolean -- ^ Whether to render the alert dialog description as a child of the dialog content
181+ , className ∷
182+ Opt String -- ^ The CSS class name of the alert dialog description
183+ , style ∷ Opt CSS -- ^ The CSS style of the alert dialog description
184+ }
185+
186+-- | The foreign component for the DialogClose
187+foreign import closeImpl ∷ ∀ a. ReactComponent { | a }
188+
189+-- | A PureScript wrapper for the DialogClose component
190+close
191+ ∷ ∀ p kids. Coerce p DialogCloseProps ⇒ IsJSX kids ⇒ p → kids → JSX
192+close props kids = React.element closeImpl $
193+ (coerce props ∷ DialogCloseProps) # RB.build
194+ ( RB.insert (Proxy ∷ _ "children") kids
195+ )