SelectFieldComponent

open class SelectFieldComponent<T>(items: List<T>, value: Store<T>?) : 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

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

Types

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

Functions

enabled
Link copied to clipboard
js
open override fun enabled(value: Boolean)
open override fun enabled(value: Flow<Boolean>)
render
Link copied to clipboard
js
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.
severity
Link copied to clipboard
js
open override fun severity(value: SeverityProperties.SeverityContext.() -> Severity)
Property to manage the severity value of the component.
severityClassOf
Link copied to clipboard
js
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.
tooltip
Link copied to clipboard
js
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

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