PopupComponent

open class PopupComponent : EventProperties<HTMLElement>

This component creates a popup.

A popup should be used to position content like tooltip or popover automatically in the right place near a trigger. It will pop(ped)up on every event which handledBy given handler.

A popup mainly consists of trigger the Elements which calls the content which will be display after call the trigger. It will be rendered on an own managed context.

It can be configured by

trigger provides two handlers which can be used within the trigger context:

  • The first is used to open/toggle the content.

  • The second closes it.

content provides only one close handler.

Example usage:

// tooltip alike behaviour: opens and closes by hovering the trigger with the mouse
popup {
trigger { toggle, close ->
span {
+"hover me"
mouseenters.map { it.currentTarget } handledBy toggle
mouseleaves.map { } handledBy close
}
}
content {
div { +"my content" }
}
// some positioning stuff
offset(10.0)
flipping(false)
placement { bottomEnd }
}

// popover alike behaviour: opens / closes by click; additional closing by click into popup content!
popup {
trigger { toggle, _ ->
span {
+"click me to toggle"
clicks.map { it.currentTarget } handledBy toggle
}
}
content { close ->
div { +"click me to close " }
clicks.map { } handledBy close
}
}

The popup uses an internal storepopupStore of TriggerInformation to find the right position of the content

See also

Constructors

PopupComponent
Link copied to clipboard
js
fun PopupComponent()

Types

Companion
Link copied to clipboard
js
object Companion

Functions

render
Link copied to clipboard
js
fun render(context: Tag<HTMLElement>, styling: BoxParams.() -> Unit, baseClass: StyleClass, id: String?, prefix: String): Div

Properties

content
Link copied to clipboard
js
val content: ComponentProperty<Tag<HTMLElement>.(SimpleHandler<Unit>) -> Unit?>
events
Link copied to clipboard
js
open override val events: ComponentProperty<EventContext<HTMLElement>.() -> Unit>
This property enables the client to access all events offered by the underlying HTML element.
flipping
Link copied to clipboard
js
val flipping: ComponentProperty<Boolean>
offset
Link copied to clipboard
js
val offset: ComponentProperty<Double>
Property for the offset between the trigger element and the popup itself.
placement
Link copied to clipboard
js
val placement: ComponentProperty<PlacementContext.() -> Placement>
trigger
Link copied to clipboard
js
val trigger: ComponentProperty<Tag<HTMLElement>.(SimpleHandler<EventTarget?>, SimpleHandler<Unit>) -> Unit?>