blob: 5b8dd5b5004f28a29b2b676ddf71a79acb1c741c (
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
|
package pl.treksoft.kvision.form
import com.github.snabbdom.VNode
import pl.treksoft.kvision.snabbdom.StringPair
class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? = null, classes: Set<String> = setOf()) :
AbstractTextInput(value, classes) {
var cols: Int? = cols
set(value) {
field = value
refresh()
}
var rows: Int? = rows
set(value) {
field = value
refresh()
}
var wrapHard: Boolean = false
set(value) {
field = value
refresh()
}
override fun render(): VNode {
return value?.let {
kvh("textarea", arrayOf(it))
} ?: kvh("textarea")
}
override fun getSnAttrs(): List<StringPair> {
val sn = super.getSnAttrs().toMutableList()
cols?.let {
sn.add("cols" to ("" + it))
}
rows?.let {
sn.add("rows" to ("" + it))
}
if (wrapHard) {
sn.add("wrap" to "hard")
}
return sn
}
}
|