2022-05-19 06:13:13 +00:00
|
|
|
package dev.inmo.jsuikit.utils
|
|
|
|
|
2022-05-19 08:15:05 +00:00
|
|
|
import dev.inmo.jsuikit.modifiers.UIKitModifier
|
|
|
|
import org.jetbrains.compose.web.attributes.AttrsScope
|
2022-05-19 06:13:13 +00:00
|
|
|
import org.jetbrains.compose.web.dom.ContentBuilder
|
|
|
|
import org.w3c.dom.Element
|
|
|
|
|
|
|
|
typealias AttrsWithContentBuilder<T> = Pair<Attrs<T>, ContentBuilder<T>>
|
|
|
|
|
2022-05-19 08:15:05 +00:00
|
|
|
@Suppress("NOTHING_TO_INLINE")
|
2022-05-19 12:56:52 +00:00
|
|
|
inline fun <T : Element> AttrsWithContentBuilder(
|
|
|
|
vararg modifiers: UIKitModifier?,
|
|
|
|
noinline attrs: AttrsScope<T>.() -> Unit = {},
|
|
|
|
noinline builder: ContentBuilder<T>
|
|
|
|
) = AttrsWithContentBuilder(
|
|
|
|
Attrs(*modifiers, attrs = attrs),
|
2022-05-19 08:15:05 +00:00
|
|
|
builder
|
|
|
|
)
|
|
|
|
|
|
|
|
@Suppress("NOTHING_TO_INLINE")
|
|
|
|
inline fun <T : Element> AttrsWithContentBuilder(attrs: Attrs<T>) = AttrsWithContentBuilder(
|
|
|
|
attrs
|
|
|
|
) {}
|
|
|
|
|
2022-05-19 06:13:13 +00:00
|
|
|
inline val <T : Element> AttrsWithContentBuilder<T>.attrs
|
|
|
|
get() = first
|
|
|
|
|
|
|
|
inline val <T : Element> AttrsWithContentBuilder<T>.attributesBuilderContext
|
|
|
|
get() = attrs.builder
|
|
|
|
|
|
|
|
inline val <T : Element> AttrsWithContentBuilder<T>.builder
|
|
|
|
get() = second
|