From 432a5744b3781f913dde9f5ab62621c1f69c4aa1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 3 Jan 2023 18:37:01 +0600 Subject: [PATCH] add opportunity to now show dialog automatically --- CHANGELOG.md | 2 ++ src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 227d13e..7139c03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 0.4.3 +* Add opportunity to now show dialog automatically + ## 0.4.2 * `Compose`: `1.2.2` diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt index 60fe10e..d8f574f 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/Dialog.kt @@ -36,6 +36,7 @@ fun Dialog( footerAttrsBuilder: AttrBuilderContext? = null, footerBuilder: ContentBuilder? = null, bodyAttrsBuilder: AttrBuilderContext? = null, + autoShow: Boolean = true, bodyBuilder: ContentBuilder ) { Div( @@ -99,7 +100,9 @@ fun Dialog( } htmlElement.addEventListener("hidden", wrapper) - UIKit.modal("#${htmlElement.id}") ?.show() + if (autoShow) { + UIKit.modal("#${htmlElement.id}") ?.show() + } } } } @@ -112,6 +115,7 @@ fun Dialog( hidden: (() -> Unit)? = null, footerBuilder: (@Composable () -> Unit)? = null, attributesCustomizer: AttrBuilderContext = {}, + autoShow: Boolean = true, bodyBuilder: @Composable () -> Unit ) = Dialog( modifiers = modifiers, @@ -130,6 +134,7 @@ fun Dialog( attributesCustomizer = { attributesCustomizer() }, + autoShow = autoShow, bodyBuilder = { bodyBuilder() }