add UIKitDialog

This commit is contained in:
InsanusMokrassar 2022-03-01 00:14:17 +06:00
parent 2e28334b41
commit c81c1125a0
3 changed files with 42 additions and 3 deletions

View File

@ -99,9 +99,7 @@ fun Dialog(
}
htmlElement.addEventListener("hidden", wrapper)
val dialog = UIKit.modal("#${htmlElement.id}")
dialog.show()
Unit
UIKit.modal("#${htmlElement.id}").show()
}
}
}

View File

@ -2,4 +2,5 @@ package dev.inmo.jsuikit.types
external interface UIKit {
val notification: UIKitNotifications
val modal: UIKitDialogs
}

View File

@ -0,0 +1,40 @@
package dev.inmo.jsuikit.types
import org.w3c.dom.Element
import kotlin.js.Promise
external interface UIKitDialogs {
operator fun invoke(element: Element): UIKitDialog
operator fun invoke(selector: String): UIKitDialog
fun alert(text: String): UIKitDialogPromiseAlert
fun confirm(text: String): UIKitDialogPromiseConfirm
fun prompt(title: String): UIKitDialogPromisePrompt
fun prompt(title: String, preset: String): UIKitDialogPromisePrompt
fun dialog(element: Element): UIKitDialog
}
external class UIKitDialogPromiseConfirm : Promise<Unit> {
val dialog: UIKitDialog
fun then(
onConfirm: () -> Unit = definedExternally,
onRejected: () -> Unit = definedExternally,
)
}
external class UIKitDialogPromisePrompt : Promise<Unit> {
val dialog: UIKitDialog
fun then(onResult: (data: String?) -> Unit)
}
external class UIKitDialogPromiseAlert : Promise<Unit> {
val dialog: UIKitDialog
fun then(onClose: () -> Unit)
}
external interface UIKitDialog {
fun show()
fun hide()
}