CheckboxGroupComponent

open class CheckboxGroupComponent<T>(items: List<T>, values: Store<List<T>>?) : Component<Div> , InputFormProperties, SeverityProperties, OrientationProperty, TooltipProperties

This class combines the configuration and the core styling of a checkbox group. The rendering itself is also done within the companion object.

In order to render a checkbox group use the checkboxGroup factory function!

This class offers the following configuration features:

  • the items as a List

  • the preselected items via a Flow>

  • the label(mapping) static or dynamic via a Flow or customized content see the examples below

  • some predefined styling variants (size)

  • the style of the items (checkbox)

  • the style checked state

  • the style of the label

  • the checked icon ( use our icon library of our theme)

  • choose the orientation of checkbox elements (vertical or horizontal)

This can be done within a functional expression that is the last parameter of the factory function, called build. It offers an initialized instance of this CheckboxGroupComponent class as receiver, so every mutating method can be called for configuring the desired state for rendering the checkbox.

Example usage

// simple use case showing the core functionality
val options = listOf("A", "B", "C")
val myStore = storeOf<List<String>>(emptyList())
checkboxGroup(items = options, values = myStore) {
}

// one can handle the events and preselected item also manually if needed:
val options = listOf("A", "B", "C")
checkboxGroup(items = options) {
selectedItems(options.skip(1)) // for selecting "B" and "C" or an empty list (default)
// if nothing should be selected at all
events {
selected handledBy someStoreOfString
}
}

// use case showing some styling options and a complex data type
val myPairs = listOf(
(1 to "ffffff"),
(2 to "rrrrrr"),
(3 to "iiiiii"),
(4 to "tttttt"),
(5 to "zzzzzz"),
(6 to "222222")
)
val myStore = storeOf<List<Pair<Int,String>>(emptyList())
checkboxGroup(items = myPairs, values = myStore) {
label { it.second } // adjust label representation to specific model characteristics
size { large }
checkedStyle {
background { color {"green"} }
}
}

// use custom layouts for the checkbox labels by specifying a label-renderer:
val options = listOf("A", "B", "C")
checkboxGroup(items = options) {
labelRendering { item ->
span({
fontFamily { mono }
background {
color { primary.highlight }
}
}) {
+item
}
}
}

Constructors

Link copied to clipboard
fun <T> CheckboxGroupComponent(items: List<T>, values: Store<List<T>>?)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class EventsContext<T>(element: Tag<HTMLElement>, val selected: Flow<List<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): Div

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
val checkedStyle: ComponentProperty<Style<BasicParams>>
Link copied to clipboard
open override val disabled: DynamicComponentProperty<Boolean>
Link copied to clipboard
val events: ComponentProperty<CheckboxGroupComponent.EventsContext<T>.() -> Unit>
Link copied to clipboard
val icon: ComponentProperty<Icons.() -> IconDefinition>
Link copied to clipboard
val itemStyle: ComponentProperty<Style<BasicParams>>
Link copied to clipboard
val label: ComponentProperty<(T) -> String>
Link copied to clipboard
val labelRendering: ComponentProperty<RenderContext.(T) -> Unit>
Link copied to clipboard
var labelStyle: ComponentProperty<Style<BasicParams>>
Link copied to clipboard
open override val orientation: ComponentProperty<OrientationContext.() -> Orientation>
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 selectedItems: DynamicComponentProperty<List<T>>
Link copied to clipboard
open override val severity: NullableDynamicComponentProperty<Severity?>
Link copied to clipboard
val size: ComponentProperty<FormSizesStyles.() -> Style<BasicParams>>