From 251a0dcfa4fc9c223ce7cabef596739114575c10 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 23 Jun 2024 21:55:34 +0000 Subject: [PATCH 1/3] chore(deps): update plugin com.diffplug.spotless to v6.25.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index bf82c0a6..175bd79b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { kotlin("plugin.allopen") version "1.8.10" kotlin("plugin.serialization") version "1.8.10" id("com.github.johnrengelman.shadow") version "7.1.2" - id("com.diffplug.spotless") version "6.17.0" + id("com.diffplug.spotless") version "6.25.0" id("idea") } From 0f72b89cae52ea353b450ec4f18801962c6a6209 Mon Sep 17 00:00:00 2001 From: Illia Kovalov Date: Wed, 26 Jun 2024 23:02:38 +0200 Subject: [PATCH 2/3] fix js compile, add jsTest pipeline step --- .github/workflows/gradle.yml | 3 +- build.gradle.kts | 8 +- src/jsMain/kotlin/com.github.ikovalyov/App.kt | 18 +++- .../kotlin/com.github.ikovalyov/Main.kt | 48 ++++++----- .../com.github.ikovalyov/extenstion/Dom.kt | 15 ---- .../react/components/bootstrap/Button.kt | 6 +- .../react/components/bootstrap/Div.kt | 4 +- .../react/components/bootstrap/Input.kt | 6 +- .../components/bootstrap/ScreenReaderSpan.kt | 2 +- .../react/components/bootstrap/nav/Anchor.kt | 2 +- .../bootstrap/nav/CollapseButton.kt | 4 +- .../components/bootstrap/nav/MenuItem.kt | 2 +- .../react/components/template/Crud.kt | 82 +++++++++---------- .../react/components/template/ItemList.kt | 4 +- .../react/components/template/TemplateEdit.kt | 10 +-- .../components/template/TemplateInsert.kt | 20 ++--- .../react/components/template/table/Button.kt | 8 +- .../react/components/template/table/Table.kt | 15 +--- .../com.github.ikovalyov/routes/Index.kt | 3 +- .../com.github.ikovalyov/styles/Colors.kt | 2 +- 20 files changed, 119 insertions(+), 143 deletions(-) delete mode 100644 src/jsMain/kotlin/com.github.ikovalyov/extenstion/Dom.kt diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f9c86e91..f15692d3 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -22,9 +22,8 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew jvmTest + run: ./gradlew jvmTest jsTest spotless: - runs-on: ubuntu-latest steps: diff --git a/build.gradle.kts b/build.gradle.kts index 173dd9d5..22f855b6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -49,7 +49,7 @@ kotlin { } } } - js { + js(IR) { browser { commonWebpackConfig { cssSupport { @@ -208,8 +208,7 @@ spotless { val files = project.fileTree(rootDir) files.include("**/*.kt") target(files) - ktlint("0.47.1") - .setUseExperimental(true) + ktlint("1.3.0") .editorConfigOverride( mapOf( "max_line_length" to "256", @@ -218,8 +217,7 @@ spotless { ) } kotlinGradle { - ktlint("0.47.1") - .setUseExperimental(true) + ktlint("1.3.0") .editorConfigOverride( mapOf( "max_line_length" to "256", diff --git a/src/jsMain/kotlin/com.github.ikovalyov/App.kt b/src/jsMain/kotlin/com.github.ikovalyov/App.kt index 81b03f93..ea13c588 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/App.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/App.kt @@ -6,8 +6,6 @@ import com.github.ikovalyov.react.components.bootstrap.Input import com.github.ikovalyov.react.components.bootstrap.ScreenReaderSpan import com.github.ikovalyov.react.components.bootstrap.nav.CollapseButton import com.github.ikovalyov.react.components.bootstrap.nav.menuItem -import csstype.ClassName -import csstype.px import emotion.react.css import react.FC import react.Props @@ -16,6 +14,8 @@ import react.dom.html.ReactHTML.form import react.dom.html.ReactHTML.nav import react.dom.html.ReactHTML.ul import react.router.dom.Link +import web.cssom.ClassName +import web.cssom.px const val navbarTogglerId = "navbarTogglerDemo01" val App = FC { @@ -38,8 +38,18 @@ val App = FC { +"Home " ScreenReaderSpan("(current)") } - menuItem(href = "${Api.backendEndpoint}/oauth/login/google", active = false, disabled = false, reactLink = false) { +"Login" } - menuItem(href = "${Api.backendEndpoint}/logout", active = false, disabled = false, reactLink = false) { +"Logout" } + menuItem( + href = "${Api.backendEndpoint}/oauth/login/google", + active = false, + disabled = false, + reactLink = false + ) { +"Login" } + menuItem( + href = "${Api.backendEndpoint}/logout", + active = false, + disabled = false, + reactLink = false + ) { +"Logout" } menuItem(href = "#", active = false, disabled = true) { +"Disabled" } } form { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/Main.kt b/src/jsMain/kotlin/com.github.ikovalyov/Main.kt index c9071652..ce8d67e3 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/Main.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/Main.kt @@ -4,15 +4,16 @@ import com.github.ikovalyov.model.security.service.SecurityService import com.github.ikovalyov.model.service.TemplateService import com.github.ikovalyov.model.service.UserService import com.github.ikovalyov.routes.Index -import csstype.ClassName import kotlinx.serialization.ExperimentalSerializationApi +import react.FC import react.Fragment import react.create import react.dom.client.createRoot import react.dom.html.ReactHTML -import react.router.Route -import react.router.Routes -import react.router.dom.BrowserRouter +import react.router.RouteObject +import react.router.RouterProvider +import react.router.dom.createBrowserRouter +import web.cssom.ClassName import web.dom.document @OptIn(ExperimentalSerializationApi::class) @@ -25,25 +26,32 @@ suspend fun main() { val allUsers = userService.getAllUsers() val templateService = TemplateService() val allTemplates = templateService.getAllTemplates() - root.render( - Fragment.create { - BrowserRouter { - App { } - ReactHTML.div { - className = ClassName("container-fluid") - Routes { - Route { - index = true - element = Index.create { - this.currentUser = currentUser - this.userList = allUsers - this.templateList = allTemplates - } - path = "/" + + val APP_ROUTER = createBrowserRouter( + arrayOf( + RouteObject( + path = "/", + element = Fragment.create { + +App.create() + ReactHTML.div { + className = ClassName("container-fluid") + +Index.create { + this.currentUser = currentUser + this.userList = allUsers + this.templateList = allTemplates } } } - } + ) + ) + ) + + val ReactRouterDomApp = FC { + RouterProvider { + router = APP_ROUTER } + } + root.render( + ReactRouterDomApp.create() ) } diff --git a/src/jsMain/kotlin/com.github.ikovalyov/extenstion/Dom.kt b/src/jsMain/kotlin/com.github.ikovalyov/extenstion/Dom.kt deleted file mode 100644 index b8be5fb5..00000000 --- a/src/jsMain/kotlin/com.github.ikovalyov/extenstion/Dom.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.ikovalyov.extenstion - -import js.core.Object -import react.Props -import react.dom.html.HTMLAttributes -import web.dom.Element - -var HTMLAttributes.extraAttrs: Props - @Deprecated(level = DeprecationLevel.HIDDEN, message = "write only") - get() = error("write only") - set(value) { - for (key in Object.keys(value)) { - asDynamic()[key] = value.asDynamic()[key] - } - } diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Button.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Button.kt index a70522f7..4cfe030f 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Button.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Button.kt @@ -1,12 +1,12 @@ package com.github.ikovalyov.react.components.bootstrap -import csstype.ClassName import react.ChildrenBuilder -import react.dom.html.ButtonType import react.dom.html.ReactHTML +import web.cssom.ClassName +import web.html.ButtonType sealed class Button { - abstract operator fun invoke(builder: ChildrenBuilder, block: ChildrenBuilder.() -> Unit): Unit + abstract operator fun invoke(builder: ChildrenBuilder, block: ChildrenBuilder.() -> Unit) object ButtonOutlineSuccess : Button() { override operator fun invoke(builder: ChildrenBuilder, block: ChildrenBuilder.() -> Unit) { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Div.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Div.kt index c0447800..f5493926 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Div.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Div.kt @@ -1,11 +1,11 @@ package com.github.ikovalyov.react.components.bootstrap -import csstype.ClassName import react.ChildrenBuilder import react.dom.html.ReactHTML +import web.cssom.ClassName sealed class Div { - abstract operator fun invoke(builder: ChildrenBuilder, block: ChildrenBuilder.() -> Unit): Unit + abstract operator fun invoke(builder: ChildrenBuilder, block: ChildrenBuilder.() -> Unit) object ContainerFluidDiv : Div() { override operator fun invoke(builder: ChildrenBuilder, block: ChildrenBuilder.() -> Unit) { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Input.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Input.kt index 1344dfd3..3f3d3fec 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Input.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/Input.kt @@ -1,13 +1,13 @@ package com.github.ikovalyov.react.components.bootstrap import com.github.ikovalyov.react.components.bootstrap.nav.ariaLabel -import csstype.ClassName import react.ChildrenBuilder -import react.dom.html.InputType import react.dom.html.ReactHTML +import web.cssom.ClassName +import web.html.InputType sealed class Input { - abstract operator fun invoke(name: String, builder: ChildrenBuilder): Unit + abstract operator fun invoke(name: String, builder: ChildrenBuilder) object SearchInput : Input() { override operator fun invoke(name: String, builder: ChildrenBuilder) { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/ScreenReaderSpan.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/ScreenReaderSpan.kt index adafda47..5104c3fa 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/ScreenReaderSpan.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/ScreenReaderSpan.kt @@ -1,8 +1,8 @@ package com.github.ikovalyov.react.components.bootstrap -import csstype.ClassName import react.ChildrenBuilder import react.dom.html.ReactHTML +import web.cssom.ClassName fun ChildrenBuilder.ScreenReaderSpan(text: String) { ReactHTML.span { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/Anchor.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/Anchor.kt index c9a612d1..72f42085 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/Anchor.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/Anchor.kt @@ -1,9 +1,9 @@ package com.github.ikovalyov.react.components.bootstrap.nav -import csstype.ClassName import kotlinx.browser.window import react.ChildrenBuilder import react.router.dom.Link +import web.cssom.ClassName fun ChildrenBuilder.ReactAnchor(hrefString: String, active: Boolean, disabled: Boolean, block: ChildrenBuilder.() -> Unit) { Link { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/CollapseButton.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/CollapseButton.kt index e66a4267..a34ea78c 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/CollapseButton.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/CollapseButton.kt @@ -1,11 +1,11 @@ package com.github.ikovalyov.react.components.bootstrap.nav -import csstype.ClassName import react.ChildrenBuilder -import react.dom.html.ButtonType import react.dom.html.HTMLAttributes import react.dom.html.ReactHTML import react.dom.html.ReactHTML.span +import web.cssom.ClassName +import web.html.ButtonType var HTMLAttributes<*>.dataBsToggle: String? get() = asDynamic()["data-bs-toggle"] diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/MenuItem.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/MenuItem.kt index 4684254f..24eee5b6 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/MenuItem.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/bootstrap/nav/MenuItem.kt @@ -1,8 +1,8 @@ package com.github.ikovalyov.react.components.bootstrap.nav -import csstype.ClassName import react.ChildrenBuilder import react.dom.html.ReactHTML.div +import web.cssom.ClassName fun ChildrenBuilder.menuItem(href: String, active: Boolean, disabled: Boolean, reactLink: Boolean = true, block: ChildrenBuilder.() -> Unit) { div { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/Crud.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/Crud.kt index f6069d06..664732d3 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/Crud.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/Crud.kt @@ -4,7 +4,7 @@ import com.benasher44.uuid.Uuid import com.github.ikovalyov.Api.backendEndpoint import com.github.ikovalyov.coroutines.SimpleCoroutineScope import com.github.ikovalyov.model.markers.IEditable -import js.core.jso +import js.objects.jso import kotlinx.browser.window import kotlinx.coroutines.await import kotlinx.coroutines.launch @@ -197,62 +197,54 @@ private fun ChildrenBuilder.CrudComponent(props: CrudComponentPr CrudState.LIST -> { console.log("Loading ItemList") - child( - ItemList( - jso> { - switchToEditState = ::switchToEditStateFuncVar - switchToViewState = ::switchToViewStateFunc - switchToInsertState = ::switchToInsertStateFunc - deleteItem = ::deleteItem - items = componentState.itemsList - } - ).render() - ) + +ItemList( + jso> { + switchToEditState = ::switchToEditStateFuncVar + switchToViewState = ::switchToViewStateFunc + switchToInsertState = ::switchToInsertStateFunc + deleteItem = ::deleteItem + items = componentState.itemsList + } + ).render() } CrudState.EDIT -> { console.log("Loading TemplateEdit") - child( - TemplateEdit( - jso { - switchToListState = ::switchToListViewStateFunc - submitForm = ::submitEditItemForm - }, - jso> { - item = componentState.currentItem!! - } - ).render() - ) + +TemplateEdit( + jso { + switchToListState = ::switchToListViewStateFunc + submitForm = ::submitEditItemForm + }, + jso> { + item = componentState.currentItem!! + } + ).render() } CrudState.VIEW -> { console.log("Loading TemplateView") - child( - TemplateView( - jso> { - switchToListState = ::switchToListViewStateFunc - }, - jso { - item = componentState.currentItem!! - } - ).render() - ) + +TemplateView( + jso> { + switchToListState = ::switchToListViewStateFunc + }, + jso { + item = componentState.currentItem!! + } + ).render() } CrudState.ADD -> { console.log("Loading TemplateInsert") - child( - TemplateInsert( - jso> { - this.item = props.factory() - this.submitForm = ::submitInsertItemForm - this.switchToListState = ::switchToListViewStateFunc - }, - jso { - this.currentItem = props.factory() - } - ).render() - ) + +TemplateInsert( + jso> { + this.item = props.factory() + this.submitForm = ::submitInsertItemForm + this.switchToListState = ::switchToListViewStateFunc + }, + jso { + this.currentItem = props.factory() + } + ).render() } } } diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/ItemList.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/ItemList.kt index 6e1f7882..75aaf98c 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/ItemList.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/ItemList.kt @@ -10,8 +10,8 @@ import react.Fragment import react.PropsWithChildren import react.ReactNode import react.create -import react.dom.html.ButtonType import react.dom.html.ReactHTML +import web.html.ButtonType import kotlin.coroutines.CoroutineContext external interface ItemListProps : PropsWithChildren { @@ -30,7 +30,7 @@ class ItemList(props: ItemListProps) : override val coroutineContext: CoroutineContext get() = job - override fun render(): ReactNode? { + override fun render(): ReactNode { return Fragment.create { Table { items = props.items?.toTypedArray() diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateEdit.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateEdit.kt index 6b55af6b..625d6a68 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateEdit.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateEdit.kt @@ -5,11 +5,6 @@ import com.github.ikovalyov.model.markers.getFieldValueAsString import com.github.ikovalyov.model.markers.getPredefinedValuesAsStrings import com.github.ikovalyov.model.markers.updateField import com.github.ikovalyov.react.components.template.table.Button -import csstype.Color -import csstype.Display -import csstype.Float -import csstype.FontWeight -import csstype.px import emotion.react.css import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -20,7 +15,6 @@ import react.PropsWithChildren import react.ReactNode import react.State import react.create -import react.dom.html.ButtonType import react.dom.html.ReactHTML.fieldset import react.dom.html.ReactHTML.form import react.dom.html.ReactHTML.input @@ -28,6 +22,8 @@ import react.dom.html.ReactHTML.label import react.dom.html.ReactHTML.option import react.dom.html.ReactHTML.p import react.dom.html.ReactHTML.select +import web.cssom.* +import web.html.ButtonType import kotlin.coroutines.CoroutineContext external interface ItemEditProps : PropsWithChildren { @@ -81,7 +77,7 @@ class TemplateEdit( display = Display.block width = 150.px float = Float.left - after { content = "\":\"".asDynamic() } + after { content = Content(":") } } htmlFor = it.hashCode().toString() } diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateInsert.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateInsert.kt index 89ef4294..b0f1599a 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateInsert.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/TemplateInsert.kt @@ -4,11 +4,6 @@ import com.github.ikovalyov.model.markers.IEditable import com.github.ikovalyov.model.markers.getFieldValueAsString import com.github.ikovalyov.model.markers.getPredefinedValuesAsStrings import com.github.ikovalyov.model.markers.updateField -import csstype.Color -import csstype.Display -import csstype.Float -import csstype.FontWeight -import csstype.px import emotion.react.css import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -19,7 +14,6 @@ import react.PropsWithChildren import react.ReactNode import react.State import react.create -import react.dom.html.ButtonType import react.dom.html.ReactHTML import react.dom.html.ReactHTML.button import react.dom.html.ReactHTML.fieldset @@ -28,6 +22,8 @@ import react.dom.html.ReactHTML.input import react.dom.html.ReactHTML.label import react.dom.html.ReactHTML.p import react.dom.html.ReactHTML.select +import web.cssom.* +import web.html.ButtonType import kotlin.coroutines.CoroutineContext external interface TemplateInsertProps : PropsWithChildren { @@ -42,7 +38,7 @@ external interface TemplateInsertState : State { class TemplateInsert( props: TemplateInsertProps, - private val initialState: TemplateInsertState + initialState: TemplateInsertState ) : Component, TemplateInsertState>(props), CoroutineScope { init { @@ -70,13 +66,13 @@ class TemplateInsert( label { +it.fieldName css { - color = csstype.Color("B4886B") - fontWeight = csstype.FontWeight.bold - display = csstype.Display.block + color = Color("B4886B") + fontWeight = FontWeight.bold + display = Display.block width = 150.px - float = csstype.Float.left + float = Float.left after { - content = "\":\"".asDynamic() + content = Content("\":\"") } } htmlFor = it.hashCode().toString() diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Button.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Button.kt index ee27e322..cb45b327 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Button.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Button.kt @@ -1,12 +1,12 @@ package com.github.ikovalyov.react.components.template.table import com.github.ikovalyov.model.markers.IEditable -import js.core.jso +import js.objects.jso import react.ChildrenBuilder import react.FC import react.PropsWithChildren -import react.dom.html.ButtonType import react.dom.html.ReactHTML.button +import web.html.ButtonType external interface ButtonProps : PropsWithChildren { var body: T @@ -25,8 +25,8 @@ private fun ChildrenBuilder.Button(props: ButtonProps) { } } -private val Button: FC> = FC { - this.Button(it) +private val Button: FC> = FC { props -> + Button(props) } fun ChildrenBuilder.Button(block: ButtonProps.() -> Unit) { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Table.kt b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Table.kt index a78fdc0e..97f7bbca 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Table.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/react/components/template/table/Table.kt @@ -3,18 +3,8 @@ package com.github.ikovalyov.react.components.template.table import com.github.ikovalyov.model.markers.IEditable import com.github.ikovalyov.model.markers.getFieldValueAsString import com.github.ikovalyov.styles.Colors -import csstype.Auto -import csstype.BorderCollapse -import csstype.Cursor -import csstype.FontWeight -import csstype.LineStyle -import csstype.Margin -import csstype.Padding -import csstype.TextAlign -import csstype.WhiteSpace -import csstype.px import emotion.react.css -import js.core.jso +import js.objects.jso import react.ChildrenBuilder import react.FC import react.Fragment @@ -35,6 +25,7 @@ import tanstack.table.core.ColumnDefTemplate import tanstack.table.core.StringOrTemplateHeader import tanstack.table.core.Table import tanstack.table.core.getCoreRowModel +import web.cssom.* external interface TableProps : PropsWithChildren { var items: Array? @@ -177,7 +168,7 @@ private fun ChildrenBuilder.buildTableBody(table: Table) { } } -private val Table: FC> = FC { Table(it) } +private val Table: FC> = FC { prop -> Table(prop) } fun ChildrenBuilder.Table(block: TableProps.() -> Unit) { child(type = Table, props = jso(block)) diff --git a/src/jsMain/kotlin/com.github.ikovalyov/routes/Index.kt b/src/jsMain/kotlin/com.github.ikovalyov/routes/Index.kt index 7aa7371d..8d94a27c 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/routes/Index.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/routes/Index.kt @@ -12,7 +12,6 @@ import com.github.ikovalyov.model.security.UserRole import com.github.ikovalyov.react.components.bootstrap.ScreenReaderSpan import com.github.ikovalyov.react.components.bootstrap.nav.menuItem import com.github.ikovalyov.react.components.template.CrudComponent -import csstype.ClassName import kotlinx.datetime.Clock import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.builtins.ListSerializer @@ -22,6 +21,7 @@ import react.Props import react.dom.html.ReactHTML.div import react.dom.html.ReactHTML.nav import react.dom.html.ReactHTML.ul +import web.cssom.ClassName @OptIn(ExperimentalSerializationApi::class) external interface IndexProps : Props { @@ -33,6 +33,7 @@ external interface IndexProps : Props { @OptIn(ExperimentalSerializationApi::class) val Index = FC { props -> val currentUser = props.currentUser + console.log(currentUser) if (currentUser != null) { div { diff --git a/src/jsMain/kotlin/com.github.ikovalyov/styles/Colors.kt b/src/jsMain/kotlin/com.github.ikovalyov/styles/Colors.kt index 6787691b..0e87d53d 100644 --- a/src/jsMain/kotlin/com.github.ikovalyov/styles/Colors.kt +++ b/src/jsMain/kotlin/com.github.ikovalyov/styles/Colors.kt @@ -1,6 +1,6 @@ package com.github.ikovalyov.styles -import csstype.Color +import web.cssom.Color object Colors { object Text { From 02fd7d4f71a1f28f25525d28367e7cf676cf428a Mon Sep 17 00:00:00 2001 From: Illia Kovalov Date: Sat, 29 Jun 2024 09:50:29 +0200 Subject: [PATCH 3/3] spotless --- build.gradle.kts | 20 +- .../com.github.ikovalyov.model/Article.kt | 308 +++++++++--------- .../kotlin/com.github.ikovalyov.model/Item.kt | 30 +- .../kotlin/com.github.ikovalyov.model/Tag.kt | 87 +++-- .../com.github.ikovalyov.model/Template.kt | 37 +-- .../TemplateListItem.kt | 9 +- .../markers/IEditable.kt | 5 +- .../security/Security.kt | 4 +- .../security/ShortString.kt | 8 +- .../security/User.kt | 141 ++++---- .../security/UserRole.kt | 30 +- .../validator/EmailValidator.kt | 4 +- .../kotlin/com/github/ikovalyov/Api.kt | 18 +- src/jsMain/kotlin/com.github.ikovalyov/App.kt | 20 +- .../kotlin/com.github.ikovalyov/Main.kt | 14 +- .../model/security/service/SecurityService.kt | 6 +- .../model/service/TemplateService.kt | 6 +- .../model/service/UserService.kt | 13 +- .../components/bootstrap/ScreenReaderSpan.kt | 2 +- .../react/components/bootstrap/nav/Anchor.kt | 4 +- .../bootstrap/nav/CollapseButton.kt | 2 +- .../components/bootstrap/nav/MenuItem.kt | 4 +- .../react/components/template/Crud.kt | 48 +-- .../react/components/template/ItemList.kt | 44 ++- .../react/components/template/TemplateEdit.kt | 167 +++++----- .../components/template/TemplateInsert.kt | 180 +++++----- .../react/components/template/TemplateView.kt | 37 +-- .../react/components/template/table/Button.kt | 6 +- .../react/components/template/table/Table.kt | 29 +- .../com.github.ikovalyov/routes/Index.kt | 26 +- .../ikovalyov/application/UsersController.kt | 2 +- .../application/api/ArticlesController.kt | 6 +- .../application/api/RecordsController.kt | 10 +- .../application/api/TemplateController.kt | 6 +- .../application/api/UserRolesController.kt | 6 +- .../application/api/UsersApiController.kt | 6 +- .../application/api/ViewsController.kt | 6 +- .../application/auth/AuthController.kt | 6 +- .../ikovalyov/command/DynamoDbInitCommand.kt | 2 +- .../converter/DynamodbArticleConverter.kt | 4 +- .../dynamodb/factory/DynamoDbClientFactory.kt | 20 +- .../repository/AbstractKeyValueRepository.kt | 9 +- .../dynamodb/repository/ArticleRepository.kt | 32 +- .../repository/ConfigurationRepository.kt | 65 ++-- .../dynamodb/repository/CrudRepository.kt | 37 +-- .../dynamodb/repository/RecordsRepository.kt | 7 +- .../dynamodb/repository/TemplateRepository.kt | 37 +-- .../dynamodb/repository/UserRepository.kt | 39 +-- .../dynamodb/repository/UserRoleRepository.kt | 48 ++- .../infrastructure/service/TemplateService.kt | 4 +- .../infrastructure/service/UserService.kt | 4 +- .../ikovalyov/model/extension/Template.kt | 28 +- .../model/extension/UserExtension.kt | 40 +-- .../model/extension/UserRoleExtension.kt | 24 +- .../template/DynamoDbTemplateLoader.kt | 5 +- .../application/api/TemplateControllerTest.kt | 10 +- .../api/UserRolesControllerTest.kt | 26 +- .../repository/ConfigurationRepositoryTest.kt | 3 +- .../repository/RecordsRepositoryTest.kt | 3 +- .../repository/TemplateRepositoryTest.kt | 3 +- .../repository/UserRolesRepositoryTest.kt | 3 +- 61 files changed, 836 insertions(+), 974 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 22f855b6..0b96ecb5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -81,8 +81,8 @@ kotlin { implementation(kotlin("stdlib-js")) implementation( project.dependencies.enforcedPlatform( - "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:1.0.0-pre.763" - ) + "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:1.0.0-pre.763", + ), ) implementation("org.jetbrains.kotlin-wrappers:kotlin-react") implementation("org.jetbrains.kotlin-wrappers:kotlin-react-dom") @@ -131,8 +131,8 @@ kotlin { configurations["kapt"].dependencies.addAll( listOf( project.dependencies.create("io.micronaut:micronaut-inject-java:3.10.4"), - project.dependencies.create("info.picocli:picocli-codegen:4.7.6") - ) + project.dependencies.create("info.picocli:picocli-codegen:4.7.6"), + ), ) if (System.getProperty("os.name").lowercase(Locale.getDefault()).contains("mac")) { implementation("io.micronaut:micronaut-runtime-osx") @@ -146,8 +146,8 @@ kotlin { configurations["kaptTest"].dependencies.addAll( listOf( project.dependencies.create("io.micronaut:micronaut-inject-java:3.10.4"), - project.dependencies.create("info.picocli:picocli-codegen:4.7.6") - ) + project.dependencies.create("info.picocli:picocli-codegen:4.7.6"), + ), ) implementation(kotlin("test-junit5")) @@ -212,8 +212,8 @@ spotless { .editorConfigOverride( mapOf( "max_line_length" to "256", - "insert_final_newline" to "true" - ) + "insert_final_newline" to "true", + ), ) } kotlinGradle { @@ -221,8 +221,8 @@ spotless { .editorConfigOverride( mapOf( "max_line_length" to "256", - "insert_final_newline" to "true" - ) + "insert_final_newline" to "true", + ), ) } } diff --git a/src/commonMain/kotlin/com.github.ikovalyov.model/Article.kt b/src/commonMain/kotlin/com.github.ikovalyov.model/Article.kt index 7cf4c2c0..5745ae0c 100644 --- a/src/commonMain/kotlin/com.github.ikovalyov.model/Article.kt +++ b/src/commonMain/kotlin/com.github.ikovalyov.model/Article.kt @@ -26,162 +26,158 @@ data class Article( val meta: List?, val template: Template?, // Template uuid val userList: List, - val templateList: List