@@ -0,0 +1,142 @@
1+module HeroUI.Modal where
5+import Effect.Uncurried (EffectFn1)
6+import React.Basic (JSX)
7+import Yoga.React.DOM.Internal (class IsJSX)
8+import Data.Function.Uncurried (runFn4)
9+import HeroUI.Internal (class CoerceHeroProps, createElementTransformImpl)
10+import HeroUI.Raw as Raw
12+data Size = Xs | Sm | Md | Lg | Full | Cover
14+derive instance Eq Size
15+derive instance Ord Size
17+sizeToString :: Size -> String
18+sizeToString = case _ of
26+data Placement = PlacementAuto | PlacementTop | PlacementCenter | PlacementBottom
28+derive instance Eq Placement
29+derive instance Ord Placement
31+placementToString :: Placement -> String
32+placementToString = case _ of
33+ PlacementAuto -> "auto"
34+ PlacementTop -> "top"
35+ PlacementCenter -> "center"
36+ PlacementBottom -> "bottom"
38+data Backdrop = Blur | Opaque | Transparent
40+derive instance Eq Backdrop
41+derive instance Ord Backdrop
43+backdropToString :: Backdrop -> String
44+backdropToString = case _ of
47+ Transparent -> "transparent"
49+data Scroll = ScrollInside | ScrollOutside
51+derive instance Eq Scroll
52+derive instance Ord Scroll
54+scrollToString :: Scroll -> String
55+scrollToString = case _ of
56+ ScrollInside -> "inside"
57+ ScrollOutside -> "outside"
59+-- | The root wires the open state (react-aria `DialogTrigger`).
62+ , defaultOpen :: Boolean
63+ , onOpenChange :: EffectFn1 Boolean Unit
64+ , isDismissable :: Boolean
65+ , className :: String
70+ :: forall givenProps nonDataProps kids
72+ => CoerceHeroProps { | givenProps } { | nonDataProps } { | ModalProps () }
76+modal props kids = runFn4 createElementTransformImpl {} Raw.modal props kids
78+type ModalBackdropProps r = (variant :: Backdrop, isDismissable :: Boolean, className :: String | r)
81+ :: forall givenProps nonDataProps kids
83+ => CoerceHeroProps { | givenProps } { | nonDataProps } { | ModalBackdropProps () }
87+modalBackdrop props kids = runFn4 createElementTransformImpl { variant: backdropToString } Raw.modalBackdrop props kids
89+type ModalContainerProps r =
90+ ( placement :: Placement
93+ , className :: String
97+modalContainerTransforms
98+ :: { placement :: Placement -> String, scroll :: Scroll -> String, size :: Size -> String }
99+modalContainerTransforms = { placement: placementToString, scroll: scrollToString, size: sizeToString }
102+ :: forall givenProps nonDataProps kids
104+ => CoerceHeroProps { | givenProps } { | nonDataProps } { | ModalContainerProps () }
108+modalContainer props kids = runFn4 createElementTransformImpl modalContainerTransforms Raw.modalContainer props kids
110+type SectionProps r = (className :: String | r)
113+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
114+modalTrigger props kids = runFn4 createElementTransformImpl {} Raw.modalTrigger props kids
117+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
118+modalDialog props kids = runFn4 createElementTransformImpl {} Raw.modalDialog props kids
121+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
122+modalHeader props kids = runFn4 createElementTransformImpl {} Raw.modalHeader props kids
125+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
126+modalIcon props kids = runFn4 createElementTransformImpl {} Raw.modalIcon props kids
129+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
130+modalHeading props kids = runFn4 createElementTransformImpl {} Raw.modalHeading props kids
133+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
134+modalBody props kids = runFn4 createElementTransformImpl {} Raw.modalBody props kids
137+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
138+modalFooter props kids = runFn4 createElementTransformImpl {} Raw.modalFooter props kids
141+ :: forall g n k. IsJSX k => CoerceHeroProps { | g } { | n } { | SectionProps () } => { | g } -> k -> JSX
142+modalCloseTrigger props kids = runFn4 createElementTransformImpl {} Raw.modalCloseTrigger props kids