aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2018-02-12 12:00:15 +0100
committerRobert Jaros <rjaros@finn.pl>2018-02-12 12:00:15 +0100
commiteea44b35add0d036119888f41e4ed38e75190934 (patch)
tree01ff2b73042ab08941df082d74241dc5e229a37d
parent4191287261b46b95908469c2ec3fa9d886681861 (diff)
downloadkvision-eea44b35add0d036119888f41e4ed38e75190934.tar.gz
kvision-eea44b35add0d036119888f41e4ed38e75190934.tar.bz2
kvision-eea44b35add0d036119888f41e4ed38e75190934.zip
DSL builders returning built components.
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/Widget.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt2
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt10
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt10
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Button.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Image.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Label.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Link.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/List.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/html/Tag.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/FlexPanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/GridPanel.kt14
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/HPanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/ResponsiveGridPanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/SimplePanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/SplitPanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/StackPanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/TabPanel.kt8
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/panel/VPanel.kt9
38 files changed, 190 insertions, 119 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
index 532a6bb7..f50b1679 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt
@@ -519,12 +519,14 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent() {
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
- fun Container.widget(classes: Set<String> = setOf(), init: (Widget.() -> Unit)? = null) {
- this.add(Widget(classes).apply { init?.invoke(this) })
+ fun Container.widget(classes: Set<String> = setOf(), init: (Widget.() -> Unit)? = null): Widget {
+ val widget = Widget(classes).apply { init?.invoke(this) }
+ this.add(widget)
+ return widget
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt b/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt
index 81765846..2616e77c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/core/WidgetWrapper.kt
@@ -56,7 +56,7 @@ open class WidgetWrapper(internal var wrapped: Component?, classes: Set<String>
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
@@ -64,8 +64,10 @@ open class WidgetWrapper(internal var wrapped: Component?, classes: Set<String>
wrapped: Component?,
classes: Set<String> = setOf(),
init: (WidgetWrapper.() -> Unit)? = null
- ) {
- this.add(WidgetWrapper(wrapped, classes).apply { init?.invoke(this) })
+ ): WidgetWrapper {
+ val widgetWrapper = WidgetWrapper(wrapped, classes).apply { init?.invoke(this) }
+ this.add(widgetWrapper)
+ return widgetWrapper
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
index fa545dc8..c008c47b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/data/DataContainer.kt
@@ -126,7 +126,7 @@ class DataContainer<M : DataComponent, C : Component>(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
@@ -135,8 +135,10 @@ class DataContainer<M : DataComponent, C : Component>(
binding: (Int) -> C,
child: Container = VPanel(),
init: (DataContainer<M, C>.() -> Unit)? = null
- ) {
- this.add(DataContainer(model, binding, child, init))
+ ): DataContainer<M, C> {
+ val dataContainer = DataContainer(model, binding, child, init)
+ this.add(dataContainer)
+ return dataContainer
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
index 1af71dc8..0f653d30 100644
--- a/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/dropdown/DropDown.kt
@@ -239,7 +239,7 @@ open class DropDown(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
@@ -247,8 +247,10 @@ open class DropDown(
text: String, elements: List<StringPair>? = null, icon: String? = null,
style: BUTTONSTYLE = BUTTONSTYLE.DEFAULT, disabled: Boolean = false,
classes: Set<String> = setOf(), init: (DropDown.() -> Unit)? = null
- ) {
- this.add(DropDown(text, elements, icon, style, disabled, classes).apply { init?.invoke(this) })
+ ): DropDown {
+ val dropDown = DropDown(text, elements, icon, style, disabled, classes).apply { init?.invoke(this) }
+ this.add(dropDown)
+ return dropDown
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
index 70c44fd7..75cb9c03 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/FormPanel.kt
@@ -218,7 +218,7 @@ open class FormPanel<K>(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
index 4c373a2d..7a8b5905 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckBox.kt
@@ -203,15 +203,17 @@ open class CheckBox(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.checkBox(
value: Boolean = false, label: String? = null,
rich: Boolean = false, init: (CheckBox.() -> Unit)? = null
- ) {
- this.add(CheckBox(value, label, rich).apply { init?.invoke(this) })
+ ): CheckBox {
+ val checkBox = CheckBox(value, label, rich).apply { init?.invoke(this) }
+ this.add(checkBox)
+ return checkBox
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
index 8d083b42..46e5395c 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/CheckInput.kt
@@ -183,15 +183,17 @@ open class CheckInput(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.checkInput(
type: CHECKINPUTTYPE = CHECKINPUTTYPE.CHECKBOX, value: Boolean = false,
classes: Set<String> = setOf(), init: (CheckInput.() -> Unit)? = null
- ) {
- this.add(CheckInput(type, value, classes).apply { init?.invoke(this) })
+ ): CheckInput {
+ val checkInput = CheckInput(type, value, classes).apply { init?.invoke(this) }
+ this.add(checkInput)
+ return checkInput
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
index 13f4c4cd..ef5d6eb9 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/Radio.kt
@@ -223,15 +223,17 @@ open class Radio(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.radio(
value: Boolean = false, extraValue: String? = null, name: String? = null, label: String? = null,
rich: Boolean = false, init: (Radio.() -> Unit)? = null
- ) {
- this.add(Radio(value, extraValue, name, label, rich).apply { init?.invoke(this) })
+ ): Radio {
+ val radio = Radio(value, extraValue, name, label, rich).apply { init?.invoke(this) }
+ this.add(radio)
+ return radio
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
index 80736d59..c7eb5a22 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt
@@ -167,15 +167,17 @@ open class RadioGroup(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.radioGroup(
options: List<StringPair>? = null, value: String? = null, inline: Boolean = false,
label: String? = null, rich: Boolean = false, init: (RadioGroup.() -> Unit)? = null
- ) {
- this.add(RadioGroup(options, value, inline, label, rich).apply { init?.invoke(this) })
+ ): RadioGroup {
+ val radioGroup = RadioGroup(options, value, inline, label, rich).apply { init?.invoke(this) }
+ this.add(radioGroup)
+ return radioGroup
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
index dc55dd04..2e9b5562 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/Select.kt
@@ -274,7 +274,7 @@ open class Select(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
@@ -282,8 +282,10 @@ open class Select(
options: List<StringPair>? = null, value: String? = null,
multiple: Boolean = false, ajaxOptions: AjaxOptions? = null, label: String? = null,
rich: Boolean = false, init: (Select.() -> Unit)? = null
- ) {
- this.add(Select(options, value, multiple, ajaxOptions, label, rich).apply { init?.invoke(this) })
+ ): Select {
+ val select = Select(options, value, multiple, ajaxOptions, label, rich).apply { init?.invoke(this) }
+ this.add(select)
+ return select
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
index be986f02..f90401ce 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/select/SelectInput.kt
@@ -388,7 +388,7 @@ open class SelectInput(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
@@ -396,8 +396,10 @@ open class SelectInput(
options: List<StringPair>? = null, value: String? = null,
multiple: Boolean = false, ajaxOptions: AjaxOptions? = null,
classes: Set<String> = setOf(), init: (SelectInput.() -> Unit)? = null
- ) {
- this.add(SelectInput(options, value, multiple, ajaxOptions, classes).apply { init?.invoke(this) })
+ ): SelectInput {
+ val selectInput = SelectInput(options, value, multiple, ajaxOptions, classes).apply { init?.invoke(this) }
+ this.add(selectInput)
+ return selectInput
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
index 2a5d2cbe..3cd50473 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
@@ -240,7 +240,7 @@ open class Spinner(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
@@ -249,12 +249,14 @@ open class Spinner(
decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL,
forceType: FORCETYPE = FORCETYPE.NONE, label: String? = null,
rich: Boolean = false, init: (Spinner.() -> Unit)? = null
- ) {
- this.add(Spinner(value, min, max, step, decimals, buttonsType, forceType, label, rich).apply {
+ ): Spinner {
+ val spinner = Spinner(value, min, max, step, decimals, buttonsType, forceType, label, rich).apply {
init?.invoke(
this
)
- })
+ }
+ this.add(spinner)
+ return spinner
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
index 6dcb2b4a..a3f72b75 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
@@ -342,7 +342,7 @@ open class SpinnerInput(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
@@ -351,12 +351,14 @@ open class SpinnerInput(
decimals: Int = 0, buttonsType: BUTTONSTYPE = BUTTONSTYPE.VERTICAL,
forceType: FORCETYPE = FORCETYPE.NONE, classes: Set<String> = setOf(),
init: (SpinnerInput.() -> Unit)? = null
- ) {
- this.add(SpinnerInput(value, min, max, step, decimals, buttonsType, forceType, classes).apply {
+ ): SpinnerInput {
+ val spinnerInput = SpinnerInput(value, min, max, step, decimals, buttonsType, forceType, classes).apply {
init?.invoke(
this
)
- })
+ }
+ this.add(spinnerInput)
+ return spinnerInput
}
}
}
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 39c9a306..e2f9ab93 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Password.kt
@@ -37,14 +37,16 @@ open class Password(value: String? = null, label: String? = null, rich: Boolean
) {
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.password(
value: String? = null, label: String? = null, rich: Boolean = false, init: (Password.() -> Unit)? = null
- ) {
- this.add(Password(value, label, rich).apply { init?.invoke(this) })
+ ): Password {
+ val password = Password(value, label, rich).apply { init?.invoke(this) }
+ this.add(password)
+ return password
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt
index 9d5c8c49..953fec90 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichText.kt
@@ -56,14 +56,16 @@ open class RichText(
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.richText(
value: String? = null, label: String? = null, rich: Boolean = false, init: (RichText.() -> Unit)? = null
- ) {
- this.add(RichText(value, label, rich).apply { init?.invoke(this) })
+ ): RichText {
+ val richText = RichText(value, label, rich).apply { init?.invoke(this) }
+ this.add(richText)
+ return richText
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
index f802cc2a..9e6e61b0 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt
@@ -112,14 +112,16 @@ open class RichTextInput(value: String? = null, classes: Set<String> = setOf())
companion object {
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.richTextInput(
value: String? = null, classes: Set<String> = setOf(), init: (RichTextInput.() -> Unit)? = null
- ) {
- this.add(RichTextInput(value, classes).apply { init?.invoke(this) })
+ ): RichTextInput {
+ val richTextInput = RichTextInput(value, classes).apply { init?.invoke(this) }
+ this.add(richTextInput)
+ return richTextInput
}
}
}
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 2878dc66..ac9d0d9b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/Text.kt
@@ -65,15 +65,17 @@ open class Text(
companion object {
/**
- * DSL builder extension function
+ * 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,
label: String? = null, rich: Boolean = false, init: (Text.() -> Unit)? = null
- ) {
- this.add(Text(type, value, label, rich).apply { init?.invoke(this) })
+ ): Text {
+ val text = Text(type, value, 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 e9575264..58f63028 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextArea.kt
@@ -74,15 +74,17 @@ open class TextArea(
companion object {
/**
- * DSL builder extension function
+ * 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,
label: String? = null, rich: Boolean = false, init: (TextArea.() -> Unit)? = null
- ) {
- this.add(TextArea(cols, rows, value, label, rich).apply { init?.invoke(this) })
+ ): TextArea {
+ val textArea = TextArea(cols, rows, value, 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 64e0f17d..8ee150e1 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextAreaInput.kt
@@ -84,15 +84,17 @@ open class TextAreaInput(cols: Int? = null, rows: Int? = null, value: String? =
companion object {
/**
- * DSL builder extension function
+ * 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
- ) {
- this.add(TextAreaInput(cols, rows, value, classes).apply { init?.invoke(this) })
+ ): 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 cc443aa5..a2bfcd0b 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/text/TextInput.kt
@@ -88,15 +88,17 @@ open class TextInput(type: TEXTINPUTTYPE = TEXTINPUTTYPE.TEXT, value: String? =
companion object {
/**
- * DSL builder extension function
+ * 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
- ) {
- this.add(TextInput(type, value, classes).apply { init?.invoke(this) })
+ ): TextInput {
+ val textInput = TextInput(type, value, classes).apply { init?.invoke(this) }
+ this.add(textInput)
+ return textInput
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
index 34ea98ce..29cb664d 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTime.kt
@@ -236,15 +236,17 @@ open class DateTime(
internal var counter = 0
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.dateTime(
value: Date? = null, format: String = "YYYY-MM-DD HH:mm", label: String? = null,
rich: Boolean = false, init: (DateTime.() -> Unit)? = null
- ) {
- this.add(DateTime(value, format, label, rich).apply { init?.invoke(this) })
+ ): DateTime {
+ val dateTime = DateTime(value, format, label, rich).apply { init?.invoke(this) }
+ this.add(dateTime)
+ return dateTime
}
}
}
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
index 0556f2ef..c198ec77 100644
--- a/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
+++ b/src/main/kotlin/pl/treksoft/kvision/form/time/DateTimeInput.kt
@@ -312,15 +312,17 @@ open class DateTimeInput(
}
/**
- * DSL builder extension function
+ * DSL builder extension function.
*
* It takes the same parameters as the constructor of the built component.
*/
fun Container.dateTimeInput(
value: Date? = null, format: String = "YYYY-MM-DD HH:mm", classes: Set<String> = setOf(),
init: (DateTimeInput.() -> Unit)? = null
- ) {
- this.add(DateTimeInput(value, format, classes).apply { init?.invoke(this) })
+ ): DateTimeInput {
+ val dateTimeInput