summaryrefslogtreecommitdiff
path: root/sw-ui-kt/src/main/kotlin/blueprintjsHelpers.kt
blob: 0d9cb9bd61433436f62b675aa13fdcafcb97c699 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.palantir.blueprintjs

import org.w3c.dom.events.Event
import org.w3c.dom.events.MouseEvent
import react.RBuilder
import react.RHandler
import react.ReactElement

typealias IconName = String

fun RBuilder.bpIcon(
    name: IconName,
    size: Int = Icon.SIZE_STANDARD,
    intent: Intent = Intent.NONE,
    title: String? = null,
    alt: String? = null,
    className: String? = null,
    block: RHandler<IIconProps> = {}
): ReactElement = child(Icon::class) {
    attrs {
        this.icon = name
        this.iconSize = size
        this.htmlTitle = title
        this.intent = intent
        this.title = alt
        this.className = className
    }
    block()
}

fun RBuilder.bpButton(
    minimal: Boolean = false,
    large: Boolean = false,
    disabled: Boolean = false,
    title: String? = null,
    icon: IconName? = null,
    rightIcon: IconName? = null,
    intent: Intent = Intent.NONE,
    onClick: ((event: MouseEvent) -> Unit)?,
    block: RHandler<IButtonProps> = {}
): ReactElement = child(Button::class) {
    attrs {
        this.title = title
        this.minimal = minimal
        this.large = large
        this.disabled = disabled
        this.icon = icon
        this.rightIcon = rightIcon
        this.intent = intent
        this.onClick = onClick
    }
    block()
}

fun RBuilder.bpInputGroup(
    large: Boolean = false,
    placeholder: String = "",
    rightElement: ReactElement? = null,
    onChange: (Event) -> Unit
): ReactElement = child(InputGroup::class) {
    attrs {
        this.large = large
        this.placeholder = placeholder
        this.rightElement = rightElement
        this.onChange = onChange
    }
}

fun RBuilder.bpTag(
    intent: Intent? = null,
    minimal: Boolean? = null,
    active: Boolean? = null,
    block: RHandler<ITagProps> = {}
): ReactElement = child(Tag::class) {
    attrs {
        this.intent = intent
        this.minimal = minimal
        this.active = active
    }
    block()
}
bgstack15