From 13236f9da345721f578328120e07989836a67474 Mon Sep 17 00:00:00 2001 From: aerialist7 Date: Sat, 24 Jul 2021 23:57:18 +0400 Subject: [PATCH] `RState` -> `State` --- examples/src/main/kotlin/example/AxiosSearch.kt | 14 ++++++++------ examples/src/main/kotlin/example/Product.kt | 13 +++++++------ examples/src/main/kotlin/example/Quill.kt | 4 ++-- examples/src/main/kotlin/example/TicTacToe.kt | 6 +++--- examples/src/main/kotlin/example/Todo.kt | 9 +++++---- .../src/main/kotlin/react/redux/Imports.kt | 2 +- .../src/main/kotlin/react/router/dom/routing.kt | 4 ++-- .../src/main/kotlin/react/Component.ext.kt | 2 +- kotlin-react/src/main/kotlin/react/Component.kt | 2 +- .../src/main/kotlin/react/ComponentClass.kt | 6 +++--- .../src/main/kotlin/react/PureComponent.kt | 2 +- kotlin-react/src/main/kotlin/react/RComponent.kt | 2 +- .../src/main/kotlin/react/RPureComponent.kt | 2 +- kotlin-react/src/main/kotlin/react/State.kt | 10 ++++++++-- 14 files changed, 44 insertions(+), 34 deletions(-) diff --git a/examples/src/main/kotlin/example/AxiosSearch.kt b/examples/src/main/kotlin/example/AxiosSearch.kt index e89ca0cae0a2..6aa8d18fb467 100644 --- a/examples/src/main/kotlin/example/AxiosSearch.kt +++ b/examples/src/main/kotlin/example/AxiosSearch.kt @@ -6,13 +6,15 @@ package example * This example queries the database of ZIP codes at http://ziptasticapi.com and displays the results. */ -import kotlinext.js.* -import kotlinx.html.* -import kotlinx.html.js.* -import org.w3c.dom.* +import kotlinext.js.js +import kotlinext.js.jsObject +import kotlinx.html.InputType +import kotlinx.html.js.onChangeFunction +import kotlinx.html.title +import org.w3c.dom.HTMLInputElement import react.* import react.dom.* -import kotlin.js.* +import kotlin.js.Promise @JsModule("axios") @JsNonModule @@ -58,7 +60,7 @@ data class ZipResult(val country: String, val state: String, val city: String) interface AxiosProps : RProps -interface AxiosState : RState { +interface AxiosState : State { var zipCode: String var zipResult: ZipResult var errorMessage: String diff --git a/examples/src/main/kotlin/example/Product.kt b/examples/src/main/kotlin/example/Product.kt index 0fc3f8297b22..7ced1c6c86b1 100644 --- a/examples/src/main/kotlin/example/Product.kt +++ b/examples/src/main/kotlin/example/Product.kt @@ -7,10 +7,11 @@ package example * Date: Nov 24, 2017 */ -import kotlinext.js.* -import kotlinx.html.* -import kotlinx.html.js.* -import org.w3c.dom.* +import kotlinext.js.js +import kotlinx.html.InputType +import kotlinx.html.js.onChangeFunction +import kotlinx.html.js.onClickFunction +import org.w3c.dom.HTMLInputElement import react.* import react.dom.* @@ -71,7 +72,7 @@ interface SearchBarProps : RProps { var filterText: String } -class SearchBar(props: SearchBarProps) : RComponent(props) { +class SearchBar(props: SearchBarProps) : RComponent(props) { override fun RBuilder.render() { div { input(type = InputType.text, name = "filterText") { @@ -116,7 +117,7 @@ fun RBuilder.searchBar( interface ProductProps : RProps -interface ProductState : RState { +interface ProductState : State { var filterText: String var inStockOnly: Boolean } diff --git a/examples/src/main/kotlin/example/Quill.kt b/examples/src/main/kotlin/example/Quill.kt index d6a767b5fa1b..17189c858487 100644 --- a/examples/src/main/kotlin/example/Quill.kt +++ b/examples/src/main/kotlin/example/Quill.kt @@ -8,7 +8,7 @@ package example */ import react.* -import react.dom.* +import react.dom.div @JsModule("react-quill") @JsNonModule @@ -23,7 +23,7 @@ interface QuillProps : RProps { var initialText: String } -interface QuillState : RState { +interface QuillState : State { var text: String } diff --git a/examples/src/main/kotlin/example/TicTacToe.kt b/examples/src/main/kotlin/example/TicTacToe.kt index 27481a47df5f..5dc0b76bf64e 100644 --- a/examples/src/main/kotlin/example/TicTacToe.kt +++ b/examples/src/main/kotlin/example/TicTacToe.kt @@ -1,6 +1,6 @@ package example -import kotlinx.html.js.* +import kotlinx.html.js.onClickFunction import react.* import react.dom.* @@ -27,7 +27,7 @@ interface BoardProps : RProps { var onClick: (Int) -> () -> Unit } -class Board(props: BoardProps) : RComponent(props) { +class Board(props: BoardProps) : RComponent(props) { fun RBuilder.renderSquare(i: Int) { square(props.squares[i], props.onClick(i)) } @@ -62,7 +62,7 @@ fun RBuilder.board(initialSquares: Array, onClick: (Int) -> () -> Unit) interface TicTacToeProps : RProps -interface TicTacToeState : RState { +interface TicTacToeState : State { var history: Array> var xIsNext: Boolean var stepNumber: Int diff --git a/examples/src/main/kotlin/example/Todo.kt b/examples/src/main/kotlin/example/Todo.kt index 90f17fcf7846..9ace22d0f952 100644 --- a/examples/src/main/kotlin/example/Todo.kt +++ b/examples/src/main/kotlin/example/Todo.kt @@ -1,8 +1,9 @@ package example -import kotlinx.html.* -import kotlinx.html.js.* -import org.w3c.dom.* +import kotlinx.html.InputType +import kotlinx.html.js.onChangeFunction +import kotlinx.html.js.onClickFunction +import org.w3c.dom.HTMLInputElement import react.* import react.dom.* @@ -14,7 +15,7 @@ interface TodoProps : RProps { var initialItems: List } -interface TodoState : RState { +interface TodoState : State { var items: List var text: String } diff --git a/kotlin-react-redux/src/main/kotlin/react/redux/Imports.kt b/kotlin-react-redux/src/main/kotlin/react/redux/Imports.kt index 7e76dd0c4bcb..ef6b8d50a6c3 100644 --- a/kotlin-react-redux/src/main/kotlin/react/redux/Imports.kt +++ b/kotlin-react-redux/src/main/kotlin/react/redux/Imports.kt @@ -6,7 +6,7 @@ package react.redux import react.* import redux.Store -external class Provider : Component { +external class Provider : Component { override fun render(): ReactElement? } diff --git a/kotlin-react-router-dom/src/main/kotlin/react/router/dom/routing.kt b/kotlin-react-router-dom/src/main/kotlin/react/router/dom/routing.kt index 7a44ac5d0394..e5afc91da637 100644 --- a/kotlin-react-router-dom/src/main/kotlin/react/router/dom/routing.kt +++ b/kotlin-react-router-dom/src/main/kotlin/react/router/dom/routing.kt @@ -15,7 +15,7 @@ external val BrowserRouterComponent: RClass external val SwitchComponent: RClass @JsName("Route") -external class RouteComponent : Component, RState> { +external class RouteComponent : Component, State> { override fun render(): ReactElement? } @@ -23,7 +23,7 @@ external class RouteComponent : Component, RState> { external val LinkComponent: RClass @JsName("NavLink") -external class NavLinkComponent : Component, RState> { +external class NavLinkComponent : Component, State> { override fun render(): ReactElement? } diff --git a/kotlin-react/src/main/kotlin/react/Component.ext.kt b/kotlin-react/src/main/kotlin/react/Component.ext.kt index 59cde78b84db..ba65922a785d 100644 --- a/kotlin-react/src/main/kotlin/react/Component.ext.kt +++ b/kotlin-react/src/main/kotlin/react/Component.ext.kt @@ -2,6 +2,6 @@ package react import kotlinext.js.assign -fun Component<*, S>.setState(buildState: S.() -> Unit) { +fun Component<*, S>.setState(buildState: S.() -> Unit) { setState({ assign(it, buildState) }) } diff --git a/kotlin-react/src/main/kotlin/react/Component.kt b/kotlin-react/src/main/kotlin/react/Component.kt index 00f1c698e756..409f19ede5a9 100644 --- a/kotlin-react/src/main/kotlin/react/Component.kt +++ b/kotlin-react/src/main/kotlin/react/Component.kt @@ -3,7 +3,7 @@ package react -abstract external class Component

