2022-01-12 13:58:52 +00:00
|
|
|
package dev.inmo.jsuikit.modifiers
|
2021-12-22 08:38:12 +00:00
|
|
|
|
2022-04-15 07:06:14 +00:00
|
|
|
import dev.inmo.jsuikit.types.DropdownOptions
|
|
|
|
import dev.inmo.jsuikit.utils.Milliseconds
|
|
|
|
import dev.inmo.jsuikit.utils.buildAttribute
|
|
|
|
|
2021-12-22 08:38:12 +00:00
|
|
|
sealed class UIKitDropdown(classname: String) : UIKitModifier {
|
|
|
|
override val classes: Array<String> = arrayOf(classname)
|
|
|
|
|
|
|
|
object Nav : UIKitDropdown("uk-dropdown-nav")
|
|
|
|
|
|
|
|
object Grid : UIKitDropdown("uk-dropdown-grid")
|
|
|
|
|
2022-01-12 10:33:46 +00:00
|
|
|
sealed class Position(name: String) : AttributeValue(name) {
|
2021-12-22 08:38:12 +00:00
|
|
|
|
|
|
|
sealed class Bottom(name: String) : Position("bottom-$name") {
|
|
|
|
|
|
|
|
object Left : Bottom("left")
|
|
|
|
object Center : Bottom("center")
|
|
|
|
object Right : Bottom("right")
|
|
|
|
object Justify : Bottom("justify")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sealed class Top(name: String) : Position("top-$name") {
|
|
|
|
|
|
|
|
object Left : Top("left")
|
|
|
|
object Center : Top("center")
|
|
|
|
object Right : Top("right")
|
|
|
|
object Justify : Top("justify")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sealed class Left(name: String) : Position("left-$name") {
|
|
|
|
|
|
|
|
object Top : Left("top")
|
|
|
|
object Center : Left("center")
|
|
|
|
object Bottom : Left("bottom")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
sealed class Right(name: String) : Position("right-$name") {
|
|
|
|
|
|
|
|
object Top : Right("top")
|
|
|
|
object Center : Right("center")
|
|
|
|
object Bottom : Right("bottom")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-12 10:33:46 +00:00
|
|
|
sealed class Mode(name: String) : AttributeValue(name) {
|
2021-12-22 08:38:12 +00:00
|
|
|
|
|
|
|
object Click : Mode("click")
|
|
|
|
object Hover : Mode("hover")
|
|
|
|
|
2022-03-30 15:08:29 +00:00
|
|
|
object None : Mode("")
|
|
|
|
object HoverAndClick : Mode("$Hover, $Click")
|
|
|
|
|
2021-12-22 08:38:12 +00:00
|
|
|
}
|
|
|
|
|
2022-01-12 10:33:46 +00:00
|
|
|
sealed class Flip(name: String) : AttributeValue(name) {
|
2021-12-22 08:38:12 +00:00
|
|
|
|
|
|
|
object True : Flip("true")
|
|
|
|
object False : Flip("false")
|
|
|
|
object X : Flip("x")
|
|
|
|
object Y : Flip("y")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-04-15 07:06:14 +00:00
|
|
|
class Custom(
|
|
|
|
dropdownOptions: DropdownOptions
|
|
|
|
) : UIKitDropdown("uk-dropdown") {
|
|
|
|
override val otherAttrs: Map<String, String> = mapOf(
|
|
|
|
buildAttribute(
|
|
|
|
"uk-dropdown"
|
|
|
|
) {
|
|
|
|
dropdownOptions.includeParameters(this)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
operator fun invoke(
|
|
|
|
dropdownOptions: DropdownOptions
|
|
|
|
) = Custom(dropdownOptions)
|
|
|
|
operator fun invoke(
|
|
|
|
toggle: String? = null,
|
|
|
|
pos: Position? = null,
|
|
|
|
mode: Mode? = null,
|
|
|
|
delayShow: Milliseconds? = null,
|
|
|
|
delayHide: Milliseconds? = null,
|
|
|
|
boundary: String? = null,
|
|
|
|
boundaryAlign: Boolean? = null,
|
|
|
|
flip: Flip? = null,
|
|
|
|
offset: Int? = null,
|
|
|
|
animation: UIKitAnimation? = null,
|
|
|
|
duration: Milliseconds? = null,
|
|
|
|
) = Custom(
|
|
|
|
DropdownOptions(
|
|
|
|
toggle = toggle,
|
|
|
|
pos = pos,
|
|
|
|
mode = mode,
|
|
|
|
delayShow = delayShow,
|
|
|
|
delayHide = delayHide,
|
|
|
|
boundary = boundary,
|
|
|
|
boundaryAlign = boundaryAlign,
|
|
|
|
flip = flip,
|
|
|
|
offset = offset,
|
|
|
|
animation = animation,
|
|
|
|
duration = duration
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
2021-12-22 08:38:12 +00:00
|
|
|
}
|