SelectFieldComponent

open class SelectFieldComponent<T>(items: List<T>, value: Store<T>? = null) : Component<Label> , InputFormProperties, SeverityProperties, TooltipProperties

This class manages the configuration and rendering of a selectField.

This class offers the following configuration aspects:

  • element size

  • placeholder text

  • icon

  • predefined styling variants

  • the text which is shown -> label

  • disabling the element

The functional expression build, which is the last parameter of the factory function, offers an initialized instance of this SelectFieldComponent class as receiver, so every mutating method can be called for configuring the desired state for rendering the selectField.

Example usage

val myOptions = listOf("black", "red", "yellow")
val selectedItem = storeOf(myOptions[0]) // preselect "red"
selectField (items = myOptions, value = selectedItem) {
}

Preselect nothing and set a placeholder text:

val myOptions = listOf("black", "red", "yellow")
val selectedItem = storeOf<String?>(null)
selectField (items = myOptions, value = selectedItem) {
placeholder("My Placeholder") // will be shown until some item is selected!
}

Customize the appearance:

selectField (items = myOptions, value = selectedItem) {
icon { fromTheme { circleAdd } }
size { large }
variant { flushed }
}

Set a specific label:

val persons = listOf(Person("John Doe", 37), Person("Jane Doe", 35))
val selectedItem = storeOf(persons[0])
selectField(items = persons, value = selectedItem) {
label { it.name } // pass a lambda expression to create a label string of an specific type
}

Constructors

Link copied to clipboard
fun <T> SelectFieldComponent(items: List<T>, value: Store<T>? = null)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class EventsContext<T>(element: Tag<HTMLElement>, val selected: Flow<T>) : EventContext<HTMLElement>

Functions

Link copied to clipboard
open override fun enabled(value: Boolean)
open override fun enabled(value: Flow<Boolean>)
Link copied to clipboard
open override fun render(    context: RenderContext,     styling: BoxParams.() -> Unit,     baseClass: StyleClass,     id: String?,     prefix: String): Label

Central method that should do the actual rendering of a component.

Link copied to clipboard
open override fun severity(value: SeverityProperties.SeverityContext.() -> Severity)

Property to manage the severity value of the component.

Link copied to clipboard
open override fun severityClassOf(severityStyle: SeverityStyles): Flow<StyleClass>

This function manages the task to map a value of the Severity enumeration to a corresponding style defined within the SeverityStyles interface. The severity itself is taken from the severity property, so only the styling interface's implementation has to be injected:

Link copied to clipboard
open override fun tooltip(vararg text: String, build: TooltipComponent.() -> Unit)
open override fun tooltip(    styling: BasicParams.() -> Unit,     text: String?,     baseClass: StyleClass,     id: String,     prefix: String,     build: TooltipComponent.() -> Unit)

Properties

Link copied to clipboard
open override val disabled: DynamicComponentProperty<Boolean>
Link copied to clipboard
val events: ComponentProperty<SelectFieldComponent.EventsContext<T>.() -> Unit>
Link copied to clipboard
val icon: ComponentProperty<Icons.() -> IconDefinition>
Link copied to clipboard
val iconStyle: Style<BasicParams>
Link copied to clipboard
val iconWrapperStyle: Style<BasicParams>
Link copied to clipboard
val label: ComponentProperty<(T) -> String>
Link copied to clipboard
val placeholder: ComponentProperty<String>
Link copied to clipboard
open override val readonly: DynamicComponentProperty<Boolean>
Link copied to clipboard
open override val renderTooltip: ComponentProperty<Tag<HTMLElement>.() -> Unit>
Link copied to clipboard
val selectedItem: NullableDynamicComponentProperty<T>
Link copied to clipboard
open override val severity: NullableDynamicComponentProperty<Severity?>
Link copied to clipboard
val size: ComponentProperty<FormSizesStyles.() -> Style<BasicParams>>
Link copied to clipboard
val variant: ComponentProperty<SelectFieldVariants.() -> Style<BasicParams>>