mirror of
https://github.com/InsanusMokrassar/JSUIKitKBindings.git
synced 2024-11-26 20:18:49 +00:00
refactor invoke functions
This commit is contained in:
parent
c81c1125a0
commit
3c7f17523b
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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?
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user