diff --git a/.gitignore b/.gitignore
index 6ac6440..3201572 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
# Created by .ignore support plugin (hsz.mobi)
gradle.properties
+web
diff --git a/.idea/artifacts/komp_todo_js_0_1_0_SNAPSHOT.xml b/.idea/artifacts/komp_todo_js_0_1_0_SNAPSHOT.xml
new file mode 100644
index 0000000..bfc44e5
--- /dev/null
+++ b/.idea/artifacts/komp_todo_js_0_1_0_SNAPSHOT.xml
@@ -0,0 +1,6 @@
+
+
+ $PROJECT_DIR$/build/libs
+
+
+
\ No newline at end of file
diff --git a/.idea/artifacts/komp_todo_js_0_2_0_SNAPSHOT.xml b/.idea/artifacts/komp_todo_js_0_2_0_SNAPSHOT.xml
new file mode 100644
index 0000000..db301df
--- /dev/null
+++ b/.idea/artifacts/komp_todo_js_0_2_0_SNAPSHOT.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/build/libs
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/aws.xml b/.idea/aws.xml
new file mode 100644
index 0000000..b63b642
--- /dev/null
+++ b/.idea/aws.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 2707cef..0322144 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -31,5 +31,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/komp-todo.iml b/.idea/komp-todo.iml
new file mode 100644
index 0000000..167fbc2
--- /dev/null
+++ b/.idea/komp-todo.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/libraries-with-intellij-classes.xml b/.idea/libraries-with-intellij-classes.xml
new file mode 100644
index 0000000..9fa3156
--- /dev/null
+++ b/.idea/libraries-with-intellij-classes.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 2fbddba..c3df5ec 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,12 +5,4 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 8660eef..7f729a7 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,25 +1,22 @@
+import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackOutput.Target.VAR
plugins {
- kotlin("multiplatform") version "1.4.30"
+ kotlin("multiplatform") version "1.6.10"
`maven-publish`
}
group = "nl.astraeus"
-version = "0.1.0-SNAPSHOT"
+version = "1.0.0"
repositories {
mavenCentral()
- jcenter()
- maven {
- url = uri("http://nexus.astraeus.nl/nexus/content/groups/public")
- }
}
kotlin {
/* Targets configuration omitted.
* To find out how to configure the targets, please follow the link:
* https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#setting-up-targets */
- js(IR) {
+ js((IR)) {
binaries.executable()
browser {
//produceKotlinLibrary()
@@ -37,13 +34,9 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
- implementation("nl.astraeus:komp:0.2.5-SNAPSHOT")
- }
- }
- val jsMain by getting {
- dependencies {
- implementation(kotlin("stdlib-js"))
+ implementation("nl.astraeus:kotlin-komponent:1.0.0")
}
}
+ val jsMain by getting
}
}
diff --git a/src/jsMain/kotlin/nl/astraeus/komp/todo/Todo.kt b/src/jsMain/kotlin/nl/astraeus/komp/todo/Todo.kt
index 422436b..3127cca 100644
--- a/src/jsMain/kotlin/nl/astraeus/komp/todo/Todo.kt
+++ b/src/jsMain/kotlin/nl/astraeus/komp/todo/Todo.kt
@@ -7,7 +7,6 @@ import kotlinx.html.js.onDoubleClickFunction
import kotlinx.html.js.onKeyPressFunction
import nl.astraeus.komp.HtmlBuilder
import nl.astraeus.komp.Komponent
-import nl.astraeus.komp.include
import org.w3c.dom.HTMLInputElement
import org.w3c.dom.events.Event
import org.w3c.dom.events.KeyboardEvent
@@ -38,7 +37,7 @@ class TodoKomponent(
override fun HtmlBuilder.render() {
li {
if (todo.editing) {
- classes += "editing"
+ classes = classes + "editing"
input(classes = "edit") {
value = todo.title
onKeyPressFunction = { e ->
@@ -50,15 +49,15 @@ class TodoKomponent(
}
} else {
if (todo.completed) {
- classes += "completed"
+ classes = classes + "completed"
}
- attributes["data-id"] = todo.dataId
div(classes = "view") {
input(classes = "toggle") {
type = InputType.checkBox
checked = todo.completed
onClickFunction = {
app.todoClicked(todo)
+ it.preventDefault()
}
}
label(classes = "todo-content") {
@@ -162,7 +161,14 @@ class TodoApp : Komponent() {
autoFocus = true
onKeyPressFunction = { e ->
val target = e.target
- if (target is HTMLInputElement && e is KeyboardEvent && e.keyCode == 13 && target.value.isNotBlank()) {
+ if (target is HTMLInputElement &&
+ e is KeyboardEvent &&
+ e.keyCode == 13 &&
+ target.value.isNotBlank()
+ ) {
+ e.preventDefault()
+ e.stopPropagation()
+
addTodo(e)
target.value = ""
@@ -201,7 +207,7 @@ class TodoApp : Komponent() {
li {
a {
if (selection == selected) {
- classes += "selected"
+ classes = classes + "selected"
}
href = "#"
+selection.title
@@ -225,5 +231,10 @@ class TodoApp : Komponent() {
}
fun main() {
- Komponent.create(document.body!!, TodoApp(), true)
+ Komponent.logReplaceEvent = false
+ Komponent.logRenderEvent = false
+
+ println("Create TodoApp()")
+
+ Komponent.create(document.body!!, TodoApp())
}