aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/text
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-05-09 23:53:57 +0200
committerRobert Jaros <rjaros@finn.pl>2020-05-09 23:53:57 +0200
commit134cb687c4e05fd81a03b682505f9fb9d741a8d7 (patch)
treef9f41f28c01dc29d1d4fdd576cc9b21958fd9c3b /src/main/kotlin/pl/treksoft/kvision/form/text
parent4a2aa49e0e561c1bc25aa962449fa2fcce9207ba (diff)
downloadkvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.tar.gz
kvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.tar.bz2
kvision-134cb687c4e05fd81a03b682505f9fb9d741a8d7.zip
Add new className parameter to all DSL builder functions.
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/form/text')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt9
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt8
3 files changed, 14 insertions, 5 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt
index d887e814..8a5acf8b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/AbstractText.kt
@@ -113,7 +113,7 @@ abstract class AbstractText(label: String? = null, rich: Boolean = false) :
*/
protected val idc = "kv_form_text_$counter"
abstract override val input: AbstractTextInput
- final override val flabel: FieldLabel = FieldLabel(idc, label, rich)
+ final override val flabel: FieldLabel = FieldLabel(idc, label, rich, setOf("control-label"))
final override val invalidFeedback: InvalidFeedback = InvalidFeedback().apply { visible = false }
init {
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
index acad7853..9503a0b1 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
@@ -24,6 +24,7 @@ package pl.treksoft.kvision.form.text
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.utils.set
/**
* Basic textarea component.
@@ -41,10 +42,12 @@ open class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? =
* Number of columns.
*/
var cols by refreshOnUpdate(cols)
+
/**
* Number of rows.
*/
var rows by refreshOnUpdate(rows)
+
/**
* Determines if hard wrapping is enabled for the textarea element.
*/
@@ -77,10 +80,12 @@ open class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? =
* It takes the same parameters as the constructor of the built component.
*/
fun Container.textAreaInput(
- cols: Int? = null, rows: Int? = null, value: String? = null, classes: Set<String> = setOf(),
+ cols: Int? = null, rows: Int? = null, value: String? = null,
+ classes: Set<String>? = null,
+ className: String? = null,
init: (TextAreaInput.() -> Unit)? = null
): TextAreaInput {
- val textAreaInput = TextAreaInput(cols, rows, value, classes).apply { init?.invoke(this) }
+ val textAreaInput = TextAreaInput(cols, rows, value, classes ?: className.set).apply { init?.invoke(this) }
this.add(textAreaInput)
return textAreaInput
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
index d057dcbd..e50e1b30 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
@@ -24,6 +24,7 @@ package pl.treksoft.kvision.form.text
import com.github.snabbdom.VNode
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.StringPair
+import pl.treksoft.kvision.utils.set
/**
* Text input types.
@@ -53,6 +54,7 @@ open class TextInput(type: TextInputType = TextInputType.TEXT, value: String? =
* Text input type.
*/
var type by refreshOnUpdate(type)
+
/**
* Determines if autocomplete is enabled for the input element.
*/
@@ -85,10 +87,12 @@ open class TextInput(type: TextInputType = TextInputType.TEXT, value: String? =
* It takes the same parameters as the constructor of the built component.
*/
fun Container.textInput(
- type: TextInputType = TextInputType.TEXT, value: String? = null, classes: Set<String> = setOf(),
+ type: TextInputType = TextInputType.TEXT, value: String? = null,
+ classes: Set<String>? = null,
+ className: String? = null,
init: (TextInput.() -> Unit)? = null
): TextInput {
- val textInput = TextInput(type, value, classes).apply { init?.invoke(this) }
+ val textInput = TextInput(type, value, classes ?: className.set).apply { init?.invoke(this) }
this.add(textInput)
return textInput
}