add several builders for AttrsWithContentBuilder

This commit is contained in:
InsanusMokrassar 2022-05-19 14:15:05 +06:00
parent 3afe6c2815
commit d78acce3c5
2 changed files with 23 additions and 1 deletions

View File

@ -10,7 +10,7 @@ import org.w3c.dom.HTMLDivElement
@Composable
fun DropArea(
attrs: Attrs<HTMLDivElement> = Attrs.empty(),
inputAttrs: InputAttrs<String> = Attrs.empty(),
inputAttrs: InputAttrs<String> = InputAttrs.empty(),
contentBuilder: ContentBuilder<HTMLDivElement> = {}
) = Div(
{

View File

@ -1,10 +1,32 @@
package dev.inmo.jsuikit.utils
import dev.inmo.jsuikit.modifiers.UIKitModifier
import org.jetbrains.compose.web.attributes.AttrsScope
import org.jetbrains.compose.web.dom.ContentBuilder
import org.w3c.dom.Element
typealias AttrsWithContentBuilder<T> = Pair<Attrs<T>, ContentBuilder<T>>
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Element> AttrsWithContentBuilder(noinline builder: ContentBuilder<T>) = AttrsWithContentBuilder(
Attrs.empty(),
builder
)
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Element> AttrsWithContentBuilder(attrs: Attrs<T>) = AttrsWithContentBuilder(
attrs
) {}
@Suppress("NOTHING_TO_INLINE")
inline fun <T : Element> AttrsWithContentBuilder(
modifier: UIKitModifier?,
vararg modifiers: UIKitModifier?,
noinline attrs: AttrsScope<T>.() -> Unit = {}
) = AttrsWithContentBuilder(
Attrs(modifier, *modifiers, attrs = attrs)
)
inline val <T : Element> AttrsWithContentBuilder<T>.attrs
get() = first