From 6dbd12df59a9f4bbaf42d55161a548434451ccaf Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sat, 12 Mar 2022 01:03:41 +0600 Subject: [PATCH] fill changelog and rename selectOptionalFile to selectFileOrNull --- CHANGELOG.md | 20 +++++++++++++++++++ .../dev/inmo/micro_utils/common/SelectFile.kt | 4 ++-- .../SelectFile.kt | 6 +++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 361f3d568c6..0896b84dfb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ ## 0.9.12 +* `Common`: + * `JS`: + * New function `openLink` + * New function `selectFile` + * New function `triggerDownloadFile` + * `Compose`: + * Created :) + * `Common`: + * `DefaultDisposableEffectResult` as a default realization of `DisposableEffectResult` + * `JS`: + * `openLink` on top of `openLink` with `String` target from common +* `Coroutines`: + * `Compose`: + * `Common`: + * New extension `Flow.toMutableState` + * New extension `StateFlow.toMutableState` + * `JS`: + * New function `selectFile` on top of `selectFile` from `common` + * New function `selectFileOrNull` on top of `selectFile` from `common` + ## 0.9.11 * `Versions`: diff --git a/common/src/jsMain/kotlin/dev/inmo/micro_utils/common/SelectFile.kt b/common/src/jsMain/kotlin/dev/inmo/micro_utils/common/SelectFile.kt index 89c7bc105dd..bd85f4de52b 100644 --- a/common/src/jsMain/kotlin/dev/inmo/micro_utils/common/SelectFile.kt +++ b/common/src/jsMain/kotlin/dev/inmo/micro_utils/common/SelectFile.kt @@ -7,13 +7,13 @@ import org.w3c.dom.HTMLInputElement import org.w3c.files.get fun selectFile( - inputSetup: HTMLInputElement.() -> Unit = {}, + inputSetup: (HTMLInputElement) -> Unit = {}, onFailure: (Throwable) -> Unit = {}, onFile: (MPPFile) -> Unit ) { (document.createElement("input") { (this as HTMLInputElement).apply { - inputSetup() + inputSetup(this) onchange = { runCatching { files ?.get(0) ?: error("File must not be null") diff --git a/coroutines/src/jsMain/kotlin/dev.inmo.micro_utils.coroutines/SelectFile.kt b/coroutines/src/jsMain/kotlin/dev.inmo.micro_utils.coroutines/SelectFile.kt index 525a51b83df..e9ee57f3b42 100644 --- a/coroutines/src/jsMain/kotlin/dev.inmo.micro_utils.coroutines/SelectFile.kt +++ b/coroutines/src/jsMain/kotlin/dev.inmo.micro_utils.coroutines/SelectFile.kt @@ -6,7 +6,7 @@ import kotlinx.coroutines.CompletableDeferred import org.w3c.dom.HTMLInputElement suspend fun selectFile( - inputSetup: HTMLInputElement.() -> Unit = {} + inputSetup: (HTMLInputElement) -> Unit = {} ): MPPFile { val result = CompletableDeferred() @@ -22,8 +22,8 @@ suspend fun selectFile( return result.await() } -suspend fun selectOptionalFile( - inputSetup: HTMLInputElement.() -> Unit = {}, +suspend fun selectFileOrNull( + inputSetup: (HTMLInputElement) -> Unit = {}, onFailure: (Throwable) -> Unit = {} ): MPPFile? { val result = CompletableDeferred()