diff options
author | Joffrey Bion <joffrey.bion@gmail.com> | 2023-01-29 04:36:31 +0100 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@gmail.com> | 2023-01-29 04:36:31 +0100 |
commit | d5b7f463bc64a849de1595a5b52ab26e2038613f (patch) | |
tree | 24e031146a38b62a58ef721f9ffa2ed2877736dd /sw-ui/src | |
parent | Upgrade to react 18 with kotlin-wrappers BOM (diff) | |
download | seven-wonders-d5b7f463bc64a849de1595a5b52ab26e2038613f.tar.gz seven-wonders-d5b7f463bc64a849de1595a5b52ab26e2038613f.tar.bz2 seven-wonders-d5b7f463bc64a849de1595a5b52ab26e2038613f.zip |
Upgrade to Kotlin 1.8 and JS IR
Diffstat (limited to 'sw-ui/src')
11 files changed, 29 insertions, 27 deletions
diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt index 68b23ce0..38b3617a 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/errors/ErrorDialog.kt @@ -14,15 +14,15 @@ import react.dom.p import styled.css import styled.styledDiv -interface ErrorDialogStateProps : PropsWithChildren { +external interface ErrorDialogStateProps : PropsWithChildren { var errorMessage: String? } -interface ErrorDialogDispatchProps : PropsWithChildren { +external interface ErrorDialogDispatchProps : PropsWithChildren { var goHome: () -> Unit } -interface ErrorDialogProps : ErrorDialogDispatchProps, ErrorDialogStateProps +external interface ErrorDialogProps : ErrorDialogDispatchProps, ErrorDialogStateProps class ErrorDialogPresenter(props: ErrorDialogProps) : RComponent<ErrorDialogProps, State>(props) { override fun RBuilder.render() { diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt index f24e0bc8..e69882c4 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/GameScene.kt @@ -25,7 +25,7 @@ import styled.css import styled.getClassName import styled.styledDiv -interface GameSceneStateProps : PropsWithChildren { +external interface GameSceneStateProps : PropsWithChildren { var currentPlayer: PlayerDTO? var players: List<PlayerDTO> var game: GameState? @@ -33,7 +33,7 @@ interface GameSceneStateProps : PropsWithChildren { var preparedCard: HandCard? } -interface GameSceneDispatchProps : PropsWithChildren { +external interface GameSceneDispatchProps : PropsWithChildren { var sayReady: () -> Unit var prepareMove: (move: PlayerMove) -> Unit var unprepareMove: () -> Unit diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt index 28f3e92d..0078fbd5 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/Hand.kt @@ -33,7 +33,7 @@ private enum class HandAction( COPY_GUILD("Copy this guild card", MoveType.COPY_GUILD, "duplicate") } -interface HandProps : PropsWithChildren { +external interface HandProps : PropsWithChildren { var action: TurnAction var ownBoard: Board var preparedMove: PlayerMove? diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt index 9a72c43c..b42d3b81 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/PlayerPreparedCard.kt @@ -13,12 +13,12 @@ import styled.css import styled.styledDiv import styled.styledImg -interface PlayerPreparedCardProps : PropsWithChildren { +external interface PlayerPreparedCardProps : PropsWithChildren { var playerDisplayName: String var cardBack: CardBack? } -interface PlayerPreparedCardContainerProps : PropsWithChildren { +external interface PlayerPreparedCardContainerProps : PropsWithChildren { var playerDisplayName: String var username: String } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt index 46f7cca7..b50f540f 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/game/TransactionsSelector.kt @@ -92,7 +92,7 @@ private fun RBuilder.optionsTable( } } -private interface OptionsTableProps : PropsWithChildren { +private external interface OptionsTableProps : PropsWithChildren { var state: TransactionSelectorState var prepareMove: (PlayerMove) -> Unit } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt index e9fb467f..45bc3ae4 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/CreateGameForm.kt @@ -10,11 +10,13 @@ import react.* import react.dom.* import styled.* -private interface CreateGameFormProps : PropsWithChildren { +private external interface CreateGameFormProps : PropsWithChildren { var createGame: (String) -> Unit } -private data class CreateGameFormState(var gameName: String = "") : State +private external interface CreateGameFormState : State { + var gameName: String +} private class CreateGameForm(props: CreateGameFormProps) : RComponent<CreateGameFormProps, CreateGameFormState>(props) { @@ -42,7 +44,7 @@ private class CreateGameForm(props: CreateGameFormProps) : RComponent<CreateGame placeholder = "Game name", onChange = { e -> val input = e.currentTarget as HTMLInputElement - setState(transformState = { CreateGameFormState(input.value) }) + state.gameName = input.value }, rightElement = createGameButton(), ) diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt index b0976a36..466f9251 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/GameList.kt @@ -15,12 +15,12 @@ import react.dom.* import styled.* import react.State as RState -interface GameListStateProps : PropsWithChildren { +external interface GameListStateProps : PropsWithChildren { var connectedPlayer: ConnectedPlayer var games: List<LobbyDTO> } -interface GameListDispatchProps : PropsWithChildren { +external interface GameListDispatchProps : PropsWithChildren { var joinGame: (Long) -> Unit } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt index 603b46cb..aa1033a0 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/gameBrowser/PlayerInfo.kt @@ -12,7 +12,7 @@ import styled.css import styled.styledDiv import styled.styledSpan -interface PlayerInfoProps : PropsWithChildren { +external interface PlayerInfoProps : PropsWithChildren { var player: BasicPlayerInfo? var showUsername: Boolean var iconSize: Int diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt index 6a4f1059..279e94f2 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/home/ChooseNameForm.kt @@ -14,7 +14,7 @@ import styled.css import styled.styledDiv import styled.styledForm -private interface ChooseNameFormProps : PropsWithChildren { +private external interface ChooseNameFormProps : PropsWithChildren { var chooseUsername: (String) -> Unit } diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt index a8f59bfb..1cb4989c 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/components/lobby/Lobby.kt @@ -19,12 +19,12 @@ import styled.* private val BOT_NAMES = listOf("Wall-E", "B-Max", "Sonny", "T-800", "HAL", "GLaDOS", "R2-D2", "Bender", "AWESOM-O") -interface LobbyStateProps : PropsWithChildren { +external interface LobbyStateProps : PropsWithChildren { var currentGame: LobbyDTO? var currentPlayer: PlayerDTO? } -interface LobbyDispatchProps : PropsWithChildren { +external interface LobbyDispatchProps : PropsWithChildren { var startGame: () -> Unit var addBot: (displayName: String) -> Unit var leaveLobby: () -> Unit diff --git a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt index ffd1a582..d5b3fffd 100644 --- a/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt +++ b/sw-ui/src/main/kotlin/org/luxons/sevenwonders/ui/redux/Utils.kt @@ -6,34 +6,34 @@ import redux.RAction import redux.WrapperAction import kotlin.reflect.KClass -inline fun <reified DP : PropsWithChildren> connectDispatch( +fun <DP : PropsWithChildren> connectDispatch( clazz: KClass<out RComponent<DP, out State>>, - noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, + mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, ): ComponentClass<PropsWithChildren> { val connect = rConnect(mapDispatchToProps = mapDispatchToProps) return connect.invoke(clazz.js.unsafeCast<ComponentClass<DP>>()) } -inline fun <reified SP : PropsWithChildren> connectState( +fun <SP : PropsWithChildren> connectState( clazz: KClass<out RComponent<SP, out State>>, - noinline mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, + mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, ): ComponentClass<PropsWithChildren> { val connect = rConnect(mapStateToProps = mapStateToProps) return connect.invoke(clazz.js.unsafeCast<ComponentClass<SP>>()) } -inline fun <reified SP : PropsWithChildren, OP : PropsWithChildren> connectStateWithOwnProps( +fun <SP : PropsWithChildren, OP : PropsWithChildren> connectStateWithOwnProps( clazz: KClass<out RComponent<SP, out State>>, - noinline mapStateToProps: SP.(SwState, OP) -> Unit, + mapStateToProps: SP.(SwState, OP) -> Unit, ): ComponentClass<OP> { val connect = rConnect(mapStateToProps = mapStateToProps) return connect.invoke(clazz.js.unsafeCast<ComponentClass<SP>>()) } -inline fun <reified SP : PropsWithChildren, reified DP : PropsWithChildren, reified P : PropsWithChildren> connectStateAndDispatch( +fun <SP : PropsWithChildren, DP : PropsWithChildren, P : PropsWithChildren> connectStateAndDispatch( clazz: KClass<out RComponent<P, out State>>, - noinline mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, - noinline mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, + mapStateToProps: SP.(SwState, PropsWithChildren) -> Unit, + mapDispatchToProps: DP.((RAction) -> WrapperAction, PropsWithChildren) -> Unit, ): ComponentClass<PropsWithChildren> { val connect = rConnect<SwState, RAction, WrapperAction, PropsWithChildren, SP, DP, P>( mapStateToProps = mapStateToProps, |