refactor invoke functions

This commit is contained in:
InsanusMokrassar 2022-03-01 00:49:19 +06:00
parent c81c1125a0
commit 3c7f17523b
4 changed files with 14 additions and 9 deletions

View File

@ -17,7 +17,7 @@ private class DialogDisposableEffectResult(
) : DisposableEffectResult {
override fun dispose() {
onDispose?.invoke()
js("UIkit").modal("#${element.id}") ?.hide()
UIKit.modal("#${element.id}") ?.hide()
onDisposed?.invoke()
}
}
@ -99,7 +99,7 @@ fun Dialog(
}
htmlElement.addEventListener("hidden", wrapper)
UIKit.modal("#${htmlElement.id}").show()
UIKit.modal("#${htmlElement.id}") ?.show()
}
}
}

View File

@ -1,6 +1,16 @@
package dev.inmo.jsuikit.types
import org.w3c.dom.Element
import kotlin.js.Json
external interface UIKit {
val notification: UIKitNotifications
val modal: UIKitDialogs
fun notification(message: String, parameters: Json)
fun notification(element: Element): UIKitNotification?
fun modal(element: Element): UIKitDialog
fun modal(selector: String): UIKitDialog?
}

View File

@ -4,8 +4,6 @@ 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

View File

@ -1,5 +1,6 @@
package dev.inmo.jsuikit.types
import dev.inmo.jsuikit.modifiers.UIKit
import dev.inmo.jsuikit.utils.Milliseconds
import org.w3c.dom.Element
import kotlin.js.Json
@ -10,10 +11,6 @@ typealias NotificationsGroup = String
external interface UIKitNotifications {
fun closeAll(group: NotificationsGroup)
operator fun invoke(message: String, parameters: Json)
operator fun invoke(element: Element): UIKitNotification?
}
external interface UIKitNotification {
@ -39,7 +36,7 @@ data class UIKitNotificationsParameters(
operator fun UIKitNotifications.invoke(
message: String,
parameters: UIKitNotificationsParameters
) = invoke(message, parameters.parametersJson())
) = UIKit.notification(message, parameters.parametersJson())
operator fun UIKitNotifications.invoke(
message: String,