diff options
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/snabbdom')
-rw-r--r-- | src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt b/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt deleted file mode 100644 index 0367633c..00000000 --- a/src/main/kotlin/pl/treksoft/kvision/snabbdom/Types.kt +++ /dev/null @@ -1,107 +0,0 @@ -package pl.treksoft.kvision.snabbdom - -import com.github.snabbdom.Attrs -import com.github.snabbdom.Classes -import com.github.snabbdom.Hooks -import com.github.snabbdom.On -import com.github.snabbdom.Props -import com.github.snabbdom.VNodeData -import com.github.snabbdom.VNodeStyle -import org.w3c.dom.CustomEvent -import org.w3c.dom.CustomEventInit -import pl.treksoft.jquery.JQueryEventObject -import pl.treksoft.kvision.core.Widget - -external class Object - -fun obj(init: dynamic.() -> Unit): dynamic { - return (Object()).apply(init) -} - -@Suppress("UnsafeCastFromDynamic") -private fun vNodeData(): VNodeData = js("({})") - -interface KvJQueryEventObject : JQueryEventObject { - val clickedIndex: Int -} - -@Suppress("UnsafeCastFromDynamic") -class KvEvent(type: String, eventInitDict: CustomEventInit) : CustomEvent(type, eventInitDict) { - override val detail: KvJQueryEventObject = obj {} -} - -interface BtOn : On { - var showBsDropdown: ((KvEvent) -> kotlin.Unit)? - var shownBsDropdown: ((KvEvent) -> kotlin.Unit)? - var hideBsDropdown: ((KvEvent) -> kotlin.Unit)? - var hiddenBsDropdown: ((KvEvent) -> kotlin.Unit)? - var showBsModal: ((KvEvent) -> kotlin.Unit)? - var shownBsModal: ((KvEvent) -> kotlin.Unit)? - var hideBsModal: ((KvEvent) -> kotlin.Unit)? - var hiddenBsModal: ((KvEvent) -> kotlin.Unit)? - var dragSplitPanel: ((KvEvent) -> kotlin.Unit)? - var dragEndSplitPanel: ((KvEvent) -> kotlin.Unit)? - var showBsSelect: ((KvEvent) -> kotlin.Unit)? - var shownBsSelect: ((KvEvent) -> kotlin.Unit)? - var hideBsSelect: ((KvEvent) -> kotlin.Unit)? - var hiddenBsSelect: ((KvEvent) -> kotlin.Unit)? - var loadedBsSelect: ((KvEvent) -> kotlin.Unit)? - var renderedBsSelect: ((KvEvent) -> kotlin.Unit)? - var refreshedBsSelect: ((KvEvent) -> kotlin.Unit)? - var changedBsSelect: ((KvEvent) -> kotlin.Unit)? - var changeDate: ((KvEvent) -> kotlin.Unit)? - var showBsDateTime: ((KvEvent) -> kotlin.Unit)? - var hideBsDateTime: ((KvEvent) -> kotlin.Unit)? - var onMinBsSpinner: ((KvEvent) -> kotlin.Unit)? - var onMaxBsSpinner: ((KvEvent) -> kotlin.Unit)? - var updateModel: ((KvEvent) -> kotlin.Unit)? -} - -interface SnOn<T> : BtOn { - var self: T -} - -fun snOpt(block: VNodeData.() -> Unit) = (vNodeData()::apply)(block) - -@Suppress("UnsafeCastFromDynamic") -internal fun on(widget: Widget): SnOn<Widget> { - val obj = js("({})") - obj["self"] = widget - return obj -} - -@Suppress("UnsafeCastFromDynamic") -internal fun hooks(): Hooks { - return js("({})") -} - -typealias StringPair = Pair<String, String> -typealias StringBoolPair = Pair<String, Boolean> - -@Suppress("UnsafeCastFromDynamic") -fun snStyle(pairs: List<StringPair>): VNodeStyle { - return obj { - pairs.forEach { (key, value) -> this[key] = value } - } -} - -@Suppress("UnsafeCastFromDynamic") -fun snProps(pairs: List<StringPair>): Props { - return obj { - pairs.forEach { (key, value) -> this[key] = value } - } -} - -@Suppress("UnsafeCastFromDynamic") -fun snClasses(pairs: List<StringBoolPair>): Classes { - return obj { - pairs.forEach { (key, value) -> this[key] = value } - } -} - -@Suppress("UnsafeCastFromDynamic") -fun snAttrs(pairs: List<StringPair>): Attrs { - return obj { - pairs.forEach { (key, value) -> this[key] = value } - } -} |