Skip to content

Commit b5a106e

Browse files
committed
Remove IProps interface and update React helpers to only accept specific props for the component.
1 parent da3fb09 commit b5a106e

File tree

1 file changed

+36
-13
lines changed

1 file changed

+36
-13
lines changed

src/Fable.React.TransitionGroup/Fable.Helpers.React.TransitionGroup.fs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ open Fable.Core
44
open Fable.Core.JsInterop
55
open Fable.Import
66
open Fable.Helpers.React
7-
open Fable.Helpers.React.Props
87

98
type Timeout = {
109
enter: int option
@@ -34,7 +33,10 @@ type TransitionProps =
3433
| OnExiting of (Browser.HTMLElement -> unit)
3534
| OnExited of (Browser.HTMLElement -> unit)
3635
| Children of U2<React.ReactNode, TransitionStatus -> React.ReactNode>
37-
interface IProp
36+
| Ref of (obj -> obj)
37+
| Key of string
38+
static member Custom(key: string, value: obj): TransitionProps =
39+
unbox(key, value)
3840

3941
type CSSTransitionClassNames = {
4042
appear: string option
@@ -48,32 +50,53 @@ type CSSTransitionClassNames = {
4850
}
4951

5052
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>
5168
| ClassNames of U2<string, CSSTransitionClassNames>
52-
interface IProp
69+
| Ref of (obj -> obj)
70+
| Key of string
71+
static member Custom(key: string, value: obj): CSSTransitionProps =
72+
unbox(key, value)
5373

5474
type TransitionGroupProps =
5575
| Component of React.ReactType
5676
| ChildFactory of (React.ReactElement -> React.ReactElement)
57-
interface IProp
77+
| Ref of (obj -> obj)
78+
| Key of string
79+
static member Custom(key: string, value: obj): TransitionGroupProps =
80+
unbox(key, value)
5881

5982
let private asNode (el: React.ReactElement): React.ReactNode =
6083
!^(!^el: React.ReactChild)
6184

62-
let transition (props: IProp list) (child: React.ReactElement): React.ReactElement =
63-
let props = (Children !^(asNode child) :> IProp)::props
85+
let transition (props: TransitionProps list) (child: React.ReactElement): React.ReactElement =
86+
let props = (TransitionProps.Children !^(asNode child))::props
6487
ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
6588

66-
let transitionWithRender (props: IProp list) (render: TransitionStatus -> React.ReactNode): React.ReactElement =
67-
let props = (Children !^render :> IProp)::props
89+
let transitionWithRender (props: TransitionProps list) (render: TransitionStatus -> React.ReactNode): React.ReactElement =
90+
let props = (TransitionProps.Children !^render)::props
6891
ofImport "Transition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
6992

70-
let cssTransition (props: IProp list) (child: React.ReactElement): React.ReactElement =
71-
let props = (Children !^(asNode child) :> IProp)::props
93+
let cssTransition (props: CSSTransitionProps list) (child: React.ReactElement): React.ReactElement =
94+
let props = (CSSTransitionProps.Children !^(asNode child))::props
7295
ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
7396

74-
let cssTransitionWithRender (props: IProp list) (render: TransitionStatus -> React.ReactNode): React.ReactElement =
75-
let props = (Children !^render :> IProp)::props
97+
let cssTransitionWithRender (props: CSSTransitionProps list) (render: TransitionStatus -> React.ReactNode): React.ReactElement =
98+
let props = (CSSTransitionProps.Children !^render)::props
7699
ofImport "CSSTransition" "react-transition-group" (keyValueList CaseRules.LowerFirst props) []
77100

78-
let transitionGroup (props: IProp list) (children: React.ReactElement list): React.ReactElement =
101+
let transitionGroup (props: TransitionGroupProps list) (children: React.ReactElement list): React.ReactElement =
79102
ofImport "TransitionGroup" "react-transition-group" (keyValueList CaseRules.LowerFirst props) children

0 commit comments

Comments
 (0)