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