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 {
|
) : DisposableEffectResult {
|
||||||
override fun dispose() {
|
override fun dispose() {
|
||||||
onDispose?.invoke()
|
onDispose?.invoke()
|
||||||
js("UIkit").modal("#${element.id}") ?.hide()
|
UIKit.modal("#${element.id}") ?.hide()
|
||||||
onDisposed?.invoke()
|
onDisposed?.invoke()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ fun Dialog(
|
|||||||
}
|
}
|
||||||
htmlElement.addEventListener("hidden", wrapper)
|
htmlElement.addEventListener("hidden", wrapper)
|
||||||
|
|
||||||
UIKit.modal("#${htmlElement.id}").show()
|
UIKit.modal("#${htmlElement.id}") ?.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
package dev.inmo.jsuikit.types
|
package dev.inmo.jsuikit.types
|
||||||
|
|
||||||
|
import org.w3c.dom.Element
|
||||||
|
import kotlin.js.Json
|
||||||
|
|
||||||
external interface UIKit {
|
external interface UIKit {
|
||||||
val notification: UIKitNotifications
|
val notification: UIKitNotifications
|
||||||
val modal: UIKitDialogs
|
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
|
import kotlin.js.Promise
|
||||||
|
|
||||||
external interface UIKitDialogs {
|
external interface UIKitDialogs {
|
||||||
operator fun invoke(element: Element): UIKitDialog
|
|
||||||
operator fun invoke(selector: String): UIKitDialog
|
|
||||||
fun alert(text: String): UIKitDialogPromiseAlert
|
fun alert(text: String): UIKitDialogPromiseAlert
|
||||||
fun confirm(text: String): UIKitDialogPromiseConfirm
|
fun confirm(text: String): UIKitDialogPromiseConfirm
|
||||||
fun prompt(title: String): UIKitDialogPromisePrompt
|
fun prompt(title: String): UIKitDialogPromisePrompt
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.jsuikit.types
|
package dev.inmo.jsuikit.types
|
||||||
|
|
||||||
|
import dev.inmo.jsuikit.modifiers.UIKit
|
||||||
import dev.inmo.jsuikit.utils.Milliseconds
|
import dev.inmo.jsuikit.utils.Milliseconds
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
import kotlin.js.Json
|
import kotlin.js.Json
|
||||||
@ -10,10 +11,6 @@ typealias NotificationsGroup = String
|
|||||||
external interface UIKitNotifications {
|
external interface UIKitNotifications {
|
||||||
|
|
||||||
fun closeAll(group: NotificationsGroup)
|
fun closeAll(group: NotificationsGroup)
|
||||||
|
|
||||||
operator fun invoke(message: String, parameters: Json)
|
|
||||||
|
|
||||||
operator fun invoke(element: Element): UIKitNotification?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
external interface UIKitNotification {
|
external interface UIKitNotification {
|
||||||
@ -39,7 +36,7 @@ data class UIKitNotificationsParameters(
|
|||||||
operator fun UIKitNotifications.invoke(
|
operator fun UIKitNotifications.invoke(
|
||||||
message: String,
|
message: String,
|
||||||
parameters: UIKitNotificationsParameters
|
parameters: UIKitNotificationsParameters
|
||||||
) = invoke(message, parameters.parametersJson())
|
) = UIKit.notification(message, parameters.parametersJson())
|
||||||
|
|
||||||
operator fun UIKitNotifications.invoke(
|
operator fun UIKitNotifications.invoke(
|
||||||
message: String,
|
message: String,
|
||||||
|
Loading…
Reference in New Issue
Block a user