@@ -54,97 +54,86 @@ object Js extends JsBaseComponentTemplate[RAW.ReactClass] {
5454
5555 // ===================================================================================================================
5656
57- type UnmountedRoot [P <: js.Object , M ] = UnmountedWithRoot [P , M , P , M ]
57+ sealed trait UnmountedSimple [P , M ] extends Generic .UnmountedSimple [P , M ] {
58+ override def mapUnmountedProps [P2 ](f : P => P2 ): UnmountedSimple [P2 , M ]
59+ override def mapMounted [M2 ](f : M => M2 ): UnmountedSimple [P , M2 ]
5860
59- sealed trait UnmountedWithRoot [P1 , M1 , P0 <: js.Object , M0 ]
60- extends Generic .UnmountedWithRoot [P1 , M1 , P0 , M0 ] {
61+ override final type Raw = RAW .ReactComponentElement
62+ override final def displayName = raw.`type`.displayName
63+ }
6164
65+ sealed trait UnmountedWithRoot [P1 , M1 , P0 <: js.Object , M0 ] extends UnmountedSimple [P1 , M1 ] with Generic .UnmountedWithRoot [P1 , M1 , P0 , M0 ] {
6266 override final type Root = UnmountedRoot [P0 , M0 ]
63- override final type Raw = RAW .ReactComponentElement
6467 override def mapUnmountedProps [P2 ](f : P1 => P2 ): UnmountedWithRoot [P2 , M1 , P0 , M0 ]
6568 override def mapMounted [M2 ](f : M1 => M2 ): UnmountedWithRoot [P1 , M2 , P0 , M0 ]
66-
67- override final def displayName = raw.`type`.displayName
6869 }
6970
71+ type UnmountedRoot [P <: js.Object , M ] = UnmountedWithRoot [P , M , P , M ]
72+
7073 def unmountedRoot [P <: js.Object , M ](r : RAW .ReactComponentElement , m : RAW .ReactComponent => M ): UnmountedRoot [P , M ] =
7174 new UnmountedRoot [P , M ] {
72-
73- override def root = this
74- override val raw = r
75- override val mountRaw = m
76-
77- override val vdomElement =
78- vdom.VdomElement (raw)
79-
80- override def key : Option [Key ] =
81- jsNullToOption(raw.key)
82-
83- override def ref : Option [String ] =
84- jsNullToOption(raw.ref)
85-
86- override def props : P =
87- raw.props.asInstanceOf [P ]
88-
89- override def propsChildren : PropsChildren =
90- PropsChildren .fromRawProps(raw.props)
91-
92- override def mapUnmountedProps [P2 ](f : P => P2 ) =
93- mappedU(this )(f, identityFn)
94-
95- override def mapMounted [M2 ](f : M => M2 ) =
96- mappedU(this )(identityFn, f)
75+ override def root = this
76+ override val raw = r
77+ override val mountRaw = m
78+ override val vdomElement = vdom.VdomElement (raw)
79+ override def key = jsNullToOption(raw.key)
80+ override def ref = jsNullToOption(raw.ref)
81+ override def props = raw.props.asInstanceOf [P ]
82+ override def propsChildren = PropsChildren .fromRawProps(raw.props)
83+ override def mapUnmountedProps [P2 ](f : P => P2 ) = mappedU(this )(f, identityFn)
84+ override def mapMounted [M2 ](f : M => M2 ) = mappedU(this )(identityFn, f)
9785 }
9886
99- private def mappedU [P2 , M2 , P1 , M1 , P0 <: js.Object , M0 ]
100- (from : UnmountedWithRoot [P1 , M1 , P0 , M0 ])
101- (mp : P1 => P2 , mm : M1 => M2 )
87+ private def mappedU [P2 , M2 , P1 , M1 , P0 <: js.Object , M0 ](from : UnmountedWithRoot [P1 , M1 , P0 , M0 ])
88+ (mp : P1 => P2 , mm : M1 => M2 )
10289 : UnmountedWithRoot [P2 , M2 , P0 , M0 ] =
10390 new UnmountedWithRoot [P2 , M2 , P0 , M0 ] {
104- override def root = from.root
105- override def props = mp(from.props)
106- override val raw = from.raw
107- override def vdomElement = from.vdomElement
108- override def key = from.key
109- override def ref = from.ref
110- override def propsChildren = from.propsChildren
111-
112- override def mapUnmountedProps [P3 ](f : P2 => P3 ) =
113- mappedU(from)(f compose mp, mm)
114-
115- override def mapMounted [M3 ](f : M2 => M3 ) =
116- mappedU(from)(mp, f compose mm)
117-
118- override val mountRaw = mm compose from.mountRaw
91+ override def root = from.root
92+ override def props = mp(from.props)
93+ override val raw = from.raw
94+ override def vdomElement = from.vdomElement
95+ override def key = from.key
96+ override def ref = from.ref
97+ override def propsChildren = from.propsChildren
98+ override def mapUnmountedProps [P3 ](f : P2 => P3 ) = mappedU(from)(f compose mp, mm)
99+ override def mapMounted [M3 ](f : M2 => M3 ) = mappedU(from)(mp, f compose mm)
100+ override val mountRaw = mm compose from.mountRaw
119101 }
120102
121103 // ===================================================================================================================
122104
123- type MountedRoot [F [_], P <: js. Object , S <: js. Object , R <: RawMounted ] = MountedWithRoot [F , P , S , R , P , S ]
105+ sealed trait MountedSimple [F [_], P , S , R <: RawMounted ] extends Generic . MountedSimple [F , P , S ] {
124106
125- sealed trait MountedWithRoot [F [_], P1 , S1 , R <: RawMounted , P0 <: js.Object , S0 <: js.Object ]
126- extends Generic .MountedWithRoot [F , P1 , S1 , P0 , S0 ] {
127-
128- override final type Root = MountedRoot [F , P0 , S0 , R ]
129- override final type WithEffect [F2 [_]] = MountedWithRoot [F2 , P1 , S1 , R , P0 , S0 ]
130- override final type WithMappedProps [P2 ] = MountedWithRoot [F , P2 , S1 , R , P0 , S0 ]
131- override final type WithMappedState [S2 ] = MountedWithRoot [F , P1 , S2 , R , P0 , S0 ]
107+ override type WithEffect [F2 [_]] <: MountedSimple [F2 , P , S , R ]
108+ override type WithMappedProps [P2 ] <: MountedSimple [F , P2 , S , R ]
109+ override type WithMappedState [S2 ] <: MountedSimple [F , P , S2 , R ]
132110
133111 override final type Raw = R
134-
135112 override final def displayName = raw.constructor.displayName
136113
137- final def withRawType [R2 <: RawMounted ]: MountedWithRoot [F , P1 , S1 , R2 , P0 , S0 ] =
138- this .asInstanceOf [MountedWithRoot [F , P1 , S1 , R2 , P0 , S0 ]]
139-
140- final def addFacade [T <: js.Object ]: MountedWithRoot [F , P1 , S1 , R with T , P0 , S0 ] =
141- withRawType[R with T ]
142-
114+ def withRawType [R2 <: RawMounted ]: MountedSimple [F , P , S , R2 ]
115+ def addFacade [T <: js.Object ]: MountedSimple [F , P , S , R with T ]
143116 // def getDefaultProps: Props
144117 // def getInitialState: js.Object | Null
145118 // def render(): ReactElement
146119 }
147120
121+ sealed trait MountedWithRoot [F [_], P1 , S1 , R <: RawMounted , P0 <: js.Object , S0 <: js.Object ]
122+ extends MountedSimple [F , P1 , S1 , R ] with Generic .MountedWithRoot [F , P1 , S1 , P0 , S0 ] {
123+ override final type Root = MountedRoot [F , P0 , S0 , R ]
124+ override final type WithEffect [F2 [_]] = MountedWithRoot [F2 , P1 , S1 , R , P0 , S0 ]
125+ override final type WithMappedProps [P2 ] = MountedWithRoot [F , P2 , S1 , R , P0 , S0 ]
126+ override final type WithMappedState [S2 ] = MountedWithRoot [F , P1 , S2 , R , P0 , S0 ]
127+
128+ override final def withRawType [R2 <: RawMounted ]: MountedWithRoot [F , P1 , S1 , R2 , P0 , S0 ] =
129+ this .asInstanceOf [MountedWithRoot [F , P1 , S1 , R2 , P0 , S0 ]]
130+
131+ override final def addFacade [T <: js.Object ]: MountedWithRoot [F , P1 , S1 , R with T , P0 , S0 ] =
132+ withRawType[R with T ]
133+ }
134+
135+ type MountedRoot [F [_], P <: js.Object , S <: js.Object , R <: RawMounted ] = MountedWithRoot [F , P , S , R , P , S ]
136+
148137 def mountedRoot [P <: js.Object , S <: js.Object , R <: RawMounted ](r : R ): MountedRoot [Effect .Id , P , S , R ] =
149138 new Template .MountedWithRoot [Effect .Id , P , S ] with MountedRoot [Effect .Id , P , S , R ] {
150139 override implicit def F = Effect .idInstance
0 commit comments