diff options
author | Joffrey Bion <joffrey.bion@booking.com> | 2020-06-02 01:57:00 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@booking.com> | 2020-06-02 01:57:00 +0200 |
commit | c3c651a43b162b1c4185233a83c755c9adbf8be3 (patch) | |
tree | bb045534f4a9f4d41e39af4e981b09df5526c394 /sw-ui/src/main/kotlin/com/palantir | |
parent | Remove useless createElement (diff) | |
download | seven-wonders-c3c651a43b162b1c4185233a83c755c9adbf8be3.tar.gz seven-wonders-c3c651a43b162b1c4185233a83c755c9adbf8be3.tar.bz2 seven-wonders-c3c651a43b162b1c4185233a83c755c9adbf8be3.zip |
Add blueprintjs Popover
Diffstat (limited to 'sw-ui/src/main/kotlin/com/palantir')
-rw-r--r-- | sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt | 127 | ||||
-rw-r--r-- | sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt | 30 |
2 files changed, 157 insertions, 0 deletions
diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt new file mode 100644 index 00000000..1c610579 --- /dev/null +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/BpPopover.kt @@ -0,0 +1,127 @@ +@file:JsModule("@blueprintjs/core") +package com.palantir.blueprintjs + +import org.w3c.dom.HTMLDivElement +import org.w3c.dom.events.Event +import react.PureComponent +import react.RState +import react.ReactElement + +external enum class PopoverInteractionKind { + CLICK, + CLICK_TARGET_ONLY, + HOVER, + HOVER_TARGET_ONLY +} + +external enum class PopoverPosition { + AUTO, + AUTO_END, + AUTO_START, + BOTTOM, + BOTTOM_LEFT, + BOTTOM_RIGHT, + LEFT, + LEFT_BOTTOM, + LEFT_TOP, + RIGHT, + RIGHT_BOTTOM, + RIGHT_TOP, + TOP, + TOP_LEFT, + TOP_RIGHT +} + +external interface IPopoverSharedProps : IOverlayableProps, IProps { + var boundary: Any? + get() = definedExternally + set(value) = definedExternally + var captureDismiss: Boolean? + get() = definedExternally + set(value) = definedExternally + var defaultIsOpen: Boolean? + get() = definedExternally + set(value) = definedExternally + var disabled: Boolean? + get() = definedExternally + set(value) = definedExternally + var hoverCloseDelay: Number? + get() = definedExternally + set(value) = definedExternally + var hoverOpenDelay: Number? + get() = definedExternally + set(value) = definedExternally + var inheritDarkTheme: Boolean? + get() = definedExternally + set(value) = definedExternally + var isOpen: Boolean? + get() = definedExternally + set(value) = definedExternally + var modifiers: Any? + get() = definedExternally + set(value) = definedExternally + var onInteraction: ((nextOpenState: Boolean, e: Event) -> Unit)? + get() = definedExternally + set(value) = definedExternally + var openOnTargetFocus: Boolean? + get() = definedExternally + set(value) = definedExternally + var popoverClassName: String? + get() = definedExternally + set(value) = definedExternally + var position: PopoverPosition? + get() = definedExternally + set(value) = definedExternally + var targetClassName: String? + get() = definedExternally + set(value) = definedExternally + var targetProps: Any? + get() = definedExternally + set(value) = definedExternally + var targetTagName: Any? + get() = definedExternally + set(value) = definedExternally + override var usePortal: Boolean? + get() = definedExternally + set(value) = definedExternally + var wrapperTagName: Any? + get() = definedExternally + set(value) = definedExternally +} + +external interface IPopoverProps : IPopoverSharedProps { + var backdropProps: Any? + get() = definedExternally + set(value) = definedExternally + var content: dynamic /* String? | JSX.Element? */ + get() = definedExternally + set(value) = definedExternally + var fill: Boolean? + get() = definedExternally + set(value) = definedExternally + var interactionKind: PopoverInteractionKind? + get() = definedExternally + set(value) = definedExternally + var hasBackdrop: Boolean? + get() = definedExternally + set(value) = definedExternally + var minimal: Boolean? + get() = definedExternally + set(value) = definedExternally + var popoverRef: ((ref: HTMLDivElement?) -> Unit)? + get() = definedExternally + set(value) = definedExternally + var target: dynamic /* String? | JSX.Element? */ + get() = definedExternally + set(value) = definedExternally +} + +external interface IPopoverState : RState { + var transformOrigin: String + var isOpen: Boolean + var hasDarkParent: Boolean +} + +open external class Popover : PureComponent<IPopoverProps, IPopoverState> { + override fun render(): ReactElement +} diff --git a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt index bf4df032..b7556360 100644 --- a/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt +++ b/sw-ui/src/main/kotlin/com/palantir/blueprintjs/blueprintjsHelpers.kt @@ -155,6 +155,36 @@ fun RBuilder.bpOverlay( block() } +fun RBuilder.bpPopover( + content: ReactElement, + hoverOpenDelay: Number? = null, + hoverCloseDelay: Number? = null, + position: PopoverPosition = PopoverPosition.AUTO, + interactionKind: PopoverInteractionKind = PopoverInteractionKind.HOVER, + minimal: Boolean = false, + canEscapeKeyClose: Boolean = true, + className: String? = null, + popoverClassName: String? = null, + portalClassName: String? = null, + onClose: () -> Unit = {}, + block: RHandler<IPopoverProps> = {} +): ReactElement = child(Popover::class) { + attrs { + this.interactionKind = interactionKind + this.minimal = minimal + this.content = content + this.position = position + this.hoverOpenDelay = hoverOpenDelay + this.hoverCloseDelay = hoverCloseDelay + this.canEscapeKeyClose = canEscapeKeyClose + this.className = className + this.popoverClassName = popoverClassName + this.portalClassName = portalClassName + this.onClose = { onClose() } + } + block() +} + fun RBuilder.bpCallout( intent: Intent? = Intent.NONE, icon: IconName? = null, |