add opportunity to now show dialog automatically

This commit is contained in:
InsanusMokrassar 2023-01-03 18:37:01 +06:00
parent 5dff8d69f2
commit 432a5744b3
2 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,8 @@
## 0.4.3 ## 0.4.3
* Add opportunity to now show dialog automatically
## 0.4.2 ## 0.4.2
* `Compose`: `1.2.2` * `Compose`: `1.2.2`

View File

@ -36,6 +36,7 @@ fun Dialog(
footerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null, footerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
footerBuilder: ContentBuilder<HTMLDivElement>? = null, footerBuilder: ContentBuilder<HTMLDivElement>? = null,
bodyAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null, bodyAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
autoShow: Boolean = true,
bodyBuilder: ContentBuilder<HTMLDivElement> bodyBuilder: ContentBuilder<HTMLDivElement>
) { ) {
Div( Div(
@ -99,7 +100,9 @@ fun Dialog(
} }
htmlElement.addEventListener("hidden", wrapper) 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, hidden: (() -> Unit)? = null,
footerBuilder: (@Composable () -> Unit)? = null, footerBuilder: (@Composable () -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {}, attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
autoShow: Boolean = true,
bodyBuilder: @Composable () -> Unit bodyBuilder: @Composable () -> Unit
) = Dialog( ) = Dialog(
modifiers = modifiers, modifiers = modifiers,
@ -130,6 +134,7 @@ fun Dialog(
attributesCustomizer = { attributesCustomizer = {
attributesCustomizer() attributesCustomizer()
}, },
autoShow = autoShow,
bodyBuilder = { bodyBuilder = {
bodyBuilder() bodyBuilder()
} }