aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-bootstrap-spinner/src
diff options
context:
space:
mode:
Diffstat (limited to 'kvision-modules/kvision-bootstrap-spinner/src')
-rw-r--r--kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt13
-rw-r--r--kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt10
2 files changed, 13 insertions, 10 deletions
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
index b841b16c..69d9410b 100644
--- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
+++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/Spinner.kt
@@ -48,7 +48,7 @@ import pl.treksoft.kvision.utils.SnOn
* @param rich determines if [label] can contain HTML code
*/
open class Spinner(
- value: Number? = null, name: String? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP,
+ value: Number? = null, name: String? = null, min: Number? = null, max: Number? = null, step: Number = DEFAULT_STEP,
decimals: Int = 0, val buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null, label: String? = null,
rich: Boolean = false
@@ -206,7 +206,10 @@ open class Spinner(
return this
}
- @Deprecated("Use onEvent extension function instead.", ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent"))
+ @Deprecated(
+ "Use onEvent extension function instead.",
+ ReplaceWith("onEvent(block)", "pl.treksoft.kvision.core.onEvent")
+ )
override fun setEventListener(block: SnOn<Widget>.() -> Unit): Widget {
@Suppress("DEPRECATION")
input.setEventListener(block)
@@ -268,9 +271,9 @@ open class Spinner(
fun Container.spinner(
value: Number? = null,
name: String? = null,
- min: Int? = null,
- max: Int? = null,
- step: Double = DEFAULT_STEP,
+ min: Number? = null,
+ max: Number? = null,
+ step: Number = DEFAULT_STEP,
decimals: Int = 0,
buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE,
diff --git a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
index c68df816..3a52fed2 100644
--- a/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
+++ b/kvision-modules/kvision-bootstrap-spinner/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt
@@ -52,7 +52,7 @@ enum class ForceType(internal val value: String) {
CEIL("ceil")
}
-internal const val DEFAULT_STEP = 1.0
+internal const val DEFAULT_STEP = 1
/**
* The basic component for spinner control.
@@ -70,7 +70,7 @@ internal const val DEFAULT_STEP = 1.0
*/
@Suppress("TooManyFunctions")
open class SpinnerInput(
- value: Number? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP,
+ value: Number? = null, min: Number? = null, max: Number? = null, step: Number = DEFAULT_STEP,
decimals: Int = 0, val buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null,
classes: Set<String> = setOf()
@@ -210,8 +210,8 @@ open class SpinnerInput(
if (v != null && v.isNotEmpty()) {
this.value = v.toDoubleOrNull()
this.value?.let {
- if (min != null && it.toInt() < min ?: 0) this.value = min
- if (max != null && it.toInt() > max ?: 0) this.value = max
+ if (min != null && it.toDouble() < (min?.toDouble() ?: 0.0)) this.value = min
+ if (max != null && it.toDouble() > (max?.toDouble() ?: 0.0)) this.value = max
}
} else {
this.value = null
@@ -321,7 +321,7 @@ open class SpinnerInput(
* It takes the same parameters as the constructor of the built component.
*/
fun Container.spinnerInput(
- value: Number? = null, min: Int? = null, max: Int? = null, step: Double = DEFAULT_STEP,
+ value: Number? = null, min: Number? = null, max: Number? = null, step: Number = DEFAULT_STEP,
decimals: Int = 0, buttonsType: ButtonsType = ButtonsType.VERTICAL,
forceType: ForceType = ForceType.NONE, buttonStyle: ButtonStyle? = null, classes: Set<String> = setOf(),
init: (SpinnerInput.() -> Unit)? = null