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
* Add opportunity to now show dialog automatically
## 0.4.2
* `Compose`: `1.2.2`

View File

@ -36,6 +36,7 @@ fun Dialog(
footerAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
footerBuilder: ContentBuilder<HTMLDivElement>? = null,
bodyAttrsBuilder: AttrBuilderContext<HTMLDivElement>? = null,
autoShow: Boolean = true,
bodyBuilder: ContentBuilder<HTMLDivElement>
) {
Div(
@ -99,9 +100,11 @@ fun Dialog(
}
htmlElement.addEventListener("hidden", wrapper)
if (autoShow) {
UIKit.modal("#${htmlElement.id}") ?.show()
}
}
}
}
@Composable
@ -112,6 +115,7 @@ fun Dialog(
hidden: (() -> Unit)? = null,
footerBuilder: (@Composable () -> Unit)? = null,
attributesCustomizer: AttrBuilderContext<HTMLDivElement> = {},
autoShow: Boolean = true,
bodyBuilder: @Composable () -> Unit
) = Dialog(
modifiers = modifiers,
@ -130,6 +134,7 @@ fun Dialog(
attributesCustomizer = {
attributesCustomizer()
},
autoShow = autoShow,
bodyBuilder = {
bodyBuilder()
}