|
| 1 | +module Fable.Helpers.React.TransitionGroup |
| 2 | + |
| 3 | +open Fable.Core |
| 4 | +open Fable.Core.JsInterop |
| 5 | +open Fable.Import |
| 6 | +open Fable.Helpers.React |
| 7 | +open Fable.Helpers.React.Props |
| 8 | + |
| 9 | +type Timeout = { |
| 10 | + enter: int option |
| 11 | + exit: int option |
| 12 | +} |
| 13 | + |
| 14 | +type TransitionStatus = |
| 15 | + | [<CompiledName("entering")>] Entering |
| 16 | + | [<CompiledName("entered")>] Entered |
| 17 | + | [<CompiledName("exiting")>] Exiting |
| 18 | + | [<CompiledName("exited")>] Exited |
| 19 | + | [<CompiledName("unmounted")>] Unmounted |
| 20 | + |
| 21 | +type TransitionProps = |
| 22 | + | In of bool |
| 23 | + | Appear of bool |
| 24 | + | Enter of bool |
| 25 | + | Exit of bool |
| 26 | + | MountOnEnter of bool |
| 27 | + | UnmountOnExit of bool |
| 28 | + | Timeout of U2<int, Timeout> |
| 29 | + | AddEndListener of (Browser.HTMLElement -> (unit -> unit) -> unit) |
| 30 | + | OnEnter of (Browser.HTMLElement -> bool -> unit) |
| 31 | + | OnEntering of (Browser.HTMLElement -> bool -> unit) |
| 32 | + | OnEntered of (Browser.HTMLElement -> bool -> unit) |
| 33 | + | OnExit of (Browser.HTMLElement -> unit) |
| 34 | + | OnExiting of (Browser.HTMLElement -> unit) |
| 35 | + | OnExited of (Browser.HTMLElement -> unit) |
| 36 | + | Children of U2<React.ReactNode, TransitionStatus -> React.ReactNode> |
| 37 | + interface IProp |
| 38 | + |
| 39 | +type CSSTransitionClassNames = { |
| 40 | + appear: string option |
| 41 | + appearActive: string option |
| 42 | + enter: string option |
| 43 | + enterActive: string option |
| 44 | + enterDone: string option |
| 45 | + exit: string option |
| 46 | + exitActive: string option |
| 47 | + exitDone: string option |
| 48 | +} |
| 49 | + |
| 50 | +type CSSTransitionProps = |
| 51 | + | ClassNames of U2<string, CSSTransitionClassNames> |
| 52 | + interface IProp |
| 53 | + |
| 54 | +type TransitionGroupProps = |
| 55 | + | Component of React.ReactType |
| 56 | + | ChildFactory of (React.ReactElement -> React.ReactElement) |
| 57 | + interface IProp |
| 58 | + |
| 59 | +let private asNode (el: React.ReactElement): React.ReactNode = |
| 60 | + !^(!^el: React.ReactChild) |
| 61 | + |
| 62 | +let transition (props: IProp list) (child: React.ReactElement): React.ReactElement = |
| 63 | + let props = (Children !^(asNode child) :> IProp)::props |
| 64 | + ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) [] |
| 65 | + |
| 66 | +let transitionWithRender (props: IProp list) (render: TransitionStatus -> React.ReactNode): React.ReactElement = |
| 67 | + let props = (Children !^render :> IProp)::props |
| 68 | + ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) [] |
| 69 | + |
| 70 | +let cssTransition (props: IProp list) (child: React.ReactElement): React.ReactElement = |
| 71 | + let props = (Children !^(asNode child) :> IProp)::props |
| 72 | + ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) [] |
| 73 | + |
| 74 | +let cssTransitionWithRender (props: IProp list) (render: TransitionStatus -> React.ReactNode): React.ReactElement = |
| 75 | + let props = (Children !^render :> IProp)::props |
| 76 | + ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) [] |
| 77 | + |
| 78 | +let transitionGroup (props: IProp list) (children: React.ReactElement list): React.ReactElement = |
| 79 | + ofImport "TransitionGroup" "react-transition-group" (keyValueList CaseRules.LowerFirst props) children |
0 commit comments