diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt index 9901aff..ec24ed4 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/elements/DropArea.kt @@ -3,6 +3,7 @@ package dev.inmo.jsuikit.elements import androidx.compose.runtime.Composable import dev.inmo.jsuikit.modifiers.* import dev.inmo.jsuikit.utils.Attrs +import dev.inmo.jsuikit.utils.InputAttrs import org.jetbrains.compose.web.attributes.InputType import org.jetbrains.compose.web.dom.* import org.w3c.dom.HTMLDivElement @@ -11,7 +12,7 @@ import org.w3c.dom.HTMLInputElement @Composable fun DropArea( attrs: Attrs = Attrs.empty(), - inputAttrs: Attrs = Attrs.empty(), + inputAttrs: InputAttrs = Attrs.empty(), contentBuilder: ContentBuilder = {} ) = Div( { @@ -19,6 +20,8 @@ fun DropArea( attrs.builder(this) } ) { - Input(InputType.File, attrs = { inputAttrs.builder.invoke(this) }) + FileInput { + inputAttrs.builder.invoke(this) + } contentBuilder(this) } diff --git a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt index c71d37d..d7635ad 100644 --- a/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt +++ b/src/jsMain/kotlin/dev/inmo/jsuikit/utils/AttributesCollection.kt @@ -3,19 +3,22 @@ package dev.inmo.jsuikit.utils import dev.inmo.jsuikit.modifiers.UIKitModifier import dev.inmo.jsuikit.modifiers.include import org.jetbrains.compose.web.attributes.AttrsBuilder +import org.jetbrains.compose.web.attributes.InputType +import org.jetbrains.compose.web.attributes.builders.InputAttrsBuilder import org.jetbrains.compose.web.dom.AttrBuilderContext import org.w3c.dom.Element +import org.w3c.dom.HTMLInputElement -class AttributesCollection ( +class AttributesCollection> ( private vararg val modifiers: UIKitModifier, - private val attrs: AttrBuilderContext = {} + private val attrs: Builder.() -> Unit = {} ) { - val builder: AttrBuilderContext = { + val builder: Builder.() -> Unit = { include(*modifiers) attrs() } - operator fun plus(other: AttributesCollection) = AttributesCollection( + operator fun plus(other: AttributesCollection) = AttributesCollection( *(modifiers + other.modifiers).distinct().toTypedArray() ) { this@AttributesCollection.attrs.invoke(this) @@ -26,8 +29,9 @@ class AttributesCollection ( val Empty = Attrs() @Suppress("UNCHECKED_CAST") - fun empty() = Empty as Attrs + fun > empty() = Empty as AttributesCollection } } -typealias Attrs = AttributesCollection +typealias Attrs = AttributesCollection> +typealias InputAttrs = AttributesCollection>