( +abstract external class Component

( props: P = definedExternally, ) { val props: P diff --git a/kotlin-react/src/main/kotlin/react/ComponentClass.kt b/kotlin-react/src/main/kotlin/react/ComponentClass.kt index edee101c1e2a..c5a5a649d09c 100644 --- a/kotlin-react/src/main/kotlin/react/ComponentClass.kt +++ b/kotlin-react/src/main/kotlin/react/ComponentClass.kt @@ -5,14 +5,14 @@ import kotlin.reflect.KClass // TODO: Should extend RComponentClassStatics, but has problems with generic params external interface ComponentClass : ComponentType

, - RComponentClassStatics?> + RComponentClassStatics?> typealias RClass

= ComponentClass

val

KClass>.rClass: ComponentClass

get() = js.unsafeCast>() -external interface RComponentClassStatics

?> { +external interface RComponentClassStatics

?> { var displayName: String? var defaultProps: P? var contextType: C @@ -34,6 +34,6 @@ external interface RComponentClassStatics

* * in your class components */ -open class RStatics

, CTX : Context<*>?>( +open class RStatics

, CTX : Context<*>?>( klazz: KClass, ) : RComponentClassStatics by klazz.js.unsafeCast>() diff --git a/kotlin-react/src/main/kotlin/react/PureComponent.kt b/kotlin-react/src/main/kotlin/react/PureComponent.kt index a3ffb05ad4b6..6eef6252c591 100644 --- a/kotlin-react/src/main/kotlin/react/PureComponent.kt +++ b/kotlin-react/src/main/kotlin/react/PureComponent.kt @@ -3,7 +3,7 @@ package react -abstract external class PureComponent

( +abstract external class PureComponent

( props: P = definedExternally, ) : Component { diff --git a/kotlin-react/src/main/kotlin/react/RComponent.kt b/kotlin-react/src/main/kotlin/react/RComponent.kt index f50be476097a..ea0e8cc09c80 100644 --- a/kotlin-react/src/main/kotlin/react/RComponent.kt +++ b/kotlin-react/src/main/kotlin/react/RComponent.kt @@ -2,7 +2,7 @@ package react import kotlinext.js.jsObject -abstract class RComponent

: Component { +abstract class RComponent

: Component { constructor() : super() { state = jsObject { init() } } diff --git a/kotlin-react/src/main/kotlin/react/RPureComponent.kt b/kotlin-react/src/main/kotlin/react/RPureComponent.kt index d450d1da11d3..ed7b0298bc7b 100644 --- a/kotlin-react/src/main/kotlin/react/RPureComponent.kt +++ b/kotlin-react/src/main/kotlin/react/RPureComponent.kt @@ -2,7 +2,7 @@ package react import kotlinext.js.jsObject -abstract class RPureComponent

: PureComponent { +abstract class RPureComponent

: PureComponent { constructor() : super() { state = jsObject { init() } } diff --git a/kotlin-react/src/main/kotlin/react/State.kt b/kotlin-react/src/main/kotlin/react/State.kt index 72f2ab4b12e6..a627f868a81f 100644 --- a/kotlin-react/src/main/kotlin/react/State.kt +++ b/kotlin-react/src/main/kotlin/react/State.kt @@ -1,5 +1,11 @@ package react -external interface RState +external interface State -class BoxedState(var state: T) : RState +class BoxedState(var state: T) : State + +@Deprecated( + message = "Legacy type alias", + replaceWith = ReplaceWith("State", "react.State"), +) +typealias RState = State