aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/pl/treksoft/kvision/form/text
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-10-17 21:58:34 +0200
committerRobert Jaros <rjaros@finn.pl>2019-10-17 21:58:34 +0200
commit736b80835f67c9c34657074ebcfbe0752bef1c18 (patch)
tree82d1e18a9ec07692dfe5dd31f470b842a9950a89 /src/main/kotlin/pl/treksoft/kvision/form/text
parent53b325d52208bfd44ba6a524ce3dda5379aed699 (diff)
downloadkvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.gz
kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.tar.bz2
kvision-736b80835f67c9c34657074ebcfbe0752bef1c18.zip
Move DSL builder functions out of the companion objects (#93)
Diffstat (limited to 'src/main/kotlin/pl/treksoft/kvision/form/text')
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt36
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt28
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt28
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt28
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt28
5 files changed, 69 insertions, 79 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
index 1d36516e..eb86f152 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
@@ -35,23 +35,21 @@ import pl.treksoft.kvision.core.Container
open class Password(value: String? = null, name: String? = null, label: String? = null, rich: Boolean = false) : Text(
TextInputType.PASSWORD,
value, name, label, rich
-) {
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.password(
- value: String? = null,
- name: String? = null,
- label: String? = null,
- rich: Boolean = false,
- init: (Password.() -> Unit)? = null
- ): Password {
- val password = Password(value, name, label, rich).apply { init?.invoke(this) }
- this.add(password)
- return password
- }
- }
+)
+
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.password(
+ value: String? = null,
+ name: String? = null,
+ label: String? = null,
+ rich: Boolean = false,
+ init: (Password.() -> Unit)? = null
+): Password {
+ val password = Password(value, name, label, rich).apply { init?.invoke(this) }
+ this.add(password)
+ return password
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
index f493b06e..32fc1881 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
@@ -66,20 +66,18 @@ open class Text(
this.addInternal(input)
this.addInternal(invalidFeedback)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.text(
- type: TextInputType = TextInputType.TEXT, value: String? = null, name: String? = null,
- label: String? = null, rich: Boolean = false, init: (Text.() -> Unit)? = null
- ): Text {
- val text = Text(type, value, name, label, rich).apply { init?.invoke(this) }
- this.add(text)
- return text
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.text(
+ type: TextInputType = TextInputType.TEXT, value: String? = null, name: String? = null,
+ label: String? = null, rich: Boolean = false, init: (Text.() -> Unit)? = null
+): Text {
+ val text = Text(type, value, name, label, rich).apply { init?.invoke(this) }
+ this.add(text)
+ return text
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
index ccf17892..47b6870c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
@@ -75,20 +75,18 @@ open class TextArea(
this.addInternal(input)
this.addInternal(invalidFeedback)
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * It takes the same parameters as the constructor of the built component.
- */
- fun Container.textArea(
- cols: Int? = null, rows: Int? = null, value: String? = null, name: String? = null,
- label: String? = null, rich: Boolean = false, init: (TextArea.() -> Unit)? = null
- ): TextArea {
- val textArea = TextArea(cols, rows, value, name, label, rich).apply { init?.invoke(this) }
- this.add(textArea)
- return textArea
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * It takes the same parameters as the constructor of the built component.
+ */
+fun Container.textArea(
+ cols: Int? = null, rows: Int? = null, value: String? = null, name: String? = null,
+ label: String? = null, rich: Boolean = false, init: (TextArea.() -> Unit)? = null
+): TextArea {
+ val textArea = TextArea(cols, rows, value, name, label, rich).apply { init?.invoke(this) }
+ this.add(textArea)
+ return textArea
}
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 9fc89544..acad7853 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
@@ -69,20 +69,18 @@ open class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? =
}
return sn
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * 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(),
- init: (TextAreaInput.() -> Unit)? = null
- ): TextAreaInput {
- val textAreaInput = TextAreaInput(cols, rows, value, classes).apply { init?.invoke(this) }
- this.add(textAreaInput)
- return textAreaInput
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * 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(),
+ init: (TextAreaInput.() -> Unit)? = null
+): TextAreaInput {
+ val textAreaInput = TextAreaInput(cols, rows, value, classes).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 bc6e178d..d057dcbd 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
@@ -77,20 +77,18 @@ open class TextInput(type: TextInputType = TextInputType.TEXT, value: String? =
}
return sn
}
+}
- companion object {
- /**
- * DSL builder extension function.
- *
- * 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(),
- init: (TextInput.() -> Unit)? = null
- ): TextInput {
- val textInput = TextInput(type, value, classes).apply { init?.invoke(this) }
- this.add(textInput)
- return textInput
- }
- }
+/**
+ * DSL builder extension function.
+ *
+ * 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(),
+ init: (TextInput.() -> Unit)? = null
+): TextInput {
+ val textInput = TextInput(type, value, classes).apply { init?.invoke(this) }
+ this.add(textInput)
+ return textInput
}